]> granicus.if.org Git - postgresql/log
postgresql
9 years agoFix portability issue in pg_audit.
Tom Lane [Thu, 14 May 2015 17:19:26 +0000 (13:19 -0400)]
Fix portability issue in pg_audit.

"%ld" is not a portable way to print int64's.  This may explain the
buildfarm crashes we're seeing --- it seems to make dromedary happy,
at least.

9 years agoSuppress uninitialized-variable warning.
Tom Lane [Thu, 14 May 2015 16:16:06 +0000 (12:16 -0400)]
Suppress uninitialized-variable warning.

9 years agoSupport "expanded" objects, particularly arrays, for better performance.
Tom Lane [Thu, 14 May 2015 16:08:40 +0000 (12:08 -0400)]
Support "expanded" objects, particularly arrays, for better performance.

This patch introduces the ability for complex datatypes to have an
in-memory representation that is different from their on-disk format.
On-disk formats are typically optimized for minimal size, and in any case
they can't contain pointers, so they are often not well-suited for
computation.  Now a datatype can invent an "expanded" in-memory format
that is better suited for its operations, and then pass that around among
the C functions that operate on the datatype.  There are also provisions
(rudimentary as yet) to allow an expanded object to be modified in-place
under suitable conditions, so that operations like assignment to an element
of an array need not involve copying the entire array.

The initial application for this feature is arrays, but it is not hard
to foresee using it for other container types like JSON, XML and hstore.
I have hopes that it will be useful to PostGIS as well.

In this initial implementation, a few heuristics have been hard-wired
into plpgsql to improve performance for arrays that are stored in
plpgsql variables.  We would like to generalize those hacks so that
other datatypes can obtain similar improvements, but figuring out some
appropriate APIs is left as a task for future work.  (The heuristics
themselves are probably not optimal yet, either, as they sometimes
force expansion of arrays that would be better left alone.)

Preliminary performance testing shows impressive speed gains for plpgsql
functions that do element-by-element access or update of large arrays.
There are other cases that get a little slower, as a result of added array
format conversions; but we can hope to improve anything that's annoyingly
bad.  In any case most applications should see a net win.

Tom Lane, reviewed by Andres Freund

9 years agoFurther fixes for the buildfarm for pg_audit
Stephen Frost [Thu, 14 May 2015 15:55:36 +0000 (11:55 -0400)]
Further fixes for the buildfarm for pg_audit

Also, use a function to load the extension ahead of all other calls,
simulating load from shared_libraries_preload, to make sure the
hooks are in place before logging start.

9 years agoFurther fixes for the buildfarm for pg_audit
Stephen Frost [Thu, 14 May 2015 15:44:16 +0000 (11:44 -0400)]
Further fixes for the buildfarm for pg_audit

The database built by the buildfarm is specific to the extension, use
\connect - instead.

9 years agoFix buildfarm with regard to pg_audit
Stephen Frost [Thu, 14 May 2015 14:57:12 +0000 (10:57 -0400)]
Fix buildfarm with regard to pg_audit

Remove the check that pg_audit be installed by
shared_preload_libraries as that's not going to work when running the
regressions tests in the buildfarm.  That check was primairly a nice to
have and isn't required anyway.

9 years agoAdd pg_audit, an auditing extension
Stephen Frost [Thu, 14 May 2015 14:36:16 +0000 (10:36 -0400)]
Add pg_audit, an auditing extension

This extension provides detailed logging classes, ability to control
logging at a per-object level, and includes fully-qualified object
names for logged statements (DML and DDL) in independent fields of the
log output.

Authors: Ian Barwick, Abhijit Menon-Sen, David Steele
Reviews by: Robert Haas, Tatsuo Ishii, Sawada Masahiko, Fujii Masao,
Simon Riggs

Discussion with: Josh Berkus, Jaime Casanova, Peter Eisentraut,
David Fetter, Yeb Havinga, Alvaro Herrera, Petr Jelinek, Tom Lane,
MauMau, Bruce Momjian, Jim Nasby, Michael Paquier,
Fabrízio de Royes Mello, Neil Tiffin

9 years agoFix distclean/maintainer-clean targets to remove top-level tmp_install dir.
Tom Lane [Wed, 13 May 2015 22:48:05 +0000 (18:48 -0400)]
Fix distclean/maintainer-clean targets to remove top-level tmp_install dir.

The top-level makefile removes tmp_install in its "clean" target, but the
distclean and maintainer-clean targets overlooked that (and they don't
simply invoke clean, because that would result in an extra tree traversal).

While at it, let's just make sure that removing GNUmakefile itself is the
very last step of the recipe.

9 years agoFix comment.
Robert Haas [Wed, 13 May 2015 19:27:41 +0000 (15:27 -0400)]
Fix comment.

Commit 78efd5c1edb59017f06ef96773e64e6539bfbc86 overlooked this.

Report by Peter Geoghegan.

9 years agoExtend abbreviated key infrastructure to datum tuplesorts.
Robert Haas [Wed, 13 May 2015 18:36:26 +0000 (14:36 -0400)]
Extend abbreviated key infrastructure to datum tuplesorts.

Andrew Gierth, reviewed by Peter Geoghegan and by me.

9 years agoFix postgres_fdw to return the right ctid value in EvalPlanQual cases.
Tom Lane [Wed, 13 May 2015 18:05:17 +0000 (14:05 -0400)]
Fix postgres_fdw to return the right ctid value in EvalPlanQual cases.

If a postgres_fdw foreign table is a non-locked source relation in an
UPDATE, DELETE, or SELECT FOR UPDATE/SHARE, and the query selects its
ctid column, the wrong value would be returned if an EvalPlanQual
recheck occurred.  This happened because the foreign table's result row
was copied via the ROW_MARK_COPY code path, and EvalPlanQualFetchRowMarks
just unconditionally set the reconstructed tuple's t_self to "invalid".

To fix that, we can have EvalPlanQualFetchRowMarks copy the composite
datum's t_ctid field, and be sure to initialize that along with t_self
when postgres_fdw constructs a tuple to return.

If we just did that much then EvalPlanQualFetchRowMarks would start
returning "(0,0)" as ctid for all other ROW_MARK_COPY cases, which perhaps
does not matter much, but then again maybe it might.  The cause of that is
that heap_form_tuple, which is the ultimate source of all composite datums,
simply leaves t_ctid as zeroes in newly constructed tuples.  That seems
like a bad idea on general principles: a field that's really not been
initialized shouldn't appear to have a valid value.  So let's eat the
trivial additional overhead of doing "ItemPointerSetInvalid(&(td->t_ctid))"
in heap_form_tuple.

This closes out our handling of Etsuro Fujita's report that tableoid and
ctid weren't correctly set in postgres_fdw EvalPlanQual cases.  Along the
way we did a great deal of work to improve FDWs' ability to control row
locking behavior; which was not wasted effort by any means, but it didn't
end up being a fix for this problem because that feature would be too
expensive for postgres_fdw to use all the time.

Although the fix for the tableoid misbehavior was back-patched, I'm
hesitant to do so here; it seems far less likely that people would care
about remote ctid than tableoid, and even such a minor behavioral change
as this in heap_form_tuple is perhaps best not back-patched.  So commit
to HEAD only, at least for the moment.

Etsuro Fujita, with some adjustments by me

