]> granicus.if.org Git - postgresql/log
postgresql
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.

12 years agoAvoid platform-dependent infinite loop in pg_dump.
Tom Lane [Thu, 10 Nov 2011 21:08:23 +0000 (16:08 -0500)]
Avoid platform-dependent infinite loop in pg_dump.

If malloc(0) returns NULL, the binary search in findSecLabels() will
probably go into an infinite loop when there are no security labels,
because NULL-1 is greater than NULL after wraparound.

(We've seen this pathology before ... I wonder whether there's a way to
detect the class of bugs automatically?)

Diagnosis and patch by Steve Singer, cosmetic adjustments by me

12 years agoFix server header file installation with vpath builds
Peter Eisentraut [Thu, 10 Nov 2011 18:52:54 +0000 (20:52 +0200)]
Fix server header file installation with vpath builds

Several server header files would not be installed in vpath builds
because they live in the build directory.

12 years agoDocument that PQexec() can handle a NULL res pointer just fine.
Bruce Momjian [Thu, 10 Nov 2011 18:00:51 +0000 (13:00 -0500)]
Document that PQexec() can handle a NULL res pointer just fine.

Backpatch to 9.1.

Mark Hills

12 years agoOnly install the extension files for the current Python major version
Peter Eisentraut [Wed, 9 Nov 2011 19:43:04 +0000 (21:43 +0200)]
Only install the extension files for the current Python major version

12 years agoFix random discrepancies between parallel_schedule and serial_schedule.
Tom Lane [Wed, 9 Nov 2011 04:05:21 +0000 (23:05 -0500)]
Fix random discrepancies between parallel_schedule and serial_schedule.

In particular, my previous patch expected the create_index test to run
before the inherit test; but this was only true in the serial schedule.
Rearrange this portion of the schedules to be more consistent.

Per buildfarm results.

12 years agoWrap appendrel member outputs in PlaceHolderVars in additional cases.
Tom Lane [Wed, 9 Nov 2011 02:14:28 +0000 (21:14 -0500)]
Wrap appendrel member outputs in PlaceHolderVars in additional cases.

Add PlaceHolderVar wrappers as needed to make UNION ALL sub-select output
expressions appear non-constant and distinct from each other.  This makes
the world safe for add_child_rel_equivalences to do what it does.  Before,
it was possible for that function to add identical expressions to different
EquivalenceClasses, which logically should imply merging such ECs, which
would be wrong; or to improperly add a constant to an EquivalenceClass,
drastically changing its behavior.  Per report from Teodor Sigaev.

The only currently known consequence of this bug is "MergeAppend child's
targetlist doesn't match MergeAppend" planner failures in 9.1 and later.
I am suspicious that there may be other failure modes that could affect
older release branches; but in the absence of any hard evidence, I'll
refrain from back-patching further than 9.1.

12 years agoMake DatumGetInetP() unpack inet datums with a 1-byte header, and add
Heikki Linnakangas [Tue, 8 Nov 2011 20:39:43 +0000 (22:39 +0200)]
Make DatumGetInetP() unpack inet datums with a 1-byte header, and add
a new macro, DatumGetInetPP(), that does not. This brings these macros
in line with other DatumGet*P() macros.

Backpatch to 8.3, where 1-byte header varlenas were introduced.

12 years ago-DLINUX_OOM_ADJ=0 should be in CPPFLAGS, not CFLAGS
Peter Eisentraut [Tue, 8 Nov 2011 04:49:50 +0000 (06:49 +0200)]
-DLINUX_OOM_ADJ=0 should be in CPPFLAGS, not CFLAGS

12 years agoFix assorted bugs in contrib/unaccent's configuration file parsing.
Tom Lane [Mon, 7 Nov 2011 16:48:53 +0000 (11:48 -0500)]
Fix assorted bugs in contrib/unaccent's configuration file parsing.

Make it use t_isspace() to identify whitespace, rather than relying on
sscanf which is known to get it wrong on some platform/locale combinations.
Get rid of fixed-size buffers.  Make it actually continue to parse the file
after ignoring a line with untranslatable characters, as was obviously
intended.

