]> granicus.if.org Git - postgresql/log
postgresql
13 years agoAdjust regression tests for error message change
Peter Eisentraut [Mon, 15 Aug 2011 14:27:10 +0000 (17:27 +0300)]
Adjust regression tests for error message change

13 years agoAdd "Reason code" prefix to internal SSI error messages
Peter Eisentraut [Mon, 15 Aug 2011 12:20:16 +0000 (15:20 +0300)]
Add "Reason code" prefix to internal SSI error messages

This makes it clearer that the error message is perhaps not supposed
to be understood by users, and it also makes it somewhat clearer that
it was not accidentally omitted from translation.

Idea from Heikki Linnakangas, except that we don't mark "Reason code"
for translation at this point, because that would make the
implementation too cumbersome.

13 years agoFix unsafe order of operations in foreign-table DDL commands.
Tom Lane [Sun, 14 Aug 2011 19:40:21 +0000 (15:40 -0400)]
Fix unsafe order of operations in foreign-table DDL commands.

When updating or deleting a system catalog tuple, it's necessary to acquire
RowExclusiveLock on the catalog before looking up the tuple; otherwise a
concurrent VACUUM FULL on the catalog might move the tuple to a different
TID before we can apply the update.  Coding patterns that find the tuple
via a table scan aren't at risk here, but when obtaining the tuple from a
catalog cache, correct ordering is important; and several routines in
foreigncmds.c got it wrong.  Noted while running the regression tests in
parallel with VACUUM FULL of assorted system catalogs.

For consistency I moved all the heap_open calls to the starts of their
functions, including a couple for which there was no actual bug.

Back-patch to 8.4 where foreigncmds.c was added.

13 years agoMessage style improvements
Peter Eisentraut [Sun, 14 Aug 2011 18:03:08 +0000 (21:03 +0300)]
Message style improvements

13 years agoFix typo
Peter Eisentraut [Sun, 14 Aug 2011 07:40:50 +0000 (10:40 +0300)]
Fix typo

13 years agoFix incorrect timeout handling during initial authentication transaction.
Tom Lane [Sat, 13 Aug 2011 21:52:24 +0000 (17:52 -0400)]
Fix incorrect timeout handling during initial authentication transaction.

The statement start timestamp was not set before initiating the transaction
that is used to look up client authentication information in pg_authid.
In consequence, enable_sig_alarm computed a wrong value (far in the past)
for statement_fin_time.  That didn't have any immediate effect, because the
timeout alarm was set without reference to statement_fin_time; but if we
subsequently blocked on a lock for a short time, CheckStatementTimeout
would consult the bogus value when we cancelled the lock timeout wait,
and then conclude we'd timed out, leading to immediate failure of the
connection attempt.  Thus an innocent "vacuum full pg_authid" would cause
failures of concurrent connection attempts.  Noted while testing other,
more serious consequences of vacuum full on system catalogs.

We should set the statement timestamp before StartTransactionCommand(),
so that the transaction start timestamp is also valid.  I'm not sure if
there are any non-cosmetic effects of it not being valid, but the xact
timestamp is at least sent to the statistics machinery.

Back-patch to 9.0.  Before that, the client authentication timeout was done
outside any transaction and did not depend on this state to be valid.

13 years agoMake USECS_PER_* timestamp macros visible even when we are not using
Bruce Momjian [Sat, 13 Aug 2011 01:32:19 +0000 (21:32 -0400)]
Make USECS_PER_* timestamp macros visible even when we are not using
integer timestamps.

13 years agoAdd major features list and introductory text for 9.1 release notes.
Bruce Momjian [Thu, 11 Aug 2011 20:36:56 +0000 (16:36 -0400)]
Add major features list and introductory text for 9.1 release notes.

Backpatch to 9.1, obviously.

13 years agoTeach unix_latch.c to use poll() where available.
Tom Lane [Thu, 11 Aug 2011 16:49:45 +0000 (12:49 -0400)]
Teach unix_latch.c to use poll() where available.

poll() is preferred over select() on platforms where both are available,
because it tends to be a bit faster and it doesn't have an arbitrary limit
on the range of FD numbers that can be accessed.  The FD range limit does
not appear to be a risk factor for any 9.1 usages, so this doesn't need to
be back-patched, but we need to have it in place if we keep on expanding
the uses of WaitLatch.

13 years agoDisplay both per-table and per-column FDW options in psql's \d output.
Robert Haas [Thu, 11 Aug 2011 15:45:47 +0000 (11:45 -0400)]
Display both per-table and per-column FDW options in psql's \d output.

Along the way, rename "Options" to "FDW Options" in various places for
consistency and clarity.

Shigeru Hanada

13 years agoUnbreak legacy syntax "COMMENT ON RULE x IS y", with no relation name.
Robert Haas [Thu, 11 Aug 2011 15:23:51 +0000 (11:23 -0400)]
Unbreak legacy syntax "COMMENT ON RULE x IS y", with no relation name.

check_object_ownership() isn't happy about the null relation pointer.
We could fix it there, but this seems more future-proof.

13 years agoChange psql's \dd command to do something more useful.
Robert Haas [Thu, 11 Aug 2011 15:16:29 +0000 (11:16 -0400)]
Change psql's \dd command to do something more useful.

Instead of displaying comments on an arbitrary subset of the object
types which support them, make \dd display comments on exactly those
object types which don't have their own backlash commands.  We now
regard the display of comments as properly the job of the relevant
backslash command (though many of them do so only in verbose mode)
rather than something that \dd should be responsible for.  However,
a handful of object types have no backlash command, so make \dd
give information about those.

Josh Kupershmidt

