PostgreSQL 14.25 commit log

Stamp 14.25.

commit   : 9adcf5f8847e0f485a390b1d3ea40688068d71bd    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 15:16:32 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 15:16:32 -0500    

Click here for diff

M configure
M configure.ac

Last-minute updates for release notes.

commit   : 1a6533506b3e6639fe6e48ee881b31aa76bfca54    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 12:43:05 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 12:43:05 -0500    

Click here for diff

Security: CVE-2026-6460 and many more.  

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

Update .abi-compliance-history for attribute versioning changes.

commit   : cc4434f15965bc2a996e401ef00eba97007cd825    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 11:45:01 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 11:45:01 -0500    

Click here for diff

Security: CVE-2026-6460  
Backpatch-through: 14-18  

M .abi-compliance-history

Work around broken TimescaleDB code

commit   : 37218773e20476fc2bce92074bc54055c0eefed3    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

TimescaleDB crashes if an attribute option is present during chunk  
creation as part of a DDL command, due to calling AlterTableInternal()  
without having set up event trigger state.  With the introduction of  
attribute versioning, which stores the version in an internal attribute  
option in the back-branches, attribute options are much more common.  
  
The breakage is easy enough to work around, so do that.  
  
This will only be applied to release branches, as this is clearly a bug  
in TimescaleDB.  
  
Security: CVE-2026-6460  
Backpatch-through: 14-19  

M src/backend/commands/event_trigger.c

Add checks for cross-rowtype deforming and conversions

commit   : cb85ce77f19f6cebd3669e08cdf1654a3613bc80    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

The previously added attribute versioning checks prevent cases of  
deforming a datum tuple with an incompatible tuple descriptor for the  
same type.  However, we have a number of cases where we deform a datum  
tuple with a descriptor for a different relation. The additional checks  
introduces here add verification for such cases, by checking that the  
tuple descriptors are compatible.  
  
The following cases are now checked during deforming:  
  
- Deforming a versioned tuple with a RECORDOID tupledesc  
  
  This can happen with triggers and EvalPlanQual rechecks of function  
  scans.  
  
- Deforming a versioned tuple with a tupledesc for another relation  
  
  This happens a bunch for partitioned tables.  
  
Additionally, when changing the type of a tuple, the old and new types  
are compared for compatibility. This currently happens in:  
  
- heap_copy_tuple_as_datum() and via that in places like  
  ExecEvalConvertRowtype(), ExecFetchSlotHeapTupleDatum(), ...  
  
- plpgsql's coerce_function_result_tuple()  
  
In a perfect world these extra checks would not be needed. But...  
  
It is perhaps worth noting that this knowingly emits error messages in  
an untranslatable way. That was considered acceptable for now, these  
error checks should not normally be hit.  
  
Note that these checks do add nontrivial overhead. This is ameliorated  
by the fact that the common ways to reach the checks are part of already  
expensive operations (like trigger invocations during DML into a  
partitioned table), which are expensive enough to make the added  
overhead comparatively small.  
  
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/access/common/heaptuple.c
M src/test/isolation/expected/eval-plan-qual-rowtype-alter.out
M src/test/regress/expected/rowtypes_alter.out

Add attribute versioning specific tests

commit   : a4ba2720b3cb7e6a68848eb649c1ff3a91e852d4    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Some of these were originally written with AI contributions, but they  
have been heavily rewritten since.  
  
The most important thing this tests is pg_upgrade's handling of  
attribute versions, including verification of composite columns staying  
properly readable across upgrades.  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

M contrib/test_decoding/Makefile
A contrib/test_decoding/expected/rowtypes_alter.out
A contrib/test_decoding/sql/rowtypes_alter.sql
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/pg_upgrade/Makefile
A src/bin/pg_upgrade/t/009_composite_types.pl
M src/test/regress/expected/alter_table.out
A src/test/regress/expected/attribute_version.out
M src/test/regress/input/create_function_0.source
M src/test/regress/output/create_function_0.source
M src/test/regress/parallel_schedule
M src/test/regress/regress.c
M src/test/regress/sql/alter_table.sql
A src/test/regress/sql/attribute_version.sql

Introduce attribute versioning to prevent unsafe deforming

commit   : 1d74a4aaf73bddde0785a1e14df55c5a8b00f558    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Using a tuple descriptor that does not match the "shape" of a composite  
datum can lead to crashes, spurious errors and can be used for exploits.  
While postgres has code that prevents such mismatches, there are a  
number of weaknesses in those protections that are nontrivial to fix,  
particularly in the back-branches.  
  
This commit introduces a new safety layer to prevent the worst of the  
negative consequences. From now on, composite datums are marked as such  
and named composite datums are versioned, allowing detection of  
mismatches between a tuple descriptor and the composite during  
deforming. In case of mismatches, errors are raised.  
  
For details about how this works, see  
src/backend/catalog/README.attver.md.  
  
Note that, over time, we should prevent most of the things that the  
safety layer detects at a higher level.  
  
This fixes a number of security relevant composite type confusions.  
  
This is a significant piece of infrastructure grafted onto the existing  
code, in a back-patchable way.  There unfortunately still are some  
compatibility issues due to this commit:  
  
- To get the full protection, extensions need to be rebuilt, due to  
  DatumGetHeapTupleHeader() not being a macro anymore (but an  
  out-of-line function). That also means that some extensions built  
  against a minor version with this change will fail with a linker  
  failure when loaded in an earlier minor version.  
  
  Extensions that have not been recompiled can observe  
  HeapTupleHeaderGetTypMod() returning parts of the version instead of  
  -1.  
  
- Upgrading to a minor version with this fix, performing DDL,  
  downgrading and then upgrading again can cause errors for composite  
  datums formed while downgraded; DDL while downgraded can additionally  
  break the version invariants.  
  
- Code looking at pg_attribute.attoptions will see the new pg_attver  
  key, which could lead to external applications setting this new key  
  via DDL.  
  
  To reduce the impact of that, ALTER COLUMN ... SET (pg_attver = ...)  
  is ignored.  
  
- Dumps of a server with this change, made by a pg_dump without it,  
  contain ALTER COLUMN ... SET (pg_attver = ...), which servers without  
  this change reject.  As pg_upgrade uses the target's pg_dump,  
  upgrading from a minor version with this change to a minor version of  
  a later major version without it fails.  
  
- Use of TupleDescCopy() is forbidden with tupledescs for named  
  composites. The new TupleDescCopySize()/TupleDescCopySized() can copy  
  any descriptor, and verify that the destination is large enough.  
  
- Code that forms datums and then modifies fields in t_choice.t_datum  
  without removing HEAP_IS_DATUM can trigger spurious errors. To reduce  
  the impact of that, the version check skips some known cases of such  
  modifications (see list below for the known effects on extensions).  
  
- DatumGetHeapTupleHeader() will be slower when pre-upgrade tuples are  
  passed, due to copying those datums before modifying them.  
  
- Tuples returned by heap_form_tuple() are now marked as datum tuples  
  and, for named composites, version-checked when deformed. Code that  
  writes such tuples to its own storage needs to clear the marking (via  
  HeapTupleHeaderClearDatum()).  
  
- heap_modify_tuple() used to copy t_ctid, which is not possible  
  anymore, due to that containing the datum version. No callers could be  
  found that need the copy.  
  
At least some of the above should be mentioned in the release notes.  
  
Investigation via github codesearch, a dump of all the extensions on  
pgxn, extensions from various distributions, etc, suggests the following  
effects on extensions:  
  
- PostGIS does some quite broken things on the upgrade from < 3.6 to  
  3.6, including corrupting the catalog. This is more noticeable with  
  these changes. In particular WARNINGs will be emitted and pg_upgrade  
  will fail, until PostGIS is fixed.  
  
  See https://trac.osgeo.org/postgis/ticket/6142  
  
- PL/R (trigger arguments), pg_variables (stored records) and pljs copy  
  tuples and set the composite datum header fields by hand, which leads  
  to spurious errors when the result is read.  They should use  
  heap_copy_tuple_as_datum() instead.  
  
- ddlx fails for columns with an explicitly set attribute option, as it  
  expects at most one option per column.  pgcontext refuses to convert  
  versioned columns, as it rejects columns with any attribute options.  
  
- firebird_fdw spuriously errors out in some cases, due to overwriting  
  the xmax (but not xmin). Other FDWs clear out xmin, which this commit  
  uses as a signal that the version information is not usable, but  
  there's no easy way to detect this in the firebird_fdw case. The fix  
  would be a one-liner.  
  
- storage_engine's rowcompress table AM stores composite datum-style  
  tuples, which will raise errors on read if the table schema is  
  subsequently changed. The fix is trivial.  
  
- pgrx-based extensions will not be protected, even after recompiling,  
  due to pgrx copying postgres code like heap_getattr(). pgrx will need  
  to update that copied code.  
  
- pg_strom's arrow FDW bypasses core functionality for more than 100  
  columns and inserts attributes itself. That does not set the attribute  
  versions correctly and thus will trigger spurious errors if composites  
  of that FDW are used.  
  
- timescaledb has a bug causing crashes during chunk creation as part of  
  DDL commands if attribute options are present. With this change every  
  new / altered attribute has an attribute option.  
  
  A later commit will work around these crashes.  
  
- Citus' distributed aggregation path theoretically can hit the new  
  error in TupleDescCopy(). However, it looks like Citus' planner does  
  not ever generate such plans - but the ERROR can be reached by a user  
  issuing a query with calls to the relevant internal Citus functions.  
  
  The fix again is trivial, should it be needed (use  
  CreateTupleDescCopy() instead of open-coding it).  
  
The new composite_type_mismatch developer option allows superusers to  
turn the version mismatch error into a warning, or to disable the check.  
Both settings are unsafe.  
  
With this infrastructure in place, additional checks can be  
performed (e.g. in heap_datum_check(), heap_datum_update_type()), at the  
cost of some complexity and runtime overhead.  A subsequent commit adds  
those.  
  
Reported-by: Heikki Linnakangas <heikki.linnakangas@iki.fi>  
Reported-by: Andres Freund <andres@anarazel.de>  
Reported-by: Andrew Gierth <andrew@tao11.riddles.org.uk>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Reported-by: Francesco Verardi <frevadiscor89@gmail.com>  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Reported-by: Tomer Fichman <tomer@irregular.com>  
Reported-by: OpenAI Security Research Team  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Mehmet Ince @mdisec <mehmet@mehmetince.net>  
Reported-by: Bryan Green <dbryan.green@gmail.com>  
Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com>  
Reported-by: Nicholas Carlini <npc@anthropic.com>  
Reported-by: Sergey Shinderuk <s.shinderuk@postgrespro.ru>  
Reported-by: Yuxiao Guo <dllggyx@outlook.com>  
Reported-by: Nikhil Sontakke <nikhil@planetscale.com>  
Reported-by: Stephan Lipp <Stephan@Adalogics.com>  
Reported-by: Daniel Bakker <daniel@jackds.nl>  
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com> (parts)  
Security: CVE-2026-6460  
Backpatch-through: 14  

M contrib/amcheck/verify_heapam.c
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/config.sgml
M src/backend/access/common/heaptuple.c
M src/backend/access/common/indextuple.c
M src/backend/access/common/reloptions.c
M src/backend/access/common/tupdesc.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heaptoast.c
M src/backend/access/heap/hio.c
M src/backend/access/heap/rewriteheap.c
A src/backend/catalog/README.attver.md
M src/backend/catalog/catalog.c
M src/backend/catalog/heap.c
M src/backend/commands/sequence.c
M src/backend/commands/tablecmds.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execSRF.c
M src/backend/executor/execTuples.c
M src/backend/executor/spi.c
M src/backend/utils/adt/expandedrecord.c
M src/backend/utils/adt/jsonfuncs.c
M src/backend/utils/adt/pg_upgrade_support.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/cache/typcache.c
M src/backend/utils/errcodes.txt
M src/backend/utils/misc/guc.c
M src/backend/utils/sort/tuplesort.c
M src/bin/pg_amcheck/t/004_verify_heapam.pl
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/include/access/htup_details.h
M src/include/access/reloptions.h
M src/include/access/tupdesc.h
M src/include/catalog/binary_upgrade.h
M src/include/catalog/catalog.h
M src/include/catalog/heap.h
M src/include/catalog/pg_attribute.h
M src/include/catalog/pg_class.h
M src/include/catalog/pg_proc.dat
M src/include/fmgr.h
M src/include/storage/itemptr.h
M src/include/utils/expandedrecord.h
M src/pl/plpgsql/src/expected/plpgsql_record.out
M src/pl/plpgsql/src/pl_exec.c
M src/test/isolation/expected/rowtypes-alter.out
M src/test/modules/spgist_name_ops/expected/spgist_name_ops.out
M src/test/regress/expected/rowtypes_alter.out
M src/tools/pgindent/typedefs.list

Always acquire expanded record descriptors early

commit   : 7209daf6166e44ed97f56a3c8d9b84c90831facf    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Only make_expanded_record_from_datum() deferred tuple descriptor lookup,  
and it has no direct/indirect users in core nor in known open source  
extensions (checked via pgxn and github).  The other ERH constructors  
already acquire a descriptor eagerly.  
  
The main reason for this change is that subsequent commits are  
simplified by it.  
  
This also allows implementing the datum constructor using  
make_expanded_record_from_typeid(), removing a good bit of duplicated  
code.  
  
This preserves ABI compatibility, to allow for backpatching.  
  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/utils/adt/expandedrecord.c
M src/include/utils/expandedrecord.h
M src/test/regress/expected/rowtypes_alter.out

plpgsql: Check compatibility of source/target ERHs

commit   : 97e0a9c4e6924e916f2036da07207af39b98b53d    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Otherwise we can assign tuples not matching the target tupledescriptor,  
e.g. because one of the tuple descriptors has been acquired before/after  
some DDL.  
  
It may seem tempting to just not enter the surrounding "if" if the  
er_tupdesc_id doesn't match (in fact both Heikki and I (Andres) were  
previously tempted), but the fieldwise-assignment path differs  
behaviorally, due to not copying the ctid along. As the tupdesc_id can  
increment due to invalidation processing, that would lead to  
unpredictable behavior.  Tests were added in previous commits that would  
show that behavior.  
  
Note that there are some cases where this will cause failures that are  
not required for correctness, when assigning a variable of a changed  
type to a previously used variable. It'd add more complexity to make  
that work; for a bugfix this seems good enough.  
  
As also noted in a comment, this perhaps should be done in the expanded  
record layer. But that'd require a few more changes and would make it  
harder to emit a somewhat understandable error message.  
  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/pl/plpgsql/src/expected/plpgsql_record.out
M src/pl/plpgsql/src/pl_exec.c
M src/test/regress/expected/rowtypes_alter.out

Add tests for row type changes causing issues

commit   : e7f11a2953ef644f79186e8d99c4b30ce6d79c17    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Most of these show the problem by displaying 'FIXME' in test output in  
case of problems, for more details about that aspect see  
rowtypes_alter.sql.  
  
A large percentage of these tests were converted from a larger set of  
tests that were not mergeable in their former shape.  
  
Author: Andres Freund <andres@anarazel.de>  
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> (in different form)  
Security: CVE-2026-6460  
Backpatch-through: 14  

A src/test/isolation/expected/eval-plan-qual-rowtype-alter.out
A src/test/isolation/expected/rowtypes-alter.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/eval-plan-qual-rowtype-alter.spec
A src/test/isolation/specs/rowtypes-alter.spec
A src/test/regress/expected/rowtypes_alter.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/rowtypes_alter.sql

commit   : e8f50a4126b86ba41b3f7334a4f7720ebb21d4cb    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

An upcoming fix touches related code. It turns out there were a number  
of cases there were not or only incidentally tested. In particular, we  
didn't leave tables with combinations of dropped columns to be tested by  
002_pg_upgrade.pl  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Add some very basic tests for make_expanded_record_from_datum()

commit   : 510561c3fb4446b023cce8954e18a68cbee42cf9    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

make_expanded_record_from_datum() / DatumGetExpandedRecord() /  
PG_GETARG_EXPANDED_RECORD() were unused. I could not find any extensions  
using it either.  
  
It seemed too likely that one of the subsequent fixes in this series  
would break them, therefore this adds some tests (written with AI help).  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/test/regress/expected/rowtypes.out
M src/test/regress/input/create_function_0.source
M src/test/regress/output/create_function_0.source
M src/test/regress/regress.c
M src/test/regress/sql/rowtypes.sql

Add test for NOT NULL differing across partition hierarchy

commit   : 8e5da6768ab0efbabbf09dfa82f2c6a5dc861cdf    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Test a trigger on a partition table where a columns NOT NULLness differs  
between parent and child.  
  
Development versions of an upcoming fix broke those cases without  
breaking any extant tests.  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Expand EPQ test coverage

commit   : f7dcd99b9c4b22d886d265f538935a43909bb4cc    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

Test EPQ handling in presence of dropped columns and resjunk elements in  
the targetlist. Development versions of an upcoming fix broke those  
cases without breaking any extant tests.  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

A src/test/isolation/expected/eval-plan-qual-dropped-column.out
A src/test/isolation/expected/eval-plan-qual-resjunk.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/eval-plan-qual-dropped-column.spec
A src/test/isolation/specs/eval-plan-qual-resjunk.spec

plpgsql: Expand test coverage of assignments

commit   : bdef8fa63cf71b9aff899672960d5ca8ef3e4cda    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

We previously were lacking coverage for important assignment related  
codepaths that will be touched in an upcoming fix:  
  
- Assignment between record variables preserve ctid/tableoid only when  
  the source tuple can be copied verbatim; where a conversion is needed  
  they are silently dropped.  
  
- A record variable's declared type is re-resolved by name  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/pl/plpgsql/src/expected/plpgsql_record.out
M src/pl/plpgsql/src/sql/plpgsql_record.sql

Harden some allocations against integer wraparound

commit   : 376324afd66c5d9bec7e9c360e98ba65695ea4cc    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:02 -0800    

Click here for diff

This isn't closing any specific security bug, but attacks are perhaps  
conceivable due to various forms of type confusion or data corruption.  
Tighten that up a bit.  More is undoubtely possible.  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Security: CVE-2026-120139  
Backpatch-through: 14  

M src/backend/access/common/detoast.c
M src/backend/access/common/toast_compression.c
M src/backend/utils/adt/array_userfuncs.c
M src/include/access/tableam.h
M src/include/postgres.h

Fix type confusion with materialized set-returning functions

commit   : 9bb8b360f47ffc374a23787d1c96258fa4ab4830    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Set-returning functions in the target list with indeterminate RECORD  
return types incorrectly used the same tuple descriptor to read and  
return tuples from the tuplestore across invocations.  
  
These types of SRFs resolve their rowtype from the passed in record  
argument and it can differ from invocation to invocation. Reading tuples  
with the wrong shape of tuple descriptor can lead to incorrect results,  
crashes, and security issues. It was reported as a way to read arbitrary  
out-of-line values via json_populate_recordset().  
  
To fix this, drop and recreate the slot and its tuple descriptor per SRF  
invocation for materialized SRFs in the target list with dynamic RECORD  
return types.  
  
Only the target-list path is affected: table functions in FROM validate  
every result against the query-supplied descriptor, and value-per-call  
SRFs never retain a slot.  
  
Co-authored-by: Melanie Plageman <melanieplageman@gmail.com>  
Co-authored-by: Robert Haas <rhaas@postgresql.org>  
Security: CVE-2026-120141  
Backpatch-through: 14  

M src/backend/executor/execSRF.c
M src/test/regress/expected/json.out
M src/test/regress/sql/json.sql

Align REASSIGN OWNED caller-privilege checks with ALTER ... OWNER TO.

commit   : b83eab069fcad3dea3e7529660319007993e7135    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Commit 3d14e171e9e2236139e8976f3309a588bcc8683b (v16) made giving an  
object to another role depend on the ability to SET ROLE to that role.  
However, a role granted "INHERIT TRUE, SET FALSE" could bypass that, via  
REASSIGN OWNED.  A role granted "INHERIT FALSE, SET TRUE" saw the  
inverse problem: REASSIGN OWNED failed spuriously, while ALTER ... OWNER  
succeeded.  
  
For avoidance of doubt, fixing this doesn't change the limitations of  
SET FALSE.  If a role owns nothing, SET FALSE grantees can't make that  
role own its first object.  For many kinds of objects, once a role owns  
one, "INHERIT TRUE, SET FALSE" prevents nothing compared to "INHERIT  
TRUE, SET TRUE".  
  
REASSIGN OWNED also bypassed the CREATEDB privilege check in ALTER  
DATABASE ... OWNER TO.  Fix by duplicating the check.  This affects all  
supported versions.  This sort of omission remains easy to miss under  
the present design, so refactoring would be prudent.  
  
Document the way REASSIGN OWNED still differs from ALTER ... OWNER TO:  
the new owner's CREATE privilege on the schema of a relation or type is  
not checked.  
  
Back-patch to v14 (all supported versions).  In v15 and v14, REASSIGN  
OWNED's privs checks is stricter than the membership checks in ALTER  
... OWNER TO.  Leave that alone, rather than aligning the commands.  Do  
fix the CREATEDB omission.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Backpatch-through: 14  
Security: CVE-2026-120146  

M doc/src/sgml/ref/reassign_owned.sgml
M src/backend/catalog/pg_shdepend.c
M src/backend/commands/dbcommands.c
M src/backend/commands/user.c
M src/include/commands/dbcommands.h
M src/test/regress/expected/database.out
M src/test/regress/sql/database.sql

Close portals at end of trigger functions with transition tables.

commit   : 84a4e2c18f20e1562dca42c00802b85bb1d57eb9    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

The query environment needed for portals over transition tables for  
triggers lasts only as long as the SPI connection, so the portals must  
be closed.  If not closed within the function, SPI_finish()  
force-closes them.  
  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-120143  

M doc/src/sgml/spi.sgml
M src/backend/executor/spi.c
M src/backend/utils/mmgr/portalmem.c
M src/include/utils/portal.h

Enforce view row visibility for INSERT ... ON CONFLICT target rows.

commit   : 4167810cfe62d5ed4cf70a576a2eed87e2f246a8    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

The WHERE condition of an automatically updatable view restricts the  
rows that an UPDATE, DELETE, or MERGE through the view can affect to  
those that are visible through it.  INSERT ... ON CONFLICT DO UPDATE  
through such a view did not follow this rule.  The conflicting row is  
found through the arbiter index rather than by scanning the view, and  
the view's WHERE condition was never applied to it.  DO UPDATE therefore  
updated the row whether or not the view showed it, and evaluated its SET  
expressions, its WHERE clause, and RETURNING against it; ON CONFLICT DO  
SELECT read it the same way.  This odd set of behaviors was documented,  
but it created a security issue, described further down.  
  