The first of these issues is per gripe from J Smith, though not exactly
either of his proposed patches.

12 years agoDon't assume that a tuple's header size is unchanged during toasting.
Tom Lane [Sat, 5 Nov 2011 03:23:06 +0000 (23:23 -0400)]
Don't assume that a tuple's header size is unchanged during toasting.

This assumption can be wrong when the toaster is passed a raw on-disk
tuple, because the tuple might pre-date an ALTER TABLE ADD COLUMN operation
that added columns without rewriting the table.  In such a case the tuple's
natts value is smaller than what we expect from the tuple descriptor, and
so its t_hoff value could be smaller too.  In fact, the tuple might not
have a null bitmap at all, and yet our current opinion of it is that it
contains some trailing nulls.

In such a situation, toast_insert_or_update did the wrong thing, because
to save a few lines of code it would use the old t_hoff value as the offset
where heap_fill_tuple should start filling data.  This did not leave enough
room for the new nulls bitmap, with the result that the first few bytes of
data could be overwritten with null flag bits, as in a recent report from
Hubert Depesz Lubaczewski.

The particular case reported requires ALTER TABLE ADD COLUMN followed by
CREATE TABLE AS SELECT * FROM ... or INSERT ... SELECT * FROM ..., and
further requires that there be some out-of-line toasted fields in one of
the tuples to be copied; else we'll not reach the troublesome code.
The problem can only manifest in this form in 8.4 and later, because
before commit a77eaa6a95009a3441e0d475d1980259d45da072, CREATE TABLE AS or
INSERT/SELECT wouldn't result in raw disk tuples getting passed directly
to heap_insert --- there would always have been at least a junkfilter in
between, and that would reconstitute the tuple header with an up-to-date
t_natts and hence t_hoff.  But I'm backpatching the tuptoaster change all
the way anyway, because I'm not convinced there are no older code paths
that present a similar risk.

12 years agoFix archive_command example
Peter Eisentraut [Fri, 4 Nov 2011 20:01:35 +0000 (22:01 +0200)]
Fix archive_command example

The given archive_command example didn't use %p or %f, which wouldn't
really work in practice.

12 years agoFix bogus code in contrib/ tsearch dictionary examples.
Tom Lane [Thu, 3 Nov 2011 23:17:52 +0000 (19:17 -0400)]
Fix bogus code in contrib/ tsearch dictionary examples.

