Commit Graph

20284 Commits

Author SHA1 Message Date
Tom Lane 27cc7db660 Rewrite interval_hash() so that the hashcodes are equal for values that
interval_eq() considers equal.  I'm not sure how that fundamental requirement
escaped us through multiple revisions of this hash function, but there it is;
it's been wrong since interval_hash was first written for PG 7.1.
Per bug #4748 from Roman Kononov.

Backpatch to all supported releases.

This patch changes the contents of hash indexes for interval columns.  That's
no particular problem for PG 8.4, since we've broken on-disk compatibility
of hash indexes already; but it will require a migration warning note in
the next minor releases of all existing branches: "if you have any hash
indexes on columns of type interval, REINDEX them after updating".
2009-04-04 04:53:58 +00:00
Tom Lane 8d1c2ca390 Fix contrib/pgstattuple and contrib/pageinspect to prevent attempts to read
temporary tables of other sessions; that is unsafe because of the way our
buffer management works.  Per report from Stuart Bishop.
This is redundant with the bufmgr.c checks in HEAD, but not at all redundant
in the back branches.
2009-03-31 22:56:18 +00:00
Magnus Hagander 9350a4ce20 Don't crash initdb when we fail to get the current username.
Give an error message and exit instead, like we do elsewhere...

Per report from Wez Furlong and Robert Treat.
2009-03-31 18:58:20 +00:00
Marc G. Fournier d60fdd2502 tag 8.0.21 2009-03-13 02:30:37 +00:00
Tom Lane d92059fe9f Update back-branch release notes. 2009-03-12 22:36:33 +00:00
Tom Lane c62b17c874 Fix core dump due to null-pointer dereference in to_char() when datetime
format codes are misapplied to a numeric argument.  (The code still produces
a pretty bogus error message in such cases, but I'll settle for stopping the
crash for now.)  Per bug #4700 from Sergey Burladyan.

Problem exists in all supported branches, so patch all the way back.
In HEAD, also clean up some ugly coding in the nearby cache management
code.
2009-03-12 00:53:56 +00:00
Heikki Linnakangas feee205a3c Add MUST (Mauritius Island Summer Time) to the list of known abbreviations.
Mauritius began using DST in the summer 2008-2009; the Olson library has been
updated already.

Xavier Bugaud
2009-03-05 14:29:12 +00:00
Tom Lane 3694e3ed17 Put back our old workaround for machines that declare cbrt() in math.h but
fail to provide the function itself.  Not sure how we escaped testing anything
later than 7.3 on such cases, but they still exist, as per André Volpato's
report about AIX 5.3.
2009-03-04 22:08:46 +00:00
Tom Lane d2fda36128 Ooops ... fix some confusion between gettext() and _() in my previous patch.
This has moved around in past releases, so just copying-and-pasting from HEAD
didn't work as intended.
2009-03-03 00:17:36 +00:00
Tom Lane 40df3efa76 When we are in error recursion trouble, arrange to suppress translation and
encoding conversion of any elog/ereport message being sent to the frontend.
This generalizes a patch that I put in last October, which suppressed
translation of only specific messages known to be associated with recursive
can't-translate-the-message behavior.  As shown in bug #4680, we need a more
general answer in order to have some hope of coping with broken encoding
conversion setups.  This approach seems a good deal less klugy anyway.

Patch in all supported branches.
2009-03-02 21:19:14 +00:00
Tom Lane 5f1f0db872 Fix buffer allocations in encoding conversion routines so that they won't
fail on zero-length inputs.  This isn't an issue in normal use because the
conversion infrastructure skips calling the converters for empty strings.
However a problem was created by yesterday's patch to check whether the
right conversion function is supplied in CREATE CONVERSION.  The most
future-proof fix seems to be to make the converters safe for this corner case.
2009-02-28 18:50:14 +00:00
Heikki Linnakangas 64deed0dba In CREATE CONVERSION, test that the given function is a valid conversion
function for the specified source and destination encodings. We do that by
calling the function with an empty string. If it can't perform the requested
conversion, it will throw an error.

