PostgreSQL 12.21 commit log

Stamp 12.21.

commit   : 20a82026828536331ebe912b86f060078a173633    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 17:50:23 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 17:50:23 -0500    

Click here for diff

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

Last-minute updates for release notes.

commit   : aee114bf1c84368db9e50ba4e7340ce632f89e19    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 17:40:13 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 17:40:13 -0500    

Click here for diff

Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979  

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

Parallel workers use AuthenticatedUserId for connection privilege checks.

commit   : 0edad8654848affe0786c798aea9e1a43dde54bc    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 17:05:53 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 17:05:53 -0500    

Click here for diff

Commit 5a2fed911 had an unexpected side-effect: the parallel worker  
launched for the new test case would fail if it couldn't use a  
superuser-reserved connection slot.  The reason that test failed  
while all our pre-existing ones worked is that the connection  
privilege tests in InitPostgres had been based on the superuserness  
of the leader's AuthenticatedUserId, but after the rearrangements  
of 5a2fed911 we were testing the superuserness of CurrentUserId,  
which the new test case deliberately made to be a non-superuser.  
  
This all seems very accidental and probably not the behavior we really  
want, but a security patch is no time to be redesigning things.  
Pending some discussion about desirable semantics, hack it so that  
InitPostgres continues to pay attention to the superuserness of  
AuthenticatedUserId when starting a parallel worker.  
  
Nathan Bossart and Tom Lane, per buildfarm member sawshark.  
  
Security: CVE-2024-10978  

M src/backend/utils/init/postinit.c

Fix cross-version upgrade tests.

commit   : 9fc1c3a02ddc4cf2a34550c0f985288cea7094bd    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 13:57:21 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 13:57:21 -0500    

Click here for diff

TestUpgradeXversion knows how to make the main regression database's  
references to pg_regress.so be version-independent.  But it doesn't  
do that for plperl's database, so that the C function added by  
commit b7e3a52a8 is causing cross-version upgrade test failures.  
Path of least resistance is to just drop the function at the end  
of the new test.  
  
In <= v14, also take the opportunity to clean up the generated  
test files.  
  
Security: CVE-2024-10979  

M src/pl/plperl/GNUmakefile
M src/pl/plperl/input/plperl_env.source
M src/pl/plperl/output/plperl_env.source

src/tools/msvc: Respect REGRESS_OPTS in plcheck.

commit   : 1e457468f0bf6c95b72be9af52f68787c8e83ba6    
  
author   : Noah Misch <[email protected]>    
date     : Mon, 11 Nov 2024 10:55:18 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Mon, 11 Nov 2024 10:55:18 -0800    

Click here for diff

v16 commit 8fe3e697a1a83a722b107c7cb9c31084e1f4d077 used REGRESS_OPTS in  
a way needing this.  That broke "vcregress plcheck".  Back-patch  
v16..v12; newer versions don't have this build system.  

M src/tools/msvc/vcregress.pl

Add needed .gitignore files in back branches.

commit   : b1e58defb6a43fe35511eaa80858293b07c8b512    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 10:42:32 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 10:42:32 -0500    

Click here for diff

v14 and earlier use generated test files, which require being  
.gitignore'd to avoid git complaints when testing in-tree.  
  
Security: CVE-2024-10979  

A src/pl/plperl/expected/.gitignore
A src/pl/plperl/sql/.gitignore

Fix improper interactions between session_authorization and role.

commit   : 4c9d96f74ba4e7d01c086ca54f217e242dd65fae    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 10:29:54 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 11 Nov 2024 10:29:54 -0500    

Click here for diff

The SQL spec mandates that SET SESSION AUTHORIZATION implies  
SET ROLE NONE.  We tried to implement that within the lowest-level  
functions that manipulate these settings, but that was a bad idea.  
In particular, guc.c assumes that it doesn't matter in what order  
it applies GUC variable updates, but that was not the case for these  
two variables.  This problem, compounded by some hackish attempts to  
work around it, led to some security-grade issues:  
  
* Rolling back a transaction that had done SET SESSION AUTHORIZATION  
would revert to SET ROLE NONE, even if that had not been the previous  
state, so that the effective user ID might now be different from what  
it had been.  
  
* The same for SET SESSION AUTHORIZATION in a function SET clause.  
  
* If a parallel worker inspected current_setting('role'), it saw  
"none" even when it should see something else.  
  
Also, although the parallel worker startup code intended to cope  
with the current role's pg_authid row having disappeared, its  
implementation of that was incomplete so it would still fail.  
  
Fix by fully separating the miscinit.c functions that assign  
session_authorization from those that assign role.  To implement the  
spec's requirement, teach set_config_option itself to perform "SET  
ROLE NONE" when it sets session_authorization.  (This is undoubtedly  
ugly, but the alternatives seem worse.  In particular, there's no way  
to do it within assign_session_authorization without incompatible  
changes in the API for GUC assign hooks.)  Also, improve  
ParallelWorkerMain to directly set all the relevant user-ID variables  
instead of relying on some of them to get set indirectly.  That  
allows us to survive not finding the pg_authid row during worker  
startup.  
  
In v16 and earlier, this includes back-patching 9987a7bf3 which  
fixed a violation of GUC coding rules: SetSessionAuthorization  
is not an appropriate place to be throwing errors from.  
  
Security: CVE-2024-10978  

M src/backend/access/transam/parallel.c
M src/backend/commands/variable.c
M src/backend/utils/init/miscinit.c
M src/backend/utils/misc/guc.c
M src/include/miscadmin.h
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Ensure cached plans are correctly marked as dependent on role.

commit   : 448525e8a44080b6048e24f6942284b7eeae1a5c    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 11 Nov 2024 09:00:00 -0600    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 11 Nov 2024 09:00:00 -0600    

Click here for diff

If a CTE, subquery, sublink, security invoker view, or coercion  
projection references a table with row-level security policies, we  
neglected to mark the plan as potentially dependent on which role  
is executing it.  This could lead to later executions in the same  
session returning or hiding rows that should have been hidden or  
returned instead.  
  
Reported-by: Wolfgang Walther  
Reviewed-by: Noah Misch  
Security: CVE-2024-10976  
Backpatch-through: 12  

M src/backend/rewrite/rewriteHandler.c
M src/test/regress/expected/rowsecurity.out
M src/test/regress/sql/rowsecurity.sql
M src/tools/pgindent/typedefs.list

Block environment variable mutations from trusted PL/Perl.

commit   : 2ab12d860e51e468703a2777b3759b7a61639df2    
  
author   : Noah Misch <[email protected]>    
date     : Mon, 11 Nov 2024 06:23:43 -0800    
  
committer: Noah Misch <[email protected]>    
date     : Mon, 11 Nov 2024 06:23:43 -0800    

Click here for diff

Many process environment variables (e.g. PATH), bypass the containment  
expected of a trusted PL.  Hence, trusted PLs must not offer features  
that achieve setenv().  Otherwise, an attacker having USAGE privilege on  
the language often can achieve arbitrary code execution, even if the  
attacker lacks a database server operating system user.  
  
To fix PL/Perl, replace trusted PL/Perl %ENV with a tied hash that just  
replaces each modification attempt with a warning.  Sites that reach  
these warnings should evaluate the application-specific implications of  
proceeding without the environment modification:  
  
  Can the application reasonably proceed without the modification?  
  
    If no, switch to plperlu or another approach.  
  
    If yes, the application should change the code to stop attempting  
    environment modifications.  If that's too difficult, add "untie  
    %main::ENV" in any code executed before the warning.  For example,  
    one might add it to the start of the affected function or even to  
    the plperl.on_plperl_init setting.  
  
In passing, link to Perl's guidance about the Perl features behind the  
security posture of PL/Perl.  
  
Back-patch to v12 (all supported versions).  
  
Andrew Dunstan and Noah Misch  
  
Security: CVE-2024-10979  

M doc/src/sgml/plperl.sgml
M src/pl/plperl/GNUmakefile
A src/pl/plperl/input/plperl_env.source
A src/pl/plperl/output/plperl_env.source
M src/pl/plperl/plc_trusted.pl
M src/test/regress/regress.c

Translation updates

commit   : 2af79da563d36fb23492bf271637dc9012e98e37    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 11 Nov 2024 13:59:28 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 11 Nov 2024 13:59:28 +0100    

Click here for diff

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

M src/backend/po/de.po
M src/backend/po/es.po
M src/backend/po/fr.po
M src/backend/po/ja.po
M src/backend/po/ru.po
M src/backend/po/sv.po
M src/bin/initdb/po/es.po
M src/bin/initdb/po/fr.po
M src/bin/initdb/po/ru.po
M src/bin/pg_archivecleanup/po/es.po
M src/bin/pg_archivecleanup/po/fr.po
M src/bin/pg_archivecleanup/po/ru.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_checksums/po/es.po
M src/bin/pg_checksums/po/fr.po
M src/bin/pg_checksums/po/ru.po
M src/bin/pg_config/po/es.po
M src/bin/pg_config/po/fr.po
M src/bin/pg_config/po/ru.po
M src/bin/pg_controldata/po/es.po
M src/bin/pg_controldata/po/fr.po
M src/bin/pg_controldata/po/ru.po
M src/bin/pg_ctl/po/es.po
M src/bin/pg_ctl/po/fr.po
M src/bin/pg_ctl/po/ru.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_resetwal/po/es.po
M src/bin/pg_resetwal/po/fr.po
M src/bin/pg_resetwal/po/ru.po
M src/bin/pg_rewind/po/es.po
M src/bin/pg_rewind/po/fr.po
M src/bin/pg_rewind/po/ru.po
M src/bin/pg_test_fsync/po/es.po
M src/bin/pg_test_fsync/po/fr.po
M src/bin/pg_test_fsync/po/ru.po
M src/bin/pg_test_timing/po/es.po
M src/bin/pg_test_timing/po/fr.po
M src/bin/pg_test_timing/po/ru.po
M src/bin/pg_upgrade/po/es.po
M src/bin/pg_upgrade/po/fr.po
M src/bin/pg_upgrade/po/ru.po
M src/bin/pg_waldump/po/es.po
M src/bin/pg_waldump/po/fr.po
M src/bin/pg_waldump/po/ru.po
M src/bin/psql/po/de.po
M src/bin/psql/po/es.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ja.po
M src/bin/psql/po/ru.po
M src/bin/scripts/po/es.po
M src/bin/scripts/po/fr.po
M src/bin/scripts/po/ru.po
M src/interfaces/ecpg/ecpglib/po/es.po
M src/interfaces/ecpg/ecpglib/po/fr.po
M src/interfaces/ecpg/preproc/po/es.po
M src/interfaces/ecpg/preproc/po/fr.po
M src/interfaces/ecpg/preproc/po/ru.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/ru.po
M src/pl/plperl/po/es.po
M src/pl/plperl/po/fr.po
M src/pl/plperl/po/ru.po
M src/pl/plpgsql/src/po/es.po
M src/pl/plpgsql/src/po/fr.po
M src/pl/plpgsql/src/po/ru.po
M src/pl/plpython/po/es.po
M src/pl/plpython/po/fr.po
M src/pl/tcl/po/es.po
M src/pl/tcl/po/fr.po

