]> granicus.if.org Git - postgresql/log
postgresql
17 years agoAdd the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
Heikki Linnakangas [Thu, 20 Mar 2008 10:38:34 +0000 (10:38 +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:00 +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 agoUpdate to tzdata 2008a distribution (Chilean DST law change).
Tom Lane [Thu, 13 Mar 2008 19:22:04 +0000 (19:22 +0000)]
Update to tzdata 2008a distribution (Chilean DST law change).

17 years agoFix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
Tom Lane [Wed, 12 Mar 2008 20:12:14 +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.

This patch also disallows LISTEN and UNLISTEN inside a prepared transaction.
That case had some pretty undesirable properties already, such as possibly
allowing pg_listener entries to be made for PIDs no longer present, so
disallowing it seems like a better idea than trying to maintain the behavior.

17 years agoUse -fwrapv in CFLAGS if we are using a version of gcc that accepts this flag.
Tom Lane [Mon, 10 Mar 2008 21:50:40 +0000 (21:50 +0000)]
Use -fwrapv in CFLAGS if we are using a version of gcc that accepts this flag.
This prevents compiler optimizations that assume overflow won't occur, which
breaks numerous overflow tests that we need to have working.  It is known
that gcc 4.3 causes problems and possible that 4.1 does.  Per my proposal
of some time ago and a recent report from Kris Jurka.

Backpatch as far as 8.0, which is as far as the patch conveniently goes.
7.x was pretty short of overflow tests anyway, so it may not matter there,
even assuming that anyone cares whether 7.x builds on recent gcc.

17 years agoChange hashscan.c to keep its list of active hash index scans in
Tom Lane [Fri, 7 Mar 2008 15:59:23 +0000 (15:59 +0000)]
Change hashscan.c to keep its list of active hash index scans in
TopMemoryContext, rather than scattered through executor per-query contexts.
This poses no danger of memory leak since the ResourceOwner mechanism
guarantees release of no-longer-needed items.  It is needed because the
per-query context might already be released by the time we try to clean up
the hash scan list.  Report by ykhuang, diagnosis by Heikki.

Back-patch to 8.0, where the ResourceOwner-based cleanup was introduced.
The given test case does not fail before 8.2, probably because we rearranged
transaction abort processing somehow; but this coding is undoubtedly risky
so I'll patch 8.0 and 8.1 anyway.

17 years agoAdd support for dlopen on recent NetBSD/MIPS, per Rémi Zara.
Alvaro Herrera [Wed, 5 Mar 2008 21:20:50 +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:44:41 +0000 (17:44 +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 agoFix datetime input to behave correctly for Feb 29 in years BC.
Tom Lane [Mon, 25 Feb 2008 23:21:22 +0000 (23:21 +0000)]
Fix datetime input to behave correctly for Feb 29 in years BC.

Formerly, DecodeDate attempted to verify the day-of-the-month exactly, but
it was under the misapprehension that it would know whether we were looking
at a BC year or not.  In reality this check can't be made until the calling
function (eg DecodeDateTime) has processed all the fields.  So, split the
BC adjustment and validity checks out into a new function ValidateDate that
is called only after processing all the fields.  In passing, this patch
makes DecodeTimeOnly work for BC inputs, which it never did before.

(The historical veracity of all this is nonexistent, of course, but if
we're going to say we support proleptic Gregorian calendar then we should
do it correctly.  In any case the unpatched code is broken because it could
emit dates that it would then reject on re-inputting.)

Per report from Bernd Helmle.  Back-patch as far as 8.0; in 7.x we were
not using our own calendar support and so this seems a bit too risky
to put into 7.4.

17 years agoUse our own getopt() and getopt_long() on Solaris, because that platform's
Tom Lane [Sun, 24 Feb 2008 05:22:22 +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:23:51 +0000 (19:23 +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 agoFix mistakes in pg_ctl's code for "start -w" that tries to cope with
Tom Lane [Wed, 20 Feb 2008 22:18:35 +0000 (22:18 +0000)]
Fix mistakes in pg_ctl's code for "start -w" that tries to cope with
non-default settings for the postmaster's port number.  The code to parse
command line options and postgresql.conf entries wasn't quite right about
whitespace or quotes, and it was coded in a not-very-readable way too.
Per bug #3969 from Itagaki Takahiro, though this is more extensive than his
proposed patch (which fixed only the whitespace problem).
This code has been broken since it was put in in 8.0, so patch all the way
back.

17 years agoPut a CHECK_FOR_INTERRUPTS call into the loops that try to find a unique new
Tom Lane [Wed, 20 Feb 2008 17:44:26 +0000 (17:44 +0000)]
Put a CHECK_FOR_INTERRUPTS call into the loops that try to find a unique new
OID or new relfilenode.  If the existing OIDs are sufficiently densely
populated, this could take a long time (perhaps even be an infinite loop),
so it seems wise to allow the system to respond to a cancel interrupt here.
Per a gripe from Jacky Leng.

Backpatch as far as 8.1.  Older versions just fail on OID collision,
instead of looping.

17 years agoRepair VACUUM FULL bug introduced by HOT patch: the original way of
Tom Lane [Mon, 11 Feb 2008 19:14:45 +0000 (19:14 +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 agoSome variants of ALTER OWNER tried to make the "object" field of the
Tom Lane [Thu, 7 Feb 2008 21:08:16 +0000 (21:08 +0000)]
Some variants of ALTER OWNER tried to make the "object" field of the
statement be a list of bare C strings, rather than String nodes, which is
what they need to be for copyfuncs/equalfuncs to work.  Fortunately these
node types never go out to disk (if they did, we'd likely have noticed the
problem sooner), so we can just fix it without creating a need for initdb.
This bug has been there since 8.0, but 8.3 exposes it in a more common
code path (Parse messages) than prior releases did.  Per bug #3940 from
Vladimir Kokovic.

17 years agoWork around for perl 5.10 bug - fix due to perl hacker Simon Cozens.
Andrew Dunstan [Tue, 22 Jan 2008 20:41:39 +0000 (20:41 +0000)]
Work around for perl 5.10 bug - fix due to perl hacker Simon Cozens.

17 years agoBackpatch my fix of rev 1.48 to avoid a division-by-zero error in the
Alvaro Herrera [Thu, 17 Jan 2008 23:47:07 +0000 (23:47 +0000)]
Backpatch my fix of rev 1.48 to avoid a division-by-zero error in the
cost-limit vacuum code.  Per trouble report from Joshua Drake.

17 years agoFix an ancient oversight in libpq's handling of V3-protocol COPY OUT mode:
Tom Lane [Mon, 14 Jan 2008 18:46:33 +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:31 +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 8.1.11. REL8_1_11
Tom Lane [Thu, 3 Jan 2008 21:41:24 +0000 (21:41 +0000)]
Stamp release 8.1.11.

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:35:49 +0000 (21:35 +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:30 +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

17 years agoMake standard maintenance operations (including VACUUM, ANALYZE, REINDEX,
Tom Lane [Thu, 3 Jan 2008 21:24:26 +0000 (21:24 +0000)]
Make standard maintenance operations (including VACUUM, ANALYZE, REINDEX,
and CLUSTER) execute as the table owner rather than the calling user, using
the same privilege-switching mechanism already used for SECURITY DEFINER
functions.  The purpose of this change is to ensure that user-defined
functions used in index definitions cannot acquire the privileges of a
superuser account that is performing routine maintenance.  While a function
used in an index is supposed to be IMMUTABLE and thus not able to do anything
very interesting, there are several easy ways around that restriction; and
even if we could plug them all, there would remain a risk of reading sensitive
information and broadcasting it through a covert channel such as CPU usage.

To prevent bypassing this security measure, execution of SET SESSION
AUTHORIZATION and SET ROLE is now forbidden within a SECURITY DEFINER context.

Thanks to Itagaki Takahiro for reporting this vulnerability.

Security: CVE-2007-6600

17 years agoFix assorted security-grade bugs in the regex engine. All of these problems
Tom Lane [Thu, 3 Jan 2008 20:48:57 +0000 (20:48 +0000)]
Fix assorted security-grade bugs in the regex engine.  All of these problems
are shared with Tcl, since it's their code to begin with, and the patches
have been copied from Tcl 8.5.0.  Problems:

CVE-2007-4769: Inadequate check on the range of backref numbers allows
crash due to out-of-bounds read.
CVE-2007-4772: Infinite loop in regex optimizer for pattern '($|^)*'.
CVE-2007-6067: Very slow optimizer cleanup for regex with a large NFA
representation, as well as crash if we encounter an out-of-memory condition
during NFA construction.

Part of the response to CVE-2007-6067 is to put a limit on the number of
states in the NFA representation of a regex.  This seems needed even though
the within-the-code problems have been corrected, since otherwise the code
could try to use very large amounts of memory for a suitably-crafted regex,
leading to potential DOS by driving the system into swap, activating a kernel
OOM killer, etc.

Although there are certainly plenty of ways to drive the system into effective
DOS with poorly-written SQL queries, these problems seem worth treating as
security issues because many applications might accept regex search patterns
from untrustworthy sources.

Thanks to Will Drewry of Google for reporting these problems.  Patches by Will
Drewry and Tom Lane.

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

17 years agoInsert ARST into the list of known timezone abbreviations.
Tom Lane [Wed, 2 Jan 2008 22:05:21 +0000 (22:05 +0000)]
Insert ARST into the list of known timezone abbreviations.

17 years agoFix invalid ipv6 address in example. Per doc comment 7211.
Magnus Hagander [Wed, 2 Jan 2008 19:53:19 +0000 (19:53 +0000)]
Fix invalid ipv6 address in example. Per doc comment 7211.

17 years agoUpdate time zone data files to tzdata release 2007k.
Tom Lane [Tue, 1 Jan 2008 20:45:25 +0000 (20:45 +0000)]
Update time zone data files to tzdata release 2007k.

17 years agoProvide a more helpful error message when there is an autoconf version
Bruce Momjian [Mon, 31 Dec 2007 17:28:12 +0000 (17:28 +0000)]
Provide a more helpful error message when there is an autoconf version
mismatch;  backpatch.

17 years agoMake path_recv() and poly_recv() reject paths/polygons containing no points.
Tom Lane [Tue, 18 Dec 2007 00:04:22 +0000 (00:04 +0000)]
Make path_recv() and poly_recv() reject paths/polygons containing no points.
The zero-point case is sensible so far as the data structure is concerned,
so maybe we ought to allow it sometime; but right now the textual input
routines for these types don't allow it, and it seems that not all the
functions for the types are prepared to cope.
Report and patch by Merlin Moncure.

17 years agoSuppress compiler warnings in recent plperl patch. Avoid uselessly expensive
Tom Lane [Sat, 1 Dec 2007 17:58:54 +0000 (17:58 +0000)]
Suppress compiler warnings in recent plperl patch.  Avoid uselessly expensive
lookup of the well-known OID of textout().

17 years agoWorkaround for perl problem where evaluating UTF8 regexes can cause
Andrew Dunstan [Sat, 1 Dec 2007 15:39:49 +0000 (15:39 +0000)]
Workaround for perl problem where evaluating UTF8 regexes can cause
implicit loading of modules, thereby breaking Safe rules.
We compile and call a tiny perl function on trusted interpreter init, after which
the problem does not occur.

17 years agoRequire a specific Autoconf version, instead of a lower bound only.
Peter Eisentraut [Mon, 26 Nov 2007 12:27:03 +0000 (12:27 +0000)]
Require a specific Autoconf version, instead of a lower bound only.

17 years agoFix buggy usage of vsnprintf in PL/Python by removing it altogether, instead
Alvaro Herrera [Fri, 23 Nov 2007 01:47:12 +0000 (01:47 +0000)]
Fix buggy usage of vsnprintf in PL/Python by removing it altogether, instead
relying on stringinfo.c.  This fixes a problem reported by Marko Kreen, but I
didn't use his patch, per subsequent discussion.

17 years agoFix "Overall Page Layout" table. The second row should be ItemIdData, not
Tatsuo Ishii [Fri, 23 Nov 2007 00:30:58 +0000 (00:30 +0000)]
Fix "Overall Page Layout" table. The second row should be ItemIdData, not
ItemPointerData.

17 years agoPrevent Perl from introducing a possibly-incompatible definition of type
Tom Lane [Thu, 22 Nov 2007 17:47:40 +0000 (17:47 +0000)]
Prevent Perl from introducing a possibly-incompatible definition of type
"bool" into plperl.c.  This has always been a hazard since Perl allows a
platform-specific choice to define bool as int rather than char, but
evidently this didn't happen on any platform we support ... until OS X 10.5.
Per report from Brandon Maust.

Back-patch as far as 8.0 --- a bit arbitrary, but it seems unlikely anyone
will be trying to port 7.x onto new platforms.

17 years agoBackpatch: Fix tsvector_out() and tsquery_out() to escape backslesh, add test of...
Teodor Sigaev [Fri, 16 Nov 2007 17:09:15 +0000 (17:09 +0000)]
Backpatch: Fix tsvector_out() and tsquery_out() to escape backslesh, add test of that.
Patch by Bruce Momjian <bruce@momjian.us>

17 years agoUpdate timezone data files to release 2007i of the zic database.
Tom Lane [Thu, 15 Nov 2007 21:21:26 +0000 (21:21 +0000)]
Update timezone data files to release 2007i of the zic database.

17 years agoHave crosstab variants treat NULL rowid as a category in its own right,
Joe Conway [Sat, 10 Nov 2007 05:01:50 +0000 (05:01 +0000)]
Have crosstab variants treat NULL rowid as a category in its own right,
per suggestion from Tom Lane. This fixes crash-bug reported by Stefan
Schwarzer.

17 years agoSecond pass at improving LIKE/regex estimation in non-C locales. It turns
Tom Lane [Fri, 9 Nov 2007 20:10:20 +0000 (20:10 +0000)]
Second pass at improving LIKE/regex estimation in non-C locales.  It turns
out that it's actually quite likely that a string that is an extension of
the given prefix will sort as larger than the "greater" string our previous
code created.  To provide some defense against that, do the comparisons
against a modified string instead of just the bare prefix.  We tack on
"Z", "z", "y", or "9", whichever is seen as largest in the current locale.
Testing suggests that this is sufficient at least for cases involving
ASCII data.

17 years agoIf an index depends on no columns of its table, give it a dependency on the
Tom Lane [Thu, 8 Nov 2007 23:23:07 +0000 (23:23 +0000)]
If an index depends on no columns of its table, give it a dependency on the
whole table instead, to ensure that it goes away when the table is dropped.
Per bug #3723 from Sam Mason.

Backpatch as far as 7.4; AFAICT 7.3 does not have the issue, because it doesn't
have general-purpose expression indexes and so there must be at least one
column referenced by an index.

17 years agoImprove the performance of LIKE/regex estimation in non-C locales, by making
Tom Lane [Wed, 7 Nov 2007 22:37:43 +0000 (22:37 +0000)]
Improve the performance of LIKE/regex estimation in non-C locales, by making
make_greater_string() try harder to generate a string that's actually greater
than its input string.  Before we just assumed that making a string that was
memcmp-greater was enough, but it is easy to generate examples where this is
not so when the locale is not C.  Instead, loop until the relevant comparison
function agrees that the generated string is greater than the input.

Unfortunately this is probably not enough to guarantee that the generated
string is greater than all extensions of the input, so we cannot relax the
restriction to C locale for the LIKE/regex index optimization.  But it should
at least improve the odds of getting a useful selectivity estimate in
prefix_selectivity().  Per example from Guillaume Smet.

Backpatch to 8.1, mainly because that's what the complainant is using...

17 years agoFixed two parser bugs.
Michael Meskes [Tue, 6 Nov 2007 08:32:57 +0000 (08:32 +0000)]
Fixed two parser bugs.

17 years agoFix a couple of issues with pg_dump's handling of inheritance child tables
Tom Lane [Sun, 28 Oct 2007 19:08:16 +0000 (19:08 +0000)]
Fix a couple of issues with pg_dump's handling of inheritance child tables
that have default expressions different from their parent.  First, if the
parent table's default expression has to be split out as a separate
ALTER TABLE command, we need a dependency constraint to ensure that the
child's command is given second.  This is because the ALTER TABLE on the
parent will propagate to the child.  (We can't prevent that by using ONLY on
the parent's command, since it's possible that other children exist that
should receive the inherited default.)  Second, if the child has a NULL
default where the parent does not, we have to explicitly say DEFAULT NULL on
the child in order for this state to be preserved after reload.  (The latter
actually doesn't work right because of a backend bug, but that is a separate
issue.)

Backpatch as far as 8.0.  7.x pg_dump has enough issues with altered tables
(due to lack of dependency analysis) that trying to fix this one doesn't seem
very productive.

17 years agoFix ALTER COLUMN TYPE to preserve the tablespace and reloptions of indexes
Tom Lane [Sat, 13 Oct 2007 15:55:58 +0000 (15:55 +0000)]
Fix ALTER COLUMN TYPE to preserve the tablespace and reloptions of indexes
it affects.  The original coding neglected tablespace entirely (causing
the indexes to move to the database's default tablespace) and for an index
belonging to a UNIQUE or PRIMARY KEY constraint, it would actually try to
assign the parent table's reloptions to the index :-(.  Per bug #3672 and
subsequent investigation.

8.0 and 8.1 did not have reloptions, but the tablespace bug is present.

17 years agoEnsure that the result of evaluating a function during constant-expression
Tom Lane [Thu, 11 Oct 2007 21:28:12 +0000 (21:28 +0000)]
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

17 years agoDon't try to free pgpassfile since it's a stack variable.
Magnus Hagander [Tue, 9 Oct 2007 15:03:30 +0000 (15:03 +0000)]
Don't try to free pgpassfile since it's a stack variable.

Martin Pitt

17 years agoKeep the planner from failing on "WHERE false AND something IN (SELECT ...)".
Tom Lane [Thu, 4 Oct 2007 20:45:02 +0000 (20:45 +0000)]
Keep the planner from failing on "WHERE false AND something IN (SELECT ...)".
eval_const_expressions simplifies this to just "WHERE false", but we have
already done pull_up_IN_clauses so the IN join will be done, or at least
planned, anyway.  The trouble case comes when the sub-SELECT is itself a join
and we decide to implement the IN by unique-ifying the sub-SELECT outputs:
with no remaining reference to the output Vars in WHERE, we won't have
propagated the Vars up to the upper join point, leading to "variable not found
in subplan target lists" error.  Fix by adding an extra scan of in_info_list
and forcing all Vars mentioned therein to be propagated up to the IN join
point.  Per bug report from Miroslav Sulc.

17 years agoUpdate timezone data files to release 2007h of the zic database.
Tom Lane [Thu, 4 Oct 2007 19:07:14 +0000 (19:07 +0000)]
Update timezone data files to release 2007h of the zic database.
Might as well have the latest when we wrap 8.3beta1.

17 years agoDefend against openssl libraries that fail on keys longer than 128 bits;
Tom Lane [Sat, 29 Sep 2007 15:50:07 +0000 (15:50 +0000)]
Defend against openssl libraries that fail on keys longer than 128 bits;
which is the case at least on some Solaris versions.  Marko Kreen

17 years agoMake archive recovery always start a new timeline, rather than only when a
Tom Lane [Sat, 29 Sep 2007 01:36:29 +0000 (01:36 +0000)]
Make archive recovery always start a new timeline, rather than only when a
recovery stop time was used.  This avoids a corner-case risk of trying to
overwrite an existing archived copy of the last WAL segment, and seems
simpler and cleaner all around than the original definition.  Per example
from Jon Colverson and subsequent analysis by Simon.

17 years agoFix crash of to_tsvector() function on huge input: compareWORD()
Teodor Sigaev [Wed, 26 Sep 2007 10:30:53 +0000 (10:30 +0000)]
Fix crash of to_tsvector() function on huge input: compareWORD()
function didn't return correct result for word position greate than
limit.

Per report from Stuart Bishop <stuart@stuartbishop.net>

17 years agoReduce the size of memory allocations by lazy vacuum when processing a small
Alvaro Herrera [Mon, 24 Sep 2007 03:53:06 +0000 (03:53 +0000)]
Reduce the size of memory allocations by lazy vacuum when processing a small
table, by allocating just enough for a hardcoded number of dead tuples per
page.  The current estimate is 200 dead tuples per page.

Per reports from Jeff Amiel, Erik Jones and Marko Kreen, and subsequent
discussion.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:  commands/vacuumlazy.c
CVS: ----------------------------------------------------------------------

17 years agoFix bogus calculation of potential output string length in translate().
Tom Lane [Sat, 22 Sep 2007 05:36:00 +0000 (05:36 +0000)]
Fix bogus calculation of potential output string length in translate().

17 years agoFix overflow in extract(epoch from interval) for intervals exceeding 68 years.
Tom Lane [Sun, 16 Sep 2007 15:56:39 +0000 (15:56 +0000)]
Fix overflow in extract(epoch from interval) for intervals exceeding 68 years.
Seems to have been introduced in 8.1 by careless SECS_PER_DAY
search-and-replace.

17 years agoUpdate release notes for last-minute fix. REL8_1_10
Tom Lane [Sun, 16 Sep 2007 03:03:27 +0000 (03:03 +0000)]
Update release notes for last-minute fix.

17 years agoFix aboriginal mistake in lazy VACUUM's code for truncating away
Tom Lane [Sun, 16 Sep 2007 02:38:02 +0000 (02:38 +0000)]
Fix aboriginal mistake in lazy VACUUM's code for truncating away
no-longer-needed pages at the end of a table.  We thought we could throw away
pages containing HEAPTUPLE_DEAD tuples; but this is not so, because such
tuples very likely have index entries pointing at them, and we wouldn't have
removed the index entries.  The problem only emerges in a somewhat unlikely
race condition: the dead tuples have to have been inserted by a transaction
that later aborted, and this has to have happened between VACUUM's initial
scan of the page and then rechecking it for empty in count_nondeletable_pages.
But that timespan will include an index-cleaning pass, so it's not all that
hard to hit.  This seems to explain a couple of previously unsolved bug
reports.

17 years agoupdate configure for 8.1.10
Marc G. Fournier [Fri, 14 Sep 2007 20:23:46 +0000 (20:23 +0000)]
update configure for 8.1.10

17 years agoFix markup that doesn't work in back branches.
Tom Lane [Fri, 14 Sep 2007 16:08:33 +0000 (16:08 +0000)]
Fix markup that doesn't work in back branches.

17 years agoMinor editorialization on release notes.
Tom Lane [Fri, 14 Sep 2007 15:51:18 +0000 (15:51 +0000)]
Minor editorialization on release notes.

17 years agoTranslation updates
Peter Eisentraut [Thu, 13 Sep 2007 21:10:01 +0000 (21:10 +0000)]
Translation updates

17 years agoMake REINDEX DATABASE silently skip remote temp tables.
Alvaro Herrera [Wed, 12 Sep 2007 20:21:23 +0000 (20:21 +0000)]
Make REINDEX DATABASE silently skip remote temp tables.

Per report from bitsandbytes88 <at> hotmail.com and subsequent discussion.

This is a back patch of a patch committed yesterday to CLUSTER and REINDEX.
REINDEX only processes user indexes as of 8.1, so we needn't backpatch this any
further.  (CLUSTER was backpatched separately all the way back to 7.4).

17 years agoFix the database-wide version of CLUSTER to silently skip temp tables of
Alvaro Herrera [Wed, 12 Sep 2007 15:16:20 +0000 (15:16 +0000)]
Fix the database-wide version of CLUSTER to silently skip temp tables of
remote sessions, instead of erroring out in the middle of the operation.

This is a backpatch of a previous fix applied to CLUSTER to HEAD and 8.2, all
the way back that it is relevant to.

17 years agoAdd a CHECK_FOR_INTERRUPTS call in the site where the vacuum delay point
Alvaro Herrera [Wed, 12 Sep 2007 02:05:55 +0000 (02:05 +0000)]
Add a CHECK_FOR_INTERRUPTS call in the site where the vacuum delay point
was removed.

17 years agoSync timezone data with 2007g zic release.
Tom Lane [Tue, 11 Sep 2007 17:43:45 +0000 (17:43 +0000)]
Sync timezone data with 2007g zic release.

17 years agoStamp releases 8.2.5, 8.1.10, 8.0.14, 7.4.18, 7.3.20.
Bruce Momjian [Tue, 11 Sep 2007 17:37:08 +0000 (17:37 +0000)]
Stamp releases 8.2.5, 8.1.10, 8.0.14, 7.4.18, 7.3.20.

Update FAQs for 8.2.5.

17 years agoStamp
Bruce Momjian [Tue, 11 Sep 2007 17:19:36 +0000 (17:19 +0000)]
Stamp

17 years agoMake sure that open hash table scans are cleaned up when bgwriter tries to
Tom Lane [Tue, 11 Sep 2007 17:15:48 +0000 (17:15 +0000)]
Make sure that open hash table scans are cleaned up when bgwriter tries to
recover from elog(ERROR).  Problem was created by introduction of hash seq
search tracking awhile back, and affects all branches that have bgwriter;
in HEAD the disease has snuck into autovacuum and walwriter too.  (Not sure
that the latter two use hash_seq_search at the moment, but surely they might
someday.)  Per report from Sergey Koposov.

17 years agoFix header's size of structs defines in ispell.
Teodor Sigaev [Tue, 11 Sep 2007 13:06:28 +0000 (13:06 +0000)]
Fix header's size of structs defines in ispell.

17 years agoRemove the vacuum_delay_point call in count_nondeletable_pages, because we hold
Alvaro Herrera [Mon, 10 Sep 2007 17:58:56 +0000 (17:58 +0000)]
Remove the vacuum_delay_point call in count_nondeletable_pages, because we hold
an exclusive lock on the table at this point, which we want to release as soon
as possible.  This is called in the phase of lazy vacuum where we truncate the
empty pages at the end of the table.

An alternative solution would be to lower the vacuum delay settings before
starting the truncating phase, but this doesn't work very well in autovacuum
due to the autobalancing code (which can cause other processes to change our
cost delay settings).  This case could be considered in the balancing code, but
it is simpler this way.

17 years agoImprove page split in rtree emulation. Now if splitted result has
Teodor Sigaev [Fri, 7 Sep 2007 17:19:52 +0000 (17:19 +0000)]
Improve page split in rtree emulation. Now if splitted result has
big misalignement, then it tries to split page basing on distribution
of boxe's centers.

Per report from  Dolafi, Tom <dolafit@janelia.hhmi.org>

17 years agoFix aboriginal bug in _tarAddFile(): when complaining that the amount of data
Tom Lane [Wed, 29 Aug 2007 16:31:51 +0000 (16:31 +0000)]
Fix aboriginal bug in _tarAddFile(): when complaining that the amount of data
read from the temp file didn't match the file length reported by ftello(),
the wrong variable's value was printed, and so the message made no sense.
Clean up a couple other coding infelicities while at it.

17 years agoFixed bug in Informix define handling.
Michael Meskes [Wed, 29 Aug 2007 13:58:51 +0000 (13:58 +0000)]
Fixed bug in Informix define handling.

17 years agoFix brain fade in DefineIndex(): it was continuing to access the table's
Tom Lane [Sat, 25 Aug 2007 19:08:31 +0000 (19:08 +0000)]
Fix brain fade in DefineIndex(): it was continuing to access the table's
relcache entry after having heap_close'd it.  This could lead to misbehavior
if a relcache flush wiped out the cache entry meanwhile.  In 8.2 there is a
very real risk of CREATE INDEX CONCURRENTLY using the wrong relid for locking
and waiting purposes.  I think the bug is only cosmetic in 8.0 and 8.1,
because their transgression is limited to using RelationGetRelationName(rel)
in an ereport message immediately after heap_close, and there's no way (except
with special debugging options) for a cache flush to occur in that interval.
Not quite sure that it's cosmetic in 7.4, but seems best to patch anyway.

Found by trying to run the regression tests with CLOBBER_CACHE_ALWAYS enabled.
Maybe we should try to do that on a regular basis --- it's awfully slow,
but perhaps some fast buildfarm machine could do it once in awhile.

17 years agoFix combo_decrypt() to throw an error for zero-length input when using a
Tom Lane [Thu, 23 Aug 2007 16:16:05 +0000 (16:16 +0000)]
Fix combo_decrypt() to throw an error for zero-length input when using a
padded encryption scheme.  Formerly it would try to access res[(unsigned) -1],
which resulted in core dumps on 64-bit machines, and was certainly trouble
waiting to happen on 32-bit machines (though in at least the known case
it was harmless because that byte would be overwritten after return).
Per report from Ken Colson; fix by Marko Kreen.

17 years agoFix potential access-off-the-end-of-memory in varbit_out(): it fetched the
Tom Lane [Tue, 21 Aug 2007 02:40:18 +0000 (02:40 +0000)]
Fix potential access-off-the-end-of-memory in varbit_out(): it fetched the
byte after the last full byte of the bit array, regardless of whether that
byte was part of the valid data or not.  Found by buildfarm testing.
Thanks to Stefan Kaltenbrunner for nailing down the cause.

17 years agoRepair problems occurring when multiple RI updates have to be done to the same
Tom Lane [Wed, 15 Aug 2007 19:16:04 +0000 (19:16 +0000)]
Repair problems occurring when multiple RI updates have to be done to the same
row within one query: we were firing check triggers before all the updates
were done, leading to bogus failures.  Fix by making the triggers queued by
an RI update go at the end of the outer query's trigger event list, thereby
effectively making the processing "breadth-first".  This was indeed how it
worked pre-8.0, so the bug does not occur in the 7.x branches.
Per report from Pavel Stehule.

17 years agoFix a gradual memory leak in ExecReScanAgg(). Because the aggregation
Neil Conway [Wed, 8 Aug 2007 18:07:02 +0000 (18:07 +0000)]
Fix a gradual memory leak in ExecReScanAgg(). Because the aggregation
hash table is allocated in a child context of the agg node's memory
context, MemoryContextReset() will reset but *not* delete the child
context. Since ExecReScanAgg() proceeds to build a new hash table
from scratch (in a new sub-context), this results in leaking the
header for the previous memory context. Therefore, use
MemoryContextResetAndDeleteChildren() instead.

Credit: My colleague Sailesh Krishnamurthy at Truviso for isolating
the cause of the leak.

17 years agoFix pg_restore to guard against unexpected EOF while reading an archive file.
Tom Lane [Mon, 6 Aug 2007 01:38:32 +0000 (01:38 +0000)]
Fix pg_restore to guard against unexpected EOF while reading an archive file.
Per report and partial patch from Chad Wagner.

17 years agoSuppress time zone name (%Z) when logging timestamps in xlog.c startup
Tom Lane [Sat, 4 Aug 2007 01:42:34 +0000 (01:42 +0000)]
Suppress time zone name (%Z) when logging timestamps in xlog.c startup
on Windows.  This is yet another manifestation of the problem that Windows
returns time zone names that may be in a different encoding than we are using.
I've put a better solution in HEAD, but the back branches need a simple patch.
Per report from Hiroshi Saito.

17 years agoMake sure syslogPipe runs in binary mode on Windows to avoid corrupting the pipe...
Andrew Dunstan [Thu, 2 Aug 2007 23:18:47 +0000 (23:18 +0000)]
Make sure syslogPipe runs in binary mode on Windows to avoid corrupting the pipe chunking protocol. Backport to 8.0

17 years agoFix a memory leak in tuplestore_end(). Unlikely to be significant during
Neil Conway [Thu, 2 Aug 2007 17:48:57 +0000 (17:48 +0000)]
Fix a memory leak in tuplestore_end(). Unlikely to be significant during
normal operation, but tuplestore_end() ought to do what it claims to do.

17 years agoFix a bug in the original implementation of redundant-join-clause removal:
Tom Lane [Tue, 31 Jul 2007 19:54:01 +0000 (19:54 +0000)]
Fix a bug in the original implementation of redundant-join-clause removal:
clauses in which one side or the other references both sides of the join
cannot be removed as redundant, because that expression won't have been
constrained below the join.  Per report from Sergey Burladyan.

17 years agoFix security definer functions with polymorphic arguments. This case has
Tom Lane [Tue, 31 Jul 2007 15:50:01 +0000 (15:50 +0000)]
Fix security definer functions with polymorphic arguments.  This case has
never worked because fmgr_security_definer() neglected to pass the fn_expr
information through.  Per report from Viatcheslav Kalinin.

17 years agoThe correct min buffer size is
Magnus Hagander [Mon, 23 Jul 2007 18:13:02 +0000 (18:13 +0000)]
The correct min buffer size is
INITIAL_EXPBUFFER_SIZE, not PQERRORMSG_LENGTH.

Backpatch only, the proper fix in HEAD is
to use PQExpBuffers everywhere.

17 years agoFix elog.c to avoid infinite recursion (leading to backend crash) when
Tom Lane [Sat, 21 Jul 2007 22:12:17 +0000 (22:12 +0000)]
Fix elog.c to avoid infinite recursion (leading to backend crash) when
log_min_error_statement is active and there is some problem in logging the
current query string; for example, that it's too long to include in the log
message without running out of memory.  This problem has existed since the
log_min_error_statement feature was introduced.  No doubt the reason it
wasn't detected long ago is that 8.2 is the first release that defaults
log_min_error_statement to less than PANIC level.
Per report from Bill Moran.

17 years agoFix WAL replay of truncate operations to cope with the possibility that the
Tom Lane [Fri, 20 Jul 2007 16:30:05 +0000 (16:30 +0000)]
Fix WAL replay of truncate operations to cope with the possibility that the
truncated relation was deleted later in the WAL sequence.  Since replay
normally auto-creates a relation upon its first reference by a WAL log entry,
failure is seen only if the truncate entry happens to be the first reference
after the checkpoint we're restarting from; which is a pretty unusual case but
of course not impossible.  Fix by making truncate entries auto-create like
the other ones do.  Per report and test case from Dharmendra Goyal.

17 years agoMake replace(), split_part(), and string_to_array() behave somewhat sanely
Tom Lane [Thu, 19 Jul 2007 20:34:34 +0000 (20:34 +0000)]
Make replace(), split_part(), and string_to_array() behave somewhat sanely
when handed an invalidly-encoded pattern.  The previous coding could get
into an infinite loop if pg_mb2wchar_with_len() returned a zero-length
string after we'd tested for nonempty pattern; which is exactly what it
will do if the string consists only of an incomplete multibyte character.
This led to either an out-of-memory error or a backend crash depending
on platform.  Per report from Wiktor Wodecki.

17 years agoOnly use the pipe chunking protocol if we know the syslogger should
Andrew Dunstan [Thu, 19 Jul 2007 19:14:54 +0000 (19:14 +0000)]
Only use the pipe chunking protocol if we know the syslogger should
be catching stderr output, and we are not ourselves the
syslogger. Otherwise, go directly to stderr.
Bug noticed by Tom Lane.
Backpatch as far as 8.0.

17 years agoFix an old thinko in SS_make_initplan_from_plan, which is used when optimizing
Tom Lane [Wed, 18 Jul 2007 21:41:22 +0000 (21:41 +0000)]
Fix an old thinko in SS_make_initplan_from_plan, which is used when optimizing
a MIN or MAX aggregate call into an indexscan: the initplan is being made at
the current query nesting level and so we shouldn't increment query_level.
Though usually harmless, this mistake could lead to bogus "plan should not
reference subplan's variable" failures on complex queries.  Per bug report
from David Sanchez i Gregori.

17 years agoFix incorrect optimization of foreign-key checks. When an UPDATE on the
Tom Lane [Tue, 17 Jul 2007 17:45:48 +0000 (17:45 +0000)]
Fix incorrect optimization of foreign-key checks.  When an UPDATE on the
referencing table does not change the tuple's FK column(s), we don't bother
to check the PK table since the constraint was presumably already valid.
However, the check is still necessary if the tuple was inserted by our own
transaction, since in that case the INSERT trigger will conclude it need not
make the check (since its version of the tuple has been deleted).  We got this
right for simple cases, but not when the insert and update are in different
subtransactions of the current top-level transaction; in such cases the FK
check would never be made at all.  (Hence, problem dates back to 8.0 when
subtransactions were added --- it's actually the subtransaction version of a
bug fixed in 7.3.5.)  Fix, and add regression test cases.  Report and fix by
Affan Salman.

17 years agoFix outfuncs.c to dump A_Const nodes representing NULLs correctly. This has
Tom Lane [Tue, 17 Jul 2007 01:22:03 +0000 (01:22 +0000)]
Fix outfuncs.c to dump A_Const nodes representing NULLs correctly.  This has
been broken since forever, but was not noticed because people seldom look
at raw parse trees.  AFAIK, no impact on users except that debug_print_parse
might fail; but patch it all the way back anyway.  Per report from Jeff Ross.

17 years agoRestrict non-superusers to password authenticated connections
Joe Conway [Mon, 9 Jul 2007 01:32:44 +0000 (01:32 +0000)]
Restrict non-superusers to password authenticated connections
to prevent possible escalation of privilege. Provide new SECURITY
DEFINER functions with old behavior, but initially REVOKE ALL
from public for these functions. Per list discussion and design
proposed by Tom Lane.

17 years agoRemove the pgstat_drop_relation() call from smgr_internal_unlink(), because
Tom Lane [Sun, 8 Jul 2007 22:23:32 +0000 (22:23 +0000)]
Remove the pgstat_drop_relation() call from smgr_internal_unlink(), because
we don't know at that point which relation OID to tell pgstat to forget.
The code was passing the relfilenode, which is incorrect, and could possibly
cause some other relation's stats to be zeroed out.  While we could try to
clean this up, it seems much simpler and more reliable to let the next
invocation of pgstat_vacuum_tabstat() fix things; which indeed is how it
worked before I introduced the buggy code into 8.1.3 and later :-(.
Problem noticed by Itagaki Takahiro, fix is per subsequent discussion.

17 years agoFix failure to restart Postgres when Linux kernel returns EIDRM for shmctl().
Tom Lane [Mon, 2 Jul 2007 20:12:05 +0000 (20:12 +0000)]
Fix failure to restart Postgres when Linux kernel returns EIDRM for shmctl().

This is a Linux kernel bug that apparently exists in every extant kernel
version: sometimes shmctl() will fail with EIDRM when EINVAL is correct.
We were assuming that EIDRM indicates a possible conflict with pre-existing
backends, and refusing to start the postmaster when this happens.  Fortunately,
there does not seem to be any case where Linux can legitimately return EIDRM
(it doesn't track shmem segments in a way that would allow that), so we can
get away with just assuming that EIDRM means EINVAL on this platform.

Per reports from Michael Fuhr and Jon Lapham --- it's a bit surprising
we have not seen more reports, actually.

17 years agoFix a passel of ancient bugs in to_char(), including two distinct buffer
Tom Lane [Fri, 29 Jun 2007 01:51:56 +0000 (01:51 +0000)]
Fix a passel of ancient bugs in to_char(), including two distinct buffer
overruns (neither of which seem likely to be exploitable as security holes,
fortunately, since the provoker can't control the data written).  One of
these is due to choosing to stomp on the output of a called function, which
is bad news in any case; make it treat the called functions' results as
read-only.  Avoid some unnecessary palloc/pfree traffic too; it's not
really helpful to free small temporary objects, and again this is presuming
more than it ought to about the nature of the results of called functions.
Per report from Patrick Welche and additional code-reading by Imad.

17 years agoFix incorrect tests for undef Perl values in some places in plperl.c.
Tom Lane [Thu, 28 Jun 2007 17:50:17 +0000 (17:50 +0000)]
Fix incorrect tests for undef Perl values in some places in plperl.c.
The correct test for defined-ness is SvOK(sv), not anything involving
SvTYPE.  Per bug #3415 from Matt Taylor.
Back-patch as far as 8.0; no apparent problem in 7.x.

17 years agotransformColumnDefinition failed to complain about
Tom Lane [Wed, 20 Jun 2007 18:21:15 +0000 (18:21 +0000)]
transformColumnDefinition failed to complain about
create table foo (bar int default null default 3);
due to not thinking about the special-case handling of DEFAULT NULL.
Problem noticed while investigating bug #3396.

17 years agoCREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULT
Tom Lane [Wed, 20 Jun 2007 18:16:04 +0000 (18:16 +0000)]
CREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULT
NULL and DefineDomain didn't.  Bug goes all the way back to original coding
of domains.  Per bug #3396 from Sergey Burladyan.

17 years agoBack-patch 8.2 fix that complains if trying to extend a relation encounters
Tom Lane [Mon, 18 Jun 2007 01:14:08 +0000 (01:14 +0000)]
Back-patch 8.2 fix that complains if trying to extend a relation encounters
a buffer containing a non-zeroed page.  This seems appropriate now that the
8.2 fix has been seen to save at least one user from data loss due to a
buggy kernel (per report from Jaime Silvela 7-May-07).  I'd go further
back than 8.1, except that the 8.0-to-8.1 bufmgr changes are large
enough that the patch doesn't work immediately; I'm hesitant to make a
change without more extensive analysis than I have time for now.

17 years agoAvoid having autovacuum run multiple ANALYZE commands in a single transaction,
Alvaro Herrera [Thu, 14 Jun 2007 13:54:40 +0000 (13:54 +0000)]
Avoid having autovacuum run multiple ANALYZE commands in a single transaction,
to prevent possible deadlock problems.  Per request from Tom Lane.