Fix by having rewriteTargetView() emit the view's WHERE quals as a  
WithCheckOption of new kind WCO_VIEW_CONFLICT_CHECK, which  
ExecOnConflictUpdate() and ExecOnConflictSelect() check against the  
conflicting row, innermost view first and before the ON CONFLICT WHERE  
clause is evaluated.  Using a new WCO kind for this is perhaps a little  
unorthodox, but doing so provides exactly what is needed here: it raises  
an error when a conflicting row doesn't satisfy the view's quals.  This  
makes sense because ON CONFLICT DO UPDATE guarantees that each row  
proposed for insertion is either inserted or updated, neither of which  
is feasible here.  The arbiter index belongs to the base relation, so  
the conflicting row makes insertion the wrong thing to do.  The view's  
WHERE condition puts the conflicting row beyond the reach of an update  
through the view, but it doesn't make sense to act as if there's no row  
to update, because when that happens we're supposed to take the  
insertion path instead (that's what upsert promises).  This situation is  
fundamentally irreconcilable, so throwing an error is all we can do.  
  
This fixes a security bug.  A user whose privileges on a view allow an  
upsert through it, but who holds none on its base relation, can modify  
every row that the view hides, one at a time, by guessing their keys, as  
if the view had no WHERE condition.  The same user can read those rows,  
through the conflict action's WHERE clause, its SET expressions, and  
RETURNING.  This historical behavior is hard to defend in general, and  
impossible to defend in cases where the target view happens to be a  
security barrier view.  
  
The problem dates to commit 168d5805e, which added ON CONFLICT and  
documented its original behavior with updatable views.  ON CONFLICT DO  
SELECT was added to Postgres 19 by commit 88327092f, and it inherited  
that behavior.  
  
An upsert through a view that relied on reaching rows the view hides now  
fails.  This should be called out as an incompatibility in the release  
notes for the next set of minor releases.  
  
Reported-by: Qing Xu <emyiqing@gmail.com>  
Reported-by: Carl Andersen <carl@spearbit.com>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reported-by: shihao zhong <zhong950419@gmail.com>  
Author: Peter Geoghegan <pg@bowt.ie>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Security: CVE-2026-16237  
Backpatch-through: 14  

M doc/src/sgml/ref/create_view.sgml
M src/backend/executor/execMain.c
M src/backend/executor/nodeModifyTable.c
M src/backend/rewrite/rewriteHandler.c
M src/include/nodes/parsenodes.h
M src/test/regress/expected/rowsecurity.out
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/rowsecurity.sql
M src/test/regress/sql/updatable_views.sql

Protect against miscalculation of tuple sizes via int32 overflow

commit   : 9fe1c78135f44c3c16c18d4aee305ec83fbc0c56    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

In-memory tuple sizes were being calculated in 64-bit-sized variables  
and later assigned to 32-bit variables, potentially leading to integer  
wraparound, which could then be used to overwrite server memory with  
attacker-controlled contents.  Repair by using overflow-aware addition  
and, for additions done in loops, checking that the result complies with  
the 1GB palloc limit at each step.  
  
Reported-by: Hillai Ben Sasson <hillai.bensasson@wiz.io>  
Reported-by: Jayden Sarveshkumar <jayden@verialabs.com>  
Reported-by: Mehmet Ince <mehmet@mehmetince.net>  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>  
Security: CVE-2026-120139  
Backpatch-through: 14  

M src/backend/access/common/heaptuple.c
M src/backend/access/heap/heaptoast.c
M src/backend/executor/execTuples.c
M src/backend/utils/adt/multirangetypes.c
M src/include/access/htup_details.h
M src/include/access/tupmacs.h
M src/include/c.h

Reject pseudo-type output parameters in SQL functions.

commit   : ded6c00d3e26fff99fe747911bda2a0d4f28d163    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

fmgr_sql_validator() rejected unsafe pseudo-type input parameters, but  
neglected to apply the same rule to output parameters.  An SQL function  
could therefore declare an output column of type "any".  This created  
problems for tupledesc_match(), which checks an SQL function's result  
rows against its declared output columns using IsBinaryCoercible().  
IsBinaryCoercible accepts every type for "any", so rows of an arbitrary  
row type could be read using a tuple descriptor that does not match  
their physical layout.  This could be abused to disclose server memory  
contents, and to perform arbitrary code execution.  
  
To fix, teach fmgr_sql_validator() to apply its pseudo-type check to  
parameters of every mode (not just for input parameters).  
  
Note that the treatment of record is somewhat arbitrary: record and  
record[] remain allowed as output column types, while record remains  
disallowed as an input parameter type.  Allowing record in either  
position is likely safe, but a back-patched security fix is not the  
place to change existing behavior either way.  
  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Stephan Lipp <Stephan@Adalogics.com>  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Security: CVE-2026-18447  
Backpatch-through: 14  

M src/backend/catalog/pg_proc.c
M src/test/regress/expected/create_function_3.out
M src/test/regress/sql/create_function_3.sql

plpgsql: recheck record field's type after casting value.

commit   : c4a0b7919b3b81abb59f365d6a4dcff1feaa4c52    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

exec_cast_value() can reach code that will change the rowtype of a  
RECORD variable, but the RECFIELD case in exec_assign_value() doesn't  
account for that and assumes the record field type and column number  
that it previously looked up are still good.  Recheck that data  
if the tuple type ID changed; since that condition never holds in  
normal usage, this is a cheap enough safety check.  
  
Reported-by: Claude and Ada Logics  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-120151  

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

Avoid using a dangling pointer in expanded-record domain checks.

commit   : f4ca5327ad2a51bdfba50e72892867f0c1dd86f7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

build_dummy_expanded_header() sets up the expanded record's dummy  
child to have eoh_context equal to the parent's er_short_term_cxt.  
If some operation on the dummy record causes creation of a short-term  
context belonging to the dummy record itself, that will be a child  
of the parent's er_short_term_cxt, which means it will get deleted  
when we reset the parent's er_short_term_cxt at the end of the callers  
of build_dummy_expanded_header().  So the next time through, we'll try  
to use a dangling context pointer, which often will now be pointing  
at some other unrelated context.  That at least risks a crash, and  
it's reported to be exploitable for arbitrary code execution.  
To fix, just clear the potentially-dangling pointer in the next  
usage cycle.  
  
Reported-by: Claude and Ada Logics  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-120150  

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

Validate all connection options before using libpqsrv_connect*

commit   : 8bead7abd0d19a5a836ec181e22b4540d571cac4    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Connection options passed to dblink(), dblink_connect[_u](), and  
dblink_exec() didn't flow through the same validation path as options  
which were set via foreign server definitions. Additionally, connection  
options added to subscriptions didn't go through any validation except  
for the password check. This allowed the sslkeylogfile parameter and  
all oauth_* parameters, both introduced in PG18, to be set by relatively  
unprivileged users.  
  
Add libpqsrv sanitization functions which block unsafe and unknown  
connection options. These are called before libpqsrv_connect() and its  
variants. (Extensions which use those functions are encouraged to do the  
same.) walrcv_connect() makes an exception to this rule for  
primary_conninfo, which is still allowed to contain any parameters.  
  
To reduce the size of the patchset, the implementation has the following  
drawbacks, which we hope to improve after release:  
  
- The superuser is also restricted.  
- The sanitization functions are not invoked when administering foreign  
  server options, or when modifying subscriptions without connecting, to  
  avoid interfering with pg_upgrade and dump/restore. The restrictions  
  will be applied later, at connection time, which may be a surprise.  
  
Backpatch all the way down. Though the new options aren't present in  
older libpqs, running an older server with a newer libpq is common. The  
tests for the newer options unfortunately cannot be easily backpatched  
past PG18.  
  
Reported-by: Andrey Krasichkov <buglloc@yandex-team.ru>  
Reported-by: b.altawil <b.altawil@proton.me>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Suggested-by: Noah Misch <noah@leadboat.com> (sslkeylogfile part)  
Reviewed-by: Noah Misch <noah@leadboat.com> (sslkeylogfile part)  
Reviewed-by: Andres Freund <andres@anarazel.de> (PG14/15 backpatch)  
Backpatch-through: 14  
Security: CVE-2026-14661  

M contrib/dblink/dblink.c
M contrib/postgres_fdw/connection.c
M src/backend/libpq/Makefile
A src/backend/libpq/be-fe-helpers.c
M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/include/access/xlog.h
M src/include/libpq/libpq-be-fe-helpers.h
M src/include/miscadmin.h

Check ON CONFLICT target row against RLS policies before user quals.

commit   : 661a0951bdc219913524ed9015514518e67d0e30    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

ExecOnConflictUpdate() and ExecOnConflictSelect() evaluated the  
user-supplied ON CONFLICT WHERE clause before checking the pre-existing  
conflicting row against the RLS policy USING quals collected as  
WCO_RLS_CONFLICT_CHECK.  A user could therefore have that clause read a  
row that no policy allowed them to see.  
  
Fix by performing the check immediately after the conflicting row is  
locked and found visible, before the WHERE clause is evaluated.  A row  
that fails the check now raises an error whatever the WHERE clause would  
have returned, so the two outcomes are no longer distinguishable.  
  
This moves the USING quals of the UPDATE policies ahead of the WHERE  
clause as well, not just those of the SELECT policies.  Only the latter  
is a security issue, since a row that nothing but an UPDATE policy hides  
can be read with a plain SELECT anyway.  No order is consistent with  
every other command: a plain UPDATE evaluates both kinds of USING qual  
ahead of the user's quals, whereas MERGE evaluates a WHEN MATCHED ... AND  
condition ahead of the UPDATE policies' USING quals, since it cannot  
know whether it is going to update until then.  ON CONFLICT DO UPDATE  
now behaves like UPDATE.  
  
This dates to 168d5805e, which added WCO_RLS_CONFLICT_CHECK along with  
ON CONFLICT itself.  ON CONFLICT DO SELECT was added in 19 by 88327092f,  
so the back branches only need the ExecOnConflictUpdate() part of the  
fix.  
  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reported-by: Only see myself <1950233439@qq.com>  
Reported-by: Nicholas Carlini <npc@anthropic.com>  
Reported-by: Joao Detomini <joao.detomini@enterprisedb.com>  
Reported-by: Josef Šimánek <josef.simanek@gmail.com>  
Reported-by: Qing Xu <emyiqing@gmail.com>  
Author: Peter Geoghegan <pg@bowt.ie>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Security: CVE-2026-120154  
Backpatch-through: 14  

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

Fix race condition adding a DEFAULT expression to a function

commit   : f5782736cd26091ccb125f0d1a830c20e84e1c51    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Because check_composite_type_dependency() didn't hold a lock while  
inspecting the pg_proc entry, it was possible that the dependency was  
deemed harmless, but concurrently, another backend added a DEFAULT  
expression to the function that should've been rejected.  To fix, hold  
an AccessShareLock on the pg_proc object while we inspect it, and on  
the other side of the story, hold an AccessExclusiveLock on the  
pg_proc object when modifying it.  
  
Note that we don't lock functions or other objects except relations  
when using them in queries, so the AccessExclusiveLock doesn't prevent  
concurrent queries using the function.  
  
This also adds locking to other objects (constraints, types) inspected  
in check_composite_type_dependency(), although that is just pro forma,  
because there is no DDL to replace the expression of an existing CHECK  
constraint, and altering a rowtype already holds a lock that conflicts  
with an ALTER DOMAIN SET DEFAULT expression on a domain over the same  
rowtype.  
  
Relations don't have this problem, because there is no DDL command to  
alter an existing table's PARTITION BY expression, nor an existing  
index's expressions or quals.  The OF type can be altered, but AFAICS  
we have sufficient locking in place for that.  
  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/catalog/pg_proc.c
M src/backend/commands/tablecmds.c
M src/test/isolation/expected/type-ddl-locking.out
M src/test/isolation/specs/type-ddl-locking.spec

Lock affected rowtype and dependent types on ALTER ATTRIBUTE

commit   : 17a225d95a3e6e31ed561b7b895fb81a43619187    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

On ALTER TYPE ... ALTER ATTRIBUTE, acquire AccessExclusiveLock on the  
rowtype, and all dependent types (arrays, domains, etc. over the  
target type).  This ensures that a concurrent backend doesn't add a  
dependency to the type that we would miss in our dependency checks.  
We were already holding the lock on the corresponding relation, and  
that conflicted with many operations, but not all operations that use  
a type also lock its relation.  
  
Note that we don't lock types (or other objects except relations) when  
using them in queries, so the AccessExclusiveLock doesn't prevent  
concurrent queries from using the type.  
  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/commands/tablecmds.c
M src/test/isolation/expected/type-ddl-locking.out
M src/test/isolation/specs/type-ddl-locking.spec

Prevent ALTERing a row type that's concurrently used in a column

commit   : ea00db41ce6b690d5ca8c220094b4a77fb4864b4    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

ALTER TABLE/TYPE checks if the type is being used in a column and  
forbids it, because that would require rewriting the data in the  
affected table.  But the check missed cases where the type was  
concurrently used in a CREATE TABLE or ALTER TABLE ADD COLUMN that  
hasn't committed yet.  
  
Commit 2fbb21170e fixed a similar race condition for dropping the  
column type altogether, but it wasn't sufficient to fix the problem  
with altering the type, because altering a composite type doesn't  
currently lock the type.  It does lock the *relation* corresponding to  
the type (i.e. pg_type.typrelid), but CREATE TABLE did not hold onto  
that lock, even though it acquires it momentarily.  To fix, don't  
release the lock.  
  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/catalog/heap.c
A src/test/isolation/expected/type-ddl-locking.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/type-ddl-locking.spec

Start to record type dependencies on index expressions et al

commit   : f32e9d5b49cd7baffc0b8be1dc924110d034411f    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

With this, we can remove find_missing_composite_type_dependencies() in  
'master', but I'll do that in a separate commit.  This doesn't help  
with existing missing dependencies, so we need to keep  
find_missing_composite_type_dependencies() in backbranches.  It's  
still better to record them going forward, though, even in  
backbranches.  
  
For all reporters and public discussions, see previous commits.  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/catalog/dependency.c
M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_column_type.out
M src/test/regress/expected/privileges.out

Check for missing dependencies on types

commit   : 1762f2e7cdbfa9ea9bd51e16678f9ee0e331620d    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

If an expression that's stored in a catalog references a rowtype in a  
way that would break ALTERing its attribute, we record a dependency on  
the type, and find_composite_type_dependencies() prevents ALTERing it.  
However, we have failed to record the dependency in some cases, namely  
if the expression itself doesn't depend on the type in an incompatible  
way, but produces a *result* of the given datatype which is stored.  
That problem arises from index expressions, PARTITION BY expressions,  
and from expression statistics.  
  
To fix, scan the pg_index, pg_partitioned_table and pg_statistic_ext  
catalogs for those cases as a separate sub-step of  
find_composite_type_dependencies().  In the future, after we have  
added the missing dependency creation and backfilled any existing  
missing dependencies, we can remove this code.  That means, in a new  
major version.  
  
For all reporters and public discussions, see previous commits.  
  
Co-authored-by: Nathan Bossart <nathan@postgresql.org>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Forbid changing type if the rowtype is used in a foreign table

commit   : f3cef207b9d1293a964610108964eb99c322ba68    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Because the foreign table's statistics could have datums in the old  
format.  
  
For all reporters and public discussions, see previous commits.  
  
Co-authored-by: Nikhil Sontakke <nikhil@planetscale.com>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/commands/tablecmds.c

Check relation dependencies more carefully

commit   : 8513bfaa286b0b168d24171ca2cd1a5121439791    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Similar to previous commits, if a relation depends on a composite  
type, we need to inspect it more carefully.  We already checked tables  
using the composite type in columns, but the dependency might also  
exist because a partitioned table's PARTITION BY expression uses the  
type, or an expression in an expression or partial index.  
  
For all reporters and public discussions, see previous commits.  
  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Check for Consts in domain DEFAULTs

commit   : 6b093b4610b23f4e9b6cc70f1c2f231f3c5a63d5    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Similar to previous commits, also look more closely at a type  
depending on a composite type.  If it's a domain, its DEFAULT  
expression might contain a Const that would need to be rewritten if  
the composite type was ALTERed.  
  
For all reporters and public discussions, see previous commits.  
  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Check for Consts in constraint definitions

commit   : b1ff3ce04676707c8513d1237988b03c597747b3    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Similar to previous commit, we also need to look more closely at a  
dependency from a constraint to a composite type.  The constraint's  
DEFAULT might contain a Const or other expression that would need to  
be rewritten, if the composite type was ALTERed.  
  
For all reporters and public discussions, see previous commits.  
  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Check for Consts in function DEFAULTs and body

commit   : 0a10508be03d6527aaa094155b5e9df7e56d0786    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

A function that uses a composite type as its return or argument type  
doesn't prevent altering the composite type.  However, if it's used in  
an argument DEFAULT expression, or in the new-style SQL function body,  
we must not allow it, because e.g. any Consts in those expressions  
would become invalid and we don't have the machinery to rewrite them.  
If there's a pg_depend entry on a function, look more closely where  
the dependency comes from, and throw an error if it's from those  
expressions.  
  
For all reporters and public discussion, see previous commit.  
  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/catalog/dependency.c
M src/backend/commands/tablecmds.c
M src/include/catalog/dependency.h
M src/test/regress/expected/alter_column_type.out
M src/test/regress/sql/alter_column_type.sql

Forbid ALTERing column type by default when other objects depend on it

commit   : 9d0efd64bff02bbf8d12959045e6cd1d55108fbf    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Previously, we'd allow changing the column type of a table or  
composite type (ALTER COLUMN / ATTRIBUTE ... TYPE ...) even if there  
are objects depending on the row type.  We only made some checks on  
dependencies from relation objects, and assumed that dependencies from  
other kinds of object were OK.  This commit flips the logic around to  
forbid if there are any dependencies, except for relations and a few  
other cases that are known to be OK.  
  
This commit is mostly refactoring, but some cases that were previously  
broken, like expressions in views, are now forbidden.  Some of the  
dependencies that we continue to allow are known to be broken too --  
subsequent commits will tighten them up.  
  
The attributions and discussion links are for the whole wider issue  
covered by all the related commits, not just the variants fixed by  
this one commit.  
  
Reported-by: Andrew Gierth <andrew@tao11.riddles.org.uk>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Reported-by: Francesco Verardi <frevadiscor89@gmail.com>  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Reported-by: Tomer Fichman <tomer@irregular.com>  
Reported-by: OpenAI Security Research Team  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Mehmet Ince @mdisec <mehmet@mehmetince.net>  
Reported-by: Bryan Green <dbryan.green@gmail.com>  
Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com>  
Reported-by: Nicholas Carlini <npc@anthropic.com>  
Reported-by: Sergey Shinderuk <s.shinderuk@postgrespro.ru>  
Reported-by: Yuxiao Guo <dllggyx@outlook.com>  
Reported-by: Nikhil Sontakke <nikhil@planetscale.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Reviewed-by: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://www.postgresql.org/message-id/CA%2BUBoq0F2ua2fQEAU3-6w0oxOgFc9BgEN4gRcchiUUZ%2BWouVrQ%40mail.gmail.com  
Discussion: https://www.postgresql.org/message-id/CA%2BbCEdDvsVApd%2BAADX%3D5uyj6Q5C3r5aruWNzOFaYqaFqLwE_5g%40mail.gmail.com  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Avoid visiting a type twice in find_composite_type_dependencies()

commit   : e0765b6d5b87b805962944ed547b42f5073b953b    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

When recursing, keep track of visited types in a hash table.  This is  
currently just an insignificant performance optimization, but it will  
come handy in the upcoming patches where we can use the hash table to  
do expensive catalog scans only once.  The upcoming patches will be  
backpatched which is why this is backpatched too.  
  
Add a test for the case that a type ultimately depends on the same  
composite type via two different paths.  That's the case where the  
hash table lets us avoid some work.  It isn't very likely to be  
broken, but let's have coverage for it for the sake of completeness.  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

Split find_composite_type_dependencies() into smaller functions

commit   : 6c24b35e78c5e5507f7467e4bf997d8b0c9b8465    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

To make it a little easier to see what the upcoming commits change,  
move some of the logic from find_composite_type_dependencies() into  
subroutines.  This is pure refactoring, there is no change in  
user-visible behavior.  
  
Security: CVE-2026-6460  
Backpatch-through: 14  

M src/backend/commands/tablecmds.c

Add tests for find_composite_type_dependencies() bugs

commit   : 8587d949fcdf3b5503c15c68c458d3c8058e5176    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

There are a bunch of bugs in find_composite_type_dependencies(), which  
will be fixed by subsequent commits.  Usually we include tests in each  
commit that fixes a bug, but there are so many variants of these that  
it feels easier to add all the tests in one commit first, to show the  
big picture.  This commit memorizes the incorrect results in the  
expected output, marked with FIXME comments to point out that they are  
broken.  The next commits will fix the issues, adjust the expected  
output for the correct behavior, and remove the FIXMEs.  
  
Backpatch-through: 14  
Security: CVE-2026-6460  

A src/test/regress/expected/alter_column_type.out
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/privileges.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/alter_column_type.sql
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/privileges.sql

Allow SET LOGGED/UNLOGGED and changing AM when the rowtype is in use

commit   : 6be4e665dffdf344bc5acb41f89009eccc0d09e9    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:01 -0800    

Click here for diff

Those commands rewrite the table, but they don't affect other tables  
or Consts using the rowtype.  
  
The reason to do this now is that the next commits will tighten up the  
dependency checking to reject more cases.  After those commits, we  
would also unnecessarily reject SET LOGGED/UNLOGGED in more cases, so  
it seems nice to eliminate the unnecessary checks first.  That's also  
why this is backpatched.  
  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Security: CVE-2026-6460  
Backpatch-through: 14  

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

commit   : 887f6fee58f46c93bec66d0f449a579e314552ae    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Previously, a dblink query that returned rows kept using its  
connection after handing each row to the declared column type's input  
function. That input function can run user-defined code (e.g., a  
domain type with a CHECK constraint), so SQL can re-enter dblink while  
an outer call is still reading results, and close the connection that  
call is reading from. The close freed the connection object while the  
outer call held a pointer to it, so the next libpq call read and wrote  
freed memory.  
  
dblink never had a rule about reentrancy. Calls that issued a new  
query failed on their own, but by accident rather than by design:  
libpq rejects a new query while one is in progress. It doesn't reject  
reading a result, so a reentrant dblink_get_result() consumed a row  
out of the outer query's single-row stream.  
  
Fix this by marking a connection while a dblink call is materializing  
a result from it, and refusing every other dblink call on that  
connection until it's done.  
  
Backpatch to all supported branches.  
  
Reported-by: 안지용 <jfdg1y76@gmail.com>  
Reviewed-by: Jacob Champion <champion.p@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Backpatch-through: 14  
Security: CVE-2026-120147  

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

Reject system catalogs as logical replication targets.

commit   : d2ea7772e46b164817c8c5ede6816f35fc2ba8c1    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

The subscriber relied on the publisher refusing to add a system  
catalog to a publication, and checked only the relation kind it was  
about to apply into. However, the relation is named by the publisher,  
and a publisher that speaks the logical replication protocol doesn't  
have to be a PostgreSQL server. A malicious one can name a system  
catalog, and the apply worker will write into it.  
  
The danger is limited to subscriptions owned by a superuser. Changes  
are applied as the table owner, or as the subscription owner when  
run_as_owner is set, and a non-superuser can never hold write  
privileges on a system catalog, so a subscription owned by a  
non-superuser stops at the privilege check.  
  
We can't depend on the publisher for this, so check the target  
relation on the subscriber too. A relation that the server maintains  
for its own use, such as a system catalog, must never be written by an  
apply worker, and neither must a temporary relation. We don't reject  
unlogged relations the way the publisher does; replicating into one is  
fine. The check runs when a worker opens the target relation to apply  
changes, and also when getting the relation list, so that such a  
relation is never recorded in pg_subscription_rel in the first place.  
  
The test attaches a callback of its own to the injection point, which  
needs a form of injection_points_attach() that v18 and older don't  
have, so it is applied to v19 and later.  
  
Reported-by: qian zhang <ttwzlt@gmail.com>  
Author: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Backpatch-through: 14  
Security: CVE-2026-120145  

M src/backend/commands/subscriptioncmds.c
M src/backend/executor/execReplication.c
M src/backend/replication/logical/relation.c
M src/backend/replication/logical/worker.c
M src/include/executor/executor.h

Reject pseudo-types in extended statistics expressions.

commit   : f2b6da9a664ff9af8c2b4e1a095fa0a5963a5362    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Previously, CREATE STATISTICS accepted an expression of a pseudo-type.  
So the statistics were built on a value whose row type is identified  
only by a typmod assigned locally in the backend that ran ANALYZE.  
Therefore, other sessions could read the statistics as the wrong data  
type, which can crash the server or return wrong results.  
  
Reject such expressions at CREATE STATISTICS time, including a type  
that contains a pseudo-type, such as a composite type with an anyarray  
column. An expression whose collation can't be determined is now  
rejected too, but ANALYZE fails on such statistics anyway.  
  
Since a statistics expression has no column name, teach the column type  
check to report an error without one.  
  
A statistics object built this way on an older minor release can still  
exist on v18 and older, so in those branches also error out when such  
statistics are used by the planner, their contents are read, or ANALYZE  
builds them. Those objects should be dropped.  
  
Backpatch to 14, where statistics on expressions were introduced.  
  
Reported-by: Mehmet D. INCE <mehmet@mehmetince.net>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Backpatch-through: 14  
Security: CVE-2026-120148  

M src/backend/catalog/heap.c
M src/backend/commands/statscmds.c
M src/backend/statistics/extended_stats.c
M src/backend/statistics/mcv.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

Make \restrict keys protective in pg_dump --format=tar restore.sql.

commit   : 9d2cda9f3fc8f474334d5d741129ccf223e74ed3    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

pg_dump tar format contains an undocumented restore.sql archive member  
that the user can edit according to its embedded comments and then run  
with psql.  Commit 71ea0d6795438f95f4ee6e35867058c44b270d51 added  
\restrict and \unrestrict to fix CVE-2025-8714.  That restore.sql always  
used "(null)" as the restriction key, so the key did not provide its  
intended protection.  Also, there was an initial \unrestrict before any  
restrict, yielding a spurious error.  Given the lack of reports about  
that spurious error in over a year, restore.sql may see negligible use.  
  
This defers fixing restore.sql from "pg_dump --format=tar --inserts",  
because that relies on "\i" commands.  That case is not subject to  
attack, but it fails to restore table data.  We should eventually fix  
"pg_dump --format=tar --inserts" restore.sql or remove restore.sql.  
Given this combination with --inserts has been broken to that degree,  
again for over a year, the combination must see little use indeed.  
  
Back-patch to v14 (all supported versions).  
  
Reported-by: Pavel Kopylov <pkopylov@cloudlinux.com>  
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> (non-test)  
Reviewed-by: Jacob Champion <champion.p@gmail.com> (test)  
Reviewed-by: Andres Freund <andres@anarazel.de> (test)  
Bug: #19718  
Discussion: https://postgr.es/m/19718-7e945d0ff9b5a589@postgresql.org  
Backpatch-through: 14  
Security: CVE-2026-116330  

M doc/src/sgml/ref/pg_dump.sgml
M src/bin/pg_dump/Makefile
M src/bin/pg_dump/pg_dump.c
A src/bin/pg_dump/t/011_restore.pl

Reject more unsafe names in extension script substitutions.

commit   : f233bee1edb790737c6bf4ed073b98c1a821426c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Commit cd5f2a3570 rejected schema and owner names containing  
quotes, backslashes, and dollar signs, but names containing  
newlines, carriage returns, comment delimiters, or the substitution  
tokens themselves can still achieve SQL injection.  To fix, reject  
those names, too.  
  
Reported-by: Anthropic OSS program  
Reported-by: Sven Klemm <sven@tigerdata.com>  
Reported-by: Aaron Chen <chenyoulong20g@ict.ac.cn>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Greg Burd <greg@burd.me>  
Security: CVE-2026-120153  
Backpatch-through: 14  

M src/backend/commands/extension.c
M src/test/modules/test_extensions/expected/test_extensions.out
M src/test/modules/test_extensions/sql/test_extensions.sql

Avoid out-of-bounds accesses in FDW batch inserts.

commit   : 56c7f155fa531846a024e11ccb0d9c83fb985fe9    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Foreign data wrappers are expected to return the number of  
successfully inserted tuples via ExecForeignBatchInsert's numSlots  
parameter.  Both the executor and COPY FROM use that number as the  
length of the slot array.  If the FDW reports more rows than we  
sent, the backend proceeds to read past the end of the array.  
(postgres_fdw is acutely affected: if the remote table has an  
INSERT rule, the reported count may be higher.)  To fix, clamp the  
reported count to the number of rows that were sent.  
  
This is a stopgap.  Clamping keeps statements that happen to  
succeed today succeeding, at the cost of misreporting the number  
of rows.  A better solution will likely involve reworking the API,  
but that is left as a future exercise.  
  
Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com>  
Reported-by: Sven Klemm <sven@tigerdata.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Jacob Champion <champion.p@gmail.com>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Security: CVE-2026-120149  
Backpatch-through: 14  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M src/backend/executor/nodeModifyTable.c

Prevent creating types in pg_temp from restricted code.

commit   : 44ebef3b5ddda43bf7e706c8d071b9ee50c11737    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Commit 62aba76568 taught security-restricted operations to refuse  
temporary table creation, since the calling session might not  
expect untrusted objects to appear at the front of its search  
path, but the same hazard exists for types.  This oversight  
allowed code running within such an operation to create domains,  
enum types, and range types in the session's temporary schema,  
potentially leading to privilege escalations.  To fix, refuse to  
create these types in a temporary schema within a  
security-restricted operation, as we already do for tables.  
  
The checks live in the command paths rather than in TypeCreate(),  
which also creates the rowtypes of the transient relations that  
REFRESH MATERIALIZED VIEW CONCURRENTLY and rewrites of temporary  
tables legitimately place in pg_temp within a security-restricted  
operation.  Composite types are already covered by the existing  
check in DefineRelation(), and creating base or shell types  
requires superuser.  Other object kinds are left alone, since  
unqualified names never resolve to them in pg_temp.  
  
Reported-by: Anthropic OSS program  
Author: Anthropic OSS program  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Security: CVE-2026-116316  
Backpatch-through: 14  

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

pg_restore: Fix out-of-bounds accesses and path traversal.

commit   : 179c2c37e06eb3999f2b57bb8e00ef6d82bedc2c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

pg_restore trusts the contents of the archives it reads, so a  
maliciously crafted archive can cause out-of-bounds reads and  
writes, or make pg_restore read files outside the archive  
directory.  This commit fixes the following issues:  
  
* Dependency IDs read from the table of contents are used as array  
  subscripts without validation.  To fix, reject any that is not a  
  positive integer.  
  
* _getObjectDescription() and IssueACLPerBlob() can read past the  
  end of a string when an entry's DROP statement or large object  
  ACL has an unexpected form.  To fix, check for the expected  
  prefix before moving past it.  
  
* A crafted archive can cause the dump ID index to be built before  
  the table of contents has been read, in which case it is too  
  small for every later lookup.  To fix, have the tar format reject  
  archives whose table of contents is not the first member.  
  
* The directory format opens the files named in the archive  
  without inspecting them.  To fix, reject names that contain a  
  directory separator and anything that isn't a regular file.  
  
* A tar member length that does not fit in a pgoff_t can cause a  
  buffer overrun on 32-bit systems.  To fix, reject such lengths.  
  
* In the back-branches, buildTocEntryArrays() sizes the dump ID  
  index arrays with unchecked multiplication, which could overflow  
  size_t on 32-bit systems.  To fix, use pg_malloc0_array().  
  
A corrupt archive can still crash pg_restore in other ways, but  
hardening against that didn't seem appropriate for a security fix,  
and therefore it is left as a future exercise.  
  
Reported-by: Dilip Kumar <dilipbalaut@gmail.com>  
Reported-by: Yonghwa Lee <underdog@theori.io>  
Reported-by: OpenSec <security@opensec.in>  
Reported-by: Ben Dixon <uk.bendixon@gmail.com>  
Author: Dilip Kumar <dilipbalaut@gmail.com>  
Author: Yonghwa Lee <underdog@theori.io>  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Security: CVE-2026-116314  
Backpatch-through: 14  

M src/bin/pg_dump/compress_io.c
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_directory.c
M src/bin/pg_dump/pg_backup_tar.c

Check table ownership when DROP OWNED BY changes policies.

commit   : 368f52460f41b1574b75fcfd9a06c281eaecb1c8    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

DROP OWNED BY removes the given roles from any row-level security  
policies that apply to them, but it does not check that the current  
user owns the table.  This allows a role to remove itself from  
restrictive policies on tables it does not own.  To fix, leave such  
policies unchanged and issue a warning, as is already done for  
privileges that the current user cannot revoke.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reported-by: Anthropic OSS program  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Co-authored-by: Anthropic OSS program  
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Security: CVE-2026-116311  
Backpatch-through: 14  

M src/backend/catalog/pg_shdepend.c
M src/backend/commands/policy.c
M src/test/regress/expected/rowsecurity.out
M src/test/regress/sql/rowsecurity.sql

dict_int: Return NULL for zero-length tokens.

commit   : fd0864aa0d5073d0960a5862935dd5711814074c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

dintdict_lexize() does not check for zero-length tokens before  
inspecting its input, so it can read past the end of the token.  In  
some cases, the returned lexeme can even contain data from well  
beyond it.  To fix, return NULL for a zero-length token, as  
dict_ispell, dict_synonym, and dict_xsyn already do.  
  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Reported-by: Anthropic OSS program  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Co-authored-by: Anthropic OSS program  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>  
Security: CVE-2026-116308  
Backpatch-through: 14  

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

Check EXECUTE privilege on foreign key cast functions.

commit   : 98090a0ff08cdc928d393b77ae8186ec34510596    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

When a foreign key's referencing column must be cast to the type of  
the referenced column, the comparison that decides whether an  
UPDATE of the referencing table changed the key executes the cast  
function without first checking for EXECUTE privileges.  To fix,  
check privileges and invoke the function execution hook before  
calling the cast function.  Note that this check is made as the  
user issuing the UPDATE, since the comparison happens before any  
switch to the referenced table's owner.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Security: CVE-2026-116303  
Backpatch-through: 14  

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

Check EXECUTE privilege on type-to-json cast functions.

commit   : d275f6accdb80dd2afa0fc7eb8eaf1eb585120e9    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

When converting a value to json or jsonb, to_json() and its many  
friends execute the cast function without first checking for  
EXECUTE privileges.  To fix, check privileges and invoke the  
object access hook before calling the cast function.  This  
covers to_json(), to_jsonb(), row_to_json(), array_to_json(), the  
json[b]_build_*() and *_agg() functions, the SQL/JSON constructors  
(v16 and later), and COPY TO with FORMAT json (v19 and later).  
  
Reported-by: Filip Janus <fjanus@redhat.com>  
Reported-by: Anthropic OSS program  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Co-authored-by: Anthropic OSS program  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Security: CVE-2026-116303  
Backpatch-through: 14  

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

Fix use-after-free issues due to drop of portals being set up

commit   : 69b973c656bbe6742cd8177310f1ba4dae5d9501    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Between CreatePortal() and PortalStart(), a portal can run user-defined  
code due to planning and executor startup, like SQL functions.  A  
function attempting to close a portal would free it, without its creator  
knowing about it.  This could lead to use-after-free issues when trying  
to use portals that have already been closed.  
  
With this change, PortalDrop() now refuses to act on portals marked as  
PORTAL_NEW or PORTAL_DEFINED.  CLOSE ALL skips them, as it does for  
active portals.  Note that AtAbort_Portals() (for transaction aborts)  
and AtSubAbort_Portals() (for subtransaction aborts) now puts such  
portals in a failed state so as they can be cleaned up during error  
cleanup.  
  
Two sets of tests are added:  
- Portal manipulations during planning and executor startup.  
- Portals and Bind messages, relying on injection points to check  
various transaction cases with portals marked as either PORTAL_NEW or  
PORTAL_DEFINED, where the on-error cleanup of portals marked as failed  
matters.  
  
Reported-by: Tomas Vondra <tomas@vondra.me>  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116332  

M src/backend/utils/mmgr/portalmem.c
A src/test/regress/expected/portals_inflight.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/portals_inflight.sql

Reject extnamespace if it's temporary or it's '$user'::regnamespace.

commit   : b049106516df15009a0e6348385f8833e0a2bf58    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Historical behavior was bizarre.  'CREATE EXTENSION tcn SCHEMA "$user"'  
set extnamespace='$user'::regnamespace, but the extension's object  
landed in the schema named after the bootstrap superuser if such a  
schema existed, else in pg_temp.  Many extension scripts failed, since  
pg_temp is searched for only a subset of object types.  In other  
scenarios, a trusted-extension script located the wrong object and  
executed arbitrary SQL of a non-superuser's choice.  The prior commit's  
locking additions could not cover this.  Back-patch to v14 (all  
supported versions).  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Backpatch-through: 14  
Security: CVE-2026-6467  

M src/backend/catalog/namespace.c
M src/backend/commands/extension.c
M src/test/modules/test_extensions/expected/test_extensions.out
M src/test/modules/test_extensions/sql/test_extensions.sql

Block ALTER SCHEMA RENAME attack on CREATE EXTENSION etc., via locking.

commit   : 73c65779702a6fb836c3b01e9f396c1dc5936ecd    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Commands that run extension SQL scripts intentionally depart from a  
standard, "Remove from search_path any schemas that permit untrusted  
users to create objects."  While CVE-2020-14350 blocked most attacks,  
one remained via ALTER SCHEMA extschema RENAME.  A user with  
database-level CREATE privilege could execute arbitrary code as the  
bootstrap superuser.  Block that attack by having ALTER SCHEMA RENAME,  
CREATE EXTENSION, and ALTER EXTENSION UPDATE lock the schema.  This  
makes schema rename locking more like that for object types  
AlterObjectRename_internal() covers.  
  
Also, make extension-mutating commands take self-exclusive locks.  Make  
relevant commands take the same lock on each dependency extension.  This  
doesn't stop a known attack against a specific extension, but  
overlapping extension mutations are fragile and not useful.  
  
Back-patch to v14 (all supported versions).  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Backpatch-through: 14  
Security: CVE-2026-6467  

M contrib/ltree/.gitignore
M contrib/ltree/Makefile
A contrib/ltree/expected/schema-rename-attack.out
A contrib/ltree/specs/schema-rename-attack.spec
M src/backend/commands/extension.c
M src/backend/commands/schemacmds.c

Fix crash in REINDEX CONCURRENTLY due to DDLs run in index functions

commit   : 122d1f8be0b16a8c0c7959be37b94c75c1d924ee    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

ReindexRelationConcurrently() keeps track of the OIDs of the relations  
it processes across all its phases, relying on session locks to protect  
them.  A function called from an index predicate or expression could  
drop one of the indexes being processed by a REINDEX CONCURRENTLY,  
causing a crash during the swap phase due to a relation gone missing.  
  
The relations being reindexed, on which are taken the session locks, are  
now pinned during the build and validation phases so as no manipulation  
of their definition can happen in the session running a REINDEX  
CONCURRENTLY.  
  
Reported-by: Florent Saudel <fsaudel@protonmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Backpatch-through: 14  
Security: CVE-2026-116336  

M src/backend/commands/indexcmds.c
M src/test/regress/expected/create_index.out
M src/test/regress/sql/create_index.sql

Check that commutator/negator operators return the same data type.

commit   : 7282f7dfe14457396aaf0ff65e08e56672c249d9    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

The commutator or negator of an operator must surely return the same  
data type as the operator itself (always boolean for a negator, but  
for a commutator it could be any type).  CREATE/ALTER OPERATOR  
failed to enforce this, providing a route for evildoers to reach  
type-confusion problems.  
  
Another ancient oversight in this feature is that if the first CREATE  
OPERATOR names a commutator or negator, but no corresponding clause  
appears in the CREATE OPERATOR that fills in the shell operator, we  
failed to preserve the shell operator's back-link, resulting in  
inconsistent catalog state.  That has to be considered part of the  
security problem, since it prevents checking whether the two operators  
have matching result types.  However, fixing it means that an operator  
created without any COMMUTATOR or NEGATOR clause at all can acquire a  
commutator/negator, if it overwrites a shell operator that links to  
such a sibling object.  That creates a new security problem: an  
attacker could set up a trojan-horse operator that names a  
commutator/negator operator that doesn't exist yet, but that the  
attacker expects to be created later.  Then the attacker has the  
potential to inject his own code into uses of that victim operator.  
The object_ownercheck() test in OperatorCreate() doesn't prevent  
that if the second operator is created by a superuser.  To fix this,  
we change that test to insist on exact equality of creating user.  
(This tightening could potentially break innocent use-cases, except  
that it's hard to foresee innocent cases where the two operators  
wouldn't be created by the same role.  The logic does not prevent  
either operator from being reassigned to a new owner later.)  
  
In v16 and earlier, this fix incorporates portions of commit  
2b5154bea.  Before that, there were yet other scenarios for creating  
inconsistent commutator/negator links, potentially allowing type  
confusion.  I also adopted some of the cosmetic refactoring done in  
that commit, just to make pg_operator.c look less different across  
branches.  
  
In master, this deletes OperatorUpd() in favor of an expanded function  
UpdateOperatorLinks().  In the back branches, OperatorUpd() is kept to  
preserve ABI compatibility.  I doubt there are any external callers,  
but as a one-line wrapper it's cheap enough to not worry about.  
  
Reported-by: Stephan Lipp <Stephan@Adalogics.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116335  

M src/backend/catalog/pg_operator.c
M src/backend/commands/operatorcmds.c
M src/include/catalog/pg_operator.h
M src/test/regress/expected/create_operator.out
M src/test/regress/sql/create_operator.sql

plperl: Refuse to free a prepared query that is being executed.

commit   : c148f9509ed5583cb17687d50859c80a462d8932    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Previously, spi_freeplan() released a prepared query's plan, and the  
memory context holding it, without checking whether the query was  
still running. Executing a prepared query can re-enter plperl, and the  
re-entered code could free the query being run. That memory context  
also holds state the running execution still needs, so freeing it  
midway left that execution using freed memory and crashed the backend.  
plperl is trusted, so any role able to create a function can reach  
this.  
  
Fix this by counting the executions in progress for each prepared  
query and refusing spi_freeplan() while that count is above zero. A  
count rather than a flag is needed because the same query can be  
running more than once at a time.  
  
Backpatch to all supported branches, where spi_freeplan() has always  
freed the plan unconditionally.  
  
Reported-by: Zheng Yu <zheng@depthfirst.com>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Backpatch-through: 14  
Security: CVE-2026-116307  

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

find_or_make_matching_shared_tupledesc: Fix possible use-after-free.

commit   : 7923562448197e5a2f9cacf65d64a044d112947c    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Previously, the following sequence of events was possible: (1) new  
anonymous-record typmod gets entered into shared_typmod_table;  
(2) another process resolves the typmod and stores a pointer to the  
associated TupleDesc; (3) the first process realizes that the  
TupleDesc duplicates one that already has some other typmod assigned  
to it and frees the TupleDesc; (4) later, the other process  
accesses the now-freed storage, interprets it as a TupleDesc, and  
uses it to deform a tuple.  
  
It is likely that an attacker can control the new contents of the  
freed memory to a sufficient degree to achieve arbitrary code  
execution; hence, this is a security vulnerability.  
  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Security: CVE-2026-116304  
Backpatch-through: 14  

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

Don't use MinMaxAggPath if aggregate's input and output types don't match.

commit   : 0eba29495584b72ce9d3ee8b754b48d964b7222c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

A sort-operator option only makes sense for an aggregate that behaves  
like MIN or MAX.  We can't really verify whether an aggregate does,  
but for our purposes the most important expectation is that the  
aggregate returns the same type as its input.  Without this, the  
planner's conversion to a MinMaxAggPath plan risks type violations.  
Since such aggregate definitions might already exist in the wild,  
check this during planning and don't generate MinMaxAggPath if the  
types don't match.  
  
Reported-by: Zheng Yu <zheng@depthfirst.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14-19  
Security: CVE-2026-116331  

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

Handle composite type changes in ExecEvalFieldStore[De]Form

commit   : e8f2492727f2e4e668d6887d2af6c88870ae8067    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

The composite type may be modified during execution, e.g. between  
deforming and forming a value, but the executor code ignored that and  
could have deformed/formed the tuple with a mismatching descriptor. The  
consequences could be severe, including reading/writing memory, etc.  
  
Fixed by remembering the descriptor in ExecInitExprRec(), and using it  
when deforming and forming tuples later, instead of looking up a new  
descriptor. This is the same approach already used for RowExpr.  
  
This means attributes added after initializing the descriptor will be  
treated as NULL, and dropped attributes will be removed from the tuple.  
  
Technically, this is an ABI break. It modifies the ExprEvalStep, which  
is part of the ABI. The meaning of one pointer (replacing rowcache with  
tupdesc) changes, and ncolumns gets removed. Neither changes the layout  
or size of the struct, and so should be backwards compatible. It could  
have a bigger impact on custom JIT providers, but we've not found any.  
  
Reported-by: OpenAI Codex Security  
Reported-by: Bronson Yen <bronson@calif.io>  
Reported-by: Mehmet D. INCE <mehmet@mehmetince.net>  
Author: Tomas Vondra <tomas@vondra.me>  
Co-Authored-by: Heikki Linnakangas <heikki.linnakangas@iki.fi>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Security: CVE-2026-116306  
Backpatch-through: 14  

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

Treat application of a leaky function to CaseTestExpr/Param as leaky.

commit   : eca4935d29a9f8b44a4b4faf8a7e86dd60f48b94    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

A CaseTestExpr or internal Param represents the value of an expression  
somewhere else in the query.  If that expression contains a Var then  
there is potential for information leakage.  Therefore, teach  
contain_leaked_vars() to reject such cases.  
  
In principle we could try to find the referenced expression and  
perform a more accurate analysis, but that seems not worth the  
substantial work required, because in most real-world cases  
there'd be a Var there anyway.  
  
Reported-by: Only see myself <1950233439@qq.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116327  

M src/backend/optimizer/util/clauses.c
M src/backend/optimizer/util/var.c
M src/include/optimizer/optimizer.h

Further harden PL/Perl against tied-scalar mischief.

commit   : a389439963d8f75a28f6f84ac7afa9db81b6094d    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

PL/Perl decides whether Perl threw an error by testing SvTRUE(ERRSV).  
If the thrown value is an object whose class overloads "bool", that  
runs user-supplied Perl code.  There is no eval{} in scope at some of  
these tests, so if that code throws in turn, Perl writes the message  
to stderr and exits the backend, not the behavior we want.  
  
To fix, don't ask Perl at all in the case that matters.  Any reference  
is true regardless of what its class claims, so a thrown object is an  
error by definition, while overloading cannot apply to a non-reference.  
Add errsv_is_true() to encapsulate that and replace tests of ERRSV  
with that.  
  
Also, consider the possibility that trying to stringify ERRSV throws  
an error, which can also be arranged with a hostile object definition.  
That risks an infinite loop in PG_PERL_TRY, so install code to prevent  
repeating such a loop.  
  
Lastly, stringify ERRSV outside our ereport() calls not inside.  If we  
do it inside then a thrown Perl error temporarily leaks an errordata[]  
slot for the unfinished ereport.  While it's not clear that this makes  
it possible to overrun ERRORDATA_STACK_SIZE, it seems best to avoid  
the leak.  
  
Reported-by: Dwij Mehta <dwijimehta@gmail.com>  
Author: Andrew Dunstan <andrew@dunslane.net>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116326  

M src/pl/plperl/plperl.c
M src/pl/plperl/plperl.h

plperl: don't save and re-use temp context in return_next().

commit   : 556614e0428afda5da5dc33c75fc275b9c401d8a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Commit ebdefb93b arranged to run plperl_return_next_internal()  
in a temporary memory context that got reset at the end of each  
call, so as not to accumulate lots of leaked memory in a PL/Perl  
function that returns many rows.  But this arrangement is unsafe  
because re-entrant calls of return_next are possible, as shown  
by the new regression test.  In that case the inner call's reset  
destroys data the outer call still needs, leading to crashes.  
Instead, just create and delete a temp context for each call.  
That works correctly in the nested case, and in the normal case  
it's not really much slower than the old way thanks to the context  
recycling logic in aset.c (which long postdates ebdefb93b, but is  
in every still-supported branch).  
  
Reported-by: Anthropic OSS program  
Author: Anthropic OSS program  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116319  

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

Hold a reference on a Perl array or hash while scanning it.

commit   : bd76c497e9624a774c9e30d610dff246ee46901b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Previously we assumed that the object would stick around while we  
examined it, but there are a few ways that the last refcount could get  
dropped meanwhile, allowing the object to be recycled and creating a  
use-after-free hazard.  To prevent that, we must acquire our own  
refcount and release it when we're done.  The tricky part is to ensure  
that the refcount gets released if an error is thrown partway through.  
A TRY/FINALLY block would work, but that answer would be expensive  
and notationally invasive.  The method used here is to push a  
refcount-carrying RV onto Perl's temporaries stack so that temporaries  
cleanup will release the reference.  A simple benchmark suggests that  
that adds just a couple percent of overhead, which seems acceptable.  
  
The first draft of this patch was created by Anthropic's OSS program.  
  
Reported-by: Anthropic OSS program  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Co-authored-by: Anthropic OSS program  
Backpatch-through: 14  
Security: CVE-2026-116320  

M contrib/hstore_plperl/hstore_plperl.c
M contrib/jsonb_plperl/jsonb_plperl.c
M src/pl/plperl/plperl.c

Fix PL/Perl to cope with errors thrown from tied structures.

commit   : 8ab0f897d41a9c6024497b088a1bafc5c94c50f1    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

An error thrown from a tied array, hash, or scalar may occur while  
PL/Perl is trying to return a function value, in which case we are  
outside the call_sv() execution loop that would normally handle  
trapping of Perl errors.  That is problematic: if Perl doesn't think  
it is inside an eval-like context, it will bleat on stderr and then  
exit(); while if it does think that, it will longjmp out to some outer  
level of Perl execution, which wreaks havoc.  We need to keep Perl's  
jmp_buf stack in sync with Postgres', so that we never have a situation  
where one of those stack pointers points above the function level the  
other stack was just used to jump out to.  
  
The core idea of this fix is to replace PG_TRY blocks within PL/Perl  
with "PG_PERL_TRY" blocks, which have fundamentally the same semantics  
as PG_TRY, but establish new jmp_buf levels within both stacks and pop  
both correctly at exit.  If a Perl error is caught using Perl's stack,  
we'll convert it to a Postgres error using logic similar to what  
PL/Perl uses for the purpose elsewhere.  
  
This simple core idea has some complications though.  One big one  
is that since PG_PERL_TRY adjusts the state of the current Perl  
interpreter, we must make sure that we don't switch interpreters  
partway through the block.  Which the old code did freely.  
To fix that without adding more TRY blocks than necessary, refactor  
the contract between plperl_call_handler and its sub-handlers  
(plperl_func_handler et al) so that we look up the target function and  
switch to the associated interpreter before we enter the sub-handler.  
  
I also spent a deal of effort on tightening the error-condition  
guarantees for select_perl_context and plperl_init_interp, as per the  
changes to their header comments.  As they stood, it was really hard  
to say anything about what state would be left behind after a failure  
during Perl interpreter creation, which cascaded into not being able  
to promise anything about what would happen in their callers.  
  
Within PG_PERL_TRY, there are more problems.  Aside from just pushing  
a new jmp_buf stack level (handled by JMPENV_PUSH/JMPENV_POP), we must  
see to it that if control does reach Perl_die then it will choose to  
longjmp() rather than summarily exit().  At least in Perl 5.40, there  
are two gating tests: PL_in_eval must be nonzero (preferably with the  
EVAL_INEVAL bit set), and S_dopoptoeval must find a CXt_EVAL context  
on the PERL_CONTEXT stack.  We could hack PL_in_eval directly, but  
there's no direct way to manipulate the context stack.  The solution  
used here is to execute OP_ENTERTRY and then (if a longjmp didn't  
happen) OP_LEAVETRY.  That requires manually saving/restoring PL_op,  
as well as ERRSV, but otherwise seems to work fairly well.  
  
Another interesting bit is that if possible, we create only one jmp_buf  
struct and link it into both error stacks.  It'd be cleaner to keep  
the two mechanisms entirely separate, but that would require two  
sigsetjmp calls in close proximity, which turns out to break clang's  
optimizer quite thoroughly.  We do get the small benefit of saving the  
cycles that would go into a second sigsetjmp call.  A complication is  
that we need to be able to figure out whether a caught longjmp was  
triggered by Perl or Postgres.  We do that by adding some state in  
elog.c so that we can tell whether the topmost error data is complete  
or not.  If it isn't, then the error was thrown by Perl.  (An example  
where this distinction matters is that the sv2cstr calls used in  
plperl.c's own ereports could throw Perl errors, at a point where we  
are still filling in a Postgres error.)  Ideally this state would be  
carried by a new flag in ErrorData, but to avoid an ABI break in  
stable branches, hide it inside elog.c for now.  
  