libpq: Bail out during SSL/GSS negotiation errors

commit   : 2a951ef0aace58026c31b9a88aeeda19c9af4205    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 11 Nov 2024 10:20:03 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 11 Nov 2024 10:20:03 +0900    

Click here for diff

This commit changes libpq so that errors reported by the backend during  
the protocol negotiation for SSL and GSS are discarded by the client, as  
these may include bytes that could be consumed by the client and write  
arbitrary bytes to a client's terminal.  
  
A failure with the SSL negotiation now leads to an error immediately  
reported, without a retry on any other methods allowed, like a fallback  
to a plaintext connection.  
  
A failure with GSS discards the error message received, and we allow a  
fallback as it may be possible that the error is caused by a connection  
attempt with a pre-11 server, GSS encryption having been introduced in  
v12.  This was a problem only with v17 and newer versions; older  
versions discard the error message already in this case, assuming a  
failure caused by a lack of support for GSS encryption.  
  
Author: Jacob Champion  
Reviewed-by: Peter Eisentraut, Heikki Linnakangas, Michael Paquier  
Security: CVE-2024-10977  
Backpatch-through: 12  

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

Fix broken collate.icu.utf8 test in v12 branch.

commit   : 0ef9ac290ff3370f345fa08091c6586fecd8354f    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 10 Nov 2024 15:45:34 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 10 Nov 2024 15:45:34 -0500    

Click here for diff

collate.icu.utf8.sql is not run by default before v13, and commits  
9c4757491/46d9be5ef evidently didn't bother to test it, with  
the completely predictable result that it was broken.  
We didn't have enable_incremental_sort in v12, plus EXPLAIN makes  
different table alias choices than later branches.  
  
Per buildfarm member copperhead.  

M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql

Release notes for 17.1, 16.5, 15.9, 14.14, 13.17, 12.21.

commit   : 7b9ec11aab362607f0ef4b9c1bbfe76172a659d4    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 10 Nov 2024 13:40:42 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 10 Nov 2024 13:40:42 -0500    

Click here for diff

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

Improve fix for not entering parallel mode when holding interrupts.

commit   : 6e39ca6e7edb97e12274607e285b6a4262b94af9    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 8 Nov 2024 13:42:01 -0500    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 8 Nov 2024 13:42:01 -0500    

Click here for diff

Commit ac04aa84a put the shutoff for this into the planner, which is  
not ideal because it doesn't prevent us from re-using a previously  
made parallel plan.  Revert the planner change and instead put the  
shutoff into InitializeParallelDSM, modeling it on the existing code  
there for recovering from failure to allocate a DSM segment.  
  
However, that code path is mostly untested, and testing a bit harder  
showed there's at least one bug: ExecHashJoinReInitializeDSM is not  
prepared for us to have skipped doing parallel DSM setup.  I also  
thought the Assert in ReinitializeParallelWorkers is pretty  
ill-advised, and replaced it with a silent Min() operation.  
  
The existing test case added by ac04aa84a serves fine to test this  
version of the fix, so no change needed there.  
  
Patch by me, but thanks to Noah Misch for the core idea that we  
could shut off worker creation when !INTERRUPTS_CAN_BE_PROCESSED.  
Back-patch to v12, as ac04aa84a was.  
  
Discussion: https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com  

M src/backend/access/transam/parallel.c
M src/backend/executor/nodeHashjoin.c
M src/backend/optimizer/plan/planner.c

Disallow partitionwise join when collations don't match

commit   : 9c4757491683a10f0531bd206850d15dad8cadeb    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 8 Nov 2024 16:30:54 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 8 Nov 2024 16:30:54 +0900    

Click here for diff

If the collation of any join key column doesn’t match the collation of  
the corresponding partition key, partitionwise joins can yield incorrect  
results. For example, rows that would match under the join key collation  
might be located in different partitions due to the partitioning  
collation. In such cases, a partitionwise join would yield different  
results from a non-partitionwise join, so disallow it in such cases.  
  
Reported-by: Tender Wang <[email protected]>  
Author: Jian He <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Reviewed-by: Junwang Zhao <[email protected]>  
Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com  
Backpatch-through: 12  

M src/backend/optimizer/path/joinrels.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql

Disallow partitionwise grouping when collations don't match

commit   : 46d9be5efb1a36328743d07e456cac5a1a40ec70    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 8 Nov 2024 16:05:33 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 8 Nov 2024 16:05:33 +0900    

Click here for diff

If the collation of any grouping column doesn’t match the collation of  
the corresponding partition key, partitionwise grouping can yield  
incorrect results. For example, rows that would be grouped under the  
grouping collation may end up in different partitions under the  
partitioning collation. In such cases, full partitionwise grouping  
would produce results that differ from those without partitionwise  
grouping, so disallowed that.  
  
Partial partitionwise aggregation is still allowed, as the Finalize  
step reconciles partition-level aggregates with grouping requirements  
across all partitions, ensuring that the final output remains  
consistent.  
  
This commit also fixes group_by_has_partkey() by ensuring the  
RelabelType node is stripped from grouping expressions when matching  
them to partition key expressions to avoid false mismatches.  
  
Bug: #18568  
Reported-by: Webbo Han <[email protected]>  
Author: Webbo Han <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Reviewed-by: Aleksander Alekseev <[email protected]>  
Reviewed-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com  
Backpatch-through: 12  

M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql

Message style improvement

commit   : cae459d11dcd9e0bca73bd59cf1b4c1718a47aa0    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 8 Nov 2024 07:17:55 +0100    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 8 Nov 2024 07:17:55 +0100    

Click here for diff

Backpatch the part of edee0c621de that applies to a90bdd7a44d, which  
was also backpatched.  That way, the message is consistent in all  
branches.  

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

doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints

commit   : 477830c1cb94beeb0440629820ef916c59beabb6    
  
author   : Álvaro Herrera <[email protected]>    
date     : Thu, 7 Nov 2024 14:06:24 +0100    
  
committer: Álvaro Herrera <[email protected]>    
date     : Thu, 7 Nov 2024 14:06:24 +0100    

Click here for diff

The previous wording is easy to read incorrectly; this change makes it  
simpler, less ambiguous, and less prominent.  
  
Backpatch to all live branches.  
  
Reviewed-by: Amit Langote <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Monkey-patch LLVM code to fix ARM relocation bug.

commit   : 50c1453a308dc535255a0048fce7cfdb0fc5219d    
  
author   : Thomas Munro <[email protected]>    
date     : Wed, 6 Nov 2024 22:04:44 +1300    
  
committer: Thomas Munro <[email protected]>    
date     : Wed, 6 Nov 2024 22:04:44 +1300    

Click here for diff

Supply a new memory manager for RuntimeDyld, to avoid crashes in  
generated code caused by memory placement that can overflow a 32 bit  
data type.  This is a drop-in replacement for the  
llvm::SectionMemoryManager class in the LLVM library, with Michael  
Smith's proposed fix from  
https://www.github.com/llvm/llvm-project/pull/71968.  
  
We hereby slurp it into our own source tree, after moving into a new  
namespace llvm::backport and making some minor adjustments so that it  
can be compiled with older LLVM versions as far back as 12.  It's harder  
to make it work on even older LLVM versions, but it doesn't seem likely  
that people are really using them so that is not investigated for now.  
  
The problem could also be addressed by switching to JITLink instead of  
RuntimeDyld, and that is the LLVM project's recommended solution as  
the latter is about to be deprecated.  We'll have to do that soon enough  
anyway, and then when the LLVM version support window advances far  
enough in a few years we'll be able to delete this code.  Unfortunately  
that wouldn't be enough for PostgreSQL today: in most relevant versions  
of LLVM, JITLink is missing or incomplete.  
  
Several other projects have already back-ported this fix into their fork  
of LLVM, which is a vote of confidence despite the lack of commit into  
LLVM as of today.  We don't have our own copy of LLVM so we can't do  
exactly what they've done; instead we have a copy of the whole patched  
class so we can pass an instance of it to RuntimeDyld.  
  
The LLVM project hasn't chosen to commit the fix yet, and even if it  
did, it wouldn't be back-ported into the releases of LLVM that most of  
our users care about, so there is not much point in waiting any longer  
for that.  If they make further changes and commit it to LLVM 19 or 20,  
we'll still need this for older versions, but we may want to  
resynchronize our copy and update some comments.  
  
The changes that we've had to make to our copy can be seen by diffing  
our SectionMemoryManager.{h,cpp} files against the ones in the tree of  
the pull request.  Per the LLVM project's license requirements, a copy  
is in SectionMemoryManager.LICENSE.  
  
This should fix the spate of crash reports we've been receiving lately  
from users on large memory ARM systems.  
  
Back-patch to all supported releases.  
  
Co-authored-by: Thomas Munro <[email protected]>  
Co-authored-by: Anthonin Bonnefoy <[email protected]>  
Reviewed-by: Anthonin Bonnefoy <[email protected]>  
Reviewed-by: Daniel Gustafsson <[email protected]> (license aspects)  
Reported-by: Anthonin Bonnefoy <[email protected]>  
Discussion: https://postgr.es/m/CAO6_Xqr63qj%3DSx7HY6ZiiQ6R_JbX%2B-p6sTPwDYwTWZjUmjsYBg%40mail.gmail.com  

M src/backend/jit/llvm/Makefile
A src/backend/jit/llvm/SectionMemoryManager.LICENSE
A src/backend/jit/llvm/SectionMemoryManager.cpp
M src/backend/jit/llvm/llvmjit.c
M src/backend/jit/llvm/llvmjit_wrap.cpp
A src/include/jit/SectionMemoryManager.h
M src/include/jit/llvmjit.h
A src/include/jit/llvmjit_backport.h

