]> granicus.if.org Git - postgresql/log
postgresql
9 years agoProtect against multixact members wraparound
Alvaro Herrera [Tue, 28 Apr 2015 14:32:53 +0000 (11:32 -0300)]
Protect against multixact members wraparound

Multixact member files are subject to early wraparound overflow and
removal: if the average multixact size is above a certain threshold (see
note below) the protections against offset overflow are not enough:
during multixact truncation at checkpoint time, some
pg_multixact/members files would be removed because the server considers
them to be old and not needed anymore.  This leads to loss of files that
are critical to interpret existing tuples's Xmax values.

To protect against this, since we don't have enough info in pg_control
and we can't modify it in old branches, we maintain shared memory state
about the oldest value that we need to keep; we use this during new
multixact creation to abort if an old still-needed file would get
overwritten.  This value is kept up to date by checkpoints, which makes
it not completely accurate but should be good enough.  We start emitting
warnings sometime earlier, so that the eventual multixact-shutdown
doesn't take DBAs completely by surprise (more precisely: once 20
members SLRU segments are remaining before shutdown.)

On troublesome average multixact size: The threshold size depends on the
multixact freeze parameters. The oldest age is related to the greater of
multixact_freeze_table_age and multixact_freeze_min_age: anything
older than that should be removed promptly by autovacuum.  If autovacuum
is keeping up with multixact freezing, the troublesome multixact average
size is
(2^32-1) / Max(freeze table age, freeze min age)
or around 28 members per multixact.  Having an average multixact size
larger than that will eventually cause new multixact data to overwrite
the data area for older multixacts.  (If autovacuum is not able to keep
up, or there are errors in vacuuming, the actual maximum is
multixact_freeeze_max_age instead, at which point multixact generation
is stopped completely.  The default value for this limit is 400 million,
which means that the multixact size that would cause trouble is about 10
members).

Initial bug report by Timothy Garnett, bug #12990
Backpatch to 9.3, where the problem was introduced.

Authors: Álvaro Herrera, Thomas Munro
Reviews: Thomas Munro, Amit Kapila, Robert Haas, Kevin Grittner

9 years agoUse a fd opened for read/write when syncing slots during startup.
Andres Freund [Mon, 27 Apr 2015 22:12:38 +0000 (00:12 +0200)]
Use a fd opened for read/write when syncing slots during startup.

Some operating systems, including the reporter's windows, return EBADFD
or similar when fsync() is invoked on a O_RDONLY file descriptor.
Unfortunately RestoreSlotFromDisk() does exactly that; which causes
failures after restarts in at least some scenarios.

If you hit the bug the error message will be something like
ERROR: could not fsync file "pg_replslot/$name/state": Bad file descriptor

Simply use O_RDWR instead of O_RDONLY when opening the relevant file
descriptor to fix the bug.  Unfortunately I have no way of verifying the
fix, but we've seen similar problems in the past.

This bug goes back to 9.4 where slots were introduced. Backpatch
accordingly.

Reported-By: Patrice Drolet
Bug: #13143:
Discussion: 20150424101006.2556.60897@wrigleys.postgresql.org

9 years agoImprove qual pushdown for RLS and SB views
Stephen Frost [Mon, 27 Apr 2015 16:29:42 +0000 (12:29 -0400)]
Improve qual pushdown for RLS and SB views

The original security barrier view implementation, on which RLS is
built, prevented all non-leakproof functions from being pushed down to
below the view, even when the function was not receiving any data from
the view.  This optimization improves on that situation by, instead of
checking strictly for non-leakproof functions, it checks for Vars being
passed to non-leakproof functions and allows functions which do not
accept arguments or whose arguments are not from the current query level
(eg: constants can be particularly useful) to be pushed down.

As discussed, this does mean that a function which is pushed down might
gain some idea that there are rows meeting a certain criteria based on
the number of times the function is called, but this isn't a
particularly new issue and the documentation in rules.sgml already
addressed similar covert-channel risks.  That documentation is updated
to reflect that non-leakproof functions may be pushed down now, if
they meet the above-described criteria.

Author: Dean Rasheed, with a bit of rework to make things clearer,
along with comment and documentation updates from me.

9 years agoFix vcbuild failures and chkpass dependency caused by 854adb8
Andrew Dunstan [Mon, 27 Apr 2015 14:50:46 +0000 (10:50 -0400)]
Fix vcbuild failures and chkpass dependency caused by 854adb8

Switching the Windows build scripts to use forward slashes instead of
backslashes has caused a couple of issues in VC builds:
- The file tree list was not correctly generated, build script
  generating vcproj file missing tree dependencies when listing items in
  Filter.
- VC builds do not accept file paths with forward slashes, perhaps it
  could be possible to use a Condition but it seems safer to simply
  enforce the file paths to use backslashes in the vcproj files.
- chkpass had an unneeded dependency with libpgport and libpgcommon to
  make build succeed but actually it is not necessary as crypt.c is
  already listed for this project and should be replaced with a fake name
  as it is a unique file.

Michael Paquier

9 years agoFix hstore_plperl regression tests on some platforms
Peter Eisentraut [Sun, 26 Apr 2015 20:09:22 +0000 (16:09 -0400)]
Fix hstore_plperl regression tests on some platforms

On some platforms, plperl and plperlu cannot be loaded at the same
time.  So split the test into two separate test files.

9 years agoAlso correct therefor to therefore.
Andres Freund [Sun, 26 Apr 2015 17:05:39 +0000 (19:05 +0200)]
Also correct therefor to therefore.

Since both forms are arguably legal I wasn't sure about changing
this. But then Tom argued for 'therefore'...

Author: Dmitriy Olshevskiy
Discussion: 34789.1430067832@sss.pgh.pa.us

9 years agoFix various typos and grammar errors in comments.
Andres Freund [Sun, 26 Apr 2015 16:42:31 +0000 (18:42 +0200)]
Fix various typos and grammar errors in comments.

Author: Dmitriy Olshevskiy
Discussion: 553D00A6.4090205@bk.ru

9 years agoFix possible division by zero in pg_xlogdump.
Andres Freund [Sun, 26 Apr 2015 16:02:32 +0000 (18:02 +0200)]
Fix possible division by zero in pg_xlogdump.

When displaying stats it was possible that a floating point division by
zero occured when no FPIs were issued for a type of record.

Author: Abhijit Menon-Sen
Discussion: 20150417091811.GA14008@toroid.org

