]> granicus.if.org Git - postgresql/log
postgresql
12 years agoStamp 9.1.3. REL9_1_3
Tom Lane [Thu, 23 Feb 2012 22:53:36 +0000 (17:53 -0500)]
Stamp 9.1.3.

12 years agoLast-minute release note updates.
Tom Lane [Thu, 23 Feb 2012 22:47:59 +0000 (17:47 -0500)]
Last-minute release note updates.

Security: CVE-2012-0866, CVE-2012-0867, CVE-2012-0868

12 years agoConvert newlines to spaces in names written in pg_dump comments.
Tom Lane [Thu, 23 Feb 2012 20:53:17 +0000 (15:53 -0500)]
Convert newlines to spaces in names written in pg_dump comments.

pg_dump was incautious about sanitizing object names that are emitted
within SQL comments in its output script.  A name containing a newline
would at least render the script syntactically incorrect.  Maliciously
crafted object names could present a SQL injection risk when the script
is reloaded.

Reported by Heikki Linnakangas, patch by Robert Haas

Security: CVE-2012-0868

12 years agoRemove arbitrary limitation on length of common name in SSL certificates.
Tom Lane [Thu, 23 Feb 2012 20:48:09 +0000 (15:48 -0500)]
Remove arbitrary limitation on length of common name in SSL certificates.

Both libpq and the backend would truncate a common name extracted from a
certificate at 32 bytes.  Replace that fixed-size buffer with dynamically
allocated string so that there is no hard limit.  While at it, remove the
code for extracting peer_dn, which we weren't using for anything; and
don't bother to store peer_cn longer than we need it in libpq.

This limit was not so terribly unreasonable when the code was written,
because we weren't using the result for anything critical, just logging it.
But now that there are options for checking the common name against the
server host name (in libpq) or using it as the user's name (in the server),
this could result in undesirable failures.  In the worst case it even seems
possible to spoof a server name or user name, if the correct name is
exactly 32 bytes and the attacker can persuade a trusted CA to issue a
certificate in which that string is a prefix of the certificate's common
name.  (To exploit this for a server name, he'd also have to send the
connection astray via phony DNS data or some such.)  The case that this is
a realistic security threat is a bit thin, but nonetheless we'll treat it
as one.

Back-patch to 8.4.  Older releases contain the faulty code, but it's not
a security problem because the common name wasn't used for anything
interesting.

Reported and patched by Heikki Linnakangas

Security: CVE-2012-0867

12 years agoRequire execute permission on the trigger function for CREATE TRIGGER.
Tom Lane [Thu, 23 Feb 2012 20:39:02 +0000 (15:39 -0500)]
Require execute permission on the trigger function for CREATE TRIGGER.

This check was overlooked when we added function execute permissions to the
system years ago.  For an ordinary trigger function it's not a big deal,
since trigger functions execute with the permissions of the table owner,
so they couldn't do anything the user issuing the CREATE TRIGGER couldn't
have done anyway.  However, if a trigger function is SECURITY DEFINER,
that is not the case.  The lack of checking would allow another user to
install it on his own table and then invoke it with, essentially, forged
input data; which the trigger function is unlikely to realize, so it might
do something undesirable, for instance insert false entries in an audit log
table.

Reported by Dinesh Kumar, patch by Robert Haas

Security: CVE-2012-0866

12 years agoAllow MinGW builds to use standardly-named OpenSSL libraries.
Tom Lane [Thu, 23 Feb 2012 20:05:17 +0000 (15:05 -0500)]
Allow MinGW builds to use standardly-named OpenSSL libraries.

In the Fedora variant of MinGW, the openssl libraries have their normal
names, not libeay32 and libssleay32.  Adjust configure probes to allow
that, per bug #6486.

Tomasz Ostrowski

12 years agoTranslation updates
Peter Eisentraut [Thu, 23 Feb 2012 18:40:55 +0000 (20:40 +0200)]
Translation updates

12 years agoRemove inappropriate quotes
Peter Eisentraut [Thu, 23 Feb 2012 10:51:33 +0000 (12:51 +0200)]
Remove inappropriate quotes

And adjust wording for consistency.

12 years agoDraft release notes for 9.1.3, 9.0.7, 8.4.11, 8.3.18.
Tom Lane [Wed, 22 Feb 2012 23:11:51 +0000 (18:11 -0500)]
Draft release notes for 9.1.3, 9.0.7, 8.4.11, 8.3.18.

12 years agoREASSIGN OWNED: Support foreign data wrappers and servers
Alvaro Herrera [Tue, 21 Feb 2012 20:58:02 +0000 (17:58 -0300)]
REASSIGN OWNED: Support foreign data wrappers and servers

This was overlooked when implementing those kinds of objects, in commit
cae565e503c42a0942ca1771665243b4453c5770.

Per report from Pawel Casperek.

12 years agoCorrectly initialise shared recoveryLastRecPtr in recovery.
Simon Riggs [Wed, 22 Feb 2012 13:53:48 +0000 (13:53 +0000)]
Correctly initialise shared recoveryLastRecPtr in recovery.
Previously we used ReadRecPtr rather than EndRecPtr, which was
not a serious error but caused pg_stat_replication to report
incorrect replay_location until at least one WAL record is replayed.

Fujii Masao

12 years agoDon't clear btpo_cycleid during _bt_vacuum_one_page.
Tom Lane [Tue, 21 Feb 2012 20:03:44 +0000 (15:03 -0500)]
Don't clear btpo_cycleid during _bt_vacuum_one_page.

When "vacuuming" a single btree page by removing LP_DEAD tuples, we are not
actually within a vacuum operation, but rather in an ordinary insertion
process that could well be running concurrently with a vacuum.  So clearing
the cycleid is incorrect, and could cause the concurrent vacuum to miss
removing tuples that it needs to remove.  This is a longstanding bug
introduced by commit e6284649b9e30372b3990107a082bc7520325676 of
2006-07-25.  I believe it explains Maxim Boguk's recent report of index
corruption, and probably some other previously unexplained reports.

In 9.0 and up this is a one-line fix; before that we need to introduce a
flag to tell _bt_delitems what to do.

12 years agoAvoid double close of file handle in syslogger on win32
Magnus Hagander [Tue, 21 Feb 2012 16:12:25 +0000 (17:12 +0100)]
Avoid double close of file handle in syslogger on win32

This causes an exception when running under a debugger or in particular
when running on a debug version of Windows.

Patch from MauMau

12 years agoDon't reject threaded Python on FreeBSD.
Tom Lane [Mon, 20 Feb 2012 21:21:35 +0000 (16:21 -0500)]
Don't reject threaded Python on FreeBSD.

According to Chris Rees, this has worked for awhile, and the current
FreeBSD port is removing the test anyway.

12 years agoFix regex back-references that are directly quantified with *.
Tom Lane [Mon, 20 Feb 2012 05:52:42 +0000 (00:52 -0500)]
Fix regex back-references that are directly quantified with *.

The syntax "\n*", that is a backref with a * quantifier directly applied
to it, has never worked correctly in Spencer's library.  This has been an
open bug in the Tcl bug tracker since 2005:
https://sourceforge.net/tracker/index.php?func=detail&aid=1115587&group_id=10894&atid=110894