Suppress new "may be used uninitialized" warning.

commit   : 766809db39029115ee3e9e742b59dae4d9476e73    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 19:42:52 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 19:42:52 -0700    

Click here for diff

Buildfarm member mamba fails to deduce that the function never uses this  
variable without initializing it.  Back-patch to v12, like commit  
b412f402d1e020c5dac94f3bf4a005db69519b99.  

M src/backend/catalog/index.c

Move I/O before the index_update_stats() buffer lock region.

commit   : d729f1ea5a46963f3d4b0dd1268f3583b1cdbe9e    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 09:04:55 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 09:04:55 -0700    

Click here for diff

Commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 enlarged the work done  
here under the pg_class heap buffer lock.  Two preexisting actions are  
best done before holding that lock.  Both RelationGetNumberOfBlocks()  
and visibilitymap_count() do I/O, and the latter might exclusive-lock a  
visibility map buffer.  Moving these reduces contention and risk of  
undetected LWLock deadlock.  Back-patch to v12, like that commit.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/index.c

Revert "For inplace update, send nontransactional invalidations."

commit   : 4b0f7d6c162e9a52e5c2bf1098d4ffd0b107425c    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 09:05:00 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 09:05:00 -0700    

Click here for diff

This reverts commit 95c5acb3fc261067ab65ddc0b2dca8e162f09442 (v17) and  
counterparts in each other non-master branch.  If released, that commit  
would have caused a worst-in-years minor release regression, via  
undetected LWLock self-deadlock.  This commit and its self-deadlock fix  
warrant more bake time in the master branch.  
  
Reported by Alexander Lakhin.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/heapam.c
M src/backend/access/transam/xact.c
M src/backend/catalog/index.c
M src/backend/replication/logical/decode.c
M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/inval.c
M src/backend/utils/cache/syscache.c
M src/include/utils/catcache.h
M src/include/utils/inval.h
M src/test/isolation/expected/inplace-inval.out
M src/test/isolation/specs/inplace-inval.spec

Revert "WAL-log inplace update before revealing it to other sessions."

commit   : 5e503e10d13ef7987a5b44b2c463a5d1bf5fd103    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 09:04:59 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 2 Nov 2024 09:04:59 -0700    

Click here for diff

This reverts commit bfd5c6e279c8e1702eea882439dc7ebdf4d4b3a5 (v17) and  
counterparts in each other non-master branch.  This unblocks reverting a  
commit on which it depends.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/README.tuplock
M src/backend/access/heap/heapam.c
M src/backend/access/transam/xloginsert.c

doc: fix ALTER DOMAIN domain_constraint to spell out options

commit   : cd64941f6fcce3f0ca4c4c35f5304160fff2b3e6    
  
author   : Bruce Momjian <[email protected]>    
date     : Fri, 1 Nov 2024 13:54:27 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Fri, 1 Nov 2024 13:54:27 -0400    

Click here for diff

It used to refer to CREATE DOMAIN, but CREATE DOMAIN allows NULL, while  
ALTER DOMAIN does not.  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/ref/alter_domain.sgml

doc: remove mention of ActiveState for Perl and Tcl on Windows

commit   : f5dbbc44f5bb420c3da80d07abf694df42efc61b    
  
author   : Bruce Momjian <[email protected]>    
date     : Fri, 1 Nov 2024 11:30:53 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Fri, 1 Nov 2024 11:30:53 -0400    

Click here for diff

Replace with Strawberry Perl and Magicsplat Tcl.  
  
Reported-by: Yasir Hussain  
  
Discussion: https://postgr.es/m/CAA9OW9fAAM_WDYYpAquqF6j1hmfRMzHPsFkRfP5E6oSfkF=dMA@mail.gmail.com  
  
Backpatch-through: 12  

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

Unpin buffer before inplace update waits for an XID to end.

commit   : c2139db11b161096c9d65a0fa7c1a8a3227ea856    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 29 Oct 2024 09:39:55 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 29 Oct 2024 09:39:55 -0700    

Click here for diff

Commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 changed inplace updates  
to wait for heap_update() commands like GRANT TABLE and GRANT DATABASE.  
By keeping the pin during that wait, a sequence of autovacuum workers  
and an uncommitted GRANT starved one foreground LockBufferForCleanup()  
for six minutes, on buildfarm member sarus.  Prevent, at the cost of a  
bit of complexity.  Back-patch to v12, like the earlier commit.  That  
commit and heap_inplace_lock() have not yet appeared in any release.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/heapam.c
M src/backend/access/index/genam.c
M src/include/access/heapam.h

Update time zone data files to tzdata release 2024b.

commit   : 8f1759c9b4ee8e69ee6630d7f8f1be1e2876f36e    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 29 Oct 2024 11:49:38 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 29 Oct 2024 11:49:38 -0400    

Click here for diff

Historical corrections for Mexico, Mongolia, and Portugal.  
Notably, Asia/Choibalsan is now an alias for Asia/Ulaanbaatar  
rather than being a separate zone, mainly because the differences  
between those zones were found to be based on untrustworthy data.  

M src/timezone/data/tzdata.zi
M src/timezone/known_abbrevs.txt
M src/timezone/tznames/Default
M src/timezone/tznames/Europe.txt

Doc: clarify enable_indexscan=off also disabled Index Only Scans

commit   : 857f13f79994c7314605236b2ab567eb9d6c4766    
  
author   : David Rowley <[email protected]>    
date     : Tue, 29 Oct 2024 16:26:41 +1300    
  
committer: David Rowley <[email protected]>    
date     : Tue, 29 Oct 2024 16:26:41 +1300    

Click here for diff

Disabling enable_indexscan has always also disabled Index Only Scans.  
Here we make that more clear in the documentation in an attempt to  
prevent future complaints complaining about this expected behavior.  
  
Reported-by: Melanie Plageman  
Author: David G. Johnston, David Rowley  
Backpatch-through: 12, oldest supported version  
Discussion: https://postgr.es/m/CAAKRu_atV=kovgpaLREyG68PB5+ncKvJ2UNoeRetEgyC3Yb5Sw@mail.gmail.com  

M doc/src/sgml/config.sgml

WAL-log inplace update before revealing it to other sessions.

commit   : e30d0d8adf534453355024aae68b8b691c105b67    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 25 Oct 2024 06:51:03 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 25 Oct 2024 06:51:03 -0700    

Click here for diff

A buffer lock won't stop a reader having already checked tuple  
visibility.  If a vac_update_datfrozenid() and then a crash happened  
during inplace update of a relfrozenxid value, datfrozenxid could  
overtake relfrozenxid.  That could lead to "could not access status of  
transaction" errors.  Back-patch to v12 (all supported versions).  In  
v14 and earlier, this also back-patches the assertion removal from  
commit 7fcf2faf9c7dd473208fd6d5565f88d7f733782b.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/README.tuplock
M src/backend/access/heap/heapam.c
M src/backend/access/transam/xloginsert.c

For inplace update, send nontransactional invalidations.

commit   : 4cf948cbeedffe597546af6c4a7a7e1d103c3923    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 25 Oct 2024 06:51:02 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 25 Oct 2024 06:51:02 -0700    

Click here for diff

The inplace update survives ROLLBACK.  The inval didn't, so another  
backend's DDL could then update the row without incorporating the  
inplace update.  In the test this fixes, a mix of CREATE INDEX and ALTER  
TABLE resulted in a table with an index, yet relhasindex=f.  That is a  
source of index corruption.  Back-patch to v12 (all supported versions).  
The back branch versions don't change WAL, because those branches just  
added end-of-recovery SIResetAll().  All branches change the ABI of  
extern function PrepareToInvalidateCacheTuple().  No PGXN extension  
calls that, and there's no apparent use case in extensions.  
  
Reviewed by Nitin Motiani and (in earlier versions) Andres Freund.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/heapam.c
M src/backend/access/transam/xact.c
M src/backend/catalog/index.c
M src/backend/replication/logical/decode.c
M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/inval.c
M src/backend/utils/cache/syscache.c
M src/include/utils/catcache.h
M src/include/utils/inval.h
M src/test/isolation/expected/inplace-inval.out
M src/test/isolation/specs/inplace-inval.spec

At end of recovery, reset all sinval-managed caches.

commit   : da9950456463456b8e2c38f5a09bf33fe958a595    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 25 Oct 2024 06:51:06 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 25 Oct 2024 06:51:06 -0700    

Click here for diff

An inplace update's invalidation messages are part of its transaction's  
commit record.  However, the update survives even if its transaction  
aborts or we stop recovery before replaying its transaction commit.  
After recovery, a backend that started in recovery could update the row  
without incorporating the inplace update.  That could result in a table  
with an index, yet relhasindex=f.  That is a source of index corruption.  
  
This bulk invalidation avoids the functional consequences.  A future  
change can fix the !RecoveryInProgress() scenario without changing the  
WAL format.  Back-patch to v17 - v12 (all supported versions).  v18 will  
instead add invalidations to WAL.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xlog.c
M src/backend/storage/ipc/sinvaladt.c
M src/include/storage/sinvaladt.h

Stop reading uninitialized memory in heap_inplace_lock().

commit   : a0c0078b13552e89d9a8667bbe32f1748be1f160    
  
author   : Noah Misch <[email protected]>    
date     : Thu, 24 Oct 2024 09:16:14 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Thu, 24 Oct 2024 09:16:14 -0700    

Click here for diff

Stop computing a never-used value.  This removes the read; the read had  
no functional implications.  Back-patch to v12, like commit  
a07e03fd8fa7daf4d1356f7cb501ffe784ea6257.  
  
Reported by Alexander Lakhin.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/heapam.c
M src/test/isolation/expected/intra-grant-inplace.out
M src/test/isolation/specs/intra-grant-inplace.spec

Remove unnecessary word in a comment

commit   : 0b8fb9e9239b5d2de375f85012354e1ff977b81c    
  
author   : Amit Langote <[email protected]>    
date     : Wed, 23 Oct 2024 17:54:48 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Wed, 23 Oct 2024 17:54:48 +0900    

Click here for diff

Relations opened by the executor are only closed once in  
ExecCloseRangeTableRelations(), so the word "again" in the comment  
for ExecGetRangeTableRelation() is misleading and unnecessary.  
  
Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50oZ05de7wUg=Q@mail.gmail.com  
Backpatch-through: 12  