9 years agoFix jsonb replace and delete on scalars and empty structures
Andrew Dunstan [Wed, 13 May 2015 17:52:08 +0000 (13:52 -0400)]
Fix jsonb replace and delete on scalars and empty structures

These operations now error out if attempted on scalars, and simply
return the input if attempted on empty arrays or objects. Along the way
we remove the unnecessary cloning of the input when it's known to be
unchanged. Regression tests covering these cases are added.

9 years agoRemove useless assertion.
Robert Haas [Wed, 13 May 2015 15:01:10 +0000 (11:01 -0400)]
Remove useless assertion.

Here, snapshot->xcnt is an unsigned type, so it will always be
non-negative.

9 years agoAdd pgstattuple_approx() to the pgstattuple extension.
Andres Freund [Wed, 13 May 2015 05:31:04 +0000 (07:31 +0200)]
Add pgstattuple_approx() to the pgstattuple extension.

The new function allows to estimate bloat and other table level statics
in a faster, but approximate, way. It does so by using information from
the free space map for pages marked as all visible in the visibility
map. The rest of the table is actually read and free space/bloat is
measured accurately.  In many cases that allows to get bloat information
much quicker, causing less IO.

Author: Abhijit Menon-Sen
Reviewed-By: Andres Freund, Amit Kapila and Tomas Vondra
Discussion: 20140402214144.GA28681@kea.toroid.org

9 years agoPL/Python: Remove procedure cache invalidation
Peter Eisentraut [Wed, 13 May 2015 02:52:18 +0000 (22:52 -0400)]
PL/Python: Remove procedure cache invalidation

This was added to react to changes in the pg_transform catalog, but
building with CLOBBER_CACHE_ALWAYS showed that PL/Python was not
prepared for having its procedure cache cleared.  Since this is a
marginal use case, and we don't do this for other catalogs anyway, we
can postpone this to another day.

9 years agoFix ON CONFLICT bugs that manifest when used in rules.
Andres Freund [Tue, 12 May 2015 22:13:22 +0000 (00:13 +0200)]
Fix ON CONFLICT bugs that manifest when used in rules.

Specifically the tlist and rti of the pseudo "excluded" relation weren't
properly treated by expression_tree_walker, which lead to errors when
excluded was referenced inside a rule because the varnos where not
properly adjusted.  Similar omissions in OffsetVarNodes and
expression_tree_mutator had less impact, but should obviously be fixed
nonetheless.

A couple tests of for ON CONFLICT UPDATE into INSERT rule bearing
relations have been added.

In passing I updated a couple comments.

9 years agoFix some errors from jsonb functions patch.
Andrew Dunstan [Tue, 12 May 2015 20:54:38 +0000 (16:54 -0400)]
Fix some errors from jsonb functions patch.

The catalog version should have been bumped, and the alternative
regression result file was not up to date with the name of jsonb_pretty.

9 years agoAdditional functions and operators for jsonb
Andrew Dunstan [Tue, 12 May 2015 19:52:45 +0000 (15:52 -0400)]
Additional functions and operators for jsonb

jsonb_pretty(jsonb) produces nicely indented json output.
jsonb || jsonb concatenates two jsonb values.
jsonb - text removes a key and its associated value from the json
jsonb - int removes the designated array element
jsonb - text[] removes a key and associated value or array element at
the designated path
jsonb_replace(jsonb,text[],jsonb) replaces the array element designated
by the path or the value associated with the key designated by the path
with the given value.

Original work by Dmitry Dolgov, adapted and reworked for PostgreSQL core
by Andrew Dunstan, reviewed and tidied up by Petr Jelinek.

9 years agoAdd support for doing late row locking in FDWs.
Tom Lane [Tue, 12 May 2015 18:10:10 +0000 (14:10 -0400)]
Add support for doing late row locking in FDWs.

Previously, FDWs could only do "early row locking", that is lock a row as
soon as it's fetched, even though local restriction/join conditions might
discard the row later.  This patch adds callbacks that allow FDWs to do
late locking in the same way that it's done for regular tables.

To make use of this feature, an FDW must support the "ctid" column as a
unique row identifier.  Currently, since ctid has to be of type TID,
the feature is of limited use, though in principle it could be used by
postgres_fdw.  We may eventually allow FDWs to specify another data type
for ctid, which would make it possible for more FDWs to use this feature.

This commit does not modify postgres_fdw to use late locking.  We've
tested some prototype code for that, but it's not in committable shape,
and besides it's quite unclear whether it actually makes sense to do late
locking against a remote server.  The extra round trips required are likely
to outweigh any benefit from improved concurrency.

Etsuro Fujita, reviewed by Ashutosh Bapat, and hacked up a lot by me

9 years agopgbench: Don't fail during startup
Stephen Frost [Tue, 12 May 2015 17:13:12 +0000 (13:13 -0400)]
pgbench: Don't fail during startup

In pgbench, report, but ignore, any errors returned when attempting to
vacuum/truncate the default tables during startup.  If the tables are
needed, we'll error out soon enough anyway.

Per discussion with Tatsuo, David Rowley, Jim Nasby, Robert, Andres,
Fujii, Fabrízio de Royes Mello, Tomas Vondra, Michael Paquier, Peter,
based on a suggestion from Jeff Janes, patch from Robert, additional
message wording from Tom.

9 years agopg_basebackup -F t now succeeds with a long symlink target
Andrew Dunstan [Tue, 12 May 2015 17:09:34 +0000 (13:09 -0400)]
pg_basebackup -F t now succeeds with a long symlink target

9 years agodoc build: use unique Makefile variable to control temp install
Bruce Momjian [Tue, 12 May 2015 16:30:50 +0000 (12:30 -0400)]
doc build:  use unique Makefile variable to control temp install

9 years ago"Fix" test_ddl_deparse regress test schedule
Alvaro Herrera [Tue, 12 May 2015 15:12:39 +0000 (12:12 -0300)]
"Fix" test_ddl_deparse regress test schedule

MSVC is not smart enough to figure it out, so dumb down the Makefile and
remove the schedule file.

Also add a .gitignore file.

Author: Michael Paquier

9 years agodoc: prevent SGML 'make check' from building temp install
Bruce Momjian [Tue, 12 May 2015 15:01:25 +0000 (11:01 -0400)]
doc:  prevent SGML 'make check' from building temp install

Report by Alvaro Herrera

9 years agoMap basebackup tablespaces using a tablespace_map file
Andrew Dunstan [Tue, 12 May 2015 13:29:10 +0000 (09:29 -0400)]
Map basebackup tablespaces using a tablespace_map file

Windows can't reliably restore symbolic links from a tar format, so
instead during backup start we create a tablespace_map file, which is
used by the restoring postgres to create the correct links in pg_tblspc.
The backup protocol also now has an option to request this file to be
included in the backup stream, and this is used by pg_basebackup when
operating in tar mode.

This is done on all platforms, not just Windows.

This means that pg_basebackup will not not work in tar mode against 9.4
and older servers, as this protocol option isn't implemented there.

Amit Kapila, reviewed by Dilip Kumar, with a little editing from me.

9 years agoReplace some appendStringInfo* calls with more appropriate variants
Peter Eisentraut [Tue, 12 May 2015 00:38:55 +0000 (20:38 -0400)]
Replace some appendStringInfo* calls with more appropriate variants

Author: David Rowley <dgrowleyml@gmail.com>

