users/c2main/postgres.git
15 years agoIgnore attempts to set "application_name" in the connection startup packet.
Tom Lane [Wed, 2 Dec 2009 17:42:02 +0000 (17:42 +0000)]
Ignore attempts to set "application_name" in the connection startup packet.
This avoids a useless connection retry and complaint in the postmaster log
when receiving a connection from 8.5 or later libpq.

Backpatch in all supported branches, but of course *not* HEAD.

15 years agoFix longstanding problems in VACUUM caused by untimely interruptions
Alvaro Herrera [Tue, 10 Nov 2009 18:01:46 +0000 (18:01 +0000)]
Fix longstanding problems in VACUUM caused by untimely interruptions

In VACUUM FULL, an interrupt after the initial transaction has been recorded
as committed can cause postmaster to restart with the following error message:
PANIC: cannot abort transaction NNNN, it was already committed
This problem has been reported many times.

In lazy VACUUM, an interrupt after the table has been truncated by
lazy_truncate_heap causes other backends' relcache to still point to the
removed pages; this can cause future INSERT and UPDATE queries to error out
with the following error message:
could not read block XX of relation 1663/NNN/MMMM: read only 0 of 8192 bytes
The window to this race condition is extremely narrow, but it has been seen in
the wild involving a cancelled autovacuum process.

The solution for both problems is to inhibit interrupts in both operations
until after the respective transactions have been committed.  It's not a
complete solution, because the transaction could theoretically be aborted by
some other error, but at least fixes the most common causes of both problems.

15 years agoMake the overflow guards in ExecChooseHashTableSize be more protective.
Tom Lane [Fri, 30 Oct 2009 20:59:23 +0000 (20:59 +0000)]
Make the overflow guards in ExecChooseHashTableSize be more protective.
The original coding ensured nbuckets and nbatch didn't exceed INT_MAX,
which while not insane on its own terms did nothing to protect subsequent
code like "palloc(nbatch * sizeof(BufFile *))".  Since enormous join size
estimates might well be planner error rather than reality, it seems best
to constrain the initial sizes to be not more than work_mem/sizeof(pointer),
thus ensuring the allocated arrays don't exceed work_mem.  We will allow
nbatch to get bigger than that during subsequent ExecHashIncreaseNumBatches
calls, but we should still guard against integer overflow in those palloc
requests.  Per bug #5145 from Bernt Marius Johnsen.

Although the given test case only seems to fail back to 8.2, previous
releases have variants of this issue, so patch all supported branches.

15 years agoRewrite pam_passwd_conv_proc to be more robust: avoid assuming that the
Tom Lane [Fri, 16 Oct 2009 22:09:16 +0000 (22:09 +0000)]
Rewrite pam_passwd_conv_proc to be more robust: avoid assuming that the
pam_message array contains exactly one PAM_PROMPT_ECHO_OFF message.
Instead, deal with however many messages there are, and don't throw error
for PAM_ERROR_MSG and PAM_TEXT_INFO messages.  This logic is borrowed from
openssh 5.2p1, which hopefully has seen more real-world PAM usage than we
have.  Per bug #5121 from Ryan Douglas, which turned out to be caused by
the conv_proc being called with zero messages.  Apparently that is normal
behavior given the combination of Linux pam_krb5 with MS Active Directory
as the domain controller.

