PostgreSQL 14.1 commit log

Stamp 14.1.

commit   : 0a455b8d61d8fc5a7d1fdc152667f9ba1fd27fda    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 16:58:24 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 16:58:24 -0500    

Click here for diff

M configure
M configure.ac

Last-minute updates for release notes.

commit   : ddc6917c314ddcf16f56dd2cfd52fbc721760b07    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 14:02:16 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 14:02:16 -0500    

Click here for diff

Security: CVE-2021-23214, CVE-2021-23222  

M doc/src/sgml/release-14.sgml

libpq: reject extraneous data after SSL or GSS encryption handshake.

commit   : 30547d7913098502cdc93c06f77c3629af51b24c    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 11:14:56 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 11:14:56 -0500    

Click here for diff

libpq collects up to a bufferload of data whenever it reads data from  
the socket.  When SSL or GSS encryption is requested during startup,  
any additional data received with the server's yes-or-no reply  
remained in the buffer, and would be treated as already-decrypted data  
once the encryption handshake completed.  Thus, a man-in-the-middle  
with the ability to inject data into the TCP connection could stuff  
some cleartext data into the start of a supposedly encryption-protected  
database session.  
  
This could probably be abused to inject faked responses to the  
client's first few queries, although other details of libpq's behavior  
make that harder than it sounds.  A different line of attack is to  
exfiltrate the client's password, or other sensitive data that might  
be sent early in the session.  That has been shown to be possible with  
a server vulnerable to CVE-2021-23214.  
  
To fix, throw a protocol-violation error if the internal buffer  
is not empty after the encryption handshake.  
  
Our thanks to Jacob Champion for reporting this problem.  
  
Security: CVE-2021-23222  

M doc/src/sgml/protocol.sgml
M src/interfaces/libpq/fe-connect.c

Reject extraneous data after SSL or GSS encryption handshake.

commit   : 9d5a76b8d18d6584341f754090c3007a54215f45    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 11:01:43 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 8 Nov 2021 11:01:43 -0500    

Click here for diff

The server collects up to a bufferload of data whenever it reads data  
from the client socket.  When SSL or GSS encryption is requested  
during startup, any additional data received with the initial  
request message remained in the buffer, and would be treated as  
already-decrypted data once the encryption handshake completed.  
Thus, a man-in-the-middle with the ability to inject data into the  
TCP connection could stuff some cleartext data into the start of  
a supposedly encryption-protected database session.  
  
This could be abused to send faked SQL commands to the server,  
although that would only work if the server did not demand any  
authentication data.  (However, a server relying on SSL certificate  
authentication might well not do so.)  
  
To fix, throw a protocol-violation error if the internal buffer  
is not empty after the encryption handshake.  
  
Our thanks to Jacob Champion for reporting this problem.  
  
Security: CVE-2021-23214  

M src/backend/libpq/pqcomm.c
M src/backend/postmaster/postmaster.c
M src/include/libpq/libpq.h

Translation updates

commit   : 5a75612022703a198383f3226d35f78b6075ff30    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 8 Nov 2021 10:06:30 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 8 Nov 2021 10:06:30 +0100    

Click here for diff

Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git  
Source-Git-Hash: f54c1d7c2c97bb2a238a149e407023a9bc007b06  

M src/backend/po/de.po
M src/backend/po/es.po
M src/backend/po/fr.po
M src/backend/po/ru.po
M src/backend/po/sv.po
M src/bin/initdb/po/es.po
M src/bin/initdb/po/fr.po
M src/bin/initdb/po/sv.po
M src/bin/pg_amcheck/nls.mk
M src/bin/pg_amcheck/po/es.po
M src/bin/pg_amcheck/po/fr.po
M src/bin/pg_amcheck/po/ru.po
A src/bin/pg_amcheck/po/sv.po
M src/bin/pg_archivecleanup/po/fr.po
M src/bin/pg_archivecleanup/po/sv.po
M src/bin/pg_basebackup/po/fr.po
M src/bin/pg_basebackup/po/sv.po
M src/bin/pg_checksums/po/fr.po
M src/bin/pg_checksums/po/sv.po
M src/bin/pg_config/po/fr.po
M src/bin/pg_config/po/sv.po
M src/bin/pg_controldata/po/fr.po
M src/bin/pg_controldata/po/sv.po
M src/bin/pg_ctl/po/fr.po
M src/bin/pg_ctl/po/sv.po
M src/bin/pg_dump/po/es.po
M src/bin/pg_dump/po/fr.po
M src/bin/pg_dump/po/ru.po
M src/bin/pg_dump/po/sv.po
M src/bin/pg_resetwal/po/es.po
M src/bin/pg_resetwal/po/fr.po
M src/bin/pg_resetwal/po/sv.po
M src/bin/pg_rewind/po/fr.po
M src/bin/pg_rewind/po/ru.po
M src/bin/pg_rewind/po/sv.po
M src/bin/pg_test_fsync/po/sv.po
M src/bin/pg_test_timing/nls.mk
A src/bin/pg_test_timing/po/sv.po
M src/bin/pg_upgrade/po/es.po
M src/bin/pg_upgrade/po/fr.po
M src/bin/pg_upgrade/po/sv.po
M src/bin/pg_verifybackup/po/fr.po
M src/bin/pg_verifybackup/po/sv.po
M src/bin/pg_waldump/po/fr.po
M src/bin/pg_waldump/po/sv.po
M src/bin/psql/po/es.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ru.po
M src/bin/psql/po/sv.po
M src/bin/scripts/po/de.po
M src/bin/scripts/po/fr.po
M src/bin/scripts/po/ru.po
M src/bin/scripts/po/sv.po
M src/interfaces/ecpg/ecpglib/po/sv.po
M src/interfaces/ecpg/preproc/po/es.po
M src/interfaces/ecpg/preproc/po/fr.po
M src/interfaces/ecpg/preproc/po/sv.po
M src/interfaces/libpq/po/sv.po
M src/pl/plperl/po/sv.po
M src/pl/plpgsql/src/po/es.po
M src/pl/plpgsql/src/po/ru.po
M src/pl/plpgsql/src/po/sv.po
M src/pl/plpython/po/sv.po
M src/pl/tcl/po/sv.po

Fix incorrect hash equality operator bug in Memoize

commit   : 1f194ed6c26e67ce92437729fc46193cc6e913d2    
  
author   : David Rowley <[email protected]>    
date     : Mon, 8 Nov 2021 14:41:13 +1300    
  
committer: David Rowley <[email protected]>    
date     : Mon, 8 Nov 2021 14:41:13 +1300    

Click here for diff

In v14, because we don't have a field in RestrictInfo to cache both the  
left and right type's hash equality operator, we just restrict the scope  
of Memoize to only when the left and right types of a RestrictInfo are the  
same.  
  
In master we add another field to RestrictInfo and cache both hash  
equality operators.  
  
Reported-by: Jaime Casanova  
Author: David Rowley  
Discussion: https://postgr.es/m/20210929185544.GB24346%40ahch-to  
Backpatch-through: 14  

M src/backend/optimizer/plan/initsplan.c

Release notes for 14.1, 13.5, 12.9, 11.14, 10.19, 9.6.24.

commit   : bb003edbb7b1e8fb2ce488e2f047e5e1982b95fd    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 7 Nov 2021 14:21:50 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 7 Nov 2021 14:21:50 -0500    

Click here for diff

M doc/src/sgml/release-14.sgml

Reset lastOverflowedXid on standby when needed

commit   : b0f6bd48f35ddfe4195804eb8197f477c88da6d2    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sat, 6 Nov 2021 18:31:21 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sat, 6 Nov 2021 18:31:21 +0300    

Click here for diff

Currently, lastOverflowedXid is never reset.  It's just adjusted on new  
transactions known to be overflowed.  But if there are no overflowed  
transactions for a long time, snapshots could be mistakenly marked as  
suboverflowed due to wraparound.  
  
This commit fixes this issue by resetting lastOverflowedXid when needed  
altogether with KnownAssignedXids.  
  
Backpatch to all supported versions.  
  
Reported-by: Stan Hu  
Discussion: https://postgr.es/m/CAMBWrQ%3DFp5UAsU_nATY7EMY7NHczG4-DTDU%3DmCvBQZAQ6wa2xQ%40mail.gmail.com  
Author: Kyotaro Horiguchi, Alexander Korotkov  
Reviewed-by: Stan Hu, Simon Riggs, Nikolay Samokhvalov, Andrey Borodin, Dmitry Dolgov  

M src/backend/storage/ipc/procarray.c

Second-draft release notes for 14.1.

commit   : 01a11c77be05dd5254d0656418b544c8f1a8031c    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 6 Nov 2021 11:56:33 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 6 Nov 2021 11:56:33 -0400    

Click here for diff

Add latest commits.  Fix some typos and infelicitous wording  
(thanks to Justin Pryzby for proof-reading).  

M doc/src/sgml/release-14.sgml

Fix handling of NaN values in BRIN minmax multi

commit   : f7829feb759ef54d9adcc696fa8345e280ed423b    
  
author   : Tomas Vondra <[email protected]>    
date     : Sat, 6 Nov 2021 01:25:31 +0100    
  
committer: Tomas Vondra <[email protected]>    
date     : Sat, 6 Nov 2021 01:25:31 +0100    

Click here for diff

When calculating distance between float4/float8 values, we need to be a  
bit more careful about NaN values in order not to trigger assert. We  
consider NaN values to be equal (distace 0.0) and in infinite distance  
from all other values.  
  
On builds without asserts, this issue is mostly harmless - the ranges  
may be merged in less efficient order, but the index is still correct.  
  
Per report from Andreas Seltenreich. Backpatch to 14, where this new  
BRIN opclass was introduced.  
  
Reported-by: Andreas Seltenreich  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/brin/brin_minmax_multi.c
M src/test/regress/expected/brin_multi.out
M src/test/regress/sql/brin_multi.sql

First-draft release notes for 14.1.

commit   : 39387228c8b7043d168bada0c64e9f59e83285f5    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 5 Nov 2021 20:26:18 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 5 Nov 2021 20:26:18 -0400    

Click here for diff

As usual, the release notes for other branches will be made by cutting  
these down, but put them up for community review first.  
  
Also as usual for a .1 release, there are some entries here that  
are not really relevant for v14 because they already appeared in 14.0.  
Those'll be removed later.  

M doc/src/sgml/release-14.sgml

Avoid crash in rare case of concurrent DROP

commit   : 02e20bb2dcaa523782a8fe7de1c2ddfefaeff033    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 5 Nov 2021 12:29:35 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 5 Nov 2021 12:29:35 -0300    

Click here for diff

When a role being dropped contains is referenced by catalog objects that  
are concurrently also being dropped, a crash can result while trying to  
construct the string that describes the objects.  Suppress that by  
ignoring objects whose descriptions are returned as NULL.  
  
The majority of relevant codesites were already cautious about this  
already; we had just missed a couple.  
  
This is an old bug, so backpatch all the way back.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/dependency.c
M src/backend/catalog/pg_shdepend.c

Pipeline mode disallows multicommand strings

commit   : c829fbc3dc93d43bc499499164ac42c4edb1cb70    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 5 Nov 2021 11:40:03 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 5 Nov 2021 11:40:03 -0300    

Click here for diff

... so mention that in appropriate places of the libpq docs.  
  
Backpatch to 14.  
  
Reported-by: RekGRpth <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/libpq.sgml

Update alternative expected output file.

commit   : f4e3b62710c0eb6e952f7744c6c7e647817f687d    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Nov 2021 19:38:17 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Nov 2021 19:38:17 +0200    

Click here for diff

Previous commit added a test to 'largeobject', but neglected the  
alternative expected output file 'largeobject_1.source'. Per failure  
on buildfarm animal 'hamerkop'.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/test/regress/output/largeobject_1.source

