Andrew Gierth [Tue, 24 Nov 2020 20:58:32 +0000 (20:58 +0000)]
Properly check index mark/restore in ExecSupportsMarkRestore.
Previously this code assumed that all IndexScan nodes supported
mark/restore, which is not true since it depends on optional index AM
support functions. This could lead to errors about missing support
functions in rare edge cases of mergejoins with no sort keys, where an
unordered non-btree index scan was placed on the inner path without a
protecting Materialize node. (Normally, the fact that merge join
requires ordered input would avoid this error.)
Backpatch all the way since this bug is ancient.
Per report from Eugen Konkov on irc.
Discussion: https://postgr.es/m/
[email protected]
Heikki Linnakangas [Fri, 20 Nov 2020 12:41:14 +0000 (14:41 +0200)]
Skip allocating hash table in EXPLAIN-only mode.
This is a backpatch of commit
2cccb627f1, backpatched due to popular
demand. Backpatch to all supported versions.
Author: Alexey Bashtanov
Discussion: https://www.postgresql.org/message-id/
36823f65-050d-ae24-aa4d-
a37726998240%40imap.cc
Tom Lane [Fri, 20 Nov 2020 05:58:26 +0000 (00:58 -0500)]
On macOS, use -isysroot in link steps as well as compile steps.
We previously put the -isysroot switch only into CPPFLAGS, theorizing
that it was only needed to find the right copies of include files.
However, it seems that we also need to use it while linking programs,
to find the right stub ".tbd" files for libraries. We got away
without that up to now, but apparently that was mostly luck. It may
also be that failures are only observed when the Xcode version is
noticeably out of sync with the host macOS version; the case that's
prompting action right now is that builds fail when using latest Xcode
(12.2) on macOS Catalina, even though it's fine on Big Sur.
Hence, add -isysroot to LDFLAGS as well. (It seems that the more
common practice is to put it in CFLAGS, whence it'd be included at
both compile and link steps. However, we can't mess with CFLAGS in
the platform template file without confusing configure's logic for
choosing default CFLAGS.)
Back-patch of
49407dc32 into all supported branches.
Report and patch by James Hilliard (some cosmetic mods by me)
Discussion: https://postgr.es/m/
20201120003314[email protected]
Thomas Munro [Thu, 19 Nov 2020 21:44:09 +0000 (10:44 +1300)]
Adjust DSM and DSA slot usage constants (back-patch).
1. Previously, a DSA area would create up to four segments at each size
before doubling the size. After this commit, it will create only two at
each size, so it ramps up faster and therefore needs fewer slots.
2. Previously, the total limit on DSM slots allowed for 2 per connection.
Switch to 5 per connection.
This back-patches commit
d061ea21 from release 13 into 10-12 based on a
field complaint.
Discussion: https://postgr.es/m/CAO03teA%2BjE1qt5iWDWzHqaufqBsF6EoOgZphnazps_tr_jDPZA%40mail.gmail.com
Discussion: https://postgr.es/m/CA%2BhUKGL6H2BpGbiF7Lj6QiTjTGyTLW_vLR%3DSn2tEBeTcYXiMKw%40mail.gmail.com
Tom Lane [Thu, 19 Nov 2020 20:03:17 +0000 (15:03 -0500)]
Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.
Commit
502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index. Weird as that is,
it used to work, so we ought to keep it working.
To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end. One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.
Per bug #16730 from Sofoklis Papasofokli. Like the previous patch,
back-patch to all supported branches.
Discussion: https://postgr.es/m/16730-
b902f7e6e0276b30@postgresql.org
Tom Lane [Tue, 17 Nov 2020 01:32:35 +0000 (20:32 -0500)]
Don't Insert() a VFD entry until it's fully built.
Otherwise, if FDDEBUG is enabled, the debugging output fails because
it tries to read the fileName, which isn't set up yet (and should in
fact always be NULL).
AFAICT, this has been wrong since Berkeley. Before
96bf88d52,
it would accidentally fail to crash on platforms where snprintf()
is forgiving about being passed a NULL pointer for %s; but the
file name intended to be included in the debug output wouldn't
ever have shown up.
Report and fix by Greg Nancarrow. Although this is only visibly
broken in custom-made builds, it still seems worth back-patching
to all supported branches, as the FDDEBUG code is pretty useless
as it stands.
Discussion: https://postgr.es/m/CAJcOf-cUDgm9qYtC_B6XrC6MktMPNRby2p61EtSGZKnfotMArw@mail.gmail.com
Tom Lane [Mon, 16 Nov 2020 21:39:59 +0000 (16:39 -0500)]
Do not return NULL for error cases in satisfies_hash_partition().
Since this function is used as a CHECK constraint condition,
returning NULL is tantamount to returning TRUE, which would have the
effect of letting in a row that doesn't satisfy the hash condition.
Admittedly, the cases for which this is done should be unreachable
in practice, but that doesn't make it any less a bad idea. It also
seems like a dartboard was used to decide which error cases should
throw errors as opposed to returning NULL.
For the checks for NULL input values, I just switched it to returning
false. There's some argument that an error would be better; but the
case really should be can't-happen in a generated hash constraint,
so it's likely not worth more code for.
For the parent-relation-open-failure case, it seems like we might
as well let relation_open throw an error, instead of having an
impossible-to-diagnose constraint failure.
Back-patch to v11 where this code came in.
Discussion: https://postgr.es/m/24067.
1605134819@sss.pgh.pa.us
Tom Lane [Mon, 16 Nov 2020 20:16:39 +0000 (15:16 -0500)]
Use "true" not "TRUE" in one ICU function call.
This was evidently missed in commit
6337865f3, which generally did
s/TRUE/true/ everywhere. It escaped notice up to now because ICU
versions before ICU 68 provided definitions of "TRUE" and "FALSE"
regardless. With ICU 68, it fails to compile.
Per report from Condor. Back-patch to v11 where
6337865f3 came in.
(I've not tested v10, where this call originated, but I imagine
it's fine since we defined TRUE in c.h back then.)
Discussion: https://postgr.es/m/
7a6f3336165bfe3ca66abcda7966f9d0@stz-bg.com
Bruce Momjian [Mon, 16 Nov 2020 18:13:43 +0000 (13:13 -0500)]
doc: update bgwriter description
This clarifies exactly what the bgwriter does, which should help with
tuning.
Reported-by: Chris Wilson
Discussion: https://postgr.es/m/
160399562040.7809.
7335281028960123489@wrigleys.postgresql.org
Backpatch-through: 9.5
Bruce Momjian [Mon, 16 Nov 2020 17:36:17 +0000 (12:36 -0500)]
doc: clarify how to find pg_type_d.h in the install tree
Followup to patch
152ed04799.
Reported-by: Alvaro Herrera
Discussion: https://postgr.es/m/
20201112202900[email protected]
Backpatch-through: 9.5
Bruce Momjian [Mon, 16 Nov 2020 15:26:17 +0000 (10:26 -0500)]
doc: improve wording of the need for analyze of exp. indexes
This is a followup commit on
3370207986.
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/
20201112211143[email protected]
Backpatch-through: 9.5
Alvaro Herrera [Mon, 16 Nov 2020 13:54:11 +0000 (10:54 -0300)]
Fix typo
Introduced in
90fdc259866e; backpatch to 12.
Author: Erik Rijkers
Discussion: https://postgr.es/m/e92b3fba98a0c0f7afc0a2a37e765954@xs4all.nl
Tom Lane [Sun, 15 Nov 2020 21:10:48 +0000 (16:10 -0500)]
Fix fuzzy thinking about amcanmulticol versus amcaninclude.
These flags should be independent: in particular an index AM should
be able to say that it supports include columns without necessarily
supporting multiple key columns. The included-columns patch got
this wrong, possibly aided by the fact that it didn't bother to
update the documentation.
While here, clarify some text about amcanreturn, which was a little
vague about what should happen when amcanreturn reports that only
some of the index columns are returnable.
Noted while reviewing the SP-GiST included-columns patch, which
quite incorrectly (and unsafely) changed SP-GiST to claim
amcanmulticol = true as a workaround for this bug.
Backpatch to v11 where included columns were introduced.
Tom Lane [Sat, 14 Nov 2020 18:09:53 +0000 (13:09 -0500)]
Doc: improve partitioning discussion in ddl.sgml.
This started with the intent to explain that range upper bounds
are exclusive, which previously you could only find out by reading
the CREATE TABLE man page. But I soon found that section 5.11
really could stand a fair amount of editorial attention. It's
apparently been revised several times without much concern for
overall flow, nor careful copy-editing.
Back-patch to v11, which is as far as the patch goes easily.
Per gripe from Edson Richter. Thanks to David Johnston for review.
Discussion: https://postgr.es/m/DM6PR13MB3988736CF8F5DC5720440231CFE60@DM6PR13MB3988.namprd13.prod.outlook.com
Bruce Momjian [Thu, 12 Nov 2020 20:13:01 +0000 (15:13 -0500)]
doc: clarify where to find pg_type_d.h (PG 11+) and pg_type.h
These files are in compiled directories and install directories.
Reported-by: [email protected]
Discussion: https://postgr.es/m/
160379609706.24746.
7506163279454026608@wrigleys.postgresql.org
Backpatch-through: 9.5
Bruce Momjian [Thu, 12 Nov 2020 20:00:44 +0000 (15:00 -0500)]
docs: mention that expression indexes need analyze
Expression indexes can't benefit from pre-computed statistics on
columns.
Reported-by: Nikolay Samokhvalov
Discussion: https://postgr.es/m/CANNMO++5rw9RDA=p40iMVbMNPaW6O=S0AFzTU=KpYHRpCd1voA@mail.gmail.com
Author: Nikolay Samokhvalov, modified
Backpatch-through: 9.5
Bruce Momjian [Thu, 12 Nov 2020 19:33:28 +0000 (14:33 -0500)]
doc: wire protocol data type for history file content is bytea
Document that though the history file content is marked as bytea, it is
the same a text, and neither is btyea-escaped or encoding converted.
Reported-by: Brar Piening
Discussion: https://postgr.es/m/
6a1b9cd9-17e3-df67-be55-
86102af6bdf5@gmx.de
Backpatch-through: 13 - 9.5 (not master)
Andrew Gierth [Thu, 12 Nov 2020 14:34:37 +0000 (14:34 +0000)]
pg_trgm: fix crash in 2-item picksplit
Whether from size overflow in gistSplit or from secondary splits,
picksplit is (rarely) called with exactly two items to split.
Formerly, due to special-case handling of the last item, this would
lead to access to an uninitialized cache entry; prior to PG 13 this
might have been harmless or at worst led to an incorrect union datum,
but in 13 onwards it can cause a backend crash from using an
uninitialized pointer.
Repair by removing the special case, which was deemed not to have been
appropriate anyway. Backpatch all the way, because this bug has
existed since pg_trgm was added.
Per report on IRC from user "ftzdomino". Analysis and testing by me,
patch from Alexander Korotkov.
Discussion: https://postgr.es/m/
[email protected]
Tomas Vondra [Wed, 11 Nov 2020 17:37:36 +0000 (18:37 +0100)]
Remove duplicate code in brin_memtuple_initialize
Commit
8bf74967dab moved some of the code from brin_new_memtuple to
brin_memtuple_initialize, but this resulted in some of the code being
duplicate. Fix by removing the duplicate lines and backpatch to 10.
Author: Tomas Vondra
Backpatch-through: 10
Discussion: https://postgr.es/m/
5eb50c97-9a8e-b691-8c40-
1b2a55611c4c%40enterprisedb.com
Tom Lane [Wed, 11 Nov 2020 03:51:19 +0000 (22:51 -0500)]
Fix and simplify some usages of TimestampDifference().
Introduce TimestampDifferenceMilliseconds() to simplify callers
that would rather have the difference in milliseconds, instead of
the select()-oriented seconds-and-microseconds format. This gets
rid of at least one integer division per call, and it eliminates
some apparently-easy-to-mess-up arithmetic.
Two of these call sites were in fact wrong:
* pg_prewarm's autoprewarm_main() forgot to multiply the seconds
by 1000, thus ending up with a delay 1000X shorter than intended.
That doesn't quite make it a busy-wait, but close.
* postgres_fdw's pgfdw_get_cleanup_result() thought it needed to compute
microseconds not milliseconds, thus ending up with a delay 1000X longer
than intended. Somebody along the way had noticed this problem but
misdiagnosed the cause, and imposed an ad-hoc 60-second limit rather
than fixing the units. This was relatively harmless in context, because
we don't care that much about exactly how long this delay is; still,
it's wrong.
There are a few more callers of TimestampDifference() that don't
have a direct need for seconds-and-microseconds, but can't use
TimestampDifferenceMilliseconds() either because they do need
microsecond precision or because they might possibly deal with
intervals long enough to overflow 32-bit milliseconds. It might be
worth inventing another API to improve that, but that seems outside
the scope of this patch; so those callers are untouched here.
Given the fact that we are fixing some bugs, and the likelihood
that future patches might want to back-patch code that uses this
new API, back-patch to all supported branches.
Alexey Kondratov and Tom Lane
Discussion: https://postgr.es/m/
3b1c053a21c07c1ed5e00be3b2b855ef@postgrespro.ru
Bruce Momjian [Wed, 11 Nov 2020 00:18:35 +0000 (19:18 -0500)]
doc: fix spelling "connction" to "connection"
Was wrong in commit
1a9388bd0f.
Reported-by: Tom Lane, Justin Pryzby
Discussion: https://postgr.es/m/
20201102063333[email protected]
Backpatch-through: 9.5
Tom Lane [Tue, 10 Nov 2020 23:32:36 +0000 (18:32 -0500)]
Work around cross-version-upgrade issues created by commit
9e38c2bb5.
Summarily changing the STYPE of regression-test aggregates that
depend on array_append or array_cat is an issue for the buildfarm's
cross-version-upgrade tests, because those aggregates (as defined
in the back branches) now won't load into HEAD. Although this seems
like only a minimal risk for genuine user-defined aggregates, we
need to do something for the buildfarm. Hence, adjust the aggregate
definitions, in both HEAD and the back branches.
Discussion: https://postgr.es/m/
1401824.
1604537031@sss.pgh.pa.us
Discussion: https://postgr.es/m/
[email protected]
Tom Lane [Mon, 9 Nov 2020 22:26:33 +0000 (17:26 -0500)]
Stamp 12.5.
Tom Lane [Mon, 9 Nov 2020 18:02:13 +0000 (13:02 -0500)]
Last-minute updates for release notes.
Security: CVE-2020-25694, CVE-2020-25695, CVE-2020-25696
Tom Lane [Mon, 9 Nov 2020 17:02:24 +0000 (12:02 -0500)]
Doc: clarify data type behavior of COALESCE and NULLIF.
After studying the code, NULLIF is a lot more subtle than you might
have guessed.
Discussion: https://postgr.es/m/
160486028730.25500.
15740897403028593550@wrigleys.postgresql.org
Noah Misch [Mon, 9 Nov 2020 15:32:09 +0000 (07:32 -0800)]
Ignore attempts to \gset into specially treated variables.
If an interactive psql session used \gset when querying a compromised
server, the attacker could execute arbitrary code as the operating
system account running psql. Using a prefix not found among specially
treated variables, e.g. every lowercase string, precluded the attack.
Fix by issuing a warning and setting no variable for the column in
question. Users wanting the old behavior can use a prefix and then a
meta-command like "\set HISTSIZE :prefix_HISTSIZE". Back-patch to 9.5
(all supported versions).
Reviewed by Robert Haas. Reported by Nick Cleaton.
Security: CVE-2020-25696
Noah Misch [Mon, 9 Nov 2020 15:32:09 +0000 (07:32 -0800)]
In security-restricted operations, block enqueue of at-commit user code.
Specifically, this blocks DECLARE ... WITH HOLD and firing of deferred
triggers within index expressions and materialized view queries. An
attacker having permission to create non-temp objects in at least one
schema could execute arbitrary SQL functions under the identity of the
bootstrap superuser. One can work around the vulnerability by disabling
autovacuum and not manually running ANALYZE, CLUSTER, REINDEX, CREATE
INDEX, VACUUM FULL, or REFRESH MATERIALIZED VIEW. (Don't restore from
pg_dump, since it runs some of those commands.) Plain VACUUM (without
FULL) is safe, and all commands are fine when a trusted user owns the
target object. Performance may degrade quickly under this workaround,
however. Back-patch to 9.5 (all supported versions).
Reviewed by Robert Haas. Reported by Etienne Stalmans.
Security: CVE-2020-25695
Peter Eisentraut [Mon, 9 Nov 2020 11:36:44 +0000 (12:36 +0100)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
3bbbf347254dd914c5ae4b5d0bba9a1ddc28eaa0
Tom Lane [Sun, 8 Nov 2020 20:16:12 +0000 (15:16 -0500)]
Release notes for 13.1, 12.5, 11.10, 10.15, 9.6.20, 9.5.24.
Tom Lane [Sun, 8 Nov 2020 18:08:36 +0000 (13:08 -0500)]
In INSERT/UPDATE, use the table's real tuple descriptor as target.
This back-patches commit
20d3fe900 into the v12 and v13 branches.
At the time I thought that commit was not fixing any observable
bug, but Bertrand Drouvot showed otherwise: adding a dropped column
to the previously-considered scenario crashes v12 and v13, unless the
dropped column happens to be an integer. That is, of course, because
the tupdesc we derive from the plan output tlist fails to describe
the dropped column accurately, so that we'll do the wrong thing with
a tuple in which that column isn't NULL.
There is no bug in pre-v12 branches because they already did use
the table's real tuple descriptor for any trigger-returned tuple.
It seems that this set of bugs can be blamed on the changes that
removed es_trig_tuple_slot, though I've not attempted to pin that
down precisely.
Although there's no code change needed in HEAD, update the test case
to include a dropped column there too.
Discussion: https://postgr.es/m/
db5d97c8-f48a-51e2-7b08-
b73d5434d425@amazon.com
Discussion: https://postgr.es/m/16644-
5da7ef98a7ac4545@postgresql.org
Peter Eisentraut [Sat, 7 Nov 2020 21:15:52 +0000 (22:15 +0100)]
Fix redundant error messages in client tools
A few client tools duplicate error messages already provided by libpq.
Discussion: https://www.postgresql.org/message-id/flat/
3e937641-88a1-e697-612e-
99bba4b8e5e4%40enterprisedb.com
Alvaro Herrera [Sat, 7 Nov 2020 01:52:15 +0000 (22:52 -0300)]
Plug memory leak in index_get_partition
The list of indexes was being leaked when asked for an index that
doesn't have an index partition in the table partition. Not a common
case admittedly --and in most cases where it occurs, caller throws an
error anyway-- but worth fixing for cleanliness and in case any
third-party code is calling this function.
While at it, remove use of lfirst_oid() to obtain a value we already
have.
Author: Justin Pryzby
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/20201105203606[email protected]
Tomas Vondra [Fri, 6 Nov 2020 23:40:40 +0000 (00:40 +0100)]
Properly detoast data in brin_form_tuple
brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:
ERROR: missing chunk number 0 for toast value 16433 in pg_toast_16426
A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example
CREATE TABLE t (val TEXT);
INSERT INTO t VALUES ('... long value ...')
CREATE INDEX idx ON t USING brin (val);
would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:
ERROR: index row size 8712 exceeds maximum 8152 for index "idx"
because this happens before the row values are toasted.
The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.
Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/
20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/
20201104010544.zexj52mlldagzowv%40development
Tom Lane [Fri, 6 Nov 2020 21:17:57 +0000 (16:17 -0500)]
Revert "Accept relations of any kind in LOCK TABLE".
Revert
59ab4ac32, as well as the followup fix
33862cb9c, in all
branches. We need to think a bit harder about what the behavior
of LOCK TABLE on views should be, and there's no time for that
before next week's releases. We'll take another crack at this
later.
Discussion: https://postgr.es/m/16703-
e348f58aab3cf6cc@postgresql.org
Tom Lane [Fri, 6 Nov 2020 20:48:21 +0000 (15:48 -0500)]
Revert "pg_dump: Lock all relations, not just plain tables".
Revert
403a3d91c, as well as the followup fix
7f4235032, in all
branches. We need to think a bit harder about what the behavior
of LOCK TABLE on views should be, and there's no time for that
before next week's releases. We'll take another crack at this
later.
Discussion: https://postgr.es/m/16703-
e348f58aab3cf6cc@postgresql.org
Tom Lane [Thu, 5 Nov 2020 16:44:32 +0000 (11:44 -0500)]
Don't throw an error for LOCK TABLE on a self-referential view.
LOCK TABLE has complained about "infinite recursion" when applied
to a self-referential view, ever since we made it recurse into views
in v11. However, that breaks pg_dump's new assumption that it's
okay to lock every relation. There doesn't seem to be any good
reason to throw an error: if we just abandon the recursion, we've
still satisfied the requirement of locking every referenced relation.
Per bug #16703 from Andrew Bille (via Alexander Lakhin).
Discussion: https://postgr.es/m/16703-
e348f58aab3cf6cc@postgresql.org
Peter Eisentraut [Wed, 4 Nov 2020 06:47:06 +0000 (07:47 +0100)]
Enable hash partitioning of text arrays
hash_array_extended() needs to pass PG_GET_COLLATION() to the hash
function of the element type. Otherwise, the hash function of a
collation-aware data type such as text will error out, since the
introduction of nondeterministic collation made hash functions require
a collation, too.
The consequence of this is that before this change, hash partitioning
using an array over text in the partition key would not work.
Reviewed-by: Heikki Linnakangas
Reviewed-by: Tom Lane
Reviewed-by: Michael Paquier
Discussion: https://www.postgresql.org/message-id/flat/
32c1fdae-95c6-5dc6-058a-
a90330a3b621%40enterprisedb.com
Tom Lane [Tue, 3 Nov 2020 21:16:36 +0000 (16:16 -0500)]
Guard against core dump from uninitialized subplan.
If the planner erroneously puts a non-parallel-safe SubPlan into
a parallelized portion of the query tree, nodeSubplan.c will fail
in the worker processes because it finds a null in es_subplanstates,
which it's unable to cope with. It seems worth a test-and-elog to
make that an error case rather than a core dump case.
This probably should have been included in commit
16ebab688, which
was responsible for allowing nulls to appear in es_subplanstates
to begin with. So, back-patch to v10 where that came in.
Discussion: https://postgr.es/m/924226.
1604422326@sss.pgh.pa.us
Tom Lane [Tue, 3 Nov 2020 20:41:32 +0000 (15:41 -0500)]
Allow users with BYPASSRLS to alter their own passwords.
The intention in commit
491c029db was to require superuserness to
change the BYPASSRLS property, but the actual effect of the coding
in AlterRole() was to require superuserness to change anything at all
about a BYPASSRLS role. Other properties of a BYPASSRLS role should
be changeable under the same rules as for a normal role, though.
Fix that, and also take care of some documentation omissions related
to BYPASSRLS and REPLICATION role properties.
Tom Lane and Stephen Frost, per bug report from Wolfgang Walther.
Back-patch to all supported branches.
Discussion: https://postgr.es/m/
a5548a9f-89ee-3167-129d-
162b5985fcf8@technowledgy.de
Tom Lane [Tue, 3 Nov 2020 02:11:50 +0000 (21:11 -0500)]
Fix unportable use of getnameinfo() in pg_hba_file_rules view.
fill_hba_line() thought it could get away with passing sizeof(struct
sockaddr_storage) rather than the actual addrlen previously returned
by getaddrinfo(). While that appears to work on many platforms,
it does not work on FreeBSD 11: you get back a failure, which leads
to the view showing NULL for the address and netmask columns in all
rows. The POSIX spec for getnameinfo() is pretty clearly on
FreeBSD's side here: you should pass the actual address length.
So it seems plausible that there are other platforms where this
coding also fails, and we just hadn't noticed.
Also, IMO the fact that getnameinfo() failure leads to a NULL output
is pretty bogus in itself. Our pg_getnameinfo_all() wrapper is
careful to emit "???" on failure, and we should use that in such
cases. NULL should only be emitted in rows that don't have IP
addresses.
Per bug #16695 from Peter Vandivier. Back-patch to v10 where this
code was added.
Discussion: https://postgr.es/m/16695-
a665558e2f630be7@postgresql.org
Magnus Hagander [Mon, 2 Nov 2020 14:20:19 +0000 (15:20 +0100)]
Add missing comma in list of SSL versions
Michael Paquier [Mon, 2 Nov 2020 06:15:25 +0000 (15:15 +0900)]
Fix some grammar and typos in comments and docs
The documentation fixes are backpatched down to where they apply.
Author: Justin Pryzby
Discussion: https://postgr.es/m/
20201031020801[email protected]
Backpatch-through: 9.6
Michael Paquier [Mon, 2 Nov 2020 01:41:30 +0000 (10:41 +0900)]
Extend PageIsVerified() to handle more custom options
This is useful for checks of relation pages without having to load the
pages into the shared buffers, and two cases can make use of that: page
verification in base backups and the online, lock-safe, flavor.
Compatibility is kept with past versions using a routine that calls the
new extended routine with the set of options compatible with the
original version. Contrary to
d401c576, a macro cannot be used as there
may be external code relying on the presence of the original routine.
This is applied down to 11, where this will be used by a follow-up
commit addressing a set of issues with page verification in base
backups.
Extracted from a larger patch by the same author.
Author: Anastasia Lubennikova
Reviewed-by: Michael Paquier, Julien Rouhaud
Discussion: https://postgr.es/m/
608f3476-0598-2514-2c03-
e05c7d2b0cbd@postgrespro.ru
Backpatch-through: 11
Tom Lane [Sun, 1 Nov 2020 16:26:16 +0000 (11:26 -0500)]
Avoid null pointer dereference if error result lacks SQLSTATE.
Although error results received from the backend should always have
a SQLSTATE field, ones generated by libpq won't, making this code
vulnerable to a crash after, say, untimely loss of connection.
Noted by Coverity.
Oversight in commit
403a3d91c. Back-patch to 9.5, as that was.
Michael Paquier [Sun, 1 Nov 2020 12:24:15 +0000 (21:24 +0900)]
Preserve index data in pg_statistic across REINDEX CONCURRENTLY
Statistics associated to an index got lost after running REINDEX
CONCURRENTLY, while the non-concurrent case preserves these correctly.
The concurrent and non-concurrent operations need to be consistent for
the end-user, and missing statistics would force to wait for a new
analyze to happen, which could take some time depending on the activity
of the existing autovacuum workers. This issue is fixed by copying any
existing entries in pg_statistic associated to the old index to the new
one. Note that this copy is already done with the data of the index in
the stats collector.
Reported-by: Fabrízio de Royes Mello
Author: Michael Paquier, Fabrízio de Royes Mello
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/CAFcNs+qpFPmiHd1oTXvcPdvAHicJDA9qBUSujgAhUMJyUMb+SA@mail.gmail.com
Backpatch-through: 12
Noah Misch [Sat, 31 Oct 2020 15:43:28 +0000 (08:43 -0700)]
Reproduce debug_query_string==NULL on parallel workers.
Certain background workers initiate parallel queries while
debug_query_string==NULL, at which point they attempted strlen(NULL) and
died to SIGSEGV. Older debug_query_string observers allow NULL, so do
likewise in these newer ones. Back-patch to v11, where commit
7de4a1bcc56f494acbd0d6e70781df877dc8ecb5 introduced the first of these.
Discussion: https://postgr.es/m/
20201014022636[email protected]
Tom Lane [Thu, 29 Oct 2020 19:28:14 +0000 (15:28 -0400)]
Stabilize timetz test across DST transitions.
The timetz test cases I added in commit
a9632830b were unintentionally
sensitive to whether or not DST is active in the PST8PDT time zone.
Thus, they'll start failing this coming weekend, as reported by
Bernhard M. Wiedemann in bug #16689. Fortunately, DST-awareness is
not significant to the purpose of these test cases, so we can just
force them all to PDT (DST hours) to preserve stability of the
results.
Back-patch to v10, as the prior patch was.
Discussion: https://postgr.es/m/16689-
57701daa23b377bf@postgresql.org
Tom Lane [Wed, 28 Oct 2020 18:35:53 +0000 (14:35 -0400)]
Use mode "r" for popen() in psql's evaluate_backtick().
In almost all other places, we use plain "r" or "w" mode in popen()
calls (the exceptions being for COPY data). This one has been
overlooked (possibly because it's buried in a ".l" flex file?),
but it's using PG_BINARY_R.
Kensuke Okamura complained in bug #16688 that we fail to strip \r
when stripping the trailing newline from a backtick result string.
That's true enough, but we'd also fail to convert embedded \r\n
cleanly, which also seems undesirable. Fixing the popen() mode
seems like the best way to deal with this.
It's been like this for a long time, so back-patch to all supported
branches.
Discussion: https://postgr.es/m/16688-
c649c7b69cd7e6f8@postgresql.org
Tom Lane [Wed, 28 Oct 2020 17:47:02 +0000 (13:47 -0400)]
Calculate extraUpdatedCols in query rewriter, not parser.
It's unsafe to do this at parse time because addition of generated
columns to a table would not invalidate stored rules containing
UPDATEs on the table ... but there might now be dependent generated
columns that were not there when the rule was made. This also fixes
an oversight that rewriteTargetView failed to update extraUpdatedCols
when transforming an UPDATE on an updatable view. (Since the new
calculation is downstream of that, rewriteTargetView doesn't actually
need to do anything; but before, there was a demonstrable bug there.)
In v13 and HEAD, this leads to easily-visible bugs because (since
commit
c6679e4fc) we won't recalculate generated columns that aren't
listed in extraUpdatedCols. In v12 this bitmap is mostly just used
for trigger-firing decisions, so you'd only notice a problem if a
trigger cared whether a generated column had been updated.
I'd complained about this back in May, but then forgot about it
until bug #16671 from Michael Paul Killian revived the issue.
Back-patch to v12 where this field was introduced. If existing
stored rules contain any extraUpdatedCols values, they'll be
ignored because the rewriter will overwrite them, so the bug will
be fixed even for existing rules. (But note that if someone were
to update to 13.1 or 12.5, store some rules with UPDATEs on tables
having generated columns, and then downgrade to a prior minor version,
they might observe issues similar to what this patch fixes. That
seems unlikely enough to not be worth going to a lot of effort to fix.)
Discussion: https://postgr.es/m/10206.
1588964727@sss.pgh.pa.us
Discussion: https://postgr.es/m/16671-
2fa55851859fb166@postgresql.org
Tom Lane [Tue, 27 Oct 2020 19:37:13 +0000 (15:37 -0400)]
Fix use-after-free bug with event triggers and ALTER TABLE.
EventTriggerAlterTableEnd neglected to make sure that it built its
output list in the right context. In simple cases this was masked
because the function is called in PortalContext which will be
sufficiently long-lived anyway; but that doesn't make it not a bug.
Commit
ced138e8c fixed this in HEAD and v13, but mistakenly chose
not to back-patch further. Back-patch the same code change all
the way (I didn't bother with the test case though, as it would
prove nothing in pre-v13 branches).
Per report from Arseny Sher.
Original fix by Jehan-Guillaume de Rorthais.
Discussion: https://postgr.es/m/877drcyprb.fsf@ars-thinkpad
Discussion: https://postgr.es/m/
20200902193715.
6e0269d4@firost
Bruce Momjian [Tue, 27 Oct 2020 18:00:38 +0000 (14:00 -0400)]
Makefile comment: remove reference to tools/thread/thread_test
You can't compile thread_test alone anymore, and the location moved too.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/
1062278.
1603819969@sss.pgh.pa.us
Backpatch-through: 9.5
Alvaro Herrera [Tue, 27 Oct 2020 17:31:37 +0000 (14:31 -0300)]
pg_dump: Lock all relations, not just plain tables
Now that LOCK TABLE can take any relation type, acquire lock on all
relations that are to be dumped. This prevents schema changes or
deadlock errors that could cause a dump to fail after expending much
effort. The server is tested to have the capability and the feature
disabled if it doesn't, so that a patched pg_dump doesn't fail when
connecting to an unpatched server.
Backpatch to 9.5.
Author: Álvaro Herrera
Reviewed-by: Tom Lane
Reported-by: Wells Oliver
Discussion: https://postgr.es/m/20201021200659[email protected]
Alvaro Herrera [Tue, 27 Oct 2020 16:49:19 +0000 (13:49 -0300)]
Accept relations of any kind in LOCK TABLE
The restriction that only tables and views can be locked by LOCK TABLE
is quite arbitrary, since the underlying mechanism can lock any relation
type. Drop the restriction so that programs such as pg_dump can lock
all relations they're interested in, preventing schema changes that
could cause a dump to fail after expending much effort.
Backpatch to 9.5.
Author: Álvaro Herrera
Reviewed-by: Tom Lane
Reported-by: Wells Oliver
Discussion: https://postgr.es/m/20201021200659[email protected]
Bruce Momjian [Tue, 27 Oct 2020 16:43:11 +0000 (12:43 -0400)]
docs: remove reference to src/tools/thread
This directory and the ability to build the thread test independently
were removed in commit
8a2121185b.
Reported-by: [email protected]
Discussion: https://postgr.es/m/
160379609706.24746.
7506163279454026608@wrigleys.postgresql.org
Backpatch-through: 9.5
Bruce Momjian [Tue, 27 Oct 2020 02:38:11 +0000 (22:38 -0400)]
doc: simplify wording of function error affects
Reported-by: [email protected]
Discussion: https://postgr.es/m/
160324449781.693.
8298142858847611071@wrigleys.postgresql.org
Backpatch-through: 9.5
Bruce Momjian [Mon, 26 Oct 2020 23:17:05 +0000 (19:17 -0400)]
doc: make blooms docs match reality
Parallel execution changed the way bloom queries are executed, so update
the EXPLAIN output, and restructure the docs to be clearer and more
accurate.
Reported-by: Daniel Westermann
Discussion: https://postgr.es/m/ZR0P278MB0122119FAE78721A694C30C8D2340@ZR0P278MB0122.CHEP278.PROD.OUTLOOK.COM
Author: Daniel Westermann and me
Backpatch-through: 9.6
Tom Lane [Sun, 25 Oct 2020 17:57:46 +0000 (13:57 -0400)]
Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.
If the old row has any "missing" attributes that are supposed to
be retrieved from an associated tuple descriptor, the wrong things
happened because the trigger result is shoved directly into an
executor slot that lacks the missing-attribute data. Notably,
CHECK-constraint verification would incorrectly see those columns
as NULL, and so would RETURNING-list evaluation.
Band-aid around this by forcibly expanding the tuple before passing
it to the trigger function. (IMO it was a fundamental misdesign to
put the missing-attribute data into tuple constraints, which so
much of the system considers to be optional. But we're probably
stuck with that now, and will have to continue to apply band-aids
as we find other places with similar issues.)
Back-patch to v12. v11 would also have the issue, except that
commit
920311ab1 already applied a similar band-aid. That forced
expansion in more cases than seem really necessary, though, so
this isn't a directly equivalent fix.
Amit Langote, with some cosmetic changes by me
Discussion: https://postgr.es/m/16644-
5da7ef98a7ac4545@postgresql.org
David Rowley [Sun, 25 Oct 2020 09:39:00 +0000 (22:39 +1300)]
Fix incorrect parameter name in a function header comment
Author: Zhijie Hou
Discussion: https://postgr.es/m/
14cd74ea00204cc8a7ea5d738ac82cd1@G08CNEXMBPEKD05.g08.fujitsu.local
Backpatch-through: 12, where the mistake was introduced
Tom Lane [Sat, 24 Oct 2020 17:12:08 +0000 (13:12 -0400)]
Fix ancient bug in ecpg's pthread_once() emulation for Windows.
We must not set the "done" flag until after we've executed the
initialization function. Otherwise, other threads can fall through
the initial unlocked test before initialization is really complete.
This has been seen to cause rare failures of ecpg's thread/descriptor
test, and it could presumably cause other sorts of misbehavior in
threaded ECPG-using applications, since ecpglib relies on
pthread_once() in several places.
Diagnosis and patch by me, based on investigation by Alexander Lakhin.
Back-patch to all supported branches (the bug dates to 2007).
Discussion: https://postgr.es/m/16685-
d6cd241872c101d3@postgresql.org
Tom Lane [Fri, 23 Oct 2020 01:23:47 +0000 (21:23 -0400)]
Update time zone data files to tzdata release 2020d.
DST law changes in Palestine, with a whopping 120 hours' notice.
Also some historical corrections for Palestine.
Tom Lane [Fri, 23 Oct 2020 01:15:22 +0000 (21:15 -0400)]
Sync our copy of the timezone library with IANA release tzcode2020d.
There's no functional change at all here, but I'm curious to see
whether this change successfully shuts up Coverity's warning about
a useless strcmp(), which appeared with the previous update.
Discussion: http://mm.icann.org/pipermail/tz/2020-October/029370.html
Tom Lane [Wed, 21 Oct 2020 20:18:41 +0000 (16:18 -0400)]
Fix connection string handling in psql's \connect command.
psql's \connect claims to be able to re-use previous connection
parameters, but in fact it only re-uses the database name, user name,
host name (and possibly hostaddr, depending on version), and port.
This is problematic for assorted use cases. Notably, pg_dump[all]
emits "\connect databasename" commands which we would like to have
re-use all other parameters. If such a script is loaded in a psql run
that initially had "-d connstring" with some non-default parameters,
those other parameters would be lost, potentially causing connection
failure. (Thus, this is the same kind of bug addressed in commits
a45bc8a4f and
8e5793ab6, although the details are much different.)
To fix, redesign do_connect() so that it pulls out all properties
of the old PGconn using PQconninfo(), and then replaces individual
properties in that array. In the case where we don't wish to re-use
anything, get libpq's default settings using PQconndefaults() and
replace entries in that, so that we don't need different code paths
for the two cases.
This does result in an additional behavioral change for cases where
the original connection parameters allowed multiple hosts, say
"psql -h host1,host2", and the \connect request allows re-use of the
host setting. Because the previous coding relied on PQhost(), it
would only permit reconnection to the same host originally selected.
Although one can think of scenarios where that's a good thing, there
are others where it is not. Moreover, that behavior doesn't seem to
meet the principle of least surprise, nor was it documented; nor is
it even clear it was intended, since that coding long pre-dates the
addition of multi-host support to libpq. Hence, this patch is content
to drop it and re-use the host list as given.
Per Peter Eisentraut's comments on bug #16604. Back-patch to all
supported branches.
Discussion: https://postgr.es/m/16604-
933f4b8791227b15@postgresql.org
Alvaro Herrera [Wed, 21 Oct 2020 17:37:25 +0000 (14:37 -0300)]
Use fast checkpoint in PostgresNode::backup()
Should cause tests to be a bit faster
Alvaro Herrera [Tue, 20 Oct 2020 22:22:09 +0000 (19:22 -0300)]
Fix ALTER TABLE .. ENABLE/DISABLE TRIGGER recursion
More precisely, correctly handle the ONLY flag indicating not to
recurse. This was implemented in
86f575948c77 by recursing in
trigger.c, but that's the wrong place; use ATSimpleRecursion instead,
which behaves properly. However, because legacy inheritance has never
recursed in that situation, make sure to do that only for new-style
partitioning.
I noticed this problem while testing a fix for another bug in the
vicinity.
This has been wrong all along, so backpatch to 11.
Discussion: https://postgr.es/m/
20201016235925[email protected]
Peter Eisentraut [Mon, 19 Oct 2020 06:52:25 +0000 (08:52 +0200)]
Avoid invalid alloc size error in shm_mq
In shm_mq_receive(), a huge payload could trigger an unjustified
"invalid memory alloc request size" error due to the way the buffer
size is increased.
Add error checks (documenting the upper limit) and avoid the error by
limiting the allocation size to MaxAllocSize.
Author: Markus Wanner
Discussion: https://www.postgresql.org/message-id/flat/3bb363e7-ac04-0ac4-9fe8-db1148755bfa%402ndquadrant.com
Tom Lane [Mon, 19 Oct 2020 23:03:46 +0000 (19:03 -0400)]
Fix connection string handling in src/bin/scripts/ programs.
When told to process all databases, clusterdb, reindexdb, and vacuumdb
would reconnect by replacing their --maintenance-db parameter with the
name of the target database. If that parameter is a connstring (which
has been allowed for a long time, though we failed to document that
before this patch), we'd lose any other options it might specify, for
example SSL or GSS parameters, possibly resulting in failure to connect.
Thus, this is the same bug as commit
a45bc8a4f fixed in pg_dump and
pg_restore. We can fix it in the same way, by using libpq's rules for
handling multiple "dbname" parameters to add the target database name
separately. I chose to apply the same refactoring approach as in that
patch, with a struct to handle the command line parameters that need to
be passed through to connectDatabase. (Maybe someday we can unify the
very similar functions here and in pg_dump/pg_restore.)
Per Peter Eisentraut's comments on bug #16604. Back-patch to all
supported branches.
Discussion: https://postgr.es/m/16604-
933f4b8791227b15@postgresql.org
Heikki Linnakangas [Mon, 19 Oct 2020 16:28:54 +0000 (19:28 +0300)]
Misc documentation fixes.
- Misc grammar and punctuation fixes.
- Stylistic cleanup: use spaces between function arguments and JSON fields
in examples. For example "foo(a,b)" -> "foo(a, b)". Add semicolon after
last END in a few PL/pgSQL examples that were missing them.
- Make sentence that talked about "..." and ".." operators more clear,
by avoiding to end the sentence with "..". That makes it look the same
as "..."
- Fix syntax description for HAVING: HAVING conditions cannot be repeated
Patch by Justin Pryzby, per Yaroslav Schekin's report. Backpatch to all
supported versions, to the extent that the patch applies easily.
Discussion: https://www.postgresql.org/message-id/
20201005191922.GE17626%40telsasoft.com
Heikki Linnakangas [Mon, 19 Oct 2020 16:02:25 +0000 (19:02 +0300)]
Fix TRUNCATE doc: ALTER SEQUENCE RESTART is now transactional.
ALTER SEQUENCE RESTART was made transactional in commit
3d79013b97.
Backpatch to v10, where that was introduced.
Patch by Justin Pryzby, per Yaroslav Schekin's report.
Discussion: https://www.postgresql.org/message-id/
20201005191922.GE17626%40telsasoft.com
Heikki Linnakangas [Mon, 19 Oct 2020 15:50:33 +0000 (18:50 +0300)]
Fix output of tsquery example in docs.
The output for this query changed in commit
4e2477b7b8. Backport to 9.6
like that commit.
Patch by Justin Pryzby, per Yaroslav Schekin's report.
Discussion: https://www.postgresql.org/message-id/
20201005191922.GE17626%40telsasoft.com
Tom Lane [Mon, 19 Oct 2020 15:23:51 +0000 (11:23 -0400)]
In libpq for Windows, call WSAStartup once and WSACleanup not at all.
The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call. However, if that ever had actual
relevance, it wasn't in this century. Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash. Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit
4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.
libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles. We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge. It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.
However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.
Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.
While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.
Back-patch of HEAD commit
7d00a6b2d.
Discussion: https://postgr.es/m/
ac976d8c-03df-d6b8-025c-
15a2de8d9af1@postgrespro.ru
Heikki Linnakangas [Mon, 19 Oct 2020 14:58:38 +0000 (17:58 +0300)]
Fix doc for full text search distance operator.
Commit
028350f619 changed its behavior from "at most" to "exactly", but
forgot to update the documentation. Backpatch to 9.6.
Patch by Justin Pryzby, per Yaroslav Schekin's report.
Discussion: https://www.postgresql.org/message-id/
20201005191922.GE17626%40telsasoft.com
Magnus Hagander [Mon, 19 Oct 2020 11:47:09 +0000 (13:47 +0200)]
Update link for pllua
Author: Daniel Gustafsson
Discussion: https://postgr.es/m/A05874AE-8771-4C61-A24E-0B6249B8F3C2@yesql.se
David Rowley [Mon, 19 Oct 2020 11:05:41 +0000 (00:05 +1300)]
Relax some asserts in merge join costing code
In the planner, it was possible, given an extreme enough case containing a
large number of joins for the number of estimated rows to become infinite.
This could cause problems in initial_cost_mergejoin() where we perform
some calculations based on those row estimates.
A problem case, presented by Onder Kalaci showed an Assert failure from
an Assert checking outerstartsel <= outerendsel. In his test case this
was effectively NaN <= Inf, which is false. The NaN outerstartsel came
from multiplying the infinite outer_path_rows by 0.0.
In master, this problem was fixed by
a90c950fc, however, that fix was too
invasive for the backbranches. Here we just relax the Asserts to allow
them to pass. The worst that appears to happen from this is that we show
NaN cost values and infinite row estimates in EXPLAIN. add_path() would
have had a hard time doing anything useful with such costs, but that does
not really matter as if the row estimates were even close to accurate,
such plan would not complete this side of the heat death of the universe.
Reported-by: Onder Kalaci
Backpatch: 9.5 to 13
Discussion: https://postgr.es/m/DM6PR21MB1211FF360183BCA901B27F04D80B0@DM6PR21MB1211.namprd21.prod.outlook.com
Michael Paquier [Mon, 19 Oct 2020 00:37:55 +0000 (09:37 +0900)]
Fix potential memory leak in pgcrypto
When allocating a EVP context, it would have been possible to leak some
memory allocated directly by OpenSSL, that PostgreSQL lost track of if
the initialization of the context allocated failed. The cleanup can be
done with EVP_MD_CTX_destroy().
Note that EVP APIs exist since OpenSSL 0.9.7 and we have in the tree
equivalent implementations for older versions since
ce9b75d (code
removed with
9b7cd59a as of 10~). However, in 9.5 and 9.6, the existing
code makes use of EVP_MD_CTX_destroy() and EVP_MD_CTX_create() without
an equivalent implementation when building the tree with OpenSSL 0.9.6
or older, meaning that this code is in reality broken with such versions
since it got introduced in
e2838c5. As we have heard no complains about
that, it does not seem worth bothering with in 9.5 and 9.6, so I have
left that out for simplicity.
Author: Michael Paquier
Discussion: https://postgr.es/m/
20201015072212[email protected]
Backpatch-through: 9.5
Tom Lane [Sat, 17 Oct 2020 20:02:47 +0000 (16:02 -0400)]
Doc: caution against misuse of 'now' and related datetime literals.
Section 8.5.1.4, which defines these literals, made only a vague
reference to the fact that they might be evaluated too soon to be
safe in non-interactive contexts. Provide a more explicit caution
against misuse. Also, generalize the wording in the related tip in
section 9.9.4: while it clearly described this problem, it implied
(or really, stated outright) that the problem only applies to table
DEFAULT clauses.
Per gripe from Tijs van Dam. Back-patch to all supported branches.
Discussion: https://postgr.es/m/c2LuRv9BiRT3bqIo5mMQiVraEXey_25B4vUn0kDqVqilwOEu_iVF1tbtvLnyQK7yDG3PFaz_GxLLPil2SDkj1MCObNRVaac-7j1dVdFERk8=@thalex.com
Tom Lane [Sat, 17 Oct 2020 01:53:33 +0000 (21:53 -0400)]
Update time zone data files to tzdata release 2020c.
DST law changes in Morocco, Canadian Yukon, Fiji, Macquarie Island,
Casey Station (Antarctica). Historical corrections for France,
Hungary, Monaco.
Tom Lane [Sat, 17 Oct 2020 01:40:16 +0000 (21:40 -0400)]
Sync our copy of the timezone library with IANA release tzcode2020c.
This changes zic's default output format from "-b fat" to "-b slim".
We were already using "slim" in v13/HEAD, so those branches drop
the explicit -b switch in the Makefiles. Instead, add an explicit
"-b fat" in v12 and before, so that we don't change the output file
format in those branches. (This is perhaps excessively conservative,
but we decided not to do so in
a12079109, and I'll stick with that.)
Other non-cosmetic changes are to drop support for zic's long-obsolete
"-y" switch, and to ensure that strftime() does not change errno
unless it fails.
As usual with tzcode changes, back-patch to all supported branches.
Tom Lane [Fri, 16 Oct 2020 15:59:13 +0000 (11:59 -0400)]
Add missing error check in pgcrypto/crypt-md5.c.
In theory, the second px_find_digest call in px_crypt_md5 could fail
even though the first one succeeded, since resource allocation is
required. Don't skip testing for a failure. (If one did happen,
the likely result would be a crash rather than clean recovery from
an OOM failure.)
The code's been like this all along, so back-patch to all supported
branches.
Daniel Gustafsson
Discussion: https://postgr.es/m/
AA8D6FE9-4AB2-41B4-98CB-
AE64BA668C03@yesql.se
Tom Lane [Fri, 16 Oct 2020 15:36:34 +0000 (11:36 -0400)]
Doc: tweak column widths in synchronous-commit-matrix table.
Commit
a97e85f2b caused "exceed the available area" warnings in PDF
builds. Fine-tune colwidth values to avoid that.
Back-patch to 9.6, like the prior patch. (This is of dubious value
before v13, since we were far from free of such warnings in older
branches. But we might as well keep the SGML looking the same in all
branches.)
Per buildfarm.
Andres Freund [Fri, 16 Oct 2020 00:38:00 +0000 (17:38 -0700)]
llvmjit: Work around bug in LLVM 3.9 causing crashes after
72559438f92.
Unfortunately in LLVM 3.9 LLVMGetAttributeCountAtIndex(func, index)
crashes when called with an index that has 0 attributes. Since there's
no way to work around this in the C API, add a small C++ wrapper doing
so.
The only reason this didn't fail before
72559438f92 is that there
always are function attributes...
Author: Andres Freund
Discussion: https://postgr.es/m/20201016001254[email protected]
Backpatch: 11-, like 72559438f92
Bruce Momjian [Fri, 16 Oct 2020 00:37:20 +0000 (20:37 -0400)]
pg_upgrade: remove C99 compiler req. from commit
3c0471b5fd
This commit required support for inline variable definition, which is
not a requirement.
RELEASE NOTE AUTHOR: the author of commit
3c0471b5fd
(pg_upgrade/tablespaces) was Justin Pryzby, not me.
Reported-by: Andres Freund
Discussion: https://postgr.es/m/
20201016001959[email protected]
Backpatch-through: 9.5
Bruce Momjian [Thu, 15 Oct 2020 23:33:36 +0000 (19:33 -0400)]
pg_upgrade: generate check error for left-over new tablespace
Previously, if pg_upgrade failed, and the user recreated the cluster but
did not remove the new cluster tablespace directory, a later pg_upgrade
would fail since the new tablespace directory would already exists.
This adds error reporting for this during check.
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/
20200925005531[email protected]
Backpatch-through: 9.5
Andres Freund [Thu, 15 Oct 2020 20:39:41 +0000 (13:39 -0700)]
llvmjit: Also copy parameter / return value attributes from template functions.
Previously we only copied the function attributes. That caused problems at
least on s390x: Because we didn't copy the 'zeroext' attribute for
ExecAggTransReparent()'s *IsNull parameters, expressions invoking it didn't
ensure that the upper bytes of the registers were zeroed. In the - relatively
rare - cases where not, ExecAggTransReparent() wrongly ended up in the
newValueIsNull branch due to the register not being zero. Subsequently causing
a crash.
It's quite possible that this would cause problems on other platforms, and in
other places than just ExecAggTransReparent() on s390x.
Thanks to Christoph (and the Debian project) for providing me with access to a
s390x machine, allowing me to debug this.
Reported-By: Christoph Berg
Author: Andres Freund
Discussion: https://postgr.es/m/
20201015083246[email protected]
Backpatch: 11-, where JIT was added
Bruce Momjian [Thu, 15 Oct 2020 19:15:29 +0000 (15:15 -0400)]
doc: improve description of synchronous_commit modes
Previously it wasn't clear exactly what each of the synchronous_commit
modes accomplished. This clarifies that, and adds a table describing it.
Only backpatched through 9.6 since 9.5 doesn't have all the options.
Reported-by: [email protected]
Discussion: https://postgr.es/m/
159741195522.14321.
13812604195366728976@wrigleys.postgresql.org
Backpatch-through: 9.6
Tom Lane [Thu, 15 Oct 2020 16:50:57 +0000 (12:50 -0400)]
In the postmaster, rely on the signal infrastructure to block signals.
POSIX sigaction(2) can be told to block a set of signals while a
signal handler executes. Make use of that instead of manually
blocking and unblocking signals in the postmaster's signal handlers.
This should save a few cycles, but more importantly it prevents
recursive invocation of signal handlers when many signals arrive in
close succession. (Assuming that the platform's signal infrastructure
is designed to avoid consuming stack space in that case, but this is
demonstrably true at least on Linux.) The existing code has been seen
to recurse to the point of stack overflow, either in the postmaster
or in a forked-off child.
Back-patch of commit
9abb2bfc0. At the time, we'd only seen excess
postmaster stack consumption in the buildfarm; but we now have a
user report of it, and that commit has aged enough to have a fair
amount of confidence that it doesn't break anything.
This still doesn't change anything about the way that it works on
Windows. Perhaps someone else would like to fix that?
Per bug #16673 from David Geier. Back-patch to 9.6. Although
the problem exists in principle before that, we've only seen it
actually materialize in connection with heavy use of parallel
workers, so it doesn't seem necessary to do anything in 9.5;
and the relevant code is different there, too.
Discussion: https://postgr.es/m/16673-
d278c604f8e34ec0@postgresql.org
Discussion: https://postgr.es/m/14878.
1570820201@sss.pgh.pa.us
Fujii Masao [Thu, 15 Oct 2020 02:04:07 +0000 (11:04 +0900)]
doc: Mention that toast_tuple_target affects also column marked as Main.
Previously it was documented that toast_tuple_target affected column
marked as only External or Extended. But this description is not correct
and toast_tuple_target affects also column marked as Main.
Back-patch to v11 where toast_tuple_target reloption was introduced.
Author: Shinya Okano
Reviewed-by: Tatsuhito Kasahara, Fujii Masao
Discussion: https://postgr.es/m/
93f46e311a67422e89e770d236059817@oss.nttdata.com
Tom Lane [Tue, 13 Oct 2020 21:44:56 +0000 (17:44 -0400)]
Paper over regression failures in infinite_recurse() on PPC64 Linux.
Our infinite_recurse() test to verify sane stack-overrun behavior
is affected by a bug of the Linux kernel on PPC64: it will get SIGSEGV
if it receives a signal when the stack depth is (a) over 1MB and
(b) within a few kB of filling the current physical stack allocation.
See https://bugzilla.kernel.org/show_bug.cgi?id=205183.
Since this test is a bit time-consuming and we run it in parallel with
test scripts that do a lot of DDL, it can be expected to get an sinval
catchup interrupt at some point, leading to failure if the timing is
wrong. This has caused more than 100 buildfarm failures over the
past year or so.
While a fix exists for the kernel bug, it might be years before that
propagates into all production kernels, particularly in some of the
older distros we have in the buildfarm. For now, let's just back off
and not run this test on Linux PPC64; that loses nothing in test
coverage so far as our own code is concerned.
To do that, split this test into a new script infinite_recurse.sql
and skip the test when the platform name is powerpc64...-linux-gnu.
Back-patch to v12. Branches before that have not been seen to get
this failure. No doubt that's because the "errors" test was not
run in parallel with other tests before commit
798070ec0, greatly
reducing the odds of an sinval catchup being necessary.
I also back-patched
3c8553547 into v12, just so the new regression
script would look the same in all branches having it.
Discussion: https://postgr.es/m/
3479046.
1602607848@sss.pgh.pa.us
Discussion: https://postgr.es/m/
20190723162703.GM22387%40telsasoft.com
Tom Lane [Mon, 12 Oct 2020 22:01:34 +0000 (18:01 -0400)]
Fix GiST buffering build to work when there are included columns.
gistRelocateBuildBuffersOnSplit did not get the memo about which
attribute count to use. This could lead to a crash if there were
included columns and buffering build was chosen. (Because there
are random page-split decisions elsewhere in GiST index build,
the crashes are not entirely deterministic.)
Back-patch to v12 where GiST gained support for included columns.
Pavel Borisov
Discussion: https://postgr.es/m/CALT9ZEECCV5m7wvxg46PC-7x-EybUmnpupBGhSFMoAAay+r6HQ@mail.gmail.com
Tom Lane [Mon, 12 Oct 2020 17:31:24 +0000 (13:31 -0400)]
Fix memory leak when guc.c decides a setting can't be applied now.
The prohibitValueChange code paths in set_config_option(), which
are executed whenever we re-read a PGC_POSTMASTER variable from
postgresql.conf, neglected to free anything before exiting. Thus
we'd leak the proposed new value of a PGC_STRING variable, as noted
by BoChen in bug #16666. For all variable types, if the check hook
creates an "extra" chunk, we'd also leak that.
These are malloc not palloc chunks, so there is no mechanism for
recovering the leaks before process exit. Fortunately, the values
are typically not very large, meaning you'd have to go through an
awful lot of SIGHUP configuration-reload cycles to make the leakage
amount to anything. Still, for a long-lived postmaster process it
could potentially be a problem.
Oversight in commit
2594cf0e8. Back-patch to all supported branches.
Discussion: https://postgr.es/m/16666-
2c41a4eec61b03e1@postgresql.org
Tom Lane [Wed, 7 Oct 2020 22:41:39 +0000 (18:41 -0400)]
Fix optimization hazard in gram.y's makeOrderedSetArgs(), redux.
It appears that commit
cf63c641c, which intended to prevent
misoptimization of the result-building step in makeOrderedSetArgs,
didn't go far enough: buildfarm member hornet's version of xlc
is now optimizing back to the old, broken behavior in which
list_length(directargs) is fetched only after list_concat() has
changed that value. I'm not entirely convinced whether that's
an undeniable compiler bug or whether it can be justified by a
sufficiently aggressive interpretation of C sequence points.
So let's just change the code to make it harder to misinterpret.
Back-patch to all supported versions, just in case.
Discussion: https://postgr.es/m/
1830491.
1601944935@sss.pgh.pa.us
Tom Lane [Wed, 7 Oct 2020 16:50:54 +0000 (12:50 -0400)]
Rethink recent fix for pg_dump's handling of extension config tables.
Commit
3eb3d3e78 was a few bricks shy of a load: while it correctly
set the table's "interesting" flag when deciding to dump the data of
an extension config table, it was not correct to clear that flag
if we concluded we shouldn't dump the data. This led to the crash
reported in bug #16655, because in fact we'll traverse dumpTableSchema
anyway for all extension tables (to see if they have user-added
seclabels or RLS policies).
The right thing to do is to force "interesting" true in makeTableDataInfo,
and otherwise leave the flag alone. (Doing it there is more future-proof
in case additional calls are added, and it also avoids setting the flag
unnecessarily if that function decides the table is non-dumpable.)
This investigation also showed that while only the --inserts code path
had an obvious failure in the case considered by
3eb3d3e78, the COPY
code path also has a problem with not having loaded table subsidiary
data. That causes fmtCopyColumnList to silently return an empty string
instead of the correct column list. That accidentally mostly works,
which perhaps is why we didn't notice this before. It would only fail
if the restore column order is different from the dump column order,
which only happens in weird inheritance cases, so it's not surprising
nobody had hit the case with an extension config table. Nonetheless,
it's a bug, and it goes a long way back, not just to v12 where the
--inserts code path started to have a problem with this.
In hopes of catching such cases a bit sooner in future, add some
Asserts that "interesting" has been set in both dumpTableData and
dumpTableSchema. Adjust the test case added by
3eb3d3e78 so that it
checks the COPY rather than INSERT form of that bug, allowing it to
detect the longer-standing symptom.
Per bug #16655 from Cameron Daniel. Back-patch to all supported
branches.
Discussion: https://postgr.es/m/16655-
5c92d6b3a9438137@postgresql.org
Discussion: https://postgr.es/m/
18048b44-3414-b983-8c7c-
9165b177900d@2ndQuadrant.com
Bruce Momjian [Tue, 6 Oct 2020 18:31:21 +0000 (14:31 -0400)]
pg_upgrade: remove pre-8.4 code and >= 8.4 check
We only support upgrading from >= 8.4 so no need for this code or tests.
Reported-by: Magnus Hagander
Discussion: https://postgr.es/m/CABUevEx-D0PNVe00tkeQRGennZQwDtBJn=493MJt-x6sppbUxA@mail.gmail.com
Backpatch-through: 9.5
Bruce Momjian [Tue, 6 Oct 2020 16:12:09 +0000 (12:12 -0400)]
pg_upgrade; change major version comparisons to use <=, not <
This makes checking for older major versions more consistent.
Backpatch-through: 9.5
Tom Lane [Tue, 6 Oct 2020 15:43:54 +0000 (11:43 -0400)]
Build EC members for child join rels in the right memory context.
This patch prevents crashes or wrong plans when partition-wise joins
are considered during GEQO planning, as a consequence of the
EquivalenceClass data structures becoming corrupt after a GEQO
context reset.
A remaining problem is that successive GEQO cycles will make multiple
copies of the required EC members, since add_child_join_rel_equivalences
has no idea that such members might exist already. For now we'll just
live with that. The lack of field complaints of crashes suggests that
this is a mighty little-used situation.
Back-patch to v12 where this code was introduced.
Discussion: https://postgr.es/m/
1683100.
1601860653@sss.pgh.pa.us
Bruce Momjian [Mon, 5 Oct 2020 20:27:33 +0000 (16:27 -0400)]
doc: show functions returning record types and use of ROWS FROM
Previously it was unclear exactly how ROWS FROM behaved and how to cast
the data types of columns returned by FROM functions. Also document
that only non-OUT record functions can have their columns cast to data
types.
Reported-by: [email protected]
Discussion: https://postgr.es/m/
158638264419.662.
2482095087061084020@wrigleys.postgresql.org
Backpatch-through: 9.5
Bruce Momjian [Mon, 5 Oct 2020 20:07:15 +0000 (16:07 -0400)]
docs: clarify the interaction of clientcert and cert auth.
This is the first paragraph change of master-only commit
253f1025da.
Backpatch-through: PG 12-13 only
Tom Lane [Mon, 5 Oct 2020 17:15:39 +0000 (13:15 -0400)]
Fix two latent(?) bugs in equivclass.c.
get_eclass_for_sort_expr() computes expr_relids and nullable_relids
early on, even though they won't be needed unless we make a new
EquivalenceClass, which we often don't. Aside from the probably-minor
inefficiency, there's a memory management problem: these bitmapsets will
be built in the caller's context, leading to dangling pointers if that
is shorter-lived than root->planner_cxt. This would be a live bug if
get_eclass_for_sort_expr() could be called with create_it = true during
GEQO join planning. So far as I can find, the core code never does
that, but it's hard to be sure that no extensions do, especially since
the comments make it clear that that's supposed to be a supported case.
Fix by not computing these values until we've switched into planner_cxt
to build the new EquivalenceClass.
generate_join_implied_equalities() uses inner_rel->relids to look up
relevant eclasses, but it ought to be using nominal_inner_relids.
This is presently harmless because a child RelOptInfo will always have
exactly the same eclass_indexes as its topmost parent; but that might
not be true forever, and anyway it makes the code confusing.
The first of these is old (introduced by me in
f3b3b8d5b), so back-patch
to all supported branches. The second only dates to v13, but we might
as well back-patch it to keep the code looking similar across branches.
Discussion: https://postgr.es/m/
1508010.
1601832581@sss.pgh.pa.us
Tom Lane [Mon, 5 Oct 2020 00:45:06 +0000 (20:45 -0400)]
Improve stability of identity.sql regression test.
I noticed while trying to run the regression tests under a low
geqo_threshold that one query on information_schema.columns had
unstable (as in, variable from one run to the next) output order.
This is pretty unsurprising given the complexity of the underlying
plan. Interestingly, of this test's three nigh-identical queries on
information_schema.columns, the other two already had ORDER BY clauses
guaranteeing stable output. Let's make this one look the same.
Back-patch to v10 where this test was added. We've not heard field
reports of the test failing, but this experience shows that it can
happen when testing under even slightly unusual conditions.
Bruce Momjian [Sat, 3 Oct 2020 02:19:31 +0000 (22:19 -0400)]
doc: libpq connection options can override command-line flags
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/16486-
b9c93d71c02c4907@postgresql.org
Backpatch-through: 9.5
Bruce Momjian [Sat, 3 Oct 2020 01:39:33 +0000 (21:39 -0400)]
doc: clarify the use of ssh port forwarding
Reported-by: [email protected]
Discussion: https://postgr.es/m/
159854511172.24991.
4373145230066586863@wrigleys.postgresql.org
Backpatch-through: 9.5