The core of the problem is in parseqatom(), which first changes "\n*" to
"\n+|" and then applies repeat() to the NFA representing the backref atom.
repeat() thinks that any arc leading into its "rp" argument is part of the
sub-NFA to be repeated.  Unfortunately, since parseqatom() already created
the arc that was intended to represent the empty bypass around "\n+", this
arc gets moved too, so that it now leads into the state loop created by
repeat().  Thus, what was supposed to be an "empty" bypass gets turned into
something that represents zero or more repetitions of the NFA representing
the backref atom.  In the original example, in place of
^([bc])\1*$
we now have something that acts like
^([bc])(\1+|[bc]*)$
At runtime, the branch involving the actual backref fails, as it's supposed
to, but then the other branch succeeds anyway.

We could no doubt fix this by some rearrangement of the operations in
parseqatom(), but that code is plenty ugly already, and what's more the
whole business of converting "x*" to "x+|" probably needs to go away to fix
another problem I'll mention in a moment.  Instead, this patch suppresses
the *-conversion when the target is a simple backref atom, leaving the case
of m == 0 to be handled at runtime.  This makes the patch in regcomp.c a
one-liner, at the cost of having to tweak cbrdissect() a little.  In the
event I went a bit further than that and rewrote cbrdissect() to check all
the string-length-related conditions before it starts comparing characters.
It seems a bit stupid to possibly iterate through many copies of an
n-character backreference, only to fail at the end because the target
string's length isn't a multiple of n --- we could have found that out
before starting.  The existing coding could only be a win if integer
division is hugely expensive compared to character comparison, but I don't
know of any modern machine where that might be true.

This does not fix all the problems with quantified back-references.  In
particular, the code is still broken for back-references that appear within
a larger expression that is quantified (so that direct insertion of the
quantification limits into the BACKREF node doesn't apply).  I think fixing
that will take some major surgery on the NFA code, specifically introducing
an explicit iteration node type instead of trying to transform iteration
into concatenation of modified regexps.

Back-patch to all supported branches.  In HEAD, also add a regression test
case for this.  (It may seem a bit silly to create a regression test file
for just one test case; but I'm expecting that we will soon import a whole
bunch of regex regression tests from Tcl, so might as well create the
infrastructure now.)

12 years agoFix longstanding error in contrib/intarray's int[] & int[] operator.
Tom Lane [Fri, 17 Feb 2012 01:00:17 +0000 (20:00 -0500)]
Fix longstanding error in contrib/intarray's int[] & int[] operator.

The array intersection code would give wrong results if the first entry of
the correct output array would be "1".  (I think only this value could be
at risk, since the previous word would always be a lower-bound entry with
that fixed value.)

Problem spotted by Julien Rouhaud, initial patch by Guillaume Lelarge,
cosmetic improvements by me.

12 years agoRun a portal's cleanup hook immediately when pushing it to FAILED state.
Tom Lane [Wed, 15 Feb 2012 21:18:39 +0000 (16:18 -0500)]
Run a portal's cleanup hook immediately when pushing it to FAILED state.

This extends the changes of commit 6252c4f9e201f619e5eebda12fa867acd4e4200e
so that we run the cleanup hook earlier for failure cases as well as
success cases.  As before, the point is to avoid an assertion failure from
an Assert I added in commit a874fe7b4c890d1fe3455215a83ca777867beadd, which
was meant to check that no user-written code can be called during portal
cleanup.  This fixes a case reported by Pavan Deolasee in which the Assert
could be triggered during backend exit (see the new regression test case),
and also prevents the possibility that the cleanup hook is run after
portions of the portal's state have already been recycled.  That doesn't
really matter in current usage, but it foreseeably could matter in the
future.

Back-patch to 9.1 where the Assert in question was added.

12 years agoDo not use the variable name when defining a varchar structure in ecpg.
Michael Meskes [Mon, 13 Feb 2012 12:19:57 +0000 (13:19 +0100)]
Do not use the variable name when defining a varchar structure in ecpg.

With a unique counter being added anyway, there is no need anymore to have the variable name listed, too.

12 years agoFix auto-explain JSON output to be valid JSON.
Andrew Dunstan [Mon, 13 Feb 2012 13:22:54 +0000 (08:22 -0500)]
Fix auto-explain JSON output to be valid JSON.

Problem reported by Peter Eisentraut.

Backpatched to release 9.0.

12 years agoFix I/O-conversion-related memory leaks in plpgsql.
Tom Lane [Sat, 11 Feb 2012 23:06:29 +0000 (18:06 -0500)]
Fix I/O-conversion-related memory leaks in plpgsql.

Datatype I/O functions are allowed to leak memory in CurrentMemoryContext,
since they are generally called in short-lived contexts.  However, plpgsql
calls such functions for purposes of type conversion, and was calling them
in its procedure context.  Therefore, any leaked memory would not be
recovered until the end of the plpgsql function.  If such a conversion
was done within a loop, quite a bit of memory could get consumed.  Fix by
calling such functions in the transient "eval_econtext", and adjust other
logic to match.  Back-patch to all supported versions.

Andres Freund, Jan Urbański, Tom Lane

12 years agoFix oversight in pg_dump's handling of extension configuration tables.
Tom Lane [Fri, 10 Feb 2012 20:22:14 +0000 (15:22 -0500)]
Fix oversight in pg_dump's handling of extension configuration tables.

If an extension has not been selected to be dumped (perhaps because of
a --schema or --table switch), the contents of its configuration tables
surely should not get dumped either.  Per gripe from
Hubert Depesz Lubaczewski.

12 years agoFix brain fade in previous pg_dump patch.
Tom Lane [Fri, 10 Feb 2012 19:09:25 +0000 (14:09 -0500)]
Fix brain fade in previous pg_dump patch.

In pre-7.3 databases, pg_attribute.attislocal doesn't exist.  The easiest
way to make sure the new inheritance logic behaves sanely is to assume it's
TRUE, not FALSE.  This will result in printing child columns even when
they're not really needed.  We could work harder at trying to reconstruct a
value for attislocal, but there is little evidence that anyone still cares
about dumping from such old versions, so just do the minimum necessary to
have a valid dump.

I had this correct in the original draft of the patch, but for some
unaccountable reason decided it wasn't necessary to change the value.
Testing against an old server shows otherwise...

12 years agoFix pg_dump for better handling of inherited columns.
Tom Lane [Fri, 10 Feb 2012 18:28:10 +0000 (13:28 -0500)]
Fix pg_dump for better handling of inherited columns.

Revise pg_dump's handling of inherited columns, which was last looked at
seriously in 2001, to eliminate several misbehaviors associated with
inherited default expressions and NOT NULL flags.  In particular make sure
that a column is printed in a child table's CREATE TABLE command if and
only if it has attislocal = true; the former behavior would sometimes cause
a column to become marked attislocal when it was not so marked in the
source database.  Also, stop relying on textual comparison of default
expressions to decide if they're inherited; instead, don't use
default-expression inheritance at all, but just install the default
explicitly at each level of the hierarchy.  This fixes the
search-path-related misbehavior recently exhibited by Chester Young, and
also removes some dubious assumptions about the order in which ALTER TABLE
SET DEFAULT commands would be executed.

Back-patch to all supported branches.

12 years agoThrow error sooner for unlogged GiST indexes.
Tom Lane [Wed, 8 Feb 2012 21:19:31 +0000 (16:19 -0500)]
Throw error sooner for unlogged GiST indexes.

Throwing an error only after we've built the main index fork is pretty
unfriendly when the table already contains data.  Per gripe from Jay
Levitt.

12 years agoFix postmaster to attempt restart after a hot-standby crash.
Tom Lane [Mon, 6 Feb 2012 20:29:26 +0000 (15:29 -0500)]
Fix postmaster to attempt restart after a hot-standby crash.

The postmaster was coded to treat any unexpected exit of the startup
process (i.e., the WAL replay process) as a catastrophic crash, and not try
to restart it. This was OK so long as the startup process could not have
any sibling postmaster children.  However, if a hot-standby backend
crashes, we SIGQUIT the startup process along with everything else, and the
resulting exit is hardly "unexpected".  Treating it as such meant we failed
to restart a standby server after any child crash at all, not only a crash
of the WAL replay process as intended.  Adjust that.  Back-patch to 9.0
where hot standby was introduced.

12 years agoAvoid throwing ERROR during WAL replay of DROP TABLESPACE.
Tom Lane [Mon, 6 Feb 2012 19:44:04 +0000 (14:44 -0500)]
Avoid throwing ERROR during WAL replay of DROP TABLESPACE.

Although we will not even issue an XLOG_TBLSPC_DROP WAL record unless
removal of the tablespace's directories succeeds, that does not guarantee
that the same operation will succeed during WAL replay.  Foreseeable
reasons for it to fail include temp files created in the tablespace by Hot
Standby backends, wrong directory permissions on a standby server, etc etc.
The original coding threw ERROR if replay failed to remove the directories,
but that is a serious overreaction.  Throwing an error aborts recovery,
and worse means that manual intervention will be needed to get the database
to start again, since otherwise the same error will recur on subsequent
attempts to replay the same WAL record.  And the consequence of failing to
remove the directories is only that some probably-small amount of disk
space is wasted, so it hardly seems justified to throw an error.
Accordingly, arrange to report such failures as LOG messages and keep going
when a failure occurs during replay.

Back-patch to 9.0 where Hot Standby was introduced.  In principle such
problems can occur in earlier releases, but Hot Standby increases the odds
of trouble significantly.  Given the lack of field reports of such issues,
I'm satisfied with patching back as far as the patch applies easily.

12 years agoAvoid problems with OID wraparound during WAL replay.
Tom Lane [Mon, 6 Feb 2012 18:14:46 +0000 (13:14 -0500)]
Avoid problems with OID wraparound during WAL replay.

Fix a longstanding thinko in replay of NEXTOID and checkpoint records: we
tried to advance nextOid only if it was behind the value in the WAL record,
but the comparison would draw the wrong conclusion if OID wraparound had
occurred since the previous value.  Better to just unconditionally assign
the new value, since OID assignment shouldn't be happening during replay
anyway.

The consequences of a failure to update nextOid would be pretty minimal,
since we have long had the code set up to obtain another OID and try again
if the generated value is already in use.  But in the worst case there
could be significant performance glitches while such loops iterate through
many already-used OIDs before finding a free one.

The odds of a wraparound happening during WAL replay would be small in a
crash-recovery scenario, and the length of any ensuing OID-assignment stall
quite limited anyway.  But neither of these statements hold true for a
replication slave that follows a WAL stream for a long period; its behavior
upon going live could be almost unboundedly bad.  Hence it seems worth
back-patching this fix into all supported branches.

Already fixed in HEAD in commit c6d76d7c82ebebb7210029f7382c0ebe2c558bca.

12 years agofe-misc.c depends on pg_config_paths.h
Alvaro Herrera [Mon, 6 Feb 2012 14:50:01 +0000 (11:50 -0300)]
fe-misc.c depends on pg_config_paths.h

Declare this in Makefile to avoid failures in parallel compiles.

Author: Lionel Elie Mamane

12 years agoFix transient clobbering of shared buffers during WAL replay.
Tom Lane [Sun, 5 Feb 2012 20:49:17 +0000 (15:49 -0500)]
Fix transient clobbering of shared buffers during WAL replay.

RestoreBkpBlocks was in the habit of zeroing and refilling the target
buffer; which was perfectly safe when the code was written, but is unsafe
during Hot Standby operation.  The reason is that we have coding rules
that allow backends to continue accessing a tuple in a heap relation while
holding only a pin on its buffer.  Such a backend could see transiently
zeroed data, if WAL replay had occasion to change other data on the page.
This has been shown to be the cause of bug #6425 from Duncan Rance (who
deserves kudos for developing a sufficiently-reproducible test case) as
well as Bridget Frey's re-report of bug #6200.  It most likely explains the
original report as well, though we don't yet have confirmation of that.