However, we can't use that trick on MinGW-64, because there we use  
gcc's __builtin_setjmp() while Perl uses MinGW's plain setjmp().  
So in that case, resort to managing the jmp_buf stacks separately.  
  
Reported-by: Ngoc Trần <anbas1342@gmail.com>  
Reported-by: Anthropic OSS program  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116326  

M src/backend/utils/error/elog.c
M src/include/c.h
M src/include/utils/elog.h
M src/pl/plperl/expected/plperl_tied.out
M src/pl/plperl/plperl.c
M src/pl/plperl/plperl.h
M src/pl/plperl/sql/plperl_tied.sql

Support tied Perl objects in plperl and associated contrib modules.

commit   : 68abacacac0c61c727a24622cec73a1b52ff53ac    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:21:00 -0800    

Click here for diff

Up to now, if you passed a "tied" object to a PL/Perl operation,  
it would most likely get treated as "undef", since we failed to  
perform get magic on values we're passed.  Tied hashes worked  
partially, in that you could read out their keys, but the values  
always read as undef.  
  
To fix, use hv_iterval() not HeVAL() to fetch values from perl  
hashes, and be careful to apply plperl_materialize_sv() before  
testing SvOK() or SvROK() on any perl SV.  
  
Add regression test cases exercising some typical usage scenarios  
for tied objects.  
  
This is a back-patch of commit ccab6d36d.  The original intent was  
for that to be master-only on the grounds that it wasn't worth  
the risk to back-patch.  However, we now realize that there are  
several security issues around tied Perl objects, some of which  
are reachable even without this fix.  Having to test different  
behaviors in master and back branches doesn't seem like a good  
plan, so as a first step do this to make the branches more alike.  
  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/569769.1786901901@sss.pgh.pa.us  
Backpatch-through: 14-19  
Security: CVE-2026-116326  

M contrib/hstore_plperl/expected/hstore_plperl.out
M contrib/hstore_plperl/hstore_plperl.c
M contrib/hstore_plperl/sql/hstore_plperl.sql
M contrib/jsonb_plperl/expected/jsonb_plperl.out
M contrib/jsonb_plperl/jsonb_plperl.c
M contrib/jsonb_plperl/sql/jsonb_plperl.sql
M src/pl/plperl/GNUmakefile
A src/pl/plperl/expected/plperl_tied.out
M src/pl/plperl/plperl.c
M src/pl/plperl/plperl.h
A src/pl/plperl/sql/plperl_tied.sql

Avoid use-after-free hazards in re-entrant use of pltcl.

commit   : b2b0f9507ab4f5da6eb0ef254620444819d8fdad    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    

Click here for diff

When pltcl invokes a SQL datatype input function, it was passing a  
string that is owned by the Tcl interpreter.  This is hazardous  
since the input function could re-entrantly call the same Tcl  
interpreter (for example, via a pltcl function in a domain check  
constraint), and that call could modify or free the string we're  
depending on.  Avoid the hazard by ensuring that we've pstrdup'd  
whatever Tcl returned.  
  
In all of these call sites, there's no great need to worry about  
pfree'ing the extra string immediately, since we're either inside a  
short-lived subtransaction or about to return from the pltcl function.  
So I didn't complicate the code by doing that.  
  
Reported-by: Anthropic OSS program  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116323  

M src/pl/tcl/pltcl.c

Prevent construction of invalid "name" values via element assignment.

commit   : 4d27101361b2ba53be51272fb71ac7a14936106d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    

Click here for diff

Although type "name" is of length NAMEDATALEN, we must not allow the  
last byte to become nonzero.  Otherwise, operations that treat it as  
a C string will read off the end, resulting in crashes or disclosure  
of server memory.  array_set_element() failed to enforce this.  
  
Another bad outcome of element assignment could be to construct an  
invalidly-encoded multibyte character.  Check that too while we're  
at it.  
  
Ideally we'd extend array_set_element()'s API to pass the array type  
OID, but that's infeasible in released branches, and it seems not  
worth the trouble even in master given the tiny usage of fixed-length  
array types.  Instead just test for elmlen == 1 && arraytyplen ==  
NAMEDATALEN to decide whether it's a name.  
  
Reported-by: Anthropic OSS program  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 14  
Security: CVE-2026-116321  

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

Fix potential buffer overrun in ts_rank_cd().

commit   : 530a034aa2cfa2785a4301398fc3fb50526b794b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    

Click here for diff