Patch all the way back, since this code has been essentially untouched
since 7.4.  (Surprising we've not heard complaints before.)

15 years agoFix off-by-one bug in bitncmp(): When comparing a number of bits divisible by
Heikki Linnakangas [Thu, 8 Oct 2009 04:47:06 +0000 (04:47 +0000)]
Fix off-by-one bug in bitncmp(): When comparing a number of bits divisible by
8, bitncmp() may dereference a pointer one byte out of bounds.

Chris Mikkelson (bug #5101)

15 years agoFix RelationCacheInitializePhase2 (Phase3, in HEAD) to cope with the
Tom Lane [Sat, 26 Sep 2009 18:25:35 +0000 (18:25 +0000)]
Fix RelationCacheInitializePhase2 (Phase3, in HEAD) to cope with the
possibility of shared-inval messages causing a relcache flush while it tries
to fill in missing data in preloaded relcache entries.  There are actually
two distinct failure modes here:

1. The flush could delete the next-to-be-processed cache entry, causing
the subsequent hash_seq_search calls to go off into the weeds.  This is
the problem reported by Michael Brown, and I believe it also accounts
for bug #5074.  The simplest fix is to restart the hashtable scan after
we've read any new data from the catalogs.  It appears that pre-8.4
branches have not suffered from this failure, because by chance there were
no other catalogs sharing the same hash chains with the catalogs that
RelationCacheInitializePhase2 had work to do for.  However that's obviously
pretty fragile, and it seems possible that derivative versions with
additional system catalogs might be vulnerable, so I'm back-patching this
part of the fix anyway.

2. The flush could delete the *current* cache entry, in which case the
pointer to the newly-loaded data would end up being stored into an
already-deleted Relation struct.  As long as it was still deleted, the only
consequence would be some leaked space in CacheMemoryContext.  But it seems
possible that the Relation struct could already have been recycled, in
which case this represents a hard-to-reproduce clobber of cached data
structures, with unforeseeable consequences.  The fix here is to pin the
entry while we work on it.

In passing, also change RelationCacheInitializePhase2 to Assert that
formrdesc() set up the relation's cached TupleDesc (rd_att) with the
correct type OID and hasoids values.  This is more appropriate than
silently updating the values, because the original tupdesc might already
have been copied into the catcache.  However this part of the patch is
not in HEAD because it fails due to some questionable recent changes in
formrdesc :-(.  That will be cleaned up in a subsequent patch.

15 years agoRemove outside-the-scanner references to "yyleng".
Tom Lane [Tue, 8 Sep 2009 04:26:17 +0000 (04:26 +0000)]
Remove outside-the-scanner references to "yyleng".

It seems the flex developers have decided to change yyleng from int to size_t.
This has already happened in the latest release of OS X, and will start
happening elsewhere once the next release of flex appears.  Rather than trying
to divine how it's declared in any particular build, let's just remove the one
existing not-very-necessary external usage.

Back-patch to all supported branches; not so much because users in the field
are likely to care about building old branches with cutting-edge flex, as
to keep OSX-based buildfarm members from having problems with old branches.

15 years agoTag 7.4.26 REL7_4_26
Marc G. Fournier [Fri, 4 Sep 2009 05:33:18 +0000 (05:33 +0000)]
Tag 7.4.26

15 years agoFinal updates of release notes for 8.4.1, 8.3.8, 8.2.14, 8.1.18, 8.0.22,
Tom Lane [Thu, 3 Sep 2009 22:14:41 +0000 (22:14 +0000)]
Final updates of release notes for 8.4.1, 8.3.8, 8.2.14, 8.1.18, 8.0.22,
7.4.26.

15 years agoDisallow RESET ROLE and RESET SESSION AUTHORIZATION inside security-definer
Tom Lane [Thu, 3 Sep 2009 22:09:06 +0000 (22:09 +0000)]
Disallow RESET ROLE and RESET SESSION AUTHORIZATION inside security-definer
functions.

This extends the previous patch that forbade SETting these variables inside
security-definer functions.  RESET is equally a security hole, since it
would allow regaining privileges of the caller; furthermore it can trigger
Assert failures and perhaps other internal errors, since the code is not
expecting these variables to change in such contexts.  The previous patch
did not cover this case because assign hooks don't really have enough
information, so move the responsibility for preventing this into guc.c.

Problem discovered by Heikki Linnakangas.

Security: no CVE assigned yet, extends CVE-2007-6600

15 years agoTranslation updates
Peter Eisentraut [Thu, 3 Sep 2009 18:49:05 +0000 (18:49 +0000)]
Translation updates

15 years agoImprove picksplit debug message
Peter Eisentraut [Wed, 2 Sep 2009 13:23:13 +0000 (13:23 +0000)]
Improve picksplit debug message

Missed this earlier because the translation site was broken for the 7.4
branch.

15 years agoUpdate release notes for 7.4.26, 8.0.22, 8.1.18, 8.2.14, 8.3.8, 8.4.1.
Bruce Momjian [Thu, 27 Aug 2009 01:26:40 +0000 (01:26 +0000)]
Update release notes for 7.4.26, 8.0.22, 8.1.18, 8.2.14, 8.3.8, 8.4.1.

15 years agoFix inclusions of readline/editline header files so that we only attempt to
Tom Lane [Mon, 24 Aug 2009 16:18:49 +0000 (16:18 +0000)]
Fix inclusions of readline/editline header files so that we only attempt to
#include the version of history.h that is in the same directory as the
readline.h we are using.  This avoids problems in some scenarios where both
readline and editline are installed.  Report and patch by Zdenek Kotala.

15 years agoFix overflow for INTERVAL 'x ms' where x is more than a couple million,
Tom Lane [Tue, 18 Aug 2009 21:23:58 +0000 (21:23 +0000)]
Fix overflow for INTERVAL 'x ms' where x is more than a couple million,
and integer datetimes are in use.  Per bug report from Hubert Depesz
Lubaczewski.

Alex Hunsaker

15 years agoRe-add documentation for --no-readline option of psql, mistakenly removed a decade...
Andrew Dunstan [Mon, 10 Aug 2009 02:39:09 +0000 (02:39 +0000)]
Re-add documentation for --no-readline option of psql, mistakenly removed a decade ago. Backpatch to release 7.4.

15 years agoTry to defend against the possibility that libpq is still in COPY_IN state
Tom Lane [Fri, 7 Aug 2009 20:16:49 +0000 (20:16 +0000)]
Try to defend against the possibility that libpq is still in COPY_IN state
when we reach the post-COPY "pump it dry" error recovery code that was added
2006-11-24.  Per a report from Neil Best, there is at least one code path
in which this occurs, leading to an infinite loop in code that's supposed
to be making it more robust not less so.  A reasonable response seems to be
to call PQputCopyEnd() again, so let's try that.

Back-patch to all versions that contain the cleanup loop.

15 years agoFix an ancient error in dist_ps (distance from point to line segment), which
Tom Lane [Tue, 23 Jun 2009 16:25:35 +0000 (16:25 +0000)]
Fix an ancient error in dist_ps (distance from point to line segment), which
a number of other geometric operators also depend on.  It miscalculated the
slope of the perpendicular to the given line segment anytime that slope was
other than 0, infinite, or +/-1.  In some cases the error would be masked
because the true closest point on the line segment was one of its endpoints
rather than the intersection point, but in other cases it could give an
arbitrarily bad answer.  Per bug #4872 from Nick Roosevelt.

Bug goes clear back to Berkeley days, so patch all supported branches.
Make a couple of cosmetic adjustments while at it.

16 years agoFix cash_in() to behave properly in locales where frac_digits is zero,
Tom Lane [Wed, 10 Jun 2009 16:32:02 +0000 (16:32 +0000)]
Fix cash_in() to behave properly in locales where frac_digits is zero,
eg Japan.  Report and fix by Itagaki Takahiro.  Also fix CASHDEBUG printout
format for branches with 64-bit money type, and some minor comment cleanup.

Back-patch to 7.4, because it's broken all the way back.

16 years agoAdjust recent PERL_SYS_INIT3 call to avoid platforms where it might fail, and to...
Andrew Dunstan [Fri, 5 Jun 2009 20:33:59 +0000 (20:33 +0000)]
Adjust recent PERL_SYS_INIT3 call to avoid platforms where it might fail, and to remove compilation warning. Backpatch the release 7.4

16 years agoInitialise perl library as documented in perl API. Backpatch to release 7.4.
Andrew Dunstan [Thu, 4 Jun 2009 16:01:23 +0000 (16:01 +0000)]
Initialise perl library as documented in perl API. Backpatch to release 7.4.

16 years agoSplit the release notes into a separate file for each (active) major branch,
Tom Lane [Sat, 2 May 2009 20:18:21 +0000 (20:18 +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.

16 years agoWhen checking for datetime field overflow, we should allow a fractional-second
Tom Lane [Fri, 1 May 2009 19:29:42 +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.

16 years agoFix the handling of sub-SELECTs appearing in the arguments of an outer-level
Tom Lane [Sat, 25 Apr 2009 16:45:34 +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.

16 years agoRemove HELIOS Software GmbH name and copyright from AIX dynloader files,
Bruce Momjian [Sat, 25 Apr 2009 15:53:26 +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.

16 years agoRemove beer-ware license from crypt-md5.c, per
Magnus Hagander [Wed, 15 Apr 2009 18:58:26 +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.

16 years agoFix 'all at one page bug' in picksplit method of R-tree emulation. Add defense
Teodor Sigaev [Tue, 7 Apr 2009 17:49:40 +0000 (17:49 +0000)]
Fix 'all at one page bug' in picksplit method of R-tree emulation. Add defense
from buggy user-defined picksplit to GiST.

16 years agoDefend against non-ASCII letters in fuzzystrmatch code. The functions
Tom Lane [Tue, 7 Apr 2009 15:54:30 +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.

16 years agoRewrite interval_hash() so that the hashcodes are equal for values that
Tom Lane [Sat, 4 Apr 2009 04:54:07 +0000 (04:54 +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".

16 years agoFix contrib/pgstattuple and contrib/pageinspect to prevent attempts to read
Tom Lane [Tue, 31 Mar 2009 22:56:28 +0000 (22:56 +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.

16 years agotag 7.4.25 REL7_4_25
Marc G. Fournier [Fri, 13 Mar 2009 02:39:42 +0000 (02:39 +0000)]
tag 7.4.25

16 years agoUpdate back-branch release notes.
Tom Lane [Thu, 12 Mar 2009 22:36:46 +0000 (22:36 +0000)]
Update back-branch release notes.

16 years agoFix core dump due to null-pointer dereference in to_char() when datetime
Tom Lane [Thu, 12 Mar 2009 00:54:04 +0000 (00:54 +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.

16 years agoAdd MUST (Mauritius Island Summer Time) to the list of known abbreviations.
Heikki Linnakangas [Thu, 5 Mar 2009 14:29:26 +0000 (14:29 +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

16 years agoPut back our old workaround for machines that declare cbrt() in math.h but
Tom Lane [Wed, 4 Mar 2009 22:08:53 +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.

16 years agoOoops ... fix some confusion between gettext() and _() in my previous patch.
Tom Lane [Tue, 3 Mar 2009 00:17:44 +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.

16 years agoWhen we are in error recursion trouble, arrange to suppress translation and
Tom Lane [Mon, 2 Mar 2009 21:19:23 +0000 (21:19 +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.

16 years agoFix buffer allocations in encoding conversion routines so that they won't
Tom Lane [Sat, 28 Feb 2009 18:50:25 +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.

16 years agoIn CREATE CONVERSION, test that the given function is a valid conversion
Heikki Linnakangas [Fri, 27 Feb 2009 16:35:53 +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.

16 years agotag 7.4.24 REL7_4_24
Marc G. Fournier [Fri, 30 Jan 2009 03:54:33 +0000 (03:54 +0000)]
tag 7.4.24

16 years agoUpdate back-branch release notes.
Tom Lane [Fri, 30 Jan 2009 00:38:26 +0000 (00:38 +0000)]
Update back-branch release notes.

16 years agoTranslation updates
Peter Eisentraut [Thu, 29 Jan 2009 22:02:17 +0000 (22:02 +0000)]
Translation updates

16 years agoReplace argument-checking Asserts with regular test-and-elog checks in all
Tom Lane [Thu, 29 Jan 2009 19:25:15 +0000 (19:25 +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.

16 years agoGo over all OpenSSL return values and make sure we compare them
Magnus Hagander [Wed, 28 Jan 2009 15:06:48 +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.

16 years agoFix uninitialized variables in get_covers
Teodor Sigaev [Fri, 16 Jan 2009 12:10:34 +0000 (12:10 +0000)]
Fix uninitialized variables in get_covers

16 years agoFix URL generation in headline. Only tag lexeme will be replaced by space.
Teodor Sigaev [Thu, 15 Jan 2009 18:30:10 +0000 (18:30 +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

16 years agoFix generation of too long headline with ShortWords.
Teodor Sigaev [Thu, 15 Jan 2009 18:29:47 +0000 (18:29 +0000)]
Fix generation of too long headline with ShortWords.
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php

16 years agoBackpatch to 7.4 the part of 1.84 (from the 8.0 timeline) that wasn't already
Alvaro Herrera [Tue, 13 Jan 2009 15:28:42 +0000 (15:28 +0000)]
Backpatch to 7.4 the part of 1.84 (from the 8.0 timeline) that wasn't already
patched, viz. str_numth().  The rest of that patch was already applied as part
of 1.69.2.1.  Per report and patch from Andreas 'ads' Scherbaum.

The involved revisions were:

revision 1.84
date: 2005-01-12 22:40:13 -0300;  author: tgl;  state: Exp;  lines: +9 -7;
branches:  1.84.4;
Remove unportable assumption that it's okay to use the target buffer
of an sprintf() as a source string.  Demonstrably does not work with
recent gcc and/or glibc on some platforms.

and

revision 1.69.2.1
date: 2005-03-25 20:42:21 -0400;  author: tgl;  state: Exp;  lines: +24 -8;
Prevent to_char(interval) from dumping core on month-related formats
when a zero-month interval is given.  Per discussion with Karel.

16 years agoRemove references to pgsql-ports and pgsql-patches mailing lists from
Tom Lane [Tue, 6 Jan 2009 17:28:15 +0000 (17:28 +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.

16 years agoFix logic in lazy vacuum to decide if it's worth trying to truncate the heap.
Heikki Linnakangas [Tue, 6 Jan 2009 14:56:13 +0000 (14:56 +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.

16 years agotag 7.4.23 REL7_4_23
Marc G. Fournier [Fri, 31 Oct 2008 03:15:21 +0000 (03:15 +0000)]
tag 7.4.23

16 years agoUpdate back-branch release notes.
Tom Lane [Thu, 30 Oct 2008 22:23:39 +0000 (22:23 +0000)]
Update back-branch release notes.

16 years agoTranslation updates
Peter Eisentraut [Thu, 30 Oct 2008 19:19:35 +0000 (19:19 +0000)]
Translation updates

16 years agoInstall a more robust solution for the problem of infinite error-processing
Tom Lane [Mon, 27 Oct 2008 19:37:56 +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.

16 years agoFix small bug in headline generation.
Teodor Sigaev [Fri, 17 Oct 2008 17:44:15 +0000 (17:44 +0000)]
Fix small bug in headline generation.
Patch from Sushant Sinha <sushant354@gmail.com>
http://archives.postgresql.org/pgsql-hackers/2008-07/msg00785.php

16 years agoFix SPI_getvalue and SPI_getbinval to range-check the given attribute number
Tom Lane [Thu, 16 Oct 2008 13:23:57 +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.

16 years agoOptional argument should be optional.
Michael Meskes [Fri, 10 Oct 2008 12:19:03 +0000 (12:19 +0000)]
Optional argument should be optional.

16 years agoFix improper display of fractional seconds in interval values
Tom Lane [Thu, 2 Oct 2008 13:48:12 +0000 (13:48 +0000)]
Fix improper display of fractional seconds in interval values
when using --enable-integer-datetimes and a non-ISO datestyle.

Ron Mayer

16 years agotag for 7.4.22 REL7_4_22
Marc G. Fournier [Fri, 19 Sep 2008 03:30:27 +0000 (03:30 +0000)]
tag for 7.4.22

16 years agoUpdate back-branch release notes.
Tom Lane [Fri, 19 Sep 2008 02:46:08 +0000 (02:46 +0000)]
Update back-branch release notes.

16 years agoFix pg_dump docs to acknowledge that you can use -Z with plain text output. Pointed...
Tom Lane [Tue, 26 Aug 2008 00:03:52 +0000 (00:03 +0000)]
Fix pg_dump docs to acknowledge that you can use -Z with plain text output.  Pointed out by Daniel Migowski.

16 years agoFix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec
Tom Lane [Sat, 16 Aug 2008 02:25:38 +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.

16 years agoDo not allow Unique nodes to be scanned backwards. The code claimed that it
Tom Lane [Tue, 5 Aug 2008 21:29:01 +0000 (21:29 +0000)]
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.

16 years agoFix performance bug in write_syslog(): the code to preferentially break the
Tom Lane [Tue, 8 Jul 2008 22:18:18 +0000 (22:18 +0000)]
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.

16 years agoFix estimate_num_groups() to assume that GROUP BY expressions yielding boolean
Tom Lane [Mon, 7 Jul 2008 20:25:40 +0000 (20:25 +0000)]
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.

17 years agoCreate a script to handle stamping release version numbers into files,
Tom Lane [Tue, 10 Jun 2008 18:09:26 +0000 (18:09 +0000)]
Create a script to handle stamping release version numbers into files,
replacing the tedious and error-prone manual process we've been using.

17 years agoFix datetime input functions to correctly detect integer overflow when
Tom Lane [Mon, 9 Jun 2008 19:34:40 +0000 (19:34 +0000)]
Fix datetime input functions to correctly detect integer overflow when
running on a 64-bit platform ... strtol() will happily return 64-bit
output in that case.  Per bug #4231 from Geoff Tolley.

17 years agotag 7.4.21 REL7_4_21
Tom Lane [Mon, 9 Jun 2008 00:16:58 +0000 (00:16 +0000)]
tag 7.4.21

17 years agoStamp 7.4.21 (except for configure.in/configure)
Tom Lane [Sun, 8 Jun 2008 22:15:45 +0000 (22:15 +0000)]
Stamp 7.4.21 (except for configure.in/configure)

17 years agoUpdate release notes for 8.3.3 et al.
Tom Lane [Sat, 7 Jun 2008 22:11:40 +0000 (22:11 +0000)]
Update release notes for 8.3.3 et al.

17 years agoFix pg_get_ruledef() so that negative numeric constants are parenthesized.
Tom Lane [Fri, 6 Jun 2008 18:00:09 +0000 (18:00 +0000)]
Fix pg_get_ruledef() so that negative numeric constants are parenthesized.
This is needed because :: casting binds more tightly than minus, so for
example -1::integer is not the same as (-1)::integer, and there are cases
where the difference is important.  In particular this caused a failure
in SELECT DISTINCT ... ORDER BY ... where expressions that should have
matched were seen as different by the parser; but I suspect that there
could be other cases where failure to parenthesize leads to subtler
semantic differences in reloaded rules.  Per report from Alexandr Popov.

17 years agoRemove link that pre-8.2 doc tools don't support. REL7_4_20
Tom Lane [Fri, 6 Jun 2008 05:34:03 +0000 (05:34 +0000)]
Remove link that pre-8.2 doc tools don't support.

17 years agotag 7.4.20
Tom Lane [Fri, 6 Jun 2008 04:37:07 +0000 (04:37 +0000)]
tag 7.4.20

17 years agoStamp 7.4.20 (except for configure.in/configure)
Tom Lane [Thu, 5 Jun 2008 23:56:42 +0000 (23:56 +0000)]
Stamp 7.4.20 (except for configure.in/configure)

17 years agoTranslation updates.
Tom Lane [Thu, 5 Jun 2008 23:38:03 +0000 (23:38 +0000)]
Translation updates.

17 years agoDraft release notes for upcoming back-branch updates.
Tom Lane [Wed, 4 Jun 2008 03:17:01 +0000 (03:17 +0000)]
Draft release notes for upcoming back-branch updates.

17 years agoImprove GRANT documentation to point out that UPDATE and DELETE typically
Tom Lane [Wed, 28 May 2008 00:46:12 +0000 (00:46 +0000)]
Improve GRANT documentation to point out that UPDATE and DELETE typically
require SELECT privilege as well, since you normally need to read existing
column values within such commands.  This behavior is according to spec,
but we'd never documented it before.  Per gripe from Volkan Yazici.

17 years agoBack-patch the 8.3 fix that prohibits TRUNCATE, CLUSTER, and REINDEX when the
Tom Lane [Tue, 27 May 2008 21:14:00 +0000 (21:14 +0000)]
Back-patch the 8.3 fix that prohibits TRUNCATE, CLUSTER, and REINDEX when the
current transaction has any open references to the target relation or index
(implying it has an active query using the relation).  Also back-patch the
8.2 fix that prohibits TRUNCATE and CLUSTER when there are pending
AFTER-trigger events.  Per suggestion from Heikki.

17 years agoAdjust timestamp regression tests to prevent two low-probability failure
Tom Lane [Sun, 25 May 2008 21:51:38 +0000 (21:51 +0000)]
Adjust timestamp regression tests to prevent two low-probability failure
cases.  Recent buildfarm experience shows that it is sometimes possible
to execute several SQL commands in less time than the granularity of
Windows' not-very-high-resolution gettimeofday(), leading to a failure
because the tests expect the value of now() to change and it doesn't.
Also, it was recognized some time ago that the same area of the tests
could fail if local midnight passes between the insertion and the checking
of the values for 'yesterday', 'tomorrow', etc.  Clean all this up per
ideas from myself and Greg Stark.

There remains a window for failure if the transaction block is entered
exactly at local midnight (so that 'now' and 'today' have the same value),
but that seems low-probability enough to live with.

Since the point of this change is mostly to eliminate buildfarm noise,
back-patch to all versions we are still actively testing.

17 years agoDon't try to close negative file descriptors, since this can cause
Magnus Hagander [Tue, 13 May 2008 20:53:54 +0000 (20:53 +0000)]
Don't try to close negative file descriptors, since this can cause
crashes on certain platforms. In particular, the MSVC runtime is known
to do this.

Fixes bug #4162, reported and diagnosed by Javier Pimas

17 years agoFix an ancient oversight in change_varattnos_of_a_node: it neglected to update
Tom Lane [Fri, 9 May 2008 22:38:05 +0000 (22:38 +0000)]
Fix an ancient oversight in change_varattnos_of_a_node: it neglected to update
varoattno along with varattno.  This resulted in having Vars that were not
seen as equal(), causing inheritance of the "same" constraint from different
parent relations to fail.  An example is

create table pp1 (f1 int check (f1>0));
create table cc1 (f2 text, f3 int) inherits (pp1);
create table cc2(f4 float) inherits(pp1,cc1);

Backpatch as far as 7.4.  (The test case still fails in 7.4, for reasons
that I don't feel like investigating at the moment.)

This is a backpatch commit only.  The fix will be applied in HEAD as part
of the upcoming pg_constraint patch.

17 years agoReplace developer FAQ with a reference to the wiki, which is where
Magnus Hagander [Tue, 22 Apr 2008 09:26:34 +0000 (09:26 +0000)]
Replace developer FAQ with a reference to the wiki, which is where
it now lives (per discussion). Leave the other FAQs alone for now.

17 years agoAdd link to major version release notes at the top of the minor
Magnus Hagander [Mon, 21 Apr 2008 09:44:54 +0000 (09:44 +0000)]
Add link to major version release notes at the top of the minor
version ones, to make it clear to users just browsing the notes
that there are a lot more changes available from whatever version
they are at than what's in the minor version release notes.

17 years agoFix several datatype input functions that were allowing unused bytes in their
Tom Lane [Fri, 11 Apr 2008 22:53:33 +0000 (22:53 +0000)]
Fix several datatype input functions that were allowing unused bytes in their
results to contain uninitialized, unpredictable values.  While this was okay
as far as the datatypes themselves were concerned, it's a problem for the
parser because occurrences of the "same" literal might not be recognized as
equal by datumIsEqual (and hence not by equal()).  It seems sufficient to fix
this in the input functions since the only critical use of equal() is in the
parser's comparisons of ORDER BY and DISTINCT expressions.
Per a trouble report from Marc Cousin.

Patch all the way back.  Interestingly, array_in did not have the bug before
8.2, which may explain why the issue went unnoticed for so long.

17 years agoFixed bug in PGTYPEStimestamp_sub that used pointers instead of the values to substract.
Michael Meskes [Thu, 10 Apr 2008 10:46:56 +0000 (10:46 +0000)]
Fixed bug in PGTYPEStimestamp_sub that used pointers instead of the values to substract.

17 years agoDefend against JOINs having more than 32K columns altogether. We cannot
Tom Lane [Sat, 5 Apr 2008 01:59:01 +0000 (01:59 +0000)]
Defend against JOINs having more than 32K columns altogether.  We cannot
currently support this because we must be able to build Vars referencing
join columns, and varattno is only 16 bits wide.  Perhaps this should be
improved in future, but considering that it never came up before, I'm not
sure the problem is worth much effort.  Per bug #4070 from Marcello
Ceschia.

The problem seems largely academic in 8.0 and 7.4, because they have
(different) O(N^2) performance issues with such wide joins, but
back-patch all the way anyway.

17 years agoAdjust DatumGetBool macro so that it isn't fooled by garbage in the Datum
Tom Lane [Tue, 25 Mar 2008 19:31:53 +0000 (19:31 +0000)]
Adjust DatumGetBool macro so that it isn't fooled by garbage in the Datum
to the left of the actual bool value.  While in most cases there won't be
any, our support for old-style user-defined functions violates the C spec
to the extent of calling functions that might return char or short through
a function pointer declared to return "char *", which we then coerce to
Datum.  It is not surprising that the result might contain garbage
high-order bits ... what is surprising is that we didn't see such cases
long ago.  Per report from Magnus.

This is a back-patch of a change that was made in HEAD almost exactly
a year ago.  I had refrained from back-patching at the time, but now
we find that this is *necessary* for contrib to work with gcc 4.3.

17 years agoAdd the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
Heikki Linnakangas [Thu, 20 Mar 2008 10:52:57 +0000 (10:52 +0000)]
Add the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
ISO_8859-5 <-> MULE_INTERNAL conversion tables.

This was discovered when trying to convert a string containing those characters
from ISO_8859-5 to Windows-1251, because we use MULE_INTERNAL/KOI8R as an
intermediate encoding between those two.

While the missing "Yo" was just an omission in the conversion tables, there are
a few other characters like the "Numero" sign ("No" as a single character) that
exists in all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
not in KOI8R. Added comments about that.

Patch by Sergey Burladyan. Back-patch to 7.4.

17 years agoFix regexp substring matching (substring(string from pattern)) for the corner
Tom Lane [Wed, 19 Mar 2008 02:41:15 +0000 (02:41 +0000)]
Fix regexp substring matching (substring(string from pattern)) for the corner
case where there is a match to the pattern overall but the user has specified
a parenthesized subexpression and that subexpression hasn't got a match.
An example is substring('foo' from 'foo(bar)?').  This should return NULL,
since (bar) isn't matched, but it was mistakenly returning the whole-pattern
match instead (ie, 'foo').  Per bug #4044 from Rui Martins.

This has been broken since the beginning; patch in all supported versions.
The old behavior was sufficiently inconsistent that it's impossible to believe
anyone is depending on it.

17 years agoFix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
Tom Lane [Wed, 12 Mar 2008 20:12:48 +0000 (20:12 +0000)]
Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
pg_listener modifications commanded by LISTEN and UNLISTEN until the end
of the current transaction.  This allows us to hold the ExclusiveLock on
pg_listener until after commit, with no greater risk of deadlock than there
was before.  Aside from fixing the race condition, this gets rid of a
truly ugly kludge that was there before, namely having to ignore
HeapTupleBeingUpdated failures during NOTIFY.  There is a small potential
incompatibility, which is that if a transaction issues LISTEN or UNLISTEN
and then looks into pg_listener before committing, it won't see any resulting
row insertion or deletion, where before it would have.  It seems unlikely
that anyone would be depending on that, though.

17 years agoAdd support for dlopen on recent NetBSD/MIPS, per Rémi Zara.
Alvaro Herrera [Wed, 5 Mar 2008 21:20:51 +0000 (21:20 +0000)]
Add support for dlopen on recent NetBSD/MIPS, per Rémi Zara.

17 years agoIf RelationBuildDesc() fails to open a critical system index, PANIC with
Tom Lane [Wed, 27 Feb 2008 17:45:02 +0000 (17:45 +0000)]
If RelationBuildDesc() fails to open a critical system index, PANIC with
a relevant error message instead of just dumping core.  Odd that nobody
reported this before Darren Reed.

17 years agoUse our own getopt() and getopt_long() on Solaris, because that platform's
Tom Lane [Sun, 24 Feb 2008 05:22:44 +0000 (05:22 +0000)]
Use our own getopt() and getopt_long() on Solaris, because that platform's
versions don't handle long options the way we want.  Per Zdenek Kotala.

17 years agoAvoid trying to print a NULL char pointer in --describe-config. On some
Tom Lane [Sat, 23 Feb 2008 19:24:09 +0000 (19:24 +0000)]
Avoid trying to print a NULL char pointer in --describe-config.  On some
platforms this works, but on some it crashes.  Zdenek Kotala

17 years agoRepair VACUUM FULL bug introduced by HOT patch: the original way of
Tom Lane [Mon, 11 Feb 2008 19:15:00 +0000 (19:15 +0000)]
Repair VACUUM FULL bug introduced by HOT patch: the original way of
calculating a page's initial free space was fine, and should not have been
"improved" by letting PageGetHeapFreeSpace do it.  VACUUM FULL is going to
reclaim LP_DEAD line pointers later, so there is no need for a guard
against the page being too full of line pointers, and having one risks
rejecting pages that are perfectly good move destinations.

This also exposed a second bug, which is that the empty_end_pages logic
assumed that any page with no live tuples would get entered into the
fraged_pages list automatically (by virtue of having more free space than
the threshold in the do_frag calculation).  This assumption certainly
seems risky when a low fillfactor has been chosen, and even without
tunable fillfactor I think it could conceivably fail on a page with many
unused line pointers.  So fix the code to force do_frag true when notup
is true, and patch this part of the fix all the way back.

Per report from Tomas Szepe.

17 years agoFix an ancient oversight in libpq's handling of V3-protocol COPY OUT mode:
Tom Lane [Mon, 14 Jan 2008 18:46:49 +0000 (18:46 +0000)]
Fix an ancient oversight in libpq's handling of V3-protocol COPY OUT mode:
we need to be able to swallow NOTICE messages, and potentially also
ParameterStatus messages (although the latter would be a bit weird),
without exiting COPY OUT state.  Fix it, and adjust the protocol documentation
to emphasize the need for this.  Per off-list report from Alexander Galler.

17 years agoA long time ago, Peter pointed out that ruleutils.c didn't dump simple
Tom Lane [Sun, 6 Jan 2008 01:03:46 +0000 (01:03 +0000)]
A long time ago, Peter pointed out that ruleutils.c didn't dump simple
constant ORDER/GROUP BY entries properly:
http://archives.postgresql.org/pgsql-hackers/2001-04/msg00457.php
The original solution to that was in fact no good, as demonstrated by
today's report from Martin Pitt:
http://archives.postgresql.org/pgsql-bugs/2008-01/msg00027.php
We can't use the column-number-reference format for a constant that is
a resjunk targetlist entry, a case that was unfortunately not thought of
in the original discussion.  What we can do instead (which did not work
at the time, but does work in 7.3 and up) is to emit the constant with
explicit ::typename decoration, even if it otherwise wouldn't need it.
This is sufficient to keep the parser from thinking it's a column number
reference, and indeed is probably what the user must have done to get
such a thing into the querytree in the first place.

17 years agoStamp release 7.4.19. REL7_4_19
Tom Lane [Thu, 3 Jan 2008 21:42:17 +0000 (21:42 +0000)]
Stamp release 7.4.19.

Security: CVE-2007-4769, CVE-2007-4772, CVE-2007-6067, CVE-2007-6600, CVE-2007-6601

17 years agoUpdate release notes for security releases.
Tom Lane [Thu, 3 Jan 2008 21:36:15 +0000 (21:36 +0000)]
Update release notes for security releases.

Security: CVE-2007-4769, CVE-2007-4772, CVE-2007-6067, CVE-2007-6600, CVE-2007-6601

17 years agoThe original patch to disallow non-passworded connections to non-superusers
Tom Lane [Thu, 3 Jan 2008 21:28:55 +0000 (21:28 +0000)]
The original patch to disallow non-passworded connections to non-superusers
failed to cover all the ways in which a connection can be initiated in dblink.
Plug the remaining holes.  Also, disallow transient connections in functions
for which that feature makes no sense (because they are only sensible as
part of a sequence of operations on the same connection).  Joe Conway

Security: CVE-2007-6601