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

12 years agoAdd missing space.
Robert Haas [Sat, 8 Oct 2011 03:48:38 +0000 (23:48 -0400)]
Add missing space.

Dickson S. Guedes

12 years agoEnsure walsenders can be SIGTERMed while in non-walsender code
Magnus Hagander [Thu, 6 Oct 2011 19:43:14 +0000 (21:43 +0200)]
Ensure walsenders can be SIGTERMed while in non-walsender code

In oder to exit on SIGTERM when in non-walsender code,
such as do_pg_stop_backup(), we need to set the interrupt
variables that are used there, and not just the walsender
local ones.

12 years agoMake pgstatindex respond to cancel interrupts.
Robert Haas [Thu, 6 Oct 2011 16:08:59 +0000 (12:08 -0400)]
Make pgstatindex respond to cancel interrupts.

A similar problem for pgstattuple() was fixed in April of 2010 by commit
33065ef8bc52253ae855bc959576e52d8a28ba06, but pgstatindex() seems to have
been overlooked.

Back-patch all the way, as with that commit, though not to 7.4 through
8.1, since those are now EOL.

12 years agoImprove and simplify CREATE EXTENSION's management of GUC variables.
Tom Lane [Thu, 6 Oct 2011 00:44:22 +0000 (20:44 -0400)]
Improve and simplify CREATE EXTENSION's management of GUC variables.

CREATE EXTENSION needs to transiently set search_path, as well as
client_min_messages and log_min_messages.  We were doing this by the
expedient of saving the current string value of each variable, doing a
SET LOCAL, and then doing another SET LOCAL with the previous value at
the end of the command.  This is a bit expensive though, and it also fails
badly if there is anything funny about the existing search_path value,
as seen in a recent report from Roger Niederland.  Fortunately, there's a
much better way, which is to piggyback on the GUC infrastructure previously
developed for functions with SET options.  We just open a new GUC nesting
level, do our assignments with GUC_ACTION_SAVE, and then close the nesting
level when done.  This automatically restores the prior settings without a
re-parsing pass, so (in principle anyway) there can't be an error.  And
guc.c still takes care of cleanup in event of an error abort.

The CREATE EXTENSION code for this was modeled on some much older code in
ri_triggers.c, which I also changed to use the better method, even though
there wasn't really much risk of failure there.  Also improve the comments
in guc.c to reflect this additional usage.

12 years agoAdd sourcefile/sourceline data to EXEC_BACKEND GUC transmission files.
Tom Lane [Tue, 4 Oct 2011 21:00:17 +0000 (17:00 -0400)]
Add sourcefile/sourceline data to EXEC_BACKEND GUC transmission files.

This oversight meant that on Windows, the pg_settings view would not
display source file or line number information for values coming from
postgresql.conf, unless the backend had received a SIGHUP since starting.

In passing, also make the error detection in read_nondefault_variables a
tad more thorough, and fix it to not lose precision on float GUCs (these
changes are already in HEAD as of my previous commit).

12 years agoProcedureCreate neglected to record dependencies on default expressions.
Tom Lane [Mon, 3 Oct 2011 16:13:15 +0000 (12:13 -0400)]
ProcedureCreate neglected to record dependencies on default expressions.

Thus, an object referenced in a default expression could be dropped while
the function remained present.  This was unaccountably missed in the
original patch to add default parameters for functions.  Reported by
Pavel Stehule.

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.