13 years agoRemove wal_sender_delay GUC, because it's no longer useful.
Tom Lane [Wed, 10 Aug 2011 22:50:28 +0000 (18:50 -0400)]
Remove wal_sender_delay GUC, because it's no longer useful.

The latch infrastructure is now capable of detecting all cases where the
walsender loop needs to wake up, so there is no reason to have an arbitrary
timeout.

Also, modify the walsender loop logic to follow the standard pattern of
ResetLatch, test for work to do, WaitLatch.  The previous coding was both
hard to follow and buggy: it would sometimes busy-loop despite having
nothing available to do, eg between receipt of a signal and the next time
it was caught up with new WAL, and it also had interesting choices like
deciding to update to WALSNDSTATE_STREAMING on the strength of information
known to be obsolete.

13 years agoAdd a bit of debug logging to backend_read_statsfile().
Tom Lane [Wed, 10 Aug 2011 20:45:43 +0000 (16:45 -0400)]
Add a bit of debug logging to backend_read_statsfile().

This is in hopes of learning more about what causes "pgstat wait timeout"
warnings in the buildfarm.  This patch should probably be reverted once
we've learned what we can.  As coded, it will result in regression test
"failures" at half the delay that the existing code does, so I expect
to see a few more than before.

13 years agoChange the autovacuum launcher to use WaitLatch instead of a poll loop.
Tom Lane [Wed, 10 Aug 2011 16:20:30 +0000 (12:20 -0400)]
Change the autovacuum launcher to use WaitLatch instead of a poll loop.

In pursuit of this (and with the expectation that WaitLatch will be needed
in more places), convert the latch field that was already added to PGPROC
for sync rep into a generic latch that is activated for all PGPROC-owning
processes, and change many of the standard backend signal handlers to set
that latch when a signal happens.  This will allow WaitLatch callers to be
wakened properly by these signals.

In passing, fix a whole bunch of signal handlers that had been hacked to do
things that might change errno, without adding the necessary save/restore
logic for errno.  Also make some minor fixes in unix_latch.c, and clean
up bizarre and unsafe scheme for disowning the process's latch.  Much of
this has to be back-patched into 9.1.

Peter Geoghegan, with additional work by Tom

13 years agoOops, we're working on version 9.2 already, not 9.1. Update the
Heikki Linnakangas [Wed, 10 Aug 2011 06:28:26 +0000 (09:28 +0300)]
Oops, we're working on version 9.2 already, not 9.1. Update the
PG_CONTROL_VERSION accordingly; I updated it wrong in previous commit.

13 years agoIf backup-end record is not seen, and we reach end of recovery from a
Heikki Linnakangas [Wed, 10 Aug 2011 06:16:29 +0000 (09:16 +0300)]
If backup-end record is not seen, and we reach end of recovery from a
streamed backup, throw an error and refuse to start up. The restore has not
finished correctly in that case and the data directory is possibly corrupt.
We already errored out in case of archive recovery, but could not during
crash recovery because we couldn't distinguish between the case that
pg_start_backup() was called and the database then crashed (must not error,
data is OK), and the case that we're restoring from a backup and not all
the needed WAL was replayed (data can be corrupt).

To distinguish those cases, add a line to backup_label to indicate
whether the backup was taken with pg_start/stop_backup(), or by streaming
(ie. pg_basebackup).

This requires re-initdb, because of a new field added to the control file.

13 years agoMeasure WaitLatch's timeout parameter in milliseconds, not microseconds.
Tom Lane [Tue, 9 Aug 2011 22:52:29 +0000 (18:52 -0400)]
Measure WaitLatch's timeout parameter in milliseconds, not microseconds.

The original definition had the problem that timeouts exceeding about 2100
seconds couldn't be specified on 32-bit machines.  Milliseconds seem like
sufficient resolution, and finer grain than that would be fantasy anyway
on many platforms.

Back-patch to 9.1 so that this aspect of the latch API won't change between
9.1 and later releases.

Peter Geoghegan

13 years agoDocumentation improvement and minor code cleanups for the latch facility.
Tom Lane [Tue, 9 Aug 2011 19:30:45 +0000 (15:30 -0400)]
Documentation improvement and minor code cleanups for the latch facility.

Improve the documentation around weak-memory-ordering risks, and do a pass
of general editorialization on the comments in the latch code.  Make the
Windows latch code more like the Unix latch code where feasible; in
particular provide the same Assert checks in both implementations.
Fix poorly-placed WaitLatch call in syncrep.c.

This patch resolves, for the moment, concerns around weak-memory-ordering
bugs in latch-related code: we have documented the restrictions and checked
that existing calls meet them.  In 9.2 I hope that we will install suitable
memory barrier instructions in SetLatch/ResetLatch, so that their callers
don't need to be quite so careful.

13 years agoAvoid creating PlaceHolderVars immediately within PlaceHolderVars.
Tom Lane [Tue, 9 Aug 2011 15:33:46 +0000 (11:33 -0400)]
Avoid creating PlaceHolderVars immediately within PlaceHolderVars.

Such a construction is useless since the lower PlaceHolderVar is already
nullable; no need to make it more so.  Noted while pursuing bug #6154.

This is just a minor planner efficiency improvement, since the final plan
will come out the same anyway after PHVs are flattened.  So not worth the
risk of back-patching.

13 years agoUse clearer notation for getnameinfo() return handling
Peter Eisentraut [Tue, 9 Aug 2011 15:28:35 +0000 (18:28 +0300)]
Use clearer notation for getnameinfo() return handling

Writing

    if (getnameinfo(...))
        handle_error();

reads quite strangely, so use something like

    if (getnameinfo(...) != 0)
        handle_error();

instead.

