PostgreSQL 20.0 (upcoming) commit log

Fix some typos in comments

commit   : 4a934833fb02ac2a18d0a3f86b67b493d7fe8979    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 20:03:57 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 20:03:57 +0900    

Click here for diff

These errors have been reported to the mailing lists in the last few  
weeks.  A similar batch of fixes has been done in be00f041a331.  

M contrib/pg_plan_advice/expected/semijoin.out
M contrib/pg_plan_advice/sql/semijoin.sql
M src/backend/access/transam/xlog.c
M src/backend/executor/nodeModifyTable.c
M src/bin/pg_dump/compress_lz4.c

JSON_TABLE: fix missing collation assignments

commit   : e405a46c45bae070364ed143fb9d5a631422e5e4    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 6 Nov 2026 16:18:23 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 6 Nov 2026 16:18:23 +0900    

Click here for diff

transformJsonTable() transforms the context item and the PASSING  
arguments into the JsonExpr stored in TableFunc.docexpr, and copies the  
transformed PASSING arguments into TableFunc.passingvalexprs, but never  
ran assign_expr_collations() over them.  That is needed here because  
assign_query_collations() doesn't look into the range table, which is  
why transformRangeTableFunc() does it for XMLTABLE, as does  
transformJsonTableColumn() for JSON_TABLE's own column expressions.  
  
As a result, expressions in there were left without collations.  A text  
comparison failed with "could not determine which collation to use for  
string comparison", even with an explicit COLLATE clause, and a row  
comparison was left with an empty inputcollids list, which made the  
executor compare zero columns and return the result for equal rows (so  
ROW(1, 2) < ROW(3, 4) yielded false), or trip an assertion in  
ExecInitExprRec() in assert-enabled builds.  
  
Fix by calling assign_expr_collations() on the transformed JsonExpr,  
before the PASSING arguments are copied out of it.  
  
Oversight in commit de3600452b6, so back-patch to 17.  
  
Bug: #19768  
Reported-by: Venu Kummari <venu2805k@gmail.com>  
Author: Venu Kummari <venu2805k@gmail.com>  
Discussion: https://postgr.es/m/19768-3633daa830be95db@postgresql.org  
Backpatch-through: 17  

M src/backend/parser/parse_jsontable.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

Fix crash with single-input aggregates with multiple sort keys

commit   : edbe7ffdc8afe7f3c12675df6ef614bcd5017b3f    
  
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

ci: Make msys2 install smaller

commit   : f8cabd1f175f60cbf2f6249b5193c6a6412e07fb    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Thu, 5 Nov 2026 21:50:55 -0500    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Thu, 5 Nov 2026 21:50:55 -0500    

Click here for diff

We only needed git and diffutils installed via pacman because the already  
installed tools were hidden by the login script resetting PATH. "Fix" that  
instead by telling msys to leave the old PATH around.  
  
Also don't install libbacktrace, it is not needed at the moment.  
  
This commit is backpatched to 19 to keep CI between master and 19 the  
same. Soon we'll backpatch CI support to regain coverage with lost with  
cirrus-ci's shutdown.  
  
Author: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/a2ejn7lfqolutzz7kozalbhy3bixdrujb4buc3pgbtlk4am2ba@wbv6v7riia33  
Discussion: https://postgr.es/m/CAN55FZ1BcWBsWgCCk2GQkYN6tzDxCw2hVK2m3qeiwaNXUnjLVg@mail.gmail.com  
Backpatch-through: 19  

M .github/workflows/pg-ci.yml

Fix wrong results of some window functions with IGNORE NULLS.

commit   : b8d82d178758b6e956ee02af512bbd949c335cc2    
  
author   : Tatsuo Ishii <ishii@postgresql.org>    
date     : Fri, 6 Nov 2026 14:22:19 +0900    
  
committer: Tatsuo Ishii <ishii@postgresql.org>    
date     : Fri, 6 Nov 2026 14:22:19 +0900    

Click here for diff

Window functions such as lead() and lag() could return wrong results  
if IGNORE NULLS is specified and the offset argument is equal to  
INT_MIN.  
  
WinGetFuncArgInPartition() used abs() to get the absolute value of the  
offset argument. If it is INT_MIN (-2147483648), the return value of  
abs() is undefined. Typically it returns INT_MIN. However,  
WinGetFuncArgInPartition() was not prepared for the case and returns  
wrong result. To fix this, use pg_abs_s32() instead of abs() to return  
2147483648, instead of -2147483648.  
  
ignorenulls_getfuncarginframe() has the same problem. So this commit  
fixes them as well. Note that currently no built in window function  
hits the bug because only nth_value() has the offset argument and it  
does not accept negative offset. However, WinGetFuncArgInFrame(), the  
caller of ignorenulls_getfuncarginframe(), is a public API, we should  
prepare the similar case when user defined window functions use it.  
  
Moreover, this commit changes some internal variable data types from  
int to int64 in order to prevent an overflow while calculating a row  
position in the partition.  
  
Also add regression test cases to window.sql.  
  
Author: jian he <jian.universality@gmail.com>  
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Discussion: https://postgr.es/m/CACJufxH2_4ucJ58_YQPin8E8hf2RRD6S7rA-UK9pSWxdg7YBQw%40mail.gmail.com  
Backpatch-through: 19  

M src/backend/executor/nodeWindowAgg.c
M src/test/regress/expected/window.out
M src/test/regress/sql/window.sql

pgrowlocks: Reject unlogged and temp tables during recovery

commit   : 3c5a4dcaaa8d5bef429bd8143d1a6e9f92fa0b74    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 14:01:31 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 14:01:31 +0900    

Click here for diff

Unlogged and temporary tables have no data on a standby, and attempting  
to use pgrowlocks() in this case led to this failure:  
  
ERROR:  could not open file "base/MMM/NNN": No such file or directory  
  
These cases are now checked, failing with a proper failure.  Temporary  
tables from other sessions cannot be accessed, as the streaming read  
APIs prevent that already.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Discussion: https://postgr.es/m/82ba0876-6127-4770-b900-aa1bd52abfed@uni-muenster.de  

M contrib/pgrowlocks/pgrowlocks.c

Fix indentation in 69b20fdd20d.

commit   : 46ed1b831fa1e2ebb95f52c939577db560c0d3a6    
  
author   : Tatsuo Ishii <ishii@postgresql.org>    
date     : Fri, 6 Nov 2026 12:57:31 +0900    
  
committer: Tatsuo Ishii <ishii@postgresql.org>    
date     : Fri, 6 Nov 2026 12:57:31 +0900    

Click here for diff

Reported-by: Richard Guo <guofenglinux@gmail.com>  
Backpatch-through: 19  

M src/backend/executor/nodeWindowAgg.c

pg_visibility: Restrict access to more relation types

commit   : 1ed083f90d29871b21d5b3d2351accf4a0d9ca81    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 12:08:25 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 12:08:25 +0900    

Click here for diff

Temporary relations of other sessions have their own local pages.  
Temporary and unlogged relations have no storage during recovery.  
pg_visibility did not check for either cases, leading to inconsistent  
results or confusing error messages, like some "ERROR: could not open  
file".  
  
This commit adds checks for both cases, so as a clean errors are  
returned instead of the previous mix of incorrect results or errors,  
depending on the function called and the relation whose information is  
requested.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Discussion: https://postgr.es/m/82ba0876-6127-4770-b900-aa1bd52abfed@uni-muenster.de  

M contrib/pg_visibility/pg_visibility.c

ci: Get build/test concurrency from environment

commit   : 8736129a48e4dff243fb1f297e4b6f10bedec72a    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Thu, 5 Nov 2026 21:49:51 -0500    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Thu, 5 Nov 2026 21:49:51 -0500    

Click here for diff

Previously we hardcoded the amount of concurrency in the CI definition. This  
practice IIRC originated from a) using make, where the concurrency is not  
sourced from the current system b) early cirrus-ci macos runners, which slowed  
down a lot with full concurrency.  
  
Hardcoding the concurrency is problematic as e.g. private repositories have  
lower concurrency and larger github runners have more cores.  
  
For most of the jobs we can rely on just using meson's and ninja's logic for  
getting the current core count. For the autoconf build we can use the nproc  
helper.  
  
To make this at least somewhat understandable, I extended the existing sysinfo  
step to show the number of cores (and made it a bit easier to understand the  
information already printed).  
  
This commit is backpatched to 19 to keep CI between master and 19 the  
same. Soon we'll backpatch CI support to regain coverage with lost with  
cirrus-ci's shutdown.  
  
Author: Andres Freund <andres@anarazel.de>  
Co-authored-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://postgr.es/m/a2ejn7lfqolutzz7kozalbhy3bixdrujb4buc3pgbtlk4am2ba@wbv6v7riia33  
Discussion: https://postgr.es/m/CAN55FZ1BcWBsWgCCk2GQkYN6tzDxCw2hVK2m3qeiwaNXUnjLVg@mail.gmail.com  
Backpatch-through: 19  

M .github/workflows/pg-ci.yml

Revert "Fix use-after-free in COPY (ON_ERROR)"

commit   : c07545dfe1a9c996d750b4676c6031334a1a2ef7    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 10:45:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 10:45:03 +0900    

Click here for diff

This reverts commit 23e2a332dd24.  It looks like it is going to need a  
little bit more work, and v19 RC2 is close by.  
  
Backpatch-through: 17  

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

doc: Improve output_plugin_libraries documentation

commit   : 48564a9bab04b03a1b37b5094ddea19151eb019a    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:53:07 -0800    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:53:07 -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   : 161d5ffcc5c2f446df528bd273de822b86965d92    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:52:56 -0800    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 5 Nov 2026 16:52:56 -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_parameters.dat
M src/include/utils/guc_hooks.h
M src/test/regress/expected/guc.out
M src/test/regress/sql/guc.sql

Detach injection point at the end of repack_dropped isolation test.

commit   : 92a74e26bbed36055e7776b354ea3d3118aafd75    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 5 Nov 2026 16:49:55 -0800    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 5 Nov 2026 16:49:55 -0800    

Click here for diff

Commit e5d25959cf8 added the repack_dropped isolation test, which  
attaches the injection point repack-concurrently-before-lock as a  
local one but doesn't detach it. The injection point is then detached  
only when the session's backend exits, and isolationtester doesn't  
wait for that before starting the next test. If the backend is slow to  
exit, the next test that attaches the same injection point, currently  
repack_missingval, fails with an "already defined" error.  
  
Fix by detaching it in the session's teardown, as the other REPACK  
tests do. Since the session that attached the injection point detaches  
it, the exiting backend no longer touches it.  
  
Reported-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/8ccd0497-c914-47e2-804d-299b678863bf@gmail.com  
Backpatch-through: 19  

M src/test/modules/injection_points/expected/repack_dropped.out
M src/test/modules/injection_points/specs/repack_dropped.spec

Fix mismatched PHVs for join alias Vars flattened more than once

commit   : f1e97a2921072898a10054c577d655a3a196f98a    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 6 Nov 2026 09:37:43 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 6 Nov 2026 09:37:43 +0900    

Click here for diff

When a join alias Var with nonempty varnullingrels expands to an  
expression that cannot carry the nullingrels itself,  
add_nullingrels_if_needed wraps it in a PlaceHolderVar with a new  
phid.  If copies of the same unexpanded alias Var are flattened by  
separate flatten_join_alias_vars calls, each call makes its own PHV,  
so the copies no longer match.  Only one of the PHVs then gets a  
PlaceHolderInfo, and the others usually lead to errors when creating  
the plan, such as "too late to create a new PlaceHolderInfo" or  
"variable not found in subplan target lists".  Worse, if an unmatched  
copy is nested inside another PHV, setrefs.c can quietly compute its  
expression above the outer join that should null it, giving wrong  
results.  
  
Such copies can arise in several ways.  When a LATERAL UNION ALL  
subquery is pulled up as an appendrel, its lateral references live on  
both in the parent RTE's subquery, which find_lateral_references  
examines on the assumption that the children are exact copies of parts  
of it, and in the child rels, which are what actually get planned.  A  
PHV made by pullup_replace_vars for a lateral reference can be copied  
into both the targetlist and the quals of the query, which are  
flattened separately.  And pull_up_simple_subquery flattens the  
subquery's targetlist, and its jointree quals if it is LATERAL, using  
the subroot, while the rest of the subquery is flattened later by  
subquery_planner using the parent root.  
  
To fix, keep the PHVs made by add_nullingrels_if_needed in a new  
PlannerInfo field, and reuse one whenever the same expression is  
expanded again with the same phrels, as pullup_replace_vars_callback  
does with its rv_cache.  When pull_up_simple_subquery pulls up a  
subquery, adjust the subroot's list in the same way as its  
append_rel_list and add it to the parent's, so that the parent's  
flattening reuses the subroot's PHVs.  This makes all expansions of  
the same join alias share one phid, however the copies came about.  
  
This bug dates back to v16, where add_nullingrels_if_needed was  
introduced.  But the fix needs a new PlannerInfo field, and several  
extensions allocate their own PlannerInfo, so adding it in released  
branches risks breaking them.  Hence, back-patch to v19 only, which  
has not been released yet.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAMbWs4_tg90KxNVdABpBnx2oGBQTCAHAV45mPEfCdKvo11ZEVQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/util/var.c
M src/include/nodes/pathnodes.h
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Fix use-after-free in COPY (ON_ERROR)

commit   : 23e2a332dd24c6b67f4a9bdbb3e0dbdb0a527156    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 09:18:35 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 6 Nov 2026 09:18:35 +0900    

Click here for diff

When ON_ERROR handled a soft error, some of the contents set for the  
error context callback could remain set and pointing at areas that could  
be reset, leading to some use-after-frees depending on the input data  
provided through COPY.  
  
These contents are now reset at the beginning of NextCopyFrom(), before  
processing the next tuple.  
  
SET_NULL is affected down to v19, IGNORE down to v17.  
  
Author: Gowdham M <gowdham.m@zohocorp.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/1a181ff6be8.6d14feb261368.4036709598649280477@zohocorp.com  
Backpatch-through: 17  

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

Stabilize 051_effective_wal_level.pl.

commit   : f1e25929e2ff234ee8d461b6918551943c75813a    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 5 Nov 2026 16:16:45 -0800    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 5 Nov 2026 16:16:45 -0800    

Click here for diff

Several tests in 051_effective_wal_level.pl quit a background psql  
session that attached a local injection point and then immediately  
start another session that attaches the same injection point. A local  
injection point is detached only when its backend exits, and quitting  
the background psql session doesn't wait for that. So if the old  
backend is slow to exit, the new session fails to attach the injection  
point because it is still defined, and the test times out waiting for  
a backend to stop at it.  
  
Fix by waiting for the old backend to disappear from pg_stat_activity  
view after quitting the session. Detaching the injection point before  
quitting isn't enough, because the exiting backend still detaches it  
by name and could remove the one the next session has just attached.  
  
Per buildfarm member melonworm.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/8ccd0497-c914-47e2-804d-299b678863bf@gmail.com  
Backpatch-through: 19  

M src/test/recovery/t/051_effective_wal_level.pl

Fix infinite loop in first_value()/nth_value() with IGNORE NULLS.

commit   : 69b20fdd20de68b0f0eaa855669a6657c65c8533    
  
author   : Tatsuo Ishii <ishii@postgresql.org>    
date     : Fri, 6 Nov 2026 08:56:29 +0900    
  
committer: Tatsuo Ishii <ishii@postgresql.org>    
date     : Fri, 6 Nov 2026 08:56:29 +0900    

Click here for diff

ignorenulls_getfuncarginframe() walks the frame row by row looking for  
the n-th non-null value.  It calls row_is_in_frame() on each position  
without first checking that the position is inside the partition,  
although row_is_in_frame() requires its caller to have done so ("The  
caller must have already determined that the row is in the  
partition").  When the frame ends at UNBOUNDED FOLLOWING,  
row_is_in_frame() has no end-of-frame test, and with EXCLUDE GROUP (or  
EXCLUDE TIES, for rows other than the current one) and no ORDER BY it  
returns 0 ("excluded") for every position, including positions past  
the last row.  The loop then never calls window_gettupleslot(), which  
is what would have noticed the end of the partition, and it advances  
abs_pos forever.  The fix checks the partition end before calling  
row_is_in_frame(), the same way window_gettupleslot() does  
(spool_tuples(), then compare with spooled_rows).  It also adds  
CHECK_FOR_INTERRUPTS() at the top of the loop: the loop can pass over  
many excluded or known-NULL rows without fetching any tuple, and  
window_gettupleslot() is where the interrupt check normally happens.  
  
Author: BHUVAN CHILUKUTI <c.bhuvan@iitg.ac.in>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>  
Discussion: https://postgr.es/m/PN0P287MB09038F3BD9921EBACF5646F6A7632%40PN0P287MB0903.INDP287.PROD.OUTLOOK.COM  
Backpatch-through: 19  

M src/backend/executor/nodeWindowAgg.c
M src/test/regress/expected/window.out
M src/test/regress/sql/window.sql

oauth: Reject quoted empty string in validator config

commit   : 8cb6b83e12043c1c91640716fb67d2ad0b988e95    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 5 Nov 2026 21:43:55 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 5 Nov 2026 21:43:55 +0100    

Click here for diff

Commit bca67e5a3 added checking for blank validator configuration, this  
completes that work by checking for a quoted empty string as well.  
  
Backpatch down to v18 like bca67e5a3.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFP7ZMLB5Q1P4H__2d54om6fO+OEBZpWLpMwhFipobrEEw@mail.gmail.com  
Backpatch-through: 18  

M src/backend/libpq/auth-oauth.c
M src/test/modules/oauth_validator/t/001_server.pl

Teach pg_upgrade to skip invalid databases.

commit   : 37a7664a9204a7fafa04553e906aa0ae9f4a91c3    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 5 Nov 2026 14:28:10 -0600    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 5 Nov 2026 14:28:10 -0600    

Click here for diff

If DROP DATABASE is interrupted at the wrong moment, it leaves the  
pg_database row behind, but it is marked as invalid, i.e.,  
datconnlimit is set to -2.  Such databases cannot be connected to,  
and there is no supported recovery mechanism (besides of course  
restoring a backup to a time before the DROP DATABASE command).  
The only thing that a user can do is run DROP DATABASE on them  
again.  
  
Currently, pg_upgrade checks for invalid databases and refuses to  
proceed if any exist.  This commit teaches pg_upgrade to instead  
simply skip them.  The pg_database row and any associated files  
won't be transferred; the invalid database will just cease to exist  
on the newly upgraded cluster.  We should probably try to  
automatically drop invalid databases during normal operation, too,  
but that is left as a future exercise.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACV3jSPaMCSRQ8XZTN_meZezNyySpMJVhVBZy_qDJK2mmQ%40mail.gmail.com  

M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/info.c
M src/bin/pg_upgrade/t/002_pg_upgrade.pl

Remove obsolete comment from AddBufferToRing()

commit   : 8e997cb8c9ecc27e55e38bb42f1cefd5ef74c9a0    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 5 Nov 2026 17:06:33 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 5 Nov 2026 17:06:33 +0200    

Click here for diff

Commit 5e899859287 changed StrategyGetBuffer() to pin buffers using  
CAS without acquiring the buffer header lock, but left  
AddBufferToRing()'s comment about the lock unchanged. Remove the stale  
paragraph.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Discussion: https://www.postgresql.org/message-id/17F7E4A7-AE49-4F2F-B4C7-57107CBB83F1@gmail.com  
Backpatch-through: 19  

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

Handle numeric overflow when handling range values

commit   : d06ac896faa7ff14e6eca5c9bc27a34818adf634    
  
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

oauth: Recheck oauth_validator_libraries during authentication

commit   : e352ac8c5c90ed6ce792f044c22145578542a330    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 5 Nov 2026 14:14:01 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 5 Nov 2026 14:14:01 +0100    

Click here for diff

The validator allowlist is only enforced while parsing pg_hba.conf.  
If changing oauth_validator_libraries makes an existing oauth line  
invalid, the HBA reload fails and the old lines stay in use, so a  
removed validator keeps authenticating users.  In particular, when  
setting the list to the empty string, the server doesn't refuse an  
OAuth connection, as documented.  
  
Backpatch down to v18 where OAuth was introduced.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFNbWXwC=s4t9Xu1kitLsQvTe-EwpVtFCjixWCHBxRTraQ@mail.gmail.com  
Backpatch-through: 18  

M src/backend/libpq/auth-oauth.c
M src/test/modules/oauth_validator/t/001_server.pl

Use branchless comparisons in btint4cmp and btint8cmp, for speed

commit   : 41467b1d88303fbaea4ddd20c21ac4b8ce6b92d7    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 5 Nov 2026 13:56:15 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 5 Nov 2026 13:56:15 +0200    

Click here for diff

The comment on pg_cmp_*() points out that the old form can produce  
better code if the comparison is inlined, but that's not a concern  
here because btint4cmp() and btint8cmp() are invoked through the  
function manager and won't be inlined.  
  
Author: David Geier <geidav.pg@gmail.com>  
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Discussion: https://www.postgresql.org/message-id/5d366878-2007-4d31-861e-19294b7a583b@gmail.com  

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

Fix stale visibility maps in incremental backups after heap truncation

commit   : b5545d3f5f924289051eb8221c88e72563771928    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 5 Nov 2026 18:06:25 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 5 Nov 2026 18:06:25 +0900    

Click here for diff

An incremental backup taken after VACUUM truncates a table can restore  
stale visibility map bits when both data checksums and wal_log_hints are  
disabled. If the restored table grows again, the stale bits can cause  
VACUUM to skip required freezing and advance relfrozenxid past unfrozen  
tuples, or cause index-only scans to return deleted rows.  
  
Heap truncation clears bits for removed heap pages in the last remaining  
VM page. With both settings disabled, that page is not separately  
WAL-logged. The WAL summarizer records the VM truncation limit but does  
not mark the remaining page as modified, allowing incremental backups  
to reuse its old contents. The truncation record precedes the incremental  
backup's start LSN, so recovery does not replay it to clear those bits.  
  
Fix this by marking the last remaining VM page as modified when  
summarizing a truncation record, so incremental backups include its  
current contents. Do this conservatively even when truncation falls on  
a VM page boundary and the remaining page does not need to change.  
  
Note that existing WAL summaries are not regenerated by this fix.  
Incremental backups taken after updating can therefore still be affected  
if they use summaries generated before the fix. Take a new full backup  
from an uncorrupted server after updating and use it as the basis for  
subsequent incremental backups. This does not repair existing backups  
or corruption already present in a restored database.  
  
Backpatch to PostgreSQL 17, where incremental backup was introduced.  
  
Bug: #19775  
Author: Ke <kehan5800@gmail.com>  
Co-authored-by: Fujii Masao <masao.fujii@gmail.com>  
Co-authored-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/19775-087aebfa1a709b09@postgresql.org  
Discussion: https://postgr.es/m/CAGRkXqSnghF+wbyP-PdfjVLfbejJG3cvZd9hN-gxsvCWj2F64Q@mail.gmail.com  
Backpatch-through: 17  

M src/backend/postmaster/walsummarizer.c
M src/bin/pg_combinebackup/meson.build
A src/bin/pg_combinebackup/t/014_vm_truncation.pl

Fix io_uring resource leaks across crash restarts

commit   : 953c6dabdb52663a6b96ad354b33496284d8ed73    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 5 Nov 2026 18:02:22 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 5 Nov 2026 18:02:22 +0900    

Click here for diff

With io_method=io_uring and restart_after_crash enabled, the postmaster  
reinitializes shared memory after a backend crash. It created new  
io_uring instances without releasing its references to the old ones,  
causing resources to accumulate on each crash restart. Eventually,  
creating new instances could fail with "Too many open files" or  
"Cannot allocate memory", preventing the server from restarting.  
  
Fix this by registering an on_shmem_exit() callback to release the  
postmaster's references to the io_uring instances during shared  
memory cleanup, before creating new ones. This prevents resources  
from accumulating across crash restarts.  
  
Backpatch to v18, where io_method=io_uring was introduced.  
  
Reported-by: Lucas DRAESCHER <git@draescher.fr>  
Author: Lucas DRAESCHER <git@draescher.fr>  
Reviewed-by: ChangAo Chen <cca5507@qq.com>  
Reviewed-by: Ilmar Yunusov <tanswis42@gmail.com>  
Reviewed-by: Laetitia Avrot <laetitia.avrot@gmail.com>  
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/zHN8Rb7syWYDBPUhCICxKLr_tQmFLg0T024irxVVb6RSSicZcqcA0eT73z2PQy7JmzzqnUzX0Hi3P2dPKRvmNx_jbAqSCLyqJvWjXEypyAI=@draescher.fr  
Backpatch-through: 18  

M src/backend/storage/aio/method_io_uring.c

Remove hash_freeze()

commit   : b3dbde59376f66e063ceacc03b6d2102825de692    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 5 Nov 2026 09:31:56 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 5 Nov 2026 09:31:56 +0100    

Click here for diff

hash_freeze() was added by a2e923a652.  Its only caller was  
execGrouping.c, which stopped using dynahash in 5dfc198146.  Nothing  
in the tree has called the function since, so remove it.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/flat/CAJ7c6TPGc1eXGp%2BtzjfVBZnSCmYkdMozKaGxDhVaw5xHdGaeUA%40mail.gmail.com  

M src/backend/utils/hash/dynahash.c
M src/include/utils/hsearch.h

SQL/JSON: Fix NULL result leakage in JSON_VALUE() RETURNING json/jsonb

commit   : 627c4df3b73ae00a0dfd08f4216514fb9ea44b5d    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 5 Nov 2026 12:24:43 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 5 Nov 2026 12:24:43 +0900    

Click here for diff

Once JSON_VALUE(... RETURNING json/jsonb) returned NULL, every later  
evaluation of the same expression in the same statement also returned  
NULL, even for inputs that had a valid value.  
  
In ExecEvalJsonExprPath(), the JSON_VALUE_OP branch for RETURNING json  
or jsonb converts the matched item to its string form but, unlike the  
sibling branches, never sets *op->resnull to false.  So a NULL result  
from a previous evaluation, whether due to a JSON null item, an empty  
match, or an error handled by NULL ON ERROR, remained in effect.  That  
caused the subsequent coercion via the type's input function, which is  
guarded by that flag, to be skipped, and the valid item to be returned  
as SQL NULL.  The result thus depended on what earlier rows, or earlier  
expressions sharing the same ExprState, had returned.  
  
Fix by setting *op->resnull to false in that branch.  Also add a  
comment noting that ExecGetJsonValueItemString() takes care of that  
in the final branch.  
  
Oversight in commit 6185c9737cf, so back-patch to 17.  
  
Bug: #19695  
Reported-by: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com>  
Author: Srinath Reddy Sadipiralla <srinath2133@gmail.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/19695-2f2c573ef1660737@postgresql.org  
Backpatch-through: 17  

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

Avoid resetting subscription two_phase state to pending when already enabled.

commit   : fc1900915b140aaed33fdcccdf85eec1a0035755    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 5 Nov 2026 09:49:17 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 5 Nov 2026 09:49:17 +0530    

Click here for diff

ALTER SUBSCRIPTION ... SET (two_phase = true) always moved the  
subscription's two_phase state to pending, even if two_phase was already  
enabled. The publisher's slot still has two_phase enabled in that case,  
and prepared transactions may already exist on the subscriber, so the  
reset broke checks that rely on the enabled state:  
  
1. A later SET (two_phase = false) no longer checked for existing prepared  
transactions and disabled two_phase anyway. When those transactions were  
committed on the publisher, their changes were re-sent as regular  
transactions instead of COMMIT PREPARED, leading to self-deadlocks,  
duplicate data, or orphaned prepared transactions.  
  
2. REFRESH PUBLICATION (and SET/ADD PUBLICATION) with copy_data = true was  
allowed even though the publisher's slot still had two_phase enabled. This  
could stream prepared transactions during the initial sync of newly added  
tables and apply them as empty prepares.  
  
Fix this by leaving the state unchanged when two_phase is already enabled.  
  
This problem was introduced by commit 1462aad2e44, which allowed altering  
the two_phase option of a subscription.  
  
This changes behavior when slot_name is altered together with SET  
(two_phase = true) on an ENABLED subscription. Previously the state was  
reset to PENDING and the apply worker enabled two_phase on the replacement  
slot. Now the state stays ENABLED and the apply worker does not touch the  
replacement slot's two_phase property. This is intentional: resetting the  
state would reintroduce the problems described above, since prepared  
transactions from the old slot may still exist on the subscriber. The  
documentation already requires the replacement slot's two_phase property  
to match the subscription option.  
  
Author: Zhijie Hou <houzhijie22@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/8e85abdf-738b-4578-ac42-4dc8eaa061dd@gmail.com  
Backpatch-through: 18  

M src/backend/commands/subscriptioncmds.c
M src/test/subscription/t/021_twophase.pl

Add stats kind filter to pgstat_drop_matching_entries()

commit   : 31f89191ff7b22b6c69ae5f3c6ab48c5d8bb0f2b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 5 Nov 2026 09:13:49 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 5 Nov 2026 09:13:49 +0900    

Click here for diff

pgstat_drop_matching_entries() scans all variable-numbered stats hash  
tables.  Some callers already know which stats kind they want to scan,  
and such a kind may have its own dshash.  
  
pgstat_drop_matching_entries() is upgraded with a stats kind argument.  
PGSTAT_KIND_INVALID preserves the existing all-kinds behavior, while a  
specific kind scans the hash mapped to that kind.  When that hash is  
shared by multiple stats kinds, entries are filtered by kind before  
invoking the match callback, or applying the drop-all behavior if no  
match callback is defined.  
  
An immediate motivation is pg_stat_statements, where some follow-up work  
can use this to drop matching entries from its stats kind, without  
having to scan all the stats hastables.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAN12+YL7SrAwzMpzfNLrVcy=w5L03p7czyO73RfS06kmdqs_fw@mail.gmail.com  

M src/backend/utils/activity/pgstat_shmem.c
M src/include/utils/pgstat_internal.h
M src/test/modules/test_custom_stats/t/001_custom_stats.pl
M src/test/modules/test_custom_stats/test_custom_var_stats–1.0.sql
M src/test/modules/test_custom_stats/test_custom_var_stats.c

SQL/JSON: Fix ON EMPTY/ERROR state leakage on NULL input

commit   : ee7cfb99a34cfba1cffdd456dc269243ddc69f3b    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 5 Nov 2026 08:38:15 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 5 Nov 2026 08:38:15 +0900    

Click here for diff

ExecInitJsonExpr() emitted JUMP_IF_NULL steps to skip the  
EEOP_JSONEXPR_PATH step when either the context item or the path  
expression was NULL, landing on a CONST step that returned NULL.  
However, ExecEvalJsonExprPath(), which implements EEOP_JSONEXPR_PATH,  
was also the only place where JsonExprState's empty and error flags  
got reset for a new row.  Skipping it left the flags as the previous  
row had set them, and since execution then fell through the  
ON EMPTY / ON ERROR steps that check those flags, a NULL-input row  
returned the previous row's ON EMPTY / ON ERROR expression instead of  
NULL, making the result depend on the order of the input rows.  
  
This could only happen when ExecInitJsonExpr() had emitted the  
ON EMPTY / ON ERROR steps for the NULL-input row to fall through,  
which it does unless the corresponding expression is a NULL constant  
and the RETURNING type is not a domain.  So JSON_VALUE and JSON_QUERY  
with their default NULL ON EMPTY / NULL ON ERROR behaviors were not  
affected, but JSON_EXISTS, whose default is FALSE ON ERROR, was.  
  
Fix by pointing those JUMP_IF_NULL steps at EEOP_JSONEXPR_PATH itself  
and dropping the CONST NULL step.  ExecEvalJsonExprPath() now returns  
NULL for NULL input after resetting the flags, skipping jsonpath  
evaluation and the ON EMPTY / ON ERROR steps as before, but still  
jumping to the coercion steps when RETURNING a domain type so that its  
constraints are checked.  
  
Oversight in commit 6185c9737cf, so back-patch to 17.  
  
Bug: #19621  
Reported-by: Suyang Zhong <syzhong16@gmail.com>  
Author: jian he <jian.universality@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>  
Tested-by: Manu <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/19621-0a480d2dc74e6bd5@postgresql.org  
Backpatch-through: 17  

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

commit   : ba3115d8389657b199f38244c429ebcfe2f77ed1    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 5 Nov 2026 08:16:50 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 5 Nov 2026 08:16:50 +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 accidental ignoring of subsequent keys in Sort nodes

commit   : b715192e52e7310a041b9ac64485560c20cfce39    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 5 Nov 2026 10:21:17 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 5 Nov 2026 10:21:17 +1300    

Click here for diff

91e9e89dc (v15) changed nodeSort.c to allow the slightly more efficient  
Datum sort method to be used when the Sort node was only outputting a  
single column.  That commit mistakenly failed to consider additional  
sort keys.  
  
This wasn't trivial to hit as adding more sort keys on another column  
would add a resjunk target entry, so Datum sort wouldn't be used.  Hitting  
this required all sort keys to be on the only output column, and then you  
might think that subsequent sort keys *could* be ignored in that case, but  
the collation for subsequent keys might differ from the first, and if the  
first sort key had a nondeterministic collation, ignoring subsequent keys  
isn't correct.  
  
Ordinary ORDER BY queries were not affected by this as repeating the same  
column in the ORDER BY clause with different collations would lead to  
additional redundant target entries and would have failed the one-column  
requirement to enable the Datum sort optimization.  The only known case  
where problems could occur was sorting for the presorted aggregate  
optimization added in 1349d2790 (v16).  
  
A query such as the following would trigger this issue if the "x" column  
was defined with a nondeterministic collation as the presorted input  
would arrive at the aggregate only presorted by 'x' (using its  
nondeterministic collation), rather than 'x, x COLLATE "C"':  
  
SELECT count(DISTINCT x COLLATE "C") FROM t GROUP BY x;  
  
This could lead to COUNT(DISTINCT) returning a count higher than the actual  
number of distinct values according to the "C" collation.  
  
Fix this by only using the Datum sort optimization when there's 1 output  
column and 1 sort key, rather than just checking for 1 output column.  
  
Reported-by: Nidal FAKIH <nidal.fakih@soptimal.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/c6790a7b-7c10-4baf-9c8f-b404420c63f9@soptimal.com  
Backpatch-through: 15  

M src/backend/executor/nodeSort.c

Fix ExecCheckIndexConstraints() crash when es_snapshot is invalid.

commit   : 76e9e44b03a3028d3ef79bc334bc45722a96ce4e    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 4 Nov 2026 19:45:39 +0000    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 4 Nov 2026 19:45:39 +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   : 73a28d2733ab1a9895f533785901aa2865a5864c    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 4 Nov 2026 18:30:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Wed, 4 Nov 2026 18:30:00 +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

Add compiler option -fstrict-flex-arrays=1

commit   : a625e153b7d2f0e1c81955d13f2fc8de472bc082    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 4 Nov 2026 09:44:28 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 4 Nov 2026 09:44:28 +0100    

Click here for diff

Currently, every trailing array regardless of its declared bound is  
exempt from -Warray-bounds, __builtin_object_size/_FORTIFY_SOURCE, and  
-fsanitize=bounds.  -fstrict-flex-arrays=1 says that only arrays  
declared with bounds [], [0], or [1] can be flexible array  
members (which are then mostly exempt from array bounds checking); for  
all other arrays, the declared size is taken as is for bounds  
checking, which is what we want.  
  
This applies to a large number of structs in the tree, for example  
  
- struct pg_hmac_ctx  
- fe_scram_state  
- struct XidCache  
- struct RelPathStr  
...  
  
which can now be checked properly.  
  
Ideally, we'd want to use the maximum level -fstrict-flex-arrays=3,  
which would also disqualify flexible array members declared with  
bounds [0] or [1].  But we do need the [1] variant in a few cases  
because standard C does not allow flexible array members as the only  
element in a struct.  Affected are:  
  
- struct RevmapContents  
- struct ReplicationSlotCtlData  
- union pgresult_data  
  
Also:  
  
- struct sqlda_struct (bound by external API specification)  
  
Turning on -fstrict-flex-arrays=3 for these would conjure undefined  
behavior.  
  
One piece of code needs to be adjusted: JsonValueList has an array  
declared as [2] (via BASE_JVL_ITEMS) but addresses it as a  
flexible-length array in some circumstances.  Change this to an  
anonymous union with one branch having the original size [2], to keep  
local variables sized the same as before, and one branch of size [1],  
which effectively makes this a flexible-array member under  
-fstrict-flex-arrays=1.  We can't make it a fully flexible-array  
member [], because JsonValueList is also used for a field in the  
middle of JsonTablePlanState, which is not allowed in standard C.  
  
There is one structure with a genuine trailing one-element array:  
  
- WordEntryPosVector1  
  
By staying with -fstrict-flex-arrays=1 we would miss out on bounds  
checking on that one.  
  
Also provide an attribute macro pg_attribute_strict_flex_array that  
allows overriding the strict flex array level for a particular struct.  
Use that to annotate WordEntryPosVector1.  Note that clang supports  
the command-line option but not the attribute, so we can only use this  
to optionally raise the level for some structs, but we can't do the  
opposite of having a higher global level and lower it for some  
exceptions.  
  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://www.postgresql.org/message-id/flat/c79da9e1-965d-4530-9e3e-84b8bde134ec%40eisentraut.org  

M configure
M configure.ac
M meson.build
M src/backend/utils/adt/jsonpath_exec.c
M src/include/c.h
M src/include/tsearch/ts_type.h
M src/tools/pgindent/pgindent

Fix NOT IN to anti-join conversion with coerced sub-select outputs

commit   : b7eee09eab738e085d6b62d35788f542dd233877    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 4 Nov 2026 16:23:54 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 4 Nov 2026 16:23:54 +0900    

Click here for diff

Commit 383eb21eb allowed converting "x NOT IN (SELECT y ...)" to an  
anti-join when neither the outer expressions nor the sub-select's  
output columns can be NULL, and the operator cannot return NULL for  
non-null inputs.  However, the operator is not necessarily applied to  
the sub-select's output itself: the parser may wrap the output's Param  
in a coercion to the operator's input type.  If that coercion is a  
cast function that returns NULL for a non-null input, the comparison  
yields NULL, so NOT IN must not return true, yet the anti-join keeps  
the outer row, producing wrong results.  
  
To fix, require each inner operand of the comparison to be the  
sub-select's output Param, possibly under a RelabelType, which cannot  
introduce NULLs.  This gives up the conversion for some coercions that  
cannot actually return NULL, such as the built-in cast from integer to  
numeric, but proving that for a cast function is not straightforward.  
  
Back-patch to v19, where the conversion was introduced.  
  
Author: BHUVAN CHILUKUTI <c.bhuvan@iitg.ac.in>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/PN0P287MB090375874C6D5433282EC9DFA7642@PN0P287MB0903.INDP287.PROD.OUTLOOK.COM  
Backpatch-through: 19  

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

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

commit   : e5f6a7a28c4ab82a80fd0fa89d9f77b80ae97c07    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Wed, 4 Nov 2026 14:46:35 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Wed, 4 Nov 2026 14:46:35 +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, as Tom Lane  
reported, buildfarm member trilobite hit the cast function case in  
the regression tests, because CLOBBER_CACHE_ALWAYS makes the  
invalidation certain.  This trilobite failure came after 6aecabcd5ed  
made the RI checks that require cast functions go through the SPI  
path instead of the fast path, which didn't have this bug as it  
didn't use SPI plans.  
  
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.  AtEOXact_RI() frees whatever is left, the same  
treatment the fast-path metadata already gets since e73e0196.  
  
Re-add the test case that f52d4051 removed because it turned trilobite  
red, now that the bug is fixed, along with a comment noting that it  
takes CLOBBER_CACHE_ALWAYS to hit the bug with it.  Also, 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/utils/adt/ri_triggers.c
M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql

Allow LIMIT pushdown in postgres_fdw with empty ORDER BY pathkeys

commit   : b6178c942ea7a85f72beb6a775d2793062a7ff8e    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 4 Nov 2026 16:23:34 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 4 Nov 2026 16:23:34 +1300    

Click here for diff

When all of the ORDER BY clause's PathKeys are redundant due to consts in  
all of the pathkeys' EquivalenceClasses, sort_pathkeys is NIL, but  
query_pathkeys may then get set to setop_pathkeys, which may not be  
shippable.  add_foreign_ordered_paths() previously used the shippability  
of query_pathkeys to decide whether the UPPERREL_ORDERED step was safe to  
push down, which needlessly prevented the subsequent UPPERREL_FINAL step  
from pushing down the LIMIT.  No sort is needed in this case, so just mark  
the ordered step as pushdown-safe.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Robins Tharakan <tharakan@gmail.com>  
Discussion: https://postgr.es/m/CAEP4nAwnSefmi4w+89XbHQ0f-0OixCYUJo9kVcbXSYL8L4rEPg@mail.gmail.com  

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

Fix incorrect Assert in add_foreign_ordered_paths

commit   : 52b41da0be54f5df6708f95dc8bda73b8ae7c563    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 4 Nov 2026 15:56:46 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 4 Nov 2026 15:56:46 +1300    

Click here for diff

12933dc60 (originally 66c0185a3) added setop_pathkeys for providing  
presorted inputs for set operation from child queries when that query  
doesn't have any other pathkey requirements.  
  
add_foreign_ordered_paths() assumed that if the query had an ORDER BY  
that the query_pathkeys would be equal to sort_pathkeys.  That's not  
true when query_pathkeys is set to setop_pathkeys, which can happen  
for set-op child queries with an ORDER BY when all the sort_pathkeys are  
redundant pathkeys. (See standard_qp_callback()).  
  
Here we relax the Assert to allow for sort_pathkeys to be empty.  In  
this case it is technically ok to mark pushdown_safe as true so that  
postgresGetForeignUpperPaths() allows add_foreign_final_paths() to  
generate paths with the LIMIT clause pushed down.  We don't adjust that  
here as that could cause plan changes in the backbranches.  Let's just  
fix things enough so the Assert doesn't fail and do a proper fix in  
master.  
  
Backpatch to 17 where the setop_pathkeys field was added.  
  
Reported-by: Robins Tharakan <tharakan@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Robins Tharakan <tharakan@gmail.com>  
Discussion: https://postgr.es/m/CAEP4nAwnSefmi4w+89XbHQ0f-0OixCYUJo9kVcbXSYL8L4rEPg@mail.gmail.com  
Backpatch-through: 17  

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

Fix possible index corruption in pg_trgm GiST indexes

commit   : 8aea84d2b8a1233ae44bb0dc0fde2a2ab0f5e35f    
  
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 memory leaks when freeing WAL readers

commit   : 6a146d297503b271f4cff6cdf8eaf8f80bbd26a6    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 4 Nov 2026 11:16:44 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 4 Nov 2026 11:16:44 +0900    

Click here for diff

Commit 3f1ce97346 introduced a circular buffer for decoded WAL records,  
with separate allocations for records that do not fit in the buffer.  
However, XLogReaderFree() did not release separately allocated  
records remaining in the decode queue. In particular, the last record  
returned by XLogReadRecord() remains queued until released, so freeing  
the reader could leak that record.  
  
For many callers, the leaked memory is reclaimed when the containing  
memory context is reset or deleted. However, it can accumulate in  
long-lived contexts. For example, when checkpointing prepared  
transactions, XlogReadTwoPhaseData() creates a WAL reader, reads the  
PREPARE record, and frees the reader. Large PREPARE records can  
therefore leave allocations in checkpointer_context, which is not  
reset during normal operation. These allocations accumulate until  
an error resets the context or the checkpointer exits.  
  
Fix this by calling ResetDecoder() in XLogReaderFree() to release all  
separately allocated records in the queue. Do this before freeing the  
decode buffer, since the queue can also contain records stored in that  
buffer.  
  
Backpatch to v15, where the circular WAL decoding buffer was  
introduced.  
  
Author: Tomás Senart <ts@perfloop.ai>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAEEBa3Uai8TGPd6P5SX_fzbu3KHMwSvu9WuqA8JPSPQ1RJR8fQ@mail.gmail.com  
Backpatch-through: 15  

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

Fix handling of nested values in "exprs" for pg_restore_extended_stats()

commit   : f1d69bb7dfc2021091281b7063fe76c6ffcb9613    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 4 Nov 2026 10:55:58 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 4 Nov 2026 10:55:58 +0900    

Click here for diff

check_all_expr_argnames_valid() iterated over the keys of each  
expression object without skipping nested containers, so an unknown key  
whose value is an array or an object broke the expected key/value token  
sequence.  This caused an assertion failure, or an infinite loop that  
cannot be canceled in non-assert builds.  
  
This issue is fixed by skipping any nested containers, as we expect a  
single array with a single sets of key/value pairs.  
  
While on it, remove an unused allocation of the invalid key name.  
This one has been noticed in passing.  
  
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/f0034efa-66fb-4963-9872-c089dd021007@tantorlabs.com  
Backpatch-through: 19  

M src/backend/statistics/extended_stats_funcs.c
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql

Fix Memoize to correctly use clause's input collation

commit   : 35273454065e6b7f07984e70ac131ce710e6f380    
  
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

Improve stability of authentication test 007_pre_auth

commit   : 590788ad0bff40c43935b7c8f41b68886ab0a3de    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 4 Nov 2026 08:38:32 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 4 Nov 2026 08:38:32 +0900    

Click here for diff

The injection point wait used by the test could be reached by autovacuum  
workers or the logical replication launcher, leading to sporadic  
failures.  
  
The configuration of the test is tweaked so as these kinds of processes  
are not spawned anymore, which should be enough to silence the problems.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://postgr.es/m/c984ed89-cac1-47a9-91fa-4d3287722203@gmail.com  
Backpatch-through: 18  

M src/test/authentication/t/007_pre_auth.pl

test_custom_stats: Add test for drop of variable-sized stats kind

commit   : 8e225d2ac57dd4e801e452c9398da4983c2d67b0    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 4 Nov 2026 08:05:17 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 4 Nov 2026 08:05:17 +0900    

Click here for diff

pgstat_drop_matching_entries() with a non-NULL callback while scanning  
all the variable-numbered stats kinds had no test coverage.  d52c24b0f80  
had an equivalent in the test module injection_points, that had no  
coverage since the tests for custom stats kinds have been moved to  
test_custom_stats.  
  
This commit adds an equivalent coverage here by dropping all the custom  
variable-sized stats entries through pgstat_drop_matching_entries().  An  
extra test checking that other variable-sized stats kinds are untouched  
is included.  
  
This is a hole in the tests of v19, but it's not critical in any way so  
no backpatch is done.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/aufa5srSxC4pu5OF@paquier.xyz  

M src/test/modules/test_custom_stats/t/001_custom_stats.pl
M src/test/modules/test_custom_stats/test_custom_var_stats–1.0.sql
M src/test/modules/test_custom_stats/test_custom_var_stats.c

pg_plan_advice: Handle custom scans that replace a join

commit   : eaa5961efc65d3701ccae3d7ed79d421e37cdd9f    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Tue, 3 Nov 2026 10:11:04 -0500    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Tue, 3 Nov 2026 10:11:04 -0500    

Click here for diff

pgpa_relids() ignored CustomScan nodes, so a custom scan that replaced  
a join caused the plan walker failed with "plan node has no RTIs". Fix  
by returning custom_relids, so that the node is then treated as an  
ordinary scan of several relations.  This allows JOIN_ORDER advice to  
handle it correctly.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260827171830.68.noahmisch@microsoft.com  
Discussion: https://postgr.es/m/sSMpyoJ12CV5Y3uS-T_8Z3M1xsJBELBd-Vh5DmlC9_jy9TOqMuWzr8-TuXrBpL8AlPlyEFkyQ4wX5guJCyVizY-R2UET0DpIEeA1aSsUjk4=@pm.me  
Author: Dongpo Liu <poe.liu@pm.me>  

M contrib/pg_plan_advice/pgpa_walker.c

Remove git-external-diff from tools directory

commit   : c0f2b6dc82718f17a2190f474450885df6c06402    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 3 Nov 2026 14:13:36 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 3 Nov 2026 14:13:36 +0100    

Click here for diff

The git-external-diff bash script could not be executed due to syntax  
errors without it being reported, which indicates that it hasn't been  
used by anyone in a long time.  Rather than spending energy on fixing  
dead code, the conclusion in the thread was to remove it.  
  
Reported-by: zmuxuny <xiahoumuxuan@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAMPOERnKK-vNtc_Ooddb9WGbDepGi1=pxOFfiGrb4_Cqzyu69w@mail.gmail.com  

D src/tools/git-external-diff

Clean up code comments for pg_wchar_tbl

commit   : 3ba886b35a2804dcd275868a19135a31ceb81386    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 3 Nov 2026 07:58:15 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 3 Nov 2026 07:58:15 +0100    

Click here for diff

The documentation for the functions in the fields of pg_wchar_tbl was  
spread out all over the place and was missing a lot of detail.  Move  
and expand this at the definition of the struct.  (See also struct  
TableAmRoutine in access/tableam.h for inspiration.)  
  
Also remove unnecessary typedefs, except where they were used  
elsewhere as well.  This indirection makes the code documentation  
harder to follow.  And some of those typedefs had nonsensical names,  
like *_converter for functions that didn't do any converting.  
  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://www.postgresql.org/message-id/flat/637d73f4-e088-4ead-b9e6-1ddb4cd4693f%40eisentraut.org  

M src/backend/utils/mb/mbutils.c
M src/common/wchar.c
M src/include/mb/pg_wchar.h
M src/tools/pgindent/typedefs.list

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

commit   : 2af6dd3370677d8b06cf2a9eb62f69ba11e12cab    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 15:01:02 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 15:01:02 +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/func-admin.sgml
M doc/src/sgml/func/func-datetime.sgml
M doc/src/sgml/func/func-info.sgml
M doc/src/sgml/func/func-json.sgml
M doc/src/sgml/func/func-string.sgml
M doc/src/sgml/func/func-textsearch.sgml
M doc/src/sgml/func/func-xml.sgml
M doc/src/sgml/textsearch.sgml

doc: Fix column name in routine_sequence_usage documentation

commit   : 1135869382178a1285e08c58d56eaac461cb89e3    
  
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

doc: Correct setting restrictions for vacuum_max_eager_freeze_failure_rate

commit   : dab476d75b8af56e919d2d3b05d123e2c0b7ea4a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 14:54:02 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 14:54:02 +0900    

Click here for diff

The documentation incorrectly stated that this parameter could only  
be set in postgresql.conf or on the server command line. However, it  
is a PGC_USERSET parameter and can therefore be changed by any user  
within a session.  
  
Remove the incorrect restriction while retaining the note about the  
per-table storage parameter override.  
  
Backpatch to v18, where this parameter was introduced.  
  
Author: Afrah Razzak <mypg.afrah@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAAJ6gzGeup6WPpraF1g6iWYOQsvLmhKk94acJ=-iq+Gg_x9W0w@mail.gmail.com  
Backpatch-through: 18  

M doc/src/sgml/config.sgml

Reject incremental backups based on a backup from a divergent history

commit   : 316861101e8c5ca48149d368e08ff865dd3ea306    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 13:03:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 13:03:38 +0900    

Click here for diff

After a failover, an incremental backup could accept a prior backup  
whose WAL range extends beyond the point where the new primary left the  
old timeline. Combining these backups could retain pages from the  
abandoned history, producing a corrupt backup that might still recover  
and start successfully.  
  
The validation checked the end of the prior backup's final WAL range  
against the new backup's start LSN, but not against the timeline's  
switch point. This allowed an incompatible prior backup to pass  
validation once the new primary had advanced far enough.  
  
Reject incremental backups if the prior backup's final WAL range  
extends beyond the timeline's switch point.  
  
Backpatch to v17, where incremental backup was introduced.  
  
Author: Sai Pranav <rajasaipranav0@gmail.com>  
Co-authored-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAPHduZC9pWm_vjznmhZNFsDZKLimqc6dKXOozLUKZVPs19zbZg@mail.gmail.com  
Backpatch-through: 17  

M doc/src/sgml/backup.sgml
M src/backend/backup/basebackup_incremental.c
M src/bin/pg_combinebackup/t/008_promote.pl

pg_waldump: Align WAL read error locations with other tools

commit   : 30faf13889b14e1bdfd0b5883291f3297135ce02    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 10:52:45 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 10:52:45 +0900    

Click here for diff

When reading WAL fails, pg_rewind and pg_walinspect report the  
position where the failed read began, followed by the detailed error  
message. In contrast, pg_waldump's "error in WAL record at ..."  
prefix reported the position of the last successfully read record.  
This was misleading because the prefix pointed to a successfully  
read record rather than the start of the failed read.  
  
Make pg_waldump report the position where the failed read began,  
consistent with pg_rewind and pg_walinspect.  
  
Note that this position usually identifies the start of the next  
record, but may precede it when a page header must be skipped.  
It may also differ from the actual error location when reading  
a record that spans multiple pages. Nevertheless, it is consistent  
with the other tools and less misleading than reporting the last  
successfully read record.  
  
Author: Rahul Yadav <rahul@rhyadav.dev>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/P2qIkq4--F-9@rhyadav.dev  

M src/bin/pg_waldump/pg_waldump.c

Fix incorrect LSNs in WAL decoding error messages

commit   : 01b3d24c41629c577ca172f3077ec7bfc2ca9bf3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 10:49:40 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 10:49:40 +0900    

Click here for diff

Commit 3f1ce97346 introduced a circular WAL decoding buffer,  
allowing records to be decoded before they are consumed. However,  
decoding error messages continued to report the location of the last  
record consumed instead of the record that failed decoding. With  
recovery prefetching, the reported location could be many records  
behind the failing record, making WAL problems harder to diagnose.  
  
Fix this by reporting the location of the record being decoded.  
Errors now identify the failing record even with recovery prefetching,  
making it easier to investigate malformed WAL during recovery or with  
tools such as pg_waldump and pg_walinspect.  
  
Backpatch to v15, where the WAL decoding buffer was introduced.  
  
Author: Rahul Yadav <rahul@rhyadav.dev>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/P2qIkq4--F-9@rhyadav.dev  
Backpatch-through: 15  

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

Fix lost wakeups in physical WAL senders

commit   : 782d9cf8bf823775efb604300713f6c39a5bfb02    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 10:46:41 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 10:46:41 +0900    

Click here for diff

Physical WAL senders could sleep even when flushed WAL was waiting to  
be sent, delaying replication and synchronous commits until another  
event woke them. In the reported case, commits stalled for about ten  
seconds, until the standby sent its next periodic status report.  
  
Commit bc971f4025c changed WAL sender wakeups to use condition  
variables, which notify only senders already on the waitlist.  
However, XLogSendPhysical() checks the flush position before  
WalSndWait() joins the waitlist. If WAL is flushed between these two  
steps, the wakeup can be missed, leaving the sender asleep despite  
having more WAL to send.  
  
Fix this by rechecking the flush position after joining the waitlist  
and returning to the send loop if more WAL is available. For cascading  
senders, also check for promotion or a timeline change, which require  
the sender to revisit the current timeline even if the flush position  
has not advanced.  
  
Backpatch to v16, where commit bc971f4025c introduced the  
condition-variable wakeup mechanism.  
  
Author: Alex Speller <alex@alexspeller.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/mvx5bs7q.33b99c32-67d8-4373-8611-7a8250fb2fd3@we.are.superhuman.com  
Backpatch-through: 16  

M src/backend/replication/walsender.c

Make Memoize cache keys only of Params from outer query levels

commit   : 45ff0b4a317f14539567a3500eb41ec8b06cde3d    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 3 Nov 2026 09:45:51 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 3 Nov 2026 09:45:51 +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   : 4f31212020ea1c2aedb0494cb1fc329b5275c1cf    
  
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

Add REPACK progress phases for logical decoding setup.

commit   : 51ae21aa313bb6b79ad914920279cd0d89e92220    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 2 Nov 2026 15:00:30 -0800    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 2 Nov 2026 15:00:30 -0800    

Click here for diff

Previously, REPACK (CONCURRENTLY) reported everything it did before the  
heap scan as "initializing", including enabling logical decoding and  
setting up the logical decoding context. Setting up the context waits  
for the transactions that have a transaction ID assigned to end and  
therefore can take arbitrarily long, but users couldn't tell that wait  
apart from the rest of the setup.  
  
Add two phases, "enabling logical decoding" and "initializing logical  
decoding". As these steps run in the decoding worker, the worker tells  
the backend running REPACK which phase to report through shared  
memory, and the backend reports it while waiting for the worker.  
  
Bump catalog version.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/CAN12%2BYJOeOyPYB5JS28VE_%2Brzg%3DRbzQXfj58TGfMYwv-TX9mJA%40mail.gmail.com  

M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
M src/include/catalog/catversion.h
M src/include/commands/progress.h
M src/include/commands/repack_internal.h
M src/test/regress/expected/rules.out

Fix BRIN minmax-multi distance calculation for OID

commit   : 4b6735c21fa4c43be041c6c610d7be6463c2c1f9    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 2 Nov 2026 23:11:38 +0100    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Mon, 2 Nov 2026 23:11:38 +0100    

Click here for diff

The oid_minmax_multi_ops opclass simply calculated the distance using  
brin_minmax_multi_distance_int4. That however interprets the values as  
int32, so OIDs above PG_INT32_MAX were treated as negative values, and  
ranges crossing the boundary ended with a negative distance.  
  
With assert-enabled guild, this tripped the (a1 <= a2) check. Without  
asserts, the index was less efficient.  
  
Fix by introducing brin_minmax_multi_distance_oid, correctly treating  
the OID values as unsigned.  
  
This required a catalog change (and catversion bump), so it can't be  
backpatched. It'd be possible to adjust brin_minmax_multi_distance_int4  
to handle the (a1 > a2) case differently. But that'd lose the assert,  
and it does not seem worth it (indexes on OIDs don't seem very common).  
  
Author: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
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/include/catalog/pg_amproc.dat
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/brin_multi.out
M src/test/regress/sql/brin_multi.sql

Make parallel vacuum processes share the cost limit.

commit   : 8628df8891abc7c69bb12ed160e36df727ca40ea    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 2 Nov 2026 13:21:38 -0800    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 2 Nov 2026 13:21:38 -0800    

Click here for diff

Since commit 40d964ec99 introduced parallel vacuum in v13, each  
process taking part in it has slept for every vacuum_cost_limit cost  
units it incurred on its own, so the leader and its workers together  
could consume the budget several times over.  
  
Fix by scaling each process's delay by the number of processes active  
in the parallel vacuum. The cap on a single delay is scaled the same  
way but also limited to one second, as sleeping longer in pg_usleep()  
keeps the process from responding to latches and signals promptly.  
  
While the new behavior is the correct one, backpatching it to v18 and  
older would make parallel VACUUM with cost-based delay slower after a  
minor update, and users would need to retune the parameters. Since we  
haven't received any complaints about the old behavior, we don't  
backpatch it to those branches for now. On v19, however, parallel  
autovacuum breaks autovacuum_vacuum_cost_limit, whose value is divided  
among autovacuum workers so that their sum doesn't exceed it, because  
parallel workers aren't counted. So backpatch to v19.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: surya poondla <suryapoondla4@gmail.com>  
Tested-by: Manu <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACWDhGH_ACJYHvxHVbL9GZ8AgMoJFnf-u5=bWx7NZtYBRQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/config.sgml
M doc/src/sgml/maintenance.sgml
M doc/src/sgml/ref/vacuum.sgml
M src/backend/commands/vacuum.c

Fix BRIN minmax-multi distance for tid values

commit   : 252432c4cf1425d065cf12eb8aa9d59209233513    
  
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   : c230e14b44d2bc40d0d141861e4cbd3839843df9    
  
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

Remove unused parameters from self-join elimination functions

commit   : 5681f0cfa5acfdc5146e2b74ff5b7e940df039f3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 01:57:47 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 01:57:47 +0900    

Click here for diff

Remove root, from, and to from split_selfjoin_quals(), and root  
from match_unique_clauses(). These parameters have been unused  
since self-join elimination was committed.  
  
Author: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Miłosz Bieniek <bieniek.milosz@proton.me>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHewXNmwCFH5bk0ANX8wRG8Y_4c9jh8OTKceNM1W6ijDS3DzLA@mail.gmail.com  

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

doc: Clarify the description of postmaster.pid fields

commit   : 1a29680f9b1eaca15d4a3f8da3bca094452cdb25    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 01:57:13 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Nov 2026 01:57:13 +0900    

Click here for diff

Document the postmaster status and note that the shared memory field  
is empty on Windows. Also mention the shared memory segment ID in  
the pidfile.h comment.  
  
This is a follow-up of commit fa5ecff759b.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Discussion: https://postgr.es/m/CAHGQGwGQRpEyTdoHJr86x=JmF4413E87MK3Jai09UvSvuotqVg@mail.gmail.com  

M doc/src/sgml/storage.sgml
M src/include/utils/pidfile.h

Fix missing tts_tid assignments in ExecForceStoreHeapTuple().

commit   : 8a8ee213df27c3de62df889e3e7002735c47110a    
  
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

Add more pg_attribute_counted_by() to various flexible array members

commit   : 633dee1bd1b41145f81619423d573754c7ad2b9e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 2 Nov 2026 11:02:39 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 2 Nov 2026 11:02:39 +0100    

Click here for diff

Annotate flexible array members whose element count is held by another  
member of the same struct, so that the compiler knows the real extent  
of these arrays.  
  
This continues the work from commit 7a04cac0c3b.  In one case, the  
order of assignments to the counted and counting fields had to be  
adjusted.  
  
Extension code could in theory be affected by the new annotations in  
the header files, but it is mostly unlikely that extensions would  
build or resize these structs themselves, and in any case a violation  
would show up as a new warning or sanitizer failure, not silent  
breakage.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/backend/executor/execParallel.c
M src/backend/nodes/bitmapset.c
M src/include/access/brin_internal.h
M src/include/access/tupdesc.h
M src/include/executor/execPartition.h
M src/include/executor/instrument.h
M src/include/executor/instrument_node.h
M src/include/jit/jit.h
M src/include/nodes/bitmapset.h
M src/include/regex/regguts.h
M src/include/statistics/extended_stats_internal.h
M src/include/statistics/statistics.h
M src/include/tsearch/dicts/spell.h
M src/include/utils/catcache.h
M src/include/utils/datetime.h
M src/pl/plpython/plpy_procedure.h

Delay checkpoint start in RecordTransactionAbortPrepared()

commit   : cea96cdfecbf40aa3f12c1c2572c191f27c318d0    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 15:17:57 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 15:17:57 +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   : 303c9b36205d11e41c7d5d61a1802ec50bccbf5a    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 14:36:38 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 14:36:38 +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 double-free when XMLSERIALIZE(... INDENT) output exceeds 1GB.

commit   : 01131ca43bbf798be6ec237a33f6bef67bede888    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 1 Nov 2026 20:45:35 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 1 Nov 2026 20:45:35 -0500    

Click here for diff

In xmltotext_with_options(), xmlSaveClose() frees the save context  
unconditionally, but ctxt was only reset to NULL on the error branch.  
When the close succeeded and a later step threw an error -- typically,  
cstring_to_text_with_len() rejecting a result larger than MaxAllocSize  
-- control reached the PG_CATCH block with ctxt still pointing at the  
freed context, so xmlSaveClose() was called a second time on freed  
memory and crashed the backend.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/bbadb6b2-d226-41a1-ace3-e0eb20648f58@uni-muenster.de  
Backpatch-through: 16  

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

Make cache keys of other Params a Memoize subplan depends on

commit   : f8da64e6ddfd5f33f1d70b3ae6f8561f1de09368    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 10:29:02 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 10:29:02 +0900    

Click here for diff

A Memoize node purges its whole cache whenever a Param changes which  
the cache keys don't determine, such as an upper-level Param used in a  
base qual of the memoized relation.  Under a correlated subquery, such  
a Param changes on every invocation of the subplan, so nothing in the  
cache survives from one invocation to the next.  
  
To improve that, make cache keys of the upper-level Params found in  
the memoized relation's base quals and targetlist, and on the inner  
side of the join clauses, as is already done for Params buried inside  
a cache key expression.  Cache entries then survive across invocations  
with the same Param value.  
  
This doesn't pay off when the Param's values don't recur across  
invocations.  Cache entries for earlier values are then kept rather  
than purged, and they only take up memory until the cache fills up and  
evicts them.  The planner can't tell the two cases apart, as it costs  
Memoize per invocation starting from an empty cache.  We accept that,  
since the cache's memory is bounded by its size limit either way, and  
evicting a stale entry costs about the same as purging it.  
  
This is only an optimization, as any Param we don't find here still  
purges the cache when it changes.  Hence we needn't track down every  
last place a Param can appear, and a Param whose type can't be hashed  
is simply left to the purging.  
  
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  

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

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

commit   : 708eb515812bf23ebc36a2c436eabe701b3c2f5d    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 10:28:38 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 2 Nov 2026 10:28:38 +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   : 180f3dcd415825af1c0d08dd7f4cc19b31112118    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 08:12:27 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 2 Nov 2026 08:12:27 +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

Move plpython's rejection of pseudotype arguments/results.

commit   : 00d33e82bbb087d0f77fb5f49475885db62d1e37    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 1 Nov 2026 17:28:21 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 1 Nov 2026 17:28:21 -0500    

Click here for diff

Perform this work in the validator function, rather than repeating  
it during every function call.  The previous coding not only  
performed unnecessary catalog lookups during function call setup,  
but failed to detect invalid argument types at CREATE FUNCTION  
time if check_function_bodies is off.  That's not how that's  
supposed to work.  
  
Review of this patch exposed that we were not testing some cases  
involving record-type output parameters, so add tests memorializing  
the expected behavior.  
  
In passing, fix an obsolete comment in plpython_composite.sql.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/2865288.1793403201@sss.pgh.pa.us  

M src/pl/plpython/expected/plpython_composite.out
M src/pl/plpython/expected/plpython_record.out
M src/pl/plpython/plpy_main.c
M src/pl/plpython/plpy_procedure.c
M src/pl/plpython/sql/plpython_composite.sql
M src/pl/plpython/sql/plpython_record.sql

Fix failure in function cache entry hashing during validation mode.

commit   : 811527d9d46eabd4a577b16df486ca86b76a073e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 1 Nov 2026 17:26:05 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 1 Nov 2026 17:26:05 -0500    

Click here for diff

When cached_function_compile() is called with forValidator = true,  
the passed FunctionCallInfo is one that the caller set up specially,  
and it's typically pretty incomplete.  compute_function_hashkey()  
was careless about this and would call get_call_result_type()  
if asked to, which would fail in any but the simplest cases.  
We'd managed not to notice in the pre-existing use-cases because  
plpgsql and functions.c don't pass includeResultType and forValidator  
both true at the same time; but plpython does, so it would reach this  
failure in cases such as polymorphic argument types.  plpython does  
not yet support polymorphic arguments, and has no test cases about  
them, so we did not see that the intended error message had degraded  
to an internal failure in get_call_result_type().  
  
To fix, just skip trying to fill the result type tupdesc when in  
validation mode.  This leads to building a hashtable entry that will  
never match any real calls, but that's true in a lot of other  
validation cases as well.  
  
The root cause here is lack of clarity about what we expect the  
passed FunctionCallInfo to contain in validation mode, so add  
comments specifying that.  Also add some plpython test cases showing  
the expected error reports.  
  
Backpatch to v18 where funccache.c was introduced.  This problem's  
not reachable in the core code in v18, since plpython didn't use  
funccache.c then.  But extensions could perhaps be using funccache.c  
as of v18, and they might hit it.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/2865288.1793403201@sss.pgh.pa.us  
Backpatch-through: 18  

M src/backend/utils/cache/funccache.c
M src/pl/plpython/expected/plpython_error.out
M src/pl/plpython/sql/plpython_error.sql

meson: Avoid PATH bloat from NLS .mo targets in tmp_install test

commit   : 799091cde90bc91701c320aa6ddf063118ccb027    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 13 Jul 2026 10:50:54 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 13 Jul 2026 10:50:54 -0400    

Click here for diff

On Windows, meson adds the build directory of every target in a test's  
'depends:' to that test's PATH.  tmp_install depended on  
installed_targets, which with NLS enabled includes several hundred .mo  
targets, pushing PATH past the Windows length limit.  tmp_install and  
initdb_cache then failed with no output.  
  
Fix by depending on a stamp custom_target that itself depends on  
installed_targets.  Meson doesn't walk a custom_target's dependencies  
when building the test PATH, so this adds at most one entry.  This can  
be removed once we mandate a meson version containing the upstream fix  
(expected in 1.13).  
  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Backpatch-through: 16  
Discussion: https://postgr.es/m/CAD5tBcJXAX8bz5q9ngE4znvVLiXaPO89D0yTFhJgEPrPyT-Erw@mail.gmail.com  

M meson.build

doc: Add missing field description for postmaster.pid

commit   : fa5ecff759b1c6766172c375e83b109ad6a7ecf1    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sun, 1 Nov 2026 20:09:53 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sun, 1 Nov 2026 20:09:53 +0100    

Click here for diff

The description mentioned that the file contains the shared memory  
segment ID, but omitted the shared memory segment key which is  
reported on the same line.  
  
Author: Laurenz Albe <laurenz.albe@cybertec.at>  
Reported-by: Yong Huang <yong321@yahoo.com>  
Discussion: https://postgr.es/m/179313458417.1253.445225696660341760@wrigleys.postgresql.org  

M doc/src/sgml/storage.sgml

Reject enforcing a parent CHECK constraint over a NOT VALID child

commit   : 0b12a5a7435a3b50cccea85347d9e3cf8128d88a    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 29 Oct 2026 07:21:16 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Thu, 29 Oct 2026 07:21:16 -0400    

Click here for diff

ALTER TABLE ... ALTER CONSTRAINT ... ENFORCED on a parent's NOT ENFORCED  
CHECK constraint marked the parent's constraint validated, but when it  
recursed to a child whose matching constraint was already ENFORCED and  
NOT VALID, it left that child alone, since its enforceability was  
unchanged.  The child's existing rows were therefore never checked, and  
the parent ended up validated with a child that was not.  Constraint  
exclusion could then skip the child when querying the parent, and so  
miss rows that violate the constraint.  
  
Fix by raising the same error that ALTER TABLE ... INHERIT already  
raises when a child has a NOT VALID copy of a parent's constraint, with  
a hint to validate the child's constraint first.  Validating the child  
implicitly instead was considered, but ALTER CONSTRAINT ... ENFORCED  
does not validate an ENFORCED NOT VALID constraint when run directly  
against the table that has it, so doing so only when reached through a  
parent would be inconsistent.  
  
Add regression tests for both regular inheritance and partitioning.  
  
Bug introduced in 342051d73b3.  
  
Reported-by: Shihao Zhong <zhong950419@gmail.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Author: Jian He <jian.universality@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Discussion: https://postgr.es/m/CAGRkXqSGE=fQrjCoNQsyiCZRKfQ4SrB015CAR=3pXYB5tB=ieg@mail.gmail.com  
Backpatch-through: 19  

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

Fix incremental backup data loss due to WAL summary merge order

commit   : d903620acf65e45a560af72aadd0965c45104ceb    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 2 Nov 2026 00:22:09 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 2 Nov 2026 00:22:09 +0900    

Click here for diff

An incremental backup taken after a relation is truncated and extended  
again can omit modified blocks. Combining it with an earlier backup can  
then restore stale data, causing live rows to disappear and deleted rows  
to reappear.  
  
WAL summaries were merged without ensuring LSN order. Applying a limit  
block from an older summary after processing a newer summary could  
discard references to blocks modified later, causing those blocks to  
be omitted from the backup.  
  
Sort the required summaries by ascending start LSN before merging them,  
preserving references to later block modifications so that the required  
blocks are included in the backup.  
  
Backpatch to 17, where incremental backup was introduced.  
  
Bug: #19774  
Reported-by: Ke <kehan5800@gmail.com>  
Author: Ke <kehan5800@gmail.com>  
Co-authored-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://www.postgresql.org/message-id/19774-8a1cbfd1774fcd0c%40postgresql.org  
Backpatch-through: 17  

M src/backend/backup/basebackup_incremental.c
M src/bin/pg_combinebackup/meson.build
A src/bin/pg_combinebackup/t/013_summary_order.pl

Fix WAL summary boundary checks for incremental backups.

commit   : f549ecd2660ad3c6d56a07835756068d43d4a92c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 2 Nov 2026 00:17:17 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 2 Nov 2026 00:17:17 +0900    

Click here for diff

A standby can summarize received WAL ahead of replay. If recovery ends  
exactly where an old-timeline summary begins, FilterWalSummaries()  
incorrectly includes that summary even though it covers only WAL outside  
the promoted server's history. Truncation information in the summary  
can cause an incremental backup to omit modified blocks, leading  
pg_combinebackup to reconstruct files with stale data from an earlier  
backup. For example, updated rows can revert to their previous values  
after restoring the backup.  
  
Fix this by excluding summaries that only touch the boundaries of the  
requested LSN range without overlapping it. This makes  
FilterWalSummaries() consistent with GetWalSummaries() and its existing  
function comments. The old-timeline summary starting at the switch point  
is thus excluded, preventing its truncation information from causing  
the backup to omit required modified blocks.  
  
Back-patch to PostgreSQL 17, where incremental backup was introduced.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWV7RThdo4K62G8hC=Anpkbr54QWbOvyVvw5uvx4+-x_DQ@mail.gmail.com  
Backpatch-through: 17  

M src/backend/backup/walsummary.c

Fix two crashes on a concurrently dropped schema

commit   : 77705d1e5a616339c3e92f586bbfa7b6bb562beb    
  
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 PL/pgSQL error message on EOF in the middle of an expression

commit   : 46d7c16ca14e01211f75b39b4062a916dcb0c6b2    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 31 Oct 2026 12:41:41 +0200    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 31 Oct 2026 12:41:41 +0200    

Click here for diff

read_sql_construct() takes up to three terminator tokens, passing zero  
for those not used.  But zero is also the token code for end of input,  
so when the function body ended in the middle of an expression or  
statement, the loop treated EOF as a valid terminator and stopped  
there, instead of reaching the code that reports a missing terminator.  
Users got a generic 'syntax error at end of input', or a misleading  
'missing expression at end of input', instead of e.g. 'missing "THEN"  
at end of SQL expression'.  
  
Don't let unused terminator slots match EOF.  
  
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>  
Discussion: https://www.postgresql.org/message-id/CAM2+6=WcWycVx0j-zw=0jFJxfazFHtZadqZbBedEg2AQkGasfQ@mail.gmail.com  

M src/pl/plpgsql/src/expected/plpgsql_misc.out
M src/pl/plpgsql/src/pl_gram.y
M src/pl/plpgsql/src/sql/plpgsql_misc.sql

Fix error handling in pg_flush_data() and FilePrefetch()

commit   : 61a372b795ddec08c15518096fe1f3e9e9973096    
  
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

tests: Don't use the initdb template for older installations

commit   : 6cda9dfc4f9764b6957e4e214193936ffb92906b    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 30 Oct 2026 16:20:02 -0400    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 30 Oct 2026 16:20:02 -0400    

Click here for diff

Previously the initdb template was used even when creating a Cluster.pm  
instance for an old install. Obviously the current template is not right for  
that case.  The only reason we didn't notice before is because the existing  
cross-version tests, e.g. 002_pg_upgrade.pl, always pass initdb options for  
the old node.  
  
Oversight in 252dcb32397.  
  
Discussion: https://postgr.es/m/xhzif5hemvslxymzhk3ykdypwqvjm7pz5dm7taizgxgfjw6fwa@6gygmz5bdnc3  
Backpatch-through: 17  

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

Remove unused parameter from pgstat_execute_transactional_drops().

commit   : 5e4966e9d23931e49f914770e663dbc316ed568f    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 30 Oct 2026 14:19:29 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 30 Oct 2026 14:19:29 -0500    

Click here for diff

This function's is_redo parameter has been unused since it was  
introduced in commit 8b1dccd37c.  It seems unlikely that we'll ever  
need to know whether we're replaying WAL here, and if we do, it's  
easy enough to add it back.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/7B30D9B5-90FA-4184-85E5-60438DBE56CC%40gmail.com  

M src/backend/access/transam/twophase.c
M src/backend/access/transam/xact.c
M src/backend/utils/activity/pgstat_xact.c
M src/include/pgstat.h

Update time zone data files to tzdata release 2026f.

commit   : cb3a90c8211241aaeb88de799f6bd96a776f6675    
  
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

Add a few recent commits to .git-blame-ignore-revs.

commit   : b52b2d31a22aca8a9526cce52c07f565969637a7    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 30 Oct 2026 13:10:23 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 30 Oct 2026 13:10:23 -0500    

Click here for diff

M .git-blame-ignore-revs

libpq: handle GSS credentials more sanely.

commit   : 1c9efb57ec974b9c84df041644a39d8d4cc03004    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 30 Oct 2026 13:56:10 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 30 Oct 2026 13:56:10 -0400    

Click here for diff

pg_GSS_have_cred_cache() always acquires new GSS credentials.  
If we already had some, they were just leaked due to overwriting  
conn->gcred, and that's a nontrivial amount of memory (around 16K  
according to reporter).  Unfortunately, pg_GSS_continue() did this  
each time through, and it is typically called more than once in a  
GSSAPI connection cycle.  So repeated connections using GSS  
authentication could leak substantial amounts of memory.  
  
IMO the source of this problem is really the poorly-designed API  
of pg_GSS_have_cred_cache(): it's unclear that it always gets new  
credentials.  Let's rename it and remove the unnecessary pointer  
parameter to make its behavior clearer.  
  
To add insult to injury, pg_GSS_continue() shouldn't even be  
trying to acquire credentials unless GSS delegation is enabled,  
which it is not by default; so the whole effort is often wasted.  
  
Problems evidently introduced by 6633cfb21, so back-patch to v16.  
  
Bug: #19411  
Reported-by: Matt Carter <Matt.Carter@twosigma.com>  
Diagnosed-by: Matt Carter <Matt.Carter@twosigma.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19411-0440c8897a04b638@postgresql.org  
Backpatch-through: 16  

M src/interfaces/libpq/fe-auth.c
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/fe-gssapi-common.c
M src/interfaces/libpq/fe-gssapi-common.h
M src/interfaces/libpq/fe-secure-gssapi.c

pg_stash_advice: Fix race conditions in 001_persist.pl

commit   : 884aca9b96989b9bc1b65d42e731e90f098ee2ee    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Fri, 30 Oct 2026 12:28:59 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Fri, 30 Oct 2026 12:28:59 -0400    

Click here for diff

Each time we start the server, there's a brief lockout while the  
persistence worker reloads stashes from disk. Until that's complete,  
no stashes will be visible and no stash modifications can be made.  
This test case failed to take that into account, and could therefore  
fail spuriously.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Reported-by: Nik Samokhvalov <nik@postgres.ai>  
Author: Nik Samokhvalov <nik@postgres.ai>  
Co-authored-by: Robert Haas <rhaas@postgresql.org> (whitespace changes)  
Backpatch-through: 19  
Discussion: http://postgr.es/m/CAM527d8PqdbDy=PuTLYBJM8-FvvFDr2BLcyFyZhw6Oi9rXb14g@mail.gmail.com  

M contrib/pg_stash_advice/t/001_persist.pl

Return INT_MAX or INT_MIN from strtoint() on overflow.

commit   : 426551c8cf4902b6164cde1104df3783bfc50483    
  
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 crash-restart race in 041_checkpoint_at_promote.pl

commit   : eda9d98fac4f22d31ffd3507ca7b470da572a1c3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 30 Oct 2026 20:50:54 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 30 Oct 2026 20:50:54 +0900    

Click here for diff

The buildfarm member bushmaster reported failures in the final test query  
in 041_checkpoint_at_promote.pl with "the database system is in recovery  
mode".  
  
After killing a backend to trigger crash recovery, the test should wait  
for the postmaster to terminate the remaining server processes and restart  
the server, then wait for recovery to finish and connections to be accepted  
before running the final query.  
  
Previously, the test assumed that the killed backend's connection closing  
meant the postmaster had noticed the crash and begun restarting. However,  
the connection can close before the postmaster notices the crash. The  
subsequent connection check can then succeed before recovery starts,  
causing the test to mistake this for recovery having completed. The final  
query could then run during recovery and fail.  
  
Fix this by waiting for the postmaster to log that all server processes  
have terminated and it is reinitializing before checking that connections  
are accepted again. This ensures that the postmaster has noticed the crash  
and begun restarting before the test waits for recovery to finish.  
  
Backpatch to v17, where this test was introduced.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/e7abd282-655d-495e-94c9-e38a58917ebf@gmail.com  
Backpatch-through: 17  

M src/test/recovery/t/041_checkpoint_at_promote.pl

Fix more issues with extended statistics on expressions

commit   : 4f89416c9dbc78da5679d32072315af56fbeb8ed    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 30 Oct 2026 17:29:32 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 30 Oct 2026 17:29:32 +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   : 328a9a1731292e57a03ec4a5f495d0ed5fc85fba    
  
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   : b0392c26bd3cfb61ee24b7577967cc806d01da36    
  
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

Don't require outer joins for lateral PHV references outside subqueries

commit   : 77e5aeef59cd2fa680e54e552767e56d07cbab4a    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 30 Oct 2026 10:49:53 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 30 Oct 2026 10:49:53 +0900    

Click here for diff

When a rel laterally references a PHV, create_lateral_join_info() adds  
the PHV's whole ph_eval_at to the rel's lateral_relids, including any  
outer-join relids.  That forces those outer joins to be formed before  
the rel can be joined, which join_is_legal() enforces since commit  
55fa1b067.  
  
That is necessary for a subquery.  A subquery is planned separately  
and references the PHV through a single Param, so some nestloop must  
supply the PHV's value as a whole, and that is only possible once the  
outer joins in its ph_eval_at have been formed.  
  
But a function, VALUES or tablesample scan does not need the PHV as a  
whole.  When the outer joins in its ph_eval_at have not been formed  
yet, replace_nestloop_params() recurses into the PHV's expression and  
parameterizes the Vars within it, so the scan computes the expression  
itself.  That gives the same answer, because the scan can only be  
joined below such an outer join via outer-join identity 3, which  
requires its join clause to be strict for the nullable side.  So the  
rows the outer join would null-extend cannot match it anyway.  We  
already rely on this for PHVs that reference other PHVs laterally,  
since commit efeb12ef0.  For such rels the outer-join relids are  
therefore not a real requirement, and listing them needlessly rejects  
join orders that identity 3 permits.  
  
To fix, include outer-join relids in lateral_relids only when the  
referencing rel is a subquery.  
  
No back-patch.  This is a planner improvement rather than a bug fix,  
and we prefer not to change plans in stable branches.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4-fcAULTpWthZMHGOFK1J+Hz=Dvr1TO-M20cC317rOGOA@mail.gmail.com  

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

Fix nestloop parameter assignment for PHVs evaluated above outer joins

commit   : c1c930376854dda25ce07a74d34d1a16f91cd3aa    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 30 Oct 2026 10:49:26 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 30 Oct 2026 10:49:26 +0900    

Click here for diff

A NestLoop can supply a PlaceHolderVar as a parameter if the PHV can  
be evaluated from the lefthand rels plus the required-outer rels of  
the join.  A PHV's ph_eval_at can include outer-join relids, but  
required-outer sets need not: create_lateral_join_info() keeps  
outer-join relids out of the lateral dependencies it derives from  
ph_lateral.  So when an outer join within ph_eval_at had been computed  
by an enclosing nestloop's outer side, the test in  
identify_current_nestloop_params() failed and no plan node claimed the  
parameter.  This resulted in "failed to assign all NestLoopParams to  
plan nodes", or, if an unrelated upper NestLoop happened to cover  
ph_eval_at and claimed the parameter, "plan should not reference  
subplan's variable".  
  
To fix, have create_nestloop_plan() also count the outer joins that  
have already been computed by the outer rels in scope.  
  
Back-patch to v18, where commit a16ef313f made it possible to compute  
a PHV that is used as a nestloop parameter in the outer side of the  
NestLoop.  v16 and v17 can fail the same way, since ph_eval_at has  
included outer-join relids since v16, but they lack that machinery.  
Fixing them would mean adding join-order restrictions to  
have_dangerous_phv() that could change plans that work today, which  
does not seem worth the risk for a failure this unlikely.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4-fcAULTpWthZMHGOFK1J+Hz=Dvr1TO-M20cC317rOGOA@mail.gmail.com  
Backpatch-through: 18  

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

Fix twophase recovery log matching with verbose logs

commit   : d242d82fc482706f95c71cd1d159950cd8e785c5    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 30 Oct 2026 10:18:21 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 30 Oct 2026 10:18:21 +0900    

Click here for diff

Commit c11eb5de01b added checks for prepared transaction recovery  
messages in 009_twophase.pl that assumed no SQLSTATE appeared after  
the log severity. With log_error_verbosity=verbose, the SQLSTATE is  
included, causing the positive checks to fail and preventing the  
negative checks from detecting unwanted LOG messages.  
  
Allow an optional SQLSTATE in all five checks.  
  
Per buildfarm member prion, which uses log_error_verbosity = verbose.  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/2256937.1793317544@sss.pgh.pa.us  

M src/test/recovery/t/009_twophase.pl

Fix poorly-formatted comment.

commit   : cab16d214bc5b70dd3514c5631ffa1f0acb3fed3    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 29 Oct 2026 17:46:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 29 Oct 2026 17:46:24 -0400    

Click here for diff

Per buildfarm member koel.  

M contrib/pg_plan_advice/pgpa_planner.c

Fix issue with code manually adjusting a TupleTableSlot

commit   : 93ec486803b703fbc7fe7ea332da92e30cefc381    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 30 Oct 2026 09:49:59 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 30 Oct 2026 09:49:59 +1300    

Click here for diff

c456e3911 changed how tuple deforming populates the slot's tts_isnull  
array.  This is now done 8 columns at a time instead of 1 column at a  
time.  That code also now deforms the tuple's entire NULL bitmap on each  
incremental deform, where previously only the tts_isnull elements for  
newly deformed attributes got set.  This caused problems for grouping  
sets queries.  
  
In prepare_projection_slot() when grouped_cols was non-empty, the code  
would manually put "true" into the grouped column's tts_isnull element to  
represent the NULL for grouping sets which don't include that column.  
This was incompatible with the post-c456e3911 complete fresh of previously  
deformed tts_isnull elements, as if any further attributes needed to be  
deformed after the NULLs were manually placed, the deforming code would  
overwrite those NULLs.  
  
Here we fix this by changing the slot_getsomeattrs() call to always  
deform everything we need for this tuple.  That means there will be no  
additional tuple deforms for this tuple.  
  
Bug: #19783  
Reported-by: Alperen Keles <alpkeles99@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/19783-070e4bf0c73c1076@postgresql.org  
Backpatch-through: 19  

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

pg_stash_advice: Don't forget unsaved changes after a failed write.

commit   : 61553eacadbca0a084c7ae46214ffdee71208823    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 29 Oct 2026 12:37:07 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 29 Oct 2026 12:37:07 -0400    

Click here for diff

If the persistence worker hits an error while writing  
pg_stash_advice.tsv, it exits and the postmaster restarts it. The new  
worker doesn't think the file needs to be rewritten until something  
changes or the server shuts down. Instead, it should retry the failed  
write.  
  
This also fixes a second bug. The worker should record the current  
change count before, rather than after, setting stashes_ready.  
Failure to do so creates a narrow window during which any changes  
won't trigger the persistence worker to rewrite the file.  
  
Zsolt's original patch included a test case, but I've left that out  
here because it doesn't seem worth the cycles for a bug that seems  
unlikely to be reintroduced. If others disagree, we can revisit.  
  
Oversight in commit c10edb102ada607eb054bc9e23690109d86849ef.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Dongpo Liu <poe.liu@pm.me>  
Discussion: http://postgr.es/m/CAN4CZFMoWWdXhrNRk1id=N_K4o5kae3kQTtJi__UfzrEOeUCCA@mail.gmail.com  
Backpatch-through: 19  

M contrib/pg_stash_advice/stashpersist.c

pg_plan_advice: Mark PARTITIONWISE inapplicable on plain rels.

commit   : 2a55a15d6b7c1374716df427e701c46c009fbe2d    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 29 Oct 2026 11:35:49 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 29 Oct 2026 11:35:49 -0400    

Click here for diff

Previously, such advice was accepted, and just had the effect of disabling  
every path for the target relation, which isn't the worst imaginable  
behavior, but it's not difficult to do better. This commit causes such  
advice to instead be marked inapplicable, like INDEX_SCAN(some_table  
NO_SUCH_INDEX).  
  
One advantage of this change is that it improves the test coverage  
provided by test_plan_advice. In fact, prior to commit  
0f7dfd7936b9e99f9aeca00f52ab1692898ffff4, these changes caused  
test_plan_advice failures, because the defect fixed by that commit  
caused PARTITIONWISE advice to target the wrong relations. Without  
this change, the advice feedback doesn't show any sign that there's  
a problem, which is how that defect escaped discovery.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Discussion: http://postgr.es/m/CA+Tgmob3X+_CSjAa_BtU9bXrX_ge_HyvO=7gSCLtBpncGwn-kQ@mail.gmail.com  
Tested-by: Jakub Wartak <jakub.wartak@enterprisedb.com>  
Backpatch-through: 19  

M contrib/pg_plan_advice/expected/partitionwise.out
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/sql/partitionwise.sql

pg_plan_advice: Suppress advice from unflattened set operations.

commit   : a054b77e40d0579a9ee1218e2447d5af045d1083    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 29 Oct 2026 10:56:10 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 29 Oct 2026 10:56:10 -0400    

Click here for diff

Previously, we could generate GATHER, GATHER_MERGE, or NO_GATHER  
advice for portions of the plan tree generated by set operation  
planning. There are no upper-planner hooks we can use to enforce  
such advice, so we shouldn't generate it, either. Make it so, and  
also add a bunch of test cases to verify the behavior.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Discussion: http://postgr.es/m/CA+Tgmob3X+_CSjAa_BtU9bXrX_ge_HyvO=7gSCLtBpncGwn-kQ@mail.gmail.com  
Tested-by: Jakub Wartak <jakub.wartak@enterprisedb.com>  
Backpatch-through: 19  

M contrib/pg_plan_advice/expected/gather.out
M contrib/pg_plan_advice/pgpa_join.c
M contrib/pg_plan_advice/pgpa_scan.c
M contrib/pg_plan_advice/pgpa_scan.h
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_plan_advice/pgpa_walker.h
M contrib/pg_plan_advice/sql/gather.sql

Reduce log verbosity during prepared transaction recovery

commit   : c11eb5de01ba3401e880195888fb25703e0edf10    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 29 Oct 2026 23:09:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 29 Oct 2026 23:09:38 +0900    

Click here for diff

Previously, RecoverPreparedTransactions() logged each prepared  
transaction at LOG level at the end of recovery. With many unresolved  
prepared transactions, these messages could clutter the server log.  
  
Lower the severity of these messages to DEBUG2, matching the messages  
in PrepareRedoAdd() and PrepareRedoRemoveFull(), and report the  
number of successfully recovered prepared transactions in a single  
LOG message. This reduces log clutter while retaining per-transaction  
details at DEBUG2.  
  
Author: Ashutosh Sharma <ashu.coek88@gmail.com>  
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAE9k0Pmq1qQEvTKqsBTwUAWrNw+191zcTBPVKmmP5E3X2C+_Xw@mail.gmail.com  

M src/backend/access/transam/twophase.c
M src/test/recovery/t/009_twophase.pl

Use pg_parse_lsn() to parse LSN fields in backup_label

commit   : 76a55702d89ba9f5d0198c2d5d3d2d62357a8880    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 29 Oct 2026 20:45:29 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 29 Oct 2026 20:45:29 +0900    

Click here for diff

The START WAL LOCATION and CHECKPOINT LOCATION fields in backup_label  
accepted overlong high components, which could overflow and produce a  
different LSN from the one supplied.  
  
Use pg_parse_lsn() to validate and convert these fields, requiring one  
to eight hexadecimal digits per component and no trailing characters,  
as for pg_lsn input.  
  
Also detect INCREMENTAL FROM LSN without parsing its value, so that  
malformed values such as "junk" do not bypass the existing check  
against using an incremental backup directly as a data directory.  
  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Jan Nidzwetzki <jan@planetscale.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/OS7PR01MB18317EED85B1A72C69B226630F5672@OS7PR01MB18317.jpnprd01.prod.outlook.com  

M src/backend/access/transam/xlogrecovery.c
M src/backend/utils/adt/pg_lsn.c
M src/include/common/pg_parse_lsn.h

Fix eager aggregation below volatile join clauses

commit   : 27c844034f827b3910bc8a358780c6609ba87a41    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Thu, 29 Oct 2026 15:32:40 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Thu, 29 Oct 2026 15:32:40 +0900    

Click here for diff

Eager aggregation could push a partial aggregation down to a relation  
that is later joined using a join clause containing volatile  
functions.  The clause is then evaluated once per group rather than  
once per input row, which changes the number of times the function is  
executed.  
  
To fix, refuse to build grouped paths for a relation if any of its  
join clauses contains volatile functions.  
  
Back-patch to v19, where eager aggregation was introduced.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqSc_qtpuPm34qoS1z0LVx4+Hc+JcJkbDEVC=z2ai4VQ1w@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/util/relnode.c
M src/test/regress/expected/eager_aggregate.out
M src/test/regress/sql/eager_aggregate.sql

Empty partial_pathlist when unsetting consider_parallel flag

commit   : abda2a2c9b2a76687513ef223f782b333951149f    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 29 Oct 2026 16:19:49 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 29 Oct 2026 16:19:49 +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

Don't replace clone clauses with constant TRUE

commit   : f400289946f7d0e66a4169cf4aa56079f1422a2b    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Thu, 29 Oct 2026 11:27:12 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Thu, 29 Oct 2026 11:27:12 +0900    

Click here for diff

When reconsider_outer_join_clauses() finds an outer-join clause  
OUTERVAR = INNERVAR whose OUTERVAR is known to equal a constant, it  
pushes INNERVAR = CONSTANT into the inner side and replaces the clause  
with constant TRUE.  The replacement assumes that OUTERVAR cannot have  
gone to NULL where the clause is evaluated.  
  
That assumption fails for a clone made for outer join identity 3.  
When an outer join is pushed into the RHS of a lower outer join, its  
relid is not added to the joinrel until the commuted pair is complete,  
so a version of a clause that lacks that join's nulling bit can be  
applied above it, after it has null-extended OUTERVAR.  This is fine  
for the original clause, because it is strict, which is what allowed  
the commutation in the first place; but it is not fine for constant  
TRUE.  As a result, inner rows could be joined to null-extended outer  
rows, producing wrong query results.  
  
To fix, throw back a clone as-is rather than the TRUE replacement, as  
v15 and earlier did.  The derived INNERVAR = CONSTANT clause remains  
valid and is still pushed down.  This can leave a redundant join  
filter in some plans, as seen in an existing regression test.  
  
To keep the thrown-back clause from affecting selectivity estimates,  
including for parameterized scans, where the cached selectivity is not  
used, restore the redundancy marker removed by b448f1c8d: a norm_selec  
greater than 1 marks a redundant clause, for which  
clause_selectivity_ext() always returns 1.0.  
  
Back-patch to v16, where clone clauses were introduced.  
  
Bug: #19765  
Reported-by: Viktor Leis <leis@in.tum.de>  
Diagnosed-by: Tender Wang <tndrwang@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Co-authored-by: Nitin Motiani <nitinmotiani@google.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Discussion: https://postgr.es/m/19765-5778b18918040583@postgresql.org  
Backpatch-through: 16  

M src/backend/optimizer/path/clausesel.c
M src/backend/optimizer/path/equivclass.c
M src/include/nodes/pathnodes.h
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Do not take a full-page image for REGBUF_NO_CHANGE buffers

commit   : 27caf4ca5ae5ecfe66822d5a9c5803e0d1bc2ed0    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 29 Oct 2026 11:13:44 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 29 Oct 2026 11:13:44 +0900    

Click here for diff

A buffer registered with REGBUF_NO_CHANGE is not modified by the record  
and, in the case of the hash index AM, may be held with only a pin (no  
content lock).  The hash index code registers the primary bucket page  
this way in hashbucketcleanup(), _hash_freeovflpage() and  
_hash_squeezebucket(), solely to force a cleanup lock on that block  
during replay.  
  
When wal_consistency_checking includes "hash", XLogRecordAssemble()  
included a full-page image for block only pinned, because  
XLR_CHECK_CONSISTENCY forces an image regardless of REGBUF_NO_IMAGE.  
The record CRC is then computed over the image while a concurrent  
backend, which legitimately holds nothing stronger than a pin  
on that page, could modify it before the record is copied into the WAL  
buffers.  This would result is an intermittent "incorrect resource  
manager data checksum in record" failure on a standby.  
  
As of this commit, never take an image for a REGBUF_NO_CHANGE buffer,  
even under XLR_CHECK_CONSISTENCY.  There is no need to do a consistency  
check on a block not changed by a record.  verifyBackupPageConsistency()  
is taught to skip a registered block that carries no image rather than  
asserting one should be present.  
  
REGBUF_NO_CHANGE exists since 00d7fb5e2e39, so backpatch down to v17.  
On older branches, the CRC problem can be reproduced as well, but we  
lack the mechanism to check how a buffer is handled by the code  
assembling a record.  Per discussion, the long term picture should be to  
fix the hash index AM so as REGBUF_NO_CHANGE is removed.  This would be  
a HEAD-only change.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Diagnosed-by: Thomas Munro <thomas.munro@gmail.com>  
Author: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/ats4pi-RM0Uom0T9@floki  
Backpatch-through: 17  

M src/backend/access/transam/README
M src/backend/access/transam/xloginsert.c
M src/backend/access/transam/xlogrecovery.c
M src/include/access/xloginsert.h

commit   : 35b349a530c61628f4b7a7968212e594297523c6    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 29 Oct 2026 10:38:48 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 29 Oct 2026 10:38:48 +0900    

Click here for diff

transformJsonTable() handed the raw PASSING argument list both to the  
JsonFuncExpr built for the row pattern and, via  
transformJsonTableColumn(), to the JsonFuncExpr built for each column  
other than FOR ORDINALITY, so the same raw expressions were run through  
transformExpr() once for the row pattern and again for every such  
column.  That doesn't work for sublinks: transformSubLink() replaces  
the SubLink's raw subselect with the 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".  Any such PASSING argument therefore made  
JSON_TABLE fail unless all of its columns were FOR ORDINALITY.  
  
Fix by giving each transformation its own copy of the raw PASSING  
arguments.  
  
Bug: #19786  
Reported-by: Alperen Keles <alpkeles99@gmail.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Co-authored-by: Amit Langote <amitlangote09@gmail.com>  
Discussion: https://postgr.es/m/19786-70758103a4b2bff2@postgresql.org  
Backpatch-through: 17  

M src/backend/parser/parse_jsontable.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

SQL/JSON: fix error handling when coercing to a domain fails softly

commit   : b6e41c16f8ccbfca0d51c94bdb6043b6e8393d6f    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 29 Oct 2026 09:36:38 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 29 Oct 2026 09:36:38 +0900    

Click here for diff

SQL/JSON query functions could throw an error, or report the wrong one,  
in cases where the ON ERROR or ON EMPTY clause said what to do instead.  
This happened when the RETURNING type, or a DEFAULT expression,  
involved a domain: if the value failed to convert to the domain's base  
type, that failure was saved to be handled by the ON ERROR behavior,  
but the domain's constraints were then checked anyway, against the  
dummy NULL left behind by the failed conversion.  A CHECK expression  
can throw a hard error on that NULL, which ON ERROR cannot catch, and  
a NOT NULL constraint reports a violation that overwrites the saved  
error, so the error message ends up describing the wrong problem.  
  
For example, this failed with "division by zero" instead of returning  
11:  
  
  CREATE DOMAIN d AS int CHECK (1 / coalesce(VALUE, 0) = 0);  
  SELECT JSON_VALUE(jsonb '"x"', '$' RETURNING d DEFAULT 11 ON ERROR);  
  
Fix by stopping as soon as a soft error has been saved, in each of the  
places that kept going:  
  
* The domain constraint checks of a CoerceToDomain in an ON ERROR or ON  
  EMPTY DEFAULT expression, which is the only case where they are  
  evaluated softly.  ExecInitCoerceToDomain now emits a jump before each  
  constraint check that skips the remaining checks if an error has  
  already been saved.  
  
* populate_domain, called from json_populate_type when coercing to a  
  domain.  Return as soon as the conversion to the base type fails,  
  instead of going on to check the domain's constraints.  
  
* populate_record, likewise.  Stop populating the remaining columns as  
  soon as one of them fails.  
  
* ExecEvalJsonCoercion.  Return at once if the DEFAULT expression whose  
  result it would coerce has already failed, and leave throwing the  
  error to the COERCION_FINISH step that follows.  
  
Reported-by: jian he <jian.universality@gmail.com>  
Author: jian he <jian.universality@gmail.com>  
Discussion: https://postgr.es/m/CACJufxHDK39zF+1zZF6prH_wtn1SDt74_mrqYk1Oo82cCu44ng@mail.gmail.com  
Backpatch-through: 17  

M src/backend/executor/execExpr.c
M src/backend/executor/execExprInterp.c
M src/backend/utils/adt/jsonfuncs.c
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/sqljson_queryfuncs.sql

Work around failure with SPARC in base backup code

commit   : c97931c16d89c848696d2110a0f4831e4d6d1b69    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 29 Oct 2026 09:43:12 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 29 Oct 2026 09:43:12 +0900    

Click here for diff

As reported by buildfarm members thorntail and billbug, both running  
SPARC, 4a92c8c29bd0 is making the base backup code unstable on such  
platforms.  
  
The only suspicion I have at this stage is a stack frame issue, pointing  
to something unrelated to 4a92c8c29bd0, that the addition of an array  
worth a size of PG_CONTROL_FILE_SIZE within perform_base_backup() is  
able to trigger.  
  
thorntail complained with a SIGBUS, pointing at misaligned access, with  
a sporadic failure.  billbug complained with a SIGSEGV (siglongjmp issue  
with PG_ENSURE_ERROR_CLEANUP perhaps?) in a more stable fashion.  
  
The code is changed to use a palloc0() instead, which should cool down  
the problem with the stack, hopefully.  Unfortunately, I could not test  
this hypothesis directly, lacking an environment able to do so.  
  
Discussion: https://postgr.es/m/auGYf3jXtzLrr4gA@paquier.xyz  
Backpatch-through: 15  

M src/backend/backup/basebackup.c

SQL/JSON: always rethrow soft errors from DEFAULT expressions

commit   : 17b4e99638aa015a5046cf365bd923261d92c35b    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 29 Oct 2026 09:15:19 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 29 Oct 2026 09:15:19 +0900    

Click here for diff

The DEFAULT expression of an ON ERROR or ON EMPTY clause is compiled  
with the JsonExpr's ErrorSaveContext in effect, so that any error  
raised while evaluating it is saved rather than thrown and can be  
reported later as "could not coerce ON ERROR expression (DEFAULT) to  
the RETURNING type". That reporting is done by an  
EEOP_JSONEXPR_COERCION_FINISH step, but ExecInitJsonExpr only added  
that step when the DEFAULT expression needed a runtime coercion, or  
when its top-level node was a CoerceViaIO or a CoerceToDomain.  Those  
are not the only nodes that can save an error: the ErrorSaveContext  
applies to the whole expression tree, so a cast nested inside, say,  
an OpExpr saves its error just the same.  In that case there was  
nothing to rethrow it and the query silently returned NULL instead  
of failing, for example:  
  
  SELECT JSON_VALUE('"a"', '$' RETURNING int  
                    DEFAULT (('a' || (random() * 0)::int)::int + 0)  
                    ON ERROR);  
  
Fix by adding the COERCION_FINISH step after every DEFAULT expression  
that is evaluated softly, that is, whenever the ON ERROR behavior is  
not ERROR.  
  
Reported-by: jian he <jian.universality@gmail.com>  
Author: jian he <jian.universality@gmail.com>  
Discussion: https://postgr.es/m/CACJufxHDK39zF+1zZF6prH_wtn1SDt74_mrqYk1Oo82cCu44ng@mail.gmail.com  
Backpatch-through: 17  

M src/backend/executor/execExpr.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/sqljson_jsontable.sql
M src/test/regress/sql/sqljson_queryfuncs.sql

pg_plan_advice: Fix multiple problems with NO_GATHER advice.

commit   : 3269ccc961189572ebd8cff4742461ed0d172105    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 28 Oct 2026 15:04:05 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 28 Oct 2026 15:04:05 -0400    

Click here for diff

First, the documentation describes NO_GATHER in a way that suggests  
that it should both suppress partial path generation and also prohibit  
the placement of Gather and Gather Merge within a join problem, but in  
fact it only did the latter. Change it to do the former as well. Like  
commit f71a9969d58e3e70239fc51bbeae668db973b265, this is fallout from  
my failure to realize everything that needed to be changed when I  
abandoned the idea of clearing consider_parallel as a way to suppress  
parallel paths.  
  
Second, emit NO_GATHER advice for the non-partial children of a  
Parallel Append, because we want exactly the behaviors described  
above for that case. In order to reproduce the Parallel Append, we'll  
need an entirely non-parallel path for that child.  
  
Third, update the documentation to be more precise about what happens  
when NO_GATHER is applied to a child table. I believe I intended this  
to work in the way described in the first paragraph above, but because  
of the omission noted there, it had no effect at all. Moreover, the  
documentation described the two different effects of NO_GATHER as if  
subqueries were the only relevant case, but partitioning or table  
inheritance gives rise to similar effects, so clarify accordingly.  
  
Discussion: http://postgr.es/m/CA+Tgmob3X+_CSjAa_BtU9bXrX_ge_HyvO=7gSCLtBpncGwn-kQ@mail.gmail.com  
Tested-by: Jakub Wartak <jakub.wartak@enterprisedb.com>  
Backpatch-through: 19  

M contrib/pg_plan_advice/expected/gather.out
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_plan_advice/sql/gather.sql
M doc/src/sgml/pgplanadvice.sgml
M src/tools/pgindent/typedefs.list

Remove the redundant interface list and fix function headings in predicate.c

commit   : 4848fd6752ad6b88c5a066442df35ba208dfcec5    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 28 Oct 2026 17:02:19 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 28 Oct 2026 17:02:19 +0900    

Click here for diff

The interface list duplicates declarations in the headers and has  
accumulated stale signatures and missing entries. Remove it rather  
than maintaining a separate copy of the declarations.  
  
Also correct the headings above AtPrepare_PredicateLocks() and  
PostPrepare_PredicateLocks(), which incorrectly name the separate  
AtPrepare_Locks() and PostPrepare_Locks() functions.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>  
Discussion: https://postgr.es/m/CAHGQGwHww5o8abim0DGVFNb5bBre2a+V1twhH2cu-J21rYGcaQ@mail.gmail.com  

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

Remove unused PageIsPredicateLocked()

commit   : fde4444b48c8dc069db2e29d096dbea45a158cc9    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 28 Oct 2026 17:01:45 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 28 Oct 2026 17:01:45 +0900    

Click here for diff

The last caller of PageIsPredicateLocked(), an assertion in B-tree  
VACUUM, was removed in commit 47ad79122bc, leaving the function unused.  
  
Remove its implementation, declaration, and entry in the list of  
predicate locking interface routines.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAJ7c6TMCOi-TTfPSWh+wxkOMgqcvoG-FCWPU1iGCfrmA2JOajQ@mail.gmail.com  

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

Fix stale pg_index flags in the relcache for TOAST indexes

commit   : 27417270ab4e929aa3731e55945872206c425f75    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 28 Oct 2026 14:21:59 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 28 Oct 2026 14:21:59 +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/access/common/toast_internals.c
M src/backend/utils/cache/relcache.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/reindex_concurrently_toast.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/reindex_concurrently_toast.spec

Detect overflows in various numerical aggregate transfns

commit   : 903ce587e665af18ef1af24b4632e5ed4bf78edc    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 13:25:21 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 13:25:21 +1300    

Click here for diff

Here we add overflow checks to guard against overflowing the int8 sum of  
all inputs for sum(int2), sum(int4), avg(int2) and avg(int4).  Such an  
overflow is very unlikely for the int2 versions, but somewhat possible  
to hit for the int4 versions when given billions of large enough inputs.  
Since our code and machines are getting faster, and with the advent of  
things like columnar table AMs, it's getting more likely that such an  
overflow could occur in a real use case.  
  
No guards have been added to the average count.  That would require 2^63  
input rows, which is not possible to achieve in a single instance of  
PostgreSQL, given other limitations such as 64-bit LSNs.  
  
Fixing this only in master as we can probably get away with that today  
due to this still being unlikely for users to ever hit.  
  
Author: Andrei Lepikhov <lepihov@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/1ddc2a6f-4b26-43d9-9f3b-5b5db98a486d@gmail.com  

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

Avoid torn copy of the control file in base backups

commit   : 4a92c8c29bd0068ecc747cca5d77949660b5f0a8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 28 Oct 2026 08:42:35 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 28 Oct 2026 08:42:35 +0900    

Click here for diff

Base backups read the control file (pg_control) from disk without any  
protection against concurrent writes by the server, making it exposed to  
torn copies.  Attempting to use such a control file at startup would  
cause a failure with a CRC not matching.  
  
Base backups now read the control file while holding ControlFileLock.  
c558e6fd92f has done the same for some SQL functions.  The contents of  
the file are saved in memory and sent over the wire as-is.  
  
Backpatch down to v15.  This issue is older than v15 but v14 is left out  
of the picture as it is going to be EOL soon, so it does not seem worth  
taking a risk for.  
  
Author: David Steele <david@pgbackrest.org>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/d1697de1-eb7f-41bf-a4b7-bba7203df11f@pgbackrest.org  
Backpatch-through: 15  

M src/backend/backup/basebackup.c

Fix broken indentation caused by 34d52e6d3

commit   : 227de22095c8101905ce41e1ebf425239feed079    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 11:42:22 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 11:42:22 +1300    

Click here for diff

Per buildfarm member koel  
  
Backpatch to 19 to avoid unnecessary variations.  
  
Backpatch-through: 19  

M src/backend/executor/execGrouping.c

Add PG_RETURN_ARG macro and use it for sum(int2) and sum(int4)

commit   : d2adf339b06b8046d69be7974f9f7e490d2c9e84    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 10:36:38 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 10:36:38 +1300    

Click here for diff

This is intended for SQL-level functions written in C for cases when  
they want to return an input parameter unmodified; NULL if that parameter  
is NULL, or the exact value of the parameter otherwise.  The return type  
and the given input parameter must have matching types.  The caller must  
verify whether it's safe to not copy non-byval types and not de-toast  
variable-length typed inputs.  
  
Here we introduce two usages of the new macro for the transition  
functions for sum(int4) and sum(int2).  These just need to return the  
int8 aggregate state value unmodified when asked to transition a NULL  
input; the aggregate state may or may not be NULL at that point.  
PG_RETURN_ARG() is coded to work for either case.  
  
This is primarily being added to partially circumvent an argument  
against adding overflow checks on sum(int2) and sum(int4), which a pending  
patch proposes to do.  Effectively, here we're removing 1 jump per  
transition function, and that commit plans to add a new jump, so this  
commit allows a net zero increase in jumps for both of those functions.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAApHDvp-3v1OWbo7RavBf37=MjNScqhj4vyAyHOUDY51nGUnog@mail.gmail.com  

M src/backend/utils/adt/numeric.c
M src/include/fmgr.h

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

commit   : 03fa13256389e5a5d41c76b14a3c9ffd1e45eb35    
  
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

Reintroduce hash_mem cap on buckets in BuildTupleHashTable

commit   : 34d52e6d3daa7dfeecddc32be91f7d5ee4dcb92f    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 09:06:30 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 28 Oct 2026 09:06:30 +1300    

Click here for diff

8f29467c5 removed the hash_mem cap from the nbuckets calculation in  
BuildTupleHashTable() and put the trust into the planner to provide that  
function with a sane value, which it would only cap at 2^32.  There are  
various places in the planner which cannot provide good estimates here  
and it's been demonstrated that it's not difficult to craft a query  
which requests 2^32 buckets.  
  
Here we reintroduce the sanity checks so we don't end up making the hash  
table's initial size to something that would exceed hash_mem.  This may  
cause the hash table to have to grow several times before it fills, but  
that seems much better than having the executor OOM due to the request  
being too large.  Users are also used to work_mem and  
hash_mem_multiplier having an effect on query performance, so this  
shouldn't be too surprising.  It also restores the limits that were  
imposed pre-8f29467c5, which were tried and tested.  
  
Bug: #19759  
Reported-by: Alperen Keles <alpkeles99@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/19759-acd3f33402e54f36@postgresql.org  
Backpatch-through: 19  

M src/backend/executor/execGrouping.c

doc: Add note about promotion waits on backends stuck sending to clients.

commit   : b936425002c54abab86dab151efdbb6952314388    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 27 Oct 2026 11:13:04 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 27 Oct 2026 11:13:04 -0700    

Click here for diff

Commit df1be4ddc83 made promotion skip waiting for the barrier that  
refreshes each process's cached logical WAL logging state in some  
cases, but promotion still waits for it on a standby with wal_level =  
replica that has a valid logical slot. A backend blocked sending data  
to a client that has stopped reading can't process the barrier, so  
promotion can wait for a long time.  
  
Add a note about this case in the failover section, along with ways to  
get out of the wait and to bound it in advance.  
  
Backpatch to v19, where commit 67c20979ce7 introduced this wait.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Zhijie Hou <houzhijie22@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqToBk9c2sPAgha-kCgxJhVwn90j1sCyUXrvydq51LKAqA@mail.gmail.com  
Backpatch-through: 19  

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

Disallow NOT NULL NO INHERIT constraints on partitioned tables

commit   : 700b422af7e26cf310caf3fb76d78f4c8ca39c1f    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 27 Oct 2026 19:46:12 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 27 Oct 2026 19:46:12 +1300    

Click here for diff

This was blocked during normal CREATE TABLE, but cases such as CREATE  
TABLE (LIKE) would copy the source table's NOT NULL NO INHERIT constraints  
and apply them to the partitioned table being created.  This could mean  
that partitions didn't correctly receive the NOT NULL constraint when they  
were created, thus could contain NULL values.  
  
cacef1722 added a test to ensure CREATE TABLE (LIKE) PARTITION BY fails  
when the source table has any CHECK NO INHERIT constraints.  Here we do  
the same for NOT NULL constraints.  
  
It's probably unlikely that people have commonly done this, but the  
release notes may wish to note that people should check if this has  
happened to them.  The following query can used each database to identify  
problematic constraints:  
  
SELECT conrelid::regclass, conname, connoinherit  
FROM pg_constraint  
WHERE contype = 'n'  
  AND connoinherit = true  
  AND conrelid IN (SELECT oid FROM pg_class WHERE relkind = 'p');  
  
If no results are shown, the queried database isn't affected.  
  
To resolve these issues, unwanted constraints can simply be dropped from  
the partitioned table with:  
  
ALTER TABLE ... DROP CONSTRAINT ...;  
  
To remove the NO INHERIT flag, use:  
  
ALTER TABLE ... ALTER CONSTRAINT ... INHERIT;  
  
This will fail if any partition contains a NULL value in the given  
column.  Finding the cause of failures is made more difficult by the  
planner trusting that "WHERE col IS NULL" cannot be true because of the  
presence of a NOT NULL constraint.  Affected users may need to resort to  
tricks like WHERE col+0 IS NULL to find these.  If it was thought to be a  
common problem, then we could adjust get_relation_notnullatts(), and the  
equivalent functions on older branches to ignore constraints marked as NO  
INHERIT on partitioned tables, but currently that would require an  
expensive lookup to find the pg_constraint row.  
  
Backpatch to v18 where NOT NULL NO INHERIT constraints were added by  
14e87ffa5.  
  
Bug: #19770  
Reported-by: Ann C <anncalla@163.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Author: Nitin Motiani <nitinmotiani@google.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Nitin Motiani <nitinmotiani@google.com>  
Discussion: https://postgr.es/m/19770-7c6e75fc30df7e06@postgresql.org  
Discussion: https://postgr.es/m/CAH5HC96YCzOy+9JZLQ4n0sMchVnharTOXrr4sbYuh=_d+ffjAA@mail.gmail.com  
Backpatch-through: 18  

M src/backend/catalog/heap.c
M src/test/regress/expected/create_table_like.out
M src/test/regress/sql/create_table_like.sql

pg_stat_statements: Fix toplevel tracking across nesting levels

commit   : 23bf901fa5306b245e23ace52e5a6777ea08bed6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 15:17:17 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 15:17:17 +0900    

Click here for diff

pg_stat_statements decides whether a query is toplevel from the  
nesting level at the time each hook runs.  A QueryDesc can outlive the  
level it started at.  For example, a cursor's query starts at level 1,  
inside DECLARE, but if the cursor is closed implicitly at COMMIT,  
ExecutorEnd runs at level 0.  The entry created for the query at parse  
analysis has toplevel = false, so ExecutorEnd misses it and stores a  
duplicate with the raw query text and toplevel = true.  
  
The same happens with track = top when another extension such as  
auto_explain requests query instrumentation.  ExecutorEnd stores the  
query even though ExecutorStart did not track it.  
  
PGSS is upgraded to save the nesting level in the extension state of the  
QueryDesc when ExecutorStart() tracks a query.  ExecutorEnd() then uses  
it in place of the current level and skips the query if no state was  
saved.  
  
For now, only the nesting level is tracked in the private extension  
state attached to QueryDesc by PGSS.  auto_explain is not touched  
either.  All these pieces are left as future improvements.  
  
No backpatch is done, due to the ABI changes required in QueryDesc.  
This relies on the work done previously in e5d5d1ad1e3a.  
  
Reported-by: Gaurav Singh <gaurav.singh@yugabyte.com>  
Author: Sami Imseih <samimseih@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAEcQ1bZrgwKsauC=03otebkLk77Zc_hYNjhTP3OUdpXs++u+BA@mail.gmail.com  
Discussion: https://postgr.es/m/CAA5RZ0v281uwSudcFrY8BymSRDM4J6PAHfzqg_9R+i7zWbTb2A@mail.gmail.com  

M contrib/pg_stat_statements/expected/level_tracking.out
M contrib/pg_stat_statements/pg_stat_statements.c
M contrib/pg_stat_statements/sql/level_tracking.sql
M src/tools/pgindent/typedefs.list

Add custom extension states to QueryDesc

commit   : e5d5d1ad1e3aa495609e19fa716dcea6a39db1bb    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 15:05:59 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 15:05:59 +0900    

Click here for diff

Extensions sometimes need to carry private data from one executor hook  
to another for a given query.  ExecutorEnd() can run in a different  
context than ExecutorStart(), so backend-wide variables cannot be used  
for that.  
  
This commit adds a way for loadable modules to attach private state to a  
QueryDesc, modeled in the same fashion as what is already done for  
PlannerGlobal, PlannerInfo, RelOptInfo and ExplainState.  
  
GetQueryDescExtensionId() maps an extension name to a backend-local ID.  
SetQueryDescExtensionState() and GetQueryDescExtensionState() store and  
fetch an opaque pointer for that ID.  The array of pointers is allocated  
in the memory context of the QueryDesc, and is freed by FreeQueryDesc().  
What the pointers refer to is owned by the extensions.  
  
There are no users of this facility yet.  A follow-up commit will make  
use of it.  Some potential use cases have been identified for  
pg_stat_statements and auto_explain, where both need to be able to  
co-exist in peace.  Extensions living outside of core may also find a  
use for it.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Discussion: https://postgr.es/m/CAEcQ1bZrgwKsauC=03otebkLk77Zc_hYNjhTP3OUdpXs++u+BA@mail.gmail.com  

M src/backend/tcop/pquery.c
M src/include/executor/execdesc.h

Avoid truncated or zero-padded copies of replaced files in backups

commit   : 51d7bf5edcaf4f8a95bb10f96b7af76d00a2f83f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 13:53:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 13:53:26 +0900    

Click here for diff

Base backups call stat() on each file while scanning the data directory,  
and later send exactly that many bytes.  If the file is replaced by for  
example a concurrent rename(), the backup contains the new file  
truncated or zero-padded to the size of the old one.  This is harmless  
for relation files as WAL replay repairs them.  However, it causes harm  
for non-relation files manipulated as temporary file renamed in place.  
  
Here is a list of non-relation files that use a temporary file followed  
by a final rename() (I may be missing some):  
* postgresql.auto.conf  
* pg_logical/replorigin_checkpoint (a damaged copy fails its CRC check  
and prevents startup)  
* pg_prewarm's autoprewarm.blocks  
* pg_stash_advice.tsv.  
  
When sending files that are not relation files, fstat() is called again  
on the opened file and the refreshed stats are used for the tar header  
and the backup manifest.  Since the rename  
is atomic, the opened file is always complete.  Relation files keep using  
the earlier stat, to avoid copying data that WAL replay would restore  
anyway (because that's cheaper).  
  
Back-patch down to v15.  v14 is going to be EOL soon, so I have decided  
to leave it out of the picture (risk/reward thing).  
  
Author: David Steele <david@pgbackrest.org>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqS_On-pLgcv6xjH8mvGhdcPmfWtythW3r8pYKUG+hsiuQ@mail.gmail.com  
Backpatch-through: 15  

M src/backend/backup/basebackup.c

Count the last block of the validation scan in a concurrent index build

commit   : 99ea4a55270d5ce48bc33b9daf5d641818e03b89    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 12:12:47 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 27 Oct 2026 12:12:47 +0900    

Click here for diff

heapam_index_validate_scan() reports PROGRESS_SCAN_BLOCKS_DONE as the  
number of the block that the scan starts on, forgetting to count the  
last block scanned.  
  
Due to the last block not being counted, the number of blocks_done never  
matched blocks_total.  This information could remain on the view for a  
long time, depending on the waits done between the phases of CREATE  
INDEX CONCURRENTLY or REINDEX CONCURRENTLY.  
  
This is incorrect still purely cosmetic, so no backpatch is done.  
  
Author: Manu <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/179303526069.2212386.7608335332316408826@gmail.com  

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

Fix pg_iswcased() for some libc case mappings.

commit   : 8474bae2ba4cf8c6e91db800a441daffe22098ee    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 26 Oct 2026 15:11:21 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 26 Oct 2026 15:11:21 -0700    

Click here for diff

Some C libraries, such as macOS libc, case-map characters that they do  
not classify as upper or lower.  ILIKE index scans could then miss  
rows, because those characters stayed in the fixed prefix.  
  
Introduced in 630706ced0. 43a948b7b25 fixed similar issues, but missed  
this one.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqS6pr-hG-g=K6RTdRw53SnMZWz3iXvh_wi8rqLSf972sA@mail.gmail.com  
Backpatch-through: 19  

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

Initialize FOUND to false in PL/pgSQL event trigger functions.

commit   : 1dc45adefa076e9377718ee9529b375a70108734    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 17:15:27 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 17:15:27 -0400    

Click here for diff

The documentation says that FOUND starts out false within each  
PL/pgSQL function call.  plpgsql_exec_function() and  
plpgsql_exec_trigger() do set it so, but plpgsql_exec_event_trigger()  
did not, leaving it NULL until the first statement that sets it.  
  
Fix this by initializing FOUND to false, as the other two entry points  
do.  While at it, also set estate.err_text to "during function entry"  
during this action and the subsequent instrumentation plugin call,  
again to match the other two routines.  
  
Back-patch to v19, but no further.  It seems unlikely that any user  
code is depending on the current behavior, but just in case, let's  
not touch the stable branches.  
  
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAM2+6=U_=hZmgs1v1JJ-XJk2bpbfqQPP9MNRDbp5RoEsOW8xsQ@mail.gmail.com  
Backpatch-through: 19  

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

ssl: Don't disable SSL for all hosts when one SNI host fails to load

commit   : 07be6f384ca7a90c83055da46346e39a0b4d421d    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 21:33:22 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 21:33:22 +0100    

Click here for diff

On Windows and in EXEC_BACKEND builds every backend reloads the SSL  
configuration, with no previous one to fall back on.  If a single  
pg_hosts.conf entry failed to load there, the whole configuration was  
discarded and the backend ran without SSL for every host.  Fix by  
keeping the failed entry without an SSL context in child processes  
and failing the handshake only for connections selecting it.  
  
Also document that SSL_passphrase_cmd_reload must be enabled on  
Windows, like commit 0f4f45772c5 did for the GUC.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFM-Hn7-bdKC8=xwCQiE128Y1Xao+aft=Grq5QA9OkZ9Kw@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/runtime.sgml
M src/backend/libpq/be-secure-openssl.c
M src/test/ssl/t/004_sni.pl

doc: Fix option name in --filter description for pg_restore

commit   : cf765d6e1451c133f131b2ce8aa2cdc306f451b9    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 19:49:38 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 19:49:38 +0100    

Click here for diff

The description of the "index" filter keyword referred to the --index  
option as --indexes, which is a typo.  Oversight in commit a5cf808be5.  
  
Author: Taras Kloba <taras.kloba@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAODqpgofaVQBZ73rmPoj83Y1-6gbGhLiBKHD=82b1wiNkoF-AQ@mail.gmail.com  
Backpatch-through: 17  

M doc/src/sgml/ref/pg_restore.sgml

Fix PL/pgSQL's handling of anycompatiblemultirange.

commit   : 663c34c1eb2c71f35955814923ad578d0d9c0cf1    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 14:03:23 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 14:03:23 -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/backend/utils/cache/funccache.c
M src/pl/plpgsql/src/pl_comp.c

Avoid waiting for a safe snapshot in notify-reading transactions.

commit   : 6e9e5681b8a7ff3c5eea09db980e888c8e81ad9c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 13:01:59 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 26 Oct 2026 13:01:59 -0400    

Click here for diff

In the perhaps-unlikely scenario where your session default settings  
specify read-only, deferrable, serializable transactions, the implicit  
transaction created by ProcessIncomingNotify() honored those settings  
and would wait for a safe snapshot to be creatable; thereby getting  
blocked by any long-running concurrent transaction.  This is a bit  
surprising, especially if you think you are committing a transaction  
that doesn't have those properties.  
  
There doesn't seem to be any good semantic reason for NOTIFY reporting  
to wait for a safe snapshot, so create a code pathway that lets it  
just get a plain snapshot, independently of transaction mode.  
  
Given the lack of field complaints about such issues, I don't feel a  
need to back-patch this.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqQ1bmVwBw2CXiyZeWWP=XkHPXLPcQ7BSg2Q5JKSvDAnTA@mail.gmail.com  

M src/backend/commands/async.c
M src/backend/utils/time/snapmgr.c
M src/include/utils/snapmgr.h

Fix pg_basebackup long-path test on Windows

commit   : a757132e2fc8d443d557667b991e432c34cd0068    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 15:15:07 +0100    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 26 Oct 2026 15:15:07 +0100    

Click here for diff

Create the long tablespace directory through the short side of the  
Windows junction.  Also check mkdir and report its underlying error  
instead of failing later with a misleading misleading error for  
CREATE TABLESPACE.  
  
Author: Harrison Booth <harrisontbooth@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAAH-eSV4BJS7W=qRf7=Hk09XD3NhFOVvvKRjH+Lh0v9e_S=Seg@mail.gmail.com  

M src/bin/pg_basebackup/t/010_pg_basebackup.pl

Fix nbtree multi-level page deletion WAL record bug.

commit   : d42c5457e515319b3ead3a824436ed3c80d3a2ce    
  
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

pg_combinebackup: Reject out-of-range block numbers in incremental files

commit   : fcfd2456078db0a7591fd53c87c67f717ac73fba    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 26 Oct 2026 10:22:02 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 26 Oct 2026 10:22:02 +0100    

Click here for diff

The header of an incremental file was only partially validated:  
num_blocks and truncation_block_length were checked against  
RELSEG_SIZE, but the block numbers stored after them were not checked  
at all.  A block number of 0xFFFFFFFF made  
find_reconstructed_block_length() compute a reconstructed length of  
zero, since it adds 1 to the block number in 32-bit arithmetic, and  
reconstruct_from_incremental_file() then allocated zero-length  
sourcemap and offsetmap arrays but still indexed them with the block  
numbers taken from the file.  In an assertions-enabled build, this  
would be caught by an Assert, but otherwise it would index the arrays  
out of bounds, typically crashing the process.  
  
To fix, check the block numbers when the header is read, like the  
other header fields.  
  
Reported-by: Sajeeb Lohani working with TrendAI Zero Day Initiative  

M src/bin/pg_combinebackup/reconstruct.c

Fix partial two-phase files left by crash during checkpoint

commit   : a5ccf20801c821b72bb04d56b7320d52149a1ce5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 17:14:07 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 17:14:07 +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

Don't build child-join EC members that reference outside rels

commit   : 022a80fe6c1d82f7777bd52f9d3e5f9952533109    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 26 Oct 2026 11:32:04 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 26 Oct 2026 11:32:04 +0900    

Click here for diff

add_child_join_rel_equivalences() built a child version of every  
multi-relation EquivalenceClass member that overlapped the child  
join's topmost parent relids.  For a member that also references a  
relation outside the join, the child version is of no use for what  
these members exist for, which is matching sort pathkeys of the child  
join, since such a member cannot be computed there.  
  
The only effect of these members was on the clauses generated for  
parameterized child-join paths, and it was a harmful one.  Each child  
join nested within a larger child join supplies its own version of  
such a member, as does each rebuild of the same child join by GEQO.  
These versions are all the same expression, yet  
generate_join_implied_equalities() would equate them to each other,  
producing redundant clauses that share one rinfo_serial and so trip  
the assertion added by commit 8510bcc98.  Even a lone such member  
could yield a join clause that duplicates a condition already enforced  
by the inner path, as seen in an existing regression test whose plan  
now loses a redundant join filter.  
  
To fix, consider only members that can be computed at the child join's  
topmost parent joinrel.  This matches what add_child_rel_equivalences()  
has done for base relations since commit 2489d76c4.  
  
In passing, simplify how both functions compute the child member's  
relids.  Now that the parent member's relids are known to lie within  
the parent rel, the child member's relids are simply the child rel's.  
  
Back-patch to v19, as with commit 8510bcc98.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/4a0d7906-14f4-4992-8815-16e17e1f6655@gmail.com  
Backpatch-through: 19  

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

Look through wrapper paths when collecting enforced clause serials.

commit   : f9bc96514afc9c71d533568f62dc613be8356c4d    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 26 Oct 2026 10:02:54 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 26 Oct 2026 10:02:54 +0900    

Click here for diff

get_param_path_clause_serials() handles join paths and Append paths  
explicitly, and for anything else returns the ppi_serials of the  
path's ParamPathInfo on the assumption that it is a baserel scan.  But  
Material, Memoize, Projection, Sort, IncrementalSort, Unique, Agg and  
GroupingSets paths all inherit their subpath's ParamPathInfo, and that  
assumption fails when the subpath is a join or Append.  
  
This could drop a join clause for good.  If a LATERAL UNION ALL  
subquery references an outer relation in an expression that becomes an  
EquivalenceClass member, the members get no child version of it, so  
their parameterized scans cannot enforce the derived clause.  The  
appendrel's ParamPathInfo claims it nonetheless, and once a  
Materialize sat on the Append, create_nestloop_path() dropped the  
clause from the join above as already enforced, returning rows that  
fail it.  
  
To fix, make get_param_path_clause_serials() recurse through such  
wrapper paths, since they enforce no clauses of their own.  Also use  
it in get_memoize_path(), which unsafely read ppi_serials directly for  
its inner-unique check.  
  
To try to clarify what's going on here, introduce a new function  
get_wrapper_parampathinfo() that pathnode.c should use instead of  
directly assuming that copying a wrapper path's subpath's param_info  
is what to do.  This is just cosmetic at present but might become  
less so in future.  
  
Back-patch to v16, where the serial-based detection of enforced  
clauses was introduced.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49jVFRZ7oOgMK9zYt7d=SLxpiz=dN=QMu5iV8TS+9T0AA@mail.gmail.com  
Backpatch-through: 16  

M src/backend/optimizer/path/joinpath.c
M src/backend/optimizer/util/pathnode.c
M src/backend/optimizer/util/relnode.c
M src/include/nodes/pathnodes.h
M src/include/optimizer/pathnode.h
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Set HEAP_XMAX_INVALID for tuples updated by aborted subtransaction

commit   : e7f4463e869cc006b7d3210c264d92b1016dcad2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 09:54:08 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 26 Oct 2026 09:54:08 +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   : 54f36adcbcda8dec03e78c1cec453b9ebf3db3d2    
  
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.in.c

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

commit   : 6e06f62816fc99e7cc2e5ea8210fe413916d74cf    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 25 Oct 2026 18:18:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 25 Oct 2026 18:18:29 -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

Fix leaked hash scans in pg_listening_channels().

commit   : dfd7ede529f288639760444a9c69f3f7bb65450c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 25 Oct 2026 15:14:13 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 25 Oct 2026 15:14:13 -0400    

Click here for diff

Commit 282b1cde9 changed pg_listening_channels() to keep a hash table  
scan open between calls of this set-returning function.  If the  
executor stops fetching rows early, as with a target-list call under  
LIMIT, the scan remains registered until transaction end, resulting in  
leak complaints and eventually a PANIC.  
  
Instead materialize the result in a tuplestore, so that we can  
complete the hash scan within a single call.  
  
Author: Joel Jacobson <joel@compiler.org>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/069fc976-bee1-4f0f-b22b-86ef7ed4f9ff@app.fastmail.com  
Backpatch-through: 19  

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

Add pg_attribute_counted_by() to various flexible array members

commit   : 7a04cac0c3b376922daa7e3b5d5c628aa0e661ba    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 25 Oct 2026 12:48:21 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 25 Oct 2026 12:48:21 +0100    

Click here for diff

Annotate flexible array members whose element count is held by another  
member of the same struct, so that the compiler knows the real extent  
of these arrays.  
  
This is an initial set of annotations.  More will follow over time,  
but those might need more investigation or code adjustments.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M contrib/hstore/hstore_io.c
M contrib/pageinspect/brinfuncs.c
M contrib/pg_visibility/pg_visibility.c
M src/backend/access/brin/brin_minmax_multi.c
M src/backend/access/nbtree/nbtutils.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogprefetcher.c
M src/backend/catalog/index.c
M src/backend/commands/tablespace.c
M src/backend/commands/trigger.c
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/checkpointer.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/storage/buffer/freelist.c
M src/backend/storage/ipc/dsm.c
M src/backend/storage/ipc/pmsignal.c
M src/backend/utils/adt/rowtypes.c
M src/backend/utils/adt/tsvector_op.c
M src/backend/utils/cache/typcache.c
M src/backend/utils/sort/sharedtuplestore.c
M src/backend/utils/sort/tuplesort.c
M src/bin/pg_dump/pg_dump.h
M src/bin/pg_rewind/filemap.h
M src/bin/pgbench/pgbench.c
M src/include/fe_utils/parallel_slot.h

ci: Enable PCH in mingw cross job

commit   : 4075409de08c7e4f25a6f8d91bbf43d7b9dceb46    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 25 Oct 2026 10:13:30 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 25 Oct 2026 10:13:30 +0100    

Click here for diff

This will make this job run a bit faster.  
  
Co-authored-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/e52e2c29-4834-4c64-a200-eddcba38fb4d%40eisentraut.org  

M .github/workflows/pg-ci.yml

ci: Convert CompilerWarnings job to meson

commit   : 3ca57291ff302793f2f559a4644862ca4b1f09bf    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 25 Oct 2026 10:13:30 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 25 Oct 2026 10:13:30 +0100    

Click here for diff

This is part of the overall move toward meson.  This particular step  
was previously held up because the headerscheck target was not ported  
to meson, but this has been done a few months ago (commit  
e82fc27e095).  This conversion is relatively straightforward.  The  
scope of each individual build step (e.g., what features it enables,  
what optimization level it uses) has been maintained, except as noted.  
  
It actually covers a bit more now, as it also compiles various test  
code via the testprep target.  
  
One thing we're losing is the sharing of the configure cache between  
the steps (gcc.cache, clang.cache).  There is a way to do that in  
meson (meson-private/coredata.dat), but it's not meant to be used  
across different build directories, and so making that work might be a  
more significant restructuring.  The overall performance of the CI  
runs seems to be about on par nonetheless.  
  
Bitcode for JIT inlining is no longer built in this job, since meson  
doesn't support it.  It added little to warning coverage, and the  
Linux autoconf job still builds it.  
  
Co-authored-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/e52e2c29-4834-4c64-a200-eddcba38fb4d%40eisentraut.org  

M .github/workflows/pg-ci.yml
A src/tools/ci/mingw-cross-file.txt

Retain locks after marking the partitioned index valid

commit   : 2ebd684974375e9c68b43577b7e46a83597c8d95    
  
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

doc: Fix removal of FreeBSD mention in DocBook section

commit   : 0019a1ecf4c7615a2570d21eeb4b32ae3b371f18    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 24 Oct 2026 22:53:43 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 24 Oct 2026 22:53:43 +0200    

Click here for diff

Commit 7c4098e6ba8 removed the mention of FreeBSD as an example project  
using DocBook, but embarrassingly missed parts of the sentence.  Fix by  
removing all of it now.  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/144397.1792874546@sss.pgh.pa.us  

M doc/src/sgml/docguide.sgml

doc: Remove mention of FreeBSD using DocBook

commit   : 7c4098e6ba8b0fa7fcadae254fedbfcea5bc5839    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 24 Oct 2026 22:35:16 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 24 Oct 2026 22:35:16 +0200    

Click here for diff

The FreeBSD Project has switched documentation markup format from  
DocBook to Asciidoc, so remove the reference on our documentation  
page.  
  
Reported-by: Matemática A3K <matematica.a3k@gmail.com>  
Discussion: https://postgr.es/m/CA+FDnhJFvFGk7Kdc=yX9=3aeRC3p4bdfYLX+x5GbOcGNKtWwkw@mail.gmail.com  

M doc/src/sgml/docguide.sgml

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

commit   : 1b0b45c5ab1aa5dc3c71cfa8e228306c2b92875c    
  
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

Emit null-keyed hash join outer tuples immediately when feasible.

commit   : 126976a8ffcfa47f40d3df09243ebf4606001912    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 23 Oct 2026 11:35:42 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 23 Oct 2026 11:35:42 -0400    

Click here for diff

Commit 1811f1af9 put outer tuples with null join keys into a  
tuplestore and emitted them at the end of the batch, which risks  
expensive spills to disk if there are a lot of them.  It's difficult  
to avoid the tuplestore in a multi-batch parallel join.  But in the  
non-parallel and single-batch cases we can just emit such tuples  
immediately, at the tiny cost of propagating the "is-null" result  
flag one call level further up.  This avoids a performance regression  
from v18 for such cases.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqTgugmYrtnP_11NjL_GCXwAfzVfm5WKUNFsfZOzxDF2rA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/executor/nodeHashjoin.c
M src/include/executor/hashjoin.h
M src/include/nodes/execnodes.h

Remove faulty Asserts added by 1999fe227.

commit   : 896246ea10cb9d20f69d0442223ce5fa9b365636    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 23 Oct 2026 10:29:45 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 23 Oct 2026 10:29:45 -0400    

Click here for diff

I added these assertions in an attempt to show that setting  
ret_old_alias/ret_new_alias in set_deparse_plan() fully covered  
all the parts of the plan where RETURNING Vars could be found.  
But it emerges that the returningOldAlias/returningNewAlias  
fields they are filled from can sometimes be NULL themselves,  
allowing the asserts to fail.  We discussed various ways that  
we might adjust the rewriter to prevent that, but the upshot  
of the discussion was just to remove the asserts again.  
  
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWWsORQbyViXmsvT4-NWkjuykkjjk2c+gQtq+vw2PJON-A@mail.gmail.com  
Backpatch-through: 18  

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

Fix handling of some SQL/JSON locations in query jumbling

commit   : 1910daf98317bc321562e7d7436a791538825d0e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 23 Oct 2026 16:21:54 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 23 Oct 2026 16:21:54 +0900    

Click here for diff

GetJsonBehaviorConst() builds Const values for clauses like ON EMPTY or  
ON ERROR in SQL/JSON, and was setting up a location without considering  
the fact that these are not constants as per the query text: they are  
query keywords.  For example "EMPTY ARRAY ON EMPTY" became "$2 ARRAY ON  
EMPTY", leading to confusing information reported for example in PGSS.  
  
The Const nodes used by GetJsonBehaviorConst() is now left unset.  The  
location was only used for an error position.  This code path cannot be  
reached currently but we cannot use the expression location if not set;  
this spot is switched to the location of behavior keyword instead, which  
is better than nothing.  
  
This is obviously a bug.  Unfortunately, no backpatch is done as this  
impacts the information of saved in PGSS and the shape of the Nodes  
themselves.  
  
Oversight in 6185c9737cf4.  
  
Author: Ilya Staroverov <i.staroverov@ftdata.ru>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/457969A9-5D24-422F-B09E-F388053DE028@localhost.localdomain  

M contrib/pg_stat_statements/expected/sqljson.out
M src/backend/parser/parse_expr.c

Temporarily remove a test case that hits an unfixed bug

commit   : f52d405113c83f691fffac261bfec297209c21b4    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 23 Oct 2026 08:00:13 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 23 Oct 2026 08:00:13 +0900    

Click here for diff

Buildfarm animal trilobite turned red because the test that is  
being removed crashes due to a long-standing bug in how  
ri_FetchPreparedPlan() handles an invalid SPI plan, which the test  
started reaching after 6aecabcd5ed made it go through the SPI path  
and which CLOBBER_CACHE_ALWAYS exposes.  Fixing that bug will take  
some time, so in the meantime remove the test case so the buildfarm  
can turn green and other committers are not distracted by this.  
  
The test will be re-added with the commit to fix the bug.  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/3043944.1792163844@sss.pgh.pa.us  
Discussion: https://posgre.es/m/CA+HiwqE=QFc7xS72xZ5scFNUbLdOCJyvew+3toLebsWipJOqnQ@mail.gmail.com  
Backpatch-through: 19  

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

Accept empty tsquery in binary input.

commit   : 3c5a4a867f2a4c72885de39306242661427f6e4f    
  
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

Qualify unqualified names in CREATE SCHEMA elements again.

commit   : b6dae498dfa60c9d15abf791d51434e8d23e5cae    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 22 Oct 2026 13:19:47 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 22 Oct 2026 13:19:47 -0400    

Click here for diff

Commit a9c350d9e stopped filling in the new schema's name, and the  
partial revert in 962e0a723 kept that, which was an error: it allows  
names that will be looked up rather than created to be resolved in  
pg_temp or pg_catalog, which they should not be.  This for example  
allowed a CREATE INDEX to target a chance-match table name in pg_temp  
rather than the expected table in the new schema.  Revert to the old  
approach of putting the new schema's name into each RangeVar.  We can  
still keep the refactorization of dealing with RangeVars as such  
instead of working with char* pointers.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqRMkfs25+7ReRkF4WCogEnD1k1=L=fmA_kxbtDfmhFn-g@mail.gmail.com  
Backpatch-through: 19  

M src/backend/parser/parse_utilcmd.c

Clear async.c's isAdvancing flag when a notify read is aborted.

commit   : 871dee0ccbe292cf4c2874aa7b460d242262d242    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 22 Oct 2026 12:26:20 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 22 Oct 2026 12:26:20 -0400    

Click here for diff

asyncQueueReadAllNotifications() sets our isAdvancing flag and clears  
it when done.  But if we error out in between, for example on a  
cancel while waiting for a safe snapshot, the flag stays set and  
SignalBackends() never advances or wakes us again, so the queue tail  
stops moving.  To fix, clear the flag in AtAbort_Notify().  
(We need not worry about this in subtransaction abort, since  
asyncQueueReadAllNotifications() is only called in top-level  
transactions.)  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqQ1bmVwBw2CXiyZeWWP=XkHPXLPcQ7BSg2Q5JKSvDAnTA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/async.c

Use pg_parse_lsn() for timeline history switchpoints

commit   : 5ffb8c7409385c58e5c1abaa22ee77ba4c1b5c33    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 17:35:28 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 17:35:28 +0900    

Click here for diff

readTimeLineHistory() previously parsed WAL switchpoints in timeline  
history files using sscanf("%X/%08X") into uint32 values. An  
overlong high component could overflow, while an overlong low component  
was truncated to its first eight digits. Trailing characters were also  
ignored.  
  
Extract the switchpoint token and use pg_parse_lsn() to validate and  
convert it, requiring one to eight hexadecimal digits per component  
with no trailing characters, as for pg_lsn input. This matches the  
change to pg_rewind's history file parser in commit f31d6fbc31d.  
  
Author: Jan Nidzwetzki <jan@planetscale.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/8b1abbd0-7335-4e68-93ec-91cdbbfd9568@planetscale.com  

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

pg_stat_statements: Add tests for SQL/JSON query patterns

commit   : ae75d12b500f01eb3ce9a46418beb2e9301e3e0b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 22 Oct 2026 17:12:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 22 Oct 2026 17:12:21 +0900    

Click here for diff

A new test file is added to track how the various SQL/JSON query  
patterns fare in PGSS, as allowed by the parser:  
- Query functions  
- JSON_TABLE  
- Constructors and predicates.  
- etc.  
  
This will be handy for the evaluation of some follow-up patches that aim  
to tweak the query jumbling for a portion of some of these SQL/JSON  
queries.  Some of them are currently slightly broken, tracking as  
parameters what should be a keyword, and we never knew about them.  
Until now.  
  
The author has written most of the patch.  I have noticed a couple of  
gaps and some inconsistencies upon further review, leading to a result  
more consistent with the usual approach used by the PGSS tests.  
  
Author: Ilya Staroverov <i.staroverov@ftdata.ru>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/457969A9-5D24-422F-B09E-F388053DE028@localhost.localdomain  

M contrib/pg_stat_statements/Makefile
A contrib/pg_stat_statements/expected/sqljson.out
M contrib/pg_stat_statements/meson.build
A contrib/pg_stat_statements/sql/sqljson.sql

Use pg_parse_lsn() for IDENTIFY_SYSTEM responses in libpqwalreceiver

commit   : ba6d9ee259cdb2a6c862a4741b16194106e00a9a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 16:45:45 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 16:45:45 +0900    

Click here for diff

libpqwalreceiver parses the WAL flush location returned by  
IDENTIFY_SYSTEM using sscanf("%X/%X") into uint32 values. This  
accepts overlong components and trailing characters, potentially  
producing a different LSN from the one supplied by the upstream server.  
  
Use pg_parse_lsn() instead, requiring one to eight hexadecimal digits  
per component and no trailing characters, as for pg_lsn input. Reject  
malformed locations with the existing protocol violation error.  
  
Suggested-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Jan Nidzwetzki <jan@planetscale.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com  

M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Reject overlong LSN components in START_REPLICATION

commit   : 4a842a1d6570b0875fb705e6335a16b525cbbd79    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 16:45:06 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 16:45:06 +0900    

Click here for diff

The replication command scanner accepts arbitrarily long hexadecimal  
LSN components, but converts them with sscanf("%X/%08X") into uint32  
values. An overlong high component can overflow, while an overlong low  
component is truncated to its first eight digits. This can cause  
START_REPLICATION to use a different WAL location from the one requested.  
  
Use pg_parse_lsn() to validate and convert the complete LSN token,  
requiring one to eight hexadecimal digits per component, as for pg_lsn  
input. This applies to both physical and logical replication.  
  
Reported-by: ♂π≌26218 <1991230470@qq.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Jan Nidzwetzki <jan@planetscale.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com  

M src/backend/replication/repl_scanner.l
M src/test/recovery/t/006_logical_decoding.pl

Fix argument handling in pg_indexam_progress_phasename()

commit   : 66042bd3ebd4a7d5b614bf7435f29a8cac06fea9    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 22 Oct 2026 14:39:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 22 Oct 2026 14:39:03 +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

Add error context for sequence synchronization.

commit   : 219334a2252729054db98288df64e61b2968f2b7    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 22 Oct 2026 10:45:59 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 22 Oct 2026 10:45:59 +0530    

Click here for diff

An unhandled ERROR while synchronizing a sequence (for example, when  
SwitchToUntrustedUser() fails because the subscription owner cannot SET  
ROLE to the sequence owner) makes the sequencesync worker exit and be  
restarted, repeatedly, until the user resolves the problem, as with the  
apply worker. The error message does not identify the sequence or  
subscription responsible.  
  
Add an error context callback around per-sequence validation and  
synchronization in copy_sequences() so that such errors report the  
schema-qualified sequence name and subscription name in CONTEXT.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Zhijie Hou <houzhijie22@gmail.com>  
Reviewed-by: Ajin Cherian <itsajin@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFMGiyksxVD1M7cc7_5E+evfi51xmDxw4uqdmvoeH53Ugw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/replication/logical/sequencesync.c
M src/test/subscription/t/036_sequences.pl

psql: Fix tab completion for DROP INDEX CONCURRENTLY

commit   : f2edf5dd00d174c7b1396f0a777375368a26c752    
  
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.in.c

Fix slot names in the standby slot removal check

commit   : d6cf162f74a89bd717ed4439e946aabf4317bc46    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 09:24:28 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 09:24:28 +0900    

Click here for diff

The DROP DATABASE test in 035_standby_logical_decoding.pl created  
slots with the prefix "drop_db_" but checked for their removal using  
"drop_db". Sined names never existed, the checks passed  
even if the actual slots remained.  
  
Fix this by using the correct prefix when checking for slot removal.  
  
Backpatch to v16, where this testce the check was introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/CAHGQGwEnuLZnFRF5CzK47n_hXT-iCXnzirxG2v_V-=QNMLkpEA@mail.gmail.com  
Backpatch-through: 16  

M src/test/recovery/t/035_standby_logical_decoding.pl

Fix a race in 035_standby_logical_decoding.pl

commit   : 487b710bc4784f7a70f8294f376cf2984ebaddb0    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 09:21:36 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 22 Oct 2026 09:21:36 +0900    

Click here for diff

Buildfarm animals francolin and kestrel reported intermittent failures  
in 035_standby_logical_decoding.pl.  
  
The test checks that replaying DROP DATABASE on a standby terminates  
pg_recvlogical with the expected recovery-conflict message and removes  
the database's replication slots. To exercise this while pg_recvlogical  
is streaming, the test must wait for streaming to start before dropping  
the database on the primary.  
  
Previously, the test treated an active slot in pg_replication_slots as  
confirmation that pg_recvlogical was streaming. However, the slot can  
become active before pg_recvlogical has entered streaming mode. If  
DROP DATABASE is replayed during this window, pg_recvlogical can report  
a connection-closed error instead of the recovery-conflict message,  
causing the test to fail.  
  
Run pg_recvlogical with --verbose and wait for "streaming initiated"  
instead of checking whether the slot is active. This ensures that  
pg_recvlogical has entered streaming mode before the database is  
dropped on the primary.  
  
Back-patch to v16, where this test was introduced.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/a50ff89b-fb2c-4912-8f89-50dd0bd0916b@gmail.com  
Backpatch-through: 16  

M src/test/recovery/t/035_standby_logical_decoding.pl

Reject currtid2() on unlogged tables during recovery.

commit   : fded90eec3ebab14a327a3c40263e2366eb3c42a    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 11:10:35 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 11:10:35 -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   : 1e707d32564497ed2478f4186b90d0821719957b    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 10:44:03 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 21 Oct 2026 10:44:03 -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   : dd568b047acc7cf7c13bcb397506ba850eb5a9e7    
  
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

Report shared buffer exhaustion as insufficient resources

commit   : 4b97fd15fb497d2810a29cd30bfacd89400b596c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 21 Oct 2026 23:40:46 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 21 Oct 2026 23:40:46 +0900    

Click here for diff

When all shared buffers examined are pinned, a query can fail with  
"no unpinned buffers available". This can happen when shared_buffers  
is too small for the workload, but the error was reported as an internal  
error, making a resource shortage look like a server bug.  
  
Replace elog() with ereport() to report this condition with SQLSTATE  
53000 (insufficient_resources) instead of XX000 (internal_error),  
matching the corresponding local-buffer error. Reword both messages  
to clarify whether shared or local buffers are involved.  
  
Author: Ma Xueting <ma@sraoss.co.jp>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/TYWP286MB2571C92032EE9D1B8F2BFACFEF812@TYWP286MB2571.JPNP286.PROD.OUTLOOK.COM  

M src/backend/storage/buffer/freelist.c
M src/backend/storage/buffer/localbuf.c
M src/test/regress/expected/temp.out

doc: Correct psql's \d+x documentation for sequences

commit   : 54f38d8115918b2145a5f7995b19c3dfc3b2d7ea    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 21 Oct 2026 23:37:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 21 Oct 2026 23:37:38 +0900    

Click here for diff

Commit 00f4c2959d6 added the x modifier to psql's list commands, making  
\d+x display sequence descriptions in expanded mode. However, the  
documentation and \? help indicate that x applies only without a pattern.  
  
Clarify that \d+x also uses expanded mode when describing sequences  
matched by a name or pattern, and update the command help accordingly.  
Also clarify that the same restriction applies to \x on and \x auto.  
  
Backpatch to v18, where the x modifier was introduced.  
  
Reported-by: George MacKerron <george.mackerron@databricks.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/FEA91EA9-CF32-4920-9674-F2C3E01C3807@databricks.com  
Backpatch-through: 18  

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

psql: Fall back to English for unsafe hidden query labels.

commit   : e7ba5eb899884693ad8d9c62fa7a23f155a4a350    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 21 Oct 2026 10:34:44 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 21 Oct 2026 10:34:44 -0400    

Click here for diff

This completes the project begun in commit 294d2196c of making  
commit 41d69e6dc's hidden query labels safe against unexpected  
encoding-related failures.  At that point we were still uncertain  
exactly what rule to use to decide that a translated label is safe.  
The rule adopted here is: translate the label only when the client  
and server encodings match and the translated bytes pass the same  
encoding verification check the server will apply.  This is enough  
to ensure that no error will be thrown, and it avoids the difficult  
task of identifying what encoding gettext() thinks it's using.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqRv7yhBOhF0YvSr6ZB7rvsPCjnXSPj8=3bKcSJuYvNrBA@mail.gmail.com  
Backpatch-through: 19  

M src/bin/psql/common.c

Fix ILIKE patterns with non-ASCII bytes in single-byte encodings.

commit   : c00a97b646c04c0d895cca44a2b24ad7abec8a6c    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 21 Oct 2026 05:46:37 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 21 Oct 2026 05:46:37 -0700    

Click here for diff

Commit 1e493158d3d changed the MATCH_LOWER implementation of GETCHAR()  
from SB_lower_char() to use pg_ascii_tolower().  The latter returns an  
unsigned char; but the local variable in C_IMatchText was a char.  
  
For single-byte encodings and the C locale, that could lead to a  
broken signed/unsigned comparison.  For example, the pattern  
U&'%\00C6' would never match.  
  
Fix by casting the result of pg_ascii_tolower() explicitly to char.  
  
Reported-by: Greg Burd <greg@burd.me>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/_GW2V-rd0QW4BTguAJriA9XVmjOn2mR3-YeAZr9ZU6EtlLvYPEm_r_fV5wGKzSNMzboj_nqn3fk72AYAvOKzEnPlCCHteaYrgESrIhPg6l8=@burd.me  
Backpatch-through: 19  

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

Fix lateral references in sort keys added by createplan.c

commit   : 6b9f40d49ae33eb0b4a7c77666fe4971ef7ba087    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 18:00:20 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 18:00:20 +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   : 456ee18045d03f8eb7194f7b7fcf53595704b44b    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 15:37:31 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 21 Oct 2026 15:37:31 +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 logical replication with lossy identity indexes.

commit   : 3cde90ecc5f85e7c6cb9fba29d473b2f6dd40ee1    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 21 Oct 2026 08:50:02 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 21 Oct 2026 08:50:02 +0530    

Click here for diff

A GiST index on a multirange stores only its bounding range, so different  
multiranges can produce the same index key. However,  
RelationFindReplTupleByIndex() and RelationFindDeletedTupleInfoByIndex()  
assume that matches through a primary key or replica identity index are  
exact and skip the equality check. This can cause updates or deletes to  
target the wrong row, and conflict detection to report update_deleted  
instead of update_missing.  
  
Fix this by rechecking candidates when the index scan sets xs_recheck.  
Compare only the index key columns, using the scan keys' equality  
operators and collations to match the index's notion of key equality.  
  
Backpatch to 18, where WITHOUT OVERLAPS was introduced. The change to  
RelationFindDeletedTupleInfoByIndex() applies only to 19 and later, where  
update_deleted conflict detection was added.  
  
Reported-by: Andres Freund <andres@anarazel.de>  
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>  
Author: Zhijie Hou <houzhijie22@gmail.com>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: kedar anavardekar <kedar.anavardekar@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/kcyaok346iwocfdourf2oojgtz7ggxmh2ugis7qqhggs4qfzc2@cu6pkox4rfwp  
Discussion: https://postgr.es/m/e5nb5jbus2oa3pffmlo7pdvdckmchd54tqld4k3n6huyg5xxqn@7rounyvufjx6  
Discussion: https://postgr.es/m/CA+renyWzTBC4GetPzJM1KqrejrmOWcGnn2NaA7tpee17HFxRPw@mail.gmail.com  
Backpatch-through: 18  

M src/backend/executor/execReplication.c
M src/test/subscription/t/034_temporal.pl
M src/test/subscription/t/035_conflicts.pl

Fix cleanup of reused pgstats entries in pgstat_release_entry_ref()

commit   : e9d0600aba5467b352eb67aaf6ad92a9a4776b0a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 21 Oct 2026 10:55:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 21 Oct 2026 10:55:21 +0900    

Click here for diff

When a stats entry is reinitialized and dropped again while a backend  
still holds a reference from an older generation, the backend releasing  
the last reference found a generation mismatch and left behind an entry  
marked as dropped with a refcount of 0.  Nothing would free it, and the  
checkpointer would trigger an assertion at shutdown when flushing the  
stats.  
  
Looking more at the issue, using some hardcoded sleeps before the  
dshash_find() that takes an exclusive lock when releasing an entry with  
some concurrent activity, there was more going on:  
- A missing entry could be reported as an error at backend exit, error  
that should not be hit even if the entry was reinitialized and dropped  
concurrently.  
- The generation check was not correct for the case of 0 due to the  
first issue.  A generation of 0 refers to an entry that has been freshly  
created.  
  
This commit reworks the entry release to be safer concurrent-wise when  
an entry targetted for release is found as already existing:  
- If marked as dropped without refount at 0, free it.  
- In other cases, ignore it.  The entry has been reinitialized or  
created again with the same key, and is still in use.  
  
Sami has posted a basic test case (equivalent added in this commit) that  
gives a way to reproduce the assertion failure on backend exit, which is  
a consequence of the incorrect handling of entry releases.  
  
Reported-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Discussion: https://postgr.es/m/CAN12+YJXE+rEOVo74uM5Ofbj_t_m0DHvd_Mo4ppeHV=aDvvXoQ@mail.gmail.com  
Backpatch-through: 15  

M contrib/test_decoding/t/001_repl_stats.pl
M src/backend/utils/activity/pgstat_shmem.c

Use Size rather than int for storing strnlen's return

commit   : 38c3d87d43397ab600f085e398789f3dea1cd0a5    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 21 Oct 2026 13:32:24 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 21 Oct 2026 13:32:24 +1300    

Click here for diff

... in fe_memutils.c's pnstrdup().  
  
strnlen() does return size_t, so it seems better to use the Size input  
parameter to store the return value rather than demote it to int and  
risk larger values being truncated.  
  
Pushing only to master as this doesn't seem like an actual problem.  
Fixing will hopefully prevent future LLM-triggered reports about this.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/0E717E09-809F-4BC4-B3B1-36BE729DBFAE@gmail.com  

M src/common/fe_memutils.c

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

commit   : 68af68ac691f2b57d29524a191debed9b0bdd558    
  
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

Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.

commit   : 1999fe227df70249dce7c9037147b54c1090b4ad    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 17:32:31 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 17:32:31 -0400    

Click here for diff

set_deparse_context_plan() set the aliases for OLD and NEW in  
RETURNING when EXPLAIN printed a ModifyTable, but that's the  
wrong place: they should be set in set_deparse_plan() like other  
plan-node-specific fields.  So they were not changed when  
push_ancestor_plan() moved to the ancestor ModifyTable to print a  
Param of a SubPlan in its RETURNING list, and the aliases of some  
previously-printed ModifyTable could be used instead.  It seems  
possible that we'd also fail to print an alias at all, since  
get_variable() is unfazed by obtaining a NULL refname.  That  
shouldn't happen for RETURNING variables, so complain.  
  
Author: Henson Choi <assam258@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAAAe_zAUb_XydapJqUk7O8o2crJa7xbxX=KvSi3nY9h98OcN7g@mail.gmail.com  
Backpatch-through: 18  

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

contrib/intarray: always parse query_int integers as decimal.

commit   : 3745790f53bc5dd87b2df3d5a0c9c62d7ff0360d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 15:13:34 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 15:13:34 -0400    

Click here for diff

Previously we called strtol() with base 0, so that a leading zero  
digit caused the number to be read as octal.  This is not documented  
because it was not the original intent: before commit 7ccb6dc2d, this  
code used atoi() which would have read the number as decimal always.  
Use base 10 instead to restore the original behavior.  
  
Also reject a bare minus sign consistently.  Per POSIX, strtol()  
"may" set errno for that case but doesn't have to, and if it doesn't  
then we'd not have noticed the bad syntax but read the value as 0.  
  
Although this change restores old behavior, 7ccb6dc2d was a long  
time ago, so it's at least possible that someone out there is  
expecting the octal behavior.  So it doesn't seem like a great  
idea to put this into stable branches.  But I (tgl) judge it  
not too late for v19.  
  
Author: Marko Grujic <marko.grujic@enterprisedb.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAOvwyF3=brZoxwcwHRQqvLjuqSqxiTN7RXpKMNHXJ1WAS5GQ2Q@mail.gmail.com  
Backpatch-through: 19  

M contrib/intarray/_int_bool.c
M contrib/intarray/expected/_int.out
M contrib/intarray/sql/_int.sql

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

commit   : b536d5a0bd7a0e35c3168f3022183f37cb5c2058    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 14:29:01 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 14:29:01 -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 to_char() for number formats ending in a decimal point.

commit   : 776df8a6d7c42282825d658ff631509f033e8f34    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 12:56:14 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 20 Oct 2026 12:56:14 -0400    

Click here for diff

When a number format has a decimal point with no digit positions  
after it (e.g. '9.' or 'FM999.PL'), NUM_numpart_to_char() copied the  
terminating '\0' of the number string into the output as if it were a  
digit, resulting in apparent truncation of the output; for example,  
a sign or literal text following the decimal point would disappear.  
Fix it by not copying the '\0'.  
  
This is clearly a bug, but given the lack of field complaints,  
people who have run into it may think it's expected behavior,  
and may even have written applications that depend on it.  
Therefore it seems unwise to change it in stable branches.  
I (tgl) think it's not too late to fix it in v19 though.  
  
Bug: #19771  
Author: Gowtham Reddy <gowthamdoma18@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19771-4f173b891525020c@postgresql.org  
Backpatch-through: 19  

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

Mark GUC-dependent type output functions as STABLE

commit   : e75fcc9867fdfe295957ad5c9a98cbe2e1b4c5c3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 20 Oct 2026 15:07:11 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 20 Oct 2026 15:07:11 +0900    

Click here for diff

byteaout and pg_mcv_list_out depend on bytea_output GUC, while  
float4out, float8out, and the geometric type output functions depend  
on extra_float_digits GUC. The BRIN minmax-multi summary output  
function also calls the summarized type's output function, so its result  
can depend on the type's output settings.  
  
Mark these functions STABLE instead of IMMUTABLE to reflect their  
dependence on session settings. This prevents them from being used in  
expressions that require immutability, such as expression indexes,  
generated columns, and partition keys.  
  
Do not backpatch, since this changes catalog entries and can break  
existing schemas that rely on these output functions being immutable.  
  
Bump catalog version.  
  
Reported-by: 放空 <jj-zhang25@mails.tsinghua.edu.cn>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://postgr.es/m/19644-d6db3fb5e5ad92f4@postgresql.org  

M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

Add Dockerfile for github.com/anthropics/oss-scanner.

commit   : ddd468cacf0d5d6f124c39439505ab93d31ac65b    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 19 Oct 2026 19:35:58 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 19 Oct 2026 19:35:58 -0700    

Click here for diff

This has no effect on normal use of this repository.  The scanner clones  
this repository and locates this file.  While we could store it in the  
scanner configuration, storing it here simplifies keeping CI and this in  
sync.  References to postgresql/project.yaml are forward-looking; see  
github.com/nmisch/oss-scanner/blob/enroll-postgresql/projects/postgresql/project.yaml  
for the planned future content.  Claude wrote some of this.  
  
Reviewed-by: Sehrope Sarkuni <sehrope@jackdb.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/20261017032215.26.noahmisch@microsoft.com  

A src/tools/oss-scanner/Dockerfile

Fix two issues in deparsing.

commit   : 0497318e4422cbb9bff8c075a53a50b12065147c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 19 Oct 2026 17:51:09 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 19 Oct 2026 17:51:09 -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/returning.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   : 91b401dc1e9db85e5884c6c0f6dab0fafb0bebeb    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 20 Oct 2026 10:32:05 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 20 Oct 2026 10:32:05 +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

Add missing dependencies to meson headerscheck target

commit   : 0f3b42ce806a1ed5a5bf9cbe23b9e3fc1bac9095    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 09:44:07 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 09:44:07 +0200    

Click here for diff

These checks compile headers, so all the headers they might include  
need to have been generated.  The makefile target does that, but the  
meson implementation didn't do that.  (Arguably a bit of a bug in  
commit e82fc27e095.)  Add the required dependencies so that meson  
compile headerscheck works in an unbuilt tree as well (as is  
documented).  
  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/e52e2c29-4834-4c64-a200-eddcba38fb4d%40eisentraut.org  

M meson.build

Add pg_attribute_returns_nonnull to various memory allocation functions

commit   : 23192ac644e2a8f0597692aacb269321ee5acd99    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 09:39:25 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 09:39:25 +0200    

Click here for diff

This function attribute tells the compiler that the function will  
never return NULL.  This allows the compiler to do better static  
analysis and lets it optimize the caller given the non-NULL guarantee.  
  
The attribute is placed in front of the declaration, rather than after  
it, so that it can also expand to the MSVC annotation _Ret_notnull_,  
which is only valid in that position.  
  
Only functions that raise an error on allocation failure are marked.  
Functions that take a flags argument, such as palloc_extended() and  
palloc_mul_extended(), can return NULL when MCXT_ALLOC_NO_OOM is  
passed and are therefore not marked.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://www.postgresql.org/message-id/flat/DJROV5LUO7B5.DIWXYC0101KD%40partin.io  

M src/include/c.h
M src/include/common/fe_memutils.h
M src/include/utils/palloc.h

Fix casting away of volatile qualifier

commit   : 22ff4fc5a21bce3ccf0376e0e91fde8fd2f28655    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 08:31:05 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 08:31:05 +0200    

Click here for diff

Fix some issues involving volatile that would be triggered by  
-Wcast-qual.  
  
For PMSignalState, move the volatile qualifiers to the PMSignalData  
fields that need it rather than making the whole structure have it.  
  
For the MemSet() calls, do the initialization honestly with a loop  
instead.  
  
Note that the MemSet() calls would be normal "discards qualifier"  
warnings if memset() (or another function with a prototype, not a  
macro) were used.  
  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de> (older version)  
Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org  

M src/backend/postmaster/launch_backend.c
M src/backend/storage/ipc/pmsignal.c
M src/backend/storage/ipc/procsignal.c
M src/backend/utils/activity/backend_progress.c
M src/include/storage/pmsignal.h

Change float{4,8}in_internal take const char * input argument

commit   : 2db51901c48e44369f5e6f209a65983c206075da    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 08:31:05 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 19 Oct 2026 08:31:05 +0200    

Click here for diff

This makes the function signature match strtof()/strtod().  
  
A caller then doesn't have to cast away a const anymore.  
  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de> (older version)  
Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/utils/adt/float.c
M src/include/utils/float.h

Recompute allocChunkLimit when reusing an AllocSet context

commit   : 7b84cf8cfc7935d9ef275ea425c7bbd6e40b8c90    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 19 Oct 2026 19:42:37 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 19 Oct 2026 19:42:37 +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   : e355089a57d6f480cffc2820c46fcf0b5e371cf6    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Mon, 19 Oct 2026 11:24:43 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Mon, 19 Oct 2026 11:24:43 +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   : 3138f248cd3de43dd0f96760fc666152ea8a5c37    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 19 Oct 2026 11:02:14 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 19 Oct 2026 11:02:14 +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

libpq: Revert the connection option "servicefile"

commit   : 9d882c10bfb6f56a0a430872ef3040875535b06b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 19 Oct 2026 07:35:00 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 19 Oct 2026 07:35:00 +0900    

Click here for diff

The following commits are reverted:  
* 092f3c63efc6, libpq: Add "servicefile" connection option  
* 6b1c4d326b06, psql: Add variable SERVICEFILE  
* 90354030b8fc, libpq: Fix "servicefile" after fallback to system  
  service file  
  
After more review, PGSERVICEFILE is sufficient for the purpose of  
specifying a per-session service file.  Some details around this feature  
will need more attention before being actually usable, if we ever get  
down to it.  
  
One independent piece that has been committed during the v19 development  
cycle is df286a5b830a, which is kept in the tree as that was an  
unrelated change.  
  
Reported-by: Sehrope Sarkuni <sehrope@jackdb.com>  
Discussion: https://postgr.es/m/CAH7T-aq+U6GDPO8mr3Gga3KzxGpAE=BSLb38x+R8fvWjzF-H8w@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/libpq.sgml
M doc/src/sgml/ref/psql-ref.sgml
M src/bin/psql/command.c
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/libpq-int.h
M src/interfaces/libpq/t/006_service.pl

test_custom_stats: Stabilize test for counters

commit   : 8afc886831bc629e524cc7185b2fdc0092aecc93    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 19 Oct 2026 07:08:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 19 Oct 2026 07:08:24 +0900    

Click here for diff

After 44539786b82, variable-sized stats updates are batched in one  
backend.  A later safe_psql() can check the counters before that backend  
has finished flushing its pending stats during shutdown, so force a  
flush before checking them.  
  
This is only needed before this report check because  
test_custom_stats_var_update() uses pgstat_prep_pending_entry(), leaving  
counter updates as backend-local pending stats.  
  
Per buildfarm member mamba.  This could be reproduced locally by slowing  
down pgstat_shutdown_hook().  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Discussion: https://postgr.es/m/193326.1792282194@sss.pgh.pa.us  

M src/test/modules/test_custom_stats/t/001_custom_stats.pl

Fix nbtree unsatisfiable row compare assertion failure.

commit   : 45fc51fcbf4534ea2f6f85e36f8155dbd5ba9851    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 17 Oct 2026 11:02:49 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 17 Oct 2026 11:02:49 -0400    

Click here for diff

An assertion within nbtree preprocessing's _bt_mark_scankey_required  
function expects the first member key of a row compare to have the same  
strategy as its header key, which its caller passes.  But the first row  
member key won't necessarily have been commuted in cases where the row  
compare is unsatisfiable due to its first member key having a NULL  
argument.  This led to spurious assertion failures in the single key  
fast path call to _bt_mark_scankey_required.  
  
To fix, always commute the row members, even when the row compare is  
unsatisfiable.  That way the header and its members will always agree on  
strategy.  
  
Oversight in commit ec986020, which improved nbtree's unsatisfiable  
RowCompare detection.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Backpatch-through: 18  

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

Fix bogus outer-join commutation with lateral refs in PlaceHolderVars

commit   : 7787aec8ab000932a8704a988b175b39ff816f2f    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 17 Oct 2026 17:18:04 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 17 Oct 2026 17:18:04 +0900    

Click here for diff

make_outerjoininfo() decides whether outer join identity 3 applies  
between an outer join and a lower one in its LHS by checking that the  
join clause is strict for the lower join's RHS.  It relied on the  
clause then necessarily referencing that RHS.  That is not so when the  
strictness comes through a PlaceHolderVar: find_nonnullable_rels()  
looks inside the PHV's expression and reports rels it references  
laterally, while pull_varnos() reports only where the PHV is  
evaluated.  
  
In that case we marked the two joins as commutable although the clause  
does not use the lower join's RHS at all.  Joinrels for the same set  
of base rels could then be built both with and without the upper  
join's relid, leading to an assertion failure in  
standard_join_search().  The bogus commutation also caused an extra  
clone of the upper join's clause to be generated, which could be  
applied at a higher join in addition to the clone already applied  
below it.  In non-assert builds, this could lead to planner errors  
such as "variable not found in subplan target lists".  
  
To fix, ignore rels that the clause is strict for but does not  
reference, consistent with clause_relids treating a PHV as computed at  
its ph_eval_at.  
  
Back-patch to v16, where this commutation logic was introduced.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49xvh4-uPv3rxWkk_rtMT1ic+psHvEAxaFEXu2Rf-32Tw@mail.gmail.com  
Backpatch-through: 16  

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

Fix skipping of join quals for appendrel children

commit   : 23e7ca78a003fb6ae5d983f3a093faaecf0778b8    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 17 Oct 2026 10:28:53 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 17 Oct 2026 10:28:53 +0900    

Click here for diff

Commit 767c59895 made set_append_rel_size() skip join quals that came  
from above an outer join that can null the parent rel.  Such quals are  
of no use while generating paths for the child, and skipping them also  
keeps them away from adjust_appendrel_attrs(), which cannot apply  
nullingrels to a non-Var translation.  
  
However, it identified such quals by looking at their clause_relids.  
That misses a reference to the parent rel that is nulled by such an  
outer join but appears only within a PlaceHolderVar, because  
pull_varnos() reports only where the PHV is evaluated.  Such a qual  
could then reach adjust_appendrel_attrs(), which failed with "failed  
to apply nullingrels to a non-Var" if the referenced output of a UNION  
ALL member was not a plain Var.  
  
To fix, also skip quals whose clause_relids overlap the parent rel's  
lateral_referencers.  A reference to the parent rel within a PHV that  
is evaluated elsewhere is necessarily a lateral reference, so this  
catches all such quals.  These quals are no use for the child either,  
since they can never be enforced by a scan of the parent rel; this is  
the same reasoning join_clause_is_movable_to() uses.  
  
Back-patch to v16, where commit 767c59895 was introduced.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4_fzrrN9G6-wLwwrdM-n=fwj3Uhr1zkgj3o91EEC-CuEA@mail.gmail.com  
Backpatch-through: 16  

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

doc: Note that plan advice does not affect cached plans

commit   : 26bd08fb5c069fbdf55867adc398cfca0f55d5c8    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Fri, 16 Oct 2026 17:22:33 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Fri, 16 Oct 2026 17:22:33 -0400    

Click here for diff

Plan advice is consulted only at plan time.  When a cached plan is  
re-executed, no re-planning occurs, so updated advice has no effect.  
DISCARD PLANS can be used to discard cached plans, but only affects  
the sessions in which it is executed.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Suggested-by: Jakub Wartak <jakub.wartak@enterprisedb.com>  
Discussion: https://postgr.es/m/20260827171830.68.noahmisch@microsoft.com  
Co-authored-by: Dongpo Liu <poe.liu@pm.me>  
Co-authored-by: Robert Haas <rhaas@postgresql.org>  
Backpatch-through: 19  

M doc/src/sgml/pgplanadvice.sgml
M doc/src/sgml/pgstashadvice.sgml

Warn when REPACK or CLUSTER skips foreign partitions

commit   : af090508018be5ace443ba6e2814500c10842a4d    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 17 Oct 2026 00:26:29 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 17 Oct 2026 00:26:29 +0900    

Click here for diff

Previously, REPACK and CLUSTER silently skipped foreign-table partitions  
when processing a partitioned table, leaving users unaware that some  
partitions had not been processed. In contrast, VACUUM FULL warns when  
skipping such partitions.  
  
Emit a warning for each skipped foreign-table partition. Inspect the  
table's partition tree even when an index is specified, because foreign  
tables have no indexes and therefore do not appear in the index's  
partition tree. Check privileges before issuing the warning, so that  
users without the required privileges receive a permission warning  
instead, as with VACUUM FULL.  
  
Note that database-wide REPACK and CLUSTER continue to skip foreign  
tables silently, consistent with database-wide VACUUM FULL.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFNXFdkmOCnt8m=K_A4i3LQC+59nx59Y=5bsH4vehQHTTw@mail.gmail.com  

M doc/src/sgml/ref/cluster.sgml
M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql

Avoid spurious failures in the login event trigger recovery test

commit   : 80cf51123601318a7d80a4eec7be568e22462a4c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 17 Oct 2026 00:18:39 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 17 Oct 2026 00:18:39 +0900    

Click here for diff

Buildfarm member skink reported failures in  
053_standby_login_event_trigger.pl. The checks that dathasloginevt was  
cleared on the primary and that the cleared flag reached the standby  
both found the flag still set.  
  
The test assumed that the first login after dropping the trigger would  
clear the flag. However, EventTriggerOnLogin() acquires the database  
lock conditionally to avoid delaying connections for this cleanup.  
Concurrent connection startup, including that of an autovacuum worker,  
can hold a conflicting lock and cause the cleanup to be skipped. The  
standby correctly retained the flag because it had not been cleared  
on the primary.  
  
Fix this by using poll_query_until() to retry with fresh connections  
to the test database until the flag is cleared, giving the login cleanup  
repeated opportunities to acquire the lock.  
  
Backpatch to v17, like commit bec61f59354, which added this test.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/09561429-50c1-4d06-a262-300c7a845175@gmail.com  
Backpatch-through: 17  

M src/test/recovery/t/053_standby_login_event_trigger.pl

Avoid unnecessary end-of-recovery barrier waits

commit   : df1be4ddc8345235ffc736adc7dc954f0f944daa    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 17 Oct 2026 00:13:27 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 17 Oct 2026 00:13:27 +0900    

Click here for diff

Commit 67c20979ce7 made end-of-recovery processing emit a process signal  
barrier and wait for all processes to refresh their cached logical WAL  
logging state. This can hold up promotion indefinitely if a backend  
cannot process the barrier, for example while blocked sending data to  
a client that has stopped reading.  
  
At wal_level=logical, logical WAL logging is enabled regardless of the  
cached state, so no cache synchronization is needed. Skip emitting and  
waiting for the barrier in this case.  
  
When logical decoding will be disabled after recovery, stale caches  
can only cause extra logical information to be written to WAL, which is  
safe. Still emit the barrier so processes update their caches  
asynchronously, but no longer wait for it to complete.  
  
These changes allow promotion to finish without waiting for unresponsive  
backends to process this barrier in either case. Retain the wait in  
other cases, even if the shared state has not changed, to prevent  
processes with stale caches from omitting required logical information  
after recovery.  
  
Reported-by: shihao zhong <zhong950419@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Author: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqToBk9c2sPAgha-kCgxJhVwn90j1sCyUXrvydq51LKAqA@mail.gmail.com  
Backpatch-through: 19  

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

pg_upgrade: Fix last multixid ending at offset wraparound

commit   : 2323f03a1789bc52bee980c56b8057470458701a    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 16 Oct 2026 17:29:57 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 16 Oct 2026 17:29:57 +0300    

Click here for diff

On v18 and below, if the newest multixid's members end exactly at the  
the 32-bit offset wraparound point, the next offset in the control  
file is 0.  GetOldMultiXactIdSingleMember() treated that as an invalid  
entry and dropped the multixid's members, so after upgrade accessing  
the tuple failed with "MultiXact N has invalid offset".  
  
To fix, only check for zero offset when it was read from the next  
multixid's slot, like GetMultiXactIdMembers() did in v18.  This is  
unlikely to happen in practice, but better to get it right.  
  
The bug came with commit bd8d9c9bdfa in v19.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://www.postgresql.org/message-id/CAN4CZFM8BCazGz6s1Vn5tMEXYiXE2fi8T2rwmwXSty5gD+h9rA@mail.gmail.com  
Backpatch-through: 19  

M src/bin/pg_upgrade/multixact_read_v18.c
M src/bin/pg_upgrade/t/007_multixact_conversion.pl

Allow role created by new test to log in on Windows.

commit   : a261fc2b7220c4773bdd2023dbd23268528c14ed    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 16 Oct 2026 10:05:43 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 16 Oct 2026 10:05:43 -0400    

Click here for diff

We must tell init about each role name we plan to connect as,  
else SSPI auth fails.  Similar to previous patches such as  
e3fbc9a8d.  
  
Oversight in a39e53a70, per buildfarm member unicorn.  

M src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl

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

commit   : febd05600d789ea89f3b3e5fd50391990b652a68    
  
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

doc: Correct the documented type of pg_get_multixact_stats().num_mxids

commit   : 03d03e62e69a61eb9b337d1915e0df8add31b5ee    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 16 Oct 2026 22:40:33 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 16 Oct 2026 22:40:33 +0900    

Click here for diff

The documentation listed num_mxids as integer, but its SQL type has  
been bigint since the function was introduced. Correct the  
documentation to match the actual return type.  
  
Backpatch to v19, where the function was introduced.  
  
Author: Naeem Akhter <naeem.akhter@percona.com>  
Author: Noriyoshi Shinoda <noriyoshi.shinoda@hpe.com>  
Reviewed-by: Naga Appani <nagnrik@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAKB0-TEcYJoUn8Q_nug8KEvC9Ea0FV_JOe8XwcW-9QrqUjaBxQ@mail.gmail.com  
Discussion: https://postgr.es/m/LV8PR84MB3787CF6E56DCC99AE23E712EEE242@LV8PR84MB3787.NAMPRD84.PROD.OUTLOOK.COM  
Backpatch-through: 19  

M doc/src/sgml/func/func-info.sgml

doc: Clarify where autovacuum_max_parallel_workers can be set

commit   : c105ab8157d310d4714153223a6e2a6d9d33d1b8    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 16 Oct 2026 22:38:10 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 16 Oct 2026 22:38:10 +0900    

Click here for diff

The description of autovacuum_max_parallel_workers did not specify  
where it can be set or how it relates to the per-table  
autovacuum_parallel_workers storage parameter.  
  
Clarify that it can be set only in postgresql.conf or on the server  
command line, and that the limit can be reduced for individual tables.  
Add a link to the autovacuum_parallel_workers storage parameter.  
  
Backpatch to v19, where parallel autovacuum was introduced.  
  
Author: Baji Shaik <baji.pgdev@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CA+fm-RMmbUUPWJShxkhoB7SeiQ7XWw3YsVnHpMzp1Y2i_gtwig@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/config.sgml

Adjust weird usages of sentinel_ok()

commit   : 57926d757ab43852021d917b6221687a341c8385    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 16 Oct 2026 21:06:53 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 16 Oct 2026 21:06:53 +1300    

Click here for diff

All other callers of sentinel_ok() pass the palloc'd address to the  
function and the requested size of the allocation as the 2nd parameter.  
Here we adjust 3 locations that were passing the MemoryChunk and adding on  
sizeof(MemoryChunk) onto the byte count.  Effectively, it's the same byte,  
but a strange way to calculate it.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvq7HyLWX27XCSf5BmijeObV-QUF6CCbKAW00LxFPc71Ag@mail.gmail.com  

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

Fix bogus Assert in find_var_for_subquery_tle

commit   : 11b56ee27315276bd09eff17fa503ba39f4231ce    
  
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

Fix argument given to buffer_readv_encode_error()

commit   : eb7cc1d09e742d369540016455d0f55c619106f2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 16 Oct 2026 14:30:42 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 16 Oct 2026 14:30:42 +0900    

Click here for diff

buffer_readv_encode_error() expects a uint8 for its "error_count"  
argument, but the value given was a boolean.  That's harmless in  
practice, but let's be clean.  
  
Thinko in 047cba7fa0f8.  
  
Author: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Steven Niu <niushiji@gmail.com>  
Discussion: https://postgr.es/m/8073.1791959482@localhost  
Backpatch-through: 18  

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

Add sentinel_ok() check to BumpCheck().

commit   : 3c157ad116715aba84d3fb828a91aeaad002f92a    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 16 Oct 2026 17:59:08 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 16 Oct 2026 17:59:08 +1300    

Click here for diff

Effectively an oversight in 29f6a959cf.  The code went to the trouble of  
doing set_sentinel() but no code ever checked it was still set during  
BumpCheck().  Since bump context types are used in a handful of places,  
it very much makes sense to backpatch this to where bump.c was added so we  
can more easily discover any memory stomping bugs.  
  
Reported-by: shihao zhong <zhong950419@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqQxTCthDEnw_10OEGLVNMUeyE4So-K29jmn9nAkxtr1ow@mail.gmail.com  
Backpatch-through: 17  

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

Fix Parallel TID Range Scan rescans with a different TID range

commit   : ba51d62be465c420b0fbe3b0efd0ccd488e79922    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 16 Oct 2026 16:49:16 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 16 Oct 2026 16:49:16 +1300    

Click here for diff

0ca3b1697 added support for parallel TID Range Scans.  The range of  
blocks to scan is stored in the shared phs_startblock and phs_numblock  
fields by the first participant to start the scan, but  
table_block_parallelscan_reinitialize() didn't reset these, so every  
rescan of the Gather reused the block range of the first execution.  
This caused rows to be silently missed when a rescan used a different  
TID range, e.g:  
  
SELECT r.lo, (SELECT count(*) FROM t WHERE ctid >= (SELECT r.lo))  
FROM (VALUES ('(30,0)'::tid), ('(10,0)'), ('(0,0)')) r(lo);  
  
Here we fix this by resetting both fields in  
table_block_parallelscan_reinitialize().  As a side effect, a rescanned  
Parallel Seq Scan using synchronized scans now gets a new start  
location, which is what a new scan would do anyway.  
  
The existing rescan test didn't exercise this, so add one that does.  
  
This was introduced in 0ca3b1697, so backpatch to v19.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFOoyCQE483YVGg07_Vr2MjFCTiCLUHUAFCwKqJAE=PN6w@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/table/tableam.c
M src/test/regress/expected/tidrangescan.out
M src/test/regress/sql/tidrangescan.sql

Report pages read from WAL buffers in pg_stat_io.hits

commit   : 856a6594d86e4a7c0e9490253912af3f6159802f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 16 Oct 2026 08:09:04 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 16 Oct 2026 08:09:04 +0900    

Click here for diff

Callers of WALReadFromBuffers() read data from the WAL buffers  
(currently only WAL senders).  This commit makes now available the  
number of pages read from the WAL uffers in pg_stat_io.hits under object  
"wal" and context "normal".  
  
A read from a WAL file is counted in pg_stat_io.reads and read_bytes.  
This new information can be useful for the tuning of wal_buffers, where  
the number of hits matches with the number of pages found as available  
in the buffers.  
  
Note that WALReadFromBuffers() may be called for an amount of data worth  
less than one WAL page, and that a partial page read is counted as one  
hit.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CALj2ACVfF2Uj9NoFy-5m98HNtjHpuD17EDE9twVeJng-jTAe7A@mail.gmail.com  

M doc/src/sgml/monitoring.sgml
M src/backend/access/transam/xlog.c
M src/backend/utils/activity/pgstat_io.c
M src/test/recovery/t/001_stream_rep.pl

Avoid dangling shared memory pointers in parallel vacuum.

commit   : e0b995e5b23116450646fd1004db4bdcdbe213e4    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 15 Oct 2026 14:09:10 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 15 Oct 2026 14:09:10 -0700    

Click here for diff

When a parallel vacuum failed, the leader's VacuumSharedCostBalance  
and VacuumActiveNWorkers kept pointing into the parallel vacuum's DSM  
segment, which is gone after the abort, until the next vacuum in the  
same process reset them. Nothing in the current code reads them in the  
meantime, but it's better not to leave them dangling. Reset them at  
the end of vacuum(), as we already do at its start.  
  
No backpatch, as this doesn't fix any live problem.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACW3OY7Ex-2-aits7yhRciH20r12DHcCNf+exuweR1FcMw@mail.gmail.com  

M src/backend/commands/vacuum.c

Install infrastructure to manage psql's hidden query labels better.

commit   : 294d2196c7abec253fd3959d3ca4c6dcae3068d6    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 14:45:14 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 14:45:14 -0400    

Click here for diff

Commit 41d69e6dc added labels to psql's internally-generated queries,  
which are sent to the server and possibly recorded in the server log.  
In that commit we always attempted to translate the labels per psql's  
NLS environment, but that is hazardous: non-ASCII labels might fail  
to be translatable to the server's encoding, rendering some or all of  
these operations unusable since the server will throw an error and  
not execute the query.  Hence, we need some gating checks to decide  
whether it's safe to translate a label.  
  
To allow that to be managed in just one place, invent a new function  
addQueryComment() that is responsible for outputting these labels.  
(Probably it should have been done that way to start with, but better  
late than never.)  
  
This commit just does the heavy lifting of creating that function and  
fixing all the call sites.  The actual choice of whether to translate  
is stubbed out, so that this commit in itself changes no behavior.  
Once we've settled on the correct gating checks to use, a much smaller  
follow-on commit will install them.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqRv7yhBOhF0YvSr6ZB7rvsPCjnXSPj8=3bKcSJuYvNrBA@mail.gmail.com  
Backpatch-through: 19  

M src/bin/psql/command.c
M src/bin/psql/common.c
M src/bin/psql/common.h
M src/bin/psql/describe.c
M src/bin/psql/nls.mk

Fix DROP DATABASE FORCE failing on parallel autovacuum workers.

commit   : a39e53a700c5b728f2f7dab964e33b157979fb3a    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 15 Oct 2026 10:33:18 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 15 Oct 2026 10:33:18 -0700    

Click here for diff

An autovacuum worker advertises no role in its PGPROC, but its  
parallel workers advertise the bootstrap superuser. So DROP DATABASE  
... FORCE run by a non-superuser with pg_signal_backend failed with  
"permission denied to terminate process" while a parallel autovacuum  
was running in the database, although the same user can terminate the  
autovacuum worker itself, and DROP DATABASE without FORCE succeeds.  
  
Fix by checking a parallel worker against its leader's role when the  
leader advertises no role. The leader is in the same database and is  
checked too, so this doesn't let anyone terminate a process they  
couldn't already terminate through its leader.  
  
Parallel workers launched by a background worker connected without a  
user name have had the same problem in older branches, but we haven't  
received any report of it, and the next minor release is the final one  
for v14, leaving no chance to fix a mistake there. So backpatch only  
to v19, where parallel autovacuum made the problem easy to hit. If we  
get a report, we can backpatch it further.  
  
Found by Bharath using AI assisted review.  
  
Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACWK6PkOk5MTfibtJyTYpb=Aq_8=YaexnPKhOj11bOCROQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/vacuumparallel.c
M src/backend/storage/ipc/procarray.c
M src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl

Simplify restriction matching in self-join elimination.

commit   : 8f2b598b4bc562d9609a47a3e069a5431237c85e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 12:42:34 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 12:42:34 -0400    

Click here for diff

In match_unique_clauses(), use equal() to compare complete restriction  
clauses after substituting the relation ID, instead of comparing their  
operands separately.  This ensures that the operator and input  
collation also match, preventing incorrect self-join elimination when  
restrictions have identical operands but different semantics.  
  
The former code apparently intended to support matching clauses to  
commuted versions of those clauses, but the amount of complication  
that added seems far out of proportion to the value, so just drop  
that goal.  (If we wanted to reinstate it, something based on  
applying CommuteOpExpr or equivalent logic would be better.)  
  
Author: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAHewXNmwYrp0DTuisCyfXXjVa_irUdDFApUzLVDg3J4MAR6gEg@mail.gmail.com  
Backpatch-through: 18  

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

Fix _bt_readnextpage half-dead leftmost page assert.

commit   : 931ce42ef9c891b5657d395abf3357a1db4a8974    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 15 Oct 2026 12:17:18 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 15 Oct 2026 12:17:18 -0400    

Click here for diff

Backwards scans that reach a half-dead leftmost leaf page step over the  
page without calling _bt_readpage.  This happens whenever the most  
recent _bt_lock_and_validate_left call returned a half-dead leftmost  
page.  An assertion within _bt_readnextpage failed to consider this,  
causing it to fail spuriously.  
  
To fix, make the assertion accept the case where currPage doesn't match  
lastcurrblkno as long as blkno is P_NONE (it's always P_NONE when the  
last leaf page examined by _bt_readnextpage is either the leftmost or  
rightmost page).  
  
Oversight in commit caca6d8d27.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Backpatch-through: 18  

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

Weaken libxml2 behavioral test added by 30d4a6daa.

commit   : d11f4a03b223e15599376601fe097662637a9212    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 12:02:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 12:02:29 -0400    

Click here for diff

The libxml2 versions I tested all pass through non-ASCII data  
in tag attributes; but it appears that late-model versions  
will hexify that data too.  Per buildfarm.  

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

Fix two edge cases in numeric log(base, val).

commit   : 94e1385ed28509bee486aa0be40dea78b9e083c3    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 11:25:10 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 11:25:10 -0400    

Click here for diff

For log(base, +Infinity) where 0 < base < 1, the correct output  
is -Infinity, not +Infinity as we had been giving.  
  
log(1, x) is erroneous regardless of x.  Formerly we returned  
+Infinity when x is +Infinity, and threw a rather confusing  
"division by zero" error for finite-positive x.  Change both  
cases to report "cannot take logarithm using base one".  
  
While the cases with infinite inputs are clearly wrong, it's  
not clear that people would appreciate such a behavior change  
in stable branches, so fix master only.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/08270B8B-634F-4381-9D6F-9BDB18DA82A0@gmail.com  

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

Modernize our parsing of XML data in CONTENT mode.

commit   : 30d4a6daac8b61fd18dfe0d990d00943a170e48b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 10:31:22 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 15 Oct 2026 10:31:22 -0400    

Click here for diff

The main goal of this patch is to get rid of our use of  
xmlKeepBlanksDefault, which libxml2 has deprecated.  
To do that, we want to use xmlParseInNodeContext instead of  
xmlParseBalancedChunkMemory, so that we can pass an options  
mask that includes XML_PARSE_NOBLANKS.  
  
xmlParseInNodeContext wants an xmlNode rather than an xmlDoc as  
context.  This gives us an opportunity for simplification though:  
we can make that node be a dummy root node for xml_parse's result  
document, and then attach the content node(s) as children of the root,  
essentially moving the data structure hack in xmltotext_with_options  
into xml_parse.  The main benefit of this is that callers no longer  
need to free the content node list separately; freeing the document is  
sufficient.  (There were error paths in xmltotext_with_options that  
I think would have leaked that list, though they could only be  
reached in OOM or similar conditions.)  
  
We also do some fooling with doc->encoding, to be bug-compatible  
with our previous behavior on as many libxml2 versions as practical.  
Some small discrepancies with previous behavior are known with older  
libxml2 versions.  Therefore, it seems inadvisable to back-patch this,  
at least not before it's gotten a good deal of field experience.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Fix-suggested-by: Andrew Dunstan <andrew@dunslane.net>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/ZR2PPFF1830B8772632FA23847D7482168FD2C62@ZR2PPFF1830B877.CHEP278.PROD.OUTLOOK.COM  

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

Use StringInfo to build the result in oidvectortypes()

commit   : a999971331301a4a2f945220733b11af90cc2962    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 15 Oct 2026 16:51:19 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 15 Oct 2026 16:51:19 +0300    

Click here for diff

Replace manual buffer management with StringInfo to avoid repeatedly  
scanning the accumulated output when appending type names.  This  
removes quadratic scanning for large input vectors and simplifies the  
code.  
  
Also check for interrupts in the loop and free temporary type names  
after appending them to the result.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://www.postgresql.org/message-id/70611808-81DA-4B99-A3DB-7371F7EA4702@gmail.com  

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

Fix minor thread handle leak in pg_test_fsync on Windows

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

Click here for diff

START_TIMER launches a new thread, but never closed the handle to it.  
We don't need the handle after starting the thread, so just close it  
right away.  The program creates a timer for each benchmark phase, so  
this isn't a big leak at the moment, but it could become more serious  
if someone added START_TIMER to a loop.  I didn't bother backpatching  
though.  
  
Author: Harrison Booth <harrisontbooth@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAAH-eSVFy2GySdYEAtd9Wp=Swka0TzZGkw2VrO8GTaq3ndcikQ@mail.gmail.com  

M src/bin/pg_test_fsync/pg_test_fsync.c

Fix CreateThread() failure checks

commit   : 54635e6892f0f8bf61b0ae0d0b4bc119e7780a3b    
  
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   : 068c9aaec31bc3e73d156a49ba0c4128f067c010    
  
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
M src/backend/access/transam/xact.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/multixact-aborted-updater.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/multixact-aborted-updater.spec
M src/test/recovery/meson.build
A src/test/recovery/t/060_multixact_crashed_updater.pl

Remove RI fast-path code for calling cast functions

commit   : 964d88fac464a9b5f55c3d0c9c2ec72bcde5847d    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 15 Oct 2026 17:05:38 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 15 Oct 2026 17:05:38 +0900    

Click here for diff

The previous commit stopped using the fast path when FK values need a  
cast function, which leaves its code for calling them unused.  So  
remove the following: the cached FmgrInfos for the cast and equality  
functions and the memory context they used, the cast step in  
build_index_scankeys(), the EXECUTE privilege check on the cast  
function, and the unused forward declaration of RI_CompareHashEntry.  
  
Also revert the changes made to ri_HashCompareOp() for the fast path's  
cross-type operators and domain-typed keys in commits 2da86c1ef9 and  
68ace967c1.  Fast-path code no longer uses the function.  
  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Discussion: https://postgr.es/m/CAM527d9BgPjeOOYmbCBTd57R145qHCk-dzw9qNq+nOrDq1j__A@mail.gmail.com  
Backpatch-through: 19  

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

Use SPI for RI checks whose FK values need a cast function

commit   : 6aecabcd5ed54ac055b4df031336e997c84f7450    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 15 Oct 2026 15:26:41 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 15 Oct 2026 15:26:41 +0900    

Click here for diff

When the FK column's type needs a cast function to reach the equality  
operator's input type, the RI fast path calls that function directly.  
The SPI path instead applies the cast as an expression in its query,  
which takes care of the function's declared arguments, its input  
collation, a NULL result, volatility, and replanning when the function  
changes.  The direct call doesn't cover all of that; for example, a  
NULL result raises an internal error rather than a foreign key  
violation, and if the cast's function is dropped and replaced, later  
checks fail with "cache lookup failed for function".  Coercions that  
aren't a call to one function, array coercion and coercion via I/O,  
fail outright with "no conversion function".  
  
Rather than replicate expression evaluation, leave FK values that  
aren't binary-coercible to the operator's input type to SPI.  The fast  
path keeps handling cross-type operators, domains and binary-compatible  
types.  As eligibility now depends on pg_cast, invalidate cached  
constraint information on pg_cast changes too.  
  
Because the check needs catalog lookups, it is made in  
ri_check_fastpath_index(), which caches its result in fastpath_state  
until the constraint's cached information is invalidated, rather than  
for every row in ri_fastpath_is_applicable().  
  
The two tests that used a cast function to exercise fast-path code that  
still exists (metadata invalidation and the active snapshot) now use  
the equality function of a custom opclass, the only user code a  
fast-path check still runs.  
  
The fast-path code that calls cast functions is now unused; the next  
commit removes it.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Reported-by: Amit Langote <amitlangote09@gmail.com>  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Discussion: https://postgr.es/m/CAM527d9BgPjeOOYmbCBTd57R145qHCk-dzw9qNq+nOrDq1j__A@mail.gmail.com  
Backpatch-through: 19  

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

Fix EPQ run-time pruning using the parent's PARAM_EXEC values

commit   : 73e69062c120f669f71531dabeacfb8041c85daf    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 15 Oct 2026 15:49:06 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 15 Oct 2026 15:49:06 +1300    

Click here for diff

8741e48e5 made EvalPlanQualStart() borrow the parent EState's  
es_part_prune_states.  However, the ExprContext in each  
PartitionPruneState belongs to the parent EState, so exec pruning during  
an EPQ recheck used the parent's PARAM_EXEC values, i.e. those from the  
old row version.  This could prune away the partition the recheck  
needed, causing the row to be silently skipped, e.g. with a correlated  
subquery on a partitioned table in the WHERE clause of an UPDATE.  
  
Here we fix this by giving the EPQ EState its own PartitionPruneStates,  
while still borrowing the parent's es_part_prune_results so that the  
same subplans are initialized.  As the states are no longer shared, the  
"initialized" field added by 1b5dd3a24 is no longer needed, so remove  
it.  This also undoes the ABI break that field caused in 18.  
  
Backpatch to 18, where 8741e48e5 and 1b5dd3a24 were backpatched.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFPZ6qKnv6FPmq1RQZ49cHALCwLBu_NJdqUrkZNg0z81JQ%40mail.gmail.com  
Backpatch-through: 18  

M src/backend/executor/execMain.c
M src/backend/executor/execPartition.c
M src/include/executor/execPartition.h
M src/test/isolation/expected/eval-plan-qual-partition-prune.out
M src/test/isolation/specs/eval-plan-qual-partition-prune.spec

Disallow serialized callbacks for fixed-sized custom stats kinds

commit   : 3c6665bf0266a7ae78117c3ed0299bfbd1f1331a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 15 Oct 2026 08:30:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 15 Oct 2026 08:30:03 +0900    

Click here for diff

The pgstats callbacks to_serialized_name() and from_serialized_name()  
are documented as being for variable-sized stats only, as they map an  
entry hash key to a name written to the on-disk stats file.  
  
pgstat_register_kind() did not enforce this policy for custom stats  
kinds.  Enforcing this behavior is more interesting since 44539786b829,  
where a stats kind can begin pointing at its own hash table, offering as  
guarantee that a PGSTAT_FILE_ENTRY_NAME will never match a fixed-sized  
stats kind at startup, should the same kind ID be reused across restart  
with a different kind info.  
  
See also 0d110901f0ef that has dealt with a similar issue, for  
PGSTAT_FILE_ENTRY_HASH.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFMxuOOuYV14+i3YcPG-16q02eBtSVa82J111=ZnDwSicA@mail.gmail.com  

M src/backend/utils/activity/pgstat.c

Fix crash when reading stats file at startup with fixed-sized kinds

commit   : 0d110901f0ef362fcf24b07357c20745f971c602    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 15 Oct 2026 08:23:09 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 15 Oct 2026 08:23:09 +0900    

Click here for diff

pgstat_read_statsfile() has never checked that the kind of a hash entry  
is variable-sized.  Since 44539786b829, that has begun tracking which  
hash table a kind ID should use, it is possible to finish with a NULL  
pointer dereference for a PGSTAT_FILE_ENTRY_HASH.  Fixed-sized stats  
kinds have no hash table and no DSA area, hence their dsa references in  
pgStatLocal.kind_hash[] are NULL.  
  
This case can occur when reading statistics files if the same kind ID is  
reused across server restarts, with shared_preload_libraries loading  
different stats kind information each time: stats written with a set of  
PGSTAT_FILE_ENTRY_HASH, then read back with the same kind ID pointing to  
a custom fixed-sized kind info.  
  
Oversight in 44539786b829.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFMxuOOuYV14+i3YcPG-16q02eBtSVa82J111=ZnDwSicA@mail.gmail.com  

M src/backend/utils/activity/pgstat.c

btree_gin: Fix timestamp-vs-timestamptz comparisons near DST boundary.

commit   : aadce2c10ffec9326a5119a3c590b77ab58b4f97    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 18:45:28 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 18:45:28 -0400    

Click here for diff

To perform cross-type index scans with a timestamp index and a  
timestamptz comparison value, btree_gin must convert the timestamptz  
to timestamp to establish the starting point for the indexscan.  This  
is hazardous because timestamp_cmp_timestamptz is actually defined to  
upconvert the timestamp to timestamptz and then compare timestamptz's.  
When dealing with ambiguous timestamps near a fall-back DST transition,  
the value may not round-trip, leading to selecting a scan start point  
that misses some index entries that should match.  
  
To fix that, move the converted value back an hour at a time until  
it's clearly <= the given comparison value.  (We could try to be  
smarter, but this way seems more certain to work across all possible  
DST behaviors.)  
  
Another hazard is that for timestamptz's that are finite but close to  
the upper range limit, the conversion may produce timestamp +Infinity,  
again comparing greater than the given value.  It's less clear whether  
this can lead to missing matching values in practice, but it would at  
least risk making the aforesaid correction loop very slow.  So replace  
+Infinity by the maximum finite timestamp.  
  
The reverse case of timestamptz index and timestamp comparison value  
is not at risk because upconverting the timestamp stays consistent  
with what timestamptz_cmp_timestamp will do.  Also, while  
date-vs-timestamptz could theoretically be at risk, the conversion  
error would have to be a full day which seems not to occur in reality.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqQio=7PWgTfKvjyQY9-7A_0A36E3put1gxJeDypgqFSzw@mail.gmail.com  
Backpatch-through: 19  

M contrib/btree_gin/btree_gin.c
M contrib/btree_gin/expected/timestamp.out
M contrib/btree_gin/sql/timestamp.sql

Unset SK_SEARCHARRAY when inequality arrays degenerate.

commit   : 1d45c5da3a0ad22b8e172da352ed25bd70a2253a    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 14 Oct 2026 17:32:32 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 14 Oct 2026 17:32:32 -0400    

Click here for diff

Initial array-specific preprocessing in _bt_preprocess_array_keys  
transforms inequality strategy SK_SEARCHARRAY scan keys into simple  
scalar scan keys, whose sk_argument contains the array's most  
restrictive element.  The transformed keys nevertheless retained their  
SK_SEARCHARRAY markings.  This approach left it up to everybody else to  
determine whether any given SK_SEARCHARRAY-marked key was an equality  
strategy key (which actually has an array) or an inequality key (which  
no longer has one).  
  
Simplify things by teaching preprocessing to unset SK_SEARCHARRAY from  
the flags for inequality scan keys, at the point where it already sets  
the key's sk_argument to a simple scalar datum.  This makes it safe for  
code that runs after array preprocessing to assume that any key marked  
SK_SEARCHARRAY must be an equality key.  
  
This also fixes a minor inconsistency: _bt_advance_array_keys's precheck  
of the least significant key was skipped when that key came from a SAOP  
inequality, even though we were willing to apply that optimization given  
an inequality that had a scalar argument before preprocessing.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-WznnuUH-fH84d60UHmDo4rO0Mio4_8DGvhxBo1yL0EwPng@mail.gmail.com  
Discussion: https://postgr.es/m/CAH2-Wznvj74CAwVydAs_Lh1hR3PGi_aN1s7BiRKE0iJYNdoixQ%40mail.gmail.com  

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

Fix self-join elimination to avoid inheritance scans.

commit   : 89e06d78298ec417cfccd4bd684aa63bcec5ce39    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 16:38:15 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 16:38:15 -0400    

Click here for diff

Self-join elimination failed to check for inheritance cases,  
which has two big problems.  First, a unique index on the parent  
table isn't sufficient to prove uniqueness across its children too.  
Second, since we matched RTEs by OID without considering rte->inh,  
we could try to merge "mytable" with "mytable ONLY", which doesn't  
even represent the same set of rows.  
  
We can fix both issues by just skipping RTEs that have inh set.  
preprocess_relation_rtes already cleared that flag for tables known  
not to have inheritance children, so this doesn't break SJE for the  
cases where it's valid.  
  
Author: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAHewXNn4EjCQEvanN_FPKQ3OJWaBXq8Pxcj-DZYbeQ6_4xSFgw@mail.gmail.com  
Backpatch-through: 18  

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

Clear more substructure of a dead relation during join removal.

commit   : 91b1872ff2de16cd353598edbc650a185e649226    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 15:37:28 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 15:37:28 -0400    

Click here for diff

The tablesample and securityQuals subtrees of a RangeTblEntry can  
include Vars, which will cause trouble if they point at a removed  
rel and are visited during later processing.  Hence, clear those  
fields during join removal, as we already do for the subquery field.  
remove_useless_outer_joins got this right for securityQuals but  
not tablesample, while remove_self_join_rel missed doing it for  
securityQuals.  (It escapes trouble for tablesample only because we  
made a policy decision to never touch sampled relations for SJE.)  
  
Oversight in 2ebf25e7d.  Back-patch to v16, like that commit  
(but the SJE issue only goes as far back as v18).  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqSOAT1yop44B8jwacL_91rxK=QuoU8Of3NLMb9NgAO2NA@mail.gmail.com  
Backpatch-through: 16  

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

Fix hash bucket split buffer pin leak.

commit   : 49103c3cd639d42eaa26eb2076b621deec0e03f3    
  
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   : 8a5f8eb456f61fa8dcf444cac64d0b241b86430e    
  
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/func-aggregate.sgml

Reorderbuffer: handle catalog-change-bearing aborted subxacts better

commit   : beff3cd00989e2d532cde376da05be42eeb98577    
  
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
M contrib/test_decoding/meson.build
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/backend/utils/time/snapmgr.c
M src/include/replication/reorderbuffer.h

commit   : 4118012791355f59b0d7774b681dc46683b50cb2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 13:30:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 14 Oct 2026 13:30:24 -0400    

Click here for diff

When being used as a window function, these aggregates must run the  
finalization step repeatedly on their accumulated state.  During that,  
discarding null-valued pairs isn't okay if we want to reject duplicate  
keys, since per SQL spec a null-valued pair still participates in  
duplicate key checking.  Hence, when both those options are selected  
(jsonb_object_agg_unique_strict) run uniqueifyJsonbObject on a copy of  
the pairs array, keeping the original data structure unmodified.  
We don't want to do that when unique_keys isn't specified, because  
repeat de-duplication can be very expensive when there are many  
duplicates, but fortunately we don't have to.  
  
uniqueifyJsonbObject did not renumber the pairs it kept, so a pair  
added later could lose to an older one with the same key.  Renumber  
them to ensure that we preserve last-one-wins behavior across  
multiple finalizations.  Also improve related comments.  
  
While adding test cases to cover these mistakes, I chose to sync up  
all the json[b]_object_agg tests in json.sql and jsonb.sql.  This  
exposed that json_object_agg() fails to de-duplicate keys in its  
output, which seems like a pre-existing bug; but for this commit  
let's just memorialize its behavior.  
  
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: 19  

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

Fix order of bin and data dir checks in pg_upgrade

commit   : d733fcaf5cac6b88de9417f2b43e51490e36c7b1    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 14 Oct 2026 15:49:48 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 14 Oct 2026 15:49:48 +0300    

Click here for diff

If you called pg_upgrade with a --new-datadir that points to a  
configuration-only dir and no --new-bindir option, it would try to  
execute "postgres -C data_directory" using the new binary before  
resolving the correct path to it.  
  
To fix, check and resolve the binary dirs first, before calling  
adjust_data_dir().  For clarity, rename the setup() function to  
check_clusters_stopped() to better reflect what it does now.  
  
One consequence of this is that if the binaries are not found, you now  
get an error earlier than before, before the pg_upgrade_output.d  
directory and the log files have been created.  That's what  
necessitated the test change in this commit.  The log files are  
important for things like listing unsupported objects in the source  
database, but missing binaries feels like a more permanent error,  
similar to invalid options or incorrect directory permissions, and it  
seems OK to just print the error to stderr for those.  
  
This has been broken forever, but I chose to not backpatch since no  
one else has complained, it's a pretty minor issue, and it's easy to  
work around by passing the binary dir explicitly.  Maybe later, if  
someone in the field runs into this.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Bohyun Lee <bohyun.lee@databricks.com>  
Discussion: https://www.postgresql.org/message-id/6894f355-10e4-4756-89ad-ae5987f416a6@iki.fi  

M src/bin/pg_upgrade/exec.c
M src/bin/pg_upgrade/option.c
M src/bin/pg_upgrade/pg_upgrade.c
M src/bin/pg_upgrade/pg_upgrade.h
M src/bin/pg_upgrade/t/002_pg_upgrade.pl

Plug holes in SP-GiST quad tree getQuadrant()

commit   : eab68b1be6aa05e42330d5d7a00006e7dac8f997    
  
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

pg_basebackup: Report correct size estimate for incremental backups

commit   : cedd2cec7d537ccae01ab5041cdcaf15aa8618e0    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 19:54:45 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 19:54:45 +0900    

Click here for diff

Progress reporting in pg_basebackup and pg_stat_progress_basebackup used  
the estimated size of a full backup even when taking an incremental backup.  
The size estimation pass did not account for incremental files and counted  
every file at its full size. Progress could therefore remain at only a few  
percent even after the incremental backup completed successfully.  
  
Fix this by making the size estimation pass account for incremental files,  
counting them at the size they will occupy in the archive.  
  
Backpatch to 17, where incremental backup was introduced.  
  
Author: Daria Lepikhova <daria.n.lepikhova@gmail.com>  
Reviewed-by: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAK49S1ASwk7L-7LYUUz1MU_+uQnZ75srva2XRR4r-w0HCVZeUQ@mail.gmail.com  
Backpatch-through: 17  

M doc/src/sgml/protocol.sgml
M src/backend/backup/basebackup.c
M src/backend/backup/basebackup_incremental.c
M src/bin/pg_basebackup/meson.build
A src/bin/pg_basebackup/t/012_incremental_progress.pl

doc: Clarify that base backup progress counts uncompressed archive data

commit   : da7a27cdc983b2b1581314f3e96b94d95e506d13    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 19:52:39 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 19:52:39 +0900    

Click here for diff

The documentation described base backup progress in terms of data  
streamed, which could be mistaken for the amount of data sent over the  
connection when server-side compression is enabled. Clarify that the  
counters measure archive data before server-side compression.  
  
The progress report message was also documented as counting bytes from  
the current tablespace, although it reports a cumulative count for the  
whole backup. Correct the description to say that the count covers all  
tablespaces since the backup began.  
  
Backpatch to 15, where both the progress report message and server-side  
compression were introduced.  
  
Suggested-by: Surya Poondla <suryapoondla4@gmail.com>  
Author: Daria Lepikhova <daria.n.lepikhova@gmail.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAOVWO5pNe6XprMnt5OTT+-2Sm67z5GX4DzUNArEHubF0z9-PZQ@mail.gmail.com  
Backpatch-through: 15  

M doc/src/sgml/monitoring.sgml
M doc/src/sgml/protocol.sgml
M doc/src/sgml/ref/pg_basebackup.sgml
M src/include/backup/basebackup_sink.h

Accumulate Memoize parallel worker stats across rescans

commit   : 8b9ffcb11061c47c1071d8e5e4825e76fc333afe    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 14 Oct 2026 22:06:30 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 14 Oct 2026 22:06:30 +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

Reuse the zstd context when compressing WAL full-page images

commit   : 857340b0263da6d6a5f764bbab2fb39d0456f9fd    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 16:40:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 16:40:50 +0900    

Click here for diff

When wal_compression=zstd, the compression of a full page image involves  
ZSTD_compress(), that creates and destroys a zstd compression context  
for each page processed.  
  
Tests with FPI-heavy workloads have proven that this can be costly, and  
a compression context can be reused across multiple pages.  This commit  
switches to use ZSTD_compressCCtx() for the compression of each page,  
with ZSTD_CCtx allocated once in each backend, allocation happening the  
first time it is required.  If the allocation fails, the code  
temporarily fails back to no compression, as a soft failure mode while  
being inside a critical section.  
  
Some tests have proved that this simple change can lead to a substantial  
performance gain.  For example, I have measured up to 6% faster runtime  
and 8% less user CPU time for a VACUUM FULL generating WAL made mostly  
of zstd-compressed FPIs.  
  
ce3387b74b70 has done something similar for the decompression of pages  
at replay.  
  
Author: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://www.postgresql.org/message-id/asRsOl73nf8GeBFd@paquier.xyz  

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

Fix typo in xlogreader.c

commit   : 2246c04e7b99519010cd47be636273a5700b0b0d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 15:13:10 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 15:13:10 +0900    

Click here for diff

Oversight in ce3387b74b70.  

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

Don't use SubPlan-containing expressions for startup-time pruning

commit   : eacee6b618718f9e5298df0629d9720fa4dd5e45    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 14:54:45 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 14:54:45 +0900    

Click here for diff

match_clause_to_partition_key() tells whether a comparison value can  
be evaluated during executor-startup pruning by checking that it has  
no Vars, no volatile functions and no PARAM_EXEC Params.  A SubPlan  
normally fails the last test, since the testexpr of an ANY/ALL SubPlan  
references the subplan's output Params.  But if the left-hand side is  
a NULL constant, the strict comparison operator in the testexpr is  
const-folded to a NULL Const, and an uncorrelated SubPlan has no  
parParam or args either, so nothing is left for pull_exec_paramids()  
to find.  The expression then reaches initial_pruning_steps, where  
ExecDoInitialPruning() must evaluate it before any PlanState exists,  
and we fail with "SubPlan found with no parent plan".  
  
To fix, don't allow such an expression to be used for startup-time  
pruning.  It's still fine for per-scan pruning, which has a PlanState  
to evaluate it with.  Expressions containing exec Params are  
unaffected.  
  
This has been broken since d47cbf474, which moved initial pruning out  
of ExecInitNode(); before that, pruning always had the parent node's  
PlanState available.  Back-patch to v18.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs48nYDu7joYeyMKYdX8kHoL_ASEax2fqZH6L+HHqO2nkXA@mail.gmail.com  
Backpatch-through: 18  

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

Disallow joins whose lateral references can never be satisfied

commit   : b84ad0cd90414970a453e37983624a13921421ca    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 14:29:52 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 14:29:52 +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

commit   : 0d6103e537e1299046e5906149f9a7d2108be2cf    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 12:04:07 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 14 Oct 2026 12:04:07 +0900    

Click here for diff

When pull_up_sublinks() converts a sublink to an antijoin, it builds a  
JoinExpr with no RTE, on the grounds that nothing above the join can  
reference its RHS.  That overlooks PlaceHolderVars.  A PHV with no  
Vars of its own is evaluated at its phrels, and for the outputs of a  
pulled-up subquery phrels is all the relids in the subquery's  
jointree, including the RHS of such a join.  
  
A qual using the PHV thus appears to reference the RHS rels, and can  
be pushed down into the RHS as a parameterized join clause.  There it  
has the opposite of the intended effect: outer rows that fail the qual  
find no match and are emitted, giving wrong results.  For an outer  
join, including an antijoin made by reducing a left join, this cannot  
happen because the join's relid is among the qual's relids.  Before  
v16, the qual's nullable_relids prevented it.  
  
To fix, make a join RTE for an antijoin built from a sublink, so that  
it has a relid like any other outer join.  Semijoins are left as they  
are: a qual evaluated within a semijoin's RHS does not change the  
result.  
  
Back-patch to v16.  Before that, the qual's nullable_relids included  
the antijoin's RHS, which kept the qual from being moved there; that  
protection went away when nullable_relids was replaced by outer-join  
relids.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4_rEdcG89BgC-AO7b+Bf2z8w3976+4zP==Urt=CXB1hsg@mail.gmail.com  
Backpatch-through: 16  

M src/backend/optimizer/README
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/plan/subselect.c
M src/backend/optimizer/util/relnode.c
M src/include/nodes/pathnodes.h
M src/include/nodes/primnodes.h
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Fix potential use-after-frees in WAL sender

commit   : f2dd2a3bd44eb1d158e6e507b86dc3df787043b1    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 12:05:07 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 12:05:07 +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   : b128e75ecc6b09f04cf6e105dd77700f586a9167    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 11:11:08 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 14 Oct 2026 11:11:08 +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/xlogrecovery.c

Release memory allocated by ndistinct_for_combination()

commit   : 6d4607e886a083f7cddb121a84f6d8ee23addd6d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 10:14:54 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 14 Oct 2026 10:14:54 +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

Delay qp_callback processing till after join removal.

commit   : 6b3f8857aa83b214f9e7d2465d4e21d6ef75f39e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 13 Oct 2026 17:53:20 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 13 Oct 2026 17:53:20 -0400    

Click here for diff

Commit 2ebf25e7d left query_planner's qp_callback call where  
it had been historically, but that turns out to be a bad idea.  
It means that the code reached via qp_callback is subject to the  
must-be-able-to-restart rule created by looping back after join  
removal.  We found one place that fails that requirement:  
adjust_group_pathkeys_for_groupagg sets Aggref.aggpresorted flags,  
and there's nothing that will reset those in case of a query_planner  
restart, yet the selected set of Aggrefs can change.  There might be  
other places with similar issues.  
  
Fortunately, qp_callback's main charter is to compute/update pathkey  
values, and that is not something that join removal depends on or  
should depend on.  (Whether join removal is valid is surely not  
dependent on what order the rel might get scanned in.)  Nothing else  
within the restart loop depends on it either --- in other words,  
the existing placement was a bit random to begin with.  So we can  
fix this problem just by moving that call to below the restart loop.  
That costs nothing, indeed it saves some cycles by not having to do  
that processing more than once.  And removing an unstated requirement  
from code that's not directly called by query_planner should help  
forestall future bugs.  
  
While the known bug only exists in v18 and up (older branches lack the  
aggpresorted optimization), I've chosen to back-patch the code change  
to v16 like 2ebf25e7d was.  This is the sort of API requirement that  
we don't really want to be different across branches.  
  
Reported-by: shihao zhong <zhong950419@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqSOAT1yop44B8jwacL_91rxK=QuoU8Of3NLMb9NgAO2NA@mail.gmail.com  
Backpatch-through: 16  

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

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

commit   : b28a2b2bfa50cb7aa3fcea069f0afad0ebcb6491    
  
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

Apply auto-vectorization to the loop in accum_sum_add()

commit   : 158b6d5109fad9d5f0c30693fa85041a1c621fe1    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 13 Oct 2026 14:31:45 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 13 Oct 2026 14:31:45 +0300    

Click here for diff

Rewrite the loop to a form that compilers are more likely to  
auto-vectorize, similar to commits 8870917623 and e3d41d08a1.  
  
Author: Xiangxin Zeng <xiangxin_zeng@qq.com>  
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>  
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>  
Discussion: https://www.postgresql.org/message-id/tencent_9DA409B9B2CAA6FFF985C638A28D35C73705@qq.com  

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

Add "own_hash" to pg_stat_kind_info

commit   : 6296e78c3d2c7406bb450c5ae477b2fef58f155e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 13 Oct 2026 13:47:25 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 13 Oct 2026 13:47:25 +0900    

Click here for diff

This is a follow-up of 44539786b829, to reflect the value of the new  
"own_hash" option to pg_stat_kind_info.  Thanks to this change, it  
becomes possible to know if a stats kind has the idea to use its own  
shared hashtable in pgstats.  
  
Bump catalog version.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0supQBxSkh=CWB39=j+cL3hHcLPki3tcBk0B1r4fesg_g@mail.gmail.com  

M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/utils/activity/pgstat_kind.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/modules/test_custom_stats/t/001_custom_stats.pl
M src/test/regress/expected/rules.out

pg_dump: Don't emit OVERRIDING SYSTEM VALUE for dropped identity columns

commit   : cde33148c9d8cc432296992eaa5c2f58a126712d    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 13 Oct 2026 13:18:00 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 13 Oct 2026 13:18:00 +0900    

Click here for diff

When a table's only GENERATED ALWAYS AS IDENTITY column had been  
dropped, pg_dump --inserts and --column-inserts could still emit  
OVERRIDING SYSTEM VALUE in INSERT statements. This clause has no effect  
when restoring into PostgreSQL but introduces unnecessary differences  
between dumps of otherwise equivalent tables.  
  
ALTER TABLE ... DROP COLUMN leaves pg_attribute.attidentity unchanged.  
getTableAttrs() used this field to set needs_override without checking  
attisdropped, so a dropped identity column could trigger the clause even  
when no remaining column required it.  
  
Ignore dropped columns when determining whether to emit the clause, so  
that the output reflects only the table's remaining columns.  
  
Apply to master only, since the unnecessary clause does not affect  
restoration into PostgreSQL and does not warrant backpatching.  
  
Author: William Bernbaum <wbernbaum@dwdev.com>  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/PH0PR18MB44430C10F7431F8D163CDAFFA6202@PH0PR18MB4443.namprd18.prod.outlook.com  

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

Allow a stats kind to use its own dshash in pgstats

commit   : 44539786b8296b6e73035142670e0d1ff2639078    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 13 Oct 2026 13:02:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 13 Oct 2026 13:02:24 +0900    

Click here for diff

Variable-numbered pgstats entries currently all live in one shared dshash  
table.  This works for stats kinds with each one having a rather "small"  
number of entries, but there are limits if a stats kind wants to  
allocate a large number of entries, especially if these need to be  
scanned on a periodic basis.  
  
This commit adds a new own_hash option for variable-numbered stats  
kinds, allowing these to use an independent dshash table backed by its  
own DSA area.  This gives a way for stats kind to leverage their efforts  
across more than one shared hashtable, splitting the load, with the same  
guarantees as the main hashtable.  Fixed-sized stats kind cannot use  
this option.  All the hashtables use the same key pattern,  
PgStat_HashKey.  
  
The motivation of this change is pg_stat_statements, to add it as a  
custom stats kind.  Out-of-core custom stats kind, or even built-in  
stats kinds can also use this option.  
  
At startup, each stats kind that opts in creates one initial DSA area in  
shared memory at startup.  At attach time, each registered  
variable-numbered stats kind is mapped to either the shared hash and DSA  
or its dedicated hash and DSA.  The local references are extended to  
track which hash table to use on a per-kind basis, with arrays based on  
the kind ID.  
  
The test module test_custom_stats is extended and refactored to provide  
coverage for this new own_hash.  
  
The idea of being able to use more than one hash table for pgstats has  
been originally mentioned off-list during a conference by Robert Haas  
(note: if my memory does not fail me here).  
  
Author: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0supQBxSkh=CWB39=j+cL3hHcLPki3tcBk0B1r4fesg_g@mail.gmail.com  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_shmem.c
M src/include/utils/pgstat_internal.h
M src/test/modules/test_custom_stats/t/001_custom_stats.pl
M src/test/modules/test_custom_stats/test_custom_var_stats–1.0.sql
M src/test/modules/test_custom_stats/test_custom_var_stats.c

doc: Consistently use double quotes for attrs in ulinks

commit   : 8e82d6610e7280d7870c0c36ff1c797e3cfb3e09    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 12 Oct 2026 11:56:10 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 12 Oct 2026 11:56:10 +0200    

Click here for diff

The href attribute to the ulink is rendered with double quotes in  
the <a> tag, and we use double quotes in the XML markup as well.  
This fixes the two cases which used single quotes.  
  
Author: Anatoliy Kraev <anatoliy.kraev@tantorlabs.ru>  
Discussion: https://postgr.es/m/5011791449270@mail.360.yandex.ru  

M doc/src/sgml/features.sgml

Show Material node Maximum Storage for parallel workers

commit   : a241bc4fedefae3c0b0952c0a9d3a28d7747bfe3    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 12 Oct 2026 22:41:35 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 12 Oct 2026 22:41:35 +1300    

Click here for diff

1eff8279d did this for the leader, but neglected to consider that the  
Material node may be below a Gather or Gather Merge and have parallel  
workers also participate in the execution of the Material node.  
  
Here we add EXPLAIN ANALYZE output to show Maximum Storage per worker  
and all the required shared memory related code to get those details  
back to the leader from each worker.  
  
Because the prior code didn't have parallel worker processes report the  
tuplestore usage details, this meant that the EXPLAIN ANALYZE output  
didn't show the Maximum Storage when running debug_parallel_query =  
regress.  You could argue that fixing that should be a bug fix, but  
fixing it would start reporting the Maximum Storage for Material nodes  
for parallel workers during parallel queries, which feels more like a  
new feature than a bug fix.  The telemetery data going missing with  
debug_parallel_query = regress isn't the end of the world, so let's just  
fix this in master.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvoUWCms-b27MpDKd5_RUFtAnVrxPgN9u3QoQbBihk+S6g@mail.gmail.com  

M src/backend/commands/explain.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeMaterial.c
M src/include/executor/instrument_node.h
M src/include/executor/nodeMaterial.h
M src/include/nodes/execnodes.h
M src/tools/pgindent/typedefs.list

Change tuplestore_get_stats() API

commit   : c6b8af429b3592b00d3240a24c5a27077ff0dd82    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 12 Oct 2026 22:36:21 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 12 Oct 2026 22:36:21 +1300    

Click here for diff

Previously, this returned a pointer to the string constant "Disk" or  
"Memory" depending on whether the tuplestore spilled to disk or not.  An  
upcoming patch adds additional EXPLAIN ANALYZE output for Material nodes  
for parallel workers.  The API pointing to the string constant is not  
great when we must transfer the storage method to the parallel leader, as  
we cannot simply point to the string constant in the other process.  
That's going to be mapped to a different memory address.  
  
Here we adjust the tuplestore_get_stats() API to set "*used_disk" to  
true when the tuplestore spilled to disk.  This allows us to avoid a  
pretty horrible: if (strcmp(..., "Disk") == 0) in the code to transfer  
the information to the parallel leader.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvoUWCms-b27MpDKd5_RUFtAnVrxPgN9u3QoQbBihk+S6g@mail.gmail.com  

M src/backend/commands/explain.c
M src/backend/utils/sort/tuplestore.c
M src/include/utils/tuplestore.h

Don't write to postgres's stdin in shmem startup failure test

commit   : 36a56229765c405b7e3655c3cf3a4fec2c0bc2b0    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 12 Oct 2026 08:26:08 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 12 Oct 2026 08:26:08 +0300    

Click here for diff

The single-user test expects postgres to fail during startup, before  
processing any queries. Sending the preceding test's queries can race  
with that exit and make IPC::Run abort on a broken pipe. To fix, pass  
empty input instead.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://www.postgresql.org/message-id/e87c8fef-e254-441e-b889-bbcbd5afea7f@gmail.com  
Backpatch-through: 19  

M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl

Add nbtree README note on index-only scans in recovery.

commit   : 9e7d152488f197e96f171f0714459c227c3f7693    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 10 Oct 2026 19:38:58 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 10 Oct 2026 19:38:58 -0400    

Click here for diff

The nbtree README has long claimed that "the interlocking required to  
avoid returning incorrect results from non-MVCC scans is not required on  
standby nodes".  A recent test case proved that the underlying reasoning  
was faulty.  
  
There are significant practical challenges around fixing this bug, and  
no user has complained about it so far.  The old "pin scan" mechanism  
prevented the problem but performed very poorly.  Since there seems to  
be no appetite for resurrecting that mechanism, and since an acceptable  
fix hasn't been forthcoming, make a note of the issue for later.  
  
Discussion: https://postgr.es/m/CAH2-Wzkro678xEDOrsxrq-YDVP4w7nXybhVJV2MxrzTj-5OU4w@mail.gmail.com  

M src/backend/access/nbtree/README

Fix hash index scans that start during a bucket split.

commit   : 173cf85a079516fdd2b09ed853702b05fbfcd15e    
  
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/hashpage.c
M src/backend/access/hash/hashsearch.c
M src/test/modules/Makefile
A src/test/modules/hash/.gitignore
A src/test/modules/hash/Makefile
A src/test/modules/hash/expected/hash_incomplete_splits.out
A src/test/modules/hash/meson.build
A src/test/modules/hash/sql/hash_incomplete_splits.sql
M src/test/modules/meson.build

doc: state PG does not support 8601-optional signed years

commit   : f58ab18a90460cd297249bc80b13d84b2671bf0c    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 9 Oct 2026 22:23:34 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 9 Oct 2026 22:23:34 -0400    

Click here for diff

Reported-by: Kacper Kuras  
  
Discussion: https://postgr.es/m/178897820483.2258529.4862563749043725162@wrigleys.postgresql.org  
  
Backpatch-through: 19  

M doc/src/sgml/datatype.sgml

doc: add SQL query showing handling of NULLs by aggregates

commit   : 0a38a8ff3fb560ec9302cf06616ab4a4e6027c40    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 9 Oct 2026 22:14:29 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 9 Oct 2026 22:14:29 -0400    

Click here for diff

Reported-by: y.saburov@gmail.com  
  
Reviewed-by: Laurenz Albe  
  
Discussion: https://postgr.es/m/178784080621.1060526.4544192651418189612@wrigleys.postgresql.org  
  
Backpatch-through: 19  

M doc/src/sgml/syntax.sgml

Fix expr_is_nonnullable() for IS DISTINCT FROM

commit   : f5635c2786af2322e1e21006a13a2c19f68fa591    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 10:52:52 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 10:52:52 +0900    

Click here for diff

Commit c8d2f68cc taught expr_is_nonnullable() to treat a DistinctExpr  
as never returning NULL.  That is wrong: when neither input is NULL,  
the result is NULL if the underlying equality operator returns NULL,  
which nothing forbids.  This could lead to wrong query results.  
  
To fix, remove the DistinctExpr case, along with its test case.  
  
While at it, test the relkind before calling has_subclass() in  
var_is_nonnullable(), to avoid a useless syscache lookup for  
partitioned tables.  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CA+TgmoaLcsmc9weJr1yo1X1SwZJX1t4XXHj0SJzH8XztmN9Hdg@mail.gmail.com  
Backpatch-through: 19  

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

Doc: remove some annoying zero-width spaces.

commit   : 91f75212bbff4151d3dc391927721a2431e56973    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 9 Oct 2026 21:14:58 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 9 Oct 2026 21:14:58 -0400    

Click here for diff

To avoid warnings and lines that extend beyond the right page  
margin in the PDF documentation, we have zero-width spaces in  
the source at strategic places.  They are not visible to the  
naked eye, but allow FOP to break the lines in sane places.  
  
However, some of these zero-width spaces were in the middle of  
text that people might copy and paste from the HTML documentation,  
which leads to mysterious syntax errors.  
  
Scanning the documentation for &zwsp; identified four places  
that this patch improves:  
  
- an ISO 8601 interval literal didn't actually need a line break  
  in either the US letter or A4 format, so simply remove that  
  zero-width space.  
  
- three v18-era examples for uuid_extract_timestamp() and  
  uuid_extract_version() had zero-width spaces in the middle of UUID  
  literals.  Instead, add regular spaces around the "::" cast symbols,  
  allowing FOP to break the lines there.  This solution isn't  
  invisible in the HTML output, but it doesn't look bad.  
  
Reported-by: Y. Saburov <y.saburov@gmail.com>  
Author: Laurenz Albe <laurenz.albe@cybertec.at>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/179143326813.1061054.14714458907175925072@wrigleys.postgresql.org  
Backpatch-through: 18  

M doc/src/sgml/datatype.sgml
M doc/src/sgml/func/func-uuid.sgml

Don't trust NOT NULL on virtual generated columns of partitioned tables

commit   : d8444163d22e576c9f284a55eab7999ba67c4ceb    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 09:21:27 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 09:21:27 +0900    

Click here for diff

Commit 383eb21eb taught the planner to convert a NOT IN sublink to an  
anti-join when the sub-select's outputs are provably non-nullable.  
Since the sub-select has not been through any planner processing at  
that point, a reference to a virtual generated column is still a plain  
Var, and query_outputs_are_not_nullable() relied on the column's NOT  
NULL constraint to prove it non-nullable.  
  
That is not safe for a partitioned table.  A partition can have a  
generation expression different from its parent's, and it enforces the  
NOT NULL constraint against its own expression, whereas a query on the  
parent computes the column using the parent's expression.  So the  
column can be NULL when read through the parent despite the  
constraint, and the anti-join would then produce wrong results, as it  
returns rows that NOT IN should have rejected.  
  
To fix, make var_is_nonnullable() ignore the NOT NULL constraint on a  
virtual generated column of a partitioned table when consulting the  
catalogs.  The other sources of NOT NULL information are only used  
after virtual generated columns have been expanded, so they are not  
affected.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS=L7=xdhTw@mail.gmail.com  
Backpatch-through: 19  

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

Preserve typmod and collation when reducing an expression to its input

commit   : d8ce0050a6cff3efefa5fce8abe3c6df7bd492ce    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 09:20:52 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 09:20:52 +0900    

Click here for diff

eval_const_expressions() can reduce a COALESCE, CASE, or NULLIF  
expression to one of its inputs.  The input, however, does not  
necessarily expose the same typmod and collation as the expression it  
replaces.  In particular, an explicit COLLATE clause on one input  
determines the collation of the whole expression, while the other  
inputs keep their own collations.  If the expression was reduced to  
one of those other inputs, anything that relies on exprCollation(),  
such as sorting or grouping on the expression, would use the wrong  
collation and could produce wrong results.  
  
For CASE and NULLIF this is a long-standing oversight.  For COALESCE  
it has become much easier to hit since commits 931766aae and  
10c4fe074, which reduce a COALESCE with a single surviving argument,  
or with a leading non-nullable argument, to that argument.  
  
To fix, apply applyRelabelType() to the replacement in these cases, so  
that it exposes the type, typmod, and collation of the expression it  
replaces.  
  
Back-patch to v19 only.  The CASE and NULLIF cases exist in older  
branches too, but they are not back-patched further, given the lack of  
field reports and the fact that the fix visibly changes the typmod  
exposed by a reduced CASE expression.  
  
Reported-by: Shihao Zhong <zhong950419@gmail.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS=L7=xdhTw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/util/clauses.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql

Fix ON CONFLICT inference for index expressions simplified to a Var

commit   : 62e46c00c657fc2e092ceec0cd79d16035798afe    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 09:20:27 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 10 Oct 2026 09:20:27 +0900    

Click here for diff

infer_arbiter_indexes() classifies each inference element by its  
const-simplified form: a plain Var is matched against the index's  
plain attributes, and anything else against its expressions.  Index  
columns, however, were classified by indkey alone, so an expression  
column stayed an expression even when const-simplification reduced it  
to a plain Var.  Since commit 10c4fe074, COALESCE on a NOT NULL column  
is reduced to the column itself, so an inference element such as  
COALESCE(b, '') became a plain Var that no longer matched the unique  
index on that same expression, and the statement failed with "there is  
no unique or exclusion constraint matching the ON CONFLICT  
specification".  
  
To fix, classify index columns the same way as inference elements: an  
index expression that is simplified to a plain Var is treated as a  
plain attribute.  Also, teach infer_collation_opclass_match() to  
compare such a column as an expression, so that an inference element  
that specifies a collation or operator class can still match it.  
  
As a consequence, an inference element naming the column directly now  
matches such an index too, which is consistent with how an element  
written as the expression already matches a plain index on the column.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: jian he <jian.universality@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS=L7=xdhTw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/util/plancat.c
M src/test/regress/expected/insert_conflict.out
M src/test/regress/sql/insert_conflict.sql

refactor: Move BackendWritebackContext initialization

commit   : 15a947f30726cadff695b7601329d90b6703e268    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 10 Oct 2026 01:01:02 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 10 Oct 2026 01:01:02 +0300    

Click here for diff

BackendWritebackContext is a purely per-process thing, so it feels  
wrong to initialize it in the shmem init/attach functions.  Move the  
initialization to InitBufferManagerAccess() instead.  
  
Backpatch to version 19, where the new shared memory callbacks system  
was introduced.  While this isn't new with that, it made the ShmemInit  
functions more closely related to shared memory initialization than  
before.  
  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/fb1bd612-4a58-4235-976f-2b2ef036bfff@iki.fi  
Backpatch-through: 19  

M src/backend/storage/buffer/buf_init.c
M src/backend/storage/buffer/bufmgr.c
M src/include/storage/buf_internals.h

Fix crash with wal_debug in EXEC_BACKEND child processes

commit   : 6873a138f782cf816e6019bbe922857050df96c9    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 10 Oct 2026 01:00:30 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 10 Oct 2026 01:00:30 +0300    

Click here for diff

Converting xlog.c to the new shared memory allocation API left the  
creation of the memory context used by wal_debug in the  
XLOGShmemInit() callback, which now only runs in the postmaster or in  
a standalone backend.  Previously, XLOGShmemInit() ran in every child.  
As a result, walDebugCtx was left uninitialized in child processes in  
EXEC_BACKEND mode, and with wal_debug turned on, the backend crashed  
on first WAL insertion.  
  
Fix by moving the walDebugCtx initialization to a separate function  
that is called in each backend that wishes to create WAL records.  (It  
cannot be created lazily on first WAL insertion, because it's done in  
a critical section, and you cannot create a new memory context in a  
critical section.)  
  
Oversight in 9b5acad3f40f.  
  
Co-authored-by:: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CALj2ACUNL4Xn3aBzvm4DTpdr_L0-AfL2agsghMRRy_ZTiKhxSA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/transam/xlog.c
M src/backend/access/transam/xloginsert.c
M src/include/access/xlog.h

Fix check on test function's arguments

commit   : 5f36942fd3196259ad5ad691f5ecbe4ce555ab7c    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 10 Oct 2026 00:29:02 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 10 Oct 2026 00:29:02 +0300    

Click here for diff

The function won't cope with nkinds == 0, it leads to division by  
zero.  It's just a test function though, so this is harmless and  
there's no need to backport.  
  
Author: Yuriy Grigoryev <ju.grigorev@ftdata.ru>  
Reviewed-by: Sho Ito <i.sho.0628@gmail.com>  
Discussion: https://www.postgresql.org/message-id/1905e9d709554733b418d06a4806436f@localhost.localdomain  

M src/test/modules/test_resowner/test_resowner_many.c

pg_plan_advice: Fix advice feedback JOIN_ORDER over a single sublist.

commit   : f6065c56d47eceb70c75de37a5ba214c67f73533    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Fri, 9 Oct 2026 13:57:08 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Fri, 9 Oct 2026 13:57:08 -0400    

Click here for diff

Suppose that a JOIN_ORDER() advice target consists of a single  
ordered or unordered sublist, something like JOIN_ORDER((...))  
or JOIN_ORDER({...}) or even JOIN_ORDER(({...})).  In the previous  
coding, the feedback for such advice would be "partially matched"  
even when the query joined all the relations mentioned. Fix that.  
  
Like the issues fixed by e1d8f81d4961ca6c4228eb9a3ab5d36168008e42,  
this escaped detection because advice generation never creates  
advice strings that have the problematic form.  
  
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: http://postgr.es/m/CAJTYsWWe8E8ya-24wRws5LSVhHNxCwLyy8c-ueY-TKvC=8P7UQ@mail.gmail.com  
Discussion: http://postgr.es/m/CA+TgmoYYHC4i-Gpzc9-JYHqih6pOK+6LTYFiNR-PioXG1nKkOQ@mail.gmail.com  
Backpatch-through: 19  

M contrib/pg_plan_advice/expected/join_order.out
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/sql/join_order.sql

pg_plan_advice: Don't suppress NO_GATHER advice for parent rels.

commit   : f71a9969d58e3e70239fc51bbeae668db973b265    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Fri, 9 Oct 2026 13:00:10 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Fri, 9 Oct 2026 13:00:10 -0400    

Click here for diff

When a table is partitioned, the previous code did not emit NO_GATHER  
advice for the parent table, on the theory that doing this for the  
child tables was good enough. However, it isn't. I believe what  
happened here is that, during development, I was planning to enforce  
NO_GATHER by clearing the consider_parallel flag for the children,  
which would have been good enough to ensure that parallelism could  
not be used at any higher level of the plan tree. Eventually, I  
switched course, but failed to realize that this code needed to be  
updated as a result. Do that, and add a regression test.  
  
Backpatch-through: 19  
Discussion: http://postgr.es/m/CA+TgmoYYHC4i-Gpzc9-JYHqih6pOK+6LTYFiNR-PioXG1nKkOQ@mail.gmail.com  

M contrib/pg_plan_advice/expected/gather.out
M contrib/pg_plan_advice/expected/partitionwise.out
M contrib/pg_plan_advice/pgpa_scan.c
M contrib/pg_plan_advice/sql/gather.sql

Fix detection of truncated zstd and LZ4 dump data

commit   : e01fc6315f19a794301ca8889d37ae629862e2ac    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 9 Oct 2026 12:03:44 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 9 Oct 2026 12:03:44 +0200    

Click here for diff

pg_restore did not verify that zstd and LZ4 decompression completed  
the final frame when reading custom and directory-format dumps. As a  
result, it could accept a dump whose compressed data was truncated.  
  
Track final-frame completion and reject incomplete compressed input.  
For zstd, flush any internally buffered output before performing the  
final check.  
  
Add regression tests for truncated zstd and LZ4 data in custom and  
directory-format dumps and also address a potentially empty error  
message while in there.  
  
Author: Chao Li <lic@highgo.com>  
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/5962B878-C43D-4EBC-9E95-1F945CE5E586@gmail.com  
Backpatch-through: 19  

M src/bin/pg_dump/compress_gzip.c
M src/bin/pg_dump/compress_lz4.c
M src/bin/pg_dump/compress_zstd.c
M src/bin/pg_dump/t/006_pg_dump_compress.pl

Fix detection of truncated compressed backups

commit   : e41b01f4359d3256943c00c834a3d9abef6c0129    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 9 Oct 2026 12:02:48 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 9 Oct 2026 12:02:48 +0200    

Click here for diff

pg_verifybackup failed to detect truncated compressed tar backups  
for zstd, lz4 and gzip compression.  
  
astreamer_zstd_decompressor checked whether ZSTD_decompressStream()  
returned an error.  However, a positive return value at end-of-input  
means that the final zstd frame has not completed.  Record the state  
and verify at finalization that zstd completed the frame.  Also flush  
any pending internally buffered output before performing that check.  
  
astreamer_gzip_decompressor did not check whether inflate() had  
reached Z_STREAM_END before finalizing.  Record whether inflate()  
completed the gzip stream, and reject finalization if it did not.  
  
astreamer_lz4_decompressor did not check whether LZ4F_decompress()  
completed the final frame before finalizing.  Record the status of  
decompression and reject finalization unless the frame completed.  
  
This prevents pg_verifybackup from accepting a truncated compressed  
tar backup.  
  
Author: Chao Li <lic@highgo.com>  
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Discussion: https://postgr.es/m/5962B878-C43D-4EBC-9E95-1F945CE5E586@gmail.com  
Backpatch-through: 19  

M src/bin/pg_verifybackup/t/010_client_untar.pl
M src/fe_utils/astreamer_gzip.c
M src/fe_utils/astreamer_lz4.c
M src/fe_utils/astreamer_zstd.c
M src/include/fe_utils/astreamer.h
M src/tools/pgindent/typedefs.list

Treat any negative ws_file as closed in xlogreader.c

commit   : 412848dac37f2e4455e1505f83f0af0f3d28a67d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 9 Oct 2026 13:59:55 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 9 Oct 2026 13:59:55 +0900    

Click here for diff

The segment_close() callback is required to set ws_file to a negative  
value after closing a WAL segment, as documented in xlogreader.h.  
XLogReaderFree() only treated -1 as closed, so it could call  
segment_close() again if another negative value was used.  
  
This should not be an issue in practice, but all the other code paths in  
the tree use 0 as comparison base when dealing with ws_file, except for  
the line updated here.  Let's be consistent, at least.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/asNr203eue0R4zpZ@bdtpg  

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

Fix incorrect reinit of run-time pruning for EPQ rechecks

commit   : 1b5dd3a24a48659e8413ef8ddd8adb6653507a9d    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 9 Oct 2026 11:03:07 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 9 Oct 2026 11:03:07 +1300    

Click here for diff

For run-time partition pruning running during execution (rather than at  
executor startup), EvalPlanQualStart() reuses the es_part_prune_states  
from the parent EState.  This could cause an issue when the EPQ recheck is  
finished, its EState is cleaned up and the es_query_cxt is deleted by  
FreeExecutorState().  That cleanup could free memory that was allocated  
again in InitExecPartitionPruneContexts() when it was called for the EPQ's  
EState, and naturally, those fields got allocated in the EPQ's  
es_query_cxt MemoryContext, which overwrote the ones for the parent  
EState.  If pruning occurs again after the EPQ's EState was cleaned up,  
then we could have accessed free'd memory.  This certainly caused issues in  
debug builds because we clobber freed memory, but may not have in  
production, depending on if the MemoryContext being deleted results in a  
free().  It may not if the allocation was on the context's init block and  
the context was pushed onto context_freelists[] for reuse.  
  
Here we fix this by adding an "initialized" field to PartitionPruneState  
and exit early in InitExecPartitionPruneContexts() when the state is  
already initialized.  
  
This was broken by bb3ec16e1, but the breakage there is slightly  
different as that commit neglected to do what was fixed in 8741e48e5  
(which did get backpatched to v18 in 9a82a64ed).  
  
Reported-by: Vladimir Savin <vladimir@encord.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Discussion: https://postgr.es/m/CAP2G_gGpV=rKMLuET4RW-qO41GvBvi6Czsjsj16eT9hAwHxG6w@mail.gmail.com  
Backpatch-through: 18  

M src/backend/executor/execPartition.c
M src/include/executor/execPartition.h
A src/test/isolation/expected/eval-plan-qual-partition-prune.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/eval-plan-qual-partition-prune.spec

Move index-only scan heap fetch comment.

commit   : d0e87c22d8351645cf77a42e60ee47f260c6c2e2    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 8 Oct 2026 17:35:57 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 8 Oct 2026 17:35:57 -0400    

Click here for diff

Oversight in commit ddce1da5.  

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

Handle concatenated gzip members in astreamer decompressor

commit   : f884f359f5acb29bd423001b4878b85f51406b42    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 8 Oct 2026 21:54:44 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 8 Oct 2026 21:54:44 +0200    

Click here for diff

With WAL streaming, pg_basebackup -Ft -z writes pg_wal.tar.gz as a  
series of gzip members.  The decompressor did not reset the inflate  
state when one ended, so inflate consumed nothing more and the loop  
never finished.  This caused pg_waldump to hang on such backups and  
as a consequence pg_verifybackup (which use pg_waldump) would hang.  
  
A test is added to pg_verifybackup for checking a gzip-compressed  
tar backup, which in turn will verify that pg_waldump works.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Discussion: https://postgr.es/m/CAGRkXqTcyuog_MzKqQm+am2xMefLFJTSKaRevnfypDWirCFvdA@mail.gmail.com  
Backpatch-through: 19  

M src/bin/pg_verifybackup/t/007_wal.pl
M src/fe_utils/astreamer_gzip.c

Fix parallel vacuum I/O timing reporting.

commit   : abf5fec634f6aac98e80e2ef6c3f3dbf0133dfaa    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 8 Oct 2026 11:26:09 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 8 Oct 2026 11:26:09 -0700    

Click here for diff

Commit 5cd72cc0c5 made the VACUUM VERBOSE and autovacuum logs report  
buffer usage from the pgBufferUsage delta, which includes the parallel  
workers' usage, but left the I/O timings on the leader's  
pgStatBlockReadTime and pgStatBlockWriteTime. So the log counted the  
blocks the workers read and dirtied but not the time they spent on  
them.  
  
Fix this by taking the I/O timings from the same BufferUsage delta.  
This also removes a small error in the leader's own timings, since  
pgStatBlock{Read,Write}Time accumulate whole microseconds per I/O.  
  
Although 5cd72cc0c5 was backpatched to v15, BufferUsage on v16 doesn't  
track the I/O time of temporary relations, so the same fix there would  
drop that time from the log. We don't think a reporting issue is worth  
v16-specific code, nor worth leaving v16 unfixed between v15 and v17,  
so backpatch to v17 only.  
  
Found by Bharath using AI assisted review with Claude.  
  
Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACXrqaHrYmGdpAoGKXtiY9Xw4o1dxSC+EELxn47GDO6HAQ@mail.gmail.com  
Backpatch-through: 17  

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

Remove faulty nbtree page deletion assertion.

commit   : 1732ab2757af722a71e17160e179ca7f80980778    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 8 Oct 2026 14:21:21 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 8 Oct 2026 14:21:21 -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

Add child_append_relid_sets to ElidedNode; use in pg_plan_advice.

commit   : 38475f23c83358eafe42a410e4342eb8d64ba24c    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 8 Oct 2026 14:12:24 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 8 Oct 2026 14:12:24 -0400    

Click here for diff

Commit 0d4391b265f83023d0b7eed71817517410f76e60 taught the planner  
to store information about the RTIs of SubqueryScan, Append, and  
MergeAppend node elided from the plan using a new ElidedNode data  
structure; an hour later, 7358abcc6076f4b2530d10126ab379f8aea612a5  
taught to save the RTIs of an Append node into another Append  
node using a new child_append_relid_sets field.  Regrettably,  
despite the fact that both commits were written by me and the  
fact that both were part of the same patch set, the latter commit  
failed to deal with the case where an Append node first acquires  
child_append_relid_sets != NIL and then gets elided. I believe that  
I thought that was impossible, but the included test case shows that  
it isn't.  
  
The proper fix involves updating the definition of ElidedNode to  
carry child_append_relid_sets, so this commit does that, breaking  
ABI compatibility. That's fine for the master branch, but it's a  
bit unfortunate to be doing do that so close to the planned ship  
date for v19.  However, shipping v19 without fixing this appears  
(at least to me) to be even more unfortunate.  
  
Backpatch-through: 19  
Discussion: http://postgr.es/m/CA+TgmoYYHC4i-Gpzc9-JYHqih6pOK+6LTYFiNR-PioXG1nKkOQ@mail.gmail.com  

M contrib/pg_overexplain/expected/pg_overexplain.out
M contrib/pg_overexplain/pg_overexplain.c
M contrib/pg_plan_advice/expected/partitionwise.out
M contrib/pg_plan_advice/pgpa_scan.c
M contrib/pg_plan_advice/sql/partitionwise.sql
M src/backend/optimizer/plan/setrefs.c
M src/include/nodes/plannodes.h

oauth_validator: Remove racing GUC check

commit   : f1eafd911ddde87f84672b5bf227a3e6cae6331f    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 8 Oct 2026 10:58:07 -0700    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Thu, 8 Oct 2026 10:58:07 -0700    

Click here for diff

Follow-up to bca67e5a3. The test added there changed the value of  
oauth_validator_libraries, waited for the postmaster to apply it, and  
verified the change on an existing background connection. But there's no  
guarantee that the SIGHUP will have arrived and completed its work on  
existing backends by that time, so the final test flaked.  
  
We only care about the postmaster's state here, since we're testing the  
GUC's effects on newly forked backends, so remove the background check  
entirely.  
  
Per buildfarm member serinus.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://postgr.es/m/a37a3cea-5bd8-4385-a1d4-bb89394c079c%40gmail.com  
Backpatch-through: 18  

M src/test/modules/oauth_validator/t/001_server.pl

COPY TO FORMAT JSON: use the query's column names as keys

commit   : c652cd3f94d57e69965f065c4ed45708a2b2a757    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 5 Oct 2026 16:28:25 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Mon, 5 Oct 2026 16:28:25 -0400    

Click here for diff

CopyToJsonOneRow() stamped the row datum with the query's descriptor  
only when the slot's descriptor was of type RECORD.  A scan that does  
not project returns the table's row type, so the keys came from the  
table, not the query, losing column aliases and mislabelling rows  
from UNION ALL branches with different column orders.  
  
Fix by always using the query's descriptor.  For non-virtual slots,  
heap_copy_tuple_as_datum() can just be passed that descriptor, so  
there is no extra cost.  This is safe because a scan skips projection  
only when tlist_matches_tupdesc() holds, so the layouts match.  
  
Bug introduced in 7dadd38cda9.  
  
Reported-by: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: João Marcelo Detomini <joao.detomini@enterprisedb.com>  
Discussion: https://postgr.es/m/CAGRkXqQHjxgufHPz86+dxGaQZt37hikduUArYtfbn2_3mryZAw@mail.gmail.com  
Backpatch-through: 19  

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

Stabilize recently added tests in 051_effective_wal_level.pl.

commit   : d64e5357485534f8aca4b700bde6c9145fdb243b    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 8 Oct 2026 10:33:23 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 8 Oct 2026 10:33:23 -0700    

Click here for diff

Commit 1f2245371e3 added a test for the case where logical decoding  
is disabled and re-enabled while synchronizing a replication slot. Its  
cleanup assumed the slot re-created on retry would still be temporary,  
and so would be gone once the corresponding remote slot was  
dropped. That isn't guaranteed: the catalog_xmin reserved on the  
standby is not necessarily ahead of the remote slot's. In that case  
the slot is persisted on the first retry, and the subsequent logical  
decoding deactivation invalidates it on the standby rather than  
dropping it, so the check that no synced slot is left behind fails.  
  
Stabilize the cleanup by calling an extra pg_sync_replication_slots()  
after dropping the remote slot and before disabling logical decoding on  
the primary.  
  
Per buildfarm member skink.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Suggested-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwFWXASACRnhHJgEdk8nWyLw4bLLDhiEiKSqBqd+tzJ2Pg@mail.gmail.com  
Backpatch-through: 19  

M src/test/recovery/t/051_effective_wal_level.pl

pg_plan_advice: Avoid miscategorizing partitionwise scans as ordinary.

commit   : 8606fb3f449301cb6c7636eed9eecf5dd267e8fb    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 8 Oct 2026 12:27:44 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 8 Oct 2026 12:27:44 -0400    

Click here for diff

Given an Append or MergeAppend node, pgpa_build_scan needs to call  
pgpa_make_scan for the node's own apprelids, and also for each element  
of child_append_relid_sets. It did that, but it overlooked the fact  
that the scan type applicable to the child scans might differ from  
the scan type applicable to the parent scan. The problem can only  
occur in one direction: an RTE_SUBQUERY (Merge)Append can appear on  
top of a RTE_RELATION (Merge)Append, but not the reverse, so the  
only failure mode here is to classify a partitionwise scan of a child  
appendrel as PGPA_SCAN_ORDINARY rather than PGPA_SCAN_PARTITIONWISE,  
leading to failure to include PARTITIONWISE(something) in the  
generated advice string.  
  
Backpatch-through: 19  
Discussion: http://postgr.es/m/CA+TgmoYYHC4i-Gpzc9-JYHqih6pOK+6LTYFiNR-PioXG1nKkOQ@mail.gmail.com  

M contrib/pg_plan_advice/expected/partitionwise.out
M contrib/pg_plan_advice/pgpa_scan.c
M contrib/pg_plan_advice/sql/partitionwise.sql

Fix failure of setrefs.c to process child_append_relid_sets

commit   : 0f7dfd7936b9e99f9aeca00f52ab1692898ffff4    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 8 Oct 2026 12:11:08 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 8 Oct 2026 12:11:08 -0400    

Click here for diff

Commit 7358abcc6076f4b2530d10126ab379f8aea612a5 taught the planner to  
store information about Append node consolidation in the final plan,  
but it forgot that child_append_relid_sets needs to be adjusted  
at setrefs.c time just like every other place where we store RTIs  
in a plan tree. Fix that.  
  
Although this can cause incorrect plan advice to be emitted in cases  
involving multi-level partitioning, it seems more appropriate to put  
the test case for it in pg_overexplain, so this commit does that.  
  
Backpatch-through: 19  
Discussion: http://postgr.es/m/CA+TgmoYYHC4i-Gpzc9-JYHqih6pOK+6LTYFiNR-PioXG1nKkOQ@mail.gmail.com  

M contrib/pg_overexplain/expected/pg_overexplain.out
M contrib/pg_overexplain/sql/pg_overexplain.sql
M src/backend/optimizer/plan/setrefs.c

Update the branch retirement timeline to fit recent practice.

commit   : 16b94c4012025afb65f6fec3f22d6a653a3b184f    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Thu, 8 Oct 2026 07:07:45 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Thu, 8 Oct 2026 07:07:45 -0700    

Click here for diff

Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  

M src/tools/RELEASE_CHANGES

Fix warning message translatability

commit   : 5c74e122ef295e251be43a8ce0c561e91fcd000d    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 8 Oct 2026 10:49:09 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 8 Oct 2026 10:49:09 +0200    

Click here for diff

Pasting together sentences with placeholders is not suitable for  
translation.  Write out both variants instead.  
  
Fix comma splice in the detail message while we're here.  

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

Lock RI fast-path rows as of the scan snapshot's command ID

commit   : 061065e28f086e3e2d7191a7785b9f218b7976d8    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 8 Oct 2026 12:49:06 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 8 Oct 2026 12:49:06 +0900    

Click here for diff

ri_LockPKTuple() passed table_tuple_lock() the current command ID, read  
at lock time.  ExecLockRows(), which locks the row for the SPI path's  
SELECT ... FOR KEY SHARE, uses the estate's es_output_cid, fixed when  
the query starts and equal to the command ID of the query's snapshot.  
The two differ if user code run between taking the snapshot and locking  
the row, such as the equality function called by the index scan,  
advances the command counter.  If that code also updated the referenced  
row, the lock reports TM_Invisible, and the check fails with "attempted  
to lock invisible tuple", where the SPI path gets TM_SelfModified and  
reports a foreign key violation.  
  
To fix, use the snapshot's command ID in ri_LockPKTuple() to mirror  
what ExecLockRows() does.  
  
This is mostly hardening.  With FK values that need a cast now checked  
through SPI, the only user code that can run there is the opclass's  
equality function, and it would have to write to the referenced table.  
That's unlikely, but the fast path should still behave like SPI.  
  
Discussion: https://postgr.es/m/CA+HiwqG79XK1oObdZ2AwT660CeJ6s3Mn4LrFPCme-k4L2rF_ag@mail.gmail.com  
Backpatch-through: 19  

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

Fix WAL segment fd leaks with the WAL reading facility (xlogreader.c/h)

commit   : cb1eef81c9bc8d1a2adc1e3a63669e315b6232bd    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 8 Oct 2026 12:11:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 8 Oct 2026 12:11:39 +0900    

Click here for diff

In most of the backend code, XLogReaders open a WAL segment file with  
BasicOpenFile() (xlogutils.c, WAL summarizer and WAL sender).  On ERROR,  
the opened file descriptor could leak while reading WAL segments, piling  
them over time if a session can spawn XLogReaders at will, leading to  
EMFILE with various consequences, the worst being a backend-side PANIC.  
  
The problem has been reported as reachable with pg_walinspect (EXECUTE  
privilege revoked from PUBLIC by default), or replication slot functions  
(REPLICATION privilege required).  
  
XLogReaderState gains a memory context reset callback, registered if a  
segment_open callback has the idea to open a WAL segment with  
BasicOpenFile().  XLogReaderRegisterResetCallback() can be used by a  
segment_open callback to ensure the cleanup of any opened file  
descriptor.  
  
No backpatch is done.  This breaks the ABI of XLogReaderState (sizeof),  
and MemoryContextUnregisterResetCallback() is new in v19.  There may be  
an argument for fixing this issue in v19, but the release is close  
enough that this change does not seem worth taking a risk for.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CALj2ACVwDuOXXDjj2cVdnTKoxsgTSLDin4XoL63AnM6aUgMQaA@mail.gmail.com  

M src/backend/access/transam/xlogreader.c
M src/backend/access/transam/xlogutils.c
M src/backend/postmaster/walsummarizer.c
M src/backend/replication/walsender.c
M src/include/access/xlogreader.h

Refuse RI fast-path row locks in read-only transactions

commit   : c993d9f7c8d4bcada0d5c0bd6ea32416d956fc8f    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 8 Oct 2026 09:26:33 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 8 Oct 2026 09:26:33 +0900    

Click here for diff

The SPI path checks a foreign key with SELECT ... FOR KEY SHARE, which  
ExecCheckXactReadOnly() refuses in a read-only transaction unless the  
referenced table is temporary.  The fast path locks the referenced row  
without that check, so for example a deferred check that fires at  
COMMIT after SET TRANSACTION READ ONLY succeeded, having locked a row  
in a read-only transaction, where the SPI path fails with "cannot  
execute SELECT FOR KEY SHARE in a read-only transaction".  
  
Fix the fast path to refuse it the same way so the behavior matches  
with checks going through SPI.  
  
Discussion: https://postgr.es/m/CA+HiwqG79XK1oObdZ2AwT660CeJ6s3Mn4LrFPCme-k4L2rF_ag@mail.gmail.com  
Backpatch-through: 19  

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

Reuse zstd decompression contexts when restoring WAL images

commit   : ce3387b74b708a679282ba5c72990b532d661bb8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 8 Oct 2026 09:47:43 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 8 Oct 2026 09:47:43 +0900    

Click here for diff

Restoring each zstd-compressed full-page image currently creates and  
destroys a decompression context.  One decompression context gets now  
saved in a XLogReaderState on first use, reused for the decompression of  
any follow-up zstd-compressed pages.  
  
The decompression context is freed in XLogReaderFree().  In non-FRONTEND  
builds, a memory context reset callback is registered to make sure that  
the decompression context does not leak.  Note that zstd has APIs to  
either initialize a pre-allocated decompression context or assign custom  
allocation and free routines, but none of these are available for  
builds that dynamically link to the zstd library (ZSTDLIB_STATIC_API).  
  
Tomas Vondra has done some benchmarking showing that for a FPI-heavy set  
of WAL records, reusing the decompression context can nicely improve the  
recovery time, bringing it close to lz4.  In my own measurements, I have  
seen up to a 4% faster recovery time when replaying records made mostly  
of zstd-compressed full-page images between HEAD and this improvement.  
Andrey has seen better numbers than that.  
  
Author: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://www.postgresql.org/message-id/asRsOl73nf8GeBFd@paquier.xyz  

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

Fix slotsync when logical decoding is disabled and re-enabled.

commit   : 1f2245371e31f0def347546f5ad250552a4eb8a4    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 7 Oct 2026 11:56:04 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 7 Oct 2026 11:56:04 -0700    

Click here for diff

Commit 6aba42c660c made slot synchronization skip persisting a new  
slot if logical decoding got disabled after the remote slot  
information was fetched. As noted in its XXX comment, the check  
missed the case where the last logical slot on the primary is dropped  
and re-created with the same name in the meantime. If the standby had  
replayed both the deactivation and the re-activation by then, the  
slot was persisted with a restart_lsn preceding the deactivation.  
Subsequent synchronization cycles failed with "unexpected logical  
decoding status change" when advancing the slot, which also stopped  
the synchronization of all other failover slots, and the slot could  
not be decoded after promotion.  
  
Fix this by remembering the end LSN of the last replayed  
XLOG_LOGICAL_DECODING_STATUS_CHANGE record that enables logical  
decoding, and by requiring the remote restart_lsn to be at or after it  
right after creating the local slot. The check is skipped until replay  
reaches the remote restart_lsn, as we can't tell anything about WAL that  
hasn't been replayed yet. Once the slot exists, a later deactivation  
invalidates it, so remove the check before persisting the slot. We  
compare the remote restart_lsn rather than the local one, so we may drop  
a slot that would have been usable, but the retry in the next  
synchronization cycle fetches fresh information.  
  
Backpatch to v19, where commit 67c20979ce7 made logical decoding toggle  
dynamically.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Zhijie Hou <houzhijie22@gmail.com>  
Discussion: https://postgr.es/m/CAM527d_eV_BAYFiQnfZLSPfHoihye=nOi-OnAM_57pdH+F+gfA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/transam/xlog.c
M src/backend/replication/logical/logicalctl.c
M src/backend/replication/logical/slotsync.c
M src/include/replication/logicalctl.h
M src/test/recovery/t/051_effective_wal_level.pl

Add an init callback for the logical decoding control data.

commit   : 952cb079131ba1bd16b71aada4b623b8b2926c6c    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 7 Oct 2026 11:09:09 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 7 Oct 2026 11:09:09 -0700    

Click here for diff

LogicalDecodingCtl had no init callback so there is no guarantee that  
its fields are initialized. Its startup function  
StartupLogicalDecodingStatus() also returns without touching the  
fields when wal_level is 'minimal'.  
  
Initialize them in an init callback explicitly. This is not a bug fix  
but we just shouldn't be depending on the allocator by accident.  
  
Backpatch to v19, where logicalctl.c was introduced, since a  
subsequent bug fix for slot synchronization adds a new field to  
LogicalDecodingCtlData and relies on this callback to initialize it.  
  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Discussion: https://postgr.es/m/CAM527d_eV_BAYFiQnfZLSPfHoihye=nOi-OnAM_57pdH+F+gfA@mail.gmail.com  
Backpatch-through: 19  

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

Tighten data validity checks in tsvectorrecv().

commit   : 10cc5aa96a6df7cb1d7c47e978cc94f01f785cb7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 7 Oct 2026 11:49:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 7 Oct 2026 11:49:30 -0400    

Click here for diff

Insist that the input lexemes be already sorted and non-duplicate.  
There's no good reason for them not to be, since the required ordering  
is simple and platform-independent.  The previous coding was willing  
to re-sort them, but that left a gap: it didn't de-duplicate them.  
De-duplicating would potentially require merging position lists,  
which would be painful; we can't easily re-use tsvectorin()'s logic  
for that, since it uses a different temporary representation.  
Let's just dodge the problem by insisting the lexeme list be fully  
correct as-presented, as we were already doing for the position lists.  
  
Also, there was an oversight in the position-list checking: it did  
not verify that the first position isn't zero.  tsvectorin() rejects  
that, so this should too.  
  
While these problems allow tsvectorrecv() to construct tsvectors  
that would not be generated internally, the vectors aren't so broken  
that we can't work with them.  Therefore, the best course of action  
seems to be to apply these tighter rules in master but not back-patch.  
Back-patching might break application workflows that aren't causing  
any serious problems.  Any such users will need to clean their data  
before loading it into PG >= v20, but they'd face that issue anyway,  
and a major update is a better time for it than a minor update.  
  
Bug: #19748  
Reported-by: Ke <kehan5800@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19748-6075f0508fa1ffc0@postgresql.org  

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

Remove "array_nulls" GUC parameter.

commit   : e96efd07c72834da48d8a21e4672a150c500a08d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 7 Oct 2026 11:39:02 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 7 Oct 2026 11:39:02 -0400    

Click here for diff

This backwards-compatibility hack was introduced twenty years ago (in  
8.2), and has surely been of no value for at least the last ten years.  
However, we shouldn't just leave it sit, because as was just pointed  
out it creates a dump/reload hazard: if it's set in the receiving  
environment then array contents will not be restored correctly.  
Other applications would likely be broken by it too, so whatever  
residual value it may have seems outweighed by the possibility of  
misuse.  
  
Our precedent for retiring some other comparable parameters, such as  
standard_conforming_strings, has been to leave the parameter in  
existence but force it to a fixed value.  I judge however that  
that's not worth the trouble here, because there's no reason to  
believe that a non-negligible number of applications are either  
setting or reading this value.  Let's just delete it in the master  
branch and be done with it.  
  
Bug: #19747  
Reported-by: Ke <kehan5800@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Discussion: https://postgr.es/m/19747-69b01e7fc190cd58@postgresql.org  

M doc/src/sgml/array.sgml
M doc/src/sgml/config.sgml
M src/backend/utils/adt/arrayfuncs.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/include/utils/array.h

Convert some casts to unconstify

commit   : 2906f0d5d7e2d3289f41b98115836c0bc15ab43e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 14:33:14 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 14:33:14 +0200    

Click here for diff

These casts existed only to cast away a const qualifier.  Convert them  
to unconstify to make that more explicit.  
  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org  

M src/backend/executor/execExpr.c
M src/backend/replication/slot.c
M src/backend/storage/ipc/shmem.c
M src/backend/storage/smgr/md.c
M src/backend/utils/mb/mbutils.c
M src/port/bsearch_arg.c
M src/port/path.c

Fix -Wcast-qual warnings with external APIs

commit   : 920746297961077ebe6069842fed6a177405f949    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 14:32:47 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 14:32:47 +0200    

Click here for diff

These casts were there only drop a qualifier to satisfy some external  
API.  Convert them to unconstify to make the purpose clear.  
  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org  

M src/backend/libpq/be-secure-gssapi.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/port/win32/socket.c
M src/bin/psql/tab-complete.in.c
M src/interfaces/libpq/fe-secure-gssapi.c
M src/interfaces/libpq/fe-secure-openssl.c

Revamp REPACK doc refentry page

commit   : 6510d5253ec0a0c4c46341784b411f64f12e2e07    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 7 Oct 2026 14:24:37 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 7 Oct 2026 14:24:37 +0200    

Click here for diff

The page a bit of a mess, with notes interpersed in the list of  
parameters, and two "notes" subsections that weren't in the Notes  
section.  
  
Limit the commentary under "Description" and "Parameters" to a minimum;  
move the existing text to appear in the "Notes" section.  Both the  
"Notes on Clustering" and "Notes on Resources" subsections, which were  
under "Description", are moved to be under "Notes" instead.  Add a new  
"Notes on Concurrent Operation" subsection there, which now carries some  
text that was in "Parameters", and gets some additional text to  
(hopefully) explain resource consumption more clearly -- notably, the  
hard limit of 104 million tuples that can be concurrently updated/deleted  
before running into the palloc size limit.  
  
Add appropriate cross-links.  
  
Author: Radim Marek <radim@boringsql.com>  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAJgoLk+dodrwuwCuXERGYwgjQzSwrKd+xgitYrL32oWDt39zvA@mail.gmail.com  

M doc/src/sgml/ref/repack.sgml

psql: Improve tab completion for GRANT/REVOKE CREATE

commit   : 00e917ef651120c261625b11a35b54990406f069    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 7 Oct 2026 20:53:53 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 7 Oct 2026 20:53:53 +0900    

Click here for diff

Complete GRANT CREATE, REVOKE CREATE, and REVOKE GRANT OPTION FOR CREATE  
with ON. Previously, the generic CREATE completion rule took precedence  
and suggested object types such as TABLE.  
  
Exclude these cases from the CREATE completion rule so that the existing  
GRANT/REVOKE rules can handle them.  
  
Author: Haruna Miwa <miwa@sraoss.co.jp>  
Reviewed-by: Sho Ito <i.sho.0628@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/OSOP286MB78539E88C47403451BFFF140F18A2@OSOP286MB7853.JPNP286.PROD.OUTLOOK.COM  

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

Fix remote_apply waits with wal_receiver_status_interval set to zero

commit   : cc33773482e879ea746256cc344ab029df1243d9    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 7 Oct 2026 19:09:23 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 7 Oct 2026 19:09:23 +0900    

Click here for diff

With synchronous_commit = remote_apply, a commit could remain blocked even  
after the synchronous standby had applied it when  
wal_receiver_status_interval was set to zero. With both  
wal_sender_timeout and wal_receiver_timeout disabled, the wait could last  
indefinitely.  
  
Commit 400a790a48e introduced this regression while avoiding unnecessary  
duplicate standby status replies. It changed apply notifications from forced  
replies to replies that check for WAL position changes. However,  
XLogWalRcvSendReply() still returned early for non-forced replies when  
wal_receiver_status_interval was zero, before checking the apply position.  
  
Fix this by allowing apply-notification requests to bypass the early return  
while preserving the existing checks that suppress unnecessary duplicate  
replies.  
  
Author: Vaibhav Dalvi <vaibhav.dalvi@enterprisedb.com>  
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CA+vB=AHKUhc9GCDwoLr=SshTBCQG09kp8TEXew50UtD5rYqowg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/replication/walreceiver.c
M src/test/recovery/meson.build
A src/test/recovery/t/059_remote_apply_status_interval.pl

Concurrent REPACK: Clear out dropped-column values from all tuples

commit   : e40b509c08f34e245bfab4124e24297ddaf4d535    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 7 Oct 2026 10:56:55 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 7 Oct 2026 10:56:55 +0200    

Click here for diff

Commit e5d25959cf87 made REPACK null-out values of dropped columns in  
the NEW tuple of an UPDATE.  However, a concurrent INSERT can carry one  
too, for example when a trigger returns a copy of an existing row.  
REPACK (CONCURRENTLY) then kept the values for such columns, which is  
wasteful -- or worse, failed with "row is too big" if the new heap  
happens not to have a TOAST table.  
  
Move their clearing from prepare_concurrent_update() to restore_tuple()  
so that it affects all tuples processed, not just the UPDATE ones.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAJgoLkK2UBzB1J9buCsSUbjf7bOqz-o_0=CeiTruU789BhBw-Q@mail.gmail.com  

M src/backend/commands/repack.c
M src/test/modules/injection_points/expected/repack_dropped.out
M src/test/modules/injection_points/specs/repack_dropped.spec

Use unconstify_constexpr

commit   : 73d4ba85059bc08b9be8f65a3fd9d1ed13eb979b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 08:21:37 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 08:21:37 +0200    

Click here for diff

Add uses of unconstify_constexpr were appropriate.  
  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org  

M src/backend/tcop/dest.c
M src/backend/utils/adt/numeric.c
M src/pl/plpython/plpy_cursorobject.c

Add unconstify_constexpr

commit   : d396cb7e22b3e25060cbb80e5c857ea655bc500b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 08:21:37 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 7 Oct 2026 08:21:37 +0200    

Click here for diff

unconstify_constexpr is like unconstify but for contexts where a  
constant expression is required, such as for initializing global  
variables.  It provides the same level of checking as unconstify, but  
the checking only works on GCC, otherwise it lets anything through.  
Also, if the check fails, it gives a less clear error message.  So it  
should only be used when necessary.  
  
(An unvolatize_constexpr doesn't seem necessary, but it could be added if  
required.)  
  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://www.postgresql.org/message-id/c76b72dd-5736-453a-b698-6968d42e4768%40eisentraut.org  

M src/include/c.h

pg_walsummary: Fix --quiet to suppress limit block output

commit   : 2a8ce0f684a4aa3da8f8c6f2d255048d545e96ff    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 7 Oct 2026 14:57:41 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 7 Oct 2026 14:57:41 +0900    

Click here for diff

Previously, pg_walsummary printed limit block lines even with --quiet  
because the output was generated before checking the quiet flag.  
  
Fix this by moving the output after the quiet check.  
  
Backpatch to v17, where pg_walsummary was introduced.  
  
Author: Koshi Shibagaki <shibagaki.koshi@fujitsu.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/TY5PR01MB18445D1AF87F64E9835BAD0B0FA962@TY5PR01MB18445.jpnprd01.prod.outlook.com  
Backpatch-through: 17  

M src/bin/pg_walsummary/pg_walsummary.c
M src/bin/pg_walsummary/t/002_blocks.pl

Fix PlaceHolderVar placement for join alias expressions

commit   : 738d19d4ea14d1173b0bac764014fcb36f8f5c79    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 7 Oct 2026 14:35:21 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 7 Oct 2026 14:35:21 +0900    

Click here for diff

When a join alias Var with nonempty varnullingrels expands to an  
expression that cannot carry the nullingrels itself, such as the  
RowExpr of a whole-row Var, add_nullingrels_if_needed() wraps it in a  
PlaceHolderVar.  The choice of the PHV's phrels had several problems.  
  
First, phrels was taken from all Vars in the expression.  If a LATERAL  
subquery within the join has been pulled up, the expression can  
contain lateral references to rels outside the join, so the PHV could  
be evaluated above the outer join that is supposed to null it.  This  
gave wrong results, or "wrong phnullingrels" errors.  
  
Second, for a variable-free expression we fell back to the join's  
relids but removed the join's own outer-join relid.  That leaves a set  
spanning both sides of the outer join without the join itself, which  
can make the PHV look nullable by that join and cause "wrong  
phnullingrels" errors.  
  
Third, that fallback raised "unsupported join alias expression" when  
the Var is an outer reference from a subquery.  The restriction is  
unnecessary: every planner caller passes root->parse as the query, so  
the Var always belongs to root->parse regardless of its varlevelsup.  
  
To fix, restrict phrels to the rels within the join, and if nothing is  
left, evaluate the PHV at the join including its outer-join relid, at  
any varlevelsup.  Add an assertion that the query is root->parse.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49q_gvoeOoF0+KZ-DpQaDb=nGFfSgrz2V_n1_64L4ZNVQ@mail.gmail.com  
Backpatch-through: 16  

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

Fix parser failure with whole-row join alias Vars

commit   : 372761e05a62856d32fb6a9811edf1c51a286b9c    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 7 Oct 2026 14:35:01 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 7 Oct 2026 14:35:01 +0900    

Click here for diff

When a query has aggregates or GROUP BY, parseCheckAggregates()  
flattens join alias Vars in the grouping expressions, target list and  
HAVING clause so that aliased and unaliased references compare equal.  
The parser has no PlannerInfo, so this relies on every join alias  
expression being able to carry varnullingrels without a PHV.  That  
doesn't hold for a whole-row Var of a join on the nullable side of an  
outer join: it expands to a RowExpr, and pushing the nulling bits down  
into its fields would turn a NULL row into ROW(NULL, ...).  Such  
queries therefore failed with "unsupported join alias expression".  
  
To fix, leave a nulled whole-row join Var unexpanded when no root is  
available.  The planner expands it later and wraps it in a  
PlaceHolderVar as before.  Nothing is lost for GROUP BY matching: a  
nulled whole-row Var can only be equal to the same Var, never to an  
expression over the join's columns.  
  
This has been broken since the introduction of varnullingrels in v16.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49q_gvoeOoF0+KZ-DpQaDb=nGFfSgrz2V_n1_64L4ZNVQ@mail.gmail.com  
Backpatch-through: 16  

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

reindexdb: Forbid index-level REINDEX with CONCURRENTLY and multiple jobs

commit   : e9c03f0f1bf698c0c603c51baaacfa60dc8c91c7    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 7 Oct 2026 10:39:06 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 7 Oct 2026 10:39:06 +0900    

Click here for diff

reindexdb batches the REINDEX commands of all indexes attached to the  
same table into a single multi-statement query when using multiple jobs,  
as two steps with query "gen" and "run".  
  
Such a query fails with REINDEX CONCURRENTLY, as this command cannot run  
inside a transaction block.  Batching cannot be avoided because the  
indexes of one table have to be re-indexed one at a time to avoid  
conflicts across jobs.  
  
Let's error out cleanly on the reindexdb side if this combination of  
options is used, instead of having the server complain about that.  This  
case has not been considered by 47f99a407d.  
  
If there is interest in supporting this combination of options, the code  
should be redesigned for this purpose with some better batching, rather  
than try to use sets of "gen" and "run" routines.  As currently written,  
an index-level reindexdb uses a set of "gen" steps with one final "run"  
step, which is nice code-wise.  (Note: I doubt that that this would be  
worth the effort.)  
  
Author: Kirill Reshke <reshkekirill@gmail.com>  
Discussion: https://postgr.es/m/CALdSSPiEkAmS+n7Ea9XDMrLjkbQk=CrB7zw1kcq9B47hfKUhXw@mail.gmail.com  
Backpatch-through: 17  

M src/bin/scripts/reindexdb.c
M src/bin/scripts/t/090_reindexdb.pl

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

commit   : f8ab6c622466ad41dc08215ecbceebeeb104dec8    
  
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

Fix handling of shutdown requests during an early crash restart

commit   : 12f866cd5f72d65ed4435b8203540efde45ba01d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 7 Oct 2026 08:45:37 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 7 Oct 2026 08:45:37 +0900    

Click here for diff

A smart or fast shutdown during an early crash restart can wait forever  
on the checkpointer and I/O workers.  FatalError is still set, so  
PM_STOP_BACKENDS adds them as processes to wait for, but these are  
relaunched by the restart and ignore the SIGTERM that a shutdown sends.  
AbortStartTime has been reset at that point, meaning that SIGKILL would  
also not fire.  
  
SIGQUIT is now sent instead of SIGTERM when FatalError is set, via  
HandleFatalError(), arming AbortStartTime.  Going through that routine  
rather than signaling the children directly matters for the startup  
process: TerminateChildren() marks the startup process as signaled, so  
its exit is not later reported as a failure.  Note that after sending  
the SIGTERM, we check for any running processes, assuming that auxiliary  
processes have been already SIGQUIT'd for an immediate shutdown or for a  
FatalError.  
  
A test case is added, able to stress the scenario of a shutdown  
triggered during the early phases of crash recovery with a custom  
restore command waiting for a shutdown by scanning the server logs.  The  
CI is stable with this test (several runs done); the buildfarm will be  
the final judge regarding its stability.  
  
No backpatch is done for now, to be on the conservative side.  This  
feels also a slightly risky change for v19, which is close to release,  
and letting this change bake on HEAD a bit would not hurt.  
  
This problem has been originally reported by Justin Pryzby back in 2023,  
without being fixed, and still existed on HEAD.  
  
Reported-by: Justin Pryzby <pryzby@telsasoft.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Co-authored-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAJTYsWXCLi00cJ6-_OkMJB4UjyV6EZjc86QwmgE9=iH_C0R-Aw@mail.gmail.com  
Discussion: https://postgr.es/m/ZWlrdQarrZvLsgIk@pryzbyj2023  

M src/backend/postmaster/postmaster.c
M src/test/recovery/meson.build
A src/test/recovery/t/058_shutdown_crash_restart.pl
A src/test/recovery/t/wait_for_shutdown

Rescind unsafe deduplication support.

commit   : a32b8dc9865aa5189d20eca273700b10dfd92fc7    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 6 Oct 2026 18:21:39 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 6 Oct 2026 18:21:39 -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/include/catalog/catversion.h
M src/include/catalog/pg_amproc.dat
M src/test/regress/expected/btree_index.out
M src/test/regress/expected/opr_sanity.out
M src/test/regress/sql/btree_index.sql

Doc: correct overambitious precision claim for contrib/seg.

commit   : 98c41fed6fce927539400bc02974b9cb3184befc    
  
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 deferred XLogLogicalInfo update after a failed transaction block.

commit   : 10b6e2a3d66098bf26b236c880bab5b3fafc42bd    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 6 Oct 2026 10:00:46 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 6 Oct 2026 10:00:46 -0700    

Click here for diff

Previously, a backend with an assigned XID deferred the  
XLogLogicalInfo update requested by a procsignal barrier, and we  
applied it in AbortTransaction() on abort. However, a failed  
transaction block keeps its XID until ROLLBACK, so a barrier absorbed  
while idle in that state was deferred, and CleanupTransaction() did  
not apply it. The next transaction then ran entirely with the stale  
value. If logical decoding had just been enabled, that transaction's  
changes were written without logical information and silently skipped  
by decoding.  
  
Fix by applying the pending update in CleanupTransaction() instead of  
AbortTransaction(). We call it after resetting the top-level XID  
because, unlike the commit and prepare paths, CleanupTransaction()  
isn't always called with interrupts held, so a barrier absorbed before  
the reset would be deferred again and carried into the next  
transaction.  
  
Patch by Sergei Patiakin, with tests added by me.  
  
Oversight in commit 67c20979ce7.  
  
Reported-by: Sergei Patiakin <sergei.patiakin@enterprisedb.com>  
Author: Sergei Patiakin <sergei.patiakin@enterprisedb.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/CANE55rApeNAFaqxLWrvm-NC0Y5gkrBFZFVaHVYP89AGS2SYMcA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/transam/xact.c
M src/backend/replication/logical/logicalctl.c
M src/test/recovery/t/051_effective_wal_level.pl

Fix COPY FROM ... WHERE for negated operators.

commit   : a14041d437ff9e74d3596aea31bd202662e28800    
  
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

Delay creation of SSL_CTX structure to allow cleanup

commit   : b0faa1d2142a088963f8e0d0cf0ce9e5fe268223    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:28:01 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:28:01 +0200    

Click here for diff

Avoid initializing the OpenSSL SSL_CTX structure for a new host  
until it has been checked for errors.  The cleanup can only see  
hosts which were successfully added so the previous coding would  
leak the SSL_CTX on failed reloads.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/A1745424-7110-41E9-B98C-3CED1A034A8F@yesql.se  
Backpatch-through: 19  

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

Copy SSL GUCs into the hosts context

commit   : fd7e11b92b3a5b94abc11228d41b5f83acd92773    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:28:00 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:28:00 +0200    

Click here for diff

When the SSL configuration from postgresql.conf is used, the default  
host entry stored pointers to the relevant GUC variables.  These  
pointers are not guaranteed to survive a failed configuration reload  
so copy the values into the hosts memory context.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/A1745424-7110-41E9-B98C-3CED1A034A8F@yesql.se  
Backpatch-through: 19  

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

Clear SSL_hosts when destroying TLS

commit   : ff684b6be258ab535f77df7b86d8252c1e72a421    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:27:57 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:27:57 +0200    

Click here for diff

The loaded SSL_CTX objects were cleared on SSL initialization but not  
when destroying the TLS objects via be_tls_destroy().  This would not  
leak the contexts, but consume memory for no reason.  
  
Reported-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/CAOYmi+mAtEn4wN3xx=r4TaY5AHy9_q9XncM8YQLhofE3op0SvA@mail.gmail.com  
Backpatch-through: 19  

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

Use safe_psql in SSL test setup to avoid silent failure

commit   : e9aea0189d0f75e5ccd52ccb06e63cc87597dd64    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:27:55 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:27:55 +0200    

Click here for diff

When setting up the cluster for SSL tests, use safe_psql instead of plain  
psql calls to ensure the processing exits on error.  There is no evidence  
of this happening in the buildfarm, it's merely a precaution.  
  
Reported-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/CAOYmi+mAtEn4wN3xx=r4TaY5AHy9_q9XncM8YQLhofE3op0SvA@mail.gmail.com  

M src/test/ssl/t/SSL/Server.pm

Keep current ssl_sni setting on SSL config reload failure

commit   : 72ffdffd1fcc53d6f950c35fbbe1079fbf9f15f4    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:27:52 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 6 Oct 2026 13:27:52 +0200    

Click here for diff

When reloading the SSL configuration fails, the existing config is  
left in place to keep the server from being inaccessible.  The GUC  
backing SNI, ssl_sni, was however changed.  This could lead to new  
connections trying to access non-existing configurations.  Fix by  
storing the ssl_sni setting at the time of initialization in the  
hosts context and only use the stored value during the handshake.  
  
The patch submitted by the reporter has been significantly reworked  
and expanded.  Additional test cases written by Rui Zhao.  
  
Author: Anthropic OSS program  
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>  
Co-authored-by: Rui Zhao <zhaorui126@gmail.com>  
Reported-by: Anthropic OSS program  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/20260920211619.9c.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/libpq/be-secure-openssl.c
M src/test/ssl/t/004_sni.pl
M src/test/ssl/t/SSL/Server.pm

postgres_fdw: Fix typo in server version check in AcquireSampleRowsFunc.

commit   : e8f4f9e3ce2a7a17790972e04631aa999b72abfd    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Tue, 6 Oct 2026 18:30:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Tue, 6 Oct 2026 18:30:00 +0900    

Click here for diff

s/95000/90500/g  
  
Oversight in commit 8ad51b5f4.  
  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Chao Li <lic@highgo.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAPmGK143-FdvSCmKc3bqfAQeGNs_aqVqF3op25TR_NTfBmL4BQ%40mail.gmail.com  
Backpatch-through: 16  

M contrib/postgres_fdw/postgres_fdw.c

Flatten join alias Vars before rechecking subquery pullup safety

commit   : d4c15309e7ed6e30e360b5911e1f4d3ca754aa2b    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 14:40:17 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 14:40:17 +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

Fix three blips with progress reporting data (heap and GIN)

commit   : 3be29d9346db1d3225773e2a8e5a86b875696617    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 6 Oct 2026 13:53:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 6 Oct 2026 13:53:50 +0900    

Click here for diff

This commit addresses three gaps in the error reporting data, as of:  
- In _gin_parallel_merge(), for a parallel GIN build, the last key was  
counted twice in the progress report.  Oversight in 8492feb98f6.  
- _gin_process_worker_data() forgot to increment bs_numtuples when  
trimming a list of pointers.  Oversight in b229c1016477.  
- blocks_done for an index build's heap scan was incorrect for its first  
block.  There was a one-off in heapam_scan_get_blocks_done(), causing  
the routine to return the total number of blocks on the first block  
scanned.  Oversight in ab0dfc961b6.  
  
Manu has reported two issues.  I have come across the one in  
_gin_process_worker_data() while reviewing his patches.  
  
All of these are mostly cosmetic, leading to incorrect data reported in  
the progress views for a short period of time, so no backpatch is done.  
  
Author: Manu <manuelreyesbravo@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/179012373464.1732093.11171496412950256250@gmail.com  

M src/backend/access/gin/gininsert.c
M src/backend/access/heap/heapam_handler.c

Run repack_dropped with make and clean up its extension

commit   : 1703ae595aa52d3218cd0575038847bba421ff1c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 6 Oct 2026 13:16:24 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 6 Oct 2026 13:16:24 +0900    

Click here for diff

Commit e5d25959cf8 added the repack_dropped test to Meson but omitted it  
from the Makefile, so make-based isolation runs did not execute it. The  
test's teardown also left the injection_points extension installed,  
relying on a later test to remove it.  
  
Add repack_dropped to the Makefile's isolation tests and drop the  
extension during teardown.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/CAHGQGwG9bHxhs4Nj+9avSjSGh0vdYNQgEuz+pmJ-H5be6tEBTw@mail.gmail.com  
Backpatch-through: 19  

M src/test/modules/injection_points/Makefile
M src/test/modules/injection_points/specs/repack_dropped.spec

Fix ADD PRIMARY KEY after dropping and re-adding a column

commit   : dd97e0c8e3823690653cd555090e01fafbb33a85    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 6 Oct 2026 13:13:47 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 6 Oct 2026 13:13:47 +0900    

Click here for diff

Previously, dropping a NOT NULL column, adding a new column with the same  
name, and making it a primary key in a single ALTER TABLE command could  
fail with "primary key column ... is not marked NOT NULL". This happened  
because ALTER TABLE checked for an existing NOT NULL constraint before  
dropping the old column. Finding the constraint caused it to skip adding  
one for the new column, even though the old constraint would be removed  
with the old column.  
  
Defer this check until after column drops and additions have been  
executed, so that it examines the columns that will actually form the  
primary key. Add any required NOT NULL constraints before creating the  
primary-key index.  
  
Backpatch to v18, where this issue was introduced by commit a379061a22a.  
  
Reported-by: Ludvig Janiuk <ludvig.janiuk@proton.me>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Co-authored-by: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/0a9b4c44-cdff-4ec8-a8fb-b3a8b59e9ba9@proton.me  
Backpatch-through: 18  

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

Don't reprocess PHV copies within outer aggregates' arguments

commit   : 6b858a36ddb80bfa4f478afebe3e84de72600e02    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 10:56:35 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 10:56:35 +0900    

Click here for diff

Since commit e28cf96e9, the copies of a query level's PlaceHolderVars  
that were pushed down into its subqueries are preprocessed by that  
level before its SubLinks are turned into SubPlans, so such a copy may  
already contain SubPlans by the time the subquery is planned.  That  
commit taught build_subplan not to process the SubLinks of a PHV that  
is passed down as a SubPlan argument, but overlooked that such a copy  
can also appear within the arguments of an outer-level Aggref,  
GroupingFunc, or ReturningExpr.  The SubLinks in those arguments are  
still processed when build_subplan collects the node, and that  
processing descended into the already-preprocessed PHV and tripped the  
no-SubPlan assertion in process_sublinks_mutator.  
  
To fix, don't descend into PHVs when processing the SubLinks in such a  
node's arguments.  Any PHV found there is a pushed-down copy that its  
owning level has already preprocessed.  
  
Back-patch to v16, as with commit e28cf96e9.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com  
Backpatch-through: 16  

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

Fix outdated comment in tablecmds.c

commit   : 80707c10456f3b29202899c62619b4a8d81fe8f9    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 6 Oct 2026 14:26:58 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 6 Oct 2026 14:26:58 +1300    

Click here for diff

Since f80bedd52, these fields are now also used when adjusting the  
expression on a virtual generated column.  
  
Reported-by: jian he <jian.universality@gmail.com>  
Discussion: https://postgr.es/m/CACJufxEvw496SK=nmvxOL0SQYBPhrsnad1DUj6cPs17cvvDSMQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/tablecmds.c

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

commit   : 1a0039d0034d590f8781c88e4d047aa13c2d5c2c    
  
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 possible crash when RI fast-path metadata is invalidated mid-check

commit   : e73e0196d30198e4579656881497f057788bb53d    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Tue, 6 Oct 2026 08:59:48 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Tue, 6 Oct 2026 08:59:48 +0900    

Click here for diff

ri_FastPathCheck() read riinfo->fpmeta again after  
ri_CheckFunctionPermissions(), which looks up catalog entries and so  
can process invalidation messages.  If one of them reaches  
InvalidateConstraintCacheCallBack() for the constraint, as a pg_amop  
change or a cache reset would, the callback detaches the metadata and  
sets riinfo->fpmeta to NULL, which build_index_scankeys() then  
dereferences.  
  
The callback already defers freeing detached metadata until  
AtEOXact_RI(), and its comment assumes callers keep their own pointer  
to it, so use a local pointer instead of riinfo->fpmeta.  
  
There is no test, as hitting this needs an invalidation to arrive  
during those catalog lookups.  
  
Discussion: https://postgr.es/m/CA+HiwqFaipkMsZ8XP-9sMk21h0Q7rih=NpJQXsBAaD39VtnrOA@mail.gmail.com  

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

Fix sorting on extra grouping keys of child relations

commit   : 8b29b8da78ea77c74ce2e6b140dcdde45ccb0268    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 08:50:18 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 08:50:18 +0900    

Click here for diff

A Var that is needed by a join but is not a GROUP BY expression  
becomes an extra grouping key for partial aggregation.  The  
EquivalenceClass for sorting on it is created when the grouped paths  
are generated, which is after the children of appendrels and  
partitionwise joins have received their EC members, so it has no child  
members.  Sort-based partial aggregation on a child relation then  
failed with "could not find pathkey item to sort", as with a  
partitionwise join whose join clause includes a non-equality  
condition.  
  
To fix, add the missing child members when the grouping pathkeys of a  
child relation are built.  This is done by the new function  
add_child_rel_pathkey_equivalences(), which handles both child base  
relations and child joins, including keys that are nullable by an  
outer join within the child join.  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CA+Tgmob7iSM9YkRM44VjUDuaCchW-fY54MV5njpTZTL9uNyV4w@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/path/equivclass.c
M src/include/optimizer/paths.h
M src/test/regress/expected/eager_aggregate.out
M src/test/regress/sql/eager_aggregate.sql

Don't pass grouped relations to FDWs

commit   : 58fca6bdf26f55484c11bf505ae699ec240d60cb    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 08:49:50 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 08:49:50 +0900    

Click here for diff

build_grouped_rel() makes a flat copy of the input relation, including  
its FDW fields.  As a result, when building a grouped join relation  
for eager aggregation, add_paths_to_joinrel() called the FDW's  
GetForeignJoinPaths for it.  postgres_fdw then failed with "Aggref  
found where not expected" on the partial Aggrefs in the target list,  
and in any case it would have treated a partially aggregated input as  
a plain foreign scan.  
  
FDWs are not prepared to handle grouped relations, so clear serverid,  
fdwroutine and fdw_private in build_grouped_rel().  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CA+Tgmob7iSM9YkRM44VjUDuaCchW-fY54MV5njpTZTL9uNyV4w@mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M src/backend/optimizer/util/relnode.c

Fix eager aggregation grouping on cross-type join keys

commit   : d764d61af3160f725ac087ccc05d9ccf03af8312    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 08:49:17 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 6 Oct 2026 08:49:17 +0900    

Click here for diff

When a Var of the relation to be partially aggregated is known equal  
to a GROUP BY expression through an EC, get_expression_sortgroupref()  
let it reuse that expression's SortGroupClause.  If the two are of  
different types, as with an int2 grouping key joined to an int4  
column, the Var was then grouped using the other type's equality  
operator, which could put unequal values into the same group and give  
wrong results.  
  
To fix, accept only EC members of the same type as the grouping  
expression.  A cross-type Var is then treated like any other join key  
and gets a SortGroupClause built for its own type.  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CA+Tgmob7iSM9YkRM44VjUDuaCchW-fY54MV5njpTZTL9uNyV4w@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/util/relnode.c
M src/test/regress/expected/eager_aggregate.out
M src/test/regress/sql/eager_aggregate.sql

Fix parallel autovacuum workers ignoring track_cost_delay_timing changes.

commit   : 92a734bf5c7ace23131b711025c75aacd8144482    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 5 Oct 2026 16:16:32 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 5 Oct 2026 16:16:32 -0700    

Click here for diff

Commit 1ff3180ca01 made the leader of a parallel autovacuum propagate  
changes to the cost-based delay parameters to its workers, but missed  
track_cost_delay_timing. Workers therefore kept the value they had at  
launch: turning the parameter on during the vacuum left  
pg_stat_progress_vacuum.delay_time counting only the leader's naps,  
and turning it off didn't stop workers from adding theirs. Throttling  
itself was not affected.  
  
Fix by adding track_cost_delay_timing to PVSharedCostParams. Since a  
worker's setting can now change while it runs, we report its residual  
delay time at exit whenever any has been accumulated, rather than only  
if track_cost_delay_timing is still on.  
  
Backpatch to v19, where parallel autovacuum was introduced.  
  
Reported-by: Sami Imseih <samimseih.pg@gmail.com>  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAN12+YJZaALd3zMeKVVRTwcuY5_yDtR_vMPwWc8QNgeYxrn4Zg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/vacuumparallel.c
M src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl

Fix "SELECT simple_expression INTO" for expression becoming non-simple.

commit   : e3199f3149e77d42ef799858ba3f8b343db09def    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 18:33:18 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 18:33:18 -0400    

Click here for diff

Commit ce8d5fe0e failed to think hard enough about the case where  
we're forced to replan the expression and it becomes no longer simple.  
The code produced the right expression result, but its handling of  
FOUND and ROW_COUNT was too simplistic since we might have obtained  
zero rows.  To fix, don't use exec_eval_expr, but go directly to  
exec_eval_simple_expr, and if that reports failure then fall through  
to the full SPI code path.  
  
Another thinko in ce8d5fe0e is that it added  
  
                 if (expr->plan == NULL)  
                     exec_prepare_plan(estate, expr, 0);  
  
which is quite useless since we cannot reach here without having  
planned the expression at least once.  (If the call were reachable  
it'd likely be wrong, since it's not passing the same flags as  
either the preceding call or the one inside exec_eval_expr.)  
  
Author: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqQB_aqWU9OeVPGvATBVZ7c9EYrNXJyHG0jKXW0FGAy2-g@mail.gmail.com  
Backpatch-through: 19  

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

Fix pg_blocking_pids() for relation extension locks.

commit   : e7ef2cf256cc135da018899202d7c4ce167e0699    
  
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/func-info.sgml
M src/backend/utils/adt/lockfuncs.c

Handle operator-stack-overflow errors softly in tsquery and ltxtquery.

commit   : fe5a0109770465b59408638dd54ea29af8f19a49    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 15:45:40 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 15:45:40 -0400    

Click here for diff

When we converted these types' input functions to report errors  
through the soft-error mechanism, we missed that stack-overflow  
errors can be triggered through bad user input.  Convert those  
to be reported softly, too.  
  
Bug: #19745  
Reported-by: Ke <kehan5800@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19745-39cd7b93a505f9a9@postgresql.org  
Backpatch-through: 16  

M contrib/ltree/ltxtquery_io.c
M src/backend/utils/adt/tsquery.c

Don't absorb child pathkeys into dummy AppendPaths for set-ops.

commit   : dfcf6fa7749d1fc4660d03590f14dca7c855048c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 12:52:48 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 12:52:48 -0400    

Click here for diff

create_append_path() has a rather questionable habit of overriding  
the caller-supplied pathkeys when it sees that there is a single  
child path, and applying the child's pathkeys instead.  In most cases  
we can get away with that, but it does not work for set-operation  
AppendPaths.  In set-operation nests, the append's result tlist will  
contain "varno 0" Vars, which won't match the child's pathkeys,  
leading to failure in create_plan().  
  
We didn't have this problem before 03d40e4b5 allowed eliding  
provably-empty child nodes of set-ops; there would never have been  
a case with only one surviving child node, so create_append_path()  
would always have accepted the specified NIL pathkeys.  
  
As a band-aid fix, force the generated AppendPath's pathkeys to NIL  
even if create_append_path() did something else, thus restoring the  
status quo ante.  This is demonstrably necessary for two of  
prepunion.c's three calls; I did it at the third too, although  
probably the pathkeys would already be NIL there.  
  
There have been reasons to want to get rid of the "varno 0" hack  
for a long time, and this is another one.  But that will require  
significant surgery in prepunion.c, and likely some changes in  
parsetree representation, so we can't tackle it for v19.  Hence,  
we need a band-aid.  
  
Bug: #19742  
Reported-by: Junwen AN <feasiblechart@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Co-authored-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/19742-dc403ca277cad1d3@postgresql.org  
Backpatch-through: 19  

M src/backend/optimizer/prep/prepunion.c
M src/test/regress/expected/union.out
M src/test/regress/sql/union.sql

Fix EXPLAIN of dummy set operations some more.

commit   : 90893c7b7cf355b87f403a8a56293abe33ad7848    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 11:47:57 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 5 Oct 2026 11:47:57 -0400    

Click here for diff

EXPLAIN failed to deal with varno-0 Vars that are made by prepunion.c  
and can survive into a finished plan in the case where a provably  
empty set operation is replaced by a dummy Result (which is possible  
since 03d40e4b5).  Commit 928df067d tried to fix this, but it was a  
couple bricks shy of a load.  First, it only dealt with varno-0 Vars  
at the top level of the Result's tlist, but they could be buried  
under coercion expressions.  Fix that by doing a recursive mutation.  
Second, it always replaced varno 0 with varno 1, but that's just  
wrong: the Result might represent a group of setop leaf queries that  
do not include the leftmost leaf.  That led to displaying the wrong  
variable(s) as outputs of the Result, risking confusion.  Fortunately,  
we can get the actual child relids from the recently-added  
Result.relids field, and use that to discover the leftmost child  
represented by the Result.  
  
This was found while discussing bug #19742, but it's really an  
independent issue.  
  
Author: shihao zhong <zhong950419@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAGRkXqTFwygKmjLG_Y=kbXRHsePFmD6k+qrzVLP4_KrG+-=oRg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/plan/setrefs.c
M src/test/regress/expected/union.out
M src/test/regress/sql/union.sql

Fix tuplesort memory accounting for datum sorts on byref types

commit   : 85adc584e2bd3ee6ce1899929fc60afb709b4772    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 6 Oct 2026 01:20:57 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 6 Oct 2026 01:20:57 +1300    

Click here for diff

6ed83d5fa made it so tuplesorts could use a bump.c memory allocator for  
non-bounded sorts in order to save memory and increase performance.  
That commit didn't get the memory accounting correct for datum sorts and  
mistakenly passed 0 bytes to tuplesort_puttuple_common().  That was  
correct for byval types, but failed to take into account palloc'd memory  
for byref types.  
  
Fix by using datumGetSize() when using the bump allocator and by using  
GetMemoryChunkSpace() when not.  
  
Backpatch to v17, where 6ed83d5fa was added.  
  
Author: Mario Karuza <mkaruza.pg@icloud.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Joao Detomini <joao.detomini@enterprisedb.com>  
Discussion: https://postgr.es/m/e9f9f54337cd86a982837763958518cdbf08863c.camel%40icloud.com  
Backpatch-through: 17  

M src/backend/utils/sort/tuplesortvariants.c

pgindent: Skip build directories automatically

commit   : 9dbc53591a2de03e0cfdab61a78726f8b2c29eef    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 5 Oct 2026 13:17:43 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 5 Oct 2026 13:17:43 +0200    

Click here for diff

pgindent descended into build directories located inside the source  
tree and reindented the generated files there, which is wasteful and  
often makes pg_bsd_indent fail outright.  This change automatically  
recognizes build directories and skips them.  This works for both  
Meson build directories and Autoconf VPATH build directories.  A build  
directory named directly on the command line is still processed, on  
the assumption that this was asked for on purpose.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/fc77b35a-34c4-4229-82f1-8cf0ce67f276%40eisentraut.org  

M src/tools/pgindent/pgindent
M src/tools/pgindent/pgindent.man

commit   : a846ee9854ee9994935d697e1f9c2a0d70f328f1    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 5 Oct 2026 13:32:00 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 5 Oct 2026 13:32:00 +0300    

Click here for diff

bt_child_highkey_check() walks right along the child level following  
btpo_next links, reading a page on each iteration, but its loop lacked a  
CHECK_FOR_INTERRUPTS().  Every other page-traversal loop in  
verify_nbtree.c already has one.  
  
The loop's existing checks do not guarantee a timely exit on a corrupt  
index.  The in-loop cycle check only fires when a rightlink points back  
through the block the walk started from, or to a page whose btpo_prev  
points to itself, so a cycle further downstream can go undetected -- for  
example a run of pages all flagged P_INCOMPLETE_SPLIT, which skips both  
the high-key comparison and bt_downlink_missing_check() and so never  
reaches an error.  Such an index, or simply a very long rightlink chain,  
makes the walk effectively uninterruptible.  Since amcheck exists to be  
run against possibly-corrupt indexes, make this walk respond to query  
cancellation and shutdown requests like the sibling loops do.  
  
Author: Paul Kim <mok03127@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Discussion: https://www.postgresql.org/message-id/20260717151437.10713-1-mok03127@gmail.com  

M contrib/amcheck/verify_nbtree.c

Don't sleep with vacuum_delay_point() while holding locks

commit   : 96c99955b62994b2cb47380d84f463456cf16ee5    
  
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/analyze.c
M src/backend/commands/vacuum.c
M src/backend/utils/activity/pgstat.c

postgres_fdw: Fix corner cases in transaction mode propagation.

commit   : d6393fc40a59830a88a79bdf08e962122fa9c631    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Mon, 5 Oct 2026 16:15:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Mon, 5 Oct 2026 16:15:00 +0900    

Click here for diff

This commit addresses the following issues in commit de28140de:  
  
* When the local transaction was DEFERRABLE, begin_remote_xact() started  
  a remote transaction in the same mode without checking the remote  
  server version.  Since DEFERRABLE is supported only in v9.1 and later,  
  this would cause a syntax error on older remote servers.  Fix this by  
  propagating the mode only to remote servers that support it.  
* pgfdw_xact_callback() committed remote transactions without  
  synchronizing the read-only mode.  If the local transaction had become  
  READ ONLY since the last remote operation, this would cause deferred  
  triggers on remote servers to still run in READ WRITE mode.  Fix this  
  by synchronizing the mode at commit time.  
* The documentation did not match the actual implementation.  Update the  
  documentation to reflect the implementation.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwE4UMaWGOZq1Z7YUTUSg-CgL4yAzO5YaGwTZe1-6Pjg2g%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/postgres-fdw.sgml

Fix relids of EC-derived join clauses for lateral UNION ALL members

commit   : a464d31ff6213fe47505c750972b404e4517ebd9    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 5 Oct 2026 15:01:48 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 5 Oct 2026 15:01:48 +0900    

Click here for diff

When a LATERAL UNION ALL subquery is flattened into an appendrel, a  
child EquivalenceMember's expression can contain lateral references to  
other relations.  create_join_clause() builds a clause from such a  
member with make_restrictinfo(), which computes clause_relids from the  
expression, and so includes the relids of the lateral references along  
with those of any outer joins that null them.  Commit 03107b4ed made  
sure that clause_relids include the child's relids, but it only ever  
added relids.  
  
This is a problem when a lateral reference is nullable.  The child is  
parameterized by its lateral_relids, which do not include the outer  
joins that null the lateral references, so the clause fails the  
join_clause_is_movable_into() assertion that  
get_baserel_parampathinfo() applies to EC-derived clauses.  
  
To fix, set a child clause's clause_relids from its members' em_relids  
rather than from their expressions.  This matches how  
adjust_appendrel_attrs() computes clause_relids for a child's other  
join clauses.  The lateral references need not be included, since  
every path for the child is parameterized by at least its  
lateral_relids.  Also update num_base_rels to match, which commit  
03107b4ed neglected to do.  
  
Back-patch to v16, where outer-join relids were added to  
clause_relids.  Before that, the relids of a lateral reference are  
always part of the child's parameterization, so the problem does not  
arise.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4-cRxpQNyQJW=PkDagSDGQ=3Rp2t_fSAyROKsDStjKHUQ@mail.gmail.com  
Backpatch-through: 16  

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

Don't take the address of flexible array members

commit   : 675dd940bc459f3e1748ffcd82c48f24c29b2a80    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 5 Oct 2026 07:41:28 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 5 Oct 2026 07:41:28 +0200    

Click here for diff

Apple clang rejects taking the address of a flexible array member that  
carries a counted_by attribute.  A future patch wants to add that  
attribute to two such places.  To avoid problems, use the array itself  
instead taking its address with &, which yields the same  
address.  (There are a few more, but they are not candidates for a  
counted_by attribute, so they are left alone here.)  
  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/backend/executor/execParallel.c
M src/bin/pg_rewind/filemap.c

Disable autovacuum in 031_recovery_conflict.pl

commit   : 9f07de2053163cda9acb68c34d8be4b56f9659d4    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 5 Oct 2026 13:02:44 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 5 Oct 2026 13:02:44 +0900    

Click here for diff

Buildfarm members adder and drongo failed to observe the expected relation  
lock wait in the startup deadlock test. In adder's failure, autovacuum  
pruned dead rows before the test's explicit VACUUM FREEZE, canceling the  
standby backend too early and releasing the relation lock wait before the  
test could observe it.  
  
Fix this by disabling autovacuum for the test node, leaving the explicit  
VACUUM commands in control of when pruning occurs. This also prevents  
auto-analyze workers on other relations from holding back xmin and  
interfering with the snapshot conflict test.  
  
Backpatch to v17, where this test is enabled.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/421c0aee-84c8-4c07-b4b9-263095479755%40gmail.com  
Discussion: https://postgr.es/m/714729ea-f536-0faf-353b-cbd5c8f241ea%40gmail.com  
Backpatch-through: 17  

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

Stabilize recovery conflict count checks in 031_recovery_conflict.pl

commit   : de34b14fcb0168395ca7f1990038f1db06fe1697    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 5 Oct 2026 13:01:22 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 5 Oct 2026 13:01:22 +0900    

Click here for diff

Buildfarm members olingo and adder reported failures in  
031_recovery_conflict.pl where a recovery conflict was counted twice.  
olingo saw the snapshot conflict count reach 2 instead of 1, while adder  
saw the same for the buffer pin conflict count.  
  
The startup process can signal a standby backend again while it is  
reporting a recovery-conflict FATAL error. Each processed conflict can  
increment the corresponding statistic. Thus, even when the expected  
conflict occurs, its counter can exceed 1. The existing poll for exactly 1  
can then time out, and the exact check of the aggregate count can fail as  
well.  
  
Fix this by polling for a positive count for each conflict type and  
accepting an aggregate count of at least the expected number.  
  
Backpatch to v17, where this test was enabled.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/421c0aee-84c8-4c07-b4b9-263095479755%40gmail.com  
Backpatch-through: 17  

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

Reject CR and LF characters in backup labels

commit   : e624e1fd13dcc754deebfd8a5be8f6fa578e17da    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 5 Oct 2026 12:46:19 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 5 Oct 2026 12:46:19 +0900    

Click here for diff

The label is written as one line of the backup_label file.  A label  
with a newline added extra lines to the file, and recovery could read  
those as other fields, failing on them.  Characters could also be  
injected to make recovery behave in inconsistent ways.  
  
Trying to use such characters in label names is now rejected, for both  
pg_backup_start() and BASE_BACKUP.  
  
As this is arguably a behavior change, no backpatch is done.  I also  
seriously doubt that anybody is relying on the behavior of pushing some  
arbitrary data to backup_label files, and even if they do, it would be a  
very bad idea to contradict what the backend decides to generate.  
  
Reported-by: Shallow <theshallow27@gmail.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/19730-85a6044c9e72774a@postgresql.org  

M src/backend/access/transam/xlog.c
M src/test/recovery/t/020_archive_status.pl

Use tuplestore_clear instead of tuplestore_end in nodeTableFuncscan.c

commit   : a7f8cd811d65d1a51be87bdb890d7ebf7d49aa45    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 5 Oct 2026 15:58:13 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 5 Oct 2026 15:58:13 +1300    

Click here for diff

Clearing the tuplestore rather than ending it avoids the need for  
various memory allocations, so is slightly more efficient.  However, the  
main reason to do this is to correctly track the maximum storage used by  
the Table Function Scan node.  40708acd65 added additional EXPLAIN  
output for Table Function Scan nodes and that output does claim to be  
showing "Maximum Storage", which is not true, as the maximums could be  
lost after tuplestore_end() is called during a rescan.  
  
This causes misreporting when the final rescan of a Table Function Scan  
node uses less storage than some previous rescan.  One example is:  
  
EXPLAIN ANALYZE  
SELECT count(*)  
FROM (VALUES ((SELECT jsonb_agg(g) FROM generate_series(1, 100000) g)),  
             ('[1]'::jsonb)) v(j),  
     LATERAL JSON_TABLE(v.j, '$[*]' COLUMNS (x int PATH '$')) jt;  
  
Without this fix, the reported Table Function Scan storage is for the  
'[1]'::jsonb case, whereas it should consider how much was used with the  
larger document and show the maximum of all rescans.  
  
TableFuncNext() used a NULL tupstore to tell that the rows still had to  
be fetched, so add a tupstore_filled flag for that, similar to what  
908a96861 did for WindowAgg.  
  
Technically, this issue does exist in v18, but no backpatch as this is a  
fairly minor issue which was only noticed during a review of a similar  
feature being proposed for Function Scans.  
  
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAHza6qdXjcqXv2aGU7OCakG0OmEsy9-jfP0Gpe2EL+k-AidOhw@mail.gmail.com  

M src/backend/executor/nodeTableFuncscan.c
M src/include/nodes/execnodes.h

Skip isolation tests that terminate other backends on Windows

commit   : e0f633ca6bc6a2ace3e6c0e79157c3bf0edddfbe    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 5 Oct 2026 11:11:08 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 5 Oct 2026 11:11:08 +0900    

Click here for diff

On Windows, a backend exiting resets its connection, and the client  
discards any data not yet read, including the FATAL message of a  
terminated backend.  isolationtester polls one connection at a time, so  
when it waits on a different session the message can get lost, failing  
the permutation and the tests that run after it.  
  
wait_cleanup in injection_points (down to v17) and slot_creation_error  
in test_decoding (down to v15) have this pattern, and have been failing  
randomly in the buildfarm.  Let's skip them on Windows.  
  
The cause of the instabilities is proving to be tricky to deal with,  
pointing for example at 29992a6a509b.  This will be tackled later,  
perhaps with a backpatch (or perhaps with a HEAD-only solution), but it  
is difficult to be sure at this stage of the work.  In theory,  
a8458f508a7 should make a revert of 29992a6a509b (revert of a revert!)  
safe on WIN32.  
  
Note that 278cdea6b9d2, that has introduced the isolation test  
slot_creation_error in test_decoding, has mentioned the potential output  
instability.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAN4CZFOoiKa9E4Gnh_OzLk3S5Z6RFyg_oY1e_WddCVYhkpTVow@mail.gmail.com  
Backpatch-through: 15  

M contrib/test_decoding/Makefile
M contrib/test_decoding/meson.build
M src/test/modules/injection_points/Makefile
M src/test/modules/injection_points/meson.build

Use tuplestore_clear instead of tuplestore_end in nodeMaterial.c

commit   : 03985e1e52672c70297b38a3c658fefb6faa57cf    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 5 Oct 2026 13:42:13 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 5 Oct 2026 13:42:13 +1300    

Click here for diff

Clearing the tuplestore rather than ending it avoids the need for  
various memory allocations, so is slightly more efficient.  However, the  
main reason to do this is to correctly track the maximum storage used by  
the Material node.  1eff8279d added additional EXPLAIN output for Material  
nodes and that output does claim to be showing "Maximum Storage", which is  
not true, as the maximums could be lost after tuplestore_end() is called  
during a rescan.  
  
This causes misreporting when the final rescan of a Material node uses  
less storage than some previous rescan.  One example is:  
  
EXPLAIN ANALYZE  
SELECT count(*) FROM (VALUES(10000),(1)) v1(r1)  
LEFT JOIN LATERAL (  
	SELECT * FROM generate_series(1, 2) gs0  
	LEFT JOIN LATERAL (  
		SELECT * FROM generate_series(1, v1.r1) gs1  
		FULL JOIN generate_series(1, v1.r1) gs4 ON false  
	) ss on true  
) q on true;  
  
Without this fix, the reported Material storage is for the v1.r1 = 1 case,  
whereas it should consider how much was used with the v1.r1 = 10000 case  
and show the maximum of each.  
  
Technically this issue does exist in v18, but no backpatch here as  
parameterized Material nodes are not that common and there have been no  
bug reports about the incorrect memory reporting, so it's probably not  
worth risking backpatching the change.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvoa55vcRth05Ozu5be4FawgTH-aCsZ5=Z+_UXTUzUxdQg@mail.gmail.com  

M src/backend/executor/nodeMaterial.c

Silence -fsanitize=function where we cast function pointers on purpose

commit   : 3ff475ac12ec8d8d07cf3fd86144659285a59d83    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 4 Oct 2026 16:05:54 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 4 Oct 2026 16:05:54 +0200    

Click here for diff

In clang, -fsanitize=undefined includes -fsanitize=function, which  
reports every call made through a function pointer whose type does not  
exactly match the called function, so it fires all over the place on  
expression tree walkers and mutators, as well as a few other places.  
So -fsanitize=undefined hasn't been working cleanly under clang for a  
while.  (Before clang 17, it only applied to C++.)  
  
This is the same issue that caused us to use  
-Wno-cast-function-type-strict with clang.  That warning applies at  
the place where the mismatching function pointer is passed, so there  
are potentially hundreds of sites.  Therefore, a global disabling is  
appropriate.  The sanitizer, on the other hand, triggers where the  
function is called, which are only about two dozen places, so it seems  
possible to silence these checks individually and still main the check  
for accidental violations elsewhere.  
  
Add pg_attribute_no_sanitize_function() and place it on the functions  
that make such calls.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/2db401d9-ef16-430e-a42c-34477006a49f%40eisentraut.org  

M contrib/pgcrypto/pgcrypto.c
M src/backend/access/heap/heapam.c
M src/backend/nodes/nodeFuncs.c
M src/backend/parser/analyze.c
M src/backend/utils/hash/dynahash.c
M src/backend/utils/mmgr/mcxt.c
M src/include/c.h
M src/include/executor/execScan.h
M src/include/lib/sort_template.h
M src/pl/plpgsql/src/pl_funcs.c

Fix join alias expansion in lateral TABLESAMPLE clauses

commit   : 852fd5b86e1a2ac1139c716eb4c96c09c03a632e    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sun, 4 Oct 2026 16:04:16 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sun, 4 Oct 2026 16:04:16 +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   : bfa1a69edd768078bc24d3930e069002167e7c9c    
  
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

Map pg_attribute_counted_by() to _Field_size_() under MSVC

commit   : 9dcaea6edc8c3f8a658ff788c94b6a896ae254af    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 3 Oct 2026 23:14:33 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 3 Oct 2026 23:14:33 +0200    

Click here for diff

MSVC has no counted_by attribute, but its source annotation  
language (SAL) has _Field_size_(), which states the same property: the  
field is a buffer whose writable size in elements is given by the  
named expression.  
  
MSVC's static analyzer (/analyze) will make use of the information.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/include/c.h

Fix lcov duplicate directory specification in non-VPATH builds.

commit   : 19ef4c8411556687180b7cfbff636be26fc715b5    
  
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

Clear out values from dropped columns during REPACK (CONCURRENTLY)

commit   : e5d25959cf8761c7dbdd7cfbb91338e94a40e8e2    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sat, 3 Oct 2026 13:04:41 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sat, 3 Oct 2026 13:04:41 +0200    

Click here for diff

When repacking a table concurrently, some border conditions can cause  
a concurrent update to propagate the original old tuple to the transient  
table (such as a trigger that returns OLD).  That's essentially just  
wasted space, which REPACK is there to remove.  Prevent that by setting  
the isnull flag to true for any column cataloged as dropped in tuples  
being "replayed" as concurrent updates.  
  
Reported-by: Radim Marek <radim@boringsql.com>  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Backpatch: 19  
Discussion: https://postgr.es/m/CAJgoLkK2UBzB1J9buCsSUbjf7bOqz-o_0=CeiTruU789BhBw-Q@mail.gmail.com  

M src/backend/commands/repack.c
A src/test/modules/injection_points/expected/repack_dropped.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/repack_dropped.spec

Remove batching from RI fast-path checks

commit   : 425daf545d9146e008220ae0b21415982220cd3f    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Sat, 3 Oct 2026 11:41:12 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Sat, 3 Oct 2026 11:41:12 +0900    

Click here for diff

This removes the buffering of FK rows for batched PK index probes,  
along with the after-trigger callback infrastructure used only by  
batching.  The per-row fast path, which probes the PK index directly  
instead of going through SPI, remains.  This is a cherry-pick of  
commit 25649d6e791c2, which made the same change in REL_19_STABLE,  
adjusted for some drift between the branches.  
  
I (amitlan) initially thought we could keep improving the batching  
path on master by fixing its remaining bugs and other issues as  
they were found.  However, we are still finding cases where delaying  
checks to accumulate a batch changes their results, such as when other  
AFTER ROW triggers modify the referenced table.  Individual cases can  
be addressed, but new ones keep turning up, which makes it hard to be  
confident that fixing the known ones will be enough.  It seems better  
to rip batching out and reconsider how to introduce it, or at least  
its useful pieces, while preserving the semantics of per-row checks.  
  
Discussion: https://postgr.es/m/CA+HiwqFx4cjFtC3akr1DW-cPYw+B-EkCSffZPrkpTef8PNS6qA@mail.gmail.com  

M src/backend/access/transam/xact.c
M src/backend/commands/trigger.c
M src/backend/utils/adt/ri_triggers.c
M src/include/commands/trigger.h
M src/test/isolation/isolation_schedule
M src/test/modules/injection_points/specs/ri_fastpath_reindex.spec
M src/test/regress/expected/foreign_key.out
M src/test/regress/expected/triggers.out
M src/test/regress/sql/foreign_key.sql
M src/test/regress/sql/triggers.sql
M src/tools/pgindent/typedefs.list

Write pg_attribute_counted_by() in front of the type

commit   : 6f3bdadaadc4692050ca20dff53d3890088b9272    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 2 Oct 2026 13:00:31 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 2 Oct 2026 13:00:31 +0200    

Click here for diff

This is technically the more correct position according to C23,  
although in practice compilers are relaxed about this.  It also opens  
us up to supporting MSVC's _Field_size_() in the future, which is a  
similar construct.  
  
This requires adding pg_attribute_counted_by to the list of  
declaration attributes in pgindent, so that pgindent doesn't mess it  
up.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/backend/utils/adt/jsonfuncs.c
M src/tools/pgindent/pgindent

Use the relation map's index when searching deleted tuples sequentially.

commit   : 5a5e3b88dead9cbea2352283addd927a32dc4d4b    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 2 Oct 2026 06:22:07 -0400    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 2 Oct 2026 06:22:07 -0400    

Click here for diff

When the index cannot be used to find a recently deleted row,  
RelationFindDeletedTupleInfoSeq() scans the table. It looked up the  
relation's replica identity or primary key again to determine which  
columns to compare, which could differ from the index selected when the  
relation was opened. A concurrent DROP INDEX CONCURRENTLY could remove the  
replica identity in between, so the search compared the whole row and  
reported the conflict as update_deleted instead of update_missing.  
  
Use the index recorded in the relation map instead. The relation map  
already records the replica identity index, or the primary key if there is  
no replica identity. It also avoids using a deferrable primary key, which  
cannot serve as a replica identity; using its columns could incorrectly  
report a deleted row with different values as update_deleted instead of  
update_missing.  
  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Author: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Zhijie Hou <houzhijie22@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CABdArM5ydwdRrpaZyK1q2p3-vY_+pnBtTmkvg_pcM=gHwmH7Kg@mail.gmail.com  
Discussion: https://postgr.es/m/OS7PR01MB1831779ED93F5470CA1D57605F58C2@OS7PR01MB18317.jpnprd01.prod.outlook.com  
Backpatch-through: 19  

M src/backend/executor/execReplication.c
M src/backend/replication/logical/worker.c
M src/include/executor/executor.h
M src/test/subscription/t/035_conflicts.pl

pgindent: Generalize the alignas() workaround to a list

commit   : 38a6b8c7adb1333d836315293b869a45ab3ace10    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 2 Oct 2026 10:04:08 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 2 Oct 2026 10:04:08 +0200    

Click here for diff

alignas() may not be the only syntax that needs to be worked around, so  
make the change more generic.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/tools/pgindent/pgindent

pgindent: Keep the alignas() placeholder the same width

commit   : 305cbed95d197dfa2ea946678c0abd26113654eb    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 2 Oct 2026 07:36:55 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 2 Oct 2026 07:36:55 +0200    

Click here for diff

pre_indent() hides each alignas(...) call from pg_bsd_indent behind  
a plain identifier, because pg_bsd_indent has a fixed table of  
declaration keywords and lexes anything else followed by "(" as the  
start of an expression.  
  
The placeholder was not the same width as the text it stood in for,  
though, and pg_bsd_indent decides where to put a trailing comment from  
the width of the code preceding it. A member declared with alignas()  
and carrying a trailing comment therefore got the comment separated by  
a tab where the real width calls for a single space, or the other way  
round. Pad the placeholder out to the original width so that the  
decision is made on the real width.  
  
No member currently declared with alignas() has a trailing comment, so  
this changes nothing in the tree today; it is a correctness fix for the  
helper.  
  
Author: Tristan Partin <tristan@partin.io>  
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/tools/pgindent/pgindent

pg_dump: Include column statistics for index-backed constraints

commit   : 80931d131a95ddcddc7b671d4fee7aceeb12a314    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 17:02:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 17:02:21 +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   : 50d6e533e4d9a0f70d798c534254007c83c0d428    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 10:43:17 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 10:43:17 +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

Report per-index vacuum progress in pg_stat_progress_vacuum

commit   : 1378aa13430e264a990a18597e9d8fdae740927e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 07:29:22 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 2 Oct 2026 07:29:22 +0900    

Click here for diff

pg_stat_progress_vacuum gains three fields, reflecting some activity  
related to index cleanups during VACUUM, which is a phase that could  
take a long time depending on the quantity of data to treat and the  
number of indexes:  
- current_index_relid, the index being processed.  
- index_blks_total, total number of blocks to process.  
- index_blks_done, number of blocks already processed.  
  
There fields are new, and do not reuse the existing fields related to  
heap as index cleanups may need multiple passes, where knowing both the  
heap activity and the index activity could be relevant.  This is  
unlikely since tids are accumulated in the heap scanning phase using an  
optimized radix tree, still possible.  VACUUM can spawn parallel workers  
to clean indexes (each worker cleans a different index); these should up  
in the progress view in the shape of one extra row for each worker.  
  
Bump catalog version.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACUgwSchK6jQ2CdKLBWUADTOE_zKdTff2Zg3E6hOuXKv-w@mail.gmail.com  

M doc/src/sgml/monitoring.sgml
M src/backend/access/heap/vacuumlazy.c
M src/backend/catalog/system_views.sql
M src/backend/commands/vacuumparallel.c
M src/include/catalog/catversion.h
M src/include/commands/progress.h
M src/test/regress/expected/rules.out

Refresh autovacuum costs while waiting for parallel workers.

commit   : 42e96cf2fe095c822f76bc94669ea875cb1e3351    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 1 Oct 2026 06:19:23 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 1 Oct 2026 06:19:23 -0700    

Click here for diff

Commit 1ff3180ca01 made a parallel autovacuum leader propagate changes  
to the cost-based delay parameters to its workers only from  
vacuum_delay_point(), which it no longer reaches once it is waiting in  
WaitForParallelWorkersToFinish(). While waiting, the leader neither  
processed a config reload nor noticed a change in the number of  
autovacuum workers sharing the cost limit, so its workers kept running  
with stale parameters until they finished.  
  
Fix by refreshing and propagating the parameters on every wakeup of  
that wait loop, and by setting the latches of the balanced autovacuum  
workers when their count changes so that a waiting leader wakes up.  
  
A regression test will be added in a separate commit.  
  
Backpatch to v19, where parallel autovacuum was introduced.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Manu <manuelreyesbravo@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAM527d-GL=Jp2EJXBSnVBGPK-4XEZwWof5Cv8P0hghS_og6oAg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/transam/parallel.c
M src/backend/commands/vacuumparallel.c
M src/backend/postmaster/autovacuum.c
M src/include/commands/vacuum.h

Stabilize repack_decode isolation test.

commit   : adffcab923e1cd3d2a0fd0b21eb4a91f080065a3    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 1 Oct 2026 05:52:15 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 1 Oct 2026 05:52:15 -0700    

Click here for diff

Commit 7164dcb66532 added the repack_decode isolation test, whose  
s1_decode step counts every change decoded from the slot. A concurrent  
autovacuum transaction that modifies only system catalogs is decoded  
as an empty BEGIN/COMMIT pair, so the count could come out larger  
than expected.  
  
Fix by passing skip-empty-xacts to test_decoding. We pass it, along  
with include-xids=0, to s1_decode_updates as well so that both steps  
use the same options for consistency, though that step shows only  
UPDATE lines and wasn't affected.  
  
Per buildfarm animal skink.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://postgr.es/m/d704cde4-b1f2-48dc-8c5e-659d1128d286@gmail.com  
Backpatch-through: 19  

M src/test/modules/injection_points/expected/repack_decode.out
M src/test/modules/injection_points/specs/repack_decode.spec

Doc: mention platform-dependent behavior of bitshift operators

commit   : 45277ca0d1cb6dbe722a01b3b5461c30abd40eee    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 1 Oct 2026 15:15:58 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 1 Oct 2026 15:15:58 +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/func-math.sgml

Update time zone data files to tzdata release 2026e.

commit   : a36e2f7cd21c36f6e8960e3b622526eaa7055bb9    
  
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 incorrect parallel build of jsonapi.o with Makefiles.

commit   : ee089509690eabf3ae1603896652190d3ff41f41    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 30 Sep 2026 15:58:33 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 30 Sep 2026 15:58:33 -0400    

Click here for diff

Commit 0785d1b8b wrote  
  
jsonapi_shlib.o: override CPPFLAGS += -DJSONAPI_USE_PQEXPBUFFER  
  
forgetting that GNU make treats this change to CPPFLAGS as affecting  
not only jsonapi_shlib.o, but anything that gets built in pursuit of  
building jsonapi_shlib.o.  Because of an even more ancient hack  
(cf 7143b3e82), that will include jsonapi.o if it's not been built  
already.  If we do apply this -D switch to jsonapi.o, it gets built  
with the wrong expansible-string infrastructure, which manifests  
immediately as a link failure in pg_combinebackup and would misbehave  
at runtime even if the build somehow completed.  
  
Perhaps remarkably, we'd not seen field reports of build failures  
till now, but it's pretty easy to reproduce a mis-build by trying  
to build src/common/ with --shuffle and a high -j factor.  
  
To fix, don't modify CPPFLAGS this way; instead make a dedicated  
build rule for jsonapi_shlib.o that injects the additional switches.  
  
There might be other places with similar problems, but some desultory  
attempts with -j32 --shuffle on a 32-thread CPU didn't find any more  
build failures.  Also, it looks like the meson build infrastructure  
lacks this problem (but I'm no meson expert).  
  
Bug: #19727  
Reported-by: Ross Burton <ross@burtonini.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ross Burton <ross@burtonini.com>  
Discussion: https://postgr.es/m/19727-32d67d9dea410f38@postgresql.org  
Backpatch-through: 18  

M src/common/Makefile

commit   : b69356cd789fe963447177a0077c12c6c322c203    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 30 Sep 2026 15:36:33 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 30 Sep 2026 15:36:33 +0300    

Click here for diff

The explanation of aggressive scans claimed that if the multixact  
members grows to 2 billion entries, we launch autovacuum even if it's  
nominally disabled.  That's no longer true; anti-wraparound vacuum is  
only triggered if we're in danger of running out of multixids, we no  
longer launch it just to shrink the 'members' SLRU.  There's no  
wraparound danger with 'members' anymore, so it's no worse than if a  
user table becomes very bloated.  
  
We do still adjust the freeze threshold though, so that if autovacuum  
runs, whether on schedule or as an emergency autovacuum to avoid  
wraparound, it will freeze more aggressively if the members SLRU is  
large.  
  
I removed the mention of the 4 billion member threshold, even though  
that still exists, because the explanation felt misleading.  The  
aggressiveness is scaled proportionally between 2 and 4 billion  
members.  At 4 billion it's as aggressive as it gets, but there's no  
sudden cliff.  
  
In the passing, fix some comments.  Remove obsolete mention of safe  
threshold for member storage triggering autovacuum.  Secondly, the  
freezing cutoff is adjusted to avoid the *members* SLRU from growing  
too large.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://www.postgresql.org/message-id/20260827231757.78.noahmisch@microsoft.com  
Backpatch-through: 19  

M doc/src/sgml/maintenance.sgml
M src/backend/access/transam/multixact.c

Allow unknown-size shmem attachments in single-user mode

commit   : c712b0d49b971fe7cf521c057bc7adb63b17760c    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 30 Sep 2026 14:25:17 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 30 Sep 2026 14:25:17 +0300    

Click here for diff

ShmemRequestInternal() rejected SHMEM_ATTACH_UNKNOWN_SIZE whenever  
IsUnderPostmaster was false.  That also rejected an after-startup  
attachment in a standalone backend, even if the area exists.  
  
To fix, check whether the shared memory has been initialized  
(ShmemIndex == NULL) rather than IsUnderPostmaster.  
  
Refactor the tests, and add more test cases for after-startup  
attachment, with SHMEM_ATTACH_UNKNOWN_SIZE and a mismatching size, and  
for this single-user case.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discusssion: https://www.postgresql.org/message-id/CAJTYsWXREGXCnWdZJsXt8pT2UY_Y2GSx+HOUu2X3s8YDCLj0_A@mail.gmail.com  
Backpatch-through: 19  

M src/backend/storage/ipc/shmem.c
M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl
M src/test/modules/test_shmem/test_shmem–1.0.sql
M src/test/modules/test_shmem/test_shmem.c

Fix clobbering of proc entry's statusFlags during slot invalidation

commit   : 9510a826e4add77280e0a7a65f429563a4c4a2a8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 30 Sep 2026 14:35:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 30 Sep 2026 14:35:14 +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

Prevent self-join elimination when RTEs' checkAsUser fields differ.

commit   : dca6a9e320e0272f0ea8d7e076cda04b06050866    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 29 Sep 2026 11:11:15 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 29 Sep 2026 11:11:15 -0400    

Click here for diff

SJE didn't consider the possibility that two RTEs referencing the  
same table have different securityQuals, and might choose to merge  
them anyway, thereby possibly losing quals that need to be enforced.  
This is a regression introduced by 2ebf25e7d, since before that we  
didn't re-generate baserestrictinfo lists from the RTEs' securityQuals  
after performing SJE.  
  
To defend against this, only consider SJE between RTEs with the same  
checkAsUser values.  That solves the problem because the set of  
applicable RLS policies depends only on the role that is considered  
to be accessing the table, so that the securityQuals must be equal  
if the checkAsUser values are.  It might also keep us from creating  
similar bugs if we ever invent other features that depend on the  
accessing role.  And it's a lot cheaper than comparing securityQuals  
trees themselves would be, not least because we can't sort them so  
the preliminary sort step wouldn't help.  
  
(The first proposed solution was to not perform SJE at all on RTEs  
with nonempty securityQuals, but that seems rather sad, especially  
since such cases worked before 2ebf25e7d.  Making the restriction  
depend on checkAsUser seems much less likely to interfere with SJE  
unnecessarily, since in most cases that'll be the same for all  
potentially-mergeable RTEs.)  
  
The added test cases show that SJE is rejected when necessary, and  
also demonstrate two quirks of this implementation.  One is that if  
a removed security qual includes an InitPlan, we'll still attach the  
now-unused InitPlan to the plan.  That's because SS_process_sublinks  
runs before self-join elimination, so the extra InitPlan has already  
been made.  The other quirk is that we won't merge RTEs having zero  
and nonzero checkAsUser fields, even if the calling user matches the  
nonzero checkAsUser value so that there is no difference for this  
user.  That's intentional so that SJE doesn't require having to mark  
the plan as caller-dependent.  
  
Reported-by: Yonghwa Lee <underdog@theori.io>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260926174457.13.noahmisch@microsoft.com  
Backpatch-through: 18  

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

pg_resetwal: Fix handling of commit timestamp XIDs

commit   : 1f7013fe089d0e0db5b5e4a20d84acecf0f128a1    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 29 Sep 2026 16:24:21 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 29 Sep 2026 16:24:21 +0300    

Click here for diff

The help text for -c option documents that zero for either transaction  
ID means to leave the corresponding value unchanged.  Commit  
978cf02bb8c replaced the separate checks for the two values with a  
single flag indicating that the option was specified, causing zero to  
be written to the control file instead.  
  
Also parse the second transaction ID with strtouint32_strict(), like  
the first one.  Using strtoul() there was an oversight in commit  
636c1914b48, which intended to reject negative and out-of-range  
arguments.  
  
Author: Chao Li <lic@highgo.com>  
Discussion: https://www.postgresql.org/message-id/F61E486B-746B-42F3-A532-B8D4F1519583@gmail.com  
Backpatch-through: 19  

M src/bin/pg_resetwal/pg_resetwal.c

Doc: add missing new line in DO example block

commit   : 1b2d57d0f5af205fef4331870030a5e1c5e511e7    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Wed, 30 Sep 2026 02:16:12 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Wed, 30 Sep 2026 02:16:12 +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   : b27ab709c4b348fdc3b785aa394ef611c52c3380    
  
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/func-formatting.sgml

Fix incorrect calcSumX2 in numeric deserialize functions

commit   : 6a93535798aa9219d01c01c67161a78780e2af1a    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 29 Sep 2026 15:46:45 +1300    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 29 Sep 2026 15:46:45 +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

Fix crash in parallel autovacuum when no DSM segment can be created.

commit   : cc053b6e127763e4168f18585ca90a67600c270e    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 28 Sep 2026 16:28:30 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 28 Sep 2026 16:28:30 -0700    

Click here for diff

If no DSM segment can be created, a ParallelContext can still be  
created with zero workers, but its seg pointer is NULL. Parallel  
autovacuum registered a segment detach callback on that NULL pointer,  
crashing the autovacuum worker.  
  
Fix by setting up the shared cost parameters and the detach callback  
only when the parallel context has workers, as there are no workers to  
propagate the parameters to otherwise.  
  
Oversight in commit 1ff3180ca01.  
  
Found by Bharath using AI assisted review with Claude.  
  
Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACVjBN03Fq4XWgKH1zOfkapK6-P3ufNLHUHnZcW1zPm+Mg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/vacuumparallel.c

Better express platform requirements in s_lock.h.

commit   : d9b5a63f49d9d372a6609243eb0e9417a0a35e6f    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 28 Sep 2026 13:52:42 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 28 Sep 2026 13:52:42 -0500    

Click here for diff

Presently, s_lock.h insists that every platform provide TAS(), and  
its header comment doesn't say which of the macros a new platform  
actually needs to supply.  The real contract is that a platform  
must provide either S_LOCK() or a TAS() for the default S_LOCK() to  
be built on.  
  
To better express that, this commit moves the "no spinlock support"  
error to where the default S_LOCK() is defined, compiles s_lock()  
only when the default S_LOCK() is in use, and provides a default  
TAS_SPIN() only when there is a TAS() to base it on.  The direct  
callers of s_lock() in the spinlock tests are adjusted to match.  
The header comment is reworked accordingly, dropping the note about  
pre-9.5 volatile requirements and the caution about TAS()  
spuriously failing along the way.  
  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/afkUeI7UhacZ5ZFm%40nathan  

M src/backend/storage/lmgr/s_lock.c
M src/include/storage/s_lock.h
M src/test/regress/regress.c

Fire create_upper_paths_hook for UPPERREL_PARTIAL_GROUP_AGG

commit   : e8a82ddeaf69b077125cf9303df809234461bd37    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Sat, 9 May 2026 14:57:09 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Sat, 9 May 2026 14:57:09 -0400    

Click here for diff

create_partial_grouping_paths() called the FDW callback  
GetForeignUpperPaths for UPPERREL_PARTIAL_GROUP_AGG, but never the  
general-purpose create_upper_paths_hook that non-FDW extensions rely  
on.  create_partial_distinct_paths() already fires both for  
UPPERREL_PARTIAL_DISTINCT.  
  
Add the missing call right next to GetForeignUpperPaths, so an  
extension can add partial-aggregate paths here too, before the caller  
gathers them and builds a Finalize Aggregate on top.  
  
Reviewed-by: Bryan Green <dbryan.green@gmail.com>  
Reviewed-by: Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/6fc72a7d-9f52-4a72-9adf-1912da255605@dunslane.net  

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

Fix WAL file selection in 013_rewind test

commit   : a5447a2deaca65c69f1838240f6bdb3ff85c9577    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 28 Sep 2026 17:46:56 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 28 Sep 2026 17:46:56 +0200    

Click here for diff

Without an explicit WAL filename, pg_waldump determines the segment  
size from the first WAL-named directory entry.  A preallocated  
segment with an uninitialized header can make this fail before the  
checkpoint is read.  
  
Pass the WAL filename recorded in backup_label to avoid depending  
on directory enumeration order.  Use command_like() so command  
failures and stderr are checked rather than appearing only as an  
empty-output mismatch.  
  
This was independently reported by Nazir Bilal Yavuz and Alexander  
Lakhin.  
  
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reported-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN55FZ1Yak_xBqMaDQsD7atpBkGLEkF-DKXcs3nLHM1Uq4YRew%40mail.gmail.com  
Discussion: https://postgr.es/m/ffd837c5-dc22-4db1-a2d8-b623cbe9b30c@gmail.com  

M src/test/modules/test_checksums/t/013_rewind.pl

Avoid idle WAL waits in checksum tests

commit   : 5f76ed5d6baa9bfa9ebd2f1d97eaf6dcbfe76b5f    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 28 Sep 2026 17:46:50 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 28 Sep 2026 17:46:50 +0200    

Click here for diff

Switch to wait_for_replay_catchup in checksum tests to explicitly  
wait for the upstream flush LSN and not the write LSN.  The write  
LSN can include unrelated unflushed WAL which isn't available for  
streaming on an idle primary.  
  
In the test for using a rewound node as standby of a new primary in  
the 013_rewind suite; also switch WAL on the source before starting  
the target.  This flushes through the minimum recovery point chosen  
to avoid a startup delay while an unflushed full_page_writes change  
waits for the background writer to log its next snapshot.  
  
This reduces test times significantly without changing the semantics  
of the tests.  
  
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN55FZ1Yak_xBqMaDQsD7atpBkGLEkF-DKXcs3nLHM1Uq4YRew%40mail.gmail.com  

M src/test/modules/test_checksums/t/003_standby_restarts.pl
M src/test/modules/test_checksums/t/011_standby_straddle.pl
M src/test/modules/test_checksums/t/013_rewind.pl
M src/test/modules/test_checksums/t/021_rewind_divergent_transitions.pl

Turn "check" into assertion

commit   : 6dc3fd90f126fa409eac51a4182ee09b9d63c16c    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 28 Sep 2026 17:41:38 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 28 Sep 2026 17:41:38 +0200    

Click here for diff

In commit 1813f951cad5, I mistakenly assumed that one particular  
function named CheckSomething() checks Something.  It doesn't, it merely  
return the state to check.  Fix by adding the necessary Assert() call.  
  
Good chance to add trailers for commit 1813f951cad5:  
Reviewed-by: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAA-aLv5MF6BLL+BWvix2Yw+CBardtH43AofPReQunhDZPNBtuA@mail.gmail.com  

M src/backend/commands/repack.c

Lock the TOAST table early in REPACK (CONCURRENTLY)

commit   : 1813f951cad59ea7f86063831d0222c429989c91    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 28 Sep 2026 17:12:29 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 28 Sep 2026 17:12:29 +0200    

Click here for diff

The decoding worker records the relfilenumber of the TOAST table when it  
starts, and skips changes stored under any other one, but the TOAST  
table was not locked until the data copy began.  If VACUUM FULL rewrote  
it while the worker was starting, concurrent updates of TOASTed columns  
were silently lost.  
  
Fix by locking the TOAST table in cluster_rel() in the concurrent case,  
before the worker starts.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reported-by: Thom Brown <thom@linux.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAA-aLv5MF6BLL+BWvix2Yw+CBardtH43AofPReQunhDZPNBtuA@mail.gmail.com  

M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
M src/test/modules/injection_points/expected/repack_toast.out
M src/test/modules/injection_points/specs/repack_toast.spec

Fix tuple search during apply after concurrent index DDL.

commit   : ad36e3608c8cb6f0848737ec81e548d4d3a0af3c    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 28 Sep 2026 07:17:39 -0400    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 28 Sep 2026 07:17:39 -0400    

Click here for diff

When searching the local relation by index, the apply worker can use the  
first match only if the index is the relation's replica identity or  
primary key. Otherwise, every match must be compared with the search slot.  
  
Only the index OID was saved in the relation map, so this was determined  
again during the search. Concurrent DROP INDEX or REINDEX can change the  
index status between these two checks, causing the tuple search to fail  
and the change to be silently skipped as an update_missing conflict.  
  
Fix this by recording the answer as idxisreplident in the relation map  
entry and avoid getting it second time in FindReplTupleInLocalRel() and  
RelationFindReplTupleByIndex().  
  
Oversight in 89e46da5e5.  
  
Author: Mikhail Nikalayeu <mihailnikalayeu@gmail.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Discussion: https://postgr.es/m/CADzfLwUJovFcnknCC9wjZKECX9xecgnGzC2r2TMV8h4QDD_jwQ@mail.gmail.com  
Backpatch-through: 16, where it was introduced  

M src/backend/executor/execReplication.c
M src/backend/replication/logical/conflict.c
M src/backend/replication/logical/relation.c
M src/backend/replication/logical/worker.c
M src/include/executor/executor.h
M src/include/replication/logicalrelation.h
M src/test/subscription/t/032_subscribe_use_index.pl

Prevent remote notices from repeating local query details in logs

commit   : 6a2edf2a1e6d0c277b7ddf9604fe5b83766cc8e1    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 28 Sep 2026 18:52:33 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 28 Sep 2026 18:52:33 +0900    

Click here for diff

Since 112faf1378ee, NOTICE, WARNING, and similar messages received through  
dblink, postgres_fdw, and replication connections have been logged with  
ereport(LOG). With the default log_min_error_statement setting, each  
such log entry can also include the current local SQL statement. An active  
error-context callback can add local CONTEXT information as well. Repeating  
these fields for every remote message increases log volume and processing  
overhead.  
  
Use errhidestmt() and errhidecontext() when logging these messages to  
prevent the local STATEMENT and CONTEXT fields, when present, from being  
repeated for each remote message in the server log.  
  
Reported-by: Merlin Moncure <mmoncure@gmail.com>  
Author: Vignesh C <vignesh21@gmail.com  
Reviewed-by: Merlin Moncure <mmoncure@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHyXU0yDwOYkWpRi=gtpDwjBxVqeaezgkgZLRWm2p1_FgaiPFQ@mail.gmail.com  
Backpatch-though: 19  

M src/include/libpq/libpq-be-fe-helpers.h

Add pg_attribute_counted_by()

commit   : a936ebd9f9f64b0efb853195d8dcdb8a0453537d    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 28 Sep 2026 09:34:46 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 28 Sep 2026 09:34:46 +0200    

Click here for diff

The counted_by attribute allows specifying that a flexible array  
member of a struct is "counted by" another member of the same struct.  
The attribute makes arrays a little more self-documenting, but it is  
also a hint to the compiler such that it can improve detection of  
object size information and provide better results in compile-time  
diagnostics and run-time features, such as the array bounds sanitizer.  
  
Both GCC and clang warn when the attribute is used in C++, where it is  
ignored, so define it away there.  
  
In its current form, it is best used for flexible array members only.  
Pointer array support may come later on.  
  
This commit only contains a single use of the attribute for testing.  
More will be added afterwards.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io  

M src/backend/utils/adt/jsonfuncs.c
M src/include/c.h

Prevent stale pg_locks.waitstart values

commit   : 5bd2e236e21b0e158dda43c184260b9395ede4f4    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 28 Sep 2026 14:20:27 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 28 Sep 2026 14:20:27 +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

Remove OID8_FORMAT from c.h

commit   : 2d36d97c91bd43a3ac57513ed786c9e02a6532fa    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 13:29:45 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 13:29:45 +0900    

Click here for diff

This marker could break translated strings if used, so let's remove it  
and encourage instead the use of PRIu64, something that xgettext is able  
to digest.  
  
This marker has been introduced in b139bd3b6ef0, down to v19 that has  
not been officially released yet, so a removal is still possible without  
breaking the ABI requirements.  
  
Discussion: https://postgr.es/m/aqeO1OU7uZjhioAq@alvherre.pgsql  
Backpatch-through: 19  

M src/include/c.h

Replace OID8_FORMAT with more portable PRIu64

commit   : 0e0bf0d92851cf1c62d64e9556a9cf4c9ab302f2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 12:34:29 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 12:34:29 +0900    

Click here for diff

The OID8_FORMAT marker could break translated messages, as proven by  
ceae3099da7b, so let's remove it while we can instead of encouraging its  
use.  
  
An alternative solution that would allow OID8_FORMAT is to save the  
result into an intermediate string, itself used in the translated  
strings, but per discussion this is not an appealing long-term approach.  
  
Note that this commit partially reworks 072d4c424057.  
  
Per discussion with Peter Eisentraut, Álvaro Herrera and Tom Lane.  
  
Discussion: https://postgr.es/m/aqeO1OU7uZjhioAq@alvherre.pgsql  

M contrib/amcheck/verify_heapam.c
M src/backend/access/heap/heaptoast.c
M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/varsup.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/replication/logical/reorderbuffer.c
M src/bin/pg_upgrade/pg_upgrade.c

Refactor assembly of external on-disk TOAST pointers

commit   : 74f7f684d6ed1fd3c3aee4d868f2e6d1da0ec93b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 12:12:10 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 12:12:10 +0900    

Click here for diff

toast_save_datum() ended with two copies of the same three steps, one  
each external on-disk TOAST pointer: allocate a datum, set its tag, then  
copy the contents from a varatt_external_oid or a varatt_external_oid8  
into it.  
  
These steps are moved into a new helper function, toast_pointer_build(),  
which takes the tag and a pointer to the struct and derives everything  
else from the tag.  For now, only two varatt_external_* exist for  
external on-disk TOAST pointers.  Some more are under discussion, where  
this refactoring shows some benefits in the shape of less duplication.  
  
There should be no behavior change.  
  
Author: Nikhil Kumar Veldanda <veldanda.nikhilkumar17@gmail.com>  
Discussion: https://postgr.es/m/CAFAfj_FeJQZrKyVn7ur0aJx8iz8SR14NheVJNyc8JNoqtMX+og@mail.gmail.com  

M src/backend/access/common/toast_internals.c

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

commit   : 5e59290402518db5b2876ecd627c7d79f73eaa44    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 06:55:02 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 28 Sep 2026 06:55:02 +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   : 3c5d9d914fa5b8fb3f371dd97bdece032ca3598d    
  
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

postgres_fdw: Improve comment in fetch_remote_statistics().

commit   : f25c50fd8fcdfdd32548b9140456249eb54a5109    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Sat, 26 Sep 2026 20:40:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Sat, 26 Sep 2026 20:40:00 +0900    

Click here for diff

Mention that the relpages value fetched from a remote server is stored  
as-is, regardless of any difference between the remote and local block  
sizes.  
  
Follow-up to commit 6a8571568.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Reported-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/CAPmGK14OBMkMEkanHdA9%2BJdrZLGzfNRcEVmb6K4DtDe_CTTTqw%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c

Fix privilege handling in postgres_fdw statistics import.

commit   : 7d47e41238004b6b8bce076d4bb76d858257b58d    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Sat, 26 Sep 2026 20:35:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Sat, 26 Sep 2026 20:35:00 +0900    

Click here for diff

When ANALYZE imports statistics from a remote server, it fetched/stored  
the statistics while still running as the user executing ANALYZE, not as  
the foreign table's owner.  This is inconsistent with the sampling path,  
and it causes a security issue: a role that owns a foreign table but has  
no access to the underlying remote data (eg, no access privileges on the  
remote server) could obtain that data by having a privileged user run  
ANALYZE on the table; the imported statistics like most_common_vals then  
expose sampled values from the remote data, as shown in the reproducer  
on the discussion thread.  
  
To fix, switch to the foreign table owner's userid in analyze_rel()  
before calling the ImportForeignStatistics() routine, mirroring the  
identity used by the sampling path.   This not only makes the privilege  
handling consistent between the sampling/import paths, but also prevents  
statistics import from disclosing data the table owner couldn't  
otherwise obtain.  
  
Oversight in commit 28972b6fc.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Reported-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Noah Misch <noah@leadboat.com>  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/CAPmGK16jVk+i2KMkkgR9ajoPdaUAinvcspkk5Bc6urbo2xYTMQ@mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/commands/analyze.c

Check EXECUTE privilege on functions invoked by the RI fast path

commit   : 1a846a555afb0e5f2008f3aefe8f77acbe6ffba6    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Sat, 26 Sep 2026 11:06:58 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Sat, 26 Sep 2026 11:06:58 +0900    

Click here for diff

ri_FastPathCheck() invokes two functions on the FK values: the  
equality operator's function, via the ScanKey the index AM evaluates,  
and, when the FK column's type differs from the PK column's, the  
implicit cast function.  The SPI path gets EXECUTE on both checked by  
ExecInitFunc() when it initializes the generated query, as the  
referenced table's owner, but the fast path performed neither check.  
  
Add ri_CheckFunctionPermissions() and call it once the fast-path  
metadata is populated, under the switch to the referenced table's  
owner, so the checks happen at the same point as the existing relation  
permission check.  Add a regression test for each function, reaching  
the fast path through per-row validation of a new constraint, and  
repeat each against a partitioned referenced table, which takes the  
SPI path, to show that the two behave identically.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai> (offlist)  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Discussion: https://postgr.es/m/CA+HiwqGH+b7sXmsH8sT18diujbheSObWs0gWXqLZqRccMKvZAA@mail.gmail.com  
Backpatch-through: 19  

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

Fix import of statistics for domains over [multi]range types and tsvector

commit   : 142fd8ff13dee8ff6665615027386908e9768d43    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 26 Sep 2026 09:28:12 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 26 Sep 2026 09:28:12 +0900    

Click here for diff

pg_restore_attribute_stats() rejected range_length_histogram,  
range_empty_frac and range_bounds_histogram for a column whose type is a  
domain over a range or a multirange type.  The same issue existed for  
most_common_elems and elem_count_histogram for a domain over tsvector.  
pg_restore_extended_stats() had the same set of problems for expressions  
whose type is a domain over a range, a multirange type, or tsvector.  
  
ANALYZE is able to generate such stats, incorporating the knowledge to  
handle domains in the in-core typanalyze callbacks.  
  
This problem is resolved by being more aggressive with the fetch of the  
base type of a domain in the early phases of restore for attribute and  
extended stats (special tip to Jian He for pointing out the unnecessary  
typcache lookups), reflecting on the surrounding helper routines shared  
by both code paths.  The fix for v18 is local to attribute_stats.c, as  
only attribute stats need to be touched.  
  
Tests are included in a fashion consistent with the surroundings.  The  
consequence of this issue was the rejection of stats that ANALYZE was  
able to build, which was not critical but annoying as it would lead to a  
gap in the stats restored.  
  
Reported-by: Qifan Liu <imchifan@163.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Jian He <jian.universality@gmail.com>  
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/19715-b8be35083016f289@postgresql.org  
Backpatch-through: 18  

M src/backend/statistics/attribute_stats.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/statistics/stat_utils.c
M src/include/statistics/stat_utils.h
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql

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

commit   : f197fdee8265050bfefb2f5d00829a814ff05ae4    
  
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   : 87762cbaa4fefa2911c156f73f585b3ba522bab0    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Sep 2026 15:34:38 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 25 Sep 2026 15:34:38 -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

Remove HAS_TEST_AND_SET.

commit   : 3e9bc39c5d723836fa3e380b4de4a6175fb302c0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 25 Sep 2026 14:07:59 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 25 Sep 2026 14:07:59 -0500    

Click here for diff

This is only set when TAS is defined, so we can just check whether  
TAS is defined directly instead.  
  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/afkUeI7UhacZ5ZFm%40nathan  

M src/include/storage/s_lock.h

Remove fallback declaration for tas().

commit   : 2079be3311b1d0a717d70404a9b9492ec06cc3e2    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 25 Sep 2026 10:40:48 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 25 Sep 2026 10:40:48 -0500    

Click here for diff

The last definition of tas() in s_lock.c was removed in commit  
718aa43a4e, and the last tas.s file was removed in commit  
25f36066dd, so this is dead code.  
  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Discussion: https://postgr.es/m/afkUeI7UhacZ5ZFm%40nathan  

M src/backend/Makefile
M src/backend/port/.gitignore
M src/backend/port/meson.build
D src/backend/port/tas/dummy.s
M src/include/storage/s_lock.h

Fix REPACK (CONCURRENTLY) for columns added without a table rewrite

commit   : 45da2c1d75663d7a692f967b77df42a84fdd6b4d    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 25 Sep 2026 14:07:59 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 25 Sep 2026 14:07:59 +0200    

Click here for diff

When applying the concurrent data changes, REPACK deformed the decoded  
tuples with the descriptor of the transient relation.  That descriptor  
has no "missing" values, because make_new_heap() gives the transient  
relation none of the defaults and constraints of the source relation.  A  
tuple written before an ALTER TABLE ... ADD COLUMN that did not rewrite  
the table has fewer attributes than the descriptor, so the missing  
values came out as NULL, even in a column declared NOT NULL.  If such a  
value belongs to the replica identity, the key used to find the target  
tuple was NULL too, so the tuple to modify cannot not be found.  The  
scan key does not remember that a value is NULL, so a pass-by-reference  
key would even crash the comparison function.  Such tuples will be rare,  
because new row versions are normally formed with the current  
descriptor.  A BEFORE ROW UPDATE trigger returning OLD is one way to  
produce one.  
  
Fix by deforming the decoded tuples with the descriptor of the source  
relation, which does have the missing values.  Tuples formed with it are  
still valid for the transient relation, whose attributes are a copy of  
the source relation ones.  Commit 20d3fe9009dd took the same approach  
for INSERT and UPDATE in the executor.  Expanding the decoded tuple with  
heap_expand_tuple() would be the other option, but that is the  
workaround of commit ba9f18abd that 20d3fe9009d got rid of, so do not  
bring it back.  
  
Add an isolation test.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reported-by: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAN12+Y+NJwr5EqKVrHpPD=5+b_NRAOzU9fhrVDO3H46x2WRxoA@mail.gmail.com  

M src/backend/commands/repack.c
M src/backend/replication/pgrepack/pgrepack.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/repack_missingval.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/repack_missingval.spec

Declare variable-length catalog columns as [] rather than [1]

commit   : 16a104073d012ac2c70e9d233dc5e76f71455035    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 25 Sep 2026 07:51:20 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 25 Sep 2026 07:51:20 +0200    

Click here for diff

Variable-length catalog columns have been declared like  
  
    text attoptions[1];  
  
but that "1" has always been a fiction.  Before the use of #ifdef  
CATALOG_VARLEN, these declarations were visible to the C compiler, and  
this was also before flexible array members were universally  
available, so this was just a convenient workaround to make this  
compile.  But these reasons are long gone, and the "1" is now just a  
confusing relic.  Change this to  
  
    text attoptions[];  
  
which more intuitively reflects the actual nature of these  
fields (while still being syntactically valid but semantically invalid  
C code).  
  
Catalog.pm could already parse both spellings, but no existing code  
used bare [].  To enforce future consistency, it is changed to no  
longer permit digits between the brackets.  But to help developers  
transition, it still recognizes the old style and gives an explicit  
error message.  (Otherwise it would produce some garbage output and  
give confusing errors later.)  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/963b2109-833c-4e93-bdb1-546741d893f4%40eisentraut.org  

M src/backend/catalog/Catalog.pm
M src/include/catalog/pg_attribute.h
M src/include/catalog/pg_class.h
M src/include/catalog/pg_constraint.h
M src/include/catalog/pg_database.h
M src/include/catalog/pg_db_role_setting.h
M src/include/catalog/pg_default_acl.h
M src/include/catalog/pg_event_trigger.h
M src/include/catalog/pg_extension.h
M src/include/catalog/pg_foreign_data_wrapper.h
M src/include/catalog/pg_foreign_server.h
M src/include/catalog/pg_foreign_table.h
M src/include/catalog/pg_init_privs.h
M src/include/catalog/pg_language.h
M src/include/catalog/pg_largeobject_metadata.h
M src/include/catalog/pg_namespace.h
M src/include/catalog/pg_parameter_acl.h
M src/include/catalog/pg_policy.h
M src/include/catalog/pg_proc.h
M src/include/catalog/pg_statistic.h
M src/include/catalog/pg_statistic_ext.h
M src/include/catalog/pg_statistic_ext_data.h
M src/include/catalog/pg_subscription.h
M src/include/catalog/pg_tablespace.h
M src/include/catalog/pg_type.h
M src/include/catalog/pg_user_mapping.h

Remove duplicate definition of the compressed varlena header

commit   : e27f3b2cad7759097407ad01ccaaca506179e346    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 25 Sep 2026 14:24:06 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 25 Sep 2026 14:24:06 +0900    

Click here for diff

toast_internals.h described the header of a compressed-in-line varlena  
a second time, as toast_compress_header, with its own TOAST_COMPRESS_*  
macros to read and write the tcinfo word.  varatt.h already describes  
the same bytes as varattrib_4b.va_compressed and provides equivalent  
macros that act as setter and getter of this information, as of  
VARDATA_COMPRESSED_GET_EXTSIZE() and GET_COMPRESS_METHOD().  
  
Let's remove the duplicate definition, and switch the TOAST code to use  
the macros from varatt.h.  There should be no behavior change.  
  
Note that toast_compression.h is removed from toast_internals.h, added  
to the C files where its declarations are required.  
  
Author: Nikhil Kumar Veldanda <veldanda.nikhilkumar17@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAFAfj_FeJQZrKyVn7ur0aJx8iz8SR14NheVJNyc8JNoqtMX+og@mail.gmail.com  

M contrib/amcheck/verify_heapam.c
M src/backend/access/brin/brin_tuple.c
M src/backend/access/common/detoast.c
M src/backend/access/common/toast_internals.c
M src/include/access/toast_internals.h
M src/include/varatt.h
M src/tools/pgindent/typedefs.list

Silence another "may be used uninitialized" compiler warning.

commit   : 2c10c2ce4d7bcd57543a49ab402af02a39724e0a    
  
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

Convert SISeg->maxMsgNum to an atomic variable.

commit   : df3978c2340d79c6319f8239a69abbd27b1069df    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 24 Sep 2026 14:47:20 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 24 Sep 2026 14:47:20 -0500    

Click here for diff

Currently, this variable is a uint32 protected by a spinlock.  The  
spinlock exists only to provide memory barriers, so by converting  
the variable to an atomic and using the barrier-providing accessors  
in the spinlock's place, we can remove the spinlock.  
  
Author: Yura Sokolov <y.sokolov@postgrespro.ru>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/30aa0030-f694-44ef-a19d-6ef7ddb69374%40postgrespro.ru  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

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

Use unsigned integers for sinval message numbers.

commit   : 25217d91b1a266a4176db8327c21c508de81c72b    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 24 Sep 2026 14:47:20 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 24 Sep 2026 14:47:20 -0500    

Click here for diff

Currently, the message numbers in sinvaladt.c are ints, but they  
are never negative, and the code already takes pains to keep them  
from overflowing.  This commit changes them to uint32.  The only  
wrinkle is that SICleanupQueue() computes two thresholds by  
subtracting from maxMsgNum, and those could previously go negative.  
They are now clamped at zero, which disables the corresponding  
checks just as a negative threshold did.  
  
This is preparatory work for a follow-up commit that will convert  
maxMsgNum to an unsigned atomic variable.  
  
Author: Yura Sokolov <y.sokolov@postgrespro.ru>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/30aa0030-f694-44ef-a19d-6ef7ddb69374%40postgrespro.ru  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

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

Add a range check on the sequence index from the publisher.

commit   : 7a7f60616136a599153bfacf87ebe32e7c2b0a6a    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 24 Sep 2026 11:05:07 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 24 Sep 2026 11:05:07 -0700    

Click here for diff

The sequencesync worker asks the publisher about a batch of sequences,  
tagging each one with its position in the worker's own list, and the  
publisher returns that position alongside the sequence's data. The  
received position is used to subscript the list using list_nth(),  
which bounds-checks only on assert builds, so it was possible that an  
index we never sent made the worker read a pointer from past the end  
of the list and then store the remote last_value through it.  
  
Check the position against the list before using it. No sane publisher  
can trigger this, but we should not let a remote server steer a memory  
access. An in-range position from another batch still gets through and  
would attach one sequence's data to another, but that's a wrong value  
rather than a corrupt process.  
  
Also, receive the index as int4 rather than int8. Previously, an  
out-of-range int8 value was silently truncated to its lower 32 bits by  
DatumGetInt32(), which could turn it into a valid index and defeat the  
check.  
  
Backpatch to v19, where sequence synchronization was introduced.  
  
Reported-by: Anthropic OSS program  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAD21AoBWDMuMmnevZaZ1xSOi75eUx8X7LbVQzmUZudk6F8Bdgg@mail.gmail.com  
Backpatch-through: 19  

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

Don't fully empty GIN pending list in parallel autovacuum workers.

commit   : 8be38b238a61d58b6c0f21d4c1d8e9c1d26d8b58    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 24 Sep 2026 10:31:50 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 24 Sep 2026 10:31:50 -0700    

Click here for diff

Autovacuum doesn't necessarily fully empty the GIN pending list. It  
stops at the tail as of the start of cleanup, so that it doesn't keep  
chasing pages appended by concurrent inserters. GIN decided this with  
AmAutoVacuumWorkerProcess(), which returns false in parallel vacuum  
workers launched by an autovacuum worker, so those workers tried to  
fully empty the list as a manual VACUUM does.  
  
Fix this by adding an is_autovacuum field to IndexVacuumInfo, set from  
the shared parallel vacuum state in parallel workers, and using it in  
GIN instead of checking the process type.  
  
Oversight in commit 1ff3180ca01.  
  
Reported-by: Jingtang Zhang <mrdrivingduck@gmail.com>  
Author: Jingtang Zhang <mrdrivingduck@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Yuhang Qiu <iamqyh@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAPsk3_DiF2i1o=JRXRk1YPVMv1VzJaCAbfiEqgwCva4=ZewVAw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/gin/ginvacuum.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/catalog/index.c
M src/backend/commands/analyze.c
M src/backend/commands/vacuumparallel.c
M src/include/access/genam.h
M src/include/miscadmin.h

Suppress -Wshadow=local warnings in REG_DEBUG code.

commit   : 92616429093e16f938aeca92e1045174835c2a8d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 24 Sep 2026 13:28:05 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 24 Sep 2026 13:28:05 -0400    

Click here for diff

Our Solaris-camp buildfarm animals (billbug, hake, pollock, so far)  
are complaining about dumpcolors()'s local variables in the wake of  
3ee0edb91.  This is unsurprising on one level, since that code  
clearly violates the new expectation; but AFAICS these animals  
aren't explicitly enabling -DREG_DEBUG, so how are they reaching  
the now-faulty code?  Do Solaris' headers #define that?  
  
In any case, the fix is simple enough, just narrow the  
declaration scopes of this function's loop variables.  
(I could have done that only to "c", but thought it best  
to maintain a consistent style in this function.)  
  
I don't see any need to back-patch this.  

M src/backend/regex/regc_color.c

Revert "JSON_TABLE: propagate table-level ON ERROR to columns per SQL standard"

commit   : 2c6f2c5e1778e243f5300ec45d0f4b0be15e6325    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 24 Sep 2026 18:32:19 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 24 Sep 2026 18:32:19 +0300    

Click here for diff

This reverts commit e73841ffbceea314cf9fa3f64a5eae9f87a46449.  Due to  
pg_dump/pg_restore problem and related pg_upgrade problem.  
  
Reported-by: Jeff Davis <pgsql@j-davis.com>  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/d048d3c10964ed984f949f649f194061501e2317.camel%40j-davis.com  
Discussion: https://postgr.es/m/CA%2BTgmoaT9LYxg2%2B4fYh8in0zguHcwyUhN_cFOS-6TCH1-2_Cfw%40mail.gmail.com  

M doc/src/sgml/func/func-json.sgml
M src/backend/parser/parse_jsontable.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

Fix ShmemInitStruct() reattachment in single-user mode

commit   : 4e277b424a5312cdee468d92078a5359f3e7d4e7    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 24 Sep 2026 18:20:32 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 24 Sep 2026 18:20:32 +0300    

Click here for diff

ShmemInitStruct() only looked for an existing allocation when  
IsUnderPostmaster was true.  Because of that, you could not reattach  
to an existing shmem area in a standalone backend.  
  
Usually, you only call ShmemInitStruct() for the same shmem area once  
in a process and hold onto the returned pointer, but there was no rule  
that you couldn't call it twice for the same area if you wanted to,  
and before commit 283e823f9d, it worked.  To fix, check for an  
existing allocation regardless of process type, like the old  
implementation did.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discusssion: https://www.postgresql.org/message-id/CAJTYsWXREGXCnWdZJsXt8pT2UY_Y2GSx+HOUu2X3s8YDCLj0_A@mail.gmail.com  
Backpatch-through: 19  

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

Fix assertion in pg_get_shmem_pagesize() in single-user mode

commit   : 89829354de1b5f3f8cb3dbdd2f2fc087f981a1b3    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 24 Sep 2026 14:38:17 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 24 Sep 2026 14:38:17 +0300    

Click here for diff

Remove assertion that was too strict, and tripped if you queried the  
pg_shmem_allocations_numa or the pg_buffercache_os_pages view in  
single-user mode.  
  
The point of the assertion was that the function should only be called  
after "the server has started", but it would be OK to call it from the  
postmaster, too, as long as it's after startup, specifically after  
huge_pages_status has been set.  We already have a direct assertion  
for that.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAJTYsWV-=w5_oFgCnfAixWGc=gMa2pkDinLyGLsb4sKcDaf2FA@mail.gmail.com  
Backpatch-through: 18  

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

Ensure ExecutorCheckPerms_hook is called from RI fast path

commit   : 2cdd1950f28cf1567ebf1c747422691b09041b30    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 24 Sep 2026 19:28:32 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 24 Sep 2026 19:28:32 +0900    

Click here for diff

The fast path's ri_CheckPermissions() called ExecCheckOneRelPerms()  
directly, so ExecutorCheckPerms_hook never saw the referenced-table  
access that the SPI path's query exposed to it via ExecutorStart().  
Modules such as sepgsql that rely on this hook therefore lost control  
over FK checks against referenced tables that go through the fast  
path.  
  
So, build a one-entry range table and permission-info list and call  
ExecCheckPermissions().  The hook now sees the same relation and  
requiredPerms as before, once per check that goes through the fast  
path.  This also drops the shortcut that skipped the column-level  
check when table-level privileges sufficed, since the hook must run  
regardless.  While at it, drop the explicit frees in the old code,  
because both callers run ri_CheckPermissions() in a per-tuple context  
that is reset after each check, so they were redundant.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch%40microsoft.com  
Backpatch-through: 19  

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

Wait for transactions of an initial decoding snapshot to commit

commit   : 46024c573bcb10b323874651702581cc312f4425    
  
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/access/transam/xact.c
M src/backend/replication/logical/snapbuild.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/repack_commit_race.out
M src/test/modules/injection_points/injection_points.c
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/repack_commit_race.spec
M src/test/recovery/meson.build
A src/test/recovery/t/057_snapshot_commit_race.pl

Use warning option -Wshadow=local

commit   : 3ee0edb9169ff7b46bc858062007bb97c7cc1ae7    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 24 Sep 2026 11:12:17 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 24 Sep 2026 11:12:17 +0200    

Click here for diff

Change the existing -Wshadow=compatible-local to -Wshadow=local.  This  
covers more cases than before.  In particular, some types are  
assignable to each other, such as char * and const char *, or bool and  
some integer type, but they are not "compatible" in the C sense, so  
they are missed by the previous warning setting, but they are really  
the same basic problem.  
  
The warnings were already fixed in commit f9fc9a78a36.  This just  
enables the compiler option.  
  
But: The LLVM headers are not clean for this option, so we need to  
disable this option for those headers.  We do this by also detecting  
in configure and meson the negative form of the warning option and  
applying it when compiling the respective files, similar to how other  
per-file warning disabling already works.  
  
This technically loses the previous -Wshadow=compatible-local checking  
of the LLVM-using files, but this worked only by accident anyway and  
there is no guarantee that future LLVM versions wouldn't run afoul of  
that warning level.  
  
The variables are intentionally named "...shadow", not  
"...shadow_local" or similar, so that other shadow warning option  
variants could be substituted easily.  
  
In the long run, a better solution might be to use -isystem for the  
LLVM include directories, as was attempted in commit 704ef84ef23 but  
then reverted in 7a0aa99e51c, because porting that logic from meson  
accurately to configure is complicated and fragile and hard to test  
and maintain.  
  
Discussion: https://www.postgresql.org/message-id/flat/84b6f128-91f5-480e-8a9e-7d0e8f538cea%40eisentraut.org  

M configure
M configure.ac
M meson.build
M src/Makefile.global.in
M src/backend/jit/llvm/Makefile
M src/backend/jit/llvm/meson.build
M src/makefiles/meson.build

Forbid pg_get_multixact_stats() during recovery

commit   : 4545cee303c257e58195e3d033c05bf38e2cd4d6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 24 Sep 2026 09:36:05 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 24 Sep 2026 09:36:05 +0900    

Click here for diff

MultiXactState->oldestOffset is not maintained during recovery, so  
calling pg_get_multixact_stats() in this context would report misleading  
information.  We could try to work this out by adding this field to the  
control file, for example, but such a change would be too invasive at  
this stage of the v19 development cycle.  
  
The information of pg_get_multixact_stats() is usually useful to control  
the need of some VACUUM or some freezing, operations that cannot happen  
on a standby, so the argument to make the function work while recovery  
is in progress gets thinner with this point in the balance.  
  
The function is updated to return an ERROR when called under  
RecoveryInProgress().  
  
Per discussion with Heikki Linnakangas and Naga Appani.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/CA+QeY+DcnsZRL4GZD8JyJu5HD-d6p8_9M5kT4jgF3gq3Rh8n4w@mail.gmail.com  
Discussion: https://postgr.es/m/20260827231757.78.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Allocate pgstats entry body before insert into shared hashtable

commit   : d9de60c5e47a7f7a5dcee050d119bda08ea85d55    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 24 Sep 2026 08:48:56 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 24 Sep 2026 08:48:56 +0900    

Click here for diff

8191e0c16a03 made pgstat_init_entry() return NULL on DSA allocation  
failure so callers could delete a just-inserted hash entry.  That works  
when dsa_allocate_extended(DSA_ALLOC_NO_OOM) returns InvalidDsaPointer,  
but not when the creation of a new DSM segment raises ERROR.  
  
Under this type of failure, pgstat_init_entry() would mark the hash  
entry live before allocating the body and cause an inconsistent state in  
shared memory.  The next backend trying to acquire the existing,  
partially-initialized entry in pgstat_acquire_entry_ref() would crash,  
taking down the server.  Some of the public reports mentioned ENOSPC on  
POSIX shared memory as one initial cause.  
  
This commit refactors the pgstats entry initialization to happen in two  
phases:  
- Allocate the DSA chunk.  
- Insert the hash entry with a valid segment.  
  
If a concurrent insert wins, the allocation of the first phase needs an  
extra set of dsa_free() calls (pulling back a DSM into its free list).  
As this changes the signature of pgstat_init_entry(), no backpatch is  
done.  
  
Author: Yuriy Grigoryev <ju.grigorev@ftdata.ru>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/ddc3ecfb01ce4e9698b23cc59767f016@localhost.localdomain  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_shmem.c
M src/include/utils/pgstat_internal.h

Add VM corruption check to verify_heapam()

commit   : 5d84c76021cb5a7591be848cd0004b8fd9453d1c    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 23 Sep 2026 18:20:49 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 23 Sep 2026 18:20:49 -0400    

Click here for diff

Detect heap pages whose PD_ALL_VISIBLE flag is clear while either  
visibility map bit is set. This inconsistent state can cause incorrect  
index-only scan results and is not currently reported by verify_heapam().  
  
This also helps users who have access to amcheck but not pg_visibility  
to diagnose corruption.  
  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/66mqpfyti3qhfttcsv6r2lbvqqd32rrmpn6i47ovrsnvguts46@gou54xc5jld3  

M contrib/amcheck/verify_heapam.c

doc: Clarify phase descriptions of pg_stat_progress_repack.

commit   : bd2aebd7a7fe38b8ad832a10d5bfd1d841f048d8    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 23 Sep 2026 14:57:48 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 23 Sep 2026 14:57:48 -0700    

Click here for diff

The "initializing" phase was described as expected to be very brief,  
but for REPACK (CONCURRENTLY), it also covers enabling and  
initializing logical decoding, either of which can take a long  
time. Also, the "catch-up" phase includes waiting for the ACCESS  
EXCLUSIVE lock needed to swap the files, which was not mentioned.  
  
Adding separate progress phases for these steps is left for v20; for  
v19 we only clarify the description.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/CAN12%2BYJOeOyPYB5JS28VE_%2Brzg%3DRbzQXfj58TGfMYwv-TX9mJA%40mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml

Correct on-access VM setting heuristic

commit   : 4a2f5533f3ceb20727686ed5ef38107d6b295e33    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 23 Sep 2026 16:33:25 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 23 Sep 2026 16:33:25 -0400    

Click here for diff

The heuristic to avoid setting the VM during on-access pruning when  
doing so would emit an extra FPI missed a few cases. First it missed  
temp and unlogged tables. Those will never emit an FPI, so they can  
always set the VM if the page is all-visible. It also missed that if  
hint bits are not WAL-logged, setting only the VM passes REGBUF_NO_IMAGE  
for an already WAL-logged heap page, forbidding a heap FPI in the WAL  
record. A page that has never been WAL-logged still requires a heap FPI.  
  
The third is more subtle: If the page is all-visible, the new prune xid  
will be InvalidTransactionId. On-access pruning only executes when the  
current pd_prune_xid is valid and visible. So, when on-access pruning  
finds the page all-visible, it will always clear pd_prune_xid, modifying  
the page.  
  
Knowing this means we can set the VM without emitting an extra heap FPI  
in more cases. When hint bits are WAL-logged, if the heap buffer is  
clean, modifying pd_prune_xid will emit an FPI if one is required. There  
is no reason to try to avoid an FPI by not setting the VM. So, set the  
VM in this case. However, when the heap buffer is already dirty,  
modifying pd_prune_xid can avoid an FPI; so if the page hasn't been  
logged since the last checkpoint, setting it all-visible will emit an  
extra heap page FPI. We will still avoid setting the VM in this case.  
  
This is being backpatched to 19 because since 378a216187ae pd_prune_xid  
is set on insert, and if we execute a prune cycle and skip setting the  
VM because of an incorrect heuristic, we have added new wasted work in  
PG 19.  
  
This commit adds some tests covering these cases. It also updates one of  
the existing temp table tests to avoid exceeding the pin limit. Setting  
the VM and FSM on-access when querying temp tables takes more local pins  
and can run into the limit with fewer heap buffers pinned.  
  
Reported-by: Melanie Plageman <melanieplageman@gmail.com>  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAAKRu_amj7qLF4c=9ijd=708Fu2G8gg-2EqwBu=aCdAHU2sPHg@mail.gmail.com  
Backpatch-through: 19  

M contrib/pg_visibility/expected/pg_visibility.out
M contrib/pg_visibility/sql/pg_visibility.sql
M src/backend/access/heap/pruneheap.c
M src/test/regress/expected/temp.out
M src/test/regress/sql/temp.sql

Fix incorrect block accounting in TID Range Scans

commit   : 374522aa63af1187c15dd21db0b2c988b55c9a3a    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 24 Sep 2026 01:18:37 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 24 Sep 2026 01:18:37 +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>  
Author: David Rowley <dgrowleyml@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   : cff329240bae6416f7e3574c7996cdd710a9674c    
  
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/func-string.sgml

doc: Mention oid8 TOAST values in the limits appendix

commit   : 74b89f8f968de13d653642b0a21521d20b71af61    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 23 Sep 2026 19:56:45 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 23 Sep 2026 19:56:45 +0900    

Click here for diff

limits.sgml mentioned the limit related to oid values in TOAST tables,  
where up to 2^32 out-of-line values can be stored.  This section did not  
mention oid8 values, able to lift this limitation, for up to 2^64  
out-of-line values.  
  
Oversight in 6e58d6356fcb.  
  
Reported-by: John Naylor <johncnaylorls@gmail.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CANWCAZa+pWZL1Zjep1pz1F0sVWwNOQf+QfGErOaiUvC10Yr2XA@mail.gmail.com  

M doc/src/sgml/limits.sgml

Clean up usage of hash_any() and hash_any_extended()

commit   : a1c37421a8707b365f5dd27d328648c7fe0503a0    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Wed, 23 Sep 2026 17:19:48 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Wed, 23 Sep 2026 17:19:48 +0700    

Click here for diff

Back in the days before a91e2fa94, hash_any() was the primary hash  
function and it returned a Datum. That commit changed hash_any() to a  
wrapper over hash_bytes(). Some places actually wanted the underlying  
uint32 from hash_bytes(), but that now presents as useless round-trip  
casting, so update the call sites where we don't immediately need a  
Datum.  
  
hash_numeric() didn't have round-trip casting, but it was internally  
inconsistent: Paths returning a constant used PG_RETURN_UINT32(), but  
the path using the result of hash_any() used PG_RETURN_DATUM. Change  
it to use uint32 throughout.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Suggested-by: John Naylor <johncnaylorls@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAJ7c6TMPhDRQMmkUHPv8oOK97B1mR8NRS61DgjpdaZUPAwaeZQ%40mail.gmail.com  

M contrib/ltree/ltree_op.c
M src/backend/access/tablesample/bernoulli.c
M src/backend/access/tablesample/system.c
M src/backend/commands/async.c
M src/backend/lib/bloomfilter.c
M src/backend/lib/hyperloglog.c
M src/backend/nodes/bitmapset.c
M src/backend/nodes/queryjumblefuncs.c
M src/backend/tsearch/ts_typanalyze.c
M src/backend/utils/adt/bytea.c
M src/backend/utils/adt/jsonb_gin.c
M src/backend/utils/adt/jsonb_util.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/cache/funccache.c

Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY SOURCE.

commit   : 85f55534e80b633bdb7bfc91eaa5793021d6bf66    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 23 Sep 2026 09:39:04 +0100    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 23 Sep 2026 09:39:04 +0100    

Click here for diff

When executing a WHEN NOT MATCHED BY SOURCE action in MERGE, if the  
tuple from the target table was concurrently deleted, the retry code  
would incorrectly execute a WHEN NOT MATCHED BY TARGET action for the  
row instead, giving incorrect results.  
  
Fix in ExecMergeMatched() -- when handling a TM_Deleted failure  
status, it should only set *matched to false (telling the caller to  
execute any WHEN NOT MATCHED BY TARGET actions) if the failed action  
was a WHEN MATCHED action. For a failed WHEN NOT MATCHED BY SOURCE  
action, the source tuple did not exist, and the target tuple has just  
been deleted, so it should do nothing.  
  
Back-patch to v17, where support for WHEN NOT MATCHED BY SOURCE  
actions was introduced.  
  
Reported-by: Jeff Davis <pgsql@j-davis.com>  
Author: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>  
Discussion: https://postgr.es/m/ccdab5ba02c65af195b5a6d2d744a01d9de47cd3.camel@j-davis.com  
Backpatch-through: 17  

M src/backend/executor/nodeModifyTable.c
M src/test/isolation/expected/merge-delete.out
M src/test/isolation/specs/merge-delete.spec

Fix alignas placement in GinTuple

commit   : 9bfdcfbfcf98f819a5f7f35fa3dee25bcf96b3a5    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 23 Sep 2026 09:16:33 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 23 Sep 2026 09:16:33 +0200    

Click here for diff

Commit bad8829872d added an alignas specifier, and placed it in the  
middle of the declaration, unlike most existing uses, possibly to  
avoid the indentation problem recently fixed in commit 884f82ae262.  
This placement is valid in C but not in C++, which requires it to be  
at the beginning.  This results in a warning in g++ and an error in  
clang++.  Fix by moving it accordingly.  

M src/include/access/gin_tuple.h

Fix sequence synchronization failure on a concurrent refresh.

commit   : dca73f7dd03ddfc89a88019659fc0161e0427a8c    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 23 Sep 2026 11:32:45 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 23 Sep 2026 11:32:45 +0530    

Click here for diff

A sequencesync worker builds its list of sequences and then processes them  
in batches. If ALTER SUBSCRIPTION ... REFRESH PUBLICATION removes one of  
those sequences in the meantime, the worker updated the local sequence and  
then failed while marking it READY, because its catalog row was gone. That  
rolled back the batch, and with disable_on_error the entire subscription  
was disabled.  
  
The worker now checks that the sequence is still part of the subscription  
before updating it, and skips it if not. The check is done under the lock  
on the subscription that the refresh also takes, so the row cannot go away  
in between.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAM527d9mL-bOofX-G7Sp441vA3Y_fa_7JBh03m-ZPduikn_XUg@mail.gmail.com  
Backpatch-through: 19, where it was introduced  

M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/sequencesync.c

Avoid replay cleanup locks for freeze-only and VM-only records

commit   : 07c73f45063f6fcdc7f460aec84396ae4e0f71c5    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Tue, 22 Sep 2026 18:19:00 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Tue, 22 Sep 2026 18:19:00 -0400    

Click here for diff

6dbb490261a combined pruning and freezing in a single WAL record but  
unconditionally requested a cleanup lock during replay. Prior to version  
17, freeze-only records were replayed under an ordinary exclusive lock.  
  
1252a4ee286 subsequently folded visibility map updates into the same  
records, extending the unnecessary cleanup-lock requirement to VM-only  
updates starting in version 19.  
  
Request a cleanup lock in redo only when the record actually prunes.  
Freezing and visibility updates do not move or remove tuple storage, so  
they need not wait for other buffer pins to be released. This avoids  
unnecessary replay delays and cancellation of standby queries holding  
buffer pins.  
  
The fix is the same for all versions, though it addresses two oversights  
in master/19 and one in 18/17.  
  
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>  
Reported-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/85b6968b-49f2-4243-86a6-9b4116e6439b@iki.fi  
Discussion: https://postgr.es/m/CAHg+QDf3NcB3vOAqQ5EFcV5DYYUZ9snCSJAU-x1JDbtcjK3eBQ@mail.gmail.com  
Discussion: https://postgr.es/m/F9BF304E-1298-481C-829A-B4E10AED025A@yandex-team.ru  
Backpatch-through: 17  

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

Assert correct VM page passed to pruning

commit   : d8516db39dfa73042e3ba28f9efc78da4dd6792d    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Tue, 22 Sep 2026 17:27:26 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Tue, 22 Sep 2026 17:27:26 -0400    

Click here for diff

Before pruning a heap page, we get the current status of the  
corresponding VM page. If the passed in vmbuffer isn't the right one,  
visibilitymap_get_status() will silently unpin it and pin the correct  
page. Pruning assumes the caller manages the vmbuffer lifecycle, so this  
would leave the caller with a stale VM reference and would leak the new  
VM pin. To avoid mistakes in development, assert that the correct VM  
page is pinned before beginning.  
  
Reported-by: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAAKRu_amj7qLF4c=9ijd=708Fu2G8gg-2EqwBu=aCdAHU2sPHg@mail.gmail.com  
Backpatch-through: 19  

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

Convert SharedFileSet->refcnt to an atomic variable.

commit   : 09a579abaca86bcd85ebc49b247d2ec58bdc6d3b    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 14:23:04 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 14:23:04 -0500    

Click here for diff

Currently, this variable is an int protected by a spinlock.  By  
converting it to an atomic variable, we can remove the spinlock.  
Detaching becomes an atomic subtract, and attaching becomes a  
compare-and-exchange loop, since it must not resurrect a fileset  
whose reference count has already reached zero.  
  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

M src/backend/storage/file/sharedfileset.c
M src/include/storage/sharedfileset.h

Convert Sharedsort's worker counters to atomic variables.

commit   : ee97eef695e8be9153595131f8b63e4b1b3e8196    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 13:50:58 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 13:50:58 -0500    

Click here for diff

Currently, currentWorker and workersFinished are ints protected by  
a spinlock.  By converting them to atomic variables, we can remove  
the spinlock.  Note that the spinlock also covered the write of  
each worker's tape metadata.  Removing it is still okay: each  
worker writes only its own slot, and the atomic increment that  
follows is a full barrier.  Furthermore, the leader doesn't read  
the slot values until all workers have finished.  
  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

M src/backend/utils/sort/tuplesort.c

Convert PROC_HDR->startupBufferPinWaitBuf to an atomic variable.

commit   : cb4a03db9ed7606da1c36e4214a6c5fd6437a26c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 13:22:15 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 13:22:15 -0500    

Click here for diff

Currently, this variable is a Buffer that is accessed via a  
volatile pointer.  By converting it to an atomic variable, we can  
remove the volatile qualifiers.  No barriers are needed because the  
value is published before the backends that read it are signaled.  
  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

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

Silence warnings about unused global variables

commit   : 802bf7cbfc6f176cd5198321417eb737b0fd4442    
  
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
M src/test/modules/test_resowner/test_resowner_many.c

Convert ParallelBitmapHeapState->state to an atomic variable.

commit   : b1ec662ec189f3492a5c386edf80359347abefef    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 12:44:32 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 22 Sep 2026 12:44:32 -0500    

Click here for diff

Currently, this variable is a SharedBitmapState protected by a  
spinlock.  By converting it to an atomic variable, we can remove the  
spinlock.  
  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

M src/backend/executor/nodeBitmapHeapscan.c

Improve error code and messages for some SQL-reachable code paths

commit   : e8a3ee5b1974e2de40e8cf8dac28f2ef500a2950    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 22 Sep 2026 19:48:30 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 22 Sep 2026 19:48:30 +0900    

Click here for diff

The error code paths adjusted in this commit are reachable via SQL  
functions that are documented.  Previously, they generated an internal  
error code, causing the messages to not be translated.  They are now  
upgraded with a suitable error code.  
  
Note the extra consistency in the three typmod errors, and the tweaks in  
acldefault_sql() to show correctly non-printable characters.  
  
Author: Alexander Lakhin <exclusion@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/94ac928b-8370-4db5-ada5-579a9ebc089d@gmail.com  

M src/backend/catalog/objectaddress.c
M src/backend/commands/tablecmds.c
M src/backend/parser/parse_utilcmd.c
M src/backend/storage/ipc/shmem.c
M src/backend/utils/adt/acl.c
M src/backend/utils/adt/timestamp.c
M src/pl/plpgsql/src/pl_gram.y

pg_upgrade: Check for arrays over system types with auto-assigned OIDs

commit   : 77f54eb07488341025073a370f6e381a6ee05e04    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Tue, 22 Sep 2026 13:47:57 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Tue, 22 Sep 2026 13:47:57 +0700    

Click here for diff

Array values embed their element type's OID, and pg_upgrade does not  
rewrite user data.  The OIDs of information_schema domains can vary  
between major versions, so a stored array over one (e.g. by aggregating  
an information_schema query into a table) comes through the upgrade  
with at best a dangling element OID.  Whole-array reads and pg_dump  
of the upgraded cluster then fail with "cache lookup failed for type  
N". Worst case, the OID has been reassigned, leading to values being  
misread instead.  
  
The data type checks miss this because nothing flags the domain itself:  
domain storage is just the base type, so the recursive expansion in  
data_type_check_query() never reaches the array type.  
  
Add a check for arrays whose element type OID was assigned by genbki.pl  
or initdb, including anything in information_schema in case it was  
dropped and reloaded.  
  
The scenarios that hit this are fairly contrived, which probably  
explains the lack of field reports, so no backpatch for now.  
  
Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com>  
Discussion: https://postgr.es/m/CANWCAZbusXHWWSq_9NpxtOGvR=M5MH4Uj+wO0f1_rtC0uMeSWg@mail.gmail.com  

M src/bin/pg_upgrade/check.c

Simplify abbreviated key hashing during cardinality estimation

commit   : d39fda1cc404834781458376173e5293f870e83a    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Mon, 21 Sep 2026 17:36:50 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Mon, 21 Sep 2026 17:36:50 +0700    

Click here for diff

In the wake of commit 2a600a93c, Datums are 64-bit values, so  
we no longer need to fold the abbreviated key to 32 bits before  
hashing. Instead, use murmurhash64(), which is simpler and avoids  
a function call. Also replace hash_uint32() with murmurhash32()  
in related places.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Suggested-by: John Naylor <johncnaylorls@gmail.com>  
Reviewed-by: Aditya Gollamudi <adigollamudi@gmail.com> (earlier version)  
Reviewed-by: Michael Paquier <michael@paquier.xyz> (earlier version)  
Discussion: https://postgr.es/m/CAJ7c6TMPhDRQMmkUHPv8oOK97B1mR8NRS61DgjpdaZUPAwaeZQ%40mail.gmail.com  

M src/backend/utils/adt/bytea.c
M src/backend/utils/adt/network.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/adt/uuid.c
M src/backend/utils/adt/varlena.c

Attempt to fix test interference from foreign_key opfamily test

commit   : 9e17d25e79d4756be08b4a5521b4b58450217137    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Sun, 20 Sep 2026 14:13:17 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Sun, 20 Sep 2026 14:13:17 +0900    

Click here for diff

The test added by c62b330912e creates a btree opfamily whose members  
include built-in integer operators, which get_mergejoin_opfamilies()  
finds regardless of schema.  So any concurrently running test that  
planned an integer join or sort could pick the family up while it  
existed.  That's the likely cause of the intermittent plan-shape  
changes seen in window.sql and equivclass.sql on the buildfarm after  
that commit.  
  
Run the test inside a transaction that is rolled back, so the family  
is never committed and never visible to other backends.  
  
Per buildfarm members sifaka, prion, turaca, widowbird.  
  
Discussion: https://postgr.es/m/CA+HiwqGitHCmO7nvV4nXXYWDkNYA+zVcJj=JNmL3C1O9B0Gz0A@mail.gmail.com  
Backpatch-though: 19  

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

JSON_TABLE: propagate table-level ON ERROR to columns per SQL standard

commit   : e73841ffbceea314cf9fa3f64a5eae9f87a46449    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 19 Sep 2026 17:23:43 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 19 Sep 2026 17:23:43 +0300    

Click here for diff

Per ISO/IEC 9075-2:2023, 7.11 <JSON table>, Syntax Rules 1)e)iv) and  
1)f)xi), a regular or formatted JSON_TABLE column that does not specify  
its own ON ERROR clause takes its default error behavior from the  
table-level ON ERROR clause: with ERROR ON ERROR on the table, the  
column behaves as ERROR ON ERROR; otherwise the column defaults to  
NULL ON ERROR.  
  
PostgreSQL instead always defaulted such columns to NULL ON ERROR, so  
  
  SELECT * FROM JSON_TABLE(jsonb '"err"', '$'  
                           COLUMNS (a int PATH '$') ERROR ON ERROR) jt;  
  
returned a NULL row where the standard requires an error.  The  
documentation stated the divergence as if it were a rule, saying that  
the table-level clause "does not affect the errors that occur when  
evaluating columns".  
  
Implement the standard behavior in the JSON_TABLE syntactic  
transformation: when a column lacks its own ON ERROR clause and the  
table-level behavior is ERROR ON ERROR, synthesize an implicit ERROR ON  
ERROR for the column before it is transformed into a JsonExpr.  A column  
with its own ON ERROR clause is unaffected.  EXISTS columns are not  
covered by those syntax rules, so they keep their FALSE ON ERROR  
default.  A JSON_TABLE stored in a view is now deparsed with the  
previously implicit ERROR ON ERROR shown explicitly on the affected  
columns, which is a semantically equivalent, round-trip-stable form.  
  
86ab7f4c721d introduced this cascade as part of the PLAN clause and  
af6fad879fbf reverted it, on the grounds that it should be a deliberate  
and separately documented change rather than a side effect of an  
unrelated feature.  This is that change.  
  
Do not back-patch.  A query that specifies ERROR ON ERROR at the table  
level and relies on its columns still yielding NULL now raises an error  
instead of returning rows.  Nothing is silently wrong in the released  
branches: the table-level clause is ignored for columns consistently,  
and that is what the documentation has promised since PostgreSQL 17, so  
users could reasonably have depended on it.  
  
Discussion: https://postgr.es/m/CAPpHfdtDXseGhrL14a2asOkwGnFTVrDk8SQc3iWZgWEEhXXMGw%40mail.gmail.com  
Reviewed-by: Nikita Malakhov <hukutoc@gmail.com>  

M doc/src/sgml/func/func-json.sgml
M src/backend/parser/parse_jsontable.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

Fix join removal when Vars reference the removed join via its alias

commit   : a8bb1a77795bab6e1304efa5c5dabee797b6887e    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 19 Sep 2026 22:46:04 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 19 Sep 2026 22:46:04 +0900    

Click here for diff

When a join has an alias, the parser marks every Var referenced  
through that alias with the join's RT index as its syntactic referent  
(varnosyn), even though varno points at the underlying base relation.  
Since commit 2ebf25e7d, join removal strips the removed relids from  
the query tree using ChangeVarNodes() with INVALID_VAR, which asserts  
that the relid doesn't appear in any field identifying a single  
relation.  A varnosyn that names the removed join violates that, so a  
query like  
  
    SELECT j.x FROM (t1 s(x) LEFT JOIN t2 ON s.x = t2.a) j;  
  
with t2.a unique fails an assertion.  In non-assert builds, varnosyn  
is silently set to INVALID_VAR.  
  
Such syntactic references are still valid after the removal: the join  
is only taken out of the jointree, and its RTE remains in the  
rangetable through to the finished plan.  So, when deleting a relid,  
leave varnosyn unchanged, as join removal did before 2ebf25e7d.  
  
Back-patch to v16, as with commit 2ebf25e7d.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAMbWs484SQSdzWTgZYKvwtuC6J4m7acw0LfBjp3aWPvav7gC_w@mail.gmail.com  
Backpatch-through: 16  

M src/backend/rewrite/rewriteManip.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Fix preprocessing of PHV copies pushed down into subqueries

commit   : bee81f7864621117f077a2694b63265378bbd7b9    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Sat, 19 Sep 2026 21:52:15 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Sat, 19 Sep 2026 21:52:15 +0900    

Click here for diff

Commit e28cf96e9 preprocessed the copies of a query level's  
PlaceHolderVars that were pushed down into its subqueries in a single  
walk at the start of subquery_planner.  That was wrong in two ways.  
  
First, such copies can also be inserted later, when a join alias Var  
of the outer level is expanded within a LATERAL subquery or a  
SubLink's subselect and the alias expression contains a PHV.  Those  
copies were never preprocessed, so a SubLink within them survived into  
the subquery's lateral references or into a SubPlan's argument list,  
tripping an assertion in identify_current_nestloop_params or failing  
in cost_qual_eval.  
  
Second, when a pushed-down copy directly contains another PHV of the  
same level, the walk preprocessed the inner one first and then the  
outer one, so the outer one's preprocessing ran into the SubPlans just  
created in the inner one and tripped an assertion in  
flatten_join_alias_vars.  
  
To fix, preprocess the copies right after join alias expansion  
instead: within preprocess_expression, just before SubLinks are turned  
into SubPlans, and for LATERAL subquery RTEs, right after their  
aliases are flattened.  Preprocessing a copy handles everything within  
it, including any further copies nested inside its SubLinks, so the  
walker no longer looks inside a copy.  
  
Back-patch to v16, as with commit e28cf96e9.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwH-acRnAk1=Ki4EiAJEt67+Rz=_jyg7pbP_c6BK4oHZ4Q@mail.gmail.com  
Backpatch-through: 16  

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

Fix PASSING of toasted text values in JSON query functions

commit   : ab713cdcdbfd05b72a6959ff17aad56cf075ae31    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 19 Sep 2026 20:13:51 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 19 Sep 2026 20:13:51 +0900    

Click here for diff

The PASSING arguments of JSON_EXISTS(), JSON_QUERY(), JSON_VALUE() and  
JSON_TABLE() are evaluated by plain expression steps and given to the  
jsonpath executor as-is.  
  
When dealing with a varlena, JsonItemFromDatum() was building a  
jbvString directly the contents of a varlena.  For a varatt_external  
(varatt_external[oid/oid8] on HEAD), this ignored that the contents of  
the varlena need to be detoasted, leading to incorrect contents  
returned.  
  
Let's detoast the value, like the jsonb and json cases.  b0feda79fdf0  
has fixed the same issue for subscript values in jsonb.  
  
Note that the results of DatumGetTextPP() are allocated in the memory  
context used for the evaluation of the expression, which is reset once  
per row.  
  
Oversight in 6185c9737cf4.  
  
Author: Chaitanya Choudhary <chaitanyyachoudhary@gmail.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/19693-2ecd2b52c838b3e5@postgresql.org  
Backpatch-through: 17  

M src/backend/utils/adt/jsonpath_exec.c
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/sqljson_queryfuncs.sql

Invalidate RI fast-path metadata on operator family changes

commit   : c62b330912e2095dc8dee2f749adf7e5d94ca611    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Sat, 19 Sep 2026 15:27:35 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Sat, 19 Sep 2026 15:27:35 +0900    

Click here for diff

The RI fast path checks a foreign key by probing the referenced  
unique index directly, using the equality operator recorded for  
the constraint.  Whether the fast path can be used is decided once  
and cached in RI_ConstraintInfo, and that cache is invalidated on  
pg_constraint changes but not on pg_amop.  So after an ALTER  
OPERATOR FAMILY drops the recorded operator and adds another in its  
place, the cached decision is stale, and the next fast-path check  
probes the index with an operator no longer in the opfamily and  
errors out with "operator XXX is not a member of opfamily XXX".  
The SPI path is unaffected, because the planner just stops matching  
the index.  
  
To fix, register an AMOPOPID syscache callback to flush the RI  
cache on pg_amop changes, and have ri_check_fastpath_index()  
recheck that the recorded operator is still the equality member of  
the index's opfamily, falling back to SPI when it is not.  
  
Add regression test coverage.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Author: Nikolay Samokhvalov <nik@postgres.ai>  
Discussion: https://www.postgr.es/m/CAM527d9PzFzagr67N0%3DEx2ng1p5HzrcAszy3j5OoZKHXQMARXA%40mail.gmail.com  
Backpatch-through: 19  

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

Add test for logical decoding with an oid8 TOAST table and OID > 2^32

commit   : a3f4fc5bacc8c4868ad6b5a02a65cbb4c0846c01    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 19 Sep 2026 13:49:34 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 19 Sep 2026 13:49:34 +0900    

Click here for diff

The test_decoding tests would usually run with an OID counter way below  
the UINT32_MAX limit, meaning that any toast value handled would always  
fit in 4 bytes.  
  
This commit adds a short test based on an oid8 TOAST table and an OID  
past 2^32, forcing an overflow check of the logical replication code  
when dealing with the detoasting of externally TOASTed values.  
  
Author: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/aqd_gYs35v--sVlR@paquier.xyz  

M src/test/recovery/t/006_logical_decoding.pl

Fix RI fast-path permission checks

commit   : 2c45694a240e89c3f7d848d433f78e394521b6d6    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Sat, 19 Sep 2026 10:35:51 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Sat, 19 Sep 2026 10:35:51 +0900    

Click here for diff

The fast path required table-level SELECT on the referenced table,  
rejecting checks that the SPI path allows with column-level grants.  
It also omitted the UPDATE privilege required by FOR KEY SHARE.  
  
When table privileges do not suffice, use ExecCheckOneRelPerms() with  
the referenced key columns as selectedCols and an empty updatedCols.  
This accepts SELECT on all referenced columns and UPDATE on any column,  
the same privileges the executor would require for the SELECT ... FOR  
KEY SHARE the SPI path runs.  Keep the table-privilege check as a  
shortcut that avoids constructing a column bitmap in the usual case.  
  
Add missing regression test coverage for the fixed cases.  
  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Author: Nikolay Samokhvalov <nik@postgres.ai>  
Co-authored-by: Amit Langote <amitlangote09@gmail.com>  
Discussion: https://www.postgr.es/m/CAM527d9BgPjeOOYmbCBTd57R145qHCk-dzw9qNq%2BnOrDq1j__A%40mail.gmail.com  
Backpatch-through: 19  

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 that oldestXID and oldestMulti are consistent at pg_upgrade

commit   : 7b879c485243e61a0d4cb169717a8e96e9e875c2    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 19 Sep 2026 00:26:11 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Sat, 19 Sep 2026 00:26:11 +0300    

Click here for diff

Now that pg_upgrade will rewrite multixid members, starting from  
oldestMulti, it's important that oldestMulti is valid.  Add a sanity  
check that oldestMulti is not newer than the oldest datminmxid value  
in pg_database.  
  
One case where this could happen is if the cluster was previously  
upgraded to version 9.3 with a buggy pg_upgrade version that didn't  
have commit a61daa14d5.  This new pg_upgrade check is similar to the  
defence that was added in commit 78db307bb2 to VACUUM to avoid  
truncating away multixids if oldestMulti is too new.  This pg_upgrade  
check differs in that we don't try to soldier on with the upgrade if  
the oldestMultiXID is inconsistent, but rather just abort the upgrade.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://www.postgresql.org/message-id/20260827231757.78.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/access/transam/multixact.c
M src/bin/pg_upgrade/check.c
M src/include/access/multixact.h

Remove unused columns from pg_upgrade's query

commit   : 484b3e1d83eefffa3953ff6bfea72dbe547916b5    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 18 Sep 2026 22:14:09 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 18 Sep 2026 22:14:09 +0300    

Click here for diff

Commit 9637badd9f removed the use of these collation-related fields in  
the result set, moving that to a different query, but forgot to remove  
the columns from the query.  

M src/bin/pg_upgrade/info.c

Fix memory leak in pgoutput with streamed prepared transactions.

commit   : bb1e3e47562aa937d4cf81b1aef7a55d0a9c28dd    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Fri, 18 Sep 2026 10:18:52 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Fri, 18 Sep 2026 10:18:52 -0700    

Click here for diff

pgoutput records the toplevel XID in the relation's streamed_txns  
list, allocated in CacheMemoryContext, when it sends a relation's  
schema during a streamed transaction. We clean up that list at stream  
commit and stream abort, but missed stream prepare, so the XIDs stay  
around until a relcache invalidation for the relation or until the  
walsender exits.  
  
Fix by cleaning up the cache after writing the stream prepare message,  
marking the schema as sent as we do at stream commit. The subscriber  
applies the spooled relation messages at PREPARE time and its relation  
map isn't rolled back by ROLLBACK PREPARED, so we don't need to send  
the schema again even if the prepared transaction eventually aborts.  
  
Oversight in commit 63cf61cdeb7b.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWWt5aaKHCnV=jNOwABzspd-WbnhWLndDqtESDQRQ-BkKQ@mail.gmail.com  
Backpatch-through: 15  

M src/backend/replication/pgoutput/pgoutput.c

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

commit   : 32872d0c9790e570105f55682e92fba22ae1b38d    
  
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

Tighten definition of ON CONFLICT arbiter index equivalence

commit   : dc5f8cb93467d8e46df9cebea0e35aed4f863768    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 18 Sep 2026 13:40:31 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 18 Sep 2026 13:40:31 +0200    

Click here for diff

Commits 2bc7e886fc1b and 90eae926abbb taught ON CONFLICT to include  
indexes matching an already selected arbiter, so that an index left  
behind by REINDEX CONCURRENTLY continues to arbitrate together with its  
replacement.  Both checks were too permissive:  
  
a) infer_arbiter_indexes() compared a candidate with a named  
constraint's index using only attributes, expressions and predicate, but  
ignored collation, NULLS NOT DISTINCT setting or deferrability.  As a  
result, an index with a difference in these settings could be accepted  
even though it did not identify the same conflicts.  Also, a deferrable  
index that otherwise matches an arbiter index would also cause ON  
CONFLICT to fail with "ON CONFLICT does not support deferrable unique  
constraints/exclusion constraints as arbiters".  
  
b) ExecInitPartitionInfo() also failed due to the failure to compare  
deferrability, so partition-local deferrable indexes would be considered  
and break inserts routed to that partition with the error mentioned  
above.  
  
Fix by making IsIndexCompatibleAsArbiter() compare those properties, and  
changing infer_arbiter_indexes() to use that routine instead of open  
coding equivalent logic.  Also handle the named-constraint case in  
infer_arbiter_indexes() separately instead of passing the constraint  
index through the regular clause-inference matching.  That function is  
not static anymore, so move it to index.c, and also reimplement it to  
use the Relation from the indexes only, no longer receiving the  
IndexInfo (which wasn't really necessary); also, use equal() to compare  
the expression and predicate lists rather than list_difference().  
  
Add tests for ON CONFLICT ON CONSTRAINT with deferrable, NULLS NOT  
DISTINCT, and different-collation sibling indexes, preserving the  
behavior of released pre-19 versions.  Also test routed inserts with a  
partition-local deferrable unique constraint.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAN4CZFPEYXeYFTxHpoPujfVFb+1Tx1jnXVboDMBg-ZhpgpQ-_g@mail.gmail.com  

M src/backend/catalog/index.c
M src/backend/executor/execPartition.c
M src/backend/optimizer/util/plancat.c
M src/include/catalog/index.h
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/expected/insert_conflict.out
M src/test/regress/sql/collate.icu.utf8.sql
M src/test/regress/sql/insert_conflict.sql

Fix SHMEM_ATTACH_UNKNOWN_SIZE when the shmem area doesn't exist

commit   : 311df1dc0392f06973cf98eac51d63cb007267ce    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 18 Sep 2026 12:12:58 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 18 Sep 2026 12:12:58 +0300    

Click here for diff

SHMEM_ATTACH_UNKNOWN_SIZE can be passed as argument to  
ShmemRequestStruct() when the caller wants to attach to an existing  
shared memory structure whose size it doesn't know.  If the shared  
memory structure doesn't exist, the request should fail, but instead,  
ProcessShmemRequestsAfterStartup() tried to create the structure with  
size = -1.  That led to integer overflow in ShmemAllocRaw() and memory  
corruption.  
  
Fix by rejecting requests with SHMEM_ATTACH_UNKNOWN_SIZE when the  
structure doesn't exist.  Also add an integer overflow check in  
ShmemAllocRaw(), to protect from this kind of confusion or simply too  
large requests.  Also document SHMEM_ATTACH_UNKNOWN_SIZE.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAExHW5u_fTsOAS85kG981Vu6eR1GV-344rup6zYew7xMjEDREw@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/xfunc.sgml
M src/backend/storage/ipc/shmem.c
M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl
M src/test/modules/test_shmem/test_shmem.c

postgres_fdw: Fix oversights in fetch_attstats().

commit   : bea01b825c077e73b009be0a6f000ed643490ae9    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 18 Sep 2026 17:45:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 18 Sep 2026 17:45:00 +0900    

Click here for diff

The query to get attribute statistics from a remote server applied the  
"C" collation to a column of type name without checking the server's  
version.  Since the name type was made collatable in Postgres 12, this  
could break attribute statistics import if the server was older.  Fix by  
casting the column value to text before collating it if the server is  
older.  
  
Also, fix a typo in the if-test in the same function.  
  
Oversights in commit 28972b6fc; the former was reported by Fujii Masao.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGvA_3q7Wg7GXQkuugGZj3%3DkxDRjDsKgVvK1uwAxHTopQ%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c

Rename WAIT FOR to WAIT in one more place

commit   : 59bc960fa12958ab863f4085091f2eb278bc7a0d    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 18 Sep 2026 10:05:15 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 18 Sep 2026 10:05:15 +0200    

Click here for diff

Commit a23ab4862cf renamed WAIT FOR to WAIT, but missed one error  
message.  In passing, also update a few code comments.  

M src/backend/commands/wait.c

Say what WAIT's snapshot restriction actually is

commit   : 26a3c0a45cc6017ee7f334c0ef63292d5e101b58    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Fri, 18 Sep 2026 08:22:55 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Fri, 18 Sep 2026 08:22:55 +0300    

Click here for diff

The reference page said WAIT "cannot be used in contexts where such a  
snapshot must remain active, including transactions running at isolation  
levels higher than READ COMMITTED", which reads as a blanket ban at those  
levels.  It is not one.  The rule the code enforces is that the current  
transaction must hold no snapshot, and a transaction-snapshot-mode  
transaction has no snapshot until its first query: WaitStmt is exempt in  
PlannedStmtRequiresSnapshot(), so the command itself does not take one.  
WAIT therefore works before that first query, which is the order an  
application wants anyway, and it is what 447aae13b03 set out to allow by  
keeping the wait snapshot-free.  
  
State the rule in terms of the snapshot rather than the isolation level,  
say that WAIT acquires none of its own and name the other ways to hold  
one, and give the consequence of holding one: it can delay replay, which  
standby_replay waits for and which the other standby modes ultimately  
depend on as well.  
  
The error for a held snapshot named the internal snapshot states instead  
of saying what the user did, and attached the isolation-level  
explanation as DETAIL unconditionally, so a READ COMMITTED session with a  
cursor was told its isolation level was too high.  Report what is held  
rather than how it is held, and emit the DETAIL only when the isolation  
level is in fact the reason.  
  
Reported-by: Sami Imseih <samimseih.pg@gmail.com>  
Reported-by: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/CAN12%2BYJddgAZzA36JZFX%2BYrnNR7Uubp9qWFz6ASs3v0kL30AMA%40mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ref/wait.sgml
M src/backend/commands/wait.c
M src/test/recovery/t/049_wait_for_lsn.pl

Don't quote the relation name twice in EXCEPT clause errors.

commit   : 926627bf9021137af66ac3bf21d1595af64ec66b    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 18 Sep 2026 10:58:00 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 18 Sep 2026 10:58:00 +0530    

Click here for diff

Commit a49b9cfd72 began reporting the EXCEPT clause relation with a  
schema-qualified name that quotes identifiers when needed, inside a  
message that already puts the name in quotes. So a schema or relation name  
that needs quoting came out quoted twice.  
  
Fix by building the qualified name as "%s.%s" without identifier quoting,  
so it renders like the qualified names in other backend error messages.  
The message text, and so its translations, is unchanged.  
RelationGetQualifiedRelationName() has no callers left, so remove it.  
  
Author: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwHfESBexa7fq99EvFCf31av=O9h9udnw22ymxmm6LMZzw@mail.gmail.com  
Backpatch-through: 19, where it was introduced  

M src/backend/catalog/pg_publication.c
M src/backend/utils/cache/relcache.c
M src/include/utils/relcache.h
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql

Fix pruning of DEFAULT partition in RANGE partitioned tables

commit   : b9d9e9bcc5786e48713d0d44de3f02c200bb7eff    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 17:14:21 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 17:14:21 +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   : 2631e08d791d3b504ddc6a4c790520f9878a1642    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 15:49:31 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 18 Sep 2026 15:49:31 +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

pg_plan_advice: Fix defects in JOIN_ORDER advice feedback.

commit   : e1d8f81d4961ca6c4228eb9a3ab5d36168008e42    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 17 Sep 2026 11:15:52 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 17 Sep 2026 11:15:52 -0400    

Click here for diff

This commit fixes several related problems. All of these problems  
escaped testing for the same reason: they do not occur when only  
generated advice is supplied, and therefore test_plan_advice was  
incapable of detecting these shortcomings.  
  
First, prior to this commit, the advice feedback code never regarded  
an unordered sublist of a JOIN_ORDER specification as matching an  
unrolled join. As a result, when JOIN_ORDER() advice contained  
unordered sublists, the advice feedback tended to be "matched, failed"  
even when the advice worked exactly as intended. Only the case where  
an unordered sublist was implemented by a plan shape not subject to  
unrolling, such as a partitionwise join, worked properly.  
  
Second, prior to this commit, a join order sublist in the initial  
position wasn't properly handled. Note that this overlaps with the  
problem described in the previous paragraph; JOIN_ORDER({a b} c) was  
broken both because of the unordered sublist and because of the  
sublist being in the initial position. However, there's more to this  
case: JOIN_ORDER((a b) c) means the same as JOIN_ORDER(a b c), but the  
advice feedback code didn't know that, and would generate "matched,  
failed" for the former case even when everything was working.  
  
Finally, prior to this commit, advice feedback didn't correctly handle  
single-element sublists. Those are pretty nonsensical, since by  
definition a join involves at least 2 tables, so we could just ban  
that case. Instead, at least for now, I've chosen to make advice  
feedback handle such cases in the same way that advice enforcement  
already does: the extra grouping levels are simply disregarded, so  
that JOIN_ORDER({a} ((b))) is enforced in the same way as, and also  
gets the same advice feedback as, JOIN_ORDER(a b).  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  

M contrib/pg_plan_advice/expected/join_order.out
M contrib/pg_plan_advice/expected/partitionwise.out
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_plan_advice/sql/join_order.sql
M contrib/pg_plan_advice/sql/partitionwise.sql

Change GEQO fitness comparisons to consider disabled_nodes.

commit   : c9c660e6ae03027615adff90cf4b26da5f8f97c1    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 17 Sep 2026 09:28:31 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 17 Sep 2026 09:28:31 -0400    

Click here for diff

Prior to v18, the total cost of a plan was just one number, a  
floating-point value. Commit e22253467942fdb100087787c3e1e3a8620c54b2  
introduced a second component, the number of disabled_nodes at or  
below that level of the plan tree. Unfortunately, I (rhaas) failed  
to realize that GEQO extracts the cost from each candidate plan and  
compares it directly as a measure of fitness.  
  
This means that, at least in principle, it's possible for GEQO to  
prefer a plan with more disabled_nodes and lower cost over one with  
fewer disabled_nodes and higher cost, which is incorrect. It may be  
possible for that to become a practical issue in v18, but it's much  
more likely to become an issue in v19 due to pg_plan_advice. Hence,  
since the straightforward fix breaks ABI compatibility, back-patch  
only to v19.  
  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com  

M src/backend/optimizer/geqo/geqo_eval.c
M src/backend/optimizer/geqo/geqo_main.c
M src/backend/optimizer/geqo/geqo_misc.c
M src/backend/optimizer/geqo/geqo_pool.c
M src/include/optimizer/geqo.h
M src/include/optimizer/geqo_gene.h
M src/tools/pgindent/typedefs.list

Fix postmaster crash on whitespace-only oauth_validator_libraries

commit   : bca67e5a33b07180c2f1703faf4443f2a1b92134    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 17 Sep 2026 14:52:30 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 17 Sep 2026 14:52:30 +0200    

Click here for diff

The check_oauth_validator check for an empty validator list didn't test  
for a string with only whitespace, which would cause the postmaster to  
crash.  Instead of testing for the empty string cases, pass the config  
value to SplitDirectoriesString unconditionally.  If an empty list is  
returned then the input string was empty.  Since pstrdup cannot handle  
NULL, assert that the string ie set.  While users cannot set the string  
to NULL, it is initialized to NULL so guard against programmer error.  
  
Check the parsed list instead.  Assert that the GUC string is non-NULL  
before pstrdup(); users cannot set it to NULL, but the C variable is  
initialized that way.  
  
This also adds a TAP test that reloads a whitespace-only setting after  
pg_hba_file_rules and waits until the existing backend sees the restored  
GUC.  
  
Author: Grigorev Jurij <ju.grigorev@ftdata.ru>  
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/04fa84f6ebbe400f940e179ebe1070e9@localhost.localdomain  
Backpatch-through: 18  

M src/backend/libpq/auth-oauth.c
M src/test/modules/oauth_validator/t/001_server.pl

Have the REPACK decoding worker use timeout values from the steering backend

commit   : a62ff0829d6b151a7107f6ae7f7f90b52405a247    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 17 Sep 2026 12:46:43 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 17 Sep 2026 12:46:43 +0200    

Click here for diff

The worker connects as the table owner in a new session, so a role- or  
database-level lock_timeout and transaction_timeout unhelpfully apply to  
it, possibly canceling the wait for older transactions.  This cannot be  
overridden by the REPACK calling session.  Fix by passing the timeout  
values from the steering backend via the DecodingWorkerShared struct and  
adopting these values in the worker; this way, values from session-local  
SET reach the worker too.  
  
In passing, remove a pointless member from the same struct.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAGRkXqTYaBjFvjtjPb1+=sZWvt93=2c472bmM+xdG7w9ZvAydA@mail.gmail.com  

M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
M src/include/commands/repack_internal.h

Tolerate partial pgstats entries in pgstat_gc_entry_refs()

commit   : 16706f1f4dc202d502f07f7b14bb600eb0daef92    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 17 Sep 2026 19:25:12 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 17 Sep 2026 19:25:12 +0900    

Click here for diff

pgstat_get_entry_ref_cached() inserts a local entry_ref with  
shmem-related fields set to NULL, expecting pgstat_get_entry_ref() (its  
sole caller) to fill them up before returning.  If an ERROR happens  
while pgstat_get_entry_ref() runs, it could be possible to finish with a  
local pgstats entry partially filled.  
  
This could lead to a crash of pgstat_gc_entry_refs(), which tolerates a  
NULL shared_stats in an assertion but unconditionally dereferenced its  
"dropped" and "generation" fields.  
  
This extends 4069df21beb8, being a cheap insurance against NULL pointer  
dereference, if some code paths of pgstat_get_entry_ref() are not able  
to perform any cleanup actions (for example after a dsm_create()  
throwing an ERROR).  
  
Reviewed-by: Grigorev Jurij <ju.grigorev@ftdata.ru>  
Discussion: https://postgr.es/m/aqtiKTvl519bu8-V@paquier.xyz  
Backpatch-through: 15  

M src/backend/utils/activity/pgstat_shmem.c

Fix REPACK worker startup and shutdown sequences

commit   : 16735af3e39eeb6e3a2c2bcc1e4a17eabc74d377    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 17 Sep 2026 11:44:57 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 17 Sep 2026 11:44:57 +0200    

Click here for diff

A REPACK background worker can fail to start for various reasons, but  
the REPACK steering process was not handling them correctly.  For  
instance, the steering process waits on a condition variable, but it  
would simply hang if the worker doesn't send the signal.  (A signal  
would be sent by postmaster, but it would wake up the process only to be  
ignored and continue sleeping.)  Fix this by splitting the wait in two:  
first wait for the worker to attach to the error queue, and then wait on  
the condition variable as before.  
  
The shutdown sequence can also get stuck, if the message queue gets full  
while trying to shut down (this can apparently happen if the log level  
is set to very noisy).  Previously the worker would send a signal and  
then detach; but the steering process can receive that signal, act on  
it, then fail to wake up to handle the detach, sleeping indefinitely.  
Fix this by having the worker send a Terminate message, which the  
steering process can react to.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Author: Shihao Zhong <zhong950419@gmail.com>  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CALj2ACVAxA9HxvFe8HSspTJ-UO4Aoz%3DkuQdZBeLrod0gqUxH3g%40mail.gmail.com  
Discussion: https://postgr.es/m/apBpOVZOyqrakEr_@nathan  

M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
M src/include/libpq/protocol.h

Fix typos and grammar of some comments

commit   : be00f041a331d5e6a49f21f139c9518542bdf9b3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 17 Sep 2026 16:50:31 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 17 Sep 2026 16:50:31 +0900    

Click here for diff

These errors have been reported to the mailing lists in the last few  
weeks.  Some of the spots fixed have been noticed by myself during  
independent code reviews, but not all.  

M contrib/amcheck/verify_heapam.c
M src/backend/access/common/toast_internals.c
M src/backend/access/index/genam.c
M src/backend/replication/logical/logicalctl.c
M src/bin/pg_ctl/t/001_start_stop.pl
M src/include/mb/pg_wchar.h
M src/include/utils/rel.h
M src/include/varatt.h
M src/port/path.c
M src/test/modules/test_extensible/expected/test_extensible.out
M src/test/modules/test_extensible/sql/test_extensible.sql

doc: Say which LSN gives read-your-writes with WAIT

commit   : 2af020eacb8b74232a0570f72a05dd1f274f68de    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 17 Sep 2026 09:33:20 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 17 Sep 2026 09:33:20 +0300    

Click here for diff

The reference page and the read-your-writes section both presented  
WAIT in standby_replay mode as enough for read-your-writes, without  
saying which LSN to wait for.  Read as written, an LSN taken after the  
last statement but before COMMIT would do, and it would not: the standby  
position WAIT compares against is the end of the last replayed record, so  
a target that falls inside the COMMIT record is satisfied while that  
record is still unapplied.  
  
Say that the target must be at or after the end of the write  
transaction's COMMIT record, and note in the example that autocommit is  
what puts the UPDATE's commit before the call that reads the position.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/CAN12%2BYKN7gXb1o9bDWgfA%3D6wjDrqNEgt%2BrXJiAWXgPCXQ5TqpA%40mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/high-availability.sgml
M doc/src/sgml/ref/wait.sgml

doc: Explain when to use the WAIT NO_THROW option

commit   : e87c55f4d8b3fc3723e1f5d8ade7278e33bbb869    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 17 Sep 2026 09:32:17 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 17 Sep 2026 09:32:17 +0300    

Click here for diff

The description of NO_THROW covered what the option does but not when an  
application would want it.  Explain that it suits callers that treat  
timeout or not in recovery as expected results to be handled as part of  
ordinary control flow, note the obligation to check the returned status,  
and give the reason to omit the option.  
  
Be precise about the option's scope: it changes only how those two wait  
outcomes are reported.  Soften the description's claim that the command  
"returns a status string instead of throwing errors" accordingly, and say  
that invalid input still raises an error, as does any condition checked  
before the wait begins.  Name two of those conditions as examples rather  
than listing them, since the set grows.  
  
Author: Rithvika Devisetti <devisettirithvika@gmail.com>  
Reported-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Kiran Kaki <itskkpg@gmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/14415b05-16d0-446f-ba7d-c891db8b3406%40eisentraut.org  
Backpatch-through: 19  

M doc/src/sgml/ref/wait.sgml

Fix assertion after aborting internal subtransaction at transaction end

commit   : 999ce9bcd80890c3d723e113bb0337c900f9f249    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 17 Sep 2026 14:24:22 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 17 Sep 2026 14:24:22 +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

Distinguish publication exclusions in object addresses.

commit   : 94670ba6d560b0738992b9bb7d0313d7d90af1d1    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 17 Sep 2026 09:14:21 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 17 Sep 2026 09:14:21 +0530    

Click here for diff

A pg_publication_rel entry can represent either an explicitly published  
relation or a table excluded from a FOR ALL TABLES publication, but the  
object address code treated every entry as a published relation without  
checking prexcept. EXCEPT entries thus appeared as ordinary  
published-table mappings in dependency messages, pg_identify_object(),  
and pg_identify_object_as_address().  
  
Report such entries as "publication excluded relation" instead, with  
object identities indicating that the table is excluded from the  
publication. pg_get_object_address() also accepts this new object type,  
so that the output of pg_identify_object_as_address() can still be  
passed back to it to look up the same object. "publication relation"  
now resolves only non-EXCEPT entries, and "publication excluded  
relation" only EXCEPT entries.  
  
Oversight in commit fd366065e06.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Author: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwHfESBexa7fq99EvFCf31av=O9h9udnw22ymxmm6LMZzw@mail.gmail.com  
Backpatch-through: 19, where it was introduced  

M src/backend/catalog/aclchk.c
M src/backend/catalog/objectaddress.c
M src/backend/commands/dropcmds.c
M src/backend/commands/event_trigger.c
M src/backend/commands/seclabel.c
M src/include/nodes/parsenodes.h
M src/test/regress/expected/object_address.out
M src/test/regress/expected/publication.out
M src/test/regress/sql/object_address.sql
M src/test/regress/sql/publication.sql

pg_plan_advice: Disallow partition name without partition schema.

commit   : 63920eb099ab7e0e9d9eb49a3aa392c9441d52ef    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 16 Sep 2026 21:03:58 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 16 Sep 2026 21:03:58 -0400    

Click here for diff

Up until now, pg_plan_advice has had a feature that allows an advice  
target to mention a partition name but omit the partition schema;  
that is, something like SEQ_SCAN(foo/bar) forces a sequential scan on  
every child of table foo whose partition name is bar, regardless of  
the schema in which bar appears. However, that feature turns out to  
have a nasty design flaw: while advice enforcement handles this case  
just fine, the advice feedback code doesn't know about it and will  
mark such advice as "matched, failed" even when everything worked  
perfectly. Unfortunately, there seems to be no simple code fix for  
this problem.  
  
Since the release of PostgreSQL 19 is imminent, take the conservative  
course and revert this feature of pg_plan_advice. In other words,  
require the partition schema whenever the partition name is present.  
You must now write e.g. SEQ_SCAN(foo/public.bar) rather than just  
SEQ_SCAN(foo/bar). This doesn't affect any cases where automatically  
generated advice is supplied, since generated advice has always  
included the partition schema anyway. Manually written advice will  
have to conform to the new, stricter rule. For a later release, we  
can consider whether to again relax this restriction in some way,  
but now is not the time to design new things.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com  

M contrib/pg_plan_advice/README
M contrib/pg_plan_advice/expected/join_order.out
M contrib/pg_plan_advice/expected/partitionwise.out
M contrib/pg_plan_advice/expected/syntax.out
M contrib/pg_plan_advice/pgpa_ast.c
M contrib/pg_plan_advice/pgpa_ast.h
M contrib/pg_plan_advice/pgpa_identifier.c
M contrib/pg_plan_advice/pgpa_parser.y
M contrib/pg_plan_advice/pgpa_trove.c
M contrib/pg_plan_advice/sql/join_order.sql
M contrib/pg_plan_advice/sql/partitionwise.sql
M contrib/pg_plan_advice/sql/syntax.sql
M doc/src/sgml/pgplanadvice.sgml

pg_plan_advice: Disallow empty sublists within JOIN_ORDER()

commit   : 5e595d659fdb4829e910a1c4122ad4dec9dd0bd3    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 16 Sep 2026 14:44:42 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 16 Sep 2026 14:44:42 -0400    

Click here for diff

Commit 8c9c2e5c09aeda713640ccb26bfca0fdccc310d5 fixed a similar  
issue for FOREIGN_JOIN(). Handle this case similar to the way that  
commit handled that case.  
  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  

M contrib/pg_plan_advice/expected/syntax.out
M contrib/pg_plan_advice/pgpa_parser.y
M contrib/pg_plan_advice/sql/syntax.sql

Fix multixact members truncation at page boundary

commit   : fcc0e27f45e2d8dc6046435908a48626c91d3d84    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 16 Sep 2026 14:52:12 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 16 Sep 2026 14:52:12 +0300    

Click here for diff

Like in PerformOffsetsTruncation() and e.g. in TruncateSUBTRANS(),  
need to step back to previous page at page boundary, to avoid passing  
a cutoff page to SimpleLruTruncate() that hasn't been created  
yet. Otherwise you can get a bogus 'LOG: could not truncate directory  
"pg_multixact/members": apparent wraparound' message in the log.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://www.postgresql.org/message-id/20260827231757.78.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Say in the FSM README why its hint writes still need full page images

commit   : a4f18fd8f2800084304844060fe5564136e6b3e5    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 16 Sep 2026 13:49:59 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 16 Sep 2026 13:49:59 +0300    

Click here for diff

The Recovery section said we would "operate correctly without the full page  
images that MarkBufferDirtyHint() provides", offering them only as a way to  
lose less slot knowledge to RBM_ZERO_ON_ERROR.  That is true of freespace.c,  
which passes RBM_ZERO_ON_ERROR on every read, and false of the system around  
it, which reads the same files and does verify checksums.  Reading it as a  
licence to dirty FSM pages without a full page image is what led to  
c06d1a4ba6b, since reverted.  
  
Say instead that RBM_ZERO_ON_ERROR is a property of this directory rather  
than of the fork, and name the readers that do not share it:  
RelationCopyStorage(), RelationCopyStorageUsingBuffer(), base backups and  
pg_checksums.  Rather than presenting today's behavior as the only one  
possible, note that the alternative is for all of that code to skip checksum  
validation of the FSM.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/20260901211837.f6.noahmisch%40microsoft.com  

M src/backend/storage/freespace/README

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

commit   : d237a7a83668bc228f7c58f104ffb25cbb607a1a    
  
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 index rebuild progress reporting for REPACK (CONCURRENTLY)

commit   : 0765b48874a3fcabadfcaa493d068ec6507e7fc7    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 16 Sep 2026 18:38:37 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 16 Sep 2026 18:38:37 +0900    

Click here for diff

Previously, during REPACK (CONCURRENTLY), index_rebuild_count in  
pg_stat_progress_repack and pg_stat_progress_cluster did not advance  
as indexes were rebuilt. This made it impossible for users monitoring the  
operation to tell how many indexes had been completed.  
  
Fix this by incrementing the count after each index is built on the new  
heap, so that both views report the number of completed index builds.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/CAHGQGwFUsrBvTurkSU8TEc=DZTunqteUXrasseqNMT7AMBZKRw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/repack.c

Suppress progress reporting when creating TOAST indexes

commit   : 4b445479f9e0ea5039c782e9dab35ec9af6b6d4d    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 16 Sep 2026 18:36:43 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 16 Sep 2026 18:36:43 +0900    

Click here for diff

Previously, when REPACK, CLUSTER, or VACUUM FULL created a transient TOAST  
table, index_rebuild_count in pg_stat_progress_repack and  
pg_stat_progress_cluster reported 2 before any indexes on the main table  
had been rebuilt. This could mislead users monitoring the operation.  
  
This happened because creating the TOAST index writes the CREATE INDEX phase  
to the same progress slot used for the index rebuild count of the enclosing  
command.  
  
Fix this by passing INDEX_CREATE_SUPPRESS_PROGRESS when creating a TOAST  
index, preserving the progress information of the enclosing command and  
keeping the count at zero until the main-table indexes are rebuilt.  
  
Author: Adam Lee <adam8157@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/aj4gJQMba0kClQmj@Mac  
Backpatch-through: 19  

M src/backend/catalog/toasting.c

Message style improvement

commit   : dfb474ca6d8cb817107a247a5c38fa660edc487b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 16 Sep 2026 09:34:06 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 16 Sep 2026 09:34:06 +0200    

Click here for diff

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

doc: Fix primary status update WAL position description

commit   : 2b96ddcf21580a870ca6d439e56f669fabebd51b    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 16 Sep 2026 16:54:56 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 16 Sep 2026 16:54:56 +0900    

Click here for diff

Commit 5f3a49abf7f changed the primary status update message to report the  
end of the last inserted WAL record instead of the WAL write position.  
However, the protocol documentation still described the WAL position field as  
the latest WAL write position, which no longer matches the message sent by  
walsender.  
  
Update the description of the WAL position field to indicate the end of the  
last inserted WAL record, matching the implementation.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwFn2QfpHDR6cWxd98tqNb5vyguEis8rtqnqidFR36p4QQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/protocol.sgml

pgindent: Fix indentation of alignas() in struct members

commit   : 884f82ae2621cc8d983bb745ce6c8c1c9a971764    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 16 Sep 2026 08:59:47 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 16 Sep 2026 08:59:47 +0200    

Click here for diff

pg_bsd_indent doesn't know about alignas(), so a struct member  
declared with it is misindented unless it's the first member.  
  
Disguise each alignas(...) call as a plain identifier while  
indenting, restoring it afterward.  Stash the call's original text  
by index rather than embedding it in the placeholder: embedding only  
works for a single-token argument, and fails to match at all against  
nested parens (e.g. alignas(sizeof(x))) or a line break, silently  
skipping the disguise.  
  
There is currently no code affected by this, but there are some  
pending patches that would be.  
  
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>  
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>  
Discussion: https://postgr.es/m/94a128da-bf3e-46bd-9e2d-609573c484da@eisentraut.org  

M src/tools/pgindent/pgindent

pg_upgrade: Run test suite with initial OID higher than UINT32_MAX

commit   : 04c4c1c3a9636bb33875c039948795d7cd0da507    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Sep 2026 10:28:44 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Sep 2026 10:28:44 +0900    

Click here for diff

The test already used a pg_resetwal to bump the initial OID to be higher  
than UINT32_MAX after the main regression test suite has been run, to  
check that pg_upgrade was able to carry an 8-byte wide value.  This now  
happens set much earlier in the script, before running the main  
regression test suite.  
  
A small oid8-related check is added, while on it.  Perhaps this could be  
expanded to more objects and/or patterns later on.  It should be good  
enough as a starting point.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/aqd_gYs35v--sVlR@paquier.xyz  

M src/bin/pg_upgrade/t/002_pg_upgrade.pl

commit   : 87c6ef14f11705e690a9c54f91e0d97977ce333f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Sep 2026 10:00:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 16 Sep 2026 10:00:24 +0900    

Click here for diff

Some of the tests introduced by c68cba09dd7f in these two modules want  
to rely on out-of-line values (compressed and not compressed), but the  
values inserted that should be compressed were not (STORAGE EXTENDED).  
  
The tests are updated to do what they should, reusing a cheap trick to  
ensure out-of-line values coming from a different test in test_decoding.  
Some checks are added to ensure that the expected set of values is  
inserted.  
  
Reported-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/CAHWVJhGxVc4CpDd+mb=6YbeL2KHDUtsUC=R68y7NeMg1cO8QMg@mail.gmail.com  

M contrib/amcheck/expected/check_heap.out
M contrib/amcheck/sql/check_heap.sql
M contrib/test_decoding/expected/toast.out
M contrib/test_decoding/sql/toast.sql

Use hex_decode_safe() to speed up UUID input.

commit   : 72af14bccd2127bf20ddeaf198b78de46e9e892b    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 15 Sep 2026 15:07:08 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 15 Sep 2026 15:07:08 -0700    

Click here for diff

Previously, string_to_uuid() decoded one byte at a time, calling  
isxdigit() twice and strtoul() once for every pair of hexadecimal  
digits. Commit ec8719ccbfcd made hex_decode_safe() decode a run of  
hexadecimal digits in bulk, so add a fast path for the two common  
shapes: 32 contiguous hexadecimal digits, and the canonical  
8x-4x-4x-4x-12x form, each optionally wrapped in braces.  
  
Anything else, and any decoding error, falls back to the  
byte-at-a-time parser, so the accepted grammar and the error messages  
don't change. hex_decode_safe() also skips whitespace, which the UUID  
grammar forbids, so we treat a short decode as an error too. Rejecting  
an input that has a fast-path shape therefore costs a second  
parse. But this only happens for syntax-error cases, so it's not a  
problem in practice.  
  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: John Naylor <johncnaylorls@gmail.com>  
Discussion: https://postgr.es/m/CAD21AoCqeR4UQU77Q_yOMNNzJ7AVeiO5QZT+4HnzPm4Wm-e02Q@mail.gmail.com  

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

Have read_stream_reset reset pending_read_nblocks.

commit   : 862092932c9479b79732f3b441da05453ea5e06d    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 15 Sep 2026 14:36:47 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 15 Sep 2026 14:36:47 -0400    

Click here for diff

Otherwise, a read of blocks the stream is about to throw away can be  
started and then waited for.  read_stream_reset drains the stream by  
calling read_stream_next_buffer, whose look-ahead treats the zeroed  
distance as end of stream, leading to it spuriously performing the  
pending read.  This caused a pathological regression for a nested loop  
antijoin query when run with the upcoming index prefetching patch series  
applied.  
  
This bug affects all stable branches with the read stream, which was  
added to Postgres 17 by commit b5a9b18cd0b.  No backpatch for now,  
though, since without index prefetching the added overhead for realistic  
query plans is negligible.  
  
Author: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/CAH2-WzkKY8b42sZSPWJceT5Fn_THk3ZgcaM8ch3Hzw+XvhP0zQ@mail.gmail.com  

M src/backend/storage/aio/read_stream.c

Fail REPACK in presence of invalid indexes, take 2

commit   : 78142821dfd42a7ca1010811ce77ff7b96218741    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 15 Sep 2026 15:40:59 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 15 Sep 2026 15:40:59 +0200    

Click here for diff

Commit 0c5d6269614e was confused about which indexes are potentially  
problematic to rebuild: we thought only !indisready indexes could fail  
to rebuild, and thus would attempt to rebuild !indisvalid ones that are  
"ready" (that is, being maintained by DML but not yet completed).  
However, that's wrong, because it could be that the validation phase of  
such an index failed or was interrupted partway through.  So, have  
REPACK throw an error with all !indisvalid indexes, not just those  
!indisready.  
  
(!indisready implies !indisvalid, so this is an expansion of what  
happened with the previous commit.)  
  
Reported-by: shihao zhong <zhong950419@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAGRkXqRA4YetT8Nu3+1-45+ffTwi2bd1d1eDFME39Y9OPRMytQ@mail.gmail.com  

M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c

Add slot-based table AM index scan interface.

commit   : ddce1da5b1b1b4672e621c0da245e01474cbd4e8    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 15 Sep 2026 11:19:13 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Tue, 15 Sep 2026 11:19:13 -0400    

Click here for diff

Add table_index_getnext_slot, a new table AM interface that serves as  
the single entry point for both plain and index-only index scans that  
use amgettuple.  The table AM's index_scan_begin callback resolves which  
implementation the scan will use and stores it in an IndexScanDesc  
function pointer (xs_getnext_slot), which table_index_getnext_slot  
dispatches through.  
  
The interface intentionally avoids using fixed TableAmRoutine members,  
allowing the table AM to dynamically register an implementation based on  
conditions known at the start of each scan.  That way a table AM can  
provide specialized variants that help the compiler produce more  
efficient code.  heapam provides two implementations: one for plain  
index scans, and one for index-only scans.  An upcoming commit that adds  
the amgetbatch interface will add two more.  (Table AMs can opt to  
provide a single generic implementation, or to provide many specialized  
implementations, as requirements dictate.)  
  
heapam's xs_getnext_slot implementations make aggressive use of forced  
inlining to ensure that plain and index-only code paths are fully  
specialized at compile time, without duplicating the code they have in  
common.  This specialization is necessary to keep icache and iTLB  
pressure to a minimum.  
  
The new interface moves visibility map checks required by index-only  
scans out of the executor (and selfuncs.c) and into heapam, enabling  
batching of visibility map lookups (though for now we continue to just  
perform retail lookups).  Using the new higher level slot-based  
interface greatly simplifies nodeIndexonlyscan.c, which no longer has to  
deal with the visibility map directly.  More importantly, this is a  
significant architectural improvement: table AMs can now implement  
index-only scans that are not tied to heapam's visibility map.  
  
Two users of the now removed table_index_fetch_tuple interface,  
_bt_check_unique and unique_key_recheck, fundamentally need to pass a  
TID to the table AM to perform constraint enforcement.  Neither actually  
performs an index scan (even though their TIDs are taken from an index),  
so neither has any use for most of the index scan machinery.  Switch  
these callers over to fetch_tid, a new special-purpose table AM  
interface for constraint enforcement code.  All true index scan callers  
now use the new slot-based interface.  (Note that fetch_tid doesn't  
perform on-access pruning, which matches how things worked prior to  
Postgres 12 commits c2fe139c2 and 71bdc99d0.)  
  
The VISITED_PAGES_LIMIT mechanism used by get_actual_variable_range to  
cap scan overhead during planning is reworked to go through a new scan  
descriptor field (xs_visited_pages_limit), rather than having selfuncs.c  
count heap page fetches and terminate the scan itself.  This is  
necessary because callers that use the new slot-based interface no  
longer have direct access to which heap blocks were fetched.  Similarly,  
nodeIndexonlyscan.c can no longer use InstrCountTuples2 to count heap  
fetches during an EXPLAIN ANALYZE.  EXPLAIN ANALYZE now obtains this  
information from a new IndexScanInstrumentation field, which table AMs  
are required to maintain during index-only scans.  
  
Though independently useful, this commit is preparatory work for an  
upcoming commit that will add an amgetbatch index AM interface, where  
the table AM takes full responsibility for managing the progress of  
index scans.  The table AM determines when to request the next batch  
from the index AM, at a time of its choosing.  A follow-on commit will  
rely on this to prefetch table blocks during index scans.  Having a  
single entry point for all index scan callers unambiguously puts the  
table AM in control of the scan.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/CAH2-WzmYqhacBH161peAWb5eF=Ja7CFAQ+0jSEMq=qnfLVTOOg@mail.gmail.com  

M contrib/amcheck/verify_nbtree.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/heap/heapam_indexscan.c
M src/backend/access/index/genam.c
M src/backend/access/index/indexam.c
M src/backend/access/nbtree/nbtinsert.c
M src/backend/access/table/Makefile
M src/backend/access/table/meson.build
M src/backend/access/table/tableam.c
A src/backend/access/table/tableam_indexscan.c
M src/backend/access/table/tableamapi.c
M src/backend/commands/constraint.c
M src/backend/commands/explain.c
M src/backend/commands/repack.c
M src/backend/executor/execIndexing.c
M src/backend/executor/execReplication.c
M src/backend/executor/nodeBitmapIndexscan.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/backend/utils/adt/ri_triggers.c
M src/backend/utils/adt/selfuncs.c
M src/include/access/genam.h
M src/include/access/heapam.h
M src/include/access/relscan.h
M src/include/access/tableam.h
A src/include/access/tableam_indexscan.h
M src/include/catalog/pg_opclass.dat
M src/include/executor/instrument_node.h
M src/include/nodes/execnodes.h
M src/test/modules/index/test_indexscan.c
M src/tools/pgindent/typedefs.list

doc: Database and tablespace size functions throws error

commit   : 1a3e782e762248b4a63294936224458571a0eb5a    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 15 Sep 2026 13:46:52 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 15 Sep 2026 13:46:52 +0200    

Click here for diff

Commit b6463ea6ef3e46 added an explicit ereport on missing object  
to pg_database_size and pg_tablespace_size, but the documentation  
wasn't updated to match.  
  
Author: Zhong ShiHao <zhong950419@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqQSegqDnkRf344G=80mJMn78o9u=auHnx=u1jf=XpuE0A@mail.gmail.com  
Backpatch-through: 18  

M doc/src/sgml/func/func-admin.sgml

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

commit   : fb60892f4034017e77b8d4376d3ca8937dcbbab2    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Tue, 15 Sep 2026 11:47:05 +0100    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Tue, 15 Sep 2026 11:47:05 +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
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/on_conflict_probe_window.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/on_conflict_probe_window.spec

Revert UPDATE/DELETE FOR PORTION OF

commit   : a4b26b8f7cd07a3e7f0cba550c30db142329e065    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 15 Sep 2026 12:12:37 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 15 Sep 2026 12:12:37 +0200    

Click here for diff

List of commits reverted:  
  
  8e72d914c52  Add UPDATE/DELETE FOR PORTION OF  
  b6ccd30d8ff  Add isolation tests for UPDATE/DELETE FOR PORTION OF  
  33db6c4baf1  Fix DELETE/UPDATE FOR PORTION OF with rules  
  7b22f15a015  Add psql tab completion for FOR PORTION OF clause  
  7ca8c942967  Fix FOR PORTION OF with non-updatable view columns  
  993a7aa0e4a  Fix cross-leftover pollution in FOR PORTION OF insert triggers  
  7ac030d5b15  Require UPDATE permission on FOR PORTION OF column  
  f0aedc7cb0e  Small terminology fixes in comments  
  7d13b03a2e6  Fix FOR PORTION OF for inheritance children  
  a272a58b942  Move FOR PORTION OF volatile check into planner  
  a40fdf65886  Reject child partition FDWs in FOR PORTION OF  
  bc3ae886a75  Forbid FOR PORTION OF with WHERE CURRENT OF  
  e994f956e48  Forbid generated columns in FOR PORTION OF  
  dfce19c2300  Forbid FOR PORTION OF on views with INSTEAD OF triggers  
  20fe90bbb93  Fix RLS checks for FOR PORTION OF leftover rows  
  9170c8b7169  Test what BEFORE UPDATE triggers do to FOR PORTION OF  
  7090c696cc9  Deparse FOR PORTION OF using the range column's current name.  
  62d1a5f8be8  Avoid RETURNING side effects for FOR PORTION OF leftovers.  
  9924e2d900b  Enforce WITH CHECK OPTION on DELETE FOR PORTION OF leftovers  
  c16a1b4f2ce  Fix error code for null FOR PORTION OF target  
  610976420a3  Fix assertion failures in DELETE FOR PORTION OF tuple routing  
  438f027238c  Resolve untyped parameters in FOR PORTION OF FROM/TO bounds  
  140fdfcdf12  Don't evaluate the FOR PORTION OF target under EXPLAIN  
  
Discussion: https://www.postgresql.org/message-id/62bf70cc-dc33-4188-8070-a8c177bb61de%40eisentraut.org  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M contrib/test_decoding/expected/ddl.out
M contrib/test_decoding/sql/ddl.sql
M doc/src/sgml/ddl.sgml
M doc/src/sgml/dml.sgml
M doc/src/sgml/glossary.sgml
M doc/src/sgml/images/Makefile
M doc/src/sgml/images/meson.build
D doc/src/sgml/images/temporal-delete.svg
D doc/src/sgml/images/temporal-delete.txt
D doc/src/sgml/images/temporal-isolation.svg
D doc/src/sgml/images/temporal-isolation.txt
D doc/src/sgml/images/temporal-update.svg
D doc/src/sgml/images/temporal-update.txt
M doc/src/sgml/ref/create_policy.sgml
M doc/src/sgml/ref/create_publication.sgml
M doc/src/sgml/ref/create_view.sgml
M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/update.sgml
M doc/src/sgml/trigger.sgml
M src/backend/commands/copyfrom.c
M src/backend/executor/execMain.c
M src/backend/executor/execPartition.c
M src/backend/executor/nodeModifyTable.c
M src/backend/nodes/nodeFuncs.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/util/pathnode.c
M src/backend/parser/analyze.c
M src/backend/parser/gram.y
M src/backend/parser/parse_agg.c
M src/backend/parser/parse_collate.c
M src/backend/parser/parse_expr.c
M src/backend/parser/parse_func.c
M src/backend/parser/parse_merge.c
M src/backend/rewrite/rewriteHandler.c
M src/backend/rewrite/rowsecurity.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/cache/lsyscache.c
M src/bin/psql/t/010_tab_completion.pl
M src/bin/psql/tab-complete.in.c
M src/include/catalog/catversion.h
M src/include/executor/executor.h
M src/include/nodes/execnodes.h
M src/include/nodes/parsenodes.h
M src/include/nodes/pathnodes.h
M src/include/nodes/plannodes.h
M src/include/nodes/primnodes.h
M src/include/optimizer/pathnode.h
M src/include/parser/analyze.h
M src/include/parser/kwlist.h
M src/include/parser/parse_node.h
M src/include/utils/lsyscache.h
D src/test/isolation/expected/for-portion-of.out
M src/test/isolation/isolation_schedule
D src/test/isolation/specs/for-portion-of.spec
D src/test/regress/expected/for_portion_of.out
M src/test/regress/expected/privileges.out
M src/test/regress/expected/rowsecurity.out
M src/test/regress/expected/updatable_views.out
M src/test/regress/expected/without_overlaps.out
M src/test/regress/parallel_schedule
D src/test/regress/sql/for_portion_of.sql
M src/test/regress/sql/privileges.sql
M src/test/regress/sql/rowsecurity.sql
M src/test/regress/sql/updatable_views.sql
M src/test/regress/sql/without_overlaps.sql
M src/test/subscription/t/034_temporal.pl
M src/tools/pgindent/typedefs.list

Fix indirect include

commit   : f292187f375738ee8e921ab6bd3fa011e2cc2813    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 15 Sep 2026 11:06:49 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 15 Sep 2026 11:06:49 +0200    

Click here for diff

Commit 0ee83dd4a99 added a call of assign_record_type_typmod() in  
postgres_fdw.c, but relied on utils/typcache.h being included via  
nodes/execnodes.h.  That was put there as part of the FOR PORTION OF  
feature, and if that were to change, there would be a possible  
unrelated compilation failure.  To fix, add the required include  
directly.  

M contrib/postgres_fdw/postgres_fdw.c

doc: Synopsis placeholder consistency

commit   : ff39a858b984d8088caa2a9777948d211f549b65    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 15 Sep 2026 10:31:25 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 15 Sep 2026 10:31:25 +0200    

Click here for diff

Make the placeholder for SUPPORT for CREATE AGGREGATE match the  
previously existing use for CREATE FUNCTION (psfunc ->  
support_function).  

M doc/src/sgml/ref/create_aggregate.sgml

amcheck: Fix thinko with check of TOASTed attribute

commit   : 0d34736e4c1629ba12fd4c848984308f2037998f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 16:44:42 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 16:44:42 +0900    

Click here for diff

A chunk_id type that does not match with one of the expected values (oid  
or oid8) was missing a "return" clause.  This caused the code to report  
two corruptions instead of one.  
  
Oversight in 6e58d6356fcb.  
  
Discussion: https://postgr.es/m/aqju1K96ex28yz2X@paquier.xyz  

M contrib/amcheck/verify_heapam.c

Add support for external on-disk TOAST pointers as oid8

commit   : 6e58d6356fcb58f06bfcebb5bfa808660e9531d2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 15:00:01 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 15:00:01 +0900    

Click here for diff

A TOAST table whose chunk_id column is oid8 is now fed a 64-bit object  
ID thanks to the introduction of a new vartag_external called  
VARTAG_ONDISK_OID8, coupled with a new varatt_external_oid8.  The only  
difference between the existing varatt_external_oid and the new  
varatt_external_oid8 is an extra 4 bytes to store 8 bytes worth an  
object ID, spread across two uint32 to force alignement as memcmp may be  
used for TOAST pointer comparison (line varatt_external_oid).  
  
There is a one-one mapping between the vartag_external and the type of a  
chunk_id:  
- An oid8 chunk_id implies the use of VARTAG_ONDISK_OID8.  
- An oid chunk_id implies the use of VARTAG_ONDISK_OID.  
  
There are a couple of changes worth noting:  
- In toast_tuple_init(), for the comparison of old and new external  
values with a memcmp over VARSIZE_EXTERNAL(old_value).  Now that  
multiple types of external on-disk TOAST pointers are possible, we  
need to add a check based on the vartag used by an old or new value.  
One of the tests added by c68cba09dd7f cover this case.  
- In toast_tuple_find_biggest_attribute(), the initial "biggest_size"  
depends on the type of chunk_id.  This needs a change in RelationData to  
track the chunk_id type; this cached data is filled on demand.  
- In detoast.h, toast_external_info_get() and toast_external_data act as  
a translation layer to retrieve all the data associated to an Oid or an  
Oid8 TOAST pointer, without the need to worry about the vartag dealt  
with.  The introduction of this function and structure has reduced a lot  
of code churn that existed in the initial versions of this patch, as per  
a suggestion from Bharath Rupireddy.  
- amcheck is updated to check the vartag <-> chunk_id type mapping  
requirements, handling both vartags depending on the underlying type of  
chunk_id on the TOAST table.  
  
Bump catalog version, due to at least the change of VARTAG_SIZE().  
(This counts for the bump forgotten in a625fc570c22..)  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz  

M contrib/amcheck/verify_heapam.c
M doc/src/sgml/storage.sgml
M src/backend/access/common/detoast.c
M src/backend/access/common/toast_compression.c
M src/backend/access/common/toast_internals.c
M src/backend/access/heap/heaptoast.c
M src/backend/access/table/toast_helper.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/cache/relcache.c
M src/include/access/detoast.h
M src/include/access/heaptoast.h
M src/include/catalog/catversion.h
M src/include/utils/rel.h
M src/include/utils/relcache.h
M src/include/varatt.h
M src/tools/pgindent/typedefs.list

commit   : c68cba09dd7fb2cca1fdddfcf8e0fe206e97a8a4    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 11:30:45 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 11:30:45 +0900    

Click here for diff

The tests added by this commit cover a large ground in terms of the  
introduction of oid8 in TOAST tables, with the following areas covered,  
with all the gaps found during the development of the feature:  
- Tables with oid8 TOAST tables in general, under strings.sql.  
- ALTER TABLE with attribute manipulations in transactions and different  
toast_table_value settings.  
- Relation rewrites, not affecting the TOAST relation after initial  
creation with VACUUM FULL, CLUSTER, REPACK.  
- pg_column_compression().  
- test_decoding, for external and extended TOAST data.  
- amcheck, external and extended storage with heap checked.  
- UPDATE with out-of-line datums that belongs to another TOAST table.  
This offers coverage for toast_tuple_init(), where external vartags  
could be mixed once multiple on-disk external TOAST pointers can  
co-exist.  This pattern can be triggered with asan/ubsan, with an  
out-of-bound memcpy when unpatched.  
  
These tests are added before the new vartag_external, mostly as a matter  
of avoiding dead code in the tree.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xy  

M contrib/amcheck/expected/check_heap.out
M contrib/amcheck/sql/check_heap.sql
M contrib/test_decoding/expected/toast.out
M contrib/test_decoding/sql/toast.sql
M src/test/regress/expected/compression.out
M src/test/regress/expected/strings.out
M src/test/regress/sql/compression.sql
M src/test/regress/sql/strings.sql

Add support for toast_value_type=oid8

commit   : a625fc570c22e199471e1a2656e2c32b8dc0c0fd    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 08:37:06 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 08:37:06 +0900    

Click here for diff

This commit adds the possibility to define TOAST tables with oid8 as  
their chunk_id, based on the reloption toast_value_type.  All the  
external TOAST pointers still rely on varatt_external_oid and a single  
vartag.  The values inserted in the oid8 TOAST tables are fed from the  
OID8 value generator, casted to OID for now, as we do not have a  
vartag_external able to store Oid8 values yet.  
  
An upcoming commit will add support for a new vartag_external and its  
associated structures, with the code being able to use a different  
on-disk external TOAST pointer depending on the attribute type of  
chunk_id defined in TOAST relations.  
  
All the changes done here are mechanical, mostly around the TOAST code  
that needs to be able to do chunk_id lookups based on the two types now  
supported.  
  
Bump catalog version.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xy  

M contrib/amcheck/verify_heapam.c
M doc/src/sgml/ref/create_table.sgml
M doc/src/sgml/storage.sgml
M src/backend/access/common/reloptions.c
M src/backend/access/common/toast_internals.c
M src/backend/access/heap/heaptoast.c
M src/backend/catalog/toasting.c
M src/backend/replication/logical/reorderbuffer.c
M src/include/access/toast_internals.h
M src/include/catalog/pg_opclass.dat
M src/include/utils/rel.h
M src/test/regress/expected/reloptions.out
M src/test/regress/sql/reloptions.sql

Fix translation of pg_controldata and pg_resetwal's NextOID output

commit   : ceae3099da7b43d1130267f6904da3c22f1b49eb    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 07:53:41 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 15 Sep 2026 07:53:41 +0900    

Click here for diff

xgettext does not recognize OID8_FORMAT and therefore extracts an  
incomplete message.  This switches to PRIu64 instead.  
  
Kyotaro Horiguchi has noticed one problem in pg_controldata, and I have  
spotted the extra two ones in pg_resetwal after more review.  
  
Oversight in cb298616463d.  
  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/20260914.124645.2220219320843846932.horikyota.ntt@gmail.com  

M src/bin/pg_controldata/pg_controldata.c
M src/bin/pg_resetwal/pg_resetwal.c

Fix ignored return value in test code

commit   : 6e70bef24e480eed3e0af0480c1bc7c0208833c8    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 19:43:56 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 19:43:56 +0200    

Click here for diff

The perlcritic check in the buildfarm alerted that the new test suites  
for online checksums didn't check the return value from read().  Fix by  
checking the return and ensuring the read call didn't fail.  Per build-  
farm member crake.  
  
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=crake&dt=2026-09-14%2015%3A04%3A18  

M src/test/modules/test_checksums/t/016_promote_enable_crash.pl
M src/test/modules/test_checksums/t/017_restartpoint_race.pl
M src/test/modules/test_checksums/t/018_enable_crash_windows.pl

Update FSM in COPY FREEZE replay

commit   : f7700080dc4c9226dd0fd81795214c02635e474d    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Mon, 14 Sep 2026 11:57:08 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Mon, 14 Sep 2026 11:57:08 -0400    

Click here for diff

d96f87332b3 folded COPY FREEZE visibility map updates into  
XLOG_HEAP2_MULTI_INSERT records. Unlike the former XLOG_HEAP2_VISIBLE  
redo path, multi-insert redo only updated the FSM when the record did  
not contain a heap page FPI and the heap page had less than 20% free  
space.  
  
This can leave all-frozen pages with missing or stale FSM entries on a  
standby. After promotion, vacuum will skip those pages, preventing  
their free space from being discovered.  
  
When a multi-insert record sets the page all-frozen, record the heap  
page's free space unconditionally.  
  
Reported-by: Melanie Plageman <melanieplageman@gmail.com>  
Discussion: https://postgr.es/m/CAAKRu_bS3nfMJCF2fjE%2Bceb5-t%3D2p_VPMk2PWuVomrOFxg5DGQ%40mail.gmail.com  
Backpatch-through: 19  

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

Handle no-op visibility map set during redo

commit   : 3245795e13c4d9a6250da8276f7eaea27011f437    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Mon, 14 Sep 2026 11:24:49 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Mon, 14 Sep 2026 11:24:49 -0400    

Click here for diff

add323da40a consolidated visibility map updates into XLOG_HEAP2_PRUNE  
records. It assumed that a record setting the visibility map would  
always modify the VM page during replay. That is not true when the  
requested bits are already set on the standby.  
  
Primary and standby visibility maps can diverge for several reasons.  
This issue was exposed by a CREATE DATABASE ... STRATEGY WAL_LOG bug.  
After a standby with an out-of-date VM is promoted, VACUUM may set bits  
that were already present on the former primary. When the former primary  
later replays that record as a standby, visibilitymap_set() is a no-op.  
  
Restore visibilitymap_set()'s former API, which returns the state of the  
VM bits before setting the requested flags. Use that result to set the  
VM page LSN only when the visibilitymap_set() updates the page.  
  
Reported-by: Rogers Wang <rogers.ww@qq.com>  
Discussion: https://postgr.es/m/tencent_2E870046716FD94285045E96505A2D4E2908%40qq.com  
Backpatch-through: 19  

M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_xlog.c
M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/access/heap/visibilitymap.c
M src/include/access/visibilitymap.h

Fix parallel GIN index build with keys larger than 65535 bytes

commit   : bad8829872d4d16f0d5de38c2cf9c0e9db86ac22    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 14 Sep 2026 15:13:17 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 14 Sep 2026 15:13:17 +0200    

Click here for diff

During a parallel GIN build, each key is serialized into a GinTuple, a  
transient representation used only while sorting.  _gin_build_tuple()  
lays out the whole tuple (the palloc size, the key memcpy, and the  
offset of the posting list) from a local variable holding the real key  
length, but then stored that length in GinTuple.keylen, which was  
uint16.  For a key longer than 65535 bytes, the stored length was thus  
silently truncated.  
  
On read-back, GinTupleGetFirst() and _gin_parse_tuple_items()  
recompute the posting-list offset from the truncated keylen and land  
inside the key data, so ginPostingListDecodeAllSegments() decodes  
garbage: an assertion failure with assertions enabled, and a read past  
the end of the allocation without, which could in turn lead to a crash  
or garbage being written into the index.  Only parallel builds are  
affected, because only they materialize a GinTuple; a serial build of  
the same data succeeds, as index_form_tuple() compresses large keys  
before the GinMaxItemSize check.  
  
To fix, widen GinTuple.keylen to Size, which is what VARSIZE_ANY()  
returns and what GinBuffer.keylen already uses, and use Size for the  
local in _gin_build_tuple() too, which was an int that truncated  
VARSIZE_ANY() the same way.  
  
Widening keylen moves GinTuple.data.  The key value is accessed in  
place in data, so data must be MAXALIGN'ed; before, that was only true  
by accident of the field layout.  Make that explicit with  
alignas(MAXIMUM_ALIGNOF) on data, so that the layout stays correct on  
32-bit platforms, where Size is 4 bytes and would otherwise leave data  
under-aligned when MAXIMUM_ALIGNOF is 8.  
  
Bug: #19545  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reported-by: Yuelin Wang <1217816127@qq.com>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/flat/19545-0f25b7e47351e8fc%40postgresql.org  

M src/backend/access/gin/gininsert.c
M src/include/access/gin_tuple.h

Avoid setting pd_prune_xid when inserting frozen tuples

commit   : 47f0fa62c00d32d8b8be41d052775c07c90024db    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Mon, 14 Sep 2026 10:42:55 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Mon, 14 Sep 2026 10:42:55 -0400    

Click here for diff

378a216187a set pd_prune_xid on inserts so that on-access pruning could  
later set the pages all-visible. heap_multi_insert() skipped this only  
when setting the page all-frozen, but it can insert frozen tuples even  
when not setting the page all-frozen. Inserting frozen tuples should not  
set pd_prune_xid as they introduce no work for on-access pruning. Fix by  
only setting pd_prune_xid when inserting non-frozen tuples.  
  
Reported-by: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAAKRu_a02pu7U2S0qPZ5L%2BoWb2m2Zp965sOKCCLnKUAKNo-hfg%40mail.gmail.com  
Backpatch-through: 19  

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

Describe special values in more GUC descriptions.

commit   : bd1244343332419df6b34be38883ee0af3227030    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 14 Sep 2026 09:15:28 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 14 Sep 2026 09:15:28 -0500    

Click here for diff

Commit 977d865c36 established some rules for mentioning special  
values (e.g., -1, 0, an empty string) in GUC descriptions.  A few  
parameters either neglect to mention their special values or  
describe them in a way that doesn't follow those rules.  Most of  
these parameters were added after the aforementioned commit.  This  
commit fixes them.  
  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/aqMkIpRr62cVqtCZ%40nathan  
Backpatch-through: 19  

M src/backend/utils/misc/guc_parameters.dat

Don't log page zeroing when checksum failures are ignored

commit   : 6547a2f6cccf8cfbfdd91a0b278bb65f0b00bdd2    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:24 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:24 +0200    

Click here for diff

When checksum failures are ignored, the page won't be zeroed on error  
even if zero_damaged_pages is set.  Found via review by GPT-6.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/E15AC050-C4B5-488D-BB2D-3C7AC9F89EA8@yesql.se  
Backpatch-through: 19  

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

Fix abort and launcher state resets in data checksums launcher

commit   : cffb4d8bd65e4c05ecd5697d09c4969467596ea5    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:15 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:15 +0200    

Click here for diff

The launcher_running flag was reset to false during shutdown, which  
left a small window where a new launcher could be started when the  
exit handler was still running.  Fix by only updating the running  
flag in shared memory in the exit handler if our local copy is true.  
  
Also reset the aborted state if the launch_operation changes during  
shutdown to allow scenarios like "start -> abort -> start" to work  
even if they reach the second start before the abort is fully done.  
  
Issues found by Noah and Robert using AI assisted review with Claude.  
Backpatch to v19 where the online checksums feature was introduced.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/E15AC050-C4B5-488D-BB2D-3C7AC9F89EA8@yesql.se  
Backpatch-through: 19  

M src/backend/postmaster/datachecksum_state.c

Improve error message for checksum state in pg_upgrade

commit   : 9a45131b7cf3b573d1b15a093a3cc80869814cbe    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:12 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:12 +0200    

Click here for diff

When attempting to upgrade a cluster which is an inprogress state, the  
same error message was used regardless of which state it was.  Fix by  
using different error messages for the different inprogress states.  
  
Found by Noah using AI assisted review with Claude.  Backpatch to v19  
where the online checksums feature was introduced.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/E15AC050-C4B5-488D-BB2D-3C7AC9F89EA8@yesql.se  
Backpatch-through: 19  

M src/bin/pg_upgrade/controldata.c

Fix enum value visibility for data_checksums

commit   : 3954d740c48750731d4a17766f3cb7b450856ed1    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:08 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:08 +0200    

Click here for diff

When the data_checksums GUC was changed into an enum the enum values  
were all incorrectly marked as hidden, which made pg_settings report  
an empty array.  Fix by setting all as visible as they should be.  
  
Found by Noah using AI assisted review with GPT.  Backpatch to v19  
where the GUC was changed in the online checksums feature.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/E15AC050-C4B5-488D-BB2D-3C7AC9F89EA8@yesql.se  
Backpatch-through: 19  

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

doc: Documentation updates for online checksums

commit   : 2bd7519a8150e7607c7ea8a89067bd0888526ddb    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:05 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:05 +0200    

Click here for diff

A set of documentation updates for the online checksums work, found via  
manual as well as LLM-guided review.  
  
  * The state diagram was re-done to be improve readability and be  
    more in line with the look and feel of other diagrams.  
  * Paragraph about mismatched states moved to its own sect2.  
  * The documentation for the functions to enable/ disable checksums  
    failed to mention that they are superuser only.  
  * The documentation for the checksums progress reporting had  
    accidentally omitted the work "fork" and for the blocks_* columns.  
    The values are per fork but the documentation made it seem they  
    were per relation.  
  * Add the state image to the meson buildfile  
  
Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/5b08b4d1-0982-4b77-bac5-3bdffc6583f5@iki.fi  
Backpatch-through: 19  

M doc/src/sgml/func/func-admin.sgml
M doc/src/sgml/images/datachecksums.gv
M doc/src/sgml/images/datachecksums.svg
M doc/src/sgml/images/meson.build
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/wal.sgml

pg_combinebackup: Refuse mixed data checksum states in a backup chain

commit   : 724477d67e2307fbaea3452e8b78b87572f2ea02    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:03 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:03 +0200    

Click here for diff

check_control_files() detected a chain whose backups were taken under  
different data checksum states, warned, and proceeded.  The output  
directory keeps the last backup's control file, so a full backup taken  
with checksums off combined with an incremental taken after an offline  
enable produces a cluster whose control file says "on" while most of  
its blocks carry no checksums; it starts, and then every connection  
dies on the first unchecksummed catalog page.  An offline enable  
between two backups of a chain is all it takes, since it rewrites  
every page without logging anything, so the incremental backup does  
not re-ship the pages.  
  
Turn the warning into an error, matching what pg_rewind does for the  
equivalent combinations.  The check stays asymmetric on purpose: when  
the last backup was taken with checksums off, stale checksums from an  
earlier backup are never verified, and that chain remains usable.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/anwm6UPxoVS41QA2@bdtpg  
Backpatch-through: 19  

M doc/src/sgml/ref/pg_combinebackup.sgml
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/test/modules/test_checksums/meson.build
A src/test/modules/test_checksums/t/024_combinebackup_mixed.pl

pg_rewind: Check the data checksum states of source and target

commit   : 227f8ea19a6b321af90607fe12d58eb5ce2c2dce    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:01 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:33:01 +0200    

Click here for diff

pg_rewind installs the source's control file on the target, but every  
block it does not copy keeps the target's content.  With checksums  
enabled on the target and disabled on the source, the rewound server  
claims enabled checksums while the blocks copied from the source have  
none, and fails checksum verification as soon as it reads them; in the  
worst case every connection attempt dies on an unverifiable catalog  
page.  
  
Comparing the control files is not enough.  Replay on the rewound  
server resumes from the last common checkpoint and adopts the data  
checksum state recorded there, so an offline disable on the source  
after the divergence leaves both control files saying "off" while the  
rewound server still resumes with verification enabled.  Check the  
state carried by the divergence checkpoint as well, which pg_rewind  
already reads.  
  
Refuse both cases, and an interrupted online transition on either  
side, same as pg_checksums does.  The opposite mismatch, checksums on  
the source only, is allowed with a warning: recovery under the backup  
label adopts the divergence state, so the rewound server keeps  
checksums disabled (or converges through the replayed WAL if the  
source enabled them online), and no page can fail verification.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/anwm6UPxoVS41QA2@bdtpg  
Backpatch-through: 19  

M doc/src/sgml/ref/pg_rewind.sgml
M src/bin/pg_rewind/parsexlog.c
M src/bin/pg_rewind/pg_rewind.c
M src/bin/pg_rewind/pg_rewind.h
M src/test/modules/test_checksums/meson.build
A src/test/modules/test_checksums/t/022_rewind_state.pl
A src/test/modules/test_checksums/t/023_rewind_standby_target.pl

pg_checksums: Refuse interrupted transitions, note change is local

commit   : 3e70c527cc399e3d7f569f6d01b6601f20b82255    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:32:58 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:32:58 +0200    

Click here for diff

An inprogress-on or inprogress-off control file means an online  
transition was cut short, running the offline tool on top of it mixes  
two procedures.  Refuse it in every mode, with a hint pointing at the  
start-stop cycle (or, on a standby, at letting replication finish)  
that resets the state.  Also print that the change applies to one  
data directory only, with standby-aware wording, since in a  
replication setup the same change must be made on every node.  
  
On a primary, inprogress-on cannot survive a graceful stop: the  
checksums launcher resolves it from its exit cleanup, and a crashed  
primary is already rejected by the existing "cluster must be shut  
down" check.  inprogress-off can, however, it is set by the backend  
running pg_disable_data_checksums(), and a fast shutdown arriving  
between its two barriers leaves it behind in a cleanly shut down  
control file, where the next start-stop cycle resolves it at end of  
recovery.  A standby can be stopped with either state, since it has  
no launcher and only carries forward whatever state the last replayed  
WAL record left it in, with a restartpoint persisting that as-is.  
The standby is also the deterministic way to reach the new guard,  
which is why the test coverage uses one; the primary window would  
need an injection point between the two barriers.  
  
The pg_checksums page said the tool still processes all relation files  
regardless of an interrupted online transition; describe the refusal  
instead.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/anwm6UPxoVS41QA2@bdtpg  
Backpatch-through: 19  

M doc/src/sgml/ref/pg_checksums.sgml
M src/bin/pg_checksums/pg_checksums.c
M src/test/modules/test_checksums/t/012_offline_standby.pl

Do not adopt data checksum state from another node during replay

commit   : b52a1c2c8a6acd4541a52e04cd14e3fcaffbeba0    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:32:55 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 14 Sep 2026 15:32:55 +0200    

Click here for diff

Offline data checksum changes with pg_checksums are local to one node,  
but replay adopted the data checksum state carried by checkpoint record  
unconditionally.  After enabling checksums offline on only the primary,  
a standby thus started verifying checksums it does not have.  After an  
offline change on a standby, the next replayed checkpoint silently  
reverted the state.  
  
To fix, make the control file track this node's state alone, and have  
replay cross-check the replayed state against it instead of adopting  
it, warning once per divergent value and reporting when the states  
agree again.  pg_control gains a watermark, normally the end LSN of  
the newest XLOG2_CHECKSUMS record the node has written or applied,  
and a flag marking that the state was last written by pg_checksums.  
Recovery must never overwrite this state with a replayed one.  The  
control file is updated when all pages are flushed.  This requires  
a PG_CONTROL_VERSION bump.  
  
Recovery from a base backup may be an exception to not adopting: its  
control file was copied at an arbitrary moment, so the state carried  
by the starting checkpoint is the one the WAL from there on was  
  
Also document the offline procedure for replication setups.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reported-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/anwm6UPxoVS41QA2@bdtpg  
Backpatch-through: 19  

M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/wal.sgml
M src/backend/access/transam/xlog.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/utils/activity/wait_event_names.txt
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_controldata/pg_controldata.c
M src/bin/pg_resetwal/pg_resetwal.c
M src/bin/pg_rewind/pg_rewind.c
M src/bin/pg_upgrade/controldata.c
M src/include/catalog/pg_control.h
M src/include/storage/lwlocklist.h
M src/test/modules/test_checksums/Makefile
M src/test/modules/test_checksums/meson.build
A src/test/modules/test_checksums/t/012_offline_standby.pl
A src/test/modules/test_checksums/t/013_rewind.pl
A src/test/modules/test_checksums/t/014_lockstep.pl
A src/test/modules/test_checksums/t/015_standby_crash_after_disable.pl
A src/test/modules/test_checksums/t/016_promote_enable_crash.pl
A src/test/modules/test_checksums/t/017_restartpoint_race.pl
A src/test/modules/test_checksums/t/018_enable_crash_windows.pl
A src/test/modules/test_checksums/t/019_standby_shutdown_catchup.pl
A src/test/modules/test_checksums/t/020_cascade_divergence.pl
A src/test/modules/test_checksums/t/021_rewind_divergent_transitions.pl

Rename the WAIT FOR command to WAIT in the documentation

commit   : a23ab4862cfebb9aba58f713854b7d5e42d5f947    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 14 Sep 2026 14:13:30 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 14 Sep 2026 14:13:30 +0300    

Click here for diff

The command tag is WAIT, but the reference page called the command  
"WAIT FOR" in its title, index entry, psql help name and throughout its  
prose, and so did the error messages.  FOR is a noise word that makes the  
grammar read like English, exactly as INTO does for INSERT and FROM does  
for DELETE; neither of those is part of the command's name.  Settle on  
WAIT everywhere the command is named, and keep WAIT FOR LSN wherever the  
syntax itself is being shown.  
  
Rename the reference page's id and file name to match, following  
cb2c696b1dd: v19 is not released, so the URL is not yet baked into a  
supported version, and every other page's id matches its title.  
  
Reported-by: Masahiko Sawada sawada.mshk@gmail.com  
Author: Xuneng Zhou xunengzhou@gmail.com  
Reviewed-by: Alexander Korotkov aekorotkov@gmail.com  
Discussion: https://postgr.es/m/CAD21AoBdtiPTbm7T_aNeDON9JpFG9g%3DJDUP4WU-Y8t8_xqvR5Q%40mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/high-availability.sgml
M doc/src/sgml/ref/allfiles.sgml
R095 doc/src/sgml/ref/wait_for.sgml doc/src/sgml/ref/wait.sgml
M doc/src/sgml/reference.sgml
M src/backend/commands/wait.c
M src/test/recovery/t/049_wait_for_lsn.pl

Fix timeout overflow in WAIT FOR LSN

commit   : 6c44473c2deed07b4cca3c202dd48b1e8e002ec9    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 14 Sep 2026 14:13:04 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 14 Sep 2026 14:13:04 +0300    

Click here for diff

Commit 447aae13b03 accepted TIMEOUT values up to INT64_MAX  
milliseconds, but computing the deadline multiplies by 1000, which  
caused an int64 overflow. And the command reported a timeout at once  
instead of waiting.  
  
Parse the value as an int instead, which simplifies the code and is  
consistent with other timeout values such as the statement_timeout GUC.  
  
The specified values are now rounded to the nearest millisecond, so a  
positive timeout below half a millisecond becomes zero and waits  
indefinitely.  
  
Backpatch to v19, where the TIMEOUT option was introduced.  
  
Reported-by: ChangAo Chen <cca5507@qq.com>  
Author: ChangAo Chen <cca5507@qq.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/tencent_86B83240785807077600A1778566B5C12908@qq.com  
Backpatch-through: 19  

M doc/src/sgml/ref/wait_for.sgml
M src/backend/access/transam/xlogwait.c
M src/backend/commands/repack_worker.c
M src/backend/commands/wait.c
M src/include/access/xlogwait.h
M src/test/recovery/t/049_wait_for_lsn.pl

postgres_fdw: Disable attribute statistics import from pre-9.1 servers.

commit   : 3ca4abd60ce3661c6ccd3d83a13986ef9541bf40    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Mon, 14 Sep 2026 19:00:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Mon, 14 Sep 2026 19:00:00 +0900    

Click here for diff

To import attribute statistics, postgres_fdw sent a query wity COLLATE  
"C" to remote servers without checking their version.  Since COLLATE is  
only supported since v9.1, this could break the import against older  
servers; fix by modifying postgres_fdw to check their version and if  
older, fall back to sampling.  (This commit still allows importing only  
relation statistics from such an older server.)  
  
Also, expand the documentation to mention that attribute statistics are  
stored into the local server without applying the foreign table columns'  
n_distinct option.  
  
Oversight in commit 28972b6fc.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Reported-by: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwH8%2BuDTwfohpck9v_9L3nwSWACbmC36JYRyqHd5xQN_OA%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c
M doc/src/sgml/postgres-fdw.sgml

Don't let JSON constructor coercions block SQL function inlining

commit   : 9d0adee8768852fc0e5713ec27cf52d46d97279d    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 14 Sep 2026 17:04:13 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 14 Sep 2026 17:04:13 +0900    

Click here for diff

contain_context_dependent_node_walker() reports a CaseTestExpr as  
context-dependent unless it sits under a simple CaseExpr or the  
elemexpr of an ArrayCoerceExpr.  A JsonConstructorExpr whose RETURNING  
type requires a coercion also carries a CaseTestExpr placeholder in  
that coercion, so any SQL function called with such a constructor as  
an argument was refused inlining.  
  
Teach the walker that a CaseTestExpr is expected within the coercion  
of a JsonConstructorExpr, the same way it already handles the elemexpr  
of an ArrayCoerceExpr.  This is safe now that eval_const_expressions  
no longer lets an enclosing simple CASE clobber that placeholder.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs48A=VCFbteTkuCoknO1_0-Cu0aMBT0M07dm7vj1QyixDg@mail.gmail.com  
Backpatch-through: 19  

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

Fix const-folding of JSON constructors inside a simple CASE

commit   : e17df18a811e082a47d68263c154ae0385cd1494    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 14 Sep 2026 17:03:41 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 14 Sep 2026 17:03:41 +0900    

Click here for diff

A JSON constructor with a RETURNING clause uses a CaseTestExpr as the  
placeholder for its result in the coercion expression.  When such a  
constructor appears in a WHEN clause of a simple CASE whose test  
expression is a constant, eval_const_expressions substituted that  
constant for the placeholder, so the coercion produced the CASE's test  
value instead of the constructor's result.  For instance,  
  
    CASE 'x' WHEN JSON_OBJECT('a': 'b' RETURNING text) THEN 1 ELSE 0 END  
  
evaluated to 1.  
  
To fix, keep case_val out of scope while simplifying the coercion, as  
is already done for the elemexpr of an ArrayCoerceExpr.  
  
Back-patch to v16, where the SQL/JSON constructor functions were  
introduced.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs48A=VCFbteTkuCoknO1_0-Cu0aMBT0M07dm7vj1QyixDg@mail.gmail.com  
Backpatch-through: 16  

M src/backend/optimizer/util/clauses.c
M src/include/nodes/primnodes.h
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/sqljson.sql

Fix attribute name of pg_stat_get_backend_subxact()

commit   : 92aaf50e230a6ca267efdf8543f8314b4cb7a59b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 15:58:08 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 15:58:08 +0900    

Click here for diff

"subxact_overflowed" maps with the name registered in pg_proc.dat.  
  
Oversight in 10ea0f924a27.  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>  
Discussion: https://postgr.es/m/ef48668c-cf8e-4f4b-bf39-4b3b9fb9b85a@uni-muenster.de  

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

doc: Mention REPACK in description of reloption toast_value_type

commit   : 4b4b5eae90e5b355c24164c8cea0ca277ae30527    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 14:12:00 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 14:12:00 +0900    

Click here for diff

The value set in toast_value_type does not affect the underlying TOAST  
table across rewrites.  VACUUM FULL and CLUSTER were mentioned, but not  
REPACK.  
  
Suggested-by: Marcos Pegoraro <marcos@f10.com.br>  
Discussion: https://postgr.es/m/CAB-JLwbsYHxo5qdWyj1WbRDhxfxsKqg9Y2=wQ4Xwjm51wsLVPg@mail.gmail.com  

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

Disallow SET UNLOGGED for tables in a publication's EXCEPT clause.

commit   : 7056ed4663f5ce4214cc1ebce42ec40f4400a7ea    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 14 Sep 2026 09:40:18 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 14 Sep 2026 09:40:18 +0530    

Click here for diff

Unlogged tables cannot be replicated, so they can neither be published nor  
be named in a publication's EXCEPT clause.  ALTER TABLE ... SET UNLOGGED  
checked only whether the table was published, so a table in an EXCEPT  
clause could still be made unlogged, leaving a state that CREATE  
PUBLICATION would reject and that pg_dump could not restore.  
  
Author: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Discussion: https://postgr.es/m/CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com  
Backpatch-through: 19, where it was introduced  

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

Fix stale copies of PHVs in subqueries

commit   : e28cf96e9351152760a24ccb55f3f66c26961294    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 14 Sep 2026 12:26:05 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 14 Sep 2026 12:26:05 +0900    

Click here for diff

When a subquery references an output of another subquery that gets  
pulled up, and that output must be wrapped in a PlaceHolderVar because  
of an intermediate outer join, the PHV expression is pushed down into  
the subquery.  That copy is not preprocessed along with the outer  
query's expressions, so the two copies can diverge.  This used to be  
harmless, but since commit 2ebf25e7d join removal edits the whole  
query tree, walking into subqueries, and can trip an assert in  
ChangeVarNodes if it removes a rel whose Var survives only in such a  
copy.  
  
To fix, preprocess these copies at their owning query level, early in  
subquery_planner, before anything can consume them (in particular  
before SubLinks are turned into SubPlans).  This covers copies pushed  
into both LATERAL subquery RTEs and SubLink subselects, and handles  
nested copies innermost-first.  extract_lateral_references no longer  
preprocesses the copies it pulls out.  
  
Correspondingly, the subquery's own processing must leave the contents  
of an upper-level PHV alone, since the owning level has already  
preprocessed them: eval_const_expressions returns such a PHV  
unchanged, and flatten_join_alias_vars no longer recurses into it.  
  
Back-patch to v16, as with commit 2ebf25e7d.  
  
Reported-by: Tender Wang <tndrwang@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAHewXN=kWGAXV537mKtSyBYobGdHhYJVDJJMXXZEmmPWE_zaPw@mail.gmail.com  
Backpatch-through: 16  

M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/plan/subselect.c
M src/backend/optimizer/util/clauses.c
M src/backend/optimizer/util/paramassign.c
M src/backend/optimizer/util/var.c
M src/include/optimizer/planner.h
M src/test/regress/expected/groupingsets.out
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql
M src/tools/pgindent/typedefs.list

Check that a promoted standby keeps its 8-byte OID counter

commit   : 1cd8669179f41b939c08e84ddddd3bdce0e095ea    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 12:05:29 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 12:05:29 +0900    

Click here for diff

The counter reaches a standby through XLOG_NEXTOID and checkpoint  
records.  This commit adds a test to move the next OID past the 2^32  
limit on a primary and read it back from the promoted standby.  This  
reuses the same trick as some of the previous tests, with a pg_resetwal  
command setting the next OID to be larger than 2^32, combined with a  
check based on pg_control_checkpoint().  
  
This closes a testing gap of cb298616463d regarding the replay of  
XLOG_NEXTOID, where this WAL record has been updated to pass down an  
Oid8 value.  By default, regression tests would use OIDs way below the  
UINT32_MAX limit.  
  
Author: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/CAHWVJhGkb1n_QSS4M=PKJD5HHcwK3KXpFwVxoRVLzAG3j+2fhQ@mail.gmail.com  

M src/test/recovery/t/004_timeline_switch.pl

Switch pg_column_toast_chunk_id() return value from oid to oid8

commit   : 4000ab1decb6138a11fb4423237589376cb9ff54    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 11:02:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 11:02:21 +0900    

Click here for diff

This is required for a follow-up commit that will add support for 8-byte  
TOAST values, with this function being changed so as it is able to  
support the largest TOAST value type available.  
  
Most of the changes in this commit are in the regression tests that use  
pg_column_toast_chunk_id(), that need to use some oid8-ish changes.  The  
change is surprisingly not invasive as casts from oid to oid8 are  
possible (the opposite cast oid8->oid is not supported).  
  
Bump catalog version.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xy  

M doc/src/sgml/func/func-admin.sgml
M src/backend/utils/adt/varlena.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/isolation/expected/cluster-toast-value-reuse.out
M src/test/isolation/specs/cluster-toast-value-reuse.spec
M src/test/modules/injection_points/specs/repack_toast.spec
M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

Refactor some TOAST value ID code to use Oid8 instead of Oid

commit   : 072d4c4240572980b9c101ff5d2b85e656e79275    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 10:00:31 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 14 Sep 2026 10:00:31 +0900    

Click here for diff

This is a mechanical update to change most of the TOAST code paths that  
assume TOAST value IDs to be Oid variables to become Oid8 variables,  
easing an the introduction of an upcoming patch to allow larger TOAST  
values, at 8 bytes.  
  
The areas touched by the change are related to table AM, amcheck and  
logical decoding's reorder buffer.  A good chunk of the changes involve  
switching printf() markers from %u to OID8_FORMAT.  
  
For the sake of the release notes in terms of compatibility (perhaps  
worth mentioning, or not), note that this changes some callback  
definitions in the table AM section, upgrading some TOAST callbacks to  
use Oid8 instead of Oid when referring to a TOAST value.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xy  

M contrib/amcheck/verify_heapam.c
M src/backend/access/common/toast_internals.c
M src/backend/access/heap/heaptoast.c
M src/backend/replication/logical/reorderbuffer.c
M src/include/access/heaptoast.h
M src/include/access/tableam.h

Fail REPACK in presence of !indisready indexes

commit   : 0c5d6269614e107d1d2d669f82f63f7e232b30c9    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sun, 13 Sep 2026 14:06:00 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sun, 13 Sep 2026 14:06:00 +0200    

Click here for diff

Like VACUUM FULL, non-concurrent REPACK would try to rebuild such  
indexes, which can sometimes succeed.  Concurrent REPACK would however  
fail.  The inconsistency is not good, so make them both throw an error  
quickly to force the user to make a decision on those indexes (most  
likely, drop them).  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Suggested-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://postgr.es/m/CAN4CZFO5A3YE0Dd-bn7eKrB20pECO3=U0wKg1z2rO=DxgWJJHQ@mail.gmail.com  

M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M src/backend/commands/repack.c

Re-read standby LSN after recovery ends

commit   : 8c7a74c3239ce29940582643533a190721b395c0    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 12 Sep 2026 23:30:03 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 12 Sep 2026 23:30:03 +0300    

Click here for diff

WaitForLSN() samples the current position before checking whether  
recovery is still in progress. If recovery reaches the target and ends  
between those operations, the promotion path can compare against the  
stale sample and incorrectly return NOT_IN_RECOVERY.  
  
Read the position again after observing that recovery has ended, before  
deciding whether promotion reached the target.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7U0gW5%2B-4oL7-qdML-yerZxUb7ku4QXp7JxCYo0qyJ_Tw%40mail.gmail.com  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Backpatch-through: 19  

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

Wake primary_flush waiters after implicit WAL flushes

commit   : d61f9c90f2ef96b38eceb592b63c688d74cf7611    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 12 Sep 2026 23:29:46 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 12 Sep 2026 23:29:46 +0300    

Click here for diff

XLogWrite() can advance the flush position when it finishes a WAL  
segment, even if its caller requested only a write. When this happens  
while AdvanceXLInsertBuffer() recycles a buffer, primary_flush waiters  
are not notified and can sleep until an unrelated flush or checkpoint.  
  
Track such progress with a process-local pending flag and perform the  
wakeup after releasing WAL write and insertion locks, keeping  
WaitLSNLock acquisition outside the contended WAL path. Add a  
deterministic injection-point test that forces this path and inspects  
the registration directly in shared memory.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7U0gW5%2B-4oL7-qdML-yerZxUb7ku4QXp7JxCYo0qyJ_Tw%40mail.gmail.com  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Backpatch-through: 19  

M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogwait.c
M src/backend/postmaster/walwriter.c
M src/test/recovery/t/049_wait_for_lsn.pl

Prevent WAIT FOR LSN from deadlocking recovery on held locks

commit   : e0c160c307264654a2e91d582cc0935243bc9253    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 12 Sep 2026 23:29:30 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Sat, 12 Sep 2026 23:29:30 +0300    

Click here for diff

A backend waiting for WAL replay can retain locks acquired by earlier  
statements.  If the startup process needs one of those locks, directly or  
through another backend, before reaching the target LSN, a deadlock can  
arise: startup waits for the backend to release the lock, while the backend  
waits for startup to advance replay.  The lock manager records the  
backend's held locks, but WAIT FOR LSN does not register its dependency on  
replay as a lock wait.  The deadlock detector therefore cannot see the  
complete cycle.  With unlimited standby conflict delays and no other  
timeout or cancellation, this deadlock can persist indefinitely.  
  
Write and flush waits are restricted as well.  Their positions are floored  
by the replay position, so without an active walreceiver the startup  
process can be their only source of progress.  If a held lock blocks  
replay, these waits can form the same cycle: the backend waits for replay  
to advance, while replay waits for the backend to release the lock.  
  
Streaming does advance them independently, but only while WAL keeps  
arriving.  If reception stops before the target is reached, a blocked  
startup process cannot restart the walreceiver.  It also cannot replay  
newer checkpoint records needed to advance restartpoints and recycle WAL,  
so continued reception can exhaust available space in pg_wal before the  
target is reached.  An active receiver at the start of the wait therefore  
does not guarantee that the wait can finish while replay remains blocked.  
  
Reject an unsatisfied standby_replay, standby_write, or standby_flush wait  
while recovery is active when the backend already holds a granted  
heavyweight lock.  This conservative restriction covers direct  
relation-lock cycles and indirect cycles involving advisory locks.  It  
also rejects some write and flush waits that an active receiver could  
satisfy.  Requests whose target is observed as already reached are exempt  
from this check, as are primary_flush requests and requests issued after  
recovery has ended.  Existing snapshot and recovery-state checks still  
apply.  
  
Report one of the held locks so the user can find it, using the same  
description the deadlock report uses.  
  
Add replay-mode tests for relation and advisory locks and for the  
already-reached case, and document the restriction along with the  
recommended usage pattern.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7U0gW5%2B-4oL7-qdML-yerZxUb7ku4QXp7JxCYo0qyJ_Tw%40mail.gmail.com  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Backpatch-through: 19  

M doc/src/sgml/ref/wait_for.sgml
M src/backend/commands/wait.c
M src/backend/storage/lmgr/lock.c
M src/include/storage/lock.h
M src/test/recovery/t/049_wait_for_lsn.pl

Revert "Use -isystem for LLVM include directories"

commit   : 7a0aa99e51c7a3263e6ee45f19f270ddae430a92    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 12 Sep 2026 15:50:08 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 12 Sep 2026 15:50:08 +0200    

Click here for diff

This reverts commit 704ef84ef232e02e241071b2faf0541d155c6b62.  
  
The configure solution in that commit doesn't work if llvm-config  
returns a system directory such as /usr/include.  The resulting  
-isystem /usr/include puts the C headers before the C++ headers in the  
include file order, which is not supposed to be done and causes  
failures.  (Using -I /usr/include doesn't have that problem because it  
is handled specially by the compiler.)  Per buildfarm members  
hippopotamus and jay.  
  
The meson solution does work because it specifically filters out  
system includes.  This logic could theoretically be ported to  
configure, but that would be a separate undertaking.  

M config/llvm.m4
M configure
M meson.build

Use -isystem for LLVM include directories

commit   : 704ef84ef232e02e241071b2faf0541d155c6b62    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 12 Sep 2026 12:35:33 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 12 Sep 2026 12:35:33 +0200    

Click here for diff

LLVM's headers produce warnings under some of the warning options we  
might like to use.  For example, -Wshadow=local reports several  
warnings from LLVM's headers when compiling llvmjit_inline.cpp.  To  
work around that, add the include directories reported by llvm-config  
with -isystem rather than -I, which makes the compiler treat them as  
system headers and not report warnings from them.  In meson, this is a  
built-in facility of the dependency() function, in configure we  
implement it ourselves.  
  
An alternative solution would have been to use "#pragma GCC  
system_header", as is already done elsewhere in the tree.  But that  
seems less elegant here.  Either, we would have to potentially create  
a separate wrapper for each LLVM header, or we would have to route all  
LLVM includes through a common header, which would break modularity.  
  
Reviewed-by: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/84b6f128-91f5-480e-8a9e-7d0e8f538cea%40eisentraut.org  

M config/llvm.m4
M configure
M meson.build

Make on-access pruning pin visibility map before locking heap page

commit   : 512d3e8919b649d36a6f246c657c8b8df7536e8a    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 11 Sep 2026 20:37:53 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 11 Sep 2026 20:37:53 -0400    

Click here for diff

b46e1e54d078 pinned the VM after acquiring a cleanup lock on the heap  
page when on-access pruning. This was not correct, as pinning the VM may  
require I/O. Pin the VM before acquiring the lock. This could mean  
occasional unneeded pinning when the buffer is under contention, but  
that should be rare.  
  
Reported-by: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAAKRu_aR6e2mNVo-DNHDUfBE5i0cbE4%3Du%3D_Qi9%2Bv573qiGtBig%40mail.gmail.com  
Backpatch-through: 19  

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

doc: Fix output column name for pg_stat_get_backend_subxact()

commit   : ce420353fab97aac14ba0386d9dd6ae8635041fb    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 12 Sep 2026 09:04:00 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 12 Sep 2026 09:04:00 +0900    

Click here for diff

pg_stat_get_backend_subxact()'s second attribute was written as  
"subxact_overflow" in the docs, but its name is "subxact_overflowed".  
Note that the attribute name is still wrong in the TupleDesc generated  
in the function; pg_proc agrees with "overflowed".  
  
Author: Shihao Zhong <zhong950419@gmail.com>  
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAGRkXqTBZ+zbVuDC8xGEB6Btj61hsui5H5nGqzFBDyOXc=4bjQ@mail.gmail.com  
Backpatch-through: 16  

M doc/src/sgml/monitoring.sgml

Fix option argument lookup in in-tree getopt_long().

commit   : 237176b7951539fcc54f6a81ce1f29853099c3f7    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 11 Sep 2026 15:18:40 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 11 Sep 2026 15:18:40 -0500    

Click here for diff

The in-tree getopt_long() moves each non-option to the end of argv,  
which might put it right where an option's argument lookup expects  
to find the argument.  For example, "vacuumdb postgres --jobs"  
takes "postgres" as the number of jobs instead of complaining that  
--jobs is missing its argument.  To fix, stop the argument lookups  
at the start of the moved non-options, which we already track to  
know when to stop scanning.  
  
Oversight in commit 411b720343.  
  
Author: Sehrope Sarkuni <sehrope@jackdb.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/CAH7T-arxDuVCSkorO%3Dk7%2BM-_JV0JFzMpN_EtKMyD2K0RDqZ2OA%40mail.gmail.com  
Backpatch-through: 17  

M src/bin/scripts/t/100_vacuumdb.pl
M src/port/getopt_long.c

Fix optional-argument handling in in-tree getopt_long().

commit   : 61aa17b92eab017d64419c19fa466d72a509d016    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 11 Sep 2026 14:37:51 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 11 Sep 2026 14:37:51 -0500    

Click here for diff

If a long option that accepts an optional argument is given without  
one, optind is advanced twice, and the following argument is  
skipped.  For example, "pg_waldump --stats --limit 5" skips --limit  
and interprets "5" as a non-option, so the command complains that  
it cannot location WAL file "5".  The same path also returns BADARG  
when optstring starts with a colon, even though nothing is missing.  
To fix, handle optional arguments before the missing-argument code,  
which then only needs to deal with required arguments.  
  
This is a bug fix and could be back-patched, but since this issue  
went unnoticed for 23 years, I'm not going to bother.  
  
Author: Sehrope Sarkuni <sehrope@jackdb.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/CAH7T-arxDuVCSkorO%3Dk7%2BM-_JV0JFzMpN_EtKMyD2K0RDqZ2OA%40mail.gmail.com  

M src/bin/pg_waldump/t/001_basic.pl
M src/port/getopt_long.c

Fix logical decoding to ignore updates without a new tuple.

commit   : 3a3524e9acf4b22e7b3100a3710be3adffe89874    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Fri, 11 Sep 2026 10:54:23 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Fri, 11 Sep 2026 10:54:23 -0700    

Click here for diff

REPACK (CONCURRENTLY) suppresses logical decoding of the changes it  
applies to the transient heap. For an update, suppression keeps the  
tuple data out of the WAL record, but the record itself is still  
written, and decoding turned it into a change carrying neither a new  
nor an old tuple. An output plugin that asks for the changes made by  
heap rewrites therefore outputs an UPDATE with no data at all,  
reported under the name of the table being repacked.  
  
Ignore such records, as decoding already does for inserts. Updates on  
catalog relations don't carry the new tuple either, so we ignore them  
too. For deletes, REPACK sets XLH_DELETE_NO_LOGICAL instead.  
  
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.  
  
Reported-by: Thom Brown <thom@linux.com>  
Reviewed-by: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/CAA-aLv7L_-dOuHXjLh0Di66dExdOb=uTOzR=jtrqCmV0Wxyd2Q@mail.gmail.com  
Backpatch-through: 19  

M src/backend/replication/logical/decode.c
M src/test/modules/injection_points/expected/repack_decode.out
M src/test/modules/injection_points/specs/repack_decode.spec

Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tuples.

commit   : 7164dcb6653242f757b5bdc4a26714a24207b1db    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Fri, 11 Sep 2026 10:20:42 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Fri, 11 Sep 2026 10:20:42 -0700    

Click here for diff

Previously, heap_update() honored TABLE_UPDATE_NO_LOGICAL for the main  
tuple but passed a hardcoded 0 to the tuple toaster, so the tuples it  
wrote to the TOAST relation were logged for decoding anyway. That was  
harmless until commit 28d534e2ae0a gave updates the flag; the insert  
path has propagated its own ever since suppression was introduced for  
heap rewrites.  
  
REPACK (CONCURRENTLY), the only user of the flag, relies on it to keep  
the changes it applies to the transient heap out of the logical  
stream. Logical decoding therefore reassembled the TOAST value and  
then dereferenced a new tuple that the suppressed record doesn't  
carry, crashing the backend. This is reachable only if an output  
plugin asks for the changes made by heap rewrites. In core that is  
just test_decoding with include-rewrites.  
  
Fix this by passing HEAP_INSERT_NO_LOGICAL down to the tuple toaster  
when TABLE_UPDATE_NO_LOGICAL is set.  
  
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.  
  
Reported-by: Thom Brown <thom@linux.com>  
Author: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/CAA-aLv7L_-dOuHXjLh0Di66dExdOb=uTOzR=jtrqCmV0Wxyd2Q@mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/heap/heapam.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/repack_decode.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/repack_decode.spec

pg_ctl: Error out on Windows-only options on other platforms

commit   : 6a1c1102c4a36c4b80bba4a46f1ad8c125f8dd4e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 17:43:11 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 17:43:11 +0200    

Click here for diff

Several pg_ctl command-line options are used only on Windows, but  
pg_ctl accepted them anyway on all platforms but didn't do anything  
with them.  
  
This commit changes it to report an error if an option is specified  
but the platform doesn't make use of it.  The affected options are -e,  
-N, -P, -U.  The option -S already errored out on non-Windows  
platforms; the new behavior of the other options is aligned with that.  
  
The --help output already didn't list these options on non-Windows  
builds, so the fact that they were accepted silently was already  
inconsistent.  The man page already lists them as "Options for  
Windows".  
  
Several global variables that were set but then only read on Windows,  
are now in #ifdef WIN32 blocks.  This avoids -Wunused-but-set-global  
warnings that the new clang 23 enables via -Wall.  
  
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   : 4e108ce790ec68c6721d08c307109e660bfc0cf3    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 17:43:11 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 11 Sep 2026 17:43:11 +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.  
  
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/access/transam/xlog.c
M src/backend/postmaster/postmaster.c
M src/bin/pg_dump/pg_dump_sort.c
M src/test/modules/test_resowner/test_resowner_many.c

Revert "Don't try to re-order the subcommands of CREATE SCHEMA".

commit   : 962e0a723a2dc3f77dc7ae51f992f3932819f81f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Sep 2026 11:38:16 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Sep 2026 11:38:16 -0400    

Click here for diff

This reverts commit a9c350d9ee66745aadcf7c0c95a567752a762171.  
While that intentionally changed our semantics for CREATE SCHEMA  
subcommands, it's being argued that the functionality gain does  
not justify potentially-subtle compatibility breakage.  The most  
useful bit of functionality gain came from commit 404db8f9e  
("Execute foreign key constraints in CREATE SCHEMA at the end"),  
which we're keeping because it's required by SQL spec and doesn't  
seem to create a compatibility hazard by itself.  
  
This is not an exact revert, partly because we're keeping 404db8f9e,  
and partly because I kept the API changes that allowed passing down  
a ParseState (which allows providing an error cursor for many of the  
errors thrown in CREATE SCHEMA).  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/20260904180712.cc.noahmisch@microsoft.com  
Backpatch-through: 19  

M doc/src/sgml/ref/create_schema.sgml
M src/backend/commands/schemacmds.c
M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/create_schema.out
M src/test/regress/expected/event_trigger.out
M src/test/regress/expected/namespace.out
M src/test/regress/sql/create_schema.sql
M src/test/regress/sql/namespace.sql
M src/tools/pgindent/typedefs.list

Revert "Support more object types within CREATE SCHEMA".

commit   : f1920437cd42b966e87dcc7aa7ee1e9837a96429    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Sep 2026 11:32:16 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 11 Sep 2026 11:32:16 -0400    

Click here for diff

This reverts commit d516974840f4059d331ae6057ede3e4edd3c6747,  
along with parts of commit 049b742daad0965be4a846035408ae27ce1f9e14  
("psql: Tighten heuristics for BEGIN/END within CREATE SCHEMA").  
  
While there's nothing particularly wrong with d51697484 in itself,  
it depends on a9c350d9e ("Don't try to re-order the subcommands of  
CREATE SCHEMA"), and concerns have been raised that the compatibility  
impact of that outweighs the benefit of allowing more object types  
within CREATE SCHEMA.  
  
It's not possible to revert 049b742da verbatim, because the  
CVE-2026-6464 patches 3045a25ba ("Teach psql to skip in-line COPY  
... FROM STDIN data after a failure") and cf754f741 ("Save/restore  
more lexer state when skipping text due to \if") depend on  
infrastructure it added.  Instead, rip out just the bits specifically  
needed to parse CREATE FUNCTION within CREATE SCHEMA.  This results in  
lexer code that matches v18-and-earlier as modified by CVE-2026-6464.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/20260904180712.cc.noahmisch@microsoft.com  
Backpatch-through: 19  

M doc/src/sgml/ref/create_schema.sgml
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/bin/psql/psqlscanslash.l
M src/bin/psql/tab-complete.in.c
M src/fe_utils/psqlscan.l
M src/include/fe_utils/psqlscan_int.h
M src/test/modules/test_ddl_deparse/expected/create_schema.out
M src/test/modules/test_ddl_deparse/sql/create_schema.sql
M src/test/regress/expected/create_schema.out
M src/test/regress/sql/create_schema.sql

Disallow REPACK (CONCURRENTLY) when replica identity index is dropped

commit   : c1c5d28f4a2df9d83ca1bcd6bcd6ed8ca065791b    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 11 Sep 2026 13:42:45 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 11 Sep 2026 13:42:45 +0200    

Click here for diff

The replica identity determination was "flawed": it fell back to the  
primary key if the marked index was dropped, which is a defensible  
choice, but logical decoding has a differing opinion and fails to  
provide usable tuple identity data in this case.  "Fix" REPACK by  
refusing to use the primary key in that case.  
  
This is arguably broken behavior in RelationGetIndexList, but I'll  
refrain from changing that at this stage.  
  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Author: Ewan Young <kdbase.hack@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/apCBRKCH8jwKiaSY@nathan  

M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M src/backend/commands/repack.c
M src/backend/utils/cache/relcache.c

Fix crash on UPDATE or DELETE of a partition pending detach.

commit   : 479a931155c6758831e57ba76f9671565c1e5553    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 11 Sep 2026 15:21:03 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 11 Sep 2026 15:21:03 +0530    

Click here for diff

ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY leaves the partition  
marked as detach-pending if its wait is interrupted, and only DETACH  
PARTITION ... FINALIZE clears that mark. In that state pg_class still says  
relispartition while get_partition_ancestors() already reports nothing,  
which RelationBuildPublicationDesc() was not ready for. It took  
relispartition to mean that the ancestor list is not empty and asked for  
its last element, which is an assertion failure, or a NULL pointer  
dereference without assertions. CheckCmdReplicaIdentity() needs the  
descriptor for every UPDATE and DELETE of a publishable relation and  
builds it on first use, so no publication has to exist for this, and a  
plain UPDATE crashes the backend.  
  
Treat such a partition as a standalone table, as after the detach is  
finalized. It is then published by FOR ALL TABLES publications, but cannot  
be added to an EXCEPT clause until the detach completes, which is now  
reported with a hint to run DETACH PARTITION ... FINALIZE.  
  
Oversight in fd366065e06a, which added the exclusion.  
  
Author: Mikhail Nikalayeu <mihailnikalayeu@gmail.com>  
Author: shveta malik <shveta.malik@gmail.com>  
Author: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Discussion: https://postgr.es/m/CADzfLwWoFPT%2Ba73%3DA%3DbsNWRMZQ98NpBEMgE%3Dt1FS4O4_%3DQVLfA%40mail.gmail.com  
Backpatch-through: 19, where it was introduced  

M src/backend/catalog/pg_publication.c
M src/backend/utils/cache/relcache.c
M src/test/isolation/expected/detach-partition-concurrently-3.out
M src/test/isolation/specs/detach-partition-concurrently-3.spec

psql: Schema-qualify catalogs in ALTER DATABASE RESET completion

commit   : 42ce84f878a4e2137c4a4520631eb236c9f1988f    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 11 Sep 2026 18:14:14 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 11 Sep 2026 18:14:14 +0900    

Click here for diff

The tab-completion query used for ALTER DATABASE ... RESET referenced  
pg_db_role_setting and pg_database without schema qualification, so a  
same-named relation earlier in search_path could be used instead of the  
system catalogs.  This could make psql offer misleading RESET candidates.  
  
Commit dbf5a83d465 schema-qualified the unnest() call in this same query,  
but the catalog references were still left unqualified.  Fix that by  
referring to pg_catalog.pg_db_role_setting and pg_catalog.pg_database  
explicitly.  
  
Backpatch to 18, where the tab-completion for ALTER DATABASE ... RESET  
was introduced.  
  
Bug: #19523  
Reported-by: Zhou Digoal <digoal@126.com>  
Author: Vismay Tiwari <vismay.t@gmail.com>  
Reviewed-by: Paul Kim <mok03127@gmail.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19523-424457118202f570@postgresql.org  
Discussion: https://postgr.es/m/CALHMmB84qkCgv3QAR78YawgfqQZCxSPkRhppxzU=e6fg8RA+AA@mail.gmail.com  
Backpatch-through: 18  

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

Fall back to SPI for RI checks with mismatched index collations

commit   : 0b0b413292161cf709b9dbc4d5adee23be53ee34    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 11 Sep 2026 17:48:32 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 11 Sep 2026 17:48:32 +0900    

Click here for diff

The fast path probes using the referenced index's collation. When that  
collation differs from the referenced column's, it can reject valid  
references or accept invalid ones. Changing the scan key's collation  
is not sufficient, since btree navigation must use the ordering under  
which the index was built.  
  
Cache index eligibility lazily after locking the referenced table,  
reloading the constraint information, and opening the index. Compare  
index and column collations using the held relation descriptors, and  
fall back to SPI on a mismatch. Also move the btree eligibility check  
here, avoiding a lookup of an index that REINDEX CONCURRENTLY could  
drop before the referenced-table lock is acquired.  
  
Cache both acceptance and rejection until the constraint information  
is reloaded, so subsequent rows need not repeat the comparisons. Check  
before probing or buffering any row. If batch entry initialization  
rejects the index, remove that entry while preserving any other pending  
checks.  
  
Add ICU regression coverage for per-row validation, ordinary inserts,  
reordered index columns, both directions of collation mismatch, and  
fallback while another foreign key check is pending.  
  
Reported-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAA4eK1Lk1DfgiFPL-HccZm-Nm+exg+FcsODH8KPw6BOBuzfHtA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/utils/adt/ri_triggers.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
M src/tools/pgindent/typedefs.list

Validate ALTER PUBLICATION after acquiring the publication lock.

commit   : 5624de9904ca560c0d4473cb9e86108f4b69be38    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 11 Sep 2026 09:51:05 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 11 Sep 2026 09:51:05 +0530    

Click here for diff

AlterPublicationOptions() can use stale publication state when the  
publication is modified concurrently while waiting for the publication  
lock. In particular, a concurrent ALTER PUBLICATION ... SET ALL TABLES  
can change puballtables, causing the validation to make decisions based  
on the old value and leads to assertion failure. Likewise,  
CheckAlterPublication() could miss a table added concurrently, letting  
SET ALL TABLES EXCEPT (...) leave pg_publication_rel with a mixture of  
inclusion and exclusion rows.  
  
Fix by acquiring the lock and re-reading the publication tuple in  
AlterPublication() before either path runs, and by calling  
CheckAlterPublication() only after that.  
  
Also fix 037_except.pl, which left one computed result untested and  
silently reused a subscription created by an earlier test.  
  
Author: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com  
Backpatch-through: 19, where it was introduced  

M src/backend/commands/publicationcmds.c
M src/test/subscription/t/037_except.pl

Add relation option toast_value_type

commit   : f33844889bb6950f9c207b9ea4830947f1e1f50e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 11 Sep 2026 12:26:58 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 11 Sep 2026 12:26:58 +0900    

Click here for diff

This relation option gives the possibility to define the attribute type  
that can be used for chunk_id in a TOAST table when it is initially  
created.  An update of this parameter has no effect if a TOAST table  
already exists under the relation, even on rewrites.  It cannot be set  
for TOAST relations.  
  
This new option can be set only to "oid" as of this commit.  This  
feature is extracted as a patch of its own to ease the introduction of a  
second mode in a follow-up change, related to the introduction of 8-byte  
OIDs in external TOAST pointers.  
  
Bump catalog version, as StdRdOptions has changed.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz  

M doc/src/sgml/ref/create_table.sgml
M src/backend/access/common/reloptions.c
M src/backend/catalog/toasting.c
M src/bin/psql/tab-complete.in.c
M src/include/catalog/catversion.h
M src/include/utils/rel.h
M src/test/regress/expected/reloptions.out
M src/test/regress/sql/reloptions.sql
M src/tools/pgindent/typedefs.list

Add static assertion to track the no-padding rule of varatt_external_oid

commit   : 1497ea77edd2ce261670f117301dc4da33d4c894    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 11 Sep 2026 10:58:51 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 11 Sep 2026 10:58:51 +0900    

Click here for diff

varatt_external_oid (varatt_external in v19 and older branches) having  
no padding is a rule that has been implied for years, as pointers of  
this structure may be compared using memcpy().  
  
I doubt that anybody is going to break this rule as varatt_external is  
old enough that it could vote in most countries, but this makes varatt.h  
more consistent for a follow-up change that introduces a second on-disk  
external TOAST pointer, and it's free to have a compile-time rule.  
  
Suggested-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACVG9cjxr-0jb8PP_Vb7vJvVGBVM_fQ2srt4CpyURpfYhQ@mail.gmail.com  

M src/include/varatt.h

Add support for TOAST chunk_id type in binary upgrades

commit   : 34fcd735f1ebd5efba8653cdbfbfd076b081660a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 11 Sep 2026 10:54:48 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 11 Sep 2026 10:54:48 +0900    

Click here for diff

This commit adds a new SQL function able to set the type of a chunk_id  
attribute for a TOAST table across binary upgrades.  The value is set  
when the creation of a TOAST table is required across upgrades, in the  
same fashion as the TOAST relation's oid and relfilenode.  
  
Note that this piece currently works only with a TOAST table's chunk_id  
set at OIDOID, because it is currently the only type of on-disk external  
TOAST pointer supported.  This change is required for a follow-up  
feature that aims to introduce support for 8-byte OIDs in external TOAST  
pointers.  
  
Taking care of this issue separately is less code churn for the next  
changes, and perhaps some of the surrounding discussions with support  
for different types of external on-disk TOAST pointers will find this  
new facility useful.  
  
Bump catalog version.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz  

M src/backend/catalog/heap.c
M src/backend/catalog/toasting.c
M src/backend/utils/adt/pg_upgrade_support.c
M src/bin/pg_dump/pg_dump.c
M src/include/catalog/binary_upgrade.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/modules/spgist_name_ops/expected/spgist_name_ops.out

Revert 87b2968df0 and 0a90df58cf.

commit   : ba9e747c49a6c09975db04bee64b22c0c304fa12    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Thu, 10 Sep 2026 18:12:48 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Thu, 10 Sep 2026 18:12:48 -0700    

Click here for diff

Those changes were intended to avoid dependencies on the global libc  
locale settings by basing identifier casefolding on the default  
locale.  They introduced an unintentional behavior difference for the  
builtin provider with locale C and a single-byte encoding.  
  
Instead of fixing that edge case, just revert the changes.  The  
identifier casefolding behavior has always been based on the global  
libc locale, and clients make an effort to use the same rules.  Until  
we have a plan to change that, provider-specific identifier  
casefolding doesn't make sense.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260826225510.10.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/parser/scansup.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/pg_locale_builtin.c
M src/backend/utils/adt/pg_locale_icu.c
M src/backend/utils/adt/pg_locale_libc.c
M src/include/utils/pg_locale.h

Fix misplaced comment in snapbuild.c.

commit   : 504fe10d1d260159369e10ff151ff28aaa091c44    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 10 Sep 2026 13:33:21 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 10 Sep 2026 13:33:21 -0700    

Click here for diff

Commits 2bef06d516 and 240e0dbacd added code between the comment and  
the assignment it describes, so the comment now appears to explain an  
unrelated line. Move it back to its original place.  
  
Author: Antonin Houska <ah@cybertec.at>  
Discussion: https://postgr.es/m/14864.1788978951@localhost  

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

Rename PqMsg_Progress to PqParallelMsg_Progress.

commit   : 8367b63e2cabb69ca0f9a5a6e6f04a1869b525a3    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 10 Sep 2026 15:10:35 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 10 Sep 2026 15:10:35 -0500    

Click here for diff

The previous name was considered to be unduly generic.  This commit  
addresses that by adding a new "PqParallelMsg" prefix for protocol  
characters sent by parallel workers to leader processes.  The new  
prefix can be reused for new parallel worker message types added in  
the future.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Discussion: https://postgr.es/m/CAN12%2BYLqbiA1v3FPD94yLbXgdyoWxVEY6%3DDtdpTPo9YCRuCpfg%40mail.gmail.com  

M src/backend/access/transam/parallel.c
M src/backend/utils/activity/backend_progress.c
M src/include/libpq/protocol.h

pg_plan_advice: Document interaction with GEQO.

commit   : 3117cf38822d872ed66861af1b4bc159818e4728    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 10 Sep 2026 13:54:30 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 10 Sep 2026 13:54:30 -0400    

Click here for diff

The general nature of this interaction has been understood (at least  
by me) since before the original commit, but I failed to explicitly  
document it. I also left behind an XXX in the README which I intended  
to remove before commit. Fix those things.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com  

M contrib/pg_plan_advice/README
M doc/src/sgml/pgplanadvice.sgml

pg_plan_advice: pgindent

commit   : f15036f20b992c782564001372d9dfe044a2beb8    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 10 Sep 2026 13:46:26 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 10 Sep 2026 13:46:26 -0400    

Click here for diff

Oversight in 1129570f654e96d45bbc63397079171af29710b9  
  
Reported-by: Nazir Bilal Yavuz <byavuz81@gmail.com> (off-list)  
Backpatch-through: 19  

M contrib/pg_plan_advice/pgpa_ast.c

Rework REPACK's documentation on clustering

commit   : 8db08e2522954916009dccdd88a634b1658bc522    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 10 Sep 2026 17:56:39 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Thu, 10 Sep 2026 17:56:39 +0200    

Click here for diff

Commit ac58465e0618 moved the discussion on clustering from CLUSTER's  
refpage to REPACK's, but somehow introduced a mistake regarding when  
exactly can the seqscan-and-sort strategy be used with respect to btrees  
(spoiler: it was 100% backwards).  Fix that, but also restructure and  
reword the whole subsection more fully to try and make it more coherent.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Reported-by: Antonin Houska <ah@cybertec.at>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/69CA7636-0359-42B6-B971-16A036698187@gmail.com  

M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c

postgres_fdw: Adjust warning message in statistics import.

commit   : 9f4bd91a1960f0263c497a9a1ddf121cbcefbb98    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 10 Sep 2026 17:30:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 10 Sep 2026 17:30:00 +0900    

Click here for diff

The previous warning message when falling back to sampling in a certain  
case failed to properly mention the reason for that.  
  
Also, for clarity, rewrite a comment about the fallback and add a note  
about it to postgres-fdw.sgml.  
  
Follow-up to commit 6a8571568.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwHq1VuXwxeDU8N4dd9U4RFEW982qQ9C26mRQDs3nu_Naw%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c
M doc/src/sgml/postgres-fdw.sgml

Clarify RI tuple-lock result handling comments

commit   : 5e34fe3580559c3eee82a32308d8a387c57e8dfd    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 10 Sep 2026 17:17:16 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 10 Sep 2026 17:17:16 +0900    

Click here for diff

Explain that returning false for TM_SelfModified follows ExecLockRows(),  
which skips such tuples. This differs from TM_Updated, which is  
unexpected in READ COMMITTED with FIND_LAST_VERSION.  
  
Also remove "fall through to error" from the TM_Updated comment, since  
the code calls elog(ERROR) directly.  
  
Reported-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAA4eK1Lk1DfgiFPL-HccZm-Nm+exg+FcsODH8KPw6BOBuzfHtA@mail.gmail.com  
Backpatch-through: 19  

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

Remove stale comment and redundant assignment in BuildTupleHashTable()

commit   : bd9d6ffa1aea612cc8da31f7b30d5573747b86f8    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 16:11:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 16:11:38 +0900    

Click here for diff

Since commit bf6c614a2f2, BuildTupleHashTable() has created the table  
slot unconditionally rather than on the first lookup. However, the  
comment still described the old behavior, and tableslot was still  
redundantly initialized to NULL before being assigned the new slot.  
  
Remove the stale comment and redundant assignment.  
  
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>  
Discussion: https://postgr.es/m/CAHza6qfduAcYc3HdXP5DYscNstz0ic6ctHTNH70VL1Uy-nJ6zg@mail.gmail.com  

M src/backend/executor/execGrouping.c

Split transaction data out of pgstats table counters

commit   : 3f2f5e7c4cc5a917e77a3d5a0c4353b702aa7307    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 13:54:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 13:54:26 +0900    

Click here for diff

At backend level, PgStat_TableCounts currently stores all the per-table  
pending counters in one structure.  This is now split into two parts,  
with the transactional part of the data moved out of PgStat_TableCounts  
into its own structure labelled with an "xact" in PgStat_RelationStatus.  
  
While on it, move truncdropped out of the counters and into  
PgStat_RelationStatus so as both structs (existing PgStat_TableCounts  
and new PgStat_TableCountsXact) contain only counters.  The previous  
state was slightly confusing: this flag is a state tracking if a  
relation has been truncated at backend-level, and not a counter.  
  
Because truncdropped no longer lives inside PgStat_TableCounts, this  
commit teaches the flush callback to treat a pending truncate as  
sufficient reason to flush, even when both counter structs are otherwise  
all zeros.  
  
This refactoring work is in preparation of a different patch that wants  
to introduce the concept of transactional stats data flush.  Compared to  
all the other stats kinds, relations are an exception as they mix  
transactional and non-transactional data.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/aoU32VTkUtpdUewB@paquier.xyz  

M src/backend/utils/activity/pgstat_relation.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/pgstat.h
M src/tools/pgindent/typedefs.list

Take RI fast-path snapshot after locking referenced relation

commit   : 3f660d86ba65d9747d5e2da418e24bd023271241    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 10 Sep 2026 13:31:09 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 10 Sep 2026 13:31:09 +0900    

Click here for diff

ri_FastPathCheck() acquired its scan snapshot before opening the  
referenced relation.  If it then waited for the relation lock in READ  
COMMITTED mode, a referenced row committed during the wait would not be  
visible to the old snapshot.  The check could consequently report a  
foreign key violation even though the referenced row existed.  
  
The batched path acquires its scan snapshot after opening the relations,  
so it does not have the lock-wait problem.  The per-row path remains  
reachable during constraint validation and checks re-entered from a  
batch flush.  
  
Take the snapshot after opening the referenced relation and reloading  
the constraint information.  This also agrees with the SPI path, which  
acquires the referenced-relation lock before selecting the snapshot  
used for the check.  
  
Also make the scan snapshot active for the duration of the check, so  
STABLE cast and equality functions use the same snapshot as the index  
scan.  Otherwise, a STABLE cast can miss rows inserted by earlier AFTER  
triggers and cause a valid foreign key to be rejected.  Add a  
regression test comparing this case with the SPI path.  
  
Finally, also advance the command counter after acquiring the  
referenced-relation lock and before reloading the constraint  
information, so local invalidations are processed under the lock, as in  
the SPI path.  
  
Add an injection-point test that pauses a per-row check before locking  
the referenced relation, commits the missing referenced row in another  
session, and verifies that validation succeeds.  Force per-row  
validation by using a role without SELECT privilege on the referenced  
table, so the test exercises this path even with batching enabled.  
  
Add isolation-test coverage for the visibility of a referenced row  
committed after the referencing transaction has executed an earlier  
command.  A later command can see such a row in READ COMMITTED, but not  
in REPEATABLE READ or SERIALIZABLE.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CA+HiwqEhm+_=bs=2wavAJz-UqC+1KebD31++mapJQQGweE8iQQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/utils/adt/ri_triggers.c
M src/test/isolation/expected/fk-snapshot-2.out
M src/test/isolation/specs/fk-snapshot-2.spec
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/ri_fastpath_snapshot.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/ri_fastpath_snapshot.spec
M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql

doc: Mention pg_stat_force_next_flush()

commit   : c8985a09b7b52519f794c433e5f8f7311a77a2fc    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 13:19:11 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 13:19:11 +0900    

Click here for diff

pg_stat_force_next_flush() has primarily been used in in-core tests to  
force cumulative statistics to be flushed at the end of a transaction  
without waiting for the PGSTAT_MIN_INTERVAL throttle, to speed up  
things.  
  
It is also useful in tests outside the core tree.  Spoiler: I have used  
it myself for some out-of-core work for the same reason as the in-core  
tests, and would have unlikely known about it without my work on the  
core code.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Discussion: https://postgr.es/m/aqEONVuLhgBiqHW6@paquier.xyz  

M doc/src/sgml/monitoring.sgml

pgbench: Improve handling of NULL in \gset and \aset

commit   : d8304bc661c29600f82ba62719457837edf47b08    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 13:10:54 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 13:10:54 +0900    

Click here for diff

Previously, readCommandResponse() stored every column with PQgetvalue(),  
which returns an empty string for the SQL NULL value.  An empty string  
is not a valid value in the pgbench expression language, and when  
returned by the server it was also indistinguishable from a NULL.  
  
When receiving a value, pgbench now checks for PQgetisnull() and sets a  
NULL value with setNullValue() before saving it.  This behavior is more  
consistent with \set, making the result saved testable with IS NULL.  
  
This is a quality-of-life improvement, so no backpatch is done.  
  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAOzEurT9J9QMmpJt_8pWZCziNYCUHOD=c-hoccOVYJLc_VxVRg@mail.gmail.com  

M src/bin/pgbench/pgbench.c
M src/bin/pgbench/t/001_pgbench_with_server.pl

Fix pg_iswcased().

commit   : 43a948b7b252344a79eb49b9f3c5c8832bee19a9    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 9 Sep 2026 20:39:53 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 9 Sep 2026 20:39:53 -0700    

Click here for diff

Commits 630706ced0 and 9c8de15969 lost some encoding-specific nuances:  
in libc with EUC encodings, or in ICU with any non-UTF8 encoding, we  
cannot easily classify characters, so we must assume they are  
case-varying. Restore these behaviors.  
  
Previously, ILIKE using an index scan could cause wrong results.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260826221526.89.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/pg_locale_icu.c
M src/backend/utils/adt/pg_locale_libc.c

Fix REPACK command reporting in pg_stat_progress_cluster

commit   : 4dd037286e06116f6f4af70a291e215c0a111c24    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 11:54:08 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 11:54:08 +0900    

Click here for diff

pg_stat_progress_cluster translates REPACK into VACUUM FULL when  
pg_stat_progress_repack.repack_index_relid is zero, and into CLUSTER  
otherwise.  
  
Previously, repack_index_relid was set only when an index scan was used.  
When REPACK used a sequential scan and sort to order the table by an index,  
the field remained zero even though index ordering had been requested. As a  
result, pg_stat_progress_cluster incorrectly reported the command as  
VACUUM FULL instead of CLUSTER.  
  
Fix this by setting repack_index_relid to the OID of the requested ordering  
index when progress reporting starts, regardless of the scan method. This  
allows pg_stat_progress_cluster to correctly report REPACK as CLUSTER when  
index ordering is requested.  
  
Also update the documentation to clarify the meaning of the index columns  
and how REPACK is translated into CLUSTER or VACUUM FULL.  
  
Suggested-by: Fujii Masao <masao.fujii@gmail.com>  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFMzy2V_wvRCBW5K8=wVCk1-C7nq=8otXO=u+s_1KZHqyA@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml
M src/backend/access/heap/heapam_handler.c
M src/backend/commands/repack.c

Fix pg_stat_progress_cluster command reporting for unprivileged users

commit   : 054c1c3e650b2fe0c44570a59bc4ea05bd2ac142    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 11:51:06 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 11:51:06 +0900    

Click here for diff

Previously, when another session ran REPACK, CLUSTER, or VACUUM FULL and  
the user lacked permission to view its progress details,  
pg_stat_progress_cluster incorrectly reported the command as CLUSTER  
instead of NULL.  
  
pg_stat_progress_cluster is based on pg_stat_progress_repack and  
translates REPACK into CLUSTER or VACUUM FULL depending on whether index  
ordering is requested. However, this translation defaulted to CLUSTER,  
incorrectly converting NULL commands returned for insufficient privileges  
into CLUSTER.  
  
Fix this translation to preserve a NULL command when the user lacks  
permission to view the progress details.  
  
Bump catalog version.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <lic@highgo.com>  
Discussion: https://postgr.es/m/CAN4CZFMzy2V_wvRCBW5K8=wVCk1-C7nq=8otXO=u+s_1KZHqyA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/catalog/system_views.sql
M src/include/catalog/catversion.h
M src/test/regress/expected/rules.out

test_bitmapset: Improve handling of incorrect inputs

commit   : 34c11958b6f12a90c0ec9fca3ce502a32280c30d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 11:25:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 11:25:24 +0900    

Click here for diff

The SQL wrappers of the module relied on stringToNode(), that entirely  
trusts its input.  This commit applies an extra round of validation, to  
prevent the test module from crashing on incorrect inputs, provided  
through the SQL functions.  
  
No backpatch, as this is no critical issue.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/CAN4CZFOTQXMZvuPxweO4Fm7+sjrPJUqU-JvYKETLBxuhqgbPjw@mail.gmail.com  

M src/test/modules/test_bitmapset/expected/test_bitmapset.out
M src/test/modules/test_bitmapset/sql/test_bitmapset.sql
M src/test/modules/test_bitmapset/test_bitmapset.c

test_extensible: Improve handling of incorrect inputs

commit   : 7ac0c2d058adb0aa47b7deb444c1949b84b7d781    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 11:02:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 11:02:21 +0900    

Click here for diff

The SQL wrappers of the module relied on stringToNode(), that trusts  
its input.  When specifying node strings that to not match with the  
expected ExtensibleNode "TestExtNode", the module would crash.  
  
This adds a simple set of sanity checks to check the input, ensuring  
that only an ExtensibleNode "TestExtNode" goes through.  Though far  
from critical, it's always nice to make these test modules not crash  
when used.  
  
Oversight in 0e944fe3579.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/CAN4CZFOTQXMZvuPxweO4Fm7+sjrPJUqU-JvYKETLBxuhqgbPjw@mail.gmail.com  

M src/test/modules/test_extensible/expected/test_extensible.out
M src/test/modules/test_extensible/sql/test_extensible.sql
M src/test/modules/test_extensible/test_extensible.c

Fix duplicate enforcement of EC-derived conditions

commit   : 895c1b5fe1ecaf3d0c5cb1ce5a85ab95e4c27dfb    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Thu, 10 Sep 2026 10:02:06 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Thu, 10 Sep 2026 10:02:06 +0900    

Click here for diff

A clause connecting the same two EC members can be requested from the  
EC machinery in different contexts.  When building parameterized index  
paths for a relation, generate_implied_equalities_for_column derives  
an indexable clause with parent_ec set, to mark it as redundant with  
other join clauses derived from the same EC.  Meanwhile, at a join  
where the relations of a multi-relation EC member first come together,  
generate_join_implied_equalities emits a clause equating the same two  
members with parent_ec unset, since that clause is the sole enforcer  
of its member there and must not be dropped as redundant.  Because  
create_join_clause treats parent_ec as part of its cache-lookup key,  
such requests can yield two different RestrictInfos for the same  
condition, carrying different rinfo_serials.  
  
This breaks the assumption that one condition has exactly one serial  
number, which create_nestloop_path relies on to drop join clauses that  
are already enforced within a parameterized inner path.  As a result,  
the same condition could be enforced twice at different plan levels,  
wasting execution effort and applying the clause's selectivity twice,  
underestimating the join's row count.  
  
To fix, make create_join_clause copy the rinfo_serial from an existing  
clause that connects the same two members with the opposite parent_ec  
marking, so that the two clauses keep their distinct markings but are  
recognized as the same condition.  
  
As a result, a duplicate join filter disappears from one of the  
existing regression plans (the "cardinal_number" query in join.sql);  
the other plan changes are join-order differences between plans of  
essentially equal cost.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAMbWs4-3yZeBMGQDpmYRPdV-sL_=6H2AN=MoeneOT+VUk28PPg@mail.gmail.com  
Backpatch-through: 19  

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

Fix more duplicate qual clauses in parameterized paths

commit   : 8510bcc981bd4bba06fd2c038dab7cc15887b51e    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Thu, 10 Sep 2026 10:01:10 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Thu, 10 Sep 2026 10:01:10 +0900    

Click here for diff

Commit f836b688f ensured that at most one clone of a join clause is  
chosen for a parameterized path, so long as the clone variants are  
parse-tree distinct.  Two ways remained to end up enforcing the same  
condition more than once, which wastes execution effort and applies  
the clause's selectivity multiple times, underestimating the row  
count.  
  
If a commuting outer join nulls no Var referenced by a particular  
qual, the clone variants of that qual are parse-tree identical, and  
the incompatible_relids test cannot tell them apart.  To fix, enforce  
just the first surviving variant, identified by rinfo_serial.  
  
The other case is in get_joinrel_parampathinfo, where the  
clause-recovery pass for dropped EquivalenceClasses queries the EC  
machinery with a context that overlaps the preceding loop's, so the  
derived-clause cache can hand back a clause that that loop already  
accepted.  To fix, skip any clause that is already present in the  
collected list.  
  
Also add assertions verifying that the clauses to be enforced at a  
join or within a parameterized path contain no duplicate rinfo_serial,  
to catch any remaining or future violations.  These assertions are  
added in master only, since hard prevention of duplicate clauses is a  
new goal and other unfixed cases may remain.  
  
Back-patch to v19, as with commit f836b688f.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAMbWs4_Ezb1Lnj7BqcTQSysC6B5UFZxfhib8xr6rqpu5uqr8dA@mail.gmail.com  
Backpatch-through: 19  

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

postgres_fdw: Fix crash when estimating joins with functions

commit   : 3430fba3b0f0655e203a4b03dd531d7bcad86ff3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 09:46:44 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 10 Sep 2026 09:46:44 +0900    

Click here for diff

Commit 0ee83dd4a99 allowed postgres_fdw to push down inner joins between  
foreign tables and functions in FROM clauses to the remote server.  
However, planning such a join with use_remote_estimate enabled could  
cause a segmentation fault. For example, the following query crashed  
when ft had use_remote_estimate set to true:  
  
    EXPLAIN SELECT * FROM generate_series(1, 3) g JOIN ft ON ft.i = g;  
  
The crash occurred because init_func_stub_fpinfo() copied the connection  
information and options from the foreign side to the function-side stub,  
but omitted the user mapping, leaving it NULL. When the function was the  
outer side of the join, the join inherited this NULL mapping and passed it  
to GetConnection() when requesting a remote estimate, causing a  
segmentation fault.  
  
Fix this by having init_func_stub_fpinfo() also copy the user mapping  
from the foreign side.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Alexander Pyhalov <a.pyhalov@postgrespro.ru>  
Discussion: https://postgr.es/m/CAHGQGwGE9xPzCke0C0r4omTkh-hU08aBd2j9oSA0FYmJLCf9jA@mail.gmail.com  

M contrib/postgres_fdw/postgres_fdw.c

Widen Object ID counter to 8 bytes

commit   : cb298616463d6e4f2c360e8d07b83b526fad375f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 09:39:18 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 10 Sep 2026 09:39:18 +0900    

Click here for diff

This commit adds a new routine called GetNewObjectId8() in varsup.c,  
which is able to retrieve a 8-byte OID, based on the next OID retrieved  
from the control file.  GetNewObjectId() is kept compatible with its  
origin, where we still check that the lower 32 bits of the counter do  
not wraparound, while handling the FirstNormalObjectId case.  
  
This change is combined with an update of the control file, with  
CheckPoint.nextOid enlarged from Oid to Oid8.  pg_control_checkpoint(),  
pg_resetwal and pg_upgrade are updated to adapt to this change, to make  
sure that the value is not truncated due to 32-bit limitations when  
used, making an upgrade to a newer version where 8-byte is supported a  
transparent operation.  
  
A couple of comments in the xlog redo logic referred to wraparound  
issues, which is not the case anymore with this change in place, so  
refresh these.  
  
This change is required to be able to support external TOAST pointers  
based on Oid8, under discussion, and can be used for other purposes.  
  
Tests are added for pg_upgrade (2^32 value carried across upgrades),  
pg_resetwal and pg_control_checkpoint(), hence across all the tools  
that need to be covered by this change.  
  
Bump catalog version.  
Bump PG_CONTROL_VERSION.  
Bump XLOG_PAGE_MAGIC, due to XLOG_NEXTOID.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz  

M doc/src/sgml/func/func-info.sgml
M doc/src/sgml/ref/pg_resetwal.sgml
M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/varsup.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/utils/misc/pg_controldata.c
M src/bin/pg_controldata/pg_controldata.c
M src/bin/pg_resetwal/pg_resetwal.c
M src/bin/pg_resetwal/t/001_basic.pl
M src/bin/pg_upgrade/controldata.c
M src/bin/pg_upgrade/pg_upgrade.c
M src/bin/pg_upgrade/pg_upgrade.h
M src/bin/pg_upgrade/t/002_pg_upgrade.pl
M src/include/access/transam.h
M src/include/access/xlog.h
M src/include/access/xlog_internal.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_control.h
M src/include/catalog/pg_proc.dat

pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth()

commit   : 1129570f654e96d45bbc63397079171af29710b9    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 9 Sep 2026 17:48:54 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 9 Sep 2026 17:48:54 -0400    

Click here for diff

Without CHECK_FOR_INTERRUPTS(), backends might not respond to query  
cancellations in a timely fashion, especially for JOIN_ORDER()  
specifications, where matching against each join can take O(n^2) time  
in the length of the join order list in degenerate cases.  
  
Recursive functions should check_stack_depth().  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com  
Backpatch-through: 19  

M contrib/pg_plan_advice/pgpa_ast.c
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/pgpa_trove.c

Add pg_nodiscard decorations to some Bitmapset functions.

commit   : d2b65863f04f99eab15eca01a54708d2f8ad6099    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 9 Sep 2026 16:30:04 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 9 Sep 2026 16:30:04 -0500    

Click here for diff

There's no conceivable use-case for ignoring the result of the  
functions that return a pointer to a Bitmapset.  Add pg_nodiscard  
decorations to those like commit a378ba49a5 did for some functions  
in pg_list.h.  
  
Author: Jan Nidzwetzki <jan@planetscale.com>  
Discussion: https://postgr.es/m/2020a70e-76f3-4661-afa6-82c2639251c2%40planetscale.com  

M src/include/nodes/bitmapset.h

Fix hangs in COPY FROM (FORMAT text).

commit   : d1895a11c8f1b19b3fe0db45cc10a9d26c56bc8c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 9 Sep 2026 16:02:24 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 9 Sep 2026 16:02:24 -0500    

Click here for diff

The SIMD path for this command reads ahead via CopyLoadInputBuf()  
whenever fewer than sizeof(Vector8) bytes remain in the input  
buffer, even if those bytes hold a complete end-of-copy marker.  
If the input is a pipe whose writer has sent the marker but not  
closed the pipe, that read blocks, and COPY waits for data it will  
never use.  The scalar loop asks only for the bytes it needs, so  
it stops at the marker without reading any further.  
  
To fix, teach CopyLoadInputBuf() to decline a speculative load  
when the caller's remaining bytes contain a backslash, which in  
text mode might begin such a marker.  (CSV mode doesn't treat  
\. as special, so it is unaffected.)  The SIMD path then hands  
those bytes to the scalar loop, as it already does when a load  
comes up short.  Checking for the marker in the SIMD helper itself  
would be more direct, but a call there costs the compiler  
registers on every line, which measurably slowed COPY of short  
lines in testing.  
  
Oversight in commit e0a3a3fd53.  
  
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/CAN55FZ1qFb4Yo3-MWeQfGQnu1_Ksx4xcFC2m3hyw8a--%2BeHQYQ%40mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/copyfromparse.c

Unify REPACK (CONCURRENTLY) error messages.

commit   : 4964c75b0889ab79a268dc1e1027e4dabe0c7dfd    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 9 Sep 2026 13:45:43 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 9 Sep 2026 13:45:43 -0700    

Click here for diff

Commit 86f7c82cf102 reported the user catalog table restriction as a  
detail, but the other checks in check_concurrent_repack_requirements()  
were still a mix: some were hints, and the details repeated  
"REPACK (CONCURRENTLY)", which the primary message already names.  
  
Report them as details with the same "This operation ..." wording. The  
one actionable hint, ALTER TABLE ... REPLICA IDENTITY USING INDEX,  
stays.  
  
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Suggested-by: Alvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan  
Backpatch-through: 19  

M contrib/test_decoding/expected/repack.out
M src/backend/commands/repack.c

Fix concurrency issues with DROP TABLESPACE

commit   : a12600b762c36d91450ce085fa25ef75250bc1c2    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 9 Sep 2026 10:50:09 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Wed, 9 Sep 2026 10:50:09 -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

Fix error message for concurrent repack on materialized views

commit   : 412ef97d925c54d6135afb4c22cceccb6421d8a2    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 9 Sep 2026 12:58:00 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 9 Sep 2026 12:58:00 +0200    

Click here for diff

Previously, running REPACK (CONCURRENTLY) on a materialized view failed  
with a confusing "has no identity index" error.  
  
REPACK (CONCURRENTLY) replays changes decoded from WAL, but a  
materialized view produces none, since it cannot be modified by DML and  
REFRESH rewrites it through a transient heap that is not logically  
decoded.  
  
Fix this by reporting a clear error for materialized views upfront,  
alongside the existing checks for system catalogs and TOAST tables, and  
document the limitation.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Kiran Kaki <itskkpg@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CALj2ACXPvy4_LkQ0nHKgbZjAGK9fkDqRYUvXA3hgwxPm_X7Eng@mail.gmail.com  

M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c

Remove stale XXX comment in logical launcher

commit   : 7beefa8d46978341aed7ba14cc82bf37c0564948    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 9 Sep 2026 11:10:15 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 9 Sep 2026 11:10:15 +0200    

Click here for diff

An XXX comment in launcher.c added by commit 2af1dc89282b questioned why  
the slot drop does not request disabling logical decoding.  But the  
conflict detection slot is a physical slot, so there is no logical  
decoding state to disable.  Remove that comment and clarify the  
situation elsewhere.  
  
Author: "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/TY4PR01MB177186C8AB596F30DF704ECDC94B62@TY4PR01MB17718.jpnprd01.prod.outlook.com  

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

Restrict REPACK (CONCURRENTLY) on user catalog tables.

commit   : 86f7c82cf1023e3599f40f939727791a7090cd44    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 13:04:56 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 13:04:56 -0700    

Click here for diff

REPACK (CONCURRENTLY) is not an MVCC-safe operation; it doesn't  
preserve the visibility information, which logical decoding needs  
because it reads user catalog tables under a historic snapshot.  
  
Disallow REPACK (CONCURRENTLY) on user catalog tables. Removing this  
check requires making it MVCC-safe and logical rewrite mappings.  
  
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.  
  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan  
Backpatch-through: 19  

M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c

Fix REPACK (CONCURRENTLY) when the table owner lacks CONNECT.

commit   : 0717ed2623683cbbe206d0b651817a3a1e0cf0de    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 12:06:06 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 12:06:06 -0700    

Click here for diff

REPACK (CONCURRENTLY) launches a background worker to decode changes  
made while the table is being rewritten. The worker connects as the  
table owner but bypassed the LOGIN check only, so CONNECT was still  
checked against a role that need not have it, and the command could  
fail with "permission denied for database".  
  
Pass BGWORKER_BYPASS_ALLOWCONN as well, as we do for parallel  
workers. That is safe because the leader already checked the invoking  
user's privileges on the table before starting the worker.  
  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Author: Matheus Alcantara <mths.dev@pm.me>  
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/apBbzFd_EYAfHV45@nathan  
Backpatch-through: 19  

M src/backend/commands/repack_worker.c

Restrict REPACK (CONCURRENTLY) to the heap access method.

commit   : e8636f2bed258ca5be115aca33de00346d687de4    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 11:49:11 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 11:49:11 -0700    

Click here for diff

REPACK (CONCURRENTLY) didn't check the table AM of the table being  
repacked, so if the table AM doesn't support logical decoding, the  
concurrent changes are never decoded and are silently lost from the  
rewritten table.  
  
Fix by erroring out for tables that use a non-heap access method.  
  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/apBkixO4xAGFoiT3@nathan  
Backpatch-through: 19  

M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c

Fix tablesync failure for partitioned tables on older publishers.

commit   : 11fb89fdbd319a53e32dce77685118979cafac0e    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 11:12:34 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 8 Sep 2026 11:12:34 -0700    

Click here for diff

Commit 266543a made initial table synchronization use "COPY table TO"  
for a partitioned table, but decided that from the relation kind  
alone. A partitioned table is only accepted there since v19, so a v19  
subscriber replicating from an older publisher with  
publish_via_partition_root failed at table sync.  
  
Check the publisher version, and fall back to the "COPY (SELECT ...)  
TO" variant otherwise.  
  
Backpatch to v19, where 266543a changed the initial table  
synchronization.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260905040020.57.noahmisch@microsoft.com  
Backpatch-through: 19  

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

pg_stash_advice: Fix failure to reload empty advice string.

commit   : dc33cca1859e2d2500ee8f3c0e564561428b4fcf    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Tue, 8 Sep 2026 10:00:22 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Tue, 8 Sep 2026 10:00:22 -0400    

Click here for diff

There's not really any good reason to store an empty advice string  
in an advice stash, but it's entirely possible that some people might  
do it by accident. If they do that without this fix, restarting the  
system will result in failure while reloading pg_stash_advice.tsv.  
  
The root cause is that I (rhaas) did not think clearly enough when  
defining pgsa_next_tsv_field(). After returning each field on the  
line, it set *cursor to the start of the next field, and after  
returning all of them, it set *cursor to the trailing NUL byte. But  
when the last field on the line is empty, this is ambiguous: if we're  
pointing at the trailing NUL byte, it could be either because it's the  
start of the zero-length field or because we're out of fields. To  
remove the ambiguity, this commit decides that *cursor will instead  
be set to NULL when there are no more fields.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260827171830.68.noahmisch@microsoft.com  
Backpatch-through: 19  

M contrib/pg_stash_advice/stashpersist.c
M contrib/pg_stash_advice/t/001_persist.pl

Don't evaluate the FOR PORTION OF target under EXPLAIN

commit   : 140fdfcdf12d524541ff26491b8e2076a690e434    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 8 Sep 2026 14:34:31 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 8 Sep 2026 14:34:31 +0200    

Click here for diff

ExecInitModifyTable() evaluated ForPortionOfExpr.targetRange  
unconditionally at executor start-up, with no EXEC_FLAG_EXPLAIN_ONLY  
guard. This caused three problems:  
  
- EXPLAIN (GENERIC_PLAN) failed with "no value found for parameter 1".  
  
- Plain EXPLAIN with FOR PORTION OF (null) raised "FOR PORTION OF  
  target must not be null".  
  
- Plain EXPLAIN ran user functions appearing in the target a second  
  time, beyond the one evaluation the planner already does for  
  selectivity estimation.  
  
Now we skip the evaluation and the accompanying null check in  
explain-only mode.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>  
Discussion: https://www.postgresql.org/message-id/flat/CA%2BrenyXci9khYXJ8uSwzF30DVw%2Bzc4QwGb1RdsuOu_YtrFuy1g%40mail.gmail.com  

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

Reject REPACK (ANALYZE) in a transaction block

commit   : 25b21c0bb712b615f22cf5fcc176764a416368bd    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 8 Sep 2026 14:06:06 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 8 Sep 2026 14:06:06 +0200    

Click here for diff

The current implementation doesn't support it correctly, leading to  
mysterious warnings and some worse problems.  Have the combination throw  
an error.  
  
This is intended as a temporary stopgap until we can implement it in a  
future release, as it's a useful feature.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Author: Antonin Houska <ah@cybertec.at>  
Author: Osama Abdul Qader <osamaabdulqader.cs@gmail.com>  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/apBCEl4hBHlq0axm@nathan  

M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack.c
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql

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

commit   : 3bed1f91aa5f184202ffb24f5af359f5af2cd1cd    
  
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

Resolve untyped parameters in FOR PORTION OF FROM/TO bounds

commit   : 438f027238c0582e89d4c81e3f88d9b1d6d810d0    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 8 Sep 2026 09:35:44 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 8 Sep 2026 09:35:44 +0200    

Click here for diff

FOR PORTION OF valid_at FROM $1 TO $2 fails with "could not determine data  
type of parameter $1", so using PREPARE requires users to say $1::date  
etc. But transformForPortionOfClause() already coerces the bounds, since  
it builds a constructor for the targeted range. We just need to store the  
coerced expressions in targetFrom and targetTo.  
  
This also improves pg_get_ruledef(), which now renders an untyped NULL  
bound as NULL::date instead of NULL::unknown.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>  
Discussion: https://www.postgresql.org/message-id/flat/CA%2BrenyW1uJp1dw%3DiK7MsWfbbZf-dKP_4JLoQ65wj%3Dfry35FjCw%40mail.gmail.com  

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

Stabilize 026_overwrite_contrecord test

commit   : a8e66b308695298f31001466caed97ee8ac52af7    
  
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 -Wshadow=local warnings

commit   : f9fc9a78a36517122c0325fd31db5ba6066d82ea    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 8 Sep 2026 07:42:59 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 8 Sep 2026 07:42:59 +0200    

Click here for diff

This fixes issues with the same variable name being used in the same  
function for two different variables.  (In some cases, one of the uses  
is a function argument.)  The fix is in most cases to rename one or  
both of them.  The individual choice depends on conventions in the  
surrounding code.  Often, making both variable names more specific is  
the best choice.  In a few cases, the fix is to move one of the  
variables to a lower scope, so that it no longer conflicts with the  
other.  
  
Since these are all local-variable conflicts, the changes in different  
files in this patch are independent of each other.  
  
These issues correspond to the gcc warning option -Wshadow=local,  
which is not currently used but could be activated after this.  
  
Reviewed-by: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/84b6f128-91f5-480e-8a9e-7d0e8f538cea%40eisentraut.org  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/access/brin/brin.c
M src/backend/access/gist/gistbuild.c
M src/backend/catalog/objectaddress.c
M src/backend/catalog/pg_constraint.c
M src/backend/commands/extension.c
M src/backend/commands/schemacmds.c
M src/backend/commands/statscmds.c
M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/executor/nodeAgg.c
M src/backend/executor/nodeValuesscan.c
M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/plan/createplan.c
M src/backend/partitioning/partdesc.c
M src/backend/statistics/dependencies.c
M src/backend/statistics/extended_stats.c
M src/backend/storage/aio/read_stream.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/utils/adt/jsonpath_exec.c
M src/backend/utils/adt/pg_upgrade_support.c
M src/backend/utils/adt/timestamp.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/cache/inval.c
M src/backend/utils/mmgr/freepage.c
M src/bin/pg_basebackup/pg_receivewal.c
M src/bin/pgbench/pgbench.c
M src/bin/psql/describe.c
M src/bin/psql/prompt.c
M src/bin/psql/prompt.h
M src/fe_utils/print.c
M src/include/lib/radixtree.h
M src/include/optimizer/paths.h
M src/include/storage/sinval.h
M src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
M src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/fe-secure-openssl.c

Fix buildfarm failure introduced by 6168c65ddc.

commit   : b3dfd8d4ea1547ccbb6fca64f0334e40762b0f4d    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Tue, 8 Sep 2026 10:46:20 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Tue, 8 Sep 2026 10:46:20 +0530    

Click here for diff

Commit 6168c65ddc added a test verifying that the conflict detection  
slot's xmin regresses to the horizon pinned by an in-progress transaction  
in the database of a newly added subscription that has retain_dead_tuples  
enabled. However, it used query_until(), which can return before starting  
a transaction, allowing the test to proceed without a pinned xid.  
  
Use query_safe() so the transaction setup completes synchronously and the  
xid is assigned before the xmin checks run.  
  
Per buildfarm.  
  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/OS9PR01MB12149257A97EE1BD3296F6AEBF5B12@OS9PR01MB12149.jpnprd01.prod.outlook.com  
Backpatch-through: 19  

M src/test/subscription/t/035_conflicts.pl

Remove incomplete pgstats entry for allocation failure at startup

commit   : c2bac0c0dbe31d1d027c5c53bc7f662b1bd0708d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 8 Sep 2026 14:12:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 8 Sep 2026 14:12:24 +0900    

Click here for diff

pgstat_init_entry() can fail after its hash entry has been inserted, in  
which case the caller has to remove the entry, as done by  
pgstat_get_entry_ref() since 8191e0c16a03.  pgstat_read_statsfile() was  
not exactly doing that, leaving an entry that could still point to an  
InvalidDsaPointer.  
  
There are no consequences here, even after 8191e0c16a03.  The stats are  
loaded from disk by the startup process, where an ERROR gets promoted to  
a FATAL, cleaning up shared memory.  So this is mostly an argument of  
consistency with the normal entry creation path, especially if someone  
decides to downgrade this ERROR to a WARNING in pgstat_read_statsfile().  
  
Author: Grigorev Jurij <ju.grigorev@ftdata.ru>  
Discussion: https://postgr.es/m/d55ecaf911844d53bd0a931751dce582@localhost.localdomain  

M src/backend/utils/activity/pgstat.c

pg_resetwal: Add test for -o with negative value

commit   : 1a531f787f89446db51942a67ee37ba5924d521d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 8 Sep 2026 12:42:09 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 8 Sep 2026 12:42:09 +0900    

Click here for diff

This has been extracted from a larger patch set, for a scenario that I  
have managed to break while working on a different change.  The case of  
-o with a negative value had no coverage.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/af19kUjwjhaoUTLn@paquier.xyz  

M src/bin/pg_resetwal/t/001_basic.pl

Fix nestloop parameter handling for PlaceHolderVars in child joins

commit   : 35d3f2069a3c842665bbc020295fb165dcb2b6ec    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 8 Sep 2026 10:04:37 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 8 Sep 2026 10:04:37 +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

Improve display of GUCs that are customarily written in octal.

commit   : 23c07b4604387b98efd25246b185b57be237d7ca    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 7 Sep 2026 16:05:18 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 7 Sep 2026 16:05:18 -0400    

Click here for diff

A few integer-valued GUCs representing Unix file permission masks  
are customarily written and shown in octal.  However, we implemented  
the "shown" part via show_hook functions, which is problematic  
because it only affects display of the current value.  It's confusing  
that, for example, the pg_settings view renders the current value in  
octal but the min, max, reset, and boot values in decimal.  
  
To improve matters, get rid of these custom show_hooks in favor of  
inventing a per-GUC flag GUC_SHOW_IN_OCTAL, which can be inspected in  
appropriate places.  I've implemented that in places that respond to  
units flags, but not in places that don't, such as GetConfigOption().  
  
It's tempting to consider going further, in particular adjusting  
input parsing so that we read the values of these variables in  
octal even without a leading zero.  I've refrained from doing so  
here because I'm afraid that it'd break more usages than it fixes,  
but perhaps there's a case to be made for that.  
  
Bug: #19540  
Reported-by: Jobin Augustine <jobinau@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/3006313.1782851535@sss.pgh.pa.us  

M src/backend/commands/variable.c
M src/backend/utils/misc/README
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/guc_funcs.c
M src/backend/utils/misc/guc_parameters.dat
M src/include/utils/guc.h
M src/include/utils/guc_hooks.h
M src/test/regress/expected/guc.out
M src/test/regress/sql/guc.sql

Revert SQL Property Graph Queries (SQL/PGQ)

commit   : b1f106c80cbeb18d3a0219994d98a51a6eca8ede    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 7 Sep 2026 19:51:46 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 7 Sep 2026 19:51:46 +0200    

Click here for diff

List of commits reverted:  
  
  2f094e7ac69  SQL Property Graph Queries (SQL/PGQ)  
  cd8844e7db6  Make some tests more stable by adding more explicit ordering  
  182cdf5aeaf  pg_dump: Add appropriate version check  
  c9babbc8816  Dump labels in reproducible order  
  040a56be4bc  Cleanup users and roles in graph_table_rls test  
  5282bf535e4  Fix some typos and make small stylistic improvements  
  720f0f89d69  Reject consecutive element patterns of same kind  
  288ae968726  Add a graph pattern variable only once  
  c5b3253b8ab  Property references are preferred over regular column references  
  a0dd0702e46  Fix cross variable references in graph pattern causing segfault  
  2ff289d0393  Check for stack overflow when rewriting graph queries  
  9082680c34e  Fix typos and grammar in graph table rewrite code  
  ac3bcc041c5  Fix collation of expressions in GRAPH_TABLE COLUMNS clause  
  9d2979dd685  pg_get_viewdef() and lateral references in COLUMNS of GRAPH_TABLE  
  891a57c7394  Do not define type for a property graph  
  dc9e7c9ed93  Handle nodes that may appear in GraphPattern expression trees  
  f6edd8ed708  Add ORDER BY to test query to stabilize test  
  1190f858eaf  doc: Small synopsis wording change for consistency  
  d0eac3cafb0  Make spelling consistent  
  6827de95ee0  Simplify code in objectaddress.c for some property graph objects  
  5778fb3eafd  Fix typo in error message  
  72498a86989  Handle element label and label property objects in object address functions  
  4cb2a9863d8  Fix LATERAL references in GRAPH_TABLE with multi-label pattern  
  9d8cdcbe0c8  Record dependencies on graph labels and properties  
  2a7e95b659d  Readable identity strings for property graph objects  
  7afa11feca6  Prevent dropping the last label from a property graph element  
  96418a6da9d  Fix handling of dropping a property not associated with the given label  
  efd7d8d7d49  Resolve unknown-type literals in GRAPH_TABLE COLUMNS  
  e0ff7fd9aa2  Make property graph object descriptions better translatable  
  0e4f0827f63  Fix properties orphaned by dropping a label  
  73dfe79fd60  Remove apparent support for SECURITY LABEL ON PROPERTY GRAPH  
  592de8bd21e  Fix pg_dump ACL minimization for PROPERTY GRAPH.  
  16a4b3ef8ee  Fix replace_property_refs() ignoring the root of expression tree  
  57f93af36f0  Resolve unknown-type literals in property expressions  
  2e6578292a9  Prohibit locking clauses on GRAPH_TABLE  
  2521f9e75e9  doc: Fix SQL quoting in example  
  0316593146d  Restore the ability to use | and -> as prefix operators.  
  780fa49746d  Fix missing space before WHERE in GRAPH_TABLE deparse  
  fa62d4f6ea7  Prohibit GRANT ... ON TABLE on a property graph  
  63c3bbb39f9  doc: Add PROPERTY GRAPH to the access privilege tables  
  0a51a06cdb0  More tab-completion for DROP PROPERTY GRAPH  
  f585671055d  Disallow aggregates, window functions, and SRFs in GRAPH_TABLE COLUMNS  
  9b917a93116  Report duplicate property and label names with a proper error  
  a82e33a83d7  Make generate_queries_for_path_pattern_recurse() interruptible  
  3c982c9bf1a  Add test for view referencing labels shared by vertex and edge tables  
  8646d1d5904  Fix inferred property graph keys with INCLUDE columns  
  0417bf52969  Fix pg_event_trigger_ddl_commands for GRANT ON PROPERTY GRAPH  
  a20d3e35f2c  doc: reformat GRAPH_TABLE examples  
  792094a5ce8  Coerce GRAPH_TABLE pattern WHERE clauses to boolean  
  
plus typedefs.list changes.  
  
Discussion: https://www.postgresql.org/message-id/CAAKRu_bEtjWYWhYxSo0o_t3DaZYRQd5PkC0abA0g9Mp4%2BovH0w%40mail.gmail.com  

M contrib/pg_overexplain/expected/pg_overexplain.out
M contrib/pg_overexplain/pg_overexplain.c
M contrib/pg_overexplain/sql/pg_overexplain.sql
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/ddl.sgml
M doc/src/sgml/features.sgml
M doc/src/sgml/func/func-info.sgml
M doc/src/sgml/information_schema.sgml
D doc/src/sgml/keywords/sql2023-16-nonreserved.txt
D doc/src/sgml/keywords/sql2023-16-reserved.txt
M doc/src/sgml/queries.sgml
M doc/src/sgml/ref/allfiles.sgml
M doc/src/sgml/ref/alter_extension.sgml
D doc/src/sgml/ref/alter_property_graph.sgml
M doc/src/sgml/ref/comment.sgml
D doc/src/sgml/ref/create_property_graph.sgml
D doc/src/sgml/ref/drop_property_graph.sgml
M doc/src/sgml/ref/grant.sgml
M doc/src/sgml/ref/psql-ref.sgml
M doc/src/sgml/ref/revoke.sgml
M doc/src/sgml/ref/select.sgml
M doc/src/sgml/reference.sgml
M src/backend/catalog/aclchk.c
M src/backend/catalog/dependency.c
M src/backend/catalog/heap.c
M src/backend/catalog/information_schema.sql
M src/backend/catalog/objectaddress.c
M src/backend/catalog/pg_class.c
M src/backend/catalog/sql_features.txt
M src/backend/commands/Makefile
M src/backend/commands/alter.c
M src/backend/commands/dropcmds.c
M src/backend/commands/event_trigger.c
M src/backend/commands/meson.build
D src/backend/commands/propgraphcmds.c
M src/backend/commands/seclabel.c
M src/backend/commands/tablecmds.c
M src/backend/executor/execMain.c
M src/backend/nodes/nodeFuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/nodes/print.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/parser/Makefile
M src/backend/parser/analyze.c
M src/backend/parser/gram.y
M src/backend/parser/meson.build
M src/backend/parser/parse_agg.c
M src/backend/parser/parse_clause.c
M src/backend/parser/parse_collate.c
M src/backend/parser/parse_expr.c
M src/backend/parser/parse_func.c
D src/backend/parser/parse_graphtable.c
M src/backend/parser/parse_relation.c
M src/backend/parser/parse_target.c
M src/backend/parser/scan.l
M src/backend/rewrite/Makefile
M src/backend/rewrite/meson.build
D src/backend/rewrite/rewriteGraphTable.c
M src/backend/rewrite/rewriteHandler.c
M src/backend/tcop/utility.c
M src/backend/utils/adt/acl.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/cache/lsyscache.c
M src/backend/utils/cache/plancache.c
M src/bin/pg_dump/common.c
M src/bin/pg_dump/dumputils.c
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/psql/command.c
M src/bin/psql/describe.c
M src/bin/psql/help.c
M src/bin/psql/tab-complete.in.c
M src/fe_utils/psqlscan.l
M src/include/catalog/Makefile
M src/include/catalog/catversion.h
M src/include/catalog/meson.build
M src/include/catalog/pg_class.h
M src/include/catalog/pg_proc.dat
D src/include/catalog/pg_propgraph_element.h
D src/include/catalog/pg_propgraph_element_label.h
D src/include/catalog/pg_propgraph_label.h
D src/include/catalog/pg_propgraph_label_property.h
D src/include/catalog/pg_propgraph_property.h
D src/include/commands/propgraphcmds.h
M src/include/nodes/parsenodes.h
M src/include/nodes/primnodes.h
M src/include/parser/analyze.h
M src/include/parser/kwlist.h
D src/include/parser/parse_graphtable.h
M src/include/parser/parse_node.h
M src/include/parser/parse_relation.h
D src/include/rewrite/rewriteGraphTable.h
M src/include/tcop/cmdtaglist.h
M src/include/utils/acl.h
M src/include/utils/lsyscache.h
M src/interfaces/ecpg/preproc/pgc.l
M src/interfaces/ecpg/test/ecpg_schedule
D src/interfaces/ecpg/test/expected/sql-sqlpgq.c
D src/interfaces/ecpg/test/expected/sql-sqlpgq.stderr
D src/interfaces/ecpg/test/expected/sql-sqlpgq.stdout
M src/interfaces/ecpg/test/sql/.gitignore
M src/interfaces/ecpg/test/sql/Makefile
M src/interfaces/ecpg/test/sql/meson.build
D src/interfaces/ecpg/test/sql/sqlpgq.pgc
M src/test/regress/expected/alter_generic.out
D src/test/regress/expected/create_property_graph.out
M src/test/regress/expected/event_trigger.out
D src/test/regress/expected/graph_table.out
D src/test/regress/expected/graph_table_rls.out
M src/test/regress/expected/object_address.out
M src/test/regress/expected/oidjoins.out
M src/test/regress/expected/privileges.out
M src/test/regress/parallel_schedule
M src/test/regress/sql/alter_generic.sql
D src/test/regress/sql/create_property_graph.sql
M src/test/regress/sql/event_trigger.sql
D src/test/regress/sql/graph_table.sql
D src/test/regress/sql/graph_table_rls.sql
M src/test/regress/sql/object_address.sql
M src/test/regress/sql/privileges.sql
M src/tools/pgindent/typedefs.list

Reset conflict slot's xmin when a subscription (re)starts retention.

commit   : 6168c65ddcac4494fb292418cc774897791e0667    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 7 Sep 2026 14:40:59 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 7 Sep 2026 14:40:59 +0530    

Click here for diff

Since the retain_dead_tuples feature uses a single cluster-wide  
replication slot across all subscriptions, adding a new subscription on a  
database with an older active transaction can require  
conflict_detection_slot.xmin to move backward to avoid missing dead tuples  
needed for update_deleted conflict detection.  
  
Previously, if a newly created subscription had an older active  
transaction than the slot's current xmin, the slot update occurred during  
worker apply, leading to an assertion failure.  
  
Fix this by having the launcher track the set of databases with active  
tuple-retaining subscriptions. When a database joins this set (either via  
a new subscription or when retention restarts), the launcher resets the  
slot's xmin to the cluster-wide safe decoding horizon before starting any  
workers. Because this horizon accounts for all active transactions across  
the entire cluster, it serves as a safe seed without requiring retroactive  
backward movement by individual apply workers.  
  
In passing, update the retain_dead_tuples documentation to clarify two  
operational boundary cases:  
(a) Conflict data continues to accumulate even when a subscription is  
disabled or its apply worker is stopped.  
(b) track_commit_timestamp must be enabled for conflict detection to  
function properly.  
  
Reported-by: Nisha Moond <nisha.moond412@gmail.com>  
Author: Zhijie Hou <houzj.fnst@fujitsu.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/TY4PR01MB177182F547A62FC2666EC04EC94B72@TY4PR01MB17718.jpnprd01.prod.outlook.com  
Backpatch-through: 19, where it was introduced  

M doc/src/sgml/ref/create_subscription.sgml
M src/backend/replication/logical/launcher.c
M src/test/subscription/t/035_conflicts.pl

Fix duplicate qual clauses in parameterized paths

commit   : f836b688f8dc627ce97760dec5569aa7c064ffe9    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 7 Sep 2026 11:50:56 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 7 Sep 2026 11:50:56 +0900    

Click here for diff

When outer-join identity 3 permits a join to commute with lower outer  
joins, we generate multiple clone versions of its join clause, of  
which only one should be applied in any given plan.  When building a  
join relation's restriction list, subbuild_joinrel_restrictlist  
selects the appropriate clone by checking required_relids and  
incompatible_relids, but no such selection was made for movable join  
clauses pushed down into a parameterized path.  As a result, a  
parameterized scan or join could enforce more than one clone of the  
same condition, shown by EXPLAIN as a duplicate qual.  This wastes  
effort evaluating the same condition repeatedly.  What is worse, it  
applies the clause's selectivity multiple times, underestimating the  
result's row count.  
  
To fix, in get_baserel_parampathinfo and get_joinrel_parampathinfo,  
skip a clone clause if any outer join listed in its  
incompatible_relids has already been computed below the point of  
evaluation.  
  
Back-patch to v19, but no further.  While this bug goes back to v16,  
applying the fix in released branches risks destabilizing plans that  
users are currently happy with, and there have been no field  
complaints.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4-g5TFF5k=jfe3JVWqtv_cCTOMmQRUp0_E8fApgqcqBng@mail.gmail.com  
Backpatch-through: 19  

M src/backend/optimizer/util/relnode.c
M src/include/nodes/pathnodes.h
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Rename varatt_external to varatt_external_oid

commit   : c5806f2165b57434290dd345ba301e4179634c23    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 7 Sep 2026 08:45:23 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 7 Sep 2026 08:45:23 +0900    

Click here for diff

This impacts a few more definitions, related to this structure, as of:  
- VARTAG_ONDISK -> VARTAG_ONDISK_OID  
- TOAST_POINTER_SIZE -> TOAST_OID_POINTER_SIZE  
- TOAST_MAX_CHUNK_SIZE -> TOAST_OID_MAX_CHUNK_SIZE  
- Macros in varatt.h for varatt_external_oid.  
  
This rename is part of a conversation to add support for more types of  
external TOAST pointers, not only OID.  One of them is to extend the  
pointers to use an OID8 variant.  The control file field for the max  
chunk size is left out, for now.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACVnO6jjs5aRx3dSOBy9LV7=iakPBR1eOvoeB8rL8Q47zg@mail.gmail.com  
Discussion: https://postgr.es/m/apoD1Ulet2PtDrRV@paquier.xyz  

M contrib/amcheck/verify_heapam.c
M doc/src/sgml/storage.sgml
M src/backend/access/common/detoast.c
M src/backend/access/common/toast_compression.c
M src/backend/access/common/toast_internals.c
M src/backend/access/heap/heaptoast.c
M src/backend/access/table/toast_helper.c
M src/backend/access/transam/xlog.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/utils/adt/varlena.c
M src/bin/pg_resetwal/pg_resetwal.c
M src/include/access/detoast.h
M src/include/access/heaptoast.h
M src/include/varatt.h
M src/tools/pgindent/typedefs.list

Fix incorrect error message in xlogreader.c

commit   : 798bdcae89debabc59fa8afc6d690fec584db32f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 5 Sep 2026 09:12:40 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 5 Sep 2026 09:12:40 +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

Convert FastPathStrongRelationLocks to atomics.

commit   : 74c77052bc20017076100f0649ca0f44b1b98c29    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 4 Sep 2026 13:02:22 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 4 Sep 2026 13:02:22 -0500    

Click here for diff

Currently, the lock counts are unsigned integers protected by a  
spinlock.  By converting them to atomic variables, we can remove  
the spinlock and the FastPathStrongRelationLockData wrapper struct.  
  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

M src/backend/storage/lmgr/lock.c
M src/tools/pgindent/typedefs.list

Convert some ParallelBlockTableScanDescData fields to atomics.

commit   : 7344937cbe640cd8c5304cefe7d6b726187ad4ab    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 4 Sep 2026 10:56:19 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 4 Sep 2026 10:56:19 -0500    

Click here for diff

Currently, phs_startblock and phs_numblock are of type BlockNumber  
and are protected by a spinlock.  By converting them to atomic  
variables, we can remove the spinlock and some retry code.  
  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

M src/backend/access/heap/heapam_handler.c
M src/backend/access/table/tableam.c
M src/include/access/relscan.h

doc: Pluralize MXID when referring to Multixact IDs

commit   : 168fa9dd424e3beabeb0b4c079a032b7b6f5297b    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 4 Sep 2026 16:49:59 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 4 Sep 2026 16:49:59 +0200    

Click here for diff

Reported-by: Yugo Nagata <nagata@sraoss.co.jp>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Discussion: https://postgr.es/m/TY4PR01MB17374866B8EBD3F507AFB1C7C94D12@TY4PR01MB17374.jpnprd01.prod.outlook.com  

M doc/src/sgml/maintenance.sgml

Convert FixedParallelState->last_xlog_end to an atomic variable.

commit   : 67b593861de13226d5bb23271aeaa16ce67024de    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 4 Sep 2026 09:48:31 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 4 Sep 2026 09:48:31 -0500    

Click here for diff

Currently, this variable is an XLogRecPtr protected by a spinlock.  
By converting it to an atomic variable, we can remove the spinlock.  
  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

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

Use pg_parse_lsn() for LSNs in backup manifests

commit   : 2227afac0171550b0e213173cadcefd165434b23    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 4 Sep 2026 23:04:59 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 4 Sep 2026 23:04:59 +0900    

Click here for diff

A user-supplied or modified backup manifest could contain an invalid WAL  
range LSN that was nevertheless accepted by the manifest parser. For  
example, an LSN component wider than 32 bits could be silently truncated,  
and trailing characters after an otherwise valid LSN could be ignored.  
  
This could cause pg_verifybackup, pg_combinebackup, and incremental  
backup validation to check WAL availability against a different location  
from the one specified in the manifest. PostgreSQL-generated manifests  
should not contain such values, but tools consuming manifests should  
reject invalid input rather than reinterpret it.  
  
Fix this by using the common pg_parse_lsn() helper to parse LSNs in  
backup manifests. It requires the same syntax as the pg_lsn input  
function.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Yuefei Shi <shiyuefei1004@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWXieRHb-ooV2XfjHAtBsS7+P5La_-o8-Cqi15CNDhh9hQ@mail.gmail.com  

M src/bin/pg_verifybackup/t/005_bad_manifest.pl
M src/common/parse_manifest.c

postgres_fdw: Fix issues with statistics import.

commit   : 6a857156827b6a938bd02b9bf7281e7b71dfd088    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 4 Sep 2026 18:40:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 4 Sep 2026 18:40:00 +0900    

Click here for diff

When analyzing a foreign table pointing to a partitioned or inherited  
table on the remote server, this method just imported relpages and  
reltuples for the parent table from the remote pg_class, causing a  
discrepancy or an error in results compared to the sampling method.  
  
* In the partitioning case, while the sampling method sets relpages=0,  
  this method set relpages=-1.  (For reltuples, the results of both  
  methods match.)  
* In the inheritance case, while the sampling method sets  
  reltuples=(# of rows in the parent and child tables), this method set  
  reltuples=(# of rows in the parent table).  (For relpages, the results  
  of both methods match.)  
  
As relpages and reltuples are used for costing foreign paths, these  
would lead to incorrect plans or plan changes depending on the method.  
To fix, do the following:  
  
* For the partitioning case, modify postgres_fdw to set relpages=0 to  
  match the sampling method.  
* For the inheritance case, we could also modify it to set the correct  
  reltuples value by fetching reltuples for the child tables as well,  
  but 1) the change isn't small, and 2) table inheritance hasn't been  
  used that much these days, so fix by disabling this method.  
  
While at it, adjust comments and docs slightly.  
  
Oversight in commit 28972b6fc.  
  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/CAPmGK173b2Xvyoeq%3DY7L09H%2BajgMgxC2fYe%3D7CCunZz8tGTfFA%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/deparse.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/postgres-fdw.sgml

Add pgstat test for reset of dead/live counters with table truncation

commit   : ac00b0f8bdc59152e0d5b5f97c979595e9a5e2ad    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 4 Sep 2026 16:55:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 4 Sep 2026 16:55:39 +0900    

Click here for diff

A patch has been proposed to refactor the table-level statistics to  
treat the non-transactional and transactional parts as two separate  
entities, in the scope of a larger piece of work to introduce  
transactional flushes.  
  
This commit adds a test for a pattern that has proved to be problematic  
while splitting the relation stats data, and where we had no coverage  
yet: an entry marked as truncdropped resets the live/dead counters in  
the flush callback, leaving any other data intact.  The code path  
resetting the live/dead counters was covered, but nothing in the  
regression tests checked the stats views for it.  
  
Extracted from a larger patch by the same author.  
  
Author: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/aoU32VTkUtpdUewB@paquier.xyz  

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

pg_upgrade: Skip tests for live server checks on Windows

commit   : ac1ccbea98f166548890f14c9ca9d4ab055ca291    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 4 Sep 2026 15:51:56 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 4 Sep 2026 15:51:56 +0900    

Click here for diff

The tests added by 88aa6ca138a1 could fail on Windows, due to the fact  
that pg_ctl is not able to compare the PID stored in postmaster.pid with  
the postmaster that has been spawned.  The postmaster may not be seen as  
running, and could fail the live check.  
  
Note that pg_ctl falls back on checking the start time recorded in  
postmaster.pid, with a lag of 2 seconds.  So, outside the possibility of  
fixing pg_ctl so as the PID file checks become more reliable, an  
alternative solution would be to use the same trick as the pg_ctl test  
001_start_stop.pl, with a hardcoded sleep of *3* seconds, at least.  I  
cannot get excited about spreading this pattern, though, so skip it is  
as we do not lose any coverage.  
  
Per report from buildfarm members fairywren.  
  
Discussion: https://postgr.es/m/apphYnTYS1WtLkKU@paquier.xyz  

M src/bin/pg_upgrade/t/002_pg_upgrade.pl

Disallow joins whose lateral references need an unformable outer join

commit   : 55fa1b06780ab16a2d48532a3b68451f6b6cc3d8    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 4 Sep 2026 10:33:39 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 4 Sep 2026 10:33:39 +0900    

Click here for diff

If a LATERAL subquery references a PlaceHolderVar that must be  
evaluated at an outer join, the subquery's lateral_relids include that  
outer join's relid, since the lateral parameter is the outer join's  
output.  join_is_legal() verified that the rels named by a proposed  
join's minimum parameterization could still be joined to from outside,  
but it did not consider such outer-join relids.  As a result, when  
identity 3 permitted a commuted join order, we could approve a join  
that includes part of that outer join's required input, even though  
the outer join could then be completed only above the proposed join,  
leaving the lateral parameter forever unsatisfiable.  
  
In assert-enabled builds this tripped the backstop Assert in  
try_nestloop_path().  In production builds the bogus join generated  
only paths whose parameterization can never be satisfied, so they  
could never appear in a complete plan.  This not only wasted planning  
effort, but also could mislead the clauseless-join heuristics into  
thinking that legality of this join means that some other join rel  
need not be formed, and that could lead to failure to find any plan at  
all.  
  
Such joins used to be rejected by the have_dangerous_phv() check in  
join_is_legal(), which refused any join where a PlaceHolderVar's eval  
set overlapped the other side of the join without being contained in  
it.  Commit a16ef313f removed that restriction, exposing this  
oversight.  
  
To fix, teach join_is_legal() to reject a proposed join if its minimum  
parameterization includes an outer-join relid whose outer join cannot  
be formed strictly outside the join, that is, when any rel needed to  
form that outer join must become part of the proposed join's own join  
tree.  
  
Back-patch to v18, where commit a16ef313f removed the  
have_dangerous_phv() restriction.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49ZveAYx9T5b0=gxn0pnvqq=MbN-Z4KLbLAE+kH06mWVA@mail.gmail.com  
Backpatch-through: 18  

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

Minimize footprint of TOAST_MAX_CHUNK_SIZE in heap and amcheck code

commit   : 2b3d11aaed891958f24aed05bf454524d603b6ea    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 4 Sep 2026 07:50:46 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 4 Sep 2026 07:50:46 +0900    

Click here for diff

This refactoring eases a little bit a follow-up change to add support  
for 8-byte TOAST value IDs, as the maximum chunk size allowed for a  
single chunk of TOASTed data depends on the size of varatt_external, its  
value ID being part of it.  
  
It is worth noting that TOAST_MAX_CHUNK_SIZE resolves as a uintptr_t, so  
the previous calculations were in 64-bit unsigned arithmetic.  These are  
now done in int32, which still works the same way due to an external  
TOAST value being bounded to 1GB.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACVnO6jjs5aRx3dSOBy9LV7=iakPBR1eOvoeB8rL8Q47zg@mail.gmail.com  

M contrib/amcheck/verify_heapam.c
M src/backend/access/heap/heaptoast.c

Add non-MVCC index scan test module.

commit   : f7a563ccd1233f99b3b202c6c208ee37694c8cef    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 3 Sep 2026 17:37:03 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 3 Sep 2026 17:37:03 -0400    

Click here for diff

Add test_indexscan, a new test module that provides an SQL-callable  
function that performs a full index scan using whatever snapshot type  
the caller asks for.  Also add a set of tests that verify and document a  
variety of behaviors associated with some specific snapshot type.  
  
Preparation for an upcoming commit that will move index scan heap  
fetches behind a new slot-based table AM interface.  Aside from testing  
non-MVCC snapshot types, these new tests can catch bugs where an index  
scan incorrectly maintains xs_heap_continue during HOT chain traversal.  
Such bugs are unlikely to affect MVCC scans, which makes it hard to  
write tests that detect them without relying on a custom test module.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/CAH2-Wzn%2BC%3DmAMv9aW3Skfh80JPpHKT3yM%3DDYwkrrhYyG2f%2B_vg%40mail.gmail.com  

M src/test/modules/index/Makefile
A src/test/modules/index/expected/hot_chain.out
M src/test/modules/index/meson.build
A src/test/modules/index/sql/hot_chain.sql
A src/test/modules/index/test_indexscan–1.0.sql
A src/test/modules/index/test_indexscan.c
A src/test/modules/index/test_indexscan.control

Auto-vectorize the varbit bitwise operators.

commit   : 9a40e39b1e8780ba75e014cb87860249c405c37e    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 3 Sep 2026 16:10:37 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 3 Sep 2026 16:10:37 -0500    

Click here for diff

Compile varbit.c with -ftree-vectorize where available, and adjust  
the loops in bit_and(), bit_or(), bitxor(), and bitnot() so that  
they are amenable to being auto-vectorized.  (Mainly, that involves  
reading the byte count into a local variable before the loop.  As  
written, the bound is recomputed from the varlena header on every  
iteration, because the compiler must assume that the loop might  
modify the header.)  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/aphxrw6NkYkLMtZN%40nathan  

M src/backend/utils/adt/Makefile
M src/backend/utils/adt/meson.build
M src/backend/utils/adt/varbit.c

Add index scan pgstat test coverage.

commit   : 83032dc42cab67dfdd33152d08434785977f069f    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 3 Sep 2026 16:27:09 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 3 Sep 2026 16:27:09 -0400    

Click here for diff

Add tests that verify the exact values of the idx_tup_read and  
idx_tup_fetch counters in pg_stat_all_indexes.  There was no existing  
coverage of pg_stat_all_indexes, beyond some counter reset tests;  
idx_tup_read and idx_tup_fetch had no tests at all.  
  
This is preparation for an upcoming commit that will move index scan  
heap fetches behind a new slot-based table AM interface, relocating the  
code that maintains these counters.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/CAH2-Wz%3DV0V5WGuo85D-OF%2BTM_CxU3q%3DMMkY-ebY0K8xc-9Xykw%40mail.gmail.com  

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

Convert PROC_HDR->startupBufferPinWaitBufId to a Buffer.

commit   : 8ca9cfb77838b3a17b7c9b5ef26cb2a26b5e1bb2    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 3 Sep 2026 15:16:16 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 3 Sep 2026 15:16:16 -0500    

Click here for diff

Presently, this field stores the buffer's index, i.e., the Buffer  
minus one, and it uses -1 to mean "not waiting."  The callers  
subtract one before storing the value and add it back after reading  
it.  This commit changes the field to store the Buffer itself and  
to use InvalidBuffer (0) as the sentinel, which gets rid of that  
arithmetic.  
  
This is preparatory work for a follow-up commit that will convert  
the variable to an unsigned atomic, for which a negative sentinel  
makes little sense.  
  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan  

M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h

Move visibility map memory ordering comments.

commit   : 903d9d12cc0adcd9a7f92c7b35333e9e40756fbf    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 3 Sep 2026 15:36:25 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 3 Sep 2026 15:36:25 -0400    

Click here for diff

nodeIndexonlyscan.c has long carried a detailed explanation of why it is  
safe for index-only scans to test a visibility map bit without locking  
the visibility map buffer, despite the possibility of reading a stale  
value.  Move that explanation into visibilitymap.c.  
  
This is preparation for an upcoming commit that will move VM checks  
needed by index-only scans out of the executor and into heapam.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Suggested-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/t6mtqbv2mbfhjni4bvwdgoecppjmxvbyfwl6utovzv76xc2672%40k3o5ryevaeqv  

M src/backend/access/heap/visibilitymap.c
M src/backend/executor/nodeIndexonlyscan.c

Fix lack of message pluralization

commit   : 534db08f972852b77ea5e96e77d5fe45f3d8df93    
  
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

Use WAL insert position for conflict detection.

commit   : 5f3a49abf7ff7bb4a9eba7101eb8e8021960074f    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 3 Sep 2026 14:12:53 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 3 Sep 2026 14:12:53 +0530    

Click here for diff

The retain_dead_tuples feature waits for concurrent transactions to be  
applied before advancing conflict_detection_slot.xmin. It gets the WAL  
write position from the publisher and waits until the apply remote  
position passes it. This ensures that dead tuples, commit timestamps, and  
origins needed for conflict detection (update_deleted,  
update_origin_differs, and delete_origin_differs) are retained while  
those transactions are applied.  
  
However, with asynchronous commit enabled on the publisher, a committed  
transaction may not have updated the WAL write position yet. As a result,  
the reported WAL position can lag behind the latest committed transaction.  
This can cause conflict_detection_slot.xmin to advance prematurely,  
allowing dead tuples needed for conflict detection to be removed before  
subsequent asynchronously committed transactions are applied.  
  
Report the end of the last inserted WAL record instead. A transaction  
inserts its commit record before it is marked committed, so the insert  
position cannot be behind a transaction that has already committed.  
Transactions that have entered the commit phase but have not yet inserted  
their commit record are still accounted for by the in-commit transaction  
ID reported in the same message.  
  
In addition to above, add missing trailing period to update_deleted  
conflict detail messages which are added for the same feature.  
  
Reported-by: Nisha Moond <nisha.moond412@gmail.com>  
Author: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/TY4PR01MB177182F547A62FC2666EC04EC94B72@TY4PR01MB17718.jpnprd01.prod.outlook.com  
Backpatch-through: 19, where it was introduced  

M src/backend/replication/logical/conflict.c
M src/backend/replication/logical/worker.c
M src/backend/replication/walsender.c

pg_upgrade: Test --check with a running source server

commit   : 88aa6ca138a1eaa63618b2e6ef85ca6c7422dfed    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 3 Sep 2026 17:28:53 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 3 Sep 2026 17:28:53 +0900    

Click here for diff

4fff78f009 has added coverage for pg_upgrade --check, but only after  
stopping the source server.  This adds coverage for the case where a  
source server is still running, checking for port patterns and a success  
case where the old server still runs.  
  
The chdir() required for VPATH builds needs to be moved slightly  
earlier, to adapt to the generation of the logs.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/apU4/hmRv/4gv20W@bdtpg  

M src/bin/pg_upgrade/t/002_pg_upgrade.pl

Revert "Remove fake FunctionCallInfos from the stats .."

commit   : 6fe9b62914bcb55cbf02d8d741a42f810d239725    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 3 Sep 2026 17:24:52 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 3 Sep 2026 17:24:52 +0900    

Click here for diff

This reverts commit cc9a8eb112fa, after more discussion with Etsuro  
Fujita.  We are still not sure about the interface that should be used  
for the portion related to the statistics import, and what should be  
exposed for FDW code that may want to rely on these two functions:  
- import_attribute_statistics()  
- import_relation_statistics()  
  
Discussion: https://postgr.es/m/CAPmGK15HUuNvEZk4b+K_x57+sg31B9LDwB7DBgVNaCpLnafhPA@mail.gmail.com  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/statistics/attribute_stats.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/statistics/relation_stats.c
M src/backend/statistics/stat_utils.c
M src/include/statistics/stat_utils.h
M src/include/statistics/statistics.h
M src/tools/pgindent/typedefs.list

Avoid backend hang during temp table cleanup in deferrable transactions

commit   : 0b776de09ed3e237181def135577321bdd31b548    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 3 Sep 2026 12:12:42 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 3 Sep 2026 12:12:42 +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
M src/test/modules/test_misc/meson.build
A src/test/modules/test_misc/t/015_temp_schema_exit_deferrable.pl

Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

commit   : 7d0a31fa22c8e830280e91e1a181d8be04e8632a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 3 Sep 2026 12:09:49 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 3 Sep 2026 12:09:49 +0900    

Click here for diff

The buildfarm member akepa reported a failure in the  
031_recovery_conflict.pl test.  
  
The test checked pg_stat_database_conflicts immediately after detecting  
a recovery conflict in the standby log. However, the conflict counter is  
flushed by the canceled backend during backend exit, so WAL replay  
completion and the log message did not guarantee that the updated  
statistics are visible yet. So, previously, the test could see a conflict  
counter of 0 even though the conflict had already occurred, triggering  
the test failure.  
  
Fix this by polling for the expected conflict counter instead of reading  
it only once, handling the asynchronous pgstats update.  
  
Per buildfarm member akepa.  
  
Backpatch to v17, where this test is enabled and has the same race.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwHmiLNRfvJDAR=PmxQgf7DbzPSO1M-1RoqO8oy=t2G5KA@mail.gmail.com  
Backpatch-through: 17  

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

Coerce GRAPH_TABLE pattern WHERE clauses to boolean

commit   : 792094a5ce89f9953d913c835e4530e56b63026a    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 2 Sep 2026 20:43:32 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 2 Sep 2026 20:43:32 +0200    

Click here for diff

transformGraphElementPattern() and transformGraphPattern() ran their  
WHERE clauses through transformExpr() without ever applying  
coerce_to_boolean(), so a WHERE clause of any type was accepted and  
its bare datum was used as the qual, which resulted in wrong results  
without a diagnostic.  Route both sites through  
transformWhereClause(), like every other WHERE clause, and add  
regression tests for the element-level and pattern-level cases.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAON2xHNZUS8ZwzVEJFeRirsC_-7EJvdbwABSzdGaJ_DF9DvHoQ%40mail.gmail.com  

M src/backend/parser/parse_graphtable.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql

Stabilize xid_wraparound/t/002_limits.pl test.

commit   : e073b64d33215d4bfded1366549b96580a402c06    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 2 Sep 2026 10:53:35 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 2 Sep 2026 10:53:35 -0400    

Click here for diff

Not many buildfarm members run this test, since it's gated behind  
PG_TEST_EXTRA=xid_wraparound, but of those that do, the slower ones  
not infrequently fail.  The reason seems to be that the test expects  
an INSERT command to either succeed or fail, but there's a window  
where it can succeed while issuing a warning about impending  
wraparound.  poll_query_until treats nonempty stderr as a failure,  
so it loops an extra time until the INSERT succeeds with no warning.  
There seems no reason to treat this behavior as wrong, so adjust  
the test to accept it.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Diagnosed-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/7a68bee2-91bd-481d-be44-160e6beebc83@gmail.com  
Backpatch-through: 17  

M src/test/modules/xid_wraparound/t/002_limits.pl

initdb: Pad rewritten GUC lines with spaces instead of tabs.

commit   : d870be195b3b7ee224a58ff562c1f1c252a96814    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 2 Sep 2026 09:22:40 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 2 Sep 2026 09:22:40 -0500    

Click here for diff

Commit f63ae72bbc converted postgresql.conf.sample to spaces so  
that it lines up at any tab width, but replace_guc_value() still  
pads with tabs when it re-aligns the trailing comment of a  
rewritten setting.  Fix that.  
  
Oversight in commit f63ae72bbc.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/apRezMywHRuR5h-6%40nathan  
Backpatch-through: 19  

M src/bin/initdb/initdb.c

postgres_fdw: Fix "may be used uninitialized" warning in foreign_join_ok()

commit   : 0fb258d1f2ca65b7299ba7c47045634df05efbff    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 2 Sep 2026 15:46:47 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 2 Sep 2026 15:46:47 +0300    

Click here for diff

Commit 0ee83dd4a99 detected the mixed foreign x function-RTE cases in one  
if/else chain that only set a pair of bool flags, then acted on those flags in  
a second chain.  fpinfo_o and fpinfo_i are each assigned in one chain and read  
in the other, so proving them initialized requires correlating the flags with  
the assignments.  gcc 13 with -Og does not manage that and reports fpinfo_i as  
possibly uninitialized; clang's -Wconditional-uninitialized likewise reports  
both variables.  
  
The flags served no purpose beyond deferring the work, so merge the two chains  
and read both fdw_private pointers up front, unconditionally.  A function rel  
never has an fdw_private of its own, so the pointer is simply NULL until the  
stub replaces it, and each branch now assigns and uses the two variables in one  
place.  
  
Reported-by: Karina Litskevich <litskevichkarina@gmail.com>  
Reported-by: Marina Polyakova <m.polyakova@postgrespro.ru>  
Reviewed-by: Marina Polyakova <m.polyakova@postgrespro.ru>  
Discussion: https://postgr.es/m/CACiT8iamoL-%3D792e6JK2uCVvwDhfCg7DXHhvqN0P33jhGg2-8A%40mail.gmail.com  

M contrib/postgres_fdw/postgres_fdw.c

Add previous commit to .git-blame-ignore-revs

commit   : 7d3247ccd15be860b098679e39eff7b6c8040355    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 2 Sep 2026 09:32:50 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 2 Sep 2026 09:32:50 +0200    

Click here for diff

M .git-blame-ignore-revs

pgindent fix for a63df2664225d06d5be

commit   : 978772cf5dd642b093382e9ff4b3a353e8a5d1a2    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 2 Sep 2026 09:27:56 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 2 Sep 2026 09:27:56 +0200    

Click here for diff

Oversight in commit a63df2664225d06d5be per buildfarm member koel.  

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

Add more test coverage for pg_clear_attribute_stats()

commit   : 66f85615d5d650c47b6e8ea75e32a6817cb23dac    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 16:22:32 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 16:22:32 +0900    

Click here for diff

pg_clear_attribute_stats() was called exactly once in the whole test  
suite, only for a correct cleanup.  None of its failure scenarios were  
covered, in terms of:  
- NULL input values  
- Incorrect object names (schema, attribute, relation)  
- Incorrect relkinds  
- Inherited pg_statistic entry cleanup  
  
All these cases are now covered.  This would have caught the failure  
fixed by 11ed011ae22, as one example.  
  
Author: Zhong ShiHao <zhong950419@gmail.com>  
Discussion: https://postgr.es/m/CAGRkXqQEFzVh_bQSoLGDqaRTq7Xta6OUoda8PDrWDPWcAuwk=w@mail.gmail.com  

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

Fix qual pushdown past grouping through simple CASE

commit   : 264ddc9a678c41fca3435f26d7c581fd2b034cf8    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 2 Sep 2026 15:32:54 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 2 Sep 2026 15:32:54 +0900    

Click here for diff

Commit 44fb59fc6 taught the grouping-conflict walker to treat the arg  
of a simple CASE as a direct operand of each WHEN comparison, but it  
only checked the collation, on the assumption that the WHEN operator  
is always the type-default "=" and thus matches the grouping eqop.  
That assumption fails once the arg is relabeled to another type: the  
WHEN then compares under that type's "=", which need not agree with  
the grouping equality.  For instance, with a DISTINCT over a citext  
column, a qual such as "CASE t::text WHEN 'A' THEN ..." was pushed  
below the Unique, although the equivalent "t::text = 'A'" is correctly  
kept above it.  
  
Instead of special-casing the arg, have the walker bind a Var arg  
while walking the WHEN conditions and resolve each CaseTestExpr to it,  
so that the arg is checked exactly as each WHEN uses it: with the  
opfamily and collation checks of a direct operand when the WHEN is a  
comparison, and as a non-operand reference otherwise.  A non-Var arg  
is walked once as a non-operand, as before.  The CaseTestExpr in an  
ArrayCoerceExpr's elemexpr and a JsonConstructorExpr's coercion stand  
for something else and are left alone.  
  
Reported-by: Tender Wang <tndrwang@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/CAHewXNkvGTOgijRLjmudpg=wz0d-J8ChY2o7ksh3Be+Q_Bxwog@mail.gmail.com  
Backpatch-through: 18  

M src/backend/optimizer/util/clauses.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/expected/subselect.out
M src/test/regress/sql/collate.icu.utf8.sql
M src/test/regress/sql/subselect.sql

Fix checkpointer restartpoint assertion failure

commit   : c2c696c1a4827cde5fdaf8c8f03f9991d43ebfad    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 2 Sep 2026 14:32:02 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 2 Sep 2026 14:32:02 +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
M src/backend/access/transam/xlogrecovery.c
M src/include/access/xlogrecovery.h

Apply some query jumbling to WAIT FOR LSN

commit   : 282111b45c86b9e61809dbf3bd4a74ec0f6a4807    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 14:14:19 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 14:14:19 +0900    

Click here for diff

The query is now stored as normalized in pg_stat_statements, with its  
LSN position ignored in the jumbling, resulting in:  
WAIT FOR LSN $1;  
  
The option values in the WITH clause are left untouched.  
  
Reported-by: Peter Eisentraut <peter@eisentraut.org>  
Author: Sirisha Chamarthi <sirichamarthi22@gmail.com>  
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>  
Reviewed-by: Rithvika Devisetti <devisettirithvika@gmail.com>  
Discussion: https://postgr.es/m/1f04f78c-2cfa-47a0-997f-f02572cd10eb@eisentraut.org  
Backpatch-through: 19  

M contrib/pg_stat_statements/expected/utility.out
M contrib/pg_stat_statements/sql/utility.sql
M src/backend/parser/gram.y
M src/include/nodes/parsenodes.h

Fix OID-counter-sensitive row ordering in foreign_key test

commit   : 262f2eea958d21fdbe90a3e92ccc3e5c3f0d8059    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 2 Sep 2026 14:03:50 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 2 Sep 2026 14:03:50 +0900    

Click here for diff

Several queries in the foreign_key test sort pg_constraint rows with  
"ORDER BY oid::regclass::text".  These OIDs are constraint OIDs, not  
relation OIDs, so the regclass cast renders them as numeric strings,  
and text comparison of numeric strings depends on digit count.  If the  
OID counter crosses a power of ten while the test runs, the output  
order flips, causing spurious test failures.  This cannot happen in a  
fresh cluster, but installcheck against a long-lived cluster can hit  
it.  
  
To fix, sort by constraint name, which is unique within each of these  
queries, and use COLLATE "C" so that the order does not depend on the  
database's default collation either.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: jian he <jian.universality@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49KaJFGs4rfBWk+YmHPTXZ+pJTMJ12iaz7ruZdSK+sC5w@mail.gmail.com  
Backpatch-through: 18  

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

Remove quals made redundant by reducing outer joins to antijoins

commit   : ad4b80b6f49bcac519175fcb632aa94cdb7f6948    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 2 Sep 2026 13:36:29 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 2 Sep 2026 13:36:29 +0900    

Click here for diff

When reduce_outer_joins reduces an outer join to an antijoin, any IS  
NULL qual on a Var from the antijoin's nullable side is necessarily  
true.  Previously, such quals were discarded later in  
distribute_qual_to_rels, mainly to avoid bogus selectivity estimates.  
But that discard was incomplete: the qual remained in the jointree,  
while its Vars were not counted in attr_needed.  Since commit  
2ebf25e7d, join removal edits the jointree and expects it to contain  
no other references to a removed rel, so it could remove a rel that  
such a discarded qual still references, and then trip an assertion on  
the qual's stale Var.  
  
To fix, move this processing to an earlier phase: such quals are now  
removed from the jointree by reduce_outer_joins itself.  This way  
later phases see a consistent query tree, and  
check_redundant_nullability_qual is no longer needed, so remove it.  
  
Back-patch to v16, as with commit 2ebf25e7d.  
  
Reported-by: Tender Wang <tndrwang@gmail.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAHewXNk8b0TsSy4dL=CO7FXL2W3WBm0BcdP-zwNJePa-Qj4HzA@mail.gmail.com  
Backpatch-through: 16  

M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/util/clauses.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Remove fake FunctionCallInfos from the stats restore and import code

commit   : cc9a8eb112fa9cf5eb868306955198adb98e497e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 13:17:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 13:17:39 +0900    

Click here for diff

The statistics import and restore paths built fake FunctionCallInfos  
with LOCAL_FCINFO() and InitFunctionCallInfoData(), never calling  
anything through them.  The only data relevantly used was the values  
carried around as NullableDatum arrays, read back with PG_GETARG_*()  
macros.  
  
import_relation_statistics() and import_attribute_statistics() were  
passing a set of NullablePointer pointers, leading to more round-trip  
manipulations with the fake FunctionCallInfos.  These are reworked so as  
the values pushed to pg_class (for relation stats) and pg_statistic (for  
attribute stats) are passed around in dedicated structures with all the  
values assigned based on positional indexes (import code cares about  
less values than the restore code), simplifying their signatures and  
reducing the number of code lines required to pass the data around.  
  
The stats_check_*() functions now take the values and the attribute  
names rather than a StatsArgInfo with positional indexes, as this code  
is shared between the stats restore and import.  This removes the  
dependency between the StatsArgInfo bits and the import code.  
StatsArgInfo is used only for the restore code, for argument mapping.  
  
No behavioral change should be introduced in this commit; this is  
(should be) pure refactoring.  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Author: Corey Huinker <corey.huinker@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CADkLM=eo7MtuCE=YjovW+=ASw1=q39qQ3qarrsw+EKfU901ztA@mail.gmail.com  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/statistics/attribute_stats.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/statistics/relation_stats.c
M src/backend/statistics/stat_utils.c
M src/include/statistics/stat_utils.h
M src/include/statistics/statistics.h
M src/tools/pgindent/typedefs.list

Speed up pg_waldump TAP test

commit   : a9eebaf3735b8663ec8d638c9d81c54730ddd9de    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 09:19:30 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 2 Sep 2026 09:19:30 +0900    

Click here for diff

Several invocations decoded and printed the full WAL range even though  
the test only needs to confirm that a command form works or that  
decoding reaches a specific error. Limit those checks to one record,  
and start the fall-off-the-end checks near the end of the generated WAL.  
  
This change reduces the IPC overhead overall, particularly on Windows,  
without reducing coverage.  
  
I am usually hesitant to backpatch such changes as this is only an  
improvement, but the gains are too good in terms of IO and runtime, for  
both the CI and the buildfarm.  Based on the numbers provided, the CI  
takes 30% less time to run the test with this change on Windows (worst  
case shown on the lists).  These tests have been introduced in  
96063e28366b.  
  
Author: Sehrope Sarkuni <sehrope@jackdb.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://postgr.es/m/CAH7T-araSEdsNpxiKaMOW8kr_ZHhekCLHx5yzm2ksq4FdgULbA@mail.gmail.com  
Backpatch-through: 17  

M src/bin/pg_waldump/t/001_basic.pl

Fix nonstandard SQL command doc id= values introduced in the v19 cycle.

commit   : cb2c696b1dd1f6d2953d9756622ca799502bae46    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Tue, 1 Sep 2026 17:03:27 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Tue, 1 Sep 2026 17:03:27 -0700    

Click here for diff

While some <refentry> instances of supported PostgreSQL versions use the  
sql-alter-table style, sql-altertable is the dominant style.  Change  
these before they're baked into the doc URLs of a supported version.  
  
Backpatch-through: 19  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/high-availability.sgml
M doc/src/sgml/ref/alter_property_graph.sgml
M doc/src/sgml/ref/create_property_graph.sgml
M doc/src/sgml/ref/drop_property_graph.sgml
M doc/src/sgml/ref/select.sgml
M doc/src/sgml/ref/wait_for.sgml

Fix user-facing English grammar introduced in the v19 cycle.

commit   : 0976940213d9b324994aa9270f8a158f6ab41f89    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Tue, 1 Sep 2026 17:03:27 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Tue, 1 Sep 2026 17:03:27 -0700    

Click here for diff

Backpatch-through: 19  

M doc/src/sgml/func/func-admin.sgml
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/queries.sgml
M doc/src/sgml/ref/wait_for.sgml
M src/backend/statistics/extended_stats_funcs.c
M src/backend/utils/activity/wait_event_names.txt

pg_dump: Fix performance regression in attribute statistics query.

commit   : a0edc1c318f3393474d50249ad2355e00fc4cd28    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 16:27:18 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 16:27:18 -0500    

Click here for diff

After adding pg_stats.tableid, we taught pg_dump to use it in the  
attribute statistics query for servers running v19 or later.  
Notably, we did not give this new form of the query a "redundant  
filter clause" like we did the pre-v19 form.  Testing indicates  
that produces a significant performance regression, and that adding  
a similar filter clause to the v19-or-later form of the query fixes  
it.  
  
Oversight in commit 4b5ba0c4ca.  
  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/apQ9nvLW_zFdarYd%40nathan  
Backpatch-through: 19  

M src/bin/pg_dump/pg_dump.c

Fix scaling of autovacuum freeze scores.

commit   : 49e098b41420aebda60804410b33fcbb5279503f    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 15:20:01 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 15:20:01 -0500    

Click here for diff

Sufficiently large settings of the *_freeze_score_weight parameters  
can lower the scaling thresholds below the *_freeze_max_age  
settings.  This can lead the scoring code to raise a value < 1.0 to  
a power > 1.0, thus lowering the score, which is the opposite of  
what is intended.  To fix, only exponentiate the scores when doing  
so won't lower their values.  
  
Oversight in commit d7965d65fc.  
  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/apWcbq91BAfhmsKU%40nathan  
Backpatch-through: 19  

M src/backend/postmaster/autovacuum.c

Fix spurious errors in COPY FROM (FORMAT {text,csv}).

commit   : 348f4ab53a080af611c92ad638781500ac53fe09    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 14:20:16 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 14:20:16 -0500    

Click here for diff

The SIMD path for these commands reads ahead into the input buffer  
via CopyLoadInputBuf(), which reports encoding and conversion  
errors.  The problem is that the errant data might lie beyond the  
end-of-copy marker, which we aren't copying and thus needn't error  
for.  To fix, add a "speculative" parameter to CopyLoadInputBuf()  
that defers these errors, and use it in the SIMD path.  The errors  
are instead reported only if we actually reach the errant data.  
Testing indicates this does not meaningfully impact performance.  
  
Oversight in commit e0a3a3fd53.  
  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://postgr.es/m/apWOr1kgVSqweBnU%40nathan  
Backpatch-through: 19  

M src/backend/commands/copyfromparse.c

Fix assertion failures in DELETE FOR PORTION OF tuple routing

commit   : 610976420a331ab007621ae30f664d17c8d2eebe    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 1 Sep 2026 20:45:13 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 1 Sep 2026 20:45:13 +0200    

Click here for diff

We must handle cases where an inserted temporal leftover gets routed to  
a different partition than the original tuple's. This happens if the  
partition key depends on the application-time column used in the FOR  
PORTION OF clause. Everything works for UPDATE, but for DELETE we can  
hit some Asserts, since that operation never needed to be covered  
before. One Assert is for the RETURNING list; the other, for WITH CHECK  
OPTION. This commit updates both to include CMD_DELETE.  
  
Author: Paul A Jungwirth <pj@illuminatedcomputing.com>  
Reported-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://postgr.es/m/03276924-6d55-470d-8192-a49c053c940f@eisentraut.org  

M src/backend/executor/execPartition.c
M src/test/regress/expected/for_portion_of.out
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/for_portion_of.sql
M src/test/regress/sql/updatable_views.sql

Make after-startup shmem failure test reliable

commit   : e916927cfbc0e6aed4dfe0d6018c42abc7fc493c    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Tue, 1 Sep 2026 10:32:41 -0400    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Tue, 1 Sep 2026 10:32:41 -0400    

Click here for diff

The test expects a 128 kB request to exceed the shared memory available after  
startup.  Huge pages can round up the main shared memory segment enough for  
that request to succeed, defeating the test.  
  
Disable huge pages for the allocation-failure phase so that it exercises the  
intended error path independently of shared memory segment rounding.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reported-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/rpkhzrrmo7qiz7rr3qlufksb2oci33wcg3ao75le7dqindgoif@6yozkjwb6bdf  
Backpatch-through: 19  

M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl

libpq: Stop greasing protocol connections

commit   : 408a28c49a6744715a954bd817141ba562e28341    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Tue, 1 Sep 2026 10:25:39 -0700    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Tue, 1 Sep 2026 10:25:39 -0700    

Click here for diff

This reverts commit 4966bd3ed95e0d02bf220c4bad2b292963827dd4, which  
introduced the 19beta grease campaign, now that Beta 3 has been stamped.  
(The reservation and documentation for the grease version code, done in  
d8d7c5dc8f, remains.)  
  
Discussion: https://postgr.es/m/CAOYmi%2Bkqt_gn-wvUjJG1j3MM4LDDsRMURSPz2eMxfABu0iGtpw%40mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/libpq.sgml
M doc/src/sgml/protocol.sgml
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/fe-misc.c
M src/interfaces/libpq/fe-protocol3.c
M src/interfaces/libpq/libpq-int.h
M src/test/modules/libpq_pipeline/libpq_pipeline.c

Revert "Force LC_COLLATE to C in postmaster."

commit   : e502f9aa817074d19fb12d9aa8de27ab3623e564    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 1 Sep 2026 09:51:44 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 1 Sep 2026 09:51:44 -0700    

Click here for diff

Out of an abundance of caution.  
  
This reverts commit 5e6e42e44fe10cab616b4fbe9725df03c987c90a.  
  
Requested-by: Daniel Verite <daniel@manitou-mail.org>  
Requested-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260826232534.13.noahmisch@microsoft.com  
Backpatch-through: 19  

M doc/src/sgml/catalogs.sgml
M doc/src/sgml/charset.sgml
M doc/src/sgml/ref/create_database.sgml
M doc/src/sgml/ref/createdb.sgml
M src/backend/main/main.c
M src/backend/utils/init/postinit.c

pg_dump: Remove some dead code.

commit   : 07749290fd9bd96503f05683ec5323a24d26dc0b    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 11:26:19 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 1 Sep 2026 11:26:19 -0500    

Click here for diff

Two members of TableInfo were set but not used.  Remove them.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Discussion: https://postgr.es/m/CAJ7c6TOET3UVUqXcXMpcoDAiZJvMFmHjnavj%2BFGdfXEKwe_56g%40mail.gmail.com  

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

Handle XmlExpr more honestly in clauses.c.

commit   : 14dbc85985357c0d6485dab8dd64fac02c91d207    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 1 Sep 2026 12:16:45 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 1 Sep 2026 12:16:45 -0400    

Click here for diff

eval_const_expressions() didn't constant-fold XmlExpr.  In some cases  
it cannot, but often it can.  Failure to do so can cause visible  
regressions in SQL-language function behavior compared to pre-v18,  
though only in a rather narrow set of contexts: basically, if you're  
trying to use a CASE to prevent evaluation of a failure-prone XML  
function.  
  
While we're at it, make contain_mutable_functions() handle XmlExpr  
more precisely, and adjust some comments that justify not treating  
XmlExpr explicitly.  
  
This seems worth sneaking into v19, but I'm hesitant to put it into  
v18.  It's not really a bug fix, because we disclaim the safety of  
using CASE this way, and it carries some risk of de-optimizing queries  
that worked satisfactorily before.  
  
Bug: #19487  
Reported-by: Ilya Portnov <i.portnov@compassplus.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19487-367258bc497b923a@postgresql.org  
Backpatch-through: 19  

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

doc: clarify aliasing of VALUES in FROM clauses

commit   : 076630cbdbdb8b6d69ad8fb30c2b6b707560c234    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 22:46:10 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 22:46:10 +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

pgcrypto: remove unused BF_ASM macro

commit   : a62fa616113e68735db3e1dc353e09e675d6df6c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 1 Sep 2026 13:50:51 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 1 Sep 2026 13:50:51 +0200    

Click here for diff

This has never been defined to anything but 0, and the _BF_body_r  
function it would call has never existed.  
  
Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://www.postgresql.org/message-id/flat/87ldew2yqu.fsf%40wibble.ilmari.org  

M contrib/pgcrypto/crypt-blowfish.c

Replace px_memset() with explicit_bzero()

commit   : 8534b0b4c765b06de30d249c9bacecc2d10ac68b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 10:09:49 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 10:09:49 +0200    

Click here for diff

The former was trying to do the same as the latter, but the latter has  
more robust and portable implementations, and it's the standard across  
the tree, so replace and remove px_memset().  
  
Co-authored-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>  
Discussion: https://www.postgresql.org/message-id/flat/a035c67f-4aa8-42e0-bb24-7b5abe927af4%40eisentraut.org  
Discussion: https://www.postgresql.org/message-id/flat/87ldew2yqu.fsf%40wibble.ilmari.org  

M contrib/pgcrypto/crypt-blowfish.c
M contrib/pgcrypto/crypt-md5.c
M contrib/pgcrypto/crypt-sha.c
M contrib/pgcrypto/mbuf.c
M contrib/pgcrypto/pgp-cfb.c
M contrib/pgcrypto/pgp-compress.c
M contrib/pgcrypto/pgp-decrypt.c
M contrib/pgcrypto/pgp-encrypt.c
M contrib/pgcrypto/pgp-mpi.c
M contrib/pgcrypto/pgp-pgsql.c
M contrib/pgcrypto/pgp-pubenc.c
M contrib/pgcrypto/pgp-pubkey.c
M contrib/pgcrypto/pgp-s2k.c
M contrib/pgcrypto/pgp.c
M contrib/pgcrypto/px-crypt.c
M contrib/pgcrypto/px-hmac.c
M contrib/pgcrypto/px.c
M contrib/pgcrypto/px.h

Fix memset invocation

commit   : 2a2dab67dc40a41a003545308423c1d3def02dea    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 1 Sep 2026 11:58:20 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 1 Sep 2026 11:58:20 +0200    

Click here for diff

It was setting sha_buf_tmp but sizing it by sizeof sha_buf.  These  
happen to be the same size, so it's not an actual problem, but for  
correctness make the sizeof match.  
  
Reported-by: Sehrope Sarkuni <sehrope@jackdb.com>  
Discussion: https://www.postgresql.org/message-id/flat/a035c67f-4aa8-42e0-bb24-7b5abe927af4%40eisentraut.org  

M contrib/pgcrypto/crypt-sha.c

Wait for checksum state transition in test

commit   : 5313fc415d90d435b91f7c0786a1630e05440759    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 1 Sep 2026 11:14:25 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 1 Sep 2026 11:14:25 +0200    

Click here for diff

The test for disabling data checksums after a failure didn't wait  
for the state transition to complete before testing, which could  
lead to false negatives in testing.  Fix by passing the wait param  
when disabling.  Identified on buildfarm member culicidae.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://postgr.es/m/b2f34fd3-8e98-450e-9e8c-ac08238e9116@gmail.com  
Backpatch-through: 19  

M src/test/modules/test_checksums/t/005_injection.pl

Handle PG_INT32_MIN negation overflow in right()

commit   : a63df2664225d06d5bee5dd9195f6d10e7fa1502    
  
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

Use pg_neg_s{32,64}_overflow() for some overflow checks

commit   : 8e483af5515ec4ee90d17a3864f5bb764e4e9c47    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 1 Sep 2026 14:32:31 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 1 Sep 2026 14:32:31 +0900    

Click here for diff

The files updated in this commit open-coded checks based on a minimal  
value (as of "x == PG_INTnn_MIN") combined with negative calculations.  
More efficient equivalents are available in int.h with  
pg_neg_s32_overflow() and pg_neg_s64_overflow().  
  
Extracted from a larger patch by the same author.  These spots have  
proved to reduce the number of instructions generated after testing  
across some versions of clang and gcc, with and without the  
__builtin_*_overflow() functions.  Some unlikely() can be removed, but  
not all, cash.c standing as an exception.  There should be no behavioral  
changes.  
  
Suggested-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAON2xHO4tTFiow2KKLbpiOEJNL4Th5p1QVTm4mSdEU+KW1rrfQ@mail.gmail.com  

M src/backend/utils/adt/cash.c
M src/backend/utils/adt/int.c
M src/backend/utils/adt/int8.c
M src/backend/utils/adt/numeric.c

doc: reformat GRAPH_TABLE examples

commit   : a20d3e35f2c00938c5329cbf570160184f4f0a69    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 12:54:31 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 1 Sep 2026 12:54:31 +0900    

Click here for diff

The GRAPH_TABLE examples in ddl.sgml and queries.sgml were written  
as single long lines, making their structure harder to read in the  
generated documentation.  
  
Reformat these examples so that the graph name, MATCH clause, and  
COLUMNS clause appear on separate lines, making them easier to read.  
  
Author: Koshino Taiki <koshino@sraoss.co.jp>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/OS9P286MB64860BD6CD6D4B4B0E1CEDE894A32@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM  
Backpatch-through: 19  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/queries.sgml

Fix integer to_char() overflow with V format

commit   : 3b120b1e94dd0387ca40e1e356f6b7eb8793d297    
  
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

Fix comment in attribute_stats.c

commit   : fa68aeeab115abf46abf8277f6dd6a89f5f93440    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 1 Sep 2026 08:12:34 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 1 Sep 2026 08:12:34 +0900    

Click here for diff

Oversight in ce207d2a7901.  
  
Author: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/CADkLM=eo7MtuCE=YjovW+=ASw1=q39qQ3qarrsw+EKfU901ztA@mail.gmail.com  
Backpatch-through: 18  

M src/backend/statistics/attribute_stats.c

commit   : 6885b845b4ba0b7aee09daa9817703477faa3704    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 31 Aug 2026 12:34:24 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 31 Aug 2026 12:34:24 -0500    

Click here for diff

Oversight in commit 283e823f9d.  
  
Backpatch-through: 19  

M doc/src/sgml/system-views.sgml

doc: Drop stale note about extension LWLock names.

commit   : 98cd8d509f8bc0aef4ea2aa5eb71085bece38b78    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 31 Aug 2026 12:07:07 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 31 Aug 2026 12:07:07 -0500    

Click here for diff

Oversight in commit 38b602b028.  
  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml

test_extensible: Test module for extensible nodes and custom scans

commit   : 0e944fe3579ecd525e5ffe7b7db4a7e1c34de49e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 31 Aug 2026 12:51:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 31 Aug 2026 12:51:14 +0900    

Click here for diff

This commit adds a new test module that implements a CustomScan based on  
an ExtensibleNode.  These APIs exist in the core code for ages but had  
zero coverage.  This now covers the read, copy and out routines for  
extensible nodes, with SQL function wrappers for each.  CustomScan nodes  
are tested with callbacks to manipulate the executor, based on the idea  
of repeating the number of times each row is returned in a single scan,  
using a GUC (default at 2 tuples for each row, can be tweaked).  
  
The code of this module is primitive to keep its logic simpler.  For  
example, custom scans happen only when matching one specific, hardcoded  
relation name, and work only for base relations (this can be extended at  
will, as required).  
  
This module can be used as a template for developers willing to develop  
their own extensions.  "Writing a Custom Scan Provider" covers the  
documentation for custom scans.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Jan Nidzwetzki <jan@planetscale.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>  
Discussion: https://postgr.es/m/CAJ7c6TNfn9Fv_Je1etA6rrgq1onVvXbjwBTkbkd4kVQhcu11gg%40mail.gmail.com  

M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_extensible/.gitignore
A src/test/modules/test_extensible/Makefile
A src/test/modules/test_extensible/expected/test_extensible.out
A src/test/modules/test_extensible/meson.build
A src/test/modules/test_extensible/sql/test_extensible.sql
A src/test/modules/test_extensible/test_extensible–1.0.sql
A src/test/modules/test_extensible/test_extensible.c
A src/test/modules/test_extensible/test_extensible.control
M src/tools/pgindent/typedefs.list

doc: Mark up "option" in the CHECKPOINT synopsis.

commit   : 92819e57945d106317eaaa4273180dd8663f91bd    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Sun, 30 Aug 2026 09:13:09 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Sun, 30 Aug 2026 09:13:09 -0500    

Click here for diff

Oversight in commit a4f126516e.  
  
Backpatch-through: 19  

M doc/src/sgml/ref/checkpoint.sgml

Drop the per-entry copy of the flag mode in CompoundAffixFlags.

commit   : 2fb8da5a245661287833b05a1b2e275ddf83bbd7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Aug 2026 20:11:56 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Aug 2026 20:11:56 -0400    

Click here for diff

Each CompoundAffixFlag carried its own copy of the dictionary's flag  
mode, which decides whether the union holds a string or an integer.  
The comment on the field explained why: cmpcmdflag() needs the mode,  
and at the time there was no bsearch() variant that would allow  
passing that context through.  But that problem is long gone, so let's  
remove the redundant storage.  No flexibility is lost because things  
would not work anyway if different flags within a dictionary have  
different representations; and the preceding commit has seen to it  
that they can't.  At present, this saves no storage on 64-bit machines  
because of alignment issues, but it still seems like good  
simplification.  
  
No back-patch: there's little value in this except cleanliness, and  
although probably no outside code is looking at this data structure,  
this'd be an API/ABI break if any does.  
  
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  

M src/backend/tsearch/spell.c
M src/include/tsearch/dicts/spell.h

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

commit   : 15ee73d7d7cd6bf01ba721603067fa59be746b3c    
  
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

Disallow ONLY in REPACK commands.

commit   : ec13f71049cda06ea55a67783b822d98824f4d15    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Sat, 29 Aug 2026 10:23:23 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Sat, 29 Aug 2026 10:23:23 -0500    

Click here for diff

The REPACK grammar accepts ONLY before the table name and * after  
the table name, but that's neither documented nor handled in the  
code.  Perhaps REPACK should support that syntax, but for now let's  
just bring it in line with its documentation.  
  
Oversight in commit ac58465e06.  
  
Reviewed-by: Antonin Houska <ah@cybertec.at>  
Discussion: https://postgr.es/m/apBTsWGwkLXVh8Ow%40nathan  
Backpatch-through: 19  

M src/backend/parser/gram.y

Propagate rebalanced cost limit to parallel vacuum workers

commit   : 6c5f1d6074208146930b67c2054509c3e82f6f7f    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 28 Aug 2026 23:24:47 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 28 Aug 2026 23:24:47 +0200    

Click here for diff

AutoVacuumUpdateCostLimit() runs after each nap in vacuum_delay_point()  
and follows av_nworkersForBalance, but the new limit never reached the  
shared cost params in the vacuum DSM: propagation only required config  
reload.  Parallel workers computed their delays from the stale limit,  
so a parallel autovacuum could run at up to twice the configured budget  
(or half of it) until the next SIGHUP, contradicting the propagation  
promise in maintenance.sgml.  
  
Call parallel_vacuum_propagate_shared_delay_params() after rebalancing.  
Gated on the leader: parallel workers take the same nap path and must  
not overwrite the shared parameters.  
  
This also adds a test to validate the behaviour: pause the leader at the  
existing injection point, start a second autovacuum worker and hold it at  
a new injection point placed after it joined the balance, then check the  
first parameter load of the parallel workers reports the balanced limit.  
The hold is needed because a second worker left running can finish its own  
vacuum before the leader resumes, which puts the balance back where it  
started.  Autovacuum is disabled for everything but the two test tables  
via thresholds, as a worker spawned by catalog churn would get trapped at  
the hold point and starve the test of its second worker slot.  
  
Backpatch to v19 where autovacuum gained the ability to use parallel  
vacuum workers.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFOZtEPwGQ6oa9LvHvN522zEp8h_dW9hHExSh7pVXofoKQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/vacuum.c
M src/backend/postmaster/autovacuum.c
M src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl

Perform join removal by editing the query's jointree.

commit   : 2ebf25e7d70a8fce31ace78d723fa9271ab8af72    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 28 Aug 2026 15:12:26 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 28 Aug 2026 15:12:26 -0400    

Click here for diff

analyzejoins.c decided which joins could be dropped by consulting the  
planner's derived data structures, but then implemented the removal  
by updating those structures in-place.  That is a lot of fiddly work,  
and nothing keeps it in step with the rest of the planner:  
remove_leftjoinrel_from_query only bothered to update "parts of the  
planner's data structures that will actually be consulted later", with  
no good way to know what those are.  Bug #19560 is one consequence.  
In that report, removing a join leaves an EquivalenceClass that now  
gives rise to a base restriction clause, but base restriction clauses  
have already been generated and nothing reconsiders them, so the WHERE  
condition disappears from the plan and we return wrong answers.  
  
The self-join elimination code has the same design and the same type  
of hazard.  We have seen many related bugs over the years too, so it's  
time to do something drastic.  
  
To fix, do the removals by editing root->parse->jointree (which is a  
far simpler and more stable representation than the derived data),  
and then have query_planner() discard everything it computed from the  
jointree and derive it over again.  This requires quite a bit less  
code, and doesn't require touching analyzejoins.c every time we change  
the data derived by query_planner().  For typical cases it can actually  
save a bit of planning time, though in cases where we have to iterate  
the derivation loop many times it does add some time.  
  
reduce_unique_semijoins() gets the same treatment: rather than deleting  
the semijoin's SpecialJoinInfo and relying on the jointree not being  
consulted again, it now changes the JoinExpr's jointype to JOIN_INNER  
and recalculates everything.  
  
Some plans change in the join regression test.  Qual evaluation order  
shifts in a few cases, because the conditions now reach later planning  
in jointree order rather than in whatever order the removal code  
re-distributed them.  A few plans improve, since the rebuilt relation  
targetlists no longer carry columns that only a removed join needed.  
We also detect a constant-false filter condition whose test used to  
carry a FIXME label.  One plan gets marginally worse, because the old  
code recomputed attr_needed from equivalence classes after a join  
removal; that is more accurate than what deconstruct_jointree()  
derives from the original clauses, but we no longer do that.  Making  
that recomputation happen anyway could be worth doing, but it should  
be considered independently and perhaps implemented differently.  
  
Back-patch to v16, on the grounds that the introduction of  
varnullingrels in v16 made the old approach significantly more complex  
and bug-prone; notably, bug #19560 does not manifest before v16.  
In released branches, do not remove externally-visible fixup  
functions such as remove_join_clause_from_rels, in case any  
extensions are relying on them; but they're no longer used by core  
code.  But we must nonetheless break API/ABI for remove_useless_joins,  
reduce_unique_semijoins, and remove_useless_self_joins, as those now  
have different outputs and very different behavior than before.  
It seems unlikely that any extensions are calling those; but just in  
case, make the breakage more obvious by renaming remove_useless_joins  
to remove_useless_outer_joins, which is a more sensible name for it  
anyway since the addition of remove_useless_self_joins.  
  
Full disclosure: initial drafts of this patch were made with  
Claude Opus 4.8.  
  
Bug: #19560  
Reported-by: Orestis Markou <orestis@orestis.gr>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Thom Brown <thom@linux.com>  
Reviewed-by: Jacob Brazeal <jacob.brazeal@gmail.com>  
Discussion: https://postgr.es/m/1186816.1784573544@sss.pgh.pa.us  
Backpatch-through: 16  

M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/plan/analyzejoins.c
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/plan/planmain.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/util/joininfo.c
M src/backend/optimizer/util/placeholder.c
M src/backend/rewrite/rewriteManip.c
M src/include/nodes/primnodes.h
M src/include/optimizer/joininfo.h
M src/include/optimizer/paths.h
M src/include/optimizer/placeholder.h
M src/include/optimizer/planmain.h
M src/include/rewrite/rewriteManip.h
M src/test/regress/expected/join.out
M src/test/regress/expected/rowsecurity.out
M src/test/regress/sql/join.sql
M src/test/regress/sql/rowsecurity.sql
M src/tools/pgindent/typedefs.list

Track which shmem areas have been fully initialized

commit   : 07fdee7c8a8b415fb3a2991e7aea34f08975d445    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 28 Aug 2026 17:49:38 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 28 Aug 2026 17:49:38 +0300    

Click here for diff

If SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP is used to allocate shared  
memory after startup, but the initialization fails half-way through,  
the shmem area is left in an indeterminate state.  Furthermore, if  
multiple shmem areas are registered in one RegisterShmemCallbacks()  
call, some might be allocated while others are not.  
  
This commit adds an explicit 'initialized' flag to each shmem area.  
We still leave behind an uninitialized area on error, but at least  
they are now clearly marked, and you get a slightly nicer error  
message if you try to re-register them.  It'd be nice to clean up more  
thoroughly and support actually retrying the allocations, but in  
practice, the most likely reason for a shmem allocation or  
initialization to fail is that you are out of shared memory and  
retrying wouldn't help with that.  
  
This isn't exactly a new problem, the old ShmemInitStruct() interface  
had similar issues if the initialization code failed, or if you  
allocated multiple structs and some allocations failed.  It was just  
left to the calling code to deal with it.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAJTYsWVRRWH48=PcuAo_2Y4Ap6M0QRmzxgUfFkNRtdWK74LjBQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/xfunc.sgml
M src/backend/storage/ipc/shmem.c
M src/test/modules/test_shmem/Makefile
M src/test/modules/test_shmem/meson.build
M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl
M src/test/modules/test_shmem/test_shmem.c

Fix backend state after a failed after-startup shmem request

commit   : c54b6979e033c6182518d4b33feb35771ae738ae    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 28 Aug 2026 17:48:46 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 28 Aug 2026 17:48:46 +0300    

Click here for diff

RegisterShmemCallbacks() left the backend in a bad state, if an error  
occurred in the callbacks or if an allocation failed.  Firstly,  
'shmem_request_state' was left in wrong state, causing a subsequent  
call to RegisterShmemCallbacks() to wrongly take the postmaster  
startup codepath or assertion failures in some other functions.  
Secondly, the 'pending_shmem_requests' list was not properly cleaned  
up, causing a subsequent RegisterShmemCallbacks() to try to process  
the stale, already-freed requests.  
  
To fix, add a PG_TRY() block to clean those things up on error.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAJTYsWVRRWH48=PcuAo_2Y4Ap6M0QRmzxgUfFkNRtdWK74LjBQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/storage/ipc/shmem.c
M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl
M src/test/modules/test_shmem/test_shmem.c

Make platform guards in two regression tests match meson builds

commit   : 4d5fdb21ddda46972d7703562c5ad4076feae8b8    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 28 Aug 2026 09:36:13 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 28 Aug 2026 09:36:13 -0400    

Click here for diff

collate.linux.utf8 skips itself unless version() matches "linux-gnu",  
and infinite_recurse skips itself when version() matches  
"powerpc64[^,]*-linux-gnu".  configure substitutes the GNU host triplet  
into that string, but the meson build composes it from  
host_machine.cpu_family() and host_system, which never carries the ABI  
suffix.  So ever since meson support arrived in 16, collate.linux.utf8  
has not run at all on a meson build, and infinite_recurse has been  
running on ppc64 Linux the very case it means to stay away from.  
Meson documentation says it reports 'ppc64' instead of 'powerpc64'.  
  
Fix by matching "-linux[-,]" and "p(ower)?pc64[^,]*-linux", which match  
all spellings.  Keeping the punctuation on either side confines the  
match to the platform field.  Neither pattern excludes musl, but  
collate.linux.utf8's other conditions already require a set of glibc  
locales to be present.  
  
Backpatch to 16, where the meson build was introduced.  
  
Discussion: https://postgr.es/m/a40b19da-9a02-47b4-8afd-2bbbde8db1e8@dunslane.net  
  
Reviewed-By: Jonathan Gonzalez V. <jonathan@abdiel.eu>  
Reviewed-By: Nazir Bilal Yavuz <byavuz81@gmail.com>  

M src/test/regress/expected/collate.linux.utf8.out
M src/test/regress/expected/collate.linux.utf8_1.out
M src/test/regress/expected/infinite_recurse.out
M src/test/regress/expected/infinite_recurse_1.out
M src/test/regress/sql/collate.linux.utf8.sql
M src/test/regress/sql/infinite_recurse.sql

Propagate disabled_nodes to single-child Append paths

commit   : de5659440dbcfe0ef61b474cec0e5ec50a9c3841    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 28 Aug 2026 14:51:36 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 28 Aug 2026 14:51:36 +0900    

Click here for diff

create_append_path() skips cost_append() when an Append has exactly  
one child whose parallel awareness matches its own, since setrefs.c  
strips such an Append out entirely.  In that case it copies the  
child's rowcount and costs directly, but it failed to copy  
disabled_nodes.  An Append over a disabled child therefore claimed to  
contain no disabled nodes, letting a disabled path win over one that  
is not disabled.  
  
This is a regression in v18; before e22253467, disable_cost was folded  
into a path's startup and total costs, so it rode along in the fields  
this shortcut already copies.  
  
Back-patch to v18.  This can change plans in stable branches, but only  
for installations that have explicitly disabled a node type, and only  
to stop using the node they asked us to avoid.  
  
Reported-by: Man Zeng <zengman@halodbtech.com>  
Author: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAHewXNm_Zx5EDoaD7wo7bq6cfRroNznS+RBCzT_p2-CWQXpgSw@mail.gmail.com  
Backpatch-through: 18  

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

Fix incorrect multi-column RANGE partition pruning

commit   : 6e5d5680b555523a3d5c547aa22df0267860344a    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 28 Aug 2026 13:10:21 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 28 Aug 2026 13:10:21 +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

Report next_multi_offset as bigint in pg_control_checkpoint().

commit   : 45817676632b46fc9d2b97c8d432348e0ee4f1f4    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 27 Aug 2026 12:25:01 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 27 Aug 2026 12:25:01 -0700    

Click here for diff

Commit bd8d9c9bdfa widened MultiXactOffset to 64 bits, but  
pg_control_checkpoint() still handle checkPointCopy.nextMultiOffset as  
xid type and declared next_multi_offset column as xid. Since xid is 32  
bits wide, an offset above 2^32 was reported truncated, while  
pg_controldata printed the full value of the same field.  
  
This commit reports the column as bigint instead. That matches  
pg_get_multixact_stats(), which already reports num_members and  
members_size, both derived from these same offsets, as int8.  
  
Backpatch to v19, where MultiXactOffset was widened.  
  
Bump catalog version.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAD21AoCvzerscfU8o4ARQ793yAGHpQ72r2x5apeC_W2-k=SLCQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/func/func-info.sgml
M src/backend/utils/misc/pg_controldata.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

pg_upgrade: Read nextMultiOffset as a 64-bit value.

commit   : 058962fdc98ea05968cd18f7b87610f9f2dd28d2    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 27 Aug 2026 12:10:46 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 27 Aug 2026 12:10:46 -0700    

Click here for diff

Commit bd8d9c9bdfa widened MultiXactOffset to 64 bits and widened  
ControlData.chkpnt_nxtmxoff accordingly, but get_control_data() still  
read the "Latest checkpoint's NextMultiOffset" line with str2uint(),  
which returns unsigned int.  
  
This commit adds str2uint64(), mirroring the str2uint() helper used  
for the other control file fields, and reads the offset with it.  
  
Backpatch to v19, where MultiXactOffset was widened.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAD21AoCvzerscfU8o4ARQ793yAGHpQ72r2x5apeC_W2-k=SLCQ@mail.gmail.com  
Backpatch-through: 19  

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

Fix empty FOREIGN_JOIN sublist validation

commit   : 8c9c2e5c09aeda713640ccb26bfca0fdccc310d5    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 27 Aug 2026 14:14:15 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 27 Aug 2026 14:14:15 -0400    

Click here for diff

FOREIGN_JOIN target sublists must contain at least two relation  
identifiers.  However, the parser checked only for sublists with  
exactly one identifier, so FOREIGN_JOIN(()) was accepted.  
  
Reject sublists with fewer than two relation identifiers, and add  
regression coverage.  
  
Author: Chao Li <lic@highgo.com>  
Discussion: http://postgr.es/m/BEDC04E0-6732-4310-95BA-6EC34BC1442C@gmail.com  

M contrib/pg_plan_advice/expected/syntax.out
M contrib/pg_plan_advice/pgpa_parser.y
M contrib/pg_plan_advice/sql/syntax.sql

Fix temporary WAL receiver slot handling on timeline switches

commit   : 58ff54aee8b252b23b35c7a6297bf9189731bca3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 28 Aug 2026 01:15:23 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 28 Aug 2026 01:15:23 +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   : 2a254323373650843a944adabe3bb0441bde4e27    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 27 Aug 2026 23:51:21 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 27 Aug 2026 23:51:21 +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

Report specific SQLSTATEs for stats restore errors

commit   : 398a6bdd933e2fe8ce8589ac728f649d1b70b3e4    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 27 Aug 2026 23:40:20 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 27 Aug 2026 23:40:20 +0900    

Click here for diff

The pg_restore_*_stats() functions could report SQLSTATE XX000 for  
invalid variadic arguments, such as an unmatched name/value pair, a NULL  
argument name, or a non-text argument name. Attribute and extended  
statistics restores could also report XX000 when the supplied statistics  
exceed the number of slots PostgreSQL can store.  
  
These are not internal errors. They result from invalid caller input or  
a PostgreSQL implementation limit, but the lack of specific SQLSTATEs  
made clients treat them as internal errors.  
  
Assign appropriate SQLSTATEs to these errors so that applications and  
tests can classify them correctly.  
  
Backpatch to v19, but no further; changing ERRCODE assignments in  
released stable branches doesn't seem like a good idea.  
  
Bug: #19629  
Reported-by: Zheng Wang <hackerzheng666@gmail.com>  
Reported-by: Yanjie Zhao  
Reported-by: Yiyang Liu  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19629-76babc04b683594d@postgresql.org  
Backpatch-through: 19  

M src/backend/statistics/stat_utils.c

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

commit   : 2866d8c7dbfc9d882a7d80fef93fbbe763709932    
  
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/sql/create_type.sql

Fix pg_event_trigger_ddl_commands for GRANT ON PROPERTY GRAPH

commit   : 0417bf52969a1d57f6bc92b9abd5c8a01f9bc9fe    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 27 Aug 2026 11:32:55 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 27 Aug 2026 11:32:55 +0200    

Click here for diff

stringify_grant_objtype() treated OBJECT_PROPGRAPH as unused, so  
pg_event_trigger_ddl_commands() failed with "unsupported object type"  
when a ddl_command_end trigger inspected GRANT/REVOKE on a property  
graph.  Return "PROPERTY GRAPH" like the GRANT command syntax.  
  
Bug: #19637  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/19637-4446f72945492ed8%40postgresql.org  

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

Fix inferred property graph keys with INCLUDE columns

commit   : 8646d1d5904503f7e8cbb7166e857fed63c6e49c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 27 Aug 2026 10:42:14 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 27 Aug 2026 10:42:14 +0200    

Click here for diff

Inferred property graph keys used all attributes stored in the primary  
key index, causing non-key INCLUDE columns to become part of the graph  
key. Use only the index's key attributes.  
  
Author: Muhammad Taha Naveed <m.taha.naveed27@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAPTqav%2BVUjYgm1jZy0Scy%3D1-PfdgznVj2%3DPwH8disiXF76HEow%40mail.gmail.com  

M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/sql/create_property_graph.sql

Don't choose an invalid index for REPLICA IDENTITY FULL lookups.

commit   : ea9c9432c828c6ba9e38bdd0bccd3f63507594fc    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 27 Aug 2026 10:12:53 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 27 Aug 2026 10:12:53 +0530    

Click here for diff

For a REPLICA IDENTITY FULL remote relation whose local counterpart has  
no primary key or replica identity, FindUsableIndexForReplicaIdentityFull()  
chooses the first index of a suitable shape from RelationGetIndexList().  
That list excludes only indexes that are not indislive, so an invalid  
index left behind by a failed CREATE INDEX CONCURRENTLY can be selected.  
  
Such an index need not contain every row. Consequently, changes for rows  
that it fails to find can be silently dropped as missing-tuple conflicts.  
If the index contains no rows at all, the scan can instead error out and  
cause the apply worker to exit.  
  
Skip invalid indexes, as the planner does.  
  
Author: Mikhail Nikalayeu <mihailnikalayeu@gmail.com>  
Reviewed-by: Miłosz Bieniek <bieniek.milosz@proton.me>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reviewed-by: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Ajin Cherian <itsajin@gmail.com>  
Discussion: https://postgr.es/m/CADzfLwWuubcbJBDRZ_J1SSqHDNjNmUYSAgf5y=17LxmP401xbw@mail.gmail.com  
Backpatch-through: 16, where it was introduced  

M src/backend/replication/logical/relation.c
M src/test/subscription/t/032_subscribe_use_index.pl

Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands

commit   : 7612ae8ed8c941985d9cbf60a0674c48f5b0abe5    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 27 Aug 2026 00:56:41 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 27 Aug 2026 00:56:41 +0300    

Click here for diff

This commit reverts f2e4cc4279 and 4b3d173629, and the subsequent fixes and  
improvements c5ae07a90a, 713e553e32, 52e629be95, ecb2508aaf, 9354896920,  
971017c495, 83df16f1fa, e64a9ba2b4, ff8bec8c46, cdae794af3, 57f19774d6, and  
881033ae8b.  d8af730100 and 0392fb900e cancelled each other out and are not  
reverted separately.  
  
The feature is reverted due to multiple design issues which are too late to  
address in this release cycle.  
  
Discussion: https://postgr.es/m/CAN4CZFNCU%3Dt09M%3D%2Br2t9hHLJuujdM4oQ8hCK_Sx-GpfiwMAicw%40mail.gmail.com  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/ref/alter_table.sgml
M src/backend/catalog/dependency.c
M src/backend/catalog/pg_constraint.c
M src/backend/commands/tablecmds.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/backend/partitioning/partbounds.c
M src/bin/psql/tab-complete.in.c
M src/include/catalog/dependency.h
M src/include/nodes/parsenodes.h
M src/include/parser/kwlist.h
M src/include/partitioning/partbounds.h
D src/test/isolation/expected/partition-merge.out
D src/test/isolation/expected/partition-split.out
M src/test/isolation/isolation_schedule
D src/test/isolation/specs/partition-merge.spec
D src/test/isolation/specs/partition-split.spec
M src/test/modules/test_ddl_deparse/expected/alter_table.out
M src/test/modules/test_ddl_deparse/sql/alter_table.sql
M src/test/modules/test_ddl_deparse/test_ddl_deparse.c
M src/test/modules/test_extensions/expected/test_extdepend.out
M src/test/modules/test_extensions/sql/test_extdepend.sql
D src/test/regress/expected/partition_merge.out
D src/test/regress/expected/partition_split.out
M src/test/regress/parallel_schedule
D src/test/regress/sql/partition_merge.sql
D src/test/regress/sql/partition_split.sql
M src/tools/pgindent/typedefs.list

Pin two ctype-dependent test_regex_utf8 cases to pg_c_utf8

commit   : b941cace8b2547c9b597fd43c880ef23c26184ea    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Sat, 22 Aug 2026 17:47:24 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Sat, 22 Aug 2026 17:47:24 -0400    

Click here for diff

test_regex_utf8 decides whether to run by looking at the database  
encoding alone, but two of its cases, [[:graph:]] and [[:print:]] over  
E'xᔀሷ', depend on the ctype as well.  In a database with encoding  
UTF8 and locale C they match just the x, because isgraph() and isprint()  
are false for anything outside ASCII, and the file fails.  
  
No buildfarm animal builds such a cluster, which is why this went  
unnoticed, and why the to_date() crash in 18.5 went undetected for want  
of exactly this coverage.  A pending buildfarm client change will let an  
animal be configured that way.  
  
Fix by giving the two cases an explicit collation, so that they exercise  
a fixed Unicode ctype instead of whatever the database happened to be  
initialized with.  test_regex() already passes its input collation down  
to the regex compiler.  The expected results are unchanged; only the  
echoed queries differ.  
  
Backpatch-through: 17 (15 and 16 get a different fix)  
  
Reviewed-by: Jonathan Gonzalez V. <jonathan@abdiel.eu>  

M src/test/modules/test_regex/expected/test_regex_utf8.out
M src/test/modules/test_regex/sql/test_regex_utf8.sql

Export subxip[] for snapshots taken during recovery.

commit   : 79b101486c1d792600b79f90579b788385e85878    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 26 Aug 2026 15:38:17 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 26 Aug 2026 15:38:17 -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
M src/test/recovery/meson.build
A src/test/recovery/t/056_standby_snapshot_export.pl

Fix crash in subscription refresh on concurrent relation drop.

commit   : f3b0bb29834edb9242b180ea7289013a92c9f225    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 26 Aug 2026 12:03:52 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 26 Aug 2026 12:03:52 -0700    

Click here for diff

Commit 46b4f5c11b0 made the logical replication origin checks quote  
the schema and relation names they interpolate into the query sent to  
the publisher. Those names can be NULL, which that commit overlooked.  
  
AlterSubscription_refresh() collects the OIDs of the relations already  
present in pg_subscription_rel and hands them to  
check_publications_origin_tables() and  
check_publications_origin_sequences(), which append the  
schema-qualified name of each one to the query so that  
already-subscribed relations are excluded from the check. The  
relations are never locked, so one of them can be dropped concurrently  
before its name is read, and get_rel_name() and get_namespace_name()  
return NULL. quote_literal_cstr() dereferences it and crashes the  
backend.  
  
This commit fixes this by skipping a relation whose name is no longer  
available. A dropped relation is not synchronized anyway, and the  
appended clauses only exclude relations from a check whose sole effect  
is a WARNING, so omitting one can at most produce a spurious WARNING.  
  
The window is reachable from ALTER SUBSCRIPTION ... REFRESH  
PUBLICATION and from SET, ADD and DROP PUBLICATION, which refresh by  
default, but only when copy_data is true and origin is none. Backpatch  
to v16 as commit 46b4f5c11b0 was back-patched that far. The sequence  
path exists only in v19 and later.  
  
The test is applied to v19 and later only. Adding it to v17 and v18  
would require enabling injection point support in  
src/test/subscription there, and v16 predates injection points  
entirely. That is more test infrastructure churn on stable branches  
than this fix warrants.  
  
Reported-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>  
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>  
Co-authored-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Ajin Cherian <itsajin@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAHg+QDcd_o3707Ey8c8b7HkE-t14g8c0tk8ME3ctywDsh3ut8g@mail.gmail.com  
Backpatch-through: 16  

M src/backend/commands/subscriptioncmds.c
M src/test/subscription/t/100_bugs.pl

Close relations opened specifically for AFTER triggers

commit   : 1051099a9045fe4d6c81eeea33dcd24cd2ba7fd4    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 27 Aug 2026 02:40:23 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 27 Aug 2026 02:40:23 +1200    

Click here for diff

39dcfda2d fixed an incorrect reuse of ResultRelInfos for AFTER triggers  
when the ResultRelInfo needed to have a different ri_RootResultRelInfo.  
That caused an issue in logical replication apply workers as  
finish_edata() neglects to call ExecCloseResultRelations() and instead  
relies on ExecCleanupTupleRouting() to close relations opened during  
partitioning's tuple routing.  Since 39dcfda2d, because we may have done  
some additional table_opens() calls due to having to create an additional  
ResultRelInfo because of requirements to have a different  
ri_RootResultRelInfo, we should now be explicitly closing any relations  
opened on ResultRelInfos in EState's es_trig_target_relations.  
  
Since finish_edate() seems to want to avoid calling  
ExecCloseResultRelations(), add a new external function named  
ExecCloseTrigTargetRelations().  
  
Reported-by: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>  
Author: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>  
Discussion: https://postgr.es/m/OS9PR01MB121491E7E05950D108AF9A6D8F5A72@OS9PR01MB12149.jpnprd01.prod.outlook.com  
Backpatch-through: 15  

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

Fix registering shmem callbacks in single-user mode

commit   : edc095a2652971d6b2a95082c22dbdf34fc01d30    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 26 Aug 2026 12:59:18 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 26 Aug 2026 12:59:18 +0300    

Click here for diff

RegisterShmemCallbacks() should not be called from the postmaster  
process after postmaster startup. Add an assertion for that, and fix  
the check for whether it's being called for "after startup"  
allocations to take single-user mode into account.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAJTYsWU7epjUL1-xrpYeOrmkmq20M2Q22Y_SRb8PWQG8KNQyDw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/storage/ipc/shmem.c
M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl

Skip relations dropped concurrently in GetSubscriptionRelations().

commit   : 05f37b2b5eac5feab774a990a64ad16e2d03f5f5    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 26 Aug 2026 14:46:49 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 26 Aug 2026 14:46:49 +0530    

Click here for diff

GetSubscriptionRelations() can see a pg_subscription_rel row for a  
relation whose pg_class row was removed by a concurrent DROP. In this  
case, get_rel_relkind() returns '\0'. Skip such relations since they no  
longer exist and do not need synchronization.  
  
Replace the assertion on relkind with an error. Once the dropped  
relation case is handled, any other unexpected relkind indicates a  
relation kind that cannot be part of a subscription and should be  
reported rather than ignored.  
  
Author: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CALDaNm3eeKocRtQyUPdg2kaxJ-VAo5pwcNytDKNT1Yc0t2V_ug%40mail.gmail.com  

M src/backend/catalog/pg_subscription.c

Remove the redundant remote_final_lsn variable from the apply worker.

commit   : 2f4df67f5d00836979bc72bf6113adb45aff48df    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 26 Aug 2026 10:49:31 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 26 Aug 2026 10:49:31 +0530    

Click here for diff

The apply worker tracked the final LSN of the remote transaction being  
applied in a separate global variable remote_final_lsn, even though  
apply_error_callback_arg already tracked the same transaction's xid and  
finish LSN for error context reporting, and both were updated together  
at the same places.  
  
Rename ApplyErrorCallbackArg to ApplyRemoteCtx and treat its  
remote_xid/finish_lsn pair as the generic descriptor of the remote  
transaction currently being applied, replacing all uses of  
remote_final_lsn so the redundant global can be removed.  
  
There is no behavior change.  
  
Recording the remote transaction being applied in a single place should  
also help the proposed conflict log table patch, which needs the same  
information when logging a conflict.  
  
Author: Zhijie Hou <houzj.fnst@fujitsu.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>  
Discussion: https://postgr.es/m/TY4PR01MB177186ED4D38C5356294CC51C94A42@TY4PR01MB17718.jpnprd01.prod.outlook.com  

M src/backend/replication/logical/applyparallelworker.c
M src/backend/replication/logical/worker.c
M src/tools/pgindent/typedefs.list

commit   : 872b20aa5649f9b90781961cbc404409783dab2b    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 26 Aug 2026 10:18:07 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 26 Aug 2026 10:18:07 +0900    

Click here for diff

Adding REPACK introduced table-rewrite behavior that overlaps with  
VACUUM FULL and CLUSTER, but some documentation still mentioned only one  
of these commands or described the progress and locking behavior  
imprecisely.  
  
Clarify that table-rewriting operations, including REPACK, can change  
CTIDs.  Also describe VACUUM FULL, CLUSTER, and REPACK consistently as  
table-rewriting operations for disk-space recovery where appropriate,  
document the pg_stat_progress_repack and compatibility  
pg_stat_progress_cluster views consistently, and clarify the ACCESS  
EXCLUSIVE locking behavior of REPACK, including CONCURRENTLY.  
  
Backpatch to v19, where REPACK was introduced.  
  
Author: Marcos Pegoraro <marcos@f10.com.br>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAB-JLwaLcHyf=OnLnBsJEbdd57WjWPpK5T7iGFJvAQphjTZj_A@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/maintenance.sgml
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/mvcc.sgml

Add test for view referencing labels shared by vertex and edge tables

commit   : 3c982c9bf1af994090a181c68f9407ff39d3ddf7    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 15:25:03 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 15:25:03 +0200    

Click here for diff

Add a test for view containing labels which are shared by both vertex  
and edge tables.  When such a label is dropped from only vertex tables  
or only edge tables, the view may be rendered invalid because it does  
not find any elements associated with the label.  Right now, you get  
an error at run time.  It would be correct per SQL standard to make  
this a syntax error (parse time error), which would require some  
restrict/cascade action when dropping labels.  This is not a big  
problem, because you still get a clean error, but it might be worth  
improving sometime.  Add a test case to record the current behavior.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAExHW5toFV8b984ipuBSAar-W50K%3D%2BXmPOcG5ZUZNP4jrf4zSg%40mail.gmail.com  

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

Revert "Remove old readline API workaround"

commit   : 39c636a1aac8fe14afd3dd5af0141dc532a297b7    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 14:04:57 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 14:04:57 +0200    

Click here for diff

This reverts commit 5e1e32c2c6c61c411358ef101acb27db3969d4fb.  
  
It turns out that macOS still ships with an ancient libedit in the  
base system that has the old definition of rl_readline_name.  

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

Fix crash on trying to expand a shared memory hash table

commit   : 86481d9f4930750a9c62c25216bf7783f69d6ff0    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 25 Aug 2026 14:11:35 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 25 Aug 2026 14:11:35 +0300    

Click here for diff

When a hash table grows large enough we try to expand the directory,  
but we shouldn't try to do that if the hash table is marked as  
HASH_FIXED_SIZE.  Before commit 9fe9ecd516b that was harmless,  
although it was a little weird to expand the directory when allocating  
the new element was doomed to fail later anyway.  But the new  
allocator function added in that commit for shared memory hash tables  
did not expect to be called after hash table creation at all and would  
just crash.  Fix by ensuring that the allocator is not called after  
hash table creation for HASH_FIXED_SIZE tables.  
  
The crash started with commit 9fe9ecd516b in v19, so backpatch to v19.  
To trigger the crash, you needed a shared memory hash table of just  
the right size so that we would attempt to resize it: power-of-2 and  
at least HASH_SEGSIZE (256) elements.  With any other size, you would  
run out of allocated elements first.  
  
Author: Konstantin Knizhnik <knizhnik@garret.ru>  
Reviewed-by: Rahila Syed <rahilasyed90@gmail.com>  
Discussion: https://www.postgresql.org/message-id/d59221f2-b3d2-41ad-8bf0-d581b42e4cba@garret.ru  
Backpatch-through: 19  

M src/backend/utils/hash/dynahash.c

commit   : 5c52858ecdc052b2a9fc2a7f30e338ec6777c4ae    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Tue, 25 Aug 2026 17:50:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Tue, 25 Aug 2026 17:50:00 +0900    

Click here for diff

* Reorder the conditions in an if-else block for efficiency.  
* Reorder struct definitions for readability.  
* Reorder arguments for some functions for consistency.  
* Move variables to the required scope.  
* Rename a variable to match an input argument.  
* Add/Tweak some comments/docs for clarity.  
  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CAPmGK14otpa7XZyBO5GxDABUK9OPWFLsAwoQP3ugNdXq%3DK4J1g%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c
M doc/src/sgml/fdwhandler.sgml
M src/backend/commands/analyze.c

pgcrypto: Consistent spelling of built-in

commit   : cbc1e24d1be9d3ca8d0f98802c92e6233ab89532    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 25 Aug 2026 10:41:10 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 25 Aug 2026 10:41:10 +0200    

Click here for diff

Consistently use "built-in" instead of "built in" and "builtin".  
  
Author: Erik Rijkers <er@xs4all.nl>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/b6d69f32-253c-43ee-290e-f5f4c051a358@xs4all.nl  

M contrib/pgcrypto/pgcrypto.c
M doc/src/sgml/pgcrypto.sgml

Change InputFunctionCall* to take a const char *str

commit   : 5767fece95ccb58c25cee0567dd83457b8e15b37    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 10:26:50 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 10:26:50 +0200    

Click here for diff

It's reasonable to specify that the input string passed to these  
functions isn't modified.  
  
In each case, the input string is passed down to CStringGetDatum(),  
which already takes a const char *, so this change just pushes that  
API specification one level up.  
  
A couple of callers benefit from this by no longer having to cast away  
a const qualifier.  
  
A few more functions that call input functions internally are changed  
so that they can now offer a const qualified input string to their  
callers.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/459217ca-3840-4452-8cd1-8f9b47e8d479%40eisentraut.org  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/bootstrap/bootstrap.c
M src/backend/parser/parse_type.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/utils/adt/domains.c
M src/backend/utils/adt/rowtypes.c
M src/backend/utils/fmgr/fmgr.c
M src/include/bootstrap/bootstrap.h
M src/include/fmgr.h
M src/include/parser/parse_type.h

Fix some -Wcast-qual warnings

commit   : e58994c30199258c7abfdfd65140a699faac0a1c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 18 Aug 2026 10:52:24 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 18 Aug 2026 10:52:24 +0200    

Click here for diff

Small rearrangements to avoid having to cast away qualifiers.  In some  
cases, the whole cast was unnecessary.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/459217ca-3840-4452-8cd1-8f9b47e8d479%40eisentraut.org  

M contrib/btree_gist/btree_bit.c
M contrib/btree_gist/btree_utils_var.c
M contrib/btree_gist/btree_utils_var.h
M contrib/postgres_fdw/connection.c
M contrib/xml2/xslt_proc.c
M src/backend/utils/adt/multirangetypes.c
M src/backend/utils/adt/rangetypes.c
M src/backend/utils/adt/varlena.c
M src/include/storage/bufpage.h
M src/test/modules/test_custom_stats/test_custom_var_stats.c

Fix incorrect cast in Assert

commit   : c00d06417f8573f9f044082211eeafba59a73708    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 25 Aug 2026 20:15:07 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 25 Aug 2026 20:15:07 +1200    

Click here for diff

This was introduced in e3e26d04b, so backpatch to v19.  
  
Reported-by: Lev Nikolaev <lev.nikolaev@tantorlabs.com>  
Discussion: https://postgr.es/m/3e991e23-2260-459f-b3d0-e84fb48d353a@tantorlabs.com  
Backpatch-through: 19  

M src/backend/nodes/bitmapset.c

Remove old readline API workaround

commit   : 5e1e32c2c6c61c411358ef101acb27db3969d4fb    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 10:07:52 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 10:07:52 +0200    

Click here for diff

The casting away of const is no longer needed.  
  
rl_readline_name has been const since readline-4.2 (2001), libedit  
since  
2018 (https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline/readline.h?sortby=date,  
rev 1.44)  
  
See also commit 8666cf65ea6 for a similar fix.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/459217ca-3840-4452-8cd1-8f9b47e8d479%40eisentraut.org  

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

Fix accidentally casting away const

commit   : 13db0dbad601916b6fb526f777c4949abc08c423    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 09:55:16 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 09:55:16 +0200    

Click here for diff

fixup for commit c83a133f2bb  

M src/fe_utils/print.c

doc: Document overflow handling of pg_class.relpages etc.

commit   : e63961d7c16f7df5ba4b881f4bfa7a7920c628bd    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 08:39:16 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 08:39:16 +0200    

Click here for diff

The pg_class fields relpages, relallvisible, and relallfrozen are  
stored as int32 in the catalog but block numbers are internally of  
type uint32.  This all works correctly because the values are  
implicitly converted back and forth according to C conversion rules.  
But this was apparently never explicitly documented, so add this.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/db993f34-e3e1-4e6e-85c3-4f248d2ff29b%40eisentraut.org  

M doc/src/sgml/catalogs.sgml

Fix signed/unsigned integer handling in pg_restore_relation_stats()

commit   : b345a554edf321e0ca53db0f4a69aac217805677    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 08:39:16 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 25 Aug 2026 08:39:16 +0200    

Click here for diff

The pg_class fields relpages, relallvisible, and relallfrozen are of  
type int32, but the statistics restoration code and some statistics  
code in postgres_fdw internally dealt with them as uint32 for a little  
bit, after which they would turn back into int32.  This doesn't make  
sense, so fix it to use int32 consistently throughout.  
  
In passing, change a float to float4 to similarly make the C type  
consistent with the SQL type.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/db993f34-e3e1-4e6e-85c3-4f248d2ff29b%40eisentraut.org  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/statistics/relation_stats.c

Fix CPU cost of right-semi and right-anti hash joins

commit   : db2d99323f1882af87989e698d3678affc4a5557    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 25 Aug 2026 10:49:44 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 25 Aug 2026 10:49:44 +0900    

Click here for diff

final_cost_hashjoin() assumed that the rows a hash join produces come  
from the outer side.  That does not hold for JOIN_RIGHT_SEMI and  
JOIN_RIGHT_ANTI, which produce rows from the inner side: matched inner  
rows for the one, unmatched inner rows for the other.  hashjointuples,  
which carries both the cpu_tuple_cost charge and the remaining qual  
costs, was therefore counting the wrong rows, and could be far off in  
either direction.  
  
Compute hashjointuples from the inner side for these two join types,  
mirroring what JOIN_SEMI and JOIN_ANTI already do with the outer side.  
The fraction we need is semifactors.outer_match_frac: it is derived  
from the SpecialJoinInfo, so despite its name it always describes the  
semijoin's left-hand side, which is the inner side here.  Compute the  
semijoin factors for these join types in all cases; previously that  
happened only when the inner side was provably unique.  
  
The same mix-up affects outer_matched_rows when the inner side is  
known unique, where the outer row count was multiplied by the inner  
side's match fraction.  A unique inner side means each outer row has  
at most one match, so use the number of matching pairs instead.  
  
A right anti join evaluates the non-hashed joinquals once per tuple  
passing the hash clauses, without any short-circuit.  Charge the  
remaining qual costs on that pair count, and only cpu_tuple_cost on  
the emitted rows.  A right semi join short-circuits already-matched  
inner tuples and keeps the emitted-row charge, as JOIN_SEMI does.  
  
Nestloop and mergejoin need no equivalent fix: neither supports  
JOIN_RIGHT_SEMI, nestloop doesn't support JOIN_RIGHT_ANTI either, and  
final_cost_mergejoin() takes its count from approx_tuple_count(),  
which multiplies the two input sizes together and so gives the same  
answer whichever side is on the outside.  
  
No backpatch as this could result in plan changes.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49XwhSC=e8_yeEaGKmKNyWR3DHH0p+e4k-bR_pgRiN8nQ@mail.gmail.com  

M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/path/joinpath.c
M src/include/nodes/pathnodes.h
M src/test/regress/expected/join.out
M src/test/regress/expected/opr_sanity.out
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/join.sql

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

commit   : 1bf74c806c41fcd382d5a0fab226e027f454a576    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Tue, 25 Aug 2026 10:16:58 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Tue, 25 Aug 2026 10:16:58 +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

Align random test function parameters in test_bitmapset

commit   : d5d86704f4fddae04911e7784824429cbb2f6a84    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 25 Aug 2026 10:42:41 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 25 Aug 2026 10:42:41 +1200    

Click here for diff

53a981ed5 adjusted test_random_offset_operations() so that the minimum  
value parameter came before the maximum value parameter.  Here we adjust  
test_random_operations() so that it accepts absolute numbers for the  
minimum and maximum values.  Previously the maximum value to put in the  
random Bitmapset was the minimum value plus the range.  Also align the  
parameter order with test_random_offset_operations() to make these  
functions consistent with each other.  
  
Backpatch to v19 as test_random_operations() is new there.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com  
Backpatch-through: 19  

M src/test/modules/test_bitmapset/expected/test_bitmapset.out
M src/test/modules/test_bitmapset/sql/test_bitmapset.sql
M src/test/modules/test_bitmapset/test_bitmapset.c

pg_locale.h: define case mapping limits.

commit   : 1e9b06a8e07c3bd394459e68902b79d7b55c2035    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 14:39:51 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 14:39:51 -0700    

Click here for diff

Clearly define case mapping upper bounds that cover all providers,  
locales, and encodings: PG_MAX_CASEMAP_MBCHARS,  
PG_MAX_CASEMAP_EXPANSION, and PG_CASEMAP_BUFSZ.  
  
Also redefine UTF8_CASEMAP_BUFSZ to include room for a NUL for  
consistency with PG_CASEMAP_BUFSZ.  
  
Use PG_CASEMAP_BUFSZ for the static buffer in ltree/crc32.c.  
  
Remove macros UNICODE_CASEMAP_LEN (which was redundant with  
UNICODE_MAX_CASEMAP_CODEPOINTS from unicode_limits.h), and  
UNICODE_CASEMAP_BUFSZ which was not as descriptive or helpful.  
  
Suggested-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Rithvika Devisetti <devisettirithvika@gmail.com>  
Discussion: https://postgr.es/m/2cfbc37ae8deccd3825e36b7f31c391cbf8ff9b8.camel@j-davis.com  

M contrib/ltree/crc32.c
M src/backend/utils/adt/pg_locale.c
M src/common/unicode/generate-unicode_case_table.pl
M src/include/common/unicode_limits.h
M src/include/utils/pg_locale.h

Fix autovacuum's handling of TOAST storage parameters.

commit   : fad70a09ff43724b521f7e450d894a93d54330a0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 24 Aug 2026 16:28:19 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 24 Aug 2026 16:28:19 -0500    

Click here for diff

The previous commit made VACUUM apply a main table's storage  
parameters to its TOAST table, as CREATE TABLE has long documented.  
Autovacuum still gets this wrong in two ways.  It falls back to the  
main table's autovacuum parameters only when the TOAST table has no  
reloptions at all, so setting a single toast.* parameter silently  
stops the rest from being inherited.  And it never consults the  
main table for the non-autovacuum parameters, such as  
vacuum_index_cleanup and vacuum_truncate.  
  
To fix, combine the two sets with merge_toast_reloptions() rather  
than choosing between them, and hand the main table's parameters  
down to vacuum_rel() the way VACUUM now does.  
pg_stat_autovacuum_scores uses the combined parameters for TOAST  
tables as well; it has to collect the main relations' parameters  
before it can do so, so it now makes a preliminary pass over  
pg_class.  
  
An existing shortcoming that this patch only makes worse is that  
autovacuum remains oblivious to concurrent storage parameter  
changes on the main table.  That is, the main table's parameters  
may be captured long before its TOAST table is processed, and a  
user may very well have altered the settings in the meantime.  
Fixing that would likely require additional pg_class lookups, and  
it's not clear if it's worth the trouble.  
  
While this is a bug fix, it's too intrusive for back-patching, but  
the issue seems to have gone unnoticed for a very long time,  
anyway.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/postmaster/autovacuum.c
M src/test/modules/test_autovacuum/meson.build
A src/test/modules/test_autovacuum/t/002_toast_relopts.pl

Fix VACUUM's handling of TOAST storage parameters.

commit   : c244c62d8b9e7762be3d35090463c76042ab7f89    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 24 Aug 2026 16:28:19 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 24 Aug 2026 16:28:19 -0500    

Click here for diff

Per the documentation for CREATE TABLE:  
  
    If a table parameter value is set and the equivalent toast.  
    parameter is not, the TOAST table will use the table's  
    parameter value.  
  
Presently, VACUUM does no such thing.  It reads the TOAST table's  
own reloptions, which hold only what was set through toast.*, so  
vacuum_index_cleanup, vacuum_max_eager_freeze_failure_rate, and  
vacuum_truncate settings on the main table have no effect on its  
TOAST table.  
  
To fix, add merge_toast_reloptions(), which walks the parse table  
for StdRdOptions and takes the main table's value for anything the  
TOAST table left at its default.  vacuum_rel() hands the main  
table's parameters down when recursing to a TOAST table, and it  
merges them into a copy of the TOAST table's parameters before the  
values are used.  This doesn't help VACUUM against a TOAST table  
directly (e.g., "VACUUM pg_toast.pg_toast_5432"), but that's  
probably okay because it's not the main supported way to vacuum a  
TOAST table (see VACUUM's PROCESS_MAIN and PROCESS_TOAST options).  
  
A follow-up commit will do the same for autovacuum.  While this is  
a bug fix, it's too intrusive for back-patching, but the issue  
seems to have gone unnoticed for a very long time, anyway.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/access/common/reloptions.c
M src/backend/commands/vacuum.c
M src/backend/postmaster/autovacuum.c
M src/include/access/reloptions.h
M src/include/commands/vacuum.h
M src/test/modules/injection_points/expected/vacuum.out
M src/test/modules/injection_points/sql/vacuum.sql

ltree/crc32.c: fix fragile code.

commit   : aea7bed4a755cab63fb667314a735b0ea3e6e688    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 13:33:31 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 13:33:31 -0700    

Click here for diff

Explicitly make space for the NUL when casefolding.  
  
No known bug in the previous code, because the previous buffer (size  
12) was more than large enough for folding any codepoint with enough  
room left for a NUL. The builtin provider's limit is 7; ICU's limit  
seems to be 7 also; and libc always does 1:1 mappings so the real  
limit is MAX_MULTIBYTE_CHAR_LEN + 1 (size 5).  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Rithvika Devisetti <devisettirithvika@gmail.com>  
Discussion: https://postgr.es/m/2cfbc37ae8deccd3825e36b7f31c391cbf8ff9b8.camel@j-davis.com  
Backpatch-through: 18  

M contrib/ltree/crc32.c

pg_locale.c: add explanatory comments.

commit   : 04a20a4a1b02ac12eecde28e441e0a20e5063382    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 11:51:02 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 11:51:02 -0700    

Click here for diff

Explain the purpose of case mapping functions, rather than just the  
API.  
  
Suggested-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/v36ssaygf7grb3qzfsjhtdzi7kqd45ds56nyuf7gi5qjml4qbb@ezmfqzmhlrs2  
Backpatch-through: 18  

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

Add C test function for pg_locale.h APIs.

commit   : 483e9186746ff3403704a23c36fbe4864a88e833    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 11:50:50 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 24 Aug 2026 11:50:50 -0700    

Click here for diff

Test the API independently to account for fallback paths that aren't  
adequately tested from SQL.  
  
The backport to 18 also tests the previously-supported behavior where  
a size of -1 meant that the string was NUL-terminated. That behavior  
was later removed in 19.  
  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/v36ssaygf7grb3qzfsjhtdzi7kqd45ds56nyuf7gi5qjml4qbb@ezmfqzmhlrs2  
Backpatch-through: 18  

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

postgres_fdw: Fix flaky push down FUNCTION RTE test

commit   : 0fd1609afe255b275c2560db6db584081a16e8a0    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 24 Aug 2026 18:50:02 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Mon, 24 Aug 2026 18:50:02 +0300    

Click here for diff

The unnest() test introduced in 0ee83dd4a99 did not produce a  
deterministic EXPLAIN plan output.  
  
The two sides of this test's nested loop join cost about the same, so  
which one ended up as the outer wasn't stable and could flip between  
platforms.  
  
Use an equality predicate on ft1.c3 instead of a range one.  That  
restricts ft1 to a single row, so it's clearly the outer of the nested  
loop and the Materialize on the inner side goes away, giving a stable  
plan.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0uC%3DGOihOKcF7o3JVETF3e-Fkc4OUO5NbqMEKCTeSN-dQ%40mail.gmail.com  

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

Fix untranslatable message that was pasted together at run time

commit   : 29636b49a7ad9f4a19e7d7c3c3003129f96c267b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 24 Aug 2026 14:20:47 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 24 Aug 2026 14:20:47 +0200    

Click here for diff

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

Fix incorrect nmembers calculation in test_bitmapset

commit   : 53a981ed5bbaa8344da88dfa3550e6cfb6ecf3c9    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Mon, 24 Aug 2026 22:43:27 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Mon, 24 Aug 2026 22:43:27 +1200    

Click here for diff

This calculation was failing to correctly account for the min_value when  
calculating how many random members to add to the Bitmapset.  What the  
code was meant to do was add a random number of members between the  
minimum and maximum values.  The code failed to account for the minimum  
value being non-zero, which could result in too many members being added  
to the set, which could reduce the effectiveness of the test.  In reality,  
the only caller to this function did pass 0 as the min_value, so there is  
no live bug being fixed here.  
  
Fix this so that the Bitmapset is more sparsely populated with members  
between the minimum and maximum values.  In passing, swap the order of the  
min_value and max_value parameters.  Having the minimum value appear  
before the maximum value makes more sense.  Also align the names of both  
parameters, and adjust the 'offset' calculation to widen the offset range  
by 1 so that the possible range for that random value is -max_value to  
max_value.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/CAApHDvpfZqdMRmR-6W9UXb+Tanex5wK6PsL=XzYCV4P3pD36Ng@mail.gmail.com  

M src/test/modules/test_bitmapset/expected/test_bitmapset.out
M src/test/modules/test_bitmapset/sql/test_bitmapset.sql
M src/test/modules/test_bitmapset/test_bitmapset.c

Use ArchiveHandle.lookaheadSize instead of a hardcoded 512

commit   : 8646214ee20b3754d69f9d087baa7eeb1b7e1d0b    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 24 Aug 2026 09:46:08 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 24 Aug 2026 09:46:08 +0200    

Click here for diff

_discoverArchiveFormat allocates the lookahead buffer used to identify  
the archive format and records its size in AH->lookaheadSize, but then  
used a hardcoded size in the two plades that need it.  Use the field  
instead, so that the buffer and its size cannot drift apart and risk  
out-of-bound reads.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAJ7c6TPqLZOMk3hPrgLQvrOg9BCY4SV6bUC_wx54fyquRkBckw@mail.gmail.com  

M src/bin/pg_dump/pg_backup_archiver.c

Make stringToNode() infrastructure thread-safe

commit   : 9673a0aa92f4fd75c564e2c8e14d71500a7b55ae    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 24 Aug 2026 12:07:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 24 Aug 2026 12:07:39 +0900    

Click here for diff

While stringToNode() was technically reentrant-safe, this was only for  
single-threaded workloads: the string decoded was stored in a global  
variable.  This may be unsafe depending on the execution model, and  
definitely unsafe in multi-threaded environments.  
  
This patch moves the global variables into a struct (ReadNodeContext),  
whose pointer is passed around on the stack.  Support functions for node  
read, extensible nodes (note: these have never been tested, should be  
tested) and pg_strtok() are updated to handle the context data across  
the call stack.  
  
Code simplifications are mostly in stringToNodeInternal(), that can rely  
on the context structure rather than a save-and-reassign logic based on  
the global variables previously available.  
  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Yuhang Qiu <iamqyh@gmail.com>  
Discussion: https://postgr.es/m/CAEze2WjsGnOM4MB+n1LLdhhUg6r=hwWZRv+-heDE4UtzRdgjyg@mail.gmail.com  

M src/backend/nodes/gen_node_support.pl
M src/backend/nodes/read.c
M src/backend/nodes/readfuncs.c
M src/include/nodes/extensible.h
M src/include/nodes/readfuncs.h
M src/tools/pgindent/typedefs.list

Move some node-read support functions from nodes.h to readfuncs.h

commit   : 89d091f602fa59326d7cdf51e134e5525ef80977    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 24 Aug 2026 10:48:36 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 24 Aug 2026 10:48:36 +0900    

Click here for diff

The functions moved in this commit have been exposed since c1ddd2361f6e,  
and there still seem to be a couple of projects out there that require  
them, as they can be more efficient than nodeRead().  Note that all  
these functions are only called in readfuncs.c in terms of the core  
code.  
  
A follow-up patch plans to improve the in-core support of pg_strtok(),  
making it thread-safe.  This change removes the need to expose internals  
specific to node reads in nodes.h, which is a header with a more general  
purpose than readfuncs.h.  
  
Based on a suggestion by me.  
  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Discussion: https://postgr.es/m/aofW6ntfWJjk_yBL@paquier.xyz  

M src/include/nodes/nodes.h
M src/include/nodes/readfuncs.h

Allow an aggregate's planner support function to be set via CREATE AGGREGATE.

commit   : 8aa49d34e977affb21f3cdbf17661c9c64753f42    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 23 Aug 2026 12:42:55 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 23 Aug 2026 12:42:55 -0400    

Click here for diff

Commit 42473b3b3 implemented SupportRequestSimplifyAggref, but failed  
to think about what infrastructure would be required for an extension  
to use that: there is no SQL-level mechanism for attaching a planner  
support function to an aggregate.  That seems pretty critical for a  
feature that's primarily intended to be used by extensions.  
  
To fix, add a SUPPORT clause to CREATE AGGREGATE, and teach pg_dump  
(and thereby pg_upgrade) about dumping this aggregate property.  
We don't need to touch ALTER AGGREGATE, because it's already the case  
that you're supposed to use CREATE OR REPLACE AGGREGATE if you want  
to alter any aggregate-specific properties set by CREATE AGGREGATE.  
(Maybe at some point we'll think that that policy ought to change,  
but I don't think this one feature moves the needle enough.)  
  
Per report from Andrei Lepikhov, who also provided some of the  
new documentation text.  
  
Reported-by: Andrei Lepikhov <lepihov@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>  
Discussion: https://postgr.es/m/8f58c96d-d3c7-4c0f-9898-116f00eeaff6@gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ref/alter_aggregate.sgml
M doc/src/sgml/ref/create_aggregate.sgml
M doc/src/sgml/xfunc.sgml
M src/backend/catalog/pg_aggregate.c
M src/backend/commands/aggregatecmds.c
M src/bin/pg_dump/pg_dump.c
M src/include/catalog/pg_aggregate.h
M src/test/regress/expected/create_aggregate.out
M src/test/regress/sql/create_aggregate.sql

Fix GIN posting tree page deletion with incomplete splits.

commit   : f20c4278342f6afc44b856e98a0850f9dd2df0a8    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 22 Aug 2026 14:50:40 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 22 Aug 2026 14:50:40 -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
M src/test/modules/gin/Makefile
M src/test/modules/gin/expected/gin_incomplete_splits.out
M src/test/modules/gin/sql/gin_incomplete_splits.sql

Track RI fast-path FK-check batches per subtransaction

commit   : e2c812f1475dc75ab6f8a39fb5696d8d32d05fa1    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Sat, 22 Aug 2026 16:23:21 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Sat, 22 Aug 2026 16:23:21 +0900    

Click here for diff

Commit 4113873 confined RI fast-path batching to the top transaction  
level to avoid mishandling the batch cache on subtransaction abort.  
That disabled batching for a foreign-key load wrapped in a savepoint,  
such as:  
  
  BEGIN; SAVEPOINT s; COPY fk_table FROM ...  
  
This was a surprising performance cliff and departed from the usual  
per-subtransaction resource handling.  
  
Track cache entries per subtransaction instead.  Add AtEOSubXact_RI(),  
called from CommitSubTransaction() and AbortSubTransaction() after  
ResourceOwnerRelease().  On abort, it removes only entries opened by  
the ending subtransaction, whose resources have just been released,  
while leaving entries opened by an outer level intact.  Thus, an inner  
subtransaction abort during outer-level trigger firing does not  
discard the outer statement's batch.  On commit, no matching entry is  
expected because its batch should already have been flushed at  
statement end.  Each entry records the subtransaction that opened its  
resources.  
  
After an abort, the remaining slot storage and per-entry flush contexts  
are reclaimed when TopTransactionContext is reset at top-level  
transaction end.  
  
A fast-path batch is filled and flushed within a single trigger-firing  
cycle, so every row added to an entry must come from the subtransaction  
that created it.  AtEOSubXact_RI() relies on this invariant to identify  
an aborting subtransaction's entries by the subid stamped at entry  
creation.  Assert the invariant in ri_FastPathBatchAdd().  
  
Add regression coverage for batching during nested firing inside a  
subtransaction, both with different constraints and with the same  
constraint at the inner and outer firing levels.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>  
Discussion: https://postgr.es/m/20260705222115.be.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Retire execdebug.h and its debugging facility

commit   : 617636328f5285fa2e0b7e42f4ae3cb0d82f8b5e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 22 Aug 2026 16:23:16 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 22 Aug 2026 16:23:16 +0900    

Click here for diff

execdebug.h includes "pretty old and crufty" code used to print  
debugging information in the executor.  As reported recently, this code  
has not compiled in the last 10 years or so, and there are better  
alternatives available, such as elog().  
  
There is no indication that this facility is still being used, so remove  
it along with its associated debugging macros:  
EXEC_NESTLOOPDEBUG  
EXEC_SORTDEBUG  
EXEC_MERGEJOINDEBUG  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Discussion: https://postgr.es/m/aoFfAvp6xdk7Cdi6@paquier.xyz  

M src/backend/executor/nodeIncrementalSort.c
M src/backend/executor/nodeMergejoin.c
M src/backend/executor/nodeNestloop.c
M src/backend/executor/nodeSort.c
M src/backend/jit/llvm/llvmjit_expr.c
D src/include/executor/execdebug.h

Doc: fix typo

commit   : e42f1d0f1be811511e305bba44b29b08073a705d    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Sat, 22 Aug 2026 12:48:44 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Sat, 22 Aug 2026 12:48:44 +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

Fix failing Memoize test on 32-bit machines

commit   : 7788fcf39bf98c3403f052f3edd73d86fe1501a7    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Sat, 22 Aug 2026 11:38:30 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Sat, 22 Aug 2026 11:38:30 +1200    

Click here for diff

609f969f6 reduced memory overheads for storing a tuple in Memoize.  That  
resulted in a Memoize eviction test no longer evicting anything from the  
cache on 32-bit machines.  
  
Here we fix that by adding another column to store in the cached  
MinimalTuple.  
  
Reported-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/aof8KwoXaqOBFR_D@paquier.xyz  

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

Fix typo.

commit   : 4b6aa98429702fc5242326cd40f000c40ca5ae98    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 21 Aug 2026 14:45:03 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 21 Aug 2026 14:45:03 -0500    

Click here for diff

Oversight in commit 40af05bb61.  

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

Move the StdRdOptions parse table to file scope.

commit   : 4ee79f3b464f97999caa44624f393199a69850a5    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 21 Aug 2026 13:43:15 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 21 Aug 2026 13:43:15 -0500    

Click here for diff

This is preparatory work for a follow-up commit that will walk the  
table from another function.  This just moves code around; it  
shouldn't change any behavior.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/access/common/reloptions.c

Ensure TOAST storage parameters have unsettable defaults.

commit   : 63979e5bea14c533dadc8f44cee0ec7a2899ccf5    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 21 Aug 2026 11:50:39 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 21 Aug 2026 11:50:39 -0500    

Click here for diff

A follow-up commit will teach autovacuum and manual VACUUM to fill  
in a TOAST table's unset storage parameters from its main table's.  
To be able to determine whether a parameter is set, it must default  
to a value that users cannot set.  Of all the parameters that can  
be set on TOAST tables, log_autovacuum_min_duration is the only one  
that violates this rule.  This commit changes its default to -2 so  
that we can tell whether it is set.  This shouldn't produce any  
user-visible behavior changes.  
  
While at it, add assertions to ensure all storage parameters that  
can be set on TOAST tables continue to follow this rule.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/access/common/reloptions.c
M src/backend/postmaster/autovacuum.c

Fix error code for null FOR PORTION OF target

commit   : c16a1b4f2ce8e88ec40d1465c01e327ab8721524    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 21 Aug 2026 13:55:58 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 21 Aug 2026 13:55:58 +0200    

Click here for diff

When the target expression of FOR PORTION OF (...) evaluated to NULL,  
ExecInitModifyTable raised an error without an errcode, so clients got  
the internal error code XX000 for a user-reachable condition.  
Oversight in commit 8e72d914c52.  
  
To fix, report ERRCODE_NULL_VALUE_NOT_ALLOWED, and reword the message  
to "FOR PORTION OF target must not be null", matching similar executor  
messages such as "frame starting offset must not be null".  
  
Bug: #19630  
Reported-by: Zheng Wang <hackerzheng666@gmail.com>  
Reported-by: Yanjie Zhao  
Reported-by: Yiyang Liu  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://www.postgresql.org/message-id/flat/19630-9f10ca28426295fa%40postgresql.org  

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

Fix typos in comments.

commit   : a1bb92fb250a7ff94a13a0e7ac784f88ccc0c402    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 21 Aug 2026 17:50:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 21 Aug 2026 17:50:00 +0900    

Click here for diff

Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CAPmGK14otpa7XZyBO5GxDABUK9OPWFLsAwoQP3ugNdXq%3DK4J1g%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c

Use pg_parse_lsn() for server-supplied LSNs

commit   : f31d6fbc31d3b6901022e011942ac680d347d46a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 21 Aug 2026 16:33:36 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 21 Aug 2026 16:33:36 +0900    

Click here for diff

Commit d6bf0ab170 introduced pg_parse_lsn() to validate LSNs given on  
the command line of pg_waldump, pg_recvlogical, and pg_receivewal.  
The remaining sscanf("%X/%08X") call sites under src/bin parse LSNs  
that arrive in server responses, timeline history files, and  
backup_label files.  sscanf() accepts several forms that pg_lsn input  
rejects and can silently continue with a different location than the  
input text: a first component wider than eight hex digits wraps  
around, a wider second component is truncated, and leading  
whitespace, signs, "0x" prefixes, and trailing characters are  
consumed or ignored.  
  
Convert those call sites as well.  The two call sites that read a  
location out of a longer line isolate it by temporarily terminating  
the string at the next whitespace character, so that they can use  
pg_parse_lsn() like the others.  Each tool keeps its existing error  
message.  
  
Malformed metadata now fails with each tool's existing error instead  
of silently proceeding with a different location.  Two error paths  
shift: pg_rewind's history-file parser now rejects trailing  
characters attached to a switchpoint, which used to be ignored, and a  
malformed backup_label location now fails pg_combinebackup's "could  
not parse" check rather than its "improper terminator" check.  
  
Author: Zexin Li <lizi.openmind@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAAP6ZkS_3OH3yhhAGK6vu+2V1C2Hv4K6SpRuZL415R-gxjdTSg@mail.gmail.com  

M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_basebackup/receivelog.c
M src/bin/pg_basebackup/streamutil.c
M src/bin/pg_combinebackup/backup_label.c
M src/bin/pg_rewind/libpq_source.c
M src/bin/pg_rewind/timeline.c

Collect quals for outer-join reduction on demand

commit   : 31c002aa89787e4bbe237e36f51dead96b674998    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 21 Aug 2026 15:51:57 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 21 Aug 2026 15:51:57 +0900    

Click here for diff

To prove that a forced-null Var is non-nullable in every matching row,  
reduce_outer_joins() uses the strict quals that hold for every row a  
subtree emits.  The first pass currently gathers those quals into each  
subtree's state, so that the second pass need not re-walk the jointree  
at decision time.  
  
That duplicates find_subquery_safe_quals(), which already performs  
this traversal for query_outputs_are_not_nullable(), and it charges  
every query containing an outer join for a list build at every  
FromExpr and every inner or semi join, whether or not any upper qual  
turns out to force a Var null.  Since each level copies what its  
children collected, the space required grows quadratically with the  
depth of nested inner joins.  What it buys is small even then: the  
walk it avoids is cheap enough to be called on demand.  
  
So rename find_subquery_safe_quals() to find_safe_quals(), export it,  
and drop safe_quals from the first pass's state in favor of the  
subtree's jointree node.  The second pass calls find_safe_quals() at  
the point where it needs the proof.  
  
Also stop treating a semijoin there like a left join: semijoins are  
reachable from the new caller, and a semijoin emits only matched  
left-hand rows, so its ON quals do hold for every output row.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs4-6FazY7+vCOvR0-vqNuaXOZic8O4D4ZrwMm2woi+Q3uA@mail.gmail.com  

M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/util/clauses.c
M src/include/optimizer/clauses.h

psql: Do not let invalid \getresults affect the next query

commit   : d2ba580475ce5af8e5d07b922964e6206333af2c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 21 Aug 2026 12:36:01 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 21 Aug 2026 12:36:01 +0900    

Click here for diff

In pipeline mode, an invalid \getresults argument could previously  
affect the next SQL command in the same pipeline. For example, after  
reporting an error for \getresults -1, psql could treat the following  
SQL command as a request to read pending pipeline results instead of  
sending it to the server, making the command appear to be skipped or  
causing missing results.  
  
This happened because psql marked \getresults as a request to read  
pipeline results before validating its optional argument. When  
validation failed, psql reported the error without running the normal  
cleanup path that clears the request.  
  
Fix this by validating the \getresults argument before marking the  
command as a request to read pipeline results. After an invalid  
argument, psql now reports the error and sends the following SQL command  
normally.  
  
Backpatch to v18, where psql pipeline meta-commands were introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>  
Discussion: https://postgr.es/m/CAHGQGwGkgM2HKZeig5hobEgUCjn7MMJux4UCcN=OfOzOEvRT0A@mail.gmail.com  
Backpatch-through: 18  

M src/bin/psql/command.c
M src/test/regress/expected/psql_pipeline.out
M src/test/regress/sql/psql_pipeline.sql

Reduce memory overheads for storing a Memoize tuple

commit   : 609f969f61bbe0cab817a12c4b9f2c1c0fa3297f    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 21 Aug 2026 14:50:18 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 21 Aug 2026 14:50:18 +1200    

Click here for diff

This uses 16 fewer bytes per tuple stored in each MemoizeEntry.  24 bytes  
can be saved by not doing palloc_object(MemoizeTuple), and instead we  
can store the pointer to the next tuple by requesting that  
ExecCopySlotMinimalTupleExtra() allocate an extra 8 bytes per  
MinimalTuple, a net saving of 16 bytes per cached tuple, which equates  
to 33% less memory in the most extreme case (assuming very few entries  
with many tuples and the narrowest possible MinimalTuple).  Real-world  
cases will save less, as we're not saving anything on the MemoizeEntry  
itself, only tuples stored within it.  
  
Saving memory in Memoize allows more entries to exist concurrently and  
reduces the chances that an entry will be evicted from the cache due to  
memory pressure.  That increases the chances of getting cache hits.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvoNurQzpR2nZ4aLq1v_4gstsSdimZP-m34PMTBPptn+zQ@mail.gmail.com  

M src/backend/executor/nodeMemoize.c
M src/include/nodes/execnodes.h
M src/tools/pgindent/typedefs.list

doc: fix wording in SELECT docs

commit   : e5aff2aa63a72e4329405dd1404c184f7d439107    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 20 Aug 2026 21:35:26 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 20 Aug 2026 21:35:26 -0400    

Click here for diff

Reported-by: Garry Polley  
  
Author: Garry Polley  
  
Discussion: https://postgr.es/m/CAPj_C4wRh_JSi_RSFZLPUDVoVeOjFhos5RG+DggtK38wzakjEQ@mail.gmail.com  
  
Backpatch-through: master  

M doc/src/sgml/ref/select.sgml

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

commit   : 1c41ebf22fd43f335ae1dfbecfe6a8c6d81c5f40    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 21 Aug 2026 12:25:46 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 21 Aug 2026 12:25:46 +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   : 0ebeec35fc3c3bf617ac447b36f1b158b076f6e7    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 20 Aug 2026 19:47:32 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 20 Aug 2026 19:47:32 -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

ecpg: Add missing NULL check in ecpg_store_input() following OOM failure

commit   : c83f7e727f20a680a5bb874e2e4d699a0f3ee68f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Aug 2026 08:28:07 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Aug 2026 08:28:07 +0900    

Click here for diff

ecpg_store_input() called strlen() directly on the result of  
PGTYPESnumeric_to_asc() without checking for a NULL value, state  
possible when the function fails due to an out-of-memory failure.  
  
This error is unlikely going to be hit in practice, so no backpatch is  
done.  
  
Author: Gladyshev Ilya <ilya.gladyshev@linux.dev>  
Discussion: https://postgr.es/m/ed5a633b469e685f3a1aef9982cff8e1c50e5883@linux.dev  

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

Improve error for RETURNING with system columns under rules

commit   : d39762b8c79a8a825be4af0a22b048a18483afa3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Aug 2026 07:51:16 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Aug 2026 07:51:16 +0900    

Click here for diff

When a DML query's RETURNING list references the system column of a  
target table, and the query was rewritten by a rule with its own  
RETURNING clause, ReplaceVarsFromTargetList() failed with an internal  
error "could not find replacement targetlist entry for attno -1",  
since the rule's RETURNING list only has entries for user columns.  
  
Such queries cannot work: the rewritten query need not scan the original  
target relation at all, so a rule's RETURNING list has no way to provide  
values for that relation's system columns.  
  
This is a life improvement change as the error reported is just more  
relevant for the user and this has never worked since RETURNING is  
reported.  No backpatch is done, based on the lack of complaints over  
the ages.  
  
Reported-by: Zheng Wang <hackerzheng666@gmail.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/19632-9155d9baec763c8c@postgresql.org  

M src/backend/rewrite/rewriteManip.c
M src/test/regress/expected/returning.out
M src/test/regress/sql/returning.sql

test_aio: Fix broken error recovery assertions in 001_aio

commit   : 9d23f862d60854d797dcab40f46b21aff45d4db5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Aug 2026 07:05:08 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 21 Aug 2026 07:05:08 +0900    

Click here for diff

The three error recovery checks in `test_handle()` used "qr/^|ok$/" to  
look for the marker "ok" in psql's output.  '^' matches every string, so  
the assertions passed no matter what psql printed.  
  
Spelling the regex correctly as "qr/^ok\|$/" exposed that the explicit  
xact case was actually failing, reporting an incorrect "current  
transaction is aborted" instead of showing that an AIO handle can be  
acquired again after an error.  This is rewritten with a ROLLBACK,  
similarly to the subxact counterpart.  
  
While on it, the subxact case had no marker column in its query, so add  
one there for consistency, and reformat to use same pattern.  
  
Author: Jelte Fennema-Nio <me@jeltef.nl>  
Discussion: https://postgr.es/m/DKSU6GI1YLG5.3VF6M4IRKQ7XE@jeltef.nl  
Backpatch-through: 18  

M src/test/modules/test_aio/t/001_aio.pl

hashtext: fix fragile code.

commit   : aa655f88f71bc747083a4c7e04b6294ff6d19da6    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Thu, 20 Aug 2026 13:54:56 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Thu, 20 Aug 2026 13:54:56 -0700    

Click here for diff

Previously, in the path for non-deterministic collations, the code  
assumed that bsize==rsize. That assumption seems to be true for ICU,  
and all non-deterministic collations are ICU, so it's not known to be  
an actual bug.  
  
The only known place where bsize may not equal rsize is in the libc  
provider, where strxfrm() can return an upper bound of the size needed  
to store the result. That means the initial call to determine the  
buffer size (with dest==NULL, n==0) could return a larger number than  
the actual call with an adequate dest buffer. That's OK, because libc  
locales are always deterministic.  
  
Commit 679c5084cf2 partially fixed the assumption, but missed this  
part. Fix it, and add a more prominent documentation note.  
  
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>  
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com  
Backpatch-through: 16  

M src/backend/access/hash/hashfunc.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/pg_locale_libc.c
M src/backend/utils/adt/varchar.c

Simplify autovacuum's TOAST-to-main-relation reloptions map.

commit   : 81920f24a47e9580af8e25a72f6b5b660b69fee1    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 20 Aug 2026 15:56:19 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 20 Aug 2026 15:56:19 -0500    

Click here for diff

The ar_relid and ar_hasrelopts members of the av_relation struct  
can be removed.  ar_relid isn't used by anything, and we only need  
ar_hasrelopts because we add an entry to the map even when the main  
table has no reloptions set.  If we instead only add entries for  
tables with reloptions set, we can take the presence of an entry to  
mean the main table has some.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Tested-by: Greg Burd <greg@burd.me>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/postmaster/autovacuum.c

doc: change "allowed in->on the standby server."

commit   : ae78826476499aa5e155cd1bc030e89fdd063edf    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 20 Aug 2026 15:32:55 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 20 Aug 2026 15:32:55 -0400    

Click here for diff

Reported-by: phamnguyenducduong@gmail.com  
  
Backpatch-through: master  

M doc/src/sgml/config.sgml

Micro-optimize appendStringInfo[VA].

commit   : 38337ee639b1825597dee8cc02cc9c0aaa83feb1    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 13:01:28 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 13:01:28 -0400    

Click here for diff

In the loop in appendStringInfo, avoid a useless assignment to  
errno during the first (and usually only) iteration.  This  
might make a noticeable difference depending on how efficiently  
the platform deals with thread-local variables.  
  
Try to make the compiler inline appendStringInfoVA into  
appendStringInfo.  
  
Instead of having appendStringInfoVA go through pvsnprintf, make  
it call vsnprintf directly.  pvsnprintf adds little except an  
int-versus-size_t impedance mismatch.  We do have to duplicate its  
error handling for the nprinted < 0 case, but we don't need to  
duplicate its check for MaxAllocSize overrun, because  
enlargeStringInfo can handle that just as easily.  Also, its  
insistence on adding one to nprinted is not needed here, since  
enlargeStringInfo expects the number of data bytes to add.  
  
In combination, these changes seem to about halve the penalty for  
going through appendStringInfo rather than directly to snprintf.c.  
This is enough to buy back the performance loss incurred in  
formatting.c by the preceding three patches, and even a little more.  
It should help other usages too.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/3451175.1786641871@sss.pgh.pa.us  

M src/common/stringinfo.c

Replace formatting.c's fixed-size output buffers with StringInfos.

commit   : ec352b37d88a12f0256526ff0a51bd86d587d604    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 12:57:25 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 12:57:25 -0400    

Click here for diff

In both versions of NUM_processor(), use a StringInfo for the  
output string, eliminating the need to guess an upper bound  
for the output length, and removing the need to truncate some  
strings of unpredictable length.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/3451175.1786641871@sss.pgh.pa.us  

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

Restructure formatting.c's NUM_processor() to add some const-sanity.

commit   : 28c5d0724875591ff55dd85a065207badc2fa8ad    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 12:55:13 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 12:55:13 -0400    

Click here for diff

NUM_processor() is an under-documented mess.  Depending on the value  
of is_to_char, it either reads "inout" and writes "number", or  
the other way around.  That makes it impossible to label either  
string "const", which seems like a minimum expectation in 2026.  
It also complicates replacing the output buffer with a StringInfo:  
we'd have to convert both strings, which is pretty pointless for  
the input side.  
  
Moreover, we're buying very little code savings by doing it like this,  
since a large majority of the function's code has to be wrapped inside  
"if (is_to_char)" tests.  
  
To fix, split the function into NUM_processor_from_char() and  
NUM_processor_to_char(), and rename/const-ify arguments as  
appropriate.  Both paths now read from "const char *input"  
and write to "char *output".  
  
This patch doesn't intend to make any algorithmic changes, it's  
just mechanical code rearrangement and symbol renaming.  The  
only real exception is that I got rid of passing "input_len"  
to NUM_processor_from_char()'s subroutines in favor of storing  
"const char *input_end" in NUMProc.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/3451175.1786641871@sss.pgh.pa.us  

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

Convert DCH_to_char() to use a StringInfo as destination.

commit   : 03d2554638cb5c95819e1e720e15672630a3cbdd    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 12:52:06 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 12:52:06 -0400    

Click here for diff

Formerly, we allocated an output char array with 12 bytes per  
byte of the format string.  That's usually far more than enough,  
and yet we had to add assorted code to defend against cases where  
it isn't enough.  Switch to using a StringInfo expansible buffer  
instead.  This is considerably more robust, shortens the code  
noticeably, and eliminates various edge-case failure conditions.  
  
While at it, const-ify some parameters that can be const.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/3451175.1786641871@sss.pgh.pa.us  

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

Ensure all pg_locale.h APIs work with collate_is_c.

commit   : bdb82ec8c24184844d561e2c76ef02cc1b551213    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Thu, 20 Aug 2026 09:25:34 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Thu, 20 Aug 2026 09:25:34 -0700    

Click here for diff

Safer for callers, so that checking collate_is_c is only needed if the  
caller wants to optimize for that case.  
  
Backpatch to avoid creating a hazard for other backpatches in this  
area.  
  
Suggested-by: Andres Freund <andres@anarazel.de>  
Suggested-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/v36ssaygf7grb3qzfsjhtdzi7kqd45ds56nyuf7gi5qjml4qbb@ezmfqzmhlrs2  
Backpatch-through: 18  

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

Rewrite tsqueryout() to use StringInfo to build the output string.

commit   : 2ecbc5e021be2cad14f837539b1661dd0c870c07    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 11:36:17 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 11:36:17 -0400    

Click here for diff

This patch started with noticing that tsquery.c's infix() function  
uselessly multiplies the length of each operand string by  
pg_database_encoding_max_length() + 1, where multiplying by 2  
would be sufficient.  Unlike the related thinko in tsvectorout(),  
this doesn't seem to risk integer overflow, since we're multiplying  
only a rather short per-operand length.  Still, it's incorrect and  
misleading.  
  
However, I then started to question why tsqueryout() is using a  
hand-rolled implementation of an expansible string buffer in the  
first place.  Replacing that by using the StringInfo infrastructure  
would make the code noticeably shorter and eliminate not only this  
mistake but a bunch of other mistake-prone arithmetic.  It might  
even be faster, given that we've spent effort on micro-optimizing  
StringInfos; but even if it's slower, it's hard to visualize a  
workload where tsqueryout() is a performance bottleneck.  So  
that's what this patch does.  
  
I also got rid of the overly-creative approach of deparsing a  
binary operator's right operand into a separate buffer, then  
deparsing the left operand into the main output buffer, then  
copying the right operand's text back to the main buffer.  
(Why the operands are stored in reverse order in the first place  
seems lost in the mists of time, but I suppose we're stuck with  
that choice.)  We can easily emit the desired text in-order by  
moving the "curpol" next-item pointer around.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/3428771.1786635967@sss.pgh.pa.us  

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

Remove redundant SvOK() tests in plperl.

commit   : 41868e8aaa6cfff63b1c8010e1356e01d86a1326    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 11:26:11 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 20 Aug 2026 11:26:11 -0400    

Click here for diff

I noticed that some places in our code test "SvOK(sv) && SvROK(sv)"  
while others check just SvROK(sv).  On investigation, it's clear  
that SvROK implies SvOK so testing both is pointless.  While removing  
these extra checks seems very unlikely to make any performance  
difference, it does make the code more consistent and intelligible.  
  
Also mop up a couple of places where there wasn't a null-pointer  
check before a SvOK() test.  I think these are unreachable cases,  
but in the name of consistency let's do it the same everywhere.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Discussion: https://postgr.es/m/2034677.1787172042@sss.pgh.pa.us  

M src/pl/plperl/plperl.c

Skip bogus find_composite_type_dependencies() call on sequences

commit   : d78040a469b8439bc4ce234477e4c5bd381e6608    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 20 Aug 2026 11:45:51 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 20 Aug 2026 11:45:51 +0300    

Click here for diff

A sequence has no rowtype.  We called  
find_composite_type_dependencies() with InvalidOid, which is harmless  
but pointless.  Skip it.  
  
This started to happen with commit 344d62fb9a97 in v15, which added  
the ALTER SEQUENCE ... SET LOGGED/UNLOGGED subcommand.  Before that,  
sequences were never rewritten.  While this is harmless, backpatch to  
keep the code the same on all branches, to make backpatching future  
patches a little easier.  
  
Backpatch-through: 15  

M src/backend/commands/tablecmds.c

Track RI fast-path FK-check batches per firing cycle

commit   : 6fc2a486417d07f45ad47bc70d90a18902c304e5    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 20 Aug 2026 17:12:39 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 20 Aug 2026 17:12:39 +0900    

Click here for diff

Commit 34a30786293 fixed an RI fast-path crash under nested C-level SPI  
by keeping batch-callback lists per after-trigger query depth.  That fix  
was incomplete: the RI fast path still tracked callback registration  
with one global flag.  Once an outer firing cycle had registered its  
callback, the flag suppressed registration for a nested cycle, leaving  
the nested batch to be handled by the outer callback, too late and with  
the wrong snapshot, potentially after the ResourceOwner holding its  
relations had gone away.  
  
Nor is per-depth callback registration sufficient while the cache is  
keyed only by constraint OID.  If nested firing checks the same  
constraint, it reuses the outer entry, combining rows that must be  
checked in separate firing cycles.  
  
Key the cache by both constraint OID and query depth.  Register a callback  
for each depth that creates an entry, and make ri_FastPathEndBatch() flush  
and release only entries belonging to the ending depth.  Add  
AfterTriggerCurrentQueryDepth() so ri_triggers.c can obtain the current  
depth; depth -1 represents deferred firing.  
  
Add regression coverage for nested firing through a cursor portal, whose  
resources must not outlive the nested cycle, nested firing of the same  
constraint at different query depths, and deferred firing at query depth  
-1.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/20260705222115.be.noahmisch@microsoft.com  
Discussion: https://postgr.es/m/CAH2-Wz=D533JbF_ak_Pc8kP0FKse-ju8DnMxtjvY==yHsP4xgw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/trigger.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
M src/tools/pgindent/typedefs.list

Unify error messages

commit   : c36a0df195dca72112c558454bf56916a4842c10    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 20 Aug 2026 08:53:57 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 20 Aug 2026 08:53:57 +0200    

Click here for diff

and some small style improvements  

M src/backend/commands/explain_state.c
M src/backend/commands/subscriptioncmds.c
M src/backend/commands/wait.c
M src/test/regress/expected/subscription.out

Fix postmaster failing to exit when startup crashes during crash restart

commit   : ead8f696b7cd013c0825ee98761a9cea28d73715    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Aug 2026 15:17:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Aug 2026 15:17:26 +0900    

Click here for diff

Commit 9b43e6793b0f removed the PM_STARTUP shortcut that exited the  
postmaster directly when the startup process died, routing the case  
through HandleChildCrash() so that children processes running during  
PM_STARTUP are cleaned up rather than orphaned.  
  
However, HandleChildCrash() does nothing if FatalError is already set,  
and that is exactly the case while reinitializing after a crash: a  
relaunched startup process that dies before WAL redo starts would leave  
the state machine stuck at PM_STARTUP, preventing the postmaster to shut  
down.  
  
This issue is fixed by restoring the pre-9b43e6793b0f shortcut behavior:  
if FatalError is set when the startup process crashes, signal the  
remaining children and move to PM_NO_CHILDREN, so as the postmaster can  
properly exit with nothing orphaned.  This is only reachable in v18 and  
newer versions, the early return of HandleChildCrash() on FatalError  
being introduced in f0b7ab725139.  
  
This issue has been reported on Windows, for a postmaster with its  
console gone.  A trick to make InitPostmasterChild() fail aggressively  
was equally able to stuck a postmaster.  
  
Reported-by: Kuan-Ting Kuo <m0935388420@gmail.com>  
Author: Zexin Li <lizi.openmind@gmail.com>  
Discussion: https://postgr.es/m/19623-f9bd331940be1273@postgresql.org  
Backpatch-through: 18  

M src/backend/postmaster/postmaster.c

Restore after-trigger firing context at subtransaction end

commit   : 785dd853b6ccd4556de34a5fc5c984cff233e737    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Thu, 20 Aug 2026 14:02:51 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Thu, 20 Aug 2026 14:02:51 +0900    

Click here for diff

AfterTriggerEndQuery(), AfterTriggerFireDeferred(), and  
AfterTriggerSetState() bracket their firing loops with  
firing_depth++/--.  The decrement runs after the loop and is not  
protected by PG_FINALLY, so an error caught by a subtransaction (e.g. a  
PL/pgSQL EXCEPTION block) leaves firing_depth too high.  Separately,  
AfterTriggerEndSubXact() unconditionally cleared  
firing_batch_callbacks, even if the subtransaction began while an outer  
batch-callback loop was active.  
  
firing_depth feeds AfterTriggerIsActive(), which the RI fast path uses  
to decide whether an FK check is running inside trigger firing and may  
batch.  A stranded firing_depth makes AfterTriggerIsActive() wrongly  
report firing as active afterwards.  This is reachable and results in  
silent data corruption: after a caught FK-check error, an ALTER TABLE ...  
ADD FOREIGN KEY whose validation runs per-row (RI_Initial_Check() having  
bailed, e.g. because RLS is enabled on the referenced table) calls  
RI_FKey_check() with AfterTriggerIsActive() wrongly true.  The check is  
routed into the batched fast path, but a utility command has no  
AfterTriggerEndQuery() to fire the flush callback.  The violating row is  
not reported, the constraint is marked validated, and the cached PK  
relation and index leak.  
  
Save firing_depth and firing_batch_callbacks at subtransaction start and  
restore them in AfterTriggerEndSubXact(), next to the existing query_depth  
handling.  Restoring, rather than zeroing or clearing, is required because  
a subtransaction can begin and end while an outer query is firing, where  
firing_depth is legitimately positive and firing_batch_callbacks may be  
legitimately set.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260705222115.be.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Reject too many arguments in CREATE TRIGGER

commit   : b99b74144f9f37f39c38ca43b94a5ad46bb24a43    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Aug 2026 09:38:23 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 20 Aug 2026 09:38:23 +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   : cb217c4f174f487009bcba3812bbf23b8d8eba4c    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 15:45:56 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 15:45:56 -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
M src/include/access/gist_private.h

Support tied Perl objects in plperl and associated contrib modules.

commit   : ccab6d36d0cbe554c380f69ade1598a41c06552a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Aug 2026 14:06:52 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Aug 2026 14:06:52 -0400    

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.  
  
Arguably this is a bug fix, but in view of the lack of field  
complaints to date, let's treat it as a new feature instead.  
The risk/reward ratio for back-patching isn't attractive.  
  
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  

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/meson.build
M src/pl/plperl/plperl.c
M src/pl/plperl/plperl.h
A src/pl/plperl/sql/plperl_tied.sql

Fix GIN multiple-VACUUM-scans pending list bug.

commit   : 8637383f5ff1cb7eefd0f9ea4e3da81a70ca206b    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 13:46:45 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 13:46:45 -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   : a13cdbd3d8b628b49219f70be2772230d36fa565    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 12:31:09 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 19 Aug 2026 12:31:09 -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

Fix compilation warning in 0ee83dd4a994

commit   : 9716f88ddf6b468d191a93e5f9fea1c6f98cc1d1    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 19 Aug 2026 17:30:48 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 19 Aug 2026 17:30:48 +0300    

Click here for diff

Discussion: https://postgr.es/m/CAO6_XqrGH2NRe0oFx_00nLXra1UZezd3jbS9pgoRhZtgzHD9gg%40mail.gmail.com  
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>  
Reviewed-by: Alexander Pyhalov <a.pyhalov@postgrespro.ru>  

M contrib/postgres_fdw/postgres_fdw.c

postgres_fdw: push down FUNCTION RTE into foreign joins

commit   : 0ee83dd4a9940883b5241fc9c80fd27f63f2e47f    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 19 Aug 2026 13:29:47 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 19 Aug 2026 13:29:47 +0300    

Click here for diff

A foreign join planning hook now considers a (foreign-table x function-RTE)  
INNER join as a push-down candidate when the function expression is  
IMMUTABLE and otherwise shippable.  The remote query absorbs the function  
call as a FROM-list item (e.g. unnest(...) AS f<rti>(c1, c2, ...)), so the  
foreign side returns only rows that match the function-produced set and the  
join executes entirely on the remote.  
  
An IMMUTABLE function gives the same result on any server, so the same  
function RTE can be a push-down candidate for several distinct foreign  
servers without semantic risk.  To keep the planner state consistent  
across those independent attempts, the per-call stub fpinfo for the  
function side lives on the joinrel's PgFdwRelationInfo (new  
outer_func_fpinfo / inner_func_fpinfo), never on the function rel itself,  
and the function side is detected via rtekind rather than fdw_private.  
  
set_foreign_rel_properties() propagates fdwroutine onto a joinrel that  
pairs a foreign rel with an RTE_FUNCTION rel so GetForeignJoinPaths gets  
called; the FDW retains full control over whether to actually generate a  
path.  deparseRangeTblRef and deparseColumnRef gain a FUNCTION-RTE branch  
that emits the function expression and resolves Vars to the generated  
column aliases.  
  
Discussion: https://postgr.es/m/e3af56f9b2f1bd9fdf12aff6ca25b18d%40postgrespro.ru  
Author: Alexander Pyhalov <a.pyhalov@postgrespro.ru>  
Reviewed-by: Solaimurugan Vellaipandiyan <drsolaimurugan.v@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  

M contrib/postgres_fdw/deparse.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/postgres_fdw.h
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/postgres-fdw.sgml
M src/backend/optimizer/util/relnode.c

Tighten ACL check in repack_is_permitted_for_relation()

commit   : e13851080ce16acb6f1c7307512dbd48cd4930dd    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 19 Aug 2026 12:25:06 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 19 Aug 2026 12:25:06 +0200    

Click here for diff

repack_is_permitted_for_relation() uses pg_class_aclcheck_ext()  
to silently skip a concurrently-dropped relation.  That's wrong  
for a caller that may already hold a lock on the relation whose  
ACL is checked, where missing a relation is not fine, and it  
makes the single-relation REPACK and CLUSTER cases more brittle.  
So only detect a missing relation where that's expected,  
following the fix for vacuum_is_permitted_for_relation() in  
commit 824d5f6241ea.  
  
The new already_locked behavior is limited to get_tables_to_repack()  
and get_tables_to_repack_partitioned().  All other callers of  
repack_is_permitted_for_relation() hold a lock on the relation  
that prevents it from being concurrently dropped, so this commit  
also adds an assertion to that effect.  
  
While at it, update the comment in RangeVarCallbackMaintainsTable to  
also mention REPACK.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Backpatch-through: 19  
Discussion: https://www.postgresql.org/message-id/CALj2ACX3pyuRS8%2B%2B6L20cJUMRTf_qbbVp69J1btJ3y6%3D77e5gw%40mail.gmail.com  

M src/backend/commands/repack.c
M src/backend/commands/tablecmds.c

Give RI fast-path cached FmgrInfos their own memory context

commit   : 590b8e89a53a4637b07cf5f4ccb290d4c29ec3b7    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Wed, 19 Aug 2026 16:10:18 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Wed, 19 Aug 2026 16:10:18 +0900    

Click here for diff

ri_populate_fastpath_metadata() copies the cast and equality FmgrInfos  
into the cached FastPathMeta with fn_mcxt set to TopMemoryContext, the  
context active at the copy.  fn_mcxt is scratch space for the called  
function: record_eq(), and the record I/O functions generally, allocate  
their per-call cache there and keep a pointer to it in fn_extra.  
  
Because that scratch is in TopMemoryContext, it outlives the metadata.  
When the metadata is discarded on invalidation, whatever the cast and  
equality functions cached is left behind, with nothing pointing at it.  
Each subsequent repopulation allocates afresh, so a session that  
repeatedly invalidates a foreign key constraint grows TopMemoryContext  
without bound.  
  
Give the metadata its own context for the FmgrInfos' fn_mcxt and delete  
it along with the metadata, so the cached scratch is freed with the  
FmgrInfos that point at it.  Since the preceding commit defers release  
of the metadata to AtEOXact_RI(), the context is deleted there rather  
than in InvalidateConstraintCacheCallBack().  
  
The context deliberately is not reset while the metadata is in use.  
fn_extra points into fn_mcxt, so resetting it would leave those  
pointers dangling; the next call would find fn_extra non-NULL and read  
freed memory.  fmgr_info_copy() zeroing fn_extra in the copy is the  
same invariant seen from the other side.  Nothing accumulates in the  
context during use in any case: record_eq() and friends allocate only  
when fn_extra is NULL and reuse the cache afterwards.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch@microsoft.com  
Discussion: https://postgr.es/m/CA+HiwqFFB6vzx8v3t2=rbNYyxMistLf5kkJfqzJ81nadFyLrxA@mail.gmail.com  
Backpatch-through: 19  

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

Don't free fast-path FK metadata from the inval callback

commit   : 170c9344defaefb351a9dbd0134f4c37a9847358    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Wed, 19 Aug 2026 16:06:00 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Wed, 19 Aug 2026 16:06:00 +0900    

Click here for diff

Commit e484b0eea6 made InvalidateConstraintCacheCallBack() pfree an  
entry's FastPathMeta to plug a leak, but that breaks the rule stated  
atop the callback: entries may have active references at invalidation  
time, so we mark them invalid rather than removing them.  
  
The metadata is subject to the same rule.  ri_FastPathCheck() and  
ri_FastPathBatchFlush() copy riinfo->fpmeta into a local, and  
ri_FastPathFlushArray() additionally takes FmgrInfo pointers into it  
before its "walk all matches" loop.  That loop runs  
index_getnext_slot(), ri_LockPKTuple(), and user-supplied cast and  
equality functions, any of which can accept invalidation messages, and  
a user function that performs DDL triggers one deliberately, no  
concurrency required.  The callback then freed the object still in use,  
so the loop read freed memory and called through FmgrInfos in it.  
  
Fix by unlinking the metadata from the entry, so the next check  
rebuilds it as before, but deferring the actual free to AtEOXact_RI(),  
which runs from CommitTransaction() / PrepareTransaction() /  
AbortTransaction() with no RI check on the stack.  Detached objects  
are chained through a new next_dead field and released there.  
  
The queue holds a few kB per detached object until the transaction  
ends, which only affects transactions that interleave DDL with  
FK-checking DML. That seems clearly preferable to a use-after-free.  
  
Unlinking alone is not enough for the multi-column path.  
ri_FastPathFlushLoop() calls build_index_scankeys() once per buffered  
row, and that function re-read riinfo->fpmeta each time.  A cast  
invoked for one row can accept an invalidation that clears the field,  
so the next row found NULL there.  Pass the metadata down from  
ri_FastPathBatchFlush() instead, as the array path already did, so one  
reference covers the whole batch.  That is only safe because of the  
deferred release above; latching without it would turn the NULL  
dereference into a use-after-free.  
  
Reported-by: Jacob Brazeal <jacob.brazeal@gmail.com> (offlist)  
Reported-by: Brian Carpenter | Deep Fork Cyber <b@deepforkcyber.com>  
<offlist>  
Reported-by: Anh Khoa <blkhoa2004@gmail.com> (offlist)  
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CA+HiwqFFB6vzx8v3t2=rbNYyxMistLf5kkJfqzJ81nadFyLrxA@mail.gmail.com  
Discussion: https://postgr.es/m/CAJTYsWUFBZNs_UN5MAAK7vG4_DEmv0FiT8552CWuOcggDUki2g@mail.gmail.com  
Backpatch-through: 19  

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

Message wording fix

commit   : eb3bdc5d56015e05f3d90457968bf407c615eaaa    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 19 Aug 2026 08:56:56 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 19 Aug 2026 08:56:56 +0200    

Click here for diff

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

Message style fixes

commit   : 35d5cfbdc1abe3cc2467f68a975242dedb3837a0    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 19 Aug 2026 08:46:54 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 19 Aug 2026 08:46:54 +0200    

Click here for diff

M src/backend/commands/analyze.c

psql: Fix psql slash option leaks

commit   : be97b984f43079fd87c561e8ca6cd614c18e652e    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:37:09 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Aug 2026 12:37:09 +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   : 1bb858c83103025742b7d2ca4d6f926564ba60e6    
  
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   : 8114617f783b93b09e24e829567366779b3e93d9    
  
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   : bdbf662b1b93911d47a7a97c2dfb5f992bb255ae    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 11:32:40 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 11:32:40 +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

Relax strictness detection for row-format IS NOT NULL tests

commit   : f863be3e2dbeed457885a109904b30bb8edcfcde    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:24:12 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:24:12 +0900    

Click here for diff

find_nonnullable_rels() and find_nonnullable_vars() declined to look  
through a NullTest with argisrow set, treating row-format IS NOT NULL  
as proving nothing.  But such a test returns FALSE, not TRUE, both  
when the composite datum is NULL and when any of its fields is NULL,  
so its truth implies a non-null input just as the plain test does.  
That is the only property strictness detection relies on, so the  
argisrow restriction can simply be dropped.  
  
This lets "a LEFT JOIN b ... WHERE b IS NOT NULL" reduce to an inner  
join, the IS NOT NULL counterpart of the whole-row anti-join reduction  
in the preceding commit.  make_outerjoininfo() likewise picks up such  
tests when it computes join strictness for outer-join ordering.  
Row-format tests on composite-type columns now also prove those  
columns non-null, which can feed the anti-join proofs.  
  
The stronger implication of a row-format test, that every field of the  
row is non-null, remains unexploited: a whole-row Var reported by  
find_nonnullable_vars() promises only a non-null datum, since the same  
entry can arise from contexts that are merely strict at the datum  
level, such as record comparisons.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49H9khf+1GwyzD0TYaks6cE-OU+1mbUiOn3gZSoBiO7zg@mail.gmail.com  

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

Reduce outer joins to anti joins for whole-row IS NULL tests

commit   : 02119d6c87e20bd17f9b94b0420c2713d62275bc    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:23:44 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:23:44 +0900    

Click here for diff

reduce_outer_joins() recognizes "WHERE b.z IS NULL" above an outer  
join as an anti-join condition, but not the whole-row "WHERE b IS  
NULL", which is a natural way to ask for an anti-join without naming a  
specific column.  Teach it to recognize the whole-row form too.  
  
A row that the join null-extends has all of b's columns set to NULL,  
so it satisfies "b IS NULL".  A matched row satisfies the test only if  
its columns happen to be all NULL.  Hence proving any one column of b  
non-null in matching rows rules out every matched row, leaving only  
null-extended rows: exactly anti-join semantics.  This mirrors the  
single-column case, and the same proofs apply: a NOT NULL table  
constraint, a strict join clause (for LEFT joins), or strict quals  
within the relation's subtree.  Because any one column suffices, the  
whole-row test reduces in a strict superset of the cases a  
single-column test does.  
  
To implement this, find_forced_null_vars() now reports a whole-row Var  
tested with row-format IS NULL as a varattno-zero entry meaning that  
all of the relation's columns are forced null.  Row-format tests on  
ordinary composite-type columns remain excluded, since such a test  
does not force the column null: it is also true when the column is a  
non-null row whose fields are all NULL.  The proof functions in  
reduce_outer_joins() treat a whole-row entry accordingly: it is  
refuted by proving any one column of its relation non-null.  A match  
on the whole-row attribute itself proves nothing, because a non-null  
composite datum can still have all columns NULL, so the per-column  
matching now explicitly excludes that attribute.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49H9khf+1GwyzD0TYaks6cE-OU+1mbUiOn3gZSoBiO7zg@mail.gmail.com  

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

Reduce FULL JOIN to ANTI JOIN

commit   : 2ce5a57bc0d93c6b14f7cd5ea5eb105a987bd46f    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:23:09 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:23:09 +0900    

Click here for diff

reduce_outer_joins() already recognizes that a LEFT JOIN is really an  
anti-join when an upper qual forces a nullable-side Var to be NULL but  
that Var is provably non-null in every row the nullable side emits.  
Only null-extended rows can then satisfy the qual, so the matched rows  
all drop out and JOIN_LEFT becomes JOIN_ANTI.  
  
The same reasoning applies to a FULL JOIN.  If a forced-null Var on  
one side is proven non-null, every row where that side is present,  
matched or not, has the Var non-null and is dropped by the qual.  Only  
the rows where that side was null-extended survive, which is an  
anti-join that keeps the other side's unmatched rows.  
  
When the proven Var is on the RHS, the surviving LHS rows are already  
the left input, so this is a plain JOIN_ANTI.  When it is on the LHS,  
the surviving RHS rows must become the left input, so we tag the join  
JOIN_RIGHT_ANTI and let the existing input-switching step, the one  
that flips JOIN_RIGHT to JOIN_LEFT, normalize it to JOIN_ANTI.  Unlike  
the LEFT JOIN case, the join's own ON quals cannot serve as proof  
here, because they do not hold for the unmatched rows the proof must  
cover.  
  
Reducing the full join this way also lets qual constraints reach its  
inputs.  reduce_outer_joins_pass2() passes nothing down through a  
JOIN_FULL, but it does pass the join's own quals down through the  
resulting JOIN_ANTI, so outer joins below it can now be reduced too.  
That is sound for the same reason it is for any anti-join: a row that  
a lower join null-extends cannot satisfy those quals, so it can never  
match, and removing it does not change which rows the anti-join emits.  
  
The proof that a forced-null Var is non-null, from the quals that hold  
for every row a subtree emits (optionally plus extra quals the caller  
supplies) or from a NOT NULL constraint, is factored into  
forced_null_var_is_nonnullable() and shared by the LEFT and FULL  
paths.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49H9khf+1GwyzD0TYaks6cE-OU+1mbUiOn3gZSoBiO7zg@mail.gmail.com  

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

Reduce LEFT JOIN to ANTI JOIN using quals within the RHS subtree

commit   : a812cf647a828fc6157ca1f864f74067f088b580    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:22:32 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 19 Aug 2026 10:22:32 +0900    

Click here for diff

reduce_outer_joins() turns a LEFT JOIN into an ANTI JOIN when some Var  
that an upper qual requires to be NULL is actually non-nullable in any  
matching row.  When that holds, only null-extended (unmatched) rows  
can satisfy the upper qual, which is exactly anti-join semantics.  
Until now we recognized such a Var as non-nullable only when the  
join's own clauses were strict for it, or when it was defined NOT NULL  
by table constraints.  
  
This patch allows strict quals applied within the RHS subtree to serve  
as the proof as well.  Because such quals hold for every row the RHS  
emits, they hold for every matching row, so a Var they force non-null  
can become NULL above the join only by null-extension.  
  
To avoid re-walking the jointree at decision time, the first pass of  
the reduce-outer-joins process gathers these proving quals into its  
per-subtree state, alongside nullable_rels.  The second pass then  
proves non-nullness from the RHS subtree's collected quals together  
with the join's own ON quals.  As before, the reduction fires only  
when the proven, forced-null Var belongs to the RHS of the join.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49H9khf+1GwyzD0TYaks6cE-OU+1mbUiOn3gZSoBiO7zg@mail.gmail.com  

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

Report single-page checksum failures in pg_stat_database

commit   : 340f2ac626586d35b13c546609571474491d6332    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 09:51:49 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 19 Aug 2026 09:51:49 +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/backup/basebackup.c
M src/bin/pg_basebackup/t/010_pg_basebackup.pl

Make plperl's handling of Perl hashes more consistent.

commit   : 5bf8fee543a19ca9ffa5aa99046adae34ba6a864    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 18 Aug 2026 17:47:13 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 18 Aug 2026 17:47:13 -0400    

Click here for diff

Make hek2cstr() available in plperl.h, so that it can be used  
in hstore_plperl and jsonb_plperl.  Those modules were previously  
using different coding techniques that probably don't get  
conversion from Perl strings to the database encoding quite right.  
(I'd prefer to make hek2cstr() non-inline, but cross-extension calls  
are messy and plperl has avoided them up to now, so stick with the  
existing approach.)  
  
Consistently use hv_iternext, hek2cstr, and HeVAL for hash iterations,  
with one exception in plperl_trusted_init: there, hv_iternextsv is  
fine since we don't actually care about the hash keys.  (A later  
patch will remove the HeVAL calls again, but for now we just want  
consistency.)  
  
Remove unnecessary extra calls of hv_iterinit.  
  
Remove duplicative pstrdup's in plperl_to_hstore.  
  
The meat of this change is to use hek2cstr() in the contrib modules,  
which makes a user-visible change in encoding conversion behavior.  
While it's certainly a bug fix, we've had no field complaints about  
those modules, so I'm hesitant to make this change in the back  
branches.  Hence, apply to master only.  
  
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  

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

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

commit   : c0641ae4e16276d9b429bdfd60879c7e64dee97e    
  
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

test_decoding: Don't print virtual generated columns.

commit   : 755f7e2c921f16e6bc09bdc8d286c495b2cee93b    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 18 Aug 2026 13:55:10 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 18 Aug 2026 13:55:10 -0700    

Click here for diff

Virtual generated columns are stored in tuples as null values, so  
heap_getattr() in tuple_to_stringinfo() always returns null for them.  
test_decoding printed such a column as null, which is  
indistinguishable from a column that genuinely holds null.  
  
This commit skips virtual generated columns in tuple_to_stringinfo(),  
the only place that prints a tuple. Stored generated columns continue  
to be printed, since their values do live in the heap tuple.  
  
This is a behavior change rather than a bug fix, and it changes  
test_decoding's output for tables that have virtual generated columns,  
which could affect consumers that parse it. Therefore it is not  
back-patched.  
  
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>  
Co-authored-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Euler Taveira <euler@eulerto.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAHg+QDfTh3UbB-Ed--o2Bd=SBDJoEiG-qp3C0+ETDibF63y=dw@mail.gmail.com  

M contrib/test_decoding/expected/ddl.out
M contrib/test_decoding/sql/ddl.sql
M contrib/test_decoding/test_decoding.c

Stabilize the FORCE drop test for online data checksums

commit   : f7a0cca2e35e36cb08817a40650a086d982ed942    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:58 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:58 +0200    

Click here for diff

Commit 51f55b13a4d added a test where DROP DATABASE ... WITH (FORCE)  
terminates a session holding a temporary table in the target database.  
While exiting, the terminated session drops its temporary table and  
commits, and the commit waits for a WAL flush behind the backlog  
generated by the checksum workers.  On machines with slow storage this  
can exceed the five seconds DROP DATABASE waits for terminated backends  
to exit, making the test fail with "database "dropmeforce" is being  
accessed by other users", as observed on buildfarm member turaco.  
  
To fix, use asynchronous commit in the terminated session, so that its  
exit does not wait for a WAL flush, and checkpoint before the drop so  
that the exit-time WAL records do not queue up behind the backlog.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://postgr.es/m/361531e2-52b5-499c-a126-815f277bbef2@gmail.com  
Backpatch-through: 19  

M src/test/modules/test_checksums/t/001_basic.pl

Minor test suite cleanup

commit   : d1283c331a427d1747a5567e323bb629a52a7c13    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:55 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:55 +0200    

Click here for diff

A few catalog queries were missing proper schema qualification in the  
test_checksums module test suites, and one suite contained a disable  
call right before tearing down the test which can be removed.  
  
Backpatch to v19 where the test suite was added.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/8CF9B235-AEE9-4E68-93DD-DF4F29E2FCE5@yesql.se  
Backpatch-through: 19  

M src/test/modules/test_checksums/t/001_basic.pl
M src/test/modules/test_checksums/t/002_restarts.pl
M src/test/modules/test_checksums/t/003_standby_restarts.pl
M src/test/modules/test_checksums/t/005_injection.pl

basebackup: do not verify checksums on pages from before enabling

commit   : 55edc7907b87db6c0b3257b4d7083c2b9fcbfd69    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:52 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:52 +0200    

Click here for diff

Enabling data checksums in a running cluster changes the state to "on"  
before the checkpoint which flushes the pages the worker rewrote.  A  
base backup which started before that transition absorbs the barrier  
mid-run and starts verifying pages whose on-disk copies legitimately  
lack checksums, and whose LSNs predate the backup start, so the LSN  
check does not skip them either.  The backup fails with bogus  
corruption warnings.  The same applies to checksums being disabled and  
re-enabled while the backup runs: hint bits set while checksums were  
off reach disk without a checksum update and without moving the page  
LSN, tripping verification once the re-enabling completes.  
  
To fix, verify checksums only while they have been continuously  
enabled since the checkpoint the backup started from: track the  
location of the last XLOG2_CHECKSUMS record inserted or replayed, and  
verify only when the state is "on" and the last change predates the  
backup start.  The starting checkpoint then guarantees that every page  
flushed before it has a checksum written, and any later change  
disables verification for the rest of the backup.  
  
A standby loses the tracked location when restarting, while pg_control  
already carries the new state, so it could reach consistency below the  
record and serve base backups with the location unknown.  To prevent  
this, replaying XLOG2_CHECKSUMS advances minRecoveryPoint to the  
record, like XLOG_PARAMETER_CHANGE does.  
  
The tests hold the enabling between the state change and its final  
checkpoint with injection points, straddling it with backups on the  
primary and across a standby crash-restart.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFP=-cVVVPue+e8qqPtDfuLuQn=ZB4Mw_C9-Ncru2wqAsQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ref/pg_basebackup.sgml
M src/backend/access/transam/xlog.c
M src/backend/backup/basebackup.c
M src/include/access/xlog.h
M src/test/modules/test_checksums/meson.build
A src/test/modules/test_checksums/t/010_backup_straddle.pl
A src/test/modules/test_checksums/t/011_standby_straddle.pl

Add data_page_checksum_version to pg_control_checkpoint

commit   : ec4399642ae94f1ade0c1532fc67146f851c408c    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:49 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:49 +0200    

Click here for diff

Commit f19c0eccae added the data_checksum_version to the pg_controldata  
output, but omitted a corresponding change to the pg_control_checkpoint  
SQL function, which reports the same checkpoint information.  The field  
is named to match what pg_control_init already reports for consistency.  
  
The integer version reported is an implementation detail which bleeds  
through, but it is quite widely used and a more holistic approach to  
improving this is left as an excercise for the next major version. The  
mapping between states and versions is added to the documentation to  
make it easier for users.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Ian Barwick <barwick@gmail.com>  
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/CAB8KJ=hb765sE8bKC-6sh=Yp3sCjN8xs474yuBrkwyoTM2pgZA@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/func/func-info.sgml
M doc/src/sgml/wal.sgml
M src/backend/utils/misc/pg_controldata.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/modules/test_checksums/t/001_basic.pl
M src/test/modules/test_checksums/t/004_offline.pl

Record initial state of data checksums in controlfile

commit   : 514fb08f51471b47c6d4e059df70be97f61a78cc    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:42 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 18 Aug 2026 22:25:42 +0200    

Click here for diff

The controlfile records the current state of data checksums, which  
also used to be the initial state from initdb when checksums could  
not be altered after initialization.  pg_control_init is documented  
to return information about cluster initialization state, which it  
no longer will if data checksums have been changed either using the  
offline tool or with online processing.  
  
Fix by adding a new field in the control file which tracks the init  
value of data checksums, and is left read only after initialization.  
  
While this is a regression dating back to when changing checksum  
state was made possible offline with pg_checksums, it is a control  
file change so it cannot be backpatched.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/B87ABFBE-A304-4839-8706-C80D73E6BF5C@yesql.se  
Backpatch-through: 19  

M src/backend/access/transam/xlog.c
M src/backend/utils/misc/pg_controldata.c
M src/include/catalog/pg_control.h
M src/test/modules/test_checksums/t/001_basic.pl
M src/test/modules/test_checksums/t/002_restarts.pl
M src/test/modules/test_checksums/t/004_offline.pl

pg_locale.c: comment improvements.

commit   : cba80d5e74d0ee5f39874db63348f3b35e55afe3    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 18 Aug 2026 13:16:28 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 18 Aug 2026 13:16:28 -0700    

Click here for diff

Add missing comments and fix outdated/incorrect comments in  
pg_locale.c and related files.  
  
Suggested-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/v3nniwcrxejmcfvz56xbd22hphprqleuornd6hqkmw2bl7kgmz@cnytz2ee5ltk  
Backpatch-through: 18  

M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/pg_locale_builtin.c
M src/backend/utils/adt/pg_locale_icu.c
M src/include/utils/pg_locale.h

Fix stream abort for a transaction that was never streamed.

commit   : aa4c52b808f76870f80189757af7217358544d60    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 18 Aug 2026 11:56:49 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 18 Aug 2026 11:56:49 -0700    

Click here for diff

Commit 072ee847ad4 taught logical decoding to discard the changes of a  
transaction that is already known to be aborted when it is picked for  
eviction. That path reuses ReorderBufferTruncateTXN(), which marks  
every subtransaction that still has in-memory changes as  
streamed. Since nothing is streamed in that path, and the top-level  
transaction is never marked, a subtransaction ends up flagged as  
streamed even though the output plugin has never seen it. Decoding the  
subsequent abort record then makes ReorderBufferAbort() invoke the  
stream_abort callback for that subtransaction.  
  
For pgoutput this sends a Stream Abort ('A') message to a subscriber  
that requested streaming = off, and it does so regardless of the  
negotiated protocol version, so even a client speaking a version that  
predates transaction streaming receives a message it cannot  
parse. test_decoding dereferences a NULL pointer and crashes, since it  
allocates its per-transaction state in the begin or stream start  
callback, neither of which runs for a transaction discarded as  
aborted.  
  
This commit fixes this by marking a subtransaction as streamed only  
when it has changes and its top-level transaction is already marked as  
streamed. All streaming call sites mark the top-level transaction  
before truncating it, so their behavior is unchanged, while the  
abort-discard path never marks the top-level transaction and therefore  
now leaves its subtransactions unmarked.  
  
Backpatch to v18, where commit 072ee847ad4 was introduced.  
  
Bug: #19616  
Reported-by: Tyler Smart <tyler@smarts.io>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/19616-f6153af509910853@postgresql.org  
Backpatch-through: 18  

M contrib/test_decoding/expected/stream.out
M contrib/test_decoding/sql/stream.sql
M src/backend/replication/logical/reorderbuffer.c

test_json_parser: Fix broken file ref and inverted result check

commit   : 195e8e427c07cc87ed8c8e819617bc87871893e5    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Tue, 18 Aug 2026 09:06:05 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Tue, 18 Aug 2026 09:06:05 -0400    

Click here for diff

A comma following a file ref in a perl print statement makes the  
statement just print the file's GLOB rather than redirecting the  
following arguments to the file. This meant the test was not testing any  
contents and the logs were instead bulked up with what the test was  
supposed to be testing.  
  
Also, run_log() returns 1 for success, not 0, so the tests for the  
return values were wrong. (We were getting 0 because of the comma error  
above.)  
  
Backpatch-thru: 17  

M src/test/modules/test_json_parser/t/004_test_parser_perf.pl

Message style fixes

commit   : 033f39e694872d8d74e670a20093db781eb0bf61    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 18 Aug 2026 14:08:14 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 18 Aug 2026 14:08:14 +0200    

Click here for diff

M src/backend/access/transam/slru.c
M src/backend/libpq/be-secure-openssl.c

Re-register LSN waiters after stale wakeups

commit   : 70b7e968d5773026ea5105ae7ff23d362bf9723d    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:27:23 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:27:23 +0300    

Click here for diff

WaitLSNWakeup() removes a waiter from the heap before setting its latch.  
If the position that caused the wakeup moves backwards before the waiter  
rechecks it, as can happen when WAL streaming restarts, the waiter may  
sleep again while no longer registered.  Subsequent WAL progress then  
cannot wake it.  
  
When an unmet waiter finds that it is no longer in the heap, add it back  
and restart the loop.  Rereading the position after registration also  
prevents missing an advance between the previous read and the re-add.  
  
Process interrupts before re-registering rather than after, so that a  
wakeup which goes stale again cannot postpone cancellation, however often  
it repeats.  As a side effect, a pending cancel now wins over an expired  
timeout, which previously reported a timeout instead.  
  
Add deterministic TAP coverage that simulates a stale standby_write  
wakeup without advancing the actual write or replay positions.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7UtW_cAa%3DQh4RDfKiUqu3pJJE22ai9tbWJVERbeRyssLw%40mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/transam/xlogwait.c
M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_wait_lsn/Makefile
A src/test/modules/test_wait_lsn/meson.build
A src/test/modules/test_wait_lsn/test_wait_lsn–1.0.sql
A src/test/modules/test_wait_lsn/test_wait_lsn.c
A src/test/modules/test_wait_lsn/test_wait_lsn.control
M src/test/recovery/Makefile
M src/test/recovery/t/049_wait_for_lsn.pl

Clarify LSN waiter cleanup after wakeup

commit   : 774dc1e9ddf2ffd0b6b66f3ed9d041fe25cae36a    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:26:38 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:26:38 +0300    

Click here for diff

WaitLSNWakeup() can be called by several processes, not only the startup  
process.  Update the cleanup comment to explain that another process may  
remove the waiter before waking it and that inHeap prevents double  
deletion.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7UtW_cAa%3DQh4RDfKiUqu3pJJE22ai9tbWJVERbeRyssLw%40mail.gmail.com  
Backpatch-through: 19  

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

Avoid locking when an LSN waiter is already removed

commit   : 0c8dd518a58fb7b65c992d3bb6ce21aa3f4fa9fb    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:25:53 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:25:53 +0300    

Click here for diff

WaitLSNWakeup() removes each selected waiter from its heap and clears  
its inHeap flag before setting its latch.  When such a waiter later  
calls deleteLSNWaiter(), it acquires WaitLSNLock exclusively only to  
discover that there is nothing left to remove.  Waking many waiters can  
therefore make them serialize on the lock for no useful work.  
  
Check inHeap before acquiring WaitLSNLock.  A lockless false value is  
conclusive because only the owning backend can change inHeap from false  
to true.  A concurrent waker can only clear it.  A stale true value  
falls through to the existing recheck under the lock.  
  
WaitLSNCleanup() performed the same lockless check before calling  
deleteLSNWaiter().  Drop it there, as it is now redundant.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7UtW_cAa%3DQh4RDfKiUqu3pJJE22ai9tbWJVERbeRyssLw%40mail.gmail.com  
Backpatch-through: 19  

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

Fix WAIT FOR LSN documentation examples

commit   : e1a60f5898827520a02c34842f71ce092360b8a7    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:25:03 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:25:03 +0300    

Click here for diff

Pad example LSNs to match pg_lsn_out() output, and use  
"standby_replay LSN" in the timeout error to match the server message.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7UtW_cAa%3DQh4RDfKiUqu3pJJE22ai9tbWJVERbeRyssLw%40mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ref/wait_for.sgml

Add wait-for-lsn process-exit cleanup callback

commit   : f994d2b71ebca8258f7c68be310077588aa62059    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:24:21 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 18 Aug 2026 14:24:21 +0300    

Click here for diff

WaitLSNCleanup() was called from ProcKill(), but not from  
AuxiliaryProcKill(), even though xlogwait.c sizes its shared memory to  
include NUM_AUXILIARY_PROCS and thus accepts calls from auxiliary  
processes.  Such a process exiting while waiting would leave its entry in  
the heap.  
  
Register an on_shmem_exit callback lazily before a process enters a  
wait-for-lsn heap instead, as suggested by Noah: that keeps the cleanup  
local to xlogwait.c and makes it harder to miss a caller that needs it,  
rather than having to remember every process-kill path.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>  
Discussion: https://postgr.es/m/20260706012642.f9.noahmisch%40microsoft.com  
Discussion: https://postgr.es/m/CABPTF7UtW_cAa%3DQh4RDfKiUqu3pJJE22ai9tbWJVERbeRyssLw%40mail.gmail.com  
Backpatch-through: 19  

M src/backend/access/transam/xlogwait.c
M src/backend/storage/lmgr/proc.c

Fix RI fast-path race with REINDEX CONCURRENTLY

commit   : d02a9084d91015547b831385fc007b6ac0161be5    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Tue, 18 Aug 2026 17:06:51 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Tue, 18 Aug 2026 17:06:51 +0900    

Click here for diff

The RI fast path reads pg_constraint.conindid before taking  
RowShareLock on the referenced table.  REINDEX CONCURRENTLY can  
repoint the constraint and mark the old index dead, or drop it,  
between those operations.  A backend in that window does not yet  
hold a relation lock, so it is not covered by REINDEX CONCURRENTLY's  
waits for lockers.  
  
Opening an index that has already been dropped produces "could not open  
relation with OID".  Opening one that has only been marked dead can  
produce wrong answers: the index is no longer maintained or vacuumed,  
so a scan can miss a referenced row or follow a stale entry to a reused  
heap line pointer.  
  
After locking the referenced table, reload the constraint and use its  
current conindid.  LockRelationOid() processes invalidation messages  
after acquiring the lock, so the reload sees a committed index swap.  
If the lock was already held, REINDEX CONCURRENTLY cannot mark the old  
index dead or drop it until the transaction releases that lock, so  
continuing to use the old conindid is safe.  
  
Do this at both RI fast-path call sites.  Add injection-point coverage  
for old indexes that have either been dropped or marked dead.  
  
Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>  
Discussion: https://postgr.es/m/CADzfLwUJiVuv69uwuF5z4TrMhNkVwQUXW03q+uVNwmYFLtjEhw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/indexcmds.c
M src/backend/utils/adt/ri_triggers.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/ri_fastpath_reindex.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/ri_fastpath_reindex.spec

hstore: Rework module to use Size and {add,mul}_size for allocation sizes

commit   : 92e20d4a4382810a30bdb394473d6ee891edab73    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 18 Aug 2026 13:44:04 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 18 Aug 2026 13:44:04 +0900    

Click here for diff

hstore has been relying on a set of int/int32 to count the total length  
of all the keys and values constructed, relying on the maximum values of  
the arguments rather than proper bound checks.  As proved in the  
reported thread, these counters could overflow and wrap, leading to  
incorrect allocations.  
  
This commit replaces the int/int32 values with a set of Size values,  
with add_size() and mul_size() in charge of checking for overflows when  
constructing hstore values before doing any allocation.  
  
The changes that matter in terms of the report are mostly in  
hstore_io.c.  hstore_compat.c is adjusted for consistency, to keep the  
allocation maths uniform across the module.  
  
This is an old bug.  A backpatch should perhaps be done but I cannot get  
excited about a change like that in stable branches.  
  
Reported-by: Man Zeng <zengman@halodbtech.com>  
Author: Tender Wang <tndrwang@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAHewXNmfD6-9MDxgpRfTzjVj0mhBw3JMoNOHeTiPOjZGhNzd=g@mail.gmail.com  

M contrib/hstore/hstore.h
M contrib/hstore/hstore_compat.c
M contrib/hstore/hstore_io.c
M contrib/hstore/hstore_op.c
M contrib/hstore/hstore_subs.c
M contrib/hstore_plperl/hstore_plperl.c
M contrib/hstore_plpython/hstore_plpython.c

Fix cross-type foreign keys in the batched fast-path FK check

commit   : cc449a504bfe50c91854727844b6fb1782a29417    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Tue, 18 Aug 2026 12:15:51 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Tue, 18 Aug 2026 12:15:51 +0900    

Click here for diff

ri_FastPathFlushArray() rechecked a concurrently updated PK tuple with a  
scan key it built itself, putting found_val, the key of the tuple it had  
just locked, into sk_argument, and passing that same slot to  
recheck_matched_pk_tuple().  Both operands therefore came from the locked  
tuple, and since sk_argument is the operator's right-hand input, the PK  
value was read as an FK value.  For a foreign key using a cross-type  
equality operator, such as a "date" primary key referenced by a "timestamp"  
column, that compares days against microseconds, so the recheck always  
failed and a batch that had to follow an update chain reported a violation  
even though the version it locked still had the key.  
  
Remove the recheck.  For a same-type key it compared the tuple against  
itself and so never rejected anything, which was harmless only because the  
loop a few lines below does the real work: it already compares found_val,  
read after the chain has been followed, against every buffered FK value,  
with the arguments in the order the operator expects.  That makes the  
recheck redundant as well as wrong.  Detection is not weakened by dropping  
it, since the buffered value that led the scan to a tuple can be matched by  
no other row visible to our snapshot.  
  
ri_FastPathProbeOne() passes its original scan key, with the FK value still  
in sk_argument, and was never affected; nor were single-row statements or  
multi-column foreign keys, which go through it.  
  
Add an isolation test covering the cross-type case, a permutation where  
the key really does move away, and a same-type permutation that should  
behave identically.  
  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Co-authored-by: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-WznQjX3GByh_Ju7unuzMcik_5PJ5D7i_=qhwk=gPEkhfVQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/utils/adt/ri_triggers.c
A src/test/isolation/expected/fk-crosstype-recheck.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/fk-crosstype-recheck.spec

Doc: clean up documentation about text search datatype limits.

commit   : 4921447bea7d6874384bd8d651d66074de39a8aa    
  
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   : e6cac7fab36a7ae861dd9172503efe8176832cb6    
  
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   : f7cc6fd76007c5a051109cf8bbd7e1d391bd45a8    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 17 Aug 2026 17:31:12 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Mon, 17 Aug 2026 17:31:12 -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

Reorder function prototypes to match definition order

commit   : dd13dd39dbd3eec00ec1bff857b14bbc77fff86f    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 17 Aug 2026 22:40:26 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 17 Aug 2026 22:40:26 +0200    

Click here for diff

While purely aesthetic, it makes reading the code easier to rearrange  
before the feature has shipped since doing it after risk backpatching  
conflicts.  Also add missing prototypes.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEQ1-+iPQnUpTXYiHmzSz9ufFVkOK4kL_uyTdYt7jgg0Q@mail.gmail.com  
Backpatch-through: 19  

M src/backend/postmaster/datachecksum_state.c

Make data checksums launcher cancel its worker at SIGINT

commit   : ed6775db84db7d28c787bbe4b9e8989f3e8f107a    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 17 Aug 2026 22:40:22 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 17 Aug 2026 22:40:22 +0200    

Click here for diff

Make sure the launcher cancels the currently running worker by calling  
TerminateBackgroundWorker when it receives SIGINT.  In order to handle  
cases where SIGINT arrives while tje launcher is waiting for a worker  
to start or exit, implement a version of WaitForBackgroundWorkerStartup  
and WaitForBackgroundWorkerShutdown which checks the abort_requested  
signalling.  A new test which kills processing with SIGINT is added.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAHGQGwEQ1-+iPQnUpTXYiHmzSz9ufFVkOK4kL_uyTdYt7jgg0Q@mail.gmail.com  
Backpatch-through: 19  

M src/backend/postmaster/datachecksum_state.c
M src/test/modules/test_checksums/t/002_restarts.pl

Replace printf format %i by %d

commit   : c9fd8ee14fae45eda987c68b5d2d4f0f0110ee35    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 17 Aug 2026 16:36:40 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 17 Aug 2026 16:36:40 +0200    

Click here for diff

as is PostgreSQL standard  

M src/backend/postmaster/datachecksum_state.c
M src/test/modules/plsample/plsample.c
M src/test/regress/pg_regress.c

Add an "unset" value for vacuum_index_cleanup.

commit   : c66e7531e4141d5fa4accaeafaec4e7c2f638da0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 17 Aug 2026 14:41:59 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 17 Aug 2026 14:41:59 -0500    

Click here for diff

This commit adds a new value to StdRdOptIndexCleanup to distinguish  
whether it is explicitly set, similar to ViewOptCheckOption's  
VIEW_OPTION_CHECK_OPTION_NOT_SET.  This changes only the internal  
representation; an unset value still defaults to AUTO, and the  
option accepts the same input as before.  
  
This is preparatory work for a follow-up commit that will make use  
of the new "unset" state.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Tested-by: Greg Burd <greg@burd.me>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/access/common/reloptions.c
M src/backend/commands/vacuum.c
M src/include/utils/rel.h

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

commit   : 131444cd167afd135768b5d1605caf89fb25e4e2    
  
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

Make autovacuum_enabled a ternary reloption.

commit   : 3d8f71a370f0ad93762f140f6e69c2abe05b229a    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 17 Aug 2026 13:17:12 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 17 Aug 2026 13:17:12 -0500    

Click here for diff

This commit reimplements autovacuum_enabled as a ternary, using the  
support added in commit 4d6a66f675 and following the example of  
vacuum_truncate.  This changes only the internal representation: an  
unset value still behaves as enabled, and the option accepts the  
same input as before.  
  
This is preparatory work for a follow-up commit that will make use  
of the new "unset" state.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Greg Burd <greg@burd.me>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/access/common/reloptions.c
M src/backend/catalog/index.c
M src/backend/postmaster/autovacuum.c
M src/include/utils/rel.h

Remove extract_autovac_opts().

commit   : 0499c6ccf5ce510ad8c57211ee8c9414e92c71b7    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 17 Aug 2026 12:16:03 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 17 Aug 2026 12:16:03 -0500    

Click here for diff

extract_autovac_opts() returns a palloc'd copy of just the  
AutoVacOpts portion of a relation's reloptions, but upcoming work  
needs the other StdRdOptions fields, too.  Remove it in favor of  
calling extractRelOptions() directly.  av_relation now caches the  
main table's whole StdRdOptions.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Tested-by: Greg Burd <greg@burd.me>  
Tested-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan  

M src/backend/postmaster/autovacuum.c

Use safer allocation routines in more places of the tree

commit   : 51c43a5dbd86ad8461544e54c00bd9f487abfacd    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 17 Aug 2026 16:15:45 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 17 Aug 2026 16:15:45 +0900    

Click here for diff

This is part of a more global effort to modernize the code tree with  
safer allocation functions, which offer more protection in terms of:  
- stronger type safety guarantees  
- size overflow checks, particulary for arrays.  
  
This set of updates includes allocation changes based on  
palloc_object(), palloc_array() and repalloc_array().  This work is  
similar to 1b105f9472bd, expanding more the new APIs in the tree in an  
incremental fashion.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://postgr.es/m/DKJB5887LGX9.359DV1UMZ1URK@partin.io  

M contrib/btree_gist/btree_bool.c
M contrib/btree_gist/btree_cash.c
M contrib/btree_gist/btree_date.c
M contrib/btree_gist/btree_enum.c
M contrib/btree_gist/btree_float4.c
M contrib/btree_gist/btree_float8.c
M contrib/btree_gist/btree_inet.c
M contrib/btree_gist/btree_int2.c
M contrib/btree_gist/btree_int4.c
M contrib/btree_gist/btree_int8.c
M contrib/btree_gist/btree_interval.c
M contrib/btree_gist/btree_macaddr.c
M contrib/btree_gist/btree_macaddr8.c
M contrib/btree_gist/btree_oid.c
M contrib/btree_gist/btree_time.c
M contrib/btree_gist/btree_ts.c
M contrib/btree_gist/btree_utils_num.c
M contrib/btree_gist/btree_uuid.c
M contrib/dict_xsyn/dict_xsyn.c
M contrib/file_fdw/file_fdw.c
M contrib/hstore/hstore_gin.c
M contrib/hstore/hstore_io.c
M contrib/hstore/hstore_op.c
M contrib/pageinspect/btreefuncs.c
M contrib/pageinspect/ginfuncs.c
M contrib/pg_logicalinspect/pg_logicalinspect.c
M contrib/pg_plan_advice/pgpa_scan.c
M contrib/pg_stash_advice/stashpersist.c
M contrib/pg_stat_statements/pg_stat_statements.c
M contrib/pg_trgm/trgm_gist.c
M contrib/pg_trgm/trgm_regexp.c
M contrib/pg_visibility/pg_visibility.c
M contrib/pgrowlocks/pgrowlocks.c
M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/postgres_fdw.c
M contrib/seg/seg.c
M contrib/tablefunc/tablefunc.c
M contrib/xml2/xpath.c
M contrib/xml2/xslt_proc.c
M doc/src/sgml/xfunc.sgml
M src/backend/access/brin/brin_minmax_multi.c
M src/backend/access/common/printtup.c
M src/backend/access/common/reloptions.c
M src/backend/access/common/tupdesc.c
M src/backend/access/gin/gindatapage.c
M src/backend/access/gin/ginget.c
M src/backend/access/gin/gininsert.c
M src/backend/access/gin/ginpostinglist.c
M src/backend/access/gin/ginscan.c
M src/backend/access/gist/gistbuildbuffers.c
M src/backend/access/gist/gistget.c
M src/backend/access/gist/gistproc.c
M src/backend/access/gist/gistscan.c
M src/backend/access/gist/gistsplit.c
M src/backend/access/gist/gistxlog.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/access/nbtree/nbtinsert.c
M src/backend/access/nbtree/nbtpage.c
M src/backend/access/nbtree/nbtpreprocesskeys.c
M src/backend/access/nbtree/nbtree.c
M src/backend/access/tablesample/bernoulli.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xact.c
M src/backend/access/transam/xloginsert.c
M src/backend/backup/basebackup_incremental.c
M src/backend/catalog/aclchk.c
M src/backend/catalog/dependency.c
M src/backend/catalog/heap.c
M src/backend/catalog/pg_constraint.c
M src/backend/catalog/pg_inherits.c
M src/backend/catalog/pg_shdepend.c
M src/backend/commands/alter.c
M src/backend/commands/analyze.c
M src/backend/commands/async.c
M src/backend/commands/collationcmds.c
M src/backend/commands/copyfrom.c
M src/backend/commands/copyfromparse.c
M src/backend/commands/copyto.c
M src/backend/commands/dbcommands.c
M src/backend/commands/explain.c
M src/backend/commands/explain_dr.c
M src/backend/commands/explain_state.c
M src/backend/commands/extension.c
M src/backend/commands/functioncmds.c
M src/backend/commands/policy.c
M src/backend/commands/subscriptioncmds.c
M src/backend/commands/tablecmds.c
M src/backend/commands/tablespace.c
M src/backend/commands/trigger.c
M src/backend/commands/vacuum.c
M src/backend/executor/execExpr.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execGrouping.c
M src/backend/executor/execJunk.c
M src/backend/executor/execParallel.c
M src/backend/executor/execPartition.c
M src/backend/executor/execSRF.c
M src/backend/executor/execTuples.c
M src/backend/executor/execUtils.c
M src/backend/executor/functions.c
M src/backend/executor/nodeAgg.c
M src/backend/executor/nodeAppend.c
M src/backend/executor/nodeBitmapAnd.c
M src/backend/executor/nodeBitmapOr.c
M src/backend/executor/nodeGather.c
M src/backend/executor/nodeGatherMerge.c
M src/backend/executor/nodeIncrementalSort.c
M src/backend/executor/nodeIndexscan.c
M src/backend/executor/nodeMemoize.c
M src/backend/executor/nodeMergejoin.c
M src/backend/executor/nodeModifyTable.c
M src/backend/executor/nodeSetOp.c
M src/backend/executor/nodeSubplan.c
M src/backend/executor/nodeTidscan.c
M src/backend/executor/nodeValuesscan.c
M src/backend/executor/spi.c
M src/backend/jit/llvm/llvmjit_expr.c
M src/backend/lib/bipartite_match.c
M src/backend/lib/knapsack.c
M src/backend/libpq/be-secure-common.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/libpq/hba.c
M src/backend/nodes/list.c
M src/backend/nodes/queryjumblefuncs.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/path/pathkeys.c
M src/backend/optimizer/plan/analyzejoins.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/plan/setrefs.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/util/appendinfo.c
M src/backend/optimizer/util/clauses.c
M src/backend/optimizer/util/extendplan.c
M src/backend/optimizer/util/inherit.c
M src/backend/optimizer/util/plancat.c
M src/backend/optimizer/util/tlist.c
M src/backend/parser/analyze.c
M src/backend/parser/parse_clause.c
M src/backend/parser/parse_cte.c
M src/backend/parser/parse_relation.c
M src/backend/partitioning/partbounds.c
M src/backend/partitioning/partdesc.c
M src/backend/partitioning/partprune.c
M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/checkpointer.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/postmaster/pmchild.c
M src/backend/postmaster/postmaster.c
M src/backend/replication/pgoutput/pgoutput.c
M src/backend/rewrite/rewriteHandler.c
M src/backend/statistics/dependencies.c
M src/backend/statistics/extended_stats.c
M src/backend/statistics/mcv.c
M src/backend/statistics/mvdistinct.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/ipc/shmem.c
M src/backend/storage/lmgr/deadlock.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/lwlock.c
M src/backend/storage/smgr/md.c
M src/backend/tcop/fastpath.c
M src/backend/tsearch/dict_thesaurus.c
M src/backend/tsearch/spell.c
M src/backend/tsearch/ts_parse.c
M src/backend/tsearch/wparser.c
M src/backend/tsearch/wparser_def.c
M src/backend/utils/activity/pgstat_xact.c
M src/backend/utils/adt/acl.c
M src/backend/utils/adt/array_typanalyze.c
M src/backend/utils/adt/array_userfuncs.c
M src/backend/utils/adt/arrayfuncs.c
M src/backend/utils/adt/arrayutils.c
M src/backend/utils/adt/enum.c
M src/backend/utils/adt/jsonb_util.c
M src/backend/utils/adt/jsonfuncs.c
M src/backend/utils/adt/levenshtein.c
M src/backend/utils/adt/like_support.c
M src/backend/utils/adt/lockfuncs.c
M src/backend/utils/adt/multirangetypes.c
M src/backend/utils/adt/name.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/adt/oracle_compat.c
M src/backend/utils/adt/orderedsetaggs.c
M src/backend/utils/adt/pg_ndistinct.c
M src/backend/utils/adt/rangetypes_typanalyze.c
M src/backend/utils/adt/regexp.c
M src/backend/utils/adt/rowtypes.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/adt/selfuncs.c
M src/backend/utils/adt/tsquery_rewrite.c
M src/backend/utils/adt/tsrank.c
M src/backend/utils/adt/tsvector.c
M src/backend/utils/adt/tsvector_op.c
M src/backend/utils/adt/xml.c
M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/inval.c
M src/backend/utils/cache/lsyscache.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/cache/typcache.c
M src/backend/utils/misc/conffiles.c
M src/backend/utils/misc/tzparser.c
M src/backend/utils/sort/logtape.c
M src/backend/utils/sort/tuplesort.c
M src/backend/utils/sort/tuplesortvariants.c
M src/backend/utils/sort/tuplestore.c
M src/backend/utils/time/combocid.c
M src/backend/utils/time/snapmgr.c
M src/common/blkreftable.c
M src/common/rmtree.c
M src/include/lib/simplehash.h
M src/pl/plpgsql/src/pl_comp.c
M src/pl/plpgsql/src/pl_gram.y
M src/pl/plpython/plpy_cursorobject.c
M src/pl/plpython/plpy_exec.c
M src/pl/plpython/plpy_procedure.c
M src/pl/plpython/plpy_spi.c
M src/test/modules/plsample/plsample.c
M src/test/modules/test_aio/test_aio.c
M src/test/modules/test_binaryheap/test_binaryheap.c
M src/test/modules/test_integerset/test_integerset.c
M src/test/modules/test_radixtree/test_radixtree.c
M src/test/modules/test_rbtree/test_rbtree.c
M src/test/modules/test_regex/test_regex.c
M src/test/modules/test_resowner/test_resowner_basic.c
M src/test/modules/test_resowner/test_resowner_many.c
M src/test/modules/test_saslprep/test_saslprep.c
M src/test/modules/test_tidstore/test_tidstore.c
M src/test/regress/regress.c

psql: Fix \d+ display of REPLICA IDENTITY NOTHING

commit   : 4fb6e9eb753b92c3241473470b66c15523d8de33    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 17 Aug 2026 09:20:52 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 17 Aug 2026 09:20:52 +0900    

Click here for diff

Commit 18954ce7f69 has replaced hardcoded relreplident values in  
describe.c with CppAsString2 macros, but used a DEFAULT instead of a  
NOTHING at one location.  This caused \d+ on a table with REPLICA  
IDENTITY NOTHING to show incorrect data.  
  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Discussion: https://postgr.es/m/CAOzEurRHWt+9XLBrbXQOSVkE45NksJ4F28twuqgZ7veW0RzpUQ@mail.gmail.com  
Backpatch-through: 18  

M src/bin/psql/describe.c
M src/test/regress/expected/replica_identity.out
M src/test/regress/sql/replica_identity.sql

Fix ASAN failure after flex errors in GUC file parsing

commit   : 803583ce74d37c27167bd4d1c9e9dd2421735943    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 17 Aug 2026 08:53:22 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 17 Aug 2026 08:53:22 +0900    

Click here for diff

As detected by ASAN, the scanner value used when parsing GUC files can  
be indeterminate when the flex error handler sigjumps to the old cleanup  
path, before yylex_init() is called.  
  
The flex scanner state is now made volatile in ParseConfigFp(), since  
its value is assigned after sigsetjmp() and cna be accessed after  
siglongjmp().  yylex_init() cannot use a volatile pointer; a temporary  
variable is used before assigning the result of yylex_init() to it.  
  
While on it, yy_create_buffer() is changed to detect the case where it  
returns a NULL value.  Based on my read of the flex code, this cannot be  
reached currently.  Future upstream changes or changes in the error  
logic of the GUC file parsing could make that reachable, and it is four  
extra lines of code.  
  
Oversight in d663f150b5ed.  
  
Reported-by: Ilia Kashintsev <ilia.kashintsev@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Discussion: https://postgr.es/m/19612-24ccb4fc6da7786f@postgresql.org  
Backpatch-through: 18  

M src/backend/utils/misc/guc-file.l

Clarify logic in CreateSubscription().

commit   : 3d00537feb565c410baf41bb301eee338e4b2317    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Sat, 15 Aug 2026 09:42:23 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Sat, 15 Aug 2026 09:42:23 -0700    

Click here for diff

No bug found in previous code, but it unnecessarily relied on grammar  
rules. Per complaint from Coverity.  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/1787286.1786328153@sss.pgh.pa.us  
Backpatch-through: 19  

M src/backend/commands/subscriptioncmds.c

Add previous commit to .git-blame-ignore-revs

commit   : 4d85fd59c723e9bd9925e14ad8f3b5ce2e19318d    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 15 Aug 2026 23:26:23 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 15 Aug 2026 23:26:23 +0900    

Click here for diff

M .git-blame-ignore-revs

pgindent fix for commit 7b7c4a8dcc9

commit   : de8370d631aabed163f563037fc370bce0864a89    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 15 Aug 2026 23:15:31 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 15 Aug 2026 23:15:31 +0900    

Click here for diff

Per buildfarm member koel.  

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

Rename EXISTS-to-ANY converted subplan to exists_to_any

commit   : 7b7c4a8dcc933f61493356a45256b47783ce404f    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 15 Aug 2026 18:12:14 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 15 Aug 2026 18:12:14 +0900    

Click here for diff

Simple EXISTS subplans can be converted to hashed ANY subplans as  
an alternative implementation. Previously, both the original EXISTS  
subplan and the converted ANY subplan used names with the  
exists_ prefix, making EXPLAIN output harder to read and  
pg_plan_advice targets less clear.  
  
Use the exists_to_any_ prefix for converted ANY subplans so that  
their names distinguish them from the original EXISTS alternative.  
This only changes the names shown by EXPLAIN and used by plan advice;  
it does not affect planner behavior.  
  
Author: Yugo Nagata <nagata@sraoss.co.jp>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/20260605165641.3950f99ace0aad8f807abe96@sraoss.co.jp  
Backpatch-through: 19  

M contrib/pg_plan_advice/expected/alternatives.out
M contrib/pg_plan_advice/sql/alternatives.sql
M src/backend/optimizer/plan/subselect.c
M src/test/regress/expected/partition_prune.out
M src/test/regress/expected/subselect.out

doc: Clarify the logging collector's guarantees.

commit   : 7e6e294e4e451c55c52caa1ff68df9858912d066    
  
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

Use correct data type for version identifier

commit   : 1b87dd4303a9a90f2f4004fb08a00af7d3d25207    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 14 Aug 2026 21:52:21 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 14 Aug 2026 21:52:21 +0200    

Click here for diff

PGSS_PG_MAJOR_VERSION is written as an uint32 field, but was read back  
into an int32.  Fix to make sure reading and writing use the same data  
type.  
  
Author: Karina Litskevich <litskevichkarina@gmail.com>  
Discussion: https://postgr.es/m/CACiT8iYTkc33YWaA2D3t51Y5s=GqBO7T1zX7bkpSmet2njcLLw@mail.gmail.com  

M contrib/pg_stat_statements/pg_stat_statements.c

Use int64 for number of entries in pg_stat_statements

commit   : 337485036052ffcdaad0e9df654927f7949f2a68    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 14 Aug 2026 21:51:53 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 14 Aug 2026 21:51:53 +0200    

Click here for diff

Commit 13b935cd changed hash_get_num_entries to return int64 instead  
of long.  This fixes a few more users of hash_get_num_entries which  
were missed in the original commit.  
  
PGSS_FILE_HEADER is left unchanged since this only affects as of yet  
unreleased versions of PostgreSQL.  Backpatch to v19 where the int64  
change was performed.  
  
Author: Karina Litskevich <litskevichkarina@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CACiT8iYTkc33YWaA2D3t51Y5s=GqBO7T1zX7bkpSmet2njcLLw@mail.gmail.com  
Backpatch-through: 19  

M contrib/pg_stat_statements/pg_stat_statements.c

Add missing PGDLLIMPORT marker.

commit   : e6bccd5abed38f93f972469ccffcc99cfc801e66    
  
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

Retire PQfn().

commit   : 40af05bb6157670482ae31fd5b0a12ff2992c966    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 14 Aug 2026 11:29:21 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 14 Aug 2026 11:29:21 -0500    

Click here for diff

PQfn() has been documented as somewhat obsolete since commit  
efc3a25bb0 (2003), and commit bd48114937 recently marked it unsafe  
because it may write past the end of result_buf when result_is_int  
is 0.  Furthermore, searches of publicly available code turned up  
no callers, only language bindings that expose the function  
without using it, so removing it seems unlikely to cause too much  
trouble.  
  
Since the symbol is exported, deleting it outright isn't an option,  
so instead this commit teaches PQfn() to fail unconditionally with  
an error that suggests alternatives.  The documentation for the  
fast-path interface is replaced with a stub in the "Obsolete or  
Renamed Features" appendix.  The server's fast-path support is  
retained for the benefit of older clients and the frontend large  
object interface.  
  
The frontend large object interface, the only in-tree caller, now  
uses PQnfn(), the private version of PQfn() added by commit  
bd48114937.  I considered converting this code away from the  
fast-path protocol entirely, but prepared statements can be  
deallocated out from under libpq (e.g., by DISCARD ALL), and  
PQexecParams() proved noticeably slower, so that is left as a  
future exercise.  
  
Reviewed-by: Christoph Berg <myon@debian.org>  
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>  
Discussion: https://postgr.es/m/ahXE28klgxIJXBLq%40nathan  

A doc/src/sgml/appendix-obsolete-libpq-fastpath.sgml
M doc/src/sgml/appendix-obsolete.sgml
M doc/src/sgml/filelist.sgml
M doc/src/sgml/libpq.sgml
M src/backend/tcop/fastpath.c
M src/include/tcop/dest.h
M src/interfaces/libpq/fe-exec.c
M src/interfaces/libpq/fe-lobj.c
M src/interfaces/libpq/fe-protocol3.c
M src/interfaces/libpq/libpq-fe.h

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

commit   : 0d7baa209a302bba358bc4f6415a08339dae547f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 14 Aug 2026 12:14:23 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 14 Aug 2026 12:14:23 -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
M src/bin/psql/t/001_basic.pl

Make generate_queries_for_path_pattern_recurse() interruptible

commit   : a82e33a83d7cd39f3abd18c7b941625ca78d4c35    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 14 Aug 2026 14:53:50 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 14 Aug 2026 14:53:50 +0200    

Click here for diff

In case of a very long path pattern with each element pattern being  
resolved to many graph elements  
generate_queries_for_path_pattern_recurse() may take very long time to  
generate all the possible graph paths.  Make  
generate_queries_for_path_pattern_recurse() interruptible so that a  
user may be able to cancel such a query if required and the interrupts  
are processed in timely manner.  
  
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDfDwcM4%3DDSiAV6Ly89YQ5EcMhzO1-9x%3DmGG1WJzODcAig%40mail.gmail.com  

M src/backend/rewrite/rewriteGraphTable.c

Enforce WITH CHECK OPTION on DELETE FOR PORTION OF leftovers

commit   : 9924e2d900bf833c1d732d4bf877f51269b03157    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 14 Aug 2026 11:43:19 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 14 Aug 2026 11:43:19 +0200    

Click here for diff

DELETE FOR PORTION OF inserts temporal leftovers through ExecInsert(),  
but the rewriter only attached view WCOs for INSERT/UPDATE.  Leftover  
rows could therefore silently escape a WITH CHECK OPTION view, while  
the equivalent UPDATE correctly raised an error.  
  
This commit fixes it by attaching the WCOs for FOR PORTION OF deletes  
too.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Co-authored-by: Paul A Jungwirth <pj@illuminatedcomputing.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAN4CZFOuTyhGspG0Nyits8PiK2keoNXkLj-u3APzc66aRcWY9A%40mail.gmail.com  

M doc/src/sgml/ref/create_view.sgml
M src/backend/rewrite/rewriteHandler.c
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/updatable_views.sql

postgres_fdw: Rename option "restore_stats" to "import_stats".

commit   : 9a08585e8e59068d0ede7d47cd037915a42e1362    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 14 Aug 2026 17:40:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 14 Aug 2026 17:40:00 +0900    

Click here for diff

The option added by commit 28972b6fc was named "restore_stats", because  
it was calling pg_restore_relation_stats()/pg_restore_attribute_stats()  
in place of fetching a remote rowsample.  However, those code paths have  
been replaced with calls to  
import_relation_statistics()/import_attribute_statistics() (cf. commit  
54cd6fc83), so the option is now slightly misnamed.  
  
Switch the option to "import_stats", which more closely reflects both  
the functions being called internally, and the user's perception of what  
the operation is doing.  
  
Back-patch to v19 where commit 28972b6fc went in.  
  
Suggested-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Author: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/CADkLM%3DezuspTk3VD-2EM6XtFP-Dfz7cJKtnbn0cB6gocsAgu1g%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/option.c
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/postgres-fdw.sgml

Add string-based injection point wait in 051_effective_wal_level.pl

commit   : eb983d0a94f666d91058552117d029939821d648    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 15:13:30 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 15:13:30 +0900    

Click here for diff

This serves as an in-core example of the condition-string API of  
injection_points introduced in 0fd73cdffc18, where a wait at the  
beginning of a replication slot creation is tightened to happen only for  
a specific slot name.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0tsGHu2h6YLnVu4HiK05q+gTE_9WVUAqihW2LSscAYS-g@mail.gmail.com  

M src/backend/replication/slot.c
M src/test/recovery/t/051_effective_wal_level.pl

injection_points: Add support for string comparison in conditions

commit   : 0fd73cdffc18d3914311122bf4fbb5acbae626f3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 14:44:48 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 14:44:48 +0900    

Click here for diff

injection_points is extended so as a caller can attach a string value to  
a point, checked with a value provided at runtime.  There are a couple  
of use cases where this can be useful, to be able to target points for  
specific object names.  
  
PID and string conditions can be combined together, so as a point can be  
allowed for a specific process and string value at the same time.  
  
The condition string is capped at 255 characters.  As the attach SQL  
function now takes an optional condition string, it is no longer STRICT,  
and rejects NULL inputs.  Empty condition strings are also rejected, as  
they don't make sense.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAA5RZ0tsGHu2h6YLnVu4HiK05q+gTE_9WVUAqihW2LSscAYS-g@mail.gmail.com  

M src/test/modules/injection_points/expected/injection_points.out
M src/test/modules/injection_points/injection_points–1.0.sql
M src/test/modules/injection_points/injection_points.c
M src/test/modules/injection_points/injection_points.h
M src/test/modules/injection_points/sql/injection_points.sql

Fix thinko in error of algorithm type lookup for channel binding

commit   : 1f97b252dfee27b6300959b8403a4a9a2003046e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 09:45:24 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 09:45:24 +0900    

Click here for diff

The error printed would always use a NULL value, due to OBJ_nid2sn()  
known to fail.  This updates the error message to use the algorithm  
number instead.  
  
Oversight in 28995f051e72, in the shape of copy-pasto failure.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGPjENxX1SmkPrv9Rb-Fnij8jN4ginObmSTnWXqROS2+g@mail.gmail.com  

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

Refactor PgStat_TableStatus to new PgStat_RelationStatus

commit   : f2ccb8e6c5915617466ccea2abcf2d443d67dab0    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 09:07:54 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 09:07:54 +0900    

Click here for diff

This new structure is split depending on the stats kind it deals with:  
- PGSTAT_KIND_RELATION, for tables.  
- PGSTAT_KIND_INDEX, for indexes.  
  
This change designs a cleaner barrier for the handling of stats data  
related to tables and indexes, by being able to track precisely what are  
the counters used by one or the other for pending data.  Using a common  
ground for both eases the tracking of Relations in the relcache, with a  
structure based on a union separated by stats kind.  
  
The code originally pointed to some counters that may not be used at  
all.  For example, indexes have no need for the tracking of  
sub-transaction data, still the code implied that these could be touched  
for an index.  A consequence is that PgStat_TableXactStatus is not  
renamed, as it is not used by indexes.  
  
Some asserts are added as an extra layer of protection to prevent the  
update of fields that should not be touched.  find_tabstat_entry() and  
find_tabstat_entry_kind() are removed, replaced by a single  
find_relstat_entry_kind() able to work for indexes and the rest.  
  
72a6dad1c911 took care of the shared memory and on-disk part of the  
split.  This focuses on the pending data part at backend level.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/f572abe7-a1bb-e13b-48c7-2ca150546822@gmail.com  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_index.c
M src/backend/utils/activity/pgstat_relation.c
M src/backend/utils/adt/pgstatfuncs.c
M src/backend/utils/cache/relcache.c
M src/include/pgstat.h
M src/include/utils/pgstat_internal.h
M src/include/utils/rel.h
M src/tools/pgindent/typedefs.list

Use explicit fetching of digests in channel binding (OpenSSL >= 3.0)

commit   : 28995f051e72a1efae0e85d0ea43f80c38166657    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 07:37:01 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 14 Aug 2026 07:37:01 +0900    

Click here for diff

This commit touches both the libpq and backend-side code of channel  
binding where respectively pgtls_get_peer_certificate_hash() and  
be_tls_get_certificate_hash() are upgraded to retrieve digests using the  
method recommended by OpenSSL 3.0: no more direct EVP_sha256() or  
similar, just a EVP_MD_fetch() through EVP to get an algorythm type,  
based on a name.  
  
The pre-3.0 code is still required for LibreSSL and as long as we  
support OpenSSL 1.1.1.  
  
Similar work has been done in b91f79cd08ab and 1f3b9bb109b8.  
  
Author: Mark Atwood <mark@reviewcommit.com>  
Co-authored-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/178596055149.1584250.13974609482797470185@reviewcommit.com  

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

Fix authorization check for role membership changes.

commit   : a8261c766067f939aeea8e2dff821fed08dada79    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 13 Aug 2026 16:35:07 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 13 Aug 2026 16:35:07 -0500    

Click here for diff

Presently, check_role_membership_authorization() decides whether  
the current user may grant or revoke membership in a role by  
calling is_admin_of_role(), which recurses through all grants,  
while it chooses the grantor to record for the resulting entry by  
calling select_best_admin(), which recurses only through inherited  
grants.  When the two disagree, the permission check passes and the  
grantor lookup then comes up empty, so the user sees an internal  
"no possible grantors" error.  ALTER GROUP ... ADD USER reaches the  
same error through the separate check in AlterRole().  
  
To fix, teach both checks to search the same way  
select_best_admin() does via a new has_admin_privs_of_role().  The  
new check passes exactly when the grantor lookup was going to  
succeed, so nothing that works today starts failing; the internal  
error simply becomes a proper permission error.  Note that this  
leaves the other callers of is_admin_of_role() alone, so a role  
reachable only through a non-inherited grant can still be dropped,  
renamed, or altered.  Whether that ought to change as well is left  
as a future exercise.  
  
Oversight in commit ce6b672e44.  
  
Reported-by: ChangAo Chen <cca5507@qq.com>  
Author: ChangAo Chen <cca5507@qq.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Pretham <prezza672@gmail.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Discussion: https://postgr.es/m/tencent_ADCE2B34B230A9B631854806104FEF40C105%40qq.com  
Discussion: https://postgr.es/m/CAJUn_kN%2BMhbb8fYP5xxQCq1KEziOinM6HgYx4ts_pPDnQ2y1nQ%40mail.gmail.com  
Backpatch-through: 16  

M src/backend/commands/user.c
M src/backend/utils/adt/acl.c
M src/include/utils/acl.h
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Reject CLUSTER (ANALYZE).

commit   : ac5cea86e8a474e13d7dcd22a4a7fabf722c5514    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 13 Aug 2026 15:28:34 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 13 Aug 2026 15:28:34 -0500    

Click here for diff

The introduction of the REPACK command also added support for  
CLUSTER (ANALYZE).  Presumably this was unintentional, as the  
CLUSTER docs make no mention of it.  CLUSTER (ANALYZE) on an  
ordinary table succeeds and does indeed analyze the table, but a  
database-wide CLUSTER (ANALYZE) or one on a partitioned table  
fails with an error like:  
  
    ERROR:  cannot execute REPACK (ANALYZE) on multiple tables  
  
Rather than improving support for CLUSTER (ANALYZE) and thereby  
encouraging folks to use CLUSTER instead of REPACK, let's just  
reject it.  This commit does so by teaching ExecRepack() to ERROR  
for the ANALYZE option in anything except REPACK commands.  Note  
that VACUUM (FULL, ANALYZE) does not go through ExecRepack() and  
therefore is unaffected by this change.  
  
Oversight in commit ac58465e06.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFMVcgv1b2G-i%2Bkhs2MDnzWSr7O_53j_x%2BuhAxUV5rwWqw%40mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/repack.c

Consistently enforce tsvector/tsquery maximum lengths.

commit   : 957d4eae52eccbfb949fa043ae07527a69bcbcf6    
  
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 misc spelling mistakes in comments, docs and tests

commit   : 2ae459b08523ab110d1e2d60b46eb6bcd253bbdc    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 13 Aug 2026 15:04:40 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 13 Aug 2026 15:04:40 +0300    

Click here for diff

M contrib/test_decoding/specs/parallel_session_origin.spec
M doc/src/sgml/gist.sgml
M src/backend/access/transam/xlog.c
M src/backend/utils/cache/inval.c
M src/interfaces/libpq/t/003_load_balance_host_list.pl

Remove unnecessary #include <poll.h>

commit   : 776348900b40eb19766ebc88df034d368543707c    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 13 Aug 2026 15:03:22 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 13 Aug 2026 15:03:22 +0300    

Click here for diff

Commit cba5b994c9 removed the call to poll() that needed it.  

M src/backend/libpq/pqcomm.c

Fix missing hash_seq_term()

commit   : a2b64736bb657163dfb085f279b4e1272b647448    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 13 Aug 2026 15:03:15 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 13 Aug 2026 15:03:15 +0300    

Click here for diff

This was harmless because the function (ThereAreNoReadyPortals()) has  
only one caller, and that caller throws an error if the function  
returns false and transaction abort cleans up the in-progress hash  
searches.  But if someone called the function in some other way,  
they'd get a warning about a leaked hash_seq_search scan.  

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

pgcrypto: remove unused field mdc_checked from PGP_Context

commit   : e8a8ccc3ca192178fd3a179a06a91368008899dc    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 13 Aug 2026 13:18:12 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 13 Aug 2026 13:18:12 +0200    

Click here for diff

mdc_finish used to set this field once it had successfully verified  
the MDC packet, with its only reader in the same function.  This was  
removed by a59ee881978 when mdc_finish stopped being called through  
the pullf_read API, the field has been unused since.  
  
Note that MDC verification does not rely on it: process_data_packets  
tracks whether an MDC packet was seen in its local got_mdc variable  
and rejects the message if a required MDC is missing, while the  
use_mdcbuf_filter path checks the hash in mdcbuf_finish().  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Discussion: https://postgr.es/m/CAJ7c6TNmHnnCkn3uZwRUE7WWYftW--48JFoDVDqoZqMrLYxUZw@mail.gmail.com  

M contrib/pgcrypto/pgp-decrypt.c
M contrib/pgcrypto/pgp.h

vacuumdb: Use ANALYZE ONLY for partitioned tables

commit   : 72e6184cd5fe82620693a2aae9e34452d1984459    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 13 Aug 2026 14:22:39 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 13 Aug 2026 14:22:39 +0900    

Click here for diff

When vacuumdb --analyze-only or --analyze-in-stages enumerates  
tables itself, it can select both a partitioned table and its  
partitions as separate work items. Previously, it generated plain  
ANALYZE for the partitioned table, which recursively analyzed its  
partitions as well.  
  
This caused duplicate work when the partitions were already selected by  
vacuumdb. With --analyze-in-stages, the redundant work could be  
repeated at every stage.  
  
Fix this by generating ANALYZE ONLY for automatically selected  
partitioned tables when connected to servers that support it. This  
updates inherited statistics for the partitioned table while leaving  
per-partition statistics to the separately selected partition entries.  
For older servers that do not support ANALYZE ONLY, vacuumdb falls back  
to the previous plain ANALYZE command.  
  
This also applies when partitioned tables are selected by schema  
filters. In that case, partitions matching the filters are analyzed as  
separate targets, while per-partition statistics for partitions outside  
the filters are not updated via the partitioned parent.  
  
This commit does not change the behavior for partitioned tables  
specified explicitly with --table, i.e., in that case, vacuumdb  
continues to generate plain ANALYZE, recursively analyzing the specified  
partitioned table and its partitions.  
  
Suggested-by: Justin Pryzby <pryzby@telsasoft.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/aKZ7lMYGnnIo35c0@pryzbyj2023  
Backpatch-through: 19  

M src/bin/scripts/t/100_vacuumdb.pl
M src/bin/scripts/vacuuming.c
M src/tools/pgindent/typedefs.list

Doc: Clarify ALTER PUBLICATION's REFRESH PUBLICATION wording.

commit   : 8d795a365848bdd76f01a28c3b6d70d01526f3e4    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 13 Aug 2026 10:00:35 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 13 Aug 2026 10:00:35 +0530    

Click here for diff

The note used a confusing "tables/except tables/schemas" slash-list,  
omitted DROP from the operations requiring a subscriber refresh, and  
called out "unset ALL SEQUENCES" without its symmetric "unset ALL TABLES"  
case. Reword for clarity and consistency.  
  
Author: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAHut+PuGKrWhVMvuFyf-wSdF-Tai_jPTz2UCSCqsYM-82ATY5w@mail.gmail.com  

M doc/src/sgml/ref/alter_publication.sgml

doc: Clarify pgbench reporting with --continue-on-error

commit   : bcb15f48786df1c4c3c0428645b5b0c6da0f3cb7    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 13 Aug 2026 13:26:47 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 13 Aug 2026 13:26:47 +0900    

Click here for diff

Clarify that transactions failed under --continue-on-error are reported  
separately and are not counted as transactions actually processed, while  
time spent on them can lower reported TPS. Also adjust the latency  
description to avoid implying that failed transactions are generally included  
in latency measurements.  
  
Backpatch to v19, where pgbench's --continue-on-error option was introduced.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/597C9755-4386-488D-A289-16D50AD81FBF@gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ref/pgbench.sgml

Reject REPLICA IDENTITY USING INDEX on column with invalid NOT NULL

commit   : bdaad789c843f57b1fc66c5ede7abaff8a915c3b    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 12 Aug 2026 19:15:48 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 12 Aug 2026 19:15:48 +0200    

Click here for diff

ALTER TABLE ... REPLICA IDENTITY USING INDEX verified key columns by  
reading pg_attribute.attnotnull, but commit a379061a22a8 made  
attnotnull true also for unvalidated (NOT VALID) not-null constraints,  
which do not prove the column null-free.  An index over such a column  
could thus be marked as replica identity even though the column might  
contain NULLs, causing apply-side divergence for UPDATE/DELETE on the  
nullable rows.  
  
Fix by additionally requiring convalidated for the underlying  
constraint, mirroring the fix d9ffc27291f applied to ATExecAddIdentity  
for the analogous identity-column case.  
  
Author: Ante Krešić <ante@tigerdata.com>  
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Backpatch-through: 18  
Discussion: https://postgr.es/m/CABXQ4dJUibZzN91qvWmsfA7MUDn9YRCNyu3CcukdyokbH1=41Q@mail.gmail.com  

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

Fix float8_regr_accum() for Inf/NaN with constant other input.

commit   : 7774249d0b66fff0b60823783db24090981020ac    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 12 Aug 2026 12:48:53 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 12 Aug 2026 12:48:53 -0400    

Click here for diff

Commit 649828769 improved this code to keep Sxx, Syy, and Sxy  
exactly zero so long as we see only a single value of the input(s).  
However, if any values of the other input are Inf or NaN, we'd  
better set Sxy to NaN instead.  Otherwise we risk reporting zero  
variance when the result is really undefined.  The old coding handled  
this implicitly, but in the short-circuit path we have to take care  
of it explicitly.  
  
Bug: #19615  
Reported-by: Junwen An <feasiblechart@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19615-c7e390593416f6b6@postgresql.org  
Backpatch-through: 19  

M src/backend/utils/adt/float.c
M src/test/regress/expected/aggregates.out
M src/test/regress/sql/aggregates.sql

Avoid recalculating pgprocno in ProcArrayAdd()

commit   : aaf67e4825f32d764296fabfa3a86c4da90cec16    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 12 Aug 2026 16:48:21 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 12 Aug 2026 16:48:21 +0200    

Click here for diff

The value is already stored in a local variable a few lines above.  
This is just a cosmetic change.  
  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>  
Discussion: https://postgr.es/m/CAOzEurTJO2aqd9ewQmo9vjCrFUAD8Lk+raujCfK5oWoLGUP_3w@mail.gmail.com  

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

Fix stale comments/signature after commit 28d534e2ae0a

commit   : b495c5685a1ac436a0006aba464efcf0edb6153d    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 12 Aug 2026 11:53:10 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 12 Aug 2026 11:53:10 +0200    

Click here for diff

Commit db89a47115f0 added an 'options' argument to table_tuple_update()  
and table_tuple_delete(), correctly documenting it as recognizing no  
values.  It also (correctly) added pg_attribute_unused() to the  
corresponding heap_update() argument.  Commit 28d534e2ae0a then added  
TABLE_UPDATE_NO_LOGICAL and TABLE_DELETE_NO_LOGICAL, but failed to  
(correctly) update the comment and heap_update()'s signature.  
  
In table_tuple_update(), move the correct explanation of 'options' to  
the right place, remove the bogus one.  
  
In table_tuple_delete(), add the missing TABLE_DELETE_NO_LOGICAL doc.  
  
In heap_update(), remove the pg_attribute_unused() marker.  
  
Author: Nikhil Sontakke <nikhil@planetscale.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CA+UBoq21SzkjThYMSwSpVU-jwzpuEsf22Hq1FPbcKcDc43C29g@mail.gmail.com  

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

Add common LSN parser for user-supplied locations

commit   : d6bf0ab1704c62f94875d25dd71c4baa1feac5be    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 12 Aug 2026 17:03:46 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 12 Aug 2026 17:03:46 +0900    

Click here for diff

pg_waldump (--start/--end), pg_recvlogical (--startpos/--endpos), and  
pg_receivewal (--endpos) parsed user-supplied WAL locations with  
sscanf("%X/%08X").  That accepts several forms rejected by pg_lsn input  
and can proceed with a different location than the user specified:  
overlong components, trailing characters, leading whitespace, signs, and  
0x prefixes.  
  
Add pg_parse_lsn() to src/common and use it for those command-line  
options.  The helper accepts the pg_lsn text syntax only: one to eight  
hexadecimal digits, a slash, one to eight hexadecimal digits, and no  
trailing characters.  Each frontend tool keeps its existing error  
message.  
  
Use the same helper from pg_lsn_in_safe(), leaving only backend-specific  
soft error reporting there.  This keeps frontend command-line validation  
and backend pg_lsn input tied to one parser.  
  
Bug: #19598  
Reported-by: Michael Malis <malis@pgrust.com>  
Author: Zexin Li <lizi.openmind@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19598-aa67c8f4331611b4@postgresql.org  

M src/backend/utils/adt/pg_lsn.c
M src/bin/pg_basebackup/pg_receivewal.c
M src/bin/pg_basebackup/pg_recvlogical.c
M src/bin/pg_basebackup/t/020_pg_receivewal.pl
M src/bin/pg_basebackup/t/030_pg_recvlogical.pl
M src/bin/pg_waldump/pg_waldump.c
M src/bin/pg_waldump/t/001_basic.pl
M src/common/Makefile
M src/common/meson.build
A src/common/pg_parse_lsn.c
A src/include/common/pg_parse_lsn.h

Use per-query timeout in subscription test

commit   : 2eb9a8e84a53cd1a202a757d704139930bc19a96    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 12 Aug 2026 09:41:44 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 12 Aug 2026 09:41:44 +0200    

Click here for diff

A buildfarm failure in subscription/038_walsnd_shutdown_timeout was  
diagnosed to the background psql session timing out due to a backup  
taking a long time.  The session was using a single timeout for all  
queries, so switch to resetting the timer for each query to make it  
survive slow backups due to constrained buildfarm machines.  
  
Backpatch to v19 where the test was introduced.  
  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/OS9PR01MB12149AA18EEA475D2AA22FD3BF5D12@OS9PR01MB12149.jpnprd01.prod.outlook.com  
Backpatch-through: 19  

M src/test/subscription/t/038_walsnd_shutdown_timeout.pl

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

commit   : 6828b03b062bf9eee7b5e5e7ee1cedd4e174ab29    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 16:23:04 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 16:23:04 +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/PostgreSQL/Test/Cluster.pm

Remove unnecessary list_free() calls in OpenTableList().

commit   : cc1ea710dc88186aab4b3c129883d710781fcfb6    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 12 Aug 2026 11:28:30 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 12 Aug 2026 11:28:30 +0530    

Click here for diff

OpenTableList() is invoked at most once per DDL statement, from  
CreatePublication() and AlterPublicationTables(), and everything it  
builds (relids, relids_with_rf, and relids_with_collist) is allocated  
in the command's own memory context. That context is reclaimed as  
soon as the command finishes, so explicitly freeing relids and  
relids_with_rf here served no purpose.  
  
Reported-by: Peter Smith <smithpb2250@gmail.com>  
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>  
Author: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: shihao zhong <zhong950419@gmail.com>  
Reviewed-by: surya poondla <suryapoondla4@gmail.com>  
Discussion: https://postgr.es/m/CAHut+Pt3bgyt==d6GCj=p9qu4sVSH_KQWLN7cMaH0RdJCO-K_Q@mail.gmail.com  

M src/backend/commands/publicationcmds.c

Avoid unnecessary matview populated-state updates

commit   : 33c77cfad3e4d5749a5827f7c8c6394e7cab0b30    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 12 Aug 2026 14:42:57 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 12 Aug 2026 14:42:57 +0900    

Click here for diff

REFRESH MATERIALIZED VIEW currently calls SetMatViewPopulatedState()  
even when the materialized view's relispopulated value already matches  
the state requested by the command.  That performs a catalog update of  
pg_class without changing the visible state of the materialized view.  
  
The extra update creates a dead pg_class tuple and causes the usual  
catalog-update side effects, including relcache invalidation and WAL,  
for no semantic benefit.  The effect is especially visible for  
REFRESH MATERIALIZED VIEW CONCURRENTLY, where the refresh updates the  
materialized view contents with DML and otherwise need not change  
pg_class just to keep relispopulated set to true.  
  
Check the current populated state before calling SetMatViewPopulatedState(),  
and update pg_class only when the value would actually change.  This  
preserves the required state transitions for WITH DATA and WITH NO DATA  
while avoiding catalog churn for repeated refreshes that leave the  
populated state unchanged.  
  
Author: ChangAo Chen <cca5507@qq.com>  
Reviewed-by: Zizhuan Liu <44973863@qq.com>  
Reviewed-by: Adam Brusselback <adambrusselback@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/tencent_DF2D8533B5412908326F7806075B7637A108@qq.com  

M src/backend/commands/matview.c

Move index statistics into their own stats kind

commit   : 72a6dad1c9119c5ddebdb16d218213f4201f52a2    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 12:06:05 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 12:06:05 +0900    

Click here for diff

This commit splits the relation and index stats data, where the index  
data is now moved to a new kind called PGSTAT_KIND_INDEX.  A benefit of  
this refactoring is a reduction of the shared memory required for each  
index, the new PgStat_StatIdxEntry including only the fields required  
for indexes.  This leads to less data flushed to disk on shutdown.  
Another benefit is that the addition of new fields for relation-level  
stats is easier to think about.  Note that indexes have no need for most  
of the xact-level fields that relations care about, clarifying the role  
of each counter for each relkind.  
  
System views are updated to use the index-level functions.  Note this  
split means a possible break for tools that had the idea to call the  
SQL functions for relation stats (not documented), as now these would  
return 0 when queried for an index.  These tools can use the new index  
functions to achieve the same result.  
  
As of this change, the pending statistics are still controlled by  
PgStat_TableStatus for both relation and index kinds.  This is left as a  
follow-up piece, this one being good enough on its own.  This commit is  
focused on the changes required for the SQL interface, shared memory  
management and the on-disk format.  
  
Bump catalog version.  
Bump PGSTAT_FILE_FORMAT_ID.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/f572abe7-a1bb-e13b-48c7-2ca150546822@gmail.com  

M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/utils/activity/Makefile
M src/backend/utils/activity/meson.build
M src/backend/utils/activity/pgstat.c
A src/backend/utils/activity/pgstat_index.c
M src/backend/utils/activity/pgstat_relation.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h
M src/include/utils/pgstat_internal.h
M src/include/utils/pgstat_kind.h
M src/test/regress/expected/rules.out
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql
M src/tools/pgindent/typedefs.list

commit   : feb15361b34a1bbbc586ee3dc0ad970f6434aad3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 09:45:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 09:45:03 +0900    

Click here for diff

KeepFileRestoredFromArchive() has been using an incorrect WAL segment  
name in the error report for an unlink() failure.  
  
Even without 1200dfd60c36, this was of consequence only on WIN32, where  
we would miss to report a segment name suffixed by ".deleted%u".  
  
Oversight in 60df192aea0e, for what looks like a copy-pasto to me.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwHSbJnUmWCuF-QNUsGYF=iSSuzLRx1z_dLfYFwfbTu4Cw@mail.gmail.com  

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

Improve GrantLockLocal() handling on out-of-memory errors

commit   : afd63e0ad23ed826aa953977a5306a3703503afa    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 09:09:58 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 12 Aug 2026 09:09:58 +0900    

Click here for diff

On the first LockAcquire for a lock tag, LockAcquireExtended() creates  
a LOCALLOCK entry in the hash table LockMethodLocalHash, with lockOwners  
set to NULL.  lockOwners is then allocated in TopMemoryContext.  
  
If the allocation fails, the hash entry would persist with lockOwners  
still NULL and maxLockOwners already set to 8.  A follow-up  
LockAcquire() on the same entry would crash on a NULL pointer  
dereference.  
  
This commit adds an extra layer of safety for such a case, by  
re-attempting MemoryContextAlloc() if a LOCALLOCK entry exists but its  
lockOwners is still NULL due to a previous in-flight allocation failure.  
  
This problem is unlikely going to show up in practice, so no backpatch  
is done.  
  
Author: Bryan Green <dbryan.green@gmail.com>  
Author: Mark Dilger <mark.dilger@enterprisedb.com>  
Discussion: https://postgr.es/m/c9a5eeb1-4d31-46e1-bb9e-33448a23a5d3@gmail.com  

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

Change wal_compression=on to the first of zstd, lz4, pglz

commit   : 931c9701f2509160a2bed7d50129669e2cb32bf9    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Wed, 12 Aug 2026 01:08:21 +0200    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Wed, 12 Aug 2026 01:08:21 +0200    

Click here for diff

Previously, wal_compression=on was an alias for pglz, with the  
assumption that users could make an informed choice to pick a better  
option. But in practice, users rarely got to that second step.  
  
Many users don't want to be choosing algorithms - they just want WAL  
compression, and expect that to work well. The configuration parameter  
is set by administrators, who do not control the workload, and so are  
not in a position to evaluate the options anyway. Some users may not  
even realize there are other options, as previously "on" was the only  
choice available.  
  
This change maps "on" to non-pglz options, supported by the build. Both  
lz4 and zstd are faster, with a comparable (or better) compression  
ratio. We prefer zstd over lz4 - per our testing the better compression  
ratio pays for the lower (de)compression speed.  
  
Like for TOAST compression, the value depends on algorithms supported by  
the PostgreSQL build, with lz4 and zstd being optional. But most builds  
will have at least one of these external libraries. If neither zstd or  
lz4 is supported, we fallback to pglz.  
  
This only affects what "on" means. Users can still make the informed  
choice and explicitly select a compression algorithm if it works better  
for their system. The default value for "wal_compression" remains "off."  
  
Initial proposal and patch by wenhui qiu, reviews and patch adjustments  
by Christoph Berg. A number of other people participated in the  
discussion. Benchmarks by me.  
  
Backpatch to 19.  
  
Author: wenhui qiu <qiuwenhuifx@gmail.com>  
Reviewed-by: Christoph Berg <myon@debian.org>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAGjGUAL1b=Mwd1SCvLbo+fivEr9KDpFcu4jmqKCZXwT=6CiiGQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/config.sgml
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/access/xlog.h

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

commit   : 040932c3114657bb53a7a62210ef01a83108d6b4    
  
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

libpq: remove unused field ssl_handshake_started from PGconn

commit   : bc86dc738e0e4c56a0635efd3d18b367b7e41f9b    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 11 Aug 2026 21:53:59 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 11 Aug 2026 21:53:59 +0200    

Click here for diff

The ssl_handshake_started field was added by d39a49c1e45 to allow  
connection_failed() skip retrying with a different SSL negotiation  
method, once the server had reported an error after the TLS handshake  
had already started.  That logic was dropped by fb5718f35ff, which  
removed the ability to fall back from direct to negotiated SSL, and  
with it the only consumer of the data in this field.  Fix by removing  
the field.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAJ7c6TPkHjVFERp1Fd-idMe=iRJnDX2Nzy_ZOkV=y4OLLgf89Q@mail.gmail.com  

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

Use frontend logging API in fe_utils/string_utils.c

commit   : 1d1d7b0e9c99a6c7b2bb874b5c7f6806e5940f04    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    

Click here for diff

This simplifies error message printing a bit.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/c855d318-4545-4dc7-b466-2e24fbf64725%40eisentraut.org  

M src/fe_utils/string_utils.c

Make printTableAddCell/printTableAddHeader string argument const

commit   : c83a133f2bb531fe56284e35809c14eed1d8bd6e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    

Click here for diff

These functions would sometimes overwrite the string argument they are  
passed, namely via mbvalidate(), which removes invalid UTF-8  
characters (or potentially analogously in other encodings, but that is  
not implemented).  However, many callers are not expecting that.  In  
many callers, the input value comes directly from libpq structures,  
such as from PQgetvalue() or PQsslAttribute().  The latter actually  
has a const char * return type, and that was cast away.  But even the  
former is not expecting its return value to be modified.  
  
Fix that by making these arguments const.  Internally, we add a  
separate function that does only the checking part of mbvalidate().  
Only if the validation returns a negative result, we make a copy and  
run mbvalidate() on the copy.  printTableAddCell() already had  
internal infrastructure for keeping track of what values needed to be  
freed.  We add the same for printTableAddHeader().  
  
In passing, also simplify the code a bit.  There were essentially  
duplicate mechanisms for keeping track of the most recently added  
cell (fields .cell and .cellsadded).  Make that consistent by using an  
integer counter for everything.  That makes the code arguably easier  
to read than with the "current pointer" approaches.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/c855d318-4545-4dc7-b466-2e24fbf64725%40eisentraut.org  

M src/bin/psql/command.c
M src/fe_utils/mbprint.c
M src/fe_utils/print.c
M src/include/fe_utils/mbprint.h
M src/include/fe_utils/print.h

Use frontend logging API in fe_utils/print.c

commit   : 59aec847fc187cfe9000fcb071c32ac38bf71948    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    

Click here for diff

This simplifies error message printing a bit.  Also adjust the error  
messages a bit for style, while we're here.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/c855d318-4545-4dc7-b466-2e24fbf64725%40eisentraut.org  

M src/fe_utils/print.c

Remove useless ENABLE_NLS conditionals

commit   : 0a92b9b76295cac6ec2ba445523d9422592f0cef    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    

Click here for diff

This already works even without those conditionals, since _() expands  
to a no-op if NLS is disabled.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/c855d318-4545-4dc7-b466-2e24fbf64725%40eisentraut.org  

M src/fe_utils/print.c

Remove useless/confusing const qualifiers

commit   : 370f3366c4c214abb0c34b2e2bd7fd42802112bf    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Aug 2026 09:21:34 +0200    

Click here for diff

The const qualifiers removed here did not qualify what is being  
pointed to, which is the normal use in function prototypes.  Instead,  
they qualify the variable itself, so that it cannot be changed inside  
the function.  That is itself not wrong, but it's not a normal style,  
and it seems distracting here.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/c855d318-4545-4dc7-b466-2e24fbf64725%40eisentraut.org  

M src/bin/psql/describe.c
M src/fe_utils/print.c
M src/include/fe_utils/print.h

Show estimated number of groups for Incremental Sort in EXPLAIN

commit   : d29d469becec1f2ac082d82863ae1c29fca9dd97    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 11 Aug 2026 13:30:07 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 11 Aug 2026 13:30:07 +1200    

Click here for diff

Incremental Sort's costs heavily depend on the estimated number of input  
groups with equal presorted key values.  Overestimations can cause the  
planner to choose Incremental Sort over Sort when Sort would have  
been a better choice.  
  
Here, we add the planner's estimate to EXPLAIN to allow easier  
understanding of why Incremental Sort has been chosen.  
  
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>  
Reviewed-by: Enrique Sánchez <enriqueesanchz@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/10682fef-3748-43f5-a932-7adcdd9bd2b8%40tantorlabs.com  

M doc/src/sgml/perform.sgml
M src/backend/commands/explain.c
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/pathnode.c
M src/include/nodes/pathnodes.h
M src/include/nodes/plannodes.h
M src/include/optimizer/cost.h

psql: Don't do backquote expansion in \unrestrict.

commit   : 086f6f1760140a0055c2faa8d6831fd3ebaf96b0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

This oversight in commit 71ea0d6795 allows a malicious server to  
inject shell commands into plain-text dump output that are run at  
restore time on the machine running psql.  To fix, interpret all  
text after \unrestrict until the end of the line as its argument.  
  
Reported-by: Lucas Velgus <velgusgus599@gmail.com>  
Reported-by: Filip Janus <fjanus@redhat.com>  
Reported-by: Daniel Bakker <daniel@jackds.nl>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Security: CVE-2026-18408  
Backpatch-through: 14  

M doc/src/sgml/ref/psql-ref.sgml
M src/bin/psql/command.c
M src/bin/psql/t/001_basic.pl

pgcrypto: Add option to revert to prior decryption behavior

commit   : 49e795414848bbd1f5122f64c0645827d8d90313    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

The previous commit raises an ERROR during PGP operations if OpenSSL  
does not support the cipher in use. However, any existing messages  
created with faulty encryption will no longer be accessible via  
pgp_[sym|pub]_decrypt().  
  
To help users out of this situation, add a new ignore-cipher-failure  
option which reverts to the broken behavior during decryption only. A  
faulty encryption wrapper, created by an OpenSSL configuration that does  
not support the cipher, can then be stripped back off by that same  
OpenSSL in order to safely reencrypt it. (Note that when OpenSSL does  
support the cipher, corrupted messages will not be decrypted regardless  
of the ignore-cipher-failure setting; this is unchanged.)  
  
The new tests add a corrupted Blowfish message for both public- and  
symmetric-key decryption, resulting in the following test matrix:  
  
- Blowfish supported, default behavior:      fails to decrypt  
- Blowfish supported, ignore-cipher-failure: fails to decrypt  
- Blowfish unsupported, default behavior:    fails to load cipher  
- Blowfish unsupported, ignore-cipher-failure: strips faulty encryption  
  
The previous commit's change to the pubkey tests is expanded similarly:  
correctly encrypted messages cannot be decrypted by an OpenSSL that does  
not support the cipher, regardless of the option's setting, though the  
failure mode will change.  
  
Suggested-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Security: CVE-2026-14663  
Backpatch-through: 14  

M contrib/pgcrypto/expected/pgp-decrypt.out
M contrib/pgcrypto/expected/pgp-decrypt_1.out
M contrib/pgcrypto/expected/pgp-info.out
M contrib/pgcrypto/expected/pgp-pubkey-decrypt.out
M contrib/pgcrypto/expected/pgp-pubkey-decrypt_1.out
M contrib/pgcrypto/pgp-cfb.c
M contrib/pgcrypto/pgp-decrypt.c
M contrib/pgcrypto/pgp-encrypt.c
M contrib/pgcrypto/pgp-pgsql.c
M contrib/pgcrypto/pgp-pubkey.c
M contrib/pgcrypto/pgp.c
M contrib/pgcrypto/pgp.h
M contrib/pgcrypto/sql/pgp-decrypt.sql
M contrib/pgcrypto/sql/pgp-pubkey-decrypt.sql
M doc/src/sgml/pgcrypto.sgml

Fix errorhandling for PGP encryption

commit   : d0ecee6de9afec143a4766a72df0d3018a06d662    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

PGP encryption was using px_cipher_encrypt without checking if any  
error was returned.  When OpenSSL is running in FIPS mode, or when  
the legacy provider hasn't been loaded, not all ciphers which are  
supported by the PGP code are available and fail the init step in  
px_cipher_encrypt.  Since the PGP encryption failed to notice this  
it XORed the non-encrypted block with the plaintext, effectively  
disabling the encryption.  
  
This was found due to a report of PGP encryption not respecting  
the pgcrypto.builtin_crypto_enabled flag and allowing Blowfish  
and DES.  This however turned out to be a false positive, since  
the PGP code only use ciphers from OpenSSL and not the built in  
ciphers.  
  
Bug: #19457  
Reported-by: Shishir Sharma <ansh01072001@gmail.com>  
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>  
Discussion: https://postgr.es/m/19457-4bab15c17aea36c7@postgresql.org  
Security: CVE-2026-14663  
Backpatch-through: 14  

M contrib/pgcrypto/expected/pgp-decrypt_1.out
A contrib/pgcrypto/expected/pgp-encrypt_1.out
M contrib/pgcrypto/expected/pgp-pubkey-decrypt_1.out
M contrib/pgcrypto/pgp-cfb.c
M doc/src/sgml/pgcrypto.sgml

Fix out-of-bound reads with ascii() for invalid multibyte characters

commit   : a16c31d39c8bc1ed979b1b778238e3e1e72a311f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

This commit addresses two defects in this SQL function, the code  
assuming that:  
- The user-supplied string was long enough to contain a character of the  
length implied by the first byte.  It is possible to provide in input  
data that was able to disclose a few bytes of server memory, allowing  
out-of-bound reads.  
- Specific bytes had values within the expected range, using a set of  
assertions to validate them.  The assertions could be triggered on  
invalid input.  These are replaced by tests and error reports.  
  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-18024  

M src/backend/utils/adt/oracle_compat.c
M src/test/regress/expected/encoding.out
M src/test/regress/sql/encoding.sql

Teach psql to skip in-line COPY ... FROM STDIN data after a failure.

commit   : 3045a25ba813b554e23c723ebe94cf504feb370c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

If the COPY command fails before sending PGRES_COPY_IN, psql did  
not realize that it ought to consume any in-line data following  
the command.  Failing to do so leads to trying to execute that  
data as SQL commands, which in the best case is wrong and in the  
worst case is a SQL-injection hazard.  
  
To fix:  
  
1. Extend psqlscan.l to recognize COPY ... FROM STDIN.  This can  
be done with a pretty simple extension to the logic that already  
recognizes nested BEGIN blocks within CREATE FUNCTION et al.  
But unlike that case, we need to consider and count multiple COPY  
commands within a single query string (separated by "\;").  The  
fallout from that is that psql_scan_reset must now always be called  
before starting a new query string.  (The comment for it that claimed  
we didn't need that because "the scan state must be INITIAL" was  
really obsolete already, since it has long reset more state besides  
start_state.)  
  
2. Teach handleCopyIn() to read and discard data when passed  
NULL for "conn".  
  
3. Add logic to SendQuery() to call handleCopyIn() that way  
if the query string contained COPY ... FROM STDIN command(s)  
that remain unaccounted-for at the end.  
  
Now that we have this counting logic, we can also detect  
if the backend sends an unexpected PGRES_COPY_IN message.  
That should never happen, but perhaps a malicious server  
could try to extract data that way.  
  
A side-effect of doing this is that we have to adjust a number of test  
scripts that thought they needn't write "\." after a COPY FROM STDIN  
that they expect to fail.  On the whole this is an improvement, since  
there's now a uniform rule "write \. after COPY FROM STDIN, whether  
you expect it to work or not".  But it is an annoying amount of test  
churn.  
  
A loose end in this patch is that if it has to skip data, it assumes  
that that data is text not binary.  It seems unduly difficult to  
detect whether the COPY command requested binary (we could handle the  
old-style COPY BINARY ... syntax, but not the new style with format  
options).  In practice, copying in-line binary data is unsupported  
anyway, because there's no way to write an end marker: the textual  
terminator sequence "\n\\.\n" could appear in binary data and there's  
no provision for escaping it, so neither psql nor the server look for  
it when in binary mode.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 14  
Security: CVE-2026-6464  

M src/bin/psql/common.c
M src/bin/psql/common.h
M src/bin/psql/copy.c
M src/bin/psql/mainloop.c
M src/bin/psql/psqlscanslash.l
M src/bin/psql/startup.c
M src/fe_utils/psqlscan.l
M src/include/fe_utils/psqlscan.h
M src/include/fe_utils/psqlscan_int.h
M src/test/regress/expected/copy.out
M src/test/regress/expected/psql.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/copy.sql
M src/test/regress/sql/copy2.sql
M src/test/regress/sql/copyselect.sql
M src/test/regress/sql/generated_stored.sql
M src/test/regress/sql/generated_virtual.sql
M src/test/regress/sql/privileges.sql
M src/test/regress/sql/psql.sql
M src/test/regress/sql/rowsecurity.sql

Save/restore more lexer state when skipping text due to \if.

commit   : cf754f7414ba6159733ee9cdffde90a3cee3c32c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

When we implemented \if ... \endif in psql, we arranged to  
save/restore the lexer's parenthesis depth counter across any chunk  
of input that we're ignoring.  At the time, that was sufficient,  
because no other part of PsqlScanState could need to be restored to  
its prior value.  However, commit e717a9a18 and follow-ons added  
more state fields that ought to be restored to their prior values.  
A problem would only be observed if someone tries to \if out a  
portion of a CREATE FUNCTION/PROCEDURE command that is relevant to  
BEGIN/END matching, which seems like a pretty unusual usage, so the  
lack of field reports isn't surprising.  Nonetheless it's a bug.  
  
To fix, replace the simple counter field in ConditionalStack  
entries with a pointer to a struct defined by psqlscan_int.h.  
(In the back branches, keep the old field and associated functions  
to minimize the risk of API/ABI breakage, even though it seems  
unlikely that any third-party code is using this.  Making the  
new struct private to psqlscan-related code should prevent API/ABI  
issues for future additions of this type.)  
  
In itself this is only a minor bug fix, but it's prerequisite  
infrastructure for the fix for CVE-2026-6464, which will add  
another such field.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 14  
Security: CVE-2026-6464  

M src/bin/psql/command.c
M src/bin/psql/psqlscanslash.h
M src/bin/psql/psqlscanslash.l
M src/fe_utils/conditional.c
M src/include/fe_utils/conditional.h
M src/include/fe_utils/psqlscan.h
M src/include/fe_utils/psqlscan_int.h
M src/test/regress/expected/psql.out
M src/test/regress/sql/psql.sql
M src/tools/pgindent/typedefs.list

Invalidate plan cache after role changes.

commit   : ffca23839ccaaf8aed5e0729cb041b53f981f04c    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

Role membership, role attribute, and database ownership changes may  
impact the expected behavior of row-level security policies, but  
currently the plan cache doesn't take notice.  To fix, register  
syscache callbacks on pg_auth_members, pg_authid, and pg_database  
that invalidate the role-dependent plans.  Changes to other  
databases' pg_database rows are ignored.  
  
Reported-by: Ilya Staroverov <i.staroverov@ftdata.ru>  
Reported-by: Shinya Kato <shinya11.kato@gmail.com>  
Author: Ilya Staroverov <i.staroverov@ftdata.ru>  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Security: CVE-2026-14666  
Backpatch-through: 14  

M src/backend/utils/adt/acl.c
M src/backend/utils/cache/plancache.c
M src/include/utils/acl.h

Check for USAGE privilege on the composite type in ALTER TABLE OF.

commit   : 53ed5ebd84fb24cae5bc6cc5a6d75edcecc9884b    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

This omission allowed roles without USAGE on a type to create  
tables that depend on it, which could prevent the owner from  
changing the type later.  
  
Reported-by: Nathan Bossart <nathandbossart@gmail.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Security: CVE-2026-6470  
Backpatch-through: 14  

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

Check for USAGE privilege on types used by stored expressions.

commit   : 4fac4c1085ab12a811f2285b189979e844ceb670    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:50 -0700    

Click here for diff

This omission allowed roles without USAGE on a type to create  
stored expressions that depend on it, which could prevent the owner  
from changing the type later.  
  
The checks deliberately live in the command paths rather than the  
dependency-recording routines.  Those routines also run whenever  
the server re-derives an existing expression, and re-checking there  
would break routine maintenance for an owner who has since lost  
USAGE on a type its objects already reference.  (Checking in the  
dependency-recording routines would also require additional  
CommandCounterIncrement() calls to avoid spurious errors.)  
  
The addition of a parameter to AlterDomainAddConstraint() breaks  
ABI compatibility, but we are unaware of any impacted third-party  
code.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Security: CVE-2026-6470  
Backpatch-through: 14  

M src/backend/catalog/dependency.c
M src/backend/catalog/heap.c
M src/backend/catalog/index.c
M src/backend/catalog/pg_attrdef.c
M src/backend/catalog/pg_constraint.c
M src/backend/catalog/pg_proc.c
M src/backend/catalog/pg_publication.c
M src/backend/catalog/pg_type.c
M src/backend/commands/indexcmds.c
M src/backend/commands/policy.c
M src/backend/commands/propgraphcmds.c
M src/backend/commands/statscmds.c
M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/commands/typecmds.c
M src/backend/parser/parse_utilcmd.c
M src/backend/rewrite/rewriteDefine.c
M src/backend/tcop/utility.c
M src/include/catalog/dependency.h
M src/include/commands/typecmds.h
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Check for USAGE privilege on the subtype in CREATE TYPE AS RANGE.

commit   : a9f6e768ac281aa1adba58d3e9c7c2b4e9474ec2    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

This omission allowed roles without USAGE on a type to create range  
types that depend on it, which could prevent the owner from  
changing the type later.  
  
Reported-by: Jingzhou Fu <fuboat@outlook.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Security: CVE-2026-6470  
Backpatch-through: 14  

M doc/src/sgml/ref/create_type.sgml
M src/backend/commands/typecmds.c
M src/test/regress/expected/rangetypes.out
M src/test/regress/sql/rangetypes.sql

Avoid overflow in Levenshtein distance calculations.

commit   : 918683d12d849a514cd38056aab882322c74adb4    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

levenshtein() and levenshtein_less_equal() let the caller specify  
the insertion, deletion, and substitution costs, and  
fuzzystrmatch's corresponding SQL functions accept any 32-bit  
integer for each.  Since the distances are calculated with 32-bit  
arithmetic, large costs can cause overflows, thereby producing  
nonsensical results.  Certain inputs to levenshtein_less_equal()  
can even cause out-of-bounds writes.  To fix, use 64-bit arithmetic  
instead, and error whenever the final result won't fit in the  
returned 32-bit integer.  
  
We may want to teach these functions to reject negative costs, too,  
but that didn't seem appropriate for a security fix, and therefore  
it is left as a future exercise.  
  
Reported-by: Ben Morris in collaboration with Claude and Anthropic Research  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>  
Security: CVE-2026-15742  
Backpatch-through: 14  

M contrib/fuzzystrmatch/expected/fuzzystrmatch.out
M contrib/fuzzystrmatch/sql/fuzzystrmatch.sql
M src/backend/utils/adt/levenshtein.c
M src/backend/utils/adt/varlena.c

Cross-check the type of a portal running EXECUTE or FETCH.

commit   : 9e02e2e18224e284af99ab1b5818d7974db12426    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

When an EXECUTE or FETCH statement is executed, there are two portals:  
an outer portal that is created for the EXECUTE or FETCH statement itself,  
and an inner portal for the statement being executed on its behalf.  
Before this commit, nothing checked that these two portals agreed on  
the tuple descriptor of the rows being returned. This can be leveraged  
to disclose server memory contents and achieve arbitrary code execution.  
  
To prevent that, we can make use of an existing safety mechanism,  
added by Tom Lane in commit 2f48ede080f42b97b594fb14102c82ca1001b80c,  
which allows a tuplestore DestReceiver to be informed of the tupleDesc  
required by the caller, and which will cause an ERROR to occur if  
that doesn't match the tupleDesc of what emerges from the executor  
(modulo dropped columns, which aren't an issue in the case at hand).  
  
Reported-by: Ben Morris in collaboration with Claude and Anthropic Research  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Security: CVE-2026-16239  

M src/backend/tcop/pquery.c

Add an output_plugin_libraries GUC to bless trusted output plugins

commit   : 226e49cbed592eaf7a08320efecb814b7492972e    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

REPLICATION users were not previously subject to restrictions on output  
plugin paths, so they were able to bypass LOAD-time protections during  
logical decoding. Unfortunately, adding the standard LOAD restrictions  
now would retroactively require all third-party output plugins to be  
installed under the $libdir/plugins directory. This would prevent the  
use of dynamic_library_path, introduce a wire incompatibility for  
clients, and require all plugin authors to check that their libraries  
are safe for use by any unprivileged user; we want to avoid that.  
  
Instead, introduce an output_plugin_libraries GUC so that DBAs can  
specify the output plugins that are trusted for use in logical decoding.  
For simplicity, superusers are subject to the restriction as well  
(though they're free to modify the GUC at will during a session, so no  
power is actually lost).  
  
The default setting is 'pgoutput, test_decoding'. If other third-party  
plugins are in use, DBAs will need to modify this parameter after they  
update. Some pointers have been added to the documentation to assist  
with this.  
  
Author: Jacob Champion <jacob.champion@enterprisedb.com>  
Reported-by: Vladimir Tokarev <vladimirelitokarev@gmail.com>  
Reported-by: Yu Kunpeng <yu443940816@live.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-6471  

M contrib/test_decoding/expected/permissions.out
M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/expected/slot.out
M contrib/test_decoding/sql/permissions.sql
M contrib/test_decoding/sql/slot.sql
M doc/src/sgml/config.sgml
M doc/src/sgml/logical-replication.sgml
M src/backend/replication/logical/logical.c
M src/backend/replication/pgrepack/pgrepack.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/misc/postgresql.conf.sample
M src/bin/pg_dump/dumputils.c
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/t/003_logical_slots.pl
M src/include/replication/logical.h
M src/test/subscription/t/100_bugs.pl

Move SplitGUCList() to fe_utils

commit   : 20e9dcefdc292d23597209248a4eef01640e6e4a    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

This is needed so that all versions of pg_upgrade that migrate logical  
replication slots can parse the new output_plugin_libraries GUC.  
  
Backpatch-through: 17  
Security: CVE-2026-6471  

M src/backend/utils/adt/varlena.c
M src/bin/pg_dump/dumputils.c
M src/bin/pg_dump/dumputils.h
M src/fe_utils/string_utils.c
M src/include/fe_utils/string_utils.h

Empty search_path in amcheck.

commit   : 0fbf785b13e6d8db093adc98fcbf8fd6d1642b80    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

A grantee of amcheck function EXECUTE privilege could execute arbitrary  
functions as the owners of expression indexes that depend on the search  
path.  An expression like (lower(col)) was not vulnerable, because  
lower() is resolved at CREATE INDEX time.  However, an expression  
calling an sql-language or plpgsql-language function often was  
vulnerable, even if it used search_path only to find objects in  
pg_catalog.  The amcheck documentation has been warning about data  
disclosure after such a GRANT, not about function execution.  
  
This might cause new amcheck errors when index expressions rely on a  
broader search_path.  Such indexes have seen errors during auto-analyze  
since CVE-2018-1058 commit 582edc369cdbd348d68441fc50fa26a84afd0c1a, and  
v17 amcheck always worked this way.  Hence, the risk is low.  
  
Leave a comment on the one other sandbox entrance that doesn't empty  
search_path.  In its case, the choice was valid.  
  
Back-patch to v14 (all supported versions), but v17 was safe already.  
Commit 2af07e2f749a9208ca1ed84fa1d8fe0e75833288 (v17) unintentionally  
blocked the attack, and commit d70b17636ddf1ea2c71d1c7bc477372b36ccb66b  
(v18) unintentionally removed that protection.  Hence, this adds to v17  
just a test and a comment.  While emptying search_path became more  
widespread in commit 2af07e2f749a9208ca1ed84fa1d8fe0e75833288 (v17),  
none of its other changes blocked an attack available in v16, even when  
considering GRANT.  For example, brin_summarize_range() has had an owner  
check that GRANT does not override.  
  
Reported-by: 王跃林 <violin0613@tju.edu.cn>  
Reported-by: Jacob Brazeal <jacob.brazeal@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-14673  

M contrib/amcheck/expected/check_btree.out
M contrib/amcheck/sql/check_btree.sql
M contrib/amcheck/verify_common.c
M src/backend/utils/init/usercontext.c

Use value of scram_iterations in mock_scram_secret().

commit   : feb8b0182ffa38a51fb6b964bd5b97dd666d4da0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

Presently, mock_scram_secret() always uses  
SCRAM_SHA_256_DEFAULT_ITERATIONS, which poses an observable  
response discrepancy hazard when scram_iterations is set to  
something else.  To fix, use the value of the configuration  
parameter instead, and document that unauthenticated users can  
discover the existence of roles with passwords created with  
different iteration counts.  
  
Reported-by: Radim Marek <radim@boringsql.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Jacob Champion <champion.p@gmail.com>  
Security: CVE-2026-14672  
Backpatch-through: 16  

M doc/src/sgml/config.sgml
M src/backend/libpq/auth-scram.c

Obstruct EXTRACT() field name deparse injection.

commit   : f9729b5078dca08f5c873ca063f0449e8bb3f256    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

The parser accepts any string as an EXTRACT() field name, but  
deparsing does not quote and escape it accordingly.  To fix, quote  
and escape the field name during deparsing as needed.  It might be  
a good idea to validate the field name during parsing and  
deparsing, too, but that is left as a future exercise.  
  
Reported-by: Ben Morris in collaboration with Claude and Anthropic Research  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Security: CVE-2026-15741  
Backpatch-through: 14  

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

Fix multirange type handling in pg_restore_attribute_stats()

commit   : 57835938fa9a73db432f9d822649dd9824c3991b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

statatt_get_type() unconditionally converted multirange types to their  
underlying range type.  This choice affected all the type information,  
like atttypid, atttyptype and operators.  
  
This made the bounds histogram work correctly (range type is required),  
but it was wrong for all the other stat kinds.  MCV values for a  
multirange column should be parsed as multirange arrays, not range  
arrays.  It also made the TYPTYPE_MULTIRANGE check for the range stats  
validation as dead code, since atttyptype was always TYPTYPE_RANGE  
after the conversion due to the centralized statatt_get_type().  
  
pg_restore_extended_stats() handles the same case correctly: it keeps  
the original type and explicitly converts to the range type only at the  
point where range_histogram_bounds is built.  
  
The fix of this issue is simple: the multirange-to-range conversion  
needs to be moved from the centralized statatt_get_type() up to where  
attribute stats build their range_histogram_bounds, matching what is  
done for extended statistics restore.  
  
The regression tests for multiranges with attribute stats are extended  
to cover this case.  
  
Author: OpenAI Security Research Team  
Backpatch-through: 18  
Security: CVE-2026-16238  

M src/backend/statistics/attribute_stats.c
M src/backend/statistics/stat_utils.c
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql

Reject GSSEncRequest after direct SSL connection

commit   : 3bf185b4bb67e340327276ddf3ae3f9da8034a54    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

When a direct SSL connection was established, ProcessStartupPacket()  
still accepted GSSEncRequest messages.  The GSSAPI negotiation would  
then use raw writes and reads, bypassing the TLS encryption layer.  
After the GSS encryption was established, the connection continued to  
use TLS.  This could betray the HBA rules so as the backend does  
protocol exchanges inconsistent with the connection policies in place,  
with TLS taking priority over GSS in the backend.  
  
The SSL negotiation path already guarded against attempts to request  
SSL after a direct SSL request has been processed.  The GSS path is now  
guarded the same way when receiving a startup packet.  
  
Reported-by: p4p3r <kbfanta@naver.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Jacob Champion <champion.p@gmail.com>  
Backpatch-through: 17  
Security: CVE-2026-14681  

M src/backend/tcop/backend_startup.c

ecpg: Fix out-of-bound writes due to processing of invalid bytea data

commit   : c7da85fec96666b038fdf83c81dbe1e1573a9e60    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

ECPG assumes that any bytea data it receives from a backend starts with  
'\x' as its first two bytes, but a check was missed to enforce that.  A  
rogue server sending some garbage bytea data would be able to crash a  
client, resulting in a client-side DoS, in the most common cases.  
  
Reported-by: ylwangtju <ylwangtju@qq.com>  
Backpatch-through: 14  
Security: CVE-2026-16241  

M src/interfaces/ecpg/ecpglib/data.c
M src/interfaces/ecpg/ecpglib/error.c
M src/interfaces/ecpg/include/ecpgerrno.h
M src/interfaces/ecpg/test/expected/sql-bytea.c
M src/interfaces/ecpg/test/expected/sql-bytea.stderr
M src/interfaces/ecpg/test/sql/bytea.pgc

Use palloc_array() in pltcl and plperl to avoid overflow

commit   : 776467301ea9edff9d1f5be975a5da6b2229ac77    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:49 -0700    

Click here for diff

Some of these could overflow on 32-bit systems with the right input.  
Convert all cases where we called palloc() with multiplication to fix  
them. Not all of them were bugs, but it's better to be safe than  
sorry.  
  
Reported-by: Tulya Project, Team Dhiutsa, Bitecope Technologies Private Ltd  
Backpatch-through: 14  
Security: CVE-2026-14677  

M src/pl/plperl/SPI.xs
M src/pl/plperl/plperl.c
M src/pl/tcl/pltcl.c

Fix pg_trgm's picksplit function with all-true datums

commit   : 66c2dbb20445195f92225708a930112ee9e96bf4    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

The CACHESIGN.sign field is a BITVECP, not a TRGM, so you should not  
use GETSIGN() on it. You don't get a compiler warning because the  
GETSIGN() macro includes a cast. It resulted in a bogus read beyond  
end of buffer, which would cause bad split decisions or a crash if  
you're very unlucky.  
  
Reported-by: Mehmet D. INCE <mehmet@mehmetince.net>  
Backpatch-through: 14  
Security: CVE-2026-14678  

M contrib/pg_trgm/trgm_gist.c

pg_stat_statements: Fix buffer overflow with query normalization

commit   : 1e2795ddeafc66cd78d2c90a69dd820488639c7c    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

Since commit 62d712ecfd94, pg_stat_statements has been underestimating  
the size of the result buffer possible for a normalized query, in cases  
where the query includes many squashable lists, causing the normalized  
query to write past the allocated area.  
  
The allocated buffer size forgot to account for the comment appended in  
a squashable list, "/*, ... */".  Instead of trying to track down  
precisely how much space we need, fix by switch to using an expansible  
StringInfo.  This not only fixes the bug, but it also makes the code  
simpler to follow.  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Reported-by: Sajeeb Lohani with TrendAI Zero Day Initiative  
Reported-by: Yuelin Wang <3020001251@tju.edu.cn>  
Diagnosed-by: Michaël Paquier <michael@paquier.xyz>  
Backpatch-through: 18  
Security: CVE-2026-14676  
Discussion: https://postgr.es/m/19528-7290dd7e6f7dcc22@postgresql.org  

M contrib/pg_stat_statements/pg_stat_statements.c

Preserve the owner of extended statistics rebuilt by ALTER TABLE.

commit   : 6713a6e04cbb24ec3f3c1dda10e703f138109e71    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

When ALTER TABLE ... ALTER COLUMN TYPE (or any subcommand that rebuilds  
them) drops and re-creates the extended statistics objects depending on  
the altered column, the re-created objects were owned by the role running  
ALTER TABLE rather than by the original owner of the statistics.  
  
Remember each object's owner before dropping it, and restore it on  
re-creation.  
  
CreateStatistics()'s signature changes and CreateStatsStmt gains a field,  
but no known third-party code calls the former or constructs the latter.  
  
Author: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 14  
Security: CVE-2026-6469  

M src/backend/commands/statscmds.c
M src/backend/commands/tablecmds.c
M src/backend/tcop/utility.c
M src/include/commands/defrem.h
M src/include/nodes/parsenodes.h
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql

Return nulls honestly in aggregate "combine" functions.

commit   : 1aa601b4f55e337f1c8d19757129815f1685cac2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

numeric_combine() and several other state-combining functions for  
aggregates cheated for the case of both inputs being NULL: they  
returned a null pointer without bothering to mark it as a SQL NULL.  
This was harmless in the expected usage where the result would be  
passed to the same combine function or a related aggregate final  
function.  But it's bad news from a security standpoint, because  
now that value can be passed to an internal-accepting function  
even if said function is strict.  While a previous patch prevented  
such queries from being issued, it seems like good defense-in-depth  
to expend the few additional lines of code needed to do this properly.  
Comparable functions such as array_agg_combine() already do so.  
  
Reported-by: Amy Burnett (OpenAI Codex Security)  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-14680  

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

Reject calls from SQL to functions that take or return type internal.

commit   : 8f7e35b08ad5b5a400d0333188c17bb354174f60    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

Allowing that is a security hole, since there are many different  
functions with different ideas of what their "internal" argument or  
result is.  We already had a defense against the easy case of  
"'foo'::internal", but that turns out to be insufficient.  Lock down  
both function and operator syntax.  Also disallow attempts to cast to  
or from type internal; those would mostly fail anyway, but we have  
created some holes with features such as CoerceViaIO.  
  
Reported-by: Amy Burnett (OpenAI Codex Security)  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-14680  

M src/backend/parser/parse_coerce.c
M src/backend/parser/parse_func.c
M src/backend/parser/parse_oper.c
M src/pl/plpgsql/src/pl_exec.c

Protect some fixed-size arrays that have FUNC_MAX_ARGS elements.

commit   : 60e7329b9b1dd1ca7bb2a39cf7d95e1d5b8b3a39    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

The maximum number of arguments allowed for an aggregate function  
is FUNC_MAX_ARGS-1 (since the underlying transfn and/or finalfn  
will be called with one more argument).  parse_func.c failed to  
enforce this, allowing construction of calls that would try to  
pass FUNC_MAX_ARGS+1 to the underlying functions, resulting in  
a memory stomp in the executor.  Add correct checking there.  
  
Since it's possible that a bad call has been stored in a view or  
SQL function, also add checks in various aggregate-related and  
window-function-related code that there are not more than  
FUNC_MAX_ARGS arguments.  These will also protect us against the  
possibility that we're trying to run a stored view that was made  
by a server executable with different FUNC_MAX_ARGS.  (Arguably,  
that scenario does not qualify as a security problem.  But let's  
just tighten up all of this while we're here, rather than split  
hairs over whether an overrun is reachable.)  
  
Likewise check in compute_function_hashkey.  Here the hazard is  
directly from a pg_proc row, but the scenario is the same.  
  
PL/Tcl has a similar issue with a fixed-size string buffer.  
Let's just replace that buffer with a Tcl_DString, removing the  
whole issue and making the code look more like what's around it.  
  
There are a lot of other FUNC_MAX_ARGS-sized arrays, but the rest  
have nearby guards already, some with comments explicitly pointing  
out the hazard of FUNC_MAX_ARGS changing.  
  
I also used palloc_array() in a few related places in funcapi.c.  
Those aren't live hazards AFAICS, but nearby code has been  
palloc_array-ified already, so it seemed inconsistent to not use  
it here.  
  
Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-14679  

M src/backend/executor/nodeWindowAgg.c
M src/backend/parser/parse_agg.c
M src/backend/parser/parse_func.c
M src/backend/utils/cache/funccache.c
M src/backend/utils/fmgr/funcapi.c
M src/pl/tcl/pltcl.c

pg_dump: avoid assuming how long pg_proc.protrftypes can be.

commit   : 13bb73aeb688632872d9866c60be8839cdc1f599    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

The backend doesn't impose any particular limit on the length of this  
array, and since there could be entries for both input and output  
arguments, it's feasible for the length to exceed FUNC_MAX_ARGS  
even without funny business.  This could lead to crashes or worse.  
  
Moreover, pg_dump shouldn't rely on hard-coding FUNC_MAX_ARGS in the  
first place: it has no business assuming that the backend it's dumping  
from was compiled with the same value of FUNC_MAX_ARGS that it is.  
So the stanza in dumpFunc() that allocates exactly FUNC_MAX_ARGS space  
for the parsed OID array is fundamentally misguided.  And it's broken  
in another way too: if there are exactly FUNC_MAX_ARGS OIDs, then  
parseOidArray won't zero-fill any entries, allowing the subsequent  
loop to run off the end of the array.  A crash seems unlikely in  
this variant, but garbage output is certain.  
  
To fix, redesign parseOidArray's API so that it does the  
array-mallocing, which simplifies the callers anyway.  While we're  
here, tighten and modernize it a bit; in particular, split it into  
separate functions for OIDs and integers, as was foreseen long ago.  
This lets us get rid of the confusing type-punning involved in  
having IndxInfo.indkeys be declared as "Oid *" when it's really  
potentially-signed ints.  Also, most of the callers expect an exact  
number of array entries, so make it verify that not just check for  
"too many".  
  
I noted while testing that this dumpFunc() stanza isn't even reached  
during check-world.  Add a function with transform to the regression  
tests to rectify that.  
  
Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-19385  

M src/bin/pg_dump/common.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/test/regress/expected/object_address.out
M src/test/regress/sql/object_address.sql

Replace fixed-size, too-short array with a palloc'd one.

commit   : 7bd56f7a3bdf1b8aaaf78218478bc7f4c88e3514    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

MatchNamedCall's arggiven array was declared FUNC_MAX_ARGS long,  
but we may actually use up to pronallargs elements, and that can  
be more than FUNC_MAX_ARGS if the function has OUT arguments  
(cf. ProcedureCreate).  Convert it to a palloc'd array.  
  
Reported-by: Zheng Yu <zheng@depthfirst.com>  
Reported-by: ylwangtju <ylwangtju@qq.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-14679  

M src/backend/catalog/namespace.c

Be more wary about constant's datatype in scalarineqsel().

commit   : 8f0c3d2feb9d7a9905d1ed0122ff1fb2bd3cfb0a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

The special case here for estimating conditions involving a ctid  
column failed to check that the RHS constant is of type tid.  
While that'd always be true for the built-in operators that  
reference this selectivity estimator, a maliciously constructed  
operator could provide a user-controlled Datum value that would  
get interpreted as an ItemPointer pointer.  That at least risks  
SIGSEGV, and perhaps with a bit of sweat it could be used for  
server memory disclosure.  
  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Backpatch-through: 14  
Security: CVE-2026-14668  

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

Harden PL/Perl code against "tied" Perl arrays and hashes.

commit   : 63cb15f40c6e4b5d74805e2f54231be09ac1783b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

Tied arrays might report different sizes each time they are inspected.  
To avoid generating a corrupt result array, fix plperl_array_to_datum()  
to read av_len() of each input array only once.  If the input does  
appear to get shorter, we'll fill nulls for the now-missing entries,  
which seems fine.  Conversely, if it gets longer, we'll ignore the new  
entries.  
  
plperl_to_hstore() assumed that Perl's hv_iterinit() returns the  
number of entries in the given Perl hash.  Usually that's true,  
but per the Perl docs, "the return value is currently only meaningful  
for hashes without tie magic".  That could potentially end in a memory  
stomp.  We don't depend on that result value anywhere else, so don't  
do so here either.  
  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Backpatch-through: 14  
Security: CVE-2026-14670  

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

Fix potential buffer overrun in regexp match/split functions.

commit   : 343aabf1d95dfb65c0b7c7cdc2e2fb4e79ba9e6d    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:48 -0700    

Click here for diff

setup_regexp_matches() sizes the buffer used to convert matched  
substrings back from pg_wchar form at the smaller of maxlen*eml and  
the original string's byte length, on the assumption that such a  
conversion cannot produce more bytes than the string it came  
from. That assumption holds only for validly encoded input. But  
pg_mb2wchar_with_len() silently accepts bytes that are invalid in the  
database encoding, turning each such byte into one pg_wchar, and  
converting that back can take more bytes than the input did. A string  
made of such bytes therefore overruns the conversion buffer by up to  
its own length, corrupting the following memory. regexp_match(),  
regexp_matches(), regexp_split_to_table() and regexp_split_to_array()  
are all affected.  
  
Fix by dropping the tighter bound and always allocating maxlen*eml + 1  
bytes.  
  
Reported-by: Francesco Verardi <frevadiscor89@gmail.com>  
Author: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-14664  

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

Harden tsquery code against overflows.

commit   : 90649b6f846c7593f0f57b2b821b8d8eb1e18693    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:47 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:47 -0700    

Click here for diff

The only overflow hazards I could find in tsquery construction  
are in QTN2QT(), which builds a flat tsquery datum from the  
QTNode tree representation used by tsquery_or, tsquery_rewrite,  
and allied functions.  There are two:  
  
1. It seems theoretically possible for the outputs of cntsize() to  
overflow an int, so I widened them to size_t.  There's no hazard  
certainly in tsquery_or and friends, but tsquery_rewrite could expand  
the query tree by large multiples (by replacing many identical  
subtrees with a large replacement tree), so in a 64-bit machine  
with plenty of available memory it should be possible to build a  
QTNode tree large enough to cause that.  If these counters did  
overflow then we'd under-allocate the output tsquery and have a heap  
overwrite problem.  size_t is sufficient, since it's counting the size  
of a subset of an in-memory data structure.  We also have to fix the  
TSQUERY_TOO_BIG() macro to not get confused if sumlen exceeds  
MaxAllocSize.  
  
2. fillQT() neglects to check that the new "distance" value for a  
QI_VAL item fits into the available 20-bit field.  It's quite easy  
to reach this, for example by tsquery_or'ing two near-megabyte-sized  
tsquerys.  However, the result is only a corrupt tsquery that does  
not represent the expected query, so perhaps this doesn't rise to  
the level of a security bug.  Nonetheless it should be fixed.  
  
Note: I followed the practice used in other tsquery code of checking  
each distance value as it's assigned, which means that the last  
operand string could extend past the MAXSTRPOS boundary.  This is a  
bit different from the pattern used for tsvectors, which insist that  
the total data length not exceed MAXSTRPOS and thereby avoid making  
per-item checks.  Perhaps that should be harmonized sometime, but for  
now it's okay for the two types to do this differently as long as  
each one is self-consistent.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-14662  

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

Harden tsvector code against overflows.

commit   : 23d9ad771817c123ebdc16ebc65977754c82b5ab    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:47 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:47 -0700    

Click here for diff

The core of this patch is to prevent array_to_tsvector() from  
generating invalid tsvectors.  It did not check for overly-long  
lexemes (so that WordEntry.len fields could overflow), nor did it  
check that the total "datalen" fits within MAXSTRPOS (so that  
WordEntry.pos fields could overflow, and the number of entries  
in the tsvector could be much more than the normal limit).  
While the field overflows couldn't do anything much worse than  
produce a corrupted tsvector value, a sufficiently large number  
of tsvector entries could cause integer overflows in later  
processing, such as tsvectorout.  
  
Another important fix is to prevent tsvectorrecv() from accepting  
invalid tsvectors.  The main problem there is that it did not  
reject empty-string lexemes.  Hence, even though it did (mostly)  
enforce the MAXSTRPOS limit, it could still produce a result  
with an unreasonable number of tsvector entries, if they were  
primarily empty strings.  
  
Also, fix tsvectorout's calculation of its required output  
buffer size: it was multiplying the string lengths by  
pg_database_encoding_max_length() for no reason.  That contributed  
to the risk of integer overflow there.  With valid tsvector input,  
there's no risk, but there's still no reason to make the output  
buffer several times bigger than needed.  
  
I also tried to make a couple of related routines more robust,  
and spent some effort on improving the comments in ts_type.h.  
Also, standardize on a single spelling of the "string is too long  
for tsvector" message, using %zu instead of an assortment of formats.  
These changes aren't security per se but came out of inspecting the  
code for problems.  
  
Reported-by: Yuhang Wu <yuhang@depthfirst.com> and Zhenpeng Lin  
Reported-by: Zheng Yu <zheng@depthfirst.com>  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Amit Langote <amitlangote09@gmail.com>  
Backpatch-through: 14  
Security: CVE-2026-14662  

M src/backend/tsearch/to_tsany.c
M src/backend/tsearch/ts_parse.c
M src/backend/utils/adt/tsvector.c
M src/backend/utils/adt/tsvector_op.c
M src/include/tsearch/ts_type.h

Guard against overlength time zone abbreviations in to_char().

commit   : 3d724bf4fde67a2931733a5143b7d6c12b23990c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 10 Aug 2026 06:37:47 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 10 Aug 2026 06:37:47 -0700    

Click here for diff

While typical abbreviations are only a few bytes long, a user-supplied  
time_zone setting could specify a much longer abbreviation, enough to  
overflow to_char's allocation of 12 bytes per format character. If so,  
throw an error in the same style as commit 9241c84cb (CVE-2015-0241).  
  
Reported-by: Hcamael <baiyjrh@gmail.com>  
Reported-by: Amjad Shahzad <amjadshahzad2000@gmail.com>  
Reported-by: Tan Zhen of AntAISecurityLab <TanZhen.AntAI@outlook.com>  
Reported-by: Tomer Fichman <tomer@irregular.com>  
Reported-by: Zheng Yu <zheng@depthfirst.com>  
Reported-by: Amy Burnett (OpenAI Codex Security)  
Reported-by: Rick de Jager <rick@v12.sh>  
Reported-by: Heewon Song <asteria121@78researchlab.com>  
Reported-by: Sylvie Mayer <smayer@cloudflare.com>  
Reported-by: Aleksander Alekseev <aleksander@tigerdata.com>  
Reported-by: Hillai Ben Sasson <hillai.bensasson@wiz.io>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 14  
Security: CVE-2026-14669  

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

Rename sort support integer comparators for clarity

commit   : 19733fa0b42caffa92463bb8a8098a40d8963d76    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Mon, 10 Aug 2026 17:31:29 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Mon, 10 Aug 2026 17:31:29 +0700    

Click here for diff

The previous names used "unsigned" for Datum-width abbreviated keys  
and "signed" for 64-bit signed integers. This may have made more  
sense when Datum width was platform-dependent, but commit 805c64f84  
added a 32-bit unsigned variant for OIDs, so it makes even less sense  
now. Rename all to be explicit about signedness and width.  
  
Suggested-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAApHDvrNMz5ahN1x=uK9yscTogmLupfLBy-_qMW9Z+k=HE5u_A@mail.gmail.com  

M src/backend/access/gist/gistproc.c
M src/backend/access/nbtree/nbtcompare.c
M src/backend/utils/adt/bytea.c
M src/backend/utils/adt/mac.c
M src/backend/utils/adt/network.c
M src/backend/utils/adt/timestamp.c
M src/backend/utils/adt/uuid.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/sort/tuplesort.c
M src/include/utils/sortsupport.h

Add ssup_datum_uint32_cmp for comparing OIDs

commit   : 94d32ce1a63c67bce7b811207095ee6d41d4caed    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Mon, 10 Aug 2026 17:25:45 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Mon, 10 Aug 2026 17:25:45 +0700    

Click here for diff

Commit 51cd5d6f0 used ssup_datum_unsigned_cmp for the OID comparator,  
which compares entire Datums. That gave wrong results, since the upper  
half of a Datum containing a 32-bit type is not reliably zero-extended:  
values fetched from tuples are sign-extended, while values returned  
by e.g. oidin() are zero-extended. An OID with the high bit set could  
therefore compare as larger or smaller depending on its source.  
  
Fix by adding a sort support comparator that only looks at the low 32  
bits. Also teach radix sort to normalize Datums the same way. This keeps  
OID eligible for radix sort. Add a regression test that sorts OIDs above  
2^31 from both kinds of source, taken from Peter Geoghegan's report.  
  
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Suggested-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFM2afRzSLJJiWKnRjqPwL7Scm2Wd1xXu140diJGuJtzGg@mail.gmail.com  
Discussion: https://postgr.es/m/CAH2-WznvXyKRah=MQ3ONGHiN8ahJcqpmtyikxCOO96A4usDPpg@mail.gmail.com  

M src/backend/access/nbtree/nbtcompare.c
M src/backend/utils/sort/tuplesort.c
M src/include/utils/sortsupport.h
M src/test/regress/expected/oid.out
M src/test/regress/sql/oid.sql

Fix errmsg grammar for publication membership

commit   : 6e89028ec487ffe6f2150b3e87af7e983f7295b2    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 10 Aug 2026 08:44:49 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 10 Aug 2026 08:44:49 +0200    

Click here for diff

Using "a member of" instead of "member of" is consistent with other  
similar error messages.  
  
Author: Peter Smith <peter.b.smith@fujitsu.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAHut+Pvyj3ad7g-Sb98LDsf1i4c+92rqr+OVG9Lb3fikc_POLg@mail.gmail.com  

M src/backend/catalog/pg_publication.c
M src/test/regress/expected/publication.out

Use EVP_MAC for HMAC (OpenSSL >= 3.0)

commit   : 1f3b9bb109b8b1a7bb60d2d7343c1759679e501b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 14:53:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 14:53:03 +0900    

Click here for diff

The legacy HMAC_CTX interface (HMAC_CTX_new(), HMAC_Init_ex(), etc.) has  
been deprecated since OpenSSL 3.0.  The legacy routines do not dispatch  
through the provider framework, so a loaded provider's HMAC  
implementation could be bypassed.  
  
This commit updates hmac_openssl.c to use EVP_MAC when building with  
OpenSSL 3.0 or newer versions.  OpenSSL 1.1.1 is the oldest version  
supported on HEAD, so the legacy routines need to be kept.  Note that  
LibreSSL uses the legacy routines.  
  
Like b91f79cd08ab, no backpatch is done.  
  
Author: Mark Atwood <mark@reviewcommit.com>  
Co-authored-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/178596055149.1584250.13974609482797470185@reviewcommit.com  

M src/common/hmac_openssl.c

Use explicit fetching for digests in cryptohash (OpenSSL >= 3.0)

commit   : b91f79cd08abba7a800d3faf79bb96e8adc8752e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 09:00:38 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 09:00:38 +0900    

Click here for diff

cryptohash_openssl.c initialized the EVP_MD_CTX with the implicit static  
digest objects (EVP_sha256() and friends).  These do not dispatch  
through a loaded provider.  OpenSSL 3.0 and newer versions recommend to  
switch to an explicit fetch, using EVP_MD_fetch(), the older routines  
being deprecated, available for backward-compatibility purposes.  
  
Now, when building with OpenSSL 3.0 or a newer bersion, we fetch the  
digest by name with EVP_MD_fetch(), cache it in the context, and free it  
on teardown.  This has as consequence to feed the hash from a provider.  
The implicit path is kept for older OpenSSL, 1.1.1 being the oldest  
version still supported on HEAD, and for LibreSSL.  
  
This is a slight change in the hashing logic.  No backpatch is done as  
that looks safer, and the code in the back-branches is also able to  
work.  This has been locally tested across OpenSSL 1.1.1 up to 3.5, so  
hopefully nothing is broken.  
  
Note: The submitted code was clearly AI-generated.  I have spend a bit  
of time cleaning it up, making it more consistent with the project style  
in terms of coding, adjusting a few more things on the way.  
  
Author: Mark Atwood <mark@reviewcommit.com>  
Co-authored-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/178596055358.1584287.8485463954311014881@reviewcommit.com  

M src/common/cryptohash_openssl.c

Use OOM-safe routine for pgstats shared hashtable insert

commit   : 127ce776983f19e81ba8abda1984f6f0e229c1b5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 08:37:32 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 10 Aug 2026 08:37:32 +0900    

Click here for diff

pgstat_get_entry_ref() called dshash_find_or_insert() to insert a new  
entry into the shared pgstats hashtable.  If the allocation required for  
the new entry fails, a local cache entry would be left in  
pgStatEntryRefHash with a NULL shared_entry.  This code is switched to  
use dshash_find_or_insert_extended(), so as local hash entries can be  
cleaned up before failuring.  This change makes pgstat_get_entry_ref()  
more robust on re-entry.  
  
Taken in isolation within a single backend, local entries are handled  
fine on HEAD as pgstat_get_entry_ref() is able to handle the case of a  
NULL shared_entry on re-entry.  However it is possible to finish with  
some NULL pointer dereference in more complex scenarios, like:  
- First backend fails insert into the shared hashtable on OOM.  
- Second backend bumps the same entry's refcount (due to  
reinitialization of the same entry, for example).  
- First backend calls pgstat_gc_entry_refs(), uses its local entry  
reference with the NULL shared_entry, crashes when checking if the  
shared entry has been dropped.  
  
6f0738ddec85 has introduced dshash_find_or_insert_extended() for the  
same reason as what we are dealing with here: the backend could be left  
in an inconsistent stat, and clean up actions need to be taken before  
issuing an error.  The failure is unlikely going to show up in practice,  
so no backpatch is done.  This hash insert extended routine is new as of  
v19.  
  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/anV8ftNMW3xyKSMG@paquier.xyz  

M src/backend/utils/activity/pgstat_shmem.c

Fix hot standby accepting connections too early after a crash reset

commit   : b59783502224c0ae721974a5d9b6fb915cbd37e1    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 8 Aug 2026 00:09:05 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 8 Aug 2026 00:09:05 +0900    

Click here for diff

Commit b53b88109f9 made the postmaster maintain reachedConsistency in  
addition to the startup process.  Since the startup process is forked  
from the postmaster, it begins life holding whatever value the  
postmaster last set.  
  
On a crash reset the postmaster re-forks the startup process while its  
own copy still says true: it clears that copy only on receipt of  
PMSIGNAL_RECOVERY_STARTED, which the replacement process cannot send  
before it exists.  The replacement therefore starts out believing the  
database is already consistent.  
  
CheckRecoveryConsistency() then skips the minRecoveryPoint comparison  
altogether, so hot standby is announced at redo start while replay may  
be arbitrarily far behind minRecoveryPoint.  Read-only connections are  
accepted and answer from heap pages that were flushed ahead of the  
replay position, returning wrong results with no error raised.  The  
same branch also runs XLogCheckInvalidPages() and  
CheckTablespaceDirectory(), which are skipped as well, and  
log_invalid_page() treats page references that are normal before  
consistency as a PANIC.  
  
Fix by clearing reachedConsistency in InitWalRecovery(), so that a  
startup process never depends on the value it inherited.  The  
postmaster's own copy is deliberately left alone: forked backends read  
it to choose the "not yet accepting connections" errdetail, and it  
converges once the new startup process sends PMSIGNAL_RECOVERY_STARTED  
and, on reaching minRecoveryPoint, PMSIGNAL_RECOVERY_CONSISTENT.  
  
Successive crash resets alternate.  A startup process that skips the  
branch never sends PMSIGNAL_RECOVERY_CONSISTENT, so the postmaster's  
copy stays false and the next reset forks a process holding the correct  
value; that pass reaches consistency properly, which sets the  
postmaster's copy back to true and re-arms the problem for the reset  
after it.  Roughly every other crash reset is therefore affected, not  
just the first one.  EXEC_BACKEND builds are unaffected, as  
reachedConsistency is not carried in BackendParameters.  
  
Backpatch to v18, where commit b53b88109f9 introduced this issue.  
  
Reported-by: Eric Ridge <eebbrr@planetscale.com>  
Author: Nikhil Sontakke <nikhil@planetscale.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CA+UBoq2n2Zg9rKgMfUtUohzGssisF9cDeyjKqPrnRNFprEyX1Q@mail.gmail.com  
Backpatch-through: 18  

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

Only clear VACUUM's read stream strategy once in failsafe mode

commit   : 69800557ca32c493853b937916789f0f3da88efe    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 7 Aug 2026 09:59:55 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 7 Aug 2026 09:59:55 -0400    

Click here for diff

112c2683807b4d690 restored failsafe vacuum's abandonment of a buffer  
access strategy by clearing the ReadBuffersOperations' strategy  
references. But it did so in lazy_scan_heap()'s main loop, meaning it  
looped through all the ReadBuffersOperations once per block after  
failsafe was engaged. Track it with a local flag and clear the strategy  
only once.  
  
Reported-by: Melanie Plageman <melanieplageman@gmail.com>  
Discussion: https://postgr.es/m/CAAKRu_Zse14nSNeCgtnE1LUAH8Of7OmYR%2BCc3O_DAzxt3m6T-g%40mail.gmail.com  
Backpatch-through: 18  

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

Handle nullable referenced key in RI fast-path check

commit   : 0ec3f048bfc15c8eb9933e8228b847593389da1b    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:39:24 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:39:24 +0900    

Click here for diff

The RI fast-path FK check asserted that the referenced key is never  
NULL, in ri_FastPathFlushArray() and in recheck_matched_pk_tuple().  
That holds for a primary key, but a foreign key may reference any  
unique column, and a UNIQUE column is nullable.  
  
The assertion is reachable under READ COMMITTED.  ri_LockPKTuple()  
locks the matched PK tuple with TUPLE_LOCK_FLAG_FIND_LAST_VERSION, so  
when a concurrent transaction commits a key-changing UPDATE while the  
check waits, the lock follows the update chain to the latest version.  
If that version now has NULL in the referenced column, the fast path  
reaches the assert; in a non-assert build it would compare against the  
NULL and treat it as a match.  
  
A NULL referenced key cannot equal any (non-null) FK value, so treat it  
as no match and let the ordinary foreign-key violation be raised.  This  
matches the SPI path, whose requalifying "pkatt = $n" evaluates to NULL  
for such a row, so the row is not returned and the check reports a  
violation.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/utils/adt/ri_triggers.c
A src/test/isolation/expected/fk-fastpath-null-key.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/fk-fastpath-null-key.spec

Add previous commit to .git-blame-ignore-revs

commit   : dea28d464196e10ddc14129484244871f890806b    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:45:50 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:45:50 +0900    

Click here for diff

M .git-blame-ignore-revs

Fix indentation issue introduced by commit 291a4bd2ca

commit   : d34f9505353dbf3888b3f7000ce2b666bac928d7    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:34:08 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:34:08 +0900    

Click here for diff

Noticed before the commit reached koel.  

M src/backend/commands/trigger.c

Drain pending asynchronous requests during ExecReScanAppend.

commit   : f57df206814d2f15a95cd452931b464a62740165    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 7 Aug 2026 17:30:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 7 Aug 2026 17:30:00 +0900    

Click here for diff

The logic for asynchronous Append assumes that pending requests made for  
subplans of an Append are drained during ExecReScanAppend.  To ensure  
that, commit 9e283fc85 modified postgresReScanForeignScan to drain such  
a request if any, but failed to take into account that if such a request  
was made for a subplan that is re-scanned with parameter changes or  
pruned in the next round by runtime pruning, the postgres_fdw callback  
function is called after ExecReScanAppend or never called, respectively.  
This would cause such a request to remain even after ExecReScanAppend,  
leading to incorrect results, an infinite loop, or an assertion failure.  
  
To fix, modify ExecReScanAppend to, for each of the pending requests,  
give the FDW a chance to drain that request using the existing  
ForeignAsyncConfigureWait/ForeignAsyncNotify callback functions.  This  
makes the change made to postgresReScanForeignScan useless, so remove it  
as well.  
  
Back-patch to v14 where asynchronous Append was added.  
  
Reported-by: Alexander Korotkov <aekorotkov@gmail.com>  
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>  
Co-authored-by: Gleb Kashkin <g.kashkin@postgrespro.ru>  
Co-authored-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Reviewed-by: Alexander Pyhalov <a.pyhalov@postgrespro.ru>  
Reviewed-by: Gleb Kashkin <g.kashkin@postgrespro.ru>  
Discussion: https://postgr.es/m/CAPpHfduMOTnV5Zj2KGJ7zanL_10QvccZHtPUaDfJvBhsh9axnQ%40mail.gmail.com  
Backpatch-through: 14  

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

Fire fast-path FK batches inside the deferred trigger loop

commit   : 291a4bd2ca1cac695f34a7d2dc4322bd235641de    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:25:42 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 17:25:42 +0900    

Click here for diff

AfterTriggerFireDeferred() drained its queued events in a loop, then  
called FireAfterTriggerBatchCallbacks() once after the loop to flush  
the RI fast-path FK-check batches the fired triggers accumulated.  
  
A batch callback runs user-supplied cast or equality functions, whose  
DML can queue further deferred trigger events.  Because the flush ran  
after the loop had exited, such an event was left in  
afterTriggers.events with nothing to fire it, since  
AfterTriggerFireDeferred() is the last drainer at commit.  The deferred  
check was skipped and a row violating the constraint committed.  
  
Move the flush inside the loop, after afterTriggerInvokeEvents(), and  
drop the "all fired" break, so afterTriggerMarkEvents() re-checks after  
each flush and fires events a flush queued at the correct time.  The  
other FireAfterTriggerBatchCallbacks() callers leave any queued event  
for the eventual commit-time AfterTriggerFireDeferred(), so only the  
commit-time firing, which has no later drainer, lost events.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Begin RI fast-path index scan under the switched user id

commit   : 7c1c2f0b8d837fa49df434ecc4438e7d3476144e    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 16:33:49 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 16:33:49 +0900    

Click here for diff

ri_FastPathCheck() called index_beginscan() before switching to the  
referenced relation's owner for the permission check and probe.  For  
btree this has no consequence, but starting the scan before the user id  
switch sets a poor example for code dealing with out-of-tree access  
methods, whose beginscan could observe the wrong user id.  Move  
index_beginscan() after the SetUserIdAndSecContext() call.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Restrict RI fast-path FK check to btree referenced indexes

commit   : edc92e0ff9572e41dc2d2fc14fbab313fa9d7bc5    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 16:30:21 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 16:30:21 +0900    

Click here for diff

The RI fast-path check probes the referenced index directly and, for  
single-column keys, uses SK_SEARCHARRAY.  Both assume the index is a  
btree.  A comment claimed "PK indexes are always btree", but a foreign  
key's referenced index need not be a primary key:  
transformFkeyCheckAttrs() accepts any unique (or, for temporal keys,  
exclusion) index, so an out-of-tree access method advertising  
amcanunique could supply a non-btree index reachable by the fast path.  
  
Add pk_index_is_btree to RI_ConstraintInfo, set from the referenced  
index's access method when the constraint is loaded, and make  
ri_fastpath_is_applicable() return false for non-btree indexes so such  
constraints fall back to the SPI path.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Remove stale comment on ri_FastPathCheck()

commit   : ccfa6c9644132d95c09dd6512643493fb5081c6a    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 16:12:47 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Fri, 7 Aug 2026 16:12:47 +0900    

Click here for diff

The note claiming ri_FastPathCheck() is only used by the ALTER TABLE  
validation path is no longer accurate.  Rather than reword it, remove  
it; the block comment above RI_FKey_check()'s call to the function  
already documents when each path is taken, and a duplicated  
cross-reference here would only drift out of date again.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch@microsoft.com  
Backpatch-through: 19  

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

Fix shared refcount leak in pgstat entry acquisition

commit   : bf80a4c2d238834073b09c231294c4479157f16e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 7 Aug 2026 14:52:09 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 7 Aug 2026 14:52:09 +0900    

Click here for diff

pgstat_acquire_entry_ref() does an entry acquisition with the following  
actions:  
- Increment of a shared ebtr's refcount.  
- Release dshash partition lock.  
- Update local entry_ref fields.  
  
With a pending interrupt, the LWLock acquired by dshash_release_lock()  
in the second step could fail, leaving around a local entry_ref with  
shared_stats set to NULL and the refcount permanently inflated as  
pgstat_release_entry_ref() skips the refcount decrement is shared_stats  
is not set.  
  
The actions are now reordered so as the lock is released after the local  
entry_ref fields are populated.  
  
The consequence of this problem is a minor leak.  It can only happen if  
an interrupt is processed when a dshash lock is released, which is a  
very narrow window (very unlikely), so no backpatch is done.  
  
Author: Niall Newman <nn@turacolabs.com>  
Discussion: https://postgr.es/m/2FDAA194-9CF3-4FD7-A450-F1A4BEB125F6@turacolabs.com  

M src/backend/utils/activity/pgstat_shmem.c

Fix local pgstat entry leak on OOM during entry creation

commit   : 4069df21beb838e75e8639c47e6a9c800e3c8af5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 7 Aug 2026 14:23:28 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 7 Aug 2026 14:23:28 +0900    

Click here for diff

When pgstat_init_entry() fails due to an OOM in the DSA allocation,  
pgstat_get_entry_ref() cleaned up the shared hashtable but forgot to  
remove the local reference that pgstat_get_entry_ref_cached() had  
already inserted into pgStatEntryRefHash.  
  
Missing this cleanup would leave a backend with a stale local cache  
entry whose entry_ref points to a NULL shared_stats.  If  
pgstat_gc_entry_refs() runs with this reference still around, it would  
crash due to a pointer dereference.  
  
The local reference is now removed before removing the shared entry,  
the order being sensitive to pending interrupts.  
  
Oversight in 8191e0c16a03.  
  
Author: Niall Newman <nn@turacolabs.com>  
Discussion: https://postgr.es/m/2FDAA194-9CF3-4FD7-A450-F1A4BEB125F6@turacolabs.com  
Backpatch-through: 15  

M src/backend/utils/activity/pgstat_shmem.c

Make 030_pg_recvlogical robust against PID reuse

commit   : 44056f6493ac11ddabbae31098398af71b563904    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 7 Aug 2026 12:28:44 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 7 Aug 2026 12:28:44 +0900    

Click here for diff

The reconnection test assumed that a restarted walsender would always  
have a different PID from the previous one. On some platforms, however,  
PIDs can be reused quickly, causing the test to time out even though  
pg_recvlogical has successfully reconnected.  
  
This issue was reported by buildfarm member fairywren:  
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=fairywren&dt=2026-07-30%2009%3A58%3A12  
  
Fix this by waiting for the server log message indicating that the  
logical replication slot has been acquired again, rather than relying on  
a PID change.  
  
Backpatch to v19, where the affected reconnection test was introduced by  
commit d89b1d817513.  
  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/OS9PR01MB121497CF10DFF54F745E37204F5C92@OS9PR01MB12149.jpnprd01.prod.outlook.com  
Backpatch-through: 19  

M src/bin/pg_basebackup/t/030_pg_recvlogical.pl

Remove scram_client_key_len and scram_server_key_len from PGconn

commit   : db0c984b1d101b7519df1922c8a880d14f19de82    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 6 Aug 2026 23:27:59 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 6 Aug 2026 23:27:59 +0200    

Click here for diff

Commit 761c79508e7 added scram_client_key_len and scram_server_key_len  
to PGconn, but no consumer read the fields and there were no accessor  
functions defined.  Code which need the length use SCRAM_MAX_KEY_LEN  
which the new fields were also verified to match, so remove the fields  
as they are not used.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>  
Discussion: https://postgr.es/m/CAJ7c6TMx3pyuW86zEjGs4kua0vQPzZEg2sCUe+NnP08fBKuVoQ@mail.gmail.com  

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

Restore vacuum failsafe abandonment of buffer access strategy

commit   : 112c2683807b4d690a19e0a182246b219832b1d0    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Thu, 6 Aug 2026 17:16:23 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Thu, 6 Aug 2026 17:16:23 -0400    

Click here for diff

VACUUM's wraparound failsafe mode exists to reclaim transaction IDs as  
quickly as possible. 4830f1024325 made the failsafe stop using the  
BAS_VACUUM buffer access strategy so that the rest of the vacuum could  
make use of all of shared buffers rather than being confined to the  
small strategy ring.  
  
However, when 9256822608f3 made vacuum's first heap pass use the read  
stream, this was accidentally disabled. The read stream keeps its own  
references to the buffer access strategy, so clearing vacrel->bstrategy  
in lazy_check_wraparound_failsafe() no longer had any effect on the  
reads issued by the first pass.  
  
Fix this by adding clearing the BufferAccessStrategy reference actually  
being used by the ongoing scan -- those in the ReadBuffersOperations  
structs themselves.  
  
Two things we accept rather than fix, as neither is worth the added  
complexity given how rarely failsafe mode is reached:  
  
- A small amount of read time for IOs that were already in progress when  
  the strategy was cleared may be attributed to IOCONTEXT_NORMAL instead  
  of IOCONTEXT_VACUUM. WaitReadBuffers() derives the IOContext from the  
  (now cleared) strategy, so the wait time of these in-flight IOs is  
  misattributed. This is bounded by the stream's look-ahead window and  
  happens at most once per vacuum, when the strategy is first cleared.  
  
- The stream's buffer pin limit stays lower than it would have been had  
  no strategy been used at all. max_pinned_buffers is capped by the  
  strategy's pin limit when the stream is created and is not recomputed  
  when the strategy is cleared. Raising it would mean building a new,  
  larger ring, which would require first waiting for all in-progress IOs  
  to complete. That didn't seem worth it.  
  
Reported-by: Jingtang Zhang <mrdrivingduck@gmail.com>  
Discussion: https://postgr.es/m/CAPsk3_APRYVLhAJ5TMwdmpSx8W_%3DPHMm%3DPmKAvnC3gBrfNommQ%40mail.gmail.com  
Backpatch-to: 18  

M src/backend/access/heap/vacuumlazy.c
M src/backend/storage/aio/read_stream.c
M src/include/storage/read_stream.h

Remove lo_hton64() and lo_ntoh64().

commit   : 5593aca0c62e08f5827d706d03be99481ef9bcb0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 6 Aug 2026 13:10:00 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 6 Aug 2026 13:10:00 -0500    

Click here for diff

These functions date back to commit 461ef73f09, which predates the  
64-bit byte-swapping routines in pg_bswap.h (added in commit  
510b8cbff1).  Commit 0ba99c84e8 converted them to use pg_hton32()  
and pg_ntoh32() but stopped short of removing them, so let's do  
that now.  
  
Discussion: https://postgr.es/m/ahXE28klgxIJXBLq%40nathan  

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

doc: Define MXID as an acronym

commit   : f0178deecbb56283fda8f4c504c8fe16ce23e1a6    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 6 Aug 2026 14:07:57 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 6 Aug 2026 14:07:57 +0200    

Click here for diff

XID is defined as an acronym in the documentation but MXID (Multixact  
ID) was missing from the acronym list.  This adds MXID as an acronym  
and links it to the "Multixacts and Wraparound" section.  
  
Author: Koshino Taiki <koshino@sraoss.co.jp>  
Discussion: https://postgr.es/m/OS9PR01MB17364A940ACFCADBB7593498A94D32@OS9PR01MB17364.jpnprd01.prod.outlook.com  

M doc/src/sgml/acronyms.sgml
M doc/src/sgml/maintenance.sgml

Report duplicate property and label names with a proper error

commit   : 9b917a93116e6b8aac7ed837ded27696f7232505    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 6 Aug 2026 10:23:44 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 6 Aug 2026 10:23:44 +0200    

Click here for diff

Adding a property with the same name multiple times to a label on an  
element, either within a single PROPERTIES clause or across statements  
via ALTER PROPERTY GRAPH ... ADD PROPERTIES, previously failed with a  
unique-index violation on pg_propgraph_label_property.  The same class  
of bug existed for labels: listing the same label multiple times on  
one element in CREATE PROPERTY GRAPH, or adding a label to an element  
that already has it via ALTER PROPERTY GRAPH ... ADD LABEL, failed  
with a unique-index violation on pg_propgraph_element_label.  Detect  
the duplicates up front and raise a friendlier error in both cases.  
  
For properties, the cross-statement duplicate is caught by a syscache  
probe before insertion.  The in-clause duplicate could have been  
caught by the same probe if we issued a CommandCounterIncrement()  
between property inserts, but that forces a catalog invalidation per  
property purely to detect a condition we can check for free on the  
in-memory target list.  The list-based check is only needed when the  
properties are listed explicitly; when they are derived from the  
table's attributes, names are already unique.  
  
For labels, a single syscache probe on pg_propgraph_element_label  
suffices for both the in-clause and cross-statement cases because  
insert_element_record() already issues CommandCounterIncrement()  
between successive label inserts.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://www.postgresql.org/message-id/flat/20260630173053.51.noahmisch%40microsoft.com  

M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/sql/create_property_graph.sql

Tighten proto_version parsing in pgoutput

commit   : 290bb8afe6b47adb8b080688bd97a710af351cb1    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Aug 2026 16:46:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Aug 2026 16:46:03 +0900    

Click here for diff

This is similar to 58ff4a0a0867, but this time for the parameter  
"proto_version", when given as a parameter to pgoutput for logical  
replication.  strtoul() lacked a check for an empty string, leading to  
an inconsistent behavior depending on the platform.  
  
The author has originally proposed a TAP test to check this empty value  
pattern.  I have added a cheaper SQL query, instead, test_decoding  
including a test area where this is possible.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://postgr.es/m/DKBS2Z9CGARC.2T07O6TJYSE8B@partin.io  

M contrib/test_decoding/expected/replorigin.out
M contrib/test_decoding/sql/replorigin.sql
M src/backend/replication/pgoutput/pgoutput.c

Tighten tid input parsing with strtoul() to reject empty fields

commit   : 58ff4a0a08679356e502dfcbbc50e9bec94b77b1    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Aug 2026 15:39:56 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Aug 2026 15:39:56 +0900    

Click here for diff

strtoul() informs that in the case of no conversion, "endptr" is set  
equal to the location of the input pointer, which is something that  
tidin() has never checked.  
  
This allowed inputs like "(,)", "(1,)" or "(,1)" to be accepted on some  
platforms, like Linux where "(1,)" implied "(1,0)", but rejected on  
others like macos where "(1,)" is rejected, due to the fact that errno  
may not be set.  
  
This change may cause some issues as some tid values will now be  
rejected, but at least we get the consistent strtoul() experience.  
If it proves to be a pain for some, it could always be reverted.  
Another point of this change is that we get one step closer to a  
possible common strtoul() where the error handling could be unified in  
core, with all the errors handled the same way for errno and no input  
parsed, at least.  
  
Reported-by: Michael Malis <malis@pgrust.com>  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://postgr.es/m/19584-e60c446ba6f57c9c@postgresql.org  
Discussion: https://postgr.es/m/DKBS2Z9CGARC.2T07O6TJYSE8B@partin.io  

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

Fix race condition in subscription TAP test 023_twophase_stream.

commit   : 4790abd112fcb889bac3e1e45b2e7238d48184e5    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 6 Aug 2026 11:41:18 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 6 Aug 2026 11:41:18 +0530    

Click here for diff

Buildfarm member olingo intermittently failed this test, timing out while  
waiting for the subscriber log to report an ERROR because  
max_prepared_transactions is zero there. The test captured the log offset  
only after issuing the publisher's  
BEGIN/INSERT/PREPARE TRANSACTION/COMMIT PREPARED sequence.  
  
Since streaming is enabled, the subscriber can receive and apply the  
transaction, and log the expected ERROR, before that publisher SQL command  
even returns, i.e. before the test captures the offset. The subsequent  
wait_for_log() calls then searched only from a point after the message had  
already been written, and timed out waiting for it.  
  
Fix by moving the offset capture to before the publisher's transaction is  
issued, ensuring it always precedes the point where the ERROR can appear  
in the subscriber log.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 16, where test was introduced  
Discussion: https://postgr.es/m/c43753d8-5265-4f77-83ff-9b1167276ec5@gmail.com  

M src/test/subscription/t/023_twophase_stream.pl

Fix unlikely incremental tuple deform bug with missing attrs

commit   : d260d7d003fa241cc3b52769d79187f30e98febd    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 6 Aug 2026 17:42:44 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 6 Aug 2026 17:42:44 +1200    

Click here for diff

The code added in c456e3911 added populate_isnull_array() to bulk  
populate the slot's tts_isnull array 8 elements at a time.  When tuples  
don't have an exact multiple-of-eight number of attributes, this will  
lead to populating the tts_isnull elements for attributes that don't  
exist in the tuple.  This is ok as the array is large enough.  However,  
if we perform tuple deforming in two passes, and on the first pass  
deform *some* of the attributes with slot_getmissingattrs() then later  
when we deform the remaining missing attributes, the subsequent call to  
populate_isnull_array() would overwrite the tts_isnull values previously  
set by slot_getmissingattrs(), and since that function only continues  
where it left off, it wouldn't reapply the previously set values and those  
would be left as NULLs, as populate_isnull_array() would have set them.  
  
Here, we fix by passing the tuple's natts to slot_getmissingattrs()  
rather than the attnum we're deforming from.  This means we apply all  
the missing attribute values each deform pass, so slightly more work,  
but deforming several missing values in different deform passes is  
likely exceedingly rare.  Doing that seems much better than adding  
overhead in the happy path to check for this and skip the subsequent call  
to populate_isnull_array().  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reported-by: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-WznHo4b+6AmAj0GZ0jXqDSK69MfHe8fAQwuY_01y7cVNdw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/executor/execTuples.c
M src/test/regress/expected/fast_default.out
M src/test/regress/sql/fast_default.sql

commit   : 1200dfd60c367e97a5e1f31100d82072eb0178b6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Aug 2026 08:19:13 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 6 Aug 2026 08:19:13 +0900    

Click here for diff

KeepFileRestoredFromArchive() called unlink() on an existing WAL segment  
before durable_rename() replaced it.  rename(2) atomically replaces a  
target on POSIX systems, and the extra unlink() created a small window  
where it would be possible for a concurrent WAL sender to see a segment  
as missing.  
  
Note that the window still exists on WIN32, as we lack a safe concurrent  
alternative.  Perhaps something like ReplaceFile() could be looked at  
for this purpose.  
  
This problem is hard to reach in practice, so no backpatch is done.  I  
also tend to be conservative regarding recovery changes, even small, in  
stable branches.  
  
Author: Stepan Neretin <slpmcf@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>  
Discussion: https://postgr.es/m/CA+Yyo5S0C25jS_pRWQiGgoiy+X=GyJS7ZJkEq=_SW1WWpkL3Sg@mail.gmail.com  

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

When changing owner of a subscription, do not throw an error.

commit   : 7f4fb058076a8294933efa9f40378cbfb3b89ffd    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:19:21 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:19:21 -0700    

Click here for diff

Errors will be caught when the connection is actually used.  
  
Restore uses multiple DDL commands to restore a subscription, so  
checks of the intermediate state risk restore errors. In the future we  
could address this with a more careful restoration order, but the  
DDL-time errors are merely for convenience.  
  
Addresses finding 2 in the report from the linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Discussion: https://postgr.es/m/e103ae8daf74485e0c0ebde297fae735d38f54d1.camel@j-davis.com  
Backpatch-through: 19  

M src/backend/commands/subscriptioncmds.c
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql

Revert "Validate subscription conninfo on owner change"

commit   : ac230cd3ce93c4752489564cfe6b37b584a465ac    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:19:10 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:19:10 -0700    

Click here for diff

This reverts commit 1c9c35890421e96a91129b51f2c6446a6d95af95.  
  
Raising errors during OWNER TO can cause problems during restore. An  
upcoming commit will avoid other errors that can happen in this path.  
  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/e103ae8daf74485e0c0ebde297fae735d38f54d1.camel@j-davis.com  
Backpatch-through: 19  

M doc/src/sgml/ref/alter_subscription.sgml
M src/backend/commands/subscriptioncmds.c
M src/test/regress/expected/subscription.out
M src/test/regress/regress.c
M src/test/regress/sql/subscription.sql

CREATE SUBSCRIPTION: do not construct conninfo unnecessarily.

commit   : 254beb174e61e339c43e1096053b0a0a2e9cf856    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:19:02 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:19:02 -0700    

Click here for diff

Still check that the creating user has USAGE privileges on the server,  
and that the FDW supports subscription connections.  
  
Addresses finding 1 in the report from the linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Discussion: https://postgr.es/m/e103ae8daf74485e0c0ebde297fae735d38f54d1.camel@j-davis.com  
Backpatch-through: 19  

M src/backend/commands/subscriptioncmds.c
M src/backend/foreign/foreign.c
M src/test/regress/expected/subscription.out

For subscription DDL, demote user mapping checks to WARNING.

commit   : 5c39be9e6d5cc4a49883162dd52b1427738b8186    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:18:44 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:18:44 -0700    

Click here for diff

The checks are useful to report to the user, but there's no reason to  
raise an error. If needed while constructing conninfo, fdwconnection  
will raise an error then.  
  
Partially addresses finding 1, and addresses finding 13 in report from  
the linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Discussion: https://postgr.es/m/e103ae8daf74485e0c0ebde297fae735d38f54d1.camel@j-davis.com  
Backpatch-through: 19  

M src/backend/commands/subscriptioncmds.c
M src/backend/foreign/foreign.c
M src/include/foreign/foreign.h
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql

Always check foreign-server USAGE when resolving subscription conninfo.

commit   : dcfb02deed84dd400c32016be768b9ec760e4c42    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:18:34 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:18:34 -0700    

Click here for diff

Previously, this was skipped in some cases to avoid raising errors  
when conninfo wasn't even needed. That was wrong in cases where  
conninfo was needed.  
  
Now that we only build conninfo when needed, always perform the USAGE  
check.  
  
Addresses finding 7 in report from linked discussion.  
  
Co-authored-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reviewed-by: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Backpatch-through: 19  

M src/backend/catalog/pg_subscription.c
M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/worker.c
M src/include/catalog/pg_subscription.h
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql

Be precise about when ALTER SUBSCRIPTION needs conninfo.

commit   : e90e198e3f478ebc0b1fba0347ad9d76c48e7fa3    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:11:04 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 13:11:04 -0700    

Click here for diff

Decide early whether the original conninfo is needed so that errors  
happen consistently.  
  
Addresses finding 12 in report from linked discussion.  
  
Co-authored-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Backpatch-through: 19  

M src/backend/commands/subscriptioncmds.c
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql

Build subscription conninfo after checking that it's enabled.

commit   : 8b73ceb78f8e40f82ef965b9a1e15a8344c61daf    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 11:57:36 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 11:57:36 -0700    

Click here for diff

If a subscription is disabled, don't try to build conninfo because  
that may generate a confusing error and try to disable an  
already-disabled subscription.  
  
Partially addresses finding 5 in report from linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Backpatch-through: 19  

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

Remove Subscription conninfo field; generate in caller.

commit   : 6d04cd2b84496d727344be1acb6287452982c9bd    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 11:36:37 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 5 Aug 2026 11:36:37 -0700    

Click here for diff

After server-based subscriptions, conninfo became more than just a  
catalog field. It has its own error paths, and it's important that  
callers that don't need conninfo don't encounter errors related to it.  
  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch%40microsoft.com  
Backpatch-through: 19  

M src/backend/catalog/pg_subscription.c
M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/sequencesync.c
M src/backend/replication/logical/tablesync.c
M src/backend/replication/logical/worker.c
M src/include/catalog/pg_subscription.h
M src/include/replication/worker_internal.h

Fix MSVC warnings from new timezone code

commit   : 0d8e41fe1c80d1310e0eed0f66af82f60e506c69    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 5 Aug 2026 19:26:30 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 5 Aug 2026 19:26:30 +0200    

Click here for diff

The new timezone code from commit aeb07c55fab introduced a few new  
compiler warnings from MSVC:  
  
    ../src/timezone/zic.c(353): warning C5287: operands are different enum types '<unnamed-enum-RF_NAME>' and '<unnamed-enum-LF_TARGET>'; use an explicit cast to silence this warning  
    ../src/timezone/zic.c(353): warning C5287: operands are different enum types '<unnamed-enum-RF_NAME>' and '<unnamed-enum-LP_YEAR>'; use an explicit cast to silence this warning  
    ../src/timezone/zic.c(1654): warning C4146: unary minus operator applied to unsigned type, result still unsigned  
  
Silence these warnings with pragmas.  
  
In order not to make future code merges more complicated, the pragmas  
apply to the entire file, not only to the specific code sections where  
they are needed.  This also prevents further warnings of the same  
kinds creeping in.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/2294297.1780270682%40sss.pgh.pa.us  

M src/timezone/zic.c

Fix calculating length of match to localized month/weekday names

commit   : fd2b89854d93d70fe8c9a69d5b8fafd5b9302cfc    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 5 Aug 2026 11:40:39 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 5 Aug 2026 11:40:39 +0200    

Click here for diff

seq_search_localized() returns the length of the matching prefix in  
*len, but because it internally case-folds the inputs, it gets  
confused on the length. The caller expects to get the length of the  
prefix in the original string, but what it actually returns is the  
length of the prefix after case-folding, which can be different if the  
case-folded characters have different byte-length than the original,  
or with ICU, if the case-folding changes the number of characters  
(e.g. "ß", the German double s).  
  
To fix, once we have determined that we have a match, work harder to  
find the match's length in the original string.  This adds some  
overhead, but the strings are expected to be short.  
  
The function does "case-folding" by converting a string to upper-case,  
then to lower-case, which is a little ugly given that we have  
dedicated functions for case-folding nowadays. But switching to that  
doesn't seem appropriate to backpatch in a security fix, and that's  
not available in older stable versions, anyway.  
  
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>  
Reported-by: Xint Code  
Reviewed-by: Jeff Davis <pgsql@j-davis.com>  

M src/backend/utils/adt/formatting.c
M src/test/regress/expected/collate.linux.utf8.out
M src/test/regress/sql/collate.linux.utf8.sql

Disallow aggregates, window functions, and SRFs in GRAPH_TABLE COLUMNS

commit   : f585671055d1c56d6fba0bc5835d28e68248ccfe    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 5 Aug 2026 10:44:10 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 5 Aug 2026 10:44:10 +0200    

Click here for diff

The COLUMNS list of a GRAPH_TABLE query is parsed as an ordinary select  
target list, which permits aggregate functions, window functions, and  
set-returning functions.  GRAPH_TABLE has no machinery to evaluate them,  
though: the rewriter copies the COLUMNS target list verbatim into a  
freshly built subquery whose hasAggs/hasWindowFuncs/hasTargetSRFs flags  
are never set, so the planner builds no Agg/WindowAgg node (and no SRF  
expansion) and the Aggref/WindowFunc/SRF reaches the executor.  This  
triggers an assertion failure ("ecxt_aggvalues != NULL"), or "Aggref  
found in non-Agg plan node" on a non-assert build, for otherwise  
parser-accepted SQL such as  
  
    SELECT max(c) FROM GRAPH_TABLE  
        (g MATCH (x IS v) COLUMNS (count(*) AS c));  
  
Reject these constructs in transformRangeGraphTable() the same way  
subqueries are already handled: save and clear pstate->p_hasAggs,  
p_hasWindowFuncs, and p_hasTargetSRFs around the transformation of the  
COLUMNS list, and raise a "not supported" error if any of them got set.  
  
This is deliberately a blanket prohibition for now.  Once quantified  
element patterns such as (a)->{1,5} are supported, aggregates over  
property references of higher degree (e.g. count(a) or sum(a.val)) can  
be allowed; at that point the check will need to inspect the aggregate  
arguments rather than reject all aggregates outright.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAON2xHOYAmYLkB2jGi6g77d6Fqv8YgOrfV-riQVf0K_7AdxD3w@mail.gmail.com  

M src/backend/parser/parse_clause.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql

Initialize read stream before fetching metapage in hash bulk-deletion

commit   : ca86d7439b1947e97d0d86036f29ebc5cb0397aa    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 5 Aug 2026 16:55:23 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 5 Aug 2026 16:55:23 +0900    

Click here for diff

hashbulkdelete() fetched the relcache's cached hash metapage before  
calling read_stream_begin_relation().  During the read stream  
initialization, relation lookups may process pending relcache  
invalidation messages, which could cause the cached metapage to be  
invalidated before the read stream uses it, leading to the failure of a  
VACUUM bulk-deletion for a hash index.  
  
This commit reworks the order of hashbulkdelete() so as its read stream  
is initialized before fetching the cached metapage, so as pending  
invalidation messages do not interfere with the relation scan.  
  
Issue introduced by bfa3c4f106b1.  
  
Author: Mikhail Nikalayeu <mihailnikalayeu@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/CADzfLwVEJ2_7ioX3ZSB1P7qXW40ghUy_ZCzeFvhDLoa_3Muztg@mail.gmail.com  
Backpatch-through: 19  

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

More tab-completion for DROP PROPERTY GRAPH

commit   : 0a51a06cdb0b23c460a78fa1d60201ebad1905e0    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 5 Aug 2026 08:35:10 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 5 Aug 2026 08:35:10 +0200    

Click here for diff

This adds completion for CASCADE and RESTRICT, similar to what  
completion of other DROP commands provides.  
  
Author: Peter Smith <peter.b.smith@fujitsu.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAHut+PuHsLupVWZ9SUeKm=jKR34wYP6qAZPoOHFhU3uDbx34wQ@mail.gmail.com  

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

doc: Update XID wraparound error example

commit   : 034ff7f94a0d49a5d9799af8364c53db477e0772    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 5 Aug 2026 11:36:43 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 5 Aug 2026 11:36:43 +0900    

Click here for diff

Commit edee0c621de, and the equivalent v17 commit f2353dd71724,  
changed the runtime XID wraparound messages to use "transaction IDs"  
terminology, but one corresponding error example in maintenance.sgml  
still used the older XID wording.  
  
Update that documentation example in line with the current runtime  
message.  
  
Backpatch to v17, where the runtime messages were changed.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/CAHGQGwHTN-Xc5iDtbzNSjfxuab5Y9qAArw8cB4PrrDJpZ+1fgA@mail.gmail.com  
Backpatch-through: 17  

M doc/src/sgml/maintenance.sgml

Clarify wraparound warning percentage messages

commit   : dc6b6fe0a841f006db3f9a5752efbcb176f60e1c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 5 Aug 2026 11:34:29 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 5 Aug 2026 11:34:29 +0900    

Click here for diff

Commit e646450e609 added DETAIL messages for XID and MultiXactId  
wraparound warnings that described the reported percentage as the  
percentage of IDs available for use.  However, the percentage is actually  
calculated from the remaining distance to the wraparound limit, not the  
stop limit where new IDs are refused.  As a result, the wording could be  
misinterpreted as meaning that the reported percentage of IDs can still  
be allocated.  
  
Update the wording to clarify that the reported percentage represents the  
remaining transaction ID space or MultiXactId space before wraparound.  
  
Also update the related XID warning hints to use "transaction ID"  
terminology consistently.  
  
Backpatch to v19, where the DETAIL messages were added.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/CAHGQGwHWZTsR6bjdfpa+pOkBPjoXXm2LuJ+5nh+CvdyqEASHcQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/maintenance.sgml
M src/backend/access/transam/multixact.c
M src/backend/access/transam/varsup.c
M src/test/modules/xid_wraparound/t/002_limits.pl

doc: Clarify wal_sender_shutdown_timeout values

commit   : 011bbdb4273feff7c1b2dbdb06692488e8a3ac21    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 5 Aug 2026 11:29:15 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 5 Aug 2026 11:29:15 +0900    

Click here for diff

Clarify how special wal_sender_shutdown_timeout values affect shutdown  
waiting.  A value of -1 disables the shutdown timeout and lets the  
WAL sender wait for the receiver to catch up, while 0 causes immediate  
termination without waiting for catch-up.  Positive values bound how long  
shutdown waits, so document that they should be high enough for WAL data  
to be replicated under normal circumstances.  
  
Update the main documentation, the GUC long description, and  
postgresql.conf.sample consistently.  While here, fix nearby paragraph  
indentation and spacing.  
  
Backpatch to v19, where wal_sender_shutdown_timeout was introduced.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Ian Barwick <barwick@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/AF4FE756-A220-4DA7-87B7-A126F3F307FD@gmail.com  
Backpatch-through: 19  

M doc/src/sgml/config.sgml
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample

Silence Coverity warning about unused visibilitymap_clear() result

commit   : a37e5745453f76e4bec208920773ef9c90fd50d1    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Tue, 4 Aug 2026 18:04:28 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Tue, 4 Aug 2026 18:04:28 -0400    

Click here for diff

Commit c0d9864f5ce made all but one caller of visibilitymap_clear() check  
its return value, causing Coverity to flag the remaining unchecked call  
in heap_page_fix_vm_corruption().  
  
This VM clear is not WAL-logged, so the caller doesn't need the return  
value of visibilitymap_clear(). Add an explicit void cast and comment to  
document that the return value is intentionally ignored.  
  
Backpatch to 19 when the number of callers discarding the return value  
dropped low enough to trigger Coverity's warning.  
  
Discussion: https://postgr.es/m/1065814.1784514869%40sss.pgh.pa.us  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Backpatch-through: 19  

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

Improving handling of oversized records in xlogreader.c

commit   : 18992dc9d98022a43831da8e1868abf3ce5cd66a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 5 Aug 2026 06:53:10 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 5 Aug 2026 06:53:10 +0900    

Click here for diff

XLogRecordAssemble() refuses records larger than XLogRecordMaxSize when  
generating records, but the reader-side only checked a minimal number  
for xl_tot_len.  
  
A crafted multi-page record with xl_tot_len near UINT32_MAX could bypass  
the contrecord length checks, overflow allocate_recordbuf()'s size math,  
and corrupt memory during reassembly (or hit related asserts under  
cassert).  
  
xlogreader.c is updated to check that the received record is never  
larger than XLogRecordMaxSize, when first receiving the first bytes of  
xl_tot_len, then again when validating the record header.  
  
WAL is a source of data trusted by the server, with CRC32 checksums  
providing a level of protection before replaying the records if data is  
corrupted.  These limits could be internally reached only with crafted  
WAL records, which is something that analyzers (named as LLMs) like  
complaining about these days.  
  
039_end_of_wal.pl is adjusted according to the new maximum limit, a test  
for XLogRecordMaxSize is added.  
  
Author: David Karapetyan <dkarapetyan@gmail.com>  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Discussion: https://postgr.es/m/CALmTjZBddzeGVU2o1JNZb3mPvV68PqDskWPAUQBVb-35yVkiwA@mail.gmail.com  

M src/backend/access/transam/xlogreader.c
M src/test/recovery/t/039_end_of_wal.pl

Add comments to uuid_extract_timestamp().

commit   : 3f2fdd150eb04fe1da60e2a99f4ba2dd2be6443b    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 4 Aug 2026 13:41:02 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 4 Aug 2026 13:41:02 -0700    

Click here for diff

The timestamp-reassembly expressions in uuid_extract_timestamp() are  
chains of shifted octets whose shift counts encode the field layout of  
each UUID version, which is not otherwise recoverable from the code.  
  
This commit documents, for UUIDv1, UUIDv6, and UUIDv7 alike, which  
octets carry which part of the timestamp and where each part lands in  
the reassembled value, citing the RFC section that defines it.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Miłosz Bieniek <bieniek.milosz@proton.me>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/DJHJW50YWKIT.XIOT4NOZRQ03@partin.io  

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

Support UUIDv6 in uuid_extract_timestamp().

commit   : 451871b740d7ad252b8aeaf16a20bcf831a39254    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 4 Aug 2026 10:57:43 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 4 Aug 2026 10:57:43 -0700    

Click here for diff

Previously, uuid_extract_timestamp() returned NULL for UUIDv6 values,  
even though it already extracted timestamps from UUIDv1 and  
UUIDv7.  
  
This commit adds a UUIDv6 branch that reassembles the timestamp from  
that layout and then converts it exactly as the UUIDv1 branch does. We  
provide no uuidv6() generator, but such values can be produced by  
client applications and stored in the database, just as UUIDv1 values  
already are.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Miłosz Bieniek <bieniek.milosz@proton.me>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/DJHJW50YWKIT.XIOT4NOZRQ03@partin.io  

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

Reindent conditional to improve readability

commit   : 589eb4c3b309f5eaa7c16592ff4edbbf780671fe    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 4 Aug 2026 15:42:56 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 4 Aug 2026 15:42:56 +0200    

Click here for diff

Found via readability-misleading-indentation warning in clangd.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://postgr.es/m/DKFO99FP6SLY.2O6A6BUK6P3OQ@partin.io  

M contrib/fuzzystrmatch/dmetaphone.c

psql: Message style fixes

commit   : 9825488c13de4d7b8cae3e7f3b1094441c78ab64    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 15:10:22 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 15:10:22 +0200    

Click here for diff

M src/bin/psql/help.c

doc: Make synopsis placeholders consistent

commit   : 0e9a31be88b8c05f558447a3d459ad54abe13e36    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 14:36:47 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 14:36:47 +0200    

Click here for diff

Existing text (e.g., create_foreign_table.sgml) uses server_name, not  
servername.  

M doc/src/sgml/ref/alter_subscription.sgml
M doc/src/sgml/ref/create_subscription.sgml

Do not reuse rd_smgr in fork loop when enabling data checksums

commit   : ab918a4fab0a6a8855b230d140bbf89fb090ad3e    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 4 Aug 2026 12:16:55 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 4 Aug 2026 12:16:55 +0200    

Click here for diff

ProcessSingleRelationByOid called RelationGetSmgr(rel), discarded the  
result, and then read rel->rd_smgr directly when looping over forks.  
Only RelationGetSmgr is authorized to read that field since a relcache  
invalidation resets rd_smgr to NULL.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>  
Reviewed-by: ChangAo Chen <cca5507@qq.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CADzfLwXGvb4Y-mqy8T+O0f_tkXR1sTDBGzP5Z=V_qcGnZ46rWg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/postmaster/datachecksum_state.c

pg_surgery: Fix infinite loop on large TID arrays

commit   : 346fbdcc2a92e86c7e964d637f8333c7b8197143    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 4 Aug 2026 11:44:11 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 4 Aug 2026 11:44:11 +0200    

Click here for diff

heap_force_common() tracked the current position in the caller-supplied  
tid[] using OffsetNumber, which is only 16 bits wide, so when the array  
held more than 65535 entries, the updated index wrapped around and the  
outer loop never reached the exit condition.  A SQL call with a  
sufficiently large TID array would then run until interrupted.  
  
Fix by tracking the tid[] position using int instead of OffsetNumber.  
A regress case based on the report is included.  
  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reported-by: Yuelin Wang <1217816127@qq.com>  
Backpatch-through: 14  
Bug: #19607  
Discussion: https://postgr.es/m/19607-2f256a66481c514b@postgresql.org  

M contrib/pg_surgery/expected/heap_surgery.out
M contrib/pg_surgery/heap_surgery.c
M contrib/pg_surgery/sql/heap_surgery.sql

doc: Add PROPERTY GRAPH to the access privilege tables

commit   : 63c3bbb39f9cb2d2bd830c8e286e03356e6e44a7    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 10:31:55 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 10:31:55 +0200    

Click here for diff

The SELECT privilege can be granted on a property graph, and its  
privileges can be examined with psql's \dp command, but property  
graphs were missing from both summary tables in the "Privileges"  
section: the applicable object types for SELECT in the privilege  
abbreviations table, and the per-object-type row in the summary of  
access privileges table.  Add the missing entries so the tables match  
the actual behavior described for the SELECT privilege and in GRANT.  
  
While at it, also add a test for \dp on a property graph.  
  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAOzEurScgwLDXQmNFnDZANGAMMiva9GnLH_kO8qGtGVHUvVk2A%40mail.gmail.com  

M doc/src/sgml/ddl.sgml
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Prohibit GRANT ... ON TABLE on a property graph

commit   : fa62d4f6ea7529aa75105aa1ed3b43477ab365a0    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 09:55:03 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 4 Aug 2026 09:55:03 +0200    

Click here for diff

We allowed GRANT ... ON TABLE on sequences for backward compatibility.  
We don't need to consider backward compatibility in case of property  
graphs since we will be prohibiting its usage on property graph from  
the very release which introduced property graphs.  
  
Change regression tests that used GRANT ... ON [TABLE] on property  
graphs to use GRANT ... ON PROPERTY GRAPH instead.  
  
While here, add the missing RELKIND_PROPGRAPH cases in  
pg_class_aclmask_ext() and in the object-type switch in  
ExecGrant_Relation() so that the default ACL and the objtype passed to  
restrict_and_check_grant() are correct.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/20260630023308.c7.noahmisch@microsoft.com  

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

Checkpoint replication slots later in the checkpoint cycle

commit   : 69ed7fd7e9da1cff2f04af04f630287971fe99fe    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 4 Aug 2026 17:06:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 4 Aug 2026 17:06:38 +0900    

Click here for diff

Previously, CheckPointReplicationSlots() ran at the start of  
CheckPointGuts(), while WAL cleanup occurred much later in  
CreateCheckPoint() and CreateRestartPoint(), after the buffer write  
and ProcessSyncRequests() phases. During a spread checkpoint, this gap  
could be several minutes.  
  
During that time, active replication slots could advance their  
restart_lsn. However, replicationSlotMinLSN had already been  
computed from the older saved values. As a result, KeepLogSeg() could  
retain WAL segments that were no longer needed, causing unnecessary  
pg_wal growth until the next checkpoint or restartpoint.  
  
Fix this by moving CheckPointReplicationSlots(),  
CheckPointSnapBuild(), and CheckPointLogicalRewriteHeap() to just  
before CheckPointTwoPhase(), after the buffer write and  
ProcessSyncRequests() phases. This makes WAL retention decisions use  
the latest replication slot state. The logical snapshot and rewrite heap  
cleanup decisions also benefit from the updated saved restart_lsn.  
  
Author: Ants Aasma <ants@cybertec.at>  
Author: Hüseyin Demir <huseyin.d3r@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CANwKhkPCBcTQ_pk06MD5W5YYNnuYHp8dLNuOUz8-5pMBMPY1Bw%40mail.gmail.com  

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

Fix error handling in getCopyDataMessage() and pqFunctionCall3()

commit   : 676bf48e1e5241f1da4088515ae4ce9fd435e417    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 4 Aug 2026 17:03:27 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 4 Aug 2026 17:03:27 +0900    

Click here for diff

Commit f6f0542266f0 changed getNotify(),  
getParameterStatus(), and related libpq message-processing paths to  
abandon the connection on out-of-memory errors.  
  
However, getCopyDataMessage() and pqFunctionCall3() did not handle  
this new fatal-error state. Both can process asynchronous  
NotificationResponse and ParameterStatus messages while waiting for  
other responses. If one of those messages triggered a fatal error, these  
loops continued processing instead of reporting it immediately.  
  
Fix this by checking for a saved fatal error after processing an  
asynchronous message. If the connection has been abandoned, return the  
appropriate error immediately instead of continuing to parse input.  
  
Backpatch to v18, where commit f6f0542266f0 introduced this issue.  
  
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAO6_XqpGfm+XHE1OzS=_+jroeDOxhhGa11P3cbm9q2gT05yorA@mail.gmail.com  
Backpatch-through: 18  

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

Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions

commit   : fef160d8b0ddf72e1089133300d30109293f5a71    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 4 Aug 2026 09:06:46 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 4 Aug 2026 09:06:46 +0200    

Click here for diff

Per commit 8bf6ec3ba3a4, a column can be GENERATED only if it is such in  
the whole inheritance tree.  
  
For this reason, ATPrepDropExpression refuses to be called with ONLY on  
a partitioned table. To detect this, the current implementation checks  
whether recurse is set to false and the rel has direct children.  
  
Recursion is implemented with ATSimpleRecursion, which calls ATPrepCmd  
with recurse = false for every node in the tree. Inner nodes (for  
example a partition which itself has subpartitions) then fail the check,  
accidentally preventing the command from working on inheritance trees of  
depth > 2.  
  
This commit fixes it by also checking that we're at the top level of the  
recursive calls using the recursing parameter, which is always true when  
called through ATSimpleRecursion, always false when invoked on the root  
rel.  
  
Also, remove a comment claiming that DROP EXPRESSION could be  
implemented with some effort.  It cannot, as the commit message for  
8bf6ec3ba3a4 explains.  
  
Author: Alberto Piai <alberto.piai@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/DHMT78XOD8BK.341V3H87KZ7NO@gmail.com  

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

Fix missing money overflow checks for INT64_MIN / -1

commit   : b4dfae2ffac25ea6caf116091b5ed15e140ddfc0    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 4 Aug 2026 17:59:13 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 4 Aug 2026 17:59:13 +1200    

Click here for diff

Similar to what 1f7cb5c30 did for the INT types, protect against  
overflow when dividing the lowest possible money value by -1.  This  
cannot be represented on a two's complement machine.  
  
Without this check, the result depends on the machine, and in the worst  
case, could result in a crash.  With the fix installed, this will now  
result in:  
  
ERROR:  money out of range  
  
Bug: #19585  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reported-by: Michael Malis <malis@pgrust.com>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>  
Discussion: https://postgr.es/m/19586-bb603bf5ad9934dd%40postgresql.org  
Discussion: https://postgr.es/m/CAB8bMisnXJVXte6s3kUOpuuAY9%3D9kehG6MMX-%2BTQoFsSGan22Q%40mail.gmail.com  
Backpatch-through: 14  

M src/backend/utils/adt/cash.c
M src/test/regress/expected/money.out
M src/test/regress/sql/money.sql

Fix missing MCXT_ALLOC_NO_OOM handling in MemoryContextAllocAligned

commit   : 03f420c37f898b817d24ee6af55eb5e41ec51655    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 4 Aug 2026 16:06:38 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 4 Aug 2026 16:06:38 +1200    

Click here for diff

Fix missing NULL check in MemoryContextAllocAligned().  The underlying  
call to MemoryContextAllocExtended() could return NULL when  
flags contains MCXT_ALLOC_NO_OOM and the underlying malloc fails.  
  
There are no current callers using MemoryContextAllocAligned() that pass  
the MCXT_ALLOC_NO_OOM in core, so no live bug fix in core here. However,  
an extension might use this pattern, so we'd better fix.  
  
Fix this so we correctly pass the NULL to the caller rather than trying  
to write to a NULL memory address.  
  
This also fixes the same bug in AlignedAllocRealloc(), which is also  
unused in core.  
  
Backpatch to v16, where these functions first appeared.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/07DAC4C3-120D-4F3C-8FEE-BA236F7E9C1D@gmail.com  
Backpatch-through: 16  

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

Validate publisher for retain_dead_tuples in the apply worker.

commit   : a3fed7608f75336ba748ab2784b2c5fa8cbf284d    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Tue, 4 Aug 2026 08:58:32 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Tue, 4 Aug 2026 08:58:32 +0530    

Click here for diff

Enabling retain_dead_tuples requires the publisher to run PostgreSQL 19 or  
later and to not be in recovery. Previously this was checked only at DDL  
time. That forced ALTER SUBSCRIPTION ... ENABLE to connect to the  
publisher, so pg_upgrade (which re-enables subscriptions during restore)  
failed if the publisher was unreachable. It was also not authoritative,  
since the publisher's version or recovery status can change afterwards,  
for example after a failover.  
  
Perform the check authoritatively in the apply worker when it connects,  
and stop doing it when enabling a subscription. ENABLE is the only command  
issued during restore that triggered it, so this also fixes the pg_upgrade  
failure. The DDL-time check is kept as a convenience for the other paths,  
none of which are issued during restore.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Analyzed-by: Jeff Davis <pgsql@j-davis.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Jeff Davis <pgsql@j-davis.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Backpatch-through: 19, where it was introduced  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch@microsoft.com  

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

Remove unused field from PartitionDescData struct

commit   : 5ea1022e4a987b6cffe4ca6014fd1389b3311f88    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 4 Aug 2026 13:29:42 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 4 Aug 2026 13:29:42 +1200    

Click here for diff

3592e0ff9 added caching logic to ExecFindPartition() to allow faster  
partition lookups for LIST and RANGE partitions when we hit the same  
partition multiple times in a row.  The last_found_part_index field was  
added, but it was never used, so remove it.  Caching works by caching the  
last matching index into the PartitionBoundInfo.datums, not by caching the  
last found partition index.  
  
Update comments to reflect this, and perform other general improvements to  
the comments in this area.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAJ7c6TMRxO6vo1tNgLZs4nTNizpjCSWdUviB8Mf3nkYiNHNhzg@mail.gmail.com  

M src/backend/executor/execPartition.c
M src/backend/partitioning/partdesc.c
M src/include/partitioning/partdesc.h

Handle concurrently-dropped relations in database-wide VACUUM.

commit   : 824d5f6241ea7a0a85c9d2b3d27beb78e42a36ab    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 3 Aug 2026 16:02:07 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 3 Aug 2026 16:02:07 -0500    

Click here for diff

When VACUUM or ANALYZE is run without a table list, we scan  
pg_class to build the list of relations to process, and we  
check the privileges on each relation we find.  Since we don't  
take any locks on the relations at this point, it's possible  
for one to be concurrently dropped, in which case the privilege  
check fails with an ERROR such as the following:  
  
	ERROR:  relation with OID 16388 does not exist  
  
This unnecessarily aborts the entire command.  To fix, use  
pg_class_aclcheck_ext() for the privilege check so that we can  
detect concurrently-dropped relations and silently skip them.  
There's no need to emit a WARNING for such relations because  
they weren't explicitly named, and a drop at this point is no  
different than one that happened before our pg_class scan  
began.  Note that concurrent drops that occur later on are  
already handled gracefully by vacuum_open_relation().  
  
The new missing_ok behavior is limited to get_all_vacuum_rels().  
All other callers of vacuum_is_permitted_for_relation() should  
hold a lock on the relation that prevents it from being  
concurrently dropped, so this commit also adds an assertion to  
that effect.  
  
Oversight in commit a556549d7e.  
  
This is a bug fix and could be back-patched, but given the  
presumed rarity of the race condition and the lack of field  
reports, I'm not going to bother.  
  
Reported-by: ChangAo Chen <cca5507@qq.com>  
Author: ChangAo Chen <cca5507@qq.com>  
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/tencent_F9D483523BB0D082C2EFDA80142F192DBC07%40qq.com  

M src/backend/commands/analyze.c
M src/backend/commands/vacuum.c
M src/include/commands/vacuum.h

postgres_fdw: reject use_scram_passthrough for subscriptions.

commit   : d63f214d68d95bc51fec630023d20074e6d086df    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 13:41:17 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 13:41:17 -0700    

Click here for diff

The subscription is initiated from a logical replication worker, so  
SCRAM pass-through won't work.  
  
Partially addresses finding 3 in report from linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch@microsoft.com  
Backpatch-through: 19  

M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/t/010_subscription.pl
M doc/src/sgml/postgres-fdw.sgml

Improve DROP SERVER handling of dependent subscriptions.

commit   : b66ea17a3a1383a24096ba6a3fe1e83c5c059a35    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 13:21:46 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 13:21:46 -0700    

Click here for diff

We do not allow a DROP SERVER ... CASCADE to implicitly drop a  
subscription, because it's in a shared catalog and dropping a  
subscription has side effects. Instead we throw an error and the user  
must drop the subscription explicitly. Document this behavior and add  
a HINT to the error message.  
  
Generalize AcquireDeletionLock()/ReleaseDeletionLock() to use shared  
object locks for all shared catalogs, which includes AuthMemRelationId  
and now SubscriptionRelationId.  
  
Move error message after AcquireDeletionLock() to avoid an unnecessary  
error if there's a concurrent DROP SUBSCRIPTION.  
  
Addresses finding 10 & 15 in report from linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch@microsoft.com  
Backpatch-through: 19  

M doc/src/sgml/ref/drop_server.sgml
M src/backend/catalog/dependency.c
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql

Fix lock release for role membership grants in DROP OWNED BY.

commit   : b48caa7dfde8991ee09226593c381bd3442297dc    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 12:21:05 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 12:21:05 -0700    

Click here for diff

Commit 6566133c5f5 added a case for AuthMemRelationId in  
AcquireDeletionLock(), but not ReleaseDeletionLock(). The fall-through  
case would go to UnlockDatabaseObject(), which would raise a WARNING;  
and the lock would be retained until the end of the transaction.  
  
Add the missing branch.  
  
Discussion: https://postgr.es/m/2487ddcd737d4fc8e408e87aa9ad4365eed3bbb3.camel@j-davis.com  
Backpatch-through: 16  

M src/backend/catalog/dependency.c
A src/test/isolation/expected/drop-owned-grant.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/drop-owned-grant.spec

Don't skip invalid databases when enabling data checksums

commit   : 6a6e99f859db1163a3646eaf8e47f865312dfc07    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 3 Aug 2026 20:44:57 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Mon, 3 Aug 2026 20:44:57 +0200    

Click here for diff

When enabling checksums cannot process a database, the launcher uses  
DatabaseExists to tell a concurrent drop (benign) from a real failure.  
Since 1df361e3d82 that check also treats a present, but-invalid, data-  
base as non-existent.  An interrupted DROP DATABASE flush the invalid  
marker before the row and files are removed, so a crash or ERROR can  
leave an invalid row whose files remain on disk.  
  
Report a database as existing whenever its catalog row is found to  
ensure that checksums cannot be enabled if there are invalid databases.  
The AccessShareLock in DatabaseExists already waits out an in-flight  
drop, so an invalid-but-present row can only be an interrupted drop  
leftover whose files still need checksums; enabling then aborts until  
it is dropped.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFOGdqxtZ5-6gb4apqmvoH=Z+TNH8RKJ3mVtoR1HirKQWg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/dbcommands.c
M src/backend/postmaster/datachecksum_state.c
M src/test/modules/test_checksums/t/005_injection.pl

Do not log subscription conninfo.

commit   : 448c4b3bfd0e302cc8d856560c33340594f863cc    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 11:34:58 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Mon, 3 Aug 2026 11:34:58 -0700    

Click here for diff

Logging connection information, even at DEBUG1, creates unnecessary  
risks. Remove the entire log message because it had no other useful  
content.  
  
Addresses finding 14 in report from linked discussion.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260710195902.4f.noahmisch@microsoft.com  
Backpatch-through: 14  

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

Undo inadvertent loosening of archive filename checking.

commit   : dd62a71013c8c4d988624d0424503ec40520760e    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 3 Aug 2026 12:25:01 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Mon, 3 Aug 2026 12:25:01 -0400    

Click here for diff

Commit c8a350a439826267186c187dbfbf1f839f7521aa attempted to consolidate  
code for identify possibly-compressed tar archives by suffix into a new  
function parse_tar_compress_algorithm(). Unfortunately, the refactoring  
wasn't perfect, and slightly changed the behavior at both existing call  
sites.  
  
In CreateBackupStreamer(), the previous code required the filename to  
consist of more than just a suffix, so the aforementioned commit had the  
effect of allowing pg_basebackup to accept a file from the server whose  
entire name was something like .tar.gz -- which should never happen, but  
let's reject it as previous releases did.  
  
In precheck_tar_backup_file(), the previous code required the suffix to  
be immediately adjacent to the prefix already checked, so the commit  
in question allowed pg_verifybackup to accept not only filenames like  
base.tar.gz but also filenames like baseFOOBARBAZ.tar.gz. While such  
filenames are perhaps unlikely, rejecting them is correct, so let's go  
back to that behavior.  
  
Discussion: http://postgr.es/m/CA+TgmoYJY8FkoeYKGF_YF1S6uOK7fd0Bd3zrw0XY_oZXbmVFpQ@mail.gmail.com  
Reported-by: Sarath Kumar <Sarath@iitmpravartak.net>  
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>  
Backpatch-through: 19  

M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_waldump/pg_waldump.c
M src/common/compression.c
M src/include/common/compression.h

Remove unused arg and dead code in set_attnotnull()

commit   : 36f7330b8b2238c2093d7eac521f996b33e66121    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 3 Aug 2026 13:52:41 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 3 Aug 2026 13:52:41 +0200    

Click here for diff

The is_valid parameter was never referenced in the function body, and  
the 'thisatt' local variable is set but never used.  Remove both.  
  
Oversight in a379061a22a8.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Backpatch-through: 18  
Discussion: https://postgr.es/m/CAA5RZ0tHnvSrfUy4jWJchjvkL_aJe0hCnZpMsFRdLrSxCne5qQ@mail.gmail.com  

M src/backend/commands/tablecmds.c

Add dshash_get_dsa_area(), able to retrieve the DSA area of a dshash table

commit   : 762e329e83f2194969a6ea859ddd08361a18ac98    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 3 Aug 2026 20:05:23 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 3 Aug 2026 20:05:23 +0900    

Click here for diff

Code using GetNamedDSHash() to retrieve a dshash table may also want to  
limit its size, but there is actually no easy way to do so because the  
dsa_area of a hash table is hidden within dshash.c.  
  
This commit adds dshash_get_dsa_area() to close the gap, which returns  
the dsa_area for a given dshash_table.  The DSA area retrieved can then  
be passed to dsa_set_size_limit(), to limit its size.  This accessor  
routine also opens the door for allocating additional objects in the  
same DSA area as a hash table, which may be useful for some.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0tKfCVqFnMZtavM42H63ha2Haf_C4mbJNWqkaW30cPW1w@mail.gmail.com  

M src/backend/lib/dshash.c
M src/include/lib/dshash.h

doc: Clarify VERBOSE output for ANALYZE and VACUUM

commit   : f4898759c5c311b7a3d2801e6363a62f51cd8671    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 3 Aug 2026 19:03:40 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 3 Aug 2026 19:03:40 +0900    

Click here for diff

ANALYZE VERBOSE and VACUUM VERBOSE both print per-table information  
at INFO level, including the table currently being processed and  
various statistics.  However, the documentation described ANALYZE  
VERBOSE only as displaying generic "progress messages", while VACUUM  
VERBOSE used different wording about a vacuum activity report.  
  
Reword the VERBOSE option descriptions and Outputs sections to describe  
the actual output more consistently.  
  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Maciek Sakrejda <m.sakrejda@gmail.com>  
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>  
Reviewed-by: Yushu Chen <gentcys@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAOzEurTpMTUEW8kHu-zKB0EBtuPfpvyoJ--8pxKe87p24BGrpg@mail.gmail.com  

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

Fix missing space before WHERE in GRAPH_TABLE deparse

commit   : 780fa49746d57403b871f4ef4c92499b324df32c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 3 Aug 2026 10:14:30 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 3 Aug 2026 10:14:30 +0200    

Click here for diff

get_graph_pattern_def() emitted the pattern-level WHERE keyword as  
"WHERE " with no leading space, so reverse-parsing produced output  
like "(o IS orders)WHERE (...)".  The element-level WHERE deparse in  
get_path_pattern_expr_def() already prepends a separating space; the  
pattern-level branch was inconsistent with it.  Emit " WHERE " to  
match.  
  
The output still re-parses to the same tree, so this is cosmetic.  
  
For test coverage, add a whole-pattern WHERE clause to the existing  
customers_us view, which is already reverse-parsed with  
pg_get_viewdef().  
  
Author: Dhruv Chauhan <chauhandhruv351@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CANWwWcpHb0h7tg6otRnL-FV83jwQpAiyw1bhvv8T78kpwZ-0ow%40mail.gmail.com  

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

Fix nullability check for a sub-select's upper-level Vars

commit   : 0d99579320d075eba5733517463d81a2231e373b    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 3 Aug 2026 15:51:59 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 3 Aug 2026 15:51:59 +0900    

Click here for diff

When checking whether a sub-select's output columns can produce NULL,  
so as to decide whether a NOT IN can be converted to an anti-join,  
query_outputs_are_not_nullable() falls back on find_nonnullable_vars()  
for targetlist entries that are plain Vars: if the sub-select's own  
quals prove the Var non-null, the output is non-nullable.  But that  
test compared only varno and varattno, without checking varlevelsup.  
An outer reference in the targetlist could thus be matched against a  
Var of the sub-select's own range table that happens to share the same  
varno and varattno, wrongly proving the output non-nullable and  
allowing an invalid conversion to an anti-join, which yields wrong  
answers when the outer reference is NULL.  
  
To fix, restrict the fallback to Vars of the current query level.  
  
Author: Rui Zhao <zhaorui126@gmail.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAHWVJhGuaFFRpmq4j+mcMcm_HC5QOT7LZsC9bf9b7BCBmvbfMA@mail.gmail.com  
Backpatch-through: 19  

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

Tighten up TS dictionary cache entry creation.

commit   : 4e68b7e291d39bc778f867e08f2741e63417fc2e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 2 Aug 2026 16:49:17 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 2 Aug 2026 16:49:17 -0400    

Click here for diff

In the not-too-likely scenario where we successfully created a hash  
table entry for a TS dictionary, but then failed to make a small  
memory context for it, we left the hash entry in existence but with  
a garbage value for dictCtx.  This confused the code the next time  
through, leading to a crash.  Rearrange things so that we leave  
the hash entry in a well-defined state with dictCtx == NULL, and  
then the next try knows it still needs to make a memory context.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/0f3ddeb5-0dbd-479c-9d0e-ae254758e624@gmail.com  
Backpatch-through: 14  

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

Fix memory-safety bugs in the ispell/hunspell dictionary loader.

commit   : 330a72052cd166894557eff8b4e30e96174b205f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 2 Aug 2026 13:22:39 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 2 Aug 2026 13:22:39 -0400    

Click here for diff

Allocate CompoundAffix with room for its terminator, initialize the  
old-format flag buffer before NIAddAffix(), and reject incomplete or  
missing Hunspell AF aliases.  None of these errors would be likely to  
trigger on real dictionary files, accounting for the lack of previous  
reports; but they're certainly bugs.  
  
Bug: #19595  
Reported-by: Michael Malis <michaelmalis2@gmail.com>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19595-7dc18b4e212c4757@postgresql.org  
Backpatch-through: 14  

M src/backend/tsearch/spell.c

Update time zone data files to tzdata release 2026c.

commit   : 6ca405938d4d65d1979460421ac3327a98a42d44    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 2 Aug 2026 11:26:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 2 Aug 2026 11:26:30 -0400    

Click here for diff

Alberta (America/Edmonton) moved to permanent UTC-06 on  
2026-06-18, which will affect their clocks beginning on 2026-11-01.  
For lack of any clarity on the point, assume their TZ abbreviation  
will be CST from that time forward.  
  
Morocco (Africa/Casablanca) will move to permanent UTC+00,  
without daylight saving time transitions, on 2026-09-20.  
  
Backpatch-through: 14  

M src/timezone/data/tzdata.zi

Add a comment to distinguish backend types

commit   : 7a0299a1348b563c72a57a2a40462e90af9dfbac    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 1 Aug 2026 21:35:51 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 1 Aug 2026 21:35:51 +0200    

Click here for diff

The data checksums entries were seemingly auxiliary processes from  
reading the code, but they are in fact background workers.  Add a  
comment to clarify.  Backpatch down to v19 where online checksums  
were introduced.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwFsBjQs2fv7b72hxzGV_fJMh6LAg4E83pNfDOu1jVgWCA@mail.gmail.com  
Backpatch-through: 19  

M src/include/miscadmin.h

doc: Fix glossary entry for data checksums workers

commit   : c5ad377da7437f44628e3c4cc2e6fceb98cdcec5    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 1 Aug 2026 21:35:19 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sat, 1 Aug 2026 21:35:19 +0200    

Click here for diff

The glossary entry for data checksums workers incorrectly stated that  
they were auxiliary processes, but they are implemented as background  
workers.  Fix, and while there, simplify the entry by combining the  
worker and launcher into a single glossary term.  Backpatch down to  
v19 where online checksums were introduced.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEv-C9ia+rBYyePzO8F=5FVvS412ZqcOupazuOb5RafNg@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/glossary.sgml

pg_verifybackup: Improve some error handling around strtoul() calls

commit   : 355814931141537e51418a276c74e91283da9631    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 1 Aug 2026 19:21:46 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 1 Aug 2026 19:21:46 +0900    

Click here for diff

Three code paths checking the size, timeline ID and system identifier  
stored in a manifest now check for an empty value.  Values are always  
expected in these parts of a backup banifest.  A couple of tests are  
added to validate this behavior  
  
Additionally, precheck_tar_backup_file() checked that "endptr" is NULL.  
Based on the C standard, strtoul() never sets an "endptr" to NULL when  
given a value (that is the case here), returning a pointer to the  
original value if there is nothing to convert.  The pre-tar validation  
code is adjusted to do so.  
  
Author: Tristan Partin <tristan@partin.io>  
Discussion: https://postgr.es/m/DKBS2Z9CGARC.2T07O6TJYSE8B@partin.io  

M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_verifybackup/t/005_bad_manifest.pl
M src/common/parse_manifest.c

Allow IO time to be counted without a matching IO operation in pg_stat_io

commit   : c9a669492719db2fe45cd17259ae0fc3bc4d91c5    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 31 Jul 2026 17:45:45 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 31 Jul 2026 17:45:45 -0400    

Click here for diff

Since 999dec9ec6a816680, pg_stat_io can show read time with zero reads  
for an IO Context: a foreign IO is counted as a read only in the  
initiating backend, while other waiters record only the wait time. That  
violates pgstat_bktype_io_stats_valid(). Relax the check to allow time  
without a matching operation count, since we want to count read wait  
time even in backends that did not initiate the read. This also enables  
future accounting of waits on IO resources (e.g., AIO handles) in  
backends that didn't start the IO.  
  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reported-by: Justin Pryzby <pryzby@telsasoft.com>  
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/ak5lccE4qiQpOBHn@pryzbyj2023  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml
M src/backend/storage/buffer/bufmgr.c
M src/backend/utils/activity/pgstat_io.c

On Windows, make link(2) report ENOTSUP when appropriate.

commit   : 481052c7754013d44a89f50912ba6845398f88df    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 31 Jul 2026 14:39:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 31 Jul 2026 14:39:29 -0400    

Click here for diff

CreateHardLinkA reports ERROR_INVALID_FUNCTION if the target file  
is on a filesystem that doesn't support hard links.  _dosmaperr  
maps that to EINVAL, which confuses zic.c into failure.  zic.c is  
expecting ENOTSUP if the filesystem lacks link support, and will  
properly fall back to making a physical copy if it gets that.  
Hence, add code to map ERROR_INVALID_FUNCTION to ENOTSUP.  
  
(We could instead teach _dosmaperr to do that, but it's far from clear  
that this would be appropriate as a global behavior: intuitively  
it seems like EINVAL should be appropriate most of the time.)  
  
We didn't need this before commit aeb07c55f, because the tzcode  
version we were using before that didn't have this particular  
error-handling logic.  Hence, no back-patch for now; but if we  
decide to back-patch tzcode 2026b or later, we'll need this too.  
  
Author: Vladlen Popolitov <v.popolitov@postgrespro.ru>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/e6122f9b2eef9096f1f11ecc058bcd91@postgrespro.ru  

M src/port/win32link.c

libpq-oauth: Avoid overflow for very large intervals

commit   : b738f7b679672ced054efc36e8da21c24d3a033b    
  
author   : Jacob Champion <jchampion@postgresql.org>    
date     : Fri, 31 Jul 2026 11:08:23 -0700    
  
committer: Jacob Champion <jchampion@postgresql.org>    
date     : Fri, 31 Jul 2026 11:08:23 -0700    

Click here for diff

The slow_down interval parsing code checks explicitly for overflow, but  
since it does that after the signed overflow has already occurred, we  
end up inviting undefined behavior from the compiler anyway.  
  
Use checked arithmetic instead. set_timer() takes a long int in order to  
interface nicely with libcurl, so use an int32 as the interval counter  
and clamp to LONG_MAX during conversion to milliseconds.  
  
Backpatch to 18, where libpq-oauth was introduced.  
  
Reported-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/qtclihmrkq67ach3xjxyi4qcksstin5qxwsnkqefkmotxwh4g6%40ae2bj6jvcmry  
Backpatch-through: 18  

M src/interfaces/libpq-oauth/oauth-curl.c

Prevent walsummarizer from getting stuck at a timeline switch.

commit   : 3e8a0c1b02c3d8b96cd5febacab8aaba4869431f    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Fri, 31 Jul 2026 11:55:54 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Fri, 31 Jul 2026 11:55:54 -0400    

Click here for diff

As previously coded, walsummarizer only wants to read WAL from a file  
where the TimeLineID in the filename exactly matches the TimeLineID being  
summarized. But in some cases, when a timeline switch occurs, the WAL file  
from the old timeline is not archived, because it's never completely  
filled, so the only way to obtain the contents of that last partial  
segment is to read from the first segment on the new timeline. Teach  
WAL summarizer to do that, and add a test case to make sure that it  
works.  
  
Reported-by: Nick Ivanov <nick.ivanov@enterprisedb.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Tested-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>  
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>  
Reviewed-by: Thom Brown <thom@linux.com>  
Discussion: http://postgr.es/m/CA+Tgmobr27GpKDZx3_ezW2+C5_g18i+jSK3sGF_cR-_ESv5N5A@mail.gmail.com  
Backpatch-through: 17  

M src/backend/postmaster/walsummarizer.c
M src/bin/pg_walsummary/meson.build
A src/bin/pg_walsummary/t/003_tli_switch.pl

Fix autovacuum's database sorting.

commit   : baab3268cc275277ee923c0d2fcaf62a61707eea    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 31 Jul 2026 10:34:40 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 31 Jul 2026 10:34:40 -0500    

Click here for diff

When db_comparator() was updated to use pg_cmp_s32(), the arguments  
were listed in the wrong order.  This caused autovacuum to sort the  
databases by their scores in ascending order instead of descending  
order.  To fix, swap the arguments to pg_cmp_s32().  
  
Oversight in commit 3b42bdb471.  
  
Reported-by: Хамидуллин Рустам <r.khamidullin@postgrespro.ru>  
Author: Хамидуллин Рустам <r.khamidullin@postgrespro.ru>  
Discussion: https://postgr.es/m/5c5a7984-b149-b505-7ad9-2a7766c65b55%40postgrespro.ru  
Backpatch-through: 17  

M src/backend/postmaster/autovacuum.c

Remove code for pre-v10 servers from AdjustUpgrade.pm.

commit   : a71825973acddde12c24501d5fe203d8214e82fa    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 31 Jul 2026 09:57:24 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Fri, 31 Jul 2026 09:57:24 -0500    

Click here for diff

We recently removed support for upgrading from pre-v10 servers, so  
we no longer need to handle older versions in this helper module.  
  
Oversight in commit 14d8418083.  
  
Discussion: https://postgr.es/m/ak7Ekv2-L-G55-YD%40nathan  

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

Fix Hash Join performance issue when hashing NULL values

commit   : 60826a352d497b15a30de29b7796d0c2d097a0e3    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 31 Jul 2026 23:23:21 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 31 Jul 2026 23:23:21 +1200    

Click here for diff

adf97c156 allowed expression evaluation to perform hashing, and  
subsequently 9ca67658d fixed a memory stomping bug in that commit  
that caused unrelated-to-hashing expression op steps to stomp on the  
intermediate hash value.  The intermediate hash value needs to be  
maintained when hashing multiple hash keys.  9ca67658d didn't quite get  
things right when in "strict" mode when it aborted hashing early after  
encountering a NULL hash key.  What was meant to happen was that the  
expression returns NULL directly to indicate to the caller the value  
hashed to NULL.  The problem was that any EEOP_HASHDATUM_FIRST_STRICT or  
EEOP_HASHDATUM_NEXT32_STRICT op step that didn't belong to the final  
key to be hashed would have its op->resnull and op->resvalue pointing to  
the location to store the intermediate hash value.  That's correct for  
non-NULLs since we bit-rotate the intermediate value and continue hashing,  
but with the strict case, when we get a NULL key, we immediately jump to  
the "jumpdone" step.  The problem is the jumpdone step expects the  
ExprState resnull and resvalue fields to be set (as they would be if we  
didn't abort hashing early due to the NULL), but when we aborted early,  
the ExprState fields never got set.  This would result in inserting  
records into the hash table that would never match to any join partner,  
which is a waste of CPU and memory.  
  
Here we fix this by having EEOP_HASHDATUM_FIRST_STRICT and  
EEOP_HASHDATUM_NEXT32_STRICT populate the ExprState resnull and resvalue  
fields directly when the value to hash is NULL.  
  
Although Hash Agg and Hashed Subplans do use hashing from ExprStates,  
those were unaffected by this bug, as neither of those uses the STRICT op  
steps.  
  
Thanks to Tomas Vondra for finding the offending commit.  
  
Reported-by: Dan Stefura <dstefura@bluecatnetworks.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/YQBPR0101MB89738FB972FBD02A3640C6D3D6C92@YQBPR0101MB8973.CANPRD01.PROD.OUTLOOK.COM  
Backpatch-through: 18  

M src/backend/executor/execExprInterp.c
M src/backend/jit/llvm/llvmjit_expr.c

Improve wording of sequence origin warning in logical replication.

commit   : 00b3e50054dad648e74d19cc199555381ab366d2    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 31 Jul 2026 09:58:46 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 31 Jul 2026 09:58:46 +0530    

Click here for diff

check_publications_origin_sequences() warns when a subscription with  
origin = NONE synchronizes sequence values that may have originated from  
another subscription. The existing warning is phrased in terms of  
copy_data and copying data, which is appropriate for table synchronization  
but misleading for sequence synchronization.  
  
Reword the warning, detail, and hint to describe sequence synchronization  
and the associated origin = NONE semantics more accurately.  
  
Also fix a typo ("rathen" -> "rather") in a comment in sequencesync.c.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Reported-by: Peter Smith <smithpb2250@gmail.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19, where it was introduced  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/sequencesync.c

Fix error handling in port's getopt_long() for missing argument

commit   : 745becce3321267a4530af286433d1dc6f043360    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 31 Jul 2026 12:44:51 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 31 Jul 2026 12:44:51 +0900    

Click here for diff

In the long option error path, the code previously returned BADARG  
immediately when optstring[0] == ':' for a missing required argument,  
without advancing "optind" or resetting "place".  This error handling  
was inconsistent with the short option path, where both updates are  
performed before returning BADARG (and inconsistent with libc,  
additionally..).  
  
This affects platforms where our port version of getopt_long() is used,  
a concept that should be limited to WIN32 these days.  An argument could  
be made in favor of a backpatch, but this could lead to a slight  
different error handling, for a report that would only show up when  
using incorrect option combinations.  
  
Author: Japin Li <japinli@hotmail.com>  
Discussion: https://postgr.es/m/SY7PR01MB10921AF81F18A8BCFA06388BEB6C22@SY7PR01MB10921.ausprd01.prod.outlook.com  

M src/port/getopt_long.c

Fix issue with RANGE's DEFAULT partition pruning

commit   : 709dfd27f14f07ee87fd9707dc765d0338752b5a    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 31 Jul 2026 15:36:31 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 31 Jul 2026 15:36:31 +1200    

Click here for diff

Partition pruning for RANGE-partitioned tables could mistakenly prune  
the DEFAULT partition in some cases when it was not valid to do so,  
which could lead to rows missing from query results.  
  
The only known cases where this could happen is when combining pruning  
steps from an IS NOT NULL clause with other steps that matched to the  
DEFAULT partition.  This could occur due to RANGE partitioned tables  
having two distinct internal representations for marking if the DEFAULT  
partition should be scanned.  The IS NOT NULL steps would mark the  
"scan_default" boolean, but other steps created for different purposes  
could mark a bound_offset Bitmapset, which would ultimately translate into  
also scanning the default partition.  This could all fail after multiple  
steps were combined with a combine intersect operator, as that will  
intersect the bound_offset bits and only set scan_default if all pruning  
steps have that flag set.  When both input steps to the intersect operator  
had different representations of whether to scan the DEFAULT partition,  
the resulting intersect step result would contain neither representation.  
  
Here, we fix this by having the IS NOT NULL pruning result mark the  
bound_offsets so that it uses both representations to mark that the  
DEFAULT partition must be scanned.  
  
Reported-by: Jacob Brazeal <jacob.brazeal@gmail.com>  
Diagnosed-by: Jacob Brazeal <jacob.brazeal@gmail.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CA+COZaDXrfTaBjLE=Z79MTaH6Xun1V4PeKxLvCNv8mXS8wn0rw@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

Use [re]palloc_array() in buffile.c and fd.c

commit   : d64c805dea27d189904394ece7576762bece278c    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 31 Jul 2026 11:48:18 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 31 Jul 2026 11:48:18 +0900    

Click here for diff

The code paths patched in this commit fix some of remnants not addressed  
by 1b105f9472bd.  We should have more holes in the tree that could  
benefit from stronger type safety guarantees.  These hypothetical holes  
could be addressed later; this finishes the job in storage/file/ for the  
backend code.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/DKBAWPZ2QDOS.10Y3JDUNKFMXX@partin.io  

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

Fix incorrect Result node flattening logic

commit   : d6eac691747499645f21398c9e305d7a671e0229    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Fri, 31 Jul 2026 13:15:52 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Fri, 31 Jul 2026 13:15:52 +1200    

Click here for diff

This fixes some incorrect flattening of nested Result nodes during  
create_plan that was introduced by f2bae51df.  That commit failed to  
maintain the logic that checks for subplans and gating quals from the  
nested Result node before flattening, and that could result in the nested  
gating qual and subplan being lost, which could produce incorrect results.  
  
Bug: #19579  
Reported-by: Viktor Leis <leis@in.tum.de>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/19579-e6296b6c9fc0591c@postgresql.org  
Backpatch-through: 19  

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

Fix background psql session cleanup in 051_effective_wal_level.pl.

commit   : 18f9785e0b3aa75b5c61fb3dd35d9f4fd6723d49    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 30 Jul 2026 16:17:10 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 30 Jul 2026 16:17:10 -0700    

Click here for diff

Commit 6aba42c660c added quit() calls for two background psql sessions  
whose slot creation is canceled by pg_cancel_backend(). Both sessions  
ran with the default ON_ERROR_STOP=1 and ended their script with \q,  
so psql exited as soon as the cancellation error arrived. quit() then  
wrote another \q to the already-closed pipe, making the test die with  
"ack Broken pipe".  
  
Run both sessions with on_error_stop => 0 and drop the trailing \q, so  
that psql stays at the prompt after reporting the error and quit() can  
shut it down cleanly.  
  
Discussion: https://postgr.es/m/CAD21AoCZY1fKYgfkvHGWGiXpatUKd23FSLnDCL4m9bWFjdXNZw@mail.gmail.com  
Backpatch-through: 19  

M src/test/recovery/t/051_effective_wal_level.pl

Fix races between deactivation of logical decoding and slot creation.

commit   : 6aba42c660cc6634c1c49197b0730f5343ff2589    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 30 Jul 2026 12:47:06 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 30 Jul 2026 12:47:06 -0700    

Click here for diff

On standbys, logical decoding can be deactivated while a logical slot  
is being created: either by replaying an  
XLOG_LOGICAL_DECODING_STATUS_CHANGE record, or by the end-of-recovery  
transition upon promotion, which deactivates logical decoding if no  
valid logical slot exists. Both could interleave with a check of the  
logical decoding status performed before creating a new slot because  
the slot invalidation executed as part of the deactivation cannot find  
a slot being created.  
  
For regular slot creation on standbys, EnsureLogicalDecodingEnabled()  
assumed that logical decoding must still be enabled during recovery  
since the caller had already checked it, tripping an assertion failure  
if a concurrent deactivation interleaved.  
  
For slot synchronization, the local slot could be created and  
persisted based on the remote slot information fetched before the  
deactivation was replayed, leaving a valid slot whose restart_lsn  
precedes the deactivation.  
  
Fix both paths by re-checking the logical decoding status after the  
new slot has been created: regular slot creation raises an error, and  
slot synchronization skips persisting the slot. If the deactivation  
happens after the re-check instead, it is guaranteed to invalidate the  
newly created slot.  
  
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAD21AoDEB99VtNbQdDrNd=1gQupJNGMfW_5kdnxq03Q82EK3ag@mail.gmail.com  
Backpatch-through: 19  

M src/backend/replication/logical/logicalctl.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/slot.c
M src/backend/replication/slotfuncs.c
M src/backend/replication/walsender.c
M src/test/recovery/t/051_effective_wal_level.pl

Reject non-finite reltuples when restoring stats

commit   : 7cb9060dcde08ca63df1f0d701b0674e0e8ae811    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 30 Jul 2026 15:30:19 +0200    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 30 Jul 2026 15:30:19 +0200    

Click here for diff

When restoring relation stats, pg_restore_relation_stats() rejected  
calls with (reltuples < -1.0). But that is insufficient - Infinity and  
NaN values both pass that check, and get stored in pg_class verbatim.  
This can have various undesirable consequences.  
  
Fixed by rejecting non-finite reltuple values, in the same non-fatal way  
as for the existing checks (emit WARNING and skip the update). Adds a  
regression test to stats_import for these non-finite values, and to  
check the -1.0 special value is still accepted.  
  
Backpatch to 18, where pg_restore_relation_stats() was introduced.  
  
Patch by Jan Nidzwetzki, minor commit message tweaks by me.  
  
Author: Jan Nidzwetzki <jan@planetscale.com>  
Discussion: https://postgr.es/m/518BA772-8026-412A-AA8F-A7FE4C6B3717@planetscale.com  
Backpatch-through: 18  

M src/backend/statistics/relation_stats.c
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql

Initialize bs_reltuples in parallel GIN builds

commit   : 1232f7a08365619a720dd4c9f35a8fb299b5ea08    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 30 Jul 2026 14:06:20 +0200    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Thu, 30 Jul 2026 14:06:20 +0200    

Click here for diff

Index builds update pg_class.reltuples for the table. In parallel GIN  
builds, workers track the number of processed rows, and report it to  
the leader, who then updates the pg_class with a total. However,  
gin_parallel_build_main failed to initialize the bs_reltuples field,  
leaving it set to whatever happens to be on the stack (which may be  
bogus values like Infinity or NaN, or just impossibly high values).  
  
If such values get reported to the leader and stored in pg_class, that  
can have serious consequences. The pg_class.reltuples field is used to  
decide when a table is due for autovacuum or autoanalyze, and if it  
happens to be set to a bogus value, that may never happen. The field is  
also used by the optimizer when calculating costs.  
  
Fixed by initializing bs_reltuples together with the rest of the build  
state. The bs_numtuples was initialized later, but it seems cleaner to  
just initialize all the fields at once.  
  
After a bogus value gets persisted in pg_class, affected systems are  
unlikely to self-heal. That would require an ANALYZE, but preventing  
that is one of the consequences. We have considered forcing autoanalyze  
in these cases, but there's not a good way to reliably identify bogus  
values (except for a small minority like Infitiny/NaN).  
  
A manual ANALYZE on (possibly) affected tables is the only solution.  
  
Backpatch to 18, where parallel GIN builds were introduced.  
  
Reported-by: Jan Nidzwetzki <jan@planetscale.com>  
Discussion: https://postgr.es/m/518BA772-8026-412A-AA8F-A7FE4C6B3717@planetscale.com  
Backpatch-through: 18  

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

Make sure to detach injection points for re-attaching

commit   : ca7709f78f205d9e6685dee47b92dfadbc1b0ac7    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 30 Jul 2026 12:41:40 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 30 Jul 2026 12:41:40 +0200    

Click here for diff

The new test for enabling data checksums with concurrent CREATE  
DATABASE calls use the same injection points as a previous test  
but accidentally missed detaching the injection point first.  
  
Fix by detaching the injection point in the PG_TEST_EXTRA SKIP  
block to make it can be reused.  Pointed out by buildfarm member  
porpoise which failed with:  
  
    die: error running SQL: 'psql:<stdin>:1:  
	     ERROR: injection point "datachecksumsworker-fake-temptable-wait"  
		        already defined'  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reported-by: Buildfarm member porpoise  
Reviewed-by: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>  
Discussion: https://postgr.es/m/28CF6FD9-E1C4-4C04-8270-E3305AC46171@yesql.se  
Backpatch-through: 19  

M src/test/modules/test_checksums/t/005_injection.pl

Add a couple of commits to .git-blame-ignore-revs

commit   : 28511528aea3cc319c72a59b559a0d3a06fe061b    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 30 Jul 2026 09:21:31 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 30 Jul 2026 09:21:31 +0200    

Click here for diff

M .git-blame-ignore-revs

Skip SUBSCRIPTION TABLE TOC entries with --no-subscriptions.

commit   : 02decf9a9abc76f04a8117aba524dbe561cb720e    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 30 Jul 2026 11:53:06 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 30 Jul 2026 11:53:06 +0530    

Click here for diff

pg_dump in --binary-upgrade mode emits "SUBSCRIPTION TABLE" TOC entries to  
preserve pg_subscription_rel state across pg_upgrade.  When such a dump  
was restored with --no-subscriptions, _tocEntryRequired() skipped the  
"SUBSCRIPTION" entry but not the associated "SUBSCRIPTION TABLE" entries,  
so the restore would try to apply subscription-relation state for a  
subscription that was never created.  
  
Skip "SUBSCRIPTION TABLE" entries as well when no_subscriptions is set.  
  
This can happen when pg_subscription_rel has entries, the dump is taken  
with --binary-upgrade, and it is restored with --no-subscriptions.  
  
Reported-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 17, where it was introduced  
Discussion: https://postgr.es/m/OS9PR01MB121493DA4C1A7748B11A646D8F5C02@OS9PR01MB12149.jpnprd01.prod.outlook.com  

M src/bin/pg_dump/pg_backup_archiver.c

Fix SystemTap dtrace warning about smgr probe argument types.

commit   : 8f191a79617d906e34d041382e6ecfbf78166a65    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 29 Jul 2026 20:25:54 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 29 Jul 2026 20:25:54 -0400    

Click here for diff

Commits ca326e903 and 1f8c504e3 widened the byte-count arguments of  
smgr__md__read__done and smgr__md__write__done to "long long int".  
SystemTap's dtrace(1) fails on that specific spelling and falls back  
with a warning (misreported near the previous probe).  Use ssize_t  
and size_t instead, matching the md.c call sites.  
  
Revise probes.d's note about which types are usable as probe  
arguments: recommend using system-supplied type names (macOS dtrace  
rejects names like PostgreSQL's uint64), and call out "long long int"  
as a known SystemTap failure case rather than a wider failure mode.  
  
Also, update the monitoring.sgml entries for these probes,  
which were missed by the prior commits.  
  
Reported-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/697d3c88568442cd637d8453d129f1bb14bbd2a8.camel@cybertec.at  

M doc/src/sgml/monitoring.sgml
M src/backend/utils/probes.d

pgindent fix for a84eca6627f

commit   : b43e8f4b3dc5b361e78f237b136c9c1f817e13c4    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 22:02:57 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 22:02:57 +0200    

Click here for diff

M src/backend/commands/vacuumparallel.c

ssl: Use the correct feature macros for TLS protocol support

commit   : 1ce49fab6026ba53dbe29576a53e67fe9e1557f7    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:14:31 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:14:31 +0200    

Click here for diff

Our test for if the underlying TLS library supported a specific  
version tested against the TLSX_Y_VERSION set of macros. These  
are however always defined, regardless of if the library was  
built without support for the specific protocol version.  Fix  
by using the feature test macros OPENSSL_NO_TLSX_Y which are  
intended for this usecase.  
  
The previous coding held no risk of protocol downgrade against  
the underlying library, a library not supporting the protocol  
version selected would simply error out as the feature isn't  
available.  This can be easily verified using a modern version  
of LibreSSL, which in version 3.8 disabled TLS1 and 1.1 by  
default.  Once we bump our minimum supported version of LibreSSL  
to 3.8+ we can add a test for this.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: Yilin Zhang <jiezhilove@126.com>  
Discussion: https://postgr.es/m/68B9881D-DAA8-467D-A251-C96E98E57BA0@yesql.se  

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

ssl: Replace deprecated API to get commonName

commit   : 54dee94e6a71817877dfdeb2c2c811330e58e754    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:14:18 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:14:18 +0200    

Click here for diff

X509_NAME_get_text_by_NID was deprecated in OpenSSL 4.0.0, and could  
be removed in a future version of OpenSSL.  The replacement APIs are  
available in all versions of OpenSSL and LibreSSL that we support so  
we can easily change to make the code future proof.  
  
The reason for the deprecation is that X509_NAME_get_text_by_NID can  
only grab the first entry in a list, and doesn't handle multibyte  
strings well.  The fix is to get the index of the name entry with  
X509_NAME_get_index_by_NID and use X509_NAME_get_entry to extract  
the data.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: Yilin Zhang <jiezhilove@126.com>  
Discussion: https://postgr.es/m/68B9881D-DAA8-467D-A251-C96E98E57BA0@yesql.se  

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

ssl: Use TLS_method instead of deprecated SSLv23_method

commit   : 05d6b5afdf0fbd0b114534081f05f072584bec8c    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:14:08 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:14:08 +0200    

Click here for diff

The SSLv23_method() function has been an alias for TLS_method since  
2015 (OpenSSL commit 32ec41539b5b) so we should use the appropriate  
name to avoid confusion.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: Yilin Zhang <jiezhilove@126.com>  
Discussion: https://postgr.es/m/68B9881D-DAA8-467D-A251-C96E98E57BA0@yesql.se  

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

ssl: Remove static var tracking tls_init_hook warnings

commit   : 9e526a14d7cb36c24d6faebf32df31251a97edc9    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:13:25 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 21:13:25 +0200    

Click here for diff

If the TLS init hook is defined in conjunction with ssl_sni we  
issue a warning to help the user re-configure the cluster.  To  
avoid drowning the log in warnings, we log only once instead of  
once per host.  This removes the static variable tracking the  
warning to aid future multithreading efforts.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Andreas Karlsson <andreas@proxel.se>  
Reviewed-by: Yilin Zhang <jiezhilove@126.com>  
Discussion: https://postgr.es/m/68B9881D-DAA8-467D-A251-C96E98E57BA0@yesql.se  

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

doc: remove added space within synopsis replaceable tags

commit   : 07374f7fa1a0b1ee09c5ec91d7dc8b2732f330bf    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Wed, 29 Jul 2026 14:20:35 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Wed, 29 Jul 2026 14:20:35 -0400    

Click here for diff

Restructuring the tags makes the output consistent and doesn't require  
added spaces.  
  
Reported-by: Peter Smith  
  
Author: Peter Smith  
  
Discussion: https://postgr.es/m/CAHut+Pu8JahGm76CMdpzH350pHJedA4R2b8JmOim3+m3yxft3Q@mail.gmail.com  
  
Backpatch-through: 19  

M doc/src/sgml/ref/initdb.sgml
M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/ref/pg_controldata.sgml
M doc/src/sgml/ref/pg_createsubscriber.sgml
M doc/src/sgml/ref/pg_resetwal.sgml
M doc/src/sgml/ref/pg_rewind.sgml

Fix stale comment in parallel_vacuum_main().

commit   : a84eca6627fe02d1e299b9a80dc4cb82a0b557ff    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 29 Jul 2026 09:52:07 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 29 Jul 2026 09:52:07 -0700    

Click here for diff

The comment claimed that a parallel vacuum worker has only the  
PROC_IN_VACUUM flag because parallel vacuum is not supported for  
autovacuum, but commit 1ff3180ca01 allowed autovacuum to use parallel  
vacuum workers.  
  
The assertion itself still holds: the leader, whether a backend  
running VACUUM or an autovacuum worker, sets PROC_IN_VACUUM before  
taking its snapshot, and a parallel worker inherits the flag when  
importing the leader's snapshot. The leader's other flags don't reach  
the worker, since the snapshot import copies only the PROC_XMIN_FLAGS  
bits and PROC_IS_AUTOVACUUM is never set on parallel workers, which  
run as regular background workers. Reword the comment to explain that.  
  
Oversight in commit 1ff3180ca01.  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CALj2ACVwQ4WABqq8Lnf+VZEJ45jcTFhyFLFr_ctfS4=QLL-r5w@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/vacuumparallel.c

Fix autovacuum-induced flakiness in backwards scan test.

commit   : 23a6e25593729feaafb6f3491a1222247f6e0125    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 29 Jul 2026 11:17:32 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 29 Jul 2026 11:17:32 -0400    

Click here for diff

Two of the permutations in backwards-scan-concurrent-splits rely on  
their VACUUM step deleting the leaf pages that the waiting backwards  
scan will have to recover from.  VACUUM can only do that when it's able  
to remove the index tuples whose heap tuples the concurrent session just  
deleted.  An autovacuum worker holding a snapshot holds back the  
removable cutoff, which leaves the pages non-empty, and so undeleted,  
causing the test to fail spuriously.  
  
To fix, wait for the removable cutoff to advance past the deletions  
before the scan acquires its snapshot.  This is much like commit  
1c64d2fc, which dealt with the same hazard in nbtree_half_dead_pages by  
adding the wait_prunable() helper that we reuse here.  
  
Oversight in commit e395fbd3.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Discussion: https://postgr.es/m/b61d9944-d7a3-45f3-b69a-f18c8bfbbbd0@gmail.com  

M src/test/modules/nbtree/expected/backwards-scan-concurrent-splits.out
M src/test/modules/nbtree/specs/backwards-scan-concurrent-splits.spec

Fix cascading standby reconnect failure after archive fallback

commit   : b614de4876bb4e4264a99ec4c6f2582ad4e0ca8d    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 29 Jul 2026 17:15:45 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Wed, 29 Jul 2026 17:15:45 +0200    

Click here for diff

A cascading standby could fail to reconnect to its upstream standby with  
"requested starting point ... is ahead of the WAL flush position" after  
falling back to archive recovery.  This happened because archive  
recovery processes whole segment files, so after replaying a segment the  
cascade's next read position lands at the start of the following  
segment, which is ahead of the upstream's flush position reported by  
GetStandbyFlushRecPtr() (still inside the just-replayed segment).  
  
Fix by having the walreceiver check the upstream's current WAL flush  
position via IDENTIFY_SYSTEM before issuing START_REPLICATION.  
IDENTIFY_SYSTEM already returns this position (as xlogpos), but  
walrcv_identify_system() previously discarded it; now we have a use for  
it.  If the requested start point exceeds the upstream's flush position  
on the same timeline, the walreceiver waits for  
wal_retrieve_retry_interval and retries.  
  
The wait is limited to gaps of at most one WAL segment, which is the  
expected case from the segment-granularity of archive recovery.  Larger  
gaps indicate the upstream is genuinely behind, so START_REPLICATION is  
allowed to proceed (and fail) normally, letting the startup process fall  
back to other WAL sources.  The first wait is logged at LOG level;  
subsequent waits are demoted to DEBUG1 to avoid log noise.  The  
walreceiver honors wal_receiver_timeout during the wait, so it will exit  
if the upstream doesn't catch up in time.  
  
To preserve ABI compatibility on back branches, the flush position from  
IDENTIFY_SYSTEM is communicated via a new global variable  
(WalRcvIdentifySystemLsn) rather than changing the signature of  
walrcv_identify_system().  
  
The bug was introduced in Postgres 9.3 by commit abfd192b1b5b, which  
added a flush-position check in StartReplication() that rejects requests  
ahead of the upstream server's WAL flush position.  
  
Author: Marco Nenciarini <marco.nenciarini@enterprisedb.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CA+nrD2cTuTkkX5WXVZengTYYZbAO6zV8K+Tri-R0fbLFuoyMBA@mail.gmail.com  

M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/backend/replication/logical/worker.c
M src/backend/replication/walreceiver.c
M src/backend/utils/activity/wait_event_names.txt
M src/include/replication/walreceiver.h
M src/test/recovery/meson.build
A src/test/recovery/t/055_cascade_reconnect.pl

doc: Add getdatabaseencoding to function docs

commit   : 9fa2c1ebd1757db6032cf81b53f973941be77747    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 12:37:02 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 29 Jul 2026 12:37:02 +0200    

Click here for diff

The getdatabaseencoding function was added in bf00bbb0c494 in 1998 but  
was never documented.  While mostly used in tests, there is no reason  
not to document it as this function isn't going anywhere and is already  
used in extensions.  
  
Author: Ian Barwick <barwick@gmail.com>  
Reviewed-by: Thom Brown <thom@linux.com>  
Reviewed-by: surya poondla <suryapoondla4@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAB8KJ=ij+pznQGub=DkyJuKL=tC=Q=07qSahTyw7TLb0DdNJsg@mail.gmail.com  

M doc/src/sgml/func/func-string.sgml

Protect PGPROC lookup when terminating background workers

commit   : 33b392eaabdd1c563d40388784df051821e03c6b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 29 Jul 2026 17:39:37 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 29 Jul 2026 17:39:37 +0900    

Click here for diff

TerminateBackgroundWorkersForDatabase() uses BackendPidGetProc() and,  
until now, accessed fields of the returned PGPROC after releasing  
ProcArrayLock, including its database OID.  If the PGPROC slot is  
recycled during this window, the database OID being checked may belong  
to a different backend, causing an unrelated background worker to be  
terminated.  
  
Triggering this bug requires a very narrow race: the background worker  
identified by BackendPidGetProc() must exit, its PGPROC slot must be  
released and reused, and only then must  
TerminateBackgroundWorkersForDatabase() examine the database OID.  
  
TerminateBackgroundWorkersForDatabase() holds BackgroundWorkerLock,  
preventing parallel workers and dynamically registered workers (such as  
those created by worker_spi) from reusing the slot.  As far as I know,  
the only plausible scenario is a static background worker that exits and  
is restarted quickly enough to reuse the same PGPROC slot within the  
race window.  In practice, this race is extremely unlikely, still  
reachable in theory.  
  
Oversight in f1e251be80a0.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Aya Iwata <iwata.aya@fujitsu.com>  
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>  
Discussion: https://postgr.es/m/78E81763-EA1D-4788-9741-4092BCB997A5@gmail.com  
Backpatch-through: 19  

M src/backend/postmaster/bgworker.c

Avoid accumulating relation locks during sequence synchronization.

commit   : c12c101b0846b1e6488f2dc986a852fbc6bf2e3b    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 29 Jul 2026 09:46:53 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 29 Jul 2026 09:46:53 +0530    

Click here for diff

While collecting the sequences to synchronize, the sequence sync worker  
opened each INIT sequence with RowExclusiveLock and held it until the  
transaction committed. With many such sequences, this could exhaust the  
shared lock table and fail with "out of shared memory".  
  
The worker only reads each sequence's identity (namespace and name) here  
and needs it to stay stable while read, for which AccessShareLock is  
enough, as it conflicts with the AccessExclusiveLock taken by DROP,  
RENAME, and SET SCHEMA. Take that lock instead and release it as soon as  
the identity is read. The later synchronization re-opens each sequence, so  
it does not rely on the lock being retained.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19, where it was introduced  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

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

Use more strlcpy() in two-phase transaction code

commit   : dd50eb9145eead17ebd62db2e43a6de7c53102c0    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 29 Jul 2026 08:54:11 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 29 Jul 2026 08:54:11 +0900    

Click here for diff

This commit replaces two calls of strcpy() and one call of strncpy() to  
use strlcpy(), which are patterns that static analyzers (mostly LLMs, it  
seems) have been complaining regarding buffer overflow risks.  
  
The existing calls are safe, here are more details for each one of them:  
- MarkAsPreparingGuts()'s strcpy() was guarded by MarkAsPreparing().  
- PrepareRedoAdd()'s strcpy() is safe because the record-level CRC check  
prevents corrupted data from reaching it unless intentionally  
crafted.  The replay code also assumes that the GID is within the allowed  
bounds, as WAL records are trusted.  
- Similarly, ParsePrepareRecord() stores its GID in a buffer bounded by  
GIDSIZE while trusting the length provided by the record.  
  
As a result, these changes are purely cosmetic.  They adopt a more  
defensive coding style and should also silence some of the static  
analysis reports received recently.  
  
Author: Matt Suiche <matt@tolmo.com>  
Discussion: https://postgr.es/m/CAGf6Lfx2kbQfcEnCi99V2i65JSWD6ij_E29F+UkY=TyMUyeG6A@mail.gmail.com  

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

Fix planner's nullability/strictness logic for ScalarArrayOpExpr.

commit   : 239eabda41e39de73c376000ba74bbeb8fe32a5c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 28 Jul 2026 16:08:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 28 Jul 2026 16:08:46 -0400    

Click here for diff

find_nonnullable_rels and find_nonnullable_vars mistakenly treated a  
ScalarArrayOpExpr that could return FALSE as strict, but that's okay  
only at top level of a qual expression; further down, we've got to  
insist on a guaranteed-NULL result.  The result was that we could draw  
mistaken conclusions about whether outer joins can be simplified, if  
the decision hinged on a non-top-level ScalarArrayOpExpr with a  
potentially-empty array argument.  
  
I believe this error dates to commit 72a070a36, which taught  
find_nonnullable_rels to descend into non-top-level parts of qual  
expressions.  is_strict_saop (added earlier by 72153c058) already had  
enough intelligence to do the case correctly, but it wasn't passed the  
proper flag, ie "top_level" needs to be passed for "falseOK".  
e006a24ad copied that mistake into find_nonnullable_vars.  
  
Later, over-eager refactoring in commit 2f153ddfd broke  
contain_nonstrict_functions' handling of ScalarArrayOpExpr by treating  
it as though it were no different from an OpExpr.  It is, because  
we must also prove the array is non-empty before concluding that the  
expression is strict.  This could result in misclassifying an  
expression as strict when it is not, leading to assorted planning  
mistakes such as inlining a SQL function that shouldn't be inlined.  
We can almost fix this by just re-adding the previous handling of  
ScalarArrayOpExpr in that function, but doing only that would lead to  
also calling check_functions_in_node() and thus redundantly checking  
the operator's strictness.  Avoid that by turning the if-series into  
an else-if chain, as it arguably should have been all along.  
  
The reason these errors have escaped detection for decades is that  
they are exposed only in arcane corner cases.  ScalarArrayOpExpr with  
an empty array isn't typical usage, and even when that's possible  
several other conditions apply before the planner can reach a mistaken  
conclusion.  While it's possible to build test cases demonstrating  
these mistakes, I (tgl) judged them too indirect and special-purpose  
to justify consuming regression test cycles forevermore.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAJTYsWV3vqRJmST-gv1NsXEef-zOnjVJpYS910aBaiuMij4nFg@mail.gmail.com  
Discussion: https://postgr.es/m/CAJTYsWWcLGmz0f8_QPP_Liq-fc7-geiFSCdqoq3XGeRHPPsWeA@mail.gmail.com  
Backpatch-through: 14  

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

Handle invalid and dropped databases during checksum enable

commit   : 51f55b13a4d3621244b3645a506b006decca0ec2    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 28 Jul 2026 21:52:27 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 28 Jul 2026 21:52:27 +0200    

Click here for diff

Enable errors out early with a hint when an invalid database exists,  
since the worker cannot connect to it and its files stay on disk.  
  
A worker that started but failed gets the same dropped-database  
heuristic as one that failed to start, so a concurrent drop during  
processing no longer aborts the whole run.  The existence check locks  
the database first, otherwise a DROP DATABASE ... WITH (FORCE) which  
killed the worker is still only halfway done and the database looks  
like it is there to stay.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFOGdqxtZ5-6gb4apqmvoH=Z+TNH8RKJ3mVtoR1HirKQWg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/postmaster/datachecksum_state.c
M src/test/modules/test_checksums/t/001_basic.pl

Recheck checksum state before file_copy during CREATE DATABASE

commit   : 153ca22a3a71ccaa55f27a4686202bce8f8de759    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 28 Jul 2026 21:52:24 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 28 Jul 2026 21:52:24 +0200    

Click here for diff

The file_copy strategy check in createdb() runs during option  
validation, before the transaction has an XID and before the  
pg_database row exists, so the datachecksumsworker launcher  
can start in that window and see neither the new database nor  
the transaction creating it.  It then raw-copies a template  
that was not processed yet, and those files stay unchecksummed,  
failing verification from then on.  
  
Recheck the state in CreateDatabaseUsingFileCopy(): the XID is  
assigned by then, so a launcher starting after this point waits  
for the transaction and finds the new database, and the copy  
errors out instead. Add an injection point before the catalog  
insert to test the window.  
  
Backpatch to v19 where online checksums were introduced.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAN4CZFPEBsz8JeY4ixQ1V4ZL_xOY6pJaZS8ZLGH7R+wF--pEtg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/commands/dbcommands.c
M src/test/modules/test_checksums/t/005_injection.pl

Fix logical decoding of empty prepared transactions.

commit   : acaa100f9a0c8dbd20ef48b3ce8b94bb773d6acc    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 28 Jul 2026 12:33:28 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 28 Jul 2026 12:33:28 -0700    

Click here for diff

A two-phase transaction that is assigned an XID but produces no change  
to be decoded -- for example, one that only acquires row locks via  
SELECT ... FOR SHARE -- has no base snapshot in the reorder  
buffer. ReorderBufferReplay() already skips such a transaction at  
PREPARE time and never invokes the begin_prepare/change/prepare  
callbacks for it, but ReorderBufferFinishPrepared() still called the  
commit_prepared (or rollback_prepared) callback. As a result a  
spurious COMMIT/ROLLBACK PREPARED was sent to the output plugin with  
no preceding PREPARE. For the built-in subscriber this breaks  
replication (the apply worker fails to find the prepared transaction),  
and test_decoding could even crash.  
  
Fix this by detecting an empty transaction (base_snapshot == NULL) in  
ReorderBufferFinishPrepared() and cleaning it up without invoking the  
commit/rollback prepared callbacks, mirroring the existing empty  
transaction handling in ReorderBufferReplay().  
  
On v18 and newer versions, commit 072ee847ad4 changed  
ReorderBufferPrepare() to send the prepare whenever it had not already  
been sent, which also fires for empty transactions and emits a  
spurious PREPARE. On those branches ReorderBufferPrepare() is  
therefore additionally guarded with base_snapshot != NULL. This guard  
and the Assert(!rbtxn_sent_prepare()) added in  
ReorderBufferFinishPrepared(), are not necessary on v17 and older  
versions: there ReorderBufferPrepare() only sends a prepare for  
concurrently-aborted transactions (which never applies to an empty  
transaction) and the RBTXN_SENT_PREPARE flag does not exist.  
  
Back-patch to v14, where decoding of two-phase transactions was  
introduced.  
  
Bug: #19556  
Reported-by: Alexander Kozhemyakin <a.kozhemyakin@postgrespro.ru>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/19556-daa6d7ea65054d48@postgresql.org  
Backpatch-through: 14  

M contrib/test_decoding/expected/twophase.out
M contrib/test_decoding/sql/twophase.sql
M src/backend/replication/logical/reorderbuffer.c
M src/test/subscription/t/021_twophase.pl

Fix pg_get_publication_tables() failure with concurrent DROP TABLE.

commit   : 63e7a0d2c3c7f80e52ddf216707ccc1d466453a4    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 28 Jul 2026 10:39:36 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Tue, 28 Jul 2026 10:39:36 -0700    

Click here for diff

pg_get_publication_tables() collects the OIDs of the published tables  
on its first call, without locking them, and then reopens each table  
later, once per result row, to compute its column list and fetch its  
row filter. The reopen used table_open(), which errors out with "could  
not open relation with OID" if the table has been dropped in the  
meantime. This could happen for any published table without an  
explicit column list, which is every table in FOR ALL TABLES and FOR  
TABLES IN SCHEMA publications, but also FOR TABLE entries without a  
column list. The failure is common in environments where many tables  
are created and dropped while publication tables are being queried,  
e.g. by table synchronization on a subscriber.  
  
Fix by opening every table with try_table_open(), which returns NULL  
if the relation no longer exists, and skipping the table in that  
case. Concurrently dropped tables are thus simply absent from the  
result set, which is the expected point-in-time behavior.  
  
As a side effect, tables with an explicit column list, which were  
previously returned without being opened, are now also locked with  
AccessShareLock, so the function can block behind concurrent DDL on  
such tables where it previously did not.  
  
Backpatch to v16, where we added the table_open() call in  
pg_get_publication_tables().  
  
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Reviewed-by: Ajin Cherian <itsajin@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CALj2ACVYYooWH-5tJ6cPKkU%2BmutVxwb_z4S%2BqAi-zdrFqxXE2Q%40mail.gmail.com  
Backpatch-through: 16  

M src/backend/catalog/pg_publication.c
A src/test/isolation/expected/pub-concurrent-drop.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/pub-concurrent-drop.spec
M src/tools/pgindent/typedefs.list

Restore vacuum_delay_point() in GIN posting-tree leaf vacuum

commit   : 8a045f760f67c8aa72881511add869d3d275a431    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 28 Jul 2026 10:50:13 +0200    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 28 Jul 2026 10:50:13 +0200    

Click here for diff

Commit fd83c83d094 turned the recursive posting-tree cleanup in  
ginVacuumPostingTreeLeaves() into an iterative sweep that follows the  
tree's leaf pages via their rightlinks.  The recursive version called  
vacuum_delay_point() while processing the tree, but that call was removed  
and never re-added to the new loop.  As that commit only set out to fix a  
deadlock, the removal appears to have been unintentional.  
  
Consequently the leaf-page sweep of a single posting tree runs with no  
vacuum_delay_point(), and therefore no CHECK_FOR_INTERRUPTS().  A posting  
tree stores all the TIDs for one indexed key, so for a frequently  
occurring key it can span a large number of leaf pages.  While such a  
tree is being vacuumed the operation ignores vacuum_cost_delay and does  
not respond to query cancellation or statement_timeout; an autovacuum  
worker likewise cannot be interrupted mid-sweep when another backend  
requests a conflicting lock.  
  
Restore the call, placed after the current page has been unlocked and  
released so that no buffer content lock is held across a potential delay  
(cf. 21c27af65fb).  The sibling loops in ginbulkdelete() and  
ginvacuumcleanup() already call vacuum_delay_point() once per page.  
  
Author: Paul Kim <mok03127@gmail.com>  
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Discussion: https://postgr.es/m/178447127453.110.12276981925360691905%40mail.gmail.com  
Backpatch-through: 14  

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

Avoid RETURNING side effects for FOR PORTION OF leftovers.

commit   : 62d1a5f8be836faa5547789fe19d34bac1b908f4    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Tue, 28 Jul 2026 09:44:23 +0100    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Tue, 28 Jul 2026 09:44:23 +0100    

Click here for diff

UPDATE/DELETE ... FOR PORTION OF inserts leftover rows for the  
untouched parts of the original row. These hidden inserts should not  
affect the command tag or ROW_COUNT, so they call ExecInsert() with  
canSetTag set to false.  
  
However, ExecInsert() still processed the RETURNING list whenever the  
target ResultRelInfo had ri_projectReturning set. That caused  
RETURNING expressions to be evaluated for leftover rows even though  
their results were discarded. As a result, expressions with side  
effects and information-leaking functions could be executed on the  
leftover rows, in addition to the visibly updated or deleted row.  
  
Fix by having ExecInsert() skip RETURNING processing when it is  
handling an internal FOR PORTION OF leftover insert. Use both the  
presence of a FOR PORTION OF clause and mtstate->operation ==  
CMD_INSERT for this check, so that the auxiliary INSERT of a  
cross-partition UPDATE with a FOR PORTION OF clause still processes  
RETURNING normally.  
  
Back-patch to v19, where support for FOR PORTION OF was added.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>  
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>  
Discussion: https://postgr.es/m/07C125E5-F6ED-460C-A394-E6503DAE18FB@gmail.com  
Backpatch-through: 19  

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

Fix portability issue in authentication test 003_peer

commit   : 5713b437abed7085e7d59849c6e9e0f4f469633d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 28 Jul 2026 10:49:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 28 Jul 2026 10:49:26 +0900    

Click here for diff

The mapped user name is built upon the OS user name of the environment  
where the test is run.  Depending on the characters used in the OS user  
name, CREATE ROLE may not get parsed (the author has mentioned hyphens  
as one case), causing a failure of the test.  
  
Let's use double-quotes around the mapped user name, which should be a  
solution good enough for the environments where this test tends to run.  
The buildfarm issued no complaint over the years.  
  
Oversight in 3c4e26a62c31, so backpatch down to v19.  Perhaps  
3c4e26a62c31 and this commit should be backpatched further down, but  
let's leave that for another day, if it proves necessary.  
  
Author: Yugo Nagata <nagata@sraoss.co.jp>  
Discussion: https://postgr.es/m/20260727133857.fbd23d43d422f10f376a8bee@sraoss.co.jp  
Backpatch-through: 19  

M src/test/authentication/t/003_peer.pl

Fix propagation of indimmediate flag in index_create_copy()

commit   : 74276e685dd01a8834f05f7d8b29a140a264e127    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 28 Jul 2026 08:33:23 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 28 Jul 2026 08:33:23 +0900    

Click here for diff

index_create_copy is used to create copy definitions of existing indexes.  
Currently, it passes 0 as constr_flags to index_create(), which results  
in the copied index to always be created as immediate (indimmediate set  
to true).  For deferrable unique constraints, it means that the  
transient index used during the phase 2 of REINDEX CONCURRENTLY forces  
immediate constraint checks on concurrent inserts, which can cause  
unexpected constraint violations based on the definition of the parent  
table, inconsistently set in the copied index.  
  
To fix this without violating the contract of constr_flags (which should  
only be used when creating constraints) and without relaxing the strict  
assertion in index_create(), this introduces a new index creation flag:  
INDEX_CREATE_DEFERRABLE.  If set, a copied index's indimmediate is set  
to false, meaning that unique constraints are not enforced immediately  
on insertion, but at transaction commit time.  
  
An isolation test for REINDEX CONCURRENTLY is added, based on an  
injection point waiting after phase 1 of the operation, where an index  
copy has been built and is able to accept DMLs for its validation in  
phase 2.  The test is tentatively backpatched down to v17.  
INJECTION_POINT() is outside a transaction context, which should be fine  
on HEAD since 8daeaa9b642c but I suspect may cause issues in v19 and  
older branches due to the wait facility depending on condition variables  
and a DSM setup, but let's see what the buildfarm tells.  
  
Author: Nitin Motiani <nitinmotiani@google.com>  
Discussion: https://postgr.es/m/CAH5HC97JmjPpgiQOqW9xm8qXhNiu7zZ1Qh+FfhEESJuDv69kuQ@mail.gmail.com  
Backpatch-through: 14  

M src/backend/catalog/index.c
M src/backend/commands/indexcmds.c
M src/include/catalog/index.h
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/reindex_concurrently_deferred.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/reindex_concurrently_deferred.spec

Further improve the names generated for indexes on expressions.

commit   : 5a3b22eb304806d5e492e6b62a34e77d6e060573    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 27 Jul 2026 16:19:24 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 27 Jul 2026 16:19:24 -0400    

Click here for diff

Commit 181b6185c failed to do anything useful with a whole-row Var,  
deeming it "fishy".  But it is legal to put such a Var into an  
expression index column, so let's expand it as the name of the table.  
  
Another problem reachable via that one is that we could generate an  
empty index column name, which isn't really legal although by chance  
nothing complained about it.  It's not clear whether any other such  
cases remain, but as cheap insurance let's use "expr" if the tree walk  
fails to generate any text.  
  
Reported-by: Chauhan Dhruv <chauhandhruv351@gmail.com>  
Author: Chauhan Dhruv <chauhandhruv351@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CANWwWcp_DCJjq8pomeqp6W=fbygvzXXQO028VDJ9_6sLPjQnVA@mail.gmail.com  

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

Fix race condition when enabling logical decoding concurrently.

commit   : 0fd30e2119ede879080cef426abf4f9b304e3f51    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 27 Jul 2026 09:10:45 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 27 Jul 2026 09:10:45 -0700    

Click here for diff

With wal_level = 'replica', logical decoding is enabled on demand  
when the first logical replication slot is created:  
  
When enabling logical decoding, EnableLogicalDecoding() flips the  
shared logical_decoding_enabled flag and writes an  
XLOG_LOGICAL_DECODING_STATUS_CHANGE record so that standbys follow the  
status change. The initial "already enabled?" check and the WAL record  
write happen under two separate acquisitions of  
LogicalDecodingControlLock, since the lock must be released while  
waiting for the ProcSignalBarrier: processes absorbing the barrier  
acquire the same lock in shared mode.  
  
Consequently, if two backends concurrently created the first logical  
slots, both could pass the initial check and both write a  
status-change record. The redundant record lands after the decoding  
start point already reserved by the other backend's slot, so decoding  
that slot processes the record and fails with "unexpected logical  
decoding status change", as xlog_decode() assumes that no such record  
can appear within the WAL range any slot decodes.  
  
Fix by re-checking the status after re-acquiring the lock, so that  
only the backend that actually performs the disabled->enabled  
transition writes the WAL record.  
  
Reported-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>  
Author: Srinath Reddy Sadipiralla <srinath2133@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAFC+b6oYzmAgp7F0ivrhfZT46-CjvCTrU9pWuMNcem-52YjOTw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/replication/logical/logicalctl.c
M src/test/recovery/t/051_effective_wal_level.pl

Deparse FOR PORTION OF using the range column's current name.

commit   : 7090c696cc9ea96a278e679e8bbfe9b051740105    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 27 Jul 2026 09:37:04 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 27 Jul 2026 09:37:04 -0400    

Click here for diff

Commit 8e72d914c recorded the range column's name in ForPortionOfExpr  
and used that for deparsing FOR PORTION OF.  This gives the wrong  
answer if the ForPortionOfExpr is saved in a rule or SQL function and  
then the column gets renamed.  Drop the ForPortionOfExpr.range_name  
field; instead fetch the current column name from the catalogs when  
needed.  
  
Also drop ForPortionOfState.fp_rangeName, which wasn't being used  
anywhere.  
  
Full disclosure: an earlier draft of this patch was made with  
Claude Opus 4.8.  
  
Reported-by: John Naylor <johncnaylorls@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/CANWCAZYFEpJ5Oi45gi4q9Y6LYa4_oiAXxuNNWe-1ym-i0fF8Pw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/executor/nodeModifyTable.c
M src/backend/optimizer/plan/planner.c
M src/backend/parser/analyze.c
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/catversion.h
M src/include/nodes/execnodes.h
M src/include/nodes/primnodes.h
M src/test/regress/expected/for_portion_of.out
M src/test/regress/sql/for_portion_of.sql

pg_resetwal: do not allow zero next multixact offset

commit   : 2cad308cb8f1c88f97f617ef9281f08c2f722277    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 27 Jul 2026 15:29:51 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 27 Jul 2026 15:29:51 +0300    

Click here for diff

Offset 0 is the "invalid" marker in pg_multixact/offsets since offsets  
went 64-bit and the allocator stopped skipping it. pg_resetwal could  
still produce it via -O 0 or guessed control values, breaking the first  
multixact created after the reset ("MultiXact n has invalid offset",  
and vacuum of the affected table fails from then on). Reject -O 0 like  
-m and -o already do, and guess 1 like initdb does.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://www.postgresql.org/message-id/CAN4CZFNoO6MUkg526TmA=mC_RjY2gp4VKCnvK6y12v3ppOkhJA@mail.gmail.com  
Backpatch-through: 19  

M src/bin/pg_resetwal/pg_resetwal.c
M src/bin/pg_resetwal/t/001_basic.pl

Fix issues in logical replication sequence synchronization.

commit   : b8d9cf512c1259f97f9896593cc1c8352c1118ac    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 27 Jul 2026 09:06:05 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 27 Jul 2026 09:06:05 +0530    

Click here for diff

1. Stop a running sequence synchronization worker when  
ALTER SUBSCRIPTION ... DISABLE is executed.  The worker did not reread its  
subscription after starting a transaction, so it kept running with a stale  
copy and missed the disable. It now calls maybe_reread_subscription()  
after StartTransactionCommand(), matching the apply worker.  
  
2. Restore the invariant that publisher-side synchronization slots are  
dropped last during ALTER SUBSCRIPTION ... REFRESH PUBLICATION.  The  
slot-drop loop now runs after the sequence-removal loop, so the  
non-transactional slot drops happen only after all catalog changes that  
could still be rolled back on error.  
  
3. Restore psql tab completion for  
ALTER SUBSCRIPTION ... REFRESH PUBLICATION WITH (.  
  
4. Make pg_stat_subscription report NULL for the fields that do not apply  
to a sequence synchronization worker, which does not stream from a  
walsender, and update the documentation accordingly.  
  
5. Update the pg_subscription_rel.srsublsn catalog documentation to  
describe its semantics for sequence rows.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19, where it was introduced  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M doc/src/sgml/catalogs.sgml
M doc/src/sgml/monitoring.sgml
M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/sequencesync.c
M src/backend/replication/logical/worker.c
M src/bin/psql/tab-complete.in.c

Fix deparsing of JSON_ARRAY(subquery) with a FORMAT clause

commit   : f4c850d11afc60a4fc4bc782fc40d7b752bf8d7f    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 27 Jul 2026 10:21:18 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 27 Jul 2026 10:21:18 +0900    

Click here for diff

Commit 8d829f5a0 introduced the JSCTOR_JSON_ARRAY_QUERY constructor  
type so that ruleutils.c could deparse JSON_ARRAY(subquery) using its  
original syntax, storing the transformed subquery in a new orig_query  
field.  However, the input FORMAT clause of JSON_ARRAY(subquery FORMAT  
...) was not preserved for deparsing.  The format was recorded only in  
the executable expression kept in the func field, which ruleutils.c  
does not inspect, so it is silently dropped.  
  
This is more than cosmetic, because FORMAT JSON changes the result:  
without it a text value is treated as a string to be quoted, while  
with it the value is treated as already-formatted JSON.  
  
To fix, record the input FORMAT in a new deparse-only field of  
JsonConstructorExpr, alongside orig_query, and emit it in ruleutils.c.  
  
Bump catalog version.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/4C89B193-7D54-4705-9CF9-F0D484B9E099@gmail.com  
Backpatch-through: 19  

M src/backend/parser/parse_expr.c
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/catversion.h
M src/include/nodes/primnodes.h
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/sqljson.sql

Update .gitignore in test/modules/nbtree

commit   : 87f08dbf3499929f4941f224f52ccd6a20081f00    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 27 Jul 2026 09:58:04 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 27 Jul 2026 09:58:04 +0900    

Click here for diff

Noticed while doing some routine work.  
  
Oversight in e395fbd32a07.  

M src/test/modules/nbtree/.gitignore

Use direct hash lookup in logicalrep_partmap_invalidate_cb()

commit   : 0962f9e344390c69e44bc55675510b2fa2b3f778    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 27 Jul 2026 09:42:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 27 Jul 2026 09:42:50 +0900    

Click here for diff

This replaces an O(N) hash_seq_search() loop by an O(1) lookup, removing  
a TODO item, making the invalidation callback faster when dealing with  
many relations.  This can work because LogicalRepPartMap is keyed by a  
partition OID, and a relmapentry's localreloid matches with it.  
  
An assertion is added in logicalrep_partition_open() to enforce the fact  
that localreloid matches with the hash key.  
  
Author: DaeMyung Kang <charsyam@gmail.com>  
Discussion: https://postgr.es/m/20260417174450.4158878-1-charsyam@gmail.com  

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

Add _bt_set_startikey row compare test coverage.

commit   : e01accdb50ce8f879182edb1b50f3bc9bd78bfa7    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sun, 26 Jul 2026 12:49:56 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sun, 26 Jul 2026 12:49:56 -0400    

Click here for diff

Add pg_regress tests that exercise the row compare logic that commit  
7d9cd2df added to _bt_set_startikey.  Also add tests that exercise the  
_bt_set_startikey SAOP array path.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-Wz=KjQsD2W2a=b51uH905=0mF6Le4evhWkN2FL1+uRPhUg@mail.gmail.com  
Backpatch-through: 19  

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

Add test coverage for nbtree backwards scans.

commit   : e395fbd32a07557de4ac98088928c1749d4845d8    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 25 Jul 2026 17:13:00 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 25 Jul 2026 17:13:00 -0400    

Click here for diff

Backwards scans have unique concurrency rules: rather than unreservedly  
trusting a saved left link, the scan optimistically rechecks its  
pointed-to leaf page's right link (i.e. whether it still points back to  
the page that _bt_readpage just read).  Usually, the left sibling of the  
just-read page won't have changed, in which case the scan can proceed  
with reading the left sibling as planned.  But it's possible that the  
key space that the scan needs to read next is no longer covered by the  
original left sibling page due to concurrent page splits and/or page  
deletions.  When that happens, the scan must recover by relocating the  
new/current left sibling of the just-read page.  
  
Test coverage for backwards scans was limited to the happy path.  Add an  
isolation test (and associated injection points) that test the recovery  
path.  This covers several distinct recovery scenarios (concurrent page  
splits, concurrent page deletions, and minor variants thereof).  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/CAH2-WzmD+jUBOpFS2jrnqqrdPSAjoxqyL9FPKaE1BtnY=8Nntg@mail.gmail.com  

M src/backend/access/nbtree/nbtsearch.c
M src/test/modules/nbtree/Makefile
A src/test/modules/nbtree/expected/backwards-scan-concurrent-splits.out
M src/test/modules/nbtree/meson.build
A src/test/modules/nbtree/specs/backwards-scan-concurrent-splits.spec

Add tests for nbtree empty index predicate locking.

commit   : 62c05d6f2fa64cce44e57871b4cfcd7b34589fcf    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 25 Jul 2026 14:15:33 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 25 Jul 2026 14:15:33 -0400    

Click here for diff

Add coverage for predicate locking of completely empty nbtree indexes,  
where we must predicate lock the entire relation (instead of some  
individual leaf page).  Both paths that can find the index empty (and  
must consider whether it's still empty after PredicateLockRelation  
returns) are covered by a new isolation test that uses injection points.  
  
Catalog relation scans skip the injection points.  The waiting session  
runs catalog queries of its own after arming the (session-local) points,  
and could otherwise suspend itself with nothing lined up to wake it.  
  
Follow-up to bugfix commits ce3f19e2 (the _bt_endpoint fix) and f9b7fc65  
(the _bt_first/_bt_search fix).  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-WzkNoTn3yXY0iGkSuavJ+sL8EROf+kitW+_2v2tJVWuKmA@mail.gmail.com  

M src/backend/access/nbtree/nbtsearch.c
M src/test/modules/nbtree/Makefile
A src/test/modules/nbtree/expected/predicate-empty-index.out
M src/test/modules/nbtree/meson.build
A src/test/modules/nbtree/specs/predicate-empty-index.spec

Add missing PGDLLIMPORT marker

commit   : 5168655bc5ed68c0b7d7d3723adbd49c55bafda7    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sat, 25 Jul 2026 19:16:42 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Sat, 25 Jul 2026 19:16:42 +0200    

Click here for diff

Oversight in commit fb23cc7e81db.  
  
Reported-by: Anton Voloshin <a.voloshin@postgrespro.ru>  
Discussion: https://postgr.es/m/ad5d772e-09d9-4248-97a4-0011afab9e71@postgrespro.ru  

M src/include/postmaster/syslogger.h

Fix another empty nbtree index SSI race.

commit   : ce3f19e26218283eaff6436e28113b532bfc4a6f    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 25 Jul 2026 12:01:35 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sat, 25 Jul 2026 12:01:35 -0400    

Click here for diff

Commit f9b7fc65 fixed a race when predicate-locking completely empty  
btrees: without a buffer lock held, a matching key could be inserted  
between _bt_search and the PredicateLockRelation call, so the scan would  
miss concurrently inserted tuples while the writer wouldn't see the  
reader's predicate lock.  That commit only fixed _bt_first's _bt_search  
path, though.  Scans without useful insertion scan keys return early  
from _bt_first via _bt_endpoint, which still didn't recheck if the  
relation was empty.  
  
To fix, add handling to _bt_endpoint that is analogous to the handling  
added to _bt_search by commit f9b7fc65.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Discussion: https://postgr.es/m/CAH2-WzkNoTn3yXY0iGkSuavJ+sL8EROf+kitW+_2v2tJVWuKmA@mail.gmail.com  
Backpatch-through: 14  

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

psql: Allow pg_read_all_stats to see database size in \l+

commit   : 38afc3dcb25c45b744d4025029ce0a6c90b7059f    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 25 Jul 2026 19:08:27 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 25 Jul 2026 19:08:27 +0900    

Click here for diff

pg_database_size() allows access to users who have either CONNECT  
privilege on the target database or privileges of the pg_read_all_stats  
role. However, previously, psql's \l+ checked only for CONNECT,  
so users with privileges of pg_read_all_stats still saw "No Access" for  
databases they could not connect to.  
  
Fix this by making \l+ also check  
pg_has_role('pg_read_all_stats', 'USAGE'), matching  
pg_database_size()'s permission rules.  
  
For back branches, emit the pg_read_all_stats check only when  
connected to PostgreSQL 10 or later, since earlier releases do not have  
that predefined role.  
  
Backpatch to all supported versions.  
  
Author: Christoph Berg <myon@debian.org>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/amCo6qRmnfPVk4-V@msg.df7cb.de  
Backpatch-through: 14  

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

Avoid reporting permission-denied publisher sequences as missing

commit   : 13b7a8a0ef56d9decae284b4983894175c17d217    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Sat, 25 Jul 2026 10:30:30 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Sat, 25 Jul 2026 10:30:30 +0900    

Click here for diff

Previously, if a sequence synchronization batch contained both a sequence  
that had been dropped on the publisher and another for which the  
replication role lacked SELECT privilege, the latter was reported  
twice: once as a permission failure and again as missing on the  
publisher.  
  
This happened because the permission-denied sequence was not marked as  
found on the publisher. As a result, when another sequence in the batch  
was genuinely missing, the later missing-sequence check incorrectly  
classified the permission-denied sequence as missing as well.  
  
Fix this by marking the permission-denied sequence as found before  
reporting the permission failure, so it is not later reported as  
missing.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CALDaNm3LsUjW7PahuCsbYAxajSF+S328tw5E9rF0erdh7dKOXw@mail.gmail.com  
Backpatch-through: 19  

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

doc: Add missing CREATE/ALTER PUBLICATION parameter descriptions

commit   : b77868f169adcdf31edbc80d8a875204ed7ba191    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 24 Jul 2026 15:46:46 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 24 Jul 2026 15:46:46 +0900    

Click here for diff

Document table_name, column_name, and schema_name in the CREATE  
PUBLICATION and ALTER PUBLICATION reference pages. Also add anchors for  
the ALTER PUBLICATION parameter list, matching the style already used by  
CREATE PUBLICATION.  
  
Author: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHut+Ptekz+TO4ui8-fiBm4Y+O2v=HQnkK_cW4G=w9ep8654EA@mail.gmail.com  

M doc/src/sgml/ref/alter_publication.sgml
M doc/src/sgml/ref/create_publication.sgml

Fix EXCEPT publication test to check subscriber

commit   : c5f1f41b52b60d4d27a9d77e074da553ee98e26e    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 24 Jul 2026 15:44:56 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 24 Jul 2026 15:44:56 +0900    

Click here for diff

Commit fd366065e06 added tests intended to verify that rows inserted  
on the publisher are replicated to the subscriber when using multiple  
publications, with one excluding the target table via EXCEPT and  
another including it.  
  
However, the tests queried the publisher instead of the subscriber.  
Since the rows were inserted directly into the publisher, the checks  
would always succeed, providing no coverage of replication.  
  
Fix this by querying the subscriber so the tests verify the replicated  
state.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGfXUO7f4t6KNGurYwg6QsnLtpP0K3EACbAwYWtxGfKfQ@mail.gmail.com  
Backpatch-through: 19  

M src/test/subscription/t/037_except.pl

Validate subscription conninfo on owner change

commit   : 1c9c35890421e96a91129b51f2c6446a6d95af95    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 23 Jul 2026 19:24:55 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 23 Jul 2026 19:24:55 +0900    

Click here for diff

For subscriptions using SERVER, changing the owner can change the  
effective connection string. However, ALTER SUBSCRIPTION ... OWNER TO  
did not validate the generated conninfo for the new owner.  
  
As a result, ownership could be transferred to a non-superuser whose  
generated connection string did not satisfy password_required=true.  
The ownership change succeeded, but the subscription would fail later  
when the worker or another command tried to connect.  
  
Fix this by making ALTER SUBSCRIPTION ... OWNER TO validate the new  
owner's generated conninfo with walrcv_check_conninfo().  
  
Backpatch to v19, where SERVER subscriptions were introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Yuanchao Zhang <145zhangyc@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/CAHGQGwFGa6+wWVgUmZPFwN=fBY59mYPkMK3=TxT=Pv5C1mNNRQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ref/alter_subscription.sgml
M src/backend/commands/subscriptioncmds.c
M src/test/regress/expected/subscription.out
M src/test/regress/regress.c
M src/test/regress/sql/subscription.sql

doc: Improve pg_stat_recovery documentation

commit   : 937db82a8d6ffb1b3bb292ed7070dae33aa659ba    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 23 Jul 2026 19:22:36 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 23 Jul 2026 19:22:36 +0900    

Click here for diff

Improve the documentation for pg_stat_recovery in several ways:  
  
- Mention the view in high-availability.sgml as a way to monitor  
  recovery state and replay progress, alongside the existing recovery  
  information functions.  
- Clarify that the view returns at most one row, not exactly one row,  
  and no rows to users who lack the pg_read_all_stats privilege.  
- Correct the description of last_replayed_end_lsn to clarify that it  
  is the end LSN of the last replayed record plus one.  
- Document that replay_end_tli equals last_replayed_tli when no WAL  
  record is currently being replayed.  
- Clarify that current_chunk_start_time is NULL until streaming WAL  
  has been received.  
  
Backpatch to v19, where pg_stat_recovery was introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAHGQGwGRavm18HqnQn_f68QB96qk6arhjET1V93OJH09Mgojkg@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/high-availability.sgml
M doc/src/sgml/monitoring.sgml
M src/include/access/xlogrecovery.h

Fix socket_putmessage_noblock() to call socket_putmessage()

commit   : 544d25b7af958ca6c03e98bfbc1538c295b30601    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 23 Jul 2026 16:48:40 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 23 Jul 2026 16:48:40 +0900    

Click here for diff

socket_putmessage_noblock() used pq_putmessage(), which redirects to  
PqCommMethods->putmessage.  In the common cases, this points to  
socket_putmessage(), but it would become incorrect if PqCommMethods  
points to a different implementation.  
  
This change may look like a bug, but as far as I can see this is mostly  
cosmetic.  The code is able to work currently, as the repalloc() done in  
the noblock() call ensures that the blocking path of internal_putbytes()  
is never reached.  The issue has gone unnoticed since 2bd9e412f92b.  
  
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAO6_Xqpf5+Rzw_-XOOz-d-R5x6_2JHtpnzXP0nrYWiHyZokA_Q@mail.gmail.com  

M src/backend/libpq/pqcomm.c

doc: Improve description of pg_stat_activity.backend_type

commit   : abbd74ce8738d536e8d99151122b7a650e3b63d5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 23 Jul 2026 16:09:13 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 23 Jul 2026 16:09:13 +0900    

Click here for diff

The documentation of pg_stat_activity used an incomplete list of values  
for backend_type.  While on it, it is improved to use an itemized list,  
now ordered alphabetically, with a short description about each item.  
  
Author: Laurenz Albe <laurenz.albe@cybertec.at>  
Reviewed-By: Michael Paquier <michael@paquier.xyz>  
Reviewed-By: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/5e94c0196084f648ae6a00107125494f5804318a.camel@cybertec.at  

M doc/src/sgml/monitoring.sgml

injection_points: Clear waiter slot on error and exit

commit   : a49b6a61094677f75807e452f333f87d4926083f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 23 Jul 2026 14:37:39 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 23 Jul 2026 14:37:39 +0900    

Click here for diff

injection_wait() only clears its slot in the waiter array after the  
wait loop finishes.  When the waiting query is canceled or the backend  
is terminated (wait look has a CHECK_FOR_INTERRUPS), the slot leaks.  
Later wakeups of the same point then bump the counter of the leaked slot  
instead of the real waiter, that sleeps forever.  Repeated leaks can  
exhaust all the slots.  
  
The code is changed so as the waiting loop is wrapped with  
PG_ENSURE_ERROR_CLEANUP, so as the injection point slots, that are  
shared resources, can be cleaned up on ERROR as much as a FATAL.  
  
An isolation test is added: cancel one waiter, terminate another waiter,  
then check that a later waiter still receives a wakeup.  Without the  
fixed code, the test would fail on timeout.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://postgr.es/m/CAN4CZFO+KF=cc0-iEg28RhqRBp_fTs6D4b8b7D7DB-pGYP3Ccg@mail.gmail.com  
Backpatch-through: 17  

M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/wait_cleanup.out
M src/test/modules/injection_points/injection_points.c
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/wait_cleanup.spec

Reject sequence synchronization against pre-PostgreSQL 19 publishers.

commit   : 1a8c172228db9f8ffd7add086e3b0a3cc4986b1c    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 23 Jul 2026 10:46:42 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 23 Jul 2026 10:46:42 +0530    

Click here for diff

Sequence synchronization requires the page_lsn field returned by  
pg_get_sequence_data(), which was added in PostgreSQL 19. Previously,  
requesting sequence synchronization against an older publisher (via  
ALTER SUBSCRIPTION ... REFRESH SEQUENCES or by running  
ALTER SUBSCRIPTION ... CONNECTION on a disabled subscription with  
sequences in the INIT state and subsequently enabling the subscription)  
would cause the sequence synchronization worker to repeatedly fail with a  
confusing "invalid query response" error.  
  
Check the publisher's server version up front in both  
AlterSubscription_refresh_seq() and copy_sequences(), and error out  
immediately when it predates PostgreSQL 19.  
  
Also document the PostgreSQL 19 publisher requirement for sequence  
replication in the logical replication documentation and in  
ALTER SUBSCRIPTION ... REFRESH SEQUENCES.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/alter_subscription.sgml
M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/sequencesync.c

walsummarizer: Guard against WAL files whose tail ends are not valid.

commit   : 8767a10cb8c5d08b924f40c8fc1f2a1e5fb8c55e    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 22 Jul 2026 08:47:44 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 22 Jul 2026 08:47:44 -0400    

Click here for diff

SummarizeWAL documents that maximum_lsn should be passed as "the switch  
point when reading a historic timeline, or the most-recently-measured end of  
WAL when reading the current timeline." But the caller always passed the  
most recently measured end-of-WAL even when reading from a historic  
timeline, due to an oversight on my part. Fix that.  
  
As far as I can determine, for this to become an issue in practice, it's  
necessary to have a corrupted WAL file in the archive.  SummarizeWAL checks  
that every record it processes both starts and ends before switch_lsn; so if  
all the WAL files in the archive are valid, SummarizeWAL will still discover  
where it should stop summarizing and do the right thing.  However, if  
there's a corrupted file in the WAL archive, and if it is also the case that  
the end of the current timeline has advanced past the switch point, then the  
incorrect maximum_lsn value can result in trying to read an invalid record  
and erroring out, which leads repeatedly retrying and failing with an error  
every time.  
  
One way this could occur is if a new primary is promoted and creates a  
.partial file, and the user manually renames that file to remove the suffix,  
and it is then archived. In that situation, the tail end of the file need  
not be valid WAL, and that could lead to a stuck WAL summarizer.  
  
Reported-by: Fabrice Chapuis <fabrice636861@gmail.com>  
Analyzed-by: Thom Brown <thom@linux.com> (using claude)  
Discussion: http://postgr.es/m/CAA5-nLDdvGMkN6Z-GaHGHG5T7QWEgv4YoHO7XvOJbeD00cghNg@mail.gmail.com  
Backpatch-through: 17  

M src/backend/postmaster/walsummarizer.c

Improve lookup_type_cache() handling on out-of-memory errors

commit   : ccfd4b683867a5eded09a82b624992c87396d02d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Jul 2026 09:52:04 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Jul 2026 09:52:04 +0900    

Click here for diff

If an error happens during the initialization of the TYPEOID catcache,  
as part of lookup_type_cache(), the error handling of that lookup would  
cause an assertion failure via finalize_in_progress_typentries(), called  
during error recovery, the presence of an in-progress type OID causing  
a catcache initialization outside of a transaction context.  
  
The in-progress list is now delayed to happen after the initial entry  
lookup.  Alexander Lakhin has found a fancy way to reproduce the  
problem, with the injection of probabilistic memory allocation failures.  
  
This problem is unlikely going to show up in practice.  Like the other  
changes of this kind, no backpatch is done.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Discussion: https://postgr.es/m/95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com  

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

Add new pgstats routine to split pending data setup

commit   : e65c331b8fbf8c9632b62c5a9dcb589cbd3046a8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Jul 2026 08:15:00 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 22 Jul 2026 08:15:00 +0900    

Click here for diff

This commit adds pgstat_prep_pending_from_entry_ref(), a new pgstats  
routine that is able to prepare an existing PgStat_EntryRef to receive  
pending stats.  This split gives a way for callers to obtain first a  
reference via pgstat_get_entry_ref(), then set up pending data as two  
separate, distinctive, steps.  
  
Previously, the only way to get an entry reference with pending data  
ready was pgstat_prep_pending_entry(), which bundles lookup, creation,  
and pending setup in a single call.  Callers that need finer control  
over the entry creation had no way to attach pending data to an  
already-obtained entry reference.  One case where this has shown to  
matter for a stats kind is where one wants to check some capacity (for  
example where a GUC bounds the maximum numer of entries allowed) before  
deciding if a new entry should be created.  So this split can help in  
reducing calls to pgstat_get_entry_ref(), meaning less shmem hash table  
lookups.  
  
The only logical ordering change is that pgStatPendingContext is  
initialized after calling pgstat_get_entry_ref() in  
pgstat_prep_pending_entry().  This does not matter in practice.  
  
pgstat_prep_pending_entry() is refactored to use the new function  
internally.  All the existing callers are unchanged.  Existing  
out-of-core custom stats kinds should see no impact.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAA5RZ0sV+TsLejUMhAM=PJoOm8u-t8ru7B67KvyLCy=19sM87g@mail.gmail.com  

M src/backend/utils/activity/pgstat.c
M src/include/utils/pgstat_internal.h

doc: clarify how TIMESTAMP WITH TIME ZONE behaves

commit   : 78758d37306cd89ab060f00cb06f249018d5b8da    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 21 Jul 2026 12:06:10 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 21 Jul 2026 12:06:10 -0400    

Click here for diff

Mention "time zone conversion" as a way to clarify the time zone is not  
stored in the database.  
  
Reported-by: Richard Neill  
  
Discussion: https://postgr.es/m/ddf41f033a8add84e1f28a095defafae@richardneill.org  
  
Backpatch-through: 19  

M doc/src/sgml/datatype.sgml

doc: clarify to_char("OF") HH/MM doesn't represent actual chars

commit   : 85df8c5bc7fe271bd17ffa1b84b972fabf964d40    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 21 Jul 2026 11:59:37 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 21 Jul 2026 11:59:37 -0400    

Click here for diff

Change formatting and chars to be less of a match against actual  
formatting characters.  
  
Reported-by: Phil  
  
Discussion: https://postgr.es/m/177801333530.795.16999885814007014333@wrigleys.postgresql.org  
  
Backpatch-through: 19  

M doc/src/sgml/func/func-formatting.sgml

Fix typo

commit   : 96104d6305f22db28b272b3c42c95539e0a091a3    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 17:18:41 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 17:18:41 +0200    

Click here for diff

from commit c1fe2d1a383  

M src/bin/pg_upgrade/check.c

Remove assertion added by commit 7dcea51c2a4d

commit   : cb2053dbde7a7e577484f92a60c9bcfe1147472b    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 21 Jul 2026 17:18:02 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 21 Jul 2026 17:18:02 +0200    

Click here for diff

We've got no reports of problems.  Get rid of it.  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/alewd1f2G0kKeM1i@alvherre.pgsql  

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

Unify error messages

commit   : 02597b42e5ff0df44e6a089801b7f6830ad19d83    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 21 Jul 2026 13:27:15 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Tue, 21 Jul 2026 13:27:15 +0200    

Click here for diff

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

pg_upgrade: Message wording fix

commit   : 078aac2ed649f983e52f039ded9014bf6447963e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 16:56:37 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 16:56:37 +0200    

Click here for diff

For internally consistent terminology  

M src/bin/pg_upgrade/controldata.c

Message style fixes

commit   : c90c9678e533e622a393d3296f8fe4b9e5e317af    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 15:27:02 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 15:27:02 +0200    

Click here for diff

Change DETAIL messages to conform to the style guide by capitalizing  
the first word of sentences and ending sentences with a period.  
  
Author: Peter Smith <peter.b.smith@fujitsu.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: vignesh C <vignesh21.gmail.com>  
Reviewed-by: Xiaopeng Wang <wxp_728.163.com>  
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/flat/CAHut%2BPszSntkUgN%2BQa9matGY6MLEoFGSuVbuKDgnnTdZ7YPRwg%40mail.gmail.com  

M contrib/dblink/dblink.c
M contrib/passwordcheck/expected/passwordcheck.out
M contrib/passwordcheck/expected/passwordcheck_1.out
M contrib/passwordcheck/passwordcheck.c
M contrib/pg_stash_advice/expected/pg_stash_advice.out
M contrib/pg_stash_advice/expected/pg_stash_advice_utf8.out
M contrib/pg_stash_advice/pg_stash_advice.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M src/backend/commands/copyto.c
M src/backend/commands/extension.c
M src/backend/commands/tablecmds.c
M src/backend/libpq/be-secure-openssl.c
M src/test/modules/test_extensions/expected/test_extensions.out
M src/test/regress/expected/create_view.out
M src/test/regress/expected/rangefuncs.out

Improve generate_partition_qual()'s cache handling on out-of-memory errors

commit   : fc6425fbe7a1fc7458fc27060ec78c5d98757690    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 21 Jul 2026 16:50:18 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 21 Jul 2026 16:50:18 +0900    

Click here for diff

An in-flight failure when trying to set rd_partcheckcxt or  
rd_partcheck, while for example doing an allocation in copyObject(),  
would leave a backend cache in a corrupted state.  The operations are  
now ordered so as we avoid a leak in the cache memory context and a  
semi-filled cache state when an allocation failure happens.  
  
This is unlikely going to be hit in practice.  Like the other  
improvements of this kind, no backpatch is done.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Discussion: https://postgr.es/m/95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com  

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

Test what BEFORE UPDATE triggers do to FOR PORTION OF

commit   : 9170c8b71693cf76a4b9a9fbcd16b1fb20b3357c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 08:33:25 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 21 Jul 2026 08:33:25 +0200    

Click here for diff

If a BEFORE trigger changes NEW.valid_at, what is the interaction with  
FOR PORTION OF?  This commit gives a test to capture our current  
behavior: The trigger's change replaces the value we computed  
automatically, but it does not change the bounds of the temporal  
leftovers.  
  
This matches the behavior of MariaDB.  On the other hand, DB2 rejects  
changing the start/end columns of a PERIOD.  Since we don't have  
PERIODs, we can't reject the change at trigger definition time as DB2  
does, but we could reject it at run time by comparing the values  
before and after running triggers.  
  
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>  
Discussion: https://www.postgresql.org/message-id/CA%2BrenyV3Cr9BvWsPeb1t8b%3DPk24apuzyGbubAEs_YsgLUTfXpg%40mail.gmail.com  

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

Allow logical replication workers to ignore default_transaction_read_only.

commit   : d774576f6f05f65e3a944eb509ef0620ea6b107e    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Tue, 21 Jul 2026 09:23:11 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Tue, 21 Jul 2026 09:23:11 +0530    

Click here for diff

Sequence synchronization updates sequence state via setval(), which  
explicitly calls PreventCommandIfReadOnly(). If  
default_transaction_read_only is enabled on the subscriber, this causes  
sequencesync workers to fail with "cannot execute setval() in a read-only  
transaction". Apply and tablesync workers are not affected, since they  
write via direct heap access rather than through these read-only-checked  
functions.  
  
Rather than special-casing sequencesync, override  
default_transaction_read_only to "off" for all logical replication workers  
in InitializeLogRepWorker(), the same way session_replication_role and  
search_path are already forced there. This keeps the initialization  
uniform.  
  
For PG-19, we kept the fix narrow by overriding  
default_transaction_read_only to "off" only for sequencesync workers.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M src/backend/replication/logical/worker.c
M src/test/subscription/t/036_sequences.pl

Add logical decoding status to pg_control_checkpoint().

commit   : 99e949f846e9d4c02296795ad041e55d88b1d320    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 20 Jul 2026 17:11:17 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Mon, 20 Jul 2026 17:11:17 -0700    

Click here for diff

Commit 8108765f04b added the logical decoding status to the  
pg_controldata output, but overlooked the pg_control_checkpoint() SQL  
function, which reports the same checkpoint information. This commit  
adds a logical_decoding column to pg_control_checkpoint(), placed  
after full_page_writes to match the pg_controldata output order.  
  
Oversight in 8108765f04b.  
  
Bump catalog version.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEkp1-1n5iC38+yHSNh955+KshwtCL6DzA0vk_vuUF_Eg@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/func/func-info.sgml
M src/backend/utils/misc/pg_controldata.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

Fix recovery target test waiting on unavailable WAL

commit   : 83486b6a65aa48ed18e4e872d5e0fb5b0bfaca41    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 21 Jul 2026 03:24:58 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 21 Jul 2026 03:24:58 +0900    

Click here for diff

Buildfarm member skink reported a failure in  
recovery/003_recovery_targets after commit d5751c33cc3. The newly  
added recovery_target_xid set-then-cleared test could time out while  
waiting for pg_last_wal_replay_lsn() to reach the expected LSN.  
  
The test recorded lsn6 after calling pg_switch_wal(). As a result,  
lsn6 pointed into the next WAL segment, but pg_switch_wal() only  
archived the previous one. Since the standby in this test restores WAL  
from the archive only, it could not obtain the segment containing  
lsn6 and waited indefinitely.  
  
Fix this by recording lsn6 before calling pg_switch_wal(), so the  
archived WAL contains the LSN that the standby is waiting for.  
  
Per buildfarm member skink.  
  
Reported-by: Álvaro Herrera <alvherre@kurilemu.de>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/al5Y2mWffRs1NP34@alvherre.pgsql  

M src/test/recovery/t/003_recovery_targets.pl

doc: Granting TRIGGER or REFERENCES on table is dangerous.

commit   : 17e805e8d8152db474bb368ab95cac127dfe6a4f    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 20 Jul 2026 13:36:39 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Mon, 20 Jul 2026 13:36:39 -0400    

Click here for diff

It's always been the case that granting these privileges to users that  
you don't fully trust was a bad idea, but it hasn't always been  
obvious to people reading the documentation that this is the case.  
To prevent confusion, and also repeated reports to pgsql-security,  
mention it explicitly.  
  
Discussion: http://postgr.es/m/CA+TgmobrjCHBuWHrvX3=2vndUCO2thUOdevrCcMDFW86cqCYvw@mail.gmail.com  
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>  
Backpatch-through: 14  

M doc/src/sgml/ddl.sgml

Fix restore of partitions with exclusion constraints

commit   : d049a31a4cd2d43739ae0039002c24c63a24d48c    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 20 Jul 2026 17:21:20 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 20 Jul 2026 17:21:20 +0200    

Click here for diff

Commit 8c852ba9a4 allowed exclusion constraints to be added to  
partitioned tables, but wasn't careful to verify that pg_restore worked  
correctly for them.  Fix that by making CompareIndexInfo() more  
selective about what needs to be rejected.  
  
Author: Japin Li <japinli@hotmail.com>  
Reported-by: Keith Paskett <keith.paskett@logansw.com>  
Discussion: https://postgr.es/m/2A40921D-83AB-411E-ADA6-7E509A46F1E4@logansw.com  

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

Avoid ERROR in recovery target GUC assign hooks

commit   : d5751c33cc3e842b20dbe67545fd2c850be8fa59    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 20 Jul 2026 21:41:14 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 20 Jul 2026 21:41:14 +0900    

Click here for diff

Recovery target parameters are postmaster-startup GUCs, but their  
assign hooks previously did more than assign individual parameter  
values. They also updated the global recoveryTarget state and raised  
ERROR if more than one recovery target appeared to be set.  
  
This was not a good fit for GUC assign hooks. Assign hooks should not  
throw ERROR, and deriving cross-parameter state while individual GUCs  
are still being assigned makes the result depend on assignment order  
rather than the final configuration.  
  
For example, setting one recovery target and then setting another  
recovery_target_* parameter to an empty string could clear  
recoveryTarget, causing recovery to proceed with no target even  
though a valid target remained configured.  
  
Fix this by having the assign hooks only store their own parameter  
values. The effective recoveryTarget is now derived once from the  
final recovery_target* settings in  
validateRecoveryParameters(), which also rejects configurations that  
specify more than one recovery target with FATAL. This preserves the  
expected behavior for repeated assignments of the same GUC, treats empty  
values as "not set", and removes cross-GUC validation from the assign  
hooks.  
  
Author: JoongHyuk Shin <sjh910805@gmail.com>  
Reviewed-by: Greg Lamberson <greg@lamco.io>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Scott Ray <scott@scottray.io>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Henson Choi <assam258@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CACSdjfPUa4UvKjADgOERXoxNYmCg2mqqiqKkiJk6mX6E4qgVFw@mail.gmail.com  

M src/backend/access/transam/xlogrecovery.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/guc_tables.c
M src/include/access/xlogrecovery.h
M src/include/utils/guc_hooks.h
M src/test/recovery/t/003_recovery_targets.pl

Allow PostgreSQL::Test::Cluster::start() to pass postmaster options

commit   : 1009339b3acaf06b457a8182bf50b504847a643c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 20 Jul 2026 21:40:31 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 20 Jul 2026 21:40:31 +0900    

Click here for diff

Previously, tests that needed extra postmaster command-line options had  
to invoke pg_ctl start directly, because  
PostgreSQL::Test::Cluster::start() provided no way to pass them. That  
bypassed the test framework's postmaster PID tracking, so a postmaster  
could be left running if the test failed after startup.  
  
Add an options parameter to  
PostgreSQL::Test::Cluster::start(), which is passed to pg_ctl's  
--options argument. This allows tests to use start() while  
preserving the framework's normal cleanup behavior.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: JoongHyuk Shin <sjh910805@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEpfE0CDUUODjBt7GO9U4ZF11hqga_Ci3wP8=O49oFKVw@mail.gmail.com  

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

Fix LSN format in REPACK worker debug message

commit   : c94409ebc3d7e9179d517736cbe9a948571f7c85    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 20 Jul 2026 13:50:45 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 20 Jul 2026 13:50:45 +0200    

Click here for diff

Commit 6f6f284c7ee4 introduced use of LSN_FORMAT_ARGS across the whole  
tree to remove use of manual bit-shifting, and commit 2633dae2e487  
changed the printf format to be %X/%08X; however commit 28d534e2ae0a  
violated both conventions by reintroducing the old manual-shift style  
with the deprecated %X/%X format in one debug message.  Make that new  
message conform to our style.  
  
Author:  kenny <kennychen851228@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAPXstDuWD8jg0=C8PXTXGSTTsZcjqJ+u+xKCrMpN99CXsxQzCg@mail.gmail.com  

M src/backend/commands/repack_worker.c

Move code to get_tables_to_repack_partitioned

commit   : ad6ae52c49ac07b6ae2f8017b63ebd757b815d8f    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 20 Jul 2026 12:12:13 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Mon, 20 Jul 2026 12:12:13 +0200    

Click here for diff

Some of its code was pointlessly in its caller.  This makes it better  
contained and clearer.  
  
Backpatch to 19, to avoid having two different copies in case we have to  
modify it again later.  
  
Author: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: ChangAo Chen <cca5507@qq.com>  
Discussion: https://postgr.es/m/alD9l-XlCuu3eUEe@alvherre.pgsql  

M src/backend/commands/repack.c

Improve pgstat_get_entry_ref_cached() behavior on out-of-memory errors

commit   : 16ebc196d8926823bc8d64931557b679cecd67aa    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 20 Jul 2026 15:52:18 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 20 Jul 2026 15:52:18 +0900    

Click here for diff

A failure in allocating a new cache entry in the backend-level hash  
table holding references to shared stats entries would leave the table  
in an inconsistent state, crash or FATAL at session exit, depending on  
if there are pending stats.  
  
Rather than leaving things in an inconsistent state on OOM, the code is  
switched to use MemoryContextAllocExtended(MCXT_ALLOC_NO_OOM), so as an  
allocation failure leads to a cleanup of the hash table before issuing  
the allocation error.  
  
The problem is unlikely going to show up in practice, so no backpatch is  
done.  Note that shared memory is not impacted, only a backend-level  
hash table.  
  
Reported-by: Alex Masterov <amasterov@gmail.com>  
Discussion: https://postgr.es/m/CA+8z=zumV9sscgK=j1Es+-564maVoO9CMDdB9CsW9=FCziCj3w@mail.gmail.com  

M src/backend/utils/activity/pgstat_shmem.c

Fix RLS checks for FOR PORTION OF leftover rows

commit   : 20fe90bbb93df755e00dc88ace5988fda0b1d7d3    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 20 Jul 2026 08:38:08 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 20 Jul 2026 08:38:08 +0200    

Click here for diff

UPDATE/DELETE FOR PORTION OF may insert leftover rows to preserve the  
parts of the old row that are outside the target range.  Those inserts  
go through ExecInsert(), which checks RLS policies using  
WCO_RLS_INSERT_CHECK.  
  
However, the rewriter only added RLS WITH CHECK options for the  
original statement command.  For UPDATE, that meant only  
WCO_RLS_UPDATE_CHECK options were available, so ExecInsert() skipped  
them.  For DELETE, no RLS WITH CHECK options were added at all.  As a  
result, leftover rows could be inserted even when they violated INSERT  
RLS policies.  
  
Fix this by adding INSERT RLS WITH CHECK options for UPDATE/DELETE FOR  
PORTION OF target relations.  Also add regression coverage for both  
UPDATE and DELETE, including cases where allowed leftovers still  
succeed and disallowed leftovers are rejected.  
  
Author: Chao Li <lic@highgo.com>  
Co-authored-by: Paul A Jungwirth <pj@illuminatedcomputing.com>  
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/6C34A987-AC50-4477-BD71-2D4AFEE1A589%40gmail.com  
Discussion: https://www.postgresql.org/message-id/flat/CAJTYsWWdeBkoH5g8D-k9LDw9ciqsMxb21EJSiFXAzP4J%3DXyxOQ%40mail.gmail.com  

M doc/src/sgml/ref/create_policy.sgml
M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/update.sgml
M src/backend/rewrite/rowsecurity.c
M src/test/regress/expected/for_portion_of.out
M src/test/regress/expected/rowsecurity.out
M src/test/regress/sql/for_portion_of.sql
M src/test/regress/sql/rowsecurity.sql

Handle concurrent sequence refreshes.

commit   : 45cf7b1e5bf923ca48dfd9aa5001bdd0630d11c3    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 20 Jul 2026 11:11:45 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 20 Jul 2026 11:11:45 +0530    

Click here for diff

'ALTER SUBSCRIPTION ... REFRESH SEQUENCES' can race with a running  
sequence synchronization worker. If the worker has fetched a sequence's  
value from the publisher but not yet marked it READY, a concurrent refresh  
that resets the sequence to INIT can be overwritten by the worker's stale  
value, silently losing the refresh request.  
  
Handle this by stopping any running sequence sync worker before resetting  
the sequences to INIT. This is race-free because AlterSubscription()  
already holds AccessExclusiveLock on the subscription object. That lock  
blocks a running worker's UpdateSubscriptionRelState(), which takes  
AccessShareLock on the object, and also any worker the apply worker  
re-launches, because a new worker takes AccessShareLock on the object in  
InitializeLogRepWorker() before it reads pg_subscription_rel. Such a  
worker cannot act on the sequence states until the refresh commits, by  
which time they are reset to INIT and it will synchronize the latest  
publisher values.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M src/backend/commands/subscriptioncmds.c

Skip unnecessary get_relids_in_jointree() when there are no PHVs

commit   : 0da71d90d62308d12a789aad8a2a09223976fe88    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 20 Jul 2026 12:13:11 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 20 Jul 2026 12:13:11 +0900    

Click here for diff

Commit 1df9e8d96 made remove_useless_result_rtes() compute the set of  
baserels in the jointree, to pass down to the find_dependent_phvs()  
checks.  But those checks are no-ops when the query contains no PHVs,  
since find_dependent_phvs() and find_dependent_phvs_in_jointree() both  
return early in that case.  So we can avoid the  
get_relids_in_jointree() scan altogether when root->glob->lastPHId is  
zero, leaving baserels as NULL.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CAMbWs49H275KzgZr3Cd1Hy+6Lmwp35bZ+5PrVc62k3HDLj6hNQ@mail.gmail.com  
Backpatch-through: 16  

M src/backend/optimizer/prep/prepjointree.c

Run nbtree test module tests under autoconf builds

commit   : b087a88c40e45453682bf6d24c42eff33f401662    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Sun, 19 Jul 2026 22:15:37 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Sun, 19 Jul 2026 22:15:37 -0400    

Click here for diff

Commit 1e4e5783e added the src/test/modules/nbtree test module, but only  
registered it in the meson build, not in the module list in  
src/test/modules/Makefile.  As a result, autoconf builds never ran the  
module's tests.  
  
To fix, add the module to the Makefile's lists of  
injection-point-dependent modules.  
  
Oversight in commit 1e4e5783e.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Michael Paquiër <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAH2-Wz=JchiD5ksiT35p8Ar02gaNv8_y6w2wBAST+Zzen-eNjw@mail.gmail.com  
Backpatch-through: 19  

M src/test/modules/Makefile

Fix parsing of underscores in pg_plan_advice occurrence numbers

commit   : f87375bfba5cee2dcea4c19879ee990463be9636    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sun, 19 Jul 2026 23:27:52 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Sun, 19 Jul 2026 23:27:52 +0200    

Click here for diff

The pg_plan_advice scanner recognizes underscores as digit separators  
just like the core parser, but used strtoint() to convert occurrence  
numbers which does not support underscores.  Consequently, advice such  
as SEQ_SCAN(x#1_0) failed to parse.  Fix by using pg_strtoint32_safe()  
like the core scanner, and also add regression test coverage.  
  
This bug was independently found and reported by Lukas Fittl and Chao  
Li.  Backpatch down to v19 where pg_plan_advice was introduced.  
  
Author: Chao Li <lic@highgo.com>  
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>  
Reported-by: Lukas Fittl <lukas@fittl.com>  
Reported-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Lukas Fittl <lukas@fittl.com>  
Discussion: https://postgr.es/m/22E2ECE0-B768-43D5-8575-61C3EBC2E4E8@gmail.com  
Discussion: https://postgr.es/m/CAP53PkzKeD=t90OfeMsniYrcRe2THQbUx3g6wV17Y=ZtiwmWTQ@mail.gmail.com  
Backpatch-through: 19  

M contrib/pg_plan_advice/expected/syntax.out
M contrib/pg_plan_advice/pgpa_scanner.l
M contrib/pg_plan_advice/sql/syntax.sql

Remove redundant null-treatment check in window function dedup.

commit   : d451ca6917e35ce5aeee032462b3cd783d7a706e    
  
author   : Tatsuo Ishii <ishii@postgresql.org>    
date     : Sun, 19 Jul 2026 10:45:47 +0900    
  
committer: Tatsuo Ishii <ishii@postgresql.org>    
date     : Sun, 19 Jul 2026 10:45:47 +0900    

Click here for diff

Commit 25a30bbd423 (IGNORE NULLS / RESPECT NULLS for window functions)  
made ExecInitWindowAgg() treat two otherwise-equal window functions as  
duplicates only when their ignore_nulls settings also matched:  
  
    if (i <= wfuncno && wfunc->ignore_nulls == perfunc[i].ignore_nulls)  
  
That extra term reads WindowStatePerFuncData.ignore_nulls, but the field  
was never populated when a per-function entry was filled in, so it stayed  
zero from palloc0_array().  Consequently a duplicate call carrying  
IGNORE NULLS or an explicit RESPECT NULLS never matched an identical  
earlier entry and was needlessly given its own per-function slot and  
evaluated twice.  (Results stayed correct; this was a missed sharing, not  
a wrong answer.)  
  
The extra term is in fact redundant.  WindowFunc.ignore_nulls is a plain  
scalar field with no pg_node_attr, so _equalWindowFunc() already compares  
it; the preceding equal() call therefore never matches two WindowFuncs  
that differ only in null treatment.  If equal() matches, ignore_nulls  
necessarily matched too, so the term can never change the outcome, and  
WindowStatePerFuncData.ignore_nulls existed only to feed it.  
  
Rather than populate the shadow field, drop the redundant term and the  
field (and adjust the now-stale comment) and let equal() do the work.  
That fixes the same bug while removing the hand-maintained duplicate  
state that caused it, so it cannot silently drift again.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Co-authored-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>  
Discussion: https://postgr.es/m/5D2C9081-5DFE-4E27-AB14-7358238EA1BC%40gmail.com  
Backpatch-through: 19  

M src/backend/executor/nodeWindowAgg.c

Further cleanup for commit 54cd6fc83.

commit   : d4046a480539056a4f805faf8d0c13beac403ccb    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Sun, 19 Jul 2026 03:50:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Sun, 19 Jul 2026 03:50:00 +0900    

Click here for diff

Commit 54cd6fc83 set the version argument for the stats-import functions  
introduced by that commit, which is of type int, using UInt32GetDatum,  
not Int32GetDatum.  This would be completely harmless as it's positive  
and currently ignored in the functions, but let's fix that code to use  
Int32GetDatum for consistency.  
  
Author: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/CAPmGK14aremJGrPezVwFqWt7dnrMhD3KF1DgzsRygAUPETBU7w%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c

Fix edge case in remove_useless_result_rtes() with outer joins.

commit   : 1df9e8d969d60cbbb296b408a9f595fa2aab2701    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 18 Jul 2026 14:09:10 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 18 Jul 2026 14:09:10 -0400    

Click here for diff

find_dependent_phvs() and find_dependent_phvs_in_jointree() decide  
whether a PlaceHolderVar depends on the RTE_RESULT rel we're  
considering removing by comparing the PHV's phrels to a singleton set  
containing that rel's RT index, reasoning that if phrels contains any  
other relid bits then those define an appropriate place where we can  
evaluate the PHV.  But since this code was originally written, we've  
redefined phrels to include outer-join relids, and that breaks this  
logic, potentially allowing us to remove an RTE_RESULT that leaves no  
valid place to evaluate the PHV.  The planner doesn't throw an error  
when that happens, but it does produce an incorrect plan that will not  
replace the PHV's value with NULL when needed.  
  
In the known test case for this bug, the "extra" OJ relid is one that  
we've actually decided to remove but haven't yet cleaned out of the  
query's PHVs.  It's not entirely clear though that that would always  
be the case.  Let's restore this code to the way it was designed to  
work, by considering only base relids within the PHV's phrels.  
  
Bug: #19553  
Reported-by: Viktor Leis <leis@in.tum.de>  
Author: Matheus Alcantara <matheusssilv97@gmail.com>  
Co-authored-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19553-4561747f93f368a7@postgresql.org  
Backpatch-through: 16  

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

Restore the ability to use | and -> as prefix operators.

commit   : 0316593146d573eea9a2232e220347727b952c13    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 18 Jul 2026 12:57:42 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 18 Jul 2026 12:57:42 -0400    

Click here for diff

Commit 2f094e7ac changed the parser to treat these as built-in  
operator names, where before they were just generic Op.  While  
it correctly gave them the same precedence as Op and added new  
productions to allow them to still be used as infix operators,  
it missed allowing them to still be used as prefix operators.  
At least one extension expects to be able to do that, so add  
the necessary productions.  
  
Bug: #19558  
Reported-by: Pierre Senellart <pierre@senellart.com>  
Author: Pierre Forstmann <pierre.forstmann@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19558-ad1fca59a3a471a0@postgresql.org  
Backpatch-through: 19  

M src/backend/parser/gram.y

Fix REASSIGN OWNED for subscriptions in other databases.

commit   : 03bcb6a7778e3eaa148c98107d878e2bd9b8a27b    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Sat, 18 Jul 2026 09:22:40 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Sat, 18 Jul 2026 09:22:40 -0700    

Click here for diff

Subscription objects are conceptually database-local objects, but  
pg_subscription is a shared catalog so that the launcher process can  
scan it.  
  
Check readers of pg_subscription to ensure that, unless it's the  
launcher process, it filters by MyDatabaseId. Most readers were  
already doing so, but this commit fixes REASSIGN OWNED and adds guards  
to catch other problems in the future. Also, clarify documentation.  
  
Author: Dilip Kumar <dilipbalaut@gmail.com>  
Reported-by: Noah Misch <noah@leadboat.com>  
Reviewed-by: shveta malik <shveta.malik@gmail.com>  
Discussion: https://postgr.es/m/20260710192533.4f.noahmisch@microsoft.com  
Backpatch-through: 19  

M contrib/postgres_fdw/t/010_subscription.pl
M doc/src/sgml/ref/reassign_owned.sgml
M doc/src/sgml/user-manag.sgml
M src/backend/catalog/pg_subscription.c
M src/backend/commands/subscriptioncmds.c

Revert "Reject concurrent sequence refreshes".

commit   : dde9a87d4d02a67a5bd459045f03a6f467a00a80    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Sat, 18 Jul 2026 07:42:18 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Sat, 18 Jul 2026 07:42:18 +0530    

Click here for diff

This reverts commit f38afa4abb04e85530c94b88daf11c089375daca.  
  
That commit fixed a race that could leave stale sequence values on the  
subscriber after 'ALTER SUBSCRIPTION ... REFRESH SEQUENCES'. It did so by  
raising an ERROR during 'ALTER SUBSCRIPTION ... REFRESH SEQUENCES'  
whenever a sequence synchronization worker was already running for the  
subscription.  
  
That approach caused intermittent buildfarm failures, because the existing  
tests did not ensure the sequencesync worker had stopped before executing  
'ALTER SUBSCRIPTION ... REFRESH SEQUENCES'. While discussing how to fix  
the tests, we concluded that blocking the command while a sequencesync  
worker is running is inconvenient for users. So we will fix the original  
race differently in a follow-up commit.  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/3614163.1784163070@sss.pgh.pa.us  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M src/backend/commands/subscriptioncmds.c
M src/test/subscription/t/036_sequences.pl

Generate unicode_limits.h.

commit   : 2cf212db5286baa7d7e80449300fe472d8c4ba9f    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Fri, 17 Jul 2026 16:41:14 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Fri, 17 Jul 2026 16:41:14 -0700    

Click here for diff

To ensure we do not overflow a size_t while case mapping on a 32-bit  
platform, we need to know the maximum amount a UTF8 string can expand.  
  
Calculate that maximum while generating unicode tables as a part of  
the update-unicode target, and output into a new header  
unicode_limits.h. Minor refactoring along the way.  
  
Add a StaticAssertDecl to check that a MaxAllocSize text value  
expanded by that amount would still have a length that fits in  
size_t. (We couldn't actually create a new text value out of that, but  
we still need to avoid overflow.)  
  
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/3213927.1783950167@sss.pgh.pa.us  

M src/backend/utils/adt/pg_locale_builtin.c
M src/common/unicode/Makefile
M src/common/unicode/generate-unicode_case_table.pl
M src/common/unicode/meson.build
M src/common/unicode_case.c
M src/include/common/unicode_case_table.h
A src/include/common/unicode_limits.h

Fix yet another portability problem in new NLS test.

commit   : f5dfd52553d3b041e30e9b1f1c6eb9f7af55fbdb    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 17 Jul 2026 18:08:23 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 17 Jul 2026 18:08:23 -0400    

Click here for diff

Álvaro reported offlist that his machine was passing the new-in-v19  
nls.sql test in "make check" but not in "make installcheck".  On  
investigation, the cause turned out to be that he has LANGUAGE set in  
his environment, and with (at least recent versions of) glibc that  
overrides LC_MESSAGES and friends, as per previous research by Bryan  
Green.  "make check" works because pg_regress unsets LANGUAGE before  
starting the postmaster, but in installcheck mode we're exposed to  
the prevailing value and we lose.  
  
We're already hacking the value of LANGUAGE in this test for Solaris,  
so let's just extend that to unsetting LANGUAGE on every other platform.  
  
Reported-by: Álvaro Herrera <alvherre@kurilemu.de>  
Diagnosed-by: Andrew Dunstan <andrew@dunslane.net>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/a337896e-5bff-490b-afc9-c545f06c014c@gmail.com  
Backpatch-through: 19  

M src/test/regress/regress.c

Turn visibilitymap_clear() Assert back into an error

commit   : 4dbc54506c328a03070bf1a98309bdc05dac331d    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 17 Jul 2026 16:47:33 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 17 Jul 2026 16:47:33 -0400    

Click here for diff

Commit ed62d26caca fixed a bug in clearing the visibility map and, while  
doing so, made some incidental changes to visibilitymap_clear(). One of  
them replaced the error thrown when the wrong buffer is passed to  
visibilitymap_clear() with an Assert().  
  
While anyone adding a new visibilitymap_clear() caller should be running  
assert-enabled builds, visibilitymap_set() still reports the same  
wrong-buffer condition with an elog(ERROR), so visibilitymap_clear()  
should also do so for consistency. This change was also unrelated to  
the bug fix and is better made as a separate commit. Restore the error.  
  
Reported-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwF_PzOv5y7ucFh7Fqqqa8ar83zYwvWugqarRD6%2B7GCtEQ%40mail.gmail.com  
Backpatch-through: 19  

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

Revert "Add GROUP BY ALL".

commit   : a32733d8f10f0e35f7e4ee772ddbef552296577f    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 17 Jul 2026 16:13:57 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 17 Jul 2026 16:13:57 -0400    

Click here for diff

This reverts commit ef38a4d9756db9ae1d20f40aa39f3cf76059b81a which  
implemented the GROUP BY ALL syntax, as well as 2ce745836 which  
made some comment improvements therein.  
  
A postcommit review discovered that GROUP BY ALL missed our special  
handling of entries that also appear in an ORDER BY in the query.  
This caused the query to return wrong results when ORDER BY  
specifies non-default equality semantics.  While this should be  
fixable with some refactoring, doing it cleanly seems like too  
much code churn for late beta.  We'll revert and try again in v20.  
  
The reverted commit also included some additional comment wordsmithing  
and docs cleanup, which are retained as they weren't connected to the  
reverted feature.  
  
catversion bump needed due to change in struct Query.  
  
Reported-by: Chao Li <li.evan.chao@gmail.com>  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/5243308F-8E5C-45AA-828C-FAD96C4F34DA@gmail.com  
Backpatch-through: 19  

M doc/src/sgml/queries.sgml
M doc/src/sgml/ref/select.sgml
M doc/src/sgml/ref/select_into.sgml
M src/backend/parser/analyze.c
M src/backend/parser/gram.y
M src/backend/parser/parse_clause.c
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/catversion.h
M src/include/nodes/parsenodes.h
M src/include/parser/parse_clause.h
M src/test/regress/expected/aggregates.out
M src/test/regress/sql/aggregates.sql

Fix GiST index-only scan column alignment issue.

commit   : c9ea37231a2e23120bafe0c4dd542642d4b87aad    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Fri, 17 Jul 2026 15:53:10 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Fri, 17 Jul 2026 15:53:10 -0400    

Click here for diff

An index-only scan filled its result slot from the HeapTuple an index AM  
returns in scan->xs_hitup by deforming it with the virtual slot's own  
tuple descriptor (during GiST and SP-GiST index-only scans).  But index  
AMs form that heap tuple using their own descriptor, scan->xs_hitupdesc.  
The AM's descriptor may disagree with the IoS virtual slot's descriptor  
about each column's precise alignment, leading to "can't happen" errors  
in certain rare edge cases.  Hard crashes were possible but much less  
likely.  
  
To fix, deform the tuple with the descriptor it was formed with.  This  
is simpler, and makes xs_hitup handling (used by GiST and SP-GiST)  
uniform with the nearby existing xs_itup handling (used by nbtree).  
  
In practice this issue was very unlikely to be hit (it was found during  
testing of a patch that will change the table AM API used during index  
scans).  The only currently affected core opclass is GiST's range_ops.  
It was only possible for the datum to be accessed at an incorrectly  
aligned offset when reading the second or subsequent column from a  
multicolumn GiST index.  This couldn't happen in the common case where  
the datum used an unaligned short varlena header.  Moreover, an earlier  
column had to leave the range datum at an offset where the two  
alignments actually disagree (e.g., an odd-length varlena datum).  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/CAH2-WzkGXa2SKnebdW29RT1hCcQBo_p03v3iqif2u9bjzLB-aQ@mail.gmail.com  
Backpatch-through: 14  

M src/backend/executor/nodeIndexonlyscan.c
M src/test/regress/expected/gist.out
M src/test/regress/sql/gist.sql

ci: Generate crashlogs on Windows

commit   : d374280e1837adc1f8218bb0d69ffbae5d808fc6    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 17 Jul 2026 11:43:52 -0400    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 17 Jul 2026 11:43:52 -0400    

Click here for diff

This configures cdb.exe to log all crashes to  
"<workspace>\crashlogs\crashlog-<pid-in-hex>.txt" (as it was previously set up  
for cirrus-ci based CI). The upload logs step already collects these logs.  
  
The logic is copied from the generation of Postgres CI Windows images for  
cirrus-ci [1].  Since this would be too long to include inline in pg-ci.yml,  
it is implemented as 'src/tools/ci/gha_setup_windows_debugger.ps1' script.  
  
[1] https://github.com/anarazel/pg-vm-images/blob/main/scripts/windows_install_dbg.ps1  
  
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://postgr.es/m/CAN55FZ1BgsXSTzOpehnMa4NzWL8Aivsxx-di7-VT6bZ3j2Omow%40mail.gmail.com  
Discussion: https://postgr.es/m/iggjozfshwbqpv33x5jqwtju5k5zrkyu3257dlifxkhtpg7eoq@k2ccyrdi5dtu  
Backpatch-through: 19, where GHA CI was added  

M .github/workflows/pg-ci.yml
A src/tools/ci/gha_setup_windows_debugger.ps1

ci: Use optimized build for mingw

commit   : 47a20d872bf71ca8b37884c8126c529b67a12cd5    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 17 Jul 2026 11:43:52 -0400    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 17 Jul 2026 11:43:52 -0400    

Click here for diff

The test runtime dominates over the compile time on GHA.  Note that we just  
need to remove options, as postgres's default is debugoptimized.  
  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Discussion: https://postgr.es/m/a2ejn7lfqolutzz7kozalbhy3bixdrujb4buc3pgbtlk4am2ba@wbv6v7riia33  
Backpatch-through: 19, where GHA CI was added  

M .github/workflows/pg-ci.yml

meson: Fix ccache issues when using precompiled headers with gcc

commit   : cf9d76d78d69aa0b11a50a50b31aa83506304cac    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 17 Jul 2026 11:23:18 -0400    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 17 Jul 2026 11:23:18 -0400    

Click here for diff

Unfortunately the combination of gcc, precompiled headers, ccache and meson  
currently is not safe without further options. The dependencies emitted by gcc  
are insufficient to trigger rebuilds when headers "below" the precompiled  
headers are changed. Whether that's a ccache, gcc or meson bug is  
debatable. Luckily gcc's -fpch-deps option fixes the issue.  
  
This problem occasionally leads to build failures, e.g. if only c.h,  
postgres.h or pg_config_manual.h change. That's e.g. the case when creating a  
new major version branch.  
  
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>  
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://postgr.es/m/CAN55FZ0tqR6Xz%3DiVFLc1BBoLOEHU775ARhcGYwggHA3XLA%3DoQg%40mail.gmail.com  
Discussion: https://postgr.es/m/CA+hUKG+s7Yvt0PUnSQUEjCjysV-7-51n9B1h468Le3VJi0x4ZQ@mail.gmail.com  
Discussion: https://postgr.es/m/phsrssp75npoyalqsolcd7fmnmlbzbmquc2p7w7mqjlw7432jk@bzskz3luyjvb  
Discussion: https://github.com/ccache/ccache/issues/1686  
Backpatch-through: 16, where meson support was added  

M meson.build

doc: Fix SQL quoting in example

commit   : 2521f9e75e910cec13591c1af76a69ea7f96109e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 17 Jul 2026 15:45:30 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 17 Jul 2026 15:45:30 +0200    

Click here for diff

The identifier "order" needs to be quoted, just like in the example a  
little bit earlier.  
  
Author: Thom Brown <thom@linux.com>  
Discussion: https://www.postgresql.org/message-id/CAA-aLv4xyAaxm8vq5LEhznh-SGphs4wUAGC6Vpas%2B1hHZzzD7A%40mail.gmail.com  

M doc/src/sgml/ddl.sgml

Fix truncation rules for base64 encoding

commit   : 1f414035135cca34b606d4c0d3db0eb57045e00b    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 17 Jul 2026 15:40:16 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Fri, 17 Jul 2026 15:40:16 +0200    

Click here for diff

Commit e1d917182 added support for base64url encoding, a base64 variant  
intended to be safe for usage in URLs and filenames.  The padding rules  
for base64url and base64 differ in that base64url require no extra '='  
padding, but the commit unintentionally relaxed this requirement for  
base64 as well.  Fix by making sure that the truncation logic check  
for the encoding and add a test to make sure.  
  
Backpatch down to v19 where support for base64url was introduced.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: David E. Wheeler <david@justatheory.com>  
Discussion: https://postgr.es/m/3258FC72-F5E1-40B9-B5D7-64478CAF7728@yesql.se  
Backpatch-through: 19  

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

Restrict pg_stat_io entries for data checksum processes

commit   : 32e4508db27d1fa3dc07404ad69d43ed97870f15    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 17 Jul 2026 20:16:34 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 17 Jul 2026 20:16:34 +0900    

Click here for diff

The data checksums launcher and workers were exposed in pg_stat_io  
with the same broad set of object/context combinations as general  
background workers. However, several of those entries can never  
accumulate I/O statistics for these processes, such as bulkwrite,  
relation init, temporary relation, and launcher vacuum entries.  
  
Teach pgstat_tracks_io_object() and pgstat_tracks_io_op() about the  
actual I/O performed by the data checksum processes. Keep the entries  
needed for catalog scans, including bulkread catalog scans, worker  
relation processing with a vacuum access strategy, and WAL writes and  
initialization, while excluding WAL reads and other object/context  
combinations that can never be used.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAHGQGwHz_-nt+YkHDMRZNBZrnoHro8cMOgSwuXEmSYT6vxgQ=w@mail.gmail.com  
Backpatch-through: 19  

M src/backend/utils/activity/pgstat_io.c
M src/test/regress/expected/stats.out

Doc: Clarify DROP SUBSCRIPTION behavior after SET (slot_name = NONE).

commit   : 03480907e9ff5d9bb3296b56c9b49db3df756e0f    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 17 Jul 2026 09:47:33 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 17 Jul 2026 09:47:33 +0530    

Click here for diff

The previous text claimed that once the slot is disassociated with  
ALTER SUBSCRIPTION ... SET (slot_name = NONE), DROP SUBSCRIPTION "will no  
longer attempt any actions on a remote host".  That is inaccurate:  
DROP SUBSCRIPTION may still connect to the publisher to drop  
internally-created table synchronization slots when some table  
synchronization is left unfinished.  Reword to describe this, and note  
that if the publisher is unreachable those slots (and the main slot, if  
it still exists) must be dropped manually to avoid indefinitely reserving  
WAL.  
  
Reported-by: Jeff Davis <pgsql@j-davis.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 14  
Discussion: https://postgr.es/m/CAA4eK1+tyYSpPxMBy1974kjivuGeR7YY=yopwRGrK3+vCTysdg@mail.gmail.com  
Discussion: https://postgr.es/m/D908370F-2695-4231-851D-17179A6A6F2A@gmail.com  

M doc/src/sgml/ref/drop_subscription.sgml

Fix wrong variable offset sanity check.

commit   : 323530e00d279f267265ef32c7e6b40a04c94105    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 16 Jul 2026 18:55:36 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 16 Jul 2026 18:55:36 -0400    

Click here for diff

Commit c7aeb775 rewrote the HOT-chain offset sanity checks in three  
places, but in heap_get_root_tuples it accidentally tested offnum -- the  
outer loop variable, which is already bounded by the loop condition --  
instead of nextoffnum, the offset actually passed to PageGetItemId.  The  
pre-c7aeb775 check tested nextoffnum.  
  
With the check ineffective, a stale t_ctid could make PageGetItemId read  
past the end of the line pointer array (which is data corruption that we  
expect to be able to catch here).  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reported-by: Konstantin Knizhnik <knizhnik@garret.ru>  
Discussion: https://postgr.es/m/87c7d8a4-3a82-4334-bee6-e8c2ad3f3293@garret.ru  
Backpatch-through: 15  

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

Remove SQL function getpgusername()

commit   : 7af998936d304b676d4e8fb2f2780560cf8443ca    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 17 Jul 2026 07:40:10 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 17 Jul 2026 07:40:10 +0900    

Click here for diff

Since 457ac0331cd3, current_user() is the recommended way to get access  
to this information, and getpgusername() was marked as deprecated since,  
without being documented.  
  
Bump catalog version.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv44sPoKhHZqBvhqRdrFUEKwatGEmXBtqC360UuD5Lt7Nw@mail.gmail.com  

M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

Use fake LSNs consistently in hash index AM.

commit   : cea74f48d36bc1073da0adab755946ad94aa6902    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 16 Jul 2026 18:08:43 -0400    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Thu, 16 Jul 2026 18:08:43 -0400    

Click here for diff

Defensively make sure that all hash index atomic actions use a fake LSN  
with an unlogged relation.  
  
Oversight in commit e5836f7b, which added fake LSN support to the hash  
index AM, but missed log_split_page.  
  
Author: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/CAH2-WzkC-opX8iS6X=a470DDC31er_x5rzPw=HjRxha9N8brZw@mail.gmail.com  
Backpatch-through: 19  

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

pg_controldata: Show logical decoding status.

commit   : 8108765f04b8dae252825123834fe350cafe174f    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 16 Jul 2026 12:20:39 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 16 Jul 2026 12:20:39 -0700    

Click here for diff

The logical decoding status is stored in checkpoint records and used  
to restore the status at server startup, but pg_controldata did not  
show it. This information is useful for diagnosing issues around the  
dynamic activation and deactivation of logical decoding.  
  
Oversight in 67c20979ce7.  
  
Reviewed-by: Guoqing Yang <yanggq1988@126.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/CAD21AoAnPAugUnDic+ESvrfXjXHk2bss9eHAD7zP0-Chy2UabA@mail.gmail.com  
Backpatch-through: 19  

M src/bin/pg_controldata/pg_controldata.c

Correct logical decoding status at end of recovery with minimal WAL level.

commit   : c209931bd40c9d47fd32903d4055a998856395d9    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 16 Jul 2026 12:13:13 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 16 Jul 2026 12:13:13 -0700    

Click here for diff

Crash recovery running with wal_level='minimal' can replay an  
XLOG_LOGICAL_DECODING_STATUS_CHANGE record that activates logical  
decoding, if the server previously ran with a higher wal_level and  
crashed after the last logical slot was dropped but before the  
checkpointer deactivated logical decoding. Replaying such a record is  
correct since it reflects the status at the time it was  
written. However, UpdateLogicalDecodingStatusEndOfRecovery() asserted  
that logical decoding is never active with wal_level='minimal',  
causing an assertion failure at the end of recovery. In production  
builds, logical decoding would remain active while running with  
wal_level='minimal'.  
  
Instead of special-casing wal_level='minimal', recompute the status at  
the end of recovery as usual: no logical slot can exist with  
wal_level='minimal' as RestoreSlotFromDisk() would have rejected it,  
so the recomputation always deactivates logical decoding in this case,  
also writing the corresponding status change record.  
  
Oversight in 67c20979ce7.  
  
Reviewed-by: Guoqing Yang <yanggq1988@126.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Discussion: https://postgr.es/m/CAD21AoAnPAugUnDic+ESvrfXjXHk2bss9eHAD7zP0-Chy2UabA@mail.gmail.com  
Backpatch-through: 19  

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

Reject infinite and out-of-range interval shifts in uuidv7().

commit   : 7575215e0b9cf56340ea5fc202fa45f7613852c9    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 16 Jul 2026 11:50:10 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Thu, 16 Jul 2026 11:50:10 -0700    

Click here for diff

uuidv7(interval) shifts the current time by the given interval before  
encoding it into the 48-bit Unix-millisecond timestamp field of the  
generated UUID. Two cases were mishandled:  
  
An infinite interval ('infinity' or '-infinity') produced an infinite  
timestamp, which overflowed during the conversion to Unix-epoch  
microseconds and yielded a garbage UUID. Reject infinite intervals up  
front, before any timestamp arithmetic.  
  
A shift that moved the timestamp outside the range representable by  
the 48-bit field was silently accepted. Timestamps before the Unix  
epoch wrapped when cast to unsigned, and timestamps beyond  
approximately year 10889 overflowed the field; both produced UUIDs  
with bogus timestamps that break sort ordering. Reject any shifted  
timestamp outside the supported range.  
  
Also document that infinite intervals and out-of-range shifts are  
rejected.  
  
Although raising a new error changes behavior in a stable branch, this  
is back-patched to 18 (where uuidv7(interval) was introduced) because  
the previous behavior can silently corrupt data. Failing loudly is far  
safer than silently accepting the wraparound; otherwise users may not  
discover that their UUIDv7 values are no longer sortable until years  
later, when recovery is painful. It also matches how PostgreSQL  
already handles timestamp + interval overflow, which raises an  
error. The change only affects applications passing an interval large  
enough to push the result outside the representable range.  
  
Backpatch to 18, where uuidv7(interval) was introduced.  
  
Reported-by: Christophe Pettus <xof@thebuild.com>  
Author: Baji Shaik <baji.pgdev@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://www.postgresql.org/message-id/799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com  
Backpatch-through: 18  

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

In transformIndexStmt, transform index expressions in INCLUDING.

commit   : 637aa273e6335c2e4d196f510d6787210403ed24    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 16 Jul 2026 11:56:01 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 16 Jul 2026 11:56:01 -0400    

Click here for diff

Process these just like the adjacent loop for expressions in regular  
index columns.  This logic was originally omitted because there was  
no intention of supporting index expressions in INCLUDING.  
There's still no near-term intention of that, but without this change  
the ChooseIndexExpressionName code added by 181b6185c spits up on  
expressions in INCLUDING: that expects to handle parse-transformed  
expressions, and it runs before we reach the place that is currently  
supposed to throw the "not supported" error.  We could fix this  
problem in other ways, but this way avoids contorting the logic,  
and it results in less code to be revised not more if we ever get  
around to supporting INCLUDING expressions.  
  
Reported-by: Maaz Syed Adeeb <maaz.adeeb@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Test-authored-by: Maaz Syed Adeeb <maaz.adeeb@gmail.com>  
Discussion: https://postgr.es/m/CAG+FJqOxYj=sVyHcys64h9DbvzP6EUPGHJ7oKj-PW=Qp5Ebk_g@mail.gmail.com  

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

Handle concurrent sequence drops during synchronization

commit   : 55f518684895bfe43e667acf59284b49707ee685    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 17 Jul 2026 00:50:54 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 17 Jul 2026 00:50:54 +0900    

Click here for diff

Commit d4a657b0a4d added a call to has_sequence_privilege() while  
fetching sequence information from the publisher, so that  
publisher-side permission failures could be distinguished from missing  
sequences. It also assumed that has_sequence_privilege() could never  
return NULL, and asserted accordingly.  
  
However, that assumption was incorrect. If a sequence is dropped after  
the synchronization worker collects its metadata but while fetching the  
sequence information, has_sequence_privilege() can return NULL.  
This can trigger the assertion failure. This was also reported in  
a buildfarm failure on member culicidae.  
  
Fix this by treating a NULL result from has_sequence_privilege() as  
indicating that the sequence was dropped concurrently, and report it as  
a missing sequence instead of asserting that the result is never NULL.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  
Discussion: https://postgr.es/m/CALDaNm2fHGLeiQKj0r6OG7N9QeayxSmpLrWYJRyt4dL_m3VRWw@mail.gmail.com  
Backpatch-through: 19  

M src/backend/replication/logical/sequencesync.c
M src/test/subscription/t/036_sequences.pl

postgres_fdw: stabilize terminated-connection regression tests

commit   : a704d0367a400fbc327469d96dc6cdba118dba8a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 17 Jul 2026 00:49:26 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 17 Jul 2026 00:49:26 +0900    

Click here for diff

The regression test for postgres_fdw_get_connections(true) assumed that  
a terminated remote connection would still remain visible in the FDW  
connection cache long enough to be reported as closed with a nonzero  
remote_backend_pid.  
  
That assumption is not always valid. postgres_fdw_get_connections()  
reports only entries that are still present in ConnectionHash, while  
pgfdw_inval_callback() may immediately discard an idle cached connection  
(xact_depth == 0) when a relevant invalidation arrives. In CI, that can  
happen between terminating the remote backend and querying  
postgres_fdw_get_connections(true), causing the function to return no  
rows.  
  
Adjust the idle-connection test to accept either outcome: if the cache  
entry is still present, verify that it reports the expected server name,  
closed status, and nonzero remote backend PID; otherwise treat zero rows  
as a legitimate result.  
  
To preserve coverage of the terminated-backend reporting path, add a  
separate check inside an explicit transaction. In that case, concurrent  
invalidation may mark the connection invalid but cannot discard it  
before transaction end, so postgres_fdw_get_connections(true) should  
still report the terminated connection as in-use, closed, and associated  
with a nonzero remote backend PID.  
  
Backpatch to v18, where the affected postgres_fdw_get_connections(true)  
test was introduced.  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CA+Tgmoax3cHXHsm9OidN4F-xiu16y8q2W8T5dTNFic1Zoo2cOw@mail.gmail.com  
Backpatch-through: 18  

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

commit   : 0de346f464b1efd2bfa74fb22c1d6ffe2f733b63    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 16 Jul 2026 16:05:36 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Thu, 16 Jul 2026 16:05:36 +0200    

Click here for diff

Commit 67846550dc6d removed the xreflabels for initdb options, which  
turned the sentence "The second field contains the page checksum if  
data checksums are enabled" into "The second field contains the page  
checksum if -k are enabled", as well "Only has effect if data checksums  
are enabled" into "Only has effect if -k are enabled".  
  
Fix by setting an explicit link text, and while there also change the  
link to point to the data checksum page which has more information  
than just the initdb option.  
  
The original report was for one instance, further inspection turned  
up quite a few more cases.  Also redirect the link in the amcheck  
docs which albeit was reading right, but will be more helpful if  
linking to the main page on data checksums.  Backpatch to v18 where  
the xreflabels were removed.  
  
Author: Daniel Gustafsson <daniel@yesql.se>  
Reported-by: y.saburov@gmail.com  
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Discussion: https://postgr.es/m/178350739237.73862.4549076173872335741@wrigleys.postgresql.org  
Backpatch-through: 18  

M doc/src/sgml/amcheck.sgml
M doc/src/sgml/config.sgml
M doc/src/sgml/storage.sgml

Revert "Make PL/Tcl require Tcl 8.6 or later"

commit   : f4f77f557bb1a173f82be42770a28758732f4cc0    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 12:38:37 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 12:38:37 +0200    

Click here for diff

This reverts commit b6d3ccf2f5f1a179e25e277bae3f432cc084ce58.  
  
macOS still ships with Tcl 8.5.  

M config/tcl.m4
M configure
M doc/src/sgml/installation.sgml
M src/pl/tcl/pltcl.c

Require ICU 55 or later

commit   : 4854b2373c738a3e2fe5a46c2667d908f7c7e13a    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    

Click here for diff

Support for older versions is removed.  Since we no longer support  
RHEL 7, we don't need to support these old versions anymore.  This  
allows a fair amount of code cleanup, including some code blocks that  
specifically catered to old versions that probably received very  
little actual testing and use.  
  
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com  

M configure
M configure.ac
M doc/src/sgml/installation.sgml
M meson.build
M src/backend/utils/adt/pg_locale_icu.c

Make PL/Tcl require Tcl 8.6 or later

commit   : b6d3ccf2f5f1a179e25e277bae3f432cc084ce58    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    

Click here for diff

Support for Tcl 8.5 and 8.4 is removed.  Since we no longer support  
RHEL 7, we don't need to support these old versions anymore.  This  
allows some small amount of code cleanup.  
  
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com  

M config/tcl.m4
M configure
M doc/src/sgml/installation.sgml
M src/pl/tcl/pltcl.c

Drop support for _MSC_VER less than 1933

commit   : da9451830455a402fd6e29403a6512ebb2b41d97    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    

Click here for diff

Commit aa7c8685234 added a workaround for _MSC_VER less than 1933,  
which is Visual Studio 2022 version 17.3.  Since we dropped support  
for Visual Studio before 2022, and the versions up to 17.3 are long  
EOL, we can drop this extra code.  
  
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com  

M src/include/c.h

Raise requirement to Visual Studio 2022

commit   : 6319d6372c8f28cfb30bd2b7b0893f28e44491e6    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 16 Jul 2026 11:47:41 +0200    

Click here for diff

The use of _Generic from commit "Replace __builtin_types_compatible_p  
with _Generic" causes compiler errors from VS 2019.  Apparently, that  
compiler is just broken for that (even though it appears to support  
_Generic in general, for example in commit 59c2f03d1ec).  
  
Per discussion, just drop support for VS 2019 and require at least VS  
2022.  This just updates the documentation about that.  In passing,  
some information about VS 2026 is added.  
  
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com  

M doc/src/sgml/installation.sgml

Check CREATE_REPLICATION_SLOT response shape in libpqwalreceiver

commit   : 3cf5264557bee2ba848e5276beecc10571d468a6    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 16 Jul 2026 13:38:34 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 16 Jul 2026 13:38:34 +0900    

Click here for diff

Previously, libpqrcv_create_slot() checked only that  
CREATE_REPLICATION_SLOT returned PGRES_TUPLES_OK before reading  
values from the first row. If the server unexpectedly returned an  
invalid result, such as zero rows, PQgetvalue() could return NULL,  
leading to a crash while parsing the LSN.  
  
Other replication commands, such as IDENTIFY_SYSTEM, already validate  
the response shape before accessing result values, but  
CREATE_REPLICATION_SLOT did not.  
  
Fix this by verifying that CREATE_REPLICATION_SLOT response contains  
exactly one row with four fields, and report a protocol violation otherwise.  
  
Backpatch to all supported versions.  
  
Bug: #19547  
Reported-by: Yuelin Wang <1217816127@qq.com>  
Author: Kenny Chen <kennychen851228@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/19547-f7986f668f71e788@postgresql.org  
Discussion: https://postgr.es/m/CAPXstDtW2iqe+DJAOTQTX+rRziJp2UhZSo1+HRj1COAtbu+nKw@mail.gmail.com  
Backpatch-through: 14  

M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

doc: Mention REPACK in MAINTAIN privilege descriptions

commit   : 3ef575e4f190a26e50e46f2f8584a53b524660d0    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 16 Jul 2026 13:37:28 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 16 Jul 2026 13:37:28 +0900    

Click here for diff

REPACK requires the MAINTAIN privilege, but it was omitted from the  
lists of commands covered by that privilege in ddl.sgml and the  
description of the predefined pg_maintain role in user-manag.sgml.  
This was an oversight in commit ac58465e061, which introduced  
REPACK.  
  
Add REPACK to both documentation lists, and update the corresponding  
comment in aclchk.c.  
  
Author: Shinya Kato <shinya11.kato@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAOzEurRJOVokiB2J8nrF569nX-ZMb0oRSB0C=yZQ17mZxd4_BQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/user-manag.sgml
M src/backend/catalog/aclchk.c

doc: Fix log_parameter_max_length docs to reference log_min_duration_statement

commit   : 89e78de0436c3ba1710431df8c3e8dd6415f7134    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 16 Jul 2026 13:35:36 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 16 Jul 2026 13:35:36 +0900    

Click here for diff

The documentation for log_parameter_max_length said it affects messages  
generated by log_duration. However, log_duration alone does not log bind  
parameter values, so this is misleading.  
  
This commit updates the documentation to reference log_min_duration_statement,  
which can log bind parameters, to better reflect actual behavior.  
  
Backpatch to all supported versions.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGnCVMVz8-LU9F8Sh57bkQX3jMZzx7age7M0LFEz5=Fog@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/config.sgml

Test that VM clear registers VM buffers

commit   : 5174d157a0381876cb1c6c5903c1844669d5bbc2    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    

Click here for diff

The WAL summarizer only tracks registered buffers, so unregistered VM  
clears are ommitted from incremental backups, corrupting the restored  
visibility map. Test those cases are now fixed.  
  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/oqcsevg35xjan2327x5kdfth6q4fgeqboxfo3v3imeyih2uiny%406sez5dzxl6nt  
Backpatch-through: 17  

M src/bin/pg_combinebackup/Makefile
M src/bin/pg_combinebackup/meson.build
A src/bin/pg_combinebackup/t/012_vm_consistency.pl

Fix VM clear WAL logging by registering VM blocks

commit   : ed62d26cacac96ca5c6b4e6fcc5308b11a8371c8    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    

Click here for diff

Heap WAL records that clear bits on the visibility map (like inserts and  
deletes) did not register the visibility map blocks they modified.  
Because the WAL summarizer only records registered blocks, an  
incremental backup taken over such operations would omit the changed VM  
pages. On restore, the VM would retain stale all-visible/all-frozen  
bits, which can cause wrong results from index-only scans and incorrect  
relfrozenxid advancement due to vacuum page skipping.  
  
Not registering the VM buffer also meant we never emitted FPIs of VM  
pages when clearing bits. A torn VM page won't raise an error because  
the VM is read with ZERO_ON_ERROR; with checksums on, it would be  
detected and zeroed, but with checksums off, it is accepted as-is and  
can lead to data corruption.  
  
Fix this by registering the VM buffer in the WAL record when clearing VM  
bits. The VM buffer must now be locked throughout the critical section  
that modifies the VM and heap pages and emits the WAL record. This can  
slow down operations that clear the VM, since the VM lock is held longer  
and VM FPIs may be emitted, but it is required for correctness.  
  
Note that this fix does not repair existing incremental backups.  
  
Bumps XLOG_PAGE_MAGIC.  
  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Author: Andres Freund <andres@anarazel.de>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/flat/CAAKRu_bn%2Be7F4yPFBgFbnP%2BsyJRKyNK092bjD2LKvZW7O4Svag>  
Backpatch-through: 17  

M contrib/pg_surgery/heap_surgery.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_xlog.c
M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/visibilitymap.c
M src/bin/pg_walsummary/t/002_blocks.pl
M src/include/access/heapam_xlog.h
M src/include/access/xlog_internal.h

Make VM clear take a RelFileLocator and not fake relcache

commit   : 2340fb8f02b28d2fe7f0023d84c3055a38cd5b9e    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    

Click here for diff

This brings it in line with visibilitymap_set(). An upcoming commit will  
start reading visibility map buffers with XLogReadBuffer*() functions,  
so we no longer require a relation object to pin the visibility map,  
allowing us to remove this fake relcache business altogether.  
  
While we're at it, remove a spurious const qualifier from the  
RelFileLocator parameter to visibilitymap_set().  
  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Discussion: https://postgr.es/m/flat/CAAKRu_bn%2Be7F4yPFBgFbnP%2BsyJRKyNK092bjD2LKvZW7O4Svag%40mail.gmail.com  

M contrib/pg_surgery/heap_surgery.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_xlog.c
M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/visibilitymap.c
M src/include/access/visibilitymap.h

Introduce macros for WAL block reference IDs of some heap record types

commit   : 10911fde088aef9c3be511955e9be632964f7a4a    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 17:24:49 -0400    

Click here for diff

When registering a buffer with the WAL machinery, the caller assigns it a  
block reference ID, and replay must read each block back by that same ID.  
Today these IDs are bare integers assigned by convention (0, 1, 2, ...),  
which is easy to follow when a record registers a single block, or when the  
blocks are handled during replay in their registration order.  
  
An upcoming bug fix registers up to two visibility map blocks in addition  
to the heap block(s) when clearing the VM, and these are not handled during  
replay in a straightforward 1:1, in-registration-order fashion. Relying on  
bare integers for the block IDs in that case is error-prone.  
  
Introduce macros naming the block reference IDs for the heap record types  
that the upcoming commit extends to register visibility map blocks, so the  
registration and replay sites refer to the same block by a meaningful name.  
  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/66mqpfyti3qhfttcsv6r2lbvqqd32rrmpn6i47ovrsnvguts46%40gou54xc>  
Backpatch through: 17  

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

Include last block in FSM vacuum of bulk extended relation

commit   : a2fd8d65a0b75aeb81cd52204f358544d1888b02    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 15:49:59 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Wed, 15 Jul 2026 15:49:59 -0400    

Click here for diff

When bulk-extending a relation, we add the newly-added blocks that we  
won't immediately use to the free space map and then call  
FreeSpaceMapVacuumRange() to propagate that free space up the FSM tree,  
so other backends can find and reuse it.  
  
However, the end block argument to FreeSpaceMapVacuumRange() is  
exclusive, and we passed the number of the last added block (since  
00d1e02be24). If that block was the first one covered by a new FSM page,  
its free space wasn't propagated up the tree and was therefore invisible  
to FSM searches until the next FSM vacuum.  
  
Fix by passing the block number one past the last added block, so the  
full range is vacuumed.  
  
Author: Jingtang Zhang <mrdrivingduck@gmail.com>  
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>  
Discussion: https://postgr.es/m/flat/CAPsk3_Bx_vdybN%3D-DZu8HLStf%2BXnuFUBkLwxouONSMkWuO9oug%40mail.gmail.com  
Backpatch-through: 16  

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

pgbench: Fix incorrect parameter name in error message

commit   : 77b4d35e0f530c666514326f86d68d1268e3ec7b    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 15 Jul 2026 21:40:09 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Wed, 15 Jul 2026 21:40:09 +0200    

Click here for diff

Commit 6f164e6d17616 accidentally mistyped --client as --clients in  
the error message.  Backpatch down to v15 where the it was introduced.  
  
Author: Semih Doğan <semih702do@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CALOtZ7tuWisV=v0cUY_q6PLHJ-fOiQ7ZN476JwmM0PyV0t5i7Q@mail.gmail.com  
Backpatch-through: 15  

M src/bin/pgbench/pgbench.c
M src/bin/pgbench/t/002_pgbench_no_server.pl

Fix like_fixed_prefix_ci() selectivity.

commit   : cc3358087822654d68d7bfb8e80fd797a4b9d1b9    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 15 Jul 2026 12:34:20 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Wed, 15 Jul 2026 12:34:20 -0700    

Click here for diff

A wrong calculation introduced by 9c8de15969 could cause trailing  
characters from the prefix to be passed to like_selectivity() rather  
than just the "rest".  
  
Discussion: https://postgr.es/m/c7334a7a44243d2e4ec5e83747589908b3787491.camel@j-davis.com  
Backpatch-through: 19  

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

Add additional sanity checks when reading a blkreftable.

commit   : ee654419d5fe7a37b230b865018dc8c1f6b9fc08    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Wed, 15 Jul 2026 13:04:32 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Wed, 15 Jul 2026 13:04:32 -0400    

Click here for diff

Code elsewhere in the system assumes that fork numbers and chunk sizes  
are within bounds, so the code that reads those quantities from disk  
should validate that they are. Without these additional checks, a  
corrupted file can cause us to index off the end of fork number or chunk  
entry arrays, potentially resulting in a crash.  
  
Reported-by: oxsignal <awo@kakao.com> (chunk sizes)  
Reported-by: Robert Haas <rhaas@postgresql.org> (fork numbers)  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: http://postgr.es/m/CA+TgmoYP8RKoBGosS7C6Fdr-GNCfyz_W1zmK=Tx1Fe0ZvzGh0g@mail.gmail.com  
Backpatch-through: 17  

M src/common/blkreftable.c

Fix argument names in pg_clear_attribute_stats() errors

commit   : 11ed011ae22a620b01a43634b5eea2f9af5c709c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 15 Jul 2026 21:22:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 15 Jul 2026 21:22:38 +0900    

Click here for diff

pg_clear_attribute_stats() checks its required arguments manually  
because the function is not strict. Previously, when schemaname or  
relname was passed as NULL, the error incorrectly reported the  
argument name as "relation" in both cases:  
  
    ERROR:  argument "relation" must not be null  
  
This was misleading, especially for schemaname, and inconsistent with  
the function's SQL-visible argument names.  
  
The cause is that cleararginfo[] in attribute_stats.c used  
"relation" for both the schema-name and relation-name arguments.  
  
This commit fixes the issue by using "schemaname" and "relname" instead,  
matching the function's declared argument names so that the error reports  
the correct argument name.  
  
Backpatch to v18, where pg_clear_attribute_stats() was introduced.  
  
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/4bf66c5e-8dd7-4ef3-8691-db67ecff6f16@tantorlabs.com  
Backpatch-through: 18  

M src/backend/statistics/attribute_stats.c

Reject concurrent sequence refreshes.

commit   : f38afa4abb04e85530c94b88daf11c089375daca    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 15 Jul 2026 15:40:36 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 15 Jul 2026 15:40:36 +0530    

Click here for diff

'ALTER SUBSCRIPTION ... REFRESH SEQUENCES' can race with an already  
running sequence synchronization worker. If a second refresh request  
resets the synchronization state while the worker has already fetched  
sequence values from the publisher but has not yet applied them to the  
subscriber, the worker can overwrite the subscriber with stale values  
and mark the synchronization as complete.  
  
Avoid this race by rejecting 'ALTER SUBSCRIPTION ... REFRESH SEQUENCES'  
when a sequence synchronization worker is already running for the  
subscription. The command reports an error asking the user to rerun it  
after the current synchronization completes.  
  
Also add a wait for the re-added 'regress_s4' sequence to finish  
synchronizing in 036_sequences.pl, so the subsequent test does not race  
against its sequencesync worker.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>  
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19, where it was introduced  
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com  

M src/backend/commands/subscriptioncmds.c
M src/test/subscription/t/036_sequences.pl

Add assertion about ssize_t narrowing in AIO code

commit   : 01f78a84bf5aca4c00fe1168381830aca6f1b873    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 10:58:13 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 10:58:13 +0200    

Click here for diff

The result from pg_preadv() or pg_pwritev(), which is of type ssize_t,  
is assigned to PgAioHandle.result, which is of type int.  This should  
be ok because the maximum result is limited by PG_IOV_MAX times  
BLCKSZ.  Add an assertion and a code comment to explain and check  
this.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/backend/storage/aio/aio_io.c

Clean up write() return type

commit   : 1f8c504e3086cf70a1538038b63b045de5df6a9b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 10:58:13 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 10:58:13 +0200    

Click here for diff

and analogously for pg_pwrite() and FileWrite()  
  
Be sure to store the return value in a variable of type ssize_t, not  
int.  
  
Some callers of FileWrite() did not have a separate error message for  
a short write.  This is okay in practice because FileWriteV() sets  
ENOSPC for all non-error returns, so you'll get a reasonable error  
message either way.  But callers handled this inconsistently, and this  
behavior isn't really prominently documented and commit 871fe4917e1  
seems to frown upon it, so it seems better to make all callers handle  
this consistently by adding the separate error message.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/backend/access/heap/rewriteheap.c
M src/backend/access/transam/timeline.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xlog.c
M src/backend/backup/basebackup_server.c
M src/backend/commands/dbcommands.c
M src/backend/libpq/be-fsstubs.c
M src/backend/postmaster/fork_process.c
M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/backend/replication/walreceiver.c
M src/backend/storage/file/buffile.c
M src/backend/storage/ipc/waiteventset.c
M src/backend/storage/smgr/md.c
M src/backend/utils/error/elog.c
M src/backend/utils/init/miscinit.c
M src/backend/utils/probes.d
M src/bin/pg_basebackup/pg_recvlogical.c
M src/bin/pg_basebackup/receivelog.c
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_combinebackup/backup_label.c
M src/bin/pg_combinebackup/copy_file.c
M src/bin/pg_combinebackup/reconstruct.c
M src/bin/pg_combinebackup/write_manifest.c
M src/bin/pg_dump/parallel.c
M src/bin/pg_test_fsync/pg_test_fsync.c
M src/fe_utils/cancel.c
M src/include/access/timeline.h
M src/include/replication/walreceiver.h
M src/interfaces/libpq/fe-lobj.c
M src/test/examples/testlo.c
M src/test/examples/testlo64.c

Clean up read() return type

commit   : ca326e903df4b2efcc7b9090abc4d1a9c27c3088    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 09:43:03 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 09:43:03 +0200    

Click here for diff

and analogously for pg_pread() and FileRead()  
  
Be sure to store the return value in a variable of type ssize_t, not  
int.  
  
Also make the error messages for short reads consistent.  They should  
always be like "read %zd of %zu".  Appearance of other placeholders  
indicates the types are probably wrong (although in some cases some  
casts are added to make macros have the right type and keep the  
strings consistent, and it some cases it's left as "%zu of %zu", which  
is close enough).  
  
In several cases, the input length is derived from struct stat  
st_size, which has type off_t, which is neither size_t nor ssize_t.  
To keep the type handling clearer, this introduces intermediate  
variables in these cases.  
  
In SendTimeLineHistory() in walsender.c, we need to adjust the logic a  
bit to over underflow wrap if we end up reading more from the file  
than expected.  This is believed to be a theoretical problem only.  
Alternatively, we could treat this as an error.  Note that the  
previous code would have processed the extra data but only up to a  
full block, which seems wrong in any case.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M contrib/basic_archive/basic_archive.c
M src/backend/access/transam/timeline.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogreader.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/access/transam/xlogutils.c
M src/backend/libpq/be-fsstubs.c
M src/backend/postmaster/syslogger.c
M src/backend/replication/logical/origin.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/replication/logical/snapbuild.c
M src/backend/replication/slot.c
M src/backend/replication/walsender.c
M src/backend/storage/file/buffile.c
M src/backend/storage/file/copydir.c
M src/backend/storage/ipc/waiteventset.c
M src/backend/storage/smgr/md.c
M src/backend/utils/cache/relmapper.c
M src/backend/utils/init/miscinit.c
M src/backend/utils/probes.d
M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_basebackup/pg_receivewal.c
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_combinebackup/load_manifest.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_combinebackup/reconstruct.c
M src/bin/pg_ctl/pg_ctl.c
M src/bin/pg_resetwal/pg_resetwal.c
M src/bin/pg_rewind/file_ops.c
M src/bin/pg_rewind/parsexlog.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/pg_waldump.c
M src/common/controldata_utils.c
M src/include/access/xlogreader.h
M src/interfaces/libpq/fe-lobj.c
M src/test/examples/testlo.c
M src/test/examples/testlo64.c

Clean up secure_read()/secure_write() return type

commit   : 7d45a6dc19743d999f5c83c95ad144a0f2eb6745    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 07:59:42 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 15 Jul 2026 07:59:42 +0200    

Click here for diff

The return type is ssize_t, not int, but some callers didn't handle  
this properly.  
  
The BIO callbacks are constrained by the OpenSSL API, so they take int  
for the length and return int.  This is safe, since the return value  
can't be greater than the input length.  To make it more clear that  
this is intentional, cast the result of the  
secure_read()/secure_write() call to int explicitly.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

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

Rework pgstat_write_statsfile() in combination with to_serialized_data

commit   : 572c3b2ddf8c90303d57bf33add4dcbf1b30b866    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Jul 2026 10:34:19 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Jul 2026 10:34:19 +0900    

Click here for diff

Contrary to the from_serialized_data callback used by the pgstats reads  
at startup, the to_serialized_data callback used for the pgstats writes  
matched with pgstat_write_statsfile(), by not returning a boolean  
status, expecting a ferror() failure to deal with the discard of the  
stats file should an error happen while writing the stats.  This was  
slightly confusing designed this way.  
  
Things are changed in this commit with:  
- to_serialized_data now returns a boolean status on a write failure.  
pgstat_write_statsfile() detects that and switches to failure mode  
instead of continuing to process the entries to write, speeding up the  
shutdown.  
- pgstat_write_statsfile() now uses STATS_DISCARD if a failure happens,  
to let the registered callbacks directly know that something is wrong,  
and that things need to be cleaned up.  This gives a better error path  
detection for custom stats kinds.  For example, they do not have to rely  
solely on the expectation of an ferror() for an auxiliary file.  
  
This new set of behaviors matches with what is already done in  
pgstat_read_statsfile() for the finish() callback (DISCARD on failure,  
READ on success) and the from_serialized_data with a status returned.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0sMgOvuhpb2P=KSJOjgjC6AfUu+GYcu9mHar-y_Xtd=Pg@mail.gmail.com  
Backpatch-through: 19  

M src/backend/utils/activity/pgstat.c
M src/include/utils/pgstat_internal.h
M src/test/modules/test_custom_stats/test_custom_var_stats.c

Include check on polpermissive relcache for policies

commit   : 8c551aab156d45f0626a64c43fcdeba1a40ead0d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Jul 2026 10:03:35 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Jul 2026 10:03:35 +0900    

Click here for diff

equalPolicy() is used in the relation cache to check if two policy  
definitions are equivalent, but missed to check for polpermissive.  
  
ALTER POLICY cannot switch a policy to be PERMISSIVE or RESTRICTIVE, so  
this would need a dropped and then re-created policy, which would  
trigger a relcache invalidation.  Anyway, there is no harm in being  
consistent in the check, and if one decides to add an ALTER POLICY to  
switch PERMISSIVE or RESTRICTIVE, we would be silently in trouble.  
  
Author: Andreas Lind <andreaslindpetersen@gmail.com>  
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Discussion: https://postgr.es/m/CAMxA3rv1CS6R7JR5ojz-3CmCEnZEFrqu+XXTnGbLRWrjJRH7sA@mail.gmail.com  
Backpatch-through: 14  

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

Strip removed-relation references from PHVs in join clauses

commit   : d68576bcfc7227d94c4391a3c34aadb8dbf8a3c7    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 15 Jul 2026 09:20:35 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 15 Jul 2026 09:20:35 +0900    

Click here for diff

Commit 9a60f295b stripped the stale PlaceHolderVars left behind by  
left-join removal from the surviving rels' baserestrictinfo and from  
EquivalenceClass member expressions, but it overlooked join clauses.  
A PlaceHolderVar embedded in a join clause can likewise retain the  
removed rel and join in its phrels, since remove_rel_from_query()  
fixes up the RestrictInfo's own relid sets but not the PHVs inside its  
expression.  
  
As before, this is normally harmless, because later processing  
consults those relid sets rather than the embedded PHVs.  However, a  
restriction clause derived from such an OR join clause inherits the  
stale PlaceHolderVar, and when the derived clause is translated for an  
appendrel child, pull_varnos() recomputes its relids and folds the  
removed relation back in.  The rebuilt clause then references a  
no-longer-existent relation, tripping an assertion during path  
generation.  
  
Fix by also stripping the removed relation from the PlaceHolderVars in  
the surviving rels' join clauses, including the sub-clauses of any OR  
clause.  
  
Like 9a60f295b, this is only reachable on v18 and later, where  
match_index_to_operand() began ignoring PlaceHolderVars.  
  
Author: Arne Roland <arne.roland@malkut.net>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/27a44087-3d65-473e-8d88-7c12228e0d7e@malkut.net  
Backpatch-through: 18  

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

Revert "Rename routines for write/read of pgstats file"

commit   : 381b3cfe2be02aa114ef7a28c4ec24feaf377c63    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Jul 2026 08:05:03 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 15 Jul 2026 08:05:03 +0900    

Click here for diff

This reverts commit ed823da1289, that has made pgstat_write_chunk() and  
pgstat_read_chunk() available for public use.  These routines do not  
have a symmetric API definition across reads and writes, with the write  
part returning a void status, deferring an error detection once all the  
stats entries have been processed with an ferror(), and the read part  
returning a boolean status.  
  
These routines are just tiny wrappers around fread() and fwrite(), and  
extensions can just define they own routines instead of relying on the  
same facilities as the core pgstat.c.  This commit removes their  
declaration from the public headers, to reduce the confusion.  
test_custom_stats is updated to use its own read/write routines.  
Perhaps something better could be designed in the future; trying to do  
so for v19 is not feasable during beta.  
  
Reported-by: Peter Eisentraut <peter@eisentraut.org>  
Author: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/a4a8e9af-3eaf-4bbf-9b21-21620f3fc434@eisentraut.org  
Backpatch-through: 19  

M src/backend/utils/activity/pgstat.c
M src/include/utils/pgstat_internal.h
M src/test/modules/test_custom_stats/test_custom_var_stats.c

postgres_fdw: don't push down non-relabeling ArrayCoerceExpr

commit   : e5354459383536a9644c4b0c8c26df0fcacae5f3    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 01:39:33 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 01:39:33 +0300    

Click here for diff

Commit 62c3b4cd9ddc taught postgres_fdw to push down ArrayCoerceExpr, but  
foreign_expr_walker() only recursed into the input array expression and  
never examined elemexpr, the per-element conversion that gives the  
coercion its semantics.  deparseArrayCoerceExpr() then shipped a bare  
"arg::resulttype" cast, or nothing at all for an implicit-format  
coercion, leaving the remote server to re-resolve the element conversion  
against its own catalogs and session state.  
  
This produced wrong results or remote errors whenever the element  
conversion was not a plain relabeling, and it was inconsistent with how  
postgres_fdw treats the equivalent scalar coercions.  An ArrayCoerceExpr  
was shipped even when its elemexpr was a cast function (whose  
shippability was never checked), a CoerceViaIO (e.g. float8out or  
byteaout, which depend on extra_float_digits / bytea_output that  
postgres_fdw sets differently on the remote session), or a  
CoerceToDomain (which pushes domain enforcement to the remote catalog).  
By contrast, a scalar CoerceViaIO is never shipped, and a scalar cast  
function is shipped only when it is shippable.  
  
Restrict pushdown to element coercions that are a plain relabeling, that  
is, elemexpr is a RelabelType or a bare CaseTestExpr.  Any other element  
coercion is now evaluated locally.  This keeps the common  
binary-coercible case pushed down, including "col = ANY($1)" with a  
varchar[]-to-text[] relabeling, which is the case 62c3b4cd9ddc set out to  
optimize.  
  
Pushing down shippable element cast functions, to reach parity with the  
scalar case, is left out here for simplicity.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260711024234.43.noahmisch%40microsoft.com  
Backpatch-through: 19  

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

Remove unreachable error check in JSON_TABLE plan transform

commit   : 9ee5241d02442911ffec9a0ce35327a0fea4a5c1    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:48:07 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:48:07 +0300    

Click here for diff

transformJsonTableNestedColumns() looked up the nested column named by a  
JSON_TABLE PLAN node and raised "invalid JSON_TABLE plan clause / PATH  
name was %s not found in nested columns list" if none was found.  That  
lookup cannot fail: validateJsonTableChildPlan() runs first, at every  
plan level, and already matches the plan's sibling path names one-to-one  
against the nested columns (reporting any uncovered nested path or any  
extra or duplicate sibling node).  The check has been unreachable since  
the PLAN clause code was first written.  
  
Replace it with an Assert documenting the invariant, which also removes  
a user-facing message that could never be emitted.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv5_9%3DzgA_Y7aoFp-%2BQSeh0kx4dfbAas9Wx%3DyrweQSqa6Q%40mail.gmail.com  

M src/backend/parser/parse_jsontable.c

Avoid redundant re-evaluation of JSON_TABLE nested paths

commit   : 6d8fd5a88183a65e77308aff374ebc239c44c6af    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:47:54 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:47:54 +0300    

Click here for diff

86ab7f4c721d makes JSON_TABLE with a NESTED PATH re-ran the nested path's  
jsonpath expression several times for each parent row.  That makes such  
queries significantly slower as the nested arrays grew, even without a PLAN  
clause.  
  
Two leftovers from the plan/join executor rework were responsible.  
JsonTablePlanScanNextRow() still reset and advanced the nested plan  
itself, although JsonTablePlanNextRow() now does that; and  
JsonTableResetNestedPlan() eagerly called JsonTableResetRowPattern()  
(which evaluates the path) in addition to setting the reset flag that  
makes JsonTablePlanNextRow() evaluate it again.  Together these caused  
the nested path to be evaluated multiple times per parent row.  
  
Reduce JsonTablePlanScanNextRow() to advancing its own row pattern  
iterator, and have JsonTableResetNestedPlan() only reset the transient  
scan state (so a not-yet-advanced sibling still reads as NULL) while  
deferring the actual path evaluation to the reset flag.  The nested path  
is now evaluated exactly once per parent row, as before the PLAN clause  
feature; results are unchanged and are covered by the existing tests.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv5U94KD4C%2BLhAPYcCeGvs1xBMngcS5oEkZHN9YWwXUHsA%40mail.gmail.com  

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

Fix and polish JSON_TABLE documentation

commit   : 4a82912bb2a2bc757142eca48f0fded1817a9a7c    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:47:33 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:47:33 +0300    

Click here for diff

Correct the JSON_TABLE synopsis to place the ON ERROR clause after the  
PLAN clause, matching the grammar (the previous order could not be  
typed).  Replace a dangling reference to json_path_specification with  
path_expression, the term the synopsis actually defines.  Mark up the  
PLAN DEFAULT keywords with <literal> and fix a couple of wording issues.  
Also list OUTER before INNER consistently, including in the parent/child  
join description, where OUTER is the default.  
  
Author: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv5PGAFmAEpbhKQz8wppoOOTHfo-=LJb2sAB3974-9QtOw@mail.gmail.com  

M doc/src/sgml/func/func-json.sgml

Make JSON_TABLE generated path names avoid collisions

commit   : cd5fd08be7ec1cef1a4c34791ce743954c2b2293    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:47:16 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:47:16 +0300    

Click here for diff

generateJsonTablePathName() produced names of the form  
"json_table_path_N" in the same namespace as user-supplied path and  
column names, without checking whether the name was already in use.  
When an unnamed NESTED path's generated name happened to match a  
user-supplied path name that a PLAN clause referenced, two sibling paths  
matched the same plan entry and one of them, together with its columns,  
was silently dropped from the output.  
  
Bump the counter until the generated name is unused, so a generated name  
can no longer coincide with a user-supplied one.  The still-uncovered  
path is then correctly reported as not found in the plan.  
  
The row pattern (root) path is named before the user-supplied column and  
path names are collected, so when it is left unnamed its generated name  
could not avoid them either, and a user column or path named like a  
generated name, e.g.  
  
    SELECT * FROM JSON_TABLE(jsonb '1', '$'  
                             COLUMNS (json_table_path_0 int PATH '$')) jt;  
  
was rejected with a bogus "duplicate JSON_TABLE column or path name"  
error.  Collect the user-supplied names first and generate the row  
pattern path's name afterwards, so that it avoids all of them.  An  
explicit root path name is still seeded into the namespace, so a column  
duplicating it is still correctly rejected.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv7aZGSExnbjJRw8eKkoXbu34TdoKLLA2gPye3aHjO5OSA@mail.gmail.com  
Discussion: https://postgr.es/m/CAA-aLv5U94KD4C%2BLhAPYcCeGvs1xBMngcS5oEkZHN9YWwXUHsA%40mail.gmail.com  

M src/backend/parser/parse_jsontable.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

Fix JSON_TABLE PLAN deparse to keep parentheses around nested joins

commit   : 160ef2751b524cbc797e59642543790c4a8132ec    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:46:56 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:46:56 +0300    

Click here for diff

get_json_table_plan() parenthesized the child of a parent/child  
(OUTER/INNER) plan only when that child was a sibling (UNION/CROSS)  
join, not when it was itself a parent/child join.  A plan such as  
PLAN (p0 OUTER (p1 INNER p11)) was therefore deparsed as  
PLAN (p0 OUTER p1 INNER p11), which does not parse back to the same  
plan tree -- a dump/restore hazard.  Parenthesize the child whenever it  
is not a bare path name, matching the logic already used for the  
operands of sibling joins.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv7aZGSExnbjJRw8eKkoXbu34TdoKLLA2gPye3aHjO5OSA@mail.gmail.com  

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

Revert cascading of JSON_TABLE's ON ERROR

commit   : af6fad879fbf9b542cfde05c52695c9dffa6bb47    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:46:40 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 15 Jul 2026 00:46:40 +0300    

Click here for diff

86ab7f4c721d commit made the table-level ON ERROR clause serve as the default  
ON ERROR for columns lacking their own, so that a top-level ERROR ON ERROR  
turned per-column evaluation errors into hard errors.  
  
The SQL standard does mandate this cascade, but introducing it should be  
a deliberate, separately-documented change, so restore the previous  
behavior for now.  This also reverts the paired ruleutils.c logic that  
deparsed a column's behavior against an ERROR default: that dropped an  
explicit ERROR ON EMPTY from a dumped view, and otherwise emitted a  
redundant NULL ON EMPTY.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv7aZGSExnbjJRw8eKkoXbu34TdoKLLA2gPye3aHjO5OSA@mail.gmail.com  

M src/backend/parser/parse_jsontable.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

Replace __builtin_types_compatible_p with _Generic

commit   : d15a6bc2e16d4b330d6d455e41ce1ab3395d8e03    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 14 Jul 2026 10:28:04 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 14 Jul 2026 10:28:04 +0200    

Click here for diff

_Generic is the C11 standard equivalent (and superset) of  
__builtin_types_compatible_p, so by replacing the latter with the  
former, we can now rely on this working on all compilers, instead of  
previously just with GCC-compatible ones.  And we can drop a configure  
test.  
  
This affects StaticAssertVariableIsOfType() and  
StaticAssertVariableIsOfTypeMacro() and indirectly unconstify() and  
unvolatize().  
  
Neither _Generic nor __builtin_types_compatible_p works in C++, so  
this does not change that, but this adds an explicit code comment  
about that.  
  
There are some subtle behavior changes, but these do not affect cases  
that are in use or likely to be useful.  _Generic does lvalue  
conversion on the controlling expression, which means it drops  
top-level qualifiers and converts arrays to pointers.  
__builtin_types_compatible_p on the other hand, supports arrays and  
just ignores qualifiers.  So before, StaticAssertVariableIsOfType(x,  
const int) might have worked, but now it does not.  (But note that it  
would previously have succeeded even if x was a non-const int, so this  
usage would always have been dubious.)  Also,  
StaticAssertVariableIsOfType(y, char[]) would have worked, but now you  
need to write char *.  (But this is not backward compatible, because  
char * would previously not have succeeded.)  Similarly, unconstify of  
non-pointers, like unconstify(const int, x) would previously have  
worked, but this was just by accident and never useful (you can just  
assign directly, without a cast), and the C++ implementation rejects  
non-pointers anyway.  Some comments are added to explain this a bit.  
There are no current uses affected by this.  
  
Note that even though we have required C11 since f5e0186f865, we have  
not made use of _Generic until now (except in an MSVC-specific case in  
commit 59c2f03d1ec).  This now raises the effective compiler  
requirement on the trailing edge slightly from GCC 4.8 to GCC 4.9.  
This in turn means that we effectively drop support for RHEL 7.  
  
Author: Peter Eisentraut <peter@eisentraut.org>  
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>  
Co-authored-by: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN+Lq341V7QL775DA@mail.gmail.com  

M config/c-compiler.m4
M configure
M configure.ac
M meson.build
M src/include/c.h
M src/include/pg_config.h.in

Add recovery test for missing redo segment with backup_label

commit   : 8f71f64deee6747ad9dea18819018b25424d61e5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 14 Jul 2026 08:00:46 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 14 Jul 2026 08:00:46 +0900    

Click here for diff

This commit adds a test case for early startup where a backup_label file  
uses a checkpoint LSN and a redo LSN located in two different segments,  
where the segment of the redo LSN is missing.  This code has never been  
covered, and is complex enough that a test case is going to be useful in  
the long-term.  
  
Nitin has proposed a more complex approach than what is added by this  
commit, by forcing a reuse of the injection points to produce a split  
between redo and checkpoint.  This commit relies on the checkpoint and  
redo LSNs generated by the first steps of the test, combined with a  
generated backup_label, making the whole cheaper.  
  
Author: Nitin Jadhav <nitinjadhavpostgres@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAMm1aWZ9Tv=Wrx52_2Ppw+6ULf_twRZuQm=ZWLA_a-kXWykHkQ@mail.gmail.com  

M src/test/recovery/t/050_redo_segment_missing.pl

Make blkreftable API use size_t/ssize_t consistently

commit   : 7b87f08e8778c2d38c95e3808419e2d18c55c672    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    

Click here for diff

It was using int for the input and output length, where size_t or  
ssize_t would be more appropriate.  It might not matter in practice,  
but it makes the APIs consistent at all levels.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/backend/backup/walsummary.c
M src/bin/pg_walsummary/pg_walsummary.c
M src/common/blkreftable.c
M src/include/backup/walsummary.h
M src/include/common/blkreftable.h

Clean up copy_file_range() return type

commit   : 1ae87df63ff693a91fbcb968850103a5a5d8cd96    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    

Click here for diff

The return type is ssize_t, not int.  Fix that in one instance; the  
others were already okay.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/bin/pg_combinebackup/reconstruct.c

commit   : 302222eddc3967d11c11708a59bdafd6d51da556    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    

Click here for diff

The return type of readlink() per POSIX is ssize_t, but most existing  
callers use int, so fix that.  Also fix the return type of the Windows  
implementation to match.  
  
In _pglstat64(), we neglected to handle the case where the output  
buffer is not large enough and the result would be truncated.  This  
case actually can't happen, because the Windows pgreadlink()  
implementation doesn't ever return that case, but adding this seems  
good for consistency with _pgstat64(), which already had this check,  
and in case pgreadlink() ever changes in this regard.  
  
Some callers of readlink(), in particular _pglstat64(), assume that  
errno == EINVAL means that the file was not a symlink.  But Windows  
pgreadlink() also sets EINVAL in other cases, in particular if the  
buffer was too small.  This could result in incorrect behavior, so  
pick a different errno.  (There might be other cases where EINVAL is  
set inappropriately, but they are outside the theme of this patch.)  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/backend/access/transam/xlog.c
M src/backend/backup/basebackup.c
M src/backend/catalog/pg_tablespace.c
M src/bin/initdb/findtimezone.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_rewind/file_ops.c
M src/include/port.h
M src/include/port/win32_port.h
M src/port/dirmod.c
M src/port/win32stat.c

Move Windows ssize_t definition earlier

commit   : 8ef9896e61e7699a676f7dca33636d0533b38edb    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    

Click here for diff

It needs to be much earlier in win32_port.h so that declarations in  
that file can also use it.  To be used by a subsequent patch.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/include/port/win32_port.h

Some const qualifications added in passing

commit   : 7f77b2a89bd4788b6bd686ba63138f51302d9839    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 13 Jul 2026 11:01:36 +0200    

Click here for diff

These are some cases in the vicinity of the patches to improve the  
size_t/ssize_t use with POSIX file system APIs.  For example, the  
input buffers for write operations or the file names passed for error  
reporting can be const.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/f9aab072-0078-49e4-ab93-3b08086a4406@eisentraut.org  

M src/backend/access/transam/timeline.c
M src/backend/access/transam/twophase.c
M src/bin/pg_basebackup/receivelog.c
M src/bin/pg_combinebackup/reconstruct.c
M src/include/access/timeline.h

Don't show tables redundantly when their schema is published.

commit   : 1863452a4bfecfefc51336ecfc78837a164fbb10    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 13 Jul 2026 09:27:47 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 13 Jul 2026 09:27:47 +0530    

Click here for diff

A table published both explicitly and through its schema (FOR TABLES IN  
SCHEMA) was listed twice by \dRp+ and \d.  Since publishing a schema  
publishes its tables in full, the explicit entry's row filter has no  
effect; suppress it when the same publication also publishes the table's  
schema.  
  
Author: Peter Smith <smithpb2250@gmail.com>  
Co-author: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>  
Reviewed-by: vignesh C <vignesh21@gmail.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Discussion: https://postgr.es/m/CAHut%2BPvSOmRrQX%2BVrFYHtFipV9hM%3Dp99FeOwYCzkuU2BOaLu7Q%40mail.gmail.com  

M src/bin/psql/describe.c
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql

Add recovery/startup test with backup_label and missing checkpoint segment

commit   : 2b8598a2b045b172a8f726ba130e9eb764dc0688    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 13 Jul 2026 09:19:20 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 13 Jul 2026 09:19:20 +0900    

Click here for diff

This test is able to trigger the following failure at the beginning of  
recovery, that was not covered yet:  
FATAL:  could not locate required checkpoint record at %X/%X  
  
Note that the backup used for the node created has its pg_wal/ removed,  
which is why the segment expected is missing.  
  
Extracted from a larger patch by the same author.  
  
Author: Nitin Jadhav <nitinjadhavpostgres@gmail.com>  
Discussion: https://postgr.es/m/CAMm1aWZ9Tv=Wrx52_2Ppw+6ULf_twRZuQm=ZWLA_a-kXWykHkQ@mail.gmail.com  

M src/test/recovery/t/042_low_level_backup.pl

Shorten pg_attribute_always_inline to pg_always_inline

commit   : 1c4b1de888559a47df599dcef356ea7fbf96fd0c    
  
author   : Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sat, 11 Jul 2026 15:14:50 +0200    
  
committer: Tomas Vondra <tomas.vondra@postgresql.org>    
date     : Sat, 11 Jul 2026 15:14:50 +0200    

Click here for diff

The pg_attribute_always_inline macro name is so long it forces pgindent  
to format the code in strange ways. Which may incentivize patch authors  
to either structure the code in strange ways (e.g. reorder prototypes),  
use shorter names, etc. Neither is very desirable for code readability.  
  
This shortens the name by removing the _attribute_ part. It also makes  
it more consistent with pg_noinline, which does not have the _attribute_  
part either.  
  
Backpatched to all supported branches, to prevent conflicts when  
backpatching other fixes. The backbranches however keep both the old and  
new macro name, so that existing code keeps working.  
  
Author: Andres Freund <andres@anarazel.de>  
Reviewed-by: Peter Geoghegan <pg@bowt.ie>  
Reviewed-by: Tomas Vondra <tomas@vondra.me>  
Discussion: https://postgr.es/m/bqqdehahpoa36igpictuqyn2s2mexk3t3ehidh2ffd2slb35e5@rzgksuiszgbg  
Backpatch-through: 14  

M src/backend/access/heap/heapam.c
M src/backend/access/transam/xlog.c
M src/backend/commands/copyfromparse.c
M src/backend/commands/copyto.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execTuples.c
M src/backend/executor/nodeHashjoin.c
M src/backend/executor/nodeSeqscan.c
M src/backend/nodes/queryjumblefuncs.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/utils/adt/json.c
M src/backend/utils/cache/catcache.c
M src/include/c.h
M src/include/executor/execScan.h
M src/include/portability/instr_time.h

Fix for loop variables used with lengthof

commit   : 5f14f82280db4b0e49d774362854c9d362106484    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 11 Jul 2026 14:38:33 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 11 Jul 2026 14:38:33 +0200    

Click here for diff

lengthof returns type size_t, but most for loops used int as a loop  
variable.  Fix that.  This avoids possible warnings about  
signed/unsigned mismatches under higher warning levels.  (The compiler  
will likely optimize these loops beyond recognition, so this shouldn't  
affect the generated code much.)  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/d639aede-209f-412b-927a-d38d4848b370%40eisentraut.org  

M contrib/dblink/dblink.c
M src/backend/access/heap/heapam.c
M src/backend/access/transam/parallel.c
M src/backend/bootstrap/bootstrap.c
M src/backend/catalog/objectaddress.c
M src/backend/commands/typecmds.c
M src/backend/main/main.c
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/replication/logical/conflict.c
M src/backend/utils/adt/amutils.c
M src/backend/utils/adt/jsonb.c
M src/backend/utils/adt/jsonpath_exec.c
M src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
M src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
M src/bin/initdb/initdb.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pgbench/pgbench.c
M src/bin/psql/command.c
M src/bin/psql/tab-complete.in.c
M src/common/unicode_norm.c
M src/interfaces/libpq/fe-auth.c
M src/interfaces/libpq/fe-connect.c
M src/pl/plpgsql/src/pl_scanner.c
M src/port/pg_localeconv_r.c
M src/port/win32error.c
M src/port/win32ntdll.c
M src/test/modules/oauth_validator/validator.c
M src/test/modules/test_escape/test_escape.c
M src/test/modules/test_integerset/test_integerset.c
M src/test/modules/test_radixtree/test_radixtree.c
M src/test/regress/regress.c
M src/timezone/zic.c

Fix for loop variables

commit   : e615da8cb21b3745456da45197fa5dc620f19dab    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 11 Jul 2026 14:38:33 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 11 Jul 2026 14:38:33 +0200    

Click here for diff

A number of for loops used loop variables that did not match the type  
of the end condition.  This could lead to wraparound or  
signed/unsigned mismatches.  Probably none of these are a problem in  
practice, but it's fragile code.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/d639aede-209f-412b-927a-d38d4848b370%40eisentraut.org  

M contrib/pageinspect/fsmfuncs.c
M contrib/pageinspect/hashfuncs.c
M contrib/pg_logicalinspect/pg_logicalinspect.c
M contrib/pg_plan_advice/pgpa_identifier.c
M contrib/pg_plan_advice/pgpa_join.c
M contrib/pg_plan_advice/pgpa_output.c
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_trgm/trgm_gist.c
M src/backend/access/gin/ginget.c
M src/backend/access/gin/ginlogic.c
M src/backend/access/gin/ginscan.c
M src/backend/access/nbtree/nbtpage.c
M src/backend/access/rmgrdesc/logicalmsgdesc.c
M src/backend/executor/execCurrent.c
M src/backend/jit/llvm/llvmjit.c
M src/backend/lib/hyperloglog.c
M src/backend/parser/parse_relation.c
M src/backend/parser/parse_target.c
M src/backend/port/win32/socket.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/replication/logical/snapbuild.c
M src/backend/statistics/dependencies.c
M src/backend/statistics/mcv.c
M src/backend/statistics/mvdistinct.c
M src/backend/storage/aio/aio_init.c
M src/backend/storage/aio/method_io_uring.c
M src/backend/storage/file/fd.c
M src/backend/storage/ipc/shmem.c
M src/backend/storage/lmgr/lock.c
M src/backend/tsearch/spell.c
M src/backend/utils/adt/json.c
M src/backend/utils/adt/pg_dependencies.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/pg_locale_icu.c
M src/backend/utils/adt/pg_locale_libc.c
M src/backend/utils/adt/pg_ndistinct.c
M src/backend/utils/adt/selfuncs.c
M src/backend/utils/adt/tsgistidx.c
M src/backend/utils/adt/tsquery.c
M src/backend/utils/adt/tsquery_gist.c
M src/backend/utils/adt/varbit.c
M src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
M src/backend/utils/misc/injection_point.c
M src/backend/utils/misc/pg_config.c
M src/backend/utils/mmgr/dsa.c
M src/backend/utils/resowner/resowner.c
M src/backend/utils/time/snapmgr.c
M src/bin/pg_amcheck/pg_amcheck.c
M src/bin/pg_basebackup/pg_recvlogical.c
M src/bin/pg_combinebackup/reconstruct.c
M src/bin/pg_config/pg_config.c
M src/bin/pg_ctl/pg_ctl.c
M src/bin/pg_dump/dumputils.c
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/psql/crosstabview.c
M src/common/hmac.c
M src/common/unicode_case.c
M src/fe_utils/print.c
M src/include/lib/radixtree.h
M src/interfaces/ecpg/test/expected/sql-sqljson.c
M src/interfaces/ecpg/test/sql/sqljson.pgc
M src/interfaces/libpq-oauth/oauth-curl.c
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/win32.c
M src/test/modules/test_aio/test_aio.c
M src/test/modules/test_binaryheap/test_binaryheap.c
M src/test/modules/test_escape/test_escape.c
M src/test/modules/test_integerset/test_integerset.c
M src/test/modules/test_predtest/test_predtest.c
M src/test/modules/test_radixtree/test_radixtree.c

Update FSM after updating VM on-access

commit   : eed6c0d33e09c53e5861fa92e99318814c5862f7    
  
author   : Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 10 Jul 2026 18:10:23 -0400    
  
committer: Melanie Plageman <melanieplageman@gmail.com>    
date     : Fri, 10 Jul 2026 18:10:23 -0400    

Click here for diff

b46e1e54d078de allowed setting the VM while on-access pruning, but it  
neglected to update the freespace map. Once the page was all-visible,  
vacuum could skip it, leading to stale freespace map values and,  
effectively, bloat. Fix it by updating the FSM if we updated the VM.  
  
Author: Melanie Plageman <melanieplageman@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/flat/CAAKRu_b2StZrEC%3DHmW8LePuQbczyFRnfs8qTAJwn_%3DW76-y24w%40mail.gmail.com  
Backpatch-through: 19  

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

bufmgr: Fix order of operations in UnlockBufHdrExt

commit   : c787c952bc882626c66ec64b1d35a664902bfa8b    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Fri, 10 Jul 2026 13:25:08 -0400    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Fri, 10 Jul 2026 13:25:08 -0400    

Click here for diff

In c75ebc657ffc I (Andres) introduced UnlockBufHdrExt() which can set and  
clear bits in the buffer state using CAS. Unfortunately I added bits before  
subtracting them, which means that a bit that was both removed and set would  
remain unset.  Fix the order of operations.  
  
The only known case where that is a problem is that BM_IO_ERROR would not  
actually remain set.  
  
It's unfortunately not trivial to add a decent, race-free, test to verify that  
BM_IO_ERROR remains set. That's therefore left for the 20 cycle.  
  
Reported-by: Yura Sokolov <y.sokolov@postgrespro.ru>  
Discussion: https://postgr.es/m/ab0dcc9e-aba0-44e3-ac23-8d74c48888e6@postgrespro.ru  
Backpatch-through: 19, where c75ebc657ffc went in  

M src/include/storage/buf_internals.h

Don't lock tables in get_tables_to_repack()

commit   : c71d43025d7aaf12fe461ec635bd2eda220c9f4a    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 10 Jul 2026 16:10:36 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 10 Jul 2026 16:10:36 +0200    

Click here for diff

When doing a whole database repack, we build a list of tables to process  
taking a lock on each.  But because it's a regular transaction-scoped  
lock, it's automatically released immediately after building the list  
anyway, which makes it not very useful.  (Also, we have three ways to  
obtain a list of tables to repack, and only one of them acquired this  
lock.)  Remove that lock acquisition, as it's useless and inconsistent.  
  
We acquire a lock properly afterwards (and recheck that the table can  
still be repacked as indicated), so we don't need to do anything other  
than drop that initial lock acquisition and harden the code in  
repack_is_permitted_for_relation() against possible concurrent drops.  
This is similar to how vacuum does it in get_all_vacuum_rels().  
  
In order for this to work reliably, also change  
repack_is_permitted_for_relation() to cope with the possibility of the  
table going away partway through.  Similarly, in ExecRepack(), be  
prepared for what we believed to be a table or matview to now be  
something else, and skip it without erroring out, by changing  
try_table_open() to try_relation_open() and testing the relkind  
separately.  
  
While at it, replace one relation_close() call in get_tables_to_repack()  
with table_close() to match the table_open() that opened the catalog.  
  
Author: ChangAo Chen <cca5507@qq.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/tencent_9F290B256A3F52B66542F1140E32ECC64309@qq.com  

M src/backend/commands/repack.c

Fix data checksum processing for temp relations and dropped databases

commit   : 97a18c221b8a71c89a68870c0c0343759b41d290    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 22:34:24 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 22:34:24 +0900    

Click here for diff

When building the list of temporary relations to wait for, the code  
previously included temporary relations without storage, such as  
temporary views, even though they are irrelevant to checksum  
processing. As a result, enabling data checksums could wait for a  
long-lived session that owned only a temporary view.  
  
This commit fixes the issue by filtering temporary relations with storage  
only, matching the existing behavior for non-temporary relations.  
  
Also, when enabling data checksums online, the launcher assigns the  
first worker to process shared catalogs and prevents later workers from  
doing so. Previously, if that worker's database was dropped after it  
had been selected for processing but before checksum processing began,  
the worker failed without processing the shared catalogs, yet they were  
still marked as processed. As a result, later workers skipped them, and  
checksum enabling could complete successfully even though the shared  
catalogs had never been processed.  
  
This commit fixes the issue by marking shared catalogs as processed  
only after a worker completes successfully.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAHGQGwGDHAQw=bmpRzk+EmKzVtxZiD5YDurMUffBMwr6WXugQA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/postmaster/datachecksum_state.c

Fix data checksum progress counter initialization

commit   : e9810253f095f19aab899694f491a1a529f9eb4d    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 22:32:53 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 22:32:53 +0900    

Click here for diff

pg_stat_progress_data_checksums uses -1 as a sentinel value that is  
displayed as NULL for progress counters. However, after  
pgstat_progress_start_command() initialized all progress counters to  
zero, data checksum progress did not reset those counters to -1.  
As a result, some counters could incorrectly appear as zero instead  
of NULL. For example, workers could report zero database counters,  
and the disabling launcher could report zero relation and block counters.  
  
Also, blocks_done was not reset when a worker started processing  
a new relation fork. As a result, it could temporarily exceed blocks_total  
or report a stale value for an empty relation fork.  
  
Fix this by initializing the data checksum progress counters to -1  
when progress reporting starts for both launcher and worker processes.  
Also reset blocks_done together with blocks_total when starting each  
relation fork.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAHGQGwEOQyEzW2cqrHEzvwbcsAsuH8MEe7MMidFOFxECy0E1_Q@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/postmaster/datachecksum_state.c
M src/test/regress/expected/rules.out

postgres_fdw: Mark statistics import helpers as static

commit   : 701f021b680ec33a799022d31b574fbcd618a40f    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 20:36:36 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 20:36:36 +0900    

Click here for diff

The set_*_arg helper functions in postgres_fdw.c are declared  
static, but their definitions omitted the static keyword. Add it to  
make their file-local scope explicit and keep the declarations and  
definitions consistent.  
  
Also fix a couple of nearby comment typos.  
  
This is a followup to commit 54cd6fc8317.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGjcQ4SwHMUQ9P8UYQ7iLKL1QE3uLSdONToQ1MrzpUUoQ@mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/postgres_fdw.c
M src/backend/statistics/attribute_stats.c
M src/backend/statistics/relation_stats.c

Forbid FOR PORTION OF on views with INSTEAD OF triggers

commit   : dfce19c2300ab00a8c41386e49dfdd6a3c8edae9    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 10 Jul 2026 10:08:21 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 10 Jul 2026 10:08:21 +0200    

Click here for diff

Previously, an attempt to use these features together caused a crash.  
Oversight of commit 8e72d914c528.  
  
Tests are added also to show that the check for this should be in the  
rewriter, not the parser, as an earlier patch version suggested.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAJ7c6TME%2Bix6VRf-2TPnVTsj8qn_hy6sYAOmMhZEivwsu2wS6g%40mail.gmail.com  

M src/backend/rewrite/rewriteHandler.c
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/updatable_views.sql

postgres_fdw: Remove SPI from postgresImportForeignStatistics.

commit   : 54cd6fc83176d7c03abf95554aef26b0b24acc7d    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 10 Jul 2026 13:20:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Fri, 10 Jul 2026 13:20:00 +0900    

Click here for diff

Previously, this function imported remote statistics by executing SQL  
functions like pg_restore_relation_stats and pg_restore_attribute_stats  
via SPI (in read-write mode).  As the SQL functions take a schema name  
and a relation name as two separate arguments, rather than a single OID  
argument, if the containing schema was concurrently renamed, the  
callback function would throw an error like this:  
  
  ERROR: schema "foo" does not exist  
  
To fix, 1) provide new interface functions to import remote statistics  
that are directly callable from FDWs and take a single OID, and 2)  
modify the callback function to use the interface functions instead when  
importing remote statistics.  
  
For #1, this commit does a bit of refactoring to  
relation_statistics_update and attribute_statistics_update, which are  
the workhorse functions for pg_restore_relation_stats and  
pg_restore_attribute_stats respectively: since they also take a schema  
name and a relation name, separate the guts of them into new functions  
so that they take a single OID and are callable not only from the  
workhorse functions but from the interface functions introduced by #1.  
  
Oversight in commit 28972b6fc.  
  
Reported-by: Robert Haas <robertmhaas@gmail.com>  
Suggested-by: Robert Haas <robertmhaas@gmail.com>  
Author: Corey Huinker <corey.huinker@gmail.com>  
Co-authored-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/CA%2BTgmoYqMtWb4zLUkT98oFnEkJ%3DWz0Pw-ggDJrp9wnSXPzUaeQ%40mail.gmail.com  
Backpatch-through: 19  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/fdwhandler.sgml
M src/backend/statistics/attribute_stats.c
M src/backend/statistics/relation_stats.c
M src/include/statistics/statistics.h

Simplify truncate_query_log() callers

commit   : 5594f209c3eff6e478e1d6109094f14b59bd3dce    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 08:37:59 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 08:37:59 +0900    

Click here for diff

truncate_query_log() returns NULL when statement truncation is  
disabled or the supplied query does not need to be truncated. Therefore,  
callers do not need to check log_statement_max_length before calling  
it.  
  
Remove the redundant checks and let truncate_query_log() make the  
decision in one place. This simplifies the statement and duration  
logging code without changing its behavior.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwFOV+7nOdfoO=kfVH=-fRA9aQE1YcHHLYty3nfQ9rQ4RA@mail.gmail.com  

M src/backend/tcop/postgres.c

Improve log_statement_max_length truncation reporting

commit   : 999a8412bbabec4811195fee7e315c282c97f694    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 08:36:46 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 10 Jul 2026 08:36:46 +0900    

Click here for diff

log_statement_max_length limits the statement text logged by  
log_statement and duration logging. However, the prepared statement  
shown in the DETAIL message for EXECUTE was still logged in full,  
allowing very large prepared queries to bypass the limit.  
  
Apply the same truncation to the prepared statement text in  
errdetail_execute(), making the setting behave consistently across the  
main log message and its associated DETAIL output.  
  
Also append an ellipsis to truncated statement text so users can easily  
tell when truncation has occurred. With this change, a limit of zero  
logs only the ellipsis, indicating that the entire statement text was  
truncated.  
  
Finally, avoid scanning the entire query string just to determine  
whether truncation is needed. Use strnlen() with sufficient lookahead  
for multibyte character handling, then use pg_mbcliplen() to ensure  
truncation never splits a multibyte character.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwFOV+7nOdfoO=kfVH=-fRA9aQE1YcHHLYty3nfQ9rQ4RA@mail.gmail.com  

M doc/src/sgml/config.sgml
M src/backend/tcop/postgres.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/test/modules/test_misc/t/014_log_statement_max_length.pl

Bump catversion for JSON_TABLE PLAN clause

commit   : 21e958c303bc8f79627726f4f15a8428c6a22003    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 9 Jul 2026 22:23:26 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 9 Jul 2026 22:23:26 +0300    

Click here for diff

86ab7f4c721d misses catversion bump as it adds new fields to the existing  
nodes.  
  
Reported-by: Thom Brown <thom@linux.com>  
Discussion: https://postgr.es/m/CAA-aLv7aZGSExnbjJRw8eKkoXbu34TdoKLLA2gPye3aHjO5OSA%40mail.gmail.com  

M src/include/catalog/catversion.h

Remove WaitEventCustomCounterData.

commit   : 8f7af125e03739b66998a75840dedd943ec3624e    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 9 Jul 2026 11:09:53 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 9 Jul 2026 11:09:53 -0500    

Click here for diff

The spinlock is unnecessary because the counter is only ever  
accessed with WaitEventCustomLock held exclusively.  This commit  
removes the struct definition and converts WaitEventCustomCounter  
to a pointer to an integer in shared memory.  
  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/ak8MeTS9QBmz6DKt%40nathan  

M src/backend/utils/activity/wait_event.c
M src/tools/pgindent/typedefs.list

libpq: Make error checks in the new buffer draining code more robust

commit   : 17accbe0f4e8a9afd563a8e255fead45e5145de5    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 9 Jul 2026 18:34:27 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 9 Jul 2026 18:34:27 +0300    

Click here for diff

Check explicitly for pqsecure_read() returning an error. It shouldn't  
fail, and we would've caught it in the check for a short read, but  
better to be explicit so that the error message is more informative.  
We also shouldn't update 'inEnd' when the read fails, although that  
too is just pro forma as we will bail out and close the connection on  
error.  
  
Reported-by: Peter Eisentraut <peter@eisentraut.org>  
Discussion: https://www.postgresql.org/message-id/34844e8c-267c-4daf-b1e0-f26059a4a7d3@eisentraut.org  
Backpatch-through: 14  

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

ssl: Include limits.h to get INT_MAX when using LibreSSL

commit   : d293f03455b2db859249f9876e4b5ec24c95d11a    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 9 Jul 2026 18:34:24 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 9 Jul 2026 18:34:24 +0300    

Click here for diff

When compiling against OpenSSL, the <limits.h> header is indirectly  
included via openssl/ossl_typ.h from openssl/conf.h, but the LibreSSL  
version of ossl_typ.h does not include <limits.h> which cause compiler  
failure due to missing symbol (since ffd080d94fe).  Fix by explicitly  
including <limits.h>.  
  
Author: Daniel Gustafsson <dgustafsson@postgresql.org>  
Discussion: https://www.postgresql.org/message-id/6A9E7815-BD5A-4C31-A515-48159823406B@yesql.se  
Backpatch-through: 14  

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

Fix advertising autovacuum launcher's ProcNumber

commit   : dff789e555404571cc76097c1539e93dc7f2e3de    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 9 Jul 2026 15:14:19 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 9 Jul 2026 15:14:19 +0300    

Click here for diff

Autovacuum launcher is not an aux process, so it needs to be  
advertised in InitProcess() rather than InitAuxiliaryProcess()  
  
In the passing, also remove some now-unnecessary 'volatile' qualifiers  
left behind by the same commit.  
  
Reported-by: Thom Brown <thom@linux.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Author: Nathan Bossart <nathandbossart@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAA-aLv6UHXubNxmAjNH8PnyKKkaXePO1ggB15=iidNW08T4hSg@mail.gmail.com  

M src/backend/postmaster/checkpointer.c
M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h

JSON_TABLE PLAN clause

commit   : 86ab7f4c721d61282c058acc0b4aa0b3adf04410    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 9 Jul 2026 14:37:31 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 9 Jul 2026 14:37:31 +0300    

Click here for diff

This patch adds the PLAN clauses for JSON_TABLE, which allow the user  
to specify how data from nested paths are joined, allowing  
considerable freedom in shaping the tabular output of JSON_TABLE.  
PLAN DEFAULT allows the user to specify the global strategies when  
dealing with sibling or child nested paths. This is often sufficient  
to achieve the necessary goal, and is considerably simpler than the  
full PLAN clause, which allows the user to specify the strategy to be  
used for each named nested path.  
  
Path names may be attached to the row pattern and to each NESTED path  
using AS.  Unlike the SQL/JSON standard, which requires a name for every  
NESTED path when a PLAN clause is present, PostgreSQL does not require  
them and generates a name for any path left unnamed; a specific PLAN()  
can only reference paths by name, so unnamed paths it must mention are  
reported as not covered by the plan.  
  
Author: Nikita Malakhov <n.malakhov@postgrespro.ru>  
Co-authored-by: Nikita Glukhov <n.gluhov@postgrespro.ru>  
Co-authored-by: Teodor Sigaev <teodor@sigaev.ru>  
Co-authored-by: Oleg Bartunov <obartunov@gmail.com>  
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>  
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>  
Co-authored-by: Amit Langote <amitlangote09@gmail.com>  
Co-authored-by: Anton Melnikov <a.melnikov@postgrespro.ru>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>  
Reviewed-by: Andrew Alsup <bluesbreaker@gmail.com>  
Reviewed-by: Erik Rijkers <er@xs4all.nl>  
Reviewed-by: Zhihong Yu <zyu@yugabyte.com>  
Reviewed-by: Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: jian he <jian.universality@gmail.com>  
Reviewed-by: Vladlen Popolitov <v.popolitov@postgrespro.ru>  
Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru  
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de  
Discussion: https://postgr.es/m/abd9b83b-aa66-f230-3d6d-734817f0995d%40postgresql.org  
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com  
Discussion: https://postgr.es/m/CAN-LCVP7HXmGu-WcinsHvdKqMGEdv=1Y67H4U58F6Y=Q0M5GyQ@mail.gmail.com  

M doc/src/sgml/func/func-json.sgml
M src/backend/catalog/sql_features.txt
M src/backend/nodes/makefuncs.c
M src/backend/parser/gram.y
M src/backend/parser/parse_jsontable.c
M src/backend/utils/adt/jsonpath_exec.c
M src/backend/utils/adt/ruleutils.c
M src/include/nodes/makefuncs.h
M src/include/nodes/parsenodes.h
M src/include/nodes/primnodes.h
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql
M src/tools/pgindent/typedefs.list

Prohibit locking clauses on GRAPH_TABLE

commit   : 2e6578292a9184dcaae6c5abc235a26db9cb2973    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 9 Jul 2026 10:10:07 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 9 Jul 2026 10:10:07 +0200    

Click here for diff

Specifying a locking clause (FOR UPDATE/SHARE) that names a  
GRAPH_TABLE alias currently results in an unhelpful "unrecognized RTE  
type: 8" error.  This commit explicitly prohibits specifying a locking  
clause on a GRAPH_TABLE alias, raising a more user-friendly error  
instead.  
  
(Locking clause support for GRAPH_TABLE could be added as a separate  
feature in the future.)  
  
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcE9wp6nOEC3SCRQ90nrCO%3DQF%2BOZq1MG8Qc6hnusmogqw%40mail.gmail.com  

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

Fix outdated comment

commit   : 51ceb751eaed32950013a8084dd2ae2bf3ce465d    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 9 Jul 2026 09:53:18 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 9 Jul 2026 09:53:18 +0200    

Click here for diff

In transformLockingClause(), there was a comment that listed all the  
RTE kinds it did not want to process, but that list was already  
outdated about what RTE kinds actually exist.  Rather than keeping  
that up-to-date, just say "all other".  
  
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcE9wp6nOEC3SCRQ90nrCO%3DQF%2BOZq1MG8Qc6hnusmogqw%40mail.gmail.com  

M src/backend/parser/analyze.c

Reject incorrect range_bounds_histograms in stats import functions

commit   : df293aed46e3133df3b5b337f095e3ebed69fd79    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 9 Jul 2026 14:23:42 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 9 Jul 2026 14:23:42 +0900    

Click here for diff

pg_restore_attribute_stats() and pg_restore_extended_stats()  
(expressions) can handle a STATISTIC_KIND_BOUNDS_HISTOGRAM value, but  
did not check its shape when importing, especially regarding:  
- Empty ranges.  
- Unsorted elements.  
  
These properties are respected by ANALYZE in compute_range_stats(), when  
computing a histogram for a [multi]range, and by the planner when  
reading the data from the stats catalogs.  The effects of importing data  
with these properties depend on the compilation options:  
- A assertion would be hit, if enabled.  
- A non-sensical value that would make the load of the stats fail.  
- A failure is hit if an empty range is loaded.  
  
While the owner of the table or the one with MAINTAIN rights is  
responsible for the stats data inserted, buggy data makes little sense  
if their load is going to fail.  This commit adds a validation step to  
match what compute_range_stats() expects.  
  
This issue would be unlikely hit in practice, so no backpatch is done.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/CAON2xHNM809WLR_g0ymKgU-tWxtbyH1Xvh4fqzRqy9YP2A59pg@mail.gmail.com  

M src/backend/statistics/attribute_stats.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/statistics/stat_utils.c
M src/include/statistics/stat_utils.h
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql

Doc: Clarify sequence synchronization commands.

commit   : c1702cb513634878425e8b3f49dc1894d2aa781e    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 9 Jul 2026 08:09:07 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 9 Jul 2026 08:09:07 +0530    

Click here for diff

Explain more accurately how REFRESH SEQUENCES differs from REFRESH  
PUBLICATION in ALTER SUBSCRIPTION, and note that CREATE SUBSCRIPTION uses  
copy_data = true (the default) to copy initial sequence values.  
  
Author: Peter Smith <smithpb2250@gmail.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAHut+PtFkGvZNihGRDoghWNKMfJufEpR9+thbG_8qPQ7RyVN4w@mail.gmail.com  

M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/alter_subscription.sgml

Add an enable_groupagg GUC parameter

commit   : e01b23b84e4346c1941e2aad78e3d80a5498038d    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Thu, 9 Jul 2026 09:44:56 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Thu, 9 Jul 2026 09:44:56 +0900    

Click here for diff

We've long had enable_hashagg to discourage hashed aggregation, but  
there was no equivalent for grouping that works by reading presorted  
input.  That's handy when investigating planner cost misestimates, and  
as an escape hatch when a sorted grouping plan is chosen over a much  
cheaper hashed one.  
  
enable_groupagg (on by default) covers the GroupAggregate and Group  
nodes, the sort-based Unique step used for DISTINCT and semijoin  
unique-ification, and the sorted mode of SetOp.  It isn't a hard  
switch; it only bumps disabled_nodes, so plans with no other choice  
are still produced.  
  
Several regression and module tests had been setting enable_sort off,  
and one enable_indexscan off, only to force a hashed plan.  Use  
enable_groupagg there instead, where that was the real intent.  In  
union.sql this also lets us test the hashed UNION path, which we had  
no way to reach before.  
  
Author: Tatsuro Yamada <yamatattsu@gmail.com>  
Co-authored-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/CAOKkKFvYHSEsFazkrf9bRH14p-H27XMaqbZfRYjS6EHBruvZMQ@mail.gmail.com  

M contrib/hstore/expected/hstore.out
M contrib/hstore/sql/hstore.sql
M contrib/ltree/expected/ltree.out
M contrib/ltree/sql/ltree.sql
M doc/src/sgml/config.sgml
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/util/pathnode.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/include/optimizer/cost.h
M src/test/modules/injection_points/expected/hashagg.out
M src/test/modules/injection_points/sql/hashagg.sql
M src/test/regress/expected/aggregates.out
M src/test/regress/expected/groupingsets.out
M src/test/regress/expected/jsonb.out
M src/test/regress/expected/multirangetypes.out
M src/test/regress/expected/rangetypes.out
M src/test/regress/expected/select_distinct.out
M src/test/regress/expected/subselect.out
M src/test/regress/expected/sysviews.out
M src/test/regress/expected/union.out
M src/test/regress/sql/aggregates.sql
M src/test/regress/sql/groupingsets.sql
M src/test/regress/sql/jsonb.sql
M src/test/regress/sql/multirangetypes.sql
M src/test/regress/sql/rangetypes.sql
M src/test/regress/sql/select_distinct.sql
M src/test/regress/sql/subselect.sql
M src/test/regress/sql/union.sql

doc: Fix data checksum progress reporting documentation

commit   : ff076c042a7467c2870d6dac4eba48651498d57b    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Thu, 9 Jul 2026 09:12:13 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Thu, 9 Jul 2026 09:12:13 +0900    

Click here for diff

Add pg_stat_progress_data_checksums to the progress reporting summary  
and the list of commands with progress reporting.  
  
Also clarify that the view reports both enabling and disabling data  
checksums, and correct the documented types of its progress counters  
to bigint.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/CAHGQGwHJHJYAkYZBi3_O13np-Rou9UL637=hB3Y_-qdCgcZn-w@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml

Tidy up datatype usage in test_random_offset_operations()

commit   : b5d73d2dd73d5a0dc744bf82ec3c18846c42c072    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 9 Jul 2026 11:50:18 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 9 Jul 2026 11:50:18 +1200    

Click here for diff

I had previously made "seed" a uint64, as that's what pg_prng_seed()  
expects to get.  However, GetCurrentTimestamp() and PG_GETARG_INT64()  
both return int64, so there was a mismatch in signedness.  
  
There are no bugs being fixed here, but it seems cleaner to make the  
variable int64 and cast to unsigned when passing to pg_prng_seed().  This  
means we no longer have to use the INT64_FORMAT specifier on the unsigned  
type to format the seed of the failing test correctly to allow a user to  
use the same seed from SQL when trying to recreate any failures manually.  
  
The most important thing to ensure is correct here is that users can  
specify the full range of seed values that could be automatically  
selected by GetCurrentTimestamp() so that we can recreate any failures  
from runs where the seed was auto-selected.  This still works as  
expected when using the int64 type.  
  
In passing, adjust a comment that was a little misleading.  
  
Reported-by: Peter Eisentraut <peter@eisentraut.org>  
Author: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/08fa9f01-373e-4cb4-9650-ad20517e2de3@eisentraut.org  

M src/backend/nodes/bitmapset.c
M src/test/modules/test_bitmapset/test_bitmapset.c

Don't create SPLIT/MERGE partitions as internal relations

commit   : 881033ae8b55dbd22f7ee9c26991b6c4e67d6bd5    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 9 Jul 2026 02:17:08 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Thu, 9 Jul 2026 02:17:08 +0300    

Click here for diff

The new partitions built for ALTER TABLE ... SPLIT PARTITION and  
ALTER TABLE ... MERGE PARTITIONS are created at the explicit request of  
the user, just like a plain CREATE TABLE.  createPartitionTable() passes  
is_internal=true to heap_create_with_catalog(), while createTableConstraints()  
does the same to StoreAttrDefault() and AddRelationNewConstraints().  
Pass is_internal=false in all these places instead, so that object-access  
hooks treat them as user-requested objects.  The is_internal flag is intended  
for objects created as internal implementation details, such as a transient  
heap built during CLUSTER.  
  
While at it, pass 0 rather than PERFORM_DELETION_INTERNAL to the  
performDeletionCheck() calls that pre-check the drop eligibility of the  
old partitions, to match the subsequent performDeletion().  The flag has  
no functional effect on performDeletionCheck(), but change this for code  
consistency.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260707185751.f9.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/commands/tablecmds.c

Remove the refint extension.

commit   : 5e90e0914cfa9345de35efd34eb7a94b59bc23b5    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 8 Jul 2026 16:22:12 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 8 Jul 2026 16:22:12 -0500    

Click here for diff

refint was sample code from the pre-built-in-FK era and has long  
been documented as superseded by the built-in foreign key  
mechanism.  Recent fixes (see commits b0b6196386, 8cfbdf8f4d,  
260e97733b, 611756948e, 1fbe2066dc, and 1541d91d1c) made it clear  
that the code has more issues than its sample-code value justifies.  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAJTYsWUHq8Ohc6-N-xamOPYz-q3qUYMtwQX-1%3DZi%3D5N1Q_GSEQ%40mail.gmail.com  

M contrib/spi/Makefile
D contrib/spi/expected/refint.out
M contrib/spi/meson.build
D contrib/spi/refint–1.0.sql
D contrib/spi/refint.c
D contrib/spi/refint.control
D contrib/spi/refint.example
D contrib/spi/sql/refint.sql
A doc/src/sgml/appendix-obsolete-refint.sgml
M doc/src/sgml/appendix-obsolete.sgml
M doc/src/sgml/contrib-spi.sgml
M doc/src/sgml/filelist.sgml
M src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm

Fix RETURNING OLD with BEFORE UPDATE trigger and concurrent update.

commit   : 8e0c252753bac55601f23f0c04d4e1601fb60074    
  
author   : Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 8 Jul 2026 20:46:25 +0100    
  
committer: Dean Rasheed <dean.a.rasheed@gmail.com>    
date     : Wed, 8 Jul 2026 20:46:25 +0100    

Click here for diff

When executing an UPDATE with a RETURNING clause on a table with a  
BEFORE UPDATE row trigger, the computation of the OLD values in the  
RETURNING list was incorrect if the target tuple was concurrently  
updated by another session, at isolation level READ COMMITTED.  
  
The problem was that the trigger code would lock the target tuple,  
waiting for the other session to commit, and then fetch the updated  
target tuple, but ExecUpdate() would not realise that the target tuple  
had changed, and use the outdated target tuple for computing OLD  
values. Fix by having ExecUpdate() check the TM_FailureData from  
trigger execution and re-fetch the target tuple if necessary.  
  
Re-fetching the target tuple like this is a little inefficient, but  
probably negligible compared to the trigger execution and update. A  
better long-term fix might be to move the EPQ code out of trigger.c,  
and let ExecUpdate() handle it, like ExecMergeMatched() does, but that  
would likely mean changing the trigger API, which seems a bit much for  
back-patching.  
  
Backpatch to v18, where support for RETURNING OLD/NEW was added.  
  
Bug: #19536  
Reported-by: Jonas Boberg <bobergj@gmail.com>  
Diagnosed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Author: Dean Rasheed <dean.a.rasheed@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/19536-73ce5847e6c0e7b1@postgresql.org  
Backpatch-through: 18  

M src/backend/executor/nodeModifyTable.c
M src/test/isolation/expected/eval-plan-qual-trigger.out
M src/test/isolation/expected/merge-match-recheck.out
M src/test/isolation/specs/eval-plan-qual-trigger.spec
M src/test/isolation/specs/merge-match-recheck.spec

Move WAIT_FOR_WAL_* wait events from Client to IPC class

commit   : 306d7680f084cf320841128f23d888294ecba6cd    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 8 Jul 2026 20:44:22 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 8 Jul 2026 20:44:22 +0300    

Click here for diff

WAIT_FOR_WAL_FLUSH, WAIT_FOR_WAL_REPLAY, and WAIT_FOR_WAL_WRITE were  
placed in the WaitEventClient class.  But WaitEventClient is about  
waiting for a socket to become readable or writable, while these events  
have other delay sources as well: local fsync and local replay, which  
may be disk- or CPU-bound.  WaitEventIPC is a better fit, so move them  
there.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260706012642.f9.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/utils/activity/wait_event_names.txt

Whole-row fixes for ALTER COLUMN SET EXPRESSION

commit   : a4639d64e2199885f8e995395b6fe874cb7228bf    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jul 2026 18:44:54 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jul 2026 18:44:54 +0200    

Click here for diff

When changing the expression of a generated column via ALTER TABLE  
ALTER COLUMN SET EXPRESSION, objects that depend on the column via  
indirect whole-row references (such as CHECK constraints, indexes)  
must be handled specially, because technically pg_depend does not  
contain such dependencies, see  
recordDependencyOnSingleRelExpr->find_expr_references_walker.  
  
This is a fix for commit f80bedd52, "Allow ALTER COLUMN SET EXPRESSION  
on virtual columns with CHECK constraints".  
  
Author: jian he <jian.universality@gmail.com>  
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>  
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAJTYsWXOkyeDVbzymWc9sKrq7Y_MUv6XJXN4H9GfsBOPd3NJ+w@mail.gmail.com  

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

Refactor how some aux processes advertise their ProcNumber

commit   : 842169b6c110f48c9f7a2dc29d0cedcc97c2ff29    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 20:33:36 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 20:33:36 +0300    

Click here for diff

This moves the responsibility of setting the ProcGlobal->walwriterProc  
and checkpointerProc fields into InitAuxiliaryProcess. Also switch to  
the same pattern to advertise the autovacuum launcher's ProcNumber,  
replacing the ad hoc av_launcherpid field in shared memory. This can  
easily be extended to other aux processes in the future, if other  
processes need to find them.  
  
Switch to pg_atomic_uint32 for the fields. Seems easier to reason  
about than volatile pointers. There was some precedence for that, as  
were already using pg_atomic_uint32 for the procArrayGroupFirst and  
clogGroupFirst fields, which also store ProcNumbers.  
  
Todo: We could also replace WalRecv->procno with this, but that's a  
little more code churn so I left that for the future.  
  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Discussion: https://www.postgresql.org/message-id/818bafaf-1e77-4c78-8037-d7120878d87c@iki.fi  

M src/backend/access/transam/xlog.c
M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/checkpointer.c
M src/backend/postmaster/walwriter.c
M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h

Remove sketchy TerminateThread() call on Ctrl-C on Windows

commit   : ad7877b00a4232d71bb4cb63c22f9d748e65e3f7    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 18:45:09 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 18:45:09 +0300    

Click here for diff

When pg_dump or pg_restore --jobs N is interrupted with Ctrl-C on  
Windows, we cancel all queries, but we don't want the cancellations to  
be reported as errors to the user in the short time before the whole  
process exits. That was previously achieved by calling  
TerminateThread() on each worker thread before sending the cancel  
message, but that doesn't appear to be 100% safe: the implementations  
of write() and the socket calls inside PQcancel() might acquire user  
space locks that were held by the terminated threads.  (write()  
certainly does that.)  
  
Instead of silencing the threads in such a sketchy way this now sets a  
volatile flag before sending any cancel requests that tells the  
threads to not log errors anymore. (Instead of a volatile, it would be  
better to use an atomic operation here, but that has to wait until we  
add support for atomics on the frontend.)  
  
Note that this also stops using pg_fatal() and exit to exit() from  
workers on failure and instead use pg_log_error combined with  
exit_nicely. If a query fails in a worker we want it to kill the  
worker not the whole process. On Unix that's currently the same thing,  
but on Windows workers are threads.  
  
Author: Jelte Fennema-Nio <postgres@jeltef.nl>  
Reviewed-by: Bryan Green <dbryan.green@gmail.com>  
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>  
Discussion: https://www.postgresql.org/message-id/DJPQS3FYSD4U.3DBTXA6U8IQ0Q@jeltef.nl  

M src/bin/pg_dump/parallel.c
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_db.c
M src/bin/pg_dump/pg_backup_utils.c
M src/bin/pg_dump/pg_backup_utils.h

Introduce bms_offset_members() function

commit   : bb7ded1eebed708865d9bb0a3513c7ed3afe7065    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Thu, 9 Jul 2026 01:11:42 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Thu, 9 Jul 2026 01:11:42 +1200    

Click here for diff

Effectively, a function to bitshift members by the specified number of  
bits.  We have various fragments of code doing this manually with a  
bms_next_member() -> bms_add_member() loop.  We can do this more  
efficiently in terms of CPU and memory allocation by making a new  
Bitmapset and bitshifting in the words of the old set to populate it.  
  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Greg Burd <greg@burd.me>  
Discussion: https://postgr.es/m/CAApHDvq=eEdw2Qp+aSzSOtTSe+h0fnVQ55CcTNqBkLDYiRZmxw@mail.gmail.com  

M src/backend/nodes/bitmapset.c
M src/backend/optimizer/plan/setrefs.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/rewrite/rewriteManip.c
M src/backend/statistics/extended_stats.c
M src/include/nodes/bitmapset.h
M src/test/modules/test_bitmapset/expected/test_bitmapset.out
M src/test/modules/test_bitmapset/sql/test_bitmapset.sql
M src/test/modules/test_bitmapset/test_bitmapset–1.0.sql
M src/test/modules/test_bitmapset/test_bitmapset.c

Add hints for sequence synchronization permission warnings

commit   : 3601f976c2e99123203413fd157f117632b3db78    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 18:16:38 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 18:16:38 +0900    

Click here for diff

Sequence synchronization reports insufficient privileges on publisher  
and subscriber sequences, but the warnings do not indicate which role  
needs which privilege. This makes common configuration mistakes harder  
to diagnose.  
  
Add HINT messages for these warnings. Publisher-side warnings suggest  
granting SELECT to the role used for the replication connection.  
Subscriber-side warnings suggest granting UPDATE to the subscription  
owner when run_as_owner is enabled. Otherwise, the worker runs as the  
sequence owner, so no useful GRANT hint can be provided.  
  
Suggested-by : Amit Kapila <amit.kapila16@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Discussion: https://postgr.es/m/CAA4eK1JOo0aJRhFHNWpj3hMwaTtNOopY34f1Lh_QD=z=+DrzWQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/logical-replication.sgml
M src/backend/replication/logical/sequencesync.c

doc: Clarify pg_get_sequence_data() NULL-return cases

commit   : 5412abc22d068ff52e13c60309e9d54eb08e6403    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 18:15:33 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 18:15:33 +0900    

Click here for diff

The documentation previously said that pg_get_sequence_data() returns  
a row of NULL values if the sequence does not exist or if the current  
user lacks privileges on it. This was incomplete and could be misleading.  
A nonexistent relation name is rejected during regclass input conversion,  
while the function returns NULLs for a nonexistent relation OID and  
several other cases.  
  
This commit clarifies that the function returns NULLs when the specified  
relation OID does not exist, the relation is not a sequence, the current  
user lacks SELECT privilege on the sequence, the sequence belongs to  
another session's temporary schema, or it is an unlogged sequence on  
a standby server.  
  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CAA4eK1JOo0aJRhFHNWpj3hMwaTtNOopY34f1Lh_QD=z=+DrzWQ@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/func/func-sequence.sgml

Resolve unknown-type literals in property expressions

commit   : 57f93af36f02a2559b005491d9fb0da660e32850    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jul 2026 10:11:11 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jul 2026 10:11:11 +0200    

Click here for diff

When a string literal is provided as a property expression, the data  
type of the property was set to "unknown", which may lead to various  
failures when the property is used in GRAPH_TABLE or when its data  
type is compared against other properties with the same name.  To fix  
this, call resolveTargetListUnknowns() on the targetlist of new  
properties being added to resolve unknown type literals.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/20260630173053.51.noahmisch%40microsoft.com  

M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/sql/create_property_graph.sql

Fix replace_property_refs() ignoring the root of expression tree

commit   : 16a4b3ef8eebd2f3da44c17523fef23d2de80679    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jul 2026 09:40:46 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 8 Jul 2026 09:40:46 +0200    

Click here for diff

replace_property_refs() called expression_tree_mutator() with the root  
of the expression tree as the input node.  But  
expression_tree_mutator() does not call the mutator function on the  
root node, so the root node remains unchanged.  If the root node is a  
property reference or a lateral reference -- the two node kinds that  
replace_property_refs_mutator() rewrites -- it is returned unchanged.  
Modules after the rewriter do not know about property reference nodes,  
resulting in "ERROR: unrecognized node type: 63".  Since varlevelsup  
of lateral references is not incremented, they are not resolved  
correctly in the planner, leading to many different symptoms.  Fix  
this by calling replace_property_refs_mutator() directly from  
replace_property_refs(), similar to how other mutator functions do.  
  
The only case when a property reference or a lateral reference can be  
the root of a GRAPH_TABLE expression tree is when it is a bare  
property reference or a bare lateral reference in the WHERE clause.  
The COLUMNS clause is passed to replace_property_refs() as a  
targetlist.  Every other expression has at least one expression node  
covering the property reference or a lateral reference in the  
expression tree.  That explains why this bug was not seen so far.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://www.postgresql.org/message-id/flat/20260630173053.51.noahmisch%40microsoft.com  

M src/backend/rewrite/rewriteGraphTable.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql

Fix misspelling in docs

commit   : 4b587f666a73a5f8e2f8a47a1be010ffcb084955    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 10:20:34 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 10:20:34 +0300    

Click here for diff

Reported-by: Erik Rijkers <er@xs4all.nl>  
Discussion: https://www.postgresql.org/message-id/6223b7dc-bfee-fcff-88d9-13f99b8d4897@xs4all.nl  
Backpatch-through: 19  

M doc/src/sgml/xfunc.sgml

injection_points: Switch wait/wakeup to rely on atomics

commit   : 8daeaa9b642c3c23cbc516da80d50aade6f4dc07    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 8 Jul 2026 14:34:09 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 8 Jul 2026 14:34:09 +0900    

Click here for diff

This change switches the implementation of wait and wakeups in the  
module injection_points to not rely anymore on condition variables,  
using a more primitive implementation based on atomics.  The former  
implementation required a PGPROC, making it impossible to inject waits  
in the postmaster or during authentication.  A couple of use cases have  
popped up for these in the past, where this would have become handy.  
  
The loop in the wait callback that relied on a condition variable is  
replaced by an atomic counter, whose check increases over time in an  
exponential manner (starts at 10us for quick responsiveness, up to  
100ms).  
  
This change may be backpatched at some point depending on how much  
testing coverage is wanted.  Let's limit ourselves to HEAD for now,  
checking things first with the buildfarm.  
  
Creating a wait still requires the SQL interface.  We are looking at  
expanding that with an alternative implementation, so as early startup  
or authentication waits would become possible.  This refactoring piece  
is mandatory to achieve this goal.  
  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Discussion: https://postgr.es/m/aher0VsjJ8xeNgLq@paquier.xyz  

M src/test/modules/injection_points/injection_points.c

Fix more Datum conversion inconsistencies

commit   : d92e98340fcb4c3ef728b3e8204573bdc86098f7    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 8 Jul 2026 13:22:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 8 Jul 2026 13:22:50 +0900    

Click here for diff

This is a continuation of the work done in ac59a90bef45.  The  
*GetDatum() macros for output should match with what the SQL functions  
use as DatumGet*() in input.  
  
Aleksander has spotted some of the areas patched here, for pageinspect.  
I have spotted the rest while digging into the state of the tree.  
  
There is no behavior change after this commit, since all the affected  
values are small enough that the signed bit is never used.  
  
Author: Aleksander Alekseev <aleksander@tigerdata.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/afLsqRjVqKK8hhKk@paquier.xyz  

M contrib/pageinspect/brinfuncs.c
M contrib/pageinspect/btreefuncs.c
M contrib/pageinspect/ginfuncs.c
M contrib/pageinspect/gistfuncs.c
M contrib/pageinspect/heapfuncs.c
M contrib/pageinspect/rawpage.c
M contrib/pg_logicalinspect/pg_logicalinspect.c
M contrib/pg_walinspect/pg_walinspect.c
M contrib/pgstattuple/pgstatindex.c
M src/backend/access/gin/ginlogic.c
M src/backend/access/transam/xlogfuncs.c
M src/backend/catalog/pg_proc.c
M src/backend/utils/adt/lockfuncs.c

doc: Clarify COPY FROM WHERE expression restrictions

commit   : d35e8babc4602c73ec4f66f93a5004a2ead62438    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 12:44:06 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 12:44:06 +0900    

Click here for diff

Commit aa606b9316a disallowed generated columns in COPY FROM WHERE  
expressions, and commit 21c69dc73f9 disallowed system columns.  
However, the COPY reference page still mentions only the restriction  
on subqueries.  
  
Update the documentation to also list generated columns and system  
columns as unsupported in COPY FROM WHERE expressions.  
  
Backpatch the generated-column documentation change to all supported  
versions. Backpatch the system-column documentation change to v19,  
where that restriction was introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwEgxErc54yVOAVWCsr1O=8pgw4oKRPuEQ9mfhkoYGR_XA@mail.gmail.com  
Backpatch-through: 14  

M doc/src/sgml/ref/copy.sgml

pg_recvlogical: send final feedback on SIGINT/SIGTERM shutdown

commit   : b5a8018116c422f39de94f69f0108ff0c9224f0a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 12:16:34 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 12:16:34 +0900    

Click here for diff

Previously, when pg_recvlogical exited due to SIGINT or SIGTERM,  
it could terminate without sending final feedback for the last decoded  
changes it had already written locally. So, if pg_recvlogical was  
restarted afterwards, the server-side logical replication slot could  
still point behind those changes, causing them to be sent again.  
  
Make pg_recvlogical send final feedback once more during SIGINT/SIGTERM  
shutdown, before sending CopyDone. This gives the server one more chance  
to advance the slot far enough to avoid resending already-written data,  
so users are less likely to see duplicate decoded output after stopping  
and restarting pg_recvlogical.  
  
This remains a best-effort improvement rather than a guarantee. Depending  
on when the signal arrives, pg_recvlogical can already have written  
decoded output that the server cannot yet safely treat as confirmed, so a  
later restart can still receive duplicate data.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwE83z9O=X7ADMsSa3e1EuP3_GgqHjFt5SmPDNxZo_wgJA@mail.gmail.com  

M src/bin/pg_basebackup/pg_recvlogical.c
M src/bin/pg_basebackup/t/030_pg_recvlogical.pl

Tighten nullingrels checks for outer joins

commit   : 4721430f199ffaf0936dc19bd473f34e8b1ee791    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 12:02:21 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 12:02:21 +0900    

Click here for diff

When fixing up the targetlist and qpqual of an outer join, we must  
account for the effects of the outer join.  Vars and PHVs appearing  
there are logically above the join, so they should have nullingrels  
equal to the input Vars/PHVs' nullingrels plus the bit added by the  
outer join.  
  
Determining the effects of the outer join can be tricky when the join  
has been commuted with another one per outer join identity 3.  In this  
case, the Vars/PHVs in the join's targetlist and qpqual should have  
the same nullingrels that they would if the two joins had been done in  
syntactic order.  Unfortunately, in setrefs.c, we don't have enough  
information to identify what that should be, so we have to use  
superset nullingrels matches instead of exact ones.  
  
However, we can tighten the check somewhat.  Currently, we check  
whether the jointype is JOIN_INNER and use NRM_SUPERSET if it is not.  
We can improve this by checking whether the Join node has non-empty  
ojrelids and using NRM_SUPERSET only in that case.  This allows us to  
perform exact matches in more situations.  
  
To support this, we record the outer-join relids in Join plan nodes.  
This information can also improve EXPLAIN (RANGE_TABLE) output by  
showing which outer-join relids are completed by each Join plan node.  
We may discover additional uses for this information in the future.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs482_DFHzQ079ZPp6c8UvmFdz3Jj+4K8tVRu9g2Bw34NPA@mail.gmail.com  

M contrib/pg_overexplain/expected/pg_overexplain.out
M contrib/pg_overexplain/pg_overexplain.c
M contrib/pg_overexplain/sql/pg_overexplain.sql
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/plan/setrefs.c
M src/include/nodes/plannodes.h

Remove nrm_match parameter from fix_upper_expr

commit   : 3b0991059f33305118d850bb94fc9dca590c4ed6    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 12:01:44 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 12:01:44 +0900    

Click here for diff

With the changes in the previous commit, we can now use exact  
nullingrels matches in all cases when fixing up expressions of  
upper-level plan nodes that are not joins.  Therefore, we can remove  
the nrm_match parameter from fix_upper_expr(), along with the  
corresponding field in fix_upper_expr_context.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs482_DFHzQ079ZPp6c8UvmFdz3Jj+4K8tVRu9g2Bw34NPA@mail.gmail.com  

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

Use exact nullingrels matches for NestLoopParams

commit   : 9dce6b5a42bbf97721bd0aeef28688745e77e82f    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 12:00:36 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 12:00:36 +0900    

Click here for diff

We have been using NRM_SUBSET to process NestLoopParams in setrefs.c,  
because Vars or PHVs in NestLoopParam expressions may previously have  
had nullingrels that were just subsets of those in the Vars or PHVs  
actually available from the outer side.  
  
Since 66e9df9f6, identify_current_nestloop_params ensures that any  
Vars or PHVs seen in a NestLoopParam expression have nullingrels that  
include exactly the outer-join relids that appear in the outer side's  
output and can null the respective Var or PHV.  As noted in that  
commit's message, we can now safely use NRM_EQUAL to process  
NestLoopParams in setrefs.c.  
  
This patch makes that change and removes the definition of NRM_SUBSET,  
along with all remaining checks for it, since it is no longer used.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs482_DFHzQ079ZPp6c8UvmFdz3Jj+4K8tVRu9g2Bw34NPA@mail.gmail.com  

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

pg_locale_libc.c: add missing casts to unsigned char.

commit   : e6e08dc5543485c7f4851551e67a99b0cf8027eb    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:20:15 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:20:15 -0700    

Click here for diff

Discussion: https://postgr.es/m/20260630012919.78@rfd.leadboat.com  
Backpatch-through: 19  

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

pg_locale_libc.c: add guards to ctype methods.

commit   : dbbeafe61ad049c8881aa82575ecf3e89d707ce3    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:20:06 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:20:06 -0700    

Click here for diff

Necessary for 16-bit wchar_t platforms (Windows).  
  
Other guards are just defensive. Also correct style issue with  
branches.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260630012919.78@rfd.leadboat.com  
Backpatch-through: 19  

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

Fix obsolete comment.

commit   : 3ab2abc9494dde30dbdfe9eeb7c96a63128941ae    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:19:59 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:19:59 -0700    

Click here for diff

Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260630012919.78@rfd.leadboat.com  
Backpatch-through: 19  

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

Fix unintentional behavior change from 5a38104b36.

commit   : d34ce773d2d3bd891e2725ec4d4b94f1195e52cf    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:04:33 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 18:04:33 -0700    

Click here for diff

Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://postgr.es/m/20260630012919.78@rfd.leadboat.com  
Backpatch-through: 19  

M src/backend/utils/adt/like.c
M src/test/regress/expected/collate.utf8.out
M src/test/regress/sql/collate.utf8.sql

Propagate stadistinct through GROUP BY/DISTINCT in subqueries and CTEs

commit   : 906b1e4a19a59612deb144ff6018cb048f7d73f8    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 09:38:31 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 09:38:31 +0900    

Click here for diff

Previously, examine_simple_variable() would return early when a  
subquery or CTE used GROUP BY or DISTINCT.  It could detect uniqueness  
for single-column cases, but for multi-column GROUP BY or DISTINCT,  
selectivity estimation fell back on 1/DEFAULT_NUM_DISTINCT (1/200).  
This produced wildly inaccurate estimates for filters and joins on  
such columns, often leading the planner to choose nested loop joins  
where hash joins would be far better.  This was a significant factor  
in poor TPC-DS benchmark performance.  
  
For DISTINCT or GROUP BY key columns that are simple Vars, we now  
recurse into the subquery to obtain the base table's stadistinct,  
which remains valid after grouping (the set of distinct values is  
preserved).  However, MCV frequencies, histograms, and correlation  
data are not valid because GROUP BY and DISTINCT change the frequency  
distribution of key columns.  So we strip all stats slots from the  
copied stats tuple, causing callers like var_eq_const() to use the  
1/ndistinct estimate instead.  If stadistinct is stored as a negative  
value (a fraction of the base table's row count), we convert it to an  
absolute count so it is not misinterpreted relative to the subquery's  
output row count.  
  
stanullfrac is adjusted too, since grouping collapses NULLs.  For a  
single grouping key, at most one NULL group survives, so the null  
fraction is 1/(ndistinct+1).  For multiple grouping keys the null  
fraction depends on the joint distribution of the keys, which we don't  
have, so we approximate it as zero; NULLs collapse far more  
aggressively than non-NULLs, so the real fraction is well below the  
base table's, and erring low keeps estimates on the hash-join-favoring  
side.  
  
Non-key columns (e.g., aggregate outputs) continue to get no stats,  
same as before.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>  
Discussion: https://postgr.es/m/CAMbWs49rWYrecgreDhKsfx3VSDW=qo35s+iAmgGu=wpARrM8_g@mail.gmail.com  

M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/with.out
M src/test/regress/sql/with.sql

doc: Fix typo in rule-system view example

commit   : 0237f1480a0d618f60d8dd4eca097e99aa7256d9    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 09:04:31 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 8 Jul 2026 09:04:31 +0900    

Click here for diff

Commit dcb00495236 accidentally changed the final expanded query's  
condition to > 2 while rewriting the example into SQL operator notation.  
  
The original query and the preceding rewritten forms all use >= 2,  
and view expansion should preserve that qualification. This commit  
changes the final condition from > 2 to >= 2.  
  
Backpatch to all supported versions.  
  
Reported-by: Yaroslav Saburov <y.saburov@gmail.com>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>  
Discussion: https://postgr.es/m/178248467618.108999.9966122434342474006@wrigleys.postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/rules.sgml

Fix EXPLAIN failure when deparsing SQL/JSON aggregates

commit   : 96ab9a990eed2265c6b073646d1566a1dd2bd3f7    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 08:46:43 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 8 Jul 2026 08:46:43 +0900    

Click here for diff

If an expression containing an aggregate is evaluated above the plan  
node that computes the aggregate, as happens with window functions or  
with expressions postponed to above the final sort, setrefs.c replaces  
the Aggref or WindowFunc with a Var referencing the lower node's  
output.  For SQL/JSON aggregates such as JSON_ARRAYAGG and  
JSON_OBJECTAGG, deparsing the containing JsonConstructorExpr then  
failed with "invalid JsonConstructorExpr underlying node type", since  
get_json_agg_constructor() did not expect a Var there.  
  
Fix by resolving the Var back to the underlying Aggref or WindowFunc  
and deparsing the constructor as if the aggregate were computed at the  
current node.  The JsonConstructorExpr retains the RETURNING clause  
and the ABSENT/NULL ON NULL and WITH UNIQUE options, and the arguments  
come from the resolved aggregate, so the original JSON aggregate  
syntax is reproduced in full.  This mirrors how get_agg_expr() already  
looks through such a Var when deparsing a combining aggregate.  
  
Reported-by: Thom Brown <thom@linux.com>  
Author: Richard Guo <guofenglinux@gmail.com>  
Discussion: https://postgr.es/m/CAA-aLv5QYTaMOk=Qhv6cgwceeHETZV8YJvWZ_rH+yVZCuchATA@mail.gmail.com  
Backpatch-through: 16  

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

unicode_case.c: change API to signal UTF8 decoding error.

commit   : 07211f64ace0150c92a00769a1cfe8b9305b9e78    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 15:23:54 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 15:23:54 -0700    

Click here for diff

Errors at this point are not expected, but if encountered, signal to  
the caller so it can raise the appropriate error.  
  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/c355354e6c3f4a7aafb047361b73db247260fca0.camel@j-davis.com  

M src/backend/utils/adt/pg_locale_builtin.c
M src/common/unicode/case_test.c
M src/common/unicode_case.c
M src/include/common/unicode_case.h

Remove unused tuple fetch in speculative completion

commit   : 7258c891d4cabd366e4529484f2ad6e99234db48    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 01:16:24 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 01:16:24 +0300    

Click here for diff

heapam_tuple_complete_speculative() fetched a tuple from the slot only  
to free it immediately afterwards, without ever using it.  
  
The function only needs slot->tts_tid to complete or abort the  
speculative insertion, so remove the unnecessary fetch and pfree().  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Discussion: https://www.postgresql.org/message-id/FCB61654-575D-4F08-AA7E-ED462EDE48A7@gmail.com  

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

pg_unicode_fast: fix final sigma logic.

commit   : 36869368989ce37d85c08c33258eb01ae96e2375    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 14:29:15 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 14:29:15 -0700    

Click here for diff

If the string is preceded only by Case Ignorable characters, don't  
consider it to be a final sigma.  
  
In the process, refactor so that the preceding and following  
characters are found first, and then the rule is applied, to improve  
clarity.  
  
Discussion: https://postgr.es/m/c355354e6c3f4a7aafb047361b73db247260fca0.camel@j-davis.com  
Backpatch-through: 18  

M src/common/unicode_case.c
M src/test/regress/expected/collate.utf8.out
M src/test/regress/sql/collate.utf8.sql

Deduplicate metapage sanity checks in _bt_gettrueroot()

commit   : 99319edb8f5e9c4363ac79088e58a70570d728bb    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 00:25:24 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Wed, 8 Jul 2026 00:25:24 +0300    

Click here for diff

Replace the metapage sanity checks in _bt_gettrueroot() with a call to  
_bt_getmeta(), which does exactly the same checks.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAEoWx2nisjqs4iC9o4Hu7-Ab767=cMZZzmhBGb8SaQtMMmVqPQ@mail.gmail.com  

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

unicode_case.c: defend against truncated UTF8.

commit   : 21ffc271d475a31dbc67706fc1f2a2c5bfc83e14    
  
author   : Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 13:34:55 -0700    
  
committer: Jeff Davis <jdavis@postgresql.org>    
date     : Tue, 7 Jul 2026 13:34:55 -0700    

Click here for diff

Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://postgr.es/m/c355354e6c3f4a7aafb047361b73db247260fca0.camel@j-davis.com  
Backpatch-through: 17  

M src/backend/utils/adt/pg_locale_builtin.c
M src/common/unicode/case_test.c
M src/common/unicode_case.c

Cleanup comments/docs around the new shmem request callbacks

commit   : 6f7199a1245cab986a13c7b57812255fe77679d1    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 22:32:36 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 22:32:36 +0300    

Click here for diff

Make it explicit in the docs that the shmem initialization callbacks  
are called while holding ShmemIndexLock.  
  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAExHW5sHs+eSiTDOd14buayc6JbBX=Hm5ssFMBK0Ki9sTGEOuA@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/xfunc.sgml
M src/backend/storage/ipc/shmem.c

Fix gistkillitems for GiST root page

commit   : 9c9ddf109bd8d73660ff3fef317f95bc1d7d6cc5    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 21:21:16 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 21:21:16 +0300    

Click here for diff

GiST index killitems feature misbehaves for single-page GiST index,  
i.e. one that has only a root page. This is caused by the GiST scan's  
curBlkno variable not being initialized for the first-to-scan page,  
which is the root page.  Fix this by moving the initializing of  
curBlkno into gistScanPage(), where we also set the related curPageLSN  
variable.  
  
Commit 377b7ab145 actually added a regression test for this already,  
but it merely noted that it's not working and memorized the result  
where the items were not killed. Now they are, as the test shows.  
  
This has been broken all along, but since it's just a very minor  
performance issue on tiny tables, I didn't bother backpatching it.  
  
Author: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>  
Reviewed-by: Soumya S Murali <soumyamurali.work@gmail.com>  
Discussion: https://postgr.es/m/CALdSSPgZWX_D8%2BFx4YQqRN5eW5iSx_rJdqQhCfdWTvqKXVfJ4w%40mail.gmail.com  
Discussion: https://postgr.es/m/lxzj26ga6ippdeunz6kuncectr5gfuugmm2ry22qu6hcx6oid6@lzx3sjsqhmt6  

M src/backend/access/gist/gistget.c
M src/test/modules/index/expected/killtuples.out
M src/test/modules/index/specs/killtuples.spec

commit   : 650bb73c137ccdea3a502775e08482731cc799ba    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 20:05:56 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 20:05:56 +0300    

Click here for diff

Only "tombstone" files (first segment of main fork) are unlinked after  
checkpoints, so rename the function and remove the extra arguments to  
make that more clear.  
  
Additionally, add an assertion in mdunlinkfiletag() that the FileTag  
only contains expected values.  
  
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>  
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAEze2WjfP95SL_Hsu7GzYXLnQyEsT49zOnNvbY_mBLCFiQra1g@mail.gmail.com  

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

Fix pg_dump ACL minimization for PROPERTY GRAPH.

commit   : 592de8bd21e177229eeef51cb474ccfc2070c65d    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Tue, 7 Jul 2026 09:51:04 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Tue, 7 Jul 2026 09:51:04 -0700    

Click here for diff

Adding a GRANT caused pg_dump to emit a useless REVOKE + GRANT of owner  
privileges, as seen in a dump of the regression database:  
  
  REVOKE ALL ON PROPERTY GRAPH graph_rls_schema.cabinet FROM nm;  
  GRANT ALL ON PROPERTY GRAPH graph_rls_schema.cabinet TO nm;  
  GRANT ALL ON PROPERTY GRAPH graph_rls_schema.cabinet TO PUBLIC;  
  
For normal dumps, this has no functional consequences.  For --no-owner  
restores, the extra statements may fail or locate unrelated users of the  
destination cluster.  
  
The problem was pg_dump assuming NULL relacl implies acldefault('r'),  
the default for TABLE.  Fix by teaching acldefault() to retrieve the  
PROPERTY GRAPH default ACL.  So pg_dump can still dump from 19beta1, use  
acldefault('g') for v20+ only.  For v19, use a hard-coded snapshot of  
the v19 default.  
  
information_schema.pg_property_graph_privileges also misused  
acldefault('r'), but its "c.prtype IN ('SELECT')" predicate compensated  
for it.  Switch to the new acldefault('g') for clarity.  Bump catversion  
since a new view won't work with old binaries.  Back-patch to v19, which  
introduced PROPERTY GRAPH.  
  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/20260630023308.c7.noahmisch@microsoft.com  
Backpatch-through: 19  

M src/backend/catalog/information_schema.sql
M src/backend/utils/adt/acl.c
M src/bin/pg_dump/pg_dump.c
M src/include/catalog/catversion.h

Remove unnecessary volatile qualifiers.

commit   : b34fd845e03aea7401d3bf403c87e171d10f7709    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 7 Jul 2026 10:57:48 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 7 Jul 2026 10:57:48 -0500    

Click here for diff

This commit cleans up volatile qualifiers that fit the below  
criteria:  
  
* Accesses to shared memory protected by a spinlock or LWLock.  
Before commit 0709b7ee72, callers had to use volatile when  
accessing spinlock-protected shared memory.  Since spinlock  
acquire/release became compiler barriers, and because LWLocks  
provide the same guarantee, that is no longer necessary.  These  
either predate that change or were cargo-culted from code that did.  
  
* Pointers used only to find the address of a member.  The volatile  
qualifier only affects accesses made by dereferencing the pointer,  
so it is unnecessary there.  
  
* Accesses to struct members that are marked volatile in the struct  
definition.  There's no need to mark these pointers volatile,  
either.  
  
* Leftovers from removed PG_TRY blocks.  These were marked volatile  
to protect a value that is modified inside a PG_TRY block, but the  
PG_TRY has since been removed.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://postgr.es/m/akQ5eJR1tCCXme8e%40nathan  

M src/backend/access/transam/clog.c
M src/backend/catalog/index.c
M src/backend/commands/async.c
M src/backend/replication/syncrep.c
M src/backend/storage/ipc/procsignal.c
M src/backend/storage/ipc/shm_toc.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c
M src/test/modules/test_shm_mq/setup.c
M src/test/modules/test_shm_mq/worker.c

libpq: Drain all pending bytes from SSL/GSS during pqReadData()

commit   : 343594a26d37522efdbae5fe5de13e19ccf2fa72    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 18:45:37 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 18:45:37 +0300    

Click here for diff

The previous commit strengthened a workaround for a hang when large  
messages are split across TLS records/GSS tokens. Because that  
workaround is implemented in libpq internals, it can only help us when  
libpq itself is polling on the socket. In nonblocking situations,  
where the client above libpq is expected to poll, the same bugs can  
show up.  
  
As a contrived example, consider a large protocol-2.0 error coming  
back from a server during PQconnectPoll(), split in an odd way across  
two records:  
  
    -- TLS record (8192-byte payload) --  
    EEEE[...repeated a total of 8192 times]  
    -- TLS record (8193-byte payload) --  
    EEEE[...repeated a total of 8192 times]\0  
  
The first record will fill the first half of the libpq receive buffer,  
which is 16k long by default. The second record completely fills the  
last half with its first 8192 bytes, leaving the terminating NULL in  
the OpenSSL buffer. Since we still haven't seen the terminator at our  
level, PQconnectPoll() will return PGRES_POLLING_READING, expecting to  
come back when the server has sent "the rest" of the data.  But there  
is nothing left to read from the socket; OpenSSL had to pull all of  
the data in the 8193-byte record off of the wire to decrypt it.  
  
A real server would probably not split up the records this way, nor  
keep the connection open after sending a fatal connection error. But  
servers that regularly use larger TLS records can get the libpq  
receive buffer into the same state if DataRows are big enough, as  
reported on the list. While the PostgreSQL server doesn't use larger  
TLS records like that, other non-PostgreSQL servers that implement the  
wire protocol are known to do that, as well as proxies that sit  
between the server and the client  
  
This is a layering violation. libpq makes decisions based on data in  
the application buffer, above the transport buffer (whether SSL or  
GSS), but clients are polling the socket below the transport buffer.  
One way to fix this in a backportable way, without changing APIs too  
much, is to ensure data never stays in the transport buffer. Then  
pqReadData's postconditions will look similar for both raw sockets and  
SSL/GSS: any available data is either in the application buffer, or  
still on the socket.  
  
Building on the prior commit, make pqReadData() to drain all pending  
data from the transport layer into conn->inBuffer, expanding the  
buffer as necessary. This is not particularly efficient from an  
architectural perspective (the pqsecure_read() implementations take  
care to fit their packets into the current buffer, and that effort is  
now completely discarded), but it's hopefully easier to reason about  
than a full rewrite would be for the back branches.  
  
Author: Jacob Champion <jacob.champion@enterprisedb.com>  
Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com>  
Reviewed-by: solai v <solai.cdac@gmail.com>  
Reported-by: Lars Kanis <lars@greiz-reinsdorf.de>  
Discussion: https://postgr.es/m/2039ac58-d3e0-434b-ac1a-2a987f3b4cb1%40greiz-reinsdorf.de  
Backpatch-through: 14  

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

libpq: Extend "read pending" check from SSL to GSS

commit   : ffd080d94fe7154940a1bdac005390d0aee034bc    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 18:45:34 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 18:45:34 +0300    

Click here for diff

An extra check for pending bytes in the SSL layer has been part of  
pqReadReady() for a very long time (79ff2e96d). But when GSS transport  
encryption was added, it didn't receive the same treatment. (As  
79ff2e96d notes, "The bug that I fixed in this patch is exceptionally  
hard to reproduce reliably.")  
  
Without that check, it's possible to hit a hang in gssencmode, if the  
server splits a large libpq message such that the final message in a  
streamed response is part of the same wrapped token as the split  
message:  
  
    DataRowDataRowDataRowDataRowDataRowData  
    -- token boundary --  
    RowDataRowCommandCompleteReadyForQuery  
  
If the split message takes up enough memory to nearly fill libpq's  
receive buffer, libpq may return from pqReadData() before the later  
messages are pulled out of the PqGSSRecvBuffer. Without additional  
socket activity from the server, pqReadReady() (via pqSocketCheck())  
will never again return true, hanging the connection.  
  
Pull the pending-bytes check into the pqsecure API layer, where both  
SSL and GSS now implement it.  
  
Note that this does not fix the root problem! Third party clients of  
libpq have no way to call pqsecure_read_is_pending() in their own  
polling. This just brings the GSS implementation up to par with the  
existing SSL workaround; a broader fix is left to a subsequent commit.  
  
In preparation for the broader fix, this patch already changes the  
*_read_pending() functions to return the number of bytes in the buffer  
rather than just a boolean. The current callers don't need that, but  
the subsequent fix will.  
  
Author: Jacob Champion <jacob.champion@enterprisedb.com>  
Discussion: https://postgr.es/m/CAOYmi%2BmpymrgZ76Jre2dx_PwRniS9YZojwH0rZnTuiGHCsj0rA%40mail.gmail.com  
Backpatch-through: 14  

M src/interfaces/libpq/fe-misc.c
M src/interfaces/libpq/fe-secure-gssapi.c
M src/interfaces/libpq/fe-secure-openssl.c
M src/interfaces/libpq/fe-secure.c
M src/interfaces/libpq/libpq-int.h

Replace hardcoded mentions of pg_hosts.conf with GUC

commit   : b9df8d5b8e4f58ef81e6b592278207889863c367    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 7 Jul 2026 17:34:58 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 7 Jul 2026 17:34:58 +0200    

Click here for diff

Three error messages were using the default file name pg_hosts.conf  
and not the variable backing the GUC, which would make logging be  
confusing for users who have renamed the file using the GUC.  Fix  
by consistently using the HostsFileName variable.  
  
Backpatch down to v19 where serverside SNI was introduced.  
  
Author: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAN4CZFMARYjQfgyRaCKOXDO=Q91kuKn=pSC02DAOOr23ojhEGQ@mail.gmail.com  
Backpatch-through: 19  

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

pg_dump: check for _beginthreadex() failure in parallel dump

commit   : 75e201bf95d8825f1c025792eed0f13d65657c5d    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 18:11:28 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Tue, 7 Jul 2026 18:11:28 +0300    

Click here for diff

ParallelBackupStart() stored _beginthreadex()'s return value as the  
worker's thread handle without checking it.  On failure that value is 0,  
which would later reach WaitForMultipleObjects() as a null handle, caught  
only by an Assert.  The fork() path already calls pg_fatal() when it  
fails; do the same for _beginthreadex(), as pgbench does.  
  
Author: Bryan Green <dbryan.green@gmail.com>  
Discussion: https://www.postgresql.org/message-id/8c712d76-ecf7-4749-a6d8-dddc01f298ec@gmail.com  
Backpatch-through: 14  

M src/bin/pg_dump/parallel.c

doc: Add reference to CREATE PROCEDURE on CREATE FUNCTION

commit   : 9762809448b42d841ec09bf17db72ff769ac8b79    
  
author   : Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 7 Jul 2026 15:55:24 +0200    
  
committer: Daniel Gustafsson <dgustafsson@postgresql.org>    
date     : Tue, 7 Jul 2026 15:55:24 +0200    

Click here for diff

The reference page for CREATE PROCEDURE had a See Also reference to  
CREATE FUNCTION, but the inverse was missing.  
  
Author: Jian He <jian.universality@gmail.com>  
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>  
Discussion: https://postgr.es/m/CACJufxFTi3ceVRJqWRr3L8GR5q+ZhPCZw=1aDTaBGS1AugweFw@mail.gmail.com  

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

Fix COUNT's logic for window run condition support

commit   : d007800f02a7b9fe3ca984a1b870405657d990ed    
  
author   : David Rowley <drowley@postgresql.org>    
date     : Tue, 7 Jul 2026 23:57:45 +1200    
  
committer: David Rowley <drowley@postgresql.org>    
date     : Tue, 7 Jul 2026 23:57:45 +1200    

Click here for diff

9d9c02ccd added code to allow the executor to stop early when processing  
WindowAgg nodes where a monotonic window function starts producing  
values that result in a pushed-down qual no longer matching, and will  
never match again due to the window function's monotonic properties.  
  
That commit requires a SupportRequestWFuncMonotonic to exist on the  
window function and for it to detect when the function is monotonic.  For  
COUNT(ANY) and COUNT(*), the support function failed to consider some  
cases where the WindowClause used EXCLUDE to exclude certain rows from  
being aggregated.  Some WindowClause definitions mean we aggregate rows  
that come after the current row, and when processing those rows later,  
if we EXCLUDE certain rows, the monotonic property can be broken.  
Wrongly treating the COUNT(*) or COUNT(ANY) aggregate as monotonic could  
lead to rows being filtered that should not be filtered from the result  
set.  
  
Another issue was that the support function for the COUNT aggregate  
mistakenly thought that a WindowClause without an ORDER BY meant that  
the results would be both monotonically increasing and decreasing, but  
that's only true when in RANGE mode, where all rows are peers.  
  
It is possible to support various cases that do have an EXCLUDE clause,  
but getting the logic correct for the exact set of cases that are valid  
is quite complex and would likely better be left for a future project.  
  
Here, we mostly disable run condition pushdown when there is an EXCLUDE  
clause unless the clause is for EXCLUDE CURRENT ROW, uses COUNT(*)  
(rather than COUNT(ANY)), and the window aggregate has no FILTER clause.  
  
Bug: #19533  
Reported-by: Qifan Liu <imchifan@163.com>  
Author: Chengpeng Yan <chengpeng_yan@outlook.com>  
Author: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: John Naylor <johncnaylorls@gmail.com>  
Discussion: https://postgr.es/m/19533-413a1014e5d0e766@postgresql.org  
Backpatch-through: 15  

M src/backend/utils/adt/int8.c
M src/test/regress/expected/window.out
M src/test/regress/sql/window.sql

Print off_t/pgoff_t consistently as %lld

commit   : c22d2f7fd46c692c83152773387be6b731c1a4b9    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 7 Jul 2026 11:50:22 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 7 Jul 2026 11:50:22 +0200    

Click here for diff

This was the dominant style already, but some places used %llu  
instead.  Since off_t/pgoff_t are signed types, using %lld seems a  
better match, and it might handle obscure error conditions with  
negative values better.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/20ce62fa-47fc-457b-b504-12f3c1651726%40eisentraut.org  

M src/bin/pg_combinebackup/reconstruct.c
M src/bin/pg_dump/pg_backup_tar.c
M src/bin/pg_rewind/libpq_source.c
M src/bin/pg_verifybackup/astreamer_verify.c
M src/bin/pg_verifybackup/pg_verifybackup.c

Don't cast pgoff_t to possibly 32-bit types for output

commit   : 04fc2564fbbabe97cadbf782e8d40b8e3f7b22a5    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 7 Jul 2026 11:45:09 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 7 Jul 2026 11:45:09 +0200    

Click here for diff

pgoff_t is most likely a 64-bit integer, so casting it to a 32-bit  
type for output could lose data.  In the cases addressed here, the  
files cannot actually get that large, so this is only cosmetic and to  
set better examples for the future.  (Similar issues that could have  
actual practical impact were addressed separately in commit  
e8f851d6172.)  
  
In one case, the 32-bit size is baked into the protocol, so here we  
add an elog and document this discrepancy.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/20ce62fa-47fc-457b-b504-12f3c1651726%40eisentraut.org  

M src/backend/access/heap/rewriteheap.c
M src/backend/backup/walsummary.c
M src/backend/replication/walsender.c
M src/backend/storage/file/fd.c
M src/bin/pg_upgrade/slru_io.c

postgres_fdw: Report ANALYZE to pgstats after importing statistics.

commit   : bb4142fb68cfab35b7c5f8db7645196c50662631    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Tue, 7 Jul 2026 18:40:00 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Tue, 7 Jul 2026 18:40:00 +0900    

Click here for diff

Commit 28972b6fc should have done this, but didn't.  
  
While at it, remove an extra blank line in fetch_remote_statistics()  
introduced by that commit.  
  
Reported-by: Chao Li <lic@highgo.com>  
Co-authored-by: Chao Li <lic@highgo.com>  
Co-authored-by: Etsuro Fujita <etsuro.fujita@gmail.com>  
Discussion: https://postgr.es/m/6ED81190-B398-44C9-A1E9-8EFE4ED183AF%40gmail.com  
Backpatch-through: 19  

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

Update GROUP BY ALL comments about window functions

commit   : 2ce74583652fb4cd29299a220ff31043adf5c96e    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 7 Jul 2026 08:37:15 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 7 Jul 2026 08:37:15 +0200    

Click here for diff

When GROUP BY ALL was added in commit ef38a4d9756, the SQL standard  
working draft was silent on what to do with window functions.  This  
has now been fixed in the SQL standard working draft.  Update the  
documentation and code comments about that.  
  
Also make the documentation more specific that we are only talking  
about aggregate functions referring to the same query level, which is  
another thing that has been made more precise in the SQL standard  
working draft since.  
  
The PostgreSQL implementation was already doing the right thing for  
both aspects, so no functionality changes.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/CAHM0NXjz0kDwtzoe-fnHAqPB1qA8_VJN0XAmCgUZ%2BiPnvP5LbA%40mail.gmail.com  

M doc/src/sgml/queries.sgml
M doc/src/sgml/ref/select.sgml
M src/backend/parser/parse_clause.c

Enforce RETURNING typmod on SQL/JSON DEFAULT behavior expressions

commit   : 4c75cc786301886145bc1a450977cbd024814ef5    
  
author   : Amit Langote <amitlan@postgresql.org>    
date     : Tue, 7 Jul 2026 08:14:04 +0900    
  
committer: Amit Langote <amitlan@postgresql.org>    
date     : Tue, 7 Jul 2026 08:14:04 +0900    

Click here for diff

transformJsonBehavior() coerced an ON EMPTY / ON ERROR DEFAULT  
expression only when its type differed from the RETURNING type's OID.  
When the base type matched but the RETURNING type carried a type  
modifier (e.g. numeric(4,1) or varchar(3)), the coercion that enforces  
the typmod was skipped, so the DEFAULT value could violate the  
declared type:  
  
    SELECT JSON_VALUE(jsonb '{}', '$.a'  
                      RETURNING numeric(4,1) DEFAULT 99999.999 ON EMPTY);  
  
returned 99999.999, which 99999.999::numeric(4,1) would reject; the  
value could even be stored into a numeric(4,1) column, as later  
coercions trust its already-correct type label.  
  
Fix by also coercing when the RETURNING type has a typmod, except for  
a NULL constant.  coerce_to_target_type() is a no-op when the typmod  
already matches.  The matching-OID short-circuit dates to 74c96699be3.  
  
Reported-by: Ewan Young <kdbase.hack@gmail.com>  
Author: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/CAON2xHPO9f4cAmyGn1mQ=VqoS7wN5rz4yOiqudxX78zninZpCw@mail.gmail.com  
Backpatch-through: 17  

M src/backend/parser/parse_expr.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/sqljson_jsontable.sql
M src/test/regress/sql/sqljson_queryfuncs.sql

Use PG_MODULE_MAGIC_EXT in newly introduced modules

commit   : 4c84545067822bcc8697b7d8f3082c5cf1937d1b    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 6 Jul 2026 15:34:12 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Mon, 6 Jul 2026 15:34:12 -0400    

Click here for diff

We forgot to use the PG_MODULE_MAGIC_EXT in some newly added modules:  
pg_plan_advice, pg_stash_advice and the pgrepack output plugin and  
instead used the older PG_MODULE_MAGIC macro.  
  
Author: Andreas Karlsson <andreas@proxel.se>  
Discussion: http://postgr.es/m/ad7b910c-d145-4120-994d-2e55c456aa75@proxel.se  
Backpatch-through: 19  

M contrib/pg_plan_advice/pg_plan_advice.c
M contrib/pg_stash_advice/pg_stash_advice.c
M src/backend/replication/pgrepack/pgrepack.c

Fix mishandling of leading '\' in nondeterministic LIKE.

commit   : 42b7ff3aaefa5f63b4890679a283f83f1a4acb00    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 14:47:58 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 14:47:58 -0400    

Click here for diff

The loop in MatchText() processed a leading '\' without regard to  
nondeterministic locales, which is problematic if what the '\'  
precedes is an ordinary character that should be subject to  
nondeterministic matching.  We'd insist on a literal match for it,  
which is not right and is not like what happens with a '\' that  
follows some ordinary characters.  Worse, we'd then advance the text  
and pattern pointers by one byte, so that if the escaped character  
is multibyte the next loop iteration would take the nondeterministic  
code path starting at a point within the character.  That could very  
possibly cause pg_strncoll() to misbehave.  
  
The fix is quite simple: move the stanza that handles '\' down past  
the one that handles nondeterminism.  The stanzas for '%' and '_'  
are fine where they are, but the '\' stanza is only correct for  
deterministic matching.  The logic for nondeterministic cases is  
already prepared to do the right things with a '\'.  
  
While here, I replaced tests of "locale && !locale->deterministic"  
with a boolean local variable, reasoning that those are in the hot  
loop paths so saving a branch and indirect fetch is worth the  
trouble.  I also improved a number of related comments.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/391592.1783187986@sss.pgh.pa.us  
Backpatch-through: 18  

M src/backend/utils/adt/like_match.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql

Fix LIKE matching with nondeterministic collations and backslashes.

commit   : d6ffcae32a10bd9b53fcfe7be507ba00c6083acc    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 14:35:21 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 14:35:21 -0400    

Click here for diff

Commit 85b7efa1c added support for LIKE with nondeterministic  
collations, but it included a bug in the de-escaping logic for  
literal pattern substrings.  That unconditionally skipped all  
backslashes, but when it encounters '\\' it should emit the second  
backslash as a de-escaped character.  That led to acting as though  
the escaped backslash was not there.  
  
Bug: #19474  
Reported-by: Bowen Shi <zxwsbg12138@gmail.com>  
Author: Nitin Motiani <nitinmotiani@google.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19474-5b86a95f3d9a7ecb@postgresql.org  
Discussion: https://postgr.es/m/CAH5HC94yU+K8Gcdy12M5BS8gwD_SXLSHzc9k5tNk7JDnpBiFMA@mail.gmail.com  
Backpatch-through: 18  

M src/backend/utils/adt/like_match.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql

Make PLy_elog() use pg_integer_constant_p().

commit   : 431896a84eb127b4fe1b609a56c67e28105136c7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 13:48:42 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 13:48:42 -0400    

Click here for diff

This macro is supposed to work like ereport().  But when  
59c2f03d1 adjusted ereport() to be more MSVC-friendly,  
it missed updating this copy of the logic.  
  
Discussion: https://postgr.es/m/754534.1783264708@sss.pgh.pa.us  
Backpatch-through: 19  

M src/pl/plpython/plpy_elog.h

Fix LIKE/regex optimization for indexscan with exact-match pattern.

commit   : 2d7808e6fc2cb5d7a964e7a24801a6fa133a3261    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 13:06:21 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 6 Jul 2026 13:06:21 -0400    

Click here for diff

Commit 85b7efa1c introduced support for LIKE with non-deterministic  
collations.  By moving some conditionals around, it accidentally broke  
the optimization for converting a LIKE or regex exact-match pattern  
to an equality indexqual when the index collation doesn't match the  
expression collation.  That should be allowed if the expression  
collation is deterministic.  This patch re-introduces the optimization  
for that common case.  
  
One important beneficiary of this optimization is the "\d tablename"  
command in psql.  Without this fix that will do a seqscan on pg_class  
instead of an index point lookup.  
  
Reported-by: Andres Freund <andres@anarazel.de>  
Author: Jelte Fennema-Nio <postgres@jeltef.nl>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/DHBQIZX8SZVI.ZX614ZMFL645@jeltef.nl  
Backpatch-through: 18  

M src/backend/utils/adt/like_support.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/expected/collate.out
M src/test/regress/sql/collate.icu.utf8.sql
M src/test/regress/sql/collate.sql

Prevent satisfies_hash_partition from crashing with VARIADIC NULL.

commit   : e8914ec22f8f254b84523d671afb60125d35c9b1    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Mon, 6 Jul 2026 12:12:41 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Mon, 6 Jul 2026 12:12:41 -0400    

Click here for diff

Commit f3b0897a1213f46b4d3a99a7f8ef3a4b32e03572 fixed some  
related problems, but overlooked this one. That commit first  
appeared in PostgreSQL 11, so back-patch to all supported branches.  
  
Backpatch-through: 14  
Discussion: http://postgr.es/m/CA+TgmobsvQw3F+KRYT83=N3teh8D2t-oPR=U06QDZJE3viCJRg@mail.gmail.com  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  

M src/backend/partitioning/partbounds.c
M src/test/regress/expected/hash_part.out
M src/test/regress/sql/hash_part.sql

Remove switch statements in vector8_shift_{left,right}.

commit   : 763ee7ea00b02592b5fb9572d77b82a1f6f052b9    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 6 Jul 2026 11:40:02 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Mon, 6 Jul 2026 11:40:02 -0500    

Click here for diff

In commit ec8719ccbf, I added switch statements with all expected  
shift counts to vector8_shift_{left,right} because vshlq_n_u32()  
and vshrq_n_u32() require integer literals.  But we can use  
vshlq_u32() instead for both cases, which does not require an  
integer literal, thereby avoiding the need for the switch  
statements.  This compiles to the same machine code on newer  
versions of popular compilers.  
  
Reviewed-by: John Naylor <johncnaylorls@gmail.com>  
Discussion: https://postgr.es/m/akWxkA-mszMm57cV%40nathan  

M src/include/port/simd.h

Add comment to describe the various frontend cancel methods

commit   : cde6ede7137e3f2399e3f60d3b7af975cfa7ddac    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 6 Jul 2026 19:11:04 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Mon, 6 Jul 2026 19:11:04 +0300    

Click here for diff

Author: Jelte Fennema-Nio <postgres@jeltef.nl>  
Discussion: https://www.postgresql.org/message-id/DJPAH0WPJV3K.1PYZ8P0QXZVMX@jeltef.nl  

M src/fe_utils/cancel.c

Remove apparent support for SECURITY LABEL ON PROPERTY GRAPH

commit   : 73dfe79fd6034b1e7e41e83d9c82c166dba8eb67    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 6 Jul 2026 11:44:55 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 6 Jul 2026 11:44:55 +0200    

Click here for diff

Commit 2f094e7ac69 added a mention of SECURITY LABEL ON PROPERTY GRAPH  
to the SECURITY LABEL reference page, and it added support to psql tab  
completion.  However, security labels on property graphs are not  
actually supported (per SecLabelSupportsObjectType()).  The syntax  
does work, but that is just a result of how gram.y is factored.  We  
don't document or tab-complete the syntax of SECURITY LABEL for other  
object types that are not actually supported, so it was inconsistent  
to do this for property graphs.  Thus, remove this.  
  
Reported-by: Noah Misch <noah@leadboat.com>  
Discussion: https://www.postgresql.org/message-id/flat/20260704221210.08.noahmisch%40microsoft.com  

M doc/src/sgml/ref/security_label.sgml
M src/bin/psql/tab-complete.in.c

Forbid generated columns in FOR PORTION OF

commit   : e994f956e4864f424320f5243b9af11e173ad398    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 6 Jul 2026 09:19:02 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 6 Jul 2026 09:19:02 +0200    

Click here for diff

With virtual generated columns there is no column to assign to, and we  
shouldn't assign directly to stored generated columns either.  (Once  
we have PERIODs, we will allow a stored generated column here, but we  
will assign to its start/end inputs.)  
  
We can't do this in parse analysis, because views haven't yet been  
rewritten, so they mask generated columns.  
  
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>  
Discussion: https://www.postgresql.org/message-id/agOOykf2HV26yVfU%40nathan  

M doc/src/sgml/ddl.sgml
M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/for_portion_of.out
M src/test/regress/sql/for_portion_of.sql

Fix qual pushdown past grouping with mismatched equivalence

commit   : 44fb59fc605ea0eabd58029bb8dc2c2416c42c3c    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Mon, 6 Jul 2026 16:13:14 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Mon, 6 Jul 2026 16:13:14 +0900    

Click here for diff

The planner has two optimizations that move a qual clause across a  
grouping boundary: subquery_planner transfers HAVING clauses to WHERE  
so they can be evaluated before aggregation, and qual_is_pushdown_safe  
pushes outer restriction clauses into a subquery past its DISTINCT,  
DISTINCT ON, window PARTITION BY, or set-operation grouping layer.  
Both produce wrong results when the moved clause's equivalence  
relation disagrees with the grouping's, since the clause then filters  
rows the grouping would have merged.  
  
The disagreement has two forms.  A type may belong to multiple btree  
opfamilies whose equality operators disagree (e.g. record_ops vs  
record_image_ops); or the grouping may use a nondeterministic  
collation, where comparing the column under a different collation, or  
wrapping it in a function or operator, can distinguish values the  
collation considers equal.  Because we cannot prove an arbitrary  
expression preserves that equality, a grouping column with a  
nondeterministic collation is safe to push only as a direct operand of  
a comparison under its own collation.  
  
Fix both call sites through a shared walker parameterized by a  
callback that maps each Var to the grouping equality operator for its  
column (or InvalidOid for non-grouping Vars).  For HAVING, the  
callback recovers the SortGroupClause's eqop via the GROUP Var's  
varattno, which requires running before flatten_group_exprs while  
havingQual still contains GROUP Vars.  For subquery pushdown, the  
callback recovers the eqop from subquery->distinctClause, a window's  
partitionClause, or any grouping node in the SetOperationStmt tree.  
The walker fires only when there is an equivalence boundary to cross,  
gated by either the existing UNSAFE_NOTIN_DISTINCTON_CLAUSE and  
UNSAFE_NOTIN_PARTITIONBY_CLAUSE flags or by a recursive check for any  
grouping node in the set-op tree.  
  
Back-patch to v18 only.  The HAVING half relies on the RTE_GROUP  
mechanism introduced in v18 (commit 247dea89f), which is what lets us  
identify grouping expressions via GROUP Vars on pre-flatten  
havingQual.  Pre-v18 branches lack that machinery, so a back-patch  
there would need a different approach.  Given the absence of field  
reports of these bugs on back branches, the risk of carrying a  
different fix on stable branches is not justified.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: Thom Brown <thom@linux.com>  
Reviewed-by: Florin Irion <irionr@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Tender Wang <tndrwang@gmail.com>  
Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com>  
Discussion: https://postgr.es/m/CAMbWs4-QLZpn3UVOpeG2fOxxhdnkDNMZ_3Zcm3dqJwRAphz68g@mail.gmail.com  
Backpatch-through: 18  

M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/util/clauses.c
M src/backend/utils/cache/lsyscache.c
M src/include/optimizer/clauses.h
M src/test/regress/expected/aggregates.out
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/expected/subselect.out
M src/test/regress/sql/aggregates.sql
M src/test/regress/sql/collate.icu.utf8.sql
M src/test/regress/sql/subselect.sql
M src/tools/pgindent/typedefs.list

Emit a warning when io_min_workers exceeds io_max_workers

commit   : 9d1188f29865e66c4196578501e74e8c815fba8d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jul 2026 11:37:36 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jul 2026 11:37:36 +0900    

Click here for diff

When io_min_workers is set strictly higher than io_max_workers, the  
minimum has no effect since the pool will never grow past  
io_max_workers.  Previously this was silently accepted, which could  
be confusing for users expecting at least io_min_workers workers to  
always be running.  
  
In order to avoid noise in the server logs, the following restrictions  
are in place:  
- The only process printing the WARNING is the IO worker with ID 0, on  
startup and reload, which is we know the only process always running  
when using IO workers.  
- At reload, the message shows only if one of the bounds has changed.  
  
Note that this commit reuses a log message updated by 7905416eef9b.  
  
Author: Baji Shaik <baji.pgdev@gmail.com>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Discussion: https://postgr.es/m/CA+fm-RO_O7-XThg2qjj=ir35x9nOFbZYu07gttqAbM5T88QB4Q@mail.gmail.com  

M src/backend/storage/aio/method_worker.c

Improve checks and error messages of pgstat_register_kind()

commit   : a924407ce0264ccb8fcea0de9c6f0573d24b57a7    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jul 2026 10:49:28 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jul 2026 10:49:28 +0900    

Click here for diff

pgstat_register_kind() did not validate that required callbacks are  
set, which could lead to NULL pointer dereferences when trying to  
register a stats kind.  This adds a couple of checks:  
- Fox fixed-sized kinds, init_shmem_cb, reset_all_cb, and snapshot_cb  
are required.  
- For variable-sized kinds, flush_pending_cb is called when there is  
pending data, pending_size being required.  
  
These issues should be easy to notice for someone developing an  
extension that relies on the custom pgstats APIs.  No backpatch is done  
as it is mainly a life improvement.  
  
Author: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/CAA5RZ0uNoe=xT7QsU1K0mMRg-QAwPtupPWZ2J3weM2PjVL2tiA@mail.gmail.com  

M src/backend/utils/activity/pgstat.c

amcheck: Fix memory leak with gin_index_check()

commit   : e939332c6b1c7750f161424d8fbf8989b11cb5f6    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jul 2026 09:32:25 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 6 Jul 2026 09:32:25 +0900    

Click here for diff

"prev_tuple" was overwritten with a new tuple coming from  
CopyIndexTuple() on each loop, leaking memory for every tuple processed  
on entry tree pages.  The function uses a dedicated memory context, but  
this could leave unused large areas of memory while processing a large  
GIN index, the larger the worse.  
  
Oversight in 14ffaece0fb5.  
  
Author: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/CALdSSPjTS6TYe5=5NfMUBYZyQu5cn=ABL6K5_OZjzGWqnwXeBw@mail.gmail.com  
Backpatch-through: 18  

M contrib/amcheck/verify_gin.c

Fix psql's pager selection for wrapped expanded output.

commit   : 07abbc93ba5ba41b60927221db92bc73f75fd1ba    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 5 Jul 2026 18:11:40 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 5 Jul 2026 18:11:40 -0400    

Click here for diff

psql decided whether to use the pager in expanded output without  
accounting for possible wrapping of column values.  This could  
allow it to not use the pager in cases where it should do so.  
  
To fix, move the IsPagerNeeded decision in print_aligned_vertical()  
down until after the wrapped data width is known.  Then, if we're in  
wrapped mode, prepare a width_wrap array specifying that width (which,  
in vertical mode, is the same for all columns).  
  
This is fixing an omission in 27da1a796, so back-patch to v19  
where that came in.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Erik Wienhold <ewie@ewie.name>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/A44110E7-6A03-4C67-95AD-527192A6C768@gmail.com  
Backpatch-through: 19  

M src/bin/psql/t/030_pager.pl
M src/fe_utils/print.c

Simplify dxsyn_lexize().

commit   : 9f03dab4574bd2820eec6902c2ef12b28c706733    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 5 Jul 2026 16:22:40 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 5 Jul 2026 16:22:40 -0400    

Click here for diff

There's no need to create and free a temporary copy of the input,  
since str_tolower() is already able to cope with not-certainly-  
nul-terminated input.  (Before v18, copying was needed because  
this code used lowerstr(), but now we can do without.)  
  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19525-b0be8e4eb7dbaf07@postgresql.org  

M contrib/dict_xsyn/dict_xsyn.c

Fix properties orphaned by dropping a label

commit   : 0e4f0827f63900374ce7352f1f9e4c39363218d0    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 5 Jul 2026 13:47:18 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sun, 5 Jul 2026 13:47:18 +0200    

Click here for diff

AlterPropGraph() cleans up pg_propgraph_property entries that are  
orphaned by dropping an element or by dropping properties associated  
with an element.  But it did not clean up pg_propgraph_property  
entries that are orphaned by dropping labels associated with an  
element.  Fix this missing case.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Author: zengman <zengman@halodbtech.com>  
Discussion: https://www.postgresql.org/message-id/flat/tencent_76F6ACA2364EAA1E5DBD7A47%40qq.com  

M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/sql/create_property_graph.sql

Disallow renaming a rule to "_RETURN".

commit   : a8c2547eaac73cd6d499a4ab151f0401bf647f56    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 4 Jul 2026 11:34:26 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 4 Jul 2026 11:34:26 -0400    

Click here for diff

ON SELECT rules must be named "_RETURN", while other kinds of rules  
must not be; this ancient restriction is depended on by various client  
code.  We successfully enforced this convention in most places, but  
ALTER RULE allowed renaming a non-SELECT rule to "_RETURN".  Notably,  
that would break dump/restore, since the eventual CREATE RULE command  
would reject the name.  
  
While at it, remove DefineQueryRewrite's hack to substitute "_RETURN"  
for the convention that was used before 7.3.  We dropped other  
server-side code that supported restoring pre-7.3 dumps some time ago  
(notably in e58a59975 and nearby commits), but this bit was missed.  
  
Bug: #19543  
Reported-by: Adam Pickering <adamkpickering@gmail.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19543-461228e77f3b32fc@postgresql.org  
Backpatch-through: 14  

M src/backend/rewrite/rewriteDefine.c
M src/test/regress/expected/rules.out
M src/test/regress/sql/rules.sql

Make property graph object descriptions better translatable

commit   : e0ff7fd9aa2e6f77c38825e71200ced742220d55    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 23:32:20 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 23:32:20 +0200    

Click here for diff

getObjectDescription() currently constructs property graph-related  
object descriptions incrementally with appendStringInfo().  This  
effectively fixes the word order in English, which makes the messages  
difficult to translate naturally into languages such as Japanese.  
  
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/20260528.121622.1662808269492494574.horikyota.ntt%40gmail.com  

M src/backend/catalog/objectaddress.c

Remove btree_gist's useless logic for encoding-aware truncation.

commit   : b82d69abf64fc0c2fc6fdd491d7cecb8244680c2    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 15:31:58 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 15:31:58 -0400    

Click here for diff

gbt_var_node_cp_len() contained logic to ensure that its choice of  
a common prefix length didn't truncate away part of a multibyte  
character.  However, that was really dead code, because we have not  
allowed truncation of text-string data types since ef770cbb6, and  
it seems unlikely that that behavior could ever get resurrected.  
The code is still reachable via gbt_var_penalty, but for that  
usage it hardly matters if we break in the middle of a multibyte  
character: we're just calculating a small correction factor that  
is arguably bunkum anyway in non-C locales.  
  
Hence, delete said code.  That actually removes all need for  
gbtree_vinfo.eml, which allows const-ification of the gbtree_vinfo  
structs in which we were changing it, which removes one headache  
for future attempts to thread-ify the backend.  
  
(Curiously, all this infrastructure was itself added by ef770cbb6.  
Not sure why Teodor didn't see the contradiction.)  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn  

M contrib/btree_gist/btree_bit.c
M contrib/btree_gist/btree_bytea.c
M contrib/btree_gist/btree_numeric.c
M contrib/btree_gist/btree_text.c
M contrib/btree_gist/btree_utils_var.c
M contrib/btree_gist/btree_utils_var.h

Tighten up btree_gist's handling of truncated bounds.

commit   : fea9c1884b2009a94287989e961d6493e22bf656    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 15:25:19 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 15:25:19 -0400    

Click here for diff

Truncating an internal node's upper bound can cause it to compare  
less than some values that in fact are included in the represented  
leaf page.  So we need a hack to make sure it looks large enough  
to include all values that could be on the page.  But there's no  
equivalent issue for the lower bound.  The fact that the code did  
fuzzy comparisons for the lower bound too seems to be the result of  
fuzzy thinking.  Or maybe there was a desire to not assume too much  
about what the datatype's comparison rule is; but we've already  
fully bought into the premise that internal keys compare like bytea.  
  
Hence, remove the useless check against the key's lower bound in  
gbt_var_node_pf_match.  The comparable check in gbt_var_penalty may  
also be useless, but I'm not quite sure.  In any case that seems  
negligible from a performance standpoint, so I left it alone.  
  
Also, in the strategy cases in gbt_var_consistent that only  
require comparisons to the lower bound, there's no need to call  
gbt_var_node_pf_match at all.  Refactor that logic by inventing  
macros lower_is_below_query and upper_is_above_query to directly  
express what we need to test.  I also took this opportunity to flip  
all the tests around to be "indexkey OP query" rather than mostly  
being the reverse: IMO this makes the code less confusing since the  
tests now match the names of the strategies.  
  
Also, in the name of consistency, make gbt_num_consistent look  
like that too.  There's no functional change there, but this  
should be more readable going forward.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn  

M contrib/btree_gist/btree_utils_num.c
M contrib/btree_gist/btree_utils_var.c

Sync signatures of gbt_var_consistent() and gbt_num_consistent().

commit   : 4b808ed77cd95dd1d6bf7acdb8ee4f8eb027422c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 14:23:22 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 14:23:22 -0400    

Click here for diff

For some odd reason we pass the strategy number to gbt_num_consistent  
as "const StrategyNumber *strategy".  There's no reason for that:  
it almost certainly costs more at both callers and callee to pass a  
pointer than to pass a small integer value.  And it's inconsistent  
with gbt_var_consistent(), so fix it.  
  
gbt_var_consistent() had its own infelicity, which was not marking  
the input "key" value const.  Fix that too while we're here.  
  
This is primarily cosmetic, so I see no need to backpatch.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn  

M contrib/btree_gist/btree_bool.c
M contrib/btree_gist/btree_cash.c
M contrib/btree_gist/btree_date.c
M contrib/btree_gist/btree_enum.c
M contrib/btree_gist/btree_float4.c
M contrib/btree_gist/btree_float8.c
M contrib/btree_gist/btree_inet.c
M contrib/btree_gist/btree_int2.c
M contrib/btree_gist/btree_int4.c
M contrib/btree_gist/btree_int8.c
M contrib/btree_gist/btree_interval.c
M contrib/btree_gist/btree_macaddr.c
M contrib/btree_gist/btree_macaddr8.c
M contrib/btree_gist/btree_oid.c
M contrib/btree_gist/btree_time.c
M contrib/btree_gist/btree_ts.c
M contrib/btree_gist/btree_utils_num.c
M contrib/btree_gist/btree_utils_num.h
M contrib/btree_gist/btree_utils_var.c
M contrib/btree_gist/btree_utils_var.h
M contrib/btree_gist/btree_uuid.c

REPACK CONCURRENTLY: Initialize the range table more honestly

commit   : 5ee9d7c299f2fe2f29db18c6448f798950efe22e    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 3 Jul 2026 20:04:48 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 3 Jul 2026 20:04:48 +0200    

Click here for diff

We were skipping a bunch of things that are mostly unnecessary for  
REPACK.  However, one thing that seems would be better to pass closer to  
truth, is the updatedCols bitmapset in the range table entry for the  
repacked table.  Cons up an RTE and install it into the EState.  
  
This only has an effect on btree indexes, because certain operations are  
optimized in the case of unchanged columns; and even then, correctnesss  
is not being compromised.  
  
The values we pass after this commit are not fully trustworthy either,  
because we simply say "all columns were updated" for all insert/updates,  
regardless of whether their values were actually modified or not.  
However, this way we err to the side of caution rather than to the  
opposite direction as we were originally doing.  This could be refined  
in the future, but there's a trade-off: determining whether the column  
was in fact updated could be expensive.  
  
Author: Antonin Houska <ah@cybertec.at>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/18222.1782126731@localhost  

M src/backend/commands/repack.c

Fix btree_gist's NotEqual strategy on internal index pages.

commit   : eef644e57c38a79eb29bf9f3f05efbcee8fbdfce    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 13:50:14 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 13:50:14 -0400    

Click here for diff

gbt_var_consistent() handled the <> (BtreeGistNotEqual) strategy without  
distinguishing leaf from internal pages, unlike every other strategy.  
In particular, it tried to apply the datatype-specific f_eq method,  
which is completely wrong since internal keys might not have the same  
representation as leaf keys.  This led to OOB reads and potentially  
crashes, and most likely to wrong query results as well.  
  
On leaf pages we can apply the inverse of what the Equal strategy does.  
On internal pages, use a correct implementation of what the previous  
code intended: we can descend if the query value equals both bounds,  
*so long as the bounds aren't truncated*.  With truncated bounds we  
don't quite know the range of what's below, so we must always descend.  
  
Adjust the code in gbt_num_consistent() to look similar, too.  This  
fixes a performance buglet in that there's no need to do two comparisons  
on a leaf entry, but the main point is just to keep code consistency.  
  
Reported-by: 王跃林 <violin0613@tju.edu.cn>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn  
Backpatch-through: 14  

M contrib/btree_gist/btree_utils_num.c
M contrib/btree_gist/btree_utils_var.c

Reverse-engineer some documentation for btree_gist's varlena modules.

commit   : d6284bbd152c1ea9e73bc77d6cb26bbf636d569b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 13:18:13 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 13:18:13 -0400    

Click here for diff

There are a number of rather subtle points about the behavior of  
this code, which its original authors did not deign to document.  
Try to improve that.  In particular, explain how internal and leaf  
keys can differ and what the restrictions are on that.  
  
This work arose from trying to fix some bugs, and in the process  
I believe I've identified some more, but this patch does not attempt  
to fix anything, only document it.  I did make a few purely cosmetic  
code changes, such as removing dead (and confusing!) initializations  
of variables and choosing more appropriate types for some pointers.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn  

M contrib/btree_gist/btree_bit.c
M contrib/btree_gist/btree_bytea.c
M contrib/btree_gist/btree_numeric.c
M contrib/btree_gist/btree_text.c
M contrib/btree_gist/btree_utils_var.c
M contrib/btree_gist/btree_utils_var.h

Use the proper comparator in gbt_bit_ssup_cmp.

commit   : a9fa6c69e3f5405866a0ebed27597e80760abc77    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 13:11:14 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Jul 2026 13:11:14 -0400    

Click here for diff

If we're dealing with leaf entries, the function to call is bitcmp  
not byteacmp.  Using byteacmp didn't lead to any obvious failure,  
but it did result in sorting the entries in a way not matching the  
datatype's actual sort order.  Hence the constructed index would be  
less efficient than one would expect, and in particular worse than  
what you got before this code was added in v18 (by commit e4309f73f).  
  
We might want to recommend that users reindex btree_gist indexes  
on bit/varbit columns.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn  
Backpatch-through: 18  

M contrib/btree_gist/btree_bit.c

Resolve unknown-type literals in GRAPH_TABLE COLUMNS

commit   : efd7d8d7d495472b2e5091af325474f05853214b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 16:58:31 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 16:58:31 +0200    

Click here for diff

The unknown-type literals in the COLUMNS clause of a GRAPH_TABLE are  
now resolved to the appropriate types.  Without that, this could cause  
various failures.  
  
Author: Satya Narlapuram <satyanarlapuram@gmail.com>  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcyKNWyzDoKMxiZNjv7C-wAxs8y0ZoNkOV137Y%2Bnk3UXg%40mail.gmail.com  

M src/backend/parser/parse_clause.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql

Prevent access to other sessions' empty temp tables

commit   : c40819ebf954eefe8ec35c210b8a3d7a7a7aaea0    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Fri, 3 Jul 2026 15:53:03 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Fri, 3 Jul 2026 15:53:03 +0300    

Click here for diff

Commit ce146621 ensures that ERROR is raised if a session tries to read  
pages of another session's temp table.  But there is a corner case where  
the other session's temp table is empty -- in this case the INSERT  
command bypasses our checks and executes without any errors.  
  
Such behavior is inconsistent and erroneous: it leaves an invalid buffer  
in the temp buffers pool.  Since the buffer was created for another  
session's temp table, we get an error "no such file or directory" when  
trying to flush it.  
  
This commit fixes it by adding a RELATION_IS_OTHER_TEMP check in the  
relation-extension path.  
  
Backpatch to 16, because it is the first release after 31966b151e6, which  
introduced a separate local relation extension function  
ExtendBufferedRelLocal(), which lacks of RELATION_IS_OTHER_TEMP() check.  
As this fix introduces more checks to 013_temp_obj_multisession.pl, backpatch  
the whole test script to 16.  
  
Discussion: https://postgr.es/m/CAJDiXgiX2XZBHDNo%2BzBbvku%2BtchrUurvPRaN1_40mEQ1_sG90g%40mail.gmail.com  
Author: Daniil Davydov <3danissimo@gmail.com>  
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>  
Reviewed-by: Imran Zaheer <imran.zhir@gmail.com>  
Reviewed-by: ZizhuanLiu X-MAN <44973863@qq.com>  
Backpatch-through: 16  

M src/backend/storage/buffer/bufmgr.c
M src/include/utils/rel.h
M src/test/modules/test_misc/t/013_temp_obj_multisession.pl

Fix handling of dropping a property not associated with the given label

commit   : 96418a6da9d0e120c30f9b6c2c2bd8bbb0a98d00    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 16:06:29 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 16:06:29 +0200    

Click here for diff

When dropping a property by name from a label, the code checked only  
whether the property existed in the graph's property catalog.  It did  
not verify that the property was actually associated with the given  
label, resulting in passing InvalidOid to performDeletion().  Fix it  
by explicilty checking the label property association.  
  
While at it also rearrange the code so as to avoid multiple ereport  
calls for the same error in the same block.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/1DA5D52A-4AFA-426E-83F7-42ED974D682B%40gmail.com  

M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/sql/create_property_graph.sql

Fix tracing of BackendKeyData and CancelRequest

commit   : b22b619056e8dc6f5f9966f8b9781bdc7cbec897    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 3 Jul 2026 14:57:35 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Fri, 3 Jul 2026 14:57:35 +0300    

Click here for diff

BackendKeyData length was increased from 4 bytes to a variable-length  
length (up to 256 bytes) in a460251f0a. However, pqTrace still traces  
it as a 4 bytes key, leading to a "mismatched message length" warning  
message. The same issue impacts the tracing of CancelRequest.  
  
This patch fixes the issue by using pqTraceOutputNchar instead of  
pqTraceOutputInt32 in both cases.  
  
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>  
Discussion: https://www.postgresql.org/message-id/CAO6_Xqo6gTv9=76H=k2qDRFU+KHuBiY2S=bQynEr6J8gS7L6xA@mail.gmail.com  
Backpatch-through: 18  

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

Fix REPACK CONCURRENTLY for stored generated columns

commit   : 3be823486f2c9f405fc754ac0ece3ce412aee105    
  
author   : Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 3 Jul 2026 12:22:37 +0200    
  
committer: Álvaro Herrera <alvherre@kurilemu.de>    
date     : Fri, 3 Jul 2026 12:22:37 +0200    

Click here for diff

In order to replay concurrent changes, REPACK CONCURRENTLY needs the  
pg_attrdef tuples for the transient table to be there, in case a tuple  
is modified concurrently with REPACK and requires to store the value  
from the generated column (which, with the current arrangements, means  
all tuples concurrently updated or inserted).  Fix by creating a copy of  
them from the original table.  Add a test that tickles the bug.  
  
Author: Antonin Houska <ah@cybertec.at>  
Reported-by: Ewan Young <kdbase.hack@gmail.com>  
Diagnosed-by: Ewan Young <kdbase.hack@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Backpatch-through: 19  
Discussion: https://postgr.es/m/CAON2xHMrELwx9vKg6niSf8fMBA=-MGXmG=MPQU6+vMVhGjF8kQ@mail.gmail.com  

M src/backend/commands/repack.c
M src/test/modules/injection_points/specs/repack.spec

Prevent dropping the last label from a property graph element

commit   : 7afa11feca6c4e48d01890580564d55cf226fe02    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 11:52:42 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 3 Jul 2026 11:52:42 +0200    

Click here for diff

Per SQL/PGQ standard, every graph element must have at least one  
label.  When dropping a label from a graph element, ensure that there  
exists at least one other label on the element.  If the label being  
dropped is the only label on the element, raise an error.  
  
We hold a ShareRowExclusiveLock when modifying a property graph.  
Hence the label will not be dropped even when multiple labels are  
being dropped concurrently.  
  
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>  
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>  
Discussion: https://www.postgresql.org/message-id/CAHg+QDeP=mTHTV48R23zKMy1SBmCKZ_L7-z5zKnYyw+K0x-gCg@mail.gmail.com  

M doc/src/sgml/ref/alter_property_graph.sgml
M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/sql/create_property_graph.sql

Add commit fdad19e1cf to .git-blame-ignore-revs.

commit   : 617c7574055009fc6678a0f17bc9160d94e58607    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Fri, 3 Jul 2026 14:05:21 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Fri, 3 Jul 2026 14:05:21 +0530    

Click here for diff

M .git-blame-ignore-revs

Fix log_statement_max_length test with verbose logs

commit   : 9bfbf5bf61901b57d86fab20559b7973b5a83298    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 14:41:44 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 14:41:44 +0900    

Click here for diff

Buildfarm member prion reported a failure in the test added by commit  
c8bd8387c27 to verify that the server logs an empty statement body  
when log_statement_max_length = 0.  
  
The test assumed that "statement:" would appear immediately after  
"LOG:" in the logged statement message. However, prion runs with  
log_error_verbosity = verbose, which inserts the SQLSTATE between  
"LOG:" and the message text. As a result, the test failed even though  
the server behaved correctly.  
  
Per buildfarm member prion.  
  
Discussion: https://postgr.es/m/CAHGQGwFiQKwvLVG+U0WWNo2kgkQ88FVGhYH_MBZu9Y0SJ8BjDw@mail.gmail.com  

M src/test/modules/test_misc/t/014_log_statement_max_length.pl

psql: Fix \df tab completion for procedures

commit   : 6d4ca6de97770cdaee18517dd2f8fe8f4ecee187    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 13:46:35 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 13:46:35 +0900    

Click here for diff

Commit fb421231daa extended \df to include procedures, but its tab  
completion continued not to show procedures.  
  
Update \df tab completion to include procedures as well.  
  
Backpatch to all supported versions.  
  
Author: Erik Wienhold <ewie@ewie.name>  
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/10fbfdfe-80f6-4ef9-b8b3-f7be0eb53a50@ewie.name  
Backpatch-through: 14  

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

pgindent fix for commit 53e6f51ee

commit   : a5422fe3bd7ecd9c64cf4a8acf5f510b8da676c5    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Fri, 3 Jul 2026 12:31:15 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Fri, 3 Jul 2026 12:31:15 +0900    

Click here for diff

M contrib/pg_plan_advice/pgpa_scan.c

Fix typo in pg_stat_us_to_ms()

commit   : 71fa15af591a3ec61a6bf57fee3a44a7824fba19    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 3 Jul 2026 12:22:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 3 Jul 2026 12:22:14 +0900    

Click here for diff

The function converts microseconds to milliseconds, but the parameter  
name used "ms".  
  
Thinko in ac8d53dae5ae.  
  
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Discussion: https://postgr.es/m/CAHza6qfek15rehnA0GXMCpF2z=Gy6C+3vmcWCMVkU4JiRD8k7g@mail.gmail.com  

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

Switch Get[Local]BufferDescriptor() to use a signed value in input

commit   : ba4134075a822e119e2ca6c2718ff08ae9464a37    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Fri, 3 Jul 2026 12:07:30 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Fri, 3 Jul 2026 12:07:30 +0900    

Click here for diff

GetBufferDescriptor() and GetLocalBufferDescriptor() took a uint32  
buffer index, but every real caller derives the index from a Buffer:  
- Unsigned value for shared buffers.  
- Signed value for local buffers.  
  
Both routines now take in input a signed number, GetBufferDescriptor()  
gaining an assertion checking that the input value is in the range  
allowed by the GUC shared_buffers.  This work is a follow-up of  
e18b0cb7344c, where we found that passing down a value for a local  
buffer was undetected and finished outside the range of NBuffers.  
  
While monitoring all the existing callers of *BufferDescriptor(), the  
only consumer that passes does an unsigned value is ClockSweepTick(),  
whose result is always a module of NBuffers.  
  
Suggested-by: Andres Freund <andres@anarazel.de>  
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>  
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAExHW5uzRMYVZsXXS3HXXT0fG_sNrpUhUqwP4NorhaCqH9JDhA@mail.gmail.com  

M src/include/storage/buf_internals.h

Remove replication slot advice from MultiXact wraparound hints

commit   : 084734ff5a4249f0095771ee1addedbd41a88a18    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 11:16:34 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 11:16:34 +0900    

Click here for diff

Previously, MultiXactId wraparound hints suggested dropping stale  
replication slots. While that advice is appropriate for transaction ID  
wraparound, where replication slots can hold back XID horizons,  
it was misleading for MultiXactId wraparound. Following it could lead  
users to drop replication slots unnecessarily without helping resolve  
the MultiXactId wraparound condition.  
  
MultiXact cleanup is not directly delayed by replication slots.  
Instead, it depends on whether old MultiXactIds can still be seen  
as live by running transactions.  
  
This commit removes the replication slot advice from MultiXactId  
wraparound hints, and documents that stale replication slots are  
normally not relevant to resolving MultiXactId wraparound problems.  
  
Backpatch to all supported branches.  
  
BUG #18876  
Reported-by: Haruka Takatsuka <harukat@sraoss.co.jp>  
Author: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/18876-0d0b53bad5a1f4c1@postgresql.org  
Backpatch-through: 14  

M doc/src/sgml/maintenance.sgml
M src/backend/access/transam/multixact.c
M src/backend/commands/vacuum.c

Add log_statement_max_length GUC to limit logged statement text

commit   : c8bd8387c27ab0e60a7864d231f06e8c3fdbfa8d    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 08:47:18 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Fri, 3 Jul 2026 08:47:18 +0900    

Click here for diff

Very large statements can make server logs grow unexpectedly. This is  
particularly painful when applications accidentally or intentionally  
send huge literal values and statement logging is enabled: the full  
statement text may be written to the log even when DBA sees only  
its leading part is useful for normal operations.  
  
This commit adds log_statement_max_length GUC that limits the number  
of bytes of statement text emitted by statement logging. The setting  
applies to statements logged by log_statement, log_min_duration_statement,  
log_min_duration_sample, and log_transaction_sample_rate. A positive  
value truncates the logged statement body to at most that many bytes,  
zero  logs an empty statement body, and the default value -1 preserves  
the existing behavior of logging statements in full.  
  
Truncation is byte-based, matching the GUC unit, but it clips only  
at multibyte character boundaries so that the log output remains valid.  
This setting does not affect statements logged because of  
log_min_error_statement; handling error-statement logging can be  
considered separately.  
  
Author: Jim Jones <jim.jones@uni-muenster.de>  
Author: Kirill Gavrilov <diphantxm@gmail.com>  
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Reviewed-by: Maxym Kharchenko <maxymkharchenko@gmail.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/CA+E0NR4S+NC6+QHyY_vUuQZMzLhKqczMx-jJVqtjAxF6+=JwAA@mail.gmail.com  

M doc/src/sgml/config.sgml
M src/backend/tcop/postgres.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/utils/guc.h
M src/test/modules/test_misc/meson.build
A src/test/modules/test_misc/t/014_log_statement_max_length.pl

pg_plan_advice: Don't generate FOREIGN_JOIN advice for a single relation.

commit   : 53e6f51eef55e8e4520901e40b4d143d944358c0    
  
author   : Robert Haas <rhaas@postgresql.org>    
date     : Thu, 2 Jul 2026 15:45:22 -0400    
  
committer: Robert Haas <rhaas@postgresql.org>    
date     : Thu, 2 Jul 2026 15:45:22 -0400    

Click here for diff

A foreign scan can target a single relation while still reaching the  
fs_relids branch of pgpa_build_scan() -- for example, when postgres_fdw  
pushes an aggregate down over one foreign table. In that case, no  
advice should be emitted.  
  
Author: Mahendra Singh Thalor <mahi6run@gmail.com>  
Co-authored-by: Robert Haas <rhaas@postgresql.org>  
Discussion: http://postgr.es/m/CAKYtNAofuAJBz6++SeikpCb=Y=MO1QgEuZNJ+KZOP2johF1r4Q@mail.gmail.com  

M contrib/pg_plan_advice/Makefile
M contrib/pg_plan_advice/meson.build
M contrib/pg_plan_advice/pgpa_scan.c
A contrib/pg_plan_advice/t/001_foreign_scan.pl

Add commit d69fdf79b8 to .git-blame-ignore-revs.

commit   : 9ef89fdb61046d0687e92ecea8035caef8a753c0    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    

Click here for diff

M .git-blame-ignore-revs

Run pgindent and pgperltidy for previous 3 commits.

commit   : d69fdf79b8ba7549a9c449e255aab0734cc67a4f    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    

Click here for diff

For ease of review, and to be able to put the indentation changes  
in .git-blame-ignore-revs, I did not fix the indentation of the  
last 3 commits.  Do that now.  
  
Discussion: https://postgr.es/m/adZ4j88Dq9r8y9_9%40nathan  

M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/controldata.c
M src/bin/pg_upgrade/exec.c
M src/bin/pg_upgrade/multixact_rewrite.c
M src/bin/pg_upgrade/pg_upgrade.c
M src/bin/pg_upgrade/relfilenumber.c
M src/bin/pg_upgrade/t/006_transfer_modes.pl
M src/bin/psql/command.c
M src/bin/psql/describe.c

Remove psql support for pre-v10 servers.

commit   : 831bec45924a80cccf20cec7cf4c941874eb96c8    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    

Click here for diff

Per discussion, it seems like a good time to bump the minimum  
supported version for various applications.  Our current policy is  
to support at least 10 previous major versions, so this bumps the  
minimum to v10 for the v20 release.  For reference, the minimum was  
last bumped to v9.2 in 2021 for v15 (see commits 30e7c175b8,  
e469f0aaf3, cf0cab868a, and 492046fa9e).  
  
For ease of review, and to be able to put the indentation changes  
in .git-blame-ignore-revs, I did not fix the indentation in this  
patch.  I'll push a separate pgindent commit after these changes  
are applied.  
  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/adZ4j88Dq9r8y9_9%40nathan  

M doc/src/sgml/ref/psql-ref.sgml
M src/bin/psql/command.c
M src/bin/psql/describe.c
M src/bin/psql/tab-complete.in.c

Remove pg_upgrade support for upgrading from pre-v10 servers.

commit   : 14d84180830768fee1d88e87e837567b89795736    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    

Click here for diff

Per discussion, it seems like a good time to bump the minimum  
supported version for various applications.  Our current policy is  
to support at least 10 previous major versions, so this bumps the  
minimum to v10 for the v20 release.  For reference, the minimum was  
last bumped to v9.2 in 2021 for v15 (see commits 30e7c175b8,  
e469f0aaf3, cf0cab868a, and 492046fa9e).  
  
For ease of review, and to be able to put the indentation changes  
in .git-blame-ignore-revs, I did not fix the indentation in this  
patch.  I'll push a separate pgindent commit after these changes  
are applied.  
  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/adZ4j88Dq9r8y9_9%40nathan  

M doc/src/sgml/ref/pgupgrade.sgml
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/controldata.c
M src/bin/pg_upgrade/exec.c
M src/bin/pg_upgrade/file.c
M src/bin/pg_upgrade/multixact_rewrite.c
M src/bin/pg_upgrade/pg_upgrade.c
M src/bin/pg_upgrade/pg_upgrade.h
M src/bin/pg_upgrade/relfilenumber.c
M src/bin/pg_upgrade/server.c
M src/bin/pg_upgrade/t/006_transfer_modes.pl
M src/bin/pg_upgrade/version.c

Remove pg_dump/pg_dumpall support for dumping from pre-v10 servers.

commit   : 3a0a30884fd08301f211f064c1433f8148e67c3a    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Thu, 2 Jul 2026 13:05:50 -0500    

Click here for diff

Per discussion, it seems like a good time to bump the minimum  
supported version for various applications.  Our current policy is  
to support at least 10 previous major versions, so this bumps the  
minimum to v10 for the v20 release.  For reference, the minimum was  
last bumped to v9.2 in 2021 for v15 (see commits 30e7c175b8,  
e469f0aaf3, cf0cab868a, and 492046fa9e).  As in previous changes of  
this sort, we aren't removing pg_restore's ability to read older  
archive files, though it's fair to wonder how that might be tested  
nowadays.  
  
For ease of review, and to be able to put the indentation changes  
in .git-blame-ignore-revs, I did not fix the indentation in this  
patch.  I'll push a separate pgindent commit after these changes  
are applied.  
  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/adZ4j88Dq9r8y9_9%40nathan  

M doc/src/sgml/ref/pg_dump.sgml
M doc/src/sgml/runtime.sgml
M src/bin/pg_dump/connectdb.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c

Use ssup_datum_*_cmp in more places

commit   : 51cd5d6f052306e9288ff8c162ca9596432a5d2e    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Thu, 2 Jul 2026 15:53:44 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Thu, 2 Jul 2026 15:53:44 +0700    

Click here for diff

The int2, oid, and oid8 "fastcmp" comparators are functionally  
equivalent to the ssup_datum_int32_cmp (for int2) and  
ssup_datum_unsigned_cmp (for oid, oid8) functions added by commit  
697492434, so simplify by using the latter instead. This has the  
added benefit of making these types eligible for radix sort.  
  
Author: Baji Shaik <baji.pgdev@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CA+fm-RMyLC94NfrxCh273+dKs44U0ZJjRczznvzvgw=KtpPNVw@mail.gmail.com  

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

test_custom_stats: Fail if loading module outside shared_preload_libraries

commit   : 5045d9ff3b5a8b09742d8bf70221c7d708305219    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Jul 2026 15:52:46 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Jul 2026 15:52:46 +0900    

Click here for diff

Previously, test_custom_var_stats and test_custom_fixed_stats silently  
skipped pgstat_register_kind() when not loaded via  
shared_preload_libraries, behavior inherited from injection_points.  
This left the SQL functions callable without the kind registered,  
leading to various issues on the backend side.  
  
This code is not designed to work without the pgstats kinds registered.  
pgstat_register_kind() gets now called when these libraries are loaded,  
with or without shared_preload_libraries, letting the registration fail  
if loading the modules at a later step than startup.  test_custom_rmgrs  
does the same thing.  
  
Oversight in 31280d96a648.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/akS/ldidWeqG1FWk@bdtpg  
Backpatch-through: 19  

M src/test/modules/test_custom_stats/test_custom_fixed_stats.c
M src/test/modules/test_custom_stats/test_custom_var_stats.c

Fix loss of precision in pg_stat_us_to_ms()

commit   : 3eca140531f1c8e58e9a59af827488616699a052    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Thu, 2 Jul 2026 13:26:56 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Thu, 2 Jul 2026 13:26:56 +0700    

Click here for diff

Multiplying by the constant 0.001 can produce trailing-digit noise in  
displayed values (for example 0.009000000000000001 instead of 0.009,  
with default extra_float_digits) because 0.001 cannot be represented  
exactly in binary floating point. Use division by 1000.0 instead,  
matching code elsewhere in the tree.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Discussion: https://postgr.es/m/akIYkMK4bHe9qX/N@bdtpg  

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

Remove stale comment

commit   : 11b33bd3c19c5f28310dd97a3d785b773a789da4    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Thu, 2 Jul 2026 13:15:35 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Thu, 2 Jul 2026 13:15:35 +0700    

Click here for diff

Commit 732e6677a added a member to TimeoutType, invalidating the  
comment on EnableTimeoutParams.type. Rather than documenting the list,  
as is done for vars that should only take a subset of enum values,  
just remove the comment.  
  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Discussion: https://postgr.es/m/CABPTF7XuFqwOcBJ1x0rTKvEvvQ+zfZVidmjTybJPmu9_zTL6Ug@mail.gmail.com  

M src/include/utils/timeout.h

Expand comment on the slot recheck in drop_local_obsolete_slots().

commit   : 6b41bd1a459cb457cbb51d021b70004646d78db0    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 2 Jul 2026 09:34:17 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 2 Jul 2026 09:34:17 +0530    

Click here for diff

The existing comment explained that a user-created slot could reuse the  
same shared memory as 'local_slot' during the window between selecting a  
slot to drop and locking its database, and that we therefore recheck  
before dropping.  It did not, however, spell out the fuller consequence:  
because local_slot points to a reusable slot-array entry, its fields may  
already describe a replacement slot, so the earlier drop decision and the  
slot_database used for locking could relate to an unrelated slot/database.  
  
Expand the comment to describe this, and note that the recheck prevents  
us from dropping a user-created replacement slot while the residual risk  
(such as briefly locking an unrelated database) is confined to the cycle  
and is acceptable given the race is rare and non-fatal.  
  
No functional change.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Author: Amit Kapila <amit.kapila16@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGGyEDL3dh7uJ6qPsGvnq4QK_R8+U=12CaprnzwrwaLGA@mail.gmail.com  
Discussion: https://postgr.es/m/CAHGQGwHqQ1PPVFfYKVxLfRyC-byRdwSN0NeaHj9SLYV97oO5cw@mail.gmail.com  

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

Fix jsonpath .decimal() to honor silent mode

commit   : 7b12ae729e6a838c269e133cd740ad39a686ec9f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Jul 2026 12:44:29 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Jul 2026 12:44:29 +0900    

Click here for diff

The jsonpath .decimal(precision[, scale]) method built its numeric  
typmod by calling numerictypmodin() through DirectFunctionCall1(), which  
can throw a hard error for an incorrect set of precision and/or scale  
vaulues.  This breaks the silent mode supported by this function, that  
should not fail.  
  
Most of the jsonpath code uses the soft error reporting to bypass  
errors, which is what this fix does by avoiding a direct use of  
numerictypmodin().  Its code is refactored to use a new routine called  
make_numeric_typmod_safe(), able to take an error context in input.  
numerictypmodin() sets no context, mapping to its previous behavior.  
The jsonpath code sets or not a context depending on the use of the  
silent mode.  This result leads to some nice simplifications:  
numerictypmodin() feeds on an array, we can now pass directly values for  
the scale and precision.  
  
Oversight in 66ea94e8e606.  
  
Author: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://postgr.es/m/CAON2xHMaigKABiyPBBq3Sjd3gp7uWMJXnnMHt=s85V1ij3KP1w@mail.gmail.com  
Backpatch-through: 17  

M src/backend/utils/adt/jsonpath_exec.c
M src/backend/utils/adt/numeric.c
M src/include/utils/numeric.h
M src/test/regress/expected/jsonb_jsonpath.out
M src/test/regress/sql/jsonb_jsonpath.sql

pgindent fix for commit a5918fddf1.

commit   : fdad19e1cfe4564230092e034c0b2185e4a04909    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 2 Jul 2026 08:49:37 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 2 Jul 2026 08:49:37 +0530    

Click here for diff

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

Allow logical replication conflicts to be logged to a table.

commit   : a5918fddf10d297c70f7ec9067e9177e0be6d520    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 2 Jul 2026 07:44:27 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 2 Jul 2026 07:44:27 +0530    

Click here for diff

Until now, logical replication conflicts were only written as plain text  
to the server log, which is hard to query, analyze, or feed into external  
monitoring and automation.  
  
This commit adds a conflict_log_destination option to CREATE SUBSCRIPTION  
and ALTER SUBSCRIPTION that controls where conflicts are recorded. It  
accepts 'log' (the existing behavior), 'table', or 'all'.  
  
When table logging is enabled ('table' or 'all'), an internal log table  
named pg_conflict_log_<subid> is created automatically in a dedicated,  
system-managed pg_conflict namespace. Using a separate namespace avoids  
collisions with user table names and lets the table be shielded from  
direct modification. The table is tied to the subscription through an  
internal dependency, so it is dropped automatically when the subscription  
is removed.  
  
The conflict details, including the local and remote tuples, are stored in  
JSON columns, so a single table layout can accommodate rows from tables  
with different schemas. The table also records the local and remote  
transaction IDs, LSNs, commit timestamps, and the conflict type, providing  
a complete record for post-mortem analysis.  
  
A per-subscription table was chosen over a single global log because it  
aligns table ownership with the subscription lifecycle. This keeps  
permission management simple: the subscription owner can perform the  
permitted maintenance operations without the security concerns or  
Row-Level Security that a shared table would require.  
  
Because the table is system-managed, it is protected from direct  
manipulation: DDL (such as ALTER, DROP, CREATE INDEX, and adding a  
trigger, rule, policy, or extended statistics), use as an inheritance  
parent or a foreign-key target, and manual INSERT, UPDATE, MERGE, or row  
locking are all rejected.  Only DELETE and TRUNCATE are permitted, so that  
users can prune old conflict rows.  
  
Conflict log tables are also excluded from publications, even those  
defined with FOR ALL TABLES or FOR TABLES IN SCHEMA.  
  
This commit only establishes the conflict log table along with its  
creation, cleanup, and protection; recording the conflicts detected  
during apply into the table will be handled in a follow-up commit.  
  
Author: Dilip Kumar <dilipbalaut@gmail.com>  
Author: Nisha Moond <nisha.moond412@gmail.com>  
Author: Amit Kapila <akapila@postgresql.org>  
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>  
Reviewed-by: Vignesh C <vignesh21@gmail.com>  
Reviewed-by: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/CAFiTN-u5D5o_AGNbHRZHaOqAMWkxLf%2BhSk_r9X3gv6HbLOB5%2Bg%40mail.gmail.com  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/glossary.sgml
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/alter_subscription.sgml
M doc/src/sgml/ref/create_subscription.sgml
M doc/src/sgml/ref/drop_subscription.sgml
M src/backend/catalog/aclchk.c
M src/backend/catalog/catalog.c
M src/backend/catalog/pg_publication.c
M src/backend/catalog/pg_subscription.c
M src/backend/catalog/system_views.sql
M src/backend/commands/lockcmds.c
M src/backend/commands/policy.c
M src/backend/commands/statscmds.c
M src/backend/commands/subscriptioncmds.c
M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/executor/execMain.c
M src/backend/replication/logical/conflict.c
M src/backend/rewrite/rewriteDefine.c
M src/bin/initdb/initdb.c
M src/bin/psql/tab-complete.in.c
M src/include/catalog/catalog.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_namespace.dat
M src/include/catalog/pg_subscription.h
M src/include/replication/conflict.h
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql
M src/test/subscription/t/035_conflicts.pl
M src/tools/pgindent/typedefs.list

Add system view pg_stat_kind_info

commit   : 3b066de6c0a1dadbd8bed107e55cae659af0598f    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Jul 2026 09:34:21 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 2 Jul 2026 09:34:21 +0900    

Click here for diff

This commit adds support for pg_stat_kind_info, that exposes at SQL  
level data about the statistics kinds registered into a backend:  
- Meta-data of a stats kind (built-in or custom, some properties).  
- Number of entries, if tracking is enabled.  
  
We have discussed the possibility of more fields (like shared memory  
size for a single entry); this adds the minimum agreed on.  
  
This is in spirit similar to pg_get_loaded_modules() for custom stats  
kinds, this view providing detailed information about the stats kinds  
when registered through shared_preload_libraries.  
  
Bump catalog version.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/DI6OFGHJ1B69.25YVDEP3BABRH@partin.io  

M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/utils/activity/Makefile
M src/backend/utils/activity/meson.build
A src/backend/utils/activity/pgstat_kind.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/modules/test_custom_stats/t/001_custom_stats.pl
M src/test/regress/expected/rules.out
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql

Add min() and max() aggregate support for uuid.

commit   : 2e606d75c0bf9c867b51ad228eae384a9d1de21a    
  
author   : Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 1 Jul 2026 11:42:54 -0700    
  
committer: Masahiko Sawada <msawada@postgresql.org>    
date     : Wed, 1 Jul 2026 11:42:54 -0700    

Click here for diff

The uuid type already has a full set of comparison operators and a  
btree operator class, so it is totally ordered.  min() and max() were  
the only common aggregates missing for it. Add the uuid_larger() and  
uuid_smaller() support functions and register the min(uuid) and  
max(uuid) aggregates that use them.  
  
uuid values are compared lexicographically over their 128 bits.  For  
UUIDv7, whose most significant bits encode a Unix timestamp, this  
coincides with chronological order, so min() and max() return the  
oldest and newest values.  
  
Bump catalog version.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>  
Discussion: https://postgr.es/m/DJGML0T9FCDV.3VA29JLODXEHZ@partin.io  

M doc/src/sgml/datatype.sgml
M doc/src/sgml/func/func-aggregate.sgml
M src/backend/utils/adt/uuid.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_aggregate.dat
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/opr_sanity.out
M src/test/regress/expected/uuid.out
M src/test/regress/sql/uuid.sql

Fix macro-redefinition warning introduced by aeb07c55f.

commit   : 85656c1bef4af031f8e9801d927cdaeaaae95566    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 13:44:45 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 13:44:45 -0400    

Click here for diff

Some platforms provide a definition of unreachable() in standard C  
headers, leading to a conflict with unreachable() in the new  
timezone code.  It seems best for our purposes to conform to what  
pg_unreachable() does, so #undef away the platform version.  
  
Reported-by: Tristan Partin <tristan@partin.io>  
Discussion: https://postgr.es/m/DJNDN9UQS9GP.11L4NJ1HHE1ZJ@partin.io  

M src/timezone/private.h

btree_gist: fix NaN handling in float4/float8 opclasses.

commit   : 7d3448961da3f8cb5c78b9d58c5e03b6bff53364    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 13:27:22 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 13:27:22 -0400    

Click here for diff

The float4 and float8 btree_gist opclasses compared keys with raw C  
operators (==, <, >).  IEEE 754 makes every comparison involving NaN  
false, so GiST disagreed with the regular float comparison operators  
and with the btree opclass, which uses float[4|8]_cmp_internal()  
(so that all NaNs are equal and NaN sorts after every non-NaN value).  
  
In addition, the penalty and distance functions were not careful  
about NaNs, and the penalty functions could also misbehave for IEEE  
infinities.  Wrong answers from the penalty functions would probably  
do no more than make the index non-optimal, but the distance mistakes  
were visible from SQL.  
  
To fix, make the comparison functions rely on the same NaN-aware  
comparison functions the core code uses, and rewrite the penalty  
and distance functions to follow the rules that NaNs are equal  
but maximally far away from non-NaNs.  The penalty_num() code was  
formerly shared between integral and float cases, but I chose to make  
two copies so that the integral cases are not saddled with the extra  
logic for NaNs and infinities/overflows.  I also rewrote it as static  
inline functions instead of an unreadable and uncommented macro.  
  
The float penalty functions were previously unreached by the  
regression tests, so add new test cases to exercise them.  
  
There's no on-disk format change, but users who have NaN entries  
in a btree_gist index would be well advised to reindex it.  
  
Bug: #19501  
Bug: #19524  
Reported-by: Man Zeng <zengman@halodbtech.com>  
Reported-by: Yuelin Wang <3020001251@tju.edu.cn>  
Author: Bill Kim <billkimjh@gmail.com>  
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/19501-3bff3bbc97f1e7c9@postgresql.org  
Discussion: https://postgr.es/m/19524-9559d302c8455664@postgresql.org  
Discussion: https://postgr.es/m/CAMQXxcgbtD2LXfX0tpgvOizxP-XxrCHV2ZDy4By_TZnJMsxXWQ@mail.gmail.com  
Backpatch-through: 14  

M contrib/btree_gist/btree_float4.c
M contrib/btree_gist/btree_float8.c
M contrib/btree_gist/btree_utils_num.h
M contrib/btree_gist/data/float4.data
M contrib/btree_gist/data/float8.data
M contrib/btree_gist/expected/float4.out
M contrib/btree_gist/expected/float8.out
M contrib/btree_gist/expected/numeric.out
M contrib/btree_gist/sql/float4.sql
M contrib/btree_gist/sql/float8.sql

doc: Fix pg_stat_autovacuum_scores descriptions.

commit   : 6440265606241277d9d99241116b14d7cc2783ca    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 1 Jul 2026 10:47:53 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Wed, 1 Jul 2026 10:47:53 -0500    

Click here for diff

The descriptions of the component scores state that values greater  
than or equal to the corresponding weight parameter mean autovacuum  
will process the table.  However, since the code that determines  
whether to vacuum or analyze a table actually checks whether the  
threshold is exceeded, it's more accurate to say "greater than"  
there.  
  
Author: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Sami Imseih <samimseih@gmail.com>  
Discussion: https://postgr.es/m/E3ABDC6B-80CA-4C37-BA0B-A519D49F4C66%40gmail.com  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml

Improve the names generated for indexes on expressions.

commit   : 181b6185c79e09e6ac94428189d9afac807244ac    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 11:33:52 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 11:33:52 -0400    

Click here for diff

If the user doesn't specify a name for an index, it's generated  
based on the names chosen for the index columns (which the user  
has no direct control over).  For index columns that are just  
columns of the base relation, the index column name is the same as  
the base column name; but for index columns that are expressions,  
it's less clear what to do.  Up to now, what we have done is  
equivalent to the heuristics used to choose SELECT output column  
names, except that we fall back to "expr" not "?column?" in the  
numerous cases that FigureColname doesn't know what to do with.  
This is not tremendously helpful.  More, it frequently leads to  
collisions of generated index names, which we can handle but  
only at the cost of user confusion; also there's some risk of  
concurrent index creations trying to use the same name.  
Let's try to do better.  
  
Messing with the FigureColname heuristics would have a very  
large blast radius, since that affects the column headings  
that applications see.  That doesn't seem wise, but fortunately  
SQL queries are seldom directly concerned with index names.  
So we should be able to change the index-name generation rules  
as long as we decouple them from FigureColname.  
  
The method used in this patch is to dig through the expression,  
extract the names of Vars, the string representations of Consts,  
and the names of functions, and run those together with underscores  
between.  Other expression node types are ignored but descended  
through.  We could work harder by handling more node types, but  
it seems like this is likely to be sufficient to arrive at unique  
index names in many cases.  
  
Notably, this rule ignores the names of operators, for example  
both "a + b" and "a * b" will be rendered as "a_b".  This choice  
was made to reduce the probability of having to double-quote  
the index name.  
  
I've also chosen to strip Const representations down to only  
alphanumeric characters (plus non-ASCII characters, which our  
parser treats as alphabetic anyway).  So for example "x + 1.0"  
would be represented as "x_10".  This likewise avoids possible  
quoting problems.  I also considered limiting how many characters  
we'd take from each Const, but didn't do that here.  
  
We might tweak these rules some more after we get some experience  
with this patch.  It's being committed at the start of a  
development cycle to provide as much time as possible to gather  
feedback.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Robert Haas <robertmhaas@gmail.com>  
Discussion: https://postgr.es/m/876799.1757987810@sss.pgh.pa.us  
Discussion: https://postgr.es/m/18959-f63b53b864bb1417@postgresql.org  

M contrib/seg/expected/partition.out
M src/backend/commands/indexcmds.c
M src/backend/parser/parse_target.c
M src/backend/parser/parse_utilcmd.c
M src/include/nodes/parsenodes.h
M src/include/parser/parse_target.h
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/create_index.out
M src/test/regress/expected/create_table.out
M src/test/regress/expected/create_table_like.out
M src/test/regress/expected/indexing.out
M src/test/regress/expected/inherit.out
M src/test/regress/expected/rangetypes.out
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/create_index.sql
M src/test/regress/sql/indexing.sql
M src/tools/pgindent/typedefs.list

Sync our copy of the timezone library with IANA release tzcode2026b.

commit   : aeb07c55fab5c17a600b77ffcdc3b71425d6a8e7    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 10:56:46 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 10:56:46 -0400    

Click here for diff

This was moderately tedious, because upstream has been busy  
since we last did this in 2020.  
  
Notably, they changed the signatures of both tzload() and tzparse(),  
which we'd unwisely exposed as API for callers to use.  I concluded  
that the best answer was to change them both back to "static" and  
instead expose a new API function of our own choosing, pg_tzload().  
  
That change may be a sufficient reason not to back-patch this update,  
as I'd normally want to do.  There's probably not a good reason for  
extensions to be calling those functions, but on the other hand  
there are few pressing reasons for a back-patch.  The one bug we have  
run into (a Valgrind uninitialized-data complaint about zic) appears  
to have no field-visible consequences.  
  
A few of the files generated by this version of zic are not  
byte-for-byte the same as before, but "zdump -v" avers that  
they represent the same sets of transitions.  
  
Discussion: https://postgr.es/m/2294297.1780270682@sss.pgh.pa.us  

M src/bin/initdb/findtimezone.c
M src/timezone/README
M src/timezone/localtime.c
M src/timezone/pgtz.c
M src/timezone/pgtz.h
M src/timezone/private.h
M src/timezone/strftime.c
M src/timezone/tzfile.h
M src/timezone/zic.c
M src/tools/pgindent/typedefs.list

Fix CPU-identification macros for RISC-V.

commit   : d3223485546e8579a1703731ef4e39a08a712860    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 10:10:21 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Jul 2026 10:10:21 -0400    

Click here for diff

Turns out that RISC-V intentionally doesn't follow the common  
naming pattern for CPU-identification macros.  But the point of  
2ef57e636 is to have a common pattern, so we're going to override  
their opinion.  
  
Discussion: https://postgr.es/m/CA+hUKGL8Hs-phHPugrWM=5dAkcT897rXyazYzLw-Szxnzgx-rA@mail.gmail.com  

M src/include/c.h

Clear base backup progress on backup failure

commit   : 55f0a13e96be6c1b81425a3353c08df8b8ec3a6c    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 1 Jul 2026 23:03:08 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 1 Jul 2026 23:03:08 +0900    

Click here for diff

Previously, if a base backup failed after it had started streaming  
files, pg_stat_progress_basebackup could continue to show a stale  
progress entry even though the backup was no longer running. This could  
be observed when the client kept the replication connection open after  
the error. It is normally not observable when using pg_basebackup,  
because the client disconnects after the error.  
  
The problem was that progress reporting was cleared only after  
successful completion.  
  
This commit moves the progress reporting cleanup into the progress  
sink's cleanup callback so that it is cleared after both successful  
and failed backups.  
  
Backpatch to v15. v14 has the same issue, but the fix does not apply  
cleanly because it lacks the base backup sink infrastructure. Since  
the bug does not affect the backup itself and is normally not  
observable when using pg_basebackup, skip the v14 backpatch.  
  
Author: Chao Li <lic@highgo.com>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/EA1A6CD2-EFA6-462B-9A02-03003555AB4A@gmail.com  
Backpatch-through: 15  

M src/backend/backup/basebackup.c
M src/backend/backup/basebackup_progress.c
M src/include/backup/basebackup_sink.h

Warn on password auth with MD5-encrypted passwords

commit   : f6fdc2a4a737b62323b786aea59ab7a38cd7f835    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 1 Jul 2026 20:57:28 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 1 Jul 2026 20:57:28 +0900    

Click here for diff

Commit bc60ee860 added a connection warning after successful MD5  
authentication, but only for the md5 authentication method. A role with  
an MD5-encrypted password can also authenticate via the password method,  
which left that path without the same deprecation warning.  
  
Emit the MD5 deprecation connection warning after successful  
password authentication as well, when the stored password is  
MD5-encrypted.  
  
Backpatch to v19, where the MD5 connection warning was introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: Chao Li <li.evan.chao@gmail.com>  
Reviewed-by: Japin Li <japinli@hotmail.com>  
Discussion: https://postgr.es/m/CAHGQGwGkWfn5rtHzvdRbVk+PCefQU3gun3hc7QnaMXHFa5Bu3w@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/config.sgml
M src/backend/libpq/auth.c
M src/backend/libpq/crypt.c
M src/test/authentication/t/001_password.pl

Fix mismatched deallocation functions

commit   : 30652b356d20c1d3772137370a6a8d29575e04d1    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 1 Jul 2026 13:48:45 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 1 Jul 2026 13:48:45 +0200    

Click here for diff

In fe_memutils.h, we have various allocation functions beginning with  
either pg_ or p.  The pg_ functions have a matching pg_free() for  
freeing memory, while the p functions use pfree().  In some cases, we  
were allocating memory with one set of functions while using the wrong  
deallocation functions.  This creates a tiny bit of mental overhead  
when reading code.  Matching up allocation and deallocation functions  
makes it easier to analyze memory handling in a code path.  
  
Author: Tristan Partin <tristan@partin.io>  
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>  
Discussion: https://www.postgresql.org/message-id/flat/DIBZE2B6SVF2.28R3EQTYJSWIG@partin.io  

M contrib/oid2name/oid2name.c
M src/bin/initdb/initdb.c
M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_basebackup/streamutil.c
M src/bin/pg_combinebackup/load_manifest.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_combinebackup/reconstruct.c
M src/bin/pg_ctl/pg_ctl.c
M src/bin/pg_dump/compress_gzip.c
M src/bin/pg_dump/compress_lz4.c
M src/bin/pg_dump/compress_none.c
M src/bin/pg_dump/connectdb.c
M src/bin/pg_dump/dumputils.c
M src/bin/pg_dump/parallel.c
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_custom.c
M src/bin/pg_dump/pg_backup_db.c
M src/bin/pg_dump/pg_backup_directory.c
M src/bin/pg_dump/pg_backup_tar.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump_sort.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/function.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pgbench/pgbench.c
M src/bin/psql/command.c
M src/bin/psql/common.c
M src/bin/psql/describe.c
M src/bin/psql/help.c
M src/bin/psql/input.c
M src/bin/psql/large_obj.c
M src/bin/psql/mainloop.c
M src/bin/psql/prompt.c
M src/bin/psql/startup.c
M src/bin/psql/stringutils.c
M src/bin/psql/tab-complete.in.c
M src/bin/scripts/vacuuming.c
M src/common/logging.c
M src/fe_utils/print.c
M src/interfaces/ecpg/test/pg_regress_ecpg.c
M src/test/isolation/isolation_main.c
M src/test/isolation/isolationtester.c
M src/test/modules/libpq_pipeline/libpq_pipeline.c
M src/test/regress/pg_regress.c
M src/test/regress/pg_regress_main.c

Split dry-run messages into primary and detail

commit   : e3b5817c8b89790f7f4bf96a1fef98aed88d2fdb    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 1 Jul 2026 10:12:33 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 1 Jul 2026 10:12:33 +0200    

Click here for diff

Fixup for commit c05dee19112.  It fits better with the style and APIs  
to print separate primary and a detail messages instead of one  
multiline message.  
  
Reviewed-by: Euler Taveira <euler@eulerto.com>  
Reviewed-by: Peter Smith <smithpb2250@gmail.com>  
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>  
Discussion: https://postgr.es/m/CAHut+PsvQJQnQO0KT0S2oegenkvJ8FUuY-QS5syyqmT24R2xFQ@mail.gmail.com  

M src/bin/pg_archivecleanup/pg_archivecleanup.c
M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_rewind/pg_rewind.c
M src/bin/scripts/vacuumdb.c

Don't cast off_t to 32-bit type for output, bug fix

commit   : e8f851d61727babe2ce162292b21e6afc89ca65f    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 1 Jul 2026 09:39:42 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 1 Jul 2026 09:39:42 +0200    

Click here for diff

off_t is most likely a 64-bit integer, so casting it to a 32-bit type  
for output could lose data.  There are more issues like this in the  
tree, but this is an instance where this could actually happen in  
practice, since base backups are routinely larger than 4 GB.  So this  
is separated out as a bug fix.  
  
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>  
Discussion: https://www.postgresql.org/message-id/flat/20ce62fa-47fc-457b-b504-12f3c1651726%40eisentraut.org  

M src/backend/backup/basebackup_server.c

Use C11 alignas instead of pg_attribute_aligned

commit   : 8061bfd15abe4d6943ac1563617c19fc069aad70    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 29 Jun 2026 10:46:51 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Mon, 29 Jun 2026 10:46:51 +0200    

Click here for diff

Replace pg_attribute_aligned with C11 alignas, for consistency with  
current conventions.  
  
(These new uses were added by commit fbc57f2bc2e, which was developed  
concurrently with the switch from pg_attribute_aligned to C11 standard  
alignas, and it ended up being committed with the "old" style.)  
  
Reviewed-by: John Naylor <johncnaylorls@gmail.com>  
Discussion: https://postgr.es/m/CANWCAZaKhE+RD5KKouUFoxx1EbUNrNhcduM1VQ=DkSDadNEFng@mail.gmail.com  

M src/port/pg_crc32c_armv8.c

Improve UNION's output row count estimate

commit   : be69a5ff1fd96cdbfe917ac4739142e52aab126e    
  
author   : Richard Guo <rguo@postgresql.org>    
date     : Wed, 1 Jul 2026 15:12:43 +0900    
  
committer: Richard Guo <rguo@postgresql.org>    
date     : Wed, 1 Jul 2026 15:12:43 +0900    

Click here for diff

A UNION (not UNION ALL) removes duplicates, so its output has no more  
rows than its input.  The planner did not account for this: it set the  
set-op relation's row count to the total size of the appended input,  
as though dedup removed nothing.  That inflated estimate then  
propagated to every node above the UNION, leading to poor plan choices  
such as a hash join with a full table scan where an index nested loop  
would have been cheaper.  
  
This patch estimates the number of distinct output rows as the sum of  
the per-child distinct-group estimates instead.  This relies on the  
fact that:  
  
  distinct(A union B) <= distinct(A) + distinct(B)  
  
that is, the union cannot have more distinct rows than its children do  
in total.  And because each child's distinct-group estimate never  
exceeds that child's row-count estimate, this sum is never larger than  
the old estimate, so it only tightens the previous over-estimate.  
  
Author: Richard Guo <guofenglinux@gmail.com>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com>  
Discussion: https://postgr.es/m/CAMbWs48Fu1nhGXPa60oc+adj7ge4dn0nHhqngqKvOVVQP61duA@mail.gmail.com  

M src/backend/optimizer/prep/prepunion.c
M src/test/regress/expected/union.out
M src/test/regress/sql/union.sql

Avoid useless calls in pg_get_multixact_stats()

commit   : b542d556670586ebadf380102f6ead920609e592    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 1 Jul 2026 12:17:17 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 1 Jul 2026 12:17:17 +0900    

Click here for diff

MultiXactOffsetStorageSize() and GetMultiXactInfo() are called to gather  
the information reported by the function, but were wasteful for the case  
where a role does not have the privileges of pg_read_all_stats, where we  
return a set of NULLs.  These calls are moved to the code path where  
their results are used.  
  
Author: Ranier Vilela <ranier.vf@gmail.com>  
Discussion: https://postgr.es/m/CAEudQAonQh7be=wOR-CJFW=bgMBz5wW_bv4t0OFxbgn-794JCQ@mail.gmail.com  
Backpatch-through: 19  

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

Document wal_compression=on

commit   : 8db58ac8eec7402af1a746621fb2910f1673db0a    
  
author   : John Naylor <john.naylor@postgresql.org>    
date     : Wed, 1 Jul 2026 08:50:08 +0700    
  
committer: John Naylor <john.naylor@postgresql.org>    
date     : Wed, 1 Jul 2026 08:50:08 +0700    

Click here for diff

Commit 4035cd5d4 added LZ4 compression for full-page writes in WAL, and  
retained "on" as a backward-compatible way to specify the builtin PGLZ  
method. Document this meaning of "on" and update postgresql.conf.sample  
to make the equivalence clear.  
  
Author: Christoph Berg <myon@debian.org>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/akJDHRtXwGLTppsQ@msg.df7cb.de  
Backpatch-through: 15  

M doc/src/sgml/config.sgml
M src/backend/utils/misc/postgresql.conf.sample

doc: Add new section describing fast-path locking

commit   : 2d31da527169fb54916d7435629c04a7b7bbda1d    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 1 Jul 2026 10:08:26 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 1 Jul 2026 10:08:26 +0900    

Click here for diff

Fast-path locking is referenced by pg_stat_lock.fastpath_exceeded, by  
pg_locks.fastpath, and in the GUC max_locks_per_transaction.  However,  
the documentation has never described in details how this works; one  
would need to look at the internals of lock.c, mostly around  
EligibleForRelationFastPath().  
  
This commit adds a new subsection called "Fast-Path Locking" to the area  
dedicated to locks, with the three places mentioned above linking to it.  
  
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAHza6qdKo9dcPy70QBi88vpqhS2gYWViS8=Uj=-+QQbR=ONgSQ@mail.gmail.com  

M doc/src/sgml/config.sgml
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/mvcc.sgml
M doc/src/sgml/system-views.sgml

Remove radius from initdb authentication methods.

commit   : a78f7390bf19868cc313482b307d5148ad00aae2    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 1 Jul 2026 11:25:37 +1200    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Wed, 1 Jul 2026 11:25:37 +1200    

Click here for diff

Commit a1643d40b removed RADIUS authentication, but apparently  
overlooked initdb's list of accepted authentication methods.  As a  
result, initdb still accepted radius for --auth, --auth-host, and  
--auth-local, allowing it to create a pg_hba.conf that the server could  
not load.  
  
Remove radius from initdb's local and host authentication method lists.  
  
Backpatch-through: 19  
Author: Chao Li <lic@highgo.com>  
Discussion: https://postgr.es/m/983F946B-A7CE-4C93-B5F0-665616F72254%40gmail.com  

M src/bin/initdb/initdb.c

Disallow set-returning functions within window OVER clauses.

commit   : 1de468099d27f44c1998c9c2251cd2aefcfab524    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 30 Jun 2026 17:21:23 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 30 Jun 2026 17:21:23 -0400    

Click here for diff

We previously allowed this, but it leads to odd behaviors, basically  
because putting a SRF there is inconsistent with the principle that a  
window function doesn't change the number of rows in the query result.  
There doesn't seem to be a strong reason to try to make such cases  
behave consistently.  Users should put their SRFs in lateral FROM  
clauses instead.  
  
This issue has been sitting on the back burner for multiple years  
now, partially because it didn't seem wise to back-patch such a  
change.  Let's squeeze it into v19 before it's too late.  
  
Bug: #17502  
Bug: #19535  
Reported-by: Daniel Farkaš <daniel.farkas@datoris.com>  
Reported-by: Qifan Liu <imchifan@163.com>  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: David Rowley <dgrowleyml@gmail.com>  
Discussion: https://postgr.es/m/17502-281a7aaacfaa872a@postgresql.org  
Discussion: https://postgr.es/m/19535-376081d7cc07c86d@postgresql.org  
Backpatch-through: 19  

M src/backend/parser/parse_func.c
M src/test/regress/expected/tsrf.out
M src/test/regress/sql/tsrf.sql

doc: clarify MERGE PARTITIONS adjacency requirement

commit   : 57f19774d6c88f501c835a7772a71ca5ba2bc163    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 30 Jun 2026 22:29:43 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Tue, 30 Jun 2026 22:29:43 +0300    

Click here for diff

The existing description says the ranges of merged range-partitions  
"must be adjacent" only under the heading "If the DEFAULT partition is  
not in the list of merged partitions".  That could be misread as  
a restriction tied to the presence of a default partition.  In fact,  
merging non-adjacent ranges is rejected regardless of whether  
the partitioned table has a default partition; spell that out explicitly.  
  
Also, this commit removes a small redundancy in the documentation sentence  
stating that "merged range-partitions" are "to be merged".  
  
Reported-by: Justin Pryzby <pryzby@telsasoft.com>  
Discussion: https://postgr.es/m/aj6BPoziSb-F8aJz%40pryzbyj2023  
Reported-by: Pavel Borisov <pashkin.elfe@gmail.com>  
Backpatch-through: 19  

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

Clean up inconsistencies in CPU-identification macros.

commit   : 2ef57e636fc97528a37515673f5f56a1fcf97186    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 30 Jun 2026 12:21:06 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 30 Jun 2026 12:21:06 -0400    

Click here for diff

In various places we depend on compiler-defined macros like __x86_64__  
to guard CPU-type-specific code.  However, those macros aren't very  
well standardized; in particular, it emerges that MSVC doesn't define  
any of the ones gcc does, but has its own.  We were not coping with  
that consistently, with the result that we're missing some useful  
CPU-dependent optimizations in MSVC builds.  There are also some  
places that are checking randomly-different spellings that may  
have been the only ones recognized by some old compilers, but we  
weren't doing that consistently either.  
  
Let's standardize on using gcc's long-form spellings (with trailing  
underscores), after putting a stanza into c.h that ensures that these  
spellings are defined even when the compiler provides some other one.  
  
I put an "#else #error" branch into the c.h addition so that we'll  
get an error if the compiler provides none of the symbols we're  
expecting.  That might be best removed in the end, since it might  
annoy people trying to port to some new CPU type.  But for testing  
this it seems like a good idea, in case we've missed some common  
variant spelling.  
  
In addition to enabling some optimizations we previously missed on  
MSVC, this cleans up a thinko.  Several places used "_M_X64" in the  
apparent belief that that's MSVC's equivalent to __x86_64__, but  
it's not: it will also get defined on some but not all ARM64 builds.  
  
Also, guard the x86_feature_available() stuff in pg_cpu.[hc] with  
	#if defined(__x86_64__) || defined(__i386__)  
which seems like a more natural way of specifying what it applies to.  
  
This builds on some previous work by Thomas Munro, but it requires  
much less code churn because it re-uses gcc's names for the CPU-type  
macros instead of inventing our own.  
  
Author: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://postgr.es/m/CA+hUKGL8Hs-phHPugrWM=5dAkcT897rXyazYzLw-Szxnzgx-rA@mail.gmail.com  
Discussion: https://postgr.es/m/3035145.1780503430@sss.pgh.pa.us  

M src/common/d2s.c
M src/include/c.h
M src/include/port/atomics.h
M src/include/port/atomics/arch-x86.h
M src/include/port/pg_bitutils.h
M src/include/port/pg_cpu.h
M src/include/portability/instr_time.h
M src/include/storage/s_lock.h
M src/port/pg_cpu_x86.c

Remove pg_spin_delay().

commit   : ae27a41e0c7f1d1c451aff230cac32fc7cdb1fee    
  
author   : Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 30 Jun 2026 10:57:54 -0500    
  
committer: Nathan Bossart <nathan@postgresql.org>    
date     : Tue, 30 Jun 2026 10:57:54 -0500    

Click here for diff

This code appears to be an artifact from commit b64d92f1a5 that was  
never used for anything.  
  
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>  
Discussion: https://postgr.es/m/afouZUH_eUkIj4i4%40nathan  

M src/include/port/atomics.h
M src/include/port/atomics/arch-x86.h
M src/include/port/atomics/generic.h

Make SPI_prepare argtypes argument const

commit   : b1c41398e48ca7d38a46c901dc93872c968b227c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 30 Jun 2026 15:43:56 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 30 Jun 2026 15:43:56 +0200    

Click here for diff

This changes the argtypes argument of SPI_prepare(),  
SPI_prepare_cursor(), SPI_cursor_open_with_args(), and  
SPI_execute_with_args() from Oid *argtypes to const Oid *argtypes.  
The underlying functions were already receptive to that, so this  
doesn't require any significant changes beyond the function signatures  
and some internal variables.  
  
Commit 28972b6fc3dc recently introduced a case where a const had to be  
cast away before calling these functions.  This is fixed here.  
  
In passing, make a very similar const addition to SPI_modifytuple().  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>  
Discussion: https://www.postgresql.org/message-id/flat/86b5162f-c472-40fa-997b-0450dece1dec%40eisentraut.org  

M contrib/postgres_fdw/postgres_fdw.c
M doc/src/sgml/spi.sgml
M src/backend/executor/spi.c
M src/backend/utils/adt/ri_triggers.c
M src/backend/utils/cache/plancache.c
M src/include/executor/spi.h
M src/include/executor/spi_priv.h
M src/include/utils/plancache.h

Fixes for SPI "const Datum *" use

commit   : cd3ad3bc03567ee120a638c840112b8865e055a8    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 30 Jun 2026 14:03:10 +0200    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 30 Jun 2026 14:03:10 +0200    

Click here for diff

Fixup for commit 8a27d418f8f, which converted many functions to use  
"const Datum *" instead of "Datum *", including some SPI functions.  
  
For SPI_cursor_open(), the code was updated but not the documentation.  
For SPI_cursor_open_with_args(), the documentation was updated but not  
the code.  (Possibly, these two were confused with each other.)  Also,  
SPI_execp() and SPI_modifytuple() were not updated, even though they  
are closely related to the functions touched by the previous commit  
and now look inconsistent.  Fix all these.  
  
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>  
Discussion: https://www.postgresql.org/message-id/flat/86b5162f-c472-40fa-997b-0450dece1dec%40eisentraut.org  

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

Add backend-level lock statistics

commit   : 8c579bdc366dbca4fe9432a01408216133628c52    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 16:59:20 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 16:59:20 +0900    

Click here for diff

This commit adds per-backend lock statistics, providing the same  
information as pg_stat_lock.  It is now possible to retrieve those stats  
(lock wait counts, wait times, and fast-path exceeded count) on a  
per-backend basis.  
  
This data can be retrieved with a new system function called  
pg_stat_get_backend_lock(), that returns one tuple per lock type based  
on the PID provided in input.  Like pg_stat_get_backend_io(), this is  
useful if joined with pg_stat_activity to get a live picture of the  
locks behavior for each running backend.  
  
pgstat_flush_backend() gains a new flag value, able to control the flush  
of the lock stats.  
  
This commit is straight-forward, relying on the infrastructure provided  
by 9aea73fc61d4 (backend-level pgstats).  
  
Bump catalog version.  No need to touch PGSTAT_FILE_FORMAT_ID as backend  
statistics are never written to disk.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/aiAzEY+cMQb/W8yu@bdtpg  

M doc/src/sgml/monitoring.sgml
M src/backend/utils/activity/pgstat_backend.c
M src/backend/utils/activity/pgstat_lock.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h
M src/include/utils/pgstat_internal.h
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql

Refactor pg_stat_get_lock() to use a helper function

commit   : dfe7d17e00665875639e905fa385231dacc57c4e    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 16:24:34 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 16:24:34 +0900    

Click here for diff

This commit extracts the tuple-building logic from pg_stat_get_lock()  
into a new static helper pg_stat_lock_build_tuples().  This is in  
preparation for a follow-up patch, to add support for backend-level lock  
stats, which will reuse the same helper.  
  
This change follows the pattern established by pg_stat_io_build_tuples()  
for IO stats and pg_stat_wal_build_tuple() for WAL stats.  
  
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Reviewed-by: Tristan Partin <tristan@partin.io>  
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>  
Discussion: https://postgr.es/m/aiAzEY+cMQb/W8yu@bdtpg  

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

Use placeholders and not GUC names in error message (autovacuum)

commit   : 7905416eef9b2ad2ff8783330d830ef2c28bef2a    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 16:16:56 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 16:16:56 +0900    

Click here for diff

A placeholder %s is now used instead of the GUC names in the error  
string of this routine.  This is going to be useful for a follow-up  
patch, where we will be able to reuse the same string, hence reducing  
the translation work.  
  
Based on a suggestion by me.  
  
Author: Baji Shaik <baji.pgdev@gmail.com>  
Discussion: https://postgr.es/m/ajnhfw84reaXgjfO@paquier.xyz  

M src/backend/postmaster/autovacuum.c

Change stat_lock.wait_time to double precision

commit   : c776550e4662385b0ebeac653ae86755008d29f3    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 12:47:34 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 12:47:34 +0900    

Click here for diff

Other statistics views (pg_stat_io, pg_stat_database, etc.) use float8  
for all measured-time columns, the new pg_stat_lock standing out as an  
outlier by using bigint.  
  
This commit aligns pg_stat_lock with the other stats views for  
consistency.  Like pg_stat_io, the time is stored in microseconds, and  
is displayed in milliseconds with a conversion done when the view is  
queried.  
  
While on it, replace a use of "long" by PgStat_Counter, the former could  
overflow for large wait times where sizeof(long) is 4 bytes (aka WIN32).  
  
Bump catalog version.  
  
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>  
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>  
Reviewed-by: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CAHza6qerEiQehrbW5xaXyxvR0qJe3KBX1R4kocDz1+7Ygu8x-g@mail.gmail.com  
Backpatch-through: 19  

M doc/src/sgml/monitoring.sgml
M src/backend/storage/lmgr/proc.c
M src/backend/utils/activity/pgstat_lock.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h

Restore comment at appendShellString().

commit   : cfa573cf8cbdcbf7cbcae34911bd1ee292abdd2f    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 29 Jun 2026 19:41:09 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 29 Jun 2026 19:41:09 -0700    

Click here for diff

Commit b380a56a3f9556588a89013b765d67947d54f7d0 removed a paragraph, but  
two of the paragraph's three sentences remained relevant.  
  
Backpatch-through: 19  

M src/fe_utils/string_utils.c

bufmgr: Fix race in LockBufferForCleanup()

commit   : 8d85cb889a395f08d58e59c31a67f199f0fc25c3    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 30 Jun 2026 10:30:47 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 30 Jun 2026 10:30:47 +0900    

Click here for diff

LockBufferForCleanup() acquires the exclusive content lock, checks the  
buffer's shared pin count, and, if other pins remain, registers itself  
as the BM_PIN_COUNT_WAITER before waiting for an unpin notification.  
  
Since commits 5310fac6e0f and c75ebc657ffc, however, a shared buffer  
pin can be released while BM_LOCKED is set, introducing the following  
race:  
  
- LockBufferForCleanup() observes a refcount greater than one.  
- Before it sets BM_PIN_COUNT_WAITER, another backend releases the  
  last conflicting pin.  
- Since BM_PIN_COUNT_WAITER is not yet set, no wakeup is sent.  
- LockBufferForCleanup() then sets BM_PIN_COUNT_WAITER and goes to  
  sleep, even though only its own pin remains.  
  
As a result, LockBufferForCleanup() can sleep indefinitely because  
the wakeup corresponding to the last conflicting unpin has already been  
missed.  
  
Fix this by setting BM_PIN_COUNT_WAITER while holding the buffer  
header lock, then rechecking the refcount before releasing the content  
lock. If only our pin remains, clear the waiter state and proceed  
without sleeping. Otherwise, wait as before.  
  
This issue was reported by buildfarm member skink, where it manifested  
as intermittent timeouts in 048_vacuum_horizon_floor.pl.  
  
Backpatch to v19, where commits 5310fac6e0f and c75ebc657ffc  
introduced the race.  
  
Reported-by: Alexander Lakhin <exclusion@gmail.com>  
Author: Xuneng Zhou <xunengzhou@gmail.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>  
Discussion: https://postgr.es/m/7685519a-0bf9-4e17-93ca-7e3aa10fa29c@gmail.com  
Backpatch-through: 19  

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

Remove stray blank line in ParseFuncOrColumn()

commit   : d8113095c488ad588a0890833f67d01df46374e7    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 30 Jun 2026 10:28:52 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 30 Jun 2026 10:28:52 +0900    

Click here for diff

Commit 419ce13b701 accidentally left a stray blank line in  
ParseFuncOrColumn(). Remove it.  
  
No functional change.  
  
Author: Henson Choi <assam258@gmail.com>  
Discussion: https://postgr.es/m/CAAAe_zDLBkZFXXCgR_-NuaeW+aUXUtuDoSgg-2QRz+b2g7G4BA@mail.gmail.com  
Backpatch-through: 19  

M src/backend/parser/parse_func.c

Fix unlogged sequence corruption after standby promotion

commit   : 8e684ce11ddaac2604375b8efcae97f6b36af4e7    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 30 Jun 2026 08:48:47 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 30 Jun 2026 08:48:47 +0900    

Click here for diff

Previously, if an unlogged sequence was created on the primary and  
replicated to a standby, reading the sequence after promoting the  
standby (for example, with nextval()) could trigger the following  
assertion failure:  
  
    TRAP: failed Assert("((const PageHeaderData *) page)->pd_special >= SizeOfPageHeaderData")  
  
In non-assert builds, the same operation could instead fail with an  
error such as:  
  
    ERROR:  bad magic number in sequence  
  
The problem was that seq_redo() updated the init fork page in shared  
buffers but did not flush it to disk. During promotion,  
ResetUnloggedRelations() recreates the main fork of unlogged  
relations by copying the init fork from disk, bypassing shared  
buffers. As a result, the main fork could be recreated from a stale  
init fork instead of the WAL-replayed page.  
  
Fix this by introducing a helper to flush init fork buffers  
immediately, and make seq_redo() use it. As a result, the main fork  
of an unlogged sequence is recreated from the up-to-date init fork on  
disk, allowing the unlogged sequence to be read successfully after  
standby promotion.  
  
Backpatch to v15, where unlogged sequences were introduced.  
  
Author: Fujii Masao <masao.fujii@gmail.com>  
Reviewed-by: vignesh C <vignesh21@gmail.com>  
Discussion: https://postgr.es/m/CAHGQGwH1Ssze3XM6wjoTjSLVOR041c6xP+vsdLP951=w8oG8bA@mail.gmail.com  
Backpatch-through: 15  

M src/backend/access/hash/hash_xlog.c
M src/backend/access/transam/xlogutils.c
M src/backend/commands/sequence_xlog.c
M src/include/access/xlogutils.h
M src/test/recovery/meson.build
A src/test/recovery/t/054_unlogged_sequence_promotion.pl

Simplify some stats restore code with InputFunctionCallSafe()

commit   : efa59a500457f310abbc38dc472f03e959ccd5b8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 08:30:08 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 30 Jun 2026 08:30:08 +0900    

Click here for diff

statatt_build_stavalues() and array_in_safe() have been relying on  
InitFunctionCallInfoData() with a locally-filled state to call a data  
type input function.  InputFunctionCallSafe() can be used to achieve the  
same job, simplifying some code.  
  
This fixes an over-allocation of FunctionCallInfoBaseData done in  
statatt_build_stavalues(), where there was space for 8 elements but only  
3 were needed.  The over-allocation exists since REL_18_STABLE, and was  
harmless in practice.  
  
While on it, fix some comments for both routines, where elemtypid was  
mentioned.  
  
Backpatch down to v19.  This code has been reworked during the last  
development cycle while working on the restore of extended statistics,  
so this keeps the code consistent across all branches.  
  
Author: Jian He <jian.universality@gmail.com>  
Author: Michael Paquier <michael@paquier.xyz>  
Discussion: https://postgr.es/m/CACJufxEGah9PaiTQ=cG14GMMBsUQ3ohGct9tdSwbMQPQ0-nbbQ@mail.gmail.com  
Backpatch-through: 19  

M src/backend/statistics/extended_stats_funcs.c
M src/backend/statistics/stat_utils.c

Stamp HEAD as 20devel.

commit   : a281a3e6dbb45d5cca41ea5f7b746724eb3ca70d    
  
author   : Joe Conway <mail@joeconway.com>    
date     : Mon, 29 Jun 2026 16:29:11 -0400    
  
committer: Joe Conway <mail@joeconway.com>    
date     : Mon, 29 Jun 2026 16:29:11 -0400    

Click here for diff

Let the hacking begin ...  

M configure
M configure.ac
M doc/src/sgml/filelist.sgml
D doc/src/sgml/release-19.sgml
A doc/src/sgml/release-20.sgml
M doc/src/sgml/release.sgml
M meson.build
M src/tools/git_changelog
M src/tools/version_stamp.pl