To fix, change the code so that only bytes that are supposed to change will
change, even transiently.  This actually saves cycles in RestoreBkpBlocks,
since it's not writing the same bytes twice.

Also fix seq_redo, which has the same disease, though it has to work a bit
harder to meet the requirement.

So far as I can tell, no other WAL replay routines have this type of bug.
In particular, the index-related replay routines, which would certainly be
broken if they had to meet the same standard, are not at risk because we
do not have coding rules that allow access to an index page when not
holding a buffer lock on it.

Back-patch to 9.0 where Hot Standby was added.

12 years agoResolve timing issue with logging locks for Hot Standby.
Simon Riggs [Wed, 1 Feb 2012 09:31:07 +0000 (09:31 +0000)]
Resolve timing issue with logging locks for Hot Standby.
We log AccessExclusiveLocks for replay onto standby nodes,
but because of timing issues on ProcArray it is possible to
log a lock that is still held by a just committed transaction
that is very soon to be removed. To avoid any timing issue we
avoid applying locks made by transactions with InvalidXid.

Simon Riggs, bug report Tom Lane, diagnosis Pavan Deolasee

12 years agoAccept a non-existent value in "ALTER USER/DATABASE SET ..." command.
Heikki Linnakangas [Mon, 30 Jan 2012 08:32:46 +0000 (10:32 +0200)]
Accept a non-existent value in "ALTER USER/DATABASE SET ..." command.

When default_text_search_config, default_tablespace, or temp_tablespaces
setting is set per-user or per-database, with an "ALTER USER/DATABASE SET
..." statement, don't throw an error if the text search configuration or
tablespace does not exist. In case of text search configuration, even if
it doesn't exist in the current database, it might exist in another
database, where the setting is intended to have its effect. This behavior
is now the same as search_path's.

Tablespaces are cluster-wide, so the same argument doesn't hold for
tablespaces, but there's a problem with pg_dumpall: it dumps "ALTER USER
SET ..." statements before the "CREATE TABLESPACE" statements. Arguably
that's pg_dumpall's fault - it should dump the statements in such an order
that the tablespace is created first and then the "ALTER USER SET
default_tablespace ..." statements after that - but it seems better to be
consistent with search_path and default_text_search_config anyway. Besides,
you could still create a dump that throws an error, by creating the
tablespace, running "ALTER USER SET default_tablespace", then dropping the
tablespace and running pg_dumpall on that.