13 years agoChange the way string relopts are allocated.
Heikki Linnakangas [Tue, 9 Aug 2011 12:25:44 +0000 (15:25 +0300)]
Change the way string relopts are allocated.

Don't try to allocate the default value for a string relopt in the same
palloc chunk as the relopt_string struct. That didn't work too well if you
added a built-in string relopt in the stringRelOpts array, as it's not
possible to have an initializer for a variable length struct in C. This
makes the code slightly simpler too.

While we're at it, move the call to validator function in
add_string_reloption to before the allocation, so that if someone does pass
a bogus default value, we don't leak memory.

13 years agoFix grammar and spelling in log message.
Heikki Linnakangas [Tue, 9 Aug 2011 08:43:57 +0000 (11:43 +0300)]
Fix grammar and spelling in log message.

13 years agoFix nested PlaceHolderVar expressions that appear only in targetlists.
Tom Lane [Tue, 9 Aug 2011 04:48:51 +0000 (00:48 -0400)]
Fix nested PlaceHolderVar expressions that appear only in targetlists.

A PlaceHolderVar's expression might contain another, lower-level
PlaceHolderVar.  If the outer PlaceHolderVar is used, the inner one
certainly will be also, and so we have to make sure that both of them get
into the placeholder_list with correct ph_may_need values during the
initial pre-scan of the query (before deconstruct_jointree starts).
We did this correctly for PlaceHolderVars appearing in the query quals,
but overlooked the issue for those appearing in the top-level targetlist;
with the result that nested placeholders referenced only in the targetlist
did not work correctly, as illustrated in bug #6154.

While at it, add some error checking to find_placeholder_info to ensure
that we don't try to create new placeholders after it's too late to do so;
they have to all be created before deconstruct_jointree starts.

Back-patch to 8.4 where the PlaceHolderVar mechanism was introduced.

13 years agoTeach psql to display the comments on SQL/MED objects in verbose mode.
Robert Haas [Mon, 8 Aug 2011 20:29:57 +0000 (16:29 -0400)]
Teach psql to display the comments on SQL/MED objects in verbose mode.

The relevant backslash commands already exist, so we're just adding an
additional column.  With this commit, all objects that have psql backslash
commands and accept comments should now display those comments at least
in verbose mode.

Josh Kupershmidt, with doc additions by me.

13 years agoTeach psql to display the comments on conversions and domains.
Robert Haas [Mon, 8 Aug 2011 16:26:13 +0000 (12:26 -0400)]
Teach psql to display the comments on conversions and domains.

\dc and \dD now accept a "+" option, which will cause the comments to
be displayed.  Along the way, correct a few oversights in the previous
commit in this area, 3b17efdfdd846c9bfad1637686e6f18198ea3df5 - namely,
(1) when \dL+ is used, make description still be the last column, for
consistency with what we've done elsewhere; and (2) document the
difference between \dC and \dC+.

Josh Kupershmidt, with a couple of doc changes by me.

13 years agoTeach vacuumlo to limit number of removals, via new -l option.
Robert Haas [Mon, 8 Aug 2011 13:12:16 +0000 (09:12 -0400)]
Teach vacuumlo to limit number of removals, via new -l option.

Also, handle failure better: don't just blindly keep trying to delete
stuff after the transaction has already failed.

Tim Lewis, reviewed by Josh Kupershmidt, with further hacking by me.

13 years agoCorrect the lie in pg_config.h.win32 about having inttypes.h.
Andrew Dunstan [Mon, 8 Aug 2011 12:52:05 +0000 (08:52 -0400)]
Correct the lie in pg_config.h.win32 about having inttypes.h.

This lie has been harmless until now, but has been exposed by the
change to include postgres.h before the python headers, which
in some versions include inttypes.h if HAVE_INTTYPES_H is set.

13 years agoAdd "Compatibility" section to ALTER EXTENSION reference page
Peter Eisentraut [Sun, 7 Aug 2011 19:15:38 +0000 (22:15 +0300)]
Add "Compatibility" section to ALTER EXTENSION reference page

Almost all other pages have one; this one must have been forgotten.

13 years agoRemove whitespace from end of lines
Peter Eisentraut [Sun, 7 Aug 2011 13:11:55 +0000 (16:11 +0300)]
Remove whitespace from end of lines

13 years agoRename "Example" sections to "Examples" in dblink chapter
Peter Eisentraut [Sun, 7 Aug 2011 12:51:04 +0000 (15:51 +0300)]
Rename "Example" sections to "Examples" in dblink chapter

For consistency with other man pages.

13 years agoFix a whitespace issue with the man pages
Peter Eisentraut [Sun, 7 Aug 2011 07:49:45 +0000 (10:49 +0300)]
Fix a whitespace issue with the man pages

There is what may actually be a mistake in our markup.  The problem is
in a situation like

<para>
 <command>FOO</command> is ...

there is strictly speaking a line break before "FOO".  In the HTML
output, this does not appear to be a problem, but in the man page
output, this shows up, so you get double blank lines at odd places.

So far, we have attempted to work around this with an XSL hack, but
that causes other problems, such as creating run-ins in places like

<acronym>SQL</acronym> <command>COPY</command>

So fix the problem properly by removing the extra whitespace.  I only
fixed the problems that affect the man page output, not all the
places.

13 years agoClean up ill-advised attempt to invent a private set of Node tags.
Tom Lane [Sat, 6 Aug 2011 18:53:49 +0000 (14:53 -0400)]
Clean up ill-advised attempt to invent a private set of Node tags.

Somebody thought it'd be cute to invent a set of Node tag numbers that were
defined independently of, and indeed conflicting with, the main tag-number
list.  While this accidentally failed to fail so far, it would certainly
lead to trouble as soon as anyone wanted to, say, apply copyObject to these
node types.  Clang was already complaining about the use of makeNode on
these tags, and I think quite rightly so.  Fix by pushing these node
definitions into the mainstream, including putting replnodes.h where it
belongs.

