PostgreSQL 9.5.25 commit log

Stamp 9.5.25.

commit   : 202c587e2f28bc295f6935d044e20680b627e7a1    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 8 Feb 2021 17:03:12 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 8 Feb 2021 17:03:12 -0500    

Click here for diff

M configure
M configure.in
M doc/bug.template
M src/include/pg_config.h.win32
M src/interfaces/libpq/libpq.rc.in
M src/port/win32ver.rc

Translation updates

commit   : c20a8efa6e2a7374f4cddb76e76213f63b7d7ac5    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 8 Feb 2021 18:13:24 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 8 Feb 2021 18:13:24 +0100    

Click here for diff

Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git  
Source-Git-Hash: 1ffd28d39fa86fe118814dba78945fb2e4322ae0  

M src/backend/po/de.po
M src/backend/po/fr.po
M src/backend/po/ru.po
M src/bin/pg_rewind/po/ru.po
M src/bin/psql/po/de.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ru.po

Release notes for 13.2, 12.6, 11.11, 10.16, 9.6.21, 9.5.25.

commit   : ac773ae242e52fceb1da5dd9cf608ef4e76dae4e    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 7 Feb 2021 15:46:38 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 7 Feb 2021 15:46:38 -0500    

Click here for diff

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

Revert "Propagate CTE property flags when copying a CTE list into a rule."

commit   : a64aacf152fc1ea808b2443b41f18e4b2c1cfc61    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 7 Feb 2021 12:54:08 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 7 Feb 2021 12:54:08 -0500    

Click here for diff

This reverts commit ed290896335414c6c069b9ccae1f3dcdd2fac6ba and  
equivalent back-branch commits.  The issue is subtler than I thought,  
and it's far from new, so just before a release deadline is no time  
to be fooling with it.  We'll consider what to do at a bit more  
leisure.  
  
Discussion: https://postgr.es/m/CAJcOf-fAdj=nDKMsRhQzndm-O13NY4dL6xGcEvdX5Xvbbi0V7g@mail.gmail.com  

M src/backend/rewrite/rewriteHandler.c

Propagate CTE property flags when copying a CTE list into a rule.

commit   : 4384eccb15495960194a4a9dc1e2861f612f3ee5    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 6 Feb 2021 19:28:39 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 6 Feb 2021 19:28:39 -0500    

Click here for diff

rewriteRuleAction() neglected this step, although it was careful to  
propagate other similar flags such as hasSubLinks or hasRowSecurity.  
Omitting to transfer hasRecursive is just cosmetic at the moment,  
but omitting hasModifyingCTE is a live bug, since the executor  
certainly looks at that.  
  
The proposed test case only fails back to v10, but since the executor  
examines hasModifyingCTE in 9.x as well, I suspect that a test case  
could be devised that fails in older branches.  Given the nearness  
of the release deadline, though, I'm not going to spend time looking  
for a better test.  
  
Report and patch by Greg Nancarrow, cosmetic changes by me  
  
Discussion: https://postgr.es/m/CAJcOf-fAdj=nDKMsRhQzndm-O13NY4dL6xGcEvdX5Xvbbi0V7g@mail.gmail.com  

M src/backend/rewrite/rewriteHandler.c

Disallow converting an inheritance child table to a view.

commit   : 5ad03374bfe74ebdea937461170c1567671e11e0    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 6 Feb 2021 15:17:02 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 6 Feb 2021 15:17:02 -0500    

Click here for diff

Generally, members of inheritance trees must be plain tables (or,  
in more recent versions, foreign tables).  ALTER TABLE INHERIT  
rejects creating an inheritance relationship that has a view at  
either end.  When DefineQueryRewrite attempts to convert a relation  
to a view, it already had checks prohibiting doing so for partitioning  
parents or children as well as traditional-inheritance parents ...  
but it neglected to check that a traditional-inheritance child wasn't  
being converted.  Since the planner assumes that any inheritance  
child is a table, this led to making plans that tried to do a physical  
scan on a view, causing failures (or even crashes, in recent versions).  
  
One could imagine trying to support such a case by expanding the view  
normally, but since the rewriter runs before the planner does  
inheritance expansion, it would take some very fundamental refactoring  
to make that possible.  There are probably a lot of other parts of the  
system that don't cope well with such a situation, too.  For now,  
just forbid it.  
  
Per bug #16856 from Yang Lin.  Back-patch to all supported branches.  
(In versions before v10, this includes back-patching the portion of  
commit 501ed02cf that added has_superclass().  Perhaps the lack of  
that infrastructure partially explains the missing check.)  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/pg_inherits.c
M src/backend/rewrite/rewriteDefine.c
M src/include/catalog/pg_inherits_fn.h
M src/test/regress/expected/rules.out
M src/test/regress/sql/rules.sql

Fix backslash-escaping multibyte chars in COPY FROM.

commit   : aaf266157d21935d8106bd68c18eadea5dfdf1eb    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 5 Feb 2021 11:14:56 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 5 Feb 2021 11:14:56 +0200    

Click here for diff

If a multi-byte character is escaped with a backslash in TEXT mode input,  
and the encoding is one of the client-only encodings where the bytes after  
the first one can have an ASCII byte "embedded" in the char, we didn't  
skip the character correctly. After a backslash, we only skipped the first  
byte of the next character, so if it was a multi-byte character, we would  
try to process its second byte as if it was a separate character. If it  
was one of the characters with special meaning, like '\n', '\r', or  
another '\\', that would cause trouble.  
  
One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.  
That's supposed to be [backslash][two-byte character][.][f][o][o], but  
because the second byte of the two-byte character is 0x5c, we incorrectly  
treat it as another backslash. And because the next character is a dot, we  
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"  
error.  
  
Backpatch to all supported versions.  
  
Reviewed-by: John Naylor, Kyotaro Horiguchi  
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi  

M src/backend/commands/copy.c

Fix ancient memory leak in contrib/auto_explain.

commit   : f0f9ed68d3f5ee356ab6323b795bb64e640a2da1    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 2 Feb 2021 13:49:08 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 2 Feb 2021 13:49:08 -0500    

Click here for diff

The ExecutorEnd hook is invoked in a context that could be quite  
long-lived, not the executor's own per-query context as I think  
we were sort of assuming.  Thus, any cruft generated while producing  
the EXPLAIN output could accumulate over multiple queries.  This can  
result in spectacular leakage if log_nested_statements is on, and  
even without that I'm surprised nobody complained before.  
  
To fix, just switch into the executor's context so that anything we  
allocate will be released when standard_ExecutorEnd frees the executor  
state.  We might as well nuke the code's retail pfree of the explain  
output string, too; that's laughably inadequate to the need.  
  
Japin Li, per report from Jeff Janes.  This bug is old, so  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/CAMkU=1wCVtbeRn0s9gt12KwQ7PLXovbpM8eg25SYocKW3BT4hg@mail.gmail.com  

M contrib/auto_explain/auto_explain.c

Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions.

commit   : 77a0e14f0b21d34c31c3eabaf249844607680fbe    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 30 Jan 2021 00:00:27 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 30 Jan 2021 00:00:27 -0800    

Click here for diff

In a cluster having used CREATE INDEX CONCURRENTLY while having enabled  
prepared transactions, queries that use the resulting index can silently  
fail to find rows.  Fix this for future CREATE INDEX CONCURRENTLY by  
making it wait for prepared transactions like it waits for ordinary  
transactions.  This expands the VirtualTransactionId structure domain to  
admit prepared transactions.  It may be necessary to reindex to recover  
from past occurrences.  Back-patch to 9.5 (all supported versions).  
  
Andrey Borodin, reviewed (in earlier versions) by Tom Lane and Michael  
Paquier.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/lmgr/lmgr.c
M src/backend/storage/lmgr/lock.c
M src/include/storage/lock.h
M src/test/isolation/Makefile
M src/test/isolation/README
A src/test/isolation/expected/prepared-transactions-cic.out
A src/test/isolation/specs/prepared-transactions-cic.spec

