]> granicus.if.org Git - postgresql/log
postgresql
12 years agoFix pg_upgrade for EXEC_BACKEND builds (e.g. Windows) by properly
Bruce Momjian [Thu, 29 Sep 2011 21:20:56 +0000 (17:20 -0400)]
Fix pg_upgrade for EXEC_BACKEND builds (e.g. Windows) by properly
passing the -b/binary-upgrade flag.

Backpatch to 9.1.X.

12 years agoFix index matching for operators with mixed collatable/noncollatable inputs.
Tom Lane [Thu, 29 Sep 2011 04:43:42 +0000 (00:43 -0400)]
Fix index matching for operators with mixed collatable/noncollatable inputs.

If an indexable operator for a non-collatable indexed datatype has a
collatable right-hand input type, any OpExpr for it will be marked with a
nonzero inputcollid (since having one collatable input is sufficient to
make that happen).  However, an index on a non-collatable column certainly
doesn't have any collation.  This caused us to fail to match such operators
to their indexes, because indxpath.c required an exact match of index
collation and clause collation.  It seems correct to allow a match when the
index is collation-less regardless of the clause's inputcollid: an operator
with both noncollatable and collatable inputs could perhaps depend on the
collation of the collatable input, but it could hardly expect the index for
the noncollatable input to have that same collation.

Per bug #6232 from Pierre Ducroquet.  His example is specifically about
"hstore ? text" but the problem seems quite generic.

12 years agoIn pg_upgrade, because toast table names can be mismatched with the heap
Bruce Momjian [Thu, 29 Sep 2011 02:53:44 +0000 (22:53 -0400)]
In pg_upgrade, because toast table names can be mismatched with the heap
oid on 8.4, modify the toast name comparison test to only apply to old
9.0+ servers.  (The test was previously 8.4+.)

12 years agoTake sepgsql regression tests out of the regular regression test mechanism.
Tom Lane [Wed, 28 Sep 2011 00:15:54 +0000 (20:15 -0400)]
Take sepgsql regression tests out of the regular regression test mechanism.

Back-port the new "test_sepgsql" script into 9.1 to provide a substitute
test mechanism.

12 years agoFix window functions that sort by expressions involving aggregates.
Tom Lane [Tue, 27 Sep 2011 03:48:39 +0000 (23:48 -0400)]
Fix window functions that sort by expressions involving aggregates.

In commit c1d9579dd8bf3c921ca6bc2b62c40da6d25372e5, I changed things so
that the output of the Agg node that feeds the window functions would not
list any ungrouped Vars directly.  Formerly, for example, the Agg tlist
might have included both "x" and "sum(x)", which is not really valid if
"x" isn't a grouping column.  If we then had a window function ordering on
something like "sum(x) + 1", prepare_sort_from_pathkeys would find no exact
match for this in the Agg tlist, and would conclude that it must recompute
the expression.  But it would break the expression down to just the Var
"x", which it would find in the tlist, and then rebuild the ORDER BY
expression using a reference to the subplan's "x" output.  Now, after the
above-referenced changes, "x" isn't in the Agg tlist if it's not a grouping
column, so that prepare_sort_from_pathkeys fails with "could not find
pathkey item to sort", as reported by Bricklen Anderson.

The fix is to not break down Aggrefs into their component parts, but just
treat them as irreducible expressions to be sought in the subplan tlist.
This is definitely OK for the use with respect to window functions in
grouping_planner, since it just built the tlist being used on the same
basis.  AFAICT it is safe for other uses too; most of the other call sites
couldn't encounter Aggrefs anyway.

12 years agoUn-break compression of plain-text output format in pg_dump.
Tom Lane [Sun, 25 Sep 2011 17:59:17 +0000 (13:59 -0400)]
Un-break compression of plain-text output format in pg_dump.

pg_dump has historically understood -Z with no -F switch to mean that
it should emit a gzip-compressed version of its plain text output.
This got broken through a misunderstanding in the 9.1 patch that added
directory output format.  Restore the former behavior.

Per complaint from Roger Niederland and diagnosis by Adrian Klaver.

12 years agoFix typo
Magnus Hagander [Sat, 24 Sep 2011 12:34:32 +0000 (14:34 +0200)]
Fix typo

12 years agoNote that sslmode=require verifies the CA if root cert is present
Magnus Hagander [Sat, 24 Sep 2011 12:25:12 +0000 (14:25 +0200)]
Note that sslmode=require verifies the CA if root cert is present

This mode still exists for backwards compatibility, making
sslmode=require the same as sslmode=verify-ca when the file is present,
but not causing an error when it isn't.

Per bug 6189, reported by Srinivas Aji

12 years agoFix our mapping of Windows timezones for Central America.
Tom Lane [Sat, 24 Sep 2011 02:12:36 +0000 (22:12 -0400)]
Fix our mapping of Windows timezones for Central America.

We were mapping "Central America Standard Time" to "CST6CDT", which seems
entirely wrong, because according to the Olson timezone database noplace
in Central America observes daylight savings time on any regular basis ---
and certainly not according to the USA DST rules that are implied by
"CST6CDT".  (Mexico is an exception, but they can be disregarded since
they have a separate timezone name in Windows.)  So, map this zone name to
plain "CST6", which will provide a fixed UTC offset.

As written, this patch will also result in mapping "Central America
Daylight Time" to CST6.  I considered hacking things so that would still
map to CST6CDT, but it seems it would confuse win32tzlist.pl to put those
two names in separate entries.  Since there's little evidence that any
such zone name is used in the wild, much less that CST6CDT would be a good
match for it, I'm not too worried about what we do with it.

Per complaint from Pratik Chirania.

13 years agosynchronous_commit is an enum not a boolean.
Simon Riggs [Fri, 23 Sep 2011 07:34:10 +0000 (08:34 +0100)]
synchronous_commit is an enum not a boolean.

Jaime Casanova

13 years agoStamp 9.1.1. REL9_1_1
Tom Lane [Thu, 22 Sep 2011 21:57:57 +0000 (17:57 -0400)]
Stamp 9.1.1.

