]> granicus.if.org Git - postgresql/log
postgresql
11 years agoChange plan caching to honor, not resist, changes in search_path.
Tom Lane [Fri, 25 Jan 2013 19:14:41 +0000 (14:14 -0500)]
Change plan caching to honor, not resist, changes in search_path.

In the initial implementation of plan caching, we saved the active
search_path when a plan was first cached, then reinstalled that path
anytime we needed to reparse or replan.  The idea of that was to try to
reselect the same referenced objects, in somewhat the same way that views
continue to refer to the same objects in the face of schema or name
changes.  Of course, that analogy doesn't bear close inspection, since
holding the search_path fixed doesn't cope with object drops or renames.
Moreover sticking with the old path seems to create more surprises than
it avoids.  So instead of doing that, consider that the cached plan depends
on search_path, and force reparse/replan if the active search_path is
different than it was when we last saved the plan.

This gets us fairly close to having "transparency" of plan caching, in the
sense that the cached statement acts the same as if you'd just resubmitted
the original query text for another execution.  There are still some corner
cases where this fails though: a new object added in the search path
schema(s) might capture a reference in the query text, but we'd not realize
that and force a reparse.  We might try to fix that in the future, but for
the moment it looks too expensive and complicated.

11 years agodoc: merge ecpg username/password example into C comment
Bruce Momjian [Fri, 25 Jan 2013 18:46:38 +0000 (13:46 -0500)]
doc:  merge ecpg username/password example into C comment

Backpatch to 9.2

per Tom Lane

11 years agodoc: adjust search_path secondary index mention
Bruce Momjian [Fri, 25 Jan 2013 18:45:09 +0000 (13:45 -0500)]
doc:  adjust search_path secondary index mention

per Tom Lane

11 years agodoc: split search_path index entries into separate secondaries
Bruce Momjian [Fri, 25 Jan 2013 17:48:51 +0000 (12:48 -0500)]
doc:  split search_path index entries into separate secondaries

Karl O. Pinc

11 years agoMake it easy to time out pg_isready, and make the default 3 seconds.
Robert Haas [Fri, 25 Jan 2013 17:01:45 +0000 (12:01 -0500)]
Make it easy to time out pg_isready, and make the default 3 seconds.

Along the way, add a missing line to the help message.

Phil Sorber, reviewed by Fujii Masao

11 years agodocs: In ecpg, clarify how username/password colon parameters are used
Bruce Momjian [Fri, 25 Jan 2013 16:18:44 +0000 (11:18 -0500)]
docs:  In ecpg, clarify how username/password colon parameters are used

Backpatch to 9.2.

Patch from Alan B

11 years agoAdd prosecdef to \df+ output.
Heikki Linnakangas [Fri, 25 Jan 2013 15:19:11 +0000 (17:19 +0200)]
Add prosecdef to \df+ output.

Jon Erdman, reviewed by Phil Sorber and Stephen Frost.

11 years agodoc: improve wording of "foreign data server" in file-fdw docs
Bruce Momjian [Fri, 25 Jan 2013 15:13:41 +0000 (10:13 -0500)]
doc:  improve wording of "foreign data server" in file-fdw docs

Backpatch to 9.2

Shigeru HANADA

11 years agoAdd some randomness to the choice of which GiST page to insert to.
Heikki Linnakangas [Fri, 25 Jan 2013 14:49:13 +0000 (16:49 +0200)]
Add some randomness to the choice of which GiST page to insert to.

When descending the tree for an insert, and there are multiple equally good
pages we could insert to, make the choice in random. Previously, we would
always choose the tuple with lowest offset number. That meant that when two
non-leaf pages overlap - in the extreme case they might have exactly the same
key - all but the first such page went unused. That wasn't optimal for space
usage; if you deleted some tuples from the non-first pages, the space would
never be reused.

With this patch, the other pages are sometimes chosen too, although there's
still a heavy bias towards low-offset tuples, so that we don't lose cache
locality when doing a lot of inserts with similar keys.

Original idea by Alexander Korotkov, although this patch version was written
by me and copy-edited by Tom Lane.

11 years agoMake pg_dump exclude unlogged table data on hot standby slaves
Magnus Hagander [Fri, 25 Jan 2013 08:44:14 +0000 (09:44 +0100)]
Make pg_dump exclude unlogged table data on hot standby slaves

Noted by Joe Van Dyk

11 years agoFix concat() and format() to handle VARIADIC-labeled arguments correctly.
Tom Lane [Fri, 25 Jan 2013 05:19:18 +0000 (00:19 -0500)]
Fix concat() and format() to handle VARIADIC-labeled arguments correctly.

Previously, the VARIADIC labeling was effectively ignored, but now these
functions act as though the array elements had all been given as separate
arguments.

Pavel Stehule

11 years agodoc: add mention of ssi read anomolies to mvcc docs
Bruce Momjian [Fri, 25 Jan 2013 02:44:54 +0000 (21:44 -0500)]
doc:  add mention of ssi read anomolies to mvcc docs

From Jeff Davis, modified by Kevin Grittner

11 years agodoc: correct sepgsql doc about permission checking of CASCADE
Bruce Momjian [Fri, 25 Jan 2013 02:21:50 +0000 (21:21 -0500)]
doc:  correct sepgsql doc about permission checking of CASCADE

Backpatch to 9.2.

Patch from Kohei KaiGai

11 years agoFix SPI documentation for new handling of ExecutorRun's count parameter.
Tom Lane [Thu, 24 Jan 2013 23:34:00 +0000 (18:34 -0500)]
Fix SPI documentation for new handling of ExecutorRun's count parameter.

Since 9.0, the count parameter has only limited the number of tuples
actually returned by the executor.  It doesn't affect the behavior of
INSERT/UPDATE/DELETE unless RETURNING is specified, because without
RETURNING, the ModifyTable plan node doesn't return control to execMain.c
for each tuple.  And we only check the limit at the top level.

While this behavioral change was unintentional at the time, discussion of
bug #6572 led us to the conclusion that we prefer the new behavior anyway,
and so we should just adjust the docs to match rather than change the code.
Accordingly, do that.  Back-patch as far as 9.0 so that the docs match the
code in each branch.

11 years agoUse correct output device for Windows prompts.
Andrew Dunstan [Thu, 24 Jan 2013 21:01:31 +0000 (16:01 -0500)]
Use correct output device for Windows prompts.

This ensures that mapping of non-ascii prompts
to the correct code page occurs.

Bug report and original patch from Alexander Law,
reviewed and reworked by Noah Misch.

Backpatch to all live branches.