Fix snapshot reference leak if lo_export fails.

commit   : 4ebd740cd3f3afe5523c5947be836edf8cccdc27    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Nov 2021 10:28:52 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Nov 2021 10:28:52 +0200    

Click here for diff

If lo_export() fails to open the target file or to write to it, it leaks  
the created LargeObjectDesc and its snapshot in the top-transaction  
context and resource owner. That's pretty harmless, it's a small leak  
after all, but it gives the user a "Snapshot reference leak" warning.  
  
Fix by using a short-lived memory context and no resource owner for  
transient LargeObjectDescs that are opened and closed within one function  
call. The leak is easiest to reproduce with lo_export() on a directory  
that doesn't exist, but in principle the other lo_* functions could also  
fail.  
  
Backpatch to all supported versions.  
  
Reported-by: Andrew B  
Reviewed-by: Alvaro Herrera  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/libpq/be-fsstubs.c
M src/backend/storage/large_object/inv_api.c
M src/test/regress/input/largeobject.source
M src/test/regress/output/largeobject.source

Fix parallel amvacuumcleanup safety bug.

commit   : f6162c020c880189255e77e33bde74a2b951eaae    
  
author   : Peter Geoghegan <[email protected]>    
date     : Tue, 2 Nov 2021 19:52:10 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Tue, 2 Nov 2021 19:52:10 -0700    

Click here for diff

Commit b4af70cb inverted the return value of the function  
parallel_processing_is_safe(), but missed the amvacuumcleanup test.  
Index AMs that don't support parallel cleanup at all were affected.  
  
The practical consequences of this bug were not very serious.  Hash  
indexes are affected, but since they just return the number of blocks  
during hashvacuumcleanup anyway, it can't have had much impact.  
  
Author: Masahiko Sawada <[email protected]>  
Discussion: https://postgr.es/m/CAD21AoA-Em+aeVPmBbL_s1V-ghsJQSxYL-i3JP8nTfPiD1wjKw@mail.gmail.com  
Backpatch: 14-, where commit b4af70cb appears.  

M src/backend/access/heap/vacuumlazy.c

Don't overlook indexes during parallel VACUUM.

commit   : 61a86ed55ba169044b9a692542bad1b05341147b    
  
author   : Peter Geoghegan <[email protected]>    
date     : Tue, 2 Nov 2021 12:06:16 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Tue, 2 Nov 2021 12:06:16 -0700    

Click here for diff

Commit b4af70cb, which simplified state managed by VACUUM, performed  
refactoring of parallel VACUUM in passing.  Confusion about the exact  
details of the tasks that the leader process is responsible for led to  
code that made it possible for parallel VACUUM to miss a subset of the  
table's indexes entirely.  Specifically, indexes that fell under the  
min_parallel_index_scan_size size cutoff were missed.  These indexes are  
supposed to be vacuumed by the leader (alongside any parallel unsafe  
indexes), but weren't vacuumed at all.  Affected indexes could easily  
end up with duplicate heap TIDs, once heap TIDs were recycled for new  
heap tuples.  This had generic symptoms that might be seen with almost  
any index corruption involving structural inconsistencies between an  
index and its table.  
  
To fix, make sure that the parallel VACUUM leader process performs any  
required index vacuuming for indexes that happen to be below the size  
cutoff.  Also document the design of parallel VACUUM with these  
below-size-cutoff indexes.  
  
It's unclear how many users might be affected by this bug.  There had to  
be at least three indexes on the table to hit the bug: a smaller index,  
plus at least two additional indexes that themselves exceed the size  
cutoff.  Cases with just one additional index would not run into  
trouble, since the parallel VACUUM cost model requires two  
larger-than-cutoff indexes on the table to apply any parallel  
processing.  Note also that autovacuum was not affected, since it never  
uses parallel processing.  
  
Test case based on tests from a larger patch to test parallel VACUUM by  
Masahiko Sawada.  
  
Many thanks to Kamigishi Rei for her invaluable help with tracking this  
problem down.  
  
Author: Peter Geoghegan <[email protected]>  
Author: Masahiko Sawada <[email protected]>  
Reported-By: Kamigishi Rei <[email protected]>  
Reported-By: Andrew Gierth <[email protected]>  
Diagnosed-By: Andres Freund <[email protected]>  
Bug: #17245  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 14-, where the refactoring commit appears.  

M src/backend/access/heap/vacuumlazy.c
M src/include/commands/vacuum.h
A src/test/regress/expected/vacuum_parallel.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/vacuum_parallel.sql

Fix variable lifespan in ExecInitCoerceToDomain().

commit   : 16a56774fade2da2f44f9f6d6899a8113d5725fc    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 2 Nov 2021 13:36:47 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 2 Nov 2021 13:36:47 -0400    

Click here for diff

This undoes a mistake in 1ec7679f1: domainval and domainnull were  
meant to live across loop iterations, but they were incorrectly  
moved inside the loop.  The effect was only to emit useless extra  
EEOP_MAKE_READONLY steps, so it's not a big deal; nonetheless,  
back-patch to v13 where the mistake was introduced.  
  
Ranier Vilela  
  
Discussion: https://postgr.es/m/CAEudQAqXuhbkaAp-sGH6dR6Nsq7v28_0TPexHOm6FiDYqwQD-w@mail.gmail.com  

M src/backend/executor/execExpr.c

Avoid O(N^2) behavior in SyncPostCheckpoint().

commit   : 08cfa5981e17d9daaa861520a1d41259748732b8    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 2 Nov 2021 11:31:54 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 2 Nov 2021 11:31:54 -0400    

Click here for diff

As in commits 6301c3ada and e9d9ba2a4, avoid doing repetitive  
list_delete_first() operations, since that would be expensive when  
there are many files waiting to be unlinked.  This is a slightly  
larger change than in those cases.  We have to keep the list state  
valid for calls to AbsorbSyncRequests(), so it's necessary to invent a  
"canceled" field instead of immediately deleting PendingUnlinkEntry  
entries.  Also, because we might not be able to process all the  
entries, we need a new list primitive list_delete_first_n().  
  
list_delete_first_n() is almost list_copy_tail(), but it modifies the  
input List instead of making a new copy.  I found a couple of existing  
uses of the latter that could profitably use the new function.  (There  
might be more, but the other callers look like they probably shouldn't  
overwrite the input List.)  
  
As before, back-patch to v13.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/nodes/list.c
M src/backend/optimizer/util/clauses.c
M src/backend/parser/parse_func.c
M src/backend/storage/sync/sync.c
M src/include/nodes/pg_list.h

Avoid some other O(N^2) hazards in list manipulation.

commit   : ad87bf355214c47221263825b3a541062c71aea7    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 1 Nov 2021 16:24:40 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 1 Nov 2021 16:24:40 -0400    

Click here for diff

In the same spirit as 6301c3ada, fix some more places where we were  
using list_delete_first() in a loop and thereby risking O(N^2)  
behavior.  It's not clear that the lists manipulated in these spots  
can get long enough to be really problematic ... but it's not clear  
that they can't, either, and the fixes are simple enough.  
  
As before, back-patch to v13.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_trgm/trgm_regexp.c
M src/backend/executor/nodeAgg.c
M src/backend/jit/llvm/llvmjit.c

Handle XLOG_OVERWRITE_CONTRECORD in DecodeXLogOp

commit   : 494ec0037e03854cd2c8a3e01c3c207d2886ce01    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 1 Nov 2021 13:07:23 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 1 Nov 2021 13:07:23 -0300    

Click here for diff

Failing to do so results in inability of logical decoding to process the  
WAL stream.  Handle it by doing nothing.  
  
Backpatch all the way back.  
  
Reported-by: Petr Jelínek <[email protected]>  

M src/backend/replication/logical/decode.c

Preserve opclass parameters across REINDEX CONCURRENTLY

commit   : f255de9a456531d917a7488ad9d084201dedcfd2    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 1 Nov 2021 11:40:22 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 1 Nov 2021 11:40:22 +0900    

Click here for diff

The opclass parameter Datums from the old index are fetched in the same  
way as for predicates and expressions, by grabbing them directly from  
the system catalogs.  They are then copied into the new IndexInfo that  
will be used for the creation of the new copy.  
  
This caused the new index to be rebuilt with default parameters rather  
than the ones pre-defined by a user.  The only way to get back a new  
index with correct opclass parameters would be to recreate a new index  
from scratch.  
  
The issue has been introduced by 911e702.  
  
Author: Michael Paquier  
Reviewed-by: Zhihong Yu  
Discussion: https://postgr.es/m/YX0CG/[email protected]  
Backpatch-through: 13  

M src/backend/catalog/index.c
M src/test/regress/expected/create_index.out
M src/test/regress/sql/create_index.sql

Don't try to read a multi-GB pg_stat_statements file in one call.

commit   : 7104e0b2457d1dc2d0e1c97e5053706e64a0fc50    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 31 Oct 2021 19:13:48 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 31 Oct 2021 19:13:48 -0400    

Click here for diff

Windows fails on a request to read() more than INT_MAX bytes,  
and perhaps other platforms could have similar issues.  Let's  
adjust this code to read at most 1GB per call.  
  
(One would not have thought the file could get that big, but now  
we have a field report of trouble, so it can.  We likely ought to  
add some mechanism to limit the size of the query-texts file  
separately from the size of the hash table.  That is not this  
patch, though.)  
  
Per bug #17254 from Yusuke Egashira.  It's been like this for  
awhile, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_stat_statements/pg_stat_statements.c

Avoid O(N^2) behavior when the standby process releases many locks.

commit   : 8424dfced790a5c2886ac33f9ce33eb57bf99f09    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 31 Oct 2021 15:31:29 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 31 Oct 2021 15:31:29 -0400    

Click here for diff