13 years agoUpdate release notes for 9.1.1, 9.0.5, 8.4.9, 8.3.16, 8.2.22.
Tom Lane [Thu, 22 Sep 2011 21:39:19 +0000 (17:39 -0400)]
Update release notes for 9.1.1, 9.0.5, 8.4.9, 8.3.16, 8.2.22.

Man, we fixed a lotta bugs since April.

13 years agoTranslation updates
Peter Eisentraut [Thu, 22 Sep 2011 20:24:25 +0000 (23:24 +0300)]
Translation updates

13 years agoFix another bit of unlogged-table-induced breakage.
Robert Haas [Wed, 21 Sep 2011 14:47:47 +0000 (10:47 -0400)]
Fix another bit of unlogged-table-induced breakage.

Per bug #6205, reported by Abel Abraham Camarillo Ojeda.  This isn't a
particularly elegant fix, but I'm trying to minimize the chances of
causing yet another round of breakage.

Adjust regression tests to exercise this case.

13 years agoSuppress "unused function" warning when not HAVE_LOCALE_T.
Tom Lane [Tue, 20 Sep 2011 21:47:21 +0000 (17:47 -0400)]
Suppress "unused function" warning when not HAVE_LOCALE_T.

Forgot to consider this case ...

13 years agoImprove reporting of newlocale() failures in CREATE COLLATION.
Tom Lane [Tue, 20 Sep 2011 17:23:40 +0000 (13:23 -0400)]
Improve reporting of newlocale() failures in CREATE COLLATION.

The standardized errno code for "no such locale" failures is ENOENT, which
we were just reporting at face value, viz "No such file or directory".
Per gripe from Thom Brown, this might confuse users, so add an errdetail
message to clarify what it means.  Also, report newlocale() failures as
ERRCODE_INVALID_PARAMETER_VALUE rather than using
errcode_for_file_access(), since newlocale()'s errno values aren't
necessarily tied directly to file access failures.

13 years agoAvoid unnecessary page-level SSI lock check in heap_insert().
Tom Lane [Fri, 16 Sep 2011 18:47:27 +0000 (14:47 -0400)]
Avoid unnecessary page-level SSI lock check in heap_insert().

As observed by Heikki, we need not conflict on heap page locks during an
insert; heap page locks are only aggregated tuple locks, they don't imply
locking "gaps" as index page locks do.  So we can avoid some unnecessary
conflicts, and also do the SSI check while not holding exclusive lock on
the target buffer.

Kevin Grittner, reviewed by Jeff Davis.  Back-patch to 9.1.

13 years agogistendscan() forgot to free so->giststate.
Tom Lane [Fri, 16 Sep 2011 08:27:56 +0000 (04:27 -0400)]
gistendscan() forgot to free so->giststate.

This oversight led to a massive memory leak --- upwards of 10KB per tuple
--- during creation-time verification of an exclusion constraint based on a
GIST index.  In most other scenarios it'd just be a leak of 10KB that would
be recovered at end of query, so not too significant; though perhaps the
leak would be noticeable in a situation where a GIST index was being used
in a nestloop inner indexscan.  In any case, it's a real leak of long
standing, so patch all supported branches.  Per report from Harald Fuchs.

13 years agoTeach the makefile used to build stand-alone libpq on Windows that libpq
Heikki Linnakangas [Wed, 14 Sep 2011 14:57:32 +0000 (17:57 +0300)]
Teach the makefile used to build stand-alone libpq on Windows that libpq
needs win32setlocale.c now. The cygwin and MSVC build scripts were changed
earlier, but this was neglected. This should fix bug report #6203 by Steve.

13 years agoIn the manual section on primary_conninfo, recommend using a role with
Heikki Linnakangas [Wed, 14 Sep 2011 06:30:32 +0000 (09:30 +0300)]
In the manual section on primary_conninfo, recommend using a role with
REPLICATION privileges, not SUPERUSER.

Fujii Masao

13 years agodeflist_to_tuplestore dumped core on an option with no value.
Tom Lane [Tue, 13 Sep 2011 15:36:53 +0000 (11:36 -0400)]
deflist_to_tuplestore dumped core on an option with no value.

Make it return NULL for the option_value, instead.

Per report from Frank van Vugt.  Back-patch to 8.4 where this code was
added.

13 years agoStamp 9.1.0. REL9_1_0
Tom Lane [Thu, 8 Sep 2011 21:13:27 +0000 (17:13 -0400)]
Stamp 9.1.0.

13 years agoTranslation updates for 9.1.0
Peter Eisentraut [Thu, 8 Sep 2011 20:10:40 +0000 (23:10 +0300)]
Translation updates for 9.1.0

13 years agoAdd missing format argument to ecpg_log() call
Peter Eisentraut [Thu, 8 Sep 2011 19:09:08 +0000 (22:09 +0300)]
Add missing format argument to ecpg_log() call

13 years agoOne last round of copy-editing for the 9.1 release notes.
Tom Lane [Thu, 8 Sep 2011 04:53:11 +0000 (00:53 -0400)]
One last round of copy-editing for the 9.1 release notes.

Also set the documented release date to 2011-09-12.

13 years agoFix corner case bug in numeric to_char().
Tom Lane [Wed, 7 Sep 2011 21:06:19 +0000 (17:06 -0400)]
Fix corner case bug in numeric to_char().

Trailing-zero stripping applied by the FM specifier could strip zeroes
to the left of the decimal point, for a format with no digit positions
after the decimal point (such as "FM999.").

Reported and diagnosed by Marti Raudsepp, though I didn't use his patch.

13 years agoAllow bcc32 and win32 batch files to compile libpq.
Bruce Momjian [Wed, 7 Sep 2011 19:43:52 +0000 (15:43 -0400)]
Allow bcc32 and win32 batch files to compile libpq.

Backpatch to 9.1.

By Hiroshi Saito

13 years agoIn pg_upgrade, disallow migration of 8.3 clusters using contrib/ltree
Bruce Momjian [Wed, 7 Sep 2011 18:42:36 +0000 (14:42 -0400)]
In pg_upgrade, disallow migration of 8.3 clusters using contrib/ltree
because its internal format was changed in 8.4.

Backpatch to 9.0 and 9.1.

Report by depesz, diagnosis by Tom.