11 years agopg_upgrade: detect stale postmaster.pid lock files
Bruce Momjian [Thu, 24 Jan 2013 20:20:11 +0000 (15:20 -0500)]
pg_upgrade:  detect stale postmaster.pid lock files

If the postmaster.pid lock file exists, try starting/stopping the
cluster to check if the lock file is valid.

Per request from Tom.

11 years agoRedefine HEAP_XMAX_IS_LOCKED_ONLY
Alvaro Herrera [Thu, 24 Jan 2013 19:04:48 +0000 (16:04 -0300)]
Redefine HEAP_XMAX_IS_LOCKED_ONLY

Tuples marked SELECT FOR UPDATE in a cluster that's later processed by
pg_upgrade would have a different infomask bit pattern than those
produced by 9.3dev; that bit pattern was being seen as "dead" by HEAD
(because they would fail the "is this tuple locked" test, and so the
visibility rules would thing they're updated, even though there's no
HEAP_UPDATED version of them).  In other words, some rows could silently
disappear after pg_upgrade.

With this new definition, those tuples become visible again.

This is breakage resulting from my commit 0ac5ad5134.

11 years agoUse the catversion to distinguish old/new clusters
Alvaro Herrera [Thu, 24 Jan 2013 15:25:48 +0000 (12:25 -0300)]
Use the catversion to distinguish old/new clusters

This makes 9.3 -> 9.3 upgrades work when they cross the commit that
added persistent multixacts; early 9.3 pg_controldata did not have the
required oldestMultiXact line, and so would fail to upgrade.

per Bruce Momjian

11 years agoDon't require oldestMultixact if server doesn't have it
Alvaro Herrera [Thu, 24 Jan 2013 14:53:15 +0000 (11:53 -0300)]
Don't require oldestMultixact if server doesn't have it

11 years agoMake output identical to pg_resetxlog's
Alvaro Herrera [Thu, 24 Jan 2013 14:52:53 +0000 (11:52 -0300)]
Make output identical to pg_resetxlog's

11 years agoFix rare missing cancellations in Hot Standby.
Simon Riggs [Thu, 24 Jan 2013 14:19:29 +0000 (14:19 +0000)]
Fix rare missing cancellations in Hot Standby.
The machinery around XLOG_HEAP2_CLEANUP_INFO failed
to correctly pass through the necessary information
on latestRemovedXid, avoiding cancellations in some
infrequent concurrent update/cleanup scenarios.

Backpatchable fix to 9.0

Detailed bug report and fix by Noah Misch,
backpatchable version by me.

11 years agopg_upgrade: report failed cluster name
Bruce Momjian [Thu, 24 Jan 2013 13:35:57 +0000 (08:35 -0500)]
pg_upgrade:  report failed cluster name

When pg_upgrade can't find required pg_controldata information, report
_which_ cluster is failing, with this message:

The %s cluster lacks some required control information:

11 years agoAlso fix rotation of csvlog on Windows.
Heikki Linnakangas [Thu, 24 Jan 2013 09:41:30 +0000 (11:41 +0200)]
Also fix rotation of csvlog on Windows.

Backpatch to 9.2, like the previous fix.

11 years agoDocs shouldn't say HOT Standby.
Simon Riggs [Thu, 24 Jan 2013 08:01:16 +0000 (08:01 +0000)]
Docs shouldn't say HOT Standby.
Not an acronym.

Jeff Janes

11 years agoFix failure to rotate postmaster log file for size reasons on Windows.
Tom Lane [Thu, 24 Jan 2013 03:08:01 +0000 (22:08 -0500)]
Fix failure to rotate postmaster log file for size reasons on Windows.

When we eliminated "unnecessary" wakeups of the syslogger process, we
broke size-based logfile rotation on Windows, because on that platform
data transfer is done in a separate thread.  While non-Windows platforms
would recheck the output file size after every log message, Windows only
did so when the control thread woke up for some other reason, which might
be quite infrequent.  Per bug #7814 from Tsunezumi.  Back-patch to 9.2
where the problem was introduced.

Jeff Janes

11 years agoisolationtester: add a few fflush(stderr) calls
Alvaro Herrera [Wed, 23 Jan 2013 16:30:14 +0000 (13:30 -0300)]
isolationtester: add a few fflush(stderr) calls

The lack of them is causing failures in some BF members.

Per Andrew Dunstan.

11 years agoClarify that connection parameters aren't totally meaningless for PQping.
Robert Haas [Wed, 23 Jan 2013 16:05:15 +0000 (11:05 -0500)]
Clarify that connection parameters aren't totally meaningless for PQping.

Per discussion with Phil Sorber.

11 years agopg_isready
Robert Haas [Wed, 23 Jan 2013 15:58:04 +0000 (10:58 -0500)]
pg_isready

New command-line utility to test whether a server is ready to
accept connections.

Phil Sorber, reviewed by Michael Paquier and Peter Eisentraut

11 years agoImprove concurrency of foreign key locking
Alvaro Herrera [Wed, 23 Jan 2013 15:04:59 +0000 (12:04 -0300)]
Improve concurrency of foreign key locking

This patch introduces two additional lock modes for tuples: "SELECT FOR
KEY SHARE" and "SELECT FOR NO KEY UPDATE".  These don't block each
other, in contrast with already existing "SELECT FOR SHARE" and "SELECT
FOR UPDATE".  UPDATE commands that do not modify the values stored in
the columns that are part of the key of the tuple now grab a SELECT FOR
NO KEY UPDATE lock on the tuple, allowing them to proceed concurrently
with tuple locks of the FOR KEY SHARE variety.

Foreign key triggers now use FOR KEY SHARE instead of FOR SHARE; this
means the concurrency improvement applies to them, which is the whole
point of this patch.

The added tuple lock semantics require some rejiggering of the multixact
module, so that the locking level that each transaction is holding can
be stored alongside its Xid.  Also, multixacts now need to persist
across server restarts and crashes, because they can now represent not
only tuple locks, but also tuple updates.  This means we need more
careful tracking of lifetime of pg_multixact SLRU files; since they now
persist longer, we require more infrastructure to figure out when they
can be removed.  pg_upgrade also needs to be careful to copy
pg_multixact files over from the old server to the new, or at least part
of multixact.c state, depending on the versions of the old and new
servers.

Tuple time qualification rules (HeapTupleSatisfies routines) need to be
careful not to consider tuples with the "is multi" infomask bit set as
being only locked; they might need to look up MultiXact values (i.e.
possibly do pg_multixact I/O) to find out the Xid that updated a tuple,
whereas they previously were assured to only use information readily
available from the tuple header.  This is considered acceptable, because
the extra I/O would involve cases that would previously cause some
commands to block waiting for concurrent transactions to finish.