get_docrep() assumed there could be no more QueryItems per group  
than there are lexemes in the input tsvector.  That's true with valid  
tsvector input, which will never show duplicate positions for any  
lexeme.  But with duplicate positions it's possible to overrun the  
allocated space.  Guard against that by dropping items if there are  
more than we expect (it doesn't seem worth working harder than that).  
  
The submitted test case that reached this constructed an invalid  
tsvector by dint of starting with one, namely a tsvector containing  
a zero position, which tsvectorrecv() failed to prevent before  
10cc5aa96.  It's not clear whether the problem is reachable without  
that.  
  
Reported-by: Anthropic OSS program  
Author: Anthropic OSS program  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116317  

M src/backend/utils/adt/tsrank.c
M src/include/tsearch/ts_type.h

Fix potential buffer overrun in tsvector_delete().

commit   : d681b9f6a53b7b34798aeb069e038456a90c9ebe    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    

Click here for diff

tsvector_delete_by_indices() sized its output as VARSIZE(input) on the  
assumption that the result can never be larger, but that only holds  
when the input's lexeme data area is laid out in WordEntry order, like  
the output's will be.  With a different ordering, additional pad bytes  
could be needed for alignment of position data.  ts_type.h explicitly  
says that a different lexeme data ordering is legal, and  
tsvectorrecv() for one can produce other orderings.  To fix, use the  
same solution as tsvector_concat(): allocate one extra byte per  
output lexeme.  That's probably considerably more than enough, but  
it's not worth working harder.  
  
Reported-by: Anthropic OSS program  
Author: Anthropic OSS program  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-116315  

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

Fix type confusion in PL/Perl's get_perl_array_ref().

commit   : c032c0fbdc0cd9254d04ea83cbd8b07aa485ed95    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    

Click here for diff

get_perl_array_ref() used sv_isa(sv, "PostgreSQL::InServer::ARRAY") to  
recognize PL/Perl's own array wrapper objects, then cast SvRV(sv) to  
HV * and looked up the "array" key.  But sv_isa() only reports which  
package a reference was blessed into, and blessing is an unprivileged  
Perl operation that constrains nothing about what is blessed.  A  
function in trusted plperl could therefore return  
  
	my $x = "hi"; return bless \$x, 'PostgreSQL::InServer::ARRAY';  
  
whereupon hv_fetch_string() would read a hash bucket array out of the  
body of a plain scalar and dereference it.  Since plperl is trusted,  
any role with CREATE on a database can reach this.  
  
Fix, per a suggestion from Tom Lane, by requiring SvTYPE(SvRV(sv)) to  
be SVt_PVHV before consulting sv_isa().  A reference blessed into that  
package but pointing at anything else now falls through to the caller's  
existing handling for other references, which looks through the  
reference; the example above fails with "malformed array literal".  Add  
a regression test next to the existing forged-object case.  
  
It's not clear if this is exploitable, but out of an abundance of  
caution we treat it as if it is.  
  
Reported-by: Zheng Yu <zheng@depthfirst.com>  
Backpatch-through: 14  
Security: CVE-2026-116309  

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

pg_basebackup: Fix use of externally-controlled format string

commit   : 50f650b91b83a7cf0ee764b6e3ac8faed129e541    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 9 Nov 2026 06:20:59 -0800    

Click here for diff

appendPQExpBuffer() was accidentally used instead of  
appendBinaryPQExpBuffer() in pg_basebackup.  The former would  
interpret the string to be appended as a format string, which could  
lead to misbehavior.  (The string contents are related to backup  
manifest contents.  Those do not normally contain any data that could  
look like a format placeholders.  In order for this to misbehave,  
files with unusual names would have to exist in the data directory.)  
  
- The hunk in ReceiveBackupManifestInMemoryChunk() is from commit  
  0d8c9c1210c, 2020, PG13.  
  
Security: CVE-2026-16240  
Backpatch-through: 14  

M src/bin/pg_basebackup/pg_basebackup.c

Translation updates

commit   : fe8c2faefb4ab04554f1be66ce07b00d3df3f5a2    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 9 Nov 2026 12:27:42 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 9 Nov 2026 12:27:42 +0100    

Click here for diff

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

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

Release notes for 18.7, 17.12, 16.16, 15.20, 14.25.

commit   : 38ccfd8c955b3249fbbbdfaaef1c478d411dcc63    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 8 Nov 2026 16:41:09 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 8 Nov 2026 16:41:09 -0500    

Click here for diff

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

Fix crash with single-input aggregates with multiple sort keys

commit   : f72e4686e213d86e5e34a474019e500e3f0fcc63    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 6 Nov 2026 20:18:18 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 6 Nov 2026 20:18:18 +1300    

Click here for diff

An aggregate's ORDER BY can list the same sort key more than once with  
different sort operators, and transformDistinctClause() copies such  
items into the DISTINCT list.  So an aggregate with a single input can  
have several sort keys and several DISTINCT columns.  
  
nodeAgg.c and execExpr.c mistakenly only checked the number of inputs  
when deciding if a Datum sort was possible.  That check must also  
consider the number of sort keys.  
  
Fix by using the Datum sort only for a single input with a single sort  
key.  
  
Also for v16+, fix crash in pre-sorted aggregate code where the uniqslot  
was only created when the number of inputs for a DISTINCT aggregate was  
above 1.  The uniqslot is required when there are multiple DISTINCT  
columns, and an ORDER BY clause may cause more than one of these to exist  
when there's only a single input column.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWXMuo5QZSy_az+86mty2XdbDw_7uB3C4FjWpFACvD_rzg@mail.gmail.com  
Backpatch-through: 14  

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

doc: Improve output_plugin_libraries documentation

commit   : 7e5d06901fc98809f1f8c835d90682f93a545f6f    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:54:54 -0800    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:54:54 -0800    

Click here for diff

Describe the effects of removing the builtin plugins from  
output_plugin_libraries. It may not be obvious to DBAs why they might  
want to keep those in the allowlist, since it wasn't previously possible  
to pick and choose plugins without modifying the Postgres installation  
itself.  
  
Reported-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAOYmi%2Bmt5bcV6B0DZR-t1tfpX8wjk8Aj%2BftEd%3DxXuH5qege2%2BQ%40mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/config.sgml
M doc/src/sgml/ref/pg_recvlogical.sgml

Add a check_hook for output_plugin_libraries

commit   : 0c8611c6e7e614ba6cc224a6b819ef2862e46c71    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:54:52 -0800    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:54:52 -0800    

Click here for diff

I omitted explicit syntax validation of output_plugin_libraries in  
226e49cbed. [ALTER SYSTEM] SET does this implicitly due to the parser  
grammar, but a DBA could still accidentally put a bad value into  
postgresql.conf, and a superuser could do the same with connection  
options or set_config(). Logical replication would then fail later on.  
  
This is an annoying papercut for a security option to have, so reject  
these cases immediately in a check_hook.  
  
Tests by Hayato Kuroda.  
  
Co-authored-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/CAOYmi%2BkBsG5rNRb1j2VjgTKg8HY90e7vSvZPLeouiAc6nXP9XA%40mail.gmail.com  
Backpatch-through: 14  

M src/backend/replication/logical/logical.c
M src/backend/utils/misc/guc.c
M src/test/regress/expected/guc.out
M src/test/regress/sql/guc.sql

Handle numeric overflow when handling range values

commit   : 52f418f1f8acbbe44c3ff267ece6082ee61fff9f    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 5 Nov 2026 13:00:43 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 5 Nov 2026 13:00:43 +0100    

Click here for diff

The numrange_subdiff() function was calculating the difference simply by  
calling numeric_sub and numeric_float8, but those functions are not  
overflow-safe. It's possible to insert valid numeric ranges for which  
the difference overflows either numeric or float8.  
  
The overflow may affect various operations on numrange columns. It may  
cause failures during ANALYZE on the table, inserts into GiST indexes,  
selectivity estimation, and possibly other operations.  
  
Fixed by handling overflows in numrange_subdiff() - extreme differences  
are treated as infinity.  
  
Author: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com  

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

commit   : 9e77656a91f4df3f584329aba9fdfc5ca6704d28    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Wed, 4 Nov 2026 16:21:42 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Wed, 4 Nov 2026 16:21:42 +0900    

Click here for diff

For INSERT ... VALUES with more than one row, transformInsertStmt()  
calls transformInsertRow() once for each VALUES row and once more for  
the final targetlist, and each call transformed the same raw  
indirection from the target column list.  That doesn't work for  
sublinks, because transformSubLink() replaces the raw subselect with  
its analyzed Query, so the second pass failed with "unexpected  
non-SELECT command in SubLink".  Other nodes that are transformed in  
place, such as NullTest, failed with "unrecognized node type".  
  
Fix by giving each transformation its own copy of the indirection.  
  
Claude found this issue when reviewing another bug.  
  
Discussion: https://postgr.es/m/CA+HiwqHCZLZV_20nz3fQX+1=vyFLDMbG0_3wY=QujNKZWts0nw@mail.gmail.com  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Backpatch-through: 14  

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

Fix ExecCheckIndexConstraints() crash when es_snapshot is invalid.

commit   : 83efe9602ecdad32ffe766ba0deab02b5fb0da93    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 4 Nov 2026 19:45:45 +0000    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 4 Nov 2026 19:45:45 +0000    

Click here for diff

At transaction level SERIALIZABLE, commit fb60892f403 made  
check_exclusion_or_unique_constraint() read the conflicting tuple  
again using estate->es_snapshot when violationOK is true and  
conflictTid is non-NULL, to ensure that INSERT ... ON CONFLICT takes  
an SIREAD lock. This can only happen from ExecCheckIndexConstraints(),  
but not all callers of ExecCheckIndexConstraints() initialize  
estate->es_snapshot, and the re-fetch crashes if it's invalid.  
  
In core Postgres, this only affects the logical replication apply  
worker which, starting from v18, uses ExecCheckIndexConstraints() to  
log conflicts while applying changes, without initializing es_snapshot  
in the EState that it builds. However, there is also extension code  
that does the same, so the problem affects all versions that  
fb60892f403 was applied to.  
  
Fix by skipping the re-fetch in check_exclusion_or_unique_constraint()  
if the snapshot is invalid.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAN4CZFPz4ysPyo1ahD-5n0iyKxmuo2Wvn%3DPgEZTyW63_Tu7Eaw%40mail.gmail.com  
Backpatch-through: 14  

M src/backend/executor/execIndexing.c

Fix comment in ExecAppendAsyncReset.

commit   : 48955703b9e6958a7bf8e2cb7af1a56265ba1017    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 4 Nov 2026 18:30:07 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 4 Nov 2026 18:30:07 +0900    

Click here for diff

We call ExecAppendAsyncEventWait with as_syncdone=true, which forces it  
to wait until at least one event occurs, ensuring it never polls.  
  
Oversight in commit f57df2068.  
  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Chao Li <lic@highgo.com>  
Discussion: https://postgr.es/m/CAPmGK1648ovA1i_4X%2BvO%3DCi%2BkSpvvG0H9jcb2m4inybXtSyw6A%40mail.gmail.com  
Backpatch-through: 14  

M src/backend/executor/nodeAppend.c

Don't free a cached RI plan that may be in use

commit   : bc2125742cb0ccacad71d4883da9369669846017    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Wed, 4 Nov 2026 14:52:31 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Wed, 4 Nov 2026 14:52:31 +0900    

Click here for diff

Currently, ri_FetchPreparedPlan() immediately frees a cached SPI plan  
if SPI_plan_is_valid() returns false, without tracking whether the  
plan might be in use.  That can cause _SPI_execute_plan() to read  
freed memory.  This happens, for example, when an RI check's or  
action's query runs some user-defined code such as a cast function or  
BEFORE ROW trigger function which may perform its own DML using its  
own query that is not restricted from firing its own triggers, some  
of which may be RI triggers for the same constraint as the outer RI  
check and hence use the same cached plan.  If an invalidation arrives  
that marks the cached plans referenced by the outer check's SPI plan  
invalid between the outer check having called _SPI_execute_plan() and  
the inner check's ri_FetchPreparedPlan(), the latter will free the  
SPI plan as mentioned above.  
  
Lucas Jeffrey reported an instance of this bug involving a  
self-referencing ON DELETE CASCADE foreign key.  The RI action's  
DELETE fires a BEFORE DELETE trigger on the rows it deletes, which  
invalidates the action's plan with GRANT and REVOKE on the table and  
then runs a DELETE of its own, and the RI action fired by that DELETE  
is the inner check described above.  Separately, Tom Lane reported  
that buildfarm member trilobite, which runs with CLOBBER_CACHE_ALWAYS,  
hit this in the regression tests on master after a change there made  
more FK checks go through SPI.  
  
Fix by keeping a stack of the plans that every ri_PerformCheck() call  
in progress is executing, pushed before SPI_execute_snapshot() and  
popped whether it returns or throws an error, the latter using  
PG_FINALLY().  ri_FetchPreparedPlan() now frees an invalid plan on the  
spot when it is not on that stack, as before, since nothing can be  
executing it.  Otherwise it only detaches the plan from its hash entry  
and queues it on a list.  Whenever a check finishes, the queued plans  
that are no longer on the stack are freed.  So a plan is held only  
while a check is actually executing it, however many invalidations  
happen meanwhile.  A new AtEOXact_RI() frees whatever is left.  
  
Add the test from Lucas's original patch, which reproduces the crash  
on an ordinary cassert build, and a test that raises errors from  
inside a check's query, some of them inside subtransactions that are  
then rolled back, to check that the stack stays exact.  
  
Author: Lucas Jeffrey <lucas.jeffrey@anachronics.com>  
Co-authored-by: Trakshan Mishra <trakshanmishra477@gmail.com>  
Co-authored-by: Amit Langote <amitlangote09@gmail.com>  
Reported-by: Lucas Jeffrey <lucas.jeffrey@anachronics.com>  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/3043944.1792163844@sss.pgh.pa.us  
Discussion: https://postgr.es/m/CAGHzy7S0XfXdK3amd5c4QhpS1o9dySVzPr+-d9ohaE4iV_vNog@mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/transam/xact.c
M src/backend/utils/adt/ri_triggers.c
M src/include/commands/trigger.h
M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql

Fix possible index corruption in pg_trgm GiST indexes

commit   : 42c6d2bc3f2e28be83bf9fda0bc4ac4f5a597963    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 4 Nov 2026 11:18:49 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 4 Nov 2026 11:18:49 +0900    

Click here for diff

Commit 911e7020770, which added configurable signature lengths,  
introduced an error in how gist_trgm_ops index entries are combined.  
Some entries could lose the flag identifying their format, causing  
later inserts to treat them as empty and lose information about  
existing entries.  As a result, queries using these indexes could  
miss matching rows.  
  
Fix this by preserving the format flag when combining index entries,  
so that subsequent inserts correctly retain the information they  
represent.  
  
This fix does not repair existing indexes.  Users should REINDEX all  
existing gist_trgm_ops indexes after upgrading to a release containing  
this fix.  
  
Backpatch to all supported versions.  
  
Author: Nate Clark <natec425@gmail.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19720-b3e83f5e99c485c5@postgresql.org  
Backpatch-through: 14  

M contrib/pg_trgm/trgm_gist.c

Fix Memoize to correctly use clause's input collation

commit   : e22cec1bdb3c4a326152c161d58077c33755a093    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 4 Nov 2026 13:43:17 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 4 Nov 2026 13:43:17 +1300    

Click here for diff

When building Memoize cache keys from a parameterized path's join clauses,  
paraminfo_get_equal_hashops() used the outer side expression of each  
clause verbatim, which meant the cache was hashed and probed using that  
expression's collation rather than the input collation of the join  
condition.  
  
If the expression's collation is nondeterministic and the clause compares  
using a different collation, values that the clause can distinguish, such  
as 'abc' and 'ABC' under a case-insensitive collation, could be treated as  
equal by the cache.  This could cause a lookup to return the cached  
results for another value, giving wrong query results.  
  
Here we fix this by relabeling the cache key expression with the join  
clause's input collation, so that cache lookups match values the same way  
as the join clause does.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqTBsBegZ8rNMYjwkeu1V5wRQ06zR6jTVickqP_3E7mb8g@mail.gmail.com  
Backpatch-through: 14  

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

doc: Match built-in function parameter names to their SQL names

commit   : 62a615e0b08c79437f3c6375f8b4b1e9db4b7c2f    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 15:05:01 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 15:05:01 +0900    

Click here for diff

Several documented function signatures used parameter names that  
differed from the registered SQL names, causing named-argument calls  
using the documented names to fail. Update the signatures and  
corresponding descriptions to use the SQL-visible names, without  
affecting existing calls.  
  
Backpatch to all supported versions, except for the changes to  
pg_logical_emit_message and pg_input_error_info, which are  
backpatched through v17 and v16, respectively.  
  
Reported-by: Mi cro <micro6947@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19D9D4CB-8C31-493E-982A-1E17042D68C5%40gmail.com  
Backpatch-through: 14  

M doc/src/sgml/func.sgml
M doc/src/sgml/textsearch.sgml

doc: Fix column name in routine_sequence_usage documentation

commit   : ea7b9f7095f001b23acbd5ca7aecfedab789db45    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 14:58:56 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 14:58:56 +0900    

Click here for diff

The sequence catalog column of information_schema.routine_sequence_usage  
is named sequence_catalog in the view definition, but the documentation  
previously called it schema_catalog.  Correct the documented column name  
to match the view.  
  
Backpatch to all supported versions.  
  
Reported-by: Mi cro <micro6947@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/179342977864.1246.4971529844925475150@wrigleys.postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/information_schema.sgml

Make Memoize cache keys only of Params from outer query levels

commit   : 63e261b0bb37a4fc4f7d2425c64ac6cf7efc54ac    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 3 Nov 2026 09:50:13 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 3 Nov 2026 09:50:13 +0900    

Click here for diff

Commit 708eb5158 made each PARAM_EXEC Param buried inside a larger  
Memoize cache key expression a cache key by itself, and, in master  
only, commit f8da64e6d extended that to the Params in the memoized  
relation's base quals, targetlist and join clauses.  Both meant to  
catch Params supplied by an outer query level, but they took every  
PARAM_EXEC Param they found, including the output Params of initPlans  
and SubPlans.  
  
When an initPlan's output Param is made a cache key, it is evaluated  
on every cache probe, which runs the initPlan even where the query  
doesn't need it, such as in a CASE arm that is never taken, and can  
raise an error the query shouldn't raise.  A SubPlan's output Params  
have a value only while the SubPlan evaluates its testexpr, so making  
a cache key of one fails with "plan should not reference subplan's  
variable".  
  
To fix, make cache keys only of the Params listed in some outer query  
level's plan_params, as those hold values supplied by outer levels and  
are always safe to evaluate.  Any other Param is left to purge the  
cache when it changes.  
  
Back-patch to all supported branches.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwHdaau1KooFbY10=MDhKtFVgpmPrDiwNpEe6bWu7wpQYA@mail.gmail.com  
Backpatch-through: 14  

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

Delay checkpoint start while creating a multixact

commit   : 67fa8cb33cd94c6d6e17dc64b3748e9d70bb145c    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 3 Nov 2026 01:39:20 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 3 Nov 2026 01:39:20 +0200    

Click here for diff

A checkpoint starting between the CREATE_ID record and the SLRU update  
could lose the multixact after a crash.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAGRkXqSuiJ_X4+Z6rsD42pcuACnD9PhoQ-Os+mUJNmJarBWkNg@mail.gmail.com  
Backpatch-through: 14  

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

Fix BRIN minmax-multi distance for tid values

commit   : c48577385d15245691dbbff3bf25f1a1b58fe70e    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 2 Nov 2026 21:49:28 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 2 Nov 2026 21:49:28 +0100    

Click here for diff

The distance function for tid values maps item pointers to float8 as  
  
  (block * MaxHeapTuplesPerPage + offset)  
  
but the multiplication was done in uint32 arithmetic, so for high block  
values (above 14759338, ~112GB) the result wrapped around. The distance  
would then be very inaccurate (possibly negative), resulting in a less  
efficient index.  
  
Fix by doing the arithmetics in double.  
  
It's also possible the (user-supplied) item pointers have offsets  
greater than MaxHeapTuplesPerPage, confusing the mapping to double  
value. This commit does not try to address that, it's not clear what  
would be a better mapping.  
  
Author: Tomas Vondra <tomas@vondra.me>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com  

M src/backend/access/brin/brin_minmax_multi.c

Handle numeric overflow in numeric_minmax_multi_ops

commit   : 174b605f0e3a3e6a01a137ea401733b699937cad    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 2 Nov 2026 20:09:59 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 2 Nov 2026 20:09:59 +0100    

Click here for diff

When calculating the distance between numeric values, the code could  
overflow in two ways. A subtraction of two finite values may still  
overflow, or the result may not fit into float8.  
  
The distances don't need to be perfectly accurate, although it may make  
the index less efficient. And for most minmax-multi opclasses it works  
like that, but for numeric the functions may error-out. That prevents  
summarization, either when creating an index or later during vacuum.  
  
Fix by using numeric_sub_safe() and numeric_float8_no_overflow(), and  
returning infinity when either of those fails. The older releases need  
to use numeric_sub_opt_error(), but the principle is the same.  
  
Also, handle NaN values the same as for float4/float8. When both values  
are NaN, return distance 0. When one value is NaN, return infinity.  
  
While at it, free the detoasted copies of arguments, and the calculated  
numeric distance. For small values it does not matter, but for extreme  
numeric values it may make a difference.  
  
Reported by Kirill Reshke, with a patch fixing the issue. Various  
improvements and backpatching by me.  
  
Backpatch to 14, where minmax-multi indexes were introduced.  
  
Author: Kirill Reshke <reshkekirill@gmail.com>  
Author: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com  

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

Fix missing tts_tid assignments in ExecForceStoreHeapTuple().

commit   : 4e9a5dc1f57c7b1e64601825a497b94b1f36359c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 2 Nov 2026 10:13:52 -0600    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 2 Nov 2026 10:13:52 -0600    

Click here for diff

ExecForceStoreHeapTuple() clears the slot before storing the tuple,  
which invalidates the slot's TID, but it only sets the TID again  
for slots of type TTSOpsHeapTuple.  Besides producing wrong query  
results, this can lead to data corruption if an affected tuple is  
locked (e.g., via SELECT ... FOR UPDATE).  To fix, set the slot's  
TID for the other kinds of slots, too.  
  
Oversight in commit b8d71745ea.  
  
Author: Virender Singla <virender.cse@gmail.com>  
Co-authored-by: Greg Burd <greg@burd.me>  
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Nikolay Samokhvalov <nik@postgres.ai>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Tested-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAM6Zo8wZOLnCWRO_tuuXVX9J4N4JN6GsEnk8WJtT0%3D_0zy-1dw%40mail.gmail.com  
Discussion: https://postgr.es/m/0498c10f-839b-4f68-9994-c29b454e55a4%40app.fastmail.com  
Backpatch-through: 14  

M src/backend/executor/execTuples.c

Update .abi-compliance-history for hashed SubPlan fix

commit   : 56fb8ee6ed72c9e0637325d25588f872c147e211    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 15:43:17 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 15:43:17 +0900    

Click here for diff

Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/179087936257.78721.1170374394656748858@mail.gmail.com  
Backpatch-through: 14-18  

M .abi-compliance-history

Delay checkpoint start in RecordTransactionAbortPrepared()

commit   : ea1b698f2ecd9a9b1a31452f6412649352c0dbb2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 15:18:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 15:18:21 +0900    

Click here for diff

ROLLBACK PREPARED flushes its abort record and then updates pg_xact.  
Nothing prevented a checkpoint from setting its redo pointer between  
these two steps.  A crash before the removal of the 2PC state file would  
then cause recovery to begin after the abort record and would restore  
the transaction as prepared, even though its rollback has been  
aknowledged.  Standbys could for example replay the abort record, and a  
follow-up COMMIT PREPARED on a primary could make them flip a  
transaction from aborted to committed.  
  
Losing an abort is harmless for a regular transaction, but not for a  
prepared transaction whose 2PC state file is still on disk.  This issue  
is fixed by setting DELAY_CHKPT_START (delayChkpt in v14) around the  
abort record and the pg_xact update, as done for COMMIT PREPARED.  
  
This issue exists since the introduction of 2PC, since d0a89683a3a4.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com  
Backpatch-through: 14  

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

Fix reuse of stale hash tables by duplicated hashed SubPlans

commit   : 40a5aa4a792d7f975940ed0d443438070256efb6    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 14:40:19 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 14:40:19 +0900    

Click here for diff

The same SubPlan can appear more than once in a plan tree.  For  
example, when an equivalence class has a constant member containing a  
SubPlan, each derived "member = constant" clause references that  
SubPlan; a hash join's hash keys and its hash clauses can both contain  
it; and extract_restriction_or_clauses() can copy it into a new  
restriction clause while leaving it in the original join clause.  Each  
reference gets its own SubPlanState, with its own hash tables, but  
they all share the subplan's PlanState.  
  
A hashed SubPlan whose subquery references outer query levels must  
rebuild its hash tables whenever those parameters change.  
ExecHashSubPlan() detected that by checking chgParam of the subplan's  
PlanState.  But buildSubPlanHash() rescans that PlanState, which  
clears its chgParam, so after one SubPlanState had rebuilt its hash  
tables, the others no longer saw the change and kept probing hash  
tables built for previous parameter values, producing wrong query  
results.  
  
To fix, give each SubPlanState its own flag to mark its hash tables as  
stale.  ExecReScan() sets it, alongside propagating chgParam to the  
node's subplans, ExecHashSubPlan() checks it instead of the subplan's  
chgParam, and buildSubPlanHash() clears it.  The new field fits into  
existing padding in SubPlanState, so this does not change the struct's  
size or the offsets of its other fields.  
  
Reported-by: Samuel Olaoye <dapsalmy@gmail.com>  
Author: Rahul Yadav <rahul@rhyadav.dev>  
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/179087936257.78721.1170374394656748858@mail.gmail.com  
Backpatch-through: 14  

M src/backend/executor/execAmi.c
M src/backend/executor/nodeSubplan.c
M src/include/nodes/execnodes.h
M src/test/regress/expected/subselect.out
M src/test/regress/sql/subselect.sql

Fix wrong results from Memoize with a Param inside a cache key

commit   : de7d7d4df80acceca1195d549bd2887d5bc8ab26    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 10:33:24 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 10:33:24 +0900    

Click here for diff

ExecReScanMemoize() purges the whole cache only when a Param changes  
which is not part of the cache key; a change to a cache-key Param is  
assumed to be handled by looking up a different cache entry.  To that  
end, create_memoize_plan() put every Param appearing in the cache key  
expressions into keyparamids.  That assumption holds only when the  
cache key values determine the Param's value.  
  
It fails for an upper-level Param which is buried inside a larger  
cache-key expression and also appears elsewhere in the subplan.  With  
a cache key of "t2.hundred + t0.ten" and a filter "t1.twenty =  
t0.ten", different (t2.hundred, t0.ten) pairs produce the same  
cache-key value while the filter selects different rows, so one cache  
entry wrongly serves both.  Since t0.ten was included in keyparamids,  
the cache was never purged when it changed.  
  
Also, pull_paramids() collected PARAM_EXTERN Params too, whose numbers  
are unrelated to those of PARAM_EXEC Params.  An external Param in a  
cache key could therefore keep a change to an unrelated executor Param  
from purging the cache.  
  
To fix, put into keyparamids only the Params whose values the cache  
keys determine.  These are the nestloop Params which replace the outer  
rel's Vars in the cache keys, as the inner scan can only reference the  
outer rel through the cache keys, and, in binary mode only, a Param  
which is a cache key by itself.  In logical mode the hash equality  
operator may not distinguish values that affect the results  
differently.  Any other Param now purges the cache when it changes.  
Also make pull_paramids() collect PARAM_EXEC Params only.  
  
Purging alone would empty the cache on every rescan of the enclosing  
plan whenever a buried Param changes, even when the Param is used  
nowhere else and the old code was correct and kept its cache entries  
across rescans.  So also make each buried Param a cache key by itself,  
which puts Memoize into binary mode, so that cache entries survive  
across rescans with the same Param value.  A buried Param whose type  
can't be hashed is left to the purging, rather than giving up on  
Memoize.  
  
Back-patch to all supported branches.  
  
Reported-by: Jacob Brazeal <jacob.brazeal@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Yilin Zhang <jiezhilove@126.com>  
Discussion: https://postgr.es/m/CA+COZaAHZT7T2G2F0-drdQB+StWJxOzqeDxp=ESp+YUiy-kOaQ@mail.gmail.com  
Backpatch-through: 14  

M src/backend/optimizer/path/joinpath.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/clauses.c
M src/include/nodes/execnodes.h
M src/include/nodes/plannodes.h
M src/test/regress/expected/memoize.out
M src/test/regress/sql/memoize.sql

Fix pgoutput crash on missing option values

commit   : 35848657c67df5bef80f98e0d7091c23ce1e187a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 08:12:53 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 08:12:53 +0900    

Click here for diff

The replication protocol allows options without values, but pgoutput  
dereferenced a NULL DefElem argument for parameters proto_version and  
publication_names.  A replication client was able to crash a WAL sender.  
  
This issue is fixed by reading both options with defGetString(), which  
is able to report a missing parameter cleanly.  
  
Reported-by: Brar Piening <brar@gmx.de>  
Author: Zhijie Hou <houzhijie22@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Discussion: https://postgr.es/m/19795-6d7d506133b7f062@postgresql.org  
Backpatch-through: 14  

M src/backend/replication/pgoutput/pgoutput.c
M src/bin/pg_basebackup/t/030_pg_recvlogical.pl

Fix two crashes on a concurrently dropped schema

commit   : 275ad2006df5750e0c7c836f9d48ce2743389d7a    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 31 Oct 2026 13:24:50 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 31 Oct 2026 13:24:50 +0200    

Click here for diff

pg_identify_object() looks up the object's schema name without a lock  
on the schema, so a concurrent DROP SCHEMA can make get_namespace_name()  
return NULL, which was then passed to quote_identifier().  Report the  
schema as NULL instead, as is already done for objects that have gone  
away.  
  
Similarly, schema_to_xml() and the related SQL/XML functions look up  
the schema name without a lock on the schema, and a concurrent DROP  
SCHEMA can make get_namespace_name() return NULL, which was then  
dereferenced.  Report that the schema does not exist, or skip it when  
mapping all schemas of the database.  
  
Author: Baji Shaik <baji.pgdev@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CA+fm-RPD0m9QL8W+804SGBBxn5iFz5wn=kncaP9SkM-s4PUANw@mail.gmail.com  
Backpatch-through: 14  

M src/backend/catalog/objectaddress.c
M src/backend/utils/adt/xml.c

Fix error handling in pg_flush_data() and FilePrefetch()

commit   : 9b24be3d94154856e019bb6ebdd8645f38bb2a68    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 31 Oct 2026 11:24:22 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 31 Oct 2026 11:24:22 +0200    

Click here for diff

posix_fadvise() returns an error code directly instead of setting  
errno. However, pg_flush_data() uses %m and errcode_for_file_access()  
to report errors without setting errno, potentially reporting an  
unrelated error. Fix this by assigning the returned error code to  
errno before reporting the error.  
  
FilePrefetch() is documented to return an errno error code on failure,  
but it returns -1 when FileAccess() fails. Fix this by returning errno  
instead.  
  
The first bug one only affects a warning, and the second doesn't have  
any effect because the only existing caller ignores the return value.  
So these are pretty harmless bugs, but let's be tidy.  
  
Author: Chao Li <lic@highgo.com>  
Discussion: https://www.postgresql.org/message-id/F1916C7A-F152-4AF3-87A9-40492D8B3670@gmail.com  
Backpatch-through: 14  

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

Update time zone data files to tzdata release 2026f.

commit   : e383197f2346c654812d86ee25d48e5ec9c6bc4b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 30 Oct 2026 14:35:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 30 Oct 2026 14:35:24 -0400    

Click here for diff

Cuba will not fall back on 2026-11-01; they will stay on DST this  
winter (but apparently plan to revert to normal next year).  
  
Historical corrections for Brazil.  

M src/timezone/data/tzdata.zi

Return INT_MAX or INT_MIN from strtoint() on overflow.

commit   : c2d5c09a6b5cdb056954b80e297599fffd3f6c56    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 30 Oct 2026 11:03:13 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 30 Oct 2026 11:03:13 -0400    

Click here for diff

Previously, strtoint() set errno to ERANGE on overflow but returned  
the result of casting the long value to int. When the value is outside  
the range of int, this produces an implementation-defined result that  
cannot reliably indicate the direction of overflow.  POSIX requires  
strtol() to return exactly LONG_MAX or LONG_MIN on overflow, which  
permits safe sign-testing or range-testing.  By analogy, make  
strtoint() return INT_MAX or INT_MIN on overflow.  
  
Back-patch, since future bug fixes may expect this behavior.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/A33EE17C-D014-4980-B3DD-AC51588A06EC@gmail.com  
Backpatch-through: 14  

M src/common/string.c

Fix more issues with extended statistics on expressions

commit   : 6ffd2f91b7400780f146d349dfa31ef3e603c5bb    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 30 Oct 2026 17:29:58 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 30 Oct 2026 17:29:58 +0900    

Click here for diff

When evaluating expressions (through make_build_data()) and building  
stats data for expressions (through build_expr_data()), both routines  
forgot that examine_expression() could return a NULL result, depending  
on the data generated by the typanalyze function assigned to a type.  
This would crash the server.  
  
This commit includes some tests added to test_custom_types that are able  
to reproduce all these issues with two fancy typanalyze callbacks:  
- False result with a valid stats target, for the expression evaluation.  
- False result with a valid stats target on second call, for the stats  
data build.  
  
No typanalyze callback in core have the idea to do that, and I doubt  
that anything out there has the idea to do that.  If they do, this  
switches the expression stats to fail gracefully instead of crashing,  
based on the combinations that are assumed as supported by the core  
code.  
  
This is a continuation of 3b7a6fa15720.  
  
Reported-by: Yuelin Wang <1217816127@qq.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/19763-14da3f96c02f07e8@postgresql.org  
Backpatch-through: 14  

M src/backend/statistics/extended_stats.c
M src/test/modules/test_custom_types/README
M src/test/modules/test_custom_types/expected/test_custom_types.out
M src/test/modules/test_custom_types/sql/test_custom_types.sql
M src/test/modules/test_custom_types/test_custom_types–1.0.sql
M src/test/modules/test_custom_types/test_custom_types.c

Check all four box corners in SP-GiST quad tree <@ search

commit   : 9e3077ff473e17852ad3690c45d8b86198f52986    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Fri, 30 Oct 2026 12:31:39 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Fri, 30 Oct 2026 12:31:39 +0700    

Click here for diff

When the centroid lies outside the query box, spg_quad_inner_consistent()  
keeps only the quadrants that contain a corner of the box.  It meant to  
test all four corners, but the last step set x back to low.x instead of  
y to low.y, so it tested (low.x, high.y) twice and never (high.x, low.y).  
  
With exact comparisons the missing corner would not matter: a box that  
does not contain the centroid lies on one side of it on at least one  
axis, so (high.x, low.y) shares a quadrant with another corner, but  
getQuadrant() compares with FPeq(), which tiebreaks to the lowest  
numbered quadrant.  
  
When a box edge lies within EPSILON of the centroid, the corner on that  
edge counts as being on the centroid's line, and (high.x, low.y) may be  
the only corner in its quadrant.  That quadrant was then skipped.  Fix  
the missing corner test.  
  
Discussion: https://postgr.es/m/CANWCAZZZpkwrX0kC4Jo6KM27J6dyBdCDir-PbjEYAS06r%3D4-ag%40mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/spgist/spgquadtreeproc.c
M src/test/regress/expected/spgist.out
M src/test/regress/sql/spgist.sql

Remove unwarranted Assert in dependencies_clauselist_selectivity()

commit   : 2a99622bfc01a61e883be573a12d1b52b8f38bcf    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 30 Oct 2026 15:27:09 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 30 Oct 2026 15:27:09 +1300    

Click here for diff

The loop above from where the Assert is removed handles assigning the same  
attnum to any duplicate expressions, so asserting there are no duplicate  
attnums just after purposefully making duplicate ones isn't the correct  
thing to do.  
  
The Assert was added by a4d75c86bf, so backpatch to v14  
  
Author: BHUVAN CHILUKUTI <c.bhuvan@iitg.ac.in>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/PN0P287MB0903563C70D8E5B81912E855A7602@PN0P287MB0903.INDP287.PROD.OUTLOOK.COM  
Backpatch-through: 14  

M src/backend/statistics/dependencies.c

Empty partial_pathlist when unsetting consider_parallel flag

commit   : b0fa692801d1a0f8d8480bc21d57992a41ee2fd5    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 29 Oct 2026 16:22:17 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 29 Oct 2026 16:22:17 +1300    

Click here for diff

It's not valid for a RelOptInfo to have a non-empty partial_pathlist  
when its consider_parallel is true.  In set_append_rel_pathlist() when  
we see the parent rel doesn't have consider_parallel set, we set that  
property to false for the child.  It is possible that the child already  
has some partial paths at that point, so we need to nullify that list as  
well as set the consider_parallel flag to false.  
  
For the reported problem case, the partial paths had been created during  
set_subquery_pathlist().  These not being empty was causing an Assert  
failure on cassert builds.  I think this could only have gone on to  
result in some wasted planner effort in non-cassert builds, but cannot  
confirm if anything worse could have happened.  
  
Bug: #19803  
Reported-by: Gowtham Reddy <gowthamdoma18@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Tested-by: Gowtham Reddy <gowthamdoma18@gmail.com>  
Discussion: https://postgr.es/m/19803-1fcc1df108c54ab6@postgresql.org  
Backpatch-through: 14  

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

Fix stale pg_index flags in the relcache for TOAST indexes

commit   : 9a56e080f164332698ce640966ba6281acd68373    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 28 Oct 2026 14:23:31 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 28 Oct 2026 14:23:31 +0900    

Click here for diff

RelationReloadIndexInfo() re-reads the mutable pg_index fields  
(indisready, indisvalid, indislive, etc.) only for indexes that are  
not system relations.  The TOAST index of a user table lives in  
pg_toast and counts as one, but REINDEX CONCURRENTLY changes these  
fields on it like on any other index.  
  
A backend that had the TOAST indexes open when the invalidation  
arrived kept indisready = false for the new index, and did not insert  
its chunks there.  Once the old index is dropped, reading such a value  
fails with "missing chunk number 0 for toast value N in pg_toast_X".  
The chunks remain in the TOAST table, only the index references were  
gone, so a rebuild of the TOAST index would fix this issue.  
  
This issue is fixed by re-reading the pg_index row for TOAST indexes,  
filling in their relcache fields.  This is the same as for an index on a  
user table.  Previouly, IsSystemRelation() was used, meaning the  
pg_index data was not re-read for a TOAST relation or a relation with a  
pinned OID (created by initdb).  This check is meant for indexes whose  
values never change, so IsCatalogRelation() is fine, implying that only  
indexes created by initdb should be skipped (REINDEX CONCURRENTLY does  
not work on catalogs).  
  
This code is as old as 8ec943856a4, and was only used for CREATE INDEX  
CONCURRENTLY.  5dc92b844e68, that has introduced REINDEX CONCURRENTLY,  
has made possible to reach the problem with TOAST indexes due to these  
getting concurrently built, validated and then swapped.  
  
A test is added, able to reproduce the issue.  It forces an insert  
before a swap, with a second session that maintains the TOAST indexes  
open while the new index becomes ready.  This has been slightly  
simplified by me compared to what the author has sent.  
  
Oversight in 5dc92b844e68.  
  
Reported-by: Saicharanreddy Chinthareddy <saicharh@amazon.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CALj2ACUAv=7wjOV3pRFhQP4WHME_JazuhoCr01i4_F2XA=JKog@mail.gmail.com  
Backpatch-through: 14  

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

Fix deparsing of AT TIME ZONE and similar as FROM-clause functions.

commit   : a44a4f1b6d11e1cb6061e70e112f688bf0a5dc85    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 27 Oct 2026 17:24:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 27 Oct 2026 17:24:02 -0400    

Click here for diff

ruleutils.c's looks_like_function() assumed that all COERCE_SQL_SYNTAX  
cases produce output that looks like a function call (or at least  
like one of the syntaxes the func_expr_windowless production accepts).  
But AT TIME ZONE, AT LOCAL, OVERLAPS and IS xxx NORMALIZED print as  
other sorts of a_expr, so those cases would produce invalid SQL syntax  
when used in a FROM clause.  Extend the logic to detect which specific  
functions are safe or unsafe.  
  
Author: Henson Choi <assam258@gmail.com>  
Reviewed-by: Prashant Chinnam <crprashant@hotmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAAAe_zC68s-DwVX1o7C1HVcRk+Z+RTS6Vw19auZFfz=KaX8tZA@mail.gmail.com  
Backpatch-through: 14  

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

Fix PL/pgSQL's handling of anycompatiblemultirange.

commit   : f291e3336d28f3f82ce0bb6503653ebe84ca7a50    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 14:03:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 14:03:24 -0400    

Click here for diff

When validating a PL/pgSQL function with polymorphic arguments or  
result type, we substitute a plausible concrete type for each  
polymorphic type.  anycompatiblemultirange was missed in both places  
that do this, when multiranges were added.  As a result, CREATE  
FUNCTION with an anycompatiblemultirange argument failed with  
"PL/pgSQL functions cannot accept type anycompatiblemultirange" when  
check_function_bodies is on.  
  
Also, a function returning anycompatiblemultirange was compiled by  
the validator with an int4 result type, and since the function cache  
key doesn't include the result type, a later call in the same session  
with int4range arguments reused that entry and failed trying to cast  
the multirange result to integer.  
  
Map anycompatiblemultirange to int4multirange, as is done for  
anymultirange, to fix both issues.  
  
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAM2+6=VEXCo7tPaxX+9_zN8SJ9DiPp2NTj_sPGN+Tb0wWTBp=w@mail.gmail.com  
Backpatch-through: 14  

M src/pl/plpgsql/src/pl_comp.c

Fix nbtree multi-level page deletion WAL record bug.

commit   : 3651d7c58bc1d6d4f2ed398f96961524c3ba035e    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 26 Oct 2026 09:50:58 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 26 Oct 2026 09:50:58 -0400    

Click here for diff

The second phase of a multi-level nbtree page deletion operation marks a  
"top parent" internal page fully deleted, and updates the to-be-deleted  
subtree's half-dead page.  The leaf page needs to have its top parent  
link updated in preparation for marking the next top parent page (the  
subtree page one level down) fully deleted.  The second phase reads the  
leaf page's sibling links and releases its lock on the leaf, relocking  
it only after it has examined the target page.  This created a small  
window where stale information could be WAL logged.  
  
It was just about possible for a concurrent split of the half-dead  
page's left sibling page to update the half-dead page's left sibling  
link.  _bt_unlink_halfdead_page neglected to re-copy the leaf page's  
sibling links when it reacquired a lock on that page.  The atomic action  
that the WAL record represents doesn't really need to change any of its  
sibling links, so this shouldn't have been a problem.  However, since we  
use REGBUF_WILL_INIT for the half-dead leaf page's buffer, using a stale  
value led to corrupted half-dead leaf pages on standbys.  This bug has  
been shown to cause wal_consistency_checking failures.  
  
To fix, re-read btpo_prev (and btpo_next) from the leaf once it has been  
relocked, before the links are logged.  That way we'll reliably WAL log  
the current leafleftsib.  
  
In practice this bug was very hard to hit.  It required a concurrent  
split at just the right/wrong time, with a multi-level page deletion.  
Even then, the resulting corruption on standbys only persisted until the  
half-dead page was marked fully deleted -- which typically happened  
immediately after the corruption was introduced.  
  
Oversight in commit efada2b8e9, which fixed a race condition in nbtree  
page deletion.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-Wznr2Gw5OQE9KMP_Xd92F9mV=gv7qE9Q6taAvfrKqsE5Qg@mail.gmail.com  
Backpatch-through: 14  

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

Fix partial two-phase files left by crash during checkpoint

commit   : b15c55163b68fc6f590436647fd8a6c9a9eaaf46    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 17:14:57 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 17:14:57 +0900    

Click here for diff

CheckPointTwoPhase() wrote each 2PC file in place, with O_TRUNC.  A  
crash mid-write, or a base backup copying the file at that point left an  
empty or partial file that would make startup fail, most likely on an  
"incorrect size of file" ERROR.  
  
The 2PC files are now written through a temporary file that gets renamed  
at the end, relying on the atomicity of the rename to make startup safe,  
be it after a crash or a base backup.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: David Steele <david@pgbackrest.org>  
Discussion: https://postgr.es/m/CAGRkXqS_On-pLgcv6xjH8mvGhdcPmfWtythW3r8pYKUG+hsiuQ@mail.gmail.com  
Backpatch-through: 14  

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

Set HEAP_XMAX_INVALID for tuples updated by aborted subtransaction

commit   : 278d2a672e65d22d5d191c674cda863623df59d7    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 09:55:01 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 09:55:01 +0900    

Click here for diff

HeapTupleSatisfiesVacuumHorizon() did not set HEAP_XMAX_INVALID on a  
tuple inserted, then updated by a subtransaction that rolled back.  
rewriteheap.c relies on this hint to tell if such tuples should be  
treated as updated and would drop them, causing rewrites to lose some  
tuples.  
  
HeapTupleSatisfiesVacuumHorizon() is updated to set the hint  
HEAP_XMAX_INVALID, so as heap AM is able to redirect such a tuple to its  
correct route, and does not lose it.  
  
This issue impacted both CLUSTER (down to v14) and REPACK [USING] (down  
to v19).  
  
Reported-by: Alperen Keles <alpkeles99@gmail.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Reported-by: Zhijie Hou <houzhijie22@gmail.com>  
Reported-by: Takeshi Ideriha <iderihatakeshi@gmail.com>  
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/19760-8f9a0eba17bc8c92@postgresql.org  
Backpatch-through: 14  

M src/backend/access/heap/heapam_visibility.c
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql

Fix tab completion for concurrent matview refresh

commit   : 12cd839ec86af7031422d2be28ad5c65f3e1610f    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 00:18:48 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 00:18:48 +0100    

Click here for diff

Refreshing materialized views with CONCURRENT cannot use WITH NO DATA,  
but the tab completion supported this combination which is rejected by  
the backend.  
  
Author: Sho Ito <i.sho.0628@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAG7L5+7JOn_tjLjS1PJFTARtEybeJ1-aAAftZZ5L25_QZrjP4w@mail.gmail.com  
Backpatch-through: 14  

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

Fix "variable set but not used" warning with unnamed POSIX semaphores.

commit   : cfd97fa13d15f8138a6046173f6bd6dbd6b3c63e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 25 Oct 2026 18:18:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 25 Oct 2026 18:18:30 -0400    

Click here for diff

Late-model clang is able to notice, when building posix_sema.c with  
USE_NAMED_POSIX_SEMAPHORES not defined, that the static variable  
nextSemKey is set once and read nowhere.  Rearrange the #ifdef's  
to not declare or set it unless USE_NAMED_POSIX_SEMAPHORES.  As a  
small side benefit, we can skip a stat() call altogether if we're  
not going to need it to initialize this variable, which I think  
clarifies the code a fraction.  
  
Per buildfarm member fritillary.  

M src/backend/port/posix_sema.c

Retain locks after marking the partitioned index valid

commit   : 31fa779823c8520a2165f30fcb25880b07342462    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sun, 25 Oct 2026 10:23:46 +0100    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sun, 25 Oct 2026 10:23:46 +0100    

Click here for diff

Commit 8b08f7d4820f (pg11-era), for no apparent reason, made  
validatePartitionedIndex() release the locks on the parent partitioned  
index and table when marking the parent index valid after marking the  
index partition as valid.  This leads to race condition, which  
particularly manifest when restoring from pg_dump in parallel mode, for  
instance causing restore of FKs to fail if the PK that they depend on is  
being concurrently validated.  Fix by retaining those locks until  
transaction commit, as we normally do everywhere in DDL code.  
  
Per buildfarm failures.  
  
Author: Andrey Borodin <x4mmm@yandex-team.ru> (in absentia)  
Diagnosed-by: Kirill Reshke <reshkekirill@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/l4joqljvbou26unhplkdj7m5olxn7rsy2loqlcta44nie5k3bs@zudmva7han7g  

M src/backend/commands/tablecmds.c

Fix GIN index search for root strings in strict jsonpath queries.

commit   : 327c5f0e6c1be3494344386c0d5848c5f4ab9252    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 24 Oct 2026 14:27:12 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 24 Oct 2026 14:27:12 -0400    

Click here for diff

A jsonb_ops index scan for 'strict $ == "a scalar"' missed a matching  
root string.  Root scalars are stored in single-element arrays, so  
gin_extract_jsonb() indexes strings with JGINFLAG_KEY. In strict mode,  
jsonb_ops__extract_nodes() instead searches for JGINFLAG_STR at the  
root.  Leave gin_extract_jsonb() alone (else we'd force people to  
reindex) and make jsonb_ops__extract_nodes() search for JGINFLAG_KEY  
instead.  
  
Author: Rui Zhao <zhaorui126@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAHWVJhHH0k3PxWmS==V1p_PONOMUaSm6LjUV487fwnOqd0jTQw@mail.gmail.com  
Backpatch-through: 14  

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

Accept empty tsquery in binary input.

commit   : 264c441c4fc7a0d85996c422bdd4348eb14d8664    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 22 Oct 2026 13:51:27 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 22 Oct 2026 13:51:27 -0400    

Click here for diff

tsqueryrecv() calls findoprnd() even when the input has no query  
items, so it fails on an empty tsquery, which is legal data.  
This breaks, for example, binary COPY of a table containing an  
empty tsquery.  
  
Skip the operand walk for an empty query, as parse_tsquery() does.  
  
Bug: #19778  
Reported-by: Shay Rojansky <roji@roji.org>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19778-1befc1fba593ab1b@postgresql.org  
Backpatch-through: 14  

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

Fix argument handling in pg_indexam_progress_phasename()

commit   : 5259332a691c5864db81c35a93629f61974a1c34    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 22 Oct 2026 14:39:17 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 22 Oct 2026 14:39:17 +0900    

Click here for diff

The function is declared in pg_proc.dat a bigint as its second input  
argument, but the function's code used PG_GETARG_INT32().  
  
This is an issue in 32-bit architectures in stable branches (up to v18)  
where bigint is still passed by reference, reporting bogus numbers.  
Since 2a600a93c7b (v19 and HEAD), this is less of a problem as Datums  
became 8-byte wide everywhere.  
  
Oversight in ab0dfc961b6.  
  
Author: Markos Fountoulakis <markos@planetscale.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/e791bbb7-af3a-4a91-a5bb-c744e5c3ef54@planetscale.com  
Backpatch-through: 14  

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

psql: Fix tab completion for DROP INDEX CONCURRENTLY

commit   : 9a284cc75671aa0fdaea8f4e31ec8c1847685e59    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 10:49:40 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 10:49:40 +0900    

Click here for diff

psql offered CASCADE after DROP INDEX CONCURRENTLY and an index name,  
even though CASCADE is not supported with CONCURRENTLY. Offer only  
RESTRICT in this case, while retaining both CASCADE and RESTRICT  
for ordinary DROP INDEX.  
  
Backpatch to all supported versions.  
  
Author: Sho Ito <i.sho.0628@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAG7L5+7KXgvJUGCGXzyQrt7UysC9iytaYzx-7YyQTFYXjHVTWQ@mail.gmail.com  
Backpatch-through: 14  

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

Reject currtid2() on unlogged tables during recovery.

commit   : e16d102a4849df97383a853fba5c7dc7194c2dd6    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 11:10:52 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 11:10:52 -0700    

Click here for diff

Commit 1e707d32564 made COPY TO report a proper error for unlogged  
tables during recovery. currtid2() has the same problem: it reads the  
table directly without going through the planner, so on a standby it  
failed with a low-level error for an unlogged table:  
  
ERROR:  could not open file "base/5/16384": No such file or directory  
  
Check for this case and report the same error as SELECT. No test is  
added, as currtid2() is an undocumented internal function.  
  
Backpatch to all supported versions, like commit 1e707d32564.  
  
Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Discussion: https://postgr.es/m/CAD21AoDNa7pL760_23AN_wYPMkWXCt+Kw0_vJAcci4R5DoCQGg@mail.gmail.com  
Backpatch-through: 14  

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

Reject COPY TO of unlogged tables during recovery.

commit   : 599c50d25f74aae02deb9c953ccf7a9bbb3aaa7b    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 10:44:20 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 10:44:20 -0700    

Click here for diff

Unlogged tables have no data on a standby, so reading one there must  
fail. SELECT and COPY (SELECT ...) TO already report a clear error,  
but COPY with a table name read the table directly and failed with a  
low-level error instead:  
  
ERROR:  could not open file "base/5/16384": No such file or directory  
  
Check for this case in COPY TO and report the same error as SELECT. On  
v19 and later, also check each partition when copying from a  
partitioned table, so that an unlogged partition is reported too.  
  
Backpatch to all supported versions, since the low-level error looks  
like data corruption.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/b6d71815-d362-4579-bf07-73eca01aee6d@uni-muenster.de  
Backpatch-through: 14  

M src/backend/commands/copyto.c
M src/test/recovery/t/001_stream_rep.pl

findtimezone: update Windows timezone name list for recent events.

commit   : d92c551e828fc40bee14d83604289eb5ec0a20bc    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 21 Oct 2026 11:52:51 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 21 Oct 2026 11:52:51 -0400    

Click here for diff

The main portion of findtimezone.c's win32_tzmap[] is now directly  
generated from the CLDR project's current windowsZones.xml file (using  
a script available in the discussion thread, but not yet merged into  
our tree).  Windows zone names that are no longer present in CLDR are  
kept, but are moved to a separate list at the end of the array to  
simplify future management.  
  
