Tom Lane [Sat, 2 May 2009 20:17:45 +0000 (20:17 +0000)]
Split the release notes into a separate file for each (active) major branch,
as per my recent proposal. release.sgml itself is now just a stub that should
change rarely; ideally, only once per major release to add a new include line.
Most editing work will occur in the release-N.N.sgml files. To update a back
branch for a minor release, just copy the appropriate release-N.N.sgml
file(s) into the back branch.
This commit doesn't change the end-product documentation at all, only the
source layout. However, it makes it easy to start omitting ancient information
from newer branches' documentation, should we ever decide to do that.
branch-fixup [Sat, 2 May 2009 20:17:19 +0000 (20:17 +0000)]
Add files from parent branch HEAD:
doc/src/sgml/generate_history.pl
doc/src/sgml/release-7.4.sgml
doc/src/sgml/release-8.0.sgml
doc/src/sgml/release-8.1.sgml
doc/src/sgml/release-8.2.sgml
doc/src/sgml/release-old.sgml
Tom Lane [Fri, 1 May 2009 19:29:20 +0000 (19:29 +0000)]
When checking for datetime field overflow, we should allow a fractional-second
part that rounds up to exactly 1.0 second. The previous coding rejected input
like "00:12:57.
9999999999999999999999999999", with the exact number of nines
needed to cause failure varying depending on float-timestamp option and
possibly on platform. Obviously this should round up to the next integral
second, if we don't have enough precision to distinguish the value from that.
Per bug #4789 from Robert Kruus.
In passing, fix a missed check for fractional seconds in one copy of the
"is it greater than 24:00:00" code.
Broken all the way back, so patch all the way back.
Tom Lane [Sat, 25 Apr 2009 16:45:12 +0000 (16:45 +0000)]
Fix the handling of sub-SELECTs appearing in the arguments of an outer-level
aggregate function. By definition, such a sub-SELECT cannot reference any
variables of query levels between itself and the aggregate's semantic level
(else the aggregate would've been assigned to that lower level instead).
So the correct, most efficient implementation is to treat the sub-SELECT as
being a sub-select of that outer query level, not the level the aggregate
syntactically appears in. Not doing so also confuses the heck out of our
parameter-passing logic, as illustrated in bug report from Daniel Grace.
Fortunately, we were already copying the whole Aggref expression up to the
outer query level, so all that's needed is to delay SS_process_sublinks
processing of the sub-SELECT until control returns to the outer level.
This has been broken since we introduced spec-compliant treatment of
outer aggregates in 7.4; so patch all the way back.
Bruce Momjian [Sat, 25 Apr 2009 15:53:49 +0000 (15:53 +0000)]
Remove HELIOS Software GmbH name and copyright from AIX dynloader files,
per approval from Helmut Tschemernjak, President.
Only back branches; files removed from CVS HEAD.
Magnus Hagander [Wed, 15 Apr 2009 18:58:32 +0000 (18:58 +0000)]
Remove beer-ware license from crypt-md5.c, per
approval from Poul-Henning Kamp.
This makes the file the same standard 2-clause BSD as the
rest of PostgreSQL.
Tom Lane [Thu, 9 Apr 2009 20:50:58 +0000 (20:50 +0000)]
Update time zone data files to tzdata release 2009e: DST law changes in
Argentina/San_Luis, Cuba, Jordan (historical correction only), Morocco,
Palestine, Syria, Tunisia.
Tom Lane [Tue, 7 Apr 2009 18:11:04 +0000 (18:11 +0000)]
Fix contrib/pg_freespacemap's underestimate of the number of pages it
could find in the FSM. Per report from Dimitri Fontaine and Andrew Gierth.
(Affects only 8.2 and 8.3 since HEAD no longer has MaxFSMPages at all.)
Tom Lane [Tue, 7 Apr 2009 15:54:07 +0000 (15:54 +0000)]
Defend against non-ASCII letters in fuzzystrmatch code. The functions
still don't behave very sanely for multibyte encodings, but at least
they won't be indexing off the ends of static arrays.
Teodor Sigaev [Mon, 6 Apr 2009 14:47:02 +0000 (14:47 +0000)]
Fix 'all at one page bug' in picksplit method of R-tree emulation. Add defense
from buggy user-defined picksplit to GiST.
Tom Lane [Sat, 4 Apr 2009 04:53:43 +0000 (04:53 +0000)]
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".
Tom Lane [Fri, 3 Apr 2009 23:27:28 +0000 (23:27 +0000)]
Use (unsigned char) cast in argument of pg_tolower(). Maybe it works on
Windows without that, but we shouldn't put bad examples where people might
copy them. Also, reformat slightly to improve the odds that pgindent
won't go nuts on this.
Magnus Hagander [Fri, 3 Apr 2009 11:52:10 +0000 (11:52 +0000)]
Make directory name comparisons on Win32 case insensitive.
This method will not catch all different ways since the locale
handling in NTFS doesn't provide an easy way to do that, but it
will hopefully solve the most common cases causing startup
problems when the backend is found in the system PATH.
Attempts to fix bug #4694.
Teodor Sigaev [Thu, 2 Apr 2009 18:06:12 +0000 (18:06 +0000)]
Fix memory allocation for output of hstore type.
Per "maosen.zhang" <
[email protected]> report.
Tom Lane [Thu, 2 Apr 2009 01:16:25 +0000 (01:16 +0000)]
plpgsql's exec_simple_cast_value() mistakenly supposed that it could bypass
casting effort whenever the input value was NULL. However this prevents
application of not-null domain constraints in the cases that use this
function, as illustrated in bug #4741. Since this function isn't meant
for use in performance-critical paths anyway, this certainly seems like
another case of "premature optimization is the root of all evil".
Back-patch as far as 8.2; older versions made no effort to enforce
domain constraints here anyway.
Tom Lane [Tue, 31 Mar 2009 22:55:41 +0000 (22:55 +0000)]
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.
Magnus Hagander [Tue, 31 Mar 2009 18:58:34 +0000 (18:58 +0000)]
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.
Heikki Linnakangas [Tue, 31 Mar 2009 05:18:43 +0000 (05:18 +0000)]
Fix a rare race condition when commit_siblings > 0 and a transaction commits
at the same instant as a new backend is spawned. Since CountActiveBackends()
doesn't hold ProcArrayLock, it needs to be prepared for the case that a
pointer at the end of the proc array is still NULL even though numProcs says
it should be valid, since it doesn't hold ProcArrayLock. Backpatch to 8.1.
8.0 and earlier had this right, but it was broken in the split of PGPROC and
sinval shared memory arrays.
Per report and proposal by Marko Kreen.
Tom Lane [Mon, 30 Mar 2009 04:09:18 +0000 (04:09 +0000)]
Fix an oversight in the support for storing/retrieving "minimal tuples" in
TupleTableSlots. We have functions for retrieving a minimal tuple from a slot
after storing a regular tuple in it, or vice versa; but these were implemented
by converting the internal storage from one format to the other. The problem
with that is it invalidates any pass-by-reference Datums that were already
fetched from the slot, since they'll be pointing into the just-freed version
of the tuple. The known problem cases involve fetching both a whole-row
variable and a pass-by-reference value from a slot that is fed from a
tuplestore or tuplesort object. The added regression tests illustrate some
simple cases, but there may be other failure scenarios traceable to the same
bug. Note that the added tests probably only fail on unpatched code if it's
built with --enable-cassert; otherwise the bug leads to fetching from freed
memory, which will not have been overwritten without additional conditions.
Fix by allowing a slot to contain both formats simultaneously; which turns out
not to complicate the logic much at all, if anything it seems less contorted
than before.
Back-patch to 8.2, where minimal tuples were introduced.
Heikki Linnakangas [Fri, 27 Mar 2009 14:59:11 +0000 (14:59 +0000)]
Fix tab completion of ANALYZE VERBOSE <tab>. It was previously confused
with EXPLAIN ANALYZE VERBOSE.
Greg Sabino Mullane, reformatted by myself. Backpatch to 8.1, where the
bug was introduced.
Tom Lane [Wed, 25 Mar 2009 15:03:25 +0000 (15:03 +0000)]
Fix old thinko in pgp.h: the idea is to declare some named enum types,
not global variables of anonymous enum types. This didn't actually hurt
much because most linkers will just merge the duplicated definitions ...
but some will complain. Per bug #4731 from Ceriel Jacobs.
Backpatch to 8.1 --- the declarations don't exist before that.
Tom Lane [Tue, 24 Mar 2009 22:06:32 +0000 (22:06 +0000)]
Install a search tree depth limit in GIN bulk-insert operations, to prevent
them from degrading badly when the input is sorted or nearly so. In this
scenario the tree is unbalanced to the point of becoming a mere linked list,
so insertions become O(N^2). The easiest and most safely back-patchable
solution is to stop growing the tree sooner, ie limit the growth of N. We
might later consider a rebalancing tree algorithm, but it's not clear that
the benefit would be worth the cost and complexity. Per report from Sergey
Burladyan and an earlier complaint from Heikki.
Back-patch to 8.2; older versions didn't have GIN indexes.
Tom Lane [Sun, 15 Mar 2009 22:05:44 +0000 (22:05 +0000)]
Fix contrib/hstore to throw an error for keys or values that don't fit in its
data structure, rather than silently truncating them. Andrew Gierth
Marc G. Fournier [Fri, 13 Mar 2009 02:16:43 +0000 (02:16 +0000)]
tag 8.2.13
Tom Lane [Thu, 12 Mar 2009 22:36:09 +0000 (22:36 +0000)]
Update back-branch release notes.
Tom Lane [Thu, 12 Mar 2009 00:53:41 +0000 (00:53 +0000)]
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.
Teodor Sigaev [Tue, 10 Mar 2009 17:44:44 +0000 (17:44 +0000)]
Prevent recursion during parse of email-like string with multiple '@'.
Patch by Heikki Linnakangas <
[email protected]>
Heikki Linnakangas [Thu, 5 Mar 2009 14:28:18 +0000 (14:28 +0000)]
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
Tom Lane [Wed, 4 Mar 2009 22:08:34 +0000 (22:08 +0000)]
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.
Tom Lane [Tue, 3 Mar 2009 00:17:22 +0000 (00:17 +0000)]
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.
Tom Lane [Mon, 2 Mar 2009 21:18:57 +0000 (21:18 +0000)]
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.
Teodor Sigaev [Mon, 2 Mar 2009 15:13:17 +0000 (15:13 +0000)]
Fix usage of char2wchar/wchar2char. Changes:
- pg_wchar and wchar_t could have different size, so char2wchar
doesn't call pg_mb2wchar_with_len to prevent out-of-bound
memory bug
- make char2wchar/wchar2char symmetric, now they should not be
called with C-locale because mbstowcs/wcstombs oftenly doesn't
work correct with C-locale.
- Text parser uses pg_mb2wchar_with_len directly in case of
C-locale and multibyte encoding
Per bug report by Hiroshi Inoue <
[email protected]> and
following discussion.
Backpatch up to 8.2 when multybyte support was implemented in tsearch.
Tom Lane [Sat, 28 Feb 2009 18:50:01 +0000 (18:50 +0000)]
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.
Heikki Linnakangas [Fri, 27 Feb 2009 16:35:36 +0000 (16:35 +0000)]
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.
Heikki Linnakangas [Fri, 27 Feb 2009 10:27:45 +0000 (10:27 +0000)]
Set isnull for errm and sqlstate local variables when they're free'd. Because
they are out of scope for any code after that anyway, leaving isnull true
should be harmless. However, PL/pgSQL Debugger doesn't seem to care about
the scoping and crashed, per report by Robert Walker (bug #4635). And it's
good to be tidy for debugging purposes too.
Fix in 8.3, 8.2 and 8.1 branches, CVS HEAD was fixed earlier already.
Analysis and fix by Ashesh Vashi and Dave Page.
Tom Lane [Wed, 25 Feb 2009 18:00:14 +0000 (18:00 +0000)]
Fix an old problem in decompilation of CASE constructs: the ruleutils.c code
looks for a CaseTestExpr to figure out what the parser did, but it failed to
consider the possibility that an implicit coercion might be inserted above
the CaseTestExpr. This could result in an Assert failure in some cases
(but correct results if Asserts weren't enabled), or an "unexpected CASE WHEN
clause" error in other cases. Per report from Alan Li.
Back-patch to 8.1; problem doesn't exist before that because CASE was
implemented differently.
Tom Lane [Tue, 24 Feb 2009 01:39:01 +0000 (01:39 +0000)]
Repair a longstanding bug in CLUSTER and the rewriting variants of ALTER
TABLE: if the command is executed by someone other than the table owner (eg,
a superuser) and the table has a toast table, the toast table's pg_type row
ends up with the wrong typowner, ie, the command issuer not the table owner.
This is quite harmless for most purposes, since no interesting permissions
checks consult the pg_type row. However, it could lead to unexpected failures
if one later tries to drop the role that issued the command (in 8.1 or 8.2),
or strange warnings from pg_dump afterwards (in 8.3 and up, which will allow
the DROP ROLE because we don't create a "redundant" owner dependency for table
rowtypes). Problem identified by Cott Lang.
Back-patch to 8.1. The problem is actually far older --- the CLUSTER variant
can be demonstrated in 7.0 --- but it's mostly cosmetic before 8.1 because we
didn't track ownership dependencies before 8.1. Also, fixing it before 8.1
would require changing the call signature of heap_create_with_catalog(), which
seems to carry a nontrivial risk of breaking add-on modules.
Magnus Hagander [Sun, 15 Feb 2009 13:58:20 +0000 (13:58 +0000)]
Loop calling CallNamedPipe() several times in case it fails,
since it can be transient failures, causing kill() to not
properly send signals.
Original patch from Steve Marshall, modified by me.
Tom Lane [Mon, 2 Feb 2009 20:25:50 +0000 (20:25 +0000)]
Fix plpgsql to not treat INSERT INTO as an INTO-variables clause anywhere
in the string, not just at the start. Per bug #4629 from Martin Blazek.
Back-patch to 8.2; prior versions don't have the problem, at least not in
the reported case, because they don't try to recognize INTO in non-SELECT
statements. (IOW, this is really fallout from the RETURNING patch.)
Tom Lane [Fri, 30 Jan 2009 16:59:16 +0000 (16:59 +0000)]
Defend against null input in analyze_requires_snapshot(), per report
from Rushabh Lathia.
Back-patch of patch of 2009-01-08. This is necessary in 8.3, as reported
by Bjorn Munch. It's not currently necessary in 8.2, AFAICS, but seems
best to include it there too.
Marc G. Fournier [Fri, 30 Jan 2009 03:13:35 +0000 (03:13 +0000)]
tag 8.2.12
Tom Lane [Fri, 30 Jan 2009 00:37:52 +0000 (00:37 +0000)]
Update back-branch release notes.
Peter Eisentraut [Thu, 29 Jan 2009 22:06:53 +0000 (22:06 +0000)]
Translation updates
Tom Lane [Thu, 29 Jan 2009 20:00:14 +0000 (20:00 +0000)]
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.
Tom Lane [Thu, 29 Jan 2009 19:24:19 +0000 (19:24 +0000)]
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.
Magnus Hagander [Wed, 28 Jan 2009 15:06:55 +0000 (15:06 +0000)]
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.
Alvaro Herrera [Tue, 20 Jan 2009 12:17:23 +0000 (12:17 +0000)]
Fix erroneous memory context switch in autovacuum, which was returning to a
context long after it had been destroyed.
Per problem report from Justin Pasher. Patch by Tom Lane and me.
8.3 and later do not have this bug, because this code has been restructured for
unrelated reasons. In 8.2 it does not manifest as a crash, but it still seems
safer fixing it nonetheless.
Heikki Linnakangas [Thu, 15 Jan 2009 18:23:53 +0000 (18:23 +0000)]
Change explanation of pg_switch_xlog()'s return value to match code.
Teodor Sigaev [Thu, 15 Jan 2009 17:44:47 +0000 (17:44 +0000)]
Fix URL generation in headline. Only tag lexeme will be replaced by space.
Per http://archives.postgresql.org/pgsql-bugs/2008-12/msg00013.php
Teodor Sigaev [Thu, 15 Jan 2009 17:44:18 +0000 (17:44 +0000)]
Fix generation of too long headline with ShortWords.
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php
Heikki Linnakangas [Wed, 14 Jan 2009 09:53:57 +0000 (09:53 +0000)]
Remove broken Assertions that failed if a statement executed in PL/pgSQL is
rewritten into another kind of statement, for example if an INSERT is
rewritten into an UPDATE.
Back-patch to 8.3 and 8.2. For HEAD, Tom suggested inventing a new
SPI_OK_REWRITTEN return code, but that's not a backportable solution. I'll
do that as a separate patch, this patch will do as a stopgap measure for HEAD
too in the meanwhile.
Magnus Hagander [Tue, 13 Jan 2009 11:45:01 +0000 (11:45 +0000)]
Throw an error when using -C and -1 at the same time in pg_restore.
It's not possible to do CREATE DATABASE inside a transaction, so previously
we just got a server error instead.
Backpatch to 8.2, which is where the -1 feature appeared.
Bruce Momjian [Fri, 9 Jan 2009 01:46:48 +0000 (01:46 +0000)]
Update release notes for 8.3.5, 8.2.11, and 8.1.15 to mention the need
to reindex GiST indexes:
If you were running a previous 8.X.X release, REINDEX all GiST
indexes after the upgrade.
Tom Lane [Wed, 7 Jan 2009 20:39:15 +0000 (20:39 +0000)]
Insert conditional SPI_push/SPI_pop calls into InputFunctionCall,
OutputFunctionCall, and friends. This allows SPI-using functions to invoke
datatype I/O without concern for the possibility that a SPI-using function
will be called (which could be either the I/O function itself, or a function
used in a domain check constraint). It's a tad ugly, but not nearly as ugly
as what'd be needed to make this work via retail insertion of push/pop
operations in all the PLs.
This reverts my patch of 2007-01-30 that inserted some retail SPI_push/pop
calls into plpgsql; that approach only fixed plpgsql, and not any other PLs.
But the other PLs have the issue too, as illustrated by a recent gripe from
Christian Schröder.
Back-patch to 8.2, which is as far back as this solution will work. It's
also as far back as we need to worry about the domain-constraint case, since
earlier versions did not attempt to check domain constraints within datatype
input. I'm not aware of any old I/O functions that use SPI themselves, so
this should be sufficient for a back-patch.
Tom Lane [Tue, 6 Jan 2009 17:27:39 +0000 (17:27 +0000)]
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.
Heikki Linnakangas [Tue, 6 Jan 2009 14:55:50 +0000 (14:55 +0000)]
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.
Joe Conway [Sat, 3 Jan 2009 19:58:10 +0000 (19:58 +0000)]
Fix bug per Oleksiy Shchukin - 2nd argument for dblink_get_result(text,bool)
is PG_GETARG_BOOL(2), should be PG_GETARG_BOOL(1).
Apply simple fix to back branches only. More extensive change to be applied
to head per Tom's suggestion.
Tom Lane [Tue, 16 Dec 2008 16:26:21 +0000 (16:26 +0000)]
Make heap_update() set newtup->t_tableOid correctly, for consistency with
the other major heapam.c functions. The only known consequence of this
omission is that UPDATE RETURNING failed to return the correct value for
"tableoid", as per report from KaiGai Kohei.
Back-patch to 8.2. Arguably it's wrong all the way back; but without
evidence of visible breakage before RETURNING was added, I'll desist from
patching the older branches.
Tom Lane [Sat, 13 Dec 2008 02:00:53 +0000 (02:00 +0000)]
Fix failure to ensure that a snapshot is available to datatype input functions
when they are invoked by the parser. We had been setting up a snapshot at
plan time but really it needs to be done earlier, before parse analysis.
Per report from Dmitry Koterov.
Also fix two related problems discovered while poking at this one:
exec_bind_message called datatype input functions without establishing a
snapshot, and SET CONSTRAINTS IMMEDIATE could call trigger functions without
establishing a snapshot.
Backpatch to 8.2. The underlying problem goes much further back, but it is
masked in 8.1 and before because we didn't attempt to invoke domain check
constraints within datatype input. It would only be exposed if a C-language
datatype input function used the snapshot; which evidently none do, or we'd
have heard complaints sooner. Since this code has changed a lot over time,
a back-patch is hardly risk-free, and so I'm disinclined to patch further
than absolutely necessary.
Tom Lane [Mon, 1 Dec 2008 21:06:31 +0000 (21:06 +0000)]
Fix an oversight in the code that makes transitive-equality deductions from
outer join clauses. Given, say,
... from a left join b on a.a1 = b.b1 where a.a1 = 42;
we'll deduce a clause b.b1 = 42 and then mark the original join clause
redundant (we can't remove it completely for reasons I don't feel like
squeezing into this log entry). However the original implementation of
that wasn't bulletproof, because clause_selectivity() wouldn't honor
this_selec if given nonzero varRelid --- which in practice meant that
it worked as desired *except* when considering index scan quals. Which
resulted in bogus underestimation of the size of the indexscan result for
an inner indexscan in an outer join, and consequently a possibly bad
choice of indexscan vs. bitmap scan. Fix by introducing an explicit test
into clause_selectivity(). Also, to make sure we don't trigger that test
in corner cases, change the convention to be that this_selec > 1, not
this_selec = 1, means it's been marked redundant. Per trouble report from
Scara Maccai.
Back-patch to 8.2, where the problem was introduced.
Tom Lane [Mon, 1 Dec 2008 17:06:35 +0000 (17:06 +0000)]
Ensure that the contents of a holdable cursor don't depend on out-of-line
toasted values, since those could get dropped once the cursor's transaction
is over. Per bug #4553 from Andrew Gierth.
Back-patch as far as 8.1. The bug actually exists back to 7.4 when holdable
cursors were introduced, but this patch won't work before 8.1 without
significant adjustments. Given the lack of field complaints, it doesn't seem
worth the work (and risk of introducing new bugs) to try to make a patch for
the older branches.
Tom Lane [Sun, 30 Nov 2008 23:24:08 +0000 (23:24 +0000)]
Fix dblink and tablefunc to not return with the wrong CurrentMemoryContext.
Per buildfarm results.
Tom Lane [Sun, 30 Nov 2008 18:49:48 +0000 (18:49 +0000)]
Remove inappropriate memory context switch in shutdown_MultiFuncCall().
This was a thinko introduced in a patch from last February; it results
in memory leakage if an SRF is shut down before the actual end of query,
because subsequent code will be running in a longer-lived context than
it's expecting to be.
Tom Lane [Tue, 25 Nov 2008 20:47:55 +0000 (20:47 +0000)]
information_schema.key_column_usage.position_in_unique_constraint was
misdocumented as not being implemented. In reality it has worked since
the release of 8.2.
Tom Lane [Wed, 12 Nov 2008 23:08:50 +0000 (23:08 +0000)]
In predtest.c, install a limit on the number of branches we will process in
AND, OR, or equivalent clauses: if there are too many (more than 100) just
exit without proving anything. This ensures that we don't spend O(N^2) time
trying (and most likely failing) to prove anything about very long IN lists
and similar cases.
Also, install a couple of CHECK_FOR_INTERRUPTS calls to ensure that a long
proof attempt can be interrupted.
Per gripe from Sergey Konoplev.
Back-patch the whole patch to 8.2 and just the CHECK_FOR_INTERRUPTS addition
to 8.1. (The rest of the patch doesn't apply cleanly, and since 8.1 doesn't
show the complained-of behavior anyway, it doesn't seem necessary to work
hard on it.)
Andrew Dunstan [Wed, 12 Nov 2008 00:00:53 +0000 (00:00 +0000)]
Detect and error out on inability to get proper linkage information required for plperl, usually due to absence of perl ExtUtils::Embed module. Backpatch as far as 8.1.
Tom Lane [Tue, 11 Nov 2008 18:13:54 +0000 (18:13 +0000)]
Get rid of adjust_appendrel_attr_needed(), which has been broken ever since
we extended the appendrel mechanism to support UNION ALL optimization. The
reason nobody noticed was that we are not actually using attr_needed data for
appendrel children; hence it seems more reasonable to rip it out than fix it.
Back-patch to 8.2 because an Assert failure is possible in corner cases.
Per examination of an example from Jim Nasby.
In HEAD, also get rid of AppendRelInfo.col_mappings, which is quite inadequate
to represent UNION ALL situations; depend entirely on translated_vars instead.
Tom Lane [Mon, 10 Nov 2008 14:57:53 +0000 (14:57 +0000)]
Fix old bug in contrib/sslinfo: X509_NAME_to_text freed the BIO_s_mem buffer
it was using too soon. In a situation where pg_do_encoding_conversion is
a no-op, this led to garbage data returned.
In HEAD, also modify the code that's ensuring null termination to make it
a tad more obvious what's happening.
Marc G. Fournier [Fri, 31 Oct 2008 02:44:09 +0000 (02:44 +0000)]
tag 8.2.11
Tom Lane [Thu, 30 Oct 2008 22:22:57 +0000 (22:22 +0000)]
Update back-branch release notes.
Peter Eisentraut [Thu, 30 Oct 2008 20:12:35 +0000 (20:12 +0000)]
Translation updates
Tom Lane [Thu, 30 Oct 2008 13:17:09 +0000 (13:17 +0000)]
Update time zone data files to tzdata release 2008i (DST law changes in
Argentina, Brazil, Mauritius, Syria).
Peter Eisentraut [Thu, 30 Oct 2008 12:25:32 +0000 (12:25 +0000)]
Missing space in error message
Tom Lane [Mon, 27 Oct 2008 19:37:36 +0000 (19:37 +0000)]
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.
Tom Lane [Sun, 26 Oct 2008 02:46:36 +0000 (02:46 +0000)]
Better solution to the IN-list issue: instead of having an arbitrary cutoff,
treat Var and non-Var IN-list items differently. Only non-Var items are
candidates to go into an ANY(ARRAY) construct --- we put all Vars as separate
OR conditions on the grounds that that leaves more scope for optimization.
Per suggestion from Robert Haas.
Tom Lane [Sat, 25 Oct 2008 17:19:26 +0000 (17:19 +0000)]
Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"
into an OR of equality comparisons, rather than x = ANY(ARRAY[...]), when there
are Vars in the right-hand side. This avoids a performance regression compared
to pre-8.2 releases, in cases where the OR form can be optimized into scans
of multiple indexes. Limit the possible downside by preferring this form only
when the list isn't very long (I set the cutoff at 32 elements, which is a
bit arbitrary but in the right ballpark). Per discussion with Jim Nasby.
In passing, also make it try the OR form if it cannot select a common type
for the array elements; we've seen a complaint or two about how the OR form
worked for such cases and ARRAY doesn't.
Tom Lane [Sat, 25 Oct 2008 03:32:51 +0000 (03:32 +0000)]
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).
Teodor Sigaev [Wed, 22 Oct 2008 12:55:59 +0000 (12:55 +0000)]
Fix GiST's killing tuple: GISTScanOpaque->curpos wasn't
correctly set. As result, killtuple() marks as dead
wrong tuple on page. Bug was introduced by me while fixing
possible duplicates during GiST index scan.
Teodor Sigaev [Fri, 17 Oct 2008 17:40:14 +0000 (17:40 +0000)]
Fix small bug in headline generation.
Patch from Sushant Sinha <
[email protected]>
http://archives.postgresql.org/pgsql-hackers/2008-07/msg00785.php
Neil Conway [Thu, 16 Oct 2008 19:26:01 +0000 (19:26 +0000)]
Fix a small memory leak in ExecReScanAgg() in the hashed aggregation case.
In the previous coding, the list of columns that needed to be hashed on
was allocated in the per-query context, but we reallocated every time
the Agg node was rescanned. Since this information doesn't change over
a rescan, just construct the list of columns once during ExecInitAgg().
Tom Lane [Thu, 16 Oct 2008 13:23:34 +0000 (13:23 +0000)]
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.
Tom Lane [Fri, 10 Oct 2008 21:46:49 +0000 (21:46 +0000)]
Fix COPY documentation to not imply that HEADER can be used outside CSV mode.
Per gripe from Bill Thoen.
Michael Meskes [Fri, 10 Oct 2008 12:19:47 +0000 (12:19 +0000)]
Optional arguments should be optional.
Tom Lane [Thu, 9 Oct 2008 16:35:19 +0000 (16:35 +0000)]
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.
Heikki Linnakangas [Tue, 7 Oct 2008 11:15:54 +0000 (11:15 +0000)]
When a relation is moved to another tablespace, we can't assume that we can
use the old relfilenode in the new tablespace. There might be another relation
in the new tablespace with the same relfilenode, so we must generate a fresh
relfilenode in the new tablespace.
The 8.3 patch to let deleted relation files linger as zero-length files until
the next checkpoint made this more obvious: moving a relation from one table
space another, and then back again, caused a collision with the lingering
file.
Back-patch to 8.1. The issue is present in 8.0 as well, but it doesn't seem
worth fixing there, because we didn't have protection from OID collisions
after OID wraparound before 8.1.
Report by Guillaume Lelarge.
Tom Lane [Thu, 2 Oct 2008 13:47:50 +0000 (13:47 +0000)]
Fix improper display of fractional seconds in interval values
when using --enable-integer-datetimes and a non-ISO datestyle.
Ron Mayer
Tom Lane [Tue, 30 Sep 2008 13:14:15 +0000 (13:14 +0000)]
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.
Tom Lane [Wed, 24 Sep 2008 16:53:00 +0000 (16:53 +0000)]
Fix more problems with rewriter failing to set Query.hasSubLinks when inserting
a SubLink expression into a rule query. We missed cases where the original
query contained a sub-SELECT in a function in FROM, a multi-row VALUES list,
or a RETURNING list. Per bug #4434 from Dean Rasheed and subsequent
investigation.
Back-patch to 8.1; older releases don't have the issue because they didn't
try to be smart about setting hasSubLinks only when needed.
Magnus Hagander [Wed, 24 Sep 2008 08:59:44 +0000 (08:59 +0000)]
Make sure pg_control is opened in binary mode, to deal
with situtations when the file contains an EOF maker
(0x1A) on Windows.
ITAGAKI Takahiro
Marc G. Fournier [Fri, 19 Sep 2008 03:12:08 +0000 (03:12 +0000)]
tag for 8.2.10
Tom Lane [Fri, 19 Sep 2008 02:45:33 +0000 (02:45 +0000)]
Update back-branch release notes.
Tom Lane [Wed, 17 Sep 2008 14:18:55 +0000 (14:18 +0000)]
Update time zone data files to tzdata release 2008f (DST law changes in
Argentina, Bahamas, Brazil, Mauritius, Morocco, Pakistan, Palestine, Paraguay).
Tom Lane [Tue, 16 Sep 2008 01:56:43 +0000 (01:56 +0000)]
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.)
Alvaro Herrera [Thu, 11 Sep 2008 14:01:16 +0000 (14:01 +0000)]
Initialize the minimum frozen Xid in vac_update_datfrozenxid using
GetOldestXmin() instead of RecentGlobalXmin; this is safer because we do not
depend on the latter being correctly set elsewhere, and while it is more
expensive, this code path is not performance-critical. This is a real
risk for autovacuum, because it can execute whole cycles without doing
a single vacuum, which would mean that RecentGlobalXmin would stay at its
initialization value, FirstNormalTransactionId, causing a bogus value to be
inserted in pg_database. This bug could explain some recent reports of
failure to truncate pg_clog.
At the same time, change the initialization of RecentGlobalXmin to
InvalidTransactionId, and ensure that it's set to something else whenever
it's going to be used. Using it as FirstNormalTransactionId in HOT page
pruning could incur in data loss. InitPostgres takes care of setting it
to a valid value, but the extra checks are there to prevent "special"
backends from behaving in unusual ways.
Per Tom Lane's detailed problem dissection in 29544.
1221061979@sss.pgh.pa.us
Tom Lane [Mon, 1 Sep 2008 22:30:48 +0000 (22:30 +0000)]
Fix plpgsql's exec_move_row() to supply valid type OIDs to exec_assign_value()
whenever possible, as per bug report from Oleg Serov. While at it, reorder
the operations in the RECORD case to avoid possible palloc failure while the
variable update is only partly complete.
Back-patch as far as 8.1. Although the code of the particular function is
similar in 8.0, 8.0's support for composite fields in rows is sufficiently
broken elsewhere that it doesn't seem worth fixing this.
Tom Lane [Tue, 26 Aug 2008 00:03:30 +0000 (00:03 +0000)]
Fix pg_dump docs to acknowledge that you can use -Z with plain text output. Pointed out by Daniel Migowski.
Teodor Sigaev [Sat, 23 Aug 2008 10:41:38 +0000 (10:41 +0000)]
Fix possible duplicate tuples while GiST scan. Now page is processed
at once and ItemPointers are collected in memory.
Remove tuple's killing by killtuple() if tuple was moved to another
page - it could produce unaceptable overhead.
Backpatch up to 8.1 because the bug was introduced by GiST's concurrency support.
Magnus Hagander [Wed, 20 Aug 2008 11:53:49 +0000 (11:53 +0000)]
Make libpq on windows not try to send chunks larger than 64Kb.
Per Microsoft knowledge base article Q201213, early versions of
Windows fail when we do this. Later versions of Windows appear
to have a higher limit than 64Kb, but do still fail on large
sends, so we unconditionally limit it for all versions.
Patch from Tom Lane.
Tom Lane [Sat, 16 Aug 2008 02:25:17 +0000 (02:25 +0000)]
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.
Heikki Linnakangas [Thu, 14 Aug 2008 20:32:11 +0000 (20:32 +0000)]
Fix pull_up_simple_union_all to copy all rtable entries from child subquery to
parent, not only those with RangeTblRefs. We need them in ExecCheckRTPerms.
Report by Brendan O'Shea. Back-patch to 8.2, where pull_up_simple_union_all
was introduced.