9 years agoAllow on-the-fly capture of DDL event details
Alvaro Herrera [Mon, 11 May 2015 22:14:31 +0000 (19:14 -0300)]
Allow on-the-fly capture of DDL event details

This feature lets user code inspect and take action on DDL events.
Whenever a ddl_command_end event trigger is installed, DDL actions
executed are saved to a list which can be inspected during execution of
a function attached to ddl_command_end.

The set-returning function pg_event_trigger_ddl_commands can be used to
list actions so captured; it returns data about the type of command
executed, as well as the affected object.  This is sufficient for many
uses of this feature.  For the cases where it is not, we also provide a
"command" column of a new pseudo-type pg_ddl_command, which is a
pointer to a C structure that can be accessed by C code.  The struct
contains all the info necessary to completely inspect and even
reconstruct the executed command.

There is no actual deparse code here; that's expected to come later.
What we have is enough infrastructure that the deparsing can be done in
an external extension.  The intention is that we will add some deparsing
code in a later release, as an in-core extension.

A new test module is included.  It's probably insufficient as is, but it
should be sufficient as a starting point for a more complete and
future-proof approach.

Authors: Álvaro Herrera, with some help from Andres Freund, Ian Barwick,
Abhijit Menon-Sen.

Reviews by Andres Freund, Robert Haas, Amit Kapila, Michael Paquier,
Craig Ringer, David Steele.
Additional input from Chris Browne, Dimitri Fontaine, Stephen Frost,
Petr Jelínek, Tom Lane, Jim Nasby, Steven Singer, Pavel Stěhule.

Based on original work by Dimitri Fontaine, though I didn't use his
code.

Discussion:
  https://www.postgresql.org/message-id/m2txrsdzxa.fsf@2ndQuadrant.fr
  https://www.postgresql.org/message-id/20131108153322.GU5809@eldon.alvh.no-ip.org
  https://www.postgresql.org/message-id/20150215044814.GL3391@alvh.no-ip.org

9 years agoAllow LOCK TABLE .. ROW EXCLUSIVE MODE with INSERT
Stephen Frost [Mon, 11 May 2015 19:44:12 +0000 (15:44 -0400)]
Allow LOCK TABLE .. ROW EXCLUSIVE MODE with INSERT

INSERT acquires RowExclusiveLock during normal operation and therefore
it makes sense to allow LOCK TABLE .. ROW EXCLUSIVE MODE to be executed
by users who have INSERT rights on a table (even if they don't have
UPDATE or DELETE).

Not back-patching this as it's a behavior change which, strictly
speaking, loosens security restrictions.

Per discussion with Tom and Robert (circa 2013).

9 years agopg_upgrade: use single or double-quotes in command-line strings
Bruce Momjian [Mon, 11 May 2015 16:57:48 +0000 (12:57 -0400)]
pg_upgrade:  use single or double-quotes in command-line strings

This is platform-dependent.

9 years agoFix incorrect checking of deferred exclusion constraint after a HOT update.
Tom Lane [Mon, 11 May 2015 16:25:28 +0000 (12:25 -0400)]
Fix incorrect checking of deferred exclusion constraint after a HOT update.

If a row that potentially violates a deferred exclusion constraint is
HOT-updated later in the same transaction, the exclusion constraint would
be reported as violated when the check finally occurs, even if the row(s)
the new row originally conflicted with have since been removed.  This
happened because the wrong TID was passed to check_exclusion_constraint(),
causing the live HOT-updated row to be seen as a conflicting row rather
than recognized as the row-under-test.

Per bug #13148 from Evan Martin.  It's been broken since exclusion
constraints were invented, so back-patch to all supported branches.

9 years agoIncrease threshold for multixact member emergency autovac to 50%.
Robert Haas [Mon, 11 May 2015 16:07:13 +0000 (12:07 -0400)]
Increase threshold for multixact member emergency autovac to 50%.

Analysis by Noah Misch shows that the 25% threshold set by commit
53bb309d2d5a9432d2602c93ed18e58bd2924e15 is lower than any other,
similar autovac threshold.  While we don't know exactly what value
will be optimal for all users, it is better to err a little on the
high side than on the low side.  A higher value increases the risk
that users might exhaust the available space and start seeing errors
before autovacuum can clean things up sufficiently, but a user who
hits that problem can compensate for it by reducing
autovacuum_multixact_freeze_max_age to a value dependent on their
average multixact size.  On the flip side, if the emergency cap
imposed by that patch kicks in too early, the user will experience
excessive wraparound scanning and will be unable to mitigate that
problem by configuration.  The new value will hopefully reduce the
risk of such bad experiences while still providing enough headroom
to avoid multixact member exhaustion for most users.

Along the way, adjust the documentation to reflect the effects of
commit 04e6d3b877e060d8445eb653b7ea26b1ee5cec6b, which taught
autovacuum to run for multixact wraparound even when autovacuum
is configured off.

9 years agoinitdb: only recommend pg_ctl to start the server
Bruce Momjian [Mon, 11 May 2015 16:14:57 +0000 (12:14 -0400)]
initdb:  only recommend pg_ctl to start the server

Previously we mentioned the 'postgres' binary method as well.

9 years agodocs: add "serialization anomaly" to transaction isolation table
Bruce Momjian [Mon, 11 May 2015 16:02:10 +0000 (12:02 -0400)]
docs:  add "serialization anomaly" to transaction isolation table

Also distinguish between SQL-standard and Postgres behavior.

Report by David G. Johnston

9 years agopg_dump: suppress "Tablespace:" comment for default tablespaces
Bruce Momjian [Mon, 11 May 2015 15:45:43 +0000 (11:45 -0400)]
pg_dump:  suppress "Tablespace:" comment for default tablespaces

Report by Hans Ginzel

9 years agoEven when autovacuum=off, force it for members as we do in other cases.
Robert Haas [Mon, 11 May 2015 14:51:14 +0000 (10:51 -0400)]
Even when autovacuum=off, force it for members as we do in other cases.

Thomas Munro, with some adjustments by me.

9 years agoAdvance the stop point for multixact offset creation only at checkpoint.
Robert Haas [Mon, 11 May 2015 02:21:20 +0000 (22:21 -0400)]
Advance the stop point for multixact offset creation only at checkpoint.

Commit b69bf30b9bfacafc733a9ba77c9587cf54d06c0c advanced the stop point
at vacuum time, but this has subsequently been shown to be unsafe as a
result of analysis by myself and Thomas Munro and testing by Thomas
Munro.  The crux of the problem is that the SLRU deletion logic may
get confused about what to remove if, at exactly the right time during
the checkpoint process, the head of the SLRU crosses what used to be
the tail.

This patch, by me, fixes the problem by advancing the stop point only
following a checkpoint.  This has the additional advantage of making
the removal logic work during recovery more like the way it works during
normal running, which is probably good.

At least one of the calls to DetermineSafeOldestOffset which this patch
removes was already dead, because MultiXactAdvanceOldest is called only
during recovery and DetermineSafeOldestOffset was set up to do nothing
during recovery.  That, however, is inconsistent with the principle that
recovery and normal running should work similarly, and was confusing to
boot.

Along the way, fix some comments that previous patches in this area
neglected to update.  It's not clear to me whether there's any
concrete basis for the decision to use only half of the multixact ID
space, but it's neither necessary nor sufficient to prevent multixact
member wraparound, so the comments should not say otherwise.