The important changes that this brings are inclusion of new zone names  
for Canada's upcoming timekeeping changes.  In addition, this tracks a  
few minor changes that CLDR has made in other entries:  
"Central Asia Standard Time" now maps to Asia/Bishkek, and  
"Mountain Standard Time (Mexico)" now maps to America/Mazatlan.  
  
Reported-by: CyberNative AI <ceo@cybernative.ai>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/179219370621.3670768.16110484606338109870@cybernative.ai  
Backpatch-through: 14  

M src/bin/initdb/findtimezone.c

Fix lateral references in sort keys added by createplan.c

commit   : 1fcd7dd80fbd4381b374230cc7168ee7c4bf37ab    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 18:06:00 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 18:06:00 +0900    

Click here for diff

When prepare_sort_from_pathkeys() cannot find a pathkey's expression  
in the input plan's targetlist, it adds a resjunk entry computing an  
EquivalenceClass member's expression.  It copied that expression  
as-is, without replacing lateral references with nestloop Params the  
way build_path_tlist() does for the rest of the targetlist.  
  
This matters when the sort key contains a PlaceHolderVar whose  
expression has a lateral reference, and the sort is placed directly  
atop the plan node that evaluates the PlaceHolderVar.  The targetlist  
already contains the PlaceHolderVar, so the sort key is considered  
computable, but the entry added for it still has the outer relation's  
Var inside the PlaceHolderVar.  If the node is a join, setrefs.c fails  
with "variable not found in subplan target lists".  If it is a scan,  
setrefs.c leaves the Var in place, and the executor fetches it from  
the scan tuple, leading to wrong results.  
  
To fix, pass root to prepare_sort_from_pathkeys() and apply  
replace_nestloop_params() to the expression before adding it to the  
targetlist.  
  
Back-patch to all supported branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49LWNm7_OxuW1V71wLi+Ev3KbfY1bMY36uydNKwSPnbtQ@mail.gmail.com  
Backpatch-through: 14  

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

Fix sorting a child rel by an expression containing a PlaceHolderVar

commit   : 2f975e2e435f79e41d47f1c754151e2262cd3981    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 15:41:20 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 15:41:20 +0900    

Click here for diff

When building sort keys for a child relation, such as the per-child  
sort columns of a MergeAppend over partitionwise child joins,  
prepare_sort_from_pathkeys() may need to compute an EquivalenceClass  
member from the child's targetlist.  find_computable_ec_member()  
accepts a member if all the Vars and quasi-Vars it contains appear in  
that targetlist.  It ignores child members that don't belong to the  
given relids, but it can still choose a parent member.  Usually that  
is harmless, since a parent member's Vars never appear in a child's  
targetlist.  PlaceHolderVars are different: equal() ignores their  
phexpr and phrels, so a parent PlaceHolderVar matches its translated  
copy in the child's targetlist.  As a result, an untranslated parent  
expression could be added to the child plan's targetlist, leading to  
"variable not found in subplan target lists" errors from setrefs.c.  
  
To fix, when relids is given, also ignore parent members that don't  
belong to it.  This changes nothing for a non-child relation, because  
any member computable from its targetlist belongs to it anyway.  When  
relids is NULL, only child members are filtered, as before.  
  
Also update the comments for prepare_sort_from_pathkeys() to reflect  
that 'relids' can identify a non-child relation being sorted, which  
has long been the case.  
  
Back-patch to all supported branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs48bLLEGy6YC+n01w6=YR=28cj_kpoKcAgOHQR7jbtLb6w@mail.gmail.com  
Backpatch-through: 14  

M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/plan/createplan.c
M src/test/regress/expected/partition_join.out
M src/test/regress/sql/partition_join.sql

Fix cross-version upgrade tests for commits 0497318e4 et al.

commit   : 32d4a592c50a037ccb6fa58cc7c9fafa39d9dc88    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 18:49:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 18:49:30 -0400    

Click here for diff

Dumps taken from unpatched versions (pre-v14) will not have the AS  
keyword that ruleutils.c now prints, causing a harmless diff in dump  
output.  Adjust the cross-version upgrade's old dump to make it match.  
  
While I'm here, move the stanza that I hastily put in a non-optimal  
place in commit f8ab6c622.  It's worth fixing because it messed up  
the logical structure of adjust_database_contents, making it  
un-obvious where to put future additions.  
  
Per buildfarm.  

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

In deparsing, parenthesize IS DOCUMENT where it is an operand.

commit   : 823474c041fb3f114fb73e1aef48654190ef2d6b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 14:29:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 14:29:02 -0400    

Click here for diff

isSimpleNode() and related code treated every XmlExpr as  
self-delimiting.  Most of them are, because they look like function  
calls with some extra decoration.  But "x IS DOCUMENT" is not: it is  
a postfix test, like IS NULL.  Printed as the operand of another  
operator, or as the operand of a postfix test, it was therefore not  
parenthesized and could not be parsed back, or was parsed as something  
unintended.  Under-parenthesization occurred even in non-pretty-print  
cases, so that this could break dump/restore workflows.  
  
To fix, treat IS DOCUMENT as neither simple nor function-like, and  
give it the same treatment as other postfix tests.  
  
Also pass the single argument of IS DOCUMENT, not the argument list,  
to get_rule_expr_paren().  This avoids unnecessary parenthesization  
of the argument.  
  
Author: Henson Choi <assam258@gmail.com>  
Reviewed-by: Prashant Chinnam <crprashant@hotmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAAAe_zDuPSkc8ihCctV67Lxbqock+S4wqCHHo8xxZ1t4teXo0g@mail.gmail.com  
Backpatch-through: 14  

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

Fix two issues in deparsing.

commit   : 8113841f0d17082865b38c272eafa95f04c1f95d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 19 Oct 2026 17:51:10 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 19 Oct 2026 17:51:10 -0400    

Click here for diff

If the target relation of UPDATE, DELETE, or MERGE has an alias,  
we printed that "bare" (without AS or forced quoting), the same  
as we do in FROM.  However, if that alias is "set", there's an  
ambiguity with the SET keyword that must follow the relation  
specification.  The parser would choose the wrong interpretation,  
so that the dumped query would fail to reload.  The least surprising  
and most future-proof fix seems to be to always print AS in these  
contexts, as we already did in INSERT.  
  
Also, we were insufficiently careful about parenthesizing the  
left-hand argument of a SubLink (IN, op ANY/ALL, or row comparison),  
so that the printed expression might not parse back with the intended  
meaning depending on operator precedence.  This is only a problem in  
"pretty-print" mode, since non-pretty mode fully parenthesizes every  
operator.  So it isn't a hazard for pg_dump, but it still seems like  
something to fix.  To do so, switch to using get_rule_expr_paren.  
Presently that will add parens in some cases where it wouldn't really  
be necessary, but that's better than the reverse, and it arguably  
is helpful for readability anyway.  
  
Author: Henson Choi <assam258@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAAAe_zDqXin5NeB5atRCbZqUdcMOeyXRqhan+tVp0F30OCURnw@mail.gmail.com  
Discussion: https://postgr.es/m/CAAAe_zCy+D45Qd_br484F+V34y0BVA=hp_7cb=u6HysyMkE3UQ@mail.gmail.com  
Backpatch-through: 14  

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

Fix a few mistakes in partition aggregate tests

commit   : 60614e596ae9c5d222b5fe1efa95817b382722f8    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 20 Oct 2026 10:35:50 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 20 Oct 2026 10:35:50 +1300    

Click here for diff

The pattern seems to be to EXPLAIN the query to ensure we get the  
expected partition-wise aggregate plan, then run the same query to check  
the results are what we expect.  A couple of places didn't use the same  
query between the EXPLAIN and the checking of the results, which  
effectively voided the plan check.  
  
Additionally, a comment claimed array_agg() didn't support partial mode,  
but that was made not true in 16fd03e95.  
  
Author: Matthias van de Meent <boekewurm@gmail.com>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAEze2WgjJUiqV-VZVrWqYz+ETLtd4oKk2gbvBWxf1Fo0is5XVQ@mail.gmail.com  
Backpatch-through: 14  

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

Recompute allocChunkLimit when reusing an AllocSet context

commit   : b1abfa33649ccd2d6dff20be94752097532862bb    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 19 Oct 2026 21:03:10 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 19 Oct 2026 21:03:10 +1300    

Click here for diff

AllocSet contexts with different maxBlockSize values can have the same  
freeListIndex.  When reusing a context from one of the context_freelists,  
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even  
though that ordinarily depends on maxBlockSize.  This could result in  
some allocations being put on an external block when they shouldn't have  
been, resulting in excessive malloc() calls, or if the allocChunkLimit was  
left set higher than it should be, allocations could have resulted in  
memory not being free()'d after pfree() due to the chunk having been put  
on a multi-chunk block (these would still later be cleaned up when the  
context is reset, so no memory leaks).  
  
The repercussions of this are only inefficient use of memory and perhaps  
some performance instability depending on which context happened to be  
top of the freelist when a new AllocSet context was created.  
  
To fix, we move the allocChunkLimit calculation code into a helper  
function and call that to reset the allocChunkLimit when reusing a  
context.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Donghang Lin <donghanglin@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com  
Backpatch-through: 14  

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

Fix use-after-free in jsonb_set_lax for Const NULL new_value

commit   : 42b320abe33907fc8449c63ed6c62ad9fba5bd90    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Mon, 19 Oct 2026 11:29:41 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Mon, 19 Oct 2026 11:29:41 +0700    

Click here for diff

Commit a83586b5543 decided to scribble on the caller's fcinfo but failed  
to take into account that const arguments are written once at expression  
init and assumed never to change.  
  
The use_json_null branch overwrote fcinfo->args[2] with a jsonb null  
built in the per-tuple expression context.  In later rows,  
args[2].isnull is still false and args[2].value still holds that  
pointer, but the per-tuple context has been reset.  Later rows find  
args[2].isnull = false, short-circuit past the NULL handling at the top  
of the function, and jump straight to jsonb_set with the stale pointer  
regardless of their own null_value_treatment argument, which is never  
read.  
  
To fix, call jsonb_set through its own call frame instead.  Arguments 0,  
1 and 3 were already checked non-NULL above, so we can use  
DirectFunctionCall4.  
  
Add regression tests covering use_json_null followed by delete_key and  
return_target, and a multi-row default-treatment query.  
  
Reported-by: Evan Si <evsi@amazon.com>  
Discussion: https://postgr.es/m/CANWCAZY-PS=ev8TiiV1j=NoR2xLopEL8fDq0fyQZahHiP5b+Pw@mail.gmail.com  
Backpatch-through: 14  

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

Don't remove an RTE_RESULT needed by a nested PlaceHolderVar

commit   : dedb20d5fe1558799261524839970742130530d6    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 19 Oct 2026 11:06:07 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 19 Oct 2026 11:06:07 +0900    

Click here for diff

When remove_useless_result_rtes() removes an RTE_RESULT, any  
PlaceHolderVars that were to be evaluated there must be evaluated  
somewhere else.  If the RTE_RESULT is the nullable side of an outer  
join, there is no other place that would preserve the PHVs' nulling  
behavior, so find_dependent_phvs() refuses the removal if any such PHV  
exists anywhere in the query.  If the RTE_RESULT is a child of an  
inner join, its PHVs can instead be evaluated at the join of all its  
sibling rels, unless a sibling needs them before that join is formed.  
find_dependent_phvs_in_jointree() checks for that by looking for such  
PHVs in the join quals and LATERAL RTEs of the siblings.  
  
That misses a PHV that is evaluated at some but not all of the sibling  
rels and contains one of the RTE_RESULT's PHVs.  Such a PHV can appear  
anywhere in the query, such as in the targetlist.  This can happen  
when pulled-up expressions are wrapped in PHVs because of outer joins  
or grouping sets.  Once the RTE_RESULT is removed, the outer PHV needs  
a value that is only available at a join above its own evaluation  
level.  The outer PHV's rel thus becomes laterally dependent on the  
other sibling rels.  If one of those rels laterally references it in  
turn, we end up with a rel that is laterally dependent on itself,  
causing an assertion failure in create_lateral_join_info().  
  
To fix, also search the whole query for PHVs that are evaluated at  
some but not all of the sibling rels, and refuse to remove the  
RTE_RESULT if any of them contains one of its PHVs.  An outer PHV that  
is evaluated at all of the sibling rels is not a problem, since the  
moved PHV is available there, so we don't block removal in that common  
case.  
  
Back-patch to all supported branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4_hLOsW8_SePp_3EmYTLX8Oc4zEZEvypyPRszpoMhDdGQ@mail.gmail.com  
Backpatch-through: 14  

M src/backend/optimizer/prep/prepjointree.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

doc: Correct the description of server behavior after an OOM kill

commit   : 14904052e653df8c9d7504c1c3425f0f5e8df04a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 16 Oct 2026 22:42:40 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 16 Oct 2026 22:42:40 +0900    

Click here for diff

The documentation stated that existing connections would continue to  
function normally after the OOM killer terminated the postmaster.  
In fact, those connections eventually terminate when server processes  
detect the postmaster's death.  
  
Clarify that the OOM killer can terminate either the postmaster or a  
child process. If the postmaster is killed, the server must be restarted.  
If a child process is killed, PostgreSQL typically terminates the  
remaining connections and either recovers automatically or shuts down,  
depending on restart_after_crash.  
  
Backpatch to all supported versions.  
  
Author: Takeshi Ideriha <iderihatakeshi@gmail.com>  
Reviewed-by: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/ce269321-a7f4-48f4-a9ca-a4a4983b9fd6@gmail.com  
Backpatch-through: 14  

M doc/src/sgml/runtime.sgml

Fix bogus Assert in find_var_for_subquery_tle

commit   : a91883995f15b7b433ee11ff27b85ad67934ffe8    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 16 Oct 2026 16:45:03 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 16 Oct 2026 16:45:03 +0900    

Click here for diff

find_var_for_subquery_tle() searches a subquery rel's targetlist for a  
Var referencing a given subquery output column, and asserted that any  
Var it finds there belongs to that rel.  That does not hold for an  
appendrel child.  set_append_rel_size() builds the child's targetlist  
by translating the parent's, and as noted there the result can contain  
arbitrary expressions.  In particular, when a member of a LATERAL UNION  
ALL subquery is pulled up and its output is a lateral reference, the  
translated expression is a Var of the laterally referenced rel.  If the  
child is itself a subquery with sorted paths, convert_subquery_pathkeys()  
would trip the Assert.  
  
In non-assert builds, the function went on to compare such a Var's  
varattno with the subquery column's resno, and so could match a Var of  
an unrelated rel.  
  
To fix, ignore Vars that do not belong to the subquery rel, the same  
way set_rel_width() already does.  Also correct the adjacent comment,  
which claimed that the only non-Var entries are placeholders.  
  
Back-patch to all supported branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs48fFiPi7Q5yJCoM_nAs47zd5XgvPHd9nZyM_ewq+k_jpQ@mail.gmail.com  
Backpatch-through: 14  

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

Update .abi-compliance-history for changes in reorderbuffer.h

commit   : 46ef0bdd0b172f34d4daa21c1eac718510a08dcf    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 15 Oct 2026 16:38:13 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 15 Oct 2026 16:38:13 +0200    

Click here for diff

The ABI changes happened in this commit:  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Branch: master [beff3cd00] 2026-10-14 19:42:04 +0200  
Branch: REL_19_STABLE [963ff022f] 2026-10-14 19:42:04 +0200  
Branch: REL_18_STABLE [5eae2800a] 2026-10-14 19:42:04 +0200  
Branch: REL_17_STABLE [624bd2b1f] 2026-10-14 19:42:04 +0200  
Branch: REL_16_STABLE [ff5ba5f19] 2026-10-14 19:42:04 +0200  
Branch: REL_15_STABLE [0a6dc4fe1] 2026-10-14 19:42:04 +0200  
Branch: REL_14_STABLE [83be64488] 2026-10-14 19:42:04 +0200  
  
    Reorderbuffer: handle catalog-change-bearing aborted subxacts better  
  
However, I'm now backpatching only between 14 and 17.  Later branches  
have further ABI changes and their compliance files will be updated  
separately.  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/as_Etcja0IsaMxlt@alvherre.pgsql  

M .abi-compliance-history

Fix CreateThread() failure checks

commit   : b1c44848ce36d892948b9b014e4c1e49f77dc82b    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 15 Oct 2026 12:04:27 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 15 Oct 2026 12:04:27 +0300    

Click here for diff

CreateThread returns NULL on failure, not INVALID_HANDLE_VALUE.  In  
setitimer(), a failed thread creation would silently disable all  
timer-based timeouts.  
  
Author: Sehrope Sarkuni <sehrope@jackdb.com>  
Discussion: https://www.postgresql.org/message-id/CAH7T-apWWfEt+V8uLU7KXv7CMM9LoqJ1Zo2LdWmXMz=u-Ek9=w@mail.gmail.com  
Backpatch-through: 14  

M src/backend/port/win32/timer.c
M src/bin/pg_test_fsync/pg_test_fsync.c

Fix checks for aborted updating transaction in multixids

commit   : 623cdfa6493d11d47a0d2d31acda16f7fbd0af54    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 15 Oct 2026 11:23:06 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 15 Oct 2026 11:23:06 +0300    

Click here for diff

As mentioned in the comments in TransactionIdDidAbort() and in  
heapam_visibility.c, the usual procedure for checking whether a  
transaction aborted is to first call TransactionIdIsInProgress(), and  
then !TransactionIdDidCommit().  A couple places didn't get the memo,  
and used TransactionIdDidAbort() incorrectly.  
  
In DoesMultiXactIdConflict(), the consequence was that if a  
conflicting transaction was just aborting, and had already marked the  
transaction as aborted in pg_xact, but had not yet removed itself from  
ProcArray, the function would return false meaning that it does not  
conflict, even though it was still considered as running by  
TransactionIdIsInProgress().  That could cause trouble later.  One  
known consequence is that if you then went ahead with updating the row  
again and called MultiXactIdExpand(), MultiXactIdExpand() would see  
both the old aborting transaction and the new updater as still  
running, and throw an ERROR: new multixact has more than one updating  
member.  The multixact-aborted-updater.spec included in this commit  
exercises that scenario.  
  
Another place that got this wrong was in heap_update(), where we check  
if the updating transaction that was part of a multixid committed or  
aborted.  Because it used TransactionIdDidAbort(), if the updating  
transaction crashed, it was considered as committed and heap_update()  
incorrectly returned TM_Updated indicating a conflict, even though the  
row could be updated.  This would only happen if the multixid as whole  
was still considered running, i.e. if the tuple was still locked by  
other transactions while the updating transaction crashed.  That can  
happen if the locker is a prepared transaction.  The included  
060_multixact_crashed_updater.pl test tests that scenario.  
  
Author: Chee Wooson <wuqi@vastdata.com.cn>  
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>  
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn  
Backpatch-through: 14  

M src/backend/access/heap/heapam.c
A src/test/recovery/t/060_multixact_crashed_updater.pl

Fix hash bucket split buffer pin leak.

commit   : 3eaa726e7be562bc6231e01bd8620909df4fb6b7    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 14 Oct 2026 14:26:04 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 14 Oct 2026 14:26:04 -0400    

Click here for diff

The process by which a hash index inserter finishes an incomplete bucket  
split involves a walk of the new bucket (the bucket "being populated")  
to collect the TIDs that the interrupted split already moved.  This  
process keeps a pin on the new bucket's primary page, and then takes  
conditional cleanup locks on both buckets.  When either lock could not  
be acquired, we gave up, but neglected to release the new bucket's pin.  
  
To fix, release the buffer pin on failure.  
  
Oversight in commit 6d46f4783, which improved hash index bucket split  
behavior by switching it from using a heavyweight lock to using these  
cleanup locks.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAH2-Wz=b9sSBv15HsgZAuazjJu8-YRGHOpLjvp+dJgEDaBx0Ng@mail.gmail.com  
Backpatch-through: 14  

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

Doc: improve documentation of the JSON object aggregates.

commit   : 4776a9ac0a7e29bed078f63d4f8576bdf6651f4c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 14:00:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 14:00:30 -0400    

Click here for diff

Say which value wins for a repeated key, and how skipped null values  
interact with that and with the unique check.  Also point out that  
duplicate keys behave differently for json and jsonb cases.  (I still  
think that's a bug, but at least now it's documented.)  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqTCfSu=aEUCvKDTGroEWOcyz3MCv4Xi8x1PZ1T1rEmG=Q@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/func.sgml

Reorderbuffer: handle catalog-change-bearing aborted subxacts better

commit   : 83be644888b860bf74fa88cc18104f58c278d870    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 14 Oct 2026 19:42:04 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 14 Oct 2026 19:42:04 +0200    

Click here for diff

When constructing a historic snapshot for logical decoding,  
reorderbuffer needs to keep track of movement of tuples in catalog  
tables.  For the most part this works correctly, except that when a  
subtransaction that wrote a catalog tuple aborts, we failed to "forget"  
about that change.  There's no known reports of anything actually  
breaking except assertion failures, but it is likely possible to  
construct cases where historical snapshots produce bogus visibility  
answers, potentially causing incorrect decoding output.  
  
To fix, have the decode of a subtransaction abort go over the TUPLECID  
list that has been accumulated on the ReorderBufferTXN for its topmost  
parent transaction, and remove all the entries that were marked as  
originating from the aborted subtransaction or its children.  There are  
some little details in which various devils lie, which the added code  
comments explain (we hope).  
  
Add a couple of isolation test cases that trip the assertions with the  
original coding.  They're not ideal test design, because they pass in  
non-assert builds without the fix.  But we'd rather have the fix be  
verified in that limited scenario than nowhere at all, and they are  
cheap enough.  
  
This bug is sibling to the one fixed in commit 8c67d29fd51c and, like  
that one, it goes all the way back to the introduction of  
reorderbuffers, so backpatch to all live branches.  
  
While reviewing this, I (Álvaro) was bothered by the snapmgr.c  
tuplecid_data file-scoped variable, as it's easily confused with a  
function parameter used widely in reorderbuffer.c.  In branches 19 and  
master, rename that to avoid confusion.  
  
Reported-by: Arseny Sher <a.sher@postgrespro.ru>  
Reported-by: Mark Dilger <mark.dilger@enterprisedb.com>  
Reported-by: Alexander Kozhemyakin <a.kozhemyakin@postgrespro.ru>  
Author: Bingshuai Li <lucian1412@outlook.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Author: Zhijie Hou <houzhijie22@gmail.com>  
Backpatch-through: 14  
Bug: #19555  
Discussion: https://postgr.es/m/87r2c8xocq.fsf@ars-thinkpad  
Discussion: https://postgr.es/m/CAHgHdKu5e3XY5e90Tuaxq_R4WrKxSV734Q%2BLwo5y39Omp2A-Gg@mail.gmail.com  
Discussion: https://postgr.es/m/19555-3c700f40a13045cd@postgresql.org  

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

Plug holes in SP-GiST quad tree getQuadrant()

commit   : 0e95444395db94610eb09aec92b6ce89202b8805    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Wed, 14 Oct 2026 18:19:39 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Wed, 14 Oct 2026 18:19:39 +0700    

Click here for diff

getQuadrant() places a point on each axis with the fuzzy comparisons  
FPlt(), FPgt() and FPeq(), which do not cover every case.  FPeq()  
compares the rounded difference against EPSILON, while FPlt() and FPgt()  
round the sum of one operand and EPSILON.  When the centroid plus  
EPSILON rounds up, a point equal to that rounded sum is more than  
EPSILON above the centroid, so FPeq() is false. FPgt() compares it with  
the same rounded sum, so it is false too, and FPlt() is false because  
the point is above the centroid.  The same gap exists below the  
centroid, when the centroid minus EPSILON rounds down.  No quadrant  
matches, and index builds, inserts and searches fail with  
"getQuadrant: impossible case".  
  
To fix, fall back to deciding each axis separately: Use fuzzy tests  
first and then tiebreak with exact comparisons. That gives every finite  
value a quadrant (NaN coordinates are still an error). Points that  
matched a fuzzy test before are routed as before, so existing indexes  
remain valid.  
  
Bug: #19597  
Reported-by: Michael Malis <malis@pgrust.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Discussion: https://postgr.es/m/19597-39c532e61d78dff6@postgresql.org  
Backpatch-through: 14  

M src/backend/access/spgist/spgquadtreeproc.c
M src/test/regress/expected/spgist.out
M src/test/regress/sql/spgist.sql

Accumulate Memoize parallel worker stats across rescans

commit   : 3d6e246264b941a811716d106fc9247368769466    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 14 Oct 2026 22:09:32 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 14 Oct 2026 22:09:32 +1300    

Click here for diff

When a Gather or Gather Merge node is rescanned, it starts a new set of  
workers, which write their Memoize stats into the same shared memory  
slots as the previous worker.  ExecEndMemoize() used memcpy() for this,  
so EXPLAIN ANALYZE showed only the stats for the final scan.  
  
Here we adjust ExecEndMemoize() to accumulate the counters so that we  
gather up the totals over all rescans.  
  
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAHza6qeA-4vB355co-2yAxDMRTpEneY0rg9CD2zMLYscYvv2UA@mail.gmail.com  
Backpatch-through: 14  

M src/backend/executor/nodeMemoize.c

Disallow joins whose lateral references can never be satisfied

commit   : 60b2a2f5264d9cb2e34b725453e3f8315dba5054    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 14:34:27 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 14:34:27 +0900    

Click here for diff

If a proposed join has lateral references to rels outside it,  
join_is_legal() checks that those rels can still be joined to from  
outside.  To do that it collects the rels that must end up on the  
inner side of an outer join with the proposed join, directly or  
indirectly, and rejects the join if any of its lateral references  
point to one of them.  
  
That search followed only outer joins, from min_lefthand to  
min_righthand.  It failed to notice that a rel that laterally  
references the proposed join, or any rel found by the search, cannot  
supply a parameter to the proposed join either, and that the same  
holds for rels on the inner side of an outer join with such a rel.  As  
a result, we could approve a join whose lateral references could never  
be satisfied.  
  
Such a join can never appear in a complete plan.  Worse, as the  
existing comment warns, its apparent legality could mislead the  
clauseless-join heuristics into thinking that some other join rel need  
not be formed.  In particular, have_join_order_restriction() would not  
force a clauseless outer join if one of its input rels appeared to  
have a legal clause join elsewhere, and if that outer join was  
required, we would fail with "failed to build any N-way joins".  
  
To fix, also include in the search any input rel of the current join  
search that laterally references a rel already found.  The input rels  
are taken from root->initial_rels rather than from the query's base  
rels, because an input can be the joinrel of a sub-joinlist, as  
happens for a full join or when from_collapse_limit or  
join_collapse_limit prevents flattening.  Such a joinrel is joined as  
a unit, so it has to be included as a whole.  
  
Back-patch to all supported branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4_p6iWbsjNcYpd6-6mWFnog3UJ2fZKrxWAQTsyNoyeQTw@mail.gmail.com  
Backpatch-through: 14  

M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/path/joinrels.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Fix potential use-after-frees in WAL sender

commit   : 0e2260ab10f68a681624157365dba58c76578958    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 12:05:18 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 12:05:18 +0900    

Click here for diff

A WAL sender tracks its WAL reader and logical decoding context as two  
static variables, which were left set after being freed for a  
START_REPLICATION command.  The WAL reader is used for in a physical  
replication command, both the WAL reader and the logical decoding  
context are used for a logical replication command.  
  
Both variables are now cleared once their contents are released at the  
end of each replication command, to keep the release of the resources  
and the maintenance of the pointers close to each other.  Some more  
cleanup is done by WalSndErrorCleanup(), as well, once the WAL reader is  
clear.  
  
The assertion added by 879ad9f90e83 is moved before the execution of a  
replication command, checking now that both the WAL reader and the  
logical decoding context are never set before the execution of a new  
command.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAJTYsWW+hdmmVt_A4hvGv2_5RWK8-kaOf5ncT65=5i_hyD=BHg@mail.gmail.com  
Backpatch-through: 14  