Backpatch to all supported versions.

12 years agoFix pushing of index-expression qualifications through UNION ALL.
Tom Lane [Sun, 29 Jan 2012 21:31:31 +0000 (16:31 -0500)]
Fix pushing of index-expression qualifications through UNION ALL.

In commit 57664ed25e5dea117158a2e663c29e60b3546e1c, I made the planner
wrap non-simple-variable outputs of appendrel children (IOW, child SELECTs
of UNION ALL subqueries) inside PlaceHolderVars, in order to solve some
issues with EquivalenceClass processing.  However, this means that any
upper-level WHERE clauses mentioning such outputs will now contain
PlaceHolderVars after they're pushed down into the appendrel child,
and that prevents indxpath.c from recognizing that they could be matched
to index expressions.  To fix, add explicit stripping of PlaceHolderVars
from index operands, same as we have long done for RelabelType nodes.
Add a regression test covering both this and the plain-UNION case (which
is a totally different code path, but should also be able to do it).

Per bug #6416 from Matteo Beccati.  Back-patch to 9.1, same as the
previous change.

12 years agoUpdate statement about sorting of character-string data.
Tom Lane [Sun, 29 Jan 2012 01:54:56 +0000 (20:54 -0500)]
Update statement about sorting of character-string data.

The sort order is no longer fixed at database creation time, but can be
controlled via COLLATE.  Noted by Thomas Kellerer.

12 years agoFix handling of init_plans list in inheritance_planner().
Tom Lane [Sun, 29 Jan 2012 01:24:49 +0000 (20:24 -0500)]
Fix handling of init_plans list in inheritance_planner().

Formerly we passed an empty list to each per-child-table invocation of
grouping_planner, and then merged the results into the global list.
However, that fails if there's a CTE attached to the statement, because
create_ctescan_plan uses the list to find the plan referenced by a CTE
reference; so it was unable to find any CTEs attached to the outer UPDATE
or DELETE.  But there's no real reason not to use the same list throughout
the process, and doing so is simpler and faster anyway.

Per report from Josh Berkus of "could not find plan for CTE" failures.
Back-patch to 9.1 where we added support for WITH attached to UPDATE or
DELETE.  Add some regression test cases, too.

12 years agoFix handling of data-modifying CTE subplans in EvalPlanQual.
Tom Lane [Sat, 28 Jan 2012 22:44:03 +0000 (17:44 -0500)]
Fix handling of data-modifying CTE subplans in EvalPlanQual.

We can't just skip initializing such subplans, because the referencing CTE
node will expect to find the subplan available when it initializes.  That
in turn means that ExecInitModifyTable must allow the case (which actually
it needed to do anyway, since there's no guarantee that ModifyTable is
exactly at the top of the CTE plan tree).  So move the complaint about not
being allowed in EvalPlanQual mode to execution instead of initialization.
Testing turned up yet another problem, which is that we'd try to
re-initialize the result relation's index list, leading to leaks and
dangling pointers.

Per report from Phil Sorber.  Back-patch to 9.1 where data-modifying CTEs
were introduced.

12 years agoFix error detection in contrib/pgcrypto's encrypt_iv() and decrypt_iv().
Tom Lane [Sat, 28 Jan 2012 04:09:16 +0000 (23:09 -0500)]
Fix error detection in contrib/pgcrypto's encrypt_iv() and decrypt_iv().

Due to oversights, the encrypt_iv() and decrypt_iv() functions failed to
report certain types of invalid-input errors, and would instead return
random garbage values.

Marko Kreen, per report from Stefan Kaltenbrunner

12 years agoFix wording, per Peter Geoghegan
Magnus Hagander [Fri, 27 Jan 2012 09:36:27 +0000 (10:36 +0100)]
Fix wording, per Peter Geoghegan

12 years agoNow that the shared library name can be adjusted in the library test,
Bruce Momjian [Wed, 25 Jan 2012 14:35:17 +0000 (09:35 -0500)]
Now that the shared library name can be adjusted in the library test,
have pg_upgrade allocate a maximum fixed size buffer for testing the
library file name, rather than base the allocation on the library name.

Backpatch to 9.1.

12 years agoIn pg_upgrade, when checking for the plpython library, we must check for
Bruce Momjian [Wed, 25 Jan 2012 03:42:37 +0000 (22:42 -0500)]
In pg_upgrade, when checking for the plpython library, we must check for
"plpython2" when upgrading from pre-PG 9.1.  Patch to head and 9.1.

Per report from Peter.

12 years agoRemove tab in 9.1 SGML file.
Bruce Momjian [Tue, 24 Jan 2012 02:08:46 +0000 (21:08 -0500)]
Remove tab in 9.1 SGML file.

12 years agoFix corner case in cleanup of transactions using SSI.
Heikki Linnakangas [Wed, 18 Jan 2012 15:09:44 +0000 (17:09 +0200)]
Fix corner case in cleanup of transactions using SSI.

When the only remaining active transactions are READ ONLY, we do a "partial
cleanup" of committed transactions because certain types of conflicts
aren't possible anymore. For committed r/w transactions, we release the
SIREAD locks but keep the SERIALIZABLEXACT. However, for committed r/o
transactions, we can go further and release the SERIALIZABLEXACT too. The
problem was with the latter case: we were returning the SERIALIZABLEXACT to
the free list without removing it from the finished list.

The only real change in the patch is the SHMQueueDelete line, but I also
reworked some of the surrounding code to make it obvious that r/o and r/w
transactions are handled differently -- the existing code felt a bit too
clever.

Dan Ports

12 years agoImprove efficiency of recent changes to plperl's sv2cstr().
Andrew Dunstan [Sun, 15 Jan 2012 21:20:39 +0000 (16:20 -0500)]
Improve efficiency of recent changes to plperl's sv2cstr().

Along the way, add a missing dependency in the GNUmakefile.

Alex Hunsaker, with a slight adjustment by me.

12 years agoFix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows.
Tom Lane [Thu, 12 Jan 2012 21:40:19 +0000 (16:40 -0500)]
Fix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows.

In commit 7b0d0e9356963d5c3e4d329a917f5fbb82a2ef05, I made CLUSTER and
VACUUM FULL try to preserve toast value OIDs from the original toast table
to the new one.  However, if we have to copy both live and recently-dead
versions of a row that has a toasted column, those versions may well
reference the same toast value with the same OID.  The patch then led to
duplicate-key failures as we tried to insert the toast value twice with the
same OID.  (The previous behavior was not very desirable either, since it
would have silently inserted the same value twice with different OIDs.
That wastes space, but what's worse is that the toast values inserted for
already-dead heap rows would not be reclaimed by subsequent ordinary
VACUUMs, since they go into the new toast table marked live not deleted.)