13 years agoFix thinko in documentation of local_preload_libraries.
Tom Lane [Sat, 6 Aug 2011 01:18:02 +0000 (21:18 -0400)]
Fix thinko in documentation of local_preload_libraries.

Somebody added a cross-reference to shared_preload_libraries, but wrote the
wrong variable name when they did it (and didn't bother to make it a link
either).

Spotted by Christoph Anton Mitterer.

13 years agoReduce PG_SYSLOG_LIMIT to 900 bytes.
Tom Lane [Sat, 6 Aug 2011 01:02:31 +0000 (21:02 -0400)]
Reduce PG_SYSLOG_LIMIT to 900 bytes.

The previous limit of 1024 was set on the assumption that all modern syslog
implementations have line length limits of 2KB or so.  However, this is
false, as at least Solaris and sysklogd truncate at only 1KB.  900 seems
to leave enough room for the max likely length of the tacked-on prefixes,
so let's go with that.

As with the previous change, it doesn't seem wise to back-patch this into
already-released branches; but it should be OK to sneak it into 9.1.

Noah Misch

13 years agoAllow per-column foreign data wrapper options.
Robert Haas [Fri, 5 Aug 2011 17:24:03 +0000 (13:24 -0400)]
Allow per-column foreign data wrapper options.

Shigeru Hanada, with fairly minor editing by me.

13 years agoModestly improve pgbench's checking for invalid ranges.
Robert Haas [Fri, 5 Aug 2011 16:48:45 +0000 (12:48 -0400)]
Modestly improve pgbench's checking for invalid ranges.

The old check against MAX_RANDOM_VALUE is clearly irrelevant since
getrand() no longer calls random().  Instead, check whether min and max
are close enough together to avoid an overflow inside getrand(), as
suggested by Tom Lane.  This is still somewhat silly, because we're
using atoi(), which doesn't check for overflow anyway and (at least on
my system) will cheerfully return 0 when given "4294967296".  But that's
a problem for another commit.

13 years agoTweak PQresStatus() to avoid a clang compiler warning.
Robert Haas [Fri, 5 Aug 2011 16:06:29 +0000 (12:06 -0400)]
Tweak PQresStatus() to avoid a clang compiler warning.

The previous test for status < 0 test is in fact testing nothing if the
compiler considers an enum to be an unsigned data type.  clang doesn't
like tautologies, so do this instead.

Report by Peter Geoghegan, fix as suggested by Tom Lane.

13 years agoFix markup for recent wal_level clarification.
Bruce Momjian [Thu, 4 Aug 2011 19:02:02 +0000 (15:02 -0400)]
Fix markup for recent wal_level clarification.

Backpatch to 9.1 and 9.0.

13 years agoRestore the primacy of postgres.h in plpython.c.
Andrew Dunstan [Thu, 4 Aug 2011 17:05:32 +0000 (13:05 -0400)]
Restore the primacy of postgres.h in plpython.c.

To avoid having the python headers hijack various definitions,
we now include them after all the system headers we want, having
first undefined some of the things they want to define. After that's
done we restore the things they scribbled on that matter, namely our
snprintf and vsnprintf macros, if we're using them.

13 years agoCreate VXID locks "lazily" in the main lock table.
Robert Haas [Thu, 4 Aug 2011 16:38:33 +0000 (12:38 -0400)]
Create VXID locks "lazily" in the main lock table.

Instead of entering them on transaction startup, we materialize them
only when someone wants to wait, which will occur only during CREATE
INDEX CONCURRENTLY.  In Hot Standby mode, the startup process must also
be able to probe for conflicting VXID locks, but the lock need never be
fully materialized, because the startup process does not use the normal
lock wait mechanism.  Since most VXID locks never need to touch the
lock manager partition locks, this can significantly reduce blocking
contention on read-heavy workloads.

Patch by me.  Review by Jeff Davis.

13 years agoTeach psql to display comments on languages and casts.
Robert Haas [Thu, 4 Aug 2011 16:22:26 +0000 (12:22 -0400)]
Teach psql to display comments on languages and casts.

The output of \dL (list languages) is fairly narrow, so we just always
display the comment.  \dC (list casts) can get fairly wide, so we only
display comments if the new \dC+ option is specified.

Josh Kupershmidt

13 years agoIn documentaiton, clarify which commands have reduced WAL volume for
Bruce Momjian [Thu, 4 Aug 2011 16:06:53 +0000 (12:06 -0400)]
In documentaiton, clarify which commands have reduced WAL volume for
wal_level = minimum.

Backpatch to 9.1 and 9.0.

13 years agoMake pgbench use erand48() rather than random().
Robert Haas [Wed, 3 Aug 2011 20:26:40 +0000 (16:26 -0400)]
Make pgbench use erand48() rather than random().

glibc renders random() thread-safe by wrapping a futex lock around it;
testing reveals that this limits the performance of pgbench on machines
with many CPU cores.  Rather than switching to random_r(), which is
only available on GNU systems and crashes unless you use undocumented
alchemy to initialize the random state properly, switch to our built-in
implementation of erand48(), which is both thread-safe and concurrent.

Since the list of reasons not to use the operating system's erand48()
is getting rather long, rename ours to pg_erand48() (and similarly
for our implementations of lrand48() and srand48()) and just always
use those.  We were already doing this on Cygwin anyway, and the
glibc implementation is not quite thread-safe, so pgbench wouldn't
be able to use that either.

Per discussion with Tom Lane.