9 years agoAdd transforms feature
Peter Eisentraut [Sun, 26 Apr 2015 14:33:14 +0000 (10:33 -0400)]
Add transforms feature

This provides a mechanism for specifying conversions between SQL data
types and procedural languages.  As examples, there are transforms
for hstore and ltree for PL/Perl and PL/Python.

reviews by Pavel Stěhule and Andres Freund

9 years agoFix typo in linux startup script.
Tom Lane [Sun, 26 Apr 2015 13:43:15 +0000 (09:43 -0400)]
Fix typo in linux startup script.

Missed a "$" in what was meant to be a variable substitution.  Careless
mistake in commit f23425fa950fec3aff458de117037c9caadbc35c.

9 years agoAdd comments warning against generalizing default_with_oids.
Tom Lane [Sun, 26 Apr 2015 01:37:39 +0000 (21:37 -0400)]
Add comments warning against generalizing default_with_oids.

pg_dump has historically assumed that default_with_oids affects only plain
tables and not other relkinds.  Conceivably we could make it apply to some
newly invented relkind if we did so from the get-go, but changing the
behavior for existing object types will break existing dump scripts.
Add code comments warning about this interaction.

Also, make sure that default_with_oids doesn't cause parse_utilcmd.c to
think that CREATE FOREIGN TABLE will create an OID column.  I think this is
only a latent bug right now, since we don't allow UNIQUE/PKEY constraints
in CREATE FOREIGN TABLE, but it's better to be consistent and future-proof.

9 years agoTry to unbreak some MSVC builds following forward slash change.
Andrew Dunstan [Sun, 26 Apr 2015 01:28:02 +0000 (21:28 -0400)]
Try to unbreak some MSVC builds following forward slash change.

Michael Paquier.

9 years agoRevert: Honor OID status of CREATE LIKE'd tables
Bruce Momjian [Sun, 26 Apr 2015 01:10:45 +0000 (21:10 -0400)]
Revert:  Honor OID status of CREATE LIKE'd tables

Reverts d992f8a8961c09ec219373ffe2b5e6473febd065

Report by Tom Lane

9 years agoDon't overwrite EXTRA_INSTALL
Peter Eisentraut [Sun, 26 Apr 2015 00:57:58 +0000 (20:57 -0400)]
Don't overwrite EXTRA_INSTALL

The temp-install target sets EXTRA_INSTALL to install the current
directory.  But when doing so, it should append instead of overwrite,
otherwise settings of EXTRA_INSTALL from a makefile won't take effect.
This would cause the earthdistance test to fail when called directly,
because it would miss installing the cube module.

9 years agoPrevent improper reordering of antijoins vs. outer joins.
Tom Lane [Sat, 25 Apr 2015 20:44:27 +0000 (16:44 -0400)]
Prevent improper reordering of antijoins vs. outer joins.

An outer join appearing within the RHS of an antijoin can't commute with
the antijoin, but somehow I missed teaching make_outerjoininfo() about
that.  In Teodor Sigaev's recent trouble report, this manifests as a
"could not find RelOptInfo for given relids" error within eqjoinsel();
but I think silently wrong query results are possible too, if the planner
misorders the joins and doesn't happen to trigger any internal consistency
checks.  It's broken as far back as we had antijoins, so back-patch to all
supported branches.

9 years agoReplace backslashes by forward slashes in MSVC build code
Peter Eisentraut [Sat, 25 Apr 2015 12:52:03 +0000 (08:52 -0400)]
Replace backslashes by forward slashes in MSVC build code

This makes it possible to run some stages of these build scripts on
non-Windows systems.  That way, we can more easily test whether file
moves or makefile changes might break the MSVC build.

Peter Eisentraut and Michael Paquier

9 years agoFix file comment for test_rls_hooks.c
Stephen Frost [Sat, 25 Apr 2015 00:44:53 +0000 (20:44 -0400)]
Fix file comment for test_rls_hooks.c

The file-level comment wasn't updated when it was copied from the shared
memory queue test module.  Fixed.

Noted by Dean Rasheed.

9 years agoPerform RLS WITH CHECK before constraints, etc
Stephen Frost [Sat, 25 Apr 2015 00:34:26 +0000 (20:34 -0400)]
Perform RLS WITH CHECK before constraints, etc

The RLS capability is built on top of the WITH CHECK OPTION
system which was added for auto-updatable views, however, unlike
WCOs on views (which are mandated by the SQL spec to not fire until
after all other constraints and checks are done), it makes much more
sense for RLS checks to happen earlier than constraint and uniqueness
checks.

This patch reworks the structure which holds the WCOs a bit to be
explicitly either VIEW or RLS checks and the RLS-related checks are
done prior to the constraint and uniqueness checks.  This also allows
better error reporting as we are now reporting when a violation is due
to a WITH CHECK OPTION and when it's due to an RLS policy violation,
which was independently noted by Craig Ringer as being confusing.

The documentation is also updated to include a paragraph about when RLS
WITH CHECK handling is performed, as there have been a number of
questions regarding that and the documentation was previously silent on
the matter.

Author: Dean Rasheed, with some kabitzing and comment changes by me.

9 years agoRemove obsolete -I options from ECPG library compilation.
Noah Misch [Fri, 24 Apr 2015 23:29:09 +0000 (19:29 -0400)]
Remove obsolete -I options from ECPG library compilation.

The MSVC build system already omitted these.

9 years agoRemove superfluous -DFRONTEND.
Noah Misch [Fri, 24 Apr 2015 23:29:05 +0000 (19:29 -0400)]
Remove superfluous -DFRONTEND.

The majority practice is to add -DFRONTEND in directories building files
that are, at other times, built for the backend.  Some directories
lacking that property added a noise -DFRONTEND in one build system.
Remove the excess flags, for consistency.

9 years agoBuild every ECPG library with -DFRONTEND.
Noah Misch [Fri, 24 Apr 2015 23:29:02 +0000 (19:29 -0400)]
Build every ECPG library with -DFRONTEND.

Each of the libraries incorporates src/port files, which often check
FRONTEND.  Build systems disagreed on whether to build libpgtypes this
way.  Only libecpg incorporates files that rely on it today.  Back-patch
to 9.0 (all supported versions) to forestall surprises.