Both dict_int and dict_xsyn were blithely assuming that whatever memory
palloc gives back will be pre-zeroed.  This would typically work for
just about long enough to run their regression tests, and no longer :-(.

The pre-9.0 code in dict_xsyn was even lamer than that, as it would
happily give back a pointer to the result of palloc(0), encouraging
its caller to access off the end of memory.  Again, this would just
barely fail to fail as long as memory contained nothing but zeroes.

Per a report from Rodrigo Hjort that code based on these examples
didn't work reliably.

12 years agoFix inline_set_returning_function() to allow multiple OUT parameters.
Tom Lane [Thu, 3 Nov 2011 21:53:19 +0000 (17:53 -0400)]
Fix inline_set_returning_function() to allow multiple OUT parameters.

inline_set_returning_function failed to distinguish functions returning
generic RECORD (which require a column list in the RTE, as well as run-time
type checking) from those with multiple OUT parameters (which do not).
This prevented inlining from happening.  Per complaint from Jay Levitt.
Back-patch to 8.4 where this capability was introduced.

12 years agoFix handling of PlaceHolderVars in nestloop parameter management.
Tom Lane [Thu, 3 Nov 2011 04:51:06 +0000 (00:51 -0400)]
Fix handling of PlaceHolderVars in nestloop parameter management.

If we use a PlaceHolderVar from the outer relation in an inner indexscan,
we need to reference the PlaceHolderVar as such as the value to be passed
in from the outer relation.  The previous code effectively tried to
reconstruct the PHV from its component expression, which doesn't work since
(a) the Vars therein aren't necessarily bubbled up far enough, and (b) it
would be the wrong semantics anyway because of the possibility that the PHV
is supposed to have gone to null at some point before the current join.
Point (a) led to "variable not found in subplan target list" planner
errors, but point (b) would have led to silently wrong answers.
Per report from Roger Niederland.

12 years agoRevert "Stop btree indexscans upon reaching nulls in either direction."
Tom Lane [Wed, 2 Nov 2011 17:33:10 +0000 (13:33 -0400)]
Revert "Stop btree indexscans upon reaching nulls in either direction."

This reverts commit 048fffed55ff1d6d346130e4a6b7be434e81e82c.
As pointed out by Naoya Anzai, we need to do more work to make that
idea handle end-of-index cases, and it is looking like too much risk
for a back-patch.  So bug #6278 is only going to be fixed in HEAD.

12 years agoDerive oldestActiveXid at correct time for Hot Standby.
Simon Riggs [Wed, 2 Nov 2011 08:53:40 +0000 (08:53 +0000)]
Derive oldestActiveXid at correct time for Hot Standby.
There was a timing window between when oldestActiveXid was derived
and when it should have been derived that only shows itself under
heavy load. Move code around to ensure correct timing of derivation.
No change to StartupSUBTRANS() code, which is where this failed.

Bug report by Chris Redekop

12 years agoStart Hot Standby faster when initial snapshot is incomplete.
Simon Riggs [Wed, 2 Nov 2011 08:46:11 +0000 (08:46 +0000)]
Start Hot Standby faster when initial snapshot is incomplete.
If the initial snapshot had overflowed then we can start whenever
the latest snapshot is empty, not overflowed or as we did already,
start when the xmin on primary was higher than xmax of our starting
snapshot, which proves we have full snapshot data.

Bug report by Chris Redekop

12 years agoFix timing of Startup CLOG and MultiXact during Hot Standby
Simon Riggs [Wed, 2 Nov 2011 08:06:54 +0000 (08:06 +0000)]
Fix timing of Startup CLOG and MultiXact during Hot Standby

Patch by me, bug report by Chris Redekop, analysis by Florian Pflug

12 years agoFix race condition with toast table access from a stale syscache entry.
Tom Lane [Tue, 1 Nov 2011 23:48:43 +0000 (19:48 -0400)]
Fix race condition with toast table access from a stale syscache entry.

If a tuple in a syscache contains an out-of-line toasted field, and we
try to fetch that field shortly after some other transaction has committed
an update or deletion of the tuple, there is a race condition: vacuum
could come along and remove the toast tuples before we can fetch them.
This leads to transient failures like "missing chunk number 0 for toast
value NNNNN in pg_toast_2619", as seen in recent reports from Andrew
Hammond and Tim Uckun.

The design idea of syscache is that access to stale syscache entries
should be prevented by relation-level locks, but that fails for at least
two cases where toasted fields are possible: ANALYZE updates pg_statistic
rows without locking out sessions that might want to plan queries on the
same table, and CREATE OR REPLACE FUNCTION updates pg_proc rows without
any meaningful lock at all.

The least risky fix seems to be an idea that Heikki suggested when we
were dealing with a related problem back in August: forcibly detoast any
out-of-line fields before putting a tuple into syscache in the first place.
This avoids the problem because at the time we fetch the parent tuple from
the catalog, we should be holding an MVCC snapshot that will prevent
removal of the toast tuples, even if the parent tuple is outdated
immediately after we fetch it.  (Note: I'm not convinced that this
statement holds true at every instant where we could be fetching a syscache
entry at all, but it does appear to hold true at the times where we could
fetch an entry that could have a toasted field.  We will need to be a bit
wary of adding toast tables to low-level catalogs that don't have them
already.)  An additional benefit is that subsequent uses of the syscache
entry should be faster, since they won't have to detoast the field.

Back-patch to all supported versions.  The problem is significantly harder
to reproduce in pre-9.0 releases, because of their willingness to flush
every entry in a syscache whenever the underlying catalog is vacuumed
(cf CatalogCacheFlushRelation); but there is still a window for trouble.

12 years agoDocument that multiple LDAP servers can be specified
Magnus Hagander [Tue, 1 Nov 2011 14:44:26 +0000 (15:44 +0100)]
Document that multiple LDAP servers can be specified

12 years agoStop btree indexscans upon reaching nulls in either direction.
Tom Lane [Mon, 31 Oct 2011 20:40:11 +0000 (16:40 -0400)]
Stop btree indexscans upon reaching nulls in either direction.

The existing scan-direction-sensitive tests were overly complex, and
failed to stop the scan in cases where it's perfectly legitimate to do so.
Per bug #6278 from Maksym Boguk.

Back-patch to 8.3, which is as far back as the patch applies easily.
Doesn't seem worth sweating over a relatively minor performance issue in
8.2 at this late date.  (But note that this was a performance regression
from 8.1 and before, so 8.2 is being left as an outlier.)

12 years agoFix assorted bogosities in cash_in() and cash_out().
Tom Lane [Sat, 29 Oct 2011 18:30:59 +0000 (14:30 -0400)]
Fix assorted bogosities in cash_in() and cash_out().

cash_out failed to handle multiple-byte thousands separators, as per bug
#6277 from Alexander Law.  In addition, cash_in didn't handle that either,
nor could it handle multiple-byte positive_sign.  Both routines failed to
support multiple-byte mon_decimal_point, which I did not think was worth
changing, but at least now they check for the possibility and fall back to
using '.' rather than emitting invalid output.  Also, make cash_in handle
trailing negative signs, which formerly it would reject.  Since cash_out
generates trailing negative signs whenever the locale tells it to, this
last omission represents a fail-to-reload-dumped-data bug.  IMO that
justifies patching this all the way back.

12 years agoClarify that ORDER BY/FOR UPDATE can't malfunction at higher iso levels.
Robert Haas [Fri, 28 Oct 2011 16:02:04 +0000 (12:02 -0400)]
Clarify that ORDER BY/FOR UPDATE can't malfunction at higher iso levels.

Kevin Grittner

12 years agoChange "and and" to "and".
Robert Haas [Fri, 28 Oct 2011 15:59:55 +0000 (11:59 -0400)]
Change "and and" to "and".

Report by Vik Reykja, patch by Kevin Grittner.

12 years agoUpdate docs to point to the timezone library's new home at IANA.
Tom Lane [Fri, 28 Oct 2011 03:09:10 +0000 (23:09 -0400)]
Update docs to point to the timezone library's new home at IANA.

The recent unpleasantness with copyrights has accelerated a move that
was already in planning.

12 years agoTypo fixes.
Tom Lane [Wed, 26 Oct 2011 22:04:13 +0000 (18:04 -0400)]
Typo fixes.

expect -> except, noted by Andrew Dunstan.  Also, "cannot" seems more
readable here than "can not", per David Wheeler.

12 years agoChange FK trigger creation order to better support self-referential FKs.
Tom Lane [Wed, 26 Oct 2011 17:02:35 +0000 (13:02 -0400)]
Change FK trigger creation order to better support self-referential FKs.

When a foreign-key constraint references another column of the same table,
row updates will queue both the PK's ON UPDATE action and the FK's CHECK
action in the same event.  The ON UPDATE action must execute first, else
the CHECK will check a non-final state of the row and possibly throw an
inappropriate error, as seen in bug #6268 from Roman Lytovchenko.

Now, the firing order of multiple triggers for the same event is determined
by the sort order of their pg_trigger.tgnames, and the auto-generated names
we use for FK triggers are "RI_ConstraintTrigger_NNNN" where NNNN is the
trigger OID.  So most of the time the firing order is the same as creation
order, and so rearranging the creation order fixes it.

This patch will fail to fix the problem if the OID counter wraps around or
adds a decimal digit (eg, from 99999 to 100000) while we are creating the
triggers for an FK constraint.  Given the small odds of that, and the low
usage of self-referential FKs, we'll live with that solution in the back
branches.  A better fix is to change the auto-generated names for FK
triggers, but it seems unwise to do that in stable branches because there
may be client code that depends on the naming convention.  We'll fix it
that way in HEAD in a separate patch.

Back-patch to all supported branches, since this bug has existed for a long
time.

12 years agoFix typo
Magnus Hagander [Tue, 25 Oct 2011 20:46:14 +0000 (22:46 +0200)]
Fix typo

12 years agoDon't trust deferred-unique indexes for join removal.
Tom Lane [Sun, 23 Oct 2011 04:43:45 +0000 (00:43 -0400)]
Don't trust deferred-unique indexes for join removal.

The uniqueness condition might fail to hold intra-transaction, and assuming
it does can give incorrect query results.  Per report from Marti Raudsepp,
though this is not his proposed patch.

Back-patch to 9.0, where both these features were introduced.  In the
released branches, add the new IndexOptInfo field to the end of the struct,
to try to minimize ABI breakage for third-party code that may be examining
that struct.

12 years agoFix overly-complicated usage of errcode_for_file_access().
Heikki Linnakangas [Sat, 22 Oct 2011 17:16:05 +0000 (20:16 +0300)]
Fix overly-complicated usage of errcode_for_file_access().

No need to do  "errcode(errcode_for_file_access())", just
"errcode_for_file_access()" is enough. The extra errcode() call is useless
but harmless, so there's no user-visible bug here. Nevertheless, backpatch
to 9.1 where this code were added.

12 years agoMore cleanup after failed reduced-lock-levels-for-DDL feature.
Tom Lane [Fri, 21 Oct 2011 17:49:58 +0000 (13:49 -0400)]
More cleanup after failed reduced-lock-levels-for-DDL feature.

Turns out that use of ShareUpdateExclusiveLock or ShareRowExclusiveLock
to protect DDL changes had gotten copied into several places that were
not touched by either of Simon's original patches for the feature, and
thus neither he nor I thought to revert them.  (Indeed, it appears that
two of these uses were committed *after* the reversion, which just goes
to show that git merging is no panacea.)  Change these places to use
AccessExclusiveLock again.  If we ever manage to resurrect that feature,
we're going to have to think a bit harder about how to keep lock level
usage in sync for DDL operations that aren't within the AlterTable
infrastructure.

Two of these bugs are only in HEAD, but one is in the 9.1 branch too.
Alvaro found one of them, I found the other two.

12 years agoFix DROP OPERATOR FAMILY IF EXISTS.
Robert Haas [Fri, 21 Oct 2011 13:10:46 +0000 (09:10 -0400)]
Fix DROP OPERATOR FAMILY IF EXISTS.

Essentially, the "IF EXISTS" portion was being ignored, and an error
thrown anyway if the opfamily did not exist.

I broke this in commit fd1843ff8979c0461fb3f1a9eab61140c977e32d; so
backpatch to 9.1.X.

Report and diagnosis by KaiGai Kohei.

12 years agoSimplify and improve ProcessStandbyHSFeedbackMessage logic.
Tom Lane [Thu, 20 Oct 2011 23:43:31 +0000 (19:43 -0400)]
Simplify and improve ProcessStandbyHSFeedbackMessage logic.

There's no need to clamp the standby's xmin to be greater than
GetOldestXmin's result; if there were any such need this logic would be
hopelessly inadequate anyway, because it fails to account for
within-database versus cluster-wide values of GetOldestXmin.  So get rid of
that, and just rely on sanity-checking that the xmin is not wrapped around
relative to the nextXid counter.  Also, don't reset the walsender's xmin if
the current feedback xmin is indeed out of range; that just creates more
problems than we already had.  Lastly, don't bother to take the
ProcArrayLock; there's no need to do that to set xmin.

Also improve the comments about this in GetOldestXmin itself.

12 years agoFix memory leak in tab completion.
Tom Lane [Thu, 20 Oct 2011 19:44:21 +0000 (15:44 -0400)]
Fix memory leak in tab completion.

This was introduced in commit e49ad77ff958b380ea6fa08c72e2dce97ac56c6b.
Fixed in another, more future-proof way in HEAD.

12 years agoDocument that postmaster.opts is excluded from base backups
Robert Haas [Wed, 19 Oct 2011 04:19:43 +0000 (00:19 -0400)]
Document that postmaster.opts is excluded from base backups

Fujii Masao

12 years agoFix pg_dump to dump casts between auto-generated types.
Tom Lane [Tue, 18 Oct 2011 21:11:01 +0000 (17:11 -0400)]
Fix pg_dump to dump casts between auto-generated types.

The heuristic for when to dump a cast failed for a cast between table
rowtypes, as reported by Frédéric Rejol.  Fix it by setting
the "dump" flag for such a type the same way as the flag is set for the
underlying table or base type.  This won't result in the auto-generated
type appearing in the output, since setting its objType to DO_DUMMY_TYPE
unconditionally suppresses that.  But it will result in dumpCast doing what
was intended.

Back-patch to 8.3.  The 8.2 code is rather different in this area, and it
doesn't seem worth any risk to fix a corner case that nobody has stumbled
on before.

12 years agoExclude postmaster.opts from base backups
Magnus Hagander [Sun, 16 Oct 2011 15:42:59 +0000 (17:42 +0200)]
Exclude postmaster.opts from base backups

Noted by Fujii Masao

12 years agoFix collate.linux.utf8 expected output for recent error message change.
Tom Lane [Sun, 16 Oct 2011 20:07:44 +0000 (16:07 -0400)]
Fix collate.linux.utf8 expected output for recent error message change.

Noted by Jeff Davis.

12 years agoFix bugs in information_schema.referential_constraints view.
Tom Lane [Sat, 15 Oct 2011 00:24:22 +0000 (20:24 -0400)]
Fix bugs in information_schema.referential_constraints view.

This view was being insufficiently careful about matching the FK constraint
to the depended-on primary or unique key constraint.  That could result in
failure to show an FK constraint at all, or showing it multiple times, or
claiming that it depended on a different constraint than the one it really
does.  Fix by joining via pg_depend to ensure that we find only the correct
dependency.

Back-patch, but don't bump catversion because we can't force initdb in back
branches.  The next minor-version release notes should explain that if you
need to fix this in an existing installation, you can drop the
information_schema schema then re-create it by sourcing
$SHAREDIR/information_schema.sql in each database (as a superuser of
course).

12 years agoFix up Perl-to-Postgres datatype conversions in pl/perl.
Tom Lane [Thu, 13 Oct 2011 22:02:43 +0000 (18:02 -0400)]
Fix up Perl-to-Postgres datatype conversions in pl/perl.

This patch restores the pre-9.1 behavior that pl/perl functions returning
VOID ignore the result value of their last Perl statement.  9.1.0
unintentionally threw an error if the last statement returned a reference,
as reported by Amit Khandekar.

Also, make sure it works to return a string value for a composite type,
so long as the string meets the type's input format.  We already allowed
the equivalent behavior for arrays, so it seems inconsistent to not allow
it for composites.

In addition, ensure we throw errors for attempts to return arrays or hashes
when the function's declared result type is not an array or composite type,
respectively.  Pre-9.1 versions rather uselessly returned strings like
ARRAY(0x221a9a0) or HASH(0x221aa90), while 9.1.0 threw an error for the
hash case and returned a garbage value for the array case.

Also, clean up assorted grotty coding in Perl array conversion, including
use of a session-lifespan memory context to accumulate the array value
(resulting in session-lifespan memory leak on error), failure to apply the
declared typmod if any, and failure to detect some cases of non-rectangular
multi-dimensional arrays.

Alex Hunsaker and Tom Lane

12 years agoUpdate documentation about ts_rank().
Bruce Momjian [Thu, 13 Oct 2011 18:17:21 +0000 (14:17 -0400)]
Update documentation about ts_rank().

12 years agoFix typo in dummy_seclabel documentation.
Tom Lane [Thu, 13 Oct 2011 16:16:07 +0000 (12:16 -0400)]
Fix typo in dummy_seclabel documentation.

dummy_label -> dummy_seclabel

Thom Brown

12 years agoDon't mark auto-generated types as extension members.
Tom Lane [Wed, 12 Oct 2011 22:40:09 +0000 (18:40 -0400)]
Don't mark auto-generated types as extension members.

Relation rowtypes and automatically-generated array types do not need to
have their own extension membership dependency entries.  If we create such
then it becomes more difficult to remove items from an extension, and it's
also harder for an extension upgrade script to make sure it duplicates the
dependencies created by the extension's regular installation script.

I changed the code in such a way that this happened in commit
988cccc620dd8c16d77f88ede167b22056176324, I think because of worries about
the shell-type-replacement case; but that cure was worse than the disease.
It would only matter if one extension created a shell type that was
replaced with an auto-generated type in another extension, which seems
pretty far-fetched.  Better to make this work unsurprisingly in normal
cases.

Report and patch by Robert Haas, comment adjustments by me.

12 years agoThrow a useful error message if an extension script file is fed to psql.
Tom Lane [Wed, 12 Oct 2011 19:45:03 +0000 (15:45 -0400)]
Throw a useful error message if an extension script file is fed to psql.

We have seen one too many reports of people trying to use 9.1 extension
files in the old-fashioned way of sourcing them in psql.  Not only does
that usually not work (due to failure to substitute for MODULE_PATHNAME
and/or @extschema@), but if it did work they'd get a collection of loose
objects not an extension.  To prevent this, insert an \echo ... \quit
line that prints a suitable error message into each extension script file,
and teach commands/extension.c to ignore lines starting with \echo.
That should not only prevent any adverse consequences of loading a script
file the wrong way, but make it crystal clear to users that they need to
do it differently now.

Tom Lane, following an idea of Andrew Dunstan's.  Back-patch into 9.1
... there is not going to be much value in this if we wait till 9.2.

12 years agoModify up/home macro to match standard parameter list; fixes doc build.
Bruce Momjian [Wed, 12 Oct 2011 18:05:00 +0000 (14:05 -0400)]
Modify up/home macro to match standard parameter list;  fixes doc build.

12 years agoImprove documentation of psql's \q command.
Tom Lane [Wed, 12 Oct 2011 17:59:30 +0000 (13:59 -0400)]
Improve documentation of psql's \q command.

The documentation neglected to explain its behavior in a script file
(it only ends execution of the script, not psql as a whole), and failed
to mention the long form \quit either.

12 years agoAdd Up/Home link to the top of the HTML doc output.
Bruce Momjian [Wed, 12 Oct 2011 15:24:15 +0000 (11:24 -0400)]
Add Up/Home link to the top of the HTML doc output.

Backpatch to 9.0.X and 9.1.X.

12 years agoDocument that not backing up postmaster.pid and postmaster.opts might
Bruce Momjian [Tue, 11 Oct 2011 21:33:21 +0000 (17:33 -0400)]
Document that not backing up postmaster.pid and postmaster.opts might
help prevent pg_ctl from getting confused.

Backpatch to 9.1.

12 years agoImprove documentation of how to fiddle with SCSI drives on FreeBSD.
Robert Haas [Mon, 10 Oct 2011 17:21:35 +0000 (13:21 -0400)]
Improve documentation of how to fiddle with SCSI drives on FreeBSD.

Per suggestions from Achilleas Mantzios and Greg Smith.

12 years agoFix typo in docs for libpq keepalives_count option.
Robert Haas [Mon, 10 Oct 2011 17:10:47 +0000 (13:10 -0400)]
Fix typo in docs for libpq keepalives_count option.

Shigehiro Honda

12 years agoRevert accidental change to pg_config_manual.h.
Robert Haas [Mon, 10 Oct 2011 02:20:44 +0000 (22:20 -0400)]
Revert accidental change to pg_config_manual.h.

This was broken in commit 53dbc27c62d8e1b6c5253feba04a5094cb8fe046, which
introduced unlogged tables.  Fortunately, as debugging tools go, this one
is pretty cheap, which is probably why it took nine months for someone to
notice, but it's not intended to be enabled by default, so revert.

Noted by Fujii Masao.

12 years agoDon't let transform_null_equals=on affect CASE foo WHEN NULL ... constructs.
Heikki Linnakangas [Sat, 8 Oct 2011 08:17:40 +0000 (11:17 +0300)]
Don't let transform_null_equals=on affect CASE foo WHEN NULL ... constructs.
transform_null_equals is only supposed to affect "foo = NULL" expressions
given directly by the user, not the internal "foo = NULL" expression
generated from CASE-WHEN.

This fixes bug #6242, reported by Sergey. Backpatch to all supported
branches.