13 years agoMove CheckRecoveryConflictDeadlock() call to a safer place.
Tom Lane [Tue, 2 Aug 2011 19:16:29 +0000 (15:16 -0400)]
Move CheckRecoveryConflictDeadlock() call to a safer place.

This kluge was inserted in a spot apparently chosen at random: the lock
manager's state is not yet fully set up for the wait, and in particular
LockWaitCancel hasn't been armed by setting lockAwaited, so the ProcLock
will not get cleaned up if the ereport is thrown.  This seems to not cause
any observable problem in trivial test cases, because LockReleaseAll will
silently clean up the debris; but I was able to cause failures with tests
involving subtransactions.

Fixes breakage induced by commit c85c941470efc44494fd7a5f426ee85fc65c268c.
Back-patch to all affected branches.

13 years agoFix incorrect initialization of ProcGlobal->startupBufferPinWaitBufId.
Tom Lane [Tue, 2 Aug 2011 17:23:52 +0000 (13:23 -0400)]
Fix incorrect initialization of ProcGlobal->startupBufferPinWaitBufId.

It was initialized in the wrong place and to the wrong value.  With bad
luck this could result in incorrect query-cancellation failures in hot
standby sessions, should a HS backend be holding pin on buffer number 1
while trying to acquire a lock.

13 years agoAvoid integer overflow when LIMIT + OFFSET >= 2^63.
Heikki Linnakangas [Tue, 2 Aug 2011 07:47:17 +0000 (10:47 +0300)]
Avoid integer overflow when LIMIT + OFFSET >= 2^63.

This fixes bug #6139 reported by Hitoshi Harada.

13 years agoMinor stylistic corrections.
Robert Haas [Mon, 1 Aug 2011 12:24:45 +0000 (08:24 -0400)]
Minor stylistic corrections.

13 years agoAdd host name resolution information to pg_hba.conf error messages
Peter Eisentraut [Sun, 31 Jul 2011 15:03:43 +0000 (18:03 +0300)]
Add host name resolution information to pg_hba.conf error messages

This is to be able to analyze issues with host names in pg_hba.conf.

13 years agoFix pg_update to properly test for the data directory's existence on
Bruce Momjian [Sat, 30 Jul 2011 05:50:18 +0000 (01:50 -0400)]
Fix pg_update to properly test for the data directory's existence on
Win32.

Backpatch to 9.1.

13 years agoReduce sinval synchronization overhead.
Robert Haas [Fri, 29 Jul 2011 20:46:13 +0000 (16:46 -0400)]
Reduce sinval synchronization overhead.

Testing shows that the overhead of acquiring and releasing
SInvalReadLock and msgNumLock on high-core count boxes can waste a lot
of CPU time and hurt performance.  This patch adds a per-backend flag
that allows us to skip all that locking in most cases.  Further
testing shows that this improves performance even when sinval traffic
is very high.

Patch by me.  Review and testing by Noah Misch.

13 years agoMove new pgbench options to correct section of --help output.
Robert Haas [Fri, 29 Jul 2011 20:43:57 +0000 (16:43 -0400)]
Move new pgbench options to correct section of --help output.

13 years agoFix pg_restore's direct-to-database mode for standard_conforming_strings.
Tom Lane [Thu, 28 Jul 2011 18:06:57 +0000 (14:06 -0400)]
Fix pg_restore's direct-to-database mode for standard_conforming_strings.

pg_backup_db.c contained a mini SQL lexer with which it tried to identify
boundaries between SQL commands, but that code was not designed to cope
with standard_conforming_strings, and would get the wrong answer if a
backslash immediately precedes a closing single quote in such a string,
as per report from Julian Mehnle.  The bug only affects direct-to-database
restores from archive files made with standard_conforming_strings = on.

Rather than complicating the code some more to try to fix that, let's just
rip it all out.  The only reason it was needed was to cope with COPY data
embedded into ordinary archive entries, which was a layout that was used
only for about the first three weeks of the archive format's existence,
and never in any production release of pg_dump.  Instead, just rely on the
archive file layout to tell us whether we're printing COPY data or not.

This bug represents a data corruption hazard in all releases in which
standard_conforming_strings can be turned on, ie 8.2 and later, so
back-patch to all supported branches.

13 years agoMinor message style adjustment
Peter Eisentraut [Wed, 27 Jul 2011 20:54:46 +0000 (23:54 +0300)]
Minor message style adjustment

13 years agoFix typo.
Robert Haas [Wed, 27 Jul 2011 15:20:07 +0000 (11:20 -0400)]
Fix typo.

Noted by Josh Kupershmidt.

13 years agoCheck to see whether libxml2 handles error context the way we expect.
Tom Lane [Tue, 26 Jul 2011 20:29:53 +0000 (16:29 -0400)]
Check to see whether libxml2 handles error context the way we expect.

It turns out to be possible to link against a libxml2.so that does this
differently than the version we configured and built against, so we need
a runtime check to avoid bizarre behavior.  Per report from Bernd Helmle.
Patch by Florian Pflug.

13 years agoAdd missing newlines at end of error messages
Peter Eisentraut [Tue, 26 Jul 2011 20:23:18 +0000 (23:23 +0300)]
Add missing newlines at end of error messages

13 years agoReplace printf format %i by %d
Peter Eisentraut [Tue, 26 Jul 2011 19:54:29 +0000 (22:54 +0300)]
Replace printf format %i by %d

They are identical, but the overwhelming majority of the code uses %d,
so standardize on that.

13 years agoOnly display column comments for relkinds that support them.
Robert Haas [Tue, 26 Jul 2011 13:52:31 +0000 (09:52 -0400)]
Only display column comments for relkinds that support them.