To fix, check if the copied OID already exists in the new toast table, and
if so, assume that it stores the desired value.  This is reasonably safe
since the only case where we will copy an OID from a previous toast pointer
is when toast_insert_or_update was given that toast pointer and so we just
pulled the data from the old table; if we got two different values that way
then we have big problems anyway.  We do have to assume that no other
backend is inserting items into the new toast table concurrently, but
that's surely safe for CLUSTER and VACUUM FULL.

Per bug #6393 from Maxim Boguk.  Back-patch to 9.0, same as the previous
patch.

12 years agoFix one-byte buffer overrun in contrib/test_parser.
Tom Lane [Tue, 10 Jan 2012 00:56:27 +0000 (19:56 -0500)]
Fix one-byte buffer overrun in contrib/test_parser.

The original coding examined the next character before verifying that
there *is* a next character.  In the worst case with the input buffer
right up against the end of memory, this would result in a segfault.

Problem spotted by Paul Guyot; this commit extends his patch to fix an
additional case.  In addition, make the code a tad more readable by not
overloading the usage of *tlen.

12 years agoUse __sync_lock_test_and_set() for spinlocks on ARM, if available.
Tom Lane [Sat, 7 Jan 2012 20:38:59 +0000 (15:38 -0500)]
Use __sync_lock_test_and_set() for spinlocks on ARM, if available.

Historically we've used the SWPB instruction for TAS() on ARM, but this
is deprecated and not available on ARMv6 and later.  Instead, make use
of a GCC builtin if available.  We'll still fall back to SWPB if not,
so as not to break existing ports using older GCC versions.

Eventually we might want to try using __sync_lock_test_and_set() on some
other architectures too, but for now that seems to present only risk and
not reward.

Back-patch to all supported versions, since people might want to use any
of them on more recent ARM chips.

Martin Pitt

12 years agoFix typo, pg_types_date.h => pgtypes_date.h.
Tom Lane [Fri, 6 Jan 2012 18:31:41 +0000 (13:31 -0500)]
Fix typo, pg_types_date.h => pgtypes_date.h.

Spotted by Koizumi Satoru.

12 years agoFix pg_restore's direct-to-database mode for INSERT-style table data.
Tom Lane [Fri, 6 Jan 2012 18:04:15 +0000 (13:04 -0500)]
Fix pg_restore's direct-to-database mode for INSERT-style table data.

In commit 6545a901aaf84cb05212bb6a7674059908f527c3, I removed the mini SQL
lexer that was in pg_backup_db.c, thinking that it had no real purpose
beyond separating COPY data from SQL commands, which purpose had been
obsoleted by long-ago fixes in pg_dump's archive file format.
Unfortunately this was in error: that code was also used to identify
command boundaries in INSERT-style table data, which is run together as a
single string in the archive file for better compressibility.  As a result,
direct-to-database restores from archive files made with --inserts or
--column-inserts fail in our latest releases, as reported by Dick Visser.

To fix, restore the mini SQL lexer, but simplify it by adjusting the
calling logic so that it's only required to cope with INSERT-style table
data, not arbitrary SQL commands.  This allows us to not have to deal with
SQL comments, E'' strings, or dollar-quoted strings, none of which have
ever been emitted by dumpTableData_insert.

Also, fix the lexer to cope with standard-conforming strings, which was the
actual bug that the previous patch was meant to solve.

Back-patch to all supported branches.  The previous patch went back to 8.2,
which unfortunately means that the EOL release of 8.2 contains this bug,
but I don't think we're doing another 8.2 release just because of that.

12 years agoFix variable confusion in BufferSync().
Robert Haas [Fri, 6 Jan 2012 13:32:32 +0000 (08:32 -0500)]
Fix variable confusion in BufferSync().

As noted by Heikki Linnakangas, the previous coding confused the "flags"
variable with the "mask" variable.  The affect of this appears to be that
unlogged buffers would get written out at every checkpoint rather than
only at shutdown time.  Although that's arguably an acceptable failure
mode, I'm back-patching this change, since it seems like a poor idea to
rely on this happening to work.

12 years agoFix breakage from earlier plperl fix.
Andrew Dunstan [Thu, 5 Jan 2012 23:01:52 +0000 (18:01 -0500)]
Fix breakage from earlier plperl fix.

Apparently the perl garbage collector was a bit too eager, so here
we control when the new SV is garbage collected.

12 years agoWork around perl bug in SvPVutf8().
Andrew Dunstan [Thu, 5 Jan 2012 17:03:44 +0000 (12:03 -0500)]
Work around perl bug in SvPVutf8().

Certain things like typeglobs or readonly things like $^V cause
perl's SvPVutf8() to die nastily and crash the backend. To avoid
that bug we make a copy of the object, which will subsequently be
garbage collected.

Back patched to 9.1 where we first started using SvPVutf8().

Per -hackers discussion. Original problem reported by David Wheeler.

12 years agoMake executor's SELECT INTO code save and restore original tuple receiver.
Tom Lane [Wed, 4 Jan 2012 23:31:01 +0000 (18:31 -0500)]
Make executor's SELECT INTO code save and restore original tuple receiver.

As previously coded, the QueryDesc's dest pointer was left dangling
(pointing at an already-freed receiver object) after ExecutorEnd.  It's a
bit astonishing that it took us this long to notice, and I'm not sure that
the known problem case with SQL functions is the only one.  Fix it by
saving and restoring the original receiver pointer, which seems the most
bulletproof way of ensuring any related bugs are also covered.

Per bug #6379 from Paul Ramsey.  Back-patch to 8.4 where the current
handling of SELECT INTO was introduced.

12 years agoFix coerce_to_target_type for coerce_type's klugy handling of COLLATE.
Tom Lane [Mon, 2 Jan 2012 19:43:51 +0000 (14:43 -0500)]
Fix coerce_to_target_type for coerce_type's klugy handling of COLLATE.

Because coerce_type recurses into the argument of a CollateExpr,
coerce_to_target_type's longstanding code for detecting whether coerce_type
had actually done anything (to wit, returned a different node than it
passed in) was broken in 9.1.  This resulted in unexpected failures in
hide_coercion_node; which was not the latter's fault, since it's critical
that we never call it on anything that wasn't inserted by coerce_type.
(Else we might decide to "hide" a user-written function call.)

Fix by removing and replacing the CollateExpr in coerce_to_target_type
itself.  This is all pretty ugly but I don't immediately see a way to make
it nicer.

Per report from Jean-Yves F. Barbier.

12 years agoUpdate per-column ACLs, not only per-table ACL, when changing table owner.
Tom Lane [Wed, 21 Dec 2011 23:23:18 +0000 (18:23 -0500)]
Update per-column ACLs, not only per-table ACL, when changing table owner.

We forgot to modify column ACLs, so privileges were still shown as having
been granted by the old owner.  This meant that neither the new owner nor
a superuser could revoke the now-untraceable-to-table-owner permissions.
Per bug #6350 from Marc Balmer.

This has been wrong since column ACLs were added, so back-patch to 8.4.

12 years agoFix gincostestimate to handle ScalarArrayOpExpr reasonably.
Tom Lane [Wed, 21 Dec 2011 00:57:40 +0000 (19:57 -0500)]
Fix gincostestimate to handle ScalarArrayOpExpr reasonably.