9 years agoFix up .gitignore and cleanup actions in some src/test/ subdirectories.
Tom Lane [Fri, 24 Apr 2015 21:13:06 +0000 (17:13 -0400)]
Fix up .gitignore and cleanup actions in some src/test/ subdirectories.

examples/, locale/, and thread/ lacked .gitignore files and were also
not connected up to top-level "make clean" etc.  This had escaped notice
because none of those directories are built in normal scenarios.  Still,
they have working Makefiles, so if someone does a "make" in one of these
directories it would be good if (a) git doesn't bleat about the product
files and (b) cleaning up removes them.

This is a longstanding oversight, but since this behavior is probably
only of interest to developers, there seems no need for back-patching.

Michael Paquier and Tom Lane

9 years agoFix obsolete comment in set_rel_size().
Tom Lane [Fri, 24 Apr 2015 19:18:07 +0000 (15:18 -0400)]
Fix obsolete comment in set_rel_size().

The cross-reference to set_append_rel_pathlist() was obsoleted by
commit e2fa76d80ba571d4de8992de6386536867250474, which split what
had been set_rel_pathlist() and child routines into two sets of
functions.  But I (tgl) evidently missed updating this comment.

Back-patch to 9.2 to avoid unnecessary divergence among branches.

Amit Langote

9 years agoAdd comments explaining how unique and exclusion constraints are enforced.
Heikki Linnakangas [Fri, 24 Apr 2015 18:12:32 +0000 (21:12 +0300)]
Add comments explaining how unique and exclusion constraints are enforced.

9 years agodoc: Move ALTER TABLE IF EXISTS description to better place
Peter Eisentraut [Fri, 24 Apr 2015 17:22:18 +0000 (13:22 -0400)]
doc: Move ALTER TABLE IF EXISTS description to better place

It was previously mixed in with the description of ALTER TABLE
subcommands.  Move it to the Parameters section, which is where it is on
other reference pages.

pointed out by Amit Langote

9 years agoFix misspellings
Peter Eisentraut [Fri, 24 Apr 2015 16:00:49 +0000 (12:00 -0400)]
Fix misspellings

Amit Langote and Thom Brown

9 years agoCopy the relation name for error reporting in WCOs
Stephen Frost [Fri, 24 Apr 2015 13:38:10 +0000 (09:38 -0400)]
Copy the relation name for error reporting in WCOs

In get_row_security_policies(), we need to make a copy of the relation
name when building the WithCheckOptions structure, since
RelationGetRelationName just returns a pointer into the local Relation
structure.  The relation name in the WCO structure is only used for
error reporting.

Pointed out by Robert and Christian Ullrich, who noted that the
buildfarm members with -DCLOBBER_CACHE_ALWAYS were failing.

9 years agoMove functions related to index maintenance to separate source file.
Heikki Linnakangas [Fri, 24 Apr 2015 06:33:23 +0000 (09:33 +0300)]
Move functions related to index maintenance to separate source file.

There is enough code here to deserve a file of their own, not be buried
in the middle of execUtils.c.

9 years agoFix deadlock at startup, if max_prepared_transactions is too small.
Heikki Linnakangas [Thu, 23 Apr 2015 18:25:44 +0000 (21:25 +0300)]
Fix deadlock at startup, if max_prepared_transactions is too small.

When the startup process recovers transactions by scanning pg_twophase
directory, it should clear MyLockedGxact after it's done processing each
transaction. Like we do during normal operation, at PREPARE TRANSACTION.
Otherwise, if the startup process exits due to an error, it will try to
clear the locking_backend field of the last recovered transaction. That's
usually harmless, but if the error happens in MarkAsPreparing, while
holding TwoPhaseStateLock, the shmem-exit hook will try to acquire
TwoPhaseStateLock again, and deadlock with itself.

This fixes bug #13128 reported by Grant McAlister. The bug was introduced
by commit bb38fb0d, so backpatch to all supported versions like that
commit.

9 years agoFix shell error on Solaris
Peter Eisentraut [Thu, 23 Apr 2015 17:09:18 +0000 (13:09 -0400)]
Fix shell error on Solaris

Apparently, the Bourne shell on Solaris doesn't like "for" loops with an
empty list, so have "make" skip the loop in that case.

9 years agoImprove speed of make check-world
Peter Eisentraut [Thu, 23 Apr 2015 12:59:52 +0000 (08:59 -0400)]
Improve speed of make check-world

Before, make check-world would create a new temporary installation for
each test suite, which is slow and wasteful.  Instead, we now create one
test installation that is used by all test suites that are part of a
make run.

The management of the temporary installation is removed from pg_regress
and handled in the makefiles.  This allows for better control, and
unifies the code with that of test suites not run through pg_regress.

review and msvc support by Michael Paquier <michael.paquier@gmail.com>

more review by Fabien Coelho <coelho@cri.ensmp.fr>

9 years agoUse the right type OID after creating a shell type
Alvaro Herrera [Wed, 22 Apr 2015 19:23:02 +0000 (16:23 -0300)]
Use the right type OID after creating a shell type

Commit a2e35b53c39b2a neglected to update the type OID to use further
down in DefineType when TypeShellMake was changed to return
ObjectAddress instead of OID (it got it right in DefineRange, however.)
This resulted in an internal error message being issued when looking up
I/O functions.

Author: Michael Paquier

Also add Asserts() to a couple of other places to ensure that the type
OID being used is as expected.

9 years agoFix installcheck for test_rls_hooks
Stephen Frost [Wed, 22 Apr 2015 16:43:57 +0000 (12:43 -0400)]
Fix installcheck for test_rls_hooks

As pointed out by the buildfarm, test_rls_hooks wasn't functioning
properly with a clean installcheck.  test_rls_hooks needs to explicitly
load the library with the hooks in it, to allow installcheck to work;
using the --temp-config doesn't help since that isn't used when running
installcheck and it isn't exactly fair to the buildfarm to modify the
installed config prior to calling installcheck.

Also, have test_rls_hooks clean up after itself.

9 years agoRLS fixes, new hooks, and new test module
Stephen Frost [Wed, 22 Apr 2015 16:01:06 +0000 (12:01 -0400)]
RLS fixes, new hooks, and new test module

In prepend_row_security_policies(), defaultDeny was always true, so if
there were any hook policies, the RLS policies on the table would just
get discarded.  Fixed to start off with defaultDeny as false and then
properly set later if we detect that only the default deny policy exists
for the internal policies.