9 years agoFix DetermineSafeOldestOffset for the case where there are no mxacts.
Robert Haas [Mon, 11 May 2015 01:34:26 +0000 (21:34 -0400)]
Fix DetermineSafeOldestOffset for the case where there are no mxacts.

Commit b69bf30b9bfacafc733a9ba77c9587cf54d06c0c failed to take into
account the possibility that there might be no multixacts in existence
at all.

Report by Thomas Munro; patch by me.

9 years agoCode review for foreign/custom join pushdown patch.
Tom Lane [Sun, 10 May 2015 18:36:30 +0000 (14:36 -0400)]
Code review for foreign/custom join pushdown patch.

Commit e7cb7ee14555cc9c5773e2c102efd6371f6f2005 included some design
decisions that seem pretty questionable to me, and there was quite a lot
of stuff not to like about the documentation and comments.  Clean up
as follows:

* Consider foreign joins only between foreign tables on the same server,
rather than between any two foreign tables with the same underlying FDW
handler function.  In most if not all cases, the FDW would simply have had
to apply the same-server restriction itself (far more expensively, both for
lack of caching and because it would be repeated for each combination of
input sub-joins), or else risk nasty bugs.  Anyone who's really intent on
doing something outside this restriction can always use the
set_join_pathlist_hook.

* Rename fdw_ps_tlist/custom_ps_tlist to fdw_scan_tlist/custom_scan_tlist
to better reflect what they're for, and allow these custom scan tlists
to be used even for base relations.

* Change make_foreignscan() API to include passing the fdw_scan_tlist
value, since the FDW is required to set that.  Backwards compatibility
doesn't seem like an adequate reason to expect FDWs to set it in some
ad-hoc extra step, and anyway existing FDWs can just pass NIL.

* Change the API of path-generating subroutines of add_paths_to_joinrel,
and in particular that of GetForeignJoinPaths and set_join_pathlist_hook,
so that various less-used parameters are passed in a struct rather than
as separate parameter-list entries.  The objective here is to reduce the
probability that future additions to those parameter lists will result in
source-level API breaks for users of these hooks.  It's possible that this
is even a small win for the core code, since most CPU architectures can't
pass more than half a dozen parameters efficiently anyway.  I kept root,
joinrel, outerrel, innerrel, and jointype as separate parameters to reduce
code churn in joinpath.c --- in particular, putting jointype into the
struct would have been problematic because of the subroutines' habit of
changing their local copies of that variable.

* Avoid ad-hocery in ExecAssignScanProjectionInfo.  It was probably all
right for it to know about IndexOnlyScan, but if the list is to grow
we should refactor the knowledge out to the callers.

* Restore nodeForeignscan.c's previous use of the relcache to avoid
extra GetFdwRoutine lookups for base-relation scans.

* Lots of cleanup of documentation and missed comments.  Re-order some
code additions into more logical places.

9 years agoAdd missing "static" marker.
Tom Lane [Sun, 10 May 2015 03:39:36 +0000 (23:39 -0400)]
Add missing "static" marker.

Per buildfarm member pademelon.

9 years agoCorrect reindexdb documentation
Stephen Frost [Sat, 9 May 2015 18:45:54 +0000 (14:45 -0400)]
Correct reindexdb documentation

--schema takes a schema, not a table.

Author: Sawada Masahiko

9 years agodoc: adjust ordering of pg_stat_statement paragraphs
Bruce Momjian [Sat, 9 May 2015 18:11:31 +0000 (14:11 -0400)]
doc:  adjust ordering of pg_stat_statement paragraphs

Clarify installation instructions

Patch by Ian Barwick

9 years agoAdd new OID alias type regnamespace
Andrew Dunstan [Sat, 9 May 2015 17:36:52 +0000 (13:36 -0400)]
Add new OID alias type regnamespace

Catalog version bumped

Kyotaro HORIGUCHI

9 years agoAdd new OID alias type regrole
Andrew Dunstan [Sat, 9 May 2015 17:06:49 +0000 (13:06 -0400)]
Add new OID alias type regrole

The new type has the scope of whole the database cluster so it doesn't
behave the same as the existing OID alias types which have database
scope,
concerning object dependency. To avoid confusion constants of the new
type are prohibited from appearing where dependencies are made involving
it.

Also, add a note to the docs about possible MVCC violation and
optimization issues, which are general over the all reg* types.

Kyotaro Horiguchi

9 years agoImprove ParseConfigFp comment wrt head/tail
Stephen Frost [Sat, 9 May 2015 15:13:37 +0000 (11:13 -0400)]
Improve ParseConfigFp comment wrt head/tail

The head_p and tail_p pointers passed to ParseConfigFp() are actually
input/output parameters, not strictly output paramaters.  This updates
the function comment to reflect that.

Per discussion with Tom.

9 years agoChange default for include_realm to 1
Stephen Frost [Fri, 8 May 2015 23:39:42 +0000 (19:39 -0400)]
Change default for include_realm to 1

The default behavior for GSS and SSPI authentication methods has long
been to strip the realm off of the principal, however, this is not a
secure approach in multi-realm environments and the use-case for the
parameter at all has been superseded by the regex-based mapping support
available in pg_ident.conf.

Change the default for include_realm to be '1', meaning that we do
NOT remove the realm from the principal by default.  Any installations
which depend on the existing behavior will need to update their
configurations (ideally by leaving include_realm set to 1 and adding a
mapping in pg_ident.conf, but alternatively by explicitly setting
include_realm=0 prior to upgrading).  Note that the mapping capability
exists in all currently supported versions of PostgreSQL and so this
change can be done today.  Barring that, existing users can update their
configurations today to explicitly set include_realm=0 to ensure that
the prior behavior is maintained when they upgrade.

This needs to be noted in the release notes.

Per discussion with Magnus and Peter.

9 years agoModify pg_stat_get_activity to build a tuplestore
Stephen Frost [Fri, 8 May 2015 23:25:30 +0000 (19:25 -0400)]
Modify pg_stat_get_activity to build a tuplestore

This updates pg_stat_get_activity() to build a tuplestore for its
results instead of using the old-style multiple-call method.  This
simplifies the function, though that wasn't the primary motivation for
the change, which is that we may turn it into a helper function which
can filter the results (or not) much more easily.

9 years agoBump catversion for pg_file_settings
Stephen Frost [Fri, 8 May 2015 23:14:32 +0000 (19:14 -0400)]
Bump catversion for pg_file_settings

Pointed out by Andres (thanks!)

Apologies for not including it in the initial patch.

9 years agoAdd pg_file_settings view and function
Stephen Frost [Fri, 8 May 2015 23:09:26 +0000 (19:09 -0400)]
Add pg_file_settings view and function

The function and view added here provide a way to look at all settings
in postgresql.conf, any #include'd files, and postgresql.auto.conf
(which is what backs the ALTER SYSTEM command).

The information returned includes the configuration file name, line
number in that file, sequence number indicating when the parameter is
loaded (useful to see if it is later masked by another definition of the
same parameter), parameter name, and what it is set to at that point.
This information is updated on reload of the server.

This is unfiltered, privileged, information and therefore access is
restricted to superusers through the GRANT system.

Author: Sawada Masahiko, various improvements by me.
Reviewers: David Steele

