Commit Graph

42173 Commits

Author SHA1 Message Date
Peter Eisentraut 8df9bd0b44 Change logical replication pg_hba.conf use
Logical replication no longer uses the "replication" keyword.  It just
matches database entries in the normal way.  The "replication" keyword
now only applies to physical replication.

Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
2017-03-22 11:19:30 -04:00
Peter Eisentraut 4cfc9484d4 Refine rules for altering publication owner
Previously, the new owner had to be a superuser.  The new rules are more
refined similar to other objects.

Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
2017-03-22 11:19:30 -04:00
Andrew Dunstan 96a7128b7b Sync pg_dump and pg_dumpall output
Before exiting any files are fsync'ed. A --no-sync option is also
provided for a faster exit if desired.

Michael Paquier.

Reviewed by Albe Laurenz

Discussion: https://postgr.es/m/CAB7nPqS1uZ=Ov+UruW6jr3vB-S_DLVMPc0dQpV-fTDjmm0ZQMg@mail.gmail.com
2017-03-22 10:20:13 -04:00
Simon Riggs 9b013dc238 Improve performance of replay of AccessExclusiveLocks
A hot standby replica keeps a list of Access Exclusive locks for a top
level transaction. These locks are released when the top level transaction
ends. Searching of this list is O(N^2), and each transaction had to pay the
price of searching this list for locks, even if it didn't take any AE
locks itself.

This patch optimizes this case by having the master server track which
transactions took AE locks, and passes that along to the standby server in
the commit/abort record. This allows the standby to only try to release
locks for transactions which actually took any, avoiding the majority of
the performance issue.

Refactor MyXactAccessedTempRel into MyXactFlags to allow minimal additional
cruft with this.

Analysis and initial patch by David Rowley
Author: David Rowley and Simon Riggs
2017-03-22 13:09:36 +00:00
Simon Riggs 1148e22a82 Teach xlogreader to follow timeline switches
Uses page-based mechanism to ensure we’re using the correct timeline.

Tests are included to exercise the functionality using a cold disk-level copy
of the master that's started up as a replica with slots intact, but the
intended use of the functionality is with later features.

Craig Ringer, reviewed by Simon Riggs and Andres Freund
2017-03-22 07:05:12 +00:00
Peter Eisentraut 9ca2dd578d Avoid Perl warning
Perl versions before 5.12 would warn "Use of implicit split to @_ is
deprecated".

Author: Jeff Janes <jeff.janes@gmail.com>
2017-03-22 00:18:49 -04:00
Peter Eisentraut 05227e0c34 pg_dump: Only dump publications when dumping everything
Don't dump publications with pg_dump -t or similar cases that select
specific groups of objects.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
2017-03-21 23:34:40 -04:00
Peter Eisentraut 9212810c4f doc: Update tool sets documentation for modern FreeBSD
For several operating systems, we give handy package manager one-liners
to install all the requirements for building our documentation.  All
current production FreeBSD releases have a friendly new package manager
a bit like apt/yum, so give a one line command here.  Also, add a brief
note about gmake vs make in the doc subdirectory.

Author: Thomas Munro <thomas.munro@enterprisedb.com>
2017-03-21 22:11:49 -04:00
Andrew Dunstan 80275561ff Document btree_gin support for enums 2017-03-21 11:11:42 -04:00
Andrew Dunstan 4ad0f88c44 Add btree_gin support for enum types
Reviewed by Tom Lane and Anastasia Lubennikova

Discussion:  http://postgr.es/m/56EA8A71.8060107@dunslane.net
2017-03-21 11:04:17 -04:00
Andrew Dunstan f7946a92b6 Add btree_gist support for enum types.
This will allow enums to be used in exclusion constraints.

The code uses the new CallerFInfoFunctionCall infrastructure in fmgr,
and the support for it added to btree_gist in commit 393bb504d7.

Reviewed by Tom Lane and Anastasia Lubennikova

Discussion:  http://postgr.es/m/56EA8A71.8060107@dunslane.net
2017-03-21 10:43:27 -04:00
Andrew Dunstan 65a9138b9b Use CallerFInfoFunctionCall with btree_gist for varlena types
Follow up to commit 393bb504d7 which did this for numeric types.
2017-03-21 10:43:27 -04:00
Andrew Dunstan 4b1c68d63e Use CallerFInfoFunctionCall with btree_gist for numeric types
None of the existing types actually need to use this mechanism, but this
will allow support for enum types which will need it. A separate patch
will adjust the varlena types support for consistency.