When replaying a transaction that held many exclusive locks on the  
primary, a standby server's startup process would expend O(N^2)  
effort on manipulating the list of locks.  This code was fine when  
written, but commit 1cff1b95a made repetitive list_delete_first()  
calls inefficient, as explained in its commit message.  Fix by just  
iterating the list normally, and releasing storage only when done.  
(This'd be inadequate if we needed to recover from an error occurring  
partway through; but we don't.)  
  
Back-patch to v13 where 1cff1b95a came in.  
  
Nathan Bossart  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/ipc/standby.c

Demote pg_unreachable() in heapam to an assertion.

commit   : bd9f4cf0ee5336ce4f9f3103521740baccfb3825    
  
author   : Peter Geoghegan <[email protected]>    
date     : Fri, 29 Oct 2021 10:53:46 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Fri, 29 Oct 2021 10:53:46 -0700    

Click here for diff

Commit d168b66682, which overhauled index deletion, added a  
pg_unreachable() to the end of a sort comparator used when sorting heap  
TIDs from an index page.  This allows the compiler to apply  
optimizations that assume that the heap TIDs from the index AM must  
always be unique.  
  
That doesn't seem like a good idea now, given recent reports of  
corruption involving duplicate TIDs in indexes on Postgres 14.  Demote  
to an assertion, just in case.  
  
Backpatch: 14-, where index deletion was overhauled.  

M src/backend/access/heap/heapam.c

Update time zone data files to tzdata release 2021e.

commit   : 0c8a40b391191793afe8f1e202765a5b71bccea5    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 29 Oct 2021 11:38:18 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 29 Oct 2021 11:38:18 -0400    

Click here for diff

DST law changes in Fiji, Jordan, Palestine, and Samoa.  Historical  
corrections for Barbados, Cook Islands, Guyana, Niue, Portugal, and  
Tonga.  
  
Also, the Pacific/Enderbury zone has been renamed to Pacific/Kanton.  
The following zones have been merged into nearby, more-populous zones  
whose clocks have agreed since 1970: Africa/Accra, America/Atikokan,  
America/Blanc-Sablon, America/Creston, America/Curacao,  
America/Nassau, America/Port_of_Spain, Antarctica/DumontDUrville,  
and Antarctica/Syowa.  

M src/timezone/data/tzdata.zi
M src/timezone/known_abbrevs.txt

Improve contrib/amcheck's tests for CREATE INDEX CONCURRENTLY.

commit   : b1f943d2aa7eba9d7f0f11d3ba66c92f814cca78    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 28 Oct 2021 11:45:14 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 28 Oct 2021 11:45:14 -0400    

Click here for diff

Commits fdd965d07 and 3cd9c3b92 tested CREATE INDEX CONCURRENTLY by  
launching two separate pgbench runs concurrently.  This was needed so  
that only a single client thread would run CREATE INDEX CONCURRENTLY,  
avoiding deadlock between two CICs.  However, there's a better way,  
which is to use an advisory lock to prevent concurrent CICs.  That's  
better in part because the test code is shorter and more readable, but  
mostly because it automatically scales things to launch an appropriate  
number of CICs relative to the number of INSERT transactions.  
As committed, typically half to three-quarters of the CIC transactions  
were pointless because the INSERT transactions had already stopped.  
  
In passing, remove background_pgbench, which was added to support  
these tests and isn't needed anymore.  We can always put it back  
if we find a use for it later.  
  
Back-patch to v12; older pgbench versions lack the  
conditional-execution features needed for this method.  
  
Tom Lane and Andrey Borodin  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/amcheck/t/002_cic.pl
M contrib/amcheck/t/003_cic_2pc.pl
M src/test/perl/PostgresNode.pm

commit   : da7d0fb159460ddb37798e91d5489c2b6da3bd0d    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 28 Oct 2021 09:26:13 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 28 Oct 2021 09:26:13 +0900    

Click here for diff

Reported-by: Anton Voloshin  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 10  

M doc/src/sgml/sepgsql.sgml

Fix ordering of items in nbtree error message.

commit   : 6cac3433965ada5ea30fdaa4911eabd0bf59cb68    
  
author   : Peter Geoghegan <[email protected]>    
date     : Wed, 27 Oct 2021 13:09:01 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Wed, 27 Oct 2021 13:09:01 -0700    

Click here for diff

Oversight in commit a5213adf.  
  
Backpatch: 13-, just like commit a5213adf.  

M src/backend/access/nbtree/nbtinsert.c

Further harden nbtree posting split code.

commit   : d078fe83d592618d9137e50306566c5a34ceb8aa    
  
author   : Peter Geoghegan <[email protected]>    
date     : Wed, 27 Oct 2021 12:10:45 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Wed, 27 Oct 2021 12:10:45 -0700    

Click here for diff

Add more defensive checks around posting list split code.  These should  
detect corruption involving duplicate table TIDs earlier and more  
reliably than any existing check.  
  
Follow up to commit 8f72bbac.  
  
Discussion: https://postgr.es/m/CAH2-WzkrSY_kjyd1_M5xJK1uM0govJXMxPn8JUSvwcUOiHuWVw@mail.gmail.com  
Backpatch: 13-, where nbtree deduplication was introduced.  

M src/backend/access/nbtree/nbtinsert.c
M src/backend/access/nbtree/nbtsearch.c

Clarify that --system reindexes system catalogs *only*

commit   : a0b6520ecfd6bd938851ec386241d2e3c689e117    
  
author   : Magnus Hagander <[email protected]>    
date     : Wed, 27 Oct 2021 16:20:02 +0200    
  
committer: Magnus Hagander <[email protected]>    
date     : Wed, 27 Oct 2021 16:20:02 +0200    

Click here for diff

Make this more clear both in the help message and docs.  
  
Reviewed-By: Michael Paquier  
Backpatch-through: 9.6  
Discussion: https://postgr.es/m/CABUevEw6Je0WUFTLhPKOk4+BoBuDrE-fKw3N4ckqgDBMFu4paA@mail.gmail.com  

M doc/src/sgml/ref/reindexdb.sgml
M src/bin/scripts/reindexdb.c

Ensure that slots are zeroed before use

commit   : 1ed1f801cdd114822a5f08409f23a7f22be0b9fb    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 26 Oct 2021 10:40:08 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 26 Oct 2021 10:40:08 +0200    

Click here for diff

The previous coding relied on the memory for the slots being zeroed  
elsewhere, which while it was true in this case is not an contract  
which is guaranteed to hold.  Explicitly clear the tts_isnull array  
to ensure that the slots are filled from a known state.  
  
Backpatch to v14 where the catalog multi-inserts were introduced.  
  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://postgr.es/m/CAJ7c6TP0AowkUgNL6zcAK-s5HYsVHVBRWfu69FRubPpfwZGM9A@mail.gmail.com  
Backpatch-through: 14  

M src/backend/catalog/heap.c
M src/backend/catalog/pg_shdepend.c

Revert "Remove unused wait events."

commit   : a6a0ae127e76da58e0396cd0f21a97066da2115b    
  
author   : Amit Kapila <[email protected]>    
date     : Tue, 26 Oct 2021 08:19:33 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Tue, 26 Oct 2021 08:19:33 +0530    

Click here for diff

This reverts commit 671eb8f34404d24c8f16ae40e94becb38afd93bb. The removed  
wait events are used by some extensions and removal of these would force a  
recompile of those extensions. We don't want that for released branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml
M src/backend/utils/activity/wait_event.c
M src/include/utils/wait_event.h

Reject huge_pages=on if shared_memory_type=sysv.

commit   : 181361a0c2fec635de10e101f683da9bddbb8178    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 26 Oct 2021 12:54:55 +1300    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 26 Oct 2021 12:54:55 +1300    

Click here for diff

It doesn't work (it could, but hasn't been implemented).  
Back-patch to 12, where shared_memory_type arrived.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Reviewed-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/config.sgml
M src/backend/port/sysv_shmem.c

Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions.

commit   : a5b9a0000e14663fd814dd51648a544fa40140a4    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 23 Oct 2021 18:36:38 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 23 Oct 2021 18:36:38 -0700    

Click here for diff

The purpose of commit 8a54e12a38d1545d249f1402f66c8cde2837d97c was to  
fix this, and it sufficed when the PREPARE TRANSACTION completed before  
the CIC looked for lock conflicts.  Otherwise, things still broke.  As  
before, in a cluster having used CIC while having enabled prepared  
transactions, queries that use the resulting index can silently fail to  
find rows.  It may be necessary to reindex to recover from past  
occurrences; REINDEX CONCURRENTLY suffices.  Fix this for future index  
builds by making CIC wait for arbitrarily-recent prepared transactions  
and for ordinary transactions that may yet PREPARE TRANSACTION.  As part  
of that, have PREPARE TRANSACTION transfer locks to its dummy PGPROC  
before it calls ProcArrayClearTransaction().  Back-patch to 9.6 (all  
supported versions).  
  
Andrey Borodin, reviewed (in earlier versions) by Andres Freund.  
  
Discussion: https://postgr.es/m/[email protected]  

A contrib/amcheck/t/003_cic_2pc.pl
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xact.c
M src/backend/storage/lmgr/lmgr.c
M src/backend/storage/lmgr/lock.c
M src/backend/utils/cache/inval.c
M src/include/access/twophase.h
M src/include/storage/lock.h

Avoid race in RelationBuildDesc() affecting CREATE INDEX CONCURRENTLY.

commit   : dde966efb286ddc222f17013a8cf4561a3b67a5e    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 23 Oct 2021 18:36:38 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 23 Oct 2021 18:36:38 -0700    

Click here for diff

CIC and REINDEX CONCURRENTLY assume backends see their catalog changes  
no later than each backend's next transaction start.  That failed to  
hold when a backend absorbed a relevant invalidation in the middle of  
running RelationBuildDesc() on the CIC index.  Queries that use the  
resulting index can silently fail to find rows.  Fix this for future  
index builds by making RelationBuildDesc() loop until it finishes  
without accepting a relevant invalidation.  It may be necessary to  
reindex to recover from past occurrences; REINDEX CONCURRENTLY suffices.  
Back-patch to 9.6 (all supported versions).  
  
Noah Misch and Andrey Borodin, reviewed (in earlier versions) by Andres  
Freund.  
  
Discussion: https://postgr.es/m/[email protected]  

A contrib/amcheck/t/002_cic.pl
M src/backend/utils/cache/inval.c
M src/backend/utils/cache/relcache.c
M src/bin/pgbench/t/001_pgbench_with_server.pl
M src/include/utils/inval.h
M src/include/utils/relcache.h
M src/test/perl/PostgresNode.pm
M src/tools/pgindent/typedefs.list

doc: Describe calculation method of streaming start for pg_receivewal

commit   : affec9f6a2dec174b333b8d4c43948af9d825b46    
  
author   : Michael Paquier <[email protected]>    
date     : Sat, 23 Oct 2021 14:43:42 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Sat, 23 Oct 2021 14:43:42 +0900    

Click here for diff

The documentation was imprecise about the starting LSN used for WAL  
streaming if nothing can be found in the local archive directory  
defined with the pg_receivewal command, so be more talkative on this  
matter.  
  
Extracted from a larger patch by the same author.  
  
Author: Ronan Dunklau, Michael Paquier  
Discussion: https://postgr.es/m/18708360.4lzOvYHigE@aivenronan  
Backpatch-through: 10  

M doc/src/sgml/ref/pg_receivewal.sgml

Fix frontend version of sh_error() in simplehash.h.

commit   : 8cee4be6dc931c74870f57a7697b031838876da4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 22 Oct 2021 16:43:38 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 22 Oct 2021 16:43:38 -0400    

Click here for diff

The code does not expect sh_error() to return, but the patch  
that made this header usable in frontend didn't get that memo.  
  
While here, plaster unlikely() on the tests that decide whether  
to invoke sh_error(), and add our standard copyright notice.  
  
Noted by Andres Freund.  Back-patch to v13 where this frontend  
support came in.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/include/lib/simplehash.h

pg_dump: fix mis-dumping of non-global default privileges.

commit   : 3ad2c2455be0bd42f1ca22907850b93c3afc575b    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 22 Oct 2021 15:22:25 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 22 Oct 2021 15:22:25 -0400    

Click here for diff

Non-global default privilege entries should be dumped as-is,  
not made relative to the default ACL for their object type.  
This would typically only matter if one had revoked some  
on-by-default privileges in a global entry, and then wanted  
to grant them again in a non-global entry.  
  
Per report from Boris Korzun.  This is an old bug, so back-patch  
to all supported branches.  
  
Neil Chen, test case by Masahiko Sawada  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAA3qoJnr2+1dVJObNtfec=qW4Z0nz=A9+r5bZKoTSy5RDjskMw@mail.gmail.com  

M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/t/002_pg_dump.pl

Add module build directory to the PATH for TAP tests

commit   : 52c0c11367fdac78a59997de2b24031c0501fbe7    
  
author   : Andrew Dunstan <[email protected]>    
date     : Fri, 22 Oct 2021 09:11:52 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Fri, 22 Oct 2021 09:11:52 -0400    

Click here for diff

For non-MSVC builds this is make's $(CURDIR), while for MSVC builds it  
is $topdir/$Config/$module. The directory is added as the second element  
in the PATH, so that the install location takes precedence, but the  
added PATH element takes precedence over the rest of the PATH.  
  
The reason for this is to allow tests to find built products that are  
not installed, such as the libpq_pipeline test driver.  
  
The libpq_pipeline test is adjusted to take advantage of this.  
  
Based on a suggestion from Andres Freund.  
  
Backpatch to release 14.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/Makefile.global.in
M src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
M src/tools/msvc/vcregress.pl

Back-patch "Add parent table name in an error in reorderbuffer.c."

commit   : 9e84f6a7213314f6f6dcb66651525d1b7eda8591    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 21 Oct 2021 09:24:59 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 21 Oct 2021 09:24:59 +0530    

