PostgreSQL 12.3 commit log

Stamp 12.3.

commit   : 5060275aa8a1ead56e0a41308d7a43049a6cbe43    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 May 2020 17:08:58 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 May 2020 17:08:58 -0400    

Click here for diff

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

Translation updates

commit   : f2367aa0a4c7a5876c5b7a62306a156075c13190    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 11 May 2020 13:19:18 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 11 May 2020 13:19:18 +0200    

Click here for diff

Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git  
Source-Git-Hash: 60bf9b5caac08d0483f6f92ebf9ef2e0eef5b6bb  

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/ru.po
M src/bin/initdb/po/uk.po
M src/bin/pg_archivecleanup/po/ru.po
M src/bin/pg_archivecleanup/po/uk.po
M src/bin/pg_basebackup/nls.mk
M src/bin/pg_basebackup/po/fr.po
M src/bin/pg_basebackup/po/ru.po
A src/bin/pg_basebackup/po/uk.po
M src/bin/pg_checksums/nls.mk
M src/bin/pg_checksums/po/fr.po
M src/bin/pg_checksums/po/ru.po
A src/bin/pg_checksums/po/uk.po
M src/bin/pg_controldata/po/uk.po
M src/bin/pg_ctl/po/de.po
M src/bin/pg_ctl/po/fr.po
M src/bin/pg_ctl/po/ru.po
M src/bin/pg_ctl/po/sv.po
M src/bin/pg_ctl/po/uk.po
M src/bin/pg_dump/nls.mk
M src/bin/pg_dump/po/de.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
A src/bin/pg_dump/po/uk.po
M src/bin/pg_resetwal/nls.mk
M src/bin/pg_resetwal/po/ru.po
A src/bin/pg_resetwal/po/uk.po
M src/bin/pg_rewind/nls.mk
M src/bin/pg_rewind/po/ru.po
A src/bin/pg_rewind/po/uk.po
M src/bin/pg_upgrade/po/de.po
M src/bin/pg_upgrade/po/fr.po
M src/bin/pg_upgrade/po/ru.po
M src/bin/pg_upgrade/po/sv.po
M src/bin/pg_waldump/nls.mk
M src/bin/pg_waldump/po/ru.po
A src/bin/pg_waldump/po/uk.po
M src/bin/psql/po/ru.po
M src/bin/psql/po/sv.po
M src/bin/psql/po/uk.po
M src/bin/scripts/nls.mk
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
A src/bin/scripts/po/uk.po
M src/interfaces/ecpg/preproc/po/uk.po
M src/interfaces/libpq/po/ru.po
M src/interfaces/libpq/po/uk.po
M src/pl/plperl/nls.mk
A src/pl/plperl/po/uk.po
M src/pl/plpgsql/src/po/ru.po
M src/pl/plpgsql/src/po/uk.po
M src/pl/plpython/po/uk.po

Release notes for 12.3, 11.8, 10.13, 9.6.18, 9.5.22.

commit   : a7cf9adacd77d9ff55e88b3721e0a4ddc21afb52    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 10 May 2020 15:05:59 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 10 May 2020 15:05:59 -0400    

Click here for diff

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

Prevent archive recovery from scanning non-existent WAL files.

commit   : 683e0ef5530f449f0f913de579b4f7bcd31c91fd    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 8 Apr 2020 00:49:29 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 8 Apr 2020 00:49:29 +0900    

Click here for diff

Previously when there were multiple timelines listed in the history file  
of the recovery target timeline, archive recovery searched all of them,  
starting from the newest timeline to the oldest one, to find the segment  
to read. That is, archive recovery had to continuously fail scanning  
the segment until it reached the timeline that the segment belonged to.  
These scans for non-existent segment could be harmful on the recovery  
performance especially when archival area was located on the remote  
storage and each scan could take a long time.  
  
To address the issue, this commit changes archive recovery so that  
it skips scanning the timeline that the segment to read doesn't belong to.  
  
Per discussion, back-patch to all supported versions.  
  
Author: Kyotaro Horiguchi, tweaked a bit by Fujii Masao  
Reviewed-by: David Steele, Pavel Suderevsky, Grigory Smolkin  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  

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

pg_restore: Provide file name with one failure message

commit   : 0507c07b5d5e30f85ce8e32653c7c2b14ceb8983    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 8 May 2020 19:38:46 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 8 May 2020 19:38:46 -0400    

Click here for diff

Almost all error messages already include file name where relevant, but  
this one had been overlooked.  Repair.  
  
Backpatch to 9.5.  
  
Author: Euler Taveira <[email protected]>  
Discussion: https://postgr.es/m/CAH503wA_VOrcKL_43p9atRejCDYmOZ8MzfK9S6TJrQqBqNeAXA@mail.gmail.com  
Reviewed-by: Álvaro Herrera <[email protected]>  

M src/bin/pg_dump/pg_backup_directory.c

First-draft release notes for 12.3.

commit   : ac0e30e0d0fe402fbdb3099fd8b32e4bc6755a6a    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 8 May 2020 16:40:14 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 8 May 2020 16:40:14 -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.  

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

Fix several DDL issues of generated columns versus inheritance

commit   : 14751c340754af9f906a893eb87a894dea3adbc9    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 6 May 2020 16:25:54 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 6 May 2020 16:25:54 +0200    

Click here for diff

Several combinations of generated columns and inheritance in CREATE  
TABLE were not handled correctly.  Specifically:  
  
- Disallow a child column specifying a generation expression if the  
  parent column is a generated column.  The child column definition  
  must be unadorned and the parent column's generation expression will  
  be copied.  
  
- Prohibit a child column of a generated parent column specifying  
  default values or identity.  
  
- Allow a child column of a not-generated parent column specifying  
  itself as a generated column.  This previously did not work, but it  
  was possible to arrive at the state via other means (involving ALTER  
  TABLE), so it seems sensible to support it.  
  
Add tests for each case.  Also add documentation about the rules  
involving generated columns and inheritance.  
  
Discussion:  
    https://www.postgresql.org/message-id/flat/15830.1575468847%40sss.pgh.pa.us  
    https://www.postgresql.org/message-id/flat/2678bad1-048f-519a-ef24-b12962f41807%40enterprisedb.com  
    https://www.postgresql.org/message-id/flat/CAJvUf_u4h0DxkCMCeEKAWCuzGUTnDP-G5iVmSwxLQSXn0_FWNQ%40mail.gmail.com  

M doc/src/sgml/ddl.sgml
M src/backend/commands/tablecmds.c
M src/test/regress/expected/generated.out
M src/test/regress/sql/generated.sql

Propagate ALTER TABLE ... SET STORAGE to indexes

commit   : bf7233ee4a546219b078b5a0afc654ec02958bee    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 9 Apr 2020 14:10:01 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 9 Apr 2020 14:10:01 +0200    

Click here for diff

When creating a new index, the attstorage setting of the table column  
is copied to regular (non-expression) index columns.  But a later  
ALTER TABLE ... SET STORAGE is not propagated to indexes, thus  
creating an inconsistent and undumpable state.  
  
Discussion: https://www.postgresql.org/message-id/flat/9765d72b-37c0-06f5-e349-2a580aafd989%402ndquadrant.com  

M contrib/test_decoding/expected/toast.out
M contrib/test_decoding/sql/toast.sql
M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/vacuum.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/vacuum.sql

Fix inconsistency in pg_buffercache docs.

commit   : fc3461c8a2ad2b4a2965f5fa871834ad7cd141ee    
  
author   : Amit Kapila <[email protected]>    
date     : Fri, 8 May 2020 08:47:51 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Fri, 8 May 2020 08:47:51 +0530    

Click here for diff

Commit 6e654546fb avoids locking bufmgr partitions to make pg_buffercache  
less disruptive on production systems but forgot to update the docs.  
  
Reported-by: Sawada Masahiko  
Author: Sawada Masahiko  
Reviewed-by: Amit Kapila  
Backpatch-through: 10  
Discussion: https://postgr.es/m/CA+fd4k6sD8oeP1qJbFAor=rCpYckU9DsywHiYx3x5Hz5Z8Ua_w@mail.gmail.com  

M doc/src/sgml/pgbuffercache.sgml

Report missing wait event for timeline history file.

commit   : a354d015386a24bbe4cfcf21a983cf7a57ad89b1    
  
author   : Fujii Masao <[email protected]>    
date     : Fri, 8 May 2020 10:36:40 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Fri, 8 May 2020 10:36:40 +0900    

Click here for diff

TimelineHistoryRead and TimelineHistoryWrite wait events are reported  
during waiting for a read and write of a timeline history file, respectively.  
However, previously, TimelineHistoryRead wait event was not reported  
while readTimeLineHistory() was reading a timeline history file. Also  
TimelineHistoryWrite was not reported while writeTimeLineHistory() was  
writing one line with the details of the timeline split, at the end.  
This commit fixes these issues.  
  
Back-patch to v10 where wait events for a timeline history file was added.  
  
Author: Masahiro Ikeda  
Reviewed-by: Michael Paquier, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

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

Fix YA text phrase search bug.

commit   : e1d70ba438a29dd03ba1ce77dcb54c0df9c4f904    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 7 May 2020 15:59:51 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 7 May 2020 15:59:51 -0400    

Click here for diff

checkcondition_str() failed to report multiple matches for a prefix  
pattern correctly: it would dutifully merge the match positions, but  
then after exiting that loop, if the last prefix-matching word had  
had no suitable positions, it would report there were no matches.  
The upshot would be failing to recognize a match that the query  
should match.  
  
