]> granicus.if.org Git - postgresql/log
postgresql
7 years agoAlways SnapshotResetXmin() during ClearTransaction()
Simon Riggs [Thu, 6 Apr 2017 14:30:22 +0000 (10:30 -0400)]
Always SnapshotResetXmin() during ClearTransaction()

Avoid corner cases during 2PC with 6bad580d9e678a0b604883e14d8401d469b06566

7 years agoIdentity columns
Peter Eisentraut [Thu, 6 Apr 2017 12:33:16 +0000 (08:33 -0400)]
Identity columns

This is the SQL standard-conforming variant of PostgreSQL's serial
columns.  It fixes a few usability issues that serial columns have:

- CREATE TABLE / LIKE copies default but refers to same sequence
- cannot add/drop serialness with ALTER TABLE
- dropping default does not drop sequence
- need to grant separate privileges to sequence
- other slight weirdnesses because serial is some kind of special macro

Reviewed-by: Vitaly Burovoy <vitaly.burovoy@gmail.com>
7 years agoAvoid SnapshotResetXmin() during AtEOXact_Snapshot()
Simon Riggs [Thu, 6 Apr 2017 12:31:52 +0000 (08:31 -0400)]
Avoid SnapshotResetXmin() during AtEOXact_Snapshot()

For normal commits and aborts we already reset PgXact->xmin,
so we can simply avoid running SnapshotResetXmin() twice.

During performance tests by Alexander Korotkov, diagnosis
by Andres Freund showed PgXact array as a bottleneck. After
manual analysis by me of the code paths that touch those
memory locations, I was able to identify extraneous code
in the main transaction commit path.

Avoiding touching highly contented shmem improves concurrent
performance slightly on all workloads, confirmed by tests
run by Ashutosh Sharma and Alexander Korotkov.

Simon Riggs

Discussion: CANP8+jJdXE9b+b9F8CQT-LuxxO0PBCB-SZFfMVAdp+akqo4zfg@mail.gmail.com

7 years agoRemove dead code and fix comments in fast-path function handling.
Heikki Linnakangas [Thu, 6 Apr 2017 06:09:39 +0000 (09:09 +0300)]
Remove dead code and fix comments in fast-path function handling.

HandleFunctionRequest() is no longer responsible for reading the protocol
message from the client, since commit 2b3a8b20c2. Fix the outdated
comments.

HandleFunctionRequest() now always returns 0, because the code that used
to return EOF was moved in 2b3a8b20c2. Therefore, the caller no longer
needs to check the return value.

Reported by Andres Freund. Backpatch to all supported versions, even though
this doesn't have any user-visible effect, to make backporting future
patches in this area easier.

Discussion: https://www.postgresql.org/message-id/20170405010525.rt5azbya5fkbhvrx@alap3.anarazel.de

7 years agoCode review for recent slot.c changes.
Andres Freund [Thu, 6 Apr 2017 03:56:35 +0000 (20:56 -0700)]
Code review for recent slot.c changes.

7 years agoFix integer-overflow problems in interval comparison.
Tom Lane [Thu, 6 Apr 2017 03:51:27 +0000 (23:51 -0400)]
Fix integer-overflow problems in interval comparison.

When using integer timestamps, the interval-comparison functions tried
to compute the overall magnitude of an interval as an int64 number of
microseconds.  As reported by Frazer McLean, this overflows for intervals
exceeding about 296000 years, which is bad since we nominally allow
intervals many times larger than that.  That results in wrong comparison
results, and possibly in corrupted btree indexes for columns containing
such large interval values.

To fix, compute the magnitude as int128 instead.  Although some compilers
have native support for int128 calculations, many don't, so create our
own support functions that can do 128-bit addition and multiplication
if the compiler support isn't there.  These support functions are designed
with an eye to allowing the int128 code paths in numeric.c to be rewritten
for use on all platforms, although this patch doesn't do that, or even
provide all the int128 primitives that will be needed for it.

Back-patch as far as 9.4.  Earlier releases did not guard against overflow
of interval values at all (commit 146604ec4 fixed that), so it seems not
very exciting to worry about overly-large intervals for them.

