]> granicus.if.org Git - postgresql/log
postgresql
12 years agoFix archive_command example
Peter Eisentraut [Fri, 4 Nov 2011 20:01:35 +0000 (22:01 +0200)]
Fix archive_command example

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

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

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

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

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

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

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

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

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

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

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

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

Bug report by Chris Redekop

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

Bug report by Chris Redekop

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Kevin Grittner

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

Report by Vik Reykja, patch by Kevin Grittner.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Report and diagnosis by KaiGai Kohei.

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

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

Also improve the comments about this in GetOldestXmin itself.

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

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

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

Fujii Masao

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

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

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

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

Noted by Fujii Masao

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

Noted by Jeff Davis.

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

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

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

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

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

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

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

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

Alex Hunsaker and Tom Lane

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

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

dummy_label -> dummy_seclabel

Thom Brown

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

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

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

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

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

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

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

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

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

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

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

Backpatch to 9.0.X and 9.1.X.

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

Backpatch to 9.1.

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

Per suggestions from Achilleas Mantzios and Greg Smith.

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

Shigehiro Honda

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

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

Noted by Fujii Masao.

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

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

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.