Reviewed by Tom Lane and Anastasia Lubennikova

Discussion:  http://postgr.es/m/27220.1478360811@sss.pgh.pa.us
2017-03-21 10:43:27 -04:00
Simon Riggs eb2a6131be Add a pg_recvlogical wrapper to PostgresNode
Allows testing of logical decoding using SQL interface and/or pg_recvlogical
Most logical decoding tests are in contrib/test_decoding. This module
is for work that doesn't fit well there, like where server restarts
are required.

Craig Ringer
2017-03-21 14:04:49 +00:00
Robert Haas d3cc37f1d8 Don't scan partitioned tables.
Partitioned tables do not contain any data; only their unpartitioned
descendents need to be scanned.  However, the partitioned tables still
need to be locked, even though they're not scanned.  To make that
work, Append and MergeAppend relations now need to carry a list of
(unscanned) partitioned relations that must be locked, and InitPlan
must lock all partitioned result relations.

Aside from the obvious advantage of avoiding some work at execution
time, this has two other advantages.  First, it may improve the
planner's decision-making in some cases since the empty relation
might throw things off.  Second, it paves the way to getting rid of
the storage for partitioned tables altogether.

Amit Langote, reviewed by me.

Discussion: http://postgr.es/m/6837c359-45c4-8044-34d1-736756335a15@lab.ntt.co.jp
2017-03-21 09:48:04 -04:00
Teodor Sigaev d5286aa905 Fix support for some operators (&<, &>, $<|, |&>) in box operator class
of SP-GiST.

Bug exists since initial commit of box opclass for SP-GiST,
so backpath to 9.6

Author: Nikita Glukhov with minor editorization of tests by me
Reviewed-by: Kyotaro Horiguchi, Anastasia Lubennikova

https://commitfest.postgresql.org/13/981/
2017-03-21 16:23:10 +03:00
Andrew Dunstan 29bf501683 Add a direct function call mechanism using the caller's context.
The current DirectFunctionCall functions use NULL as the flinfo in
initializing the FunctionCallInfoData for the call. That means the
called function has no fn_mcxt or fn_extra to work with, and attempting
to do so will result in an access violation. These functions instead use
the provided flinfo, which will usually be the caller's own flinfo. The
caller needs to ensure that it doesn't use the fn_extra in way that is
incompatible with the way the called function will use it. The called
function should not rely on anything else in the provided context, as it
will be relevant to the caller, not the callee.

Original code from Tom Lane.

Discussion: https://postgr.es/m/db2b70a4-78d7-294a-a315-8e7f506c5978@2ndQuadrant.com
2017-03-21 08:57:46 -04:00
Peter Eisentraut 010505546a doc: Improve markup 2017-03-21 08:33:46 -04:00
Bruce Momjian 17fa3e834f doc: clarify that function "ownership" that controls permission
It used to say the creation user.

Reported-by: Nathan Wagner
2017-03-20 22:33:26 -04:00
Bruce Momjian 692ed0567d doc: adjust 'Infinity' example to include minus
This clarifies that quoted infinity values must have the negative signs
inside single quotes.

Reported-by: Don Morrison
2017-03-20 22:22:18 -04:00
Andrew Dunstan 8bc40533d6 Add missing support for new node fields
Commit b6fb534f added two new node fields but neglected to add copy and
comparison support for them, Mea culpa, should have checked for that.

per buildfarm animals with -DCOPY_PARSE_PLAN_TREES
2017-03-20 21:57:33 -04:00
Bruce Momjian c709b113e8 doc: improve createdb example
The previous example could error out due to encoding mismatches;  use
-T/template instead.

Reported-by: Jason O'Donnell
2017-03-20 21:23:56 -04:00
Andrew Dunstan aa740b59a6 Force the regression databases to have bytea_output set to hex
Even if the installation defaults to escape output, this makes
pg_regress make the setting hex, so that installcheck tests can pass in
such a setting.

Jeff Janes.