Another important change is the fact that locking tuples that have
previously been updated causes the future versions to be marked as
locked, too; this is essential for correctness of foreign key checks.
This causes additional WAL-logging, also (there was previously a single
WAL record for a locked tuple; now there are as many as updated copies
of the tuple there exist.)

With all this in place, contention related to tuples being checked by
foreign key rules should be much reduced.

As a bonus, the old behavior that a subtransaction grabbing a stronger
tuple lock than the parent (sub)transaction held on a given tuple and
later aborting caused the weaker lock to be lost, has been fixed.

Many new spec files were added for isolation tester framework, to ensure
overall behavior is sane.  There's probably room for several more tests.

There were several reviewers of this patch; in particular, Noah Misch
and Andres Freund spent considerable time in it.  Original idea for the
patch came from Simon Riggs, after a problem report by Joel Jacobson.
Most code is from me, with contributions from Marti Raudsepp, Alexander
Shulgin, Noah Misch and Andres Freund.

This patch was discussed in several pgsql-hackers threads; the most
important start at the following message-ids:
AANLkTimo9XVcEzfiBR-ut3KVNDkjm2Vxh+t8kAmWjPuv@mail.gmail.com
1290721684-sup-3951@alvh.no-ip.org
1294953201-sup-2099@alvh.no-ip.org
1320343602-sup-2290@alvh.no-ip.org
1339690386-sup-8927@alvh.no-ip.org
4FE5FF020200002500048A3D@gw.wicourts.gov
4FEAB90A0200002500048B7D@gw.wicourts.gov

11 years agoFurther documentation tweaks for event triggers.
Robert Haas [Wed, 23 Jan 2013 14:17:20 +0000 (09:17 -0500)]
Further documentation tweaks for event triggers.

Per discussion between Dimitri Fontaine, myself, and others.

11 years agoUpdate comments and output for event_trigger regression test.
Robert Haas [Wed, 23 Jan 2013 11:46:27 +0000 (06:46 -0500)]
Update comments and output for event_trigger regression test.

11 years agoImplement pg_unreachable() on MSVC.
Heikki Linnakangas [Wed, 23 Jan 2013 10:47:00 +0000 (12:47 +0200)]
Implement pg_unreachable() on MSVC.

11 years agoGitignore vcxproj files.
Andrew Dunstan [Wed, 23 Jan 2013 08:44:37 +0000 (03:44 -0500)]
Gitignore vcxproj files.

Per request from Craig Ringer.

11 years agoFix more issues with cascading replication and timeline switches.
Heikki Linnakangas [Wed, 23 Jan 2013 08:01:04 +0000 (10:01 +0200)]
Fix more issues with cascading replication and timeline switches.

When a standby server follows the master using WAL archive, and it chooses
a new timeline (recovery_target_timeline='latest'), it only fetches the
timeline history file for the chosen target timeline, not any other history
files that might be missing from pg_xlog. For example, if the current
timeline is 2, and we choose 4 as the new recovery target timeline, the
history file for timeline 3 is not fetched, even if it's part of this
server's history. That's enough for the standby itself - the history file
for timeline 4 includes timeline 3 as well - but if a cascading standby
server wants to recover to timeline 3, it needs the history file. To fix,
when a new recovery target timeline is chosen, try to copy any missing
history files from the archive to pg_xlog between the old and new target
timeline.

A second similar issue was with the WAL files. When a standby recovers from
archive, and it reaches a segment that contains a switch to a new timeline,
recovery fetches only the WAL file labelled with the new timeline's ID. The
file from the new timeline contains a copy of the WAL from the old timeline
up to the point where the switch happened, and recovery recovers it from the
new file. But in streaming replication, walsender only tries to read it
from the old timeline's file. To fix, change walsender to read it from the
new file, so that it behaves the same as recovery in that sense, and doesn't
try to open the possibly nonexistent file with the old timeline's ID.

11 years agopg_upgrade: remove --single-transaction usage
Bruce Momjian [Wed, 23 Jan 2013 03:27:13 +0000 (22:27 -0500)]
pg_upgrade:  remove --single-transaction usage

With AtEOXact applied, --single-transaction makes pg_restore slower, and
has the potential to require lock table configuration, so remove the
argument.

Per suggestion from Tom.

11 years agodoc: Fix declared number of columns in table
Peter Eisentraut [Wed, 23 Jan 2013 02:47:49 +0000 (21:47 -0500)]
doc: Fix declared number of columns in table

This was broken in 841a5150c575ccd89e4b03aec66eeeefb21f3cbe.

11 years agoFix a few small bugs in yesterday's event trigger patch.
Robert Haas [Wed, 23 Jan 2013 02:37:01 +0000 (21:37 -0500)]
Fix a few small bugs in yesterday's event trigger patch.

Dimitri Fontaine

11 years agoFix CREATE EVENT TRIGGER syntax synopsis in documentation.
Robert Haas [Tue, 22 Jan 2013 23:52:26 +0000 (18:52 -0500)]
Fix CREATE EVENT TRIGGER syntax synopsis in documentation.

Dimitri Fontaine, per a report from Thom Brown

11 years agoTypo fixes.
Robert Haas [Tue, 22 Jan 2013 03:35:32 +0000 (22:35 -0500)]
Typo fixes.

Noted by Thom Brown.

11 years agoAdd infrastructure for storing a VARIADIC ANY function's VARIADIC flag.
Tom Lane [Tue, 22 Jan 2013 01:25:26 +0000 (20:25 -0500)]
Add infrastructure for storing a VARIADIC ANY function's VARIADIC flag.

Originally we didn't bother to mark FuncExprs with any indication whether
VARIADIC had been given in the source text, because there didn't seem to be
any need for it at runtime.  However, because we cannot fold a VARIADIC ANY
function's arguments into an array (since they're not necessarily all the
same type), we do actually need that information at runtime if VARIADIC ANY
functions are to respond unsurprisingly to use of the VARIADIC keyword.
Add the missing field, and also fix ruleutils.c so that VARIADIC ANY
function calls are dumped properly.

Extracted from a larger patch that also fixes concat() and format() (the
only two extant VARIADIC ANY functions) to behave properly when VARIADIC is
specified.  This portion seems appropriate to review and commit separately.

Pavel Stehule

11 years agoAdd ddl_command_end support for event triggers.
Robert Haas [Mon, 21 Jan 2013 23:00:24 +0000 (18:00 -0500)]
Add ddl_command_end support for event triggers.

Dimitri Fontaine, with slight changes by me

11 years agoRefactor ALTER some-obj RENAME implementation
Alvaro Herrera [Mon, 21 Jan 2013 15:06:41 +0000 (12:06 -0300)]
Refactor ALTER some-obj RENAME implementation

