]> granicus.if.org Git - postgresql/log
postgresql
14 years agoFix multiple memory leaks in PLy_spi_execute_fetch_result: it would leak
Tom Lane [Fri, 30 Apr 2010 19:15:58 +0000 (19:15 +0000)]
Fix multiple memory leaks in PLy_spi_execute_fetch_result: it would leak
memory if the result had zero rows, and also if there was any sort of error
while converting the result tuples into Python data.  Reported and partially
fixed by Andres Freund.

Back-patch to all supported versions.  Note: I haven't tested the 7.4 fix.
7.4's configure check for python is so obsolete it doesn't work on my
current machines :-(.  The logic change is pretty straightforward though.

15 years agoProvide better guidance for adjusting shared_buffers.
Robert Haas [Mon, 19 Apr 2010 00:00:22 +0000 (00:00 +0000)]
Provide better guidance for adjusting shared_buffers.

This change was previously committed to HEAD, but the consensus seems to be
in favor of back-patching it.  I'm only backpatching as far as 8.3.X, however,
because it's not clear to me to what degree this advice applies to older
branches, and in any case our first advice to anyone attempting to tune those
versions is likely to be "upgrade".

15 years agoOn Windows, syslogger runs in two threads. The main thread processes config
Heikki Linnakangas [Fri, 16 Apr 2010 09:52:01 +0000 (09:52 +0000)]
On Windows, syslogger runs in two threads. The main thread processes config
reload and rotation signals, and a helper thread reads messages from the
pipe and writes them to the log file. However, server code isn't generally
thread-safe, so if both try to do e.g palloc()/pfree() at the same time,
bad things will happen. To fix that, use a critical section (which is like
a mutex) to enforce that only one the threads are active at a time.

15 years agoFix psql's \copy to not insert spaces around dots and commas in the text of
Tom Lane [Thu, 15 Apr 2010 21:05:17 +0000 (21:05 +0000)]
Fix psql's \copy to not insert spaces around dots and commas in the text of
the SELECT query in \copy (SELECT ...) commands.  This is unnecessary and
breaks numeric literals, as seen in bug #5411 from Vitalii Tymchyshyn.

This change has already been made in passing in HEAD; backpatch to 8.2
through 8.4 (earlier releases don't have COPY (SELECT ...) at all).

15 years agoIP port -> TCP port
Peter Eisentraut [Thu, 15 Apr 2010 20:47:06 +0000 (20:47 +0000)]
IP port -> TCP port

backpatched to 8.1, where this first appeared

15 years agoFix a problem introduced by my patch of 2010-01-12 that revised the way
Tom Lane [Wed, 14 Apr 2010 21:31:27 +0000 (21:31 +0000)]
Fix a problem introduced by my patch of 2010-01-12 that revised the way
relcache reload works.  In the patched code, a relcache entry in process of
being rebuilt doesn't get unhooked from the relcache hash table; which means
that if a cache flush occurs due to sinval queue overrun while we're
rebuilding it, the entry could get blown away by RelationCacheInvalidate,
resulting in crash or misbehavior.  Fix by ensuring that an entry being
rebuilt has positive refcount, so it won't be seen as a target for removal
if a cache flush occurs.  (This will mean that the entry gets rebuilt twice
in such a scenario, but that's okay.)  It appears that the problem can only
arise within a transaction that has previously reassigned the relfilenode of
a pre-existing table, via TRUNCATE or a similar operation.  Per bug #5412
from Rusty Conover.

Back-patch to 8.2, same as the patch that introduced the problem.
I think that the failure can't actually occur in 8.2, since it lacks the
rd_newRelfilenodeSubid optimization, but let's make it work like the later
branches anyway.

Patch by Heikki, slightly editorialized on by me.

15 years agoClean up inconsistent commas
Magnus Hagander [Fri, 9 Apr 2010 11:49:58 +0000 (11:49 +0000)]
Clean up inconsistent commas

15 years agoUpdate list of Windows timezones we try to match localized names against
Magnus Hagander [Fri, 9 Apr 2010 11:46:10 +0000 (11:46 +0000)]
Update list of Windows timezones we try to match localized names against
to one that's up to date with Windows 2003R2.

15 years agoProceed to look for the next timezone when matching a localized
Magnus Hagander [Thu, 8 Apr 2010 11:26:03 +0000 (11:26 +0000)]
Proceed to look for the next timezone when matching a localized
Windows timezone name where the information in the registry is
incomplete, instead of aborting.

This fixes cases when the registry information is incomplete for
a timezone that is alphabetically before the one that is in use.

Per report from Alexander Forschner

15 years agoLog the actual timezone name that we fail to look up the values for in
Magnus Hagander [Tue, 6 Apr 2010 20:35:15 +0000 (20:35 +0000)]
Log the actual timezone name that we fail to look up the values for in
case the registry data doesn't follow the format we expect, to facilitate
debugging.

15 years agoSync perl's ppport.h on all branches back to 7.4 with recent update on HEAD, ensuring...
Andrew Dunstan [Sat, 3 Apr 2010 17:54:14 +0000 (17:54 +0000)]
Sync perl's ppport.h on all branches back to 7.4 with recent update on HEAD, ensuring we can build older branches with modern Perl installations.

15 years agoEnsure that contrib/pgstattuple functions respond to cancel interrupts
Tom Lane [Fri, 2 Apr 2010 16:17:05 +0000 (16:17 +0000)]
Ensure that contrib/pgstattuple functions respond to cancel interrupts
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara

15 years agoDon't pass an invalid file handle to dup2(). That causes a crash on
Heikki Linnakangas [Thu, 1 Apr 2010 20:12:34 +0000 (20:12 +0000)]
Don't pass an invalid file handle to dup2(). That causes a crash on
Windows, thanks to a feature in CRT called Parameter Validation.

Backpatch to 8.2, which is the oldest version supported on Windows. In
8.2 and 8.3 also backpatch the earlier change to use DEVNULL instead of
NULL_DEV #define for a /dev/null-like device. NULL_DEV was hard-coded to
"/dev/null" regardless of platform, which didn't work on Windows, while
DEVNULL works on all platforms. Restarting syslogger didn't work on
Windows on versions 8.3 and below because of that.

15 years agoFix ginint4_queryextract() to actually do what it was intended to do for an
Tom Lane [Thu, 25 Mar 2010 15:50:22 +0000 (15:50 +0000)]
Fix ginint4_queryextract() to actually do what it was intended to do for an
unsatisfiable query, such as indexcol && empty_array.  It should return -1
to tell GIN no scan is required; but silly typo disabled the logic for that,
resulting in unnecessary "GIN indexes do not support whole-index scans" error.
Per bug report from Jeff Trout.

Back-patch to 8.3 where the logic was introduced.

15 years agoPrevent ALTER USER f RESET ALL from removing the settings that were put there
Alvaro Herrera [Thu, 25 Mar 2010 14:45:06 +0000 (14:45 +0000)]
Prevent ALTER USER f RESET ALL from removing the settings that were put there
by a superuser -- "ALTER USER f RESET setting" already disallows removing such a
setting.

Apply the same treatment to ALTER DATABASE d RESET ALL when run by a database
owner that's not superuser.

15 years agoClear error_context_stack and debug_query_string at the beginning of proc_exit,
Tom Lane [Sat, 20 Mar 2010 00:58:21 +0000 (00:58 +0000)]
Clear error_context_stack and debug_query_string at the beginning of proc_exit,
so that we won't try to attach any context printouts to messages that get
emitted while exiting.  Per report from Dennis Koegel, the context functions
won't necessarily work after we've started shutting down the backend, and it
seems possible that debug_query_string could be pointing at freed storage
as well.  The context information doesn't seem particularly relevant to
such messages anyway, so there's little lost by suppressing it.

Back-patch to all supported branches.  I can only demonstrate a crash with
log_disconnections messages back to 8.1, but the risk seems real in 8.0 and
before anyway.

15 years agoTypo fixes.
Magnus Hagander [Wed, 17 Mar 2010 18:04:25 +0000 (18:04 +0000)]
Typo fixes.

Fujii Masao

15 years agotag 8.3.10 REL8_3_10
Marc G. Fournier [Fri, 12 Mar 2010 03:40:31 +0000 (03:40 +0000)]
tag 8.3.10

15 years agoPreliminary release notes for releases 8.4.3, 8.3.10, 8.2.16, 8.1.20, 8.0.24,
Tom Lane [Wed, 10 Mar 2010 01:58:38 +0000 (01:58 +0000)]
Preliminary release notes for releases 8.4.3, 8.3.10, 8.2.16, 8.1.20, 8.0.24,
7.4.28.

15 years agoUse SvROK(sv) rather than directly checking SvTYPE(sv) == SVt_RV in plperl.
Tom Lane [Tue, 9 Mar 2010 22:34:58 +0000 (22:34 +0000)]
Use SvROK(sv) rather than directly checking SvTYPE(sv) == SVt_RV in plperl.
The latter is considered unwarranted chumminess with the implementation,
and can lead to crashes with recent Perl versions.

Report and fix by Tim Bunce.  Back-patch to all versions containing the
questionable coding pattern.

15 years agoUpdate time zone data files to tzdata release 2010d: DST law changes in Fiji,
Alvaro Herrera [Tue, 9 Mar 2010 14:29:50 +0000 (14:29 +0000)]
Update time zone data files to tzdata release 2010d: DST law changes in Fiji,
Samoa, Chile; corrections to recent changes in Paraguay and Bangladesh.

15 years agoReturn proper exit code (3) from psql when ON_ERROR_STOP=on and
Bruce Momjian [Tue, 9 Mar 2010 01:10:05 +0000 (01:10 +0000)]
Return proper exit code (3) from psql when ON_ERROR_STOP=on and
--single-transaction are both used and the failure happens in commit,
e.g. failed deferred trigger.  Also properly free BEGIN/COMMIT result
structures from --single-transaction.

Per report from Dominic Bevacqua

15 years agoBackport fix from HEAD that makes ecpglib give the right SQLSTATE if the connection...
Michael Meskes [Mon, 8 Mar 2010 13:15:51 +0000 (13:15 +0000)]
Backport fix from HEAD that makes ecpglib give the right SQLSTATE if the connection disappears.

15 years agoAdd missing space in example.
Magnus Hagander [Mon, 8 Mar 2010 12:39:42 +0000 (12:39 +0000)]
Add missing space in example.

Tim Landscheidt

15 years agoRequire hostname to be set when using GSSAPI authentication. Without it,
Magnus Hagander [Mon, 8 Mar 2010 10:01:20 +0000 (10:01 +0000)]
Require hostname to be set when using GSSAPI authentication. Without it,
the GSSAPI libraries crash.

Noted by Zdenek Kotala

15 years agoUpdate time zone data files to tzdata release 2010c: DST law changes in
Tom Lane [Mon, 8 Mar 2010 01:18:26 +0000 (01:18 +0000)]
Update time zone data files to tzdata release 2010c: DST law changes in
Bangladesh, Mexico, Paraguay.

15 years agoWhen reading pg_hba.conf and similar files, do not treat @file as an inclusion
Tom Lane [Sat, 6 Mar 2010 00:46:02 +0000 (00:46 +0000)]
When reading pg_hba.conf and similar files, do not treat @file as an inclusion
unless (1) the @ isn't quoted and (2) the filename isn't empty.  This guards
against unexpectedly treating usernames or other strings in "flat files"
as inclusion requests, as seen in a recent trouble report from Ed L.
The empty-filename case would be guaranteed to misbehave anyway, because our
subsequent path-munging behavior results in trying to read the directory
containing the current input file.

I think this might finally explain the report at
http://archives.postgresql.org/pgsql-bugs/2004-05/msg00132.php
of a crash after printing "authentication file token too long, skipping",
since I was able to duplicate that message (though not a crash) on a
platform where stdio doesn't refuse to read directories.  We never got
far in investigating that problem, but now I'm suspicious that the trigger
condition was an @ in the flat password file.

Back-patch to all active branches since the problem can be demonstrated in all
branches except HEAD.  The test case, creating a user named "@", doesn't cause
a problem in HEAD since we got rid of the flat password file.  Nonetheless it
seems like a good idea to not consider quoted @ as a file inclusion spec,
so I changed HEAD too.

15 years agoFix a couple of places that would loop forever if attempts to read a stdio file
Tom Lane [Wed, 3 Mar 2010 20:31:22 +0000 (20:31 +0000)]
Fix a couple of places that would loop forever if attempts to read a stdio file
set ferror() but never set feof().  This is known to be the case for recent
glibc when trying to read a directory as a file, and might be true for other
platforms/cases too.  Per report from Ed L.  (There is more that we ought to
do about his report, but this is one easily identifiable issue.)

15 years agoMake contrib/xml2 use core xml.c's error handler, when available (that is,
Tom Lane [Wed, 3 Mar 2010 19:10:35 +0000 (19:10 +0000)]
Make contrib/xml2 use core xml.c's error handler, when available (that is,
in versions >= 8.3).  The core code is more robust and efficient than what
was there before, and this also reduces risks involved in swapping different
libxml error handler settings.

Before 8.3, there is still some risk of problems if add-on modules such as
Perl invoke libxml without setting their own error handler.  Given the lack
of reports I'm not sure there's a risk in practice, so I didn't take the
step of actually duplicating the core code into older contrib/xml2 branches.
Instead I just tweaked the existing code to ensure it didn't leave a dangling
pointer to short-lived memory when throwing an error.

15 years agoExport xml.c's libxml-error-handling support so that contrib/xml2 can use it
Tom Lane [Wed, 3 Mar 2010 17:30:01 +0000 (17:30 +0000)]
Export xml.c's libxml-error-handling support so that contrib/xml2 can use it
too, instead of duplicating the functionality (badly).

I renamed xml_init to pg_xml_init, because the former seemed just a bit too
generic to be safe as a global symbol.  I considered likewise renaming
xml_ereport to pg_xml_ereport, but felt that the reference to ereport probably
made it sufficiently PG-centric already.

15 years agoMake iconv work like other optional libraries for MSVC.
Andrew Dunstan [Wed, 3 Mar 2010 03:28:35 +0000 (03:28 +0000)]
Make iconv work like other optional libraries for MSVC.

15 years agopgindent run on xml.c in 8.3 branch, per request from Tom.
Bruce Momjian [Wed, 3 Mar 2010 00:32:49 +0000 (00:32 +0000)]
pgindent run on xml.c in 8.3 branch, per request from Tom.

15 years agoAdd missing library and include dir for XSLT in MSVC builds
Andrew Dunstan [Tue, 2 Mar 2010 23:50:58 +0000 (23:50 +0000)]
Add missing library and include dir for XSLT in MSVC builds

15 years agoDo not run regression tests for contrib/xml2 on MSVC unless building with XML
Andrew Dunstan [Tue, 2 Mar 2010 18:15:53 +0000 (18:15 +0000)]
Do not run regression tests for contrib/xml2 on MSVC unless building with XML

15 years agoBackpatch MSVC build fix for XSLT
Andrew Dunstan [Tue, 2 Mar 2010 15:43:44 +0000 (15:43 +0000)]
Backpatch MSVC build fix for XSLT

15 years agoFix numericlocale psql option when used with a null string and latex and troff
Heikki Linnakangas [Mon, 1 Mar 2010 20:55:59 +0000 (20:55 +0000)]
Fix numericlocale psql option when used with a null string and latex and troff
formats; a null string must not be formatted as a numeric. The more exotic
formats latex and troff also incorrectly formatted all strings as numerics
when numericlocale was on.

Backpatch to 8.1 where numericlocale option was added.

This fixes bug #5355 reported by Andy Lester.

15 years agoFix contrib/xml2 so regression test still works when it's built without libxslt.
Tom Lane [Mon, 1 Mar 2010 18:08:16 +0000 (18:08 +0000)]
Fix contrib/xml2 so regression test still works when it's built without libxslt.

This involves modifying the module to have a stable ABI, that is, the
xslt_process() function still exists even without libxslt.  It throws a
runtime error if called, but doesn't prevent executing the CREATE FUNCTION
call.  This is a good thing anyway to simplify cross-version upgrades.

15 years agoRemove xmlCleanupParser calls from contrib/xml2.
Tom Lane [Mon, 1 Mar 2010 05:16:48 +0000 (05:16 +0000)]
Remove xmlCleanupParser calls from contrib/xml2.

These are unnecessary and probably dangerous.  I don't see any immediate
risk situations in the core XML support or contrib/xml2 itself, but there
could be issues with external uses of libxml2, and in any case it's an
accident waiting to happen.

15 years agoBack-patch today's memory management fixups in contrib/xml2.
Tom Lane [Mon, 1 Mar 2010 03:41:11 +0000 (03:41 +0000)]
Back-patch today's memory management fixups in contrib/xml2.

Prior to 8.3, these changes are not critical for compatibility with core
Postgres, since core had no libxml2 calls then.  However there is still
a risk if contrib/xml2 is used along with libxml2 functionality in Perl
or other loadable modules.  So back-patch to all versions.

Also back-patch addition of regression tests.  I'm not sure how many of
the cases are interesting without the interaction with core xml code,
but a silly regression test is still better than none at all.

15 years agoBack-patch changes of 2009-05-13 in xml.c's memory management.
Tom Lane [Mon, 1 Mar 2010 02:21:40 +0000 (02:21 +0000)]
Back-patch changes of 2009-05-13 in xml.c's memory management.

I was afraid to do this when these changes were first made, but now that
8.4 has seen some field use it should be all right to back-patch.  These
changes are really quite necessary in order to give xml.c any hope of
co-existing with loadable modules that also wish to use libxml2.

15 years agoAllow predicate_refuted_by() to deduce that NOT A refutes A.
Tom Lane [Thu, 25 Feb 2010 21:00:10 +0000 (21:00 +0000)]
Allow predicate_refuted_by() to deduce that NOT A refutes A.

We had originally made the stronger assumption that NOT A refutes any B
if B implies A, but this fails in three-valued logic, because we need to
prove B is false not just that it's not true.  However the logic does
go through if B is equal to A.

Recognizing this limited case is enough to handle examples that arise when
we have simplified "bool_var = true" or "bool_var = false" to just "bool_var"
or "NOT bool_var".  If we had not done that simplification then the
btree-operator proof logic would have been able to prove that the expressions
were contradictory, but only for identical expressions being compared to the
constants; so handling identical A and B covers all the same cases.

The motivation for doing this is to avoid unexpected asymmetrical behavior
when a partitioned table uses a boolean partitioning column, as in today's
gripe from Dominik Sander.

Back-patch to 8.2, which is as far back as predicate_refuted_by attempts to
do anything at all with NOTs.

15 years agoAdd configuration parameter ssl_renegotiation_limit to control
Magnus Hagander [Thu, 25 Feb 2010 13:26:23 +0000 (13:26 +0000)]
Add configuration parameter ssl_renegotiation_limit to control
how often we do SSL session key renegotiation. Can be set to
0 to disable renegotiation completely, which is required if
a broken SSL library is used (broken patches to CVE-2009-3555
a known cause) or when using a client library that can't do
renegotiation.

15 years agoAllow zero-dimensional (ie, empty) arrays in contrib/ltree operations.
Tom Lane [Wed, 24 Feb 2010 18:02:36 +0000 (18:02 +0000)]
Allow zero-dimensional (ie, empty) arrays in contrib/ltree operations.

The main motivation for changing this is bug #4921, in which it's pointed out
that it's no longer safe to apply ltree operations to the result of
ARRAY(SELECT ...) if the sub-select might return no rows.  Before 8.3,
the ARRAY() construct would return NULL, which might or might not be helpful
but at least it wouldn't result in an error.  Now it returns an empty array
which results in a failure for no good reason, since the ltree operations
are all perfectly capable of dealing with zero-element arrays.

As far as I can find, these ltree functions are the only places where zero
array dimensionality is rejected unnecessarily.

Back-patch to 8.3 to prevent behavioral regression of queries that worked
in older releases.

15 years agoFix STOP WAL LOCATION in backup history files no to return the next
Itagaki Takahiro [Fri, 19 Feb 2010 01:06:51 +0000 (01:06 +0000)]
Fix STOP WAL LOCATION in backup history files no to return the next
segment of XLOG_BACKUP_END record even if the the record is placed
at a segment boundary. Furthermore the previous implementation could
return nonexistent segment file name when the boundary is in segments
that has "FE" suffix; We never use segments with "FF" suffix.

Backpatch to 8.0, where hot backup was introduced.

Reported by Fujii Masao.

15 years agoVolatile-ize all five places where we expect a PG_TRY block to restore
Tom Lane [Thu, 18 Feb 2010 23:50:20 +0000 (23:50 +0000)]
Volatile-ize all five places where we expect a PG_TRY block to restore
old memory context in plpython.  Before only one of them was marked
volatile, but per report from Zdenek Kotala, some compilers do the
wrong thing here.

15 years agoFix ExecEvalArrayRef to pass down the old value of the array element or slice
Tom Lane [Thu, 18 Feb 2010 18:42:04 +0000 (18:42 +0000)]
Fix ExecEvalArrayRef to pass down the old value of the array element or slice
being assigned to, in case the expression to be assigned is a FieldStore that
would need to modify that value.  The need for this was foreseen some time
ago, but not implemented then because we did not have arrays of composites.
Now we do, but the point evidently got overlooked in that patch.  Net result
is that updating a field of an array element doesn't work right, as
illustrated if you try the new regression test on an unpatched backend.
Noted while experimenting with EXPLAIN VERBOSE, which has also got some issues
in this area.

Backpatch to 8.3, where arrays of composites were introduced.

15 years agoPrevent #option dump from crashing on FORI statement with null step. Reported by...
Tom Lane [Wed, 17 Feb 2010 01:48:58 +0000 (01:48 +0000)]
Prevent #option dump from crashing on FORI statement with null step.  Reported by Pavel.

15 years agorevert prior patch to fsync directories until portability problems exposed by build...
Greg Stark [Tue, 16 Feb 2010 00:01:22 +0000 (00:01 +0000)]
revert prior patch to fsync directories until portability problems exposed by build farm can be sorted out

15 years agoMake CREATE DATABASE safe against losing whole files by fsyncing the
Greg Stark [Sun, 14 Feb 2010 17:50:43 +0000 (17:50 +0000)]
Make CREATE DATABASE safe against losing whole files by fsyncing the
directory and not just the individual files.

Back-patch to 8.1 -- before that we just called "cp -r" and never
fsynced anything anyways.

15 years agoDon't choke when exec_move_row assigns a synthesized null to a column
Tom Lane [Fri, 12 Feb 2010 19:37:52 +0000 (19:37 +0000)]
Don't choke when exec_move_row assigns a synthesized null to a column
that happens to be composite itself.  Per bug #5314 from Oleg Serov.

Backpatch to 8.0 --- 7.4 has got too many other shortcomings in
composite-type support to make this worth worrying about in that branch.

15 years agoFree reference in correct Perl context. Backpatch to release 8.2. Patch from Tim...
Andrew Dunstan [Fri, 12 Feb 2010 04:32:56 +0000 (04:32 +0000)]
Free reference in correct Perl context. Backpatch to release 8.2. Patch from Tim Bunce.

15 years agoAdd a note to the documentation of pg_standby that it's important that
Heikki Linnakangas [Fri, 5 Feb 2010 11:08:02 +0000 (11:08 +0000)]
Add a note to the documentation of pg_standby that it's important that
the postgres process has permissions to delete the trigger file, per
suggestion by Mason Hale.

Also fix pg_standby to do a more predictable exit(200) instead of the
current exit(-1) when the unlink of the trigger file fails anyway.

This only affects 8.3 branch. Older versions didn't have pg_standby,
and in 8.4 upwards pg_standby is no longer responsible for deleting the
trigger file; it's supposed to be done by recovery_end_command instead.

15 years agoCheck to ensure the number of primary key fields supplied does not
Joe Conway [Wed, 3 Feb 2010 23:01:34 +0000 (23:01 +0000)]
Check to ensure the number of primary key fields supplied does not
exceed the total number of non-dropped source table fields for
dblink_build_sql_*(). Addresses bug report from Rushabh Lathia.

Backpatch all the way to the 7.3 branch.

15 years agoChange regexp engine's ccondissect/crevdissect routines to perform DFA
Tom Lane [Mon, 1 Feb 2010 02:45:41 +0000 (02:45 +0000)]
Change regexp engine's ccondissect/crevdissect routines to perform DFA
matching before recursing instead of after.  The DFA match eliminates
unworkable midpoint choices a lot faster than the recursive check, in most
cases, so doing it first can speed things up; particularly in pathological
cases such as recently exhibited by Michael Glaesemann.

In addition, apply some cosmetic changes that were applied upstream (in the
Tcl project) at the same time, in order to sync with upstream version 1.15
of regexec.c.

Upstream apparently intends to backpatch this, so I will too.  The
pathological behavior could be unpleasant if encountered in the field,
which seems to justify any risk of introducing new bugs.

Tom Lane, reviewed by Donal K. Fellows of Tcl project

15 years agoFix race condition in win32 signal handling.
Magnus Hagander [Sun, 31 Jan 2010 17:16:27 +0000 (17:16 +0000)]
Fix race condition in win32 signal handling.

There was a race condition where the receiving pipe could be closed by the
child thread if the main thread was pre-empted before it got a chance to
create a new one, and the dispatch thread ran to completion during that time.

One symptom of this is that rows in pg_listener could be dropped under
heavy load.

Analysis and original patch by Radu Ilie, with some small
modifications by Magnus Hagander.

15 years agoAvoid performing encoding conversion on command tag strings during EndCommand.
Tom Lane [Sat, 30 Jan 2010 20:10:05 +0000 (20:10 +0000)]
Avoid performing encoding conversion on command tag strings during EndCommand.

Since all current and foreseeable future command tags will be pure ASCII,
there is no need to do conversion on them.  This saves a few cycles and also
avoids polluting otherwise-pristine subtransaction memory contexts, which
is the cause of the backend memory leak exhibited in bug #5302.  (Someday
we'll probably want to have a better method of determining whether
subtransaction contexts need to be kept around, but today is not that day.)

Backpatch to 8.0.  The cycle-shaving aspect of this would work in 7.4
too, but without subtransactions the memory-leak aspect doesn't apply,
so it doesn't seem worth touching 7.4.

15 years agoApply Tcl_Init() to the "hold" interpreter created by pltcl.
Tom Lane [Mon, 25 Jan 2010 01:58:25 +0000 (01:58 +0000)]
Apply Tcl_Init() to the "hold" interpreter created by pltcl.

You might think this is unnecessary since that interpreter is never used
to run code --- but it turns out that's wrong.  As of Tcl 8.5, the "clock"
command (alone among builtin Tcl commands) is partially implemented by
loaded-on-demand Tcl code, which means that it fails if there's not
unknown-command support, and also that it's impossible to run it directly
in a safe interpreter.  The way they get around the latter is that
Tcl_CreateSlave() automatically sets up an alias command that forwards any
execution of "clock" in a safe slave interpreter to its parent interpreter.
Thus, when attempting to execute "clock" in trusted pltcl, the command
actually executes in the "hold" interpreter, where it will fail if
unknown-command support hasn't been introduced by sourcing the standard
init.tcl script, which is done by Tcl_Init().  (This is a pretty dubious
design decision on the Tcl boys' part, if you ask me ... but they didn't.)

Back-patch all the way.  It's not clear that anyone would try to use ancient
versions of pltcl with a recent Tcl, but it's not clear they wouldn't, either.
Also add a regression test using "clock", in branches that have regression
test support for pltcl.

Per recent trouble report from Kyle Bateman.

15 years agoFix assorted core dumps and Assert failures that could occur during
Tom Lane [Sun, 24 Jan 2010 21:49:39 +0000 (21:49 +0000)]
Fix assorted core dumps and Assert failures that could occur during
AbortTransaction or AbortSubTransaction, when trying to clean up after an
error that prevented (sub)transaction start from completing:
* access to TopTransactionResourceOwner that might not exist
* assert failure in AtEOXact_GUC, if AtStart_GUC not called yet
* assert failure or core dump in AfterTriggerEndSubXact, if
  AfterTriggerBeginSubXact not called yet

Per testing by injecting elog(ERROR) at successive steps in StartTransaction
and StartSubTransaction.  It's not clear whether all of these cases could
really occur in the field, but at least one of them is easily exposed by
simple stress testing, as per my accidental discovery yesterday.

15 years agoInsert CHECK_FOR_INTERRUPTS calls into loops in dbsize.c, to ensure that
Tom Lane [Sat, 23 Jan 2010 21:29:12 +0000 (21:29 +0000)]
Insert CHECK_FOR_INTERRUPTS calls into loops in dbsize.c, to ensure that
the various disk-size-reporting functions will respond to query cancel
reasonably promptly even in very large databases.  Per report from
Kevin Grittner.

15 years agoFix portalmem.c to avoid keeping a dangling pointer to a cached plan list
Tom Lane [Mon, 18 Jan 2010 02:30:37 +0000 (02:30 +0000)]
Fix portalmem.c to avoid keeping a dangling pointer to a cached plan list
after it's released its reference count for the cached plan.  There are
code paths that might try to examine the plan list before noticing that
the portal is already in aborted state.  Report and diagnosis by Tatsuo
Ishii, though this isn't exactly his proposed patch.

15 years agoWhen loading critical system indexes into the relcache, ensure we lock the
Tom Lane [Wed, 13 Jan 2010 23:07:22 +0000 (23:07 +0000)]
When loading critical system indexes into the relcache, ensure we lock the
underlying catalog not only the index itself.  Otherwise, if the cache
load process touches the catalog (which will happen for many though not
all of these indexes), we are locking index before parent table, which can
result in a deadlock against processes that are trying to lock them in the
normal order.  Per today's failure on buildfarm member gothic_moth; it's
surprising the problem hadn't been identified before.

Back-patch to 8.2.  Earlier releases didn't have the issue because they
didn't try to lock these indexes during load (instead assuming that they
couldn't change schema at all during multiuser operation).

15 years agoFix relcache reload mechanism to be more robust in the face of errors
Tom Lane [Tue, 12 Jan 2010 18:12:33 +0000 (18:12 +0000)]
Fix relcache reload mechanism to be more robust in the face of errors
occurring during a reload, such as query-cancel.  Instead of zeroing out
an existing relcache entry and rebuilding it in place, build a new relcache
entry, then swap its contents with the old one, then free the new entry.
This avoids problems with code believing that a previously obtained pointer
to a cache entry must still reference a valid entry, as seen in recent
failures on buildfarm member jaguar.  (jaguar is using CLOBBER_CACHE_ALWAYS
which raises the probability of failure substantially, but the problem
could occur in the field without that.)  The previous design was okay
when it was made, but subtransactions and the ResourceOwner mechanism
make it unsafe now.

Also, make more use of the already existing rd_isvalid flag, so that we
remember that the entry requires rebuilding even if the first attempt fails.

Back-patch as far as 8.2.  Prior versions have enough issues around relcache
reload anyway (due to inadequate locking) that fixing this one doesn't seem
worthwhile.

15 years agoMake bit/varbit substring() treat any negative length as meaning "all the rest
Tom Lane [Thu, 7 Jan 2010 19:53:22 +0000 (19:53 +0000)]
Make bit/varbit substring() treat any negative length as meaning "all the rest
of the string".  The previous coding treated only -1 that way, and would
produce an invalid result value for other negative values.

We ought to fix it so that 2-parameter bit substring() is a different C
function and the 3-parameter form throws error for negative length, but
that takes a pg_proc change which is impractical in the back branches;
and in any case somebody might be relying on -1 working this way.
So just do this as a back-patchable fix.

15 years agoSet errno to zero before invoking SSL_read or SSL_write. It appears that
Tom Lane [Wed, 30 Dec 2009 03:46:01 +0000 (03:46 +0000)]
Set errno to zero before invoking SSL_read or SSL_write.  It appears that
at least in some Windows versions, these functions are capable of returning
a failure indication without setting errno.  That puts us into an infinite
loop if the previous value happened to be EINTR.  Per report from Brendan
Hill.

Back-patch to 8.2.  We could take it further back, but since this is only
known to be an issue on Windows and we don't support Windows before 8.2,
it does not seem worth the trouble.

15 years agoOops, previous backpatch applied incorrectly.
Heikki Linnakangas [Tue, 29 Dec 2009 20:49:00 +0000 (20:49 +0000)]
Oops, previous backpatch applied incorrectly.

15 years agoPrevious fix for temporary file management broke returning a set from
Heikki Linnakangas [Tue, 29 Dec 2009 17:41:18 +0000 (17:41 +0000)]
Previous fix for temporary file management broke returning a set from
PL/pgSQL function within an exception handler. Make sure we use the right
resource owner when we create the tuplestore to hold returned tuples.

Simplify tuplestore API so that the caller doesn't need to be in the right
memory context when calling tuplestore_put* functions. tuplestore.c
automatically switches to the memory context used when the tuplestore was
created. Tuplesort was already modified like this earlier. This patch also
removes the now useless MemoryContextSwitch calls from callers.

Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like
the previous patch that broke this.

15 years agoFix wrong WAL info value generated when gistContinueInsert() performs an
Tom Lane [Thu, 24 Dec 2009 17:52:19 +0000 (17:52 +0000)]
Fix wrong WAL info value generated when gistContinueInsert() performs an
index page split.  This would result in index corruption, or even more likely
an error during WAL replay, if we were unlucky enough to crash during
end-of-recovery cleanup after having completed an incomplete GIST insertion.

Yoichi Hirai

15 years agoFix integer-to-bit-string conversions to handle the first fractional byte
Tom Lane [Sat, 12 Dec 2009 19:24:51 +0000 (19:24 +0000)]
Fix integer-to-bit-string conversions to handle the first fractional byte
correctly when the output bit width is wider than the given integer by
something other than a multiple of 8 bits.

This has been wrong since I first wrote that code for 8.0 :-(.  Kudos to
Roman Kononov for being the first to notice, though I didn't use his
patch.  Per bug #5237.

15 years agotag 8.3.9 REL8_3_9
Marc G. Fournier [Thu, 10 Dec 2009 03:02:07 +0000 (03:02 +0000)]
tag 8.3.9

15 years agoUpdate release notes for releases 8.4.2, 8.3.9, 8.2.15, 8.1.19, 8.0.23,
Tom Lane [Thu, 10 Dec 2009 00:31:34 +0000 (00:31 +0000)]
Update release notes for releases 8.4.2, 8.3.9, 8.2.15, 8.1.19, 8.0.23,
7.4.27.

15 years agoPrevent indirect security attacks via changing session-local state within
Tom Lane [Wed, 9 Dec 2009 21:58:17 +0000 (21:58 +0000)]
Prevent indirect security attacks via changing session-local state within
an allegedly immutable index function.  It was previously recognized that
we had to prevent such a function from executing SET/RESET ROLE/SESSION
AUTHORIZATION, or it could trivially obtain the privileges of the session
user.  However, since there is in general no privilege checking for changes
of session-local state, it is also possible for such a function to change
settings in a way that might subvert later operations in the same session.
Examples include changing search_path to cause an unexpected function to
be called, or replacing an existing prepared statement with another one
that will execute a function of the attacker's choosing.

The present patch secures VACUUM, ANALYZE, and CREATE INDEX/REINDEX against
these threats, which are the same places previously deemed to need protection
against the SET ROLE issue.  GUC changes are still allowed, since there are
many useful cases for that, but we prevent security problems by forcing a
rollback of any GUC change after completing the operation.  Other cases are
handled by throwing an error if any change is attempted; these include temp
table creation, closing a cursor, and creating or deleting a prepared
statement.  (In 7.4, the infrastructure to roll back GUC changes doesn't
exist, so we settle for rejecting changes of "search_path" in these contexts.)

Original report and patch by Gurjeet Singh, additional analysis by
Tom Lane.

Security: CVE-2009-4136

15 years agoReject certificates with embedded NULLs in the commonName field. This stops
Magnus Hagander [Wed, 9 Dec 2009 06:37:25 +0000 (06:37 +0000)]
Reject certificates with embedded NULLs in the commonName field. This stops
attacks where an attacker would put <attack>\0<propername> in the field and
trick the validation code that the certificate was for <attack>.

This is a very low risk attack since it reuqires the attacker to trick the
CA into issuing a certificate with an incorrect field, and the common
PostgreSQL deployments are with private CAs, and not external ones. Also,
default mode in 8.4 does not do any name validation, and is thus also not
vulnerable - but the higher security modes are.

Backpatch all the way. Even though versions 8.3.x and before didn't have
certificate name validation support, they still exposed this field for
the user to perform the validation in the application code, and there
is no way to detect this problem through that API.

Security: CVE-2009-4034

15 years agoUpdate time zone data files to tzdata release 2009s: DST law changes in
Tom Lane [Wed, 9 Dec 2009 00:36:08 +0000 (00:36 +0000)]
Update time zone data files to tzdata release 2009s: DST law changes in
Antarctica, Argentina, Bangladesh, Fiji, Novokuznetsk, Pakistan, Palestine,
Samoa, Syria.  Also historical corrections for Hong Kong.

15 years agoTranslation updates
Peter Eisentraut [Tue, 8 Dec 2009 22:15:48 +0000 (22:15 +0000)]
Translation updates

15 years agoFix bug in temporary file management with subtransactions. A cursor opened
Heikki Linnakangas [Thu, 3 Dec 2009 11:03:44 +0000 (11:03 +0000)]
Fix bug in temporary file management with subtransactions. A cursor opened
in a subtransaction stays open even if the subtransaction is aborted, so
any temporary files related to it must stay alive as well. With the patch,
we use ResourceOwners to track open temporary files and don't automatically
close them at subtransaction end (though in the normal case temporary files
are registered with the subtransaction resource owner and will therefore be
closed).

At end of top transaction, we still check that there's no temporary files
marked as close-at-end-of-transaction open, but that's now just a debugging
cross-check as the resource owner cleanup should've closed them already.

15 years agoIgnore attempts to set "application_name" in the connection startup packet.
Tom Lane [Wed, 2 Dec 2009 17:41:31 +0000 (17:41 +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 agoAvoid core dump on empty thesaurus dictionary.
Tom Lane [Mon, 30 Nov 2009 16:38:46 +0000 (16:38 +0000)]
Avoid core dump on empty thesaurus dictionary.
Per report from Robert Gravsjö.

15 years agoFix session-lifespan memory leak when a plperl function is redefined:
Tom Lane [Sun, 29 Nov 2009 21:02:28 +0000 (21:02 +0000)]
Fix session-lifespan memory leak when a plperl function is redefined:
we have to tell Perl it can release its compiled copy of the function
text.  Noted by Alexey Klyukin.

Back-patch to 8.2 --- the problem exists further back, but this patch
won't work without modification, and it's probably not worth the trouble.

15 years agoFix syntax in extract() examples
Peter Eisentraut [Tue, 24 Nov 2009 19:20:53 +0000 (19:20 +0000)]
Fix syntax in extract() examples

Author: Erik Rijkers <er@xs4all.nl>

15 years agoFix an old bug in multixact and two-phase commit. Prepared transactions can
Heikki Linnakangas [Mon, 23 Nov 2009 09:59:00 +0000 (09:59 +0000)]
Fix an old bug in multixact and two-phase commit. Prepared transactions can
be part of multixacts, so allocate a slot for each prepared transaction in
the "oldest member" array in multixact.c. On PREPARE TRANSACTION, transfer
the oldest member value from the current backends slot to the prepared xact
slot. Also save and recover the value from the 2pc state file.

The symptom of the bug was that after a transaction prepared, a shared lock
still held by the prepared transaction was sometimes ignored by other
transactions.

Fix back to 8.1, where both 2PC and multixact were introduced.

15 years agoFix memory leak in syslogger: logfile_rotate() would leak a copy of the
Tom Lane [Thu, 19 Nov 2009 02:45:50 +0000 (02:45 +0000)]
Fix memory leak in syslogger: logfile_rotate() would leak a copy of the
output filename if CSV logging was enabled and only one of the two possible
output files got rotated during a particular call (which would, in fact,
typically be the case during a size-based rotation).  This would amount to
about MAXPGPATH (1KB) per rotation, and it's been there since the CSV
code was put in, so it's surprising that nobody noticed it before.
Per bug #5196 from Thomas Poindessous.

15 years agoMake text search parser accept underscores in XML attributes (bug #5075)
Peter Eisentraut [Sun, 15 Nov 2009 13:54:22 +0000 (13:54 +0000)]
Make text search parser accept underscores in XML attributes (bug #5075)

15 years agoAdd inheritable ACE when creating a restricted token for execution on
Magnus Hagander [Sat, 14 Nov 2009 15:39:41 +0000 (15:39 +0000)]
Add inheritable ACE when creating a restricted token for execution on
Win32.

Also refactor the code around it to be more clear.

Jesse Morris

15 years agoDo not build psql's flex module on its own, but instead include it in
Tom Lane [Tue, 10 Nov 2009 23:12:29 +0000 (23:12 +0000)]
Do not build psql's flex module on its own, but instead include it in
mainloop.c.  This ensures that postgres_fe.h is read before including
any system headers, which is necessary to avoid problems on some platforms
where we make nondefault selections of feature macros for stdio.h or
other headers.  We have had this policy for flex modules in the backend
for many years, but for some reason it was not applied to psql.
Per trouble report from Alexandra Roy and diagnosis by Albe Laurenz.

15 years agoFix longstanding problems in VACUUM caused by untimely interruptions
Alvaro Herrera [Tue, 10 Nov 2009 18:00:44 +0000 (18:00 +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 agoDisable triggering failover with a signal in pg_standby on Windows, because
Heikki Linnakangas [Wed, 4 Nov 2009 12:51:42 +0000 (12:51 +0000)]
Disable triggering failover with a signal in pg_standby on Windows, because
Windows doesn't do signal processing like other platforms do. It never
really worked, but recent changes to the signal handling made it crash.

This fixes bug #4961. Patch by Fujii Masao.

15 years agoFix obscure segfault condition in PL/Python
Peter Eisentraut [Tue, 3 Nov 2009 08:44:52 +0000 (08:44 +0000)]
Fix obscure segfault condition in PL/Python

In PLy_output(), when the elog() call in the TRY branch throws an exception
(this can happen when a statement timeout kicks in, for example), the
PyErr_SetString() call in the CATCH branch can cause a segfault, because the
Py_XDECREF(so) call before it releases memory that is still used by the sv
variable that PyErr_SetString() uses as argument, because sv points into
memory owned by so.

Backpatched back to 8.0, where this code was introduced.

I also threw in a couple of volatile declarations for variables that are used
before and after the TRY.  I don't think they caused the crash that I
observed, but they could become issues.

15 years agoEnsure the previous Perl interpreter selection is restored upon exit from
Tom Lane [Sat, 31 Oct 2009 18:12:12 +0000 (18:12 +0000)]
Ensure the previous Perl interpreter selection is restored upon exit from
plperl_call_handler, in both the normal and error-exit paths.  Per report
from Alexey Klyukin.

15 years agoMake the overflow guards in ExecChooseHashTableSize be more protective.
Tom Lane [Fri, 30 Oct 2009 20:58:57 +0000 (20:58 +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 agoFix AfterTriggerSaveEvent to use a test and elog, not just Assert, to check
Tom Lane [Tue, 27 Oct 2009 20:14:39 +0000 (20:14 +0000)]
Fix AfterTriggerSaveEvent to use a test and elog, not just Assert, to check
that it's called within an AfterTriggerBeginQuery/AfterTriggerEndQuery pair.
The RI cascade triggers suppress that overhead on the assumption that they
are always run non-deferred, so it's possible to violate the condition if
someone mistakenly changes pg_trigger to mark such a trigger deferred.
We don't really care about supporting that, but throwing an error instead
of crashing seems desirable.  Per report from Marcelo Costa.

15 years agoRewrite pam_passwd_conv_proc to be more robust: avoid assuming that the
Tom Lane [Fri, 16 Oct 2009 22:08:48 +0000 (22:08 +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 agoRename the new MAX_AUTH_TOKEN_LENGTH #define to PG_MAX_AUTH_MAX_TOKEN_LENGTH,
Heikki Linnakangas [Wed, 14 Oct 2009 22:10:17 +0000 (22:10 +0000)]
Rename the new MAX_AUTH_TOKEN_LENGTH #define to PG_MAX_AUTH_MAX_TOKEN_LENGTH,
to make it more obvious that it's a PostgreSQL internal limit, not something
that comes from system header files.

15 years agoRaise the maximum authentication token (Kerberos ticket) size in GSSAPI
Heikki Linnakangas [Wed, 14 Oct 2009 07:27:44 +0000 (07:27 +0000)]
Raise the maximum authentication token (Kerberos ticket) size in GSSAPI
and SSPI athentication methods. While the old 2000 byte limit was more than
enough for Unix Kerberos implementations, tickets issued by Windows Domain
Controllers can be much larger.

Ian Turner

15 years agoFix off-by-one bug in bitncmp(): When comparing a number of bits divisible by
Heikki Linnakangas [Thu, 8 Oct 2009 04:46:37 +0000 (04:46 +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 an oversight in an 8.3-era patch: pgstat_initstats should allow stats
Tom Lane [Fri, 2 Oct 2009 22:50:03 +0000 (22:50 +0000)]
Fix an oversight in an 8.3-era patch: pgstat_initstats should allow stats
to be collected for sequences.

Report and fix by Akira Kurosawa

15 years agoFix erroneous handling of shared dependencies (ie dependencies on roles)
Tom Lane [Fri, 2 Oct 2009 18:13:19 +0000 (18:13 +0000)]
Fix erroneous handling of shared dependencies (ie dependencies on roles)
in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
as if a new function was being created, even if it wasn't, with two bad
consequences: pg_shdepend might record the wrong owner for the function,
and any dependencies for roles mentioned in the function's ACL would be lost.
The fix is very easy: just don't touch pg_shdepend at all when doing a
function replacement.

Also update the CREATE FUNCTION reference page, which never explained
exactly what changes and doesn't change in a function replacement.
In passing, fix the CREATE VIEW reference page similarly; there's no
code bug there, but the docs didn't say what happens.

15 years agoFix equivclass.c's not-quite-right strategy for handling X=X clauses.
Tom Lane [Tue, 29 Sep 2009 01:21:02 +0000 (01:21 +0000)]
Fix equivclass.c's not-quite-right strategy for handling X=X clauses.

The original coding correctly noted that these aren't just redundancies
(they're effectively X IS NOT NULL, assuming = is strict).  However, they
got treated that way if X happened to be in a single-member EquivalenceClass
already, which could happen if there was an ORDER BY X clause, for instance.
The simplest and most reliable solution seems to be to not try to process
such clauses through the EquivalenceClass machinery; just throw them back
for traditional processing.  The amount of work that'd be needed to be
smarter than that seems out of proportion to the benefit.

Per bug #5084 from Bernt Marius Johnsen, and analysis by Andrew Gierth.

15 years agoConvert a perl array to a postgres array when returned by Set Returning Functions...
Andrew Dunstan [Mon, 28 Sep 2009 17:30:41 +0000 (17:30 +0000)]
Convert a perl array to a postgres array when returned by Set Returning Functions as well as non SRFs. Backpatch to 8.1 where these facilities were introduced. with a little help from Abhijit Menon-Sen.

15 years agoFix RelationCacheInitializePhase2 (Phase3, in HEAD) to cope with the
Tom Lane [Sat, 26 Sep 2009 18:25:03 +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 agoFix incorrect arguments for gist_box_penalty call. The bug could be observed
Teodor Sigaev [Fri, 18 Sep 2009 14:03:12 +0000 (14:03 +0000)]
Fix incorrect arguments for gist_box_penalty call. The bug could be observed
only for secondary page split (i.e. for non-first columns of index)

 Patch by Paul Ramsey <pramsey@opengeo.org>