Backport to 7.4 - 8.3. Per bug report #4680 by Denis Afonin.
2009-02-27 16:35:47 +00:00
Marc G. Fournier 287e6acae8 commit first then tag 8.0.20 2009-01-30 04:59:15 +00:00
Tom Lane e4f5645d72 Update back-branch release notes. 2009-01-30 00:38:14 +00:00
Peter Eisentraut 4919f74177 Translation updates 2009-01-29 22:04:05 +00:00
Tom Lane fba3896cb4 Update time zone data files to tzdata release 2009a: introduces Asia/Kathmandu
as the preferred spelling of that zone name, corrects historical DST
information for Switzerland and Cuba.
2009-01-29 20:00:32 +00:00
Tom Lane 7612c1d813 Replace argument-checking Asserts with regular test-and-elog checks in all
encoding conversion functions.  These are not can't-happen cases because
it's possible to create a conversion with the wrong conversion function
for the specified encoding pair.  That would lead to an Assert crash in
an Assert-enabled build, or incorrect conversion otherwise, neither of
which is desirable.  This would be a DOS issue if production databases
were customarily built with asserts enabled, but fortunately that's not so.
Per an observation by Heikki.

Back-patch to all supported branches.
2009-01-29 19:25:01 +00:00
Magnus Hagander 5ecd9dc75a Go over all OpenSSL return values and make sure we compare them
to the documented API value. The previous code got it right as
it's implemented, but accepted too much/too little compared to
the API documentation.

Per comment from Zdenek Kotala.
2009-01-28 15:06:51 +00:00
Teodor Sigaev 473b40d23e Fix uninitialized variables in get_covers 2009-01-16 12:09:30 +00:00
Teodor Sigaev b7394a6e6e Fix URL generation in headline. Only tag lexeme will be replaced by space.
Per http://archives.postgresql.org/pgsql-bugs/2008-12/msg00013.php
2009-01-15 18:17:12 +00:00
Teodor Sigaev 696dbd873d Fix generation of too long headline with ShortWords.
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php
2009-01-15 18:16:52 +00:00
Tom Lane 0cdeea0e54 Remove references to pgsql-ports and pgsql-patches mailing lists from
various documentation, since those lists are now dead/deprecated.
Point to pgsql-bugs and/or pgsql-hackers as appropriate.
2009-01-06 17:28:01 +00:00
Heikki Linnakangas fea5ec5263 Fix logic in lazy vacuum to decide if it's worth trying to truncate the heap.
If the table was smaller than REL_TRUNCATE_FRACTION (= 16) pages, we always
tried to acquire AccessExclusiveLock on it even if there was no empty pages
at the end.