9 years agoFix two problems in infer_arbiter_indexes().
Andres Freund [Fri, 8 May 2015 20:22:05 +0000 (22:22 +0200)]
Fix two problems in infer_arbiter_indexes().

The first is a pretty simple bug where a relcache entry is used after
the relation is closed. In this particular situation it does not appear
to have bad consequences unless compiled with RELCACHE_FORCE_RELEASE.

The second is that infer_arbiter_indexes() skipped indexes that aren't
yet valid according to indcheckxmin. That's not required here, because
uniqueness checks don't care about visibility according to an older
snapshot.  While thats not really a bug, it makes things undesirably
non-deterministic.  There is some hope that this explains a test failure
on buildfarm member jaguarundi.

Discussion: 9096.1431102730@sss.pgh.pa.us

9 years agoAt promotion, archive last segment from old timeline with .partial suffix.
Heikki Linnakangas [Fri, 8 May 2015 18:59:01 +0000 (21:59 +0300)]
At promotion, archive last segment from old timeline with .partial suffix.

Previously, we would archive the possible-incomplete WAL segment with its
normal filename, but that causes trouble if the server owning that timeline
is still running, and tries to archive the same segment later. It's not nice
for the standby to trip up the master's archival like that. And it's pretty
confusing, anyway, to have an incomplete segment in the archive that's
indistinguishable from a normal, complete segment.

To avoid such confusion, add a .partial suffix to the file. Or to be more
precise, make a copy of the old segment under the .partial suffix, and
archive that instead of the original file. pg_receivexlog also uses the
.partial suffix for the same purpose, to tell apart incompletely streamed
files from complete ones.

There is no automatic mechanism to use the .partial files at recovery, so
they will go unused, unless the administrator manually copies to them to
the pg_xlog directory (and removes the .partial suffix). Recovery won't
normally need the WAL - when recovering to the new timeline, it will find
the same WAL on the first segment on the new timeline instead - but it
nevertheless feels better to archive the file with the .partial suffix, for
debugging purposes if nothing else.

9 years agoAdd macros to check if a filename is a WAL segment or other such file.
Heikki Linnakangas [Fri, 8 May 2015 18:58:57 +0000 (21:58 +0300)]
Add macros to check if a filename is a WAL segment or other such file.

We had many instances of the strlen + strspn combination to check for that.
This makes the code a bit easier to read.

9 years agoFix whitespace
Peter Eisentraut [Fri, 8 May 2015 18:45:53 +0000 (14:45 -0400)]
Fix whitespace

9 years agoMinor ON CONFLICT related comments and doc fixes.
Andres Freund [Fri, 8 May 2015 16:00:01 +0000 (18:00 +0200)]
Minor ON CONFLICT related comments and doc fixes.

Geoff Winkless, Stephen Frost, Peter Geoghegan and me.

9 years agoTeach autovacuum about multixact member wraparound.
Robert Haas [Fri, 8 May 2015 16:09:14 +0000 (12:09 -0400)]
Teach autovacuum about multixact member wraparound.

The logic introduced in commit b69bf30b9bfacafc733a9ba77c9587cf54d06c0c
and repaired in commits 669c7d20e6374850593cb430d332e11a3992bbcf and
7be47c56af3d3013955c91c2877c08f2a0e3e6a2 helps to ensure that we don't
overwrite old multixact member information while it is still needed,
but a user who creates many large multixacts can still exhaust the
member space (and thus start getting errors) while autovacuum stands
idly by.

To fix this, progressively ramp down the effective value (but not the
actual contents) of autovacuum_multixact_freeze_max_age as member space
utilization increases.  This makes autovacuum more aggressive and also
reduces the threshold for a manual VACUUM to perform a full-table scan.

This patch leaves unsolved the problem of ensuring that emergency
autovacuums are triggered even when autovacuum=off.  We'll need to fix
that via a separate patch.

Thomas Munro and Robert Haas

9 years agoRemove reference to src/tools/backend/index.html
Stephen Frost [Fri, 8 May 2015 11:14:18 +0000 (07:14 -0400)]
Remove reference to src/tools/backend/index.html

src/tools/backend was removed back in 63f1ccd, but
backend/storage/lmgr/README didn't get the memo.

Author: Amit Langote

9 years agoRemove dependency on ordering in logical decoding upsert test.
Andres Freund [Fri, 8 May 2015 04:06:03 +0000 (06:06 +0200)]
Remove dependency on ordering in logical decoding upsert test.

Buildfarm member magpie sorted the output differently than intended by
Peter. "Resolve" the problem by simply not aggregating, it's not that
many lines.

9 years agoAdd support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
Andres Freund [Fri, 8 May 2015 03:31:36 +0000 (05:31 +0200)]
Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.

The newly added ON CONFLICT clause allows to specify an alternative to
raising a unique or exclusion constraint violation error when inserting.
ON CONFLICT refers to constraints that can either be specified using a
inference clause (by specifying the columns of a unique constraint) or
by naming a unique or exclusion constraint.  DO NOTHING avoids the
constraint violation, without touching the pre-existing row.  DO UPDATE
SET ... [WHERE ...] updates the pre-existing tuple, and has access to
both the tuple proposed for insertion and the existing tuple; the
optional WHERE clause can be used to prevent an update from being
executed.  The UPDATE SET and WHERE clauses have access to the tuple
proposed for insertion using the "magic" EXCLUDED alias, and to the
pre-existing tuple using the table name or its alias.

This feature is often referred to as upsert.

This is implemented using a new infrastructure called "speculative
insertion". It is an optimistic variant of regular insertion that first
does a pre-check for existing tuples and then attempts an insert.  If a
violating tuple was inserted concurrently, the speculatively inserted
tuple is deleted and a new attempt is made.  If the pre-check finds a
matching tuple the alternative DO NOTHING or DO UPDATE action is taken.
If the insertion succeeds without detecting a conflict, the tuple is
deemed inserted.

To handle the possible ambiguity between the excluded alias and a table
named excluded, and for convenience with long relation names, INSERT
INTO now can alias its target table.

Bumps catversion as stored rules change.

Author: Peter Geoghegan, with significant contributions from Heikki
    Linnakangas and Andres Freund. Testing infrastructure by Jeff Janes.
Reviewed-By: Heikki Linnakangas, Andres Freund, Robert Haas, Simon Riggs,
    Dean Rasheed, Stephen Frost and many others.

9 years agoRepresent columns requiring insert and update privileges indentently.
Andres Freund [Thu, 7 May 2015 22:20:46 +0000 (00:20 +0200)]
Represent columns requiring insert and update privileges indentently.

Previously, relation range table entries used a single Bitmapset field
representing which columns required either UPDATE or INSERT privileges,
despite the fact that INSERT and UPDATE privileges are separately
cataloged, and may be independently held.  As statements so far required
either insert or update privileges but never both, that was
sufficient. The required permission could be inferred from the top level
statement run.

The upcoming INSERT ... ON CONFLICT UPDATE feature needs to
independently check for both privileges in one statement though, so that
is not sufficient anymore.

Bumps catversion as stored rules change.

Author: Peter Geoghegan
Reviewed-By: Andres Freund
9 years agoImprove BRIN infra, minmax opclass and regression test
Alvaro Herrera [Thu, 7 May 2015 16:02:22 +0000 (13:02 -0300)]
Improve BRIN infra, minmax opclass and regression test