Remove duplicate implementations of catalog munging and miscellaneous
privilege checks.  Instead rely on already existing data in
objectaddress.c to do the work.

Author: KaiGai Kohei, changes by me
Reviewed by: Robert Haas, Ălvaro Herrera, Dimitri Fontaine

11 years agoFix one-byte buffer overrun in PQprintTuples().
Tom Lane [Mon, 21 Jan 2013 04:43:46 +0000 (23:43 -0500)]
Fix one-byte buffer overrun in PQprintTuples().

This bug goes back to the original Postgres95 sources.  Its significance
to modern PG versions is marginal, since we have not used PQprintTuples()
internally in a very long time, and it doesn't seem to have ever been
documented either.  Still, it *is* exposed to client apps, so somebody
out there might possibly be using it.

Xi Wang

11 years agoFix error-checking typo in check_TSCurrentConfig().
Tom Lane [Mon, 21 Jan 2013 04:09:35 +0000 (23:09 -0500)]
Fix error-checking typo in check_TSCurrentConfig().

The code failed to detect an out-of-memory failure.

Xi Wang

11 years agodoc: Fix syntax of a URL
Peter Eisentraut [Mon, 21 Jan 2013 00:36:30 +0000 (19:36 -0500)]
doc: Fix syntax of a URL

Leading white space before the "http:" is apparently treated as a
relative link at least by some browsers.

11 years agoFix an O(N^2) performance issue for sessions modifying many relations.
Tom Lane [Sun, 20 Jan 2013 18:44:49 +0000 (13:44 -0500)]
Fix an O(N^2) performance issue for sessions modifying many relations.

AtEOXact_RelationCache() scanned the entire relation cache at the end of
any transaction that created a new relation or assigned a new relfilenode.
Thus, clients such as pg_restore had an O(N^2) performance problem that
would start to be noticeable after creating 10000 or so tables.  Since
typically only a small number of relcache entries need any cleanup, we
can fix this by keeping a small list of their OIDs and doing hash_searches
for them.  We fall back to the full-table scan if the list overflows.

Ideally, the maximum list length would be set at the point where N
hash_searches would cost just less than the full-table scan.  Some quick
experimentation says that point might be around 50-100; I (tgl)
conservatively set MAX_EOXACT_LIST = 32.  For the case that we're worried
about here, which is short single-statement transactions, it's unlikely
there would ever be more than about a dozen list entries anyway; so it's
probably not worth being too tense about the value.

We could avoid the hash_searches by instead keeping the target relcache
entries linked into a list, but that would be noticeably more complicated
and bug-prone because of the need to maintain such a list in the face of
relcache entry drops.  Since a relcache entry can only need such cleanup
after a somewhat-heavyweight filesystem operation, trying to save a
hash_search per cleanup doesn't seem very useful anyway --- it's the scan
over all the not-needing-cleanup entries that we wish to avoid here.

Jeff Janes, reviewed and tweaked a bit by Tom Lane

11 years agoClarify that streaming replication can be both async and sync
Magnus Hagander [Sun, 20 Jan 2013 15:10:12 +0000 (16:10 +0100)]
Clarify that streaming replication can be both async and sync

Josh Kupershmidt

11 years agoUse SET TRANSACTION READ ONLY in pg_dump, if server supports it.
Tom Lane [Sat, 19 Jan 2013 22:56:40 +0000 (17:56 -0500)]
Use SET TRANSACTION READ ONLY in pg_dump, if server supports it.

This currently does little except serve as documentation.  (The one case
where it has a performance benefit, SERIALIZABLE mode in 9.1 and up, was
already using READ ONLY mode.)  However, it's possible that it might have
performance benefits in future, and in any case it seems like good
practice since it would catch any accidentally non-read-only operations.

Pavan Deolasee

11 years agoModernize string literal syntax in tutorial example.
Tom Lane [Sat, 19 Jan 2013 22:20:32 +0000 (17:20 -0500)]
Modernize string literal syntax in tutorial example.

Un-double the backslashes in the LIKE patterns, since
standard_conforming_strings is now the default.  Just to be sure, include
a command to set standard_conforming_strings to ON in the example.

Back-patch to 9.1, where standard_conforming_strings became the default.

Josh Kupershmidt, reviewed by Jeff Janes

11 years agoMake pgxs build executables with the right suffix.
Andrew Dunstan [Sat, 19 Jan 2013 19:54:29 +0000 (14:54 -0500)]
Make pgxs build executables with the right suffix.

Complaint and patch from ZoltĂĄn BöszörmĂ©nyi.

When cross-compiling, the native make doesn't know
about the Windows .exe suffix, so it only builds with
it when explicitly told to do so.

The native make will not see the link between the target
name and the built executable, and might this do unnecesary
work, but that's a bigger problem than this one, if in fact
we consider it a problem at all.

Back-patch to all live branches.

11 years agolibpq doc: Clarify what commands return PGRES_TUPLES_OK
Peter Eisentraut [Sat, 19 Jan 2013 03:36:54 +0000 (22:36 -0500)]
libpq doc: Clarify what commands return PGRES_TUPLES_OK

The old text claimed that INSERT and UPDATE always return
PGRES_COMMAND_OK, but INSERT/UPDATE with RETURNING return
PGRES_TUPLES_OK.

Josh Kupershmidt

11 years agoProtect against SnapshotNow race conditions in pg_tablespace scans.
Tom Lane [Fri, 18 Jan 2013 23:06:20 +0000 (18:06 -0500)]
Protect against SnapshotNow race conditions in pg_tablespace scans.

Use of SnapshotNow is known to expose us to race conditions if the tuple(s)
being sought could be updated by concurrently-committing transactions.
CREATE DATABASE and DROP DATABASE are particularly exposed because they do
heavyweight filesystem operations during their scans of pg_tablespace,
so that the scans run for a very long time compared to most.  Furthermore,
the potential consequences of a missed or twice-visited row are nastier
than average:

* createdb() could fail with a bogus "file already exists" error, or
  silently fail to copy one or more tablespace's worth of files into the
  new database.

* remove_dbtablespaces() could miss one or more tablespaces, thus failing
  to free filesystem space for the dropped database.

* check_db_file_conflict() could likewise miss a tablespace, leading to an
  OID conflict that could result in data loss either immediately or in
  future operations.  (This seems of very low probability, though, since a
  duplicate database OID would be unlikely to start with.)

Hence, it seems worth fixing these three places to use MVCC snapshots, even
though this will someday be superseded by a generic solution to SnapshotNow
race conditions.

Back-patch to all active branches.