The original coding of this function overlooked the possibility that
it could be passed anything except simple OpExpr indexquals.  But
ScalarArrayOpExpr is possible too, and the code would probably crash
(and surely give ridiculous answers) in such a case.  Add logic to try
to estimate sanely for such cases.

In passing, fix the treatment of inner-indexscan cost estimation: it was
failing to scale up properly for multiple iterations of a nestloop.
(I think somebody might've thought that index_pages_fetched() is linear,
but of course it's not.)

Report, diagnosis, and preliminary patch by Marti Raudsepp; I refactored
it a bit and fixed the cost estimation.

Back-patch into 9.1 where the bogus code was introduced.

12 years agoAvoid crashing when we have problems unlinking files post-commit.
Tom Lane [Tue, 20 Dec 2011 20:00:41 +0000 (15:00 -0500)]
Avoid crashing when we have problems unlinking files post-commit.

smgrdounlink takes care to not throw an ERROR if it fails to unlink
something, but that caution was rendered useless by commit
3396000684b41e7e9467d1abc67152b39e697035, which put an smgrexists call in
front of it; smgrexists *does* throw error if anything looks funny, such
as getting a permissions error from trying to open the file.  If that
happens post-commit, you get a PANIC, and what's worse the same logic
appears in the WAL replay code, so the database even fails to restart.

Restore the intended behavior by removing the smgrexists call --- it isn't
accomplishing anything that we can't do better by adjusting mdunlink's
ideas of whether it ought to warn about ENOENT or not.

Per report from Joseph Shraibman of unrecoverable crash after trying to
drop a table whose FSM fork had somehow gotten chmod'd to 000 permissions.
Backpatch to 8.4, where the bogus coding was introduced.

12 years agoIn ecpg removed old leftover check for given connection name.
Michael Meskes [Sun, 18 Dec 2011 14:34:33 +0000 (15:34 +0100)]
In ecpg removed old leftover check for given connection name.

Ever since we introduced real prepared statements this should work for
different connections. The old solution just emulating prepared statements,
though, wasn't able to handle this.

Closes: #6309
12 years agoFix reference to "verify-ca" and "verify-full" in a note in the docs.
Heikki Linnakangas [Fri, 16 Dec 2011 13:03:36 +0000 (15:03 +0200)]
Fix reference to "verify-ca" and "verify-full" in a note in the docs.

12 years agoDisable excessive FP optimization by recent versions of gcc.
Andrew Dunstan [Wed, 14 Dec 2011 22:14:21 +0000 (17:14 -0500)]
Disable excessive FP optimization by recent versions of gcc.

Suggested solution from Tom Lane. Problem discovered, probably not
for the first time, while testing the mingw-w64 32 bit compiler.

Backpatched to all live branches.

12 years agoRevert the behavior of inet/cidr functions to not unpack the arguments.
Heikki Linnakangas [Mon, 12 Dec 2011 07:49:47 +0000 (09:49 +0200)]
Revert the behavior of inet/cidr functions to not unpack the arguments.

I forgot to change the functions to use the PG_GETARG_INET_PP() macro,
when I changed DatumGetInetP() to unpack the datum, like Datum*P macros
usually do. Also, I screwed up the definition of the PG_GETARG_INET_PP()
macro, and didn't notice because it wasn't used.

This fixes the memory leak when sorting inet values, as reported
by Jochen Erwied and debugged by Andres Freund. Backpatch to 8.3, like
the previous patch that broke it.

12 years agoDon't set reachedMinRecoveryPoint during crash recovery. In crash recovery,
Heikki Linnakangas [Fri, 9 Dec 2011 12:32:42 +0000 (14:32 +0200)]
Don't set reachedMinRecoveryPoint during crash recovery. In crash recovery,
we don't reach consistency before replaying all of the WAL. Rename the
variable to reachedConsistency, to make its intention clearer.

In master, that was an active bug because of the recent patch to
immediately PANIC if a reference to a missing page is found in WAL after
reaching consistency, as Tom Lane's test case demonstrated. In 9.1 and 9.0,
the only consequence was a misleading "consistent recovery state reached at
%X/%X" message in the log at the beginning of crash recovery (the database
is not consistent at that point yet). In 8.4, the log message was not
printed in crash recovery, even though there was a similar
reachedMinRecoveryPoint local variable that was also set early. So,
backpatch to 9.1 and 9.0.

12 years agoFix corner cases in readlink() usage.
Tom Lane [Wed, 7 Dec 2011 18:34:19 +0000 (13:34 -0500)]
Fix corner cases in readlink() usage.

Make sure all calls are protected by HAVE_READLINK, and get the buffer
overflow tests right.  Be a bit more paranoid about string length in
_tarWriteHeader(), too.

12 years agoAvoid using readlink() on platforms that don't support it
Magnus Hagander [Wed, 7 Dec 2011 11:09:05 +0000 (12:09 +0100)]
Avoid using readlink() on platforms that don't support it

We don't have any such platforms now, but might in the future.

Also, detect cases when a tablespace symlink points to a path that
is longer than we can handle, and give a warning.

12 years agoAdd missing documentation for function pg_stat_get_wal_senders()
Magnus Hagander [Tue, 6 Dec 2011 10:02:02 +0000 (11:02 +0100)]
Add missing documentation for function pg_stat_get_wal_senders()

Euler Taveira de Oliveira

12 years agoIn pg_upgrade, allow tables using regclass to be upgraded because we
Bruce Momjian [Mon, 5 Dec 2011 21:45:19 +0000 (16:45 -0500)]
In pg_upgrade, allow tables using regclass to be upgraded because we
preserve pg_class oids since PG 9.0.

12 years agoApplied another patch by Zoltan to fix memory alignement issues in ecpg's sqlda
Michael Meskes [Sat, 3 Dec 2011 20:03:57 +0000 (21:03 +0100)]
Applied another patch by Zoltan to fix memory alignement issues in ecpg's sqlda
code.

12 years agoTreat ENOTDIR as ENOENT when looking for client certificate file
Magnus Hagander [Sat, 3 Dec 2011 14:02:53 +0000 (15:02 +0100)]
Treat ENOTDIR as ENOENT when looking for client certificate file

This makes it possible to use a libpq app with home directory set
to /dev/null, for example - treating it the same as if the file
doesn't exist (which it doesn't).

Per bug #6302, reported by Diego Elio Petteno

12 years agoAdd some weasel wording about threaded usage of PGresults.
Tom Lane [Fri, 2 Dec 2011 16:33:53 +0000 (11:33 -0500)]
Add some weasel wording about threaded usage of PGresults.

PGresults used to be read-only from the application's viewpoint, but now
that we've exposed various functions that allow modification of a PGresult,
that sweeping statement is no longer accurate.  Noted by Dmitriy Igrishin.

12 years agoStamp 9.1.2. REL9_1_2
Tom Lane [Thu, 1 Dec 2011 21:47:20 +0000 (16:47 -0500)]
Stamp 9.1.2.