Josh Kupershmidt, with minor modifications by me.

13 years agoClarify which relkinds accept column comments.
Robert Haas [Tue, 26 Jul 2011 13:34:55 +0000 (09:34 -0400)]
Clarify which relkinds accept column comments.

Per discussion with Josh Kupershmidt.

13 years agoDon't build replacement getpeereid function on mingw.
Andrew Dunstan [Tue, 26 Jul 2011 03:48:44 +0000 (23:48 -0400)]
Don't build replacement getpeereid function on mingw.

Windows doesn't have Unix sockets, so it's not needed, and moreover causes compile warnings.

13 years agoSilence compiler warning about uninitialized variable.
Andrew Dunstan [Mon, 25 Jul 2011 23:37:17 +0000 (19:37 -0400)]
Silence compiler warning about uninitialized variable.

It is set correctly on the only path that uses it, but the
compiler can't know that.

13 years agoAdd some environment checks prior to sepgsql regression testing.
Robert Haas [Mon, 25 Jul 2011 14:51:02 +0000 (10:51 -0400)]
Add some environment checks prior to sepgsql regression testing.

This probably needs more work, but it's a start.

KaiGai Kohei

13 years agoImprovements to SQL/MED documentation.
Robert Haas [Mon, 25 Jul 2011 13:37:06 +0000 (09:37 -0400)]
Improvements to SQL/MED documentation.

Laurenz Albe, somewhat modified by me.

13 years agoAdd new pgbench options, --tablespace and --index-tablespace.
Robert Haas [Mon, 25 Jul 2011 13:16:14 +0000 (09:16 -0400)]
Add new pgbench options, --tablespace and --index-tablespace.

Per a request from Greg Smith.

13 years agoAdd new pgbench switch, --unlogged-tables.
Robert Haas [Mon, 25 Jul 2011 10:49:00 +0000 (06:49 -0400)]
Add new pgbench switch, --unlogged-tables.

This entails adjusting pgbench to use getopt_long() rather
than getopt().

13 years agoFix previous patch so it also works if not USE_SSL (mea culpa).
Tom Lane [Mon, 25 Jul 2011 03:29:03 +0000 (23:29 -0400)]
Fix previous patch so it also works if not USE_SSL (mea culpa).

On balance, the need to cover this case changes my mind in favor of pushing
all error-message generation duties into the two fe-secure.c routines.
So do it that way.

13 years agoImprove libpq's error reporting for SSL failures.
Tom Lane [Sun, 24 Jul 2011 20:29:07 +0000 (16:29 -0400)]
Improve libpq's error reporting for SSL failures.

In many cases, pqsecure_read/pqsecure_write set up useful error messages,
which were then overwritten with useless ones by their callers.  Fix this
by defining the responsibility to set an error message to be entirely that
of the lower-level function when using SSL.

Back-patch to 8.3; the code is too different in 8.2 to be worth the
trouble.

13 years agoUse OpenSSL's SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
Tom Lane [Sun, 24 Jul 2011 19:17:51 +0000 (15:17 -0400)]
Use OpenSSL's SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.

This disables an entirely unnecessary "sanity check" that causes failures
in nonblocking mode, because OpenSSL complains if we move or compact the
write buffer.  The only actual requirement is that we not modify pending
data once we've attempted to send it, which we don't.  Per testing and
research by Martin Pihlak, though this fix is a lot simpler than his patch.

I put the same change into the backend, although it's less clear whether
it's necessary there.  We do use nonblock mode in some situations in
streaming replication, so seems best to keep the same behavior in the
backend as in libpq.

Back-patch to all supported releases.

13 years agoIn pg_upgrade on Windows, check if the directory is writable by actually
Bruce Momjian [Sun, 24 Jul 2011 05:42:45 +0000 (01:42 -0400)]
In pg_upgrade on Windows, check if the directory is writable by actually
creating and removing a file because access() doesn't work on that
platform.

Backpatch to 9.1 where this check was added.

13 years agoUnbreak Windows builds broken by EDITOR_LINENUMBER_ARG change.
Andrew Dunstan [Sat, 23 Jul 2011 23:33:17 +0000 (19:33 -0400)]
Unbreak Windows builds broken by EDITOR_LINENUMBER_ARG change.

13 years agoChange EDITOR_LINENUMBER_SWITCH to an environment variable
Peter Eisentraut [Sat, 23 Jul 2011 21:25:29 +0000 (00:25 +0300)]
Change EDITOR_LINENUMBER_SWITCH to an environment variable

Also change "switch" to "arg" because "switch" is a bit of a sloppy
term.  So the environment variable is called
PSQL_EDITOR_LINENUMBER_ARG.  Set "+" as hardcoded default value on
Unix (since "vi" is the hardcoded default editor), so many users won't
have to configure this at all.  Move the documentation around a bit to
centralize the editor configuration under environment variables,
rather than repeating bits of it under every backslash command that
invokes an editor.

13 years agoRethink behavior of CREATE OR REPLACE during CREATE EXTENSION.
Tom Lane [Sat, 23 Jul 2011 20:59:39 +0000 (16:59 -0400)]
Rethink behavior of CREATE OR REPLACE during CREATE EXTENSION.

The original implementation simply did nothing when replacing an existing
object during CREATE EXTENSION.  The folly of this was exposed by a report
from Marc Munro: if the existing object belongs to another extension, we
are left in an inconsistent state.  We should insist that the object does
not belong to another extension, and then add it to the current extension
if not already a member.

13 years agoUnbreak unlogged tables.
Robert Haas [Fri, 22 Jul 2011 20:15:43 +0000 (16:15 -0400)]
Unbreak unlogged tables.