The infinite recursion detection in fireRIRrules() didn't properly
manage the activeRIRs list in the case of WCOs, so it would incorrectly
report infinite recusion if the same relation with RLS appeared more
than once in the rtable, for example "UPDATE t ... FROM t ...".

Further, the RLS expansion code in fireRIRrules() was handling RLS in
the main loop through the rtable, which lead to RTEs being visited twice
if they contained sublink subqueries, which
prepend_row_security_policies() attempted to handle by exiting early if
the RTE already had securityQuals.  That doesn't work, however, since
if the query involved a security barrier view on top of a table with
RLS, the RTE would already have securityQuals (from the view) by the
time fireRIRrules() was invoked, and so the table's RLS policies would
be ignored.  This is fixed in fireRIRrules() by handling RLS in a
separate loop at the end, after dealing with any other sublink
subqueries, thus ensuring that each RTE is only visited once for RLS
expansion.

The inheritance planner code didn't correctly handle non-target
relations with RLS, which would get turned into subqueries during
planning. Thus an update of the form "UPDATE t1 ... FROM t2 ..." where
t1 has inheritance and t2 has RLS quals would fail.  Fix by making sure
to copy in and update the securityQuals when they exist for non-target
relations.

process_policies() was adding WCOs to non-target relations, which is
unnecessary, and could lead to a lot of wasted time in the rewriter and
the planner. Fix by only adding WCO policies when working on the result
relation.  Also in process_policies, we should be copying the USING
policies to the WITH CHECK policies on a per-policy basis, fix by moving
the copying up into the per-policy loop.

Lastly, as noted by Dean, we were simply adding policies returned by the
hook provided to the list of quals being AND'd, meaning that they would
actually restrict records returned and there was no option to have
internal policies and hook-based policies work together permissively (as
all internal policies currently work).  Instead, explicitly add support
for both permissive and restrictive policies by having a hook for each
and combining the results appropriately.  To ensure this is all done
correctly, add a new test module (test_rls_hooks) to test the various
combinations of internal, permissive, and restrictive hook policies.

Largely from Dean Rasheed (thanks!):

CAEZATCVmFUfUOwwhnBTcgi6AquyjQ0-1fyKd0T3xBWJvn+xsFA@mail.gmail.com

Author: Dean Rasheed, though I added the new hooks and test module.

9 years agoPull in tableoid for inheiritance with rowMarks
Stephen Frost [Wed, 22 Apr 2015 15:29:35 +0000 (11:29 -0400)]
Pull in tableoid for inheiritance with rowMarks

As noted by Etsuro Fujita [1] and Dean Rasheed[2],
cb1ca4d800621dcae67ca6c799006de99fa4f0a5 changed ExecBuildAuxRowMark()
to always look for the tableoid in the target list, but didn't also
change preprocess_targetlist() to always include the tableoid.  This
resulted in errors with soon-to-be-added RLS with inheritance tests,
and errors when using inheritance with foreign tables.

Authors: Etsuro Fujita and Dean Rasheed (independently)

Minor word-smithing on the comments by me.

[1] 552CF0B6.8010006@lab.ntt.co.jp
[2] CAEZATCVmFUfUOwwhnBTcgi6AquyjQ0-1fyKd0T3xBWJvn+xsFA@mail.gmail.com

9 years agoMake the pg_rewind regression tests more robust on slow systems.
Heikki Linnakangas [Wed, 22 Apr 2015 11:28:37 +0000 (14:28 +0300)]
Make the pg_rewind regression tests more robust on slow systems.

There were a couple of hard-coded sleeps in the tests: to wait for standby
to catch up with master, and to wait for promotion with "pg_ctl promote"
to complete. Instead of a fixed, hard-coded sleep, poll the server with a
query once a second. This isn't ideal either, and I wish we had a better
solution for real-world applications too, but this should fix the
immediate problem.

Patch by Michael Paquier, with some editing by me.

9 years agoRename pg_replication_slot's new active_in to active_pid.
Andres Freund [Wed, 22 Apr 2015 07:42:36 +0000 (09:42 +0200)]
Rename pg_replication_slot's new active_in to active_pid.

In d811c037ce active_in was added but discussion since showed that
active_pid is preferred as a name.

Discussion: CAMsr+YFKgZca5_7_ouaMWxA5PneJC9LNViPzpDHusaPhU9pA7g@mail.gmail.com

9 years agoDon't leave 'tmp_check' directory behind in pg_rewind regression tests.
Heikki Linnakangas [Wed, 22 Apr 2015 07:14:44 +0000 (10:14 +0300)]
Don't leave 'tmp_check' directory behind in pg_rewind regression tests.

9 years agoMove pg_xlogdump from contrib/ to src/bin/
Peter Eisentraut [Wed, 11 Mar 2015 02:33:24 +0000 (22:33 -0400)]
Move pg_xlogdump from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agoUpdate FDW docs to reflect existence of CHECK constraints.
Robert Haas [Tue, 21 Apr 2015 21:46:47 +0000 (17:46 -0400)]
Update FDW docs to reflect existence of CHECK constraints.

Generalize the remarks previously made about NOT NULL constraints to
CHECK constraints.

Etsuro Fujita

9 years agoAdd missing installcheck target to pg_rewind's Makefile
Heikki Linnakangas [Tue, 21 Apr 2015 11:09:25 +0000 (14:09 +0300)]
Add missing installcheck target to pg_rewind's Makefile

Michael Paquier

9 years agoAdd 'active_in' column to pg_replication_slots.
Andres Freund [Tue, 21 Apr 2015 09:51:06 +0000 (11:51 +0200)]
Add 'active_in' column to pg_replication_slots.

Right now it is visible whether a replication slot is active in any
session, but not in which.  Adding the active_in column, containing the
pid of the backend having acquired the slot, makes it much easier to
associate pg_replication_slots entries with the corresponding
pg_stat_replication/pg_stat_activity row.

This should have been done from the start, but I (Andres) dropped the
ball there somehow.

Author: Craig Ringer, revised by me Discussion:
CAMsr+YFKgZca5_7_ouaMWxA5PneJC9LNViPzpDHusaPhU9pA7g@mail.gmail.com

9 years agoMove pg_test_timing from contrib/ to src/bin/
Peter Eisentraut [Wed, 11 Mar 2015 02:33:24 +0000 (22:33 -0400)]
Move pg_test_timing from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agoHonor OID status of CREATE LIKE'd tables
Bruce Momjian [Mon, 20 Apr 2015 20:11:25 +0000 (16:11 -0400)]
Honor OID status of CREATE LIKE'd tables