12 years agoClarify documentation about SQL:2008 variant of LIMIT/OFFSET syntax.
Tom Lane [Thu, 1 Dec 2011 21:39:02 +0000 (16:39 -0500)]
Clarify documentation about SQL:2008 variant of LIMIT/OFFSET syntax.

The point that you need parentheses for non-constant expressions apparently
needs to be brought out a bit more clearly, per bug #6315.

12 years agoTranslation updates
Peter Eisentraut [Thu, 1 Dec 2011 21:03:05 +0000 (23:03 +0200)]
Translation updates

12 years agoFix getTypeIOParam to support type record[].
Tom Lane [Thu, 1 Dec 2011 17:44:22 +0000 (12:44 -0500)]
Fix getTypeIOParam to support type record[].

Since record[] uses array_in, it needs to have its element type passed
as typioparam.  In HEAD and 9.1, this fix essentially reverts commit
9bc933b2125a5358722490acbc50889887bf7680, which was a hack that is no
longer needed since domains don't set their typelem anymore.  Before
that, adjust the logic so that only domains are excluded from being
treated like arrays, rather than assuming that only base types should
be included.  Add a regression test to demonstrate the need for this.
Per report from Maxim Boguk.

Back-patch to 8.4, where type record[] was added.

12 years agoUpdate information about configuring SysV IPC parameters on NetBSD.
Tom Lane [Thu, 1 Dec 2011 01:55:04 +0000 (20:55 -0500)]
Update information about configuring SysV IPC parameters on NetBSD.

Per Emmanuel Kasper, sysctl works fine as of NetBSD 5.0.

12 years agoDraft release notes for 9.1.2, 9.0.6, 8.4.10, 8.3.17, 8.2.23.
Tom Lane [Thu, 1 Dec 2011 00:34:52 +0000 (19:34 -0500)]
Draft release notes for 9.1.2, 9.0.6, 8.4.10, 8.3.17, 8.2.23.

12 years agoUpdate time zone data files to tzdata release 2011n.
Tom Lane [Wed, 30 Nov 2011 16:48:05 +0000 (11:48 -0500)]
Update time zone data files to tzdata release 2011n.

DST law changes in Brazil, Cuba, Fiji, Palestine, Russia, Samoa.
Historical corrections for Alaska and British East Africa.

12 years agoTweak previous patch to ensure edata->filename always gets initialized.
Tom Lane [Wed, 30 Nov 2011 05:37:14 +0000 (00:37 -0500)]
Tweak previous patch to ensure edata->filename always gets initialized.

On a platform that isn't supplying __FILE__, previous coding would either
crash or give a stale result for the filename string.  Not sure how likely
that is, but the original code catered for it, so let's keep doing so.

12 years agoStrip file names reported in error messages in vpath builds
Peter Eisentraut [Tue, 29 Nov 2011 20:04:59 +0000 (22:04 +0200)]
Strip file names reported in error messages in vpath builds

In vpath builds, the __FILE__ macro that is used in verbose error
reports contains the full absolute file name, which makes the error
messages excessively verbose.  So keep only the base name, thus
matching the behavior of non-vpath builds.

12 years agoPrevent autovacuum transactions from running in serializable mode.
Tom Lane [Wed, 30 Nov 2011 03:39:16 +0000 (22:39 -0500)]
Prevent autovacuum transactions from running in serializable mode.

Force the transaction isolation level to READ COMMITTED in autovacuum
worker and launcher processes.  There is no benefit to using a higher
isolation level, and doing so could result in delaying foreground
transactions (or maybe even causing unnecessary serialization failures?).
Noted by Dan Ports.

Also, make sure we disable zero_damaged_pages and statement_timeout in
the autovac launcher, not only workers.  Now that the launcher can run
transactions, these settings could affect its behavior, and it seems
like the same arguments apply to the launcher as the workers.

12 years agopg_dump: Add gettext plural support to error message
Peter Eisentraut [Tue, 29 Nov 2011 17:49:02 +0000 (19:49 +0200)]
pg_dump: Add gettext plural support to error message

12 years agoDisallow deletion of CurrentExtensionObject while running extension script.
Tom Lane [Tue, 29 Nov 2011 00:12:17 +0000 (19:12 -0500)]
Disallow deletion of CurrentExtensionObject while running extension script.

While the deletion in itself wouldn't break things, any further creation
of objects in the script would result in dangling pg_depend entries being
added by recordDependencyOnCurrentExtension().  An example from Phil
Sorber convinced me that this is just barely likely enough to be worth
expending a couple lines of code to defend against.  The resulting error
message might be confusing, but it's better than leaving corrupted catalog
contents for the user to deal with.

12 years agoRemove erroneous claim about use of pg_locks.objid for advisory locks.
Tom Lane [Mon, 28 Nov 2011 18:52:04 +0000 (13:52 -0500)]
Remove erroneous claim about use of pg_locks.objid for advisory locks.

The correct information appears in the text, so just remove the statement
in the table, where it did not fit nicely anyway.  (Curiously, the correct
info has been there much longer than the erroneous table entry.)
Resolves problem noted by Daniele Varrazzo.

In HEAD and 9.1, also do a bit of wordsmithing on other text on the page.

12 years agoFix some bogosities in pg_dump's foreign-table support.
Tom Lane [Mon, 28 Nov 2011 17:51:47 +0000 (12:51 -0500)]
Fix some bogosities in pg_dump's foreign-table support.

The server name for a foreign table was not quoted at need, as per report
from Ronan Dunklau.  Also, queries related to FDW options were inadequately
schema-qualified in places where the search path isn't just pg_catalog, and
were inconsistently formatted everywhere, and we didn't always check that
we got the expected number of rows from them.

12 years agoEnsure that whole-row junk Vars are always of composite type.
Tom Lane [Mon, 28 Nov 2011 03:27:32 +0000 (22:27 -0500)]
Ensure that whole-row junk Vars are always of composite type.

The EvalPlanQual machinery assumes that whole-row Vars generated for the
outputs of non-table RTEs will be of composite types.  However, for the
case where the RTE is a function call returning a scalar type, we were
doing the wrong thing, as a result of sharing code with a parser case
where the function's scalar output is wanted.  (Or at least, that's what
that case has done historically; it does seem a bit inconsistent.)

To fix, extend makeWholeRowVar's API so that it can support both use-cases.
This fixes Belinda Cussen's report of crashes during concurrent execution
of UPDATEs involving joins to the result of UNNEST() --- in READ COMMITTED
mode, we'd run the EvalPlanQual machinery after a conflicting row update
commits, and it was expecting to get a HeapTuple not a scalar datum from
the "wholerowN" variable referencing the function RTE.

Back-patch to 9.0 where the current EvalPlanQual implementation appeared.

In 9.1 and up, this patch also fixes failure to attach the correct
collation to the Var generated for a scalar-result case.  An example:
regression=# select upper(x.*) from textcat('ab', 'cd') x;
ERROR:  could not determine which collation to use for upper() function

12 years agoFix MSVC builds broken by xsubpp change
Andrew Dunstan [Sun, 27 Nov 2011 06:23:00 +0000 (01:23 -0500)]
Fix MSVC builds broken by xsubpp change