Discussion: http://postgr.es/m/CAMkU=1xivkTNeyCfzhwdHJ+VH5qpU+4gsipRNuEUbyQf+KN3Kw@mail.gmail.com
2017-03-20 18:12:24 -04:00
Andrew Dunstan b6fb534f10 Add IF NOT EXISTS for CREATE SERVER and CREATE USER MAPPING
There is still some inconsistency with the error messages surrounding
foreign servers. Some use the word "foreign" and some don't. My
inclination is to remove all such uses of "foreign" on the basis that
the  CREATE/ALTER/DROP SERVER commands don't use the word. However, that
is left for another day. In this patch I have kept to the existing usage
in the affected commands, which omits "foreign".

Anastasia Lubennikova, reviewed by Arthur Zakirov and Ashtosh Bapat.

Discussion: http://postgr.es/m/7c2ab9b8-388a-1ce0-23a3-7acf2a0ed3c6@postgrespro.ru
2017-03-20 16:40:45 -04:00
Andrew Dunstan 839cb0649a Use a consistent error message style for user mappings.
User mappings are essentially anonymous, so messages referring to "user
mapping foo on server bar" are wrong, and inconsistent with other error
messages referring to user mappings. To be consistent with existing use,
use "user mapping for foo on server bar" instead.

I dropped the noise word "user" from the original suggestion to be
consistent with other uses.

Discussion: http://postgr.es/m/56c6f8ab-b2d6-f1fa-deb0-1d18cf67f7b9@2ndQuadrant.com
2017-03-20 16:01:45 -04:00
Robert Haas 9abbf4727d Another fix for single-page hash index vacuum.
The WAL consistency checking code needed to be updated for the new
page status bit, but that didn't get done previously.

Ashutosh Sharma, reviewed by Amit Kapila

Discussion: http://postgr.es/m/CAA4eK1LP_oz4EfMen14OjJuzN5CqPdfRkFFuA-MfkcfeE8zGyg@mail.gmail.com
2017-03-20 15:55:27 -04:00
Robert Haas 953477ca35 Fixes for single-page hash index vacuum.
Clear LH_PAGE_HAS_DEAD_TUPLES during replay, similar to what gets done
for btree.  Update hashdesc.c for xl_hash_vacuum_one_page.

Oversights in commit 6977b8b7f4 spotted
by Amit Kapila.  Patch by Ashutosh Sharma.

Bump WAL version.  The original patch to make hash indexes write-ahead
logged probably should have done this, and the single page vacuuming
patch probably should have done it again, but better late than never.

Discussion: http://postgr.es/m/CAA4eK1Kd=mJ9xreovcsh0qMiAj-QqCphHVQ_Lfau1DR9oVjASQ@mail.gmail.com
2017-03-20 15:49:09 -04:00
Tom Lane bc18126a6b Add configure test to see if the C compiler has gcc-style computed gotos.
We'll need this for the upcoming patch to speed up expression evaluation.
Might as well push it now to see if it behaves sanely in the buildfarm.

Andres Freund

Discussion: https://postgr.es/m/20170320062511.hp5qeurtxrwsvfxr@alap3.anarazel.de
2017-03-20 13:35:26 -04:00
Heikki Linnakangas 14a72525d2 Add .gitignore for src/test/authentication/tmp_check.
Michael Paquier

Discussion: https://www.postgresql.org/message-id/CAB7nPqRZ_LNTCJ7gGjE_SpRanGoALfTgsxdauNsKq%2BLBRH9fxg%40mail.gmail.com
2017-03-20 18:27:36 +01:00
Tom Lane 59bfb190f7 Add missed "make clean" logic in src/interfaces/libpq/Makefile.
Commit 818fd4a67 missed cleaning up the symlinks it added for various .c
files imported from src/port and src/common.  Neatnik-ishly make the
file lists in the "clean" target look exactly like the earlier lists of
what to symlink in.
2017-03-20 12:51:45 -04:00
Tom Lane be6c3d19fd Improve regression test coverage for TID scanning.
TidScan plan nodes were not systematically tested before.  These additions
raise the LOC coverage number for the basic regression tests from 52% to
92% in nodeTidscan.c, and from 60% to 93% in tidpath.c.

Andres Freund, tweaked a bit by me

Discussion: https://postgr.es/m/20170320062511.hp5qeurtxrwsvfxr@alap3.anarazel.de
2017-03-20 12:30:23 -04:00
Teodor Sigaev 9cf6033281 Revert unintentional change in increasing usage count during pin of buffers,
this makes buffer access strategy have no effect.
Change was a part of commit 48354581a4 during 9.6
release cycle, so backpath to 9.6

