PostgreSQL 14.0 (upcoming) commit log

Fix outdated --help message for postgres -f

commit   : 63b64d8270691894a9a8f2d4e929e7780020edb8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 15 Aug 2022 13:37:38 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 15 Aug 2022 13:37:38 +0900    

Click here for diff

This option switch supports a total of 8 values, as told by  
set_plan_disabling_options() and the documentation, but this was not  
reflected in the output generated by --help.  
  
Author: Junwang Zhao  
Discussion: https://postgr.es/m/CAEG8a3+pT3cWzyjzKs184L1XMNm8NDnoJLiSjAYSO7XqpRh_vA@mail.gmail.com  
Backpatch-through: 10  

M src/backend/main/main.c

Preserve memory context of VarStringSortSupport buffers.

commit   : 06602372b36df2b36e4db5ac30504dad878ea254    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 14 Aug 2022 12:05:27 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 14 Aug 2022 12:05:27 -0400    

Click here for diff

When enlarging the work buffers of a VarStringSortSupport object,  
varstrfastcmp_locale was careful to keep them in the ssup_cxt  
memory context; but varstr_abbrev_convert just used palloc().  
The latter creates a hazard that the buffers could be freed out  
from under the VarStringSortSupport object, resulting in stomping  
on whatever gets allocated in that memory later.  
  
In practice, because we only use this code for ICU collations  
(cf. 3df9c374e), the problem is confined to use of ICU collations.  
I believe it may have been unreachable before the introduction  
of incremental sort, too, as traditional sorting usually just  
uses one context for the duration of the sort.  
  
We could fix this by making the broken stanzas in varstr_abbrev_convert  
match the non-broken ones in varstrfastcmp_locale.  However, it seems  
like a better idea to dodge the issue altogether by replacing the  
pfree-and-allocate-anew coding with repalloc, which automatically  
preserves the chunk's memory context.  This fix does add a few cycles  
because repalloc will copy the chunk's content, which the existing  
coding assumes is useless.  However, we don't expect that these buffer  
enlargement operations are performance-critical.  Besides that, it's  
far from obvious that copying the buffer contents isn't required, since  
these stanzas make no effort to mark the buffers invalid by resetting  
last_returned, cache_blob, etc.  That seems to be safe upon examination,  
but it's fragile and could easily get broken in future, which wouldn't  
get revealed in testing with short-to-moderate-size strings.  
  
Per bug #17584 from James Inform.  Whether or not the issue is  
reachable in the older branches, this code has been broken on its  
own terms from its introduction, so patch all the way back.  
  
Discussion: https://postgr.es/m/17584-95c79b4a7d771f44@postgresql.org  

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

Avoid misbehavior when hash_table_bytes < bucket_size.

commit   : 1dfc9193af7ff3cde963aa153e21fadbfebe030a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 13 Aug 2022 16:59:58 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 13 Aug 2022 16:59:58 -0400    

Click here for diff

It's possible to reach this case when work_mem is very small and tupsize  
is (relatively) very large.  In that case ExecChooseHashTableSize would  
get an assertion failure, or with asserts off it'd compute nbuckets = 0,  
which'd likely cause misbehavior later (I've not checked).  To fix,  
clamp the number of buckets to be at least 1.  
  
This is due to faulty conversion of old my_log2() coding in 28d936031.  
Back-patch to v13, as that was.  
  
Zhang Mingli  
  
Discussion: https://postgr.es/m/beb64ca0-91e2-44ac-bf4a-7ea36275ec02@Spark  

M src/backend/executor/nodeHash.c

Catch stack overflow when recursing in transformFromClauseItem().

commit   : 496ab1d6c8d853899595e986f04cd70c4b13dac4    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 13 Aug 2022 15:21:28 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 13 Aug 2022 15:21:28 -0400    

Click here for diff

Most parts of the parser can expect that the stack overflow check  
in transformExprRecurse() will trigger before things get desperate.  
However, transformFromClauseItem() can recurse directly to self  
without having analyzed any expressions, so it's possible to drive  
it to a stack-overrun crash.  Add a check to prevent that.  
  
Per bug #17583 from Egor Chindyaskin.  Back-patch to all supported  
branches.  
  
Richard Guo  
  
Discussion: https://postgr.es/m/17583-33be55b9f981f75c@postgresql.org  

M src/backend/parser/parse_clause.c

Add missing fields to _outConstraint()

commit   : 2db574a2184e5e6ae289e48079e8523c9cbdc8c4    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 13 Aug 2022 10:32:38 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 13 Aug 2022 10:32:38 +0200    

Click here for diff

As of 897795240cfaaed724af2f53ed2c50c9862f951f, check constraints can  
be declared invalid.  But that patch didn't update _outConstraint() to  
also show the relevant struct fields (which were only applicable to  
foreign keys before that).  This currently only affects debugging  
output, so no impact in practice.  

M src/backend/nodes/outfuncs.c

pg_upgrade: Fix some minor code issues

commit   : 08c5c6d2833bfae8a27ed7ab3f66513b735321bb    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 13 Aug 2022 00:00:41 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 13 Aug 2022 00:00:41 +0200    

Click here for diff

96ef3b8ff1cf1950e897fd2f766d4bd9ef0d5d56 accidentally copied a not  
applicable comment from the float8_pass_by_value code to the  
data_checksums code.  Remove that.  
  
87d3b35a1ca31a9d947a8f919a6006679216dff0 changed pg_upgrade to  
checking the checksum version rather than just the Boolean presence of  
checksums, but didn't change the field type in its ControlData struct  
from bool.  So this would not work correctly if there ever is a  
checksum version larger than 1.  

M src/bin/pg_upgrade/controldata.c
M src/bin/pg_upgrade/pg_upgrade.h

doc: add missing role attributes to user management section

commit   : 88b54b07916c58c7cd20cc0998dc2c62c060a1f7    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 15:43:23 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 15:43:23 -0400    

Click here for diff

Reported-by: Shinya Kato  
  
Discussion: https://postgr.es/m/1ecdb1ff78e9b03dfce37e85eaca725a@oss.nttdata.com  
  
Author: Shinya Kato  
  
Backpatch-through: 10  

M doc/src/sgml/user-manag.sgml

doc: add section about heap-only tuples (HOT)

commit   : 675a368a35a1ae4aa2c54fbd2a8310e3939d73b8    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 15:05:13 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 15:05:13 -0400    

Click here for diff

Reported-by: Jonathan S. Katz  
  
Discussion: https://postgr.es/m/c59ffbd5-96ac-a5a5-a401-14f627ca1405@postgresql.org  
  
Backpatch-through: 11  

M doc/src/sgml/acronyms.sgml
M doc/src/sgml/btree.sgml
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/config.sgml
M doc/src/sgml/indexam.sgml
M doc/src/sgml/indices.sgml
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/create_table.sgml
M doc/src/sgml/storage.sgml

doc: warn about security issues around log files

commit   : 9039e34e7ed26710e49b4c43d8859387cf4f4faf    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 12:02:20 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 12:02:20 -0400    

Click here for diff

Reported-by: Simon Riggs  
  
Discussion: https://postgr.es/m/CANP8+jJESuuXYq9Djvf-+tx2vY2OFLmfEuu+UvwHNJ1RT7iJCQ@mail.gmail.com  
  
Author: Simon Riggs  
  
Backpatch-through: 10  

M doc/src/sgml/config.sgml
M doc/src/sgml/maintenance.sgml

doc: clarify configuration file for Windows builds

commit   : ec98eac9873bd50d75fc51a440848d07ba158d8f    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 11:35:23 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 11:35:23 -0400    

Click here for diff

The use of file 'config.pl' was not clearly explained.  
  
Reported-by: liambowen@gmail.com  
  
Discussion: https://postgr.es/m/164246013804.31952.4958087335645367498@wrigleys.postgresql.org  
  
Backpatch-through: 10  

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

doc: document the CREATE INDEX "USING" clause

commit   : e6f7892914ab70b40a2ffa71887e3bdcfa668988    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 11:26:03 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 11:26:03 -0400    

Click here for diff

Somehow this was in the syntax but had no description.  
  
Reported-by: robertcorrington@gmail.com  
  
Discussion: https://postgr.es/m/164228771825.31954.2719791849363756957@wrigleys.postgresql.org  
  
Backpatch-through: 10  

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

doc: clarify CREATE TABLE AS ... IF NOT EXISTS

commit   : ff48a0c80ec8dc47ba59161b43058ddcdfbe5b09    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 10:59:00 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 10:59:00 -0400    

Click here for diff

Mention that the table is not modified if it already exists.  
  
Reported-by: frank_limpert@yahoo.com  
  
Discussion: https://postgr.es/m/164441177106.9677.5991676148704507229@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/ref/create_table_as.sgml

doc: improve wal_level docs for the 'minimal' level

commit   : a8fade6cb5ecadca939b2ced770d809631fddd89    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 10:30:01 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 10:30:01 -0400    

Click here for diff

Reported-by: David G. Johnston  
  
Discussion: https://postgr.es/m/CAKFQuwZ24UcfkoyLLSW3PMGQATomOcw1nuYFRuMev-NoOF+mYw@mail.gmail.com  
  
Author: David G. Johnston  
  
Backpatch-through: 14, partial to 13  

M doc/src/sgml/config.sgml

doc: clarify DROP EXTENSION dependent members text

commit   : ec3530f4597540cec9d6ccdb2290899822581128    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 09:06:48 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 12 Aug 2022 09:06:48 -0400    

Click here for diff

Member tracking was added in PG 13.  
  
Reported-by: David G. Johnston  
  
Discussion: https://postgr.es/m/CAKFQuwY1YtxQHVWUFYvSnOjZ5VPpXjF33V52bSKEwFjK2K=1Aw@mail.gmail.com  
  
Author: David G. Johnston  
  
Backpatch-through: 13  

M doc/src/sgml/ref/drop_extension.sgml

Fix _outConstraint() for "identity" constraints

commit   : 3f4069ca2c3efdc5d945fb7a4a5b4a1ecd176719    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 12 Aug 2022 08:17:30 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 12 Aug 2022 08:17:30 +0200    

Click here for diff

The set of fields printed by _outConstraint() in the CONSTR_IDENTITY  
case didn't match the set of fields actually used in that case.  (The  
code was probably uncarefully copied from the CONSTR_DEFAULT case.)  
Fix that by using the right set of fields.  Since there is no read  
support for this node type, this is really just for debugging output  
right now, so it doesn't affect anything important.  

M src/backend/nodes/outfuncs.c

Back-Patch "Add wait_for_subscription_sync for TAP tests."

commit   : e082ef9c4282d4dd9c15585ef7a4da30db1289d5    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 12 Aug 2022 11:16:35 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 12 Aug 2022 11:16:35 +0530    

Click here for diff

This was originally done in commit 0c20dd33db for 16 only, to eliminate  
duplicate code and as an infrastructure that makes it easier to write  
future tests. However, it has been suggested that it would be good to  
back-patch this testing infrastructure to aid future tests in  
back-branches.  
  
Backpatch to all supported versions.  
  
Author: Masahiko Sawada  
Reviewed by: Amit Kapila, Shi yu  
Discussion: https://postgr.es/m/CAD21AoC-fvAkaKHa4t1urupwL8xbAcWRePeETvshvy80f6WV1A@mail.gmail.com  
Discussion: https://postgr.es/m/E1oJBIf-0006sw-SA@gemulon.postgresql.org  

M src/test/perl/PostgresNode.pm
M src/test/subscription/t/001_rep_changes.pl
M src/test/subscription/t/002_types.pl
M src/test/subscription/t/004_sync.pl
M src/test/subscription/t/005_encoding.pl
M src/test/subscription/t/006_rewrite.pl
M src/test/subscription/t/008_diff_schema.pl
M src/test/subscription/t/010_truncate.pl
M src/test/subscription/t/011_generated.pl
M src/test/subscription/t/013_partition.pl
M src/test/subscription/t/014_binary.pl
M src/test/subscription/t/015_stream.pl
M src/test/subscription/t/016_stream_subxact.pl
M src/test/subscription/t/017_stream_ddl.pl
M src/test/subscription/t/018_stream_subxact_abort.pl
M src/test/subscription/t/019_stream_subxact_ddl_abort.pl
M src/test/subscription/t/021_alter_sub_pub.pl
M src/test/subscription/t/100_bugs.pl

Fix catalog lookup with the wrong snapshot during logical decoding.

commit   : 68dcce247f1a13318613a0e27782b2ca21a4ceb7    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 11 Aug 2022 09:45:04 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 11 Aug 2022 09:45:04 +0530    

Click here for diff

Previously, we relied on HEAP2_NEW_CID records and XACT_INVALIDATION  
records to know if the transaction has modified the catalog, and that  
information is not serialized to snapshot. Therefore, after the restart,  
if the logical decoding decodes only the commit record of the transaction  
that has actually modified a catalog, we will miss adding its XID to the  
snapshot. Thus, we will end up looking at catalogs with the wrong  
snapshot.  
  
To fix this problem, this changes the snapshot builder so that it  
remembers the last-running-xacts list of the decoded RUNNING_XACTS record  
after restoring the previously serialized snapshot. Then, we mark the  
transaction as containing catalog changes if it's in the list of initial  
running transactions and its commit record has XACT_XINFO_HAS_INVALS. To  
avoid ABI breakage, we store the array of the initial running transactions  
in the static variables InitialRunningXacts and NInitialRunningXacts,  
instead of storing those in SnapBuild or ReorderBuffer.  
  
This approach has a false positive; we could end up adding the transaction  
that didn't change catalog to the snapshot since we cannot distinguish  
whether the transaction has catalog changes only by checking the COMMIT  
record. It doesn't have the information on which (sub) transaction has  
catalog changes, and XACT_XINFO_HAS_INVALS doesn't necessarily indicate  
that the transaction has catalog change. But that won't be a problem since  
we use snapshot built during decoding only to read system catalogs.  
  
On the master branch, we took a more future-proof approach by writing  
catalog modifying transactions to the serialized snapshot which avoids the  
above false positive. But we cannot backpatch it because of a change in  
the SnapBuild.  
  
Reported-by: Mike Oh  
Author: Masahiko Sawada  
Reviewed-by: Amit Kapila, Shi yu, Takamichi Osumi, Kyotaro Horiguchi, Bertrand Drouvot, Ahsan Hadi  
Backpatch-through: 10  
Discussion: https://postgr.es/m/81D0D8B0-E7C4-4999-B616-1E5004DBDCD2%40amazon.com  

M contrib/test_decoding/Makefile
A contrib/test_decoding/expected/catalog_change_snapshot.out
A contrib/test_decoding/specs/catalog_change_snapshot.spec
M src/backend/replication/logical/decode.c
M src/backend/replication/logical/snapbuild.c
M src/include/replication/snapbuild.h

Fix handling of R/W expanded datums that are passed to SQL functions.

commit   : 95bfadd4e83c17f1a31ab97eb2aba44a38c36324    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 10 Aug 2022 13:37:25 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 10 Aug 2022 13:37:25 -0400    

Click here for diff

fmgr_sql must make expanded-datum arguments read-only, because  
it's possible that the function body will pass the argument to  
more than one callee function.  If one of those functions takes  
the datum's R/W property as license to scribble on it, then later  
callees will see an unexpected value, leading to wrong answers.  
  
From a performance standpoint, it'd be nice to skip this in the  
common case that the argument value is passed to only one callee.  
However, detecting that seems fairly hard, and certainly not  
something that I care to attempt in a back-patched bug fix.  
  
Per report from Adam Mackler.  This has been broken since we  
invented expanded datums, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/WScDU5qfoZ7PB2gXwNqwGGgDPmWzz08VdydcPFLhOwUKZcdWbblbo-0Lku-qhuEiZoXJ82jpiQU4hOjOcrevYEDeoAvz6nR0IU4IHhXnaCA=@mackler.email  
Discussion: https://postgr.es/m/187436.1660143060@sss.pgh.pa.us  

M src/backend/executor/functions.c
M src/test/regress/expected/create_function_3.out
M src/test/regress/sql/create_function_3.sql

Stamp 14.5.

commit   : 278273ccbad27a8834dfdf11895da9cd91de4114    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 16:44:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 16:44:29 -0400    

Click here for diff

M configure
M configure.ac

Stabilize output of new regression test.

commit   : c0d5d52a780fb575d8f93d0b1a8ef8cb43851a84    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 12:16:01 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 12:16:01 -0400    

Click here for diff

Per buildfarm, the output order of \dx+ isn't consistent across  
locales.  Apply NO_LOCALE to force C locale.  There might be a  
more localized way, but I'm not seeing it offhand, and anyway  
there is nothing in this test module that particularly cares  
about locales.  
  
Security: CVE-2022-2625  

M src/test/modules/test_extensions/Makefile

Last-minute updates for release notes.

commit   : ea2917ca905b7a669cc9d90c3b0e4539667a15a4    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 11:28:47 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 11:28:47 -0400    

Click here for diff

Security: CVE-2022-2625  

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

In extensions, don't replace objects not belonging to the extension.

commit   : 5721da7e41e7a280587bda29cd1674c7da3317f8    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 11:12:31 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 8 Aug 2022 11:12:31 -0400    

Click here for diff

Previously, if an extension script did CREATE OR REPLACE and there was  
an existing object not belonging to the extension, it would overwrite  
the object and adopt it into the extension.  This is problematic, first  
because the overwrite is probably unintentional, and second because we  
didn't change the object's ownership.  Thus a hostile user could create  
an object in advance of an expected CREATE EXTENSION command, and would  
then have ownership rights on an extension object, which could be  
modified for trojan-horse-type attacks.  
  
Hence, forbid CREATE OR REPLACE of an existing object unless it already  
belongs to the extension.  (Note that we've always forbidden replacing  
an object that belongs to some other extension; only the behavior for  
previously-free-standing objects changes here.)  
  
For the same reason, also fail CREATE IF NOT EXISTS when there is  
an existing object that doesn't belong to the extension.  
  
Our thanks to Sven Klemm for reporting this problem.  
  
Security: CVE-2022-2625  

M doc/src/sgml/extend.sgml
M src/backend/catalog/pg_collation.c
M src/backend/catalog/pg_depend.c
M src/backend/catalog/pg_operator.c
M src/backend/catalog/pg_type.c
M src/backend/commands/createas.c
M src/backend/commands/foreigncmds.c
M src/backend/commands/schemacmds.c
M src/backend/commands/sequence.c
M src/backend/commands/statscmds.c
M src/backend/commands/view.c
M src/backend/parser/parse_utilcmd.c
M src/include/catalog/dependency.h
M src/test/modules/test_extensions/Makefile
M src/test/modules/test_extensions/expected/test_extensions.out
M src/test/modules/test_extensions/sql/test_extensions.sql
A src/test/modules/test_extensions/test_ext_cine–1.0–1.1.sql
A src/test/modules/test_extensions/test_ext_cine–1.0.sql
A src/test/modules/test_extensions/test_ext_cine.control
A src/test/modules/test_extensions/test_ext_cor–1.0.sql
A src/test/modules/test_extensions/test_ext_cor.control

Translation updates

commit   : 9a8df3307088f2f401cdad06df9351154819de45    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Mon, 8 Aug 2022 12:39:52 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Mon, 8 Aug 2022 12:39:52 +0200    

Click here for diff

Source-Git-URL: ssh://git@git.postgresql.org/pgtranslation/messages.git  
Source-Git-Hash: 20d70fc4a9763d5d31afc422be0be0feb0fb0363  

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

Release notes for 14.5, 13.8, 12.12, 11.17, 10.22.

commit   : 3526a8f7b4242ad5a80fbdf27636625e7b192be6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 7 Aug 2022 15:46:27 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 7 Aug 2022 15:46:27 -0400    

Click here for diff

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

Remove unportable use of timezone in recent test

commit   : f4beef1c2d66cdbfd036117a8cbf9a703d83d33e    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Sun, 7 Aug 2022 10:19:40 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Sun, 7 Aug 2022 10:19:40 +0200    

Click here for diff

Per buildfarm member snapper  
  
Discussion: https://postgr.es/m/129951.1659812518@sss.pgh.pa.us  

M src/test/modules/brin/t/02_wal_consistency.pl

Improve recently-added test reliability

commit   : 9d5c96d9be6476c4a7a3fa227e6e20748f1d827f    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Sat, 6 Aug 2022 15:52:10 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Sat, 6 Aug 2022 15:52:10 +0200    

Click here for diff

Commit 59be1c942a47 already tried to make  
src/test/recovery/t/033_replay_tsp_drops more reliable, but it wasn't  
enough.  Try to improve on that by making this use of a replication slot  
to be more like others.  Also, don't drop the slot.  
  
Make a few other stylistic changes while at it.  It's still quite slow,  
which is another thing that we need to fix in this script.  
  
Backpatch to all supported branches.  
  
Discussion: https://postgr.es/m/349302.1659191875@sss.pgh.pa.us  

M src/test/recovery/t/033_replay_tsp_drops.pl

First-draft release notes for 14.5.

commit   : aab05919a685449826db986a921c1d8632d673e0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 17:38:53 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 17:38:53 -0400    

Click here for diff

As usual, the release notes for older branches will be made by cutting  
these down, but put them up for community review first.  
  
Due to the out-of-cycle release of 14.4, there are a number of commits  
that appeared in 14.4 that are not yet shipped in the earlier branches.  
This draft repeats those release note entries for convenience in  
preparing the older-branch notes later.  They'll be stripped out of  
the 14.5 section after that's done.  

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

Partially undo commit 94da73281.

commit   : b9243cadad55e296e83839fb96457f64dcaaeb25    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 15:57:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 15:57:46 -0400    

Click here for diff

On closer inspection, mcv.c isn't as broken for ScalarArrayOpExpr  
as I thought.  The Var-on-right issue is real enough, but actually  
it does cope fine with a NULL array constant --- I was misled by  
an XXX comment suggesting it didn't.  Undo that part of the code  
change, and replace the XXX comment with something less misleading.  

M src/backend/statistics/extended_stats.c
M src/backend/statistics/mcv.c

Fix handling of bare boolean expressions in mcv_get_match_bitmap.

commit   : 3fe2fc6bbdb251c78a88cdd41e400014be76f80e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 15:00:03 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 15:00:03 -0400    

Click here for diff

Since v14, the extended stats machinery will try to estimate for  
otherwise-unsupported boolean expressions if they match an expression  
available from an extended stats object.  mcv.c did not get the memo  
about this, and would spit up with "unknown clause type".  Fortunately  
the case is easy to handle, since we can expect the expression yields  
boolean.  
  
While here, replace some not-terribly-on-point assertions with  
simpler runtime tests for lookup failure.  That seems appropriate  
so that we get an elog not a crash if we somehow get to the new  
it-should-be-a-bool-expression code with a subexpression that  
doesn't match any stats column.  
  
Per report from Danny Shemesh.  Thanks to Justin Pryzby for  
preliminary investigation.  
  
Discussion: https://postgr.es/m/CAFZC=QqD6=27wQPOW1pbRa98KPyuyn+7cL_Ay_Ck-roZV84vHg@mail.gmail.com  

M src/backend/statistics/mcv.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

Fix non-bulletproof ScalarArrayOpExpr code for extended statistics.

commit   : ea6c916962c4fc87c3d26d938e0149d4c91f2ca0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 13:58:37 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 13:58:37 -0400    

Click here for diff

statext_is_compatible_clause_internal() checked that the arguments  
of a ScalarArrayOpExpr are one Var and one Const, but it would allow  
cases where the Const was on the left.  Subsequent uses of the clause  
are not expecting that and would suffer assertion failures or core  
dumps.  mcv.c also had not bothered to cope with the case of a NULL  
array constant, which seems really unacceptably sloppy of somebody.  
(Although our tools failed us there too, since AFAIK neither Coverity  
nor any compiler warned of the obvious use-of-uninitialized-variable  
condition.)  It seems best to handle that by having  
statext_is_compatible_clause_internal() reject it.  
  
Noted while fixing bug #17570.  Back-patch to v13 where the  
extended stats code grew some awareness of ScalarArrayOpExpr.  

M src/backend/statistics/extended_stats.c
M src/backend/statistics/mcv.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

Backpatch addition of .git-blame-ignore-revs

commit   : fff3f3333fdc34d9f412fc8c87bef47ce4007ce9    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 5 Aug 2022 19:36:24 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 5 Aug 2022 19:36:24 +0200    

Click here for diff

This makes it more convenient for git config to contain the  
blame.ignoreRevsFile setting; otherwise current git versions complain if  
the file is not present.  
  
I constructed the file for each branch by scraping the file in branch  
master for commits that appear in that branch.  Because a few additional  
pgindent commits have been added to the list in master since the list  
was first created, this also propagates those to branches 14 and 15  
where the file already existed.  Also, some entries appear to have been  
made using author-date rather than committer-date in the format string,  
so some timestamps are changed.  Also remove bogus whitespace in the  
suggested `git log` format string.  
  
Backpatch to all supported branches.  
  
Discussion: https://postgr.es/m/20220711163138.o72evdeus5f5yy5z@alvherre.pgsql  

M .git-blame-ignore-revs

Fix incorrect permissions-checking code for extended statistics.

commit   : 7c6ce0475a344d1f35b500898768530d0c02030a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 12:46:34 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 5 Aug 2022 12:46:34 -0400    

Click here for diff

Commit a4d75c86b improved the extended-stats logic to allow extended  
stats to be collected on expressions not just bare Vars.  To apply  
such stats, we first verify that the user has permissions to read all  
columns used in the stats.  (If not, the query will likely fail at  
runtime, but the planner ought not do so.)  That had to get extended  
to check permissions of columns appearing within such expressions,  
but the code for that was completely wrong: it applied pull_varattnos  
to the wrong pointer, leading to "unrecognized node type" failures.  
Furthermore, although you couldn't get to this because of that bug,  
it failed to account for the attnum offset applied by pull_varattnos.  
  
This escaped recognition so far because the code in question is not  
reached when the user has whole-table SELECT privilege (which is the  
common case), and because only subexpressions not specially handled  
by statext_is_compatible_clause_internal() are at risk.  
  
I think a large part of the reason for this bug is under-documentation  
of what statext_is_compatible_clause() is doing and what its arguments  
are, so do some work on the comments to try to improve that.  
  
Per bug #17570 from Alexander Kozhemyakin.  Patch by Richard Guo;  
comments and other cosmetic improvements by me.  (Thanks also to  
Japin Li for diagnosis.)  Back-patch to v14 where the bug came in.  
  
Discussion: https://postgr.es/m/17570-f2f2e0f4bccf0965@postgresql.org  

M src/backend/statistics/extended_stats.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

commit   : 541f41d4fa783ce213f15d4f5faaca5bb7a50559    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 5 Aug 2022 18:00:17 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 5 Aug 2022 18:00:17 +0200    

Click here for diff

That bit is unlogged and therefore it's wrong to consider it in WAL page  
comparison.  
  
Add a test that tickles the case, as branch testing technology allows.  
  
This has been a problem ever since wal consistency checking was  
introduced (commit a507b86900f6 for pg10), so backpatch to all supported  
branches.  
  
Author: 王海洋 (Haiyang Wang) <wanghaiyang.001@bytedance.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://postgr.es/m/CACciXAD2UvLMOhc4jX9VvOKt7DtYLr3OYRBhvOZ-jRxtzc_7Jg@mail.gmail.com  
Discussion: https://postgr.es/m/CACciXADOfErX9Bx0nzE_SkdfXr6Bbpo5R=v_B6MUTEYW4ya+cg@mail.gmail.com  

M src/backend/access/brin/brin_pageops.c
M src/backend/access/brin/brin_xlog.c
A src/test/modules/brin/t/02_wal_consistency.pl

Add HINT for restartpoint race with KeepFileRestoredFromArchive().

commit   : 8ad6c5dbbe5a234c55c6663020db297251756006    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Fri, 5 Aug 2022 08:30:58 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Fri, 5 Aug 2022 08:30:58 -0700    

Click here for diff

The five commits ending at cc2c7d65fc27e877c9f407587b0b92d46cd6dd16  
closed this race condition for v15+.  For v14 through v10, add a HINT to  
discourage studying the cosmetic problem.  
  
Reviewed by Kyotaro Horiguchi and David Steele.  
  
Discussion: https://postgr.es/m/20220731061747.GA3692882@rfd.leadboat.com  

M src/backend/access/transam/xlog.c
M src/backend/storage/file/fd.c

regress: fix test instability

commit   : 6d9481cd05d2a0d4152c02c5d48b7f7eb7b90a49    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 5 Aug 2022 11:55:52 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 5 Aug 2022 11:55:52 +0200    

Click here for diff

Having additional triggers in a test table made the ORDER BY clauses in  
old queries underspecified.  Add another column there for stability.  
  
Per sporadic buildfarm pink.  

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

postgres_fdw: Disable batch insertion when there are WCO constraints.

commit   : 4a9bc2e0f5226d29e7e11c9611b8649a4aa74a4b    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 5 Aug 2022 17:15:03 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 5 Aug 2022 17:15:03 +0900    

Click here for diff

When inserting a view referencing a foreign table that has WITH CHECK  
OPTION constraints, in single-insert mode postgres_fdw retrieves the  
data that was actually inserted on the remote side so that the WITH  
CHECK OPTION constraints are enforced with the data locally, but in  
batch-insert mode it cannot currently retrieve the data (except for the  
row first inserted through the view), resulting in enforcing the WITH  
CHECK OPTION constraints with the data passed from the core (except for  
the first-inserted row), which led to incorrect results when inserting  
into a view referencing a foreign table in which a remote BEFORE ROW  
INSERT trigger changes the rows inserted through the view so that they  
violate the view's WITH CHECK OPTION constraint.  Also, the query  
inserting into the view caused an assertion failure in assert-enabled  
builds.  
  
Fix these by disabling batch insertion when inserting into such a view.  
  
Back-patch to v14 where batch insertion was added.  
  
Discussion: https://postgr.es/m/CAPmGK17LpbTZs4m4a_6THP54UBeK9fHvX8aVVA%2BC6yEZDZwQcg%40mail.gmail.com  

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

Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

commit   : 731d514ae58ff4b5c81729881d350c6f89c4e488    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Thu, 4 Aug 2022 20:02:02 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Thu, 4 Aug 2022 20:02:02 +0200    

Click here for diff

Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is  
not correct, because ATPrepCmd() can't distinguish between triggers that  
may be cloned and those that may not, so would wrongly try to recurse  
for the latter category of triggers.  
  
So this commit restores the code in EnableDisableTrigger() that  
86f575948c77 had added to do the recursion, which would do it only for  
triggers that may be cloned, that is, row-level triggers.  This also  
changes tablecmds.c such that ATExecCmd() is able to pass the value of  
ONLY flag down to EnableDisableTrigger() using its new 'recurse'  
parameter.  
  
This also fixes what seems like an oversight of 86f575948c77 that the  
recursion to partition triggers would only occur if EnableDisableTrigger()  
had actually changed the trigger.  It is more apt to recurse to inspect  
partition triggers even if the parent's trigger didn't need to be  
changed: only then can we be certain that all descendants share the same  
state afterwards.  
  
Backpatch all the way back to 11, like bbb927b4db9b.  Care is taken not  
to break ABI compatibility (and that no catversion bump is needed.)  
  
Co-authored-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru>  
Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com  

M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/nodes/copyfuncs.c
M src/backend/nodes/equalfuncs.c
M src/include/commands/trigger.h
M src/include/nodes/parsenodes.h
M src/test/regress/expected/triggers.out
M src/test/regress/sql/triggers.sql

Add CHECK_FOR_INTERRUPTS in ExecInsert's speculative insertion loop.

commit   : efba7a63ffbe59790b88e3af459dfd81c742b90f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 4 Aug 2022 14:10:06 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 4 Aug 2022 14:10:06 -0400    

Click here for diff

Ordinarily the functions called in this loop ought to have plenty  
of CFIs themselves; but we've now seen a case where no such CFI is  
reached, making the loop uninterruptible.  Even though that's from  
a recently-introduced bug, it seems prudent to install a CFI at  
the loop level in all branches.  
  
Per discussion of bug #17558 from Andrew Kesper (an actual fix for  
that bug will follow).  
  
Discussion: https://postgr.es/m/17558-3f6599ffcf52fd4a@postgresql.org  

M src/backend/executor/nodeModifyTable.c

Add proper regression test for the recent SRFs-in-pathkeys problem.

commit   : 1a9ac84923b8530ca18d497b3ccc40965c01b66b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 4 Aug 2022 11:11:22 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 4 Aug 2022 11:11:22 -0400    

Click here for diff

Remove the test case added by commit fac1b470a, which never actually  
worked to expose the problem it claimed to test.  Replace it with  
a case that does expose the problem, and also covers the SRF-not-  
at-the-top deficiency repaired in 1aa8dad41.  
  
Richard Guo, with some editorialization by me  
  
Discussion: https://postgr.es/m/17564-c7472c2f90ef2da3@postgresql.org  

M src/test/regress/expected/incremental_sort.out
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/incremental_sort.sql
M src/test/regress/sql/select_parallel.sql

Fix assorted doc typos

commit   : 120e159b7d93fa36b94ded8a51fe4e619e1261ca    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Thu, 4 Aug 2022 15:59:32 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Thu, 4 Aug 2022 15:59:32 +0700    

Click here for diff

Erik Rijkers and Justin Pryzby  
  
Backpatch to v14  
  
Discussion: https://www.postgresql.org/message-id/b79bfeff-d0e3-29a3-2576-0e325848dede%40xs4all.nl  

M doc/src/sgml/brin.sgml
M doc/src/sgml/ref/drop_extension.sgml

Clarify DROP EXTENSION docs regarding explicitly dependent routines

commit   : d107e73fa8b5ba874a4b29be73e743652c32efd2    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Thu, 4 Aug 2022 15:29:25 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Thu, 4 Aug 2022 15:29:25 +0700    

Click here for diff

Per suggestion from Robert Haas  
  
Backpatch to v14  
  
Discussion: https://www.postgresql.org/message-id/CA%2BTgmoZ1QvHquYHLkMy1oHKqz4-E7QQctj6e0ocq_GP1B5%2B9bA%40mail.gmail.com  

M doc/src/sgml/ref/drop_extension.sgml

Fix incorrect tests for SRFs in relation_can_be_sorted_early().

commit   : 445b9020c97f3e1ff63534efeec5a280e33d2495    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 3 Aug 2022 17:33:42 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 3 Aug 2022 17:33:42 -0400    

Click here for diff

Commit fac1b470a thought we could check for set-returning functions  
by testing only the top-level node in an expression tree.  This is  
wrong in itself, and to make matters worse it encouraged others  
to make the same mistake, by exporting tlist.c's special-purpose  
IS_SRF_CALL() as a widely-visible macro.  I can't find any evidence  
that anyone's taken the bait, but it was only a matter of time.  
  
Use expression_returns_set() instead, and stuff the IS_SRF_CALL()  
genie back in its bottle, this time with a warning label.  I also  
added a couple of cross-reference comments.  
  
After a fair amount of fooling around, I've despaired of making  
a robust test case that exposes the bug reliably, so no test case  
here.  (Note that the test case added by fac1b470a is itself  
broken, in that it doesn't notice if you remove the code change.  
The repro given by the bug submitter currently doesn't fail either  
in v15 or HEAD, though I suspect that may indicate an unrelated bug.)  
  
Per bug #17564 from Martijn van Oosterhout.  Back-patch to v13,  
as the faulty patch was.  
  
Discussion: https://postgr.es/m/17564-c7472c2f90ef2da3@postgresql.org  

M src/backend/nodes/nodeFuncs.c
M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/util/tlist.c
M src/include/optimizer/optimizer.h

Reduce test runtime of src/test/modules/snapshot_too_old.

commit   : 8eaa4d0f3dbe2022f683cb8c90beeafbb43232fa    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 3 Aug 2022 11:14:55 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 3 Aug 2022 11:14:55 -0400    

Click here for diff

The sto_using_cursor and sto_using_select tests were coded to exercise  
every permutation of their test steps, but AFAICS there is no value in  
exercising more than one.  This matters because each permutation costs  
about six seconds, thanks to the "pg_sleep(6)".  Perhaps we could  
reduce that, but the useless permutations seem worth getting rid of  
in any case.  (Note that sto_using_hash_index got it right already.)  
  
While here, clean up some other sloppiness such as an unused table.  
  
This doesn't make too much difference in interactive testing, since the  
wasted time is typically masked by parallelization with other tests.  
However, the buildfarm runs this as a serial step, which means we can  
expect to shave ~40 seconds from every buildfarm run.  That makes it  
worth back-patching.  
  
Discussion: https://postgr.es/m/2515192.1659454702@sss.pgh.pa.us  

M src/test/modules/snapshot_too_old/expected/sto_using_cursor.out
M src/test/modules/snapshot_too_old/expected/sto_using_select.out
M src/test/modules/snapshot_too_old/specs/sto_using_cursor.spec
M src/test/modules/snapshot_too_old/specs/sto_using_select.spec

Be more wary about 32-bit integer overflow in pg_stat_statements.

commit   : 17fd203b414e9a1d649fb22ab11afd8355947476    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 2 Aug 2022 18:05:34 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 2 Aug 2022 18:05:34 -0400    

Click here for diff

We've heard a couple of reports of people having trouble with  
multi-gigabyte-sized query-texts files.  It occurred to me that on  
32-bit platforms, there could be an issue with integer overflow  
of calculations associated with the total query text size.  
Address that with several changes:  
  
1. Limit pg_stat_statements.max to INT_MAX / 2 not INT_MAX.  
The hashtable code will bound it to that anyway unless "long"  
is 64 bits.  We still need overflow guards on its use, but  
this helps.  
  
2. Add a check to prevent extending the query-texts file to  
more than MaxAllocHugeSize.  If it got that big, qtext_load_file  
would certainly fail, so there's not much point in allowing it.  
Without this, we'd need to consider whether extent, query_offset,  
and related variables shouldn't be off_t not size_t.  
  
3. Adjust the comparisons in need_gc_qtexts() to be done in 64-bit  
arithmetic on all platforms.  It appears possible that under duress  
those multiplications could overflow 32 bits, yielding a false  
conclusion that we need to garbage-collect the texts file, which  
could lead to repeatedly garbage-collecting after every hash table  
insertion.  
  
Per report from Bruno da Silva.  I'm not convinced that these  
issues fully explain his problem; there may be some other bug that's  
contributing to the query-texts file becoming so large in the first  
place.  But it did get that big, so #2 is a reasonable defense,  
and #3 could explain the reported performance difficulties.  
  
(See also commit 8bbe4cbd9, which addressed some related bugs.  
The second Discussion: link is the thread that led up to that.)  
  
This issue is old, and is primarily a problem for old platforms,  
so back-patch.  
  
Discussion: https://postgr.es/m/CAB+Nuk93fL1Q9eLOCotvLP07g7RAv4vbdrkm0cVQohDVMpAb9A@mail.gmail.com  
Discussion: https://postgr.es/m/5601D354.5000703@BlueTreble.com  

M contrib/pg_stat_statements/pg_stat_statements.c

Check maximum number of columns in function RTEs, too.

commit   : d947a8bd5606af4333076724d20b4cb87d386c30    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 1 Aug 2022 12:22:35 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 1 Aug 2022 12:22:35 -0400    

Click here for diff

I thought commit fd96d14d9 had plugged all the holes of this sort,  
but no, function RTEs could produce oversize tuples too, either  
via long coldeflists or just from multiple functions in one RTE.  
(I'm pretty sure the other variants of base RTEs aren't a problem,  
because they ultimately refer to either a table or a sub-SELECT,  
whose widths are enforced elsewhere.  But we explicitly allow join  
RTEs to be overwidth, as long as you don't try to form their  
tuple result.)  
  
Per further discussion of bug #17561.  As before, patch all branches.  
  
Discussion: https://postgr.es/m/17561-80350151b9ad2ad4@postgresql.org  

M src/backend/parser/parse_relation.c

Fix error reporting after ioctl() call with pg_upgrade --clone

commit   : 523926dea97f360f1f785853eea49e4dc4a6e1e9    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 1 Aug 2022 16:39:27 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 1 Aug 2022 16:39:27 +0900    

Click here for diff

errno was not reported correctly after attempting to clone a file,  
leading to incorrect error reports.  While scanning through the code, I  
have not noticed any similar mistakes.  
  
Error introduced in 3a769d8.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/20220731134135.GY15006@telsasoft.com  
Backpatch-through: 12  

M src/bin/pg_upgrade/file.c

Fix trim_array() for zero-dimensional array argument.

commit   : e71d4254f710bef53fa40d0b49b5af9bad10ce40    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 31 Jul 2022 13:43:17 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 31 Jul 2022 13:43:17 -0400    

Click here for diff

The code tried to access ARR_DIMS(v)[0] and ARR_LBOUND(v)[0]  
whether or not those values exist.  This made the range check  
on the "n" argument unstable --- it might or might not fail, and  
if it did it would report garbage for the allowed upper limit.  
These bogus accesses would probably annoy Valgrind, and if you  
were very unlucky even lead to SIGSEGV.  
  
Report and fix by Martin Kalcher.  Back-patch to v14 where this  
function was added.  
  
Discussion: https://postgr.es/m/baaeb413-b8a8-4656-5757-ef347e5ec11f@aboutsource.net  

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

Fix new recovery test for log_error_verbosity=verbose case

commit   : e90c4fc881e2c836b4d4fb9fae03310f9c0d8597    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 29 Jul 2022 17:43:34 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 29 Jul 2022 17:43:34 -0400    

Click here for diff

The new test is from commit 9e4f914b5e.  
  
With this setting messages have SQL error numbers included, so that  
needs to be provided for in the pattern looked for.  
  
Backpatch to all live branches like the original.  

M src/test/recovery/t/033_replay_tsp_drops.pl

In transformRowExpr(), check for too many columns in the row.

commit   : 8df167baa7c76685cde43611df7026b5ad2e708e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 29 Jul 2022 13:30:50 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 29 Jul 2022 13:30:50 -0400    

Click here for diff

A RowExpr with more than MaxTupleAttributeNumber columns would fail at  
execution anyway, since we cannot form a tuple datum with more than that  
many columns.  While heap_form_tuple() has a check for too many columns,  
it emerges that there are some intermediate bits of code that don't  
check and can be driven to failure with sufficiently many columns.  
Checking this at parse time seems like the most appropriate place to  
install a defense, since we already check SELECT list length there.  
  
While at it, make the SELECT-list-length error use the same errcode  
(TOO_MANY_COLUMNS) as heap_form_tuple does, rather than the generic  
PROGRAM_LIMIT_EXCEEDED.  
  
Per bug #17561 from Egor Chindyaskin.  The given test case crashes  
in all supported branches (and probably a lot further back),  
so patch all.  
  
Discussion: https://postgr.es/m/17561-80350151b9ad2ad4@postgresql.org  

M src/backend/parser/parse_expr.c
M src/backend/parser/parse_node.c

Fix test instability

commit   : 4d8d85740c0228b04a10818587b70f4ae3a2beba    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 29 Jul 2022 12:50:47 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 29 Jul 2022 12:50:47 +0200    

Click here for diff

On FreeBSD, the new test fails due to a WAL file being removed before  
the standby has had the chance to copy it.  Fix by adding a replication  
slot to prevent the removal until after the standby has connected.  
  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reported-by: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Discussion: https://postgr.es/m/CAEze2Wj5nau_qpjbwihvmXLfkAWOZ5TKdbnqOc6nKSiRJEoPyQ@mail.gmail.com  

M src/test/recovery/t/033_replay_tsp_drops.pl

Fix replay of create database records on standby

commit   : a3aacb7cbfc74fc20e8681cba99e2db84c8dd980    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Thu, 28 Jul 2022 08:26:05 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Thu, 28 Jul 2022 08:26:05 +0200    

Click here for diff

Crash recovery on standby may encounter missing directories  
when replaying database-creation WAL records.  Prior to this  
patch, the standby would fail to recover in such a case;  
however, the directories could be legitimately missing.  
Consider the following sequence of commands:  
  
    CREATE DATABASE  
    DROP DATABASE  
    DROP TABLESPACE  
  
If, after replaying the last WAL record and removing the  
tablespace directory, the standby crashes and has to replay the  
create database record again, crash recovery must be able to continue.  
  
A fix for this problem was already attempted in 49d9cfc68bf4, but it  
was reverted because of design issues.  This new version is based  
on Robert Haas' proposal: any missing tablespaces are created  
during recovery before reaching consistency.  Tablespaces  
are created as real directories, and should be deleted  
by later replay.  CheckRecoveryConsistency ensures  
they have disappeared.  
  
The problems detected by this new code are reported as PANIC,  
except when allow_in_place_tablespaces is set to ON, in which  
case they are WARNING.  Apart from making tests possible, this  
gives users an escape hatch in case things don't go as planned.  
  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Author: Asim R Praveen <apraveen@pivotal.io>  
Author: Paul Guo <paulguo@gmail.com>  
Reviewed-by: Anastasia Lubennikova <lubennikovaav@gmail.com> (older versions)  
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com> (older versions)  
Reviewed-by: Michaël Paquier <michael@paquier.xyz>  
Diagnosed-by: Paul Guo <paulguo@gmail.com>  
Discussion: https://postgr.es/m/CAEET0ZGx9AvioViLf7nbR_8tH9-=27DN5xWJ2P9-ROH16e4JUA@mail.gmail.com  

M src/backend/access/transam/xlog.c
M src/backend/commands/dbcommands.c
M src/backend/commands/tablespace.c
A src/test/recovery/t/033_replay_tsp_drops.pl

commit   : 5ad478c9d95657948fd818ac7e97a28eea3c3433    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 28 Jul 2022 14:13:37 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 28 Jul 2022 14:13:37 +1200    

Click here for diff

On Windows with MSVC, get_dirent_type() was recently made to return  
DT_LNK for junction points by commit 9d3444dc, which fixed some  
defective dirent.c code.  
  
On Windows with Cygwin, get_dirent_type() already worked for symlinks,  
as it does on POSIX systems, because Cygwin has its own fake symlinks  
that behave like POSIX (on closer inspection, Cygwin's dirent has the  
BSD d_type extension but it's probably always DT_UNKNOWN, so we fall  
back to lstat(), which understands Cygwin symlinks with S_ISLNK()).  
  
On Windows with MinGW/MSYS, we need extra code, because the MinGW  
runtime has its own readdir() without d_type, and the lstat()-based  
fallback has no knowledge of our convention for treating junctions as  
symlinks.  
  
Back-patch to 14, where get_dirent_type() landed.  
  
Reported-by: Andrew Dunstan <andrew@dunslane.net>  
Discussion: https://postgr.es/m/b9ddf605-6b36-f90d-7c30-7b3e95c46276%40dunslane.net  

M src/common/file_utils.c

Allow "in place" tablespaces.

commit   : 961cab0a5a90d449a64a71912b324d7e7548619b    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 27 Jul 2022 07:55:13 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 27 Jul 2022 07:55:13 +0200    

Click here for diff

This is a backpatch to branches 10-14 of the following commits:  
  
7170f2159fb2 Allow "in place" tablespaces.  
c6f2f01611d4 Fix pg_basebackup with in-place tablespaces.  
f6f0db4d6240 Fix pg_tablespace_location() with in-place tablespaces  
7a7cd84893e0 doc: Remove mention to in-place tablespaces for pg_tablespace_location()  
5344723755bd Remove unnecessary Windows-specific basebackup code.  
  
In-place tablespaces were introduced as a testing helper mechanism, but  
they are going to be used for a bugfix in WAL replay to be backpatched  
to all stable branches.  
  
I (Álvaro) had to adjust some code to account for lack of  
get_dirent_type() in branches prior to 14.  
  
Author: Thomas Munro <thomas.munro@gmail.com>  
Author: Michaël Paquier <michael@paquier.xyz>  
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>  
Discussion: https://postgr.es/m/20220722081858.omhn2in5zt3g4nek@alvherre.pgsql  

M doc/src/sgml/config.sgml
M src/backend/access/transam/xlog.c
M src/backend/commands/tablespace.c
M src/backend/utils/adt/misc.c
M src/backend/utils/misc/guc.c
M src/include/commands/tablespace.h

Force immediate commit after CREATE DATABASE etc in extended protocol.

commit   : 3e1297a63f760b02ea8d951f6b270c9c843083ae    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 26 Jul 2022 13:07:03 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 26 Jul 2022 13:07:03 -0400    

Click here for diff

We have a few commands that "can't run in a transaction block",  
meaning that if they complete their processing but then we fail  
to COMMIT, we'll be left with inconsistent on-disk state.  
However, the existing defenses for this are only watertight for  
simple query protocol.  In extended protocol, we didn't commit  
until receiving a Sync message.  Since the client is allowed to  
issue another command instead of Sync, we're in trouble if that  
command fails or is an explicit ROLLBACK.  In any case, sitting  
in an inconsistent state while waiting for a client message  
that might not come seems pretty risky.  
  
This case wasn't reachable via libpq before we introduced pipeline  
mode, but it's always been an intended aspect of extended query  
protocol, and likely there are other clients that could reach it  
before.  
  
To fix, set a flag in PreventInTransactionBlock that tells  
exec_execute_message to force an immediate commit.  This seems  
to be the approach that does least damage to existing working  
cases while still preventing the undesirable outcomes.  
  
While here, add some documentation to protocol.sgml that explicitly  
says how to use pipelining.  That's latent in the existing docs if  
you know what to look for, but it's better to spell it out; and it  
provides a place to document this new behavior.  
  
Per bug #17434 from Yugo Nagata.  It's been wrong for ages,  
so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/17434-d9f7a064ce2a88a3@postgresql.org  

M doc/src/sgml/protocol.sgml
M src/backend/access/transam/xact.c
M src/backend/tcop/postgres.c
M src/include/access/xact.h

Fix ReadRecentBuffer for local buffers.

commit   : 3f968b9415045c4f8ae3cd56b5b4a83d1aa27db8    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 25 Jul 2022 08:48:38 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 25 Jul 2022 08:48:38 +0300    

Click here for diff

It incorrectly used GetBufferDescriptor instead of  
GetLocalBufferDescriptor, causing it to not find the correct buffer in  
most cases, and performing an out-of-bounds memory read in the corner  
case that temp_buffers > shared_buffers.  
  
It also bumped the usage-count on the buffer, even if it was  
previously pinned. That won't lead to crashes or incorrect results,  
but it's different from what the shared-buffer case does, and  
different from the usual code in LocalBufferAlloc. Fix that too, and  
make the code ordering match LocalBufferAlloc() more closely, so that  
it's easier to verify that it's doing the same thing.  
  
Currently, ReadRecentBuffer() is only used with non-temp relations, in  
WAL redo, so the broken code is currently dead code. However, it could  
be used by extensions.  
  
Backpatch-through: 14  
Discussion: https://www.postgresql.org/message-id/2d74b46f-27c9-fb31-7f99-327a87184cc0%40iki.fi  
Reviewed-by: Thomas Munro, Zhang Mingli, Richard Guo  

M src/backend/storage/buffer/bufmgr.c

Doc: improve documentation about random().

commit   : 31d5354cb148c6aa90014f62d3a4752adeebd51a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 23 Jul 2022 19:00:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 23 Jul 2022 19:00:30 -0400    

Click here for diff

We didn't explicitly say that random() uses a randomly-chosen seed  
if you haven't called setseed().  Do so.  
  
Also, remove ref/set.sgml's no-longer-accurate (and never very  
relevant) statement that the seed value is multiplied by 2^31-1.  
  
Back-patch to v12 where set.sgml's claim stopped being true.  
The claim that we use a source of random bits as seed was debatable  
before 4203842a1, too, so v12 seems like a good place to stop.  
  
Per question from Carl Sopchak.  
  
Discussion: https://postgr.es/m/f37bb937-9d99-08f0-4de7-80c91a3cfc2e@sopchak.me  

M doc/src/sgml/func.sgml
M doc/src/sgml/ref/set.sgml

Fix get_dirent_type() for Windows junction points.

commit   : fee0165fc1cfaf4ac0052c4554810e46c02dd70c    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Fri, 22 Jul 2022 16:57:12 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Fri, 22 Jul 2022 16:57:12 +1200    

Click here for diff

Commit 87e6ed7c8 added code that intended to report Windows "junction  
points" as DT_LNK (the same way we report symlinks on Unix).  Windows  
junction points are *also* directories according to the Windows  
attributes API, and we were reporting them as as DT_DIR.  Change the  
order we check the attribute flags, to prioritize DT_LNK.  
  
If at some point we start using Windows' recently added real symlinks  
and need to distinguish them from junction points, we may need to  
rethink this, but for now this continues the tradition of wrapper  
functions that treat junction points as symlinks.  
  
Back-patch to 14, where get_dirent_type() landed.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>  
Discussion: https://postgr.es/m/CA%2BhUKGLzLK4PUPx0_AwXEWXOYAejU%3D7XpxnYE55Y%2Be7hB2N3FA%40mail.gmail.com  
Discussion: https://postgr.es/m/20220721111751.x7hod2xgrd76xr5c%40alvherre.pgsql  

M src/port/dirent.c

postgres_fdw: Fix bug in checking of return value of PQsendQuery().

commit   : 169d50ba34a91a1c3e2535b8ef49480bad4b9867    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 21 Jul 2022 22:52:50 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 21 Jul 2022 22:52:50 +0900    

Click here for diff

When postgres_fdw begins an asynchronous data fetch, it submits FETCH query  
by using PQsendQuery(). If PQsendQuery() fails and returns 0, postgres_fdw  
should report an error. But, previously, postgres_fdw reported an error  
only when the return value is less than 0, though PQsendQuery() never return  
the values other than 0 and 1. Therefore postgres_fdw could not handle  
the failure to send FETCH query in an asynchronous data fetch.  
  
This commit fixes postgres_fdw so that it reports an error  
when PQsendQuery() returns 0.  
  
Back-patch to v14 where asynchronous execution was supported in postgres_fdw.  
  
Author: Fujii Masao  
Reviewed-by: Japin Li, Tom Lane  
Discussion: https://postgr.es/m/b187a7cf-d4e3-5a32-4d01-8383677797f3@oss.nttdata.com  

M contrib/postgres_fdw/postgres_fdw.c

doc: use wording "restore" instead of "reload" of dumps

commit   : e613466e46c86d6c64bac062b35ef5d0ca539d19    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 Jul 2022 14:55:23 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 Jul 2022 14:55:23 -0400    

Click here for diff

Reported-by: axel.kluener@gmail.com  
  
Discussion: https://postgr.es/m/164736074430.660.3645615289283943146@wrigleys.postgresql.org  
  
Backpatch-through: 11  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/extend.sgml
M doc/src/sgml/perform.sgml
M doc/src/sgml/plhandler.sgml
M doc/src/sgml/ref/alter_type.sgml
M doc/src/sgml/ref/create_domain.sgml
M doc/src/sgml/ref/pg_dump.sgml
M doc/src/sgml/ref/pg_dumpall.sgml
M doc/src/sgml/ref/pg_resetwal.sgml
M doc/src/sgml/ref/pg_restore.sgml
M doc/src/sgml/ref/pgupgrade.sgml
M doc/src/sgml/runtime.sgml
M doc/src/sgml/textsearch.sgml

doc: clarify that auth. names are lower case and case-sensitive

commit   : 21640e986518ab7d15b5a811cf2c5064af244249    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 Jul 2022 13:58:20 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 Jul 2022 13:58:20 -0400    

Click here for diff

This is true even for acronyms that are usually upper case, like LDAP.  
  
Reported-by: Alvaro Herrera  
  
Discussion: https://postgr.es/m/202205141521.2nodjabmsour@alvherre.pgsql  
  
Backpatch-through: 10  

M doc/src/sgml/client-auth.sgml

Fix ruleutils issues with dropped cols in functions-returning-composite.

commit   : da9a28fd5563261354d648258b1824b3f35dde5c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 21 Jul 2022 13:56:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 21 Jul 2022 13:56:02 -0400    

Click here for diff

Due to lack of concern for the case in the dependency code, it's  
possible to drop a column of a composite type even though stored  
queries have references to the dropped column via functions-in-FROM  
that return the composite type.  There are "soft" references,  
namely FROM-clause aliases for such columns, and "hard" references,  
that is actual Vars referring to them.  The right fix for hard  
references is to add dependencies preventing the drop; something  
we've known for many years and not done (and this commit still doesn't  
address it).  A "soft" reference shouldn't prevent a drop though.  
We've been around on this before (cf. 9b35ddce9, 2c4debbd0), but  
nobody had noticed that the current behavior can result in dump/reload  
failures, because ruleutils.c can print more column aliases than the  
underlying composite type now has.  So we need to rejigger the  
column-alias-handling code to treat such columns as dropped and not  
print aliases for them.  
  
Rather than writing new code for this, I used expandRTE() which already  
knows how to figure out which function result columns are dropped.  
I'd initially thought maybe we could use expandRTE() in all cases, but  
that fails for EXPLAIN's purposes, because the planner strips a lot of  
RTE infrastructure that expandRTE() needs.  So this patch just uses it  
for unplanned function RTEs and otherwise does things the old way.  
  
If there is a hard reference (Var), then removing the column alias  
causes us to fail to print the Var, since there's no longer a name  
to print.  Failing seems less desirable than printing a made-up  
name, so I made it print "?dropped?column?" instead.  
  
Per report from Timo Stolz.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/5c91267e-3b6d-5795-189c-d15a55d61dbb@nullachtvierzehn.de  

M src/backend/parser/parse_relation.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/create_view.out
M src/test/regress/sql/create_view.sql

Fix assertion failure and segmentation fault in backup code.

commit   : be2e842c8a79d98a3fa03eeaf9329bf1f51a9704    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 12 Jul 2022 11:53:29 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 12 Jul 2022 11:53:29 +0900    

Click here for diff

When a non-exclusive backup is canceled, do_pg_abort_backup() is called  
and resets some variables set by pg_backup_start (pg_start_backup in v14  
or before). But previously it forgot to reset the session state indicating  
whether a non-exclusive backup is in progress or not in this session.  
  
This issue could cause an assertion failure when the session running  
BASE_BACKUP is terminated after it executed pg_backup_start and  
pg_backup_stop (pg_stop_backup in v14 or before). Also it could cause  
a segmentation fault when pg_backup_stop is called after BASE_BACKUP  
in the same session is canceled.  
  
This commit fixes the issue by making do_pg_abort_backup reset  
that session state.  
  
Back-patch to all supported branches.  
  
Author: Fujii Masao  
Reviewed-by: Kyotaro Horiguchi, Masahiko Sawada, Michael Paquier, Robert Haas  
Discussion: https://postgr.es/m/3374718f-9fbf-a950-6d66-d973e027f44c@oss.nttdata.com  

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

Prevent BASE_BACKUP in the middle of another backup in the same session.

commit   : 2aedf25eb4d0a89c38dbbad8e5bbda237838292f    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 12 Jul 2022 09:31:57 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 12 Jul 2022 09:31:57 +0900    

Click here for diff

Multiple non-exclusive backups are able to be run conrrently in different  
sessions. But, in the same session, only one non-exclusive backup can be  
run at the same moment. If pg_backup_start (pg_start_backup in v14 or before)  
is called in the middle of another non-exclusive backup in the same session,  
an error is thrown.  
  
However, previously, in logical replication walsender mode, even if that  
walsender session had already called pg_backup_start and started  
a non-exclusive backup, it could execute BASE_BACKUP command and  
start another non-exclusive backup. Which caused subsequent pg_backup_stop  
to throw an error because BASE_BACKUP unexpectedly reset the session state  
marked by pg_backup_start.  
  
This commit prevents BASE_BACKUP command in the middle of another  
non-exclusive backup in the same session.  
  
Back-patch to all supported branches.  
  
Author: Fujii Masao  
Reviewed-by: Kyotaro Horiguchi, Masahiko Sawada, Michael Paquier, Robert Haas  
Discussion: https://postgr.es/m/3374718f-9fbf-a950-6d66-d973e027f44c@oss.nttdata.com  

M src/backend/replication/basebackup.c

Re-add SPICleanup for ABI compatibility in stable branch

commit   : 8657946d375f4831b026d7c28016b27acdd2c246    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 18 Jul 2022 16:23:48 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 18 Jul 2022 16:23:48 +0200    

Click here for diff

This fixes an ABI break introduced by  
604651880c71c5106a72529b9ce29eaad0cfab27.  
  
Author: Markus Wanner <markus.wanner@enterprisedb.com>  
Discussion: https://www.postgresql.org/message-id/defd749a-8410-841d-1126-21398686d63d@enterprisedb.com  

M src/backend/executor/spi.c
M src/include/executor/spi.h

pg_upgrade: Adjust quoting style in message to match guidelines

commit   : 9293589d96756f921f54793c4586c6bd61f94e4f    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 18 Jul 2022 14:53:00 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 18 Jul 2022 14:53:00 +0200    

Click here for diff

M src/bin/pg_upgrade/check.c

Fix omissions in support for the "regcollation" type.

commit   : bb30410b9f4cae1ec74f120833b74ecc0b1de7d2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 17 Jul 2022 17:43:28 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 17 Jul 2022 17:43:28 -0400    

Click here for diff

The patch that added regcollation doesn't seem to have been too  
thorough about supporting it everywhere that other reg* types  
are supported.  Fix that.  (The find_expr_references omission  
is moderately serious, since it could result in missing expression  
dependencies.  The others are less exciting.)  
  
Noted while fixing bug #17483.  Back-patch to v13 where  
regcollation was added.  
  
Discussion: https://postgr.es/m/1423433.1652722406@sss.pgh.pa.us  

M src/backend/catalog/dependency.c
M src/backend/utils/adt/selfuncs.c
M src/backend/utils/cache/catcache.c

postgres_fdw: set search_path to 'pg_catalog' while deparsing constants.

commit   : 810bcbd383ab615a24ea972db0e1157572f3a12c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 17 Jul 2022 17:27:50 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 17 Jul 2022 17:27:50 -0400    

Click here for diff

The motivation for this is to ensure successful transmission of the  
values of constants of regconfig and other reg* types.  The remote  
will be reading them with search_path = 'pg_catalog', so schema  
qualification is necessary when referencing objects in other schemas.  
  
Per bug #17483 from Emmanuel Quincerot.  Back-patch to all supported  
versions.  (There's some other stuff to do here, but it's less  
back-patchable.)  
  
Discussion: https://postgr.es/m/1423433.1652722406@sss.pgh.pa.us  

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

Make dsm_impl_posix_resize more future-proof.

commit   : c412c60b91ac01d07774026991b949c1b43fa5e4    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Sat, 16 Jul 2022 10:59:52 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Sat, 16 Jul 2022 10:59:52 +1200    

Click here for diff

Commit 4518c798 blocks signals for a short region of code, but it  
assumed that whatever called it had the signal mask set to UnBlockSig on  
entry.  That may be true today (or may even not be, in extensions in the  
wild), but it would be better not to make that assumption.  We should  
save-and-restore the caller's signal mask.  
  
The PG_SETMASK() portability macro couldn't be used for that, which is  
why it wasn't done before.  But... considering that commit a65e0864  
established back in 9.6 that supported POSIX systems have sigprocmask(),  
and that this is POSIX-only code, there is no reason not to use standard  
sigprocmask() directly to achieve that.  
  
Back-patch to all supported releases, like 4518c798 and 80845b7c.  
  
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CA%2BhUKGKx6Biq7_UuV0kn9DW%2B8QWcpJC1qwhizdtD9tN-fn0H0g%40mail.gmail.com  

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

Clarify that pg_dump takes ACCESS SHARE lock

commit   : 2ebb8416cc4c1b8f73481335c2c6ce07286bc938    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Fri, 1 Jul 2022 11:41:36 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Fri, 1 Jul 2022 11:41:36 +0700    

Click here for diff

Add link to the description of lock levels to avoid confusing "shared locks"  
with SHARE locks.  
  
Florin Irion  
  
Reviewed-by: Álvaro Herrera, Tom Lane, and Nathan Bossart  
Discussion: https://www.postgresql.org/message-id/flat/d0f30cc2-3c76-1d43-f291-7c4b2872d653@gmail.com  
  
This is a backpatch of 4e2e8d71f, applied through version 14  

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

docs: make monitoring "phases" table titles consistent

commit   : e1d5ac3118be2c8f93a7b9c8813027f7a7f8d049    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 20:01:11 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 20:01:11 -0400    

Click here for diff

Reported-by: Nitin Jadhav  
  
Discussion: https://postgr.es/m/CAMm1aWbmTHwHKC2PERH0CCaFVPoxrtLeS8=wNuoge94qdSp3vA@mail.gmail.com  
  
Author: Nitin Jadhav  
  
Backpatch-through: 13  

M doc/src/sgml/monitoring.sgml

doc: clarify how dropping of extensions affects dependent objs.

commit   : 2fc2d805e9c7acd554689782e854cd713faf9575    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 17:41:03 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 17:41:03 -0400    

Click here for diff

Clarify that functions/procedures are dropped when any extension that  
depends on them is dropped.  
  
Reported-by: David G. Johnston  
  
Discussion: https://postgr.es/m/CAKFQuwbPSHMDGkisRUmewopweC1bFvytVqB=a=X4GFg=4ZWxPA@mail.gmail.com  
  
Backpatch-through: 13  

M doc/src/sgml/ref/alter_function.sgml
M doc/src/sgml/ref/alter_procedure.sgml
M doc/src/sgml/ref/drop_extension.sgml

pg_upgrade doc: mention that replication slots must be recreated

commit   : 0d8db8cf853ceb34c5be1e398fc566b0521bb24e    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 16:34:30 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 16:34:30 -0400    

Click here for diff

Reported-by: Nikhil Shetty  
  
Discussion: https://postgr.es/m/CAFpL5Vxastip0Jei-K-=7cKXTg=5sahSe5g=om=x68NOX8+PUA@mail.gmail.com  
  
Backpatch-through: 10  

M doc/src/sgml/ref/pgupgrade.sgml

doc: add documentation about ecpg Oracle-compatibility mode

commit   : 8e97474834e4247886ecb11ffc39d65239eddfe2    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 16:19:45 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 16:19:45 -0400    

Click here for diff

Reported-by: Takeshi Ideriha  
  
Discussion: https://postgr.es/m/TYCPR01MB7041A157067208327D8DAAF9EAA59@TYCPR01MB7041.jpnprd01.prod.outlook.com  
  
Backpatch-through: 11  

M doc/src/sgml/ecpg.sgml

doc: clarify the behavior of identically-named savepoints

commit   : 8f253ba251b86d6792cb81093e5d84457bc9790a    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 15:44:22 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 15:44:22 -0400    

Click here for diff

Original patch by David G. Johnston.  
  
Reported-by: David G. Johnston  
  
Discussion: https://postgr.es/m/CAKFQuwYQCxSSuSL18skCWG8QHFswOJ3hjovHsOZUE346i4OpVQ@mail.gmail.com  
  
Backpatch-through: 10  

M doc/src/sgml/ref/release_savepoint.sgml
M doc/src/sgml/ref/savepoint.sgml

doc: clarify that "excluded" ON CONFLICT is a single row

commit   : 3bfe26bd4ce11ee5bd2a2f240ee24e220f3f8635    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 15:33:28 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 15:33:28 -0400    

Click here for diff

Original patch by David G. Johnston.  
  
Reported-by: David G. Johnston  
  
Discussion: https://postgr.es/m/CAKFQuwa4J0+WuO7kW1PLbjoEvzPN+Q_j+P2bXxNnCLaszY7ZdQ@mail.gmail.com  
  
Backpatch-through: 10  

M doc/src/sgml/ref/insert.sgml

doc: mention that INSERT can block because of unique indexes

commit   : 4996786a90aa195025e2ee1fccb9d478740108a6    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 15:17:19 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 15:17:19 -0400    

Click here for diff

Initial patch by David G. Johnston.  
  
Reported-by: David G. Johnston  
  
Discussion: https://postgr.es/m/CAKFQuwZpbdzceO41VE-xt1Xh8rWRRfgopTAK1wL9EhCo0Am-Sw@mail.gmail.com  
  
Backpatch-through: 10  

M doc/src/sgml/ref/insert.sgml

doc: mention the pg_locks lock names in parentheses

commit   : 6396ab3d14278746951ea78fb8207534a8825a7e    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 12:08:54 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 14 Jul 2022 12:08:54 -0400    

Click here for diff

Reported-by: Troy Frericks  
  
Discussion: https://postgr.es/m/165653551130.665.8240515669521441325@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/mvcc.sgml

Don't clobber postmaster sigmask in dsm_impl_resize.

commit   : 8383645592de522e9791ba84ddde23f3105366b5    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Fri, 15 Jul 2022 01:23:29 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Fri, 15 Jul 2022 01:23:29 +1200    

Click here for diff

Commit 4518c798 intended to block signals in regular backends that  
allocate DSM segments, but dsm_impl_resize() is also reached by  
dsm_postmaster_startup().  It's not OK to clobber the postmaster's  
signal mask, so only manipulate the signal mask when under the  
postmaster.  
  
Back-patch to all releases, like 4518c798.  
  
Discussion: https://postgr.es/m/CA%2BhUKGKNpK%3D2OMeea_AZwpLg7Bm4%3DgYWk7eDjZ5F6YbozfOf8w%40mail.gmail.com  

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

Block signals while allocating DSM memory.

commit   : 2019e6ecfa26b11e2191a7a1ab41cea4f3ef1544    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 13 Jul 2022 16:16:07 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 13 Jul 2022 16:16:07 +1200    

Click here for diff

On Linux, we call posix_fallocate() on shm_open()'d memory to avoid  
later potential SIGBUS (see commit 899bd785).  
  
Based on field reports of systems stuck in an EINTR retry loop there,  
there, we made it possible to break out of that loop via slightly odd  
coding where the CHECK_FOR_INTERRUPTS() call was somewhat removed from  
the loop (see commit 422952ee).  
  
On further reflection, that was not a great choice for at least two  
reasons:  
  
1.  If interrupts were held, the CHECK_FOR_INTERRUPTS() would do nothing  
and the EINTR error would be surfaced to the user.  
  
2.  If EINTR was reported but neither QueryCancelPending nor  
ProcDiePending was set, then we'd dutifully retry, but with a bit more  
understanding of how posix_fallocate() works, it's now clear that you  
can get into a loop that never terminates.  posix_fallocate() is not a  
function that can do some of the job and tell you about progress if it's  
interrupted, it has to undo what it's done so far and report EINTR, and  
if signals keep arriving faster than it can complete (cf recovery  
conflict signals), you're stuck.  
  
Therefore, for now, we'll simply block most signals to guarantee  
progress.  SIGQUIT is not blocked (see InitPostmasterChild()), because  
its expected handler doesn't return, and unblockable signals like  
SIGCONT are not expected to arrive at a high rate.  For good measure,  
we'll include the ftruncate() call in the blocked region, and add a  
retry loop.  
  
Back-patch to all supported releases.  
  
Reported-by: Alvaro Herrera <alvherre@alvh.no-ip.org>  
Reported-by: Nicola Contu <nicola.contu@gmail.com>  
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/20220701154105.jjfutmngoedgiad3%40alvherre.pgsql  

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

Plug memory leak

commit   : 9e038d6907b3d6cf5854eb36bf150db90bec60a0    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 13 Jul 2022 12:10:03 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 13 Jul 2022 12:10:03 +0200    

Click here for diff

Commit 054325c5eeb3 created a memory leak in PQsendQueryInternal in case  
an error occurs while sending the message.  Repair.  
  
Backpatch to 14, like that commit.  Reported by Coverity.  

M src/interfaces/libpq/fe-exec.c

Invent qsort_interruptible().

commit   : af72b0889441e5ece199f782511d84d72fa6b88c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 12 Jul 2022 16:30:36 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 12 Jul 2022 16:30:36 -0400    

Click here for diff

Justin Pryzby reported that some scenarios could cause gathering  
of extended statistics to spend many seconds in an un-cancelable  
qsort() operation.  To fix, invent qsort_interruptible(), which is  
just like qsort_arg() except that it will also do CHECK_FOR_INTERRUPTS  
every so often.  This bloats the backend by a couple of kB, which  
seems like a good investment.  (We considered just enabling  
CHECK_FOR_INTERRUPTS in the existing qsort and qsort_arg functions,  
but there are some callers for which that'd demonstrably be unsafe.  
Opt-in seems like a better way.)  
  
For now, just apply qsort_interruptible() in statistics collection.  
There's probably more places where it could be useful, but we can  
always change other call sites as we find problems.  
  
Back-patch to v14.  Before that we didn't have extended stats on  
expressions, so that the problem was less severe.  Also, this patch  
depends on the sort_template infrastructure introduced in v14.  
  
Tom Lane and Justin Pryzby  
  
Discussion: https://postgr.es/m/20220509000108.GQ28830@telsasoft.com  

M src/backend/commands/analyze.c
M src/backend/statistics/extended_stats.c
M src/backend/statistics/mcv.c
M src/backend/statistics/mvdistinct.c
M src/backend/tsearch/ts_typanalyze.c
M src/backend/utils/adt/array_typanalyze.c
M src/backend/utils/adt/rangetypes_typanalyze.c
M src/backend/utils/sort/Makefile
A src/backend/utils/sort/qsort_interruptible.c
M src/include/port.h

Fix lock assertions in dshash.c.

commit   : 5e7608e81ebb2a9e2a72ab771eba3c620c0b42a6    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Mon, 11 Jul 2022 14:47:16 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Mon, 11 Jul 2022 14:47:16 +1200    

Click here for diff

dshash.c previously maintained flags to be able to assert that you  
didn't hold any partition lock.  These flags could get out of sync with  
reality in error scenarios.  
  
Get rid of all that, and make assertions about the locks themselves  
instead.  Since LWLockHeldByMe() loops internally, we don't want to put  
that inside another loop over all partition locks.  Introduce a new  
debugging-only interface LWLockAnyHeldByMe() to avoid that.  
  
This problem was noted by Tom and Andres while reviewing changes to  
support the new shared memory stats system, and later showed up in  
reality while working on commit 389869af.  
  
Back-patch to 11, where dshash.c arrived.  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reported-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>  
Reviewed-by: Zhihong Yu <zyu@yugabyte.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/20220311012712.botrpsikaufzteyt@alap3.anarazel.de  
Discussion: https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com  

M src/backend/lib/dshash.c
M src/backend/storage/lmgr/lwlock.c
M src/include/storage/lwlock.h

doc: Fix inconsistent quotes in some jsonb fields

commit   : ec5f1fe2fca5f7b8f06aed6f3f4efbe8288c031e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 11 Jul 2022 10:56:48 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 11 Jul 2022 10:56:48 +0900    

Click here for diff

Single quotes are not allowed in json internals, double quotes are.  
  
Reported-by: Eric Mutta  
Discussion: https://postgr.es/m/165715362165.665.3875113264927503997@wrigleys.postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/json.sgml

Fix \watch's interaction with libedit on ^C.

commit   : ab7fef0acfbd33331b4d3a000d501454fdcee8f2    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Sun, 10 Jul 2022 16:30:03 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Sun, 10 Jul 2022 16:30:03 +1200    

Click here for diff

When you hit ^C, the terminal driver in Unix-like systems echoes "^C" as  
well as sending an interrupt signal (depending on stty settings).  At  
least libedit (but maybe also libreadline) is then confused about the  
current cursor location, and corrupts the display if you try to scroll  
back.  Fix, by moving to a new line before the next prompt is displayed.  
  
Back-patch to all supported released.  
  
Author: Pavel Stehule <pavel.stehule@gmail.com>  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/3278793.1626198638%40sss.pgh.pa.us  

M src/bin/psql/command.c

doc: add examples for array_length() and jsonb_array_length()

commit   : f1c779e2b9e48eab05ad471e4111eb17e7e6ad3a    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 8 Jul 2022 20:23:35 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 8 Jul 2022 20:23:35 -0400    

Click here for diff

The examples show the output of array_length() and jsonb_array_length()  
for empty arrays.  
  
Discussion: https://postgr.es/m/CAKFQuwaoBmRuWdMLzLHDCFDJDX3wvfQ7egAF0bpik_BFgG1KWg@mail.gmail.com  
  
Author: David G. Johnston  
  
Backpatch-through: 13  

M doc/src/sgml/func.sgml

doc: add pg_prewarm example

commit   : 9d71664c88defe967ccdbf485c0216c0d5a301ee    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 8 Jul 2022 18:36:27 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 8 Jul 2022 18:36:27 -0400    

Click here for diff

Discussion: https://postgr.es/m/20220618085541.ezxdaljlpo6x7msc@home-desktop  
  
Author: Dong Wook Lee  
  
Backpatch-through: 11  

M doc/src/sgml/pgprewarm.sgml

Fix alias matching in transformLockingClause().

commit   : 8d8464445a476f0de961006d684922ada545d9a4    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Thu, 7 Jul 2022 13:08:03 +0100    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Thu, 7 Jul 2022 13:08:03 +0100    

Click here for diff

When locking a specific named relation for a FOR [KEY] UPDATE/SHARE  
clause, transformLockingClause() finds the relation to lock by  
scanning the rangetable for an RTE with a matching eref->aliasname.  
However, it failed to account for the visibility rules of a join RTE.  
  
If a join RTE doesn't have a user-supplied alias, it will have a  
generated eref->aliasname of "unnamed_join" that is not visible as a  
relation name in the parse namespace. Such an RTE needs to be skipped,  
otherwise it might be found in preference to a regular base relation  
with a user-supplied alias of "unnamed_join", preventing it from being  
locked.  
  
In addition, if a join RTE doesn't have a user-supplied alias, but  
does have a join_using_alias, then the RTE needs to be matched using  
that alias rather than the generated eref->aliasname, otherwise a  
misleading "relation not found" error will be reported rather than a  
"join cannot be locked" error.  
  
Backpatch all the way, except for the second part which only goes back  
to 14, where JOIN USING aliases were added.  
  
Dean Rasheed, reviewed by Tom Lane.  
  
Discussion: https://postgr.es/m/CAEZATCUY_KOBnqxbTSPf=7fz9HWPnZ5Xgb9SwYzZ8rFXe7nb=w@mail.gmail.com  

M src/backend/parser/analyze.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Tighten pg_upgrade's new check for non-upgradable anyarray usages.

commit   : 9783413cbff9f2b4893ab81e873968905a2cfbfc    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 5 Jul 2022 18:23:19 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 5 Jul 2022 18:23:19 -0400    

Click here for diff

We only need to reject cases when the aggregate or operator is  
itself declared with a polymorphic type.  Per buildfarm.  
  
Discussion: https://postgr.es/m/3383880.QJadu78ljV@vejsadalnx  

M src/bin/pg_upgrade/check.c

Fix pg_upgrade to detect non-upgradable anyarray usages.

commit   : 175e60a5e35e213f42ed69eeb5ab992a49ae41f4    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 5 Jul 2022 13:06:31 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 5 Jul 2022 13:06:31 -0400    

Click here for diff

When we changed some built-in functions to use anycompatiblearray  
instead of anyarray, we created a dump/restore hazard for user-defined  
operators and aggregates relying on those functions: the user objects  
have to be modified to change their signatures similarly.  This causes  
pg_upgrade to fail partway through if the source installation contains  
such objects.  We generally try to have pg_upgrade detect such hazards  
and fail before it does anything exciting, so add logic to detect  
this case too.  
  
Back-patch to v14 where the change was made.  
  
Justin Pryzby, reviewed by Andrey Borodin  
  
Discussion: https://postgr.es/m/3383880.QJadu78ljV@vejsadalnx  

M src/bin/pg_upgrade/check.c

libpq: Improve idle state handling in pipeline mode

commit   : 7c1f426123845c8be6a3a2791dbc0ebc87a92c40    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 5 Jul 2022 14:21:20 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 5 Jul 2022 14:21:20 +0200    

Click here for diff

We were going into IDLE state too soon when executing queries via  
PQsendQuery in pipeline mode, causing several scenarios to misbehave in  
different ways -- most notably, as reported by Daniele Varrazzo, that a  
warning message is produced by libpq:  
  message type 0x33 arrived from server while idle  
But it is also possible, if queries are sent and results consumed not in  
lockstep, for the expected mediating NULL result values from PQgetResult  
to be lost (a problem which has not been reported, but which is more  
serious).  
  
Fix this by introducing two new concepts: one is a command queue element  
PGQUERY_CLOSE to tell libpq to wait for the CloseComplete server  
response to the Close message that is sent by PQsendQuery.  Because the  
application is not expecting any PGresult from this, the mechanism to  
consume it is a bit hackish.  
  
The other concept, authored by Horiguchi-san, is a PGASYNC_PIPELINE_IDLE  
state for libpq's state machine to differentiate "really idle" from  
merely "the idle state that occurs in between reading results from the  
server for elements in the pipeline".  This makes libpq not go fully  
IDLE when the libpq command queue contains entries; in normal cases, we  
only go IDLE once at the end of the pipeline, when the server response  
to the final SYNC message is received.  (However, there are corner cases  
it doesn't fix, such as terminating the query sequence by  
PQsendFlushRequest instead of PQpipelineSync; this sort of scenario is  
what requires PGQUERY_CLOSE bit above.)  
  
This last bit helps make the libpq state machine clearer; in particular  
we can get rid of an ugly hack in pqParseInput3 to avoid considering  
IDLE as such when the command queue contains entries.  
  
A new test mode is added to libpq_pipeline.c to tickle some related  
problematic cases.  
  
Reported-by: Daniele Varrazzo <daniele.varrazzo@gmail.com>  
Co-authored-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://postgr.es/m/CA+mi_8bvD0_CW3sumgwPvWdNzXY32itoG_16tDYRu_1S2gV2iw@mail.gmail.com  

M src/interfaces/libpq/fe-exec.c
M src/interfaces/libpq/fe-protocol3.c
M src/interfaces/libpq/libpq-int.h
M src/test/modules/libpq_pipeline/libpq_pipeline.c
M src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
A src/test/modules/libpq_pipeline/traces/pipeline_idle.trace

BRIN: improve documentation on summarization

commit   : 0b71e43c4892bdbbf57e6ff441d9443f22d1fda3    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 5 Jul 2022 13:38:26 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 5 Jul 2022 13:38:26 +0200    

Click here for diff

The existing wording wasn't clear enough and some details weren't  
anywhere, such as the fact that autosummarization is off by default.  
Improve.  
  
Authors: Roberto Mello, Jaime Casanova, Justin Pryzby, Álvaro Herrera  
Discussion: https://postgr.es/m/CAKz==bK_NoJytRyQfX8K-erCW3Ff7--oGYpiB8+ePVS7dRVW_A@mail.gmail.com  
Discussion: https://postgr.es/m/20220224193520.GY9008@telsasoft.com  

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

Remove %error-verbose directive from jsonpath parser

commit   : 7fd43684fc9e3f2da9c646dea04a531bd6f50cee    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Sun, 3 Jul 2022 17:08:25 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Sun, 3 Jul 2022 17:08:25 -0400    

Click here for diff

None of the other bison parsers contains this directive, and it gives  
rise to some unfortunate and impenetrable messages, so just remove it.  
  
Backpatch to release 12, where it was introduced.  
  
Per gripe from Erik Rijkers  
  
Discussion: https://postgr.es/m/ba069ce2-a98f-dc70-dc17-2ccf2a9bf7c7@xs4all.nl  

M src/backend/utils/adt/jsonpath_gram.y
M src/test/regress/expected/jsonpath.out

Fix previous commit's ecpg_clocale for ppc Darwin.

commit   : 463a841d7407dbc96cc1c39ca99ebe9c8bdd3244    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 2 Jul 2022 21:03:19 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 2 Jul 2022 21:03:19 -0700    

Click here for diff

Per buildfarm member prairiedog, this platform rejects uninitialized  
global variables in shared libraries.  Back-patch to v10, like the  
addition of the variable.  
  
Reviewed by Tom Lane.  
  
Discussion: https://postgr.es/m/20220703030619.GB2378460@rfd.leadboat.com  

M src/interfaces/ecpg/ecpglib/connect.c

ecpglib: call newlocale() once per process.

commit   : 5b94e2bd4d5430f5ea4e965a32727a6006972a55    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 2 Jul 2022 13:00:30 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 2 Jul 2022 13:00:30 -0700    

Click here for diff

ecpglib has been calling it once per SQL query and once per EXEC SQL GET  
DESCRIPTOR.  Instead, if newlocale() has not succeeded before, call it  
while establishing a connection.  This mitigates three problems:  
- If newlocale() failed in EXEC SQL GET DESCRIPTOR, the command silently  
  proceeded without the intended locale change.  
- On AIX, each newlocale()+freelocale() cycle leaked memory.  
- newlocale() CPU usage may have been nontrivial.  
  
Fail the connection attempt if newlocale() fails.  Rearrange  
ecpg_do_prologue() to validate the connection before its uselocale().  
  
The sort of program that may regress is one running in an environment  
where newlocale() fails.  If that program establishes connections  
without running SQL statements, it will stop working in response to this  
change.  I'm betting against the importance of such an ECPG use case.  
Most SQL execution (any using ECPGdo()) has long required newlocale()  
success, so there's little a connection could do without newlocale().  
  
Back-patch to v10 (all supported versions).  
  
Reviewed by Tom Lane.  Reported by Guillaume Lelarge.  
  
Discussion: https://postgr.es/m/20220101074055.GA54621@rfd.leadboat.com  

M src/interfaces/ecpg/ecpglib/connect.c
M src/interfaces/ecpg/ecpglib/descriptor.c
M src/interfaces/ecpg/ecpglib/ecpglib_extern.h
M src/interfaces/ecpg/ecpglib/execute.c

Harden dsm_impl.c against unexpected EEXIST.

commit   : fb81a93a6442e55d8c7376a01c27cb5d6c062c80    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Fri, 1 Jul 2022 12:05:52 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Fri, 1 Jul 2022 12:05:52 +1200    

Click here for diff

Previously, we trusted the OS not to report EEXIST unless we'd passed in  
IPC_CREAT | IPC_EXCL or O_CREAT | O_EXCL, as appropriate.  Solaris's  
shm_open() can in fact do that, causing us to crash because we didn't  
ereport and then we blithely assumed the mapping was successful.  
  
Let's treat EEXIST just like any other error, unless we're actually  
trying to create a new segment.  This applies to shm_open(), where this  
behavior has been seen, and also to the equivalent operations for our  
sysv and mmap modes just on principle.  
  
Based on the underlying reason for the error, namely contention on a  
lock file managed by Solaris librt for each distinct name, this problem  
is only likely to happen on 15 and later, because the new shared memory  
stats system produces shm_open() calls for the same path from  
potentially large numbers of backends concurrently during  
authentication.  Earlier releases only shared memory segments between a  
small number of parallel workers under one Gather node.  You could  
probably hit it if you tried hard enough though, and we should have been  
more defensive in the first place.  Therefore, back-patch to all  
supported releases.  
  
Per build farm animal margay.  This isn't the end of the story, though,  
it just changes random crashes into random "File exists" errors; more  
work needed for a green build farm.  
  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/CA%2BhUKGKqKrCV5xKWfh9rnm%3Do%3DDwZLTLtnsj_XpUi9g5%3DV%2B9oyg%40mail.gmail.com  

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

Fix visibility check when XID is committed in CLOG but not in procarray.

commit   : e24615a0057a9932904317576cf5c4d42349b363    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 27 Jun 2022 08:21:08 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 27 Jun 2022 08:21:08 +0300    

Click here for diff

TransactionIdIsInProgress had a fast path to return 'false' if the  
single-item CLOG cache said that the transaction was known to be  
committed. However, that was wrong, because a transaction is first  
marked as committed in the CLOG but doesn't become visible to others  
until it has removed its XID from the proc array. That could lead to an  
error:  
  
    ERROR:  t_xmin is uncommitted in tuple to be updated  
  
or for an UPDATE to go ahead without blocking, before the previous  
UPDATE on the same row was made visible.  
  
The window is usually very short, but synchronous replication makes it  
much wider, because the wait for synchronous replica happens in that  
window.  
  
Another thing that makes it hard to hit is that it's hard to get such  
a commit-in-progress transaction into the single item CLOG cache.  
Normally, if you call TransactionIdIsInProgress on such a transaction,  
it determines that the XID is in progress without checking the CLOG  
and without populating the cache. One way to prime the cache is to  
explicitly call pg_xact_status() on the XID. Another way is to use a  
lot of subtransactions, so that the subxid cache in the proc array is  
overflown, making TransactionIdIsInProgress rely on pg_subtrans and  
CLOG checks.  
  
This has been broken ever since it was introduced in 2008, but the race  
condition is very hard to hit, especially without synchronous  
replication. There were a couple of reports of the error starting from  
summer 2021, but no one was able to find the root cause then.  
  
TransactionIdIsKnownCompleted() is now unused. In 'master', remove it,  
but I left it in place in backbranches in case it's used by extensions.  
  
Also change pg_xact_status() to check TransactionIdIsInProgress().  
Previously, it only checked the CLOG, and returned "committed" before  
the transaction was actually made visible to other queries. Note that  
this also means that you cannot use pg_xact_status() to reproduce the  
bug anymore, even if the code wasn't fixed.  
  
Report and analysis by Konstantin Knizhnik. Patch by Simon Riggs, with  
the pg_xact_status() change added by me.  
  
Author: Simon Riggs  
Reviewed-by: Andres Freund  
Discussion: https://www.postgresql.org/message-id/flat/4da7913d-398c-e2ad-d777-f752cf7f0bbb%40garret.ru  

M src/backend/access/transam/transam.c
M src/backend/storage/ipc/procarray.c
M src/backend/utils/adt/xid8funcs.c

Fix relptr's encoding of the base address.

commit   : 99504ff8265eac35da5af06f4ce99196bbdc0239    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Mon, 27 Jun 2022 10:30:15 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Mon, 27 Jun 2022 10:30:15 +1200    

Click here for diff

Previously, we encoded both NULL and the first byte at the base address  
as 0.  That confusion led to the assertion in commit e07d4ddc, which  
failed when min_dynamic_shared_memory was used.  Give them distinct  
encodings, by switching to 1-based offsets for non-NULL pointers.  Also  
improve macro hygiene in passing (missing/misplaced parentheses), and  
remove open-coded access to the raw offset value from freepage.c/h.  
  
Although e07d4ddc was back-patched to 10, the only code that actually  
makes use of relptr at the base address arrived in 84b1c63a, so no need  
to back-patch further than 14 for now.  
  
Reported-by: Justin Pryzby <pryzby@telsasoft.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/20220519193839.GT19626%40telsasoft.com  

M src/backend/utils/mmgr/freepage.c
M src/include/utils/freepage.h
M src/include/utils/relptr.h

Don't trust signalfd() on illumos.

commit   : e086b55381a98975348051d218cff0752c19d0f9    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Sun, 26 Jun 2022 10:40:06 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Sun, 26 Jun 2022 10:40:06 +1200    

Click here for diff

Since commit 6a2a70a02, we've used signalfd() to receive latch wakeups  
when building with WAIT_USE_EPOLL (default for Linux and illumos), and  
our traditional self-pipe when falling back to WAIT_USE_POLL (default  
for other Unixes with neither epoll() nor kqueue()).  
  
Unexplained hangs and kernel panics have been reported on illumos  
systems, apparently linked to this use of signalfd(), leading illumos  
users and build farm members to have to define WAIT_USE_POLL explicitly  
as a work-around.  A bug report exists at  
https://www.illumos.org/issues/13700 but no fix is available yet.  
  
Let's provide a way for illumos users to go back to self-pipes with  
epoll(), like releases before 14, and choose that by default.  No change  
for Linux users.  To help with development/debugging, macros  
WAIT_USE_{EPOLL,POLL} and WAIT_USE_{SIGNALFD,SELF_PIPE} can be defined  
explicitly to override the defaults.  
  
Back-patch to 14, where we started using signalfd().  
  
Reported-by: Japin Li <japinli@hotmail.com>  
Reported-by: Olaf Bohlen <olbohlen@eenfach.de> (off-list)  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Discussion: https://postgr.es/m/MEYP282MB1669C8D88F0997354C2313C1B6CA9%40MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM  

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

Fix PostgreSQL::Test aliasing for Perl v5.10.1.

commit   : 4b0d21b06c6b0f3b0fec0d069759f4b82913e452    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 25 Jun 2022 14:15:56 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 25 Jun 2022 14:15:56 -0700    

Click here for diff

This Perl segfaults if a declaration of the to-be-aliased package  
precedes the aliasing itself.  Per buildfarm members lapwing and wrasse.  
Like commit 20911775de4ab7ac3ecc68bd714cb3ed0fd68b6a, back-patch to v10  
(all supported versions).  
  
Discussion: https://postgr.es/m/20220625171533.GA2012493@rfd.leadboat.com  

M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/perl/PostgreSQL/Test/Utils.pm

CREATE INDEX: use the original userid for more ACL checks.

commit   : ace9973867c2f17ed6191a4a3b9a46939a2df45b    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 25 Jun 2022 09:07:41 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 25 Jun 2022 09:07:41 -0700    

Click here for diff

Commit a117cebd638dd02e5c2e791c25e43745f233111b used the original userid  
for ACL checks located directly in DefineIndex(), but it still adopted  
the table owner userid for more ACL checks than intended.  That broke  
dump/reload of indexes that refer to an operator class, collation, or  
exclusion operator in a schema other than "public" or "pg_catalog".  
Back-patch to v10 (all supported versions), like the earlier commit.  
  
Nathan Bossart and Noah Misch  
  
Discussion: https://postgr.es/m/f8a4105f076544c180a87ef0c4822352@stmuk.bayern.de  

M contrib/citext/Makefile
A contrib/citext/expected/create_index_acl.out
A contrib/citext/sql/create_index_acl.sql
M src/backend/commands/indexcmds.c

For PostgreSQL::Test compatibility, alias entire package symbol tables.

commit   : 20911775de4ab7ac3ecc68bd714cb3ed0fd68b6a    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 25 Jun 2022 09:07:44 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 25 Jun 2022 09:07:44 -0700    

Click here for diff

Remove the need to edit back-branch-specific code sites when  
back-patching the addition of a PostgreSQL::Test::Utils symbol.  Replace  
per-symbol, incomplete alias lists.  Give old and new package names the  
same EXPORT and EXPORT_OK semantics.  Back-patch to v10 (all supported  
versions).  
  
Reviewed by Andrew Dunstan.  
  
Discussion: https://postgr.es/m/20220622072144.GD4167527@rfd.leadboat.com  

M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/perl/PostgreSQL/Test/Utils.pm
M src/test/perl/PostgresNode.pm
M src/test/perl/TestLib.pm

Fix memory leak due to LogicalRepRelMapEntry.attrmap.

commit   : 3238b5c330bc384441473dd2859845c27d9ade2f    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 23 Jun 2022 09:20:41 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 23 Jun 2022 09:20:41 +0530    

Click here for diff

When rebuilding the relation mapping on subscribers, we were not releasing  
the attribute mapping's memory which was no longer required.  
  
The attribute mapping used in logical tuple conversion was refactored in  
PG13 (by commit e1551f96e6) but we forgot to update the related code that  
frees the attribute map.  
  
Author: Hou Zhijie  
Reviewed-by: Amit Langote, Amit Kapila, Shi yu  
Backpatch-through: 10, where it was introduced  
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com  

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

doc: improve wording of plpgsql RAISE format text

commit   : f1e3a7075832f218a36feb04b059c7da04fb19ee    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Wed, 22 Jun 2022 16:59:54 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Wed, 22 Jun 2022 16:59:54 -0400    

Click here for diff

Reported-by: pg@kirasoft.com  
  
Discussion: https://postgr.es/m/165455351426.573551.7050474465030525109@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/plpgsql.sgml

doc: clarify wording about phantom reads

commit   : 1463f22d42fddc620ca29c6fa9eb7dce0e56a2fe    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Wed, 22 Jun 2022 14:33:26 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Wed, 22 Jun 2022 14:33:26 -0400    

Click here for diff

Reported-by: akhilhello@gmail.com  
  
Discussion: https://postgr.es/m/165222922369.669.10475917322916060899@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/high-availability.sgml
M doc/src/sgml/mvcc.sgml

Fix SPI's handling of errors during transaction commit.

commit   : 604651880c71c5106a72529b9ce29eaad0cfab27    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 22 Jun 2022 12:11:59 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 22 Jun 2022 12:11:59 -0400    

Click here for diff

SPI_commit previously left it up to the caller to recover from any error  
occurring during commit.  Since that's complicated and requires use of  
low-level xact.c facilities, it's not too surprising that no caller got  
it right.  Let's move the responsibility for cleanup into spi.c.  Doing  
that requires redefining SPI_commit as starting a new transaction, so  
that it becomes equivalent to SPI_commit_and_chain except that you get  
default transaction characteristics instead of preserving the prior  
transaction's characteristics.  We can make this pretty transparent  
API-wise by redefining SPI_start_transaction() as a no-op.  Callers  
that expect to do something in between might be surprised, but  
available evidence is that no callers do so.  
  
Having made that API redefinition, we can fix this mess by having  
SPI_commit[_and_chain] trap errors and start a new, clean transaction  
before re-throwing the error.  Likewise for SPI_rollback[_and_chain].  
Some cleanup is also needed in AtEOXact_SPI, which was nowhere near  
smart enough to deal with SPI contexts nested inside a committing  
context.  
  
While plperl and pltcl need no changes beyond removing their now-useless  
SPI_start_transaction() calls, plpython needs some more work because it  
hadn't gotten the memo about catching commit/rollback errors in the  
first place.  Such an error resulted in longjmp'ing out of the Python  
interpreter, which leaks Python stack entries at present and is reported  
to crash Python 3.11 altogether.  Add the missing logic to catch such  
errors and convert them into Python exceptions.  
  
This is a back-patch of commit 2e517818f.  That's now aged long enough  
to reduce the concerns about whether it will break something, and we  
do need to ensure that supported branches will work with Python 3.11.  
  
Peter Eisentraut and Tom Lane  
  
Discussion: https://postgr.es/m/3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.com  
Discussion: https://postgr.es/m/17416-ed8fe5d7213d6c25@postgresql.org  

M doc/src/sgml/spi.sgml
M src/backend/executor/spi.c
M src/backend/tcop/postgres.c
M src/backend/utils/mmgr/portalmem.c
M src/include/executor/spi.h
M src/pl/plperl/expected/plperl_transaction.out
M src/pl/plperl/plperl.c
M src/pl/plperl/sql/plperl_transaction.sql
M src/pl/plpgsql/src/pl_exec.c
M src/pl/plpython/expected/plpython_transaction.out
M src/pl/plpython/plpy_plpymodule.c
M src/pl/plpython/plpy_spi.c
M src/pl/plpython/plpy_spi.h
M src/pl/plpython/sql/plpython_transaction.sql
M src/pl/tcl/expected/pltcl_transaction.out
M src/pl/tcl/pltcl.c
M src/pl/tcl/sql/pltcl_transaction.sql

Fix stale values in partition map entries on subscribers.

commit   : f0022a77d011411d8314e1e554e182d0ab8e142e    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Tue, 21 Jun 2022 15:30:36 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Tue, 21 Jun 2022 15:30:36 +0530    

Click here for diff

We build the partition map entries on subscribers while applying the  
changes for update/delete on partitions. The component relation in each  
entry is closed after its use so we need to update it on successive use of  
cache entries.  
  
This problem was there since the original commit f1ac27bfda that  
introduced this code but we didn't notice it till the recent commit  
26b3455afa started to use the component relation of partition map cache  
entry.  
  
Reported-by: Tom Lane, as per buildfarm  
Author: Amit Langote, Hou Zhijie  
Reviewed-by: Amit Kapila, Shi Yu  
Backpatch-through: 13, where it was introduced  
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com  

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

Fix partition table's REPLICA IDENTITY checking on the subscriber.

commit   : 52d5ea9adb010d0908e8962842571cd1f6c2d66c    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Tue, 21 Jun 2022 07:52:41 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Tue, 21 Jun 2022 07:52:41 +0530    

Click here for diff

In logical replication, we will check if the target table on the  
subscriber is updatable by comparing the replica identity of the table on  
the publisher with the table on the subscriber. When the target table is a  
partitioned table, we only check its replica identity but not for the  
partition tables. This leads to assertion failure while applying changes  
for update/delete as we expect those to succeed only when the  
corresponding partition table has a primary key or has a replica  
identity defined.  
  
Fix it by checking the replica identity of the partition table while  
applying changes.  
  
Reported-by: Shi Yu  
Author: Shi Yu, Hou Zhijie  
Reviewed-by: Amit Langote, Amit Kapila  
Backpatch-through: 13, where it was introduced  
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com  

M src/backend/replication/logical/relation.c
M src/backend/replication/logical/worker.c
M src/test/subscription/t/013_partition.pl

Fix data inconsistency between publisher and subscriber.

commit   : 0980adfd4d021e3329bf41452ce1a1210321974f    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 16 Jun 2022 08:32:10 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 16 Jun 2022 08:32:10 +0530    

Click here for diff

We were not updating the partition map cache in the subscriber even when  
the corresponding remote rel is changed. Due to this data was getting  
incorrectly replicated for partition tables after the publisher has  
changed the table schema.  
  
Fix it by resetting the required entries in the partition map cache after  
receiving a new relation mapping from the publisher.  
  
Reported-by: Shi Yu  
Author: Shi Yu, Hou Zhijie  
Reviewed-by: Amit Langote, Amit Kapila  
Backpatch-through: 13, where it was introduced  
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com  

M src/backend/replication/logical/relation.c
M src/backend/replication/logical/worker.c
M src/include/replication/logicalrelation.h
M src/test/subscription/t/013_partition.pl

Fix cache look-up failures while applying changes in logical replication.

commit   : d457cb4e8a5e25fe16420cb91cb8450d8fca49d3    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 15 Jun 2022 09:59:52 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 15 Jun 2022 09:59:52 +0530    

Click here for diff

While building a new attrmap which maps partition attribute numbers to  
remoterel's, we incorrectly update the map for dropped column attributes.  
Later, it caused cache look-up failure when we tried to use the map to  
fetch the information about attributes.  
  
This also fixes the partition map cache invalidation which was using the  
wrong type cast to fetch the entry. We were using stale partition map  
entry after invalidation which leads to the assertion or cache look-up  
failure.  
  
Reported-by: Shi Yu  
Author: Hou Zhijie, Shi Yu  
Reviewed-by: Amit Langote, Amit Kapila  
Backpatch-through: 13, where it was introduced  
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com  

M src/backend/replication/logical/relation.c
M src/test/subscription/t/013_partition.pl

Avoid ecpglib core dump with out-of-order operations.

commit   : 7bc21ed8c8e755ef6fe41dae60c198fcc9c9ee56    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 14 Jun 2022 18:16:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 14 Jun 2022 18:16:46 -0400    

Click here for diff

If an application executed operations like EXEC SQL PREPARE  
without having first established a database connection, it could  
get a core dump instead of the expected clean failure.  This  
occurred because we did "pthread_getspecific(actual_connection_key)"  
without ever having initialized the TSD key actual_connection_key.  
The results of that are probably platform-specific, but at least  
on Linux it often leads to a crash.  
  
To fix, add calls to ecpg_pthreads_init() in the code paths that  
might use actual_connection_key uninitialized.  It's harmless  
(and hopefully inexpensive) to do that more than once.  
  
Per bug #17514 from Okano Naoki.  The problem's ancient, so  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/17514-edd4fad547c5692c@postgresql.org  

M src/interfaces/ecpg/ecpglib/connect.c

Doc: clarify the default collation behavior of domains.

commit   : be35a6456901cfdf4df91697370dc5edac7e58c5    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 14 Jun 2022 17:47:09 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 14 Jun 2022 17:47:09 -0400    

Click here for diff

The previous wording was "the underlying data type's default collation  
is used", which is wrong or at least misleading.  The domain inherits  
the base type's collation behavior, which if "default" actually can  
mean that we use some non-default collation obtained from elsewhere.  
  
Per complaint from Jian He.  
  
Discussion: https://postgr.es/m/CACJufxHMR8_4WooDPjjvEdaxB2hQ5a49qthci8fpKP0MKemVRQ@mail.gmail.com  

M doc/src/sgml/ref/create_domain.sgml

Stamp 14.4.

commit   : 164d174bbf9a3aba719c845497863cd3c49a3ad0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 13 Jun 2022 16:04:05 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 13 Jun 2022 16:04:05 -0400    

Click here for diff

M configure
M configure.ac

Translation updates

commit   : cb31fc24b7283a663d1cfc760bb655a86a48b571    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jun 2022 07:32:39 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jun 2022 07:32:39 +0200    

Click here for diff

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

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

Doc: remove a04ccf6df from release notes, now that it's reverted.

commit   : 18f66a1a91bdc44dce2823faec9530dc14223234    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 16:38:15 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 16:38:15 -0400    

Click here for diff

Discussion: https://postgr.es/m/17504-76b68018e130415e@postgresql.org  

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

Revert "Fix psql's single transaction mode on client-side errors with -c/-f switches".

commit   : f25b5519c99a68324b147dad15b68b1a3bd378ad    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 16:34:25 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 16:34:25 -0400    

Click here for diff

This reverts commits a04ccf6df et al. in the back branches only.  
There was some disagreement already over whether to back-patch  
157f8739a, on the grounds that it is the sort of behavioral  
change that we don't like to back-patch.  Furthermore, it now  
looks like the logic needs some more work, which we don't have  
time for before the upcoming 14.4 release.  Revert for now, and  
perhaps reconsider later.  
  
Discussion: https://postgr.es/m/17504-76b68018e130415e@postgresql.org  

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

First-draft release notes for 14.4.

commit   : 03fa84ac7c9239a18b7953d49acedd80f6aaccee    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 13:47:19 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 13:47:19 -0400    

Click here for diff

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

Un-break whole-row Vars referencing domain-over-composite types.

commit   : 77c1d92cbac15f3c9c02f9a5b1ef551842659de6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 10:35:57 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 10 Jun 2022 10:35:57 -0400    

Click here for diff

In commit ec62cb0aa, I foolishly replaced ExecEvalWholeRowVar's  
lookup_rowtype_tupdesc_domain call with just lookup_rowtype_tupdesc,  
because I didn't see how a domain could be involved there, and  
there were no regression test cases to jog my memory.  But the  
existing code was correct, so revert that change and add a test  
case showing why it's necessary.  (Note: per comment in struct  
DatumTupleFields, it is correct to produce an output tuple that's  
labeled with the base composite type, not the domain; hence just  
blindly looking through the domain is correct here.)  
  
Per bug #17515 from Dan Kubb.  Back-patch to v11 where domains over  
composites became a thing.  
  
Discussion: https://postgr.es/m/17515-a24737438363aca0@postgresql.org  

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

Doc: copy-edit "jsonb Indexing" section.

commit   : 0ccef410e4c35fd6a742091736b6fe1997eec6d3    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 8 Jun 2022 12:01:51 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 8 Jun 2022 12:01:51 -0400    

Click here for diff

The patch introducing jsonpath dropped a para about that between  
two related examples, and didn't bother updating the introductory  
sentences that it falsified.  The grammar was pretty shaky as well.  

M doc/src/sgml/json.sgml

Fix whitespace

commit   : 804a5079220d48598ce15a16f76c5d2d0df923d1    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jun 2022 14:27:42 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jun 2022 14:27:42 +0200    

Click here for diff

M src/test/perl/PostgreSQL/Test/Cluster.pm

Harden Memoization code against broken data types

commit   : cbcea3b91dcd242473dfdc5464dcfb53dae2bdf4    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 8 Jun 2022 12:39:44 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 8 Jun 2022 12:39:44 +1200    

Click here for diff

Bug #17512 highlighted that a suitably broken data type could cause the  
backend to crash if either the hash function or equality function were in  
someway non-deterministic based on their input values.  Such a data type  
could cause a crash of the backend due to some code which assumes that  
we'll always find a hash table entry corresponding to an item in the  
Memoize LRU list.  
  
Here we remove the assumption that we'll always find the entry  
corresponding to the given LRU list item and add run-time checks to verify  
we have found the given item in the cache.  
  
This is not a fix for bug #17512, but it will turn the crash reported by  
that bug report into an internal ERROR.  
  
Reported-by: Ales Zeleny  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/CAApHDvpxFSTwvoYWT7kmFVSZ9zLAeHb=S9vrz=RExMgSkQNWqw@mail.gmail.com  
Backpatch-through: 14, where Memoize was added.  

M src/backend/executor/nodeMemoize.c

Fix off-by-one loop termination condition in pg_stat_get_subscription().

commit   : 5c3b5f7db6cee574488dfbb9462f0eb6090315b9    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 7 Jun 2022 15:34:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 7 Jun 2022 15:34:30 -0400    

Click here for diff

pg_stat_get_subscription scanned one more LogicalRepWorker array entry  
than is really allocated.  In the worst case this could lead to SIGSEGV,  
if the LogicalRepCtx data structure is near the end of shared memory.  
That seems quite unlikely though (thanks to the ordering of calls in  
CreateSharedMemoryAndSemaphores) and we've heard no field reports of it.  
A more likely misbehavior is one row of garbage data in the function's  
result, but even that is not real likely because of the check that the  
pid field matches some live backend.  
  
Report and fix by Kuntal Ghosh.  This bug is old, so back-patch  
to all supported branches.  
  
Discussion: https://postgr.es/m/CAGz5QCJykEDzW6jQK6Yz7Qh_PMtD=95de_7QoocbVR2Qy8hWZA@mail.gmail.com  

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

Don't fail on libpq-generated error reports in pg_amcheck.

commit   : 32a85ee46b034be7b8bf8f31b24cf6fe3684fe7f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jun 2022 11:26:57 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jun 2022 11:26:57 -0400    

Click here for diff

An error PGresult generated by libpq itself, such as a report of  
connection loss, won't have broken-down error fields.  
should_processing_continue() blithely assumed that  
PG_DIAG_SEVERITY_NONLOCALIZED would always be present, and would  
dump core if it wasn't.  
  
Per grepping to see if 6d157e7cb's mistake was repeated elsewhere.  

M src/bin/pg_amcheck/pg_amcheck.c

Don't fail on libpq-generated error reports in ecpg_raise_backend().

commit   : a5dbca460ace7e89a607d43e206973efaee0ed19    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jun 2022 11:20:21 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jun 2022 11:20:21 -0400    

Click here for diff

An error PGresult generated by libpq itself, such as a report of  
connection loss, won't have broken-down error fields.  
ecpg_raise_backend() blithely assumed that PG_DIAG_MESSAGE_PRIMARY  
would always be present, and would end up passing a NULL string  
pointer to snprintf when it isn't.  That would typically crash  
before 3779ac62d, and it would fail to provide a useful error report  
in any case.  Best practice is to substitute PQerrorMessage(conn)  
in such cases, so do that.  
  
Per bug #17421 from Masayuki Hirose.  Back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/17421-790ff887e3188874@postgresql.org  

M src/interfaces/ecpg/ecpglib/error.c

Fix psql's single transaction mode on client-side errors with -c/-f switches

commit   : a04ccf6dfb4a15b9c279154b3366f8051de8b5d1    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jun 2022 11:07:22 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jun 2022 11:07:22 +0900    

Click here for diff

psql --single-transaction is able to handle multiple -c and -f switches  
in a single transaction since d5563d7d, but this had the surprising  
behavior of forcing a transaction COMMIT even if psql failed with an  
error in the client (for example incorrect path given to \copy), which  
would generate an error, but still commit any changes that were already  
applied in the backend.  This commit makes the behavior more consistent,  
by enforcing a transaction ROLLBACK if any commands fail, both  
client-side and backend-side, so as no changes are applied if one error  
happens in any of them.  
  
Some tests are added on HEAD to provide some coverage about all that.  
Backend-side errors are unreliable as IPC::Run can complain on SIGPIPE  
if psql quits before reading a query result, but that should work  
properly in the case where any errors come from psql itself, which is  
what the original report is about.  
  
Reported-by: Christoph Berg  
Author: Kyotaro Horiguchi, Michael Paquier  
Discussion: https://postgr.es/m/17504-76b68018e130415e@postgresql.org  
Backpatch-through: 10  

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

Doc: improve example for intarray's uniq() function.

commit   : c1ad8047a2c22f841e4e3df39696febeb7167e6c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jun 2022 13:54:53 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jun 2022 13:54:53 -0400    

Click here for diff

The previous entry invited confusion between what uniq() does  
by itself and what it does when combined with sort().  The latter  
usage is pretty useful so we should show it, but add an additional  
example to clarify the results of uniq() alone.  
  
Per suggestion from Martin Kalcher.  Back-patch to v13, where  
we switched to formatting that supports multiple examples.  
  
Discussion: https://postgr.es/m/165407884456.573551.8779012279828726162@wrigleys.postgresql.org  

M doc/src/sgml/intarray.sgml

Doc: fix incorrect bit-reversal in example of macaddr formatting.

commit   : 2223c2a7c4403e71c2553c313e958503084077f3    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jun 2022 11:51:37 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jun 2022 11:51:37 -0400    

Click here for diff

Will Mortensen (minor additional copy-editing by me)  
  
Discussion: https://postgr.es/m/CAMpnoC5Y6jiZHSA82FG+e_AqkwMg-i94EYqs1C_9kXXFc3_3Yw@mail.gmail.com  

M doc/src/sgml/datatype.sgml

Doc: Further fix CREATE FOREIGN TABLE synopsis.

commit   : 18e3b197bc6a4d957a92b3540b7afcc07a9e7f29    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 2 Jun 2022 18:00:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 2 Jun 2022 18:00:02 +0900    

Click here for diff

This patch fixes the partitioning synopsis in the Parameters section in  
the CREATE FOREIGN TABLE documentation.  Follow-up for commit ce21a36cf.  
  
Back-patch to v11 where default partition was introduced.  
  
Reviewed by Amit Langote and Robert Haas.  
  
Discussion: https://postgr.es/m/CAPmGK17U5jEqVZuo3r38wB0VFWomEtJCBGn_h92HQzQ2sP-49Q%40mail.gmail.com  

M doc/src/sgml/ref/create_foreign_table.sgml

Silence compiler warnings from some older compilers.

commit   : 4e467261560f087e0c75452646695a4edbb09de7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jun 2022 17:21:45 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jun 2022 17:21:45 -0400    

Click here for diff

Since a117cebd6, some older gcc versions issue "variable may be used  
uninitialized in this function" complaints for brin_summarize_range.  
Silence that using the same coding pattern as in bt_index_check_internal;  
arguably, a117cebd6 had too narrow a view of which compilers might give  
trouble.  
  
Nathan Bossart and Tom Lane.  Back-patch as the previous commit was.  
  
Discussion: https://postgr.es/m/20220601163537.GA2331988@nathanxps13  

M contrib/amcheck/verify_nbtree.c
M src/backend/access/brin/brin.c

Fix pl/perl test case so it will still work under Perl 5.36.

commit   : 1072e4c45dc3e4a9a62b34087414627b307e10f6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jun 2022 16:15:47 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jun 2022 16:15:47 -0400    

Click here for diff

Perl 5.36 has reclassified the warning condition that this test  
case used, so that the expected error fails to appear.  Tweak  
the test so it instead exercises a case that's handled the same  
way in all Perl versions of interest.  
  
This appears to meet our standards for back-patching into  
out-of-support branches: it changes no user-visible behavior  
but enables testing of old branches with newer tools.  
Hence, back-patch as far as 9.2.  
  
Dagfinn Ilmari Mannsåker, per report from Jitka Plesníková.  
  
Discussion: https://postgr.es/m/564579.1654093326@sss.pgh.pa.us  

M src/pl/plperl/expected/plperl.out
M src/pl/plperl/sql/plperl.sql

Doc: fix a couple of erroneous examples.

commit   : 80cd99c55802d4e4517049dea341ccb356cfa3ba    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jun 2022 10:39:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jun 2022 10:39:46 -0400    

Click here for diff

The example given for anyelement <@ anymultirange didn't return  
true as claimed; adjust it so it does.  
  
In passing, change a couple of sample results where the modern  
numeric-based logic produces a different number of trailing zeroes  
than before.  
  
Erik Rijkers  
  
Discussion: https://postgr.es/m/cc35735d-1ec1-5bb3-9e27-cddbab7afa23@xs4all.nl  

M doc/src/sgml/func.sgml

Doc: mention limitation of the number of resultset columns

commit   : f2a0060a9bfb7a6f257a536de5ea2d4f7cedff03    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 1 Jun 2022 12:46:18 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 1 Jun 2022 12:46:18 +1200    

Click here for diff

The PostgreSQL limitations section of the documents mentioned the limit  
on the number of columns that can exist in a table.  Users might be  
surprised to find that there's also a limit on the number of columns that  
can exist in a targetlist.  Users may experience restrictions which  
surprise them if they happened to select a large number of columns from  
several tables with many columns.  Here we document that there is a  
limitation on this and mention what that limit actually is.  
  
Wording proposal by Alvaro Herrera  
  
Reported-by: Vladimir Sitnikov  
Author: Dave Crammer  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/CAB=Je-E18aTYpNqje4mT0iEADpeGLSzwUvo3H9kRRuDdsNo4aQ@mail.gmail.com  
Backpatch-through: 12, where the limitations section was added  

M doc/src/sgml/limits.sgml

Recommend scram-sha-256 instead of md5 authentication in docs

commit   : a694cf4ca496a7db66a61f6ec2a15a9af6493cef    
  
author   : Magnus Hagander <magnus@hagander.net>    
date     : Tue, 31 May 2022 21:59:47 +0200    
  
committer: Magnus Hagander <magnus@hagander.net>    
date     : Tue, 31 May 2022 21:59:47 +0200    

Click here for diff

PostgreSQL 14 changed the default to be scram-sha-256, so we should stop  
recommending the user to use md5 or even worse password.  
  
Suggested-By: Daniel Westermann  
Author: Jonathan S. Katz  
Backpatch-through: 14  
Discussion: https://postgr.es/m/GV0P278MB0419A8BAC0B0B84AFA5263D9D2DC9@GV0P278MB0419.CHEP278.PROD.OUTLOOK.COM  

M doc/src/sgml/runtime.sgml

Revert changes to CONCURRENTLY that "sped up" Xmin advance

commit   : 042b584c7f7d6216c54359c0ee0f613ba3b3d9c2    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 31 May 2022 21:24:59 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 31 May 2022 21:24:59 +0200    

Click here for diff

This reverts commit d9d076222f5b "VACUUM: ignore indexing operations  
with CONCURRENTLY".  
  
These changes caused indexes created with the CONCURRENTLY option to  
miss heap tuples that were HOT-updated and HOT-pruned during the index  
creation.  Before these changes, HOT pruning would have been prevented  
by the Xmin of the transaction creating the index, but because this  
change was precisely to allow the Xmin to move forward ignoring that  
backend, now other backends scanning the table can prune them.  This is  
not a problem for VACUUM (which requires a lock that conflicts with a  
CREATE INDEX CONCURRENTLY operation), but HOT-prune can definitely  
occur.  In other words, Xmin advancement was sped up, but at the cost of  
corrupting the resulting index.  
  
Regrettably, this means that the new feature in PG14 that RIC/CIC on  
very large tables no longer force VACUUM to retain very old tuples goes  
away.  We might try to implement it again in a later release, but for  
now the risk of indexes missing tuples is too high and there's no easy  
fix.  
  
Backpatch to 14, where this change appeared.  
  
Reported-by: Peter Slavov <pet.slavov@gmail.com>  
Diagnosys-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Diagnosys-by: Michael Paquier <michael@paquier.xyz>  
Diagnosys-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/17485-396609c6925b982d%40postgresql.org  

M doc/src/sgml/ref/create_index.sgml
M doc/src/sgml/ref/reindex.sgml
M src/backend/storage/ipc/procarray.c

Ensure ParseTzFile() closes the input file after failing.

commit   : c47a558528dd79fe76c698cde7e23f38610b05ed    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 May 2022 14:47:44 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 May 2022 14:47:44 -0400    

Click here for diff

We hadn't noticed this because (a) few people feed invalid  
timezone abbreviation files to the server, and (b) in typical  
scenarios guc.c would throw ereport(ERROR) and then transaction  
abort handling would silently clean up the leaked file reference.  
However, it was possible to observe file leakage warnings if one  
breaks an already-active abbreviation file, because guc.c does  
not throw ERROR when loading supposedly-validated settings during  
session start or SIGHUP processing.  
  
Report and fix by Kyotaro Horiguchi (cosmetic adjustments by me)  
  
Discussion: https://postgr.es/m/20220530.173740.748502979257582392.horikyota.ntt@gmail.com  

M src/backend/utils/misc/tzparser.c

Doc: fix mention of pg_dump's minimum supported server version.

commit   : a18b2a3fbcf16998faeb35fc2341708983769841    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 May 2022 12:14:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 May 2022 12:14:02 -0400    

Click here for diff

runtime.sgml contains a passing reference to the minimum server  
version that pg_dump[all] can dump from.  That was 7.0 for many  
years, but when 64f3524e2 raised it to 8.0, we missed updating this  
bit.  Then when 30e7c175b raised it to 9.2, we missed it again.  
  
Given that track record, I'm not too hopeful that we'll remember  
to fix this in future changes ... but for now, make the docs match  
reality in each branch.  
  
Noted by Daniel Westermann.  
  
Discussion: https://postgr.es/m/GV0P278MB041917EB3E2FE8704B5AE2C6D2DC9@GV0P278MB0419.CHEP278.PROD.OUTLOOK.COM  

M doc/src/sgml/runtime.sgml

doc: Reword description of roles able to view track_activities's info

commit   : 0adff38da4bc88bcbcc07641ddc04180fe183188    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 30 May 2022 10:50:32 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 30 May 2022 10:50:32 +0900    

Click here for diff

The information generated when track_activities is accessible to  
superusers, roles with the privileges of pg_read_all_stats, as well as  
roles one has the privileges of.  The original text did not outline the  
last point, while the change done in ac1ae47 was unclear about the  
second point.  
  
Per discussion with Nathan Bossart.  
  
Discussion: https://postgr.es/m/20220521185743.GA886636@nathanxps13  
Backpatch-through: 10  

M doc/src/sgml/config.sgml

Fix COPY FROM when database encoding is SQL_ASCII.

commit   : f82595ac903e4e4062d909e73693dd809c6845c0    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sun, 29 May 2022 23:53:45 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sun, 29 May 2022 23:53:45 +0300    

Click here for diff

In the codepath when no encoding conversion is required, the check for  
incomplete character at the end of input incorrectly used server  
encoding's max character length, instead of the client's. Usually the  
server and client encodings are the same when we're not performing  
encoding conversion, but SQL_ASCII is an exception.  
  
In the passing, also fix some outdated comments that still talked about  
the old COPY protocol. It was removed in v14.  
  
Per bug #17501 from Vitaly Voronov. Backpatch to v14 where this was  
introduced.  
  
Discussion: https://www.postgresql.org/message-id/17501-128b1dd039362ae6@postgresql.org  

M src/backend/commands/copyfromparse.c

Doc: fix missing/bogus documentation of range_intersect_agg().

commit   : 9f2d1946d4b41a27cb5b62da7a5f070acc62cd4e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 29 May 2022 13:25:21 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 29 May 2022 13:25:21 -0400    

Click here for diff

The form taking anymultirange had not been documented.  This was  
fixed in HEAD in b21c4cf95, but that should have been back-patched  
to v14 since the function was added there.  Do so now.  
  
Also, the form taking anyrange was incorrectly documented as  
returning anymultirange, when it returns anyrange.  
  
Remove b21c4cf95 from the v15 release notes, since it no longer  
qualifies as new-in-v15.  
  
Noted by Shay Rojansky.  
  
Discussion: https://postgr.es/m/CADT4RqAktzP7t6SFf0Xqm9YhahzvsmxFbzXe-gFOd=+_CHm0JA@mail.gmail.com  

M doc/src/sgml/func.sgml

Handle NULL for short descriptions of custom GUC variables

commit   : fe441a0319405a52e773e8f3750e925ecc5d86eb    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 28 May 2022 12:12:46 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 28 May 2022 12:12:46 +0900    

Click here for diff

If a short description is specified as NULL in one of the various  
DefineCustomXXXVariable() functions available to external modules to  
define a custom parameter, SHOW ALL would crash.  This change teaches  
SHOW ALL to properly handle NULL short descriptions, as well as any code  
paths that manipulate it, to gain in flexibility.  Note that  
help_config.c was already able to do that, when describing a set of GUCs  
for postgres --describe-config.  
  
Author: Steve Chavez  
Reviewed by: Nathan Bossart, Andres Freund, Michael Paquier, Tom Lane  
Discussion: https://postgr.es/m/CAGRrpzY6hO-Kmykna_XvsTv8P2DshGiU6G3j8yGao4mk0CqjHA%40mail.gmail.com  
Backpatch-through: 10  

M src/backend/utils/misc/guc.c

Remove misguided SSL key file ownership check in libpq.

commit   : b4be4a082bde8b4f3caca6fa3127af005720f2d8    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 26 May 2022 14:14:05 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 26 May 2022 14:14:05 -0400    

Click here for diff

Commits a59c79564 et al. tried to sync libpq's SSL key file  
permissions checks with what we've used for years in the backend.  
We did not intend to create any new failure cases, but it turns out  
we did: restricting the key file's ownership breaks cases where the  
client is allowed to read a key file despite not having the identical  
UID.  In particular a client running as root used to be able to read  
someone else's key file; and having seen that I suspect that there are  
other, less-dubious use cases that this restriction breaks on some  
platforms.  
  
We don't really need an ownership check, since if we can read the key  
file despite its having restricted permissions, it must have the right  
ownership --- under normal conditions anyway, and the point of this  
patch is that any additional corner cases where that works should be  
deemed allowable, as they have been historically.  Hence, just drop  
the ownership check, and rearrange the permissions check to get rid  
of its faulty assumption that geteuid() can't be zero.  (Note that the  
comparable backend-side code doesn't have to cater for geteuid() == 0,  
since the server rejects that very early on.)  
  
This does have the end result that the permissions safety check used  
for a root user's private key file is weaker than that used for  
anyone else's.  While odd, root really ought to know what she's doing  
with file permissions, so I think this is acceptable.  
  
Per report from Yogendra Suralkar.  Like the previous patch,  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/MW3PR15MB3931DF96896DC36D21AFD47CA3D39@MW3PR15MB3931.namprd15.prod.outlook.com  

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

In CREATE FOREIGN TABLE syntax synopsis, fix partitioning stuff.

commit   : a5fc06bf31352fc57cb34ccbf2ca18214118ab9b    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 26 May 2022 12:54:57 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 26 May 2022 12:54:57 -0400    

Click here for diff

Foreign tables can be partitioned, but previous documentation commits  
left the syntax synopsis both incomplete and incorrect.  
  
Justin Pryzby and Amit Langote  
  
Discussion: http://postgr.es/m/20220521130922.GX19626@telsasoft.com  

M doc/src/sgml/ref/create_foreign_table.sgml

Show 'AS "?column?"' explicitly when it's important.

commit   : 6f7eec1193f8ddafb6d7ff495d3ce2eb01202a86    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 21 May 2022 14:45:58 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 21 May 2022 14:45:58 -0400    

Click here for diff

ruleutils.c was coded to suppress the AS label for a SELECT output  
expression if the column name is "?column?", which is the parser's  
fallback if it can't think of something better.  This is fine, and  
avoids ugly clutter, so long as (1) nothing further up in the parse  
tree relies on that column name or (2) the same fallback would be  
assigned when the rule or view definition is reloaded.  Unfortunately  
(2) is far from certain, both because ruleutils.c might print the  
expression in a different form from how it was originally written  
and because FigureColname's rules might change in future releases.  
So we shouldn't rely on that.  
  
Detecting exactly whether there is any outer-level use of a SELECT  
column name would be rather expensive.  This patch takes the simpler  
approach of just passing down a flag indicating whether there *could*  
be any outer use; for example, the output column names of a SubLink  
are not referenceable, and we also do not care about the names exposed  
by the right-hand side of a setop.  This is sufficient to suppress  
unwanted clutter in all but one case in the regression tests.  That  
seems like reasonable evidence that it won't be too much in users'  
faces, while still fixing the cases we need to fix.  
  
Per bug #17486 from Nicolas Lutic.  This issue is ancient, so  
back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/17486-1ad6fd786728b8af@postgresql.org  

M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/matview.out

doc: Mention pg_read_all_stats in description of track_activities

commit   : 7f798e89367878c0637d6152365b7452b052f3d5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 21 May 2022 19:05:54 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 21 May 2022 19:05:54 +0900    

Click here for diff

The description of track_activities mentioned that it is visible to  
superusers and that the information related to the current session can  
be seen, without telling about pg_read_all_stats.  Roles that are  
granted the privileges of pg_read_all_stats can also see this  
information, so mention it in the docs.  
  
Author: Ian Barwick  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/CAB8KJ=jhPyYFu-A5r-ZGP+Ax715mUKsMxAGcEQ9Cx_mBAmrPow@mail.gmail.com  
Backpatch-through: 10  

M doc/src/sgml/config.sgml

Fix DDL deparse of CREATE OPERATOR CLASS

commit   : 58b088a9b3c2ec19998a3822190afdd6af847efe    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 20 May 2022 18:52:55 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 20 May 2022 18:52:55 +0200    

Click here for diff

When an implicit operator family is created, it wasn't getting reported.  
Make it do so.  
  
This has always been missing.  Backpatch to 10.  
  
Author: Masahiko Sawada <sawada.mshk@gmail.com>  
Reported-by: Leslie LEMAIRE <leslie.lemaire@developpement-durable.gouv.fr>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Michael Paquiër <michael@paquier.xyz>  
Discussion: https://postgr.es/m/f74d69e151b22171e8829551b1159e77@developpement-durable.gouv.fr  

M src/backend/commands/opclasscmds.c
M src/backend/tcop/utility.c
M src/test/modules/test_ddl_deparse/expected/opfamily.out
M src/test/regress/expected/event_trigger.out
M src/test/regress/sql/event_trigger.sql

doc: Explain 'invalid' index state for CREATE INDEX CONCURRENTLY

commit   : aa783575294f6e3579b9c78a75d54a693f010213    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 20 May 2022 10:05:31 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 20 May 2022 10:05:31 +0200    

Click here for diff

It wasn't previously mentioned that the index is created as invalid,  
which is confusing to new users.  
  
Backpatch to 14 (only because of a conflict in 13).  
  
Author: Laurenz Albe <laurenz.albe@cybertec.at>  
Reported-by: Lauren Fliksteen <dancernerd32@gmail.com>  
Reviewed-by: Rajakavitha Kodhandapani <krajakavitha@gmail.com>  
Discussion: https://postgr.es/m/165290238488.670.7500177735573254738@wrigleys.postgresql.org  

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

Doc: clarify location of libpq's default service file on Windows.

commit   : 3a8d83cae35e887be0011fa6139c83423037bc67    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 19 May 2022 18:36:07 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 19 May 2022 18:36:07 -0400    

Click here for diff

The documentation didn't specify the name of the per-user service file  
on Windows, and extrapolating from the pattern used for other config  
files gave the wrong answer.  The fact that it isn't consistent with the  
others sure seems like a bug, but it's far too late to change that now;  
we'd just penalize people who worked it out in the past.  So, simply  
document the true state of affairs.  
  
In passing, fix some gratuitous differences between the discussions  
of the service file and the password file.  
  
Julien Rouhaud, per question from Dominique Devienne.  
  
Backpatch to all supported branches.  I (tgl) also chose to back-patch  
the part of commit ba356a397 that touched libpq.sgml's description of  
the service file --- in hindsight, I'm not sure why I didn't do so at  
the time, as it includes some fairly essential information.  
  
Discussion: https://postgr.es/m/CAFCRh-_mdLrh8eYVzhRzu4c8bAFEBn=rwoHOmFJcQOTsCy5nig@mail.gmail.com  

M doc/src/sgml/libpq.sgml

Repurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS

commit   : 8d9d1286acf9f209243cbcddc53cc4c875a90e20    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Thu, 19 May 2022 16:20:32 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Thu, 19 May 2022 16:20:32 +0200    

Click here for diff

This is a slight, convenient semantics change from what commit  
0f0cfb494004 ("Fix parallel operations that prevent oldest xmin from  
advancing") introduced that lets us simplify the coding in the one place  
where it is used.  
  
Backpatch to 13.  This is related to commit 6fea65508a1a ("Tighten  
ComputeXidHorizons' handling of walsenders") rewriting the code site  
where this is used, which has not yet been backpatched, but it may well  
be in the future.  
  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/202204191637.eldwa2exvguw@alvherre.pgsql  

M src/backend/storage/ipc/procarray.c
M src/include/storage/proc.h

Fix incorrect comments for Memoize struct

commit   : 3f712ea6dc40a0c9d5cf96907655343039601473    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 19 May 2022 17:14:56 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 19 May 2022 17:14:56 +1200    

Click here for diff

Reported-by: Peter Eisentraut  
Discussion: https://postgr.es/m/0635f5aa-4973-8dc2-4e4e-df9fd5778a65@enterprisedb.com  
Backpatch-through: 14, where Memoize was added  

M src/include/nodes/plannodes.h

Update xml_1.out and xml_2.out

commit   : e8b93c6e2810306887dc8477aab88ae08cf335f9    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 18 May 2022 23:19:53 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 18 May 2022 23:19:53 +0200    

Click here for diff

Commit 0fbf01120023 should have updated them but didn't.  

M src/test/regress/expected/xml_1.out
M src/test/regress/expected/xml_2.out

Check column list length in XMLTABLE/JSON_TABLE alias

commit   : 94edb85d253e5ae066481e4e369ad9e35dea41b5    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 18 May 2022 20:28:31 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 18 May 2022 20:28:31 +0200    

Click here for diff

We weren't checking the length of the column list in the alias clause of  
an XMLTABLE or JSON_TABLE function (a "tablefunc" RTE), and it was  
possible to make the server crash by passing an overly long one.  Fix it  
by throwing an error in that case, like the other places that deal with  
alias lists.  
  
In passing, modify the equivalent test used for join RTEs to look like  
the other ones, which was different for no apparent reason.  
  
This bug came in when XMLTABLE was born in version 10; backpatch to all  
stable versions.  
  
Reported-by: Wang Ke <krking@zju.edu.cn>  
Discussion: https://postgr.es/m/17480-1c9d73565bb28e90@postgresql.org  

M src/backend/parser/parse_clause.c
M src/backend/parser/parse_relation.c
M src/test/regress/expected/int2.out
M src/test/regress/expected/join.out
M src/test/regress/expected/with.out
M src/test/regress/expected/xml.out
M src/test/regress/sql/int2.sql
M src/test/regress/sql/join.sql
M src/test/regress/sql/with.sql
M src/test/regress/sql/xml.sql

Fix incorrect row estimates used for Memoize costing

commit   : 23c2b76a8322233ce0b2c135c10ad52d48a4a22b    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 16 May 2022 16:08:37 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 16 May 2022 16:08:37 +1200    

Click here for diff

In order to estimate the cache hit ratio of a Memoize node, one of the  
inputs we require is the estimated number of times the Memoize node will  
be rescanned.  The higher this number, the large the cache hit ratio is  
likely to become.  Unfortunately, the value being passed as the number of  
"calls" to the Memoize was incorrectly using the Nested Loop's  
outer_path->parent->rows instead of outer_path->rows.  This failed to  
account for the fact that the outer_path might be parameterized by some  
upper-level Nested Loop.  
  
This problem could lead to Memoize plans appearing more favorable than  
they might actually be.  It could also lead to extended executor startup  
times when work_mem values were large due to the planner setting overly  
large MemoizePath->est_entries resulting in the Memoize hash table being  
initially made much larger than might be required.  
  
Fix this simply by passing outer_path->rows rather than  
outer_path->parent->rows.  Also, adjust the expected regression test  
output for a plan change.  
  
Reported-by: Pavel Stehule  
Author: David Rowley  
Discussion: https://postgr.es/m/CAFj8pRAMp%3DQsMi6sPQJ4W3hczoFJRvyXHJV3AZAZaMyTVM312Q%40mail.gmail.com  
Backpatch-through: 14, where Memoize was introduced  

M src/backend/optimizer/path/joinpath.c
M src/test/regress/expected/join.out

Fix control file update done in restartpoints still running after promotion

commit   : 6dced63b411b920f7d0296337e4b3c8cba3e2e30    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 16 May 2022 11:26:22 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 16 May 2022 11:26:22 +0900    

Click here for diff

If a cluster is promoted (aka the control file shows a state different  
than DB_IN_ARCHIVE_RECOVERY) while CreateRestartPoint() is still  
processing, this function could miss an update of the control file for  
"checkPoint" and "checkPointCopy" but still do the recycling and/or  
removal of the past WAL segments, assuming that the to-be-updated LSN  
values should be used as reference points for the cleanup.  This causes  
a follow-up restart attempting crash recovery to fail with a PANIC on a  
missing checkpoint record if the end-of-recovery checkpoint triggered by  
the promotion did not complete while the cluster abruptly stopped or  
crashed before the completion of this checkpoint.  The PANIC would be  
caused by the redo LSN referred in the control file as located in a  
segment already gone, recycled by the previous restartpoint with  
"checkPoint" out-of-sync in the control file.  
  
This commit fixes the update of the control file during restartpoints so  
as "checkPoint" and "checkPointCopy" are updated even if the cluster has  
been promoted while a restartpoint is running, to be on par with the set  
of WAL segments actually recycled in the end of CreateRestartPoint().  
  
7863ee4 has fixed this problem already on master, but the release timing  
of the latest point versions did not let me enough time to study and fix  
that on all the stable branches.  
  
Reported-by: Fujii Masao, Rui Zhao  
Author: Kyotaro Horiguchi  
Reviewed-by: Nathan Bossart, Michael Paquier  
Discussion: https://postgr.es/m/20220316.102444.2193181487576617583.horikyota.ntt@gmail.com  
Backpatch-through: 10  

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

Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs.

commit   : ac51c9fba5a796ff434c0a7e05a5fd081690b21c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 12 May 2022 11:31:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 12 May 2022 11:31:46 -0400    

Click here for diff

This follows in the footsteps of commit 2591ee8ec by removing one more  
ill-advised shortcut from planning of GroupingFuncs.  It's true that  
we don't intend to execute the argument expression(s) at runtime, but  
we still have to process any Vars appearing within them, or we risk  
failure at setrefs.c time (or more fundamentally, in EXPLAIN trying  
to print such an expression).  Vars in upper plan nodes have to have  
referents in the next plan level, whether we ever execute 'em or not.  
  
Per bug #17479 from Michael J. Sullivan.  Back-patch to all supported  
branches.  
  
Richard Guo  
  
Discussion: https://postgr.es/m/17479-6260deceaf0ad304@postgresql.org  

M src/backend/optimizer/util/var.c
M src/test/regress/expected/groupingsets.out
M src/test/regress/sql/groupingsets.sql

Fix the logical replication timeout during large transactions.

commit   : d6da71fa8f28faa68823e163f318ffb38a7a9a54    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 11 May 2022 10:51:04 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 11 May 2022 10:51:04 +0530    

Click here for diff

The problem is that we don't send keep-alive messages for a long time  
while processing large transactions during logical replication where we  
don't send any data of such transactions. This can happen when the table  
modified in the transaction is not published or because all the changes  
got filtered. We do try to send the keep_alive if necessary at the end of  
the transaction (via WalSndWriteData()) but by that time the  
subscriber-side can timeout and exit.  
  
To fix this we try to send the keepalive message if required after  
processing certain threshold of changes.  
  
Reported-by: Fabrice Chapuis  
Author: Wang wei and Amit Kapila  
Reviewed By: Masahiko Sawada, Euler Taveira, Hou Zhijie, Hayato Kuroda  
Backpatch-through: 10  
Discussion: https://postgr.es/m/CAA5-nLARN7-3SLU_QUxfy510pmrYK6JJb=bk3hcgemAM_pAv+w@mail.gmail.com  

M src/backend/replication/logical/logical.c
M src/backend/replication/pgoutput/pgoutput.c
M src/backend/replication/walsender.c
M src/include/replication/logical.h

Improve setup of environment values for commands in MSVC's vcregress.pl

commit   : ca9e9b08e453523314a3b8e87d1894edb23b6e8d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 11 May 2022 10:22:29 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 11 May 2022 10:22:29 +0900    

Click here for diff

The current setup assumes that commands for lz4, zstd and gzip always  
exist by default if not enforced by a user's environment.  However,  
vcpkg, as one example, installs libraries but no binaries, so this  
default setup to assume that a command should always be present would  
cause failures.  This commit improves the detection of such external  
commands as follows:  
* If a ENV value is available, trust the environment/user and use it.  
* If a ENV value is not available, check its execution by looking in the  
current PATH, by launching a simple "$command --version" (that should be  
portable enough).  
** On execution failure, ignore ENV{command}.  
** On execution success, set ENV{command} = "$command".  
  
Note that this new rule applies to gzip, lz4 and zstd but not tar that  
we assume will always exist.  Those commands are set up in the  
environment only when using bincheck and taptest.  The CI includes all  
those commands and I have checked that their setup is correct there.  I  
have also tested this change in a MSVC environment where we have none of  
those commands.  
  
While on it, remove the references to lz4 from the documentation and  
vcregress.pl in ~v13.  --with-lz4 has been added in v14~ so there is no  
point to have this information in these older branches.  
  
Reported-by: Andrew Dunstan  
Reviewed-by: Andrew Dunstan  
Discussion: https://postgr.es/m/14402151-376b-a57a-6d0c-10ad12608e12@dunslane.net  
Backpatch-through: 10  

M src/tools/msvc/vcregress.pl

configure: don't probe for libldap_r if libldap is 2.5 or newer.

commit   : 12736e7dc326c404ae0f12ebdf5d1dbb954ec5f6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 10 May 2022 18:42:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 10 May 2022 18:42:02 -0400    

Click here for diff

In OpenLDAP 2.5 and later, libldap itself is always thread-safe and  
there's never a libldap_r.  Our existing coding dealt with that  
by assuming it wouldn't find libldap_r if libldap is thread-safe.  
But that rule fails to cope if there are multiple OpenLDAP versions  
visible, as is likely to be the case on macOS in particular.  We'd  
end up using shiny new libldap in the backend and a hoary libldap_r  
in libpq.  
  
Instead, once we've found libldap, check if it's >= 2.5 (by  
probing for a function introduced then) and don't bother looking  
for libldap_r if so.  While one can imagine library setups that  
this'd still give the wrong answer for, they seem unlikely to  
occur in practice.  
  
Per report from Peter Eisentraut.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/fedacd7c-2a38-25c9-e7ff-dea549d0e979@enterprisedb.com  

M configure
M configure.ac

Stamp 14.3.

commit   : 0e9cc8c0f3bc411de888a77318d8854ccba90e80    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 17:14:45 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 17:14:45 -0400    

Click here for diff

M configure
M configure.ac

Last-minute updates for release notes.

commit   : 0ae1d09575bbadd2e7a9ada5721a88c8ee0b6be3    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 14:29:53 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 14:29:53 -0400    

Click here for diff

Security: CVE-2022-1552  

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

Fix core dump in transformValuesClause when there are no columns.

commit   : ab2f783921734a96aa1baf4f3ea165292b62aecf    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 14:15:37 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 14:15:37 -0400    

Click here for diff

The parser code that transformed VALUES from row-oriented to  
column-oriented lists failed if there were zero columns.  
You can't write that straightforwardly (though probably you  
should be able to), but the case can be reached by expanding  
a "tab.*" reference to a zero-column table.  
  
Per bug #17477 from Wang Ke.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/17477-0af3c6ac6b0a6ae0@postgresql.org  

M src/backend/parser/analyze.c
M src/test/regress/expected/select.out
M src/test/regress/sql/select.sql

Revert "Disallow infinite endpoints in generate_series() for timestamps."

commit   : 9b5797ca54f5ad74740220c1be070eda4c21c82c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 11:02:36 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 May 2022 11:02:36 -0400    

Click here for diff

This reverts commit eafdf9de06e9b60168f5e47cedcfceecdc6d4b5f  
and its back-branch counterparts.  Corey Huinker pointed out that  
we'd discussed this exact change back in 2016 and rejected it,  
on the grounds that there's at least one usage pattern with LIMIT  
where an infinite endpoint can usefully be used.  Perhaps that  
argument needs to be re-litigated, but there's no time left before  
our back-branch releases.  To keep our options open, restore the  
status quo ante; if we do end up deciding to change things, waiting  
one more quarter won't hurt anything.  
  
Rather than just doing a straight revert, I added a new test case  
demonstrating the usage with LIMIT.  That'll at least remind us of  
the issue if we forget again.  
  
Discussion: https://postgr.es/m/3603504.1652068977@sss.pgh.pa.us  
Discussion: https://postgr.es/m/CADkLM=dzw0Pvdqp5yWKxMd+VmNkAMhG=4ku7GnCZxebWnzmz3Q@mail.gmail.com  

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

In REFRESH MATERIALIZED VIEW, set user ID before running user code.

commit   : 677a494789062ca88e0142a17bedd5415f6ab0aa    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 9 May 2022 08:35:08 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 May 2022 08:35:08 -0700    

Click here for diff

It intended to, but did not, achieve this.  Adopt the new standard of  
setting user ID just after locking the relation.  Back-patch to v10 (all  
supported versions).  
  
Reviewed by Simon Riggs.  Reported by Alvaro Herrera.  
  
Security: CVE-2022-1552  

M src/backend/commands/matview.c
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Make relation-enumerating operations be security-restricted operations.

commit   : ab49ce7c3414ac19e4afb386d7843ce2d2fb8bda    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 9 May 2022 08:35:08 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 May 2022 08:35:08 -0700    

Click here for diff

When a feature enumerates relations and runs functions associated with  
all found relations, the feature's user shall not need to trust every  
user having permission to create objects.  BRIN-specific functionality  
in autovacuum neglected to account for this, as did pg_amcheck and  
CLUSTER.  An attacker having permission to create non-temp objects in at  
least one schema could execute arbitrary SQL functions under the  
identity of the bootstrap superuser.  CREATE INDEX (not a  
relation-enumerating operation) and REINDEX protected themselves too  
late.  This change extends to the non-enumerating amcheck interface.  
Back-patch to v10 (all supported versions).  
  
Sergey Shinderuk, reviewed (in earlier versions) by Alexander Lakhin.  
Reported by Alexander Lakhin.  
  
Security: CVE-2022-1552  

M contrib/amcheck/expected/check_btree.out
M contrib/amcheck/sql/check_btree.sql
M contrib/amcheck/verify_nbtree.c
M src/backend/access/brin/brin.c
M src/backend/catalog/index.c
M src/backend/commands/cluster.c
M src/backend/commands/indexcmds.c
M src/backend/utils/init/miscinit.c
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Translation updates

commit   : e5b5a21356233739a552063fa70d4f5b245edb9a    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 9 May 2022 12:26:57 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 9 May 2022 12:26:57 +0200    

Click here for diff

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

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/pg_amcheck/po/de.po
M src/bin/pg_amcheck/po/fr.po
M src/bin/pg_amcheck/po/ru.po
M src/bin/pg_amcheck/po/sv.po
M src/bin/pg_basebackup/po/sv.po
M src/bin/pg_config/po/ru.po
M src/bin/pg_ctl/po/ru.po
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
M src/bin/pg_rewind/po/de.po
M src/bin/pg_rewind/po/fr.po
M src/bin/pg_rewind/po/ru.po
M src/bin/pg_rewind/po/sv.po
M src/bin/pg_waldump/po/ru.po
M src/bin/psql/po/de.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ru.po
M src/bin/psql/po/sv.po
M src/bin/scripts/po/ru.po
M src/interfaces/libpq/po/de.po
M src/interfaces/libpq/po/fr.po
M src/interfaces/libpq/po/ru.po
M src/interfaces/libpq/po/sv.po
M src/pl/plperl/po/ru.po

Disable 031_recovery_conflict.pl until after minor releases.

commit   : 55e5a5e0fa16dbe023ebdab35628fc73454c1dd4    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Sun, 8 May 2022 17:59:30 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Sun, 8 May 2022 17:59:30 -0700    

Click here for diff

f40d362a667 disabled part of 031_recovery_conflict.pl due to instability  
that's not trivial to fix in the back branches. That fixed most of the  
issues. But there was one more failure (on lapwing / REL_10_STABLE).  
  
That failure looks like it might be caused by a genuine problem. Disable the  
test until after the set of releases, to avoid packagers etc potentially  
having to fight with a test failure they can't do anything about.  
  
Discussion: https://postgr.es/m/3447060.1652032749@sss.pgh.pa.us  
Backpatch: 10-14  

M src/test/recovery/t/031_recovery_conflict.pl

Release notes for 14.3, 13.7, 12.11, 11.16, 10.21.

commit   : 2867d9b9697ffc34133ad988782ae0af88811c4d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 8 May 2022 12:36:38 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 8 May 2022 12:36:38 -0400    

Click here for diff

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

Fix back-patch of "Under has_wal_read_bug, skip .../001_wal.pl."

commit   : e599ea09698ae6ae45bfbb04fbe0bda4e3c04ab0    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 7 May 2022 09:12:56 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 7 May 2022 09:12:56 -0700    

Click here for diff

Per buildfarm members tadarida, snapper, and kittiwake.  Back-patch to  
v10 (all supported versions).  

M contrib/bloom/t/001_wal.pl

Under has_wal_read_bug, skip contrib/bloom/t/001_wal.pl.

commit   : aca4d561cb9f567537d12d9d8fbc45ae1528bc9d    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 7 May 2022 00:33:15 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 7 May 2022 00:33:15 -0700    

Click here for diff

Per buildfarm members snapper and kittiwake.  Back-patch to v10 (all  
supported versions).  
  
Discussion: https://postgr.es/m/20220116210241.GC756210@rfd.leadboat.com  

M contrib/bloom/t/001_wal.pl

Temporarily skip recovery deadlock test in back branches.

commit   : f40d362a667f6cf36f17d7565e4d7565fb7910f3    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 6 May 2022 09:01:08 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 6 May 2022 09:01:08 -0700    

Click here for diff

The recovery deadlock test has a timing issue that was fixed in 5136967f1eb in  
HEAD. Unfortunately the same fix doesn't quite work in the back branches: 1)  
adjust_conf() doesn't exist, which is easy enough to work around 2) a restart  
cleares the recovery conflict stats < 15.  
  
These issues can be worked around, but given the upcoming set of minor  
releases, skip the problematic test for now. The buildfarm doesn't show  
failures in other parts of 031_recovery_conflict.pl.  
  
Discussion: https://postgr.es/m/20220506155827.dfnaheq6ufylwrqf@alap3.anarazel.de  
Backpatch: 10-14  

M src/test/recovery/t/031_recovery_conflict.pl

Backpatch addition of pump_until() more completely.

commit   : 7fa95bb0ac8e98799a98a08006a11feefcb614a6    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 6 May 2022 08:38:19 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 6 May 2022 08:38:19 -0700    

Click here for diff

In a2ab9c06ea1 I just backpatched the introduction of pump_until(), without  
changing the existing local definitions (as 6da65a3f9a9). The necessary  
changes seemed more verbose than desirable. However, that leads to warnings,  
as I failed to realize...  
  
Backpatch to all versions containing pump_until() calls before  
f74496dd611 (there's none in 10).  
  
Discussion: https://postgr.es/m/2808491.1651802860@sss.pgh.pa.us  
Discussion: https://postgr.es/m/18b37361-b482-b9d8-f30d-6115cd5ce25c@enterprisedb.com  
Backpatch: 11-14  

M src/test/recovery/t/013_crash_restart.pl
M src/test/recovery/t/022_crash_temp_files.pl

First-draft release notes for 14.3.

commit   : 66ca1427a4963012fd565b922d0a67a8a8930d1f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 5 May 2022 18:27:31 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 5 May 2022 18:27:31 -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-14.sgml

Update time zone data files to tzdata release 2022a.

commit   : 77ee14ed96e94f16f4ff355637d563f29e893bc2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 5 May 2022 14:54:53 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 5 May 2022 14:54:53 -0400    

Click here for diff

DST law changes in Palestine.  Historical corrections for  
Chile and Ukraine.  

M src/timezone/data/tzdata.zi

Revert "Fix timing issue in deadlock recovery conflict test."

commit   : 6e2924b57793d662aa48bc88ac9e97d5d8eb90cf    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Wed, 4 May 2022 14:20:24 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Wed, 4 May 2022 14:20:24 -0700    

Click here for diff

This reverts commit 5136967f1eb194bf7598668f9893b997199935c1.  

M src/test/recovery/t/031_recovery_conflict.pl

Fix timing issue in deadlock recovery conflict test.

commit   : 5136967f1eb194bf7598668f9893b997199935c1    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Wed, 4 May 2022 12:50:38 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Wed, 4 May 2022 12:50:38 -0700    

Click here for diff

Per buildfarm members longfin and skink.  
  
Discussion: https://postgr.es/m/20220413002626.udl7lll7f3o7nre7@alap3.anarazel.de  
Backpatch: 10-  

M src/test/recovery/t/031_recovery_conflict.pl

Backpatch 031_recovery_conflict.pl.

commit   : f74496dd611ee4d345072b8eff7e7175fb5eb47d    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 2 May 2022 18:26:09 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Mon, 2 May 2022 18:26:09 -0700    

Click here for diff

The prior commit showed that the introduction of recovery conflict tests was a  
good idea. Without these tests it's hard to know that the fix didn't break  
something...  
  
031_recovery_conflict.pl was introduced in 9f8a050f68d and extended in  
21e184403bf.  
  
Discussion: https://postgr.es/m/20220413002626.udl7lll7f3o7nre7@alap3.anarazel.de  
Backpatch: 10-14  

A src/test/recovery/t/031_recovery_conflict.pl

Fix possibility of self-deadlock in ResolveRecoveryConflictWithBufferPin().

commit   : 9ab3b2bdbb5dc4ff857685eae5645d7c35839055    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 2 May 2022 18:25:00 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Mon, 2 May 2022 18:25:00 -0700    

Click here for diff

The tests added in 9f8a050f68d failed nearly reliably on FreeBSD in CI, and  
occasionally on the buildfarm. That turns out to be caused not by a bug in the  
test, but by a longstanding bug in recovery conflict handling.  
  
The standby timeout handler, used by ResolveRecoveryConflictWithBufferPin(),  
executed SendRecoveryConflictWithBufferPin() inside a signal handler. A bad  
idea, because the deadlock timeout handler (or a spurious latch set) could  
have interrupted ProcWaitForSignal(). If unlucky that could cause a  
self-deadlock on ProcArrayLock, if the deadlock check is in  
SendRecoveryConflictWithBufferPin()->CancelDBBackends().  
  
To fix, set a flag in StandbyTimeoutHandler(), and check the flag in  
ResolveRecoveryConflictWithBufferPin().  
  
Subsequently the recovery conflict tests will be backpatched.  
  
Discussion: https://postgr.es/m/20220413002626.udl7lll7f3o7nre7@alap3.anarazel.de  
Backpatch: 10-  

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

Backpatch addition of wait_for_log(), pump_until().

commit   : 5ab8e8014801dd6bc05809e7ba994c013e9ee86b    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 2 May 2022 18:09:42 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Mon, 2 May 2022 18:09:42 -0700    

Click here for diff

These were originally introduced in a2ab9c06ea1 and a2ab9c06ea1, as they are  
needed by a about-to-be-backpatched test.  
  
Discussion: https://postgr.es/m/20220413002626.udl7lll7f3o7nre7@alap3.anarazel.de  
Backpatch: 10-14  

M src/test/perl/PostgreSQL/Test/Utils.pm
M src/test/perl/PostgresNode.pm
M src/test/perl/TestLib.pm

Fix typo in comment.

commit   : 24c58f7a2a5c762f35ffe8aaa00fa08caeb881fe    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Mon, 2 May 2022 16:45:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Mon, 2 May 2022 16:45:02 +0900    

Click here for diff

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

Disable asynchronous execution if using gating Result nodes.

commit   : ebb79024152348227250404fd06c35c56cbc672e    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 28 Apr 2022 15:15:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 28 Apr 2022 15:15:02 +0900    

Click here for diff

mark_async_capable_plan(), which is called from create_append_plan() to  
determine whether subplans are async-capable, failed to take into  
account that the given subplan created from a given subpath might  
include a gating Result node if the subpath is a SubqueryScanPath or  
ForeignPath, causing a segmentation fault there when the subplan created  
from a SubqueryScanPath includes the Result node, or causing  
ExecAsyncRequest() to throw an error about an unrecognized node type  
when the subplan created from a ForeignPath includes the Result node,  
because in the latter case the Result node was unintentionally  
considered as async-capable, but we don't currently support executing  
Result nodes asynchronously.  Fix by modifying mark_async_capable_plan()  
to disable asynchronous execution in such cases.  Also, adjust code in  
the ProjectionPath case in mark_async_capable_plan(), for consistency  
with other cases, and adjust/improve comments there.  
  
is_async_capable_path() added in commit 27e1f1456, which was rewritten  
to mark_async_capable_plan() in a later commit, has the same issue,  
causing the error at execution mentioned above, so back-patch to v14  
where the aforesaid commit went in.  
  
Per report from Justin Pryzby.  
  
Etsuro Fujita, reviewed by Zhihong Yu and Justin Pryzby.  
  
Discussion: https://postgr.es/m/20220408124338.GK24419%40telsasoft.com  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M src/backend/optimizer/plan/createplan.c

Inhibit mingw CRT's auto-globbing of command line arguments

commit   : 71f394667c824257ddf6e8359cba746e621a2d16    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 25 Apr 2022 15:02:13 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 25 Apr 2022 15:02:13 -0400    

Click here for diff

For some reason by default the mingw C Runtime takes it upon itself to  
expand program arguments that look like shell globbing characters. That  
has caused much scratching of heads and mis-attribution of the causes of  
some TAP test failures, so stop doing that.  
  
This removes an inconsistency with Windows binaries built with MSVC,  
which have no such behaviour.  
  
Per suggestion from Noah Misch.  
  
Backpatch to all live branches.  
  
Discussion: https://postgr.es/m/20220423025927.GA1274057@rfd.leadboat.com  

M src/common/exec.c

Remove some recently-added pg_dump test cases.

commit   : 75a006beef6c502a16bc4e1c0dc4d67d2cd5de9c    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 25 Apr 2022 09:14:19 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Mon, 25 Apr 2022 09:14:19 -0400    

Click here for diff

Commit d2d35479796c3510e249d6fc72adbd5df918efbf included a pretty  
extensive set of test cases, and some of them don't work on all  
of our Windows machines. This happens because IPC::Run expands  
its arguments as shell globs on a few machines, but doesn't on most  
of the buildfarm. It might be good to fix that problem systematically  
somehow, but in the meantime, there are enough test cases for this  
commit that it seems OK to just remove the ones that are failing.  
  
Discussion: http://postgr.es/m/3a190754-b2b0-d02b-dcfd-4ec1610ffbcb@dunslane.net  
Discussion: http://postgr.es/m/CA+TgmoYRGUcFBy6VgN0+Pn4f6Wv=2H0HZLuPHqSy6VC8Ba7vdg@mail.gmail.com  

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

Fix incautious CTE matching in rewriteSearchAndCycle().

commit   : dff6c77faf0c6bcf1d407dc3ffef9e169166c714    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 23 Apr 2022 12:16:12 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 23 Apr 2022 12:16:12 -0400    

Click here for diff

This function looks for a reference to the recursive WITH CTE,  
but it checked only the CTE name not ctelevelsup, so that it could  
seize on a lower CTE that happened to have the same name.  This  
would result in planner failures later, either weird errors such as  
"could not find attribute 2 in subquery targetlist", or crashes  
or assertion failures.  The code also merely Assert'ed that it found  
a matching entry, which is not guaranteed at all by the parser.  
  
Per bugs #17320 and #17318 from Zhiyong Wu.  
Thanks to Kyotaro Horiguchi for investigation.  
  
Discussion: https://postgr.es/m/17320-70e37868182512ab@postgresql.org  
Discussion: https://postgr.es/m/17318-2eb65a3a611d2368@postgresql.org  

M src/backend/rewrite/rewriteSearchCycle.c
M src/test/regress/expected/with.out
M src/test/regress/sql/with.sql

Remove inadequate assertion check in CTE inlining.

commit   : da22ef388a2469c3d7d11a8c97a3c41cc0016f4a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 21 Apr 2022 17:58:52 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 21 Apr 2022 17:58:52 -0400    

Click here for diff

inline_cte() expected to find exactly as many references to the  
target CTE as its cterefcount indicates.  While that should be  
accurate for the tree as emitted by the parser, there are some  
optimizations that occur upstream of here that could falsify it,  
notably removal of unused subquery output expressions.  
  
Trying to make the accounting 100% accurate seems expensive and  
doomed to future breakage.  It's not really worth it, because  
all this code is protecting is downstream assumptions that every  
referenced CTE has a plan.  Let's convert those assertions to  
regular test-and-elog just in case there's some actual problem,  
and then drop the failing assertion.  
  
Per report from Tomas Vondra (thanks also to Richard Guo for  
analysis).  Back-patch to v12 where the faulty code came in.  
  
Discussion: https://postgr.es/m/29196a1e-ed47-c7ca-9be2-b1c636816183@enterprisedb.com  

M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/plan/subselect.c
M src/include/nodes/pathnodes.h
M src/test/regress/expected/with.out
M src/test/regress/sql/with.sql

Support new perl module namespace in stable branches

commit   : b235d41d9646c531864ecc680fd9ec5da9217051    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 21 Apr 2022 07:39:25 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 21 Apr 2022 07:39:25 -0400    

Click here for diff

Commit b3b4d8e68a moved our perl test modules to a better namespace  
structure, but this has made life hard for people wishing to backpatch  
improvements in the TAP tests. Here we alleviate much of that difficulty  
by implementing the new module names on top of the old modules, mostly  
by using a little perl typeglob aliasing magic, so that we don't have a  
dual maintenance burden. This should work both for the case where a new  
test is backpatched and the case where a fix to an existing test that  
uses the new namespace is backpatched.  
  
Reviewed by Michael Paquier  
  
Per complaint from Andres Freund  
  
Discussion: https://postgr.es/m/20220418141530.nfxtkohefvwnzncl@alap3.anarazel.de  
  
Applied to branches 10 through 14  

A src/test/perl/PostgreSQL/Test/Cluster.pm
A src/test/perl/PostgreSQL/Test/Utils.pm
M src/test/perl/PostgresNode.pm
M src/test/perl/TestLib.pm

postgres_fdw: Disable batch insert when BEFORE ROW INSERT triggers exist.

commit   : 89d349b0a0239504325e5f63755f3bc1e1742478    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 21 Apr 2022 15:30:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 21 Apr 2022 15:30:02 +0900    

Click here for diff

Previously, we allowed this, but such triggers might query the table to  
insert into and act differently if the tuples that have already been  
processed and prepared for insertion are not there, so disable it in  
such cases.  
  
Back-patch to v14 where batch insert was added.  
  
Discussion: https://postgr.es/m/CAPmGK16_uPqsmgK0-LpLSUk54_BoK13bPrhxhfjSoSTVz414hA%40mail.gmail.com  

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

Fix CLUSTER tuplesorts on abbreviated expressions.

commit   : e4521841a1ee6917633bd28b34496c1627588731    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 20 Apr 2022 17:17:41 -0700    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 20 Apr 2022 17:17:41 -0700    

Click here for diff

CLUSTER sort won't use the datum1 SortTuple field when clustering  
against an index whose leading key is an expression.  This makes it  
unsafe to use the abbreviated keys optimization, which was missed by the  
logic that sets up SortSupport state.  Affected tuplesorts output tuples  
in a completely bogus order as a result (the wrong SortSupport based  
comparator was used for the leading attribute).  
  
This issue is similar to the bug fixed on the master branch by recent  
commit cc58eecc5d.  But it's a far older issue, that dates back to the  
introduction of the abbreviated keys optimization by commit 4ea51cdfe8.  
  
Backpatch to all supported versions.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Author: Thomas Munro <thomas.munro@gmail.com>  
Discussion: https://postgr.es/m/CA+hUKG+bA+bmwD36_oDxAoLrCwZjVtST2fqe=b4=qZcmU7u89A@mail.gmail.com  
Backpatch: 10-  

M src/backend/utils/sort/tuplesort.c
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql

Disallow infinite endpoints in generate_series() for timestamps.

commit   : e346329470081f5919e83b1acb2d0f2442c1fc3d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 20 Apr 2022 18:08:15 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 20 Apr 2022 18:08:15 -0400    

Click here for diff

Such cases will lead to infinite loops, so they're of no practical  
value.  The numeric variant of generate_series() already threw error  
for this, so borrow its message wording.  
  
Per report from Richard Wesley.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/91B44E7B-68D5-448F-95C8-B4B3B0F5DEAF@duckdblabs.com  

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

Allow db.schema.table patterns, but complain about random garbage.

commit   : 4a66300acd8c788998615ffc077b7d7be57afceb    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 20 Apr 2022 11:02:35 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 20 Apr 2022 11:02:35 -0400    

Click here for diff

psql, pg_dump, and pg_amcheck share code to process object name  
patterns like 'foo*.bar*' to match all tables with names starting in  
'bar' that are in schemas starting with 'foo'. Before v14, any number  
of extra name parts were silently ignored, so a command line '\d  
foo.bar.baz.bletch.quux' was interpreted as '\d bletch.quux'.  In v14,  
as a result of commit 2c8726c4b0a496608919d1f78a5abc8c9b6e0868, we  
instead treated this as a request for table quux in a schema named  
'foo.bar.baz.bletch'. That caused problems for people like Justin  
Pryzby who were accustomed to copying strings of the form  
db.schema.table from messages generated by PostgreSQL itself and using  
them as arguments to \d.  
  
Accordingly, revise things so that if an object name pattern contains  
more parts than we're expecting, we throw an error, unless there's  
exactly one extra part and it matches the current database name.  
That way, thisdb.myschema.mytable is accepted as meaning just  
myschema.mytable, but otherdb.myschema.mytable is an error, and so  
is some.random.garbage.myschema.mytable.  
  
Mark Dilger, per report from Justin Pryzby and discussion among  
various people.  
  
Discussion: https://www.postgresql.org/message-id/20211013165426.GD27491%40telsasoft.com  

M doc/src/sgml/ref/psql-ref.sgml
M src/bin/pg_amcheck/pg_amcheck.c
M src/bin/pg_amcheck/t/002_nonesuch.pl
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/psql/describe.c
M src/fe_utils/string_utils.c
M src/include/fe_utils/string_utils.h
M src/test/regress/expected/psql.out
M src/test/regress/sql/psql.sql

Stabilize streaming tests in test_decoding.

commit   : 7891a0d5d9fa53a0ba55ff70d77db54c7e50998f    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 20 Apr 2022 08:48:25 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 20 Apr 2022 08:48:25 +0530    

Click here for diff

We have some streaming tests that rely on the size of changes which can  
fail if there are additional changes like invalidation messages by  
background activity like auto analyze. Avoid such failures by increasing  
autovacuum_naptime to a reasonably high value (1d).  
  
Author: Dilip Kumar  
Backpatch-through: 14  
Discussion: https://postgr.es/m/1958043.1650129119@sss.pgh.pa.us  

M contrib/test_decoding/logical.conf

Fix breakage in AlterFunction().

commit   : 08a9e7a8c7917233926802aaea94a5529a747a50    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 19 Apr 2022 23:03:59 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 19 Apr 2022 23:03:59 -0400    

Click here for diff

An ALTER FUNCTION command that tried to update both the function's  
proparallel property and its proconfig list failed to do the former,  
because it stored the new proparallel value into a tuple that was  
no longer the interesting one.  Carelessness in 7aea8e4f2.  
  
(I did not bother with a regression test, because the only likely  
future breakage would be for someone to ignore the comment I added  
and add some other field update after the heap_modify_tuple step.  
A test using existing function properties could not catch that.)  
  
Per report from Bryn Llewellyn.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/8AC9A37F-99BD-446F-A2F7-B89AD0022774@yugabyte.com  

M src/backend/commands/functioncmds.c

Fix extract epoch from interval calculation

commit   : 7a8d8219ccbf0963f2171ea23e1616ee6a7823ba    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 19 Apr 2022 20:38:53 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 19 Apr 2022 20:38:53 +0200    

Click here for diff

The new numeric code for extract epoch from interval accidentally  
truncated the DAYS_PER_YEAR value to an integer, leading to results  
that mismatched the floating-point interval_part calculations.  
  
The commit a2da77cdb4661826482ebf2ddba1f953bc74afe4 that introduced  
this actually contains the regression test change that this reverts.  
I suppose this was missed at the time.  
  
Reported-by: Joseph Koshakow <koshy44@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/CAAvxfHd5n%3D13NYA2q_tUq%3D3%3DSuWU-CufmTf-Ozj%3DfrEgt7pXwQ%40mail.gmail.com  

M src/backend/utils/adt/timestamp.c
M src/test/regress/expected/interval.out

Fix the check to limit sync workers.

commit   : c9dea58e270236a8d256a686f71f6bab960f0b80    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Tue, 19 Apr 2022 08:54:37 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Tue, 19 Apr 2022 08:54:37 +0530    

Click here for diff

We don't allow to invoke more sync workers once we have reached the sync  
worker limit per subscription. But the check to enforce this also doesn't  
allow to launch an apply worker if it gets restarted.  
  
This code was introduced by commit de43897122 but we caught the problem  
only with the test added by recent commit c91f71b9dc which started failing  
occasionally in the buildfarm.  
  
As per buildfarm.  
Diagnosed-by: Amit Kapila, Masahiko Sawada, Tomas Vondra  
Author: Amit Kapila  
Backpatch-through: 10  
Discussion: https://postgr.es/m/CAH2L28vddB_NFdRVpuyRBJEBWjz4BSyTB=_ektNRH8NJ1jf95g@mail.gmail.com  
	    https://postgr.es/m/f90d2b03-4462-ce95-a524-d91464e797c8@enterprisedb.com  

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

Avoid invalid array reference in transformAlterTableStmt().

commit   : e805735a83f7bb5bfe773b9690f96a52ba2b84b2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 18 Apr 2022 12:16:45 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 18 Apr 2022 12:16:45 -0400    

Click here for diff

Don't try to look at the attidentity field of system attributes,  
because they're not there in the TupleDescAttr array.  Sometimes  
this is harmless because we accidentally pick up a zero, but  
otherwise we'll report "no owned sequence found" from an attempt  
to alter a system attribute.  (It seems possible that a SIGSEGV  
could occur, too, though I've not seen it in testing.)  
  
It's not in this function's charter to complain that you can't  
alter a system column, so instead just hard-wire an assumption  
that system attributes aren't identities.  I didn't bother with  
a regression test because the appearance of the bug is very  
erratic.  
  
Per bug #17465 from Roman Zharkov.  Back-patch to all supported  
branches.  (There's not actually a live bug before v12, because  
before that get_attidentity() did the right thing anyway.  
But for consistency I changed the test in the older branches too.)  
  
Discussion: https://postgr.es/m/17465-f2a554a6cb5740d3@postgresql.org  

M src/backend/parser/parse_utilcmd.c

Fix race in TAP test 002_archiving.pl when restoring history file

commit   : 8bcf90c7a67caf3009d7e529e15266cfd833c573    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 18 Apr 2022 11:40:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 18 Apr 2022 11:40:14 +0900    

Click here for diff

This test, introduced in df86e52, uses a second standby to check that  
it is able to remove correctly RECOVERYHISTORY and RECOVERYXLOG at the  
end of recovery.  This standby uses the archives of the primary to  
restore its contents, with some of the archive's contents coming from  
the first standby previously promoted.  In slow environments, it was  
possible that the test did not check what it should, as the history file  
generated by the promotion of the first standby may not be stored yet on  
the archives the second standby feeds on.  So, it could be possible that  
the second standby selects an incorrect timeline, without restoring a  
history file at all.  
  
This commits adds a wait phase to make sure that the history file  
required by the second standby is archived before this cluster is  
created.  This relies on poll_query_until() with pg_stat_file() and an  
absolute path, something not supported in REL_10_STABLE.  
  
While on it, this adds a new test to check that the history file has  
been restored by looking at the logs of the second standby.  This  
ensures that a RECOVERYHISTORY, whose removal needs to be checked,  
is created in the first place.  This should make the test more robust.  
  
This test has been introduced by df86e52, but it came in light as an  
effect of the bug fixed by acf1dd42, where the extra restore_command  
calls made the test much slower.  
  
Reported-by: Andres Freund  
Discussion: https://postgr.es/m/YlT23IvsXkGuLzFi@paquier.xyz  
Backpatch-through: 11  

M src/test/recovery/t/002_archiving.pl

Add a temp-install prerequisite to src/interfaces/ecpg "checktcp".

commit   : acd0eb635e859127c456c2166ed9455a1fdac60e    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 16 Apr 2022 17:43:54 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 16 Apr 2022 17:43:54 -0700    

Click here for diff

The target failed, tested $PATH binaries, or tested a stale temporary  
installation.  Commit c66b438db62748000700c9b90b585e756dd54141 missed  
this.  Back-patch to v10 (all supported versions).  

M src/interfaces/ecpg/Makefile

Rethink the delay-checkpoint-end mechanism in the back-branches.

commit   : 10520f4346876aad4941797c2255a21bdac74739    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 14 Apr 2022 11:10:07 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 14 Apr 2022 11:10:07 -0400    

Click here for diff

The back-patch of commit bbace5697df12398e87ffd9879171c39d27f5b33 had  
the unfortunate effect of changing the layout of PGPROC in the  
back-branches, which could break extensions. This happened because it  
changed the delayChkpt from type bool to type int. So, change it back,  
and add a new bool delayChkptEnd field instead. The new field should  
fall within what used to be padding space within the struct, and so  
hopefully won't cause any extensions to break.  
  
Per report from Markus Wanner and discussion with Tom Lane and others.  
  
Patch originally by me, somewhat revised by Markus Wanner per a  
suggestion from Michael Paquier. A very similar patch was developed  
by Kyotaro Horiguchi, but I failed to see the email in which that was  
posted before writing one of my own.  
  
Discussion: http://postgr.es/m/CA+Tgmoao-kUD9c5nG5sub3F7tbo39+cdr8jKaOVEs_1aBWcJ3Q@mail.gmail.com  
Discussion: http://postgr.es/m/20220406.164521.17171257901083417.horikyota.ntt@gmail.com  

M src/backend/access/transam/multixact.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xloginsert.c
M src/backend/catalog/storage.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/ipc/procarray.c
M src/include/storage/proc.h
M src/include/storage/procarray.h

pageinspect: Fix handling of all-zero pages

commit   : df6bbe73b86cda28472b9ecc61ac2deff5b2837b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 14 Apr 2022 15:09:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 14 Apr 2022 15:09:26 +0900    

Click here for diff

Getting from get_raw_page() an all-zero page is considered as a valid  
case by the buffer manager and it can happen for example when finding a  
corrupted page with zero_damaged_pages enabled (using zero_damaged_pages  
to look at corrupted pages happens), or after a crash when a relation  
file is extended before any WAL for its new data is generated (before a  
vacuum or autovacuum job comes in to do some cleanup).  
  
However, all the functions of pageinspect, as of the index AMs (except  
hash that has its own idea of new pages), heap, the FSM or the page  
header have never worked with all-zero pages, causing various crashes  
when going through the page internals.  
  
This commit changes all the pageinspect functions to be compliant with  
all-zero pages, where the choice is made to return NULL or no rows for  
SRFs when finding a new page.  get_raw_page() still works the same way,  
returning a batch of zeros in the bytea of the page retrieved.  A hard  
error could be used but NULL, while more invasive, is useful when  
scanning relation files in full to get a batch of results for a single  
relation in one query.  Tests are added for all the code paths  
impacted.  
  
Reported-by: Daria Lepikhova  
Author: Michael Paquier  
Discussion: https://postgr.es/m/561e187b-3549-c8d5-03f5-525c14e65bd0@postgrespro.ru  
Backpatch-through: 10  

M contrib/pageinspect/brinfuncs.c
M contrib/pageinspect/btreefuncs.c
M contrib/pageinspect/expected/brin.out
M contrib/pageinspect/expected/btree.out
M contrib/pageinspect/expected/gin.out
M contrib/pageinspect/expected/gist.out
M contrib/pageinspect/expected/hash.out
M contrib/pageinspect/expected/page.out
M contrib/pageinspect/fsmfuncs.c
M contrib/pageinspect/ginfuncs.c
M contrib/pageinspect/gistfuncs.c
M contrib/pageinspect/rawpage.c
M contrib/pageinspect/sql/brin.sql
M contrib/pageinspect/sql/btree.sql
M contrib/pageinspect/sql/gin.sql
M contrib/pageinspect/sql/gist.sql
M contrib/pageinspect/sql/hash.sql
M contrib/pageinspect/sql/page.sql

Prevent access to no-longer-pinned buffer in heapam_tuple_lock().

commit   : c590e514a90ddc9237a3438efb05be074d43452b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 13 Apr 2022 13:35:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 13 Apr 2022 13:35:02 -0400    

Click here for diff

heap_fetch() used to have a "keep_buf" parameter that told it to return  
ownership of the buffer pin to the caller after finding that the  
requested tuple TID exists but is invisible to the specified snapshot.  
This was thoughtlessly removed in commit 5db6df0c0, which broke  
heapam_tuple_lock() (formerly EvalPlanQualFetch) because that function  
needs to do more accesses to the tuple even if it's invisible.  The net  
effect is that we would continue to touch the page for a microsecond or  
two after releasing pin on the buffer.  Usually no harm would result;  
but if a different session decided to defragment the page concurrently,  
we could see garbage data and mistakenly conclude that there's no newer  
tuple version to chain up to.  (It's hard to say whether this has  
happened in the field.  The bug was actually found thanks to a later  
change that allowed valgrind to detect accesses to non-pinned buffers.)  
  
The most reasonable way to fix this is to reintroduce keep_buf,  
although I made it behave slightly differently: buffer ownership  
is passed back only if there is a valid tuple at the requested TID.  
In HEAD, we can just add the parameter back to heap_fetch().  
To avoid an API break in the back branches, introduce an additional  
function heap_fetch_extended() in those branches.  
  
In HEAD there is an additional, less obvious API change: tuple->t_data  
will be set to NULL in all cases where buffer ownership is not returned,  
in particular when the tuple exists but fails the time qual (and  
!keep_buf).  This is to defend against any other callers attempting to  
access non-pinned buffers.  We concluded that making that change in back  
branches would be more likely to introduce problems than cure any.  
  
In passing, remove a comment about heap_fetch that was obsoleted by  
9a8ee1dc6.  
  
Per bug #17462 from Daniil Anisimov.  Back-patch to v12 where the bug  
was introduced.  
  
Discussion: https://postgr.es/m/17462-9c98a0f00df9bd36@postgresql.org  

M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/include/access/heapam.h

Docs: wording improvement for compute_query_id = regress

commit   : ea669b8088380cc0bc7c48ab8581ea5fba1c5b4f    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 13 Apr 2022 21:29:35 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 13 Apr 2022 21:29:35 +1200    

Click here for diff

It's more accurate to say that the query identifier is not shown when  
compute_query_id = regress rather than to say it is hidden.  
  
This change (ebf6c5249) appeared in v14, so it makes sense to backpatch  
this small adjustment to keep the documents consistent between v14 and  
master.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/20220411020336.GB26620@telsasoft.com  
Backpatch-through: 14, where compute_query_id = regress was added  

M doc/src/sgml/config.sgml

Docs: adjust pg_upgrade syntax to mark -B as optional

commit   : e286be5d05311ec060a4359fcbc53eb98b914d42    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 13 Apr 2022 11:19:34 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 13 Apr 2022 11:19:34 +1200    

Click here for diff

This was made optional in 959f6d6a1.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/20220411020336.GB26620@telsasoft.com  
Backpatch-through: 13, where -B was made optional  

M doc/src/sgml/ref/pgupgrade.sgml

Doc: tweak textsearch.sgml for SEO purposes.

commit   : 8320a34d38e220d99eb24fbd09536b12711fb102    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 12 Apr 2022 18:21:04 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 12 Apr 2022 18:21:04 -0400    

Click here for diff

Google seems to like to return textsearch.html for queries about  
GIN and GiST indexes, even though it's not a primary reference  
for either.  It seems likely that that's because those keywords  
appear in the page title.  Since "GIN and GiST Index Types" is  
not a very apposite title for this material anyway, rename the  
section in hopes of stopping that.  
  
Also provide explicit links to the GIN and GiST chapters, to help  
anyone who finds their way to this page regardless.  
  
Per gripe from Jan Piotrowski.  Back-patch to supported branches.  
(Unfortunately Google is likely to continue returning the 9.1  
version of this page, but improving that situation is a matter  
for the www team.)  
  
Discussion: https://postgr.es/m/164978902252.1276550.9330175733459697101@wrigleys.postgresql.org  

M doc/src/sgml/textsearch.sgml

Docs: avoid confusing use of the word "synchronized"

commit   : 3a95dfe4025f48fb57262ce590ba397a80a1a7b6    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 13 Apr 2022 09:16:33 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 13 Apr 2022 09:16:33 +1200    

Click here for diff

It's misleading to call the data directory the "synchronized data  
directory" when discussing a crash scenario when using pg_rewind's  
--no-sync option.  Here we just remove the word "synchronized" to avoid  
any possible confusion.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/20220411020336.GB26620@telsasoft.com  
Backpatch-through: 12, where --no-sync was added  

M doc/src/sgml/ref/pg_rewind.sgml

Suppress "variable 'pagesaving' set but not used" warning.

commit   : a65747b1c787cc85dc59f088543f3d333f310eee    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 6 Apr 2022 17:03:35 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 6 Apr 2022 17:03:35 -0400    

Click here for diff

With asserts disabled, late-model clang notices that this variable  
is incremented but never otherwise read.  
  
Discussion: https://postgr.es/m/3171401.1649275153@sss.pgh.pa.us  

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

Remove race condition in 022_crash_temp_files.pl test.

commit   : 9a7229948c70945ca6ef0b36adfe61b74f4fdaf5    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 5 Apr 2022 20:44:01 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 5 Apr 2022 20:44:01 -0400    

Click here for diff

It's possible for the query that "waits for restart" to complete a  
successful iteration before the postmaster has noticed its SIGKILL'd  
child and begun the restart cycle.  (This is a bit hard to believe  
perhaps, but it's been seen at least twice in the buildfarm, mainly  
on ancient platforms that likely have quirky schedulers.)  
  
To provide a more secure interlock, wait for the other session  
we're using to report that it's been forcibly shut down.  
  
Patch by me, based on a suggestion from Andres Freund.  
Back-patch to v14 where this test case came in.  
  
Discussion: https://postgr.es/m/1801850.1649047827@sss.pgh.pa.us  

M src/test/recovery/t/022_crash_temp_files.pl

Update some tests in 013_crash_restart.pl.

commit   : 8803df4ea960117f42f38ee82a74e954e72e0339    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 4 Apr 2022 22:10:07 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 4 Apr 2022 22:10:07 -0400    

Click here for diff

The expected backend message after SIGQUIT changed in commit  
7e784d1dc, but we missed updating this test case.  Also, experience  
shows that we might sometimes get "could not send data to server"  
instead of either of the libpq messages the test is looking for.  
  
Per report from Mark Dilger.  Back-patch to v14 where the  
backend message changed.  
  
Discussion: https://postgr.es/m/17BD82D7-49AC-40C9-8204-E7ADD30321A0@enterprisedb.com  

M src/test/recovery/t/013_crash_restart.pl

Doc: Remove MultiXact wraparound section link.

commit   : 32558a8bc3c0035e7b738e47b00ff6b4bfc96da8    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 2 Apr 2022 09:49:06 -0700    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 2 Apr 2022 09:49:06 -0700    

Click here for diff

Remove circular "25.1.5.1. Multixacts And Wraparound" link that  
references the section that the link itself appears in.  An explanation  
of MultiXactId age appears only a few sentences before the link, so  
there's no question that the link is superfluous at best.  
  
Oversight in commit d5409295.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Backpatch: 14-  

M doc/src/sgml/maintenance.sgml

Remove obsolete comment

commit   : d480ae069e6c13dcb719b8c6aaf7a5540196a1b3    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 2 Apr 2022 07:27:26 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 2 Apr 2022 07:27:26 +0200    

Click here for diff

accidentally left behind by 4cb658af70027c3544fb843d77b2e84028762747  

M src/include/utils/rel.h

libpq: Fix pkg-config without OpenSSL

commit   : 7a27892750e966998381e6c34cdfec30ac5e3906    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 1 Apr 2022 17:12:56 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 1 Apr 2022 17:12:56 +0200    

Click here for diff

Do not add OpenSSL dependencies to libpq pkg-config file if OpenSSL is  
not enabled.  Oversight in beff361bc1edc24ee5f8b2073a1e5e4c92ea66eb.  
  
Author: Fabrice Fontaine <fontaine.fabrice@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/20220331163759.32665-1-fontaine.fabrice%40gmail.com  

M src/interfaces/libpq/Makefile

Fix postgres_fdw to check shippability of sort clauses properly.

commit   : 9f9489aa2eefeaf4a6517b0b14f8f22938c2e3f3    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 31 Mar 2022 14:29:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 31 Mar 2022 14:29:24 -0400    

Click here for diff

postgres_fdw would push ORDER BY clauses to the remote side without  
verifying that the sort operator is safe to ship.  Moreover, it failed  
to print a suitable USING clause if the sort operator isn't default  
for the sort expression's type.  The net result of this is that the  
remote sort might not have anywhere near the semantics we expect,  
which'd be disastrous for locally-performed merge joins in particular.  
  
We addressed similar issues in the context of ORDER BY within an  
aggregate function call in commit 7012b132d, but failed to notice  
that query-level ORDER BY was broken.  Thus, much of the necessary  
logic already existed, but it requires refactoring to be usable  
in both cases.  
  
Back-patch to all supported branches.  In HEAD only, remove the  
core code's copy of find_em_expr_for_rel, which is no longer used  
and really should never have been pushed into equivclass.c in the  
first place.  
  
Ronan Dunklau, per report from David Rowley;  
reviews by David Rowley, Ranier Vilela, and myself  
  
Discussion: https://postgr.es/m/CAApHDvr4OeC2DBVY--zVP83-K=bYrTD7F8SZDhN4g+pj2f2S-A@mail.gmail.com  

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

Add missing newline in one libpq error message.

commit   : 402279afe48d26c6657bec55256bd91d924e4086    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 31 Mar 2022 11:24:26 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 31 Mar 2022 11:24:26 -0400    

Click here for diff

Oversight in commit a59c79564.  Back-patch, as that was.  
Noted by Peter Eisentraut.  
  
Discussion: https://postgr.es/m/7f85ef6d-250b-f5ec-9867-89f0b16d019f@enterprisedb.com  

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

doc: Fix typo in ANALYZE documentation

commit   : c5479178441ea68341afa2d2bf41738dabbefc71    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 31 Mar 2022 12:03:33 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 31 Mar 2022 12:03:33 +0200    

Click here for diff

Commit 61fa6ca79b3 accidentally wrote constrast instead of contrast.  
  
Backpatch-through: 10  
Discussion: https://postgr.es/m/88903179-5ce2-3d4d-af43-7830372bdcb6@enterprisedb.com  

M doc/src/sgml/ref/analyze.sgml

Fix typo in comment.

commit   : 637afee327f4690afc3f16fd76123cd4b7af1d95    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 30 Mar 2022 19:00:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 30 Mar 2022 19:00:02 +0900    

Click here for diff

M src/backend/commands/copyfrom.c

Revert "Fix replay of create database records on standby"

commit   : adc943b4e1fe26c3085e81c65f5b185c7ff0611a    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 29 Mar 2022 15:36:21 +0200    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 29 Mar 2022 15:36:21 +0200    

Click here for diff

This reverts commit 49d9cfc68bf4.  The approach taken by this patch has  
problems, so we'll come up with a radically different fix.  
  
Discussion: https://postgr.es/m/CA+TgmoYcUPL+WOJL2ZzhH=zmrhj0iOQ=iCFM0SuYqBbqZEamEg@mail.gmail.com  

M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogutils.c
M src/backend/commands/dbcommands.c
M src/backend/commands/tablespace.c
M src/include/access/xlogutils.h
M src/tools/pgindent/typedefs.list

Document autoanalyze limitations for partitioned tables

commit   : 6b262f353ef710704a9388d32924b8c10c7e6eaa    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 28 Mar 2022 14:27:36 +0200    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 28 Mar 2022 14:27:36 +0200    

Click here for diff

When dealing with partitioned tables, counters for partitioned tables  
are not updated when modifying child tables. This means autoanalyze may  
not update optimizer statistics for the parent relations, which can  
result in poor plans for some queries.  
  
It's worth documenting this limitation, so that people are aware of it  
and can take steps to mitigate it (e.g. by setting up a script executing  
ANALYZE regularly).  
  
Backpatch to v10. Older branches are affected too, of couse, but we no  
longer maintain those.  
  
Author: Justin Pryzby  
Reviewed-by: Zhihong Yu, Tomas Vondra  
Backpatch-through: 10  
Discussion: https://postgr.es/m/20210913035409.GA10647%40telsasoft.com  

M doc/src/sgml/maintenance.sgml
M doc/src/sgml/ref/analyze.sgml

Fix NULL input behaviour of pg_stat_get_replication_slot().

commit   : c1a0d7d1c4b77d978fe93edc0889589148cbad23    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Sun, 27 Mar 2022 21:39:43 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Sun, 27 Mar 2022 21:39:43 -0700    

Click here for diff

pg_stat_get_replication_slot() accidentally was marked as non-strict, crashing  
when called with NULL input. As it's already released, introduce an explicit  
NULL check in 14, fix the catalog in HEAD.  
  
Bumps catversion in HEAD.  
  
Discussion: https://postgr.es/m/20220326212432.s5n2maw6kugnpyxw@alap3.anarazel.de  
Backpatch: 14-, where replication slot stats were introduced  

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

waldump: fix use-after-free in search_directory().

commit   : 6839aa7a6921d133a51e6162b9ee710ab712293d    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 16:38:43 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 16:38:43 -0700    

Click here for diff

After closedir() dirent->d_name is not valid anymore. As there alerady are a  
few places relying on the limited lifetime of pg_waldump, do so here as well,  
and just pg_strdup() the string.  
  
The bug was introduced in fc49e24fa69a.  
  
Found by UBSan, run locally.  
  
Backpatch: 11-, like fc49e24fa69 itself.  

M src/bin/pg_waldump/pg_waldump.c

Fix breakage of get_ps_display() in the PS_USE_NONE case.

commit   : 3f7a59c59b4873a3b39838401d590f9d030a3500    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 27 Mar 2022 12:57:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 27 Mar 2022 12:57:46 -0400    

Click here for diff

Commit 8c6d30f21 caused this function to fail to set *displen  
in the PS_USE_NONE code path.  If the variable's previous value  
had been negative, that'd lead to a memory clobber at some call  
sites.  We'd managed not to notice due to very thin test coverage  
of such configurations, but this appears to explain buildfarm member  
lorikeet's recent struggles.  
  
Credit to Andrew Dunstan for spotting the problem.  Back-patch  
to v13 where the bug was introduced.  
  
Discussion: https://postgr.es/m/136102.1648320427@sss.pgh.pa.us  

M src/backend/utils/misc/ps_status.c

pageinspect: Add more sanity checks to prevent out-of-bound reads

commit   : 27d384441851fe28ced962665632f2d1b914f11b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sun, 27 Mar 2022 17:53:51 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sun, 27 Mar 2022 17:53:51 +0900    

Click here for diff

A couple of code paths use the special area on the page passed by the  
function caller, expecting to find some data in it.  However, feeding  
an incorrect page can lead to out-of-bound reads when trying to access  
the page special area (like a heap page that has no special area,  
leading PageGetSpecialPointer() to grab a pointer outside the allocated  
page).  
  
The functions used for hash and btree indexes have some protection  
already against that, while some other functions using a relation OID  
as argument would make sure that the access method involved is correct,  
but functions taking in input a raw page without knowing the relation  
the page is attached to would run into problems.  
  
This commit improves the set of checks used in the code paths of BRIN,  
btree (including one check if a leaf page is found with a non-zero  
level), GIN and GiST to verify that the page given in input has a  
special area size that fits with each access method, which is done  
though PageGetSpecialSize(), becore calling PageGetSpecialPointer().  
  
The scope of the checks done is limited to work with pages that one  
would pass after getting a block with get_raw_page(), as it is possible  
to craft byteas that could bypass existing code paths.  Having too many  
checks would also impact the usability of pageinspect, as the existing  
code is very useful to look at the content details in a corrupted page,  
so the focus is really to avoid out-of-bound reads as this is never a  
good thing even with functions whose execution is limited to  
superusers.  
  
The safest approach could be to rework the functions so as these fetch a  
block using a relation OID and a block number, but there are also cases  
where using a raw page is useful.  
  
Tests are added to cover all the code paths that needed such checks, and  
an error message for hash indexes is reworded to fit better with what  
this commit adds.  
  
Reported-By: Alexander Lakhin  
Author: Julien Rouhaud, Michael Paquier  
Discussion: https://postgr.es/m/16527-ef7606186f0610a1@postgresql.org  
Discussion: https://postgr.es/m/561e187b-3549-c8d5-03f5-525c14e65bd0@postgrespro.ru  
Backpatch-through: 10  

M contrib/pageinspect/brinfuncs.c
M contrib/pageinspect/btreefuncs.c
M contrib/pageinspect/expected/brin.out
M contrib/pageinspect/expected/btree.out
M contrib/pageinspect/expected/gin.out
M contrib/pageinspect/expected/gist.out
M contrib/pageinspect/expected/hash.out
M contrib/pageinspect/ginfuncs.c
M contrib/pageinspect/gistfuncs.c
M contrib/pageinspect/hashfuncs.c
M contrib/pageinspect/sql/brin.sql
M contrib/pageinspect/sql/btree.sql
M contrib/pageinspect/sql/gin.sql
M contrib/pageinspect/sql/gist.sql
M contrib/pageinspect/sql/hash.sql

Suppress compiler warning in relptr_store().

commit   : 0144c9c7e73dc75f9cd5297c7c380d55927beb75    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 26 Mar 2022 14:29:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 26 Mar 2022 14:29:29 -0400    

Click here for diff

clang 13 with -Wextra warns that "performing pointer subtraction with  
a null pointer has undefined behavior" in the places where freepage.c  
tries to set a relptr variable to constant NULL.  This appears to be  
a compiler bug, but it's unlikely to get fixed instantly.  Fortunately,  
we can work around it by introducing an inline support function, which  
seems like a good change anyway because it removes the macro's existing  
double-evaluation hazard.  
  
Backpatch to v10 where this code was introduced.  
  
Patch by me, based on an idea of Andres Freund's.  
  
Discussion: https://postgr.es/m/48826.1648310694@sss.pgh.pa.us  

M src/include/utils/relptr.h

Harden TAP tests that intentionally corrupt page checksums.

commit   : 579cef5faf11b63a312691e086415b37d7888b5a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Mar 2022 14:23:26 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Mar 2022 14:23:26 -0400    

Click here for diff

The previous method for doing that was to write zeroes into a  
predetermined set of page locations.  However, there's a roughly  
1-in-64K chance that the existing checksum will match by chance,  
and yesterday several buildfarm animals started to reproducibly  
see that, resulting in test failures because no checksum mismatch  
was reported.  
  
Since the checksum includes the page LSN, test success depends on  
the length of the installation's WAL history, which is affected by  
(at least) the initial catalog contents, the set of locales installed  
on the system, and the length of the pathname of the test directory.  
Sooner or later we were going to hit a chance match, and today is  
that day.  
  
Harden these tests by specifically inverting the checksum field and  
leaving all else alone, thereby guaranteeing that the checksum is  
incorrect.  
  
In passing, fix places that were using seek() to set up for syswrite(),  
a combination that the Perl docs very explicitly warn against.  We've  
probably escaped problems because no regular buffered I/O is done on  
these filehandles; but if it ever breaks, we wouldn't deserve or get  
much sympathy.  
  
Although we've only seen problems in HEAD, now that we recognize the  
environmental dependencies it seems like it might be just a matter  
of time until someone manages to hit this in back-branch testing.  
Hence, back-patch to v11 where we started doing this kind of test.  
  
Discussion: https://postgr.es/m/3192026.1648185780@sss.pgh.pa.us  

M contrib/amcheck/t/001_verify_heapam.pl
M src/bin/pg_amcheck/t/003_check.pl
M src/bin/pg_amcheck/t/004_verify_heapam.pl
M src/bin/pg_basebackup/t/010_pg_basebackup.pl
M src/bin/pg_checksums/t/002_actions.pl
M src/test/perl/PostgresNode.pm

Fix replay of create database records on standby

commit   : ffd28516e69983d44616451b808b1c9d4f3c2b60    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 25 Mar 2022 13:16:21 +0100    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 25 Mar 2022 13:16:21 +0100    

Click here for diff

Crash recovery on standby may encounter missing directories when  
replaying create database WAL records.  Prior to this patch, the standby  
would fail to recover in such a case.  However, the directories could be  
legitimately missing.  Consider a sequence of WAL records as follows:  
  
    CREATE DATABASE  
    DROP DATABASE  
    DROP TABLESPACE  
  
If, after replaying the last WAL record and removing the tablespace  
directory, the standby crashes and has to replay the create database  
record again, the crash recovery must be able to move on.  
  
This patch adds a mechanism similar to invalid-page tracking, to keep a  
tally of missing directories during crash recovery.  If all the missing  
directory references are matched with corresponding drop records at the  
end of crash recovery, the standby can safely continue following the  
primary.  
  
Backpatch to 13, at least for now.  The bug is older, but fixing it in  
older branches requires more careful study of the interactions with  
commit e6d8069522c8, which appeared in 13.  
  
A new TAP test file is added to verify the condition.  However, because  
it depends on commit d6d317dbf615, it can only be added to branch  
master.  I (Álvaro) manually verified that the code behaves as expected  
in branch 14.  It's a bit nervous-making to leave the code uncovered by  
tests in older branches, but leaving the bug unfixed is even worse.  
Also, the main reason this fix took so long is precisely that we  
couldn't agree on a good strategy to approach testing for the bug, so  
perhaps this is the best we can do.  
  
Diagnosed-by: Paul Guo <paulguo@gmail.com>  
Author: Paul Guo <paulguo@gmail.com>  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Author: Asim R Praveen <apraveen@pivotal.io>  
Discussion: https://postgr.es/m/CAEET0ZGx9AvioViLf7nbR_8tH9-=27DN5xWJ2P9-ROH16e4JUA@mail.gmail.com  

M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogutils.c
M src/backend/commands/dbcommands.c
M src/backend/commands/tablespace.c
M src/include/access/xlogutils.h
M src/tools/pgindent/typedefs.list

Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.

commit   : bbace5697df12398e87ffd9879171c39d27f5b33    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 24 Mar 2022 14:32:24 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 24 Mar 2022 14:32:24 -0400    

Click here for diff

If TRUNCATE causes some buffers to be invalidated and thus the  
checkpoint does not flush them, TRUNCATE must also ensure that the  
corresponding files are truncated on disk. Otherwise, a replay  
from the checkpoint might find that the buffers exist but have  
the wrong contents, which may cause replay to fail.  
  
Report by Teja Mupparti. Patch by Kyotaro Horiguchi, per a design  
suggestion from Heikki Linnakangas, with some changes to the  
comments by me. Review of this and a prior patch that approached  
the issue differently by Heikki Linnakangas, Andres Freund, Álvaro  
Herrera, Masahiko Sawada, and Tom Lane.  
  
Discussion: http://postgr.es/m/BYAPR06MB6373BF50B469CA393C614257ABF00@BYAPR06MB6373.namprd06.prod.outlook.com  

M src/backend/access/transam/multixact.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xloginsert.c
M src/backend/catalog/storage.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/ipc/procarray.c
M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h
M src/include/storage/procarray.h

Don't try to translate NULL in GetConfigOptionByNum().

commit   : 81045e1e1c3370fb7e57c8841b0a7b6aab31831b    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 13:05:59 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 13:05:59 -0700    

Click here for diff

Noticed via -fsanitize=undefined. Introduced when a few columns in  
GetConfigOptionByNum() / pg_settings started to be translated in 72be8c29a /  
PG 12.  
  
Backpatch to all affected branches, for the same reasons as 46ab07ffda9.  
  
Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de  
Backpatch: 12-  

M src/backend/utils/misc/guc.c

Don't call fwrite() with len == 0 when writing out relcache init file.

commit   : 89a94c24aadd8f40084339ea3d16e2e14fa9f629    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 13:05:25 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 13:05:25 -0700    

Click here for diff

Noticed via -fsanitize=undefined.  
  
Backpatch to all branches, for the same reasons as 46ab07ffda9.  
  
Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de  
Backpatch: 10-  

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

configure: check for dlsym instead of dlopen.

commit   : e52e9bd57f33da1c4a915e24d0a24759a23cb5fd    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 12:43:14 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Wed, 23 Mar 2022 12:43:14 -0700    

Click here for diff

When building with sanitizers the sanitizer library provides dlopen, but not  
dlsym(), making configure think that -ldl isn't needed. Just checking for  
dlsym() ought to suffice, hard to see dlsym() being provided without dlopen()  
also being provided.  
  
Backpatch to all branches, for the same reasons as 46ab07ffda9.  
  
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de  
Backpatch: 10-  

M configure
M configure.ac

pg_upgrade: Upgrade an Assert to a real 'if' test

commit   : 9814c708c657a9f21fd1a36b5dc0f49ca2d01499    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 23 Mar 2022 19:23:51 +0100    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 23 Mar 2022 19:23:51 +0100    

Click here for diff

It seems possible for the condition being tested to be true in  
production, and nobody would never know (except when some data  
eventually becomes corrupt?).  
  
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>  
Discussion: https://postgr.es/m//202109040001.zky3wgv2qeqg@alvherre.pgsql  

M src/bin/pg_rewind/parsexlog.c

Fix "missing continuation record" after standby promotion

commit   : caaeb88ff7ae84a3bbf0ee497a4bda18cf9261cd    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 23 Mar 2022 18:22:10 +0100    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 23 Mar 2022 18:22:10 +0100    

Click here for diff

Invalidate abortedRecPtr and missingContrecPtr after a missing  
continuation record is successfully skipped on a standby. This fixes a  
PANIC caused when a recently promoted standby attempts to write an  
OVERWRITE_RECORD with an LSN of the previously read aborted record.  
  
Backpatch to 10 (all stable versions).  
  
Author: Sami Imseih <simseih@amazon.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>  
Discussion: https://postgr.es/m/44D259DE-7542-49C4-8A52-2AB01534DCA9@amazon.com  

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

Try to stabilize vacuum test.

commit   : cd3a5055f952ca2811e63d86558dd3e1f4147f62    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 23 Mar 2022 14:31:18 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 23 Mar 2022 14:31:18 +1300    

Click here for diff

As commits b700f96c and 3414099c did for the reloptions test, make  
sure VACUUM can always truncate the table as expected.  
  
Back-patch to 12, where vacuum_truncate arrived.  
  
Discussion: https://postgr.es/m/CAD21AoCNoWjYkdEtr%2BVDoF9v__V905AedKZ9iF%3DArgCtrbxZqw%40mail.gmail.com  

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

Add missing dependency of pg_dumpall to WIN32RES.

commit   : 2d608c9607584a30ff718d2c9f211ef3c692a315    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Tue, 22 Mar 2022 08:22:02 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Tue, 22 Mar 2022 08:22:02 -0700    

Click here for diff

When cross-building to windows, or building with mingw on windows, the build  
could fail with  
  x86_64-w64-mingw32-gcc: error: win32ver.o: No such file or director  
because pg_dumpall didn't depend on WIN32RES, but it's recipe references  
it. The build nevertheless succeeded most of the time, due to  
pg_dump/pg_restore having the required dependency, causing win32ver.o to be  
built.  
  
Reported-By: Thomas Munro <thomas.munro@gmail.com>  
Discussion: https://postgr.es/m/CA+hUKGJeekpUPWW6yCVdf9=oBAcCp86RrBivo4Y4cwazAzGPng@mail.gmail.com  
Backpatch: 10-, omission present on all live branches  

M src/bin/pg_dump/Makefile

Fix failures in SSL tests caused by out-of-tree keys and certificates

commit   : fdb1be4962ca080c007308ddb7163bf76310bb7c    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 22 Mar 2022 13:21:33 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 22 Mar 2022 13:21:33 +0900    

Click here for diff

This issue is environment-sensitive, where the SSL tests could fail in  
various way by feeding on defaults provided by sslcert, sslkey,  
sslrootkey, sslrootcert, sslcrl and sslcrldir coming from a local setup,  
as of ~/.postgresql/ by default.  Horiguchi-san has reported two  
failures, but more advanced testing from me (aka inclusion of garbage  
SSL configuration in ~/.postgresql/ for all the configuration  
parameters) has showed dozens of failures that can be triggered in the  
whole test suite.  
  
History has showed that we are not good when it comes to address such  
issues, fixing them locally like in dd87799, and such problems keep  
appearing.  This commit strengthens the entire test suite to put an end  
to this set of problems by embedding invalid default values in all the  
connection strings used in the tests.  The invalid values are prefixed  
in each connection string, relying on the follow-up values passed in the  
connection string to enforce any invalid value previously set.  Note  
that two tests related to CRLs are required to fail with certain pre-set  
configurations, but we can rely on enforcing an empty value instead  
after the invalid set of values.  
  
Reported-by: Kyotaro Horiguchi  
Reviewed-by: Andrew Dunstan, Daniel Gustafsson, Kyotaro Horiguchi  
Discussion: https://postgr.es/m/20220316.163658.1122740600489097632.horikyota.ntt@gmail.com  
backpatch-through: 10  

M src/test/ssl/t/001_ssltests.pl

Fix assorted missing logic for GroupingFunc nodes.

commit   : 48b6035f0f72c312aaa22733cb88f5290f473ac0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 21 Mar 2022 17:44:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 21 Mar 2022 17:44:29 -0400    

Click here for diff

The planner needs to treat GroupingFunc like Aggref for many purposes,  
in particular with respect to processing of the argument expressions,  
which are not to be evaluated at runtime.  A few places hadn't gotten  
that memo, notably including subselect.c's processing of outer-level  
aggregates.  This resulted in assertion failures or wrong plans for  
cases in which a GROUPING() construct references an outer aggregation  
level.  
  
Also fix missing special cases for GroupingFunc in cost_qual_eval  
(resulting in wrong cost estimates for GROUPING(), although it's  
not clear that that would affect plan shapes in practice) and in  
ruleutils.c (resulting in excess parentheses in pretty-print mode).  
  
Per bug #17088 from Yaoguang Chen.  Back-patch to all supported  
branches.  
  
Richard Guo, Tom Lane  
  
Discussion: https://postgr.es/m/17088-e33882b387de7f5c@postgresql.org  

M src/backend/nodes/nodeFuncs.c
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/plan/subselect.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/groupingsets.out
M src/test/regress/sql/groupingsets.sql

Fix risk of deadlock failure while dropping a partitioned index.

commit   : 05ccf974cd75d3a95869c4ce4b96fdbc10e663cf    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 21 Mar 2022 12:22:13 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 21 Mar 2022 12:22:13 -0400    

Click here for diff

DROP INDEX needs to lock the index's table before the index itself,  
else it will deadlock against ordinary queries that acquire the  
relation locks in that order.  This is correctly mechanized for  
plain indexes by RangeVarCallbackForDropRelation; but in the case of  
a partitioned index, we neglected to lock the child tables in advance  
of locking the child indexes.  We can fix that by traversing the  
inheritance tree and acquiring the needed locks in RemoveRelations,  
after we have acquired our locks on the parent partitioned table and  
index.  
  
While at it, do some refactoring to eliminate confusion between  
the actual and expected relkind in RangeVarCallbackForDropRelation.  
We can save a couple of syscache lookups too, by having that function  
pass back info that RemoveRelations will need.  
  
Back-patch to v11 where partitioned indexes were added.  
  
Jimmy Yih, Gaurab Dey, Tom Lane  
  
Discussion: https://postgr.es/m/BYAPR05MB645402330042E17D91A70C12BD5F9@BYAPR05MB6454.namprd05.prod.outlook.com  

M src/backend/commands/tablecmds.c
A src/test/isolation/expected/partition-drop-index-locking.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/partition-drop-index-locking.spec

Doc: fix our example systemd script.

commit   : a1efc8f8c820a1e94eb26f7c93e4c6f6e9b277d6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 20 Mar 2022 12:39:40 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 20 Mar 2022 12:39:40 -0400    

Click here for diff

The example used "TimeoutSec=0", but systemd's documented way to get  
the desired effect is "TimeoutSec=infinity".  
  
Discussion: https://postgr.es/m/164770078557.670.5467111518383664377@wrigleys.postgresql.org  

M doc/src/sgml/runtime.sgml

doc: Mention SET TABLESPACE clause for ALTER MATERIALIZED VIEW

commit   : c422e8da7ec26f7f43c05b6020fd80fd24d3c8a2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 19 Mar 2022 16:37:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 19 Mar 2022 16:37:39 +0900    

Click here for diff

This command flavor is supported, but there was nothing in the  
documentation about it.  
  
Author: Yugo Nagata  
Discussion: https://postgr.es/m/20220316133337.5dc9740abfa24c25ec9f67f5@sraoss.co.jp  
Backpatch-through: 10  

M doc/src/sgml/ref/alter_materialized_view.sgml

Fix incorrect xmlschema output for types timetz and timestamptz.

commit   : ae8ec7febac1b414681c16022e6c655a62a2540a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 18 Mar 2022 16:01:42 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 18 Mar 2022 16:01:42 -0400    

Click here for diff

The output of table_to_xmlschema() and allied functions includes  
a regex describing valid values for these types ... but the regex  
was itself invalid, as it failed to escape a literal "+" sign.  
  
Report and fix by Renan Soares Lopes.  Back-patch to all  
supported branches.  
  
Discussion: https://postgr.es/m/7f6fabaa-3f8f-49ab-89ca-59fbfe633105@me.com  

M src/backend/utils/adt/xml.c
M src/test/regress/expected/xmlmap.out
M src/test/regress/expected/xmlmap_1.out
M src/test/regress/sql/xmlmap.sql

Revert applying column aliases to the output of whole-row Vars.

commit   : 1d072bd2030af0f2eaa522449028ff160f71ebf8    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 17 Mar 2022 18:18:05 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 17 Mar 2022 18:18:05 -0400    

Click here for diff

In commit bf7ca1587, I had the bright idea that we could make the  
result of a whole-row Var (that is, foo.*) track any column aliases  
that had been applied to the FROM entry the Var refers to.  However,  
that's not terribly logically consistent, because now the output of  
the Var is no longer of the named composite type that the Var claims  
to emit.  bf7ca1587 tried to handle that by changing the output  
tuple values to be labeled with a blessed RECORD type, but that's  
really pretty disastrous: we can wind up storing such tuples onto  
disk, whereupon they're not readable by other sessions.  
  
The only practical fix I can see is to give up on what bf7ca1587  
tried to do, and say that the column names of tuples produced by  
a whole-row Var are always those of the underlying named composite  
type, query aliases or no.  While this introduces some inconsistencies,  
it removes others, so it's not that awful in the abstract.  What *is*  
kind of awful is to make such a behavioral change in a back-patched  
bug fix.  But corrupt data is worse, so back-patched it will be.  
  
(A workaround available to anyone who's unhappy about this is to  
introduce an extra level of sub-SELECT, so that the whole-row Var is  
referring to the sub-SELECT's output and not to a named table type.  
Then the Var is of type RECORD to begin with and there's no issue.)  
  
Per report from Miles Delahunty.  The faulty commit dates to 9.5,  
so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/2950001.1638729947@sss.pgh.pa.us  

M src/backend/executor/execExpr.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execTuples.c
M src/test/regress/expected/rowtypes.out
M src/test/regress/sql/rowtypes.sql

Fix publish_as_relid with multiple publications

commit   : 677a1dc0ca0f33220ba1ea8067181a72b4aff536    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Wed, 16 Mar 2022 16:42:47 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Wed, 16 Mar 2022 16:42:47 +0100    

Click here for diff

Commit 83fd4532a7 allowed publishing of changes via ancestors, for  
publications defined with publish_via_partition_root. But the way  
the ancestor was determined in get_rel_sync_entry() was incorrect,  
simply updating the same variable. So with multiple publications,  
replicating different ancestors, the outcome depended on the order  
of publications in the list - the value from the last loop was used,  
even if it wasn't the top-most ancestor.  
  
This is a probably rare situation, as in most cases publications do  
not overlap, so each partition has exactly one candidate ancestor  
to replicate as and there's no ambiguity.  
  
Fixed by tracking the "ancestor level" for each publication, and  
picking the top-most ancestor. Adds a test case, verifying the  
correct ancestor is used for publishing the changes and that this  
does not depend on order of publications in the list.  
  
Older releases have another bug in this loop - once all actions are  
replicated, the loop is terminated, on the assumption that inspecting  
additional publications is unecessary. But that misses the fact that  
those additional applications may replicate different ancestors.  
  
Fixed by removal of this break condition. We might still terminate the  
loop in some cases (e.g. when replicating all actions and the ancestor  
is the partition root).  
  
Backpatch to 13, where publish_via_partition_root was introduced.  
  
Initial report and fix by me, test added by Hou zj. Reviews and  
improvements by Amit Kapila.  
  
Author: Tomas Vondra, Hou zj, Amit Kapila  
Reviewed-by: Amit Kapila, Hou zj  
Discussion: https://postgr.es/m/d26d24dd-2fab-3c48-0162-2b7f84a9c893%40enterprisedb.com  

M src/backend/replication/pgoutput/pgoutput.c
M src/test/subscription/t/013_partition.pl

Fix default signature length for gist_ltree_ops

commit   : 7d30f59da714ab25f82f4bc24f30cba1022d8cb9    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 16 Mar 2022 11:41:18 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 16 Mar 2022 11:41:18 +0300    

Click here for diff

911e702077 implemented operator class parameters including the signature length  
in ltree.  Previously, the signature length for gist_ltree_ops was 8.  Because  
of bug 911e702077 the default signature length for gist_ltree_ops became 28 for  
ltree 1.1 (where options method is NOT provided) and 8 for ltree 1.2 (where  
options method is provided).  This commit changes the default signature length  
for ltree 1.1 to 8.  
  
Existing gist_ltree_ops indexes might be corrupted in various scenarios.  
Thus, we have to recommend reindexing all the gist_ltree_ops indexes after  
the upgrade.  
  
Reported-by: Victor Yegorov  
Reviewed-by: Tomas Vondra, Tom Lane, Andres Freund, Nikita Glukhov  
Reviewed-by: Andrew Dunstan  
Author: Tomas Vondra, Alexander Korotkov  
Discussion: https://postgr.es/m/17406-71e02820ae79bb40%40postgresql.org  
Discussion: https://postgr.es/m/d80e0a55-6c3e-5b26-53e3-3c4f973f737c%40enterprisedb.com  

M contrib/ltree/ltree.h
M contrib/ltree/ltree_gist.c

Fix race between DROP TABLESPACE and checkpointing.

commit   : 26e00793980996fada8d61181d45070ce9fee600    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 17:20:24 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 17:20:24 +1300    

Click here for diff

Commands like ALTER TABLE SET TABLESPACE may leave files for the next  
checkpoint to clean up.  If such files are not removed by the time DROP  
TABLESPACE is called, we request a checkpoint so that they are deleted.  
However, there is presently a window before checkpoint start where new  
unlink requests won't be scheduled until the following checkpoint.  This  
means that the checkpoint forced by DROP TABLESPACE might not remove the  
files we expect it to remove, and the following ERROR will be emitted:  
  
	ERROR:  tablespace "mytblspc" is not empty  
  
To fix, add a call to AbsorbSyncRequests() just before advancing the  
unlink cycle counter.  This ensures that any unlink requests forwarded  
prior to checkpoint start (i.e., when ckpt_started is incremented) will  
be processed by the current checkpoint.  Since AbsorbSyncRequests()  
performs memory allocations, it cannot be called within a critical  
section, so we also need to move SyncPreCheckpoint() to before  
CreateCheckPoint()'s critical section.  
  
This is an old bug, so back-patch to all supported versions.  
  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/20220215235845.GA2665318%40nathanxps13  

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

pageinspect: Fix memory context allocation of page in brin_revmap_data()

commit   : dc5b3bdae31690e11839079e15b74ba0df0aa167    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Mar 2022 12:29:47 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Mar 2022 12:29:47 +0900    

Click here for diff

This caused the function to fail, as the aligned copy of the raw page  
given by the function caller was not saved in the correct memory  
context, which needs to be multi_call_memory_ctx in this case.  
  
Issue introduced by 076f4d9.  
  
Per buildfarm members sifika, mylodon and longfin.  I have reproduced  
that locally with macos.  
  
Discussion: https://postgr.es/m/YjFPOtfCW6yLXUeM@paquier.xyz  
Backpatch-through: 10  

M contrib/pageinspect/brinfuncs.c

Fix documentation typo in commit 5e6368b4.

commit   : ea70f6945029b622ea28d53c7a32354d1d033246    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 15:53:28 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 15:53:28 +1300    

Click here for diff

Back-patch to 14.  

M doc/src/sgml/monitoring.sgml

Fix waiting in RegisterSyncRequest().

commit   : 1396b5c6ed2bf46433c77ad0ce7f1ddaa984c224    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 15:35:42 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 15:35:42 +1300    

Click here for diff

If we run out of space in the checkpointer sync request queue (which is  
hopefully rare on real systems, but common with very small buffer pool),  
we wait for it to drain.  While waiting, we should report that as a wait  
event so that users know what is going on, and also handle postmaster  
death, since otherwise the loop might never terminate if the  
checkpointer has exited.  
  
Back-patch to 12.  Although the problem exists in earlier releases too,  
the code is structured differently before 12 so I haven't gone any  
further for now, in the absence of field complaints.  
  
Reported-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/20220226213942.nb7uvb2pamyu26dj%40alap3.anarazel.de  

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

pageinspect: Fix handling of page sizes and AM types

commit   : b61e6214cface3def6241295edadf4eeaf4c884d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Mar 2022 11:20:47 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Mar 2022 11:20:47 +0900    

Click here for diff

This commit fixes a set of issues related to the use of the SQL  
functions in this module when the caller is able to pass down raw page  
data as input argument:  
- The page size check was fuzzy in a couple of places, sometimes  
looking after only a sub-range, but what we are looking for is an exact  
match on BLCKSZ.  After considering a few options here, I have settled  
down to do a generalization of get_page_from_raw().  Most of the SQL  
functions already used that, and this is not strictly required if not  
accessing an 8-byte-wide value from a raw page, but this feels safer in  
the long run for alignment-picky environment, particularly if a code  
path begins to access such values.  This also reduces the number of  
strings that need to be translated.  
- The BRIN function brin_page_items() uses a Relation but it did not  
check the access method of the opened index, potentially leading to  
crashes.  All the other functions in need of a Relation already did  
that.  
- Some code paths could fail on elog(), but we should to use ereport()  
for failures that can be triggered by the user.  
  
Tests are added to stress all the cases that are fixed as of this  
commit, with some junk raw pages (\set VERBOSITY ensures that this works  
across all page sizes) and unexpected index types when functions open  
relations.  
  
Author: Michael Paquier, Justin Prysby  
Discussion: https://postgr.es/m/20220218030020.GA1137@telsasoft.com  
Backpatch-through: 10  

M contrib/pageinspect/brinfuncs.c
M contrib/pageinspect/btreefuncs.c
M contrib/pageinspect/expected/brin.out
M contrib/pageinspect/expected/btree.out
M contrib/pageinspect/expected/gin.out
M contrib/pageinspect/expected/gist.out
M contrib/pageinspect/expected/hash.out
M contrib/pageinspect/expected/page.out
M contrib/pageinspect/fsmfuncs.c
M contrib/pageinspect/gistfuncs.c
M contrib/pageinspect/hashfuncs.c
M contrib/pageinspect/rawpage.c
M contrib/pageinspect/sql/brin.sql
M contrib/pageinspect/sql/btree.sql
M contrib/pageinspect/sql/gin.sql
M contrib/pageinspect/sql/gist.sql
M contrib/pageinspect/sql/hash.sql
M contrib/pageinspect/sql/page.sql

Wake up for latches in CheckpointWriteDelay().

commit   : 78c0f85e435bf327dcf2c1aded47b51263b32b82    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 13:37:58 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 13:37:58 +1300    

Click here for diff

The checkpointer shouldn't ignore its latch.  Other backends may be  
waiting for it to drain the request queue.  Hopefully real systems don't  
have a full queue often, but the condition is reached easily when  
shared_buffers is small.  
  
This involves defining a new wait event, which will appear in the  
pg_stat_activity view often due to spread checkpoints.  
  
Back-patch only to 14.  Even though the problem exists in earlier  
branches too, it's hard to hit there.  In 14 we stopped using signal  
handlers for latches on Linux, *BSD and macOS, which were previously  
hiding this problem by interrupting the sleep (though not reliably, as  
the signal could arrive before the sleep begins; precisely the problem  
latches address).  
  
Reported-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/20220226213942.nb7uvb2pamyu26dj%40alap3.anarazel.de  

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

Back-patch LLVM 14 API changes.

commit   : d9f7ad54e552262ee0090e88d5abd3e04fcdeac8    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 11:35:00 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 16 Mar 2022 11:35:00 +1300    

Click here for diff

Since LLVM 14 has stopped changing and is about to be released,  
back-patch the following changes from the master branch:  
  
  e6a7600202105919bffd62b3dfd941f4a94e082b  
  807fee1a39de6bb8184082012e643951abb9ad1d  
  a56e7b66010f330782243de9e25ac2a6596be0e1  
  
Back-patch to 11, where LLVM JIT support came in.  

M src/backend/jit/llvm/Makefile
M src/backend/jit/llvm/llvmjit_error.cpp
M src/backend/jit/llvm/llvmjit_inline.cpp

Restore the previous semantics of get_constraint_index().

commit   : 8dcd1c3564f04bc1f71020c150b31deea07b7a95    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Mar 2022 13:47:26 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Mar 2022 13:47:26 -0500    

Click here for diff

Commit 8b069ef5d changed this function to look at pg_constraint.conindid  
rather than searching pg_depend.  That was a good performance improvement,  
but it failed to preserve the exact semantics.  The old code would only  
return an index that was "owned by" (internally dependent on) the  
specified constraint, whereas the new code will also return indexes that  
are just referenced by foreign key constraints.  This confuses ALTER  
TABLE, which was implicitly expecting the previous semantics, into  
failing with errors like  
    ERROR:  relation 146621 has multiple clustered indexes  
or  
    ERROR:  "pk_attbl" is not an index for table "atref"  
  
We can fix this without reverting the performance improvement by adding  
a contype check in get_constraint_index().  Another way could be to  
make ALTER TABLE check it, but I'm worried that extension code could  
also have subtle dependencies on the old semantics.  
  
Tom Lane and Japin Li, per bug #17409 from Holly Roberts.  
Back-patch to v14 where the error crept in.  
  
Discussion: https://postgr.es/m/17409-52871dda8b5741cb@postgresql.org  

M src/backend/utils/cache/lsyscache.c
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

doc: Add ALTER/DROP ROUTINE to the event trigger matrix

commit   : 8f091572873c072ff844b0e2e18088ec51e4b03f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 9 Mar 2022 14:59:18 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 9 Mar 2022 14:59:18 +0900    

Click here for diff

ALTER ROUTINE triggers the events ddl_command_start and ddl_command_end,  
and DROP ROUTINE triggers sql_drop, ddl_command_start and  
ddl_command_end, but this was not mention on the matrix table.  
  
Reported-by: Leslie Lemaire  
Discussion: https://postgr.es/m/164647533363.646.5802968483136493025@wrigleys.postgresql.org  
Backpatch-through: 11  

M doc/src/sgml/event-trigger.sgml

Introduce PG_TEST_TIMEOUT_DEFAULT for TAP suite non-elapsing timeouts.

commit   : f60bb3e0a9044058a3df1d75bb900e77e51ad4ed    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Fri, 4 Mar 2022 18:53:13 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Fri, 4 Mar 2022 18:53:13 -0800    

Click here for diff

Slow hosts may avoid load-induced, spurious failures by setting  
environment variable PG_TEST_TIMEOUT_DEFAULT to some number of seconds  
greater than 180.  Developers may see faster failures by setting that  
environment variable to some lesser number of seconds.  In tests, write  
$PostgreSQL::Test::Utils::timeout_default wherever the convention has  
been to write 180.  This change raises the default for some briefer  
timeouts.  Back-patch to v10 (all supported versions).  
  
Discussion: https://postgr.es/m/20220218052842.GA3627003@rfd.leadboat.com  

M contrib/amcheck/t/002_cic.pl
M contrib/amcheck/t/003_cic_2pc.pl
M src/bin/pg_ctl/t/004_logrotate.pl
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/psql/t/010_tab_completion.pl
M src/bin/scripts/t/080_pg_isready.pl
M src/test/perl/PostgresNode.pm
M src/test/perl/TestLib.pm
M src/test/recovery/t/003_recovery_targets.pl
M src/test/recovery/t/006_logical_decoding.pl
M src/test/recovery/t/010_logical_decoding_timelines.pl
M src/test/recovery/t/013_crash_restart.pl
M src/test/recovery/t/017_shm.pl
M src/test/recovery/t/019_replslot_limit.pl
M src/test/recovery/t/021_row_visibility.pl
M src/test/recovery/t/022_crash_temp_files.pl
M src/test/recovery/t/024_archive_recovery.pl
M src/test/subscription/t/015_stream.pl

Fix pg_regress to print the correct postmaster address on Windows.

commit   : a008c03dd722f3a9ea44b13ca2cc6066fd90ddc1    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 4 Mar 2022 13:23:58 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 4 Mar 2022 13:23:58 -0500    

Click here for diff

pg_regress reported "Unix socket" as the default location whenever  
HAVE_UNIX_SOCKETS is defined.  However, that's not been accurate  
on Windows since 8f3ec75de.  Update this logic to match what libpq  
actually does now.  
  
This is just cosmetic, but still it's potentially misleading.  
Back-patch to v13 where 8f3ec75de came in.  
  
Discussion: https://postgr.es/m/3894060.1646415641@sss.pgh.pa.us  

M src/interfaces/libpq/fe-connect.c
M src/test/regress/pg_regress.c

Fix bogus casting in BlockIdGetBlockNumber().

commit   : 5c9d17e94c5cc0d24c1f0dbfe030000238d65afb    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 3 Mar 2022 19:03:17 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 3 Mar 2022 19:03:17 -0500    

Click here for diff

This macro cast the result to BlockNumber after shifting, not before,  
which is the wrong thing.  Per the C spec, the uint16 fields would  
promote to int not unsigned int, so that (for 32-bit int) the shift  
potentially shifts a nonzero bit into the sign position.  I doubt  
there are any production systems where this would actually end with  
the wrong answer, but it is undefined behavior per the C spec, and  
clang's -fsanitize=undefined option reputedly warns about it on some  
platforms.  (I can't reproduce that right now, but the code is  
undeniably wrong per spec.)  It's easy to fix by casting to  
BlockNumber (uint32) in the proper places.  
  
It's been wrong for ages, so back-patch to all supported branches.  
  
Report and patch by Zhihong Yu (cosmetic tweaking by me)  
  
Discussion: https://postgr.es/m/CALNJ-vT9r0DSsAOw9OXVJFxLENoVS_68kJ5x0p44atoYH+H4dg@mail.gmail.com  

M src/include/storage/block.h

Clean up assorted failures under clang's -fsanitize=undefined checks.

commit   : b0bc196e52e606fe0116fb63da20f57fb577745b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 3 Mar 2022 18:13:24 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 3 Mar 2022 18:13:24 -0500    

Click here for diff

Most of these are cases where we could call memcpy() or other libc  
functions with a NULL pointer and a zero count, which is forbidden  
by POSIX even though every production version of libc allows it.  
We've fixed such things before in a piecemeal way, but apparently  
never made an effort to try to get them all.  I don't claim that  
this patch does so either, but it gets every failure I observe in  
check-world, using clang 12.0.1 on current RHEL8.  
  
numeric.c has a different issue that the sanitizer doesn't like:  
"ln(-1.0)" will compute log10(0) and then try to assign the  
resulting -Inf to an integer variable.  We don't actually use the  
result in such a case, so there's no live bug.  
  
Back-patch to all supported branches, with the idea that we might  
start running a buildfarm member that tests this case.  This includes  
back-patching c1132aae3 (Check the size in COPY_POINTER_FIELD),  
which previously silenced some of these issues in copyfuncs.c.  
  
Discussion: https://postgr.es/m/CALNJ-vT9r0DSsAOw9OXVJFxLENoVS_68kJ5x0p44atoYH+H4dg@mail.gmail.com  

M contrib/pgcrypto/px.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_visibility.c
M src/backend/access/transam/clog.c
M src/backend/access/transam/xact.c
M src/backend/nodes/copyfuncs.c
M src/backend/storage/ipc/shm_mq.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/time/snapmgr.c
M src/fe_utils/print.c

Allow root-owned SSL private keys in libpq, not only the backend.

commit   : 2a1f84636dc335a3edf53a8361ae44bb2ae00093    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 2 Mar 2022 11:57:02 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 2 Mar 2022 11:57:02 -0500    

Click here for diff

This change makes libpq apply the same private-key-file ownership  
and permissions checks that we have used in the backend since commit  
9a83564c5.  Namely, that the private key can be owned by either the  
current user or root (with different file permissions allowed in the  
two cases).  This allows system-wide management of key files, which  
is just as sensible on the client side as the server, particularly  
when the client is itself some application daemon.  
  
Sync the comments about this between libpq and the backend, too.  
  
Back-patch of a59c79564 and 50f03473e into all supported branches.  
  
David Steele  
  
Discussion: https://postgr.es/m/f4b7bc55-97ac-9e69-7398-335e212f7743@pgmasters.net  

M doc/src/sgml/libpq.sgml
M src/backend/libpq/be-secure-common.c
M src/interfaces/libpq/fe-secure-openssl.c

Disallow execution of SPI functions during plperl function compilation.

commit   : ac910bb2328ff107359d009aaf821c01559cef19    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Feb 2022 17:40:21 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Feb 2022 17:40:21 -0500    

Click here for diff

Perl can be convinced to execute user-defined code during compilation  
of a plperl function (or at least a plperlu function).  That's not  
such a big problem as long as the activity is confined within the  
Perl interpreter, and it's not clear we could do anything about that  
anyway.  However, if such code tries to use plperl's SPI functions,  
we have a bigger problem.  In the first place, those functions are  
likely to crash because current_call_data->prodesc isn't set up yet.  
In the second place, because it isn't set up, we lack critical info  
such as whether the function is supposed to be read-only.  And in  
the third place, this path allows code execution during function  
validation, which is strongly discouraged because of the potential  
for security exploits.  Hence, reject execution of the SPI functions  
until compilation is finished.  
  
While here, add check_spi_usage_allowed() calls to various functions  
that hadn't gotten the memo about checking that.  I think that perhaps  
plperl_sv_to_literal may have been intentionally omitted on the grounds  
that it was safe at the time; but if so, the addition of transforms  
functionality changed that.  The others are more recently added and  
seem to be flat-out oversights.  
  
Per report from Mark Murawski.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/9acdf918-7fff-4f40-f750-2ffa84f083d2@intellasoft.net  

M src/pl/plperl/plperl.c

pg_waldump: Fix error message for WAL files smaller than XLOG_BLCKSZ.

commit   : 9ff7fd9063ce918e458a643b53eda1cf95f7d115    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 25 Feb 2022 10:30:05 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 25 Feb 2022 10:30:05 -0800    

Click here for diff

When opening a WAL file smaller than XLOG_BLCKSZ (e.g. 0 bytes long) while  
determining the wal_segment_size, pg_waldump checked errno, despite errno not  
being set by the short read. Resulting in a bogus error message.  
  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://postgr.es/m/20220214.181847.775024684568733277.horikyota.ntt@gmail.com  
Backpatch: 11-, the bug was introducedin fc49e24fa  

M src/bin/pg_waldump/pg_waldump.c

Fix data loss on crash after sorted GiST index build.

commit   : 7d80e93fb1f1059ba3691b2584bb16992d7d734e    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 24 Feb 2022 14:34:06 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 24 Feb 2022 14:34:06 +0200    

Click here for diff

If a checkpoint happens during the index build, and the system crashes  
after the checkpoint and the index build have finished, the data written  
to the index before the checkpoint started could be lost. The checkpoint  
won't have fsync'd it, and it won't be replayed at crash recovery either.  
Fix by calling smgrimmedsync() after the index build, just like in B-tree  
index build.  
  
Backpatch to v14 where the sorted GiST index build was introduced.  
  
Reported-by: Melanie Plageman  
Discussion: https://www.postgresql.org/message-id/CAAKRu_ZJJynimxKj5xYBSziL62-iEtPE+fx-B=JzR=jUtP92mw@mail.gmail.com  

M src/backend/access/gist/gistbuild.c

Re-allow underscore as first character of custom GUC names.

commit   : dd7c0597918a6922a43a1f2e7085e6276a6216ec    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 23 Feb 2022 11:10:46 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 23 Feb 2022 11:10:46 -0500    

Click here for diff

Commit 3db826bd5 intended that valid_custom_variable_name's  
rules for valid identifiers match those of scan.l.  However,  
I (tgl) had some kind of brain fade and put "_" in the wrong  
list.  
  
Fix by Japin Li, per bug #17415 from Daniel Polski.  
  
Discussion: https://postgr.es/m/17415-ebdb683d7e09a51c@postgresql.org  

M src/backend/utils/misc/guc.c

Add compute_query_id = regress

commit   : 627c79a1e87d9ec4a8a8a0c5be8564ba74e221ea    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 22 Feb 2022 10:23:49 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 22 Feb 2022 10:23:49 +0900    

Click here for diff

"regress" is a new mode added to compute_query_id aimed at facilitating  
regression testing when a module computing query IDs is loaded into the  
backend, like pg_stat_statements.  It works the same way as "auto",  
meaning that query IDs are computed if a module enables it, except that  
query IDs are hidden in EXPLAIN outputs to ensure regression output  
stability.  
  
Like any GUCs of the kind (force_parallel_mode, etc.), this new  
configuration can be added to an instance's postgresql.conf, or just  
passed down with PGOPTIONS at command level.  compute_query_id uses an  
enum for its set of option values, meaning that this addition ensures  
ABI compatibility.  
  
Using this new configuration mode allows installcheck-world to pass when  
running the tests on an instance with pg_stat_statements enabled,  
stabilizing the test output while checking the paths doing query ID  
computations.  
  
Reported-by: Anton Melnikov  
Reviewed-by: Julien Rouhaud  
Discussion: https://postgr.es/m/1634283396.372373993@f75.i.mail.ru  
Discussion: https://postgr.es/m/YgHlxgc/OimuPYhH@paquier.xyz  
Backpatch-through: 14  

M doc/src/sgml/config.sgml
M src/backend/commands/explain.c
M src/backend/utils/misc/guc.c
M src/include/utils/queryjumble.h

Fix temporary object cleanup failing due to toast access without snapshot.

commit   : 7bbfe5994165aef9e903b1919d625fe87d4f146e    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Sat, 19 Feb 2022 12:27:20 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Sat, 19 Feb 2022 12:27:20 -0800    

Click here for diff

When cleaning up temporary objects during process exit the cleanup could fail  
with:  
  FATAL: cannot fetch toast data without an active snapshot  
  
The bug is caused by RemoveTempRelationsCallback() not setting up a  
snapshot. If an object with toasted catalog data needs to be cleaned up,  
init_toast_snapshot() could fail with the above error.  
  
Most of the time however the the problem is masked due to cached catalog  
snapshots being returned by GetOldestSnapshot(). But dropping an object can  
cause catalog invalidations to be emitted. If no further catalog accesses are  
necessary between the invalidation processing and the next toast datum  
deletion, the bug becomes visible.  
  
It's easy to miss this bug because it typically happens after clients  
disconnect and the FATAL error just ends up in the log.  
  
Luckily temporary table cleanup at the next use of the same temporary schema  
or during DISCARD ALL does not have the same problem.  
  
Fix the bug by pushing a snapshot in RemoveTempRelationsCallback(). Also add  
isolation tests for temporary object cleanup, including objects with toasted  
catalog data.  
  
A future HEAD only commit will add more assertions.  
  
Reported-By: Miles Delahunty  
Author: Andres Freund  
Discussion: https://postgr.es/m/CAOFAq3BU5Mf2TTvu8D9n_ZOoFAeQswuzk7yziAb7xuw_qyw5gw@mail.gmail.com  
Backpatch: 10-  

M src/backend/catalog/namespace.c
A src/test/isolation/expected/temp-schema-cleanup.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/temp-schema-cleanup.spec

Remove most msys special processing in TAP tests

commit   : 8b5cd373ba033977ef0100f52871dd6b38b7239e    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Sun, 20 Feb 2022 11:48:45 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Sun, 20 Feb 2022 11:48:45 -0500    

Click here for diff

Following migration of Windows buildfarm members running TAP tests to  
use of ucrt64 perl for those tests, special processing for msys perl is  
no longer necessary and so is removed.  
  
Backpatch to release 10  
  
Discussion: https://postgr.es/m/c65a8781-77ac-ea95-d185-6db291e1baeb@dunslane.net  

M src/bin/pg_ctl/t/001_start_stop.pl
M src/bin/pg_rewind/t/RewindTest.pm
M src/test/perl/PostgresNode.pm
M src/test/perl/TestLib.pm
M src/test/recovery/t/021_row_visibility.pl
M src/test/recovery/t/cp_history_files

Remove PostgreSQL::Test::Utils::perl2host completely

commit   : 652ff988fbf635c04618803fad06b863bf28bdb9    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Sun, 20 Feb 2022 08:55:06 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Sun, 20 Feb 2022 08:55:06 -0500    

Click here for diff

Commit f1ac4a74de disabled this processing, and as nothing has broken (as  
expected) here we proceed to remove the routine and adjust all the call  
sites.  
  
Backpatch to release 10  
  
Discussion: https://postgr.es/m/0ba775a2-8aa0-0d56-d780-69427cf6f33d@dunslane.net  
Discussion: https://postgr.es/m/20220125023609.5ohu3nslxgoygihl@alap3.anarazel.de  

M src/bin/pg_basebackup/t/010_pg_basebackup.pl
M src/bin/pg_checksums/t/002_actions.pl
M src/bin/pg_verifybackup/t/003_corruption.pl
M src/bin/pgbench/t/001_pgbench_with_server.pl
M src/bin/scripts/t/090_reindexdb.pl
M src/test/perl/PostgresNode.pm
M src/test/perl/TestLib.pm
M src/test/recovery/t/014_unlogged_reinit.pl
M src/test/recovery/t/017_shm.pl
M src/test/recovery/t/018_wal_optimize.pl
M src/test/recovery/t/025_stuck_on_old_timeline.pl

Suppress warning about stack_base_ptr with late-model GCC.

commit   : 2e30d77a196810f7e9d57709a942b1826fd1bb43    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 17 Feb 2022 22:45:34 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 17 Feb 2022 22:45:34 -0500    

Click here for diff

GCC 12 complains that set_stack_base is storing the address of  
a local variable in a long-lived pointer.  This is an entirely  
reasonable warning (indeed, it just helped us find a bug);  
but that behavior is intentional here.  We can work around it  
by using __builtin_frame_address(0) instead of a specific local  
variable; that produces an address a dozen or so bytes different,  
in my testing, but we don't care about such a small difference.  
Maybe someday a compiler lacking that function will start to issue  
a similar warning, but we'll worry about that when it happens.  
  
Patch by me, per a suggestion from Andres Freund.  Back-patch to  
v12, which is as far back as the patch will go without some pain.  
(Recently-established project policy would permit a back-patch as  
far as 9.2, but I'm disinclined to expend the work until GCC 12  
is much more widespread.)  
  
Discussion: https://postgr.es/m/3773792.1645141467@sss.pgh.pa.us  

M config/c-compiler.m4
M configure
M configure.ac
M src/backend/postmaster/postmaster.c
M src/backend/tcop/postgres.c
M src/backend/utils/init/miscinit.c
M src/include/pg_config.h.in
M src/tools/msvc/Solution.pm

Doc: Update documentation for modifying postgres_fdw foreign tables.

commit   : a9e186da81d9965789b1a7ab869329eabe3595c3    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 16 Feb 2022 15:15:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 16 Feb 2022 15:15:02 +0900    

Click here for diff

Document that they can be modified using COPY as well.  
  
Back-patch to v11 where commit 3d956d956 added support for COPY in  
postgres_fdw.  

M doc/src/sgml/postgres-fdw.sgml

WAL log unchanged toasted replica identity key attributes.

commit   : 04645bbcae72c71e5bf28a7a0c96efa851e13ddb    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 14 Feb 2022 08:07:46 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 14 Feb 2022 08:07:46 +0530    

Click here for diff

Currently, during UPDATE, the unchanged replica identity key attributes  
are not logged separately because they are getting logged as part of the  
new tuple. But if they are stored externally then the untoasted values are  
not getting logged as part of the new tuple and logical replication won't  
be able to replicate such UPDATEs. So we need to log such attributes as  
part of the old_key_tuple during UPDATE.  
  
Reported-by: Haiying Tang  
Author: Dilip Kumar and Amit Kapila  
Reviewed-by: Alvaro Herrera, Haiying Tang, Andres Freund  
Backpatch-through: 10  
Discussion: https://postgr.es/m/OS0PR01MB611342D0A92D4F4BF26C0F47FB229@OS0PR01MB6113.jpnprd01.prod.outlook.com  

M contrib/test_decoding/expected/toast.out
M doc/src/sgml/ref/alter_table.sgml
M src/backend/access/heap/heapam.c

Fix memory leak in IndexScan node with reordering

commit   : c76665edce3d4db4e509723e91742569e9f46817    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 14 Feb 2022 03:26:55 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 14 Feb 2022 03:26:55 +0300    

Click here for diff

Fix ExecReScanIndexScan() to free the referenced tuples while emptying the  
priority queue.  Backpatch to all supported versions.  
  
Discussion: https://postgr.es/m/CAHqSB9gECMENBQmpbv5rvmT3HTaORmMK3Ukg73DsX5H7EJV7jw%40mail.gmail.com  
Author: Aliaksandr Kalenik  
Reviewed-by: Tom Lane, Alexander Korotkov  
Backpatch-through: 10  

M src/backend/executor/nodeIndexscan.c
M src/test/regress/expected/create_index.out
M src/test/regress/sql/create_index.sql

Fix thinko in PQisBusy().

commit   : ae27b1acc43d58badad356a4da8fc0c72d46d7fb    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 12 Feb 2022 13:23:20 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 12 Feb 2022 13:23:20 -0500    

Click here for diff

In commit 1f39a1c06 I made PQisBusy consider conn->write_failed, but  
that is now looking like complete brain fade.  In the first place, the  
logic is quite wrong: it ought to be like "and not" rather than "or".  
This meant that once we'd gotten into a write_failed state, PQisBusy  
would always return true, probably causing the calling application to  
iterate its loop until PQconsumeInput returns a hard failure thanks  
to connection loss.  That's not what we want: the intended behavior  
is to return an error PGresult, which the application probably has  
much cleaner support for.  
  
But in the second place, checking write_failed here seems like the  
wrong thing anyway.  The idea of the write_failed mechanism is to  
postpone handling of a write failure until we've read all we can from  
the server; so that flag should not interfere with input-processing  
behavior.  (Compare 7247e243a.)  What we *should* check for is  
status = CONNECTION_BAD, ie, socket already closed.  (Most places that  
close the socket don't touch asyncStatus, but they do reset status.)  
This primarily ensures that if PQisBusy() returns true then there is  
an open socket, which is assumed by several call sites in our own  
code, and probably other applications too.  
  
While at it, fix a nearby thinko in libpq's my_sock_write: we should  
only consult errno for res < 0, not res == 0.  This is harmless since  
pqsecure_raw_write would force errno to zero in such a case, but it  
still could confuse readers.  
  
Noted by Andres Freund.  Backpatch to v12 where 1f39a1c06 came in.  
  
Discussion: https://postgr.es/m/20220211011025.ek7exh6owpzjyudn@alap3.anarazel.de  

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

Don't use_physical_tlist for an IOS with non-returnable columns.

commit   : 277e744ae176ef8e411a9e6c5b2e649322ee6bdd    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Feb 2022 15:23:52 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Feb 2022 15:23:52 -0500    

Click here for diff

createplan.c tries to save a runtime projection step by specifying  
a scan plan node's output as being exactly the table's columns, or  
index's columns in the case of an index-only scan, if there is not a  
reason to do otherwise.  This logic did not previously pay attention  
to whether an index's columns are returnable.  That worked, sort of  
accidentally, until commit 9a3ddeb51 taught setrefs.c to reject plans  
that try to read a non-returnable column.  I have no desire to loosen  
setrefs.c's new check, so instead adjust use_physical_tlist() to not  
try to optimize this way when there are non-returnable column(s).  
  
Per report from Ryan Kelly.  Like the previous patch, back-patch  
to all supported branches.  
  
Discussion: https://postgr.es/m/CAHUie24ddN+pDNw7fkhNrjrwAX=fXXfGZZEHhRuofV_N_ftaSg@mail.gmail.com  

M src/backend/optimizer/plan/createplan.c
M src/test/regress/expected/gist.out
M src/test/regress/sql/gist.sql

Make pg_ctl stop/restart/promote recheck postmaster aliveness.

commit   : 1e8c5cf7c6c2668da69b77cea91f74ca75e67c56    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 10 Feb 2022 16:49:39 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 10 Feb 2022 16:49:39 -0500    

Click here for diff

"pg_ctl stop/restart" checked that the postmaster PID is valid just  
once, as a side-effect of sending the stop signal, and then would  
wait-till-timeout for the postmaster.pid file to go away.  This  
neglects the case wherein the postmaster dies uncleanly after we  
signal it.  Similarly, once "pg_ctl promote" has sent the signal,  
it'd wait for the corresponding on-disk state change to occur  
even if the postmaster dies.  
  
I'm not sure how we've managed not to notice this problem, but it  
seems to explain slow execution of the 017_shm.pl test script on AIX  
since commit 4fdbf9af5, which added a speculative "pg_ctl stop" with  
the idea of making real sure that the postmaster isn't there.  In the  
test steps that kill-9 and then restart the postmaster, it's possible  
to get past the initial signal attempt before kill() stops working  
for the doomed postmaster.  If that happens, pg_ctl waited till  
PGCTLTIMEOUT before giving up ... and the buildfarm's AIX members  
have that set very high.  
  
To fix, include a "kill(pid, 0)" test (similar to what  
postmaster_is_alive uses) in these wait loops, so that we'll  
give up immediately if the postmaster PID disappears.  
  
While here, I chose to refactor those loops out of where they were.  
do_stop() and do_restart() can perfectly well share one copy of the  
wait-for-stop loop, and it seems desirable to put a similar function  
beside that for wait-for-promote.  
  
Back-patch to all supported versions, since pg_ctl's wait logic  
is substantially identical in all, and we're seeing the slow test  
behavior in all branches.  
  
Discussion: https://postgr.es/m/20220210023537.GA3222837@rfd.leadboat.com  

M src/bin/pg_ctl/pg_ctl.c

Use gendef instead of pexports for building windows .def files

commit   : 92f60f536eceabcefb2528d4bf5366fef4a1536d    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 10 Feb 2022 13:44:05 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 10 Feb 2022 13:44:05 -0500    

Click here for diff

Modern msys systems lack pexports but have gendef instead, so use that.  
  
Discussion: https://postgr.es/m/3ccde7a9-e4f9-e194-30e0-0936e6ad68ba@dunslane.net  
  
Backpatch to release 9.4 to enable building with perl on older branches.  
Before that pexports is not used for plperl.  

M src/pl/plperl/GNUmakefile
M src/pl/plpython/Makefile
M src/pl/tcl/Makefile

Make timeout.c more robust against missed timer interrupts.

commit   : 2e211c16612a127bea861e416bdc22ff39c54866    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 10 Feb 2022 11:52:20 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 10 Feb 2022 11:52:20 -0500    

Click here for diff

Commit 09cf1d522 taught schedule_alarm() to not do anything if  
the next requested event is after when we expect the next interrupt  
to fire.  However, if somehow an interrupt gets lost, we'll continue  
to not do anything indefinitely, even after the "next interrupt" time  
is obviously in the past.  Thus, one missed interrupt can break  
timeout scheduling for the life of the session.  Michael Harris  
reported a scenario where a bug in a user-defined function caused this  
to happen, so you don't even need to assume kernel bugs exist to think  
this is worth fixing.  We can make things more robust at little cost  
by detecting the case where signal_due_at is before "now" and forcing  
a new setitimer call to occur.  This isn't a completely bulletproof  
fix of course; but in our typical usage pattern where we frequently set  
timeouts and clear them before they are reached, the interrupt will  
get re-enabled after at most one timeout interval, which with a little  
luck will be before we really need it.  
  
While here, let's mark signal_due_at as volatile, since the signal  
handler can both examine and set it.  I'm not sure there's any  
actual risk given that signal_pending is already volatile, but  
it's surely questionable.  
  
Backpatch to v14 where this logic came in.  
  
Michael Harris and Tom Lane  
  
Discussion: https://postgr.es/m/CADofcAWbMrvgwSMqO4iG_iD3E2v8ZUrC-_crB41my=VMM02-CA@mail.gmail.com  

M src/backend/utils/misc/timeout.c

Set SNI ClientHello extension to localhost in tests

commit   : 5f00ef065ec8f086efeec93083fe250f81a3f585    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 10 Feb 2022 14:23:36 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 10 Feb 2022 14:23:36 +0100    

Click here for diff

The connection strings in the SSL client tests were using the host  
set up from Cluster.pm which is a temporary pathname. When SNI is  
enabled we pass the host to OpenSSL in order to set the server name  
indication ClientHello extension via SSL_set_tlsext_host_name.  
  
OpenSSL doesn't validate the hostname apart from checking the max  
length, but LibreSSL checks for RFC 5890 conformance which results  
in errors during testing as the pathname from Cluster.pm is not a  
valid hostname.  
  
Fix by setting the host explicitly to localhost, as that's closer  
to the intent of the test.  
  
Backpatch through 14 where SNI support came in.  
  
Reported-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/17391-304f81bcf724b58b@postgresql.org  
Backpatch-through: 14  

M src/test/ssl/t/001_ssltests.pl
M src/test/ssl/t/002_scram.pl

Use Test::Builder::todo_start(), replacing $::TODO.

commit   : 1a83297d222487070386b55b032657345d7ec64a    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Wed, 9 Feb 2022 18:16:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Wed, 9 Feb 2022 18:16:59 -0800    

Click here for diff

Some pre-2017 Test::More versions need perfect $Test::Builder::Level  
maintenance to find the variable.  Buildfarm member snapper reported an  
overall failure that the file intended to hide via the TODO construct.  
That trouble was reachable in v11 and v10.  For later branches, this  
serves as defense in depth.  Back-patch to v10 (all supported versions).  
  
Discussion: https://postgr.es/m/20220202055556.GB2745933@rfd.leadboat.com  

M contrib/amcheck/t/003_cic_2pc.pl

Test honestly for <sys/signalfd.h>.

commit   : c23461a22a1ead0a34dc209c2918ec4ccaf61475    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 9 Feb 2022 14:24:55 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 9 Feb 2022 14:24:55 -0500    

Click here for diff

Commit 6a2a70a02 supposed that any platform having <sys/epoll.h>  
would also have <sys/signalfd.h>.  It turns out there are still a  
few people using platforms where that's not so, so we'd better make  
a separate configure probe for it.  But since it took this long to  
notice, I'm content with the decision to not have a separate code  
path for epoll-only machines; we'll just fall back to using poll()  
for these stragglers.  
  
Per gripe from Gabriela Serventi.  Back-patch to v14 where this  
code came in.  
  
Discussion: https://postgr.es/m/CAHOHWE-JjJDfcYuLAAEO7Jk07atFAU47z8TzHzg71gbC0aMy=g@mail.gmail.com  

M configure
M configure.ac
M src/backend/storage/ipc/latch.c
M src/include/pg_config.h.in
M src/tools/msvc/Solution.pm

Remove ppport.h's broken re-implementation of eval_pv().

commit   : e327291e4a96571c85b6a9b140e1a8116fb47ec6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 8 Feb 2022 19:25:56 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 8 Feb 2022 19:25:56 -0500    

Click here for diff

Recent versions of Devel::PPPort try to redefine eval_pv() to  
dodge a bug in pre-5.31 Perl versions.  Unfortunately the redefinition  
fails on compilers that don't support statements nested within  
expressions.  However, we aren't actually interested in this bug fix,  
since we always call eval_pv() with croak_on_error = FALSE.  
So, until there's an upstream fix for this breakage, just comment  
out the macro to revert to the older behavior.  
  
Per report from Wei Sun, as well as previous buildfarm failure  
on pademelon (which I'd unfortunately not looked at carefully  
enough to understand the cause).  Back-patch to all supported  
versions, since we're using the same ppport.h in all.  
  
Discussion: https://postgr.es/m/tencent_2EFCC8BA0107B6EC0F97179E019A8A43C806@qq.com  
Report: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=pademelon&dt=2022-02-02%2001%3A22%3A58  

M src/pl/plperl/ppport.h

Stamp 14.2.

commit   : 78b1ddc753b3e5e3f3e9eb0e7519b48146018394    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 7 Feb 2022 16:15:36 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 7 Feb 2022 16:15:36 -0500    

Click here for diff

M configure
M configure.ac

Translation updates

commit   : 3c879e61d9ad5968e88e12620e270808b6cb76f5    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 7 Feb 2022 13:31:57 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 7 Feb 2022 13:31:57 +0100    

Click here for diff

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

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/el.po
M src/bin/initdb/po/sv.po
M src/bin/pg_amcheck/po/el.po
M src/bin/pg_amcheck/po/ru.po
M src/bin/pg_basebackup/nls.mk
M src/bin/pg_basebackup/po/de.po
A src/bin/pg_basebackup/po/el.po
M src/bin/pg_basebackup/po/es.po
M src/bin/pg_basebackup/po/fr.po
M src/bin/pg_basebackup/po/ru.po
M src/bin/pg_dump/po/de.po
M src/bin/pg_dump/po/el.po
M src/bin/pg_dump/po/es.po
M src/bin/pg_dump/po/fr.po
M src/bin/pg_dump/po/ru.po
M src/bin/pg_dump/po/sv.po
M src/bin/pg_resetwal/po/el.po
M src/bin/pg_resetwal/po/sv.po
M src/bin/pg_rewind/po/sv.po
M src/bin/pg_upgrade/po/ru.po
M src/bin/pg_upgrade/po/sv.po
M src/bin/psql/po/de.po
M src/bin/psql/po/el.po
M src/bin/psql/po/es.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ru.po
M src/bin/psql/po/sv.po
M src/bin/scripts/po/el.po
M src/bin/scripts/po/es.po
M src/bin/scripts/po/ru.po
M src/bin/scripts/po/sv.po
M src/interfaces/ecpg/preproc/po/el.po
M src/interfaces/libpq/po/de.po
M src/interfaces/libpq/po/es.po
M src/interfaces/libpq/po/fr.po
M src/interfaces/libpq/po/ru.po
M src/interfaces/libpq/po/sv.po
M src/pl/plperl/po/ru.po
M src/pl/plpgsql/src/po/el.po

Release notes for 14.2, 13.6, 12.10, 11.15, 10.20.

commit   : 1d9ccc0a6d3c1b3d5c52e6e427a9e1cb824b0a90    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 6 Feb 2022 14:24:55 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 6 Feb 2022 14:24:55 -0500    

Click here for diff

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

Doc: be clearer that foreign-table partitions need user-added constraints.

commit   : d0cd7b77265cf39e0e8984ba9d5bec0c155dccdb    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 5 Feb 2022 12:55:44 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 5 Feb 2022 12:55:44 -0500    

Click here for diff

A very well-informed user might deduce this from what we said already,  
but I'd bet against it.  Lay it out explicitly.  
  
While here, rewrite the comment about tuple routing to be more  
intelligible to an average SQL user.  
  
Per bug #17395 from Alexander Lakhin.  Back-patch to v11.  (The text  
in this area is different in v10 and I'm not sufficiently excited  
about this point to adapt the patch.)  
  
Discussion: https://postgr.es/m/17395-8c326292078d1a57@postgresql.org  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/ref/create_foreign_table.sgml

Test, don't just Assert, that mergejoin's inputs are in order.

commit   : d13a838e1c19df5358d250b8d469544d7ab3dfda    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 5 Feb 2022 11:59:30 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 5 Feb 2022 11:59:30 -0500    

Click here for diff

There are two Asserts in nodeMergejoin.c that are reachable if  
the input data is not in the expected order.  This seems way too  
fragile.  Alexander Lakhin reported a case where the assertions  
could be triggered with misconfigured foreign-table partitions,  
and bitter experience with unstable operating system collation  
definitions suggests another easy route to hitting them.  Neither  
Assert is in a place where we can't afford one more test-and-branch,  
so replace 'em with plain test-and-elog logic.  
  
Per bug #17395.  While the reported symptom is relatively recent,  
collation changes could happen anytime, so back-patch to all  
supported branches.  
  
Discussion: https://postgr.es/m/17395-8c326292078d1a57@postgresql.org  

M src/backend/executor/nodeMergejoin.c

First-draft release notes for 14.2.

commit   : ab22eea83169c8d0eb15050ce61cbe3d7dae4de6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 4 Feb 2022 14:55:00 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 4 Feb 2022 14:55:00 -0500    

Click here for diff

As usual, the release notes for older branches will be made by cutting  
these down, but put them up for community review first.  

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

Fix compiler warning in non-assert builds, introduced in f862d57057f.

commit   : 2a3958e4d9b9b1e82adefa11f3e69ea5c16efb45    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Thu, 3 Feb 2022 10:44:26 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Thu, 3 Feb 2022 10:44:26 -0800    

Click here for diff

Discussion: https://postgr.es/m/20220203183655.ralgkh54sdcgysmn@alap3.anarazel.de  
Backpatch: 14-, like f862d57057f  

M src/backend/executor/nodeForeignscan.c

Further fix for EvalPlanQual with mix of local and foreign partitions.

commit   : 7b0cec2fa05a123ed96163d7ac8485384570b3e0    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 3 Feb 2022 15:15:01 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 3 Feb 2022 15:15:01 +0900    

Click here for diff

We assume that direct-modify ForeignScan nodes cannot be re-evaluated  
during EvalPlanQual processing, but the rework for inherited  
UPDATE/DELETE in commit 86dc90056 changed things, without considering  
that, so that such ForeignScan nodes get called as part of the  
EvalPlanQual subtree during EvalPlanQual processing in the case of an  
inherited UPDATE/DELETE where the inheritance set contains foreign  
target relations.  To avoid re-evaluating such ForeignScan nodes during  
EvalPlanQual processing, commit c3928b467 modified nodeForeignscan.c,  
but the assumption made there that ExecForeignScan() should never be  
called for such ForeignScan nodes during EvalPlanQual processing turned  
out to be wrong in some cases, leading to a segmentation fault or a  
"cannot re-evaluate a Foreign Update or Delete during EvalPlanQual"  
error.  
  
Fix by modifying nodeForeignscan.c further to avoid re-evaluating such  
ForeignScan nodes even in ExecForeignScan()/ExecReScanForeignScan()  
during EvalPlanQual processing.  Since this makes non-reachable the  
test-and-elog added to ForeignNext() by commit c3928b467 that produced  
the aforesaid error, convert the test-and-elog to an Assert.  
  
Per bug #17355 from Alexander Lakhin.  Back-patch to v14 where both  
commits came in.  
  
Patch by me, reviewed and tested by Alexander Lakhin and Amit Langote.  
  
Discussion: https://postgr.es/m/17355-de8e362eb7001a96@postgresql.org  

M src/backend/executor/nodeForeignscan.c

doc: clarify syntax notation, particularly parentheses

commit   : 25560761289e5dbe21514c9ef2cf7272d9181488    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Wed, 2 Feb 2022 21:53:51 -0500    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Wed, 2 Feb 2022 21:53:51 -0500    

Click here for diff

Also move TCL syntax to the PL/tcl section.  
  
Reported-by: davs2rt@gmail.com  
  
Discussion: https://postgr.es/m/164308146320.12460.3590769444508751574@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/notation.sgml
M doc/src/sgml/pltcl.sgml

doc: Fix mistake in PL/Python documentation

commit   : ee57467cb6b2ce1e25d367cbd64cc60ae9ba0eb3    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 2 Feb 2022 09:14:26 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 2 Feb 2022 09:14:26 +0100    

Click here for diff

Small thinko introduced by 94aceed317730953476bec490ce0148b2af3c383  
  
Reported-by: nassehk@gmail.com  

M doc/src/sgml/plpython.sgml

Replace use of deprecated Python module distutils.sysconfig, take 2.

commit   : 803f0b1739065b2d1d46c4a72c99b46cdd354f60    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 1 Feb 2022 19:03:41 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 1 Feb 2022 19:03:41 -0500    

Click here for diff

With Python 3.10, configure spits out warnings about the module  
distutils.sysconfig being deprecated and scheduled for removal in  
Python 3.12.  Change the uses in configure to use the module sysconfig  
instead.  The logic stays largely the same, although we have to  
rely on INCLUDEPY instead of the deprecated get_python_inc function.  
  
Note that sysconfig exists since Python 2.7, so this moves the  
minimum required version up from Python 2.6 (or 2.4, before v13).  
Also, sysconfig didn't exist in Python 3.1, so the minimum 3.x  
version is now 3.2.  
  
Back-patch of commit bd233bdd8 into all supported branches.  
  
In v10, this also includes back-patching v11's beff4bb9c, primarily  
because this opinion is clearly out-of-date:  
  
    While at it, get rid of the code's assumption that both the major and  
    minor numbers contain exactly one digit.  That will foreseeably be  
    broken by Python 3.10 in perhaps four or five years.  That's far enough  
    out that we probably don't need to back-patch this.  
  
Peter Eisentraut, Tom Lane, Andres Freund  
  
Discussion: https://postgr.es/m/c74add3c-09c4-a9dd-1a03-a846e5b2fc52@enterprisedb.com  

M config/python.m4
M configure
M doc/src/sgml/installation.sgml

Revert "plperl: Fix breakage of c89f409749c in back branches."

commit   : 00fdfde6dc726dbbee7e7e3e25a6406e2c76c4f6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 31 Jan 2022 15:07:39 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 31 Jan 2022 15:07:39 -0500    

Click here for diff

This reverts commits d81cac47a et al.  We shouldn't need that  
hack after the preceding commits.  
  
Discussion: https://postgr.es/m/20220131015130.shn6wr2fzuymerf6@alap3.anarazel.de  

M src/pl/plperl/plperl.c

plperl: update ppport.h to Perl 5.34.0.

commit   : 2d44912cf79f1f174a83f587e1c4328315b8a0fa    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 31 Jan 2022 15:01:05 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 31 Jan 2022 15:01:05 -0500    

Click here for diff

Also apply the changes suggested by running  
perl ppport.h --compat-version=5.8.0  
  
And remove some no-longer-required NEED_foo declarations.  
  
Dagfinn Ilmari Mannsåker  
  
Back-patch of commit 05798c9f7 into all supported branches.  
At the time we thought this update was mostly cosmetic, but the  
lack of it has caused trouble, while the patch itself hasn't.  
  
Discussion: https://postgr.es/m/87y278s6iq.fsf@wibble.ilmari.org  
Discussion: https://postgr.es/m/20220131015130.shn6wr2fzuymerf6@alap3.anarazel.de  

M src/pl/plperl/plperl.c
M src/pl/plperl/plperl.h
M src/pl/plperl/ppport.h

plperl: Fix breakage of c89f409749c in back branches.

commit   : d81cac47a829c3e2c729ef98acaf132adb7ff3ae    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Sun, 30 Jan 2022 17:53:53 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Sun, 30 Jan 2022 17:53:53 -0800    

Click here for diff

ppport.h was only updated in 05798c9f7f0 (master). Unfortunately my commit  
c89f409749c uses PERL_VERSION_LT which came in with that update. Breaking most  
buildfarm animals.  
  
I should have noticed that...  
  
We might want to backpatch the ppport update instead, but for now lets get the  
buildfarm green again.  
  
Discussion: https://postgr.es/m/20220131015130.shn6wr2fzuymerf6@alap3.anarazel.de  
Backpatch: 10-14, master doesn't need it  

M src/pl/plperl/plperl.c

plperl: windows: Use Perl_setlocale on 5.28+, fixing compile failure.

commit   : 8484e38126d7522069e44b81cd41ef53f700b2e1    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Sun, 30 Jan 2022 14:29:04 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Sun, 30 Jan 2022 14:29:04 -0800    

Click here for diff

For older versions we need our own copy of perl's setlocale(), because it was  
not exposed (why we need the setlocale in the first place is explained in  
plperl_init_interp) . The copy stopped working in 5.28, as some of the used  
macros are not public anymore.  But Perl_setlocale is available in 5.28, so  
use that.  
  
Author: Victor Wagner <vitus@wagner.pp.ru>  
Reviewed-By: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>  
Discussion: https://postgr.es/m/20200501134711.08750c5f@antares.wagner.home  
Backpatch: all versions  

M src/pl/plperl/plperl.c

Fix failure to validate the result of select_common_type().

commit   : c025067f6d3fbffd1acc8c70ec9d2ecc5be8c90b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Jan 2022 11:41:12 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Jan 2022 11:41:12 -0500    

Click here for diff

Although select_common_type() has a failure-return convention, an  
apparent successful return just provides a type OID that *might* work  
as a common supertype; we've not validated that the required casts  
actually exist.  In the mainstream use-cases that doesn't matter,  
because we'll proceed to invoke coerce_to_common_type() on each input,  
which will fail appropriately if the proposed common type doesn't  
actually work.  However, a few callers didn't read the (nonexistent)  
fine print, and thought that if they got back a nonzero OID then the  
coercions were sure to work.  
  
This affects in particular the recently-added "anycompatible"  
polymorphic types; we might think that a function/operator using  
such types matches cases it really doesn't.  A likely end result  
of that is unexpected "ambiguous operator" errors, as for example  
in bug #17387 from James Inform.  Another, much older, case is that  
the parser might try to transform an "x IN (list)" construct to  
a ScalarArrayOpExpr even when the list elements don't actually have  
a common supertype.  
  
It doesn't seem desirable to add more checking to select_common_type  
itself, as that'd just slow down the mainstream use-cases.  Instead,  
write a separate function verify_common_type that performs the  
missing checks, and add a call to that where necessary.  Likewise add  
verify_common_type_from_oids to go with select_common_type_from_oids.  
  
Back-patch to v13 where the "anycompatible" types came in.  (The  
symptom complained of in bug #17387 doesn't appear till v14, but  
that's just because we didn't get around to converting || to use  
anycompatible till then.)  In principle the "x IN (list)" fix could  
go back all the way, but I'm not currently convinced that it makes  
much difference in real-world cases, so I won't bother for now.  
  
Discussion: https://postgr.es/m/17387-5dfe54b988444963@postgresql.org  

M src/backend/parser/parse_coerce.c
M src/backend/parser/parse_expr.c
M src/include/parser/parse_coerce.h
M src/test/regress/expected/arrays.out
M src/test/regress/expected/expressions.out
M src/test/regress/sql/arrays.sql
M src/test/regress/sql/expressions.sql

Fix incorrect memory context switch in COPY TO execution

commit   : b30282fccfa34238492c0f64808e7b4aa4ef72b3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 29 Jan 2022 10:23:17 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 29 Jan 2022 10:23:17 +0900    

Click here for diff

c532d15 has split the logic of COPY commands into multiple files, one  
change being to move the internals of BeginCopy() to BeginCopyTo().  
Originally the code was written so as we'd switch back-and-forth between  
the current execution memory context and the dedicated memory context  
for the COPY command, and this refactoring has introduced an extra  
switch to the current memory context from the COPY context once  
BeginCopyTo() is done with the past logic coming from BeginCopy().  
  
The code was correctly doing the analyze, rewrite and planning phases in  
the COPY context, but it was not assigning "copy_file" (FILE* used when  
copying to a source file) and "filename" in the COPY context, making the  
COPY status data inconsistent.  
  
Author: Bharath Rupireddy  
Reviewed-by: Japin Li  
Discussion: https://postgr.es/m/CALj2ACWvVa69foi9jhHFY=2BuHxAoYboyE+vXQTARwxZcJnVrQ@mail.gmail.com  
Backpatch-through: 14  

M src/backend/commands/copyto.c

Fix typo in comment.

commit   : d99166ed4f6e9f370289a90dd6678c06bfffd41f    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 28 Jan 2022 15:45:01 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 28 Jan 2022 15:45:01 +0900    

Click here for diff

M src/backend/executor/nodeForeignscan.c

Prevent memory context logging from sending log message to connected client.

commit   : 6e7ee55e727771d97d0fce531a5cda350bb3fa84    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 28 Jan 2022 11:24:42 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 28 Jan 2022 11:24:42 +0900    

Click here for diff

When pg_log_backend_memory_contexts() is executed, the target backend  
should use LOG_SERVER_ONLY to log its memory contexts, to prevent them  
from being sent to its connected client regardless of client_min_messages.  
But previously the backend unexpectedly used LOG to log the message  
"logging memory contexts of PID %d" and it could be sent to the client.  
This is a bug in memory context logging.  
  
To fix the bug, this commit changes that message so that it's logged with  
LOG_SERVER_ONLY.  
  
Back-patch to v14 where pg_log_backend_memory_contexts() was added.  
  
Author: Fujii Masao  
Reviewed-by: Bharath Rupireddy, Atsushi Torikoshi  
Discussion: https://postgr.es/m/82c12f36-86f7-5e72-79af-7f5c37f6cad7@oss.nttdata.com  

M src/backend/utils/mmgr/mcxt.c

Fix ordering of XIDs in ProcArrayApplyRecoveryInfo

commit   : fb2f8e534aaefa649ada8df3e4863ebad32229f7    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 27 Jan 2022 17:53:53 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 27 Jan 2022 17:53:53 +0100    

Click here for diff

Commit 8431e296ea reworked ProcArrayApplyRecoveryInfo to sort XIDs  
before adding them to KnownAssignedXids. But the XIDs are sorted using  
xidComparator, which compares the XIDs simply as uint32 values, not  
logically. KnownAssignedXidsAdd() however expects XIDs in logical order,  
and calls TransactionIdFollowsOrEquals() to enforce that. If there are  
XIDs for which the two orderings disagree, an error is raised and the  
recovery fails/restarts.  
  
Hitting this issue is fairly easy - you just need two transactions, one  
started before the 4B limit (e.g. XID 4294967290), the other sometime  
after it (e.g. XID 1000). Logically (4294967290 <= 1000) but when  
compared using xidComparator we try to add them in the opposite order.  
Which makes KnownAssignedXidsAdd() fail with an error like this:  
  
  ERROR: out-of-order XID insertion in KnownAssignedXids  
  
This only happens during replica startup, while processing RUNNING_XACTS  
records to build the snapshot. Once we reach STANDBY_SNAPSHOT_READY, we  
skip these records. So this does not affect already running replicas,  
but if you restart (or create) a replica while there are transactions  
with XIDs for which the two orderings disagree, you may hit this.  
  
Long-running transactions and frequent replica restarts increase the  
likelihood of hitting this issue. Once the replica gets into this state,  
it can't be started (even if the old transactions are terminated).  
  
Fixed by sorting the XIDs logically - this is fine because we're dealing  
with normal XIDs (because it's XIDs assigned to backends) and from the  
same wraparound epoch (otherwise the backends could not be running at  
the same time on the primary node). So there are no problems with the  
triangle inequality, which is why xidComparator compares raw values.  
  
Investigation and root cause analysis by Abhijit Menon-Sen. Patch by me.  
  
This issue is present in all releases since 9.4, however releases up to  
9.6 are EOL already so backpatch to 10 only.  
  
Reviewed-by: Abhijit Menon-Sen  
Reviewed-by: Alvaro Herrera  
Backpatch-through: 10  
Discussion: https://postgr.es/m/36b8a501-5d73-277c-4972-f58a4dce088a%40enterprisedb.com  

M src/backend/storage/ipc/procarray.c
M src/backend/utils/adt/xid.c
M src/include/utils/builtins.h

Improve msys2 detection for TAP tests

commit   : 999dc1d2650883b817ea6d4e393ca8ba84a8687d    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 27 Jan 2022 08:17:42 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 27 Jan 2022 08:17:42 -0500    

Click here for diff

Perl instances on some msys toolchains (e.g. UCRT64) have their  
configured osname set to 'MSWin32' rather than 'msys'.  The test for  
the msys2 platform is adjusted accordingly.  
  
Backpatch to release 14.  

M src/test/perl/TestLib.pm

postgres_fdw: Fix handling of a pending asynchronous request in postgresReScanForeignScan().

commit   : d1cca9441dc488b9e4d82cf34c9cacc998e6470f    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 27 Jan 2022 16:15:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 27 Jan 2022 16:15:02 +0900    

Click here for diff

Commit 27e1f1456 failed to process a pending asynchronous request made  
for a given ForeignScan node in postgresReScanForeignScan() (if any) in  
cases where we would only reset the next_tuple counter in that function,  
contradicting the assumption that there should be no pending  
asynchronous requests that have been made for async-capable subplans for  
the parent Append node after ReScan.  This led to an assert failure in  
an assert-enabled build.  I think this would also lead to mis-rewinding  
the cursor in that function in the case where we have already fetched  
one batch for the ForeignScan node and the asynchronous request has been  
made for the second batch, because even in that case we would just reset  
the counter when called from that function, so we would fail to execute  
MOVE BACKWARD ALL.  
  
To fix, modify that function to process the asynchronous request before  
restarting the scan.  
  
While at it, add a comment to a function to match other places.  
  
Per bug #17344 from Alexander Lakhin.  Back-patch to v14 where the  
aforesaid commit came in.  
  
Patch by me.  Test case by Alexander Lakhin, adjusted by me.  Reviewed  
and tested by Alexander Lakhin and Dmitry Dolgov.  
  
Discussion: https://postgr.es/m/17344-226b78b00de73a7e@postgresql.org  

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

On sparc64+ext4, suppress test failures from known WAL read failure.

commit   : d94a95cce9eb8582f3bb48fd745f21749b317e83    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Wed, 26 Jan 2022 18:06:19 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Wed, 26 Jan 2022 18:06:19 -0800    

Click here for diff

Buildfarm members kittiwake, tadarida and snapper began to fail  
frequently when commits 3cd9c3b921977272e6650a5efbeade4203c4bca2 and  
f47ed79cc8a0cfa154dc7f01faaf59822552363f added tests of concurrency, but  
the problem was reachable before those commits.  Back-patch to v10 (all  
supported versions).  
  
Discussion: https://postgr.es/m/20220116210241.GC756210@rfd.leadboat.com  

M contrib/amcheck/t/003_cic_2pc.pl
M src/test/perl/TestLib.pm

Fix pg_hba_file_rules for authentication method cert

commit   : 4afae689ead4ffbfdbaac1cd72794c729446596e    
  
author   : Magnus Hagander <magnus@hagander.net>    
date     : Wed, 26 Jan 2022 09:52:41 +0100    
  
committer: Magnus Hagander <magnus@hagander.net>    
date     : Wed, 26 Jan 2022 09:52:41 +0100    

Click here for diff

For authentication method cert, clientcert=verify-full is implied. But  
the pg_hba_file_rules entry would incorrectly show clientcert=verify-ca.  
  
Per bug #17354  
  
Reported-By: Feike Steenbergen  
Reviewed-By: Jonathan Katz  
Backpatch-through: 12  

M src/backend/libpq/hba.c

Revert "graceful shutdown" changes for Windows, in back branches only.

commit   : 75674c7ec1b1607e7013b5cebcb22d9c8b4b2cb6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 25 Jan 2022 12:17:40 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 25 Jan 2022 12:17:40 -0500    

Click here for diff

This reverts commits 6051857fc and ed52c3707, but only in the back  
branches.  Further testing has shown that while those changes do fix  
some things, they also break others; in particular, it looks like  
walreceivers fail to detect walsender-initiated connection close  
reliably if the walsender shuts down this way.  We'll keep trying to  
improve matters in HEAD, but it now seems unwise to push these changes  
into stable releases.  
  
Discussion: https://postgr.es/m/CA+hUKG+OeoETZQ=Qw5Ub5h3tmwQhBmDA=nuNO3KG=zWfUypFAw@mail.gmail.com  

M src/backend/libpq/pqcomm.c

Consider parallel awareness when removing single-child Appends

commit   : 357ff66153b4791d32c45724d8a0d3c91d89c937    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 25 Jan 2022 21:14:27 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 25 Jan 2022 21:14:27 +1300    

Click here for diff

8edd0e794 added some code to remove Append and MergeAppend nodes when they  
contained a single child node.  As it turned out, this was unsafe to do  
when the Append/MergeAppend was parallel_aware and the child node was not.  
Removing the Append/MergeAppend, in this case, could lead to the child plan  
being called multiple times by parallel workers when it was unsafe to do  
so.  
  
Here we fix this by just not removing the Append/MergeAppend when the  
parallel_aware flag of the parent and child node don't match.  
  
Reported-by: Yura Sokolov  
Bug: #17335  
Discussion: https://postgr.es/m/b59605fecb20ba9ea94e70ab60098c237c870628.camel%40postgrespro.ru  
Backpatch-through: 12, where 8edd0e794 was first introduced  

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

doc: Fix some grammar

commit   : 29d9da36b7b132476ef7b31a5dace7bc7410cc82    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 25 Jan 2022 10:49:30 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 25 Jan 2022 10:49:30 +0900    

Click here for diff

This is an extraction of the user-visible changes done in 410aa24,  
including all the relevant documentation parts.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/20220124030001.GQ23027@telsasoft.com  
Backpatch-through: 10  

M doc/src/sgml/config.sgml
M doc/src/sgml/ddl.sgml
M doc/src/sgml/perform.sgml
M doc/src/sgml/protocol.sgml
M doc/src/sgml/ref/pg_receivewal.sgml
M doc/src/sgml/ref/select_into.sgml

Fix limitations on what SQL commands can be issued to a walsender.

commit   : 1efcc5946d595a168a1abf737030f2e0ee1f4d43    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 24 Jan 2022 15:33:34 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 24 Jan 2022 15:33:34 -0500    

Click here for diff

In logical replication mode, a WalSender is supposed to be able  
to execute any regular SQL command, as well as the special  
replication commands.  Poor design of the replication-command  
parser caused it to fail in various cases, notably:  
  
* semicolons embedded in a command, or multiple SQL commands  
sent in a single message;  
  
* dollar-quoted literals containing odd numbers of single  
or double quote marks;  
  
* commands starting with a comment.  
  
The basic problem here is that we're trying to run repl_scanner.l  
across the entire input string even when it's not a replication  
command.  Since repl_scanner.l does not understand all of the  
token types known to the core lexer, this is doomed to have  
failure modes.  
  
We certainly don't want to make repl_scanner.l as big as scan.l,  
so instead rejigger stuff so that we only lex the first token of  
a non-replication command.  That will usually look like an IDENT  
to repl_scanner.l, though a comment would end up getting reported  
as a '-' or '/' single-character token.  If the token is a replication  
command keyword, we push it back and proceed normally with repl_gram.y  
parsing.  Otherwise, we can drop out of exec_replication_command()  
without examining the rest of the string.  
  
(It's still theoretically possible for repl_scanner.l to fail on  
the first token; but that could only happen if it's an unterminated  
single- or double-quoted string, in which case you'd have gotten  
largely the same error from the core lexer too.)  
  
In this way, repl_gram.y isn't involved at all in handling general  
SQL commands, so we can get rid of the SQLCmd node type.  (In  
the back branches, we can't remove it because renumbering enum  
NodeTag would be an ABI break; so just leave it sit there unused.)  
  
I failed to resist the temptation to clean up some other sloppy  
coding in repl_scanner.l while at it.  The only externally-visible  
behavior change from that is it now accepts \r and \f as whitespace,  
same as the core lexer.  
  
Per bug #17379 from Greg Rychlewski.  Back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/17379-6a5c6cfb3f1f5e77@postgresql.org  

M src/backend/replication/repl_gram.y
M src/backend/replication/repl_scanner.l
M src/backend/replication/walsender.c
M src/include/replication/walsender_private.h

Remember to reset yy_start state when firing up repl_scanner.l.

commit   : ef9706bbc8ce917a366e4640df8c603c9605817a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 24 Jan 2022 12:09:46 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 24 Jan 2022 12:09:46 -0500    

Click here for diff

Without this, we get odd behavior when the previous cycle of  
lexing exited in a non-default exclusive state.  Every other  
copy of this code is aware that it has to do BEGIN(INITIAL),  
but repl_scanner.l did not get that memo.  
  
The real-world impact of this is probably limited, since most  
replication clients would abandon their connection after getting  
a syntax error.  Still, it's a bug.  
  
This mistake is old, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/1874781.1643035952@sss.pgh.pa.us  

M src/backend/replication/repl_scanner.l

pg_dump: avoid useless query in binary_upgrade_set_type_oids_by_type_oid

commit   : 1042de69dbb6f3c0aa92a741a68aeca23f4ed45e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 23 Jan 2022 13:54:24 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 23 Jan 2022 13:54:24 -0500    

Click here for diff

Commit 6df7a9698 wrote appendPQExpBuffer where it should have  
written printfPQExpBuffer.  This resulted in re-issuing the  
previous query along with the desired one, which very accidentally  
had no negative consequences except for some wasted cycles.  
  
Back-patch to v14 where that came in.  
  
Discussion: https://postgr.es/m/1714711.1642962663@sss.pgh.pa.us  

M src/bin/pg_dump/pg_dump.c

Suppress variable-set-but-not-used warning from clang 13.

commit   : ef4edf88df6592b6a29649f3ae69d44cef478291    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 23 Jan 2022 11:09:00 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 23 Jan 2022 11:09:00 -0500    

Click here for diff

In the normal configuration where GEQO_DEBUG isn't defined,  
recent clang versions have started to complain that geqo_main.c  
accumulates the edge_failures count but never does anything  
with it.  As a minimal back-patchable fix, insert a void cast  
to silence this warning.  (I'd speculated about ripping out the  
GEQO_DEBUG logic altogether, but I don't think we'd wish to  
back-patch that.)  
  
Per recently-established project policy, this is a candidate  
for back-patching into out-of-support branches: it suppresses  
an annoying compiler warning but changes no behavior.  Hence,  
back-patch all the way to 9.2.  
  
Discussion: https://postgr.es/m/CA+hUKGLTSZQwES8VNPmWO9AO0wSeLt36OCPDAZTccT1h7Q7kTQ@mail.gmail.com  

M src/backend/optimizer/geqo/geqo_main.c

Correct type of front_pathkey to PathKey

commit   : 72ac4d71b54fdac5efc9ecfc23663f26c20ddcf9    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sun, 23 Jan 2022 03:36:55 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sun, 23 Jan 2022 03:36:55 +0100    

Click here for diff

In sort_inner_and_outer we iterate a list of PathKey elements, but the  
variable is declared as (List *). This mistake is benign, because we  
only pass the pointer to lcons() and never dereference it.  
  
This exists since ~2004, but it's confusing. So fix and backpatch to all  
supported branches.  
  
Backpatch-through: 10  
Discussion: https://postgr.es/m/bf3a6ea1-a7d8-7211-0669-189d5c169374%40enterprisedb.com  

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

Check syscache result in AlterStatistics

commit   : a192243c75be0f142f829b3e73548bc7cbd3b90d    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sun, 23 Jan 2022 02:49:41 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sun, 23 Jan 2022 02:49:41 +0100    

Click here for diff

The syscache lookup may return NULL even for valid OID, for example due  
to a concurrent DROP STATISTICS, so a HeapTupleIsValid is necessary.  
Without it, it may fail with a segfault.  
  
Reported by Alexander Lakhin, patch by me. Backpatch to 13, where ALTER  
STATISTICS ... SET STATISTICS was introduced.  
  
Backpatch-through: 13  
Discussion: https://postgr.es/m/17372-bf3b6e947e35ae77%40postgresql.org  

M src/backend/commands/statscmds.c

Flush table's relcache during ALTER TABLE ADD PRIMARY KEY USING INDEX.

commit   : 3839e29c58b44639bb6800f3415af87f4d1fb655    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 22 Jan 2022 13:32:40 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 22 Jan 2022 13:32:40 -0500    

Click here for diff

Previously, unless we had to add a NOT NULL constraint to the column,  
this command resulted in updating only the index's relcache entry.  
That's problematic when replication behavior is being driven off the  
existence of a primary key: other sessions (and ours too for that  
matter) failed to recalculate their opinion of whether the table can  
be replicated.  Add a relcache invalidation to fix it.  
  
This has been broken since pg_class.relhaspkey was removed in v11.  
Before that, updating the table's relhaspkey value sufficed to cause  
a cache flush.  Hence, backpatch to v11.  
  
Report and patch by Hou Zhijie  
  
Discussion: https://postgr.es/m/OS0PR01MB5716EBE01F112C62F8F9B786947B9@OS0PR01MB5716.jpnprd01.prod.outlook.com  

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

Fix race condition in gettext() initialization in libpq and ecpglib.

commit   : f4ebf0dbea835da85c21988321258a587a567dbd    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 21 Jan 2022 15:36:12 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 21 Jan 2022 15:36:12 -0500    

Click here for diff

In libpq and ecpglib, multiple threads can concurrently enter the  
initialization logic for message localization.  Since we set the  
its-done flag before actually doing the work, it'd be possible  
for some threads to reach gettext() before anyone has called  
bindtextdomain().  Barring bugs in libintl itself, this would not  
result in anything worse than failure to localize some early  
messages.  Nonetheless, it's a bug, and an easy one to fix.  
  
Noted while investigating bug #17299 from Clemens Zeidler  
(much thanks to Liam Bowen for followup investigation on that).  
It currently appears that that actually *is* a bug in libintl itself,  
but that doesn't let us off the hook for this bit.  
  
Back-patch to all supported versions.  
  
Discussion: https://postgr.es/m/17299-7270741958c0b1ab@postgresql.org  
Discussion: https://postgr.es/m/CAE7q7Eit4Eq2=bxce=Fm8HAStECjaXUE=WBQc-sDDcgJQ7s7eg@mail.gmail.com  

M src/interfaces/ecpg/ecpglib/misc.c
M src/interfaces/libpq/fe-misc.c

fsync pg_logical/mappings in CheckPointLogicalRewriteHeap().

commit   : 2b7dbe4bd5872ae5c6780e1a4121c2a5a8401e7c    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 21 Jan 2022 11:22:55 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 21 Jan 2022 11:22:55 -0800    

Click here for diff

While individual logical rewrite files were synced to disk, the directory was  
not. On some filesystems that could lead to loosing directory entries after a  
crash.  
  
Reported-By: Tom Lane <tgl@sss.pgh.pa.us>  
Author: Nathan Bossart <bossartn@amazon.com>  
Discussion: https://postgr.es/m/867F2E29-2782-4869-970E-B984C6D35A8F@amazon.com  
Backpatch: 10-  

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

postgres_fdw: Fix subabort cleanup of connections used in asynchronous execution.

commit   : 700e8fe6d414ebaf9820fef364097d9b83cae7fd    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 21 Jan 2022 17:45:02 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 21 Jan 2022 17:45:02 +0900    

Click here for diff

Commit 27e1f1456 resets the per-connection states of connections used to  
scan foreign tables asynchronously during abort cleanup at main  
transaction end, but it failed to do so during subabort cleanup at  
subtransaction end, leading to a segmentation fault when re-executing an  
asynchronous-foreign-table-scan query in a transaction that was  
cancelled in a subtransaction of it.  
  
Fix by modifying pgfdw_abort_cleanup() to reset the per-connection state  
of a given connection also when called for subabort cleanup.  Also,  
modify that function to do the reset in both the abort-cleanup and  
subabort-cleanup cases if necessary, to save cycles, and improve a  
comment on it a little bit.  
  
Back-patch to v14 where the aforesaid commit came in.  
  
Reviewed by Alexander Pyhalov  
  
Discussion: https://postgr.es/m/CAPmGK14cCV-JA7kNsyt2EUTKvZ4xkr2LNRthi1U1C3cqfGppAw@mail.gmail.com  

M contrib/postgres_fdw/connection.c

Fix one-off bug causing missing commit timestamps for subtransactions

commit   : 84db5169d4715904b0bffa25509f3c77fcd52188    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Jan 2022 14:54:47 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Jan 2022 14:54:47 +0900    

Click here for diff

The logic in charge of writing commit timestamps (enabled with  
track_commit_timestamp) for subtransactions had a one-bug bug,  
where it would be possible that commit timestamps go missing for the  
last subtransaction committed.  
  
While on it, simplify a bit the iteration logic in the loop writing the  
commit timestamps, as per suggestions from Kyotaro Horiguchi and Tom  
Lane, so as some variable initializations are not part of the loop  
itself.  
  
Issue introduced in 73c986a.  
  
Analyzed-by: Alex Kingsborough  
Author: Alex Kingsborough, Kyotaro Horiguchi  
Discussion: https://postgr.es/m/73A66172-4050-4F2A-B7F1-13508EDA2144@amazon.com  
Backpatch-through: 10  

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

Tighten TAP tests' tracking of postmaster state some more.

commit   : cf680bd6538a5a05020ab4d193b43563e9eb0c5e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Jan 2022 17:28:07 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Jan 2022 17:28:07 -0500    

Click here for diff

Commits 6c4a8903b et al. had a couple of deficiencies:  
  
* The logic I added to Cluster::start to see if a PID file is present  
could be fooled by a stale PID file left over from a previous  
postmaster.  To fix, if we're not sure whether we expect to find a  
running postmaster or not, validate the PID using "kill 0".  
  
* 017_shm.pl has a loop in which it just issues repeated Cluster::start  
calls; this will fail if some invocation fails but leaves self->_pid  
set.  Per buildfarm results, the above fix is not enough to make this  
safe: we might have "validated" a PID for a postmaster that exits  
immediately after we look.  Hence, match each failed start call with  
a stop call that will get us back to the self->_pid == undef state.  
Add a fail_ok option to Cluster::stop to make this work.  
  
Discussion: https://postgr.es/m/CA+hUKGKV6fOHvfiPt8=dOKzvswjAyLoFoJF1iQXMNpi7+hD1JQ@mail.gmail.com  

M src/test/perl/PostgresNode.pm
M src/test/recovery/t/017_shm.pl

Allow clean.bat to be run from anywhere

commit   : 156a846d93ee2dab365a89ddd1469ef7a9d1b92e    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 20 Jan 2022 10:13:18 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 20 Jan 2022 10:13:18 -0500    

Click here for diff

This was omitted from c3879a7b4c which modified the other msvc .bat  
files.  
  
Per request from Juan José Santamaría Flecha  
  
Discussion: https://postgr.es/m/CAC+AXB0_fxYGbQoaYjCA8um7TTbOVP4L9aXnVmHwK8WzaT4gdA@mail.gmail.com  
  
Backpatch to all live branches.  

M src/tools/msvc/clean.bat

Try to stabilize reloptions test, again.

commit   : b9dd162205bf2e1a20ce21a80e6ea497c7980ffe    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 20 Jan 2022 22:11:48 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 20 Jan 2022 22:11:48 +1300    

Click here for diff

Since the test requires reproducible behavior from VACUUM, and since  
DISABLE_PAGE_SKIPPING doesn't actually disable all forms of page  
skipping, let's use a temporary table to avoid contention.  
  
Back-patch to 12, like commit 3414099c.  
  
Discussion: https://postgr.es/m/20220120052404.sonrhq3f3qgplpzj%40alap3.anarazel.de  

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

doc: Mention the level of locks taken on objects in COMMENT

commit   : a9009f59fff148b11588cfccdc3989d3363cfab1    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Jan 2022 16:54:54 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Jan 2022 16:54:54 +0900    

Click here for diff

This information was nowhere to be found.  This adds one note on the  
page of COMMENT, and one note in the section dedicated to explicit  
locking, both telling that a SHARE UPDATE EXCLUSIVE lock is taken on the  
object commented.  
  
Author: Nikolai Berkoff  
Reviewed-by: Laurenz Albe  
Discussion: https://postgr.es/m/_0HDHIGcCdCsUyXn22QwI2FEuNR6Fs71rtgGX6hfyBlUh5rrnE2qMmvIFu9EY4Pijr2gUmJEAXCjuNU2Oxku9TryLp9CdHllpsCfN3gD0-Y=@pm.me  
Backpatch-through: 10  

M doc/src/sgml/mvcc.sgml
M doc/src/sgml/ref/comment.sgml

TAP tests: check for postmaster.pid anyway when "pg_ctl start" fails.

commit   : b0623625a0a30d66e991deab6488c59bb63ea20e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Jan 2022 16:29:09 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Jan 2022 16:29:09 -0500    

Click here for diff

"pg_ctl start" might start a new postmaster and then return failure  
anyway, for example if PGCTLTIMEOUT is exceeded.  If there is a  
postmaster there, it's still incumbent on us to shut it down at  
script end, so check for the PID file even though we are about  
to fail.  
  
This has been broken all along, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/647439.1642622744@sss.pgh.pa.us  

M src/test/perl/PostgresNode.pm

doc: Fix description of pg_replication_origin_oid() in error case

commit   : 0f1367c9f381aae523f6557c0ee28a800b3eace7    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Jan 2022 10:37:47 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Jan 2022 10:37:47 +0900    

Click here for diff

This function returns NULL if the replication origin given in input  
argument does not exist, contrary to what the docs described  
previously.  
  
Author: Ian Barwick  
Discussion: https://postgr.es/m/CAB8KJ=htJjBL=103URqjOxV2mqb4rjphDpMeKdyKq_QXt6h05w@mail.gmail.com  
Backpatch-through: 10  

M doc/src/sgml/func.sgml

Try to stabilize the reloptions test.

commit   : ff4d0d8cc5e2e3823bf3428e707ee33c13d401f6    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 19 Jan 2022 07:03:01 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 19 Jan 2022 07:03:01 +1300    

Click here for diff

Where we test vacuum_truncate's effects, sometimes this is failing to  
truncate as expected on the build farm.  That could be explained by page  
skipping, so disable it explicitly, with the theory that commit fe246d1c  
didn't go far enough.  
  
Back-patch to 12, where the vacuum_truncate tests were added.  
  
Discussion: https://postgr.es/m/CA%2BhUKGLT2UL5_JhmBzUgkdyKfc%3D5J-gJSQJLysMs4rqLUKLAzw%40mail.gmail.com  

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

Fix psql \d's query for identifying parent triggers.

commit   : 3886785b4ce59147b92319e7204ab64a9d8801cb    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Jan 2022 21:18:49 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Jan 2022 21:18:49 -0500    

Click here for diff

The original coding (from c33869cc3) failed with "more than one row  
returned by a subquery used as an expression" if there were unrelated  
triggers of the same tgname on parent partitioned tables.  (That's  
possible because statement-level triggers don't get inherited.)  Fix  
by applying LIMIT 1 after sorting the candidates by inheritance level.  
  
Also, wrap the subquery in a CASE so that we don't have to execute it at  
all when the trigger is visibly non-inherited.  Aside from saving some  
cycles, this avoids the need for a confusing and undocumented NULLIF().  
  
While here, tweak the format of the emitted query to look a bit  
nicer for "psql -E", and add some explanation of this subquery,  
because it badly needs it.  
  
Report and patch by Justin Pryzby (with some editing by me).  
Back-patch to v13 where the faulty code came in.  
  
Discussion: https://postgr.es/m/20211217154356.GJ17618@telsasoft.com  

M src/bin/psql/describe.c
M src/test/regress/expected/triggers.out
M src/test/regress/sql/triggers.sql

Avoid calling gettext() in signal handlers.

commit   : 4e8726566e4d7c0e712d16c0dc7a27d212ece090    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Jan 2022 13:30:04 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Jan 2022 13:30:04 -0500    

Click here for diff

It seems highly unlikely that gettext() can be relied on to be  
async-signal-safe.  psql used to understand that, but someone got  
it wrong long ago in the src/bin/scripts/ version of handle_sigint,  
and then the bad idea was perpetuated when those two versions were  
unified into src/fe_utils/cancel.c.  
  
I'm unsure why there have not been field complaints about this  
... maybe gettext() is signal-safe once it's translated at least  
one message?  But we have no business assuming any such thing.  
  
In cancel.c (v13 and up), I preserved our ability to localize  
"Cancel request sent" messages by invoking gettext() before  
the signal handler is set up.  In earlier branches I just made  
src/bin/scripts/ not localize those messages, as psql did then.  
  
(Just for extra unsafety, the src/bin/scripts/ version was  
invoking fprintf() from a signal handler.  Sigh.)  
  
Noted while fixing signal-safety issues in PQcancel() itself.  
Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/2937814.1641960929@sss.pgh.pa.us  

M src/fe_utils/cancel.c

Avoid calling strerror[_r] in PQcancel().

commit   : 050949877004f003b7d95fddf8f572a32f3a2f70    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Jan 2022 12:52:44 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Jan 2022 12:52:44 -0500    

Click here for diff

PQcancel() is supposed to be safe to call from a signal handler,  
and indeed psql uses it that way.  All of the library functions  
it uses are specified to be async-signal-safe by POSIX ...  
except for strerror.  Neither plain strerror nor strerror_r  
are considered safe.  When this code was written, back in the  
dark ages, we probably figured "oh, strerror will just index  
into a constant array of strings" ... but in any locale except C,  
that's unlikely to be true.  Probably the reason we've not heard  
complaints is that (a) this error-handling code is unlikely to be  
reached in normal use, and (b) in many scenarios, localized error  
strings would already have been loaded, after which maybe it's  
safe to call strerror here.  Still, this is clearly unacceptable.  
  
The best we can do without relying on strerror is to print the  
decimal value of errno, so make it do that instead.  (This is  
probably not much loss of user-friendliness, given that it is  
hard to get a failure here.)  
  
Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/2937814.1641960929@sss.pgh.pa.us  

M src/interfaces/libpq/fe-connect.c

Teach hash_ok_operator() that record_eq is only sometimes hashable.

commit   : 17da9d4c28297fd699cbbda969a9f64c4c09c665    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 16 Jan 2022 16:39:26 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 16 Jan 2022 16:39:26 -0500    

Click here for diff

The need for this was foreseen long ago, but when record_eq  
actually became hashable (in commit 01e658fa7), we missed updating  
this spot.  
  
Per bug #17363 from Elvis Pranskevichus.  Back-patch to v14 where  
the faulty commit came in.  
  
Discussion: https://postgr.es/m/17363-f6d42fd0d726be02@postgresql.org  

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

Fix psql's tab-completion of enum label values.

commit   : d91d4338e05486f943361260b9d4ad54421d3b44    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 16 Jan 2022 14:59:20 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 16 Jan 2022 14:59:20 -0500    

Click here for diff

Since enum labels have to be single-quoted, this part of the  
tab completion machinery got side-swiped by commit cd69ec66c.  
A side-effect of that commit is that (at least with some versions  
of Readline) the text string passed for completion will omit the  
leading quote mark of the enum label literal.  Libedit still acts  
the same as before, though, so adapt COMPLETE_WITH_ENUM_VALUE so  
that it can cope with either convention.  
  
Also, when we fail to find any valid completion, set  
rl_completion_suppress_quote = 1.  Otherwise readline will  
go ahead and append a closing quote, which is unwanted.  
  
Per report from Peter Eisentraut.  Back-patch to v13 where  
cd69ec66c came in.  
  
Discussion: https://postgr.es/m/8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com  

M src/bin/psql/t/010_tab_completion.pl
M src/bin/psql/tab-complete.c

Build inherited extended stats on partitioned tables

commit   : ea212bd95fd2456953ca8995cf2a04d3db82ac19    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sat, 15 Jan 2022 18:17:20 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sat, 15 Jan 2022 18:17:20 +0100    

Click here for diff

Commit 859b3003de disabled building of extended stats for inheritance  
trees, to prevent updating the same catalog row twice. While that  
resolved the issue, it also means there are no extended stats for  
declaratively partitioned tables, because there are no data in the  
non-leaf relations.  
  
That also means declaratively partitioned tables were not affected by  
the issue 859b3003de addressed, which means this is a regression  
affecting queries that calculate estimates for the whole inheritance  
tree as a whole (which includes e.g. GROUP BY queries).  
  
But because partitioned tables are empty, we can invert the condition  
and build statistics only for the case with inheritance, without losing  
anything. And we can consider them when calculating estimates.  
  
It may be necessary to run ANALYZE on partitioned tables, to collect  
proper statistics. For declarative partitioning there should no prior  
statistics, and it might take time before autoanalyze is triggered. For  
tables partitioned by inheritance the statistics may include data from  
child relations (if built 859b3003de), contradicting the current code.  
  
Report and patch by Justin Pryzby, minor fixes and cleanup by me.  
Backpatch all the way back to PostgreSQL 10, where extended statistics  
were introduced (same as 859b3003de).  
  
Author: Justin Pryzby  
Reported-by: Justin Pryzby  
Backpatch-through: 10  
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com  

M src/backend/commands/analyze.c
M src/backend/statistics/dependencies.c
M src/backend/statistics/extended_stats.c
M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

Ignore extended statistics for inheritance trees

commit   : 2cc007fd0359870b4a1e959af0ac94e61df47240    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sat, 15 Jan 2022 02:15:23 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sat, 15 Jan 2022 02:15:23 +0100    

Click here for diff

Since commit 859b3003de we only build extended statistics for individual  
relations, ignoring the child relations. This resolved the issue with  
updating catalog tuple twice, but we still tried to use the statistics  
when calculating estimates for the whole inheritance tree. When the  
relations contain very distinct data, it may produce bogus estimates.  
  
This is roughly the same issue 427c6b5b9 addressed ~15 years ago, and we  
fix it the same way - by ignoring extended statistics when calculating  
estimates for the inheritance tree as a whole. We still consider  
extended statistics when calculating estimates for individual child  
relations, of course.  
  
This may result in plan changes due to different estimates, but if the  
old statistics were not describing the inheritance tree particularly  
well it's quite likely the new plans is actually better.  
  
Report and patch by Justin Pryzby, minor fixes and cleanup by me.  
Backpatch all the way back to PostgreSQL 10, where extended statistics  
were introduced (same as 859b3003de).  
  
Author: Justin Pryzby  
Reported-by: Justin Pryzby  
Backpatch-through: 10  
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com  

M src/backend/statistics/dependencies.c
M src/backend/statistics/extended_stats.c
M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

Fix possible HOT corruption when RECENTLY_DEAD changes to DEAD while pruning.

commit   : dad1539aec28ae3d024b00ae322f02f7fe0c41ee    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 10 Dec 2021 20:12:26 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 10 Dec 2021 20:12:26 -0800    

Click here for diff

Since dc7420c2c92 the horizon used for pruning is determined "lazily". A more  
accurate horizon is built on-demand, rather than in GetSnapshotData(). If a  
horizon computation is triggered between two HeapTupleSatisfiesVacuum() calls  
for the same tuple, the result can change from RECENTLY_DEAD to DEAD.  
  
heap_page_prune() can process the same tid multiple times (once following an  
update chain, once "directly"). When the result of HeapTupleSatisfiesVacuum()  
of a tuple changes from RECENTLY_DEAD during the first access, to DEAD in the  
second, the "tuple is DEAD and doesn't chain to anything else" path in  
heap_prune_chain() can end up marking the target of a LP_REDIRECT ItemId  
unused.  
  
Initially not easily visible,  
Once the target of a LP_REDIRECT ItemId is marked unused, a new tuple version  
can reuse it. At that point the corruption may become visible, as index  
entries pointing to the "original" redirect item, now point to a unrelated  
tuple.  
  
To fix, compute HTSV for all tuples on a page only once. This fixes the entire  
class of problems of HTSV changing inside heap_page_prune(). However,  
visibility changes can obviously still occur between HTSV checks inside  
heap_page_prune() and outside (e.g. in lazy_scan_prune()).  
  
The computation of HTSV is now done in bulk, in heap_page_prune(), rather than  
on-demand in heap_prune_chain(). Besides being a bit simpler, it also is  
faster: Memory accesses can happen sequentially, rather than in the order of  
HOT chains.  
  
There are other causes of HeapTupleSatisfiesVacuum() results changing between  
two visibility checks for the same tuple, even before dc7420c2c92. E.g.  
HEAPTUPLE_INSERT_IN_PROGRESS can change to HEAPTUPLE_DEAD when a transaction  
aborts between the two checks. None of the these other visibility status  
changes are known to cause corruption, but heap_page_prune()'s approach makes  
it hard to be confident.  
  
A patch implementing a more fundamental redesign of heap_page_prune(), which  
fixes this bug and simplifies pruning substantially, has been proposed by  
Peter Geoghegan in  
https://postgr.es/m/CAH2-WzmNk6V6tqzuuabxoxM8HJRaWU6h12toaS-bqYcLiht16A@mail.gmail.com  
  
However, that redesign is larger change than desirable for backpatching. As  
the new design still benefits from the batched visibility determination  
introduced in this commit, it makes sense to commit this narrower fix to 14  
and master, and then commit Peter's improvement in master.  
  
The precise sequence required to trigger the bug is complicated and hard to do  
exercise in an isolation test (until we have wait points). Due to that the  
isolation test initially posted at  
https://postgr.es/m/20211119003623.d3jusiytzjqwb62p%40alap3.anarazel.de  
and updated in  
https://postgr.es/m/20211122175914.ayk6gg6nvdwuhrzb%40alap3.anarazel.de  
isn't committable.  
  
A followup commit will introduce additional assertions, to detect problems  
like this more easily.  
  
Bug: #17255  
Reported-By: Alexander Lakhin <exclusion@gmail.com>  
Debugged-By: Andres Freund <andres@anarazel.de>  
Debugged-By: Peter Geoghegan <pg@bowt.ie>  
Author: Andres Freund <andres@andres@anarazel.de>  
Reviewed-By: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/20211122175914.ayk6gg6nvdwuhrzb@alap3.anarazel.de  
Backpatch: 14-, the oldest branch containing dc7420c2c92  

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

Revert error handling improvements for cryptohashes

commit   : ad5b6f248ab288c3252d8122d12a1eb410d4a0b6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Jan 2022 11:25:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Jan 2022 11:25:39 +0900    

Click here for diff

This reverts commits ab27df2, af8d530 and 3a0cced, that introduced  
pg_cryptohash_error().  In order to make the core code able to pass down  
the new error types that this introduced, some of the MD5-related  
routines had to be reworked, causing an ABI breakage, but we found that  
some external extensions rely on them.  Maintaining compatibility  
outweights the error report benefits, so just revert the change in v14.  
  
Reported-by: Laurenz Albe  
Discussion: https://postgr.es/m/9f0c0a96d28cf14fc87296bbe67061c14eb53ae8.camel@cybertec.at  

M contrib/passwordcheck/passwordcheck.c
M contrib/pgcrypto/internal-sha2.c
M contrib/pgcrypto/internal.c
M contrib/uuid-ossp/uuid-ossp.c
M src/backend/commands/user.c
M src/backend/libpq/auth-scram.c
M src/backend/libpq/auth.c
M src/backend/libpq/crypt.c
M src/backend/replication/backup_manifest.c
M src/backend/utils/adt/cryptohashfuncs.c
M src/common/cryptohash.c
M src/common/cryptohash_openssl.c
M src/common/md5_common.c
M src/include/common/cryptohash.h
M src/include/common/md5.h
M src/include/libpq/crypt.h
M src/include/libpq/scram.h
M src/interfaces/libpq/fe-auth.c
M src/tools/pgindent/typedefs.list

Fix ruleutils.c's dumping of whole-row Vars in more contexts.

commit   : 4aee39ddb8fa748a6beea2bc1b48882990c226a7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 13 Jan 2022 17:49:26 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 13 Jan 2022 17:49:26 -0500    

Click here for diff

Commit 7745bc352 intended to ensure that whole-row Vars would be  
printed with "::type" decoration in all contexts where plain  
"var.*" notation would result in star-expansion, notably in  
ROW() and VALUES() constructs.  However, it missed the case of  
INSERT with a single-row VALUES, as reported by Timur Khanjanov.  
  
Nosing around ruleutils.c, I found a second oversight: the  
code for RowCompareExpr generates ROW() notation without benefit  
of an actual RowExpr, and naturally it wasn't in sync :-(.  
(The code for FieldStore also does this, but we don't expect that  
to generate strictly parsable SQL anyway, so I left it alone.)  
  
Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/efaba6f9-4190-56be-8ff2-7a1674f9194f@intrans.baku.az  

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

Fix incorrect comments in hmac.c and hmac_openssl.c

commit   : 3c1ffd02dd058666ddf27d7e621ab5bbc4b769bb    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 13 Jan 2022 09:43:44 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 13 Jan 2022 09:43:44 +0900    

Click here for diff

Both files referred to pg_hmac_ctx->data, which, I guess, comes from the  
early versions of the patch that has resulted in commit e6bdfd9.  
  
Author: Sergey Shinderuk  
Discussion: https://postgr.es/m/8cbb56dd-63d6-a581-7a65-25a97ac4be03@postgrespro.ru  
Backpatch-through: 14  

M src/common/hmac.c
M src/common/hmac_openssl.c

Fix memory leak in indexUnchanged hint mechanism.

commit   : 41ee68a91f0fc8e1f6583e4f153d79578adb265c    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 12 Jan 2022 15:41:02 -0800    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 12 Jan 2022 15:41:02 -0800    

Click here for diff

Commit 9dc718bd added a "logically unchanged by UPDATE" hinting  
mechanism, which is currently used within nbtree indexes only (see  
commit d168b666).  This mechanism determined whether or not the incoming  
item is a logically unchanged duplicate (a duplicate needed only for  
MVCC versioning purposes) once per row updated per non-HOT update.  This  
approach led to memory leaks which were noticeable with an UPDATE  
statement that updated sufficiently many rows, at least on tables that  
happen to have an expression index.  
  
On HEAD, fix the issue by adding a cache to the executor's per-index  
IndexInfo struct.  
  
Take a different approach on Postgres 14 to avoid an ABI break: simply  
pass down the hint to all indexes unconditionally with non-HOT UPDATEs.  
This is deemed acceptable because the hint is currently interpreted  
within btinsert() as "perform a bottom-up index deletion pass if and  
when the only alternative is splitting the leaf page -- prefer to delete  
any LP_DEAD-set items first".  nbtree must always treat the hint as a  
noisy signal about what might work, as a strategy of last resort, with  
costs imposed on non-HOT updaters.  (The same thing might not be true  
within another index AM that applies the hint, which is why the original  
behavior is preserved on HEAD.)  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reported-By: Klaudie Willis <Klaudie.Willis@protonmail.com>  
Diagnosed-By: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/261065.1639497535@sss.pgh.pa.us  
Backpatch: 14-, where the hinting mechanism was added.  

M src/backend/executor/execIndexing.c

commit   : af8d530e47588d909a3c8d400b21a273e50498d6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Jan 2022 12:40:04 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Jan 2022 12:40:04 +0900    

Click here for diff

One of the comments introduced in b69aba7 was worded a bit weirdly, so  
improve it.  
  
Reported-by: Sergey Shinderuk  
Discussion: https://postgr.es/m/71b9a5d2-a3bf-83bc-a243-93dcf0bcfb3b@postgrespro.ru  
Backpatch-through: 14  

M src/common/cryptohash.c
M src/common/cryptohash_openssl.c

Clean up error message reported after \password encryption failure.

commit   : ab27df2490e3a5dfb8ecb3de66818d16645ef3dd    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 11 Jan 2022 12:03:06 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 11 Jan 2022 12:03:06 -0500    

Click here for diff

Experimenting with FIPS mode enabled, I saw  
  
regression=# \password joe  
Enter new password for user "joe":  
Enter it again:  
could not encrypt password: disabled for FIPS  
out of memory  
  
because PQencryptPasswordConn was still of the opinion that "out of  
memory" is always appropriate to print.  
  
Minor oversight in b69aba745.  Like that one, back-patch to v14.  

M src/interfaces/libpq/fe-auth.c

Improve error handling of cryptohash computations

commit   : 3a0cced86d3b1bbbf0aaa0fb34e2b15edd643979    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 11 Jan 2022 09:55:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 11 Jan 2022 09:55:24 +0900    

Click here for diff

The existing cryptohash facility was causing problems in some code paths  
related to MD5 (frontend and backend) that relied on the fact that the  
only type of error that could happen would be an OOM, as the MD5  
implementation used in PostgreSQL ~13 (the in-core implementation is  
used when compiling with or without OpenSSL in those older versions),  
could fail only under this circumstance.  
  
The new cryptohash facilities can fail for reasons other than OOMs, like  
attempting MD5 when FIPS is enabled (upstream OpenSSL allows that up to  
1.0.2, Fedora and Photon patch OpenSSL 1.1.1 to allow that), so this  
would cause incorrect reports to show up.  
  
This commit extends the cryptohash APIs so as callers of those routines  
can fetch more context when an error happens, by using a new routine  
called pg_cryptohash_error().  The error states are stored within each  
implementation's internal context data, so as it is possible to extend  
the logic depending on what's suited for an implementation.  The default  
implementation requires few error states, but OpenSSL could report  
various issues depending on its internal state so more is needed in  
cryptohash_openssl.c, and the code is shaped so as we are always able to  
grab the necessary information.  
  
The core code is changed to adapt to the new error routine, painting  
more "const" across the call stack where the static errors are stored,  
particularly in authentication code paths on variables that provide  
log details.  This way, any future changes would warn if attempting to  
free these strings.  The MD5 authentication code was also a bit blurry  
about the handling of "logdetail" (LOG sent to the postmaster), so  
improve the comments related that, while on it.  
  
The origin of the problem is 87ae969, that introduced the centralized  
cryptohash facility.  Extra changes are done for pgcrypto in v14 for the  
non-OpenSSL code path to cope with the improvements done by this  
commit.  
  
Reported-by: Michael Mühlbeyer  
Author: Michael Paquier  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/89B7F072-5BBE-4C92-903E-D83E865D9367@trivadis.com  
Backpatch-through: 14  

M contrib/passwordcheck/passwordcheck.c
M contrib/pgcrypto/internal-sha2.c
M contrib/pgcrypto/internal.c
M contrib/uuid-ossp/uuid-ossp.c
M src/backend/commands/user.c
M src/backend/libpq/auth-scram.c
M src/backend/libpq/auth.c
M src/backend/libpq/crypt.c
M src/backend/replication/backup_manifest.c
M src/backend/utils/adt/cryptohashfuncs.c
M src/common/cryptohash.c
M src/common/cryptohash_openssl.c
M src/common/md5_common.c
M src/include/common/cryptohash.h
M src/include/common/md5.h
M src/include/libpq/crypt.h
M src/include/libpq/scram.h
M src/interfaces/libpq/fe-auth.c
M src/tools/pgindent/typedefs.list

Doc: fix bogus example about ambiguous timestamps.

commit   : 05cdda68f8f6e63cb87bc1776236d7619cd89fb7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Jan 2022 11:46:16 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Jan 2022 11:46:16 -0500    

Click here for diff

I had a brain fade in commit d32899157, and used 2:30AM as the  
example timestamp for both spring-forward and fall-back cases.  
But it's not actually ambiguous at all in the fall-back case,  
because that transition is from 2AM to 1AM under USA rules.  
Fix the example to use 1:30AM, which *is* ambiguous.  
  
Noted while answering a question from Aleksander Alekseev.  
Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/2191355.1641828552@sss.pgh.pa.us  

M doc/src/sgml/datetime.sgml

Avoid warning about uninitialized value in MSVC python3 tests

commit   : 1cd46f168fda4d819e315eacf3d4f3d5aa84859c    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 10 Jan 2022 10:08:44 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 10 Jan 2022 10:08:44 -0500    

Click here for diff

Juan José Santamaría Flecha  
  
Backpatch to all live branches  

M src/tools/msvc/vcregress.pl

Fix results of index-only scans on btree_gist char(N) indexes.

commit   : 043c1e1a73aace8b459b3290ff7a50c9b124fb33    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 8 Jan 2022 14:54:39 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 8 Jan 2022 14:54:39 -0500    

Click here for diff

If contrib/btree_gist is used to make a GIST index on a char(N)  
(bpchar) column, and that column is retrieved via an index-only  
scan, what came out had all trailing spaces removed.  Since  
that doesn't happen in any other kind of table scan, this is  
clearly a bug.  The cause is that gbt_bpchar_compress() strips  
trailing spaces (using rtrim1) before a new index entry is made.  
That was probably a good idea when this code was first written,  
but since we invented index-only scans, it's not so good.  
  
One answer could be to mark this opclass as incapable of index-only  
scans.  But to do so, we'd need an extension module version bump,  
followed by manual action by DBAs to install the updated version  
of btree_gist.  And it's not really a desirable place to end up,  
anyway.  
  
Instead, let's fix the code by removing the unwanted space-stripping  
action and adjusting the opclass's comparison logic to ignore  
trailing spaces as bpchar normally does.  This will not hinder  
cases that work today, since index searches with this logic will  
act the same whether trailing spaces are stored or not.  It will  
not by itself fix the problem of getting space-stripped results  
from index-only scans, of course.  Users who care about that can  
REINDEX affected indexes after installing this update, to immediately  
replace all improperly-truncated index entries.  Otherwise, it can  
be expected that the index's behavior will change incrementally as  
old entries are replaced by new ones.  
  
Per report from Alexander Lakhin.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/696c995b-b37f-5526-f45d-04abe713179f@gmail.com  

M contrib/btree_gist/btree_text.c
M contrib/btree_gist/expected/char.out
M contrib/btree_gist/expected/char_1.out

Fix issues with describe queries of extended statistics in psql

commit   : f5bea8360691eeaef7ad3b6163b3e2bbb9c7c466    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 8 Jan 2022 16:45:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 8 Jan 2022 16:45:14 +0900    

Click here for diff

This addresses some problems in the describe queries used for extended  
statistics:  
- Two schema qualifications for the text type were missing for \dX.  
- The list of extended statistics listed for a table through \d was  
ordered based on the object OIDs, but it is more consistent with the  
other commands to order by namespace and then by object name.  
- A couple of aliases were not used in \d.  These are removed.  
  
This is similar to commits 1f092a3 and 07f8a9e.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/20220107022235.GA14051@telsasoft.com  
Backpatch-through: 14  

M src/bin/psql/describe.c

commit   : 61c8da50cb39ab41c3a7a0122d6943f72bb0798e    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 7 Jan 2022 19:04:56 -0500    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 7 Jan 2022 19:04:56 -0500    

Click here for diff

Backpatch-through: 10  

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

Allow MSVC .bat wrappers to be called from anywhere

commit   : a7772e8748a7783776f0095e0d7068bcf42e3d69    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 7 Jan 2022 16:07:45 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 7 Jan 2022 16:07:45 -0500    

Click here for diff

Instead of using a hardcoded or default path to the perl file the .bat  
file is a wrapper for, we use a path that means the file is found in  
the same directory as the .bat file.  
  
Patch by Anton Voloshin, slightly tweaked by me.  
  
Backpatch to all live branches  
  
Discussion: https://postgr.es/m/2b7a674b-5fb0-d264-75ef-ecc7a31e54f8@postgrespro.ru  

M src/tools/msvc/build.bat
M src/tools/msvc/install.bat
M src/tools/msvc/pgbison.bat
M src/tools/msvc/pgflex.bat
M src/tools/msvc/vcregress.bat

Prevent altering partitioned table's rowtype, if it's used elsewhere.

commit   : f285d95839e05608ee99dba399abe860d3c026c5    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 6 Jan 2022 16:46:46 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 6 Jan 2022 16:46:46 -0500    

Click here for diff

We disallow altering a column datatype within a regular table,  
if the table's rowtype is used as a column type elsewhere,  
because we lack code to go around and rewrite the other tables.  
This restriction should apply to partitioned tables as well, but it  
was not checked because ATRewriteTables and ATPrepAlterColumnType  
were not on the same page about who should do it for which relkinds.  
  
Per bug #17351 from Alexander Lakhin.  Back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/17351-6db1870f3f4f612a@postgresql.org  

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

commit   : 9ae0a4c702324110dde366f9370f9b6c02b4dee8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Jan 2022 11:41:40 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Jan 2022 11:41:40 +0900    

Click here for diff

The link used in the documentation is dead, and the only options to have  
an access to this part of the SQL specification are not free.  Like any  
other books referred, just remove the link to keep some neutrality but  
keep its reference.  
  
Reported-by: Erik Rijkers  
Discussion: https://postgr.es/m/989abd7d-af30-ab52-1201-bf0b4f33b872@xs4all.nl  
Backpatch-through: 12  

M doc/src/sgml/biblio.sgml

Reduce relcache access in WAL sender streaming logical changes

commit   : 5ddfebded41f7754b3c4fc1b576ca33736efcab6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 5 Jan 2022 10:27:47 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 5 Jan 2022 10:27:47 +0900    

Click here for diff

get_rel_sync_entry(), which is called each time a change needs to be  
logically replicated, is a rather hot code path in the WAL sender  
sending logical changes.  This code path was doing a relcache access on  
relkind and relpartition for each logical change, but we only need to  
know this information when building or re-building the cached  
information for a relation.  
  
Some measurements prove that this is noticeable in perf profiles,  
particularly when attempting to replicate changes from relations that  
are not published as these cause less overhead in the WAL sender,  
delaying further the replication of changes for relations that are  
published.  
  
Issue introduced in 83fd453.  
  
Author: Hou Zhijie  
Reviewed-by: Kyotaro Horiguchi, Euler Taveira  
Discussion: https://postgr.es/m/OS0PR01MB5716E863AA9E591C1F010F7A947D9@OS0PR01MB5716.jpnprd01.prod.outlook.com  
Backpatch-through: 13  

M src/backend/replication/pgoutput/pgoutput.c

Fix silly mistake in Assert

commit   : f9db153c282de599a7d5ae2694f50fe10fba8461    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 4 Jan 2022 13:21:23 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 4 Jan 2022 13:21:23 -0300    

Click here for diff

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

Allow special SKIP LOCKED condition in Assert()

commit   : f185f35a83d980033824c3522b7b97ab1c2de71e    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 4 Jan 2022 13:01:05 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Tue, 4 Jan 2022 13:01:05 -0300    

Click here for diff

Under concurrency, it is possible for two sessions to be merrily locking  
and releasing a tuple and marking it again as HEAP_XMAX_INVALID all the  
while a third session attempts to lock it, miserably fails at it, and  
then contemplates life, the universe and everything only to eventually  
fail an assertion that said bit is not set.  Before SKIP LOCKED that was  
indeed a reasonable expectation, but alas! commit df630b0dd5ea falsified  
it.  
  
This bug is as old as time itself, and even older, if you think time  
begins with the oldest supported branch.  Therefore, backpatch to all  
supported branches.  
  
Author: Simon Riggs <simon.riggs@enterprisedb.com>  
Discussion: https://postgr.es/m/CANbhV-FeEwMnN8yuMyss7if1ZKjOKfjcgqB26n8pqu1e=q0ebg@mail.gmail.com  

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

Fix index-only scan plans, take 2.

commit   : d228af79d0f206f9bd24856b2c1df0909c8db1ec    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 3 Jan 2022 15:42:27 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 3 Jan 2022 15:42:27 -0500    

Click here for diff

Commit 4ace45677 failed to fix the problem fully, because the  
same issue of attempting to fetch a non-returnable index column  
can occur when rechecking the indexqual after using a lossy index  
operator.  Moreover, it broke EXPLAIN for such indexquals (which  
indicates a gap in our test cases :-().  
  
Revert the code changes of 4ace45677 in favor of adding a new field  
to struct IndexOnlyScan, containing a version of the indexqual that  
can be executed against the index-returned tuple without using any  
non-returnable columns.  (The restrictions imposed by check_index_only  
guarantee this is possible, although we may have to recompute indexed  
expressions.)  Support construction of that during setrefs.c  
processing by marking IndexOnlyScan.indextlist entries as resjunk  
if they can't be returned, rather than removing them entirely.  
(We could alternatively require setrefs.c to look up the IndexOptInfo  
again, but abusing resjunk this way seems like a reasonably safe way  
to avoid needing to do that.)  
  
This solution isn't great from an API-stability standpoint: if there  
are any extensions out there that build IndexOnlyScan structs directly,  
they'll be broken in the next minor releases.  However, only a very  
invasive extension would be likely to do such a thing.  There's no  
change in the Path representation, so typical planner extensions  
shouldn't have a problem.  
  
As before, back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us  
Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org  

M src/backend/commands/explain.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/nodes/copyfuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/plan/setrefs.c
M src/backend/optimizer/plan/subselect.c
M src/include/nodes/execnodes.h
M src/include/nodes/plannodes.h
M src/test/regress/expected/gist.out
M src/test/regress/sql/gist.sql

pg_stat_statements: Remove obsolete comment

commit   : 52d50261dbd353a34027d057ce2e0b892922fa58    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 3 Jan 2022 17:34:53 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 3 Jan 2022 17:34:53 +0900    

Click here for diff

Since 4f0b096, pgss_store() does nothing if compute_query_id is disabled  
or if no other module computed a query identifier, but the top comment  
of this function did not reflect that.  This behavior is already  
documented in its own code path, and this just removes the inconsistent  
comment.  
  
Author: Kyotaro Horiguchi  
Reviewed-by: Julien Rouhaud  
Discussion: https://postgr.es/m/20211122.153823.1325120762360533122.horikyota.ntt@gmail.com  
Backpatch-through: 14  

M contrib/pg_stat_statements/pg_stat_statements.c

Fix typo

commit   : f0c5866113fb1d85ada6dc3fe67e4909d94bacc2    
  
author   : Magnus Hagander <magnus@hagander.net>    
date     : Sun, 2 Jan 2022 17:03:32 +0100    
  
committer: Magnus Hagander <magnus@hagander.net>    
date     : Sun, 2 Jan 2022 17:03:32 +0100    

Click here for diff

Reported-By: Eric Mutta  
Backpatch-through: 10  
Discussion: https://postgr.es/m/164052477973.21665.7888120874624887609@wrigleys.postgresql.org  

M doc/src/sgml/high-availability.sgml

Fix index-only scan plans when not all index columns can be returned.

commit   : cabea571d11e020c8c72dfb8ddced441745d7238    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 1 Jan 2022 16:12:03 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 1 Jan 2022 16:12:03 -0500    

Click here for diff

If an index has both returnable and non-returnable columns, and one of  
the non-returnable columns is an expression using a Var that is in a  
returnable column, then a query returning that expression could result  
in an index-only scan plan that attempts to read the non-returnable  
column, instead of recomputing the expression from the returnable  
column as intended.  
  
To fix, redefine the "indextlist" list of an IndexOnlyScan plan node  
as containing null Consts in place of any non-returnable columns.  
This solves the problem by preventing setrefs.c from falsely matching  
to such entries.  The executor is happy since it only cares about the  
exposed types of the entries, and ruleutils.c doesn't care because a  
correct plan won't reference those entries.  I considered some other  
ways to prevent setrefs.c from doing the wrong thing, but this way  
seems good since (a) it allows a very localized fix, (b) it makes  
the indextlist structure more compact in many cases, and (c) the  
indextlist is now a more faithful representation of what the index AM  
will actually produce, viz. nulls for any non-returnable columns.  
  
This is easier to hit since we introduced included columns, but it's  
possible to construct failing examples without that, as per the  
added regression test.  Hence, back-patch to all supported branches.  
  
Per bug #17350 from Louis Jachiet.  
  
Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org  

M src/backend/optimizer/plan/createplan.c
M src/include/nodes/plannodes.h
M src/test/regress/expected/gist.out
M src/test/regress/sql/gist.sql

Revert b2a459edf "Fix GRANTED BY support in REVOKE ROLE statements"

commit   : cb4f1be43ad2c60ea80b07d3345d8a52ca9f763f    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 30 Dec 2021 13:23:47 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 30 Dec 2021 13:23:47 +0100    

Click here for diff

The reverted commit attempted to fix SQL specification compliance for  
the cases which 6aaaa76bb left.  This however broke existing behavior  
which takes precedence over spec compliance so revert. The introduced  
tests are left after the revert since the codepath isn't well covered.  
Per bug report 17346. Backpatch down to 14 where it was introduced.  
  
Reported-by: Andrew Bille <andrewbille@gmail.com>  
Discussion: https://postgr.es/m/17346-f72b28bd1a341060@postgresql.org  

M src/backend/commands/user.c
M src/backend/parser/gram.y
M src/test/regress/expected/privileges.out

Fix overly generic name in with.sql test.

commit   : f7d7ac23d19240a90bbb8d91cb231ef7f883dd02    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 30 Dec 2021 16:09:53 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 30 Dec 2021 16:09:53 +1300    

Click here for diff

Avoid the name "test".  In the 10 branch, this could clash with  
alter_table.sql, as seen in the build farm.  That other instance was  
already renamed in later branches by commit 2cf8c7aa, but it's good to  
future-proof the name here too.  
  
Back-patch to 10.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CA%2BhUKGJf4RAXUyAYVUcQawcptX%3DnhEco3SYpuPK5cCbA-F1eLA%40mail.gmail.com  

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

doc: clarify when expression indexes evaluate their expressions

commit   : 2ff209953e0a7b4ce9df1c1ba15783345ef5659f    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Wed, 22 Dec 2021 16:29:16 -0500    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Wed, 22 Dec 2021 16:29:16 -0500    

Click here for diff

Only non-HOT updates evaluate the index expression.  
  
Reported-by: Chris Lowder  
  
Discussion: https://postgr.es/m/163967385701.26064.15365003480975321072@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/indices.sgml

Correct comment and some documentation about REPLICA_IDENTITY_INDEX

commit   : 420f9ac1b77cca142d4ab7919a4f2b703c1278b8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Dec 2021 16:38:38 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Dec 2021 16:38:38 +0900    

Click here for diff

catalog/pg_class.h was stating that REPLICA_IDENTITY_INDEX with a  
dropped index is equivalent to REPLICA_IDENTITY_DEFAULT.  The code tells  
a different story, as it is equivalent to REPLICA_IDENTITY_NOTHING.  
  
The behavior exists since the introduction of replica identities, and  
fe7fd4e even added tests for this case but I somewhat forgot to fix this  
comment.  
  
While on it, this commit reorganizes the documentation about replica  
identities on the ALTER TABLE page, and a note is added about the case  
of dropped indexes with REPLICA_IDENTITY_INDEX.  
  
Author: Michael Paquier, Wei Wang  
Reviewed-by: Euler Taveira  
Discussion: https://postgr.es/m/OS3PR01MB6275464AD0A681A0793F56879E759@OS3PR01MB6275.jpnprd01.prod.outlook.com  
Backpatch-through: 10  

M doc/src/sgml/ref/alter_table.sgml
M src/include/catalog/pg_class.h

Remove assertion for ALTER TABLE .. DETACH PARTITION CONCURRENTLY

commit   : 8a22a40b2cfd1ea3218663153e5c6d7ebc68d2bf    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Dec 2021 15:38:05 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Dec 2021 15:38:05 +0900    

Click here for diff

One code path related to this flavor of ALTER TABLE was checking that  
the relation to detach has to be a normal table or a partitioned table,  
which would fail if using the command with a different relation kind.  
  
Views, sequences and materialized views cannot be part of a partition  
tree, so these would cause the command to fail anyway, but the assertion  
was triggered.  Foreign tables can be part of a partition tree, and  
again the assertion would have failed.  The simplest solution is just to  
remove this assertion, so as we get the same failure as the  
non-concurrent code path.  
  
While on it, add a regression test in postgres_fdw for the concurrent  
partition detach of a foreign table, as per a suggestion from Alexander  
Lakhin.  
  
Issue introduced in 71f4c8c.  
  
Reported-by: Alexander Lakhin  
Author: Michael Paquier, Alexander Lakhin  
Reviewed-by: Peter Eisentraut, Kyotaro Horiguchi  
Discussion: https://postgr.es/m/17339-a9e09aaf38a3457a@postgresql.org  
Backpatch-through: 14  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M src/backend/commands/tablecmds.c

Ensure casting to typmod -1 generates a RelabelType.

commit   : f9a8bc9f27e6c7569f30fc86b82129647068f6a0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 16 Dec 2021 15:36:02 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 16 Dec 2021 15:36:02 -0500    

Click here for diff

Fix the code changed by commit 5c056b0c2 so that we always generate  
RelabelType, not something else, for a cast to unspecified typmod.  
Otherwise planner optimizations might not happen.  
  
It appears we missed this point because the previous experiments were  
done on type numeric: the parser undesirably generates a call on the  
numeric() length-coercion function, but then numeric_support()  
optimizes that down to a RelabelType, so that everything seems fine.  
It misbehaves for types that have a non-optimized length coercion  
function, such as bpchar.  
  
Per report from John Naylor.  Back-patch to all supported branches,  
as the previous patch eventually was.  Unfortunately, that no longer  
includes 9.6 ... we really shouldn't put this type of change into a  
nearly-EOL branch.  
  
Discussion: https://postgr.es/m/CAFBsxsEfbFHEkouc+FSj+3K1sHipLPbEC67L0SAe-9-da8QtYg@mail.gmail.com  

M src/backend/parser/parse_coerce.c
M src/test/regress/expected/expressions.out
M src/test/regress/sql/expressions.sql

Adjust behavior of some env settings for the TAP tests of MSVC

commit   : 4ddbd7456a2d1a2f06f0860151bcbc720bf75e55    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Dec 2021 10:40:08 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Dec 2021 10:40:08 +0900    

Click here for diff

edc2332 has introduced in vcregress.pl some control on the environment  
variables LZ4, TAR and GZIP_PROGRAM to allow any TAP tests to be able  
use those commands.  This makes the settings more consistent with  
src/Makefile.global.in, as the same default gets used for Make and MSVC  
builds.  
  
Each parameter can be changed in buildenv.pl, but as a default gets  
assigned after loading buldenv.pl, it is not possible to unset any of  
these, and using an empty value would not work with "||=" either.  As  
some environments may not have a compatible command in their PATH (tar  
coming from MinGW is an issue, for one), this could break tests without  
an exit path to bypass any failing test.  This commit changes things so  
as the default values for LZ4, TAR and GZIP_PROGRAM are assigned before  
loading buildenv.pl, not after.  This way, we keep the same amount of  
compatibility as a GNU build with the same defaults, and it becomes  
possible to unset any of those values.  
  
While on it, this adds some documentation about those three variables in  
the section dedicated to the TAP tests for MSVC.  
  
Per discussion with Andrew Dunstan.  
  
Discussion: https://postgr.es/m/YbGYe483803il3X7@paquier.xyz  
Backpatch-through: 10  

M doc/src/sgml/install-windows.sgml
M src/tools/msvc/vcregress.pl

Fix datatype confusion in logtape.c's right_offset().

commit   : 25c7faa1feeeff040242100d61b1f8914db3d3ea    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 14 Dec 2021 11:46:36 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 14 Dec 2021 11:46:36 -0500    

Click here for diff

This could only matter if (a) long is wider than int, and (b) the heap  
of free blocks exceeds UINT_MAX entries, which seems pretty unlikely.  
Still, it's a theoretical bug, so backpatch to v13 where the typo came  
in (in commit c02fdc922).  
  
In passing, also make swap_nodes() use consistent datatypes.  
  
Ma Liangzhu  
  
Discussion: https://postgr.es/m/17336-fc4e522d26a750fd@postgresql.org  

M src/backend/utils/sort/logtape.c

Remove assertion for replication origins in PREPARE TRANSACTION

commit   : 4be3e005e5da931aa816e3c04e1217c33de52fd6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 14 Dec 2021 10:58:25 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 14 Dec 2021 10:58:25 +0900    

Click here for diff

When using replication origins, pg_replication_origin_xact_setup() is an  
optional choice to be able to set a LSN and a timestamp to mark the  
origin, which would be additionally added to WAL for transaction commits  
or aborts (including 2PC transactions).  An assertion in the code path  
of PREPARE TRANSACTION assumed that this data should always be set, so  
it would trigger when using replication origins without setting up an  
origin LSN.  Some tests are added to cover more this kind of scenario.  
  
Oversight in commit 1eb6d65.  
  
Per discussion with Amit Kapila and Masahiko Sawada.  
  
Discussion: https://postgr.es/m/YbbBfNSvMm5nIINV@paquier.xyz  
Backpatch-through: 11  

M contrib/test_decoding/expected/replorigin.out
M contrib/test_decoding/sql/replorigin.sql
M src/backend/access/transam/twophase.c

Doc: de-document unimplemented geometric operators.

commit   : a80fd2ae4cd4058b745959de1092f73810077779    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 13 Dec 2021 17:49:36 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 13 Dec 2021 17:49:36 -0500    

Click here for diff

In commit 791090bd7, I made an effort to fill in documentation  
for all geometric operators listed in pg_operator.  However,  
it now appears that at least some of the omissions may have been  
intentional, because some of those operator entries point at  
unimplemented stub functions.  Remove those from the docs again.  
  
(In HEAD, poly_distance stays, because c5c192d7b just added an  
implementation for it.)  
  
Per complaint from Anton Voloshin.  
  
Discussion: https://postgr.es/m/3426566.1638832718@sss.pgh.pa.us  

M doc/src/sgml/func.sgml

isolationtester: append session name to application_name.

commit   : 5b5455b035c62a710ebd6facb164112e36e9fa49    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 13 Dec 2021 12:02:42 -0800    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Mon, 13 Dec 2021 12:02:42 -0800    

Click here for diff

When writing / debugging an isolation test it sometimes is useful to see which  
session holds what lock etc. To make it easier, both as part of spec files and  
interactively, append the session name to application_name. Since b1907d688  
application_name already contains the test name, this appends the session's  
name to that.  
  
insert-conflict-specconflict did something like this manually, which can now  
be removed.  
  
As we have done lately with other test infrastructure improvements, backpatch  
this change, to make it easier to backpatch tests.  
  
Author: Andres Freund <andres@anarazel.de>  
Reviewed-By: Michael Paquier <michael@paquier.xyz>  
Reviewed-By: Andrew Dunstan <andrew@dunslane.net>  
Discussion: https://postgr.es/m/20211211012052.2blmzcmxnxqawd2z@alap3.anarazel.de  
Backpatch: 10-, to make backpatching of tests easier.  

M src/test/isolation/expected/insert-conflict-specconflict.out
M src/test/isolation/isolationtester.c
M src/test/isolation/specs/insert-conflict-specconflict.spec

Fix alignment in multirange_get_range() function

commit   : 7615edd1db92b0bf909037480e8d9fcdb1be5f4b    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 13 Dec 2021 17:17:33 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 13 Dec 2021 17:17:33 +0300    

Click here for diff

The multirange_get_range() function fails when two boundaries of the same  
range have different alignments.  Fix that by adding proper pointer alignment.  
  
Reported-by: Alexander Lakhin  
Discussion: https://postgr.es/m/17300-dced2d01ddeb1f2f%40postgresql.org  
Backpatch-through: 14  

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

Fix some typos with {a,an}

commit   : a04fc56d03b33780612cf7630bb3f1a9388a9a02    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 9 Dec 2021 15:20:45 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 9 Dec 2021 15:20:45 +0900    

Click here for diff

One of the changes impacts the documentation, so backpatch.  
  
Author: Peter Smith  
Discussion: https://postgr.es/m/CAHut+Pu6+c+r3mY24VT7u+H+E_s6vMr5OdRiZ8NT3EOa-E5Lmw@mail.gmail.com  
Backpatch-through: 14  

M contrib/amcheck/verify_nbtree.c
M doc/src/sgml/ecpg.sgml
M src/backend/access/table/toast_helper.c
M src/backend/catalog/pg_depend.c
M src/backend/jit/llvm/llvmjit_error.cpp
M src/backend/replication/logical/reorderbuffer.c

Fix double publish of child table's data.

commit   : 614b77d65a3859ad8d2c1c28475e98ddee06dc50    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 9 Dec 2021 08:49:50 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 9 Dec 2021 08:49:50 +0530    

Click here for diff

We publish the child table's data twice for a publication that has both  
child and parent tables and is published with publish_via_partition_root  
as true. This happens because subscribers will initiate synchronization  
using both parent and child tables, since it gets both as separate tables  
in the initial table list.  
  
Ensure that pg_publication_tables returns only parent tables in such  
cases.  
  
Author: Hou Zhijie  
Reviewed-by: Greg Nancarrow, Amit Langote, Vignesh C, Amit Kapila  
Backpatch-through: 13  
Discussion: https://postgr.es/m/OS0PR01MB57167F45D481F78CDC5986F794B99@OS0PR01MB5716.jpnprd01.prod.outlook.com  

M src/backend/catalog/pg_publication.c
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql
M src/test/subscription/t/013_partition.pl

Doc: improve xfunc-c-type-table.

commit   : 3d603431975b4ca920c698abd7f0083a3fabe827    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 8 Dec 2021 16:54:31 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 8 Dec 2021 16:54:31 -0500    

Click here for diff

List types numeric and timestamptz, which don't seem to have ever been  
included here.  Restore bigint, which was no-doubt-accidentally deleted  
in v12.  Fix some errors, or at least obsolete usages (nobody declares  
float arguments as "float8*" anymore, even though they might be that  
under the hood).  Re-alphabetize.  Remove the seeming claim that this  
is a complete list of built-in types.  
  
Per question from Oskar Stenberg.  
  
Discussion: https://postgr.es/m/HE1PR03MB2971DE2527ECE1E99D6C19A8F96E9@HE1PR03MB2971.eurprd03.prod.outlook.com  

M doc/src/sgml/xfunc.sgml

Revert "Check that we have a working tar before trying to use it"

commit   : e4d73d089f4a1200c5d24f9d9dd014d911567f53    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 8 Dec 2021 16:45:39 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 8 Dec 2021 16:45:39 -0500    

Click here for diff

This reverts commit f920f7e799c587228227ec94356c760e3f3d5f2b.  
  
The patch in effect fixed a problem we didn't have and caused another  
instead.  
  
Backpatch to release 14 like original  
  
Discussion: https://postgr.es/m/3655283.1638977975@sss.pgh.pa.us  

M src/bin/pg_basebackup/t/010_pg_basebackup.pl

Check that we have a working tar before trying to use it

commit   : 90c08ed11332b766769b2e5ba114fb7ecb34e401    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 8 Dec 2021 10:21:35 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 8 Dec 2021 10:21:35 -0500    

Click here for diff

Issue exposed by commit edc2332550 and the buildfarm.  
  
Backpatch to release 14 where this usage started.  

M src/bin/pg_basebackup/t/010_pg_basebackup.pl

Fix origin timestamp during decoding of ROLLBACK PREPARED operation.

commit   : f2e1730ee9bc1a8a3875a69a174cfb365b210821    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 8 Dec 2021 15:21:12 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 8 Dec 2021 15:21:12 +0530    

Click here for diff

This happens because we were passing incorrect arguments to  
ReorderBufferFinishPrepared().  
  
Author: Masahiko Sawada  
Reviewed-by: Vignesh C  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CAD21AoBqhUqgDZUhUVnnwKRubPDNJ6m6fJDPgok3E5cWJLL+pA@mail.gmail.com  

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

Fix corruption of toast indexes with REINDEX CONCURRENTLY

commit   : 64ab21f0e5deb80ff67f953c6e3c8640a007a929    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 8 Dec 2021 11:01:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 8 Dec 2021 11:01:14 +0900    

Click here for diff

REINDEX CONCURRENTLY run on a toast index or a toast relation could  
corrupt the target indexes rebuilt, as a backend running in parallel  
that manipulates toast values would directly release the lock on the  
toast relation when its local operation is done, rather than releasing  
the lock once the transaction that manipulated the toast values  
committed.  
  
The fix done here is simple: we now hold a ROW EXCLUSIVE lock on the  
toast relation when saving or deleting a toast value until the  
transaction working on them is committed, so as a concurrent reindex  
happening in parallel would be able to wait for any activity and see any  
new rows inserted (or deleted).  
  
An isolation test is added to check after the case fixed here, which is  
a bit fancy by design as it relies on allow_system_table_mods to rename  
the toast table and its index to fixed names.  This way, it is possible  
to reindex them directly without any dependency on the OID of the  
underlying relation.  Note that this could not use a DO block either, as  
REINDEX CONCURRENTLY cannot be run in a transaction block.  The test is  
backpatched down to 13, where it is possible, thanks to c4a7a39, to use  
allow_system_table_mods in a test suite.  
  
Reported-by: Alexey Ermakov  
Analyzed-by: Andres Freund, Noah Misch  
Author: Michael Paquier  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/17268-d2fb426e0895abd4@postgresql.org  
Backpatch-through: 12  

M src/backend/access/common/toast_internals.c
A src/test/isolation/expected/reindex-concurrently-toast.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/reindex-concurrently-toast.spec

Enable settings used in TAP tests for MSVC builds

commit   : 93094232c8958a42fdd066ef52d4673108e768e3    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Tue, 7 Dec 2021 14:53:39 -0500    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Tue, 7 Dec 2021 14:53:39 -0500    

Click here for diff

Certain settings from configuration or the Makefile infrastructure are  
used by the TAP tests, but were not being set up by vcregress.pl. This  
remedies those omissions. This should increase test coverage, especially  
on the buildfarm.  
  
Reviewed by Noah Misch  
  
Discussion: https://postgr.es/m/17093da5-e40d-8335-d53a-2bd803fc38b0@dunslane.net  
  
Backpatch to all live branches.  

M src/tools/msvc/vcregress.pl

On Windows, also call shutdown() while closing the client socket.

commit   : ea5ecdadf6eacdc1ef5c67648ebaed2efcb0d07a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 7 Dec 2021 13:34:06 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 7 Dec 2021 13:34:06 -0500    

Click here for diff

Further experimentation shows that commit 6051857fc is not sufficient  
when using (some versions of?) OpenSSL.  The reason is obscure, but  
calling shutdown(socket, SD_SEND) improves matters.  
  
Per testing by Andrew Dunstan and Alexander Lakhin.  
Back-patch as before.  
  
Discussion: https://postgr.es/m/af5e0bf3-6a61-bb97-6cba-061ddf22ff6b@dunslane.net  

M src/backend/libpq/pqcomm.c

Doc: Fix misleading wording of CRL parameters

commit   : b6360aa46ce966f77fba290637f51f5bb2de12a9    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 3 Dec 2021 14:15:50 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 3 Dec 2021 14:15:50 +0100    

Click here for diff

ssl_crl_file and ssl_crl_dir are both used to for client certificate  
revocation, not server certificates.  The description for the params  
could be easily misread to mean the opposite however,  as evidenced  
by the bugreport leading to this fix.  Similarly, expand sslcrl and  
and sslcrldir to explicitly mention server certificates. While there  
also mention sslcrldir where previously only sslcrl was discussed.  
  
Backpatch down to v10, with the CRL dir fixes down to 14 where they  
were introduced.  
  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>  
Discussion: https://postgr.es/m/20211202.135441.590555657708629486.horikyota.ntt@gmail.com  
Discussion: https://postgr.es/m/CABWY_HCBUCjY1EJHrEGePGEaSZ5b29apgTohCyygtsqe_ySYng@mail.gmail.com  
Backpatch-through: 10  

M doc/src/sgml/config.sgml
M doc/src/sgml/libpq.sgml
M doc/src/sgml/runtime.sgml

postgres_fdw: Fix unexpected reporting of empty message.

commit   : 5cb86a2622f616cbacc0c4fc05a2d34e458863b6    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Dec 2021 17:35:29 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Dec 2021 17:35:29 +0900    

Click here for diff

pgfdw_report_error() in postgres_fdw gets a message from PGresult or  
PGconn to report an error received from a remote server. Previously  
if it could get a message from neither of them, it reported empty  
message unexpectedly. The cause of this issue was that pgfdw_report_error()  
didn't handle properly the case where no message could be obtained  
and its local variable message_primary was set to '\0'.  
  
This commit improves pgfdw_report_error() so that it reports the message  
"could not obtain ..." when it gets no message and message_primary  
is set to '\0'. This is the same behavior as when message_primary is NULL.  
  
dblink_res_error() in dblink has the same issue, so this commit also  
improves it in the same way.  
  
Back-patch to all supported branches.  
  
Author: Fujii Masao  
Reviewed-by: Bharath Rupireddy  
Discussion: https://postgr.es/m/477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com  

M contrib/dblink/dblink.c
M contrib/postgres_fdw/connection.c

On Windows, close the client socket explicitly during backend shutdown.

commit   : 4cd2928543c1148278f8c1f393ee58dd72816df0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 2 Dec 2021 17:14:43 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 2 Dec 2021 17:14:43 -0500    

Click here for diff

It turns out that this is necessary to keep Winsock from dropping any  
not-yet-sent data, such as an error message explaining the reason for  
process termination.  It's pretty weird that the implicit close done  
by the kernel acts differently from an explicit close, but it's hard  
to argue with experimental results.  
  
Independently submitted by Alexander Lakhin and Lars Kanis (comments  
by me, though).  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/90b34057-4176-7bb0-0dbb-9822a5f6425b@greiz-reinsdorf.de  
Discussion: https://postgr.es/m/16678-253e48d34dc0c376@postgresql.org  

M src/backend/libpq/pqcomm.c

Move into separate file all the SQL queries used in pg_upgrade tests

commit   : b6dac98b05618c22bf357e5fcf23ad2419013439    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Dec 2021 10:31:29 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Dec 2021 10:31:29 +0900    

Click here for diff

The existing pg_upgrade/test.sh and the buildfarm code have been holding  
the same set of SQL queries when doing cross-version upgrade tests to  
adapt the objects created by the regression tests before the upgrade  
(mostly, incompatible or non-existing objects need to be dropped from  
the origin, perhaps re-created).  
  
This moves all those SQL queries into a new, separate, file with a set  
of \if clauses to handle the version checks depending on the old version  
of the cluster to-be-upgraded.  
  
The long-term plan is to make the buildfarm code re-use this new SQL  
file, so as committers are able to fix any compatibility issues in the  
tests of pg_upgrade with a refresh of the core code, without having to  
poke at the buildfarm client.  Note that this is only able to handle the  
main regression test suite, and that nothing is done yet for contrib  
modules yet (these have more issues like their database names).  
  
A backpatch down to 10 is done, adapting the version checks as this  
script needs to be only backward-compatible, so as it becomes possible  
to clean up a maximum amount of code within the buildfarm client.  
  
Author: Justin Pryzby, Michael Paquier  
Discussion: https://postgr.es/m/20201206180248.GI24052@telsasoft.com  
Backpatch-through: 10  

M src/bin/pg_upgrade/test.sh
A src/bin/pg_upgrade/upgrade_adapt.sql

Avoid leaking memory during large-scale REASSIGN OWNED BY operations.

commit   : 8f4b0200e15a5684f6331f94caea002370754257    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Dec 2021 13:44:47 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Dec 2021 13:44:47 -0500    

Click here for diff

The various ALTER OWNER routines tend to leak memory in  
CurrentMemoryContext.  That's not a problem when they're only called  
once per command; but in this usage where we might be touching many  
objects, it can amount to a serious memory leak.  Fix that by running  
each call in a short-lived context.  
  
(DROP OWNED BY likely has a similar issue, except that you'll probably  
run out of lock table space before noticing.  REASSIGN is worth fixing  
since for most non-table object types, it won't take any lock.)  
  
Back-patch to all supported branches.  Unfortunately, in the back  
branches this helps to only a limited extent, since the sinval message  
queue bloats quite a lot in this usage before commit 3aafc030a,  
consuming memory more or less comparable to what's actually leaked.  
Still, it's clearly a leak with a simple fix, so we might as well fix it.  
  
Justin Pryzby, per report from Guillaume Lelarge  
  
Discussion: https://postgr.es/m/CAECtzeW2DAoioEGBRjR=CzHP6TdL=yosGku8qZxfX9hhtrBB0Q@mail.gmail.com  

M src/backend/catalog/pg_shdepend.c

Doc: Add "Attach Partition" limitation during logical replication.

commit   : 4b8eec716a524b9c9f4a65660a7006628c1d8da3    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 1 Dec 2021 10:18:27 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 1 Dec 2021 10:18:27 +0530    

Click here for diff

ATTACHing a table into a partition tree whose root is published using a  
publication with publish_via_partition_root set to true does not result in  
the table's existing contents being replicated. This happens because  
subscriber doesn't consider replicating the newly attached partition as  
the root table is already in a 'ready' state.  
  
This behavior was introduced in PG13 (83fd4532a7) where we allowed to  
publish partition changes via ancestors.  
  
We can consider fixing this limitation in the future.  
  
Author: Amit Langote  
Reviewed-by: Hou Zhijie, Amit Kapila  
Backpatch-through: 13  
Discussion: https://postgr.es/m/OS0PR01MB5716E97F00732B52DC2BBC2594989@OS0PR01MB5716.jpnprd01.prod.outlook.com  

M doc/src/sgml/ref/create_publication.sgml

Cope with cross-compiling when checking for a random-number source.

commit   : 175edafd1f30a78643359b56c5545b5e7aabfb50    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 30 Nov 2021 17:18:04 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 30 Nov 2021 17:18:04 -0500    

Click here for diff

Commit 16f96c74d neglected to consider the possibility of cross-compiling,  
causing cross-compiles to fail at the configure stage unless you'd  
selected --with-openssl.  Since we're now more or less assuming that  
/dev/urandom is available everywhere, it seems reasonable to assume  
that the cross-compile target has it too, rather than failing.  
  
Per complaint from Vincas Dargis.  Back-patch to v14 where this came in.  
  
Discussion: https://postgr.es/m/0dc14a31-acaf-8cae-0df4-a87339b22bd9@gmail.com  

M configure
M configure.ac

Fix compatibility thinko for fstat() on standard streams in win32stat.c

commit   : 5550a9c385198ac51d2f3b17be2f6ff9f886d76d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Nov 2021 09:55:56 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Nov 2021 09:55:56 +0900    

Click here for diff

GetFinalPathNameByHandleA() cannot be used in compilation environments  
where _WIN32_WINNT < 0x0600, meaning at least Windows XP used by some  
buildfarm members under MinGW that Postgres still needs to support.  
This was reported as a compilation warning by the buildfarm, but this is  
actually worse than the report as the code would have not worked.  
  
Instead, this switches to GetFileInformationByHandle() that is able to  
fail for standard streams and succeed for redirected ones, which is what  
we are looking for herein the code emulating fstat().  We also know that  
it is able to work in all the environments still supported, thanks to  
the existing logic of win32stat.c.  
  
Issue introduced by 10260c7, so backpatch down to 14.  
  
Reported-by: Justin Pryzby, via buildfarm member jacana  
Author: Michael Paquier  
Reviewed-by: Juan José Santamaría Flecha  
Discussion: https://postgr.es/m/20211129050122.GK17618@telsasoft.com  
Backpatch-through: 14  

M src/port/win32stat.c

Doc: improve documentation about ORDER BY in matviews.

commit   : ce43b3dc52c90082981f2f1de5351a95fc21c405    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 29 Nov 2021 12:13:13 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 29 Nov 2021 12:13:13 -0500    

Click here for diff

Remove the confusing use of ORDER BY in an example materialized  
view.  It adds nothing to the example, but might encourage  
people to follow bad practice.  Clarify REFRESH MATERIALIZED  
VIEW's note about whether view ordering is retained (it isn't).  
  
Maciek Sakrejda  
  
Discussion: https://postgr.es/m/CAOtHd0D-OvrUU0C=4hX28p4BaSE1XL78BAQ0VcDaLLt8tdUzsg@mail.gmail.com  

M doc/src/sgml/ref/refresh_materialized_view.sgml
M doc/src/sgml/rules.sgml

Harden be-gssapi-common.h for headerscheck

commit   : 1b1e4bfe7da770ad159c0f4291925a3597a65dbc    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 26 Nov 2021 17:00:29 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 26 Nov 2021 17:00:29 -0300    

Click here for diff

Surround the contents with a test that the feature is enabled by  
configure, to silence header checking tools on systems without GSSAPI  
installed.  
  
Backpatch to 12, where the file appeared.  
  
Discussion: https://postgr.es/m/202111161709.u3pbx5lxdimt@alvherre.pgsql  

M src/include/libpq/be-gssapi-common.h

Document units for max_slot_wal_keep_size

commit   : 2187a229410f12168d48eb41fce22ba348b2b757    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 26 Nov 2021 14:31:57 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 26 Nov 2021 14:31:57 -0300    

Click here for diff

The doc blurb failed to mention units, as well as lacking the point  
about changeability.  
  
Backpatch to 13.  
  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reported by: b1000101@pm.me  
Discussion: https://postgr.es/m/163760291192.26193.10801700492025355788@wrigleys.postgresql.org  

M doc/src/sgml/config.sgml

Fix determination of broken LSN in OVERWRITTEN_CONTRECORD

commit   : d24dac9549067716f5b4d8e44ccf87dd5274bfcd    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 26 Nov 2021 11:14:27 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 26 Nov 2021 11:14:27 -0300    

Click here for diff

In commit ff9f111bce24 I mixed up inconsistent definitions of the LSN of  
the first record in a page, when the previous record ends exactly at the  
page boundary.  The correct LSN is adjusted to skip the WAL page header;  
I failed to use that when setting XLogReaderState->overwrittenRecPtr,  
so at WAL replay time VerifyOverwriteContrecord would refuse to let  
replay continue past that record.  
  
Backpatch to 10.  9.6 also contains this bug, but it's no longer being  
maintained.  
  
Discussion: https://postgr.es/m/45597.1637694259@sss.pgh.pa.us  

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

Fix GRANTED BY support in REVOKE ROLE statements

commit   : 371087d006e04991080bf17cf2287db38d3ea92e    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 26 Nov 2021 14:02:01 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 26 Nov 2021 14:02:01 +0100    

Click here for diff

Commit 6aaaa76bb added support for the GRANTED BY clause in GRANT and  
REVOKE statements, but missed adding support for checking the role in  
the REVOKE ROLE case. Fix by checking that the parsed role matches the  
CURRENT_ROLE/CURRENT_USER requirement, and also add some tests for it.  
Backpatch to v14 where GRANTED BY support was introduced.  
  
Discussion: https://postgr.es/m/B7F6699A-A984-4943-B9BF-CEB84C003527@yesql.se  
Backpatch-through: 14  

M src/backend/commands/user.c
M src/backend/parser/gram.y
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Remove unneeded Python includes

commit   : 1cc13b83eb125fb63eeb1249aa5b28d06fbd2b6c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 25 Nov 2021 14:19:22 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 25 Nov 2021 14:19:22 +0100    

Click here for diff

Inluding <compile.h> and <eval.h> has not been necessary since Python  
2.4, since they are included via <Python.h>.  Morever, <eval.h> is  
being removed in Python 3.11.  So remove these includes.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/84884.1637723223%40sss.pgh.pa.us  

M src/pl/plpython/plpython.h

Block ALTER TABLE .. DROP NOT NULL on columns in replica identity index

commit   : e415916e24ccf28a88d87182e716beace9820753    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 25 Nov 2021 15:05:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 25 Nov 2021 15:05:24 +0900    

Click here for diff

Replica identities that depend directly on an index rely on a set of  
properties, one of them being that all the columns defined in this index  
have to be marked as NOT NULL.  There was a hole in the logic with ALTER  
TABLE DROP NOT NULL, where it was possible to remove the NOT NULL  
property of a column part of an index used as replica identity, so block  
it to avoid problems with logical decoding down the road.  
  
The same check was already done columns part of a primary key, so the  
fix is straight-forward.  
  
Author: Haiying Tang, Hou Zhijie  
Reviewed-by: Dilip Kumar, Michael Paquier  
Discussion: https://postgr.es/m/OS0PR01MB6113338C102BEE8B2FFC5BD9FB619@OS0PR01MB6113.jpnprd01.prod.outlook.com  
Backpatch-through: 10  

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

Fix fstat() emulation on Windows with standard streams

commit   : d2198b4593cca21390907a1d6762e3a0357298db    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 25 Nov 2021 12:17:05 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 25 Nov 2021 12:17:05 +0900    

Click here for diff

The emulation of fstat() in win32stat.c caused two issues with the  
existing in-core callers, failing on EINVAL when using a stream as  
argument:  
- psql's \copy would crash when using a stream.  
- pg_recvlogical would fail with -f -.  
  
The tests in copyselect.sql from the main test suite covers the first  
case, and there is a TAP test for the second case.  However, in both  
cases, as the standard streams are always redirected, automated tests  
did not notice those issues, requiring a terminal on Windows to be  
reproducible.  
  
This issue has been introduced in bed9075, and the origin of the problem  
is that GetFileInformationByHandle() does not work directly on streams,  
so this commit adds an extra code path to emulate and return a set of  
stats that match best with the reality.  Note that redirected streams  
rely on handles that can be queried with GetFileInformationByHandle(),  
but we can rely on GetFinalPathNameByHandleA() to detect this case.  
  
Author: Dmitry Koval, Juan José Santamaría Flecha  
Discussion: https://postgr.es/m/17288-6b58a91025a8a8a3@postgresql.org  
Backpatch-through: 14  

M src/port/win32stat.c

Doc: improve documentation about nextval()/setval().

commit   : 6d1bdd5e0712c0c3460d68dc2175f842530b1f83    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 24 Nov 2021 13:37:12 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 24 Nov 2021 13:37:12 -0500    

Click here for diff

Clarify that the results of nextval and setval are not guaranteed  
persistent until the calling transaction commits.  Some people  
seem to have drawn the opposite conclusion from the statement that  
these functions are never rolled back, so re-word to avoid saying  
it quite that way.  
  
Discussion: https://postgr.es/m/CAKU4AWohO=NfM-4KiZWvdc+z3c1C9FrUBR6xnReFJ6sfy0i=Lw@mail.gmail.com  

M doc/src/sgml/func.sgml

Fix missing space in docs.

commit   : 88482d75cce5f3527ebad1cf42ec59a355f4b033    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 24 Nov 2021 18:32:56 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 24 Nov 2021 18:32:56 +0200    

Click here for diff

Author: Japin Li  
Discussion: https://www.postgresql.org/message-id/MEYP282MB1669C36E5F733C2EFBDCB80BB6619@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM  

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

Flush Memoize cache when non-key parameters change, take 2

commit   : c2dc7b9e15039ce90c0a631ff291feb81d2c8051    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 23:29:56 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 23:29:56 +1300    

Click here for diff

It's possible that a subplan below a Memoize node contains a parameter  
from above the Memoize node.  If this parameter changes then cache entries  
may become out-dated due to the new parameter value.  
  
Previously Memoize was mistakenly not aware of this.  We fix this here by  
flushing the cache whenever a parameter that's not part of the cache  
key changes.  
  
Bug: #17213  
Reported by: Elvis Pranskevichus  
Author: David Rowley  
Discussion: https://postgr.es/m/17213-988ed34b225a2862@postgresql.org  
Backpatch-through: 14, where Memoize was added  

M src/backend/executor/nodeMemoize.c
M src/backend/nodes/bitmapset.c
M src/backend/nodes/copyfuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/clauses.c
M src/include/nodes/execnodes.h
M src/include/nodes/plannodes.h
M src/include/optimizer/clauses.h
M src/test/regress/expected/memoize.out
M src/test/regress/sql/memoize.sql

Add support for Visual Studio 2022 in build scripts

commit   : 0e681fa458750b08a5c7885820320fb85cd9ddf1    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 24 Nov 2021 13:03:55 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 24 Nov 2021 13:03:55 +0900    

Click here for diff

Documentation and any code paths related to VS are updated to keep the  
whole consistent.  Similarly to 2017 and 2019, the version of VS and the  
version of nmake that we use to determine which code paths to use for  
the build are still inconsistent in their own way.  
  
Backpatch down to 10, so as buildfarm members are able to use this new  
version of Visual Studio on all the stable branches supported.  
  
Author: Hans Buschmann  
Discussion: https://postgr.es/m/1633101364685.39218@nidsa.net  
Backpatch-through: 10  

M doc/src/sgml/install-windows.sgml
M src/tools/msvc/MSBuildProject.pm
M src/tools/msvc/README
M src/tools/msvc/Solution.pm
M src/tools/msvc/VSObjectFactory.pm

Revert "Flush Memoize cache when non-key parameters change"

commit   : 7933bc0d13616844ed66271942eac12c3a7f0488    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 15:28:34 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 15:28:34 +1300    

Click here for diff

This reverts commit f94edb06ab60545a0e9e90aedc39e3b81b2b9e3f.  

M src/backend/executor/nodeMemoize.c
M src/backend/nodes/bitmapset.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/clauses.c
M src/include/nodes/execnodes.h
M src/include/nodes/plannodes.h
M src/include/optimizer/clauses.h
M src/test/regress/expected/memoize.out
M src/test/regress/sql/memoize.sql

Flush Memoize cache when non-key parameters change

commit   : f94edb06ab60545a0e9e90aedc39e3b81b2b9e3f    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 14:57:07 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 14:57:07 +1300    

Click here for diff

It's possible that a subplan below a Memoize node contains a parameter  
from above the Memoize node.  If this parameter changes then cache entries  
may become out-dated due to the new parameter value.  
  
Previously Memoize was mistakenly not aware of this.  We fix this here by  
flushing the cache whenever a parameter that's not part of the cache  
key changes.  
  
Bug: #17213  
Reported by: Elvis Pranskevichus  
Author: David Rowley  
Discussion: https://postgr.es/m/17213-988ed34b225a2862@postgresql.org  
Backpatch-through: 14, where Memoize was added  

M src/backend/executor/nodeMemoize.c
M src/backend/nodes/bitmapset.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/clauses.c
M src/include/nodes/execnodes.h
M src/include/nodes/plannodes.h
M src/include/optimizer/clauses.h
M src/test/regress/expected/memoize.out
M src/test/regress/sql/memoize.sql

Allow Memoize to operate in binary comparison mode

commit   : 6c32c0977783fae217b5eaa1d22d26c96e5b0085    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 10:07:38 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 24 Nov 2021 10:07:38 +1300    

Click here for diff

Memoize would always use the hash equality operator for the cache key  
types to determine if the current set of parameters were the same as some  
previously cached set.  Certain types such as floating points where -0.0  
and +0.0 differ in their binary representation but are classed as equal by  
the hash equality operator may cause problems as unless the join uses the  
same operator it's possible that whichever join operator is being used  
would be able to distinguish the two values.  In which case we may  
accidentally return in the incorrect rows out of the cache.  
  
To fix this here we add a binary mode to Memoize to allow it to the  
current set of parameters to previously cached values by comparing  
bit-by-bit rather than logically using the hash equality operator.  This  
binary mode is always used for LATERAL joins and it's used for normal  
joins when any of the join operators are not hashable.  
  
Reported-by: Tom Lane  
Author: David Rowley  
Discussion: https://postgr.es/m/3004308.1632952496@sss.pgh.pa.us  
Backpatch-through: 14, where Memoize was added  

M contrib/postgres_fdw/expected/postgres_fdw.out
M src/backend/commands/explain.c
M src/backend/executor/nodeMemoize.c
M src/backend/nodes/copyfuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/path/joinpath.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/pathnode.c
M src/backend/utils/adt/datum.c
M src/include/nodes/execnodes.h
M src/include/nodes/pathnodes.h
M src/include/nodes/plannodes.h
M src/include/optimizer/pathnode.h
M src/include/utils/datum.h
M src/test/regress/expected/join.out
M src/test/regress/expected/memoize.out
M src/test/regress/expected/subselect.out
M src/test/regress/sql/memoize.sql

Adjust pg_dump's priority ordering for casts.

commit   : 0fdf67476ccbcc60bba185fd08a90b95cd91ce2d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 22 Nov 2021 17:16:29 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 22 Nov 2021 17:16:29 -0500    

Click here for diff

When a stored expression depends on a user-defined cast, the backend  
records the dependency as being on the cast's implementation function  
--- or indeed, if there's no cast function involved but just  
RelabelType or CoerceViaIO, no dependency is recorded at all.  This  
is problematic for pg_dump, which is at risk of dumping things in the  
wrong order leading to restore failures.  Given the lack of previous  
reports, the risk isn't that high, but it can be demonstrated if the  
cast is used in some view whose rowtype is then used as an input or  
result type for some other function.  (That results in the view  
getting hoisted into the functions portion of the dump, ahead of  
the cast.)  
  
A logically bulletproof fix for this would require including the  
cast's OID in the parsed form of the expression, whence it could be  
extracted by dependency.c, and then the stored dependency would force  
pg_dump to do the right thing.  Such a change would be fairly invasive,  
and certainly not back-patchable.  Moreover, since we'd prefer that  
an expression using cast syntax be equal() to one doing the same  
thing by explicit function call, the cast OID field would have to  
have special ignored-by-comparisons semantics, making things messy.  
  
So, let's instead fix this by a very simple hack in pg_dump: change  
the object-type priority order so that casts are initially sorted  
before functions, immediately after types.  This fixes the problem  
in a fairly direct way for casts that have no implementation function.  
For those that do, the implementation function will be hoisted to just  
before the cast by the dependency sorting step, so that we still have  
a valid dump order.  (I'm not sure that this provides a full guarantee  
of no problems; but since it's been like this for many years without  
any previous reports, this is probably enough to fix it in practice.)  
  
Per report from Дмитрий Иванов.  
Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/CAPL5KHoGa3uvyKp6z6m48LwCnTsK+LRQ_mcA4uKGfqAVSEjV_A@mail.gmail.com  

M src/bin/pg_dump/pg_dump_sort.c

Pacify perlcritic.

commit   : 72842a5756857a1ce6e2b2bd7a162cdf1a279fa9    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 22 Nov 2021 15:57:31 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 22 Nov 2021 15:57:31 -0500    

Click here for diff

Per buildfarm.  

M config/check_modules.pl

Fix pg_dump --inserts mode for generated columns with dropped columns.

commit   : aedc4600d84dd1ebd9386e72ac78f329b8be4804    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 22 Nov 2021 15:25:48 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 22 Nov 2021 15:25:48 -0500    

Click here for diff