13 years agoFix typo in error message.
Tom Lane [Wed, 7 Sep 2011 17:29:26 +0000 (13:29 -0400)]
Fix typo in error message.

Per Euler Taveira de Oliveira.

13 years agoFix get_name_for_var_field() to deal with RECORD Params.
Tom Lane [Wed, 7 Sep 2011 17:01:15 +0000 (13:01 -0400)]
Fix get_name_for_var_field() to deal with RECORD Params.

With 9.1's use of Params to pass down values from NestLoop join nodes
to their inner plans, it is possible for a Param to have type RECORD, in
which case the set of fields comprising the value isn't determinable by
inspection of the Param alone.  However, just as with a Var of type RECORD,
we can find out what we need to know if we can locate the expression that
the Param represents.  We already knew how to do this in get_parameter(),
but I'd overlooked the need to be able to cope in get_name_for_var_field(),
which led to EXPLAIN failing with "record type has not been registered".

To fix, refactor the search code in get_parameter() so it can be used by
both functions.

Per report from Marti Raudsepp.

13 years agoRevert documentation patch about NEW/OLD and triggers.
Bruce Momjian [Wed, 7 Sep 2011 13:24:02 +0000 (09:24 -0400)]
Revert documentation patch about NEW/OLD and triggers.

Backpatch to 9.0 and 9.1.

Patch from Josh Kupershmidt.

13 years agoProperly document the existance of OLD/NEW trigger pl/pgsql trigger
Bruce Momjian [Wed, 7 Sep 2011 02:54:18 +0000 (22:54 -0400)]
Properly document the existance of OLD/NEW trigger pl/pgsql trigger
fields.

Backpatch to 9.0 and 9.1.

Report from Pavel Stehule, patch from Josh Kupershmidt

13 years agoFix spelling mistake in pgpass documentation change.
Bruce Momjian [Tue, 6 Sep 2011 23:42:48 +0000 (19:42 -0400)]
Fix spelling mistake in pgpass documentation change.

Per Peter.

13 years agoAdd documentation suggestion about adding a comment to the top of
Bruce Momjian [Tue, 6 Sep 2011 21:32:16 +0000 (17:32 -0400)]
Add documentation suggestion about adding a comment to the top of
pgpass.

Backpatch to 9.1.

13 years agoFix plpgsql "PERFORM" markup.
Bruce Momjian [Tue, 6 Sep 2011 19:20:16 +0000 (15:20 -0400)]
Fix plpgsql "PERFORM" markup.

Backpatch to 9.0 and 9.1.

13 years agoAvoid possibly accessing off the end of memory in SJIS2004 conversion.
Tom Lane [Tue, 6 Sep 2011 18:50:28 +0000 (14:50 -0400)]
Avoid possibly accessing off the end of memory in SJIS2004 conversion.

The code in shift_jis_20042euc_jis_2004() would fetch two bytes even when
only one remained in the string.  Since conversion functions aren't
supposed to assume null-terminated input, this poses a small risk of
fetching past the end of memory and incurring SIGSEGV.  No such crash has
been identified in the field, but we've certainly seen the equivalent
happen in other code paths, so patch this one all the way back.

Report and patch by Noah Misch.

13 years agoAvoid possibly accessing off the end of memory in examine_attribute().
Tom Lane [Tue, 6 Sep 2011 18:35:27 +0000 (14:35 -0400)]
Avoid possibly accessing off the end of memory in examine_attribute().

Since the last couple of columns of pg_type are often NULL,
sizeof(FormData_pg_type) can be an overestimate of the actual size of the
tuple data part.  Therefore memcpy'ing that much out of the catalog cache,
as analyze.c was doing, poses a small risk of copying past the end of
memory and incurring SIGSEGV.  No such crash has been identified in the
field, but we've certainly seen the equivalent happen in other code paths,
so patch this one all the way back.

Per valgrind testing by Noah Misch, though this is not his proposed patch.
I chose to use SearchSysCacheCopy1 rather than inventing special-purpose
infrastructure for copying only the minimal part of a pg_type tuple.

13 years agoDocument PERFORM limitation when using WITH queries.
Bruce Momjian [Tue, 6 Sep 2011 17:41:30 +0000 (13:41 -0400)]
Document PERFORM limitation when using WITH queries.

Backpatch to 9.0 and 9.1.

Report from depstein@alliedtesting.com.

13 years agoAdd an "incompatibility" entry to 9.1 release notes about CREATE EXTENSION.
Tom Lane [Tue, 6 Sep 2011 16:36:40 +0000 (12:36 -0400)]
Add an "incompatibility" entry to 9.1 release notes about CREATE EXTENSION.

We've now seen more than one gripe from somebody who didn't get the memo
about how to install contrib modules in 9.1.  Try to make it a little more
prominent that you aren't supposed to call the scripts directly anymore.

13 years agoUpdate type-conversion documentation for long-ago changes.
Tom Lane [Tue, 6 Sep 2011 16:14:51 +0000 (12:14 -0400)]
Update type-conversion documentation for long-ago changes.

This example wasn't updated when we changed the behavior of bpcharlen()
in 8.0, nor when we changed the number of parameters taken by the bpchar()
cast function in 7.3.  Per report from lsliang.

13 years agoProperly document semphore requirements by accounting for worker
Bruce Momjian [Tue, 6 Sep 2011 15:08:34 +0000 (11:08 -0400)]
Properly document semphore requirements by accounting for worker
processes.

Backpatch to 9.1 and 9.0.

Submitted by Anton Yuzhaninov, confirmed by Robert Haas

13 years agoAdd documentation link to strftime supported options.
Bruce Momjian [Tue, 6 Sep 2011 02:58:13 +0000 (22:58 -0400)]
Add documentation link to strftime supported options.

13 years agoAdjust translator comment format to xgettext expectations
Alvaro Herrera [Mon, 5 Sep 2011 21:52:49 +0000 (18:52 -0300)]
Adjust translator comment format to xgettext expectations

13 years agoMark some untranslatable messages with errmsg_internal
Alvaro Herrera [Mon, 5 Sep 2011 20:47:18 +0000 (17:47 -0300)]
Mark some untranslatable messages with errmsg_internal