Reported-by: Jim Nasby
Author: Alexander Korotkov
Reviewed-by: Jim Nasby, Andres Freund

https://commitfest.postgresql.org/13/1029/
2017-03-20 18:48:46 +03:00
Stephen Frost de34123834 pg_dump: Skip COLLATION-related regression tests
Not every platform supports non-default collations, as pointed out by
the buildfarm, so skip collation-related regression tests in pg_dump
when they aren't supported.
2017-03-19 16:56:14 -04:00
Magnus Hagander 839da3c7d9 Update obsolete comment
Commit ff27db5d changed this function to no longer return the start
position, but forgot the comment.
2017-03-19 17:07:27 +01:00
Peter Eisentraut 767ce36ff3 doc: Fix a few typos and awkward links 2017-03-18 23:43:47 -04:00
Tom Lane e3044f6184 Avoid use of already-closed relcache entry.
Oversight in commit 17f8ffa1e.  Per buildfarm member prion.
2017-03-18 18:43:06 -04:00
Tom Lane 17f8ffa1e3 Fix REFRESH MATERIALIZED VIEW to report activity to the stats collector.
The non-concurrent code path for REFRESH MATERIALIZED VIEW failed to
report its updates to the stats collector.  This is bad since it means
auto-analyze doesn't know there's any work to be done.  Adjust it to
report the refresh as a table truncate followed by insertion of an
appropriate number of rows.

Since a matview could contain more than INT_MAX rows, change the
signature of pgstat_count_heap_insert() to accept an int64 rowcount.
(The accumulator it's adding into is already int64, but existing
callers could not insert more than a small number of rows at once,
so the argument had been declared just "int n".)

This is surely a bug fix, but changing pgstat_count_heap_insert()'s API
seems too risky for the back branches.  Given the lack of previous
complaints, I'm not sure it's a big enough problem to justify a kluge
solution that would avoid that.  So, no back-patch, at least for now.

Jim Mlodgenski, adjusted a bit by me

Discussion: https://postgr.es/m/CAB_5SRchSz7-WmdO5szdiknG8Oj_GGqJytrk1KRd11yhcMs1KQ@mail.gmail.com
2017-03-18 17:49:39 -04:00
Peter Eisentraut 27f1f585fd doc: Improve wording
Link to CREATE and ALTER ROLE consistently, instead of mixing CREATE
USER and ALTER ROLE.
2017-03-18 17:40:47 -04:00
Peter Eisentraut a72188a35b doc: Add markup 2017-03-18 14:41:47 -04:00
Peter Eisentraut 5e86bb51ea doc: Update compatibility claim
Update outdated claim that TRUNCATE is a PostgreSQL extension.

Add cross-links between DELETE and TRUNCATE references pages.
2017-03-18 14:25:41 -04:00
Peter Eisentraut cb5fa4130e doc: Tweak reference page header style
Change the header style of references pages in HTML and PDF output to be
more like the old style under DSSSL.  In particular, the page should
start with a header containing the command name, instead of just "Name".
2017-03-18 14:17:28 -04:00
Stephen Frost 805e8bc702 Adjust number of tests for pg_dump 001_basic.pl
When removing a test, need to make sure the count of tests is adjusted
when it isn't calculated.
2017-03-18 13:53:29 -04:00
Stephen Frost 5abda5a3e9 pg_dump: Remove "option requires an argument -- j" test
This is really testing getopt more than pg_dump, and what getopt returns
exactly appears to differ based on platform, so remove this test.

Per buildfarm.
2017-03-18 13:46:45 -04:00
Stephen Frost 31a8b77a92 Improve pg_dump regression tests and code coverage
These improvements bring the lines-of-code coverage of pg_dump.c up to
87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly).  Nearly
every function is covered, three of the four which aren't are only
called when talking to older PG instances.

There is more which can, and should, be done here to improve the
coverage but it's past time to see what the buildfarm thinks of this.

What has been added:

- Coverage for many more command-line options
- Use command_fails_like instead of command_exit_is
- Operator classes, operator families
- Text search configuration, templates, parsers, dictionaries
- FDWs, servers, foreign tables
- Materialized views
- Improved Publications / Subscriptions test (though this needs work,
  see PG10 open items and tests marked with XXX in 002_pg_dump.pl)