Stephen Frost and Tom Lane

11 years agoRename new latex longtable function name, for consistency
Bruce Momjian [Fri, 18 Jan 2013 19:02:53 +0000 (14:02 -0500)]
Rename new latex longtable function name, for consistency

11 years agoUnbreak lock conflict detection for Hot Standby.
Robert Haas [Fri, 18 Jan 2013 16:49:52 +0000 (11:49 -0500)]
Unbreak lock conflict detection for Hot Standby.

This got broken in the original fast-path locking patch, because
I failed to account for the fact that Hot Standby startup process
might take a strong relation lock on a relation in a database to
which it is not bound, and confused MyDatabaseId with the database
ID of the relation being locked.

Report and diagnosis by Andres Freund.  Final form of patch by me.

11 years agoImprove pg_upgrade error report
Bruce Momjian [Fri, 18 Jan 2013 14:26:18 +0000 (09:26 -0500)]
Improve pg_upgrade error report

If the cluster alignments don't match, output this suggestion:

Likely one cluster is a 32-bit install, the other 64-bit

11 years agoFix off-by-one bug in xlog reading logic
Alvaro Herrera [Fri, 18 Jan 2013 14:17:18 +0000 (11:17 -0300)]
Fix off-by-one bug in xlog reading logic

Bug reported by Michael Paquier

Author: Andres Freund

11 years agopsql latex fixes
Bruce Momjian [Fri, 18 Jan 2013 13:30:31 +0000 (08:30 -0500)]
psql latex fixes

Remove extra line at bottom of table for new 'latex' mode border=3.
Also update 'latex'-longtable 'tableattr' docs to say
'whitespace-separated' instead of 'space'.

11 years agoNow that START_REPLICATION returns the next timeline's ID after reaching end
Heikki Linnakangas [Fri, 18 Jan 2013 09:48:29 +0000 (11:48 +0200)]
Now that START_REPLICATION returns the next timeline's ID after reaching end
of timeline, take advantage of that in walreceiver.

Startup process is still in control of choosign the target timeline, by
scanning the timeline history files present in pg_xlog, but walreceiver now
uses the next timeline's ID to fetch its history file immediately after it
has finished streaming the old timeline. Before, the standby would first try
to restart streaming on the old timeline, which fetches the missing timeline
history file as a side-effect, and only then restart from the new timeline.
This patch eliminates the extra iteration, which speeds up the timeline
switch and reduces the noise in the log caused by the extra restart on the
old timeline.

11 years agoUse the right timeline when beginning to stream from master.
Heikki Linnakangas [Fri, 18 Jan 2013 09:41:36 +0000 (11:41 +0200)]
Use the right timeline when beginning to stream from master.

The xlogreader refactoring broke the logic to decide which timeline to start
streaming from. XLogPageRead() uses the timeline history to check which
timeline the requested WAL position falls into. However, after the
refactoring, XLogPageRead() is always first called with the first page in
the segment, to verify the segment header, and only then with the actual WAL
position we're interested in. That first read of the segment's header made
XLogPageRead() to always start streaming from the old timeline containing
the segment header, not the timeline containing the actual record, if there
was a timeline switch within the segment.

I thought I fixed this yesterday, but that fix was too narrow and only fixed
this for the corner-case that the timeline switch happened in the first page
of the segment. To fix this more robustly, pass explicitly the position of
the record we're actually interested in to XLogPageRead, and use that to
decide which timeline to read from, rather than deduce it from the page and
offset.

Per report from Fujii Masao.

11 years agoWhen xlogreader asks the callback function to read a page, make sure we
Heikki Linnakangas [Thu, 17 Jan 2013 21:45:37 +0000 (23:45 +0200)]
When xlogreader asks the callback function to read a page, make sure we
get a large enough part of the page to include the beginning of the next
record we're interested in. The XLogPageRead callback uses the requested
length to decide which timeline to stream WAL from, and if the first call
is short, and the page contains a timeline switch, we'll repeatedly try
to stream that page from the old timeline, and never get across the
timeline switch.

11 years agoI added a result set to START_STREAMING command, but neglected walreceiver.
Heikki Linnakangas [Thu, 17 Jan 2013 21:12:30 +0000 (23:12 +0200)]
I added a result set to START_STREAMING command, but neglected walreceiver.

The patch to allow pg_receivexlog to switch timeline added a result set
after copy has ended in START_STREAMING command, to return the next
timeline's ID to the client. But walreceived didn't get the memo, and threw
an error on the unexpected result set. Fix.

11 years agoAccelerate end-of-transaction dropping of relations
Alvaro Herrera [Thu, 17 Jan 2013 18:55:10 +0000 (15:55 -0300)]
Accelerate end-of-transaction dropping of relations

When relations are dropped, at end of transaction we need to remove the
files and clean the buffer pool of buffers containing pages of those
relations.  Previously we would scan the buffer pool once per relation
to clean up buffers.  When there are many relations to drop, the
repeated scans make this process slow; so we now instead pass a list of
relations to drop and scan the pool once, checking each buffer against
the passed list.  When the number of relations is larger than a
threshold (which as of this patch is being set to 20 relations) we sort
the array before starting, and bsearch the array; when it's smaller, we
simply scan the array linearly each time, because that's faster.  The
exact optimal threshold value depends on many factors, but the
difference is not likely to be significant enough to justify making it
user-settable.

This has been measured to be a significant win (a 15x win when dropping
100,000 relations; an extreme case, but reportedly a real one).

Author: Tomas Vondra, some tweaks by me
Reviewed by: Robert Haas, Shigeru Hanada, Andres Freund, Ălvaro Herrera

11 years agoMake pg_receivexlog and pg_basebackup -X stream work across timeline switches.
Heikki Linnakangas [Thu, 17 Jan 2013 18:23:00 +0000 (20:23 +0200)]
Make pg_receivexlog and pg_basebackup -X stream work across timeline switches.

This mirrors the changes done earlier to the server in standby mode. When
receivelog reaches the end of a timeline, as reported by the server, it
fetches the timeline history file of the next timeline, and restarts
streaming from the new timeline by issuing a new START_STREAMING command.

When pg_receivexlog crosses a timeline, it leaves the .partial suffix on the
last segment on the old timeline. This helps you to tell apart a partial
segment left in the directory because of a timeline switch, and a completed
segment. If you just follow a single server, it won't make a difference, but
it can be significant in more complicated scenarios where new WAL is still
generated on the old timeline.

This includes two small changes to the streaming replication protocol:
First, when you reach the end of timeline while streaming, the server now
sends the TLI of the next timeline in the server's history to the client.
pg_receivexlog uses that as the next timeline, so that it doesn't need to
parse the timeline history file like a standby server does. Second, when
BASE_BACKUP command sends the begin and end WAL positions, it now also sends
the timeline IDs corresponding the positions.