13 years agoAdd mention that UTC really means UT1.
Bruce Momjian [Mon, 5 Sep 2011 19:38:00 +0000 (15:38 -0400)]
Add mention that UTC really means UT1.

Backpatch to 9.1.

13 years agoUpdate time zone data files to tzdata release 2011i.
Tom Lane [Mon, 5 Sep 2011 18:46:31 +0000 (14:46 -0400)]
Update time zone data files to tzdata release 2011i.

DST law changes in Canada, Egypt, Russia, Samoa, South Sudan.

13 years agoDocument that contrib/pgtrgm only processes ASCII alphanumeric
Bruce Momjian [Mon, 5 Sep 2011 17:24:46 +0000 (13:24 -0400)]
Document that contrib/pgtrgm only processes ASCII alphanumeric
characters.

Backpatch to 9.0 and 9.1.

13 years agoGuard against using plperl's Makefile without specifying --with-perl.
Tom Lane [Mon, 5 Sep 2011 00:07:38 +0000 (20:07 -0400)]
Guard against using plperl's Makefile without specifying --with-perl.

The $(PERL) macro will be set by configure if it finds perl at all,
but $(perl_privlibexp) isn't configured unless you said --with-perl.
This results in confusing error messages if someone cd's into
src/pl/plperl and tries to build there despite the configure omission,
as reported by Tomas Vondra in bug #6198.  Add simple checks to
provide a more useful report, while not disabling other use of the
makefile such as "make clean".

Back-patch to 9.0, which is as far as the patch applies easily.

13 years agoFix #include problems in 9.1 branch.
Tom Lane [Sun, 4 Sep 2011 23:10:09 +0000 (19:10 -0400)]
Fix #include problems in 9.1 branch.

Remove unnecessary and circular #include of syncrep.h from proc.h.
Add htup.h to tablecmds.h so it will compile without prerequisites.

13 years agoFix typo in pg_srand48 (srand48 in older branches).
Tom Lane [Sat, 3 Sep 2011 20:17:39 +0000 (16:17 -0400)]
Fix typo in pg_srand48 (srand48 in older branches).

">" should be ">>".  This typo results in failure to use all of the bits
of the provided seed.

This might rise to the level of a security bug if we were relying on
srand48 for any security-critical purposes, but we are not --- in fact,
it's not used at all unless the platform lacks srandom(), which is
improbable.  Even on such a platform the exposure seems minimal.

Reported privately by Andres Freund.

13 years agoFix brace indentation of commit 5ad0e899f08136a00f56bf224a6b9729b2f4c69f to fit Postg...
Michael Meskes [Fri, 2 Sep 2011 07:45:11 +0000 (09:45 +0200)]
Fix brace indentation of commit 5ad0e899f08136a00f56bf224a6b9729b2f4c69f to fit PostgreSQL style.

13 years agoRemove spurious comma. Spotted by Tom.
Heikki Linnakangas [Thu, 1 Sep 2011 16:59:09 +0000 (19:59 +0300)]
Remove spurious comma. Spotted by Tom.

13 years agolibpq compiles various pgport files like ecpg does, and needs similar Makefile
Heikki Linnakangas [Thu, 1 Sep 2011 15:58:50 +0000 (18:58 +0300)]
libpq compiles various pgport files like ecpg does, and needs similar Makefile
changes for the win32 setlocale() wrapper I put into ecpg, to make it compile
on MinGW.

13 years agoIn ecpglib restore LC_NUMERIC in case of an error.
Michael Meskes [Thu, 1 Sep 2011 13:27:38 +0000 (15:27 +0200)]
In ecpglib restore LC_NUMERIC in case of an error.

13 years agoFix MinGW build, broken by my previous patch to add a setlocale() wrapper
Heikki Linnakangas [Thu, 1 Sep 2011 11:02:40 +0000 (14:02 +0300)]
Fix MinGW build, broken by my previous patch to add a setlocale() wrapper
on Windows. ecpglib doesn't link with libpgport, but picks and compiles
the .c files it needs individually. To cope with that, move the setlocale()
wrapper from chklocale.c to a separate setlocale.c file, and include that
in ecpglib.

13 years agosetlocale() on Windows doesn't work correctly if the locale name contains
Heikki Linnakangas [Thu, 1 Sep 2011 08:08:32 +0000 (11:08 +0300)]
setlocale() on Windows doesn't work correctly if the locale name contains
dots. I previously worked around this in initdb, mapping the known
problematic locale names to aliases that work, but Hiroshi Inoue pointed
out that that's not enough because even if you use one of the aliases, like
"Chinese_HKG", setlocale(LC_CTYPE, NULL) returns back the long form, ie.
"Chinese_Hong Kong S.A.R.". When we try to restore an old locale value by
passing that value back to setlocale(), it fails. Note that you are affected
by this bug also if you use one of those short-form names manually, so just
reverting the hack in initdb won't fix it.

To work around that, move the locale name mapping from initdb to a wrapper
around setlocale(), so that the mapping is invoked on every setlocale() call.

Also, add a few checks for failed setlocale() calls in the backend. These
calls shouldn't fail, and if they do there isn't much we can do about it,
but at least you'll get a warning.

Backpatch to 9.1, where the initdb hack was introduced. The Windows bug
affects older versions too if you set locale manually to one of the aliases,
but given the lack of complaints from the field, I'm hesitent to backpatch.

13 years agoMove the line to undefine setlocale() macro on Win32 outside USE_REPL_SNPRINTF
Heikki Linnakangas [Thu, 1 Sep 2011 06:13:37 +0000 (09:13 +0300)]
Move the line to undefine setlocale() macro on Win32 outside USE_REPL_SNPRINTF
ifdef block. It has nothing to do with whether the replacement snprintf
function is used. It caused no live bug, because the replacement snprintf
function is always used on Win32, but it was nevertheless misplaced.

13 years agoFurther repair of eqjoinsel ndistinct-clamping logic.
Tom Lane [Thu, 1 Sep 2011 04:18:34 +0000 (00:18 -0400)]
Further repair of eqjoinsel ndistinct-clamping logic.