Click here for diff

This was originally done in commit 5e77625b26 for 15 only, as a  
troubleshooting aid but multiple people showed interest in back-patching  
this.  
  
Author: Jeremy Schneider  
Reviewed-by: Amit Kapila  
Backpatch-through: 9.6  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/replication/logical/reorderbuffer.c

Remove unused wait events.

commit   : 671eb8f34404d24c8f16ae40e94becb38afd93bb    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 21 Oct 2021 08:07:08 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 21 Oct 2021 08:07:08 +0530    

Click here for diff

Commit 464824323e introduced the wait events which were neither used by  
that commit nor by follow-up commits for that work.  
  
Author: Masahiro Ikeda  
Backpatch-through: 14, where it was introduced  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml
M src/backend/utils/activity/wait_event.c
M src/include/utils/wait_event.h

Fix corruption of pg_shdepend when copying deps from template database

commit   : 5040c96415a062a1016e0a6b9a4dc9f26a7f356e    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 21 Oct 2021 10:39:07 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 21 Oct 2021 10:39:07 +0900    

Click here for diff

Using for a new database a template database with shared dependencies  
that need to be copied over was causing a corruption of pg_shdepend  
because of an off-by-one computation error of the index number used for  
the values inserted with a slot.  
  
Issue introduced by e3931d0.  Monitoring the rest of the code, there are  
no similar mistakes.  
  
Reported-by: Sven Klemm  
Author: Aleksander Alekseev  
Reviewed-by: Daniel Gustafsson, Michael Paquier  
Discussion: https://postgr.es/m/CAJ7c6TP0AowkUgNL6zcAK-s5HYsVHVBRWfu69FRubPpfwZGM9A@mail.gmail.com  
Backpatch-through: 14  

M src/backend/catalog/pg_shdepend.c

Protect against collation variations in test

commit   : 7182788552b7b7d7fca226af2ec281789b1abff3    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 20 Oct 2021 13:05:42 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 20 Oct 2021 13:05:42 -0300    

Click here for diff

Discussion: https://postgr.es/m/YW/[email protected]  

M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

Fix build of MSVC with OpenSSL 3.0.0

commit   : 81aefaea82934e577e9d81fcb1f809a8d75bbf5c    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 20 Oct 2021 16:48:57 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 20 Oct 2021 16:48:57 +0900    

Click here for diff

The build scripts of Visual Studio would fail to detect properly a 3.0.0  
build as the check on the second digit was failing.  This is adjusted  
where needed, allowing the builds to complete.  Note that the MSIs of  
OpenSSL mentioned in the documentation have not changed any library  
names for Win32 and Win64, making this change straight-forward.  
  
Reported-by: htalaco, via github  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.6  

M src/tools/msvc/Solution.pm

Ensure correct lock level is used in ALTER ... RENAME

commit   : 3ce3fb2f7dc66fef67c8184b96245d74372b729e    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 19 Oct 2021 19:08:45 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 19 Oct 2021 19:08:45 -0300    

Click here for diff

Commit 1b5d797cd4f7 intended to relax the lock level used to rename  
indexes, but inadvertently allowed *any* relation to be renamed with a  
lowered lock level, as long as the command is spelled ALTER INDEX.  
That's undesirable for other relation types, so retry the operation with  
the higher lock if the relation turns out not to be an index.  
  
After this fix, ALTER INDEX <sometable> RENAME will require access  
exclusive lock, which it didn't before.  
  
Author: Nathan Bossart <[email protected]>  
Author: Álvaro Herrera <[email protected]>  
Reported-by: Onder Kalaci <[email protected]>  
Discussion: https://postgr.es/m/PH0PR21MB1328189E2821CDEC646F8178D8AE9@PH0PR21MB1328.namprd21.prod.outlook.com  

M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

Adapt src/test/ldap/t/001_auth.pl to work with openldap 2.5.

commit   : 533315b68f8a00784686500f29ee780244341bc2    
  
author   : Andres Freund <[email protected]>    
date     : Tue, 19 Oct 2021 10:14:49 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Tue, 19 Oct 2021 10:14:49 -0700    

Click here for diff

ldapsearch's deprecated -h/-p arguments were removed, need to use -H now -  
which has been around for over 20 years.  
  
As perltidy insists on reflowing the parameters anyway, change order and  
"phrasing" to yield a less confusing layout (per suggestion from Tom Lane).  
  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 11-, where the tests were added.  

M src/test/ldap/t/001_auth.pl

Fix assignment to array of domain over composite.

commit   : 04dae19f4d5067b35b421dcd43175a5059747800    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 19 Oct 2021 13:54:45 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 19 Oct 2021 13:54:45 -0400    

Click here for diff

An update such as "UPDATE ... SET fld[n].subfld = whatever"  
failed if the array elements were domains rather than plain  
composites.  That's because isAssignmentIndirectionExpr()  
failed to cope with the CoerceToDomain node that would appear  
in the expression tree in this case.  The result would typically  
be a crash, and even if we accidentally didn't crash, we'd not  
correctly preserve other fields of the same array element.  
  
Per report from Onder Kalaci.  Back-patch to v11 where arrays of  
domains came in.  
  
Discussion: https://postgr.es/m/PH0PR21MB132823A46AA36F0685B7A29AD8BD9@PH0PR21MB1328.namprd21.prod.outlook.com  

M src/backend/executor/execExpr.c
M src/test/regress/expected/domain.out
M src/test/regress/sql/domain.sql

Remove bogus assertion in transformExpressionList().

commit   : f627fd547a34bb3ffba5763a1ab404c2777debe4    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 19 Oct 2021 11:35:15 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 19 Oct 2021 11:35:15 -0400    

Click here for diff

I think when I added this assertion (in commit 8f889b108), I was only  
thinking of the use of transformExpressionList at top level of INSERT  
and VALUES.  But it's also called by transformRowExpr(), which can  
certainly occur in an UPDATE targetlist, so it's inappropriate to  
suppose that p_multiassign_exprs must be empty.  Besides, since the  
input is not expected to contain ResTargets, there's no reason it  
should contain MultiAssignRefs either.  Hence this code need not  
be concerned about the state of p_multiassign_exprs, and we should  
just drop the assertion.  
  
Per bug #17236 from ocean_li_996.  It's been wrong for years,  
so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/parser/parse_target.c

Fix bug in TOC file error message printing

commit   : 3e2f32b01d3b6868022c8381b28e8fc5399baeb9    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 19 Oct 2021 12:59:54 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 19 Oct 2021 12:59:54 +0200    

Click here for diff

If the blob TOC file cannot be parsed, the error message was failing  
to print the filename as the variable holding it was shadowed by the  
destination buffer for parsing.  When the filename fails to parse,  
the error will print an empty string:  
  
 ./pg_restore -d foo -F d dump  
 pg_restore: error: invalid line in large object TOC file "": ..  
  
..instead of the intended error message:  
  
 ./pg_restore -d foo -F d dump  
 pg_restore: error: invalid line in large object TOC file "dump/blobs.toc": ..  
  
Fix by renaming both variables as the shared name was too generic to  
store either and still convey what the variable held.  
  
Backpatch all the way down to 9.6.  
  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.6  

M src/bin/pg_dump/pg_backup_directory.c

Fix sscanf limits in pg_basebackup and pg_dump

commit   : 121be6a665aaf64e0fe45b424cd26b53b384dc31    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 19 Oct 2021 12:59:50 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 19 Oct 2021 12:59:50 +0200    

Click here for diff

Make sure that the string parsing is limited by the size of the  
destination buffer.  
  
In pg_basebackup the available values sent from the server  
is limited to two characters so there was no risk of overflow.  
  
In pg_dump the buffer is bounded by MAXPGPATH, and thus the limit  
must be inserted via preprocessor expansion and the buffer increased  
by one to account for the terminator. There is no risk of overflow  
here, since in this case, the buffer scanned is smaller than the  
destination buffer.  
  
Backpatch the pg_basebackup fix to 11 where it was introduced, and  
the pg_dump fix all the way down to 9.6.  
  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 11 and 9.6  

M src/bin/pg_basebackup/streamutil.c
M src/bin/pg_dump/pg_backup_directory.c

Block ALTER INDEX/TABLE index_name ALTER COLUMN colname SET (options)

commit   : b1b797ec71a1a8cc6bb500313f4373bcb5aac1ff    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 19 Oct 2021 11:04:00 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 19 Oct 2021 11:04:00 +0900    

Click here for diff

The grammar of this command run on indexes with column names has always  
been authorized by the parser, and it has never been documented.  
  
Since 911e702, it is possible to define opclass parameters as of CREATE  
INDEX, which actually broke the old case of ALTER INDEX/TABLE where  
relation-level parameters n_distinct and n_distinct_inherited could be  
defined for an index (see 76a47c0 and its thread where this point has  
been touched, still remained unused).  Attempting to do that in v13~  
would cause the index to become unusable, as there is a new dedicated  
code path to load opclass parameters instead of the relation-level ones  
previously available.  Note that it is possible to fix things with a  
manual catalog update to bring the relation back online.  
  
This commit disables this command for now as the use of column names for  
indexes does not make sense anyway, particularly when it comes to index  
expressions where names are automatically computed.  One way to properly  
support this case properly in the future would be to use column numbers  
when it comes to indexes, in the same way as ALTER INDEX .. ALTER COLUMN  
.. SET STATISTICS.  
  
Partitioned indexes were already blocked, but not indexes.  Some tests  
are added for both cases.  
  
There was some code in ANALYZE to enforce n_distinct to be used for an  
index expression if the parameter was defined, but just remove it for  
now until/if there is support for this (note that index-level parameters  
never had support in pg_dump either, previously), so this was just dead  
code.  
  
Reported-by: Matthijs van der Vleuten  
Author: Nathan Bossart, Michael Paquier  
Reviewed-by: Vik Fearing, Dilip Kumar  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 13  

M src/backend/commands/analyze.c
M src/backend/commands/tablecmds.c
M src/test/regress/expected/btree_index.out
M src/test/regress/sql/btree_index.sql

Invalidate partitions of table being attached/detached

commit   : 72d0642172571be7b44d54728deb609d7285d9d0    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 18 Oct 2021 19:08:25 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 18 Oct 2021 19:08:25 -0300    

Click here for diff

Failing to do that, any direct inserts/updates of those partitions  
would fail to enforce the correct constraint, that is, one that  
considers the new partition constraint of their parent table.  
  
Backpatch to 10.  
  
Reported by: Hou Zhijie <[email protected]>  
Author: Amit Langote <[email protected]>  
Author: Álvaro Herrera <[email protected]>  
Reviewed-by: Nitin Jadhav <[email protected]>  
Reviewed-by: Pavel Borisov <[email protected]>  
  
Discussion: https://postgr.es/m/OS3PR01MB5718DA1C4609A25186D1FBF194089%40OS3PR01MB5718.jpnprd01.prod.outlook.com  

M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

Reset properly snapshot export state during transaction abort

commit   : 5b353aaff69c6099aebd45f1a63cb38b9a7ef75c    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 18 Oct 2021 11:56:48 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 18 Oct 2021 11:56:48 +0900    

Click here for diff

During a replication slot creation, an ERROR generated in the same  
transaction as the one creating a to-be-exported snapshot would have  
left the backend in an inconsistent state, as the associated static  
export snapshot state was not being reset on transaction abort, but only  
on the follow-up command received by the WAL sender that created this  
snapshot on replication slot creation.  This would trigger inconsistency  
failures if this session tried to export again a snapshot, like during  
the creation of a replication slot.  
  
Note that a snapshot export cannot happen in a transaction block, so  
there is no need to worry resetting this state for subtransaction  
aborts.  Also, this inconsistent state would very unlikely show up to  
users.  For example, one case where this could happen is an  
out-of-memory error when building the initial snapshot to-be-exported.  
Dilip found this problem while poking at a different patch, that caused  
an error in this code path for reasons unrelated to HEAD.  
  