11 years agoImprove memory space management in tuplesort and tuplestore.
Tom Lane [Thu, 17 Jan 2013 18:12:14 +0000 (13:12 -0500)]
Improve memory space management in tuplesort and tuplestore.

The code originally just doubled the size of the tuple-pointer array so
long as that would fit in allowedMem.  This could result in failing to use
as much as half of allowedMem, if (as is typical) the last doubling attempt
didn't quite fit.  Worse, we might double the array size but be unable to
use most of the added slots, because there was no room left within the
allowedMem limit for tuples the slots should point to.  To fix, double only
so long as we've used less than half of allowedMem in total.  Then do one
more array enlargement, but scale it based on total memory consumption so
far.  This will work nicely as long as the average tuple size is reasonably
stable, and in any case should be better than the old method.

This change will result in large sort operations consuming a larger
fraction of work_mem than they typically did in the past.  The release
notes should mention that users may want to revisit their work_mem
settings, if they'd tuned those settings based on the old behavior of
sorting.

Jeff Janes, reviewed by Peter Geoghegan and Robert Haas

11 years agoFix a couple of error-handling bugs in the xlogreader patch.
Heikki Linnakangas [Thu, 17 Jan 2013 17:05:19 +0000 (19:05 +0200)]
Fix a couple of error-handling bugs in the xlogreader patch.

XLogReadRecord should reset its state on every error, to make sure it
re-reads the page on next call. It was inconsistent in that some errors did
that, but some did not.

In ReadRecord(), don't give up on an error if we're in standby mode. The
loop was set up to retry, but the checks within the loop broke out of the
loop on any error.

Andres Freund, with some tweaking by me.

11 years agoAdd a latex-longtable output format to psql
Bruce Momjian [Thu, 17 Jan 2013 16:39:38 +0000 (11:39 -0500)]
Add a latex-longtable output format to psql

latex longtable is more powerful than the 'tabular' output format
'latex' uses.  Also add border=3 support to 'latex'.

11 years agoSilence compiler warnings
Magnus Hagander [Thu, 17 Jan 2013 15:10:16 +0000 (16:10 +0100)]
Silence compiler warnings

11 years agoMake GiST indexes on-disk compatible with 9.2 again.
Heikki Linnakangas [Thu, 17 Jan 2013 14:35:46 +0000 (16:35 +0200)]
Make GiST indexes on-disk compatible with 9.2 again.

The patch that turned XLogRecPtr into a uint64 inadvertently changed the
on-disk format of GiST indexes, because the NSN field in the GiST page
opaque is an XLogRecPtr. That breaks pg_upgrade. Revert the format of that
field back to the two-field struct that XLogRecPtr was before. This is the
same we did to LSNs in the page header to avoid changing on-disk format.

Bump catversion, as this invalidates any existing GiST indexes built on
9.3devel.

11 years agoBase the default SSL ciphers on DEFAULT instead of ALL
Magnus Hagander [Thu, 17 Jan 2013 14:04:44 +0000 (15:04 +0100)]
Base the default SSL ciphers on DEFAULT instead of ALL

It's better to start from what the OpenSSL people consider a good
default and then remove insecure things (low encryption, exportable
encryption and md5 at this point) from that, instead of starting
from everything that exists and remove from that. We trust the
OpenSSL people to make good choices about what the default is.

11 years agoMake size-output fixed length in pg_basebackup verbose mode
Magnus Hagander [Thu, 17 Jan 2013 13:43:33 +0000 (14:43 +0100)]
Make size-output fixed length in pg_basebackup verbose mode

This way the line doesn't shift right as the amount of data processed
increases.

11 years agoTruncate filenames in the leadning end in pg_basebackup verbose output
Magnus Hagander [Thu, 17 Jan 2013 13:38:49 +0000 (14:38 +0100)]
Truncate filenames in the leadning end in pg_basebackup verbose output

When truncating at the end, like before, the output would often end up
just showing the path instead of the filename.

Also increase the length of the filename by 5, which still keeps us at
less than 80 characters in most outputs.

11 years agoSupport multiple -t/--table arguments for more commands
Magnus Hagander [Thu, 17 Jan 2013 10:24:47 +0000 (11:24 +0100)]
Support multiple -t/--table arguments for more commands

On top of the previous support in pg_dump, add support to specify
multiple tables (by using the -t option multiple times) to
pg_restore, clsuterdb, reindexdb and vacuumdb.

Josh Kupershmidt, reviewed by Karl O. Pinc

11 years agoGet rid of pg_dump's README
Peter Eisentraut [Thu, 17 Jan 2013 04:49:54 +0000 (23:49 -0500)]
Get rid of pg_dump's README

It was largely full of outdated and incorrect information.  Move the few
notes which were still relevant into header comments of pg_backup_tar.c
and pg_dumpall.c.

Josh Kupershmidt

11 years agoSplit out XLog reading as an independent facility
Alvaro Herrera [Wed, 16 Jan 2013 19:12:53 +0000 (16:12 -0300)]
Split out XLog reading as an independent facility

This new facility can not only be used by xlog.c to carry out crash
recovery, but also by external programs.  By supplying a function to
read XLog pages from somewhere, all the WAL reading can be used for
completely different purposes.

For the standard backend use, the behavior should be pretty much the
same as previously.  As for non-backend programs, an hypothetical
pg_xlogdump program is now closer to reality, but some more backend
support is still necessary.

This patch was originally submitted by Andres Freund in a different
form, but Heikki Linnakangas opted for and authored another design of
the concept.  Andres has advanced the patch since Heikki's initial
version.  Review and some (mostly cosmetics) changes by me.

11 years agoMake \? help message more clear when not connected.
Heikki Linnakangas [Tue, 15 Jan 2013 20:21:03 +0000 (22:21 +0200)]
Make \? help message more clear when not connected.

On second thought, "none" could mislead to think that you're connected a
database with that name. Duplicate the whole string, so that it can be
more easily translated. In back-branches, thought, just use an empty string
in place of the database name, to avoid adding a translatable string.

11 years agoDon't pass NULL to fprintf, if not currently connected to a database.
Heikki Linnakangas [Tue, 15 Jan 2013 16:54:03 +0000 (18:54 +0200)]
Don't pass NULL to fprintf, if not currently connected to a database.

Backpatch all the way to 8.3. Fixes bug #7811, per report and diagnosis by
Meng Qingzhong.