Examination of examples provided by Mark Kirkwood and others has convinced
me that actually commit 7f3eba30c9d622d1981b1368f2d79ba0999cdff2 was quite
a few bricks shy of a load.  The useful part of that patch was clamping
ndistinct for the inner side of a semi or anti join, and the reason why
that's needed is that it's the only way that restriction clauses
eliminating rows from the inner relation can affect the estimated size of
the join result.  I had not clearly understood why the clamping was
appropriate, and so mis-extrapolated to conclude that we should clamp
ndistinct for the outer side too, as well as for both sides of regular
joins.  These latter actions were all wrong, and are reverted with this
patch.  In addition, the clamping logic is now made to affect the behavior
of both paths in eqjoinsel_semi, with or without MCV lists to compare.
When we have MCVs, we suppose that the most common values are the ones
that are most likely to survive the decimation resulting from a lower
restriction clause, so we think of the clamping as eliminating non-MCV
values, or potentially even the least-common MCVs for the inner relation.

Back-patch to 8.4, same as previous fixes in this area.

13 years agoFix pg_upgrade to preserve toast relfrozenxids for old 8.3 servers.
Bruce Momjian [Thu, 1 Sep 2011 01:49:59 +0000 (21:49 -0400)]
Fix pg_upgrade to preserve toast relfrozenxids for old 8.3 servers.

This fixes a pg_upgrade bug that could lead to query errors when
clog files are improperly removed.

Backpatch to 8.4, 9.0, 9.1.

13 years agoImprove eqjoinsel's ndistinct clamping to work for multiple levels of join.
Tom Lane [Wed, 31 Aug 2011 20:04:53 +0000 (16:04 -0400)]
Improve eqjoinsel's ndistinct clamping to work for multiple levels of join.

This patch fixes an oversight in my commit
7f3eba30c9d622d1981b1368f2d79ba0999cdff2 of 2008-10-23.  That patch
accounted for baserel restriction clauses that reduced the number of rows
coming out of a table (and hence the number of possibly-distinct values of
a join variable), but not for join restriction clauses that might have been
applied at a lower level of join.  To account for the latter, look up the
sizes of the min_lefthand and min_righthand inputs of the current join,
and clamp with those in the same way as for the base relations.

Noted while investigating a complaint from Ben Chobot, although this in
itself doesn't seem to explain his report.

Back-patch to 8.4; previous versions used different estimation methods
for which this heuristic isn't relevant.

13 years agoThe replication status values in pg_stat_replication was changed to
Heikki Linnakangas [Wed, 31 Aug 2011 09:37:37 +0000 (12:37 +0300)]
The replication status values in pg_stat_replication was changed to
lowercase earlier, but documentation was not updated. Update the docs.

Fujii Masao

13 years agoFix not-backwards-compatible pg_upgrade test for prepared transactions.
Tom Lane [Tue, 30 Aug 2011 21:15:00 +0000 (17:15 -0400)]
Fix not-backwards-compatible pg_upgrade test for prepared transactions.

There's no reason for this test to use the undocumented pg_prepared_xact()
function, when it can use the stable API pg_prepared_xacts instead.
Fixes breakage against 8.3, as reported by Justin Arnold.

13 years agoFix a missed case in code for "moving average" estimate of reltuples.
Tom Lane [Tue, 30 Aug 2011 18:49:52 +0000 (14:49 -0400)]
Fix a missed case in code for "moving average" estimate of reltuples.

It is possible for VACUUM to scan no pages at all, if the visibility map
shows that all pages are all-visible.  In this situation VACUUM has no new
information to report about the relation's tuple density, so it wasn't
changing pg_class.reltuples ... but it updated pg_class.relpages anyway.
That's wrong in general, since there is no evidence to justify changing the
density ratio reltuples/relpages, but it's particularly bad if the previous
state was relpages=reltuples=0, which means "unknown tuple density".
We just replaced "unknown" with "zero".  ANALYZE would eventually recover
from this, but it could take a lot of repetitions of ANALYZE to do so if
the relation size is much larger than the maximum number of pages ANALYZE
will scan, because of the moving-average behavior introduced by commit
b4b6923e03f4d29636a94f6f4cc2f5cf6298b8c8.

The only known situation where we could have relpages=reltuples=0 and yet
the visibility map asserts everything's visible is immediately following
a pg_upgrade.  It might be advisable for pg_upgrade to try to preserve the
relpages/reltuples statistics; but in any case this code is wrong on its
own terms, so fix it.  Per report from Sergey Koposov.

Back-patch to 8.4, where the visibility map was introduced, same as the
previous change.

13 years agoFix concat_ws() to not insert a separator after leading NULL argument(s).
Tom Lane [Mon, 29 Aug 2011 19:20:57 +0000 (15:20 -0400)]
Fix concat_ws() to not insert a separator after leading NULL argument(s).

Per bug #6181 from Itagaki Takahiro.  Also do some marginal code cleanup
and improve error handling.

13 years agoActually, all of parallel restore's limitations should be tested earlier.
Tom Lane [Mon, 29 Aug 2011 02:27:48 +0000 (22:27 -0400)]
Actually, all of parallel restore's limitations should be tested earlier.

On closer inspection, whining in restore_toc_entries_parallel is really
much too late for any user-facing error case.  The right place to do it
is at the start of RestoreArchive(), before we've done anything interesting
(suh as trying to DROP all the targets ...)

Back-patch to 8.4, where parallel restore was introduced.

13 years agoBe more user-friendly about unsupported cases for parallel pg_restore.
Tom Lane [Mon, 29 Aug 2011 01:48:58 +0000 (21:48 -0400)]
Be more user-friendly about unsupported cases for parallel pg_restore.

If we are unable to do a parallel restore because the input file is stdin
or is otherwise unseekable, we should complain and fail immediately, not
after having done some of the restore.  Complaining once per thread isn't
so cool either, and the messages should be worded to make it clear this is
an unsupported case not some weird race-condition bug.  Per complaint from
Lonni Friedman.

Back-patch to 8.4, where parallel restore was introduced.

13 years agoDon't assume that "E" response to NEGOTIATE_SSL_CODE means pre-7.0 server.
Tom Lane [Sat, 27 Aug 2011 20:37:02 +0000 (16:37 -0400)]
Don't assume that "E" response to NEGOTIATE_SSL_CODE means pre-7.0 server.

