OSDN Git Service

pg-rex/syncrep.git
13 years agoMerge branch 'pgrex90-base' into pgrex90 pgrex902 pgrex902-1.0
MasaoFujii [Tue, 8 Mar 2011 07:59:32 +0000 (16:59 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge commit 'REL9_0_2' into pgrex90-base
MasaoFujii [Tue, 8 Mar 2011 07:58:39 +0000 (16:58 +0900)]
Merge commit 'REL9_0_2' into pgrex90-base

13 years agoRemove the old event files in pg_event during startup.
MasaoFujii [Wed, 15 Dec 2010 06:56:29 +0000 (15:56 +0900)]
Remove the old event files in pg_event during startup.

13 years agoIf the server is shutting down and we cannot ensure that
MasaoFujii [Wed, 15 Dec 2010 06:02:36 +0000 (15:02 +0900)]
If the server is shutting down and we cannot ensure that
the transaction has successfully been replicated, we exit
before returning a "success" to the client.

13 years agoFix the bug which prevents postmaster from sending the signal to
MasaoFujii [Wed, 15 Dec 2010 04:46:07 +0000 (13:46 +0900)]
Fix the bug which prevents postmaster from sending the signal to
the walsenders.

13 years agoWhen the primary cannot work any longer, for example, because of
MasaoFujii [Tue, 14 Dec 2010 13:56:11 +0000 (22:56 +0900)]
When the primary cannot work any longer, for example, because of
shutdown, walsender tries to signal the waiters to exit with fatal
error before returning a success to the client.

13 years agoTag 9.0.2. REL9_0_2
Marc G. Fournier [Tue, 14 Dec 2010 02:55:50 +0000 (22:55 -0400)]
Tag 9.0.2.

13 years agoUpdate release notes for releases 9.0.2, 8.4.6, 8.3.13, 8.2.19, and 8.1.23.
Tom Lane [Tue, 14 Dec 2010 01:21:55 +0000 (20:21 -0500)]
Update release notes for releases 9.0.2, 8.4.6, 8.3.13, 8.2.19, and 8.1.23.

13 years agoTranslation updates for release 9.0.2
Peter Eisentraut [Mon, 13 Dec 2010 21:20:00 +0000 (23:20 +0200)]
Translation updates for release 9.0.2

13 years agoUpdate time zone data files to tzdata release 2010o: DST law changes in
Tom Lane [Mon, 13 Dec 2010 17:41:57 +0000 (12:41 -0500)]
Update time zone data files to tzdata release 2010o: DST law changes in
Fiji and Samoa.  Historical corrections for Hong Kong.

13 years agoChange postmaster so that it sends SIGINT to the walsenders when
MasaoFujii [Mon, 13 Dec 2010 14:54:31 +0000 (23:54 +0900)]
Change postmaster so that it sends SIGINT to the walsenders when
smart or fast shutdown is requested.

SIGINT makes the walsenders prevent the server from getting into
standalone mode.

13 years agoPrevent asynchronous walsender from waking up the waiter of replication.
MasaoFujii [Mon, 13 Dec 2010 13:38:29 +0000 (22:38 +0900)]
Prevent asynchronous walsender from waking up the waiter of replication.

13 years agoBug fix
MasaoFujii [Mon, 13 Dec 2010 10:08:05 +0000 (19:08 +0900)]
Bug fix

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Mon, 13 Dec 2010 09:12:21 +0000 (18:12 +0900)]
Merge branch 'pgrex90-base' into pgrex90

Conflicts:
doc/src/sgml/protocol.sgml
src/backend/replication/walsender.c
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-protocol2.c
src/interfaces/libpq/fe-protocol3.c
src/interfaces/libpq/libpq-int.h

13 years agoAllow bidirectional copy messages in streaming replication mode.
Robert Haas [Sat, 11 Dec 2010 14:27:37 +0000 (09:27 -0500)]
Allow bidirectional copy messages in streaming replication mode.

Fujii Masao.  Review by Alvaro Herrera, Tom Lane, and myself.

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Mon, 13 Dec 2010 07:56:27 +0000 (16:56 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoFix efficiency problems in tuplestore_trim().
Tom Lane [Fri, 10 Dec 2010 16:33:38 +0000 (11:33 -0500)]
Fix efficiency problems in tuplestore_trim().

The original coding in tuplestore_trim() was only meant to work efficiently
in cases where each trim call deleted most of the tuples in the store.
Which, in fact, was the pattern of the original usage with a Material node
supporting mark/restore operations underneath a MergeJoin.  However,
WindowAgg now uses tuplestores and it has considerably less friendly
trimming behavior.  In particular it can attempt to trim one tuple at a
time off a large tuplestore.  tuplestore_trim() had O(N^2) runtime in this
situation because of repeatedly shifting its tuple pointer array.  Fix by
avoiding shifting the array until a reasonably large number of tuples have
been deleted.  This can waste some pointer space, but we do still reclaim
the tuples themselves, so the percentage wastage should be pretty small.

Per Jie Li's report of slow percent_rank() evaluation.  cume_dist() and
ntile() would certainly be affected as well, along with any other window
function that has a moving frame start and requires reading substantially
ahead of the current row.

Back-patch to 8.4, where window functions were introduced.  There's no
need to tweak it before that.

13 years agoReduce spurious Hot Standby conflicts from never-visible records.
Simon Riggs [Fri, 10 Dec 2010 06:59:33 +0000 (06:59 +0000)]
Reduce spurious Hot Standby conflicts from never-visible records.
Hot Standby conflicts only with tuples that were visible at
some point. So ignore tuples from aborted transactions or for
tuples updated/deleted during the inserting transaction when
generating the conflict transaction ids.

Following detailed analysis and test case by Noah Misch.
Original report covered btree delete records, correctly observed
by Heikki Linnakangas that this applies to other cases also.
Fix covers all sources of cleanup records via common code.
Includes additional fix compared to commit on HEAD

13 years agoEliminate O(N^2) behavior in parallel restore with many blobs.
Tom Lane [Thu, 9 Dec 2010 18:03:11 +0000 (13:03 -0500)]
Eliminate O(N^2) behavior in parallel restore with many blobs.

With hundreds of thousands of TOC entries, the repeated searches in
reduce_dependencies() become the dominant cost.  Get rid of that searching
by constructing reverse-dependency lists, which we can do in O(N) time
during the fix_dependencies() preprocessing.  I chose to store the reverse
dependencies as DumpId arrays for consistency with the forward-dependency
representation, and keep the previously-transient tocsByDumpId[] array
around to locate actual TOC entry structs quickly from dump IDs.

While this fixes the slow case reported by Vlad Arkhipov, there is still
a potential for O(N^2) behavior with sufficiently many tables:
fix_dependencies itself, as well as mark_create_done and
inhibit_data_for_failed_table, are doing repeated searches to deal with
table-to-table-data dependencies.  Possibly this work could be extended
to deal with that, although the latter two functions are also used in
non-parallel restore where we currently don't run fix_dependencies.

Another TODO is that we fail to parallelize restore of multiple blobs
at all.  This appears to require changes in the archive format to fix.

Back-patch to 9.0 where the problem was reported.  8.4 has potential issues
as well; but since it doesn't create a separate TOC entry for each blob,
it's at much less risk of having enough TOC entries to cause real problems.

13 years agoPrevents query conflict from suspending a failover.
MasaoFujii [Thu, 9 Dec 2010 13:42:25 +0000 (22:42 +0900)]
Prevents query conflict from suspending a failover.

After the standby has been triggered, we cancel the
conflicting query and transactions immediately to
speed up a failover.

13 years agoSupport pg_ctl promote which promotes the standby server to the primary.
MasaoFujii [Thu, 9 Dec 2010 11:20:47 +0000 (20:20 +0900)]
Support pg_ctl promote which promotes the standby server to the primary.

13 years agoIntroduce the routines for signaling the postmaster from users.
MasaoFujii [Thu, 9 Dec 2010 06:56:41 +0000 (15:56 +0900)]
Introduce the routines for signaling the postmaster from users.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Thu, 9 Dec 2010 04:37:42 +0000 (13:37 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Thu, 9 Dec 2010 04:36:49 +0000 (13:36 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoForce default wal_sync_method to be fdatasync on Linux.
Tom Lane [Thu, 9 Dec 2010 01:01:14 +0000 (20:01 -0500)]
Force default wal_sync_method to be fdatasync on Linux.

Recent versions of the Linux system header files cause xlogdefs.h to
believe that open_datasync should be the default sync method, whereas
formerly fdatasync was the default on Linux.  open_datasync is a bad
choice, first because it doesn't actually outperform fdatasync (in fact
the reverse), and second because we try to use O_DIRECT with it, causing
failures on certain filesystems (e.g., ext4 with data=journal option).
This part of the patch is largely per a proposal from Marti Raudsepp.
More extensive changes are likely to follow in HEAD, but this is as much
change as we want to back-patch.

Also clean up confusing code and incorrect documentation surrounding the
fsync_writethrough option.  Those changes shouldn't result in any actual
behavioral change, but I chose to back-patch them anyway to keep the
branches looking similar in this area.

In 9.0 and HEAD, also do some copy-editing on the WAL Reliability
documentation section.

Back-patch to all supported branches, since any of them might get used
on modern Linux versions.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Tue, 7 Dec 2010 14:05:24 +0000 (23:05 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Tue, 7 Dec 2010 14:02:22 +0000 (23:02 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoChange walsender so that it sends a XLogCatchupComplete message
MasaoFujii [Tue, 7 Dec 2010 13:59:40 +0000 (22:59 +0900)]
Change walsender so that it sends a XLogCatchupComplete message
to the standby when it has caught up with the primary.

13 years agoIntroduce WalSndState
MasaoFujii [Tue, 7 Dec 2010 11:51:56 +0000 (20:51 +0900)]
Introduce WalSndState

13 years agoFix bugs in the hot standby known-assigned-xids tracking logic. If there's
Heikki Linnakangas [Tue, 7 Dec 2010 08:23:30 +0000 (09:23 +0100)]
Fix bugs in the hot standby known-assigned-xids tracking logic. If there's
an old transaction running in the master, and a lot of transactions have
started and finished since, and a WAL-record is written in the gap between
the creating the running-xacts snapshot and WAL-logging it, recovery will fail
with "too many KnownAssignedXids" error. This bug was reported by
Joachim Wieland on Nov 19th.

In the same scenario, when fewer transactions have started so that all the
xids fit in KnownAssignedXids despite the first bug, a more serious bug
arises. We incorrectly initialize the clog code with the oldest still running
transaction, and when we see the WAL record belonging to a transaction with
an XID larger than one that committed already before the checkpoint we're
recovering from, we zero the clog page containing the already committed
transaction, leading to data loss.

In hindsight, trying to track xids in the known-assigned-xids array before
seeing the running-xacts record was too complicated. To fix that, hold
XidGenLock while the running-xacts snapshot is taken and WAL-logged. That
ensures that no transaction can begin or end in that gap, so that in recvoery
we know that the snapshot contains all transactions running at that point in
WAL.

13 years agoAdd a stack overflow check to copyObject().
Tom Lane [Tue, 7 Dec 2010 03:55:51 +0000 (22:55 -0500)]
Add a stack overflow check to copyObject().

There are some code paths, such as SPI_execute(), where we invoke
copyObject() on raw parse trees before doing parse analysis on them.  Since
the bison grammar is capable of building heavily nested parsetrees while
itself using only minimal stack depth, this means that copyObject() can be
the front-line function that hits stack overflow before anything else does.
Accordingly, it had better have a check_stack_depth() call.  I did a bit of
performance testing and found that this slows down copyObject() by only a
few percent, so the hit ought to be negligible in the context of complete
processing of a query.

Per off-list report from Toshihide Katayama.  Back-patch to all supported
branches.

13 years agoFix two typos, by Fujii Masao.
Heikki Linnakangas [Mon, 6 Dec 2010 11:36:26 +0000 (12:36 +0100)]
Fix two typos, by Fujii Masao.

13 years agoIntroduce standby_fencing_command which is used to shoot the standby
MasaoFujii [Fri, 3 Dec 2010 10:02:50 +0000 (19:02 +0900)]
Introduce standby_fencing_command which is used to shoot the standby
in the head when replication is terminated for a reason other than
the master server shutdown and emergency bailout (i.e., unexpected
death of postmaster).

13 years agoFix typo.
MasaoFujii [Fri, 3 Dec 2010 06:33:49 +0000 (15:33 +0900)]
Fix typo.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Fri, 3 Dec 2010 03:01:00 +0000 (12:01 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Fri, 3 Dec 2010 02:55:47 +0000 (11:55 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoIntroduce replication timeout for synchronous replication.
MasaoFujii [Fri, 3 Dec 2010 02:53:06 +0000 (11:53 +0900)]
Introduce replication timeout for synchronous replication.

13 years agoPrevent inlining a SQL function with multiple OUT parameters.
Tom Lane [Wed, 1 Dec 2010 05:53:23 +0000 (00:53 -0500)]
Prevent inlining a SQL function with multiple OUT parameters.

There were corner cases in which the planner would attempt to inline such
a function, which would result in a failure at runtime due to loss of
information about exactly what the result record type is.  Fix by disabling
inlining when the function's recorded result type is RECORD.  There might
be some sub-cases where inlining could still be allowed, but this is a
simple and backpatchable fix, so leave refinements for another day.
Per bug #5777 from Nate Carson.

Back-patch to all supported branches.  8.1 happens to avoid a core-dump
here, but it still does the wrong thing.

13 years agoIntroduce replication timeout for asynchronous and synchronous replication.
MasaoFujii [Tue, 30 Nov 2010 14:33:06 +0000 (23:33 +0900)]
Introduce replication timeout for asynchronous and synchronous replication.

13 years agoIntroduce new boolean parameter which indicates whether there is
MasaoFujii [Tue, 30 Nov 2010 13:38:07 +0000 (22:38 +0900)]
Introduce new boolean parameter which indicates whether there is
pending WAL data in output buffer or not, into XLogSend, for
improving the code readability.

13 years agoChange walsender so that it sends WAL data in non-blocking mode.
MasaoFujii [Tue, 30 Nov 2010 11:41:52 +0000 (20:41 +0900)]
Change walsender so that it sends WAL data in non-blocking mode.

13 years agoIntroduce new backend libpq functions which send data to client
MasaoFujii [Tue, 30 Nov 2010 01:47:15 +0000 (10:47 +0900)]
Introduce new backend libpq functions which send data to client
if writable without blocking.

These functions are required to introduce the replication timeout
to walsender process.

13 years agoMove call to GetTopTransactionId() earlier in LockAcquire(),
Simon Riggs [Mon, 29 Nov 2010 01:10:56 +0000 (01:10 +0000)]
Move call to GetTopTransactionId() earlier in LockAcquire(),
removing an infrequently occurring race condition in Hot Standby.
An xid must be assigned before a lock appears in shared memory,
rather than immediately after, else GetRunningTransactionLocks()
may see InvalidTransactionId, causing assertion failures during
lock processing on standby.

Bug report and diagnosis by Fujii Masao, fix by me.

13 years agoFix significant memory leak in contrib/xml2 functions.
Tom Lane [Fri, 26 Nov 2010 20:20:55 +0000 (15:20 -0500)]
Fix significant memory leak in contrib/xml2 functions.

Most of the functions that execute XPath queries leaked the data structures
created by libxml2.  This memory would not be recovered until end of
session, so it mounts up pretty quickly in any serious use of the feature.
Per report from Pavel Stehule, though this isn't his patch.

Back-patch to all supported branches.

13 years agoPrepare for replication_timeout.
MasaoFujii [Fri, 26 Nov 2010 13:23:34 +0000 (22:23 +0900)]
Prepare for replication_timeout.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Fri, 26 Nov 2010 10:28:52 +0000 (19:28 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Fri, 26 Nov 2010 10:24:21 +0000 (19:24 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoDon't raise "identifier will be truncated" messages in dblink
Itagaki Takahiro [Thu, 25 Nov 2010 10:40:58 +0000 (19:40 +0900)]
Don't raise "identifier will be truncated" messages in dblink
except creating new connections.

13 years agoMake walsender wake waiters up if replication has been completed.
MasaoFujii [Mon, 22 Nov 2010 14:18:19 +0000 (23:18 +0900)]
Make walsender wake waiters up if replication has been completed.

13 years agoMake backend wait for replication.
MasaoFujii [Mon, 22 Nov 2010 13:47:31 +0000 (22:47 +0900)]
Make backend wait for replication.

13 years agoIntroduce WalSndWaiter struct which is used for backend to wait for
MasaoFujii [Mon, 22 Nov 2010 13:22:57 +0000 (22:22 +0900)]
Introduce WalSndWaiter struct which is used for backend to wait for
replication.

13 years agoMake walreceiver send back the ACK per its replication mode.
MasaoFujii [Mon, 22 Nov 2010 12:08:16 +0000 (21:08 +0900)]
Make walreceiver send back the ACK per its replication mode.

13 years agoMake walreceiver include its replication mode in START_REPLICATION
MasaoFujii [Mon, 22 Nov 2010 11:56:50 +0000 (20:56 +0900)]
Make walreceiver include its replication mode in START_REPLICATION
query which is sent in a handshake processing.

13 years agoAdd replication_mode in postgresql.conf
MasaoFujii [Mon, 22 Nov 2010 02:44:41 +0000 (11:44 +0900)]
Add replication_mode in postgresql.conf

13 years agoRevert "Add the definition of replication modes."
MasaoFujii [Mon, 22 Nov 2010 02:33:53 +0000 (11:33 +0900)]
Revert "Add the definition of replication modes."

This reverts commit 4b390ba3022a7515772a621001bbdf1d82d0e371.

This is for moving replication_mode from recovery.conf to postgresql.conf

13 years agoRevert "Add replication_mode parameter in recovery.conf."
MasaoFujii [Mon, 22 Nov 2010 02:32:04 +0000 (11:32 +0900)]
Revert "Add replication_mode parameter in recovery.conf."

This reverts commit 3293dd5337a258a00e1a65936e1e4d18a886e078.

This is for moving replication_mode from recovery.conf to
postgresql.conf.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Mon, 22 Nov 2010 02:11:25 +0000 (11:11 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Mon, 22 Nov 2010 02:06:42 +0000 (11:06 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoFix leakage of cost_limit when multiple autovacuum workers are active.
Tom Lane [Sat, 20 Nov 2010 03:28:25 +0000 (22:28 -0500)]
Fix leakage of cost_limit when multiple autovacuum workers are active.

When using default autovacuum_vac_cost_limit, autovac_balance_cost relied
on VacuumCostLimit to contain the correct global value ... but after the
first time through in a particular worker process, it didn't, because we'd
trashed it in previous iterations.  Depending on the state of other autovac
workers, this could result in a steady reduction of the effective
cost_limit setting as a particular worker processed more and more tables,
causing it to go slower and slower.  Spotted by Simon Poole (bug #5759).
Fix by saving and restoring the GUC variables in the loop in do_autovacuum.

In passing, improve a few comments.

Back-patch to 8.3 ... the cost rebalancing code has been buggy since it was
put in.

13 years agoImprove plpgsql's error reporting for no-such-column cases.
Tom Lane [Thu, 18 Nov 2010 22:06:57 +0000 (17:06 -0500)]
Improve plpgsql's error reporting for no-such-column cases.

Given a column reference foo.bar, where there is a composite plpgsql
variable foo but it doesn't contain a column bar, the pre-9.0 coding would
immediately throw a "record foo has no field bar" error.  In 9.0 the parser
hook instead falls through to let the core parser see if it can resolve the
reference.  If not, you get a complaint about "missing FROM-clause entry
for table foo", which while in some sense correct isn't terribly helpful.
Complicate things a bit so that we can throw the old error message if
neither the core parser nor the hook are able to resolve the column
reference, while not changing the behavior in any other case.
Per bug #5757 from Andrey Galkin.

13 years agoSend paramHandle to subprocesses as 64-bit on Win64
Magnus Hagander [Tue, 16 Nov 2010 11:40:56 +0000 (12:40 +0100)]
Send paramHandle to subprocesses as 64-bit on Win64

The handle to the shared memory segment containing startup
parameters was sent as 32-bit even on 64-bit systems. Since
HANDLEs appear to be allocated sequentially this shouldn't
be a problem until we reach 2^32 open handles in the postmaster,
but a 64-bit value should be sent across as 64-bit, and not
zero out the top 32 bits.

Noted by Tom Lane.

13 years agoThe GiST scan algorithm uses LSNs to detect concurrent pages splits, but
Heikki Linnakangas [Tue, 16 Nov 2010 09:02:11 +0000 (11:02 +0200)]
The GiST scan algorithm uses LSNs to detect concurrent pages splits, but
temporary indexes are not WAL-logged. We used a constant LSN for temporary
indexes, on the assumption that we don't need to worry about concurrent page
splits in temporary indexes because they're only visible to the current
session. But that assumption is wrong, it's possible to insert rows and
split pages in the same session, while a scan is in progress. For example,
by opening a cursor and fetching some rows, and INSERTing new rows before
fetching some more.

Fix by generating fake increasing LSNs, used in place of real LSNs in
temporary GiST indexes.

13 years agoFix aboriginal mistake in plpython's set-returning-function support.
Tom Lane [Mon, 15 Nov 2010 19:27:00 +0000 (14:27 -0500)]
Fix aboriginal mistake in plpython's set-returning-function support.

We must stay in the function's SPI context until done calling the iterator
that returns the set result.  Otherwise, any attempt to invoke SPI features
in the python code called by the iterator will malfunction.  Diagnosis and
patch by Jan Urbanski, per bug report from Jean-Baptiste Quenot.

Back-patch to 8.2; there was no support for SRFs in previous versions of
plpython.

13 years agoAvoid spurious Hot Standby conflicts from btree delete records.
Simon Riggs [Mon, 15 Nov 2010 09:31:23 +0000 (09:31 +0000)]
Avoid spurious Hot Standby conflicts from btree delete records.
Similar conflicts were already avoided for related record types.
Massive over-caution resulted in a usability bug. Clear theoretical
basis for doing this is now confirmed by me.
Request to remove from Heikki (twice), over-caution by me.

13 years agoFix bug in cube picksplit algorithm.
Robert Haas [Mon, 15 Nov 2010 02:27:34 +0000 (21:27 -0500)]
Fix bug in cube picksplit algorithm.

Alexander Korotkov

13 years agoFix canAcceptConnections() bugs introduced by replication-related patches.
Tom Lane [Sun, 14 Nov 2010 20:57:42 +0000 (15:57 -0500)]
Fix canAcceptConnections() bugs introduced by replication-related patches.

We must not return any "okay to proceed" result code without having checked
for too many children, else we might fail later on when trying to add the
new child to one of the per-child state arrays.  It's not clear whether
this oversight explains Stefan Kaltenbrunner's recent report, but it could
certainly produce a similar symptom.

Back-patch to 8.4; the logic was not broken before that.

13 years agoAdd missing outfuncs.c support for struct InhRelation.
Tom Lane [Sat, 13 Nov 2010 05:34:50 +0000 (00:34 -0500)]
Add missing outfuncs.c support for struct InhRelation.

This is needed to support debug_print_parse, per report from Jon Nelson.
Cursory testing via the regression tests suggests we aren't missing
anything else.

13 years agoFix old oversight in const-simplification of COALESCE() expressions.
Tom Lane [Fri, 12 Nov 2010 20:14:51 +0000 (15:14 -0500)]
Fix old oversight in const-simplification of COALESCE() expressions.

Once we have found a non-null constant argument, there is no need to
examine additional arguments of the COALESCE.  The previous coding got it
right only if the constant was in the first argument position; otherwise
it tried to simplify following arguments too, leading to unexpected
behavior like this:

regression=# select coalesce(f1, 42, 1/0) from int4_tbl;
ERROR:  division by zero

It's a minor corner case, but a bug is a bug, so back-patch all the way.

13 years agodocs -> documentation
Peter Eisentraut [Fri, 12 Nov 2010 19:25:57 +0000 (21:25 +0200)]
docs -> documentation

13 years agoAdd replication_mode parameter in recovery.conf.
MasaoFujii [Fri, 12 Nov 2010 17:43:58 +0000 (02:43 +0900)]
Add replication_mode parameter in recovery.conf.

13 years agoProvide the capability to signal the reason when setting the latch.
MasaoFujii [Fri, 12 Nov 2010 14:23:21 +0000 (23:23 +0900)]
Provide the capability to signal the reason when setting the latch.

13 years agoReplace obsolete function named CheckClosedConnection with new one
MasaoFujii [Fri, 12 Nov 2010 14:20:36 +0000 (23:20 +0900)]
Replace obsolete function named CheckClosedConnection with new one
named ProcessStreamMsgs.

13 years agoAdd the definition of replication modes.
MasaoFujii [Fri, 12 Nov 2010 13:37:29 +0000 (22:37 +0900)]
Add the definition of replication modes.

13 years agoAdd missing support for removing foreign data wrapper / server privileges
Heikki Linnakangas [Fri, 12 Nov 2010 13:19:14 +0000 (15:19 +0200)]
Add missing support for removing foreign data wrapper / server privileges
belonging to a user at DROP OWNED BY. Foreign data wrappers and servers
don't do anything useful yet, which is why no-one has noticed, but since we
have them, seems prudent to fix this. Per report from Chetan Suttraway.
Backpatch to 9.0, 8.4 has the same problem but this patch didn't apply
there so I'm not going to bother.

13 years agoRemove a junk space.
MasaoFujii [Fri, 12 Nov 2010 13:20:37 +0000 (22:20 +0900)]
Remove a junk space.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Fri, 12 Nov 2010 13:10:15 +0000 (22:10 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Fri, 12 Nov 2010 13:09:44 +0000 (22:09 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoFix bug introduced by the recent patch to check that the checkpoint redo
Heikki Linnakangas [Thu, 11 Nov 2010 17:21:49 +0000 (19:21 +0200)]
Fix bug introduced by the recent patch to check that the checkpoint redo
location read from backup label file can be found: wasShutdown was set
incorrectly when a backup label file was found.

Jeff Davis, with a little tweaking by me.

13 years agoFix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.
Tom Lane [Wed, 10 Nov 2010 21:51:39 +0000 (16:51 -0500)]
Fix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.

This code was just plain wrong: what you got was not a line through the
given point but a line almost indistinguishable from the Y-axis, although
not truly vertical.  The only caller that tries to use this function with
m == DBL_MAX is dist_ps_internal for the case where the lseg is horizontal;
it would end up producing the distance from the given point to the place
where the lseg's line crosses the Y-axis.  That function is used by other
operators too, so there are several operators that could compute wrong
distances from a line segment to something else.  Per bug #5745 from
jindiax.

Back-patch to all supported branches.

13 years agoMention that pg_upgrade requires compatible 32/64-bit binaries.
Bruce Momjian [Wed, 10 Nov 2010 14:33:37 +0000 (14:33 +0000)]
Mention that pg_upgrade requires compatible 32/64-bit binaries.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Wed, 10 Nov 2010 13:19:41 +0000 (22:19 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMake startup process respond to signals to cancel waiting on latch.
Simon Riggs [Thu, 14 Oct 2010 18:15:26 +0000 (19:15 +0100)]
Make startup process respond to signals to cancel waiting on latch.
A tidy up for recently committed changes to startup latch.

Fujii Masao

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Wed, 10 Nov 2010 12:55:42 +0000 (21:55 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoDon't use __declspec (dllimport) for PGDLLEXPORT to reduce warnings
Itagaki Takahiro [Wed, 10 Nov 2010 03:17:43 +0000 (12:17 +0900)]
Don't use __declspec (dllimport) for PGDLLEXPORT to reduce warnings
by gcc version 4 on mingw and cygwin. We don't use dllexport here
because dllexport and dllwrap don't work well together.

13 years agoRepair memory leakage while ANALYZE-ing complex index expressions.
Tom Lane [Tue, 9 Nov 2010 16:28:18 +0000 (11:28 -0500)]
Repair memory leakage while ANALYZE-ing complex index expressions.

The general design of memory management in Postgres is that intermediate
results computed by an expression are not freed until the end of the tuple
cycle.  For expression indexes, ANALYZE has to re-evaluate each expression
for each of its sample rows, and it wasn't bothering to free intermediate
results until the end of processing of that index.  This could lead to very
substantial leakage if the intermediate results were large, as in a recent
example from Jakub Ouhrabka.  Fix by doing ResetExprContext for each sample
row.  This necessitates adding a datumCopy step to ensure that the final
expression value isn't recycled too.  Some quick testing suggests that this
change adds at worst about 10% to the time needed to analyze a table with
an expression index; which is annoying, but seems a tolerable price to pay
to avoid unexpected out-of-memory problems.

Back-patch to all supported branches.

13 years agoIn rewriteheap.c (used by VACUUM FULL and CLUSTER), calculate the tuple
Heikki Linnakangas [Tue, 9 Nov 2010 15:40:09 +0000 (17:40 +0200)]
In rewriteheap.c (used by VACUUM FULL and CLUSTER), calculate the tuple
length stored in the line pointer the same way it's calculated in the normal
heap_insert() codepath. As noted by Jeff Davis, the length stored by
raw_heap_insert() included padding but the one stored by the normal codepath
did not. While the mismatch seems to be harmless, inconsistency isn't good,
and the normal codepath has received a lot more testing over the years.

Backpatch to 8.3 where the heap rewrite code was introduced.

13 years agoplpython has plpy.Error instead of plpy.ERROR
Alvaro Herrera [Tue, 9 Nov 2010 14:00:56 +0000 (11:00 -0300)]
plpython has plpy.Error instead of plpy.ERROR

Author: Marti Raudsepp <marti@juffo.org>

13 years agoFix error handling in temp-file deletion with log_temp_files active.
Tom Lane [Tue, 9 Nov 2010 03:14:55 +0000 (22:14 -0500)]
Fix error handling in temp-file deletion with log_temp_files active.

The original coding in FileClose() reset the file-is-temp flag before
unlinking the file, so that if control came back through due to an error,
it wouldn't try to unlink the file twice.  This was correct when written,
but when the log_temp_files feature was added, the logging action was put
in between those two steps.  An error occurring during the logging action
--- such as a query cancel --- would result in the unlink not getting done
at all, as in recent report from Michael Glaesemann.

To fix this, make sure that we do both the stat and the unlink before doing
anything that could conceivably CHECK_FOR_INTERRUPTS.  There is a judgment
call here, which is which log message to emit first: if you can see only
one, which should it be?  I chose to log unlink failure at the risk of
losing the log_temp_files log message --- after all, if the unlink does
fail, the temp file is still there for you to see.

Back-patch to all versions that have log_temp_files.  The code was OK
before that.

13 years agoFix permanent memory leak in autovacuum launcher
Alvaro Herrera [Mon, 8 Nov 2010 21:35:42 +0000 (18:35 -0300)]
Fix permanent memory leak in autovacuum launcher

get_database_list was uselessly allocating its output data, along some
created along the way, in a permanent memory context.  This didn't
matter when autovacuum was a single, short-lived process, but now that
the launcher is permanent, it shows up as a permanent leak.

To fix, make get_database list allocate its output data in the caller's
context, which is in charge of freeing it when appropriate; and the
memory leaked by heap_beginscan et al is allocated in a throwaway
transaction context.

13 years agoAdd support for detecting register-stack overrun on IA64.
Tom Lane [Sun, 7 Nov 2010 02:59:09 +0000 (22:59 -0400)]
Add support for detecting register-stack overrun on IA64.

Per recent investigation, the register stack can grow faster than the
regular stack depending on compiler and choice of options.  To avoid
crashes we must check both stacks in check_stack_depth().

Back-patch to all supported versions.

13 years agoReduce recursion depth in recently-added regression test.
Tom Lane [Wed, 3 Nov 2010 17:41:53 +0000 (13:41 -0400)]
Reduce recursion depth in recently-added regression test.

Some buildfarm members fail the test with the original depth of 10 levels,
apparently because they are running at the minimum max_stack_depth setting
of 100kB and using ~ 10k per recursion level.  While it might be
interesting to try to figure out why they're eating so much stack, it isn't
likely that any fix for that would be back-patchable.  So just change the
test to recurse only 5 levels.  The extra levels don't prove anything
correctness-wise anyway.

13 years agoFix adjust_semi_join to be more cautious about clauseless joins.
Tom Lane [Tue, 2 Nov 2010 22:45:44 +0000 (18:45 -0400)]
Fix adjust_semi_join to be more cautious about clauseless joins.

It was reporting that these were fully indexed (hence cheap), when of
course they're the exact opposite of that.  I'm not certain if the case
would arise in practice, since a clauseless semijoin is hard to produce
in SQL, but if it did happen we'd make some dumb decisions.

13 years agoFix buffer overrun in pg_upgrade.
Tom Lane [Tue, 2 Nov 2010 21:31:54 +0000 (17:31 -0400)]
Fix buffer overrun in pg_upgrade.

Problem reported, and cause identified, by Hernan Gonzalez.

13 years agoEnsure an index that uses a whole-row Var still depends on its table.
Tom Lane [Tue, 2 Nov 2010 21:15:13 +0000 (17:15 -0400)]
Ensure an index that uses a whole-row Var still depends on its table.

We failed to record any dependency on the underlying table for an index
declared like "create index i on t (foo(t.*))".  This would create trouble
if the table were dropped without previously dropping the index.  To fix,
simplify some overly-cute code in index_create(), accepting the possibility
that sometimes the whole-table dependency will be redundant.  Also document
this hazard in dependency.c.  Per report from Kevin Grittner.

In passing, prevent a core dump in pg_get_indexdef() if the index's table
can't be found.  I came across this while experimenting with Kevin's
example.  Not sure it's a real issue when the catalogs aren't corrupt, but
might as well be cautious.

Back-patch to all supported versions.

13 years agoBootstrap WAL to begin at segment logid=0 logseg=1 (000000010000000000000001)
Heikki Linnakangas [Tue, 2 Nov 2010 09:23:43 +0000 (11:23 +0200)]
Bootstrap WAL to begin at segment logid=0 logseg=1 (000000010000000000000001)
rather than 0/0, so that we can safely use 0/0 as an invalid value. This is a
more future-proof fix for the corner-case bug in streaming replication that
was fixed yesterday. We had a similar corner-case bug with log/seg 0/0 back in
February as well. Avoiding 0/0 as a valid value should prevent bugs like that
in the future. Per Tom Lane's idea.

Back-patch to 9.0. Since this only affects bootstrapping, it makes no
difference to existing installations. We don't need to worry about the
bug in existing installations, because if you've managed to get past the
initial base backup already, you won't hit the bug in the future either.

13 years agoFix corner-case bug in tracking of latest removed WAL segment during
Heikki Linnakangas [Mon, 1 Nov 2010 07:56:45 +0000 (09:56 +0200)]
Fix corner-case bug in tracking of latest removed WAL segment during
streaming replication. We used log/seg 0/0 to indicate that no WAL segments
have been removed since startup, but 0/0 is a valid value for the very first
WAL segment after initdb. To make that disambiguous, store
(latest removed WAL segment + 1) in the global variable.

Per report from Matt Chesler, also reproduced by Greg Smith.

13 years agoFix plpgsql's handling of "simple" expression evaluation.
Tom Lane [Thu, 28 Oct 2010 17:01:01 +0000 (13:01 -0400)]
Fix plpgsql's handling of "simple" expression evaluation.

In general, expression execution state trees aren't re-entrantly usable,
since functions can store private state information in them.
For efficiency reasons, plpgsql tries to cache and reuse state trees for
"simple" expressions.  It can get away with that most of the time, but it
can fail if the state tree is dirty from a previous failed execution (as
in an example from Alvaro) or is being used recursively (as noted by me).

Fix by tracking whether a state tree is in use, and falling back to the
"non-simple" code path if so.  This results in a pretty considerable speed
hit when the non-simple path is taken, but the available alternatives seem
even more unpleasant because they add overhead in the simple path.  Per
idea from Heikki.

Back-patch to all supported branches.

13 years agoFix long-standing segfault when accept() or one of the calls made right
Heikki Linnakangas [Wed, 27 Oct 2010 17:03:00 +0000 (20:03 +0300)]
Fix long-standing segfault when accept() or one of the calls made right
after accepting a connection fails, and the server is compiled with GSSAPI
support. Report and patch by Alexander V. Chernikov, bug #5731.

13 years agoFix up some oversights in psql's Unicode-escape support.
Tom Lane [Wed, 27 Oct 2010 02:23:16 +0000 (22:23 -0400)]
Fix up some oversights in psql's Unicode-escape support.

Original patch failed to include new exclusive states in a switch that
needed to include them; and also was guilty of very fuzzy thinking
about how to handle error cases.  Per bug #5729 from Alan Choi.

13 years agoNote explicitly that hash indexes are also not replicated because they're not
Heikki Linnakangas [Tue, 26 Oct 2010 19:50:31 +0000 (22:50 +0300)]
Note explicitly that hash indexes are also not replicated because they're not
WAL-logged. Make the notice about the lack of WAL-logging more visible by
making it a <caution>. Also remove the false statement from hot standby
caveats section that hash indexes are not used during hot standby.