I broke this in commit 5da79169d3e9f0fab47da03318c44075b3f824c5, which
was obviously insufficiently well tested.  Add some regression tests
in the hope of making future slip-ups more likely to be noticed.

13 years agoIn pg_upgrade, add C comment about why we don't try to do shared file
Bruce Momjian [Thu, 21 Jul 2011 21:12:35 +0000 (17:12 -0400)]
In pg_upgrade, add C comment about why we don't try to do shared file
writes for logging.

13 years agoFix PQsetvalue() to avoid possible crash when adding a new tuple.
Tom Lane [Thu, 21 Jul 2011 16:24:14 +0000 (12:24 -0400)]
Fix PQsetvalue() to avoid possible crash when adding a new tuple.

PQsetvalue unnecessarily duplicated the logic in pqAddTuple, and didn't
duplicate it exactly either --- pqAddTuple does not care what is in the
tuple-pointer array positions beyond the last valid entry, whereas the
code in PQsetvalue assumed such positions would contain NULL.  This led
to possible crashes if PQsetvalue was applied to a PGresult that had
previously been enlarged with pqAddTuple, for instance one built from a
server query.  Fix by relying on pqAddTuple instead of duplicating logic,
and not assuming anything about the contents of res->tuples[res->ntups].

Back-patch to 8.4, where PQsetvalue was introduced.

Andrew Chernow

13 years agoMake xpath() do something useful with XPath expressions that return scalars.
Tom Lane [Thu, 21 Jul 2011 15:32:46 +0000 (11:32 -0400)]
Make xpath() do something useful with XPath expressions that return scalars.

Previously, xpath() simply returned an empty array if the expression did
not yield a node set.  This is useless for expressions that return scalars,
such as one with name() at the top level.  Arrange to return the scalar
value as a single-element xml array, instead.  (String values will be
suitably escaped.)

This change will also cause xpath_exists() to return true, not false,
for such expressions.

Florian Pflug, reviewed by Radoslaw Smogura

13 years agoEnsure that xpath() escapes special characters in string values.
Tom Lane [Wed, 20 Jul 2011 22:44:09 +0000 (18:44 -0400)]
Ensure that xpath() escapes special characters in string values.

Without this it's possible for the output to not be legal XML, as
illustrated by the added regression test cases.

NB: this change will need to be called out as an incompatibility in the
9.2 release notes, since it's possible somebody was relying on the old
behavior, even though it's clearly wrong.

Florian Pflug, reviewed by Radoslaw Smogura

13 years agoIn pg_upgrade, fix the -l/log option to work on Windows.
Bruce Momjian [Wed, 20 Jul 2011 22:31:03 +0000 (18:31 -0400)]
In pg_upgrade, fix the -l/log option to work on Windows.

Also, double-quote the log file name in all places, to allow (on all
platforms) log file names with spaces.

Back patch to 9.0 and 9.1.

13 years agoIn pg_upgrade, use pg_strudup(), for consistency.
Bruce Momjian [Wed, 20 Jul 2011 20:37:17 +0000 (16:37 -0400)]
In pg_upgrade, use pg_strudup(), for consistency.

13 years agoSupport SECURITY LABEL on databases, tablespaces, and roles.
Robert Haas [Wed, 20 Jul 2011 17:18:24 +0000 (13:18 -0400)]
Support SECURITY LABEL on databases, tablespaces, and roles.

This requires a new shared catalog, pg_shseclabel.

Along the way, fix the security_label regression tests so that they
don't monkey with the labels of any pre-existing objects.  This is
unlikely to matter in practice, since only the label for the "dummy"
provider was being manipulated.  But this way still seems cleaner.

KaiGai Kohei, with fairly extensive hacking by me.

13 years agoRewrite libxml error handling to be more robust.
Tom Lane [Wed, 20 Jul 2011 17:03:12 +0000 (13:03 -0400)]
Rewrite libxml error handling to be more robust.

libxml reports some errors (like invalid xmlns attributes) via the error
handler hook, but still returns a success indicator to the library caller.
This causes us to miss some errors that are important to report.  Since the
"generic" error handler hook doesn't know whether the message it's getting
is for an error, warning, or notice, stop using that and instead start
using the "structured" error handler hook, which gets enough information
to be useful.

While at it, arrange to save and restore the error handler hook setting in
each libxml-using function, rather than assuming we can set and forget the
hook.  This should improve the odds of working nicely with third-party
libraries that also use libxml.

In passing, volatile-ize some local variables that get modified within
PG_TRY blocks.  I noticed this while testing with an older gcc version
than I'd previously tried to compile xml.c with.

Florian Pflug and Tom Lane, with extensive review/testing by Noah Misch

13 years agoImprove sepgsql and SECURITY LABEL documentation.
Robert Haas [Wed, 20 Jul 2011 13:22:57 +0000 (09:22 -0400)]
Improve sepgsql and SECURITY LABEL documentation.

KaiGai Kohei, based on feedback from Yeb Havinga, with some
corrections by me.

13 years agoMinor improvement to pg_seclabel documentation.
Robert Haas [Wed, 20 Jul 2011 13:12:42 +0000 (09:12 -0400)]
Minor improvement to pg_seclabel documentation.

This is a bit more consistent with the way pg_description is
documented, and also include a useful cross-link.

13 years agoMake isolationtester more robust on locked commands
Alvaro Herrera [Tue, 19 Jul 2011 18:22:42 +0000 (14:22 -0400)]
Make isolationtester more robust on locked commands

Noah Misch diagnosed the buildfarm problems in the isolation tests
partly as failure to differentiate backends properly; the old code was
using backend IDs, which is not good enough because a new backend might
use an already used ID.  Use PIDs instead.