These days, such a response is far more likely to signify a server-side
problem, such as fork failure.  Reporting "server does not support SSL"
(in sslmode=require) could be quite misleading.  But the results could
be even worse in sslmode=prefer: if the problem was transient and the
next connection attempt succeeds, we'll have silently fallen back to
protocol version 2.0, possibly disabling features the user needs.

Hence, it seems best to just eliminate the assumption that backing off
to non-SSL/2.0 protocol is the way to recover from an "E" response, and
instead treat the server error the same as we would in non-SSL cases.

I tested this change against a pre-7.0 server, and found that there
was a second logic bug in the "prefer" path: the test to decide whether
to make a fallback connection attempt assumed that we must have opened
conn->ssl, which in fact does not happen given an "E" response.  After
fixing that, the code does indeed connect successfully to pre-7.0,
as long as you didn't set sslmode=require.  (If you did, you get
"Unsupported frontend protocol", which isn't completely off base
given the server certainly doesn't support SSL.)

Since there seems no reason to believe that pre-7.0 servers exist anymore
in the wild, back-patch to all supported branches.

13 years agoEnsure we discard unread/unsent data when abandoning a connection attempt.
Tom Lane [Sat, 27 Aug 2011 18:16:19 +0000 (14:16 -0400)]
Ensure we discard unread/unsent data when abandoning a connection attempt.

There are assorted situations wherein PQconnectPoll() will abandon a
connection attempt and try again with different parameters (eg, SSL versus
not SSL).  However, the code forgot to discard any pending data in libpq's
I/O buffers when doing this.  In at least one case (server returns E
message during SSL negotiation), there is unread input data which bollixes
the next connection attempt.  I have not checked to see whether this is
possible in the other cases where we close the socket and retry, but it
seems like a matter of good defensive programming to add explicit
buffer-flushing code to all of them.

This is one of several issues exposed by Daniel Farina's report of
misbehavior after a server-side fork failure.

This has been wrong since forever, so back-patch to all supported branches.

13 years agoSpelling improvement
Peter Eisentraut [Sat, 27 Aug 2011 05:07:58 +0000 (08:07 +0300)]
Spelling improvement

13 years agoFix potential memory clobber in tsvector_concat().
Tom Lane [Fri, 26 Aug 2011 20:51:39 +0000 (16:51 -0400)]
Fix potential memory clobber in tsvector_concat().

tsvector_concat() allocated its result workspace using the "conservative"
estimate of the sum of the two input tsvectors' sizes.  Unfortunately that
wasn't so conservative as all that, because it supposed that the number of
pad bytes required could not grow.  Which it can, as per test case from
Jesper Krogh, if there's a mix of lexemes with positions and lexemes
without them in the input data.  The fix is to assume that we might add
a not-previously-present pad byte for each and every lexeme in the two
inputs; which really is conservative, but it doesn't seem worthwhile to
try to be more precise.

This is an aboriginal bug in tsvector_concat, so back-patch to all
versions containing it.

13 years agoIn pg_upgrade, limit schema name filter to include toast tables. Bug
Bruce Momjian [Fri, 26 Aug 2011 04:12:34 +0000 (00:12 -0400)]
In pg_upgrade, limit schema name filter to include toast tables.  Bug
introduced recently when trying to filter out temp tables.

Backpatch to 9.0 and 9.1.

13 years agoAdd expected isolationtester output when prepared xacts are disabled
Alvaro Herrera [Thu, 25 Aug 2011 20:35:57 +0000 (17:35 -0300)]
Add expected isolationtester output when prepared xacts are disabled

This was deemed unnecessary initially but in later discussion it was
agreed otherwise.

Original file from Kevin Grittner, allegedly from Dan Ports.
I had to clean up whitespace a bit per changes from Heikki.

13 years agoFix psql lexer to avoid use of backtracking.
Tom Lane [Thu, 25 Aug 2011 18:33:08 +0000 (14:33 -0400)]
Fix psql lexer to avoid use of backtracking.

Per previous experimentation, backtracking slows down lexing performance
significantly (by about a third).  It's usually pretty easy to avoid, just
need to have rules that accept an incomplete construct and do whatever the
lexer would have done otherwise.

The backtracking was introduced by the patch that added quoted variable
substitution.  Back-patch to 9.0 where that was added.

13 years agoProperly quote SQL/MED generic options in pg_dump output.
Robert Haas [Thu, 25 Aug 2011 16:37:32 +0000 (12:37 -0400)]
Properly quote SQL/MED generic options in pg_dump output.

Shigeru Hanada

13 years agoRevert "Tweak postgresql.conf.sample's comments on listen_addresess."
Robert Haas [Thu, 25 Aug 2011 13:41:00 +0000 (09:41 -0400)]
Revert "Tweak postgresql.conf.sample's comments on listen_addresess."

This reverts commit 1bde67c0b9adce8b7ed2a2d1fcb2788cf96cea64, which
should have been done only on the master branch.

13 years agoTweak postgresql.conf.sample's comments on listen_addresess.
Robert Haas [Thu, 25 Aug 2011 13:39:35 +0000 (09:39 -0400)]
Tweak postgresql.conf.sample's comments on listen_addresess.

This makes it slightly more clear that '*' is not part of the default
value, in case that wasn't obvious.

As requested by Dougal Sutherland.

13 years agoAdjust CREATE DOMAIN example for standard_conforming_strings=on.
Robert Haas [Thu, 25 Aug 2011 13:35:38 +0000 (09:35 -0400)]
Adjust CREATE DOMAIN example for standard_conforming_strings=on.

Noted by Hitoshi Harada.

13 years agoFix pgstatindex() to give consistent results for empty indexes.
Tom Lane [Thu, 25 Aug 2011 03:50:15 +0000 (23:50 -0400)]
Fix pgstatindex() to give consistent results for empty indexes.

For an empty index, the pgstatindex() function would compute 0.0/0.0 for
its avg_leaf_density and leaf_fragmentation outputs.  On machines that
follow the IEEE float arithmetic standard with any care, that results in
a NaN.  However, per report from Rushabh Lathia, Microsoft couldn't
manage to get this right, so you'd get a bizarre error on Windows.