Previously, tables created by CREATE LIKE never had OIDs.

Report by Tom Lane

9 years agoMove pg_test_fsync from contrib/ to src/bin/
Peter Eisentraut [Wed, 11 Mar 2015 02:33:24 +0000 (22:33 -0400)]
Move pg_test_fsync from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agopg_upgrade: binary_upgrade_create_empty_extension() is strict
Bruce Momjian [Sat, 18 Apr 2015 00:08:42 +0000 (20:08 -0400)]
pg_upgrade:  binary_upgrade_create_empty_extension() is strict

Was broken by commit 30982be4e5019684e1772dd9170aaa53f5a8e894.

Patch by Jeff Janes

9 years agoFix typo in relcache's equalPolicy()
Stephen Frost [Fri, 17 Apr 2015 20:37:11 +0000 (16:37 -0400)]
Fix typo in relcache's equalPolicy()

The USING policies were not being checked for differences as the same
policy was being passed in to both sides of the equal().  This could
result in backends not realizing that a policy had been changed, if
none of the other attributes had been changed.

Fix by passing to equal() the policy1 and policy2 using quals for
comparison.

No need to back-patch as this is not yet released.  Noticed while
testing changes to RLS proposed by Dean Rasheed.

9 years agoAdd new target modulescheck in vcregress.pl
Alvaro Herrera [Fri, 17 Apr 2015 02:39:52 +0000 (23:39 -0300)]
Add new target modulescheck in vcregress.pl

This allows an MSVC build to run regression tests related to modules in
src/test/modules.

Author: Michael Paquier
Reviewed by: Andrew Dunstan

9 years agopg_upgrade: document need for text search files to be copied
Bruce Momjian [Thu, 16 Apr 2015 23:51:12 +0000 (19:51 -0400)]
pg_upgrade:  document need for text search files to be copied

Report by CJ Estel

Backpatch through 9.4

9 years agoMSVC: install src/test/modules together with contrib
Alvaro Herrera [Thu, 16 Apr 2015 19:40:14 +0000 (16:40 -0300)]
MSVC: install src/test/modules together with contrib