M src/backend/replication/walsender.c

Add missing FreeDir() in CheckTablespaceDirectory()

commit   : cde0f9c6a2a54f965b2405ad06e857b2cbbe47de    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 11:12:39 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 11:12:39 +0900    

Click here for diff

CheckTablespaceDirectory() did not close the directory opened with  
AllocateDir(), leaving its resources held during subsequent recovery,  
potentially indefinitely on a standby.  Add the missing FreeDir() call.  
  
Backpatch to all supported versions.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/66A784B7-55C1-4613-8C24-B4C2A8D75414@gmail.com  
Backpatch-through: 14  

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

Release memory allocated by ndistinct_for_combination()

commit   : 205f40f5b27392b54a7ffba3059522ccc2a5d269    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 10:16:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 10:16:26 +0900    

Click here for diff

Building extended statistics of type "ndistinct" calls  
ndistinct_for_combination() once for every combination of columns.  Each  
call allocates arrays for the whole sample and never frees them, with  
memory accumulating until the whole statistics object is built.  The  
sample has 300 multiplied by target rows.  With large statistics targets  
(default_statistics_target up to 10k), this can add up to gigabytes  
worth of memory, useless once a combination is computed.  
  
ndistinct_for_combination() is now called in a dedicated memory context,  
reset after each combination is computed.  We only need the estimated  
number of distinct values, so there is no need to copy anything out of  
the memory context.  
  
Similar fixes have been done in 83772cc78e03 and ad8a166ca868 for other  
areas of the extended stats computations.  
  
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>  
Discussion: https://postgr.es/m/20d6689e-f490-4ca7-a92f-e92f691ba07e@tantorlabs.com  
Backpatch-through: 14  

M src/backend/statistics/mvdistinct.c

Fix two errors in extraction of GIN indexquals from jsonpath queries.

commit   : d987ad61d3b1cc3881d85352761607f496e45751    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 13 Oct 2026 16:33:35 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 13 Oct 2026 16:33:35 -0400    

Click here for diff

extract_jsp_bool_expr applied De Morgan's laws incorrectly when  
considering an AND operator underneath a NOT.  If one AND input  
was implementable as a GIN indexqual while the other was not,  
we derived an incomplete indexqual, leading to some rows not  
being returned that should be.  
  
extract_jsp_bool_expr also failed to check for methods being  
applied to literals, so that for example '$.x == "42".double()'  
was treated as '$.x == "42"' not '$.x == 42'.  The indexqual  
thus selected the wrong rows, all of which would fail qual  
recheck, leading to no rows being returned.  
  
While we're here, improve the comments a trifle.  
  
Reported-by: Chinmay Kanchi <cgkanchi@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAJqPDh9Cm=x8eYZ1Jf=_avd2WEqc=0t_f7_SO4igo-CKPi25_Q@mail.gmail.com  
Discussion: https://postgr.es/m/CAJqPDh-tu5KY66KU8cvAEg3DQrZLzDZwjkLLa42zD+_Xm1WJAg@mail.gmail.com  
Backpatch-through: 14  

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

Fix hash index scans that start during a bucket split.

commit   : 22be34ac1a094be3b239600c31ae4f27026217a6    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 10 Oct 2026 10:26:18 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 10 Oct 2026 10:26:18 -0400    

Click here for diff

A hash index scan whose target bucket is still being populated by a  
split must read both buckets of the split: forward scans read the bucket  
being populated (skipping the tuples that the split copied there) and  
then the bucket being split, and backward scans read them in the  
opposite order.  _hash_readnext and _hash_readprev make the transition  
from the first bucket to the second, but _hash_next did not: on reaching  
the end of the first bucket, it ended the scan, so every matching tuple  
in the second bucket was overlooked.  
  
To fix, teach _hash_next to make the same transition, using helper  
functions shared with _hash_readnext and _hash_readprev.  
  
_hash_next only missed the transition when the last page that it read in  
the first bucket had a match (otherwise _hash_readpage's loop made the  
required transition).  Getting wrong answers also needed a matching  
tuple to be inserted into the bucket being populated _after_ the split  
began.  Forward scans then lost the older tuples in the bucket being  
split.  An incomplete split would keep the buckets in this state until  
an inserter finished the split at some indeterminate later time.  Note  
that wrong answers didn't require an incomplete split.  
  
Although this fix treats the bug as the omission of a required step in  
_hash_next, the real problem is the way that page stepping works in  
general.  The logic for stepping to the next page appears both in  
high-level routines like _hash_next and in low-level routines like  
_hash_readnext and _hash_readprev.  If anything, _hash_next already knew  
too much about page stepping (cf. nbtree's _bt_next function).  All of  
the logic around stepping really belongs in one routine, modeled on  
nbtree's _bt_steppage function, but that approach is much too invasive  
for a backpatched fix.  
  
Claude Code found this problem.  The committed test case is a simplified  
version of the one that it wrote to demonstrate this bug.  
  
Oversight in commit 7c75ef57, which introduced page-at-a-time processing  
of hash index scans.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Vignesh C <vignesh21@gmail.com>  
Discussion: https://postgr.es/m/CAH2-Wz=4CJK9ysZzbzxBGGTkgAg9ib8cJyCx=9q_d1r8tf0ang@mail.gmail.com  
Backpatch-through: 14  

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

Remove faulty nbtree page deletion assertion.

commit   : 76a6c5da407e461b337ff48dbdbefd144f392187    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 8 Oct 2026 14:21:09 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 8 Oct 2026 14:21:09 -0400    

Click here for diff

_bt_pagedel only builds a search stack when it needs one to locate the  
downlink of the page that it's about to mark half-dead (and when it  
doesn't already have one from an earlier sibling deletion that took  
place during the same _bt_pagedel call).  _bt_pagedel won't build a  
search stack for the page its caller passes whenever it happens to be  
one that an earlier interrupted VACUUM left half-dead (since there is no  
downlink to remove).  We nevertheless asserted that page deletion could  
only build a search stack for that initial caller-passed page.  
  
To fix, remove the assertion, which spuriously failed when a half-dead  
leaf page was passed by the _bt_pagedel caller and its right sibling  
page was empty/had to be considered for deletion during the same call  
(necessitating building a search stack to locate the right sibling's  
downlink).  
  
Oversight in commit cd8c73a38, which refactored nbtree page deletion's  
INCOMPLETE_SPLIT check.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Iliia Khaprov <i.khaprov@gmail.com>  
Discussion: https://postgr.es/m/CAFO+O_p5So4MXwQ1VEcL9+9vGgODu11TTWcYq9RDbxnira8o2w@mail.gmail.com  
Backpatch-through: 14  

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

Don't attempt to upgrade bpchar indexes from versions before 14.

commit   : 415cd3bfb4c08eae7b6faf9fa1c83eed2ab6f43f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 6 Oct 2026 21:16:52 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 6 Oct 2026 21:16:52 -0400    

Click here for diff

As of a32b8dc98 and friends, amcheck will complain about bpchar  
indexes that claim to allow de-duplication.  This causes our  
cross-version-upgrade tests to fail when upgrading from a version  
that lacks those commits, since there are some such indexes in the  
core regression tests.  Drop such indexes from the upgrade source  
database.  (oidvector indexes would be problematic too, but  
there aren't any user-defined indexes on oidvector in our tests.)  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAH2-Wzk-oO3HjLaByo8Vpse6Tpha1mqAW8DFShh-kS-Wo59ugA@mail.gmail.com  
Backpatch-through: 14  

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

Rescind unsafe deduplication support.

commit   : 4697138049a18feac4e961e0f75cd6c828f9c04f    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 6 Oct 2026 18:21:27 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 6 Oct 2026 18:21:27 -0400    

Click here for diff

bpchar equality ignores trailing spaces, so equal values in a column  
with no length specifier can have different images.  Similarly,  
oidvector equality intentionally pays no attention to the array lower  
bound field.  We nevertheless allowed nbtree deduplication to be used  
with indexes built with bpchar_ops, bpchar_pattern_ops, or  
oidvector_ops.  A posting list split could therefore place a TID in an  
index tuple whose key was equal to, but not bytewise identical to, the  
corresponding table value.  This allowed index-only scans to return  
subtly wrong results.  
  
To fix, drop support function 4 from the affected opclasses (we can't  
change catalog contents on branches 14 through 18, so we just disable  
deduplication by adding hard-coding to the relevant support functions).  
Deliberately leave the oidvector opclass alone on branches 14 through  
18, though.  Disallowing oidvector deduplication on these branches would  
make pg_amcheck report that pg_proc_proname_args_nsp_index has a corrupt  
metapage, needlessly alarming users.  
  
System catalog oidvector values always have a lower bound of 0, so the  
issue can't cause harm there; a user can only hit it by indexing an  
oidvector column that stores the output of a function like trim_array().  
It seems very unlikely that any user would ever do that.  
  
Users should REINDEX any B-Tree index on a bpchar column.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Co-authored-by: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Ke <kehan5800@gmail.com>  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Bug: #19749  
Discussion: https://postgr.es/m/19749-d46adf7c7d910b07@postgresql.org  
Discussion: https://postgr.es/m/CAGRkXqQQ311Lg=62x5UdZtPuRFgpT6XpPMw4X9E3tgbTu162Mw@mail.gmail.com  
Backpatch-through: 14  

M contrib/amcheck/verify_nbtree.c
M doc/src/sgml/btree.sgml
M src/backend/utils/adt/datum.c
M src/backend/utils/adt/varlena.c
M src/test/regress/expected/btree_index.out
M src/test/regress/sql/btree_index.sql

Doc: correct overambitious precision claim for contrib/seg.

commit   : 6236f8f398e6755eca448acbe56c955b991ded5f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 6 Oct 2026 15:07:01 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 6 Oct 2026 15:07:01 -0400    

Click here for diff

seg.sgml claims that a seg can store 7 significant digits, but this  
is nonsense.  The underlying float4 data type is not (quite) that  
precise, and seg_out() intentionally rounds off to at most FLT_DIG  
decimal places.  With IEEE float arithmetic, FLT_DIG will be defined  
as 6, or at least that's the case on all platforms I know of.  
  
AFAICT this thinko goes clear back to the introduction of seg  
(commit a3694b420), but it wasn't questioned until now.  
  
Bug: #19744  
Reported-by: Ke <kehan5800@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19744-8c700582bbb1d075@postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/seg.sgml

Fix COPY FROM ... WHERE for negated operators.

commit   : c596e189dfbef330dae624abdcaf1bcdd82adadf    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 6 Oct 2026 09:04:32 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 6 Oct 2026 09:04:32 -0500    

Click here for diff

COPY FROM runs its WHERE clause through eval_const_expressions(),  
which among other things replaces NOT above an operator with the  
operator's negator, if it has one (e.g., NOT (a > 0) becomes  
a <= 0).  The node it builds for the negator has no opfuncid, and  
since COPY FROM never calls fix_opfuncids() on the clause, nothing  
fills it in before the executor needs it.  So  
  
	COPY tab FROM stdin WHERE NOT (a > 0)  
  
fails with "cache lookup failed for function 0".  
  
To fix, call fix_opfuncids() on the clause, as the relcache does  
for index predicates.  
  
Oversight in commit 31f3817402.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan  
Backpatch-through: 14  

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

Flatten join alias Vars before rechecking subquery pullup safety

commit   : 3b65ff900c6f7c209b7811fec4c1c58047cd2707    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 14:44:39 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 14:44:39 +0900    

Click here for diff

pull_up_simple_subquery() rechecks is_simple_subquery() after pulling  
up the subquery's own subqueries, but it flattened join alias Vars in  
the subquery's targetlist only after that, and never in its quals.  A  
join alias Var within the subquery, such as a whole-row Var of a join,  
can expand to an expression containing lateral references to the outer  
query once the join's inputs have been pulled up, and until it is  
flattened is_simple_subquery() cannot see them.  We could thus pull up  
a LATERAL subquery whose targetlist or quals reference rels outside  
the lowest outer join above it.  This leads to assertion failures in  
distribute_qual_to_rels() or "wrong phnullingrels" errors, and in some  
cases to wrong query results, where rows that should have been  
preserved by an outer join above the subquery are discarded.  
  
To fix, flatten join alias Vars in the targetlist, and in the jointree  
quals if the subquery is LATERAL, before the recheck.  If the recheck  
fails, the flattened copy is discarded along with the rest of the  
modified subquery, so no harm is done.  
  
Back-patch to all supported branches, as this can lead to wrong query  
results.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs48GFZ=3Bjc1ug9JRsB0Qupg+CGcb9js5vmTM6kY2OGWOg@mail.gmail.com  
Backpatch-through: 14  

M src/backend/optimizer/prep/prepjointree.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Doc: remove stray right brace in TRANSFORM option syntax summaries.

commit   : 7358c30d38b5ce6fd01b728364960ba4cb3819b7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 20:40:03 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 20:40:03 -0400    

Click here for diff

Author: Lele Gaifax <lele@metapensiero.it>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/87bj98oaen.fsf@metapensiero.it  
Backpatch-through: 14  

M doc/src/sgml/ref/create_function.sgml
M doc/src/sgml/ref/create_procedure.sgml

Fix pg_blocking_pids() for relation extension locks.

commit   : 36e021cb1bb7b2e582b18467b1adca23bcf9609e    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 5 Oct 2026 14:52:18 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 5 Oct 2026 14:52:18 -0500    

Click here for diff

pg_blocking_pids() assumes that members of the same lock group  
never block each other, but that hasn't been true for relation  
extension locks since v13.  This commit teaches the function to  
report lock group members as blockers for relation extension locks.  
Since parallel workers are reported with their leader's PID, the  
result may now include the blocked session's own PID.  
  
Oversight in commit 85f6b49c2c.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/apTpV8h%2BCYHf%2B1PJ%40bdtpg  
Backpatch-through: 14  

M doc/src/sgml/func.sgml
M src/backend/utils/adt/lockfuncs.c

Don't sleep with vacuum_delay_point() while holding locks

commit   : 4a7778ef8751c3307584ca2a30d7e3f0fb3b3662    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 5 Oct 2026 13:12:33 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 5 Oct 2026 13:12:33 +0300    

Click here for diff

It's a bad idea to sleep while holding locks, because you might block  
another process that wants to acquire the same lock.  Furthermore,  
it's not safe to call ProcessConfigFile() in a critical section or  
while holding locks.  So avoid calling vacuum_delay_point() while  
holding locks, and also make vacuum_delay_point() return quickly  
without sleeping if it's called while interrupts cannot be processed.  
  
To find the vacuum_delay_point() calls that were made while holding  
locks, I added "Assert(INTERRUPTS_CAN_BE_PROCESSED())" in  
vacuum_delay_point() and ran the regression tests.  I didn't include  
that Assert in this commit, because there might be more places that do  
that that are not covered by the regression tests, including  
extensions.  
  
In ginInsertCleanup(), there was already another vacuum_delay_point()  
call later in the loop, while not holding any locks, so just remove  
the other call that was made while holding the lock.  
  
In hashbucketcleanup(), move the vacuum_delay_point() call up the  
stack to its caller.  The call in hashbucketcleanup() was not able to  
handle interrupts because it held a lock, and because there were no  
vacuum_delay_point() or CHECK_FOR_INTERRUPTS() calls in the caller's  
loop, the whole hash index vacuuming phase was uninterruptible by  
pending shutdown or query cancel.  Now it can be interrupted between  
buckets.  Unfortunately, hashbucketcleanup() has to process all the  
bucket's pages in one go without pausing; fixing that would require  
changing how hashbucketcleanup()'s lock chaining works.  
  
In acquire_sample_rows(), move the vacuum_delay_point() call in the  
loop to between pages, to a time where we're not holding the buffer  
lock.  
  
In master, also remove a misleading CHECK_FOR_INTERRUPTS() call from  
pgstat_write_statsfile().  It was a no-op because we're always holding  
a lock on the current dshash partition at that point.  A call that  
does nothing is harmless, but it makes you think that the loop is  
interruptible when in reality it's not.  
  
Author: Kevin Rocker <me@kevinrocker.com>  
Author: Andrey Borodin <amborodin@acm.org>  
Author: Mostafa <mostafa.nabil.nafie@gmail.com>  
Reported-by: Greg Burd <greg@burd.me>  
Reported-by: Sergei Kornilov <sk@zsrv.org>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>  
Tested-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/19628-c2b17d358181a1ea@postgresql.org  
Discussion: https://postgr.es/m/492c6247-43d3-477b-8981-fb0c56767b38%40app.fastmail.com  
Backpatch-through: 14  

M src/backend/access/gin/ginfast.c
M src/backend/access/hash/hash.c
M src/backend/commands/vacuum.c

Fix join alias expansion in lateral TABLESAMPLE clauses

commit   : df1196369080a8ec42e5820d7653039a01061ec8    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sun, 4 Oct 2026 16:07:10 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sun, 4 Oct 2026 16:07:10 +0900    

Click here for diff

preprocess_expression skips flatten_join_alias_vars for TABLESAMPLE  
clauses, on the assumption that they cannot contain Vars of the  
current query level.  That's not true once a LATERAL subquery  
containing a sampled relation has been pulled up: the relation's  
TABLESAMPLE clause then becomes a lateral reference of this level, and  
if it referred to a join alias Var, that Var is left unexpanded.  
extract_lateral_references then pulls the join alias Var out as a  
lateral reference and fails with "no relation entry for relid N".  
  
To fix, treat such clauses like lateral function and VALUES RTEs:  
introduce EXPRKIND_TABLESAMPLE_LATERAL, used for the TABLESAMPLE  
clause of a lateral relation RTE, and keep skipping the alias  
expansion only for the non-lateral kind.  
  
Back-patch to all supported branches, as this dates back to the  
introduction of TABLESAMPLE.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4834TwOtyyycyvja3MuOBkfpXy3dFAL0zt_vcM1KtqV-Q@mail.gmail.com  
Backpatch-through: 14  

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

commit   : 10717fe150a06791b50a357912d90249c0bf40a6    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sun, 4 Oct 2026 12:06:24 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sun, 4 Oct 2026 12:06:24 +0900    

Click here for diff

If a subquery has been flattened into its parent, the joinaliasvars  
entries of a join above it can be arbitrary expressions rather than  
plain Vars, so expanding a reference to such a join alias may insert a  
SubLink into a lower-level subquery.  flatten_join_alias_vars_mutator  
detects that and sets the subquery's hasSubLinks flag, but only in the  
single-column code path; the whole-row path just asserted in a comment  
that its recursive call would handle this, which is true only when the  
alias entry is itself a Var referencing another join.  
  
Hence a whole-row reference to such a join appearing in a sub-select  
left that sub-select's hasSubLinks false, so preprocess_expression  
skipped SS_process_sublinks for it, and the unprocessed SubLink  
reached code that is not prepared for one: this produced "cannot  
handle unplanned sub-select" from cost_qual_eval, an assertion failure  
in preprocess_aggrefs, or "unrecognized node type" at execution,  
depending on where in the sub-select the SubLink ended up.  
  
To fix, make the same check in the whole-row expansion path.  
  
Back-patch to all supported branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49PgeNFhQTZ2gSzwatF0_LXyegMPGt++jSfxUN7NZuQ5Q@mail.gmail.com  
Backpatch-through: 14  

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

Fix lcov duplicate directory specification in non-VPATH builds.

commit   : 9df103328f19b292a0217162ec396bc07157b8b9    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 3 Oct 2026 14:44:39 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 3 Oct 2026 14:44:39 -0400    

Click here for diff

In an in-tree build, "make coverage-html" invoked lcov with two  
"-d ." options, because $(srcdir) is just ".".  With lcov 2.0  
(and perhaps earlier versions?) that results in scanning every  
foo.gcda file twice and producing counts twice what they should  
be.  With later lcov versions (at least 2.3), it results in  
"duplicate file" errors.  
  
In VPATH builds we do need two -d options to cover both regular  
and generated .c files.  But in in-tree builds it suffices to  
specify "-d .", so suppress the second switch.  
  
Author: Narek Galstyan <narek.galstyan@enterprisedb.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAHsn6_xCDQWe8_vVFhtFk27_xTdyVV+Dr0yWzaooBZ6+-VH-5w@mail.gmail.com  
Backpatch-through: 14  

M src/Makefile.global.in

pg_dump: Include column statistics for index-backed constraints

commit   : a96a9e17064ba0e5ba08514c4055200edab2b29d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 17:02:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 17:02:50 +0900    

Click here for diff

dumpIndex() emits ALTER INDEX .. SET STATISTICS for per-column  
statistics targets, but dumpConstraint() never did.  Targets set on the  
expression columns of an exclusion constraint's index were silently  
lost on dump/restore and pg_upgrade.  
  
The same code can be used in the index and constraint dump code to  
generate these ALTER INDEX commands.  The logic has been refactored so  
that both share a new subroutine in charge of generating all these  
custom SET STATISTICS, if any.  
  
Oversight in e4fca461ab6f.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Andrew Krylosov <krylosov.andrew@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFMd9riOuV5LkM+uV=uF-HYp49C8Fh22xWyMxptGLBCZ3A@mail.gmail.com  
Backpatch-through: 14  

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

Fix crash when describing a FETCH statement whose cursor is gone

commit   : 84b86b2108cf809e1e1483f3812c3f796c8bf598    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 10:43:34 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 10:43:34 +0900    

Click here for diff