The minmax opclass was using the wrong support functions when
cross-datatypes queries were run.  Instead of trying to fix the
pg_amproc definitions (which apparently is not possible), use the
already correct pg_amop entries instead.  This requires jumping through
more hoops (read: extra syscache lookups) to obtain the underlying
functions to execute, but it is necessary for correctness.

Author: Emre Hasegeli, tweaked by Álvaro
Review: Andreas Karlsson

Also change BrinOpcInfo to record each stored type's typecache entry
instead of just the OID.  Turns out that the full type cache is
necessary in brin_deform_tuple: the original code used the indexed
type's byval and typlen properties to extract the stored tuple, which is
correct in Minmax; but in other implementations that want to store
something different, that's wrong.  The realization that this is a bug
comes from Emre also, but I did not use his patch.

I also adopted Emre's regression test code (with smallish changes),
which is more complete.

9 years agoFix incorrect math in DetermineSafeOldestOffset.
Robert Haas [Thu, 7 May 2015 15:00:47 +0000 (11:00 -0400)]
Fix incorrect math in DetermineSafeOldestOffset.

The old formula didn't have enough parentheses, so it would do the wrong
thing, and it used / rather than % to find a remainder.  The effect of
these oversights is that the stop point chosen by the logic introduced in
commit b69bf30b9bfacafc733a9ba77c9587cf54d06c0c might be rather
meaningless.

Thomas Munro, reviewed by Kevin Grittner, with a whitespace tweak by me.

9 years agoMakefile: Add comment that doc uninstall clears man directories
Bruce Momjian [Thu, 7 May 2015 14:26:08 +0000 (10:26 -0400)]
Makefile:  Add comment that doc uninstall clears man directories

Report by Mario Valdez

9 years agoProperly send SCM status updates when shutting down service on Windows
Magnus Hagander [Thu, 7 May 2015 13:04:13 +0000 (15:04 +0200)]
Properly send SCM status updates when shutting down service on Windows

The Service Control Manager should be notified regularly during a shutdown
that takes a long time. Previously we would increaes the counter, but forgot
to actually send the notification to the system. The loop counter was also
incorrectly initalized in the event that the startup of the system took long
enough for it to increase, which could cause the shutdown process not to wait
as long as expected.

Krystian Bigaj, reviewed by Michael Paquier

9 years agoFix indentation that could mask a future bug
Magnus Hagander [Thu, 7 May 2015 09:41:26 +0000 (11:41 +0200)]
Fix indentation that could mask a future bug

Michael Paquier, spotted using Coverity

9 years agoFix minor resource leak in pg_dump
Magnus Hagander [Thu, 7 May 2015 09:40:15 +0000 (11:40 +0200)]
Fix minor resource leak in pg_dump

Michael Paquier, spotted using Coverity

9 years agoAvoid using a C++ keyword as a structure member name.
Robert Haas [Wed, 6 May 2015 02:41:03 +0000 (22:41 -0400)]
Avoid using a C++ keyword as a structure member name.

Per request from Peter Eisentraut.

9 years agocitext's regexp_matches() functions weren't documented, either.
Tom Lane [Tue, 5 May 2015 20:11:01 +0000 (16:11 -0400)]
citext's regexp_matches() functions weren't documented, either.

9 years agoFix incorrect declaration of citext's regexp_matches() functions.
Tom Lane [Tue, 5 May 2015 19:50:53 +0000 (15:50 -0400)]
Fix incorrect declaration of citext's regexp_matches() functions.

These functions should return SETOF TEXT[], like the core functions they
are wrappers for; but they were incorrectly declared as returning just
TEXT[].  This mistake had two results: first, if there was no match you got
a scalar null result, whereas what you should get is an empty set (zero
rows).  Second, the 'g' flag was effectively ignored, since you would get
only one result array even if there were multiple matches, as reported by
Jeff Certain.

While ignoring 'g' is a clear bug, the behavior for no matches might well
have been thought to be the intended behavior by people who hadn't compared
it carefully to the core regexp_matches() functions.  So we should tread
carefully about introducing this change in the back branches.  Still, it
clearly is a bug and so providing some fix is desirable.

After discussion, the conclusion was to introduce the change in a 1.1
version of the citext extension (as we would need to do anyway); 1.0 still
contains the incorrect behavior.  1.1 is the default and only available
version in HEAD, but it is optional in the back branches, where 1.0 remains
the default version.  People wishing to adopt the fix in back branches will
need to explicitly do ALTER EXTENSION citext UPDATE TO '1.1'.  (I also
provided a downgrade script in the back branches, so people could go back
to 1.0 if necessary.)

This should be called out as an incompatible change in the 9.5 release
notes, although we'll also document it in the next set of back-branch
release notes.  The notes should mention that any views or rules that use
citext's regexp_matches() functions will need to be dropped before
upgrading to 1.1, and then recreated again afterwards.

Back-patch to 9.1.  The bug goes all the way back to citext's introduction
in 8.4, but pre-9.1 there is no extension mechanism with which to manage
the change.  Given the lack of previous complaints it seems unnecessary to
change this behavior in 9.0, anyway.

9 years agodoc: Update installation instructions for new shared libperl/libpython handling
Peter Eisentraut [Tue, 5 May 2015 18:41:39 +0000 (14:41 -0400)]
doc: Update installation instructions for new shared libperl/libpython handling

9 years agoAdd geometry/range functions to support BRIN inclusion
Alvaro Herrera [Tue, 5 May 2015 18:22:24 +0000 (15:22 -0300)]
Add geometry/range functions to support BRIN inclusion

This commit adds the following functions:
    box(point) -> box
    bound_box(box, box) -> box
    inet_same_family(inet, inet) -> bool
    inet_merge(inet, inet) -> cidr
    range_merge(anyrange, anyrange) -> anyrange

The first of these is also used to implement a new assignment cast from
point to box.

These functions are the first part of a base to implement an "inclusion"
operator class for BRIN, for multidimensional data types.

Author: Emre Hasegeli
Reviewed by: Andreas Karlsson

9 years agoFix some problems with patch to fsync the data directory.
Robert Haas [Tue, 5 May 2015 12:30:28 +0000 (08:30 -0400)]
Fix some problems with patch to fsync the data directory.

pg_win32_is_junction() was a typo for pgwin32_is_junction().  open()
was used not only in a two-argument form, which breaks on Windows,
but also where BasicOpenFile() should have been used.

Per reports from Andrew Dunstan and David Rowley.

9 years agohstore_plpython: Support tests on Python 2.3
Peter Eisentraut [Tue, 5 May 2015 02:30:21 +0000 (22:30 -0400)]
hstore_plpython: Support tests on Python 2.3

Python 2.3 does not have the sorted() function, so do it the long way.

9 years agoFix typos
Peter Eisentraut [Tue, 5 May 2015 00:40:19 +0000 (20:40 -0400)]
Fix typos

Author: Erik Rijkers <er@xs4all.nl>

9 years agoUse outerPlanState macro instead of referring to leffttree.
Robert Haas [Mon, 4 May 2015 20:13:07 +0000 (16:13 -0400)]
Use outerPlanState macro instead of referring to leffttree.

This makes the executor code more consistent.  It also removes
an apparently superfluous NULL test in nodeGroup.c.

Qingqing Zhou, reviewed by Tom Lane, and further revised by me.