12 years agoUse the right interpreter for encoding test.
Andrew Dunstan [Sat, 26 Nov 2011 23:40:54 +0000 (18:40 -0500)]
Use the right interpreter for encoding test.

12 years agoUse the preferred version of xsubpp, not necessarily the one that came with the
Andrew Dunstan [Sat, 26 Nov 2011 20:24:57 +0000 (15:24 -0500)]
Use the preferred version of xsubpp, not necessarily the one that came with the
distro version of perl.

David Wheeler and Alex Hunsaker.

Backpatch to 9.1 where it applies cleanly. A simple workaround is available for earlier
branches, and further effort doesn't seem warranted.

12 years agoFix overly-aggressive and inconsistent quoting in OS X start script.
Tom Lane [Sat, 26 Nov 2011 18:01:02 +0000 (13:01 -0500)]
Fix overly-aggressive and inconsistent quoting in OS X start script.

Sidar Lopez, per bug #6310, with some additional improvements by me.
Back-patch to 9.0, where the issue was introduced.

12 years agoEnsure plperl strings are always correctly UTF8 encoded.
Andrew Dunstan [Sat, 26 Nov 2011 17:16:27 +0000 (12:16 -0500)]
Ensure plperl strings are always correctly UTF8 encoded.

Amit Khandekar and Alex Hunsaker.

Backpatched to 9.1 where the problem first occurred.

12 years agoAllow pg_upgrade to upgrade clusters that use exclusion contraints by
Bruce Momjian [Fri, 25 Nov 2011 19:35:43 +0000 (14:35 -0500)]
Allow pg_upgrade to upgrade clusters that use exclusion contraints by
fixing pg_dump to properly preserve such indexes.

Backpatch to 9.1 and 9.0 (where the bug was introduced).

12 years agoFix erroneous replay of GIN_UPDATE_META_PAGE WAL records.
Tom Lane [Fri, 25 Nov 2011 18:58:59 +0000 (13:58 -0500)]
Fix erroneous replay of GIN_UPDATE_META_PAGE WAL records.

A simple thinko in ginRedoUpdateMetapage, namely failing to increment a
loop counter, led to inserting records into the last pending-list page in
the wrong order (the opposite of that intended).  So far as I can tell,
this would not upset the code that eventually flushes pending items into
the main part of the GIN index.  But it did break the code that searched
the pending list for matches, resulting in transient failure to find
matching entries during index lookups, as illustrated in bug #6307 from
Maksym Boguk.

Back-patch to 8.4 where the incorrect code was introduced.

12 years agoPreserve SQLSTATE when an SPI error is propagated through PL/python
Heikki Linnakangas [Thu, 24 Nov 2011 15:18:43 +0000 (17:18 +0200)]
Preserve SQLSTATE when an SPI error is propagated through PL/python
exception handler. This was a regression in 9.1, when the capability
to catch specific SPI errors was added, so backpatch to 9.1.

Mika Eloranta, with some editing by Jan Urbański.

12 years agoFix citext upgrade script to update derived copies of pg_type.typcollation.
Tom Lane [Mon, 21 Nov 2011 16:24:39 +0000 (11:24 -0500)]
Fix citext upgrade script to update derived copies of pg_type.typcollation.

If the existing citext type has not merely been created, but used in any
tables, then the upgrade script wasn't doing enough.  We have to update
attcollation for each citext table column, and indcollation for each citext
index column, as well.  Per report from Rudolf van der Leeden.

12 years agoAvoid floating-point underflow while tracking buffer allocation rate.
Tom Lane [Sat, 19 Nov 2011 05:35:29 +0000 (00:35 -0500)]
Avoid floating-point underflow while tracking buffer allocation rate.

When the system is idle for awhile after activity, the "smoothed_alloc"
state variable in BgBufferSync converges slowly to zero.  With standard
IEEE float arithmetic this results in several iterations with denormalized
values, which causes kernel traps and annoying log messages on some
poorly-designed platforms.  There's no real need to track such small values
of smoothed_alloc, so we can prevent the kernel traps by forcing it to zero
as soon as it's too small to be interesting for our purposes.  This issue
is purely cosmetic, since the iterations don't happen fast enough for the
kernel traps to pose any meaningful performance problem, but still it seems
worth shutting up the log messages.

The kernel log messages were previously reported by a number of people,
but kudos to Greg Matthews for tracking down exactly where they were coming
from.

12 years agoFix pg_upgrade's pg_scandir_internal() the right way. Backpatch to 9.1.
Bruce Momjian [Thu, 17 Nov 2011 18:40:45 +0000 (13:40 -0500)]
Fix pg_upgrade's pg_scandir_internal() the right way.  Backpatch to 9.1.

12 years agoFix pg_upgrade's pg_scandir_internal() to properly handle a NULL
Bruce Momjian [Thu, 17 Nov 2011 18:24:55 +0000 (13:24 -0500)]
Fix pg_upgrade's pg_scandir_internal() to properly handle a NULL
pattern, which is used on PG 9.1 and HEAD (but not pre-9.1).  Fixes
crash on Windows.

Backpatched to 9.1.

Reported by Mark Dilger

12 years agoApplied Zoltan's patch to correctly align interval and timestamp data in ecpg's sqlda.
Michael Meskes [Thu, 17 Nov 2011 13:07:25 +0000 (14:07 +0100)]
Applied Zoltan's patch to correctly align interval and timestamp data in ecpg's sqlda.

12 years agoDon't elide blank lines when accumulating psql command history.
Robert Haas [Wed, 16 Nov 2011 01:34:47 +0000 (20:34 -0500)]
Don't elide blank lines when accumulating psql command history.

This can change the meaning of queries, if the blank line happens to
occur in the middle of a quoted literal, as per complaint from Tomas Vondra.

Back-patch to all supported branches.

12 years agoApplied patch by Zoltan to fix copy&paste bug in ecpg's sqlda handling.
Michael Meskes [Sun, 13 Nov 2011 12:46:45 +0000 (13:46 +0100)]
Applied patch by Zoltan to fix copy&paste bug in ecpg's sqlda handling.

12 years agoIn plpgsql, allow foreign tables to define row types.
Tom Lane [Sat, 12 Nov 2011 23:49:15 +0000 (18:49 -0500)]
In plpgsql, allow foreign tables to define row types.

This seems to have been just an oversight in previous foreign-table work.
A quick grep didn't turn up any other places where RELKIND_FOREIGN_TABLE
was obviously omitted.

One change noted by Alexander Soudakov, the other by me.
Back-patch to 9.1.

12 years agoThrow nice error if server is too old to support psql's \ef or \sf command.
Tom Lane [Thu, 10 Nov 2011 23:36:55 +0000 (18:36 -0500)]
Throw nice error if server is too old to support psql's \ef or \sf command.

Previously, you'd get "function pg_catalog.pg_get_functiondef(integer) does
not exist", which is at best rather unprofessional-looking.  Back-patch
to 8.4 where \ef was introduced.

Josh Kupershmidt

12 years agoCorrect documentation for trace_userlocks.
Robert Haas [Thu, 10 Nov 2011 23:00:34 +0000 (18:00 -0500)]
Correct documentation for trace_userlocks.