Also, the code was purposely careless about other concurrent activity,
because it isn't expected; and in fact, it doesn't affect the vast
majority of the time.  However, it can be observed that autovacuum can
block tables for long enough to cause sporadic failures.  The new code
accounts for that by ignoring locks held by processes not explicitly
declared in our spec file.

Author: Noah Misch

13 years agoIncrease deadlock_timeout to 100ms in FK isolation tests
Alvaro Herrera [Tue, 19 Jul 2011 17:07:16 +0000 (13:07 -0400)]
Increase deadlock_timeout to 100ms in FK isolation tests

The previous value of 20ms is dangerously close to the time actually
spent just waiting for the deadlock to happen, so on occasion it causes
the test to fail simply because the other session didn't get to run
early enough, not managing to cause the deadlock that needs to be
detected.  With this new value, it's expected that most machines on
normal load will be able to pass the test.

Author: Noah Misch

13 years agoAdd expected regress output on stricter isolation levels
Alvaro Herrera [Tue, 19 Jul 2011 16:43:16 +0000 (12:43 -0400)]
Add expected regress output on stricter isolation levels

These new files allow the new FK tests on isolationtester to pass on the
serializable and repeatable read isolation levels (which are untested
by the buildfarm).

Author: Kevin Grittner
Reviewed by Noah Misch

13 years agoRemove O(N^2) performance issue with multiple SAVEPOINTs.
Simon Riggs [Tue, 19 Jul 2011 16:21:24 +0000 (17:21 +0100)]
Remove O(N^2) performance issue with multiple SAVEPOINTs.
Subtransaction locks now released en masse at main commit, rather than
repeatedly re-scanning for locks as we ascend the nested transaction tree.
Split transaction state TBLOCK_SUBEND into two states, TBLOCK_SUBCOMMIT
and TBLOCK_SUBRELEASE to allow the commit path to be optimised using
the existing code in ResourceOwnerRelease() which appears to have been
intended for this usage, judging from comments therein.

13 years agoSome refinement for the "fast path" lock patch.
Robert Haas [Tue, 19 Jul 2011 16:10:15 +0000 (12:10 -0400)]
Some refinement for the "fast path" lock patch.

1. In GetLockStatusData, avoid initializing instance before we've ensured
that the array is large enough.  Otherwise, if repalloc moves the block
around, we're hosed.

2. Add the word "Relation" to the name of some identifiers, to avoid
assuming that the fast-path mechanism will only ever apply to relations
(though these particular parts certainly will).  Some of the macros
could possibly use similar treatment, but the names are getting awfully
long already.

3. Add a missing word to comment in AtPrepare_Locks().

13 years agoRemove superfluous variable.
Robert Haas [Tue, 19 Jul 2011 14:30:03 +0000 (10:30 -0400)]
Remove superfluous variable.

Reported by Peter Eisentraut.

13 years agoMinor doc additions for cascading replication.
Simon Riggs [Tue, 19 Jul 2011 08:07:42 +0000 (09:07 +0100)]
Minor doc additions for cascading replication.

13 years agoIntroduce sending servers as new category for replication params
Simon Riggs [Tue, 19 Jul 2011 07:59:55 +0000 (08:59 +0100)]
Introduce sending servers as new category for replication params

Fujii Masao

13 years agoFix typo
Peter Eisentraut [Tue, 19 Jul 2011 05:02:34 +0000 (08:02 +0300)]
Fix typo

13 years agoPut inline declaration before return type
Peter Eisentraut [Tue, 19 Jul 2011 04:57:38 +0000 (07:57 +0300)]
Put inline declaration before return type

gcc -Wextra complains that the other way around is obsolescent, and
this was the only place where it was written in this order.

13 years agoChange debug message from ereport to elog
Peter Eisentraut [Tue, 19 Jul 2011 04:50:10 +0000 (07:50 +0300)]
Change debug message from ereport to elog

13 years agoCascading replication feature for streaming log-based replication.
Simon Riggs [Tue, 19 Jul 2011 02:40:03 +0000 (03:40 +0100)]
Cascading replication feature for streaming log-based replication.
Standby servers can now have WALSender processes, which can work with
either WALReceiver or archive_commands to pass data. Fully updated
docs, including new conceptual terms of sending server, upstream and
downstream servers. WALSenders terminated when promote to master.

Fujii Masao, review, rework and doc rewrite by Simon Riggs

13 years agoAdd GET STACKED DIAGNOSTICS plpgsql command to retrieve exception info.
Tom Lane [Mon, 18 Jul 2011 18:46:27 +0000 (14:46 -0400)]
Add GET STACKED DIAGNOSTICS plpgsql command to retrieve exception info.

This is more SQL-spec-compliant, more easily extensible, and better
performing than the old method of inventing special variables.

Pavel Stehule, reviewed by Shigeru Hanada and David Wheeler

13 years agoAdapted expected result for latest change to ecpglib.
Michael Meskes [Mon, 18 Jul 2011 16:56:15 +0000 (18:56 +0200)]
Adapted expected result for latest change to ecpglib.

13 years agoAvoid index rebuild for no-rewrite ALTER TABLE .. ALTER TYPE.
Robert Haas [Mon, 18 Jul 2011 15:02:48 +0000 (11:02 -0400)]
Avoid index rebuild for no-rewrite ALTER TABLE .. ALTER TYPE.

Noah Misch.  Review and minor cosmetic changes by me.

13 years agoMade ecpglib write double with a precision of 15 digits.
Michael Meskes [Mon, 18 Jul 2011 14:25:27 +0000 (16:25 +0200)]
Made ecpglib write double with a precision of 15 digits.

Patch originally by Akira Kurosawa <kurosawa-akira@mxc.nes.nec.co.jp>.