Tom Lane [Fri, 12 May 2017 20:26:31 +0000 (16:26 -0400)]
Fix dependencies for extended statistics objects.
A stats object ought to have a dependency on each individual column
it reads, not the entire table. Doing this honestly lets us get rid
of the hard-wired logic in RemoveStatisticsExt, which seems to have
been misguidedly modeled on RemoveStatistics; and it will be far easier
to extend to multiple tables later.
Also, add overlooked dependency on owner, and make the dependency on
schema be NORMAL like every other such dependency.
There remains some unfinished work here, which is to allow statistics
objects to be extension members. That takes more effort than just
adding the dependency call, though, so I left it out for now.
initdb forced because this changes the set of pg_depend records that
should exist for a statistics object.
Discussion: https://postgr.es/m/22676.
1494557205@sss.pgh.pa.us
Alvaro Herrera [Fri, 12 May 2017 17:59:23 +0000 (14:59 -0300)]
Change CREATE STATISTICS syntax
Previously, we had the WITH clause in the middle of the command, where
you'd specify both generic options as well as statistic types. Few
people liked this, so this commit changes it to remove the WITH keyword
from that clause and makes it accept statistic types only. (We
currently don't have any generic options, but if we invent in the
future, we will gain a new WITH clause, probably at the end of the
command).
Also, the column list is now specified without parens, which makes the
whole command look more similar to a SELECT command. This change will
let us expand the command to supporting expressions (not just columns
names) as well as multiple tables and their join conditions.
Tom added lots of code comments and fixed some parts of the CREATE
STATISTICS reference page, too; more changes in this area are
forthcoming. He also fixed a potential problem in the alter_generic
regression test, reducing verbosity on a cascaded drop to avoid
dependency on message ordering, as we do in other tests.
Tom also closed a security bug: we documented that table ownership was
required in order to create a statistics object on it, but didn't
actually implement it.
Implement tab-completion for statistics objects. This can stand some
more improvement.
Authors: Alvaro Herrera, with lots of cleanup by Tom Lane
Discussion: https://postgr.es/m/
20170420212426[email protected]
Peter Eisentraut [Fri, 12 May 2017 17:53:24 +0000 (13:53 -0400)]
Replace another "transaction log" with "write-ahead log"
Reported-by: Dagfinn Ilmari Mannsåker <[email protected]>
Peter Eisentraut [Fri, 12 May 2017 17:51:27 +0000 (13:51 -0400)]
Standardize "WAL location" terminology
Other previously used terms were "WAL position" or "log position".
Peter Eisentraut [Fri, 12 May 2017 15:49:56 +0000 (11:49 -0400)]
Replace "transaction log" with "write-ahead log"
This makes documentation and error messages match the renaming of "xlog"
to "wal" in APIs and file naming.
Andrew Dunstan [Fri, 12 May 2017 15:11:49 +0000 (11:11 -0400)]
Honor PROVE_FLAGS environment setting
On MSVC builds and on back branches that means removing the hardcoded
--verbose setting. On master for Unix that means removing the empty
setting in the global Makefile so that the value can be acquired from
the environment as well as from the make arguments.
Backpatch to 9.4 where we introduced TAP tests
Andrew Dunstan [Fri, 12 May 2017 14:17:54 +0000 (10:17 -0400)]
Add libxml2 include path for MSVC builds
On Unix this path is detected via the use of xml2-config, but that's not
available on Windows. This means that users building with libxml2 will
no longer need to move things around from the standard libxml2
installation for MSVC builds.
Backpatch to all live branches.
Peter Eisentraut [Fri, 12 May 2017 13:15:40 +0000 (09:15 -0400)]
pg_dump: Add --no-publications option
Author: Michael Paquier <
[email protected]>
Peter Eisentraut [Fri, 12 May 2017 12:57:01 +0000 (08:57 -0400)]
Rework the options syntax for logical replication commands
For CREATE/ALTER PUBLICATION/SUBSCRIPTION, use similar option style as
other statements that use a WITH clause for options.
Author: Petr Jelinek <
[email protected]>
Pavan Deolasee [Fri, 12 May 2017 12:06:23 +0000 (17:36 +0530)]
Fix EXPLAIN ANALYZE SELECT INTO
EXPLAIN ANALYZE SELECT INTO was missing the treatment that we give to a regular
SELECT INTO or CREATE TABLE AS SELECT. This patch fixes that such that even
when EXPLAIN ANALYZE is used, we first create the target table and then insert
the selected rows.
The EXPLAIN ANALYZE will only show the plan for the final transformed INSERT
INTO statement. This is not very useful right now the EXPLAIN ANALYZE doesn't
show anything below Remote Subquery Scan, but that's a separate issue and will
be fixed in a separate patch.
The regression test's expected output is updated accordingly.
This will be backpatched to XL9_5_STABLE.
Andrew Dunstan [Fri, 12 May 2017 10:41:23 +0000 (06:41 -0400)]
Avoid tests which crash the calling process on Windows
Certain recovery tests use the Perl IPC::Run module's start/kill_kill
method of processing. On at least some versions of perl this causes the
whole process and its caller to crash. If we ever find a better way of
doing these tests they can be re-enabled on this platform. This does not
affect Mingw or Cygwin builds, which use a different perl and a
different shell and so are not affected.
Simon Riggs [Fri, 12 May 2017 09:50:56 +0000 (10:50 +0100)]
Lag tracking for logical replication
Lag tracking is called for each commit, but we introduce
a pacing delay to ensure we don't swamp the lag tracker.
Author: Petr Jelinek, with minor pacing delay code from me
Pavan Deolasee [Fri, 12 May 2017 06:20:44 +0000 (11:50 +0530)]
Accept regression diffs in copydml test case
We don't support triggers yet and hence we accept error messages regarding the
lack of support. Since triggers are not created, the corresponding NOTICEs
raised from the triggers are also not printed.
The core COPY DML functionality is covered by other cases in the test case
hence nothing additional is required.
Tom Lane [Thu, 11 May 2017 22:09:22 +0000 (18:09 -0400)]
Doc fix: scale(numeric) returns integer, not numeric.
Thinko in commit
abb173392, which introduced this function.
Report: https://postgr.es/m/
20170511215234[email protected]
Tom Lane [Thu, 11 May 2017 18:51:21 +0000 (14:51 -0400)]
Increase MAX_SYSCACHE_CALLBACKS to provide more room for extensions.
Increase from the historical value of 32 to 64. We are up to 31 callers
of CacheRegisterSyscacheCallback() in HEAD, so if they were all to be
exercised in one process that would leave only one slot for add-on modules.
It's probably not possible for that to happen, but still we clearly need
more daylight here. (At some point it might be worth making the array
dynamically resizable; but since we've never heard a complaint of "out of
syscache_callback_list slots" happening in the field, I doubt it's worth
it yet.)
Back-patch as far as 9.4, which is where we increased the companion limit
MAX_RELCACHE_CALLBACKS (cf commit
f01d1ae3a). It's not as urgent in
released branches, which have only a couple dozen call sites in core, but
it still seems that somebody might hit the limit before these branches die.
Discussion: https://postgr.es/m/12184.
1494450131@sss.pgh.pa.us
Tom Lane [Thu, 11 May 2017 15:49:59 +0000 (11:49 -0400)]
Rename WAL-related functions and views to use "lsn" not "location".
Per discussion, "location" is a rather vague term that could refer to
multiple concepts. "LSN" is an unambiguous term for WAL locations and
should be preferred. Some function names, view column names, and function
output argument names used "lsn" already, but others used "location",
as well as yet other terms such as "wal_position". Since we've already
renamed a lot of things in this area from "xlog" to "wal" for v10,
we may as well incur a bit more compatibility pain and make these names
all consistent.
David Rowley, minor additional docs hacking by me
Discussion: https://postgr.es/m/CAKJS1f8O0njDKe8ePFQ-LK5-EjwThsDws6ohJ-+c6nWK+oUxtg@mail.gmail.com
Alvaro Herrera [Wed, 10 May 2017 21:41:27 +0000 (18:41 -0300)]
Revert "Permit dump/reload of not-too-large >1GB tuples"
This reverts commits
fa2fa9955280 and
42f50cb8fa98.
While the functionality that was intended to be provided by these
commits is desired, the patch didn't actually solve as many of the
problematic situations as we hoped, and it created a bunch of its own
problems. Since we're going to require more extensive changes soon for
other reasons and users have been working around these problems for a
long time already, there is no point in spending effort in fixing this
halfway measure.
Per complaint from Tom Lane.
Discussion: https://postgr.es/m/21407.
1484606922@sss.pgh.pa.us
(Commit
fa2fa9955280 had already been reverted in branches 9.5 as
f858524ee4f and 9.6 as
e9e44a0953, so this touches master only.
Commit
42f50cb8fa98 was not present in the older branches.)
Peter Eisentraut [Wed, 10 May 2017 14:14:49 +0000 (10:14 -0400)]
psql: Add missing translation markers
Robert Haas [Wed, 10 May 2017 03:57:52 +0000 (23:57 -0400)]
Fix typo.
Thomas Munro
Discussion: http://postgr.es/m/CAEepm=3vV1YKxDfLMqq-nYM2fN+STMYLwPKFCoah4M0gxqqNNg@mail.gmail.com
Robert Haas [Wed, 10 May 2017 03:51:54 +0000 (23:51 -0400)]
Avoid theoretical infinite loop loading relcache partition key.
Amit Langote, per report from 甄明洋
Discussion: http://postgr.es/m/
57bd1e1.1886.
15bd7b79cee.Coremail.
18612389267@yeah.net
Robert Haas [Wed, 10 May 2017 03:49:20 +0000 (23:49 -0400)]
Document trigger-firing behavior for inheritance/partitioning.
Amit Langote, reviewed Thomas Munro and by me.
Discussion: http://postgr.es/m/CA+Tgmoadpcs3=mMgdyqVX7L7L_PwO_Dn5j-98a6Tj7ByBuimUQ@mail.gmail.com
Robert Haas [Wed, 10 May 2017 03:44:21 +0000 (23:44 -0400)]
Remove no-longer-needed compatibility code for hash indexes.
Because commit
ea69a0dead5128c421140dc53fac165ba4af8520 bumped the
HASH_VERSION, we don't need to worry about PostgreSQL 10 seeing
bucket pages from earlier versions.
Amit Kapila
Discussion: http://postgr.es/m/CAA4eK1LAo4DGwh+mi-G3U8Pj1WkBBeFL38xdCnUHJv1z4bZFkQ@mail.gmail.com
Robert Haas [Wed, 10 May 2017 03:40:08 +0000 (23:40 -0400)]
Fix typos in comments.
Etsuro Fujita
Discussion: http://postgr.es/m/
968d99bf-0fa8-085b-f0a1-
a379f8d661ff@lab.ntt.co.jp
Robert Haas [Wed, 10 May 2017 03:34:02 +0000 (23:34 -0400)]
Prohibit transition tables on views and foreign tables.
Thomas Munro, per off-list report from Prabhat Sabu. Changes
to the message wording for consistency with the existing
relkind check for partitioned tables by me.
Discussion: http://postgr.es/m/CAEepm=2xJFFpGM+N=gpWx-9Nft2q1oaFZX07_y23AHCrJQLt0g@mail.gmail.com
Robert Haas [Wed, 10 May 2017 03:22:39 +0000 (23:22 -0400)]
Don't permit transition tables with TRUNCATE triggers.
Prior to this prohibition, such a trigger caused a crash.
Thomas Munro, per a report from Neha Sharma. I added a
regression test.
Discussion: http://postgr.es/m/CAEepm=0VR5W-N38eTkO_FqJbGqQ_ykbBRmzmvHyxDhy1p=0Csw@mail.gmail.com
Robert Haas [Wed, 10 May 2017 03:13:21 +0000 (23:13 -0400)]
Pass EXEC_FLAG_REWIND when initializing a tuplestore scan.
Since a rescan is possible, we must be able to rewind.
Thomas Munro, per a report from Prabhat Sabu
Discussion: http://postgr.es/m/CAEepm=2=Uv5fm=exqL+ygBxaO+-tgmC=o+63H4zYAXi9HtXf1w@mail.gmail.com
Robert Haas [Wed, 10 May 2017 02:41:12 +0000 (22:41 -0400)]
Disallow finite partition bound following earlier UNBOUNDED column.
Amit Langote, per an observation by me.
Discussion: http://postgr.es/m/CA+TgmoYWnV2GMnYLG-Czsix-E1WGAbo4D+0tx7t9NdfYBDMFsA@mail.gmail.com
Peter Eisentraut [Tue, 9 May 2017 18:40:42 +0000 (14:40 -0400)]
Improve memory use in logical replication apply
Previously, the memory used by the logical replication apply worker for
processing messages would never be freed, so that could end up using a
lot of memory. To improve that, change the existing ApplyContext memory
context to ApplyMessageContext and reset that after every
message (similar to MessageContext used elsewhere). For consistency of
naming, rename the ApplyCacheContext to ApplyContext.
Author: Stas Kelvich <
[email protected]>
Alvaro Herrera [Tue, 9 May 2017 17:58:51 +0000 (14:58 -0300)]
Ignore PQcancel errors properly
Add a (void) cast to all PQcancel() calls that purposefully don't check
the return value, to keep compilers and static checkers happy.
Per Coverity.
Peter Eisentraut [Tue, 9 May 2017 14:58:06 +0000 (10:58 -0400)]
pg_dump: Add --no-subscriptions option
Author: Michael Paquier <
[email protected]>
Reviewed-by: Petr Jelinek <[email protected]>
Peter Eisentraut [Tue, 9 May 2017 14:25:26 +0000 (10:25 -0400)]
doc: Add info about replication slot management
Add some more information about managing replication slots associated
with logical replication subscriptions.
Peter Eisentraut [Tue, 9 May 2017 14:20:42 +0000 (10:20 -0400)]
Remove the NODROP SLOT option from DROP SUBSCRIPTION
It turned out this approach had problems, because a DROP command should
not have any options other than CASCADE and RESTRICT. Instead, always
attempt to drop the slot if there is one configured, but also add an
ALTER SUBSCRIPTION action to set the slot to NONE.
Author: Petr Jelinek <
[email protected]>
Reported-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/29431.
1493730652@sss.pgh.pa.us
Bruce Momjian [Tue, 9 May 2017 13:28:44 +0000 (09:28 -0400)]
pgindent: use HTTP instead of FTP to retrieve pg_bsd_indent src
FTP support will be removed from ftp.postgresql.org in months, but http
still works. Typedefs already used http.
Pavan Deolasee [Tue, 9 May 2017 07:11:56 +0000 (12:41 +0530)]
Allow COPY (INSERT RETURNING), but block COPY (SELECT INTO)
Since SELECT INTO is transformed into a CREATE TABLE AS SELECT, which then
further transformed into CREATE TABLE + INSERT INTO by XL, we must do the check
for SELECT INTO a bit differently in XL. This patch does that and as a result
also now allow COPY (INSERT RETURNING) correctly.
Backpatched to XL9_5_STABLE
Tom Lane [Mon, 8 May 2017 19:02:57 +0000 (15:02 -0400)]
Further patch rangetypes_selfuncs.c's statistics slot management.
Values in a STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM slot are float8,
not of the type of the column the statistics are for.
This bug is at least partly the fault of sloppy specification comments
for get_attstatsslot()/free_attstatsslot(): the type OID they want is that
of the stavalues entries, not of the underlying column. (I double-checked
other callers and they seem to get this right.) Adjust the comments to be
more correct.
Per buildfarm.
Security: CVE-2017-7484
Peter Eisentraut [Mon, 8 May 2017 18:01:00 +0000 (14:01 -0400)]
Check connection info string in ALTER SUBSCRIPTION
Previously it would allow an invalid connection string to be set.
Author: Petr Jelinek <
[email protected]>
Reported-by: tushar <[email protected]>
Tom Lane [Mon, 8 May 2017 16:57:27 +0000 (12:57 -0400)]
Last-minute updates for release notes.
Security: CVE-2017-7484, CVE-2017-7485, CVE-2017-7486
Peter Eisentraut [Mon, 8 May 2017 16:07:59 +0000 (12:07 -0400)]
Fix statistics reporting in logical replication workers
This new arrangement ensures that statistics are reported right after
commit of transactions. The previous arrangement didn't get this quite
right and could lead to assertion failures.
Author: Petr Jelinek <
[email protected]>
Reported-by: Erik Rijkers <[email protected]>
Tom Lane [Mon, 8 May 2017 15:18:40 +0000 (11:18 -0400)]
Fix possibly-uninitialized variable.
Oversight in
e2d4ef8de et al (my fault not Peter's). Per buildfarm.
Security: CVE-2017-7484
Noah Misch [Mon, 8 May 2017 14:24:24 +0000 (07:24 -0700)]
Match pg_user_mappings limits to information_schema.user_mapping_options.
Both views replace the umoptions field with NULL when the user does not
meet qualifications to see it. They used different qualifications, and
pg_user_mappings documented qualifications did not match its implemented
qualifications. Make its documentation and implementation match those
of user_mapping_options. One might argue for stronger qualifications,
but these have long, documented tenure. pg_user_mappings has always
exhibited this problem, so back-patch to 9.2 (all supported versions).
Michael Paquier and Feike Steenbergen. Reviewed by Jeff Janes.
Reported by Andrew Wheelwright.
Security: CVE-2017-7486
Noah Misch [Mon, 8 May 2017 14:24:24 +0000 (07:24 -0700)]
Restore PGREQUIRESSL recognition in libpq.
Commit
65c3bf19fd3e1f6a591618e92eb4c54d0b217564 moved handling of the,
already then, deprecated requiressl parameter into conninfo_storeval().
The default PGREQUIRESSL environment variable was however lost in the
change resulting in a potentially silent accept of a non-SSL connection
even when set. Its documentation remained. Restore its implementation.
Also amend the documentation to mark PGREQUIRESSL as deprecated for
those not following the link to requiressl. Back-patch to 9.3, where
commit
65c3bf1 first appeared.
Behavior has been more complex when the user provides both deprecated
and non-deprecated settings. Before commit
65c3bf1, libpq operated
according to the first of these found:
requiressl=1
PGREQUIRESSL=1
sslmode=*
PGSSLMODE=*
(Note requiressl=0 didn't override sslmode=*; it would only suppress
PGREQUIRESSL=1 or a previous requiressl=1. PGREQUIRESSL=0 had no effect
whatsoever.) Starting with commit
65c3bf1, libpq ignored PGREQUIRESSL,
and order of precedence changed to this:
last of requiressl=* or sslmode=*
PGSSLMODE=*
Starting now, adopt the following order of precedence:
last of requiressl=* or sslmode=*
PGSSLMODE=*
PGREQUIRESSL=1
This retains the
65c3bf1 behavior for connection strings that contain
both requiressl=* and sslmode=*. It retains the
65c3bf1 change that
either connection string option overrides both environment variables.
For the first time, PGSSLMODE has precedence over PGREQUIRESSL; this
avoids reducing security of "PGREQUIRESSL=1 PGSSLMODE=verify-full"
configurations originating under v9.3 and later.
Daniel Gustafsson
Security: CVE-2017-7485
Bruce Momjian [Mon, 8 May 2017 13:50:07 +0000 (09:50 -0400)]
doc: add Simon Riggs to VACUUM VERBOSE PG 10 release note item
Reported-by: Masahiko Sawada
Peter Eisentraut [Fri, 5 May 2017 16:18:48 +0000 (12:18 -0400)]
Add security checks to selectivity estimation functions
Some selectivity estimation functions run user-supplied operators over
data obtained from pg_statistic without security checks, which allows
those operators to leak pg_statistic data without having privileges on
the underlying tables. Fix by checking that one of the following is
satisfied: (1) the user has table or column privileges on the table
underlying the pg_statistic data, or (2) the function implementing the
user-supplied operator is leak-proof. If neither is satisfied, planning
will proceed as if there are no statistics available.
At least one of these is satisfied in most cases in practice. The only
situations that are negatively impacted are user-defined or
not-leak-proof operators on a security-barrier view.
Reported-by: Robert Haas <[email protected]>
Author: Peter Eisentraut <
[email protected]>
Author: Tom Lane <
[email protected]>
Security: CVE-2017-7484
Heikki Linnakangas [Mon, 8 May 2017 08:26:07 +0000 (11:26 +0300)]
Remove support for password_encryption='off' / 'plain'.
Storing passwords in plaintext hasn't been a good idea for a very long
time, if ever. Now seems like a good time to finally forbid it, since we're
messing with this in PostgreSQL 10 anyway.
Remove the CREATE/ALTER USER UNENCRYPTED PASSSWORD 'foo' syntax, since
storing passwords unencrypted is no longer supported. ENCRYPTED PASSWORD
'foo' is still accepted, but ENCRYPTED is now just a noise-word, it does
the same as just PASSWORD 'foo'.
Likewise, remove the --unencrypted option from createuser, but accept
--encrypted as a no-op for backward compatibility. AFAICS, --encrypted was
a no-op even before this patch, because createuser encrypted the password
before sending it to the server even if --encrypted was not specified. It
added the ENCRYPTED keyword to the SQL command, but since the password was
already in encrypted form, it didn't make any difference. The documentation
was not clear on whether that was intended or not, but it's moot now.
Also, while password_encryption='on' is still accepted as an alias for
'md5', it is now marked as hidden, so that it is not listed as an accepted
value in error hints, for example. That's not directly related to removing
'plain', but it seems better this way.
Reviewed by Michael Paquier
Discussion: https://www.postgresql.org/message-id/
16e9b768-fd78-0b12-cfc1-
7b6b7f238fde@iki.fi
Pavan Deolasee [Mon, 8 May 2017 08:18:41 +0000 (13:48 +0530)]
Use correct namespace while inserting rows via CTAS
We transform CREATE TABLE AS SELECT into a CREATE TABLE, followed by INSERT
INTO. But the generated INSERT INTO statement was not qualifying the table name
with schema, unless the original query has use qualified names. This results
into incorrect behaviour when tables are created in implicit schemas such
as "temporary" schemas. In passing also fix some places where we should be
quoting identifiers correctly.
Report, a test case and some initial analysis by Tomas Vondra. Patch and
further test cases by me.
Backpatched to XL9_5_STABLE
Simon Riggs [Mon, 8 May 2017 07:49:28 +0000 (08:49 +0100)]
Remove poorly worded and duplicated comment
Move line of code to avoid need for duplicated comment
Brought to attention by Masahiko Sawada
Tomas Vondra [Mon, 8 May 2017 01:16:22 +0000 (03:16 +0200)]
Fix pg_dump getTables() queries broken by
69fba376
Commit
69fba376, cherry-picked from the XL9_5_STABLE branch, broke two
of the queries in getTables(). The mistake seems fairly simple - adding
the string format in one appendPQExpBuffer() call, adding the values to
the next one.
Corrected, and gcc no longer complains about format and type mismatch.
Tomas Vondra [Sun, 7 May 2017 23:08:53 +0000 (01:08 +0200)]
Accept distributed plans in groupingsets test suite
Grouping sets were not supported by Postgres-XL so far, so all plans
are from upstream and thus missing the Remote Subquery nodes. The
changes look reasonable and produce correct results, so accept them.
Note the plans only push down the scans, not the actual grouping set
evaluation, which is still evaluated on the coordinator. That's because
PostgreSQL does not support parallel execution for grouping set paths.
If that gets added in the future, we can add that to XL quite easily.
Tom Lane [Sun, 7 May 2017 20:56:02 +0000 (16:56 -0400)]
Release notes for 9.6.3, 9.5.7, 9.4.12, 9.3.17, 9.2.21.
Tom Lane [Sun, 7 May 2017 18:43:04 +0000 (14:43 -0400)]
Third pass on 9.6.3 release notes.
Add updates for recent commits.
In passing, credit Etsuro Fujita for his work on the postgres_fdw
query cancel feature in 9.6; I seem to have missed that in the
original drafting of the 9.6 notes.
Heikki Linnakangas [Sun, 7 May 2017 16:58:21 +0000 (19:58 +0300)]
Fix memory leaks if random salt generation fails.
In the backend, this is just to silence coverity warnings, but in the
frontend, it's a genuine leak, even if extremely rare.
Spotted by Coverity, patch by Michael Paquier.
Tom Lane [Sun, 7 May 2017 16:33:12 +0000 (12:33 -0400)]
Guard against null t->tm_zone in strftime.c.
The upstream IANA code does not guard against null TM_ZONE pointers in this
function, but in our code there is such a check in the other pre-existing
use of t->tm_zone. We do have some places that set pg_tm.tm_zone to NULL.
I'm not entirely sure it's possible to reach strftime with such a value,
but I'm not sure it isn't either, so be safe.
Per Coverity complaint.
Tom Lane [Sun, 7 May 2017 15:57:41 +0000 (11:57 -0400)]
Install the "posixrules" timezone link in MSVC builds.
Somehow, we'd missed ever doing this. The consequences aren't too
severe: basically, the timezone library would fall back on its hardwired
notion of the DST transition dates to use for a POSIX-style zone name,
rather than obeying US/Eastern which is the intended behavior. The net
effect would only be to obey current US DST law further back than it
ought to apply; so it's not real surprising that nobody noticed.
David Rowley, per report from Amit Kapila
Discussion: https://postgr.es/m/CAA4eK1LC7CaNhRAQ__C3ht1JVrPzaAXXhEJRnR5L6bfYHiLmWw@mail.gmail.com
Tom Lane [Sun, 7 May 2017 15:34:31 +0000 (11:34 -0400)]
Restore fullname[] contents before falling through in pg_open_tzfile().
Fix oversight in commit
af2c5aa88: if the shortcut open() doesn't work,
we need to reset fullname[] to be just the name of the toplevel tzdata
directory before we fall through into the pre-existing code. This failed
to be exposed in my (tgl's) testing because the fall-through path is
actually never taken under normal circumstances.
David Rowley, per report from Amit Kapila
Discussion: https://postgr.es/m/CAA4eK1LC7CaNhRAQ__C3ht1JVrPzaAXXhEJRnR5L6bfYHiLmWw@mail.gmail.com
Tomas Vondra [Sun, 7 May 2017 15:25:59 +0000 (17:25 +0200)]
Resolve failures in the gin regression test suite
The failures were due to running gin_clean_pending_list() being executed
on the coordinator only. As there are no data stored on the coordinator,
the pending list is always empty, the function can't clean anything and
so just returns 0. So the condition (r>10) was always false.
Resolved by using EXECUTE DIRECTO to run the function on both datanodes.
It would be nice if we could do this automatically for such maintenance
functions, but we don't have that capability at this point. So explicit
EXECUTE DIRECT seems like the right solution.
Tomas Vondra [Sun, 7 May 2017 14:11:40 +0000 (16:11 +0200)]
Resolve failures in foreign_key regression tests
The test case is a new one from upstream, and the failure to distribute
the DELETE (after the ON DELETE rule is created) is already present in
XL 9.5, so accept that as expected behavior.
I've however slightly expanded the test case to also check that after
dropping the rule, the DELETE succeeds. That is expected, as both column
are distribution keys of the two tables.
Bruce Momjian [Sun, 7 May 2017 03:31:54 +0000 (23:31 -0400)]
doc PG 10: adjustments to BRIN, WAL, JSON, XML items, syntax
Reported-by: Alvaro Herrera
Stephen Frost [Sun, 7 May 2017 02:58:12 +0000 (22:58 -0400)]
pg_dump: Don't leak memory in buildDefaultACLCommands()
buildDefaultACLCommands() didn't destroy the string buffer created in
certain cases, leading to a memory leak. Fix by destroying the buffer
before returning from the function.
Spotted by Coverity.
Author: Michael Paquier
Back-patch to 9.6 where buildDefaultACLCommands() was added.
Stephen Frost [Sun, 7 May 2017 01:46:35 +0000 (21:46 -0400)]
RLS: Fix ALL vs. SELECT+UPDATE policy usage
When we add the SELECT-privilege based policies to the RLS with check
options (such as for an UPDATE statement, or when we have INSERT ...
RETURNING), we need to be sure and use the 'USING' case if the policy is
actually an 'ALL' policy (which could have both a USING clause and an
independent WITH CHECK clause).
This could result in policies acting differently when built using ALL
(when the ALL had both USING and WITH CHECK clauses) and when building
the policies independently as SELECT and UPDATE policies.
Fix this by adding an explicit boolean to add_with_check_options() to
indicate when the USING policy should be used, even if the policy has
both USING and WITH CHECK policies on it.
Reported by: Rod Taylor
Back-patch to 9.5 where RLS was introduced.
Andres Freund [Sun, 7 May 2017 00:03:04 +0000 (17:03 -0700)]
Fix duplicated words in comment.
Reported-By: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzn3rY2N0gTWndaApD113T+O8L6oz8cm7_F3P8y4awdoOg@mail.gmail.com
Backpatch: no, only present in master
Tomas Vondra [Sat, 6 May 2017 23:55:41 +0000 (01:55 +0200)]
Resolve failures in truncate regression test suite
The failures were caused by triggers and RESTART IDENTITY, two features
not yet supported in Postgres-XL. Instead of adding the errors messages
to expected output (which is what XL9_5_STABLE does), I have removed
the relevant blocks.
The reason is that the tests did nothing useful. The basic TRUNCATE
functionality is tested by the preceding tests, and there are other
test suites verifying that triggers are indeed still unsupported.
The RESTART IDENTITY is a bit of an exception, as it was only tested
here, so to ensure we keep returning a 'not supported' error I've added
a simple test into xl_limitations test suite.
Andres Freund [Sat, 6 May 2017 23:47:40 +0000 (16:47 -0700)]
Fix off-by-one possibly leading to skipped XLOG_RUNNING_XACTS records.
Since
6ef2eba3f57f1 ("Skip checkpoints, archiving on idle systems."),
GetLastImportantRecPtr() is used to avoid performing superfluous
checkpoints, xlog switches, running-xact records when the system is
idle. Unfortunately the check concerning running-xact records had a
off-by-one error, leading to such records being potentially skipped
when only a single record has been inserted since the last
running-xact record.
An alternative approach would have been to change
GetLastImportantRecPtr()'s definition to point to the end of records,
but that would make the checkpoint code more complicated.
Author: Andres Freund
Discussion: https://postgr.es/m/
20170505012447[email protected]
Backpatch: no, code only present in master
Tomas Vondra [Sat, 6 May 2017 21:47:28 +0000 (23:47 +0200)]
Resolve failures in json and jsonb regression tests
The failures were caused by failed distribution key updates, which also
caused differences in subsequent query results. Instead of making the
table replicated as usual, I've decided to use DISTRIBUTE RANDOMLY in
this case, because we don't have that exercised in the tests yet.
Tom Lane [Sat, 6 May 2017 20:28:20 +0000 (16:28 -0400)]
Second pass on 9.6.3 release notes.
Improve description of logical decoding snapshot issues, per suggestion
from Petr Jelinek. Mention possible need to re-sync logical replicas
as a post-upgrade task. Minor copy-editing for some other items.
Tom Lane [Sat, 6 May 2017 18:19:47 +0000 (14:19 -0400)]
Document current_role.
This system function has been there a very long time, but somehow escaped
being listed in func.sgml.
Fabien Coelho and Tom Lane
Discussion: https://postgr.es/m/alpine.DEB.2.20.
1705061027580.3896@lancre
Tom Lane [Fri, 5 May 2017 23:33:34 +0000 (19:33 -0400)]
First-draft release notes for 9.6.3.
As usual, the release notes for other branches will be made by cutting
these down, but put them up for community review first. Note there
are some entries that really only apply to pre-9.6 branches.
Tomas Vondra [Fri, 5 May 2017 18:41:58 +0000 (20:41 +0200)]
Update expected output issues in misc test suite
The expected output included output for queries that are however
commented-out in the input script. Fix that by removing the query
results and replace it with just the commands.
Tomas Vondra [Fri, 5 May 2017 18:35:04 +0000 (20:35 +0200)]
Remove unnecessary output variants for misc tests
The misc_1 and misc_2 output variants seem to be obsolete (not present
on upstream), and apparently unused, because missing output for the
last block testing multi-statement commands.
Simply remove the variants, and only keep misc.source.
Tom Lane [Fri, 5 May 2017 16:46:04 +0000 (12:46 -0400)]
Suppress compiler warning about unportable pointer value.
Setting a pointer value to "0xdeadbeef" draws a warning from some
compilers, and for good reason. Be less cute and just set it to NULL.
In passing make some other cosmetic adjustments nearby.
Discussion: https://postgr.es/m/CAJrrPGdW3EkU-CRobvVKYf3fJuBdgWyuGeAbNzAQ4yBh+bfb_Q@mail.gmail.com
Alvaro Herrera [Fri, 5 May 2017 15:05:34 +0000 (12:05 -0300)]
Allow MSVC to build with Tcl 8.6.
Commit
eaba54c20c5 added support for Tcl 8.6 for configure-supported
platforms after verifying that pltcl works without further changes, but
the MSVC tooling wasn't updated accordingly. Update MSVC to match,
restructuring the code to avoid duplicating the logic for every Tcl
version supported.
Backpatch to all live branches, like
eaba54c20c5. In 9.4 and previous,
change the patch to use backslashes rather than forward, as in the rest
of the file.
Reported by Paresh More, who also tested the patch I provided.
Discussion: https://postgr.es/m/CAAgiCNGVw3ssBtSi3ZNstrz5k00ax=UV+_ZEHUeW_LMSGL2sew@mail.gmail.com
Peter Eisentraut [Mon, 1 May 2017 19:09:06 +0000 (15:09 -0400)]
Prevent panic during shutdown checkpoint
When the checkpointer writes the shutdown checkpoint, it checks
afterwards whether any WAL has been written since it started and throws
a PANIC if so. At that point, only walsenders are still active, so one
might think this could not happen, but walsenders can also generate WAL,
for instance in BASE_BACKUP and certain variants of
CREATE_REPLICATION_SLOT. So they can trigger this panic if such a
command is run while the shutdown checkpoint is being written.
To fix this, divide the walsender shutdown into two phases. First, the
postmaster sends a SIGUSR2 signal to all walsenders. The walsenders
then put themselves into the "stopping" state. In this state, they
reject any new commands. (For simplicity, we reject all new commands,
so that in the future we do not have to track meticulously which
commands might generate WAL.) The checkpointer waits for all walsenders
to reach this state before proceeding with the shutdown checkpoint.
After the shutdown checkpoint is done, the postmaster sends
SIGINT (previously unused) to the walsenders. This triggers the
existing shutdown behavior of sending out the shutdown checkpoint record
and then terminating.
Author: Michael Paquier <
[email protected]>
Reported-by: Fujii Masao <[email protected]>
Magnus Hagander [Fri, 5 May 2017 10:42:21 +0000 (12:42 +0200)]
Fix wording in pg_upgrade docs
Author: Daniel Gustafsson
Magnus Hagander [Fri, 5 May 2017 10:08:48 +0000 (12:08 +0200)]
Build pgoutput.dll in MSVC build
Without this, logical replication obviously does not work on Windows
MauMau, with clean.bet additions from me per note from Michael Paquier
Heikki Linnakangas [Fri, 5 May 2017 07:02:13 +0000 (10:02 +0300)]
Make SCRAM salts and nonces longer.
The salt is stored base64-encoded. With the old 10 bytes raw length, it was
always padded to 16 bytes after encoding. We might as well use 12 raw bytes
for the salt, and it's still encoded into 16 bytes.
Similarly for the random nonces, use a raw length that's divisible by 3, so
that there's no padding after base64 encoding. Make the nonces longer while
we're at it. 10 bytes was probably enough to prevent replay attacks, but
there's no reason to be skimpy here.
Per suggestion from Álvaro Hernández Tortosa.
Discussion: https://www.postgresql.org/message-id/
df8c6e27-4d8e-5281-96e5-
131a4e638fc8@8kdata.com
Heikki Linnakangas [Fri, 5 May 2017 07:01:44 +0000 (10:01 +0300)]
Misc cleanup of SCRAM code.
* Remove is_scram_verifier() function. It was unused.
* Fix sanitize_char() function, used in error messages on protocol
violations, to print bytes >= 0x7F correctly.
* Change spelling of scram_MockSalt() function to be more consistent with
the surroundings.
* Change a few more references to "server proof" to "server signature" that
I missed in commit
d981074c24.
Heikki Linnakangas [Fri, 5 May 2017 07:01:41 +0000 (10:01 +0300)]
Don't use SCRAM-specific "e=invalid-proof" on invalid password.
Instead, send the same FATAL message as with other password-based
authentication mechanisms. This gives a more user-friendly message:
psql: FATAL: password authentication failed for user "test"
instead of:
psql: error received from server in SASL exchange: invalid-proof
Even before this patch, the server sent that FATAL message, after the
SCRAM-specific "e=invalid-proof" message. But libpq would stop at the
SCRAM error message, and not process the ErrorResponse that would come
after that. We could've taught libpq to check for an ErrorResponse after
failed authentication, but it's simpler to modify the server to send only
the ErrorResponse. The SCRAM specification allows for aborting the
authentication at any point, using an application-defined error mechanism,
like PostgreSQL's ErrorResponse. Using the e=invalid-proof message is
optional.
Reported by Jeff Janes.
Discussion: https://www.postgresql.org/message-id/CAMkU%3D1w3jQ53M1OeNfN8Cxd9O%
[email protected]
Pavan Deolasee [Wed, 3 May 2017 08:35:17 +0000 (14:05 +0530)]
Add a user configurable parameter to control the number of rows fetched from
the remote side during RemoteSubplan execution.
This allows us to experiment with different sizes more easily. Playing with the
fetch size also exposed couple of problems fixed in this same commit.
1. We were incorrectly forgetting a connection response combiner while
suspending a portal, leading to errors later when we try to buffer the results
because the connection must be used for other queries.
2. The remote cursor name was not getting set properly, thus datanodes
complaining about non-existent cursors.
Pavan Deolasee [Tue, 2 May 2017 09:04:11 +0000 (14:34 +0530)]
Ensure that we don't try to allocate connection in/out buffers over
MaxAllocSize.
We take this opportunity to rearrange the code to avoid duplicity in handling
in and out buffers. Also, add some other checks to ensure that we don't overrun
the limits.
Report, investigation and draft patch by Krzysztof Nienartowicz.
Pavan Deolasee [Fri, 5 May 2017 04:57:15 +0000 (10:27 +0530)]
Update expected output for guc test case missed while cherry-picking
9954d3510a85918fa2c99c20be2ab1d6d32a584b
The test case still fails, but for other outstanding issues in the merge.
Pavan Deolasee [Fri, 5 May 2017 04:50:05 +0000 (10:20 +0530)]
Adjust expected output for tsearch which got missed during cherry-picking of
6f7506edc369
There was a merge conflict because the alternate expected output file is
removed in the master branch. So fix it manually now
Tomas Vondra [Thu, 19 Jan 2017 11:45:15 +0000 (12:45 +0100)]
fix buffer overflow in gtm_serialize_pgxcnodeinfo()
Due to gtm_get_pgxcnodeinfo_size() not considering 'max_sessions'
field, gtm_serialize_pgxcnodeinfo() was writing ~4B beyond the end
of the allocated buffer. In most cases that did not overwrite any
important data, but sometimes it corrupted malloc metadata, as
reported on the mailing list by Rami Sergey.
23:
1325909760:2017-01-16 12:29:56.522 MSK -DEBUG:
gtm_get_pgxcnodeinfo_size: s_len=87, s_datalen=91
LOCATION: ProcessPGXCNodeList, register_gtm.c:391
*** Error in `/usr/local/pgsql/bin/gtm': free(): invalid next size
(fast): 0x00007fc448004c90 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fc44f0f47e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7fc44f0fce0a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fc44f10098c]
Fixed by adding 'max_sessions' to gtm_get_pgxcnodeinfo_size().
Report by Rami Sergey, fix by me.
Pavan Deolasee [Tue, 25 Apr 2017 08:05:07 +0000 (13:35 +0530)]
Fix a typo in gtmPxyExtraConfig default value
Pavan Deolasee [Tue, 25 Apr 2017 05:34:47 +0000 (11:04 +0530)]
Ensure that GTM master is added first before allowing addition of other
components.
This fixes a pgxc_ctl crash reported by Tomas, but it also makes sense because
GTM details must be added to configuration files of other components while
adding them.
In passing also fix problems while calling "clean/stop all" on non existing GTM
master.
Tomas Vondra [Sat, 19 Nov 2016 10:33:49 +0000 (11:33 +0100)]
remove pgxcpath.c and RemoteQueryPath, which are both unused
The pgxcpath.c file was not even built, so it's obviously dead code.
As it was the only place referencing RemoteQueryPath, remove that
structure too.
Tomas Vondra [Sat, 19 Nov 2016 10:23:08 +0000 (11:23 +0100)]
remove optimizer/pgxcplan.h, mostly a duplicate of pgxc/planner.h
The header defined pretty much the same structures as pgxc/planner.h,
but often with subtle differences (missing fields etc.). Furthermore,
most of the the function prototypes were not actually implemented.
Turns out, the header was only included in pgxcship.c, which only
used a single function from the header. So just remove the file and
make the function static within pgxcship.c.
Pavan Deolasee [Wed, 19 Apr 2017 14:49:32 +0000 (20:19 +0530)]
Fix non-deterministic behaviour of sequence test case added in
f8cbb7dc.
Pavan Deolasee [Tue, 18 Apr 2017 12:05:53 +0000 (17:35 +0530)]
Use already created EState while explaining FQS-ed query.
This ensures that we get details about supplied parameters correctly.
Pavan Deolasee [Tue, 18 Apr 2017 06:57:06 +0000 (12:27 +0530)]
Allow pg_dump to dump from PostgreSQL databases.
The current implementation could only dump from XL database, which is not ideal
since we then need to use pg_dump/pg_dumpall from PG installation to dump PG
database. We now check whether the remote server is running XL or PG and then
acoordingly skip XL-specific dumps.
Pavan Deolasee [Wed, 12 Apr 2017 14:07:37 +0000 (19:37 +0530)]
Handle temp sequences so that duplicate values are not produced.
We used to keep the temporary sequences on the local node and generate sequence
values locally. But when nextval is pushed down to the datanodes, each node
might end up producing the same value and thus causing duplicates. Instead we
now handle the temporary sequences on the GTM too. But instead of schema
qualifying sequence names, we use coordinator name and coordinator PID to
uniquely identify the sequence.
Report by Tomas Vondra and fixes by me.
Pavan Deolasee [Wed, 12 Apr 2017 11:53:21 +0000 (17:23 +0530)]
Add a 5s sleep in create_index test case to give cluster monitor a chance to
advance OldestXmin and vacuum can correctly detect all-visible pages.
Pavan Deolasee [Tue, 11 Apr 2017 05:55:48 +0000 (11:25 +0530)]
Adjust tsearch test case and expected output based on testing feedback.
We don't really need to add ORDER BY since the results don't come from any
distributed table. This allows us to have consistent output from the test.
Pavan Deolasee [Fri, 7 Apr 2017 05:21:33 +0000 (10:51 +0530)]
Reduce verbosity of client disconnection messages.
Per complaint from Michael Misiewicz that it may fill up the GTM/GTM-proxy log
files.
Pavan Deolasee [Thu, 6 Apr 2017 07:29:39 +0000 (12:59 +0530)]
Remove an obselete code which was stopping constraints to be modified at the
coordinator.
It was causing regression failures and making this change while fixes the
failure, it does not cause any new failures either. So it seems like a good
change. We will revisit if something gets reported because of the change.
Pavan Deolasee [Thu, 6 Apr 2017 05:34:14 +0000 (11:04 +0530)]
Support an additional syntax ANALYZE (COORDINATOR) to allow users to rebuild
coordinator side statistics without running ANALYZE again on the datanodes.
When ANALYZE (COORDINATOR) is run, we don't update planner statistics on the
datanodes. But simply gather the existing statistics and update coordinator
side view of the global stats. The command only updates statistics on the
current coordinator and to update stats on all coordintors, the command must be
executed on all coordintors separately.
Pavan Deolasee [Mon, 3 Apr 2017 17:06:19 +0000 (22:36 +0530)]
Try to validate the combiner only when a RESPONSE_COPY is received during
running COPY protocol.
We sometimes do see a 'M' message (command ID received from the remote node)
from the datanode and that breaks the combiner validation message. So we only
do that if we received a RESPONSE_COPY message during COPY IN protocol.
Pavan Deolasee [Fri, 24 Mar 2017 08:10:02 +0000 (13:40 +0530)]
Ensure that the config parameters specified in the gtmPxyExtraConfig file take
precendence over the defaults.
As reported quite a while back by Tobias Oberstein, this bug remained
unaddressed for too long. This commit should fix and ensure that the values
supplied via gtmPxyExtraConfig are honored correctly.
Pavan Deolasee [Fri, 10 Mar 2017 09:07:20 +0000 (14:37 +0530)]
Do not add a newline ('\n') between rows while running a BINARY COPY protocol.
PostgreSQL's BINARY COPY protocol does not expect a newline character between
rows. But coordinator was adding this while running the protocol between
coordinator and the datanodes. While Postgres-XL had some provision to deal
with this on the datanode side, it seemed either insufficient or buggy as
evident during tests with pglogical. So get rid of that and make the protocol
same as vanilla PG.
Pavan Deolasee [Thu, 9 Mar 2017 08:03:54 +0000 (13:33 +0530)]
Extend CommitTS properly, filling in any holes, just like ExtendCLOG.
Postgres-XL may have gaps in assigned transaction IDs, especially because not
all XIDs may be activated on a given node. So we must ensure that CommitTS is
extended properly when we see a new XID. This is same as CLOG, but we never
properly added support for CommitTS.
Pavan Deolasee [Mon, 20 Feb 2017 07:44:19 +0000 (13:14 +0530)]
Handle sequence's transactional behaviour on GTM
Previously we were tracking changes to sequences on the coordinator side and
applying those changes at transaction commit/rollback time. While this worked
ok for most cases, there were issues such as what happens if a sequence is
dropped and then recreated in the same transaction. Since the DROP is not
executed until the transaction commit time, the subsequent CREATE would fail on
the GTM.
We now track sequences renamed/dropped/created on the GTM side and do a cleanup
on transaction commit/rollback. For example, if a sequence is renamed but the
transaction is later aborted, the sequence will be renamed back to its original
name. Similarly, if a sequence is dropped and the transaction aborts, the
sequence will be re-instated.
Pavan Deolasee [Tue, 31 Jan 2017 17:29:10 +0000 (22:59 +0530)]
Handle some corner cases around empty strings in SET commands.
There are some tricky situations where a SET command may only use an empty
string ('') as a value. This lead to various problems since the value is
converted into an zero length string or even a \"\" by GUC processor, depending
on whether it appears in a quoted list GUC or a normal GUC. Sending the value
to the remote node on any of these formats is guaranteed to break things. So
for now add some band-aids to deal with these special cases.
Per report from Vivek Shukla (
[email protected])