It looks like you need all of these conditions to see the bug:  
* a phrase search (else we don't ask for match position details)  
* a prefix search item (else we don't get to this code)  
* a weight restriction (else checkclass_str won't fail)  
  
Noted while investigating a problem report from Pavel Borisov,  
though this is distinct from the issue he was on about.  
  
Back-patch to 9.6 where phrase search was added.  

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

Heed lock protocol in DROP OWNED BY

commit   : 2eea49471fbaeed050eea4fe0e28cdb8de61d0ac    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 6 May 2020 12:29:41 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 6 May 2020 12:29:41 -0400    

Click here for diff

We were acquiring object locks then deleting objects one by one, instead  
of acquiring all object locks first, ignoring those that did not exist,  
and then deleting all objects together.   The latter is the correct  
protocol to use, and what this commits changes to code to do.  Failing  
to follow that leads to "cache lookup failed for relation XYZ" error  
reports when DROP OWNED runs concurrently with other DDL -- for example,  
a session termination that removes some temp tables.  
  
Author: Álvaro Herrera  
Reported-by: Mithun Chicklore Yogendra (Mithun CY)  
Reviewed-by: Ahsan Hadi, Tom Lane  
Discussion: https://postgr.es/m/CADq3xVZTbzK4ZLKq+dn_vB4QafXXbmMgDP3trY-GuLnib2Ai1w@mail.gmail.com  

M src/backend/catalog/dependency.c
M src/backend/catalog/pg_shdepend.c
M src/backend/commands/subscriptioncmds.c
M src/include/catalog/dependency.h

Handle spaces for Python install location in MSVC scripts

commit   : 8c0939dadab0e7c26e303efbbb2245b0aebf97c2    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 6 May 2020 21:08:22 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 6 May 2020 21:08:22 +0900    

Click here for diff

Attempting to use an installation path of Python that includes spaces  
caused the MSVC builds to fail.  This fixes the issue by using the same  
quoting method as ad7595b for OpenSSL.  
  
Author: Victor Wagner  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M src/tools/msvc/Mkvcbuild.pm

Doc: warn that timezone abbreviations don't work in recovery_target_time.

commit   : befa0e471e021cadcac9644a322eb6e4c0e6f524    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 5 May 2020 16:06:49 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 5 May 2020 16:06:49 -0400    

Click here for diff

Moving this setting into the main configuration file was ill-considered,  
perhaps, because that typically causes it to be set before  
timezone_abbreviations has been set.  Which in turn means that zone  
abbreviations don't work, only full zone names.  
  
We could imagine hacking things so that such cases do work, but the  
stability of the hack would be questionable, and the value isn't really  
that high.  Instead just document that you should use a numeric zone  
offset or a full zone name.  
  
Per bug #16404 from Reijo Suhonen.  
Back-patch to v12 where this was changed.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/config.sgml

Fix severe memory leaks in GSSAPI encryption support.

commit   : 987717d7c7007055ff7fc2ecf3d40e9bdb00e071    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 5 May 2020 13:10:09 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 5 May 2020 13:10:09 -0400    

Click here for diff

Both the backend and libpq leaked buffers containing encrypted data  
to be transmitted, so that the process size would grow roughly as  
the total amount of data sent.  
  
There were also far-less-critical leaks of the same sort in GSSAPI  
session establishment.  
  
Oversight in commit b0b39f72b, which I failed to notice while  
reviewing the code in 2c0cdc818.  
  
Per complaint from pmc@citylink.  
Back-patch to v12 where this code was introduced.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/libpq/be-secure-gssapi.c
M src/interfaces/libpq/fe-secure-gssapi.c

Fix GSS client to non-GSS server connection

commit   : 79e594cf04754d55196d2ce54fc869ccad5fa9c3    
  
author   : Stephen Frost <[email protected]>    
date     : Sat, 2 May 2020 11:39:32 -0400    
  
committer: Stephen Frost <[email protected]>    
date     : Sat, 2 May 2020 11:39:32 -0400    

Click here for diff

If the client is compiled with GSSAPI support and tries to start up GSS  
with the server, but the server is not compiled with GSSAPI support, we  
would mistakenly end up falling through to call ProcessStartupPacket  
with secure_done = true, but the client might then try to perform SSL,  
which the backend wouldn't understand and we'd end up failing the  
connection with:  
  
FATAL:  unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0  
  
Fix by arranging to track ssl_done independently from gss_done, instead  
of trying to use the same boolean for both.  
  
Author: Andrew Gierth  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 12-, where GSSAPI encryption was added.  

M src/backend/postmaster/postmaster.c

Get rid of trailing semicolons in C macro definitions.

commit   : c08da32f133b0fea794d7cf346bfa73021366d3a    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 1 May 2020 17:28:00 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 1 May 2020 17:28:00 -0400    

Click here for diff

Writing a trailing semicolon in a macro is almost never the right thing,  
because you almost always want to write a semicolon after each macro  
call instead.  (Even if there was some reason to prefer not to, pgindent  
would probably make a hash of code formatted that way; so within PG the  
rule should basically be "don't do it".)  Thus, if we have a semi inside  
the macro, the compiler sees "something;;".  Much of the time the extra  
empty statement is harmless, but it could lead to mysterious syntax  
errors at call sites.  In perhaps an overabundance of neatnik-ism, let's  
run around and get rid of the excess semicolons whereever possible.  
  
The only thing worse than a mysterious syntax error is a mysterious  
syntax error that only happens in the back branches; therefore,  
backpatch these changes where relevant, which is most of them because  
most of these mistakes are old.  (The lack of reported problems shows  
that this is largely a hypothetical issue, but still, it could bite  
us in some future patch.)  
  
John Naylor and Tom Lane  
  
Discussion: https://postgr.es/m/CACPNZCs0qWTqJ2QUSGJ07B7uvAvzMb-KbG2q+oo+J3tsWN5cqw@mail.gmail.com  

M contrib/btree_gist/btree_ts.c
M contrib/btree_gist/btree_utils_num.h
M contrib/pg_trgm/trgm.h
M contrib/pgcrypto/crypt-blowfish.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/util/pathnode.c
M src/backend/utils/adt/formatting.c
M src/backend/utils/sort/gen_qsort_tuple.pl
M src/bin/pg_dump/pg_backup_archiver.h
M src/include/access/hash.h
M src/include/access/nbtree.h
M src/port/qsort.c
M src/port/qsort_arg.c

Clear up issue with FSM and oldest bpto.xact.

commit   : e1477db92105c56fe057855ba13b5b1288edd06d    
  
author   : Peter Geoghegan <[email protected]>    
date     : Fri, 1 May 2020 12:19:42 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Fri, 1 May 2020 12:19:42 -0700    

Click here for diff

On further reflection, code comments added by commit b0229f26 slightly  
misrepresented how we determine the oldest bpto.xact for the index.  
btvacuumpage() does not treat the bpto.xact of a page that it put in the  
FSM as a candidate to be the oldest deleted page (the delete-marked page  
that has the oldest bpto.xact XID among all pages encountered).  
  
The definition of a deleted page for the purposes of the bpto.xact  
calculation is different from the definition used by the bulk delete  
statistics.  The bulk delete statistics don't distinguish between pages  
that were deleted by the current VACUUM, pages deleted by a previous  
VACUUM operation but not yet recyclable/reusable, and pages that are  
reusable (though reusable pages are counted separately).  
  
Backpatch: 11-, just like commit b0229f26.  

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

Fix undercounting in VACUUM VERBOSE output.

commit   : 40708eaaf3fd8536c245e1131e892ddbd9029218    
  
author   : Peter Geoghegan <[email protected]>    
date     : Fri, 1 May 2020 09:51:08 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Fri, 1 May 2020 09:51:08 -0700    

Click here for diff

The logic for determining how many nbtree pages in an index are deleted  
pages sometimes undercounted pages.  Pages that were deleted by the  
current VACUUM operation (as opposed to some previous VACUUM operation  
whose deleted pages have yet to be reused) were sometimes overlooked.  
The final count is exposed to users through VACUUM VERBOSE's "%u index  
pages have been deleted" output.  
  
btvacuumpage() avoided double-counting when _bt_pagedel() deleted more  
than one page by assuming that only one page was deleted, and that the  
additional deleted pages would get picked up during a future call to  
btvacuumpage() by the same VACUUM operation.  _bt_pagedel() can  
legitimately delete pages that the btvacuumscan() scan will not visit  
again, though, so that assumption was slightly faulty.  
  
Fix the accounting by teaching _bt_pagedel() about its caller's  
requirements.  It now only reports on pages that it knows btvacuumscan()  
won't visit again (including the current btvacuumpage() page), so  
everything works out in the end.  
  
This bug has been around forever.  Only backpatch to v11, though, to  
keep _bt_pagedel() is sync on the branches that have today's bugfix  
commit b0229f26da.  Note that this commit changes the signature of  
_bt_pagedel(), just like commit b0229f26da.  
  
Author: Peter Geoghegan  
Reviewed-By: Masahiko Sawada  
Discussion: https://postgr.es/m/CAH2-WzkrXBcMQWAYUJMFTTvzx_r4q=pYSjDe07JnUXhe+OZnJA@mail.gmail.com  
Backpatch: 11-  

M src/backend/access/nbtree/nbtpage.c
M src/backend/access/nbtree/nbtree.c
M src/include/access/nbtree.h

Fix bug in nbtree VACUUM "skip full scan" feature.

commit   : 05b73261cc26bf06d0c3896f67b3eaaee3b50496    
  
author   : Peter Geoghegan <[email protected]>    
date     : Fri, 1 May 2020 08:39:51 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Fri, 1 May 2020 08:39:51 -0700    

Click here for diff

Commit 857f9c36cda (which taught nbtree VACUUM to skip a scan of the  
index from btcleanup in situations where it doesn't seem worth it) made  
VACUUM maintain the oldest btpo.xact among all deleted pages for the  
index as a whole.  It failed to handle all the details surrounding pages  
that are deleted by the current VACUUM operation correctly (though pages  
deleted by some previous VACUUM operation were processed correctly).  
  
The most immediate problem was that the special area of the page was  
examined without a buffer pin at one point.  More fundamentally, the  
handling failed to account for the full range of _bt_pagedel()  
behaviors.  For example, _bt_pagedel() sometimes deletes internal pages  
in passing, as part of deleting an entire subtree with btvacuumpage()  
caller's page as the leaf level page.  The original leaf page passed to  
_bt_pagedel() might not be the page that it deletes first in cases where  
deletion can take place.  
  
It's unclear how disruptive this bug may have been, or what symptoms  
users might want to look out for.  The issue was spotted during  
unrelated code review.  
  
To fix, push down the logic for maintaining the oldest btpo.xact to  
_bt_pagedel().  btvacuumpage() is now responsible for pages that were  
fully deleted by a previous VACUUM operation, while _bt_pagedel() is now  
responsible for pages that were deleted by the current VACUUM operation  
(this includes half-dead pages from a previous interrupted VACUUM  
operation that become fully deleted in _bt_pagedel()).  Note that  
_bt_pagedel() should never encounter an existing deleted page.  
  
This commit theoretically breaks the ABI of a stable release by changing  
the signature of _bt_pagedel().  However, if any third party extension  
is actually affected by this, then it must already be completely broken  
(since there are numerous assumptions made in _bt_pagedel() that cannot  
be met outside of VACUUM).  It seems highly unlikely that such an  
extension actually exists, in any case.  
  
Author: Peter Geoghegan  
Reviewed-By: Masahiko Sawada  
Discussion: https://postgr.es/m/CAH2-WzkrXBcMQWAYUJMFTTvzx_r4q=pYSjDe07JnUXhe+OZnJA@mail.gmail.com  
Backpatch: 11-, where the "skip full scan" feature was introduced.  

M src/backend/access/nbtree/nbtpage.c
M src/backend/access/nbtree/nbtree.c
M src/include/access/nbtree.h

Fix bogus tar-file padding logic for standby.signal.

commit   : a08bfe7424929fcba4af9eb8ca80214eca47159a    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 27 Apr 2020 13:04:35 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 27 Apr 2020 13:04:35 -0400    

Click here for diff

When pg_basebackup -R is used, we inject standby.signal into the  
tar file for the main tablespace. The proper thing to do is to pad  
each file injected into the tar file out to a 512-byte boundary  
by appending nulls, but here the file is of length 0 and we add  
511 zero bytes.  Since 0 is already a multiple of 512, we should  
not add any zero bytes. Do that instead.  
  
Patch by me, reviewed by Tom Lane.  
  
Discussion: http://postgr.es/m/CA+TgmobWbfReO9-XFk8urR1K4wTNwqoHx_v56t7=T8KaiEoKNw@mail.gmail.com  

M src/bin/pg_basebackup/pg_basebackup.c

Fix full text search to handle NOT above a phrase search correctly.

commit   : 18f7e856cde4734b55844243e54dd8614efbd9eb    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 27 Apr 2020 12:21:04 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 27 Apr 2020 12:21:04 -0400    

Click here for diff

Queries such as '!(foo<->bar)' failed to find matching rows when  
implemented as a GiST or GIN index search.  That's because of  
failing to handle phrase searches as tri-valued when considering  
a query without any position information for the target tsvector.  
We can only say that the phrase operator might match, not that it  
does match; and therefore its NOT also might match.  The previous  
coding incorrectly inverted the approximate phrase result to  
decide that there was certainly no match.  
  
To fix, we need to make TS_phrase_execute return a real ternary result,  
and then bubble that up accurately in TS_execute.  As long as we have  
to do that anyway, we can simplify the baroque things TS_phrase_execute  
was doing internally to manage tri-valued searching with only a bool  
as explicit result.  
  
For now, I left the externally-visible result of TS_execute as a plain  
bool.  There do not appear to be any outside callers that need to  
distinguish a three-way result, given that they passed in a flag  
saying what to do in the absence of position data.  This might need  
to change someday, but we wouldn't want to back-patch such a change.  
  
Although tsginidx.c has its own TS_execute_ternary implementation for  
use at upper index levels, that sadly managed to get this case wrong  
as well :-(.  Fixing it is a lot easier fortunately.  
  
Per bug #16388 from Charles Offenbacher.  Back-patch to 9.6 where  
phrase search was introduced.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/tsginidx.c
M src/backend/utils/adt/tsvector_op.c
M src/test/regress/data/tsearch.data
M src/test/regress/expected/tsearch.out
M src/test/regress/expected/tstypes.out
M src/test/regress/sql/tsearch.sql
M src/test/regress/sql/tstypes.sql

Fix error case for CREATE ROLE ... IN ROLE.

commit   : d0360632d39fca05f6f6e13e98184e72d44c6b3a    
  
author   : Andrew Gierth <[email protected]>    
date     : Sat, 25 Apr 2020 05:10:24 +0100    
  
committer: Andrew Gierth <[email protected]>    
date     : Sat, 25 Apr 2020 05:10:24 +0100    

Click here for diff

CreateRole() was passing a Value node, not a RoleSpec node, for the  
newly-created role name when adding the role as a member of existing  
roles for the IN ROLE syntax.  
  
This mistake went unnoticed because the node in question is used only  
for error messages and is not accessed on non-error paths.  
  
In older pg versions (such as 9.5 where this was found), this results  
in an "unexpected node type" error in place of the real error. That  
node type check was removed at some point, after which the code would  
accidentally fail to fail on 64-bit platforms (on which accessing the  
Value node as if it were a RoleSpec would be mostly harmless) or give  
an "unexpected role type" error on 32-bit platforms.  
  
Fix the code to pass the correct node type, and add an lfirst_node  
assertion just in case.  
  
Per report on irc from user m1chelangelo.  
  
Backpatch all the way, because this error has been around for a long  
time.  

M src/backend/commands/user.c

Update Windows timezone name list to include currently-known zones.

commit   : 1e07e3fc0076d96954f32223efc93b6468e441a4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 17:53:23 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 17:53:23 -0400    

Click here for diff

Thanks to Juan José Santamaría Flecha.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/initdb/findtimezone.c
M src/tools/win32tzlist.pl

Improve placement of "display name" comment in win32_tzmap[] entries.

commit   : a2342c6582be1df1f7977283dd01345ec383be27    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 17:21:44 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 17:21:44 -0400    

Click here for diff

Sticking this comment at the end of the last line was a bad idea: it's  
not particularly readable, and it tempts pgindent to mess with line  
breaks within the comment, which in turn reveals that win32tzlist.pl's  
clean_displayname() does the wrong thing to clean up such line breaks.  
While that's not hard to fix, there's basically no excuse for this  
arrangement to begin with, especially since it makes the table layout  
needlessly vary across back branches with different pgindent rules.  
Let's just put the comment inside the braces, instead.  
  
This commit just moves and reformats the comments, and updates  
win32tzlist.pl to match; there's no actual data change.  
  
Per odd-looking results from Juan José Santamaría Flecha.  
Back-patch, since the point is to make win32_tzmap[] look the  
same in all supported branches again.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/initdb/findtimezone.c
M src/tools/win32tzlist.pl

Repair performance regression in information_schema.triggers view.

commit   : 64e49a67e0207a45e41ba2a5f19964230f21a951    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 12:02:36 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 12:02:36 -0400    

Click here for diff

Commit 32ff26911 introduced use of rank() into the triggers view to  
calculate the spec-mandated action_order column.  As written, this  
prevents query constraints on the table-name column from being pushed  
below the window aggregate step.  That's bad for performance of this  
typical usage pattern, since the view now has to be evaluated for all  
tables not just the one(s) the user wants to see.  It's also the cause  
of some recent buildfarm failures, in which trying to evaluate the view  
rows for triggers in process of being dropped resulted in "cache lookup  
failed for function NNN" errors.  Those rows aren't of interest to the  
test script doing the query, but the filter that would eliminate them  
is being applied too late.  None of this happened before the rank()  
call was there, so it's a regression compared to v10 and before.  
  
We can improve matters by changing the rank() call so that instead of  
partitioning by OIDs, it partitions by nspname and relname, casting  
those to sql_identifier so that they match the respective view output  
columns exactly.  The planner has enough intelligence to know that  
constraints on partitioning columns are safe to push down, so this  
eliminates the performance problem and the regression test failure  
risk.  We could make the other partitioning columns match view outputs  
as well, but it'd be more complicated and the performance benefits  
are questionable.  
  
Side note: as this stands, the planner will push down constraints on  
event_object_table and trigger_schema, but not on event_object_schema,  
because it checks for ressortgroupref matches not expression  
equivalence.  That might be worth improving someday, but it's not  
necessary to fix the immediate concern.  
  
Back-patch to v11 where the rank() call was added.  Ordinarily we'd not  
change information_schema in released branches, but the test failure has  
been seen in v12 and presumably could happen in v11 as well, so we need  
to do this to keep the buildfarm happy.  The change is harmless so far  
as users are concerned.  Some might wish to apply it to existing  
installations if performance of this type of query is of concern,  
but those who don't are no worse off.  
  
I bumped catversion in HEAD as a pro forma matter (there's no  
catalog incompatibility that would really require a re-initdb).  
Obviously that can't be done in the back branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/information_schema.sql

Update time zone data files to tzdata release 2020a.

commit   : c820692bd0ebaae73d4c1c351c93e9de320d39e6    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 10:54:47 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 24 Apr 2020 10:54:47 -0400    

Click here for diff

DST law changes in Morocco and the Canadian Yukon.  
Historical corrections for Shanghai.  
  
The America/Godthab zone is renamed to America/Nuuk to reflect  
current English usage; however, the old name remains available as a  
compatibility link.  

M src/timezone/data/tzdata.zi

Remove some unstable parts from new TAP test for archive status check

commit   : 26057550d5dc5d259f5d01b9ccedb90528f541da    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 24 Apr 2020 11:33:58 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 24 Apr 2020 11:33:58 +0900    

Click here for diff

The test is proving to have timing issues when looking at archive status  
files on standbys after crash recovery, while other parts of the test  
rely on pg_stat_archiver as a wait point to make sure that a given state  
of the archiving is reached.  The coverage is not heavily impacted by  
the removal those extra tests.  
  
Per reports from several buildfarm animals, like crake, piculet,  
culicidae and francolin.  
  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M src/test/recovery/t/020_archive_status.pl

Fix handling of WAL segments ready to be archived during crash recovery

commit   : 22db5269bfa1bb9d16c5d2cc2e371c431ed4ae7e    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 24 Apr 2020 08:48:35 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 24 Apr 2020 08:48:35 +0900    

Click here for diff

78ea8b5 has fixed an issue related to the recycling of WAL segments on  
standbys depending on archive_mode.  However, it has introduced a  
regression with the handling of WAL segments ready to be archived during  
crash recovery, causing those files to be recycled without getting  
archived.  
  
This commit fixes the regression by tracking in shared memory if a live  
cluster is either in crash recovery or archive recovery as the handling  
of WAL segments ready to be archived is different in both cases (those  
WAL segments should not be removed during crash recovery), and by using  
this new shared memory state to decide if a segment can be recycled or  
not.  Previously, it was not possible to know if a cluster was in crash  
recovery or archive recovery as the shared state was able to track only  
if recovery was happening or not, leading to the problem.  
  
A set of TAP tests is added to close the gap here, making sure that WAL  
segments ready to be archived are correctly handled when a cluster is in  
archive or crash recovery with archive_mode set to "on" or "always", for  
both standby and primary.  
  
Reported-by: Benoît Lobréau  
Author: Jehan-Guillaume de Rorthais  
Reviewed-by: Kyotaro Horiguchi, Fujii Masao, Michael Paquier  
Discussion: https://postgr.es/m/20200331172229.40ee00dc@firost  
Backpatch-through: 9.5  

M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogarchive.c
M src/include/access/xlog.h
A src/test/recovery/t/020_archive_status.pl

Fix transient memory leak for SRFs in FROM.

commit   : 95695c784d1d0a1748a9e9f4535caea820b9f9e1    
  
author   : Andres Freund <[email protected]>    
date     : Wed, 22 Apr 2020 19:52:07 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Wed, 22 Apr 2020 19:52:07 -0700    

Click here for diff

In a9c35cf85ca I changed ExecMakeTableFunctionResult() to dynamically  
allocate the FunctionCallInfo used to call the SRF. Unfortunately I  
did not account for the fact that the surrounding memory context has  
query lifetime, leading to a leak till the end of the query.  
  
In most cases the leak is fairly inconsequential, but if the  
FunctionScan is done many times in the query, the leak can add  
up. This happens e.g. if the function scan is on the inner side of a  
nested loop, due to a lateral join.  
EXPLAIN SELECT sum(f) FROM generate_series(1, 100000000) g(i), generate_series(i, i+1) f;  
quickly shows the leak.  
  
Instead of explicitly freeing the FunctionCallInfo it seems better to  
make sure all the per-set temporary state in  
ExecMakeTableFunctionResult() is cleaned up wholesale. Currently  
that's probably just the FunctionCallInfo allocation, but since  
there's some initialization work, and since there's already an  
appropriate context, this seems like a more robust approach.  
  
Bug: #16112  
Reported-By: Ben Cornett  
Author: Andres Freund  
Reviewed-By: Tom Lane  
Discussion: https://postgr.es/m/16112-4448bbf55a404189%40postgresql.org  
Backpatch: 12, a9c35cf85ca  

M src/backend/executor/execSRF.c

docs: land height is "elevation", not "altitude"

commit   : b3cbbd0b6e2bbf7ba7f94ced41b4ca07e68bc768    
  
author   : Bruce Momjian <[email protected]>    
date     : Wed, 22 Apr 2020 16:23:19 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Wed, 22 Apr 2020 16:23:19 -0400    

Click here for diff

See https://mapscaping.com/blogs/geo-candy/what-is-the-difference-between-elevation-relief-and-altitude  
No patching of regression tests.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/advanced.sgml
M doc/src/sgml/ddl.sgml

Fix memory leak in libpq when using sslmode=verify-full

commit   : e1c08722ae0219634147f8a05876a5ef0df9be93    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 22 Apr 2020 07:27:45 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 22 Apr 2020 07:27:45 +0900    

Click here for diff

Checking if Subject Alternative Names (SANs) from a certificate match  
with the hostname connected to leaked memory after each lookup done.  
  
This is broken since acd08d7 that added support for SANs in SSL  
certificates, so backpatch down to 9.5.  
  
Author: Roman Peshkurov  
Reviewed-by: Hamid Akhtar, Michael Paquier, David Steele  
Discussion: https://postgr.es/m/CALLDf-pZ-E3mjxd5=bnHsDu9zHEOnpgPgdnO84E2RuwMCjjyPw@mail.gmail.com  
Backpatch-through: 9.5  

M src/interfaces/libpq/fe-secure-openssl.c

Document partitiong tables ancillary object handling some more

commit   : cda02408f20dda90dfe4eb8b6a1adf053afe7446    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 21 Apr 2020 17:14:18 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 21 Apr 2020 17:14:18 -0400    

Click here for diff

Add a couple of lines to make it explicit that indexes, constraints,  
triggers are added, removed, or left alone.  
  
Backpatch to pg11.  
  
Author: Álvaro Herrera <[email protected]>  
Reviewed-by: Justin Pryzby <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Fix possible crash during FATAL exit from reindexing.

commit   : 5a4efd100ad48d7fd876ce1bc283ad56560039e0    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 21 Apr 2020 15:58:42 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 21 Apr 2020 15:58:42 -0400    

Click here for diff

index.c supposed that it could just use a PG_TRY block to clean up the  
state associated with an active REINDEX operation.  However, that code  
doesn't run if we do a FATAL exit --- for example, due to a SIGTERM  
shutdown signal --- while the REINDEX is happening.  And that state does  
get consulted during catalog accesses, which makes it problematic if we  
do any catalog accesses during shutdown --- for example, to clean up any  
temp tables created in the session.  
  
If this combination of circumstances occurred, we could find ourselves  
trying to access already-freed memory.  In debug builds that'd fairly  
reliably cause an assertion failure.  In production we might often  
get away with it, but with some bad luck it could cause a core dump.  
  
Another possible bad outcome is an erroneous conclusion that an  
index-to-be-accessed is being reindexed; but it looks like that would  
be unlikely to have any consequences worse than failing to drop temp  
tables right away.  (They'd still get dropped by the next session that  
uses that temp schema.)  
  
To fix, get rid of the use of PG_TRY here, and instead hook into  
the transaction abort mechanisms to clean up reindex state.  
  
Per bug #16378 from Alexander Lakhin.  This has been wrong for a  
very long time, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xact.c
M src/backend/catalog/index.c
M src/include/catalog/index.h

Fix minor violations of FunctionCallInvoke usage protocol.

commit   : 90abbba07460580616ab2b351d3512e67f43ad83    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 21 Apr 2020 14:23:42 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 21 Apr 2020 14:23:42 -0400    

Click here for diff

Working on commit 1c455078b led me to check through FunctionCallInvoke  
call sites to see if every one was being honest about (a) making sure  
that fcinfo.isnull is initially false, and (b) checking its state after  
the call.  Sure enough, I found some violations.  
  
The main one is that finalize_partialaggregate re-used serialfn_fcinfo  
without resetting isnull, even though it clearly intends to cater for  
serialfns that return NULL.  There would only be an issue with a  
non-strict serialfn, since it's unlikely that a serialfn would return  
NULL for non-null input.  We have no non-strict serialfns in core, and  
there may be none in the wild either, which would account for the lack  
of complaints.  Still, it's clearly wrong, so back-patch that fix to  
9.6 where finalize_partialaggregate was introduced.  
  
Also, arrayfuncs.c and rowtypes.c contained various callers that were  
not bothering to check for result nulls.  While what's being called is  
a comparison or hash function that probably *shouldn't* return null,  
that's a lousy excuse for not having any check at all.  There are  
existing places that just Assert(!fcinfo->isnull) in comparable  
situations, so I added that to the places that were calling btree  
comparison or hash support functions.  In the places calling  
boolean-returning equality functions, it's quite cheap to have them  
treat isnull as FALSE, so make those places do that.  Also remove some  
"locfcinfo->isnull = false" assignments that are unnecessary given the  
assumption that no previous call returned null.  These changes seem like  
mostly neatnik-ism or debugging support, so I didn't back-patch.  

M src/backend/executor/nodeAgg.c
M src/include/fmgr.h

Fix detaching partitions with cloned row triggers

commit   : e26c8a6b31e9ce657b0185812a8eecb0c1811321    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 21 Apr 2020 13:57:00 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 21 Apr 2020 13:57:00 -0400    

Click here for diff

When a partition is detached, any triggers that had been cloned from its  
parent were not properly disentangled from its parent triggers.  
This resulted in triggers that could not be dropped because they  
depended on the trigger in the trigger in the no-longer-parent table:  
  ALTER TABLE t DETACH PARTITION t1;  
  DROP TRIGGER trig ON t1;  
    ERROR:  cannot drop trigger trig on table t1 because trigger trig on table t requires it  
    HINT:  You can drop trigger trig on table t instead.  
  
Moreover the table can no longer be re-attached to its parent, because  
the trigger name is already taken:  
  ALTER TABLE t ATTACH PARTITION t1 FOR VALUES FROM (1)TO(2);  
    ERROR:  trigger "trig" for relation "t1" already exists  
  
The former is a bug introduced in commit 86f575948c77.  (The latter is  
not necessarily a bug, but it makes the bug more uncomfortable.)  
  
To avoid the complexity that would be needed to tell whether the trigger  
has a local definition that has to be merged with the one coming from  
the parent table, establish the behavior that the trigger is removed  
when the table is detached.  
  
Backpatch to pg11.  
  
Author: Justin Pryzby <[email protected]>  
Reviewed-by: Amit Langote <[email protected]>  
Reviewed-by: Álvaro Herrera <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M doc/src/sgml/ref/create_trigger.sgml
M src/backend/commands/tablecmds.c
M src/test/regress/expected/triggers.out
M src/test/regress/sql/triggers.sql

doc: change SGML markup "figure" to "example"

commit   : 71ae1a89d2efd03bfae89a056d76dc4052de52a7    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 20 Apr 2020 21:41:13 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 20 Apr 2020 21:41:13 -0400    

Click here for diff

Reported-by: Jürgen Purtz  
  
Discussion: https://postgr.es/m/[email protected]  
  
Author: Jürgen Purtz  
  
Backpatch-through: 9.5  

M doc/src/sgml/func.sgml

Allow pg_read_all_stats to access all stats views again

commit   : 212e712a5eed31828e6ffc5e61ca76fd477a519f    
  
author   : Magnus Hagander <[email protected]>    
date     : Mon, 20 Apr 2020 12:53:40 +0200    
  
committer: Magnus Hagander <[email protected]>    
date     : Mon, 20 Apr 2020 12:53:40 +0200    

Click here for diff

The views pg_stat_progress_* had not gotten the memo that  
pg_read_all_stats is supposed to be able to read all statistics. Also  
make a pass over all text-returning pg_stat_xyz functions that could  
return "insufficient privilege" and make sure they also respect  
pg_read_all_status.  
  
Reported-by: Andrey M. Borodin  
Reviewed-by: Andrey M. Borodin, Kyotaro Horiguchi  
Discussion: https://postgr.es/m/[email protected]  

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

Fix race conditions in synchronous standby management.

commit   : 00ef5d52c5778cf4f57bdf997316745ff3c9124d    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 18 Apr 2020 14:02:44 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 18 Apr 2020 14:02:44 -0400    

Click here for diff

We have repeatedly seen the buildfarm reach the Assert(false) in  
SyncRepGetSyncStandbysPriority.  This apparently is due to failing to  
consider the possibility that the sync_standby_priority values in  
shared memory might be inconsistent; but they will be whenever only  
some of the walsenders have updated their values after a change in  
the synchronous_standby_names setting.  That function is vastly too  
complex for what it does, anyway, so rewriting it seems better than  
trying to apply a band-aid fix.  
  
Furthermore, the API of SyncRepGetSyncStandbys is broken by design:  
it returns a list of WalSnd array indexes, but there is nothing  
guaranteeing that the contents of the WalSnd array remain stable.  
Thus, if some walsender exits and then a new walsender process  
takes over that WalSnd array slot, a caller might make use of  
WAL position data that it should not, potentially leading to  
incorrect decisions about whether to release transactions that  
are waiting for synchronous commit.  
  
To fix, replace SyncRepGetSyncStandbys with a new function  
SyncRepGetCandidateStandbys that copies all the required data  
from shared memory while holding the relevant mutexes.  If the  
associated walsender process then exits, this data is still safe to  
make release decisions with, since we know that that much WAL *was*  
sent to a valid standby server.  This incidentally means that we no  
longer need to treat sync_standby_priority as protected by the  
SyncRepLock rather than the per-walsender mutex.  
  
SyncRepGetSyncStandbys is no longer used by the core code, so remove  
it entirely in HEAD.  However, it seems possible that external code is  
relying on that function, so do not remove it from the back branches.  
Instead, just remove the known-incorrect Assert.  When the bug occurs,  
the function will return a too-short list, which callers should treat  
as meaning there are not enough sync standbys, which seems like a  
reasonably safe fallback until the inconsistent state is resolved.  
Moreover it's bug-compatible with what has been happening in non-assert  
builds.  We cannot do anything about the walsender-replacement race  
condition without an API/ABI break.  
  
The bogus assertion exists back to 9.6, but 9.6 is sufficiently  
different from the later branches that the patch doesn't apply at all.  
I chose to just remove the bogus assertion in 9.6, feeling that the  
probability of a bad outcome from the walsender-replacement race  
condition is too low to justify rewriting the whole patch for 9.6.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/replication/syncrep.c
M src/backend/replication/walsender.c
M src/include/replication/syncrep.h
M src/include/replication/walsender_private.h

Fix possible crash with GENERATED ALWAYS columns

commit   : a375f11c44cf245363f356508f7d5126bdaa18ae    
  
author   : David Rowley <[email protected]>    
date     : Sat, 18 Apr 2020 14:11:21 +1200    
  
committer: David Rowley <[email protected]>    
date     : Sat, 18 Apr 2020 14:11:21 +1200    

Click here for diff

In some corner cases, this could also lead to corrupted values being  
included in the tuple.  
  
Users who are concerned that they are affected by this should first  
upgrade and then perform a base backup of their database and restore onto  
an off-line server. They should then query each table with generated  
columns to ensure there are no rows where the generated expression does  
not match a newly calculated version of the GENERATED ALWAYS expression.  
If no crashes occur and no rows are returned then you're not affected.  
  
Fixes bug #16369.  
  
Reported-by: Cameron Ezell  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12 (where GENERATED ALWAYS columns were added.)  

M src/backend/executor/nodeModifyTable.c
M src/test/regress/expected/generated.out
M src/test/regress/sql/generated.sql

Use a slightly more liberal regex to detect Visual Studio version

commit   : 6b02bee66cae232d587679eb476f4784c38abad1    
  
author   : Andrew Dunstan <[email protected]>    
date     : Fri, 17 Apr 2020 14:52:42 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Fri, 17 Apr 2020 14:52:42 -0400    

Click here for diff

Apparently in some language versions of Visual Studio nmake outputs some  
material after the version number and before the end of the line. This  
has been seen in Chinese versions. Therefore, we no longer demand that  
the version string comes at the end of a line.  
  
Per complaint from Cuiping Lin.  
  
Backpatch to all live branches.  

M src/tools/msvc/VSObjectFactory.pm

Fix minor memory leak in pg_basebackup and pg_receivewal

commit   : c03356995f861e02bfdf94054092fcbdf3240519    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 17 Apr 2020 10:45:15 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 17 Apr 2020 10:45:15 +0900    

Click here for diff

The result of the query used to retrieve the WAL segment size from the  
backend was not getting freed in two code paths.  Both pg_basebackup and  
pg_receivewal exit immediately if a failure happened on this query, so  
this was not an actual problem, but it could be an issue if this code  
gets used for other tools in different ways, be they future tools in  
this code tree or external, existing, ones.  
  
Oversight in commit fc49e24, so backpatch down to 11.  
  
Author: Jie Zhang  
Discussion: https://postgr.es/m/970ad9508461469b9450b64027842331@G08CNEXMBPEKD06.g08.fujitsu.local  
Backpatch-through: 11  

M src/bin/pg_basebackup/streamutil.c

Fix cache reference leak in contrib/sepgsql.

commit   : 687e566b90f3ed5874d7026fb5897841519415d0    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 16 Apr 2020 14:45:54 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 16 Apr 2020 14:45:54 -0400    

Click here for diff

fixup_whole_row_references() did the wrong thing with a dropped column,  
resulting in a commit-time warning about a cache reference leak.  
  
I (tgl) added a test case exercising this, but back-patched the test  
only as far as v10; the patch didn't apply cleanly to 9.6 and it  
didn't seem worth the trouble to adapt it.  The bug is pretty old  
though, so apply the code change all the way back.  
  
Michael Luo, with cosmetic improvements by me  
  
Discussion: https://postgr.es/m/BYAPR08MB5606D1453D7F50E2AF4D2FD29AD80@BYAPR08MB5606.namprd08.prod.outlook.com  

M contrib/sepgsql/dml.c
M contrib/sepgsql/expected/dml.out
M contrib/sepgsql/sql/dml.sql

Fix minor memory leak in pg_dump

commit   : d70c014624dda9cd78bd4664c291a6627efca23f    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 15 Apr 2020 15:56:43 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 15 Apr 2020 15:56:43 +0900    

Click here for diff

A query used to read default ACL information from the catalogs did not  
free a set of PQExpBuffer.  
  
Oversight in commit e2090d9, so backpatch down to 9.6.  
  
Author: Jie Zhang  
Reviewed-by: Sawada Masahiko  
Discussion: https://postgr.es/m/05bcbc5857f948efa0b451b85a48ae10@G08CNEXMBPEKD06.g08.fujitsu.local  
Backpatch-through: 9.6  

M src/bin/pg_dump/pg_dump.c

Add a wait_for_catchup() before immediate stop of a test master.

commit   : 30afff385dd292c0e057f837838f063ea16ebef8    
  
author   : Noah Misch <[email protected]>    
date     : Mon, 13 Apr 2020 18:47:28 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Mon, 13 Apr 2020 18:47:28 -0700    

Click here for diff

Per buildfarm member hoverfly, a slow walsender could make the test  
fail.  Back-patch to v10, where the test was introduced.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/test/recovery/t/010_logical_decoding_timelines.pl

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

commit   : 8ffb86644530fb205cbecf85008d8e4a89d4a0a6    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 11 Apr 2020 12:29:06 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 11 Apr 2020 12:29:06 -0400    

Click here for diff

ExecReScanHashJoin will destroy the join's hash table if it expects  
that the inner relation will produce different rows on rescan.  
Up to now it's not bothered to clear the additional pointer to that  
hash table that exists in the child HashState node.  However, it's  
possible for the query to terminate without building a fresh hash  
table (this happens if the outer relation is found to be empty  
during the final rescan).  So we can end with a dangling pointer  
to a deleted hash table.  That was harmless originally, but since  
9.0 EXPLAIN ANALYZE has used that pointer to print hash table  
statistics.  In debug builds this reproducibly results in garbage  
statistics.  In non-debug builds there's frequently no ill effects,  
but in principle one could get wrong EXPLAIN ANALYZE output, or  
perhaps even a crash if free() has released the hashtable memory  
back to the OS.  
  
To fix, just make sure we clear the additional pointer when destroying  
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print  
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't  
ideal, but since the problem manifests only in unusual corner cases,  
it's hard to justify taking any risks to do better in the back  
branches.  A follow-on patch will improve matters in HEAD.  
  
Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro  
of a trouble report from Alvaro Herrera.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/nodeHashjoin.c

doc: restore intentional typo

commit   : a0a7d5dea2d4461a72d1d6a7f5b7dffa5ab72743    
  
author   : Andrew Gierth <[email protected]>    
date     : Sat, 11 Apr 2020 08:04:57 +0100    
  
committer: Andrew Gierth <[email protected]>    
date     : Sat, 11 Apr 2020 08:04:57 +0100    

Click here for diff

Commit ac8623760 "fixed" a typo in an example of what would happen in  
the event of a typo. Restore the original typo and add a comment about  
its intentionality. Backpatch to 12 where the error was introduced.  
  
Per report from irc user Nicolás Alvarez.  

M doc/src/sgml/protocol.sgml

Doc: clarify locking requirements for ALTER TABLE ADD FOREIGN KEY.

commit   : a88e5886c59c0e1e01f424a1fcb477db82ddd3af    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 10 Apr 2020 13:12:58 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 10 Apr 2020 13:12:58 -0400    

Click here for diff

The docs explained that a SHARE ROW EXCLUSIVE lock is needed on the  
referenced table, but failed to say the same about the table being  
altered.  Since the page says that ACCESS EXCLUSIVE lock is taken  
unless otherwise stated, this left readers with the wrong conclusion.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/alter_table.sgml

Doc: sync CREATE GROUP syntax synopsis with CREATE ROLE.

commit   : 21b74a17c8ab316cbd696f4d467ccc42985a72de    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 10 Apr 2020 10:44:10 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 10 Apr 2020 10:44:10 -0400    

Click here for diff

CREATE GROUP is an exact alias for CREATE ROLE, and CREATE USER is  
almost an exact alias, as can easily be confirmed by checking the  
code.  So the man page syntax descriptions ought to match up.  The  
last few additions of role options seem to have forgotten to update  
create_group.sgml, though.  Fix that, and add a naggy reminder to  
create_role.sgml in hopes of not forgetting again.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/create_group.sgml
M doc/src/sgml/ref/create_role.sgml

Further cleanup of ts_headline code.

commit   : 07453e9e332d262d9791e6819fadf74d5a2e8193    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 15:38:43 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 15:38:43 -0400    

Click here for diff

Suppress a probably-meaningless uninitialized-variable warning  
(induced by my previous patch, I'm sorry to say).  
  
Improve mark_hl_fragments()'s test for overlapping cover strings:  
it failed to consider the possibility that the current string is  
strictly within another one.  That's unlikely given the preceding  
splitting into MaxWords fragments, but I don't think it's impossible.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/tsearch/wparser_def.c

Doc: improve documentation about ts_headline() function.

commit   : fac00400846b742a0b8c804b3e075b385d5c3668    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 15:11:08 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 15:11:08 -0400    

Click here for diff

Now that I've had my nose in that code, I thought the docs about  
it left something to be desired.  

M doc/src/sgml/textsearch.sgml

Fix default text search parser's ts_headline code for phrase queries.

commit   : 8413789477222aa1f69f96045f03c86568bc2a6f    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 13:19:23 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 13:19:23 -0400    

Click here for diff

This code could produce very poor results when asked to highlight a  
string based on a query using phrase-match operators.  The root cause  
is that hlCover(), which is supposed to find a minimal substring that  
matches the query, was written assuming that word position is not  
significant.  I'm only 95% convinced that its algorithm was correct even  
for plain AND/OR queries; but it definitely fails completely for phrase  
matches, causing it to possibly not identify a cover string at all.  
  
Hence, rewrite hlCover() with a less-tense algorithm that just tries  
all the possible substrings, earlier and shorter ones first.  (This is  
not as bad as it sounds performance-wise, because all of the string  
matching has been done already: the repeated tsquery match checks  
boil down to pointer comparisons.)  
  
Unfortunately, since that approach produces more candidate cover  
strings than before, it also exposes that there were bugs in the  
heuristics in mark_hl_words() for selecting a best cover string.  
Fixes there include:  
* Do not apply the ShortWord filter to words that appear in the query.  
* Remove a misguided optimization for quickly rejecting a cover.  
* Fix order-of-operation bug that could cause computation of a  
wrong figure of merit (poslen) when shortening a cover.  
* Change the preference rule so that candidate headlines that do not  
include their whole cover string (after MaxWords trimming) are lowest  
priority, since they may not actually satisfy the user's query.  
  
This results in some changes in existing regression test cases,  
but they all seem reasonable.  Note in particular that the tests  
involving strings like "1 2 3" were previously being affected by  
the ShortWord filter, masking the normal matching behavior.  
  
Per bug #16345 from Augustinas Jokubauskas; the new test cases are  
based on that example.  Back-patch to 9.6 where phrase search was  
added to tsquery.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/tsearch/wparser_def.c
M src/test/regress/expected/tsearch.out
M src/test/regress/sql/tsearch.sql

Cosmetic improvements for default text search parser's ts_headline code.

commit   : 1306edeae3b362b57b37b41e7b6a14406d03ebad    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 12:36:59 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 9 Apr 2020 12:36:59 -0400    

Click here for diff

This code was woefully unreadable and under-commented.  Try to improve  
matters by adding comments, using some macros to make complicated  
if-tests more readable, using boolean type where appropriate, etc.  
There are a couple of tiny coding improvements too, but this commit  
includes (I hope) no behavioral change.  
  
Nonetheless, back-patch as far as 9.6, because a followup bug-fixing  
commit depends on this.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/tsearch/wparser_def.c

Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue

commit   : f06d583c5ad7a6a129d846103225448861f2df0d    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 9 Apr 2020 16:17:55 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 9 Apr 2020 16:17:55 +0200    

Click here for diff

CREATE TABLE LIKE INCLUDING GENERATED would fail if a generated column  
referred to a column with a higher attribute number.  This is because  
the column mapping mechanism created the mapping incrementally as  
columns are added.  This was sufficient for previous uses of that  
mechanism (omitting dropped columns), and it also happened to work if  
generated columns only referred to columns with lower attribute  
numbers, but here it failed.  
  
This fix is to build the attribute mapping in a separate loop before  
processing the columns in detail.  
  
Bug: #16342  
Reported-by: Ethan Waldo <[email protected]>  
Reviewed-by: Tom Lane <[email protected]>  

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

Allow parallel create index to accumulate buffer usage stats.

commit   : 13823ad3b012cfaf986ee4dfbd60190ca07187f1    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 9 Apr 2020 09:11:24 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 9 Apr 2020 09:11:24 +0530    

Click here for diff

Currently, we don't account for buffer usage incurred by parallel workers  
for parallel create index.  This commit allows each worker to record the  
buffer usage stats and leader backend to accumulate that stats at the  
end of the operation.  This will allow pg_stat_statements to display  
correct buffer usage stats for (parallel) create index command.  
  
Reported-by: Julien Rouhaud  
Author: Sawada Masahiko  
Reviewed-by: Dilip Kumar, Julien Rouhaud and Amit Kapila  
Backpatch-through: 11, where this was introduced  
Discussion: https://postgr.es/m/20200328151721.GB12854@nol  

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

createuser: Change a fprintf to pg_log_error

commit   : 41b4b2a7cffc3f437aa19751f2055a2918429d33    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 8 Apr 2020 19:19:45 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 8 Apr 2020 19:19:45 +0200    

Click here for diff

M src/bin/scripts/createuser.c

Fix pg_dump/pg_restore to restore event trigger comments later.

commit   : 983ed99a60aef44e7b0ca518d3ca32ae4c3ce411    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 8 Apr 2020 11:23:39 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 8 Apr 2020 11:23:39 -0400    

Click here for diff

Repair an oversight in commit 8728b2c70: if we're postponing restore  
of event triggers to the end, we must also postpone restoring any  
comments on them, since of course we cannot create the comments first.  
(This opens yet another opportunity for an event trigger to bollix  
the restore, but there's no help for that.)  
  
Per bug #16346 from Alexander Lakhin.  
  
Like the previous commit, back-patch to all supported branches.  
  
Hamid Akhtar and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/pg_backup_archiver.c

Fix crash when using COLLATE in partition bound expressions

commit   : 0a9ae1800f67339a8acb45029369e60b98e72fd6    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 8 Apr 2020 15:04:57 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 8 Apr 2020 15:04:57 +0900    

Click here for diff

Attempting to use a COLLATE clause with a type that it not collatable in  
a partition bound expression could crash the server.  This commit fixes  
the code by adding more checks similar to what is done when computing  
index or partition attributes by making sure that there is a collation  
iff the type is collatable.  
  
Backpatch down to 12, as 7c079d7 introduced this problem.  
  
Reported-by: Alexander Lakhin  
Author: Dmitry Dolgov  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/create_table.out
M src/test/regress/sql/create_table.sql

Fix circle_in to accept "(x,y),r" as it's advertised to do.

commit   : 35d1eefb29d03d5a85f71038679f1f8a14358255    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 7 Apr 2020 20:50:02 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 7 Apr 2020 20:50:02 -0400    

Click here for diff

Our documentation describes four allowed input syntaxes for circles,  
but the regression tests tried only three ... with predictable  
consequences.  Remarkably, this has been wrong since the circle  
datatype was added in 1997, but nobody noticed till now.  
  
David Zhang, with some help from me  
  
Discussion: https://postgr.es/m/[email protected]  

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

Adjust bytea get_bit/set_bit to cope with bytea strings > 256MB.

commit   : 6e6b74a206c3b4ad9f22f4910b2e0ed9d922b312    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 7 Apr 2020 16:30:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 7 Apr 2020 16:30:55 -0400    

Click here for diff

Since the existing bit number argument can't exceed INT32_MAX, it's  
not possible for these functions to manipulate bits beyond the first  
256MB of a bytea value.  However, it'd be good if they could do at  
least that much, and not fall over entirely for longer bytea values.  
Adjust the comparisons to be done in int64 arithmetic so that works.  
Also tweak the error reports to show sane values in case of overflow.  
  
Also add some test cases to improve the miserable code coverage  
of these functions.  
  
Apply patch to back branches only; HEAD has a better solution  
as of commit 26a944cf2.  
  
Extracted from a much larger patch by Movead Li  
  
Discussion: https://postgr.es/m/[email protected]  

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

Preserve clustered index after rewrites with ALTER TABLE

commit   : 3e62dd3a937b7da84e8ae126c7bf8319c1cd5c08    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 6 Apr 2020 11:05:47 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 6 Apr 2020 11:05:47 +0900    

Click here for diff

A table rewritten by ALTER TABLE would lose tracking of an index usable  
for CLUSTER.  This setting is tracked by pg_index.indisclustered and is  
controlled by ALTER TABLE, so some extra work was needed to restore it  
properly.  Note that ALTER TABLE only marks the index that can be used  
for clustering, and does not do the actual operation.  
  
Author: Amit Langote, Justin Pryzby  
Reviewed-by: Ibrar Ahmed, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M src/backend/commands/tablecmds.c
M src/backend/utils/cache/lsyscache.c
M src/include/utils/lsyscache.h
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

Use TransactionXmin instead of RecentGlobalXmin in heap_abort_speculative().

commit   : 23a0cf2c9ff0c59b01dc401f870130578f4213fa    
  
author   : Andres Freund <[email protected]>    
date     : Sun, 5 Apr 2020 17:47:30 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Sun, 5 Apr 2020 17:47:30 -0700    

Click here for diff

There's a very low risk that RecentGlobalXmin could be far enough in  
the past to be older than relfrozenxid, or even wrapped  
around. Luckily the consequences of that having happened wouldn't be  
too bad - the page wouldn't be pruned for a while.  
  
Avoid that risk by using TransactionXmin instead. As that's announced  
via MyPgXact->xmin, it is protected against wrapping around (see code  
comments for details around relfrozenxid).  
  
Author: Andres Freund  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 9.5-  

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

Save errno across LWLockRelease() calls

commit   : d278d4e1adc14998948656d16e759f70c0fafb66    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sun, 5 Apr 2020 10:02:00 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sun, 5 Apr 2020 10:02:00 +0200    

Click here for diff

Fixup for "Drop slot's LWLock before returning from SaveSlotToPath()"  
  
Reported-by: Michael Paquier <[email protected]>  

M src/backend/replication/slot.c

Fix bugs in gin_fuzzy_search_limit processing.

commit   : 05f4a88184a4587d883594d4b90d41f9bb63a39b    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 3 Apr 2020 13:15:30 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 3 Apr 2020 13:15:30 -0400    

Click here for diff

entryGetItem()'s three code paths each contained bugs associated  
with filtering the entries for gin_fuzzy_search_limit.  
  
The posting-tree path failed to advance "advancePast" after having  
decided to filter an item.  If we ran out of items on the current  
page and needed to advance to the next, what would actually happen  
is that entryLoadMoreItems() would re-load the same page.  Eventually,  
the random dropItem() test would accept one of the same items it'd  
previously rejected, and we'd move on --- but it could take awhile  
with small gin_fuzzy_search_limit.  To add insult to injury, this  
case would inevitably cause entryLoadMoreItems() to decide it needed  
to re-descend from the root, making things even slower.  
  
The posting-list path failed to implement gin_fuzzy_search_limit  
filtering at all, so that all entries in the posting list would  
be returned.  
  
The bitmap-result path used a "gotitem" variable that it failed to  
update in the one place where it'd actually make a difference, ie  
at the one "continue" statement.  I think this was unreachable in  
practice, because if we'd looped around then it shouldn't be the  
case that the entries on the new page are before advancePast.  
Still, the "gotitem" variable was contributing nothing to either  
clarity or correctness, so get rid of it.  
  
Refactor all three loops so that the termination conditions are  
more alike and less unreadable.  
  
The code coverage report showed that we had no coverage at all for  
the re-descend-from-root code path in entryLoadMoreItems(), which  
seems like a very bad thing, so add a test case that exercises it.  
We also had exactly no coverage for gin_fuzzy_search_limit, so add a  
simplistic test case that at least hits those code paths a little bit.  
  
Back-patch to all supported branches.  
  
Adé Heyward and Tom Lane  
  
Discussion: https://postgr.es/m/CAEknJCdS-dE1Heddptm7ay2xTbSeADbkaQ8bU2AXRCVC2LdtKQ@mail.gmail.com  

M src/backend/access/gin/ginget.c
M src/test/regress/expected/gin.out
M src/test/regress/sql/gin.sql

Fix bogus CALLED_AS_TRIGGER() defenses.

commit   : d56657c35d9cd442438754c68b9aaa30e6720cc4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 3 Apr 2020 11:24:56 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 3 Apr 2020 11:24:56 -0400    

Click here for diff

contrib/lo's lo_manage() thought it could use  
trigdata->tg_trigger->tgname in its error message about  
not being called as a trigger.  That naturally led to a core dump.  
  
unique_key_recheck() figured it could Assert that fcinfo->context  
is a TriggerData node in advance of having checked that it's  
being called as a trigger.  That's harmless in production builds,  
and perhaps not that easy to reach in any case, but it's logically  
wrong.  
  
The first of these per bug #16340 from William Crowell;  
the second from manual inspection of other CALLED_AS_TRIGGER  
call sites.  
  
Back-patch the lo.c change to all supported branches, the  
other to v10 where the thinko crept in.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/lo/lo.c
M src/backend/commands/constraint.c

doc: remove unnecessary INNER keyword

commit   : bc96699b8f8d7ab4c91dbd15c53fbf9635bfee8b    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 2 Apr 2020 17:42:09 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 2 Apr 2020 17:42:09 -0400    

Click here for diff

A join that was added in commit 9b2009c4cf that did not use the INNER  
keyword but the existing query used it.  It was cleaner to remove the  
existing INNER keyword.  
  
Reported-by: Peter Eisentraut  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/pgbuffercache.sgml

commit   : aa9749ed95cadb8478e98fec15ed37fb83faa2ef    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 2 Apr 2020 17:27:43 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 2 Apr 2020 17:27:43 -0400    

Click here for diff

Reported-by: Peter Eisentraut  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/func.sgml

Check equality semantics for unique indexes on partitioned tables.

commit   : 76ea606968c6060549a04f83f9b8608c416085b5    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 1 Apr 2020 14:49:49 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 1 Apr 2020 14:49:49 -0400    

Click here for diff

We require the partition key to be a subset of the set of columns  
being made unique, so that physically-separate indexes on the different  
partitions are sufficient to enforce the uniqueness constraint.  
  
The existing code checked that the listed columns appear, but did not  
inquire into the index semantics, which is a serious oversight given  
that different index opclasses might enforce completely different  
notions of uniqueness.  
  
Ideally, perhaps, we'd just match the partition key opfamily to the  
index opfamily.  But hash partitioning uses hash opfamilies which we  
can't directly match to btree opfamilies.  Hence, look up the equality  
operator in each family, and accept if it's the same operator.  This  
should be okay in a fairly general sense, since the equality operator  
ought to precisely represent the opfamily's notion of uniqueness.  
  
A remaining weak spot is that we don't have a cross-index-AM notion of  
which opfamily member is "equality".  But we know which one to use for  
hash and btree AMs, and those are the only two that are relevant here  
at present.  (Any non-core AMs that know how to enforce equality are  
out of luck, for now.)  
  
Back-patch to v11 where this feature was introduced.  
  
Guancheng Luo, revised a bit by me  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/indexcmds.c

Fix crash in psql when attempting to reuse old connection

commit   : f79bea4b6bcd2e5a801915a179bed2684168f89e    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 1 Apr 2020 14:45:57 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 1 Apr 2020 14:45:57 +0900    

Click here for diff

In a psql session, if the connection to the server is abruptly cut, the  
referenced connection would become NULL as of CheckConnection().  This  
could cause a hard crash with psql if attempting to connect by reusing  
the past connection's data because of a null-pointer dereference with  
either PQhost() or PQdb().  This issue is fixed by making sure that no  
reuse of the past connection is done if it does not exist.  
  
Issue has been introduced by 6e5f8d4, so backpatch down to 12.  
  
Reported-by: Hugh Wang  
Author: Michael Paquier  
Reviewed-by: Álvaro Herrera, Tom Lane  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/bin/psql/command.c

psql: do file completion for \gx

commit   : 6a50f1af44631acdc3ed4e538ef477624ef7c539    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 23:01:33 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 23:01:33 -0400    

Click here for diff

This was missed when the feature was added.  
  
Reported-by: Vik Fearing  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 10  

M src/bin/psql/tab-complete.c

doc: remove mention of bitwise operators as solely type-limited

commit   : f9c1bb73ab5bf6027dfdc983663f8e934f20d29a    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 18:44:29 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 18:44:29 -0400    

Click here for diff

There are other operators that have limited number data type support, so  
just remove the sentence.  
  
Reported-by: Sergei Agalakov  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/func.sgml

doc: clarify hierarchy of objects: global, db, schema, etc.

commit   : 22d233bac3ec1dce057d5bc7bba0f943cfbfa4fe    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 18:10:39 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 18:10:39 -0400    

Click here for diff

The previous wording was confusing because it wasn't in decreasing order  
and had to backtrack.  Also clarify role/user wording.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/manage-ag.sgml

doc: restore wording from recent patch "rolled back to"

commit   : f0862643ee6ba04a719f71c1d739a5395525b812    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:52:48 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:52:48 -0400    

Click here for diff

Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5 - 12  

M doc/src/sgml/mvcc.sgml

doc: clarify when row-level locks are released

commit   : 3f8276a2f04cf3c27fb4ee6647801add42d55218    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:27:32 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:27:32 -0400    

Click here for diff

They are released just like table-level locks.  Also clean up wording.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/mvcc.sgml

doc: add namespace column to pg_buffercache example query

commit   : d68470013618009241454b5578665994b7b36d02    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:16:33 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:16:33 -0400    

Click here for diff

Without the namespace, the table name could be ambiguous.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/pgbuffercache.sgml

doc: clarify which table creation is used for inheritance part.

commit   : 51a1c77bd769642670249554e48ad99698ea61fc    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:07:43 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 17:07:43 -0400    

Click here for diff

Previously people might assume that the partition syntax version of  
CREATE TABLE is to be used for the inheritance partition table example;  
mention that the non-partitioned version should be used.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 10  

M doc/src/sgml/ddl.sgml

Fix race condition in statext_store().

commit   : 6c426cd43790d56e6b96c21ae2d968ceb733bdde    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 31 Mar 2020 17:06:22 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 31 Mar 2020 17:06:22 -0400    

Click here for diff

Must hold some lock on the pg_statistic_ext_data catalog *before*  
we look up the tuple we aim to replace.  Otherwise a concurrent  
VACUUM FULL or similar operation could move it to a different TID,  
leaving us trying to replace the wrong tuple.  
  
Back-patch to v12 where this got broken.  
  
Credit goes to Dean Rasheed; I'm just doing the clerical work.  
  
Discussion: https://postgr.es/m/CAEZATCU0zHMDiQV0g8P2U+YSP9C1idUPrn79DajsbonwkN0xvQ@mail.gmail.com  

M src/backend/statistics/extended_stats.c

doc: adjust UPDATE/DELETE's FROM/USING to match SELECT's FROM

commit   : 1fd0eee66f1e74d6a547d860a9f5d51a2277bb02    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 16:31:44 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 16:31:44 -0400    

Click here for diff

Previously the syntax and wording were unclear.  
  
Reported-by: Alexey Bashtanov  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/update.sgml

Allow ecpg to be built stand-alone, allow parallel libpq make

commit   : 297a174d25b80450aa2bdb058d0a5f2e65f3ba37    
  
author   : Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 14:17:32 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Tue, 31 Mar 2020 14:17:32 -0400    

Click here for diff

This change defines SHLIB_PREREQS for the libpgport dependency, rather  
than using a makefile rule.  This was broken in PG 12.  
  
Reported-by: Filip Janus  
  
Discussion: https://postgr.es/m/[email protected]  
  
Author: Dagfinn Ilmari Mannsåker (for libpq)  
  
Backpatch-through: 12  

M src/interfaces/ecpg/pgtypeslib/Makefile
M src/interfaces/libpq/Makefile

Teach pg_ls_dir_files() to ignore ENOENT failures from stat().

commit   : ee40e8975e2cd2811d14a35ce9179bd46e1f59f2    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 31 Mar 2020 12:57:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 31 Mar 2020 12:57:55 -0400    

Click here for diff

Buildfarm experience shows that this function can fail with ENOENT  
if some other process unlinks a file between when we read the directory  
entry and when we try to stat() it.  The problem is old but we had  
not noticed it until 085b6b667 added regression test coverage.  
  
To fix, just ignore ENOENT failures.  There is one other case that  
this might hide: a symlink that points to nowhere.  That seems okay  
though, at least better than erroring.  
  
Back-patch to v10 where this function was added, since the regression  
test cases were too.  
  
Discussion: https://postgr.es/m/[email protected]  

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

Back-patch addition of stack overflow and interrupt checks for lquery.

commit   : 94c9152dc880a8b1d1223c885d6d56d33e417b57    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 31 Mar 2020 11:37:44 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 31 Mar 2020 11:37:44 -0400    

Click here for diff

Experimentation shows that it's not hard at all to drive the  
old implementation of "ltree ~ lquery" match to stack overflow,  
so throw in a check_stack_depth() call, as I just did in HEAD.  
  
I wasn't able to make it take a long time, because all the  
pathological cases I tried hit stack overflow first; but  
I bet there are some others that do take a long time, so add  
CHECK_FOR_INTERRUPTS() too.  
  
Discussion: https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com  

M contrib/ltree/lquery_op.c

Revert "Skip redundant anti-wraparound vacuums"

commit   : 3ec8576a02b2b06aa214c8f3c2c3303c8a67639f    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 31 Mar 2020 08:27:54 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 31 Mar 2020 08:27:54 +0900    

Click here for diff

This reverts commit 2aa6e33, that added a fast path to skip  
anti-wraparound and non-aggressive autovacuum jobs (these have no sense  
as anti-wraparound implies aggressive).  With a cluster using a high  
amount of relations with a portion of them being heavily updated, this  
could cause autovacuum to lock down, with autovacuum workers attempting  
repeatedly those jobs on the same relations for the same database, that  
just kept being skipped.  This lock down can be solved with a manual  
VACUUM FREEZE.  
  
Justin King has reported one environment where the issue happened, and  
Julien Rouhaud and I have been able to reproduce it in a second  
environment.  With a very aggressive autovacuum_freeze_max_age,  
triggering those jobs with pgbench is a matter of minutes, and hitting  
the lock down is a lot harder (my local tests failed to do that).  
  
Note that anti-wraparound and non-aggressive jobs can only be triggered  
on a subset of shared catalogs:  
- pg_auth_members  
- pg_authid  
- pg_database  
- pg_replication_origin  
- pg_shseclabel  
- pg_subscription  
- pg_tablespace  
While the lock down was possible down to v12, the root cause of those  
jobs is a much older issue, which needs more analysis.  
  
Bonus thanks to Andres Freund for the discussion.  
  
Reported-by: Justin King  
Discussion: https://postgr.es/m/CAE39h22zPLrkH17GrkDgAYL3kbjvySYD1io+rtnAUFnaJJVS4g@mail.gmail.com  
Backpatch-through: 12  

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

Consistently truncate non-key suffix columns.

commit   : 97cda93d81dc89ab05703e1c3344525ab268e49f    
  
author   : Peter Geoghegan <[email protected]>    
date     : Mon, 30 Mar 2020 12:03:57 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Mon, 30 Mar 2020 12:03:57 -0700    

Click here for diff

INCLUDE indexes failed to have their non-key attributes physically  
truncated away in certain rare cases.  This led to physically larger  
pivot tuples that contained useless non-key attribute values.  The  
impact on users should be negligible, but this is still clearly a  
regression (Postgres 11 supports INCLUDE indexes, and yet was not  
affected).  
  
The bug appeared in commit dd299df8, which introduced "true" suffix  
truncation of key attributes.  
  
Discussion: https://postgr.es/m/CAH2-Wz=E8pkV9ivRSFHtv812H5ckf8s1-yhx61_WrJbKccGcrQ@mail.gmail.com  
Backpatch: 12-, where "true" suffix truncation was introduced.  

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

Be more careful about extracting encoding from locale strings on Windows.

commit   : de5b9db3644d5262940c72bab174b43f0bc696cd    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 30 Mar 2020 11:14:58 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 30 Mar 2020 11:14:58 -0400    

Click here for diff

GetLocaleInfoEx() can fail on strings that setlocale() was perfectly  
happy with.  A common way for that to happen is if the locale string  
is actually a Unix-style string, say "et_EE.UTF-8".  In that case,  
what's after the dot is an encoding name, not a Windows codepage number;  
blindly treating it as a codepage number led to failure, with a fairly  
silly error message.  Hence, check to see if what's after the dot is  
all digits, and if not, treat it as a literal encoding name rather than  
a codepage number.  This will do the right thing with many Unix-style  
locale strings, and produce a more sensible error message otherwise.  
  
Somewhat independently of that, treat a zero (CP_ACP) result from  
GetLocaleInfoEx() as meaning that we must use UTF-8 encoding.  
  
Back-patch to all supported branches.  
  
Juan José Santamaría Flecha  
  
Discussion: https://postgr.es/m/[email protected]  

M src/port/chklocale.c

Doc: correct misstatement about ltree label maximum length.

commit   : 756781cc8b6b9c3edb73dc617048605454c4103e    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 29 Mar 2020 18:54:19 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 29 Mar 2020 18:54:19 -0400    

Click here for diff

The documentation says that the max length is 255 bytes, but  
code inspection says it's actually 255 characters; and relevant  
lengths are stored as uint16 so that that works.  

M doc/src/sgml/ltree.sgml

Protect against overflow of ltree.numlevel and lquery.numlevel.

commit   : 2bb6bdbe5da77eab44abf6512779a4aa04419700    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 28 Mar 2020 17:09:51 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 28 Mar 2020 17:09:51 -0400    

Click here for diff

These uint16 fields could be overflowed by excessively long input,  
producing strange results.  Complain for invalid input.  
  
Likewise check for out-of-range values of the repeat counts in lquery.  
(We don't try too hard on that one, notably not bothering to detect  
if atoi's result has overflowed.)  
  
Also detect length overflow in ltree_concat.  
  
In passing, be more consistent about whether "syntax error" messages  
include the type name.  Also, clarify the documentation about what  
the size limit is.  
  
This has been broken for a long time, so back-patch to all supported  
branches.  
  
Nikita Glukhov, reviewed by Benjie Gillam and Tomas Vondra  
  
Discussion: https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com  

M contrib/ltree/expected/ltree.out
M contrib/ltree/ltree.h
M contrib/ltree/ltree_io.c
M contrib/ltree/ltree_op.c
M contrib/ltree/sql/ltree.sql
M doc/src/sgml/ltree.sgml

Ensure snapshot is registered within ScanPgRelation().

commit   : 1d377f203ea47483d48b041c32986dda2f672205    
  
author   : Andres Freund <[email protected]>    
date     : Sat, 28 Mar 2020 11:52:11 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Sat, 28 Mar 2020 11:52:11 -0700    

Click here for diff

In 9.4 I added support to use a historical snapshot in  
ScanPgRelation(), while adding logical decoding. Unfortunately a  
conflict with the concurrent removal of SnapshotNow was incorrectly  
resolved, leading to an unregistered snapshot being used.  
  
It is not correct to use an unregistered (or non-active) snapshot for  
anything non-trivial, because catalog invalidations can cause the  
snapshot to be invalidated.  
  
Luckily it seems unlikely to actively cause problems in practice, as  
ScanPgRelation() requires that we already have a lock on the relation,  
we only look for a single row, and we don't appear to rely on the  
result's tid to be correct. It however is clearly wrong and potential  
negative consequences would likely be hard to find. So it seems worth  
backpatching the fix, even without a concrete hazard.  
  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 9.5-  

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

Ensure that plpgsql cleans up cleanly during parallel-worker exit.

commit   : a54a87320782e775794f2f0b05fcd0c1fc5539d0    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 26 Mar 2020 18:06:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 26 Mar 2020 18:06:55 -0400    

Click here for diff

plpgsql_xact_cb ought to treat events XACT_EVENT_PARALLEL_COMMIT and  
XACT_EVENT_PARALLEL_ABORT like XACT_EVENT_COMMIT and XACT_EVENT_ABORT  
respectively, since its goal is to do process-local cleanup.  This  
oversight caused plpgsql's end-of-transaction cleanup to not get done  
in parallel workers.  Since a parallel worker will exit just after the  
transaction cleanup, the effects of this are limited.  I couldn't find  
any case in the core code with user-visible effects, but perhaps there  
are some in extensions.  In any case it's wrong, so let's fix it before  
it bites us not after.  
  
In passing, add some comments around the handling of expression  
evaluation resources in DO blocks.  There's no live bug there, but it's  
quite unobvious what's happening; at least I thought so.  This isn't  
related to the other issue, except that I found both things while poking  
at expression-evaluation performance.  
  
Back-patch the plpgsql_xact_cb fix to 9.5 where those event types  
were introduced, and the DO-block commentary to v11 where DO blocks  
gained the ability to issue COMMIT/ROLLBACK.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/pl/plpgsql/src/pl_exec.c
M src/pl/plpgsql/src/pl_handler.c

Drop slot's LWLock before returning from SaveSlotToPath()

commit   : 223e9c77dcaf8788fdca2fab3a3b65b797a54615    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 26 Mar 2020 11:51:39 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 26 Mar 2020 11:51:39 +0100    

Click here for diff

When SaveSlotToPath() is called with elevel=LOG, the early exits didn't  
release the slot's io_in_progress_lock.  
  
This could result in a walsender being stuck on the lock forever.  A  
possible way to get into this situation is if the offending code paths  
are triggered in a low disk space situation.  
  
Author: Pavan Deolasee <[email protected]>  
Reported-by: Craig Ringer <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/56a138c5-de61-f553-7e8f-6789296de785%402ndquadrant.com  

M src/backend/replication/slot.c

Re-implement the ereport() macro using __VA_ARGS__.

commit   : a86715451653c730d637847b403b0420923956f7    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 24 Mar 2020 11:48:33 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 24 Mar 2020 11:48:33 -0400    

Click here for diff

Now that we require C99, we can depend on __VA_ARGS__ to work, and  
revising ereport() to use it has several significant benefits:  
  
* The extra parentheses around the auxiliary function calls are now  
optional.  Aside from being a bit less ugly, this removes a common  
gotcha for new contributors, because in some cases the compiler errors  
you got from forgetting them were unintelligible.  
  
* The auxiliary function calls are now evaluated as a comma expression  
list rather than as extra arguments to errfinish().  This means that  
compilers can be expected to warn about no-op expressions in the list,  
allowing detection of several other common mistakes such as forgetting  
to add errmsg(...) when converting an elog() call to ereport().  
  
* Unlike the situation with extra function arguments, comma expressions  
are guaranteed to be evaluated left-to-right, so this removes platform  
dependency in the order of the auxiliary function calls.  While that  
dependency hasn't caused us big problems in the past, this change does  
allow dropping some rather shaky assumptions around errcontext() domain  
handling.  
  
There's no intention to make wholesale changes of existing ereport  
calls, but as proof-of-concept this patch removes the extra parens  
from a couple of calls in postgres.c.  
  
While new code can be written either way, code intended to be  
back-patched will need to use extra parens for awhile yet.  It seems  
worth back-patching this change into v12, so as to reduce the window  
where we have to be careful about that by one year.  Hence, this patch  
is careful to preserve ABI compatibility; a followup HEAD-only patch  
will make some additional simplifications.  
  
Andres Freund and Tom Lane  
  
Discussion: https://postgr.es/m/CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com  

M doc/src/sgml/sources.sgml
M src/backend/tcop/postgres.c
M src/backend/utils/error/elog.c
M src/include/utils/elog.h

Add regression tests for constraint errors in partitioned tables.

commit   : 7c836420026125f430e5ae3a3eb0264e75ec5b3e    
  
author   : Andres Freund <[email protected]>    
date     : Mon, 23 Mar 2020 14:50:20 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Mon, 23 Mar 2020 14:50:20 -0700    

Click here for diff

While #16293 only applied to 11 (and 10 to some degree), it seems best  
to add tests to all branches with partitioning support.  
  
Reported-By: Daniel WM  
Author: Andres Freund  
Bug: #16293  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 10-  

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

Doc: explain that LIKE et al can be used in ANY (sub-select) etc.

commit   : 64232dab8a0704488ada42099ab2cf77fcca2bec    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 23 Mar 2020 12:42:15 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 23 Mar 2020 12:42:15 -0400    

Click here for diff

This wasn't stated anywhere, and it's perhaps not that obvious,  
since we get questions about it from time to time.  Also undocumented  
was that the parser actually translates these into operators.  
  
Discussion: https://postgr.es/m/CAFj8pRBkvZ71BqGKZnBBG4=0cKG+s50Dy+DYmrizUKEpAtdc+w@mail.gmail.com  

M doc/src/sgml/func.sgml

Fix our getopt_long's behavior for a command line argument of just "-".

commit   : 036fdf6be2ebc6cddd045ba83efdc62810b84483    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 23 Mar 2020 11:58:01 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 23 Mar 2020 11:58:01 -0400    

Click here for diff

src/port/getopt_long.c failed on such an argument, always seeing it  
as an unrecognized switch.  This is unhelpful; better is to treat such  
an item as a non-switch argument.  That behavior is what we find in  
GNU's getopt_long(); it's what src/port/getopt.c does; and it is  
required by POSIX for getopt(), which getopt_long() ought to be  
generally a superset of.  Moreover, it's expected by ecpg, which  
intends an argument of "-" to mean "read from stdin".  So fix it.  
  
Also add some documentation about ecpg's behavior in this area, since  
that was miserably underdocumented.  I had to reverse-engineer it  
from the code.  
  
Per bug #16304 from James Gray.  Back-patch to all supported branches,  
since this has been broken forever.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/ecpg-ref.sgml
M src/port/getopt_long.c

Doc: Fix type of some storage parameters in CREATE TABLE page

commit   : d2159c677812e60bcc43222a8297ca2103821314    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 23 Mar 2020 13:38:10 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 23 Mar 2020 13:38:10 +0900    

Click here for diff

autovacuum_vacuum_scale_factor and autovacuum_analyze_scale_factor have  
been documented as "float4", but "floating type" is used in this case  
for GUCs and relation options in the documentation.  
  
Author: Atsushi Torikoshi  
Discussion: https://postgr.es/m/CACZ0uYFf_p9BpbjLccx3CA=eM1Hk2Te=ULY4iptGLUhL-JxCPA@mail.gmail.com  
Backpatch-through: 9.5  

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

Revert "Skip WAL for new relfilenodes, under wal_level=minimal."

commit   : 63631ee64f84bae7feeb06b8417b628e82319ce2    
  
author   : Noah Misch <[email protected]>    
date     : Sun, 22 Mar 2020 09:24:09 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sun, 22 Mar 2020 09:24:09 -0700    

Click here for diff

This reverts commit cb2fd7eac285b1b0a24eeb2b8ed4456b66c5a09f.  Per  
numerous buildfarm members, it was incompatible with parallel query, and  
a test case assumed LP64.  Back-patch to 9.5 (all supported versions).  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_visibility/expected/pg_visibility.out
M contrib/pg_visibility/sql/pg_visibility.sql
M doc/src/sgml/config.sgml
M doc/src/sgml/perform.sgml
M src/backend/access/gist/gistutil.c
M src/backend/access/gist/gistxlog.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/heap/rewriteheap.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/rmgrdesc/gistdesc.c
M src/backend/access/transam/README
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogutils.c
M src/backend/bootstrap/bootparse.y
M src/backend/catalog/storage.c
M src/backend/commands/cluster.c
M src/backend/commands/copy.c
M src/backend/commands/createas.c
M src/backend/commands/indexcmds.c
M src/backend/commands/matview.c
M src/backend/commands/tablecmds.c
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/backend/storage/buffer/bufmgr.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/smgr/md.c
M src/backend/storage/smgr/smgr.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/access/gist_private.h
M src/include/access/gistxlog.h
M src/include/access/heapam.h
M src/include/access/rewriteheap.h
M src/include/access/tableam.h
M src/include/catalog/storage.h
M src/include/nodes/parsenodes.h
M src/include/storage/bufmgr.h
M src/include/storage/lock.h
M src/include/storage/smgr.h
M src/include/utils/rel.h
M src/include/utils/relcache.h
D src/test/recovery/t/018_wal_optimize.pl
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/create_table.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/create_table.sql

Skip WAL for new relfilenodes, under wal_level=minimal.

commit   : e4b0a02ef8c8c69f2a49f4ca86de12ef34e97ac3    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

Until now, only selected bulk operations (e.g. COPY) did this.  If a  
given relfilenode received both a WAL-skipping COPY and a WAL-logged  
operation (e.g. INSERT), recovery could lose tuples from the COPY.  See  
src/backend/access/transam/README section "Skipping WAL for New  
RelFileNode" for the new coding rules.  Maintainers of table access  
methods should examine that section.  
  
To maintain data durability, just before commit, we choose between an  
fsync of the relfilenode and copying its contents to WAL.  A new GUC,  
wal_skip_threshold, guides that choice.  If this change slows a workload  
that creates small, permanent relfilenodes under wal_level=minimal, try  
adjusting wal_skip_threshold.  Users setting a timeout on COMMIT may  
need to adjust that timeout, and log_min_duration_statement analysis  
will reflect time consumption moving to COMMIT from commands like COPY.  
  
Internally, this requires a reliable determination of whether  
RollbackAndReleaseCurrentSubTransaction() would unlink a relation's  
current relfilenode.  Introduce rd_firstRelfilenodeSubid.  Amend the  
specification of rd_createSubid such that the field is zero when a new  
rel has an old rd_node.  Make relcache.c retain entries for certain  
dropped relations until end of transaction.  
  
Back-patch to 9.5 (all supported versions).  This introduces a new WAL  
record type, XLOG_GIST_ASSIGN_LSN, without bumping XLOG_PAGE_MAGIC.  As  
always, update standby systems before master systems.  This changes  
sizeof(RelationData) and sizeof(IndexStmt), breaking binary  
compatibility for affected extensions.  (The most recent commit to  
affect the same class of extensions was  
089e4d405d0f3b94c74a2c6a54357a84a681754b.)  
  
Kyotaro Horiguchi, reviewed (in earlier, similar versions) by Robert  
Haas.  Heikki Linnakangas and Michael Paquier implemented earlier  
designs that materially clarified the problem.  Reviewed, in earlier  
designs, by Andrew Dunstan, Andres Freund, Alvaro Herrera, Tom Lane,  
Fujii Masao, and Simon Riggs.  Reported by Martijn van Oosterhout.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_visibility/expected/pg_visibility.out
M contrib/pg_visibility/sql/pg_visibility.sql
M doc/src/sgml/config.sgml
M doc/src/sgml/perform.sgml
M src/backend/access/gist/gistutil.c
M src/backend/access/gist/gistxlog.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/heap/rewriteheap.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/rmgrdesc/gistdesc.c
M src/backend/access/transam/README
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogutils.c
M src/backend/bootstrap/bootparse.y
M src/backend/catalog/storage.c
M src/backend/commands/cluster.c
M src/backend/commands/copy.c
M src/backend/commands/createas.c
M src/backend/commands/indexcmds.c
M src/backend/commands/matview.c
M src/backend/commands/tablecmds.c
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/backend/storage/buffer/bufmgr.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/smgr/md.c
M src/backend/storage/smgr/smgr.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/access/gist_private.h
M src/include/access/gistxlog.h
M src/include/access/heapam.h
M src/include/access/rewriteheap.h
M src/include/access/tableam.h
M src/include/catalog/storage.h
M src/include/nodes/parsenodes.h
M src/include/storage/bufmgr.h
M src/include/storage/lock.h
M src/include/storage/smgr.h
M src/include/utils/rel.h
M src/include/utils/relcache.h
A src/test/recovery/t/018_wal_optimize.pl
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/create_table.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/create_table.sql

In log_newpage_range(), heed forkNum and page_std arguments.

commit   : a5abec521c5d40fefbbb42af093fa9fd508b2614    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

The function assumed forkNum=MAIN_FORKNUM and page_std=true, ignoring  
the actual arguments.  Existing callers passed exactly those values, so  
there's no live bug.  Back-patch to v12, where the function first  
appeared, because another fix needs this.  
  
Discussion: https://postgr.es/m/[email protected]  

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

During heap rebuild, lock any TOAST index until end of transaction.

commit   : 88b3a6cd262344f5de64eab31804a0f39a7c6337    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

swap_relation_files() calls toast_get_valid_index() to find and lock  
this index, just before swapping with the rebuilt TOAST index.  The  
latter function releases the lock before returning.  Potential for  
mischief is low; a concurrent session can issue ALTER INDEX ... SET  
(fillfactor = ...), which is not alarming.  Nonetheless, changing  
pg_class.relfilenode without a lock is unconventional.  Back-patch to  
9.5 (all supported versions), because another fix needs this.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/tuptoaster.c
M src/backend/commands/cluster.c

Fix cosmetic blemishes involving rd_createSubid.

commit   : b35017549ce1253de0580ec618cdc9020f4b5e05    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

Remove an obsolete comment from AtEOXact_cleanup().  Restore formatting  
of a comment in struct RelationData, mangled by the pgindent run in  
commit 9af4159fce6654aa0e081b00d02bca40b978745c.  Back-patch to 9.5 (all  
supported versions), because another fix stacks on this.  

M src/backend/utils/cache/relcache.c
M src/include/utils/rel.h

docs: use alias in WHERE clause of full text search example

commit   : ff339f4359424f4a8b5737168a749eff962d7f94    
  
author   : Bruce Momjian <[email protected]>    
date     : Fri, 20 Mar 2020 20:19:32 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Fri, 20 Mar 2020 20:19:32 -0400    

Click here for diff

The current doc query specified an alias in the FROM clause and used in  
it the target list, but not in the WHERE clause.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 9.5  

M doc/src/sgml/textsearch.sgml

Turn off deprecated bison warnings under MSVC

commit   : d0747714e6ef193c16d1acf31c15f387877d591f    
  
author   : Andrew Dunstan <[email protected]>    
date     : Fri, 20 Mar 2020 13:55:15 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Fri, 20 Mar 2020 13:55:15 -0400    

Click here for diff

These are disabled by the configure code, so this is just fixing an  
inconsistency in the MSVC code.  
  
Backpatch to all live branches.  

M src/tools/msvc/pgbison.pl

pg_upgrade: make get_major_server_version() err msg consistent

commit   : 9f62ea27e3f4095da38ba4cd6247043ab86f0b6a    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Mar 2020 15:20:55 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Mar 2020 15:20:55 -0400    

Click here for diff

This patch fixes the error message in get_major_server_version() to be  
"could not parse version file", and uses the full file path name, rather  
than just the data directory path.  
  
Also, commit 4109bb5de4 added the cause of the failure to the  "could  
not open" error message, and improved quoting.  This patch backpatches  
the "could not open" cause to PG 12, where it was first widely used, and  
backpatches the quoting fix in that patch to all supported releases.  
  
Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  
  
Author: Dagfinn Ilmari Mannsåker  
  
Backpatch-through: 9.5  

M src/bin/pg_upgrade/server.c

commit   : fdaa16aecfd98eb72718cbfe2d645c0b4e3124cd    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 19 Mar 2020 09:51:40 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 19 Mar 2020 09:51:40 +0900    

Click here for diff

A comment about switching indisvalid of the new and old indexes swapped  
in REINDEX CONCURRENTLY got this backwards.  
  
Issue introduced by 5dc92b8, the original commit of REINDEX  
CONCURRENTLY.  
  
Author: Julien Rouhaud  
Discussion: https://postgr.es/m/20200318143340.GA46897@nol  
Backpatch-through: 12  

M src/backend/catalog/index.c

commit   : 21b1cb6a786e0e0598a7d2b262e1a5ca0dfceba4    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 18 Mar 2020 23:07:17 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 18 Mar 2020 23:07:17 +0900    

Click here for diff

This commit corrects the descriptions of RecoveryWalAll and RecoveryWalStream  
wait events in the documentation.  
  
Back-patch to v10 where those wait events were added.  
  
Author: Fujii Masao  
Reviewed-by: Kyotaro Horiguchi, Atsushi Torikoshi  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml

Add missing errcode() in a few ereport calls.

commit   : e37824136f060aefcb9e95ee3968446434c783c7    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 18 Mar 2020 09:33:01 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 18 Mar 2020 09:33:01 +0530    

Click here for diff

This will allow to specifying SQLSTATE error code for the errors in the  
missing places.  
  
Reported-by: Sawada Masahiko  
Author: Sawada Masahiko  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com  

M contrib/adminpack/adminpack.c
M src/backend/storage/page/bufpage.c

Fix typo in indexcmds.c

commit   : c5b6b9c0d74400300b77d44194f6679f470352f2    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 18 Mar 2020 11:13:12 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 18 Mar 2020 11:13:12 +0900    

Click here for diff

Introduced by 61d7c7b.  
  
Backpatch-through: 12  

M src/backend/commands/indexcmds.c

Fix consistency issues with replication slot copy

commit   : e58e13e846953e0540b1a2c9a7739b666e134997    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 17 Mar 2020 16:13:18 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 17 Mar 2020 16:13:18 -0300    

Click here for diff

Commit 9f06d79ef831's replication slot copying failed to  
properly reserve the WAL that the slot is expecting to see  
during DecodingContextFindStartpoint (to set the confirmed_flush  
LSN), so concurrent activity could remove that WAL and cause the  
copy process to error out.  But it doesn't actually *need* that  
WAL anyway: instead of running decode to find confirmed_flush, it  
can be copied from the source slot. Fix this by rearranging things  
to avoid DecodingContextFindStartpoint() (leaving the target slot's  
confirmed_flush_lsn to invalid), and set that up afterwards by copying  
from the target slot's value.  
  
Also ensure the source slot's confirmed_flush_lsn is valid.  
  
Reported-by: Arseny Sher  
Author: Masahiko Sawada, Arseny Sher  
Discussion: https://postgr.es/m/871rr3ohbo.fsf@ars-thinkpad  

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

Doc: clarify behavior of "anyrange" pseudo-type.

commit   : bcd460003a722fb421a911309d2f5a7316862084    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 17 Mar 2020 15:05:17 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 17 Mar 2020 15:05:17 -0400    

Click here for diff

I noticed that we completely failed to document the restriction  
that an "anyrange" result type has to be inferred from an "anyrange"  
input.  The docs also were less clear than they could be about the  
relationship between "anyrange" and "anyarray".  
  
It's been like this all along, so back-patch.  

M doc/src/sgml/extend.sgml

Use pkg-config, if available, to locate libxml2 during configure.

commit   : d8e7f8149400733b749b48195b5f886a083edb8d    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 17 Mar 2020 12:09:26 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 17 Mar 2020 12:09:26 -0400    

Click here for diff

If pkg-config is installed and knows about libxml2, use its information  
rather than asking xml2-config.  Otherwise proceed as before.  This  
patch allows "configure --with-libxml" to succeed on platforms that  
have pkg-config but not xml2-config, which is likely to soon become  
a typical situation.  
  
The old mechanism can be forced by setting XML2_CONFIG explicitly  
(hence, build processes that were already doing so will certainly  
not need adjustment).  Also, it's now possible to set XML2_CFLAGS  
and XML2_LIBS explicitly to override both programs.  
  
There is a small risk of this breaking existing build processes,  
if there are multiple libxml2 installations on the machine and  
pkg-config disagrees with xml2-config about which to use.  The  
only case where that seems really likely is if a builder has tried  
to select a non-default xml2-config by putting it early in his PATH  
rather than setting XML2_CONFIG.  Plan to warn against that in the  
minor release notes.  
  
Back-patch to v10; before that we had no pkg-config infrastructure,  
and it doesn't seem worth adding it for this.  
  
Hugh McMaster and Tom Lane; Peter Eisentraut also made an earlier  
attempt at this, from which I lifted most of the docs changes.  
  
Discussion: https://postgr.es/m/CAN9BcdvfUwc9Yx5015bLH2TOiQ-M+t_NADBSPhMF7dZ=pLa_iw@mail.gmail.com  

M configure
M configure.in
M doc/src/sgml/installation.sgml

Avoid holding a directory FD open across assorted SRF calls.

commit   : 2a89455aade3e917b6b0d02d9ce385049d0525eb    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 16 Mar 2020 21:05:29 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 16 Mar 2020 21:05:29 -0400    

Click here for diff

This extends the fixes made in commit 085b6b667 to other SRFs with the  
same bug, namely pg_logdir_ls(), pgrowlocks(), pg_timezone_names(),  
pg_ls_dir(), and pg_tablespace_databases().  
  
Also adjust various comments and documentation to warn against  
expecting to clean up resources during a ValuePerCall SRF's final  
call.  
  
Back-patch to all supported branches, since these functions were  
all born broken.  
  
Justin Pryzby, with cosmetic tweaks by me  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/adminpack/adminpack.c
M contrib/pgrowlocks/pgrowlocks.c
M doc/src/sgml/xfunc.sgml
M src/backend/utils/adt/datetime.c
M src/backend/utils/adt/genfile.c
M src/backend/utils/adt/misc.c
M src/backend/utils/fmgr/README
M src/include/funcapi.h
M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

Document pg_ls_*dir hiding of directories and special files

commit   : f340977a4fab20f1898d4ac61ae1c36031e109cb    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 16 Mar 2020 19:12:14 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 16 Mar 2020 19:12:14 -0300    

Click here for diff

It's strange that a directory-listing function does not list all entries  
in a directory, so let's at least document it.  This involves  
  
pg_ls_logdir  
pg_ls_waldir  
pg_ls_archive_statusdir  
pg_ls_tmpdir  
  
Backpatch as far back as it applies cleanly (and as far as as each  
function exists).  REL_10_STABLE uses different wording, but hopefully  
people are not reading docs so old to write new apps anyway.  
  
Author: Justin Pryzby <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml

Plug memory leak

commit   : cf72898c686ce81fd870769f1a51818b49688bec    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 16 Mar 2020 16:27:13 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 16 Mar 2020 16:27:13 -0300    

Click here for diff

Introduced by b08dee24a557.  Noted by Coverity.  

M src/bin/pg_dump/pg_dump.c

Restructure polymorphic-type resolution in funcapi.c.

commit   : 390984f92696712fe783609cabbc79f58d0f8a7d    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 14 Mar 2020 14:42:22 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 14 Mar 2020 14:42:22 -0400    

Click here for diff

resolve_polymorphic_tupdesc() and resolve_polymorphic_argtypes() failed to  
cover the case of having to resolve anyarray given only an anyrange input.  
The bug was masked if anyelement was also used (as either input or  
output), which probably helps account for our not having noticed.  
  
While looking at this I noticed that resolve_generic_type() would produce  
the wrong answer if asked to make that same resolution.  ISTM that  
resolve_generic_type() is confusingly defined and overly complex, so  
rather than fix it, let's just make funcapi.c do the specific lookups  
it requires for itself.  
  
With this change, resolve_generic_type() is not used anywhere, so remove  
it in HEAD.  In the back branches, leave it alone (complete with bug)  
just in case any external code is using it.  
  
While we're here, make some other refactoring adjustments in funcapi.c  
with an eye to upcoming future expansion of the set of polymorphic types:  
  
* Simplify quick-exit tests by adding an overall have_polymorphic_result  
flag.  This is about a wash now but will be a win when there are more  
flags.  
  
* Reduce duplication of code between resolve_polymorphic_tupdesc() and  
resolve_polymorphic_argtypes().  
  
* Don't bother to validate correct matching of anynonarray or anyenum;  
the parser should have done that, and even if it didn't, just doing  
"return false" here would lead to a very confusing, off-point error  
message.  (Really, "return false" in these two functions should only  
occur if the call_expr isn't supplied or we can't obtain data type  
info from it.)  
  
* For the same reason, throw an elog rather than "return false" if  
we fail to resolve a polymorphic type.  
  
The bug's been there since we added anyrange, so back-patch to  
all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/fmgr/funcapi.c
M src/test/regress/expected/rangetypes.out
M src/test/regress/sql/rangetypes.sql

Doc: fix mistaken reference to "PG_ARGNULL_xxx()" macro.

commit   : f393fb20a1543a3e08597968ff6017d9d399513d    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 13 Mar 2020 12:49:10 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 13 Mar 2020 12:49:10 -0400    

Click here for diff

This should of course be just "PG_ARGISNULL()".  
  
Also reorder a couple of paras to make the discussion of PG_ARGISNULL  
less disjointed.  
  
Back-patch to v10 where the error was introduced.  
  
Laurenz Albe and Tom Lane, per an anonymous docs comment  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/xfunc.sgml

Preserve replica identity index across ALTER TABLE rewrite

commit   : c9ef507e82ebb2bffc50e531edd6fb4593dd5146    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 13 Mar 2020 11:28:11 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 13 Mar 2020 11:28:11 +0100    

Click here for diff

If an index was explicitly set as replica identity index, this setting  
was lost when a table was rewritten by ALTER TABLE.  Because this  
setting is part of pg_index but actually controlled by ALTER  
TABLE (not part of CREATE INDEX, say), we have to do some extra work  
to restore it.  
  
Based-on-patch-by: Quan Zongliang <[email protected]>  
Reviewed-by: Euler Taveira <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/commands/tablecmds.c
M src/backend/utils/cache/lsyscache.c
M src/include/utils/lsyscache.h
M src/test/regress/expected/replica_identity.out
M src/test/regress/sql/replica_identity.sql

Fix test case instability introduced in 085b6b667.

commit   : 630590d6ff632b95418eff9e98482d9a93b60ee3    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 11 Mar 2020 18:23:57 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 11 Mar 2020 18:23:57 -0400    

Click here for diff

I forgot that the WAL directory might hold other files besides WAL  
segments, notably including new segments still being filled.  
That means a blind test for the first file's size being 16MB can  
fail.  Restrict based on file name length to make it more robust.  
  
Per buildfarm.  

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

Paper over bt_metap() oldest_xact bug in backbranches.

commit   : 393b449f1a643f5a90a4399dffa3148a94e5beec    
  
author   : Peter Geoghegan <[email protected]>    
date     : Wed, 11 Mar 2020 14:15:02 -0700    
  
committer: Peter Geoghegan <[email protected]>    
date     : Wed, 11 Mar 2020 14:15:02 -0700    

Click here for diff

The data types that contrib/pageinspect's bt_metap() function were  
declared to return as OUT arguments were wrong in some cases.  In  
particular, the oldest_xact column (a TransactionId/xid field) was  
declared integer/int4 within the pageinspect extension's sql file.  This  
led to errors when an oldest_xact value that exceeded 2^31-1 was  
encountered.  
  
We cannot fix the declaration on Postgres 11 or 12.  All we can do is  
ameliorate the problem.  Use "%d" instead of "%u" to format the output  
of the oldest_xact value.  This makes the C code match the declaration,  
suppressing unhelpful error messages that might otherwise make  
bt_metap() totally unusable.  A bogus negative oldest_xact value will be  
displayed instead of raising an error.  
  
This commit addresses the same issue as master branch commit 691e8b2e18,  
which actually fixed the problem.  Backpatch to the 11 and 12 branches  
only, since they are the only branches (other than master) that have  
oldest_xact.  All of the other problematic columns already display bogus  
output for out of range values.  
  
Reported-By: Victor Yegorov  
Bug: #16285  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 11 and 12 only  

M contrib/pageinspect/btreefuncs.c

Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

commit   : f977e6dec8a01f32eee0ccfafc80646d3546b8f7    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 11 Mar 2020 16:54:54 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 11 Mar 2020 16:54:54 -0300    

Click here for diff

pg_dump is oblivious to this kind of dependency, so they're lost on  
dump/restores (and pg_upgrade).  Have pg_dump emit ALTER lines so that  
they're preserved.  Add some pg_dump tests for the whole thing, also.  
  
Reviewed-by: Tom Lane (offlist)  
Reviewed-by: Ibrar Ahmed  
Reviewed-by: Ahsan Hadi (who also reviewed commit 899a04f5ed61)  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/common.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/test/modules/test_pg_dump/t/001_base.pl

Avoid holding a directory FD open across pg_ls_dir_files() calls.

commit   : 3c8864fc1c54d6d58a65f07a306a9c874551d13d    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 11 Mar 2020 15:27:59 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 11 Mar 2020 15:27:59 -0400    

Click here for diff

This coding technique is undesirable because (a) it leaks the FD for  
the rest of the transaction if the SRF is not run to completion, and  
(b) allocated FDs are a scarce resource, but multiple interleaved  
uses of the relevant functions could eat many such FDs.  
  
In v11 and later, a query such as "SELECT pg_ls_waldir() LIMIT 1"  
yields a warning about the leaked FD, and the only reason there's  
no warning in earlier branches is that fd.c didn't whine about such  
leaks before commit 9cb7db3f0.  Even disregarding the warning, it  
wouldn't be too hard to run a backend out of FDs with careless use  
of these SQL functions.  
  
Hence, rewrite the function so that it reads the directory within  
a single call, returning the results as a tuplestore rather than  
via value-per-call mode.  
  
There are half a dozen other built-in SRFs with similar problems,  
but let's fix this one to start with, just to see if the buildfarm  
finds anything wrong with the code.  
  
In passing, fix bogus error report for stat() failure: it was  
whining about the directory when it should be fingering the  
individual file.  Doubtless a copy-and-paste error.  
  
Back-patch to v10 where this function was added.  
  
Justin Pryzby, with cosmetic tweaks and test cases by me  
  
Discussion: https://postgr.es/m/[email protected]  

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

Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

commit   : b7739ebecdcc157be2fee348912ae3197383895f    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 11 Mar 2020 11:04:59 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 11 Mar 2020 11:04:59 -0300    

Click here for diff

If the command is attempted for an extension that the object already  
depends on, silently do nothing.  
  
In particular, this means that if a database containing multiple such  
entries is dumped, the restore will silently do the right thing and  
record just the first one.  (At least, in a world where pg_dump does  
dump such entries -- which it doesn't currently, but it will.)  
  
Backpatch to 9.6, where this kind of dependency was introduced.  
  
Reviewed-by: Ibrar Ahmed, Tom Lane (offlist)  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/pg_depend.c
M src/backend/commands/alter.c
M src/include/catalog/dependency.h
M src/test/modules/test_extensions/expected/test_extdepend.out
M src/test/modules/test_extensions/sql/test_extdepend.sql

Prevent reindex of invalid indexes on TOAST tables

commit   : 8bca5f93547c77f3beb5ac679d6471504fc09a43    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 10 Mar 2020 15:38:34 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 10 Mar 2020 15:38:34 +0900    

Click here for diff

Such indexes can only be duplicated leftovers of a previously failed  
REINDEX CONCURRENTLY command, and a valid equivalent is guaranteed to  
exist.  As toast indexes can only be dropped if invalid, reindexing  
these would lead to useless duplicated indexes that can't be dropped  
anymore, except if the parent relation is dropped.  
  
Thanks to Justin Pryzby for reminding that this problem was reported  
long ago during the review of the original patch of REINDEX  
CONCURRENTLY, but the issue was never addressed.  
  
Reported-by: Sergei Kornilov, Justin Pryzby  
Author: Julien Rouhaud  
Reviewed-by: Michael Paquier  
Discussion: https://postgr.es/m/36712441546604286%40sas1-890ba5c2334a.qloud-c.yandex.net  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/backend/catalog/index.c
M src/backend/commands/indexcmds.c
M src/backend/utils/cache/lsyscache.c
M src/include/utils/lsyscache.h

Fix pg_dump/pg_restore to restore event triggers later.

commit   : 4c40b27b5064ca52fb1acd0068811c9d728c79c4    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 9 Mar 2020 14:58:11 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 9 Mar 2020 14:58:11 -0400    

Click here for diff

Previously, event triggers were restored just after regular triggers  
(and FK constraints, which are basically triggers).  This is risky  
since an event trigger, once installed, could interfere with subsequent  
restore commands.  Worse, because event triggers don't have any  
particular dependencies on any post-data objects, a parallel restore  
would consider them eligible to be restored the moment the post-data  
phase starts, allowing them to also interfere with restoration of a  
whole bunch of objects that would have been restored before them in  
a serial restore.  There's no way to completely remove the risk of a  
misguided event trigger breaking the restore, since if nothing else  
it could break other event triggers.  But we can certainly push them  
to later in the process to minimize the hazard.  
  
To fix, tweak the RestorePass mechanism introduced by commit 3eb9a5e7c  
so that event triggers are handled as part of the post-ACL processing  
pass (renaming the "REFRESH" pass to "POST_ACL" to reflect its more  
general use).  This will cause them to restore after everything except  
matview refreshes, which seems OK since matview refreshes really ought  
to run in the post-restore state of the database.  In a parallel  
restore, event triggers and matview refreshes might be intermixed,  
but that seems all right as well.  
  
Also update the code and comments in pg_dump_sort.c so that its idea  
of how things are sorted agrees with what actually happens due to  
the RestorePass mechanism.  This is mostly cosmetic: it'll affect the  
order of objects in a dump's TOC, but not the actual restore order.  
But not changing that would be quite confusing to somebody reading  
the code.  
  
Back-patch to all supported branches.  
  
Fabrízio de Royes Mello, tweaked a bit by me  
  
Discussion: https://postgr.es/m/CAFcNs+ow1hmFox8P--3GSdtwz-S3Binb6ZmoP6Vk+Xg=K6eZNA@mail.gmail.com  

M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_archiver.h
M src/bin/pg_dump/pg_dump_sort.c

Fix bug that causes to report waiting in PS display twice, in hot standby.

commit   : 82c04e4836adddffe7c78ead525ff61fd5871645    
  
author   : Fujii Masao <[email protected]>    
date     : Tue, 10 Mar 2020 00:14:43 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Tue, 10 Mar 2020 00:14:43 +0900    

Click here for diff

Previously "waiting" could appear twice via PS in case of lock conflict  
in hot standby mode. Specifically this issue happend when the delay  
in WAL application determined by max_standby_archive_delay and  
max_standby_streaming_delay had passed but it took more than 500 msec  
to cancel all the conflicting transactions. Especially we can observe this  
easily by setting those delay parameters to -1.  
  
The cause of this issue was that WaitOnLock() and  
ResolveRecoveryConflictWithVirtualXIDs() added "waiting" to  
the process title in that case. This commit prevents  
ResolveRecoveryConflictWithVirtualXIDs() from reporting waiting  
in case of lock conflict, to fix the bug.  
  
Back-patch to all back branches.  
  
Author: Masahiko Sawada  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/CA+fd4k4mXWTwfQLS3RPwGr4xnfAEs1ysFfgYHvmmoUgv6Zxvmg@mail.gmail.com  

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

Avoid assertion failure with targeted recovery in standby mode.

commit   : 412c298c9c677937fc7f5fdab5c0b21d2c9ec512    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 9 Mar 2020 15:31:31 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 9 Mar 2020 15:31:31 +0900    

Click here for diff

At the end of recovery, standby mode is turned off to re-fetch the last  
valid record from archive or pg_wal. Previously, if recovery target was  
reached and standby mode was turned off while the current WAL source  
was stream, recovery could try to retrieve WAL file containing the last  
valid record unexpectedly from stream even though not in standby mode.  
This caused an assertion failure. That is, the assertion test confirms that  
WAL file should not be retrieved from stream if standby mode is not true.  
  
This commit moves back the current WAL source to archive if it's stream  
even though not in standby mode, to avoid that assertion failure.  
  
This issue doesn't cause the server to crash when built with assertion  
disabled. In this case, the attempt to retrieve WAL file from stream not  
in standby mode just fails. And then recovery tries to retrieve WAL file  
from archive or pg_wal.  
  
Back-patch to all supported branches.  
  
Author: Kyotaro Horiguchi  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

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

Doc: fix some description of environment variables with frontend tools

commit   : 654bd6985df897d3c9eb0be403e44d1871e4e352    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 9 Mar 2020 10:54:55 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 9 Mar 2020 10:54:55 +0900    

Click here for diff

This addresses a couple of issues in the documentation:  
- Description of PG_COLOR was missing for some tools (pg_archivecleanup  
and pg_test_fsync), while the other descriptions had grammar mistakes.  
- pgbench supports more environment variables: PGUSER, PGHOST and  
PGPORT.  
- vacuumlo, oid2name and pgbench support coloring (HEAD only)  
  
Author: Michael Paquier  
Reviewed-by: Fabien Coelho, Daniel Gustafsson, Juan José Santamaría  
Flecha  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M doc/src/sgml/ref/clusterdb.sgml
M doc/src/sgml/ref/createdb.sgml
M doc/src/sgml/ref/createuser.sgml
M doc/src/sgml/ref/dropdb.sgml
M doc/src/sgml/ref/dropuser.sgml
M doc/src/sgml/ref/initdb.sgml
M doc/src/sgml/ref/pg_basebackup.sgml
M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/ref/pg_controldata.sgml
M doc/src/sgml/ref/pg_dump.sgml
M doc/src/sgml/ref/pg_dumpall.sgml
M doc/src/sgml/ref/pg_isready.sgml
M doc/src/sgml/ref/pg_receivewal.sgml
M doc/src/sgml/ref/pg_recvlogical.sgml
M doc/src/sgml/ref/pg_resetwal.sgml
M doc/src/sgml/ref/pg_restore.sgml
M doc/src/sgml/ref/pg_rewind.sgml
M doc/src/sgml/ref/pg_waldump.sgml
M doc/src/sgml/ref/pgarchivecleanup.sgml
M doc/src/sgml/ref/pgbench.sgml
M doc/src/sgml/ref/pgtestfsync.sgml
M doc/src/sgml/ref/psql-ref.sgml
M doc/src/sgml/ref/reindexdb.sgml
M doc/src/sgml/ref/vacuumdb.sgml

Fix typo

commit   : b2019c21345d9e1af0f12b76a904b49665f3d829    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sat, 7 Mar 2020 08:51:59 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sat, 7 Mar 2020 08:51:59 +0100    

Click here for diff

M src/backend/catalog/objectaddress.c

Fix more issues with dependency handling at swap phase of REINDEX CONCURRENTLY

commit   : 26876127be2cbbb3ecb18bf75c0670bfb1a3d289    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 5 Mar 2020 12:50:23 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 5 Mar 2020 12:50:23 +0900    

Click here for diff

When canceling a REINDEX CONCURRENTLY operation after swapping is done,  
a drop of the parent table would leave behind old indexes.  This is a  
consequence of 68ac9cf, which fixed the case of pg_depend bloat when  
repeating REINDEX CONCURRENTLY on the same relation.  
  
In order to take care of the problem without breaking the previous fix,  
this uses a different strategy, possible even with the exiting set of  
routines to handle dependency changes.  The dependencies of/on the  
new index are additionally switched to the old one, allowing an old  
invalid index remaining around because of a cancellation or a failure to  
use the dependency links of the concurrently-created index.  This  
ensures that dropping any objects the old invalid index depends on also  
drops the old index automatically.  
  
Reported-by: Julien Rouhaud  
Author: Michael Paquier  
Reviewed-by: Julien Rouhaud  
Discussion: https://postgr.es/m/20200227080735.l32fqcauy73lon7o@nol  
Backpatch-through: 12  

M src/backend/catalog/index.c

Fix assertion failure with ALTER TABLE ATTACH PARTITION and indexes

commit   : dc8364824f80cf60f8d2f5a617b0470992e293dd    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 3 Mar 2020 13:56:11 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 3 Mar 2020 13:56:11 +0900    

Click here for diff

Using ALTER TABLE ATTACH PARTITION causes an assertion failure when  
attempting to work on a partitioned index, because partitioned indexes  
cannot have partition bounds.  
  
The grammar of ALTER TABLE ATTACH PARTITION requires partition bounds,  
but not ALTER INDEX, so mixing ALTER TABLE with partitioned indexes is  
confusing.  Hence, on HEAD, prevent ALTER TABLE to attach a partition if  
the relation involved is a partitioned index.  On back-branches, as  
applications may rely on the existing behavior, just remove the  
culprit assertion.  
  
Reported-by: Alexander Lakhin  
Author: Amit Langote, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 11  

M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/indexing.out
M src/test/regress/sql/indexing.sql

Fix the name of the first WAL segment file, in docs.

commit   : f22feedc253502771533a48197050e6c5f9f5ab9    
  
author   : Fujii Masao <[email protected]>    
date     : Tue, 3 Mar 2020 12:22:04 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Tue, 3 Mar 2020 12:22:04 +0900    

Click here for diff

Previously the documentation explains that WAL segment files  
start at 000000010000000000000000. But the first WAL segment file  
that initdb creates is 000000010000000000000001 not  
000000010000000000000000. This change was caused by old  
commit 8c843fff2d, but the documentation had not been updated  
a long time.  
  
Back-patch to all supported branches.  
  
Author: Fujii Masao  
Reviewed-by: David Zhang  
Discussion: https://postgr.es/m/CAHGQGwHOmGe2OqGOmp8cOfNVDivq7dbV74L5nUGr+3eVd2CU2Q@mail.gmail.com  

M doc/src/sgml/wal.sgml

Preserve pg_index.indisclustered across REINDEX CONCURRENTLY

commit   : f087d63a45b5935b5c15cecb7d88f140d5cc8b7c    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 3 Mar 2020 10:12:49 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 3 Mar 2020 10:12:49 +0900    

Click here for diff

If the flag value is lost, a CLUSTER query following REINDEX  
CONCURRENTLY could fail.  Non-concurrent REINDEX is already handling  
this case consistently.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

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

Fix command-line colorization on Windows with VT100-compatible environments

commit   : 3b5709e664c44c75c1d27a20c59fdbb0dec3ded5    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 2 Mar 2020 15:46:24 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 2 Mar 2020 15:46:24 +0900    

Click here for diff

When setting PG_COLOR to "always" or "auto" in a Windows terminal  
VT100-compatible, the colorization output was not showing up correctly  
because it is necessary to update the console's output handling mode.  
This fix allows to detect automatically if the environment is compatible  
with VT100.  Hence, PG_COLOR=auto is able to detect and handle both  
compatible and non-compatible environments.  The behavior of  
PG_COLOR=always remains unchanged, as it enforces the use of colorized  
output even if the environment does not allow it.  
  
This fix is based on an initial suggestion from Thomas Munro.  
  
Reported-by: Haiying Tang  
Author: Juan José Santamaría Flecha  
Reviewed-by: Michail Nikolaev, Michael Paquier, Haiying Tang  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/common/logging.c

Correctly re-use hash tables in buildSubPlanHash().

commit   : 96d783ae55b9406f1b5e689e1e7afe8d21e3a549    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 29 Feb 2020 13:48:10 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 29 Feb 2020 13:48:10 -0500    

Click here for diff

Commit 356687bd8 omitted to remove leftover code for destroying  
a hashed subplan's hash tables, with the result that the tables  
were always rebuilt not reused; this leads to severe memory  
leakage if a hashed subplan is re-executed enough times.  
Moreover, the code for reusing the hashnulls table had a typo  
that would have made it do the wrong thing if it were reached.  
  
Looking at the code coverage report shows severe under-coverage  
of the potential callers of ResetTupleHashTable, so add some test  
cases that exercise them.  
  
Andreas Karlsson and Tom Lane, per reports from Ranier Vilela  
and Justin Pryzby.  
  
Backpatch to v11, as the faulty commit was.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAEudQAo=DCebm1RXtig9OH+QivpS97sMkikt0A9qHmMUs+g6ZA@mail.gmail.com  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/nodeSubplan.c
M src/test/regress/expected/subselect.out
M src/test/regress/sql/subselect.sql

Avoid failure if autovacuum tries to access a just-dropped temp namespace.

commit   : d7684c38a5e9db15c205371528ea3686235229f4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 28 Feb 2020 20:28:34 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 28 Feb 2020 20:28:34 -0500    

Click here for diff

Such an access became possible when commit 246a6c8f7 added more  
aggressive cleanup of orphaned temp relations by autovacuum.  
Since autovacuum's snapshot might be slightly stale, it could  
attempt to access an already-dropped temp namespace, resulting in  
an assertion failure or null-pointer dereference.  (In practice,  
since we don't drop temp namespaces automatically but merely  
recycle them, this situation could only arise if a superuser does  
a manual drop of a temp namespace.  Still, that should be allowed.)  
  
The core of the bug, IMO, is that isTempNamespaceInUse and its callers  
failed to think hard about whether to treat "temp namespace isn't there"  
differently from "temp namespace isn't in use".  In hopes of forestalling  
future mistakes of the same ilk, replace that function with a new one  
checkTempNamespaceStatus, which makes the same tests but returns a  
three-way enum rather than just a bool.  isTempNamespaceInUse is gone  
entirely in HEAD; but just in case some external code is relying on it,  
keep it in the back branches, as a bug-compatible wrapper around the  
new function.  
  
Per report originally from Prabhat Kumar Sahu, investigated by Mahendra  
Singh and Michael Paquier; the final form of the patch is my fault.  
This replaces the failed fix attempt in a052f6cbb.  
  
Backpatch as far as v11, as 246a6c8f7 was.  
  
Discussion: https://postgr.es/m/CAKYtNAr9Zq=1-ww4etHo-VCC-k120YxZy5OS01VkaLPaDbv2tg@mail.gmail.com  

M src/backend/catalog/namespace.c
M src/backend/postmaster/autovacuum.c
M src/include/catalog/namespace.h

Doc: correct thinko in pg_buffercache documentation.

commit   : e198334034ef683558f857d513ff7f73f7c8c7bd    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 28 Feb 2020 11:29:58 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 28 Feb 2020 11:29:58 -0500    

Click here for diff

Access to this module is granted to the pg_monitor role, not  
pg_read_all_stats.  (Given the view's performance impact,  
it seems wise to be restrictive, so I think this was the  
correct decision --- and anyway it was clearly intentional.)  
  
Per bug #16279 from Philip Semanchuk.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/pgbuffercache.sgml

Remove TAP test for createdb --lc-ctype

commit   : aeb846edbf9cee131593bd9743493d501a554ff2    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 27 Feb 2020 21:58:45 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 27 Feb 2020 21:58:45 +0900    

Click here for diff

OpenBSD falls back to "C" when using an incorrect input with setlocale()  
and LC_CTYPE, causing this test, introduced by 008cf04, to fail.  This  
removes the culprit test to avoid the portability issue.  
  
Per report from Robert Haas, via buildfarm member curculio.  
  
Discussion: https://postgr.es/m/CA+TgmoZ6ddh3mHD9gU8DvNYoFmuJaYYn1+4AvZNp25vTdRwCAQ@mail.gmail.com  
Backpatch-through: 11  

M src/bin/scripts/t/020_createdb.pl

Skip foreign tablespaces when running pg_checksums/pg_verify_checksums

commit   : f6e8e8b3809b58a0ab6c5369e8baa1fd9b96e73e    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 27 Feb 2020 15:31:48 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 27 Feb 2020 15:31:48 +0900    

Click here for diff

Attempting to use pg_checksums (pg_verify_checksums in 11) on a data  
folder which includes tablespace paths used across multiple major  
versions would cause pg_checksums to scan all directories present in  
pg_tblspc, and not only marked with TABLESPACE_VERSION_DIRECTORY.  This  
could lead to failures when for example running sanity checks on an  
upgraded instance with --check.  Even worse, it was possible to rewrite  
on-disk pages with --enable for a cluster potentially online.  
  
This commit makes pg_checksums skip any directories not named  
TABLESPACE_VERSION_DIRECTORY, similarly to what is done for base  
backups.  
  
Reported-by: Michael Banck  
Author: Michael Banck, Bernd Helmle  
Discussion: https://postgr.es/m/[email protected]  
backpatch-through: 11  

M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_checksums/t/002_actions.pl

createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate

commit   : 943affb3d1db38ba0960ee9a0666ea2598b78f1f    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 27 Feb 2020 11:21:00 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 27 Feb 2020 11:21:00 +0900    

Click here for diff

The original coding failed to properly quote those arguments, leading to  
failures when using quotes in the values used.  As the quoting can be  
encoding-sensitive, the connection to the backend needs to be taken  
before applying the correct quoting.  
  
Author: Michael Paquier  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 9.5  

M src/bin/scripts/createdb.c
M src/bin/scripts/t/020_createdb.pl

Suppress unnecessary RelabelType nodes in more cases.

commit   : 30d5c6bf2e09fe76448e59e9889ab5b38171da34    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 26 Feb 2020 18:13:58 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 26 Feb 2020 18:13:58 -0500    

Click here for diff

eval_const_expressions sometimes produced RelabelType nodes that  
were useless because they just relabeled an expression to the same  
exposed type it already had.  This is worth avoiding because it can  
cause two equivalent expressions to not be equal(), preventing  
recognition of useful optimizations.  In the test case added here,  
an unpatched planner fails to notice that the "sqli = constant" clause  
renders a sort step unnecessary, because one code path produces an  
extra RelabelType and another doesn't.  
  
Fix by ensuring that eval_const_expressions_mutator's T_RelabelType  
case will not add in an unnecessary RelabelType.  Also save some  
code by sharing a subroutine with the effectively-equivalent cases  
for CollateExpr and CoerceToDomain.  (CollateExpr had no bug, and  
I think that the case couldn't arise with CoerceToDomain, but  
it seems prudent to do the same check for all three cases.)  
  
Back-patch to v12.  In principle this has been wrong all along,  
but I haven't seen a case where it causes visible misbehavior  
before v12, so refrain from changing stable branches unnecessarily.  
  
Per investigation of a report from Eric Gillum.  
  
Discussion: https://postgr.es/m/CAMmjdmvAZsUEskHYj=KT9sTukVVCiCSoe_PBKOXsncFeAUDPCQ@mail.gmail.com  

M src/backend/optimizer/util/clauses.c
M src/test/regress/expected/equivclass.out
M src/test/regress/sql/equivclass.sql

Fix docs regarding AFTER triggers on partitioned tables

commit   : 902f40dc774b00fe906aca594df42278d832681d    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 26 Feb 2020 19:57:14 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 26 Feb 2020 19:57:14 -0300    

Click here for diff

In commit 86f575948c77 I forgot to update the trigger.sgml paragraph  
that needs to explain that AFTER triggers are allowed in partitioned  
tables.  Do so now.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/trigger.sgml

Add prefix checks in exclude lists for pg_rewind, pg_checksums and base backups

commit   : a8beece956ebf0659e64e229519f6e87b13b8b3a    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 24 Feb 2020 18:14:16 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 24 Feb 2020 18:14:16 +0900    

Click here for diff

An instance of PostgreSQL crashing with a bad timing could leave behind  
temporary pg_internal.init files, potentially causing failures when  
verifying checksums.  As the same exclusion lists are used between  
pg_rewind, pg_checksums and basebackup.c, all those tools are extended  
with prefix checks to keep everything in sync, with dedicated checks  
added for pg_internal.init.  
  
Backpatch down to 11, where pg_checksums (pg_verify_checksums in 11) and  
checksum verification for base backups have been introduced.  
  
Reported-by: Michael Banck  
Author: Michael Paquier  
Reviewed-by: Kyotaro Horiguchi, David Steele  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 11  

M src/backend/replication/basebackup.c
M src/bin/pg_basebackup/t/010_pg_basebackup.pl
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_checksums/t/002_actions.pl
M src/bin/pg_rewind/filemap.c

Doc: Fix instructions to control build environment with MSVC

commit   : 4c95ce048327d465382f265303555ebf32e5dcd0    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 21 Feb 2020 12:05:36 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 21 Feb 2020 12:05:36 +0900    

Click here for diff

The documentation included some outdated instructions to change the  
architecture, build type or target OS of a build done with MSVC.  This  
commit updates the documentation to include the modern options  
available, down to Visual Studio 2013.  
  
Reported-by: Kyotaro Horiguchi  
Author: Juan José Santamaría Flecha  
Discussion: https://postgr.es/m/CAC+AXB0J7tAqW_2F1fCE4Dh2=Ccz96TcLpsGXOCvka7VvWG9Qw@mail.gmail.com  
Backpatch-through: 12  

M doc/src/sgml/install-windows.sgml

Simplify FK-to-partitioned regression test query

commit   : 3f50d5ced3f854119862b1ce60a6f3c5d38a4386    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 20 Feb 2020 14:14:20 -0300    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 20 Feb 2020 14:14:20 -0300    

Click here for diff

Avoid a join between relations having the FK to detect FK violation.  
The planner might optimize this considering the PK must exist on the  
referenced side at some point, effectively masking a bug this test  
tries to detect.  
  
Tom Lane and Jehan-Guillaume de Rorthais  
Discussion: https://postgr.es/m/[email protected]  

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

Remove extra word from comment.

commit   : aab50a7ae4945d63be33c322929822fed9bab57a    
  
author   : Etsuro Fujita <[email protected]>    
date     : Thu, 20 Feb 2020 19:15:01 +0900    
  
committer: Etsuro Fujita <[email protected]>    
date     : Thu, 20 Feb 2020 19:15:01 +0900    

Click here for diff

M src/backend/partitioning/partbounds.c

Doc: discourage use of partial indexes for poor-man's-partitioning.

commit   : fb4815c066c8f8ded20112c749f09192c0a03709    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 19 Feb 2020 18:52:18 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 19 Feb 2020 18:52:18 -0500    

Click here for diff

Creating a bunch of non-overlapping partial indexes is generally  
a bad idea, so add an example saying not to do that.  
  
Back-patch to v10.  Before that, the alternative of using (real)  
partitioning wasn't available, so that the tradeoff isn't quite  
so clear cut.  
  
Discussion: https://postgr.es/m/CAKVFrvFY-f7kgwMRMiPLbPYMmgjc8Y2jjUGK_Y0HVcYAmU6ymg@mail.gmail.com  

M doc/src/sgml/indices.sgml

Fix typo

commit   : 09e40f2b68e1a04d7d0bb0e91f56df0d64b21786    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 19 Feb 2020 20:52:42 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 19 Feb 2020 20:52:42 +0100    

Click here for diff

Reported-by: Daniel Verite <[email protected]>  

M src/common/unicode_norm.c

Fix confusion about event trigger vs. plain function in plpgsql.

commit   : 32aa14d40c7ce12e648c9f88fe22fa0146bee3b4    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 19 Feb 2020 14:44:58 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 19 Feb 2020 14:44:58 -0500    

Click here for diff

The function hash table keys made by compute_function_hashkey() failed  
to distinguish event-trigger call context from regular call context.  
This meant that once we'd successfully made a hash entry for an event  
trigger (either by validation, or by normal use as an event trigger),  
an attempt to call the trigger function as a plain function would  
find this hash entry and thereby bypass the you-can't-do-that check in  
do_compile().  Thus we'd attempt to execute the function, leading to  
strange errors or even crashes, depending on function contents and  
server version.  
  
To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,  
paralleling the longstanding infrastructure for regular triggers.  
This fits into what had been pad space, so there's no risk of an ABI  
break, even assuming that any third-party code is looking at these  
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype  
enum field, but felt that that carried some API/ABI risk.  Maybe we  
should change it in HEAD though.)  
  
Per bug #16266 from Alexander Lakhin.  This has been broken since  
event triggers were invented, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/pl/plpgsql/src/pl_comp.c
M src/pl/plpgsql/src/plpgsql.h
M src/test/regress/expected/event_trigger.out
M src/test/regress/sql/event_trigger.sql

Fix mesurement of elapsed time during truncating heap in VACUUM.

commit   : 16e6c968be64db82a9680961e2e69d38cdfbd408    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 19 Feb 2020 20:37:26 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 19 Feb 2020 20:37:26 +0900    

Click here for diff

VACUUM may truncate heap in several batches. The activity report  
is logged for each batch, and contains the number of pages in the table  
before and after the truncation, and also the elapsed time during  
the truncation. Previously the elapsed time reported in each batch was  
the total elapsed time since starting the truncation until finishing  
each batch. For example, if the truncation was processed dividing into  
three batches, the second batch reported the accumulated time elapsed  
during both first and second batches. This is strange and confusing  
because the number of pages in the table reported together is not  
total. Instead, each batch should report the time elapsed during  
only that batch.  
  
The cause of this issue was that the resource usage snapshot was  
initialized only at the beginning of the truncation and was never  
reset later. This commit fixes the issue by changing VACUUM so that  
the resource usage snapshot is reset at each batch.  
  
Back-patch to all supported branches.  
  
Reported-by: Tatsuhito Kasahara  
Author: Tatsuhito Kasahara  
Reviewed-by: Masahiko Sawada, Fujii Masao  
Discussion: https://postgr.es/m/CAP0=ZVJsf=NvQuy+QXQZ7B=ZVLoDV_JzsVC1FRsF1G18i3zMGg@mail.gmail.com  

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

Stop demanding that top xact must be seen before subxact in decoding.

commit   : 59112f235549171dfc8418edf5184c104e14610c    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 19 Feb 2020 08:27:15 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 19 Feb 2020 08:27:15 +0530    

Click here for diff

Manifested as  
  
ERROR:  subtransaction logged without previous top-level txn record  
  
this check forbids legit behaviours like  
 - First xl_xact_assignment record is beyond reading, i.e. earlier  
   restart_lsn.  
 - After restart_lsn there is some change of a subxact.  
 - After that, there is second xl_xact_assignment (for another subxact)  
   revealing the relationship between top and first subxact.  
  
Such a transaction won't be streamed anyway because we hadn't seen it in  
full.  Saying for sure whether xact of some record encountered after  
the snapshot was deserialized can be streamed or not requires to know  
whether it wrote something before deserialization point --if yes, it  
hasn't been seen in full and can't be decoded. Snapshot doesn't have such  
info, so there is no easy way to relax the check.  
  
Reported-by: Hsu, John  
Diagnosed-by: Arseny Sher  
Author: Arseny Sher, Amit Kapila  
Reviewed-by: Amit Kapila, Dilip Kumar  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/[email protected]  

M contrib/test_decoding/Makefile
A contrib/test_decoding/expected/subxact_without_top.out
A contrib/test_decoding/specs/subxact_without_top.spec
M src/backend/replication/logical/reorderbuffer.c

Teach pg_dump to dump comments on RLS policy objects.

commit   : 6da7d36305a57f6c2fb337898966335fa0f9b0a5    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 17 Feb 2020 18:40:02 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 17 Feb 2020 18:40:02 -0500    

Click here for diff

This was unaccountably omitted in the original RLS patch.  
The SQL syntax is basically the same as for comments on triggers,  
so crib code from dumpTrigger().  
  
Per report from Marc Munro.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/pg_dump.c

Fill in extraUpdatedCols in logical replication

commit   : 4a97f647ddbc79af2fb91727d4a2502ce667d0fd    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 17 Feb 2020 15:19:58 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 17 Feb 2020 15:19:58 +0100    

Click here for diff

The extraUpdatedCols field of the target RTE records which generated  
columns are affected by an update.  This is used in a variety of  
places, including per-column triggers and foreign data wrappers.  When  
an update was initiated by a logical replication subscription, this  
field was not filled in, so such an update would not affect generated  
columns in a way that is consistent with normal updates.  To fix,  
factor out some code from analyze.c to fill in extraUpdatedCols in the  
logical replication worker as well.  
  
Reviewed-by: Pavel Stehule <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/parser/analyze.c
M src/backend/replication/logical/worker.c
M src/include/parser/analyze.h

Add description about GSSOpenServer wait event into document.

commit   : 0b54741815694cc97041c81e344aa9b3162e529e    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 17 Feb 2020 16:16:08 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 17 Feb 2020 16:16:08 +0900    

Click here for diff

This commit also updates wait event enum into alphabetical order.  
Previously the enum entry for GSSOpenServer was added out-of-order.  
  
Back-patch to v12 where commit b0b39f72b9 introduced  
GSSOpenServer wait event. In v12, the commit doesn't include  
the update of wait event enum, not to break ABI.  
  
Author: Fujii Masao  
Reviewed-by: Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml
M src/backend/postmaster/pgstat.c

Add description about LogicalRewriteTruncate wait event into document.

commit   : 6c221aa56e18b1f1d87e40b33a5d5e48694a6350    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 17 Feb 2020 15:33:32 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 17 Feb 2020 15:33:32 +0900    

Click here for diff

Back-patch to v10 where commit 249cf070e3 introduced  
LogicalRewriteTruncate wait event.  
  
Author: Fujii Masao  
Reviewed-by: Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml

Try again to work around Windows' ERROR_SHARING_VIOLATION in pg_ctl.

commit   : de5e03f7fe737887f960fb49813cc62c2f8f3ec2    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 16 Feb 2020 12:20:18 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 16 Feb 2020 12:20:18 -0500    

Click here for diff

Commit 0da33c762 introduced an unfortunate regression in pg_ctl on  
Windows: if the log file specified with -l doesn't exist yet, and  
pg_ctl is running with Administrator privileges, then the log file  
might get created with permissions that prevent the postmaster from  
writing on it.  (It seems that whether this happens depends on whether  
the log file is inside the user's home directory or not, and perhaps  
on other phase-of-the-moon conditions, which may explain why we failed  
to notice it sooner.)  
  
To fix, just don't create the log file if it doesn't exist yet.  The  
case where we need to wait obviously only occurs with a pre-existing  
log file.  
  
In passing, switch from using fopen() to plain open(), saving a few  
cycles.  
  
Per bug #16259 from Jonathan Katz and Heath Lord.  Back-patch to v12,  
as the faulty commit was.  
  
Alexander Lakhin  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_ctl/pg_ctl.c

Avoid a performance regression in float overflow/underflow detection.

commit   : 764a554d6f5e811fca63b9303114af8890802a1b    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 13 Feb 2020 13:37:43 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 13 Feb 2020 13:37:43 -0500    

Click here for diff

Commit 6bf0bc842 replaced float.c's CHECKFLOATVAL() macro with static  
inline subroutines, but that wasn't too well thought out.  In the original  
coding, the unlikely condition (isinf(result) or result == 0) was checked  
first, and the inf_is_valid or zero_is_valid condition only afterwards.  
The inline-subroutine coding caused that to be swapped around, which is  
pretty horrid for performance because (a) in common cases the is_valid  
condition is twice as expensive to evaluate (e.g., requiring two isinf()  
calls not one) and (b) in common cases the is_valid condition is false,  
requiring us to perform the unlikely-condition check anyway.  Net result  
is that one isinf() call becomes two or three, resulting in visible  
performance loss as reported by Keisuke Kuroda.  
  
The original fix proposal was to revert the replacement of the macro,  
but on second thought, that macro was just a bad idea from the beginning:  
if anything it's a net negative for readability of the code.  So instead,  
let's just open-code all the overflow/underflow tests, being careful to  
test the unlikely condition first (and mark it unlikely() to help the  
compiler get the point).  
  
Also, rather than having N copies of the actual ereport() calls, collapse  
those into out-of-line error subroutines to save some code space.  This  
does mean that the error file/line numbers won't be very helpful for  
figuring out where the issue really is --- but we'd already burned that  
bridge by putting the ereports into static inlines.  
  
In HEAD, check_float[48]_val() are gone altogether.  In v12, leave them  
present in float.h but unused in the core code, just in case some  
extension is depending on them.  
  
Emre Hasegeli, with some kibitzing from me and Andres Freund  
  
Discussion: https://postgr.es/m/CANDwggLe1Gc1OrRqvPfGE=kM9K0FSfia0hbeFCEmwabhLz95AA@mail.gmail.com  

M src/backend/utils/adt/float.c
M src/backend/utils/adt/geo_ops.c
M src/include/utils/float.h

Doc: fix old oversights in GRANT/REVOKE documentation.

commit   : 2efefd28add2b91da87739b52d04522a61676fc9    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 12 Feb 2020 14:13:13 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 12 Feb 2020 14:13:13 -0500    

Click here for diff

The GRANTED BY clause in GRANT/REVOKE ROLE has been there since 2005  
but was never documented.  I'm not sure now whether that was just an  
oversight or was intentional (given the limited capability of the  
option).  But seeing that pg_dumpall does emit code that uses this  
option, it seems like not documenting it at all is a bad idea.  
  
Also, when we upgraded the syntax to allow CURRENT_USER/SESSION_USER  
as the privilege recipient, the role form of GRANT was incorrectly  
not modified to show that, and REVOKE's docs weren't touched at all.  
  
Although I'm not that excited about GRANTED BY, the other oversight  
seems serious enough to justify a back-patch.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/grant.sgml
M doc/src/sgml/ref/revoke.sgml

Document the pg_upgrade -j/--jobs option as taking an argument

commit   : 3ba8a38000861c37a26aab9298d2fb3800cbd9d6    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 11 Feb 2020 23:47:36 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 11 Feb 2020 23:47:36 +0100    

Click here for diff

M doc/src/sgml/ref/pgupgrade.sgml
M src/bin/pg_upgrade/option.c