FetchStatementTargetList() dereferenced the portal named by a  
FetchStmt without checking that it still exists.  With the extended  
query protocol, a client can sent a Parse "FETCH n FROM c" while cursor  
"c" is open (which caches a result's TupleDesc), issue a CLOSE on cursor  
"c", and then Describe the prepared statement or a portal bound to it.  
  
Describe would re-resolve the target list through the named cursor, and  
crash.  In a non-assert builds, this causes a NULL pointer dereference.  
An assertion was triggered in assert builds slightly before the pointer  
dereference.  
  
This commit changes the describe of a FetchStmt to match with the  
ExecuteStmt case: if the named cursor's portal is invalid, fail rather  
than assume that the portal should always exist.  
  
A test case is added to libpq_pipeline, backpatchable all the way down.  
  
Author: Dirkjan Bussink <d.bussink@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/7DE248EB-7509-4F8A-9F37-4694A40BBAB7@gmail.com  
Backpatch-through: 14  

M src/backend/tcop/pquery.c
M src/test/modules/libpq_pipeline/libpq_pipeline.c

Doc: mention platform-dependent behavior of bitshift operators

commit   : 2028d62f3e79f2425d87d9f431c75d6f84bda06e    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 1 Oct 2026 15:18:33 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 1 Oct 2026 15:18:33 +1300    

Click here for diff

There have been several recent complaints that << and >> don't behave  
the same way on all supported platforms.  There is a risk that <<  
overflows the signed integer type, which is undefined behavior, and there  
are platform-dependent behaviors from shifting by numbers of bits >= the  
bitwidth of the type, and also from shifting by negative values.  
  
Document this to warn unsuspecting users of these facts.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAApHDvr0O6ZF8NO=Rq9Q+Sz=FHT=NZ1kkNTXZDcNph-OWuk7TQ@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/func.sgml

Update time zone data files to tzdata release 2026e.

commit   : 863f04ed3c8738d228606f3876914811b6758ded    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 30 Sep 2026 17:28:14 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 30 Sep 2026 17:28:14 -0400    

Click here for diff

Canada's Northwest Territories will move to permanent UTC-06 on  
2026-11-01.  For now, assume their TZ abbreviation will be CST from  
that time forward.  This affects only America/Inuvik as the rest of  
the territory is covered by America/Edmonton, for which the  
equivalent change was released in 2026c.  
  
Manitoba (America/Winnipeg) will move to permanent UTC-05 on  
2026-10-31.  For now, assume their TZ abbreviation will be EST  
from that time forward.  
  
(Upstream notes that more changes may be needed soon if smaller  
jurisdictions choose to break away from what these have done,  
but for now the plan is wait-and-see.)  
  
Historical corrections for Colombia, Iran, and Ireland.  
  
The backward-compatibility zone names EST5EDT, CST6CDT, MST7MDT, and  
PST8PDT now conform better to POSIX.  For example, EST5EDT now always  
uses the abbreviation "EST" for standard time (now always 5 hours  
behind UTC) and "EDT" for daylight saving time, whereas it formerly  
had different UT offsets before standard time was introduced and  
sometimes used abbreviations like "LMT", "EWT" and "EPT", all contrary  
to POSIX.  Also, though not specified by POSIX these names now use US  
federal rules rather than rules of specific places like New York,  
reverting to 2024a behavior.  This change affects only timestamps  
before 1966-10-30 at 01:00 standard time.  
  
Backpatch-through: 14  

M src/timezone/data/tzdata.zi

Fix clobbering of proc entry's statusFlags during slot invalidation

commit   : 56b306f8b2edb2a7ec466a42fdc5213f908fb6a5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 30 Sep 2026 14:37:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 30 Sep 2026 14:37:24 +0900    

Click here for diff

ReplicationSlotRelease() copied MyProc->statusFlags unconditionally  
when resetting PROC_IN_LOGICAL_DECODING, using its pgxactoff to decide  
which area to update.  
  
Slot invalidations can be done by the checkpointer or the startup  
process, and ReplicationSlotRelease() ignored the fact that pgxactoff is  
only meaningful for processes in the proc array, that auxiliary  
processes never join.  pgxactoff would remain at 0 for these, meaning  
that an incorrect set of status flags would be updated.  
  
The consequences of this issue could be various, depending on the  
statsFlags lost in the proc slot incorrectly overwritten.  Losing  
PROC_AFFECTS_ALL_HORIZONS has been mentioned as the worse case, causing  
VACUUM to remove rows a standby may needs even if standby feedback is  
enabled.  Assertions failures are another possibility.  
  
Let's skip the update of statusFlags unless PROC_IN_LOGICAL_DECODING is  
set.  Nothing but StartupDecodingContext() sets it, and no auxiliary  
processes call it.  
  
Author: Vlad Lesin <vladlesin@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/889a06dd-45fc-423b-9dd2-87d5b5dc60c6@gmail.com  
Backpatch-through: 14  

M src/backend/replication/slot.c

Doc: add missing new line in DO example block

commit   : 6c1686e32cbd61eb620b41ae06d41e419e5fd330    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 30 Sep 2026 02:18:55 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 30 Sep 2026 02:18:55 +1300    

Click here for diff

Reported-by: Oli Sennhauser <oli.sennhauser@fromdual.com>  
Discussion: https://postgr.es/m/777637c4-9d31-498d-a8ef-645fb510bf5a@fromdual.com  
Backpatch-through: 14  

M doc/src/sgml/ref/do.sgml

doc: Fix incorrect output in example

commit   : 80cf7ee59902e2afe7101dc67bb5f921b9b3f4e9    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 29 Sep 2026 10:49:15 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 29 Sep 2026 10:49:15 +0200    

Click here for diff

Reported-by: y.saburov@gmail.com  
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>  
Discussion: https://postgr.es/m/CAKFQuwZ5zQzv1uyoH1UD5ETb7+ArqF2zNXVU4Et+b0_E8bS2sQ@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/func.sgml

Fix incorrect calcSumX2 in numeric deserialize functions

commit   : 42ebc601feca2fd5eb065108ec79da12a227d66e    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 29 Sep 2026 15:50:33 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 29 Sep 2026 15:50:33 +1300    

Click here for diff

calcSumX2 is used to inform the aggregate transition function whether it  
should include the square of the transition value in the aggregate  
state.  The deserialize functions for various numeric aggregates that do  
use calcSumX2 weren't properly setting the property to true.  This does  
not matter in core as we never perform any aggregate transitions after a  
deserialize operation.  
  
This fix is only required for external code which plumbs aggregate paths  
together in such a way that could result in aggregate transitions being  
performed after states have been deserialized.  
  
Author: Maxime Schoemans <maxime.schoemans@enterprisedb.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/FEBF5C3D-CC53-455F-AA9D-4D377A2E957C@enterprisedb.com  
Backpatch-through: 14  

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

Prevent stale pg_locks.waitstart values

commit   : edfa6c8fcbfea8721180276855c893ee8fc56598    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 28 Sep 2026 14:22:04 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 28 Sep 2026 14:22:04 +0900    

Click here for diff

Previously, pg_locks.waitstart could report the start time of a previous  
lock wait for a new wait. For a regular backend, this could happen briefly  
before the new start time was stored. On a standby, the startup process could  
show the old time throughout the next wait, making it appear to have started  
earlier than it did.  
  
This happened because PGPROC->waitStart could remain set after a previous  
wait in two cases. First, RemoveFromWaitQueue() did not clear it when a wait  
was canceled due to a lock timeout, cancellation, or deadlock. Second, even  
after a successful lock grant, ProcWakeup() could clear it before the waiter  
stored its new start time.  
  
Fix this by clearing waitStart in RemoveFromWaitQueue() when a failed wait  
is removed, at the end of ProcSleep() to handle writes made after  
ProcWakeup() cleared it, and in LockErrorCleanup() when an error bypasses  
the ProcSleep() reset. This prevents pg_locks.waitstart from showing the  
previous wait's time for a new wait.  
  
Backpatch to all supported versions.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reported-by: Alex Shapalov <shapalov@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Andrew Krylosov <krylosov.andrew@gmail.com>  
Discussion: https://postgr.es/m/CAPrb+Q+XN=sNusXiUeWmMo2H7Qgq3Y4uPekSSLkHcnCyf7GhXg@mail.gmail.com  
Discussion: https://postgr.es/m/CAGRkXqQLxZBr-ouVrtaX2utMggi4+TiVMbgH04b_0JLgKryxbA@mail.gmail.com  
Backpatch-through: 14  

M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c

Enforce pg_class.relchecks limit (32,767 or INT16_MAX)

commit   : 3eff6531d1d7870990bea7baa08a7d2b5868cda3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 06:55:12 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 06:55:12 +0900    

Click here for diff

pg_class.relchecks reports the number of CHECK constraints in a table,  
and is stored within a smallint.  It was possible to define a table that  
could overflow the counter when specifying more than 32k constraints  
(new table or adding a constraint).  This would cause the table to  
become undroppable, as this counter should never be negative when  
dropping these constraints.  
  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Jian He <jian.universality@gmail.com>  
Reviewed-by: Sivaprasad <sivaprasad.postgres@gmail.com>  
Discussion: https://postgr.es/m/CAEze2WjSW4qaHYnvkTtbknp85eGEirGJTLMZatotdJJKiA+_hA@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/limits.sgml
M src/backend/catalog/heap.c

Don't emit garbage "\[un]restrict (null)" commands in pg_dump.

commit   : ae63671a7fb1c297c39027e0b29e6bed8d8aa5e2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 26 Sep 2026 12:55:40 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 26 Sep 2026 12:55:40 -0400    

Click here for diff

_reconnectToDB() failed to consider the possibility that it could  
be called without any restrict_key set.  This is reachable while  
generating the "restore.sql" file in tar dump mode, which nobody  
noticed because that file is mostly unused (and nothing really  
bad happens anyway unless you specified --inserts mode).  But  
I wonder if there are other code paths that reach the issue.  
  
Bug: #19718  
Reported-by: Pavel Kopylov <pkopylov@cloudlinux.com>  
Author: Pavel Kopylov <pkopylov@cloudlinux.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19718-7e945d0ff9b5a589@postgresql.org  
Backpatch-through: 14  

M src/bin/pg_dump/pg_backup_archiver.c

Doc: clarify there's no log_line_prefix in csvlog or jsonlog output.

commit   : fba35c7c28a567839faba867db0808564c0a66db    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Sep 2026 18:36:17 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Sep 2026 18:36:17 -0400    

Click here for diff

The documentation didn't make clear that "log_line_prefix" is  
not output when "log_destination" is "csvlog" or "jsonlog".  
  
Reported-by: Michael Schönitzer <michael@schoenitzer.de>  
Author: Laurenz Albe <laurenz.albe@cybertec.at>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/179032875673.1026201.6950455317699774504@wrigleys.postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/config.sgml

Modernize crypt-des.c a bit, avoiding dubious casts.

commit   : 2a972dd5fb13489e057b0237bd5f7c8f6ef35b86    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Sep 2026 15:34:39 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Sep 2026 15:34:39 -0400    

Click here for diff

The header comment for this file says it assumes that "the CPU is not  
picky about alignment", which we wouldn't really accept for Postgres.  
The two functions that have alignment requirements have been hacked in  
ways that are inconsistent and yet both ugly.  des_setkey just casts  
its "const char *" argument to "const uint32 *", relying on the caller  
to ensure that that pointer is actually word-aligned, which the caller  
does by declaring the buffer as uint32[] and then casting to "char *".  
Meanwhile des_cipher carefully memcpy's to and from an internal  
uint32[] buffer, which is pretty silly given that what it's passed  
must be word-aligned for the benefit of des_setkey.  And on top of  
that we have a bunch of ugly casting and oddly-written pointer  
arithmetic in the caller px_crypt_des.  The odd pointer arithmetic  
causes warnings about possible buffer overrun when using recent gcc  
at -O3 or higher.  
  
Let's clean this up by converting the buffer variable into a union  
of a uint8 array and a uint32 array, so that we can remove all these  
casts, and also replace the strange loop logic with a simple subscript  
variable to satisfy gcc.  
  
Reported-by: Andres Freund <andres@anarazel.de>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Co-authored-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/2005885.1790359097@sss.pgh.pa.us  
Discussion: https://postgr.es/m/3nuudxv365kjnmwjhnygdakhxuktpdjvf26rt26eb44esgqdrj@y2x3vomkrfoo  
Backpatch-through: 14  

M contrib/pgcrypto/crypt-des.c

Silence another "may be used uninitialized" compiler warning.

commit   : 5a7a6788c96abf583de3f4dc4f8fdcdb35a08172    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 24 Sep 2026 17:57:05 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 24 Sep 2026 17:57:05 -0400    

Click here for diff

gcc 12.5.0 complains about this instance in LookupFuncWithArgs().  
This is the same type of problem fixed in commit f04781df5, and  
it's just as obscure why this compiler version picks on this case  
when others don't.  Still, silence it in the same way as f04781df5.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/1812498.1790279465@sss.pgh.pa.us  
Backpatch-through: 14  

M src/backend/parser/parse_func.c

Wait for transactions of an initial decoding snapshot to commit

commit   : 070e21268b2cde728dbd4aae529ac591f26afb27    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 24 Sep 2026 11:52:47 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 24 Sep 2026 11:52:47 +0200    

Click here for diff

SnapBuildInitialSnapshot() converts the snapshot builder's list of  
committed transactions into a regular MVCC snapshot, which is then used  
with HeapTupleSatisfiesMVCC().  However, a snapshot produced that way  
and used as an MVCC snapshot can potentially cause data corruption, if  
it captures a transaction after it writes its commit WAL record but  
before it has updated its CLOG entry: it will be incorrectly used to set  
hint bits as if that transaction had aborted.  
  
Fix by having SnapBuildInitialSnapshot() wait until such transactions  
have removed themselves from procarray, which guarantees correct  
visibility.  
  
Other uses of SnapBuildBuildSnapshot only use the snapshot as  
historical, so they don't need the waits, but add commentary in that  
function to alert possible future callers.  
  
While at this, backpatch commit 504fe10d1d26, "Fix misplaced comment in  
snapbuild.c."  The comment it moved was nearby the place we modify.  
  
This bug was diagnosed by stress-testing of REPACK (CONCURRENTLY) in  
branch 19, so add a test case that tickles it using that feature in that  
branch and master.  However, the bug exists in all branches, and in  
branch 18 we can add a test with regular logical decoding using  
injection points that tickles it.  Unfortunately that test cannot be  
backpatched to earlier branches for lack of facilities.  
  
Reported-by: Mihail Nikalayeu <mihailnikalayeu@gmail.com>  
Author: Antonin Houska <ah@cybertec.at>  
Author: Rui Zhao <zhaorui126@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/85833.1768840165@localhost  
Discussion: https://postgr.es/m/CADzfLwU78as45To9a%3D-Qkr5jEg3tMxc5rUtdKy2MTv4r_SDGng%40mail.gmail.com  

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

Fix incorrect block accounting in TID Range Scans

commit   : c84dd31bd9f5c2ba1ca79615d405ea0bf00c51a2    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 24 Sep 2026 01:21:45 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 24 Sep 2026 01:21:45 +1200    

Click here for diff

heapgettup_advance_block() (or heapgettup() and heapgettup_pagemode() in  
versions before v16) would incorrectly decrement rs_numblocks when  
advancing to the next block.  Ordinarily this was fine, but if the TID  
Range scan plan was used by a scrollable cursor and the cursor was fetched  
backwards enough to result in another block being required, then  
rs_numblocks may have reached 0 prematurely resulting in the scan ending  
prematurely.  
  
Reported-by: Jeff Davis <pgsql@j-davis.com>  
Author: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/6b50233fcc0f7d6f4845f083777fa9702d9612e4.camel@j-davis.com  
Backpatch-through: 14  

M src/backend/access/heap/heapam.c
M src/test/regress/expected/tidrangescan.out
M src/test/regress/sql/tidrangescan.sql

doc: Fix example output for format()

commit   : 851a5869cd27bee61e08c277f22bc47b033aaaef    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 23 Sep 2026 14:07:25 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 23 Sep 2026 14:07:25 +0200    

Click here for diff

The example output for format() didn't show the actual output  
generated for the example query.  Backpatch to all supported  
branches.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reported-by: y.saburov@gmail.com  
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>  
Discussion: https://postgr.es/m/178979714249.1241.1230833804069549466@wrigleys.postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/func.sgml

Silence warnings about unused global variables

commit   : 5d17c0c02f3074a8273e020e3b9ffa4a41bea325    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 22 Sep 2026 19:30:29 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 22 Sep 2026 19:30:29 +0200    

Click here for diff

Similar to commit "Remove unused global variables", silence  
-Wunused-but-set-global warnings from clang 23 (included in -Wall).  
These are variables that are used in assert-enabled builds only, so  
annotate them with PG_USED_FOR_ASSERTS_ONLY.  

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

Use default limitOption in subquery generated for MIN/MAX index scan.

commit   : d98b99b2ab022dd499d26917fb1dd03fec257267    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 18 Sep 2026 11:02:10 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 18 Sep 2026 11:02:10 -0400    

Click here for diff

We unintentionally copied the original query's limitOption field while  
building the modified subquery.  If it was LIMIT_OPTION_WITH_TIES,  
that behavior would propagate through to execution, potentially  
causing a "more than one row returned by a subquery used as an  
expression" error.  Fix by resetting to the default LIMIT_OPTION_COUNT.  
This bug dates back to the introduction of WITH TIES.  
  
Bug: #19694  
Reported-by: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com>  
Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19694-4e61bd0475398eef@postgresql.org  
Backpatch-through: 14  

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

Fix pruning of DEFAULT partition in RANGE partitioned tables

commit   : 3d734a05977cff3a306a4624cfe604a992a546a0    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 17:17:13 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 17:17:13 +1200    

Click here for diff

Some code added in 489247b0e tried to prune the DEFAULT partition when  
the next partition had a MINVALUE clause and likewise when the final  
partition to scan had a MAXVALUE clause for the final partition key in  
the pruning step.  This code was incorrect as it could prune the default  
partition incorrectly in cases such as:  
  
p: PARTITION BY RANGE (a, b)  
p1: FOR VALUES FROM (13, 0) TO (19, MAXVALUE)  
pd: DEFAULT  
  
SELECT * FROM t WHERE a = 32 AND b >= -7;  
  
Here the pruning step for a = 32 and b >= -7 would see that only the  
default partition needs to be scan, but it would then see that the  
partition prior to the default had a MAXVALUE bound then prune away the  
default thinking that it needn't be scanned.  This could result in  
incorrect results.  
  
Fix this by moving the code that looks for the MAXVALUE bound into the  
code handling BTEqualStrategyNumber so that when we're pruning with a  
prefix of the partition keys, we check if the bound for the offset we've  
calculated lands on a partition where the next partition key is bounded  
with MAXVALUE.  If so we don't include the default partition.  
  
This leaves only the case of the first partition key.  We handle that by  
modifying the existing code that was checking the last key covered by  
the given values.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAON2xHO=sqdqp=z8zWkybnWp0AuvefnAi2ez2vOYWrhXB6hHWQ@mail.gmail.com  
Backpatch-through: 14  

M src/backend/partitioning/partprune.c
M src/test/regress/expected/partition_prune.out
M src/test/regress/sql/partition_prune.sql

Add CHECK_FOR_INTERRUPTS when building pruning steps

commit   : 30ed631b20e13e82fe06cdc5947d5f2acfdc6d6d    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 15:52:36 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 15:52:36 +1200    

Click here for diff

Building the partition pruning steps for excessively complex queries  
can take some time.  Add CHECK_FOR_INTERRUPTS() to  
get_steps_using_prefix_recurse() to allow more timely processing of  
interruptions.  
  
Bug: #19692  
Reported-by: Qifan Liu <imchifan@163.com>  
Discussion: https://postgr.es/m/19692-dacfc57cda5035fc@postgresql.org  
Backpatch-through: 14  

M src/backend/partitioning/partprune.c

Fix assertion after aborting internal subtransaction at transaction end

commit   : aad2baff0eef8874af46877120811896017654f3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 17 Sep 2026 14:28:21 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 17 Sep 2026 14:28:21 +0900    

Click here for diff

Previously, aborting an internal subtransaction during COMMIT or  
PREPARE TRANSACTION could cause the following assertion failure.  
This could happen, for example, when a deferred constraint trigger fired  
at COMMIT and its PL/pgSQL exception block caught an error raised  
while executing the trigger function.  
  
    TRAP: failed Assert("s->blockState == TBLOCK_SUBINPROGRESS || s->blockState  
    == TBLOCK_INPROGRESS || s->blockState == TBLOCK_IMPLICIT_INPROGRESS ||  
    s->blockState == TBLOCK_PARALLEL_INPROGRESS || s->blockState ==  
    TBLOCK_STARTED"), File: "xact.c", Line: 4851, PID: 73455  
  
An internal subtransaction should be able to be aborted while the parent  
transaction is in the COMMIT or PREPARE TRANSACTION phase. However,  
RollbackAndReleaseCurrentSubTransaction()'s assertion check previously  
did not allow TBLOCK_END and TBLOCK_PREPARE as parent transaction  
states, causing the assertion failure.  
  
This commit fixes the assertion check by allowing those two parent  
transaction states.  
  
Backpatch to all supported versions.  
  
Reported-by: Fabrízio de Royes Mello <fabrizio@planetscale.com>  
Author: Patrick Reynolds <piki@planetscale.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Fabrízio de Royes Mello <fabrizio@planetscale.com>  
Discussion: https://postgr.es/m/CABo-N97AeMbWuYTWg-3%3D2DkTR3EkvS%2BFt%3DyEaWB181STsR1mBg%40mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/transam/xact.c
M src/test/regress/expected/triggers.out
M src/test/regress/sql/triggers.sql

Use the join collation when unique-ifying a semijoin's RHS

commit   : b8e0b45abb61ec42de9cb702041902d690629f6d    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 16 Sep 2026 12:17:53 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 16 Sep 2026 12:17:53 +0300    

Click here for diff

A semijoin whose RHS is unique-ified groups the RHS on the expressions in  
SpecialJoinInfo.semi_rhs_exprs.  Those were recorded with whatever collation  
the RHS expression itself exposes, which need not be the collation the join  
compares with.  Neither SortGroupClause nor the pathkey machinery carries a  
collation of its own, so both Unique-over-Sort and HashAggregate then grouped  
by the wrong equality: values the join considers equal survived, and the  
following inner join emitted the outer row once per survivor.  
  
With a non-deterministic collation on one side, "SELECT count(*) FROM t WHERE  
c IN (SELECT c0 FROM t2)" therefore counted more rows than the same predicate  
reports for the rows of t.  
  
Label each RHS expression with the operator's input collation, the same  
treatment process_equivalence() gives to equivalence class members.  Every  
consumer of semi_rhs_exprs reads the collation off the expression, so this  
fixes the sort-based and hash-based paths together; in the branches where  
create_unique_path() also passes these expressions to  
relation_has_unique_index_for(), it likewise stops a unique index built with a  
different collation from being taken as proof that unique-ification can be  
skipped.  The same goes for a subquery's DISTINCT computed under a different  
collation, since translate_sub_tlist() punts on the relabeled expressions.  
  
Reported-by: Suyang Zhong <syzhong16@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/19633-647cd4c73a84b085%40postgresql.org  
Backpatch-through: 14  

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

Fix missing SIREAD lock on the row found by ON CONFLICT.

commit   : 5b6b83cb787f0c7ef9379d99511087bb73ed8c67    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Tue, 15 Sep 2026 11:47:11 +0100    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Tue, 15 Sep 2026 11:47:11 +0100    

Click here for diff

INSERT ... ON CONFLICT decides what to do based on the conflicting row  
found by the arbiter index probe, but SSI never saw that read: the  
probe runs with a dirty snapshot, which predicate locking ignores, and  
the later fetch of the row uses SnapshotAny.  When the statement then  
writes nothing, as with DO NOTHING, DO UPDATE with a WHERE clause  
rejecting the row, or DO SELECT, nothing records the read at all.  A  
concurrent writer of that row went unnoticed and write skew could  
commit at SERIALIZABLE, even though the same schedule with a plain  
SELECT of the row fails with a serialization error.  
  
To fix, read the conflicting tuple again with the query snapshot,  
right where the probe finds it.  The table AM takes the SIREAD lock  
and checks for a concurrent writer of the tuple as part of that read,  
both under the buffer lock, so a writer either sees the lock or is  
seen.  A predicate lock by itself acquired separately after the probe  
could not offer that: a writer passing its conflict check in between  
would be missed.  Doing this in the probe covers every conflict  
action, including rows that the WHERE clause of DO UPDATE or DO SELECT  
then rejects.  
  
The DO NOTHING and DO UPDATE cases have been broken since ON CONFLICT  
was added in 9.5; DO SELECT is new in v19.  Backpatch to all supported  
branches.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Andrey Borodin <x4mmm@yandex-team.ru>  
Reported-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/787936C5-4155-4CF9-939D-39DC0EC1C892@yandex-team.ru  
Discussion: https://postgr.es/m/CAN4CZFM1GkHJkpMeo4G5rxtacVsfeKCJYiik9E9AKX1E9VYQ1w@mail.gmail.com  
Backpatch-through: 14  

M src/backend/executor/execIndexing.c
A src/test/isolation/expected/insert-conflict-serializable.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/insert-conflict-serializable.spec

pg_ctl: Silence warnings about unused global variables

commit   : ddc22e8084918807a6c5e258bbc5c474a85ea274    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 19:12:43 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 19:12:43 +0200    

Click here for diff

Several global variables are only used in Windows build.  This causes  
-Wunused-but-set-global warnings that the new clang 23 enables via  
-Wall.  
  
This commit marks these with an unused attribute to silence the  
warnings.  
  
(In the master branch, this is addressed differently, but for  
backpatching, this just silences the warnings without any behavior  
change.)  
  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/eb013f9d-2247-444e-8815-9d17b4ce78e7%40eisentraut.org  

M src/bin/pg_ctl/pg_ctl.c

Remove unused global variables

commit   : 4096767a94b039aebcc84e347ea1744374a6f6eb    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 21:23:34 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 21:23:34 +0200    

Click here for diff

The new clang 23 has a new warning about set-but-unused  
static (internal-linkage) global variables: -Wunused-but-set-global,  
which is activated in PostgreSQL builds via -Wall.  This triggers a  
few warnings in PostgreSQL code.  This commit removes several such  
variables that were either never used or whose last use was removed  
some time ago.  
  
For pq_init_crypto_lib, we apply the same #ifdef HAVE_CRYPTO_LOCK that  
the other uses of the variable already have, so that the variable is  
either fully used or fully nonexistent, depending on the  
configuration, not half-way.  
  
Reinit was already documented in a comment as dead code, and it was  
removed in a later branch.  To minimize the surgery there, just add an  
unused attribute to silence the warning.  
  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/eb013f9d-2247-444e-8815-9d17b4ce78e7%40eisentraut.org  

M src/backend/postmaster/postmaster.c
M src/backend/utils/adt/jsonpath_scan.l
M src/bin/pg_dump/pg_dump_sort.c
M src/interfaces/libpq/fe-secure-openssl.c

Fix concurrency issues with DROP TABLESPACE

commit   : 539b7e8290e71a253ac4b70faed75e38a7125d97    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 9 Sep 2026 11:23:25 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 9 Sep 2026 11:23:25 -0400    

Click here for diff

DROP TABLESPACE checked pg_shdepend for dependent objects without  
first locking the tablespace.  A concurrent command that recorded a  
shared dependency on the tablespace right after that check could still  
commit, leaving an object whose pg_shdepend entry (or, for a relation,  
pg_class.reltablespace) pointed to a tablespace that no longer existed.  
  
Close the race by having DropTableSpace() take an AccessExclusiveLock  
on the tablespace before calling checkSharedDependencies().  That  
conflicts with the AccessShareLock shdepLockAndCheckObject() takes when  
recording a new dependency, so the loser of the race blocks and  
rechecks once the winner commits.  
  
That AccessExclusiveLock creates a new deadlock: ALTER TABLESPACE  
RENAME/SET and the internal ACL/owner updates in DROP OWNED and  
REASSIGN OWNED touched the catalog tuple without locking the  
tablespace, risking a lock-order cycle with DROP.  Fix by taking an  
AccessShareLock first in all four paths, rechecking pg_shdepend after  
any wait in the DROP OWNED and REASSIGN OWNED cases.  GRANT, REVOKE,  
and ALTER TABLESPACE ... OWNER TO already lock the object.  
  
Add isolation tests covering both orderings of the original race  
(dependency-first and drop-first) and all four previously-unlocked  
update paths.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Discussion: https://postgr.es/m/CAJTYsWXjAQFnGKzXsht3XK8KHhyhontwFJw4JAHsUSfs_ptR4g@mail.gmail.com  
Backpatch-through: 14  

M src/backend/catalog/pg_shdepend.c
M src/backend/commands/tablespace.c
A src/test/isolation/expected/tablespace-dependency-locking.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/tablespace-dependency-locking.spec

Revert "Mark modified the FSM buffer as dirty during recovery"

commit   : 35e4b760a5e91808f315184d020e58ac2695619c    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 8 Sep 2026 13:30:55 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 8 Sep 2026 13:30:55 +0300    

Click here for diff

This reverts commit c06d1a4ba6b26eef27b04074683cccade6c277ee.  
  
The commit assumed that if the FSM code tolerates torn pages, everything else  
does so.  Readers that do not tolerate that include RelationCopyStorage(),  
used by ALTER TABLE ... SET TABLESPACE for every fork, the read stream in  
RelationCopyStorageUsingBuffer() used by CREATE DATABASE ... STRATEGY =  
wal_log, and, most awkwardly, the checksum verification in base backups and  
pg_checksums.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260901211837.f6.noahmisch%40microsoft.com  
Backpatch-through: 14  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  

M src/backend/storage/freespace/freespace.c

doc: Remove unnecessary CVE items from release notes

commit   : 99c003b4dd9e29174f4883420d4ce3affb9c1a66    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 8 Sep 2026 17:27:19 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 8 Sep 2026 17:27:19 +0900    

Click here for diff

The following CVEs were listed in the release notes of some stable  
branches, but they should not:  
- CVE-2026-16238, not on v17 and older  
- CVE-2026-14676, not on v17 and older  
- CVE-2026-14681, not on v16 and older  
- CVE-2026-14672, not on v15 and older  
  
Author: Yogesh Sharma <yogesh.sharma@catprosystems.com>  
Discussion: https://postgr.es/m/340842e1-31ce-4551-9d79-71de490f67e9@CatProSystems.com  
Backpatch-through: 14-17  

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

Stabilize 026_overwrite_contrecord test

commit   : abea7cc0436691177465bb23b44e2daf0c68c5be    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 8 Sep 2026 16:48:29 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 8 Sep 2026 16:48:29 +0900    

Click here for diff

On slow machines, this test can take long enough to generate WAL that a  
time-based checkpoint occurs before the primary is stopped. If the  
checkpoint record is written to the tail WAL segment that the test later  
removes, a standby initialized from the resulting backup tries to read  
the missing checkpoint record and fails with a PANIC during startup.  
This caused the test to fail on buildfarm member skink.  
  
Fix this by setting checkpoint_timeout high enough to prevent unrelated  
checkpoints during the test. This follows the approach used by other  
recovery tests, such as 043_no_contrecord_switch.pl, that depend on a  
specific WAL layout.  
  
Backpatch to all supported versions.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwFajfjKhvNSTkTcE-wFn30p_A0_i1cvk-Q=FJhDr_5cXA@mail.gmail.com  
Discussion: https://postgr.es/m/9ffdb19a-7a89-424e-925a-dd981c37f0ba@gmail.com  
Backpatch-through: 14  

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

Fix nestloop parameter handling for PlaceHolderVars in child joins

commit   : 627081c73932ce9c2c70f6660bf8de320c0c40f7    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 8 Sep 2026 10:13:50 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 8 Sep 2026 10:13:50 +0900    

Click here for diff

When creating a nestloop plan for a partitionwise child join, the  
outer rel's relids are child relids, but PlaceHolderInfo.ph_eval_at is  
always expressed in terms of the topmost parent rels.  As a result,  
replace_nestloop_params() and identify_current_nestloop_params()  
failed to recognize that a PlaceHolderVar evaluated at the outer child  
rel can be supplied as a nestloop param.  Instead, the Vars within the  
PHV's expression were replaced with params, but the outer child rel  
emits only the PHV, not those bare Vars, leading to "variable not  
found in subplan target list" errors from setrefs.c.  
  
To fix, also include the outer rel's top parent relids in the relid  
set used for these checks, so that ph_eval_at comparisons are done in  
terms of parent rels while Var checks continue to work in terms of  
child rels.  
  
On v18 and later, the required-outer set passed to  
identify_current_nestloop_params() has the same problem: it is in  
terms of child rels once a parameterized child join path has been  
reparameterized by an upper child join.  With the above fix in place,  
a PlaceHolderVar that depends on both the outer rel and the parameter  
source becomes a single NestLoopParam, and that param was never  
claimed by any nestloop node, leading to "failed to assign all  
NestLoopParams to plan nodes" errors.  To fix, also include the top  
parents of any child rels in that set.  Older branches lack this code  
path, so they receive only the first change.  
  
Back-patch to all supported branches.  
  
Bug: #19653  
Reported-by: Annie <10215501441@stu.ecnu.edu.cn>  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19653-9352cc6ba17b662f@postgresql.org  
Backpatch-through: 14  

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

Fix incorrect error message in xlogreader.c

commit   : 4305b32c98714773b4545b4827a6b927f5f2e5a5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 5 Sep 2026 09:12:57 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 5 Sep 2026 09:12:57 +0900    

Click here for diff

When neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED is set,  
DecodeXLogRecord() checks that bimg_len needs to be equal to BLCKSZ.  
However, the associated error message reported the data length  
associated to a block (DecodedBkpBlock.data_len), and not the length of  
the block (DecodedBkpBlock.bimg_len).  
  
Oversight in 57aa5b2bb11a, probably due to some copy-paste from the  
surroundings.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWVz9ymE7aMt2ZiQvs1bxNvhjfTf+XaJEsdFw7MT5dvtYQ@mail.gmail.com  
Backpatch-through: 14  

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

Fix lack of message pluralization

commit   : f419fad428639ce515a53ab7450c78ef60105960    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 3 Sep 2026 11:49:09 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 3 Sep 2026 11:49:09 +0200    

Click here for diff

Fixups for commits b99b74144f9, 79b101486c1, bf7d19be9b1.  

M src/backend/commands/trigger.c
M src/backend/replication/logical/worker.c
M src/backend/utils/time/snapmgr.c

Avoid backend hang during temp table cleanup in deferrable transactions

commit   : 57c1072380536656df87ebc59270f966b7a0f695    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 3 Sep 2026 12:16:54 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 3 Sep 2026 12:16:54 +0900    

Click here for diff

Previously, a session that had created temporary objects could hang during  
exit if its default transaction mode was SERIALIZABLE READ ONLY DEFERRABLE  
and a concurrent serializable transaction was prepared. During backend  
exit, temporary-relation cleanup pushed a regular transaction snapshot,  
which honored the session's default settings and could wait for a safe  
serializable snapshot. So, if the conflicting transaction was prepared,  
this wait could last indefinitely.  
  
The wait occurred while the backend was already exiting and interrupts  
were held off, so even pg_terminate_backend() could not cancel it. The  
backend therefore remained until the prepared transaction was resolved.  
  
Temporary-relation cleanup only needs an active MVCC snapshot for fetching  
TOAST data from catalog tuples while dropping temporary objects. It does  
not need a transaction snapshot affected by the user's default isolation  
settings. So, use a catalog snapshot instead, which provides the needed  
protection without entering the deferrable safe-snapshot wait.  
  
Backpatch to all supported versions.  
  
Bug: #19441  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19441-ec29f3b1363b4a68@postgresql.org  
Backpatch-through: 14  

M src/backend/catalog/namespace.c
A src/test/modules/test_misc/t/015_temp_schema_exit_deferrable.pl

Fix checkpointer restartpoint assertion failure

commit   : d3c9ccdf1edec4f486a860e279d2ef2e22f5e4f1    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 2 Sep 2026 14:35:10 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 2 Sep 2026 14:35:10 +0900    

Click here for diff

When recovery starts from a backup without a signal file, pg_subtrans  
is not started at the beginning of recovery and remains unstarted  
throughout recovery. However, previously, a restartpoint run by  
the checkpointer during recovery nevertheless tried to truncate  
pg_subtrans, triggering the assertion failure:  
  
    TRAP: failed Assert("TransactionIdIsValid(initial)")  
  
This commit fixes this by tracking whether pg_subtrans has been  
started during recovery, and have the checkpointer check this flag  
before truncating pg_subtrans at restartpoints.  
  
Backpatch to all supported versions.  
  
Reported-by: Imran Zaheer <imran.zhir@gmail.com>  
Author: Imran Zaheer <imran.zhir@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CA+UBfamzfEReT0VOGRUW_=_AecCYQ-CNKLR_T4Q+YEmJAH3fdg@mail.gmail.com  
Backpatch-through: 14  

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

doc: clarify aliasing of VALUES in FROM clauses

commit   : 03851df1105da45350e6d8db20d099299b27428c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 22:50:32 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 22:50:32 +0900    

Click here for diff

The VALUES reference page said that an AS clause was required when  
VALUES is used in a FROM clause. This was imprecise because AS is  
optional when specifying an alias.  
  
In v14 and v15, a table alias is still required in this case, so state  
that explicitly instead. In v16 and later, commit bcedd8f5fce made table  
aliases for subqueries in FROM clauses optional, so state that the  
table alias is optional there. In all branches, continue to recommend  
explicit column aliases as good practice.  
  
Backpatch to all supported versions.  
  
Author: Ian Barwick <barwick@gmail.com>  
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAB8KJ=jrvZdNLLhYSiCgbjLTz2LKEjYw+-HVQkaF+kgk61KtHA@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/ref/values.sgml

Handle PG_INT32_MIN negation overflow in right()

commit   : 858fb27b69bc81b2ac2dab9e4db4df4056cc2fae    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 1 Sep 2026 10:13:30 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 1 Sep 2026 10:13:30 +0200    

Click here for diff

A negative n means "return all but the first |n| characters", so  
text_right() negates n before clipping.  Negating PG_INT32_MIN  
overflows; with -fwrapv the result is PG_INT32_MIN again, still  
negative, and pg_mbcharcliplen() then returns an offset of zero,  
so the whole string is returned where the correct answer is an  
empty string:  
  
  SELECT right('abcdef', (-2147483648)::int4); -- 'abcdef', want ''  
  SELECT right('abcdef', -2147483647);         -- '', correct  
  
Clamp to PG_INT32_MAX instead.  Any n whose absolute value is at  
least the string's length skips all of it, and a text value cannot  
be longer than PG_INT32_MAX, so this gives the same answer for every  
other input.  Erroring out, as text_format_string_conversion() does  
for a width of INT_MIN, would not be correct here: unlike a format  
width, an out-of-range skip count has a well-defined result.  
  
Using pg_neg_s32_overflow() would be a slightly more optimal fix but  
as it's only available in PostgreSQL 18 and later the decision was  
taken to apply the same fix to all backbranches.  
  
Backpatch to all supported versions.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAON2xHNnBz-AcPJgDmd5_39+8qR5AUKEZk4X3ZM-0zdsATn8kQ@mail.gmail.com  
Backpatch-through: 14  

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

Fix integer to_char() overflow with V format

commit   : f1c6f7ec95dc0434726738a5733491ef00a5a640    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 11:42:13 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 11:42:13 +0900    

Click here for diff

When to_char() formatted an integer value with a V pattern, it could  
return an incorrect result instead of reporting an overflow. V shifts  
the decimal point by multiplying the input value by a power of ten before  
formatting it, so, for example,  
  
    to_char(3, '9V999999999')  
  
requires computing 3 * 10^9. This result does not fit in int4, but  
the integer variant of to_char() performed the multiplication using a  
plain int32 expression. The intermediate result could therefore  
overflow, causing the function to output incorrect digits instead of  
raising "integer out of range".  
  
Use dtoi4() and int4mul() for this calculation so that both an  
out-of-range multiplier and an out-of-range product are detected, as  
with ordinary integer arithmetic. This also matches the existing int8  
implementation, which uses dtoi8() and int8mul() for the same  
operation.  
  
After this change, to_char() with V format either returns the  
correctly formatted result when the scaled value fits in int4, or  
raises "integer out of range" when it does not.  
  
Backpatch to all supported versions.  
  
Reported-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Miłosz Bieniek <bieniek.milosz@proton.me>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAB8bMivEfqZxOVdzc3kZDN++XshmkEz2t7dfGBU8+oUm864EZg@mail.gmail.com  
Backpatch-through: 14  

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

Harden spell.c against out-of-order FLAG lines in Hunspell files.

commit   : b4c8afdfaf52ce4a5839be6b4d205e696b00a543    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Aug 2026 19:56:49 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Aug 2026 19:56:49 -0400    

Click here for diff

The compound flags collected from COMPOUNDFLAG and friends are stored in  
either the string or the integer member of a union, according to the  
flag mode that the affix file's FLAG line declares.  NIImportOOAffixes()  
converted each flag as soon as it read it, using the mode in effect at  
that point, and recorded that mode in the entry.  Since FLAG may appear  
anywhere in the file, including after the compound flags, entries written  
before and after it could disagree about which member of the union holds  
the flag.  
  
In assert-enabled builds, this would result in an assertion failure.  
Otherwise, cmpcmdflag() takes the mode from its first argument and  
applies it to both, so it can read an integer as a char pointer and pass  
that to strcmp().  Depending on which way the mismatch goes, the result  
is a segfault while sorting the array, a segfault in the bsearch() that  
later looks flags up (the lookup key is built with the final mode, so  
this happens even when the array itself is consistent), or, when both  
members happen to be readable, no crash at all and a compound flag that  
is never found, which silently disables compound word splitting.  This  
isn't a security bug because we consider dictionary files to be trusted  
data, but it's still worth fixing.  (In practice, dictionary files  
usually put the FLAG line first, which is why this went unreported for  
so long.)  
  
Fix by keeping the flags as strings while the file is read and converting  
them once it has been read in full, when the mode is final.  This also  
makes the position of the FLAG line irrelevant, which is how the flags on  
AF, SFX and PFX lines are already treated: those are parsed in a second  
pass and so always use the final mode.  That precedent is reason for  
behaving this way rather than throwing an error.  
  
The old ispell file format reaches addCompoundAffixFlagValue() too,  
from NIImportAffixes(), and returns without entering NIImportOOAffixes(),  
so it needs the conversion step as well.  
  
While we're here, also fix some integer width mismatches: store the  
result of strtol() into a "long", and cast to int only after we've done  
range checks.  Typically a value too wide for int would fail the range  
checks anyway, but in some cases it would be silently accepted after  
truncation to int.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAON2xHN3QmsaySM6DGWa1gttcbJoFh0wjAE-_ZpSPo=LKN1hYw@mail.gmail.com  
Backpatch-through: 14  

M src/backend/tsearch/spell.c

Fix incorrect multi-column RANGE partition pruning

commit   : 978caef1936fc06a6dcc75283115ede953ab6d34    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 28 Aug 2026 13:13:04 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 28 Aug 2026 13:13:04 +1200    

Click here for diff

When performing partition pruning with a RANGE partitioned table where  
the pruning quals are only present for a leading prefix of the partition  
key, it was possible that partition pruning would accidentally prune away  
some partitions which shouldn't be pruned and include some partitions that  
were not needed.  
  
This happened due to an incorrectly coded loop bound which was  
terminating the loop when the bound reached the first or last element in  
the partition bound array.  This resulted in those end elements not being  
checked in cases where they should be checked.  It appears that it might  
have been coded this way to avoid stepping off the array, but that was  
done incorrectly as it failed to take into account the direction of travel  
through the array (the loop can go forwards or backwards).  I.e., it's  
valid to loop when 'off' is the last element if we're going backwards  
through the array, and valid to loop if 'off' is 0 and we're looping  
forward through the array, but the code as it was didn't allow that.  
  
Here we fix this by moving the loop condition check to after we've  
calculated the array element to process, and break from the loop if that  
element is beyond either end of the array.  
  
Example of accidentally pruned partition:  
  
p: partition by range (a, b);  
p1: for values from (1, 4) to (1, 7);  
p2: for values from (1, 7) to (3, 8);  
p3: for values from (4, 8) to (6, 9);  
def: default;  
  
select * from p where a <= 1;  
  
Here p2 was pruned by mistake.  
  
Example of accidentally not pruning a partition:  
  
p: partition by range (a, b);  
p1: for values from (7, 2) to (7, 7);  
def: default;  
  
select * from p where a > 7;  
  
No partitions would be pruned in this case, despite it being impossible  
for matching rows to exist in p1.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvp5ne9AWaH-tG1Lke-USLz3NwWLWTUdP5NT7ypKtcFqcg@mail.gmail.com  
Backpatch-through: 14  

M src/backend/partitioning/partprune.c
M src/test/regress/expected/partition_prune.out
M src/test/regress/sql/partition_prune.sql

Fix temporary WAL receiver slot handling on timeline switches

commit   : aec25d6107ddf03430947f67d662bdedffc064c2    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 28 Aug 2026 01:17:19 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 28 Aug 2026 01:17:19 +0900    

Click here for diff

Previously, when wal_receiver_create_temp_slot was enabled, a timeline  
switch could cause the walreceiver to try to create the same temporary  
replication slot again on the same connection. The slot had already been  
created before the first streaming attempt and still existed, so the  
second creation attempt failed with a FATAL error such as  
"could not create replication slot ...".  
  
The walreceiver would later be restarted and streaming replication could  
continue, so this did not permanently break replication. Nevertheless,  
the unexpected failure is a bug and should be fixed.  
  
Fix this by tracking whether the temporary replication slot has already  
been created for the lifetime of the walreceiver and skipping subsequent  
creation attempts. Also copy the retained slot name to shared memory on  
each streaming attempt, since RequestXLogStreaming() clears it when  
streaming is restarted without a configured primary slot. This also  
keeps pg_stat_wal_receiver.slot_name populated after timeline switches.  
  
Backpatch to all supported versions.  
  
Author: ChangAo Chen <cca5507@qq.com>  
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/tencent_628FDAF814231923BC8E8357BBBC50F94207@qq.com  
Backpatch-through: 14  

M src/backend/replication/walreceiver.c
M src/test/recovery/t/004_timeline_switch.pl

Stabilize 019_replslot_limit

commit   : 321ec8ee1c016fde47aeebb9e0b3882bcc4c6b97    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 27 Aug 2026 23:57:47 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 27 Aug 2026 23:57:47 +0900    

Click here for diff

The test assumed that advancing WAL would lead to a checkpoint that  
invalidates the obsolete replication slot.  If a checkpoint that started  
before the WAL switch completes first, the following checkpoint can be  
skipped as idle, so the expected walsender termination is not logged.  
  
Force a CHECKPOINT in a background psql session after advancing WAL, so  
the slot invalidation is exercised deterministically.  
  
This has been observed on buildfarm members alligator and partridge:  
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=alligator&dt=2024-12-13%2001%3A24%3A58  
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=partridge&dt=2026-08-06%2018%3A00%3A11  
  
Backpatch to all supported versions.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/0b07ead5-a5da-445e-9698-a7d340708bdf@gmail.com  
Backpatch-through: 14  

M src/test/recovery/t/019_replslot_limit.pl

Don't create a shell type for function returning an array

commit   : ba2ea49b3cba05a948d38afe6191a4338e063dce    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 27 Aug 2026 14:31:44 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 27 Aug 2026 14:31:44 +0300    

Click here for diff

Refactor the checks in the function to move all the conditions for  
when to attempt creating a shell type into one place.  Add a check for  
the array syntax.  
  
In addition to rejecting array syntax, another user-visible effect is  
that the error message is now different if the type specified a  
typmod.  You now get "type does not exist" instead of the more  
specific "type modifier cannot be specified for shell type".  That  
seems better; the implicit shell type creation exists only for  
backwards compatibility, and it never worked with type modifiers, so  
if there's a type modifier it's most likely not because the user tried  
to create a shell type,  
  
Add test for the array syntax, the type modifier, and some other cases  
for which we don't create shell types.  
  
Discussion: https://www.postgresql.org/message-id/de673feb-41b4-4685-b24b-6408b95e58ab@iki.fi  
Backpatch-through: 14  

M src/backend/commands/functioncmds.c
M src/test/regress/expected/create_type.out
M src/test/regress/input/create_function_1.source
M src/test/regress/output/create_function_1.source
M src/test/regress/sql/create_type.sql

Export subxip[] for snapshots taken during recovery.

commit   : 9a1fa1f36e48394bb205eaf66cc33c18a6fe1bff    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 26 Aug 2026 15:38:04 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 26 Aug 2026 15:38:04 -0400    

Click here for diff

A snapshot taken during recovery stores all of its in-progress XIDs in  
subxip, every running top-level XID included, leaving xip empty.  Unlike  
with other snapshots, its suboverflowed flag does not mean that subxip  
is redundant.  We nevertheless treated it that way during snapshot  
export, so an importing session could see in-progress transactions as  
aborted.  This misbehavior could also lead to hint bits being  
incorrectly set on the standby; affected tuples then wrongly appeared  
visible or invisible to sessions that never imported the snapshot.  
  
To fix, teach snapshot export to include the subxip[] array regardless  
of the overflow flag when the snapshot is taken during recovery.  This  
is in line with how CopySnapshot() and SerializeSnapshot() already  
handle the same issue.  
  
Claude Code diagnosed this problem.  The committed TAP test is a  
simplified version of the one that it wrote to demonstrate this bug.  
  
Oversight in commit 6c2003f8a, which enabled snapshot export and import  
during recovery.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Bug: #17846  
Discussion: https://postgr.es/m/CAH2-WzmHVeYY%3Dpjz9x8DhhxVjXHX0pvoQ-MdiB1Tt6%3Do2GTiKg%40mail.gmail.com  
Discussion: https://postgr.es/m/17846-1a0e5ce976f4c01a@postgresql.org  
Backpatch-through: 14  

M src/backend/utils/time/snapmgr.c
A src/test/recovery/t/056_standby_snapshot_export.pl

Don't assume DISTINCT ON implies uniqueness when the tlist has SRFs

commit   : 7e29fcd1ae0083a7fd45f14ab7b9ad3ea0c97e9c    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 25 Aug 2026 10:22:12 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 25 Aug 2026 10:22:12 +0900    

Click here for diff

query_is_distinct_for() treated a subquery's DISTINCT ON clause as  
proof that its output is unique over the DISTINCT ON columns, even if  
the targetlist contains set-returning functions.  That's not true:  
when the query has an ORDER BY, the planner postpones evaluation of  
SRFs that are not DISTINCT ON or ORDER BY columns until after the  
Unique step, so the subquery can produce duplicates of the DISTINCT ON  
columns.  Relying on this bogus uniqueness proof allowed join removal  
and unique-inner joins to produce wrong results.  
  
Plain DISTINCT is not affected, since all tlist columns are DISTINCT  
columns there, and so any SRFs get expanded before the Unique step.  
  
To fix, make query_supports_distinctness() and query_is_distinct_for()  
refuse to prove distinctness via DISTINCT ON if the targetlist  
contains any SRFs.  This is more conservative than necessary, since  
the SRFs are only postponed when there is an ORDER BY and none of them  
appear in a sort/group column, but it doesn't seem worth the trouble  
to check that precisely.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAMbWs4-hfd1Pyy_zBejsVUSy-3dx16rz2hgUakkKnAg3qg2q=Q@mail.gmail.com  
Backpatch-through: 14  

M src/backend/optimizer/plan/analyzejoins.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Fix GIN posting tree page deletion with incomplete splits.

commit   : bbe7aca31db0b9e4758bb67a2d42f1bcc05e0c4b    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 22 Aug 2026 14:50:28 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 22 Aug 2026 14:50:28 -0400    

Click here for diff

GIN posting tree page deletion failed to consider whether the target  
page's left sibling page, or the deletion target itself, was marked as  
incompletely split.  Page deletion finds the target page's left sibling  
by walking the parent's downlinks, but an incompletely split page's new  
right half is part of the sibling chain despite having no downlink.  
Deletion could therefore overwrite the rightlink of the wrong page,  
disconnecting the split's still-live right half from the sibling chain.  
Scans would then silently miss tuples from that page.  
  
To fix, teach the relevant page deletion path to avoid deleting a  
posting tree page whose left sibling is marked incompletely split (and  
to avoid doing so when the target page itself is so marked).  This is  
essentially the same approach used by nbtree page deletion.  
  
Claude Code found this problem.  The committed test case is a simplified  
version of the one that it wrote to demonstrate this bug.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAH2-Wz=sKJcn+OtfVN9rdg+Ps9e4cuQWNP-9t12UE2d8nEG90Q@mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/gin/ginvacuum.c

Doc: fix typo

commit   : e8c6d114ea112ddaa8ab226092c46e3d68f63a83    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Sat, 22 Aug 2026 12:51:22 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Sat, 22 Aug 2026 12:51:22 +1200    

Click here for diff

Author: Jochen Bandhauer <jb@jbitc.de>  
Discussion: https://postgr.es/m/69ecfa04-9177-42fd-8d5d-9f375669fc5b@jbitc.de  
Backpatch-through: 14  

M doc/src/sgml/maintenance.sgml

Attempt to stabilize plan of self-join test in tidscan.sql

commit   : 7f1054b51bc742b7fa27ce8e8c1f3d61cf7349e2    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 21 Aug 2026 12:28:43 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 21 Aug 2026 12:28:43 +1200    

Click here for diff

The test that checks the expected plan for this self-join test has been  
known to have failed in the past due to badly timed VACUUMs causing  
small variations in row estimates on one of the tables, resulting in a  
swapped join order.  Currently, failures have only been seen in v14, and  
seemingly due to 74388a1ac and 4496020e6 the failures have not been seen  
in more recent versions.  
  
Here we shrink down the number of matching rows on one side of the join  
to make the alternative join order's costs more expensive relative to  
the cheapest join order.  Previously the alternative order had the same  
cost.  
  
We do this in all supported versions to reduce the chances of future  
changes reintroducing stability issues with these queries.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/f5d1f4c2-6224-4797-be17-c86e77f96c9c@gmail.com  
Backpatch-through: 14  

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

Fix snapshot import xmin ProcArrayLock bug.

commit   : e94ba903bc3e3432ee78150e8e15c37bffe1328d    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 20 Aug 2026 19:47:21 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 20 Aug 2026 19:47:21 -0400    

Click here for diff

ProcArrayInstallImportedXmin verifies that the source transaction (the  
transaction whose snapshot we're importing) is still running, and then  
installs the caller's imported xmin.  These steps have to be atomic.  
But it was just about possible for VACUUM to fail to observe the  
imported xmin in either the source proc or the importing one.  This  
could result in VACUUM pruning away deleted tuples that were still  
visible to the imported snapshot.  
  
To fix, take ProcArrayLock in exclusive mode while importing an exported  
snapshot's xmin within ProcArrayInstallImportedXmin.  That guarantees  
that a concurrent VACUUM's OldestXmin cannot advance past the xmin (one  
proc or the other always advertises an xmin that holds it back).  
  
Author: Chee Wooson <chee.wooson@gmail.com>  
Reviewed-by: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/20260730042128.714201-1-chee.wooson@gmail.com  
Backpatch-through: 14  

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

Reject too many arguments in CREATE TRIGGER

commit   : 4434340b5769439cc31dbd068a8c7f336eef71ed    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Aug 2026 09:38:36 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Aug 2026 09:38:36 +0900    

Click here for diff

The number of trigger arguments is stored as a smallint, but there was  
no check that the number of arguments fits with the catalog data type.  
This could result in an invalid negative value being stored once one  
defined more than INT16_MAX arguments, with an overflowed value stored  
in the catalogs.  
  
Looking at other catalogs that store a number of arguments, we have  
similar protections already in place (aggregates, functions, etc.).  
  
Reported-by: Xingwang Xiang <v3rdant.xiang@gmail.com>  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://postgr.es/m/19627-5b72a57e332e2b3f@postgresql.org  
Backpatch-through: 14  

M src/backend/commands/trigger.c

GiST: Invalidate killed items consistently.

commit   : 9628f4de6c5fadc73fa424f5a2e215b9aaa122cd    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 15:45:43 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 15:45:43 -0400    

Click here for diff

GiST neglected to invalidate its killedItems[] array on a rescan.  As a  
result, it was just about possible for the wrong tuples from the wrong  
index page to be LP_DEAD-marked on a rescan.  The scan mistakenly  
believed that the previous rescan's killedItems[] were for this rescan's  
curBlkno, causing index corruption.  
  
To fix, bring GiST in line with nbtree and hash: call gistkillitems from  
both gistrescan and gistendscan (the existing gistgettuple caller still  
handles the common case where we need to LP_DEAD-mark before moving on  
to the next page).  That way the scan's pending killedItems[] are passed  
to gistkillitems while they still describe items from curBlkno.  When  
gistkillitems runs, it'll invalidate the array in passing (and won't  
needlessly miss out on an opportunity to LP_DEAD-mark eligible index  
tuples).  Back branches just get minimal hardening: we invalidate  
killedItems[] at the places where the master branch gets new calls to  
gistkillitems (and we invalidate curBlkno and curPageLSN on a rescan).  
  