9 years agoImprove procost estimates for some text search functions.
Tom Lane [Mon, 4 May 2015 19:38:57 +0000 (15:38 -0400)]
Improve procost estimates for some text search functions.

The text search functions that involve parsing raw text into lexemes are
remarkably CPU-intensive, so estimating them at the same cost as most other
built-in functions seems like a mistake; moreover, doing so turns out to
discourage the optimizer from using functional indexes on these functions.
After some debate, we've agreed to raise procost from 1 to 100 for
to_tsvector(), plainto_tsvector(), to_tsquery(), ts_headline(),
ts_match_tt(), and ts_match_tq(), which are all the text search functions
that parse raw text.

Also increase procost for the 2-argument form of ts_rewrite()
(tsquery_rewrite_query); while this function doesn't do text parsing,
it does execute a user-supplied SQL query, so its previous procost of 1 is
clearly a drastic underestimate.  It seems reasonable to assign it the same
cost we assign to PL functions by default, so 100 is the number here too.

I did not bother bumping catversion for this change, since it does not
break catalog compatibility with the server executable nor result in
any regression test changes.

Per complaint from Andrew Gierth and subsequent discussion.

9 years agoRecursively fsync() the data directory after a crash.
Robert Haas [Mon, 4 May 2015 18:13:53 +0000 (14:13 -0400)]
Recursively fsync() the data directory after a crash.

Otherwise, if there's another crash, some writes from after the first
crash might make it to disk while writes from before the crash fail
to make it to disk.  This could lead to data corruption.

Back-patch to all supported versions.

Abhijit Menon-Sen, reviewed by Andres Freund and slightly revised
by me.

9 years agoFix the same-rel optimization when creating WAL records.
Heikki Linnakangas [Mon, 4 May 2015 17:58:42 +0000 (20:58 +0300)]
Fix the same-rel optimization when creating WAL records.

prev_regbuf was never set, and therefore the same-rel flag was never set on
WAL records.

Report and fix by Zhanq Zq

9 years agoFix two small bugs in json's populate_record_worker
Andrew Dunstan [Mon, 4 May 2015 16:38:58 +0000 (12:38 -0400)]
Fix two small bugs in json's populate_record_worker

The first bug is not releasing a tupdesc when doing an early return out
of the function. The second bug is a logic error in choosing when to do
an early return if given an empty jsonb object.

Bug reports from Pavel Stehule and Tom Lane respectively.

Backpatch to 9.4 where these were introduced.

9 years agoSecond try at fixing warnings caused by commit 9b43d73b3f9bef27.
Tom Lane [Mon, 4 May 2015 03:44:52 +0000 (23:44 -0400)]
Second try at fixing warnings caused by commit 9b43d73b3f9bef27.

Commit ef3f9e642d2b2bba suppressed one cause of warnings here, but
recent clang on OS X is still unhappy because we're passing a "long"
to abs().  The fact that tm_gmtoff is declared as long is no doubt a
hangover from days when int might be only 16 bits; but Postgres has
never been able to run on such machines, so we can just cast it to int
with no worries.  For consistency, also cast to int in the other
uses of tm_gmtoff in this stanza.

Note: this code is still broken on machines that don't follow C99
integer-division-truncates-towards-zero rules.  Given the lack of
complaints about it, I don't feel a large desire to complicate things
enough to cope with the pre-C99 rules.

9 years agoFix overlooked relcache invalidation in ALTER TABLE ... ALTER CONSTRAINT.
Tom Lane [Sun, 3 May 2015 15:30:24 +0000 (11:30 -0400)]
Fix overlooked relcache invalidation in ALTER TABLE ... ALTER CONSTRAINT.

When altering the deferredness state of a foreign key constraint, we
correctly updated the catalogs and then invalidated the relcache state for
the target relation ... but that's not the only relation with relevant
triggers.  Must invalidate the other table as well, or the state change
fails to take effect promptly for operations triggered on the other table.
Per bug #13224 from Christian Ullrich.

In passing, reorganize regression test case for this feature so that it
isn't randomly injected into the middle of an unrelated test sequence.

Oversight in commit f177cbfe676dc2c7ca2b206c54d6bf819feeea8b.  Back-patch
to 9.4 where the faulty code was added.

9 years agofix escaping of brackets for m4 broken in b6b2149e48aa61981ae0199c963d5145a37c258c
Andrew Dunstan [Sun, 3 May 2015 13:37:15 +0000 (09:37 -0400)]
fix escaping of brackets for m4 broken in b6b2149e48aa61981ae0199c963d5145a37c258c

9 years agoEnable transforms modules to build and run with Mingw builds.
Andrew Dunstan [Sun, 3 May 2015 13:10:47 +0000 (09:10 -0400)]
Enable transforms modules to build and run with Mingw builds.

These modules were all missing essential Windows scaffolding, including
resources files and descriptions, and links to the relevant library
import files. This latter item means that the modules can't be built
with pgxs on Windows, as we don't install the import files. If we ever
decide to install them this restriction could probably be removed.

Also, as with plperl we need to make sure that perl's CORE directory is
last on the include list, as on Windows it appears to contain some
headers with names that clash with names of some headers we include.

9 years agoFix python_includespec on Windows at configure time
Andrew Dunstan [Sun, 3 May 2015 12:17:04 +0000 (08:17 -0400)]
Fix python_includespec on Windows at configure time

By converting to using forward slashes at configure time we avoid
having to repeat the logic anywhere that this is needed, such as
in transforms modules for plpython.

9 years agoCombine initdb tests that successfully create a data directory.
Noah Misch [Sat, 2 May 2015 20:47:28 +0000 (16:47 -0400)]
Combine initdb tests that successfully create a data directory.

This eliminates many seconds of test duration and the cause to invoke
"rm -rf", which is typically unavailable on Windows.

Michael Paquier and Noah Misch

9 years agoFix one more TAP test to use standard command-line argument ordering.
Noah Misch [Sat, 2 May 2015 20:46:52 +0000 (16:46 -0400)]
Fix one more TAP test to use standard command-line argument ordering.

Commit c67a86f7da90c30b81f91957023fb752f06f0598 caught most of these,
but this negative test escaped notice.  The test did pass, for the wrong
reason, under affected configurations.

Michael Paquier

9 years agoRename coerce_type() local variable.
Noah Misch [Sat, 2 May 2015 20:46:23 +0000 (16:46 -0400)]
Rename coerce_type() local variable.

coerce_type() has local variables named targetTypeId, baseTypeId, and
targetType.  targetType has been the Type structure for baseTypeId, so
rename it to baseType.

9 years agoWindows also needs an override of the shared libpython detection
Peter Eisentraut [Sat, 2 May 2015 17:23:16 +0000 (13:23 -0400)]
Windows also needs an override of the shared libpython detection

9 years agohstore_plperl: Move port-specific parts to later in the makefile
Peter Eisentraut [Sat, 2 May 2015 12:03:47 +0000 (08:03 -0400)]
hstore_plperl: Move port-specific parts to later in the makefile

PORTNAME isn't set until the global makefiles have been included.

9 years agoFix shared libpython detection on OS X
Peter Eisentraut [Sat, 2 May 2015 03:12:45 +0000 (23:12 -0400)]
Fix shared libpython detection on OS X

Apparently, looking for an appropriately named file doesn't work on some
older versions, so put the back the explicit platform detection.