Report by Simon Riggs. Back-patch all the way to 7.4.
2009-01-06 14:56:03 +00:00
Marc G. Fournier d297635721 tag for 8.0.19 2008-10-31 02:54:50 +00:00
Tom Lane f1ac413466 Update back-branch release notes. 2008-10-30 22:23:25 +00:00
Peter Eisentraut 60278b1cc8 Translation updates 2008-10-30 19:21:26 +00:00
Tom Lane ed0f09a0af Update time zone data files to tzdata release 2008i (DST law changes in
Argentina, Brazil, Mauritius, Syria).
2008-10-30 13:17:23 +00:00
Peter Eisentraut 28faad52c7 Missing space in error message 2008-10-30 12:16:32 +00:00
Tom Lane d24efb83ee Install a more robust solution for the problem of infinite error-processing
recursion when we are unable to convert a localized error message to the
client's encoding.  We've been over this ground before, but as reported by
Ibrar Ahmed, it still didn't work in the case of conversion failures for
the conversion-failure message itself :-(.  Fix by installing a "circuit
breaker" that disables attempts to localize this message once we get into
recursion trouble.

Patch all supported branches, because it is in fact broken in all of them;
though I had to add some missing translations to the older branches in
order to expose the failure in the particular test case I was using.
2008-10-27 19:37:48 +00:00
Tom Lane b1b2140035 Fix an old bug in after-trigger handling: AfterTriggerEndQuery took the
address of afterTriggers->query_stack[afterTriggers->query_depth] and hung
onto it through all its firings of triggers.  However, if a trigger causes
sufficiently many nested query executions, query_stack will get repalloc'd
bigger, leaving AfterTriggerEndQuery --- and hence afterTriggerInvokeEvents
--- using a stale pointer.

So far as I can find, the only consequence of this error is to stomp on a
couple of words of already-freed memory; which would lead to a failure only if
that chunk had already gotten re-allocated for something else.  So it's hard
to exhibit a simple failure case, but this is surely a bug.

I noticed this while working on my recent patch to reduce pending-trigger
space usage.  The present patch is mighty ugly, because it requires making
afterTriggerInvokeEvents know about all the possible event lists it might get
called on.  Fortunately, this is only needed in back branches because CVS HEAD
avoids the problem in a different way: afterTriggerInvokeEvents only touches
the passed AfterTriggerEventList pointer once at startup.  Back branches are
stable enough that wiring in knowledge of all possible call usages doesn't
seem like a killer problem.

Back-patch to 8.0.  7.4's trigger code is completely different and doesn't
seem to have the problem (it doesn't even use repalloc).
2008-10-25 03:33:05 +00:00
Teodor Sigaev 12956db2b3 Fix small bug in headline generation.
Patch from Sushant Sinha <sushant354@gmail.com>
http://archives.postgresql.org/pgsql-hackers/2008-07/msg00785.php
2008-10-17 17:42:32 +00:00
Tom Lane 4a59796840 Fix SPI_getvalue and SPI_getbinval to range-check the given attribute number
according to the TupleDesc's natts, not the number of physical columns in the
tuple.  The previous coding would do the wrong thing in cases where natts is
different from the tuple's column count: either incorrectly report error when
it should just treat the column as null, or actually crash due to indexing off
the end of the TupleDesc's attribute array.  (The second case is probably not
possible in modern PG versions, due to more careful handling of inheritance
cases than we once had.  But it's still a clear lack of robustness here.)

The incorrect error indication is ignored by all callers within the core PG
distribution, so this bug has no symptoms visible within the core code, but
it might well be an issue for add-on packages.  So patch all the way back.
2008-10-16 13:23:49 +00:00
Michael Meskes f99df7c573 Optional argument should be optional. 2008-10-10 12:19:18 +00:00
Tom Lane 603ce02654 Fix overly tense optimization of PLpgSQL_func_hashkey: we must represent
the isTrigger state explicitly, not rely on nonzero-ness of trigrelOid
to indicate trigger-hood, because trigrelOid will be left zero when compiling
for validation.  The (useless) function hash entry built by the validator
was able to match an ordinary non-trigger call later in the same session,
thereby bypassing the check that is supposed to prevent such a call.
Per report from Alvaro.

It might be worth suppressing the useless hash entry altogether, but
that's a bigger change than I want to consider back-patching.

Back-patch to 8.0.  7.4 doesn't have the problem because it doesn't
have validation mode.
2008-10-09 16:35:33 +00:00
Tom Lane cb0a4fed98 Fix improper display of fractional seconds in interval values
when using --enable-integer-datetimes and a non-ISO datestyle.

Ron Mayer
2008-10-02 13:48:03 +00:00
Tom Lane c6b808ea8d Recent patches to pg_ctl broke "pg_ctl restart" for the case where no
command-line options had been given to the postmaster; and just plain
broke it altogether in 8.1 and 8.0.  Per report from KaiGai Kohei.
2008-09-30 13:14:28 +00:00
Marc G. Fournier b0ea4828e4 tag for 8.0.18 2008-09-19 03:23:34 +00:00
Tom Lane 9ca010304d Update back-branch release notes. 2008-09-19 02:45:56 +00:00
Tom Lane a763929571 Update time zone data files to tzdata release 2008f (DST law changes in
Argentina, Bahamas, Brazil, Mauritius, Morocco, Pakistan, Palestine, Paraguay).
2008-09-17 14:19:10 +00:00
Tom Lane 2b74fcedc4 Widen the nLocks counts in local lock tables from int to int64. This
forestalls potential overflow when the same table (or other object, but
usually tables) is accessed by very many successive queries within a single
transaction.  Per report from Michael Milligan.

Back-patch to 8.0, which is as far back as the patch conveniently applies.
There have been no reports of overflow in pre-8.3 releases, but clearly the
risk existed all along.  (Michael's report suggests that 8.3 may consume lock
counts faster than prior releases, but with no test case to look at it's hard
to be sure about that.  Widening the counts seems a good future-proofing
measure in any event.)
2008-09-16 01:56:56 +00:00
Tom Lane c1758175f8 Fix pg_dump docs to acknowledge that you can use -Z with plain text output. Pointed out by Daniel Migowski. 2008-08-26 00:03:43 +00:00
Tom Lane af3f5293ef Fix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec
returns NULL instead of a PGresult.  The former coding would fail, which
is OK, but it neglected to give you the PQerrorMessage that might tell
you why.  In the oldest branches, there was another problem: it'd sometimes
report PQerrorMessage from the wrong connection.
2008-08-16 02:25:30 +00:00
Tom Lane 1848ea7200 Install checks in executor startup to ensure that the tuples produced by an
INSERT or UPDATE will match the target table's current rowtype.  In pre-8.3
releases inconsistency can arise with stale cached plans, as reported by
Merlin Moncure.  (We patched the equivalent hazard on the SELECT side in Feb
2007; I'm not sure why we thought there was no risk on the insertion side.)
In 8.3 and HEAD this problem should be impossible due to plan cache
invalidation management, but it seems prudent to make the check anyway.

Back-patch as far as 8.0.  7.x versions lack ALTER COLUMN TYPE, so there
seems no way to abuse a stale plan comparably.
2008-08-08 17:01:41 +00:00
Tom Lane 7f75a64077 Do not allow Unique nodes to be scanned backwards. The code claimed that it
would work, but in fact it didn't return the same rows when moving backwards
as when moving forwards.  This would have no visible effect in a DISTINCT
query (at least assuming the column datatypes use a strong definition of
equality), but it gave entirely wrong answers for DISTINCT ON queries.
2008-08-05 21:28:54 +00:00
Tom Lane e126577aa0 Update 8.1 and 8.0 plpython to work with Python 2.5. This backports several
fixes made during the 8.2 development cycle, but not backported at the time
for lack of confidence in the new coding.

I didn't touch 7.4 because it has more problems than this: the configure
probe for Python fails.
2008-07-28 18:45:18 +00:00
Tom Lane c54053355a Fix performance bug in write_syslog(): the code to preferentially break the
log message at newlines cost O(N^2) for very long messages with few or no
newlines.  For messages in the megabyte range this became the dominant cost.
Per gripe from Achilleas Mantzios.

Patch all the way back, since this is a safe change with no portability
risks.  I am also thinking of increasing PG_SYSLOG_LIMIT, but that should
be done separately.
2008-07-08 22:18:09 +00:00
Tom Lane 756aeaf0f3 Fix estimate_num_groups() to assume that GROUP BY expressions yielding boolean
results always contribute two groups, regardless of the expression contents.
This is very substantially more accurate than the regular heuristic for
certain boolean tests like "col IS NULL".  Per gripe from Sam Mason.

Back-patch to all supported releases, since the behavior of
estimate_num_groups() hasn't changed all that much since 7.4.
2008-07-07 20:25:30 +00:00
Tom Lane 2d94cf6bfe Fix identify_system_timezone() so that it tests the behavior of the system
timezone setting in the current year and for 100 years back, rather than
always examining years 1904-2004.  The original coding would have problems
distinguishing zones whose behavior diverged only after 2004; which is a
situation we will surely face sometime, if it's not out there already.

In passing, also prevent selection of the dummy "Factory" timezone, even
if that's exactly what the system is using.  Reporting time as GMT seems
better than that.
2008-07-01 03:41:25 +00:00
Bruce Momjian 0e69ff3399 Fix 'pg_ctl reload' to properly preserve postmaster commend-line
arguments on restart.  Patch to releases 8.0 - 8.3.X.
2008-06-27 01:52:58 +00:00
Tom Lane bd80180e1d Clean up a number of bogosities around pltcl's handling of the Tcl "result":
1. Directly reading interp->result is deprecated in Tcl 8.0 and later;
you're supposed to use Tcl_GetStringResult.  This code finally broke with
Tcl 8.5, because Tcl_GetVar can now have side-effects on interp->result even
though it preserves the logical state of the result.  (There's arguably a
Tcl issue here, because Tcl_GetVar could invalidate the pointer result of a
just-preceding Tcl_GetStringResult, but I doubt the Tcl guys will see it as
a bug.)

2. We were being sloppy about the encoding of the result: some places would
push database-encoding data into the Tcl result, which should not happen,
and we were assuming that any error result coming back from Tcl was in the
database encoding, which is not a good assumption.

3. There were a lot of calls of Tcl_SetResult that uselessly specified
TCL_VOLATILE for constant strings.  This is only a minor performance issue,
but I fixed it in passing since I had to look at all the calls anyway.

#2 is a live bug regardless of which Tcl version you are interested in,
so back-patch even to branches that are unlikely to be used with Tcl 8.5.
I went back as far as 8.0, which is as far as the patch applied easily;
7.4 was using a different error processing scheme that has got its own
problems :-(
2008-06-17 00:53:13 +00:00