]> granicus.if.org Git - postgresql/log
postgresql
15 years agoFix plpgsql's exec_eval_expr() to ensure it returns a sane type OID
Tom Lane [Wed, 14 Apr 2010 23:52:16 +0000 (23:52 +0000)]
Fix plpgsql's exec_eval_expr() to ensure it returns a sane type OID
even when the expression is a query that returns no rows.

So far as I can tell, the only caller that actually fails when a garbage
OID is returned is exec_stmt_case(), which is new in 8.4 --- in all other
cases, we might make a useless trip through casting logic, but we won't
fail since the isnull flag will be set.  Hence, backpatch only to 8.4,
just in case there are apps out there that aren't expecting an error to
be thrown if the query returns more or less than one column.  (Which seems
unlikely, since the error would be thrown if the query ever did return a
row; but it's possible there's some never-exercised code out there.)

Per report from Mario Splivalo.

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:20 +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:50:03 +0000 (11:50 +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:12 +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:06 +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:17 +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:53:55 +0000 (17:53 +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:16:57 +0000 (16:16 +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:28 +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 "constraint_exclusion = partition" logic so that it will also attempt
Tom Lane [Tue, 30 Mar 2010 21:58:18 +0000 (21:58 +0000)]
Fix "constraint_exclusion = partition" logic so that it will also attempt
constraint exclusion on an inheritance set that is the target of an UPDATE
or DELETE query.  Per gripe from Marc Cousin.  Back-patch to 8.4 where
the feature was introduced.

15 years agoFix ginint4_queryextract() to actually do what it was intended to do for an
Tom Lane [Thu, 25 Mar 2010 15:50:15 +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:44:51 +0000 (14:44 +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 agoFix thinko in log message for "sameuser" ident map mismatch: the provided
Tom Lane [Wed, 24 Mar 2010 17:05:51 +0000 (17:05 +0000)]
Fix thinko in log message for "sameuser" ident map mismatch: the provided
and authenticated usernames were swapped.  Reported by Bryan Henderson
in bug #5386.

Also clean up poorly-maintained header comment for this function.

15 years agoClear error_context_stack and debug_query_string at the beginning of proc_exit,
Tom Lane [Sat, 20 Mar 2010 00:58:14 +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 agoModify error context callback functions to not assume that they can fetch
Tom Lane [Fri, 19 Mar 2010 22:54:49 +0000 (22:54 +0000)]
Modify error context callback functions to not assume that they can fetch
catalog entries via SearchSysCache and related operations.  Although, at the
time that these callbacks are called by elog.c, we have not officially aborted
the current transaction, it still seems rather risky to initiate any new
catalog fetches.  In all these cases the needed information is readily
available in the caller and so it's just a matter of a bit of extra notation
to pass it to the callback.

Per crash report from Dennis Koegel.  I've concluded that the real fix for
his problem is to clear the error context stack at entry to proc_exit, but
it still seems like a good idea to make the callbacks a bit less fragile
for other cases.

Backpatch to 8.4.  We could go further back, but the patch doesn't apply
cleanly.  In the absence of proof that this fixes something and isn't just
paranoia, I'm not going to expend the effort.

15 years agoFix missing parentheses for current_query(), per bug #5378.
Tom Lane [Thu, 18 Mar 2010 15:29:51 +0000 (15:29 +0000)]
Fix missing parentheses for current_query(), per bug #5378.
Also make a couple other minor editorial improvements.

15 years agoFix bug in %r handling in recovery_end_command, it always came out as 0
Heikki Linnakangas [Thu, 18 Mar 2010 09:18:54 +0000 (09:18 +0000)]
Fix bug in %r handling in recovery_end_command, it always came out as 0
because InRedo was cleared before recovery_end_command was executed.
Also, always take ControlFileLock when reading checkpoint location for
%r. That didn't matter before, but in 8.4 bgwriter is active during
recovery and can modify the control file concurrently.

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

Fujii Masao

15 years agoFix incorrect example in CREATE INDEX reference page, per Josh Kupershmidt.
Tom Lane [Wed, 17 Mar 2010 15:55:55 +0000 (15:55 +0000)]
Fix incorrect example in CREATE INDEX reference page, per Josh Kupershmidt.
Also fix and uncomment an old example of creating a GIST index, and make
a couple of other minor editorial adjustments.

15 years agotag 8.4.3 REL8_4_3
Marc G. Fournier [Fri, 12 Mar 2010 03:23:23 +0000 (03:23 +0000)]
tag 8.4.3

15 years agoImprove PL/Perl documentation of database access functions. (Backpatch to 8.4
Alvaro Herrera [Thu, 11 Mar 2010 21:53:53 +0000 (21:53 +0000)]
Improve PL/Perl documentation of database access functions.  (Backpatch to 8.4
of a patch previously applied by Bruce Momjian to CVS HEAD)

Alexey Klyukin

15 years agoAdd missing reset of need_initialization in reloptions code.
Tom Lane [Thu, 11 Mar 2010 21:47:25 +0000 (21:47 +0000)]
Add missing reset of need_initialization in reloptions code.

This resulted in useless extra work during every call of parseRelOptions,
but no bad effects other than that.  Noted by Alvaro.

15 years agoSync timezone code with tzcode 2010c from the Olson group. This fixes some
Tom Lane [Thu, 11 Mar 2010 18:43:32 +0000 (18:43 +0000)]
Sync timezone code with tzcode 2010c from the Olson group.  This fixes some
corner cases that come up in certain timezones (apparently, only those with
lots and lots of distinct TZ transition rules, as far as I can gather from
a quick scan of their archives).  Per suggestion from Jeevan Chalke.

Back-patch to 8.4.  Possibly we need to push this into earlier releases
as well, but I'm hesitant to update them to the 64-bit tzcode without
more thought and testing.

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:24 +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:49 +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:28:46 +0000 (14:28 +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:23 +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:07:00 +0000 (13:07 +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:51 +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:24 +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 agoDisallow gssapi authentication on local connections, since it
Magnus Hagander [Mon, 8 Mar 2010 09:57:35 +0000 (09:57 +0000)]
Disallow gssapi authentication on local connections, since it
requires a hostname to function.

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:18 +0000 (01:18 +0000)]
Update time zone data files to tzdata release 2010c: DST law changes in
Bangladesh, Mexico, Paraguay.

15 years agoFix warning messages in restrict_and_check_grant() to include the column name
Tom Lane [Sat, 6 Mar 2010 23:10:50 +0000 (23:10 +0000)]
Fix warning messages in restrict_and_check_grant() to include the column name
when warning about column-level privileges.  This is more useful than before
and makes the apparent duplication complained of by Piyush Newe not so
duplicate.  Also fix lack of quote marks in a related message text.

Back-patch to 8.4, where column-level privileges were introduced.

Stephen Frost

15 years agoWhen reading pg_hba.conf and similar files, do not treat @file as an inclusion
Tom Lane [Sat, 6 Mar 2010 00:45:55 +0000 (00:45 +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 IsBinaryCoercible to not confuse a cast using in/out functions
Heikki Linnakangas [Thu, 4 Mar 2010 09:40:01 +0000 (09:40 +0000)]
Fix IsBinaryCoercible to not confuse a cast using in/out functions
with binary compatibility.

Backpatch to 8.4 where INOUT casts were introduced.

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:16 +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 agoFix pg_dump of ACLs of foreign servers. The command to grant/revoke
Heikki Linnakangas [Wed, 3 Mar 2010 20:10:42 +0000 (20:10 +0000)]
Fix pg_dump of ACLs of foreign servers. The command to grant/revoke
privileges of foreign servers is "GRANT ... ON *FOREIGN* SERVER ...".

15 years agoMake contrib/xml2 use core xml.c's error handler, when available (that is,
Tom Lane [Wed, 3 Mar 2010 19:10:29 +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:29:53 +0000 (17:29 +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:29:02 +0000 (03:29 +0000)]
Make iconv work like other optional libraries for MSVC.

15 years agoAdd missing library and include dir for XSLT in MSVC builds
Andrew Dunstan [Tue, 2 Mar 2010 23:51:17 +0000 (23:51 +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:16:16 +0000 (18:16 +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:44:03 +0000 (15:44 +0000)]
Backpatch MSVC build fix for XSLT

15 years agoFix translation of strings in psql \d output (translation in headers worked,
Heikki Linnakangas [Mon, 1 Mar 2010 21:27:32 +0000 (21:27 +0000)]
Fix translation of strings in psql \d output (translation in headers worked,
but not in cells).

15 years agoFix numericlocale psql option when used with a null string and latex and troff
Heikki Linnakangas [Mon, 1 Mar 2010 20:55:53 +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:07 +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:40 +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:04 +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 agoAllow predicate_refuted_by() to deduce that NOT A refutes A.
Tom Lane [Thu, 25 Feb 2010 21:00:03 +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:26 +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:30 +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 agoRemove stray semicolon, per report from strk
Alvaro Herrera [Wed, 24 Feb 2010 14:11:40 +0000 (14:11 +0000)]
Remove stray semicolon, per report from strk

15 years agoRemove incorrect statement that PostgreSQL 8.4 has no default parameters.
Robert Haas [Fri, 19 Feb 2010 23:55:52 +0000 (23:55 +0000)]
Remove incorrect statement that PostgreSQL 8.4 has no default parameters.

Tom Lane already removed this from HEAD as par of the plpgsql variable
resolution behavior patch, but this part of his patch also applies to 8.4.

15 years agoFix STOP WAL LOCATION in backup history files no to return the next
Itagaki Takahiro [Fri, 19 Feb 2010 01:04:39 +0000 (01:04 +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:12 +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 agoProvide some rather hokey ways for EXPLAIN to print FieldStore and assignment
Tom Lane [Thu, 18 Feb 2010 22:43:39 +0000 (22:43 +0000)]
Provide some rather hokey ways for EXPLAIN to print FieldStore and assignment
ArrayRef expressions that are not in the immediate context of an INSERT or
UPDATE targetlist.  Such cases never arise in stored rules, so ruleutils.c
hadn't tried to handle them.  However, they do occur in the targetlists of
plans derived from such statements, and now that EXPLAIN VERBOSE tries to
print targetlists, we need some way to deal with the case.

I chose to represent an assignment ArrayRef as "array[subscripts] := source",
which is fairly reasonable and doesn't omit any information.  However,
FieldStore is problematic because the planner will fold multiple assignments
to fields of the same composite column into one FieldStore, resulting in a
structure that is hard to understand at all, let alone display comprehensibly.
So in that case I punted and just made it print the source expression(s).

Backpatch to 8.4 --- the lack of functionality exists in older releases,
but doesn't seem to be important for lack of anything that would call it.

15 years agoFix ExecEvalArrayRef to pass down the old value of the array element or slice
Tom Lane [Thu, 18 Feb 2010 18:41:55 +0000 (18:41 +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 agoForce READY portals into FAILED state when a transaction or subtransaction
Tom Lane [Thu, 18 Feb 2010 03:06:53 +0000 (03:06 +0000)]
Force READY portals into FAILED state when a transaction or subtransaction
is aborted, if they were created within the failed xact.  This prevents
ExecutorEnd from being run on them, which is a good idea because they may
contain references to tables or other objects that no longer exist.
In particular this is hazardous when auto_explain is active, but it's
really rather surprising that nobody has seen an issue with this before.
I'm back-patching this to 8.4, since that's the first version that contains
auto_explain or an ExecutorEnd hook, but I wonder whether we shouldn't
back-patch further.

15 years agoPrevent #option dump from crashing on FORI statement with null step. Reported by...
Tom Lane [Wed, 17 Feb 2010 01:48:51 +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:35 +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:47 +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 agoOoops, let's get the non-null vs null bit right ...
Tom Lane [Sun, 14 Feb 2010 01:01:40 +0000 (01:01 +0000)]
Ooops, let's get the non-null vs null bit right ...

15 years agoDocument the behavior of STRICT VARIADIC functions.
Tom Lane [Sun, 14 Feb 2010 00:48:20 +0000 (00:48 +0000)]
Document the behavior of STRICT VARIADIC functions.

15 years agoDon't choke when exec_move_row assigns a synthesized null to a column
Tom Lane [Fri, 12 Feb 2010 19:37:43 +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:02 +0000 (04:32 +0000)]
Free reference in correct Perl context. Backpatch to release 8.2. Patch from Tim Bunce.

15 years agoFix bug in GIN WAL redo cleanup function: don't free fake relcache entry
Heikki Linnakangas [Tue, 9 Feb 2010 20:31:35 +0000 (20:31 +0000)]
Fix bug in GIN WAL redo cleanup function: don't free fake relcache entry
while it's still being used.

Backpatch to 8.4, where the fake relcache method was introduced.

15 years agoRemove obsolete comment about 'fsm' argument, which isn't an argument
Heikki Linnakangas [Mon, 8 Feb 2010 20:00:55 +0000 (20:00 +0000)]
Remove obsolete comment about 'fsm' argument, which isn't an argument
anymore.

15 years agoProperly document that OVER and WINDOW are Postgres reserved words.
Bruce Momjian [Fri, 5 Feb 2010 19:34:57 +0000 (19:34 +0000)]
Properly document that OVER and WINDOW are Postgres reserved words.

15 years agoCheck to ensure the number of primary key fields supplied does not
Joe Conway [Wed, 3 Feb 2010 23:01:23 +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 agoForgot to back-patch CLUSTER test fix to 8.4.
Tom Lane [Wed, 3 Feb 2010 06:36:16 +0000 (06:36 +0000)]
Forgot to back-patch CLUSTER test fix to 8.4.

15 years agoCLUSTER specified the wrong namespace when renaming toast tables of temporary
Tom Lane [Tue, 2 Feb 2010 19:12:34 +0000 (19:12 +0000)]
CLUSTER specified the wrong namespace when renaming toast tables of temporary
relations (they don't live in pg_toast).  This caused an Assert failure in
assert-enabled builds.  So far as I can see, in a non-assert build it would
only have messed up the checks for conflicting names, so a failure would be
quite improbable but perhaps not impossible.

15 years agoRemove copyright mention of Andrew Yu, per author's permission.
Bruce Momjian [Tue, 2 Feb 2010 18:52:06 +0000 (18:52 +0000)]
Remove copyright mention of Andrew Yu, per author's permission.

Backpatch to 8.4.X.

15 years agoChange regexp engine's ccondissect/crevdissect routines to perform DFA
Tom Lane [Mon, 1 Feb 2010 02:45:35 +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:29 +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:09:59 +0000 (20:09 +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 agoFix memory leakage introduced into print_aligned_text by 8.4 changes
Tom Lane [Sat, 30 Jan 2010 18:59:58 +0000 (18:59 +0000)]
Fix memory leakage introduced into print_aligned_text by 8.4 changes
(failure to free col_lineptrs[] array elements) and exacerbated in the
current devel cycle (failure to free "wrap").  This resulted in moderate
bloat of psql over long script runs.  Noted while testing bug #5302,
although what the reporter was complaining of was backend-side leakage.

15 years agoApply Tcl_Init() to the "hold" interpreter created by pltcl.
Tom Lane [Mon, 25 Jan 2010 01:58:19 +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:31 +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:06 +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 agoWell, the systemtap guys moved the goalposts again: with the latest version,
Tom Lane [Wed, 20 Jan 2010 23:12:15 +0000 (23:12 +0000)]
Well, the systemtap guys moved the goalposts again: with the latest version,
we *must* generate probes.o or the dtrace probes don't work.  Revert our
workaround for their previous bug.  Details at
https://bugzilla.redhat.com/show_bug.cgi?id=557266

15 years agoWhen doing a parallel restore, we must guard against out-of-range dependency
Tom Lane [Tue, 19 Jan 2010 18:39:26 +0000 (18:39 +0000)]
When doing a parallel restore, we must guard against out-of-range dependency
dump IDs, because the array we're using is sized according to the highest
dump ID actually defined in the archive file.  In a partial dump there could
be references to higher dump IDs that weren't dumped.  Treat these the same
as references to in-range IDs that weren't dumped.  (The whole thing is a
bit scary because the missing objects might have been part of dependency
chains, which we won't know about.  Not much we can do though --- throwing
an error is probably overreaction.)

Also, reject parallel restore with pre-1.8 archive version (made by pre-8.0
pg_dump).  In these old versions the dependency entries are OIDs, not dump
IDs, and we don't have enough information to interpret them.

Per bug #5288 from Jon Erdman.

15 years agoFix an oversight in convert_EXISTS_sublink_to_join: we can't convert an
Tom Lane [Mon, 18 Jan 2010 18:17:52 +0000 (18:17 +0000)]
Fix an oversight in convert_EXISTS_sublink_to_join: we can't convert an
EXISTS that contains a WITH clause.  This would usually lead to a
"could not find CTE" error later in planning, because the WITH wouldn't
get processed at all.  Noted while playing with an example from Ken Marshall.

15 years agoFix incorrect comparison of scan key in GIN. Per report from
Teodor Sigaev [Mon, 18 Jan 2010 11:53:10 +0000 (11:53 +0000)]
Fix incorrect comparison of scan key in GIN. Per report from
Vyacheslav Kalinin <vka@mgcp.com>

15 years agoFix portalmem.c to avoid keeping a dangling pointer to a cached plan list
Tom Lane [Mon, 18 Jan 2010 02:30:30 +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 agoFix spelling error, noticed by Thomas Shinnick
Magnus Hagander [Sat, 16 Jan 2010 20:38:57 +0000 (20:38 +0000)]
Fix spelling error, noticed by Thomas Shinnick

15 years agoRe-order configure tests to reflect the fact that the code generated for
Tom Lane [Sat, 16 Jan 2010 19:50:38 +0000 (19:50 +0000)]
Re-order configure tests to reflect the fact that the code generated for
posix_fadvise and other file-related functions can depend on _LARGEFILE_SOURCE
and/or _FILE_OFFSET_BITS.  Per report from Robert Treat.

Back-patch to 8.4.  This has been wrong all along, but we weren't really using
posix_fadvise in anger before, and AC_FUNC_FSEEKO seems to mask the issue well
enough for that function.

15 years agoWhen loading critical system indexes into the relcache, ensure we lock the
Tom Lane [Wed, 13 Jan 2010 23:07:15 +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 bug #5269: ResetPlanCache mustn't invalidate cached utility statements,
Tom Lane [Wed, 13 Jan 2010 16:57:03 +0000 (16:57 +0000)]
Fix bug #5269: ResetPlanCache mustn't invalidate cached utility statements,
especially not ROLLBACK.  ROLLBACK might need to be executed in an already
aborted transaction, when there is no safe way to revalidate the plan.  But
in general there's no point in marking utility statements invalid, since
they have no plans in the normal sense of the word; so we might as well
work a bit harder here to avoid future revalidation cycles.

Back-patch to 8.4, where the bug was introduced.

15 years agoFix relcache reload mechanism to be more robust in the face of errors
Tom Lane [Tue, 12 Jan 2010 18:12:26 +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 agoImprove ExecEvalVar's handling of whole-row variables in cases where the
Tom Lane [Mon, 11 Jan 2010 15:31:12 +0000 (15:31 +0000)]
Improve ExecEvalVar's handling of whole-row variables in cases where the
rowtype contains dropped columns.  Sometimes the input tuple will be formed
from a select targetlist in which dropped columns are filled with a NULL
of an arbitrary type (the planner typically uses INT4, since it can't tell
what type the dropped column really was).  So we need to relax the rowtype
compatibility check to not insist on physical compatibility if the actual
column value is NULL.

In principle we might need to do this for functions returning composite
types, too (see tupledesc_match()).  In practice there doesn't seem to be
a bug there, probably because the function will be using the same cached
rowtype descriptor as the caller.  Fixing that code path would require
significant rearrangement, so I left it alone for now.

Per complaint from Filip Rembialkowski.

15 years agoUpdate Windows installation notes.
Magnus Hagander [Sun, 10 Jan 2010 15:54:14 +0000 (15:54 +0000)]
Update Windows installation notes.

pginstaller isn't used anymore, in favor of the one-click installers.
Make it clear that we support Windows 2000 and newer with the native
port, instead of first saying we support NT4 and then saying we don't.

15 years agoBackported fix for protecting ecpg against applications freeing strings to 8.4.
Michael Meskes [Fri, 8 Jan 2010 09:22:44 +0000 (09:22 +0000)]
Backported fix for protecting ecpg against applications freeing strings to 8.4.

15 years agoMake bit/varbit substring() treat any negative length as meaning "all the rest
Tom Lane [Thu, 7 Jan 2010 19:53:16 +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 agoAlter the configure script to fail immediately if the C compiler does not
Tom Lane [Thu, 7 Jan 2010 00:25:18 +0000 (00:25 +0000)]
Alter the configure script to fail immediately if the C compiler does not
provide a working 64-bit integer datatype.  As recently noted, we've been
broken on such platforms since early in the 8.4 development cycle.  Since
it took nearly two years for anyone to even notice, it seems that the
rationale for continuing to support such platforms has reached the point
of non-existence.  Rather than thrashing around to try to make it work
again, we'll just admit up front that this no longer works.

Back-patch to 8.4 since that branch is also broken.

We should go around to remove INT64_IS_BUSTED support, but just in HEAD,
so that seems like material for a separate commit.

15 years agoAdd support for doing FULL JOIN ON FALSE. While this is really a rather
Tom Lane [Tue, 5 Jan 2010 23:25:44 +0000 (23:25 +0000)]
Add support for doing FULL JOIN ON FALSE.  While this is really a rather
peculiar variant of UNION ALL, and so wouldn't likely get written directly
as-is, it's possible for it to arise as a result of simplification of
less-obviously-silly queries.  In particular, now that we can do flattening
of subqueries that have constant outputs and are underneath an outer join,
it's possible for the case to result from simplification of queries of the
type exhibited in bug #5263.  Back-patch to 8.4 to avoid a functionality
regression for this type of query.

15 years agoMake the win32 putenv() override update *all* present versions of the
Magnus Hagander [Fri, 1 Jan 2010 14:57:19 +0000 (14:57 +0000)]
Make the win32 putenv() override update *all* present versions of the
MSVCRxx runtime, not just the current + Visual Studio 6 (MSVCRT). Clearly
there can be an almost unlimited number of runtimes loaded at the same
time.

Per report from Hiroshi Inoue

15 years agoReset minRecoveryPoint at checkpoints, so that we don't uselessly update
Heikki Linnakangas [Wed, 30 Dec 2009 08:37:23 +0000 (08:37 +0000)]
Reset minRecoveryPoint at checkpoints, so that we don't uselessly update
it in the control file at crash recovery following an archive recovery.

Per Fujii Masao and subsequent discussion.

15 years agoSet errno to zero before invoking SSL_read or SSL_write. It appears that
Tom Lane [Wed, 30 Dec 2009 03:45:53 +0000 (03:45 +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 agoPrevious fix for temporary file management broke returning a set from
Heikki Linnakangas [Tue, 29 Dec 2009 17:41:09 +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:11 +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