Author: Dilip Kumar  
Reviewed-by: Michael Paquier, Zhihong Yu  
Discussion: https://postgr.es/m/CAFiTN-s0zA1Kj0ozGHwkYkHwa5U0zUE94RSc_g81WrpcETB5=w@mail.gmail.com  
Backpatch-through: 9.6  

M src/backend/access/transam/xact.c
M src/backend/replication/logical/snapbuild.c
M src/include/replication/snapbuild.h

Avoid core dump in pg_dump when dumping from pre-8.3 server.

commit   : 3e4c8db931e1a9b760b22382f7c9e0e28e732a2c    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 16 Oct 2021 15:02:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 16 Oct 2021 15:02:55 -0400    

Click here for diff

Commit f0e21f2f6 missed adding a tgisinternal output column  
to getTriggers' query for pre-8.3 servers.  Back-patch to v11,  
like that commit.  

M src/bin/pg_dump/pg_dump.c

Make pg_dump acquire lock on partitioned tables that are to be dumped.

commit   : b5152e3ba688e7023f0e5f1a1b82b77bedadaafa    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 16 Oct 2021 12:23:57 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 16 Oct 2021 12:23:57 -0400    

Click here for diff

It was clearly the intent to do so all along, but the original coding  
fat-fingered this by checking the wrong array element.  We fixed it  
in passing in 403a3d91c, but that later got reverted, and we forgot  
to keep this bug fix.  
  
Most of the time this'd be relatively harmless, since once we lock  
any of the partitioned table's leaf partitions, that would suffice  
to prevent major DDL on the partitioned table itself.  However, a  
childless partitioned table would get dumped with no relevant lock  
whatsoever, possibly allowing dump failure or inconsistent output.  
  
Unlike 403a3d91c, there are no versioning concerns, since every server  
version that has partitioned tables will allow you to lock one.  
  
Back-patch to v10 where partitioned tables were introduced.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/pg_dump.c

Fix PostgresNode install_path sanity tests that fail on Windows

commit   : c697d8a39b9001281aa62249afb01d4ab5e63703    
  
author   : Andrew Dunstan <[email protected]>    
date     : Fri, 15 Oct 2021 12:56:29 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Fri, 15 Oct 2021 12:56:29 -0400    

Click here for diff

Backpatch to 14 where install_path was introduced.  

M src/test/perl/PostgresNode.pm

Remove unstable pg_amcheck tests.

commit   : 5863115e4cb16bd905ed78a481457c5ff92ebef4    
  
author   : Peter Geoghegan <[email protected]>    
date     : Thu, 14 Oct 2021 14:50:25 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Thu, 14 Oct 2021 14:50:25 -0700    

Click here for diff

Recent pg_amcheck bugfix commit d2bf06db added a test case that the  
buildfarm has shown to be non-portable.  It doesn't particularly seem  
worth keeping anyway.  Remove it.  
  
Discussion: https://postgr.es/m/CAH2-Wz=7HKJ9WzAh7+M0JfwJ1yfT9qoE+KPa3P7iGToPOtGhXg@mail.gmail.com  
Backpatch: 14-, just like the original commit.  

D src/bin/pg_amcheck/t/006_bad_targets.pl

Check criticalSharedRelcachesBuilt in GetSharedSecurityLabel().

commit   : 0b90f1c4c329f2be8ede10722a99a856020c0169    
  
author   : Jeff Davis <[email protected]>    
date     : Thu, 14 Oct 2021 12:24:22 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Thu, 14 Oct 2021 12:24:22 -0700    

Click here for diff

An extension may want to call GetSecurityLabel() on a shared object  
before the shared relcaches are fully initialized. For instance, a  
ClientAuthentication_hook might want to retrieve the security label on  
a role.  
  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.6  

M src/backend/commands/seclabel.c

Fix planner error with pulling up subquery expressions into function RTEs.

commit   : fd059ac2e461af922c7a18a7ac1cab8ad56c6353    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 14 Oct 2021 12:43:43 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 14 Oct 2021 12:43:43 -0400    

Click here for diff

If a function-in-FROM laterally references the output of some sub-SELECT  
earlier in the FROM clause, and we are able to flatten that sub-SELECT  
into the outer query, the expression(s) copied into the function RTE  
missed being processed by eval_const_expressions.  This'd lead to trouble  
and probable crashes at execution if such expressions contained  
named-argument function call syntax or functions with defaulted arguments.  
The bug is masked if the query contains any explicit JOIN syntax, which  
may help explain why we'd not noticed.  
  
Per bug #17227 from Bernd Dorn.  This is an oversight in commit 7266d0997,  
so back-patch to v13 where that came in.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/rangefuncs.out
M src/test/regress/sql/rangefuncs.sql

Change recently added test code for stability

commit   : 79c7fe1af82d42211baf37e8dc865288b251cc6d    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 13 Oct 2021 18:49:27 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 13 Oct 2021 18:49:27 -0300    

Click here for diff

The test code added with ff9f111bce24 fails under valgrind, and probably  
other slow cases too, because if (say) autovacuum runs in between and  
produces WAL of its own, the large INSERT fails to account for that in  
the LSN calculations.  Rewrite to use a DO loop.  
  
Per complaint from Andres Freund  
  
Backpatch to all branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/test/recovery/t/026_overwrite_contrecord.pl

pg_amcheck: avoid unhelpful verification attempts.

commit   : dd58194cf563c9d69821162861506d5d9acceddd    
  
author   : Peter Geoghegan <[email protected]>    
date     : Wed, 13 Oct 2021 14:08:11 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Wed, 13 Oct 2021 14:08:11 -0700    

Click here for diff

Avoid calling contrib/amcheck functions with relations that are  
unsuitable for checking.  Specifically, don't attempt verification of  
temporary relations, or indexes whose pg_index entry indicates that the  
index is invalid, or not ready.  
  
These relations are not supported by any of the contrib/amcheck  
functions, for reasons that are pretty fundamental.  For example, the  
implementation of REINDEX CONCURRENTLY can add its own "transient"  
pg_index entries, which has rather unclear implications for the B-Tree  
verification functions, at least in the general case -- so they just  
treat it as an error.  It falls to the amcheck caller (in this case  
pg_amcheck) to deal with the situation at a higher level.  
  
pg_amcheck now simply treats these conditions as additional "visibility  
concerns" when it queries system catalogs.  This is a little arbitrary.  
It seems to have the least problems among any of the available  
alternatives.  
  
Author: Mark Dilger <[email protected]>  
Reported-By: Alexander Lakhin <[email protected]>  
Reviewed-By: Peter Geoghegan <[email protected]>  
Reviewed-By: Robert Haas <[email protected]>  
Bug: #17212  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 14-, where pg_amcheck was introduced.  

M doc/src/sgml/ref/pg_amcheck.sgml
M src/bin/pg_amcheck/pg_amcheck.c
A src/bin/pg_amcheck/t/006_bad_targets.pl

postgres_fdw: Move comments about elog level in (sub)abort cleanup.

commit   : 419d27b1a28ae0b8ebb465610bcc67f36e78adfd    
  
author   : Etsuro Fujita <[email protected]>    
date     : Wed, 13 Oct 2021 19:00:01 +0900    
  
committer: Etsuro Fujita <[email protected]>    
date     : Wed, 13 Oct 2021 19:00:01 +0900    

Click here for diff

The comments were misplaced when adding postgres_fdw.  Fix that by  
moving the comments to more appropriate functions.  
  
Author: Etsuro Fujita  
Backpatch-through: 9.6  
Discussion: https://postgr.es/m/CAPmGK164sAXQtC46mDFyu6d-T25Mzvh5qaRNkit06VMmecYnOA%40mail.gmail.com  

M contrib/postgres_fdw/connection.c

Fix use-after-free with multirange types in CREATE TYPE

commit   : 922e15c47647af1b15af0a92742c8af69e83c823    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 13 Oct 2021 16:38:15 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 13 Oct 2021 16:38:15 +0900    

Click here for diff

The code was freeing the name of the multirange type function stored in  
the parse tree but it should not do that.  Event triggers could for  
example look at such a corrupted parsed tree with a ddl_command_end  
event.  
  
Author: Alex Kozhemyakin, Sergey Shinderuk  
Reviewed-by: Peter Eisentraut, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 14  

M src/backend/commands/typecmds.c

Fix tests of pg_upgrade across different major versions

commit   : f4e1c8892b9e90a9d3ccae21db04a1215b9312a5    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 13 Oct 2021 09:22:00 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 13 Oct 2021 09:22:00 +0900    

Click here for diff

This fixes a set of issues that cause different breakages or annoyances  
when using pg_upgrade's test.sh to do upgrades across different major  
versions:  
- test.sh is completely broken when using v14 as new version because of  
the removal of testtablespace/ as Makefile rule.  Older versions of  
pg_regress don't support --make-tablespacedir, blocking the creation of  
the tablespace.  In order to fix that, it is simple enough to create  
those directories in the script itself, but only do that when an old  
version is involved.  This fix is needed on HEAD and REL_14_STABLE.  
- The script would fail when using PG <= v11 as old version because of  
WITH OIDS relations not supported in v12.  In order to fix this, this  
steals a method from the buildfarm that uses a DO block to change all  
the relations marked as WITH OIDS, allowing pg_upgrade to pass.  This is  
more portable than using ALTER TABLE queries on the relations causing  
issues.  This is fixed down to v12, and authored originally by Andrew  
Dunstan.  
- Not using --extra-float-digits=0 with v11 as old version causes  
a lot of diffs in the dumps, making the whole unreadable.  This gets  
only done when using v11 as old version.  This is fixed down to v12.  
The buildfarm code uses that already.  
  
Note that the addition of --wal-segsize and --allow-group-access breaks  
the script when using v10 or older at initdb time as these got added in  
11.  10 would be EOL'd next year and nobody has complained about those  
problems yet, so nothing is done about that.  This means that this  
commit fixes upgrade tests using test.sh with v11 as minimum older  
version, up to HEAD, and that it is enough to apply this change down to  
12.  The old and new dumps still generate diffs, still require manual  
checks, and more could be done to reduce the noise, but this allows the  
tests to run with a rather minimal amount of them.  
  
I have tested this commit and test.sh with v11 as minimum across all the  
branches where this is applied.  Note that this commit has no impact on  
the normal pg_upgrade test run with a simple "make check".  
  
Author:  Justin Pryzby, Andrew Dunstan, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/bin/pg_upgrade/test.sh

Doc: normalize vacuum_multixact_failsafe_age ID.

commit   : 070c402b4a5d3cc40b3551d42763aea9afb6288d    
  
author   : Peter Geoghegan <[email protected]>    
date     : Tue, 12 Oct 2021 10:59:22 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Tue, 12 Oct 2021 10:59:22 -0700    

Click here for diff

Author: Pavel Luzanov <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 14-, where the failsafe was introduced.  

M doc/src/sgml/config.sgml
M doc/src/sgml/release-14.sgml

Add more $Test::Builder::Level in the TAP tests

commit   : d834ebcf23208b3ae2109c0cae9af077202a27a4    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 12 Oct 2021 11:16:20 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 12 Oct 2021 11:16:20 +0900    

Click here for diff

Incrementing the level of the call stack reported is useful for  
debugging purposes as it allows to control which part of the test is  
exactly failing, especially if a test is structured with subroutines  
that call routines from Test::More.  
  
This adds more incrementations of $Test::Builder::Level where debugging  
gets improved (for example it does not make sense for some paths like  
pg_rewind where long subroutines are used).  
  
A note is added to src/test/perl/README about that, based on a  
suggestion from Andrew Dunstan and a wording coming from both of us.  
  
Usage of Test::Builder::Level has spread in 12, so a backpatch down to  
this version is done.  
  