- Unlogged tables
- Partitioned tables
- Additional ACL testing for various object types

There is room for improvement, specifically:

- Various type-based option (alignment, storage, etc)
- Composite type collation
- Extra Procedural language functions (inline, validator)
- Different function options (SRF, Transform, config, security definer,
  cost, leakproof)
- OpClass options (default, storage, order by, recheck)
- OpFamily options (order by, recheck)
- Aggregate functions (combinefunc, serialfunc, deserialfunc, etc)
- Text Search parser 'headline'
- Text Search template 'init'
- FDW options (handler, validator, options)
- Server options (type, version, options)
- User mapping options
- Default ACLs for sequences, types
- Security labels
- View circular dependencies (last function that needs coverage)
- Toast table autovacuum options
- Replica identity options
- Independent indexes (plus marking them as clustered on)
- Deferrable / initially deferred constraints
- Independent domain constraints

There's bits of extension pg_dump'ing also not covered, but those will
need to go into test_pg_dump (such as having a filter for config
tables).

Last, but not least, this approximately halves the number of tests run
with 'ok()' by removing the ok()-based checking of if all runs are
covered by each test.  Instead, 002_pg_dump.pl will just exit out in
such a case (with a message in the log file).  In general, when adding
tests, cover all runs unless there is a very good reason not to (such as
adding a 'catch-all' case).  With these changes, the resulting output
and number of "tests" run is actually reduced.
2017-03-18 13:18:24 -04:00
Peter Eisentraut 164bdbe9c2 doc: Correct row count in table
The incorrect count causes FOP to error out.
2017-03-18 09:42:26 -04:00
Robert Haas 249cf070e3 Create and use wait events for read, write, and fsync operations.
Previous commits, notably 53be0b1add and
6f3bd98ebf, made it possible to see from
pg_stat_activity when a backend was stuck waiting for another backend,
but it's also fairly common for a backend to be stuck waiting for an
I/O.  Add wait events for those operations, too.

Rushabh Lathia, with further hacking by me.  Reviewed and tested by
Michael Paquier, Amit Kapila, Rajkumar Raghuwanshi, and Rahila Syed.

Discussion: http://postgr.es/m/CAGPqQf0LsYHXREPAZqYGVkDqHSyjf=KsD=k0GTVPAuzyThh-VQ@mail.gmail.com
2017-03-18 07:43:01 -04:00
Michael Meskes 928250aef5 Fix schedule of ecpg test files to only try two-phase commit test when possible. 2017-03-18 10:35:14 +01:00
Tom Lane f7819baa61 Fix WaitEventSetWait() to handle write-ready waits properly on Windows.
Windows apparently will not detect socket write-ready events unless a
preceding send attempt returned WSAEWOULDBLOCK.  In many usage patterns
that's satisfied by the caller of WaitEvenSetWait(), but not always.

Apply the same solution that we already had in pgwin32_select(), namely to
perform a dummy WSASend() call with len=0.  This will return WSAEWOULDBLOCK
if there's no buffer space (even though it could legitimately do nothing
and report success, which makes me a bit nervous about this solution;
but since it's been working fine in libpq, let's roll with it).

In passing, improve the comments about this in pgwin32_select(), and remove
duplicated code there.

Back-patch to 9.6 where WaitEventSetWait() was introduced.  We might need
to back-patch something similar into predecessor code.  But given the lack
of complaints so far, it's not clear that the case ever gets exercised
in the back branches, so I'm not going to expend effort on it right now.

This should resolve recurring failures on buildfarm member bowerbird,
which has been failing since 1e8a85009 went in.

Diagnosis and patch by Petr Jelinek, cosmetic adjustments by me.

Discussion: https://postgr.es/m/5b6a6d6d-fb45-0afb-2e95-5600063c3dbd@2ndquadrant.com
2017-03-17 14:58:06 -04:00
Peter Eisentraut fef2bcdcba pageinspect: Add page_checksum function
Author: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
2017-03-17 10:55:17 -04:00
Andrew Gierth 64ae420b27 Repair test for vacuum reltuples fix.
Concurrent auto-analyze could be holding a snapshot, affecting the
removal of deleted row versions.  Remove the deletion to avoid this
happening.  Per buildfarm.

In passing, make the test independent of assumptions of physical row
order, just out of sheer paranoia.
2017-03-17 14:35:54 +00:00