Before 9.6, we did not assume that unreferenced "static inline" functions
would not draw compiler warnings, so omit functions not directly referenced
by timestamp.c, the only present consumer of int128.h.  (We could have
omitted these functions in HEAD too, but since they were written and
debugged on the way to the present patch, and they look likely to be needed
by numeric.c, let's keep them in HEAD.)  I did not bother to try to prevent
such warnings in a --disable-integer-datetimes build, though.

Before 9.5, configure will never define HAVE_INT128, so the part of
int128.h that exploits a native int128 implementation is dead code in the
9.4 branch.  I didn't bother to remove it, thinking that keeping the file
looking similar in different branches is more useful.

In HEAD only, add a simple test harness for int128.h in src/tools/.

In back branches, this does not change the float-timestamps code path.
That's not subject to the same kind of overflow risk, since it computes
the interval magnitude as float8.  (No doubt, when this code was originally
written, overflow was disregarded for exactly that reason.)  There is a
precision hazard instead :-(, but we'll avert our eyes from that question,
since no complaints have been reported and that code's deprecated anyway.

Kyotaro Horiguchi and Tom Lane

Discussion: https://postgr.es/m/1490104629.422698.918452336.26FA96B7@webmail.messagingengine.com

7 years agoReduce lock level for CREATE STATISTICS
Simon Riggs [Wed, 5 Apr 2017 22:22:32 +0000 (18:22 -0400)]
Reduce lock level for CREATE STATISTICS

In line with other lock reductions related to planning.

Simon Riggs

7 years agoCollect and use multi-column dependency stats
Simon Riggs [Wed, 5 Apr 2017 22:00:42 +0000 (18:00 -0400)]
Collect and use multi-column dependency stats

Follow on patch in the multi-variate statistics patch series.

CREATE STATISTICS s1 WITH (dependencies) ON (a, b) FROM t;
ANALYZE;
will collect dependency stats on (a, b) and then use the measured
dependency in subsequent query planning.

Commit 7b504eb282ca2f5104b5c00b4f05a3ef6bb1385b added
CREATE STATISTICS with n-distinct coefficients. These are now
specified using the mutually exclusive option WITH (ndistinct).

Author: Tomas Vondra, David Rowley
Reviewed-by: Kyotaro HORIGUCHI, Álvaro Herrera, Dean Rasheed, Robert Haas
and many other comments and contributions
Discussion: https://postgr.es/m/56f40b20-c464-fad2-ff39-06b668fac47c@2ndquadrant.com

7 years agoAllow --with-wal-segsize=n up to n=1024MB
Simon Riggs [Wed, 5 Apr 2017 19:38:17 +0000 (15:38 -0400)]
Allow --with-wal-segsize=n up to n=1024MB

Other part of Beena Emerson's patch to allow testing

7 years agoSpelling mistake in comment in utility.c
Simon Riggs [Wed, 5 Apr 2017 18:29:29 +0000 (14:29 -0400)]
Spelling mistake in comment in utility.c

7 years agoFix pageinspect failures on hash indexes.
Robert Haas [Wed, 5 Apr 2017 18:17:23 +0000 (14:17 -0400)]
Fix pageinspect failures on hash indexes.

Make every page in a hash index which isn't all-zeroes have a valid
special space, so that tools like pageinspect don't error out.

Also, make pageinspect cope with all-zeroes pages, because
_hash_alloc_buckets can leave behind large numbers of those until
they're consumed by splits.

Ashutosh Sharma and Robert Haas, reviewed by Amit Kapila.
Original trouble report from Jeff Janes.

Discussion: http://postgr.es/m/CAMkU=1y6NjKmqbJ8wLMhr=F74WzcMALYWcVFhEpm7i=mV=XsOg@mail.gmail.com

7 years agoUse American English in error message
Peter Eisentraut [Wed, 5 Apr 2017 18:06:15 +0000 (14:06 -0400)]
Use American English in error message

All error messages use the American English spelling of recognize,
apply to the single one not doing so to be consistent.

Author: Daniel Gustafsson <daniel@yesql.se>

7 years agodoc: Remove remark elements
Peter Eisentraut [Wed, 5 Apr 2017 17:18:32 +0000 (13:18 -0400)]
doc: Remove remark elements

They were not rendered with DSSSL, but now they show up by default using
XSLT.  Just remove them, since they are not useful.

7 years agohash: Fix write-ahead logging bug.
Robert Haas [Wed, 5 Apr 2017 15:45:35 +0000 (11:45 -0400)]
hash: Fix write-ahead logging bug.

The size of the data is not the same thing as the size of the size of
the data.

Reported off-list by Tushar Ahuja.  Fix by Ashutosh Sharma, reviewed
by Amit Kapila.

Discussion: http://postgr.es/m/CAE9k0PnmPDXfvf8HDObme7q_Ewc4E26ukHXUBPySoOs0ObqqaQ@mail.gmail.com

7 years agoAdd isolation test for SERIALIZABLE READ ONLY DEFERRABLE.
Kevin Grittner [Wed, 5 Apr 2017 15:04:36 +0000 (10:04 -0500)]
Add isolation test for SERIALIZABLE READ ONLY DEFERRABLE.

This improves code coverage and lays a foundation for testing
similar issues in a distributed environment.

Author: Thomas Munro <thomas.munro@enterprisedb.com>
Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
7 years agodblink: Small code rearrangement for clarity
Peter Eisentraut [Wed, 5 Apr 2017 13:03:11 +0000 (09:03 -0400)]
dblink: Small code rearrangement for clarity

suggested by Tom Lane

7 years agoCapitalize names of PLs consistently
Peter Eisentraut [Wed, 5 Apr 2017 04:38:25 +0000 (00:38 -0400)]
Capitalize names of PLs consistently

Author: Daniel Gustafsson <daniel@yesql.se>

7 years agopageinspect: Add bt_page_items function with bytea argument
Peter Eisentraut [Wed, 5 Apr 2017 03:48:49 +0000 (23:48 -0400)]
pageinspect: Add bt_page_items function with bytea argument

Author: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
7 years agoFollow-on cleanup for the transition table patch.
Kevin Grittner [Tue, 4 Apr 2017 23:36:39 +0000 (18:36 -0500)]
Follow-on cleanup for the transition table patch.

Commit 59702716 added transition table support to PL/pgsql so that
SQL queries in trigger functions could access those transient
tables.  In order to provide the same level of support for PL/perl,
PL/python and PL/tcl, refactor the relevant code into a new
function SPI_register_trigger_data.  Call the new function in the
trigger handler of all four PLs, and document it as a public SPI
function so that authors of out-of-tree PLs can do the same.

Also get rid of a second QueryEnvironment object that was
maintained by PL/pgsql.  That was previously used to deal with
cursors, but the same approach wasn't appropriate for PLs that are
less tangled up with core code.  Instead, have SPI_cursor_open
install the connection's current QueryEnvironment, as already
happens for SPI_execute_plan.

While in the docs, remove the note that transition tables were only
supported in C and PL/pgSQL triggers, and correct some ommissions.

Thomas Munro with some work by Kevin Grittner (mostly docs)

7 years agoMake min_wal_size/max_wal_size use MB internally
Simon Riggs [Tue, 4 Apr 2017 22:00:01 +0000 (18:00 -0400)]
Make min_wal_size/max_wal_size use MB internally

Previously they were defined using multiples of XLogSegSize.
Remove GUC_UNIT_XSEGS. Introduce GUC_UNIT_MB

Extracted from patch series on XLogSegSize infrastructure.

Beena Emerson

7 years agoFix uninitialized variables in twophase.c
Simon Riggs [Tue, 4 Apr 2017 21:50:02 +0000 (17:50 -0400)]
Fix uninitialized variables in twophase.c

7 years agoForce synchronous commit in new-ish test_decoding test.
Andres Freund [Tue, 4 Apr 2017 21:38:00 +0000 (14:38 -0700)]
Force synchronous commit in new-ish test_decoding test.

This was missed in a924c327 ff.

7 years agoFix two valgrind issues in slab allocator.
Andres Freund [Tue, 4 Apr 2017 21:26:42 +0000 (14:26 -0700)]
Fix two valgrind issues in slab allocator.

During allocation VALGRIND_MAKE_MEM_DEFINED was called with a pointer
as size. That kind of works, but makes valgrind exceedingly slow for
workloads involving the slab allocator.

Secondly there was an access to memory marked as unreachable within
SlabCheck(). Fix that too.

Author: Tomas Vondra
Discussion: https://postgr.es/m/a6543b6d-6015-99b1-63ef-3ed55a76a730@2ndquadrant.com

7 years agoClarify documentation of to_tsvector(json(b))
Andrew Dunstan [Tue, 4 Apr 2017 20:50:13 +0000 (16:50 -0400)]
Clarify documentation of to_tsvector(json(b))

Per gripe from Sven R. Kunze

7 years agoSpeedup 2PC recovery by skipping two phase state files in normal path
Simon Riggs [Tue, 4 Apr 2017 19:56:56 +0000 (15:56 -0400)]
Speedup 2PC recovery by skipping two phase state files in normal path

2PC state info held in shmem at PREPARE, then cleaned at COMMIT PREPARED/ABORT PREPARED,
avoiding writing/fsyncing any state information to disk in the normal path, greatly enhancing replay speed.
Prepared transactions that live past one checkpoint redo horizon will be written to disk as now.
Similar conceptually to 978b2f65aa1262eb4ecbf8b3785cb1b9cf4db78e and building upon
the infrastructure created by that commit.

Authors, in equal measure: Stas Kelvich, Nikhil Sontakke and Michael Paquier
Discussion: https://postgr.es/m/CAMGcDxf8Bn9ZPBBJZba9wiyQq-Qk5uqq=VjoMnRnW5s+fKST3w@mail.gmail.com

7 years agoAdjust min/max values when changing sequence type
Peter Eisentraut [Tue, 4 Apr 2017 16:36:15 +0000 (12:36 -0400)]
Adjust min/max values when changing sequence type

When changing the type of a sequence, adjust the min/max values of the
sequence if it looks like the previous values were the default values.
Previously, it would leave the old values in place, requiring manual
adjustments even in the usual/default cases.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Reviewed-by: Vitaly Burovoy <vitaly.burovoy@gmail.com>
7 years agoFix thinko in BitmapAdjustPrefetchIterator.
Robert Haas [Tue, 4 Apr 2017 13:03:41 +0000 (09:03 -0400)]
Fix thinko in BitmapAdjustPrefetchIterator.

Dilip Kumar

Discussion: http://postgr.es/m/CAFiTN-uKAvRhWprb0i-U9zFOekgQRRwqjP1wvOBsKZb-UEKbug@mail.gmail.com

7 years agoFix typo
Peter Eisentraut [Tue, 4 Apr 2017 13:03:24 +0000 (09:03 -0400)]
Fix typo

Author: Masahiko Sawada <sawada.mshk@gmail.com>

7 years agopsql: Add some missing tab completion
Peter Eisentraut [Tue, 4 Apr 2017 12:58:21 +0000 (08:58 -0400)]
psql: Add some missing tab completion

Add tab completion for COMMENT/SECURITY LABEL ON
PUBLICATION/SUBSCRIPTION.

Reported-by: Stephen Frost <sfrost@snowman.net>
7 years agoRemove --verbose from PROVE_FLAGS
Stephen Frost [Tue, 4 Apr 2017 12:42:09 +0000 (08:42 -0400)]
Remove --verbose from PROVE_FLAGS

Per discussion, the TAP tests are really more verbose than necessary, so
remove the --verbose flag from PROVE_FLAGS.  Also add comments to let
folks know how they can enable it if they really wish to, as suggested
by Craig Ringer.

Author: Michael Paquier, additional comments by me.
Discussion: https://postgr.es/m/CAMsr%2BYGAzcMDOZ_BirnMCL6Sb%3DMUjP0FRE82YBDSbXcf6pm9Yg%40mail.gmail.com

7 years agoFix remote position tracking in logical replication
Peter Eisentraut [Tue, 4 Apr 2017 12:24:32 +0000 (08:24 -0400)]
Fix remote position tracking in logical replication

We need to set the origin remote position to end_lsn, not commit_lsn, as
commit_lsn is the start of commit record, and we use the origin remote
position as start position when restarting replication stream.  If we'd
use commit_lsn, we could request data that we already received from the
remote server after a crash of a downstream server.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>

7 years agoFix formula in _hash_spareindex.
Robert Haas [Tue, 4 Apr 2017 11:42:05 +0000 (07:42 -0400)]
Fix formula in _hash_spareindex.

This was correct in earlier versions of the patch that lead to
commit ea69a0dead5128c421140dc53fac165ba4af8520, but somehow got
broken in the last version which I actually committed.

Mithun Cy, per an off-list report from Ashutosh Sharma

Discussion: http://postgr.es/m/CAD__OujbAwNU71v1y-RoQxZ8LZ6-V2UFTkex3v34MK6uZ3Xb5w@mail.gmail.com

7 years agoExpand hash indexes more gradually.
Robert Haas [Tue, 4 Apr 2017 03:46:33 +0000 (23:46 -0400)]
Expand hash indexes more gradually.

Since hash indexes typically have very few overflow pages, adding a
new splitpoint essentially doubles the on-disk size of the index,
which can lead to large and abrupt increases in disk usage (and
perhaps long delays on occasion).  To mitigate this problem to some
degree, divide larger splitpoints into four equal phases.  This means
that, for example, instead of growing from 4GB to 8GB all at once, a
hash index will now grow from 4GB to 5GB to 6GB to 7GB to 8GB, which
is perhaps still not as smooth as we'd like but certainly an
improvement.

This changes the on-disk format of the metapage, so bump HASH_VERSION
from 2 to 3.  This will force a REINDEX of all existing hash indexes,
but that's probably a good idea anyway.  First, hash indexes from
pre-10 versions of PostgreSQL could easily be corrupted, and we don't
want to confuse corruption carried over from an older release with any
corruption caused despite the new write-ahead logging in v10.  Second,
it will let us remove some backward-compatibility code added by commit
293e24e507838733aba4748b514536af2d39d7f2.

Mithun Cy, reviewed by Amit Kapila, Jesper Pedersen and me.  Regression
test outputs updated by me.

Discussion: http://postgr.es/m/CAD__OuhG6F1gQLCgMQNnMNgoCvOLQZz9zKYJQNYvYmmJoM42gA@mail.gmail.com
Discussion: http://postgr.es/m/CA+TgmoYty0jCf-pa+m+vYUJ716+AxM7nv_syvyanyf5O-L_i2A@mail.gmail.com

7 years agoFurther corrections and improvements to partitioning documentation.
Robert Haas [Tue, 4 Apr 2017 03:10:16 +0000 (23:10 -0400)]
Further corrections and improvements to partitioning documentation.

Amit Langote

Discussion: http://postgr.es/m/80f6b049-e882-f6c3-f82c-f44baa94d369@lab.ntt.co.jp

7 years agoUpdate comment.
Robert Haas [Tue, 4 Apr 2017 03:07:31 +0000 (23:07 -0400)]
Update comment.

Craig Ringer, reviewed by me.

7 years agoPrint new RelOptInfo field top_parent_relids in outfuncs.c
Robert Haas [Tue, 4 Apr 2017 03:06:36 +0000 (23:06 -0400)]
Print new RelOptInfo field top_parent_relids in outfuncs.c

I intended to include this adjustment in the previous commit
(7a39b5e4d11229ece930a51fd7cb29e535db44940) but messed up.

7 years agoAbstract logic to allow for multiple kinds of child rels.
Robert Haas [Tue, 4 Apr 2017 02:41:31 +0000 (22:41 -0400)]
Abstract logic to allow for multiple kinds of child rels.

Currently, the only type of child relation is an "other member rel",
which is the child of a baserel, but in the future joins and even
upper relations may have child rels.  To facilitate that, introduce
macros that test to test for particular RelOptKind values, and use
them in various places where they help to clarify the sense of a test.
(For example, a test may allow RELOPT_OTHER_MEMBER_REL either because
it intends to allow child rels, or because it intends to allow simple
rels.)

Also, remove find_childrel_top_parent, which will not work for a
child rel that is not a baserel.  Instead, add a new RelOptInfo
member top_parent_relids to track the same kind of information in a
more generic manner.

Ashutosh Bapat, slightly tweaked by me.  Review and testing of the
patch set from which this was taken by Rajkumar Raghuwanshi and Rafia
Sabih.

Discussion: http://postgr.es/m/CA+TgmoagTnF2yqR3PT2rv=om=wJiZ4-A+ATwdnriTGku1CLYxA@mail.gmail.com

7 years agoProperly acquire buffer lock for page-at-a-time hash vacuum.
Robert Haas [Tue, 4 Apr 2017 02:24:17 +0000 (22:24 -0400)]
Properly acquire buffer lock for page-at-a-time hash vacuum.

In a couple of places, _hash_kill_items was mistakenly called with
the buffer lock not held.  Repair.

Ashutosh Sharma, per a report from Andreas Seltenreich

Discussion: http://postgr.es/m/87o9wo8o0j.fsf@credativ.de

7 years agoTry and silence spurious Coverity warning.
Andrew Gierth [Mon, 3 Apr 2017 22:30:24 +0000 (23:30 +0100)]
Try and silence spurious Coverity warning.

gset_data (aka gd) in planner.c is always non-null if and only if
parse->groupingSets is non-null, but Coverity doesn't know that and
complains.  Feed it an assertion to see if that keeps it happy.

7 years agoMake header self-contained
Peter Eisentraut [Mon, 3 Apr 2017 20:17:45 +0000 (16:17 -0400)]
Make header self-contained

Add necessary include files for things used in the header.

7 years agoFix whitespace
Peter Eisentraut [Mon, 3 Apr 2017 15:12:48 +0000 (11:12 -0400)]
Fix whitespace

7 years agoHandle change of slot name in logical replication apply
Peter Eisentraut [Mon, 3 Apr 2017 15:10:28 +0000 (11:10 -0400)]
Handle change of slot name in logical replication apply

Since change of slot name is a supported operation, handle it more
gracefully, instead of in the this-should-not-happen way.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>

7 years agodoc: Change xref style to number only
Peter Eisentraut [Mon, 3 Apr 2017 14:50:32 +0000 (10:50 -0400)]
doc: Change xref style to number only

Change the style of links generated by xrefs to section number only, as
it was with DSSSL, instead of number and title, as is the default of the
XSLT stylesheets.

Our documentation is mostly written expecting the old style, so keep
that for the time being, per discussion.

7 years agoRemove reinvention of stringify macro.
Tom Lane [Sun, 2 Apr 2017 23:19:16 +0000 (19:19 -0400)]
Remove reinvention of stringify macro.

We already have CppAsString2, there's no need for the MSVC support to
re-invent a macro to do that (and especially not to inject it in as
ugly a way as this).

Discussion: https://postgr.es/m/CADkLM=c+hm2rc0tkKgC-ZgrLttHT2KkfppE+BC-=i-xj+7V-TQ@mail.gmail.com

7 years agoDoc: clarify behavior of OT_WHOLE_LINE and OT_FILEPIPE psql slash commands.
Tom Lane [Sun, 2 Apr 2017 23:01:53 +0000 (19:01 -0400)]
Doc: clarify behavior of OT_WHOLE_LINE and OT_FILEPIPE psql slash commands.

This is another bit of ancient behavior that was documented poorly (in
a couple of cases) or not at all (in several others).

Discussion: https://postgr.es/m/9b4ea968-753f-4b5f-b46c-d7d3bf7c8f90@manitou-mail.org

7 years agoDocument psql's behavior of recalling the previously executed query.
Tom Lane [Sun, 2 Apr 2017 22:26:37 +0000 (18:26 -0400)]
Document psql's behavior of recalling the previously executed query.

Various psql slash commands that normally act on the current query buffer
will automatically recall and re-use the most recently executed SQL command
instead, if the current query buffer is empty.  Although this behavior is
ancient (dating apparently to commit 77a472993), it was documented nowhere
in the psql reference page.  For that matter, we'd never bothered to define
the concept of "current query buffer" explicitly.  Fix that.  Do some
wordsmithing on relevant command descriptions to improve clarity and
consistency.

Discussion: https://postgr.es/m/9b4ea968-753f-4b5f-b46c-d7d3bf7c8f90@manitou-mail.org

7 years agoFix behavior of psql's \p to agree with \g, \w, etc.
Tom Lane [Sun, 2 Apr 2017 20:50:25 +0000 (16:50 -0400)]
Fix behavior of psql's \p to agree with \g, \w, etc.

In commit e984ef586 I (tgl) simplified the behavior of \p to just print
the current query buffer; but Daniel Vérité points out that this made it
inconsistent with the behavior of \g and \w.  It should print the same
thing \g would execute.  Fix that, and improve related comments.

Daniel Vérité

Discussion: https://postgr.es/m/9b4ea968-753f-4b5f-b46c-d7d3bf7c8f90@manitou-mail.org

7 years agoFix some typos and spelling errors in comments
Magnus Hagander [Sun, 2 Apr 2017 17:55:28 +0000 (19:55 +0200)]
Fix some typos and spelling errors in comments

Author: Erik Rijkers

7 years agoAllow psql variable substitution to occur in backtick command strings.
Tom Lane [Sun, 2 Apr 2017 01:44:54 +0000 (21:44 -0400)]
Allow psql variable substitution to occur in backtick command strings.

Previously, text between backquotes in a psql metacommand's arguments
was always passed to the shell literally.  That considerably hobbles
the usefulness of the feature for scripting, so we'd foreseen for a long
time that we'd someday want to allow substitution of psql variables into
the shell command.  IMO the addition of \if metacommands has brought us to
that point, since \if can greatly benefit from some sort of client-side
expression evaluation capability, and psql itself is not going to grow any
such thing in time for v10.  Hence, this patch.  It allows :VARIABLE to be
replaced by the exact contents of the named variable, while :'VARIABLE'
is replaced by the variable's contents suitably quoted to become a single
shell-command argument.  (The quoting rules for that are different from
those for SQL literals, so this is a bit of an abuse of the :'VARIABLE'
notation, but I doubt anyone will be confused.)

As with other situations in psql, no substitution occurs if the word
following a colon is not a known variable name.  That limits the risk of
compatibility problems for existing psql scripts; but the risk isn't zero,
so this needs to be called out in the v10 release notes.

Discussion: https://postgr.es/m/9561.1490895211@sss.pgh.pa.us

7 years agoFix two undocumented parameters to functions from ENR patch.
Kevin Grittner [Sat, 1 Apr 2017 20:21:05 +0000 (15:21 -0500)]
Fix two undocumented parameters to functions from ENR patch.

On ProcessUtility document the parameter, to match others.

On CreateCachedPlan drop the queryEnv parameter.  It was not
referenced within the function, and had been added on the
assumption that with some unknown future usage of QueryEnvironment
it might be useful to do something there.  We have avoided other
"just in case" implementation of unused paramters, so drop it here.

Per gripe from Tom Lane

7 years agoBRIN de-summarization
Alvaro Herrera [Sat, 1 Apr 2017 19:10:04 +0000 (16:10 -0300)]
BRIN de-summarization

When the BRIN summary tuple for a page range becomes too "wide" for the
values actually stored in the table (because the tuples that were
present originally are no longer present due to updates or deletes), it
can be useful to remove the outdated summary tuple, so that a future
summarization can install a tighter summary.

This commit introduces a SQL-callable interface to do so.

Author: Álvaro Herrera
Reviewed-by: Eiji Seki
Discussion: https://postgr.es/m/20170228045643.n2ri74ara4fhhfxf@alvherre.pgsql

7 years agoFix expected output
Alvaro Herrera [Sat, 1 Apr 2017 19:00:11 +0000 (16:00 -0300)]
Fix expected output

Previous commit had a thinko in the expected output for new tests.

Per buildfarm

7 years agoBRIN auto-summarization
Alvaro Herrera [Sat, 1 Apr 2017 17:00:53 +0000 (14:00 -0300)]
BRIN auto-summarization

Previously, only VACUUM would cause a page range to get initially
summarized by BRIN indexes, which for some use cases takes too much time
since the inserts occur.  To avoid the delay, have brininsert request a
summarization run for the previous range as soon as the first tuple is
inserted into the first page of the next range.  Autovacuum is in charge
of processing these requests, after doing all the regular vacuuming/
analyzing work on tables.

This doesn't impose any new tasks on autovacuum, because autovacuum was
already in charge of doing summarizations.  The only actual effect is to
change the timing, i.e. that it occurs earlier.  For this reason, we
don't go any great lengths to record these requests very robustly; if
they are lost because of a server crash or restart, they will happen at
a later time anyway.

Most of the new code here is in autovacuum, which can now be told about
"work items" to process.  This can be used for other things such as GIN
pending list cleaning, perhaps visibility map bit setting, both of which
are currently invoked during vacuum, but do not really depend on vacuum
taking place.

The requests are at the page range level, a granularity for which we did
not have SQL-level access; we only had index-level summarization
requests via brin_summarize_new_values().  It seems reasonable to add
SQL-level access to range-level summarization too, so add a function
brin_summarize_range() to do that.

Authors: Álvaro Herrera, based on sketch from Simon Riggs.
Reviewed-by: Thomas Munro.
Discussion: https://postgr.es/m/20170301045823.vneqdqkmsd4as4ds@alvherre.pgsql

7 years agoWrite "waiting for checkpoint" on regular progress row
Magnus Hagander [Sat, 1 Apr 2017 15:04:14 +0000 (17:04 +0200)]
Write "waiting for checkpoint" on regular progress row

When reporting progress, make the "waiting for checkpoint" test be
overwritten by the file-based progress once it's completed. This is more
consistent with how we report the rest of the progress.

Suggested by Jeff Janes

7 years agoTry to fix breakage of sepgsql hooks by ENR patch.
Kevin Grittner [Sat, 1 Apr 2017 05:10:12 +0000 (00:10 -0500)]
Try to fix breakage of sepgsql hooks by ENR patch.

Turned up by buildfarm animal rhinoceros.  Fixing blind.  Will have
to wait for next run by rhinoceros to know whether it worked.

7 years agoAdd transition table support to plpgsql.
Kevin Grittner [Sat, 1 Apr 2017 04:30:08 +0000 (23:30 -0500)]
Add transition table support to plpgsql.

Kevin Grittner and Thomas Munro
Reviewed by Heikki Linnakangas, David Fetter, and Thomas Munro
with valuable comments and suggestions from many others

7 years agoAdd infrastructure to support EphemeralNamedRelation references.
Kevin Grittner [Sat, 1 Apr 2017 04:17:18 +0000 (23:17 -0500)]
Add infrastructure to support EphemeralNamedRelation references.

A QueryEnvironment concept is added, which allows new types of
objects to be passed into queries from parsing on through
execution.  At this point, the only thing implemented is a
collection of EphemeralNamedRelation objects -- relations which
can be referenced by name in queries, but do not exist in the
catalogs.  The only type of ENR implemented is NamedTuplestore, but
provision is made to add more types fairly easily.

An ENR can carry its own TupleDesc or reference a relation in the
catalogs by relid.

Although these features can be used without SPI, convenience
functions are added to SPI so that ENRs can easily be used by code
run through SPI.

The initial use of all this is going to be transition tables in
AFTER triggers, but that will be added to each PL as a separate
commit.

An incidental effect of this patch is to produce a more informative
error message if an attempt is made to modify the contents of a CTE
from a referencing DML statement.  No tests previously covered that
possibility, so one is added.

Kevin Grittner and Thomas Munro
Reviewed by Heikki Linnakangas, David Fetter, and Thomas Munro
with valuable comments and suggestions from many others

7 years agoAvoid GatherMerge crash when there are no workers.
Robert Haas [Sat, 1 Apr 2017 01:15:05 +0000 (21:15 -0400)]
Avoid GatherMerge crash when there are no workers.

It's unnecessary to return an actual slot when we have no tuple.
We can just return NULL, which avoids the risk of indexing into an
array that might not contain any elements.

Rushabh Lathia, per a report from Tomas Vondra

Discussion: http://postgr.es/m/6ecd6f17-0dcf-1de7-ded8-0de7db1ddc88@2ndquadrant.com

7 years agoFix parallel query so it doesn't spoil row estimates above Gather.
Robert Haas [Sat, 1 Apr 2017 01:01:20 +0000 (21:01 -0400)]
Fix parallel query so it doesn't spoil row estimates above Gather.

Commit 45be99f8cd5d606086e0a458c9c72910ba8a613d removed GatherPath's
num_workers field, but this is entirely bogus.  Normally, a path's
parallel_workers flag is supposed to indicate the number of workers
that it wants, and should be 0 for a non-partial path.  In that
commit, I mistakenly thought that GatherPath could also use that field
to indicate the number of workers that it would try to start, but
that's disastrous, because then it can propagate up to higher nodes in
the plan tree, which will then get incorrect rowcounts because the
parallel_workers flag is involved in computing those values.  Repair
by putting the separate field back.

Report by Tomas Vondra.  Patch by me, reviewed by Amit Kapila.

Discussion: http://postgr.es/m/f91b4a44-f739-04bd-c4b6-f135bd643669@2ndquadrant.com

7 years agoDon't use bgw_main even to specify in-core bgworker entrypoints.
Robert Haas [Sat, 1 Apr 2017 00:35:51 +0000 (20:35 -0400)]
Don't use bgw_main even to specify in-core bgworker entrypoints.

On EXEC_BACKEND builds, this can fail if ASLR is in use.

Backpatch to 9.5.  On master, completely remove the bgw_main field
completely, since there is no situation in which it is safe for an
EXEC_BACKEND build.  On 9.6 and 9.5, leave the field intact to avoid
breaking things for third-party code that doesn't care about working
under EXEC_BACKEND.  Prior to 9.5, there are no in-core bgworker
entrypoints.

Petr Jelinek, reviewed by me.

Discussion: http://postgr.es/m/09d8ad33-4287-a09b-a77f-77f8761adb5e@2ndquadrant.com

7 years agoFix unstable regression test result.
Tom Lane [Sat, 1 Apr 2017 00:29:30 +0000 (20:29 -0400)]
Fix unstable regression test result.

Whoops, missed that same test was made for json as well as jsonb.

7 years agoFix unstable regression test result.
Tom Lane [Sat, 1 Apr 2017 00:24:12 +0000 (20:24 -0400)]
Fix unstable regression test result.

Commit e306df7f9 added a test case that depends on "the" being a
stop word, which it is not in non-English locales.  Since the
point of the test is to check stopword behavior, fix by forcibly
selecting the 'english' configuration.

Per buildfarm.

7 years agoFix typos.
Robert Haas [Sat, 1 Apr 2017 00:17:47 +0000 (20:17 -0400)]
Fix typos.

Brandur Leach

7 years agoFor foreign keys, check REFERENCES privilege only on the referenced table.
Tom Lane [Fri, 31 Mar 2017 22:11:25 +0000 (18:11 -0400)]
For foreign keys, check REFERENCES privilege only on the referenced table.

We were requiring that the user have REFERENCES permission on both the
referenced and referencing tables --- but this doesn't seem to have any
support in the SQL standard, which says only that you need REFERENCES
permission on the referenced table.  And ALTER TABLE ADD FOREIGN KEY has
already checked that you own the referencing table, so the check could
only fail if a table owner has revoked his own REFERENCES permission.
Moreover, the symmetric interpretation of this permission is unintuitive
and confusing, as per complaint from Paul Jungwirth.  So let's drop the
referencing-side check.

In passing, do a bit of wordsmithing on the GRANT reference page so that
all the privilege types are described in similar fashion.

Discussion: https://postgr.es/m/8940.1490906755@sss.pgh.pa.us

7 years agoImprove documentation for table partitioning.
Robert Haas [Fri, 31 Mar 2017 21:33:34 +0000 (17:33 -0400)]
Improve documentation for table partitioning.

Emphasize the new declarative partitioning more, and compare and
contrast it more clearly with inheritance-based partitioning.

Amit Langote, reviewed and somewhat revised by me

Discussion: http://postgr.es/m/a6f99cdb-21e7-1d65-1381-91f2cfa156e2@lab.ntt.co.jp

7 years agoRevert "Allow ON CONFLICT .. DO NOTHING on a partitioned table."
Robert Haas [Fri, 31 Mar 2017 20:47:38 +0000 (16:47 -0400)]
Revert "Allow ON CONFLICT .. DO NOTHING on a partitioned table."

This reverts commit 8355a011a0124bdf7ccbada206a967d427039553, which
turns out to have been a misguided effort.  We can't really support
this in a partitioning hierarchy after all for exactly the reasons
stated in the documentation removed by that commit.  It's still
possible to use ON CONFLICT .. DO NOTHING (or for that matter ON
CONFLICT .. DO UPDATE) on individual partitions if desired, but
but to allow this on a partitioned table implies that we have some
way of evaluating uniqueness across the whole partitioning
hierarchy, which is false.

Shinoda Noriyoshi noticed that the old code was crashing (which we
could fix, though not in a nice way) and Amit Langote realized
that this was indicative of a fundamental problem with the commit
being reverted here.

Discussion: http://postgr.es/m/ff3dc21d-7204-c09c-50ac-cf11a8c45c81@lab.ntt.co.jp

7 years agoDon't allocate storage for partitioned tables.
Robert Haas [Fri, 31 Mar 2017 20:28:30 +0000 (16:28 -0400)]
Don't allocate storage for partitioned tables.

Also, don't allow setting reloptions on them, since that would have no
effect given the lack of storage.  The patch does this by introducing
a new reloption kind for which there are currently no reloptions -- we
might have some in the future -- so it adjusts parseRelOptions to
handle that case correctly.

Bumped catversion.  System catalogs that contained reloptions for
partitioned tables are no longer valid; plus, there are now fewer
physical files on disk, which is not technically a catalog change but
still a good reason to re-initdb.

Amit Langote, reviewed by Maksim Milyutin and Kyotaro Horiguchi and
revised a bit by me.

Discussion: http://postgr.es/m/20170331.173326.212311140.horiguchi.kyotaro@lab.ntt.co.jp

7 years agopostgres_fdw: Teach IMPORT FOREIGN SCHEMA about partitioning.
Robert Haas [Fri, 31 Mar 2017 19:01:35 +0000 (15:01 -0400)]
postgres_fdw: Teach IMPORT FOREIGN SCHEMA about partitioning.

Don't import partitions.  Do import partitioned tables which are
not themselves partitions.

Report by Stephen Frost.  Design and patch by Michael Paquier,
reviewed by Amit Langote.  Documentation revised by me.

Discussion: http://postgr.es/m/20170309141531.GD9812@tamriel.snowman.net

7 years agoFull Text Search support for json and jsonb
Andrew Dunstan [Fri, 31 Mar 2017 18:26:03 +0000 (14:26 -0400)]
Full Text Search support for json and jsonb

The new functions are ts_headline() and to_tsvector.

Dmitry Dolgov, edited and documented by me.

7 years agoTransform or iterate over json(b) string values
Andrew Dunstan [Fri, 31 Mar 2017 18:25:25 +0000 (14:25 -0400)]
Transform or iterate over json(b) string values

Dmitry Dolgov, reviewed and lightly edited by me.

7 years agoFix typo in comment
Magnus Hagander [Fri, 31 Mar 2017 07:00:38 +0000 (09:00 +0200)]
Fix typo in comment

Daniel Gustafsson

7 years agoFix broken markup.
Tom Lane [Thu, 30 Mar 2017 21:13:44 +0000 (17:13 -0400)]
Fix broken markup.

Per buildfarm.

7 years agoFix pgrowlocks minor coding oversight
Simon Riggs [Thu, 30 Mar 2017 18:53:07 +0000 (14:53 -0400)]
Fix pgrowlocks minor coding oversight

7 years agoDefault monitoring roles
Simon Riggs [Thu, 30 Mar 2017 18:18:53 +0000 (14:18 -0400)]
Default monitoring roles

Three nologin roles with non-overlapping privs are created by default
* pg_read_all_settings - read all GUCs.
* pg_read_all_stats - pg_stat_*, pg_database_size(), pg_tablespace_size()
* pg_stat_scan_tables - may lock/scan tables

Top level role - pg_monitor includes all of the above by default, plus others

Author: Dave Page
Reviewed-by: Stephen Frost, Robert Haas, Peter Eisentraut, Simon Riggs
7 years agoSupport \if ... \elif ... \else ... \endif in psql scripting.
Tom Lane [Thu, 30 Mar 2017 16:59:11 +0000 (12:59 -0400)]
Support \if ... \elif ... \else ... \endif in psql scripting.

This patch adds nestable conditional blocks to psql.  The control
structure feature per se is complete, but the boolean expressions
understood by \if and \elif are pretty primitive; basically, after
variable substitution and backtick expansion, the result has to be
"true" or "false" or one of the other standard spellings of a boolean
value.  But that's enough for many purposes, since you can always
do the heavy lifting on the server side; and we can extend it later.

Along the way, pay down some of the technical debt that had built up
around psql/command.c:
* Refactor exec_command() into a function per command, instead of
being a 1500-line monstrosity.  This makes the file noticeably longer
because of repetitive function header/trailer overhead, but it seems
much more readable.
* Teach psql_get_variable() and psqlscanslash.l to suppress variable
substitution and backtick expansion on the basis of the conditional
stack state, thereby allowing removal of the OT_NO_EVAL kluge.
* Fix the no-doubt-once-expedient hack of sometimes silently substituting
mainloop.c's previous_buf for query_buf when calling HandleSlashCmds.
(It's a bit remarkable that commands like \r worked at all with that.)
Recall of a previous query is now done explicitly in the slash commands
where that should happen.

Corey Huinker, reviewed by Fabien Coelho, further hacking by me

Discussion: https://postgr.es/m/CADkLM=c94OSRTnat=LX0ivNq4pxDNeoomFfYvBKM5N_xfmLtAA@mail.gmail.com

7 years agoTry to fix xml docs build broken in 5ded4bd.
Andres Freund [Thu, 30 Mar 2017 16:41:00 +0000 (09:41 -0700)]
Try to fix xml docs build broken in 5ded4bd.

Apparently the sgml to xml conversion treats non-closed <para>s
differently than jade does.

7 years agoSimplify the example of VACUUM in documentation.
Fujii Masao [Thu, 30 Mar 2017 16:31:15 +0000 (01:31 +0900)]
Simplify the example of VACUUM in documentation.

Previously a detailed activity report by VACUUM VERBOSE ANALYZE was
described as an example of VACUUM in docs. But it had been obsolete
for a long time. For example, commit feb4f44d296b88b7f0723f4a4f3945a371276e0b
updated the content of that activity report in 2003, but we had
forgotten to update the example.

So basically we need to update the example. But since no one cared
about the details of VACUUM output and complained about that mistake
for such long time, per discussion on hackers, we decided to get rid
of the detailed activity report from the example and simplify it.

Back-patch to all supported versions.

Reported by Masahiko Sawada, patch by me.
Discussion: https://postgr.es/m/CAD21AoAGA2pB3p-CWmTkxBsbkZS1bcDGBLcYVcvcDxspG_XAfA@mail.gmail.com

7 years agoRemove support for version-0 calling conventions.
Andres Freund [Wed, 29 Mar 2017 20:16:49 +0000 (13:16 -0700)]
Remove support for version-0 calling conventions.

The V0 convention is failure prone because we've so far assumed that a
function is V0 if PG_FUNCTION_INFO_V1 is missing, leading to crashes
if a function was coded against the V1 interface.  V0 doesn't allow
proper NULL, SRF and toast handling.  V0 doesn't offer features that
V1 doesn't.

Thus remove V0 support and obsolete fmgr README contents relating to
it.

Author: Andres Freund, with contributions by Peter Eisentraut & Craig Ringer
Reviewed-By: Peter Eisentraut, Craig Ringer
Discussion: https://postgr.es/m/20161208213441.k3mbno4twhg2qf7g@alap3.anarazel.de

7 years agoMove contrib/seg to only use V1 calling conventions.
Andres Freund [Wed, 29 Mar 2017 20:16:30 +0000 (13:16 -0700)]
Move contrib/seg to only use V1 calling conventions.

A later commit will remove V0 support.

Author: Andres Freund, with contributions by Craig Ringer
Reviewed-By: Peter Eisentraut, Craig Ringer
Discussion: https://postgr.es/m/20161208213441.k3mbno4twhg2qf7g@alap3.anarazel.de

7 years agoImplement SortSupport for macaddr data type
Teodor Sigaev [Wed, 29 Mar 2017 20:28:56 +0000 (23:28 +0300)]
Implement SortSupport for macaddr data type

Introduces a scheme to produce abbreviated keys for the macaddr type.
Bump catalog version.

Author: Brandur Leach
Reviewed-by: Julien Rouhaud, Peter Geoghegan
https://commitfest.postgresql.org/13/743/

7 years agopg_dump: Remove query truncation in error messages
Peter Eisentraut [Wed, 29 Mar 2017 19:17:14 +0000 (15:17 -0400)]
pg_dump: Remove query truncation in error messages

Remove the behavior that a query mentioned in an error message would be
truncated to 128 characters.  The queries that pg_dump runs are often
longer than that, and this behavior makes analyzing failures harder
unnecessarily.

Discussion: https://www.postgresql.org/message-id/flat/63201ef9-26fb-3f1f-664d-98531678cebc%402ndquadrant.com

7 years agoUpdate copyright year in recently added files
Peter Eisentraut [Wed, 29 Mar 2017 18:54:10 +0000 (14:54 -0400)]
Update copyright year in recently added files

Author: Masahiko Sawada <sawada.mshk@gmail.com>

7 years agoSimplify check of modified attributes in heap_update
Alvaro Herrera [Wed, 29 Mar 2017 15:18:48 +0000 (12:18 -0300)]
Simplify check of modified attributes in heap_update

The old coding was getting more complicated as new things were added,
and it would be barely tolerable with upcoming WARM updates and other
future features such as indirect indexes.  The new coding incurs a small
performance cost in synthetic benchmark cases, and is barely measurable
in normal cases.  A much larger benefit is expected from WARM, which
could actually bolt its needs on top of the existing coding, but it is
much uglier and bug-prone than doing it on this new code.  Additional
optimization can be applied on top of this, if need be.

Reviewed-by: Pavan Deolasee, Amit Kapila, Mithun CY
Discussion: https://postgr.es/m/20161228232018.4hc66ndrzpz4g4wn@alvherre.pgsql
https://postgr.es/m/CABOikdMJfz69dBNRTOZcB6s5A0tf8OMCyQVYQyR-WFFdoEwKMQ@mail.gmail.com

7 years agoMark more functions parallel-restricted.
Robert Haas [Wed, 29 Mar 2017 14:59:27 +0000 (10:59 -0400)]
Mark more functions parallel-restricted.

Commit 61c2e1a95f94bb904953a6281ce17a18ac38ee6d allowed parallel
query to be used in more places, revealing via buildfarm member
mandrill that several functions intended to be called from triggers
were incorrectly marked parallel-safe rather than parallel-restricted.

Report by Tom Lane.  Patch by Rafia Sabih.  Reviewed by me.

Discussion: http://postgr.es/m/16061.1490479253@sss.pgh.pa.us

7 years agoPlug race in dsa_attach.
Robert Haas [Wed, 29 Mar 2017 13:44:29 +0000 (09:44 -0400)]
Plug race in dsa_attach.

With sufficiently bad luck, it was possible for a parallel worker to
attempt attach to a DSA area after all other backends have detached
from it, which is not legal.  If the worker had waited a little longer
to get started, the DSM itself would have been destroyed, which is why
this wasn't noticed before.

Thomas Munro, per a report from Andreas Seltenreich

Discussion: http://postgr.es/m/87h92g83t3.fsf@credativ.de

7 years agoFix hardcoded typeof check result for Windows
Peter Eisentraut [Wed, 29 Mar 2017 12:55:34 +0000 (08:55 -0400)]
Fix hardcoded typeof check result for Windows

The test result that I had blindly stipulated didn't work out on the
build farm, so disable the feature in Windows MSVC for now.

7 years agoFix configure check for typeof
Peter Eisentraut [Wed, 29 Mar 2017 02:28:56 +0000 (22:28 -0400)]
Fix configure check for typeof

7 years agoImprove Node vs Expr use a bit
Peter Eisentraut [Wed, 29 Mar 2017 01:55:58 +0000 (21:55 -0400)]
Improve Node vs Expr use a bit

Author: Mark Dilger <hornschnorter@gmail.com>

7 years agoCast result of copyObject() to correct type
Peter Eisentraut [Thu, 9 Mar 2017 20:18:59 +0000 (15:18 -0500)]
Cast result of copyObject() to correct type

copyObject() is declared to return void *, which allows easily assigning
the result independent of the input, but it loses all type checking.

If the compiler supports typeof or something similar, cast the result to
the input type.  This creates a greater amount of type safety.  In some
cases, where the result is assigned to a generic type such as Node * or
Expr *, new casts are now necessary, but in general casts are now
unnecessary in the normal case and indicate that something unusual is
happening.

Reviewed-by: Mark Dilger <hornschnorter@gmail.com>
7 years agodoc: Mention --enable-tap-tests in regression test chapter
Peter Eisentraut [Wed, 29 Mar 2017 01:12:30 +0000 (21:12 -0400)]
doc: Mention --enable-tap-tests in regression test chapter

Reported-by: Jeff Janes <jeff.janes@gmail.com>
7 years agoChange 'diag' to 'note' in TAP tests
Peter Eisentraut [Wed, 29 Mar 2017 00:38:06 +0000 (20:38 -0400)]
Change 'diag' to 'note' in TAP tests

Reduce noise from TAP tests by changing 'diag' to 'note', so output only
goes to the test's log file not stdout, unless in verbose mode.  This
also removes the junk on screen when running the TAP tests in parallel.

Author: Craig Ringer <craig@2ndquadrant.com>

7 years agoAllow DSM segments to be created as pinned
Alvaro Herrera [Fri, 24 Mar 2017 22:27:22 +0000 (19:27 -0300)]
Allow DSM segments to be created as pinned

dsm_create and dsm_attach assumed that a current resource owner was
always in place.  Exploration with the API show that this is
inconvenient: sometimes one must create a dummy resowner, create/attach
the DSM, only to pin the mapping later, which is wasteful.  Change
create/attach so that if there is no current resowner, the dsm is
effectively pinned right from the start.

Discussion: https://postgr.es/m/20170324232710.32acsfsvjqfgc6ud@alvherre.pgsql
Reviewed by Thomas Munro.

7 years agoMake new expression eval code reject references to dropped columns.
Tom Lane [Tue, 28 Mar 2017 22:05:03 +0000 (18:05 -0400)]
Make new expression eval code reject references to dropped columns.

Formerly, a Var referencing an already-dropped column was allowed and would
always produce a NULL value.  However, that behavior was implemented in
slot_getattr which the new expression code doesn't use; thus there is now a
risk of returning theoretically-deleted data.  We had regression test cases
that purported to exercise this, but they failed to expose any problem,
apparently because plpgsql filters the dropped column and produces an
output tuple that has a NULL there already.

Ideally the DROP or ALTER attempt in these test cases would get rejected
due to dependency checks; but until that happens, let's modify the behavior
so that we fail the query during executor start.  This was already true for
the related case of a column having changed type underneath us, and there's
no obvious reason why we need to be laxer for dropped columns.

In passing, adjust the error messages in CheckVarSlotCompatibility to
include the composite type name.  In the cases shown in the regression
tests this is always just "record", but it should be more useful in
actual stale-plan cases, where the slot tupdesc would be a table's
tupdesc directly.

Discussion: https://postgr.es/m/16803.1490723570@sss.pgh.pa.us

7 years agoRemove direct uses of ItemPointer.{ip_blkid,ip_posid}
Alvaro Herrera [Tue, 28 Mar 2017 15:52:55 +0000 (12:52 -0300)]
Remove direct uses of ItemPointer.{ip_blkid,ip_posid}

There are no functional changes here; this simply encapsulates knowledge
of the ItemPointerData struct so that a future patch can change things
without more breakage.

All direct users of ip_blkid and ip_posid are changed to use existing
macros ItemPointerGetBlockNumber and ItemPointerGetOffsetNumber
respectively.  For callers where that's inappropriate (because they
Assert that the itempointer is is valid-looking), add
ItemPointerGetBlockNumberNoCheck and ItemPointerGetOffsetNumberNoCheck,
which lack the assertion but are otherwise identical.

Author: Pavan Deolasee
Discussion: https://postgr.es/m/CABOikdNnFon4cJiL=h1mZH3bgUeU+sWHuU4Yr8AB=j3A2p1GiA@mail.gmail.com

7 years agoCorrect grammar in error message
Simon Riggs [Tue, 28 Mar 2017 17:24:39 +0000 (13:24 -0400)]
Correct grammar in error message

"could not generate" rather than "could not generation"
from commit 818fd4a67d610991757b610755e3065fb99d80a5

7 years agoFix ssl tests
Peter Eisentraut [Tue, 28 Mar 2017 17:22:00 +0000 (13:22 -0400)]
Fix ssl tests

facde2a98f0b5f7689b4e30a9e7376e926e733b8 introduced a typo during
rebasing.

7 years agoSuppress implicit-conversion warnings seen with newer clang versions.
Tom Lane [Tue, 28 Mar 2017 17:16:19 +0000 (13:16 -0400)]
Suppress implicit-conversion warnings seen with newer clang versions.

We were assigning values near 255 through "char *" pointers.  On machines
where char is signed, that's not entirely kosher, and it's reasonable
for compilers to warn about it.

A better solution would be to change the pointer type to "unsigned char *",
but that would be vastly more invasive.  For the moment, let's just apply
this simple backpatchable solution.

Aleksander Alekseev

Discussion: https://postgr.es/m/20170220141239.GD12278@e733.localdomain
Discussion: https://postgr.es/m/2839.1490714708@sss.pgh.pa.us

7 years agoAltering default privileges on schemas
Teodor Sigaev [Tue, 28 Mar 2017 15:58:55 +0000 (18:58 +0300)]
Altering default privileges on schemas

Extend ALTER DEFAULT PRIVILEGES command to schemas.

Author: Matheus Oliveira
Reviewed-by: Petr Jelínek, Ashutosh Sharma
https://commitfest.postgresql.org/13/887/

7 years agodblink: Fix error reporting
Peter Eisentraut [Tue, 28 Mar 2017 15:08:38 +0000 (11:08 -0400)]
dblink: Fix error reporting

The conname variable was not initialized in some code paths, resulting
in error reports referring to the "unnamed" connection rather than the
correct connection name.

Author: Rushabh Lathia <rushabh.lathia@gmail.com>

7 years agoCleanup slots during drop database
Simon Riggs [Tue, 28 Mar 2017 14:05:21 +0000 (10:05 -0400)]
Cleanup slots during drop database

Automatically drop all logical replication slots associated with a
database when the database is dropped. Previously we threw an ERROR
if a slot existed. Now we throw ERROR only if a slot is active in
the database being dropped.

Craig Ringer