Reviewed-by: Andrew Dunstan, Peter Eisentraut, Daniel Gustafsson  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M contrib/amcheck/t/001_verify_heapam.pl
M contrib/test_decoding/t/001_repl_stats.pl
M src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
M src/bin/pg_verifybackup/t/005_bad_manifest.pl
M src/bin/psql/t/010_tab_completion.pl
M src/test/kerberos/t/001_auth.pl
M src/test/perl/README
M src/test/recovery/t/001_stream_rep.pl
M src/test/recovery/t/003_recovery_targets.pl
M src/test/recovery/t/007_sync_rep.pl
M src/test/recovery/t/009_twophase.pl
M src/test/recovery/t/018_wal_optimize.pl

Make autovacuum launcher more responsive to pg_log_backend_memory_contexts().

commit   : 62e821ad28e1f08ea9734d7338bdebd783228a1c    
  
author   : Fujii Masao <[email protected]>    
date     : Tue, 12 Oct 2021 09:50:17 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Tue, 12 Oct 2021 09:50:17 +0900    

Click here for diff

Previously when pg_log_backend_memory_contexts() sent the request to  
the autovacuum launcher, it could take more than several seconds to  
log its memory contexts. Because the function (HandleAutoVacLauncherInterrupts)  
to process any new interrupts that autovacuum launcher received  
didn't handle the request for logging of memory contexts. This commit changes  
the function so that it handles the request, to make autovacuum launcher  
more responsitve to pg_log_backend_memory_contexts().  
  
Back-patch to v14 where pg_log_backend_memory_contexts() was added.  
  
Author: Koyu Tanigawa  
Reviewed-by: Bharath Rupireddy, Atsushi Torikoshi  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/postmaster/autovacuum.c

amcheck: Skip unlogged relations in Hot Standby.

commit   : e7712155ea08c2f86dc32dccb5df2b230733be31    
  
author   : Peter Geoghegan <[email protected]>    
date     : Mon, 11 Oct 2021 17:21:46 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Mon, 11 Oct 2021 17:21:46 -0700    

Click here for diff

Have verify_heapam.c treat unlogged relations as if they were simply  
empty when in Hot Standby mode.  This brings it in line with  
verify_nbtree.c, which has handled unlogged relations in the same way  
since bugfix commit 6754fe65a4.  This was an oversight in commit  
866e24d47d, which extended contrib/amcheck to check heap relations.  
  
In passing, lower the verbosity used when reporting that a relation has  
been skipped like this, from NOTICE to DEBUG1.  This is appropriate  
because the skipping behavior is only an implementation detail, needed  
to work around the fact that unlogged tables don't have smgr-level  
storage for their main fork when in Hot Standby mode.  
  
Affected unlogged relations should be considered "trivially verified",  
not skipped over.  They are verified in the same sense that a totally  
empty relation can be verified.  This behavior seems least surprising  
overall, since unlogged relations on a replica will initially be empty  
if and when the replica is promoted and Hot Standby ends.  
  
Author: Mark Dilger <[email protected]>  
Reviewed-By: Peter Geoghegan <[email protected]>  
Discussion: https://postgr.es/m/CAH2-Wzk_pukOFY7JmdiFLsrz+Pd3V8OwgC1TH2Vd5BH5ZgK4bA@mail.gmail.com  
Backpatch: 14-, where heapam verification was introduced.  

M contrib/amcheck/verify_heapam.c
M contrib/amcheck/verify_nbtree.c

Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.

commit   : 2c25db32eedb9696c4b900c70ebef03683babf24    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Oct 2021 11:56:52 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Oct 2021 11:56:52 -0400    

Click here for diff

Commit 3f50b8263 had an oversight: formerly, to deparse expressions  
attached to a plan node, it was only necessary to update the  
deparse_namespace ancestors list alongside calling set_deparse_plan.  
Now it's necessary to update the ancestors list *first*, because  
set_deparse_plan consults it, and one call site got that wrong.  
  
This error was masked in most cases because explain.c uses just one  
List object for the ancestors list, updating it in-place as the plan  
is scanned, so that we accidentally had the right List assigned to  
dpns->ancestors before it was needed.  It would fail only if a  
WorkTableScan node were the first one that we tried to deparse a  
subexpression of.  
  
Per report from Markus Winand.  Like the previous patch,  
back-patch to v14.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/ruleutils.c

postgres_fdw: Fix comments in connection.c.

commit   : 2051fd30a4fa3b62cdb244f5b9748c1cb3b39845    
  
author   : Etsuro Fujita <[email protected]>    
date     : Thu, 7 Oct 2021 18:15:01 +0900    
  
committer: Etsuro Fujita <[email protected]>    
date     : Thu, 7 Oct 2021 18:15:01 +0900    

Click here for diff

Commit 27e1f1456 missed updating some comments.  
  
Reviewed-by: Bharath Rupireddy  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CAPmGK15Q2Nm6U%2Ba_GwskrWFEVBZ9_3VKOvRrprGufpx91M_3Sw%40mail.gmail.com  

M contrib/postgres_fdw/connection.c

Add missing word to comment in joinrels.c.

commit   : ef2e107f548cfbd22060e92c0f435616cac2f57c    
  
author   : Etsuro Fujita <[email protected]>    
date     : Thu, 7 Oct 2021 17:45:01 +0900    
  
committer: Etsuro Fujita <[email protected]>    
date     : Thu, 7 Oct 2021 17:45:01 +0900    

Click here for diff

Author: Amit Langote  
Backpatch-through: 13  
Discussion: https://postgr.es/m/CA%2BHiwqGQNbtamQ_9DU3osR1XiWR4wxWFZurPmN6zgbdSZDeWmw%40mail.gmail.com  

M src/backend/optimizer/path/joinrels.c

Fix null-pointer crash in postgres_fdw's conversion_error_callback.

commit   : 12ff678e1d657fc94a1cfa90f1b85dd9bd79e1e6    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 6 Oct 2021 15:50:24 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 6 Oct 2021 15:50:24 -0400    

Click here for diff

Commit c7b7311f6 adjusted conversion_error_callback to always use  
information from the query's rangetable, to avoid doing catalog lookups  
in an already-failed transaction.  However, as a result of the utterly  
inadequate documentation for make_tuple_from_result_row, I failed to  
realize that fsstate could be NULL in some contexts.  That led to a  
crash if we got a conversion error in such a context.  Fix by falling  
back to the previous coding when fsstate is NULL.  Improve the  
commentary, too.  
  
Per report from Andrey Borodin.  Back-patch to 9.6, like the previous  
patch.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/sql/postgres_fdw.sql

Fix corner-case loss of precision in numeric_power().

commit   : 8e26b868d5cfe9c746578aa3b172b6f24a5a310c    
  
author   : Dean Rasheed <[email protected]>    
date     : Wed, 6 Oct 2021 13:19:25 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Wed, 6 Oct 2021 13:19:25 +0100    

Click here for diff

This fixes a loss of precision that occurs when the first input is  
very close to 1, so that its logarithm is very small.  
  
Formerly, during the initial low-precision calculation to estimate the  
result weight, the logarithm was computed to a local rscale that was  
capped to NUMERIC_MAX_DISPLAY_SCALE (1000). However, the base may be  
as close as 1e-16383 to 1, hence its logarithm may be as small as  
1e-16383, and so the local rscale needs to be allowed to exceed 16383,  
otherwise all precision is lost, leading to a poor choice of rscale  
for the full-precision calculation.  
  
Fix this by removing the cap on the local rscale during the initial  
low-precision calculation, as we already do in the full-precision  
calculation. This doesn't change the fact that the initial calculation  
is a low-precision approximation, computing the logarithm to around 8  
significant digits, which is very fast, especially when the base is  
very close to 1.  
  
Patch by me, reviewed by Alvaro Herrera.  
  
Discussion: https://postgr.es/m/CAEZATCV-Ceu%2BHpRMf416yUe4KKFv%3DtdgXQAe5-7S9tD%3D5E-T1g%40mail.gmail.com  

M src/backend/utils/adt/numeric.c
M src/test/regress/expected/numeric.out
M src/test/regress/sql/numeric.sql

Fix warning in TAP test of pg_verifybackup

commit   : ae254356f94af220841f3c59dcd4d820449ca0fc    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 6 Oct 2021 13:28:30 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 6 Oct 2021 13:28:30 +0900    

Click here for diff

Oversight in a3fcbcd.  
  
Reported-by: Thomas Munro  
Discussion: https://postgr.es/m/CA+hUKGKnajZEwe91OTjro9kQLCMGGFHh2vvFn8tgHgbyn4bF9w@mail.gmail.com  
Backpatch-through: 13  

M src/bin/pg_verifybackup/t/007_wal.pl

Doc: improve description of UNION/INTERSECT/EXCEPT syntax.

commit   : cb8a5a588eb7325d17780a7a8871ae3b49adc497    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 5 Oct 2021 10:24:14 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 5 Oct 2021 10:24:14 -0400    

Click here for diff

queries.sgml failed to mention the rather important point that  
INTERSECT binds more tightly than UNION or EXCEPT.  I thought  
it could also use more discussion of the role of parentheses  
in these constructs.  
  
Per gripe from Christopher Painter-Wakefield.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/queries.sgml

doc: remove URL for ICU explorer/locexp

commit   : 1f00a2902bf422cb15fc66145f1e349fdb97689b    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 4 Oct 2021 17:10:59 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 4 Oct 2021 17:10:59 -0400    

Click here for diff

The old URL was HTTP 404 and the git link didn't build.  Also update two  
other ICU links.  If we ever get a good link we will add it back.  
  
Reported-by: Anton Voloshin  
  
Author: Laurenz Albe  
  
Backpatch-through: 10  

M doc/src/sgml/charset.sgml

Fix TestLib::slurp_file() with offset on windows.

commit   : c4465cd09e3ab034ced25e623d5760e9ce437f6c    
  
author   : Andres Freund <[email protected]>    
date     : Mon, 4 Oct 2021 13:28:06 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Mon, 4 Oct 2021 13:28:06 -0700    

Click here for diff

3c5b0685b921 used setFilePointer() to set the position of the filehandle, but  
passed the wrong filehandle, always leaving the position at 0. Instead of just  
fixing that, remove use of setFilePointer(), we have a perl fd at this point,  
so we can just use perl's seek().  
  
Additionally, the perl filehandle wasn't closed, just the windows filehandle.  
  
Reviewed-By: Andrew Dunstan <[email protected]>  
Author: Andres Freund <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 9.6-, like 3c5b0685b921  

M src/test/perl/TestLib.pm

Update our mapping of Windows time zone names some more.

commit   : 919c08d909f766bb51c5c617714364a91bb90d9d    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 4 Oct 2021 14:52:17 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 4 Oct 2021 14:52:17 -0400    

Click here for diff

Per discussion, let's just follow CLDR's default zone mappings  
faithfully.  There are two changes here that are clear improvements:  
  
* Mapping "Greenwich Standard Time" to Atlantic/Reykjavik is actually  
a better fit than using London, because Iceland hasn't observed DST  
since 1968, so this is more nearly what people might expect.  
  
* Since the "Samoa" zone is specified to be UTC+13:00, we must map  
it to Pacific/Apia not Pacific/Samoa; the latter refers to American  
Samoa which is now on the other side of the date line.  
  
The rest of these changes look like they're choosing the most populous  
IANA zone as representative.  Whatever the details, we're just going  
to say "if you don't like this mapping, complain to CLDR".  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/initdb/findtimezone.c

Doc: fix minor issues in GiST support function documentation.

commit   : 5f46180070d108f2f2aec6a9d3d488d3ef55b42e    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 4 Oct 2021 13:34:31 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 4 Oct 2021 13:34:31 -0400    

Click here for diff