M src/backend/executor/execUtils.c

ecpg: Fix out-of-bound read in DecodeDateTime()

commit   : 9ecfd8a48adf84ec5603a53a6e1a5add097ab56f    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 23 Oct 2024 08:35:08 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 23 Oct 2024 08:35:08 +0900    

Click here for diff

It was possible for the code to read out-of-bound data from the  
"day_tab" table with some crafted input data.  Let's treat these as  
invalid input as the month number is incorrect.  
  
A test is added to test this case with a check on the errno returned by  
the decoding routine.  A test close to the new one added in this commit  
was testing for a failure, but did not look at the errno generated, so  
let's use this commit to also change it, adding a check on the errno  
returned by DecodeDateTime().  
  
Like the other test scripts, dt_test should likely be expanded to  
include more checks based on the errnos generated in these code paths.  
This is left as future work.  
  
This issue exists since 2e6f97560a83, so backpatch all the way down.  
  
Reported-by: Pavel Nekrasov  
Author: Bruce Momjian, Pavel Nekrasov  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/interfaces/ecpg/pgtypeslib/dt_common.c
M src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
M src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
M src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stdout
M src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc

Fix wrong assertion and poor error messages in "COPY (query) TO".

commit   : 6a57a457cf7d3409579868ef17de6725ec6e67ca    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 21 Oct 2024 15:08:22 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 21 Oct 2024 15:08:22 -0400    

Click here for diff

If the query is rewritten into a NOTIFY command by a DO INSTEAD  
rule, we'd get an assertion failure, or in non-assert builds  
issue a rather confusing error message.  Improve that.  
  
Also fix a longstanding grammar mistake in a nearby error message.  
  
Per bug #18664 from Alexander Lakhin.  Back-patch to all supported  
branches.  
  
Tender Wang and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/copy.c
M src/test/regress/expected/copydml.out
M src/test/regress/sql/copydml.sql

Fix race condition in committing a serializable transaction

commit   : e2ec3afebc238e281df7f3f435c243d9c300046d    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 21 Oct 2024 09:49:21 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 21 Oct 2024 09:49:21 +0300    

Click here for diff

The finished transaction list can contain XIDs that are older than the  
serializable global xmin. It's a short-lived state;  
ClearOldPredicateLocks() removes any such transactions from the list,  
and it's called whenever the global xmin advances. But if another  
backend calls SummarizeOldestCommittedSxact() in that window, it will  
call SerialAdd() on an XID that's older than the global xmin, or if  
there are no more transactions running, when global xmin is  
invalid. That trips the assertion in SerialAdd().  
  
Fixes bug #18658 reported by Andrew Bille. Thanks to Alexander Lakhin  
for analysis. Backpatch to all versions.  
  
Discussion: https://www.postgresql.org/message-id/18658-7dab125ec688c70b%40postgresql.org  

M src/backend/storage/lmgr/predicate.c

Note that index_name in ALTER INDEX ATTACH PARTITION can be schema-qualified

commit   : dd27cc044447202580ab24eedd114a264197710d    
  
author   : Álvaro Herrera <[email protected]>    
date     : Sun, 20 Oct 2024 15:36:20 +0200    
  
committer: Álvaro Herrera <[email protected]>    
date     : Sun, 20 Oct 2024 15:36:20 +0200    

Click here for diff

Missed in 8b08f7d4820f; backpatch to all supported branches.  
  
Reported-by: [email protected]  
Reviewed-by: Tom Lane <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/alter_index.sgml

Fix extreme skew detection in Parallel Hash Join.

commit   : 4fa80a6d7d4bde83065a5e1d84c01522d2fd368c    
  
author   : Thomas Munro <[email protected]>    
date     : Thu, 17 Oct 2024 15:52:24 +1300    
  
committer: Thomas Munro <[email protected]>    
date     : Thu, 17 Oct 2024 15:52:24 +1300    

Click here for diff

After repartitioning the inner side of a hash join that would have  
exceeded the allowed size, we check if all the tuples from a parent  
partition moved to one child partition.  That is evidence that it  
contains duplicate keys and later attempts to repartition will also  
fail, so we should give up trying to limit memory (for lack of a better  
fallback strategy).  
  