Fix by forcing the results to be NaN explicitly, rather than relying on
the division operator to give that or the snprintf function to print it
correctly.  I have some doubts that this is really the most useful
definition, but it seems better to remain backward-compatible with
those platforms for which the behavior wasn't completely broken.

Back-patch to 8.2, since the code is like that in all current releases.

13 years agoFix pgxs.mk to always add --dbname=$(CONTRIB_TESTDB) to REGRESS_OPTS.
Tom Lane [Wed, 24 Aug 2011 19:16:23 +0000 (15:16 -0400)]
Fix pgxs.mk to always add  --dbname=$(CONTRIB_TESTDB) to REGRESS_OPTS.

The previous coding resulted in contrib modules unintentionally overriding
the use of CONTRIB_TESTDB.  There seems no particularly good reason to
allow that (after all, the makefile can set CONTRIB_TESTDB if that's really
what it intends).

In passing, document REGRESS_OPTS where the other pgxs.mk options are
documented.

Back-patch to 9.1 --- in prior versions, there were no cases of contrib
modules setting REGRESS_OPTS without including the --dbname switch, so
while the coding was fragile there was no actual bug.

13 years agoBuild src/ before contrib/ in make world
Peter Eisentraut [Wed, 24 Aug 2011 18:34:49 +0000 (21:34 +0300)]
Build src/ before contrib/ in make world

This fixes failures under parallel make when contrib modules use a
generated backend header file (such as errcodes.h).

13 years agoAvoid locale dependency in expected output.
Tom Lane [Wed, 24 Aug 2011 17:47:01 +0000 (13:47 -0400)]
Avoid locale dependency in expected output.

We'll have to settle for just listing the extensions' data types,
since function arguments seem to sort differently in different locales.
Per buildfarm results.

13 years agoFix multiple bugs in extension dropping.
Tom Lane [Wed, 24 Aug 2011 17:09:06 +0000 (13:09 -0400)]
Fix multiple bugs in extension dropping.

When we implemented extensions, we made findDependentObjects() treat
EXTENSION dependency links similarly to INTERNAL links.  However, that
logic contained an implicit assumption that an object could have at most
one INTERNAL dependency, so it did not work correctly for objects having
both INTERNAL and DEPENDENCY links.  This led to failure to drop some
extension member objects when dropping the extension.  Furthermore, we'd
never actually exercised the case of recursing to an internally-referenced
(owning) object from anything other than a NORMAL dependency, and it turns
out that passing the incoming dependency's flags to the owning object is
the Wrong Thing.  This led to sometimes dropping a whole extension silently
when we should have rejected the drop command for lack of CASCADE.

Since we obviously were under-testing extension drop scenarios, add some
regression test cases.  Unfortunately, such test cases require some
extensions (duh), so we can't test for problems in the core regression
tests.  I chose to add them to the earthdistance contrib module, which is
a good test case because it has a dependency on the cube contrib module.

Back-patch to 9.1.  Arguably these are pre-existing bugs in INTERNAL
dependency handling, but since it appears that the cases can never arise
pre-9.1, I'll refrain from back-patching the logic changes further than
that.

13 years agoMake CREATE EXTENSION check schema creation permissions.
Tom Lane [Wed, 24 Aug 2011 01:49:07 +0000 (21:49 -0400)]
Make CREATE EXTENSION check schema creation permissions.

When creating a new schema for a non-relocatable extension, we neglected
to check whether the calling user has permission to create schemas.
That didn't matter in the original coding, since we had already checked
superuserness, but in the new dispensation where users need not be
superusers, we should check it.  Use CreateSchemaCommand() rather than
calling NamespaceCreate() directly, so that we also enforce the rules
about reserved schema names.

Per complaint from KaiGai Kohei, though this isn't the same as his patch.

13 years agoFix overoptimistic assumptions in column width estimation for subqueries.
Tom Lane [Tue, 23 Aug 2011 21:11:41 +0000 (17:11 -0400)]
Fix overoptimistic assumptions in column width estimation for subqueries.

set_append_rel_pathlist supposed that, while computing per-column width
estimates for the appendrel, it could ignore child rels for which the
translated reltargetlist entry wasn't a Var.  This gave rise to completely
silly estimates in some common cases, such as constant outputs from some or
all of the arms of a UNION ALL.  Instead, fall back on get_typavgwidth to
estimate from the value's datatype; which might be a poor estimate but at
least it's not completely wacko.

That problem was exposed by an Assert in set_subquery_size_estimates, which
unfortunately was still overoptimistic even with that fix, since we don't
compute attr_widths estimates for appendrels that are entirely excluded by
constraints.  So remove the Assert; we'll just fall back on get_typavgwidth
in such cases.

Also, since set_subquery_size_estimates calls set_baserel_size_estimates
which calls set_rel_width, there's no need for set_subquery_size_estimates
to call get_typavgwidth; set_rel_width will handle it for us if we just
leave the estimate set to zero.  Remove the unnecessary code.

Per report from Erik Rijkers and subsequent investigation.

13 years agoAdd recovery.conf to the index in the user manual.
Heikki Linnakangas [Tue, 23 Aug 2011 08:55:21 +0000 (11:55 +0300)]
Add recovery.conf to the index in the user manual.

Fujii Masao

13 years agoFix handling of extension membership when filling in a shell operator.
Tom Lane [Mon, 22 Aug 2011 14:55:47 +0000 (10:55 -0400)]
Fix handling of extension membership when filling in a shell operator.

The previous coding would result in deleting and not re-creating the
extension membership pg_depend rows, since there was no
CommandCounterIncrement that would allow recordDependencyOnCurrentExtension
to see that the deletion had happened.  Make it work like the shell type
case, ie, keep the existing entries (and then throw an error if they're for
the wrong extension).

Per bug #6172 from Hitoshi Harada.  Investigation and fix by Dimitri
Fontaine.

13 years agoFix trigger WHEN conditions when both BEFORE and AFTER triggers exist.
Tom Lane [Sun, 21 Aug 2011 22:16:02 +0000 (18:16 -0400)]
Fix trigger WHEN conditions when both BEFORE and AFTER triggers exist.