11 years agoRework order of checks in ALTER / SET SCHEMA
Alvaro Herrera [Tue, 15 Jan 2013 16:23:43 +0000 (13:23 -0300)]
Rework order of checks in ALTER / SET SCHEMA

When attempting to move an object into the schema in which it already
was, for most objects classes we were correctly complaining about
exactly that ("object is already in schema"); but for some other object
classes, such as functions, we were instead complaining of a name
collision ("object already exists in schema").  The latter is wrong and
misleading, per complaint from Robert Haas in
CA+TgmoZ0+gNf7RDKRc3u5rHXffP=QjqPZKGxb4BsPz65k7qnHQ@mail.gmail.com

To fix, refactor the way these checks are done.  As a bonus, the
resulting code is smaller and can also share some code with Rename
cases.

While at it, remove use of getObjectDescriptionOids() in error messages.
These are normally disallowed because of translatability considerations,
but this one had slipped through since 9.1.  (Not sure that this is
worth backpatching, though, as it would create some untranslated
messages in back branches.)

This is loosely based on a patch by KaiGai Kohei, heavily reworked by
me.

11 years agoGive a proper error message if connecting to incompatible server.
Heikki Linnakangas [Tue, 15 Jan 2013 13:45:52 +0000 (15:45 +0200)]
Give a proper error message if connecting to incompatible server.

The WAL streaming message format changed in 9.3, so 9.3 pg_basebackup or
pg_receivelog won't work against older servers.

11 years agoFix hash_update_hash_key() to handle same-bucket case correctly.
Tom Lane [Tue, 15 Jan 2013 02:57:15 +0000 (21:57 -0500)]
Fix hash_update_hash_key() to handle same-bucket case correctly.

Original coding would corrupt the hashtable if the item being updated was
at the end of its bucket chain and the new hash key hashed to that same
bucket.  Diagnosis and fix by Heikki Linnakangas.

11 years agoReturn value of lseek() can be negative on failure.
Heikki Linnakangas [Mon, 14 Jan 2013 22:42:37 +0000 (00:42 +0200)]
Return value of lseek() can be negative on failure.

Because the return value of lseek() was assigned to an unsigned size_t
variable, we'd fail to notice an error return code -1. Compiler gave a
warning about this.

Andres Freund

11 years agoFix obsolete SQL syntax in comment.
Tom Lane [Mon, 14 Jan 2013 20:48:12 +0000 (15:48 -0500)]
Fix obsolete SQL syntax in comment.

This was legal back in the days of add_missing_from, though perhaps
never good style.  It's not legal anymore ...

Jan UrbaƄski

11 years agoReject out-of-range dates in to_date().
Tom Lane [Mon, 14 Jan 2013 20:19:48 +0000 (15:19 -0500)]
Reject out-of-range dates in to_date().

Dates outside the supported range could be entered, but would not print
reasonably, and operations such as conversion to timestamp wouldn't behave
sanely either.  Since this has the potential to result in undumpable table
data, it seems worth back-patching.

Hitoshi Harada

11 years agoAdd new timezone abbrevation "FET".
Tom Lane [Mon, 14 Jan 2013 19:45:40 +0000 (14:45 -0500)]
Add new timezone abbrevation "FET".

This seems to have been invented in 2011 to represent GMT+3, non daylight
savings rules, as now used in Europe/Kaliningrad and Europe/Minsk.
There are no conflicts so might as well add it to the Default list.
Per bug #7804 from Ruslan Izmaylov.

11 years agoRemove spurious space
Alvaro Herrera [Fri, 11 Jan 2013 15:21:13 +0000 (12:21 -0300)]
Remove spurious space

Andres Freund

11 years agoPrevent very-low-probability PANIC during PREPARE TRANSACTION.
Tom Lane [Mon, 14 Jan 2013 03:19:47 +0000 (22:19 -0500)]
Prevent very-low-probability PANIC during PREPARE TRANSACTION.

The code in PostPrepare_Locks supposed that it could reassign locks to
the prepared transaction's dummy PGPROC by deleting the PROCLOCK table
entries and immediately creating new ones.  This was safe when that code
was written, but since we invented partitioning of the shared lock table,
it's not safe --- another process could steal away the PROCLOCK entry in
the short interval when it's on the freelist.  Then, if we were otherwise
out of shared memory, PostPrepare_Locks would have to PANIC, since it's
too late to back out of the PREPARE at that point.

Fix by inventing a dynahash.c function to atomically update a hashtable
entry's key.  (This might possibly have other uses in future.)

This is an ancient bug that in principle we ought to back-patch, but the
odds of someone hitting it in the field seem really tiny, because (a) the
risk window is small, and (b) nobody runs servers with maxed-out lock
tables for long, because they'll be getting non-PANIC out-of-memory errors
anyway.  So fixing it in HEAD seems sufficient, at least until the new
code has gotten some testing.

11 years agoMake spelling more uniform
Peter Eisentraut [Mon, 14 Jan 2013 02:42:03 +0000 (21:42 -0500)]
Make spelling more uniform

11 years agoUpdate comments for elog_start().
Tom Lane [Sun, 13 Jan 2013 23:50:48 +0000 (18:50 -0500)]
Update comments for elog_start().

Forgot I was going to do this as part of the previous patch ...

11 years agoImprove handling of ereport(ERROR) and elog(ERROR).
Tom Lane [Sun, 13 Jan 2013 23:39:20 +0000 (18:39 -0500)]
Improve handling of ereport(ERROR) and elog(ERROR).

In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform
suitably-intelligent compilers that ereport() doesn't return if the elevel
is ERROR or higher.  This patch extends that to elog(), and also fixes a
double-evaluation hazard that the previous commit created in ereport(),
as well as reducing the emitted code size.

The elog() improvement requires the compiler to support __VA_ARGS__, which
should be available in just about anything nowadays since it's required by
C99.  But our minimum language baseline is still C89, so add a configure
test for that.

The previous commit assumed that ereport's elevel could be evaluated twice,
which isn't terribly safe --- there are already counterexamples in xlog.c.
On compilers that have __builtin_constant_p, we can use that to protect the
second test, since there's no possible optimization gain if the compiler
doesn't know the value of elevel.  Otherwise, use a local variable inside
the macros to prevent double evaluation.  The local-variable solution is
inferior because (a) it leads to useless code being emitted when elevel
isn't constant, and (b) it increases the optimization level needed for the
compiler to recognize that subsequent code is unreachable.  But it seems
better than not teaching non-gcc compilers about unreachability at all.

Lastly, if the compiler has __builtin_unreachable(), we can use that
instead of abort(), resulting in a noticeable code savings since no
function call is actually emitted.  However, it seems wise to do this only
in non-assert builds.  In an assert build, continue to use abort(), so that
the behavior will be predictable and debuggable if the "impossible"
happens.