gist.sgml and xindex.sgml hadn't been fully updated for the  
addition of a sortsupport support function (commit 16fa9b2b3).  
xindex.sgml also missed that the compress and decompress support  
functions are optional, an apparently far older oversight.  
  
In passing, fix gratuitous inconsistencies in wording and  
capitalization.  
  
Noted by E. Rogov.  Back-patch to v14; the residual issues  
before that aren't significant enough to bother with.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/gist.sgml
M doc/src/sgml/xindex.sgml

Fix snapshot builds during promotion of hot standby node with 2PC

commit   : 828f7f0009edda3f78dd789102cd02a394f94938    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 4 Oct 2021 14:05:48 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 4 Oct 2021 14:05:48 +0900    

Click here for diff

Some specific logic is done at the end of recovery when involving 2PC  
transactions:  
1) Call RecoverPreparedTransactions(), to recover the state of 2PC  
transactions into memory (re-acquire locks, etc.).  
2) ShutdownRecoveryTransactionEnvironment(), to move back to normal  
operations, mainly cleaning up recovery locks and KnownAssignedXids  
(including any 2PC transaction tracked previously).  
3) Switch XLogCtl->SharedRecoveryState to RECOVERY_STATE_DONE, which is  
the tipping point for any process calling RecoveryInProgress() to check  
if the cluster is still in recovery or not.  
  
Any snapshot taken between steps 2) and 3) would be empty, causing any  
transaction relying on a snapshot at this point to potentially corrupt  
data as there could still be some 2PC transactions to track, with  
RecentXmin moving backwards on successive calls to GetSnapshotData() in  
the same transaction.  
  
As SharedRecoveryState is the point to take into account to know if it  
is safe to discard KnownAssignedXids, this commit moves step 2) after  
step 3), so as we can never finish with empty snapshots.  
  
This exists since the introduction of hot standby, so backpatch all the  
way down.  The window with incorrect snapshots is extremely small, but I  
have seen it when running 023_pitr_prepared_xact.pl, as did buildfarm  
member fairywren.  Thomas Munro also found it independently.  Special  
thanks to Andres Freund for taking the time to analyze this issue.  
  
Reported-by: Thomas Munro, Michael Paquier  
Analyzed-by: Andres Freund  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.6  

M src/backend/access/transam/xlog.c

Fix checking of query type in plpgsql's RETURN QUERY command.

commit   : e0eba586b1b8448639ab4170fe39270d73dc2e2a    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 3 Oct 2021 13:21:20 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 3 Oct 2021 13:21:20 -0400    

Click here for diff

Prior to v14, we insisted that the query in RETURN QUERY be of a type  
that returns tuples.  (For instance, INSERT RETURNING was allowed,  
but not plain INSERT.)  That happened indirectly because we opened a  
cursor for the query, so spi.c checked SPI_is_cursor_plan().  As a  
consequence, the error message wasn't terribly on-point, but at least  
it was there.  
  
Commit 2f48ede08 lost this detail.  Instead, plain RETURN QUERY  
insisted that the query be a SELECT (by checking for SPI_OK_SELECT)  
while RETURN QUERY EXECUTE failed to check the query type at all.  
Neither of these changes was intended.  
  
The only convenient place to check this in the EXECUTE case is inside  
_SPI_execute_plan, because we haven't done parse analysis until then.  
So we need to pass down a flag saying whether to enforce that the  
query returns tuples.  Fortunately, we can squeeze another boolean  
into struct SPIExecuteOptions without an ABI break, since there's  
padding space there.  (It's unlikely that any extensions would  
already be using this new struct, but preserving ABI in v14 seems  
like a smart idea anyway.)  
  
Within spi.c, it seemed like _SPI_execute_plan's parameter list  
was already ridiculously long, and I didn't want to make it longer.  
So I thought of passing SPIExecuteOptions down as-is, allowing that  
parameter list to become much shorter.  This makes the patch a bit  
more invasive than it might otherwise be, but it's all internal to  
spi.c, so that seems fine.  
  
Per report from Marc Bachmann.  Back-patch to v14 where the  
faulty code came in.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/spi.sgml
M src/backend/executor/spi.c
M src/include/executor/spi.h
M src/pl/plpgsql/src/pl_exec.c
M src/test/regress/expected/plpgsql.out
M src/test/regress/sql/plpgsql.sql

Update our mapping of Windows time zone names using CLDR info.

commit   : fa8db48791c58444ab35d6f2419074a717fbb9b7    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 2 Oct 2021 16:05:42 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 2 Oct 2021 16:05:42 -0400    

Click here for diff

This corrects a bunch of entries in win32_tzmap[], and adds a few  
new ones, based on the CLDR project's windowsZones.xml file.  
Non-cosmetic changes fall into four main categories:  
  
* Flat-out errors:  
  
US/Aleutan doesn't exist  
America/Salvador doesn't exist  
Asia/Baku is wrong for Yerevan  
Asia/Dhaka (Bangladesh) is wrong for Astana (Kazakhstan)  
Europe/Bucharest is wrong for Chisinau  
America/Mexico_City is wrong for Chetumal  
America/Buenos_Aires is wrong for Cayenne  
America/Caracas has its own zone, so poor fit for La Paz  
US/Eastern is wrong for Haiti  
US/Eastern is wrong for Indiana (East)  
Asia/Karachi is wrong for Tashkent  
Etc/UTC+12 doesn't exist  
Signs of Etc/GMT zones were backwards  
  
* Judgment calls:  
  