These modules have to be installed so that the testing module can access
them.  (We don't have that yet, but will soon have it.)

Author: Michael Paquier
Reviewed by: Andrew Dunstan

9 years agoFix assertion failure in logical decoding.
Heikki Linnakangas [Thu, 16 Apr 2015 18:00:55 +0000 (21:00 +0300)]
Fix assertion failure in logical decoding.

Logical decoding set SnapshotData's regd_count field to avoid the
snapshot manager from prematurely freeing snapshots that are generated
by the decoding system. That was always an abuse of the field, as it was
never supposed to be used outside the snapshot manager. Commit 94028691
made snapshot manager's tracking of the snapshots smarter, and that scheme
fell apart. The snapshot manager got confused and hit the assertion, when
a snapshot that was marked with regd_count==1 was not found in the heap,
where the snapshot manager tracks registered the snapshots.

To fix, don't abuse the regd_count field like that. Logical decoding still
abuses the active_count field for similar purposes, but that's currently
harmless.

The assertion failure was first reported by Michael Paquier

9 years agoMSVC: Include modules of src/test/modules in build
Alvaro Herrera [Thu, 16 Apr 2015 18:17:26 +0000 (15:17 -0300)]
MSVC: Include modules of src/test/modules in build

commit_ts, being only a module used for test purposes, is ignored in the
process for now.

Author: Michael Paquier
Reviewed by: Andrew Dunstan

9 years agoAdd missing newlines to error messages.
Heikki Linnakangas [Thu, 16 Apr 2015 06:18:00 +0000 (09:18 +0300)]
Add missing newlines to error messages.

9 years agoError out in pg_rewind if lstat() fails.
Heikki Linnakangas [Wed, 15 Apr 2015 20:13:32 +0000 (23:13 +0300)]
Error out in pg_rewind if lstat() fails.

A "file not found" is expected if the source server is running, so don't
complain about that. But any other error is definitely not expected.

9 years agoMinor cleanup of pg_rewind.
Heikki Linnakangas [Wed, 15 Apr 2015 19:52:00 +0000 (22:52 +0300)]
Minor cleanup of pg_rewind.

Update comments and function names to use the terms "source" and "target"
consistently. Some places were calling them remote and local instead, which
was confusing.

Fix incorrect comment in extractPageInfo on database creation record - it
was wrong on what happens for databases created in the target that don't
exist in source.

9 years agoShut down test servers after pg_rewind regression tests.
Heikki Linnakangas [Wed, 15 Apr 2015 16:54:38 +0000 (19:54 +0300)]
Shut down test servers after pg_rewind regression tests.

Now that the test servers are initialized twice in each .pl script,
the single END block is not enough to stop them. Add a new clean_rewind_test
function that is called at the end of each test.

Michael Paquier

9 years agoFix logic to skip checkpoint if no records have been inserted.
Heikki Linnakangas [Wed, 15 Apr 2015 14:21:04 +0000 (17:21 +0300)]
Fix logic to skip checkpoint if no records have been inserted.

After the WAL format changes, the calculation of the size of a checkpoint
record became incorrect. Instead of trying to fix the math, check that the
previous record, i.e. the xl_prev value that we'd write for the next
record, matches the last checkpoint's redo pointer. That way it's not
dependent on the size of the checkpoint record at all.

The old logic was actually slightly wrong all along: if the previous
checkpoint record crossed a page boundary, the page headers threw off the
record size calculation, and the checkpoint was not skipped. The new
checkpoint would not cross a page boundary, so this only resulted in at
most one extra checkpoint after the system became idle. The new logic fixes
that. (It's not worth fixing in backbranches).

However, it makes some sense to try to keep the latest checkpoint contained
fully in a page, or at least in a single WAL segment, just on general
robustness grounds. If something goes awfully wrong, it's more likely that
you can recover the latest WAL segment, than the last two WAL segments. So
I added an extra check that the checkpoint is not skipped if the previous
checkpoint crossed a WAL segment.

Reported by Jeff Janes.

9 years agoMove pg_upgrade from contrib/ to src/bin/
Peter Eisentraut [Wed, 11 Mar 2015 02:33:25 +0000 (22:33 -0400)]
Move pg_upgrade from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agoIntegrate pg_upgrade_support module into backend
Peter Eisentraut [Wed, 11 Mar 2015 02:33:25 +0000 (22:33 -0400)]
Integrate pg_upgrade_support module into backend

Previously, these functions were created in a schema "binary_upgrade",
which was deleted after pg_upgrade was finished.  Because we don't want
to keep that schema around permanently, move them to pg_catalog but
rename them with a binary_upgrade_... prefix.

The provided functions are only small wrappers around global variables
that were added specifically for pg_upgrade use, so keeping the module
separate does not create any modularity.

The functions still check that they are only called in binary upgrade
mode, so it is not possible to call these during normal operation.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agoOptimize pg_comp_crc32c_sse42 routine slightly, and also use it on x86.
Heikki Linnakangas [Tue, 14 Apr 2015 20:58:16 +0000 (23:58 +0300)]
Optimize pg_comp_crc32c_sse42 routine slightly, and also use it on x86.

Eliminate the separate 'len' variable from the loops, and also use the 4
byte instruction. This shaves off a few more cycles. Even though this
routine that uses the special SSE 4.2 instructions is much faster than a
generic routine, it's still a hot spot, so let's make it as fast as
possible.

Change the configure test to not test _mm_crc32_u64. That variant is only
available in the 64-bit x86-64 architecture, not in 32-bit x86. Modify
pg_comp_crc32c_sse42 so that it only uses _mm_crc32_u64 on x86-64. With
these changes, the SSE accelerated CRC-32C implementation can also be used
on 32-bit x86 systems.

This also fixes the 32-bit MSVC build.

9 years agoOops, fix misspelled #endif
Heikki Linnakangas [Tue, 14 Apr 2015 19:00:52 +0000 (22:00 +0300)]
Oops, fix misspelled #endif

I hope this fixes the Windows builfarm failures.

9 years agoTry to fix the CRC-32C autoconf magic for icc compiler.
Heikki Linnakangas [Tue, 14 Apr 2015 16:56:03 +0000 (19:56 +0300)]
Try to fix the CRC-32C autoconf magic for icc compiler.

On gcc and clang, the _mm_crc32_u8 and _mm_crc32_u64 intrinsics are not
defined at all, when not building with -msse4.2. But on icc, they are.
So we cannot assume that if those intrinsics are defined, we can always use
them safely, we might still need the runtime check.

To fix, check if the __SSE_4_2__ preprocessor symbol is defined. That's
supposed to be defined only when the compiler is targeting a processor that
has SSE 4.2 support.

Per buildfarm members fulmar and okapi.

9 years agoFix typo in comment
Alvaro Herrera [Tue, 14 Apr 2015 15:12:18 +0000 (12:12 -0300)]
Fix typo in comment

SLRU_SEGMENTS_PER_PAGE -> SLRU_PAGES_PER_SEGMENT

I introduced this ancient typo in subtrans.c and later propagated it to
multixact.c.  I fixed the latter in f741300c, but only back to 9.3;
backpatch to all supported branches for consistency.

9 years agoUse Intel SSE 4.2 CRC instructions where available.
Heikki Linnakangas [Tue, 14 Apr 2015 14:05:03 +0000 (17:05 +0300)]
Use Intel SSE 4.2 CRC instructions where available.

Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.

Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)

Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.

9 years agoReorganize our CRC source files again.
Heikki Linnakangas [Tue, 14 Apr 2015 14:03:42 +0000 (17:03 +0300)]
Reorganize our CRC source files again.

Now that we use CRC-32C in WAL and the control file, the "traditional" and
"legacy" CRC-32 variants are not used in any frontend programs anymore.
Move the code for those back from src/common to src/backend/utils/hash.

Also move the slicing-by-8 implementation (back) to src/port. This is in
preparation for next patch that will add another implementation that uses
Intel SSE 4.2 instructions to calculate CRC-32C, where available.

9 years agopgbench: Attempt fix build on Windows
Peter Eisentraut [Mon, 13 Apr 2015 19:32:57 +0000 (15:32 -0400)]
pgbench: Attempt fix build on Windows

9 years agoRemove duplicated word in README
Alvaro Herrera [Mon, 13 Apr 2015 17:28:21 +0000 (14:28 -0300)]
Remove duplicated word in README

9 years agoMove pgbench from contrib/ to src/bin/
Peter Eisentraut [Wed, 11 Mar 2015 02:33:24 +0000 (22:33 -0400)]
Move pgbench from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agoFix pg_rewind regression tests in VPATH builds
Heikki Linnakangas [Mon, 13 Apr 2015 15:28:42 +0000 (18:28 +0300)]
Fix pg_rewind regression tests in VPATH builds

Should call just "pg_rewind", instead of "./pg_rewind". The tests are called
so that PATH contains the temporariy installation bin dir.

Per report from Alvaro Herrera

9 years agoRefactor and fix TAP tests of pg_rewind
Heikki Linnakangas [Mon, 13 Apr 2015 15:06:12 +0000 (18:06 +0300)]
Refactor and fix TAP tests of pg_rewind

* Don't pass arguments to prove, since that's not supported on perl 5.8
which is the minimum version supported by the TAP tests. Refactor the
test files themselves to run the tests twice, in both local and remote mode.

* Use eq rather than == for string comparison. This thinko caused the remote
versions of the tests to never run.

* Add "use strict" and "use warnings", and fix warnings that that produced.

* Increase the delay after standby promotion, to make the tests more robust.

* In remote mode, the connection string to the promoted standby was
incorrect, leading to connection errors.

Patch by Michael Paquier, to address Peter Eisentraut's report.

9 years agoDon't archive bogus recycled or preallocated files after timeline switch.
Heikki Linnakangas [Mon, 13 Apr 2015 13:53:49 +0000 (16:53 +0300)]
Don't archive bogus recycled or preallocated files after timeline switch.

After a timeline switch, we would leave behind recycled WAL segments that
are in the future, but on the old timeline. After promotion, and after they
become old enough to be recycled again, we would notice that they don't have
a .ready or .done file, create a .ready file for them, and archive them.
That's bogus, because the files contain garbage, recycled from an older
timeline (or prealloced as zeros). We shouldn't archive such files.

This could happen when we're following a timeline switch during replay, or
when we switch to new timeline at end-of-recovery.

To fix, whenever we switch to a new timeline, scan the data directory for
WAL segments on the old timeline, but with a higher segment number, and
remove them. Those don't belong to our timeline history, and are most
likely bogus recycled or preallocated files. They could also be valid files
that we streamed from the primary ahead of time, but in any case, they're
not needed to recover to the new timeline.

9 years agoSilence gettext warning about '\r' escape sequence in translatable string.
Fujii Masao [Mon, 13 Apr 2015 04:30:59 +0000 (13:30 +0900)]
Silence gettext warning about '\r' escape sequence in translatable string.

gettext was unhappy about the commit b216ad7 because it revealed
the problem that internationalized messages may contain '\r' escape
sequence in pg_rewind. This commit moves '\r' to a separate printf() call.

Michael Paquier, bug reported by Peter Eisentraut

9 years agoemacs: Set indent-tabs-mode in perl-mode
Peter Eisentraut [Mon, 13 Apr 2015 03:53:23 +0000 (23:53 -0400)]
emacs: Set indent-tabs-mode in perl-mode

This matches existing practice, but makes the setup complete and
consistent with the C code setup.

9 years agoFree leaked result set in pg_rewind
Heikki Linnakangas [Sun, 12 Apr 2015 19:42:01 +0000 (22:42 +0300)]
Free leaked result set in pg_rewind

It was not significant in practice, it was just one instance of a small
result set, but let's pacify Coverity.

Michael Paquier

9 years agoAdd system view pg_stat_ssl
Magnus Hagander [Sun, 12 Apr 2015 17:07:46 +0000 (19:07 +0200)]
Add system view pg_stat_ssl

This view shows information about all connections, such as if the
connection is using SSL, which cipher is used, and which client
certificate (if any) is used.

Reviews by Alex Shulgin, Heikki Linnakangas, Andres Freund & Michael Paquier

9 years agoRemove duplicated words in comments.
Heikki Linnakangas [Sun, 12 Apr 2015 07:46:17 +0000 (10:46 +0300)]
Remove duplicated words in comments.

David Rowley

9 years agoMove pg_archivecleanup from contrib/ to src/bin/
Peter Eisentraut [Wed, 11 Mar 2015 02:33:23 +0000 (22:33 -0400)]
Move pg_archivecleanup from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
9 years agoOptimize locking a tuple already locked by another subxact
Alvaro Herrera [Fri, 10 Apr 2015 16:47:15 +0000 (13:47 -0300)]
Optimize locking a tuple already locked by another subxact

Locking and updating the same tuple repeatedly led to some strange
multixacts being created which had several subtransactions of the same
parent transaction holding locks of the same strength.  However,
once a subxact of the current transaction holds a lock of a given
strength, it's not necessary to acquire the same lock again.  This made
some coding patterns much slower than required.

The fix is twofold.  First we change HeapTupleSatisfiesUpdate to return
HeapTupleBeingUpdated for the case where the current transaction is
already a single-xid locker for the given tuple; it used to return
HeapTupleMayBeUpdated for that case.  The new logic is simpler, and the
change to pgrowlocks is a testament to that: previously we needed to
check for the single-xid locker separately in a very ugly way.  That
test is simpler now.

As fallout from the HTSU change, some of its callers need to be amended
so that tuple-locked-by-own-transaction is taken into account in the
BeingUpdated case rather than the MayBeUpdated case.  For many of them
there is no difference; but heap_delete() and heap_update now check
explicitely and do not grab tuple lock in that case.

The HTSU change also means that routine MultiXactHasRunningRemoteMembers
introduced in commit 11ac4c73cb895 is no longer necessary and can be
removed; the case that used to require it is now handled naturally as
result of the changes to heap_delete and heap_update.

The second part of the fix to the performance issue is to adjust
heap_lock_tuple to avoid the slowness:

1. Previously we checked for the case that our own transaction already
held a strong enough lock and returned MayBeUpdated, but only in the
multixact case.  Now we do it for the plain Xid case as well, which
saves having to LockTuple.

2. If the current transaction is the only locker of the tuple (but with
a lock not as strong as what we need; otherwise it would have been
caught in the check mentioned above), we can skip sleeping on the
multixact, and instead go straight to create an updated multixact with
the additional lock strength.

3. Most importantly, make sure that both the single-xid-locker case and
the multixact-locker case optimization are applied always.  We do this
by checking both in a single place, rather than them appearing in two
separate portions of the routine -- something that is made possible by
the HeapTupleSatisfiesUpdate API change.  Previously we would only check
for the single-xid case when HTSU returned MayBeUpdated, and only
checked for the multixact case when HTSU returned BeingUpdated.  This
was at odds with what HTSU actually returned in one case: if our own
transaction was locker in a multixact, it returned MayBeUpdated, so the
optimization never applied.  This is what led to the large multixacts in
the first place.

Per bug report #8470 by Oskari Saarenmaa.

9 years agolibpq: Don't overwrite existing OpenSSL thread callbacks
Peter Eisentraut [Fri, 10 Apr 2015 00:45:34 +0000 (20:45 -0400)]
libpq: Don't overwrite existing OpenSSL thread callbacks

If someone else already set the callbacks, don't overwrite them with
ours.  When unsetting the callbacks, only unset them if they point to
ours.

Author: Jan Urbański <wulczer@wulczer.org>

9 years agoShow owner of types in psql \dT+
Magnus Hagander [Thu, 9 Apr 2015 19:39:35 +0000 (21:39 +0200)]
Show owner of types in psql \dT+

9 years agoMake SSL regression test suite more portable by avoiding cp.
Heikki Linnakangas [Thu, 9 Apr 2015 19:07:18 +0000 (22:07 +0300)]
Make SSL regression test suite more portable by avoiding cp.

Use perl 'glob' and File::Copy instead of "cp". This takes us one step
closer to running the suite on Windows.

Michael Paquier

9 years agoGitignore temp files generated by SSL regression suite
Heikki Linnakangas [Thu, 9 Apr 2015 18:58:10 +0000 (21:58 +0300)]
Gitignore temp files generated by SSL regression suite

Michael Paquier

9 years agoFix typo
Magnus Hagander [Thu, 9 Apr 2015 12:15:39 +0000 (14:15 +0200)]
Fix typo

Michael Paquier

9 years agoFix incorrect punctuation
Magnus Hagander [Thu, 9 Apr 2015 11:35:30 +0000 (13:35 +0200)]
Fix incorrect punctuation

Amit Langote

9 years agoFix typo in eb68379c3.
Andres Freund [Thu, 9 Apr 2015 11:29:22 +0000 (13:29 +0200)]
Fix typo in eb68379c3.

I'd accidentally missed to rename PG_FORCE_NULL to BKI_FORCE_NULL in one
place.

Author: Jeevan Chalke
Discussion: CAM2+6=VPoow5PqgqiTjPX4QNeokb7op8aD_8Zg3QnHZMvvU0GQ@mail.gmail.com

9 years agoRemove obsolete FORCE option from REINDEX.
Fujii Masao [Thu, 9 Apr 2015 02:31:42 +0000 (11:31 +0900)]
Remove obsolete FORCE option from REINDEX.

FORCE option has been marked "obsolete" since very old version 7.4
but existed for backwards compatibility. Per discussion on pgsql-hackers,
we concluded that it's no longer worth keeping supporting the option.

9 years agoChange SQLSTATE for event triggers "wrong context" message
Alvaro Herrera [Wed, 8 Apr 2015 18:26:50 +0000 (15:26 -0300)]
Change SQLSTATE for event triggers "wrong context" message

When certain event-trigger-only functions are called when not in the
wrong context, they were reporting the "feature not supported" SQLSTATE,
which is somewhat misleading.  Create a new custom error code for such
uses instead.

Not backpatched since it may be seen as an undesirable behavioral
change.

Author: Michael Paquier
Discussion: https://www.postgresql.org/message-id/CAB7nPqQ-5NAkHQHh_NOm7FPep37NCiLKwPoJ2Yxb8TDoGgbYYA@mail.gmail.com

9 years agoFix autovacuum launcher shutdown sequence
Alvaro Herrera [Wed, 8 Apr 2015 16:19:49 +0000 (13:19 -0300)]
Fix autovacuum launcher shutdown sequence

It was previously possible to have the launcher re-execute its main loop
before shutting down if some other signal was received or an error
occurred after getting SIGTERM, as reported by Qingqing Zhou.

While investigating, Tom Lane further noticed that if autovacuum had
been disabled in the config file, it would misbehave by trying to start
a new worker instead of bailing out immediately -- it would consider
itself as invoked in emergency mode.

Fix both problems by checking the shutdown flag in a few more places.
These problems have existed since autovacuum was introduced, so
backpatch all the way back.

9 years agolibpq: add newlines to SSPI error messages
Bruce Momjian [Wed, 8 Apr 2015 14:28:47 +0000 (10:28 -0400)]
libpq:  add newlines to SSPI error messages

Report by Tom Lane

9 years agolibpq: issue clear error message for nested service files
Bruce Momjian [Wed, 8 Apr 2015 14:26:21 +0000 (10:26 -0400)]
libpq:  issue clear error message for nested service files

Previously an odd error message was generated.  Nested service files are
not supported.

Report by David Johnston

9 years agoFix typo in comment.
Fujii Masao [Wed, 8 Apr 2015 11:55:43 +0000 (20:55 +0900)]
Fix typo in comment.

9 years agoAdd file_ops.c to GETTEXT_FILES in nls.mk.
Fujii Masao [Wed, 8 Apr 2015 04:46:58 +0000 (13:46 +0900)]
Add file_ops.c to GETTEXT_FILES in nls.mk.

Since file_ops.c contains translatable strings, it should have been listed
in GETTEXT_FILES.

9 years agoMake trace_sort control abbreviation debug output for the text opclass.
Robert Haas [Wed, 8 Apr 2015 02:45:17 +0000 (22:45 -0400)]
Make trace_sort control abbreviation debug output for the text opclass.

This is consistent with what the new numeric suppor for abbreviated keys
now does, and seems much more convenient than having a separate compiler
define to control this debug output.

Peter Geoghegan

9 years agoMark the second argument of pg_log as the translatable string in nls.mk.
Fujii Masao [Wed, 8 Apr 2015 02:06:25 +0000 (11:06 +0900)]
Mark the second argument of pg_log as the translatable string in nls.mk.

9 years agoFix assorted inconsistent function declarations.
Tom Lane [Tue, 7 Apr 2015 20:56:21 +0000 (16:56 -0400)]
Fix assorted inconsistent function declarations.

While gcc doesn't complain if you declare a function "static" and then
define it not-static, other compilers do; and in any case the code is
highly misleading this way.  Add the missing "static" keywords to a
couple of recent patches.  Per buildfarm member pademelon.

9 years agoFix reporting of missing or invalid command line arguments in pg_rewind.
Heikki Linnakangas [Tue, 7 Apr 2015 20:28:28 +0000 (23:28 +0300)]
Fix reporting of missing or invalid command line arguments in pg_rewind.

pg_fatal never returns, so a multi-line message cannot be printed by
calling it twice.

Michael Paquier and Fujii Masao

9 years agoRemove variable shadowing
Alvaro Herrera [Tue, 7 Apr 2015 20:14:00 +0000 (17:14 -0300)]
Remove variable shadowing

Commit a2e35b53 should have removed the variable declaration in the
inner block, but didn't.  As a result, the returned address might end up
not being what was intended.

9 years agoFix process startup in pg_rewind.
Heikki Linnakangas [Tue, 7 Apr 2015 20:04:25 +0000 (23:04 +0300)]
Fix process startup in pg_rewind.

Don't allow pg_rewind to run as root on Unix platforms, as any new or
replaced files in the data directory would become owned by root. On Windows,
it can run under a user that has Administrator rights, but a restricted
token needs to be used. This is the same we do e.g. in pg_resetxlog.

Also, add missing set_pglocale_pgservice() call, to fix localization.

Michael Paquier and Fujii Masao

9 years agoFix spelling of author's name
Simon Riggs [Tue, 7 Apr 2015 18:04:29 +0000 (14:04 -0400)]
Fix spelling of author's name

9 years agopg_event_trigger_dropped_objects: add is_temp column
Alvaro Herrera [Mon, 6 Apr 2015 14:40:55 +0000 (11:40 -0300)]
pg_event_trigger_dropped_objects: add is_temp column

It now also reports temporary objects dropped that are local to the
backend.  Previously we weren't reporting any temp objects because it
was deemed unnecessary; but as it turns out, it is necessary if we want
to keep close track of DDL command execution inside one session.  Temp
objects are reported as living in schema pg_temp, which works because
such a schema-qualification always refers to the temp objects of the
current session.