The test that proved corruption on master didn't result in corruption on  
any stable branch, though only because, without commit 9c9ddf109, we'd  
clobber curPageLSN without also updating curBlkno -- which accidentally  
prevented it.  Relying on gistkillitems to not LP_DEAD-mark by passing  
it a curBlkno whose curPageLSN was taken from an entirely different page  
seems like a very bad idea, which is why this issue is being treated as  
a bug affecting all stable branches.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-By: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAH2-WzmwEThnQf17Ju+t0N9_KJLsEQSXzYrFnaS2=s4KnGGrqw@mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/gist/gistget.c
M src/backend/access/gist/gistscan.c

Fix GIN multiple-VACUUM-scans pending list bug.

commit   : 0bace7af3dff862e9643e45df11449857cc56932    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 13:46:34 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 13:46:34 -0400    

Click here for diff

ginbulkdelete performs pending list cleanup before it searches the entry  
tree (and any posting trees) for dead TIDs.  This is necessary to avoid  
leaving behind dangling TID references that index vacuuming is required  
to remove; nothing prevents recently inserted pending list tuples from  
containing TIDs that VACUUM already considers dead.  
  
However, ginbulkdelete neglected to perform pending list cleanup on  
VACUUM's second or subsequent call.  It was therefore possible for a  
VACUUM that requires multiple rounds of index vacuuming to leave behind  
dangling references.  
  
To fix, teach ginbulkdelete to perform pending list cleanup during every  
call.  In passing, tweak some related comments in the pending list  
cleanup path to make it clear why it's safe for VACUUM to not _fully_  
empty an index's pending list.  
  
This was arguably an oversight in commit e2c79e14, which fixed a similar  
issue where pending list cleanup by VACUUM could end early, but missed  
this closely related problem.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAH2-Wzmsa-RPA2Ko8A5LaGOnmbpimJ--71xkiBqwgjk3Fq8YEg@mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/gin/ginfast.c
M src/backend/access/gin/ginvacuum.c
M src/include/access/gin_private.h

Fix GIN VACUUM posting tree root split bug.

commit   : fbf889de95606471cecf4ff5533dc24d40cb8700    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 12:30:56 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 12:30:56 -0400    

Click here for diff

ginVacuumPostingTreeLeaves swaps a shared buffer lock for an exclusive  
one when it encounters a leaf page.  It neglected to re-verify whether a  
page that was initially a leaf root page became an internal page due to  
a concurrent root page split (during the window when no lock was held).  
It was therefore possible for GIN VACUUM to spuriously treat an internal  
page as a leaf page, leading to data corruption.  VACUUM could miss dead  
TIDs that it was required to remove, leaving behind dangling references  
in the index.  
  
To fix, re-verify that a leaf page is still a leaf page after an  
exclusive lock is acquired.  If it isn't, drop our exclusive lock and  
acquire a shared lock so that the non-leaf root page gets processed in  
the usual way.  
  
Oversight in commit fd83c83d, which fixed a deadlock bug in GIN posting  
tree vacuuming.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAH2-Wz=RBpJTQgvOxr6C=J04dExmFSt1E3F-r+cRTQ56hEotkg@mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/gin/ginvacuum.c

psql: Fix psql slash option leaks

commit   : e8bc40d290673a74c094c289b00c01c997d36652    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:38:16 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:38:16 +0900    

Click here for diff

psql_scan_slash_option() returns a malloc'd string, but \getresults,  
\gset in pipeline mode, \restrict, and \unrestrict did not free it  
after consuming or copying the value.  
  
Free these option strings after use.  
  
Backpatch to all supported versions. In v17 and older, only \restrict  
and \unrestrict are affected, so those branches need only that part of  
the fix.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEh3R3=1tx_a5=fTDJ+ycuwxWMEn6bG_Yt4B5P+hE7AVw@mail.gmail.com  
Backpatch-through: 14  

M src/bin/psql/command.c

psql: Avoid returning oom_buffer from psql slash option scanner

commit   : de38e72a199117ef69d7653f91f849626b4dcf3b    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:34:28 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:34:28 +0900    

Click here for diff

psql_scan_slash_option() builds option text in a local PQExpBufferData  
and returns the buffer's data pointer to its caller. If either the initial  
allocation or a later enlargement failed, that data pointer could be  
the static PQExpBuffer OOM buffer rather than malloc-owned storage.  
The callers could then eventually pass it to free(), causing undefined  
behavior.  
  
Detect a broken option buffer before returning it, report OOM, and return  
NULL instead. Also avoid evaluating a backtick substitution when the option  
buffer is already broken, since doing so could otherwise touch the static  
OOM buffer.  
  
This keeps the existing NULL-return convention for slash options. Callers  
are not generally changed to distinguish OOM from no option.  
  
Backpatch to all supported versions.  
  
Reported-by: Junwang Zhao <zhjwpku@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEh3R3=1tx_a5=fTDJ+ycuwxWMEn6bG_Yt4B5P+hE7AVw@mail.gmail.com  
Backpatch-through: 14  

M src/bin/psql/command.c
M src/bin/psql/psqlscanslash.l

psql: Avoid returning oom_buffer from psql slash command scanner

commit   : e6c200f9a39a75da1bb829e87e99133ea5fea237    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:31:00 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:31:00 +0900    

Click here for diff

psql_scan_slash_command() builds the command name in a local  
PQExpBufferData and returns the buffer's data pointer to its caller. If  
either the initial allocation or a later enlargement failed, that data  
pointer could be the static PQExpBuffer OOM buffer rather than malloc-owned  
storage. HandleSlashCmds() could then eventually pass it to free(), causing  
undefined behavior.  
  
Detect a broken command-name buffer before returning it, report OOM, and  
return NULL instead. Teach HandleSlashCmds() to treat a NULL command name  
as a command error before trying to compare or dispatch it.  
  
Backpatch to all supported versions.  
  
Reported-by: Junwang Zhao <zhjwpku@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEh3R3=1tx_a5=fTDJ+ycuwxWMEn6bG_Yt4B5P+hE7AVw@mail.gmail.com  
Backpatch-through: 14  

M src/bin/psql/command.c
M src/bin/psql/psqlscanslash.l

Fix relcache reference leak when decoding TRUNCATE

commit   : 29b52d2b47fb8fa892695bc941d3e035164481cf    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 11:32:58 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 11:32:58 +0900    

Click here for diff

ReorderBufferProcessTXN() opens every relation referenced by a  
TRUNCATE change.  When RelationIsLogicallyLogged() returns false,  
it skips the relation without releasing the reference acquired  
by RelationIdGetRelation().  
  
Looking at the in-core code paths building XLOG_HEAP_TRUNCATE records,  
no relation OIDs would be included if they do not satisfy  
RelationIsLogicallyLogged().  One pattern that could go through is if a  
table is switched to SET UNLOGGED, but that would not be reachable in  
practice as the decoding happens after a historical snapshot is taken,  
so the relation should still be valid.  
  
This is a defense-in-depth measure in practice, and we tend to be  
careful about how Relations are handled when sending changes to output  
plugins, so backpatch all the way down.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/7DD65D03-3B5A-43B2-99AD-8E6AF5372BAB@gmail.com  
Backpatch-through: 14  

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

Report single-page checksum failures in pg_stat_database

commit   : 19d900358fd6f200ada6aabfa4d44d83c16a3f0a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 09:52:01 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 09:52:01 +0900    

Click here for diff

Base backups reported checksum failures to pg_stat_database only for  
files with more than one failing page.  Commit 6b9e875f728 placed the  
report inside the block emitting the per-file summary WARNING, which  
was skipped for a single failure.  As a result, a backup failing on  
files with one corrupted page each left checksum_failures untouched.  
  
To fix, emit the per-file summary and the pgstat report for any  
non-zero failure count.  The end-of-backup total WARNING had the same  
off-by-one and is now also emitted for a single failure.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFN+Bi6XmaH8zOdMWjoycYFx9nKtOr+dzQf0o-UQ+Rdqmw@mail.gmail.com  
Backpatch-through: 14  

M src/backend/replication/basebackup.c
M src/bin/pg_basebackup/t/010_pg_basebackup.pl

Defend against null "SV *" pointers in plperl modules.

commit   : ec24237a40c695f4a4364039e778361c3103c330    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 18 Aug 2026 17:33:44 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 18 Aug 2026 17:33:44 -0400    

Click here for diff

Tied hashes, and probably tied arrays, are capable of returning Perl  
value pointers that are actually NULL, not the usual pointer to an  
undef SV.  We were not defending against that everywhere, leading  
to possible SIGSEGV.  Fix the code to consistently treat a null  
pointer returned from hv_iternext or av_fetch like a !SvOK one.  
(Note that the large diff in SV_to_JsonbValue is actually quite  
trivial, but it required reindenting a chunk of existing code.)  
  
Claude Code found the instance in hstore_plperl, and I found the  
others by code auditing.  Perhaps the other instances aren't  
actually reachable, but I see little reason to assume that.  
  
The known test cases for these errors require perl's Tie modules,  
which may not be present, so it doesn't seem worth the trouble  
to create regression test cases that would cover them.  
  
Reported-by: Claude Code (via Noah Misch)  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/569769.1786901901@sss.pgh.pa.us  
Backpatch-through: 14  

M contrib/hstore_plperl/hstore_plperl.c
M contrib/jsonb_plperl/jsonb_plperl.c
M src/pl/plperl/plperl.c

Doc: clean up documentation about text search datatype limits.

commit   : cce1fa9dbcc134281e6d17f34d2f30cd51345184    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Aug 2026 18:17:51 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Aug 2026 18:17:51 -0400    

Click here for diff

textsearch.sgml neglected to mention that the MAXSTRPOS total-length  
limit applies to tsquery as well as tsvector.  It also claims that  
there is a 32K limit on the total number of nodes in a tsquery, which  
is wrong.  (I suspect that QueryOperator.left may once have been  
int16, which would give rise to such a limit.  But it's uint32 now,  
so you'd hit the 1GB varlena limit well before overflowing that.)  
  
While at it, re-order the bullet points into an order that makes  
more sense, to me anyway.  
  
Reported-by: Claude Code (via Noah Misch)  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/455079.1786897319@sss.pgh.pa.us  
Backpatch-through: 14  

M doc/src/sgml/textsearch.sgml

Tighten up tsqueryrecv().

commit   : 05556bdf938db0f4b87f3852cd5802fb71a13263    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Aug 2026 18:09:07 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Aug 2026 18:09:07 -0400    

Click here for diff

tsqueryrecv() accepted zero-length lexemes, which tsqueryin() doesn't.  
It also accepted phrase distance values larger than MAXENTRYPOS,  
which tsqueryin() doesn't.  While neither of these omissions are  
very harmful in themselves, they do allow accepting tsquery values  
that will fail in a subsequent textual dump/reload.  
  
Commit 23d9ad771 performed similar tightening of tsvectorrecv(),  
but I left off these changes at the time because they didn't seem  
to have security implications.  
  
Reported-by: Claude Code (via Noah Misch)  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/455079.1786897319@sss.pgh.pa.us  
Backpatch-through: 14  

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

GiST: Deprecate F_TUPLES_DELETED opaque area flag.

commit   : 9d2d3bd079f90aaf05988ef61de6a7b8d0118c70    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 17 Aug 2026 17:31:01 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 17 Aug 2026 17:31:01 -0400    

Click here for diff

This flag hasn't been useful since the removal of old-style VACUUM FULL,  
so remove it now (this includes removing vestigial code that  
unnecessarily set the flag).  
  
Also add test coverage of gistprunepage().  Had that test case been  
available before now, the issue fixed by this commit would have been  
detected by wal_consistency_checking buildfarm animals.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Michael Paquiër <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAH2-WznbTsQCrjmd=eSawfPqcxCjSFUkk6Qzd3z+gpNte5i03Q@mail.gmail.com  
Backpatch-through: 14  

M src/backend/access/gist/gistvacuum.c
M src/backend/access/gist/gistxlog.c
M src/include/access/gist.h
M src/test/regress/expected/gist.out
M src/test/regress/sql/gist.sql

Make plperl's handling of Perl arrays safer and more consistent.

commit   : ede3188e118f81ea933ac5d64866190024f678a7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Aug 2026 15:06:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Aug 2026 15:06:02 -0400    

Click here for diff

plperl_func_handler()'s stanza for handling an arrayref result in  
a SETOF function could loop forever (or at least till OOM) when  
given a tied array, since av_fetch won't necessarily ever return  
a null pointer in that case.  Be consistent with the other places  
where we traverse a perl array: call av_len() once and use len+1  
as the loop limit, silently ignoring any null pointers we get back  
from that range of subscripts.  
  
But actually, Perl's preferred locution for this seems to be to  
use av_count() not av_len()+1.  av_count() seems better since  
there's less risk of forgetting to add 1.  Also, both of those  
functions return Size_t (or SSize_t) not int, creating at least  
a theoretical overflow hazard.  While we're modernizing this,  
let's use the correct variable type where we can, and include an  
overflow check where we can't.  
  
Reported-by: Claude Code (via Noah Misch)  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Discussion: https://postgr.es/m/569769.1786901901@sss.pgh.pa.us  
Backpatch-through: 14  

M contrib/jsonb_plperl/jsonb_plperl.c
M src/pl/plperl/plperl.c

doc: Clarify the logging collector's guarantees.

commit   : a92fbdfb830046e907813e9067b2c9de9708d600    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 14 Aug 2026 15:27:16 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 14 Aug 2026 15:27:16 -0500    

Click here for diff

Presently, the documentation for logging_collector says that the  
collector "is designed to never lose messages," which reads as a  
stronger promise than we actually make.  The collector does not  
fsync the log file or retry failed writes, so log messages can go  
missing after an operating system crash, power loss, or a write  
error.  Reword that sentence and add a note about what is not  
guaranteed.  
  
Author: Daniel Bauman <danielbaniel@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Zhenwei Shang <a934172442@gmail.com>  
Reviewed-by: Robert Treat <rob@xzilla.net>  
Discussion: https://postgr.es/m/CAMtj0_a86DdDKkW-ReVpQpqjndVS6GMrwXVpQY4G3-SGY7saMQ%40mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/config.sgml

Add missing PGDLLIMPORT marker.

commit   : bcc9d9ffe6edeedf71a2a5b45dcb906b128a7d21    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 14 Aug 2026 13:41:32 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 14 Aug 2026 13:41:32 -0500    

Click here for diff

Oversight in commit ffca23839c.  
  
Reported-by: Anton Voloshin <a.voloshin@postgrespro.ru>  
Author: Anton Voloshin <a.voloshin@postgrespro.ru>  
Backpatch-through: 14  

M src/include/utils/acl.h

psql: count every COPY FROM STDIN when scanning a query string.

commit   : f1204c1a798565c24f645503c43135a1372e9d2b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 14 Aug 2026 12:14:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 14 Aug 2026 12:14:24 -0400    

Click here for diff

When SendQuery() is not told how many COPY FROM STDIN commands the  
query string contains (as for -c, \gexec, and \watch), it scans the  
string to count them itself.  But it called psql_scan() only once,  
which stops at the first semicolon, so any COPY FROM STDIN past the  
first sub-command was not counted, causing failure of cases that used  
to work.  Oversight in commit 3045a25ba.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAN4CZFPqa6c+u4uX5jJ8LANHTQ4dxM3m4_8G9WmX_A4-2wuv2A@mail.gmail.com  
Backpatch-through: 14  

M src/bin/psql/common.c

Consistently enforce tsvector/tsquery maximum lengths.

commit   : 39cad0de4ac3a6d211e1ad00bc1af061a753b414    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 13 Aug 2026 11:20:27 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 13 Aug 2026 11:20:27 -0400    

Click here for diff

Some places rejected individual tokens longer than MAXSTRLEN, while  
others rejected ones longer than MAXSTRLEN-1.  The data structure is  
perfectly capable of handling MAXSTRLEN, so there's nothing wrong  
with using the looser bound.  Moreover, as things stand there is a  
dump/reload hazard: some code paths permit construction of a tsvector  
or tsquery that would later be rejected by tsvectorin or tsqueryin.  
So standardize on using MAXSTRLEN.  
  
Identical remarks apply to MAXSTRPOS (the total data length),  
so fix that too.  
  
Back-patch, in hopes of avoiding cases where a value acceptable to  
one supported release is not acceptable to another.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFNYQo4zfbRR435uD0vSfuy5y7dnFOXDfKr9zYoL1JnAxA@mail.gmail.com  
Backpatch-through: 14  

M src/backend/tsearch/ts_parse.c
M src/backend/utils/adt/tsquery.c
M src/backend/utils/adt/tsvector.c
M src/backend/utils/adt/tsvector_op.c

Fix poll_query_until() timeout handling with an undefined query in Cluster.pm

commit   : d47336e5f6f1f20b4522d6073c30c6dbd5b07fb6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 16:23:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 16:23:21 +0900    

Click here for diff

On timeout, poll_query_until() would fail to print its report when  
"$query" was undefined.  Instead of the expected report, this prevented  
the contents of stdout and stderr from being shown.  
  
Note that some of the in-core tests use an undefined query for  
connection-only polls.  
  
Author: Bryan Green <dbryan.green@gmail.com>  
Reviewed-by: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>  
Discussion: https://postgr.es/m/0f515c6d-6032-4c5f-80ac-5c78faae9522@gmail.com  
Backpatch-through: 14  

M src/test/perl/PostgresNode.pm

Tweak allocation rule for tzload()'s "union local_storage" variable.

commit   : 2e29cb3b815df71f02158dbe538ca7906291aa5c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 11 Aug 2026 18:17:48 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 11 Aug 2026 18:17:48 -0400    

Click here for diff

By default, allocate this via malloc, as we've been doing since commit  
62c8421e8.  Commit aeb07c55f adopted upstream tzdb's default of  
allocating it on the stack, but that still doesn't seem like a good  
idea for the reasons given in 62c8421e8 (and now memorialized in a  
comment, in hopes that we don't make the same mistake again).  
  
However, under USE_VALGRIND, put it on the stack as upstream does.  
This accidentally prevents a crash when Python 3.14 is used under  
Valgrind.  The reasons for that are obscure, and it's most likely  
not our bug, and even if we figured it out it'd be nice to have a fix  
for buildfarm member skink now rather than after persuading the guilty  
party to fix it.  
  
In the normal non-USE_VALGRIND case, this has no effect on the logic  
in released branches, and it reverts master to match them.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/f071e691-5930-4738-9dbd-43ed2da367fe@gmail.com  
Backpatch-through: 14  

M src/timezone/localtime.c