(These changes follow CLDR's choices, except for the first one)  
  
Use Europe/London for "Greenwich Standard Time", since that seems much  
more likely than Africa/Casablanca to be what people will think that  
zone name means.  CLDR has Atlantic/Reykjavik here, but that's no better.  
  
Asia/Shanghai seems a better fit than Hong Kong for "China Standard  
Time".  
  
Europe/Sarajevo is now a link to Belgrade, ie "Central Europe Standard  
Time"; so use Warsaw for "Central European Standard Time".  
  
America/Sao_Paulo seems more representative than Araguaina for  
"E. South America Standard Time".  
  
Africa/Johannesburg seems more representative than Harare for  
"South Africa Standard Time".  
  
* New Windows zone names:  
  
"Israel Standard Time"  
"Kaliningrad Standard Time"  
"Russia Time Zone N" for various N  
"Singapore Standard Time"  
"South Sudan Standard Time"  
"W. Central Africa Standard Time"  
"West Bank Standard Time"  
"Yukon Standard Time"  
  
Some of these replace older spellings, but I kept the older spellings  
too in case our code runs on a machine with the older data.  
  
* Replace aliases (tzdb Links) with underlying city-named zones:  
  
(This tracks tzdb's longstanding practice, and reduces inconsistency  
with the rest of the entries, as well as with CLDR.)  
  
US/Alaska  
Asia/Kuwait  
Asia/Muscat  
Canada/Atlantic  
Australia/Canberra  
Canada/Saskatchewan  
US/Central  
US/Eastern  
US/Hawaii  
US/Mountain  
Canada/Newfoundland  
US/Pacific  
  
Back-patch to all supported branches, as is our usual practice for  
time zone data updates.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/initdb/findtimezone.c

Re-alphabetize the win32_tzmap[] array.

commit   : 81464999bc92ebf9b813e1c7bd8b333e29511fb5    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 2 Oct 2021 16:05:10 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 2 Oct 2021 16:05:10 -0400    

Click here for diff

The original intent seems to have been to sort case-insensitively  
by the Windows zone name, but various changes over the years did  
not get that memo.  This commit just moves a few entries to  
restore exact alphabetic order, to ease comparison to the outputs  
of processing scripts.  
  
Back-patch to all supported branches, as is our usual practice for  
time zone data updates.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/initdb/findtimezone.c

Reference test binary using TESTDIR in 001_libpq_pipeline.pl.

commit   : 0baa33da0fd123aff215c505116dc60bc04dae90    
  
author   : Andres Freund <[email protected]>    
date     : Wed, 29 Sep 2021 18:02:32 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Wed, 29 Sep 2021 18:02:32 -0700    

Click here for diff

The previous approach didn't really work on windows, due to the PATH separator  
being ';' not ':'. Instead of making the PATH change more complicated,  
reference the binary using the TESTDIR environment.  
  
Reported-By: Andres Freund <[email protected]>  
Suggested-By: Andrew Dunstan <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 14-, where the test was introduced.  

M src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl

Error out if SKIP LOCKED and WITH TIES are both specified

commit   : 20047609d39cc4d30d6b266ed3a8b418b3ce5f78    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 1 Oct 2021 18:29:18 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 1 Oct 2021 18:29:18 -0300    

Click here for diff

Both bugs #16676[1] and #17141[2] illustrate that the combination of  
SKIP LOCKED and FETCH FIRST WITH TIES break expectations when it comes  
to rows returned to other sessions accessing the same row.  Since this  
situation is detectable from the syntax and hard to fix otherwise,  
forbid for now, with the potential to fix in the future.  
  
[1] https://postgr.es/m/[email protected]  
[2] https://postgr.es/m/[email protected]  
  
Backpatch-through: 13, where WITH TIES was introduced  
Author: David Christensen <[email protected]>  
Discussion: https://postgr.es/m/CAOxo6XLPccCKru3xPMaYDpa+AXyPeWFs+SskrrL+HKwDjJnLhg@mail.gmail.com  

M doc/src/sgml/ref/select.sgml
M src/backend/commands/matview.c
M src/backend/parser/gram.y
M src/test/regress/expected/limit.out
M src/test/regress/sql/limit.sql

Remove unstable, unnecessary test; fix typo

commit   : 0ce67bce00717d8934b599ab4409e28b33c612ea    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 1 Oct 2021 18:03:11 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 1 Oct 2021 18:03:11 -0300    

Click here for diff

Commit ff9f111bce24 added some test code that's unportable and doesn't  
add meaningful coverage.  Remove it rather than try and get it to work  
everywhere.  
  
While at it, fix a typo in a log message added by the aforementioned  
commit.  
  
Backpatch to 14.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xlog.c
M src/test/recovery/t/026_overwrite_contrecord.pl
D src/test/recovery/t/idiosyncratic_copy

Fix memory leak in pg_hmac

commit   : a5e83ad79c282421f32224c5152d6182de34da35    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Fri, 1 Oct 2021 22:47:05 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Fri, 1 Oct 2021 22:47:05 +0200    

Click here for diff

The intermittent h buffer was not freed, causing it to leak. Backpatch  
through 14 where HMAC was refactored to the current API.  
  
Author: Sergey Shinderuk <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 14  

M src/common/hmac.c

Avoid believing incomplete MCV-only stats in get_variable_range().

commit   : a54509bfd952085a24224480ff74d5cbd558c407    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 1 Oct 2021 14:59:35 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 1 Oct 2021 14:59:35 -0400    

Click here for diff

get_variable_range() would incautiously believe that statistics  
containing only an MCV list are sufficient to derive a range estimate.  
That's okay for an enum-like column that contains only MCVs, but  
otherwise the estimate could be pretty bad.  Make it report that the  
range is indeterminate unless the MCVs plus nullfrac account for  
the whole table.  
  
I don't think this needs a dedicated test case, since a quick code  
coverage check verifies that the existing regression tests traverse  
all the alternatives.  There is room to doubt that a future-proof  
test case could be built anyway, given that the submitted example  
accidentally doesn't fail before v11.  
  
Per bug #17207 from Simon Perepelitsa.  Back-patch to v10.  
In principle this has been broken all along, but I'm hesitant to  
make such changes in 9.6, since if anyone is unhappy with 9.6.24's  
behavior there will be no second chance to fix it.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/selfuncs.c

Fix Portal snapshot tracking to handle subtransactions properly.

commit   : e6adaa1795d593edd616b9541fff0920637f9721    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 1 Oct 2021 11:10:12 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 1 Oct 2021 11:10:12 -0400    

Click here for diff

Commit 84f5c2908 forgot to consider the possibility that  
EnsurePortalSnapshotExists could run inside a subtransaction with  
lifespan shorter than the Portal's.  In that case, the new active  
snapshot would be popped at the end of the subtransaction, leaving  
a dangling pointer in the Portal, with mayhem ensuing.  
  
To fix, make sure the ActiveSnapshot stack entry is marked with  
the same subtransaction nesting level as the associated Portal.  
It's certainly safe to do so since we won't be here at all unless  
the stack is empty; hence we can't create an out-of-order stack.  
  
Let's also apply this logic in the case where PortalRunUtility  
sets portalSnapshot, just to be sure that path can't cause similar  
problems.  It's slightly less clear that that path can't create  
an out-of-order stack, so add an assertion guarding it.  
  
Report and patch by Bertrand Drouvot (with kibitzing by me).  
Back-patch to v11, like the previous commit.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xact.c
M src/backend/tcop/pquery.c
M src/backend/utils/mmgr/portalmem.c
M src/backend/utils/time/snapmgr.c
M src/include/utils/portal.h
M src/include/utils/snapmgr.h
M src/pl/plpgsql/src/expected/plpgsql_transaction.out
M src/pl/plpgsql/src/sql/plpgsql_transaction.sql

Doc: Move pg_stat_replication_slots view to "Collected Statistics Views" section.

commit   : 8de4a31720c2c2ce55f73f4af4b3cdc6cdcca225    
  
author   : Amit Kapila <[email protected]>    
date     : Fri, 1 Oct 2021 08:31:41 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Fri, 1 Oct 2021 08:31:41 +0530    

Click here for diff

Commit 9868167500 added pg_stat_replication_slots view to monitor  
ReorderBuffer stats but mistakenly added it under  
"Dynamic Statistics Views" section in the docs whereas it belongs to  
"Collected Statistics Views" section.  
  
Author: Amit Kapila  
Reviewed-by: Masahiko Sawada  
Backpatch-through: 14, where it was introduced  
Discussion: https://postgr.es/m/CAA4eK1Kb5ur=OC-G4cAsqPOjoVe+S8LNw1WmUY8Owasjk8o5WQ@mail.gmail.com  

M doc/src/sgml/monitoring.sgml

Remove gratuitous environment dependency in 002_types.pl test.

commit   : afc6081f6ea8fa053dafe14e609d1d8e885410f8    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 30 Sep 2021 16:23:10 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 30 Sep 2021 16:23:10 -0400    

Click here for diff

Computing related timestamps by subtracting "N days" is sensitive  
to the prevailing timezone, since we interpret that as "same local  
time on the N'th prior day".  Even though the intervals in question  
are only two to four days, through remarkable bad luck they managed  
to cross the end of Ramadan in 2014, causing the test's output to  
change if timezone is set to Africa/Casablanca.  (Maybe in other  
Muslim areas as well; I didn't check.)  There's absolutely no reason  
for this test to exercise interval subtraction, so just get rid of  
that and use plain timestamptz constants representing the intended  
values.  
  
Per report from Andres Freund.  Back-patch to v10 where this test  
script came in.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/test/subscription/t/002_types.pl

Repair two portability oversights of new test

commit   : e3731bac52cf049bed965aa4f96cb073ed044b68    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 30 Sep 2021 10:01:03 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 30 Sep 2021 10:01:03 -0300    

Click here for diff

First, as pointed out by Tom Lane and Michael Paquier, I failed to  
realize that Windows' PostgresNode needs an extra pg_hba.conf line  
(added by PostgresNode->set_replication_conf, called internally by  
->init() when 'allows_streaming=>1' is given -- but I purposefully  
omitted that).  I think a good fix should be to have nodes with only  
'has_archiving=>1' set up for replication too, but that's a bigger  
discussion.  Fix it by calling ->set_replication_conf, which is not  
unprecedented, as pointed out by Andrew Dunstan.  
  
I also forgot to uncomment a ->finish() call for a pumpable IPC::Run  
file descriptor.  Apparently this is innocuous in almost all platforms.  
  
Backpatch to 14.  The older branches were added this file too, but not  
this particular part of the test.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  

M src/test/recovery/t/026_overwrite_contrecord.pl

Fix WAL replay in presence of an incomplete record

commit   : 64a8687a68914aa3f5a0867885777a1294eceb1c    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 29 Sep 2021 11:21:51 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 29 Sep 2021 11:21:51 -0300    

Click here for diff

Physical replication always ships WAL segment files to replicas once  
they are complete.  This is a problem if one WAL record is split across  
a segment boundary and the primary server crashes before writing down  
the segment with the next portion of the WAL record: WAL writing after  
crash recovery would happily resume at the point where the broken record  
started, overwriting that record ... but any standby or backup may have  
already received a copy of that segment, and they are not rewinding.  
This causes standbys to stop following the primary after the latter  
crashes:  
  LOG:  invalid contrecord length 7262 at A8/D9FFFBC8  
because the standby is still trying to read the continuation record  
(contrecord) for the original long WAL record, but it is not there and  
it will never be.  A workaround is to stop the replica, delete the WAL  
file, and restart it -- at which point a fresh copy is brought over from  
the primary.  But that's pretty labor intensive, and I bet many users  
would just give up and re-clone the standby instead.  
  
A fix for this problem was already attempted in commit 515e3d84a0b5, but  
it only addressed the case for the scenario of WAL archiving, so  
streaming replication would still be a problem (as well as other things  
such as taking a filesystem-level backup while the server is down after  
having crashed), and it had performance scalability problems too; so it  
had to be reverted.  
  
This commit fixes the problem using an approach suggested by Andres  
Freund, whereby the initial portion(s) of the split-up WAL record are  
kept, and a special type of WAL record is written where the contrecord  
was lost, so that WAL replay in the replica knows to skip the broken  
parts.  With this approach, we can continue to stream/archive segment  
files as soon as they are complete, and replay of the broken records  
will proceed across the crash point without a hitch.  
  
Because a new type of WAL record is added, users should be careful to  
upgrade standbys first, primaries later. Otherwise they risk the standby  
being unable to start if the primary happens to write such a record.  
  
A new TAP test that exercises this is added, but the portability of it  
is yet to be seen.  
  
This has been wrong since the introduction of physical replication, so  
backpatch all the way back.  In stable branches, keep the new  
XLogReaderState members at the end of the struct, to avoid an ABI  
break.  
  
Author: Álvaro Herrera <[email protected]>  
Reviewed-by: Kyotaro Horiguchi <[email protected]>  
Reviewed-by: Nathan Bossart <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogreader.c
M src/include/access/xlog_internal.h
M src/include/access/xlogreader.h
M src/include/catalog/pg_control.h
A src/test/recovery/t/026_overwrite_contrecord.pl
A src/test/recovery/t/idiosyncratic_copy
M src/tools/pgindent/typedefs.list

doc: PG 14 relnotes, improve cache invalidation wording

commit   : 4f2c75316b2b767a838aa9fefb6e4944ace34f23    
  
author   : Bruce Momjian <[email protected]>    
date     : Wed, 29 Sep 2021 10:27:53 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Wed, 29 Sep 2021 10:27:53 -0400    

Click here for diff

Reported-by: Simon Riggs (privately)  
  
Backpatch-through: 14 only  

M doc/src/sgml/release-14.sgml

pgbench: Fix handling of socket errors during benchmark.

commit   : 8231c500ed742431263052cd48fbb859d7f7d7ea    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 29 Sep 2021 21:01:10 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 29 Sep 2021 21:01:10 +0900    

Click here for diff

Previously socket errors such as invalid socket or socket wait method failures  
during benchmark caused pgbench to exit with status 0. Instead, errors during  
the run should result in exit status 2.  
  
Back-patch to v12 where pgbench started reporting exit status.  
  
Original complaint and patch by Hayato Kuroda.  
  
Author: Yugo Nagata, Fabien COELHO  
Reviewed-by: Kyotaro Horiguchi, Fujii Masao  
Discussion: https://postgr.es/m/TYCPR01MB5870057375ACA8A73099C649F5349@TYCPR01MB5870.jpnprd01.prod.outlook.com  

M src/bin/pgbench/pgbench.c

pgbench: Correct log level of message output when socket wait method fails.

commit   : 8021334d3710cb030ed1b6de764a0bb2233e5265    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 29 Sep 2021 20:35:00 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 29 Sep 2021 20:35:00 +0900    

Click here for diff

The failure of socket wait method like "select()" doesn't terminate pgbench.  
So the log level of error message when that failure happens should be ERROR.  
But previously FATAL was used in that case.  
  
Back-patch to v13 where pgbench started using common logging API.  
  
Author: Yugo Nagata, Fabien COELHO  
Reviewed-by: Kyotaro Horiguchi, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pgbench/pgbench.c

Clarify use of "statistics objects" in the code

commit   : 2cf9cf5d7b5e66202389618a4c08945da352b35c    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 29 Sep 2021 15:29:45 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 29 Sep 2021 15:29:45 +0900    

Click here for diff

The code inconsistently used "statistic object" or "statistics" where  
the correct term, as discussed, is actually "statistics object".  This  
improves the state of the code to be more consistent.  
  
While on it, fix an incorrect error message introduced in a4d75c8.  This  
error should never happen, as the code states, but it would be  
misleading.  
  
Author: Justin Pryzby  
Reviewed-by: Álvaro Herrera, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 14  

M src/backend/commands/statscmds.c
M src/backend/commands/tablecmds.c
M src/backend/parser/parse_utilcmd.c
M src/backend/statistics/extended_stats.c
M src/backend/utils/adt/selfuncs.c

doc: Fix some typos and markups

commit   : 2a27dbaeb9088718baa25bc97f2e049e063412db    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 29 Sep 2021 11:56:36 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 29 Sep 2021 11:56:36 +0900    

Click here for diff

Author: Ekaterina Kiryanova  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 14  

M doc/src/sgml/btree.sgml
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/ref/alter_subscription.sgml
M doc/src/sgml/ref/initdb.sgml
M doc/src/sgml/ref/psql-ref.sgml
M doc/src/sgml/spgist.sgml
M doc/src/sgml/test-decoding.sgml

Fix instability in contrib/bloom TAP tests.

commit   : cea5624f6a23a100fb93aee8b40bdc3a8cb52081    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 28 Sep 2021 17:34:31 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 28 Sep 2021 17:34:31 -0400    

Click here for diff

It turns out that the instability complained of in commit d3c09b9b1  
has an embarrassingly simple explanation.  The test script waits for  
the standby to flush incoming WAL to disk, but it should wait for  
the WAL to be replayed, since we are testing for the effects of that  
to be visible.  
  
While at it, use wait_for_catchup instead of reinventing that logic,  
and adjust $Test::Builder::Level to improve future error reports.  
  
Back-patch to v12 where the necessary infrastructure came in  
(cf. aforesaid commit).  Also back-patch 7d1aa6bf1 so that the  
test will actually get run.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/bloom/Makefile
M contrib/bloom/t/001_wal.pl

doc: adjust attributions in PG 14 release notes

commit   : 2f283d036da8e4c74fd07022cb685efee4e345bd    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 28 Sep 2021 14:15:39 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 28 Sep 2021 14:15:39 -0400    

Click here for diff

Backpatch-through: 14 only  

M doc/src/sgml/release-14.sgml

Properly schema-prefix reference to pg_catalog.pg_get_statisticsobjdef_columns

commit   : febbb2f52c99b16261387daba4931d621dfbef0f    
  
author   : Magnus Hagander <[email protected]>    
date     : Tue, 28 Sep 2021 16:23:18 +0200    
  
committer: Magnus Hagander <[email protected]>    
date     : Tue, 28 Sep 2021 16:23:18 +0200    

Click here for diff

Author: Tatsuro Yamada  
Backpatch-through: 14  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/bin/psql/describe.c