Silence another gcc 11 warning.

commit   : d777e27c80f83e1177393641b99b1c7c4b19af17    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 28 Jan 2021 17:18:23 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 28 Jan 2021 17:18:23 -0500    

Click here for diff

Per buildfarm and local experimentation, bleeding-edge gcc isn't  
convinced that the MemSet in reorder_function_arguments() is safe.  
Shut it up by adding an explicit check that pronargs isn't negative,  
and by changing MemSet to memset.  (It appears that either change is  
enough to quiet the warning at -O2, but let's do both to be sure.)  

M src/backend/optimizer/util/clauses.c

Make ecpg's rjulmdy() and rmdyjul() agree with their declarations.

commit   : 27c79a46aae34e239c5655586bd6be9102469853    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 28 Jan 2021 11:17:13 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 28 Jan 2021 11:17:13 -0500    

Click here for diff

We had "short *mdy" in the extern declarations, but "short mdy[3]"  
in the actual function definitions.  Per C99 these are equivalent,  
but recent versions of gcc have started to issue warnings about  
the inconsistency.  Clean it up before the warnings get any more  
widespread.  
  
Back-patch, in case anyone wants to build older PG versions with  
bleeding-edge compilers.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/interfaces/ecpg/compatlib/informix.c

pgbench: Remove dead code

commit   : cfbbc1f17c24258836662ed6a0f3087c33b90bae    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 28 Jan 2021 12:50:40 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 28 Jan 2021 12:50:40 -0300    

Click here for diff

doConnect() never returns connections in state CONNECTION_BAD, so  
checking for that is pointless.  Remove the code that does.  
  
This code has been dead since ba708ea3dc84, 20 years ago.  
  
Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Tom Lane <[email protected]>  

M src/bin/pgbench/pgbench.c

Report the true database name on connection errors

commit   : f2dc962360b329c811c5e08eb0de4fb82462cdaf    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 26 Jan 2021 16:42:13 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 26 Jan 2021 16:42:13 -0300    

Click here for diff

When reporting connection errors, we might show a database name in the  
message that's not the one we actually tried to connect to, if the  
database was taken from libpq defaults instead of from user parameters.  
Fix such error messages to use PQdb(), which reports the correct name.  
  
(But, per commit 2930c05634bc, make sure not to try to print NULL.)  
  
Apply to branches 9.5 through 13.  Branch master has already been  
changed differently by commit 58cd8dca3de0.  
  
Reported-by: Robert Haas <[email protected]>  
Discussion: https://postgr.es/m/CA+TgmobssJ6rS22dspWnu-oDxXevGmhMD8VcRBjmj-b9UDqRjw@mail.gmail.com  

M contrib/oid2name/oid2name.c
M contrib/vacuumlo/vacuumlo.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pgbench/pgbench.c

Code review for psql's helpSQL() function.

commit   : 131825cd50a898b91e43e82cdd971032ef32b3b3    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 26 Jan 2021 13:04:52 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 26 Jan 2021 13:04:52 -0500    

Click here for diff

The loops to identify word boundaries could access past the end of  
the input string.  Likely that would never result in an actual  
crash, but it makes valgrind unhappy.  
  
The logic to try different numbers of words didn't work when the  
input has two words but we only have a match to the first, eg  
"\h with select".  (We must "continue" the pass loop, not "break".)  
  
The logic to compute nl_count was bizarrely managed, and in at  
least two code paths could end up calling PageOutput with  
nl_count = 0, resulting in failing to paginate output that should  
have been fed to the pager.  Also, in v12 and up, the nl_count  
calculation hadn't been updated to account for the addition of a URL.  
  
The PQExpBuffer holding the command syntax details wasn't freed,  
resulting in a session-lifespan memory leak.  
  
While here, improve some comments, choose a more descriptive name  
for a variable, fix inconsistent datatype choice for another variable.  
  
Per bug #16837 from Alexander Lakhin.  This code is very old,  
so back-patch to all supported branches.  
  
Kyotaro Horiguchi and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/psql/help.c

Fix broken ruleutils support for function TRANSFORM clauses.

commit   : 41309f716ef5dbe6c3399f448e25f0ec2d23fa3c    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 25 Jan 2021 13:03:12 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 25 Jan 2021 13:03:12 -0500    

Click here for diff

I chanced to notice that this dumped core due to a faulty Assert.  
To add insult to injury, the output has been misformatted since v11.  
Obviously we need some regression testing here.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/hstore_plpython/expected/hstore_plpython.out
M contrib/hstore_plpython/sql/hstore_plpython.sql
M src/backend/utils/fmgr/funcapi.c

Fix hypothetical bug in heap backward scans

commit   : 9b1f8af47e359e3f17177a9c18b3750add407e03    
  
author   : David Rowley <[email protected]>    
date     : Mon, 25 Jan 2021 20:01:34 +1300    
  
committer: David Rowley <[email protected]>    
date     : Mon, 25 Jan 2021 20:01:34 +1300    

Click here for diff

Both heapgettup() and heapgettup_pagemode() incorrectly set the first page  
to scan in a backward scan in which the number of pages to scan was  
specified by heap_setscanlimits().  The code incorrectly started the scan  
at the end of the relation when startBlk was 0, or otherwise at  
startBlk - 1, neither of which is correct when only scanning a subset of  
pages.  
  
The fix here checks if heap_setscanlimits() has changed the number of  
pages to scan and if so we set the first page to scan as the final page in  
the specified range during backward scans.  
  
Proper adjustment of this code was forgotten when heap_setscanlimits() was  
added in 7516f5259 back in 9.5.  However, practice, nowhere in core code  
performs backward scans after having used heap_setscanlimits(), yet, it is  
possible an extension uses the heap functions in this way, hence  
backpatch.  
  
An upcoming patch does use heap_setscanlimits() with backward scans, so  
this must be fixed before that can go in.  
  
Author: David Rowley  
Discussion: https://postgr.es/m/CAApHDvpGc9h0_oVD2CtgBcxCS1N-qDYZSeBRnUh+0CWJA9cMaA@mail.gmail.com  
Backpatch-through: 9.5, all supported versions  

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

Update time zone data files to tzdata release 2021a.

commit   : c26a0865d6367f46823182a90f45e6a304f75230    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 24 Jan 2021 16:29:48 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 24 Jan 2021 16:29:48 -0500    

Click here for diff

DST law changes in Russia (Volgograd zone) and South Sudan.  
Historical corrections for Australia, Bahamas, Belize, Bermuda,  
Ghana, Israel, Kenya, Nigeria, Palestine, Seychelles, and Vanuatu.  
Notably, the Australia/Currie zone has been corrected to the point  
where it is identical to Australia/Hobart.  

M src/timezone/data/tzdata.zi

Make check-prepared-txns use temp-install binaries.

commit   : 16b435eaa653359cb8f57048848abeb868549145    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 23 Jan 2021 14:09:59 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 23 Jan 2021 14:09:59 -0800    

Click here for diff

It tested the installed binaries.  This fixes 9.6 and 9.5 to follow  
later versions and "make -C src/test/isolation check" in this respect.  

M src/test/isolation/Makefile

Doc: improve directions for building on macOS.

commit   : 2cdce1e8484b56dd8b163301aace950834471150    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 22 Jan 2021 18:58:25 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 22 Jan 2021 18:58:25 -0500    

Click here for diff

In light of recent discussions, we should instruct people to  
install Apple's command line tools; installing Xcode is secondary.  
  
Also, fix sample command for finding out the default sysroot,  
as we now know that the command originally recommended can give  
a result that doesn't match your OS version.  
  
Also document the workaround to use if you really don't want  
configure to select a sysroot at all.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/installation.sgml

Further tweaking of PG_SYSROOT heuristics for macOS.

commit   : 175f716a8f37c0325cc3f683dad242536f9515d0    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 20 Jan 2021 12:07:23 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 20 Jan 2021 12:07:23 -0500    

Click here for diff

It emerges that in some phases of the moon (perhaps to do with  
directory entry order?), xcrun will report that the SDK path is  
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk  
which is normally a symlink to a version-numbered sibling directory.  
Our heuristic to skip non-version-numbered pathnames was rejecting  
that, which is the wrong thing to do.  We'd still like to end up  
with a version-numbered PG_SYSROOT value, but we can have that by  
dereferencing the symlink.  
  
Like the previous fix, back-patch to all supported versions.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/template/darwin

Fix ALTER DEFAULT PRIVILEGES with duplicated objects

commit   : 0ddb529cf3e25afd94abf85aa3688b9d9063897c    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 20 Jan 2021 11:39:35 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 20 Jan 2021 11:39:35 +0900    

Click here for diff

Specifying duplicated objects in this command would lead to unique  
constraint violations in pg_default_acl or "tuple already updated by  
self" errors.  Similarly to GRANT/REVOKE, increment the command ID after  
each subcommand processing to allow this case to work transparently.  
  
A regression test is added by tweaking one of the existing queries of  
privileges.sql to stress this case.  
  
Reported-by: Andrus  
Author: Michael Paquier  
Reviewed-by: Álvaro Herrera  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M src/backend/catalog/aclchk.c
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Remove faulty support for MergeAppend plan with WHERE CURRENT OF.

commit   : 0ab177bec1c546d2b98b5934a817b23bcc335ca9    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 19 Jan 2021 13:25:33 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 19 Jan 2021 13:25:33 -0500    

Click here for diff

Somebody extended search_plan_tree() to treat MergeAppend exactly  
like Append, which is 100% wrong, because unlike Append we can't  
assume that only one input node is actively returning tuples.  
Hence a cursor using a MergeAppend across a UNION ALL or inheritance  
tree could falsely match a WHERE CURRENT OF query at a row that  
isn't actually the cursor's current output row, but coincidentally  
has the same TID (in a different table) as the current output row.  
  
Delete the faulty code; this means that such a case will now return  
an error like 'cursor "foo" is not a simply updatable scan of table  
"bar"', instead of silently misbehaving.  Users should not find that  
surprising though, as the same cursor query could have failed that way  
already depending on the chosen plan.  (It would fail like that if the  
sort were done with an explicit Sort node instead of MergeAppend.)  
  
Expand the clearly-inadequate commentary to be more explicit about  
what this code is doing, in hopes of forestalling future mistakes.  
  
It's been like this for awhile, so back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execCurrent.c

Avoid crash with WHERE CURRENT OF and a custom scan plan.

commit   : 33a46993f15a1232ccd83ac70f41935bb7313566    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 18 Jan 2021 18:32:30 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 18 Jan 2021 18:32:30 -0500    

Click here for diff

execCurrent.c's search_plan_tree() assumed that ForeignScanStates  
and CustomScanStates necessarily have a valid ss_currentRelation.  
This is demonstrably untrue for postgres_fdw's remote join and  
remote aggregation plans, and non-leaf custom scans might not have  
an identifiable scan relation either.  Avoid crashing by ignoring  
such nodes when the field is null.  
  
This solution will lead to errors like 'cursor "foo" is not a  
simply updatable scan of table "bar"' in cases where maybe we  
could have allowed WHERE CURRENT OF to work.  That's not an issue  
for postgres_fdw's usages, since joins or aggregations would render  
WHERE CURRENT OF invalid anyway.  But an otherwise-transparent  
upper level custom scan node might find this annoying.  When and if  
someone cares to expend work on such a scenario, we could invent a  
custom-scan-provider callback to determine what's safe.  
  
Report and patch by David Geier, commentary by me.  It's been like  
this for awhile, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execCurrent.c

Prevent excess SimpleLruTruncate() deletion.

commit   : c424c75f5382c43ed334e7bb4f74cbfea4425df5    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 16 Jan 2021 12:21:35 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 16 Jan 2021 12:21:35 -0800    

Click here for diff

Every core SLRU wraps around.  With the exception of pg_notify, the wrap  
point can fall in the middle of a page.  Account for this in the  
PagePrecedes callback specification and in SimpleLruTruncate()'s use of  
said callback.  Update each callback implementation to fit the new  
specification.  This changes SerialPagePrecedesLogically() from the  
style of asyncQueuePagePrecedes() to the style of CLOGPagePrecedes().  
(Whereas pg_clog and pg_serial share a key space, pg_serial is nothing  
like pg_notify.)  The bug fixed here has the same symptoms and user  
followup steps as 592a589a04bd456410b853d86bd05faa9432cbbb.  Back-patch  
to 9.5 (all supported versions).  
  
Reviewed by Andrey Borodin and (in earlier versions) by Tom Lane.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/clog.c
M src/backend/access/transam/commit_ts.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/slru.c
M src/backend/access/transam/subtrans.c
M src/backend/commands/async.c
M src/backend/storage/lmgr/predicate.c
M src/include/access/slru.h

Improve our heuristic for selecting PG_SYSROOT on macOS.

commit   : 3934543c2bb082adce8285789993f5ef732f044d    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 15 Jan 2021 11:28:51 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 15 Jan 2021 11:28:51 -0500    

Click here for diff

In cases where Xcode is newer than the underlying macOS version,  
asking xcodebuild for the SDK path will produce a pointer to the  
SDK shipped with Xcode, which may end up building code that does  
not work on the underlying macOS version.  It appears that in  
such cases, xcodebuild's answer also fails to match the default  
behavior of Apple's compiler: assuming one has installed Xcode's  
"command line tools", there will be an SDK for the OS's own version  
in /Library/Developer/CommandLineTools, and the compiler will  
default to using that.  This is all pretty poorly documented,  
but experimentation suggests that "xcrun --show-sdk-path" gives  
the sysroot path that the compiler is actually using, at least  
in some cases.  Hence, try that first, but revert to xcodebuild  
if xcrun fails (in very old Xcode, it is missing or lacks the  
--show-sdk-path switch).  
  
Also, "xcrun --show-sdk-path" may give a path that is valid but lacks  
any OS version identifier.  We don't really want that, since most  
of the motivation for wiring -isysroot into the build flags at all  
is to ensure that all parts of a PG installation are built against  
the same SDK, even when considering extensions built later and/or on  
a different machine.  Insist on finding "N.N" in the directory name  
before accepting the result.  (Adding "--sdk macosx" to the xcrun  
call seems to produce the same answer as xcodebuild, but usually  
more quickly because it's cached, so we also try that as a fallback.)  
  
The core reason why we don't want to use Xcode's default SDK in cases  
like this is that Apple's technology for introducing new syscalls  
does not play nice with Autoconf: for example, configure will think  
that preadv/pwritev exist when using a Big Sur SDK, even when building  
on an older macOS version where they don't exist.  It'd be nice to  
have a better solution to that problem, but this patch doesn't attempt  
to fix that.  
  
Per report from Sergey Shinderuk.  Back-patch to all supported versions.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/template/darwin

Doc: clarify behavior of back-half options in pg_dump.

commit   : 2d19f13773cac817ff254954142a458a256e8232    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 13 Jan 2021 13:30:04 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 13 Jan 2021 13:30:04 -0500    

Click here for diff

Options that change how the archive data is converted to SQL text  
are ignored when dumping to archive formats.  The documentation  
previously said "not meaningful", which is not helpful.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/pg_dump.sgml

Fix memory leak in SnapBuildSerialize.

commit   : 4bccceaa9179bffbe3469909e28ce4ded34f0a09    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 13 Jan 2021 08:31:45 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 13 Jan 2021 08:31:45 +0530    

Click here for diff

The memory for the snapshot was leaked while serializing it to disk during  
logical decoding. This memory will be freed only once walsender stops  
streaming the changes. This can lead to a huge memory increase when master  
logs Standby Snapshot too frequently say when the user is trying to create  
many replication slots.  
  
Reported-by: [email protected]  
Diagnosed-by: [email protected]  
Author: Amit Kapila  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/[email protected]  

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

Fix thinko in comment

commit   : a8bb366ad0e5c422622ee00d5e3105f8451deb62    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 12 Jan 2021 11:48:45 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 12 Jan 2021 11:48:45 -0300    

Click here for diff

This comment has been wrong since its introduction in commit  
2c03216d8311.  
  
Author: Masahiko Sawada <[email protected]>  
Discussion: https://postgr.es/m/CAD21AoAzz6qipFJBbGEaHmyWxvvNDp8httbwLR9tUQWaTjUs2Q@mail.gmail.com  

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

doc: expand description of how non-SELECT queries are processed

commit   : 7bf325c1fe56a0c5de0e5603910209e8bbb8e8c6    
  
author   : Bruce Momjian <[email protected]>    
date     : Sat, 9 Jan 2021 12:11:15 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Sat, 9 Jan 2021 12:11:15 -0500    

Click here for diff

The previous description of how the executor processes non-SELECT  
queries was very dense, causing lack of clarity.  This expanded text  
spells it out more simply.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/arch-dev.sgml

Fix ancient bug in parsing of BRE-mode regular expressions.

commit   : 0c23f30fad2919eb53964fa348ede60e504b5c1e    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 8 Jan 2021 12:16:00 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 8 Jan 2021 12:16:00 -0500    

Click here for diff

brenext(), when parsing a '*' quantifier, forgot to return any "value"  
for the token; per the equivalent case in next(), it should return  
value 1 to indicate that greedy rather than non-greedy behavior is  
wanted.  The result is that the compiled regexp could behave like 'x*?'  
rather than the intended 'x*', if we were unlucky enough to have  
a zero in v->nextvalue at this point.  That seems to happen with some  
reliability if we have '.*' at the beginning of a BRE-mode regexp,  
although that depends on the initial contents of a stack-allocated  
struct, so it's not guaranteed to fail.  
  
Found by Alexander Lakhin using valgrind testing.  This bug seems  
to be aboriginal in Spencer's code, so back-patch all the way.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/regex/regc_lex.c

doc: improve NLS instruction wording

commit   : 155bfbb543c220b3239ac8fc88e3de472f43e57a    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 5 Jan 2021 14:26:37 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 5 Jan 2021 14:26:37 -0500    

Click here for diff

Reported-by: "Tang, Haiying"  
  
Discussion: https://postgr.es/m/bbbccf7a3c2d436e85d45869d612fd6b@G08CNEXMBPEKD05.g08.fujitsu.local  
  
Author: "Tang, Haiying"  
  
Backpatch-through: 9.5  

M doc/src/sgml/nls.sgml

commit   : 651a557b8c6a93606fd0bc8c5ed84d0cfbe8b4fd    
  
author   : Bruce Momjian <[email protected]>    
date     : Sat, 2 Jan 2021 13:06:24 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Sat, 2 Jan 2021 13:06:24 -0500    

Click here for diff

Backpatch-through: 9.5  

M COPYRIGHT
M doc/src/sgml/legal.sgml

Doc: improve explanation of EXTRACT(EPOCH) for timestamp without tz.

commit   : 4a4cad91dab75ce25bbe4bf6b27a88b94a7eac45    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 1 Jan 2021 15:51:09 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 1 Jan 2021 15:51:09 -0500    

Click here for diff

Try to be clearer about what computation is actually happening here.  
  
Per bug #16797 from Dana Burd.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml

Doc: spell out comparison behaviors for the date/time types.

commit   : 7fe23c8bb5d2de892796594a66bc7a3292c6302c    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 30 Dec 2020 17:48:43 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 30 Dec 2020 17:48:43 -0500    

Click here for diff

The behavior of cross-type comparisons among date/time data types was  
not really explained anywhere.  You could probably infer it if you  
recognized the applicability of comments elsewhere about datatype  
conversions, but it seems worthy of explicit documentation.  
  
Per bug #16797 from Dana Burd.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml

doc: Improve some grammar and sentences

commit   : d46eb10c06f411fc370e8255c03ec01c8e49c5f2    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 29 Dec 2020 18:19:30 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 29 Dec 2020 18:19:30 +0900    

Click here for diff

90fbf7c has taken care of that for HEAD.  This includes the portion of  
the fixes that applies to the documentation, where needed depending on  
the branch.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M doc/src/sgml/ref/pg_dump.sgml

Fix inconsistent code with shared invalidations of snapshots

commit   : 8fcc2fb98064adfe6b14f6ac6964c59f5ace09cd    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 28 Dec 2020 22:17:24 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 28 Dec 2020 22:17:24 +0900    

Click here for diff

The code in charge of processing a single invalidation message has been  
using since 568d413 the structure for relation mapping messages.  This  
had fortunately no consequence as both locate the database ID at the  
same location, but it could become a problem in the future if this area  
of the code changes.  
  
Author: Konstantin Knizhnik  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M src/backend/utils/cache/inval.c

postgres_fdw: Fix connection leak.

commit   : b5c73eef8adf5e722564c7e512de761b1a08bfe2    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 28 Dec 2020 20:01:31 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 28 Dec 2020 20:01:31 +0900    

Click here for diff

In postgres_fdw, the cached connections to foreign servers will not be  
closed until the local session exits if the user mappings or foreign servers  
that those connections depend on are dropped. Those connections can be  
leaked.  
  
To fix that connection leak issue, after a change to a pg_foreign_server  
or pg_user_mapping catalog entry, this commit makes postgres_fdw close  
the connections depending on that entry immediately if current  
transaction has not used those connections yet. Otherwise, mark those  
connections as invalid and then close them at the end of current transaction,  
since they cannot be closed in the midst of the transaction using them.  
Closed connections will be remade at the next opportunity if necessary.  
  
Back-patch to all supported branches.  
  
Author: Bharath Rupireddy  
Reviewed-by: Zhihong Yu, Zhijie Hou, Fujii Masao  
Discussion: https://postgr.es/m/CALj2ACVNcGH_6qLY-4_tXz8JLvA+4yeBThRfxMz7Oxbk1aHcpQ@mail.gmail.com  

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

Fix back-patch of "Invalidate acl.c caches when pg_authid changes."

commit   : 14649bf502eb36d85fb9e78981651942a683162b    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 25 Dec 2020 11:02:56 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 25 Dec 2020 11:02:56 -0800    

Click here for diff

Test script role names and error messages differed in v10, 9.6 and 9.5.  
  
Discussion: https://postgr.es/m/[email protected]  

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

Invalidate acl.c caches when pg_authid changes.

commit   : 90383a613b48925f9dbc4ca325a1234956baddab    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 25 Dec 2020 10:41:59 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 25 Dec 2020 10:41:59 -0800    

Click here for diff

This makes existing sessions reflect "ALTER ROLE ... [NO]INHERIT" as  
quickly as they have been reflecting "GRANT role_name".  Back-patch to  
9.5 (all supported versions).  
  
Reviewed by Nathan Bossart.  
  
Discussion: https://postgr.es/m/[email protected]  

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

Remove "invalid concatenation of jsonb objects" error case.

commit   : edcdbc44eed2eae5c7b40a051998e32ecf4f8f12    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 21 Dec 2020 13:11:30 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 21 Dec 2020 13:11:30 -0500    

Click here for diff

The jsonb || jsonb operator arbitrarily rejected certain combinations  
of scalar and non-scalar inputs, while being willing to concatenate  
other combinations.  This was of course quite undocumented.  Rather  
than trying to document it, let's just remove the restriction,  
creating a uniform rule that unless we are handling an object-to-object  
concatenation, non-array inputs are converted to one-element arrays,  
resulting in an array-to-array concatenation.  (This does not change  
the behavior for any case that didn't throw an error before.)  
  
Per complaint from Joel Jacobson.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/utils/adt/jsonfuncs.c
M src/test/regress/expected/jsonb.out
M src/test/regress/sql/jsonb.sql

Doc: fix description of how to use src/tutorial files.

commit   : 7414a0517e82c66795929275899d66a24acd39a8    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 20 Dec 2020 15:28:22 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 20 Dec 2020 15:28:22 -0500    

Click here for diff

The separate "cd" command before invoking psql made sense (or at least  
I thought so) when it was added in commit ed1939332.  But 4e3a61635  
removed the supporting text that explained when to use it, making it  
just confusing.  So drop it.  
  
Also switch from four-dot to three-dot filler for the unsupplied  
part of the path, since at least one person has read the four-dot  
filler as a typo for "../..".  And fix these/those inconsistency.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/query.sgml

Avoid memcpy() with same source and destination during relmapper init.

commit   : 94aaa79afe656e6845d3c8af0befa8922edae0e8    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 18 Dec 2020 15:46:44 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 18 Dec 2020 15:46:44 -0500    

Click here for diff

A narrow reading of the C standard says that memcpy(x,x,n) is undefined,  
although it's hard to envision an implementation that would really  
misbehave.  However, analysis tools such as valgrind might whine about  
this; accordingly, let's band-aid relmapper.c to not do it.  
  
See also 5b630501e, d3f4e8a8a, ad7b48ea0, and other similar fixes.  
Apparently, none of those folk tried valgrinding initdb?  This has been  
like this for long enough that I'm surprised it hasn't been reported  
before.  
  
Back-patch, just in case anybody wants to use a back branch on a platform  
that complains about this; we back-patched those earlier fixes too.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/cache/relmapper.c

Use native methods to open input in TestLib::slurp_file on Windows.

commit   : da7edca4630c5bcf7c0f0f5819ab6fb020d3c845    
  
author   : Andrew Dunstan <[email protected]>    
date     : Tue, 15 Dec 2020 10:00:18 -0500    
  
committer: Andrew Dunstan <[email protected]>    
date     : Tue, 15 Dec 2020 10:00:18 -0500    

Click here for diff

This is a backport of commits 114541d58e and 6f59826f0 to the remaining  
live branches.  

M src/test/perl/TestLib.pm

Revert "Cannot use WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE."

commit   : 133a0906d5bf529ac2898c24b98ed87db1c6284d    
  
author   : Jeff Davis <[email protected]>    
date     : Mon, 14 Dec 2020 23:50:20 -0800    
  
committer: Jeff Davis <[email protected]>    
date     : Mon, 14 Dec 2020 23:50:20 -0800    

Click here for diff

This reverts commit 3a9e64aa0d96c8ffb6c682b082d0f72b1d373327.  
  
Commit 4bad60e3 fixed the root of the problem that 3a9e64aa worked  
around.  
  
This enables proper pipelining of commands after terminating  
replication, eliminating an undocumented limitation.  
  
Discussion: https://postgr.es/m/3d57bc29-4459-578b-79cb-7641baf53c57%40iki.fi  
Backpatch-through: 9.5  

M src/backend/replication/walsender.c

initdb: complete getopt_long alphabetization

commit   : da214247de1d566709bff0420dd8024fd9fa0d10    
  
author   : Bruce Momjian <[email protected]>    
date     : Sat, 12 Dec 2020 12:59:09 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Sat, 12 Dec 2020 12:59:09 -0500    

Click here for diff

Backpatch-through: 9.5  

M src/bin/initdb/initdb.c

initdb: properly alphabetize getopt_long options in C string

commit   : ccbe536776f599cf3f709c60543222f1840e9d5d    
  
author   : Bruce Momjian <[email protected]>    
date     : Sat, 12 Dec 2020 12:51:16 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Sat, 12 Dec 2020 12:51:16 -0500    

Click here for diff

Backpatch-through: 9.5  

M src/bin/initdb/initdb.c

Doc: clarify that CREATE TABLE discards redundant unique constraints.

commit   : 14db9579222138b3fba2f73c285ff3f9e4bf9465    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 8 Dec 2020 13:09:48 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 8 Dec 2020 13:09:48 -0500    

Click here for diff

The SQL standard says that redundant unique constraints are disallowed,  
but we long ago decided that throwing an error would be too  
user-unfriendly, so we just drop redundant ones.  The docs weren't very  
clear about that though, as this behavior was only explained for PRIMARY  
KEY vs UNIQUE, not UNIQUE vs UNIQUE.  
  
While here, I couldn't resist doing some copy-editing and markup-fixing  
on the adjacent text about INCLUDE options.  
  
Per bug #16767 from Matthias vd Meent.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/create_table.sgml

Doc: explain that the string types can't store \0 (ASCII NUL).

commit   : 0921b86ca1e451c70642c3007feb25f7efb34f65    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 8 Dec 2020 12:06:19 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 8 Dec 2020 12:06:19 -0500    

Click here for diff

This restriction was mentioned in connection with string literals,  
but it wasn't made clear that it's a general restriction not just  
a syntactic limitation in query strings.  
  
Per unsigned documentation comment.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/datatype.sgml

pgcrypto: Detect errors with EVP calls from OpenSSL

commit   : f95d9fd8153cb1b7da55f425bf217482e4943d2e    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 8 Dec 2020 15:23:02 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 8 Dec 2020 15:23:02 +0900    

Click here for diff

The following routines are called within pgcrypto when handling digests  
but there were no checks for failures:  
- EVP_MD_CTX_size (can fail with -1 as of 3.0.0)  
- EVP_MD_CTX_block_size (can fail with -1 as of 3.0.0)  
- EVP_DigestInit_ex  
- EVP_DigestUpdate  
- EVP_DigestFinal_ex  
  
A set of elog(ERROR) is added by this commit to detect such failures,  
that should never happen except in the event of a processing failure  
internal to OpenSSL.  
  
Note that it would be possible to use ERR_reason_error_string() to get  
more context about such errors, but these refer mainly to the internals  
of OpenSSL, so it is not really obvious how useful that would be.  This  
is left out for simplicity.  
  
Per report from Coverity.  Thanks to Tom Lane for the discussion.  
  
Backpatch-through: 9.5  

M contrib/pgcrypto/openssl.c

Fix more race conditions in the newly-added pg_rewind test.

commit   : beb6b45ab7470b0412edb565eaa6f48683245d47    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 7 Dec 2020 14:44:34 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 7 Dec 2020 14:44:34 +0200    

Click here for diff

pg_rewind looks at the control file to check what timeline a server is on.  
But promotion doesn't immediately write a checkpoint, it merely writes  
an end-of-recovery WAL record. If pg_rewind runs immediately after  
promotion, before the checkpoint has completed, it will think think that  
the server is still on the earlier timeline. We ran into this issue a long  
time ago already, see commit 484a848a73f.  
  
It's a bit bogus that pg_rewind doesn't determine the timeline correctly  
until the end-of-recovery checkpoint has completed. We probably should  
fix that. But for now work around it by waiting for the checkpoint  
to complete before running pg_rewind, like we did in commit 484a848a73f.  
  
In the passing, tidy up the new test a little bit. Rerder the INSERTs so  
that the comments make more sense, remove a spurious CHECKPOINT call after  
pg_rewind has already run, and add --debug option, so that if this fails  
again, we'll have more data.  
  
Per buildfarm failure at https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=rorqual&dt=2020-12-06%2018%3A32%3A19&stg=pg_rewind-check.  
Backpatch to all supported versions.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/bin/pg_rewind/t/008_min_recovery_point.pl

Fix race conditions in newly-added test.

commit   : 1dd608bbac28a5dfcaade0ffb56f0dc4f61f7320    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 4 Dec 2020 18:20:18 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 4 Dec 2020 18:20:18 +0200    

Click here for diff

Buildfarm has been failing sporadically on the new test.  I was able to  
reproduce this by adding a random 0-10 s delay in the walreceiver, just  
before it connects to the primary. There's a race condition where node_3  
is promoted before it has fully caught up with node_1, leading to diverged  
timelines. When node_1 is later reconfigured as standby following node_3,  
it fails to catch up:  
  
LOG:  primary server contains no more WAL on requested timeline 1  
LOG:  new timeline 2 forked off current database system timeline 1 before current recovery point 0/30000A0  
  
That's the situation where you'd need to use pg_rewind, but in this case  
it happens already when we are just setting up the actual pg_rewind  
scenario we want to test, so change the test so that it waits until  
node_3 is connected and fully caught up before promoting it, so that you  
get a clean, controlled failover.  
  
Also rewrite some of the comments, for clarity. The existing comments  
detailed what each step in the test did, but didn't give a good overview  
of the situation the steps were trying to create.  
  
For reasons I don't understand, the test setup had to be written slightly  
differently in 9.6 and 9.5 than in later versions. The 9.5/9.6 version  
needed node 1 to be reinitialized from backup, whereas in later versions  
it could be shut down and reconfigured to be a standby. But even 9.5 should  
support "clean switchover", where primary makes sure that pending WAL is  
replicated to standby on shutdown. It would be nice to figure out what's  
going on there, but that's independent of pg_rewind and the scenario that  
this test tests.  
  
Discussion: https://www.postgresql.org/message-id/b0a3b95b-82d2-6089-6892-40570f8c5e60%40iki.fi  

M src/bin/pg_rewind/t/008_min_recovery_point.pl

docs: list single-letter options first in command-line summary

commit   : 47c4843a03cac9c35d97ddc42868b157731d2032    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 3 Dec 2020 10:28:58 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 3 Dec 2020 10:28:58 -0500    

Click here for diff

In a few places, the long-version options were listed before the  
single-letter ones in the command summary of a few commands.  This  
didn't match other commands, and didn't match the option ordering later  
in the same reference page.  
  
Backpatch-through: 9.5  

M doc/src/sgml/ref/reindexdb.sgml
M doc/src/sgml/ref/vacuumdb.sgml

Fix pg_rewind bugs when rewinding a standby server.

commit   : 81e3c868f891bf291a3ad38d81b04096146c2f6f    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 3 Dec 2020 15:57:48 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 3 Dec 2020 15:57:48 +0200    

Click here for diff

If the target is a standby server, its WAL doesn't end at the last  
checkpoint record, but at minRecoveryPoint. We must scan all the  
WAL from the last common checkpoint all the way up to minRecoveryPoint  
for modified pages, and also consider that portion when determining  
whether the server needs rewinding.  
  
Backpatch to all supported versions.  
  
Author: Ian Barwick and me  
Discussion: https://www.postgresql.org/message-id/CABvVfJU-LDWvoz4-Yow3Ay5LZYTuPD7eSjjE4kGyNZpXC6FrVQ%40mail.gmail.com  

M src/bin/pg_rewind/parsexlog.c
M src/bin/pg_rewind/pg_rewind.c
A src/bin/pg_rewind/t/008_min_recovery_point.pl

Ensure that expandTableLikeClause() re-examines the same table.

commit   : fb500296dfa6cffdd4dfdc8175e2173c6074f20a    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 1 Dec 2020 14:02:28 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 1 Dec 2020 14:02:28 -0500    

Click here for diff

As it stood, expandTableLikeClause() re-did the same relation_openrv  
call that transformTableLikeClause() had done.  However there are  
scenarios where this would not find the same table as expected.  
We hold lock on the LIKE source table, so it can't be renamed or  
dropped, but another table could appear before it in the search path.  
This explains the odd behavior reported in bug #16758 when cloning a  
table as a temp table of the same name.  This case worked as expected  
before commit 502898192 introduced the need to open the source table  
twice, so we should fix it.  
  
To make really sure we get the same table, let's re-open it by OID not  
name.  That requires adding an OID field to struct TableLikeClause,  
which is a little nervous-making from an ABI standpoint, but as long  
as it's at the end I don't think there's any serious risk.  
  
Per bug #16758 from Marc Boeren.  Like the previous patch,  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/nodes/copyfuncs.c
M src/backend/nodes/equalfuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/include/nodes/parsenodes.h
M src/test/regress/expected/create_table_like.out
M src/test/regress/sql/create_table_like.sql

Free disk space for dropped relations on commit.

commit   : e00928de8d221435864c8f84421df988c0425ef7    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 1 Dec 2020 13:46:27 +1300    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 1 Dec 2020 13:46:27 +1300    

Click here for diff

When committing a transaction that dropped a relation, we previously  
truncated only the first segment file to free up disk space (the one  
that won't be unlinked until the next checkpoint).  
  
Truncate higher numbered segments too, even though we unlink them on  
commit.  This frees the disk space immediately, even if other backends  
have open file descriptors and might take a long time to get around to  
handling shared invalidation events and closing them.  Also extend the  
same behavior to the first segment, in recovery.  
  
Back-patch to all supported releases.  
  
Bug: #16663  
Reported-by: Denis Patron <[email protected]>  
Reviewed-by: Pavel Borisov <[email protected]>  
Reviewed-by: Neil Chen <[email protected]>  
Reviewed-by: David Zhang <[email protected]>  
Discussion: https://postgr.es/m/16663-fe97ccf9932fc800%40postgresql.org  

M src/backend/storage/smgr/md.c

Document concurrent indexes waiting on each other

commit   : 968a537b432eb19001ad5788023aabe0a009aa16    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 30 Nov 2020 18:24:55 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 30 Nov 2020 18:24:55 -0300    

Click here for diff

Because regular CREATE INDEX commands are independent, and there's no  
logical data dependency, it's not immediately obvious that transactions  
held by concurrent index builds on one table will block the second phase  
of concurrent index creation on an unrelated table, so document this  
caveat.  
  
Backpatch this all the way back.  In branch master, mention that only  
some indexes are involved.  
  
Author: James Coleman <[email protected]>  
Reviewed-by: David Johnston <[email protected]>  
Discussion: https://postgr.es/m/CAAaqYe994=PUrn8CJZ4UEo_S-FfRr_3ogERyhtdgHAb2WG_Ufg@mail.gmail.com  

M doc/src/sgml/ref/create_index.sgml

Fix miscomputation of direct_lateral_relids for join relations.

commit   : 8c5da2d512e3e00c55f3f8fb7af12dfabc5b9284    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 30 Nov 2020 12:22:43 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 30 Nov 2020 12:22:43 -0500    

Click here for diff

If a PlaceHolderVar is to be evaluated at a join relation, but  
its value is only needed there and not at higher levels, we neglected  
to update the joinrel's direct_lateral_relids to include the PHV's  
source rel.  This causes problems because join_is_legal() then won't  
allow joining the joinrel to the PHV's source rel at all, leading  
to "failed to build any N-way joins" planner failures.  
  
Per report from Andreas Seltenreich.  Back-patch to 9.5  
where the problem originated.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/util/placeholder.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Fix recently-introduced breakage in psql's \connect command.

commit   : e2d5de15003d17e2f5c91a5c9151528031a97014    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 29 Nov 2020 15:22:04 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 29 Nov 2020 15:22:04 -0500    

Click here for diff

Through my misreading of what the existing code actually did,  
commits 85c54287a et al. broke psql's behavior for the case where  
"\c connstring" provides a password in the connstring.  We should  
use that password in such a case, but as of 85c54287a we ignored it  
(and instead, prompted for a password).  
  
Commit 94929f1cf fixed that in HEAD, but since I thought it was  
cleaning up a longstanding misbehavior and not one I'd just created,  
I didn't back-patch it.  
  
Hence, back-patch the portions of 94929f1cf having to do with  
password management.  In addition to fixing the introduced bug,  
this means that "\c -reuse-previous=on connstring" will allow  
re-use of an existing connection's password if the connstring  
doesn't change user/host/port.  That didn't happen before, but  
it seems like a bug fix, and anyway I'm loath to have significant  
differences in this code across versions.  
  
Also fix an error with the same root cause about whether or not to  
override a connstring's setting of client_encoding.  As of 85c54287a  
we always did so; restore the previous behavior of overriding only  
when stdin/stdout are a terminal and there's no environment setting  
of PGCLIENTENCODING.  (I find that definition a bit surprising, but  
right now doesn't seem like the time to revisit it.)  
  
Per bug #16746 from Krzysztof Gradek.  As with the previous patch,  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/psql-ref.sgml
M src/bin/psql/command.c

Doc: clarify behavior of PQconnectdbParams().

commit   : 414fb255e55f249f2c5e6d207ef6bd98c460a730    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 29 Nov 2020 13:58:30 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 29 Nov 2020 13:58:30 -0500    

Click here for diff

The documentation omitted the critical tidbit that a keyword-array entry  
is simply ignored if its corresponding value-array entry is NULL or an  
empty string; it will *not* override any previously-obtained value for  
the parameter.  (See conninfo_array_parse().)  I'd supposed that would  
force the setting back to default, which is what led me into bug #16746;  
but it doesn't.  
  
While here, I couldn't resist the temptation to do some copy-editing,  
both in the description of PQconnectdbParams() and in the section  
about connection URI syntax.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/libpq.sgml

Fix a recently-introduced race condition in LISTEN/NOTIFY handling.

commit   : 60d6c71430f9f95021f8da5064d5aa47015f7575    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 28 Nov 2020 14:03:40 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 28 Nov 2020 14:03:40 -0500    

Click here for diff

Commit 566372b3d fixed some race conditions involving concurrent  
SimpleLruTruncate calls, but it introduced new ones in async.c.  
A newly-listening backend could attempt to read Notify SLRU pages that  
were in process of being truncated, possibly causing an error.  Also,  
the QUEUE_TAIL pointer could become set to a value that's not equal to  
the queue position of any backend.  While that's fairly harmless in  
v13 and up (thanks to commit 51004c717), in older branches it resulted  
in near-permanent disabling of the queue truncation logic, so that  
continued use of NOTIFY led to queue-fill warnings and eventual  
inability to send any more notifies.  (A server restart is enough to  
make that go away, but it's still pretty unpleasant.)  
  
The core of the problem is confusion about whether QUEUE_TAIL  
represents the "logical" tail of the queue (i.e., the oldest  
still-interesting data) or the "physical" tail (the oldest data we've  
not yet truncated away).  To fix, split that into two variables.  
QUEUE_TAIL regains its definition as the logical tail, and we  
introduce a new variable to track the oldest un-truncated page.  
  
Per report from Mikael Gustavsson.  Like the previous patch,  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/async.c

doc: Fix typos

commit   : 796f57d21697b2a9addfebae9d0182f2539b883e    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 25 Nov 2020 09:49:00 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 25 Nov 2020 09:49:00 +0100    

Click here for diff

Author: Justin Pryzby <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M doc/src/sgml/contrib.sgml

Properly check index mark/restore in ExecSupportsMarkRestore.

commit   : 59ed45e278b78dbfae1b02ad90eee3d01ddec929    
  
author   : Andrew Gierth <[email protected]>    
date     : Tue, 24 Nov 2020 20:58:32 +0000    
  
committer: Andrew Gierth <[email protected]>    
date     : Tue, 24 Nov 2020 20:58:32 +0000    

Click here for diff

Previously this code assumed that all IndexScan nodes supported  
mark/restore, which is not true since it depends on optional index AM  
support functions. This could lead to errors about missing support  
functions in rare edge cases of mergejoins with no sort keys, where an  
unordered non-btree index scan was placed on the inner path without a  
protecting Materialize node. (Normally, the fact that merge join  
requires ordered input would avoid this error.)  
  
Backpatch all the way since this bug is ancient.  
  
Per report from Eugen Konkov on irc.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execAmi.c
M src/backend/optimizer/util/plancat.c
M src/include/nodes/relation.h

Skip allocating hash table in EXPLAIN-only mode.

commit   : ded7db4c1dddcead3184b17619ddc5c203db42fe    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 20 Nov 2020 14:41:14 +0200    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 20 Nov 2020 14:41:14 +0200    

Click here for diff

This is a backpatch of commit 2cccb627f1, backpatched due to popular  
demand. Backpatch to all supported versions.  
  
Author: Alexey Bashtanov  
Discussion: https://www.postgresql.org/message-id/36823f65-050d-ae24-aa4d-a37726998240%40imap.cc  

M src/backend/executor/nodeAgg.c

commit   : 2bb8c0f1d94dd4b2d23ae56b2f5ebec785d2df7b    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 20 Nov 2020 00:58:26 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 20 Nov 2020 00:58:26 -0500    

Click here for diff

We previously put the -isysroot switch only into CPPFLAGS, theorizing  
that it was only needed to find the right copies of include files.  
However, it seems that we also need to use it while linking programs,  
to find the right stub ".tbd" files for libraries.  We got away  
without that up to now, but apparently that was mostly luck.  It may  
also be that failures are only observed when the Xcode version is  
noticeably out of sync with the host macOS version; the case that's  
prompting action right now is that builds fail when using latest Xcode  
(12.2) on macOS Catalina, even though it's fine on Big Sur.  
  
Hence, add -isysroot to LDFLAGS as well.  (It seems that the more  
common practice is to put it in CFLAGS, whence it'd be included at  
both compile and link steps.  However, we can't mess with CFLAGS in  
the platform template file without confusing configure's logic for  
choosing default CFLAGS.)  
  
Back-patch of 49407dc32 into all supported branches.  
  
Report and patch by James Hilliard (some cosmetic mods by me)  
  
Discussion: https://postgr.es/m/[email protected]  

M configure
M configure.in
M src/template/darwin

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

commit   : 6631d5f261e9fdc2ccc2a81214a45865d6e59122    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 19 Nov 2020 15:03:17 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 19 Nov 2020 15:03:17 -0500    

Click here for diff

Commit 502898192 was too careless about the order of execution of the  
additional ALTER TABLE operations generated by expandTableLikeClause.  
It just stuck them all at the end, which seems okay for most purposes.  
But it falls down in the case where LIKE is importing a primary key  
or unique index and the outer CREATE TABLE includes a FOREIGN KEY  
constraint that needs to depend on that index.  Weird as that is,  
it used to work, so we ought to keep it working.  
  
To fix, make parse_utilcmd.c insert LIKE clauses between index-creation  
and FK-creation commands in the transformed list of commands, and change  
utility.c so that the commands generated by expandTableLikeClause are  
executed immediately not at the end.  One could imagine scenarios where  
this wouldn't work either; but currently expandTableLikeClause only  
makes column default expressions, CHECK constraints, and indexes, and  
this ordering seems fine for those.  
  
Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/parser/parse_utilcmd.c
M src/backend/tcop/utility.c
M src/test/regress/expected/create_table_like.out
M src/test/regress/sql/create_table_like.sql

Don't Insert() a VFD entry until it's fully built.

commit   : d02dbbadb7cc7a3c70803c3b77a448b355ecb85b    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 16 Nov 2020 20:32:35 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 16 Nov 2020 20:32:35 -0500    

Click here for diff

Otherwise, if FDDEBUG is enabled, the debugging output fails because  
it tries to read the fileName, which isn't set up yet (and should in  
fact always be NULL).  
  
AFAICT, this has been wrong since Berkeley.  Before 96bf88d52,  
it would accidentally fail to crash on platforms where snprintf()  
is forgiving about being passed a NULL pointer for %s; but the  
file name intended to be included in the debug output wouldn't  
ever have shown up.  
  
Report and fix by Greg Nancarrow.  Although this is only visibly  
broken in custom-made builds, it still seems worth back-patching  
to all supported branches, as the FDDEBUG code is pretty useless  
as it stands.  
  
Discussion: https://postgr.es/m/CAJcOf-cUDgm9qYtC_B6XrC6MktMPNRby2p61EtSGZKnfotMArw@mail.gmail.com  

M src/backend/storage/file/fd.c

doc: update bgwriter description

commit   : a39de0c415fa6f0e215c97e4d587aaa6482174ca    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 13:13:43 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 13:13:43 -0500    

Click here for diff

This clarifies exactly what the bgwriter does, which should help with  
tuning.  
  
Reported-by: Chris Wilson  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/config.sgml

doc: clarify how to find pg_type_d.h in the install tree

commit   : 4dccb5c59ff7f9c6cfd3ddfe7ab98b2d7a2b7e6f    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 12:36:16 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 12:36:16 -0500    

Click here for diff

Followup to patch 152ed04799.  
  
Reported-by: Alvaro Herrera  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/libpq.sgml

doc: adjust expression index analyze working some more

commit   : ba665ed1c2e3386026a8249cdaabf95c4674d716    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 11:14:53 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 11:14:53 -0500    

Click here for diff

This applies the fix bcbd771332 to skipped branches.  
  
Reported-by: Erik Rijkers  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5-11  

M doc/src/sgml/ref/create_index.sgml

doc: improve wording of the need for analyze of exp. indexes

commit   : 6571695d914c19f4d015481deba714866075b5ac    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 10:26:16 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Nov 2020 10:26:16 -0500    

Click here for diff

This is a followup commit on 3370207986.  
  
Reported-by: Justin Pryzby  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/ref/create_index.sgml

doc: clarify where to find pg_type_d.h (PG 11+) and pg_type.h

commit   : be83aeba840a5dc678781151c0560ca9de08d7b3    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 12 Nov 2020 15:13:01 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 12 Nov 2020 15:13:01 -0500    

Click here for diff

These files are in compiled directories and install directories.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/libpq.sgml

docs: mention that expression indexes need analyze

commit   : 3284fe452112c9f15975ebccc73c168ed6892d4f    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 12 Nov 2020 15:00:43 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 12 Nov 2020 15:00:43 -0500    

Click here for diff

Expression indexes can't benefit from pre-computed statistics on  
columns.  
  
Reported-by: Nikolay Samokhvalov  
  
Discussion: https://postgr.es/m/CANNMO++5rw9RDA=p40iMVbMNPaW6O=S0AFzTU=KpYHRpCd1voA@mail.gmail.com  
  
Author: Nikolay Samokhvalov, modified  
  
Backpatch-through: 9.5  

M doc/src/sgml/ref/create_index.sgml

doc: wire protocol data type for history file content is bytea

commit   : fea2b70dd4deccb2c803d94493a164097b0af662    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 12 Nov 2020 14:33:28 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 12 Nov 2020 14:33:28 -0500    

Click here for diff

Document that though the history file content is marked as bytea, it is  
the same a text, and neither is btyea-escaped or encoding converted.  
  
Reported-by: Brar Piening  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 13 - 9.5 (not master)  

M doc/src/sgml/protocol.sgml
M src/backend/replication/walsender.c

pg_trgm: fix crash in 2-item picksplit

commit   : 4b212b7c87754095d4f89b03a3aaec6e32d09342    
  
author   : Andrew Gierth <[email protected]>    
date     : Thu, 12 Nov 2020 14:34:37 +0000    
  
committer: Andrew Gierth <[email protected]>    
date     : Thu, 12 Nov 2020 14:34:37 +0000    

Click here for diff

Whether from size overflow in gistSplit or from secondary splits,  
picksplit is (rarely) called with exactly two items to split.  
  
Formerly, due to special-case handling of the last item, this would  
lead to access to an uninitialized cache entry; prior to PG 13 this  
might have been harmless or at worst led to an incorrect union datum,  
but in 13 onwards it can cause a backend crash from using an  
uninitialized pointer.  
  
Repair by removing the special case, which was deemed not to have been  
appropriate anyway. Backpatch all the way, because this bug has  
existed since pg_trgm was added.  
  
Per report on IRC from user "ftzdomino". Analysis and testing by me,  
patch from Alexander Korotkov.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_trgm/trgm_gist.c

Fix and simplify some usages of TimestampDifference().

commit   : 210564a74409f79cb1441fab62c4154dd148840f    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 10 Nov 2020 22:51:19 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 10 Nov 2020 22:51:19 -0500    

Click here for diff

Introduce TimestampDifferenceMilliseconds() to simplify callers  
that would rather have the difference in milliseconds, instead of  
the select()-oriented seconds-and-microseconds format.  This gets  
rid of at least one integer division per call, and it eliminates  
some apparently-easy-to-mess-up arithmetic.  
  
Two of these call sites were in fact wrong:  
  
* pg_prewarm's autoprewarm_main() forgot to multiply the seconds  
by 1000, thus ending up with a delay 1000X shorter than intended.  
That doesn't quite make it a busy-wait, but close.  
  
* postgres_fdw's pgfdw_get_cleanup_result() thought it needed to compute  
microseconds not milliseconds, thus ending up with a delay 1000X longer  
than intended.  Somebody along the way had noticed this problem but  
misdiagnosed the cause, and imposed an ad-hoc 60-second limit rather  
than fixing the units.  This was relatively harmless in context, because  
we don't care that much about exactly how long this delay is; still,  
it's wrong.  
  
There are a few more callers of TimestampDifference() that don't  
have a direct need for seconds-and-microseconds, but can't use  
TimestampDifferenceMilliseconds() either because they do need  
microsecond precision or because they might possibly deal with  
intervals long enough to overflow 32-bit milliseconds.  It might be  
worth inventing another API to improve that, but that seems outside  
the scope of this patch; so those callers are untouched here.  
  
Given the fact that we are fixing some bugs, and the likelihood  
that future patches might want to back-patch code that uses this  
new API, back-patch to all supported branches.  
  
Alexey Kondratov and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/connection.c
M src/backend/access/transam/xlog.c
M src/backend/replication/walreceiverfuncs.c
M src/backend/replication/walsender.c
M src/backend/utils/adt/timestamp.c
M src/include/utils/timestamp.h

doc: fix spelling "connction" to "connection"

commit   : f93f1a21ae62fe4650335d5818b806f86928d2c2    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 10 Nov 2020 19:18:35 -0500    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 10 Nov 2020 19:18:35 -0500    

Click here for diff

Was wrong in commit 1a9388bd0f.  
  
Reported-by: Tom Lane, Justin Pryzby  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/ref/pg_basebackup.sgml
M doc/src/sgml/ref/pg_dumpall.sgml

Work around cross-version-upgrade issues created by commit 9e38c2bb5.

commit   : 6c91e28224f6d7599b7148e28709e7ed825982b8    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 10 Nov 2020 18:32:36 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 10 Nov 2020 18:32:36 -0500    

Click here for diff

Summarily changing the STYPE of regression-test aggregates that  
depend on array_append or array_cat is an issue for the buildfarm's  
cross-version-upgrade tests, because those aggregates (as defined  
in the back branches) now won't load into HEAD.  Although this seems  
like only a minimal risk for genuine user-defined aggregates, we  
need to do something for the buildfarm.  Hence, adjust the aggregate  
definitions, in both HEAD and the back branches.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  

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