9 years agoMake hstore_plperl's build even more like plperl's
Peter Eisentraut [Sat, 2 May 2015 02:16:58 +0000 (22:16 -0400)]
Make hstore_plperl's build even more like plperl's

Combine the two places that set CPPFLAGS into one.  Also, some settings
should be restricted to Windows only.  More precisely, -Wno-comment is
a GCC-only option, but Windows in a makefile implies GCC at the moment.

Also, since -Wno-comment is more properly a preprocessor option, move it
to CPPFLAGS to simplify things a bit.

9 years agoMove interpreter shared library detection to configure
Peter Eisentraut [Sat, 2 May 2015 01:38:21 +0000 (21:38 -0400)]
Move interpreter shared library detection to configure

For building PL/Perl, PL/Python, and PL/Tcl, we need a shared library of
libperl, libpython, and libtcl, respectively.  Previously, this was
checked in the makefiles, skipping the PL build with a warning if no
shared library was available.  Now this is checked in configure, with an
error if no shared library is available.

The previous situation arose because in the olden days, the configure
options --with-perl, --with-python, and --with-tcl controlled whether
frontend interfaces for those languages would be built.  The procedural
languages were added later, and shared libraries were often not
available in the beginning.  So it was decided skip the builds of the
procedural languages in those cases.  The frontend interfaces have since
been removed from the tree, and shared libraries are now available most
of the time, so that setup makes much less sense now.

Also, the new setup allows contrib modules and pgxs users to rely on the
respective PLs being available based on configure flags.

9 years agoMake hstore_plperl's build more like plperl's
Andrew Dunstan [Fri, 1 May 2015 19:36:44 +0000 (15:36 -0400)]
Make hstore_plperl's build more like plperl's

This involves moving perl's CORE library to the end of the include list,
and adding other compilation settings that plperl uses. This won't
completely fix the breakage currently being seen by gcc builds on
Windows, but it will let the build get further, and should be wholly
benign, if not beneficial, on *nix.

9 years agoMark views created from tables as replication identity 'nothing'
Bruce Momjian [Fri, 1 May 2015 17:03:23 +0000 (13:03 -0400)]
Mark views created from tables as replication identity 'nothing'

pg_dump turns tables into views using a method that was not setting
pg_class.relreplident properly.

Patch by Marko Tiikkaja

Backpatch through 9.4

9 years agoDeparse named arguments to use the new => operator instead of :=
Robert Haas [Fri, 1 May 2015 13:37:10 +0000 (09:37 -0400)]
Deparse named arguments to use the new => operator instead of :=

Tom Lane pointed out that this wasn't done, and asked whether that was
intentional.  Subsequent discussion was in favor of making the change,
so here we go.

9 years agoAllow FDWs and custom scan providers to replace joins with scans.
Robert Haas [Fri, 1 May 2015 12:50:35 +0000 (08:50 -0400)]
Allow FDWs and custom scan providers to replace joins with scans.

Foreign data wrappers can use this capability for so-called "join
pushdown"; that is, instead of executing two separate foreign scans
and then joining the results locally, they can generate a path which
performs the join on the remote server and then is scanned locally.
This commit does not extend postgres_fdw to take advantage of this
capability; it just provides the infrastructure.

Custom scan providers can use this in a similar way.  Previously,
it was only possible for a custom scan provider to scan a single
relation.  Now, it can scan an entire join tree, provided of course
that it knows how to produce the same results that the join would
have produced if executed normally.

KaiGai Kohei, reviewed by Shigeru Hanada, Ashutosh Bapat, and me.

9 years agoCopy editing of the replication origins patch.
Andres Freund [Fri, 1 May 2015 10:22:13 +0000 (12:22 +0200)]
Copy editing of the replication origins patch.

Michael Paquier and myself.

9 years agoFix unaligned memory access in xlog parsing due to replication origin patch.
Andres Freund [Fri, 1 May 2015 09:36:14 +0000 (11:36 +0200)]
Fix unaligned memory access in xlog parsing due to replication origin patch.

ParseCommitRecord() accessed xl_xact_origin directly. But the chunks in
the commit record's data only have 4 byte alignment, whereas
xl_xact_origin's members require 8 byte alignment on some
platforms. Update comments to make not of that and copy the record to
stack local storage before reading.

With help from Stefan Kaltenbrunner in pinning down the buildfarm and
verifying the fix.

9 years agoFix pg_rewind regression failure after "fast promotion"
Heikki Linnakangas [Fri, 1 May 2015 04:57:18 +0000 (21:57 -0700)]
Fix pg_rewind regression failure after "fast promotion"

pg_rewind looks at the control file to determine the server's timeline. If
the standby performs a "fast promotion", the timeline ID in the control
file is not updated until the next checkpoint. The startup process requests
a checkpoint immediately after promotion, so this is unlikely to be an
issue in the real world, but the regression suite ran pg_rewind so quickly
after promotion that the checkpoint had not yet completed.

Reported by Stephen Frost

9 years agoFix up some loose ends for CURRENT_USER as RoleSpec
Alvaro Herrera [Thu, 30 Apr 2015 19:57:05 +0000 (16:57 -0300)]
Fix up some loose ends for CURRENT_USER as RoleSpec

In commit 31eae6028eca4, some documents were not updated to show the new
capability; fix that.  Also, the error message you get when CURRENT_USER
and SESSION_USER are used in a context that doesn't accept them could be
clearer about it being a problem only in those contexts; so add the
word "here".

Author: Kyotaro HORIGUCHI

His patch submission also included changes to GRANT/REVOKE, but those
seemed more controversial, so I left them out.  We can reconsider these
changes later.

9 years agoCreate an infrastructure for parallel computation in PostgreSQL.
Robert Haas [Thu, 30 Apr 2015 19:02:14 +0000 (15:02 -0400)]
Create an infrastructure for parallel computation in PostgreSQL.

This does four basic things.  First, it provides convenience routines
to coordinate the startup and shutdown of parallel workers.  Second,
it synchronizes various pieces of state (e.g. GUCs, combo CID
mappings, transaction snapshot) from the parallel group leader to the
worker processes.  Third, it prohibits various operations that would
result in unsafe changes to that state while parallelism is active.
Finally, it propagates events that would result in an ErrorResponse,
NoticeResponse, or NotifyResponse message being sent to the client
from the parallel workers back to the master, from which they can then
be sent on to the client.

Robert Haas, Amit Kapila, Noah Misch, Rushabh Lathia, Jeevan Chalke.
Suggestions and review from Andres Freund, Heikki Linnakangas, Noah
Misch, Simon Riggs, Euler Taveira, and Jim Nasby.

9 years agoFix pg_upgrade's multixact handling (again)
Alvaro Herrera [Thu, 30 Apr 2015 16:55:06 +0000 (13:55 -0300)]
Fix pg_upgrade's multixact handling (again)

We need to create the pg_multixact/offsets file deleted by pg_upgrade
much earlier than we originally were: it was in TrimMultiXact(), which
runs after we exit recovery, but it actually needs to run earlier than
the first call to SetMultiXactIdLimit (before recovery), because that
routine already wants to read the first offset segment.

Per pg_upgrade trouble report from Jeff Janes.

While at it, silence a compiler warning about a pointless assert that an
unsigned variable was being tested non-negative.  This was a signed
constant in Thomas Munro's patch which I changed to unsigned before
commit.  Pointed out by Andres Freund.