These changes involve making the ereport and elog macros emit do-while
statement blocks not just expressions, which forces small changes in
a few call sites.

Andres Freund, Tom Lane, Heikki Linnakangas

11 years agoExtend and improve use of EXTRA_REGRESS_OPTS.
Andrew Dunstan [Sat, 12 Jan 2013 13:28:58 +0000 (08:28 -0500)]
Extend and improve use of EXTRA_REGRESS_OPTS.

This is now used by ecpg tests, and not clobbered by pg_upgrade
tests. This change won't affect anything that doesn't set this
environment variable, but will enable the buildfarm to control
exactly what port regression test installs will be running on,
and thus to detect possible rogue postmasters more easily.

Backpatch to release 9.2 where EXTRA_REGRESS_OPTS was first used.

11 years agoRedesign the planner's handling of index-descent cost estimation.
Tom Lane [Fri, 11 Jan 2013 17:56:58 +0000 (12:56 -0500)]
Redesign the planner's handling of index-descent cost estimation.

Historically we've used a couple of very ad-hoc fudge factors to try to
get the right results when indexes of different sizes would satisfy a
query with the same number of index leaf tuples being visited.  In
commit 21a39de5809cd3050a37d2554323cc1d0cbeed9d I tweaked one of these
fudge factors, with results that proved disastrous for larger indexes.
Commit bf01e34b556ff37982ba2d882db424aa484c0d07 fudged it some more,
but still with not a lot of principle behind it.

What seems like a better way to address these issues is to explicitly model
index-descent costs, since that's what's really at stake when considering
diferent indexes with similar leaf-page-level costs.  We tried that once
long ago, and found that charging random_page_cost per page descended
through was way too much, because upper btree levels tend to stay in cache
in real-world workloads.  However, there's still CPU costs to think about,
and the previous fudge factors can be seen as a crude attempt to account
for those costs.  So this patch replaces those fudge factors with explicit
charges for the number of tuple comparisons needed to descend the index
tree, plus a small charge per page touched in the descent.  The cost
multipliers are chosen so that the resulting charges are in the vicinity of
the historical (pre-9.2) fudge factors for indexes of up to about a million
tuples, while not ballooning unreasonably beyond that, as the old fudge
factor did (even more so in 9.2).

To make this work accurately for btree indexes, add some code that allows
extraction of the known root-page height from a btree.  There's no
equivalent number readily available for other index types, but we can use
the log of the number of index pages as an approximate substitute.

This seems like too much of a behavioral change to risk back-patching,
but it should improve matters going forward.  In 9.2 I'll just revert
the fudge-factor change.

11 years agoLast-gasp attempt to save libperl.so configure probe.
Tom Lane [Fri, 11 Jan 2013 03:16:22 +0000 (22:16 -0500)]
Last-gasp attempt to save libperl.so configure probe.

I notice that plperl's makefile adds the -I for $perl_archlibexp/CORE
at the end of CPPFLAGS not the beginning.  It seems somewhat unlikely
that the include search order has anything to do with why buildfarm
member okapi is failing, but I'm about out of other ideas.

11 years agoTest linking libperl.so using only Perl's required libraries.
Tom Lane [Thu, 10 Jan 2013 04:46:44 +0000 (23:46 -0500)]
Test linking libperl.so using only Perl's required libraries.

It appears that perl_embed_ldflags should already mention all the libraries
that are required by libperl.so itself.  So let's try the test link with
just those and not the other LIBS we've found up to now.  This should
more nearly reproduce what will happen when plperl is linked, and perhaps
will fix buildfarm member okapi's problem.

11 years agoAdd explicit configure-time checks for perl.h and libperl.so.
Tom Lane [Thu, 10 Jan 2013 00:41:37 +0000 (19:41 -0500)]
Add explicit configure-time checks for perl.h and libperl.so.

Although most platforms seem to package Perl in such a way that these files
are present even in basic Perl installations, Debian does not.  Hence, make
an effort to fail during configure rather than build if --with-perl was
given and these files are lacking.  Per gripe from Josh Berkus.

11 years agoDetect Windows perl linkage parameters in configure script.
Andrew Dunstan [Wed, 9 Jan 2013 22:49:23 +0000 (17:49 -0500)]
Detect Windows perl linkage parameters in configure script.

This means we can now construct a configure test for the library
presence. Previously these parameters were only figured out at
build time in plperl's GnuMakefile.

11 years agoProperly install ecpg_compat and pgtypes libraries on msvc
Magnus Hagander [Wed, 9 Jan 2013 16:29:59 +0000 (17:29 +0100)]
Properly install ecpg_compat and pgtypes libraries on msvc

JiangGuiqing

11 years agoDon't attempt to write recovery.conf when -R is not specified
Magnus Hagander [Wed, 9 Jan 2013 15:57:32 +0000 (16:57 +0100)]
Don't attempt to write recovery.conf when -R is not specified

Fixes segmentation fault during regular use.

Fujii Masao

11 years agoAllow parallel copy/link in pg_upgrade
Bruce Momjian [Wed, 9 Jan 2013 13:57:47 +0000 (08:57 -0500)]
Allow parallel copy/link in pg_upgrade

This patch implements parallel copying/linking of files by tablespace
using the --jobs option in pg_upgrade.

11 years agoFix potential corruption of lock table in CREATE/DROP INDEX CONCURRENTLY.
Tom Lane [Tue, 8 Jan 2013 23:25:58 +0000 (18:25 -0500)]
Fix potential corruption of lock table in CREATE/DROP INDEX CONCURRENTLY.

If VirtualXactLock() has to wait for a transaction that holds its VXID lock
as a fast-path lock, it must first convert the fast-path lock to a regular
lock.  It failed to take the required "partition" lock on the main
shared-memory lock table while doing so.  This is the direct cause of the
assert failure in GetLockStatusData() recently observed in the buildfarm,
but more worryingly it could result in arbitrary corruption of the shared
lock table if some other process were concurrently engaged in modifying the
same partition of the lock table.  Fortunately, VirtualXactLock() is only
used by CREATE INDEX CONCURRENTLY and DROP INDEX CONCURRENTLY, so the
opportunities for failure are fewer than they might have been.

In passing, improve some comments and be a bit more consistent about
order of operations.

11 years agoFix typo
Peter Eisentraut [Tue, 8 Jan 2013 02:34:30 +0000 (21:34 -0500)]
Fix typo

11 years agoFix a logic bug in pgindent.
Andrew Dunstan [Mon, 7 Jan 2013 17:26:27 +0000 (12:26 -0500)]
Fix a logic bug in pgindent.