A thinko prevented the check from working correctly in partition 0 (the  
one that is partially loaded into memory already).  After  
repartitioning, we should check for extreme skew if the *parent*  
partition's space_exhausted flag was set, not the child partition's.  
The consequence was repeated futile repartitioning until per-partition  
data exceeded various limits including "ERROR: invalid DSA memory alloc  
request size 1811939328", OS allocation failure, or temporary disk space  
errors.  (We could also do something about some of those symptoms, but  
that's material for separate patches.)  
  
This problem only became likely when PostgreSQL 16 introduced support  
for Parallel Hash Right/Full Join, allowing NULL keys into the hash  
table.  Repartitioning always leaves NULL in partition 0, no matter how  
many times you do it, because the hash value is all zero bits.  That's  
unlikely for other hashed values, but they might still have caused  
wasted extra effort before giving up.  
  
Back-patch to all supported releases.  
  
Reported-by: Craig Milhiser <[email protected]>  
Reviewed-by: Andrei Lepikhov <[email protected]>  
Discussion: https://postgr.es/m/CA%2BwnhO1OfgXbmXgC4fv_uu%3DOxcDQuHvfoQ4k0DFeB0Qqd-X-rQ%40mail.gmail.com  

M src/backend/executor/nodeHash.c

Further refine _SPI_execute_plan's rule for atomic execution.

commit   : cf1443d675c58456e317e6402a5648243ac25d02    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 16 Oct 2024 17:36:30 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 16 Oct 2024 17:36:30 -0400    

Click here for diff

Commit 2dc1deaea turns out to have been still a brick shy of a load,  
because CALL statements executing within a plpgsql exception block  
could still pass the wrong snapshot to stable functions within the  
CALL's argument list.  That happened because standard_ProcessUtility  
forces isAtomicContext to true if IsTransactionBlock is true, which  
it always will be inside a subtransaction.  Then ExecuteCallStmt  
would think it does not need to push a new snapshot --- but  
_SPI_execute_plan didn't do so either, since it thought it was in  
nonatomic mode.  
  
The best fix for this seems to be for _SPI_execute_plan to operate  
in atomic execution mode if IsSubTransaction() is true, even when the  
SPI context as a whole is non-atomic.  This makes _SPI_execute_plan  
have the same rules about when non-atomic execution is allowed as  
_SPI_commit/_SPI_rollback have about when COMMIT/ROLLBACK are allowed,  
which seems appropriately symmetric.  (If anyone ever tries to allow  
COMMIT/ROLLBACK inside a subtransaction, this would all need to be  
rethought ... but I'm unconvinced that such a thing could be logically  
consistent at all.)  
  
For further consistency, also check IsSubTransaction() in  
SPI_inside_nonatomic_context.  That does not matter for its  
one present-day caller StartTransaction, which can't be reached  
inside a subtransaction.  But if any other callers ever arise,  
they'd presumably want this definition.  
  
Per bug #18656 from Alexander Alehin.  Back-patch to all  
supported branches, like previous fixes in this area.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/spi.c
M src/pl/plpgsql/src/expected/plpgsql_call.out
M src/pl/plpgsql/src/sql/plpgsql_call.sql

Reduce memory block size for decoded tuple storage to 8kB.

commit   : 53fa68b3bc3a3668524dda86904fd5ddfcf3cb9d    
  
author   : Masahiko Sawada <[email protected]>    
date     : Wed, 16 Oct 2024 12:07:50 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Wed, 16 Oct 2024 12:07:50 -0700    

Click here for diff

Commit a4ccc1cef introduced the Generation Context and modified the  
logical decoding process to use a Generation Context with a fixed  
block size of 8MB for storing tuple data decoded during logical  
decoding (i.e., rb->tup_context). Several reports have indicated that  
the logical decoding process can be terminated due to  
out-of-memory (OOM) situations caused by excessive memory usage in  
rb->tup_context.  
  
This issue can occur when decoding a workload involving several  
concurrent transactions, including a long-running transaction that  
modifies tuples. By design, the Generation Context does not free a  
memory block until all chunks within that block are  
released. Consequently, if tuples modified by the long-running  
transaction are stored across multiple memory blocks, these blocks  
remain allocated until the long-running transaction completes, leading  
to substantial memory fragmentation. The memory usage during logical  
decoding, tracked by rb->size, does not account for memory  
fragmentation, resulting in potentially much higher memory consumption  
than the value of the logical_decoding_work_mem parameter.  
  
Various improvement strategies were discussed in the relevant  
thread. This change reduces the block size of the Generation Context  
used in rb->tup_context from 8MB to 8kB. This modification  
significantly decreases the likelihood of substantial memory  
fragmentation occurring and is relatively straightforward to  
backport. Performance testing across multiple platforms has confirmed  
that this change will not introduce any performance degradation that  
would impact actual operation.  
  
Backport to all supported branches.  
  
Reported-by: Alex Richman, Michael Guissine, Avi Weinberg  
Reviewed-by: Amit Kapila, Fujii Masao, David Rowley  
Tested-by: Hayato Kuroda, Shlok Kyal  
Discussion: https://postgr.es/m/CAD21AoBTY1LATZUmvSXEssvq07qDZufV4AF-OHh9VD2pC0VY2A%40mail.gmail.com  
Backpatch-through: 12  

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

Remove incorrect function import from pgindent

commit   : 610c65064732d25e7a0066ea49b56433b9c2cc4c    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Wed, 9 Oct 2024 09:34:34 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Wed, 9 Oct 2024 09:34:34 +0200    

Click here for diff

Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly  
imported the devnull function from File::Spec, but the module does  
not export anything.  In recent versions of Perl calling a missing  
import function cause a warning, which combined with warnings being  
fatal cause pgindent to error out.  
  
Backpatch to all supported versions.  
  
Author: Erik Wienhold <[email protected]>  
Reviewed-by: Andrew Dunstan <[email protected]>  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Discusson: https://postgr.es/m/[email protected]  
Backpatch-through: v12  

M src/tools/pgindent/pgindent

vacuumdb: Schema-qualify operator in catalog query's WHERE clause.

commit   : 5e0431c32a8f723fcf5b0eea77a4b6144b6abdff    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 7 Oct 2024 16:49:20 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 7 Oct 2024 16:49:20 -0500    

Click here for diff

Commit 1ab67c9dfa, which modified this catalog query so that it  
doesn't return temporary relations, forgot to schema-qualify the  
operator.  A comment earlier in the function implores us to fully  
qualify everything in the query:  
  
	 * Since we execute the constructed query with the default search_path  
	 * (which could be unsafe), everything in this query MUST be fully  
	 * qualified.  
  
This commit fixes that.  While at it, add a newline for consistency  
with surrounding code.  
  
Reviewed-by: Noah Misch  
Discussion: https://postgr.es/m/ZwQJYcuPPUsF0reU%40nathan  
Backpatch-through: 12  

M src/bin/scripts/vacuumdb.c

Fix Y2038 issues with MyStartTime.

commit   : c91d0af0a2ad3d3176eaf508281a4e29bb1975b8    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 7 Oct 2024 13:51:03 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 7 Oct 2024 13:51:03 -0500    

Click here for diff

Several places treat MyStartTime as a "long", which is only 32 bits  
wide on some platforms.  In reality, MyStartTime is a pg_time_t,  
i.e., a signed 64-bit integer.  This will lead to interesting bugs  
on the aforementioned systems in 2038 when signed 32-bit integers  
are no longer sufficient to store Unix time (e.g., "pg_ctl start"  
hanging).  To fix, ensure that MyStartTime is handled as a 64-bit  
value everywhere.  (Of course, users will need to ensure that  
time_t is 64 bits wide on their system, too.)  
  
Co-authored-by: Max Johnson  
Discussion: https://postgr.es/m/CO1PR07MB905262E8AC270FAAACED66008D682%40CO1PR07MB9052.namprd07.prod.outlook.com  
Backpatch-through: 12  

M src/backend/utils/error/elog.c
M src/backend/utils/init/miscinit.c
M src/bin/pg_ctl/pg_ctl.c

Ignore not-yet-defined Portals in pg_cursors view.

commit   : 5c17f5a6392f0367236c912e36708bf332ff8aab    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 6 Oct 2024 16:03:48 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 6 Oct 2024 16:03:48 -0400    

Click here for diff

pg_cursor() supposed that any Portal it finds in the hash table must  
have sourceText set up, but there's an edge case where that is not so.  
A newly-created Portal has sourceText = NULL, and that doesn't change  
until PortalDefineQuery is called.  In SPI_cursor_open_internal,  
we perform GetCachedPlan between CreatePortal and PortalDefineQuery,  
and it's possible for user-defined code to execute during that  
planning and cause a fetch from the pg_cursors view, resulting in a  
null-pointer-dereference crash.  (It looks like the same could happen  
in exec_bind_message, but I've not tried to provoke a failure there.)  
  
I considered trying to fix this by setting sourceText sooner, but  
there may be instances of this same calling pattern in extensions,  
and we couldn't be sure they'd get the memo promptly.  It seems  
better to redefine pg_cursor as not showing Portals that have  
not yet had PortalDefineQuery called on them, which we can do by  
just skipping them if sourceText is still NULL.  
  
(Before a1c692358, pg_cursor would instead return a row with NULL  
in the statement column.  We could revert to that behavior but it  
doesn't really seem like a better definition, especially since our  
documentation doesn't suggest that the column could be NULL.)  
  
Per report from PetSerAl.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/CAKygsHTBXLXjwV43kpZa+Cs+XTiaeeJiZdL4cPBm9f4MTdw7wg@mail.gmail.com  

M src/backend/utils/mmgr/portalmem.c

Parse libpq's "keepalives" option more like other integer options.

commit   : 47d8a15deaebc755daf0289993e5898a3536a107    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 2 Oct 2024 17:30:36 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 2 Oct 2024 17:30:36 -0400    

Click here for diff

Use pqParseIntParam (nee parse_int_param) instead of using strtol  
directly.  This allows trailing whitespace, which the previous coding  
didn't, and makes the spelling of the error message consistent with  
other similar cases.  
  
This seems to be an oversight in commit e7a221797, which introduced  
parse_int_param.  That fixed places that were using atoi(), but missed  
this place which was randomly using strtol() instead.  
  
Ordinarily I'd consider this minor cleanup not worth back-patching.  
However, it seems that ecpg assumes it can add trailing whitespace  
to URL parameters, so that use of the keepalives option fails in  
that context.  Perhaps that's worth improving as a separate matter.  
In the meantime, back-patch this to all supported branches.  
  
Yuto Sasaki (some further cleanup by me)  
  
Discussion: https://postgr.es/m/TY2PR01MB36286A7B97B9A15793335D18C1772@TY2PR01MB3628.jpnprd01.prod.outlook.com  

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

Fix race condition in COMMIT PREPARED causing orphaned 2PC files

commit   : 34d751ba7b302f65c387dc0095c81238e169e1a3    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 1 Oct 2024 15:44:15 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 1 Oct 2024 15:44:15 +0900    

Click here for diff

COMMIT PREPARED removes on-disk 2PC files near its end, but the state  
checked if a file is on-disk or not gets read from shared memory while  
not holding the two-phase state lock.  
  
Because of that, there was a small window where a second backend doing a  
PREPARE TRANSACTION could reuse the GlobalTransaction put back into the  
2PC free list by the COMMIT PREPARED, overwriting the "ondisk" flag read  
afterwards by the COMMIT PREPARED to decide if its on-disk two-phase  
state file should be removed, preventing the file deletion.  
  
This commit fixes this issue so as the "ondisk" flag in the  
GlobalTransaction is read while holding the two-phase state lock, not  
from shared memory after its entry has been added to the free list.  
  
Orphaned two-phase state files flushed to disk after a checkpoint are  
discarded at the beginning of recovery.  However, a truncation of  
pg_xact/ would make the startup process issue a FATAL when it cannot  
read the SLRU page holding the state of the transaction whose 2PC file  
was orphaned, which is a necessary step to decide if the 2PC file should  
be removed or not.  Removing manually the file would be necessary in  
this case.  
  
Issue introduced by effe7d9552dd, so backpatch all the way down.  
  
Mea culpa.  
  
Author: wuchengwen  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

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

Remove NULL dereference from RenameRelationInternal().

commit   : 5a33a39a8bb4540e760110202853aded611b1e7c    
  
author   : Noah Misch <[email protected]>    
date     : Sun, 29 Sep 2024 15:54:25 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sun, 29 Sep 2024 15:54:25 -0700    

Click here for diff

Defect in last week's commit aac2c9b4fde889d13f859c233c2523345e72d32b,  
per Coverity.  Reaching this would need catalog corruption.  Back-patch  
to v12, like that commit.  

M src/backend/commands/tablecmds.c

Avoid 037_invalid_database.pl hang under debug_discard_caches.

commit   : 91e5add02ba98ab3d46db6d3b457d6fd084f1ae3    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 27 Sep 2024 15:28:56 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 27 Sep 2024 15:28:56 -0700    

Click here for diff

Back-patch to v12 (all supported versions).  

M src/test/recovery/t/037_invalid_database.pl

Fix incorrect memory access in VACUUM FULL with invalid toast indexes

commit   : 2f33e68a5c56607ceb3e8a5e4c8d9cf7e6a8c197    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 27 Sep 2024 09:40:22 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 27 Sep 2024 09:40:22 +0900    

Click here for diff

An invalid toast index is skipped in reindex_relation().  These would be  
remnants of a failed REINDEX CONCURRENTLY and they should never been  
rebuilt as there can only be one valid toast index at a time.  
  
REINDEX_REL_SUPPRESS_INDEX_USE, used by CLUSTER and VACUUM FULL, needs  
to maintain a list of the indexes being processed.  The list of indexes  
is retrieved from the relation cache, and includes invalid indexes.  The  
code has missed that invalid toast indexes are ignored in  
reindex_relation() as this leads to a hard failure in reindex_index(),  
and they were left in the reindex pending list, making the list  
inconsistent when rechecked.  The incorrect memory access was happening  
when scanning pg_class for the refresh of pg_database.datfrozenxid, when  
doing a scan of pg_class.  
  
This issue exists since REINDEX CONCURRENTLY exists, where invalid toast  
indexes can exist, so backpatch all the way down.  
  
Reported-by: Alexander Lakhin  
Author: Tender Wang  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/backend/catalog/index.c

tests: Restrict pg_locks queries in advisory_locks.sql to current database

commit   : 81487c83bed99d715b0122d2c49f36390e6c15ad    
  
author   : Andres Freund <[email protected]>    
date     : Wed, 5 Oct 2022 10:44:38 -0700    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 5 Oct 2022 10:44:38 -0700    

Click here for diff

Otherwise testing an existing installation can fail, if there are other locks,  
e.g. from one of the isolation tests.  
  
This was originally applied as c3315a7da57b in 16~, but it is possible  
to see this test fail depending on the concurrent activity for older  
active branches.  
  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

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

vacuumdb: Skip temporary tables in query to build list of relations

commit   : ef57a713580feb5f84f23882e6980cc31e74cf85    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 25 Sep 2024 14:45:01 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 25 Sep 2024 14:45:01 +0900    

Click here for diff

Running vacuumdb with a non-superuser while another user has created a  
temporary table would lead to a mid-flight permission failure,  
interrupting the operation.  vacuum_rel() skips temporary relations of  
other backends, and it makes no sense for vacuumdb to know about these  
relations, so let's switch it to ignore temporary relations entirely.  
  
Adding a qual in the query based on relpersistence simplifies the  
generation of its WHERE clause in vacuum_one_database(), per se the  
removal of "has_where".  
  
Author: VaibhaveS, Michael Paquier  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/CAM_eQjwfAR=y3G1fGyS1U9FTmc+FyJm9amNfY2QCZBnDDbNPZg@mail.gmail.com  
Backpatch-through: 12  

M src/bin/scripts/vacuumdb.c

For inplace update durability, make heap_update() callers wait.

commit   : cafcc3ad0ed324993211b0dce09362aad3165146    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    

Click here for diff

The previous commit fixed some ways of losing an inplace update.  It  
remained possible to lose one when a backend working toward a  
heap_update() copied a tuple into memory just before inplace update of  
that tuple.  In catalogs eligible for inplace update, use LOCKTAG_TUPLE  
to govern admission to the steps of copying an old tuple, modifying it,  
and issuing heap_update().  This includes MERGE commands.  To avoid  
changing most of the pg_class DDL, don't require LOCKTAG_TUPLE when  
holding a relation lock sufficient to exclude inplace updaters.  
Back-patch to v12 (all supported versions).  In v13 and v12, "UPDATE  
pg_class" or "UPDATE pg_database" can still lose an inplace update.  The  
v14+ UPDATE fix needs commit 86dc90056dfdbd9d1b891718d2e5614e3e432f35,  
and it wasn't worth reimplementing that fix without such infrastructure.  
  
Reviewed by Nitin Motiani and (in earlier versions) Heikki Linnakangas.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/README.tuplock
M src/backend/access/heap/heapam.c
M src/backend/access/index/genam.c
M src/backend/catalog/aclchk.c
M src/backend/catalog/catalog.c
M src/backend/commands/dbcommands.c
M src/backend/commands/indexcmds.c
M src/backend/commands/tablecmds.c
M src/backend/executor/execReplication.c
M src/backend/executor/nodeModifyTable.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/cache/syscache.c
M src/include/storage/lockdefs.h
M src/include/utils/syscache.h
M src/test/isolation/expected/intra-grant-inplace.out
M src/test/isolation/specs/eval-plan-qual.spec
M src/test/isolation/specs/intra-grant-inplace.spec

Fix data loss at inplace update after heap_update().

commit   : 7354b680ab64fbde6072f248fe3b2ff909a99d12    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    

Click here for diff

As previously-added tests demonstrated, heap_inplace_update() could  
instead update an unrelated tuple of the same catalog.  It could lose  
the update.  Losing relhasindex=t was a source of index corruption.  
Inplace-updating commands like VACUUM will now wait for heap_update()  
commands like GRANT TABLE and GRANT DATABASE.  That isn't ideal, but a  
long-running GRANT already hurts VACUUM progress more just by keeping an  
XID running.  The VACUUM will behave like a DELETE or UPDATE waiting for  
the uncommitted change.  
  
For implementation details, start at the systable_inplace_update_begin()  
header comment and README.tuplock.  Back-patch to v12 (all supported  
versions).  In back branches, retain a deprecated heap_inplace_update(),  
for extensions.  
  
Reported by Smolkin Grigory.  Reviewed by Nitin Motiani, (in earlier  
versions) Heikki Linnakangas, and (in earlier versions) Alexander  
Lakhin.  
  
Discussion: https://postgr.es/m/CAMp+ueZQz3yDk7qg42hk6-9gxniYbp-=bG2mgqecErqR5gGGOA@mail.gmail.com  

M src/backend/access/heap/README.tuplock
M src/backend/access/heap/heapam.c
M src/backend/access/index/genam.c
M src/backend/catalog/index.c
M src/backend/catalog/toasting.c
M src/backend/commands/dbcommands.c
M src/backend/commands/vacuum.c
M src/include/access/genam.h
M src/include/access/heapam.h
M src/test/isolation/expected/intra-grant-inplace-db.out
M src/test/isolation/expected/intra-grant-inplace.out
M src/test/isolation/specs/intra-grant-inplace-db.spec
M src/test/isolation/specs/intra-grant-inplace.spec

Warn if LOCKTAG_TUPLE is held at commit, under debug_assertions.

commit   : b779d37a3db2555a1d6c571c09eeabfe1c5caeb5    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    

Click here for diff

The current use always releases this locktag.  A planned use will  
continue that intent.  It will involve more areas of code, making unlock  
omissions easier.  Warn under debug_assertions, like we do for various  
resource leaks.  Back-patch to v12 (all supported versions), the plan  
for the commit of the new use.  
  
Reviewed by Heikki Linnakangas.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/lmgr/lock.c
M src/include/storage/lock.h

Back-patch "Refactor code in tablecmds.c to check and process tablespace moves"

commit   : dc845383cd12dcbb09b468b2eea94bf549528a4b    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:24 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:24 -0700    

Click here for diff

Back-patch commits 4c9c359d38ff1e2de388eedd860785be6a49201c and  
24843297a96d7be16cc3f4b090aacfc6e5e6839e to v13 and v12.  Before those  
commits, we held the modifiable copy of the relation's pg_class row  
throughout a table_relation_copy_data().  That can last long enough to  
copy MaxBlockNumber of data.  A subsequent fix will hold LockTuple() for  
the lifespan of that modifiable copy.  By back-patching this first, we  
avoid a needless long-duration LOCKTAG_TUPLE.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/tablecmds.c
M src/include/commands/tablecmds.h

Drop global objects after completed test

commit   : 8ec99d0b79b236c14660ff2f3beb6ee9747e8f5c    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Wed, 3 Apr 2024 13:33:25 +0200    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 3 Apr 2024 13:33:25 +0200    

Click here for diff

Project policy is to not leave global objects behind after a regress  
test run.  This was found as a result of the development of a patch  
to make pg_regress detect such leftovers automatically, which in the  
end was withdrawn due to issues with parallel runs.  
  
This was originally committed as 936e3fa3787a, but the issue also exists  
in the 12~16 range.  
  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/test/modules/test_pg_dump/expected/test_pg_dump.out
M src/test/modules/test_pg_dump/sql/test_pg_dump.sql

Doc: explain how to test ADMIN privilege with pg_has_role().

commit   : 0ce8008386cabac026c27be86776f717f0bb229b    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 20 Sep 2024 15:56:34 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 20 Sep 2024 15:56:34 -0400    

Click here for diff

This has always been possible, but the syntax is a bit obscure,  
and our user-facing docs were not very helpful.  Spell it out  
more clearly.  
  
Per complaint from Dominique Devienne.  Back-patch to  
all supported branches.  
  
Discussion: https://postgr.es/m/CAFCRh-8JNEy+dV4SXFOrWca50u+d=--TO4cq=+ac1oBtfJy4AA@mail.gmail.com  

M doc/src/sgml/func.sgml

commit   : 940bcf80aa76a5f1e65b34d1db638f2079a07d84    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 18:05:21 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 18:05:21 -0400    

Click here for diff

Make paragraph empty instead of removing it.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/stylesheet-fo.xsl

doc PG relnotes: document "Unresolved ID reference found" cause

commit   : 468501b17a3a371ee9337ab8965568e6f76770fb    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 12:01:58 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 12:01:58 -0400    

Click here for diff

Backpatch-through: 12  

M doc/src/sgml/stylesheet-fo.xsl

commit   : e65b6c012e24259ef195ad3ac41ca5e04298170b    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 09:47:22 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 09:47:22 -0400    

Click here for diff

FYI, during PDF builds, this link type generates a "Unresolved ID  
reference found" warning because it is suppressed from the PDF output.  
  
Backpatch-through: 12  

M doc/src/sgml/release.sgml
M doc/src/sgml/stylesheet-fo.xsl

commit   : 8adb4f233aa124de2e1806af00d0e004d5320d58    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 08:45:32 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 08:45:32 -0400    

Click here for diff

Reported-by: Andrew Dunstan  
  
Discussion: https://postgr.es/m/[email protected]  
  
Author: Andrew Dunstan  
  
Backpatch-through: 12  

M src/tools/add_commit_links.pl

doc PG relnotes: add paragraph explaining the section symbol

commit   : 923241acb15659c8fbbadeab1a6ce7b687672fd3    
  
author   : Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 17:13:19 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 17:13:19 -0400    

Click here for diff

And suppress the symbol in print mode, where the section symbol does not  
appear.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/release.sgml
M doc/src/sgml/stylesheet-fo.xsl

commit   : 67ffd2eb52a59474c2046fae95e3e3e8f4a854e4    
  
author   : Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 16:34:51 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 16:34:51 -0400    

Click here for diff

In print output, there are too many commit links for footnotes in the  
release notes to be useful.  
  
Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/stylesheet-fo.xsl

Don't enter parallel mode when holding interrupts.

commit   : 507b72bd9f7de95a224ae5af8797f42bfce1ed9c    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 17 Sep 2024 19:53:11 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 17 Sep 2024 19:53:11 -0700    

Click here for diff

Doing so caused the leader to hang in wait_event=ParallelFinish, which  
required an immediate shutdown to resolve.  Back-patch to v12 (all  
supported versions).  
  
Francesco Degrassi  
  
Discussion: https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com  

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

doc PG relnotes: fix SGML markup for new commit links

commit   : 011659d498357f4c0f243816140b09085422d309    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 14:23:39 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 14:23:39 -0400    

Click here for diff

Backpatch-through: 12  

M doc/src/sgml/postgres.sgml

commit   : 81978404a3960ad90f6f1531af702268e7f81864    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 14:14:37 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 14:14:37 -0400    

Click here for diff

Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

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

commit   : 63357b6c7f631131488b8af83d10d9dedfdccaab    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 13:26:36 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 13:26:36 -0400    

Click here for diff

Reported-by: jian he  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M src/tools/RELEASE_CHANGES
A src/tools/add_commit_links.pl

Replace usages of xmlXPathCompile() with xmlXPathCtxtCompile().

commit   : 0206795d2595e60117dbb4729e2f0ba904b39bd6    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 15 Sep 2024 13:33:09 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 15 Sep 2024 13:33:09 -0400    

Click here for diff

In existing releases of libxml2, xmlXPathCompile can be driven  
to stack overflow because it fails to protect itself against  
too-deeply-nested input.  While there is an upstream fix as of  
yesterday, it will take years for that to propagate into all  
shipping versions.  In the meantime, we can protect our own  
usages basically for free by calling xmlXPathCtxtCompile instead.  
  
(The actual bug is that libxml2 keeps its nesting counter in the  
xmlXPathContext, and its parsing code was willing to just skip  
counting nesting levels if it didn't have a context.  So if we supply  
a context, all is well.  It seems odd actually that it works at all  
to not supply a context, because this means that XPath parsing does  
not have access to XML namespace info.  Apparently libxml2 never  
checks namespaces until runtime?  Anyway, this seems like good  
future-proofing even if its only immediate effect is to dodge a bug.)  
  
Sadly, this hack only offers protection with libxml2 2.9.11 and newer.  
Before that there are multiple similar problems, so if you are  
processing untrusted XML it behooves you to get a newer version.  
But we have some pretty old libxml2 in the buildfarm, so it seems  
impractical to add a regression test to verify this fix.  
  
Per bug #18617 from Jingzhou Fu.  Back-patch to all supported  
versions.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://gitlab.gnome.org/GNOME/libxml2/-/issues/799  

M contrib/xml2/xpath.c
M src/backend/utils/adt/xml.c

doc PG relnotes: add attribution for time zone data files items

commit   : c9c0c466caf229be71ebabcb2c2638bbfd80f958    
  
author   : Bruce Momjian <[email protected]>    
date     : Sat, 14 Sep 2024 19:51:54 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Sat, 14 Sep 2024 19:51:54 -0400    

Click here for diff

This is needed for a future script to add commit links;  specifically we  
need the closing parentheses of the attribution.  
  
Backpatch-through: 12  

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

Run regression tests with timezone America/Los_Angeles.

commit   : 205813da4c264d80db3c3215db199cc119e18369    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 14 Sep 2024 17:55:03 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 14 Sep 2024 17:55:03 -0400    

Click here for diff

Historically we've used timezone "PST8PDT", but the recent release  
2024b of tzdb changes the definition of that zone in a way that  
breaks many test cases concerned with dates before 1970.  Although  
we've not yet adopted 2024b into our own tree, this is already  
problematic for people using --with-system-tzdata if their platform  
has already adopted 2024b.  To work with both older and newer  
versions of tzdb, switch to using "America/Los_Angeles", accepting  
the ensuing changes in regression test results.  
  
Back-patch to all supported branches.  
  
Per report and patch from Wolfgang Walther.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/set.sgml
M doc/src/sgml/regress.sgml
M src/test/regress/expected/date.out
M src/test/regress/expected/horology.out
M src/test/regress/expected/timestamptz.out
M src/test/regress/pg_regress.c
M src/test/regress/sql/horology.sql
M src/test/regress/sql/timestamptz.sql

Only define NO_THREAD_SAFE_LOCALE for MSVC plperl when required

commit   : d94e3b33eaf6c57109a21115572ac78124da5939    
  
author   : Andrew Dunstan <[email protected]>    
date     : Sat, 14 Sep 2024 08:37:08 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Sat, 14 Sep 2024 08:37:08 -0400    

Click here for diff

Latest versions of Strawberry Perl define USE_THREAD_SAFE_LOCALE, and we  
therefore get a handshake error when building against such instances.  
The solution is to perform a test to see if USE_THREAD_SAFE_LOCALE is  
defined and only define NO_THREAD_SAFE_LOCALE if it isn't.  
  
Backpatch the meson.build fix back to release 16 and apply the same  
logic to Mkvcbuild.pm in releases 12 through 16.  
  
Original report of the issue from Muralikrishna Bandaru.  

M src/tools/msvc/Mkvcbuild.pm

Allow _h_indexbuild() to be interrupted.

commit   : 813ade54806c0bce9a0b74db4e7977f9d0be0185    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 13 Sep 2024 16:16:47 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 13 Sep 2024 16:16:47 -0400    

Click here for diff

When we are building a hash index that is large enough to need  
pre-sorting (larger than either maintenance_work_mem or NBuffers),  
the initial sorting phase is interruptible, but the insertion  
phase wasn't.  Add the missing CHECK_FOR_INTERRUPTS().  
  
Per bug #18616 from Alexander Lakhin.  Back-patch to all  
supported branches.  
  
Pavel Borisov  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/hash/hashsort.c

Fix contrib/pageinspect's test for sequences.

commit   : e0277d90acf6f328d3dfc804238682490124fbb3    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 13 Sep 2024 10:16:40 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 13 Sep 2024 10:16:40 -0500    

Click here for diff

I managed to break this test in two different ways in commit  
05036a3155.  
  
First, the output of the new call to tuple_data_split() on the test  
sequence is dependent on endianness.  This is fixed by setting a  
special start value for the test sequence that produces the same  
output regardless of the endianness of the machine.  
  
Second, on versions older than v15, the new test case fails under  
"force_parallel_mode = regress" with the following error:  
  
	ERROR:  cannot access temporary tables during a parallel operation  
  
This is because pageinspect's disk-accessing functions are  
incorrectly marked PARALLEL SAFE on versions older than v15 (see  
commit aeaaf520f4 for details).  This one is fixed by changing the  
test sequence to be permanent.  The only reason it was previously  
marked temporary was to avoid needing a DROP SEQUENCE command at  
the end of the test.  Unlike some other tests in this file, the use  
of a permanent sequence here shouldn't result in any test  
instability like what was fixed by commit e2933a6e11.  
  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/ZuOKOut5hhDlf_bP%40nathan  
Backpatch-through: 12  

M contrib/pageinspect/expected/page.out
M contrib/pageinspect/sql/page.sql

Reintroduce support for sequences in pgstattuple and pageinspect.

commit   : dd5670fa549ec5b06f331b55353f54df8b786449    
  
author   : Nathan Bossart <[email protected]>    
date     : Thu, 12 Sep 2024 16:31:29 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Thu, 12 Sep 2024 16:31:29 -0500    

Click here for diff

Commit 4b82664156 restricted a number of functions provided by  
contrib modules to only relations that use the "heap" table access  
method.  Sequences always use this table access method, but they do  
not advertise as such in the pg_class system catalog, so the  
aforementioned commit also (presumably unintentionally) removed  
support for sequences from some of these functions.  This commit  
reintroduces said support for sequences to these functions and adds  
a couple of relevant tests.  
  
Co-authored-by: Ayush Vatsa  
Reviewed-by: Robert Haas, Michael Paquier, Matthias van de Meent  
Discussion: https://postgr.es/m/CACX%2BKaP3i%2Bi9tdPLjF5JCHVv93xobEdcd_eB%2B638VDvZ3i%3DcQA%40mail.gmail.com  
Backpatch-through: 12  

M contrib/pageinspect/expected/page.out
M contrib/pageinspect/heapfuncs.c
M contrib/pageinspect/sql/page.sql
M contrib/pgstattuple/expected/pgstattuple.out
M contrib/pgstattuple/pgstattuple.c
M contrib/pgstattuple/sql/pgstattuple.sql

Remove incorrect Assert.

commit   : 2be0e863204e08ff00c2c94f1750965d25cebb9f    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 11 Sep 2024 11:41:47 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 11 Sep 2024 11:41:47 -0400    

Click here for diff

check_agglevels_and_constraints() asserted that if we find an  
aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the  
expression must be in a LATERAL subquery.  Alexander Lakhin found a  
case where that's not so: because of the odd scoping rules for NEW/OLD  
within a rule, a reference to NEW/OLD could cause an aggregate to be  
considered top-level even though it's in an unmarked sub-select.  
The error message that would be thrown seems sufficiently on-point,  
so just remove the Assert.  (Hence, this is not a bug for production  
builds.)  
  
This Assert was added by me in commit eaccfded9 (9.3 era).  It looks  
like I put it in to cross-check that the new logic for detecting  
misplaced aggregates (using agglevelsup) caught the same cases that a  
previous check on p_lateral_active did.  So there might have been some  
related misbehavior before eaccfded9 ... but that's very ancient  
history by now, so I didn't dig any deeper.  
  
Per bug #18608 from Alexander Lakhin.  Back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/parser/parse_agg.c

Stabilize 039_end_of_wal test.

commit   : 4f8cefcadef318f5ea446943a473e7364bd40ec6    
  
author   : Thomas Munro <[email protected]>    
date     : Sat, 31 Aug 2024 14:32:08 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Sat, 31 Aug 2024 14:32:08 +1200    

Click here for diff

The first test was sensitive to the insert LSN after setting up the  
catalogs, which depended on environmental things like the locales on the  
OS and usernames.  Switch to a new WAL file before the first test, as a  
simple way to put every computer into the same state.  
  
Back-patch to all supported releases.  
  
Reported-by: Anton Voloshin <[email protected]>  
Reported-by: Nathan Bossart <[email protected]>  
Reviewed-by: Tom Lane <[email protected]>  
Reviewed-by: Nathan Bossart <[email protected]>  
Discussion: https://postgr.es/m/b26aeac2-cb6d-4633-a7ea-945baae83dcf%40postgrespro.ru  

M src/test/recovery/t/039_end_of_wal.pl

Clarify restrict_nonsystem_relation_kind description.

commit   : 6f2525c775f28600038d8f06d361c9b059dad686    
  
author   : Masahiko Sawada <[email protected]>    
date     : Fri, 30 Aug 2024 15:05:55 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Fri, 30 Aug 2024 15:05:55 -0700    

Click here for diff

This change improves the description of the  
restrict_nonsystem_relation_kind parameter in guc_table.c and the  
documentation for better clarity.  
  
Backpatch to 12, where this GUC parameter was introduced.  
  
Reviewed-by: Peter Eisentraut  
Discussion: https://postgr.es/m/6a96f1af-22b4-4a80-8161-1f26606b9ee2%40eisentraut.org  
Backpatch-through: 12  

M doc/src/sgml/config.sgml
M src/backend/utils/misc/guc.c

Disallow USING clause when altering type of generated column

commit   : 1c57ae795b3c0650cbac13e0f59f326ddc34c5d0    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 08:38:29 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 08:38:29 +0200    

Click here for diff

This does not make sense.  It would write the output of the USING  
clause into the converted column, which would violate the generation  
expression.  This adds a check to error out if this is specified.  
  
There was a test for this, but that test errored out for a different  
reason, so it was not effective.  
  
Reported-by: Jian He <[email protected]>  
Reviewed-by: Yugo NAGATA <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/c7083982-69f4-4b14-8315-f9ddb20b9834%40eisentraut.org  

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

Document limit on the number of out-of-line values per table

commit   : 5ff394503ce2b5b63239ec23fcaca1dc1d1ff049    
  
author   : John Naylor <[email protected]>    
date     : Tue, 20 Aug 2024 10:02:34 +0700    
  
committer: John Naylor <[email protected]>    
date     : Tue, 20 Aug 2024 10:02:34 +0700    

Click here for diff

Document the hard limit stemming from the size of an OID, and also  
mention the perfomance impact that occurs before the hard limit  
is reached.  
  
Jakub Wartak and Robert Haas  
Backpatch to all supported versions  
  
Discussion: https://postgr.es/m/CAKZiRmwWhp2yxjqJLwbBjHdfbJBcUmmKMNAZyBjjtpgM9AMatQ%40mail.gmail.com  

M doc/src/sgml/limits.sgml

Explain dropdb can't use syscache because of TOAST

commit   : 9d42627bcaffb34d4c165a4618583a81db67c48d    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 13:31:51 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 13:31:51 +0200    

Click here for diff

Add a comment explaining dropdb() can't rely on syscache. The issue with  
flattened rows was fixed by commit 0f92b230f88b, but better to have  
a clear explanation why the systable scan is necessary. The other places  
doing in-place updates on pg_database have the same comment.  
  
Suggestion and patch by Yugo Nagata. Backpatch to 12, same as the fix.  
  
Author: Yugo Nagata  
Backpatch-through: 12  
Discussion: https://postgr.es/m/CAJTYsWWNkCt+-UnMhg=BiCD3Mh8c2JdHLofPxsW3m2dkDFw8RA@mail.gmail.com  

M src/backend/commands/dbcommands.c

Fix regression in TLS session ticket disabling

commit   : cd98a142cb37fbef82b94a88cd72ed936854991c    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Mon, 19 Aug 2024 12:55:11 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Mon, 19 Aug 2024 12:55:11 +0200    

Click here for diff

Commit 274bbced disabled session tickets for TLSv1.3 on top of the  
already disabled TLSv1.2 session tickets, but accidentally caused  
a regression where TLSv1.2 session tickets were incorrectly sent.  
Fix by unconditionally disabling TLSv1.2 session tickets and only  
disable TLSv1.3 tickets when the right version of OpenSSL is used.  
  
Backpatch to all supported branches.  
  
Reported-by: Cameron Vogt <[email protected]>  
Reported-by: Fire Emerald <[email protected]>  
Reviewed-by: Jacob Champion <[email protected]>  
Discussion: https://postgr.es/m/DM6PR16MB3145CF62857226F350C710D1AB852@DM6PR16MB3145.namprd16.prod.outlook.com  
Backpatch-through: v12  

M src/backend/libpq/be-secure-openssl.c

Fix DROP DATABASE for databases with many ACLs

commit   : f18d3e47f0fe2743ea9d93b10fedd504ba818f4a    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 00:04:41 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 00:04:41 +0200    

Click here for diff

Commit c66a7d75e652 modified DROP DATABASE so that if interrupted, the  
database is known to be in an invalid state and can only be dropped.  
This is done by setting a flag using an in-place update, so that it's  
not lost in case of rollback.  
  
For databases with many ACLs, this may however fail like this:  
  
  ERROR:  wrong tuple length  
  
This happens because with many ACLs, the pg_database.datacl attribute  
gets TOASTed. The dropdb() code reads the tuple from the syscache, which  
means it's detoasted. But the in-place update expects the tuple length  
to match the on-disk tuple.  
  
Fixed by reading the tuple from the catalog directly, not from syscache.  
  
Report and fix by Ayush Tiwari. Backpatch to 12. The DROP DATABASE fix  
was backpatched to 11, but 11 is EOL at this point.  
  
Reported-by: Ayush Tiwari  
Author: Ayush Tiwari  
Reviewed-by: Tomas Vondra  
Backpatch-through: 12  
Discussion: https://postgr.es/m/CAJTYsWWNkCt+-UnMhg=BiCD3Mh8c2JdHLofPxsW3m2dkDFw8RA@mail.gmail.com  

M src/backend/commands/dbcommands.c

docs: fix incorrect plpgsql error message

commit   : 005262a03da66ab93a5ba69f0f41926e9b2e1ab6    
  
author   : Bruce Momjian <[email protected]>    
date     : Fri, 16 Aug 2024 22:50:54 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Fri, 16 Aug 2024 22:50:54 -0400    

Click here for diff

Change "$1" to "username".  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/plpgsql.sgml

Fix creation of partition descriptor during concurrent detach+drop

commit   : 559ae1336e030c427e6a7df3ad59e657fd77734c    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 18:17:56 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 18:17:56 -0400    

Click here for diff

If a partition undergoes DETACH CONCURRENTLY immediately followed by  
DROP, this could cause a problem for a concurrent transaction  
recomputing the partition descriptor when running a prepared statement,  
because it tries to dereference a pointer to a tuple that's not found in  
a catalog scan.  
  
The existing retry logic added in commit dbca3469ebf8 is sufficient to  
cope with the overall problem, provided we don't try to dereference a  
non-existant heap tuple.  
  
Arguably, the code in RelationBuildPartitionDesc() has been wrong all  
along, since no check was added in commit 898e5e3290a7 against receiving  
a NULL tuple from the catalog scan; that bug has only become  
user-visible with DETACH CONCURRENTLY which was added in branch 14.  
Therefore, even though there's no known mechanism to cause a crash  
because of this, backpatch the addition of such a check to all supported  
branches.  In branches prior to 14, this would cause the code to fail  
with a "missing relpartbound for relation XYZ" error instead of  
crashing; that's okay, because there are no reports of such behavior  
anyway.  
  
Author: Kuntal Ghosh <[email protected]>  
Reviewed-by: Junwang Zhao <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/partitioning/partdesc.c

Allow adjusting session_authorization and role in parallel workers.

commit   : adc28d01e98bdfaf9720d363447124d22565620a    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 10 Aug 2024 15:51:28 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 10 Aug 2024 15:51:28 -0400    

Click here for diff

The code intends to allow GUCs to be set within parallel workers  
via function SET clauses, but not otherwise.  However, doing so fails  
for "session_authorization" and "role", because the assign hooks for  
those attempt to set the subsidiary "is_superuser" GUC, and that call  
falls foul of the "not otherwise" prohibition.  We can't switch to  
using GUC_ACTION_SAVE for this, so instead add a new GUC variable  
flag GUC_ALLOW_IN_PARALLEL to mark is_superuser as being safe to set  
anyway.  (This is okay because is_superuser has context PGC_INTERNAL  
and thus only hard-wired calls can change it.  We'd need more thought  
before applying the flag to other GUCs; but maybe there are other  
use-cases.)  This isn't the prettiest fix perhaps, but other  
alternatives we thought of would be much more invasive.  
  
While here, correct a thinko in commit 059de3ca4: when rejecting  
a GUC setting within a parallel worker, we should return 0 not -1  
if the ereport doesn't longjmp.  (This seems to have no consequences  
right now because no caller cares, but it's inconsistent.)  Improve  
the comments to try to forestall future confusion of the same kind.  
  
Despite the lack of field complaints, this seems worth back-patching.  
Thanks to Nathan Bossart for the idea to invent a new flag,  
and for review.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/misc/guc.c
M src/include/utils/guc.h
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql

doc: Fix name of CRC algorithm in "Reliability" section.

commit   : 016c3ea26c0a156b28e33915ab2575d73039cf5a    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 9 Aug 2024 10:52:37 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 9 Aug 2024 10:52:37 -0500    

Click here for diff

This section claims we use CRC-32 for WAL records and two-phase  
state files, but we've actually used CRC-32C since v9.5 (commit  
5028f22f6e).  Fix that.  
  
Reviewed-by: Robert Haas  
Discussion: https://postgr.es/m/ZrUFpLP-w2zTAHqq%40nathan  
Backpatch-through: 12  

M doc/src/sgml/wal.sgml

Fix "failed to find plan for subquery/CTE" errors in EXPLAIN.

commit   : 7408772de56302f72694943d44a660f35aaf410e    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 9 Aug 2024 11:21:39 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 9 Aug 2024 11:21:39 -0400    

Click here for diff

To deparse a reference to a field of a RECORD-type output of a  
subquery, EXPLAIN normally digs down into the subquery's plan to try  
to discover exactly which anonymous RECORD type is meant.  However,  
this can fail if the subquery has been optimized out of the plan  
altogether on the grounds that no rows could pass the WHERE quals,  
which has been possible at least since 3fc6e2d7f.  There isn't  
anything remaining in the plan tree that would help us, so fall back  
to printing the field name as "fN" for the N'th column of the record.  
(This will actually be the right thing some of the time, since it  
matches the column names we assign to RowExprs.)  
  
In passing, fix a comment typo in create_projection_plan, which  
I noticed while experimenting with an alternative fix for this.  
  
Per bug #18576 from Vasya B.  Back-patch to all supported branches.  
  
Richard Guo and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/plan/createplan.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/rowtypes.out
M src/test/regress/sql/rowtypes.sql

Refuse ATTACH of a table referenced by a foreign key

commit   : 17ed92e1ff60392e9dbfbee79824e45ae0751a0b    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 19:35:13 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 19:35:13 -0400    

Click here for diff

Trying to attach a table as a partition which is already on the  
referenced side of a foreign key on the partitioned table that it is  
being attached to, leads to strange behavior: we try to clone the  
foreign key from the parent to the partition, but this new FK points to  
the partition itself, and the mix of pg_constraint rows and triggers  
doesn't behave well.  
  
Rather than trying to untangle the mess (which might be possible given  
sufficient time), I opted to forbid the ATTACH.  This doesn't seem a  
problematic restriction, given that we already fail to create the  
foreign key if you do it the other way around, that is, having the  
partition first and the FK second.  
  
Backpatch to all supported branches.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Fix pg_rewind debug output to print the source timeline history

commit   : 8b86e289f7f0db1b1b95c33c880c26393ecd414e    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 8 Aug 2024 10:20:25 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 8 Aug 2024 10:20:25 +0300    

Click here for diff

getTimelineHistory() is called twice, to read the source and the  
target timeline history files. However, the loop to print the file  
with the --debug option used the wrong variable when dealing with the  
source. As a result, the source's history was always printed as empty.  
  
Spotted while debugging bug #18575, but this does not fix that bug,  
just the debugging output. Backpatch to all supported versions.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/bin/pg_rewind/pg_rewind.c

Teach RPM the package name provided in Perl alias packages.

commit   : 646b16bcafeaa98d7a085ccf4bef11dfc0999fb8    
  
author   : Noah Misch <[email protected]>    
date     : Wed, 7 Aug 2024 11:43:34 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Wed, 7 Aug 2024 11:43:34 -0700    

Click here for diff

When commit 1185be355462d1dc7e2950a7e52eb7ca0cb6f3c8 introduced  
installation of a file containing "use PostgreSQL::Test::Utils", the RPM  
Package Manager said "nothing provides perl(PostgreSQL::Test::Utils)".  
Discussed on pgsql-packagers.  Back-patch to v12, v13, and v14 only;  
newer versions don't have the alias packages.  
  
Reviewed by Andrew Dunstan, Tom Lane, and John Harvey.  Reported by John  
Harvey.  

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