Due to tuple-slot mismanagement, evaluation of WHEN conditions for AFTER
ROW UPDATE triggers could crash if there had been a BEFORE ROW trigger
fired for the same update.  Fix by not trying to overload the use of
estate->es_trig_tuple_slot.  Per report from Yoran Heling.

Back-patch to 9.0, when trigger WHEN conditions were introduced.

13 years agoFix performance problem when building a lossy tidbitmap.
Tom Lane [Sat, 20 Aug 2011 18:51:02 +0000 (14:51 -0400)]
Fix performance problem when building a lossy tidbitmap.

As pointed out by Sergey Koposov, repeated invocations of tbm_lossify can
make building a large tidbitmap into an O(N^2) operation.  To fix, make
sure we remove more than the minimum amount of information per call, and
add a fallback path to behave sanely if we're unable to fit the bitmap
within the requested amount of memory.

This has been wrong since the tidbitmap code was written, so back-patch
to all supported branches.

13 years agoFix contrib/sepgsql and contrib/xml2 to always link required libraries.
Robert Haas [Fri, 19 Aug 2011 15:57:38 +0000 (11:57 -0400)]
Fix contrib/sepgsql and contrib/xml2 to always link required libraries.

contrib/xml2 can get by without libxslt; the relevant features just
won't work.  But if doesn't have libxml2, or if sepgsql doesn't have
libselinux, the link succeeds but the module then fails to work at load
time.  To avoid that, link the require libraries unconditionally, so
that it will be clear at link-time that there is a problem.

Per discussion with Tom Lane and KaiGai Kohei.

13 years agoAllow sepgsql regression tests to be run from a user homedir.
Robert Haas [Fri, 19 Aug 2011 15:51:10 +0000 (11:51 -0400)]
Allow sepgsql regression tests to be run from a user homedir.

KaiGai Kohei, with some changes by me.

13 years agoTag 9.1rc1. REL9_1_RC1
Tom Lane [Thu, 18 Aug 2011 21:23:13 +0000 (17:23 -0400)]
Tag 9.1rc1.

13 years agoExplain max_prepared_transactions requirement in isolation tests' README.
Tom Lane [Thu, 18 Aug 2011 15:45:33 +0000 (11:45 -0400)]
Explain max_prepared_transactions requirement in isolation tests' README.

Now that we have a test that requires nondefault settings to pass, it seems
like we'd better mention that detail in the directions about how to run the
tests.

Also do some very minor copy-editing.

13 years agoReport libpq errors correctly if session setup or teardown steps fail in
Heikki Linnakangas [Thu, 18 Aug 2011 13:47:31 +0000 (16:47 +0300)]
Report libpq errors correctly if session setup or teardown steps fail in
isolation regression tests.

Alvaro committed these fixes to master branch on Tue Jul 29th, as part of
Noah Misch's patch. The rest of that patch is not needed on 9.1, but this
part should be backpatched.

13 years agoAdd an SSI regression test that tests all interesting permutations in the
Heikki Linnakangas [Thu, 18 Aug 2011 10:36:37 +0000 (13:36 +0300)]
Add an SSI regression test that tests all interesting permutations in the
order of begin, prepare, and commit of three concurrent transactions that
have conflicts between them.

The test runs for a quite long time, and the expected output file is huge,
but this test caught some serious bugs during development, so seems
worthwhile to keep. The test uses prepared transactions, so it fails if the
server has max_prepared_transactions=0. Because of that, it's marked as
"ignore" in the schedule file.

Dan Ports

13 years agoStrip whitespace from SQL blocks in the isolation test suite. This is purely
Heikki Linnakangas [Thu, 18 Aug 2011 09:16:10 +0000 (12:16 +0300)]
Strip whitespace from SQL blocks in the isolation test suite. This is purely
cosmetic, it removes a lot of IMHO ugly whitespace from the expected output.

13 years agoImprove detection of Python 3.2 installations
Peter Eisentraut [Thu, 18 Aug 2011 11:43:16 +0000 (14:43 +0300)]
Improve detection of Python 3.2 installations

Because of ABI tagging, the library version number might no longer be
exactly the Python version number, so do extra lookups.  This affects
installations without a shared library, such as ActiveState's
installer.

Also update the way to detect the location of the 'config' directory,
which can also be versioned.

Ashesh Vashi

13 years agoChange PyInit_plpy to external linkage
Peter Eisentraut [Thu, 18 Aug 2011 09:53:32 +0000 (12:53 +0300)]
Change PyInit_plpy to external linkage

Module initialization functions in Python 3 must have external
linkage, because PyMODINIT_FUNC does dllexport on Windows-like
platforms.  Without this change, the build with Python 3 fails on
Windows.

13 years agoUpdate 9.1 release notes to reflect commits through today.
Tom Lane [Thu, 18 Aug 2011 00:18:23 +0000 (20:18 -0400)]
Update 9.1 release notes to reflect commits through today.

Also do another pass of copy-editing.

13 years agoFix two issues in plpython's handling of composite results.
Tom Lane [Wed, 17 Aug 2011 21:07:25 +0000 (17:07 -0400)]
Fix two issues in plpython's handling of composite results.

Dropped columns within a composite type were not handled correctly.
Also, we did not check for whether a composite result type had changed
since we cached the information about it.

Jan UrbaƄski, per a bug report from Jean-Baptiste Quenot

13 years agoProperly handle empty arrays returned from plperl functions.
Andrew Dunstan [Wed, 17 Aug 2011 16:03:26 +0000 (12:03 -0400)]
Properly handle empty arrays returned from plperl functions.

Bug reported by David Wheeler, fix by Alex Hunsaker.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
# modified:   src/pl/plperl/plperl.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# autom4te.cache/
# configure.in~
# doc/src/sgml/ref/grant.sgml~
# src/backend/port/win32_latch.c~
# src/bin/psql/command.c~
# src/include/pg_config.h.win32~
# src/pl/plpython/plpython.c~
# src/tools/msvc/pgbison.bat~
# src/tools/msvc/pgbison.pl.bak
# src/tools/msvc/pgflex.bat~
# src/tools/msvc/pgflex.pl.bak
# src/tools/pgindent/README~
# src/tools/pgindent/pgindent.pl
# src/tools/pgindent/pgindent.pl~
# xxxxx
# yyyyyy