Rename the WAIT FOR command to WAIT in the documentation
commit : 1a562a2661b30e72f37bdf8500fac01c347114ac
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 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 doc/src/sgml/release-19.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 : f260c03bccb709b61a0ddfdcc214134402150c0f
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 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 : 3e44c8a441f34117b3e6369fadfcbc94c7ae537d
author : Etsuro Fujita <efujita@postgresql.org>
date : Mon, 14 Sep 2026 19:00:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Mon, 14 Sep 2026 19:00:01 +0900 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 : 9e9dc104badf49c1f2e536ca3468e0f64f9a44a5
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 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 : acd8d3e0f906b4a65d1f155a6ec62bfd623d7a5b
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 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
Disallow SET UNLOGGED for tables in a publication's EXCEPT clause.
commit : 17d84c2b67f38cc3fc8b868c668297d59a299d97
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 14 Sep 2026 09:35:02 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 14 Sep 2026 09:35:02 +0530 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 : 2d48d0f153dc86c71a1ab80c5252ab35bb1d84b7
author : Richard Guo <rguo@postgresql.org>
date : Mon, 14 Sep 2026 12:27:21 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 14 Sep 2026 12:27:21 +0900 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
Fix Makefile build
commit : 4664929e5a2a57477e87745b87c8e40e60d1bcd4
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 14 Sep 2026 11:29:09 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 14 Sep 2026 11:29:09 +0900 db169985c10f has missed once reference to ddlutils.c in adt's Makefile,
making the build fail with ./configure. Meson was fine.
Per buildfarm.
Discussion: https://postgr.es/m/aqdaP73B-CIrmSPV@paquier.xyz
Backpatch-through: 19, only M src/backend/utils/adt/Makefile
Revert pg_get_role_ddl(), pg_get_tablespace_ddl(), and pg_get_database_ddl().
commit : db169985c10f02fa6d97920b0fafdde0ade3fde8
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 12 Sep 2026 11:54:41 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 12 Sep 2026 11:54:41 -0400 List of commits reverted:
4881981f920 Add infrastructure for pg_get_*_ddl functions
76e514ebb4b Add pg_get_role_ddl() function
b99fd9fd7f3 Add pg_get_tablespace_ddl() function
a4f774cf1c7 Add pg_get_database_ddl() function
6c7bce28c83 Fixups for a4f774cf1c7
1f108fc02ec Fix pfree crash in pg_get_role_ddl() and pg_get_database_ddl().
cda0c4c5d6f Reject invalid databases in pg_get_database_ddl()
79fba6ebaba doc: Fix missing role attribute in pg_get_tablespace_ddl() description.
c529ee38b9e Convert ddlutils regression tests to TAP tests.
df1bac400fb Fix timezone dependence in test_misc/012_ddlutils.pl
5642a0367c2 Avoid SIGSEGV in pg_get_database_ddl() on NULL tablespace
2af70e93747 Fix incorrect declarations of variadic pg_get_*_ddl() functions.
d6ed87d1989 Use named boolean parameters for pg_get_*_ddl option arguments
plus the corresponding release notes entries.
Discussion: https://postgr.es/m/20260827015242.54.noahmisch@microsoft.com M doc/src/sgml/func/func-info.sgml
M doc/src/sgml/release-19.sgml
D src/backend/utils/adt/ddlutils.c
M src/backend/utils/adt/meson.build
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/utils/ruleutils.h
M src/test/modules/test_misc/meson.build
D src/test/modules/test_misc/t/012_ddlutils.pl
Fail REPACK in presence of !indisready indexes
commit : e14a2354d9f7e44b0ffcaeaf187aa475e3e7d11b
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 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 : 6bc236c8a5b198e7ffde80377777167f1d4b78bb
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 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 : 854be98cc4aad48a960197e4d70b1da9063a906e
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 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 : f7c0929170a370f8229e66f54ea7396441efaaf1
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 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
Make on-access pruning pin visibility map before locking heap page
commit : b3609cd2db8d7fd13cc261b8b00d642cd31947cf
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 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 : e31766933ad63f76277d706ecee9e65e0870c169
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 12 Sep 2026 09:04:07 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 12 Sep 2026 09:04:07 +0900 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 : a160883053c3712af14c3035c7a1d5462a836a89
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 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 logical decoding to ignore updates without a new tuple.
commit : 7ed016a1de345ffac2d54979914c61617abae4ce
author : Masahiko Sawada <msawada@postgresql.org>
date : Fri, 11 Sep 2026 10:54:25 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Fri, 11 Sep 2026 10:54:25 -0700 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
pg_ctl: Silence warnings about unused global variables
commit : fbaeb88978f023e724bef1ce74fc46c65841401c
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 11 Sep 2026 19:12:43 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 11 Sep 2026 19:12:43 +0200 Several global variables are only used in Windows build. This causes
-Wunused-but-set-global warnings that the new clang 23 enables via
-Wall.
This commit marks these with an unused attribute to silence the
warnings.
(In the master branch, this is addressed differently, but for
backpatching, this just silences the warnings without any behavior
change.)
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/eb013f9d-2247-444e-8815-9d17b4ce78e7%40eisentraut.org M src/bin/pg_ctl/pg_ctl.c
Remove unused global variables
commit : e8601cb3d48de06e642683e91ef21f528e2ab462
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 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
Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tuples.
commit : 741f9d741e6dd9bc9174e4f522fc65b87b8d5ee3
author : Masahiko Sawada <msawada@postgresql.org>
date : Fri, 11 Sep 2026 10:20:46 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Fri, 11 Sep 2026 10:20:46 -0700 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
Doc: update v19 release notes for reversion of a9c350d9e.
commit : 6351dadfcf962a0bfa430cdbba05482acc45876e
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 11 Sep 2026 11:51:14 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 11 Sep 2026 11:51:14 -0400 Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20260904180712.cc.noahmisch@microsoft.com M doc/src/sgml/release-19.sgml
Revert "Don't try to re-order the subcommands of CREATE SCHEMA".
commit : e0fdc3f54b417daeca957eb95b5eb04a418cc3bf
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 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 : 3c5d28ba64e2b9a309076106cf0b66a013eaf180
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 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 : 434bde9ce6b0c71c051e47f03641d5ebd1c68a3b
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 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 : 090b44557d45686403d2d98c32d1d3add4337361
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 11 Sep 2026 15:19:17 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 11 Sep 2026 15:19:17 +0530 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 : 043bc68b224e25578b1cc7e8ee7d54e0d03c762e
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 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 : 2bc7b71dc168d537c67a307e5ac5d6c764bbc721
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 11 Sep 2026 17:49:42 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 11 Sep 2026 17:49:42 +0900 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 a row, and let the caller use SPI if the index is
unsuitable.
Add ICU regression coverage for per-row validation, ordinary inserts,
reordered index columns, and both directions of collation mismatch.
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 : f6b2d6b827a0f1a7485ca43a64b9ddfbebcd2934
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 11 Sep 2026 09:48:51 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 11 Sep 2026 09:48:51 +0530 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
Revert 87b2968df0 and 0a90df58cf.
commit : c58566d06f964166370e93f1bc8444a534bd0bd2
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 10 Sep 2026 18:13:17 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 10 Sep 2026 18:13:17 -0700 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
pg_plan_advice: Document interaction with GEQO.
commit : 9ed2684b89a43a2dd6295fdb151a0a98608457d4
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 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 : 6610a41ac7155d0d131dd861cb64c051554b4f73
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 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 : 07aef52eba3c2b10fb706f2ac48819597a339067
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 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 : 683ce2329c2d5fb2f7bf625131cd5d9de15987a8
author : Etsuro Fujita <efujita@postgresql.org>
date : Thu, 10 Sep 2026 17:30:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Thu, 10 Sep 2026 17:30:01 +0900 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 : ca3fd678f47becc5b84e0b027b2f062c5ad05b2b
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 10 Sep 2026 17:17:29 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 10 Sep 2026 17:17:29 +0900 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 batching from RI fast-path checks
commit : 25649d6e791c2d803fff0ce8b69ed968028a5edc
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 10 Sep 2026 14:41:54 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 10 Sep 2026 14:41:54 +0900 Commit b7b27eb41a5 added batching to the direct-index fast path for
foreign key checks introduced by 2da86c1ef9b. Instead of probing the
referenced index once per row, it accumulated referencing rows and
checked them in groups, using SK_SEARCHARRAY for single-column foreign
keys.
The batching requires state to survive across trigger invocations and
to be flushed at the end of each trigger-firing cycle. Follow-up work
has had to define how that state interacts with nested trigger firing,
subtransactions, deferred constraints, and SET CONSTRAINTS.
Failure to handle one of those cases can leave a buffered check
unperformed, allowing a transaction to commit a permanent foreign key
violation without reporting an error. With PostgreSQL 19 close to
release, there is not enough time to gain confidence that all relevant
trigger and transaction states have been covered.
Remove the batching and its after-trigger callback infrastructure,
including the per-batch RI cache and associated subtransaction cleanup.
Restore the early exit in AfterTriggerFireDeferred(), since batch
callbacks can no longer queue additional deferred triggers after
afterTriggerInvokeEvents() returns.
Remove tests that exercise only the batching implementation and its
callback and cache lifetime machinery. Retain tests that continue to
exercise the underlying per-row fast path, including validation,
scan-key construction, cross-type rechecks, deferred checks, and
metadata invalidation.
Keep the underlying per-row fast path. It performs each check
synchronously and retains no pending checks across trigger invocations.
Also retain the fixes made to the per-row probe path, including support
for domain-typed referencing columns, restriction to btree referenced
indexes, concurrent index replacement, metadata invalidation, and
nullable referenced keys.
This removal applies only to REL_19_STABLE.
Discussion: https://postgr.es/m/CA+HiwqEDcCSDoYTtoXH4Ta_BpGN+revMZSLLj6GRz2_5ybwE1g@mail.gmail.com M .git-blame-ignore-revs
M doc/src/sgml/release-19.sgml
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
Take RI fast-path snapshot after locking referenced relation
commit : 139018268375b3f09995d2c1819b0d838ddacf36
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 10 Sep 2026 13:31:39 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 10 Sep 2026 13:31:39 +0900 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
Fix pg_iswcased().
commit : b264391a846e8b5917b00dde2399c38843c75bb8
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 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 : e418e8eb92aa1dccca18b297a85c7ff38a7ee2a0
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 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 : d1f742d5d12654173b022fd7723ab206a3e3a3de
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 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
Fix duplicate enforcement of EC-derived conditions
commit : 7c620d2bf87bdb9508dd8cb40377f84388244dca
author : Richard Guo <rguo@postgresql.org>
date : Thu, 10 Sep 2026 10:03:53 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Thu, 10 Sep 2026 10:03:53 +0900 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 : be2602cfcc1578480ccefca66eda93975d2c10de
author : Richard Guo <rguo@postgresql.org>
date : Thu, 10 Sep 2026 10:03:13 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Thu, 10 Sep 2026 10:03:13 +0900 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
pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth()
commit : ddee5d03077c05925e83533e50ebe805c934d2cf
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 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
Fix hangs in COPY FROM (FORMAT text).
commit : 50ba390a4f81536aac13c1b8cf75c646a1156527
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 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 : 94cc8c443a3115531be7abe414dad5034ee3bb57
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 9 Sep 2026 13:45:46 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 9 Sep 2026 13:45:46 -0700 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 : 5dec175fb4c537947faaba504cda394b4ca6b726
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 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 : 40d811540a589cbddeb0736966f2541088134163
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 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 : 46c6fb9a82f2eaa0b56f1231e12e65af39e5ec84
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 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 : 04bb1500253489de049a0f26ff1843197c9da0c0
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 13:04:59 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 13:04:59 -0700 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 : 9bf3a414560d93ef8e8cf61748cd5783ab4bc9f9
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 12:06:09 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 12:06:09 -0700 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 : fe7b60723420c5279824c35efc45630889239a70
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 11:49:14 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 11:49:14 -0700 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 : fa48e39526b8d1cdc5b6e86074d6a3149fbd059b
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 11:12:36 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 8 Sep 2026 11:12:36 -0700 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 : 21b2808536859f1ffe257088df0f6f09edfd96a1
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 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 : 98f6984e5c0d180264d1e972c36252c8b36206ef
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 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 : 24dd8c369e5656a9c38f5494c9c57c38705ce62f
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 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 : d0518cb3e40503859e5dd17a0a75de9b8967fe4b
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 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 : f1940321687644a3ef38dccca8bbeb7c50d4cbdc
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 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 : c13e961c603cd0abb282d2a846ff8574dd80d3a1
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 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 buildfarm failure introduced by 6168c65ddc.
commit : d2384bc30f6882d30cb49e2912580ab95d642f3c
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 8 Sep 2026 10:45:33 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 8 Sep 2026 10:45:33 +0530 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
Fix nestloop parameter handling for PlaceHolderVars in child joins
commit : 729e4a322786381c68b83d014f8ad5be300b942f
author : Richard Guo <rguo@postgresql.org>
date : Tue, 8 Sep 2026 10:06:06 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Tue, 8 Sep 2026 10:06:06 +0900 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
Revert SQL Property Graph Queries (SQL/PGQ)
commit : 2b9e1aff4d3d933ae8ee377fef22c2af9c7797e8
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 7 Sep 2026 19:18:08 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 7 Sep 2026 19:18:08 +0200 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
ac0ad6a7c9d Prevent dropping the last label from a property graph element
36aae3d0297 Fix handling of dropping a property not associated with the given label
cc9aa7f3a98 Resolve unknown-type literals in GRAPH_TABLE COLUMNS
d8687368300 Make property graph object descriptions better translatable
45d4c917ff4 Fix properties orphaned by dropping a label
33bfad0f3ca Remove apparent support for SECURITY LABEL ON PROPERTY GRAPH
ccca2cd81b2 Fix pg_dump ACL minimization for PROPERTY GRAPH.
7883ea13ffd Fix replace_property_refs() ignoring the root of expression tree
b820c623dd5 Resolve unknown-type literals in property expressions
01c544e1afb Prohibit locking clauses on GRAPH_TABLE
8d2beee027a Restore the ability to use | and -> as prefix operators.
d2ac26eb9b1 Fix missing space before WHERE in GRAPH_TABLE deparse
4054ec5b4f3 Prohibit GRANT ... ON TABLE on a property graph
77964322d60 doc: Add PROPERTY GRAPH to the access privilege tables
c5e11de2f37 More tab-completion for DROP PROPERTY GRAPH
8ce749f8f65 Disallow aggregates, window functions, and SRFs in GRAPH_TABLE COLUMNS
22d0eebfef7 Report duplicate property and label names with a proper error
41a300ae3df Make generate_queries_for_path_pattern_recurse() interruptible
58af2138740 Fix inferred property graph keys with INCLUDE columns
63f8e9773aa Fix pg_event_trigger_ddl_commands for GRANT ON PROPERTY GRAPH
07df2b25327 doc: reformat GRAPH_TABLE examples
1c8c790ec10 Coerce GRAPH_TABLE pattern WHERE clauses to boolean
plus release notes entries and 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 doc/src/sgml/release-19.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 : 9186ffd6336763b9f38fee25b32f3e556b4ca518
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 7 Sep 2026 14:34:15 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 7 Sep 2026 14:34:15 +0530 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 : 2ad899642020ef7125818fddd494f5c76b928293
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 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
Fix incorrect error message in xlogreader.c
commit : 941568a9067267f71d5f68862584a92294828230
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 5 Sep 2026 09:12:45 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 5 Sep 2026 09:12:45 +0900 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
postgres_fdw: Fix issues with statistics import.
commit : f4012672bb2e5f1b0a4641826e14e9d209049dea
author : Etsuro Fujita <efujita@postgresql.org>
date : Fri, 4 Sep 2026 18:40:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Fri, 4 Sep 2026 18:40:01 +0900 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
Disallow joins whose lateral references need an unformable outer join
commit : 10a84539b9474310c849c4a6dc965f496864ec94
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 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
Fix lack of message pluralization
commit : bb238161f910cefe67c7c24522e817c831ea4909
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 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 : 08b016edd568cd154af3c23b8b347a8d1036498d
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 3 Sep 2026 13:56:52 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 3 Sep 2026 13:56:52 +0530 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
Avoid backend hang during temp table cleanup in deferrable transactions
commit : e65f21a274eb9de52b8286ff3b721259e6c37e82
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 3 Sep 2026 12:14:44 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 3 Sep 2026 12:14:44 +0900 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 : 9431cce4dc97fe3eaad73e6f98ac16d62755eb82
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 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 : 1c8c790ec104bbef338eb52a9dc17030cee7c82e
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 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 : 75716fe3ddbd98737459f1d24c7f459a7173ff27
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 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 : c0584c27f4f70935b3ccf31e58edb8e175fec447
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 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
Fix qual pushdown past grouping through simple CASE
commit : a3bc7f2c0de8ad5c6ae746cb6c1c5c187a60c124
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 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 : 7b4c2c1bcd366d4324fdee4f99c15e0b391d5f43
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 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 : 7635a3206797a9c793bcf2e43d107c9fe08dc17d
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 2 Sep 2026 14:14:22 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 2 Sep 2026 14:14:22 +0900 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 : f23de8dcba906ba27250f5f878e0684795eaf853
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 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 : 763d563eaec82528fdd49c07830a2dae00567778
author : Richard Guo <rguo@postgresql.org>
date : Wed, 2 Sep 2026 13:37:41 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 2 Sep 2026 13:37:41 +0900 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
Speed up pg_waldump TAP test
commit : 8e6860fb9638b5db784a24419d4441f0bf2cd04c
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 2 Sep 2026 09:19:32 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 2 Sep 2026 09:19:32 +0900 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 : c586a5336a5bd0fef2136424542f4738ae96bf94
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 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
M doc/src/sgml/release-19.sgml
Fix user-facing English grammar introduced in the v19 cycle.
commit : 6dbc931a39976dbbffca99e4e9c77d4d2a8cc240
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 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 : 7da24355a2993721bf9bc54224b3bb3e601530ce
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 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 : 1bda0b23bce47ab19d518ba51b26b9caed967782
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 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 : f26ab219e28ceb88b29f9165800879548dcc6646
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 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 : 938f4f8f343415f5ce17d0e3f0736b2c118d422e
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 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 : 61e64cb19a08c23dca1df46f1ae09df514059fc6
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 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 : ef67d599eff86203371e38f2d08ec6fa6236b5b2
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 1 Sep 2026 10:26:10 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 1 Sep 2026 10:26:10 -0700 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 : 1956251afa8bee718a236fcbf31a8f0da46e5055
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 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
Handle XmlExpr more honestly in clauses.c.
commit : f3ac68ffe38692582c24880ef10cc365ec683fa6
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 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 : a4da80419305797a24da544bb8514b6399ce0b1f
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 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
Wait for checksum state transition in test
commit : 135b867a530cac2e3796d87c852b53bef40f0077
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 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 : 2291b6ffbe2351deaada0f9bf7967c4db21a86e9
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 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
doc: reformat GRAPH_TABLE examples
commit : 07df2b253277321d68d515615ec6c0a3d70ec591
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 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 : 9efc2f9d8964ec927ccdeb4d461ff8070b0e6255
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 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 : ca8d4bdb047f97f00f03915bcd5fcb3d89534027
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 1 Sep 2026 08:12:38 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 1 Sep 2026 08:12:38 +0900 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
doc: Fix link on pg_dsm_registry_allocations page.
commit : 347486775812573f09c79e1f4d26d1f7506d261f
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 Oversight in commit 283e823f9d.
Backpatch-through: 19 M doc/src/sgml/system-views.sgml
doc: Drop stale note about extension LWLock names.
commit : 4186d7169b068a3f248e9795702d41ea9842a954
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 Oversight in commit 38b602b028.
Backpatch-through: 19 M doc/src/sgml/monitoring.sgml
doc: Fix the data type named in the regdatabase entry.
commit : 59335b5e71d552229f74ac41f3ef6b5a4d966535
author : Nathan Bossart <nathan@postgresql.org>
date : Sun, 30 Aug 2026 09:40:40 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Sun, 30 Aug 2026 09:40:40 -0500 Oversight in commit b45137f315.
Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
doc: Mark up "option" in the CHECKPOINT synopsis.
commit : efc3db99c41192be5bbce20be2199448ec227572
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 Oversight in commit a4f126516e.
Backpatch-through: 19 M doc/src/sgml/ref/checkpoint.sgml
Harden spell.c against out-of-order FLAG lines in Hunspell files.
commit : 50daffb0665e31ba9e223e3c9106a49f2c44eab5
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 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 : f23de46e15ba3faf38a97915df29ae98a472a16b
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 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 : 4af0528a0e49d06b997c443b044cb013503e1546
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 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
Fix pg_stat_autovacuum_scores for TOAST tables.
commit : 7ddb9c41a13534011bb64a856fb5a60e41b82b75
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 28 Aug 2026 15:11:06 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 28 Aug 2026 15:11:06 -0500 In v19, pg_stat_autovacuum_scores computes a TOAST table's scores
from its own storage parameters alone. On the other hand,
autovacuum falls back to the main table's parameters when the TOAST
table has none. This means that the view may report scores that
don't match what autovacuum would calculate. This contradicts the
documented promise that the view generates its results the same way
autovacuum workers do. To fix, teach the view to do the same
fallback. As in do_autovacuum(), we must make a preliminary pass
over pg_class to collect the main tables' parameters, since the
pg_class scan may see TOAST tables before their main tables.
Commit fad70a09ff for v20 improved autovacuum's handling of TOAST
storage parameters and adjusted the view to match, but it was
deemed too intrusive to back-patch. This fix is for v19 only.
Oversight in commit 87f61f0c82.
Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAD21AoB1CJRVfCDh8qYuD3eueiygXxk7F3nybgjN0RZXSD-QUw%40mail.gmail.com
Backpatch-through: 19 only M src/backend/postmaster/autovacuum.c
Perform join removal by editing the query's jointree.
commit : 0ab90a5c94188ab0a2113e36c73f093f741129c1
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 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 : 9d888cd3f34c4e9a8f7fbe7e78c70bbd84a481de
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 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 : 92d44b200e12c7ecbaee57d37fcd5e8803811358
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 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
doc PG 19 relnotes: move replication items to logical replicat.
commit : da8da39102788aabe2d479354cb146651825b094
author : Bruce Momjian <bruce@momjian.us>
date : Fri, 28 Aug 2026 10:04:58 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Fri, 28 Aug 2026 10:04:58 -0400 Reported-by: Masahiko Sawada
Author: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoC1dJGqngg_cdT_ayQjOdw6gmSBfVOTtAWOq-5C+XeLZQ@mail.gmail.com
Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
Make platform guards in two regression tests match meson builds
commit : 5523e4d9add7379398b5a998b83ddce3f64d72a4
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 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 : 15ccc2041ee864cccc8b72de4a1f21e9b51ccc47
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 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 : 7a74e5ed92d4e36f5b8da3db66457d6f32cf80f3
author : David Rowley <drowley@postgresql.org>
date : Fri, 28 Aug 2026 13:10:56 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 28 Aug 2026 13:10:56 +1200 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 : 3fcb7167198e1b2ecf8cc0d934c8ffe53755e0ae
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 27 Aug 2026 12:25:04 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 27 Aug 2026 12:25:04 -0700 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 : e721ce48dc78b58827c35d6a13f9f72a591e68f2
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 27 Aug 2026 12:10:49 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 27 Aug 2026 12:10:49 -0700 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 : 400c810ddbd7890f751913977e4442d71a0ebfc4
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 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 : 764d31b8ae360685b06913c7c6195ec1bfefcd33
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 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 : d225057849e2d4e013f1cd828f04084d004feb8f
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 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 : 4c5291435d40a0cf02b131b680a71e42243fcd04
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 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 : ba12a202ce1b5581dc0ed149cf3f637d7897ad5d
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 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 : 63f8e9773aadba37661f70629a0a0e8f5933afc8
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 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 : 58af2138740b3da0c866f1e20045c43bb7bacc0b
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 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
Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands
commit : 3e8bcc8644feaa9ca1cc954197b6994817af4290
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 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
Don't choose an invalid index for REPLICA IDENTITY FULL lookups.
commit : 3c73b272b42ecad68ad5c970bfd62d714ae03828
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 27 Aug 2026 10:05:51 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 27 Aug 2026 10:05:51 +0530 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
Pin two ctype-dependent test_regex_utf8 cases to pg_c_utf8
commit : 073bd832772fa9ee2460d8420d2275687fbe88bc
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 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 : ef89c839cdc8398095be0d24e65a688115e38b72
author : Peter Geoghegan <pg@bowt.ie>
date : Wed, 26 Aug 2026 15:38:15 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Wed, 26 Aug 2026 15:38:15 -0400 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 : 4d9224a436f0e728b0b1bdd70e72c798bf4bbe98
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 26 Aug 2026 12:03:54 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 26 Aug 2026 12:03:54 -0700 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 : 4f0af2635be7963c3250d0469e2c159dd0338574
author : David Rowley <drowley@postgresql.org>
date : Thu, 27 Aug 2026 02:41:21 +1200
committer: David Rowley <drowley@postgresql.org>
date : Thu, 27 Aug 2026 02:41:21 +1200 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 : b259ece92a951e799d8ace7a865d6269cc1cdd71
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 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 : 4680f32d333da51db3034047595dc0f567410625
author : Amit Kapila <akapila@postgresql.org>
date : Wed, 26 Aug 2026 14:40:23 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Wed, 26 Aug 2026 14:40:23 +0530 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
doc: Update REPACK-related table rewrite documentation
commit : dc8628e55d443120f4759a969ec329474a838ee3
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 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
Fix crash on trying to expand a shared memory hash table
commit : 31ad154242e2dc9fa9bbc4ebbe31f559e2282d9c
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 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
Further cleanup related to statistics import support in postgres_fdw.
commit : 77027b347cf94b38aa93f86d213002cd608230a4
author : Etsuro Fujita <efujita@postgresql.org>
date : Tue, 25 Aug 2026 17:50:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Tue, 25 Aug 2026 17:50:01 +0900 * 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
Fix incorrect cast in Assert
commit : 2c654c4ea1b6a960dd6cda1387dd1dd335e6e651
author : David Rowley <drowley@postgresql.org>
date : Tue, 25 Aug 2026 20:16:52 +1200
committer: David Rowley <drowley@postgresql.org>
date : Tue, 25 Aug 2026 20:16:52 +1200 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
Don't assume DISTINCT ON implies uniqueness when the tlist has SRFs
commit : d446ca2c459c5541c257fbff05ec5a0bdbeb6a0c
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 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 : d6e4e22e9143749a9b629f2149e78edf2b6e0ec0
author : David Rowley <drowley@postgresql.org>
date : Tue, 25 Aug 2026 10:43:08 +1200
committer: David Rowley <drowley@postgresql.org>
date : Tue, 25 Aug 2026 10:43:08 +1200 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
ltree/crc32.c: fix fragile code.
commit : 5ce1cf485c2382fdd40ce54a0a39bece8f67b451
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 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 : c96cd80d6055cc2fec3335efe08ca897c6a5c012
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 24 Aug 2026 11:51:35 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 24 Aug 2026 11:51:35 -0700 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 : 3b984ab52a4eb667b49271fbde5dfbff7b5ef801
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 24 Aug 2026 11:51:15 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 24 Aug 2026 11:51:15 -0700 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
Fix untranslatable message that was pasted together at run time
commit : 250942b0d8212f8bdb10b9d63a911aeea5dd4de0
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 M src/backend/storage/page/bufpage.c
Allow an aggregate's planner support function to be set via CREATE AGGREGATE.
commit : 165aa5040a02e13011f07e3c6669ac0edf4f8258
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 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 : b13fd289988067dd09ccc08243fcab803804595b
author : Peter Geoghegan <pg@bowt.ie>
date : Sat, 22 Aug 2026 14:50:39 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sat, 22 Aug 2026 14:50:39 -0400 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 : 268958a2e5feac370844e164a4e7e2535f6d2bc7
author : Amit Langote <amitlan@postgresql.org>
date : Sat, 22 Aug 2026 16:23:28 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Sat, 22 Aug 2026 16:23:28 +0900 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
Doc: fix typo
commit : 051be721d02a7b1dedc10521db43a94bcf8a739a
author : David Rowley <drowley@postgresql.org>
date : Sat, 22 Aug 2026 12:49:17 +1200
committer: David Rowley <drowley@postgresql.org>
date : Sat, 22 Aug 2026 12:49:17 +1200 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 error code for null FOR PORTION OF target
commit : c7e34c31e844b2234fa57fef12ae37f30c8f5a9b
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 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 : c63b210ed34d9153e82c86abba3160a569b86f72
author : Etsuro Fujita <efujita@postgresql.org>
date : Fri, 21 Aug 2026 17:50:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Fri, 21 Aug 2026 17:50:01 +0900 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
psql: Do not let invalid \getresults affect the next query
commit : 2b0d50e39c58e14b69de76aae2a1c73877de52a6
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 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
Attempt to stabilize plan of self-join test in tidscan.sql
commit : c06bf14e87c0fe9cda937a5de3ec2a698b249554
author : David Rowley <drowley@postgresql.org>
date : Fri, 21 Aug 2026 12:26:34 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 21 Aug 2026 12:26:34 +1200 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 : ca99016f939dc1e1b260c3ea16721948a1558ef7
author : Peter Geoghegan <pg@bowt.ie>
date : Thu, 20 Aug 2026 19:47:31 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Thu, 20 Aug 2026 19:47:31 -0400 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
test_aio: Fix broken error recovery assertions in 001_aio
commit : 86ed13547589d8401b3b1e1ec2873903b287cb80
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 21 Aug 2026 07:05:11 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 21 Aug 2026 07:05:11 +0900 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 : 3849ce5b3094f6d679a4c474f0654eba5187b14d
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 20 Aug 2026 13:54:45 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 20 Aug 2026 13:54:45 -0700 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
Ensure all pg_locale.h APIs work with collate_is_c.
commit : 5e9d23f98cc1c5a7b4add5b843a564fe9c35c6b3
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 20 Aug 2026 09:24:50 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 20 Aug 2026 09:24:50 -0700 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
Skip bogus find_composite_type_dependencies() call on sequences
commit : d85a2590075fe652739a18be6f4bf0047a433218
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 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 : d2a710c7e9e08e101694fe6c1f6789f18f9d3dcf
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 20 Aug 2026 17:12:53 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 20 Aug 2026 17:12:53 +0900 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 : 28f9c5b5777bcb27de2e63a5feb41ec82d225992
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 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 : 3861984342d85898a674fa0c7c93019317bfcff7
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 20 Aug 2026 15:17:29 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 20 Aug 2026 15:17:29 +0900 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 : f3a52a229adeb9c54e5b656b45af609b967874d6
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 20 Aug 2026 14:02:57 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 20 Aug 2026 14:02:57 +0900 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 : 2a2076da14077518cd01b19fff7ac6251871e9dd
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 20 Aug 2026 09:38:27 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 20 Aug 2026 09:38:27 +0900 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 : 29f7881a5fdb6f0282a32bdb4fe7ef3c03e88a7f
author : Peter Geoghegan <pg@bowt.ie>
date : Wed, 19 Aug 2026 15:45:54 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Wed, 19 Aug 2026 15:45:54 -0400 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
pg_locale.c, unicode_case.c: use size_t for iteration.
commit : c684d98c3da783d37321649dd75df3f67ec98b99
author : Jeff Davis <jdavis@postgresql.org>
date : Wed, 19 Aug 2026 10:36:44 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Wed, 19 Aug 2026 10:36:44 -0700 Already done by e615da8cb21b in master. Backpatch these particular
cases to make other backpatches in this area safer, and to be safe for
callers in extensions that we don't know about.
This applies to REL_19_STABLE and REL_18_STABLE only.
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/v36ssaygf7grb3qzfsjhtdzi7kqd45ds56nyuf7gi5qjml4qbb@ezmfqzmhlrs2 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/common/unicode_case.c
Fix GIN multiple-VACUUM-scans pending list bug.
commit : adf440cbe69920b0475ffca118041de4a8e369ca
author : Peter Geoghegan <pg@bowt.ie>
date : Wed, 19 Aug 2026 13:46:44 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Wed, 19 Aug 2026 13:46:44 -0400 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 : 6ee9a8b398c0e5024568bc9333b0f5458287a0c1
author : Peter Geoghegan <pg@bowt.ie>
date : Wed, 19 Aug 2026 12:31:07 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Wed, 19 Aug 2026 12:31:07 -0400 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
Tighten ACL check in repack_is_permitted_for_relation()
commit : 9bb8e16bd53e2c8a822bf13832c4dcb3905a34e5
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 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 : abca12838fefabbf146307447c23176ec7eb67ed
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 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 : 18a15b9673809c6b4848575aa14aaa8e0e5c7a33
author : Amit Langote <amitlan@postgresql.org>
date : Wed, 19 Aug 2026 16:06:05 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Wed, 19 Aug 2026 16:06:05 +0900 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 : ca86b45adddc5385c50e974a0905b7938eb10487
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 M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/partition_split.out
Message style fixes
commit : b6b1f89847f7bece7fab2ef392d3c84a7ee6f88d
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 M src/backend/commands/analyze.c
psql: Fix psql slash option leaks
commit : e3ad751e1f43a97a3ed5da358a938f8f87b6a4a1
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 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 : e793e51abab3987dd55d4598316e60966c9e159e
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 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 : 9d4505b7f826b649501253c094aea5c28a66f266
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 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 : 4a710d68871cd9bbdcc57b244dbbeeca08de7735
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 19 Aug 2026 11:32:47 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 19 Aug 2026 11:32:47 +0900 ReorderBufferProcessTXN() opens every relation referenced by a
TRUNCATE change. When RelationIsLogicallyLogged() returns false,
it skips the relation without releasing the reference acquired
by RelationIdGetRelation().
Looking at the in-core code paths building XLOG_HEAP_TRUNCATE records,
no relation OIDs would be included if they do not satisfy
RelationIsLogicallyLogged(). One pattern that could go through is if a
table is switched to SET UNLOGGED, but that would not be reachable in
practice as the decoding happens after a historical snapshot is taken,
so the relation should still be valid.
This is a defense-in-depth measure in practice, and we tend to be
careful about how Relations are handled when sending changes to output
plugins, so backpatch all the way down.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7DD65D03-3B5A-43B2-99AD-8E6AF5372BAB@gmail.com
Backpatch-through: 14 M src/backend/replication/logical/reorderbuffer.c
Report single-page checksum failures in pg_stat_database
commit : db0f6dd80a0323bd39a5566f72699b6cbfe204bc
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 19 Aug 2026 09:51:52 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 19 Aug 2026 09:51:52 +0900 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
Defend against null "SV *" pointers in plperl modules.
commit : fe06b9b5bd61dc04ab788091c56a0cb9ef44b3d2
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 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
Stabilize the FORCE drop test for online data checksums
commit : 1d28812160d4e7ec06ebb2223d2c67b0dec74720
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 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 : c61c3ec40cb8e08fe54573de7cf1a27fa4d10f9f
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 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 : 0907112d3882192f3c14d5ce0735790341e073ed
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 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 : 397f0fd06edc3a5b114449164c5d39c59a468b61
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 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 : aaf8b9989f7aaeb6594122caee1eea6c87e10655
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 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 : fe91799d3bc6511247a58643b095b5f9a1ccd660
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 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 : e4f16fda6e1479b4fdfa6dc31dd41f48c86426fe
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 18 Aug 2026 11:56:52 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 18 Aug 2026 11:56:52 -0700 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
doc PG 19: update to current
commit : ffb7e3af79b307cf93a5a26e0ddc4e96f420befc
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 18 Aug 2026 10:43:33 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 18 Aug 2026 10:43:33 -0400 Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
test_json_parser: Fix broken file ref and inverted result check
commit : 96c34b1a8bb5b083c5f4cf5eee91e5edd63e8edd
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 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 : f8408134dd47f9a99c6452b91da7271084a9e6a4
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 M src/backend/access/transam/slru.c
M src/backend/libpq/be-secure-openssl.c
Re-register LSN waiters after stale wakeups
commit : 0ec36f4ba325062882eb7a36b8f815e85ff8c123
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 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 : f2d6392e199256dd4a37bebbc92a2d28fac45b5f
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 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 : 58c48b4ec42583c69b3a7e9c6cf7649b38fc8151
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 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 : d2eb714c7ae70afc1837da5db4393b0f50dcc77f
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 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 : 7864a14c4370b11cac74bcdf4cae5bb6a6ae867b
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 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 : ec51b80b348fe34da15cfb991191ef0bdc4838c6
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 18 Aug 2026 17:07:02 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 18 Aug 2026 17:07:02 +0900 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
Fix cross-type foreign keys in the batched fast-path FK check
commit : 3b70fa6f3d32ac832ed9ddd566c11b05e575f2c7
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 18 Aug 2026 12:16:02 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 18 Aug 2026 12:16:02 +0900 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 : 2d893fd926eb17b6d85d1eb7f1f6d615b2e68ba9
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 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 : 1c732c8518d88c2663f96236bf8bb104f3d0a5d4
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 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 : 9c1e3b58bf541fca073892ddc4f81eef85067b50
author : Peter Geoghegan <pg@bowt.ie>
date : Mon, 17 Aug 2026 17:31:11 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Mon, 17 Aug 2026 17:31:11 -0400 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 : abac86c7a27a4604c07a3a85ca02dae4b12ae8c8
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 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 : 3a18526e8d6bcdd25db847128dd83bb4c1ba6ec2
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 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 : 81aa0a2fa7c4d35511e68daf1ba47bdfa3ec5474
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 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
Make plperl's handling of Perl arrays safer and more consistent.
commit : b6b4f5a6460a6c2634924dd44e0b07f990b8aae0
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 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
psql: Fix \d+ display of REPLICA IDENTITY NOTHING
commit : 67342a148632801d44c2fb9a7bf4231b6827c5d2
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 17 Aug 2026 09:21:06 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 17 Aug 2026 09:21:06 +0900 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 : 13967fe0e2b64cfcaab53ca05f4e11b34147423e
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 17 Aug 2026 08:53:24 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 17 Aug 2026 08:53:24 +0900 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 : 7b846015a40df872db572d92476d1e7c4e0c0066
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 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 : c9bd90242db70e9a7bec9897a124faf2a6f80168
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 15 Aug 2026 23:26:57 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 15 Aug 2026 23:26:57 +0900 M .git-blame-ignore-revs
pgindent fix for commit 7b7c4a8dcc9
commit : 3d2f2eb1664e5c823b66a063d2de9a9787970d42
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 Per buildfarm member koel. M src/backend/optimizer/plan/subselect.c
Rename EXISTS-to-ANY converted subplan to exists_to_any
commit : 3ab3f33281f62bdcef1dd987a89fcfe7f082b6d8
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 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 : 16742849a3dea3d8e6331471cb5134ca4aec14b2
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 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 int64 for number of entries in pg_stat_statements
commit : de73e691e7f53a4fe08f09928a9f72331476a439
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 14 Aug 2026 21:52:06 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 14 Aug 2026 21:52:06 +0200 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 : e19cd26f06c9ed4a6994accbbdcbef9ab05b2ad1
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 Oversight in commit ffca23839c.
Reported-by: Anton Voloshin <a.voloshin@postgrespro.ru>
Author: Anton Voloshin <a.voloshin@postgrespro.ru>
Backpatch-through: 14 M src/include/utils/acl.h
psql: count every COPY FROM STDIN when scanning a query string.
commit : 7f8de6d877c2440480eb4fcd2fd6a503a373065f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 14 Aug 2026 12:14:24 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 14 Aug 2026 12:14:24 -0400 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 : 41a300ae3df5015d0779728ee0b4adb866953d31
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 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 : f3a116a26ff0c0be83b990d3d9b3fd9e425bb197
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 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 : 48965e14655a007c1250dbd4a1aba65e478ce929
author : Etsuro Fujita <efujita@postgresql.org>
date : Fri, 14 Aug 2026 17:40:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Fri, 14 Aug 2026 17:40:01 +0900 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
Fix authorization check for role membership changes.
commit : 9db2383e0041324f01c066fa9b000750c385bfff
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 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 : d7db169fa13a7e4db9013816c7a2c498bd304fba
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 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 : 5185e64ae0b220fac434f10a490bf108f01cb66a
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 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
vacuumdb: Use ANALYZE ONLY for partitioned tables
commit : 9e725e77a5d8356a2237a15025b57d75b08e87e4
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 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 : dc6c9c540b5a4bf5aa2aedc8959b0d015004d45c
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 13 Aug 2026 10:10:46 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 13 Aug 2026 10:10:46 +0530 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 : ed23f7ce7f8f633175ae785d18577fbc440139ae
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 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 : 82c86ac6822033cff10a39496925c02ca7adc532
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 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 : 94f94b245c6598f3a2b1d5ee3c463719ea83c869
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 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
Fix stale comments/signature after commit 28d534e2ae0a
commit : fd56954c9fe69bdc899d7cad93ec0b22b663cb30
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 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
Use per-query timeout in subscription test
commit : 7cda7b50d562a03f1c2e0c1d2f2e970acbd769e8
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 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 : 7ff4ee83f7aeb5650e7783cced9d662381cbd94d
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 12 Aug 2026 16:23:10 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 12 Aug 2026 16:23:10 +0900 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
Change wal_compression=on to the first of zstd, lz4, pglz
commit : 5838806ce696dd0759c5e4b87754e802612135e0
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 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 : cf9453b919c75674a9349090e02dcff1c4d2a5e9
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 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
Stamp 19beta3.
commit : 3638289fb57bdabec00deda98ee9624a35f5d66a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 16:50:29 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 16:50:29 -0400 M configure
M configure.ac
M meson.build
psql: Don't do backquote expansion in \unrestrict.
commit : 0119aa30e0fc78771681cc54e4133bf7bd3a77dd
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : d97b3f58c1c49d396841f86531bf82a315d24e86
author : Jacob Champion <jchampion@postgresql.org>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : ba207f58f38955fdd787839eb757d48fa8c15c5b
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : 80ce920a5a42a43d98ac40d174fea8ae518abf63
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : d6ab88d374ab6bd6fead0902f7e7ff6ebc8b9006
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : 8cf01e213ccc33e22e87b49e2711e4a83b4f01e0
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : 567286b762bcb7a70233e5bb4b401fc62f9424ee
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : bb1bc525dc01985efeda58a3e613e381146df6a7
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : 424fb7160bc51d55c4be2023d9238f2db8807b35
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:06 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:06 -0700 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 : efdb260728c93f605f9ef7aaef56b013f6bb87b7
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 62c31b490d94b38a62869593524abca5f67c4c46
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 64a65ead1235f50816a46d4eb66a8ffcba7d5cde
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 5d47df21e89967e351df5ad7aa93bc3af40db64a
author : Jacob Champion <jchampion@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 7082ce248a52d02507c69aa2eadafdd34552a059
author : Jacob Champion <jchampion@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 557cc7186435c7e228c8e4074254a84d1e845790
author : Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 4d192fa168cf43c6431bf96941d8c709bb92bf5d
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : a3832a7571013469dc81e35d0fe1c0066e86d893
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : b3d9262bbddcbfd1be1dbd43a48bc155234d21e1
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : bf1bb7e29cb1eddb0fad7422c032abb2b756c281
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : 457b8737ab29ec5e29fc06dcc019795c40e6f261
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : a1c1727cb400b8ae61a13844d7e22ef38e7da79b
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 10 Aug 2026 06:38:05 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:05 -0700 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 : aa7b5815ea099763b1cfe01e431b0ec8312c943f
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : bb02eba534112594bc44a4b4c4fe9acb7ac7d656
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 93b93f28fb1a3aef83a2fa979f54cc1b4eae5fcc
author : Masahiko Sawada <msawada@postgresql.org>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 21d8cfb18f465be344dd83852792b88818c33634
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 21a00de43b3d887a72d79ac91407baa284070ed2
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 42d9749b7ab56a7cbd751d136aea7abe1c0db887
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 86cd82bf4887cd7abf2f0203d3e1a09e7022746d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 92972e815d85038ccb8574a1d7e2f2df8d148fe9
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 0d60ee71727ccd71a791b088a91c4bd8c1fb85e4
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 8c48cd615195e80925fb81ad77bd08a8bd4eb0c2
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 7df2aa8efeba44189dc8d763da34ce171422307e
author : Masahiko Sawada <msawada@postgresql.org>
date : Mon, 10 Aug 2026 06:38:04 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:04 -0700 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 : 3b2238fbe9b9cc95f026fd4129804a72d0c22151
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:03 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:03 -0700 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 : cb947ca31f6947f3746341a635f90395a3ee52e6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:03 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:03 -0700 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 : 3294ab83947270a44f680a1725383e6521315b70
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 10 Aug 2026 06:38:03 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 10 Aug 2026 06:38:03 -0700 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
Translation updates
commit : b330f4978df65116c4339aeea0796ca2b9717214
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 10 Aug 2026 12:10:27 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 10 Aug 2026 12:10:27 +0200 Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: 1cfa61615af29902242c24687492c8e49d94c1d0 M src/backend/po/de.po
M src/backend/po/ru.po
M src/bin/initdb/po/ru.po
M src/bin/initdb/po/sv.po
M src/bin/pg_amcheck/po/ru.po
M src/bin/pg_archivecleanup/po/ru.po
M src/bin/pg_basebackup/po/ru.po
M src/bin/pg_checksums/po/ru.po
M src/bin/pg_combinebackup/po/ru.po
M src/bin/pg_config/po/ru.po
M src/bin/pg_controldata/po/de.po
M src/bin/pg_controldata/po/ka.po
M src/bin/pg_controldata/po/ru.po
M src/bin/pg_ctl/po/ru.po
M src/bin/pg_dump/po/de.po
M src/bin/pg_dump/po/ka.po
M src/bin/pg_dump/po/ru.po
M src/bin/pg_resetwal/po/de.po
M src/bin/pg_resetwal/po/ru.po
M src/bin/pg_rewind/po/de.po
M src/bin/pg_rewind/po/ru.po
M src/bin/pg_rewind/po/sv.po
M src/bin/pg_test_fsync/po/ru.po
M src/bin/pg_test_timing/po/de.po
M src/bin/pg_upgrade/po/de.po
M src/bin/pg_upgrade/po/ka.po
M src/bin/pg_upgrade/po/ru.po
M src/bin/pg_verifybackup/po/ru.po
M src/bin/pg_waldump/po/sv.po
M src/bin/pg_walsummary/po/ru.po
M src/bin/psql/po/de.po
M src/bin/psql/po/ru.po
M src/bin/scripts/po/ru.po
M src/interfaces/ecpg/preproc/po/ru.po
M src/interfaces/libpq/po/de.po
M src/interfaces/libpq/po/ka.po
M src/interfaces/libpq/po/ru.po
M src/pl/plpython/po/ru.po
Fix hot standby accepting connections too early after a crash reset
commit : 7673dfe771e9de85b079ea2ec5cc6f22c83adab1
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 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 : 55d01a10f2b79c9ed76cbf668f35863f4be7112a
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 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 : a05ece57b16088e564bf95f92646350bafa2cfa1
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 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 : d1458441e03ba23e6c79e144de938592f19f8273
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 7 Aug 2026 17:43:47 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 7 Aug 2026 17:43:47 +0900 M .git-blame-ignore-revs
Fix indentation issue introduced by commit 291a4bd2ca
commit : 52d87b42d9bef6a2ca66572fc39e5c1b0f61f5dd
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 Noticed before the commit reached koel. M src/backend/commands/trigger.c
Drain pending asynchronous requests during ExecReScanAppend.
commit : 7d74b26447229cccc2005d8b48b36bcd8bd17f33
author : Etsuro Fujita <efujita@postgresql.org>
date : Fri, 7 Aug 2026 17:30:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Fri, 7 Aug 2026 17:30:01 +0900 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 : acdfaee1b947776ec381a4756f01979d31316774
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 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 : f68f47fe7d66a475d934823624013bcb7fae6f01
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 7 Aug 2026 16:34:00 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 7 Aug 2026 16:34:00 +0900 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 : 8c0aa08c159494a86fe5c3206e8a9f5de850112e
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 7 Aug 2026 16:30:15 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 7 Aug 2026 16:30:15 +0900 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 : c17b91ed9f84e43efc9a3d41ade5d1d1b827f8d4
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 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 local pgstat entry leak on OOM during entry creation
commit : 89fc6a7c12f2ee6d75e6ebab06844edd4737c348
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 7 Aug 2026 14:23:33 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 7 Aug 2026 14:23:33 +0900 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 : cacba321c2ef9dfd1c1b6924b6c7291a1182d2d6
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 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
Restore vacuum failsafe abandonment of buffer access strategy
commit : fd90c3221850d9ee1d05f4ce3f5420a54b3e471c
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 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
Report duplicate property and label names with a proper error
commit : 22d0eebfef780b21c4e5a16966eff59fb7a9b9d6
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 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
Fix race condition in subscription TAP test 023_twophase_stream.
commit : f4e44f184cef6a80b4d11bbaeaf2b13e59c1dd8e
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 6 Aug 2026 11:33:05 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 6 Aug 2026 11:33:05 +0530 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 : 4edd59de527780f536fbbf97d5e117524ded2723
author : David Rowley <drowley@postgresql.org>
date : Thu, 6 Aug 2026 17:43:26 +1200
committer: David Rowley <drowley@postgresql.org>
date : Thu, 6 Aug 2026 17:43:26 +1200 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
When changing owner of a subscription, do not throw an error.
commit : a1e39c501d7a89a01c2738fecf7b66927e4e8bb7
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 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 : 45b479a836ec5434933b5d57fdc2c215b7e11b61
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 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 : 1718a16433a3f6572e0ff9c64ef394ae8fec3765
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 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 : caadb9e97f571e19f359a42ad186df877ea834c7
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 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 : 5ba18183c4ca34beeedf7023d1f260ba1f5e9f87
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 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 : ae420d66e72051b7ceab49d14f990094f1c8c6b4
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 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 : f567e066d6e3d09b1db740d0a891b9464c64caa2
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 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 : 8f7617ff7af60f4d9b2be0ba2d89b2fedbc027cc
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 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 calculating length of match to localized month/weekday names
commit : 55ea764269b6fe8b3fcc221a970c09e12ef7a96b
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 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 : 8ce749f8f65c8991d6d2f5010116530e0d7fb2ad
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 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 : 0e2fb2c8c307aaee5ab47aa92055b53ca146706b
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 5 Aug 2026 16:55:26 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 5 Aug 2026 16:55:26 +0900 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 : c5e11de2f378b8e52893bfcd3f6ffd583fffc160
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 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 : 4642ddc2a58623af6934bec1708d901a3a8e9cd4
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 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 : 3d4216d85f42d9f011001367d5f962ca8d1d72e2
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 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 : 1aaca5ab8ffb7f9387dce2a2de128eff006ac1c4
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 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 : 2f768dda531c94c071972a68d77163fba35684a6
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 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
psql: Message style fixes
commit : 8126fe4739b52f930a1bf2b9f205536e3b26f81b
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 M src/bin/psql/help.c
doc: Make synopsis placeholders consistent
commit : 16aba1f9b3addecc6f8463ac2ab783551627d148
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 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 : 01805b7d16b9a06d5223071215db0337bc8e6d92
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 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 : 1f24c823720dfbd6632383c8e8ba92a4b3bc0785
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 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 : 77964322d608f33b34f455ac2d3bd772f222160f
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 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 : 4054ec5b4f39272f5009516db19fb7c253989ebd
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 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
Fix error handling in getCopyDataMessage() and pqFunctionCall3()
commit : 8380013cd288ca35d225f862c809ec64b563d4fd
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 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 : ce6e434ceeb05d1aaf64a3f48c5927f46ea3c2e0
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 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 : 7746f7492d5b521f66af1e99cd42024cae8dde82
author : David Rowley <drowley@postgresql.org>
date : Tue, 4 Aug 2026 17:59:58 +1200
committer: David Rowley <drowley@postgresql.org>
date : Tue, 4 Aug 2026 17:59:58 +1200 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 : 5cb0f004f179435dcb53b94e9b5827d540886b42
author : David Rowley <drowley@postgresql.org>
date : Tue, 4 Aug 2026 16:09:29 +1200
committer: David Rowley <drowley@postgresql.org>
date : Tue, 4 Aug 2026 16:09:29 +1200 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 : 98bcb0ab8aa3c783adc27e677ab861a4a8baa411
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 4 Aug 2026 08:52:00 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 4 Aug 2026 08:52:00 +0530 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
postgres_fdw: reject use_scram_passthrough for subscriptions.
commit : 8c1723f550a7adf6373c8c507e819fc3249d793a
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 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 : 608704adee75fd4316a10f4aa9a93aa8c6dc7eeb
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 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 : 9eccdae22aca63360c48f5005d062a1684f017af
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 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 : 343d98c3601abf3060ff82b7b2a8bc7903105bf3
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 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 : 72b0fee51df2e5d9ab3313407f1a5313fd768882
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 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 : 072b962d99c6317e5cd5a5ac11b21fae2cab6f8a
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 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 : 1d24c588975a3982720cd7874496d1dffb83d292
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 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
Fix missing space before WHERE in GRAPH_TABLE deparse
commit : d2ac26eb9b1e8ad19fd526efb0ffff4fae5ed56f
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 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 : 3fb599b26411a1322dec89759349ce4920e1055a
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 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 : df8407d7dc7dc77165f56e5bdfed13ac72048696
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 2 Aug 2026 16:49:18 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 2 Aug 2026 16:49:18 -0400 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 : 3fe4062cc6216e4edee1ac981020173b3dc01a81
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 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 : 3c16aa29305e5ae1244132008f337780525c04e7
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 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 : 4afa9788b51625d19eee08a1420b48b04c0699fa
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 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 : 602f19c84ca1db471b6264d4965e2becfc00cbbc
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 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
Allow IO time to be counted without a matching IO operation in pg_stat_io
commit : d6792cc58e9c0aead136f381052151e1c246b534
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 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
Add list of major features to the v19 release notes.
commit : 0c57a40694d88cdda588b5f8a6e5568861d1759d
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 31 Jul 2026 14:00:37 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 31 Jul 2026 14:00:37 -0500 Reviewed-by: Michael Banck <mbanck@gmx.net>
Discussion: https://postgr.es/m/akWIxtcathhoUuCQ%40nathan
Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
libpq-oauth: Avoid overflow for very large intervals
commit : 19ff9a1ae04087ff324dc2180c757d56258ab89a
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 31 Jul 2026 11:13:41 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 31 Jul 2026 11:13:41 -0700 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 : dfb96277d7ba01d3bcb70a64b7835182ae419022
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 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 : b3331578b58650be6811e842d79937c4a51b74ef
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 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
Fix Hash Join performance issue when hashing NULL values
commit : a71a348ed1e081d3bd32f0b1f9c177f44f9a822a
author : David Rowley <drowley@postgresql.org>
date : Fri, 31 Jul 2026 23:24:23 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 31 Jul 2026 23:24:23 +1200 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 : c7d8049682d623109a40de0c84d68e114c013c26
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 31 Jul 2026 09:51:08 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 31 Jul 2026 09:51:08 +0530 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 issue with RANGE's DEFAULT partition pruning
commit : f9282a65058b30f0e10fc5dff0171bbd6eb9a254
author : David Rowley <drowley@postgresql.org>
date : Fri, 31 Jul 2026 15:37:12 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 31 Jul 2026 15:37:12 +1200 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
Fix incorrect Result node flattening logic
commit : 4a791db9bdbd48280e752578b93909995f93fe49
author : David Rowley <drowley@postgresql.org>
date : Fri, 31 Jul 2026 13:16:29 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 31 Jul 2026 13:16:29 +1200 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 : 5c808b8c5c395a7d7afea7efaaa3328b4bc4e004
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 30 Jul 2026 16:17:13 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 30 Jul 2026 16:17:13 -0700 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 : 6a80179f6b09a6c71a48e864cc4e85f3ea2f4e3c
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 30 Jul 2026 12:47:08 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 30 Jul 2026 12:47:08 -0700 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 : 068447dcd9d7def7b58531078d167c280d9d1861
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 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 : 5707d7517fa893f6d36b0e4a1173ee71699ada48
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 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 : b835cdba9aa96cc338ba8d9dc979a29b48fca88f
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 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 previous commit to .git-blame-ignore-revs
commit : 6d38b535d6f5789ef604ea4147825cf07bd127e3
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Jul 2026 09:30:53 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Jul 2026 09:30:53 +0200 M .git-blame-ignore-revs
pgindent fix for 4ee0ccfd
commit : b1aeda3ec939c2867e5c3eb4ee7e1bae4768503e
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Jul 2026 09:26:07 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Jul 2026 09:26:07 +0200 M src/backend/commands/vacuumparallel.c
Skip SUBSCRIPTION TABLE TOC entries with --no-subscriptions.
commit : 33cffe591deebb873bc7b97a5f5d10eda9d219ae
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 30 Jul 2026 11:49:33 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 30 Jul 2026 11:49:33 +0530 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
doc: Add a note that refint will be removed in v20
commit : 55c81430af1c70d5ed250f320f82e31d9a3e63e0
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 29 Jul 2026 21:51:46 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 29 Jul 2026 21:51:46 +0200 refint has been removed from the spi contrib module in v20. Add a note
to the documentation of the still-supported back branches so that users
are aware the module is going away.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reported-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAJTYsWUHq8Ohc6-N-xamOPYz-q3qUYMtwQX-1=Zi=5N1Q_GSEQ@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/contrib-spi.sgml
doc: remove added space within synopsis replaceable tags
commit : bc90a53455836a61c4282073866325d3c14954d5
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 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 : 4ee0ccfd55f973160a2ab013bc96488715221270
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 29 Jul 2026 09:52:10 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 29 Jul 2026 09:52:10 -0700 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 cascading standby reconnect failure after archive fallback
commit : bef46aed394917be95f6572f64af90e24b1c0652
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 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
Protect PGPROC lookup when terminating background workers
commit : 16c3435794befad6499449cbd73696f6d3ca8e24
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 29 Jul 2026 17:39:40 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 29 Jul 2026 17:39:40 +0900 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 : e46c2a65710f021e25bc0fcf404dd00c86aec1d7
author : Amit Kapila <akapila@postgresql.org>
date : Wed, 29 Jul 2026 09:39:59 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Wed, 29 Jul 2026 09:39:59 +0530 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
Fix planner's nullability/strictness logic for ScalarArrayOpExpr.
commit : 9740c68ff7aa5d5a2d40c3ff0172467b38a17df8
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 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 : e469e4784ea9f632b91e5d988cd336cbf54af58a
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 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 : 9eb77f9fc80db071b434aea58681ed2adb9038d3
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 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 : 2289e65e15ee53cbba2d96543553c467c9ccbc4e
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 28 Jul 2026 12:33:31 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 28 Jul 2026 12:33:31 -0700 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 : 28c995948cfd6b8ff3b2576aedd6f3d38107e9bc
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 28 Jul 2026 10:39:40 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 28 Jul 2026 10:39:40 -0700 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 : 70dad584e8371eb8a470d882829ba428a22701d4
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 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 : fd92f74b91d079430ef4544713a90b7b6aa8faee
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 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 : 123ea94f76b8efc9f45286e2ba55ee02bff5056c
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 28 Jul 2026 10:50:23 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 28 Jul 2026 10:50:23 +0900 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 : 9f6fb1191915f1baeb32ab11392af436cf869ce4
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 28 Jul 2026 08:35:09 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 28 Jul 2026 08:35:09 +0900 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
Fix race condition when enabling logical decoding concurrently.
commit : 99e47536bbf1a165f5dc8d504f928821ebc8df6a
author : Masahiko Sawada <msawada@postgresql.org>
date : Mon, 27 Jul 2026 09:10:48 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Mon, 27 Jul 2026 09:10:48 -0700 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 : 2a9541ddfd3a5b069c505e36a91f289126871a21
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 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 : 31974f64f029a29a6d7eeeb3f870030beee2066f
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 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 : d2768065a979ffad11e2ee650b9fa9fd95168a8b
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 27 Jul 2026 09:04:31 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 27 Jul 2026 09:04:31 +0530 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 : aa50f4f02920101b84466668bd3b90c156dcda89
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 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
Add _bt_set_startikey row compare test coverage.
commit : 03ec8fc25bbea225c7260a18c702b03d3d38881d
author : Peter Geoghegan <pg@bowt.ie>
date : Sun, 26 Jul 2026 12:49:54 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sun, 26 Jul 2026 12:49:54 -0400 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 missing PGDLLIMPORT marker
commit : 603a3335f2b60b2c798da5c627b3bb288b92a7bd
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 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 : 2aa3c6d1fceecd94b1f605f0c62884cb686e67ed
author : Peter Geoghegan <pg@bowt.ie>
date : Sat, 25 Jul 2026 12:01:34 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sat, 25 Jul 2026 12:01:34 -0400 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 : 77aeca80249c9e640c811e80633a2e334a9320de
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 25 Jul 2026 19:09:19 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 25 Jul 2026 19:09:19 +0900 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 : bb6125ca3ac756a44be9ef574e89aa5cff482afb
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 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
Fix EXCEPT publication test to check subscriber
commit : 72207b17daa328d83b1609b4bc5cc4047fe4ba01
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 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 : 41be67e534ffccd055922482c17b874fb7a74f30
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 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 : 42b480d286828f94e476ab45a752321602b12c75
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 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
injection_points: Clear waiter slot on error and exit
commit : 703859d7c649fc44da94fe1f1b9c24dcd58d9372
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 23 Jul 2026 14:37:42 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 23 Jul 2026 14:37:42 +0900 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 : 57e7c52c0fe43fff36d0f4440eea13cf5668b160
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 23 Jul 2026 10:39:03 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 23 Jul 2026 10:39:03 +0530 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 : bdcea66f0f3b2f16c51d6c95bb9d0bb317fdfd99
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 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
doc: clarify how TIMESTAMP WITH TIME ZONE behaves
commit : 9fa107f07f06d8b0281f729931512ee896aa3440
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 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 : d9d235510e10fb61457744fc7798852c46260f29
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 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 : d972ead131cc11463a5ce02433cc994b5b817558
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 from commit c1fe2d1a383 M src/bin/pg_upgrade/check.c
Remove assertion added by commit 7dcea51c2a4d
commit : 7d1b39fc3d9aca1175d00b2859d896f6e81ecad4
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 21 Jul 2026 17:18:06 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 21 Jul 2026 17:18:06 +0200 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
pg_upgrade: Message wording fix
commit : 2b6e7c0a7dbf36b39ce923373e65ac9e3b6ad7d9
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 For internally consistent terminology M src/bin/pg_upgrade/controldata.c
Message style fixes
commit : 4d529d77f8f0e2bdbd6bc2119bb09eebffd23583
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 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
Test what BEFORE UPDATE triggers do to FOR PORTION OF
commit : 5454fe4a6e77661384a9766e6d760bf3ec1c9b0f
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 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 : 4cd02d552263ed8d4b148aaefd24cd9dd8af57ed
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 21 Jul 2026 09:12:52 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 21 Jul 2026 09:12:52 +0530 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/sequencesync.c
M src/test/subscription/t/036_sequences.pl
Add logical decoding status to pg_control_checkpoint().
commit : 4ca78f292de7b86495cec0a416dc047d94df96c4
author : Masahiko Sawada <msawada@postgresql.org>
date : Mon, 20 Jul 2026 17:11:21 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Mon, 20 Jul 2026 17:11:21 -0700 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
doc: Granting TRIGGER or REFERENCES on table is dangerous.
commit : a649138d8558a97880d3ba1d1f41f66320debf7f
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 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 : 2b2c2492c2b053a5d7b347abfb2e80127841b9bf
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 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
Fix LSN format in REPACK worker debug message
commit : 10389a7e15e0ed0214e19c6560edd4dc6bb07a35
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 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 : 69fe2514fdd829cc4aebcd084f6f300f60e84f57
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 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
Fix RLS checks for FOR PORTION OF leftover rows
commit : c58c83ce50cf65ee45bd60910f710a2bd251cc36
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 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 : a8c9d2be280443956cf2740017bf869ccdc562c3
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 20 Jul 2026 11:06:45 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 20 Jul 2026 11:06:45 +0530 '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 : 72457f1df803bba077b338d5ed3fb8418e69967d
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 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 : bd6ca6f852694a8a0f52db748ff8badec4223c8f
author : Peter Geoghegan <pg@bowt.ie>
date : Sun, 19 Jul 2026 22:15:36 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sun, 19 Jul 2026 22:15:36 -0400 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 : dfde93581dcfab7509b6b28863c5270eb8d94754
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 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 : 829bacaeb323e4811eb804b5e4e29f643a0c619d
author : Tatsuo Ishii <ishii@postgresql.org>
date : Sun, 19 Jul 2026 10:47:29 +0900
committer: Tatsuo Ishii <ishii@postgresql.org>
date : Sun, 19 Jul 2026 10:47:29 +0900 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
doc PG 19 relnotes: \crosstab to \crosstabview
commit : f7bc98156e1170c60a03dfbeee7871e59888de82
author : Bruce Momjian <bruce@momjian.us>
date : Sat, 18 Jul 2026 20:43:24 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sat, 18 Jul 2026 20:43:24 -0400 Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: update to current
commit : 7bcb29e742cd65d01a00c656ee99f61694c2919d
author : Bruce Momjian <bruce@momjian.us>
date : Sat, 18 Jul 2026 20:41:00 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sat, 18 Jul 2026 20:41:00 -0400 Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
Further cleanup for commit 54cd6fc83.
commit : 5951bf2ba56cd4806955fb6299529bde026de1ac
author : Etsuro Fujita <efujita@postgresql.org>
date : Sun, 19 Jul 2026 03:50:01 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Sun, 19 Jul 2026 03:50:01 +0900 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 : 8bc479627ec4a361cbcaa2b10877b5af766c6349
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 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 : 8d2beee027af41a6b66c670b6a595895f24a1bb0
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 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 : e727c6f2ef5c75a282fbef9cb8adc0c1c6c7978e
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 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 : fd27c7e64fe0d5d514ee5fa97250327ce33756fa
author : Amit Kapila <akapila@postgresql.org>
date : Sat, 18 Jul 2026 07:53:13 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Sat, 18 Jul 2026 07:53:13 +0530 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
Fix yet another portability problem in new NLS test.
commit : 5ed9cee74c6cf23729bd5cc4dee3b0ebbd4aa7aa
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 Á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 : 3180ce3d7a836e7fbcf8946a0e0be9f263353481
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 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 : 372b8d1adb76740123791e9ded4f665b175f5bf5
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 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
doc PG 19 relnote: move Oauth items
commit : 3b5a3cfb903eca6dfc87319e0ac29e3e23430e08
author : Bruce Momjian <bruce@momjian.us>
date : Fri, 17 Jul 2026 15:56:54 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Fri, 17 Jul 2026 15:56:54 -0400 Reported-by: Jacob Champion
Author: Jacob Champion
Discussion: https://postgr.es/m/CAOYmi+k5h_w5p6HsVJF5k+bNGmChMAhpGU_1gjJMxHg080XibA@mail.gmail.com
Backpatch-through: 19 M doc/src/sgml/release-19.sgml
Fix GiST index-only scan column alignment issue.
commit : 1d4c81ad6266fb2e534fe2e6de8d0050041a4ad6
author : Peter Geoghegan <pg@bowt.ie>
date : Fri, 17 Jul 2026 15:53:07 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Fri, 17 Jul 2026 15:53:07 -0400 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 : 3601be26b3fa076e1aa03e9f1e0ad0e6077ce759
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 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 : cce2bbbfd3cb8df4844013d20c3e08cef6d29084
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 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 : 6a90e70415efe1137d58072331f9101e0a00a4e6
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 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 : 5ccbcbdbb7df508d4d57cf24ced189e15bc6601e
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 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 : 5f57f58179bf48805558ac0494851e93fe0eca76
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 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 : 3aa54433b0cdce48facb610a5b720208cc760654
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 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 : 2572fc53128cdbd262bf91fb2e302e0c4459be6f
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 17 Jul 2026 09:41:07 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 17 Jul 2026 09:41:07 +0530 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 : 64542957b44cce7e29f1979bcfbf04477234ea3c
author : Peter Geoghegan <pg@bowt.ie>
date : Thu, 16 Jul 2026 18:55:35 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Thu, 16 Jul 2026 18:55:35 -0400 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
Use fake LSNs consistently in hash index AM.
commit : 048067c04c6c0c0862f0e00c4ebe158ac41bda19
author : Peter Geoghegan <pg@bowt.ie>
date : Thu, 16 Jul 2026 18:08:41 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Thu, 16 Jul 2026 18:08:41 -0400 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 : 8e93e0c72b8aa225b0a66d4afdfb69e38d8b2424
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 16 Jul 2026 12:20:45 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 16 Jul 2026 12:20:45 -0700 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 : baf0ec4652c2c42c76cf108bb95860b61c1eff16
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 16 Jul 2026 12:13:16 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 16 Jul 2026 12:13:16 -0700 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 : 2a933deaa23bff4245c327bc8e9f4676095d0f6c
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 16 Jul 2026 11:50:16 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 16 Jul 2026 11:50:16 -0700 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
Handle concurrent sequence drops during synchronization
commit : 24a2b541bd450a2db9d8f3ddefc92ace58ef9a42
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 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 : ee8f123da72d9e23e35848bfe3c2f49c02d7756c
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 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
doc: Fix link text for data checksums
commit : e3a27cad462f08716312e692b426747d840803c6
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 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
Check CREATE_REPLICATION_SLOT response shape in libpqwalreceiver
commit : 0231fa2c3a8621450e51044d335725dae2338abb
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 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 : 8a84ddd8c63289e14e1e1cc2c8a4a9c41f652e1a
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 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 : 54bf009052edadf85658a94eeece2ea355480b23
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 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 : 9171f77db2326c65fc69ab81d156622d19163b6a
author : Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 15 Jul 2026 17:32:17 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 15 Jul 2026 17:32:17 -0400 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 : b01c31eef9c3a83d0bd9f30656cedaa6722890ee
author : Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 15 Jul 2026 17:32:17 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 15 Jul 2026 17:32:17 -0400 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. Though it is late in the cycle (post-beta 2) to
be doing so, that seemed better than maintaining the backwards
compatability code in yet another branch.
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
Introduce macros for WAL block reference IDs of some heap record types
commit : 56bf5fa5d67a0cea97a8b456a3834749b3146f95
author : Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 15 Jul 2026 17:32:17 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 15 Jul 2026 17:32:17 -0400 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 : 7a103928a0986c6f9308a3bc476176fa6e1dd0c9
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 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 : 04a6d65a763312fecae866e7240d3ea895bad329
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 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 : 94e1b104f8db88837e5ef13a6692dad746e3690f
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 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 : 95c1b8ec7773817d8626d0aad6e7424b3c5ef04d
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 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 : 173ea84dfdc96390ce37a3918aa660a15c4734a9
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 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 : 928ed9b653e968ddb559a3fde7ff9a84b08f1196
author : Amit Kapila <akapila@postgresql.org>
date : Wed, 15 Jul 2026 15:47:35 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Wed, 15 Jul 2026 15:47:35 +0530 '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
doc PG 19 relnotes: swap OAUTH hook and validator items
commit : 0546889b1b9fa80f0374ddd708c39cb63ed83518
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Jul 2026 05:51:12 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Jul 2026 05:51:12 -0400 Reported-by: Andreas Karlsson
Discussion: https://postgr.es/m/f5f129c3-88fa-43dc-a23a-75155fa10be3@proxel.se
Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: "OAUTH validators to supply failure item"
commit : aa9787e325df8a864cd29dac2fcfdaaf02b6b8ed
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Jul 2026 05:36:00 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Jul 2026 05:36:00 -0400 Moved to source code section.
Reported-by: Andreas Karlsson
Discussion: https://postgr.es/m/f5f129c3-88fa-43dc-a23a-75155fa10be3@proxel.se
Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: remove duplicate word
commit : 49d250b3d6884a693eacaefb3e08799e7c25f7f0
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Jul 2026 05:13:39 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Jul 2026 05:13:39 -0400 Backpatch-through: 19 M doc/src/sgml/release-19.sgml
Rework pgstat_write_statsfile() in combination with to_serialized_data
commit : 0892319c65e7d7458ee8fb902618491aaa0e4734
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Jul 2026 10:35:19 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Jul 2026 10:35:19 +0900 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 : 31d04313c1163497f4c6f4f64fad2359cbbab149
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Jul 2026 10:03:38 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Jul 2026 10:03:38 +0900 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 : aae47813a14d1f5638469bda146d7839e39b7097
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 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 : b464e498cebe34da006575672caeabced1718927
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Jul 2026 08:05:08 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Jul 2026 08:05:08 +0900 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 : 2349b106b6661c084dc1171654146c730ecb048f
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 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
Stamp 19beta2.
commit : 7873db5369b967dd53984df34fd800003410d04f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 13 Jul 2026 16:03:24 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 13 Jul 2026 16:03:24 -0400 M configure
M configure.ac
M meson.build
Translation updates
commit : 8055e3375aa1c2237181e06be26b05b964d18ed5
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Jul 2026 12:03:36 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Jul 2026 12:03:36 +0200 Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: 2ef2c86b2592e8a199edc86779bc44cfdb258971 M src/backend/po/de.po
M src/backend/po/ja.po
M src/backend/po/ka.po
M src/bin/initdb/po/ka.po
M src/bin/pg_archivecleanup/po/de.po
M src/bin/pg_archivecleanup/po/ja.po
M src/bin/pg_archivecleanup/po/ka.po
M src/bin/pg_basebackup/po/de.po
M src/bin/pg_basebackup/po/ja.po
M src/bin/pg_basebackup/po/ka.po
M src/bin/pg_combinebackup/po/de.po
M src/bin/pg_combinebackup/po/ja.po
M src/bin/pg_combinebackup/po/ka.po
M src/bin/pg_config/po/ka.po
M src/bin/pg_controldata/po/ka.po
M src/bin/pg_ctl/po/ka.po
M src/bin/pg_dump/po/de.po
M src/bin/pg_dump/po/ja.po
M src/bin/pg_dump/po/ka.po
M src/bin/pg_resetwal/po/ka.po
M src/bin/pg_rewind/po/de.po
M src/bin/pg_rewind/po/ja.po
M src/bin/pg_rewind/po/ka.po
M src/bin/pg_test_timing/po/de.po
M src/bin/pg_test_timing/po/ja.po
M src/bin/pg_test_timing/po/ka.po
M src/bin/pg_upgrade/po/de.po
M src/bin/pg_upgrade/po/ja.po
M src/bin/pg_upgrade/po/ka.po
M src/bin/pg_verifybackup/po/ka.po
M src/bin/pg_waldump/po/ka.po
M src/bin/psql/po/de.po
M src/bin/psql/po/ja.po
M src/bin/psql/po/ka.po
M src/bin/scripts/po/de.po
M src/bin/scripts/po/ja.po
M src/bin/scripts/po/ka.po
M src/interfaces/ecpg/preproc/po/ka.po
M src/interfaces/libpq/po/de.po
M src/interfaces/libpq/po/ja.po
M src/interfaces/libpq/po/ka.po
M src/pl/plperl/po/ka.po
M src/pl/plpgsql/src/po/ka.po
M src/pl/plpython/po/de.po
M src/pl/plpython/po/ja.po
M src/pl/plpython/po/ka.po
M src/pl/tcl/po/ka.po
Shorten pg_attribute_always_inline to pg_always_inline
commit : a474c01c87661f85827736dc8cfc353fd63c6ecf
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 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
Update FSM after updating VM on-access
commit : e9eaeb04248a8b2cc977440caa1b72174c108c14
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 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 : a1b74b7279c24638c44f9d3d1af2da30cfb7068d
author : Andres Freund <andres@anarazel.de>
date : Fri, 10 Jul 2026 13:25:13 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 10 Jul 2026 13:25:13 -0400 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 : 133eba078f776268d24f82a2b3d5bf9ca31dd4c3
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 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 : c479ea58e7798b8cab8b8a4ca9e6ce3e292a3f17
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 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 : 9d1d91a14335392347e09a6cef2a45d8eafeebbd
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 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 : 2bbec7c49a6c872fdfdddf7ff9ea9dc9cebaef40
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 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 : 5b5e99047ab0df2ef3d18de81176558e49015205
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 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 : 3334b0d9f25a897b8298c849d08909bdc532874a
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 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
libpq: Make error checks in the new buffer draining code more robust
commit : d9eb70c9c692475174289d9bdc5c76734abbfa0c
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 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 : 536512f34e7a6156188f6ba5c834ab01c911c5ae
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 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
Prohibit locking clauses on GRAPH_TABLE
commit : 01c544e1afb99bc2a76803870010b7cd2907f3b5
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 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 : 0b1dbb74478051205c2befc90bac9d9f55524104
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 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
Doc: Clarify sequence synchronization commands.
commit : 19fbb47ef6854b1e3a7311ed2f4e765426e7a611
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 9 Jul 2026 08:01:38 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 9 Jul 2026 08:01:38 +0530 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
doc: Fix data checksum progress reporting documentation
commit : dff11f846c4bd044e51ca944f2f3e089be0462ac
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 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
Don't create SPLIT/MERGE partitions as internal relations
commit : 6120d01c9f5c985c5154d226181295137e57c552
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 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
Fix RETURNING OLD with BEFORE UPDATE trigger and concurrent update.
commit : 7048e50f8f93057128db7e8a0a2925248f71a266
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 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 : 56fa044d15e8b06d84889f06f5def21a62fb86a3
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 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 : 9530898940302d6f501fb54a3fbc61cbfb7768bf
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 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
Add hints for sequence synchronization permission warnings
commit : 165dc09b28619510d9ab0034fdfccfb7af5422ae
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 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 : 67490b55f38d98bd08a6fa2764dd44a2a7c5a2db
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 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 : b820c623dd5090ef69b8b8151a0b152f5d976fed
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 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 : 7883ea13ffdc6c657923031d80b2505d08f51e33
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 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 : 9120b7958b7b0f44589c635e41af9b33819615ff
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 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
doc: Clarify COPY FROM WHERE expression restrictions
commit : 64ed30fda8d77782bd69297e3892895ca9f84816
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 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_locale_libc.c: add missing casts to unsigned char.
commit : e4b24d2f56533b9d5a46a54b4f670e5129c4bac8
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 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 : 404fe01e0c5d402c257cfe809e5a15f64a2c6586
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 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 : dffd7fb0a07b9d0265b447b728ac7a9c6ff60391
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 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 : ef5d080b452cb63ce798e9a77705eead062cd73f
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 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
doc: Fix typo in rule-system view example
commit : 93338a0fd3b83bb9eeca1f80b8160510aca0272a
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 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 : eaa561fb6e278ed7ce293ed7d1e7ddaa7354180b
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 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
pg_unicode_fast: fix final sigma logic.
commit : 28d498e28031f026b8416a4c8439ddda62dfb00f
author : Jeff Davis <jdavis@postgresql.org>
date : Tue, 7 Jul 2026 14:29:21 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Tue, 7 Jul 2026 14:29:21 -0700 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
unicode_case.c: defend against truncated UTF8.
commit : 05da336dd7d32ed4a70efc5f21c355f8ace482e8
author : Jeff Davis <jdavis@postgresql.org>
date : Tue, 7 Jul 2026 13:35:07 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Tue, 7 Jul 2026 13:35:07 -0700 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 : a53d6d8aea8fe703d86dd2bdc0a3d86800eca7c3
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 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 pg_dump ACL minimization for PROPERTY GRAPH.
commit : ccca2cd81b2dab2be7d9d451a84d971a8489ca70
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 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
libpq: Drain all pending bytes from SSL/GSS during pqReadData()
commit : 7f8745543e79ae48cb8d80e97c17105d76511fd9
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 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 : eeb2940ae83cb6a5e48e90465bea0cede341ea59
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 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 : f74a45a5416fb18c391b3a1651e29ada78106c43
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Tue, 7 Jul 2026 17:39:28 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Tue, 7 Jul 2026 17:39:28 +0200 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 : 4746a35e45ab360fa3408da0367c4165a5cb8837
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 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
Fix COUNT's logic for window run condition support
commit : fcd58c6d9642487eb97e9cf7699daddb3951bc9a
author : David Rowley <drowley@postgresql.org>
date : Tue, 7 Jul 2026 23:58:29 +1200
committer: David Rowley <drowley@postgresql.org>
date : Tue, 7 Jul 2026 23:58:29 +1200 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
postgres_fdw: Report ANALYZE to pgstats after importing statistics.
commit : 0021794f4c5778348418fc2f5658f3b3cb2f2e86
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 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 : 7f0998f87b08e325ab65b1355464a1430042b9aa
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 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 : d30bfcbddca3b08f66d1207265d9ab7d8a7b95c1
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 7 Jul 2026 08:13:59 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 7 Jul 2026 08:13:59 +0900 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 : da8889ccd7ea0782a22a2300abc8fb801ecfa160
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 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 : 54d5947efe2d03a1419d71630c3ae95b2ec14906
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 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 : 99775b3885b600277dea577db69e7469e59bcdbe
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 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 : 017499a50f371c5a801f4e3b9b6a6ec2f59da859
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 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 : 67cf73ddbe3334ee1fecc29ffb6d4cd2e10ab9ac
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 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 : 2ddc4566214d8eff3c4013a9e241b5e9b47abbaf
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 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 apparent support for SECURITY LABEL ON PROPERTY GRAPH
commit : 33bfad0f3cad222e4a2593cc774234e3117f1bc0
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 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 : c8d49ffb007b2f5aff61cff2ff68786f2d53ac5d
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 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 : 98d5d7ee6419dc4b3894d7b4610a2e128f675052
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 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
amcheck: Fix memory leak with gin_index_check()
commit : 80cfd8aef645295aceafd2aa98912c64edd06394
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Jul 2026 09:32:28 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Jul 2026 09:32:28 +0900 "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 : 56e892a49439ad361d8610bd859f4c7a29ec336e
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 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
Fix properties orphaned by dropping a label
commit : 45d4c917ff4f4fe206ad18d0279a47c9f2a08123
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 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 : 80c7f5467d9e14595688ceceba62b8b784595d1e
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 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 : d86873683001a57b32e894a5ea06fd8f3cee254f
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 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
REPACK CONCURRENTLY: Initialize the range table more honestly
commit : 5e450df50dc8e688abbad229f174f006cc550388
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 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 : fc6649abefd44bd0edc4318e3e82caf34b0e885f
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 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
Use the proper comparator in gbt_bit_ssup_cmp.
commit : 11cb9c431127ad0f331b1bf884f5c646f70b3c4f
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 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 : cc9aa7f3a9839878d6bb376bec6ea2e005c64d76
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 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 : 8021cdceb0186d3e0fb2c56ffef9ece46840a7e3
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 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 : 36aae3d0297d35602dec40ca3edbaf82320a4cc7
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 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 : 0766bc57e9f94e5321e6ea4cb49db430224b2e60
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 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 : fb284f2f9bdb9dd5e866132f7d0b8eeaa972e521
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 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 : ac0ad6a7c9d1f7c0d82696260fdcb2d09a8962c1
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 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
psql: Fix \df tab completion for procedures
commit : 558e0de6d3bba428a2aa9f233e0483d52672097c
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 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 : ea203d371de0a411cc4a27f3d707c0b6dce1fb4f
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 M contrib/pg_plan_advice/pgpa_scan.c
Remove replication slot advice from MultiXact wraparound hints
commit : 4ebbf001882f46fae10d7a564ceded4d9bbd92b5
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 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
pg_plan_advice: Don't generate FOREIGN_JOIN advice for a single relation.
commit : 89f5f860cc584cf4c531dbc38b614e4db5c61e24
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 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
test_custom_stats: Fail if loading module outside shared_preload_libraries
commit : 7838efe9a2d165cc3cf3a4538ecc5f10d49b1a49
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 2 Jul 2026 15:52:50 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 2 Jul 2026 15:52:50 +0900 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.
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 jsonpath .decimal() to honor silent mode
commit : 5bbc9b3000a50b4278ddd449ecea0fd7c3d91686
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 2 Jul 2026 12:44:31 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 2 Jul 2026 12:44:31 +0900 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
btree_gist: fix NaN handling in float4/float8 opclasses.
commit : a47005f0b11df3e456c755c73b6f41fd26b27cad
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 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 : ba7a65c5c5aaa71df23def8280fa70db7f11fd3b
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 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
Clear base backup progress on backup failure
commit : b70000837888917690782197c098942ddb529753
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 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 : e57a865dc7003f75d3a2d080603c95dd469b89a5
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 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
Split dry-run messages into primary and detail
commit : 36b1a1e826eaa144d5661f1f047cc43d8921cbae
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 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 : d4e2280b7e4872b603592ae521320b9d1c4e6b24
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Jul 2026 09:40:16 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Jul 2026 09:40:16 +0200 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 : 182f6944d3d0eeccf60e5885757f1677d4b988cc
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 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
Avoid useless calls in pg_get_multixact_stats()
commit : 9a2c07cbde9796049e4b37e3dde0b6f5253cb97b
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 1 Jul 2026 12:17:24 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 1 Jul 2026 12:17:24 +0900 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 : b26e0f61451dfa0756d398129c79bbd46365b51e
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 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
Remove radius from initdb authentication methods.
commit : 1f34f12f0c312ae7f31d76fa8dc2d934c43f9b6c
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 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 : 0c15b715c6517af7b1046b45f868425930eaee6f
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 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 : 78860fab26f1440ec4a8e31d039a88c66329196f
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 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
Fixes for SPI "const Datum *" use
commit : 2fb6015f78749c3a235354acded31562414775be
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 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
Change stat_lock.wait_time to double precision
commit : ff6f6e0470ecb362a389bb20aac46a843e496c2f
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 30 Jun 2026 12:47:57 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 30 Jun 2026 12:47:57 +0900 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 : 7e5a19a16c55290471c6503a2b3e50d1e14d393c
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 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 : 74e93d0f0000f197f27d311ab5fd70b3adfbac26
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 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 : b07664a179bd038aec89813b336306678a84bb1c
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 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 : 22af34b983620a840e38c5f4ddae34b53647ba5c
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 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 : ac536a4061bcf22db46ba23d077cd36e65e14e1a
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 30 Jun 2026 08:30:52 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 30 Jun 2026 08:30:52 +0900 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
doc PG 19 relnotes: fix autovacuum_vacuum_score_weight prefix
commit : 1a7fa06dbcd186f4e13332157f3ffb6da955fe1a
author : Bruce Momjian <bruce@momjian.us>
date : Mon, 29 Jun 2026 17:37:58 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Mon, 29 Jun 2026 17:37:58 -0400 Was missing "autovacuum_" prefix.
Reported-by: Chao Li
Author: Chao Li
Discussion: https://postgr.es/m/6D50BAF9-0586-420C-AFAC-CCDB61EF694A@gmail.com
Backpatch-through: 19 only M doc/src/sgml/release-19.sgml
Adapt REL_19_STABLE to its new status as a stable branch
commit : 3cd530e84b05080492dcf0f4c596ef9d58ced012
author : Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 16:39:23 -0400
committer: Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 16:39:23 -0400 Per the checklist in RELEASE_CHANGES for the creation of a new stable
branch, this commit does the following things:
- Update URLs of top-level README and Makefile to point to the new
stable version. M Makefile
M README.md
Add previous 2 commits to .git-blame-ignore-revs.
commit : 9cfd19bc10ac07139ca6c6d051d4492764441edb
author : Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 15:33:52 -0400
committer: Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 15:33:52 -0400 M .git-blame-ignore-revs
Run pgperltidy
commit : 99e44c3181c779ae0f3539ba7f408661983fbf8e
author : Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 15:27:44 -0400
committer: Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 15:27:44 -0400 This is required before the creation of a new branch. pgindent is
clean, as well as is reformat-dat-files.
perltidy version is v20230309, as documented in pgindent's README. M contrib/dblink/t/001_auth_scram.pl
M contrib/postgres_fdw/t/001_auth_scram.pl
M src/include/catalog/pg_proc.dat
M src/test/modules/test_misc/t/012_ddlutils.pl
M src/test/recovery/t/051_effective_wal_level.pl
M src/test/ssl/t/001_ssltests.pl
M src/test/subscription/t/100_bugs.pl
Sync typedefs.list with the buildfarm.
commit : 3f815dd11374b54deb29228dc0040179864af828
author : Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 15:16:25 -0400
committer: Joe Conway <mail@joeconway.com>
date : Mon, 29 Jun 2026 15:16:25 -0400 Replace typedefs.list with the authoritative list from our buildfarm, and
run pgindent using that. M src/tools/pgindent/typedefs.list
Fix typo
commit : 52e118fe2f7e3381bdaa479816a7f72eda2ae517
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 29 Jun 2026 16:15:13 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 29 Jun 2026 16:15:13 +0200 from commit c1fe2d1a383 M src/bin/pg_upgrade/check.c
Forbid FOR PORTION OF with WHERE CURRENT OF
commit : bc3ae886a759f2d3fd5f1b92f5fbeeccfee9e7a9
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 29 Jun 2026 15:13:45 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 29 Jun 2026 15:13:45 +0200 It is not clear how the implicit condition of FOR PORTION OF should
interact with the use of a cursor. Normally, we forbid combining
WHERE CURRENT OF with other WHERE conditions. The SQL standard only
includes FOR PORTION OF with <update statement: searched> and <delete
statement: searched>, not <update statement: positioned> or <delete
statement: positioned>, so it is easy for us to exclude the
functionality, at least for now.
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/flat/CA%2BrenyUEKPexUYsH4qeU8_o1jqKsUkEWca1keS6n21shgG1g%2BA%40mail.gmail.com M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/update.sgml
M src/backend/parser/analyze.c
M src/test/regress/expected/for_portion_of.out
M src/test/regress/sql/for_portion_of.sql
Fix handling of copy_file_range() return value
commit : 994f770a0fd55dfdeb96d1d60d35545ba2d51480
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 29 Jun 2026 11:49:11 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 29 Jun 2026 11:49:11 +0200 Treat copy_file_range() return value of zero as an error: it indicates
that no bytes could be copied (perhaps the source file is shorter than
expected), and the existing retry loop would otherwise spin forever
since nwritten would never reach BLCKSZ.
The other uses of copy_file_range() in the tree don't have this
problem.
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Yingying Chen <cyy9255@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/3208cf7a-c7f3-41eb-92f6-33cbeff4df40%40eisentraut.org M src/bin/pg_combinebackup/reconstruct.c
doc: Reorder table for Object DDL Functions
commit : b7e4e3e7fa73458ecca5cd10f341743fd12a4faa
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 29 Jun 2026 13:15:07 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 29 Jun 2026 13:15:07 +0900 While on it, let's add links pointing to the set of SQL commands
generated by these functions. The descriptions of the functions are
exactly the same, just moved around.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Ian Lawrence Barwick <barwick@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pun9Z8qZFJTa9fLgdhM=Cip9d-cnx2YXDW6eFrSwbQj1g@mail.gmail.com M doc/src/sgml/func/func-info.sgml
plpython: Fix NULL pointer dereferences for broken sequence and mapping objects
commit : 8612f0b7ce09212b0b80af925b0966bdbd46a60f
author : Richard Guo <rguo@postgresql.org>
date : Mon, 29 Jun 2026 11:38:39 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 29 Jun 2026 11:38:39 +0900 PL/Python and its hstore and jsonb transforms build SQL values from
Python containers by calling Python C API functions that can return
NULL, and in several places the result was used without first checking
it.
On the sequence side, PySequence_GetItem() is used when converting a
returned sequence into a SQL array or composite value, when reading
the argument list passed to plpy.execute() or plpy.cursor(), and when
reading the list of type names given to plpy.prepare(). On the
mapping side, the hstore and jsonb transforms call PyMapping_Size()
and PyMapping_Items() and then index the result with PyList_GetItem()
and PyTuple_GetItem().
All of these return NULL (or -1), with a Python exception set, for a
broken object: for example one whose __getitem__() or items() raises,
or which reports a length that disagrees with what it actually yields.
The unchecked result was then dereferenced, crashing the backend.
Fix this by checking the result of each call and reporting a regular
error if it failed, so that the underlying Python exception is
surfaced instead of taking down the session.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAMbWs49BKM9wP6m8bCXEpHwQKp7usvOGV6Jf=J7FYr_BCpxLqg@mail.gmail.com
Backpatch-through: 14 M contrib/hstore_plpython/expected/hstore_plpython.out
M contrib/hstore_plpython/hstore_plpython.c
M contrib/hstore_plpython/sql/hstore_plpython.sql
M contrib/jsonb_plpython/expected/jsonb_plpython.out
M contrib/jsonb_plpython/jsonb_plpython.c
M contrib/jsonb_plpython/sql/jsonb_plpython.sql
M src/pl/plpython/expected/plpython_composite.out
M src/pl/plpython/expected/plpython_spi.out
M src/pl/plpython/expected/plpython_types.out
M src/pl/plpython/plpy_cursorobject.c
M src/pl/plpython/plpy_spi.c
M src/pl/plpython/plpy_typeio.c
M src/pl/plpython/sql/plpython_composite.sql
M src/pl/plpython/sql/plpython_spi.sql
M src/pl/plpython/sql/plpython_types.sql
Hardwire RI fast-path end-of-xact cleanup into xact.c
commit : 6f4bac854fb784f83b86f05c7e9921e038135442
author : Amit Langote <amitlan@postgresql.org>
date : Mon, 29 Jun 2026 10:24:28 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Mon, 29 Jun 2026 10:24:28 +0900 Commit b7b27eb41a5, which added foreign-key fast-path batching to
ri_triggers.c, registered ri_FastPathXactCallback() via
RegisterXactCallback() to clear the fast-path batching state at end of
transaction. RegisterXactCallback() is documented as intended for
dynamically loaded modules; built-in code is supposed to hardwire its
end-of-xact hooks into xact.c, mainly so callback ordering can be
controlled where it matters (see the header comment on
RegisterXactCallback()).
Convert the callback into a plain AtEOXact_RI() function and call it
directly from CommitTransaction(), PrepareTransaction() and
AbortTransaction(), alongside the other AtEOXact_* cleanup steps, and
drop the RegisterXactCallback() registration.
Like the other AtEOXact_* routines, AtEOXact_RI() takes an isCommit
argument and treats the two paths differently. On commit or prepare
the fast-path cache must already have been flushed and torn down by
the after-trigger batch callback, so a surviving cache indicates a
trigger batch was never flushed -- which would have silently skipped
FK checks -- and draws an Assert plus a WARNING. On abort a surviving
cache is expected (a flush may have errored out partway) and is simply
reset.
There is no ordering dependency here: AtEOXact_RI() only resets
backend-local static state (the cache pointer, the
callback-registered flag, and the in-flush guard). It touches no
relations, locks, buffers or catalogs, so its position relative to
ResourceOwnerRelease() and the surrounding AtEOXact_* calls does not
matter. On a normal commit the fast-path cache has already been
flushed and torn down by ri_FastPathEndBatch() (an
AfterTriggerBatchCallback fired from AfterTriggerFireDeferred(), well
before any end-of-xact callback), so the reset is a no-op; its real
job is the abort path, where teardown may not have run and the static
pointers would otherwise dangle into the next transaction. The cache
memory itself lives in TopTransactionContext and is freed by the
end-of-transaction memory-context reset on both paths.
The companion RegisterSubXactCallback() use from b7b27eb41a5 was
already removed by commit 4113873a, which confined fast-path batching
to the top transaction level, so only the RegisterXactCallback() use
remained.
Reported-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/ajypPeEWceXRGAEW@bdtpg M src/backend/access/transam/xact.c
M src/backend/utils/adt/ri_triggers.c
M src/include/commands/trigger.h
doc: Improve consistency in varlistentry attributes
commit : e42d4a1f3dc59420be796883404020cb41ddd05e
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Sun, 28 Jun 2026 23:43:19 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Sun, 28 Jun 2026 23:43:19 +0200 Use underscores consistent across the varlistentry attributes in
config.sgml. Inconsistencies found using Claude, verified by the
reporter.
Reported-by: Bill Kim <billkimjh@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/CAMQXxchB0ZfMHyk+Ji-=s3hkqh0_XyuKiaNLRgvatvndSt3KNw@mail.gmail.com M doc/src/sgml/config.sgml
Avoid collation lookup failure when considering a "char" column.
commit : b574fec00f275e50ffe2c9780ec1f6398796c905
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 28 Jun 2026 12:31:29 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 28 Jun 2026 12:31:29 -0400 If a "char" column has a statistics histogram, scalarineqsel()
would fail with "cache lookup failed for collation 0". Avoid
the failing lookup by acting as though the collation is "C".
Prior to commit 06421b084, this code didn't fail because
lc_collate_is_c() intentionally didn't spit up on InvalidOid.
It did act differently though: it would take the non-C-collation
code path and hence apply strxfrm using libc's prevailing locale.
But that seems like the wrong thing for a non-collatable comparison,
so let's not resurrect that aspect.
Author: Feng Wu <wufengwufengwufeng@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CACK3muq6s-O1Wc3w4dRL1Fe8YQ-Fz1zJbezeQwhuLgNxGNEFiA@mail.gmail.com
Backpatch-through: 18 M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/planner_est.out
M src/test/regress/sql/planner_est.sql
Use named boolean parameters for pg_get_*_ddl option arguments
commit : d6ed87d19890b1cfa93d1f6e8957fa525834c0e2
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 26 Jun 2026 08:00:39 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 26 Jun 2026 08:00:39 -0400 Replace the VARIADIC text[] alternating key/value option interface with
typed named boolean parameters for pg_get_role_ddl(), pg_get_tablespace_ddl(),
and pg_get_database_ddl(), as added by commit 4881981f920 and friends.
The new signatures are:
pg_get_role_ddl(role regrole,
pretty boolean DEFAULT false,
memberships boolean DEFAULT true)
pg_get_tablespace_ddl(tablespace oid/name,
pretty boolean DEFAULT false,
owner boolean DEFAULT true)
pg_get_database_ddl(db regdatabase,
pretty boolean DEFAULT false,
owner boolean DEFAULT true,
tablespace boolean DEFAULT true)
This provides type safety at the SQL level, allows named-argument calling
syntax (pretty => true), removes the runtime string-parsing machinery
(DdlOption, parse_ddl_options) in favour of direct PG_GETARG_BOOL() calls,
and allows the functions to be marked STRICT.
While we're here, I added an extra TAP test for pg_get_database(owner =>
false, ...)
Catalog version bumped.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://postgr.es/m/DHM6C7SLS4BN.1WW9Z4PRPN0VJ@jeltef.nl
(and on Discord) M doc/src/sgml/func/func-info.sgml
M src/backend/utils/adt/ddlutils.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/modules/test_misc/t/012_ddlutils.pl
pgindent fix for commit effb923d9de
commit : 02f699c1416380c0411fbc0f53061f86b2f52ed3
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 19:57:41 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 19:57:41 -0400 M src/backend/commands/copyto.c
doc: Clarify ALTER CONSTRAINT enforceability behavior
commit : f03ecd26396423cc38898b2479586c7c89ac9a1c
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 17:43:02 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 17:43:02 -0400 The ALTER TABLE documentation said that FOREIGN KEY and CHECK
constraints may be altered, but did not distinguish between
deferrability and enforceability attributes.
Clarify that deferrability attributes can currently be altered only for
FOREIGN KEY constraints, while enforceability can be altered for both
FOREIGN KEY and CHECK constraints. Also document that setting a
constraint to ENFORCED verifies existing rows and resumes checking new
or updated rows.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/E74C57FA-1DD0-4C8E-8FB1-538034752592@gmail.com
Discussion: https://postgr.es/m/711B1ED3-1781-4B6C-A573-B58AF20770E5@gmail.com M doc/src/sgml/ref/alter_table.sgml
doc: Clarify inherited constraint behavior
commit : d16be8605f5f699020fe4e6eaef008a41407a9bb
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 17:43:02 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 17:43:02 -0400 Update the table inheritance documentation to mention not-null constraints
alongside check constraints where inherited constraints are discussed.
Also clarify that some properties of inherited constraints can now be altered
directly on child tables, while the resulting constraint must remain compatible
with its inherited parent constraints. For multiple inheritance, say explicitly
that when a column or constraint is inherited from more than one parent, the
stricter definition applies.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/E74C57FA-1DD0-4C8E-8FB1-538034752592@gmail.com M doc/src/sgml/ddl.sgml
Prevent inherited CHECK constraints from being weakened
commit : 0cd17fdd3c000f6e64e79da0fea5e65dc9f562df
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 17:42:51 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 17:42:51 -0400 Disallow marking an inherited CHECK constraint as NOT ENFORCED when an
equivalent parent constraint remains ENFORCED. This prevents ALTER
CONSTRAINT from producing a child constraint that is weaker than one of
its inherited parent definitions.
When recursively altering a CHECK constraint to NOT ENFORCED, collect the
corresponding constraints in the affected inheritance subtree and ignore
those parent constraints while checking descendants. If a descendant also
inherits an equivalent ENFORCED constraint from a parent outside the
current ALTER, keep the descendant ENFORCED by merging to the stricter
state.
This was missed in commit 342051d73b3, which introduced the ability to
alter CHECK constraint enforceability.
Add regression coverage for direct child ALTER, ONLY ALTER, mixed-parent
inheritance, and a common-ancestor diamond where all equivalent inherited
constraints can be changed together.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/E74C57FA-1DD0-4C8E-8FB1-538034752592@gmail.com 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
COPY TO FORMAT JSON: respect column list order
commit : effb923d9dec8fd4a5102fee80e52d65d86747c8
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 16:48:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 27 Jun 2026 16:48:35 -0400 When COPY TO with FORMAT json is given an explicit column list that
names all columns in a different order, the JSON output incorrectly
used the table's physical column order instead of the requested order.
This happened because BeginCopyTo() only built a restricted TupleDesc
when list_length(attnumlist) < tupDesc->natts. When all columns are
listed (just reordered), this condition was false and no projected
TupleDesc was built, causing CopyToJsonOneRow() to emit columns in
physical order.
Fix by also building the projected TupleDesc when an explicit column
list was provided (attnamelist != NIL), even if it names all columns.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CA+fm-ROd4cNKM524n6EdgtZ9xOzOHJDNv8J_9Mvr2+2t1qWSDw@mail.gmail.com M src/backend/commands/copyto.c
M src/test/regress/expected/copy.out
M src/test/regress/sql/copy.sql
Reject child partition FDWs in FOR PORTION OF
commit : a40fdf658862b3221a35268f8c74abfd46b9e93c
author : Peter Eisentraut <peter@eisentraut.org>
date : Sat, 27 Jun 2026 19:34:40 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sat, 27 Jun 2026 19:34:40 +0200 We should defer validating FDW usage until after analysis. We have to
guard against not just the topmost table, but also individual child
partitions. Added the check to CheckValidResultRel, because it is
called after looking up child partitions (accounting for pruning), but
before the FDW can run a DirectModify update, which would bypass
per-tuple executor work.
Author: jian he <jian.universality@gmail.com>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/flat/CA%2BrenyUte0_UJsJiDJQi82oaBsMJn%3Dcct0Wn%3DvOqXtuDn%3DYYJA%40mail.gmail.com M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
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/parser/analyze.c
M src/include/executor/executor.h
Move FOR PORTION OF volatile check into planner
commit : a272a58b94249879c3f7e170a5ebfaeec940d411
author : Peter Eisentraut <peter@eisentraut.org>
date : Sat, 27 Jun 2026 09:07:07 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sat, 27 Jun 2026 09:07:07 +0200 This needs to be wary of the function volatility changing after we
check it. We cannot enforce this when checking at parse time, so move
it later, into the planner.
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CA%2BrenyUte0_UJsJiDJQi82oaBsMJn%3Dcct0Wn%3DvOqXtuDn%3DYYJA%40mail.gmail.com M src/backend/optimizer/plan/planner.c
M src/backend/parser/analyze.c
Switch maximum of GUC huge_page_size to MAX_KILOBYTES
commit : dbaa4dc3c8dd77a0e1c977024d4ae150e00456b3
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 27 Jun 2026 11:45:56 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 27 Jun 2026 11:45:56 +0900 As documented in guc.h, MAX_KILOBYTES is used to cap GUC parameters that
are measured in kilobytes of memory. This way, size_t values can fit in
builds where sizeof(size_t) is 4 bytes.
Unfortunately, huge_page_size has missed this aspect, causing
calculation failures when setting this GUC to a value higher than
MAX_KILOBYTES, up to INT_MAX.
Oversight in d2bddc2500fb. No backpatch is done, based on the lack of
complaints.
Reported-by: Daria Shanina <vilensipkdm@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20260626.132415.904994526137946499.horikyota.ntt@gmail.com M src/backend/utils/misc/guc_parameters.dat
Make crosstabview honor boolean/null display settings
commit : 4df5fe3833a87f6629eb888ca5a385bcb0b179d9
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 26 Jun 2026 20:03:42 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 26 Jun 2026 20:03:42 +0200 psql's \pset display_true/false settings, added by commit 645cb44c5490,
affect normal query output, but not \crosstabview. As a result, boolean
values used anywhere in crosstab output were always shown as "t" or "f",
which is inconsistent. Change \crosstabview so that the configured
values are displayed instead.
While at it, make \crosstabview print the \pset null string, if any, in
cells for which the query produces a NULL value. Cells for which the
query produces no value continue to have the empty string. This is an
oversight in the aboriginal \crosstabview commit, c09b18f21c52.
Add a regression test covering all of this.
Author: Chao Li <lic@highgo.com>
Reported-by: Chao Li <lic@highgo.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Backpatch: none needed
Discussion: https://postgr.es/m/B5E6F0A5-4B48-46D0-B5EB-CF8F8CC7D07D@gmail.com M src/bin/psql/crosstabview.c
M src/test/regress/expected/psql_crosstab.out
M src/test/regress/sql/psql_crosstab.sql
Fix out-of-bounds access in autoprewarm worker
commit : dac36601fd774a00b3b7390a656a689e2881bcf4
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Fri, 26 Jun 2026 19:34:14 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Fri, 26 Jun 2026 19:34:14 +0200 The read stream callback apw_read_stream_next_block() advances p->pos
through the block_info array. When processing the last block, it
increments p->pos to prewarm_stop_idx before returning. The callback
itself is safe because it checks bounds before accessing the array.
However, the caller assigned blk from block_info[i] at the end of the
loop body, before the loop condition was re-evaluated. When i equaled
prewarm_stop_idx, this accessed memory beyond the allocated DSM segment,
causing a segfault.
Restructure the loop to check bounds at the top and assign blk at the
beginning of the loop body, where it is always safe. This avoids the
need for an explicit bounds check at the end.
Backpatch to 18, where the bug was introduced by commit 6acab8bdbcda.
Author: Matheus Alcantara <mths.dev@pm.me>
Reported-by: Glauber Batista <glauberrbatista@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Backpatch-through: 18
Discussion: https://www.postgresql.org/message-id/CAO%2B_mTQgQyTYwDh%3DU8iTnsDmOGyWsZJjUV31SmEYwmw6_xY6Bw%40mail.gmail.com M contrib/pg_prewarm/autoprewarm.c
Improve docs for EXPLAIN (IO)
commit : ed9ec3abb601bbe6a22363ca5ac80959de8c14ef
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Fri, 26 Jun 2026 17:57:26 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Fri, 26 Jun 2026 17:57:26 +0200 Commit 681daed931 introduced a new EXPLAIN option "IO", but the docs
did not explain what information was added to the output. Expand the
description a little bit, similarly to the other EXPLAIN options.
While at it, fix a typo in the first sentence.
Author: Tomas Vondra <tomas@vondra.me> M doc/src/sgml/ref/explain.sgml
Take into account default_tablespace during MERGE/SPLIT PARTITION(S)
commit : cdae794af31b3e9cfc323fc654292d86fa746f77
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Fri, 26 Jun 2026 15:25:13 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Fri, 26 Jun 2026 15:25:13 +0300 createPartitionTable() passed the partitioned parent's reltablespace straight
to heap_create_with_catalog(), bypassing the default_tablespace GUC fallback
that DefineRelation() applies for CREATE TABLE ... PARTITION OF. When the
parent had no explicit tablespace (reltablespace = 0), the new partition
unconditionally landed in the database default, even if default_tablespace
was set to something else; merging or splitting a set of partitions that all
lived in a non-default tablespace produced a new partition in the database
default.
Mirror DefineRelation()'s logic: take parent's reltablespace if set,
otherwise check GetDefaultTablespace() (which reads default_tablespace
and normalises pg_default / MyDatabaseTableSpace to InvalidOid). Also
add the CREATE ACL check on the resolved tablespace and the pg_global
rejection, matching DefineRelation()'s behavior.
Update the documentation for MERGE/SPLIT PARTITION to spell out the
tablespace-selection rule explicitly.
Reported-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Discussion: https://postgr.es/m/ajQTklv8QArzTp3h%40pryzbyj2023 M doc/src/sgml/ref/alter_table.sgml
M src/backend/commands/tablecmds.c
M src/test/regress/expected/partition_merge.out
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_merge.sql
M src/test/regress/sql/partition_split.sql
doc: Improve description of pg_get_multixact_stats()
commit : 30937c60cd9d9069a0377214d9675a7128a2e5a1
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 26 Jun 2026 10:47:32 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 26 Jun 2026 10:47:32 +0900 This addresses two gaps in the documentation:
- The function uses an xid, and was not mentioned as an exception in a
section of the docs related to xid8.
- The function returns NULL if a role does not have the privileges of
pg_read_all_stats. The execution is not denied.
Author: Chao Li <li.evan.chao@gmail.com>
Author: Yingying Chen <cyy9255@gmail.com>
Discussion: https://postgr.es/m/CAGGTb65Qmtor2nJP-ATgfWpMpD2qhKrdyO7fmRbbS++nQ=vtMw@mail.gmail.com M doc/src/sgml/func/func-info.sgml
Mark uuid-to-bytea cast as leakproof.
commit : 6468f7a853c3c75066410cfb54ecdb3050ec7132
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 25 Jun 2026 14:25:57 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 25 Jun 2026 14:25:57 -0700 The uuid-to-bytea cast just serializes a valid uuid datum into its
fixed 16-byte representation. It does not have an input-dependent
error path so mark its pg_proc entry as leakproof.
Oversight in commit ba21f5bf8a.
Bump catalog version.
Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/1FAAF426-9205-4F53-8D3B-F2003D96EC37@gmail.com M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/opr_sanity.out
Fix null-pointer crash in ECPG compiler.
commit : 7f5e0b22e5eabf7b794b5059efa9454ba3616afe
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 25 Jun 2026 16:58:29 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 25 Jun 2026 16:58:29 -0400 When compiling a DECLARE section containing a union nested
inside a struct, ecpg passes a null value for struct_sizeof to
ECPGmake_struct_type. I (tgl) didn't foresee that case in
commit 0e6060790, and wrote an unprotected mm_strdup() call.
Reported-by: iMSA (via Jehan-Guillaume de Rorthais <jgdr@dalibo.com>)
Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20260625114849.34b2148e@karst
Backpatch-through: 18 M src/interfaces/ecpg/preproc/type.c
Message and comment wording fixes
commit : cae90d747969612b6e3778416246840790421527
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 25 Jun 2026 10:51:22 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 25 Jun 2026 10:51:22 +0200 Some parts of pg_upgrade referred to "on the old cluster" etc. Change
that to "in the old cluster", matching existing style. M doc/src/sgml/logical-replication.sgml
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/t/003_logical_slots.pl
M src/bin/pg_upgrade/t/004_subscription.pl
M src/bin/pg_upgrade/t/006_transfer_modes.pl
doc: Some spell checking
commit : e7c1dcc7a76c378b6bbf6271e56bb17e152cf362
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 25 Jun 2026 08:36:00 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 25 Jun 2026 08:36:00 +0200 M doc/src/sgml/ddl.sgml
M doc/src/sgml/release-19.sgml
Fix options listing of pg_test_timing --cutoff
commit : 3277e69b8eb08c0f16f276aeb8f8e1c9d058c666
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 25 Jun 2026 07:39:59 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 25 Jun 2026 07:39:59 +0200 The new pg_test_timing --cutoff option (commit 0b096e379e6) appeared
out of order in the documentation and the code. Fix that. M doc/src/sgml/ref/pgtesttiming.sgml
M src/bin/pg_test_timing/pg_test_timing.c
pg_stat_io: Don't flag extends by autovacuum launcher
commit : 4abf411e2328f57fd2547b5c2187a2159e97a606
author : Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 24 Jun 2026 14:51:31 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 24 Jun 2026 14:51:31 -0400 pg_stat_io asserts on unexpected combinations of backend type and IOOp.
These combinations were meant to help detect bugs given our current
understanding of the system -- not serve as a set of rules for what is
allowed. The autovacuum launcher scans catalog tables and may on-access
prune them. This previously wouldn't have led to any extends of the
relation, but now that on-access pruning may pin a page of the
visibility map (4f7ecca84ddacbce27), scanning tables may lead to
extending the visibility map. This would cause the launcher to trip an
assert. Since there is no reason to forbid the launcher from doing
extends, remove it from the list of backend type pgstat_tracks_io_op
flags for doing IOOP_EXTEND.
Read-only catalog scans still don't let pruning set the VM; doing so
needs table AM API changes and is left for the future.
Reported-by: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/CAON2xHNOyaN9MCZohhD_NL6as3QVhGA0SOn2Hyi9w6+Y-_1bFA@mail.gmail.com M src/backend/utils/activity/pgstat_io.c
psql: Add tab completion for subscription wal_receiver_timeout
commit : 56b2792cf84fc78f9109b0ae122174e70379ad07
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 24 Jun 2026 22:57:50 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 24 Jun 2026 22:57:50 +0900 Commit fb80f388f added wal_receiver_timeout as a CREATE/ALTER
SUBSCRIPTION option, but psql tab completion did not include it in the
subscription option lists.
Add wal_receiver_timeout to completion for CREATE SUBSCRIPTION ... WITH
and ALTER SUBSCRIPTION ... SET.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/BBC5628A-63C0-4436-B8F3-90AF59BBEB73@gmail.com M src/bin/psql/tab-complete.in.c
Remove extraneous newlines from guc_parameters.dat
commit : a7f59b252a8ed7a8a78cfd1dcd6293759c8ef09a
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 24 Jun 2026 14:58:54 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 24 Jun 2026 14:58:54 +0200 In commit fce7c73fb, two unnecessary newlines were kept: before
archive_command and seq_page_cost. Remove them here just to be
tidier.
Author: Anton Voloshin <a.voloshin@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/270ae9e7-85c6-487d-b02b-a994af56710b%40postgrespro.ru M src/backend/utils/misc/guc_parameters.dat
Distinguish datacheckums worker invocations more reliably
commit : a4f02cab4b97027b397d073f6174de8581befbfd
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:33 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:33 +0300 In some corner cases, a new datachecksums worker could be launched
while an old one was still running. If you're really unlucky, the old
worker could set the worker_result in shared memory and mislead the
launcher to think that a newer worker invocation completed
successfully, even though it failed for some reason. That's highly
unlikely to happen in practice as it requires several race conditions
with workers and launchers starting, failing and succeeding and at the
right moments. Nevertheless, better to tighten it up.
To distinguish different worker invocations, assign a unique
'worker_invocation' number every time a new worker is launched. In
the worker, check that the invocation number matches before setting
the worker result. This ensures that the result always belongs to the
latest invocation.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi M src/backend/postmaster/datachecksum_state.c
Minor cleanup around checking datachecksum worker result
commit : c48e7b2c8bd09c3a81658ac2388be28b80b87142
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:30 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:30 +0300 Rename the 'success' field in DataChecksumState to 'worker_result'.
That's more appropriate when it's not a simple boolean.
Don't access the field after releasing the lock in ProcessDatabase().
No other process should be modifying it, but if we bother to do any
locking in the first place, let's do it right.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi M src/backend/postmaster/datachecksum_state.c
Avoid leaving DataChecksumState->worker_pid to an old value
commit : c008b7ea10a5037bf9c6573283b97f4ba56d65c0
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:27 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:27 +0300 It might be left to an old value if the launcher was terminated while
a worker was running. launcher_exit() sends SIGTERM to the worker,
but did not clear 'worker_pid'. Clear it, to be tidy.
Also clear it in ProcessDatabase() before starting a new datachecksums
worker, to be sure we start from a clean slate. The codepath where
WaitForBackgroundWorkerStartup() returns BGWH_STOPPED but
worker_result != DATACHECKSUMSWORKER_SUCCESSFUL didn't clear it, while
all other codepaths did clear or set it.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi M src/backend/postmaster/datachecksum_state.c
Misc cleanup in datachecksums_state.[ch]
commit : 0edbf72f76833a145cb8eca128b775a8f0090d15
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:24 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 24 Jun 2026 15:07:24 +0300 Move DataChecksumsWorkerResult struct to the .c file. It's not used
anywhere else since commit 07009121c2 removed the injection point test
code that the comment referred to.
Mark StartDataChecksumsWorkerLauncher() as static, since it's not
called from outside the .c file. The DataChecksumsWorkerOperation
struct can then be moved into the .c file too.
Clarify the comment on StartDataChecksumsWorkerLauncher(). It said
"Main entry point for datachecksumsworker launcher process", but I
found that misleading. That description would be a better fit for
DataChecksumsWorkerLauncherMain(), which is the process's "main"
function, rather than StartDataChecksumsWorkerLauncher().
Fix comment on WaitForAllTransactionsToFinish() on postmaster death.
The comment claimed that it sets "the abort flag" on postmaster death,
but it actually just errors outs. Improve the comment to explain why
it doesn't just use WL_EXIT_ON_PM_DEATH.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi M src/backend/postmaster/datachecksum_state.c
M src/include/postmaster/datachecksum_state.h
Fix set of typos and grammar mistakes
commit : b3a95566fc2505d4586680c09d4966dba836cb20
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 24 Jun 2026 16:00:28 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 24 Jun 2026 16:00:28 +0900 This is similar to d3bba0415435, batching all the reports of this type
received since the last batch. This covers typos and inconsistencies
for the most part.
The user-visible documentation change impacts only HEAD. M contrib/pg_stash_advice/stashfuncs.c
M doc/src/sgml/oauth-validators.sgml
M doc/src/sgml/stylesheet-html-common.xsl
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogprefetcher.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/postmaster/startup.c
M src/backend/utils/activity/pgstat_relation.c
M src/backend/utils/activity/pgstat_slru.c
M src/backend/utils/adt/float.c
M src/backend/utils/adt/pg_dependencies.c
M src/include/tsearch/ts_type.h
M src/port/pqsignal.c
Refine error reporting for null treatment on non-window functions
commit : 419ce13b7019f906ebc010af3be09a9deffc2a47
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 24 Jun 2026 11:42:36 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 24 Jun 2026 11:42:36 +0900 Commit 4e5920e6de8 disallowed RESPECT NULLS/IGNORE NULLS on
non-window functions, but it also caused the parser to check for
that clause too early in some cases. As a result, calls such as a
nonexistent function with IGNORE NULLS no longer reported the more
helpful "function ... does not exist" error, and aggregate functions
used as window functions reported "only window functions accept ..."
instead of the more accurate aggregate-specific error.
This commit moves the RESPECT NULLS/IGNORE NULLS checks so that
helpful existing errors are preserved where appropriate. This restores
"function ... does not exist" for nonexistent functions, while still
reporting that plain functions are not window functions and that
aggregates do not accept null treatment.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAHGQGwH7VY_0GkhycyYZ4czkPGL0uGzDyOxk3uuFOSRR7wFY3g@mail.gmail.com M src/backend/parser/parse_func.c
M src/test/regress/expected/window.out
M src/test/regress/sql/window.sql
plperl: Fix NULL pointer dereference for forged array object
commit : 4015abe14bb05f67d2c47549f59c5d382e57150b
author : Richard Guo <rguo@postgresql.org>
date : Wed, 24 Jun 2026 09:09:48 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 24 Jun 2026 09:09:48 +0900 In get_perl_array_ref(), for a PostgreSQL::InServer::ARRAY object, we
look up its "array" key with hv_fetch_string() and then inspect the
returned SV. However, hv_fetch_string() returns a NULL pointer when
the key is absent, and the code dereferenced that result without first
checking whether the pointer itself was NULL. As a result, a plperl
function returning a forged PostgreSQL::InServer::ARRAY object that
lacks the "array" key would crash the backend with a segmentation
fault.
Fix this by checking the pointer returned by hv_fetch_string() before
dereferencing it, matching how other callers in this file already
guard the result. With the check in place, such an object falls
through to the existing error report instead of crashing.
Author: Xing Guo <higuoxing@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CACpMh+DYgcnqZwQLXXuxQcehJTd7T8UmKWSLsK4mFBEp9G2ajA@mail.gmail.com
Backpatch-through: 14 M src/pl/plperl/expected/plperl_array.out
M src/pl/plperl/plperl.c
M src/pl/plperl/sql/plperl_array.sql
Re-index ModifyTable FDW arrays when pruning result relations
commit : b43f8aa4cb302c3f74fd1ed611e3548d4e03dce1
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 23 Jun 2026 21:07:13 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 23 Jun 2026 21:07:13 +0900 ExecInitModifyTable() rebuilds the per-result-relation lists after
dropping result relations removed by initial runtime pruning. The
re-indexing was done for withCheckOptionLists, returningLists,
updateColnosLists, mergeActionLists and mergeJoinConditions, but
fdwPrivLists and fdwDirectModifyPlans were missed. As a result, a
kept foreign result relation could be handed the wrong fdw_private,
or ri_usesFdwDirectModify could be set from the wrong plan index,
leading to wrong behavior or a crash in BeginForeignModify() and in
the direct-modify path.
show_modifytable_info() had the same problem: it indexed the
plan-ordered node->fdwPrivLists with the post-pruning executor
position, so once initial pruning removed a result relation it
could read a different relation's fdw_private (often a NIL entry),
producing wrong EXPLAIN output or a crash.
Fix by re-indexing fdwPrivLists and fdwDirectModifyPlans alongside
the other lists, saving the re-indexed private lists in
ModifyTableState.mt_fdwPrivLists and reading from there in both
nodeModifyTable.c and explain.c.
Reported-by: Chi Zhang <798604270@qq.com>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Author: Rafia Sabih <rafia.pghackers@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/19484-a3cb82c8cde3c8fa%40postgresql.org
Backpatch-through: 18 M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M src/backend/commands/explain.c
M src/backend/executor/nodeModifyTable.c
M src/include/nodes/execnodes.h
Nail pg_parameter_acl in relcache.
commit : 4cc02b80774ecdc4cf2a2d5df09c07df36d68ca5
author : Jeff Davis <jdavis@postgresql.org>
date : Tue, 23 Jun 2026 12:06:33 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Tue, 23 Jun 2026 12:06:33 -0700 Previously, a parameter specified in the startup packet for a physical
replication connection could encounter an error trying to perform an
ACL check for the setting.
Problem was introduced in a0ffa885e4, but no reasonable back-patchable
solution was found, so fixing only in master.
Bumps catversion.
Discussion: https://postgr.es/m/d8f8e11f06d692fff89e6be0f22732d30cf695a0.camel%40j-davis.com
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com> M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/relcache.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_parameter_acl.h
Fix incorrect declarations of variadic pg_get_*_ddl() functions.
commit : 2af70e9374789913c4d474e6fce2e69d7060202e
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 23 Jun 2026 15:06:34 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 23 Jun 2026 15:06:34 -0400 The final parameter of an ordinary variadic function should be an
array type. CREATE FUNCTION won't accept a declaration that isn't
like that, but it's possible to put an incorrect combination into a
pg_proc.dat entry. Sadly, the opr_sanity test that was supposed to
check that is broken and does not report functions with non-array
final parameters. This allowed exactly such a thinko to sneak into
the recently-added pg_get_*_ddl() functions: their last argument
should be declared text[] but was declared text. (We'd probably
have noticed eventually, when somebody tried to actually pass a
variadic array to one of those functions. But their regression
tests do not do that.)
Fix those functions, and fix the opr_sanity test so we'll notice
next time. Bump catversion for new pg_proc contents.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/D41A334E-ED9E-42EE-830D-28D4D36E9317@gmail.com M doc/src/sgml/func/func-info.sgml
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/opr_sanity.out
M src/test/regress/sql/opr_sanity.sql
psql: Tighten heuristics for BEGIN/END within CREATE SCHEMA.
commit : 049b742daad0965be4a846035408ae27ce1f9e14
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 23 Jun 2026 14:12:03 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 23 Jun 2026 14:12:03 -0400 Since d51697484, psql's scanner treats CREATE SCHEMA as a command that
may contain SQL-standard routine bodies, so that semicolons inside
BEGIN ATOMIC ... END blocks do not terminate the command too early.
However, the code counted BEGIN/END throughout CREATE SCHEMA, so that
it could be fooled by valid (and previously accepted) code such as
CREATE SCHEMA s CREATE VIEW begin AS SELECT 1;
Improve this by explicitly checking whether each CREATE sub-clause is
CREATE [OR REPLACE] {FUNCTION|PROCEDURE}, and only counting BEGIN/END
within those clauses. Since CREATE FUNCTION/PROCEDURE wasn't allowed
in CREATE SCHEMA before d51697484, this will not risk failure on any
cases that worked before v19.
There remain cases that fool the top-level CREATE FUNCTION/PROCEDURE
heuristic and thus also the CREATE SCHEMA case, for example
CREATE FUNCTION begin () ...
But that's been true all along with no field complaints, so we'll
leave that issue for another day.
In the name of keeping things readable, move the logic supporting
this out of the {identifier} flex rule and into some small new
subroutines. Also rename existing related PsqlScanState fields
to help distinguish them from the added fields.
This patch also fixes what seems to me (tgl) a small bug: \;
would reset BEGIN/END detection even when inside parens or BEGIN.
That's unlike what a plain semicolon would do, and no such effect
is suggested by the documentation.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/8E03BB8D-003D-4850-9772-5F8015A5A0C7@gmail.com M src/fe_utils/psqlscan.l
M src/include/fe_utils/psqlscan_int.h
M src/test/regress/expected/create_schema.out
M src/test/regress/sql/create_schema.sql
doc: Describe better handling of indexes in ALTER TABLE ATTACH PARTITION
commit : 56f2b0b5334df68b16964d4f9a0cbe9dae913227
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 23 Jun 2026 16:49:34 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 23 Jun 2026 16:49:34 +0900 When ALTER TABLE ... ATTACH PARTITION matches partition indexes to the
parent table's indexes, invalid indexes are skipped. This commit
improves the documentation to describe what e90e9275f56 has changed:
invalid indexes are skipped, and only valid indexes are considered for a
match.
Author: Mohamed Ali <moali.pg@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAGnOmWpAMaE-BOkpwM6mJnHcpS2QZ8yLSSaqmz+vryEsbCWWWA@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/alter_table.sgml
Readable identity strings for property graph objects
commit : 2a7e95b659df2903420e27542e9127c50e8f2a17
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 23 Jun 2026 08:58:16 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 23 Jun 2026 08:58:16 +0200 The "identity" column of pg_identify_object() for property graph
objects can be long string of names connected by "of", e.g. "a of l of
e of g". The type of the first named object is given by column
"type". But the types of intermediate objects are not easy to find
from the identity string especially when some of them share the same
name. Some objects, like user mappings or authorization identifier
members, add types of objects other than the first one in the identity
string. Do the same for property graph objects.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/aej1DkLwhyZWmtxJ%40bdtpg M src/backend/catalog/objectaddress.c
M src/test/regress/expected/create_property_graph.out
doc: Update pg_dump/dumpall/upgrade about handling of external statistics
commit : f0a4f280b4d3cd16c368c524fe0c212643615f46
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 23 Jun 2026 08:20:11 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 23 Jun 2026 08:20:11 +0900 The pages of pg_dump, pg_dumpall and pg_upgrade mentioned that their
--no-statistics and --statistics options did not include the handling of
statistics created by CREATE STATISTICS, which was wrong.
Oversight in c32fb29e979d.
Reported-by: Igi Izumi <igi@sraoss.co.jp>
Discussion: https://postgr.es/m/19529-c7eb1e7a0b07eae6@postgresql.org M doc/src/sgml/ref/pg_dump.sgml
M doc/src/sgml/ref/pg_dumpall.sgml
M doc/src/sgml/ref/pgupgrade.sgml
Fix unsafe order of operations in ResourceOwnerReleaseAll().
commit : ef01ca6dbca54e9bf3abea01c357b346847ebcf3
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 22 Jun 2026 18:03:23 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 22 Jun 2026 18:03:23 -0400 This function called the resource-kind-specific ReleaseResource()
method for each item before deleting that item from the resowner.
That's backwards from the ordering in ResourceOwnerReleaseAllOfKind,
and it's not very safe. If ReleaseResource throws an error then the
subsequent abort cleanup will come back here and try to release that
item again, possibly leading to a double-free or similar crash,
and in any case risking an infinite error cleanup loop. This mistake
explains why the pgcrypto bug just fixed in 80bb0ebcc led to a crash
rather than something more benign.
Remove the item from the resowner, then call ReleaseResource,
matching the way things were done before b8bff07da. If there
is a problem of this sort, we'd prefer to leak the item than
suffer the other likely consequences.
Per further analysis of bug #19527.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/646741.1782157515@sss.pgh.pa.us
Backpatch-through: 17 M src/backend/utils/resowner/resowner.c
pgcrypto: avoid recursive ResourceOwnerForget().
commit : 80bb0ebcc11fb9cb5904d490640408b3d7003a17
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 22 Jun 2026 12:59:16 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 22 Jun 2026 12:59:16 -0400 Raising an error within a function using an OSSLCipher object led
to a complaint from ResourceOwnerForget and then a double-free crash,
because ResOwnerReleaseOSSLCipher forgot to unhook the OSSLCipher
object from its owner. (The sibling logic for OSSLDigest objects got
this right, as did every other ReleaseResource function AFAICS.)
Oversight in cd694f60d.
Bug: #19527
Reported-by: Yuelin Wang <3020001251@tju.edu.cn>
Author: Yuelin Wang <3020001251@tju.edu.cn>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19527-6e7686960c6dce78@postgresql.org
Backpatch-through: 17 M contrib/pgcrypto/openssl.c
Strip removed-relation references from PlaceHolderVars at join removal
commit : 9a60f295bcb186a729d04e76377b7f122b2a1dd9
author : Richard Guo <rguo@postgresql.org>
date : Mon, 22 Jun 2026 10:40:40 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 22 Jun 2026 10:40:40 +0900 When left-join removal deletes a relation, remove_rel_from_query()
updates the relid sets attached to RestrictInfos and
EquivalenceMembers, and the canonical PlaceHolderVar held in each
PlaceHolderInfo, but it does not rewrite the PlaceHolderVars embedded
in clause and EquivalenceClass member expressions. That has been
fine, because later processing consults those relid sets rather than
the embedded PlaceHolderVars.
However, such an expression may afterwards be translated for an
appendrel child and have its relids recomputed from scratch by
pull_varnos(). If the embedded PlaceHolderVar's phrels still mentions
the removed relation, pull_varnos() folds it back in, so the rebuilt
clause's relids reference a no-longer-existent relation. That yields
a parameterized path keyed on the removed relation, tripping the
Assert on root->outer_join_rels in get_eclass_indexes_for_relids().
Fix by stripping the removed relids from the PlaceHolderVars in
surviving rels' baserestrictinfo and in EquivalenceClass member
expressions, keeping them consistent with the canonical
PlaceHolderVars.
This is only reachable on v18 and later, where
match_index_to_operand() began ignoring PlaceHolderVars; before that,
the wrapping PlaceHolderVar prevented the index match that exposes the
stale relids.
Reported-by: Alexander Kuzmenkov <akuzmenkov@tigerdata.com>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CALzhyqwryL2QywgO03VQr_237Sq3MEVgTTT2_A9G3nGT5-SRZg@mail.gmail.com
Backpatch-through: 18 M src/backend/optimizer/plan/analyzejoins.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql
plpython: Use funccache.c infrastructure for procedure caching.
commit : 9bcb8a694b3b9d71e42a6107fbd7ca6ac540400a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 21 Jun 2026 15:08:27 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 21 Jun 2026 15:08:27 -0400 PL/Python set-returning functions can crash with a use-after-free when
CREATE OR REPLACE FUNCTION is executed while the SRF is mid-iteration.
The crash occurs because srfstate->savedargs is allocated in proc->mcxt,
which gets deleted when the procedure is invalidated, leaving a dangling
pointer that PLy_function_restore_args() then dereferences.
The best fix is to use reference counting to prevent destroying the
function state while it's still in use, similar to what PL/pgSQL has
done. Rather than inventing a new wheel, this commit converts
PL/Python to use the funccache.c infrastructure.
The main challenge is that PL/Python uses SFRM_ValuePerCall for SRFs,
where the handler is called multiple times. A naive implementation
would allow the refcount to return to zero between calls, but we need
to hang onto the original state and function body. SQL-language
functions face the same challenge, so this commit follows the same
approach used in functions.c: maintain a per-call-site cache struct
(PLyProcedureCache) in fn_extra that holds both the pointer to the
long-lived PLyProcedure and the SRF execution state.
The use_count is incremented when we first obtain the procedure and is
decremented via a MemoryContextCallback registered on fn_mcxt, which runs
even during error aborts. Cleaning up the per-call SRF state needs more
care: an ExprContextCallback handles the in-query cases, since the
iterator is not guaranteed to run to completion (for example a LIMIT or a
rescan can abandon it early). But unlike SQL functions, whose resources
are released by transaction abort, PL/Python holds Python reference counts
on the iterator and saved arguments that abort will not release, and
ExprContextCallbacks are not invoked during an error abort. The
MemoryContextCallback on fn_mcxt therefore doubles as the backstop that
releases those references when a query errors out mid-iteration.
Since fn_extra is now used for PLyProcedureCache, this commit removes
use of the funcapi.h SRF infrastructure (SRF_IS_FIRSTCALL,
SRF_RETURN_NEXT, etc.) and switches to direct isDone signaling via
ReturnSetInfo, matching how SQL functions handle ValuePerCall mode.
This fixes a longstanding bug, so ideally we'd back-patch it. But
it'd be impractical to back-patch further than v18 where funccache.c
came in. The patch is somewhat invasive, and the bug only arises in
very uncommon usages (which is why it evaded detection for so long).
On the whole, the risk/reward ratio for putting this into v18 doesn't
seem good, so commit to master only.
Bug: #19480
Reported-by: Andrzej Doros <adoros@starfishstorage.com>
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19480-f1f9fdce30462fc4@postgresql.org M src/pl/plpython/expected/plpython_setof.out
M src/pl/plpython/plpy_exec.c
M src/pl/plpython/plpy_exec.h
M src/pl/plpython/plpy_main.c
M src/pl/plpython/plpy_procedure.c
M src/pl/plpython/plpy_procedure.h
M src/pl/plpython/sql/plpython_setof.sql
M src/tools/pgindent/typedefs.list
doc: Clarify pg_get_sequence_data() privileges and NULL results
commit : 031904048aa22e7c70dc8e9c170e2743f9b0f090
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 20 Jun 2026 18:20:58 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 20 Jun 2026 18:20:58 +0900 The documentation for pg_get_sequence_data() did not match the
function's behavior. It stated that either USAGE or SELECT privilege
was sufficient, but the function returns sequence data only when the
caller has SELECT privilege.
The documentation also did not explain that the function returns a row
containing all NULL values when sequence data cannot be returned, such
as when the sequence does not exist or the caller lacks the required
privilege.
Update the documentation to reflect the actual behavior, including the
required privilege and the result returned when sequence data is
unavailable.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/CAHGQGwGNTaXnBKUV510_P1KwhdbHT+kgZ4zU5njBHy7nCqdhzg@mail.gmail.com M doc/src/sgml/func/func-sequence.sgml
Fix misreporting of publisher sequence permissions during sync
commit : d4a657b0a4db72ca3fe1a02e851f776276a8d8a1
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 20 Jun 2026 18:19:23 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 20 Jun 2026 18:19:23 +0900 When synchronizing sequences for logical replication, a
publisher-side permission failure could be reported as if the sequence
were missing on the publisher, making the real cause harder to
identify.
This happened because pg_get_sequence_data() returns a row of NULL
values when the replication connection lacks permission to read a
sequence. Sequence synchronization treated that the same as a missing
sequence, causing it to emit a misleading "missing sequence on
publisher" warning.
Fix this by distinguishing permission failures from genuinely missing
sequences. The synchronization query now checks whether the
replication connection has the required privilege for each published
sequence, allowing the worker to report permission failures
separately.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/CAHGQGwGNTaXnBKUV510_P1KwhdbHT+kgZ4zU5njBHy7nCqdhzg@mail.gmail.com M src/backend/replication/logical/sequencesync.c
M src/test/subscription/t/036_sequences.pl
Make type cache initialization more resilient on re-entry after OOM
commit : 73dab12719eec2996d8b033bb9d8bc2819cb0d4e
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 20 Jun 2026 16:29:28 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 20 Jun 2026 16:29:28 +0900 An out-of-memory failure while initializing the type cache hash tables
would issue an ERROR and leave a backend in a partially inconsistent
state. Without assertions, the server would crash with a NULL pointer
dereference on initialization re-entry when doing a type lookup due to
one or both hash tables missing. An assertion would trigger if these
are enabled in the build.
This commit changes the ordering of the type cache initialization to
become more robust on re-entry after an in-flight allocation failure:
- The two hash tables are initialized first, and can only be initialized
once.
- The initialization is considered as done once the in-progress list is
allocated in the CacheMemoryContext. This is now the last allocation
step.
- Last, the callbacks are registered. These can only fail with a FATAL
error, taking down the process so leaving the process in a non-complete
state is fine.
This is in the same spirit as b85f9c00fb88 and 29fb598b9cad, where
random allocation failures can make the backend go crazy in the code
paths fixed due to the static states becoming inconsistent. Like the
other fixes, this is unlikely going to show up in practice, so no
backpatch is done.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com M src/backend/utils/cache/typcache.c
Make StandbyAcquireAccessExclusiveLock() more resilent with OOMs
commit : b85f9c00fb8822eb2142c347ce529f651dbef178
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 20 Jun 2026 15:00:40 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 20 Jun 2026 15:00:40 +0900 In StandbyReleaseXidEntryLocks, a failure in acquiring a lock with
LockAcquire() due to an out-of-memory problem would lead to an
inconsistency with the lock state cached in the startup process,
impacting the list of RecoveryLockXidEntrys. The code is updated here
so as the cached state is updated once the lock is acquired.
This problem is unlikely going to happen in practice. Even if it were
to show up, it would translate to a LOG message for non-assert builds
(assertion failure otherwise), so no backpatch is done. This commit is
in the same spirit as 29fb598b9cad, with a problem emulated by injecting
random failures for allocations.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com M src/backend/storage/ipc/standby.c
Make pg_mkdir_p() tolerant of a concurrent directory creation.
commit : f25a07b2d94c8028129e260b49b90eaff266bd3a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 19 Jun 2026 12:52:00 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 19 Jun 2026 12:52:00 -0400 pg_mkdir_p creates each missing path component with a stat() followed
by mkdir(). If the stat() reports the component as absent but another
process creates it in the window before this process's mkdir(), mkdir()
fails with EEXIST and pg_mkdir_p treated that as a hard error -- unlike
"mkdir -p", which is meant to be idempotent and race-tolerant.
This shows up when several processes concurrently create paths that
share an ancestor directory: for example, parallel initdb runs whose
data directories live under a common temporary directory. One process
wins the race to create the shared ancestor and the others fail with
could not create directory "...": File exists
Fix this race condition by first trying mkdir() and only attempting
stat() if it fails with EEXIST.
On Windows, there's an additional problem: stat() opens a file handle
and participates in share-mode locking, which means it can transiently
fail on a directory another process is concurrently creating. Use
GetFileAttributes() instead: it requests only FILE_READ_ATTRIBUTES
and is exempt from share-mode denial, so it reliably sees a
concurrently-created directory.
I (tgl) also chose to back-patch 039f7ee0f's effects on this function,
so that pgmkdirp.c remains identical in all live branches.
Author: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3ca004de-e49b-4471-b8aa-fd656e70f68c@dunslane.net
Backpatch-through: 14 M src/port/pgmkdirp.c
Update JIT tuple deforming code for virtual generated columns
commit : dc5116780846951a409d788479a9e9fa6edd9f07
author : David Rowley <drowley@postgresql.org>
date : Fri, 19 Jun 2026 15:26:18 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 19 Jun 2026 15:26:18 +1200 The JIT deforming code contains an optimization that determines which
columns are guaranteed to exist in the tuple. That's used to allow
skipping of reading the tuple's natts when the code only needs to deform
attributes that are guaranteed to always exist in all tuples. 83ea6c540
missed updating this code to account for VIRTUAL generated columns.
These are stored as NULLs in the tuple, but may be defined as NOT NULL.
This could result in the code thinking more columns are guaranteed to
exist than actually do.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/1151393.1781734980@sss.pgh.pa.us M src/backend/jit/llvm/llvmjit_deform.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
Fix comments on data checksum cost settings
commit : 8d22f5232458278aa62a1769758a8aa6b1dfe290
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 18 Jun 2026 23:16:35 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 18 Jun 2026 23:16:35 +0200 The cost parameters for the data checksums worker can be updated by the
user issuing a repeated enable checksum command, but the comments on the
struct members hadn't been updated to reflect this and were out of date.
Another part of the same comment needed better wording to be readable.
Also wrap the reading of the parameters in a lock, there is no live
bug due to not using a lock but it's still the right thing to do.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/2176020b-ecbc-438b-9fc3-9c3593d9e6fc@iki.fi M src/backend/postmaster/datachecksum_state.c
Silence "may be used uninitialized" compiler warning.
commit : f04781df5daf112840d08eab39fb95505fda6c9c
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 18 Jun 2026 11:29:49 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 18 Jun 2026 11:29:49 -0500 Newer gcc warns that this "actual_arg_types" variable may be used
uninitialized, but visual inspection indicates there's no bug. To
silence the warning, initialize the variable to zeros.
Bug: #19485
Reported-by: Hans Buschmann <buschmann@nidsa.net>
Tested-by: Erik Rijkers <er@xs4all.nl>
Tested-by: Hans Buschmann <buschmann@nidsa.net>
Reviewed-by: Tristan Partin <tristan@partin.io>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/19485-2b03231a775756f1%40postgresql.org
Discussion: https://postgr.es/m/6c52a1a6612948519468d46cb224a8c4%40nidsa.net M src/backend/optimizer/util/clauses.c
hstore_plperl: Add CHECK_FOR_INTERRUPTS() in reference-unwinding loop.
commit : c0f17b04d9069cdfd0631b86c776be13192dbe1d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 18 Jun 2026 12:22:55 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 18 Jun 2026 12:22:55 -0400 Add CHECK_FOR_INTERRUPTS() to the while loop in plperl_to_hstore()
that dereferences chains of Perl references, so that a circular
reference (e.g. $x = \$x) can be cancelled by the user instead of
spinning indefinitely. (We looked at detecting such circular
references, but it seems more trouble than it's worth.)
This is a follow-up to da82fbb8f, which fixed the same issue in
SV_to_JsonbValue() in jsonb_plperl.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJ7c6TPbjkzUk4qJ5dHvDNEz0hBuFue3A-XWz_=897z+BC+z8A@mail.gmail.com
Backpatch-through: 14 M contrib/hstore_plperl/hstore_plperl.c
Avoid errors during DROP SUBSCRIPTION when slot_name is NONE.
commit : 702e9dfd6c5001fd64d51c3c47dca2fc953fa9cd
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 18 Jun 2026 09:00:32 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 18 Jun 2026 09:00:32 -0700 Previously, if the subscription used a server,
ForeignServerConnectionString() could raise an error (e.g. missing
user mapping) during DROP SUBSCRIPTION even if the conninfo wasn't
needed at all.
Construct conninfo after the early return, so that if slot_name is
NONE and rstates is NIL, the DROP SUBSCRIPTION will succeed even if
ForeignServerConnectionString() raises an error (e.g. missing user
mapping).
If slot_name is NONE and rstates is not NIL, DROP SUBSCRIPTION may
still encounter an error from ForeignServerConnectionString().
Reported-by: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/OS9PR01MB12149B54DEA148108C6FA5667F52D2@OS9PR01MB12149.jpnprd01.prod.outlook.com M src/backend/commands/subscriptioncmds.c
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql
doc PG 19 relnotes: fix "standard_conforming_strings = off text
commit : 9228275b04c1677927d359fd36bae5468b69c6a1
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 18 Jun 2026 12:19:16 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 18 Jun 2026 12:19:16 -0400 Reported-by: Tom Lane
Discussion: https://postgr.es/m/1242905.1781796886@sss.pgh.pa.us M doc/src/sgml/release-19.sgml
Avoid division-by-zero when calculating autovacuum MXID score.
commit : 1f2297b548794a0fec502a9fc70c9970d96b09c4
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 18 Jun 2026 10:18:25 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 18 Jun 2026 10:18:25 -0500 In some cases, effective_multixact_freeze_max_age can be 0, which
presents a division-by-zero hazard for the multixact ID age score
calculation. To fix, bump it to 1 in that case so that we use the
multixact ID age as the score. While at it, also document that
this component score scales due to high multixact member space
usage.
Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>
Author: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CAD21AoC6nKeYAjTvJ9dmBea03GZK9222h_O%3DONmcVuxfyO88Bg%40mail.gmail.com M doc/src/sgml/maintenance.sgml
M src/backend/postmaster/autovacuum.c
doc: Fix "Prev" link, take 2.
commit : f0a5c4fbfc42f57a4564b9919c7eb0c52e656fc1
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 18 Jun 2026 09:31:27 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 18 Jun 2026 09:31:27 -0500 Commit 6678b58d78 fixed a wrong "Prev" link by changing the link
generation code to use [position()=last()] instead of [last()] in
the predicate on the union of reverse axes. Unfortunately, that
caused documentation builds to take much longer. To fix, combine
the "preceding" and "ancestor" steps into one "preceding" step and
one "ancestor" step, and revert the predicate back to [last()].
The smaller union evades the libxml2 bug while avoiding the build
time regression.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Tested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1132496.1781718007%40sss.pgh.pa.us
Backpatch-through: 14 M doc/src/sgml/stylesheet-speedup-xhtml.xsl
Revert non-text output formats for pg_dumpall
commit : 7ca548f23a60887541493b2da47f2b2720c35ee3
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 15 Jun 2026 15:58:04 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 15 Jun 2026 15:58:04 -0400 This reverts the non-text (custom/directory/tar) output format support
for pg_dumpall added by 763aaa06f03 and its feature-specific follow-ups,
in line with Noah Misch's post-commit review which recommends reverting
and finishing the work through the commitfest.
Scope is deliberately minimal: only the feature itself is removed.
Independent improvements that merely touched the same files, or that were
committed alongside the feature but do not depend on its design, are
preserved.
Reverted (the feature):
763aaa06f03 Add non-text output formats to pg_dumpall
d6d9b96b404 Clean up nodes that are no longer of use in 007_pgdumpall.pl
01c729e0c7a Fix casting away const-ness in pg_restore.c
c7572cd48d3 Improve writing map.dat preamble
3c19983cc08 pg_restore: add --no-globals option to skip globals
abff4492d02 Fix options listing of pg_restore --no-globals
bb53b8d359d Fix small memory leak in get_dbname_oid_list_from_mfile()
a793677e57b pg_restore: Remove dead code in restore_all_databases()
a198c26dede pg_dumpall: simplify coding of dropDBs()
ec80215c033 pg_restore: Remove unnecessary strlen() calls in options parsing
Preserved (independent of the feature):
b2898baaf7e the check_mut_excl_opts() helper in src/fe_utils/option_utils.c
and its use in pg_dump
7c8280eeb58 pg_dump's conflicting-option refactor (and tests 002/005)
be0d0b457cb pg_dumpall's rejection of --clean together with --data-only
(re-expressed directly, since pg_dumpall.c is otherwise
returned to its pre-feature state)
74b4438a70b the dangling-grantor-OID GRANT fix (back-patched through 16)
273d26b75e7, d4cb9c37765 independent pg_restore.sgml clarifications
Because the feature restructured pg_dumpall.c and pg_restore.c (pg_restore's
main() was split into restore_one_database() plus a dispatcher) and
interleaved its option checks with the conflicting-option refactor in the
same regions, the cosmetic check_mut_excl_opts() reflow of those two files'
option blocks is inseparable from the feature and comes out with it; the
behavior is unchanged. The reusable helper and pg_dump's use of it are
unaffected.
Discussion: https://postgr.es/m/20260607000218.96.noahmisch@microsoft.com M doc/src/sgml/ref/pg_dumpall.sgml
M doc/src/sgml/ref/pg_restore.sgml
M doc/src/sgml/release-19.sgml
M src/bin/pg_dump/meson.build
M src/bin/pg_dump/parallel.c
M src/bin/pg_dump/pg_backup.h
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_archiver.h
M src/bin/pg_dump/pg_backup_tar.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_dump/pg_restore.c
M src/bin/pg_dump/t/001_basic.pl
M src/bin/pg_dump/t/005_pg_dump_filterfile.pl
D src/bin/pg_dump/t/007_pg_dumpall.pl
M src/tools/pgindent/typedefs.list
Create TOAST table for partitions made by MERGE/SPLIT PARTITION
commit : ff8bec8c460a13bedbb416d8697f4675a0709ce8
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 18 Jun 2026 10:30:14 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 18 Jun 2026 10:30:14 +0300 ALTER TABLE ... MERGE PARTITIONS / SPLIT PARTITION builds a new
partition via createPartitionTable(), but never gives it a TOAST table.
When the source rows carried out-of-line varlena values, the move
into the new partition entered heap_toast_insert_or_update() with
reltoastrelid = InvalidOid: the externalization step is skipped, the
value falls back to inline storage and heap_insert() fails with
"row is too big" error. Also, TOAST table is needed if the new partition
receives out-of-line varlena values after the DDL operation is complete.
Call NewRelationCreateToastTable() right after the new partition is
created in createPartitionTable(), mirroring what DefineRelation()
does for regular CREATE TABLE. NewRelationCreateToastTable() decides
on its own whether a TOAST table is actually required, so partitions
with no toast-eligible columns are unaffected.
Reported-by: Justin Pryzby <pryzby@telsasoft.com>
Discussion: https://postgr.es/m/ai_c4-v8iLA2kXFV%40pryzbyj2023
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com> M src/backend/commands/tablecmds.c
M src/test/regress/expected/partition_merge.out
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_merge.sql
M src/test/regress/sql/partition_split.sql
Make GetSnapshotData() more resilient on out-of-memory errors
commit : 29fb598b9cad898ef851b9a7704f980218057562
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 18 Jun 2026 14:05:27 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 18 Jun 2026 14:05:27 +0900 If the allocation of Snapshot->subxip fails, a follow-up call of
GetSnapshotData() would see a partially-initialized snapshot, causing a
NULL dereference on reentry when using "subxip" because only "xip" would
be allocated. In the event of an out-of-memory error when allocating
"subxip", "xip" is now reset before throwing an ERROR, so as Snapshots
can be allocated and handled gracefully on retry.
This problem is unlikely going to show up in practice, so no backpatch.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com M src/backend/storage/ipc/procarray.c
Avoid stale slot access after dropping obsolete synced slots.
commit : bdae2c20e88d80c63bd8de2c57aebd9cea590bc7
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 18 Jun 2026 09:50:33 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 18 Jun 2026 09:50:33 +0530 drop_local_obsolete_slots() continued to dereference local_slot after
calling ReplicationSlotDropAcquired(). Once the slot is dropped, its
entry in the slot array can be reused by another backend, so later reads
of local_slot->data could observe a different slot's name or database
OID, leading to an incorrect unlock and log message.
Save the slot name and database OID before performing the drop, and use
the saved values for the subsequent UnlockSharedObject() call and the log
message. While at it, emit the "dropped replication slot" message only
when a slot was actually dropped, rather than unconditionally.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Backpatch-through: 17, where it was introduced
Discussion: https://postgr.es/m/TY4PR01MB177184FF9EE916F577E1F554194082@TY4PR01MB17718.jpnprd01.prod.outlook.com M src/backend/replication/logical/slotsync.c
Fix PANIC with track_functions due to concurrent drop of pgstats entries
commit : 850b9218c8e4aa7a56f4ec34a542d4a37f9e07eb
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 18 Jun 2026 11:49:30 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 18 Jun 2026 11:49:30 +0900 pgstat_drop_entry_internal() generates an ERROR if facing a pgstats
entry already marked as dropped. With a workload doing a lot of
concurrent CALL and DROP/CREATE PROCEDURE, it could be possible for
AtEOXact_PgStat_DroppedStats(), that wants to do transactional drops, to
find entries that are already dropped, after a commit record has been
written. In this case, ERRORs are upgraded to PANIC, taking down the
server.
This issue is fixed by making pgstat_drop_entry() optionally more
tolerant to concurrent drops, adding to the routine a missing_ok option
to make some of its callers more tolerant (spoiler: some of the callers
want a strict behavior, like replication slots and backend stats).
pgstat_drop_entry_internal() cannot be called anymore for an entry
marked as dropped, hence its error is replaced by an assertion.
Functions are handled as a special case in core; this problem could also
apply to custom stats kinds depending on what an extension does.
track_functions is costly when enabled (disabled by default), which is
perhaps the main reason why this has not be found yet.
A similar version of this patch has been proposed by Sami Imseih on a
different thread for a feature in development. This version has tweaked
here by me for the sake of fixing this issue.
Reported-by: zhanglihui <zlh21343@163.com>
Author: Sami Imseih <samimseih@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/19520-73873648d44793cf@postgresql.org
Backpatch-through: 15 M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_function.c
M src/backend/utils/activity/pgstat_replslot.c
M src/backend/utils/activity/pgstat_shmem.c
M src/backend/utils/activity/pgstat_xact.c
M src/include/utils/pgstat_internal.h
M src/test/modules/test_custom_stats/test_custom_var_stats.c
Doc: Clarify that publication exclusions track table identity.
commit : 77b6dd909252e3a6352e345788a925d3e4768cda
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 18 Jun 2026 08:02:33 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 18 Jun 2026 08:02:33 +0530 The EXCEPT clause of a FOR ALL TABLES publication tracks each excluded
table by its identity rather than by name. As a result, renaming a table
or moving it to another schema with ALTER TABLE ... SET SCHEMA leaves the
exclusion in place, and the table stays excluded from the publication.
This behavior was not previously documented and could surprise users who
might reasonably expect a schema-qualified exclusion to apply only while
the table remains in that schema. Add a note to CREATE PUBLICATION to make
the behavior explicit.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAHut+PvQ5BqnawCQd6r1tqqd+iAJC-CuRY8wscuXSrpHGUzofA@mail.gmail.com M doc/src/sgml/ref/create_publication.sgml
doc PG 19 relnotes: update to current
commit : 34b198b2d7d1b0b4a9b90ea8697a81432889e451
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 17 Jun 2026 21:44:25 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 17 Jun 2026 21:44:25 -0400 M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: remove VALIDATE CONSTRAINT lock item
commit : 2dab2ce3d781c9fdaf39d9ce2c5523043eb89d9d
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 17 Jun 2026 21:34:23 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 17 Jun 2026 21:34:23 -0400 Reported-by: Fujii Masao
Discussion: https://postgr.es/m/CAHGQGwGjfu5n5H-jsMp6fAsf-zMJzYWDcJGti6pmr7SHf9BcpA@mail.gmail.com M doc/src/sgml/release-19.sgml
Fix ALTER DOMAIN VALIDATE CONSTRAINT locking
commit : 64797ad97d6e0a476f809979df99e0013c1933b1
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 18 Jun 2026 10:19:15 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 18 Jun 2026 10:19:15 +0900 Commit 16a0039dc0d1 reduced the lock level for ALTER DOMAIN ...
VALIDATE CONSTRAINT from ShareLock to ShareUpdateExclusiveLock.
However, that change was unsafe. If DML on tables using the domain had
already started and initialized domain constraint checks before a NOT
VALID constraint was added, it could still insert or update rows that
violated the new constraint.
This commit reverts commit 16a0039dc0d1 so that ALTER DOMAIN ...
VALIDATE CONSTRAINT once again acquires ShareLock on relations using
the domain. Also add an isolation test covering this case.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/463C0E1A-4A40-4BCA-839C-9236B80D65EE@gmail.com M src/backend/commands/typecmds.c
A src/test/isolation/expected/alter-domain-validate.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/alter-domain-validate.spec
doc PG 19 relnotes: mention pg_dump{all} & standard_conforming_strings
commit : 62c09cdc16757da93c373a197ec51a52b14bc2b3
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 17 Jun 2026 19:33:35 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 17 Jun 2026 19:33:35 -0400 Dumps will fail if standard_conforming_strings = off.
Reported-by: Tom Lane
Backpatch-through: 1131492.1781717349@sss.pgh.pa.us M doc/src/sgml/release-19.sgml
Avoid errors during ALTER SUBSCRIPTION.
commit : e5c40584a712e8f8c6bd9a7a87bdb855cfd2f20b
author : Jeff Davis <jdavis@postgresql.org>
date : Wed, 17 Jun 2026 15:34:07 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Wed, 17 Jun 2026 15:34:07 -0700 Previously, when retrieving the old Subscription object, constructing
the conninfo could encounter an error during
ForeignServerConnectionString(). ACL errors were handled properly, but
other errors could interfere with a user fixing the problem with ALTER
SUBSCRIPTION.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/D908370F-2695-4231-851D-17179A6A6F2A@gmail.com 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/regress.c
M src/test/regress/sql/subscription.sql
oauth: Skip call-count test for libcurl 8.20.0
commit : fd5ea2e9e37c1aee80698b3e8d9d835eaa19a30c
author : Jacob Champion <jchampion@postgresql.org>
date : Wed, 17 Jun 2026 09:57:59 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Wed, 17 Jun 2026 09:57:59 -0700 The call-count test in 001_server.pl runs into a recent upstream
regression in Curl:
https://github.com/curl/curl/issues/21547
The symptom is high CPU usage on some platforms during OAuth HTTP
requests. But it looks like the fix is on track for a June 2026 release,
as part of Curl 8.21.0, so just skip the test if we happen to be using
the broken version.
Reported-by: Andrew Dunstan <andrew@dunslane.net>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Tested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAOYmi%2B%3DyrwMSsHuNJ1V14isA4iSix5Xb3P3VEp1X0BS61MdV4A%40mail.gmail.com
Backpatch-through: 18 M src/test/modules/oauth_validator/t/001_server.pl
libpq-oauth: Print libcurl version with OAUTHDEBUG_UNSAFE_TRACE
commit : 4bd477dcc61959b3299d091e6c7fc02b73c7afa5
author : Jacob Champion <jchampion@postgresql.org>
date : Wed, 17 Jun 2026 09:57:20 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Wed, 17 Jun 2026 09:57:20 -0700 When debugging an OAuth trace, it's helpful to know what version of Curl
is in use. The SSL library that Curl is using (which may not be the one
in use by libpq) is also relevant, and it's just as easy to get, so
print that too.
This is being added post-feature-freeze, with RMT approval, in order to
fix some tests in the face of an upstream Curl regression. A subsequent
commit will make use of it in oauth_validator. Backpatch to 18 as well.
Tested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAOYmi%2B%3DkP86t%2BZFFXNQ9G6K4ht7utdmB%3DCzhP%3DZ2wvuBymOTtQ%40mail.gmail.com
Backpatch-through: 18 M src/interfaces/libpq-oauth/oauth-curl.c
oauth_validator: Print captured stderr after call-count failure
commit : 6222233159728963cc0183d7c80fb66fc444a113
author : Jacob Champion <jchampion@postgresql.org>
date : Wed, 17 Jun 2026 09:57:15 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Wed, 17 Jun 2026 09:57:15 -0700 If the call count test fails, you'll reasonably want to know what the
network trace looked like, but that information is currently swallowed.
Print it out instead.
Backpatch-through: 18 M src/test/modules/oauth_validator/t/001_server.pl
jsonb_plperl, jsonb_plpython: Fix unguarded recursion and loops.
commit : da82fbb8f9a3b1e46b55d5975ef59113cd3a59a6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 17 Jun 2026 11:04:41 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 17 Jun 2026 11:04:41 -0400 Add check_stack_depth() to Jsonb_to_SV, SV_to_JsonbValue,
PLyObject_FromJsonbContainer, and PLyObject_ToJsonbValue. Without
this, deeply nested JSONB values can crash the backend with SIGSEGV
instead of raising a proper error.
Also add CHECK_FOR_INTERRUPTS() to the while loop in SV_to_JsonbValue
that dereferences chains of Perl references, so that a circular
reference (e.g. $x = \$x) can be cancelled by the user instead of
spinning indefinitely. (We looked at detecting such circular
references, but it seems more trouble than it's worth.)
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJ7c6TPbjkzUk4qJ5dHvDNEz0hBuFue3A-XWz_=897z+BC+z8A@mail.gmail.com
Backpatch-through: 14 M contrib/jsonb_plperl/jsonb_plperl.c
M contrib/jsonb_plpython/jsonb_plpython.c
vacuumdb: Fix --missing-stats-only for partitioned indexes.
commit : d2cea63065b3684d2d1eba4c3f4dea68bf1b373c
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 17 Jun 2026 09:18:39 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 17 Jun 2026 09:18:39 -0500 The current form of the catalog query picks up partitioned tables
with expression indexes that lack statistics. However, since such
indexes never have statistics, there's no point in analyzing them.
To fix, adjust the relevant part of the query to skip partitioned
tables with expression indexes. While at it, remove the nearby
stainherit check; entries for index expressions always have
stainherit = false.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/CA%2Bfm-RPE1tEc6CUUPDyRbYTz9tF5Kw47nnk-Zq%3DyYvanbsxyCQ%40mail.gmail.com
Backpatch-through: 18 M src/bin/scripts/t/100_vacuumdb.pl
M src/bin/scripts/vacuuming.c
Fix pgstat_count_io_op_time() calls passing incorrect information
commit : 3048e81308f9d0ebe62214b56c8ea3da42e45851
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 17 Jun 2026 16:05:11 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 17 Jun 2026 16:05:11 +0900 Several calls of pgstat_count_io_op_time() have been used as data to
count negative values returned by pg_pread() or pg_pwrite(), leading to
an incorrect count reported, casting them back to uint64.
Most of the problematic calls updated here are adjusted so as we do not
report buggy negative numbers anymore. In xlogrecovery.c, the spot
updated still counts short reads. In xlog.c, after a WAL segment
initialization, I/O numbers are aggregated only after checking that the
operation has succeeded.
issues introduced by a051e71e28a1.
Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/0db864e6-4477-4eba-b2be-d3523cc86564@eisentraut.org
Backpatch-through: 18 M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogreader.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/replication/walreceiver.c
Silence uninitialized variable warning with some compiler versions
commit : f29299c42b0b7877db0c339147d95524be69b4e6
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 17 Jun 2026 09:00:49 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 17 Jun 2026 09:00:49 +0300 The first "if (difffile)" block initializes the startpos variable, and
the second "if (difffile)" block reads it. The second if-condition can
only be true when the first one was true, so the startpos variable is
always initialized when it's used. However, the compiler might not be
able to deduce that, and warn about startpos being used uninitialized.
To silence the warning, rearrange the if-checks. Also, bail out if the
diff file cannot be opened, instead of ignoring it silently.
Author: Mikhail Litsarev <m.litsarev@postgrespro.ru>
Reviewed-by; Ewan Young <kdbase.hack@gmail.com>
Discussion: https://www.postgresql.org/message-id/ee06f058c626cd37babd8c81579ffb1e@postgrespro.ru M src/test/regress/pg_regress.c
Add tuple deformation test for virtual generated columns
commit : 1f7dfe8c8ef725ded72f7398ceca4b39ea511aee
author : David Rowley <drowley@postgresql.org>
date : Wed, 17 Jun 2026 16:57:16 +1200
committer: David Rowley <drowley@postgresql.org>
date : Wed, 17 Jun 2026 16:57:16 +1200 Add coverage for a virtual generated NOT NULL column followed by a
physically stored NOT NULL column. This exercises the tuple deformation
case fixed by 89eafad297a, where TupleDescFinalize() could incorrectly
treat a virtual generated column as part of the guaranteed physical column
prefix and compute cached offsets past it.
Without that fix, deforming the following column could read from the wrong
tuple offset.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/A4BC563C-0CA3-4EF3-952A-EA41F9E5BF1E%40gmail.com 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
Fix error message typo.
commit : ab3023ad1e685987ee1b5e7f28e0635296464cf5
author : Tatsuo Ishii <ishii@postgresql.org>
date : Wed, 17 Jun 2026 12:43:07 +0900
committer: Tatsuo Ishii <ishii@postgresql.org>
date : Wed, 17 Jun 2026 12:43:07 +0900 4e5920e6de8 added an ereport call with the primary error message
starting with upper case, which is prohibited by our error message
style guide. This commit fixes it.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://postgr.es/m/8BACA715-B9B6-479D-9153-C05F05482664%40gmail.com M src/backend/parser/parse_func.c
M src/test/regress/expected/window.out
Fix RI fast-path for domain-typed FK columns
commit : 68ace967c16bcd5fae87f13678b74ab5c5ea1a0f
author : Amit Langote <amitlan@postgresql.org>
date : Wed, 17 Jun 2026 11:15:53 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Wed, 17 Jun 2026 11:15:53 +0900 The RI fast path is the first caller to pass a cross-type pf_eq_oprs
operator to ri_HashCompareOp(). Its test for whether a cast can be
skipped, "typeid == righttype", failed when the FK column was a domain,
since typeid is then the domain OID rather than its base type. The code
concluded no usable conversion existed and threw "no conversion function
from <domain> to <type>" for every valid row.
Look through the domain to its base type. When pfeqop comes directly
from the index opfamily its right-hand input is getBaseType(fktype), so
getBaseType(typeid) == righttype is the correct test; the PK = PK
fallback (right-hand input opcintype) still fails that test and falls
through to the existing cast lookup unchanged.
Oversight in commit 2da86c1.
Reported-by: Ewan Young <kdbase.hack@gmail.com>
Author: Ewan Young <kdbase.hack@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CAON2xHNDFC4cX2atvTpMuC=cK9y7q4J+n3+15w4148AohXEc1w@mail.gmail.com 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 to not allow null treatment to non window functions.
commit : 4e5920e6de87dc1ed761d2a898b7786c50c11db2
author : Tatsuo Ishii <ishii@postgresql.org>
date : Wed, 17 Jun 2026 10:12:07 +0900
committer: Tatsuo Ishii <ishii@postgresql.org>
date : Wed, 17 Jun 2026 10:12:07 +0900 The null treatment clause (RESPECT NULLS/IGNORE NULLS) are only
allowed to window functions per spec. Previously the check was only
applied to aggregates in window clause. Other types of functions were
allowed to use the clause, which was plain wrong.
To fix this, ParseFuncOrColumn() now checks whether other than window
functions are used with the null treatment clause. If so, error out.
Also remove the unnecessary test for "aggregate functions do not
accept RESPECT/IGNORE NULLS" because it is now checked in the
early-stage new check. The window regression test expected file is
changed accordingly.
Reported-by: jian he <jian.universality@gmail.com>
Reviewed-by: jian he <jian.universality@gmail.com>
Author: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://postgr.es/m/CACJufxFnm%2BAj2Jyhyd58PtW8e1vTZDKimkZE%2BMashCPSDKw56Q%40mail.gmail.com M src/backend/parser/parse_func.c
M src/test/regress/expected/window.out
Fix another instability in recovery TAP test 004_timeline_switch
commit : 9285737ac3cf868f623631b087687cab260a9de4
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 17 Jun 2026 08:42:04 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 17 Jun 2026 08:42:04 +0900 The test did not wait for the standby to be connected to the primary.
This breaks one assumption at the beginning of the test, where the
primary is stopped to ensure that all its records are flushed to both
standbys before moving on with its next steps.
If standby_1 finishes ahead of standby_2, the test would be able work
fine as the former waits for the latter. The opposite is not true,
standby_2 getting ahead of standby_1 would cause the test to fail on
timeout when standby_1 attempts to connect to standby_2.
This commit adds an additional polling query after the two standbys are
started, checking that both standbys are connected to the primary before
processing with the initial steps of the test.
Like 7185eddf0522, backpatch down to v14.
Author: Sergey Tatarintsev <s.tatarintsev@postgrespro.ru>
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/fea4190e-f8b5-4432-a52d-bcbee5f34366@postgrespro.ru
Backpatch-through: 14 M src/test/recovery/t/004_timeline_switch.pl
doc PG 19 relnotes: update to current
commit : 9e28c0bd13dce71676866b2647bf6bb17f50e82e
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 16 Jun 2026 13:28:29 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 16 Jun 2026 13:28:29 -0400 Reported-by: Chao Li M doc/src/sgml/release-19.sgml
logical decoding: Correctly free speculative insertion
commit : f50c329f538fdd979a849a06f425c8f9c94787a5
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 16 Jun 2026 18:13:15 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 16 Jun 2026 18:13:15 +0200 The error path in ReorderBufferProcessTXN was not freeing
(reorderbuffer.c's representation of) a speculative insertion record
correctly. In assert-enabled builds, this leads to an assertion
failure. In production builds, I see no effect; there may be a small
transient leak, but in an improbable code path such as this, such a leak
is not of any significance. For users running with assertions enabled,
the crash is annoying.
Fix by having ReorderBufferProcessTXN() free the speculative insert
ahead of freeing the rest of the transaction, and no longer try to
handle that insert as a separate argument to ReorderBufferResetTXN().
This code came in with commit 7259736a6e5b (14-era). Backpatch all the
way back.
In branches 14-16, also backpatch the assertion that originally fails in
the problem scenario, which was added by dbed2e36625d (originally
backpatched to 17), that at the end of ReorderBufferReturnTXN() the
in-memory size of the transaction is zero.
Author: Vishal Prasanna <vishal.g@zohocorp.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Backpatch-through: 14
Discussion: https://postgr.es/m/19c7623e882.4080fd5426212.311756747309556767@zohocorp.com M src/backend/replication/logical/reorderbuffer.c
M src/test/subscription/t/100_bugs.pl
concurrent repack: check there are no leftover toast attribs
commit : e2a8cabc47f9502d26b1212851b6d43e5c06df22
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 16 Jun 2026 14:26:31 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 16 Jun 2026 14:26:31 +0200 Upon reading attributes from the file of concurrent changes, verify that
none are left over unprocessed after we read all columns for the tuple.
This should never happen, so add an elog(ERROR) for it.
While at it, downgrade a nearby message from ereport() to elog(). These
things should never happen.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://postgr.es/m/CAJ7c6TMSF7cANU8nEJ9E28EvU74tE4H7AzT292Rt3ZuHqqxq8w@mail.gmail.com M src/backend/commands/repack.c
pg_restore: Use dependency-based matching for STATISTICS DATA
commit : ae39bd23c662584d2c342b38a7939a38ff058076
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 15:58:12 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 15:58:12 +0900 The previous approach introduced by 0dd93de69e80 was weak in terms of
name matching, as an --index=foo could match with a table with the same
name but from a different schema, pulling in more data than necessary.
For example, imagine the following case:
CREATE SCHEMA s1;
CREATE SCHEMA s2;
CREATE TABLE s1.foo (id int);
INSERT INTO s1.foo SELECT generate_series(1,100);
ANALYZE s1.foo;
CREATE TABLE s2.bar (id int);
CREATE INDEX foo ON s2.bar(id);
INSERT INTO s2.bar SELECT generate_series(1,100);
ANALYZE s2.bar;
A targetted pg_restore --index=foo would grab the relation and attribute
stats of s1.foo on top of the index s2.foo, which is incorrect. This
commit fixes this scenario by relying on a lookup of the dependencies of
a STATISTICS DATA TOC entry, checking if a TOC entry depends on an index
or another relkind before matching with the names of the objects wanted
for the restore.
Discussion: https://postgr.es/m/ajDBwpxs-otl585H@paquier.xyz
Backpatch-through: 18 M src/bin/pg_dump/pg_backup_archiver.c
Fix int32 overflow in ltree_compare()
commit : 3f32804918383e48e9ce1d0f1b396775ab312d52
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 16 Jun 2026 09:27:00 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 16 Jun 2026 09:27:00 +0300 The expression (len_diff * 10 * (an + 1)) used as the return value of
ltree_compare() is computed at int32 width. With LTREE_MAX_LEVELS =
65535, the product can exceed INT32_MAX once an ltree has more than
~14,653 levels, which causes the result to wrap and invert its sign.
That corrupts btree ordering as well as the "magnitude" consumed by
ltree_penalty() for GiST page splits.
To fix, split ltree_compare() into two functions. The new
ltree_compare_distance() function returns a float, which won't
overflow. It's used by the ltree_penalty() caller. All the other
callers only care about the sign of the return value, i.e. which of
the arguments is greater, so change ltree_compare() to not multiply
the result with (10 * (an + 1)), which avoids the overflow for those
callers.
Existing btree or GiST indexes on ltree columns containing values with
more than ~14,653 levels may be corrupt and should be REINDEXed.
Add a regression test based on the reporter's PoC.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reported-by: 王跃林 <violin0613@tju.edu.cn>
Discussion: https://www.postgresql.org/message-id/AI6AnABgKW93Qbx1jVzi84r9.8.1781322625756.Hmail.3020001251%40tju.edu.cn
Backpatch-through: 14 M contrib/ltree/expected/ltree.out
M contrib/ltree/ltree.h
M contrib/ltree/ltree_gist.c
M contrib/ltree/ltree_op.c
M contrib/ltree/sql/ltree.sql
Reject oversized MCV lists in pg_restore_extended_stats()
commit : f6e4ec0a705b180f29e4910dd5297b815a260eec
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 14:47:20 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 14:47:20 +0900 import_mcv(), called by pg_restore_extended_stats(), allowed a list of
MCV items to be larger than the maximum supported when the stats are
loaded back in statext_mcv_deserialize() (STATS_MCVLIST_MAX_ITEMS or 10k
items). A follow-up attempt at loading them would cause a failure,
statext_mcv_deserialize() blocking any attempts.
Attempts at restoring MCV lists too long are now rejected, generating a
WARNING like other inconsistent inputs.
Author: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/CAON2xHORd2ESXm1KcVeeZ0Kd_aJk4dL4M2WLtzVDM4puaZ-20w@mail.gmail.com 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 various query jumble comments
commit : e5f94c4808fe88c170840ac3a24cdfa423b404fc
author : David Rowley <drowley@postgresql.org>
date : Tue, 16 Jun 2026 13:42:21 +1200
committer: David Rowley <drowley@postgresql.org>
date : Tue, 16 Jun 2026 13:42:21 +1200 Some comments for struct WindowFunc were trying to detail which fields
were irrelevant for query jumble but the list had not been kept
up-to-date. Here we fix that by removing the comment to allow the
"query_jumble_ignore" attribute to self-document. This involved
removing similar comments from other structs.
While we're on the topic, improve comments around why Consts only jumble
the "consttype" and also add some rationale about why various other fields
are ignored.
Reported-by: jian he <jian.universality@gmail.com>
Author: David Rowley <dgrowleyml@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CACJufxEWeP2SLVMsbFNynd0pQnwbxh6U-v1nq5ccf9mSvBZntw%40mail.gmail.com M src/include/nodes/nodes.h
M src/include/nodes/parsenodes.h
M src/include/nodes/primnodes.h
pg_dump: Remove dead code in TAP tests
commit : d3b345eef3f3a08da724aa5681e3dbe6fbb1d91a
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 08:31:39 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 08:31:39 +0900 The schema_only_with_statistics test scenario was referenced in
002_pg_dump.pl, but was associated to no command sequence since
0ed92cf50cc4.
Issue discovered while investigating a different bug. Perhaps this
cleanup is not worth backpatching, but there is also an argument in
favor of reducing noise when touching this area of the code in stable
branches.
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/ai-y0S7Z25NlrG_n@paquier.xyz
Backpatch-through: 18 M src/bin/pg_dump/t/002_pg_dump.pl
Fix inconsistencies with pg_restore --statistics[-only]
commit : 0dd93de69e80ce98eb23f86d163bea8b0787643e
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 08:21:08 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 16 Jun 2026 08:21:08 +0900 Attempting to restore a schema, a table or an index with
--only-statistics skipped all the statistics of the objects wanted.
Like for pg_dump, statistics should be included, so this created an
assymetry between dump and restore.
A second set of problems existed for --table and --index, where the
presence of --statistics skipped the restore of the stats of the
object(s) targetted.
This issue has been reported originally as related to an inconsistency
with the way extended stats restore is handled in Postgres v19, but the
issue is related to the restore of relation and attribute statistics in
v18. Some TAP tests are added to cover all these cases.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Author: Chao Li <li.evan.chao@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/66E80CAB-527C-42B1-BB65-3F82CF4AD998@gmail.com
Backpatch-through: 18 M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/t/002_pg_dump.pl
Clean up quoting of variable strings within replication commands.
commit : a75bd485b5ea7a8c9bd00e18aef0f7b0b71236e7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 15 Jun 2026 15:35:37 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 15 Jun 2026 15:35:37 -0400 Our handling of quoting within replication commands was pretty
sloppy, typically looking like
appendStringInfo(&cmd, " SLOT \"%s\"", options->slotname);
This is fine as long as options->slotname doesn't contain a double
quote mark, but what if it does? In principle this'd allow injection
of harmful options into replication commands, in the probably-unlikely
case that a slot name comes from untrustworthy input. We ought to
clean that up.
Moreover, even the places that were trying to be more careful
generally got it wrong, because they used quoting subroutines
intended for SQL commands rather than something that will work
with the replication-command scanner repl_scanner.l. For example,
several places naively use PQescapeLiteral() to quote option values
for replication commands. If the string contains a backslash,
PQescapeLiteral() will produce E'...' literal syntax, which
repl_scanner.l doesn't recognize. Another near miss was to use
quote_identifier() to quote identifiers. That function won't quote
valid lowercase identifiers unless they match SQL keywords ... but in
this context, replication keywords are what matter. Neither of these
errors seem to risk string injection, but they definitely can cause
syntax errors in replication commands that ought to be valid.
We can clean all this up by using simple quoting logic that just
doubles single or double quotes respectively.
Or at least, we could if repl_scanner.l handled doubled double quotes
in identifiers, but for some reason it doesn't! So the first step in
this fix has to be to fix that. (The fact that we'll later reject
slot names containing double quotes is very far short of justifying
this omission.)
Having done that, this patch runs around and applies correct
quoting in all places that generate replication commands containing
strings coming from outside the immediate context. Probably some
of these places are safe because of restrictions elsewhere, but it
seems best to just quote all the time.
This was originally reported as a security bug, which it could be
if replication slot names or parameters were to originate from
untrustworthy sources. But the security team concluded that that
was a very improbable situation, so we're just going to fix this
as a regular bug.
Reported-by: Team Dhiutsa
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/1648659.1781287310@sss.pgh.pa.us
Backpatch-through: 14 M src/backend/commands/subscriptioncmds.c
M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/backend/replication/repl_scanner.l
M src/bin/pg_basebackup/pg_recvlogical.c
M src/bin/pg_basebackup/receivelog.c
M src/bin/pg_basebackup/streamutil.c
M src/bin/pg_basebackup/streamutil.h
doc: Fix "Prev" link.
commit : 6678b58d7810b7471f00af66423aecb08f87a32a
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 15 Jun 2026 12:16:38 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 15 Jun 2026 12:16:38 -0500 Presently, the "Prev" link on the page for background workers sends
you to the middle of the previous chapter instead of the actual
previous page. This appears to be caused by a libxml2 bug, but
regardless, a minimal fix is to change the link generation code to
use [position()=last()] instead of [last()] in the predicate on the
union of reverse axes.
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/aim4AZorFKaC7Wrf%40nathan
Backpatch-through: 14 M doc/src/sgml/stylesheet-speedup-xhtml.xsl
Doc: reword discussion of asterisk after table names in FROM.
commit : 8ebbf79a83e4fe87285243dde03b969b81f3439a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 15 Jun 2026 13:07:57 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 15 Jun 2026 13:07:57 -0400 The syntax "tablename *" has been obsolete for years, but we want to
retain it and its documentation for backward compatibility reasons.
However, the documentation wording was confusing and could be
understood to mean that "tablename *" is the same as "ONLY tablename".
Reported-by: Jochen Bandhauer <jochen.bandhauer@gmx.net>
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/178125831604.1285960.8250607197280951685@wrigleys.postgresql.org M doc/src/sgml/queries.sgml
Modernize pg_bsd_indent's error/warning reporting code.
commit : ca6969629d8526706ba0368b0063ddca86ed1f3e
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 15 Jun 2026 12:22:55 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 15 Jun 2026 12:22:55 -0400 Late-model clang complains that these functions should be labeled
with "format(printf, 2, 3)", and it's right. But let's go a bit
further and also make use of varargs, to remove duplication and
allow these functions to be used with non-integer input values.
Since no good deed goes unpunished, I had to also adjust a couple
of call sites. They weren't wrong as-is, since the size_t-sized
arguments were coerced to int on the way into diag3(). But
without that, we have to adjust the format strings.
The point of this is to suppress compiler warnings, so back-patch
into branches containing pg_bsd_indent, even though there's no
functional change.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/1645041.1781283554@sss.pgh.pa.us
Backpatch-through: 16 M src/tools/pg_bsd_indent/indent.c
M src/tools/pg_bsd_indent/indent.h
M src/tools/pg_bsd_indent/io.c
Fix PQdescribePrepared with more than 7498 params
commit : e0511883cae27ec70834c52bbde1863aa11d81e1
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 15 Jun 2026 11:28:45 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 15 Jun 2026 11:28:45 +0300 If a query has more than 7498 params, the ParameterDescription message
exceeds the 30000 byte limit on messages that are not specifically
marked as possibly being longer than that (VALID_LONG_MESSAGE_TYPE).
To fix, add ParameterDescription to the list.
Author: Ning Sun <classicning@gmail.com>
Discussion: https://www.postgresql.org/message-id/dbfb4b65-0aa8-470a-8b87-b6496160b28a@gmail.com
Backpatch-through: 14 M src/interfaces/libpq/fe-protocol3.c
Trim regression test expected output for xml
commit : b78cd2bda5b1a306e2877059011933de1d0fb735
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 15 Jun 2026 11:37:52 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 15 Jun 2026 11:37:52 +0900 This commit reduces the number of expected output files for the "xml"
test from three to two (well, mostly one, see below for details).
xml_2.out existed to handle some differences in output due to libxml2
2.9.3, due to some error context missing (085423e3e326). This file is
removed, by tweaking the XML inputs to trigger the same error patterns
for the problematic 2.9.3 and other libxml2 versions. This part is
authored by Tom Lane.
xml_1.out (no libxml2 support) is reduced in size by adding an \if query
that exits the test early. This still checks NO_XML_SUPPORT() through
xmlin(). The rest of the test is skipped if XML input cannot be
handled by the backend. This part has been written by me.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/aiu6CXO67q-s70n5@paquier.xyz
Backpatch-through: 14 M src/test/regress/expected/xml.out
M src/test/regress/expected/xml_1.out
D src/test/regress/expected/xml_2.out
M src/test/regress/sql/xml.sql
Doc: remove stale entry for removed aclitem[] ~ aclitem operator.
commit : 2963ddeef2be6d6e064cb9d382f67dcbf2c049a8
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 14 Jun 2026 11:01:48 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 14 Jun 2026 11:01:48 -0400 Commit 2f70fdb06 removed the deprecated containment operator
~(aclitem[],aclitem) from the catalogs, but missed removing its entry
from the documentation. (Arguably the blame should fall on c62dd80cd,
which added this entry in contravention of the longstanding policy
that we don't document deprecated aliases in the first place.)
Author: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAOzEurQSyR5psWukyhUz1LtxyO55C2Vfp0Fmt8w2jGKxhszQmQ@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/func/func-info.sgml
Fix oversight in commit aa1f93a33.
commit : 0131e8fc508ff8e10a6797bfe8043a0b9d34b30b
author : Etsuro Fujita <efujita@postgresql.org>
date : Sun, 14 Jun 2026 16:00:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Sun, 14 Jun 2026 16:00:00 +0900 Since the remote column names of a foreign table could be longer than
NAMEDATALEN, remattrmap_cmp(), which compares such column names, should
have used strcmp(), not strncmp() with n=NAMEDATALEN.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/81D981EB-ECC1-495D-8EAC-5CFB67B2CF77%40gmail.com M contrib/postgres_fdw/postgres_fdw.c
amcheck: Use correct varlena size accessor in bt_normalize_tuple()
commit : da1eff08a5bedc4bea9f75c8412d877c5619afc0
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 14 Jun 2026 02:49:05 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 14 Jun 2026 02:49:05 +0300 bt_normalize_tuple() uses VARSIZE() to get the size of varlena, even though
it's not yet known, that it has a 4-byte header. Fix this by replacing a
accessor with a universal VARSIZE_ANY().
Backpatch to all supported versions.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/7ckc7oka4bvafkf5bwlqs6ygrhlsbhz25ppozfch7zbuxcx3rf%40e4pr4oqenalc
Author: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Backpatch-through: 14 M contrib/amcheck/verify_nbtree.c
Adjust cross-version upgrade tests for seg_out() fix
commit : 3e3d7875e95621b02311ea3443e5139e3bce944a
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 12 Jun 2026 18:05:25 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 12 Jun 2026 18:05:25 -0400 Commit 0e1f1ed157e taught seg_out() to print the certainty indicator
on an interval's upper boundary, but it was back-patched only as far
as v14. When upgrading from an older release, the old server prints
the one test_seg row exercising that case ('4.6 .. ~7.0') without the
indicator, so the pre- and post-upgrade dumps do not match. Make
AdjustUpgrade.pm delete just that row; seg's comparison function does
distinguish the certainty indicators, so the otherwise identical row
'4.6 .. 7.0' is unaffected.
Back-patch to all supported branches.
Per buildfarm members crake and fairywren.
Discussion: https://postgr.es/m/5ccbdbde-6467-4a10-bf4d-0be73a05ce8d@dunslane.net M src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
Fix translatable string construction in psql
commit : 5459223edb1d08d31711c55f7be9aa6a5710f762
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 12 Jun 2026 14:24:41 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 12 Jun 2026 14:24:41 +0200 Similar to commit 3692a622d3fd, for a slightly different code pattern in
psql.
No backpatch to avoid disrupting translation in stable branches.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/airjxKXx7aTG8kfE@alvherre.pgsql M src/bin/psql/describe.c
Update expected regression test output for xml_2.out
commit : 0b74df66f08f474aa2225553b8d38704ae844797
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 12 Jun 2026 12:37:21 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 12 Jun 2026 12:37:21 +0900 This one has been forgotten in 8bf257aebac1. Per report from buildfarm
member massasauga.
Backpatch-through: 14 M src/test/regress/expected/xml_2.out
Fix second race with timeline selection during promotion
commit : a8ee70bd5e0069c5550b0b0c5418638507fa0ed7
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 12 Jun 2026 11:44:11 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 12 Jun 2026 11:44:11 +0900 read_local_xlog_page_guts has the same race as logical_read_xlog_page:
RecoveryInProgress() can return true during promotion, impacting the
availability of the operations doing WAL page reads with this callback.
This problem is similar to eb4e7224a1c6 that has addressed the issue for
logical replication, impacting more areas of the code where this WAL
page callback can be used (same narrow window during promotion, same
availability issue):
- pg_walinspect.
- Slot advance (SQL function).
- Slot creation.
Repack workers (v19~) and 2PC files (since forever) can also use this
callback, but they are irrelevant as far as I know. A test is added
with the SQL lookup functions. This part relies on injection points,
and is backpatched down to v18, like the test added for eb4e7224a1c6.
This issue could probably be fixed as well in v14 and v15 for
pg_walinspect. However, I also feel that there is a conservative
argument about consistency here due to the support of logical decoding
on standbys, so let's limit ourselves to v16 for now. pg_walinspect is
used less in the field compared to the two other operations, making
addressing this problem less attractive in these two older branches.
Reported-by: Xuneng Zhou <xunengzhou@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3%40gmail.com
Backpatch-through: 16 M src/backend/access/transam/xlogutils.c
M src/test/recovery/t/035_standby_logical_decoding.pl
Confine RI fast-path batching to the top transaction level
commit : 4113873a5ab0fb83a6f772f455b2842359d5ec50
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 12 Jun 2026 11:05:25 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 12 Jun 2026 11:05:25 +0900 The FK fast-path batching added in b7b27eb41a5 buffers rows in a
transaction-lived cache (ri_fastpath_cache) keyed by constraint OID.
Running user-defined cast and equality functions during a batch flush,
together with the cache's lifetime and iteration, exposed two defects
reachable by an unprivileged table owner.
First, on subtransaction abort ri_FastPathSubXactCallback discarded the
entire cache. An entry's batch holds rows buffered by the enclosing
transaction, not just the aborting subxact -- the cache is keyed by
constraint, so a single entry can mix rows from multiple subxact levels.
An internal subxact abort during after-trigger firing (e.g. a PL/pgSQL
BEGIN ... EXCEPTION block) therefore dropped buffered rows of the outer
transaction without running their FK checks, letting orphan rows commit
behind a constraint that still reported itself valid. The discard also
left relations opened by the batch unclosed, producing "resource was not
closed" warnings.
Second, ri_FastPathEndBatch flushes by iterating the cache with
hash_seq_search. If flush-time user code inserts into a different
fast-path FK table, a new entry is added to the cache mid-scan; it may
land in a bucket the scan has already passed and never be reached, and
ri_FastPathTeardown then destroys the cache without flushing it,
silently dropping that check.
Cleanly unwinding the cache on subxact abort would require tracking the
originating subxact of each buffered row, since rows from different
levels share an entry (the cache is keyed by constraint) and deferred
constraints cannot be flushed early at a subxact boundary. Rather than
add that bookkeeping, confine batching to the top transaction level: in
RI_FKey_check, when GetCurrentTransactionNestLevel() > 1, use the
per-row fast path (ri_FastPathCheck) instead of buffering. Rows checked
inside a subtransaction are then verified immediately and roll back
cleanly with their subtransaction, and the cache only ever holds
top-level rows. With the cache confined to the top level, a
subtransaction abort has nothing of its own to discard, so
ri_FastPathSubXactCallback is removed along with its registration.
For the second defect, add a cache-wide flag (ri_fastpath_flushing) set
while ri_FastPathEndBatch iterates the cache. A re-entrant FK check
arriving while the flag is set takes the per-row path rather than adding
an entry to the cache being scanned, so no entry can be missed and torn
down unflushed. The flag is cleared in a PG_FINALLY so a flush that
throws (a reported violation or an error from user code) does not leave
it stuck. As defensive insurance it is also cleared in
ri_FastPathXactCallback() at transaction end.
The per-row fast path still bypasses SPI and stays well ahead of the
pre-19 SPI-based check. A fuller fix that preserves batching across
subtransactions -- whether by tracking the originating subxact of each
buffered row or by per-subxact cache stacks merged into the parent on
commit -- is left for a future release.
The subtransaction-abort case is covered by a new regression test. The
mid-scan cross-table case depends on hash bucket placement and so is not
reliably reproducible in a portable test, but the flag prevents it by
construction.
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>
Reviewed-by: Nikolay Samokhvalov <nik@postgres.ai>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CAM527d9exRCdWrhJOnAxk_vACg7sr_yPoaJp_+uCFY0qP8v=aw@mail.gmail.com M src/backend/utils/adt/ri_triggers.c
M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql
doc: fix reference for finding replication slots to drop
commit : 67bd944c0e61baf01eae61fcf54cc96011455ebb
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 12 Jun 2026 11:08:33 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 12 Jun 2026 11:08:33 +0900 Commit a70bce43fb added instructions on how to recover if PostgreSQL
refuses to issue new transaction IDs because of imminent wraparound,
but when describing how to find replication slots that should be dropped,
it referred to pg_stat_replication where it should have referenced
pg_replication_slots.
In passing, decorate references to views with <structname> tags.
Backpatch to all supported versions.
Reported-By: Sanjaya Waruna <sanjaya.waruna@gmail.com>
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/176767268098.1084085.10345048667224193115@wrigleys.postgresql.org
Backpatch-through: 14 M doc/src/sgml/maintenance.sgml
Fix out-of-bounds write in RI fast-path batch on re-entry
commit : 0e47bb5fbeec64d776d49dee242bac39d4616f8b
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 12 Jun 2026 10:36:45 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 12 Jun 2026 10:36:45 +0900 The FK fast-path batching added in b7b27eb41a5 wrote the incoming row
into the batch array before checking whether the array was full:
fpentry->batch[fpentry->batch_count] = ExecCopySlotHeapTuple(newslot);
fpentry->batch_count++;
if (fpentry->batch_count >= RI_FASTPATH_BATCH_SIZE)
ri_FastPathBatchFlush(fpentry, fk_rel, riinfo);
batch_count is reset to zero only at the end of ri_FastPathBatchFlush(),
so it remains at RI_FASTPATH_BATCH_SIZE throughout a full-batch flush.
A flush runs user-defined cast functions and equality operators; if that
user code performs DML on the same FK table, ri_FastPathBatchAdd()
re-enters with batch_count == RI_FASTPATH_BATCH_SIZE and writes one past
the end of the array, corrupting the adjacent batch_count field. This
is reachable by an unprivileged table owner via an implicit cast with a
PL/pgSQL function and causes a SIGSEGV in assert-enabled builds.
Fix by bounds-checking the write into the batch array so a re-entrant
add can never write past the end, and by adding a "flushing" flag to
RI_FastPathEntry that routes re-entrant ri_FastPathBatchAdd() calls on
a busy entry to the per-row path (ri_FastPathCheck) instead of touching
the mid-flush batch array. The flag is set around the probe in
ri_FastPathBatchFlush() and cleared in a PG_FINALLY, which also resets
batch_count, so the entry is left empty and reusable if a flush error
(including a reported FK violation) is caught by a savepoint.
Add regression tests for both the re-entrant flush and reuse of an entry
after a flush error caught by a savepoint.
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>
Reviewed-by: Nikolay Samokhvalov <nik@postgres.ai>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CAM527d9exRCdWrhJOnAxk_vACg7sr_yPoaJp_+uCFY0qP8v=aw@mail.gmail.com 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 handling of namespace nodes in xpath() (xml)
commit : 8bf257aebac12791dc78a599e4f7dc225893d45e
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 12 Jun 2026 10:25:45 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 12 Jun 2026 10:25:45 +0900 xpath() attempted to call xmlCopyNode() and xmlNodeDump() on a
XML_NAMESPACE_DECL, finishing with a confusing error:
=# SELECT xpath('//namespace::foo', '<root xmlns:foo="http://127.0.0.1"/>');
ERROR: 53200: could not copy node
CONTEXT: SQL function "xpath" statement 1
xpath() is changed so as it goes through xmlXPathCastNodeToString()
instead, that is able to handle namespace nodes. xml2 uses the same
solution. This issue has been discovered while digging into
9d33a5a804db.
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aioT7ui_ZJ9RMlfM@paquier.xyz
Backpatch-through: 14 M src/backend/utils/adt/xml.c
M src/test/regress/expected/xml.out
M src/test/regress/expected/xml_1.out
M src/test/regress/sql/xml.sql
amcheck: Fix missing allequalimage corruption report
commit : 389bd4c5b93426e6616a0be7cff9cf91179c16e7
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 12 Jun 2026 09:35:27 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 12 Jun 2026 09:35:27 +0900 When amcheck validates that a B-Tree metapage's allequalimage flag
matches _bt_allequalimage(), it could fail to report corruption
unless one of the index key columns used interval_ops. As a result,
pg_amcheck could silently miss this corruption on other opclasses,
incorrectly reporting the index as valid.
The mistake was that bt_index_check_callback() kept ereport(ERROR)
inside the loop that scans key attributes for INTERVAL_BTREE_FAM_OID,
even though that loop is only needed to decide whether to add
the interval-specific hint. This commit moves ereport() out of the loop
so allequalimage mismatches are always reported, while still emitting
the hint for affected interval indexes.
Back-patch to v18, where d70b17636dd introduced this regression
while moving the check into bt_index_check_callback().
Author: Chao Li <lic@highgo.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/011ACC9C-CB87-4160-ACE7-4ED57AB86E15@gmail.com
Backpatch-through: 18 M contrib/amcheck/verify_nbtree.c
Fix md5_password_warnings for role and database settings
commit : 44196fd4f378d776c4cd7282256f4d6df03b5734
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 12 Jun 2026 08:32:39 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 12 Jun 2026 08:32:39 +0900 MD5 authentication warnings are queued during authentication, before
startup options and role/database settings have been applied. The code
checked md5_password_warnings at queue time, so settings such as
ALTER ROLE ... SET md5_password_warnings = off did not suppress the
warning, even though the established session showed the GUC as off.
Keep the connection-warning infrastructure generic by allowing each
queued warning to carry an optional filter callback. Evaluate that
callback when warnings are emitted, after startup options and
role/database settings have been processed.
Use this for MD5 authentication warnings, while leaving password
expiration warnings unchanged. Add test coverage for an MD5-authenticated
role with md5_password_warnings disabled.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/AE46E42D-5966-4D76-9E64-95EAB01B9FB5@gmail.com M src/backend/libpq/crypt.c
M src/backend/utils/init/postinit.c
M src/include/miscadmin.h
M src/test/authentication/t/001_password.pl
M src/tools/pgindent/typedefs.list
Fix type confusion in AddRelsyncInvalidationMessage
commit : 99db753c656946bfd1d4ddd3978ebfcee6fb86c0
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 11 Jun 2026 15:55:44 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 11 Jun 2026 15:55:44 -0400 Since this is trying to add a SharedInvalRelSyncMsg rather than
a SharedInvalRelcacheMsg, it should use rs rather than rc.
This makes no difference as things stand, because the two structure
definitions are identical (except for the capitalization of "relid"),
but it's still a good idea to fix it.
Co-authored-by: Stolpovskikh Danil <d.stolpovskikh@ftdata.ru>
Co-authored-by: Robert Haas <rhaas@postgresql.org>
Discussion: http://postgr.es/m/bd6a5735b72b4afe99af49c3c62901d6@localhost.localdomain M src/backend/utils/cache/inval.c
Fix translatable string construction
commit : 3692a622d3fdf8a44af0c0b541a51163ead314f1
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 11 Jun 2026 18:29:36 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 11 Jun 2026 18:29:36 +0200 In a few places, we were constructing translatable strings consisting of
elements list by adding one element at a time and separately a comma.
This is not great from a translation point of view, so rewrite to append
the comma together with the corresponding element in one go.
Author: Peter Smith <smithpb2250@gmail.com>
Author: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAHut+Pvp7jYcaiZ3pXedXgLcWZWDBLXFUK05JtZpGv3Mj=UOjw@mail.gmail.com M src/backend/catalog/pg_subscription.c
M src/backend/commands/tablecmds.c
M src/backend/replication/logical/relation.c
IS JSON/JSON(): Protect against expressions uncoercible to text
commit : 7dd15325952fe85521b1fefea3ad39cf1b46e0c8
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 11 Jun 2026 16:17:58 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 11 Jun 2026 16:17:58 +0200 transformJsonParseArg() was not careful enough on generation of
transformed expressions when starting from expressions that are not
coercible to text but are in the string type category: it failed to
verify that coerce_to_target_type() succeeds, and returned a NULL
pointer. This leads to a later NULL dereference and crash at executor
time.
This escaped noticed because it cannot happen for built-in types, all of
which have casts to text. Only user-created types are potentially
problematic.
Fix by raising an error when a cast to text doesn't exist.
This mistake came in with commit 6ee30209a6f1.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reported-by: Chi Zhang <798604270@qq.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Backpatch-through: 16
Discussion: https://postgr.es/m/19491-7aafc221ec63f288@postgresql.org M src/backend/nodes/makefuncs.c
M src/backend/parser/parse_expr.c
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/sqljson.sql
Fix parsing of parenthesised OLD/NEW in RETURNING list.
commit : 79c65b9d97fe92ea2792be09479cf4bbea7cefe1
author : Dean Rasheed <dean.a.rasheed@gmail.com>
date : Thu, 11 Jun 2026 12:08:47 +0100
committer: Dean Rasheed <dean.a.rasheed@gmail.com>
date : Thu, 11 Jun 2026 12:08:47 +0100 When parsing expressions like (old).colname and (old).* in a RETURNING
list, the parser would lose track of the intended varreturningtype,
and therefore return incorrect results.
The root cause was code using GetNSItemByRangeTablePosn() to find a
namespace item from its rtindex and levelsup, without taking into
account returningtype, which would return the wrong namespace item.
Fix by adding a new function GetNSItemByVar() that does take
returningtype into account.
Backpatch to v18, where support for RETURNING OLD/NEW was added.
Bug: #19516
Reported-by: Marko Grujic <markoog@gmail.com>
Author: Marko Grujic <markoog@gmail.com>
Suggested-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAOvwyF2cO_5mAt=w=y-dFnaG5UkZ+3H8nSDoKF_iuWZHsU2ARg@mail.gmail.com
Backpatch-through: 18 M src/backend/parser/parse_coerce.c
M src/backend/parser/parse_func.c
M src/backend/parser/parse_relation.c
M src/backend/parser/parse_target.c
M src/include/parser/parse_relation.h
M src/test/regress/expected/returning.out
M src/test/regress/sql/returning.sql
seg: Fix seg_out() to preserve the upper boundary's certainty indicator
commit : 0e1f1ed157e90741e12a3715909e1b2d71ff9344
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 11 Jun 2026 12:33:48 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 11 Jun 2026 12:33:48 +0300 When printing the upper boundary of a seg interval, seg_out() decided
whether to emit the certainty indicator ('<', '>' or '~') by testing the
upper indicator (u_ext) for '<' and '>', but mistakenly tested the lower
indicator (l_ext) for '~'. This is a copy-and-paste slip from the
symmetric code that prints the lower boundary a few lines above.
The consequences for valid input were:
* A '~' on the upper boundary was dropped on output, e.g.
'1.5 .. ~2.5'::seg printed as '1.5 .. 2.5'.
* When the lower boundary carried '~' but the upper boundary had no
indicator, the wrong test matched and sprintf(p, "%c", seg->u_ext)
wrote a NUL byte (u_ext == '\0'), which truncated the result string
and silently lost the entire upper boundary, e.g.
'~6.5 .. 8.5'::seg printed as '~6.5 .. '.
Certainty indicators are documented to be preserved on output (they are
ignored by the operators, but kept as comments), so this broke the
input/output round-trip for the affected values.
The bug has existed since seg was added. It went unnoticed because the
existing regression tests only exercised certainty indicators on
single-point segs, which are printed by a different branch of seg_out().
Add tests that place indicators on both boundaries of an interval.
Author: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAON2xHPYeRRCEVAv8XfE18KsEsEHCiYcJ5fOsoxFuMEfpxF1=g@mail.gmail.com
Backpatch-through: 14 M contrib/seg/expected/seg.out
M contrib/seg/seg.c
M contrib/seg/sql/seg.sql
Fix race with timeline selection in logical decoding during promotion
commit : eb4e7224a1c6f0058d708cdfda7326bbf884a871
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 11 Jun 2026 17:28:57 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 11 Jun 2026 17:28:57 +0900 During promotion, there is a window where RecoveryInProgress() returns
true but the WAL segments of the old timeline have already been removed.
A logical decoding could pick up the old timeline in this window when
reading a page, failing with the following error:
ERROR: requested WAL segment ... has already been removed
This issue does not lead to any data correctness issue, as retrying to
decode the data works in follow-up decoding attempts. It impacts
availability, though. Other WAL page read callbacks have a similar
issue, this commit takes care of what should be the noisiest code path:
logical decoding with START_REPLICATION in a WAL sender.
A TAP test, based on an injection point waiting in the startup process
after the segments have been removed/recycled, is added. This part is
backpatched down to v17.
This issue has been causing sporadic failures in the buildfarm, and
was reproducible manually. This issue happens since logical decoding on
standbys exists, down to v16.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3@gmail.com
Backpatch-through: 16 M src/backend/access/transam/xlog.c
M src/backend/replication/walsender.c
M src/test/recovery/t/035_standby_logical_decoding.pl
Disallow negative values for max_retention_duration.
commit : 987440b33a511482232c59a190cc16ae4feff9aa
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 11 Jun 2026 11:17:54 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 11 Jun 2026 11:17:54 +0530 The subscription option max_retention_duration accepts an integer value
representing a timeout in milliseconds, where zero means unlimited
retention (no timeout). Negative values have no useful meaning, but were
silently accepted and stored in the subscription catalog.
A negative value causes should_stop_conflict_info_retention() to always
return true, because TimestampDifferenceExceeds() treats a negative
threshold as already exceeded. This stops dead tuple retention
immediately rather than honoring the configured timeout.
Fix by rejecting negative values for max_retention_duration during CREATE
SUBSCRIPTION and ALTER SUBSCRIPTION.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/9232401A-DEEE-49E1-9D11-D14A776DB82B@gmail.com M src/backend/commands/subscriptioncmds.c
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql
xml2: Fix crash with namespace nodes in xpath_nodeset()
commit : 9d33a5a804db48b254de7a0ad2fde03152f378e3
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 11 Jun 2026 14:29:18 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 11 Jun 2026 14:29:18 +0900 pgxmlNodeSetToText() passed nodeTab[i]->doc to xmlNodeDump() without
checking the node type, which could cause a crash as a
XML_NAMESPACE_DECL maps to a xmlNs struct. The passed-in code would
then be dereferenced in xmlNodeDump().
This commit switches the code to render XML_NAMESPACE_DECL nodes with
xmlXPathCastNodeToString(), like xpath_table(). Some tests are added,
written by me.
Author: Andrey Chernyy <andrey.cherny@tantorlabs.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20260611031436.5afde3cb@andrnote
Backpatch-through: 14 M contrib/xml2/expected/xml2.out
M contrib/xml2/expected/xml2_1.out
M contrib/xml2/sql/xml2.sql
M contrib/xml2/xpath.c
Undo thinko in commit e78d1d6d4.
commit : 9d141466ff087230571e9c9dfd720deb94977253
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 10 Jun 2026 17:01:45 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 10 Jun 2026 17:01:45 -0400 In pursuit of removing a Valgrind-detected leak, I inserted
"pfree(pq_mq_handle);" into mq_putmessage's recursion-trouble-recovery
code path, failing to notice that shm_mq_detach would have pfree'd
that block just before (i.e., this particular code path did not leak).
So now that was a double pfree. We didn't notice because the
recursion scenario isn't exercised in our regression tests, but
Alexander Lakhin found it via code fuzzing.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/b8b40954-e155-41b3-9af8-ad4f261a1b64@gmail.com M src/backend/libpq/pqmq.c
Fix MarkBufferDirtyHint() to not call GetBufferDescriptor() for local buffers
commit : e18b0cb7344cb4bd28468f6c0aeeb9b9241d30aa
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 10 Jun 2026 13:49:26 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 10 Jun 2026 13:49:26 +0900 GetBufferDescriptor() was called before checking if the buffer is local.
Such buffers have a negative ID, meaning that we could call
GetBufferDescriptor() with a wrapped-around uint32 value causing a
potential out-of-bound access to the BufferDescriptors array.
This is harmless in the existing code for the current uses of
MarkBufferDirtyHint(), but the author has found a way to make that
buggy while working on a different patch set, and the order of the
operations is wrong.
Oversight in 82467f627bd4. No backpatch is required, as this is new to
v19.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/CAExHW5uzRMYVZsXXS3HXXT0fG_sNrpUhUqwP4NorhaCqH9JDhA@mail.gmail.com M src/backend/storage/buffer/bufmgr.c
pg_buffercache: restore rowtype verification in pg_buffercache_pages()
commit : b70d5672d0c5d4310965fcbc1c846c9d111a3046
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 10 Jun 2026 12:32:59 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 10 Jun 2026 12:32:59 +0900 Commit 257c8231bf9 changed pg_buffercache_pages() to materialize its output
directly into a tuplestore. As a result, the function ended up trusting
a caller-supplied RECORD descriptors. That could lead to crashes
if the supplied row definition did not match the actual returned values,
for example by passing bool Datums to tuplestore_putvalues() with
an incompatible descriptor.
Fix this by constructing the correct tuple descriptor for
pg_buffercache_pages() and assigning it to
rsinfo->setDesc after InitMaterializedSRF(). This restores the executor's
tupledesc_match() verification, so incompatible caller-supplied
row definitions are rejected with an error, as before commit 257c8231bf9.
Bug: #19508
Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Discussion: https://postgr.es/m/19508-e5f188183279219b@postgresql.org M contrib/pg_buffercache/expected/pg_buffercache.out
M contrib/pg_buffercache/pg_buffercache_pages.c
M contrib/pg_buffercache/sql/pg_buffercache.sql
psql: Add some missing schema qualifications in describe.c
commit : bf5206f007732c64f857e6bc214f77b5f31efc6a
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 10 Jun 2026 10:56:23 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 10 Jun 2026 10:56:23 +0900 These schema qualifications have been missed by 2f094e7a (recent),
8185bb53 (recent) and 923def9a533a (much older, down to v15).
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Tingchuan Sun <suntingchuan1996@163.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/C809E3C7-2437-486E-B626-0BE5F40BBB6C@gmail.com M src/bin/psql/describe.c
Fix race when logical decoding activation is concurrently interrupted.
commit : 93a3e6839bf8d2e0498291335191b57ddf458b48
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 9 Jun 2026 11:19:27 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 9 Jun 2026 11:19:27 -0700 EnableLogicalDecoding() sets xlog_logical_info to true, emits a
procsignal barrier, sets logical_decoding_enabled to true, and then
writes a WAL record. If the activating backend is interrupted between
these steps, a PG_ENSURE_ERROR_CLEANUP() callback runs to undo the
partial activation.
The previous callback asserted that logical_decoding_enabled was still
false and then cleared xlog_logical_info. Both actions were unsafe
when a second backend was concurrently activating: the peer backend
might have already observed xlog_logical_info as true, set
logical_decoding_enabled to true, and written the activation WAL
record before our callback fired, causing the first backend to hit the
assertion failure.
Fix this by having the abort callback call
RequestDisableLogicalDecoding(), allowing the checkpointer to undo the
partial activation in the same manner as a normal deactivation. This
simplifies the logic by unifying the activation abort and deactivation
paths. While this approach now wakes up the checkpointer when an
activation is interrupted, this should not be a serious issue in
practice since such interruptions are rare.
Add a test case to 051_effective_wal_level.pl.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/788B5B8A-BC22-48D8-818E-7B00416CF84E@gmail.com M src/backend/replication/logical/logicalctl.c
M src/test/recovery/t/051_effective_wal_level.pl
Disallow direct use of the pgrepack logical decoding plugin
commit : cd7b204b2df99516a48a738e662d8512e706b519
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 9 Jun 2026 20:12:55 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 9 Jun 2026 20:12:55 +0200 Nothing is to be gained from using pgrepack outside of REPACK
(CONCURRENTLY), and it leads to assertion failures in assertion-enabled
builds, and to crashes due to bogus memory lifetime in production
builds. Reject attempts to do that with a clean error report.
Clean up the nearby code a tad while at it. The only functional changes
in that are that the output_writer_private context is allocated and
partially filled by the pgrepack output plugin; and that ->relid therein
is now always present (rather than only in assertion-enabled builds).
Other than that it's just minor code rearrangement and added comments.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>
Suggested-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Antonin Houska <ah@cybertec.at> (older version)
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com> (older version)
Discussion: https://postgr.es/m/19500-38a02529a69353a5@postgresql.org M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M src/backend/commands/repack_worker.c
M src/backend/replication/pgrepack/pgrepack.c
M src/include/commands/repack_internal.h
Record dependencies on graph labels and properties
commit : 9d8cdcbe0c8aee743e29079bdb2e4b5eeae4c70e
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 9 Jun 2026 12:55:47 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 9 Jun 2026 12:55:47 +0200 A view definition with GRAPH_TABLE depends upon the property graph it
references as well as the properties and labels referenced in it. We
recorded the dependency on the property graph, but did not record
dependency on labels and properties. This allowed properties or
labels referenced by a view to be dropped, resulting in a cache lookup
error when such a view was accessed. Fix this bug by handling
GraphPropertyRef and GraphLabelRef in find_expr_references_walker().
The dependency on the data type of property does not need to be
recorded separately as it is recorded indirectly via a dependency on
the property graph property itself.
Note that a property or a label associated with individual elements
can still be dropped as long as there are other elements that are
associated with that property or label, since they do not lead to
dropping the property or the label from the property graph altogether.
Reported-by: Man Zeng <zengman@halodbtech.com>
Author: Ayush Tiwari <ayushtiwari.slg01@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/tencent_43D9888041FA4FDE498C7BF1%40qq.com M src/backend/catalog/dependency.c
M src/include/catalog/catversion.h
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Use correct type for catalog_xmin
commit : bd4bd30ce6a7f08e95390c3fa068f2bfbe9fcee8
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 9 Jun 2026 08:18:41 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 9 Jun 2026 08:18:41 +0900 Commit 85c17f6 mistakenly declared a variable storing catalog_xmin as
XLogRecPtr, even though catalog_xmin is a TransactionId.
This caused no functional issue, but the type was clearly incorrect.
Therefore, this commit fixes it to use the correct type TransactionId
instead, and backpatch to v17 where the issue was introduced.
Author: Imran Zaheer <imran.zhir@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CA+UBfa=mNeLt-4BFjEP4tqdDsnq+oMqqPr7fd9Wji2_9YXmQdA@mail.gmail.com M src/backend/replication/logical/slotsync.c
Guard against uninitialized default locale.
commit : 1c77203c15e43d4ae9a8fed67ce89eeeca54af8f
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 8 Jun 2026 13:10:40 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 8 Jun 2026 13:10:40 -0700 No known problem today, but defend against issues like dbf217c1c7 in
the future.
Discussion: https://postgr.es/m/d080287d8d2d14c246c86be2e9eb611fb6b27b11.camel@j-davis.com
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Backpatch-through: 17 M src/backend/utils/adt/pg_locale.c
ci: Improve ccache handling
commit : f52c44ce48a61dd99d8ea545a57da95e62b084e4
author : Andres Freund <andres@anarazel.de>
date : Mon, 8 Jun 2026 15:26:47 -0400
committer: Andres Freund <andres@anarazel.de>
date : Mon, 8 Jun 2026 15:26:47 -0400 There previously were a number of issues:
- We'd upload the cache even if we already had a high hit rate. That means we
churn through the available cache space very quickly.
For this we now check if the cache hit ratio is already high, and skip
uploading a new cache in that case.
- We'd generate per-branch caches, even if master's already would suffice,
because the branch doesn't change much
This is solved indirectly by the above.
- The cache key allowed prefix matches based on the branch,
e.g. master-pending would always use master's branch
Replace the cache key element separator of - with :, which is not a valid
part of a branch name.
- When rebasing a feature branch, we'd start with just that branch's cache,
rather than also having the newer cache of master available
This is solved by downloading by master's and the feature branch's cache,
simply overlaying both. That's possible because ccache is content addressed.
- The size of a cache would increase to the max, even though there likely will
be no benefit from old cache entries.
Address this by explicitly evicting old data and also recompressing the
cache before uploading it.
In my testing this utilizes the available cache space (10GB for personal
accounts) much more effectively than before.
The not entirely trivial determination of whether it's worth uploading a cache
entry is moved to a python script. I first had it as shell, but that gets
awkward. This way it'd also be more viable to use ccache for msvc at some
point.
The per-job redundancies are a bit annoying. There's a way around that, by
using composite actions, but I think that might be harder to understand,
without all that much of an improvement.
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/7eugqon2ilnaq6yimtq7prtl5wlia43mhpmwlydzlw4u4wonaz@hh2fagz5bjuu M .github/workflows/pg-ci.yml
A src/tools/ci/gha_ccache_decide.py
Remove inappropriate translation marker in getObjectIdentityParts().
commit : 4b1e18b0573b6630feb3d794930be1005016077d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 8 Jun 2026 15:23:48 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 8 Jun 2026 15:23:48 -0400 Strings built by this function are not supposed to be subject to
NLS translation, but commit 6566133c5 missed that memo, so that
object identities like "membership of role %s in role %s" were
translated. M src/backend/catalog/objectaddress.c
dict_synonym.c: remove incorrect outlen.
commit : 9234e333711ef9875a4cef31889e88439421c396
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 8 Jun 2026 11:47:53 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 8 Jun 2026 11:47:53 -0700 Previously, outlen was miscalculated if case_sensitive was false and
str_tolower() changed the byte length of the string. If outlen was too
large, pnstrdup() would stop at the NUL terminator, preventing
overrun. But if outlen was too small, it would cause truncation.
Fix by just removing outlen. It was only used in a single site, which
could just as well use pstrdup().
Discussion: https://postgre.es/m/1101e1a3afbbabb503317069c40374b82e6f4cac.camel@j-davis.com
Reviewed-by: Tristan Partin <tristan@partin.io>
Backpatch-through: 14 M src/backend/tsearch/dict_synonym.c
Revert "Enable fast default for domains with non-volatile constraints"
commit : a0354e29c41a9fb7491b3c7c23f079b1923c045a
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 8 Jun 2026 13:42:50 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 8 Jun 2026 13:42:50 -0400 This reverts commit a0b6ef29a51818a4073a5f390ed10ef6453d5c11, along with
its follow-up 2e123e3c2bd34f2377212a4e7cfcdbf9e2d9c7ff ("Silence compiler
warning from older compilers"), which only adjusted code introduced by
the former.
The change failed with an empty table and an invalid default, and the
best way to deal with that will involve an addition to the TAM API, so
it's not ready for relese 19 now.
Discussion: https://postgr.es/m/7033D663-DDB4-4B35-922C-F33DE53B1502@gmail.com M src/backend/commands/tablecmds.c
M src/backend/executor/execExpr.c
M src/include/executor/executor.h
M src/test/regress/expected/fast_default.out
M src/test/regress/sql/fast_default.sql
Fix syslogger NULL-pointer-dereference in EXEC_BACKEND
commit : fb23cc7e81db181bfb3dcfed6ad0731a3473d4e1
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 8 Jun 2026 19:49:54 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 8 Jun 2026 19:49:54 +0200 Commit 0c8e082fba8d changed the time at which MyBackendType is assigned,
breaking a careful choreography in syslogger to decide when to write
messages to its own log files. Fix by flipping a boolean at the
(approximate) location where previously MyBackendType was set, instead
of depending on MyBackendType directly.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/ahP-JT4ZRPyobnLb@paquier.xyz M src/backend/postmaster/syslogger.c
M src/backend/utils/error/csvlog.c
M src/backend/utils/error/elog.c
M src/backend/utils/error/jsonlog.c
M src/include/postmaster/syslogger.h
Fix FOR PORTION OF for inheritance children
commit : 7d13b03a2e677b78047cf537e519166dcbafa117
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 8 Jun 2026 19:18:58 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 8 Jun 2026 19:18:58 +0200 ExecForPortionOfLeftovers() assumed that any result relation with
ri_RootResultRelInfo should reinsert temporal leftovers through the
root relation. That is correct for partitioned tables, where tuple
routing is needed, but it is wrong for plain inheritance.
When UPDATE/DELETE FOR PORTION OF is run on an inheritance parent and
a child row is split, the leftover rows must be inserted back into the
child relation. Reinserting through the parent can lose child-only
columns and place the leftover rows in the wrong relation.
Fix this by distinguishing partitioned-table routing from plain
inheritance. For partitioned tables, keep using the root leftover
slot and insert through the root relation. For plain inheritance
children, use a leftover slot matching the child relation and insert
directly into the child. Also keep translating the application-time
column attno for child relations, so multiple-inheritance cases with
different attribute numbers are handled correctly.
Added an ExecInitForPortionOf function to set up the ForPortionOfState
for each child table, which keeps most of these decisions localized
instead of spread out through ExecForPortionOfLeftovers. Incidentally
clarified a comment about the rangetype stored in ForPortionOfState.
Add regression tests for UPDATE and DELETE FOR PORTION OF on
inheritance children, including a multiple-inheritance case where the
range column has a different attnum in the parent and child.
Author: jian he <jian.universality@gmail.com>
Co-authored-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/flat/4245F94D-84F1-4E05-BF81-C458A6CF9901%40gmail.com M src/backend/executor/nodeModifyTable.c
M src/include/nodes/execnodes.h
M src/test/regress/expected/for_portion_of.out
M src/test/regress/sql/for_portion_of.sql
Fix missed checks for hashability of container-type equality.
commit : 06e94eccfd910225a78f3510700bc89c1d88782f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 8 Jun 2026 11:48:07 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 8 Jun 2026 11:48:07 -0400 The operators for array_eq, record_eq, range_eq, and multirange_eq
are all marked oprcanhash, but there's a pitfall: their hash functions
can fail at runtime if the contained type(s) are not hashable.
Therefore, the planner has to check hashability of the contained types
before deciding it can use hashing in these cases. Not every place
had gotten this memo, and noplace at all had considered the issue
for ranges or multiranges. In particular we could attempt to use
hashing for a ScalarArrayOpExpr on a container type when it won't
actually work, leading to "could not identify a hash function ..."
runtime failures.
For the most part we should fix this in the lookup functions provided
by lsyscache.c, to wit get_op_hash_functions and op_hashjoinable.
But there's a problem: get_op_hash_functions is not passed the input
data type it would need to check. We mustn't change the API of that
exported function in a back-patched fix, and even if we wanted to,
its call sites in the executor mostly don't have easy access to the
required data type OID. Fortunately, the executor call sites don't
actually need fixing, because it's expected that the planner verified
hashability before building a plan that requires it. Therefore,
leave get_op_hash_functions as-is and invent a wrapper function
get_op_hash_functions_ext that does the additional checking needed
in the planner's uses.
We also need to fix hash_ok_operator (extending the fix in 647889667).
While at it, neaten up a couple of places in lookup_type_cache where
relevant code for multirange cases was written differently from the
code for other container types.
Note: while this touches pg_operator.dat, it's only to add oid_symbol
macros. So there's no on-disk data change and no need for a
catversion bump.
Reported-by: Andrei Lepikhov <lepihov@gmail.com>
Author: Andrei Lepikhov <lepihov@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/ed221f95-f09b-4a9c-b05b-e1fed621ec87@gmail.com
Backpatch-through: 14 M src/backend/optimizer/plan/subselect.c
M src/backend/optimizer/util/clauses.c
M src/backend/utils/adt/selfuncs.c
M src/backend/utils/cache/lsyscache.c
M src/backend/utils/cache/typcache.c
M src/include/catalog/pg_operator.dat
M src/include/utils/lsyscache.h
doc: Expand on proper use of refint.
commit : 1541d91d1ccad2f1ac735574fabbacebf9ecbfa5
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 8 Jun 2026 10:33:52 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 8 Jun 2026 10:33:52 -0500 The security team has received a couple of reports about potential
SQL injection via refint's trigger arguments. We discussed this
while preparing CVE-2026-6637 and concluded that forcibly quoting
these arguments is more likely to break working code than to
prevent exploits. Unlike data values, the table/column names come
from trigger arguments, and there is little reason for a trigger
author to put hostile inputs into those arguments. So, let's
document it accordingly.
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>
Reported-by: Alex Young <alex000young@gmail.com>
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Suggested-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Christoph Berg <myon@debian.org>
Reviewed-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/ahXP7z7nsfGPOZ3T%40nathan
Backpatch-through: 14 M doc/src/sgml/contrib-spi.sgml
doc: Fix spelling for CHECKPOINT reference page
commit : f58623faa856cfac67f1ff54b951f82f81fa1f59
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 8 Jun 2026 11:03:54 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 8 Jun 2026 11:03:54 +0200 Fixing incorrect spelling and breaking up a long sentence.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Thom Brown <thom@linux.com>
Discussion: https://postgr.es/m/CAA-aLv5pZNZbdhPG2Wu0fzyKCjn9TTzN9QZ=JONPyqZQKhBV=g@mail.gmail.com M doc/src/sgml/ref/checkpoint.sgml
ecpg: Reject multiple header items in GET/SET DESCRIPTOR
commit : 4484165b0712f09ca369ed497fc6f504b718abac
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 8 Jun 2026 17:07:48 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 8 Jun 2026 17:07:48 +0900 Previously, ecpg accepted multiple descriptor header items in GET DESCRIPTOR
and SET DESCRIPTOR, but generated broken C code when they were used.
Although the grammar allowed this syntax, the implementation did not actually
support it.
This commit tightens the ecpg grammar so the header form of GET/SET DESCRIPTOR
accepts only a single header item, matching the implementation and preventing
generation of broken C code.
Also update the documentation synopsis accordingly.
Backpatch to all supported versions.
Author: Masashi Kamura <kamura.masashi@fujitsu.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Lakshmi G <lakshmigcdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/OS9PR01MB13174AD7D1829D0644B6BB90E9447A@OS9PR01MB13174.jpnprd01.prod.outlook.com
Backpatch-through: 14 M doc/src/sgml/ecpg.sgml
M src/interfaces/ecpg/preproc/ecpg.trailer
pg_createsubscriber: Fix duplicate publication name rejection.
commit : 6ce035ffff444479e63ea6276d56e33cc8b991d9
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 8 Jun 2026 12:19:29 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 8 Jun 2026 12:19:29 +0530 pg_createsubscriber rejected duplicate --publication values while parsing
command-line options, even when the duplicate names referred to
publications in different databases. Since publication names are
database-local objects, the same name is perfectly valid across multiple
databases.
This restriction was not a practical problem before commit 85ddcc2f4c,
which added support for reusing pre-existing publications. After that
change, users who have identically-named publications in multiple
databases (a common convention) could not use the feature without renaming
their publications.
The analogous restriction on --subscription names is intentionally kept as
they are reused as replication slot names, which are cluster-global, so
allowing duplicate subscription names without additional guards could
cause a slot-name collision. That work is left for a future release.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/B08A7C89-B3DE-4C1D-A671-32AD8BAB7E22@gmail.com M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl
Fix memory leak in pgstat_progress_parallel_incr_param()
commit : b20c952ce70370b22ea7a206d7b674a322397d28
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 8 Jun 2026 15:29:16 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 8 Jun 2026 15:29:16 +0900 When called from a parallel worker, this function calls initStringInfo()
and pq_beginmessage(), causing a StringInfo allocation to happen twice.
pq_endmessage() frees only the second allocation, with each call leaking
~1 kB into the per-worker memory context. This could cause a few
hundred megabytes worth of memory to pile up until the worker exits (the
message allocations happen in the parallel worker context), with the
situation being worse the longer a parallel worker runs.
Oversight in f1889729dd3.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/CA+fm-RMopta1Dmq8udiU5sp+zwTvhUf4+xfbr3rZDfczH+p-xw@mail.gmail.com
Backpatch-through: 17 M src/backend/utils/activity/backend_progress.c
Fix incorrect format placeholders
commit : a450dd7ad4ff80c65f565f1a2bd24be8ff0bf3e3
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 8 Jun 2026 07:55:01 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 8 Jun 2026 07:55:01 +0200 M src/test/modules/test_bitmapset/test_bitmapset.c
Doc: Add missing SGML markup in alter_publication.sgml.
commit : da51d9154deba7907062206d190dcd5730fe77f2
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 8 Jun 2026 11:26:25 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 8 Jun 2026 11:26:25 +0530 Author: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pu7Zxm3oU7OyK3FVXRuDO+V6143adGUC6nnSrhqizYqQQ@mail.gmail.com M doc/src/sgml/ref/alter_publication.sgml
psql: Fix expanded aligned output
commit : 3d0d6741d810fbab894905b4945f4dc4e827c4ff
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 8 Jun 2026 14:37:51 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 8 Jun 2026 14:37:51 +0900 When a table's columns are narrower than the record header line, the
expanded aligned format produced misaligned output because the data
column width was not adjusted to match the record header width, leading
to output like:
+-[ RECORD 1 ]-+
| a | 10 |
| b | 20 |
+---+----+
This commit adjusts the output so as the column width match with the
header line, giving:
+-[ RECORD 1 ]-+
| a | 10 |
| b | 20 |
+---+----------+
Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAFj8pRCzGpsr9zTHbtTd4mGh2YPJqOEgLgt8JLiopuYA9_1xGw@mail.gmail.com
Backpatch-through: 14 M src/fe_utils/print.c
M src/test/regress/expected/psql.out
M src/test/regress/sql/psql.sql
Fix publisher retain_dead_tuples check when also changing origin.
commit : 75dcc63dac0ef183774ec22a6557174ee36db601
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 8 Jun 2026 10:59:05 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 8 Jun 2026 10:59:05 +0530 In AlterSubscription(), when the SET clause includes both
retain_dead_tuples and origin options, the origin branch was using
assignment (=) rather than bitwise-or assignment (|=) when setting
check_pub_rdt. This meant that if retain_dead_tuples had already set the
flag to true in the same command, the origin branch would silently
overwrite it. As a result, the publisher-side retain_dead_tuples check
could be incorrectly skipped.
Fix by changing the assignment to |= so that the flag accumulates across
both option branches within the same ALTER SUBSCRIPTION command.
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDfe7WPOhVGKzv83ZB+BmXM88r=KPQn1sa_ZXMMChcNo=A@mail.gmail.com M src/backend/commands/subscriptioncmds.c
doc PG 19 relnotes: improve awkward or confusing wording
commit : eb77a521996f6b7900dc0dfe6346f7e3c88455bb
author : Bruce Momjian <bruce@momjian.us>
date : Sun, 7 Jun 2026 23:27:28 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sun, 7 Jun 2026 23:27:28 -0400 Reported-by: Álvaro Herrera
Discussion: https://postgr.es/m/aiQPgZtALNqj4npv@alvherre.pgsql M doc/src/sgml/release-19.sgml
Fix tuple deforming with virtual generated columns
commit : 89eafad297a9b01ad77cfc1ab93a433e0af894b0
author : David Rowley <drowley@postgresql.org>
date : Sat, 6 Jun 2026 16:45:29 +1200
committer: David Rowley <drowley@postgresql.org>
date : Sat, 6 Jun 2026 16:45:29 +1200 TupleDescFinalize() failed to take into account virtual generated
columns, which are always stored as NULL in tuples. TupleDescFinalize()
didn't check for this, and that could result in attcacheoff being set for
and beyond virtual generated columns. Also, the TupleDesc's
firstNonGuaranteedAttr could also be set incorrectly, which could result
in the tuple deformation function deforming without checking for NULLs,
and deforming using incorrectly cached offsets.
This could result in tuples being deformed incorrectly, which could
result in incorrect results, ERRORs or possibly a crash.
This has been broken since c456e39113.
Author: Chao Li <li.evan.chao@gmail.com>
Reported-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: ChangAo Chen <cca5507@qq.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/A4BC563C-0CA3-4EF3-952A-EA41F9E5BF1E%40gmail.com M src/backend/access/common/tupdesc.c
M src/backend/executor/execTuples.c
pg_surgery: Fix off-by-one bug with heap offset
commit : 193a4ded94741ba9c24509540a5d586c11761e37
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 6 Jun 2026 08:16:36 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 6 Jun 2026 08:16:36 +0900 heap_force_common() declared a boolean array indexed with an
OffsetNumber for a size of MaxHeapTuplesPerPage. OffsetNumbers are
1-based, so an input TID whose offset number equals MaxHeapTuplesPerPage
wrote one byte past the end of the stack array, crashing the server.
Like heapam_handler.c, this commit changes the array so as it uses a
0-based index, substracting one from the OffsetNumbers.
Reported-by: Wang Yuelin <violin0613@tju.edu.cn>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Discussion: https://postgr.es/m/20260604002256.40f1fd544@smtp.qiye.163.com
Backpatch-through: 14 M contrib/pg_surgery/heap_surgery.c
doc: Clarify OAuth validator authn_id logging
commit : 4cb2e2fe0aa8251bef8c2e2351cd5a062c105c0a
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Sat, 6 Jun 2026 00:18:30 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Sat, 6 Jun 2026 00:18:30 +0200 Document that OAuth validators can return an authenticated identity
in the authn_id member. The server records the identity value before
checking if the connection is authorized, so it may appear in
connection-authentication logs (even if the connection later fails
authorization).
Also remove outdated wording saying that all result parameters are
ignored when a validator returns false since validators may provide
error_detail.
Patch by Chao Li with some additional wordsmithing by me.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reported-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/0281836A-F5FF-41A5-9EE1-656C1FAAC6B2@gmail.com M doc/src/sgml/oauth-validators.sgml
doc: Use groups instead of curves in TLS documentation
commit : 55136e378c6bfc2240043d0edee6f92924e2c9fd
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 5 Jun 2026 22:16:42 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 5 Jun 2026 22:16:42 +0200 With TLS 1.3 the concept of curves was renamed to groups. Update
our wording to use groups instead of curves to make it clear what
the underlying GUC can support.
This was extracted from a slightly larger patch which also renamed
variables to match the new terminology. Given that we are in beta
this portion was however left as a future excercise.
Author: Evan Si <evsi@amazon.com>
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/23C40DD6-1C47-46FC-A746-8A1D8530AD3E@amazon.com
Backpatch-through: 18 M doc/src/sgml/config.sgml
doc PG 19 relnotes: update to current, merge items
commit : 4ebae546accf6ff0daee2f171f5d6907771b76f6
author : Bruce Momjian <bruce@momjian.us>
date : Fri, 5 Jun 2026 14:05:01 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Fri, 5 Jun 2026 14:05:01 -0400 M doc/src/sgml/release-19.sgml
refint: Remove plan cache.
commit : 1fbe2066dcc882321e87fdac43b942b890338f34
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 5 Jun 2026 12:08:05 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 5 Jun 2026 12:08:05 -0500 Presently, refint stores plans in a per-backend cache to avoid
re-preparing in each call. This has a few problems. For one,
check_foreign_key() embeds the new key values in its cascade-UPDATE
queries, so a cached plan reuses the values from preparation.
Also, the cache is never invalidated, so it can return stale
entries that cause other problems. There may very well be more
bugs lurking.
We could spend a lot of time trying to address all these problems,
but this module is primarily intended as sample code, and by all
indications, it sees minimal use. Furthermore, there is a growing
consensus for removing refint in v20. However, since we'll need to
support it on the back-branches for a while longer, it probably
still makes sense to fix some of the more egregious bugs.
Therefore, let's just remove refint's plan cache entirely. That
means we'll re-prepare on every call, but that seems quite unlikely
to bother anyone. On v17 and older versions, the regression test
for triggers fails after this change, so I've borrowed pieces of
commit 8cfbdf8f4d to fix it.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWXU%2BfhuzrEd_bnrxyGH3%2Bny8QRQC2QHf3ws6s9iki3c2Q%40mail.gmail.com
Backpatch-through: 14 M contrib/spi/refint.c
doc PG 19 relnotes: add more markup, move some items to sysviews
commit : b45137f315bb49fa4f50ae9cc16fda0a49196610
author : Bruce Momjian <bruce@momjian.us>
date : Fri, 5 Jun 2026 11:38:34 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Fri, 5 Jun 2026 11:38:34 -0400 Also remove duplicate psql tab completion authors.
Reported-by: duplicates reported by Yugo Nagata M doc/src/sgml/release-19.sgml
Reword activity message to avoid truncation
commit : e5e1f6dc795da65d430d59a813643739bed6cadb
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 5 Jun 2026 17:25:56 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 5 Jun 2026 17:25:56 +0200 The message sent to pg_stat_activity when waiting for transactions to
end was long enough that it could get truncated when the xid included
in the string grew large. Fix by rewording to avoid truncation, using
a similar message in the logical replication code as inspiration.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: ChangAo Chen <cca5507@qq.com>
Discussion: https://postgr.es/m/tencent_47CA9CE2F91FF4D81D875E162AD69AA4900A@qq.com M src/backend/postmaster/datachecksum_state.c
Fix LATERAL references in GRAPH_TABLE with multi-label pattern
commit : 4cb2a9863d89b320f37eb1bd76822f6f65e59311
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 5 Jun 2026 09:27:31 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 5 Jun 2026 09:27:31 +0200 When rewriting a GRAPH_TABLE into a subquery,
replace_property_refs_mutator() bumps levelsup of lateral references
by one so that they reference outside the subquery. This works for
path patterns that result in only one path query. Patterns that
produce multiple path queries are rewritten as a UNION of path
queries. Since every path query becomes a subquery of the UNION
statement, the levelsup of lateral references in those path queries
need an additional bump. This adjustment was missing resulting in the
lateral references being interpreted as references in the UNION query
itself. This caused different symptoms like a crash in
create_lateral_join_info() or error "plan should not reference
subplan's variable". The symptoms varied depending on the number of
RangeTblEntries in the UNION statement.
This commit adds the missing adjustment.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Author: Satya Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDfnLzsgjaQ_CiKSpP4JH3MKOiwoawEcCzXa9uYr45yiWw%40mail.gmail.com M src/backend/rewrite/rewriteGraphTable.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Handle element label and label property objects in object address functions
commit : 72498a86989e3491228ba09be43eab778a3ac943
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 5 Jun 2026 08:59:05 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 5 Jun 2026 08:59:05 +0200 getObjectTypeDescription() and getObjectIdentityParts() do not handle
objects in pg_propgraph_element_label and pg_propgraph_label_property
catalogs. These functions when called for handling DDL that affects
these objects cause an "unsupported object class" error. An error is
reported when these functions are called via pg_identify_object() and
pg_identify_object_as_address() with objects from the said catalogs.
The objects in these catalogs do not have a (user-given) name but they
can be manipulated individually through ALTER PROPERTY GRAPH
sub-commands. Hence they need to be accessible to the event triggers.
Handle these catalogs in the respective functions.
Reported-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/aej1DkLwhyZWmtxJ@bdtpg M src/backend/catalog/objectaddress.c
M src/test/regress/expected/create_property_graph.out
M src/test/regress/expected/event_trigger.out
M src/test/regress/expected/object_address.out
M src/test/regress/sql/create_property_graph.sql
M src/test/regress/sql/event_trigger.sql
M src/test/regress/sql/object_address.sql
xml2: Fix stylesheet document leak in xslt_process()
commit : 9ec568b3eb6a8e8aad9041078e4c7bfedf293ca8
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 5 Jun 2026 14:29:27 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 5 Jun 2026 14:29:27 +0900 xslt_process() parses the stylesheet text into an xmlDoc before passing it
to xsltParseStylesheetDoc(). On success, the returned stylesheet owns
that document and frees it through xsltFreeStylesheet(), calling
xmlFreeDoc() at its end. On failure, libxslt leaves the caller
responsible for the xmlDoc. In xml2, this would cause the memory
allocated for the xmlDoc to pile up across calls of xslt_process() when
failing to create a sheet.
While on it, I have double-checked the code of xml2 with libxslt, and it
seems that we are in the clear now, hopefully.. This leak exists for a
long time. 732061150b0 has made the fix introduced in this commit
easier to implement.
Author: Andrey Chernyy <andrey.cherny@tantorlabs.com>
Discussion: https://postgr.es/m/20260605024642.5a1b6518@andrnote M contrib/xml2/xslt_proc.c
Fix pg_subscription column privileges for subwalrcvtimeout
commit : 1a5b19e447aa6c2743371dc559f697cf63c7ba82
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 5 Jun 2026 09:51:55 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 5 Jun 2026 09:51:55 +0900 The subwalrcvtimeout column was added by commit fb80f38, but the
column-level privileges on pg_subscription were not updated. As a
result, non-superusers cannot read the column, unlike the other
publicly readable pg_subscription columns.
This commit grants SELECT privilege on subwalrcvtimeout to PUBLIC.
Bump catalog version.
Author: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CABdArM4uA=6nA0BunJwudiEoY1BcWUS_oj_2pkEq_d-YdiBJhw@mail.gmail.com M src/backend/catalog/system_views.sql
M src/include/catalog/catversion.h
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql
Fix off-by-one with NFC recomposition for Hangul U+11A7 (TBASE)
commit : f2ff15e4c37190e677437ecb76f706a05a645c6b
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 5 Jun 2026 07:50:08 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 5 Jun 2026 07:50:08 +0900 The NFC recomposition incorrectly included TBASE as a valid T syllable,
which is incorrect based on the Unicode specification (TBASE is one
below the start of the range, range beginning at U+11A8).
This would cause the TBASE to be silently swallowed in the
normalization, leading to an incorrect result.
A couple of regression tests are added to check more patterns with
Hangul recomposition and decomposition, on top of a test to check the
problem with TBASE. Diego has submitted the code fix, and I have
written the tests.
Author: Diego Frias <mail@dzfrias.dev>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/B92ED640-7D4A-4505-B09F-3548F58CBB16@dzfrias.dev
Backpatch-through: 14 M src/common/unicode_norm.c
M src/test/regress/expected/unicode.out
M src/test/regress/sql/unicode.sql
doc: Mention online checksum enabling in pg_checksums docs
commit : 4ae3e98c02cf57ba5e1d29e914a3b2e4d15f066f
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 5 Jun 2026 00:12:33 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 5 Jun 2026 00:12:33 +0200 The documentation for bin/pg_checksums refered to online processing only
in passing, this extends the documentation to list online checksums as as
alternative as well as providing a link to the new Data Checksums section.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Bruce Momjian <bruce@momjian.us>
Reported-by: Bruce Momjian <bruce@momjian.us>
Discussion: https://postgr.es/m/aiHKJWa1k28fFTqf@momjian.us M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/wal.sgml
ci: Remove support for cirrus-ci based CI
commit : 68c8a365d4dcefd7ec60f7a99a7ab7b557c36357
author : Andres Freund <andres@anarazel.de>
date : Thu, 4 Jun 2026 14:55:57 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 4 Jun 2026 14:55:57 -0400 As mentioned in the earlier commit, cirrus-ci has shut down. Therefore remove
all files related to running CI via cirrus. Also update comments / code that
were referencing cirrus-ci.
Discussion: https://postgr.es/m/3ydjipcr7kbss57nvi67noplncqhesl5eyb6wgol4ccjxynspv%40yatlykpribmm D .cirrus.star
D .cirrus.tasks.yml
D .cirrus.yml
M src/bin/pg_combinebackup/t/010_hardlink.pl
M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/tools/ci/ci_macports_packages.sh
D src/tools/ci/gcp_ram_disk.sh
ci: Add GitHub Actions based CI
commit : 9c126063b19adc53a0ce15ac1ae1a70979e3c12e
author : Andres Freund <andres@anarazel.de>
date : Thu, 4 Jun 2026 14:55:57 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 4 Jun 2026 14:55:57 -0400 Cirrus CI, which the project used for CI until now, has shut down on June 1,
2026. Replace it with GitHub Actions. GitHub Actions was selected because it
has unlimited runner time for public repositories.
The GitHub Actions based CI currently covers:
- SanityCheck
- Linux - Autoconf
- Linux - Meson, (32-bit and 64-bit)
- macOS - Meson
- Windows (Visual Studio + Meson and MinGW + Meson)
- CompilerWarnings
BSD coverage is left for later, as it requires more work.
Note that, for performance reasons, use of address sanitizer was moved to the
Linux - Meson (64-bit) task.
While Actions workflows in new forks are disabled by default, existing forks
that pull new changes into the repository will automatically start running
CI. That may not be desired. There however is no way native to Actions to
prevent this.
To avoid that, each repository that wants real CI to run needs to explicitly
opt into doing so, by creating the 'PG_CI_ENABLED' repository variable with
the value 1.
To make that less confusing, emit a summary whenever we skip running CI, with
a message explaining how to enable CI.
The remaining cirrus-ci support will be removed in a subsequent commit, to
make review easier.
Back-branches will be updated later, after being sure that workflow runs
correctly on master.
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
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/3ydjipcr7kbss57nvi67noplncqhesl5eyb6wgol4ccjxynspv%40yatlykpribmm A .github/workflows/pg-ci.yml
M src/tools/ci/README
M src/tools/ci/ci_macports_packages.sh
doc PG 19 relnotes: various fixes reported via email
commit : 7598b5383b16a562bd7e7732eda7d783b34f4615
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 4 Jun 2026 12:26:38 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 4 Jun 2026 12:26:38 -0400 M doc/src/sgml/config.sgml
M doc/src/sgml/release-19.sgml
Improve reporting of invalid weight symbols in setweight() et al.
commit : ce6bf3cd17d1f96c9c40d2915ef25580fbbc8be7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 4 Jun 2026 12:24:51 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 4 Jun 2026 12:24:51 -0400 This commit addresses two related issues:
tsvector_filter() assumed it could print an incorrect weight value
with %c. This could result in an invalidly-encoded error message
if the database encoding is multibyte and the char value has its
high bit set. Weight values that are ASCII control characters
could render illegibly too. Fix by printing such values in octal
(\ooo), similarly to how charout() would render them.
tsvector_setweight() and tsvector_setweight_by_filter() reported
the same unrecognized-weight error condition with elog(), as though
it were an internal error. That'd not translate, would produce an
unwanted XX000 SQLSTATE code, and also reported the bad value as a
decimal integer which seems unhelpful. Fix by refactoring so that
all three functions share one copy of the code that interprets a
weight argument.
The invalid-encoding aspect seems to me (tgl) to justify
back-patching.
Author: Ewan Young <kdbase.hack@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAON2xHNaeLAUzRCXL5AmXLcXaSE_gWAVjWQRmLzc_oZ=1_Vf4Q@mail.gmail.com
Backpatch-through: 14 M src/backend/utils/adt/tsvector_op.c
Fix another case of indirectly casting away const.
commit : c35f85ac02a1c19dbb40382a8098846ffc3b368b
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 4 Jun 2026 11:37:43 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 4 Jun 2026 11:37:43 -0400 Like 8f1791c61, this fixes a case of implicitly casting away
const by not treating the result of strrchr() on a const pointer
as const. This was missed at the time because the machines
reporting those warnings weren't building with --with-llvm.
While here, clean up another infelicity: in the probably-
impossible case that the input string contains only one dot,
this function would call pnstrdup() with a length of -1
and thereby emit a module name equal to the function name.
It seems to me we should emit modname = NULL instead.
Also remove a useless Assert and two redundant assignments.
Back-patch, as 8f1791c61 was, so that users of back branches
don't see this warning when building with late-model gcc.
Reported-by: hubert depesz lubaczewski <depesz@depesz.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/aiGNJ89PBqvq2Yyz@depesz.com
Backpatch-through: 14 M src/backend/jit/llvm/llvmjit.c
Add previous commit to .git-blame-ignore-revs.
commit : 4dce650cc1bb48d6a65503f17dff87085728e08b
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 4 Jun 2026 10:16:21 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 4 Jun 2026 10:16:21 -0500 M .git-blame-ignore-revs
Re-pgindent nodeModifyTable.c after commit 993a7aa0e4.
commit : bd57abbb1910e51e45761b59985745d094ae9e03
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 4 Jun 2026 10:15:37 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 4 Jun 2026 10:15:37 -0500 M src/backend/executor/nodeModifyTable.c
Ensure USE_AVX... symbols are not defined if not building for x86_64.
commit : e88bd2736f86d66dc75ad8b2f7edd799d20b7d53
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 4 Jun 2026 10:37:25 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 4 Jun 2026 10:37:25 -0400 Various code assumed this was true already, and usually it is.
However, it emerges that in a "universal" (multi-architecture)
macOS build, configure will define USE_AVX2_WITH_RUNTIME_CHECK
if the build host is x86_64, and then the arm64 half of the
build fails.
Ideally we'd get pg_config.h to define this symbol conditionally
depending on defined(__x86_64__), but I don't see any way to
persuade Autoconf to do that. Instead, clean up the mess by
#undef'ing it again in c.h for not-x86_64 builds.
For consistency I made c.h also #undef the USE_AVX512... symbols.
Those are not actively broken, but it seems only happenstance
that configure's tests for them fail in a universal build.
Down the road we may have occasion to add more #undef's here.
This problem is new in v19, so no need for back-patch.
Reported-by: Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
Reported-by: Tobias Bussmann <t.bussmann@gmx.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/15574903-87C9-478A-B2D7-CC8F4C275DBB@gmx.net M src/include/c.h
Small terminology fixes in comments
commit : f0aedc7cb0ed82d4cca48332dc0852c767514558
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 4 Jun 2026 11:57:55 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 4 Jun 2026 11:57:55 +0200 Author: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcd%3Dt69gLf9yQexO07EJ2mx0Z70NFHo6h94X1EDA%3DhM0g%40mail.gmail.com M src/test/regress/expected/for_portion_of.out
M src/test/regress/sql/for_portion_of.sql
Require UPDATE permission on FOR PORTION OF column
commit : 7ac030d5b152475275e84e0abe0b3628700fbeda
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 4 Jun 2026 11:30:41 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 4 Jun 2026 11:30:41 +0200 It seems like the SQL standard does require this after all, and it
makes sense because these columns get changed. (This is not to be
confused with *not* requiring INSERT permission to add the temporal
leftovers.)
Adding the column to RTEPermissionInfo->updatedCols also fixes a
couple outstanding bugs from other (non-permission) features using
that bitmapset to detect changes: GENERATED columns and UPDATE OF
triggers. This patch includes test cases to exercise those scenarios,
including on partitioned tables.
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcd%3Dt69gLf9yQexO07EJ2mx0Z70NFHo6h94X1EDA%3DhM0g%40mail.gmail.com M src/backend/parser/analyze.c
M src/test/regress/expected/for_portion_of.out
M src/test/regress/expected/privileges.out
M src/test/regress/sql/for_portion_of.sql
M src/test/regress/sql/privileges.sql
Fix cross-leftover pollution in FOR PORTION OF insert triggers
commit : 993a7aa0e4af0922ac86d8914e0e78fc38fb0daf
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 4 Jun 2026 11:12:58 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 4 Jun 2026 11:12:58 +0200 When we insert temporal leftovers after an UPDATE FOR PORTION OF, we
must make a new copy of the tuple before each insert. Otherwise, if
an insert trigger assigns to attributes of NEW, the second leftover
sees those changes.
Author: Sergei Patiakin <sergei.patiakin@enterprisedb.com>
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/flat/CANE55rCqcse_pwXBMWhbj3_7XROb8Dks6%3DOLFmKy3bO3zDsCsg%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
libpq: Fix "servicefile" after fallback to system service file
commit : 90354030b8fceecef9a1908fdefcccf0e02823fb
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 4 Jun 2026 15:12:11 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 4 Jun 2026 15:12:11 +0900 When "servicefile" is specified in a connection string but the requested
service is not found in this file, libpq falls back to a default file,
pg_service.conf in PGSYSCONFDIR. The "servicefile" option was missing
an update in this case, causing an incorrect value to be reported,
impacting SERVICEFILE in psql, for example.
An extra update of the option is added in this commit, based on the
actual file where the service name has been found. A test is added to
cover this problem.
Oversight in 092f3c63efc6.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/59DD1652-4EB5-449B-8DE3-959F06561A96@gmail.com M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/t/006_service.pl
doc PG 19 relnotes: merge pg_upgrade LO metadata items
commit : 378668d50b44afb52688988de6651aa8585f3f5c
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 3 Jun 2026 14:21:05 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 3 Jun 2026 14:21:05 -0400 Also fix commit message cut/paste mistake, and add "tar" markup. M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: reordering, rewording, added markup
commit : 41ddb9c33eadc7fec0745b86943c87f3a465cd40
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 3 Jun 2026 13:48:02 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 3 Jun 2026 13:48:02 -0400 M doc/src/sgml/release-19.sgml
pg_dump: scope indAttNames per index in getIndexes()
commit : 298bdd379552148f6043b4595374a7a6fbdd13c3
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 3 Jun 2026 11:33:35 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 3 Jun 2026 11:33:35 +0300 getIndexes() declared indAttNames and nindAttNames in the outer
per-table loop, so the names collected for an index on expressions
were carried over to the next plain index in the same table.
This is an internal inconsistency rather than a user-facing bug.
dumpRelationStats_dumper() only walks indexes that have pg_statistic
rows, and ANALYZE only creates those for indexes with expressions,
so the second index in the affected pair is not visited and the stale
array is never consulted.
Fix by moving the two variables into the inner per-index loop so each
iteration starts with a clean slate.
Author: Maksim Melnikov <m.melnikov@postgrespro.ru>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/be5fc489-587e-421f-bbb8-adb43cfd50f4@postgrespro.ru
Backpatch-through: 17 M src/bin/pg_dump/pg_dump.c
Fix race in ReplicationSlotRelease() for ephemeral slots
commit : f2081a7800f1696cb0415bacd655cb41b7b9ca63
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 3 Jun 2026 18:44:56 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 3 Jun 2026 18:44:56 +0900 When releasing an ephemeral replication slot, ReplicationSlotRelease()
drops the slot via ReplicationSlotDropAcquired().
However, after dropping the slot, ReplicationSlotRelease() continued
to use its local "slot" pointer, which still referenced the dropped
slot's former shared-memory entry. It could then update fields such as
effective_xmin in that entry.
Once an ephemeral slot has been dropped (via ReplicationSlotDropAcquired()),
its slot array entry can be reused immediately by another backend
creating a new slot. As a result, those updates could corrupt
the state of an unrelated replication slot.
Fix by skipping those shared-memory updates for phemeral slots and
performing them only for non-ephemeral slots, whose shared-memory
entries remain valid after release.
Backpatch to all supported versions.
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Masao Fujii <masao.fujii@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/TY4PR01MB177184FF9EE916F577E1F554194082@TY4PR01MB17718.jpnprd01.prod.outlook.com
Backpatch-through: 14 M src/backend/replication/slot.c
Improve overflow/underflow handling in regr_intercept().
commit : eb8e76e130fd8bd42982d597f5a66f08b13380c0
author : Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 3 Jun 2026 09:20:21 +0100
committer: Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 3 Jun 2026 09:20:21 +0100 As with corr() and regr_r2(), improve regr_intercept()'s final
function to cope with overflow/underflow in the final calculation.
Here, instead of using sqrt(), we use frexp() and ldexp() to recover,
if an overflow or underflow is detected, so that the multiplication
and division steps operate on normalised mantissas, and cannot
overflow or underflow.
As with 6498287696d, and the previous commit improving regr_r2(), this
is arguably a bug fix, but given the lack of prior complaints, refrain
from back-patching.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com>
Discussion: https://postgr.es/m/33E01656-BB3B-46E9-A41F-24A01A7C35F4@outlook.com M src/backend/utils/adt/float.c
M src/test/regress/expected/aggregates.out
M src/test/regress/sql/aggregates.sql
Improve overflow/underflow handling in regr_r2().
commit : d58ec50e0faae364fa59cdb88eba7e23b55ab583
author : Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 3 Jun 2026 09:01:13 +0100
committer: Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 3 Jun 2026 09:01:13 +0100 Commit 6498287696d improved corr()'s final function to cope with
overflow/underflow in the final calculation, and clamped its result to
[-1, 1] in case of roundoff error. Improve regr_r2() in a similar way,
clamping its result to [0, 1].
Arguably this is a bug fix, but given the lack of prior complaints,
refrain from back-patching, as we did with 6498287696d.
Reported-by: Chengpeng Yan <chengpeng_yan@outlook.com>
Author: Chengpeng Yan <chengpeng_yan@outlook.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/33E01656-BB3B-46E9-A41F-24A01A7C35F4@outlook.com M src/backend/utils/adt/float.c
M src/test/regress/expected/aggregates.out
M src/test/regress/sql/aggregates.sql
vacuumdb: Fix --analyze-in-stages skipping partitioned tables
commit : 95b6ec52e684e5de743e5bf4a2303f6cac466682
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 3 Jun 2026 16:53:16 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 3 Jun 2026 16:53:16 +0900 Commit 6429e5b77 changed vacuumdb to process partitioned tables when
--analyze-only or --analyze-in-stages is specified, matching the
documented behavior of analyzing regular tables, partitioned tables,
and materialized views.
Later, commit c4067383cb2 accidentally changed this behavior so that
partitioned tables were processed for --analyze-only, but skipped for
--analyze-in-stages.
As a result, vacuumdb --analyze-in-stages no longer matched its
documentation. Partitioned tables were skipped, leaving parent-table
statistics outdated even though users running vacuumdb
--analyze-in-stages after pg_upgrade, restore, or bulk loading would
expect statistics to be rebuilt for the database.
Fix this issue by making --analyze-in-stages process partitioned
tables again.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/EDFF0AFB-050F-4FBF-8D4F-B44DC454D957@gmail.com M src/bin/scripts/t/100_vacuumdb.pl
M src/bin/scripts/vacuuming.c
Fix copy-paste error in hash_record_extended()
commit : 273a3c77615e793089b2f41b666b6fcaa970a0c9
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 3 Jun 2026 12:47:22 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 3 Jun 2026 12:47:22 +0900 The code failed to initialize the second isnull argument passed to
FunctionCallInvoke(). This is harmless for existing in-core extended
hash support functions, since FunctionCallInvoke() does not use the
value (note that all the in-core extended hash functions are strict),
examining only the argument values. However, extension-provided
extended hash functions could be affected if they inspect
PG_ARGISNULL(1).
Oversight in 01e658fa74cb.
Author: Man Zeng <zengman@halodbtech.com>
Discussion: https://postgr.es/m/tencent_7818173C01E01836109848C3@qq.com
Backpatch-through: 14 M src/backend/utils/adt/rowtypes.c
Fix eager aggregation for semi/antijoin inner rels
commit : ffeda04259bb0b78e901c61e4b9d0ad86e786f4f
author : Richard Guo <rguo@postgresql.org>
date : Wed, 3 Jun 2026 10:12:40 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 3 Jun 2026 10:12:40 +0900 Eager aggregation pushes a partial aggregate down to a base or join
relation, to be finalized after that relation is joined with the rest
of the query. eager_aggregation_possible_for_relation() already
refuses to do this for a relation on the nullable side of an outer
join, but it failed to also refuse it for a relation on the inner side
of a semijoin or antijoin.
Such a join does not emit its inner rows, so a partial aggregate
computed on the inner side does not survive the join and cannot be
combined by the final aggregation. This can happen only for an
aggregate that references no table column, such as count(*): it is
considered computable on any relation, including the inner one,
whereas an aggregate that references a column is anchored to the outer
side and never reaches the inner relation.
The existing outer-join check did not catch this because it consults
nulling_relids, which only tracks joins that null-extend their inner
side. Semijoins and antijoins formed from EXISTS, IN, NOT EXISTS, or
NOT IN sublinks do not null-extend and carry no ojrelid, so they are
invisible to that check.
Fix by additionally rejecting any relation that includes inner-side
relations of a semijoin or antijoin but not the join's outer side.
Pushing a partial aggregate to the outer side of such a join, grouped
by the join key, remains valid and is still allowed.
Reported-by: Radim Marek <radim@boringsql.com>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAJgoLk+d_P5sKrx-SZt01Acm_j0QnWn6aKJzFJ=waRu_3C8AoQ@mail.gmail.com M src/backend/optimizer/README
M src/backend/optimizer/util/relnode.c
M src/test/regress/expected/eager_aggregate.out
M src/test/regress/sql/eager_aggregate.sql
Fix wrong unsafe-flag test in check_output_expressions()
commit : ee2fa291c8b2f8abdbad57024b92652ac4a640ff
author : Richard Guo <rguo@postgresql.org>
date : Wed, 3 Jun 2026 09:36:52 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 3 Jun 2026 09:36:52 +0900 The check for window functions (point 4) guarded on the wrong bit: it
tested UNSAFE_NOTIN_DISTINCTON_CLAUSE while setting
UNSAFE_NOTIN_PARTITIONBY_CLAUSE. Each check in this loop guards on
the same bit it is about to set, as an idempotency optimization, since
unsafeFlags[] is accumulated across the arms of a set operation and
there is no point recomputing a column's status once its bit is
present.
This is not a live bug. When UNSAFE_NOTIN_PARTITIONBY_CLAUSE is
already set but UNSAFE_NOTIN_DISTINCTON_CLAUSE is not, the guard fails
to skip targetIsInAllPartitionLists() and recomputes it, but setting
the same bit again changes nothing. When
UNSAFE_NOTIN_DISTINCTON_CLAUSE is already set, point 4 is skipped and
UNSAFE_NOTIN_PARTITIONBY_CLAUSE is left unset; but such a column is
already unsafe for pushdown via UNSAFE_NOTIN_DISTINCTON_CLAUSE, so the
outcome is unchanged.
To fix, test UNSAFE_NOTIN_PARTITIONBY_CLAUSE, matching the bit being
set and the pattern of the surrounding checks.
Back-patch to v15, where the buggy check was introduced.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAMbWs49Q_xnF_P2QSUyDzJ34MnrO7dh-cUAaK2HJPgSgh88NcA@mail.gmail.com
Backpatch-through: 15 M src/backend/optimizer/path/allpaths.c
psql: Fix issues with deferred errors in pipelines
commit : d21604e17e491eef39626a2eff518b9731fefb91
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 3 Jun 2026 08:58:26 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 3 Jun 2026 08:58:26 +0900 When an error is raised while processing a Sync message in a pipeline,
like a deferred constraint violation, the error was not associated with
the piped command and was not counted in available_results. This caused
assertion failures in discardAbortedPipelineResults(), keeping an
incorrect state at pipeline exit, because the code assumed that the
number of available and requested results would always be positive,
expecting all the counters to be 0 at the end of a pipeline.
This commit switches discardAbortedPipelineResults() and
ExecQueryAndProcessResults() to take a softer approach when consuming
and draining the results after an error. If there are still piped syncs
in the pipeline when it ends, we now attempt to consume them before
leaving the pipeline mode.
Alexander has been able to reach two assertion failures through his
testing. While investigating more this issue, I have bumped into two
more. Most of these cases are covered by the regression tests added in
this commit, plus some cases with mixes of pipelines, deferred errors
and results fetched. Some of the tests discussed (like the backend
termination one) could not be included in this commit but have been
tested manually. Another test scenario discussed involved the injection
of an error state in the backend, that was able to trick libpq
internally and put its queue out of sync. This scenario is not going to
happen in practice, but if we were to do something about it we would
need to make libpq understand that it needs to fail in some cases but
not block.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19494-97a86d84fee71c47@postgresql.org
Backpatch-through: 18 M src/bin/psql/common.c
M src/test/regress/expected/psql_pipeline.out
M src/test/regress/sql/psql_pipeline.sql
xml2: Fix more memory leaks with libxml2 and XPath evaluations
commit : a77bdb11e6ba47f1a3e8363411b84c7f35f676e2
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 3 Jun 2026 08:16:42 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 3 Jun 2026 08:16:42 +0900 Several objects were allocated by libxml2 and never released in some
error or even success paths, leading to some memory leaks that would
stack across SQL calls:
- In pgxml_xpath(), the result of xmlXPathCompiledEval() could leak.
This now uses a TRY/CATCH block to ensure a correct cleanup of a
workspace on failure.
- In xpath_table() missed some objects not freed on failure. Some
xmlFree() calls were missing for the results copied after a success.
- In pgxmlNodeSetToText(), xmlXPathCastNodeToString() allocates a result
that the caller is responsible for freeing. It was not freed.
Most of the work of this commit stands on top of 732061150b0, that has
refactored xml2 to make the handling of such leaks easier. The leaks
fixed here are more ancient than the commit mentioned above, and we have
never bothered doing something about them in older stable branches.
Author: Andrey Chernyy <andrey.cherny@tantorlabs.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20260601010124.5edf9a20@andrnote M contrib/xml2/xpath.c
Stamp 19beta1.
commit : 4b0bf0788b066a4ca1d4f959566678e44ec93422
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 1 Jun 2026 16:02:13 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 1 Jun 2026 16:02:13 -0400 M configure
M configure.ac
M meson.build
Translation updates
commit : ef6a95c7c64de07dff4dd1f1da88ffae7b086ef3
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 1 Jun 2026 12:13:54 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 1 Jun 2026 12:13:54 +0200 Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: fcf4cea0a0730cdd7f5da35160ab1c745212768f M src/backend/po/de.po
M src/backend/po/es.po
M src/backend/po/ja.po
M src/backend/po/ka.po
M src/backend/po/ko.po
M src/backend/po/ru.po
M src/backend/po/sv.po
M src/backend/po/uk.po
M src/bin/initdb/po/de.po
M src/bin/initdb/po/es.po
M src/bin/initdb/po/fr.po
M src/bin/initdb/po/ja.po
M src/bin/initdb/po/ka.po
M src/bin/initdb/po/ko.po
M src/bin/initdb/po/ru.po
M src/bin/initdb/po/sv.po
M src/bin/initdb/po/uk.po
M src/bin/initdb/po/zh_CN.po
M src/bin/pg_amcheck/po/de.po
M src/bin/pg_amcheck/po/es.po
M src/bin/pg_amcheck/po/fr.po
M src/bin/pg_amcheck/po/ja.po
M src/bin/pg_amcheck/po/ka.po
M src/bin/pg_amcheck/po/ko.po
M src/bin/pg_amcheck/po/ru.po
M src/bin/pg_amcheck/po/sv.po
M src/bin/pg_archivecleanup/po/de.po
M src/bin/pg_archivecleanup/po/es.po
M src/bin/pg_archivecleanup/po/fr.po
M src/bin/pg_archivecleanup/po/ja.po
M src/bin/pg_archivecleanup/po/ka.po
M src/bin/pg_archivecleanup/po/ko.po
M src/bin/pg_archivecleanup/po/ru.po
M src/bin/pg_archivecleanup/po/sv.po
M src/bin/pg_archivecleanup/po/uk.po
M src/bin/pg_basebackup/po/de.po
M src/bin/pg_basebackup/po/es.po
M src/bin/pg_basebackup/po/fr.po
M src/bin/pg_basebackup/po/ja.po
M src/bin/pg_basebackup/po/ka.po
M src/bin/pg_basebackup/po/ko.po
M src/bin/pg_basebackup/po/ru.po
M src/bin/pg_basebackup/po/sv.po
M src/bin/pg_basebackup/po/uk.po
M src/bin/pg_checksums/po/de.po
M src/bin/pg_checksums/po/es.po
M src/bin/pg_checksums/po/fr.po
M src/bin/pg_checksums/po/ja.po
M src/bin/pg_checksums/po/ka.po
M src/bin/pg_checksums/po/ko.po
M src/bin/pg_checksums/po/ru.po
M src/bin/pg_checksums/po/sv.po
M src/bin/pg_checksums/po/uk.po
M src/bin/pg_combinebackup/po/de.po
M src/bin/pg_combinebackup/po/es.po
M src/bin/pg_combinebackup/po/fr.po
M src/bin/pg_combinebackup/po/ja.po
M src/bin/pg_combinebackup/po/ka.po
M src/bin/pg_combinebackup/po/ko.po
M src/bin/pg_combinebackup/po/ru.po
M src/bin/pg_combinebackup/po/sv.po
M src/bin/pg_combinebackup/po/uk.po
M src/bin/pg_config/po/de.po
M src/bin/pg_config/po/es.po
M src/bin/pg_config/po/fr.po
M src/bin/pg_config/po/ja.po
M src/bin/pg_config/po/ka.po
M src/bin/pg_config/po/ru.po
M src/bin/pg_config/po/sv.po
M src/bin/pg_controldata/po/de.po
M src/bin/pg_controldata/po/es.po
M src/bin/pg_controldata/po/fr.po
M src/bin/pg_controldata/po/ja.po
M src/bin/pg_controldata/po/ka.po
M src/bin/pg_controldata/po/ko.po
M src/bin/pg_controldata/po/ru.po
M src/bin/pg_controldata/po/sv.po
M src/bin/pg_controldata/po/uk.po
M src/bin/pg_ctl/po/de.po
M src/bin/pg_ctl/po/es.po
M src/bin/pg_ctl/po/fr.po
M src/bin/pg_ctl/po/ja.po
M src/bin/pg_ctl/po/ka.po
M src/bin/pg_ctl/po/ko.po
M src/bin/pg_ctl/po/ru.po
M src/bin/pg_ctl/po/sv.po
M src/bin/pg_ctl/po/uk.po
M src/bin/pg_dump/po/de.po
M src/bin/pg_dump/po/es.po
M src/bin/pg_dump/po/fr.po
M src/bin/pg_dump/po/ja.po
M src/bin/pg_dump/po/ka.po
M src/bin/pg_dump/po/ko.po
M src/bin/pg_dump/po/ru.po
M src/bin/pg_dump/po/sv.po
M src/bin/pg_dump/po/uk.po
M src/bin/pg_resetwal/po/de.po
M src/bin/pg_resetwal/po/es.po
M src/bin/pg_resetwal/po/fr.po
M src/bin/pg_resetwal/po/ja.po
M src/bin/pg_resetwal/po/ka.po
M src/bin/pg_resetwal/po/ko.po
M src/bin/pg_resetwal/po/ru.po
M src/bin/pg_resetwal/po/sv.po
M src/bin/pg_resetwal/po/uk.po
M src/bin/pg_rewind/po/de.po
M src/bin/pg_rewind/po/fr.po
M src/bin/pg_rewind/po/ja.po
M src/bin/pg_rewind/po/ka.po
M src/bin/pg_test_fsync/po/de.po
M src/bin/pg_test_fsync/po/es.po
M src/bin/pg_test_fsync/po/fr.po
M src/bin/pg_test_fsync/po/ja.po
M src/bin/pg_test_fsync/po/ka.po
M src/bin/pg_test_fsync/po/ru.po
M src/bin/pg_test_fsync/po/sv.po
M src/bin/pg_test_timing/po/de.po
M src/bin/pg_test_timing/po/ka.po
M src/bin/pg_upgrade/po/de.po
M src/bin/pg_upgrade/po/es.po
M src/bin/pg_upgrade/po/fr.po
M src/bin/pg_upgrade/po/ja.po
M src/bin/pg_upgrade/po/ka.po
M src/bin/pg_upgrade/po/ko.po
M src/bin/pg_upgrade/po/ru.po
M src/bin/pg_upgrade/po/sv.po
M src/bin/pg_upgrade/po/uk.po
M src/bin/pg_verifybackup/po/de.po
M src/bin/pg_verifybackup/po/es.po
M src/bin/pg_verifybackup/po/fr.po
M src/bin/pg_verifybackup/po/ja.po
M src/bin/pg_verifybackup/po/ka.po
M src/bin/pg_verifybackup/po/ko.po
M src/bin/pg_verifybackup/po/ru.po
M src/bin/pg_verifybackup/po/sv.po
M src/bin/pg_verifybackup/po/uk.po
M src/bin/pg_waldump/po/de.po
M src/bin/pg_waldump/po/fr.po
M src/bin/pg_waldump/po/ja.po
M src/bin/pg_waldump/po/ka.po
M src/bin/pg_walsummary/po/de.po
M src/bin/pg_walsummary/po/es.po
M src/bin/pg_walsummary/po/fr.po
M src/bin/pg_walsummary/po/ja.po
M src/bin/pg_walsummary/po/ka.po
M src/bin/pg_walsummary/po/ru.po
M src/bin/pg_walsummary/po/sv.po
M src/bin/pg_walsummary/po/uk.po
M src/bin/psql/po/de.po
M src/bin/psql/po/es.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ja.po
M src/bin/psql/po/ka.po
M src/bin/psql/po/ko.po
M src/bin/psql/po/ru.po
M src/bin/psql/po/sv.po
M src/bin/psql/po/uk.po
M src/bin/scripts/po/de.po
M src/bin/scripts/po/es.po
M src/bin/scripts/po/fr.po
M src/bin/scripts/po/ja.po
M src/bin/scripts/po/ka.po
M src/bin/scripts/po/ko.po
M src/bin/scripts/po/ru.po
M src/bin/scripts/po/sv.po
M src/bin/scripts/po/uk.po
M src/interfaces/ecpg/ecpglib/po/es.po
M src/interfaces/ecpg/ecpglib/po/ja.po
M src/interfaces/ecpg/ecpglib/po/ka.po
M src/interfaces/ecpg/ecpglib/po/ru.po
M src/interfaces/ecpg/ecpglib/po/sv.po
M src/interfaces/ecpg/preproc/po/es.po
M src/interfaces/ecpg/preproc/po/fr.po
M src/interfaces/ecpg/preproc/po/ja.po
M src/interfaces/ecpg/preproc/po/ka.po
M src/interfaces/ecpg/preproc/po/ko.po
M src/interfaces/ecpg/preproc/po/ru.po
M src/interfaces/ecpg/preproc/po/sv.po
M src/interfaces/ecpg/preproc/po/uk.po
M src/interfaces/libpq/po/de.po
M src/interfaces/libpq/po/es.po
M src/interfaces/libpq/po/fr.po
M src/interfaces/libpq/po/ja.po
M src/interfaces/libpq/po/ka.po
M src/interfaces/libpq/po/ko.po
M src/interfaces/libpq/po/ru.po
M src/interfaces/libpq/po/sv.po
M src/interfaces/libpq/po/uk.po
M src/pl/plperl/po/es.po
M src/pl/plperl/po/ja.po
M src/pl/plperl/po/ka.po
M src/pl/plperl/po/ru.po
M src/pl/plperl/po/sv.po
M src/pl/plperl/po/uk.po
M src/pl/plpgsql/src/po/de.po
M src/pl/plpgsql/src/po/es.po
M src/pl/plpgsql/src/po/fr.po
M src/pl/plpgsql/src/po/ja.po
M src/pl/plpgsql/src/po/ka.po
M src/pl/plpgsql/src/po/ru.po
M src/pl/plpgsql/src/po/sv.po
M src/pl/plpgsql/src/po/uk.po
M src/pl/plpython/po/de.po
M src/pl/plpython/po/es.po
M src/pl/plpython/po/fr.po
M src/pl/plpython/po/ja.po
M src/pl/plpython/po/ka.po
M src/pl/plpython/po/ru.po
M src/pl/plpython/po/sv.po
M src/pl/plpython/po/uk.po
M src/pl/tcl/po/es.po
M src/pl/tcl/po/fr.po
M src/pl/tcl/po/ja.po
M src/pl/tcl/po/ka.po
M src/pl/tcl/po/ko.po
M src/pl/tcl/po/ru.po
M src/pl/tcl/po/sv.po
M src/pl/tcl/po/uk.po
doc PG 19 relnotes: add links for functions and stucts
commit : 78ec4b69a0dc064fc8c65bf0711db5a32d030237
author : Bruce Momjian <bruce@momjian.us>
date : Sun, 31 May 2026 23:19:18 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sun, 31 May 2026 23:19:18 -0400 M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: first phase of markup additions
commit : 4ff61509881b708a96e7c0055038b46071f4b8b5
author : Bruce Momjian <bruce@momjian.us>
date : Sun, 31 May 2026 22:54:03 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sun, 31 May 2026 22:54:03 -0400 M doc/src/sgml/release-19.sgml
doc: add missing xreflabel to debug_print_raw_parse
commit : 39343218347b4bbd41bb8b4bbdac595695d59000
author : Bruce Momjian <bruce@momjian.us>
date : Sun, 31 May 2026 16:17:49 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sun, 31 May 2026 16:17:49 -0400 M doc/src/sgml/config.sgml
doc relnote markup: allow period in <command> regex for ellipses
commit : 21298c2cd0cd8fe83e567f3f3f16475bd3934124
author : Bruce Momjian <bruce@momjian.us>
date : Sat, 30 May 2026 17:49:26 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sat, 30 May 2026 17:49:26 -0400 M doc/src/sgml/release.sgml
doc PG 19 relnotes: adjust pg_read_all_data & pg_write_all_data
commit : 3e744cc745b894b3712990b84729f805e4333147
author : Bruce Momjian <bruce@momjian.us>
date : Sat, 30 May 2026 14:55:32 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Sat, 30 May 2026 14:55:32 -0400 These were previously marked as functions, not roles, and were in the
wrong section.
Reported-by: 彭冲 <chong.peng@enmotech.com>
Discussion: https://postgr.es/m/tencent_5468291122A490C6578D9467@qq.com M doc/src/sgml/release-19.sgml
Avoid leaking system path from pg_available_extensions
commit : db5ed03217b9c238703df8b4b286115d6e940488
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 20 May 2026 08:49:15 +0800
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 20 May 2026 08:49:15 +0800 The documentation says that when extension_control_path is set to an
empty string, the default '$system' path is still assumed. However,
get_extension_control_directories() added the system extension directory
with a NULL macro in that case. As a result, pg_available_extensions
could expose the expanded system directory path instead of reporting
'$system' as the location.
Record the implicitly-added system directory with the '$system' macro, so
pg_available_extensions reports the documented symbolic location and does
not leak the actual system path.
Update the extension_control_path TAP test to check the reported location
directly.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Lu Feng <fnlo1995@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/357C774A-ECE9-4455-B641-315205D4D9A1@gmail.com M src/backend/commands/extension.c
M src/test/modules/test_extensions/t/001_extension_control_path.pl
Apply encoding conversion in COPY TO FORMAT JSON
commit : 7dc5bbcf220be05786a08aad2455c61b6dbd4b78
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 20 Apr 2026 11:16:36 +0530
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 20 Apr 2026 11:16:36 +0530 CopyToJsonOneRow() sent the output of composite_to_json() directly
via CopySendData() without encoding conversion. The text and CSV
paths convert per-attribute via pg_server_to_any() when
need_transcoding is true, but the JSON path skipped this entirely.
This meant COPY ... TO ... WITH (FORMAT json, ENCODING 'LATIN1') on
a UTF-8 server silently produced UTF-8 output, and COPY TO STDOUT
with a non-UTF-8 client_encoding would send unconverted bytes to
the client.
Apply pg_server_to_any() to the whole JSON buffer after
composite_to_json() returns, converting to the requested file
encoding when it differs from the server encoding. Tests cover
both the explicit ENCODING option and the implicit case where
file_encoding is inherited from client_encoding.
Introduced by 7dadd38cda9 (json format for COPY TO).
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CAJTYsWX-jsLzxGRAb-dWnEpGYRPbDYHwce8LctVE92LiDfM2Jw@mail.gmail.com M src/backend/commands/copyto.c
M src/test/regress/expected/copyencoding.out
M src/test/regress/sql/copyencoding.sql
Allow old WAL recycling during REPACK CONCURRENTLY
commit : 45b02984e2fa9ee7bd83f7e58797b160baf0cc13
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 30 May 2026 00:23:25 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 30 May 2026 00:23:25 +0200 During REPACK CONCURRENTLY, logical decoding keeps replication
slot.restart_lsn pinned behind the oldest running transaction, which is
often the long-lived REPACK transaction itself. As a result, old WAL
segments are retained longer than necessary.
This commit advances the replication slot each time WAL insertion
crosses a segment boundary, so obsolete WAL files can be recycled while
REPACK is still running.
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/TY4PR01MB17718B44164522D0798F8E898940A2@TY4PR01MB17718.jpnprd01.prod.outlook.com M src/backend/commands/repack_worker.c
doc: Correct the timeline for OAuth's shutdown_cb
commit : 08127c641c099b21480d4cd47c2706fe64ca1820
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 29 May 2026 14:40:20 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 29 May 2026 14:40:20 -0700 During original feature development, the OAuth validator shutdown
callback was invoked via before_shmem_exit(). That was changed to use a
reset callback before commit, but I forgot to update the documentation
for validator developers.
Correct this and backport to 18, where OAuth was introduced. The
callback is invoked whenever the server is "finished" with token
validation. (We make no stronger guarantees here, in the hopes that this
API might successfully navigate future multifactor authentication
support and/or changes to the server threading model.)
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAN4CZFOuMb_gnLvCwRdMybg_k8WRNJTjcij%2BPoQkuQHDUzxGWg%40mail.gmail.com
Backpatch-through: 18 M doc/src/sgml/oauth-validators.sgml
Fix compilation with OpenSSL 4
commit : 89d243d52189ad426538012e0db9aad441240e68
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:52:35 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:52:35 +0200 OpenSSL 4.0.0 changed some parameters and returnvalues to const, so
we need to update our declarations and subsequently cast away const-
ness from a few callsites to make libpq build without warnings. This
is tested with OpenSSL 1.1.1 through 4.0.0 as well as with LibreSSL.
No functional change is introduced, this commit only allows postgres
to be compiled against OpenSSL 4.0.0 without warnings.
There is also an errormessage change in OpenSSL 4.0.0 which needed
to be covered by our testharness.
This will be backpatched to all supported branches since they are
all equally likely to be built against OpenSSL 4.0.0 as it becomes
available in distributions. Backpatching will be done once it has
been in master for a few days without issues.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/066B07BB-85FA-487C-BE8C-40F791CFC3C4@yesql.se
Backpatch-through: 14 M contrib/sslinfo/sslinfo.c
M src/backend/libpq/be-secure-openssl.c
M src/interfaces/libpq/fe-secure-openssl.c
M src/test/ssl/t/001_ssltests.pl
Constistent naming for datacheckusms processes
commit : 5ab239c9a908ba5d8614d23fcdc425859a2fed3c
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:25 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:25 +0200 The launcher and worker for enabling/disabling checksums were named
"datachecksum worker|launcher" but using the plural form makes more
sense given the underlying GUC name data_checksums.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20260528.121622.1662808269492494574.horikyota.ntt@gmail.com M src/backend/postmaster/datachecksum_state.c
M src/include/postmaster/proctypelist.h
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/DataChecksums/Utils.pm
M src/test/regress/expected/stats.out
Use correct datatype for PID
commit : 0ca1b3010597231b474d94d877ecc8266a473537
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:23 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:23 +0200 The datachecksums launcher was using int for storing a PID, but
the correct type is pid_t (which is defined to be a signed int).
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/f1281cf3-89a3-4936-9bc5-2a5a6291229f@vondra.me M src/backend/postmaster/datachecksum_state.c
Improve comments in online checksums code
commit : cd857dec0e0ae63dabf548d51fddb27c45561086
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:21 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:21 +0200 Spelling fixes and rewording outdated information.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/f1281cf3-89a3-4936-9bc5-2a5a6291229f@vondra.me M src/backend/access/transam/xlog.c
M src/backend/postmaster/auxprocess.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/utils/init/postinit.c
Fix checksum state transition during promotion
commit : 5fee7cab1b8746c9e1bc25b20158cb074c7a76da
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:18 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 29 May 2026 21:26:18 +0200 When a standby is promoted to primary during checksum enabling when the
state is inprogress-on, the standby shall revert the state to off since
checksums weren't fully enabled at the time of the crash. Consider the
following scenario:
1) primary/standby cluster has checksums off
2) primary starts enabling checksums
3) primary moves to inprogress-on
4) standby receives that and moves to inprogress-on too
5) primary crashes
6) standby gets promoted, and does the StartupXLOG thing
7) standby moves from inprogress-on back to off
Any processes in the standby need to be informed at step 6 to change
state with a procsignalbarrier, else they will stay in inprogress-on
while new backends will see the state as off. StartupXLOG failed to
emit a procsignalbarrier which caused inconsistent state in the node
promoted to primary.
Fixed by emitting a procsignalbarrier during promotion, and adding a
new test for this scenario.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/f1281cf3-89a3-4936-9bc5-2a5a6291229f@vondra.me M src/backend/access/transam/xlog.c
M src/test/modules/test_checksums/t/003_standby_restarts.pl
Advance restart_lsn more eagerly in LogicalConfirmReceivedLocation
commit : 38470c2c1ea7dc0971d7abf65ef1dde80824ef43
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 29 May 2026 21:10:01 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 29 May 2026 21:10:01 +0200 The existing logic computed an updated replicationSlotMinLSN from all
slots' restart_lsn only when catalog_xmin also advanced. This is not a
problem in normal (non-repack) cases, because catalog_xmin changes
pretty frequently, so the recomputation is triggered frequently enough.
However, REPACK does not currently change its catalog snapshot, so that
doesn't work very well if no other replication slot is being used.
(After this commit, we still don't recycle WAL properly for REPACK,
because its background worker is not advancing its restart_lsn either;
that will be fixed in a separate commit. However, this preexisting
problem in older code is logically separate from that one.)
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/TY4PR01MB17718B44164522D0798F8E898940A2@TY4PR01MB17718.jpnprd01.prod.outlook.com M src/backend/replication/logical/logical.c
Remove unnecessary signal handler change
commit : 5d48d3b14e0e3a46e93b9f71b47205bebaab4b0e
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 29 May 2026 20:53:06 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 29 May 2026 20:53:06 +0200 In reality, this changes nothing, since the signal handler in bgworkers
is already die() since commit d62dca3b2974.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/e60318b8-be75-4bfd-82f0-0829f51fa839@gmail.com M src/backend/commands/repack_worker.c
libpq: Send users to the wiki during grease failures
commit : 2368c14e9e205c5ee3cf0106bde028f2914f188a
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 29 May 2026 11:34:12 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 29 May 2026 11:34:12 -0700 The existing documentation link for grease errors is fine, but something
a little more user-friendly and updatable would be ideal, since the
campaign won't last very long. The page
https://wiki.postgresql.org/wiki/Grease
has been added for this purpose. (It's admin-protected, to avoid making
it a spam target).
Discussion: https://postgr.es/m/CAOYmi%2BkVfqgPAaR1QuY7%3DRPBYR6MsA3V3_f5%2BH-75uC06YCDDA%40mail.gmail.com M src/interfaces/libpq/fe-misc.c
libpq: Fix grease error message style
commit : 5ca41e4125e9822816a8c1fb79ec19077360b861
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 29 May 2026 11:34:03 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 29 May 2026 11:34:03 -0700 Double-quote the protocol extension name, and move it out of line with a
%s specifier, to help with translation. Fixes up 4966bd3ed.
Reported-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Suggested-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/20260528.121622.1662808269492494574.horikyota.ntt%40gmail.com M src/interfaces/libpq/fe-protocol3.c
pg_plan_advice: DO_NOT_SCAN is a simple tag, not a generic one.
commit : b1901e2895e08f57a5fedfd27375babd6c633893
author : Robert Haas <rhaas@postgresql.org>
date : Fri, 29 May 2026 13:51:09 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Fri, 29 May 2026 13:51:09 -0400 Generic tags allow sublists, e.g. MERGE_JOIN((x y)), but simple
tags do not, e.g. SEQ_SCAN(x) is valid but SEQ_SCAN((x)) is not.
DO_NOT_SCAN was intended to be simple tag, but was accidentally
implemented as a generic one. This could result in assertion
failures. Repair.
Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>
Analyzed-by: Tender Wang <tndrwang@gmail.com>
Analyzed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: http://postgr.es/m/19493-5878eac7a2525c23@postgresql.org M contrib/pg_plan_advice/expected/syntax.out
M contrib/pg_plan_advice/pgpa_parser.y
M contrib/pg_plan_advice/pgpa_scanner.l
M contrib/pg_plan_advice/sql/syntax.sql
pg_stash_advice: Reject overlong stash names in dump file.
commit : 878839bafe259e6df355e7adc5a040a1541b63b8
author : Robert Haas <rhaas@postgresql.org>
date : Fri, 29 May 2026 13:25:20 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Fri, 29 May 2026 13:25:20 -0400 Otherwise, the server will crash. This can only happen if the dump
file has been corrupted or manually altered, but we should still
defend against it.
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Co-authored-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Co-authored-by: Robert Haas <rhaas@postgresql.org>
Discussion: http://postgr.es/m/CAJTYsWWYhcEx1YqC=B331-Df9EpD8MxzwswWL0okz9LLCUUpBA@mail.gmail.com M contrib/pg_stash_advice/stashpersist.c
Cover additional errors and corner conditions in repack.c
commit : 2670cc298f42cd7b1c426bf7ccfb0652d8e0b347
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 29 May 2026 11:54:00 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 29 May 2026 11:54:00 +0200 The coverage report shows that some error cases were not being tested;
add test cases for them.
While at it, move some recently added ones to the test_decoding suite:
the preventative check added in 43649b6a53e9 now causes servers with
wal_level=minimal to error out earlier than before.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Baji Shaik <baji.pgdev@gmail.com>
Discussion: https://postgr.es/m/ahiwD29RNfVT4tjQ@alvherre.pgsql M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql
Use term "referenced" rather than "dependent" in dependency locking
commit : e2b35735b00181ba098d102d6504978a61fab983
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 28 May 2026 21:38:21 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 28 May 2026 21:38:21 +0300 Reported-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://www.postgresql.org/message-id/20260528.114608.488039299811669368.horikyota.ntt@gmail.com
Backpatch-through: 14 M src/backend/catalog/pg_depend.c
M src/test/isolation/expected/ddl-dependency-locking.out
Improve REPACK (CONCURRENTLY) error messages some more
commit : 378dffaf8c80f07f2226538669da4d98ffaecefa
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 28 May 2026 20:29:20 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 28 May 2026 20:29:20 +0200 We had discussed changing the wording of messages from "cannot repack
table X" to "cannot execute REPACK on table X", so that translators
don't have to figure out how to translate REPACK as a verb in their
language. We already do that for VACUUM and others and it's not very
nice. Also remove extra double-quotes in a message of that form which I
mistakenly added in commit 43649b6a53e9.
While at it, add specific error messages for the cases of a table with a
deferrable primary key, and of REPLICA IDENTITY FULL; otherwise the user
gets a message that the table doesn't have an identity index and it's
not clear why that is.
Author: Baji Shaik <baji.pgdev@gmail.com>
Discussion: https://postgr.es/m/CA+fm-ROdgh0rEVuXoViBk4TVgjodrN=MTR_RYuOuKLZ9voX4YA@mail.gmail.com
Discussion: https://postgr.es/m/CABV9wwOo=wvq1hwTRK6HgBWUB=ekzsEebY30EWoc1V9UJQrrrw@mail.gmail.com M src/backend/commands/repack.c
M src/test/regress/expected/cluster.out
Make stack depth check work with asan's use-after-return
commit : 659701788171a5899119a6ddd98771371b355437
author : Andres Freund <andres@anarazel.de>
date : Thu, 28 May 2026 11:34:11 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 28 May 2026 11:34:11 -0400 With address sanitizer's stack-use-after-return check, stack variables are
moved to heap allocations, to allow to detect references to the memory at a
later time. That broke our stack-depth check, which is why we had to disable
detect_stack_use_after_return in CI. Luckily __builtin_frame_address() works
correctly, even under asan, so use that.
We started using __builtin_frame_address() with de447bb8e6fb, however as of
that commit we just used it for the stack base address, not for the value to
compare to the base address. Now we use it for both.
When building without __builtin_frame_address() support, we continue to use
stack variables for the stack depth determination.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/2kk4z4odvuyrg7qlwjd7ft4eron4cle4btb33v4qatgsdkayir@gj6e62rgsel4
Backpatch-through: 14 M .cirrus.tasks.yml
M src/backend/utils/misc/stack_depth.c
Fix some minor issues in repack ereport()s
commit : 497e92dce9b4c094fc6cee0ab37e6b9d65e67046
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 28 May 2026 16:46:12 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 28 May 2026 16:46:12 +0200 A few of them were missing errcode(), and a couple could use some
wordsmithing.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CA+fm-ROdgh0rEVuXoViBk4TVgjodrN=MTR_RYuOuKLZ9voX4YA@mail.gmail.com M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
Improve REPACK (CONCURRENTLY) error when wal_level < replica
commit : 43649b6a53e9b3964e921cc962f5c977bce688fd
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 28 May 2026 15:04:36 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 28 May 2026 15:04:36 +0200 The error emitted when REPACK (CONCURRENTLY) is run with too low a
wal_level is thrown by CheckSlotRequirements(), which is a bit
mysterious when the user doesn't know what's up. Add an upfront check
in check_concurrent_repack_requirements() for a more explicit, REPACK-
centered report, which is easier to understand -- this also saves
starting the worker just to have it die immediately.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CA+fm-ROdgh0rEVuXoViBk4TVgjodrN=MTR_RYuOuKLZ9voX4YA@mail.gmail.com M src/backend/commands/repack.c
postgres_fdw: Fix whitespace violation in connection.c
commit : af23353a73d5b890181f8fc3d2c20ff35b655af0
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 28 May 2026 21:53:26 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 28 May 2026 21:53:26 +0900 Previously a continuation line in the call to libpqsrv_connect_params_start()
in postgres_fdw/connection.c was indented with spaces, violating
the PostgreSQL project's whitespace rules for C files and triggering
git show --check.
This commit reformats the code to avoid that layout and use indentation
consistent with project style. No functional change.
Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Chao Li <lic@highgo.com>
Author: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/2620a664-7b44-48b2-9aa8-5f0131702d9c@eisentraut.org M contrib/postgres_fdw/connection.c
postgres_fdw, dblink: Validate use_scram_passthrough values
commit : 8a86aa313a714adc56c74e4b08793e4e6102b5ca
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 28 May 2026 20:58:08 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 28 May 2026 20:58:08 +0900 The use_scram_passthrough option in postgres_fdw and dblink accepts
only boolean values. However, unlike other boolean options such as
keep_connections, its value was not previously validated.
As a result, commands such as
"CREATE SERVER ... OPTIONS (use_scram_passthrough 'invalid')"
could succeed unexpectedly.
This commit updates postgres_fdw and dblink to validate that
use_scram_passthrough is assigned a valid boolean value, and throw an
error for invalid input.
Backpatch to v18, where use_scram_passthrough was introduced.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwF+-k-Ehsu5W94ZP7GxS3wiBd+mi0PfGTdJ_i2Yr0zR3g@mail.gmail.com
Backpatch-through: 18 M contrib/dblink/dblink.c
M contrib/postgres_fdw/option.c
Fix race between ProcSignalInit() and EmitProcSignalBarrier().
commit : d79bf7612a07a6f053f4122a8bf88754217cd1c9
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 27 May 2026 16:25:56 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 27 May 2026 16:25:56 -0700 Previously, ProcSignalInit() read the global barrier generation before
publishing its PID into pss_pid. This created a race condition: a
process could initialize its local generation with an older global
value, while a concurrent EmitProcSignalBarrier() might skip that
process because its pss_pid was still zero. This resulted in
WaitForProcSignalBarrier() hanging indefinitely.
Fix this by publishing pss_pid before reading psh_barrierGeneration
with a memory barrier so that the store to pss_pid is ordered before
the load. A concurrent EmitProcSignalBarrier() then either observes
the published PID and signals this slot, or completes its generation
increment before we load it.
While this race has become more visible due to recent features using
signal barriers in more places (such as online wal_level changes), the
issue is theoretically present since signal barriers were introduced
to release smgr caches (e.g., in DROP DATABASE). v14 has the
procsiangl barrier infrastricutre but no in-tree caller that actually
emits a barrier, so the case is unreachable there.
This issue was also reported by buildfarm member flaviventris.
Reported-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/CAEze2WgAJmWReDN7Chtba8Er2YBvKCoa0KVN25-1evnTrHsLyA@mail.gmail.com
Backpatch-through: 15 M src/backend/storage/ipc/procsignal.c
Fix 051_effective_wal_level.pl on builds without injection points.
commit : 47ad2233fad4335fdd866c8ad55941706ae1661d
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 27 May 2026 15:52:30 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 27 May 2026 15:52:30 -0700 Commit 2af1dc89282 placed the new "logical decoding disabled after
REPACK (CONCURRENTLY)" check at the end of
051_effective_wal_level.pl. That placement assumed the logical slot
"test_slot" no longer existed when the check ran, but the assumption
only holds on builds with injection points: the earlier
injection-point-driven tests drop "test_slot" as a side effect, while
on builds without injection points the slot persists. When
"test_slot" still exists, logical decoding remains enabled and the new
check fails on those buildfarm members.
Move the REPACK test earlier in the script, ensuring that the test
starts with logical decoding disabled.
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAD21AoBmdmBQ-+Jga+jSKKq5OPGEP1pEjSJfRPT6MCwVHLD6og@mail.gmail.com M src/test/recovery/t/051_effective_wal_level.pl
Disable logical decoding after REPACK (CONCURRENTLY)
commit : 2af1dc89282bea681201cf66e2bb32537294e623
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 27 May 2026 20:11:21 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 27 May 2026 20:11:21 +0200 REPACK (CONCURRENTLY) uses a temporary logical replication slot, which
is dropped once done, but it wasn't calling RequestDisableLogicalDecoding(),
leaving effective_wal_level stuck at 'logical'.
Fix by adding a Boolean flag to ReplicationSlotDropAcquired() to have it
request to disable logical decoding, and passing it as true on REPACK.
Other callers of that function preserve their existing behavior.
Author: Imran Zaheer <imran.zhir@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Discussion: https://postgr.es/m/CA+UBfaktds57dw2M8BEv_kS-=ixph3w+3MxKixtaDQMi_k7Ybg@mail.gmail.com M src/backend/commands/repack_worker.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/slot.c
M src/include/replication/slot.h
M src/test/recovery/t/051_effective_wal_level.pl
Fix NOTIFY wakeups for pre-commit LISTEN entries.
commit : 0f24332aeb4f43409c2a7bec9fef1e3317689bc5
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 27 May 2026 12:23:35 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 27 May 2026 12:23:35 -0400 Commit 282b1cde9 made SignalBackends() ignore ListenerEntry entries
whose "listening" flag said that the listener was not yet committed.
That will be true for a new listener that has already registered its
queue position, but has not yet reached AtCommit_Notify(). If another
backend notifies the same channel in that window, SignalBackends()
would directly advance the new listener's queue position, causing it
to miss message(s). Really this is a definitional question: is a new
listener active as of PreCommit, or as of AtCommit? But it seems to
make more sense to expect that the new listener will see all messages
after its initially-registered queue position, especially since the
direct-advance logic is supposed to be an optimization that doesn't
affect semantics.
Fix this by treating all channel entries as valid wakeup targets.
Rename the "listening" flag to removeOnAbort to reflect its remaining
purpose: identifying staged LISTEN entries that abort cleanup must
remove.
While we're here, remove an obsolete test case added by 282b1cde9.
The check for "ChannelHashAddListener array growth" was meant to
exercise code that never made it into the committed patch, so now
it's just a waste of test cycles.
Author: Joel Jacobson <joel@compiler.org>
Reviewed-by: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/9835b0a4-9121-47ac-9c44-427b8b1a7f1b@app.fastmail.com
Discussion: https://postgr.es/m/6fe5ee75-537d-4d4f-909a-b21303c3ce75@app.fastmail.com M src/backend/commands/async.c
M src/test/isolation/expected/async-notify.out
M src/test/isolation/specs/async-notify.spec
Avoid orphaned objects dependencies
commit : 2fbb21170e9053720c2c374b21eb650a22b8aaea
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 27 May 2026 18:35:58 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 27 May 2026 18:35:58 +0300 Concurrent DDL can leave behind objects referencing other objects that
no longer exist. This can happen if an object is dropped, while a new
object that depends on it is created concurrently. For example:
session 1: BEGIN; CREATE FUNCTION myschema.myfunc() ...;
session 2: DROP SCHEMA myschema;
session 1: COMMIT;
DROP SCHEMA does check that there are no objects dependending on the
schema being dropped, but it does not see objects being concurrently
created by other sessions. Even if it did, this scenario would still
fail:
session 1: BEGIN: DROP SCHEMA myschema;
session 2: CREATE FUNCTION myschema.myfunc() ...;
session 1: COMMIT;
When the DROP SCHEMA runs, the schema was empty, but the new function
is created in it before the dropping transaction completes. The CREATE
FUNCTION does not see that the schema is concurrently being dropped.
In both of these scenarios, the function is left behind in the schema
that no longer exists.
To fix, acquire AccessShareLock on all referenced objects when
recording dependencies. This conflicts with the AccessExclusiveLock
taken by DROP, preventing the race. After acquiring the lock, verify
that the object still exists, and if it was dropped concurrently,
report an error. We already had such a mechanism for shared
dependencies, but for some reason we didn't do it for in-database
dependendies.
Ideally the locks would be acquired much earlier when creating a new
object, but that will require modifying a lot of callers. This check
while recording the dependency is a nice wholesale protection, and
even if we change all the CREATE commands to acquire locks earlier,
it's still good to have this as a backstop to catch any cases where we
forgot to do so.
The patch adds a few tests for some cases that left behind orphaned
objects before this. It also adds a test for roles, which already had
such protection, although that test is partially disabled because the
error message includes an OID which is not predictable.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Discussion: https://postgr.es/m/ZiYjn0eVc7pxVY45@ip-10-97-1-34.eu-west-3.compute.internal
Backpatch-through: 14 M src/backend/catalog/pg_depend.c
A src/test/isolation/expected/ddl-dependency-locking.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/ddl-dependency-locking.spec
M src/test/regress/expected/alter_table.out
Don't try to record dependency on a dropped column's datatype
commit : fd93ee100830a1c0f4d292addd0a460cb48106a0
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 27 May 2026 18:35:55 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 27 May 2026 18:35:55 +0300 When creating a relation with a dropped column, we called
recordDependencyOn() also on the datatype of the dropped column, which
is always InvalidOid. In versions 15 and above, that was harmless
because recordDependencyOn() considers InvalidOid as a pinned object,
and skips over it. On version 14, isPinnedObject() does not consider
InvalidOid as pinned, so we created a bogus pg_depend entry with
refobjectid == 0.
As far as I can tell, the only case when AddNewAttributeTuples() is
called with dropped columns is when performing a table-rewriting ALTER
TABLE command. That temporarily creates a new relation with the same
columns, including dropped ones, then swaps the relations, and drops
the newly created table again. So even on version 14, the bogus
pg_depend entry was only on the transient relation that was dropped at
the end of the ALTER TABLE command, which was harmless.
Even though this is harmless, let's be tidy, similar to commit
713bce9484. The reason I noticed this now and why I backported this,
is because the next commit will add code to acquire locks on the
referenced objects, and we don't want to acquire a lock on InvalidOid.
Discussion: https://postgr.es/m/ZiYjn0eVc7pxVY45@ip-10-97-1-34.eu-west-3.compute.internal
Backpatch-through: 14 M src/backend/catalog/heap.c
Use strtoi64 instead of strtoll
commit : ee31868a535d1fbe0ddbb698c9c947a2067c2b6f
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 27 May 2026 17:12:27 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 27 May 2026 17:12:27 +0200 This is mostly for notational consistency, since the result is stored
in a variable of type int64. M contrib/pg_stash_advice/stashpersist.c
Remove incorrect OpenSSL feature guards
commit : c71b94f03304954e4352f96595254622b64f851c
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 27 May 2026 12:58:56 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 27 May 2026 12:58:56 +0200 Commit 316472146 introduced support for ECDH key exchange with an ifdef
guard to ensure support in the underlying OpenSSL installation. Commit
10bf4fc2c3 in OpenSSL removed this guard in 2015 which effectively made
our check a no-op. There has been no complaints that this doesn't work
and OpenSSL installations without ECDH support are likely very rare, so
remove the checks rather than re-implementing support. Not backpatched
since this fix doesn't alter functionality.
Also fix a typo introduced in the original commit which had survived
till this day.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: https://postgr.es/m/1787BA9F-A11C-4A7A-9252-94C470D5CBE3@yesql.se M src/backend/libpq/be-secure-openssl.c
M src/backend/libpq/be-secure.c
Fix procLatch ownership race in ProcKill()
commit : 84b9d6bceab6e6ec4ff49fa52a7fc90d85e3798c
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 27 May 2026 17:19:20 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 27 May 2026 17:19:20 +0900 DisownLatch() was executed after the PGPROC entry of the process
terminated is pushed back into a freelist. A newly-forked backend that
recycles the slot could call OwnLatch() and PANIC with a "latch already
owned by PID", taking down the server.
There were two scenarios related to lock groups where this issue could
be reached:
* A follower pushes the leader's PGPROC back to the freelist while the
leader has not yet called DisownLatch() in its own ProcKill().
* A leader outliving all its followers pushes its own PGPROC onto the
freelist before reaching DisownLatch(), which would be the most common
scenario.
This issue is fixed by calling SwitchBackToLocalLatch() and
DisownLatch() at an earlier phase of ProcKill(), before any freelist
manipulation happens, so that the slot of the backend terminated is
never exposed as owning a latch.
Note that pgstat_reset_wait_event_storage() is kept at a later stage.
An upcoming commit will take advantage of that by introducing a test
able to check the original PANIC scenario.
Author: Vlad Lesin <vladlesin@gmail.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/d2983796-2603-41b7-a66e-fc8489ddb954@gmail.com
Backpatch-through: 14 M src/backend/storage/lmgr/proc.c
Fix race conditions in ProcKill()'s lock-group freelist handling
commit : 56310452318cee4bb8c291be126ce0c2b2affa5f
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 27 May 2026 14:48:56 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 27 May 2026 14:48:56 +0900 This commit fixes two bugs in ProcKill()'s lock-group teardown freelist
publication:
* a double push of the leader's PGPROC that corrupts the freelist.
* a leak of the last follower's PGPROC slot.
ProcKill()'s lock-group teardown had two PGPROC freelist updates
scattered through the function, done under two separate freeProcsLock
acquisitions:
* A follower's push of the leader's PGPROC, done when a follower is the
last group member exiting.
* Every backend's self-push at the bottom of the function.
The two freelist updates were coordinated only by inspecting
proc->lockGroupLeader, which a follower could clear as a side effect of
pushing the leader. This coordination was broken. For example, with
two concurrent backends:
* The follower clears leader->lockGroupLeader and pushes the leader's
PGPROC under leader_lwlock.
* The follower does not clear its own proc->lockGroupLeader, being
skipped.
* When the leader reaches the bottom of ProcKill(), it sees a NULL
proc->lockGroupLeader (the follower cleared it) and pushes itself,
causing a second dlist_push_tail() of the same node onto the same
freelist.
* The follower at the bottom sees its own proc->lockGroupLeader being
not NULL (never cleared) and skips its own push, causing its own slot
to leak.
This commit refactors the freelist manipulation to be done in two
distinct phases, each step using its own lock acquisition to ensure that
each freelist operation happens in an isolated manner for each backend
(follower or leader):
- First, under a single leader_lwlock acquisition, check the state of
the lock-group. Depending on if we are dealing with a follower and/or a
leader, and if the leader has exited before a follower, then set some
state booleans that define which actions should be taken with the
freelist.
- Second, under a single freeProcsLock acquisition, perform the cleanup
actions, self-push of a backend and/or push of the leader back to the
freelist.
This is an old issue, dating back to 9.6 where parallel workers and lock
grouping has been added.
Author: Vlad Lesin <vladlesin@gmail.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/d2983796-2603-41b7-a66e-fc8489ddb954@gmail.com
Backpatch-through: 14 M src/backend/storage/lmgr/proc.c
pg_createsubscriber: Fix cleanup of publisher-side objects after errors
commit : 12d0004889e56d9883fafafc95c73a802307aaa7
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 27 May 2026 10:34:17 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 27 May 2026 10:34:17 +0900 When pg_createsubscriber fails after creating logical replication
objects, it should remove the publication and replication slot that
it created on the publisher.
Previously, if dropping subscriber-side objects failed,
pg_createsubscriber reset its internal cleanup state too early. As a
result, the exit-time cleanup could skip removing the publication or
replication slot on the publisher.
This could leave pg_createsubscriber-created objects behind on
the publisher after a failed run. That can make a retry harder,
because the leftover publication or replication slot may need to be
removed manually before running pg_createsubscriber again.
In the case of a replication slot, leaving it behind can also retain
WAL files longer than expected.
The cause of this issue was that the flags made_publication and
made_replslot tracking whether pg_createsubscriber created
a publication or replication slot on the primary were incorrectly
reset to false when failures occurred while dropping objects
on the subscriber.
This commit fixes the issue by preventing those cleanup flags from
being reset even when failures occurred while dropping objects
on the subscriber, ensuring proper cleanup of primary objects
before exit on failure.
Backpatch to v17, where pg_createsubscriber was added.
Author: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/CABdArM5V9QKK1PkLY9dpgAcZa3kUp84-wPqPovxvdLOri4=69w@mail.gmail.com
Backpatch-through: 17 M src/bin/pg_basebackup/pg_createsubscriber.c
doc: add comma to UPDATE docs, for consistency
commit : 9a41b34a28702a71cc0a0e77dd80ca80366d12fb
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 20:17:40 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 20:17:40 -0400 Reported-by: X-MAN
Author: X-MAN
Discussion: https://postgr.es/m/tencent_90A64D807DE3586650CF3426C28BB599D30A@qq.com M doc/src/sgml/ref/update.sgml
Clean up 019_replslot_limit.pl comments
commit : 0b866bb90368ba18a97772c21cd2e0952a16835d
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 27 May 2026 03:07:45 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 27 May 2026 03:07:45 +0300 Update stale comments and test names in 019_replslot_limit.pl to match
the actual WAL advancement and wal_status checks. Remove a redundant
standby stop in the inactive_since coverage.
Discussion: https://postgr.es/m/CABPTF7XxDonXAcz6DsN6AUJB3swYrZkJHq3UCDaD3Q2H%2Bj0gUA%40mail.gmail.com
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/test/recovery/t/019_replslot_limit.pl
Stabilize 019_replslot_limit.pl: wait on slot restart_lsn
commit : cdb1d1cf1de63b5dfecd5ebb23fd277b0e767f57
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 27 May 2026 02:54:04 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 27 May 2026 02:54:04 +0300 wait_for_catchup() has "wait for the standby to reach the target LSN"
semantics. However, the previous polling implementation actually waited for
the primary to observe that position via pg_stat_replication.
7e8aeb9e483 introduced the new WAIT FOR LSN-based implementation, which
just probes the standby.
019_replslot_limit.pl relied on the old side effect: its
"slot state changes to extended/unreserved" subtests inspect
primary-side pg_replication_slots, whose wal_status depends on
restart_lsn, which only advances after the walsender processes a
standby reply. Make the test wait on what it actually needs by
replacing each wait_for_catchup() with
wait_for_slot_catchup('rep1', 'restart', primary->lsn('write')).
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/63f6abc9-c0ae-465d-a4e6-667eca6ea008@gmail.com
Author: Xuneng Zhou <xunengzhou@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com> M src/test/recovery/t/019_replslot_limit.pl
Skip pg_database.dathasloginevt cleanup on standby
commit : bec61f59354e652598b4c8b52b4c022ebb616230
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 27 May 2026 02:26:50 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 27 May 2026 02:26:50 +0300 EventTriggerOnLogin() tries to clear pg_database.dathasloginevt when
the database no longer has any login event triggers but the flag is
still set. To make that safe against concurrent flag setters, it
takes a conditional AccessExclusiveLock on the database object.
On a hot standby, that lock acquisition fails outright with
FATAL: cannot acquire lock mode AccessExclusiveLock on database
objects while recovery is in progress
because LockAcquireExtended() refuses locks stronger than
RowExclusiveLock on database objects during recovery. The standby
already replays the flag's value from the primary, so the dangling
flag is the result of replaying a state in which the primary had
already dropped its login event triggers but not yet run a login
event trigger pass to clear the flag. Any session connecting to the
standby in that window therefore fails to connect.
Skip the cleanup on a standby. The flag will be cleared via WAL
replay once the primary clears it on its side.
Add a recovery TAP test that reproduces the original report: create
and drop a login event trigger on the primary in one session, wait
for the standby to replay, then verify that a fresh connection to
the standby succeeds.
Backpatch to v17, where the login event triggers were introduced.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reported-by: Egor Chindyaskin <kyzevan23@mail.ru>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/19488-d7ccfca2bf6b74b0%40postgresql.org
Backpatch-through: 17 M src/backend/commands/event_trigger.c
M src/test/recovery/meson.build
A src/test/recovery/t/053_standby_login_event_trigger.pl
Fix memory accumulation in pg_sync_replication_slots() during retries.
commit : 490259d0729007c40aff1f5255550154fb7afcbc
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 26 May 2026 15:16:12 -0700
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 26 May 2026 15:16:12 -0700 Unlike the slotsync worker, whose retry cycles are separated by
transaction boundaries, pg_sync_replication_slots() retries within a
single SQL function call. Per-cycle allocations for slot names, plugin
names, database names, and auxiliary list containers get accumulated
across retries until the function returned. Memory growth is proportional
to the number of retries and remote slots, and the function may wait an
extended period between cycles when slots are slow to persist.
Fix by running each retry cycle in a short-lived memory context
(sync_retry_ctx) that is reset before the next attempt. Additionally,
release tuple slots created with MakeSingleTupleTableSlot() before
clearing the walreceiver result.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VVPxgfYyr8Kyi=+JACjckQ6NpniV9eRtHboj2hMn0REw@mail.gmail.com M src/backend/replication/logical/slotsync.c
doc PG 19 relnotes: more fixes
commit : 8656ba7f71878eb16b2bcd6ec5d448dfb402bcfa
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 17:49:31 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 17:49:31 -0400 Reported-by: Thom Brown
Author: Thom Brown
Discussion: https://postgr.es/m/CAA-aLv7B7M9s5fZgCoWzXqer5RJ9jqG_k0h8t5QHFW=Qbxa=Eg@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: various corrections
commit : 1d751b4b6b0165f122cd14ff84e556e2d2ebcb1e
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 16:31:58 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 16:31:58 -0400 Reported-by: Thom Brown
Author: Thom Brown
Discussion: https://postgr.es/m/CAA-aLv7w1wwucet76yAW0yq3-LrN5wL81uRrnpT3Tyxh7dmyTw@mail.gmail.com M doc/src/sgml/release-19.sgml
Add stack depth check to QueueFKConstraintValidation().
commit : 61ea5cc6a61ff9eb8b3d7b055e507a726e5856c7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 26 May 2026 11:58:25 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 26 May 2026 11:58:25 -0400 QueueFKConstraintValidation() recurses through the partition hierarchy
to queue child constraint validations and to mark child rows as
validated. With a sufficiently deep partition tree, this can result
in a stack-overflow crash. Defend against that as we do elsewhere.
Bug: #19482
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19482-4cc37cbf52d55235@postgresql.org
Backpatch-through: 18 M src/backend/commands/tablecmds.c
Restructure repack worker teardown
commit : 1588d89af22f292e9ba44eaa33a14122e0754c3a
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 26 May 2026 17:24:06 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 26 May 2026 17:24:06 +0200 The original code would leave a shared memory segment unreleased if we
fail partway through initialization. Change the shutdown order so that
we always free it.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/agtNn6ZCmdI2KJFn@alvherre.pgsql M src/backend/commands/repack.c
doc PG 19 relnotes: adjust item to mention pg_replication_slots
commit : cfedd45133574df0328bc02a2486d969e91d1556
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 10:59:30 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 26 May 2026 10:59:30 -0400 Reported-by: Chong Peng
Author: Chong Peng
Discussion: https://postgr.es/m/CC2712F9-8457-4733-AA9D-7D7C9843B590@gmail.com M doc/src/sgml/release-19.sgml
Fix calculation of members_size in pg_get_multixact_stats()
commit : 6aa26be288fa811270dfc1e39c015c23a97688b4
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 26 May 2026 13:49:04 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 26 May 2026 13:49:04 +0900 pg_get_multixact_stats() uses members_size to report the amount of
storage used by the currently retained multixact members. However,
MultiXactOffsetStorageSize() divided the member count by the number of
members per storage group before multiplying by the group size, so it
was rounding down its result and incorrectly reported zero when there
were few retained members. The calculation is changed to calculate the
same based on the member count.
While on it, this fixes a different issue in the isolation test
multixact-stats. Three fields were defined for checks related to the
oldest offset values, but were not used. The offsets existed in an
older version of the patch than what has been committed. These are
replaced by checks for members_size, checking the new calculation
formula.
Thinkos introduced in 97b101776ce2.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/819AC1B2-1A71-4244-B081-3ADD85D1725D@gmail.com M src/include/access/multixact_internal.h
M src/test/isolation/expected/multixact-stats.out
M src/test/isolation/specs/multixact-stats.spec
Adjust some error hints
commit : d40aed554227e5f8203798fda25b936a264638ec
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 26 May 2026 08:13:22 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 26 May 2026 08:13:22 +0900 The wording of two error hints is tweaked in this commit:
- Import of extended statistics, where the value of an array element is
not a NULL or a string.
- Online data checksum switch, where a period was missing.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CA+fm-RMrKbyky_+vi5SDdAVnFVjWh7zW3GoDAVnrp5OpDnW6tw@mail.gmail.com M src/backend/access/transam/xlog.c
M src/backend/statistics/extended_stats_funcs.c
M src/test/regress/expected/stats_import.out
Fix missed ReleaseVariableStats() in intarray's _int_matchsel().
commit : 524cc0f638745489f55bafa12f3f93fe8944e027
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 25 May 2026 18:15:49 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 25 May 2026 18:15:49 -0400 Given a WHERE clause like "int[] @@ query_int" or "query_int ~~ int[]"
where the query_int side is a table column having statistics,
_int_matchsel() exited without remembering to free the statistics
tuple. This would typically lead to warnings about cache refcount
leakage, like
WARNING: resource was not closed: cache pg_statistic (73), tuple 42/12 has count 1
It's been wrong since this code was added, in commit c6fbe6d6f.
Bug: #19492
Reported-by: Man Zeng <zengman@halodbtech.com>
Author: Man Zeng <zengman@halodbtech.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19492-ddcd0e22399ef85a@postgresql.org
Backpatch-through: 14 M contrib/intarray/_int_selfuncs.c
dblink: Reject use_scram_passthrough on foreign-data wrappers
commit : e2b8813403b19609a3f194b1d4cdb88df5aa4c7d
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 26 May 2026 01:07:24 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 26 May 2026 01:07:24 +0900 Previously, dblink accepted the use_scram_passthrough option on
foreign-data wrappers via ALTER FOREIGN DATA WRAPPER dblink_fdw
OPTIONS, even though the setting had no effect there.
use_scram_passthrough should be only meaningful for foreign servers
and user mappings, so this commit updates dblink to accept the option
only in those contexts.
Backpatch to v18, where use_scram_passthrough was introduced.
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwEJ8rZjmbOvCicyr4vbuLio082bNTde0WNoSWaWr9wVcg@mail.gmail.com
Backpatch-through: 18 M contrib/dblink/dblink.c
M contrib/dblink/expected/dblink.out
M contrib/dblink/sql/dblink.sql
dblink: Give user mapping precedence for use_scram_passthrough
commit : 5f5165e2fe193cc2c9e9078992cdb277013e8dec
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 26 May 2026 00:51:18 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 26 May 2026 00:51:18 +0900 Commit 97f6fc10fff changed postgres_fdw so that user-mapping settings
override foreign server settings for use_scram_passthrough. This commit
applies the same behavior to dblink.
Backpatch to v18, where use_scram_passthrough was introduced.
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwEJ8rZjmbOvCicyr4vbuLio082bNTde0WNoSWaWr9wVcg@mail.gmail.com
Backpatch-through: 18 M contrib/dblink/dblink.c
M contrib/dblink/t/001_auth_scram.pl
M doc/src/sgml/dblink.sgml
postgres_fdw: Give user mapping precedence for use_scram_passthrough
commit : 97f6fc10fff0e42d08d78ce7f2a5b116e7f8d9b2
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 26 May 2026 00:46:31 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 26 May 2026 00:46:31 +0900 Previously, when use_scram_passthrough was specified on both a foreign server
and a user mapping, the server-level setting took precedence over the
user-mapping setting. This was inconsistent with the usual semantics of
postgres_fdw options, where foreign server options provide shared defaults
and user mapping options override them on a per-user basis.
This commit updates postgres_fdw so that the user-mapping setting takes
precedence when use_scram_passthrough is specified in both places. This
matches the behavior of other connection options such as sslcert and sslkey.
Backpatch to v18, where use_scram_passthrough was introduced. In v18,
this only affects limited configurations that specify conflicting values
at both the foreign server and user-mapping levels. In such cases, users
would naturally expect the user-mapping setting to override the server-level
setting, so changing the behavior should be minimally disruptive.
Also keeping v18 as the only branch with different semantics for
use_scram_passthrough would be unnecessarily confusing, so backpatch
this fix to v18.
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwEJ8rZjmbOvCicyr4vbuLio082bNTde0WNoSWaWr9wVcg@mail.gmail.com
Backpatch-through: 18 M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/t/001_auth_scram.pl
M doc/src/sgml/postgres-fdw.sgml
doc: Clarify CHECKPOINT handling of unlogged buffers
commit : 377cc45194f4f1bd6eb68bd6eb42402e46e326d7
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 25 May 2026 12:15:29 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 25 May 2026 12:15:29 +0200 The CHECKPOINT reference page still described checkpoints as flushing
all data files, which could be misleading as it depends on the value
of FLUSH_UNLOGGED option. Update the description to make it clearer
that only data files of permanent relations are flushed by default.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/4855807D-F1CA-44E6-9B58-406691832848@gmail.com M doc/src/sgml/ref/checkpoint.sgml
psql: Tab completion for CHECKPOINT FLUSH_UNLOGGED boolean options
commit : 7e5d8bd013e1fa3502d58de399815dedb81807c6
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 25 May 2026 11:57:14 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 25 May 2026 11:57:14 +0200 Tab completion for CHECKPOINT options contained FLUSH_UNLOGGED, but
the boolean value was not part of the completion. Fix to make this
consistent with other boolean values.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/4855807D-F1CA-44E6-9B58-406691832848@gmail.com M src/bin/psql/tab-complete.in.c
Reject degenerate SPLIT PARTITION with DEFAULT partition
commit : e64a9ba2b4fcd8956369ac6e2146ac816e590df2
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 25 May 2026 11:57:42 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 25 May 2026 11:57:42 +0300 ALTER TABLE ... SPLIT PARTITION allows a DEFAULT partition to be created
as one of the replacement partitions when the parent table does not
already have one. However, it should not allow the degenerate case where
a non-DEFAULT partition keeps exactly the same bound as the split
partition and the command merely adds a DEFAULT partition through the
SPLIT PARTITION path.
Detect that case by comparing the bound of the split partition with the
bound of the only non-DEFAULT replacement partition, and raise an error
when they are the same. Users should add a DEFAULT partition directly
with CREATE TABLE ... PARTITION OF ... DEFAULT or ALTER TABLE ... ATTACH
PARTITION ... DEFAULT instead.
The comparison goes through the partition operator family rather than
byte equality so that values which are binary-different but compare
equal under the partition key's comparator are treated as the same
bound. The corresponding regression test uses a float8 LIST partition
with -0.0 and 0.0 -- they have different bit patterns but are equal
under float8 -- to verify that a datumIsEqual()-based check would let
the degenerate split through while the partsupfunc-based check
correctly rejects it.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_split.sql
Fix size check in statext_dependencies_deserialize()
commit : 0b8fa5fd37b193c46a03aa5d2838f2c6af973782
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 25 May 2026 14:38:02 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 25 May 2026 14:38:02 +0900 The check for the minimum expected bytea size of a MVDependencies object
was using SizeOfItem() for its calculation. This macro uses the number
of attributes in a single dependency.
This minimum size calculation should be based on MinSizeOfItems(), that
computes the minimum expected size as the header plus the
minimally-sized number of dependency items.
Oversight in d08c44f7a4ec.
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Discussion: https://postgr.es/m/4b8d299d-2505-4c30-bf80-0f697410db35@tantorlabs.com
Backpatch-through: 14 M src/backend/statistics/dependencies.c
Revert "Allow logical replication snapshots to be database-specific"
commit : 01a80f062146af1b17b411c35cb8d992c487fa7c
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 23 May 2026 21:33:19 -0700
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 23 May 2026 21:33:19 -0700 This reverts commit 0d3dba38c777, which was determined to have
fundamental flaws. This restricts REPACK (CONCURRENTLY) so that only
one process can run it concurrently on different tables and even on
different databases; we'll lift that restriction in another way during
the next development cycle.
Reported-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAA4eK1Jg21ODQ7fS2fvN5W_S5kDRhAP5inj3XMRQaa=s-GbYhw@mail.gmail.com M contrib/pg_visibility/pg_visibility.c
M doc/src/sgml/logicaldecoding.sgml
M src/backend/access/index/genam.c
M src/backend/access/rmgrdesc/standbydesc.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogfuncs.c
M src/backend/postmaster/bgwriter.c
M src/backend/replication/logical/decode.c
M src/backend/replication/logical/logical.c
M src/backend/replication/logical/snapbuild.c
M src/backend/replication/pgrepack/pgrepack.c
M src/backend/replication/slot.c
M src/backend/storage/ipc/procarray.c
M src/backend/storage/ipc/standby.c
M src/include/access/xlog_internal.h
M src/include/miscadmin.h
M src/include/replication/output_plugin.h
M src/include/replication/snapbuild.h
M src/include/storage/procarray.h
M src/include/storage/standby.h
M src/include/storage/standbydefs.h
psql: Add missing IO option to EXPLAIN tab completion
commit : 2c4bd2bf5700db98be0602854a8b7fa2c16b5f4a
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 23 May 2026 09:39:58 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 23 May 2026 09:39:58 +0900 Commit 681daed9316 added EXPLAIN (IO) as a boolean option, but did
not update psql's tab completion to include it. Add IO to both the
option keyword list and the boolean ON/OFF completion.
Author: Afrah Razzak <mypg.afrah@gmail.com>
Reviewed-by: Zhenwei Shang <a934172442@gmail.com>
Discussion: https://postgr.es/m/CAAJ6gzGi9gK6nGjsGCch0nFPdd2+odWatTS1uAGwRDPbHkmSVQ@mail.gmail.com M src/bin/psql/tab-complete.in.c
Avoid exposing WAL receiver raw conninfo during timeline jumps
commit : c37b38806a1f7269a25caa9d90d67bf2da363842
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 23 May 2026 08:10:07 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 23 May 2026 08:10:07 +0900 When reusing an existing WAL receiver after it has reached
WALRCV_WAITING for new instructions, RequestXLogStreaming() copied
PrimaryConnInfo into WalRcv->conninfo before switching the state to
WALRCV_RESTARTING. At that point ready_to_display could still be true,
so pg_stat_wal_receiver could expose the raw connection string,
including sensitive fields, but it should only show the user-displayable
version of the connection string.
WALRCV_RESTARTING does not establish a new connection. The waiting WAL
receiver reuses its existing connection and only needs a new startpoint
and timeline, so there is no need to copy the raw connection string into
shared memory again. Let's only copy conninfo when launching a new WAL
receiver after WALRCV_STOPPED, not while waiting for instructions.
This commit adds coverage for the case fixed by this commit to the
timeline-switch test by verifying that the WAL receiver conninfo remains
consistent across the jump.
Backpatch all the way down, as this issue is possible since
pg_stat_wal_receiver has been introduced.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/EF91FF76-1E2B-4F3B-9162-290B4DC517FF@gmail.com
Backpatch-through: 14 M src/backend/replication/walreceiverfuncs.c
M src/test/recovery/t/004_timeline_switch.pl
Improve pg_stat_wal_receiver for CONNECTING status
commit : 7f469097c72e6f8988024eb9bc1b417bfeb29fd9
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 23 May 2026 04:04:26 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 23 May 2026 04:04:26 +0900 Commit a36164e7465 added a CONNECTING status for the WAL receiver, but
pg_stat_wal_receiver returned no information while the connection to the
primary was attempted, limiting the usability of the feature in
high-latency environments where the connection attempt to the primary
could take time.
This commit improves the report of the status by splitting the way the
shared memory state of the WAL receiver is filled before and after the
connection to the primary is attempted with walrcv_connect():
- Before the attempt, reset all the connection fields, switch
ready_to_display to true.
- After the attempt, fill in the connection fields.
This change means two spinlock acquisitions instead of one, but at least
monitoring tools can know about the connection attempt before its
completion, enlarging the usability of the feature. This code path is
taken only once when a WAL receiver is spawned, so the extra acquisition
does not matter performance-wise.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/EF91FF76-1E2B-4F3B-9162-290B4DC517FF@gmail.com M src/backend/replication/walreceiver.c
Set notice receiver before libpq connection startup completes
commit : 06a5c3cdef024630aef0992bb7b471459aa2b70f
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 23 May 2026 00:25:48 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 23 May 2026 00:25:48 +0900 Commit 112faf1378e added custom notice receivers for replication,
postgres_fdw, and dblink so that remote NOTICE, WARNING, and similar
messages are reported via ereport(). However, those notice receivers were
installed only after libpqsrv_connect() and libpqsrv_connect_params()
returned, by which point libpq connection startup had already completed.
As a result, messages emitted during connection establishment could be
missed.
This commit fixes the issue by splitting libpqsrv_connect() and
libpqsrv_connect_params() into separate start and complete phases:
libpqsrv_connect_start(), libpqsrv_connect_params_start(), and
libpqsrv_connect_complete(). This allows callers to perform
per-connection setup, such as installing a notice receiver, after the
connection has been started but before startup completes.
Note that callers of libpqsrv_connect_start() and
libpqsrv_connect_params_start() must still call
libpqsrv_connect_complete(), even if the start function returns NULL, so
that any external FDs reserved during startup are released properly.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>
Discussion: https://postgr.es/m/A2B8B7DE-C119-492F-A9FA-14CF86849777@gmail.com M contrib/dblink/dblink.c
M contrib/postgres_fdw/connection.c
M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/include/libpq/libpq-be-fe-helpers.h
Prevent setting NO INHERIT on partitioned NOT NULL constraints
commit : d8b5d87e545c340b129150d7214bff15275e2634
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 22 May 2026 23:59:04 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 22 May 2026 23:59:04 +0900 The documentation states that NOT NULL constraints on partitioned tables
are always inherited by all partitions, and therefore cannot be declared
NO INHERIT. While a check already existed to reject creating such
constraints with NO INHERIT, previously the same check was missing for
ALTER TABLE ... ALTER CONSTRAINT ... NO INHERIT.
This commit adds the missing check so that attempting to set NO INHERIT
on a partitioned NOT NULL constraint now fails.
Backpatch to v18, where ALTER TABLE ... ALTER CONSTRAINT ... [NO] INHERIT
was added.
Author: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/ecc985ad-6ec1-4094-a315-317943ca5f3f@proxel.se
Backpatch-through: 18 M src/backend/commands/tablecmds.c
M src/test/regress/expected/constraints.out
M src/test/regress/sql/constraints.sql
Revert "Reject degenerate SPLIT PARTITION with DEFAULT partition"
commit : 0392fb900eb89f52988cccd33046443c39c70d1c
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 20 May 2026 23:23:49 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 20 May 2026 23:23:49 +0300 This reverts commit d8af73010033cb8ad6c941942d6b03d74d7e4f7e. Per buildfarm
failures. M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_split.sql
Reject degenerate SPLIT PARTITION with DEFAULT partition
commit : d8af73010033cb8ad6c941942d6b03d74d7e4f7e
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 20 May 2026 14:32:57 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 20 May 2026 14:32:57 +0300 ALTER TABLE ... SPLIT PARTITION allows a DEFAULT partition to be created
as one of the replacement partitions when the parent table does not
already have one. However, it should not allow the degenerate case where
a non-DEFAULT partition keeps exactly the same bound as the split
partition and the command merely adds a DEFAULT partition through the
SPLIT PARTITION path.
Detect that case by comparing the bound of the split partition with the
bound of the only non-DEFAULT replacement partition, and raise an error
when they are the same. Users should add a DEFAULT partition directly
with CREATE TABLE ... PARTITION OF ... DEFAULT or ALTER TABLE ... ATTACH
PARTITION ... DEFAULT instead.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_split.sql
pg_recvlogical: Add tests for output file permissions
commit : d6a72bbe00254139b2a8cbec15eaf576f7b5d358
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 20 May 2026 16:01:56 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 20 May 2026 16:01:56 +0900 Commit 263d1e6dfee changed pg_recvlogical to honor source cluster file
permissions when creating output files. This commit adds tests verifying
that output files are created with mode 0600 when the source cluster is
initialized without group access, and with mode 0640 when group access is
enabled.
Author: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Author: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHhpizYzMo3nFP4GkNMueSNMY3QfC-gBN1VTXtuiANDvw@mail.gmail.com M src/bin/pg_basebackup/t/030_pg_recvlogical.pl
pg_recvlogical: Honor source cluster file permissions for output files
commit : 263d1e6dfeec5e573db4f78e6dac4bb17259c482
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 20 May 2026 15:54:13 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 20 May 2026 15:54:13 +0900 Commit c37b3d08ca6 attempted to preserve group permissions on pg_recvlogical
output files when group access was enabled on the source cluster. However,
the output files were still created with a fixed S_IRUSR | S_IWUSR mode,
preventing group-read permissions from being applied.
This commit fixes the issue by creating output files with pg_file_create_mode
instead of a hard-coded mode. This allows pg_recvlogical to correctly preserve
group permissions from the source cluster.
Backpatch to all supported branches.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHhpizYzMo3nFP4GkNMueSNMY3QfC-gBN1VTXtuiANDvw@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/pg_recvlogical.sgml
M src/bin/pg_basebackup/pg_recvlogical.c
Fix REPACK decoding worker not cleaned up on FATAL exit
commit : 0160143ad9a686a7e705348da1f90e63a2a31536
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 19 May 2026 11:37:46 -0700
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 19 May 2026 11:37:46 -0700 When the launching backend of REPACK (CONCURRENTLY) is terminated via
pg_terminate_backend(), ProcDiePending causes ereport(FATAL) which
bypasses PG_FINALLY blocks. As a result, stop_repack_decoding_worker()
is never called, leaving the decoding worker running indefinitely and
holding its temporary replication slot.
Fix by using PG_ENSURE_ERROR_CLEANUP, which handles both ERROR and
FATAL exits.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CA+fm-RNoPxL2N7db_A0anMXV_aDu6jWj4PNOPtMtBUAPDPvSXQ@mail.gmail.com M src/backend/commands/repack.c
Clarify SPLIT PARTITION bound requirements in docs
commit : 83df16f1fa5ccce72534ddad51fd0109da1e49e2
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 19 May 2026 13:39:53 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 19 May 2026 13:39:53 +0300 The documentation said that the bounds of new partitions should not
overlap and that their combined bounds should equal the bounds of the
split partition. That is misleading when a new DEFAULT partition is
specified, because the explicit partitions may cover only part of the
split partition while the DEFAULT partition covers the rest.
Clarify that new non-DEFAULT partition bounds must not overlap with
other new or existing partitions and must be contained within the bounds
of the split partition. Also state that the combined bounds must exactly
match the split partition only when no new DEFAULT partition is specified.
While here, improve nearby wording about hash-partitioned target tables
and splitting a DEFAULT partition with the same partition name.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com M doc/src/sgml/ref/alter_table.sgml
Fix SPLIT PARTITION hint for DEFAULT partition bounds
commit : 971017c49599b6666029ca46ee00378d8836f336
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 19 May 2026 13:39:39 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 19 May 2026 13:39:39 +0300 When ALTER TABLE ... SPLIT PARTITION specifies a DEFAULT partition, the
explicit partitions do not need to cover the split partition's bound
exactly. They may cover only part of it, with the DEFAULT partition
covering the remaining range.
However, the existing hint said that the combined bounds of the new
partitions must exactly match the bound of the split partition, which is
misleading for this case and inconsistent with the code comment.
Fix the hint to state the actual requirement: explicit partition bounds
must stay within the bounds of the split partition when a DEFAULT
partition is specified.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_split.out
Fix SPLIT PARTITION range bound validation with DEFAULT
commit : 9354896920e4b2efd3b1b88caaea4e0c9071acb2
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 19 May 2026 13:38:55 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 19 May 2026 13:38:55 +0300 When splitting a range partition and defining a new DEFAULT partition, the
validation checked the lower bound of the first explicit partition and the
upper bound of explicit partitions only when they were not first. If there
was exactly one explicit non-DEFAULT partition, its upper bound was therefore
not checked.
This could allow the replacement partition to extend beyond the upper bound
of the partition being split, potentially overlapping another existing
partition.
Fix this by checking the upper bound whenever the explicit partition is the
last one. Add a regression test covering the single explicit partition plus
DEFAULT case.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Zhenwei Shang <a934172442@gmail.com>
Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_split.sql
Fix COPY FROM ON_ERROR SET_NULL with selective column list
commit : 1164a822729a496baedfc4068a6c86e247d5934e
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 19 May 2026 10:11:41 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 19 May 2026 10:11:41 +0900 When using COPY FROM ... ON_ERROR SET_NULL with a selective column list, the
domain_with_constraint array was incorrectly allocated based on the length of
the target column list. While the array was populated sequentially,
CopyFromTextLikeOneRow attempted to access it using the physical attribute
index (attnum - 1). This mismatch caused out-of-bounds reads when targeting
high-numbered columns, allowing NULL values to bypass NOT NULL domain checks
and be silently inserted.
Fix by allocating the array to match the total number of physical attributes
(num_phys_attrs) and indexing via attnum - 1, bringing it into alignment with
other per-column arrays in BeginCopyFrom.
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDdej0c0gWJi2FnbirzhgzyZNPiTwC1P5B_-dSNCzq-91A@mail.gmail.com M src/backend/commands/copyfrom.c
M src/test/regress/expected/copy2.out
M src/test/regress/sql/copy2.sql
Remove support for 8 byte tear free read/write on 32-bit
commit : 801b9962e787b4159b38defee3458738e0349d96
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:59:59 -0700
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:59:59 -0700 The macro for enabling single-copy atomicity on i586+ when using
GCC has been incorrect since 2017 (commit e8fdbd58f) without any
complaints, and getting it to work is non-trivial.
Getting this to work reliably require C11 atomics, which in turn
also bumps the required MSVC version. For now, simply remove the
attempted support which doesn't work anyways.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reported-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAKZiRmycHOOJyEPc9FUss1_69_U62WoSx32jT7wyES-YkStZKA@mail.gmail.com
Discussion: https://posrgr.es/m/CA+hUKGKFvu3zyvv3aaj5hHs9VtWcjFAmisOwOc7aOZNc5AF3NA@mail.gmail.com M src/include/port/atomics/arch-x86.h
Remove obsolete comment in AtEOXact_Inval
commit : 15b140d465b6cd3380ca58d1d9b878a6a94f94d8
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:43:12 -0700
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:43:12 -0700 This comment was originally added to RegisterInvalid() in POSTGRES before
Postgres95, and came in via the Postgres95 import. It has been obsolote
for quite some time so remove.
Author: Steven Niu <niushiji@highgo.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/MN2PR15MB30219837B2381AE2518A4C45A7FCA@MN2PR15MB3021.namprd15.prod.outlook.com M src/backend/utils/cache/inval.c
psql: Make ParseVariableDouble reject values above max
commit : e04910a9a2a3f20c8139efd4fa4a6cdf00f3d3bd
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:33:36 -0700
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:33:36 -0700 ParseVariableDouble missed returning false after logging an error when
the parsed value exceeded max, making the value assigned rather than
rejected. Backpatch down to v18 where this was introduced as part of
the \WATCH_INTERVAL.
Author: Sven Klemm <sven@tigerdata.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAMCrgp31p_5SDVi7dwnP39tTW5icQ0MWHA+N4kJdXgkL0PEy8w@mail.gmail.com
Backpatch-through: 18 M src/bin/psql/t/001_basic.pl
M src/bin/psql/variables.c
oauth: Fix missing quote in errormessage
commit : aa7eb23aca31dbf0263e32c4fbf85ad824a642df
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:03:09 -0700
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 18 May 2026 08:03:09 -0700 The error message for incorrect oauth validator configuration was missing
a quote character. OAuth was introduced in v18 but there is no need for a
backpatch since this was introduced in 22f9207aaa37.
Author: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/ff9b84b9e6d5a3fef1f320ee5d63ec7dae722739.camel@gmail.com M src/backend/libpq/auth-oauth.c
Fix issues with handling of expressions in extended stats restore
commit : a28fa2947d2a507089605c47bbfa9016d457208c
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 18 May 2026 13:18:35 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 18 May 2026 13:18:35 +0900 This commit addresses some defects with the handling of expressions in
pg_restore_extended_stats() and pg_clear_extended_stats():
- Misleading WARNING for an incorrect number of expressions, where the
number of required expressions was reported as the number of elements
given in input rather than the actual number of expressions expected by
the extstats object definition.
- Incorrect matching of expression names, where a key name was
considered as valid as long as it matched with the prefix of a legit key
name. For example "correlatio" given in input would match with
"correlation", and be considered valid. The consequence of this bug was
a silent discard of the input data, where the operation would be
considered a success. The value associated to the prefixed key was not
inserted in the catalogs, just ignored. pg_dump would not generate such
input data patterns, but a user doing manual stats injection could.
- Missing heap_freetuple() in pg_clear_extended_stats(), for the case
where the extstats object in input does not match with its parent
relation.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/A7C11B83-7534-4A09-9071-FBD09175CFC8@gmail.com 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 parsing of REPACK options
commit : a120ecf549853da9fda32e4f80ecd8060531d7b5
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 18 May 2026 13:14:49 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 18 May 2026 13:14:49 +0900 Previously, REPACK option parsing had two bugs.
First, REPACK (CONCURRENTLY OFF) failed with:
ERROR: unrecognized REPACK option "concurrently"
while CONCURRENTLY ON was accepted correctly.
Second, when the same option was specified multiple times, the last value
specified was not always honored. If any occurrence set the option to ON,
the option was treated as enabled even when the final setting was OFF.
This commit fixes these issues by correctly accepting CONCURRENTLY
regardless of its value, and by making the last specified value take precedence
when an option appears multiple times.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAHGQGwGAY4kfDtC4i+hAOX-a3u0yOA6__6EDTQz-ytsDHgh-yQ@mail.gmail.com M src/backend/commands/repack.c
Fix IGNORE NULLS nullness cache for volatile window arguments.
commit : 26269fe3c83beed1601e3bd156a98cf7696e9e08
author : Tatsuo Ishii <ishii@postgresql.org>
date : Mon, 18 May 2026 12:09:37 +0900
committer: Tatsuo Ishii <ishii@postgresql.org>
date : Mon, 18 May 2026 12:09:37 +0900 The IGNORE NULLS implementation caches whether a window function argument
evaluated to NULL or NOT NULL for a given partition row. That is safe for
ordinary expressions, but not for volatile expressions, where evaluating the
same argument on the same row can produce a different NULL/NOT NULL result
later.
This could produce wrong results in two ways. A row previously cached as
NULL could be skipped even though a later evaluation would return NOT NULL.
Conversely, a row cached as NOT NULL could be chosen as the target row, then
re-evaluated to fetch the actual value and return NULL.
Make the nullness cache conditional per argument. Do not use it for
arguments containing volatile functions or subplans, following the same
conservative approach used for moving window aggregates. Also avoid
re-evaluating non-cacheable partition arguments after the scan has already
found the target row.
Add regression tests covering volatile arguments and subplan arguments with
IGNORE NULLS.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://postgr.es/m/42B42506-6972-4266-8422-FB73E61D9DA7@gmail.com M src/backend/executor/nodeWindowAgg.c
M src/test/regress/expected/window.out
M src/test/regress/sql/window.sql
injection_points: Move some structs to new header injection_points.h
commit : e7b416b2fa444ca93d0ef1bd22b02747255733f7
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 18 May 2026 11:11:40 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 18 May 2026 11:11:40 +0900 This commit moves the definitions of InjectionPointConditionType and
InjectionPointCondition into a new header local to the test module
injection_points.h, so as these can be shared across more files in the
module. A patch for a bug fix is under discussion, whose proposed test
will benefit from this refactoring.
Backpatch down to where the module exists, as this should be useful for
future bug fixes, even cases unrelated to the thread where this change
has been discussed.
Author: Andrey Borodin <x4mmm@yandex-team.ru>
Author: Vlad Lesin <vladlesin@gmail.com>
Discussion: https://postgr.es/m/d2983796-2603-41b7-a66e-fc8489ddb954@gmail.com
Backpatch-through: 17 M src/test/modules/injection_points/injection_points.c
A src/test/modules/injection_points/injection_points.h
Use ereport(ERROR), not Assert(), for publisher tuples missing columns.
commit : bf7d19be9b18f6f78bd95052a2704259021e6806
author : Noah Misch <noah@leadboat.com>
date : Sat, 16 May 2026 18:01:35 -0700
committer: Noah Misch <noah@leadboat.com>
date : Sat, 16 May 2026 18:01:35 -0700 Three locations use Assert() to guard against a mismatch between the
number of columns advertised in the RELATION message and the number
actually received in the subsequent INSERT/UPDATE tuple message. Since
these values originate from the publisher, the check must survive into
production builds.
A malicious or buggy publisher can send a RELATION claiming N columns
and an INSERT claiming M < N columns. The subscriber's apply worker
indexes into colvalues[]/colstatus[] using column indices from the
RELATION message's attribute map, causing a heap out-of-bounds read when
the tuple's column array is smaller than expected. We've looked, without
success, for a scenario in which the publisher holds sufficient control
over these out-of-bounds bytes to exploit this or even to reach a
SIGSEGV. Despite not finding one, the code has been fragile. Back-patch
to v14 (all supported versions).
Reported-by: Varik Matevosyan <varikmatevosyan@gmail.com>
Author: Varik Matevosyan <varikmatevosyan@gmail.com>
Discussion: https://postgr.es/m/CA+bBoog3cCogktzfLb9bppUByu-10B3CFp8u=iKXG_OvtAguCw@mail.gmail.com
Backpatch-through: 14 M src/backend/replication/logical/worker.c
Simplify signature of ProcessStartupPacket()
commit : 3dcd85d1b96151529718cc195d85d4ce4e0c1ccb
author : Michael Paquier <michael@paquier.xyz>
date : Sun, 17 May 2026 07:44:17 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sun, 17 May 2026 07:44:17 +0900 There is now only one caller of ProcessStartupPacket(). Let's simplify
the routine so as the GSS and SSL states are tracked inside it. If
future callers are added, there is less guessing to do.
Suggested-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/aga7lCWluyc5zLb5@paquier.xyz M src/backend/tcop/backend_startup.c
doc: Fix example of pg_restore_extended_stats()
commit : 4111b91ab3d5ad3afc22370168fcb3622de8a098
author : Michael Paquier <michael@paquier.xyz>
date : Sun, 17 May 2026 07:36:04 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sun, 17 May 2026 07:36:04 +0900 Oversight in ba97bf9cb7b4, probably due to an incorrect rebase.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/8A72720A-55AC-4D41-B9DF-5610307600E6@gmail.com M doc/src/sgml/func/func-admin.sgml
pg_test_timing: Show additional TSC clock source debug info
commit : 5ba34f6dc838a1bc4415dc179be5bb2cf3b6d549
author : Andres Freund <andres@anarazel.de>
date : Sat, 16 May 2026 11:51:34 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sat, 16 May 2026 11:51:34 -0400 In some cases its necessary to understand whether TSC frequency data was
sourced from CPUID, and which of the registers. Show this debug info at
the end of pg_test_timing, and rework TSC functions to support that.
This would have helped debug the buildfarm report fixed in 7fc36c5db550
and is likely going to aid in any TSC-related issues reported during the
beta period or later.
Additionally, emit a warning if TSC frequency from calibration differs
by more than 10% from the TSC frequency in use, and suggest the use
of timing_clock_source = 'system'.
In passing, add an explicit early return in the output function if the
loop count is zero. This can't happen in practice, but coverity complained
because we unconditionally call output for the fast TSC measurement.
Author: Lukas Fittl <lukas@fittl.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (coverity fix only)
Discussion: https://postgr.es/m/CAP53Pkw3Gzb+KTF5pu_o7tzbfZ7+qm2m6uDWuGtTJjZpV9yNpg@mail.gmail.com M doc/src/sgml/ref/pgtesttiming.sgml
M src/bin/pg_test_timing/pg_test_timing.c
M src/common/instr_time.c
M src/include/port/pg_cpu.h
M src/include/portability/instr_time.h
M src/port/pg_cpu_x86.c
M src/tools/pgindent/typedefs.list
postgres_fdw: Replace buffers in RemoteAttributeMapping with pointers.
commit : aa1f93a3387ad619c14cea2b8ed01e6f49cb6600
author : Etsuro Fujita <efujita@postgresql.org>
date : Sat, 16 May 2026 17:55:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Sat, 16 May 2026 17:55:00 +0900 Commit 28972b6fc ("Add support for importing statistics from remote
servers.") stored the names of local/remote columns for a foreign table
into the buffers of NAMEDATALEN bytes in this structure, without
accounting for the possibility that the remote column name in particular
could be longer than NAMEDATALEN - 1. If it was longer than that, this
would leave it unterminated/truncated in the buffer, invoking undefined
behavior when match_attrmap() processes it, which assumes that it's
fully-contained/terminated in the buffer.
To fix, replace the buffers with char pointers, pstrdup the local/remote
column names, and store the results into the pointers. This commit also
adds a function to clean up the nested data structure.
Per Coverity and Tom Lane.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/342868.1776017700%40sss.pgh.pa.us M contrib/postgres_fdw/postgres_fdw.c
Check retain_dead_tuples for ALTER SUBSCRIPTION ... SERVER.
commit : 8eba2edb80102ac7d16c0335caca62e11adc8072
author : Jeff Davis <jdavis@postgresql.org>
date : Fri, 15 May 2026 15:52:33 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Fri, 15 May 2026 15:52:33 -0700 Previously, the subscription setting retain_dead_tuples didn't cause
ALTER SUBSCRIPTION ... SERVER to check the publisher. And if the
publisher was checked for some other reason, then it would use the old
conninfo.
Fix ALTER SUBSCRIPTION ... SERVER to always check the publisher when
retain_dead_tuples is set, and to use the new connection info, like
ALTER SUBSCRIPTION ... CONNECTION.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/f13a8e29410bbbf9999290f2c04513a8884fa51c.camel@j-davis.com M src/backend/commands/subscriptioncmds.c
Don't accept length of -1 in pg_locale.h APIs.
commit : 6d22c67c3bf5b50565062a35cbfc46075fb9c276
author : Jeff Davis <jdavis@postgresql.org>
date : Fri, 15 May 2026 11:09:15 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Fri, 15 May 2026 11:09:15 -0700 Reverts ac30021356. Per discussion, that commit interfered with useful
tooling, and was not worth the special cases.
Suggested-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/s32n3tm2mjh247f3xkkxkdk7cf77hglbr3ia3hrsdjylajou7y@nlldpag3tjd5 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/common/unicode/case_test.c
M src/common/unicode_case.c
M src/include/common/unicode_case.h
M src/include/utils/pg_locale.h
doc PG 19 relnotes: remove "Add fake LSN support to hash index"
commit : 41b60bf172efb552eaa437b90327ef1c626587e6
author : Bruce Momjian <bruce@momjian.us>
date : Fri, 15 May 2026 13:26:50 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Fri, 15 May 2026 13:26:50 -0400 Also add missing commit link to json_array() item.
Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzm1UAuv9ih6_ATbwbmrmusKPoJ2qSo3HBF-JaUEkVYUPg@mail.gmail.com M doc/src/sgml/release-19.sgml
Re-add regression tests for ltree and intarray
commit : 27bdae84137f35af42ca5ae4f0507dfb8c69db60
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 15 May 2026 14:27:30 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 15 May 2026 14:27:30 +0900 These tests have been removed by 906ea101d0d5, due to some of them being
unstable in the buildfarm with low max_stack_depth values. They are now
reworked so as they should be more portable.
The tests to cover the findoprnd() overflows use a balanced tree to
avoid using too much stack, per a suggestion and an investigation by Tom
Lane.
Note: This is initially applied only on HEAD; a backpatch will follow
should the buildfarm be fine with the situation.
Discussion: https://postgr.es/m/agZc6XecyE7E7fep@paquier.xyz
Backpatch-through: 14 M contrib/intarray/expected/_int.out
M contrib/intarray/sql/_int.sql
M contrib/ltree/expected/ltree.out
M contrib/ltree/sql/ltree.sql
psql: Fix tab completion for REPACK boolean options
commit : e5035950dab7fdce23185f21e96b4cc8f16d58e6
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 15 May 2026 14:24:45 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 15 May 2026 14:24:45 +0900 Previously, tab completion for REPACK parenthesized boolean options
(ANALYZE, CONCURRENTLY, and VERBOSE) did not suggest the boolean values
ON and OFF, unlike VACUUM.
This commit fixes the issue by adding ON/OFF completion for those options.
Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CA+fm-RNZpy7MAceR9gSyy833H_uL-fTx0LxO73RnvwEaprpuRA@mail.gmail.com M src/bin/psql/tab-complete.in.c
doc PG 19 relnotes: update to current
commit : 6b48f5d1a74168c78badfb2e59ef788bb8eb396e
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 14 May 2026 16:37:28 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 14 May 2026 16:37:28 -0400 M doc/src/sgml/release-19.sgml
refint: Fix segfault in check_foreign_key().
commit : 611756948eef3a3a1babc3418fc254077528b679
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 14 May 2026 13:11:49 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 14 May 2026 13:11:49 -0500 When an UPDATE statement triggers check_foreign_key() with the
action set to "cascade", it generates more UPDATE statements to
modify the key values in referencing relations. If a new key value
is NULL, SPI_getvalue() returns a NULL pointer, which is
subsequently passed to quote_literal_cstr(), causing a segfault.
To fix, skip quoting when a new key value is NULL and insert an
unquoted NULL keyword instead.
Oversight in commit 260e97733b. While the refint documentation
recommends marking primary key columns NOT NULL, the aforementioned
scenario accidentally worked on platforms where snprintf()
substitutes "(null)" for NULL pointers. Note that for
character-type columns, the old code quoted "(null)" as a string
literal, so this didn't always produce correct results. But it
still seems better to fix this than to reject cases that previously
worked.
Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Pierre Forstmann <pierre.forstmann@gmail.com>
Discussion: https://postgr.es/m/19476-bd04ea6241345303%40postgresql.org
Backpatch-through: 14 M contrib/spi/refint.c
Fix attribute mapping for COPY TO on partitioned tables.
commit : 82f0135a2630cc4465a8a424e38faf0f4e92f421
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 14 May 2026 10:32:34 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 14 May 2026 10:32:34 -0700 Commit 4bea91f21f61 enabled COPY TO on a partitioned table to read
tuples from its partitions and mapped them to the root table's tuple
descriptor before output. However, it incorrectly built the attribute
map from the root table to the partition.
This commit fixes by building the attribute map from the partition to
the root table, ensuring that partition attributes are correctly
mapped to their corresponding root attributes.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/85EA70F3-C3DB-477B-B856-EA569FDAAE7C@gmail.com M src/backend/commands/copyto.c
M src/test/regress/expected/copy.out
M src/test/regress/sql/copy.sql
Prevent access to other sessions' temp tables
commit : ce146621f7860d2e19c509f1466feca3bf777678
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 14 May 2026 12:25:19 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 14 May 2026 12:25:19 +0300 Commit b7b0f3f2724 ("Use streaming I/O in sequential scans") routed
sequential scans through read_stream_next_buffer(), bypassing the
RELATION_IS_OTHER_TEMP() check in ReadBufferExtended(). As a result,
a superuser can attempt to read or modify temp tables of other
sessions through the read-stream path. When the query plan uses no index,
SELECT/UPDATE/DELETE/MERGE silently see no rows / report zero affected rows,
and COPY produces an empty output -- because the buffer manager has no
visibility into the owning session's local buffers and silently returns
nothing. Any query plan that uses, for instance, a btree index
still errors out via the existing check in ReadBufferExtended(), which
is reached from hio.c and nbtree respectively, but this is incidental.
Fix by enforcing RELATION_IS_OTHER_TEMP() at the three additional
buffer-manager entry points:
- read_stream_begin_impl() rejects the read at stream setup time,
covering sequential and bitmap scans that go through the
read-stream path.
- ReadBuffer_common() becomes the canonical place for the check,
consolidating the existing one previously kept in
ReadBufferExtended(). All ReadBufferExtended() callers go through
ReadBuffer_common(), so the consolidation is behavior-preserving.
- StartReadBuffersImpl() catches direct callers of StartReadBuffers()
that bypass both of the above. This is currently defense-in-depth,
but documents the contract for future code.
The companion test in src/test/modules/test_misc was added in the
preceding commit; this commit updates the assertions for SELECT,
UPDATE, DELETE, MERGE, and COPY (which previously documented the
bug as silent success) to expect the new error.
Author: Jim Jones <jim.jones@uni-muenster.de>
Author: Daniil Davydov <3danissimo@gmail.com>
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Soumya S Murali <soumyamurali.work@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJDiXghdFcZ8%3Dnh4G69te7iRr3Q0uFyXxb3ZdG09_GTNZXwH0g%40mail.gmail.com
Backpatch-through: 17 M src/backend/storage/aio/read_stream.c
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
Add tests for cross-session temp table access
commit : 1fee0e857e330d148cf14b8d6027d02111841cf8
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 14 May 2026 12:21:03 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 14 May 2026 12:21:03 +0300 Add a TAP test in src/test/modules/test_misc that documents what
happens when one session attempts to read or modify another session's
temporary table. This commit only adds tests; it does not change
backend behavior, so the assertions reflect current behavior:
- SELECT, UPDATE, DELETE, MERGE, COPY on a table without an index
silently succeed with no error and zero rows / zero affected rows.
These commands run through the read-stream path, which currently
bypasses the RELATION_IS_OTHER_TEMP() check. This is the
underlying bug to be fixed in a follow-up.
- INSERT errors with "cannot access temporary tables of other
sessions" because hio.c calls ReadBufferExtended() to find a page
with free space and is caught by the existing check there.
- Index scan errors via the same existing check, reached through
nbtree -> ReadBuffer -> ReadBufferExtended.
- TRUNCATE / ALTER TABLE / ALTER INDEX / CLUSTER fail with their
command-specific error messages.
- VACUUM is silently skipped to avoid noise during database-wide
VACUUM (vacuum_rel() returns without warning).
- DROP TABLE is intentionally allowed: DROP does not touch the
table's contents, and autovacuum relies on this to clean up
temp relations orphaned by a crashed backend.
- ALTER FUNCTION / DROP FUNCTION on an owner-created function over
its own temp row type work as catalog operations -- they don't
read the underlying data.
- CREATE FUNCTION from a separate session, using another session's
temp row type as an argument, is allowed but emits a NOTICE: the
function is moved into the creator's pg_temp namespace with an
auto-dependency on the borrowed type, so it disappears together
with the session that created it.
- A bare DROP TABLE on a temp table that has a cross-session
dependent function fails with a catalog-level dependency error.
- LOCK TABLE in ACCESS SHARE mode on another session's temp table
succeeds and properly blocks the owner's session-exit cleanup
(which acquires AccessExclusiveLock via findDependentObjects).
This exercises the same LockRelationOid path used by autovacuum
when cleaning up orphaned temp relations.
- When the owner session ends, the normal session-exit cleanup
cascades through DEPENDENCY_NORMAL and removes both the temp
objects and any cross-session functions that depended on them.
Also, document the contract for RELATION_IS_OTHER_TEMP() so that
future buffer-access entry points enforce the same rule.
Backpatch this through PostgreSQL 17, where b7b0f3f27241 introduces a code
path bypassing this check.
Author: Jim Jones <jim.jones@uni-muenster.de>
Author: Daniil Davydov <3danissimo@gmail.com>
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Soumya S Murali <soumyamurali.work@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJDiXghdFcZ8%3Dnh4G69te7iRr3Q0uFyXxb3ZdG09_GTNZXwH0g%40mail.gmail.com
Backpatch-through: 17 M src/include/utils/rel.h
M src/test/modules/test_misc/meson.build
A src/test/modules/test_misc/t/013_temp_obj_multisession.pl
postgres_fdw: Fix deparsing of remote column names in stats import.
commit : 5107398e6d5ecad96f3d1c0efcfc9aa02b9cdff9
author : Etsuro Fujita <efujita@postgresql.org>
date : Thu, 14 May 2026 17:05:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Thu, 14 May 2026 17:05:00 +0900 build_remattrmap() deparses a list of remote column names for a query
that retrieves attribute stats for them from the remote server.
Previously, it did so by using the array-literal syntax with each column
name individually quoted by quote_identifier(), causing the query to
fail on the remote server with a syntax error or no results when that
column name included a single quote or backslash, as quote_identifier()
doesn't escape those characters, making the query invalid or incorrect.
Fix by switching from the array-literal syntax to the ARRAY constructor
syntax with each column name individually quoted by
deparseStringLiteral().
Oversight in commit 28972b6fc.
Reported-by: Satya Narlapuram <satyanarlapuram@gmail.com>
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Alex Guo <guo.alex.hengchen@gmail.com>
Reviewed-by: Zhenwei Shang <a934172442@gmail.com>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/CAHg%2BQDc9%3DWtYi%3DJW6QUL6ASOJc6PcGPTuxoMkhnkQ7oi7j5atg%40mail.gmail.com
Discussion: https://postgr.es/m/CAJTYsWWGhVDFjr%2BsmdYdU-Q_TT9YMzXA4QcLCr7rizDOyrEEow%40mail.gmail.com M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/sql/postgres_fdw.sql
Fix jsonpath .split_part() to honor silent mode
commit : 954e57708ea6996e8948ccb820ed03d0262fc2d2
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 14 May 2026 16:02:07 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 14 May 2026 16:02:07 +0900 The jsonpath .split_part() method passed its field-position argument
through numeric_int4(), that can fail hard if called directly.
This commit switches the code to use numeric_int4_safe() with an error
context for soft reporting, so as the overflow and zero field-position
cases can be handled in silent mode.
Oversight in bd4f879a9cdd.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/FCF996D0-580B-431C-8DE1-A540C58E444C@gmail.com M src/backend/utils/adt/jsonpath_exec.c
M src/test/regress/expected/jsonb_jsonpath.out
M src/test/regress/sql/jsonb_jsonpath.sql
pgbench: fix verbose error message corruption with multiple threads
commit : 61f8a85a577fd0ea0bf924a88064187bed31eb48
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 14 May 2026 12:30:34 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 14 May 2026 12:30:34 +0900 When pgbench runs with multiple threads and verbose error reporting is
enabled (--verbose-errors), multiple clients can build verbose error
messages concurrently. Previously, a function-local static
PQExpBuffer was used for these messages, causing the buffer to be
shared across threads. This was not thread-safe and could result in
corrupted or incorrect log output.
Fix this by using a local PQExpBufferData instead of a static buffer.
This keeps verbose error messages correct during concurrent execution.
Backpatch to v15, where this issue was introduced.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Alex Guo <guo.alex.hengchen@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwER1AjGXpkKB9t9820NBhMQ_Ghv7=HsKeodUr3=SZsF4g@mail.gmail.com
Backpatch-through: 15 M src/bin/pgbench/pgbench.c
Add several commits to .git-blame-ignore-revs.
commit : 0c025ab347dc37c93620ad3d040227d9ac0e32b2
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 13 May 2026 14:53:48 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 13 May 2026 14:53:48 -0500 M .git-blame-ignore-revs
Fix style in a few REPACK ereports
commit : 3bf63730cb041a834c618082ba3d5e8bf96a31a5
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 13 May 2026 18:28:31 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 13 May 2026 18:28:31 +0200 Use consistent "REPACK (CONCURRENTLY)" naming in errhint messages,
matching the actual command syntax and the errmsg text used elsewhere
in the same file. Also improve the ereport() after XLogReadRecord
failure to be like others in the tree.
While at it, remove direct mentions of the DDL in the translatable
strings, both in the same errhint() calls as well as some errmsg()
calls. Add periods where missing.
There are all oversights in 28d534e2ae0a.
Reported-by: Baji Shaik <baji.pgdev@gmail.com>
Discussion: https://postgr.es/m/CA+fm-RPxX1xTcYY4qQGPRDXB2-Fy2SDNdZi=zVjr0j=MPg2PaA@mail.gmail.com M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
M src/test/regress/expected/cluster.out
Use "grep -E" not "egrep".
commit : 2122281672b4505c6fa391899d8af2318770a102
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 12:07:19 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 12:07:19 -0400 "egrep" has never been in POSIX; the standard way to access this
functionality is "grep -E". Recent versions of GNU grep have
started to warn about this, so stop using "egrep".
This could be back-patched, but I see little need to do so
because the affected places are not code that runs during
normal builds. (Perhaps src/backend/port/aix/mkldexport.sh
is an exception, but let's wait to see if any AIX users
complain before touching that.)
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/473272.1778685870@sss.pgh.pa.us M doc/src/sgml/func/func-matching.sgml
M src/backend/port/aix/mkldexport.sh
M src/tools/find_typedef
M src/tools/perlcheck/find_perl_files
Pre-beta updates: run src/tools/copyright.pl.
commit : b94989e73d570587dc67a49f1f8c485e3ff240d0
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 11:01:57 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 11:01:57 -0400 As usual, post-1-Jan patches missed some copyright-year updates. M src/test/modules/test_aio/t/003_initdb.pl
M src/test/modules/test_aio/t/TestAio.pm
M src/test/ssl/t/004_sni.pl
Do pre-release housekeeping on catalog data.
commit : c7cb8e5b73c6d090f60320ddd7e15f6aeda180c1
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:54:44 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:54:44 -0400 Run renumber_oids.pl to move high-numbered OIDs down, as per pre-beta
tasks specified by RELEASE_CHANGES. For reference, the command was
./renumber_oids.pl --first-mapped-oid 8000 --target-oid 6400
(but there were already some used OIDs at 6400, so the first one
actually assigned was 6434). M src/include/catalog/catversion.h
M src/include/catalog/pg_operator.dat
M src/include/catalog/pg_opfamily.dat
M src/include/catalog/pg_proc.dat
M src/include/catalog/pg_propgraph_element.h
M src/include/catalog/pg_propgraph_element_label.h
M src/include/catalog/pg_propgraph_label.h
M src/include/catalog/pg_propgraph_label_property.h
M src/include/catalog/pg_propgraph_property.h
M src/include/catalog/pg_type.dat
Add preceding commits to .git-blame-ignore-revs.
commit : 652ae1a520dbf4c213008c88a168abacf5f2a4e4
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:44:36 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:44:36 -0400 M .git-blame-ignore-revs
Pre-beta mechanical code beautification, step 3: run reformat-dat-files.
commit : 719fe0779d8d116bf8ee06056fed4c1257f1744c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:41:33 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:41:33 -0400 M src/include/catalog/pg_aggregate.dat
M src/include/catalog/pg_proc.dat
M src/include/catalog/pg_range.dat
M src/include/catalog/pg_type.dat
Pre-beta mechanical code beautification, step 2: run pgperltidy.
commit : 736a97bddd16f0511dc62b7e4770376a34f10114
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:37:42 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:37:42 -0400 It's as opinionated as ever. M contrib/auto_explain/t/001_auto_explain.pl
M contrib/pg_prewarm/t/001_basic.pl
M contrib/pg_stash_advice/t/001_persist.pl
M src/backend/storage/lmgr/generate-lwlocknames.pl
M src/bin/pg_combinebackup/t/011_ib_truncation.pl
M src/bin/pg_ctl/t/001_start_stop.pl
M src/bin/pg_dump/t/001_basic.pl
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/pg_dump/t/005_pg_dump_filterfile.pl
M src/bin/pg_upgrade/t/003_logical_slots.pl
M src/bin/pg_upgrade/t/004_subscription.pl
M src/bin/pg_upgrade/t/006_transfer_modes.pl
M src/bin/pg_verifybackup/t/007_wal.pl
M src/bin/pg_verifybackup/t/008_untar.pl
M src/bin/pg_verifybackup/t/010_client_untar.pl
M src/bin/pg_waldump/t/001_basic.pl
M src/bin/pgbench/t/001_pgbench_with_server.pl
M src/bin/psql/t/001_basic.pl
M src/bin/scripts/t/020_createdb.pl
M src/bin/scripts/t/100_vacuumdb.pl
M src/interfaces/libpq/t/006_service.pl
M src/test/authentication/t/001_password.pl
M src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
M src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
M src/test/modules/test_aio/t/002_io_workers.pl
M src/test/modules/test_cloexec/t/001_cloexec.pl
M src/test/modules/test_extensions/t/001_extension_control_path.pl
M src/test/modules/test_misc/t/003_check_guc.pl
M src/test/modules/test_misc/t/010_index_concurrently_upsert.pl
M src/test/modules/test_misc/t/012_ddlutils.pl
M src/test/modules/test_plan_advice/t/001_replan_regress.pl
M src/test/modules/test_shmem/t/001_late_shmem_alloc.pl
M src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
M src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/perl/PostgreSQL/Test/Utils.pm
M src/test/postmaster/t/003_start_stop.pl
M src/test/postmaster/t/004_negotiate.pl
M src/test/recovery/t/013_crash_restart.pl
M src/test/recovery/t/035_standby_logical_decoding.pl
M src/test/recovery/t/040_standby_failover_slots_sync.pl
M src/test/recovery/t/046_checkpoint_logical_slot.pl
M src/test/recovery/t/051_effective_wal_level.pl
M src/test/ssl/t/SSL/Server.pm
M src/test/subscription/t/023_twophase_stream.pl
M src/test/subscription/t/035_conflicts.pl
M src/test/subscription/t/036_sequences.pl
M src/tools/add_commit_links.pl
Pre-beta mechanical code beautification, step 1: run pgindent.
commit : 020794ee42a3413b416898e7931a8a3a5b43e9ab
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:34:17 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:34:17 -0400 Update typedefs.list from the buildfarm, and run pgindent.
The changes from the new typedefs list are pretty minimal,
since we'd been pretty good (not perfect) about updating
typedefs.list by hand. But the pgindent behavior changes
installed by a3e6beba6, b518ba4af, and 60f9467c3 add up
to make this a relatively sizable diff. M contrib/amcheck/verify_common.c
M contrib/btree_gist/btree_gist.c
M contrib/btree_gist/btree_utils_num.c
M contrib/btree_gist/btree_utils_var.c
M contrib/cube/cube.c
M contrib/dblink/dblink.c
M contrib/fuzzystrmatch/daitch_mokotoff.c
M contrib/fuzzystrmatch/dmetaphone.c
M contrib/fuzzystrmatch/fuzzystrmatch.c
M contrib/intarray/_int_gist.c
M contrib/intarray/_int_op.c
M contrib/intarray/_intbig_gist.c
M contrib/isn/isn.c
M contrib/jsonb_plpython/jsonb_plpython.c
M contrib/pgcrypto/crypt-blowfish.c
M contrib/pgcrypto/crypt-gensalt.c
M contrib/pgcrypto/px.c
M contrib/pgcrypto/px.h
M contrib/postgres_fdw/postgres_fdw.c
M contrib/seg/seg.c
M contrib/spi/moddatetime.c
M contrib/xml2/xpath.c
M src/backend/access/gin/gininsert.c
M src/backend/access/index/amvalidate.c
M src/backend/access/nbtree/nbtreadpage.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogreader.c
M src/backend/backup/basebackup_incremental.c
M src/backend/backup/walsummary.c
M src/backend/catalog/aclchk.c
M src/backend/catalog/heap.c
M src/backend/commands/analyze.c
M src/backend/commands/copyto.c
M src/backend/commands/tablecmds.c
M src/backend/executor/nodeAppend.c
M src/backend/executor/nodeBitmapAnd.c
M src/backend/executor/nodeBitmapOr.c
M src/backend/executor/nodeMergeAppend.c
M src/backend/executor/nodeModifyTable.c
M src/backend/executor/nodeWindowAgg.c
M src/backend/lib/rbtree.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/libpq/pqformat.c
M src/backend/optimizer/geqo/geqo_copy.c
M src/backend/optimizer/geqo/geqo_cx.c
M src/backend/optimizer/geqo/geqo_erx.c
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_mutation.c
M src/backend/optimizer/geqo/geqo_ox1.c
M src/backend/optimizer/geqo/geqo_ox2.c
M src/backend/optimizer/geqo/geqo_pmx.c
M src/backend/optimizer/geqo/geqo_pool.c
M src/backend/optimizer/geqo/geqo_px.c
M src/backend/optimizer/geqo/geqo_recombination.c
M src/backend/optimizer/geqo/geqo_selection.c
M src/backend/parser/parse_clause.c
M src/backend/parser/parse_coerce.c
M src/backend/parser/parse_func.c
M src/backend/parser/parse_oper.c
M src/backend/parser/parse_relation.c
M src/backend/partitioning/partbounds.c
M src/backend/port/win32/signal.c
M src/backend/replication/logical/applyparallelworker.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/logicalfuncs.c
M src/backend/storage/file/fd.c
M src/backend/storage/ipc/dsm_registry.c
M src/backend/utils/activity/pgstat_io.c
M src/backend/utils/adt/cash.c
M src/backend/utils/adt/date.c
M src/backend/utils/adt/datetime.c
M src/backend/utils/adt/ddlutils.c
M src/backend/utils/adt/formatting.c
M src/backend/utils/adt/geo_ops.c
M src/backend/utils/adt/int.c
M src/backend/utils/adt/int8.c
M src/backend/utils/adt/lockfuncs.c
M src/backend/utils/adt/pgstatfuncs.c
M src/backend/utils/adt/selfuncs.c
M src/backend/utils/adt/timestamp.c
M src/backend/utils/adt/varchar.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/error/elog.c
M src/backend/utils/error/jsonlog.c
M src/backend/utils/mb/mbutils.c
M src/backend/utils/misc/guc.c
M src/backend/utils/mmgr/bump.c
M src/backend/utils/mmgr/slab.c
M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_combinebackup/load_manifest.c
M src/bin/pg_ctl/pg_ctl.c
M src/bin/pg_dump/common.c
M src/bin/pg_dump/filter.c
M src/bin/pg_dump/filter.h
M src/bin/pg_dump/pg_backup.h
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_archiver.h
M src/bin/pg_dump/pg_backup_custom.c
M src/bin/pg_dump/pg_backup_directory.c
M src/bin/pg_dump/pg_backup_tar.c
M src/bin/pg_upgrade/exec.c
M src/bin/pg_upgrade/parallel.c
M src/bin/pg_upgrade/pg_upgrade.h
M src/bin/pg_upgrade/server.c
M src/bin/pg_upgrade/util.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_verifybackup/pg_verifybackup.h
M src/bin/pg_walsummary/pg_walsummary.c
M src/bin/pgbench/pgbench.c
M src/bin/psql/common.c
M src/bin/psql/large_obj.c
M src/bin/psql/startup.c
M src/bin/psql/stringutils.h
M src/bin/psql/tab-complete.in.c
M src/common/jsonapi.c
M src/common/logging.c
M src/common/percentrepl.c
M src/common/psprintf.c
M src/common/sha2.c
M src/common/stringinfo.c
M src/common/wchar.c
M src/fe_utils/option_utils.c
M src/include/access/amapi.h
M src/include/access/amvalidate.h
M src/include/backup/walsummary.h
M src/include/catalog/pg_db_role_setting.h
M src/include/common/blkreftable.h
M src/include/common/fe_memutils.h
M src/include/common/hashfn_unstable.h
M src/include/common/logging.h
M src/include/common/parse_manifest.h
M src/include/common/percentrepl.h
M src/include/executor/tuptable.h
M src/include/fe_utils/conditional.h
M src/include/fe_utils/option_utils.h
M src/include/fmgr.h
M src/include/jit/llvmjit_emit.h
M src/include/lib/stringinfo.h
M src/include/libpq/pg-gssapi.h
M src/include/optimizer/geqo.h
M src/include/optimizer/geqo_copy.h
M src/include/optimizer/geqo_gene.h
M src/include/optimizer/geqo_misc.h
M src/include/optimizer/geqo_mutation.h
M src/include/optimizer/geqo_pool.h
M src/include/optimizer/geqo_random.h
M src/include/optimizer/geqo_recombination.h
M src/include/optimizer/geqo_selection.h
M src/include/port.h
M src/include/postgres.h
M src/include/tsearch/ts_type.h
M src/include/utils/datetime.h
M src/include/utils/elog.h
M src/include/utils/palloc.h
M src/include/utils/tuplestore.h
M src/interfaces/ecpg/compatlib/informix.c
M src/interfaces/ecpg/ecpglib/descriptor.c
M src/interfaces/ecpg/ecpglib/ecpglib_extern.h
M src/interfaces/ecpg/ecpglib/execute.c
M src/interfaces/ecpg/ecpglib/misc.c
M src/interfaces/ecpg/include/ecpgerrno.h
M src/interfaces/ecpg/include/ecpglib.h
M src/interfaces/ecpg/pgtypeslib/dt.h
M src/interfaces/ecpg/pgtypeslib/dt_common.c
M src/interfaces/ecpg/pgtypeslib/interval.c
M src/interfaces/ecpg/pgtypeslib/pgtypeslib_extern.h
M src/interfaces/ecpg/pgtypeslib/timestamp.c
M src/interfaces/ecpg/preproc/descriptor.c
M src/interfaces/ecpg/preproc/preproc_extern.h
M src/interfaces/ecpg/preproc/type.c
M src/interfaces/ecpg/preproc/type.h
M src/interfaces/ecpg/preproc/util.c
M src/interfaces/ecpg/preproc/variable.c
M src/interfaces/libpq/fe-exec.c
M src/interfaces/libpq/fe-misc.c
M src/interfaces/libpq/libpq-fe.h
M src/interfaces/libpq/libpq-int.h
M src/interfaces/libpq/pqexpbuffer.c
M src/interfaces/libpq/pqexpbuffer.h
M src/pl/plpython/plpy_elog.c
M src/pl/plpython/plpy_elog.h
M src/pl/plpython/plpy_exec.c
M src/pl/plpython/plpy_spi.c
M src/pl/plpython/plpython_system.h
M src/port/dirmod.c
M src/port/inet_aton.c
M src/port/open.c
M src/port/pqsignal.c
M src/port/snprintf.c
M src/port/strlcat.c
M src/port/strsep.c
M src/port/win32security.c
M src/test/locale/test-ctype.c
M src/test/modules/libpq_pipeline/libpq_pipeline.c
M src/test/modules/test_tidstore/test_tidstore.c
M src/test/regress/pg_regress.c
M src/test/regress/regress.c
M src/timezone/localtime.c
M src/timezone/zic.c
M src/tools/pgindent/typedefs.list
M src/tutorial/complex.c
pgindent: improve formatting of multiline comments.
commit : 60f9467c38348e06ad96815d4394651dd02a0389
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:21:54 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:21:54 -0400 Enforce this standard formatting of multiline comments that start
in column 1:
/*
* line 1
* line 2
*/
Unlike indented comments, we don't reconsider line breaks, except
for forcing the initial /* and trailing */ onto their own lines.
We do make each line start with " *", with some whitespace following.
We preserve pgindent's existing behavior of not touching comments
that begin with /**... or /*-... Also, if the first line looks like
/* === or /* ---, we don't split that line; similarly for the last
line.
The vast majority of multiline comments in our tree already look
like this, but this change will clean up some stragglers.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reported-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJ7c6TPQ0kkHQG-AqeAJ3PV_YtmDzcc7s%2B_V4%3Dt%2BxgSnZm1cFw%40mail.gmail.com
Discussion: https://postgr.es/m/EB0141C5-ACC2-4F0B-85EA-0E3AFBCE322F@umbc.edu M src/tools/pgindent/pgindent
Make pg_bsd_indent add a space between comma and period.
commit : b518ba4affed8d3a47944d769d33b7814d88ddb2
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:17:57 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 13 May 2026 10:17:57 -0400 Formatting of variadic functions and struct literals with named fields
used to be ugly due to pg_bsd_indent treating period as always being a
binary operator. After a comma, it's not that, so insert a space.
Bump pg_bsd_indent's version so that people who use out-of-tree
copies will know they need to update. (This also covers the other
pg_bsd_indent behavioral change introduced in a3e6beba6.)
Author: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/c3327be8-09e2-46a1-88b4-228a339d6916@proxel.se M src/tools/pg_bsd_indent/args.c
M src/tools/pg_bsd_indent/indent.c
M src/tools/pg_bsd_indent/tests/declarations.0.stdout
M src/tools/pg_bsd_indent/tests/struct.0
M src/tools/pg_bsd_indent/tests/struct.0.stdout
M src/tools/pgindent/pgindent
pgindent: Fix spacing after != when member name matches typedef.
commit : a3e6beba60ec4e6804e91200e407d046414f18de
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 13 May 2026 09:10:50 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 13 May 2026 09:10:50 -0500 When a struct member name matches a registered typedef, pgindent
removes the space after "!=" (and some other operators), like so:
entry->dsh.dsa_handle !=DSA_HANDLE_INVALID
The problem is that the related code in lexi.c sets last_u_d to
true before jumping to found_typename, causing the next operator to
be classified as unary and suppressing the following space. This
is correct for type names, but not for struct members. For
example, "Datum *x" needs "*" to be unary to suppress the space
before "x". To fix, only set last_u_d before jumping to
found_typename if the typedef name doesn't appear after "." or
"->".
Note that this does not bump INDENT_VERSION. We'll do that just
once after some other changes to pg_bsd_indent are committed.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/aS9hkwnkWf3dZIA_%40nathan M src/tools/pg_bsd_indent/lexi.c
Fix FOR PORTION OF with non-updatable view columns
commit : 7ca8c9429675b34600e679525da6b5280c1cafa5
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 13 May 2026 13:34:09 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 13 May 2026 13:34:09 +0200 Both UPDATE and DELETE were failing to test that the application-time
column was updatable. The column is not part of
perminfo->updatedCols, because it should not be checked for
permissions. And it needs to be checked in the DELETE case as well,
since we might insert leftovers with a value for that column.
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Co-authored-by: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/CACJufxFRqg8%3DgbZ-Q6ZS_UQ%2BYdwfZpk%2B9rf7jgWrk8m4RMUm%3DA%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
pg_stat_statements: Set PlannedStmt to NULL after nested utility execution
commit : 66366217822e23a00251f6ba3743d8e5675fcfc2
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 13 May 2026 15:39:44 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 13 May 2026 15:39:44 +0900 As mentioned in 8268e41aca23, pgss_ProcessUtility() may free the
PlannedStmt after an internal ROLLBACK. This commit sets the
PlannedStmt "pstmt" to NULL once it is no longer safe to rely on it,
making bugs similar to the one fixed by the previous commit easier to
detect.
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/0A9A8DAC-BC3C-4C7A-9504-2C6050405544@anarazel.de M contrib/pg_stat_statements/pg_stat_statements.c
Add more tests for corrupted data with pglz_decompress()
commit : 900c07b854a7d7549ea4116aaafbb02bc610553a
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 13 May 2026 14:43:42 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 13 May 2026 14:43:42 +0900 Two cases fixed by 2b5ba2a0a141 were not covered, to emulate the
handling of corrupted data, for:
- set control bit with a valid 2-byte match tag where offset is 0.
- set control bit with a valid 2-byte match tag where offset exceeds
output written.
Oversight in 67d318e70402.
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/agF4xkIdRcrCIprs@paquier.xyz
Backpatch-through: 14 M src/test/regress/expected/compression_pglz.out
M src/test/regress/sql/compression_pglz.sql
Fix stale COPY progress during logical replication table sync
commit : 422e54e3092afd09997d27cc7c99598f91075b0d
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 13 May 2026 11:44:31 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 13 May 2026 11:44:31 +0900 Previously, pg_stat_progress_copy in the subscriber could continue to show
the initial COPY operation for logical replication table synchronization as
active even after the data copy had finished. The stale progress entry
remained visible until synchronization caught up with the publisher.
This happened because the table synchronization code called BeginCopyFrom()
and CopyFrom(), but failed to call EndCopyFrom() afterward.
This commit fixes the issue by adding the missing EndCopyFrom() call so that
the COPY progress state in the subscriber is cleared as soon as the initial
data copy completes.
Backpatch to all supported branches.
Author: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAOzEurQKuy3RiPkd=25PEwEzaqHuGvEOf=X7vaVzhgNjaukYzA@mail.gmail.com
Backpatch-through: 14 M src/backend/replication/logical/tablesync.c
psql: save/restore truePrint/falsePrint printQueryOpt values
commit : 34be85f65746da83cebaf874f236605c28ec0fe5
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 12 May 2026 18:28:20 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 12 May 2026 18:28:20 -0400 Reported-by: a.kozhemyakin
Author: David G. Johnston
Discussion: https://postgr.es/m/83e247ed-0b2d-4aba-bc42-e7bbc20be0d6@postgrespro.ru M src/bin/psql/command.c
doc PG 19 relnotes: add two optimizer hooks
commit : cac0f24eb57f628c59e026e5b924f9d9ee4d7353
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 12 May 2026 16:16:14 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 12 May 2026 16:16:14 -0400 Reported-by: Jian He
Discussion: https://postgr.es/m/CACJufxE8Ew_DCXtd1VZSC=pNPHqZRa4RJkbCr7z6ZPJJ3o3hGQ@mail.gmail.com M doc/src/sgml/release-19.sgml
De-obfuscate the comment in tsrank.c's calc_rank_or().
commit : 163f20ca12a9f83aff68c47e9ab94f0856800dd5
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 12 May 2026 15:04:42 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 12 May 2026 15:04:42 -0400 Oleg's original comment was intelligible only to him.
Aleksander has reverse-engineered what seems like a plausible
explanation of what the code is trying to do, so replace the
comment with that. (Also, re-order the final expression to
match the new comment.)
In passing, this makes the comment satisfy our usual formatting
conventions. pgindent has let it pass as-is so far, but planned
changes would mess it up without some sort of intervention.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAJ7c6TO0xvunpeOv89i1eKQBhKF9=GEETkTz+yAGs1xGYH25MQ@mail.gmail.com M src/backend/utils/adt/tsrank.c
doc PG 19 relnotes: remove "Optionally" for CPU optimizations
commit : 06fccab4c61b4c3555fbbdb9da1290bcde1ddb50
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 12 May 2026 15:13:46 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 12 May 2026 15:13:46 -0400 Reported-by: John Naylor
Discussion: https://postgr.es/m/CANWCAZZWfdoMcemSaTMon+e6aCkSABN3+sco0aStC90cFPVE4A@mail.gmail.com M doc/src/sgml/release-19.sgml
Add psql tab completion for FOR PORTION OF clause
commit : 7b22f15a015ff57507cd9c8cfa0b9741b33cc0bd
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 12 May 2026 17:19:15 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 12 May 2026 17:19:15 +0200 Add tab completion support in psql for the FOR PORTION OF clause
used in UPDATE and DELETE statements with temporal tables.
For both UPDATE and DELETE, completion now guides users through:
<table> FOR -> PORTION -> OF -> <column> -> FROM
Author: Kiran Kaki <itskkpg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAD0dvCQLqLzPrQJRjjA2qXDH%3DD%2BXShcxhbSPxNhVruC8HGhkbQ%40mail.gmail.com M src/bin/psql/t/010_tab_completion.pl
M src/bin/psql/tab-complete.in.c
pg_stat_statements: Fix potential use-after-free of PlannedStmt
commit : 8268e41aca23ae3414360b0a1dc6ae99ea7b43f4
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 12 May 2026 13:36:38 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 12 May 2026 13:36:38 +0900 pgss_ProcessUtility() included a reference to a portion of a PlannedStmt
after the point where this data's structure could have been freed,
causing an incorrect memory access. There was a comment documenting
this requirement, missed in 3357471cf9f5.
This commit includes a test able to make valgrind complain with a
PlannedStmt freed by an internal ROLLBACK query. Similarly to what is
mentioned in 495e73c2079e, this can be triggered by using the extended
query protocol, something that can be now tested thanks to the recent
meta-command additions in psql. This commit mentions potential other
cases, but as far as I can see the extended protocol case with an
internal ROLLBACK is the only problematic pattern reachable in practice.
Issue introduced by 3357471cf9f5, gone unnoticed due to a lack of test
coverage. The fix is authored by Chao, my contribution being the new
test.
Author: Chao Li <li.evan.chao@gmail.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/2F91906A-F2B5-4A6B-9695-D136957D4545@gmail.com M contrib/pg_stat_statements/expected/plancache.out
M contrib/pg_stat_statements/pg_stat_statements.c
M contrib/pg_stat_statements/sql/plancache.sql
doc PG 19 relnotes: adjustments/removal of items
commit : 8974a7c433d363b729c5b2379ff849e2e60dffbe
author : Bruce Momjian <bruce@momjian.us>
date : Mon, 11 May 2026 17:43:15 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Mon, 11 May 2026 17:43:15 -0400 Reported-by: John Naylor
Discussion: https://postgr.es/m/CANWCAZZWfdoMcemSaTMon+e6aCkSABN3+sco0aStC90cFPVE4A@mail.gmail.com M doc/src/sgml/release-19.sgml
Use palloc_array() in a few more places to avoid overflow
commit : c3f7dde39e940c86cccc179e8cbe188966e4e3ec
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 11 May 2026 21:18:06 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 11 May 2026 21:18:06 +0300 These could overflow on 32-bit systems.
Backpatch-through: 14
Security: CVE-2026-6473 M contrib/hstore_plperl/hstore_plperl.c
M contrib/hstore_plpython/hstore_plpython.c
Fix REPACK with WITHOUT OVERLAPS replica identity indexes
commit : 36f52a59b31502213a01fb4b0a89afc0f3bfd21d
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 11 May 2026 18:17:46 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 11 May 2026 18:17:46 +0200 REPACK replay builds scan keys for the replica identity index, but it
hard-coded BTEqualStrategyNumber when looking up the equality operator.
That is not correct for non-btree identity indexes, such as the GiST
indexes created for WITHOUT OVERLAPS primary keys. In addition,
find_target_tuple() accepted the first tuple returned by the identity
index scan, which is unsafe for lossy index scans because the index AM may
return false positives with xs_recheck set.
Fix this by using IndexAmTranslateCompareType() to translate COMPARE_EQ
to the equality strategy number for the index AM, and by continuing the
scan when recheck is required until a candidate tuple matches the locator
tuple on all replica identity key columns.
The recheck uses the same equality operator functions as the identity
index scan keys, preserving ScanKey argument ordering.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/7B0EC0EC-5461-41EF-9B31-F9BBE608DEA5@gmail.com M src/backend/commands/repack.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/repack_temporal.out
A src/test/modules/injection_points/expected/repack_temporal_multirange.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/repack_temporal.spec
A src/test/modules/injection_points/specs/repack_temporal_multirange.spec
Remove test cases for field overflows in intarray and ltree.
commit : 906ea101d0d58a0b78bbe67be5fe54976c0a21e6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 12:12:03 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 12:12:03 -0400 These checks are failing in the buildfarm, reporting stack overflows
rather than the expected errors, though seemingly only on ppc64 and
s390x platforms. Perhaps there is something off about our tests
for stack depth on those architectures? But there's no time to
debug that right now, and surely these tests aren't too essential.
Revert for now and plan to revisit after the release dust settles.
Backpatch-through: 14
Security: CVE-2026-6473 M contrib/intarray/expected/_int.out
M contrib/intarray/sql/_int.sql
M contrib/ltree/expected/ltree.out
M contrib/ltree/sql/ltree.sql
refint: Fix SQL injection and buffer overruns.
commit : 260e97733bf09acc448faea24fc6210411892b1a
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 Maliciously crafted key value updates could achieve SQL injection
within check_foreign_key(). To fix, ensure new key values are
properly quoted and escaped in the internally generated SQL
statements. While at it, avoid potential buffer overruns by
replacing the stack buffers for internally generated SQL statements
with StringInfo.
Reported-by: Nikolay Samokhvalov <nik@postgres.ai>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Security: CVE-2026-6637
Backpatch-through: 14 M contrib/spi/refint.c
Mark PQfn() unsafe and fix overrun in frontend LO interface.
commit : bd48114937c8af9cb86972e2b576924a761359cf
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 When result_is_int is set to 0, PQfn() cannot validate that the
result fits in result_buf, so it will write data beyond the end of
the buffer when the server returns more data than requested. Since
this function is insecurable and obsolete, add a warning to the top
of the pertinent documentation advising against its use.
The only in-tree caller of PQfn() is the frontend large object
interface. To fix that, add a buf_size parameter to
pqFunctionCall3() that is used to protect against overruns, and use
it in a private version of PQfn() that also accepts a buf_size
parameter.
Reported-by: Yu Kunpeng <yu443940816@live.com>
Reported-by: Martin Heistermann <martin.heistermann@unibe.ch>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Security: CVE-2026-6477
Backpatch-through: 14 M doc/src/sgml/libpq.sgml
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-int.h
Fix integer overflow in array_agg(), when the array grows too large
commit : 6d68fcb28f9180289d1910d3fa7fca2d32021730
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 If you accumulate many arrays full of NULLs, you could overflow
'nitems', before reaching the MaxAllocSize limit on the allocations.
Add an explicit check that the number of items doesn't grow too large.
With more than MaxArraySize items, getting the final result with
makeArrayResultArr() would fail anyway, so better to error out early.
Reported-by: Xint Code
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/utils/adt/arrayfuncs.c
Fix integer-overflow and alignment hazards in locale-related code.
commit : b2869ebc43bd0ce7c0e73a15730d77644aebaf8e
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 pg_locale_icu.c was full of places where a very long input string
could cause integer overflow while calculating a buffer size,
leading to buffer overruns.
It also was cavalier about using char-type local arrays as buffers
holding arrays of UChar. The alignment of a char[] variable isn't
guaranteed, so that this risked failure on alignment-picky platforms.
The lack of complaints suggests that such platforms are very rare
nowadays; but it's likely that we are paying a performance price on
rather more platforms. Declare those arrays as UChar[] instead,
keeping their physical size the same.
pg_locale_libc.c's strncoll_libc_win32_utf8() also had the
disease of assuming it could double or quadruple the input
string length without concern for overflow.
Reported-by: Xint Code
Reported-by: Pavel Kohout <pavel.kohout@aisle.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/utils/adt/pg_locale_icu.c
M src/backend/utils/adt/pg_locale_libc.c
Prevent path traversal in pg_basebackup and pg_rewind
commit : a1063eecedf379de5dad73f9bd6e856ad5c114fb
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 pg_rewind and pg_basebackup could be fed paths from rogue endpoints that
could overwrite the contents of the client when received, achieving path
traversal.
There were two areas in the tree that were sensitive to this problem:
- pg_basebackup, through the astreamer code, where no validation was
performed before building an output path when streaming tar data. This
is an issue in v15 and newer versions.
- pg_rewind file operations for paths received through libpq, for all
the stable branches supported.
In order to address this problem, this commit adds a helper function in
path.c, that reuses path_is_relative_and_below_cwd() after applying
canonicalize_path(). This can be used to validate the paths received
from a connection point. A path is considered invalid if any of the two
following conditions is satisfied:
- The path is absolute.
- The path includes a direct parent-directory reference.
Reported-by: XlabAI Team of Tencent Xuanwu Lab
Reported-by: Valery Gubanov <valerygubanov95@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6475 M src/bin/pg_rewind/file_ops.c
M src/fe_utils/astreamer_file.c
M src/fe_utils/astreamer_tar.c
M src/include/port.h
M src/port/path.c
Avoid overflow in size calculations in formatting.c.
commit : 6a985e71e9213420b5ebd388b20b2d3180ce0468
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 A few functions in this file were incautious about multiplying a
possibly large integer by a factor more than 1 and then using it as
an allocation size. This is harmless on 64-bit systems where we'd
compute a size exceeding MaxAllocSize and then fail, but on 32-bit
systems we could overflow size_t, leading to an undersized
allocation and buffer overrun. To fix, use palloc_array() or
mul_size() instead of handwritten multiplication.
Reported-by: Sven Klemm <sven@tigerdata.com>
Reported-by: Xint Code
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Security: CVE-2026-6473
Backpatch-through: 14 M src/backend/utils/adt/formatting.c
Check CREATE privilege on multirange type schema in CREATE TYPE.
commit : 4793fc41f82893b059bd59739bdcbe3d58c4df7e
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 This omission allowed roles to create multirange types in any
schema, potentially leading to privilege escalations. Note that
when a multirange type name is not specified in CREATE TYPE, it is
automatically placed in the range type's schema, which is checked
at the beginning of DefineRange().
Reported-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Security: CVE-2026-6472
Backpatch-through: 14 M src/backend/commands/typecmds.c
M src/test/regress/expected/multirangetypes.out
M src/test/regress/sql/multirangetypes.sql
pg_createsubscriber: Obstruct SQL injection via subscription names.
commit : d389415ffad509f0de1342e6ebbb5d5c62dbedef
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 11 May 2026 05:13:47 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:47 -0700 drop_existing_subscription() neglected to escape the subscription
name when generating its query string. To fix, use
PQescapeIdentifier() to construct a properly escaped name, and use
it in the ALTER SUBSCRIPTION and DROP SUBSCRIPTION commands.
Reported-by: Yu Kunpeng <yu443940816@live.com>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Security: CVE-2026-6476
Backpatch-through: 17 M src/bin/pg_basebackup/pg_createsubscriber.c
Fix MCV input array checks in statistics restore functions
commit : 6d6348f0329dd50ba9f954df28c2ffa88a15df07
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 The SQL functions for the restore of attribute and expression statistics
accept "most_common_vals" and "most_common_freqs" as independent arrays.
The planner assumes these have the same number of elements, but it was
possible to insert in the catalogs data that would cause an over-read
when the catalog data is loaded in the planner.
There were two holes in the stats restore logic:
- Both arrays should match in size.
- The input array must be one-dimensional, and it should match with what
is delivered by pg_dump when scanning the pg_stats catalogs.
The multivariate extended statistics MCV path (import_mcv) already
validated these inputs via check_mcvlist_array(), and is not affected.
These problems exist in v18 and newer versions for the restore of
attribute statistics. These problems affect only HEAD for the restore
of the expression statistics.
Reported-by: Jeroen Gui <jeroen.gui1@proton.me>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Security: CVE-2026-6575
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/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql
Guard against unsafe conditions in usage of pg_strftime().
commit : ec8ded4b327f9d121811f43bf0177d0f289c3949
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 Although pg_strftime() has defined error conditions, no callers bother
to check for errors. This is problematic because the output string is
very likely not null-terminated if an error occurs, so that blindly
using it is unsafe. Rather than trusting that we can find and fix all
the callers, let's alter the function's API spec slightly: make it
guarantee a null-terminated result so long as maxsize > 0.
Furthermore, if we do get an error, let's make that null-terminated
result be an empty string. We could instead truncate at the buffer
length, but that risks producing mis-encoded output if the tz_name
string contains multibyte characters. It doesn't seem reasonable for
src/timezone/ to make use of our encoding-aware truncation logic.
Also, the only really likely source of a failure is a user-supplied
timezone name that is intentionally trying to overrun our buffers.
I don't feel a need to be particularly friendly about that case.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6474 M src/timezone/strftime.c
Avoid passing unintended format codes to snprintf().
commit : 76ab76f875a85d51da91dca18d64a6b717533ad9
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 timeofday() assumed that the output of pg_strftime() could not contain
% signs, other than the one it explicitly asks for with %%. However,
we don't have that guarantee with respect to the time zone name (%Z).
A crafted time zone setting could abuse the subsequent snprintf()
call, resulting in crashes or disclosure of server memory.
To fix, split the pg_strftime() call into two and then treat the
outputs as literal strings, not a snprintf format string. The
extra pg_strftime() call doesn't really cost anything, since the
bulk of the conversion work was done by pg_localtime().
Also, adjust buffer widths so that we're not risking string truncation
during the snprintf() step, as that would create a hazard of producing
mis-encoded output.
This also fixes a latent portability issue: the format string expects
an int, but tp.tv_usec is long int on many platforms.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6474 M src/backend/utils/adt/timestamp.c
Fix SQL injection in logical replication origin checks.
commit : 46b4f5c11b0f2f6e6db834ffafc0d1a01a0373c1
author : Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 ALTER SUBSCRIPTION ... REFRESH PUBLICATION interpolates schema and
relation names into SQL without quoting them. A crafted subscriber
relation name can inject arbitrary SQL on the publisher. Test such a
name. Back-patch to v16, where commit
875693019053b8897ec3983e292acbb439b088c3 first appeared.
Reported-by: Pavel Kohout <pavel.kohout@aisle.com>
Author: Pavel Kohout <pavel.kohout@aisle.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Backpatch-through: 16
Security: CVE-2026-6638 M src/backend/commands/subscriptioncmds.c
M src/test/subscription/t/030_origin.pl
Apply timingsafe_bcmp() in authentication paths
commit : 5924e256c499c010dd369984498c8d5a4ee17894
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 This commit applies timingsafe_bcmp() to authentication paths that
handle attributes or data previously compared with memcpy() or strcmp(),
which are sensitive to timing attacks.
The following data is concerned by this change, some being in the
backend and some in the frontend:
- For a SCRAM or MD5 password, the computed key or the MD5 hash compared
with a password during a plain authentication.
- For a SCRAM exchange, the stored key, the client's final nonce and the
server nonce.
- RADIUS (up to v18), the encrypted password.
- For MD5 authentication, the MD5(MD5()) hash.
Reported-by: Joe Conway <mail@joeconway.com>
Security: CVE-2026-6478
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Backpatch-through: 14 M src/backend/libpq/auth-scram.c
M src/backend/libpq/crypt.c
M src/interfaces/libpq/fe-auth-scram.c
Guard against overflow in "left" fields of query_int and ltxtquery.
commit : 43451a7a2b3305571e7f8ed56d053e97acca1d1d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 contrib/intarray's query_int type uses an int16 field to hold the
offset from a binary operator node to its left operand. However, it
allows the number of nodes to be as much as will fit in MaxAllocSize,
so there is a risk of overflowing int16 depending on the precise shape
of the tree. Simple right-associative cases like "a | b | c | ..."
work fine, so we should not solve this by restricting the overall
number of nodes. Instead add a direct test of whether each individual
offset is too large.
contrib/ltree's ltxtquery type uses essentially the same logic and
has the same 16-bit restriction.
(The core backend's tsquery.c has a variant of this logic too, but
in that case the target field is 32 bits, so it is okay so long
as varlena datums are restricted to 1GB.)
In v16 and up, these types support soft error reporting, so we have
to complicate the recursive findoprnd function's API a bit to allow
the complaint to be reported softly. v14/v15 don't need that.
Undocumented and overcomplicated code like this makes my head hurt,
so add some comments and simplify while at it.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Backpatch-through: 14
Security: CVE-2026-6473 M contrib/intarray/_int_bool.c
M contrib/intarray/expected/_int.out
M contrib/intarray/sql/_int.sql
M contrib/ltree/expected/ltree.out
M contrib/ltree/ltxtquery_io.c
M contrib/ltree/sql/ltree.sql
Fix unbounded recursive handling of SSL/GSS in ProcessStartupPacket()
commit : b63f25bddfebc67b1e78f86341a6aecb0e9fe576
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 The handling of SSL and GSS negotiation messages in
ProcessStartupPacket() could cause a recursion of the backend,
ultimately crashing the server as the negotiation attempts were not
tracked across multiple calls processing startup packets.
A malicious client could therefore alternate rejected SSL and GSS
requests indefinitely, each adding a stack frame, until the backend
crashed with a stack overflow, taking down a server.
This commit addresses this issue by modifying ProcessStartupPacket() so
as processed negotiation attempts are tracked, preventing infinite
recursive attempts. A TAP test is added to check this problem, where
multiple SSL and GSS negotiated attempts are stacked.
Reported-by: Calif.io in collaboration with Claude and Anthropic
Research
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Security: CVE-2026-6479
Backpatch-through: 14 M src/backend/tcop/backend_startup.c
M src/test/postmaster/meson.build
A src/test/postmaster/t/004_negotiate.pl
Fix assorted places that need to use palloc_array().
commit : c55cea5290647c8d3e571893078664bbca955017
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 multirange_recv and BlockRefTableReaderNextRelation were incautious
about multiplying a possibly-large integer by a factor more than 1
and then using it as an allocation size. This is harmless on 64-bit
systems where we'd compute a size exceeding MaxAllocSize and then
fail, but on 32-bit systems we could overflow size_t leading to an
undersized allocation and buffer overrun.
Fix these places by using palloc_array() instead of a handwritten
multiplication. (In HEAD, some of them were fixed already, but
none of that work got back-patched at the time.)
In addition, BlockRefTableReaderNextRelation passes the same value
to BlockRefTableRead's "int length" parameter. If built for
64-bit frontend code, palloc_array() allows a larger array size
than it otherwise would, potentially allowing that parameter to
overflow. Add an explicit check to forestall that and keep the
behavior the same cross-platform.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/utils/adt/multirangetypes.c
M src/common/blkreftable.c
Prevent buffer overrun in unicode_normalize().
commit : 066b7b144f33819b0f4efa6b24ec638974c79a8a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 Some UTF8 characters decompose to more than a dozen codepoints.
It is possible for an input string that fits into well under
1GB to produce more than 4G decomposed codepoints, causing
unicode_normalize()'s decomp_size variable to wrap around to a
small positive value. This results in a small output buffer
allocation and subsequent buffer overrun.
To fix, test after each addition to see if we've overrun MaxAllocSize,
and break out of the loop early if so. In frontend code we want to
just return NULL for this failure (treating it like OOM). In the
backend, we can rely on the following palloc() call to throw error.
I also tightened things up in the calling functions in varlena.c,
using size_t rather than int and allocating the input workspace
with palloc_array(). These changes are probably unnecessary
given the knowledge that the original input and the normalized
output_chars array must fit into 1GB, but it's a lot easier to
believe the code is safe with these changes.
Reported-by: Xint Code
Reported-by: Bruce Dang <bruce@calif.io>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Co-authored-by: Heikki Linnakangas <hlinnaka@iki.fi>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/utils/adt/varlena.c
M src/common/unicode_norm.c
Harden our regex engine against integer overflow in size calculations.
commit : 0dc1fdc75ebbad9419ac5e313064be0fcf092543
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 The number of NFA states, number of NFA arcs, and number of colors
are all bounded to reasonably small values. However, there are
places where we try to allocate arrays sized by products of those
quantities, and those calculations could overflow, enabling
buffer-overrun attacks. In practice there's no problem on 64-bit
machines, but there are some live scenarios on 32-bit machines.
A related problem is that citerdissect() and creviterdissect()
allocate arrays based on the length of the input string, which
potentially could overflow.
To fix, invent MALLOC_ARRAY and REALLOC_ARRAY macros that rely on
palloc_array_extended and repalloc_array_extended with the NO_OOM
option, similarly to the existing MALLOC and REALLOC macros.
(Like those, they'll throw an error not return a NULL result for
oversize requests. This doesn't really fit into the regex code's
view of error handling, but it'll do for now. We can consider
whether to change that behavior in a non-security follow-up patch.)
I installed similar defenses in the colormap construction code.
It's not entirely clear whether integer overflow is possible
there, but analyzing the behavior in detail seems not worth
the trouble, as the risky spots are not in hot code paths.
I left a bunch of calls as-is after verifying that they can't
overflow given reasonable limits on nstates and narcs. Those
limits were enforced already via REG_MAX_COMPILE_SPACE, but
add commentary to document the interactions.
In passing, also fix a related edge case, which is that the
special color numbers used in LACON carcs could overflow the
"color" data type, if ncolors is close to MAX_COLOR.
In v14 and v15, the regex engine calls malloc() directly instead
of using palloc(), so MALLOC_ARRAY and REALLOC_ARRAY do likewise.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/regex/regc_color.c
M src/backend/regex/regc_cvec.c
M src/backend/regex/regc_nfa.c
M src/backend/regex/regcomp.c
M src/backend/regex/rege_dfa.c
M src/backend/regex/regexec.c
M src/include/regex/regcustom.h
M src/include/regex/regguts.h
Make palloc_array() and friends safe against integer overflow.
commit : 46593aea0a5ca7ead0876833d99639c9a4bb5a9d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 Sufficiently large "count" arguments could result in undetected
overflow, causing the allocated memory chunk to be much smaller
than what the caller will subsequently write into it. This is
unlikely to be a hazard with 64-bit size_t but can sometimes
happen on 32-bit builds, primarily where a function allocates
workspace that's significantly larger than its input data.
Rather than trying to patch the at-risk callers piecemeal,
let's just redefine these macros so that they always check.
To do that, move the longstanding add_size() and mul_size() functions
into palloc.h and mcxt.c, and adjust them to not be specific to
shared-memory allocation. Then invent palloc_mul(), palloc0_mul(),
palloc_mul_extended() to use these functions. Actually, the latter
use inlined copies to save one function call. repalloc_array() gets
similar treatment. I didn't bother trying to inline the calls for
repalloc0_array() though.
In v14 and v15, this also adds repalloc_extended(), which previously
was only available in v16 and up.
We need copies of all this in fe_memutils.[hc] as well, since that
module also provides palloc_array() etc.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/storage/ipc/shmem.c
M src/backend/utils/mmgr/mcxt.c
M src/common/fe_memutils.c
M src/include/common/fe_memutils.h
M src/include/storage/shmem.h
M src/include/utils/memutils.h
M src/include/utils/palloc.h
Fix overflows with ts_headline()
commit : d388e1d7f0468db8d046f9101f972d1fa988b19a
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 The options "StartSel", "StopSel" and "FragmentDelimiter" given by a
caller of the SQL function ts_headline() have their lengths stored as
int16. When providing values larger than PG_INT16_MAX, it was possible
to overflow the length values stored, leading to incorrect behaviors in
generateHeadline(), in most cases translating to a crash.
Attempting to use values for these options larger than PG_INT16_MAX is
now blocked. Some test cases are added to cover our tracks.
Reported-by: Xint Code
Author: Michael Paquier <michael@paquier.xyz>
Backpatch-through: 14
Security: CVE-2026-6473 M src/backend/tsearch/wparser_def.c
M src/test/regress/expected/tsearch.out
M src/test/regress/sql/tsearch.sql
ltree: Fix overflows with lquery parsing
commit : 2f1b16e867e78cdd899fa7df3acb5f6e616a9371
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 11 May 2026 05:13:46 -0700
committer: Noah Misch <noah@leadboat.com>
date : Mon, 11 May 2026 05:13:46 -0700 The lquery parser in contrib/ltree/ had two overflow problems:
- A single lquery level with many OR-separated variants (e.g.,
'label1|label2|...'), could cause an overflow of totallen, this being
stored as a uint16, meaning a maximum value of UINT16_MAX or 65k. Each
variant contributes MAXALIGN(LVAR_HDRSIZE + len) bytes. With enough
long variants, the value would wraparound. This would corrupt the data
written by LQL_NEXT(), leading to a stack corruption, most likely
translating into a crash, but it would allow incorrect memory access.
- numvar, labelled as a uint16, counts the number of OR-variants in a
single level, and it is incremented without bounds checking. With more
than PG_UINT16_MAX (65k) variants in a single level, and a minimum of
131kB of input data, it would wrap to 0. When a (wildcard) '*' is
used, this would change the query results silently.
For both issues, a set of overflows checks are added to guard against
these problematic patterns.
The first issue has been reported by the three people listed below,
affecting v16 and newer versions due to b1665bf01e5f. Its coding was
still unsafe in v14 and v15. The second issue affects all the stable
branches; I have bumped into while reviewing the code of the module.
Reported-by: Vergissmeinnicht <vergissmeinnichtzh@gmail.com>
Reported-by: A1ex <alex000young@gmail.com>
Reported-by: Jihe Wang <wangjihe.mail@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Security: CVE-2026-6473
Backpatch-through: 14 M contrib/ltree/expected/ltree.out
M contrib/ltree/ltree_io.c
M contrib/ltree/sql/ltree.sql
pg_upgrade: Message improvements
commit : c1fe2d1a3837bdb3b5476cb85d59bed5ddfe485b
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 11 May 2026 11:38:20 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 11 May 2026 11:38:20 +0200 M src/bin/pg_upgrade/check.c
Fix universal builds on MacOS
commit : 901ed9b352b41f034e17bc540725082a488fce31
author : John Naylor <john.naylor@postgresql.org>
date : Fri, 8 May 2026 16:44:25 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Fri, 8 May 2026 16:44:25 +0700 Commit 16743db06 assumed that the CPUID instruction was always
available when the usual x86 symbols were defined. That is not the
case, so zero out the info rather than error out.
Reported-by: Jakob Egger <jakob@eggerapps.at>
Reported-by: Tobias Bussmann <t.bussmann@gmx.net>
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/223EA201-A0E8-4A13-B220-EB903E8DF817@eggerapps.at M src/port/pg_cpu_x86.c
Enforce RETURNING typmod for empty-set JSON_ARRAY(query)
commit : 9d124a14b3d4803afee5efc4f794dfb72016cb88
author : Richard Guo <rguo@postgresql.org>
date : Fri, 8 May 2026 17:21:48 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 8 May 2026 17:21:48 +0900 Commit 8d829f5a0 introduced a COALESCE wrapper around the
JSON_ARRAYAGG subquery so that JSON_ARRAY(query) returns '[]' rather
than NULL when the subquery yields no rows, per the SQL/JSON standard.
The empty-array Const used as the COALESCE fallback was, however,
built with typmod -1 and the type input function was likewise invoked
with typmod -1. As a result, any length restriction from the
RETURNING clause was silently bypassed on the empty-set path, while
the non-empty path enforced it via the JSON_ARRAYAGG coercion.
Build the empty-array Const using the typmod of the COALESCE's
non-empty argument, and pass that typmod to OidInputFunctionCall as
well so the value is length-checked at parse time. This makes the
empty-set and non-empty-set paths behave consistently.
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWXPYqa58YXrU+SQMVonsAhjLS46HNUMU=wO5zm9MgY3_g@mail.gmail.com M src/backend/parser/parse_expr.c
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/sqljson.sql
Use schema-qualified names in EXCEPT clause error messages.
commit : a49b9cfd72d89a8fd68c90e84c38aa7e2ada756b
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 8 May 2026 10:00:26 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 8 May 2026 10:00:26 +0530 Error messages in check_publication_add_relation() previously reported
only the relation name when a table in an EXCEPT clause could not be
processed, which is ambiguous when the same name exists in multiple
schemas. Use schema-qualified names instead, consistent with other error
messages that reference relation names.
Author: Dilip Kumar <dilipbalaut@gmail.com>
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/CAFiTN-scG7b11Jsp+VoDRT8ZFE84eSKLcDsSB18dZ8AaP=R-mw@mail.gmail.com M src/backend/catalog/pg_publication.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/cache/lsyscache.c
M src/backend/utils/cache/relcache.c
M src/include/utils/lsyscache.h
M src/include/utils/relcache.h
M src/test/regress/expected/publication.out
postgres_fdw: Fix syntax error in fetch_attstats().
commit : 3f7a1afbaef06a7af93223cf2a653f2ec5740590
author : Etsuro Fujita <efujita@postgresql.org>
date : Fri, 8 May 2026 13:15:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Fri, 8 May 2026 13:15:00 +0900 When importing remote stats for a foreign table backed by a pre-v17
remote server, the query built/executed in this function has three NULL
placeholders for the range stats supported in v17 at the end of the
SELECT list. Previously, it included a trailing comma after the last
NULL, like "SELECT ..., NULL, NULL, NULL, FROM pg_catalog.pg_stats ...",
causing a syntax error on the remote server. Fix by removing the comma.
Oversight in commit 28972b6fc.
Author: Satya Narlapuram <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/CAHg%2BQDdEE7wp1S60Fn9Kmna8KfdMo5Tu6dROLpMn_-EOUBKmWQ%40mail.gmail.com M contrib/postgres_fdw/postgres_fdw.c
Consider opfamily and collation when removing redundant GROUP BY columns
commit : a1b754558ae87ceb1a44c34dc540f9128f6472eb
author : Richard Guo <rguo@postgresql.org>
date : Fri, 8 May 2026 12:45:51 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 8 May 2026 12:45:51 +0900 remove_useless_groupby_columns() uses a relation's unique indexes to
prove that some GROUP BY columns are functionally dependent on others,
and so can be dropped from the GROUP BY clause. The match between
index columns and GROUP BY columns was done by attno alone, ignoring
two equality-relation issues.
A type may belong to multiple btree opfamilies whose notions of
equality differ. The record type, for instance, has record_ops
(per-field equality) and record_image_ops (bytewise equality). A
unique index under one opfamily does not prove uniqueness under the
equality used by GROUP BY when the SortGroupClause's eqop comes from a
different opfamily.
Likewise, since nondeterministic collations were introduced in PG 12,
two collations may disagree on equality, and a unique index under one
collation does not prove uniqueness under another.
In either case, rows that the index considers distinct can collapse
into a single GROUP BY group, taking ungrouped columns of differing
values with them, so the planner drops a column that is not in fact
functionally dependent and produces wrong results.
Fix by requiring, for each unique-index key column, that some GROUP BY
item on the same column has an eqop in the index's opfamily and a
collation that agrees on equality with the index's collation. This
mirrors the combined check relation_has_unique_index_for() applies to
join clauses.
This is a v18 regression: commit bd10ec529 extended
remove_useless_groupby_columns() from primary-key constraints to
arbitrary unique indexes. Before that, the function consulted only
primary keys, whose enforcement index is required by parse_utilcmd.c
to use the default opclass and the column's declared collation, so
neither mismatch could arise. Back-patch to v18 only.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAMbWs49t6uArWoTT-cHY+nhsi23nJJKcF9Xb9cYGzaZ9kNJ98g@mail.gmail.com
Backpatch-through: 18 M src/backend/optimizer/plan/initsplan.c
M src/test/regress/expected/aggregates.out
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/aggregates.sql
M src/test/regress/sql/collate.icu.utf8.sql
M src/tools/pgindent/typedefs.list
Fix HAVING-to-WHERE pushdown for simple-CASE form
commit : ba82de48e62c633f5ad5e9dc9e6f2f3e8455a09f
author : Richard Guo <rguo@postgresql.org>
date : Fri, 8 May 2026 10:57:50 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 8 May 2026 10:57:50 +0900 Commit f76686ce7 added a walker that detects when a HAVING clause uses
a collation that conflicts with the GROUP BY's nondeterministic
collation, keeping such clauses in HAVING. The walker uses
exprInputCollation() to identify each ancestor's comparison collation,
but missed the simple-CASE case: parse analysis builds each WHEN as
OpExpr(CaseTestExpr op val), where CaseTestExpr is a placeholder for
the arg, while the actual arg expression sits at cexpr->arg, outside
the OpExpr that carries the comparison's inputcollid. A GROUP Var at
cexpr->arg was therefore visited with the WHEN's inputcollid absent
from the ancestor stack, the conflict went undetected, and the clause
was wrongly pushed to WHERE.
Fix by handling simple CASE explicitly: before walking cexpr->arg,
push every WHEN's inputcollid onto the ancestor stack so a GROUP Var
at the arg is checked against the same collations the WHEN comparisons
would apply. Then walk the WHEN bodies and defresult under the
unchanged stack, where their own collation contexts are picked up by
the default path.
Back-patch to v18 only; this fix extends the walker added by commit
f76686ce7 and inherits its dependency on the v18 RTE_GROUP mechanism.
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDcqPdd=2V0PQ_oNYj50OUeqSqznqFaYtP3RdokLBDXBqw@mail.gmail.com
Backpatch-through: 18 M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
doc PG 19 relnotes: add UTF-8 case folding performance item
commit : 12ca57bf346f1be0986f360d147bbe1a46d682db
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 7 May 2026 20:53:22 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 7 May 2026 20:53:22 -0400 Reported-by: Andreas Karlsson
Discussion: https://postgr.es/m/9dae1593-4441-4a20-a1ab-ce5018db9878@proxel.se M doc/src/sgml/release-19.sgml
Fix use-after-free of qs in AfterTriggerEndQuery.
commit : 4b1b2be22f2588f00dfd330886c1ca949f7dd938
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 8 May 2026 08:26:04 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 8 May 2026 08:26:04 +0900 afterTriggerInvokeEvents() may repalloc afterTriggers.query_stack
while firing trigger events, leaving any precomputed entry pointer
dangling. The loop body in AfterTriggerEndQuery() recomputes qs
after each afterTriggerInvokeEvents() call for that reason, but the
"all fired" break path exits without the recompute, and the
subsequent FireAfterTriggerBatchCallbacks(qs->batch_callbacks)
dereferences the freed pointer.
Fix by recomputing qs immediately before
FireAfterTriggerBatchCallbacks(), as the loop body already does
after each afterTriggerInvokeEvents() call.
The hazard was introduced in 34a30786293, which added the
qs->batch_callbacks dereference at this site.
Reported-by: Amul Sul <sulamul@gmail.com>
Author: Amul Sul <sulamul@gmail.com>
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CAAJ_b95p6-qiVpE2Gpr=bUsNAqTcejD_rPgLnfjx9m=fo3Rf3Q@mail.gmail.com M src/backend/commands/trigger.c
M src/test/regress/expected/triggers.out
M src/test/regress/sql/triggers.sql
doc PG 19 relnotes: correct two items
commit : 2d773a9f005fa555eb9fa35157b96f48d6ea8b53
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 7 May 2026 20:21:16 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 7 May 2026 20:21:16 -0400 Reported-by: jian he
Discussion: https://postgr.es/m/CACJufxG_ZTCTtFMxKiVji-s10jHt99krfH+Kn+Ww2prF=X6g6Q@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: add missing commits and details
commit : 4c0f1e4910184a7427ab133f1b233aa0ab5c26ec
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 7 May 2026 18:02:02 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 7 May 2026 18:02:02 -0400 Reported-by: Xuneng Zhou
Discussion: https://postgr.es/m/CABPTF7VxrFB_4Qoo2=PyrczGyq8CqOpQ5D5yye3DyxDC=so_0Q@mail.gmail.com M doc/src/sgml/release-19.sgml
Fix race condition in XLogLogicalInfo and ProcSignal initialization.
commit : b384cdb2745b56121426605d985210896555fc05
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 7 May 2026 10:09:42 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 7 May 2026 10:09:42 -0700 Previously, InitializeProcessXLogLogicalInfo() was called before
ProcSignalInit(). This created a window where a process could miss a
signal barrier if it was issued between these two calls. As a result,
the process could fail to update its local XLogLogicalInfo cache,
leading to an inconsistent logical decoding state.
This commit fixes this by moving InitializeProcessXLogLogicalInfo()
after ProcSignalInit(). This ensures that the process is registered to
participate in signal barriers before its state is initialized,
preventing it from missing any state changes propagated during the
startup sequence.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/CAD21AoBzdeSyLSSPM5E6ysN1r8qzp8u_BRmnLvuAp_S8QxS_fQ@mail.gmail.com
Discussion: https://postgr.es/m/CAD21AoBj+zKvgw_Q8gjr4YbKccW_uMe3OFQ5+KT246FHUuNXSQ@mail.gmail.com M src/backend/postmaster/auxprocess.c
M src/backend/utils/init/postinit.c
Rationalize error comments in partition split/merge tests
commit : ecb2508aaf9b978871734ea2fdf701ab7d593d0a
author : John Naylor <john.naylor@postgresql.org>
date : Thu, 7 May 2026 19:10:51 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Thu, 7 May 2026 19:10:51 +0700 The regression tests had a copy of the full error, detail, and hint
text in comments above each failing statement in the .sql files. This
is a maintenance hazard, so simplify to "-- ERROR", in line with
other tests.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CANWCAZap26BRLwtd+A7GFDSD6-+C3F0NVdUGUAu2LUfvpOTy=w@mail.gmail.com M src/test/regress/expected/partition_merge.out
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_merge.sql
M src/test/regress/sql/partition_split.sql
Message corrections for partition split/merge commands
commit : 52e629be95fc2ff52eabdae5b72c8eb6d8eef38d
author : John Naylor <john.naylor@postgresql.org>
date : Thu, 7 May 2026 19:10:35 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Thu, 7 May 2026 19:10:35 +0700 Fix spelling and grammar, turn an accidental duplicate errmsg into
errdetail, and remove an errposition that was not pointing at anything
relevant to the error.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Yuchen Li <liyuchen_xyz@163.com> (earlier version)
Discussion: https://postgr.es/m/CAJTYsWUvMT5uKOasPnm6-o9CrdXbRONiAYHTKJb7wx66LB8S1A@mail.gmail.com M src/backend/commands/tablecmds.c
M src/backend/parser/parse_utilcmd.c
M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_merge.out
M src/test/regress/expected/partition_split.out
pg_createsubscriber: Message improvements and corrections
commit : 43fc1dc7527c4213c4d48a96bf98738df0acb71a
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 7 May 2026 11:19:55 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 7 May 2026 11:19:55 +0200 M src/bin/pg_basebackup/pg_createsubscriber.c
Fix typo in error message
commit : 5778fb3eafd05c562af5d4585baf0e3ac57d07e0
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 7 May 2026 10:36:59 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 7 May 2026 10:36:59 +0200 Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAJTYsWXFy1j_T82%2BM_S9kFxU414tQYnZQD-b82%3DoL_LbG_5fPQ%40mail.gmail.com M src/backend/commands/propgraphcmds.c
M src/test/regress/expected/create_property_graph.out
Simplify code in objectaddress.c for some property graph objects
commit : 6827de95ee094f8a2cb892a40e6f154491e78496
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 7 May 2026 10:18:49 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 7 May 2026 10:18:49 +0900 Property graph element labels and label properties relied on a direct
systable scan when retrieving their object descriptions. These can be
simplified with get_catalog_object_by_oid(). This offers the benefit to
do a direct syscache lookup, if available.
The same logic will be used in a follow-up patch when retrieving the
object identity parts, applying the same rule across the board for these
object types.
Extracted from a larger patch by the author.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Alex Guo <guo.alex.hengchen@gmail.com>
Discussion: https://postgr.es/m/aej1DkLwhyZWmtxJ@bdtpg M src/backend/catalog/objectaddress.c
Fix WAIT FOR LSN cleanup on subtransaction abort
commit : 5cdec423193cb99b502816197395637120256f0d
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 6 May 2026 13:32:18 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 6 May 2026 13:32:18 +0300 WAIT FOR LSN registers the current backend in shared memory before entering an
interruptible wait loop. Top-level abort and backend exit already call
WaitLSNCleanup(), but subtransaction abort did not. If an interrupt, such as
statement_timeout, occurred while waiting inside a savepoint, rolling back to
the savepoint left the backend marked as present in the WAIT FOR LSN heap.
Clean up WAIT FOR LSN state from AbortSubTransaction() as well, and add
a TAP test covering reuse of WAIT FOR LSN after a savepoint rollback.
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWXDRwo-RVRaQgwxVcXgURVFeX8BKnijQrPiPcSCkDDX9A%40mail.gmail.com
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogwait.c
M src/test/recovery/t/049_wait_for_lsn.pl
Fix regex searching for page verification failures in tests
commit : 486b9a9b9eb45f48be183f0fc3cf3dc657026438
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 6 May 2026 12:38:15 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 6 May 2026 12:38:15 +0200 The test for finding page verification failures in the logfiles
were missing the /m modifier to make sure it anchors to every
newline in the search space buffer, and not just the last one.
Spotted while adding a test for the recently reported issue with
excessive WAL for unlogged relations.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDeGrpZbNZdLjd_T4b43xKEEXZN0HGhkFm-1bkBdyzK7AQ@mail.gmail.com M src/test/modules/test_checksums/t/006_pgbench_single.pl
M src/test/modules/test_checksums/t/007_pgbench_standby.pl
M src/test/modules/test_checksums/t/008_pitr.pl
M src/test/modules/test_checksums/t/009_fpi.pl
Apply data-checksum worker throttling parameters
commit : 9a39056c418c83f164a25c8c2ee34600da99bfc7
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 6 May 2026 12:38:12 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 6 May 2026 12:38:12 +0200 The DataChecksumsWorker accepts cost_delay and cost_limit parameters
from pg_enable_data_checksums() so users can throttle the I/O caused
by enabling checksums. Due to the API for setting the cost parameters
changing between when the code was written, and when it was committed
the new cost update function call was omitted and thus the parameters
were silently ignored.
Fix by calling VacuumUpdateCosts() after assigning the parameters
(both during worker startup and on the runtime cost-update path), and
by leaving the page-cost weights at their GUC-controlled defaults.
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDeevH6aTyWdXYBJW0wOmfoZy66gDi5TfinK_dXeCrHQLg@mail.gmail.com M src/backend/postmaster/datachecksum_state.c
Skip WAL for unlogged main fork during online checksum enable
commit : 2018bd6167909f3de7405774527d1230397950e0
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 6 May 2026 12:38:01 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 6 May 2026 12:38:01 +0200 ProcessSingleRelationFork() unconditionally generated an FPI WAL
record for every page of every relation when enabling checksums.
Unlogged relations, which by definition never generate WAL for
data changes, were not exempt which generated excessive WAL to
be emitted.
Fix by guarding the FPI WAL record call with RelationNeedsWAL()
to avoid emitting WAL for unlogged main forks. Unlogged pages
are still dirtied to ensure the checksum is written to disk at
the next checkpoint. The init fork remains WAL-logged even for
unlogged relations, as it's needed on the standby to materialize
the relation after promotion (see ResetUnloggedRelations()).
Skipping init-fork WAL would leave the standby with a stale init
fork that, once copied to the main fork on promotion, would fail
checksum verification on every read of the unlogged relation.
A test which creates an unlogged table with an index, enables
checksums, promotes the standby, and verifies that the unlogged
relation and its indexes are still readable post-promotion has
been added.
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDeGrpZbNZdLjd_T4b43xKEEXZN0HGhkFm-1bkBdyzK7AQ@mail.gmail.com M src/backend/postmaster/datachecksum_state.c
M src/test/modules/test_checksums/t/003_standby_restarts.pl
Document deprecated --wal-directory option for pg_verifybackup
commit : 43dc21f76fff67c481b1d208f9ee81a28972a158
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 6 May 2026 10:40:45 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 6 May 2026 10:40:45 +0200 Commit b3cf461b3cf renamed --wal-directory to --wal-path but retained
the former as a silent alias. Per project policy, all options,
including deprecated ones, should be documented to assist users
transitioning between versions.
This patch restores --wal-directory to the documentation and --help
output.
Author: Amul Sul <sulamul@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/E1w3fZp-000gje-31%40gemulon.postgresql.org M doc/src/sgml/ref/pg_verifybackup.sgml
M src/bin/pg_verifybackup/pg_verifybackup.c
Skip other sessions' temp tables in REPACK, CLUSTER, and VACUUM FULL
commit : a0a0c0c20ec5f8787bb1be5f476c4e59f6810634
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 5 May 2026 16:20:26 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 5 May 2026 16:20:26 +0200 get_tables_to_repack() and get_all_vacuum_rels() were including other
sessions' temporary tables in their output work list, causing REPACK,
CLUSTER and VACUUM FULL (when executed without a table list) to attempt
to acquire AccessExclusiveLock on them, potentially blocking for an
extended time. Fix by skipping other-session temp tables early, before
they are added to the list.
This issue is ancient, but there have been no complaints about it that I
know of, so I'm opting for not backpatching at present.
Author: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/0b555318-2bf2-46df-9377-09629a2a59db@uni-muenster.de M src/backend/commands/repack.c
M src/backend/commands/vacuum.c
Add missing guard for __builtin_constant_p
commit : 6766264262851686481dee4401541ee8cd874c2a
author : John Naylor <john.naylor@postgresql.org>
date : Tue, 5 May 2026 18:51:07 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Tue, 5 May 2026 18:51:07 +0700 Oversight in commit e2809e3a1. While at it, use pg_integer_constant_p
in master.
Discussion: https://postgr.es/m/CANWCAZbOha-x5MCreQn3TRA56VdKWNMAKMy3fAV1kJSw9Vp4pw@mail.gmail.com
Backpatch-through: 18 M src/include/port/pg_crc32c.h
postgres_fdw: Fix handling of abort-cleanup-failed connections.
commit : 648818ba3876fb3e43faffea729eccba969eefab
author : Etsuro Fujita <efujita@postgresql.org>
date : Tue, 5 May 2026 18:55:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Tue, 5 May 2026 18:55:00 +0900 As connections that failed abort cleanup can't safely be further used,
if a remote query tries to get such a connection, we reject it.
Previously, this rejection involved dropping the connection if it was
open, without accounting for the possibility of open cursors using it,
causing a server crash when such an open cursor tried to use an
already-dropped connection, as a cursor-handling function
(create_cursor, fetch_more_data, or close_cursor) was called on a freed
PGconn. To fix, delay dropping failed connections until abort cleanup
of the main transaction, to ensure open cursors using such a connection
can safely refer to the PGconn for it.
Oversight in commit 8bf58c0d9.
Reported-by: Zhibai Song <songzhibai1234@gmail.com>
Diagnosed-by: Zhibai Song <songzhibai1234@gmail.com>
Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAPmGK176y6JP017-Cn%2BhS9CEJx_6iVhRoYbAqzuLU4d8-XPPNg%40mail.gmail.com
Backpatch-through: 14 M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
doc: Clean up title case use
commit : d0ed9ad8b07d716b1b8caae3d1eb370571a0a6f3
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 11:24:16 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 11:24:16 +0200 M doc/src/sgml/appendix-obsolete-auth-radius.sgml
M doc/src/sgml/runtime.sgml
M doc/src/sgml/wal.sgml
M doc/src/sgml/xfunc.sgml
Message style improvements (oauth related)
commit : 22f9207aaa37fe418055f7a1ad6e681c021f70b0
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 09:59:49 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 09:59:49 +0200 M src/backend/libpq/auth-oauth.c
M src/interfaces/libpq-oauth/oauth-curl.c
M src/test/modules/oauth_validator/t/001_server.pl
Don't lose column values on REPACK
commit : eb2e2eb4d4cf31808f67a3f9cee77548308a4700
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 5 May 2026 10:24:49 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 5 May 2026 10:24:49 +0200 Commit 28d534e2ae0a introduced reform_tuple() with a fast path that
returns the source tuple verbatim when no dropped columns require fixing
up. I (Álvaro) failed to realize that this broke handling of columns
with a 'missingval' defined: after a VACUUM FULL, CLUSTER, or REPACK
operation, the catalogued missingval is thrown away, so the tuples are
no longer correct.
Fix by forcing the rewrite when the tuple is shorter than the tuple
descriptor.
Author: Satya Narlapuram <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDeoccU5CudrJpmSKZfKZ1gRMNY=5BxSC=JpHgkonzgcOw@mail.gmail.com M contrib/test_decoding/expected/repack.out
M contrib/test_decoding/sql/repack.sql
M src/backend/access/heap/heapam_handler.c
M src/test/regress/expected/fast_default.out
M src/test/regress/sql/fast_default.sql
Make spelling consistent
commit : d0eac3cafb0130b6da1eff03f2fd3afc448801c8
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 09:36:54 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 09:36:54 +0200 "vertexes" -> "vertices"
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAJTYsWXFy1j_T82%2BM_S9kFxU414tQYnZQD-b82%3DoL_LbG_5fPQ%40mail.gmail.com M src/backend/commands/propgraphcmds.c
M src/backend/rewrite/rewriteGraphTable.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
doc: Small synopsis wording change for consistency
commit : 1190f858eaf2483768248ad65c04ec99864be351
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 09:27:32 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 5 May 2026 09:27:32 +0200 M doc/src/sgml/ref/create_property_graph.sgml
Consider collation when proving subquery uniqueness
commit : 574581b50ac9c63dd9e4abebb731a3b67e5b50f6
author : Richard Guo <rguo@postgresql.org>
date : Tue, 5 May 2026 10:23:31 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Tue, 5 May 2026 10:23:31 +0900 rel_is_distinct_for()'s RTE_SUBQUERY branch passed only the equality
operator from each join clause to query_is_distinct_for(), discarding
the operator's input collation. query_is_distinct_for() then verified
opfamily compatibility but never checked collations, so a DISTINCT /
GROUP BY / set-op operating under one collation was trusted to prove
uniqueness for a comparison performed under an unrelated collation.
As with the recent fix in relation_has_unique_index_for(), this is
unsound for nondeterministic collations and yields wrong query results
in any optimization that consumes the proof.
Fix by carrying each clause's operator input collation into
query_is_distinct_for() and validating it at every check-site against
the subquery target expression's collation.
Back-patch to all supported branches. query_is_distinct_for() is
declared in an installed header, so on stable branches the existing
two-list signature is retained as a thin wrapper that forwards to a
new collation-aware entry point; external callers continue to receive
the historical collation-blind answer.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAMbWs4_XUUSTyzCaRjUeeahWNqi=8ZOA5Q4coi8zUVEDSBkM6A@mail.gmail.com
Backpatch-through: 14 M src/backend/optimizer/plan/analyzejoins.c
M src/include/nodes/pathnodes.h
M src/include/optimizer/planmain.h
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
M src/tools/pgindent/typedefs.list
Consider collation when proving uniqueness from unique indexes
commit : 5a55ea507a2d9a3fb2d004d64a994ead2ff7cf51
author : Richard Guo <rguo@postgresql.org>
date : Tue, 5 May 2026 10:22:53 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Tue, 5 May 2026 10:22:53 +0900 relation_has_unique_index_for() has long had an XXX noting that it
doesn't check collations when matching a unique index's columns
against equality clauses. This was benign as long as all collations
in play reduced to the same notion of equality, but has been incorrect
since nondeterministic collations were introduced in PG 12: a unique
index under a deterministic collation does not prove uniqueness under
a nondeterministic collation, nor vice versa.
The consequence is wrong query results for any planner optimization
that consumes the faulty proof, including inner-unique join execution
(which stops the inner search after the first match per outer row),
useless-left-join removal, semijoin-to-innerjoin reduction, and
self-join elimination.
Fix by requiring the index's collation to agree on equality with the
clause's input collation. Two collations agree on equality if either
is InvalidOid (denoting a non-collation-sensitive operation, which
cannot conflict with the other side), if they have the same OID, or if
both are deterministic: by definition a deterministic collation treats
two strings as equal iff they are byte-wise equal (see CREATE
COLLATION), so any two deterministic collations share the same
equality relation and the uniqueness proof carries over. Any mismatch
involving a nondeterministic collation is rejected.
Back-patch to all supported branches; the bug has existed since
nondeterministic collations were introduced in PG 12.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAMbWs4_XUUSTyzCaRjUeeahWNqi=8ZOA5Q4coi8zUVEDSBkM6A@mail.gmail.com
Backpatch-through: 14 M src/backend/optimizer/path/indxpath.c
M src/backend/utils/cache/lsyscache.c
M src/include/utils/lsyscache.h
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
Declare load_hosts() as returning HostsFileLoadResult.
commit : 93da29736649f8f7ecb0787f233a28a02a9738db
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 4 May 2026 18:33:06 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 4 May 2026 18:33:06 -0400 This function returns some value of enum HostsFileLoadResult,
but for reasons lost in the development process was declared to
return "int". Fix that, for clarity and so that our typedefs
collection tooling sees the typedef as used. Also fix the
variable that the sole call assigns into. Move the typedef
to the header file that declares load_hosts() to avoid creating
header dependency problems.
Discussion: https://postgr.es/m/359138.1777922557@sss.pgh.pa.us M src/backend/libpq/be-secure-common.c
M src/backend/libpq/be-secure-openssl.c
M src/include/libpq/hba.h
M src/include/libpq/libpq.h
Add ORDER BY to test query to stabilize test
commit : f6edd8ed708fe9e37742886916406ce52f2d3a84
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 20:59:16 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 20:59:16 +0200 for commit dc9e7c9ed93 M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Fix off-by-one in repack index loop
commit : b5f92b8eb4398e747cd438c259e54f8f540f778c
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 4 May 2026 20:01:19 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 4 May 2026 20:01:19 +0200 A blunder of mine (Álvaro) in commit 28d534e2ae0a.
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: Xiaopeng Wang <wxp_728@163.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CA+3i_M9ytFufvD8Tm0rhpfxuC4XrpgQDBHxM7NJQYxv488JW7w@mail.gmail.com M src/backend/commands/repack.c
Handle nodes that may appear in GraphPattern expression trees
commit : dc9e7c9ed9389c081f6dd5164b802f8b328f4baf
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 17:30:56 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 17:30:56 +0200 expression_tree_mutator_impl() did not handle T_GraphPattern,
T_GraphElementPattern, and T_GraphPropertyRef. The corresponding
expression_tree_walker_impl() already handles all three node types.
This causes an "unrecognized node type" error whenever a GRAPH_TABLE
appeared in an expression tree.
While at it, also update raw_expression_tree_walker() and
expression_tree_walker() to handle missing nodes that may appear in
GraphPattern expression trees. When raw_expression_tree_walker() is
called, GraphElementPattern::labelexpr contains ColumnRefs instead of
GraphLabelRefs. Hence those are not handled in
raw_expression_tree_walker().
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDc97WFTSkXg%3Dg_ZAH8GnY2gJrvq72cs%2BYjqEAuZgXnkAQ%40mail.gmail.com M src/backend/nodes/nodeFuncs.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Do not define type for a property graph
commit : 891a57c73945c0dcf942810f604bbd90d724b9ed
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 15:45:56 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 15:45:56 +0200 Even though a property graph is defined in pg_class it does not
contain any rows by itself and need not have a type defined. Avoid
creating a type for it.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAExHW5ucu7ZTgYkO6rB_1ShJP3e%3DGAT2T3CP4XWN8rUVEsiJoA%40mail.gmail.com M src/backend/catalog/heap.c
M src/include/catalog/catversion.h
M src/test/regress/expected/create_property_graph.out
Fix options listing of pg_restore --no-globals
commit : abff4492d0246a3de9053b3cb60a7076c3800dba
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 12:00:22 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 12:00:22 +0200 The new pg_restore option --no-globals (commit 3c19983cc08) appeared
out of order in the documentation and help output. Fix that. M doc/src/sgml/ref/pg_restore.sgml
M src/bin/pg_dump/pg_restore.c
Add missing serial commas
commit : b83a94a73bc3488119bb2517b0c1406be8a50545
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 11:53:04 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 11:53:04 +0200 M src/backend/statistics/extended_stats_funcs.c
M src/backend/utils/adt/pg_dependencies.c
M src/test/regress/expected/pg_dependencies.out
M src/test/regress/expected/stats_import.out
doc: Fix up spacing around verbatim DocBook elements
commit : 2fcc8aaeb23a387b22e7abde61b2c7943cd0a4a6
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 09:45:21 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 4 May 2026 09:45:21 +0200 M doc/src/sgml/func/func-admin.sgml
M doc/src/sgml/func/func-window.sgml
M doc/src/sgml/high-availability.sgml
M doc/src/sgml/libpq.sgml
M doc/src/sgml/maintenance.sgml
M doc/src/sgml/pgplanadvice.sgml
Simplify translatable messages for tuple value details in conflict.c.
commit : bf3ead60751488f5c65434fa7ea770a9f6031db0
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 4 May 2026 12:06:41 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 4 May 2026 12:06:41 +0530 append_tuple_value_detail() constructed user-visible messages using
separately translated fragments such as ": ", ", ", and ".",. This
makes correct translation difficult or impossible in some languages.
Refactor append_tuple_value_detail() to move all punctuation and
sentence construction to the callers, which now use a single
translatable string with a %s placeholder for the tuple data.
Reported-by: David Rowley <dgrowleyml@gmail.com>
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/227279.1775956328%40sss.pgh.pa.us#8f3a5f50543556c60cc5a13270cb7ba4
Discussion: https://postgr.es/m/CAApHDvohYOdrvhVxXzCJNX_GYMSWBfjTTtB6hgDauEtZ8Nar2A@mail.gmail.com M src/backend/replication/logical/conflict.c
Mark modified the FSM buffer as dirty during recovery
commit : c06d1a4ba6b26eef27b04074683cccade6c277ee
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 20:23:50 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 20:23:50 +0300 The XLogRecordPageWithFreeSpace function updates the freespace map (FSM) data
while replaying data-level WAL records during the recovery. If the FSM block
is updated, it needs to be marked as modified. Currently, this is done with
the MarkBufferDirtyHint call (as in all other cases for modifying FSM data).
However, in the recovery context, this function will actually do nothing if
checksums are enabled. It's assumed that the page should not be dirtied
during recovery while modifying hints to protect against torn pages, since no
new WAL data can be generated at this point to store FPI.
Such logic does not seem fully aligned with the FSM case, as its blocks could
be simply zeroed if a checksum mismatch is detected. Currently, changes to an
FSM block could be lost if each change to that block occurs infrequently
enough to allow it to be evicted from the cache. To persist the change, the
modification needs to be performed while the FSM block is still kept in
buffers and marked as dirty after receiving its FPI. If the block has already
been cleaned, the change won't be persisted, so stored FSM blocks may remain
in an obsolete state.
If a large number of discrepancies between the data in leaf FSM blocks and the
actual data blocks accumulate on the replica server, this could cause
significant delays in insert operations after switchover. Such an insert
operation may need to visit many data blocks marked as having sufficient
space in the FSM, only to discover that the information is incorrect and the
FSM records need to be corrected. In a heavily trafficked insert-only table
with many concurrent clients performing inserts, this has been observed to
cause several-second stalls, causing visible application malfunction. The
desire to avoid such cases was the reason behind the commit ab7dbd681, which
introduced an update of FSM data during the heap_xlog_visible invocation.
However, an update to the FSM data on the standby side could be lost due to a
missing 'dirty' flag, so there is still a possibility that a large number of
FSM records will contain incorrect data. Note that having a zeroed FSM page
in such a case (due to a checksum mismatch) is preferable, as a zero value
will be interpreted as an indication of full data blocks, and the inserter
will be routed to the next FSM block or to the end of the table.
Given that FSM is ready to handle torn page writes and
XLogRecordPageWithFreeSpace is called only during the recovery, there seems
to be no reason to use MarkBufferDirtyHint here instead of a regular
MarkBufferDirty call.
Discussion: https://postgr.es/m/596c4f1c-f966-4512-b9c9-dd8fbcaf0928%40postgrespro.ru
Author: Alexey Makhmutov <a.makhmutov@postgrespro.ru>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/storage/freespace/freespace.c
Document that WAIT FOR LSN is timeline-blind
commit : 21d290161b11adc92a49da8e71fda69c20032618
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:20:41 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:20:41 +0300 WAIT FOR LSN compares only the numeric LSN and has no notion of which
timeline a WAL record belongs to. There are many possible scenarios when
timeline-switching can break read-your-writes consistency. The proper
analysis and timeline support is possible in the next major release. Yet
just document the current behaviour.
Reported-by: Xuneng Zhou <xunengzhou@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com> M doc/src/sgml/ref/wait_for.sgml
Improve WAIT FOR LSN test coverage
commit : cb096e6d6981e0a4b25beb46ab0cf9154971123a
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:20:16 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:20:16 +0300 Add regression coverage for several WAIT FOR LSN edge cases.
First, cover fresh walreceiver shared-memory initialization after a
standby restart. Restart the standby while its upstream is down, so
RequestXLogStreaming() seeds writtenUpto/flushedUpto to the
segment-aligned receiveStart and the walreceiver cannot immediately
advance them. Verify that the seeded flush position is segment-aligned,
that replay can be ahead of it, and that standby_write/standby_flush
still succeed for an already-replayed LSN via the replay-position floor
in GetCurrentLSNForWaitType().
Second, add fencepost checks for the target <= currentLSN predicate.
With replay paused and walreceiver stopped, verify exact boundaries for
standby_replay using pg_last_wal_replay_lsn(), and for standby_flush
using pg_last_wal_receive_lsn(). Also verify that a waiter for
current + 1 sleeps while replay is paused and wakes with success once
new WAL is delivered and replay advances.
Finally, add a cascading-standby timeline-switch test. Start a waiter
on the downstream standby, promote its upstream, generate WAL on the new
timeline, and verify that the cascade follows the new timeline and the
wait completes successfully once replay reaches the target LSN.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/1957514.1775526774%40sss.pgh.pa.us
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Xuneng Zhou <xunengzhou@gmail.com> M src/test/recovery/t/049_wait_for_lsn.pl
Wake standby_write/standby_flush waiters from the WAL replay loop
commit : e7cd592174d94f9aea197edc5f0c6f708df27271
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:19:00 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:19:00 +0300 The startup process only woke STANDBY_REPLAY waiters after replaying
each WAL record. STANDBY_WRITE and STANDBY_FLUSH waiters depended only
on walreceiver write/flush callbacks. As a result, replay progress alone
did not wake those waiters, and in pure archive recovery (where no
walreceiver exists) they could sleep until timeout.
Fix by also calling WaitLSNWakeup() for STANDBY_WRITE and
STANDBY_FLUSH after each replay. For the replay-floor semantics used by
GetCurrentLSNForWaitType(), replay progress is a valid lower bound for
both modes: WAL cannot be replayed unless it has already been written
and flushed locally.
This works together with the replay-position floor in
GetCurrentLSNForWaitType(). The getter ensures that a waiter woken by
replay can recheck successfully; the replay-side wakeups ensure that a
waiter already asleep is notified when replay reaches its target.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1957514.1775526774%40sss.pgh.pa.us
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/access/transam/xlogrecovery.c
M src/test/recovery/t/049_wait_for_lsn.pl
Use replay position as floor for WAIT FOR LSN standby_(write|flush)
commit : cba67b5b87f9e7a576a99d00c0cd60f7ea529ba3
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:18:30 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:18:30 +0300 GetCurrentLSNForWaitType() for standby_write and standby_flush modes
returned only the walreceiver position, which may lag behind WAL
already present on the standby from a base backup, archive restore,
or prior streaming. This could cause unnecessary blocking if the
target LSN falls between the walreceiver's tracked position and the
replay position.
Fix by returning the maximum of the walreceiver position and the
replay position. WAL up to the replay point is physically on disk
regardless of its origin, so there is no reason to wait for the
walreceiver to re-receive it.
This complements 29e7dbf5e4d, which seeded writtenUpto to
receiveStart in RequestXLogStreaming() to fix the most common
hang scenario. The getter-level floor handles the remaining edge
cases: targets between receiveStart and the replay position, and
standbys running with archive recovery only (no walreceiver).
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1957514.1775526774%40sss.pgh.pa.us
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M doc/src/sgml/ref/wait_for.sgml
M src/backend/access/transam/xlogwait.c
M src/test/recovery/t/049_wait_for_lsn.pl
Remove redundant WAIT FOR LSN caller-side pre-checks
commit : df9f938ca2ec30e1018a76d80ccc77c7073d7acf
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:17:32 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:17:32 +0300 All five wakeup call sites duplicate WaitLSNWakeup()'s internal
fast-path minWaitedLSN check and add an unnecessary NULL check
on waitLSNState.
Remove the inline pre-checks and call WaitLSNWakeup() directly.
The fast-path check inside WaitLSNWakeup() already returns early
when no waiter's target has been reached, so there is no
performance difference.
The waitLSNState NULL checks are also unnecessary: shared memory
is fully initialized before any backend or auxiliary process
starts, so waitLSNState is always non-NULL at these call sites.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/jzq5shdewncpxc35r3s2mcfsmo4bjovkza5mnqf5bdfumhfi3g%40bglckf7dxmw5
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/replication/walreceiver.c
Fix memory ordering in WAIT FOR LSN wakeup mechanism
commit : a80a593ab63696a0ad0e5c10b9e1b99aaa98032e
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:16:30 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:16:30 +0300 WAIT FOR LSN uses a Dekker-style handshake: the waker stores an LSN
position then reads minWaitedLSN; the waiter stores its target into
minWaitedLSN then reads the position. Without a barrier between each
side's store and load, a CPU may satisfy the load before the store
becomes globally visible, causing either side to miss a concurrent
update. The result is a missed wakeup: the waiter sleeps indefinitely
until the next unrelated event.
Fix by embedding the required barriers into the atomic operations on
minWaitedLSN:
- In updateMinWaitedLSN(), use pg_atomic_write_membarrier_u64() so the
waiter's preceding heap update is visible before the new minWaitedLSN
value is published.
- In WaitLSNWakeup(), use pg_atomic_read_membarrier_u64() in the
fast-path check so the waker's preceding position store is globally
visible before minWaitedLSN is read.
The waiter side is also covered by the barrier semantics already present
in GetCurrentLSNForWaitType(): GetWalRcvWriteRecPtr() uses an explicit
read barrier (from patch 0001), while the remaining getters acquire a
spinlock, which implies the same ordering.
Also call ResetLatch() unconditionally after WaitLatch(), following the
standard latch loop pattern. WaitLatch() does not guarantee that all
simultaneously true wake conditions are reported in one return, so a
timeout can race with SetLatch(). If we skip ResetLatch() on a timeout
return, the code performs further asynchronous-state checks before
consuming the latch, violating the latch API's required wait/reset
pattern. That can leave the latch set across loop exit and cause a
later unrelated WaitLatch() in the same backend to return immediately.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/zqbppucpmkeqecfy4s5kscnru4tbk6khp3ozqz6ad2zijz354k%40w4bdf4z3wqoz
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/access/transam/xlogwait.c
Use barrier semantics when reading/writing writtenUpto
commit : dfb690dd52375517138ce1ee0f20a831d9585778
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:21:25 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sun, 3 May 2026 16:21:25 +0300 The walreceiver publishes its write position lock-free via writtenUpto.
On weakly-ordered architectures (ARM, PowerPC), both sides of this
handshake need explicit barriers so that the lock-less reader sees a
consistent state.
Use pg_atomic_write_membarrier_u64() at both write sites and
pg_atomic_read_membarrier_u64() in GetWalRcvWriteRecPtr(). This matches
the barrier semantics that GetWalRcvFlushRecPtr() and other LSN-position
functions get implicitly from their spinlock acquire/release, and
protects from bugs caused by expectations of similar barrier guarantees
from different LSN-position functions.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/zqbppucpmkeqecfy4s5kscnru4tbk6khp3ozqz6ad2zijz354k%40w4bdf4z3wqoz
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/replication/walreceiver.c
M src/backend/replication/walreceiverfuncs.c
Add missing connection validation in ECPG
commit : c34a280c85b39b6e875afa56542a055d2b90b640
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 1 May 2026 15:12:28 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 1 May 2026 15:12:28 -0400 ECPGdeallocate_all(), ECPGprepared_statement(), ECPGget_desc(), and
ecpg_freeStmtCacheEntry() could crash with a SIGSEGV when called
without an established connection (for example, when EXEC SQL CONNECT
was forgotten or a non-existent connection name was used), because
they dereferenced the result of ecpg_get_connection() without first
checking it for NULL.
Each site is fixed in the style of the surrounding code.
New tests are added for these conditions.
Author: Shruthi Gowda <gowdashru@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Mahendra Singh Thalor <mahi6run@gmail.com>
Reviewed-by: Nishant Sharma <nishant.sharma@enterprisedb.com>
Discussion: https://postgr.es/m/3007317.1765210195@sss.pgh.pa.us
Backpatch-through: 14 M src/interfaces/ecpg/ecpglib/descriptor.c
M src/interfaces/ecpg/ecpglib/prepare.c
M src/interfaces/ecpg/test/connect/.gitignore
M src/interfaces/ecpg/test/connect/Makefile
M src/interfaces/ecpg/test/connect/meson.build
A src/interfaces/ecpg/test/connect/test6.pgc
M src/interfaces/ecpg/test/ecpg_schedule
A src/interfaces/ecpg/test/expected/connect-test6.c
A src/interfaces/ecpg/test/expected/connect-test6.stderr
A src/interfaces/ecpg/test/expected/connect-test6.stdout
Only show signal-sender PID/UID detail in server log
commit : b772f3fcad1870731020dbe56713c616abc5dc26
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 1 May 2026 11:52:14 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 1 May 2026 11:52:14 -0400 The errdetail() added in 55890a91945 (and reworked in 3e2a1496bae)
exposed the operating-system PID and UID of whoever sent the
termination signal directly to the affected client.
Discussion suggested this should not be sent to the client, but only
recorded in the server log where the admin can use it for diagnosis.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Discussion: https://postgr.es/m/E5CA274C-74BD-4067-8B73-A3AD8C080EFA@gmail.com M src/backend/replication/syncrep.c
M src/backend/tcop/postgres.c
M src/bin/psql/t/001_basic.pl
Fix BF failure introduced in commit 2bf6c9ff71.
commit : f67dbd8398c060362802cb559261893881c21cbe
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 1 May 2026 14:35:26 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 1 May 2026 14:35:26 +0530 The sequence subscription test switches regress_seq_sub to connect to the
publisher as regress_seq_repl (a non-superuser) when checking behavior
with insufficient sequence privileges but forgot to set up pg_hba.conf to
allow connections from it. The special setup is only needed on Windows
machines that don't use UNIX sockets.
As per buildfarm.
Reported-by: Ajin Cherian <itsajin@gmail.com>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Discussion: https://postgr.es/m/CAFPTHDad911HUMkHgD1KZk+WOvTopiBcYf4C_8Fqj1-sZk3xgw@mail.gmail.com M src/test/subscription/t/036_sequences.pl
doc: Mention validation attempt during ALTER INDEX .. ATTACH PARTITION
commit : 0916282a0606fb788634738bab5b9f0bbde2aa08
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 1 May 2026 13:10:35 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 1 May 2026 13:10:35 +0900 Since 9d3e094f12, the command tries to validate the parent index of the
named index, if invalid. The documentation did not mention this
behavior, which could be confusing.
Author: Mohamed ALi <moali.pg@gmail.com>
Discussion: https://postgr.es/m/CAGnOmWpHu25_LpT=zv7KtetQhqV1QEZzFYLd_TDyOLu1Od9fpw@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/alter_index.sgml
Avoid blocking indefinitely while finishing walsender shutdown
commit : c0b24b32b0d3776435923d55396cc43fc657ecc5
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 1 May 2026 12:12:44 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 1 May 2026 12:12:44 +0900 When walsender finishes streaming during shutdown, it sends a
CommandComplete message to tell the receiver that WAL streaming is done.
Previously, that path used EndCommand() followed by pq_flush().
Those functions can block indefinitely waiting for the socket to become
writeable. As a result, even when wal_sender_shutdown_timeout is set,
walsender could remain stuck while sending the final completion message,
and the shutdown timeout would not be enforced.
Fix this by introducing EndCommandExtended(), which allows
CommandComplete to be queued with pq_putmessage_noblock(), and by
using the walsender nonblocking flush path instead of pq_flush(), so
the shutdown timeout continues to be checked while pending output is
flushed.
Per CI testing on FreeBSD.
Reported-by: Andres Freund <andres@anarazel.de>
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/vwlugmsogfn36jhm56zwrgd7m6xe6ircltvfh3kzt6kldvbtht@f45dgow5uhnx M src/backend/replication/walsender.c
M src/backend/tcop/dest.c
M src/include/tcop/dest.h
Fix HAVING-to-WHERE pushdown with nondeterministic collations
commit : f76686ce7f77e57456ad3644f2f6b4280181d1f4
author : Richard Guo <rguo@postgresql.org>
date : Fri, 1 May 2026 11:13:50 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 1 May 2026 11:13:50 +0900 When GROUP BY uses a nondeterministic collation, the planner's
optimization of moving HAVING clauses to WHERE can produce incorrect
query results. The HAVING clause may apply a stricter collation that
distinguishes values the GROUP BY considers equal. Pushing such a
clause to WHERE causes it to filter individual rows before grouping,
potentially eliminating group members and changing aggregate results.
Fix this by detecting collation conflicts before flatten_group_exprs,
while the HAVING clause still contains GROUP Vars (Vars referencing
RTE_GROUP). At that point, each GROUP Var directly carries the GROUP
BY collation as its varcollid, making it straightforward to compare
against the operator's inputcollid. A mismatch where the GROUP BY
collation is nondeterministic means the clause is unsafe to push down.
RowCompareExpr is treated specially, since it carries per-column
inputcollids[] rather than a single inputcollid.
The conflicting clause indices are recorded in a Bitmapset and
consulted during the existing HAVING-to-WHERE loop, so that only
affected clauses are kept in HAVING; other safe clauses in the same
query are still pushed.
Back-patch to v18 only. The fix relies on the RTE_GROUP mechanism
introduced in v18 (commit 247dea89f), which is what lets us identify
grouping expressions and their resolved collations 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 this bug on back branches, the risk of carrying a
different fix on stable branches is not justified.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Discussion: https://postgr.es/m/CAMbWs48Dn2wW6XM94GZsoyMiH42=KgMo+WcobPKuWvGYnWaPOQ@mail.gmail.com
Backpatch-through: 18 M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
M src/tools/pgindent/typedefs.list
Use "concurrent delete" in serialization error for TM_Deleted cases
commit : 410013d2a5917ee8978c944e582e323acc9ebdcf
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 1 May 2026 09:56:10 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 1 May 2026 09:56:10 +0900 In ExecLockRows() and ri_LockPKTuple(), the TM_Deleted code path was
using the same "could not serialize access due to concurrent update"
message as the TM_Updated path. Use "concurrent delete" instead, since
the tuple was deleted, not updated. The ExecLockRows() instance was
likely a copy-paste error per Andres; the ri_LockPKTuple() instance
was carried over from the same pattern in commit 2da86c1ef9.
Update affected isolation test expected files accordingly and add
a new test to fk-concurrent-pk-upd.spec with concurrent delete of the
PK row.
The ExecLockRows() change is master-only for lack of user complaints
and to avoid breaking anything that might match on the error text.
Reported-by: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CACJufxEG1JTCq4A1gnNAu-bGAq9Xn=Xkf7kC3TRWFz6iuUOuRA@mail.gmail.com M src/backend/executor/nodeLockRows.c
M src/backend/utils/adt/ri_triggers.c
M src/test/isolation/expected/fk-concurrent-pk-upd.out
M src/test/isolation/expected/fk-partitioned-2.out
M src/test/isolation/expected/fk-snapshot-2.out
M src/test/isolation/expected/fk-snapshot-3.out
M src/test/isolation/specs/fk-concurrent-pk-upd.spec
Fix JSON_ARRAY(query) empty set handling and view deparsing
commit : 8d829f5a0203ed4395e2d4d3931cd225a00c1b14
author : Richard Guo <rguo@postgresql.org>
date : Fri, 1 May 2026 09:42:00 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 1 May 2026 09:42:00 +0900 According to the SQL/JSON standard, JSON_ARRAY(query) must return an
empty JSON array ('[]') when the subquery returns zero rows.
Previously, the parser rewrote JSON_ARRAY(query) into a JSON_ARRAYAGG
aggregate function. Because this aggregate evaluates to NULL over an
empty set without a GROUP BY clause, the constructor erroneously
returned NULL. Additionally, this premature rewrite baked physical
implementation details into the catalog, preventing ruleutils.c from
deparsing the original syntax for views.
This patch resolves both issues by introducing a new
JSCTOR_JSON_ARRAY_QUERY constructor type. The parser builds the
executable form --- a COALESCE-wrapped JSON_ARRAYAGG subquery --- from
raw parse nodes via transformExprRecurse, and stores it in the func
field. The original transformed Query is kept in a new orig_query
field so that ruleutils.c can deparse the original syntax for views.
During planning, eval_const_expressions replaces the node with the
pre-built func expression.
The deparsing issue was reported by Tom Lane.
Bump catalog version.
Bug: #19418
Reported-by: Lukas Eder <lukas.eder@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/19418-591ba1f29862ef5b@postgresql.org M doc/src/sgml/func/func-json.sgml
M src/backend/nodes/nodeFuncs.c
M src/backend/optimizer/util/clauses.c
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
REPACK CONCURRENTLY: fix processing of toasted tuples
commit : 6ca631b9901264b97c5b165e66edd3a85847ee0b
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 28 Apr 2026 16:02:27 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 28 Apr 2026 16:02:27 +0200 In order to process tuples inserted or updated while REPACK executes, we
write those tuples to disk and later restore them; however, some forms
of toasted tuples were not being processed correctly. Fix that.
Also expand the tests a bit for better coverage.
Author: Satya Narlapuram <satyanarlapuram@gmail.com>
Author: Antonin Houska <ah@cybertec.at>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDeXb9HM2VGKXQedyCp52GzajJK5KOUdNi6oLjsS0nerQw@mail.gmail.com M src/backend/commands/repack.c
M src/test/modules/injection_points/expected/repack_toast.out
M src/test/modules/injection_points/specs/repack_toast.spec
Remove working test that was supposed to fail
commit : 2fd787d0aac1cb00a42ebce92ebb1d7534035ee3
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 30 Apr 2026 22:57:24 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 30 Apr 2026 22:57:24 +0200 I evidently failed to review the expected output in commit 832e220d99af
carefully enough. Per complaint from Tom Lane.
Discussion: https://postgr.es/m/769631.1777575242@sss.pgh.pa.us M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql
Fix attnum remapping in generateClonedExtStatsStmt()
commit : 6cf49e804c9b4ac24046a48541810d1fed33fec3
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 30 Apr 2026 11:04:57 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 30 Apr 2026 11:04:57 -0400 When cloning extended statistics via CREATE TABLE ... LIKE ... INCLUDING
STATISTICS, stxkeys holds attribute numbers from the source (parent)
table, but get_attname() was being called with the child relation's
OID. If the parent has dropped columns, the child's attribute numbers
are renumbered sequentially and no longer match, so the lookup either
returns the wrong column name (silent corruption) or errors out when
the attnum does not exist in the child.
Fix it by remapping the parent attnum through attmap before the lookup,
consistent with how expression statistics are already handled a few
lines below.
Add a regression test covering both manifestations: a 3-column parent
where the stale attnum refers to no child column (cache-lookup error),
and a 4-column parent where the stale attnum silently refers to the
wrong child column.
Author: Julien Tachoires <julmon@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Discussion: https://postgr.es/m/20260415105718.tomuncfbmlt67oel@poseidon.home.virt
Backpatch-through: 14 M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/create_table_like.out
M src/test/regress/sql/create_table_like.sql
Avoid SIGSEGV in pg_get_database_ddl() on NULL tablespace
commit : 5642a0367c2fe69684800c5d5c5929c20d99ef72
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 30 Apr 2026 10:14:52 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 30 Apr 2026 10:14:52 -0400 There is a narrow race in which a concurrent ALTER DATABASE ... SET
TABLESPACE moves the database off the tablespace and a DROP TABLESPACE
removes it between the syscache lookup and the catalog scan. If that
happens, output an error.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Jack Bonatakis <jack@bonatak.is>
Reviewed-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/573E45C1-31A4-4885-A00C-1A2171159A2A@gmail.com M src/backend/utils/adt/ddlutils.c
Fix data_checksum GUC show_hook
commit : 75152c5dc5d38929ddf82f65d5c59eb5a628ab38
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:57 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:57 +0200 Commit f19c0eccae erroneously omitted the show_hook for the
data_checksum GUC.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/backend/utils/misc/guc_parameters.dat
Improve database detection logic in datachecksumsworker
commit : 1df361e3d82c5eddccdb10f10dbaf611f752e1b9
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:55 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:55 +0200 The worker need to know whether a database which failed checksum
processing still exists, or has been dropped. This improves the
detection logic by checking for being partially dropped.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/backend/postmaster/datachecksum_state.c
Improve handling of concurrent checksum requests
commit : bf25e5571b325875e0e48bac2e59a820918f2d6a
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:53 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:53 +0200 When pg_{enable|disable}_data_checksums is called while checksums are
being enabled or disabled, the already running launcher is detected
and the new desired state is recorded. Processing will then pick up
the new state and change its operation to fulfill the new request.
If the same state is requested but with different cost values, the
new cost values will take effect on the next relation processed.
The previous coding had a complex logic of starting a new launcher
for this, which is now avoided with the shared mem structure instead
used to signal current processing.
This makes the logic more robust, and fixes a bug where the launcher
would erroneously revert back to the "off" state.
Access to the shared memory is also protected with LWLocks in all
cases. Since the shmem structure is used for signalling between
the worker and the launcher, and there can be only one of each,
there were no concurrency issues detected but it's better to stick
to proper locking protocol should this ever be updated to handle
multiple workers.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/backend/access/transam/xlog.c
M src/backend/postmaster/datachecksum_state.c
M src/include/access/xlog.h
Typo and spelling fixups for online checksums
commit : 381d19da1536bdbddb2f7ea1649b2f88933b8f1f
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:50 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:50 +0200 A collection of spelling, wording and punctuation fixups for the code
documentation from postcommit review.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/backend/access/transam/xlog.c
M src/backend/postmaster/datachecksum_state.c
Fix invalid checksum state transition in checkpoints
commit : 25b922ec5825e6938c28cdae718aa70b8f11fd50
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:48 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:48 +0200 Commit 78e950cb8 added checksum state handling to all XLOG_CHECKPOINT
records which caused unnecessary state transitions and emission of
procsignal barriers. Remove as only the _REDO record need to handle
checksum state. Barrier emission is also consistently made after
controlfile updates to avoid race conditions.
Additionally, interrupts are held between calling ProcSignalInit and
InitLocalDataChecksumState to remove a window where otherwise invalid
state transitions can happen.
Also remove a pointless assertion on Controlfile which will never hit.
Author: Tomas Vondra <tomas@vondra.me>
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/backend/access/transam/xlog.c
M src/backend/postmaster/auxprocess.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/utils/init/postinit.c
Handle data_checksum state changes during launcher_exit
commit : 8fb8ded8895620809bb71188476fbc2aec0f419d
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:46 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:46 +0200 When erroring out from the datachecksums launcher during data checksum
enabling, before state has transitioned to "on", we revert back to the
"off" state. Since checksums weren't enabled, there is no use staying
in an inprogress state since the checksum launcher currently doesn't
support restarting from where it left off. Should restartability get
added in the future, this would need to be revisited. This state
transition was however missing from the allowed transitions in the
statemachine causing an error.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/backend/access/transam/xlog.c
M src/backend/postmaster/datachecksum_state.c
Test improvements for online checksums
commit : a0d8f4c1ae16ca2c12e208c660f97666be809700
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:43 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:43 +0200 This includes a number of smaller fixups to the online checksums test
module which were found during postcommit review and stabilization
work.
* Fix scope increase for PG_TEST_EXTRA: The online checksums tests
have two levels of PG_TEST_EXTRA, checksum and checksums_extended
for extra test runs and test runs with increased randomization.
The logic for increasing the number of test iterations was however
backwards.
* Change stopmode for PITR test: The pitr suite used immediate stop
mode which caused problems on slower machines where the sigquit
would interrupt archive commands leaving partial WAL files behind.
This would then prevent restart. Fix by using fast mode which is
the appropriate mode for the test at hand. Also increase timeouts
to help slower test systems since an expired timeout will incur
the same effect as an immediate standby with a partial WAL left
behind. This issue was observed when running the test suites on
a Raspberry Pi 4 machine.
* Improve logging: The test suite for data checksums use a set of
helper functions in a Perl module to avoid repeating code, this
makes sure that the helper functions do a better job of logging
their test output to make debug easier.
* Remove unused code: wait_for_cluster_crash was used during the
development of online checksums but was never used in any test
which shipped, so remove the function.
* Standby fixes: Ensure no vacuum on pgbench init on standby with
-n to avoid bogus error message in the log, and enable
hot_standby_feedback to prevent queries from getting cancelled
due to recovery on slower systems.
Author: Daniel Gustafsson <daniel@yesql.se>
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se M src/test/modules/test_checksums/t/007_pgbench_standby.pl
M src/test/modules/test_checksums/t/008_pitr.pl
M src/test/modules/test_checksums/t/DataChecksums/Utils.pm
Prevent pg_enable/disable_data_checksums() on standby
commit : b120358c612dce62b493da7682b4df90a10783c9
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:41 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 30 Apr 2026 13:41:41 +0200 These functions missed a RecoveryInProgress() check, allowing them to
be called on a hot standby. Enabling, or disabling, checksums on the
standby only would cause the cluster to get out of sync and replaying
checksum transitions to fail.
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAHg+QDfRk4-S7DMmdbXJnQ-xF=sUpMAKuh8b83ObLqYVKx5QLA@mail.gmail.com M src/backend/postmaster/datachecksum_state.c
Fix double table_close of sequence_rel in copy_sequences().
commit : 2bf6c9ff71c976d0a9fb6c31d6e1da02550b5278
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 30 Apr 2026 16:27:11 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 30 Apr 2026 16:27:11 +0530 sequence_rel was declared at batch scope, so when a row is skipped due to
concurrent drop or insufficient privileges, the end-of-row cleanup closes
the stale pointer from the previous row, tripping the relcache refcount
assertion.
Move sequence_rel inside the per-row loop.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/CAJTYsWWOuw-yfmzotV4jCJ6LLxEsb=STLcGtDYXOxRcU9Te3Pw@mail.gmail.com M src/backend/replication/logical/sequencesync.c
M src/test/subscription/t/036_sequences.pl
Fix errno check based on EINTR in pg_flush_data()
commit : 5941e7f092233adb5415b2a12addea48a97a6618
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 30 Apr 2026 18:44:38 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 30 Apr 2026 18:44:38 +0900 Upon a failure of sync_file_range(), EINTR was checked based on the
returned result of the routine rather than its errno. sync_file_range()
returns -1 on failure, making the check a no-op, invalidating the retry
attempt in this case.
Oversight in 0d369ac65004.
Author: DaeMyung Kang <charsyam@gmail.com>
Discussion: https://postgr.es/m/20260429151811.1810874-1-charsyam@gmail.com
Backpatch-through: 16 M src/backend/storage/file/fd.c
Adjust some incorrect *GetDatum() macros
commit : ac59a90bef4527961ce205c9f890bf3ef0672c7d
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 30 Apr 2026 13:10:19 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 30 Apr 2026 13:10:19 +0900 This reverts portions of commit 6dcfac9696cb, which is wrong in trying
to use a *GetDatum() that matches with the C types of the values read.
*GetDatum() should match with the output argument types of the SQL
functions.
The portions of 6dcfac9696cb that are right regarding this rule are:
- gistget.c, where the GiST support functions use DatumGetUInt16() to
retrieve the strategy number.
- The BRIN code for strategynum, used in syscache lookups.
The adjustments done in this commit are for pageinspect, pg_buffercache
and pg_lock_status().
While double-checking the whole state of the tree regarding non-matching
pairs of DatumGet*() and *GetDatum(), I have found much more code paths
that are incorrect, unrelated to 6dcfac9696cb. These may be adjusted in
the future, in a different patch (perhaps not for v19, as we are already
past feature freeze).
Reported-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/97f9375a-be61-4272-a44d-408337fe8fa6@eisentraut.org
Discussion: https://postgr.es/m/CAJ7c6TMcGu8qmRe1gZfJ-gOzVnZq-t=fwn-UuyStx1w6ZyydMw@mail.gmail.com M contrib/pageinspect/btreefuncs.c
M contrib/pageinspect/ginfuncs.c
M contrib/pageinspect/gistfuncs.c
M contrib/pg_buffercache/pg_buffercache_pages.c
M src/backend/utils/adt/lockfuncs.c
Fix error of pg_stat_reset_shared()
commit : 4bfd0f1b769eca345072ea4da646a0d46a49960c
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 30 Apr 2026 11:12:56 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 30 Apr 2026 11:12:56 +0900 "lock" a values is supported since 4019f725f5d4, but the error message
of the function used when specifying an incorrect value forgot about it.
Author: Maksim Logvinenko <logvinenko-ms@yandex.ru>
Discussion: https://postgr.es/m/433431777389005@mail.yandex.ru M src/backend/utils/adt/pgstatfuncs.c
M src/test/regress/expected/stats.out
Suppress "has no symbols" linker warnings on macOS.
commit : 3dd42ee97b812c0711b4d18e9cab069065367dca
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 29 Apr 2026 12:25:09 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 29 Apr 2026 12:25:09 -0500 After a recent macOS update, building Postgres produces warnings
that look like this:
ranlib: warning: 'libpgport_shlib.a(pg_cpu_x86.c.o)' has no symbols
ranlib: warning: 'libpgport_shlib.a(pg_popcount_x86.c.o)' has no symbols
To fix, add a dummy symbol to files that may otherwise have none.
Per project policy, this is a candidate for back-patching into
out-of-support branches: it suppresses annoying compiler warnings
but changes no behavior.
Reported-by: Zhang Mingli <zmlpostgres@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/229aaaf3-f529-44ed-8e50-00cb6909af21%40Spark
Backpatch-through: 13 M src/port/pg_cpu_x86.c
M src/port/pg_popcount_aarch64.c
M src/port/pg_popcount_x86.c
test_tidstore: Stabilize regression tests by sorting offsets.
commit : a424e31b16ba9f52f4a8a0569daf47e287198404
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 29 Apr 2026 09:10:04 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 29 Apr 2026 09:10:04 -0700 TidStoreSetBlockOffsets() requires its offsets array to be strictly
ascending and asserts this precondition. In test_tidstore, we were
passing random offset numbers deduplicated by a DISTINCT clause in an
array_agg() call directly to the do_set_block_offsets() test
harness. However, DISTINCT without an ORDER BY clause does not
guarantee sorted results according to the SQL standard.
Fix this by sorting the offsets in-place inside do_set_block_offsets()
before calling TidStoreSetBlockOffsets().
While this assertion failure is not observed during regular regression
tests because they use queries simple enough that the optimizer
consistently chooses plans yielding sorted results, it makes sense to
stabilize the test. The failure could theoretically occur depending on
the optimizer's plan choice, and has been reported when experimenting
with certain third-party extensions.
Backpatch to v17, where test_tidstore was introduced, to ensure
extension development on stable branches does not hit this assertion.
Reported-by: Andrei Lepikhov <lepihov@gmail.com>
Author: Andrei Lepikhov <lepihov@gmail.com>
Discussion: https://postgr.es/m/b97f1850-fc7b-43c4-9b04-4e97bb9e7dc0@gmail.com
Backpatch-through: 17 M src/test/modules/test_tidstore/test_tidstore.c
Fix timezone dependence in test_misc/012_ddlutils.pl
commit : df1bac400fb4877ba9f4bda2a29adaf8b40b4bd3
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 29 Apr 2026 11:58:15 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 29 Apr 2026 11:58:15 -0400 The tests introduced in c529ee38b9e are timezone sensitive.
Pin the cluster's timezone to UTC at init time so timestamptz output
is deterministic regardless of the host's local timezone. M src/test/modules/test_misc/t/012_ddlutils.pl
Convert ddlutils regression tests to TAP tests.
commit : c529ee38b9eb26527da05b85dee087676dd8fe37
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 29 Apr 2026 11:10:23 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 29 Apr 2026 11:10:23 -0400 The regression tests for pg_get_role_ddl(), pg_get_database_ddl(),
and pg_get_tablespace_ddl() created databases and tablespaces, which
are heavyweight operations. As noted by Andres Freund, this is
wasteful in the core regression suite which gets run repeatedly.
Convert the three test files (role_ddl.sql, database_ddl.sql,
tablespace_ddl.sql) into a single TAP test that runs once, covering
all the same functionality: basic DDL generation, pretty-printing,
option handling, error cases, permission checks, and edge cases like
quoted names and role memberships.
Discussion: https://postgr.es/m/5c67dc79-909a-4e17-8606-6686667da6c6@dunslane.net M src/test/modules/test_misc/meson.build
A src/test/modules/test_misc/t/012_ddlutils.pl
D src/test/regress/expected/database_ddl.out
D src/test/regress/expected/role_ddl.out
D src/test/regress/expected/tablespace_ddl.out
M src/test/regress/parallel_schedule
D src/test/regress/sql/database_ddl.sql
D src/test/regress/sql/role_ddl.sql
D src/test/regress/sql/tablespace_ddl.sql
Fix nbtree skip array parallel alloc accounting.
commit : 748d871b7cb08302ef312b665bd64012f19fc16c
author : Peter Geoghegan <pg@bowt.ie>
date : Wed, 29 Apr 2026 11:22:23 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Wed, 29 Apr 2026 11:22:23 -0400 btestimateparallelscan neglected to add btps_arrElems[] space overhead
for skip array scan keys that were later output by nbtree preprocessing.
Skip arrays don't actually need to use this space, but a scan with a
subsequent SAOP array will need to subscript btps_arrElems[] using a
simple so->arrayKeys[]-wise offset. so->arrayKeys[] has entries for
both kinds of arrays.
As a result of this oversight, it was possible for an index scan with a
skip array and a lower-order SAOP array to write past the allocated
shared memory boundary when storing the SAOP array's cur_elem. In
practice the problem seems to be limited to scans with many skipped
index columns, since our general approach to estimating the amount of
shared memory that will be required is fairly conservative.
To fix, have btestimateparallelscan request an extra sizeof(int) space
for key columns that might require a skip array later on.
Oversight in commit 92fe23d9, which added the nbtree skip scan
optimization.
Author: Siddharth Kothari <sidkot@google.com>
Discussion: https://postgr.es/m/CAGCUe0Lwk3C0qdkBa+OLpYc7yXwW=pbaz8Sju4xMXEQAmyp+5g@mail.gmail.com
Backpatch-through: 18 M src/backend/access/nbtree/nbtree.c
Cosmetic fixes for radix sort
commit : ca9807dfec5b70751c3524de264e4a16afb2a94a
author : John Naylor <john.naylor@postgresql.org>
date : Wed, 29 Apr 2026 16:14:25 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Wed, 29 Apr 2026 16:14:25 +0700 Do minor comment fixes and remove implicit cast to Datum.
While here, let's prefer crashing instead of entering an infinite
loop in case of future programming mistakes when computing next_level,
suggested by ChangAo Chen.
Discussion: https://postgr.es/m/tencent_49E3F11E74D8A584A2144ED532A490CBC40A@qq.com M src/backend/utils/sort/tuplesort.c
Remove unused ByteaSortSupport.abbreviate field
commit : a0302eac784d170497eca3184d246f945b2e3a7f
author : John Naylor <john.naylor@postgresql.org>
date : Wed, 29 Apr 2026 13:57:07 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Wed, 29 Apr 2026 13:57:07 +0700 Oversight in commit 9303d62c6.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://postgr.es/m/CAJ7c6TOsKmmgyA6EwxKVsNeHFHrWXYdgZivgjo_ujf890BpeeA@mail.gmail.com M src/backend/utils/adt/bytea.c
Fix xid_advance_interval when max_retention_duration is 0.
commit : c210647aeb17692c138014235c7e7a2d9af73b87
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 28 Apr 2026 14:51:38 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 28 Apr 2026 14:51:38 +0530 When a subscription has retain_dead_tuples enabled and maxretention is
zero (unlimited), adjust_xid_advance_interval() mistakenly caps
xid_advance_interval to zero.
This zero interval forces get_candidate_xid() to evaluate
TimestampDifferenceExceeds() as always true, causing the apply worker to
call GetOldestActiveTransactionId() for every WAL message. This
leads to unnecessary ProcArrayLock acquisitions.
Fix this by only capping the interval when maxretention > 0, allowing
the exponential back-off to function properly.
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDdKVnCLHot=AcoPpEiSyDzGz7wGYjAFHVOw57oDtmUDWQ@mail.gmail.com M src/backend/replication/logical/worker.c
Fix wrong datum conversion for subretentionactive in CreateSubscription.
commit : 7424aac088e1c4356b92d2673378dbdd50d1c888
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 28 Apr 2026 12:51:25 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 28 Apr 2026 12:51:25 +0530 Use BoolGetDatum() instead of Int32GetDatum() when storing the boolean
subretentionactive column in pg_subscription. This was an oversight in
a850be2fe6.
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Discussion: https://postgr.es/m/CA+3i_M98-XjE-_fw0p+8xOnw64y2_YLtJfcwvCfsVMn-z2ZjGg@mail.gmail.com M src/backend/commands/subscriptioncmds.c
REPACK CONCURRENTLY: Don't use deferrable primary keys
commit : 832e220d99afa241d80cd3334eb78439719fe744
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 27 Apr 2026 18:22:03 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 27 Apr 2026 18:22:03 +0200 Similarly to logical replication, REPACK CONCURRENTLY needs to ability
to reliably locate a tuple based on an identity. A replica identity
index is okay. Primary keys normally also are, except when they are
deferrable, because a tuple being modified might not yet be indexed,
causing REPACK to fail.
Change the REPACK CONCURRENTLY code to use GetRelationIdentityOrPK(),
similar to what the logical replication code does. (Though we don't yet
support locating tuples based on arbitrary indexes for replica identity
FULL.)
While at it, add a few more test cases for situations that aren't
supported by REPACK, to improve coverage.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Reviewed-by: Yuchen Li <liyuchen_xyz@163.com>
Discussion: https://postgr.es/m/10DD5E13-B45D-44F1-BE08-C63E00ABCAC0@gmail.com M src/backend/commands/repack.c
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql
Fix DELETE/UPDATE FOR PORTION OF with rules
commit : 33db6c4baf17e0fdf2ac08f7d050155985c0d7e3
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 27 Apr 2026 10:29:21 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 27 Apr 2026 10:29:21 +0200 Previously, these test cases would give internal errors or crash. The
fix is to add some missing fields of ForPortionOfExpr to
expression_tree_walker.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://postgr.es/m/CACJufxHs1Hs00EqsZ4NbuAjmYzMzjJyP1sAj12Ne=cBsEVmQOA@mail.gmail.com M src/backend/nodes/nodeFuncs.c
M src/test/regress/expected/for_portion_of.out
M src/test/regress/sql/for_portion_of.sql
doc: Fix grammar in some logical replication pages
commit : 31b9d90f15a57bca72128d512ae7ae624e6b1c93
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 27 Apr 2026 16:17:04 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 27 Apr 2026 16:17:04 +0900 Author: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/CAHut+PuvY_wYLPJ4DTs7NE9Lu2ty4d-OgZAOJC-NvCM=2wwcQQ@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/alter_subscription.sgml
M doc/src/sgml/ref/create_publication.sgml
Fix bogus calls in remove_self_join_rel()
commit : c66d6d19eb1a7bde17acaab421158be9cc94add8
author : Richard Guo <rguo@postgresql.org>
date : Mon, 27 Apr 2026 10:40:37 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 27 Apr 2026 10:40:37 +0900 remove_self_join_rel() called adjust_relid_set() on all_result_relids
and leaf_result_relids but threw away the return value. Since
adjust_relid_set() returns a freshly-built Relids and does not modify
the input in place, the calls did nothing. This has been the case
since the SJE feature went in (commit fc069a3a6).
There has been no observable misbehavior, because the relid being
passed is guaranteed not to be a member of either set. At the point
remove_self_join_rel() runs, those sets contain only resultRelation;
inheritance children have not been added yet, as that happens later in
query_planner(), in expand_single_inheritance_child() called from
add_other_rels_to_query(). And remove_self_joins_recurse() rejects
parse->resultRelation as an SJE candidate to preserve the EvalPlanQual
mechanism. Even with the result assigned, the calls would be no-ops
in practice.
Rather than make the calls do the cleanup they pretend to do, replace
them with assertions of the invariant. Any future loosening of the
SJE candidate filter -- for instance to allow eliminating a result
relation under provable conditions -- will trip the assertion and
force whoever does it to revisit this code.
Additionally, decorate adjust_relid_set() with pg_nodiscard so that
any future accidental discard of its return value is caught at compile
time.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAMbWs49fYQcqJfJ_Gtn8r1GFNoYtb1=2AUab4ieuqY4Zid9ocQ@mail.gmail.com M src/backend/optimizer/plan/analyzejoins.c
M src/include/rewrite/rewriteManip.h
Fix some memory leaks in the WAL receiver
commit : b801d5eef17fde6d1311eaefa0f125c55731e30c
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 27 Apr 2026 10:32:45 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 27 Apr 2026 10:32:45 +0900 These are old leaks, that can pile up if a WAL receiver stays alive,
waiting for new WAL data after the sender has switched to a new
timeline.
While this is technically a bug, the impact is minimal and would only
become noticeable if the WAL sender handles a lot of timeline switches,
so no backpatch is done. Note that in most cases, primary_conninfo
would be updated in a standby to point to a new sender, meaning a
restart of the WAL receiver. Let's be clean on HEAD, though.
Author: DaeMyung Kang <charsyam@gmail.com>
Discussion: https://postgr.es/m/20260426170100.847923-1-charsyam@gmail.com
Discussion: https://postgr.es/m/20260426170219.849330-1-charsyam@gmail.com M src/backend/replication/walreceiver.c
Fix new test with comma in build directory.
commit : f9c638054c5b29d519bc8530f95da8a74b47af51
author : Noah Misch <noah@leadboat.com>
date : Sun, 26 Apr 2026 15:03:51 -0700
committer: Noah Misch <noah@leadboat.com>
date : Sun, 26 Apr 2026 15:03:51 -0700 Quote pg_hosts.conf fields derived from the build directory, since
hba.c:next_token() treats a comma as a token separator. Commit
4f433025f666fa4a6209f0e847715767fb1c7ace introduced pg_hosts.conf and
this test. A build directory name containing a comma worked before that
commit. A build directory name containing a quote character has not
worked, so don't handle that.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/20260426213252.7a@rfd.leadboat.com M src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
Don't use INT64_FORMAT in translatable string
commit : 7d7e58feef21e7781e8e99a960fae4d6d5a2a927
author : Peter Eisentraut <peter@eisentraut.org>
date : Sat, 25 Apr 2026 20:23:03 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sat, 25 Apr 2026 20:23:03 +0200 Use PRId64 instead. M src/bin/pg_test_timing/pg_test_timing.c
Update time zone data files to tzdata release 2026b.
commit : f64f62f5bedaf005ab1a0f20426dd870cd142e4a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 24 Apr 2026 12:28:35 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 24 Apr 2026 12:28:35 -0400 British Columbia (America/Vancouver) moved to permanent UTC-07 on
2026-03-09, which will affect their clocks beginning on 2026-11-01.
For lack of any clarity on the point, assume their TZ abbreviation
will be MST from that time forward.
Moldova (Europe/Chisinau) has followed EU DST transition times since
2022.
Backpatch-through: 14 M src/timezone/data/tzdata.zi
meson: Differentiate top-level and custom targets
commit : 3b28dad70e2fa57a973697d51242c284d475c7df
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 09:51:09 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 09:51:09 +0200 We need to create top-level targets to run targets with the ninja
command like `ninja <target_name>`.
Some targets (man, html, ...) have the same target name on both
top-level and custom target. This creates a confusion for the meson
build:
$ meson compile -C build html
```
ERROR: Can't invoke target `html`: ambiguous name. Add target type
and/or path:
- ./doc/src/sgml/html:custom
- ./doc/src/sgml/html:alias
```
Solve that problem by adding '-custom' suffix to these problematic
targets' custom target names. Top-level targets can be called with
both meson and ninja now:
$ meson compile -C build html
$ ninja -C build html
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Suggested-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/5508e572-79ae-4b20-84d0-010a66d077f2%40eisentraut.org M doc/src/sgml/meson.build
pg_get_viewdef() and lateral references in COLUMNS of GRAPH_TABLE
commit : 9d2979dd6856e160f35544d79eb11f2c68c30985
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 09:12:03 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 09:12:03 +0200 Expressions in GRAPH_TABLE COLUMNS list may have lateral references.
get_rule_expr() requires lateral namespaces to deparse such
references. get_from_clause_item() does not pass them when processing
the expressions in COLUMNS list causing ERROR "bogus varlevelsup: 0
offset 0". Fix get_from_clause_item() to pass input deparse_context
containing lateral namespaces to get_rule_expr() instead of the dummy
context.
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcLVa2iBnggkHxY4itZbXtDMfsYHEjnCUYe9hNbnxDi-w%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 collation of expressions in GRAPH_TABLE COLUMNS clause
commit : ac3bcc041c5cc2b7ce522d4ce6e6c4653f1263ea
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 08:43:26 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 08:43:26 +0200 GRAPH_TABLE clause is converted into a rangetable entry, which is
ignored by assign_query_collations(). Hence we assign collations
while transforming its parts. But expressions in COLUMNS clause
missed that treatment, so fix that.
While at it, also add comments about collation assignment to the parts
of GRAPH_TABLE clause, and also fix a small grammar issue.
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAHg+QDc4aaiufYSgrwMMPMMRTPtQ66SghcrPFbWJFZMqNaG+BA@mail.gmail.com M src/backend/parser/parse_clause.c
M src/backend/parser/parse_graphtable.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Fix typos and grammar in graph table rewrite code
commit : 9082680c34e987d51f84c217e1dbd140d4a4517b
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 08:27:04 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 08:27:04 +0200 Reported-by: Lakshmi N <lakshmin.jhs@gmail.com>
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CA+3i_M9gpUGjH-BkJk=UFjK16jq9fEQHpmZ1cxpJO+xM4hWC+A@mail.gmail.com M src/backend/commands/propgraphcmds.c
M src/backend/rewrite/rewriteGraphTable.c
Check for stack overflow when rewriting graph queries
commit : 2ff289d03939498a656a0c6cf2da08623f8357b4
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 08:18:21 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 24 Apr 2026 08:18:21 +0200 generate_queries_for_path_pattern_recurse() and
generate_setop_from_pathqueries() are recursive functions. For a
property graph with hundreds of tables, a graph pattern with a handful
element patterns can cause stack overflow. Fix it by calling
check_stack_depth() at the beginning of these functions.
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAHg+QDfgK0xddH8f3eAb+UVn7sBDOnv8RvM6OkP4HtHAt6aD7w@mail.gmail.com M src/backend/rewrite/rewriteGraphTable.c
pg_test_timing: store timing deltas in int64
commit : 863c4b827d92879dbd526a43a23c33fa9bd23b4f
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 24 Apr 2026 12:11:40 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 24 Apr 2026 12:11:40 +0900 Commit 0b096e379e6 changed pg_test_timing to measure timing
differences in nanoseconds instead of microseconds, but the resulting
deltas continued to be stored in int32.
That can overflow for large gaps (for example, values greater than about
2.14 seconds in nanoseconds), leading to truncation or incorrect output.
This commit fixes the issue by storing measured timing deltas in int64.
This prevents overflow for large values and better matches
nanosecond-resolution measurements.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Xiaopeng Wang <wxp_728@163.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/F780CEEB-A237-4302-9F55-60E9D8B6533D@gmail.com M src/bin/pg_test_timing/pg_test_timing.c
Fix incorrect logic for hashed IN / NOT IN with non-strict operators
commit : 94219a73f79d49c0f3576af57fa8241fbf230395
author : David Rowley <drowley@postgresql.org>
date : Fri, 24 Apr 2026 14:03:12 +1200
committer: David Rowley <drowley@postgresql.org>
date : Fri, 24 Apr 2026 14:03:12 +1200 ExecEvalHashedScalarArrayOp(), when using a strict equality function,
performs a short-circuit when looking up NULL values. When the function
is non-strict, the code incorrectly looked up the hash table for a
zero-valued Datum, which could have resulted in an accidental true
return if the hash table contained zero valued Datum, or could result
in a crash for non-byval types.
Here we fix this by adding an extra step when we build the hash table to
check what the result of a NULL lookup would be. This requires looping
over the array and checking what the non-hashed version of the code
would do. We cache the results of that in the expression so that we can
reuse the result any time we're asked to search for a NULL value.
It's important to note that non-strict equality functions are free to
treat any NULL value as equal to any non-NULL value. For example,
someone may wish to design a type that treats an empty string and NULL
as equal.
All built-in types have strict equality functions, so this could affect
custom / user-defined types.
Author: Chengpeng Yan <chengpeng_yan@outlook.com>
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: ChangAo Chen <cca5507@qq.com>
Discussion: https://postgr.es/m/A16187AE-2359-4265-9F5E-71D015EC2B2D@outlook.com
Backpatch-through: 14 M src/backend/executor/execExprInterp.c
M src/include/executor/execExpr.h
M src/test/regress/expected/expressions.out
M src/test/regress/sql/expressions.sql
pg_test_timing: fix unit in backward-clock warning
commit : 019cc9962bdbe2a3aaeb1f384d7a0b0d494fc311
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 24 Apr 2026 08:59:14 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 24 Apr 2026 08:59:14 +0900 pg_test_timing reports timing differences in nanoseconds in master, and
in microseconds in v14 through v18, but previously the backward-clock
warning incorrectly labeled the value as milliseconds.
This commit fixes the warning message to use "ns" in master and
"us" in v14 through v18, matching the actual unit being reported.
Backpatch to all supported versions.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Xiaopeng Wang <wxp_728@163.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/F780CEEB-A237-4302-9F55-60E9D8B6533D@gmail.com
Backpatch-through: 14 M src/bin/pg_test_timing/pg_test_timing.c
Add missing source files to several nls.mk
commit : aa27a3331abb704756b4433fecca0f41c3cd2700
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 23 Apr 2026 21:52:02 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 23 Apr 2026 21:52:02 +0200 M src/bin/pg_basebackup/nls.mk
M src/bin/pg_checksums/nls.mk
M src/bin/pg_combinebackup/nls.mk
M src/bin/pg_resetwal/nls.mk
M src/bin/pg_upgrade/nls.mk
M src/bin/pg_waldump/nls.mk
Don't call CheckAttributeType() with InvalidOid on dropped cols
commit : 713bce9484dea8bce93ec7abacd0e47ddf30dcf5
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 23 Apr 2026 21:05:27 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 23 Apr 2026 21:05:27 +0300 If CheckAttributeType() is called with InvalidOid, it performs a bunch
of pointless, futile syscache lookups with InvalidOid, but ultimately
tolerates it and has no effect. We were calling it with InvalidOid on
dropped columns, but it seems accidental that it works, so let's stop
doing it.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/93ce56cd-02a6-4db1-8224-c8999372facc@iki.fi
Backpatch-through: 14 M src/backend/catalog/heap.c
Don't allow composite type to be member of itself via multirange
commit : dd4069197650d5c6d1d6385ceccc43ae2ccffc67
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 23 Apr 2026 21:28:11 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 23 Apr 2026 21:28:11 +0300 CheckAttributeType() checks that a composite type is not made a member
of itself with ALTER TABLE ADD COLUMN or ALTER TYPE ADD ATTRIBUTE,
even indirectly via a domain, array, another composite type or a range
type. But it missed checking for multiranges. That was a simple
oversight when multiranges were added.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/93ce56cd-02a6-4db1-8224-c8999372facc@iki.fi
Backpatch-through: 14 M src/backend/catalog/heap.c
M src/test/regress/expected/multirangetypes.out
M src/test/regress/sql/multirangetypes.sql
Move REPACK (CONCURRENTLY) test out of stock regression tests
commit : 4b2aa4b39cbac71d9795ff760af3991a681eae00
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 23 Apr 2026 12:34:41 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 23 Apr 2026 12:34:41 +0200 These tests sometimes run with wal_level=minimal, which does not allow
to run REPACK (CONCURRENTLY). Move them to test_decoding, which is
ensured to run with high enough wal_level.
Discussion: https://postgr.es/m/260901.1776696126@sss.pgh.pa.us M contrib/test_decoding/Makefile
A contrib/test_decoding/expected/repack.out
M contrib/test_decoding/meson.build
A contrib/test_decoding/sql/repack.sql
M src/test/regress/expected/cluster.out
M src/test/regress/sql/cluster.sql
psql: Improve describe footer titles for publications.
commit : 2e1d4fdb10e6636a7ab64f801d880b4d326ab822
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 23 Apr 2026 14:10:03 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 23 Apr 2026 14:10:03 +0530 The psql describe (`\d`) footer titles were previously unintuitive when
listing publications that included or excluded specific tables. Even
though the tag for included publications was pre-existing, it is better
to update it to "Included in publications:" to match the phrasing of
the "Excluded from publications:" tag.
Footer titles for sequence and schema descriptions have been updated
similarly to maintain consistency.
Reported-by: Álvaro Herrera <alvherre@kurilemu.de>
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Yuchen Li <liyuchen_xyz@163.com>
Discussion: https://postgr.es/m/aeDs7iZUox1bbKAK%40alvherre.pgsql M doc/src/sgml/logical-replication.sgml
M src/bin/psql/describe.c
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql
Avoid casting void * function arguments
commit : 71123a5454fbb0cf7f44ef1151e32d650be4cc31
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 23 Apr 2026 08:08:57 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 23 Apr 2026 08:08:57 +0200 Like commit c3c240537f6, but for newly added code. M contrib/pg_trgm/trgm_op.c
Fix new-to-v19 -Wshadow warnings
commit : 4f0cbc6fb5df6dec84482d0bf0ff2d2d4be58132
author : David Rowley <drowley@postgresql.org>
date : Thu, 23 Apr 2026 16:49:29 +1200
committer: David Rowley <drowley@postgresql.org>
date : Thu, 23 Apr 2026 16:49:29 +1200 There's some talk about upgrading our current -Wshadow=compatible-local
up to -Wshadow. There's some pending questions as to whether the churn
and extra backpatching pain are worthwhile for doing all of them. We
can't use the latter argument for ones that are new to v19, providing we
fix them now. So let's fix those ones so that the problem is not any
worse for if we decide to fix the remainder for v20.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Yuchen Li <liyuchen_xyz@163.com>
Discussion: https://postgr.es/m/CAApHDvp=rx5GxM=yW8QhFF3noXtYt7LkOxJ7zkaPOzpti4Gm8w@mail.gmail.com M src/backend/commands/tablecmds.c
M src/backend/commands/wait.c
M src/backend/postmaster/datachecksum_state.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/psql/describe.c
catcache.c: use C_COLLATION_OID for texteqfast/texthashfast.
commit : dbf217c1c7c2744a18db489c255255e07cfbb110
author : Jeff Davis <jdavis@postgresql.org>
date : Wed, 22 Apr 2026 10:22:44 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Wed, 22 Apr 2026 10:22:44 -0700 The problem report was about setting GUCs in the startup packet for a
physical replication connection. Setting the GUC required an ACL
check, which performed a lookup on pg_parameter_acl.parname. The
catalog cache was hardwired to use DEFAULT_COLLATION_OID for
texteqfast() and texthashfast(), but the database default collation
was uninitialized because it's a physical walsender and never connects
to a database. In versions 18 and later, this resulted in a NULL
pointer dereference, while in version 17 it resulted in an ERROR.
As the comments stated, using DEFAULT_COLLATION_OID was arbitrary
anyway: if the collation actually mattered, it should have used the
column's actual collation. (In the catalog, some text columns are the
default collation and some are "C".)
Fix by using C_COLLATION_OID, which doesn't require any initialization
and is always available. When any deterministic collation will do,
it's best to consistently use the simplest and fastest one, so this is
a good idea anyway.
Another problem was raised in the thread, which this commit doesn't
fix (see second discussion link).
Reported-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/D18AD72A-5004-4EF8-AF80-10732AF677FA@yandex-team.ru
Discussion: https://postgr.es/m/4524ed61a015d3496fc008644dcb999bb31916a7.camel%40j-davis.com
Backpatch-through: 17 M src/backend/utils/cache/catcache.c
pg_upgrade: Fix detection of invalid logical replication slots.
commit : e471dc59121932d669d69d0683c71d5df3b527e3
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 22 Apr 2026 09:59:46 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 22 Apr 2026 09:59:46 -0700 Commit 7a1f0f8747a optimized the slot verification query but
overlooked cases where all logical replication slots are already
invalidated. In this scenario, the CTE returns no rows, causing the
main query (which used a cross join) to return an empty result even
when invalid slots exist.
This commit fixes this by using a LEFT JOIN with the CTE, ensuring
that slots are properly reported even if the CTE returns no rows.
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CA+3i_M8eT6j8_cBHkYykV-SXCxbmAxpVSKptjDVq+MFtpT-Paw@mail.gmail.com M src/bin/pg_upgrade/info.c
Harmonize function parameter names for Postgres 19.
commit : d14f69a32a17924d93838491bc8e78a1a9b46807
author : Peter Geoghegan <pg@bowt.ie>
date : Wed, 22 Apr 2026 12:47:19 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Wed, 22 Apr 2026 12:47:19 -0400 Make sure that function declarations use names that exactly match the
corresponding names from function definitions in a few places. Most of
these inconsistencies were introduced during Postgres 19 development.
This commit was written with help from clang-tidy, by mechanically
applying the same rules as similar clean-up commits (the earliest such
commit was commit 035ce1fe). M contrib/jsonb_plperl/jsonb_plperl.c
M contrib/sepgsql/sepgsql.h
M src/backend/access/heap/pruneheap.c
M src/backend/commands/propgraphcmds.c
M src/backend/commands/repack.c
M src/backend/parser/gram.y
M src/backend/replication/logical/conflict.c
M src/backend/replication/pgrepack/pgrepack.c
M src/backend/rewrite/rewriteGraphTable.c
M src/backend/storage/buffer/bufmgr.c
M src/bin/pg_upgrade/multixact_read_v18.h
M src/include/commands/repack.h
M src/include/executor/executor.h
M src/include/postmaster/datachecksum_state.h
M src/include/replication/syncrep.h
M src/include/tsearch/ts_locale.h
M src/pl/plperl/plperl.c
M src/timezone/localtime.c
Guard against overly-long numeric formatting symbols from locale.
commit : a50777680f6678bae39ffa04d01633bd023a5f48
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 22 Apr 2026 12:41:00 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 22 Apr 2026 12:41:00 -0400 to_char() allocates its output buffer with 8 bytes per formatting
code in the pattern. If the locale's currency symbol, thousands
separator, or decimal or sign symbol is more than 8 bytes long,
in principle we could overrun the output buffer. No such locales
exist in the real world, so it seems sufficient to truncate the
symbol if we do see it's too long.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/638232.1776790821@sss.pgh.pa.us
Backpatch-through: 14 M src/backend/utils/adt/formatting.c
Prevent some buffer overruns in spell.c's parsing of affix files.
commit : d7970e7e951bb39b0d5d7ae633fc7f1af54aa932
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 22 Apr 2026 12:02:15 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 22 Apr 2026 12:02:15 -0400 parse_affentry() and addCompoundAffixFlagValue() each collect fields
from an affix file into working buffers of size BUFSIZ. They failed
to defend against overlength fields, so that a malicious affix file
could cause a stack smash. BUFSIZ (typically 8K) is certainly way
longer than any reasonable affix field, but let's fix this while
we're closing holes in this area.
I chose to do this by silently truncating the input before it can
overrun the buffer, using logic comparable to the existing logic in
get_nextfield(). Certainly there's at least as good an argument for
raising an error, but for now let's follow the existing precedent.
Reported-by: Igor Stepansky <igor.stepansky@orca.security>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/864123.1776810909@sss.pgh.pa.us
Backpatch-through: 14 M src/backend/tsearch/spell.c
Prevent buffer overrun in spell.c's CheckAffix().
commit : 844bb90d49f78c44c6ed395d245ff8a500b16395
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 22 Apr 2026 10:47:56 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 22 Apr 2026 10:47:56 -0400 This function writes into a caller-supplied buffer of length
2 * MAXNORMLEN, which should be plenty in real-world cases.
However a malicious affix file could supply an affix long
enough to overrun that. Defend by just rejecting the match
if it would overrun the buffer. I also inserted a check of
the input word length against Affix->replen, just to be sure
we won't index off the buffer, though it would be caller error
for that not to be true.
Also make the actual copying steps a bit more readable, and remove
an unnecessary requirement for the whole input word to fit into the
output buffer (even though it always will with the current caller).
The lack of documentation in this code makes my head hurt, so
I also reverse-engineered a basic header comment for CheckAffix.
Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/641711.1776792744@sss.pgh.pa.us
Backpatch-through: 14 M src/backend/tsearch/spell.c
Preserve extension dependencies on indexes during partition merge/split
commit : 713e553e3213d53f4ba25dcb7a8c41994b7cab9d
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 22 Apr 2026 14:32:57 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Wed, 22 Apr 2026 14:32:57 +0300 When using ALTER TABLE ... MERGE PARTITIONS or ALTER TABLE ... SPLIT
PARTITION, extension dependencies on partition indexes were being lost.
This happened because the new partition indexes are created fresh from
the parent partitioned table's indexes, while the old partition indexes
(with their extension dependencies) are dropped.
Fix this by collecting extension dependencies from source partition
indexes before detaching them, then applying those dependencies to the
corresponding new partition indexes after they're created. The mapping
between old and new indexes is done via their common parent partitioned
index.
For MERGE operations, all source partition indexes sharing a parent
partitioned index must have the same extension dependencies; if they
differ, an error naming both conflicting partition indexes is raised.
The check is implemented by collecting one entry per partition index,
sorting by parent index OID, and comparing adjacent entries in a single
pass. This is order-independent: the same set of partitions produces
the same decision regardless of the order they are listed in the MERGE
command, and subset mismatches are caught in both directions.
For SPLIT operations, the new partition indexes simply inherit all
extension dependencies from the source partition's index.
The regression tests exercising this feature live under
src/test/modules/test_extensions, where the test_ext3 and test_ext5
extensions are available; core regression tests cannot assume any
particular extension is installed.
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>
Reported-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/CALdSSPjXtzGM7Uk4fWRwRMXcCczge5uNirPQcYCHKPAWPkp9iQ%40mail.gmail.com M doc/src/sgml/ref/alter_table.sgml
M src/backend/commands/tablecmds.c
M src/test/modules/test_extensions/expected/test_extdepend.out
M src/test/modules/test_extensions/sql/test_extdepend.sql
M src/tools/pgindent/typedefs.list
Fix UPDATE/DELETE ... WHERE CURRENT OF on a table with virtual columns.
commit : 5548a969b65d4e0d5045d9db0bcac062a9a3e3c7
author : Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 22 Apr 2026 11:50:17 +0100
committer: Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 22 Apr 2026 11:50:17 +0100 Formerly, attempting to use WHERE CURRENT OF to update or delete from
a table with virtual generated columns would fail with the error
"WHERE CURRENT OF on a view is not implemented".
The reason was that the check preventing WHERE CURRENT OF from being
used on a view was in replace_rte_variables_mutator(), which presumed
that the only way it could get there was as part of rewriting a query
on a view. That is no longer the case, since replace_rte_variables()
is now also used to expand the virtual generated columns of a table.
Fix by doing the check for WHERE CURRENT OF on a view at parse time.
This is safe, since it is no longer possible for the relkind to change
after the query is parsed (as of b23cd185f).
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDc_TwzSgb=B_QgNLt3mvZdmRK23rLb+RkanSQkDF40GjA@mail.gmail.com
Backpatch-through: 18 M src/backend/parser/analyze.c
M src/backend/rewrite/rewriteManip.c
M src/test/regress/expected/generated_virtual.out
M src/test/regress/expected/portals.out
M src/test/regress/sql/generated_virtual.sql
M src/test/regress/sql/portals.sql
Fix expansion of EXCLUDED virtual generated columns.
commit : 783425175809c91f702dec72b0d52cab7692f1a9
author : Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 22 Apr 2026 09:03:44 +0100
committer: Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 22 Apr 2026 09:03:44 +0100 If the SET or WHERE clause of an INSERT ... ON CONFLICT command
references EXCLUDED.col, where col is a virtual generated column, the
column was not properly expanded, leading to an "unexpected virtual
generated column reference" error, or incorrect results.
The problem was that expand_virtual_generated_columns() would expand
virtual generated columns in both the SET and WHERE clauses and in the
targetlist of the EXCLUDED pseudo-relation (exclRelTlist). Then
fix_join_expr() from set_plan_refs() would turn the expanded
expressions in the SET and WHERE clauses back into Vars, because they
would be found to match the expression entries in the indexed tlist
produced from exclRelTlist.
To fix this, arrange for expand_virtual_generated_columns() to not
expand virtual generated columns in exclRelTlist. This forces
set_plan_refs() to resolve generation expressions in the query using
non-virtual columns, as required by the executor.
In addition, exclRelTlist now always contains only Vars. That was
something already claimed in a couple of existing comments in the
planner, which relied on that fact to skip some processing, though
those did not appear to constitute active bugs.
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDf7wTLz_vqb1wi1EJ_4Uh+Vxm75+b4c-Ky=6P+yOAHjbQ@mail.gmail.com
Backpatch-through: 18 M src/backend/optimizer/prep/prepjointree.c
M src/test/regress/expected/generated_virtual.out
M src/test/regress/sql/generated_virtual.sql
Fix some const qualifier use in ri_triggers.c
commit : 1b9dc2cb75745329fc133953a6e86f17ff472d36
author : Amit Langote <amitlan@postgresql.org>
date : Wed, 22 Apr 2026 09:33:10 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Wed, 22 Apr 2026 09:33:10 +0900 The ri_FetchConstraintInfo() and ri_LoadConstraintInfo() functions
were declared to return const RI_ConstraintInfo *, but callers
sometimes need to modify the struct, requiring casts to drop the
const. Remove the misapplied const qualifiers and the casts that
worked around them.
Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/548600ed-8bbb-4e50-8fc3-65091b122276@eisentraut.org M src/backend/utils/adt/ri_triggers.c
Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index
commit : 9d3e094f12cce57a477c3df92f411b2fae816b60
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 22 Apr 2026 10:32:10 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 22 Apr 2026 10:32:10 +0900 This commit tweaks ALTER INDEX .. ATTACH PARTITION to attempt a
validation of a parent index in the case where an index is already
attached but the parent is not yet valid. This occurs in cases where a
parent index was created invalid such as with CREATE INDEX ONLY, but was
left invalid after an invalid child index was attached (partitioned
indexes set indisvalid to false if at least one partition is
!indisvalid, indisvalid is true in a partitioned table iff all
partitions are indisvalid). This could leave a partition tree in a
situation where a user could not bring the parent index back to valid
after fixing the child index, as there is no built-in mechanism to do
so. This commit relies on the fact that repeated ATTACH PARTITION
commands on the same index silently succeed.
An invalid parent index is more than just a passive issue. It causes
for example ON CONFLICT on a partitioned table if the invalid parent
index is used to enforce a unique constraint.
Some test cases are added to track some of problematic patterns, using a
set of partition trees with combinations of invalid indexes and ATTACH
PARTITION.
Reported-by: Mohamed Ali <moali.pg@gmail.com>
Author: Sami Imseih <sanmimseih@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: http://postgr.es/m/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com
Backpatch-through: 14 M src/backend/commands/tablecmds.c
M src/test/regress/expected/indexing.out
M src/test/regress/sql/indexing.sql
Fix not-quite-right Makefile for src/test/modules/test_checksums.
commit : 64b2b4212486406771089aff7ba015c650334f66
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 21 Apr 2026 18:29:24 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 21 Apr 2026 18:29:24 -0400 This neglected to set TAP_TESTS = 1, and partially compensated
for that by writing duplicative hand-made rules for check and
installcheck. That's not really sufficient though. The way
I noticed the error was that "make distclean" didn't clean out
the tmp_check subdirectory, and there might be other consequences.
Do it the standard way instead. M src/test/modules/test_checksums/Makefile
bufmgr: use I/O stats arguments in FlushUnlockedBuffer()
commit : 31b0544b32bc9e08c8c6775aed7ca2b808390f80
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 17:47:22 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 17:47:22 -0400 FlushUnlockedBuffer() accepted io_object and io_context arguments but
hardcoded IOOBJECT_RELATION and IOCONTEXT_NORMAL when calling
FlushBuffer(). Pass them through instead. Also fix FlushBuffer() to use
its io_object parameter for I/O timing stats rather than hardcoding
IOOBJECT_RELATION.
Not actively broken since all current callers pass IOOBJECT_RELATION and
IOCONTEXT_NORMAL, so not backpatched.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/BC97546F-5C15-42F2-AD57-CFACDB9657D0@gmail.com M src/backend/storage/buffer/bufmgr.c
Stabilize btree_gist test against on-access VM setting
commit : 62407d26b7c9e619ed696fced88fdacc5d1ae522
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 17:32:45 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 17:32:45 -0400 The btree_gist enum test expects a bitmap heap scan. Since b46e1e54d07
enabled setting the VM during on-access pruning and 378a21618 set
pd_prune_xid on INSERT, scans of enumtmp may set pages all-visible.
If autovacuum or autoanalyze then updates pg_class.relallvisible, the
planner could choose an index-only scan instead.
Make the enumtmp a temp table to exclude it from autovacuum/autoanalyze.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/46733d68-aec0-4d09-8120-4c66b87047a4%40gmail.com M contrib/btree_gist/expected/enum.out
M contrib/btree_gist/sql/enum.sql
Stabilize plancache test against on-access VM setting
commit : 85ae8ab05334f335e3b97d4a4b6309f926eda39c
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 14:36:59 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 14:36:59 -0400 Since b46e1e54d07 allowed setting the VM on-access and 378a21618 set
pd_prune_xid on INSERT, the testing of generic/custom plans in
src/test/regress/sql/plancache.sql was destabilized.
One of the queries of test_mode could have set the pages all-visible and
if autovacuum/autoanalyze ran and updated pg_class.relallvisible, it
would affect whether we got an index-only or sequential scan.
Preclude this by disabling autovacuum and autoanalyze for test_mode and
carefully sequencing when ANALYZE is run.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/71277259-264e-4983-a201-938b404049d7%40gmail.com M src/test/regress/expected/plancache.out
M src/test/regress/sql/plancache.sql
Make local buffers pin limit more conservative
commit : da6874635db2e8ab95150481c992f03ec6094805
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 11:01:57 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 21 Apr 2026 11:01:57 -0400 GetLocalPinLimit() and GetAdditionalLocalPinLimit(), currently in use
only by the read stream, previously allowed a backend to pin all
num_temp_buffers local buffers. This meant that the read stream could
use every available local buffer for read-ahead, leaving none for other
concurrent pin-holders like other read streams and related buffers like
the visibility map buffer needed during on-access pruning.
This became more noticeable since b46e1e54d07, which allows on-access
pruning to set the visibility map, which meant that some scans also
needed to pin a page of the VM. It caused a test in
src/test/regress/sql/temp.sql to fail in some cases.
Cap the local pin limit to num_temp_buffers / 4, providing some
headroom. This doesn't guarantee that all needed pins will be available
— for example, a backend can still open more cursors than there are
buffers — but it makes it less likely that read-ahead will exhaust the
pool.
Note that these functions are not limited by definition to use in the
read stream; however, this cap should be appropriate in other contexts.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/97529f5a-ec10-46b1-ab50-4653126c6889%40gmail.com M src/backend/storage/buffer/localbuf.c
Remove gen_node_support.pl's ad-hoc ABI stability check.
commit : 1cd3cd372ae497f3134126edc96aa56352e7f4a0
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 21 Apr 2026 10:58:00 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 21 Apr 2026 10:58:00 -0400 We installed this in commit eea9fa9b2 to protect against foreseeable
mistakes that would break ABI in stable branches by renumbering
NodeTag enum entries. However, we now have much more thorough
ABI stability checks thanks to buildfarm members using libabigail
(see the .abi-compliance-history mechanism). So this incomplete,
single-purpose check seems like an anachronism. I wouldn't object
to keeping it were it not that it requires an additional manual step
when making a new stable git branch. That seems like something easy
to screw up, so let's get rid of it.
This patch just removes the logic that checks for changes in the last
auto-assigned NodeTag value. We still need eea9fa9b2's cross-check
on the supplied list of header files, to prevent divergence between
the makefile and meson build systems. We'll also sometimes need the
nodetag_number() infrastructure for hand-assigning new NodeTags in
stable branches.
Discussion: https://postgr.es/m/1458883.1776143073@sss.pgh.pa.us M src/backend/nodes/gen_node_support.pl
M src/tools/RELEASE_CHANGES
Make plpgsql_trap test more robust and less resource-intensive.
commit : 81c082f51ad8834d28fdfc83b1fbe67ec4e51246
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 21 Apr 2026 10:54:39 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 21 Apr 2026 10:54:39 -0400 We were using "select count(*) into x from generate_series(1,
1_000_000_000_000)" to waste one second waiting for a statement
timeout trap. Aside from consuming CPU to little purpose, this could
easily eat several hundred MB of temporary file space, which has been
observed to cause out-of-disk-space errors in the buildfarm.
Let's just use "pg_sleep(10)", which is far less resource-intensive.
Also update the "when others" exception handler so that if it does
ever again trap an error, it will tell us what error. The cause of
these intermittent buildfarm failures had been obscure for awhile.
Discussion: https://postgr.es/m/557992.1776779694@sss.pgh.pa.us
Backpatch-through: 14 M src/pl/plpgsql/src/expected/plpgsql_trap.out
M src/pl/plpgsql/src/sql/plpgsql_trap.sql
Fix a set of typos and grammar issues across the tree
commit : d3bba041543593eb5341683107d899734dc8e73e
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 21 Apr 2026 14:46:22 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 21 Apr 2026 14:46:22 +0900 This batch is similar to 462fe0ff6215 and addresses a variety of code
style issues, including grammar mistakes, typos, inconsistent variable
names in function declarations, and incorrect function names in comments
and documentation. These fixes have accumulated on the community
mailing lists since the commit mentioned above.
Notably, Alexander Lakhin previously submitted a patch identifying many
of the trivial typos and grammar issues that had been reported on
pgsql-hackers. His patch covered a somewhat large portion of the issues
addressed here, though not all of them.
The documentation changes only affect HEAD. M contrib/btree_gist/btree_utils_var.h
M contrib/pg_overexplain/pg_overexplain.c
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_join.c
M contrib/pg_plan_advice/pgpa_output.c
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_stash_advice/stashfuncs.c
M contrib/pg_stash_advice/stashpersist.c
M contrib/pg_trgm/trgm_op.c
M contrib/postgres_fdw/postgres_fdw.c
M doc/src/sgml/pgstashadvice.sgml
M doc/src/sgml/ref/alter_property_graph.sgml
M doc/src/sgml/ref/alter_table.sgml
M doc/src/sgml/ref/cluster.sgml
M doc/src/sgml/release-19.sgml
M src/backend/access/common/indextuple.c
M src/backend/access/common/tidstore.c
M src/backend/access/heap/heapam_visibility.c
M src/backend/access/rmgrdesc/gindesc.c
M src/backend/access/transam/commit_ts.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/xlog.c
M src/backend/commands/explain_state.c
M src/backend/commands/repack.c
M src/backend/commands/vacuumparallel.c
M src/backend/executor/execTuples.c
M src/backend/executor/nodeModifyTable.c
M src/backend/lib/hyperloglog.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/optimizer/path/indxpath.c
M src/backend/parser/analyze.c
M src/backend/parser/parse_graphtable.c
M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/replication/logical/origin.c
M src/backend/replication/logical/worker.c
M src/backend/rewrite/rewriteGraphTable.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/storage/aio/method_worker.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/predicate.c
M src/backend/utils/adt/network.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/error/elog.c
M src/bin/pg_combinebackup/t/011_ib_truncation.pl
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_restore.c
M src/bin/pg_resetwal/pg_resetwal.c
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/controldata.c
M src/common/wchar.c
M src/include/access/tableam.h
M src/include/postmaster/datachecksum_state.h
M src/interfaces/libpq/fe-protocol3.c
M src/test/modules/test_checksums/t/003_standby_restarts.pl
M src/test/modules/test_checksums/t/005_injection.pl
M src/test/modules/test_checksums/test_checksums.c
M src/test/modules/test_extensions/t/001_extension_control_path.pl
M src/test/recovery/t/026_overwrite_contrecord.pl
M src/test/regress/expected/fast_default.out
M src/test/regress/sql/fast_default.sql
M src/tools/pg_bsd_indent/indent.c
M src/tools/pg_bsd_indent/io.c
M src/tools/pg_bsd_indent/pr_comment.c
Fix incorrect NEW references to generated columns in rule rewriting
commit : c6a79be3f3c78a1ab2b4ae8842451c72e0a8e6f3
author : Richard Guo <rguo@postgresql.org>
date : Tue, 21 Apr 2026 14:28:26 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Tue, 21 Apr 2026 14:28:26 +0900 When a rule action or rule qualification references NEW.col where col
is a generated column (stored or virtual), the rewriter produces
incorrect results.
rewriteTargetListIU removes generated columns from the query's target
list, since stored generated columns are recomputed by the executor
and virtual ones store nothing. However, ReplaceVarsFromTargetList
then cannot find these columns when resolving NEW references during
rule rewriting. For UPDATE, the REPLACEVARS_CHANGE_VARNO fallback
redirects NEW.col to the original target relation, making it read the
pre-update value (same as OLD.col). For INSERT,
REPLACEVARS_SUBSTITUTE_NULL replaces it with NULL. Both are wrong
when the generated column depends on columns being modified.
Fix by building target list entries for generated columns from their
generation expressions, pre-resolving the NEW.attribute references
within those expressions against the query's targetlist, and passing
them together with the query's targetlist to ReplaceVarsFromTargetList.
Back-patch to all supported branches. Virtual generated columns were
added in v18, so the back-patches in pre-v18 branches only handle
stored generated columns.
Reported-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDexGTmCZzx=73gXkY2ZADS6LRhpnU+-8Y_QmrdTS6yUhA@mail.gmail.com
Backpatch-through: 14 M src/backend/rewrite/rewriteHandler.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
Fix orphaned processes when startup process fails during PM_STARTUP
commit : 9b43e6793b0f9dcd2c3935af020cf96cd7b05ec2
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 21 Apr 2026 09:39:59 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 21 Apr 2026 09:39:59 +0900 When the startup process exists with a FATAL error during PM_STARTUP,
the postmaster called ExitPostmaster() directly, assuming that no other
processes are running at this stage. Since 7ff23c6d277d, this
assumption is not true, as the checkpointer, the background writer, the
IO workers and bgworkers kicking in early would be around.
This commit removes the startup-specific shortcut happening in
process_pm_child_exit() for a failing startup process during PM_STARTUP,
falling down to the existing exit() flow to signal all the started
children with SIGQUIT, so as we have no risk of creating orphaned
processes.
This required an extra change in HandleFatalError() for v18 and newer
versions, as an assertion could be triggered for PM_STARTUP. It is now
incorrect. In v17 and older versions, HandleChildCrash() needs to be
changed to handle PM_STARTUP so as children can be waited on.
While on it, fix a comment at the top of postmaster.c. It was claiming
that the checkpointer and the background writer were started after
PM_RECOVERY. That is not the case.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWVoD3V9yhhqSae1_wqcnTdpFY-hDT7dPm5005ZFsL_bpA@mail.gmail.com
Backpatch-through: 15 M src/backend/postmaster/postmaster.c
doc: Use "integer" for some I/O worker GUC type descriptions
commit : 8155581ec695095711a5abd903a95236fbdfb823
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 21 Apr 2026 08:50:10 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 21 Apr 2026 08:50:10 +0900 The documentation previously described the io_max_workers,
io_worker_idle_timeout, and io_worker_launch_interval GUCs as
type "int". However, the documentation consistently uses "integer"
for parameters of this type.
This commit updates these parameter descriptions to use "integer"
for consistency.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAHGQGwEpMDpB-K8SSUVRRHg6L6z3pLAkekd9aviOS=ns0EC=+Q@mail.gmail.com M doc/src/sgml/config.sgml
doc: Correct context description for some JIT support GUCs
commit : 524cbb515549b82d7d9458be6d81c945af2bc1e2
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 21 Apr 2026 08:44:19 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 21 Apr 2026 08:44:19 +0900 The documentation for jit_debugging_support and jit_profiling_support
previously stated that these parameters can only be set at server start.
However, both parameters use the PGC_SU_BACKEND context, meaning they
can be set at session start by superusers or users granted the appropriate
SET privilege, but cannot be changed within an active session.
This commit updates the documentation to reflect the actual behavior.
Backpatch to all supported versions.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAHGQGwEpMDpB-K8SSUVRRHg6L6z3pLAkekd9aviOS=ns0EC=+Q@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/config.sgml
plsample: Use TextDatumGetCString() for text-to-CString conversion
commit : f1cfb48efb086f99f6995f5d4b8a7c3ee289d1f0
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 21 Apr 2026 08:37:17 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 21 Apr 2026 08:37:17 +0900 Replace the outdated DatumGetCString(DirectFunctionCall1(textout, ...))
pattern with TextDatumGetCString(). The macro is the modern, more
efficient way to convert a text Datum to a C string as it avoids
unnecessary function call machinery and handles detoasting internally.
Since plsample serves as reference code for extension authors, it
should follow current idiomatic practices.
Author: Amul Sul <sulamul@gmail.com>
Discussion: https://postgr.es/m/CAAJ_b95-xMvUN1PEqxv8y6g-A-8k+fSgyv20kSZc9eF1wZAUPg@mail.gmail.com M src/test/modules/plsample/plsample.c
Fix relid-set clobber during join removal.
commit : f0ac6d494b56b83cf49d328ee0c5dd20df937fce
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 20 Apr 2026 19:24:46 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 20 Apr 2026 19:24:46 -0400 Commit cfcd57111 et al fell over under Valgrind testing.
(It seems to be enough to #define USE_VALGRIND, you don't actually
need to run it under Valgrind to see failures.) The cause is that
remove_rel_from_eclass updates each EquivalenceMember's em_relids,
and those can be aliases of the left_relids or right_relids of some
RestrictInfo in ec_sources. If the update made em_relids empty then
bms_del_member will have pfree'd the relid set, so that the subsequent
attempt to clean up ec_sources accesses already-freed memory.
We missed seeing ill effects before cfcd57111 because (a) if the
pfree happens then we will remove the EquivalenceMember altogether,
making the source RestrictInfo no longer of use, and (b) the
cleanup of ec_sources didn't touch left/right_relids before that.
I'm unclear though on how cfcd57111 managed to pass non-USE_VALGRIND
testing. Apparently we managed to store another Bitmapset into the
freed space before trying to access it, but you'd not think that would
happen 100% of the time. I think what USE_VALGRIND changes is that it
makes list.c much more memory-hungry, so that the freed space gets
claimed by some List node before a Bitmapset can be put there.
This failure can be seen in v16, v17, and master, but oddly enough not
v18. That's because the SJE patch replaced the simple bms_del_members
calls used here with adjust_relid_set, which is careful not to
scribble on its input. But commit 20efbdffe just recently put back
the old coding and thus resurrected the problem.
Discussion: https://postgr.es/m/458729.1776724816@sss.pgh.pa.us
Backpatch-through: 16, 17, master M src/backend/optimizer/plan/analyzejoins.c
Fix callers of unicode_strtitle() using srclen == -1.
commit : bdcb85b56ac4e0594e3c3402545a4c87712ce461
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 20 Apr 2026 14:44:08 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 20 Apr 2026 14:44:08 -0700 Currently, only called that way in tests, which failed to fail.
Discussion: https://postgr.es/m/581a72ff452bb045ba83bbe3c6cf4467702d4f0f.camel@j-davis.com
Backpatch-through: 18 M src/backend/utils/adt/pg_locale_builtin.c
M src/common/unicode/case_test.c
style: define parameterless functions as foo(void).
commit : 59919ec7761fbe0d1592ca73cde1715aee60706e
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 20 Apr 2026 14:42:54 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 20 Apr 2026 14:42:54 -0700 Avoids warning in 'update-unicode' build target. Similar to
11171fe1fc.
Discussion: https://postgr.es/m/581a72ff452bb045ba83bbe3c6cf4467702d4f0f.camel@j-davis.com M src/common/unicode/case_test.c
M src/common/unicode/category_test.c
doc: Fix missing role attribute in pg_get_tablespace_ddl() description.
commit : 79fba6ebaba4f6cd46fd80b55c891bb2ba734119
author : Masahiko Sawada <msawada@postgresql.org>
date : Mon, 20 Apr 2026 13:31:13 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Mon, 20 Apr 2026 13:31:13 -0700 The second function signature entry for pg_get_tablespace_ddl() was
missing the role="func_signature" attribute. This commit adds the
missing attribute to ensure consistent formatting with other function
entries.
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>
Discussion: https://postgr.es/m/CAHza6qcSgwdh+f41zEm6NSaGHvs5_cwjVu22+KTic=TfnonrFA@mail.gmail.com M doc/src/sgml/func/func-info.sgml
Clean up all relid fields of RestrictInfos during join removal.
commit : cfcd5711160a42249def8f781bae197829cf44c7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 20 Apr 2026 14:48:23 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 20 Apr 2026 14:48:23 -0400 The original implementation of remove_rel_from_restrictinfo()
thought it could skate by with removing no-longer-valid relid
bits from only the clause_relids and required_relids fields.
This is quite bogus, although somehow we had not run across a
counterexample before now. At minimum, the left_relids and
right_relids fields need to be fixed because they will be
examined later by clause_sides_match_join(). But it seems
pretty foolish not to fix all the relid fields, so do that.
This needs to be back-patched as far as v16, because the
bug report shows a planner failure that does not occur
before v16. I'm a little nervous about back-patching,
because this could cause unexpected plan changes due to
opening up join possibilities that were rejected before.
But it's hard to argue that this isn't a regression. Also,
the fact that this changes no existing regression test results
suggests that the scope of changes may be fairly narrow.
I'll refrain from back-patching further though, since no
adverse effects have been demonstrated in older branches.
Bug: #19460
Reported-by: François Jehl <francois.jehl@pigment.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/19460-5625143cef66012f@postgresql.org
Backpatch-through: 16 M src/backend/optimizer/plan/analyzejoins.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql
Make ExecForPortionOfLeftovers() obey SRF protocol.
commit : 207cb2abcba00f78d57cdaca896f41c9453b0f2f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 20 Apr 2026 10:21:52 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 20 Apr 2026 10:21:52 -0400 Before each call to the SRF, initialize isnull and isDone, as per the
comments for struct ReturnSetInfo. This fixes a Coverity warning
about rsi.isDone not being initialized. The built-in
{multi,}range_minus_multi functions don't return without setting it,
but a user-supplied function might not be as accommodating.
We also add statistics tracking around the function call, which
will be expected once user-defined withoutPortionProcs functions
are supported, and a cross-check on rsi.returnMode just for
paranoia's sake.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Co-authored-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://postgr.es/m/4126231.1776622202@sss.pgh.pa.us M src/backend/executor/nodeModifyTable.c
REPACK: do not require REPLICATION or LOGIN
commit : 5dbb63fc82b72ccc6f9e7be0361efdeee5deeb50
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 20 Apr 2026 15:44:23 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 20 Apr 2026 15:44:23 +0200 Although REPACK (CONCURRENTLY) uses replication slots, there is no
concern that the slot will leak data of other users, because the
MAINTAIN privilege on the table is required anyway; requiring
REPLICATION is user-unfriendly without providing any actual protection.
A related aspect is that the REPLICATION attribute is not needed to
prevent REPACK from stealing slots from logical replication, since
commit e76d8c749c31 made REPACK use a separate pool of replication
slots.
Similarly, there's no reason to require that the table owner has the
LOGIN privilege. Bypass the default behavior in the background worker
launch sequence.
Because there are now successful concurrent repack runs in the
regression tests, we're forced to run test_plan_advice under
wal_level=replica, so add that. Also, move the cluster.sql test to a
different parallel group in parallel_schedule: apparently the use of the
repack worker causes it to exceed the maximum limit of processes in some
runs (the actual limit reached is the number of XIDs in a snapshot's xip
array).
Author: Antonin Houska <ah@cybertec.at>
Reported-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/aeJHPNmL4vVy3oPw@pryzbyj2023 M src/backend/commands/repack_worker.c
M src/test/modules/test_plan_advice/t/001_replan_regress.pl
M src/test/regress/expected/cluster.out
M src/test/regress/parallel_schedule
M src/test/regress/sql/cluster.sql
doc PG 19 relnotes: fix typo, "date" -> "data"
commit : 158d8fadd79f90935cb9bc1ae0bec366cbf09f42
author : Bruce Momjian <bruce@momjian.us>
date : Mon, 20 Apr 2026 07:15:06 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Mon, 20 Apr 2026 07:15:06 -0400 Reported-by: shammat@gmx.net
Discussion: https://postgr.es/m/c0d3dfe1-d3e1-45ff-bcdd-40ded5d37ada@gmx.net M doc/src/sgml/release-19.sgml
049_wait_for_lsn.pl: create function and procedure at once
commit : 23cbadeeb4738b8f5e615f0c5a2ef7af6111d512
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 20 Apr 2026 13:05:55 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 20 Apr 2026 13:05:55 +0300 Create the PL/pgSQL function and procedure for the top-level WAIT FOR
checks in a single transaction, then wait once for standby replay before
running both tests. Also revise some surrounding comments.
This avoids an extra 'wait_for_catchup()' on the delayed standby without
changing the test coverage.
Discussion: https://postgr.es/m/CABPTF7WZ1yuYz8V%3Dxsbghg8e7qaAm5MpyNw6BthWcbN7%2BP6biw%40mail.gmail.com
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/test/recovery/t/049_wait_for_lsn.pl
Clean up remove_rel_from_query() after self-join elimination commit
commit : 20efbdffeb6418afa13d6c8457054735d11c7e3a
author : Richard Guo <rguo@postgresql.org>
date : Mon, 20 Apr 2026 17:00:22 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 20 Apr 2026 17:00:22 +0900 The self-join elimination (SJE) commit grafted self-join removal onto
remove_rel_from_query(), which was originally written for left-join
removal only. This resulted in several issues:
- Comments throughout remove_rel_from_query() still assumed only
left-join removal, making the code misleading.
- ChangeVarNodesExtended was called on phv->phexpr with subst=-1
during left-join removal, which is pointless and confusing since any
surviving PHV shouldn't reference the removed rel.
- phinfo->ph_lateral was adjusted for left-join removal, which is
unnecessary since the removed relid cannot appear in ph_lateral for
outer joins.
- The comment about attr_needed reconstruction was in
remove_rel_from_query(), but the actual rebuild is performed by the
callers.
- EquivalenceClass processing in remove_rel_from_query() is redundant
for self-join removal, since the caller (remove_self_join_rel)
already handles ECs via update_eclasses().
- In remove_self_join_rel(), ChangeVarNodesExtended was called on
root->processed_groupClause, which contains SortGroupClause nodes
that have no Var nodes to rewrite. The accompanying comment
incorrectly mentioned "HAVING clause".
This patch fixes all these issues, clarifying the separation between
left-join removal and self-join elimination code paths within
remove_rel_from_query(). The resulting code is also better structured
for adding new types of join removal (such as inner-join removal) in
the future.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Discussion: https://postgr.es/m/CAMbWs48JC4OVqE=3gMB6se2WmRNNfMyFyYxm-09vgpm+Vwe8Hg@mail.gmail.com M src/backend/optimizer/plan/analyzejoins.c
Add missing Datum conversions
commit : 04f9ea372a20c0346ad6d78de348543375761aaa
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 20 Apr 2026 07:22:16 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 20 Apr 2026 07:22:16 +0200 Similar to commit ff89e182d42, for new code added since. M src/backend/catalog/objectaddress.c
M src/backend/catalog/pg_subscription.c
M src/backend/commands/subscriptioncmds.c
M src/backend/partitioning/partbounds.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/utils/cache/lsyscache.c
Fix incorrect format placeholders
commit : 5936afe1ee83aea739163edf30349b63bc620c0a
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 20 Apr 2026 07:09:13 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 20 Apr 2026 07:09:13 +0200 M src/backend/storage/ipc/shmem.c
M src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/pg_waldump.c
Flush statistics during idle periods in parallel apply worker.
commit : 090c4297e40977bc35e59faeb0a003561a4a5c7c
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 20 Apr 2026 10:31:11 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 20 Apr 2026 10:31:11 +0530 Parallel apply workers previously failed to report statistics while
waiting for new work in the main loop. This resulted in the stats from the
most recent transaction remaining unbuffered, leading to arbitrary
reporting delays—particularly when streamed transactions were infrequent.
This commit ensures that statistics are explicitly flushed when the worker
is idle, providing timely visibility into accumulated worker activity.
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 16, where it was introduced
Discussion: https://postgr.es/m/TYRPR01MB1419579F217CC4332B615589594202@TYRPR01MB14195.jpnprd01.prod.outlook.com M src/backend/replication/logical/applyparallelworker.c
Meson: Fix check_header() for readline and gssapi
commit : 63a116a96e7377ffb385f394655a387021d4b75b
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 20 Apr 2026 12:36:14 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 20 Apr 2026 12:36:14 +0900 Since f039c2244110, the minimum version of meson supported is 0.57.2,
meaning that it is possible to use the result of declare_dependency()
when checking for headers with check_header(). There were two TODOs for
readline and gssapi to change declare_dependency() after upgrading to at
least 0.57.0, which were not addressed yet.
While on it, this fixes a comment related to str.replace(). The
function has been introduced in meson 0.58.0, not 0.56.
Author: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/00cd2e0c-85df-4cf9-a889-125d85e66980@proxel.se M meson.build
Minor fixes for test_bitmapset.c
commit : 5142f0093e648d1a32fdcc7c835d17fa103e1239
author : David Rowley <drowley@postgresql.org>
date : Mon, 20 Apr 2026 09:58:40 +1200
committer: David Rowley <drowley@postgresql.org>
date : Mon, 20 Apr 2026 09:58:40 +1200 1. Make it so test_random_operations() can accept a NULL to have the
function select a random seed.
2. Widen the seed parameter of test_random_operations() to bigint.
Without that, it'll be impossible to run the function with a seed
which was selected by GetCurrentTimestamp(), and if a randomly
selected seed ever results in a failure, we'll likely want to run
with the same seed to debug the issue.
3. Report the seed in the error messages in test_random_operations().
If the buildfarm were ever to fail there, we'd certainly want to know
what this was.
4. Add CHECK_FOR_INTERRUPTS() to test_random_operations(). Someone might
run with a large num_ops and they'd have no way to cancel the query.
5. Minor cosmetic fixes; header order and whitespace issue.
To allow #1, the STRICT modifier had to be removed. The additional
prechecks were added as I didn't see how else to handle someone passing
those parameters as NULL.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/CAApHDvrDW9W72vAr7h7XeCu7+Qz-_Vff02Q+RPPuVeM0Qf0MCw@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–1.0.sql
M src/test/modules/test_bitmapset/test_bitmapset.c
Fix 64-bit shifting in dynahash.c
commit : 9018c7d37bb464cd53567c0b553a6f49b50bec78
author : Peter Eisentraut <peter@eisentraut.org>
date : Sun, 19 Apr 2026 12:57:41 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sun, 19 Apr 2026 12:57:41 +0200 The switch from long to int64 in commit 13b935cd521 was incomplete.
It was shifting the constant 1L, which is not always 64 bit. Fix by
using an explicit int64 constant.
MSVC warning:
../src/backend/utils/hash/dynahash.c(1767): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
Also add the corresponding warning to the standard warning set on
MSVC, to help catch similar issues in the future.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1142ad86-e475-41b3-aeee-c6ad913064fa%40eisentraut.org M meson.build
M src/backend/utils/hash/dynahash.c
pg_plan_advice: pgindent
commit : 228a1f9542792c6533ef74c2e7aefad0da1d9a7a
author : Robert Haas <rhaas@postgresql.org>
date : Fri, 17 Apr 2026 17:45:50 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Fri, 17 Apr 2026 17:45:50 -0400 Per buildfarm member koel. M contrib/pg_plan_advice/pgpa_planner.c
Change PointerGetDatum() back to a macro
commit : d65995cbc6e1644b5514d28f07c89f68fa690e53
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 17 Apr 2026 22:14:40 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 17 Apr 2026 22:14:40 +0300 The argument was marked as "const void *X", but that might rightly
give the compiler the idea that *X cannot be modified through the
resulting Datum, and make incorrect optimizations based on that. Some
functions use pointer Datums to pass output arguments, like GIN
support functions. Coverity started to complain after commit
6f5ad00ab7 that there's dead code in ginExtractEntries(), because it
didn't see that it passes PointerGetDatum(&nentries) to a function
that sets it.
This issue goes back to commit c8b2ef05f481 (version 16), which
changed PointerGetDatum() from a macro to a static inline function.
This commit changes it back to a macro, but uses a trick with a dummy
conditional expression to still produce a compiler error if you try to
pass a non-pointer as the argument.
Even though this goes back to v16, I'm only committing this to
'master' for now, to verify that this silences the Coverity warning.
If this works, we might want to introduce separate const and non-const
versions of PointerGetDatum() instead of this, but that's a bigger
patch. It's also not decided yet whether to back-patch this (or some
other fix), given that we haven't yet seen any hard evidence of
compilers actually producing buggy code because of this.
Discussion: https://www.postgresql.org/message-id/342012.1776017102@sss.pgh.pa.us M src/include/postgres.h
pg_plan_advice: Fix another unique-semijoin bug.
commit : 4321dcad475bc7cbb4efe18c0b0652a0506e8348
author : Robert Haas <rhaas@postgresql.org>
date : Fri, 17 Apr 2026 14:08:37 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Fri, 17 Apr 2026 14:08:37 -0400 This one occurs when an outer join appears beneath the made-unique
side of a semijoin. The issue is that join RTEs are not featured
out of sj_unique_rels entries. Fix, and add a test case.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Analyzed-by: Tender Wang <tndrwang@gmail.com>
Discussion: http://postgr.es/m/c0c63979-43c2-4424-8fe8-56949934c9d8@gmail.com M contrib/pg_plan_advice/expected/semijoin.out
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/sql/semijoin.sql
Doc: Improve the wording of logical slot prerequisites.
commit : f3ae1ec7295b6c4d54974eea14bef4b917dc2c7e
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 17 Apr 2026 15:02:15 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 17 Apr 2026 15:02:15 +0530 Replace the previous negative phrasing such as "there are no slots whose
... is not true" with a direct expression that all slots must have
conflicting = false.
Similarly, reword the requirement on the new cluster to state that it must
not have any permanent logical slots, clarifying that any existing logical
slots must have temporary set to true.
These changes improve readability without altering the meaning.
Reported-by: <mimidatabase@gmail.com>
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/177609278737.403059.14174275013090471947%40wrigleys.postgresql.org M doc/src/sgml/logical-replication.sgml
doc: Improve description of pg_ctl -l log file permissions
commit : 950f50d5d49bcb55865582e8c5b12068533f6664
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 17 Apr 2026 15:30:59 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 17 Apr 2026 15:30:59 +0900 The documentation stated only that the log file created by pg_ctl -l is
inaccessible to other users by default. However, since commit c37b3d0,
the actual behavior is that only the cluster owner has access by default,
but users in the same group as the cluster owner may also read the file
if group access is enabled in the cluster.
This commit updates the documentation to describe this behavior
more clearly.
Backpatch to all supported versions.
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Xiaopeng Wang <wxp_728@163.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/OS9PR01MB1214959BE987B4839E3046050F54BA@OS9PR01MB12149.jpnprd01.prod.outlook.com
Backpatch-through: 14 M doc/src/sgml/ref/pg_ctl-ref.sgml
psql: Fix incorrect tab completion after CREATE PUBLICATION ... EXCEPT (...)
commit : 4e0e1f3b2704e04768a4bccb7102450d74730a50
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 17 Apr 2026 14:31:05 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 17 Apr 2026 14:31:05 +0900 Previously, tab completion after EXCEPT (...) always suggested FROM SERVER.
This was correct for IMPORT FOREIGN SCHEMA ... EXCEPT (...), but became
incorrect once commit fd366065e06 added CREATE PUBLICATION ... EXCEPT (...).
This commit updates tab completion so FROM SERVER is no longer suggested
after CREATE PUBLICATION ... EXCEPT (...), while preserving the existing
behavior for IMPORT FOREIGN SCHEMA ... EXCEPT (...).
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CALDaNm1-Fx6Msw6zcRuSjgQdw6asdTyp2DwP-4TCKGYAT+ndsA@mail.gmail.com M src/bin/psql/tab-complete.in.c
Reject invalid databases in pg_get_database_ddl()
commit : cda0c4c5d6f581cddaa24cde02c583d1c8f5521d
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 17 Apr 2026 13:19:56 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 17 Apr 2026 13:19:56 +0900 An invalid database has datconnlimit set to -2. pg_get_database_ddl()
emits this verbatim as CONNECTION LIMIT = -2, which ALTER DATABASE
rejects. Error out early instead.
Reported-by: Lakshmi N <lakshmin.jhs@gmail.com>
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Hu Xunqi <huxunqi.08@gmail.com>
Discussion: https://postgr.es/m/CA+3i_M8m1k2gFch+tU0JmAQh9FRV+pFrfTXDrJo+BqmwsTmOhg@mail.gmail.com M src/backend/utils/adt/ddlutils.c
doc PG 19 relnotes: change "free space map" to "visibility map"
commit : f3c28c2f2b77479e0afc49b5e6e64a6f7dedfd3d
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 17:23:55 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 17:23:55 -0400 Reported-by: Melanie Plageman
Author: Melanie Plageman M doc/src/sgml/release-19.sgml
Make psql DETAIL line test unconditionally optional.
commit : 446c400fd89b46ac6e71fb01604ffd830f12c9e9
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 15 Apr 2026 14:41:33 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 15 Apr 2026 14:41:33 -0400 Commit 3e2a1496bae6 made the psql TAP test require the DETAIL line on
platforms with SA_SIGINFO, rather than making it optional. This
unexpectedly blew up on OpenBSD buildfarm members, because OpenBSD does
not set si_pid for SIGTERM signals even though it has SA_SIGINFO
defined.
So revert to the test as it was in commit 55890a919454, where the detail
line being missing never causes an error.
Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/2007157.1776269052%40sss.pgh.pa.us M src/bin/psql/t/001_basic.pl
Add missing initialization
commit : 05c401d5786a05ea630e884ffa492aa01683d15b
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 16 Apr 2026 22:27:04 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 16 Apr 2026 22:27:04 +0200 The backend running REPACK can check DecodingWorkerShared->initialized
before the worker could have the chance to initialize it, possibly
leading to wrong behavior.
While at it, remove DecodingWorkerShared->worker_dsm_segment, because
that doesn't actually need to be in shared memory; a simple local-memory
global variable is enough.
Oversights in commit 28d534e2ae0a.
Author: Antonin Houska <ah@cybertec.at>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/18181295-8375-4789-ad32-269d78d6001e@gmail.com M src/backend/commands/repack.c
M src/backend/commands/repack_worker.c
M src/include/commands/repack_internal.h
doc PG 19 relnotes: add author and move items
commit : 191a037d4f2d0a028c19e9ca29da72bc79d2236e
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 12:45:40 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 12:45:40 -0400 Reported-by: Richard Guo
Author: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4_etzZZPMEzte8hJv2f4Tn6dGskg8v1R_N9uCd2of0kMQ@mail.gmail.com M doc/src/sgml/release-19.sgml
Update FSM during prune/freeze replay even if freespace is zero
commit : b4c1b2be300e619aebc3a2c00198009af256bfee
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 16 Apr 2026 12:10:47 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 16 Apr 2026 12:10:47 -0400 add323da40a started updating the visibility map in the same WAL record
as pruning and freezing. This included updating the freespace map during
replay of a record setting the VM, which we've done since ab7dbd681.
add323da40a, however, conditioned doing so on there being > 0 freespace
on the page, which differed from the previous state for records updating
the VM.
The FSM is not WAL-logged and is instead updated heuristically on
standbys. In rare cases, this heuristic could lead to pages with 0
freespace having outdated entries in the FSM. If the standby is later
promoted and vacuum skips these pages because they are marked
all-visible/all-frozen, overly optimistic values would be propagated up
the FSM tree, causing slowness when searching for freespace for new
tuples.
Fix it by always updating the FSM during replay when setting VM bits.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reported-by: Alexey Makhmutov <a.makhmutov@postgrespro.ru>
Discussion: https://postgr.es/m/ead2f110-c736-48f5-99e1-023dc9acbf0b%40postgrespro.ru M src/backend/access/heap/heapam_xlog.c
doc PG 19 relnotes: update author
commit : af1ed03739fb4f7bf11a55971ff1377d7ebf6d2d
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 11:23:55 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 11:23:55 -0400 Reported-by: Masahiko Sawada
Author: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoCLCZnzEFam8H07qq-=fUpDwmTmV7+4RPnT2x_xoJBrgg@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: corrections reported to me privately
commit : 2dc34eaa07fcfbc63c9b2dafde317a85383b01d4
author : Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 10:43:17 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Thu, 16 Apr 2026 10:43:17 -0400 M doc/src/sgml/release-19.sgml
Use XLogRecPtrIsValid() consistently for WAL position checks
commit : 2fd84e2226e2e1e13f5ad57bec3465488d67e944
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 16 Apr 2026 23:02:34 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 16 Apr 2026 23:02:34 +0900 Commit a2b02293bc6 switched various checks to use XLogRecPtrIsValid(),
but later changes reintroduced XLogRecPtrIsInvalid() and direct comparisons
with InvalidXLogRecPtr.
This commit replaces those uses with XLogRecPtrIsValid() for better
readability and consistency.
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Xiaopeng Wang <wxp_728@163.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CALDaNm16knMFtcqyAG3XYSkyagmVXfhaR0T=hau8UTAU0+eLQQ@mail.gmail.com M src/backend/commands/repack_worker.c
M src/backend/replication/walreceiver.c
M src/bin/pg_waldump/archive_waldump.c
doc: Add missing GUCs to SSL SNI docs
commit : 4abcdc1bbebfaeffc072296711e8a2af8d7d7cdf
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 16 Apr 2026 11:18:57 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Thu, 16 Apr 2026 11:18:57 +0200 The ssl_sni and hosts_file GUCs were missing from the configuration
section of the documentation, they were only described in the main
SSL SNI subsection. This adds the GUCs to the relevant sections as
well as rewords the existing SSL SNI documentation to refer to the
settings along with a few smaller fixups.
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/CAHGQGwESD2Pty+J1kP3mXmWwMKZ5uJmknZdJsSGrMSRR6CQBmw@mail.gmail.com M doc/src/sgml/config.sgml
M doc/src/sgml/runtime.sgml
MSVC: Turn missing function declaration into an error
commit : 1a51ec16db7aa1688d0083911db78e17ff7f26ba
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 16 Apr 2026 09:53:03 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 16 Apr 2026 09:53:03 +0200 Calling an undeclared function should be an error as of C99, and GCC
and Clang do that, but MSVC doesn't even warn about it in the default
warning level. (Commit c86d2ccdb35 fixed an instance of this
problem.) This turns on this warning and makes it an error by
default, to match other compilers.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1142ad86-e475-41b3-aeee-c6ad913064fa%40eisentraut.org M meson.build
Add missing include
commit : c86d2ccdb35544590531f5431606db46b57730a8
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 16 Apr 2026 09:35:05 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 16 Apr 2026 09:35:05 +0200 "utils/pg_locale.h" is needed when under MSVC for wchar2char(),
introduced by commit 65707ed9afc. Surprisingly, MSVC doesn't warn by
default about calling undeclared functions. This will be addressed in
a separate commit.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1142ad86-e475-41b3-aeee-c6ad913064fa%40eisentraut.org M src/backend/utils/error/elog.c
Fix comments for Korean encodings in encnames.c
commit : 9a618901a476ea168278414592d8a9818252dff3
author : Thomas Munro <tmunro@postgresql.org>
date : Thu, 16 Apr 2026 18:17:05 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Thu, 16 Apr 2026 18:17:05 +1200 * JOHAB: replace the incorrect "simplified Chinese" description with
a correct one that identifies it as the Korean combining (Johab)
encoding standardized in KS X 1001 annex 3.
* EUC_KR: drop a stray space before the comma in the existing
comment, and note that the encoding covers the KS X 1001
precomposed (Wansung) form.
* UHC: spell out "Unified Hangul Code", clarify that it is
Microsoft Windows CodePage 949, and describe its relationship to
EUC-KR (superset covering all 11,172 precomposed Hangul syllables).
Backpatch-through: 14
Author: Henson Choi <assam258@gmail.com>
Discussion: https://postgr.es/m/CAAAe_zAFz1v-3b7Je4L%2B%3DwZM3UGAczXV47YVZfZi9wbJxspxeA%40mail.gmail.com M src/common/encnames.c
Fix pg_overexplain to emit valid output with RANGE_TABLE option.
commit : 059cf7f58d23fc53423e4e58feaaa717faef53c5
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 16 Apr 2026 13:47:07 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 16 Apr 2026 13:47:07 +0900 overexplain_range_table() emitted the "Unprunable RTIs" and "Result
RTIs" properties before closing the "Range Table" group. In the JSON
and YAML formats the Range Table group is rendered as an array of RTE
objects, so emitting key/value pairs inside it produced structurally
invalid output. The XML format had a related oddity, with these
elements nested inside <Range-Table> rather than appearing as its
siblings.
These fields are properties of the PlannedStmt as a whole, not of any
individual RTE, so close the Range Table group before emitting them.
They now appear as siblings of "Range Table" in the parent Query
object, which is what was intended.
Also add a test exercising FORMAT JSON with RANGE_TABLE so that any
future regression in the output structure is caught.
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDdDrdqMr98a_OBYDYmK3RaT7XwCEShZfvDYKZpZTfOEjQ@mail.gmail.com
Backpatch-through: 18 M contrib/pg_overexplain/expected/pg_overexplain.out
M contrib/pg_overexplain/pg_overexplain.c
M contrib/pg_overexplain/sql/pg_overexplain.sql
Fix incorrect comment in JsonTablePlanJoinNextRow()
commit : b5062a4e57fcdd51949a046314ec90731bdbf92c
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 16 Apr 2026 13:45:33 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 16 Apr 2026 13:45:33 +0900 The comment on the return-false path when both UNION siblings are
exhausted said "there are more rows," which is the opposite of what
the code does. The code itself is correct, returning false to signal
no more rows, but the misleading comment could tempt a reader into
"fixing" the return value, which would cause UNION plans to loop
indefinitely.
Back-patch to 17, where JSON_TABLE was introduced.
Author: Chuanwen Hu <463945512@qq.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/tencent_4CC6316F02DECA61ACCF22F933FEA5C12806@qq.com
Backpatch-through: 17 M src/backend/utils/adt/jsonpath_exec.c
Use proc_exit() for walreceiver exit in WalRcvWaitForStartPosition()
commit : ee550254a29a4ccd3852f14b1806b8ffe26b7454
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 16 Apr 2026 12:33:17 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 16 Apr 2026 12:33:17 +0900 Previously, when the walreceiver exited from WalRcvWaitForStartPosition()
at the startup process's request, it called exit(1) directly. This could
skip cleanup performed by the callback functions.
This commit makes the walreceiver to use proc_exit() instead, ensuring
normal cleanup is executed on exit.
Also this commit updates comments describing walreceiver termination.
Apply to master only, as this has not caused practical issues so far.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/74381238-4E8A-4621-B794-57025DCCE0BA@gmail.com M src/backend/replication/walreceiver.c
doc PG 19 relnotes: remove doc author from "Allow autovacuum"
commit : 7102ce9823ed6f1d1568b82d170aaa9bd973ef6e
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 16:58:11 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 16:58:11 -0400 Reported-by: Aleksander Alekseev
Discussion: https://postgr.es/m/CAJ7c6TO-FHg4SGF48PJ9dnV3cg1-_xW9=P4t8-cd-+JWvZAPyQ@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: add free space map all-visible item
commit : be324941262b06f4275ac19768b1a8a024960687
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 16:52:17 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 16:52:17 -0400 Reported-by: Melanie Plageman
Discussion: https://postgr.es/m/CAAKRu_bzN6ioG+h7agjCF847whVpS2WEiJB3UXAtkJ3WVXOZwA@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: fixes for commands and authors
commit : 3837e72757347cb9749f46e01e9f86e18e3e5d61
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 16:18:51 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 16:18:51 -0400 Reported-by: jian he
Discussion: https://postgr.es/m/CANzqJaCKn_AahetGkZWKJVi6MKyGKqr1JrziquyHt1-SRwQpSw@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: remove "Lakshmi N" as author of checksums
commit : 75693dc5b72e7e8a9759ff86489f325a22ab06c5
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 15:43:36 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 15:43:36 -0400 Reported-by: Daniel Gustafsson
Discussion: https://postgr.es/m/762DAF2F-7055-4F52-9DF7-23C4A19478A0@yesql.se M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: fix "now targets"
commit : caebf165098f356f8ade0146035b908f8eb573ef
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 15:37:00 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 15:37:00 -0400 Reported-by: Laurenz Albe
Discussion: https://postgr.es/m/27be2ef070e3a0ca55b478e0493fac0124d4f95e.camel@cybertec.at M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: addjust CREATE/ALTER PUBLICATION "EXCEPT"
commit : 57f768816dcd0095bc330cf113eaf2f52a525da9
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 15:35:23 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 15:35:23 -0400 Reported-by: Peter Smith
Backpatch-through: CAHut+Psb41Lou8+BS4ZYmZJFG8pF99wEr+xcP17PCZP1MaY_+Q@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: add missing March 16 autovacuum score item
commit : 23ec74c8a85245e379ef2eb515e3e6e7f2381655
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 14:42:57 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 14:42:57 -0400 Also fix "deformed" tuples.
Reported-by: David Rowley
Backpatch-through: CAApHDvrsyD3QKBO=dypNkyFzYOzQEbgy+xJLwn=y+h+bLSDd-g@mail.gmail.com M doc/src/sgml/release-19.sgml
doc PG 19 relnotes: adjust ShmemRequestStruct item
commit : e70ac90d95a2e0ba95b5b6b02ae9b7f6607bf4db
author : Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 13:03:29 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Wed, 15 Apr 2026 13:03:29 -0400 Reported-by: Ashutosh Bapat
Author: Ashutosh Bapat
Discussion: https://postgr.es/m/CAExHW5vjpd=mWauQZsTbKX9QqD8yxDUABBGQAT5n+CT+nr8QHw@mail.gmail.com M doc/src/sgml/release-19.sgml
Fix COPY TO FORMAT JSON to exclude generated columns.
commit : f30d0c720f2ec979ab1b5b44b1f9f201d6efdf8c
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 15 Apr 2026 07:47:12 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 15 Apr 2026 07:47:12 -0400 COPY TO with FORMAT json was including generated columns in the
output, unlike TEXT and CSV formats. Virtual generated columns
appeared as null, and stored ones showed their computed values.
The JSON code path only built a restricted TupleDesc when an explicit
column list was given (attnamelist != NIL), but CopyGetAttnums()
also excludes generated columns from the default list. Fix by
checking whether the attnumlist is shorter than the full TupleDesc
instead.
Bug introduced in 7dadd38cda9.
Author: Satya Narlapuram <satya.narlapuram@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDcfpGDoPL3fvfjXRtfn=fny6DdJR6BAy6TpS1Xj2EZfXA@mail.gmail.com M src/backend/commands/copyto.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
Rework signal handler infrastructure to pass sender info as argument.
commit : 3e2a1496bae628c379ca0a11ef5f5ba666f24ae8
author : Andrew Dunstan <andrew@dunslane.net>
date : Tue, 14 Apr 2026 16:13:08 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Tue, 14 Apr 2026 16:13:08 -0400 Commit 095c9d4cf06 added errdetail() reporting of the PID and UID of
the process that sent a termination signal. However, as noted by
Andres Freund, the implementation had architectural problems:
1. wrapper_handler() in pqsignal.c contained SIGTERM-specific logic
(setting ProcDieSenderPid/Uid), violating its role as a generic
signal dispatch wrapper.
2. Using globals to pass sender info between wrapper_handler and the
real handler is unsafe when signals nest on some platforms.
3. The syncrep.c errdetail used psprintf() to conditionally embed
text via %s, breaking translatability.
Adopt the approach proposed by Andres Freund: introduce a
pg_signal_info struct that is passed as an argument to all signal
handlers via the SIGNAL_ARGS macro. wrapper_handler populates it
from siginfo_t when SA_SIGINFO is available, or with zeros otherwise.
This keeps wrapper_handler fully generic and avoids any globals for
passing signal metadata.
Since pqsigfunc now has a different signature from the system's
signal handler type, SIG_IGN and SIG_DFL can no longer be passed
directly to pqsignal(). Introduce PG_SIG_IGN and PG_SIG_DFL macros
that cast to the new pqsigfunc type, and update all call sites.
The legacy pqsignal() in libpq retains its original signature via
a local typedef.
Only die() reads pg_siginfo today, copying the sender PID/UID into
ProcDieSenderPid/Uid for later use by ProcessInterrupts(). Only the
first SIGTERM's sender info is recorded.
Also fix the syncrep.c translatability issue by using separate ereport
calls with complete, independently translatable errdetail strings.
Also make the psql TAP test require the DETAIL line on platforms with
SA_SIGINFO, rather than making it unconditionally optional.
On Windows, pg_signal_info uses uint32_t for pid and uid fields
since pid_t/uid_t are not available early enough in the include
chain. The Windows signal dispatch in pgwin32_dispatch_queued_signals()
passes a zeroed pg_signal_info to handlers.
Author: Andres Freund <andres@anarazel.de>
Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/cwyyryh2veejuxbj5ifzyaejw7jhhqc5mrdeq56xckknsdecn2@6hzfcxde2nm5
Discussion: https://postgr.es/m/jygesyr7mwg7ovdbxpmjvvbi3hccptpkcreqb645h7f56puwbz@hmkkwi3melfe M src/backend/bootstrap/bootstrap.c
M src/backend/port/win32/signal.c
M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/bgwriter.c
M src/backend/postmaster/checkpointer.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/postmaster/pgarch.c
M src/backend/postmaster/postmaster.c
M src/backend/postmaster/startup.c
M src/backend/postmaster/syslogger.c
M src/backend/postmaster/walsummarizer.c
M src/backend/postmaster/walwriter.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/syncrep.c
M src/backend/replication/walreceiver.c
M src/backend/replication/walsender.c
M src/backend/storage/aio/method_worker.c
M src/backend/storage/file/fd.c
M src/backend/storage/ipc/waiteventset.c
M src/backend/tcop/postgres.c
M src/bin/initdb/initdb.c
M src/bin/pg_ctl/pg_ctl.c
M src/bin/pg_dump/parallel.c
M src/bin/psql/t/001_basic.pl
M src/fe_utils/print.c
M src/include/c.h
M src/include/port.h
M src/interfaces/libpq/legacy-pqsignal.c
M src/port/pqsignal.c
M src/test/regress/pg_regress.c
M src/tools/pgindent/typedefs.list
doc: first draft of PG 19 release notes
commit : 972c14fb9134fdfd76ea6ebcf98a55a945bbc988
author : Bruce Momjian <bruce@momjian.us>
date : Tue, 14 Apr 2026 21:06:07 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Tue, 14 Apr 2026 21:06:07 -0400 M doc/src/sgml/release-19.sgml
Fix var_is_nonnullable() to handle invalid NOT NULL constraints
commit : 363af93bdd24c37064d94bd4e637827442594d53
author : Richard Guo <rguo@postgresql.org>
date : Wed, 15 Apr 2026 09:38:56 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 15 Apr 2026 09:38:56 +0900 The NOTNULL_SOURCE_SYSCACHE code path in var_is_nonnullable() used
get_attnotnull() to check pg_attribute.attnotnull, which is true for
both valid and invalid (NOT VALID) NOT NULL constraints. An invalid
constraint does not guarantee the absence of NULLs, so this could lead
to incorrect results. For example, query_outputs_are_not_nullable()
could wrongly conclude that a subquery's output is non-nullable,
causing NOT IN to be incorrectly converted to an anti-join.
Fix by checking the attnullability field in the relation's tuple
descriptor instead, which correctly distinguishes valid from invalid
constraints, consistent with what the NOTNULL_SOURCE_HASHTABLE code
path already does.
While at it, rename NOTNULL_SOURCE_SYSCACHE to NOTNULL_SOURCE_CATALOG
to reflect that this code path no longer uses a syscache lookup, and
remove the now-unused get_attnotnull() function.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/CAMbWs48ALW=mR0ydQ62dGS-Q+3D7WdDSh=EWDezcKp19xi=TUA@mail.gmail.com M src/backend/optimizer/util/clauses.c
M src/backend/utils/cache/lsyscache.c
M src/include/optimizer/optimizer.h
M src/include/utils/lsyscache.h
M src/test/regress/expected/subselect.out
M src/test/regress/sql/subselect.sql
Fix pfree crash in pg_get_role_ddl() and pg_get_database_ddl().
commit : 1f108fc02ece09da5773ece74e25812cb952ebfc
author : Andrew Dunstan <andrew@dunslane.net>
date : Tue, 14 Apr 2026 18:25:36 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Tue, 14 Apr 2026 18:25:36 -0400 DatumGetArrayTypeP() can return a pointer into the tuple when the
datum is stored as a short varlena, so pfree() on the result crashes.
Use DatumGetArrayTypePCopy() to always get a palloc'd copy.
Bug introduced in 76e514ebb4b and a4f774cf1c7.
Reported-by: Jeff Davis <pgsql@j-davis.com>
Author: Satya Narlapuram <satya.narlapuram@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDdWtv9PKtPZEokwGCNtbv4MVnfYw5wMZrsEj4xizSNe5Q@mail.gmail.com M src/backend/utils/adt/ddlutils.c
Check for unterminated strings when calling uloc_getLanguage().
commit : dacd8fa6f259e25f747d6d71290d9d5ed86095df
author : Jeff Davis <jdavis@postgresql.org>
date : Tue, 14 Apr 2026 12:06:02 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Tue, 14 Apr 2026 12:06:02 -0700 Missed by commit 1671f990dd66.
Author: Andreas Karlsson <andreas@proxel.se>
Discussion: https://postgr.es/m/118ca69e-47eb-42e1-83e9-72ccf40dd6fd@proxel.se
Backpatch-through: 16 M src/bin/initdb/initdb.c
Add tests for low-level PGLZ [de]compression routines
commit : 67d318e70402b0eb450c7e20c0378b88e5a6df1d
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Apr 2026 05:09:05 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 15 Apr 2026 05:09:05 +0900 The goal of this module is to provide an entry point for the coverage of
the low-level compression and decompression PGLZ routines. The new test
is moved to a new parallel group, with all the existing
compression-related tests added to it.
This includes tests for the cases detected by fuzzing that emulate
corrupted compressed data, as fixed by 2b5ba2a0a141:
- Set control bit with read of a match tag, where no data follows.
- Set control bit with read of a match tag, where 1 byte follows.
- Set control bit with match tag where length nibble is 3 bytes
(extended case).
While on it, some tests are added for compress/decompress roundtrips,
and for check_complete=false/true. Like 2b5ba2a0a141, backpatch to all
the stable branches.
Discussion: https://postgr.es/m/adw647wuGjh1oU6p@paquier.xyz
Backpatch-through: 14 A src/test/regress/expected/compression_pglz.out
M src/test/regress/parallel_schedule
M src/test/regress/regress.c
A src/test/regress/sql/compression_pglz.sql
Replace deprecated StaticAssertStmt() with StaticAssertDecl()
commit : 66ad764c8d517f59577d41ac3dad786729c9e10e
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 14 Apr 2026 12:03:30 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 14 Apr 2026 12:03:30 +0300 Commit 6f5ad00ab763 added another use of StaticAssertStmt(), but it
was marked as deprecated in commit d50c86e74375.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/adeNWH5pDawDvvR2@ip-10-97-1-34.eu-west-3.compute.internal M src/backend/access/gin/ginutil.c
Add missing period to HINT messages.
commit : fce3f7d267777402b5a9b32db254982f2d75c4aa
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 14 Apr 2026 09:37:18 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 14 Apr 2026 09:37:18 +0530 Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Discussion: https://postgr.es/m/CAHut+PvikGr4AtoFSs=jq=hmTybVF2NCMEZ57-sjwbGudfuqsQ@mail.gmail.com M contrib/pgcrypto/crypt-sha.c
M src/backend/parser/parse_utilcmd.c
M src/backend/partitioning/partbounds.c
M src/test/regress/expected/partition_merge.out
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_split.sql
Fix overrun when comparing with unterminated ICU language string.
commit : 06ce97b9994eca91250d7c28f0df9b1ae7829f36
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 13 Apr 2026 11:19:04 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 13 Apr 2026 11:19:04 -0700 The overrun was introduced in commit c4ff35f10.
Author: Andreas Karlsson <andreas@proxel.se>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/96d80a47-f17f-42fa-82b1-2908efbd6541@gmail.com
Backpatch-through: 18 M src/backend/utils/adt/pg_locale_icu.c
doc: Remove stray word from pg_stash_advice docs.
commit : e89f98ff035fa56ff288ff2407f3eceddf187d70
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 12:51:04 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 12:51:04 -0400 Commit c10edb102ada607eb054bc9e23690109d86849ef left behind the
word "both" where it no longer makes sense.
Reported-by: Erik Rijkers <er@xs4all.nl>
Discussion: http://postgr.es/m/8912b2e5-ccad-4cbd-ab53-869b0b9ecec5@xs4all.nl M doc/src/sgml/pgstashadvice.sgml
doc: Fix a couple of mistakes in pgplanadvice.sgml
commit : f4a4f1a7e6285c846a4c2662d8ce5246a6bcb7e7
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 12:45:57 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 12:45:57 -0400 It said FOREIGN_SCAN where it should say FOREIGN_JOIN.
NESTED_LOOP_MEMOIZE was mistakenly omitted from the list of join
methods.
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: jie wang <jugierwang@gmail.com>
Discussion: http://postgr.es/m/CA+3i_M-mo7Of=Pn8WzRfJLt=fc=gDTn1oOdj8v8BEtgXh9ZMCg@mail.gmail.com M doc/src/sgml/pgplanadvice.sgml
pg_plan_advice: Export feedback-related definitions.
commit : c644aca24089ce001c46029f9e2144789ada165b
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 11:47:40 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 11:47:40 -0400 It turns out that our main regression test suite queries tables upon
which concurrent DDL is occurring, which can, rarely, cause
test_plan_advice failures. We're not quite ready to fix that problem
just yet, because we want to gather some more information about how
often it actually happens first. But, our plan is going to require
test_plan_advice to access a few bits of pg_plan_advice that have
been considered internal up until now, so this commit rejiggers
things to expose those bits.
First, test_plan_advice is going to need to be able to interpret
the PGPA_TE_* constants which have been declared in pgpa_trove.h.
The "TE" stands for "trove entry" but that's kind of a silly name;
change the naming to "FB" (for "feedback") and move the declarations
to pg_plan_advice.h, which is a header file that's already installed.
This has the side benefit of making these constants available to any
other extensions that may want to examine plan advice feedback.
Second, test_plan_advice is going to call pgpa_planner_feedback_warning,
so make that function non-static and mark it PGDLLEXPORT.
Discussion: http://postgr.es/m/CA+TgmobOOmmXSJz3e+cjTY-bA1+W0dqVDqzxUBEvGtW62whYGg@mail.gmail.com M contrib/pg_plan_advice/pg_plan_advice.h
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/pgpa_planner.h
M contrib/pg_plan_advice/pgpa_trove.c
M contrib/pg_plan_advice/pgpa_trove.h
pg_plan_advice: Fix a bug when a subquery is pruned away entirely.
commit : 0f93ebb3112d562fe54b685d0ca08c5ba1b41467
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 10:34:09 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 10:34:09 -0400 If a subquery is proven empty, and if that subquery contained a
semijoin, and if making one side or the other of that semijoin
unique and performing an inner join was a possible strategy, then
the previous code would fail with ERROR: no rtoffset for plan %s
when attempting to generate advice. Fix that.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: http://postgr.es/m/CA+TgmobOOmmXSJz3e+cjTY-bA1+W0dqVDqzxUBEvGtW62whYGg@mail.gmail.com M contrib/pg_plan_advice/expected/semijoin.out
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/sql/semijoin.sql
pg_plan_advice: Add alternatives test to Makefile.
commit : 1faf9dfa4796a05b68c59194b8da9b0f57ed9889
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 10:09:20 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 10:09:20 -0400 Oversight in commit 6455e55b0da47255f332a96f005ba0dd1c7176c2.
Discussion: http://postgr.es/m/CA+TgmobOOmmXSJz3e+cjTY-bA1+W0dqVDqzxUBEvGtW62whYGg@mail.gmail.com M contrib/pg_plan_advice/Makefile
pg_plan_advice: Handle non-repeatable TABLESAMPLE scans.
commit : 3311ccc3d24bf83fb26a8af81ea68a8fcc295c26
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 08:46:25 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 13 Apr 2026 08:46:25 -0400 When a tablesample routine says that it is not repeatable across
scans, set_tablesample_rel_pathlist will (usually) materialize it,
confusing pg_plan_advice's plan walker machinery. To fix, update that
machinery to view such Material paths as essentially an extension of
the underlying scan.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: http://postgr.es/m/CA+TgmobOOmmXSJz3e+cjTY-bA1+W0dqVDqzxUBEvGtW62whYGg@mail.gmail.com M contrib/pg_plan_advice/Makefile
M contrib/pg_plan_advice/expected/scan.out
M contrib/pg_plan_advice/pgpa_join.c
M contrib/pg_plan_advice/pgpa_scan.c
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_plan_advice/pgpa_walker.h
M contrib/pg_plan_advice/sql/scan.sql
Explicitly forbid non-top-level WAIT FOR execution
commit : a8b61c23c5ff980312026a05cab5502aa31fd710
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 13 Apr 2026 14:04:52 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 13 Apr 2026 14:04:52 +0300 Previously we were relying on a snapshot-based check to detect invalid
execution contexts. However, when WAIT FOR is wrapped into a stored
procedure or a DO block, it could pass this check, causing an error
elsewhere.
This commit implements an explicit isTopLevel check to reject WAIT FOR
when called from within a function, procedure, or DO block. The
isTopLevel check catches these cases early with a clear error message,
matching the pattern used by other utility commands like VACUUM and
REINDEX. The snapshot check is retained for the remaining case:
top-level execution within a transaction block using an isolation level
higher than READ COMMITTED.
Also adds tests for WAIT FOR LSN wrapped in a procedure and DO block,
complementing the existing test that uses a function wrapper. Relevant
documentation paragraph is also added.
Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/CAHg%2BQDcN-n3NUqgRtj%3DBQb9fFQmH8-DeEROCr%3DPDbw_BBRKOYA%40mail.gmail.com
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com> M doc/src/sgml/ref/wait_for.sgml
M src/backend/commands/wait.c
M src/backend/tcop/utility.c
M src/include/commands/wait.h
M src/test/recovery/t/049_wait_for_lsn.pl
Update Unicode data to CLDR 48.2
commit : b47854b6992d6155861da709c0f846073a401f61
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 11:12:35 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 11:12:35 +0200 No actual changes result.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/2a668979-ed92-49a3-abf9-a3ec2d460ec2%40eisentraut.org M src/Makefile.global.in
M src/common/unicode/meson.build
pg_createsubscriber: Don't use MAXPGPATH
commit : 99b726ac4894cf40957ca6bd5473d7dfb9c36a9b
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:59:08 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:59:08 +0200 Use dynamic allocation instead. Using MAXPGPATH is unnecessary in new
code like this..
Discussion: https://www.postgresql.org/message-id/flat/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc%2BG%2Bf4oSUHw%40mail.gmail.com M src/bin/pg_basebackup/pg_createsubscriber.c
pg_createsubscriber: Remove separate logfile_open() function
commit : f5528b90b411e0ba365f9cf42e97aa9b1c47cffa
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:52:19 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:52:19 +0200 This seems like an excessive indirection.
Discussion: https://www.postgresql.org/message-id/flat/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc%2BG%2Bf4oSUHw%40mail.gmail.com M src/bin/pg_basebackup/pg_createsubscriber.c
pg_createsubscriber: Use logging.c log file callback
commit : 847336ba53af2d140563cdf9f2b0c4f678378a54
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:44:14 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:44:14 +0200 This reverts commit 6b5b7eae3ae, where a new logging API layer was
introduced locally in pg_createsubscriber. Instead, use the log file
callback introduced in logging.c. This new approach is simpler,
eliminates code duplication, and doesn't require any caller changes or
NLS updates (which the previous commit missed).
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc%2BG%2Bf4oSUHw%40mail.gmail.com M src/bin/pg_basebackup/pg_createsubscriber.c
Add log file support to logging.c
commit : 41237556f8c554f691968dbdce5fa6f4012e8036
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:44:02 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 13 Apr 2026 10:44:02 +0200 This adds the ability for users of logging.c to provide a file handle
for a log file, where log messages are also written in addition to
stderr.
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc%2BG%2Bf4oSUHw%40mail.gmail.com M src/common/logging.c
M src/include/common/logging.h
Fix capitalization in publication describe output.
commit : 8f81c923516237fe842f800a77d4556f9dc35fe5
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 13 Apr 2026 10:54:16 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 13 Apr 2026 10:54:16 +0530 Consistent with existing psql metadata display conventions, update the
description tags for EXCEPT publications to use lowercase for the second
word (e.g., "Except tables" instead of "Except Tables"). This aligns the
output style with other publication describe commands.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pt3t_tCYwDStkj5fG4Z=YXrHvPBA7iGdh745QipC5zKeg@mail.gmail.com M src/bin/psql/describe.c
M src/test/regress/expected/publication.out
Fix excessive logging in idle slotsync worker.
commit : 85c17f612af7b9c47a9828805686f0dd2433cdf1
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 13 Apr 2026 10:06:50 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 13 Apr 2026 10:06:50 +0530 The slotsync worker was incorrectly identifying no-op states as successful
updates, triggering a busy loop to sync slots that logged messages every
200ms. This patch corrects the logic to properly classify these states,
enabling the worker to respect normal sleep intervals when no work is
performed.
Reported-by: Fujii Masao <masao.fujii@gmail.com>
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Backpatch-through: 17, where it was introduced
Discussion: https://postgr.es/m/CAHGQGwF6zG9Z8ws1yb3hY1VqV-WT7hR0qyXCn2HdbjvZQKufDw@mail.gmail.com M src/backend/replication/logical/slotsync.c
Improve various new-to-v19 appendStringInfo calls
commit : 49ce41810faca2722424b3d8fabda79bf4902339
author : David Rowley <drowley@postgresql.org>
date : Mon, 13 Apr 2026 13:16:48 +1200
committer: David Rowley <drowley@postgresql.org>
date : Mon, 13 Apr 2026 13:16:48 +1200 Similar to 928394b66 and 8461424fd, here we adjust a few new locations
which were not using the most suitable appendStringInfo* or
appendPQExpBuffer* function for the intended purpose.
Author: David Rowley <drowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvohYOdrvhVxXzCJNX_GYMSWBfjTTtB6hgDauEtZ8Nar2A@mail.gmail.com M contrib/pg_plan_advice/pg_plan_advice.c
M contrib/pg_plan_advice/pgpa_output.c
M contrib/pg_plan_advice/pgpa_trove.c
M src/backend/replication/logical/conflict.c
M src/backend/replication/logical/slotsync.c
M src/backend/utils/adt/ruleutils.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/psql/describe.c
M src/test/modules/test_escape/test_escape.c
test_saslprep: Fix issue with copy of input bytea
commit : 5d35531af1840fdd8debfc1ff657643ddba029ab
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 13 Apr 2026 09:06:17 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 13 Apr 2026 09:06:17 +0900 The data given in input of the function may not be null-terminated,
causing strlcpy() to complain with an invalid read.
Issue spotted using valgrind.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/09df9d75-13e7-45fe-89af-33fe118e797b@gmail.com M src/test/modules/test_saslprep/test_saslprep.c
Fix unlikely overflow bug in bms_next_member()
commit : e3e26d04bd52795083b3947151c5c71e989a01f8
author : David Rowley <drowley@postgresql.org>
date : Mon, 13 Apr 2026 11:39:15 +1200
committer: David Rowley <drowley@postgresql.org>
date : Mon, 13 Apr 2026 11:39:15 +1200 ... and bms_prev_member().
Both of these functions won't work correctly when given a prevbit of
INT_MAX and would crash when operating on a Bitmapset that happened to
have a member with that value.
Here we fix that by using an unsigned int to calculate which member to
look for next.
I've also adjusted bms_prev_member() to check for < 0 rather than == -1
for starting the loop. This was done as it's safer and comes at zero
extra cost.
With our current use cases, it's likely impossible to have a Bitmapset
with an INT_MAX member, so no backpatch here. I only noticed this issue
when working on a bms function to bitshift a Bitmapset.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAApHDvr1B2gbf6JF69QmueM2QNRvbQeeKLxDnF=w9f9--022uA@mail.gmail.com M src/backend/nodes/bitmapset.c
Use stack-allocated StringInfoDatas, where possible
commit : a63bbc811d41b3567eb37fe2636e660a852dbbf2
author : David Rowley <drowley@postgresql.org>
date : Mon, 13 Apr 2026 10:43:19 +1200
committer: David Rowley <drowley@postgresql.org>
date : Mon, 13 Apr 2026 10:43:19 +1200 6d0eba662 already did most of the changes, but some new ones snuck in
just prior to that commit, so these got missed.
Having these short-lived StringInfoDatas on the stack rather than having
them get palloc'd by makeStringInfo() is simply for performance as it
saves doing a 2nd palloc.
Since this code is new to v19, it makes sense to improve it now rather
than wait until we branch as having v19 and v20 differ here just makes it
harder to backpatch fixes in this area.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/adt4wpj4FZwR+S7I@ip-10-97-1-34.eu-west-3.compute.internal M src/backend/replication/logical/sequencesync.c
Doc: use "an SQL" consistently rather than "a SQL"
commit : a78cf591a3f5288aa5ae96902a36e342a3178b79
author : David Rowley <drowley@postgresql.org>
date : Sun, 12 Apr 2026 22:49:27 +1200
committer: David Rowley <drowley@postgresql.org>
date : Sun, 12 Apr 2026 22:49:27 +1200 Per the precedent set by 04539e73f, adjust article prefixes for "SQL" to
use "an" consistently rather than "a", i.e., "an es-que-ell" rather than
"a sequel".
Also see b51f86e49, b1b13d2b5, d866f0374 and 7bdd489d3.
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvp3osQwQam+wNTp9BdhP+QfWO6aY6ZTixQQMfM-UArKCw@mail.gmail.com M doc/src/sgml/xfunc.sgml
Honor passed-in database OIDs in pgstat_database.c
commit : 80156cee06b9d257251d72379ac43f9b88bd13e1
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 11 Apr 2026 17:02:52 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 11 Apr 2026 17:02:52 +0900 Three routines in pgstat_database.c incorrectly ignore the database OID
provided by their caller, using MyDatabaseId instead:
- pgstat_report_connect()
- pgstat_report_disconnect()
- pgstat_reset_database_timestamp()
The first two functions, for connection and disconnection, each have a
single caller that already passes MyDatabaseId. This was harmless,
still incorrect.
The timestamp reset function also has a single caller, but in this case
the issue has a real impact: it fails to reset the timestamp for the
shared-database entry (datid=0) when operating on shared objects. This
situation can occur, for example, when resetting counters for shared
relations via pg_stat_reset_single_table_counters().
There is currently one test in the tree that checks the reset of a
shared relation, for pg_shdescription, we rely on it to check what is
stored in pg_stat_database. As stats_reset may be NULL, two resets are
done to provide a baseline for comparison.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Dapeng Wang <wangdp20191008@gmail.com>
Discussion: https://postgr.es/m/ABBD5026-506F-4006-A569-28F72C188693@gmail.com
Backpatch-through: 15 M src/backend/utils/activity/pgstat_database.c
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql
Fix estimate_array_length error with set-operation array coercions
commit : 77d0e82e58854cfa5e2c4f365a97f16c0d91c394
author : Richard Guo <rguo@postgresql.org>
date : Sat, 11 Apr 2026 16:38:47 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Sat, 11 Apr 2026 16:38:47 +0900 When a nested set operation's output type doesn't match the parent's
expected type, recurse_set_operations builds a projection target list
using generate_setop_tlist with varno 0. If the required type
coercion involves an ArrayCoerceExpr, estimate_array_length could be
called on such a Var, and would pass it to examine_variable, which
errors in find_base_rel because varno 0 has no valid relation entry.
Fix by skipping the statistics lookup for Vars with varno 0.
Bug introduced by commit 9391f7152. Back-patch to v17, where
estimate_array_length was taught to use statistics.
Reported-by: Justin Pryzby <pryzby@telsasoft.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/adjW8rfPDkplC7lF@pryzbyj2023
Backpatch-through: 17 M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/union.out
M src/test/regress/sql/union.sql
read_stream: Remove obsolete comment.
commit : b2a17ba7a5d00071f433d3ef60ddd2356679aad7
author : Thomas Munro <tmunro@postgresql.org>
date : Sat, 11 Apr 2026 11:23:26 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Sat, 11 Apr 2026 11:23:26 +1200 This comment was describing the v17 implementation (or io_method=sync).
Backpatch-through: 18 M src/backend/storage/aio/read_stream.c
Fix unstable log verification in test_autovacuum.
commit : c22d115f1d13d7c1b89ec20abaa02ebeb811b9dd
author : Masahiko Sawada <msawada@postgresql.org>
date : Fri, 10 Apr 2026 16:01:42 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Fri, 10 Apr 2026 16:01:42 -0700 The test in test_autovacuum was unstable because it called
log_contains() immediately after verifying autovacuum_count in
pg_stat_user_tables. This created a race condition where the
statistics could be updated before the autovacuum logs were fully
flushed to disk.
This commit replaces log_contains() with wait_for_log() to ensure the
test waits for the parallel vacuum messages to appear. Additionally,
remove the checks of the autovacuum count. Verifying the log messages
is sufficient to confirm parallel autovacuum behavior, as logging is
only enabled for the specific table under test.
Per report from buildfarm member flaviventris.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/525d0f48-93f7-493f-a988-f39b460a79bc@gmail.com M src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
doc: Improve consistency of parallel vacuum description.
commit : 2a3d2f9f68da0c430c497bf29f60373f5214307d
author : Masahiko Sawada <msawada@postgresql.org>
date : Fri, 10 Apr 2026 10:59:24 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Fri, 10 Apr 2026 10:59:24 -0700 Use consistent phrasing for parallel vacuum descriptions between
manual VACUUM and autovacuum. Specifically, clarify that the parallel
worker count is limited by the respective options only if they are
explicitly specified.
Also, fix a typo in the parallel vacuum section.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://postgr.es/m/CAJ7c6TPcSqzhbhrsiCMmVwmE8F7pwS7i9J49SP1zPKS_ER+vcA@mail.gmail.com M doc/src/sgml/maintenance.sgml
Adjust log level of logical decoding messages by context
commit : de74d1e9a5453b8efe2eda2afebcf8218a503184
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 10 Apr 2026 22:59:34 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 10 Apr 2026 22:59:34 +0900 Commit 21b018e7eab lowered some logical decoding messages from LOG to DEBUG1.
However, per discussion on pgsql-hackers, messages from background activity
(e.g., walsender or slotsync worker) should remain at LOG, as they are less
frequent and more likely to indicate issues that DBAs should notice.
For foreground SQL functions (e.g., pg_logical_slot_peek_binary_changes()),
keep these messages at DEBUG1 to avoid excessive log noise. They can still be
enabled by lowering client_min_messages or log_min_messages for the session.
This commit updates logical decoding to log these messages at LOG for
background activity and at DEBUG1 for foreground execution.
Suggested-by: Robert Haas <robertmhaas@gmail.com>
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CA+TgmoYsu2+YAo9eLGkDp5VP-pfQ-jOoX382vS4THKHeRTNgew@mail.gmail.com M src/backend/replication/logical/logical.c
M src/backend/replication/logical/snapbuild.c
M src/include/replication/logical.h
M src/test/recovery/t/038_save_logical_slots_shutdown.pl
Revert "Add built-in fuzzing harnesses for security testing."
commit : eec8e234bdcbe43e0407b03c44484bf75423d515
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 10 Apr 2026 09:53:58 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 10 Apr 2026 09:53:58 -0400 This reverts commit 4a18907b412e77684bf888ad6d1b4844d220196a.
inadvertenly pushed, mea culpa M meson_options.txt
D src/test/fuzzing/fuzz_b64decode.c
D src/test/fuzzing/fuzz_conninfo.c
D src/test/fuzzing/fuzz_json.c
D src/test/fuzzing/fuzz_json_incremental.c
D src/test/fuzzing/fuzz_parsepgarray.c
D src/test/fuzzing/fuzz_pgbench_expr.c
D src/test/fuzzing/fuzz_pglz.c
D src/test/fuzzing/fuzz_rawparser.c
D src/test/fuzzing/fuzz_regex.c
D src/test/fuzzing/fuzz_saslprep.c
D src/test/fuzzing/fuzz_typeinput.c
D src/test/fuzzing/fuzz_unescapebytea.c
D src/test/fuzzing/meson.build
M src/test/meson.build
Use size_t instead of Size in pg_waldump
commit : 3f8913f683ba99e7135d374541f52c626fcc6eec
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 10 Apr 2026 09:29:00 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 10 Apr 2026 09:29:00 -0400 In commit b15c1513984 I missed the memo about not using Size in new
code.
Per complaint from Thomas Munro
Discussion: https://postgr.es/m/CA+hUKGJkeTVuq5u5WKJm6xkwmW577UuQ7fA=PyBCSR3h9g2GtQ@mail.gmail.com M src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/pg_waldump.h
Add built-in fuzzing harnesses for security testing.
commit : 4a18907b412e77684bf888ad6d1b4844d220196a
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 9 Apr 2026 14:20:40 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 9 Apr 2026 14:20:40 -0400 Add 12 libFuzzer-compatible fuzzing harnesses behind a new -Dfuzzing=true
meson option. Each harness implements LLVMFuzzerTestOneInput() and can
also be built in standalone mode (reading from files) when no fuzzer
engine is detected.
Frontend targets (no backend dependencies):
fuzz_json - non-incremental JSON parser (pg_parse_json)
fuzz_json_incremental - incremental/chunked JSON parser
fuzz_conninfo - libpq connection string parser (PQconninfoParse)
fuzz_pglz - PGLZ decompressor (pglz_decompress)
fuzz_unescapebytea - libpq bytea unescape (PQunescapeBytea)
fuzz_b64decode - base64 decoder (pg_b64_decode)
fuzz_saslprep - SASLprep normalization (pg_saslprep)
fuzz_parsepgarray - array literal parser (parsePGArray)
fuzz_pgbench_expr - pgbench expression parser (via Bison/Flex)
Backend targets (link against postgres_lib):
fuzz_rawparser - SQL raw parser (raw_parser)
fuzz_regex - regex engine (pg_regcomp/pg_regexec)
fuzz_typeinput - type input functions (numeric/date/timestamp/interval) M meson_options.txt
A src/test/fuzzing/fuzz_b64decode.c
A src/test/fuzzing/fuzz_conninfo.c
A src/test/fuzzing/fuzz_json.c
A src/test/fuzzing/fuzz_json_incremental.c
A src/test/fuzzing/fuzz_parsepgarray.c
A src/test/fuzzing/fuzz_pgbench_expr.c
A src/test/fuzzing/fuzz_pglz.c
A src/test/fuzzing/fuzz_rawparser.c
A src/test/fuzzing/fuzz_regex.c
A src/test/fuzzing/fuzz_saslprep.c
A src/test/fuzzing/fuzz_typeinput.c
A src/test/fuzzing/fuzz_unescapebytea.c
A src/test/fuzzing/meson.build
M src/test/meson.build
Fix heap-buffer-overflow in pglz_decompress() on corrupt input.
commit : 2b5ba2a0a141f621f61cb732d776dc78269f879b
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 9 Apr 2026 11:48:55 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 9 Apr 2026 11:48:55 -0400 When decoding a match tag, pglz_decompress() reads 2 bytes (or 3
for extended-length matches) from the source buffer before checking
whether enough data remains. The existing bounds check (sp > srcend)
occurs after the reads, so truncated compressed data that ends
mid-tag causes a read past the allocated buffer.
Fix by validating that sufficient source bytes are available before
reading each part of the match tag. The post-read sp > srcend
check is no longer needed and is removed.
Found by fuzz testing with libFuzzer and AddressSanitizer. M src/common/pg_lzcompress.c
Fix incremental JSON parser numeric token reassembly across chunks.
commit : 2478bd5db0aad3599802636201af7adc170ba280
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 9 Apr 2026 07:57:07 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 9 Apr 2026 07:57:07 -0400 When the incremental JSON parser splits a numeric token across chunk
boundaries, it accumulates continuation characters into the partial
token buffer. The accumulator's switch statement unconditionally
accepted '+', '-', '.', 'e', and 'E' as valid numeric continuations
regardless of position, which violated JSON number grammar
(-? int [frac] [exp]). For example, input "4-" fed in single-byte
chunks would accumulate the '-' into the numeric token, producing an
invalid token that later triggered an assertion failure during
re-lexing.
Fix by tracking parser state (seen_dot, seen_exp, prev character)
across the existing partial token and incoming bytes, so that each
character class is accepted only in its grammatically valid position. M src/common/jsonapi.c
Add test case for same-type reordered FK columns
commit : 009ea1b08d7b8843435bd0f1137fa3df09aac79f
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 17:44:06 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 17:44:06 +0900 The test added in 980c1a85d819 covered reordered FK columns with
different types, which triggered an "operator not a member of opfamily"
error in the fast-path prior to that commit. Add a test for the
same-type case, which is also fixed by that commit but where the wrong
scan key ordering instead produced a spurious FK violation without any
internal error.
Reported-by: Fredrik Widlert <fredrik.widlert@digpro.se>
Discussion: https://postgr.es/m/CADfhSr8hYc-4Cz7vfXH_oV-Jq81pyK9W4phLrOGspovsg2W7Kw@mail.gmail.com M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql
Move afterTriggerFiringDepth into AfterTriggersData
commit : d6e96bacd3c05f1a2c1e350d04cc450e91311299
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 16:16:07 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 16:16:07 +0900 The static variable afterTriggerFiringDepth introduced by commit
5c54c3ed1b9 is logically part of the after-trigger state and in
hindsight should have been a field in AfterTriggersData alongside
query_depth and the other per-transaction after-trigger state.
Move it there as firing_depth. Also update its comment to
accurately reflect its sole remaining purpose: signaling to
AfterTriggerIsActive() that after-trigger firing is active.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CA+HiwqFt4NGTNk7BinOsHHM48E9zGAa852vCfGoSe1bbL=JNFQ@mail.gmail.com M src/backend/commands/trigger.c
Fix var_is_nonnullable() to account for varreturningtype
commit : f6936bf9da58afd167787635863bae387ae5ba35
author : Richard Guo <rguo@postgresql.org>
date : Fri, 10 Apr 2026 15:51:00 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 10 Apr 2026 15:51:00 +0900 var_is_nonnullable() failed to consider varreturningtype, which meant
it could incorrectly claim a Var is non-nullable based on a column's
NOT NULL constraint even when the Var refers to a non-existent row.
Specifically, OLD.col is NULL for INSERT (no old row exists) and
NEW.col is NULL for DELETE (no new row exists), regardless of any NOT
NULL constraint on the column.
This caused the planner's constant folding in eval_const_expressions
to incorrectly simplify IS NULL / IS NOT NULL tests on such Vars. For
example, "old.a IS NULL" in an INSERT's RETURNING clause would be
folded to false when column "a" has a NOT NULL constraint, even though
the correct result is true.
Fix by returning false from var_is_nonnullable() when varreturningtype
is not VAR_RETURNING_DEFAULT, since such Vars can be NULL regardless
of table constraints.
Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDfaAipL6YzOq2H=gAhKBbcUTYmfbAv+W1zueOfRKH43FQ@mail.gmail.com M src/backend/optimizer/util/clauses.c
M src/test/regress/expected/returning.out
M src/test/regress/sql/returning.sql
Assert index_attnos[0] == 1 in ri_FastPathFlushArray()
commit : 155c03ee9d449589fa93aabcac41d643d03875b9
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 15:24:38 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 15:24:38 +0900 ri_FastPathFlushArray() handles single-column FKs only, so
index_attnos[0] is always 1. Add an Assert to make this invariant
explicit, as a followup to 980c1a85d819.
Suggested-by: Junwang Zhao <zhjwpku@gmail.com> (offlist)
Discussion: https://www.postgresql.org/message-id/CADfhSr-pCkbDxmiOVYSAGE5QGjsQ48KKH_W424SPk%2BpwzKZFaQ%40mail.gmail.com M src/backend/utils/adt/ri_triggers.c
Fix FK fast-path scan key ordering for mismatched column order
commit : 980c1a85d819edc72c866001b9ca4fba454900fe
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 13:33:55 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 13:33:55 +0900 The fast-path foreign key check introduced in 2da86c1ef9b assumed that
constraint key positions directly correspond to index column positions.
This is not always true as a FK constraint can reference PK columns in a
different order than they appear in the PK's unique index.
For example, if the PK is (a, b, c) and the FK references them as
(a, c, b), the constraint stores keys in the FK-specified order, but
the index has columns in PK order. The buggy code used the constraint
key index to access rd_opfamily[i], which retrieved the wrong operator
family when columns were reordered, causing "operator X is not a member
of opfamily Y" errors.
After fixing the opfamily lookup, a second issue started to happen:
btree index scans require scan keys to be ordered by attribute number.
The code was placing scan keys at array position i with attribute number
idx_attno, producing out-of-order keys when columns were swapped. This
caused "btree index keys must be ordered by attribute" errors.
The fix adds an index_attnos array to FastPathMeta that maps each
constraint key position to its corresponding index column position.
In ri_populate_fastpath_metadata(), we search indkey to find the actual
index column for each pk_attnums[i] and use that position for the
opfamily lookup. In build_index_scankeys(), we place each scan key at
the array position corresponding to its index column
(skeys[idx_attno-1]) rather than at the constraint key position,
ensuring scan keys are properly ordered by attribute number as btree
requires.
Reported-by: Fredrik Widlert <fredrik.widlert@digpro.se>
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/CADfhSr-pCkbDxmiOVYSAGE5QGjsQ48KKH_W424SPk%2BpwzKZFaQ%40mail.gmail.com 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 typo left by 34a30786293
commit : 03029409b409ffd5c7f2eab9acb13d2fa76fa4bd
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 13:32:38 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 13:32:38 +0900 Reported-by: jie wang <jugierwang@gmail.com>
Reported-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAJnZyeDyaS=X-eYN=9rDYqK=6ma1gMLa0qDgfNbZKK0e0+q99Q@mail.gmail.com M src/backend/commands/trigger.c
Fix RI fast-path crash under nested C-level SPI
commit : 34a307862930056e1976471d6d81a5e2efc148df
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 12:40:09 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 10 Apr 2026 12:40:09 +0900 When a C-language function uses SPI_connect/SPI_execute/SPI_finish to
INSERT into a table with FK constraints, the FK AFTER triggers fire
and schedule ri_FastPathEndBatch via
RegisterAfterTriggerBatchCallback(), opening PK relations under
CurrentResourceOwner at the time of the SPI call. The query_depth > 0
guard in FireAfterTriggerBatchCallbacks suppresses the callback at
that nesting level, deferring teardown to the outer query's
AfterTriggerEndQuery. By then the resource owner active during the SPI
call may have been released, decrementing the cached relations'
refcounts to zero. ri_FastPathTeardown, running under the outer
query's resource owner, then crashes in assert builds when it attempts
to close relations whose refcounts are already zero:
TRAP: failed Assert("rel->rd_refcnt > 0")
Fix by storing batch callbacks at the level where they should fire:
in AfterTriggersQueryData.batch_callbacks for immediate constraints
(fired by AfterTriggerEndQuery) and in AfterTriggersData.batch_callbacks
for deferred constraints (fired by AfterTriggerFireDeferred and
AfterTriggerSetState). RegisterAfterTriggerBatchCallback() routes the
callback to the current query-level list when query_depth >= 0, and to
the top-level list otherwise. FireAfterTriggerBatchCallbacks() takes a
list parameter and simply iterates and invokes it; memory cleanup is
handled by the caller. This replaces the query_depth > 0 guard with
list-level scoping. Note that deferred constraints are unaffected by
this bug: their callbacks fire at commit via AfterTriggerFireDeferred,
under the outer transaction's resource owner, which remains valid
throughout.
Also add firing_batch_callbacks to AfterTriggersData to enforce that
callbacks do not register new callbacks during
FireAfterTriggerBatchCallbacks(), which would be unsafe as it could
modify the list being iterated. An Assert in
RegisterAfterTriggerBatchCallback() enforces this discipline for
future callers. The flag is reset at transaction and subtransaction
boundaries to handle cases where an error thrown by a callback is
caught and the subtransaction is rolled back.
While at it, ensure callbacks are properly accounted for at all
transaction boundaries, as cleanup of b7b27eb41a5c: discard any
remaining top-level callbacks on both commit and abort in
AfterTriggerEndXact(), and clean up query-level callbacks in
AfterTriggerFreeQuery().
Note that ri_PerformCheck() calls SPI with fire_triggers=false, which
skips AfterTriggerBeginQuery/EndQuery for that SPI command. Any
triggers queued during that SPI command are not fired immediately but
deferred to the outer query level. Since the fast-path check for
those triggers runs under the outer query's resource owner rather than
a nested SPI resource owner, and ri_PerformCheck() does not create
a dedicated child resource owner, the bug described above does not
apply.
Reported-by: Evan Montgomery-Recht <montge@mianetworks.net>
Reported-by: Sandro Santilli <strk@kbt.io>
Analyzed-by: Evan Montgomery-Recht <montge@mianetworks.net>
Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAEg7pwcKf01FmDqFAf-Hzu_pYnMYScY_Otid-pe9uw3BJ6gq9g@mail.gmail.com M src/backend/commands/trigger.c
Document new catalog columns, missed in commit 8185bb5347.
commit : 90630ec42939d074ecc7b6b959b48252eed32646
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 9 Apr 2026 20:29:42 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 9 Apr 2026 20:29:42 -0700 Reported-by: "Shinoda, Noriyoshi (PSD Japan FSI)" <noriyoshi.shinoda@hpe.com>
Co-authored-by: "Shinoda, Noriyoshi (PSD Japan FSI)" <noriyoshi.shinoda@hpe.com>
Discussion: https://postgr.es/m/LV8PR84MB3787135EBDBF7747A05731F3EE592@LV8PR84MB3787.NAMPRD84.PROD.OUTLOOK.COM M doc/src/sgml/catalogs.sgml
Zero-fill private_data when attaching an injection point
commit : 5b5bf51e435304b2043db46b65455747de2af1f5
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 10 Apr 2026 11:17:09 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 10 Apr 2026 11:17:09 +0900 InjectionPointAttach() did not initialize the private_data buffer of the
shared memory entry before (perhaps partially) overwriting it. When the
private data is set to NULL by the caler, the buffer was left
uninitialized. If set, it could have stale contents.
The buffer is initialized to zero, so as the contents recorded when a
point is attached are deterministic.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0tsGHu2h6YLnVu4HiK05q+gTE_9WVUAqihW2LSscAYS-g@mail.gmail.com
Backpatch-through: 17 M src/backend/utils/misc/injection_point.c
Fix double-free in pg_stat_autovacuum_scores.
commit : 71ff232a5bc40f36365be985da72b8b6fa275811
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 9 Apr 2026 13:07:06 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 9 Apr 2026 13:07:06 -0500 Presently, relation_needs_vacanalyze() unconditionally frees the
pgstat entry returned by pgstat_fetch_stat_tabentry_ext(). This
behavior was first added by commit 02502c1bca to avoid memory
leakage in autovacuum. While this is fine for autovacuum since it
forces stats_fetch_consistency to "none", it is not okay for other
callers that use "cache" or "snapshot". This manifests as a
double-free when pg_stat_autovacuum_scores is called multiple times
in the same transaction.
To fix, add a "bool *may_free" parameter to
pgstat_fetch_stat_tabentry_ext() that returns whether it is safe
for the caller to explicitly pfree() the result. If a caller would
rather leave it to the memory context machinery to free the result,
it can pass NULL as the "may_free" argument (or just ignore its
value).
Oversight in commit 87f61f0c82.
Reported-by: Tender Wang <tndrwang@gmail.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAHewXNkJKdwb3D5OnksrdOqzqUnXUEMpDam1TPW0vfUkW%3D7jUw%40mail.gmail.com
Discussion: https://postgr.es/m/5684f479-858e-4c5d-b8f5-bcf05de1f909%40gmail.com M src/backend/postmaster/autovacuum.c
M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_backend.c
M src/backend/utils/activity/pgstat_database.c
M src/backend/utils/activity/pgstat_function.c
M src/backend/utils/activity/pgstat_relation.c
M src/backend/utils/activity/pgstat_replslot.c
M src/backend/utils/activity/pgstat_subscription.c
M src/include/pgstat.h
M src/include/utils/pgstat_internal.h
M src/test/modules/test_custom_stats/test_custom_var_stats.c
Remove an unstable wait from parallel autovacuum regression test.
commit : 8030b839d3d2be1038297db852dbe0578c1b46ce
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 9 Apr 2026 09:13:32 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 9 Apr 2026 09:13:32 -0700 The test 001_parallel_autovacuum.pl verified that vacuum delay
parameters are propagated to parallel vacuum workers by using
injection points. It previously waited for autovacuum to complete on
the test_autovac table. However, since injection points are
cluster-wide, an autovacuum worker could be triggered on tables in
other databases (e.g., template1) and get stuck at the same injection
point. This could lead to a timeout when the test waits for the
expected table's autovacuum to finish.
This commit removes the wait for autovacuum completion from this
specific test case. Since the primary goal is to verify the
propagation of parameter updates, which is already confirmed via log
messages, waiting for the entire vacuum process to finish is
unnecessary and prone to instability in concurrent test environments.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0s+kZZRMSF4HW7tZ9W2jS1o4B+Fg8dr5a-T6mANX+mdQA@mail.gmail.com M src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
instrumentation: Avoid CPUID 0x15/0x16 for Hypervisor TSC frequency
commit : 7fc36c5db55016f7a1d89b5e2efd82fe6fd39632
author : Andres Freund <andres@anarazel.de>
date : Thu, 9 Apr 2026 11:50:24 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 9 Apr 2026 11:50:24 -0400 This restricts the retrieval of the TSC frequency whilst under a Hypervisor to
either Hypervisor-specific CPUID registers (0x40000010), or TSC
calibration. We previously allowed retrieving from the traditional CPUID
registers for TSC frequency (0x15/0x16) like on bare metal, but it turns out
that they are not trustworthy when virtualized and can report wildly incorrect
frequencies, like 7 kHz when the actual calibrated frequencty is 2.5 GHz.
Per report from buildfarm member drongo.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/jr4hk2sxhqcfpb67ftz5g4vw33nm67cgf7go3wwmqsafu5aclq%405m67ukuhyszz M src/port/pg_cpu_x86.c
Add LOG_NEVER error level code.
commit : 60165db6e1f21ec6cbfce4fd8fd1e521a043d954
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 9 Apr 2026 10:18:15 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 9 Apr 2026 10:18:15 -0500 This logging level means not to emit the log, which is useful for
functions like relation_needs_vacanalyze(). This function accepts
a log level argument but not all callers want it to emit logs.
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3101163.1775676098%40sss.pgh.pa.us M src/backend/postmaster/autovacuum.c
M src/include/utils/elog.h
Fix integer overflow in nodeWindowAgg.c
commit : 8b6c89e377b545ddb04fc09eecf89cd52be89e07
author : Richard Guo <rguo@postgresql.org>
date : Thu, 9 Apr 2026 19:28:33 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Thu, 9 Apr 2026 19:28:33 +0900 In nodeWindowAgg.c, the calculations for frame start and end positions
in ROWS and GROUPS modes were performed using simple integer addition.
If a user-supplied offset was sufficiently large (close to INT64_MAX),
adding it to the current row or group index could cause a signed
integer overflow, wrapping the result to a negative number.
This led to incorrect behavior where frame boundaries that should have
extended indefinitely (or beyond the partition end) were treated as
falling at the first row, or where valid rows were incorrectly marked
as out-of-frame. Depending on the specific query and data, these
overflows can result in incorrect query results, execution errors, or
assertion failures.
To fix, use overflow-aware integer addition (ie, pg_add_s64_overflow)
to check for overflows during these additions. If an overflow is
detected, the boundary is now clamped to INT64_MAX. This ensures the
logic correctly treats the boundary as extending to the end of the
partition.
Bug: #19405
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/19405-1ecf025dda171555@postgresql.org
Backpatch-through: 14 M src/backend/executor/nodeWindowAgg.c
M src/test/regress/expected/window.out
M src/test/regress/sql/window.sql
Update config.guess and config.sub
commit : 11d6042337fc064e245081671c47cd9c1ac0d772
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 9 Apr 2026 11:26:14 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 9 Apr 2026 11:26:14 +0200 M config/config.guess
M config/config.sub
Strip PlaceHolderVars from partition pruning operands
commit : c1408956e393958cc93ef0dd622de406c7f3b8da
author : Richard Guo <rguo@postgresql.org>
date : Thu, 9 Apr 2026 16:41:31 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Thu, 9 Apr 2026 16:41:31 +0900 When pulling up a subquery, its targetlist items may be wrapped in
PlaceHolderVars to enforce separate identity or as a result of outer
joins. This causes any upper-level WHERE clauses referencing these
outputs to contain PlaceHolderVars, which prevents partprune.c from
recognizing that they match partition key columns, defeating partition
pruning.
To fix, strip PlaceHolderVars from operands before comparing them to
partition keys. A PlaceHolderVar with empty phnullingrels appearing
in a relation-scan-level expression is effectively a no-op, so
stripping it is safe. This parallels the existing treatment in
indxpath.c for index matching.
In passing, rename strip_phvs_in_index_operand() to strip_noop_phvs()
and move it from indxpath.c to placeholder.c, since it is now a
general-purpose utility used by both index matching and partition
pruning code.
Back-patch to v18. Although this issue exists before that, changes in
that version made it common enough to notice. Given the lack of field
reports for older versions, I am not back-patching further. In the
v18 back-patch, strip_phvs_in_index_operand() is retained as a thin
wrapper around the new strip_noop_phvs() to avoid breaking third-party
extensions that may reference it.
Reported-by: Cándido Antonio Martínez Descalzo <candido@ninehq.com>
Diagnosed-by: David Rowley <dgrowleyml@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAH5YaUwVUWETTyVECTnhs7C=CVwi+uMSQH=cOkwAUqMdvXdwWA@mail.gmail.com
Backpatch-through: 18 M src/backend/optimizer/path/indxpath.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/placeholder.c
M src/backend/partitioning/partprune.c
M src/include/optimizer/paths.h
M src/include/optimizer/placeholder.h
M src/test/regress/expected/partition_prune.out
M src/test/regress/sql/partition_prune.sql
Add nkeys parameter to recheck_matched_pk_tuple()
commit : e1cc57fabd6c32fcb740d62da90443f8c708951e
author : Amit Langote <amitlan@postgresql.org>
date : Thu, 9 Apr 2026 14:45:31 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Thu, 9 Apr 2026 14:45:31 +0900 The function looped over ii_NumIndexKeyAttrs elements of the skeys
array, but one caller (ri_FastPathFlushArray) passes a one-element
array since it only handles single-column FKs. The function
signature did not communicate this constraint, which static analysis
flags as a potential out-of-bounds read.
Add an nkeys parameter and assert that it matches
ii_NumIndexKeyAttrs, then use it in the loop. The call sites
already know the key count.
Reported-by: Evan Montgomery-Recht <montge@mianetworks.net>
Discussion: https://postgr.es/m/CAEg7pwcKf01FmDqFAf-Hzu_pYnMYScY_Otid-pe9uw3BJ6gq9g@mail.gmail.com M src/backend/utils/adt/ri_triggers.c
Reduce presence of syscache.h in src/include/
commit : e0fa5bd146564d9d05cac15bdcba65b7860d2b91
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 9 Apr 2026 08:49:36 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 9 Apr 2026 08:49:36 +0900 ee642cccc43c has added syscache.h in inval.h and objectaddress.h,
enlarging by a lot the footprint of this header, particularly via
objectaddress.h. A change in syscache.h would cause a lot more files to
be recompiled.
This commit reduces the presence of syscache.h by switching to a direct
use of syscache_ids.h in inval.h and objectaddress.h, where the enum
SysCacheIdentifier is defined. genbki.pl gains an #ifndef block for
this header, so as its inclusion is more controlled.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/vlcexdcimsmvu3aplt2yxpfndkgtuvjsrms2fdl46rbw3k2kug@drspkoxlaije M src/backend/catalog/genbki.pl
M src/include/catalog/objectaddress.h
M src/include/utils/inval.h
Simplify declaration of memcpy target
commit : 2cff363715efe3fd2dfbb04f9aa52fd5638f8f0d
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 8 Apr 2026 22:58:56 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 8 Apr 2026 22:58:56 +0200 The existing one is understandable failing on (some?) 32-bit platforms.
Reported-by: Tomas Vondra <tomas@vondra.me>
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1c197f2d-49a2-4830-8dde-55867218b62d@vondra.me M src/backend/commands/repack.c
doc: Fix data_checksums data type
commit : b364828f825a5914a21140145186365021ac0bc4
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 8 Apr 2026 22:53:43 +0300
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 8 Apr 2026 22:53:43 +0300 Commit f19c0eccae96 changed the data_checksums GUC datatype from a
boolean to an enum. This updates the documentation to accurately
reflect its new type and document the new possible states: 'on',
'off', 'inprogress-on', and 'inprogress-off'.
Also update the xref for more information to point to the section
on data checksums rather than the initdb checksum option.
Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CA+3i_M-AtTnqTB2KLBTpu-c-jvnTuy7bGxyxs80rgiQLxWrRUQ@mail.gmail.com M doc/src/sgml/config.sgml
Add a couple of commits to .git-blame-ignore-revs.
commit : e0851bded6412641ada14f36072b82d81906ee29
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 8 Apr 2026 13:41:22 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 8 Apr 2026 13:41:22 -0500 M .git-blame-ignore-revs
Add missing PGDLLIMPORT markings
commit : f8eec1ced6979157cbf517b5bbf617b82a01a397
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 8 Apr 2026 15:49:33 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 8 Apr 2026 15:49:33 +0200 M src/include/miscadmin.h
M src/include/portability/instr_time.h
Remove RADIUS support.
commit : a1643d40b308911cc725e62d3c5f7904b426aa09
author : Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 22:38:43 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 22:38:43 +1200 Our RADIUS implementation supported only the deprecated RADIUS/UDP
variant, without the recommended Message-Authenticator attribute to
mitigate against the Blast-RADIUS vulnerability. By now, popular RADIUS
servers are expected to generate loud warnings or reject our
authentication attempts outright.
Since there have been no user reports about this, it seems unlikely that
there are users.
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Michael Banck <mbanck@gmx.net>
Discussion: https://postgr.es/m/CA%2BhUKG%2BSH309V8KECU5%3DxuLP9Dks0v9f9UVS2W74fPAE5O21dg%40mail.gmail.com A doc/src/sgml/appendix-obsolete-auth-radius.sgml
M doc/src/sgml/appendix-obsolete.sgml
M doc/src/sgml/client-auth.sgml
M doc/src/sgml/filelist.sgml
M src/backend/libpq/auth.c
M src/backend/libpq/hba.c
M src/backend/libpq/pg_hba.conf.sample
M src/backend/utils/adt/hbafuncs.c
M src/include/libpq/hba.h
M src/tools/pgindent/typedefs.list
Add support for importing statistics from remote servers.
commit : 28972b6fc3dcd1296e844246b635eddfa29c38e1
author : Etsuro Fujita <efujita@postgresql.org>
date : Wed, 8 Apr 2026 19:15:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Wed, 8 Apr 2026 19:15:00 +0900 Add a new FDW callback routine that allows importing remote statistics
for a foreign table directly to the local server, instead of collecting
statistics locally. The new callback routine is called at the beginning
of the ANALYZE operation on the table, and if the FDW failed to import
the statistics, the existing callback routine is called on the table to
collect statistics locally.
Also implement this for postgres_fdw. It is enabled by "restore_stats"
option both at the server and table level. Currently, it is the user's
responsibility to ensure remote statistics to import are up-to-date, so
the default is false.
Author: Corey Huinker <corey.huinker@gmail.com>
Co-authored-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/CADkLM%3DchrYAx%3DX2KUcDRST4RLaRLivYDohZrkW4LLBa0iBhb5w%40mail.gmail.com M contrib/postgres_fdw/deparse.c
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/fdwhandler.sgml
M doc/src/sgml/postgres-fdw.sgml
M src/backend/commands/analyze.c
M src/backend/statistics/extended_stats.c
M src/include/commands/vacuum.h
M src/include/foreign/fdwapi.h
M src/include/statistics/statistics.h
M src/tools/pgindent/typedefs.list
aio: Adjust I/O worker pool automatically.
commit : d1c01b79d4ae90e52bf9db9c05c9de17b7313e85
author : Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 19:06:14 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 19:06:14 +1200 The size of the I/O worker pool used to implement io_method=worker was
previously controlled by the io_workers setting, defaulting to 3. It
was hard to know how to tune it effectively. That is replaced with:
io_min_workers=2
io_max_workers=8 (up to 32)
io_worker_idle_timeout=60s
io_worker_launch_interval=100ms
The pool is automatically sized within the configured range according to
recent variation in demand. It grows when existing workers detect that
latency might be introduced by queuing, and shrinks when the
highest-numbered worker is idle for too long. Work was already
concentrated into low-numbered workers in anticipation of this logic.
The logic for waking extra workers now also tries to measure and reduce
the number of spurious wakeups, though they are not entirely eliminated.
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2Bm4xV0LMoH2c%3DoRAdEXuCnh%2BtGBTWa7uFeFMGgTLAw%2BQ%40mail.gmail.com M doc/src/sgml/config.sgml
M src/backend/postmaster/postmaster.c
M src/backend/storage/aio/method_worker.c
M src/backend/utils/activity/wait_event_names.txt
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/include/storage/io_worker.h
M src/include/storage/lwlocklist.h
M src/include/storage/pmsignal.h
M src/test/modules/test_aio/t/002_io_workers.pl
M src/tools/pgindent/typedefs.list
Exit early from pg_comp_crc32c_pmull for small inputs
commit : 948ef7cdc499b5226784a45ef1187ff554bf692a
author : John Naylor <john.naylor@postgresql.org>
date : Wed, 8 Apr 2026 13:52:14 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Wed, 8 Apr 2026 13:52:14 +0700 The vectorized path in commit fbc57f2bc had a side effect of putting
more branches in the path taken for small inputs. To reduce risk
of regressions, only proceed with the vectorized path if we can
guarantee that the remaining input after the alignment preamble is
greater than 64 bytes. That also allows removing length checks in
the alignment preamble.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/CANWCAZZ48GuLYhJCcTy8TXysjrMVJL6n1n7NP94=iG+t80YKPw@mail.gmail.com M src/port/pg_crc32c_armv8.c
pg_upgrade: Check for unsupported encodings.
commit : ce11e63f812f987a9d6256b81cd4af91921a5a39
author : Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 17:45:09 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 17:45:09 +1200 Since we have dropped MULE_INTERNAL, add a check that all encodings used
in the source cluster are still supported according to
PG_ENCODING_BE_VALID(). This is done generically, in case we decide to
drop another encoding some day.
Suggested-by: Jeff Davis <pgsql@j-davis.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGKXDXh-FdU0orjfv%2BF08f%3DD91BhV3Ra-4zL-q%2BJmGYqTA%40mail.gmail.com M src/bin/pg_upgrade/check.c
Remove MULE_INTERNAL encoding.
commit : 77645d44e3552ca0690e158ce5c51dc75c4934a4
author : Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 17:40:06 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Wed, 8 Apr 2026 17:40:06 +1200 This was useful before widespread Unicode adoption, and was based on the
internal encoding Emacs used to mix multiple sub-encodings. Emacs
itself has stopped using it, and our implementation hadn't been updated
with modern underlying standards. It is thought to be very unlikely
that anyone is still using it in the field. Since such a complex
encoding comes with costs and risks, we agreed to drop support.
Any existing database using this encoding would need to be dumped and
restored with a new encoding to upgrade to PostgreSQL 19, most likely
UTF8, since pg_upgrade would fail.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Discussion: https://postgr.es/m/CA%2BhUKGKXDXh-FdU0orjfv%2BF08f%3DD91BhV3Ra-4zL-q%2BJmGYqTA%40mail.gmail.com M doc/src/sgml/charset.sgml
M src/backend/utils/mb/conv.c
M src/backend/utils/mb/conversion_procs/Makefile
R057 src/backend/utils/mb/conversion_procs/latin_and_mic/Makefile src/backend/utils/mb/conversion_procs/cyrillic/Makefile
R080 src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c src/backend/utils/mb/conversion_procs/cyrillic/cyrillic.c
D src/backend/utils/mb/conversion_procs/cyrillic_and_mic/Makefile
D src/backend/utils/mb/conversion_procs/euc_cn_and_mic/Makefile
D src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c
M src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
D src/backend/utils/mb/conversion_procs/euc_kr_and_mic/Makefile
D src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c
M src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
M src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
M src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
D src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c
M src/backend/utils/mb/conversion_procs/meson.build
M src/backend/utils/mb/mbutils.c
M src/common/encnames.c
M src/common/wchar.c
M src/include/catalog/pg_conversion.dat
M src/include/catalog/pg_proc.dat
M src/include/mb/pg_wchar.h
M src/pl/plpython/plpy_util.c
D src/test/mb/expected/mule_internal.out
M src/test/mb/mbregress.sh
D src/test/mb/sql/mule_internal.sql
M src/test/modules/test_escape/test_escape.c
M src/test/regress/expected/conversion.out
M src/test/regress/expected/encoding.out
M src/test/regress/expected/object_address.out
M src/test/regress/expected/xml.out
M src/test/regress/expected/xml_1.out
M src/test/regress/expected/xml_2.out
M src/test/regress/regress.c
M src/test/regress/sql/conversion.sql
M src/test/regress/sql/encoding.sql
M src/test/regress/sql/object_address.sql
M src/test/regress/sql/xml.sql
instrumentation: Allocate query level instrumentation in ExecutorStart
commit : 2c16deee2f7d52d6567dcbad046f74a8e880ee52
author : Andres Freund <andres@anarazel.de>
date : Wed, 8 Apr 2026 00:02:26 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 8 Apr 2026 00:02:26 -0400 Until now extensions that wanted to measure overall query execution could
create QueryDesc->totaltime, which the core executor would then start and
stop. That's a bit odd and composes badly, e.g. extensions always had to use
INSTRUMENT_ALL, because otherwise another extension might not get what they
need.
Instead this introduces a new field, QueryDesc->query_instr_options, that
extensions can use to indicate whether they need query level instrumentation
populated, and with which instrumentation options. Extensions should take care
to only add options they need, instead of replacing the options of others.
The prior name of the field, totaltime, sounded like it would only measure
time, but these days the instrumentation infrastructure can track more
resources. The secondary benefit is that this will make it obvious to
extensions that they may not create the Instrumentation struct themselves
anymore (often extensions build only against a postgres build without
assertions).
Adjust pg_stat_statements and auto_explain to match, and lower the
requested instrumentation level for auto_explain to INSTRUMENT_TIMER,
since the summary instrumentation it needs is only runtime.
The reason to push this now, rather in the PG 20 cycle, is that 5a79e78501f
already required extensions using query level instrumentations to adjust their
code, and it seemed undesirable to require them to do so again for 20.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53Pkyqsht+exJQYRsjhSWYKu+vFGHhPub7m6PmFD6Or0=p1g@mail.gmail.com M contrib/auto_explain/auto_explain.c
M contrib/pg_stat_statements/pg_stat_statements.c
M src/backend/executor/execMain.c
M src/backend/tcop/pquery.c
M src/include/executor/execdesc.h
Fix slotsync worker blocking promotion when stuck in wait
commit : db93032a7cbd30199429167e649e22fab89327ed
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 8 Apr 2026 11:22:21 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 8 Apr 2026 11:22:21 +0900 Previously, on standby promotion, the startup process sent SIGUSR1 to
the slotsync worker (or a backend performing slot synchronization) and
waited for it to exit. This worked in most cases, but if the process was
blocked waiting for a response from the primary (e.g., due to a network
failure), SIGUSR1 would not interrupt the wait. As a result, the process
could remain stuck, causing the startup process to wait for a long time
and delaying promotion.
This commit fixes the issue by introducing a new procsignal reason,
PROCSIG_SLOTSYNC_MESSAGE. On promotion, the startup process
sends this signal, and the handler sets interrupt flags so the process
exits (or errors out) promptly at CHECK_FOR_INTERRUPTS(), allowing
promotion to complete without delay.
Backpatch to v17, where slotsync was introduced.
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: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwFzNYroAxSoyJhqTU-pH=t4Ej6RyvhVmBZ91Exj_TPMMQ@mail.gmail.com
Backpatch-through: 17 M src/backend/replication/logical/slotsync.c
M src/backend/storage/ipc/procsignal.c
M src/backend/tcop/postgres.c
M src/include/replication/slotsync.h
M src/include/storage/procsignal.h
instrumentation: Move ExecProcNodeInstr to allow inlining
commit : 544000288ec8f7dc6a1e0285821adc47324ecd33
author : Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 21:36:07 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 21:36:07 -0400 This moves the implementation of ExecProcNodeInstr, the ExecProcNode variant
that gets used when instrumentation is on, to be defined in instrument.c
instead of execProcNode.c, and marks functions it uses as inline.
This allows compilers to generate an optimized implementation, and shows a 4
to 12% reduction in instrumentation overhead for queries that move lots of
rows.
Author: Lukas Fittl <lukas@fittl.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53PkzdBK8VJ1fS4AZ481LgMN8f9mJiC39ZRHqkFUSYq6KWmg@mail.gmail.com M src/backend/executor/execProcnode.c
M src/backend/executor/instrument.c
M src/include/executor/executor.h
Add EXPLAIN (IO) instrumentation for TidRangeScan
commit : e157fe6f76e0be4f05a725b3099cf53949a2c2af
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 23:25:01 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 23:25:01 +0200 Adds support for EXPLAIN (IO) instrumentation for TidRange scans. This
requires adding shared instrumentation for parallel scans, using the
separate DSM approach introduced by dd78e69cfc33.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/backend/commands/explain.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeTidrangescan.c
M src/include/executor/instrument_node.h
M src/include/executor/nodeTidrangescan.h
M src/include/nodes/execnodes.h
M src/tools/pgindent/typedefs.list
pg_test_timing: Also test RDTSC[P] timing, report time source, TSC frequency
commit : 16fca482548382c8d6255319b1c6e5de4afff7f1
author : Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 17:08:32 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 17:08:32 -0400 This adds support to pg_test_timing for the different timing sources added by
294520c4448.
Author: Lukas Fittl <lukas@fittl.com>
Author: David Geier <geidav.pg@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> (in an earlier version)
Discussion: https://www.postgresql.org/message-id/flat/20200612232810.f46nbqkdhbutzqdg%40alap3.anarazel.de M doc/src/sgml/config.sgml
M doc/src/sgml/ref/pgtesttiming.sgml
M src/bin/pg_test_timing/pg_test_timing.c
M src/include/portability/instr_time.h
Add EXPLAIN (IO) instrumentation for SeqScan
commit : 3b1117d6e2e47d86cdbd978b79434c630cb0ef52
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 23:06:43 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 23:06:43 +0200 Adds support for EXPLAIN (IO) instrumentation for sequential scans. This
requires adding shared instrumentation, using the separate DSM approach
introduced by dd78e69cfc33.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/backend/commands/explain.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeSeqscan.c
M src/include/executor/instrument_node.h
M src/include/executor/nodeSeqscan.h
M src/include/nodes/execnodes.h
M src/test/regress/expected/explain.out
M src/test/regress/sql/explain.sql
M src/tools/pgindent/typedefs.list
Suppress unused-variable warning.
commit : b268928f932cdfb899e96ab28badfe716298483e
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 7 Apr 2026 17:03:20 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 7 Apr 2026 17:03:20 -0400 x86 machines lacking HAVE__CPUIDEX saw a complaint about
"unused variable 'reg'", per buildfarm as well as local
experience. Oversight in bcb2cf41f. M src/port/pg_cpu_x86.c
auto_explain: Add new GUC auto_explain.log_io
commit : 61c36a34a4196bfe1ce80b376e5979020bc571b2
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 22:49:42 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 22:49:42 +0200 Allows enabling the new EXPLAIN "IO" option for auto_explain.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M contrib/auto_explain/auto_explain.c
M doc/src/sgml/auto-explain.sgml
Add EXPLAIN (IO) infrastructure with BitmapHeapScan support
commit : 681daed93169ff5bed2796dd5c8c76ee2fae1ebd
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 22:33:32 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 22:33:32 +0200 Allows collecting details about AIO / prefetch for scan nodes backed by
a ReadStream. This may be enabled by a new "IO" option in EXPLAIN, and
it shows information about the prefetch distance and I/O requests.
As of this commit this applies only to BitmapHeapScan, because that's
the only scan node using a ReadStream and collecting instrumentation
from workers in a parallel query. Support for SeqScan and TidRangeScan,
the other scan nodes using ReadStream, will be added in subsequent
commits.
The stats are collected only when required by EXPLAIN ANALYZE, with the
IO option (disabled by default). The amount of collected statistics is
very limited, but we don't want to clutter EXPLAIN with too much data.
The IOStats struct is stored in the scan descriptor as a field, next to
other fields used by table AMs. A pointer to the field is passed to the
ReadStream, and updated directly.
It's the responsibility of the table AM to allocate the struct (e.g. in
ambeginscan) whenever the flag SO_SCAN_INSTRUMENT flag is passed to the
scan, so that the executor and ReadStream has access to it.
The collected stats are designed for ReadStream, but are meant to be
reasonably generic in case a TAM manages I/Os in different ways.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M doc/src/sgml/ref/explain.sgml
M src/backend/access/heap/heapam.c
M src/backend/commands/explain.c
M src/backend/commands/explain_state.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/storage/aio/read_stream.c
M src/include/access/relscan.h
M src/include/access/tableam.h
M src/include/commands/explain_state.h
M src/include/executor/instrument.h
M src/include/executor/instrument_node.h
M src/include/storage/read_stream.h
M src/tools/pgindent/typedefs.list
Switch EXPLAIN to unaligned output for json/xml/yaml
commit : 10d5a12a93150deb15f600492bbd4e46a2212b3b
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 22:12:26 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 22:12:26 +0200 Use unaligned output for multiple EXPLAIN queries using non-text format
in regression tests. With aligned output adding/removing explain fields
can be very disruptive, as it often modifies the whole block because of
padding. Unaligned output does not have this issue.
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/test/regress/expected/explain.out
M src/test/regress/sql/explain.sql
Fix WITHOUT OVERLAPS' interaction with domains.
commit : 4edd6036d69ce42ac1af236f659f20daed65c8d4
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 7 Apr 2026 14:45:33 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 7 Apr 2026 14:45:33 -0400 UNIQUE/PRIMARY KEY ... WITHOUT OVERLAPS requires the no-overlap
column to be a range or multirange, but it should allow a domain
over such a type too. This requires minor adjustments in both
the parser and executor.
In passing, fix a nearby break-instead-of-continue thinko in
transformIndexConstraint. This had the effect of disabling
parse-time validation of the no-overlap column's type in the context
of ALTER TABLE ADD CONSTRAINT, if it follows a dropped column.
We'd still complain appropriately at runtime though.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CACJufxGoAmN_0iJ=hjTG0vGpOSOyy-vYyfE+-q0AWxrq2_p5XQ@mail.gmail.com
Backpatch-through: 18 M src/backend/executor/execIndexing.c
M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/without_overlaps.out
M src/test/regress/sql/without_overlaps.sql
instrumentation: Use Time-Stamp Counter on x86-64 to lower overhead
commit : 294520c44487ecaade7a6ea8781b973f9ed03909
author : Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 12:48:07 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 12:48:07 -0400 This allows the direct use of the Time-Stamp Counter (TSC) value retrieved
from the CPU using RDTSC/RDTSCP instructions, instead of APIs like
clock_gettime() on POSIX systems.
This reduces the overhead of EXPLAIN with ANALYZE and TIMING ON. Tests showed
that the overhead on top of actual runtime when instrumenting queries moving
lots of rows through the plan can be reduced from 2x as slow to 1.2x as slow
compared to the actual runtime. More complex workloads such as TPCH queries
have also shown ~20% gains when instrumented compared to before.
To control use of the TSC, the new "timing_clock_source" GUC is introduced,
whose default ("auto") automatically uses the TSC when reliable, for example
when running on modern Intel CPUs, or when running on Linux and the system
clocksource is reported as "tsc". The use of the operating system clock source
can be enforced by setting "system", or on x86-64 architectures the use of TSC
can be enforced by explicitly setting "tsc".
In order to use the TSC the frequency is first determined by use of CPUID, and
if not available, by running a short calibration loop at program start,
falling back to the system clock source if TSC values are not stable.
Note, that we split TSC usage into the RDTSC CPU instruction which does not
wait for out-of-order execution (faster, less precise) and the RDTSCP
instruction, which waits for outstanding instructions to retire. RDTSCP is
deemed to have little benefit in the typical InstrStartNode() /
InstrStopNode() use case of EXPLAIN, and can be up to twice as slow. To
separate these use cases, the new macro INSTR_TIME_SET_CURRENT_FAST() is
introduced, which uses RDTSC.
The original macro INSTR_TIME_SET_CURRENT() uses RDTSCP and is supposed to be
used when precision is more important than performance. When the system timing
clock source is used both of these macros instead utilize the system
APIs (clock_gettime / QueryPerformanceCounter) like before.
Additional users of interval timing, such as track_io_timing and
track_wal_io_timing could also benefit from being converted to use
INSTR_TIME_SET_CURRENT_FAST() but are left for future changes.
Author: Lukas Fittl <lukas@fittl.com>
Author: Andres Freund <andres@anarazel.de>
Author: David Geier <geidav.pg@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com> (in an earlier version)
Reviewed-by: Maciek Sakrejda <m.sakrejda@gmail.com> (in an earlier version)
Reviewed-by: Robert Haas <robertmhaas@gmail.com> (in an earlier version)
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com> (in an earlier version)
Discussion: https://postgr.es/m/20200612232810.f46nbqkdhbutzqdg@alap3.anarazel.de M doc/src/sgml/config.sgml
M src/backend/executor/instrument.c
M src/backend/postmaster/launch_backend.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/common/instr_time.c
M src/include/portability/instr_time.h
M src/include/utils/guc_hooks.h
M src/include/utils/guc_tables.h
M src/tools/pgindent/typedefs.list
Allow retrieving x86 TSC frequency/flags from CPUID
commit : bcb2cf41f964e9ed4d27abe4dee8daa249f659bb
author : Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 12:48:07 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 12:48:07 -0400 This adds additional x86 specific CPUID checks for flags needed for
determining whether the Time-Stamp Counter (TSC) is usable on a given system,
as well as a helper function to retrieve the TSC frequency from CPUID.
This is intended for a future patch that will utilize the TSC to lower the
overhead of timing instrumentation.
In passing, always make pg_cpuid_subleaf reset the variables used for its
result, to avoid accidentally using stale results if __get_cpuid_count errors
out and the caller doesn't check for it.
Author: Lukas Fittl <lukas@fittl.com>
Author: David Geier <geidav.pg@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: John Naylor <john.naylor@postgresql.org>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com> (in an earlier version)
Discussion: https://www.postgresql.org/message-id/flat/20200612232810.f46nbqkdhbutzqdg%40alap3.anarazel.de M src/include/port/pg_cpu.h
M src/port/pg_cpu_x86.c
instrumentation: Standardize ticks to nanosecond conversion method
commit : 0022622c93d9e6419cb47110c58af87a74994ea6
author : Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 12:48:07 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 12:48:07 -0400 The timing infrastructure (INSTR_* macros) measures time elapsed using
clock_gettime() on POSIX systems, which returns the time as nanoseconds,
and QueryPerformanceCounter() on Windows, which is a specialized timing
clock source that returns a tick counter that needs to be converted to
nanoseconds using the result of QueryPerformanceFrequency().
This conversion currently happens ad-hoc on Windows, e.g. when calling
INSTR_TIME_GET_NANOSEC, which calls QueryPerformanceFrequency() on every
invocation, despite the frequency being stable after program start,
incurring unnecessary overhead. It also causes a fractured implementation
where macros are defined differently between platforms.
To ease code readability, and prepare for a future change that intends
to use a ticks-to-nanosecond conversion on x86-64 for TSC use, introduce
new pg_ticks_to_ns() / pg_ns_to_ticks() functions that get called from
INSTR_* macros on all platforms.
These functions rely on a separately initialized ticks_per_ns_scaled
value, that represents the conversion ratio. This value is initialized
from QueryPerformanceFrequency() on Windows, and set to zero on x86-64
POSIX systems, which results in the ticks being treated as nanoseconds.
Other architectures always directly return the original ticks.
To support this, pg_initialize_timing() is introduced, and is now
mandatory for both the backend and any frontend programs to call before
utilizing INSTR_* macros.
In passing, fix variable names in comment documenting INSTR_TIME_ADD_NANOSEC().
Author: Lukas Fittl <lukas@fittl.com>
Author: David Geier <geidav.pg@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://www.postgresql.org/message-id/flat/20200612232810.f46nbqkdhbutzqdg%40alap3.anarazel.de M src/backend/postmaster/postmaster.c
M src/bin/pg_test_timing/pg_test_timing.c
M src/bin/pgbench/pgbench.c
M src/bin/psql/startup.c
M src/common/Makefile
A src/common/instr_time.c
M src/common/meson.build
M src/include/portability/instr_time.h
M src/test/regress/expected/misc_functions.out
M src/test/regress/pg_regress.c
M src/test/regress/regress.c
M src/test/regress/sql/misc_functions.sql
oauth: Allow validators to register custom HBA options
commit : b977bd308a09e8a70db1776db80e8abd84ca2b7e
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 7 Apr 2026 08:15:19 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 7 Apr 2026 08:15:19 -0700 OAuth validators can already use custom GUCs to configure behavior
globally. But we currently provide no ability to adjust settings for
individual HBA entries, because the original design focused on a world
where a provider covered a "single audience" of users for one database
cluster. This assumption does not apply to multitenant use cases, where
a single validator may be controlling access for wildly different user
groups.
To improve this use case, add two new API calls for use by validator
callbacks: RegisterOAuthHBAOptions() and GetOAuthHBAOption().
Registering options "foo" and "bar" allows a user to set "validator.foo"
and "validator.bar" in an oauth HBA entry. These options are stringly
typed (syntax validation is solely the responsibility of the defining
module), and names are restricted to a subset of ASCII to avoid tying
our hands with future HBA syntax improvements.
Unfortunately, we can't check the custom option names during a reload of
the configuration, like we do with standard HBA options, without
requiring all validators to be loaded via shared_preload_libraries.
(I consider this to be a nonstarter: most validators should probably use
session_preload_libraries at most, since requiring a full restart just
to update authentication behavior will be unacceptable to many users.)
Instead, the new validator.* options are checked against the registered
list at connection time.
Multiple alternatives were proposed and/or prototyped, including
extending the GUC system to allow per-HBA overrides, joining forces with
recent refactoring work on the reloptions subsystem, and giving the
ability to customize HBA options to all PostgreSQL extensions. I
personally believe per-HBA GUC overrides are the best option, because
several existing GUCs like authentication_timeout and pre_auth_delay
would fit there usefully. But the recent addition of SNI per-host
settings in 4f433025f indicates that a more general solution is needed,
and I expect that to take multiple releases' worth of discussion.
This compromise patch, then, is intentionally designed to be an
architectural dead end: simple to describe, cheap to maintain, and
providing just enough functionality to let validators move forward for
PG19. The hope is that it will be replaced in the future by a solution
that can handle per-host, per-HBA, and other per-context configuration
with the same functionality that GUCs provide today. In the meantime,
the bulk of the code in this patch consists of strict guardrails on the
simple API, to try to ensure that we don't have any reason to regret its
existence during its unknown lifespan.
I owe particular thanks here to Zsolt Parragi, who prototyped several
approaches that guided the final design.
Suggested-by: Zsolt Parragi <zsolt.parragi@percona.com>
Suggested-by: VASUKI M <vasukianand0119@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAN4CZFM3b8u5uNNNsY6XCya257u%2BDofms3su9f11iMCxvCacag%40mail.gmail.com M doc/src/sgml/client-auth.sgml
M doc/src/sgml/oauth-validators.sgml
M src/backend/libpq/auth-oauth.c
M src/backend/libpq/hba.c
M src/include/libpq/hba.h
M src/include/libpq/oauth.h
M src/test/modules/oauth_validator/t/001_server.pl
M src/test/modules/oauth_validator/validator.c
libpq: Split PGOAUTHDEBUG=UNSAFE into multiple options
commit : 6d00fb9048fe61381c9f4d542cfd2bc767d95a3b
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 7 Apr 2026 08:15:14 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 7 Apr 2026 08:15:14 -0700 PGOAUTHDEBUG is a blunt instrument: you get all the debugging features,
or none of them. The most annoying consequence during manual use is the
Curl debug trace, which tends to obscure the device flow prompt
entirely. The promotion of PGOAUTHCAFILE into its own feature in
993368113 improved the situation somewhat, but there's still the
discomfort of knowing you have to opt into many dangerous behaviors just
to get the single debug feature you wanted.
Explode the PGOAUTHDEBUG syntax into a comma-separated list. The old
"UNSAFE" value enables everything, like before. Any individual unsafe
features still require the envvar to begin with an "UNSAFE:" prefix, to
try to interrupt the flow of someone who is about to do something they
should not.
So now, rather than
PGOAUTHDEBUG=UNSAFE # enable all the unsafe things
a developer can say
PGOAUTHDEBUG=call-count # only show me the call count. safe!
PGOAUTHDEBUG=UNSAFE:trace # print secrets, but don't allow HTTP
To avoid adding more build system scaffolding to libpq-oauth, implement
this entirely in a small private header. This unfortunately can't be
standalone, so it needs a headerscheck exception.
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Co-authored-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2B%3DfbZNJSkHVci%3DGpR8XPYObK%3DH%2B2ERRha0LDTS%2BifsWnw%40mail.gmail.com
Discussion: https://postgr.es/m/CAN4CZFMmDZMH56O9vb_g7vHqAk8ryWFxBMV19C39PFghENg8kA%40mail.gmail.com M doc/src/sgml/libpq.sgml
M src/interfaces/libpq-oauth/oauth-curl.c
M src/interfaces/libpq-oauth/oauth-utils.c
M src/interfaces/libpq-oauth/oauth-utils.h
M src/interfaces/libpq-oauth/test-oauth-curl.c
M src/interfaces/libpq/fe-auth-oauth.c
M src/interfaces/libpq/fe-auth-oauth.h
A src/interfaces/libpq/oauth-debug.h
M src/test/modules/oauth_validator/t/001_server.pl
M src/tools/pginclude/headerscheck
Reserve replication slots specifically for REPACK
commit : e76d8c749c3152657711ed733f0aea61c0e36a91
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 16:55:29 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 16:55:29 +0200 Add a new GUC max_repack_replication_slots, which lets the user reserve
some additional replication slots for concurrent repack (and only
concurrent repack). With this, the user doesn't have to worry about
changing the max_replication_slots in order to cater for use of
concurrent repack.
(We still use the same pool of bgworkers though, but that's less
commonly a problem than slots.)
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Discussion: https://postgr.es/m/202604012148.nnnmyxxrr6nh@alvherre.pgsql M doc/src/sgml/config.sgml
M doc/src/sgml/ref/repack.sgml
M src/backend/commands/repack_worker.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/logical.c
M src/backend/replication/logical/logicalfuncs.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/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/include/replication/logical.h
M src/include/replication/slot.h
Fix harmless leftover in _hash_kill_items()
commit : 979387f1885111c72b84af535f23de4e3e913206
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 17:38:11 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 17:38:11 +0300 Checking for 'havePin' is sufficient here. An earlier version of the
patch didn't have the 'havePin' variable and used
'so->hashso_bucket_buf == so->currPos.buf' as the condition when both
locking and unlocking the page. The havePin variable was added later
during development, but the unlocking condition wasn't fully
updated. Tidy it up.
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/b9de8d05-3b02-4a27-9b0b-03972fa4bfd3@iki.fi M src/backend/access/hash/hashutil.c
Add errdetail() with PID and UID about source of termination signal.
commit : 55890a919454a2165031a04b175ca92e3ed70e69
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 6 Apr 2026 12:39:14 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 6 Apr 2026 12:39:14 -0400 When a backend is terminated via pg_terminate_backend() or an external
SIGTERM, the error message now includes the sender's PID and UID as
errdetail, making it easier to identify the source of unexpected
terminations in multi-user environments.
On platforms that support SA_SIGINFO (Linux, FreeBSD, and most modern
Unix systems), the signal handler captures si_pid and si_uid from the
siginfo_t structure. On platforms without SA_SIGINFO, the detail is
simply omitted.
Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Chao Li <1356863904@qq.com>
Discussion: https://postgr.es/m/CAKZiRmyrOWovZSdixpLd3PGMQXuQL_zw2Ght5XhHCkQ1uDsxjw@mail.gmail.com M configure
M configure.ac
M meson.build
M src/backend/replication/syncrep.c
M src/backend/tcop/postgres.c
M src/backend/utils/init/globals.c
M src/bin/psql/t/001_basic.pl
M src/include/miscadmin.h
M src/include/pg_config.h.in
M src/port/pqsignal.c
pg_stash_advice: Allow stashed advice to be persisted to disk.
commit : c10edb102ada607eb054bc9e23690109d86849ef
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 7 Apr 2026 10:11:25 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 7 Apr 2026 10:11:25 -0400 If pg_stash_advice.persist = true, stashed advice will be written to
pg_stash_advice.tsv in the data directory, periodically and at
shutdown. On restart, stash modifications are locked out until this
file has been reloaded, but queries will not be, so there may be a
short window after startup during which previously-stashed advice is
not automatically applied.
Author: Robert Haas <rhaas@postgresql.org>
Co-authored-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/CA+Tgmob87qsWa-VugofU6epuV0H5XjWZGMbQas4Q-ADKmvSyBg@mail.gmail.com M contrib/pg_stash_advice/Makefile
M contrib/pg_stash_advice/meson.build
M contrib/pg_stash_advice/pg_stash_advice–1.0.sql
M contrib/pg_stash_advice/pg_stash_advice.c
M contrib/pg_stash_advice/pg_stash_advice.h
M contrib/pg_stash_advice/stashfuncs.c
A contrib/pg_stash_advice/stashpersist.c
A contrib/pg_stash_advice/t/001_persist.pl
M doc/src/sgml/pgstashadvice.sgml
M src/tools/pgindent/typedefs.list
Minimal fix for WAIT FOR ... MODE 'standby_flush'
commit : 29e7dbf5e4daa8fafc2b18a1551e7b31c8847340
author : Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 09:11:07 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 7 Apr 2026 09:11:07 -0400 The investigation into the negative test performance impact of 7e8aeb9e483
lead to discovering that there are a few issues with WAIT FOR.
This commit is just a minimal fix to prevent hangs in standby_flush mode, due
to WAIT FOR ... 'standby_flush' seeing a 0 LSN if a newly started walreceiver
does not receive any writes, because the stanby is already caught up.
There are several other issues and this is isn't necessarily the best fix. But
this way we get the hangs out of the way.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/zqbppucpmkeqecfy4s5kscnru4tbk6khp3ozqz6ad2zijz354k@w4bdf4z3wqoz M src/backend/replication/walreceiver.c
M src/backend/replication/walreceiverfuncs.c
doc: Add an example of REPACK (CONCURRENTLY)
commit : 8fb95a8ab6e511c049066a03fe9b81fe83ff937b
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 15:33:55 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 15:33:55 +0200 Suggested-by: vignesh C <vignesh21@gmail.com>
Discussion: https://postgr.es/m/CALDaNm3tiKhtegx5Cawi34UjbHmNGEDNAtScGM1RgWRtV-5_0Q@mail.gmail.com M doc/src/sgml/ref/repack.sgml
Tidy up #ifdef USE_INJECTION_POINTS guards
commit : 9480c585df6cdb33c542c4a2cac26a341a54afd4
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 16:18:31 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 16:18:31 +0300 Remove unnecessary #ifdef guard around the function prototypes; they
are already inside a larger #ifdef block. Move #include "subsystems.h"
inside the USE_INJECTION_POINTS guard; it's needed for
InjectionPointShmemCallbacks, which is a also inside the guard.
Reported-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://www.postgresql.org/message-id/87y0iz2c1v.fsf@wibble.ilmari.org M src/backend/utils/misc/injection_point.c
Fix tests under wal_level=minimal
commit : be142fa008ade51bb579a5990b43d55bab743194
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 15:14:32 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 15:14:32 +0200 Buildfarm members which have specifically configured to use
wal_level=minimal fail the repack regression tests, which require
wal_level=replica. Add a temp config file to fix that. M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/extra.conf
M src/test/modules/injection_points/meson.build
Modernize and optimize pg_buffercache_pages()
commit : 257c8231bf97a77378f6fedb826b1243f0a41612
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 16:04:48 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 16:04:48 +0300 Refactor pg_buffercache_pages() to use SFRM_Materialize mode and
construct a tuplestore directly. That's simpler and more efficient
than collecting all the data to a custom array first.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Author: Palak Chaturvedi <chaturvedipalak1911@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5sMsaz1j+hrdhyo-DJp7JCgJx87=q2iJfOc_9mwYWyvmw@mail.gmail.com M contrib/pg_buffercache/pg_buffercache_pages.c
Optimize sorting and deduplicating trigrams
commit : 9f3755ea07aa8858999bdac3d33151e93d2643e2
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 14:11:25 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 14:11:25 +0300 Use templated qsort() so that the comparison function can be
inlined. To speed up qunique(), use a specialized comparison function
that only checks for equality.
Author: David Geier <geidav.pg@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://www.postgresql.org/message-id/2a76b5ef-4b12-4023-93a1-eed6e64968f3@gmail.com M contrib/pg_trgm/trgm_op.c
Use add_size/mul_size for index instrumentation size calculations
commit : 884f9b3c762f987ed6073303b597c110a4102fb7
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 12:47:26 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 12:47:26 +0200 Use overflow-safe size arithmetic in the Index[Only]Scan and parallel
instrumentation functions, consistent with other executor nodes (Hash,
Sort, Agg, Memoize). This was an oversight in dd78e69cfc3.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
Fix BitmapHeapScan non-parallel-aware EXPLAIN ANALYZE
commit : 9c18b47e61071cf1395620f182b07a7ab9aac263
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 12:47:04 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Tue, 7 Apr 2026 12:47:04 +0200 Allocates shared bitmap table scan instrumentation for all parallel
scans. Previously, the instrumentation was only allocated for
parallel-aware scans, other bitmap heap scans in the parallel query had
no shared instrumentation and EXPLAIN didn't report exact/lossy pages.
This affected cases like scans on the outside of a parallel join or
queries run with debug_parallel_query=regress.
Fixed by allocating a separate DSM chunk for shared instrumentation and
doing so regardless of parallel-awareness. The instrumentation is
allocated in its own DSM chunk, separate from ParallelBitmapHeapState.
Report an initial patch by me. The approach with a separate DSM was
proposed and implemented by Melanie.
Not backpatched. The issue affects Postgres 18 (since 5a1e6df3b84c), but
having multiple DSM chunks is possible only since dd78e69cfc33. If we
decide to fix this in backbranches too, it will need to be done in a
less invasive way.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/backend/commands/explain.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/include/executor/nodeBitmapHeapscan.h
Allow logical replication snapshots to be database-specific
commit : 0d3dba38c777384a9dd7dffe924355c9683a6b71
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 12:31:18 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 12:31:18 +0200 By default, the logical decoding assumes access to shared catalogs, so
the snapshot builder needs to consider cluster-wide XIDs during startup.
That in turn means that, if any transaction is already running (and has
XID assigned), the snapshot builder needs to wait for its completion, as
it does not know if that transaction performed catalog changes earlier.
A possible problem with this concept is that if REPACK (CONCURRENTLY) is
running in some database, backends running the same command in other
databases get stuck until the first one has committed. Thus only a
single backend in the cluster can run REPACK (CONCURRENTLY) at any time.
Likewise, REPACK (CONCURRENTLY) can block walsenders starting on behalf
of subscriptions throughout the cluster.
This patch adds a new option to logical replication output plugin, to
declare that it does not use shared catalogs (i.e. catalogs that can be
changed by transactions running in other databases in the cluster). In
that case, no snapshot the backend will use during the decoding needs to
contain information about transactions running in other databases. Thus
the snapshot builder only needs to wait for completion of transactions
in the current database.
Currently we only use this option in the REPACK background worker. It
could possibly be used in the plugin for logical replication too,
however that would need thorough analysis of that plugin.
Bump WAL version number, due to a new field in xl_running_xacts.
Author: Antonin Houska <ah@cybertec.at>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/90475.1775218118@localhost M contrib/pg_visibility/pg_visibility.c
M doc/src/sgml/logicaldecoding.sgml
M src/backend/access/index/genam.c
M src/backend/access/rmgrdesc/standbydesc.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogfuncs.c
M src/backend/postmaster/bgwriter.c
M src/backend/replication/logical/decode.c
M src/backend/replication/logical/logical.c
M src/backend/replication/logical/snapbuild.c
M src/backend/replication/pgrepack/pgrepack.c
M src/backend/replication/slot.c
M src/backend/storage/ipc/procarray.c
M src/backend/storage/ipc/standby.c
M src/include/access/xlog_internal.h
M src/include/miscadmin.h
M src/include/replication/output_plugin.h
M src/include/replication/snapbuild.h
M src/include/storage/procarray.h
M src/include/storage/standby.h
M src/include/storage/standbydefs.h
Avoid different-size pointer-to-integer cast
commit : a3b069ef90bd3a7278920b4ea5255e019f202d5d
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 12:28:05 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 12:28:05 +0200 Buildfarm member mamba is unhappy that I wrote "(Datum) NULL" in commit
28d534e2ae0a:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=mamba&dt=2026-04-07%2005%3A08%3A08
Use "(Datum) 0" which is what we do everywhere else.
Discussion: https://postgr.es/m/CANWCAZaOs_+WPH13ow33Q==+FwBwVZkqzm4vND=WEB4_NBmv1Q@mail.gmail.com M src/backend/commands/repack.c
Optimize sort and deduplication in ginExtractEntries()
commit : 6f5ad00ab763f9e029ec591f7f650bd09c1e933f
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 13:26:39 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 7 Apr 2026 13:26:39 +0300 Remove NULLs from the array first, and use qsort to deduplicate only
the non-NULL items. This simplifies the comparison function. Also
replace qsort_arg() with a templated version so that the comparison
function can be inlined. These changes make ginExtractEntries() a
little faster especially for simple datatypes like integers.
Author: David Geier <geidav.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/6d16b6bd-a1ff-4469-aefb-a1c8274e561a@iki.fi M src/backend/access/gin/ginutil.c
M src/include/access/gin_private.h
Add isolation tests for UPDATE/DELETE FOR PORTION OF
commit : b6ccd30d8ff6422ad0f79ce2fc801f2437d90664
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 7 Apr 2026 11:07:59 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 7 Apr 2026 11:07:59 +0200 Add documentation about concurrency issues related to UPDATE/DELETE
FOR PORTION OF as well as supporting isolation tests.
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/ec498c3d-5f2b-48ec-b989-5561c8aa2024%40illuminatedcomputing.com M doc/src/sgml/dml.sgml
M doc/src/sgml/images/Makefile
M doc/src/sgml/images/meson.build
A doc/src/sgml/images/temporal-isolation.svg
A doc/src/sgml/images/temporal-isolation.txt
M src/backend/executor/nodeModifyTable.c
A src/test/isolation/expected/for-portion-of.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/for-portion-of.spec
Fix valgrind failure
commit : 5bcc3fbd196ccbec55c2ce6b58d6946f06cf6213
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 11:13:16 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 7 Apr 2026 11:13:16 +0200 Buildfarm member skink reports that the new REPACK code is trying to
write uninitialized bytes to disk, which correspond to padding space in
the SerializedSnapshotData struct. Silence that by initializing the
memory in SerializeSnapshot() to all zeroes.
Co-authored-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Co-authored-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/1976915.1775537087@sss.pgh.pa.us M src/backend/commands/repack_worker.c
M src/backend/utils/time/snapmgr.c
Use .h for the file containing the page checksum code fragment
commit : 8c3e22a8f8b9af94b519b6e223db0912d552093e
author : John Naylor <john.naylor@postgresql.org>
date : Tue, 7 Apr 2026 15:52:55 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Tue, 7 Apr 2026 15:52:55 +0700 Commit 5e13b0f24 used a .c file for a file containing a code fragment,
to avoid adding an exception to headerscheck. That turned out to be
too clever, since it meant installation didn't happen by the usual
mechanism. Make it look like a normal header and add the requisite
exception.
Bug: #19450
Reported-by: RekGRpth <rekgrpth@gmail.com>
Discussion: https://postgr.es/m/19450-bb0612c50c6786e5@postgresql.org M src/backend/storage/page/checksum.c
R088 src/include/storage/checksum_block.inc.c src/include/storage/checksum_block_internal.h
M src/include/storage/checksum_impl.h
M src/tools/pginclude/headerscheck
Simplify SortSupport for the macaddr data type
commit : 30229be755e703cf23fd73e95c5a515f9011cb5a
author : John Naylor <john.naylor@postgresql.org>
date : Tue, 7 Apr 2026 13:29:27 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Tue, 7 Apr 2026 13:29:27 +0700 As of commit 6aebedc38 Datums are 64-bit values. Since MAC addresses
have only 6 bytes, the abbreviated key always contains the entire
MAC address and is thus authoritative (for practical purposes -- the
tuple sort machinery has no way of knowing that). Abbreviating this
datatype is cheap, and aborting abbreviation prevents optimizations
like radix sort, so remove cardinality estimation.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Suggested-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CAJ7c6TMk10rF_LiMz6j9rRy1rqk-5s+wBPuBefLix4cY+-4s1w@mail.gmail.com M src/backend/utils/adt/mac.c
Mark JumbleState as a const in the post_parse_analyze hook
commit : 49cc0d41488b92a1d547e278b459c3b224393c8f
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 15:22:49 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 15:22:49 +0900 This commit changes the post_parse_analyze_hook_type() hook to take a
const JumbleState, to tell external modules that they are not allowed to
touch the JumbleState that has been compiled by the core code. This
fixes a pretty old problem with pg_stat_statements, that had always the
idea of modifying the lengths of the constants stored in the
JumbleState. The previous state could confuse extensions that need to
look at a JumbleState depending on the loading order, if
pg_stat_statements is part of the stack loaded.
Another piece included in this commit is the move of the routine
fill_in_constant_lengths() to queryjumblefuncs.c, to give an option to
extensions to compile the lengths of the constants, if necessary. I was
surprised by the number of external code that carries a copy of this
routine (see the thread for details). Previously, this routine modified
JumbleState. It now copies the set of LocationLens from JumbleState,
and fills the constant lengths for separate use.
pg_stat_statements is updated to use the new ComputeConstantLengths().
JumbleState is now marked with a const in the module, where relevant.
Author: Sami Imseih <samimseih@gmail.com>
Co-authored-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/CAA5RZ0tZp5qU0ikZEEqJnxvdSNGh1DWv80sb-k4QAUmiMoOp_Q@mail.gmail.com M contrib/pg_stat_statements/pg_stat_statements.c
M src/backend/nodes/queryjumblefuncs.c
M src/include/nodes/queryjumble.h
M src/include/parser/analyze.h
Split CREATE STATISTICS error reasons out into errdetails
commit : 51098839cfb40dc496bb48fe4ea14d19170099ac
author : John Naylor <john.naylor@postgresql.org>
date : Tue, 7 Apr 2026 11:37:48 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Tue, 7 Apr 2026 11:37:48 +0700 Some errmsgs in statscmds.c were phrased as "...cannot be used
because...". Put the reasons into errdetails. While at it, switch
from passive voice to "cannot create..." for the errmsg.
Author: Yugo Nagata <nagata@sraoss.co.jp>
Suggested-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CANWCAZaZeX0omWNh_ZbD_JVujzYQdRUW8UZOQ4dWh9Sg7OcAow@mail.gmail.com M src/backend/commands/statscmds.c
M src/test/regress/expected/stats_ext.out
Fix injection point detach timing problem in TAP test for lock stats
commit : 3284e3f63cf0b42a1c89bb547778754d72aac9e4
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 13:17:13 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 13:17:13 +0900 injection_points_detach() could fail because of a concurrent cleanup
triggered by injection_points_set_local() when a session finishes.
This problem could be reproduced by adding a hardcoded sleep in
InjectionPointDetach(), and has been detected by the CI.
As the test is designed so as the injection point is detached before
being awaken, there is no need for it to be local, similarly to test
010_index_concurrently_upsert. This commit removes
injection_points_set_local(), replacing it with a confirmation that the
point has been attached in the session expected to block on a lock.
With this removal, the detach cannot happen concurrently anymore, only
before when the point is woken up.
Issue introduced by 557a9f1e3e62, where the test has been added.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/rp6wz4lnz5qn4zlh7uxtavzfrmqvycy2g42z4zasfss2gxi54f@zzcsjdvdflwp M src/test/modules/test_misc/t/011_lock_stats.pl
Fix shmem allocation of fixed-sized custom stats kind
commit : 17132f55c5a2c04743edec20655cc7123ce08713
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 11:59:49 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 11:59:49 +0900 StatsShmemSize(), that computes the shmem size needed for pgstats,
includes the amount of shared memory wanted by all the custom stats
kinds registered. However, the shared memory allocation was done by
ShmemAlloc() in StatsShmemInit(), meaning that the space reserved was
not used, wasting some memory.
These extra allocations would show up under "<anonymous>" in
pg_shmem_allocations, as the allocations done by ShmemAlloc() are not
tracked by ShmemIndexEnt.
Issue introduced by 7949d9594582.
Author: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/04b04387-92f5-476c-90b0-4064e71c5f37@iki.fi
Backpatch-through: 18 M src/backend/utils/activity/pgstat_shmem.c
Fix deferred FK check batching introduced by commit b7b27eb41a5
commit : 5c54c3ed1b934a35a8e9eacff679699ccb3a5070
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 7 Apr 2026 08:36:49 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 7 Apr 2026 08:36:49 +0900 That commit introduced AfterTriggerIsActive() to detect whether
we are inside the after-trigger firing machinery, so that RI trigger
functions can take the batched fast path. It was implemented using
query_depth >= 0, which correctly identified immediate trigger firing
but missed the deferred case where query_depth is -1 at COMMIT via
AfterTriggerFireDeferred(). This caused deferred FK checks to fall
back to the per-row fast path instead of the batched path.
The correct check is whether we are inside an after-trigger firing
loop specifically. Introduce afterTriggerFiringDepth, a counter
incremented around the trigger-firing loops in AfterTriggerEndQuery,
AfterTriggerFireDeferred, and AfterTriggerSetState, and decremented
after FireAfterTriggerBatchCallbacks() returns. AfterTriggerIsActive()
now returns afterTriggerFiringDepth > 0.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Author: Chao Li <li.evan.chao@gmail.com>
Co-authored-by: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/C2133B47-79CD-40FF-B088-02D20D654806@gmail.com M src/backend/commands/trigger.c
Fix shared memory size of template code for custom fixed-sized pgstats
commit : 98979578055ffba3bd520adcec00881f72fc2861
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 08:24:32 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 7 Apr 2026 08:24:32 +0900 On HEAD, the template code for custom fixed-sized pgstats is in the test
module test_custom_stats. On REL_18_STABLE, this code lives in the test
module injection_points.
Both cases were underestimating the size of the shared memory area
required for the storage of the stats data, using a single entry rather
than the whole area. This underestimation meant that there was no
memory allocated for the LWLock required for the stats, and even more.
This problem would be also misleading for extension developers looking
at this code.
This issue has been noticed while digging into a different bug reported
by Heikki Linnakangas, showing that the underestimation was causing
failures in the TAP tests of the test modules for 32-bit builds. The
other issue reported, related to the memory allocation of custom
fixed-sized pgstats, will be fixed in a follow-up commit.
Discussion: https://postgr.es/m/adMk_lWbnz3HDOA8@paquier.xyz
Backpatch-through: 18 M src/test/modules/test_custom_stats/test_custom_fixed_stats.c
Allocate separate DSM chunk for parallel Index[Only]Scan instrumentation
commit : dd78e69cfc337f93cfc0303ddf660262d7f1237e
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 6 Apr 2026 19:10:19 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 6 Apr 2026 19:10:19 -0400 Previously, parallel index and index-only scans packed the parallel scan
descriptor and shared instrumentation (for EXPLAIN ANALYZE) into a
single DSM allocation. Since scans may be instrumented without being
parallel-aware, and vice versa, using separate DSM chunks -- each with
its own TOC key -- is cleaner. A future commit will extend this pattern
to other scan node types.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/backend/access/index/indexam.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeBitmapIndexscan.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/include/access/genam.h
M src/include/access/relscan.h
M src/include/executor/instrument_node.h
M src/include/executor/nodeIndexonlyscan.h
M src/include/executor/nodeIndexscan.h
Assert no duplicate keys in shm_toc_insert()
commit : 43222b8e53f49f2cf0849947a02c6fbd74899332
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 6 Apr 2026 18:41:17 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 6 Apr 2026 18:41:17 -0400 shm_toc_insert() silently accepts duplicate keys. Since shm_toc_lookup()
returns the first matching entry, any later entry with the same key
would be unreachable. Add an assertion to catch this.
Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/flat/a177a6dd-240b-455a-8f25-aca0b1c08c6e%40vondra.me M src/backend/storage/ipc/shm_toc.c
Add pg_stat_autovacuum_scores system view.
commit : 87f61f0c82806b7e4201f15bd77920e9e7108b11
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 6 Apr 2026 16:56:33 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 6 Apr 2026 16:56:33 -0500 This view contains one row for each table in the current database,
showing the current autovacuum scores for that specific table. It
also shows whether autovacuum would vacuum or analyze the table.
Bumps catversion.
Author: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Discussion: https://postgr.es/m/CAA5RZ0s4xjMrB-VAnLccC7kY8d0-4806-Lsac-czJsdA1LXtAw%40mail.gmail.com M doc/src/sgml/maintenance.sgml
M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/postmaster/autovacuum.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/rules.out
Use PG_DATA_CHECKSUM_OFF instead of hardcoded value
commit : b3a37ffbc5b94c0214f1f3f1953e800654a1962f
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 6 Apr 2026 22:11:53 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 6 Apr 2026 22:11:53 +0200 For a long time, the online checksums patchset kept the "off" state as
literal zero without a label to be consistent with the previous coding
which only had a label for the "on" state. Later, when an "off" label
was made not all uses in the code got the memo. Fix by setting these
to PG_DATA_CHECKSUM_OFF.
While there, fix a duplicate word in a comment introduced by the same
commit.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAJ7c6TPRTnQFXXX1CRcYoTLXw2swtDH==uSz1MYoMKdLrKZHjA@mail.gmail.com M src/backend/access/transam/xlog.c
M src/backend/bootstrap/bootstrap.c
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_upgrade/controldata.c
M src/bin/pg_upgrade/file.c
Add CONCURRENTLY option to REPACK
commit : 28d534e2ae0ac888b5460f977a10cd9bb017ef98
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 6 Apr 2026 21:55:08 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 6 Apr 2026 21:55:08 +0200 When this flag is specified, REPACK no longer acquires access-exclusive
lock while the new copy of the table is being created; instead, it
creates the initial copy under share-update-exclusive lock only (same as
vacuum, etc), and it follows an MVCC snapshot; it sets up a replication
slot starting at that snapshot, and uses a concurrent background worker
to do logical decoding starting at the snapshot to populate a stash of
concurrent data changes. Those changes can then be re-applied to the
new copy of the table just before swapping the relfilenodes.
Applications can continue to access the original copy of the table
normally until just before the swap, which is the only point at which
the access-exclusive lock is needed.
There are some loose ends in this commit:
1. concurrent repack needs its own replication slot in order to apply
logical decoding, which are a scarce resource and easy to run out of.
2. due to the way the historic snapshot is initially set up, only one
REPACK process can be running at any one time on the whole system.
3. there's a danger of deadlocking (and thus abort) due to the lock
upgrade required at the final phase.
These issues will be addressed in upcoming commits.
The design and most of the code are by Antonin Houska, heavily based on
his own pg_squeeze third-party implementation.
Author: Antonin Houska <ah@cybertec.at>
Co-authored-by: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Co-authored-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Noriyoshi Shinoda <noriyoshi.shinoda@hpe.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Discussion: https://postgr.es/m/5186.1706694913@antos
Discussion: https://postgr.es/m/202507262156.sb455angijk6@alvherre.pgsql M doc/src/sgml/monitoring.sgml
M doc/src/sgml/mvcc.sgml
M doc/src/sgml/ref/repack.sgml
M src/Makefile
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/heap/rewriteheap.c
M src/backend/catalog/system_views.sql
M src/backend/commands/Makefile
M src/backend/commands/matview.c
M src/backend/commands/meson.build
M src/backend/commands/repack.c
A src/backend/commands/repack_worker.c
M src/backend/commands/tablecmds.c
M src/backend/commands/vacuum.c
M src/backend/libpq/pqmq.c
M src/backend/meson.build
M src/backend/postmaster/bgworker.c
M src/backend/replication/logical/decode.c
A src/backend/replication/pgrepack/Makefile
A src/backend/replication/pgrepack/meson.build
A src/backend/replication/pgrepack/pgrepack.c
M src/backend/storage/ipc/procsignal.c
M src/backend/tcop/postgres.c
M src/backend/utils/activity/wait_event_names.txt
M src/bin/psql/tab-complete.in.c
M src/include/access/heapam_xlog.h
M src/include/access/tableam.h
M src/include/commands/progress.h
M src/include/commands/repack.h
A src/include/commands/repack_internal.h
M src/include/replication/decode.h
M src/include/storage/lockdefs.h
M src/include/storage/procsignal.h
M src/makefiles/Makefile.cygwin
M src/makefiles/Makefile.win32
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/repack.out
A src/test/modules/injection_points/expected/repack_toast.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/specs/repack.spec
A src/test/modules/injection_points/specs/repack_toast.spec
M src/test/regress/expected/cluster.out
M src/test/regress/expected/rules.out
M src/test/regress/sql/cluster.sql
M src/tools/pgindent/typedefs.list
Document that WAIT FOR may be interrupted by recovery conflicts
commit : 10484c2cc75be3746933d2052b18e8c28512f69e
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 6 Apr 2026 22:42:06 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 6 Apr 2026 22:42:06 +0300 Add a note to the WAIT FOR documentation explaining that sessions
using this command on a standby server may be interrupted by recovery
conflicts. Some conflicts are unavoidable - for example, replaying
a tablespace drop terminates all backends unconditionally.
Discussion: https://postgr.es/m/CAPpHfds7oSCbZqob7ytT_Lso8fv-NW8LnedUTE4Krde%2B3rkJeA%40mail.gmail.com
Author: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com> M doc/src/sgml/ref/wait_for.sgml
Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup()
commit : 7e8aeb9e483db48500987da8981a70b491b7844c
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 6 Apr 2026 22:41:02 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 6 Apr 2026 22:41:02 +0300 When the standby is passed as a PostgreSQL::Test::Cluster instance,
use the WAIT FOR LSN command on the standby server to implement
wait_for_catchup() for replay, write, and flush modes. This is more
efficient than polling pg_stat_replication on the upstream, as the
WAIT FOR LSN command uses a latch-based wakeup mechanism.
The optimization applies when:
- The standby is passed as a Cluster object (not just a name string)
- The mode is 'replay', 'write', or 'flush' (not 'sent')
Rather than pre-checking pg_is_in_recovery() on the standby (which
would add an extra round-trip on every call), we issue WAIT FOR LSN
directly and handle the 'not in recovery' result as a signal to fall
back to polling.
For 'sent' mode, when the standby is passed as a string (e.g., a
subscription name for logical replication), when the standby has been
promoted, or when WAIT FOR LSN is interrupted by a recovery conflict,
the function falls back to the original polling-based approach using
pg_stat_replication on the upstream. The recovery conflict fallback
is necessary because some conflicts are unavoidable - for example,
ResolveRecoveryConflictWithTablespace() kills all backends
unconditionally, regardless of what they are doing.
The recovery conflict detection matches the English error message
"conflict with recovery", which is reliable because the test suite
runs with LC_MESSAGES=C.
Discussion: https://postgr.es/m/CABPTF7UiArgW-sXj9CNwRzUhYOQrevLzkYcgBydmX5oDes1sjg%40mail.gmail.com
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de> M src/test/perl/PostgreSQL/Test/Cluster.pm
Avoid syscache lookup while building a WAIT FOR tuple descriptor
commit : 834038c1f8d52f51666c60ec774bbbf590f4e8c6
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 6 Apr 2026 22:27:36 +0300
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Mon, 6 Apr 2026 22:27:36 +0300 Use TupleDescInitBuiltinEntry instead of TupleDescInitEntry when building
the result tuple descriptor for the WAIT FOR command. This avoids a syscache
access that could re-establish a catalog snapshot after we've explicitly
released all snapshots before the wait.
Discussion: https://postgr.es/m/CABPTF7U%2BSUnJX_woQYGe%3D%3DR9Oz%2B-V6X0VO2stBLPGfJmH_LEhw%40mail.gmail.com
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> M src/backend/commands/wait.c
Remove recheck_relation_needs_vacanalyze().
commit : 775fe51daaef9131c5a00447c0ea9ff36d6a2406
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 6 Apr 2026 14:30:52 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 6 Apr 2026 14:30:52 -0500 This function is a thin wrapper around relation_needs_vacanalyze()
that handles fetching and freeing the pgstat entry for the table.
Since all callers of relation_needs_vacanalyze() do that anyway, we
can teach that function to fetch/free the pgstat entry and use it
instead.
Suggested-by: Álvaro Herrera <alvherre@kurilemu.de>
Author: Sami Imseih <samimseih@gmail.com>
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0s4xjMrB-VAnLccC7kY8d0-4806-Lsac-czJsdA1LXtAw%40mail.gmail.com M src/backend/postmaster/autovacuum.c
auto_explain: Add new GUC, auto_explain.log_extension_options.
commit : e972dff6c30447ebcfa2f8601b67f926247463b6
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 15:09:24 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 15:09:24 -0400 The associated value should look like something that could be
part of an EXPLAIN options list, but restricted to EXPLAIN options
added by extensions.
For example, if pg_overexplain is loaded, you could set
auto_explain.log_extension_options = 'DEBUG, RANGE_TABLE'.
You can also specify arguments to these options in the same manner
as normal e.g. 'DEBUG 1, RANGE_TABLE false'.
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: http://postgr.es/m/CA+Tgmob-0W8306mvrJX5Urtqt1AAasu8pi4yLrZ1XfwZU-Uj1w@mail.gmail.com M contrib/auto_explain/Makefile
M contrib/auto_explain/auto_explain.c
A contrib/auto_explain/expected/extension_options.out
M contrib/auto_explain/meson.build
A contrib/auto_explain/sql/extension_options.sql
M contrib/auto_explain/t/001_auto_explain.pl
M doc/src/sgml/auto-explain.sgml
M src/tools/pgindent/typedefs.list
Support more object types within CREATE SCHEMA.
commit : d516974840f4059d331ae6057ede3e4edd3c6747
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 15:16:21 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 15:16:21 -0400 Having rejected the principle that we should know how to re-order
the sub-commands of CREATE SCHEMA, there is not really anything
except a little coding to stop us from supporting more object types.
This patch adds support for creating functions (including procedures
and aggregates), operators, types (including domains), collations,
and text search objects.
SQL:2021 specifies that we should allow functions, procedures,
types, domains, and collations, so this moves us a great deal
closer to full SQL compatibility of CREATE SCHEMA. What remains
missing from their list are casts, transforms, roles, and some
object types we don't support yet (e.g. CREATE CHARACTER SET).
Supporting casts or transforms would be problematic because
they don't have names at all, let alone schema-qualified names,
so it'd be quite a stretch to say that they belong to a schema.
Roles likewise are not schema-qualified, plus they are global
to a cluster, making it even less reasonable to consider them
as belonging to a schema. So I don't see us trying to complete
the list.
User-defined aggregates and operators are outside the spec's ken,
as are text search objects, so adding them does not do anything for
spec compatibility. But they go along with these other object types,
plus it takes no additional code to support them since they are
represented as DefineStmts like some variants of CREATE TYPE.
It would indeed take some effort to reject them.
Author: Kirill Reshke <reshkekirill@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CALdSSPh4jUSDsWu3K58hjO60wnTRR0DuO4CKRcwa8EVuOSfXxg@mail.gmail.com 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/tab-complete.in.c
M src/fe_utils/psqlscan.l
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
Execute foreign key constraints in CREATE SCHEMA at the end.
commit : 404db8f9edbb291bcc31542d488fb20f6a965798
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 14:52:28 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 14:52:28 -0400 The previous patch simplified CREATE SCHEMA's behavior to "execute all
subcommands in the order they are written". However, that's a bit too
simple, as the spec clearly requires forward references in foreign key
constraint clauses to work, see feature F311-01. (Most other SQL
implementations seem to read more into the spec than that, but it's
not clear that there's justification for more in the text, and this is
the only case that doesn't introduce unresolvable issues.) We never
implemented that before, but let's do so now.
To fix it, transform FOREIGN KEY clauses into ALTER TABLE ... ADD
FOREIGN KEY commands and append them to the end of the CREATE SCHEMA's
subcommand list. This works because the foreign key constraints are
independent and don't affect any other DDL that might be in CREATE
SCHEMA. For simplicity, we do this for all FOREIGN KEY clauses even
if they would have worked where they were.
Author: Jian He <jian.universality@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1075425.1732993688@sss.pgh.pa.us M doc/src/sgml/ref/create_schema.sgml
M src/backend/parser/parse_utilcmd.c
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/expected/event_trigger.out
M src/test/regress/sql/create_schema.sql
Don't try to re-order the subcommands of CREATE SCHEMA.
commit : a9c350d9ee66745aadcf7c0c95a567752a762171
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 14:42:55 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 14:42:55 -0400 transformCreateSchemaStmtElements has always believed that it is
supposed to re-order the subcommands of CREATE SCHEMA into a safe
execution order. However, it is nowhere near being capable of doing
that correctly. Nor is there reason to think that it ever will be,
or that that is a well-defined requirement. (The SQL standard does
say that it should be possible to do foreign-key forward references
within CREATE SCHEMA, but it's not clear that the text requires
anything more than that.) Moreover, the problem will get worse as
we add more subcommand types. Let's just drop the whole idea and
execute the commands in the order given, which seems like a much
less astonishment-prone definition anyway. The foreign-key issue
will be handled in a follow-up patch.
This will result in a release-note-worthy incompatibility,
which is that forward references like
CREATE SCHEMA myschema
CREATE VIEW myview AS SELECT * FROM mytable
CREATE TABLE mytable (...);
used to work and no longer will. Considering how many closely
related variants never worked, this isn't much of a loss.
Along the way, pass down a ParseState so that we can provide an
error cursor for "wrong schema name" and related errors, and fix
transformCreateSchemaStmtElements so that it doesn't scribble
on the parsetree passed to it.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: https://postgr.es/m/1075425.1732993688@sss.pgh.pa.us M doc/src/sgml/ref/create_schema.sgml
M src/backend/commands/extension.c
M src/backend/commands/schemacmds.c
M src/backend/parser/parse_utilcmd.c
M src/backend/tcop/utility.c
M src/include/commands/schemacmds.h
M src/include/parser/parse_utilcmd.h
M src/test/regress/expected/create_schema.out
M src/test/regress/expected/create_view.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
Allow autovacuum to use parallel vacuum workers.
commit : 1ff3180ca0169556984ab83759477f593129794d
author : Masahiko Sawada <msawada@postgresql.org>
date : Mon, 6 Apr 2026 11:48:29 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Mon, 6 Apr 2026 11:48:29 -0700 Previously, autovacuum always disabled parallel vacuum regardless of
the table's index count or configuration. This commit enables
autovacuum workers to use parallel index vacuuming and index cleanup,
using the same parallel vacuum infrastructure as manual VACUUM.
Two new configuration options control the feature. The GUC
autovacuum_max_parallel_workers sets the maximum number of parallel
workers a single autovacuum worker may launch; it defaults to 0,
preserving existing behavior unless explicitly enabled. The per-table
storage parameter autovacuum_parallel_workers provides per-table
limits. A value of 0 disables parallel vacuum for the table, a
positive value caps the worker count (still bounded by the GUC), and
-1 (the default) defers to the GUC.
To handle cases where autovacuum workers receive a SIGHUP and update
their cost-based vacuum delay parameters mid-operation, a new
propagation mechanism is added to vacuumparallel.c. The leader stores
its effective cost parameters in a DSM segment. Parallel vacuum
workers poll for changes in vacuum_delay_point(); if an update is
detected, they apply the new values locally via VacuumUpdateCosts().
A new test module, src/test/modules/test_autovacuum, is added to
verify that parallel autovacuum workers are correctly launched and
that cost-parameter updates are propagated as expected.
The patch was originally proposed by Maxim Orlov, but the
implementation has undergone significant architectural changes
since then during the review process.
Author: Daniil Davydov <3danissimo@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: zengman <zengman@halodbtech.com>
Discussion: https://postgr.es/m/CACG=ezZOrNsuLoETLD1gAswZMuH2nGGq7Ogcc0QOE5hhWaw=cw@mail.gmail.com M doc/src/sgml/config.sgml
M doc/src/sgml/maintenance.sgml
M doc/src/sgml/ref/create_table.sgml
M doc/src/sgml/ref/vacuum.sgml
M src/backend/access/common/reloptions.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/commands/vacuum.c
M src/backend/commands/vacuumparallel.c
M src/backend/postmaster/autovacuum.c
M src/backend/utils/init/globals.c
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/bin/psql/tab-complete.in.c
M src/include/commands/vacuum.h
M src/include/miscadmin.h
M src/include/utils/rel.h
M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_autovacuum/.gitignore
A src/test/modules/test_autovacuum/Makefile
A src/test/modules/test_autovacuum/meson.build
A src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
M src/tools/pgindent/typedefs.list
Rename cluster.c to repack.c (and corresponding .h)
commit : c0b53ec06309f955455c7d71da277991d0da4ec0
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 6 Apr 2026 19:37:28 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 6 Apr 2026 19:37:28 +0200 CLUSTER is no longer the favored way to invoke this functionality, and
the code is about to shift its focus to the REPACK more ambitiously.
Rename the file to avoid leaving an unnecessary historical artifact
around.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/202603271635.owyhm7btgoic@alvherre.pgsql M src/backend/commands/Makefile
M src/backend/commands/matview.c
M src/backend/commands/meson.build
R099 src/backend/commands/cluster.c src/backend/commands/repack.c
M src/backend/commands/tablecmds.c
M src/backend/commands/vacuum.c
M src/backend/storage/ipc/procsignal.c
M src/backend/tcop/postgres.c
M src/backend/tcop/utility.c
R090 src/include/commands/cluster.h src/include/commands/repack.h
Disallow system columns in COPY FROM WHERE conditions.
commit : 21c69dc73f9d0af6a11f13ef61522577126a8674
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 14:05:01 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 14:05:01 -0400 These columns haven't been computed yet when the filtering happens
(since we've not written the candidate tuple into the table); so
any check on them is wrong or useless. Worse, since aa606b931 such a
reference results in an access off the end of a TupleDesc, potentially
causing a phony "generated columns are not supported in COPY FROM
WHERE conditions" error; and since c98ad086a it throws an Assert
instead.
Actually we could allow tableoid, which has been set to the OID of the
table named as the COPY target. However, plausible uses for tests of
tableoid would involve a partitioned target table, and the user would
wish it to read as the OID of the destination partition. There has
been some discussion of changing things to make it work like that,
but pending that happening we should just disallow tableoid along
with other system columns.
It seems best though to install this prohibition only in HEAD.
In the back branches we'll just guard the unsafe TupleDesc access,
and people will keep getting whatever semantics they got before.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/6f435023-8ab6-47c2-ba07-035d0c4212f9@gmail.com M src/backend/commands/copy.c
M src/test/regress/expected/copy2.out
M src/test/regress/sql/copy2.sql
Add missing .gitignore files.
commit : f7da81f68b63430d24caba99c0a95933c10cefcb
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 13:25:29 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 13:25:29 -0400 contrib/pg_stash_advice and src/test/modules/test_shmem
missed these, leading to complaints from git after an
in-tree check-world run.
Use our standard boilerplate list of ignorable subdirectories,
although the two modules presently create different subsets
of that. A contrib/pg_stash_advice/.gitignore
A src/test/modules/test_shmem/.gitignore
Fix null-bitmap combining in array_agg_array_combine().
commit : 6582010c801ff6f54215de45ad1afb3d9fd43bab
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 13:14:50 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 6 Apr 2026 13:14:50 -0400 This code missed the need to update the combined state's
nullbitmap if state1 already had a bitmap but state2 didn't.
We need to extend the existing bitmap with 1's but didn't.
This could result in wrong output from a parallelized
array_agg(anyarray) calculation, if the input has a mix of
null and non-null elements. The errors depended on timing
of the parallel workers, and therefore would vary from one
run to another.
Also install guards against integer overflow when calculating
the combined object's sizes, and make some trivial cosmetic
improvements.
Author: Dmytro Astapov <dastapov@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFQUnFj2pQ1HbGp69+w2fKqARSfGhAi9UOb+JjyExp7kx3gsqA@mail.gmail.com
Backpatch-through: 16 M src/backend/utils/adt/array_userfuncs.c
Add a guc_check_handler to the EXPLAIN extension mechanism.
commit : 0442f1c9eff673849664d8ef71c202ad076e72e9
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 12:29:59 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 12:29:59 -0400 It would be useful to be able to tell auto_explain to set a custom
EXPLAIN option, but it would be bad if it tried to do so and the
option name or value wasn't valid, because then every query would fail
with a complaint about the EXPLAIN option. So add a guc_check_handler
that auto_explain will be able to use to only try to set option
name/value/type combinations that have been determined to be legal,
and to emit useful messages about ones that aren't.
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: http://postgr.es/m/CA+Tgmob-0W8306mvrJX5Urtqt1AAasu8pi4yLrZ1XfwZU-Uj1w@mail.gmail.com M contrib/pg_overexplain/pg_overexplain.c
M contrib/pg_plan_advice/pg_plan_advice.c
M src/backend/commands/explain_state.c
M src/include/commands/explain_state.h
Remove autoanalyze corner case.
commit : e3481edfd1b6b0a64fef8f43cfa3b48e94c01682
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 6 Apr 2026 11:28:46 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 6 Apr 2026 11:28:46 -0500 The restructuring in commit 53b8ca6881 revealed an interesting
corner case: if a table needs vacuuming for wraparound prevention
and autovacuum is disabled for it, we might still choose to analyze
it. Research seems to indicate this was an accidental addition by
commit 48188e1621, and further discussion indicates there is
consensus that it is unnecessary and can be removed.
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Shinya Kato <shinya11.kato@gmail.com>
Discussion: https://postgr.es/m/adB9nSsm_S0D9708%40nathan M src/backend/postmaster/autovacuum.c
Expose helper functions scan_quoted_identifier and scan_identifier.
commit : e0e819cc08d3dc6fe843779c2bb3388135d20d14
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 11:13:25 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 11:13:25 -0400 Previously, this logic was embedded within SplitIdentifierString,
SplitDirectoriesString, and SplitGUCList. Factoring it out saves
a bit of duplicated code, and also makes it available to extensions
that might want to do similar things without necessarily wanting to
do exactly the same thing.
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: http://postgr.es/m/CA+Tgmob-0W8306mvrJX5Urtqt1AAasu8pi4yLrZ1XfwZU-Uj1w@mail.gmail.com M src/backend/utils/adt/varlena.c
M src/include/utils/varlena.h
Add TAP tests for log_lock_waits
commit : ca2b5443e2dcfc09692fd7b93753890b0b9633d2
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 23:49:40 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 23:49:40 +0900 This commit updates 011_lock_stats.pl to verify log_lock_waits behavior.
The tests check that messages are emitted both when a wait occurs and
when the lock is acquired, and that the "still waiting for" message is logged
exactly once per wait, even if the backend wakes up during the wait.
The latter covers the behavior introduced by commit fd6ecbfa75f.
Author: Hüseyin Demir <huseyin.d3r@gmail.com>
Co-authored-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAB5wL7YB1my9W5k5i=SY+=sTjeozyJ0YkvGXrVfeDNzuRkoTPg@mail.gmail.com M src/test/modules/test_misc/t/011_lock_stats.pl
Release postmaster working memory context in slotsync worker
commit : 93dc1ace2007fe7c1103ccda3d7bc13b4eb4352f
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 23:04:18 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 23:04:18 +0900 Child processes do not need the postmaster's working memory context and
normally release it at the start of their main entry point. However,
the slotsync worker forgot to do so.
This commit makes the slotsync worker release the postmaster's working
memory context at startup, preventing unintended use.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Tiancheng Ge <getiancheng_2012@163.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHO05JaUpgKF8FBDmPdBUJsK22axRRcgmAUc2Jyi8OK8g@mail.gmail.com M src/backend/replication/logical/slotsync.c
Fix memory leaks introduced by commit 283e823f9dcb
commit : ed71d7356e3b394f579db87782a41e3d5dfb99ad
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 15:46:03 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 15:46:03 +0300 When freeing pending_shmem_requests we should also free the ->options.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://www.postgresql.org/message-id/CAJ7c6TN9tp8MTc0WXM0zfSWqjfBqU8gpe+o5KqHB1-cQ7409Kw@mail.gmail.com M src/backend/storage/ipc/shmem.c
Fix compilation without injection points with some compilers
commit : 2670a0fcc6a5ee0273b0751dcc18d514735290ad
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 15:46:00 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 15:46:00 +0300 Some compilers didn't like the empty initializer when compiled without
USE_INJECTION_POINTS. Per buildfarm member 'drongo', using Visual
Studio 2019.
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/adNHcBVJO5gIOp1l@paquier.xyz M src/backend/utils/misc/injection_point.c
M src/include/storage/subsystemlist.h
Add pg_stash_advice contrib module.
commit : e8ec19aa321abc89fb4fd277c994f14680ba17db
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 07:41:28 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 6 Apr 2026 07:41:28 -0400 This module allows plan advice strings to be provided automatically
from an in-memory advice stash. Advice stashes are stored in dynamic
shared memory and must be recreated and repopulated after a server
restart. If pg_stash_advice.stash_name is set to the name of an advice
stash, and if query identifiers are enabled, the query identifier
for each query will be looked up in the advice stash and the
associated advice string, if any, will be used each time that query
is planned.
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Discussion: http://postgr.es/m/CA+TgmoaeNuHXQ60P3ZZqJLrSjP3L1KYokW9kPfGbWDyt+1t=Ng@mail.gmail.com M contrib/Makefile
M contrib/meson.build
A contrib/pg_stash_advice/Makefile
A contrib/pg_stash_advice/expected/pg_stash_advice.out
A contrib/pg_stash_advice/expected/pg_stash_advice_utf8.out
A contrib/pg_stash_advice/expected/pg_stash_advice_utf8_1.out
A contrib/pg_stash_advice/meson.build
A contrib/pg_stash_advice/pg_stash_advice–1.0.sql
A contrib/pg_stash_advice/pg_stash_advice.c
A contrib/pg_stash_advice/pg_stash_advice.control
A contrib/pg_stash_advice/pg_stash_advice.h
A contrib/pg_stash_advice/sql/pg_stash_advice.sql
A contrib/pg_stash_advice/sql/pg_stash_advice_utf8.sql
A contrib/pg_stash_advice/stashfuncs.c
M doc/src/sgml/contrib.sgml
M doc/src/sgml/filelist.sgml
A doc/src/sgml/pgstashadvice.sgml
M src/tools/pgindent/typedefs.list
Use single LWLock for lock statistics in pgstats
commit : 404a17c155ac6e80d990fb0625569a3854f7090d
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Apr 2026 14:01:04 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Apr 2026 14:01:04 +0900 Previously, one LWLock was used for each lock type, adding complexity
without an observable performance benefit as data is gathered only for
paths involving lock waits, at least currently. This commit replaces
the per-type set of LWLocks with a single LWLock protecting the stats
data of all the lock types, like the stats kinds for SLRU or WAL. A
good chunk of the callbacks get simpler thanks to this change.
The previous approach also had one bug in the flush callback when nowait
was called with "true": a backend iterating over all entries could
successfully flush some entries while skipping others due to contention,
then unconditionally reset the pending data. This would cause some
stats data loss.
Oversight in 4019f725f5d4.
Reported-by: Tomas Vondra <tomas@vondra.me>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/1af63e6d-16d5-4d5b-9b03-11472ef1adf9@vondra.me M src/backend/utils/activity/pgstat_lock.c
M src/include/utils/pgstat_internal.h
Improve more stability of worker_spi termination test
commit : 283c5fb22b44562428700284aad23eb5245b19d8
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Apr 2026 13:23:28 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Apr 2026 13:23:28 +0900 Alexander Lakhin has noticed that it can be possible on machines with
slow storage to have the spawned workers be stuck in
initialize_worker_spi(), before they reach their main loop. Waiting for
a flush to happen would block the interrupt attempts done by the
database commands, causing the test to fail on timeout once the number
of interrupt attempts is reached in CountOtherDBBackends().
This commit switches the test to wait for the spawned bgworkers to reach
their main loops before attempting the database commands that would
trigger the interrupts, napping for a time larger than the default, with
worker_spi.naptime set at 10 minutes. Another thing that could be
attempted is to enforce a larger number of tries in
CountOtherDBBackends(), if what is done here is not enough. Let's see
first if what this commit does is enough for the buildfarm members
widowbird and jay.
Analyzed-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/f913fba1-da59-404c-9eb3-07c7304be637@gmail.com M src/test/modules/worker_spi/t/002_worker_terminate.pl
Simplify redundant current_database() subqueries in stats.sql regression test
commit : d78a4f0bf058906c5cfd25c815ccbdf18013b312
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 13:19:45 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 13:19:45 +0900 Previously the stats.sql regression test used conditions like
"datname = (SELECT current_database())" to check the current database name.
The subquery is unnecessary, so this commit simplifies these expressions to
"datname = current_database()".
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/A1535A8F-65AF-4C3D-ACBE-25891CB5D38B@gmail.com M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql
Fix volatile function evaluation in eager aggregation
commit : 3a08a2a8b4fd36a9fa0da0253d1ca053c19047d5
author : Richard Guo <rguo@postgresql.org>
date : Mon, 6 Apr 2026 11:54:08 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 6 Apr 2026 11:54:08 +0900 Pushing aggregates containing volatile functions below a join can
violate volatility semantics by changing the number of times the
function is executed.
Here we check the Aggref nodes in the targetlist and havingQual for
volatile functions and disable eager aggregation when such functions
are present.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAMbWs48A53PY1Y4zoj7YhxPww9fO1hfnbdntKfA855zpXfVFRA@mail.gmail.com M src/backend/optimizer/plan/initsplan.c
M src/test/regress/expected/eager_aggregate.out
M src/test/regress/sql/eager_aggregate.sql
Fix collation handling for grouping keys in eager aggregation
commit : bd94845e8c90475b8149f6a091876a1827b6b305
author : Richard Guo <rguo@postgresql.org>
date : Mon, 6 Apr 2026 11:52:33 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Mon, 6 Apr 2026 11:52:33 +0900 When determining if it is safe to use an expression as a grouping key
for partial aggregation, eager aggregation relies on the B-tree
equalimage support function to ensure that equality implies image
equality.
Previously, the code incorrectly passed the default collation of the
expression's data type to the equalimage procedure, rather than the
expression's actual collation. As a result, if a column used a
non-deterministic collation but the base type's default collation was
deterministic, eager aggregation would incorrectly assume that the
column was safe for byte-level grouping. This could cause rows to be
prematurely grouped and subsequently discarded by strict join
conditions, resulting in incorrect query results.
This patch fixes the issue by passing the expression's actual
collation to the equalimage procedure.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAMbWs48A53PY1Y4zoj7YhxPww9fO1hfnbdntKfA855zpXfVFRA@mail.gmail.com M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/util/relnode.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
Add wal_sender_shutdown_timeout GUC to limit shutdown wait for replication
commit : a8f45dee91768cf1447ffaf2527e499e75a194c3
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 11:35:03 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 6 Apr 2026 11:35:03 +0900 Previously, during shutdown, walsenders always waited until all pending data
was replicated to receivers. This ensures sender and receiver stay in sync
after shutdown, which is important for physical replication switchovers,
but it can significantly delay shutdown. For example, in logical replication,
if apply workers are blocked on locks, walsenders may wait until those locks
are released, preventing shutdown from completing for a long time.
This commit introduces a new GUC, wal_sender_shutdown_timeout,
which specifies the maximum time a walsender waits during shutdown for all
pending data to be replicated. When set, shutdown completes once all data is
replicated or the timeout expires. A value of -1 (the default) disables
the timeout.
This can reduce shutdown time when replication is slow or stalled. However,
if the timeout is reached, the sender and receiver may be left out of sync,
which can be problematic for physical replication switchovers.
Author: Andrey Silitskiy <a.silitskiy@postgrespro.ru>
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Takamichi Osumi <osumi.takamichi@fujitsu.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Vitaly Davydov <v.davydov@postgrespro.ru>
Reviewed-by: Ronan Dunklau <ronan@dunklau.fr>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/TYAPR01MB586668E50FC2447AD7F92491F5E89@TYAPR01MB5866.jpnprd01.prod.outlook.com M doc/src/sgml/config.sgml
M doc/src/sgml/high-availability.sgml
M src/backend/replication/walsender.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/include/replication/walsender.h
M src/test/subscription/meson.build
A src/test/subscription/t/038_walsnd_shutdown_timeout.pl
Fix unportable use of __builtin_constant_p
commit : 8194c4a9dd38f7373166ea3fd9243a6e51c0869f
author : John Naylor <john.naylor@postgresql.org>
date : Mon, 6 Apr 2026 09:30:01 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Mon, 6 Apr 2026 09:30:01 +0700 On MSVC Arm, USE_ARMV8_CRC32C is defined, but __builtin_constant_p
is not available. Use pg_integer_constant_p and add appropriate
guards. There is a similar potential hazard for the x86 path, but
for now let's get the buildfarm green.
Oversight in commit fbc57f2bc, per buildfarm member hoatzin. M src/include/port/pg_crc32c.h
Test stabilization for online checksums
commit : 07009121c235dc1b9338b57b6a85006a5e3b0bd8
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 6 Apr 2026 02:03:10 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 6 Apr 2026 02:03:10 +0200 Postcommit review and buildfarm/CI failures revealed a few issues in
the test code which this commit attempts to resolve. These failures
are verified using synthetic means.
* Wait for launcher exit in enable/disable checksum tests
When enabling or disabling data checksums in a test with waiting
for an end state (on or off), the test typically want to perform
more test against the cluster immediately. Make sure to wait for
the launcher to exit in these cases before returning in order to
know it can immediately be acted on. This is a more generic way
of implementating 0036232ba8f.
* Refactor injection point tests to use the injection_points test
extension. Two injection points added for online checksums were
better expressed using the injection_points extension with the
test code embedded in datachecksum_state.c.
* Make tests less timing dependent and allow transitions to "on"
and not just "inprogress-on" in case a test manages to finish
before it's checked for state.
* When waiting on a blocking background psql keeping a temporary
table open, the test first closed the background session abd
then the server. This could cause data checksums to manage to
get enabled in the brief window between dropping the temporary
table and closing the server. Fix by closing the server first
before the background session.
* Remove a few superfluous duplicate checks and general cleanup
of comments as well as making LSN logging consistent.
These issues were reported by Andres as well as spotted in the
buildfarm and on CI.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/92F25C14-801E-4198-994D-D83E31FEB0D8@yesql.se M src/backend/postmaster/datachecksum_state.c
M src/test/modules/test_checksums/t/001_basic.pl
M src/test/modules/test_checksums/t/003_standby_restarts.pl
M src/test/modules/test_checksums/t/004_offline.pl
M src/test/modules/test_checksums/t/005_injection.pl
M src/test/modules/test_checksums/t/006_pgbench_single.pl
M src/test/modules/test_checksums/t/007_pgbench_standby.pl
M src/test/modules/test_checksums/t/008_pitr.pl
M src/test/modules/test_checksums/t/DataChecksums/Utils.pm
M src/test/modules/test_checksums/test_checksums–1.0.sql
M src/test/modules/test_checksums/test_checksums.c
Handle checksumworker startup wait race
commit : d771b0a907e67dc929dbbdebf70ecb006081b629
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 6 Apr 2026 01:55:06 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Mon, 6 Apr 2026 01:55:06 +0200 If the background worker for processing databases manages to finish
before the launcher starts waiting for it, the launcher would treat
it erroneously as an error. Fix by ensureing to check result state
in this case. Identified on CI and synthetically reproduced during
local testing.
Also while, make sure to properly lock the shared memory structure
before updating tje result state.
Author: Daniel Gustafsson <daniel@yesql.seA
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/4fxw37ge47v5baeozla5phymi233hxbcjbwwsfwv3mpg3kyl2z@6jk4nkf6jp4 M src/backend/postmaster/datachecksum_state.c
Add tests for lock statistics, take two
commit : 557a9f1e3e62894cc3302eda72d9df091d72f37b
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Apr 2026 08:51:30 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 6 Apr 2026 08:51:30 +0900 Commit 7c64d56fd976 has removed the isolation test providing coverage
for lock statistics due to some instability in the CI, where the
deadlock timeout may not have enough time to process, preventing the
stats data to be updated. These also relied on a set of hardcoded
sleeps.
This commit switches the test suite to TAP, instead, that uses an
injection point with a wait to avoid the sleeps. The injection point is
added in ProcSleep(), once we know that the deadlock timeout has fired
and that the stats have been updated.
Multiple lock patterns are checked, all rely on the same workflow, with
two sessions:
- session 1 holds a given lock type.
- session 2 attaches to the new injection point with the wait action.
- session 2 attempts to acquire a lock conflicting with the lock of
session 1, waiting for the injection point to be reached.
- session 1 releases its lock, session 2 commits.
- pg_stat_lock is polled until the counters are updated for the lock
type.
Bertrand's version of the patch introduced a new routine to
BackgroundPsql() to detect the blocked background sessions. I have
tweaked the test so as we use the same method as some of the other tests
instead, based on some \echo commands. This test has been run multiple
times in the CI, all passing, so I'd like to think that this is more
stable than the first version attempted.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/acNTR1lLHwQJ0o+P@ip-10-97-1-34.eu-west-3.compute.internal M src/backend/storage/lmgr/proc.c
M src/test/modules/test_misc/meson.build
A src/test/modules/test_misc/t/011_lock_stats.pl
Convert all remaining subsystems to use the new shmem allocation API
commit : 9b5acad3f40fa6015f367fbf887ae5c1a93a3698
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:10 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:10 +0300 This removes all remaining uses of ShmemInitStruct() and
ShmemInitHash() from built-in code.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/access/common/syncscan.c
M src/backend/access/nbtree/nbtutils.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogprefetcher.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/access/transam/xlogwait.c
M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/checkpointer.c
M src/backend/postmaster/datachecksum_state.c
M src/backend/postmaster/pgarch.c
M src/backend/postmaster/walsummarizer.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/logicalctl.c
M src/backend/replication/logical/origin.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/slot.c
M src/backend/replication/walreceiverfuncs.c
M src/backend/replication/walsender.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/lock.c
M src/backend/utils/activity/backend_status.c
M src/backend/utils/activity/pgstat_shmem.c
M src/backend/utils/activity/wait_event.c
M src/backend/utils/misc/injection_point.c
M src/include/access/nbtree.h
M src/include/access/syncscan.h
M src/include/access/twophase.h
M src/include/access/xlog.h
M src/include/access/xlogprefetcher.h
M src/include/access/xlogrecovery.h
M src/include/access/xlogwait.h
M src/include/pgstat.h
M src/include/postmaster/autovacuum.h
M src/include/postmaster/bgworker_internals.h
M src/include/postmaster/bgwriter.h
M src/include/postmaster/datachecksum_state.h
M src/include/postmaster/pgarch.h
M src/include/postmaster/walsummarizer.h
M src/include/replication/logicalctl.h
M src/include/replication/logicallauncher.h
M src/include/replication/origin.h
M src/include/replication/slot.h
M src/include/replication/slotsync.h
M src/include/replication/walreceiver.h
M src/include/replication/walsender.h
M src/include/storage/lock.h
M src/include/storage/subsystemlist.h
M src/include/utils/backend_status.h
M src/include/utils/injection_point.h
M src/include/utils/wait_event.h
M src/test/modules/injection_points/injection_points.c
M src/test/modules/test_aio/test_aio.c
Convert buffer manager to use the new shmem allocation functions
commit : a4b6139dcceb47986577aef36e73f15187ceb727
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:08 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:08 +0300 This rectifies the initialization functions a little, making the
"buffer strategy" stuff in freelist.c and buffer mapping hash table in
buf_init.c top-level "subsystems" of their own, registered directly in
subsystemlist.h. Previously they were called indirectly from
BufferManagerShmemInit() and BufferManagerShmemSize()
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/storage/buffer/buf_init.c
M src/backend/storage/buffer/buf_table.c
M src/backend/storage/buffer/freelist.c
M src/backend/storage/ipc/ipci.c
M src/include/storage/buf_internals.h
M src/include/storage/bufmgr.h
M src/include/storage/subsystemlist.h
Add alignment option to ShmemRequestStruct()
commit : dacfe81a0de513308e6753fe3d9b4f3e4811da69
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:06 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:06 +0300 The buffer blocks, converted to use ShmemRequestStruct() in the next
commit, are IO-aligned. This might come handy in other places too, so
make it an explicit feature of ShmemRequestStruct().
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/storage/ipc/shmem.c
M src/include/storage/shmem.h
Convert AIO to use the new shmem allocation functions
commit : 58a1573385edb28435913affe626ff7daffba76d
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:04 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:04 +0300 This replaces the "shmem_size" and "shmem_init" callbacks in the IO
methods table with the same ShmemCallback struct that we now use in
other subsystems
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/storage/aio/aio_init.c
M src/backend/storage/aio/method_io_uring.c
M src/backend/storage/aio/method_worker.c
M src/backend/storage/ipc/ipci.c
M src/include/storage/aio_internal.h
M src/include/storage/aio_subsys.h
M src/include/storage/subsystemlist.h
Convert SLRUs to use the new shmem allocation functions
commit : 2e0943a8597e1eeaec184465ba8b1f2f453a69e0
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:02 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:02 +0300 I replaced the old SimpleLruInit() function without a backwards
compatibility wrapper, because few extensions define their own SLRUs.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/access/transam/clog.c
M src/backend/access/transam/commit_ts.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/slru.c
M src/backend/access/transam/subtrans.c
M src/backend/commands/async.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/shmem.c
M src/backend/storage/lmgr/predicate.c
M src/backend/utils/activity/pgstat_slru.c
M src/include/access/clog.h
M src/include/access/commit_ts.h
M src/include/access/multixact.h
M src/include/access/slru.h
M src/include/access/subtrans.h
M src/include/commands/async.h
M src/include/storage/predicate.h
M src/include/storage/shmem_internal.h
M src/include/storage/subsystemlist.h
M src/test/modules/test_slru/test_slru.c
M src/tools/pgindent/typedefs.list
Refactor shmem initialization code in predicate.c
commit : 4c9eca5afea0e8623e39f6a778412d4da687f659
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:01 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:13:01 +0300 This is in preparation to convert it to use the new shmem allocation
functions, making the next commit that does that smaller. This inlines
SerialInit() to the caller, and moves all the initialization steps
within PredicateLockShmemInit() to happen after all the
ShmemInit{Struct|Hash}() calls.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/storage/lmgr/predicate.c
Use the new shmem allocation functions in a few core subsystems
commit : c6d55714ba4c282dcf5fb5fe5ef2a5cad0b06e81
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:59 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:59 +0300 These subsystems have some complicating properties, making them
slightly harder to convert than most:
- The initialization callbacks of some of these subsystems have
dependencies, i.e. they need to be initialized in the right order.
- The ProcGlobal pointer still needs to be inherited by the
BackendParameters mechanism on EXEC_BACKEND builds, because
ProcGlobal is required by InitProcess() to get a PGPROC entry, and
the PGPROC entry is required to use LWLocks, and usually attaching
to shared memory areas requires the use of LWLocks.
- Similarly, ProcSignal pointer still needs to be handled by
BackendParameters, because query cancellation connections access it
without calling InitProcess
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/access/transam/twophase.c
M src/backend/access/transam/varsup.c
M src/backend/port/posix_sema.c
M src/backend/port/sysv_sema.c
M src/backend/port/win32_sema.c
M src/backend/storage/ipc/dsm.c
M src/backend/storage/ipc/dsm_registry.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/latch.c
M src/backend/storage/ipc/pmsignal.c
M src/backend/storage/ipc/procarray.c
M src/backend/storage/ipc/procsignal.c
M src/backend/storage/ipc/sinvaladt.c
M src/backend/storage/lmgr/proc.c
M src/backend/utils/hash/dynahash.c
M src/include/access/transam.h
M src/include/storage/dsm.h
M src/include/storage/dsm_registry.h
M src/include/storage/pg_sema.h
M src/include/storage/pmsignal.h
M src/include/storage/proc.h
M src/include/storage/procarray.h
M src/include/storage/procsignal.h
M src/include/storage/sinvaladt.h
M src/include/storage/subsystemlist.h
Convert lwlock.c to use the new shmem allocation functions
commit : a006bc7b1699d952afcb6d786343e8bf0ecc61d6
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:57 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:57 +0300 It seems like a good candidate to convert first because it needs to
initialized before any other subsystem, but other than that it's
nothing special.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/postmaster/postmaster.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/lwlock.c
M src/backend/tcop/postgres.c
M src/include/storage/lwlock.h
M src/include/storage/subsystemlist.h
Introduce a registry of built-in shmem subsystems
commit : 1fc2e9fbc0a3d17aa484dbfab11af58eb2cb20ad
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:55 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:55 +0300 To add a new built-in subsystem, add it to subsystemslist.h. That
hooks up its shmem callbacks so that they get called at the right
times during postmaster startup. For now this is unused, but will
replace the current SubsystemShmemSize() and SubsystemShmemInit()
calls in the next commits.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/bootstrap/bootstrap.c
M src/backend/postmaster/launch_backend.c
M src/backend/postmaster/postmaster.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/shmem.c
M src/backend/tcop/postgres.c
M src/include/storage/ipc.h
A src/include/storage/subsystemlist.h
A src/include/storage/subsystems.h
M src/tools/pginclude/headerscheck
Convert pg_stat_statements to use the new shmem allocation functions
commit : d4885af3d65325c1fcd319e98c634fde9a200443
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:53 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:53 +0300 As part of this, embed the LWLock it needs in the shared memory struct
itself, so that we don't need to use RequestNamedLWLockTranche()
anymore. LWLockNewTrancheId() + LWLockInitialize() is more convenient
to use in extensions.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M contrib/pg_stat_statements/pg_stat_statements.c
Add a test module to test after-startup shmem allocations
commit : 6409994c7dd8cc8c06c00882880e04cc895c28bd
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:51 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:51 +0300 The old ShmemInit{Struct/Hash}() functions could be used after
postmaster statup, as long as the allocation is small enough to fit in
spare shmem reserved at startup. I believe some extensions do that,
although we hadn't really documented it and had not coverage for it.
The new test module covers that after-startup usage with the new
ShmemRequestStruct() functions.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_shmem/Makefile
A src/test/modules/test_shmem/meson.build
A src/test/modules/test_shmem/t/001_late_shmem_alloc.pl
A src/test/modules/test_shmem/test_shmem–1.0.sql
A src/test/modules/test_shmem/test_shmem.c
A src/test/modules/test_shmem/test_shmem.control
M src/tools/pgindent/typedefs.list
Introduce a new mechanism for registering shared memory areas
commit : 283e823f9dcb03d0be720928b261628af06d3fd4
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:50 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:50 +0300 This replaces the [Subsystem]ShmemSize() and [Subsystem]ShmemInit()
functions called at postmaster startup with a new set of callbacks.
The new mechanism is designed to be more ergonomic. Notably, the size
of each shmem area is specified in the same ShmemRequestStruct() call,
together with its name. The same mechanism is used in extensions,
replacing the shmem_{request/startup}_hooks.
ShmemInitStruct() and ShmemInitHash() become backwards-compatibility
wrappers around the new functions. In future commits, I will replace
all ShmemInitStruct() and ShmemInitHash() calls with the new
functions, although we'll still need to keep them around for
extensions.
Co-authored-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M doc/src/sgml/system-views.sgml
M doc/src/sgml/xfunc.sgml
M src/backend/bootstrap/bootstrap.c
M src/backend/postmaster/launch_backend.c
M src/backend/postmaster/postmaster.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/shmem.c
M src/backend/storage/ipc/shmem_hash.c
M src/backend/storage/lmgr/proc.c
M src/backend/tcop/postgres.c
M src/backend/utils/hash/dynahash.c
M src/include/storage/shmem.h
M src/include/storage/shmem_internal.h
M src/tools/pgindent/typedefs.list
Move some code from shmem.c and shmem.h
commit : 6ef9bee29310fa519b1b0f01221fcf1c41a33679
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:48 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 6 Apr 2026 02:12:48 +0300 A little refactoring in preparation for the next commit, to make the
material changes in that commit more clear.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/postmaster/launch_backend.c
M src/backend/storage/ipc/Makefile
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/meson.build
M src/backend/storage/ipc/shmem.c
A src/backend/storage/ipc/shmem_hash.c
M src/include/storage/shmem.h
A src/include/storage/shmem_internal.h
instrumentation: Separate per-node logic from other uses
commit : 5a79e78501f46bd3ac7fbd0ff84cf1e20dbafd19
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 17:18:00 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 17:18:00 -0400 Previously, different places (e.g. query "total time") were repurposing the
Instrumentation struct initially introduced for capturing per-node statistics
during execution. This overuse of the same struct is confusing, e.g. by
cluttering calls of InstrStartNode/InstrStopNode in unrelated code paths, and
prevents future refactorings.
Instead, simplify the Instrumentation struct to only track time and WAL/buffer
usage. Similarly, drop the use of InstrEndLoop outside of per-node
instrumentation - these calls were added without any apparent benefit since
the relevant fields were never read.
Introduce the NodeInstrumentation struct to carry forward the per-node
instrumentation information. WorkerInstrumentation is renamed to
WorkerNodeInstrumentation for clarity.
In passing, clarify that InstrAggNode is expected to only run after
InstrEndLoop (as it does in practice), and drop unused code.
This also fixes a consequence-less bug: Previously ->async_mode was only set
when a non-zero instrument_option was passed. That turns out to be harmless
right now, as ->async_mode only affects a timing related field.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53PkzdBK8VJ1fS4AZ481LgMN8f9mJiC39ZRHqkFUSYq6KWmg@mail.gmail.com M contrib/auto_explain/auto_explain.c
M contrib/pg_stat_statements/pg_stat_statements.c
M contrib/postgres_fdw/postgres_fdw.c
M src/backend/commands/explain.c
M src/backend/executor/execMain.c
M src/backend/executor/execParallel.c
M src/backend/executor/execProcnode.c
M src/backend/executor/instrument.c
M src/include/executor/instrument.h
M src/include/nodes/execnodes.h
M src/tools/pgindent/typedefs.list
instrumentation: Separate trigger logic from other uses
commit : 7d9b74df53e9268bd638274f1415ebfeecf0de51
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 16:47:12 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 16:47:12 -0400 Introduce TriggerInstrumentation to capture trigger timing and firings
(previously counted in "ntuples"), to aid a future refactoring that
splits out all Instrumentation fields beyond timing and WAL/buffers into
more specific structs.
In passing, drop the "n" argument to InstrAlloc, as all remaining callers need
exactly one Instrumentation struct. The duplication between InstrAlloc() and
InstrInit(), as well as the conditional initialization of async_mode will be
addressed in a subsequent commit.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/CAP53PkzdBK8VJ1fS4AZ481LgMN8f9mJiC39ZRHqkFUSYq6KWmg@mail.gmail.com M contrib/auto_explain/auto_explain.c
M contrib/pg_stat_statements/pg_stat_statements.c
M src/backend/commands/explain.c
M src/backend/commands/trigger.c
M src/backend/executor/execMain.c
M src/backend/executor/execProcnode.c
M src/backend/executor/instrument.c
M src/include/executor/instrument.h
M src/include/nodes/execnodes.h
M src/tools/pgindent/typedefs.list
Fixups for a4f774cf1c7
commit : 6c7bce28c83f4deaa6a6205dc32e86ac1630182c
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 15:36:34 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 15:36:34 -0400 The database name was warned about when building with
-DENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS, leading to BF and CI failures.
It is somewhat confusing that the required prefix is different for databases
than other object types.
Also fix a pgindent violation that caused koel to start to fail.
Discussion: https://postgr.es/m/ptyiexyhmtxf4lm524s7o7w64r26ra237uusv4tjav4yhpmeoo@vfwwllz7tivb M src/backend/utils/adt/ddlutils.c
M src/test/regress/expected/database_ddl.out
M src/test/regress/sql/database_ddl.sql
Add tid_block() and tid_offset() accessor functions
commit : df6949ccf7a6d5160e3068ed843eb46ab7bc2601
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 14:45:27 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 14:45:27 -0400 The two new functions allow to extract the block number and offset from a tid.
There are existing ways to do so (e.g. by doing (ctid::text::point)[0]), but
they are hard to remember and not pretty.
tid_block() returns int8 (bigint) because BlockNumber is uint32, which exceeds
the range of int4. tid_offset() returns int4 (integer) because OffsetNumber is
uint16, which fits safely in int4.
Bumps catversion.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWUzok2+mvSYkbVUwq_SWWg-GdHqCuYumN82AU97SjwjCA@mail.gmail.com M doc/src/sgml/func/allfiles.sgml
A doc/src/sgml/func/func-tid.sgml
M doc/src/sgml/func/func.sgml
M src/backend/utils/adt/tid.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/opr_sanity.out
M src/test/regress/expected/tid.out
M src/test/regress/sql/tid.sql
Check that the tranche name is unique in RequestNamedLWLockTranche
commit : f10b6be2581f879f24a4830443bab356ec6d71c5
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 5 Apr 2026 21:05:20 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 5 Apr 2026 21:05:20 +0300 You could request two tranches with same name, but things would get
confusing when you called GetNamedLWLockTranche() to get the LWLocks
allocated for them; it would always return the first tranche with the
name. That doesn't make sense, so forbid duplicates.
We still allow duplicates with LWLockNewTrancheId(). That works better
as you don't use the name to look up the tranche ID later. It's still
confusing in wait events, for example, but it's not dangerous in the
same way.
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://www.postgresql.org/message-id/463a28db-0c0b-4af6-bac6-3891828bbbfe@iki.fi M src/backend/storage/lmgr/lwlock.c
Improve test_lwlock_tranches
commit : 92a685e4070d01653daac1d60de6c155723a5c68
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 5 Apr 2026 21:05:15 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 5 Apr 2026 21:05:15 +0300 While working on refactoring how shmem is allocated, I made a mistake
where the main LWLock array did not reserve space for the LWLocks
allocated with RequestNamedLWLockTranche(), and the test still
passed. Matthias van de Meent spotted that before it got committed,
but in order to catch such mistakes in the future, add checks in
test_lwlock_tranches that the locks allocated with
RequestNamedLWLockTranche() can be acquired and released.
Another change is to stop requesting multiple tranches with the same
name with RequestNamedLWLockTranche(). As soon as I started to test
using the locks I realized that's bogus, and the next commit will
forbid it. Keep test coverage for duplicates requested with
LWLockNewTrancheId() for now, but make it more clear that that's what
the test does.
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://www.postgresql.org/message-id/463a28db-0c0b-4af6-bac6-3891828bbbfe@iki.fi
Discussion: https://www.postgresql.org/message-id/CAEze2WjgCROMMXY0+j8FFdm3iFcr7By-+6Mwiz=PgGSEydiW3A@mail.gmail.com M src/test/modules/test_lwlock_tranches/expected/test_lwlock_tranches.out
M src/test/modules/test_lwlock_tranches/sql/test_lwlock_tranches.sql
M src/test/modules/test_lwlock_tranches/test_lwlock_tranches–1.0.sql
M src/test/modules/test_lwlock_tranches/test_lwlock_tranches.c
Add pg_get_database_ddl() function
commit : a4f774cf1c7e5c6cf2f3393f611e1df16cdb5a5a
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:57:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:57:35 -0400 Add a new SQL-callable function that returns the DDL statements needed
to recreate a database. It takes a regdatabase argument and an optional
VARIADIC text argument for options that are specified as alternating
name/value pairs. The following options are supported: pretty (boolean)
for formatted output, owner (boolean) to include OWNER and tablespace
(boolean) to include TABLESPACE. The return is one or multiple rows
where the first row is a CREATE DATABASE statement and subsequent rows are
ALTER DATABASE statements to set some database properties.
The caller must have CONNECT privilege on the target database.
Author: Akshay Joshi <akshay.joshi@enterprisedb.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Discussion: https://postgr.es/m/CANxoLDc6FHBYJvcgOnZyS+jF0NUo3Lq_83-rttBuJgs9id_UDg@mail.gmail.com
Discussion: https://postgr.es/m/e247c261-e3fb-4810-81e0-a65893170e94@dunslane.net M doc/src/sgml/func/func-info.sgml
M src/backend/utils/adt/ddlutils.c
M src/include/catalog/pg_proc.dat
A src/test/regress/expected/database_ddl.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/database_ddl.sql
Add pg_get_tablespace_ddl() function
commit : b99fd9fd7f363c6363f4c8a95c699b9134b0357f
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:55:16 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:55:16 -0400 Add a new SQL-callable function that returns the DDL statements needed
to recreate a tablespace. It takes a tablespace name or OID and an
optional VARIADIC text argument for options that are specified as
alternating name/value pairs. The following options are supported: pretty
(boolean) for formatted output and owner (boolean) to include OWNER.
(It includes two variants because there is no regtablespace pseudotype.)
The return is one or multiple rows where the first row is a CREATE
TABLESPACE statement and subsequent rows are ALTER TABLESPACE statements
to set some tablespace properties.
The caller must have SELECT privilege on pg_tablespace.
get_reloptions() in ruleutils.c is made non-static so it can be called
from the new ddlutils.c file.
Author: Nishant Sharma <nishant.sharma@enterprisedb.com>
Author: Manni Wood <manni.wood@enterprisedb.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAKWEB6rmnmGKUA87Zmq-s=b3Scsnj02C0kObQjnbL2ajfPWGEw@mail.gmail.com
Discussion: https://postgr.es/m/e247c261-e3fb-4810-81e0-a65893170e94@dunslane.net M doc/src/sgml/func/func-info.sgml
M src/backend/utils/adt/ddlutils.c
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/pg_proc.dat
M src/include/utils/ruleutils.h
A src/test/regress/expected/tablespace_ddl.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/tablespace_ddl.sql
Add pg_get_role_ddl() function
commit : 76e514ebb4b55f95b844e3e94e61fa64ab16fd0b
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:52:25 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:52:25 -0400 Add a new SQL-callable function that returns the DDL statements needed
to recreate a role. It takes a regrole argument and an optional VARIADIC
text argument for options that are specified as alternating name/value
pairs. The following options are supported: pretty (boolean) for
formatted output and memberships (boolean) to include GRANT statements
for role memberships and membership options. The return is one or
multiple rows where the first row is a CREATE ROLE statement and
subsequent rows are ALTER ROLE statements to set some role properties.
Password information is never included in the output.
The caller must have SELECT privilege on pg_authid.
Author: Mario Gonzalez <gonzalemario@gmail.com>
Author: Bryan Green <dbryan.green@gmail.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://postgr.es/m/4c5f895e-3281-48f8-b943-9228b7da6471@gmail.com
Discussion: https://postgr.es/m/e247c261-e3fb-4810-81e0-a65893170e94@dunslane.net M doc/src/sgml/func/func-info.sgml
M src/backend/utils/adt/ddlutils.c
M src/include/catalog/pg_proc.dat
A src/test/regress/expected/role_ddl.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/role_ddl.sql
Add infrastructure for pg_get_*_ddl functions
commit : 4881981f92024e4db6249bd3dc96a3859638a665
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:50:41 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 19 Mar 2026 09:50:41 -0400 Add parse_ddl_options(), append_ddl_option(), and append_guc_value()
helper functions in a new ddlutils.c file that provide common option
parsing and output formatting for the pg_get_*_ddl family of functions
which will follow in later patches. These accept VARIADIC text
arguments as alternating name/value pairs.
Callers declare an array of DdlOption descriptors specifying the
accepted option names and their types (boolean, text, or integer).
parse_ddl_options() matches each supplied pair against the array,
validates the value, and fills in the result fields. This
descriptor-based scheme is based on an idea from Euler Taveira.
This is placed in a new ddlutils.c file which will contain the
pg_get_*_ddl functions.
Author: Akshay Joshi <akshay.joshi@enterprisedb.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Euler Taveira <euler@eulerto.com>
Discussion: https://postgr.es/m/CAKWEB6rmnmGKUA87Zmq-s=b3Scsnj02C0kObQjnbL2ajfPWGEw@mail.gmail.com
Discussion: https://postgr.es/m/4c5f895e-3281-48f8-b943-9228b7da6471@gmail.com
Discussion: https://postgr.es/m/CANxoLDc6FHBYJvcgOnZyS+jF0NUo3Lq_83-rttBuJgs9id_UDg@mail.gmail.com
Discussion: https://postgr.es/m/e247c261-e3fb-4810-81e0-a65893170e94@dunslane.net M src/backend/utils/adt/Makefile
A src/backend/utils/adt/ddlutils.c
M src/backend/utils/adt/meson.build
M src/tools/pgindent/typedefs.list
Allow index_create to suppress index_build progress reporting
commit : caec9d9fadf1b04741ac554470c46bc1f8e89d19
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sun, 5 Apr 2026 13:34:08 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sun, 5 Apr 2026 13:34:08 +0200 A future REPACK patch wants a way to suppress index_build doing its
progress reports when building an index, because that would interfere
with repack's own reporting; so add an INDEX_CREATE_SUPPRESS_PROGRESS
bit that enables this.
Furthermore, change the index_create_copy() API so that it takes flag
bits for index_create() and passes them unchanged. This gives its
callers more direct control, which eases the interface -- now its
callers can pass the INDEX_CREATE_SUPPRESS_PROGRESS bit directly. We
use it for the current caller in REINDEX CONCURRENTLY, since it's also
not interested in progress reporting, since it doesn't want
index_build() to be called at all in the first place.
One thing to keep in mind, pointed out by Mihail, is that we're not
suppressing the index-AM-specific progress report updates which happen
during ambuild(). At present this is not a problem, because the values
updated by those don't overlap with those used by commands other than
CREATE INDEX; but maybe in the future we'll want the ability to suppress
them also. (Alternatively we might want to display how each
index-build-subcommand progresses during REPACK and others.)
Author: Antonin Houska <ah@cybertec.at>
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Discussion: https://postgr.es/m/102906.1773668762@localhost M src/backend/bootstrap/bootstrap.c
M src/backend/catalog/heap.c
M src/backend/catalog/index.c
M src/backend/commands/indexcmds.c
M src/include/catalog/index.h
postgres_fdw: Inherit the local transaction's access/deferrable modes.
commit : de28140ded8d4ba00faf905ec3530ffeb8a34a53
author : Etsuro Fujita <efujita@postgresql.org>
date : Sun, 5 Apr 2026 18:55:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Sun, 5 Apr 2026 18:55:00 +0900 READ ONLY transactions should prevent modifications to foreign data as
well as local data, but postgres_fdw transactions declared as READ ONLY
that reference foreign tables mapped to a remote view executing volatile
functions would modify data on remote servers, as it would open remote
transactions in READ WRITE mode.
Similarly, DEFERRABLE transactions should not abort due to a
serialization failure even when accessing foreign data, but postgres_fdw
transactions declared as DEFERRABLE would abort due to that failure in a
remote server, as it would open remote transactions in NOT DEFERRABLE
mode.
To fix, modify postgres_fdw to open remote transactions in the same
access/deferrable modes as the local transaction. This commit also
modifies it to open remote subtransactions in the same access mode as
the local subtransaction.
This commit changes the behavior of READ ONLY/DEFERRABLE transactions
using postgres_fdw; in particular, it doesn't allow the READ ONLY
transactions to modify data on remote servers anymore, so such
transactions should be redeclared as READ WRITE or rewritten using other
tools like dblink. The release notes should note this as an
incompatibility.
These issues exist since the introduction of postgres_fdw, but to avoid
the incompatibility in the back branches, fix them in master only.
Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAPmGK16n_hcUUWuOdmeUS%2Bw4Q6dZvTEDHb%3DOP%3D5JBzo-M3QmpQ%40mail.gmail.com
Discussion: https://postgr.es/m/E1uLe9X-000zsY-2g%40gemulon.postgresql.org 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
M src/backend/access/transam/xact.c
M src/include/access/xact.h
aio: Simplify pgaio_worker_submit().
commit : fc44f106657a0b2f55147d8309a676a6ac555a95
author : Thomas Munro <tmunro@postgresql.org>
date : Sun, 5 Apr 2026 18:01:10 +1200
committer: Thomas Munro <tmunro@postgresql.org>
date : Sun, 5 Apr 2026 18:01:10 +1200 Merge pgaio_worker_submit_internal() and pgaio_worker_submit(). The
separation didn't serve any purpose.
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2Bm4xV0LMoH2c%3DoRAdEXuCnh%2BtGBTWa7uFeFMGgTLAw%2BQ%40mail.gmail.com M src/backend/storage/aio/method_worker.c
read_stream: Only increase read-ahead distance when waiting for IO
commit : f63ca3379025ee4547865182da6cae14aec35d58
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400 This avoids increasing the distance to the maximum in cases where the I/O
subsystem is already keeping up. This turns out to be important for
performance for two reasons:
- Pinning a lot of buffers is not cheap. If additional pins allow us to avoid
IO waits, it's definitely worth it, but if we can already do all the
necessary readahead at a distance of 16, reading ahead 512 buffers can
increase the CPU overhead substantially. This is particularly noticeable
when the to-be-read blocks are already in the kernel page cache.
- If the read stream is read to completion, reading in data earlier than
needed is of limited consequences, leaving aside the CPU costs mentioned
above. But if the read stream will not be fully consumed, e.g. because it is
on the inner side of a nested loop join, the additional IO can be a serious
performance issue. This is not that commonly a problem for current read
stream users, but the upcoming work, to use a read stream to fetch table
pages as part of an index scan, frequently encounters this.
Note that this commit would have substantial performance downsides without
earlier commits:
- Commit 6e36930f9aa, which avoids decreasing the readahead distance when
there was recent IO, is crucial, as otherwise we very often would end up not
reading ahead aggressively enough anymore with this commit, due to
increasing the distance less often.
- "read stream: Split decision about look ahead for AIO and combining" is
important as we would otherwise not perform IO combining when the IO
subsystem can keep up.
- "aio: io_uring: Trigger async processing for large IOs" is important to
continue to benefit from memory copy parallelism when using fewer IOs.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Tested-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CA+hUKGL2PhFyDoqrHefqasOnaXhSg48t1phs3VM8BAdrZqKZkw@mail.gmail.com M src/backend/storage/aio/read_stream.c
read stream: Split decision about look ahead for AIO and combining
commit : 8ca147d582a5a9f3345478654408c46314758b50
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400 In a subsequent commit the read-ahead distance will only be increased when
waiting for IO. Without further work that would cause a regression: As IO
combining and read-ahead are currently controlled by the same mechanism, we
would end up not allowing IO combining when never needing to wait for IO (as
the distance ends up too small to allow for full sized IOs), which can
increase CPU overhead. A typical reason to not have to wait for IO completion
at a low look-ahead distance is use of io_uring with the to-be-read data in
the page cache. But even with worker the IO submission rate may be low enough
for the worker to keep up.
One might think that we could just always perform IO combining, but doing so
at the start of a scan can cause performance regressions:
1) Performing a large IO commonly has a higher latency than smaller IOs. That
is not a problem once reading ahead far enough, but at the start of a stream
it can lead to longer waits for IO completion.
2) Sometimes read streams will not be read to completion. Immediately starting
with full sized IOs leads to more wasted effort. This is not commonly an
issue with existing read stream users, but the upcoming use of read streams
to fetch table pages as part of an index scan frequently encounters this.
Solve this issue by splitting ReadStream->distance into ->combine_distance and
->readahead_distance. Right now they are increased/decreased at the same time,
but that will change in the next commit.
One of the comments in read_stream_should_look_ahead() refers to a motivation
that only really exists as of the next commit, but without it the code doesn't
make sense on its own.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CA+hUKGL2PhFyDoqrHefqasOnaXhSg48t1phs3VM8BAdrZqKZkw@mail.gmail.com M src/backend/storage/aio/read_stream.c
read_stream: Move logic about IO combining & issuing to helpers
commit : 434dab76ba76fba5dacab2dc695b6b3d5df8315b
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400 The long if statements were hard to read and hard to document. Splitting them
into inline helpers makes it much easier to explain each part separately.
This is done in preparation for making the logic more complicated...
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu M src/backend/storage/aio/read_stream.c
aio: io_uring: Trigger async processing for large IOs
commit : a9ee66881744d67193b56964b8398e5f83130956
author : Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400
committer: Andres Freund <andres@anarazel.de>
date : Sun, 5 Apr 2026 00:43:54 -0400 io_method=io_uring has a heuristic to trigger asynchronous processing of IOs
once the IO depth is a bit larger. That heuristic is important when doing
buffered IO from the kernel page cache, to allow parallelizing of the memory
copy, as otherwise io_method=io_uring would be a lot slower than
io_method=worker in that case.
An upcoming commit will make read_stream.c only increase the read-ahead
distance if we needed to wait for IO to complete. If to-be-read data is in the
kernel page cache, io_uring will synchronously execute IO, unless the IO is
flagged as async. Therefore the aforementioned change in read_stream.c
heuristic would lead to a substantial performance regression with io_uring
when data is in the page cache, as we would never reach a deep enough queue to
actually trigger the existing heuristic.
Parallelizing the copy from the page cache is mainly important when doing a
lot of IO, which commonly is only possible when doing largely sequential IO.
The reason we don't just mark all io_uring IOs as asynchronous is that the
dispatch to a kernel thread has overhead. This overhead is mostly noticeable
with small random IOs with a low queue depth, as in that case the gain from
parallelizing the memory copy is small and the latency cost high.
The facts from the two prior paragraphs show a way out: Use the size of the IO
in addition to the depth of the queue to trigger asynchronous processing.
One might think that just using the IO size might be enough, but
experimentation has shown that not to be the case - with deep look-ahead
distances being able to parallelize the memory copy is important even with
smaller IOs.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CA+hUKGL2PhFyDoqrHefqasOnaXhSg48t1phs3VM8BAdrZqKZkw@mail.gmail.com M src/backend/storage/aio/method_io_uring.c
Fix unused function warning on Arm platforms
commit : 2849fe4c978540111748208ba96af7808602c567
author : John Naylor <john.naylor@postgresql.org>
date : Sun, 5 Apr 2026 08:49:47 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Sun, 5 Apr 2026 08:49:47 +0700 Guard definition pg_pmull_available() on compile-time availability
of PMULL. Oversight in fbc57f2bc. In passing, remove "inline" hint
for consistency.
Reported-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/f153d5a4-a9be-4211-b0b2-7e99b56d68d5@vondra.me M src/port/pg_crc32c_armv8_choose.c
Modernize struct declarations in snapbuild.h
commit : 69c11f0545a027fdcb32254b546a0cd431823e4f
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sun, 5 Apr 2026 00:21:53 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sun, 5 Apr 2026 00:21:53 +0200 Just a cosmetic cleanup. M src/include/replication/snapbuild.h
Make index_concurrently_create_copy more general
commit : 33bf7318f94ce730563eb5ed95ad6c61d6e6f7a6
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 4 Apr 2026 20:38:26 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 4 Apr 2026 20:38:26 +0200 Also rename it to index_create_copy. Add a 'boolean concurrent' option,
and make it work for both cases: in concurrent mode, just create the
catalog entries; caller is responsible for the actual building later.
In non-concurrent mode, the index is built right away.
This allows it to be reused for other purposes -- specifically, for
concurrent REPACK.
(With the CONCURRENTLY option, REPACK cannot simply swap the heap file and
rebuild its indexes. Instead, it needs to build a separate set of
indexes, including their system catalog entries, *before* the actual
swap, to reduce the time AccessExclusiveLock needs to be held for. This
approach is different from what CREATE INDEX CONCURRENTLY does.)
Per a suggestion from Mihail Nikalayeu.
Author: Antonin Houska <ah@cybertec.at>
Reviewed-by: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/41104.1754922120@localhost M src/backend/catalog/index.c
M src/backend/commands/indexcmds.c
M src/include/catalog/index.h
heapam: Keep buffer pins across index scan resets.
commit : 2d3490dd99f04d97202eb37f103f929f3dc33162
author : Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 13:49:37 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 13:49:37 -0400 Avoid dropping the heap page pin (xs_cbuf) and visibility map pin
(xs_vmbuffer) within heapam_index_fetch_reset. Retaining these pins
saves cycles during certain nested loop joins and merge joins that
frequently restore a saved mark: cases where the next tuple fetched
after a reset often falls on the same heap page will now avoid the cost
of repeated pinning and unpinning.
Avoiding dropping the scan's heap page buffer pin is preparation for an
upcoming patch that will add I/O prefetching to index scans. Testing of
that patch (which makes heapam tend to pin more buffers concurrently
than was typical before now) shows that the aforementioned cases get a
small but clearly measurable benefit from this optimization.
Upcoming work to add a slot-based table AM interface for index scans
(which is further preparation for prefetching) will move VM checks for
index-only scans out of the executor and into heapam. That will expand
the role of xs_vmbuffer to include VM lookups for index-only scans (the
field won't just be used for setting pages all-visible during on-access
pruning via the enhancement recently introduced by commit b46e1e54).
Avoiding dropping the xs_vmbuffer pin will preserve the historical
behavior of nodeIndexonlyscan.c, which always kept this pin on a rescan;
that aspect of this commit isn't really new.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wz=g=JTSyDB4UtB5su2ZcvsS7VbP+ZMvvaG6ABoCb+s8Lw@mail.gmail.com M src/backend/access/heap/heapam_indexscan.c
M src/backend/access/index/indexam.c
Remove unnecessary #include "spin.h" from shmem.h
commit : fda530013282de284b1352ad310c2c53ead8ba78
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 20:22:04 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 20:22:04 +0300 Commit 6b8238cb6a removed the last usage of slock_t from the
file. proc.c was relying the indirect #include, so add it to proc.c
directly. M src/include/storage/proc.h
M src/include/storage/shmem.h
heapam: Track heap block in IndexFetchHeapData.
commit : c7d09595e46ff513ae0a23ae80e58871a321174f
author : Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 11:45:33 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 11:45:33 -0400 Add an explicit BlockNumber field (xs_blk) to IndexFetchHeapData that
tracks which heap block is currently pinned in xs_cbuf.
heapam_index_fetch_tuple now uses xs_blk to determine when buffer
switching is needed, replacing the previous approach that compared
buffer identities via ReleaseAndReadBuffer on every non-HOT-chain call.
This is preparatory work for an upcoming commit that will add index
prefetching using a read stream. Delegating the release of a currently
pinned buffer to ReleaseAndReadBuffer won't work anymore -- at least not
when the next buffer that the scan needs to pin is one returned by
read_stream_next_buffer (not a buffer returned by ReadBuffer).
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wz=g=JTSyDB4UtB5su2ZcvsS7VbP+ZMvvaG6ABoCb+s8Lw@mail.gmail.com M src/backend/access/heap/heapam_indexscan.c
M src/include/access/heapam.h
Move heapam_handler.c index scan code to new file.
commit : a29fdd6c8d816af0d042491a79c8ec1a60272c06
author : Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 11:30:41 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 11:30:41 -0400 Move the heapam index fetch callbacks (index_fetch_begin,
index_fetch_reset, index_fetch_end, and index_fetch_tuple) into a new
dedicated file. Also move heap_hot_search_buffer over. This is a
purely mechanical move with no functional impact.
Upcoming work to add a slot-based table AM interface for index scans
will substantially expand this code. Keeping it in heapam_handler.c
would clutter a file whose primary role is to wire up the TableAmRoutine
callbacks. Bitmap heap scans and sequential scans would benefit from
similar separation in the future.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/bmbrkiyjxoal6o5xadzv5bveoynrt3x37wqch7w3jnwumkq2yo@b4zmtnrfs4mh M src/backend/access/heap/Makefile
M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
A src/backend/access/heap/heapam_indexscan.c
M src/backend/access/heap/meson.build
M src/include/access/heapam.h
Rename heapam_index_fetch_tuple argument for clarity.
commit : 1adff1a0c558ecaef4fbe4cf343c426a59414749
author : Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 11:30:05 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sat, 4 Apr 2026 11:30:05 -0400 Rename heapam_index_fetch_tuple's call_again argument to heap_continue,
for consistency with the pointed-to variable name (IndexScanDescData's
xs_heap_continue field).
Preparation for an upcoming commit that will move index scan related
heapam functions into their own file.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/bmbrkiyjxoal6o5xadzv5bveoynrt3x37wqch7w3jnwumkq2yo@b4zmtnrfs4mh M src/backend/access/heap/heapam_handler.c
Fix indentation
commit : 519acd1be59e407a62dbe6a5240d9d1dcb8cd062
author : John Naylor <john.naylor@postgresql.org>
date : Sat, 4 Apr 2026 21:48:58 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Sat, 4 Apr 2026 21:48:58 +0700 Per buildfarm member koel M src/port/pg_crc32c_armv8.c
Compute CRC32C on ARM using the Crypto Extension where available
commit : fbc57f2bc2ee498958a4c5326002af39dd99c90b
author : John Naylor <john.naylor@postgresql.org>
date : Sat, 4 Apr 2026 20:47:01 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Sat, 4 Apr 2026 20:47:01 +0700 In similar vein to commit 3c6e8c123, the ARMv8 cryptography extension
has 64x64 -> 128-bit carryless multiplication instructions suitable
for computing CRC. This was tested to be around twice as fast as
scalar CRC instructions for longer inputs.
We now do a runtime check, even for builds that target "armv8-a+crc",
but those builds can still use a direct call for constant inputs,
which we assume are short.
As for x86, the MIT-licensed implementation was generated with the
"generate" program from
https://github.com/corsix/fast-crc32/
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/CANWCAZaKhE+RD5KKouUFoxx1EbUNrNhcduM1VQ=DkSDadNEFng@mail.gmail.com M config/c-compiler.m4
M configure
M configure.ac
M meson.build
M src/include/pg_config.h.in
M src/include/port/pg_crc32c.h
M src/port/meson.build
M src/port/pg_crc32c_armv8.c
M src/port/pg_crc32c_armv8_choose.c
Use AVX2 for calculating page checksums where available
commit : 5e13b0f240397b210a0af11f83204d0b4f1713c2
author : John Naylor <john.naylor@postgresql.org>
date : Sat, 4 Apr 2026 18:07:15 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Sat, 4 Apr 2026 18:07:15 +0700 We already rely on autovectorization for computing page checksums,
but on x86 we can get a further several-fold performance increase by
annotating pg_checksum_block() with a function target attribute for
the AVX2 instruction set extension. Not only does that use 256-bit
registers, it can also use vector multiplication rather than the
vector shifts and adds used in SSE2.
Similar to other hardware-specific paths, we set a function pointer
on first use. We don't bother to avoid this on platforms without AVX2
since the overhead of indirect calls doesn't matter for multi-kilobyte
inputs. However, we do arrange so that only core has the function
pointer mechanism. External programs will continue to build a normal
static function and don't need to be aware of this.
This matters most when using io_uring since in that case the checksum
computation is not done in parallel by IO workers.
Co-authored-by: Matthew Sterrett <matthewsterrett2@gmail.com>
Co-authored-by: Andrew Kim <andrew.kim@intel.com>
Reviewed-by: Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>
Tested-by: Ants Aasma <ants.aasma@cybertec.at>
Tested-by: Stepan Neretin <slpmcf@gmail.com> (earlier version)
Discussion: https://postgr.es/m/CA+vA85_5GTu+HHniSbvvP+8k3=xZO=WE84NPwiKyxztqvpfZ3Q@mail.gmail.com
Discussion: https://postgr.es/m/20250911054220.3784-1-root%40ip-172-31-36-228.ec2.internal M config/c-compiler.m4
M configure
M configure.ac
M meson.build
M src/backend/storage/page/checksum.c
M src/include/pg_config.h.in
M src/include/port/pg_cpu.h
A src/include/storage/checksum_block.inc.c
M src/include/storage/checksum_impl.h
M src/port/pg_cpu_x86.c
Add missing shmem size estimate for fast-path locking struct
commit : c06443063f01b0996a16dea77462ac6b31eb181d
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 11:46:11 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 11:46:11 +0300 It's been missing ever since fast-path locking was introduced. It's a
small discrepancy, about 4 kB, but let's be tidy. This doesn't seem
worth backpatching, however; in stable branches we were less precise
about the estimates and e.g. added a 10% margin to the hash table
estimates, which is usually much bigger than this discrepancy. M src/backend/storage/lmgr/lock.c
More tar portability adjustments.
commit : bab656bb87b0ffed92407f93d0d4a9e4d18c0c5c
author : Thomas Munro <tmunro@postgresql.org>
date : Sat, 4 Apr 2026 11:13:18 +1300
committer: Thomas Munro <tmunro@postgresql.org>
date : Sat, 4 Apr 2026 11:13:18 +1300 For the three implementations that have caused problems so far:
* GNU and BSD (libarchive) tar both understand --format=ustar
* ustar doesn't support large UID/GID values, so set them to 0 to
avoid a hard error from at least GNU tar
* OpenBSD tar needs -F ustar, and it appears to warn but carry
on with "nobody" if a UID is too large
* -f /dev/null is a more portable way to throw away the output, since
the default destination might be a tape device depending on build
options that a distribution might change
* Windows ships BSD tar but lacks /dev/null, so ask perl for its name
Based on their manuals, the other two implementations the tests are
likely to encounter in the wild don't seem to need any special handling:
* Solaris/illumos tar uses ustar and replaces large UIDs with 60001
* AIX tar uses ustar (unless --format=pax) and truncates large UIDs
Backpatch-through: 18
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>
Co-authored-by: Sami Imseih <samimseih@gmail.com> (large UIDs)
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (earlier version)
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com> (OpenBSD)
Reviewed-by: Andrew Dunstan <andrew@dunslane.net> (Windows)
Discussion: https://postgr.es/m/3676229.1775170250%40sss.pgh.pa.us
Discussion: https://postgr.es/m/CAA5RZ0tt89MgNi4-0F4onH%2B-TFSsysFjMM-tBc6aXbuQv5xBXw%40mail.gmail.com M src/test/perl/PostgreSQL/Test/Utils.pm
Remove HASH_DIRSIZE, always use the default algorithm to select it
commit : 4953a25b7f3bb5a555342764231157c76e6acbac
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:28 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:28 +0300 It's not very useful to specify a non-standard directory size. The
HASH_DIRSIZE option was only used for shared memory hash tables, and
those always used hash_select_dirsize() to choose the size, which in
turn just uses the default algorithm anyway. That assumption was
ingrained in hash_estimate_size(), too.
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/storage/ipc/shmem.c
M src/backend/utils/hash/dynahash.c
M src/include/utils/hsearch.h
Allocate all parts of shmem hash table from a single contiguous area
commit : 9fe9ecd516b09434df59d6e7396d508f9c4477c8
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:25 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:25 +0300 Previously, the shared header (HASHHDR) and the directory were
allocated by the caller, and passed to hash_create(), while the actual
elements were allocated separately with ShmemAlloc(). After this
commit, all the memory needed by the header, the directory, and all
the elements is allocated using a single ShmemInitStruct() call, and
the different parts are carved out of that allocation. This way the
ShmemIndex entries (and thus pg_shmem_allocations) reflect the size of
the whole hash table, rather than just the directories.
Commit f5930f9a98 attempted this earlier, but it had to be reverted.
The new strategy is to let dynahash.c perform all the allocations with
the alloc function, but have the alloc function carve out the parts
from the one larger allocation. The shared header and the directory
are now also allocated with alloc calls, instead of passing the area
for those directly from the caller.
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/storage/ipc/shmem.c
M src/backend/utils/hash/dynahash.c
M src/include/utils/hsearch.h
M src/tools/pgindent/typedefs.list
Prevent shared memory hash tables from growing beyond initial size
commit : 999e9ebb51c920de270e23a5fe929441f073ad55
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:24 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:24 +0300 Set HASH_FIXED_SIZE on all shared memory hash tables, to prevent them
from growing after the initial allocation. It was always weirdly
indeterministic that if one hash table used up all the unused shared
memory, you could not use that space for other things anymore until
restart. We just got rid of that behavior for the LOCK and PROCLOCK
tables, but it's similarly weird for all other hash tables.
Increase SHMEM_INDEX_SIZE because we were already above the max size,
on that one, and it's now a hard limit.
Some callers of ShmemInitHash() still pass HASH_FIXED_SIZE, but that's
now unnecessary. They should perhaps now be removed, but it doesn't do
any harm either to pass it.
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/storage/ipc/shmem.c
M src/include/storage/shmem.h
Merge init and max size options on shmem hash tables
commit : 9ebe1c4f2c7cecd0fc2d02afd87a74f6ba44569e
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:20 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 4 Apr 2026 02:40:20 +0300 Replace the separate init and max size options with a single size
option. We didn't make much use of the feature, all callers except the
ones in wait_event.c already used the same size for both, and the hash
tables in wait_event.c are small so there's little harm in just
allocating them to the max size.
The only reason why you might want to not reserve the max size upfront
is to make the memory available for other hash tables to grow beyond
their max size. Letting hash tables grow much beyond their max size is
bad for performance, however, because we cannot resize the directory,
and we never had very much "wiggle room" to grow to anyway so you
couldn't really rely on it. We recently marked the LOCK and PROCLOCK
tables with HAS_FIXED_SIZE, so there's nothing left in core that would
benefit from more unallocated shared memory.
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M contrib/pg_stat_statements/pg_stat_statements.c
M src/backend/storage/buffer/buf_table.c
M src/backend/storage/ipc/shmem.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/predicate.c
M src/backend/utils/activity/wait_event.c
M src/include/storage/shmem.h
oauth: Let validators provide failure DETAILs
commit : d438a36591c58f60e0748b341855ec5519e1e3b4
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 3 Apr 2026 16:05:33 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 3 Apr 2026 16:05:33 -0700 At the moment, the only way for a validator module to report error
details on failure is to log them separately before returning from
validate_cb. Independently of that problem, the ereport() calls that we
make during validation failure partially duplicate some of the work of
auth_failed().
The end result is overly verbose and confusing for readers of the logs:
[768233] LOG: [my_validator] bad signature in bearer token
[768233] LOG: OAuth bearer authentication failed for user "jacob"
[768233] DETAIL: Validator failed to authorize the provided token.
[768233] FATAL: OAuth bearer authentication failed for user "jacob"
[768233] DETAIL: Connection matched file ".../pg_hba.conf" line ...
Solve both problems by making use of the existing logdetail pointer
that's provided by ClientAuthentication. Validator modules may set
ValidatorModuleResult->error_detail to override our default generic
message.
The end result looks something like
[242284] FATAL: OAuth bearer authentication failed for user "jacob"
[242284] DETAIL: [my_validator] bad signature in bearer token
Connection matched file ".../pg_hba.conf" line ...
Reported-by: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/202601241015.y5uvxd7oxnfs%40alvherre.pgsql M doc/src/sgml/oauth-validators.sgml
M src/backend/libpq/auth-oauth.c
M src/backend/libpq/auth.c
M src/include/libpq/oauth.h
M src/test/modules/oauth_validator/t/001_server.pl
M src/test/modules/oauth_validator/validator.c
Make data checksum tests more resilient for slow machines
commit : 0036232ba8fb282979cff16c8751a361cb85fe76
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Sat, 4 Apr 2026 00:25:07 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Sat, 4 Apr 2026 00:25:07 +0200 The test for re-running checksum enabling was only checking for the
data checksum state to transition to 'on', but didn't account for
the launcher process having had time to exit, thus getting an error
instead of the expected no-op. Adding a pg_stat_activity check for
the launcher exiting resolves the error, verified by inducing delay
in the launcher.
Also wrap a variable only used in injection point tests within the
correct USE macros to avoid warning for an unused variable.
All per the buildfarm.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Buildfarm
Discussion: https://postgr.es/m/1CB288C9-564B-4664-B096-C2F4377D17AB@yesql.se M src/test/modules/test_checksums/t/001_basic.pl
M src/test/modules/test_checksums/test_checksums.c
Add elevel parameter to relation_needs_vacanalyze().
commit : 01876ace13697163b3b8455e1c7e4140ecfcdb1a
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 3 Apr 2026 17:04:28 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 3 Apr 2026 17:04:28 -0500 This will be used in a follow-up commit to avoid emitting debug
logs from this function.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0s4xjMrB-VAnLccC7kY8d0-4806-Lsac-czJsdA1LXtAw%40mail.gmail.com M src/backend/postmaster/autovacuum.c
Teach relation_needs_vacanalyze() to always compute scores.
commit : 53b8ca6881a1578fc47db47a2754faba754a2b7c
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 3 Apr 2026 16:44:41 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 3 Apr 2026 16:44:41 -0500 Presently, this function only computes component scores when the
corresponding threshold is reached. A follow-up commit will add a
view that shows tables' autovacuum scores, and we anticipate that
users will want to use this view to discover tables that are
nearing autovacuum eligibility. This commit teaches this function
to always compute autovacuum scores, even when a threshold has not
been reached or autovacuum is disabled.
The restructuring in this commit revealed an interesting edge case.
If the table needs vacuuming for wraparound prevention and
autovacuum is disabled for it, we might still choose to analyze it.
It's not clear if this is intentional, but it has been this way for
nearly 20 years, so it seems best to avoid changing it without
further discussion.
Author: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0s4xjMrB-VAnLccC7kY8d0-4806-Lsac-czJsdA1LXtAw%40mail.gmail.com M src/backend/postmaster/autovacuum.c
Online enabling and disabling of data checksums
commit : f19c0eccae9680f5785b11cdc58ef571998caec9
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 3 Apr 2026 22:58:51 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Fri, 3 Apr 2026 22:58:51 +0200 This allows data checksums to be enabled, or disabled, in a running
cluster without restricting access to the cluster during processing.
Data checksums could prior to this only be enabled during initdb or
when the cluster is offline using the pg_checksums app. This commit
introduce functionality to enable, or disable, data checksums while
the cluster is running regardless of how it was initialized.
A background worker launcher process is responsible for launching a
dynamic per-database background worker which will mark all buffers
dirty for all relation with storage in order for them to have data
checksums calculated on write. Once all relations in all databases
have been processed, the data_checksums state will be set to on and
the cluster will at that point be identical to one which had data
checksums enabled during initialization or via offline processing.
When data checksums are being enabled, concurrent I/O operations
from backends other than the data checksums worker will write the
checksums but not verify them on reading. Only when all backends
have absorbed the procsignalbarrier for setting data_checksums to
on will they also start verifying checksums on reading. The same
process is repeated during disabling; all backends write checksums
but do not verify them until the barrier for setting the state to
off has been absorbed by all. This in-progress state is used to
ensure there are no false negatives (or positives) due to reading
a checksum which is not in sync with the page.
A new testmodule, test_checksums, is introduced with an extensive
set of tests covering both online and offline data checksum mode
changes. The tests which run concurrent pgbdench during online
processing are gated behind the PG_TEST_EXTRA flag due to being
very expensive to run. Two levels of PG_TEST_EXTRA flags exist
to turn on a subset of the expensive tests, or the full suite of
multiple runs.
This work is based on an earlier version of this patch which was
reviewed by among others Heikki Linnakangas, Robert Haas, Andres
Freund, Tomas Vondra, Michael Banck and Andrey Borodin. During
the work on this new version, Tomas Vondra has given invaluable
assistance with not only coding and reviewing but very in-depth
testing.
Author: Daniel Gustafsson <daniel@yesql.se>
Author: Magnus Hagander <magnus@hagander.net>
Co-authored-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CABUevExz9hUUOLnJVr2kpw9Cx=o4MCr1SVKwbupzuxP7ckNutA@mail.gmail.com
Discussion: https://postgr.es/m/20181030051643.elbxjww5jjgnjaxg@alap3.anarazel.de
Discussion: https://postgr.es/m/CABUevEwE3urLtwxxqdgd5O2oQz9J717ZzMbh+ziCSa5YLLU_BA@mail.gmail.com M doc/src/sgml/config.sgml
M doc/src/sgml/func/func-admin.sgml
M doc/src/sgml/glossary.sgml
M doc/src/sgml/images/Makefile
A doc/src/sgml/images/datachecksums.gv
A doc/src/sgml/images/datachecksums.svg
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/regress.sgml
M doc/src/sgml/wal.sgml
M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/xlog.c
M src/backend/backup/basebackup.c
M src/backend/bootstrap/bootstrap.c
M src/backend/catalog/system_views.sql
M src/backend/commands/dbcommands.c
M src/backend/postmaster/Makefile
M src/backend/postmaster/auxprocess.c
M src/backend/postmaster/bgworker.c
A src/backend/postmaster/datachecksum_state.c
M src/backend/postmaster/meson.build
M src/backend/postmaster/postmaster.c
M src/backend/replication/logical/decode.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/procsignal.c
M src/backend/storage/page/README
M src/backend/storage/page/bufpage.c
M src/backend/utils/activity/pgstat_backend.c
M src/backend/utils/activity/pgstat_io.c
M src/backend/utils/activity/wait_event_names.txt
M src/backend/utils/adt/pgstatfuncs.c
M src/backend/utils/init/miscinit.c
M src/backend/utils/init/postinit.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_checksums/pg_checksums.c
M src/bin/pg_controldata/pg_controldata.c
M src/bin/pg_upgrade/controldata.c
M src/bin/pg_waldump/t/001_basic.pl
M src/include/access/rmgrlist.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
M src/include/commands/progress.h
M src/include/miscadmin.h
A src/include/postmaster/datachecksum_state.h
M src/include/postmaster/proctypelist.h
M src/include/replication/decode.h
M src/include/storage/bufpage.h
M src/include/storage/checksum.h
M src/include/storage/lwlocklist.h
M src/include/storage/procsignal.h
M src/include/utils/backend_progress.h
M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_checksums/.gitignore
A src/test/modules/test_checksums/Makefile
A src/test/modules/test_checksums/README
A src/test/modules/test_checksums/meson.build
A src/test/modules/test_checksums/t/001_basic.pl
A src/test/modules/test_checksums/t/002_restarts.pl
A src/test/modules/test_checksums/t/003_standby_restarts.pl
A src/test/modules/test_checksums/t/004_offline.pl
A src/test/modules/test_checksums/t/005_injection.pl
A src/test/modules/test_checksums/t/006_pgbench_single.pl
A src/test/modules/test_checksums/t/007_pgbench_standby.pl
A src/test/modules/test_checksums/t/008_pitr.pl
A src/test/modules/test_checksums/t/009_fpi.pl
A src/test/modules/test_checksums/t/DataChecksums/Utils.pm
A src/test/modules/test_checksums/test_checksums–1.0.sql
A src/test/modules/test_checksums/test_checksums.c
A src/test/modules/test_checksums/test_checksums.control
M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/regress/expected/rules.out
M src/test/regress/expected/stats.out
M src/tools/pgindent/typedefs.list
Refactor relation_needs_vacanalyze().
commit : 8261ee24fe332a5042cd4bc3101b4fd99dee6a46
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 3 Apr 2026 14:03:12 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 3 Apr 2026 14:03:12 -0500 This commit adds an early return to this function, allowing us to
remove a level of indentation on a decent chunk of code. This is
preparatory work for follow-up commits that will add a new system
view to show tables' autovacuum scores.
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0s4xjMrB-VAnLccC7kY8d0-4806-Lsac-czJsdA1LXtAw%40mail.gmail.com M src/backend/postmaster/autovacuum.c
Change default of max_locks_per_transactions to 128
commit : 79534f90657c37c5238e5341a111dedd26d9c0fb
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:27:46 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:27:46 +0300 The previous commits reduced the amount of memory available for locks
by eliminating the "safety margins" and by settling the split between
LOCK and PROCLOCK tables at startup. The allocation is now more
deterministic, but it also means that you often hit one of the limits
sooner than before. To compensate for that, bump up
max_locks_per_transactions from 64 to 128. With that there is a little
more space in the both hash tables than what was the effective maximum
size for either table before the previous commits.
This only changes the default, so if you had changed
max_locks_per_transactions in postgresql.conf, you will still have
fewer locks available than before for the same setting value. This
should be noted in the release notes. A good rule of thumb is that if
you double max_locks_per_transactions, you should be able to get as
many locks as before.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/e07be2ba-856b-4ff5-8313-8b58b6b4e4d0@iki.fi M doc/src/sgml/config.sgml
M src/backend/utils/init/postinit.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/bin/pg_resetwal/pg_resetwal.c
Make the lock hash tables fixed-sized
commit : e1ad034809a4628b995ae458d0d56744ca3b5ff3
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:27:16 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:27:16 +0300 This prevents the LOCK table from "stealing" space that was originally
calculated for the PROLOCK table, and vice versa. That was weirdly
indeterministic so that if you e.g. took a lot of locks consuming all
the available shared memory for the LOCK table, subsequent
transactions that needed the more space for the PROCLOCK table would
fail, but if you restarted the system then the space would be
available for PROCLOCK again. Better to be strict and predictable,
even though that means that in many cases you can acquire far fewer
locks than before.
This also prevents the lock hash tables from using up the
general-purpose 100 kB reserve we set aside for "stuff that's too
small to bother estimating" in CalculateShmemSize(). We are pretty
good at accounting for everything nowadays, so we could probably make
that reservation smaller, but I'll leave that for another commit.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/e07be2ba-856b-4ff5-8313-8b58b6b4e4d0@iki.fi M src/backend/storage/lmgr/lock.c
Remove 10% safety margin from lock manager hash table estimates
commit : 3e854d2ff1a6ee1d9e0e01319ef41eb466f06c23
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:26:18 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:26:18 +0300 As the comment says, the hash table sizes are just estimates, but that
doesn't mean we need a "safety margin" here. hash_estimate_size()
estimates the needed size in bytes pretty accurately for the given
number of elements, so if we wanted room for more elements in the
table, we should just use larger max_table_size in the
hash_estimate_size() call.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/e07be2ba-856b-4ff5-8313-8b58b6b4e4d0@iki.fi M src/backend/storage/lmgr/lock.c
Remove bogus "safety margin" from predicate.c shmem estimates
commit : feb03dfecdc9810619bc94793be3257a487a669f
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:25:57 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 3 Apr 2026 20:25:57 +0300 The 10% safety margin was copy-pasted from lock.c when the predicate
locking code was originally added. However, we later (commit
7c797e7194) added the HASH_FIXED_SIZE flag to the hash tables, which
means that they cannot actually use the safety margin that we're
calculating for them.
The extra memory was mainly used by the main lock manager, which is
the only shmem hash table of non-trivial size that does not use the
HASH_FIXED_SIZE flag. If we wanted to have more space for the lock
manager, we should reserve it directly in lock.c. After this commit,
the lock manager will just have less memory available than before.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/e07be2ba-856b-4ff5-8313-8b58b6b4e4d0@iki.fi M src/backend/storage/lmgr/predicate.c
Optimize fast-path FK checks with batched index probes
commit : b7b27eb41a5cc0b45a1a9ce5c1cde5883d7bc358
author : Amit Langote <amitlan@postgresql.org>
date : Fri, 3 Apr 2026 14:33:53 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Fri, 3 Apr 2026 14:33:53 +0900 Instead of probing the PK index on each trigger invocation, buffer
FK rows in a new per-constraint cache entry (RI_FastPathEntry) and
flush them as a batch.
On each trigger invocation, the new ri_FastPathBatchAdd() buffers
the FK row in RI_FastPathEntry. When the buffer fills (64 rows)
or the trigger-firing cycle ends, the new ri_FastPathBatchFlush()
probes the index for all buffered rows, sharing a single
CommandCounterIncrement, snapshot, permission check, and security
context switch across the batch, rather than repeating each per row
as the SPI path does. Per-flush CCI is safe because all AFTER
triggers for the buffered rows have already fired by flush time.
For single-column foreign keys, the new ri_FastPathFlushArray()
builds an ArrayType from the buffered FK values (casting to the
PK-side type if needed) and constructs a scan key with the
SK_SEARCHARRAY flag. The index AM sorts and deduplicates the array
internally, then walks matching leaf pages in one ordered traversal
instead of descending from the root once per row. A matched[] bitmap
tracks which batch items were satisfied; the first unmatched item is
reported as a violation. Multi-column foreign keys fall back to
per-row probing via the new ri_FastPathFlushLoop().
The fast path introduced in the previous commit (2da86c1ef9) yields
~1.8x speedup. This commit adds ~1.6x on top of that, for a combined
~2.9x speedup over the unpatched code (int PK / int FK, 1M rows, PK
table and index cached in memory).
FK tuples are materialized via ExecCopySlotHeapTuple() into a new
purpose-specific memory context (flush_cxt), child of
TopTransactionContext, which is also used for per-flush transient
work: cast results, the search array, and index scan allocations.
It is reset after each flush and deleted in teardown.
The PK relation, index, tuple slots, and fast-path metadata are
cached in RI_FastPathEntry across trigger invocations within a
trigger-firing batch, avoiding repeated open/close overhead. The
snapshot and IndexScanDesc are taken fresh per flush. The entry is
not subject to cache invalidation: cached relations are held with
locks for the transaction duration, and the entry's lifetime is
bounded by the trigger-firing cycle.
Lifecycle management for RI_FastPathEntry relies on three new
mechanisms:
- AfterTriggerBatchCallback: A new general-purpose callback
mechanism in trigger.c. Callbacks registered via
RegisterAfterTriggerBatchCallback() fire at the end of each
trigger-firing batch (AfterTriggerEndQuery for immediate
constraints, AfterTriggerFireDeferred at COMMIT, and
AfterTriggerSetState for SET CONSTRAINTS IMMEDIATE). The RI
code registers ri_FastPathEndBatch as a batch callback.
- Batch callbacks only fire at the outermost query level
(checked inside FireAfterTriggerBatchCallbacks), so nested
queries from SPI inside other AFTER triggers do not tear down
the cache mid-batch.
- XactCallback: ri_FastPathXactCallback NULLs the static cache
pointer at transaction end, handling the abort path where the
batch callback never fired.
- SubXactCallback: ri_FastPathSubXactCallback NULLs the static
cache pointer on subtransaction abort, preventing the batch
callback from accessing already-released resources.
- AfterTriggerBatchIsActive(): A new exported accessor that
returns true when afterTriggers.query_depth >= 0. During
ALTER TABLE ... ADD FOREIGN KEY validation, RI triggers are
called directly outside the after-trigger framework, so batch
callbacks would never fire. The fast-path code uses this to
fall back to the non-cached per-invocation path in that
context.
ri_FastPathEndBatch() flushes any partial batch before tearing
down cached resources. Since the FK relation may already be
closed by flush time (e.g. for deferred constraints at COMMIT),
it reopens the relation using entry->fk_relid if needed.
The existing ALTER TABLE validation path bypasses batching and
continues to call ri_FastPathCheck() directly per row, because
RI triggers are called outside the after-trigger framework there
and batch callbacks would never fire to flush the buffer.
Suggested-by: David Rowley <dgrowleyml@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Co-authored-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Tested-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CA+HiwqF4C0ws3cO+z5cLkPuvwnAwkSp7sfvgGj3yQ=Li6KNMqA@mail.gmail.com 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
jit: No backport::SectionMemoryManager for LLVM 22.
commit : be21341e13d996b54ff8a2f1f9c8f4f1b63fc9ea
author : Thomas Munro <tmunro@postgresql.org>
date : Fri, 3 Apr 2026 14:48:54 +1300
committer: Thomas Munro <tmunro@postgresql.org>
date : Fri, 3 Apr 2026 14:48:54 +1300 LLVM 22 has the fix that we copied into our tree in commit 9044fc1d and
a new function to reach it[1][2], so we only need to use our copy for
Aarch64 + LLVM < 22. The only change to the final version that our copy
didn't get is a new LLVM_ABI macro, but that isn't appropriate for us.
Our copy is hopefully now frozen and would only need maintenance if bugs
are found in the upstream code.
Non-Aarch64 systems now also use the new API with LLVM 22. It allocates
all sections with one contiguous mmap() instead of one per
section. We could have done that earlier, but commit 9044fc1d wanted to
limit the blast radius to the affected systems. We might as well
benefit from that small improvement everywhere now that it is available
out of the box.
We can't delete our copy until LLVM 22 is our minimum supported version,
or we switch to the newer JITLink API for at least Aarch64.
[1] https://github.com/llvm/llvm-project/pull/71968
[2] https://github.com/llvm/llvm-project/pull/174307
Backpatch-through: 14
Discussion: https://postgr.es/m/CA%2BhUKGJTumad75o8Zao-LFseEbt%3DenbUFCM7LZVV%3Dc8yg2i7dg%40mail.gmail.com M src/backend/jit/llvm/SectionMemoryManager.cpp
M src/backend/jit/llvm/llvmjit.c
M src/include/jit/SectionMemoryManager.h
M src/include/jit/llvmjit_backport.h
Further harden tests that might use not-so-compatible tar versions.
commit : ebba64c08d965550b2d034ee931a27fdf2de56b7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 2 Apr 2026 17:21:18 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 2 Apr 2026 17:21:18 -0400 Buildfarm testing shows that OpenSUSE (and perhaps related platforms?)
configures GNU tar in such a way that it'll archive sparse WAL files
by default, thus triggering the pax-extension detection code added by
bc30c704a. Thus, we need something similar to 852de579a but for
GNU tar's option set. "--format=ustar" seems to do the trick.
Moreover, the buildfarm shows that pg_verifybackup's 003_corruption.pl
test script is also triggering creation of pax-format tar files on
that platform. We had not noticed because those test cases all fail
(intentionally) before getting to the point of trying to verify WAL
data.
Since that means two TAP scripts need this option-selection logic, and
plausibly more will do so in future, factor it out into a subroutine
in Test::Utils. We also need to back-patch the 003_corruption.pl fix
into v18, where it's also failing.
While at it, clean up some places where guards for $tar being empty
or undefined were incomplete or even outright backwards. Presumably,
we missed noticing because the set of machines that run TAP tests
and don't have tar installed is empty. But if we're going to try
to handle that scenario, we should do it correctly.
Reported-by: Tomas Vondra <tomas@vondra.me>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/02770bea-b3f3-4015-8a43-443ae345379c@vondra.me
Backpatch-through: 18 M src/bin/pg_verifybackup/t/003_corruption.pl
M src/bin/pg_waldump/t/001_basic.pl
M src/test/perl/PostgreSQL/Test/Utils.pm
Add additional jsonpath string methods
commit : bd4f879a9cdd11b6b683cea0ea51d7c27a8f1153
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 2 Apr 2026 15:07:33 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 2 Apr 2026 15:07:33 -0400 Add the following jsonpath methods:
* l/r/btrim()
* lower(), upper()
* initcap()
* replace()
* split_part()
Each simply dispatches to the standard string processing functions.
These depend on the locale, but since it's set at `initdb`, they can be
considered immutable and therefore allowed in any jsonpath expression.
Author: Florents Tselai <florents.tselai@gmail.com>
Co-authored-by: David E. Wheeler <david@justatheory.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CA+v5N40sJF39m0v7h=QN86zGp0CUf9F1WKasnZy9nNVj_VhCZQ@mail.gmail.com M doc/src/sgml/func/func-json.sgml
M src/backend/utils/adt/jsonpath.c
M src/backend/utils/adt/jsonpath_exec.c
M src/backend/utils/adt/jsonpath_gram.y
M src/backend/utils/adt/jsonpath_scan.l
M src/include/utils/jsonpath.h
M src/test/regress/expected/jsonb_jsonpath.out
M src/test/regress/expected/jsonpath.out
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/jsonb_jsonpath.sql
M src/test/regress/sql/jsonpath.sql
M src/test/regress/sql/sqljson_queryfuncs.sql
Rename jsonpath method arg tokens
commit : a35c9d524ed0a225894c45a33017a82cd8bb6680
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 2 Apr 2026 15:07:24 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 2 Apr 2026 15:07:24 -0400 This is just cleanup in the jsonpath grammar.
Rename the `csv_` tokens to `int_`, because they represent signed or
unsigned integers, as follows:
* `csv_elem` => `int_elem`
* `csv_list` => `int_list`
* `opt_csv_list` => `opt_int_list`
Rename the `datetime_precision` tokens to `uint_arg`, as they represent
unsigned integers and will be useful for other methods in the future, as
follows:
* `datetime_precision` => `uint_elem`
* `opt_datetime_precision` => `opt_uint_arg`
Rename the `datetime_template` tokens to `str_arg`, as they represent
strings and will be useful for other methods in the future, as follows:
* `datetime_template` => `str_elem`
* `opt_datetime_template` => `opt_str_arg`
Author: David E. Wheeler <david@justatheory.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CA+v5N40sJF39m0v7h=QN86zGp0CUf9F1WKasnZy9nNVj_VhCZQ@mail.gmail.com M src/backend/utils/adt/jsonpath_gram.y
Add target_relid parameter to pg_get_publication_tables().
commit : fd7a25af11e2cad4f48ffc4e50f18644e657ed53
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 2 Apr 2026 11:34:50 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 2 Apr 2026 11:34:50 -0700 When a tablesync worker checks whether a specific table is published,
it previously issued a query to the publisher calling
pg_get_publication_tables() and filtering the result by relid via a
WHERE clause. Because the function itself was fully evaluated before
the filter was applied, this forced the publisher to enumerate all
tables in the publication. For publications covering a large number of
tables, this resulted in expensive catalog scans and unnecessary CPU
overhead on the publisher.
This commit adds a new overloaded form of pg_get_publication_tables()
that accepts an array of publication names and a target table
OID. Instead of enumerating all published tables, it evaluates
membership for the specified relation via syscache lookups, using the
new is_table_publishable_in_publication() helper. This helper
correctly accounts for publish_via_partition_root, ALL TABLES with
EXCEPT clauses, schema publications, and partition inheritance, while
avoiding the overhead of building the complete published table list.
The existing VARIADIC array form of pg_get_publication_tables() is
preserved for backward compatibility. Tablesync workers use the new
two-argument form when connected to a publisher running PostgreSQL 19
or later.
Bump catalog version.
Reported-by: Marcos Pegoraro <marcos@f10.com.br>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Haoyan Wang <wanghaoyan20@163.com>
Discussion: https://postgr.es/m/CAB-JLwbBFNuASyEnZWP0Tck9uNkthBZqi6WoXNevUT6+mV8XmA@mail.gmail.com M src/backend/catalog/pg_publication.c
M src/backend/replication/logical/tablesync.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql
Harden astreamer tar parsing logic against archives it can't handle.
commit : bc30c704add5518fbd831a5ad3bc46990c4954cf
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 2 Apr 2026 12:20:26 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 2 Apr 2026 12:20:26 -0400 Previously, there was essentially no verification in this code that
the input is a tar file at all, let alone that it fits into the
subset of valid tar files that we can handle. This was exposed by
the discovery that we couldn't handle files that FreeBSD's tar
makes, because it's fairly aggressive about converting sparse WAL
files into sparse tar entries. To fix:
* Bail out if we find a pax extension header. This covers the
sparse-file case, and also protects us against scenarios where
the pax header changes other file properties that we care about.
(Eventually we may extend the logic to actually handle such
headers, but that won't happen in time for v19.)
* Be more wary about tar file type codes in general: do not assume
that anything that's neither a directory nor a symlink must be a
regular file. Instead, we just ignore entries that are none of the
three supported types.
* Apply pg_dump's isValidTarHeader to verify that a purported
header block is actually in tar format. To make this possible,
move isValidTarHeader into src/port/tar.c, which is probably where
it should have been since that file was created.
I also took the opportunity to const-ify the arguments of
isValidTarHeader and tarChecksum, and to use symbols not hard-wired
constants inside tarChecksum.
Back-patch to v18 but not further. Although this code exists inside
pg_basebackup in older branches, it's not really exposed in that
usage to tar files that weren't generated by our own code, so it
doesn't seem worth back-porting these changes across 3c9056981
and f80b09bac. I did choose to include a back-patch of 5868372bb
into v18 though, to minimize cosmetic differences between these
two branches.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/3049460.1775067940@sss.pgh.pa.us>
Backpatch-through: 18 M src/bin/pg_basebackup/astreamer_inject.c
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_archiver.h
M src/bin/pg_dump/pg_backup_tar.c
M src/bin/pg_verifybackup/astreamer_verify.c
M src/bin/pg_waldump/archive_waldump.c
M src/fe_utils/astreamer_file.c
M src/fe_utils/astreamer_tar.c
M src/include/fe_utils/astreamer.h
M src/include/pgtar.h
M src/port/tar.c
Remove redundant SetLatch() calls in interrupt handling functions
commit : 57706799186aa7971b78cab8911fb2604833de0f
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 2 Apr 2026 23:55:30 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 2 Apr 2026 23:55:30 +0900 Interrupt handling functions (e.g., HandleCatchupInterrupt(),
HandleParallelApplyMessageInterrupt()) are called only by
procsignal_sigusr1_handler(), which already calls SetLatch()
for the current process at the end of its processing.
Therefore, these interrupt handling functions do not need to
call SetLatch() themselves.
However, previously, some of these functions redundantly
called SetLatch(). This commit removes those unnecessary
calls.
While duplicate SetLatch() calls are redundant, they are
harmless, so this change is not backpatched.
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Discussion: https://postgr.es/m/CALj2ACWd5apddj6Cd885WwJ6LquYu_G81C4GoR4xSoDV1x-FEA@mail.gmail.com M src/backend/access/transam/parallel.c
M src/backend/commands/async.c
M src/backend/replication/logical/applyparallelworker.c
M src/backend/replication/walsender.c
M src/backend/storage/ipc/sinval.c
Check for __cpuidex and __get_cpuid_count separately
commit : effaa464afd355e8927bf430cfe6a0ddd2ee5695
author : John Naylor <john.naylor@postgresql.org>
date : Thu, 2 Apr 2026 19:39:57 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Thu, 2 Apr 2026 19:39:57 +0700 Previously we would only check for the availability of __cpuidex if
the related __get_cpuid_count was not available on a platform.
Future commits will need to access hypervisor information about
the TSC frequency of x86 CPUs. For that case __cpuidex is the only
viable option for accessing a high leaf (e.g. 0x40000000), since
__get_cpuid_count does not allow that.
__cpuidex is defined in cpuid.h for gcc/clang, but in intrin.h
for MSVC, so adjust tests to suite. We also need to cast the array
of unsigned ints to signed, since gcc (with -Wall) and clang emit
warnings otherwise.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: John Naylor <john.naylor@postgresql.org>
Discussion: https://postgr.es/m/CAP53PkyooCeR8YV0BUD_xC7oTZESHz8OdA=tP7pBRHFVQ9xtKg@mail.gmail.com M configure
M configure.ac
M meson.build
M src/port/pg_cpu_x86.c
Use command_ok for pg_regress calls in 002_pg_upgrade and 027_stream_regress
commit : bb6ae9707c1789c9d2036c9bbd35965a01e1b214
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:55:21 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:55:21 -0400 Now that command_ok() captures and displays failure output, use it
instead of system() plus manual diff-dumping in these two tests. This
simplifies both scripts and produces consistent, truncated output on
failure.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl M src/bin/pg_upgrade/t/002_pg_upgrade.pl
M src/test/recovery/t/027_stream_regress.pl
perl tap: Use croak instead of die in our helper modules
commit : b8da9869b850246ea047038fb974830269b83bcc
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:55:13 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:55:13 -0400 Replace die with croak throughout Cluster.pm and Utils.pm (except in
INIT blocks and signal handlers, where die is correct) so that error
messages report the test script's line number rather than the helper
module's.
Add @CARP_NOT in Utils.pm listing PostgreSQL::Test::Cluster, so that
when a Utils function is called through a Cluster.pm wrapper, croak
skips both packages and reports the actual test-script caller.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/perl/PostgreSQL/Test/Utils.pm
perl tap: Show die reason in TAP output
commit : 76540fdedf405c01518007bef3bdd96e0b96d390
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:54:41 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:54:41 -0400 Install a $SIG{__DIE__} handler in the INIT block of Utils.pm that emits
the die message as a TAP diagnostic. Previously, an unexpected die
(e.g. from safe_psql) produced only "no plan was declared" with no
indication of the actual error. The handler also calls done_testing()
to suppress that confusing message.
Dies during compilation ($^S undefined) and inside eval ($^S == 1) are
left alone.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl
Discussion: https://postgr.es/m/20220222181924.eehi7o4pmneeb4hm%40alap3.anarazel.de M src/test/perl/PostgreSQL/Test/Utils.pm
perl tap: Show failed command output
commit : 1402b8d2fc70faa5154cbc26cab8c4ac384880db
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:54:29 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:54:29 -0400 Capture stdout and stderr from command_ok() and command_fails() and emit
them as TAP diagnostics on failure. Output is truncated to the first
and last 30 lines per channel to avoid flooding.
A new helper _diag_command_output() is introduced in Utils.pm so
both functions share the same truncation and formatting logic.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl M src/bin/pg_ctl/t/001_start_stop.pl
M src/test/perl/PostgreSQL/Test/Utils.pm
pg_regress: Include diffs in TAP output
commit : 5720ae01436480c1dcdd34ece0c3d83b00844bca
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:53:49 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 1 Apr 2026 13:53:49 -0400 When pg_regress fails it is often tedious to find the actual diffs,
especially in CI where you must navigate a file browser. Emit the first
80 lines of the combined regression.diffs as TAP diagnostics so the
failure reason is visible directly in the test output.
The line limit is across all failing tests in a single pg_regress run to
avoid flooding when a crash causes every subsequent test to fail.
New DIAG_DETAIL / DIAG_END tap output types are added, mirroring the
existing NOTE_DETAIL / NOTE_END pair, so that long diff lines can be
emitted without spurious '#' prefixes on continuation lines.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl M src/test/regress/pg_regress.c
jit: Change the default to off.
commit : 7f8c88c2b872cb74882ab93dcb05529dab2a10bc
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Thu, 2 Apr 2026 12:53:18 +0200
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Thu, 2 Apr 2026 12:53:18 +0200 While JIT can speed up large analytical queries, it can also cause
serious performance issues on otherwise very fast queries. Compiling
and optimizing the expressions may be so expensive, it completely
outweighs the JIT benefits for shorter queries.
Ideally, we'd address this in the cost model, but the part deciding
whether to enable JIT for a query is rather simple, partially because we
don't have any reliable estimates of how expensive the LLVM compilation
and optimization is.
Sometimes seemingly unrelated changes (for example a couple additional
INSERTs into a table) increase the cost just enough to enable JIT,
resulting in a performance cliff.
Because of these risks, most large-scale deployments already disable JIT
by default. Notably, this includes all hyperscalers.
This commit changes our default to align with that established practice.
If we improve the JIT (be it better costing or cheaper execution), we
can consider enabling it by default again.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://postgr.es/m/DG1VZJEX1AQH.2EH4OKGRUDB71@jeltef.nl M doc/src/sgml/config.sgml
M src/backend/jit/jit.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
Test pg_stat_statements across crash restart
commit : 148fe2b05df592f5bca575b4e5e8a4253ea5a3ce
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 2 Apr 2026 13:33:06 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 2 Apr 2026 13:33:06 +0300 Add 'pg_stat_statements' to the crash restart test, to test that
shared memory and LWLock initialization works across crash restart in
a library listed in shared_preload_libraries. We had no test coverage
for that.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/test/recovery/t/013_crash_restart.pl
Doc: Fix oversight in commit 55cefadde8.
commit : 4441d6b2e44976b499bec334a8a7f087f9189974
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 2 Apr 2026 10:16:53 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 2 Apr 2026 10:16:53 +0530 pg_publication_rel.prrelid refers to sequences whereas stores information only of tables.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pv1UKR_bxmN7wcCCpQveHoYprvH-hbdFq8gsaH1Ye7B_w@mail.gmail.com M doc/src/sgml/catalogs.sgml
jit: Stop emitting lifetime.end for LLVM 22.
commit : de6b80e5ff4b92b1ca6e1fd3bf0f737f857f114d
author : Thomas Munro <tmunro@postgresql.org>
date : Thu, 2 Apr 2026 15:24:44 +1300
committer: Thomas Munro <tmunro@postgresql.org>
date : Thu, 2 Apr 2026 15:24:44 +1300 The lifetime.end intrinsic can now only be used for stack memory
allocated with alloca[1][2][3]. We use it to tell LLVM about the
lifetime of function arguments/isnull values that we keep in palloc'd
memory, so that it can avoid spilling registers to memory.
We might need to rearrange things and put them on the stack, but that'll
take some research. In the meantime, unbreak the build on LLVM 22.
[1] https://github.com/llvm/llvm-project/pull/149310
[2] https://llvm.org/docs/LangRef.html#llvm-lifetime-end-intrinsic
[3] https://llvm.org/docs/LangRef.html#i-alloca
Backpatch-through: 14
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com> (earlier attempt)
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com> (earlier attempt)
Reviewed-by: Andres Freund <andres@anarazel.de> (earlier attempt)
Discussion: https://postgr.es/m/CA%2BhUKGJTumad75o8Zao-LFseEbt%3DenbUFCM7LZVV%3Dc8yg2i7dg%40mail.gmail.com M src/backend/jit/llvm/llvmjit_expr.c
Fix nocachegetattr() so it again supports deforming cstrings
commit : 331d829e62dbb08112bb3a2c5770cd10ba0ffccb
author : David Rowley <drowley@postgresql.org>
date : Thu, 2 Apr 2026 14:11:17 +1300
committer: David Rowley <drowley@postgresql.org>
date : Thu, 2 Apr 2026 14:11:17 +1300 c456e3911 added various optimizations to the tuple deformation routines.
One optimization assumed that heap tuples would never contain cstrings.
That optimization also made its way into nocachegetattr(), which isn't
correct as ROW() types get formed into HeapTuples by ExecEvalRow() and
those can contain cstring Datums. nocachegetattr() gets used to extract
Datums from those tuples.
Here we remove the pg_assume(), which was there to instruct the compiler
to omit the attlen == -2 related code in att_addlength_pointer().
Author: David Rowley <dgrowleyml@gmail.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/80aeac57-8f50-4732-a5b4-c2373c3f8149@gmail.com M src/backend/access/common/heaptuple.c
pg_test_timing: Reduce per-loop overhead
commit : 82c0cb4e672dbc89f0bd0013c625a3a16ee36ad6
author : Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 20:02:09 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 20:02:09 -0400 The pg_test_timing program was previously using INSTR_TIME_GET_NANOSEC on an
absolute instr_time value in order to do a diff, which goes against the spirit
of how the GET_* macros are supposed to be used, and will cause overhead in a
future change that assumes these macros are typically used on intervals only.
Additionally the program was doing unnecessary work in the test loop by
measuring the time elapsed, instead of checking the existing current time
measurement against a target end time. To support that, introduce a new
INSTR_TIME_ADD_NANOSEC macro that allows adding user-defined nanoseconds
to an instr_time variable.
While modifying the relevant code anyway, simplify it by not handling
durations <= 0 in test_timing(), since duration is unsigned and 0 is
disallowed by the caller.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53Pkyxv3-3gX+aOxC5tX0p2v9RHU+XH0iyvb64+ZnBXj92vg@mail.gmail.com M src/bin/pg_test_timing/pg_test_timing.c
M src/include/portability/instr_time.h
read_stream: Prevent distance from decaying too quickly
commit : 6e36930f9aaffd5e097a01935e6f68ed851535ae
author : Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 19:50:03 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 19:50:03 -0400 Until now we reduced the look-ahead distance by 1 on every hit, and doubled it
on every miss. That is problematic because there are very common IO patterns
where this prevents us from ever reaching a sufficiently high distance (e.g. a
miss followed by a hit will never have the distance grow beyond 2). In many
such cases, if we had ever reached a sufficient look-ahead distance, things
would have been fine, because we grow the distance faster than we decrease it.
One might think that the most obvious answer to this problem would be to never
reduce the distance. However, that would not work well, as (particularly with
upcoming users of read streams), it is reasonably common to at first have a
lot of misses and then to transition to a fully cached workload, e.g. because
the same blocks are needed repeatedly within one stream. Doing unnecessarily
deep readahead can be costly, due to having to pin a lot more buffers, which
increases CPU overhead.
Because the cost of a synchronously handled miss can be very high (multiple
milliseconds for every IO with commonly used storage) compared to the CPU
overhead of keeping the distance too high, we want to err on the side of not
reducing the distance too early.
The insight that a decrease of the distance by 1 at ever hit may be ok at
large distances, but not at low distances, shows a way out: If we only allow
decreasing the distance once there were no misses for our maximum look-ahead
distance, we will keep the distance high as long as readahead has a chance to
do IO asynchronously, but not commonly when not.
Several folks have written variants of this patch, including at least Thomas
Munro, Melanie Plageman and I.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CA+hUKGL2PhFyDoqrHefqasOnaXhSg48t1phs3VM8BAdrZqKZkw@mail.gmail.com
Discussion: https://postgr.es/m/CAH2-Wz%3DkMg3PNay96cHMT0LFwtxP-cQSRZTZzh1Cixxf8G%3Dzrw%40mail.gmail.com M src/backend/storage/aio/read_stream.c
read_stream: Issue IO synchronously while in fast path
commit : cceb1bf45e3a12a859c1453bd53925b95d1b0cf1
author : Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 19:22:44 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 19:22:44 -0400 While in fast-path, execute any IO that we might encounter synchronously.
Because we are, in that moment, not reading ahead, dispatching any occasional
IO to workers has the dispatch overhead, without any realistic chance of the
IO completing before we need it.
This helps io_method=worker performance for workloads that have only
occasional cache misses, but where those occasional misses still take long
enough to matter. It is likely this is only measurable with fast local
storage or workloads with the data in the kernel page cache, as with remote
storage the IO latency, not the dispatch-to-worker latency, is the determining
factor.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CAH2-Wz%3DkMg3PNay96cHMT0LFwtxP-cQSRZTZzh1Cixxf8G%3Dzrw%40mail.gmail.com M src/backend/storage/aio/read_stream.c
Make ShmemIndex visible in the pg_shmem_allocations view
commit : 1bdbb211bbf31b0024f000746c42326648ecde90
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 1 Apr 2026 23:56:51 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 1 Apr 2026 23:56:51 +0300 Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/storage/ipc/shmem.c
Give an 'options' parameter to tuple_delete/_update
commit : db89a47115f0c7e664832f4b41cb03130b8a4fbe
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 1 Apr 2026 20:26:57 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 1 Apr 2026 20:26:57 +0200 The tuple_insert() method already has an equivalent argument, so this
makes sense just on consistency grounds, for future growth.
table_delete() can immediately use it to carry the 'changingPart'
boolean; for table_update we don't have any options at present.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> (older version)
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/202603171606.kf6pmhscqbqz@alvherre.pgsql M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/table/tableam.c
M src/backend/executor/nodeModifyTable.c
M src/include/access/heapam.h
M src/include/access/tableam.h
Add UPDATE/DELETE FOR PORTION OF
commit : 8e72d914c52876525a90b28444453de8085c866f
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Apr 2026 19:06:03 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Apr 2026 19:06:03 +0200 This is an extension of the UPDATE and DELETE commands to do a
"temporal update/delete" based on a range or multirange column. The
user can say UPDATE t FOR PORTION OF valid_at FROM '2001-01-01' TO
'2002-01-01' SET ... (or likewise with DELETE) where valid_at is a
range or multirange column.
The command is automatically limited to rows overlapping the targeted
portion, and only history within those bounds is changed. If a row
represents history partly inside and partly outside the bounds, then
the command truncates the row's application time to fit within the
targeted portion, then it inserts one or more "temporal leftovers":
new rows containing all the original values, except with the
application-time column changed to only represent the untouched part
of history.
To compute the temporal leftovers that are required, we use the *_minus_multi
set-returning functions defined in 5eed8ce50c.
- Added bison support for FOR PORTION OF syntax. The bounds must be
constant, so we forbid column references, subqueries, etc. We do
accept functions like NOW().
- Added logic to executor to insert new rows for the "temporal
leftover" part of a record touched by a FOR PORTION OF query.
- Documented FOR PORTION OF.
- Added tests.
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/ec498c3d-5f2b-48ec-b989-5561c8aa2024%40illuminatedcomputing.com 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/dml.sgml
M doc/src/sgml/glossary.sgml
M doc/src/sgml/images/Makefile
M doc/src/sgml/images/meson.build
A doc/src/sgml/images/temporal-delete.svg
A doc/src/sgml/images/temporal-delete.txt
A doc/src/sgml/images/temporal-update.svg
A doc/src/sgml/images/temporal-update.txt
M doc/src/sgml/ref/create_publication.sgml
M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/update.sgml
M doc/src/sgml/trigger.sgml
M src/backend/executor/execMain.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/utils/adt/ruleutils.c
M src/backend/utils/cache/lsyscache.c
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
A src/test/regress/expected/for_portion_of.out
M src/test/regress/expected/privileges.out
M src/test/regress/expected/updatable_views.out
M src/test/regress/expected/without_overlaps.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/for_portion_of.sql
M src/test/regress/sql/privileges.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 vicinity of tuple_insert to use uint32, not int, for options
commit : ec2f81766ad72d3ff4c45400f30d2670589aec11
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 1 Apr 2026 18:14:51 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 1 Apr 2026 18:14:51 +0200 Oversight in commit 1bd6f22f43ac: I was way too optimistic about the
compiler letting me know what variables needed to be updated, and missed
a few of them. Clean it up.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/40E570EE-5A60-49D8-B8F7-2F8F2B7C8DFA@gmail.com M src/backend/access/common/toast_internals.c
M src/backend/access/heap/heaptoast.c
M src/backend/access/heap/hio.c
M src/backend/access/heap/rewriteheap.c
M src/backend/access/table/toast_helper.c
M src/backend/commands/copyfrom.c
M src/backend/commands/createas.c
M src/backend/commands/matview.c
M src/backend/commands/tablecmds.c
M src/include/access/heaptoast.h
M src/include/access/hio.h
M src/include/access/toast_helper.h
M src/include/access/toast_internals.h
Add support for extended statistics on virtual generated columns.
commit : f7f4052a4e959ded803417b14af2b45316445940
author : Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 1 Apr 2026 17:02:24 +0100
committer: Dean Rasheed <dean.a.rasheed@gmail.com>
date : Wed, 1 Apr 2026 17:02:24 +0100 This allows both univariate and multivariate statistics to be built on
virtual generated columns and expressions that refer to virtual
generated columns. The restriction disallowing extended statistics on
a single column is lifted in the case of a single virtual generated
column, since it is treated as a single expression.
In the catalogs, references to virtual generated columns are stored
as-is. They are expanded at ANALYZE time to build the statistics, and
at planning time to allow the optimizer to make use of the statistics.
This allows the statistics to be correctly rebuilt using ANALYZE, if a
column's generation expression is altered (which causes any existing
statistics data to be deleted).
Author: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/20250422181006.dd6f9d1d81299f5b2ad55e1a@sraoss.co.jp M doc/src/sgml/ref/alter_table.sgml
M doc/src/sgml/ref/create_statistics.sgml
M src/backend/commands/statscmds.c
M src/backend/optimizer/util/plancat.c
M src/backend/statistics/extended_stats.c
M src/test/regress/expected/stats_ext.out
M src/test/regress/sql/stats_ext.sql
doc: Add missing description for DROP SUBSCRIPTION IF EXISTS.
commit : 196bf448e0054304f3e18df00c5c6133e5c8c7d7
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 1 Apr 2026 09:48:48 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 1 Apr 2026 09:48:48 -0500 Oversight in commit 665d1fad99.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHut%2BPv72haFerrCdYdmF6hu6o2jKcGzkXehom%2BsP-JBBmOVDg%40mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/drop_subscription.sgml
bufmgr: Return whether WaitReadBuffers() needed to wait
commit : 513374a47a71d64ff5c4790b7f962d3a80e8cc7c
author : Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 09:26:43 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 09:26:43 -0400 Thanks to the previous commit, pgaio_wref_check_done() will now detect whether
IO has completed even if userspace has not yet consumed the kernel completion.
This knowledge can be useful for callers of WaitReadBuffers() to know whether
it needed to wait or not, e.g. for adjusting read-ahead aggressiveness or for
instrumentation.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CAH2-Wz%3DkMg3PNay96cHMT0LFwtxP-cQSRZTZzh1Cixxf8G%3Dzrw%40mail.gmail.com
Discussion: https://postgr.es/m/a177a6dd-240b-455a-8f25-aca0b1c08c6e@vondra.me M src/backend/storage/buffer/bufmgr.c
M src/include/storage/bufmgr.h
aio: io_uring: Allow IO methods to check if IO completed in the background
commit : 6e648e353fa04ad86f896da347bbb9b51bc98ad4
author : Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 09:26:43 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 1 Apr 2026 09:26:43 -0400 Until now pgaio_wref_check_done() with io_method=io_uring would not detect if
IOs are known to have completed to the kernel, but the completion has not yet
been consumed by userspace. This can lead to inferior performance and also
makes it harder to use smarter feedback logic in read_stream, because we
cannot use knowledge about whether an IO completed to control the readahead
distance.
This commit just adds the io_uring specific infrastructure. Later commits will
return whether a wait was needed from WaitReadBuffers() and then use that
knowledge.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
Discussion: https://postgr.es/m/CAH2-Wz%3DkMg3PNay96cHMT0LFwtxP-cQSRZTZzh1Cixxf8G%3Dzrw%40mail.gmail.com M src/backend/storage/aio/aio.c
M src/backend/storage/aio/method_io_uring.c
M src/include/storage/aio_internal.h
Make FastPathMeta self-contained by copying FmgrInfo structs
commit : edee5634564d5f9fae4c3a10ee3182de338ed07e
author : Amit Langote <amitlan@postgresql.org>
date : Wed, 1 Apr 2026 18:43:40 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Wed, 1 Apr 2026 18:43:40 +0900 FastPathMeta stored pointers into ri_compare_cache entries via
compare_entries[], creating a dependency on that cache remaining
stable. If ri_compare_cache entries were invalidated after fpmeta
was populated, the pointers would dangle.
Replace compare_entries[] with inline copies of the two FmgrInfo
fields actually needed (cast_func_finfo and eq_opr_finfo), copied
at populate time via fmgr_info_copy(). fpmeta now depends only on
riinfo remaining valid, which is already handled by the invalidation
callback.
Introduced by commit 2da86c1ef9 ("Add fast path for foreign key
constraint checks"), noticed while reviewing code for robustness
under CLOBBER_CACHE_ALWAYS.
Discussion: https://postgr.es/m/CA+HiwqFQ+ZA7hSOygv4uv_t75B3r0_gosjadetCsAEoaZwTu6g@mail.gmail.com M src/backend/utils/adt/ri_triggers.c
Fix two issues in fast-path FK check introduced by commit 2da86c1ef9
commit : e484b0eea61482207b8fb8df9533be6d7defc25e
author : Amit Langote <amitlan@postgresql.org>
date : Wed, 1 Apr 2026 17:29:33 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Wed, 1 Apr 2026 17:29:33 +0900 First, under CLOBBER_CACHE_ALWAYS, the RI_ConstraintInfo entry can
be invalidated by relcache callbacks triggered inside table_open()
or index_open(), leaving ri_FastPathCheck() calling
ri_populate_fastpath_metadata() with a stale entry whose valid flag
is false. Fix by moving the fpmeta initialization to after
ri_CheckPermissions(), reloading riinfo first to ensure it is
valid, then calling ri_ExtractValues() and build_index_scankeys()
immediately after before any further operations that could trigger
invalidation.
Second, fpmeta allocated in TopMemoryContext was not freed when the
entry was invalidated in InvalidateConstraintCacheCallBack(),
leaking memory each time the constraint cache entry was recycled.
Fix by freeing and NULLing fpmeta at invalidation time.
Noticed locally when testing with CLOBBER_CACHE_ALWAYS.
Discussion: https://postgr.es/m/CA+HiwqGBU__7-VZZhQWQ3EQuwLYNPd9==ngnzduhGWKHMj9mvw@mail.gmail.com M src/backend/utils/adt/ri_triggers.c
Skip common prefixes during radix sort
commit : f6bd9f0fe25a3cea06e26204cc75cc6e954c4577
author : John Naylor <john.naylor@postgresql.org>
date : Wed, 1 Apr 2026 14:18:57 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Wed, 1 Apr 2026 14:18:57 +0700 During the counting step, keep track of the bits that are the same
for the entire input. If we counted only a single distinct byte,
the next recursion will start at the next byte position that has
more than one distinct byte in the input. This allows us to skip over
multiple passes where the byte is the same for the entire input.
This provides a significant speedup for integers that have some upper
bytes with all-zeros or all-ones, which is common.
Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com>
Reviewed-by: ChangAo Chen <cca5507@qq.com>
Discussion: https://postgr.es/m/CANWCAZYpGMDSSwAa18fOxJGXaPzVdyPsWpOkfCX32DWh3Qznzw@mail.gmail.com M src/backend/utils/sort/tuplesort.c
Reduce log level of some logical decoding messages from LOG to DEBUG1
commit : 21b018e7eab57b5e4be183133a8c5b8229eccb3d
author : Fujii Masao <fujii@postgresql.org>
date : Wed, 1 Apr 2026 15:43:02 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Wed, 1 Apr 2026 15:43:02 +0900 Previously some logical decoding messages (e.g., "logical decoding found
consistent point") were logged at level LOG, even though they provided
low-level, developer-oriented information that DBAs were typically not
interested in.
Since these messages can occur routinely (for example, when keeping calling
pg_logical_slot_get_changes() to obtain the changes from logical decoding),
logging them at LOG can be overly verbose.
This commit reduces their log level to DEBUG1 to avoid unnecessary log noise.
This change applies to a small set of messages for now. Additional messages
may be adjusted similarly in the future.
Even with this change, if these messages from walsender still need to be
observed, enabling DEBUG1 logging selectively for walsender (e.g.,
log_min_messages = 'warning,walsender:debug1') would be helpful to avoid
increasing overall log volume.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwGTyHgtD9tyN664x6vQ8Q1G53H7ZUCgBU9_X=nLt3f1QA@mail.gmail.com M src/backend/replication/logical/logical.c
M src/backend/replication/logical/snapbuild.c
M src/test/recovery/t/038_save_logical_slots_shutdown.pl
Use standard C23 and C++ attributes if available
commit : 76f4b92bac87fa54bd6dd8bd53e59f93127ec2ef
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Apr 2026 08:03:01 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Apr 2026 08:03:01 +0200 Use the standard C23 and C++ attributes [[nodiscard]], [[noreturn]],
and [[maybe_unused]], if available.
This makes pg_nodiscard and pg_attribute_unused() available in
not-GCC-compatible compilers that support C23 as well as in C++.
For pg_noreturn, we can now drop the GCC-specific and MSVC-specific
fallbacks, because the C11 and the C++ implementation will now cover
all required cases.
Note, in a few places, we need to change the position of the attribute
because it's not valid in that place in C23.
Discussion: https://www.postgresql.org/message-id/flat/pxr5b3z7jmkpenssra5zroxi7qzzp6eswuggokw64axmdixpnk@zbwxuq7gbbcw M src/backend/utils/mmgr/slab.c
M src/include/c.h
M src/include/lib/radixtree.h
M src/test/modules/worker_spi/worker_spi.c
Enable test_cplusplusext with MSVC
commit : c05ad248f99c729b53f6fa83939266b509682c33
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Apr 2026 07:48:47 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 1 Apr 2026 07:48:47 +0200 The test_cplusplusext test module has so far been disabled on MSVC.
The only remaining problem now is that designated initializers, as
used in PG_MODULE_MAGIC, require C++20. (With GCC and Clang they work
in older C++ versions as well.)
This adds another test in the top-level meson.build to check that the
compiler supports C++20 designated initializers. This is not
required, we are just checking and recording the answer. If yes, we
can enable the test module.
Most current compilers likely won't be in C++20 mode by default. This
doesn't change that; we are not doing anything to try to switch the
compiler into that mode. This might be a separate project, but for
now we'll leave that for the user or the test scaffolding.
The VS task on Cirrus CI is changed to provide the required flag to
turn on C++20 mode.
There is no equivalent change in configure, since this change mainly
targets MSVC.
Co-authored-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com M .cirrus.tasks.yml
M meson.build
M src/test/modules/test_cplusplusext/meson.build
Fix miscellaneous issues in EXCEPT publication clause.
commit : 6b0550c45d132c7a75acf98cb76f8a43bf5e94df
author : Amit Kapila <akapila@postgresql.org>
date : Wed, 1 Apr 2026 09:08:54 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Wed, 1 Apr 2026 09:08:54 +0530 Improve documentation regarding multiple publications and partition
hierarchies. Refine error reporting for excluded relations. Consolidate
docs by using table_object instead of expanded table syntax in publication
commands. Also includes minor test cleanup and naming fixes.
Reported-by: Peter Smith <smithpb2250@gmail.com>
Author: 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/CALDaNm1CiBYcteE_jjPA4BPHfX30dg9eTTTkJgkjY5tgE7t=bQ@mail.gmail.com
Discussion: https://postgr.es/m/CALDaNm3=JrucjhiiwsYQw5-PGtBHFONa6F7hhWCXMsGvh=tamA@mail.gmail.com M doc/src/sgml/ref/alter_publication.sgml
M doc/src/sgml/ref/create_publication.sgml
M src/backend/catalog/pg_publication.c
M src/test/regress/expected/publication.out
M src/test/subscription/t/037_except.pl
Fix pg_waldump/t/001_basic.pl with BSD tar on ZFS.
commit : 852de579a6eea3bebf719530ea2d2c232573b845
author : Thomas Munro <tmunro@postgresql.org>
date : Wed, 1 Apr 2026 14:02:39 +1300
committer: Thomas Munro <tmunro@postgresql.org>
date : Wed, 1 Apr 2026 14:02:39 +1300 The new test fails with an error about a missing WAL file on that
stack, because it is archived in GNU tar's --sparse --format=posix
format. BSD tar uses that format by default, unlike GNU tar itself, and
ZFS triggers it by implicitly creating sparse files when it sees a lot
of zeroes.
The problem will surely also affect real users of the new tar support in
pg_waldump (commit b15c1513) and pg_verifybackup (commit b3cf461b3) on
such systems. Ideas under discussion, but for now the test is made to
pass by disabling sparse file detection in BSD tar.
Diagnosed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/1624716.1774736283%40sss.pgh.pa.us M src/bin/pg_waldump/t/001_basic.pl
bufmgr: Fix ordering of checks in PinBuffer()
commit : c0af4eb4e71ecd4826ae6c9985f1d10ace5e1be6
author : Andres Freund <andres@anarazel.de>
date : Tue, 31 Mar 2026 19:24:58 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 31 Mar 2026 19:24:58 -0400 The check for skip_if_not_valid added in 819dc118c0f6 was put at the start of
the loop. A CAS loop in theory does allow to make that check in a race free
manner. However, just after the check, there's a
old_buf_state = WaitBufHdrUnlocked(buf);
which introduces a race, because it would allow BM_VALID to be cleared, after
the skip_if_not_valid check.
Fix by restarting the loop after WaitBufHdrUnlocked().
Reported-by: Yura Sokolov <y.sokolov@postgrespro.ru>
Discussion: https://postgr.es/m/5bf667f3-5270-4b19-a08f-0facbecdff68@postgrespro.ru M src/backend/storage/buffer/bufmgr.c
Doc: warn that parallel pg_restore may fail if --no-schema was used.
commit : 273d26b75e78a4811b0c6039c0ee38cde2341ce4
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 31 Mar 2026 16:36:01 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 31 Mar 2026 16:36:01 -0400 If the archive file was made with --no-schema or related options
then it likely does not have enough dependency information to
ensure that parallel restore will choose a workable restore order.
Document this.
In passing, do some minor wordsmithing on new nearby text about
restoring from pg_dumpall archives.
Author: vaibhave postgres <postgresvaibhave@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAM_eQjzTLtt1X9WKvMV6Rew0UvxT3mmhimZa9WT-vqaPjmXk-g@mail.gmail.com M doc/src/sgml/ref/pg_dump.sgml
M doc/src/sgml/ref/pg_restore.sgml
Fix test_aio read_buffers() to work without cassert
commit : 8519251ee975a8cca16fb35d699c1a39f2d217a1
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 31 Mar 2026 15:02:52 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 31 Mar 2026 15:02:52 -0400 In a production build, StartReadBuffers() doesn't populate all fields
of a ReadBuffersOperation for a buffer hit because no callers use them
(they are populated in assert builds).
read_buffers() (a test-only function) relied on some of these fields, so
AIO tests failed on non-assert builds (discovered on the buildfarm after
commit 020c02bd908).
Fix by tracking the required information ourselves in read_buffers() and
avoiding reliance on the ReadBuffersOperation unless we know that we did
IO.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/9ce8f5d8-8ab2-4aa2-b062-c5d74161069c%40gmail.com M src/test/modules/test_aio/test_aio.c
oauth: Don't log discovery connections by default
commit : e020a897efeaed52cd3f5fef7f933cb5dc6cbfaf
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:33 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:33 -0700 Currently, when the client sends a parameter discovery request within
OAUTHBEARER, the server logs the attempt with
FATAL: OAuth bearer authentication failed for user
These log entries are difficult to distinguish from true authentication
failures, and by default, libpq sends a discovery request as part of
every OAuth connection, making them annoyingly noisy. Use the new
PG_SASL_EXCHANGE_ABANDONED status to suppress them.
Patch by Zsolt Parragi, with some additional comments added by me.
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAN4CZFPim7hUiyb7daNKQPSZ8CvQRBGkVhbvED7yZi8VktSn4Q%40mail.gmail.com M src/backend/libpq/auth-oauth.c
M src/test/modules/oauth_validator/t/001_server.pl
sasl: Allow backend mechanisms to "abandon" exchanges
commit : c4ff16339f07d1e253bdf18e5da5fa25f62a750d
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:31 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:31 -0700 Introduce PG_SASL_EXCHANGE_ABANDONED, which allows CheckSASLAuth to
suppress the failing log entry for any SASL exchange that isn't actually
an authentication attempt. This is desirable for OAUTHBEARER's discovery
exchanges (and a subsequent commit will make use of it there).
This might have some overlap in the future with in-band aborts for SASL
exchanges, but it's intentionally not named _ABORTED to avoid confusion.
(We don't currently support clientside aborts in our SASL profile.)
Adapted from a patch by Zsolt Parragi.
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Co-authored-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAN4CZFPim7hUiyb7daNKQPSZ8CvQRBGkVhbvED7yZi8VktSn4Q%40mail.gmail.com M src/backend/libpq/auth-sasl.c
M src/backend/libpq/auth.c
M src/include/libpq/sasl.h
Add FATAL_CLIENT_ONLY to ereport/elog
commit : c2bca7cc9621f45e27dc332e3f58c7544386de88
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:29 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:29 -0700 SASL exchanges must end with either an AuthenticationOk or an
ErrorResponse from the server, and the standard way to produce an
ErrorResponse packet is for auth_failed() to call ereport(FATAL). This
means that there's no way for a SASL mechanism to suppress the server
log entry if the "authentication attempt" was really just a query for
authentication metadata, as is done with OAUTHBEARER.
Following the example of 1f9158ba4, add a FATAL_CLIENT_ONLY elevel. This
will allow ClientAuthentication() to choose not to log a particular
failure, while still correctly ending the authentication exchange before
process exit.
(The provenance of this patch is convoluted: since it's a mechanical
copy-paste of 1f9158ba4, both Zsolt Parragi and I produced nearly
identical versions independently, and Andrey Borodin reviewed Zsolt's
version. Tom Lane is the author of 1f9158ba4, but I don't want to imply
that he's signed off on this adaptation. See Discussion.)
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CAN4CZFPim7hUiyb7daNKQPSZ8CvQRBGkVhbvED7yZi8VktSn4Q%40mail.gmail.com M src/backend/utils/error/elog.c
M src/include/utils/elog.h
libpq: Allow developers to reimplement libpq-oauth
commit : 09532b4040ed4c313351366166f55e810f152d6a
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:26 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:26 -0700 For PG19, since we won't have the ability to officially switch out flow
plugins, relax the flow-loading code to not require the internal init
function. Modules that don't have one will be treated as custom user
flows in error messages.
This will let bleeding-edge developers more easily test out the API and
provide feedback for PG20, by telling the runtime linker to find a
different libpq-oauth. It remains undocumented for end users.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAOYmi%2BmrGg%2Bn_X2MOLgeWcj3v_M00gR8uz_D7mM8z%3DdX1JYVbg%40mail.gmail.com M src/interfaces/libpq/fe-auth-oauth.c
M src/interfaces/libpq/fe-auth-oauth.h
libpq: Poison the v2 part of a v1 Bearer request
commit : 0af4d402cb900364f275cc6f9c28dca4a5bec36b
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:23 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 31 Mar 2026 11:47:23 -0700 The new PGoauthBearerRequestV2 API (which has similarities to the
"subclass" pointer architecture in use by the backend, for Nodes)
carries the risk of a developer ignoring the type of hook in use and
just casting directly to the V2 struct. This will appear to work fine in
19, but crash (or worse) when speaking to libpq 18.
However, we're in a unique position to catch this problem, because we
have tight control over the struct. Add poisoning code to the v1 path
which does the following:
- masks the v2 request->issuer pointer, to hopefully point at nonsense
memory
- abort()s if the v2 request->error is assigned by the hook
- attempts to cover both with VALGRIND_MAKE_MEM_NOACCESS for the
duration of the callback (a potential AddressSanitizer implementation
is left for future work)
The struct is unpoisoned after the call, so we can switch back to the v2
internal implementation when necessary.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAOYmi%2BnCg5upBVOo_UCSjMfO%3DYMkZXcSEsgaADKXqerr5wahZQ%40mail.gmail.com M src/interfaces/libpq/fe-auth-oauth.c
M src/interfaces/libpq/fe-auth-oauth.h
Avoid including vacuum.h in tableam.h and heapam.h.
commit : 771fe0948cad0acf883f15026c718d4f6942c8cb
author : Nathan Bossart <nathan@postgresql.org>
date : Tue, 31 Mar 2026 12:43:52 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Tue, 31 Mar 2026 12:43:52 -0500 Commit 2252fcd427 modified some function prototypes in tableam.h
and heapam.h to take a VacuumParams argument instead of a pointer,
which required including vacuum.h in those headers. vacuum.h has a
reasonably large dependency tree, and headers like tableam.h are
widely included, so this is not ideal. To fix, change the
functions in question to accept a "const VacuumParams *" argument
instead. That allows us to use a forward declaration for
VacuumParams and avoid including vacuum.h. Since vacuum_rel()
needs to scribble on the params argument, we still pass it by value
to that function so that the original struct is not modified.
Reported-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/rzxpxod4c4la62yvutyrvgoyilrl2fx55djaf2suidy7np5m6c%403l2ln476eadh M contrib/dblink/dblink.c
M contrib/tablefunc/tablefunc.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/catalog/toasting.c
M src/backend/commands/analyze.c
M src/backend/commands/cluster.c
M src/backend/commands/event_trigger.c
M src/backend/commands/vacuum.c
M src/backend/postmaster/autovacuum.c
M src/backend/replication/logical/conflict.c
M src/backend/replication/logical/worker.c
M src/backend/utils/adt/ri_triggers.c
M src/include/access/heapam.h
M src/include/access/tableam.h
M src/include/commands/vacuum.h
M src/pl/tcl/pltcl.c
M src/tools/pgindent/typedefs.list
Doc: remove bogus claim that tsvectors can have up to 2^64 entries.
commit : 960382e3e991f774d0ef92eb82dd7ef641f74108
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 31 Mar 2026 11:49:54 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 31 Mar 2026 11:49:54 -0400 This is nonsense on its face, since the textsearch parsing logic
generally uses int32 to count words (see, eg, struct ParsedText).
Not to mention that we don't support input strings larger than
1GB.
The actual limitation of interest is documented nearby: a tsvector
can't be larger than 1MB, thanks to 20-bit offset fields within it
(see WordEntry.pos). That constrains us to well under 256K lexemes
per tsvector, depending on how many positions are stored per lexeme.
It seems sufficient therefore to just remove the bit about number
of lexemes.
Author: Dharin Shah <dharinshah95@gmail.com>
Discussion: https://postgr.es/m/CAOj6k6d0YO6AO-bhxkfUXPxUi-+YX9-doh2h5D5z0Bm8D2w=OA@mail.gmail.com M doc/src/sgml/textsearch.sgml
Doc: improve explanation of GiST compress/decompress methods.
commit : fb7a9050d53c5cd4b7c86f8e07196bd47b9db3b2
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 31 Mar 2026 11:23:20 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 31 Mar 2026 11:23:20 -0400 The docs previously didn't explain that leaf and non-leaf keys
could be treated differently, even though many of our opclasses
do exactly that. It also wasn't explained how that relates to
the STORAGE option, particularly since only one storage type
can be specified for both leaf and non-leaf keys.
While here, reorganize the text slightly, rather than sticking
additional detail into what's supposed to be a brief summary
paragraph.
Author: Paul A Jungwirth <pj@illuminatedcomputing.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA+renyWs5Np+FLSYfL+eu20S4U671A3fQGb-+7e22HLrD1NbYw@mail.gmail.com M doc/src/sgml/gist.sgml
M src/backend/access/gist/README
Change the signature of dynahash's alloc function
commit : 7b424e3108e4745ba7d37e358a1177911fa5a5ad
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 31 Mar 2026 16:55:03 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 31 Mar 2026 16:55:03 +0300 Instead of passing the current memory context to the alloc function
via a shared variable, pass it directly as an argument.
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/storage/ipc/shmem.c
M src/backend/utils/hash/dynahash.c
M src/include/utils/hsearch.h
Remove HASH_SEGMENT option
commit : dde69621c3248c1c6e623a4f5baa182783ead681
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 31 Mar 2026 16:45:28 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 31 Mar 2026 16:45:28 +0300 It's been unused forever. There's no urgency in removing it now, but
it was just something that caught my eye.
Aleksander Alekseev proposed this a long time ago [0], but Tom Lane
was worried about third-party extensions using it. I believe that's a
non-issue: I tried grepping through all extensions found on github and
didn't find any references to HASH_SEGMENT.
[0] https://www.postgresql.org/message-id/20160418180711.55ac82c0@fujitsu
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/utils/hash/dynahash.c
M src/include/utils/hsearch.h
Fix cross variable references in graph pattern causing segfault
commit : a0dd0702e464f206b08c99a74cb58809c51aafa5
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 11:44:43 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 11:44:43 +0200 When converting the WHERE clause in an element pattern,
generate_query_for_graph_path() calls replace_property_refs() to
replace the property references in it. Only the current graph element
pattern is passed as the context for replacement. If there are
references to variables from other element patterns, it causes a
segmentation fault (an assertion failure in an Assert enabled build)
since it does not find path_element object corresponding to those
variables.
We do not support forward and backward variable references within a
graph table clause. Hence prohibit all the cross references.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reported-by: Man Zeng <zengman@halodbtech.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5u6AoDfNg4%3DR5eVJn_bJn%3DC%3DwVPrto02P_06fxy39fniA%40mail.gmail.com M src/backend/parser/parse_graphtable.c
M src/include/parser/parse_node.h
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Property references are preferred over regular column references
commit : c5b3253b8abd7b89689d1095c7c1154b784ca9c9
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 11:37:35 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 11:37:35 +0200 When a ColumnRef can be resolved as a graph table property reference
and a lateral table column reference prefer the graph table property
reference since element pattern variables in the GRAPH_TABLE clause
form the innermost namespace.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5u6AoDfNg4%3DR5eVJn_bJn%3DC%3DwVPrto02P_06fxy39fniA%40mail.gmail.com M src/backend/parser/parse_expr.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Fix use-after-free in ri_LoadConstraintInfo
commit : 68a8601ee9ec7285b5a3839e17360c0a9d0e52a3
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 31 Mar 2026 17:04:44 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 31 Mar 2026 17:04:44 +0900 conindid was read from conForm after ReleaseSysCache(tup). Move
the read to before the release.
Introduced by commit 2da86c1ef9b5.
Per buildfarm member prion.
Discussion: https://postgr.es/m/CA+HiwqGGYjN6F2oL7yAk=hvSs-sj3TPqZ9JC9iyLkCqJadECrw@mail.gmail.com M src/backend/utils/adt/ri_triggers.c
Formalize WAL record for XLOG_CHECKPOINT_REDO
commit : 097ab69d17f74e3c45b8c092d29df74f59bb5421
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Tue, 31 Mar 2026 09:38:01 +0200
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Tue, 31 Mar 2026 09:38:01 +0200 XLOG_CHECKPOINT_REDO only contains the wal_level copied straight in
without an encapsulating record structure. While it works, it makes
future uses of XLOG_CHECKPOINT_REDO hard as there is nowhere to put
new data items. This fix this was inspired by the online checksums
patch which adds data to this record, but this change has value on
its own.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/c92b5d8b-bc03-47bc-b209-2e4a719eee32@iki.fi M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/xlog.c
M src/backend/postmaster/walsummarizer.c
M src/include/access/xlog_internal.h
M src/tools/pgindent/typedefs.list
Disable some C++ warnings in MSVC
commit : 82a7cbea747c465eee8449587be2d6cc47af82fe
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 08:38:24 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 08:38:24 +0200 Flexible array members, as used in many PostgreSQL header files, are
not a C++ feature. MSVC warns about these. Disable the
warning. (GCC and Clang accept them, but they would warn in -pedantic
mode.)
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com M meson.build
meson: Make room for C++-only warning flags for MSVC
commit : 4c83f1253593ef46a0a190afb8ecead21f483196
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 08:38:24 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 31 Mar 2026 08:38:24 +0200 Refactor the MSVC warning option handling to have a list of common
flags and lists of flags specific to C and C++.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com M meson.build
Add fast path for foreign key constraint checks
commit : 2da86c1ef9b5446e0e22c0b6a5846293e58d98e3
author : Amit Langote <amitlan@postgresql.org>
date : Tue, 31 Mar 2026 13:49:21 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Tue, 31 Mar 2026 13:49:21 +0900 Add a fast-path optimization for foreign key checks that bypasses SPI
by directly probing the unique index on the referenced table.
Benchmarking shows ~1.8x speedup for bulk FK inserts (int PK/int FK,
1M rows, where PK table and index are cached).
The fast path applies when the referenced table is not partitioned and
the constraint does not involve temporal semantics. Otherwise, the
existing SPI path is used.
This optimization covers only the referential check trigger
(RI_FKey_check). The action triggers (CASCADE, SET NULL, SET DEFAULT,
RESTRICT, NO ACTION) must find rows on the FK side to modify, which
requires a table scan with no guaranteed index available, and then
execute DML against those rows through the full executor path including
any triggered actions. Replicating that without substantial code
duplication is not feasible, so those triggers remain on the SPI path.
Extending the fast path to action triggers remains possible as future
work if the necessary infrastructure is built.
The new ri_FastPathCheck() function extracts the FK values, builds scan
keys, performs an index scan, and locks the matching tuple with
LockTupleKeyShare via ri_LockPKTuple(), which handles the RI-specific
subset of table_tuple_lock() results.
If the locked tuple was reached by chasing an update chain
(tmfd.traversed), recheck_matched_pk_tuple() verifies that the key
is still the same, emulating EvalPlanQual.
The scan uses GetTransactionSnapshot(), matching what the SPI path
uses (via _SPI_execute_plan pushing GetTransactionSnapshot() as the
active snapshot). Under READ COMMITTED this is a fresh snapshot;
under REPEATABLE READ / SERIALIZABLE it is the frozen transaction-
start snapshot, so PK rows committed after the transaction started
are not visible.
The ri_CheckPermissions() function performs schema USAGE and table
SELECT checks, matching what the SPI path gets implicitly through
the executor's permission checks. The fast path also switches to
the PK table owner's security context (with SECURITY_NOFORCE_RLS)
before the index probe, matching the SPI path where the query runs
as the table owner.
ri_HashCompareOp() is adjusted to handle cross-type equality operators
(e.g. int48eq for int4 PK / int8 FK) which can appear in conpfeqop.
The existing code asserted same-type operators only, which was correct
for its existing callers (ri_KeysEqual compares same-type FK column
values via ff_eq_oprs), but the fast path is the first caller to pass
pf_eq_oprs, which can be cross-type.
Per-key metadata (compare entries, operator procedures, strategy
numbers) is cached in RI_ConstraintInfo via
ri_populate_fastpath_metadata() on first use, eliminating repeated
calls to ri_HashCompareOp() and get_op_opfamily_properties().
conindid and pk_is_partitioned are also cached at constraint load
time, avoiding per-invocation syscache lookups and the need to open
pk_rel before deciding whether the fast path applies.
New regression tests cover RLS bypass and ACL enforcement for the
fast-path permission checks. New isolation tests exercise concurrent
PK updates under both READ COMMITTED and REPEATABLE READ.
Author: Junwang Zhao <zhjwpku@gmail.com>
Co-authored-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Tested-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CA+HiwqF4C0ws3cO+z5cLkPuvwnAwkSp7sfvgGj3yQ=Li6KNMqA@mail.gmail.com M src/backend/utils/adt/ri_triggers.c
A src/test/isolation/expected/fk-concurrent-pk-upd.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/fk-concurrent-pk-upd.spec
M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql
M src/tools/pgindent/typedefs.list
Change syntax of EXCEPT TABLE clause in publication commands.
commit : 5984ea868eeeb202bddedfbdaca81adfe7ea6779
author : Amit Kapila <akapila@postgresql.org>
date : Tue, 31 Mar 2026 09:40:51 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Tue, 31 Mar 2026 09:40:51 +0530 Adjust the syntax of the EXCEPT clause in CREATE/ALTER PUBLICATION
added in commits fd366065e0 and 493f8c6439 to move the TABLE keyword
inside the relation list.
Old syntax:
CREATE PUBLICATION ... FOR ALL TABLES EXCEPT TABLE (t1, ...);
ALTER PUBLICATION ... SET ALL TABLES EXCEPT TABLE (t1, ...);
New syntax:
CREATE PUBLICATION ... FOR ALL TABLES EXCEPT (TABLE t1, ...);
ALTER PUBLICATION ... SET ALL TABLES EXCEPT (TABLE t1, ...);
This is to ensure that inclusion and exclusion list can be specified in
a same way. Previously, the exclusion table list can be specified as
TABLE (t1, t2, t3) and inclusion list can be specified as TABLE t1, t2,
t3, or TABLE t1, TABLE t2, TABLE t3.
This change is purely syntactic and does not alter behavior.
Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>
Author: vignesh C <vignesh21@gmail.com>
Author: Shlok Kyal <shlok.kyal.oss@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: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAD21AoCC8XuwfX62qKBSfHUAoww_XB3_84HjswgL9jxQy696yw@mail.gmail.com
Discussion: https://postgr.es/m/CALDaNm3=JrucjhiiwsYQw5-PGtBHFONa6F7hhWCXMsGvh=tamA@mail.gmail.com M doc/src/sgml/catalogs.sgml
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/alter_publication.sgml
M doc/src/sgml/ref/create_publication.sgml
M src/backend/catalog/pg_publication.c
M src/backend/commands/publicationcmds.c
M src/backend/parser/gram.y
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/psql/describe.c
M src/bin/psql/tab-complete.in.c
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql
M src/test/subscription/t/037_except.pl
Doc: update ddl.sgml's description of cmin and cmax.
commit : 786552e7f22315c4103c5404f9c4c6bccc95f8c1
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 30 Mar 2026 18:25:17 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 30 Mar 2026 18:25:17 -0400 We long ago folded these two tuple header fields into one field
to save space. However, nothing was done to the user-facing
documentation about them, perhaps with the idea that we'd add
code to emit something approximating the original definitions.
That never happened and presumably never will, so update the
text to reflect current reality.
Author: Paul A Jungwirth <pj@illuminatedcomputing.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA+renyVYYboiTayRRE0j1oKpeB+NjEBSUXfwgEu6O0JESSmauQ@mail.gmail.com M doc/src/sgml/ddl.sgml
Add warning option -Wold-style-declaration
commit : c73e8ee061adf26ed77ffa7e676f5de6d9f6da21
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 23:12:38 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 23:12:38 +0200 This warning has been triggered a few times via the buildfarm (see
commits 8212625e53f, 2b7259f8557, afe86a9e73b), so we might as well
add it so that everyone sees it.
(This is completely separate from the recently added
-Wold-style-definition.)
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal M configure
M configure.ac
M meson.build
libpq: Add oauth_ca_file option to change CAs without debugging
commit : 993368113c432832862db29f927c206dab0c0b8a
author : Jacob Champion <jchampion@postgresql.org>
date : Mon, 30 Mar 2026 14:14:45 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Mon, 30 Mar 2026 14:14:45 -0700 PG18 hid the PGOAUTHCAFILE envvar behind PGOAUTHDEBUG=UNSAFE, because I
thought that any "real" production usage of private CA certificates
would have them added to the Curl system trust store. But there are use
cases, such as containerized environments, that prefer to manage custom
CA settings more granularly; some of them consider envvar configuration
of certificates to be standard practice.
Move PGOAUTHCAFILE out from under the debug flag, and add an
oauth_ca_file option to libpq to configure trusted CAs per connection.
Patch by Jonathan Gonzalez V., with some additional wordsmithing and
test organization by me.
Author: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
Co-authored-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/16a91d02795cb991963326a902afa764e4d721db.camel%40gmail.com M doc/src/sgml/libpq.sgml
M src/interfaces/libpq-oauth/oauth-curl.c
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/libpq-int.h
M src/test/modules/oauth_validator/t/001_server.pl
M src/test/modules/oauth_validator/t/OAuth/Server.pm
Remove bits* typedefs.
commit : bab2f27eaaad77f799ecc224f9e11b09adb07d5a
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 30 Mar 2026 16:12:08 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 30 Mar 2026 16:12:08 -0500 In addition to removing the bits8, bits16, and bits32 typedefs,
this commit replaces all uses with uint8, uint16, or uint32. bits*
provided little benefit beyond establishing the intent of the
variable, and they were inconsistently used for that purpose.
Third-party code should instead use the corresponding uint*
typedef.
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://postgr.es/m/absbX33E4eaA0Ity%40nathan M contrib/dblink/dblink.c
M contrib/pageinspect/gistfuncs.c
M contrib/pageinspect/heapfuncs.c
M contrib/postgres_fdw/deparse.c
M doc/src/sgml/fdwhandler.sgml
M src/backend/access/brin/brin_tuple.c
M src/backend/access/common/heaptuple.c
M src/backend/access/common/indextuple.c
M src/backend/access/common/reloptions.c
M src/backend/access/spgist/spgutils.c
M src/backend/catalog/index.c
M src/backend/catalog/indexing.c
M src/backend/catalog/objectaddress.c
M src/backend/commands/indexcmds.c
M src/backend/commands/subscriptioncmds.c
M src/backend/commands/tablecmds.c
M src/backend/commands/vacuum.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execIndexing.c
M src/backend/executor/execReplication.c
M src/backend/executor/execTuples.c
M src/backend/executor/nodeModifyTable.c
M src/backend/foreign/foreign.c
M src/backend/nodes/gen_node_support.pl
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/syslogger.c
M src/backend/utils/activity/pgstat_backend.c
M src/backend/utils/adt/array_userfuncs.c
M src/backend/utils/adt/arrayfuncs.c
M src/backend/utils/adt/format_type.c
M src/backend/utils/adt/misc.c
M src/backend/utils/adt/regproc.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/adt/varbit.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/fmgr/funcapi.c
M src/backend/utils/init/postinit.c
M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/psql/tab-complete.in.c
M src/bin/scripts/vacuumdb.c
M src/bin/scripts/vacuuming.h
M src/include/access/htup_details.h
M src/include/access/itup.h
M src/include/access/reloptions.h
M src/include/access/tupmacs.h
M src/include/c.h
M src/include/catalog/index.h
M src/include/commands/cluster.h
M src/include/commands/vacuum.h
M src/include/common/jsonapi.h
M src/include/executor/executor.h
M src/include/executor/instrument_node.h
M src/include/foreign/foreign.h
M src/include/funcapi.h
M src/include/miscadmin.h
M src/include/nodes/parsenodes.h
M src/include/port/pg_bitutils.h
M src/include/postmaster/syslogger.h
M src/include/replication/reorderbuffer.h
M src/include/replication/walsender_private.h
M src/include/utils/array.h
M src/include/utils/arrayaccess.h
M src/include/utils/builtins.h
M src/include/utils/pgstat_internal.h
M src/include/utils/regproc.h
M src/include/utils/ruleutils.h
M src/include/utils/varbit.h
M src/pl/plpython/plpy_typeio.c
M src/port/pg_bitutils.c
M src/port/pg_popcount_aarch64.c
M src/port/pg_popcount_x86.c
M src/test/modules/worker_spi/worker_spi.c
M src/tools/pgindent/typedefs.list
Use ShmemInitStruct to allocate shmem for semaphores
commit : 40c41dc77306bf6f8f97b0012355c0dd8e11a430
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 23:39:35 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 23:39:35 +0300 This makes them visible in pg_shmem_allocations
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi M src/backend/port/posix_sema.c
M src/backend/port/sysv_sema.c
Set pd_prune_xid on insert
commit : 378a216187aea1b488ce60ed07dd1ac5c14a9984
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 16:07:11 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 16:07:11 -0400 Now that on-access pruning can update the visibility map (VM) during
read-only queries, set the page’s pd_prune_xid hint during INSERT and on
the new page during UPDATE.
This allows heap_page_prune_and_freeze() to set the VM the first time a
page is read after being filled with tuples. This may avoid I/O
amplification by setting the page all-visible when it is still in shared
buffers and allowing later vacuums to skip scanning the page. It also
enables index-only scans of newly inserted data much sooner.
As a side benefit, this addresses a long-standing note in heap_insert()
and heap_multi_insert(): aborted inserts can now be pruned on-access
rather than lingering until the next VACUUM.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_xlog.c
M src/backend/access/heap/pruneheap.c
Allow on-access pruning to set pages all-visible
commit : b46e1e54d078def33b840ae1fa6c5236a7b12ec2
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 15:47:07 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 15:47:07 -0400 Many queries do not modify the underlying relation. For such queries, if
on-access pruning occurs during the scan, we can check whether the page
has become all-visible and update the visibility map accordingly.
Previously, only vacuum and COPY FREEZE marked pages as all-visible or
all-frozen.
This commit implements on-access VM setting for sequential scans, tid
range scans, sample scans, bitmap heap scans, and the underlying heap
relation in index scans.
Setting the visibility map on-access can avoid write amplification
caused by vacuum later needing to set the page all-visible, which could
trigger a write and potentially an FPI. It also allows more frequent
index-only scans, since they require pages to be marked all-visible in
the VM.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/include/access/heapam.h
Add commit 874da8b1f6 to .git-blame-ignore-revs.
commit : e3637a05dc4330e451f890184f13b341a4f8fd51
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 30 Mar 2026 14:35:24 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 30 Mar 2026 14:35:24 -0500 M .git-blame-ignore-revs
configure: Apply -Werror=vla to C++ as well as C
commit : 488ab592d9ea1b4c7d6e43389c34c4bbbcb8f0d4
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 20:55:16 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 20:55:16 +0200 The comment part of d9dd406fe281 mentioned that -Wvla is not applicable
for C++. That is not fully correct: it is true that VLAs are not part of the
C++ standard, and g++ with -pedantic will also warn about them as a non-standard
extension. However, -Wvla itself works fine in C++ and will catch VLA
usage just as in C.
Fix configure.ac to apply -Werror=vla to C++ as well. There is no need to
fix meson.build as it already includes it in common_warning_flags.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/7bf60ab1-2b5d-4a77-93ce-815072a0a014%40eisentraut.org M configure
M configure.ac
Be more careful to preserve consistency of a tuplestore.
commit : 739477345036c26f0661eedb419058b0b9943f34
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 30 Mar 2026 13:59:54 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 30 Mar 2026 13:59:54 -0400 Several places in tuplestore.c would leave the tuplestore data
structure effectively corrupt if some subroutine were to throw
an error. Notably, if WRITETUP() failed after some number of
successful calls within dumptuples(), the tuplestore would
contain some memtuples pointers that were apparently live
entries but in fact pointed to pfree'd chunks.
In most cases this sort of thing is fine because transaction
abort cleanup is not too picky about the contents of memory that
it's going to throw away anyway. There's at least one exception
though: if a Portal has a holdStore, we're going to call
tuplestore_end() on that, even during transaction abort.
So it's not cool if that tuplestore is corrupt, and that means
tuplestore.c has to be more careful.
This oversight demonstrably leads to crashes in v15 and before,
if a holdable cursor fails to persist its data due to an undersized
temp_file_limit setting. Very possibly the same thing can happen in
v16 and v17 as well, though the specific test case submitted failed
to fail there (cf. 095555daf). The failure is accidentally dodged
as of v18 because 590b045c3 got rid of tuplestore_end's retail tuple
deletion loop. Still, it seems unwise to permit tuplestores to become
internally inconsistent in any branch, so I've applied the same fix
across the board.
Since the known test case for this is rather expensive and doesn't
fail in recent branches, I've omitted it.
Bug: #19438
Reported-by: Dmitriy Kuzmin <kuzmin.db4@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19438-9d37b179c56d43aa@postgresql.org
Backpatch-through: 14 M src/backend/utils/sort/tuplestore.c
Replace getopt() with our re-entrant variant in the backend
commit : 681774315d738ed9bb213d755c6f39fa5b5009b9
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 20:47:16 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 20:47:16 +0300 Some of these probably could continue using non-re-entrant getopt()
even if we start using threads in the future, but it seems better to
make them all anyway, so that we have a clear-cut rule of "no plain
getopt() in the postgres binary".
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/d1da5f0e-0d68-47c9-a882-eb22f462752f@iki.fi M src/backend/bootstrap/bootstrap.c
M src/backend/postmaster/postmaster.c
M src/backend/tcop/postgres.c
M src/backend/utils/misc/ps_status.c
Invent a variant of getopt(3) that is thread-safe
commit : fd8e3f7ceeed8b0155e124a0da4ec6a4fb53ec1f
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 20:47:13 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 20:47:13 +0300 The standard getopt(3) function is not re-entrant nor thread-safe.
That's OK for current usage, but it's one more little thing we need to
change in order to make the server multi-threaded.
There's no standard getopt_r() function on any platform, I presume
because command line arguments are usually parsed early when you start
a program, before launching any threads, so there isn't much need for
it. However, we call it at backend startup to parse options from the
startup packet. Because there's no standard, we're free to define our
own.
The pg_getopt_start/next() implementation is based on the old getopt
implementation, I just gathered all the state variables to a struct.
The non-re-entrant getopt() function is now a wrapper around the
re-entrant variant, on platforms that don't have getopt(3).
getopt_long() is not used in the server, so we don't need to provide a
re-entrant variant of that.
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/d1da5f0e-0d68-47c9-a882-eb22f462752f@iki.fi A src/include/port/pg_getopt_ctx.h
M src/port/Makefile
M src/port/getopt.c
M src/port/meson.build
A src/port/pg_getopt_ctx.c
M src/tools/pgindent/typedefs.list
Fix latent bug in get_stats_option_name()
commit : c5f7820e5780f5be9cb406834108576b42e568f8
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 20:34:48 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 20:34:48 +0300 The function is supposed to look at the passed in 'arg' argument, but
peeks at the 'optarg' global variable that's part of getopt()
instead. It happened to work anyway, because all callers passed
'optarg' as the argument.
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/d1da5f0e-0d68-47c9-a882-eb22f462752f@iki.fi M src/backend/tcop/postgres.c
Pass down information on table modification to scan nodes
commit : 50eb5faea2959125a575bae0a062ccb33b49c43d
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 13:27:34 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 13:27:34 -0400 Pass down information to sequential scan, index [only] scan, bitmap
table scan, sample scan, and TID range scan nodes on whether or not the
query modifies the relation being scanned. A later commit will use this
information to update the VM during on-access pruning only if the
relation is not modified by the query.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/4379FDA3-9446-4E2C-9C15-32EFE8D4F31B%40yandex-team.ru M src/backend/executor/execUtils.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/backend/executor/nodeSamplescan.c
M src/backend/executor/nodeSeqscan.c
M src/backend/executor/nodeTidrangescan.c
M src/include/access/tableam.h
M src/include/executor/executor.h
Don't use bits32 in table AM interface
commit : 349bd8820215528adbd79a31796d205e148734f6
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 30 Mar 2026 19:03:28 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 30 Mar 2026 19:03:28 +0200 Seems there's near-universal dislike for the bitsXX typedefs.
Revert that part of commit 1bd6f22f43ac in favor of using plain uint32. M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/include/access/heapam.h
M src/include/access/tableam.h
Thread flags through begin-scan APIs
commit : dcd8cc1c852cac4e65d336a79afb6b9eb9700ae1
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 12:27:24 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 12:27:24 -0400 Add an AM user-settable flags parameter to several of the table scan
functions, one table AM callback, and index_beginscan(). This allows
users to pass additional context to be used when building the scan
descriptors.
For index scans, a new flags field is added to IndexFetchTableData, and
the heap AM saves the caller-provided flags there.
This introduces an extension point for follow-up work to pass per-scan
information (such as whether the relation is read-only for the current
query) from the executor to the AM layer.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/2be31f17-5405-4de9-8d73-90ebc322f7d8%40vondra.me M contrib/pgrowlocks/pgrowlocks.c
M src/backend/access/brin/brin.c
M src/backend/access/gin/gininsert.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/index/genam.c
M src/backend/access/index/indexam.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/table/tableam.c
M src/backend/commands/constraint.c
M src/backend/commands/copyto.c
M src/backend/commands/tablecmds.c
M src/backend/commands/typecmds.c
M src/backend/executor/execIndexing.c
M src/backend/executor/execReplication.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/backend/executor/nodeSamplescan.c
M src/backend/executor/nodeSeqscan.c
M src/backend/executor/nodeTidrangescan.c
M src/backend/partitioning/partbounds.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
Detect pfree or repalloc of a previously-freed memory chunk.
commit : 095555daf1246ac28595fcf5b26bbb4686b0cdb6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 30 Mar 2026 12:02:08 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 30 Mar 2026 12:02:08 -0400 Before the major rewrite in commit c6e0fe1f2, AllocSetFree() would
typically crash when asked to free an already-free chunk. That was
an ugly but serviceable way of detecting coding errors that led to
double pfrees. But since that rewrite, double pfrees went through
just fine, because the "hdrmask" of a freed chunk isn't changed at all
when putting it on the freelist. We'd end with a corrupt freelist
that circularly links back to the doubly-freed chunk, which would
usually result in trouble later, far removed from the actual bug.
This situation is no good at all for debugging purposes. Fortunately,
we can fix it at low cost in MEMORY_CONTEXT_CHECKING builds by making
AllocSetFree() check for chunk->requested_size == InvalidAllocSize,
relying on the pre-existing code that sets it that way just below.
I investigated the alternative of changing a freed chunk's methodid
field, which would allow detection in non-MEMORY_CONTEXT_CHECKING
builds too. But that adds measurable overhead. Seeing that we didn't
notice this oversight for more than three years, it's hard to argue
that detecting this type of bug is worth any extra overhead in
production builds.
Likewise fix AllocSetRealloc() to detect repalloc() on a freed chunk,
and apply similar changes in generation.c and slab.c. (generation.c
would hit an Assert failure anyway, but it seems best to make it act
like aset.c.) bump.c doesn't need changes since it doesn't support
pfree in the first place. Ideally alignedalloc.c would receive
similar changes, but in debugging builds it's impossible to reach
AlignedAllocFree() or AlignedAllocRealloc() on a pfreed chunk, because
the underlying context's pfree would have wiped the chunk header of
the aligned chunk. But that means we should get an error of some
sort, so let's be content with that.
Per investigation of why the test case for bug #19438 didn't appear to
fail in v16 and up, even though the underlying bug was still present.
(This doesn't fix the underlying double-free bug, just cause it to
get detected.)
Bug: #19438
Reported-by: Dmitriy Kuzmin <kuzmin.db4@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19438-9d37b179c56d43aa@postgresql.org
Backpatch-through: 16 M src/backend/utils/mmgr/aset.c
M src/backend/utils/mmgr/generation.c
M src/backend/utils/mmgr/slab.c
Fix outdated comment on MainLWLockArray
commit : bd365b1ae510005eda5633702d2fa9325ee8ab61
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 17:13:11 +0300
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 30 Mar 2026 17:13:11 +0300 It's no longer passed to child processes down via BackendParameters in
EXEC_BACKEND mode.
Reported-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAA5RZ0vPWNMvTBqyH7nqDRrHd6Y4Et5iNqXFuwpbsPOk3cL4rQ@mail.gmail.com M src/backend/storage/lmgr/lwlock.c
pg_plan_advice: Avoid assertion failure with partitionwise aggregate.
commit : e2ee95233cab32a0d5fe64925aefe816c13dbbc0
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 30 Mar 2026 09:58:25 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 30 Mar 2026 09:58:25 -0400 An Append node that is part of a partitionwise aggregate has no
apprelids. If such a node was elided, the previous coding would
attempt to call unique_nonjoin_rtekind() on a NULL pointer, which
leads to an assertion failure. Insert a NULL check to prevent that.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: http://postgr.es/m/0afba1ce-c946-4131-972d-191d9a1c097c@gmail.com M contrib/pg_plan_advice/pgpa_scan.c
Remove PlannedStmt->resultRelations in favor of resultRelationRelids
commit : 39dcd10a2c493821cc88a9f8d17677507571e87d
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 09:51:28 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 09:51:28 -0400 PlannedStmt->resultRelations was an integer list of range table indexes
because at the time it was added (to Query), the Bitmapset data type did
not yet exist in Postgres.
0f4c170cf3b added a Bitmapset of result relations, so remove the integer
list of RTIs and use the more compact resultRelationRelids.
Discussion: https://postgr.es/m/CAApHDvqAOeOwCKh9g0gfxWa040%3DHyc7_oA%3DC59rjod8kXJDWyw%40mail.gmail.com M contrib/pg_overexplain/pg_overexplain.c
M src/backend/executor/execParallel.c
M src/backend/executor/execUtils.c
M src/backend/optimizer/plan/planner.c
M src/include/nodes/plannodes.h
Make it cheap to check if a relation is modified by a query
commit : 0f4c170cf3b85ef8b092990a88e5b7b50892f7d5
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 09:38:03 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 30 Mar 2026 09:38:03 -0400 Save the range table indexes of result relations and row mark relations
in separate bitmapsets in the PlannedStmt. Precomputing them allows
cheap membership checks during execution. Together, these two groups
approximate all relations that will be modified by a query. This
includes relations targeted by INSERT, UPDATE, DELETE, and MERGE as well
as relations with any row mark (like SELECT FOR UPDATE).
Future work will use information on whether or not a relation is
modified by a query in a heuristic.
PlannedStmt->resultRelations is only used in a membership check, so it
will be removed in a separate commit.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/F5CDD1B5-628C-44A1-9F85-3958C626F6A9%40gmail.com M src/backend/executor/execParallel.c
M src/backend/optimizer/plan/planner.c
M src/include/nodes/plannodes.h
Have table_insert and siblings use an unsigned type for options
commit : 1bd6f22f43ac1bd2215ba4ef720fc4f18fea26e5
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 30 Mar 2026 13:27:04 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 30 Mar 2026 13:27:04 +0200 Using signed types can lead to bugs, such as the one fixed by commit
2a2e1b470b9b.
Discussion: https://postgr.es/m/44e6ze3kuunhky63wmfjxrmn72pds2whwf5ok6hpz7c4my7k2h@l65zhpcuasnf M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/include/access/heapam.h
M src/include/access/tableam.h
headerscheck: Avoid mutual inclusion of pg_config.h and c.h
commit : c546f008cddf9319ce500321a65eec2329ae6d6a
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 09:31:08 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 09:31:08 +0200 Headers that c.h includes early should not have another header
included before them in the headerscheck test file, especially not
c.h.
A particular instance of a problem is that pg_config.h defines some
symbols that c.h later undefines in some cases, such as in the code
added by commit cd083b54bd67, but there were also some before that.
This only works correctly if pg_config.h is included first.
pg_config_manual.h and pg_config_os.h are closely related to
pg_config.h and should be treated the same way.
postgres_ext.h is meant to be usable standalone, so testing it with
c.h included first defeats the point.
c.h also includes port.h, but this commit leaves that alone, since
port.h does need some of c.h to be processed first. (But because of
header guards, testing port.h separately is probably ineffective.)
Discussion: https://www.postgresql.org/message-id/flat/579116be-5016-4dbc-aed0-c06f8d9f5bbb%40eisentraut.org M src/tools/pginclude/headerscheck
Make cast functions to type money error safe
commit : b36b95640487b9dc70408e9078c30e80963efccb
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 10:05:22 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 10:05:22 +0200 This converts the cast functions from types integer, bigint, and
numeric to type money to support soft errors.
Note: Casting from type money to type numeric (the other way, function
cash_numeric) is not yet error safe.
Author: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CADkLM%3Dfv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ%40mail.gmail.com M src/backend/utils/adt/cash.c
Remove extraneous PGDLLIMPORT
commit : ec5981c3816e46a5d38d2834e406257bb5563429
author : John Naylor <john.naylor@postgresql.org>
date : Mon, 30 Mar 2026 14:39:13 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Mon, 30 Mar 2026 14:39:13 +0700 Oversight from commit 3c6e8c123896. Should be harmless, so no
backpatch.
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAN4CZFM8jmh4+1rUR2c++JWK9sV85T8_mqmwHMvM0YWkTm4_dQ@mail.gmail.com M src/include/port/pg_crc32c.h
Fix accidentally casting away const
commit : 75a5914d005b5b65090567eb08343b6a962c89cf
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 09:21:49 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 09:21:49 +0200 Recently introduced in commit b15c1513984. M src/bin/pg_waldump/archive_waldump.c
Make cast function from circle to polygon error safe
commit : 26f9012beecf36bcffc5a2081c7e698d3ecf6aa2
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 09:06:27 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 30 Mar 2026 09:06:27 +0200 Previously, the function casting type circle to type polygon could not
be made error safe, because it is an SQL language function.
This refactors it as a C/internal function, by sharing code with the
C/internal function that the SQL function previously wrapped, and soft
error support is added.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: Discussion: https://www.postgresql.org/message-id/flat/CADkLM%3Dfv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ%40mail.gmail.com M src/backend/catalog/system_functions.sql
M src/backend/utils/adt/geo_ops.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
Fix FK triggers losing DEFERRABLE/INITIALLY DEFERRED when marked ENFORCED again
commit : 2497dac55648e738b643577e807bfd2a3ac4c6e2
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 30 Mar 2026 14:37:33 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 30 Mar 2026 14:37:33 +0900 Previously, a foreign key defined as DEFERRABLE INITIALLY DEFERRED could
behave as NOT DEFERRABLE after being set to NOT ENFORCED and then back
to ENFORCED.
This happened because recreating the FK triggers on re-enabling the constraint
forgot to restore the tgdeferrable and tginitdeferred fields in pg_trigger.
Fix this bug by properly setting those fields when the foreign key constraint
is marked ENFORCED again and its triggers are recreated, so the original
DEFERRABLE and INITIALLY DEFERRED properties are preserved.
Backpatch to v18, where NOT ENFORCED foreign keys were introduced.
Author: Yasuo Honda <yasuo.honda@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAKmOUTms2nkxEZDdcrsjq5P3b2L_PR266Hv8kW5pANwmVaRJJQ@mail.gmail.com
Backpatch-through: 18 M src/backend/commands/tablecmds.c
M src/test/regress/expected/foreign_key.out
M src/test/regress/sql/foreign_key.sql
Fix datum_image_*()'s inability to detect sign-extension variations
commit : 0d866282b841a198bff0e6bbfc75493e46ecd126
author : David Rowley <drowley@postgresql.org>
date : Mon, 30 Mar 2026 16:14:34 +1300
committer: David Rowley <drowley@postgresql.org>
date : Mon, 30 Mar 2026 16:14:34 +1300 Functions such as hash_numeric() are not careful to use the correct
PG_RETURN_*() macro according to the return type of that function as
defined in pg_proc. Because that function is meant to return int32,
when the hashed value exceeds 2^31, the 64-bit Datum value won't wrap to
a negative number, which means the Datum won't have the same value as it
would have had it been cast to int32 on a two's complement machine. This
isn't harmless as both datum_image_eq() and datum_image_hash() may receive
a Datum that's been formed and deformed from a tuple in some cases, and
not in other cases. When formed into a tuple, the Datum value will be
coerced into an integer according to the attlen as specified by the
TupleDesc. This can result in two Datums that should be equal being
classed as not equal, which could result in (but not limited to) an error
such as:
ERROR: could not find memoization table entry
Here we fix this by ensuring we cast the Datum value to a signed integer
according to the typLen specified in the datum_image_eq/datum_image_hash
function call before comparing or hashing.
Author: David Rowley <dgrowleyml@gmail.com>
Reported-by: Tender Wang <tndrwang@gmail.com>
Backpatch-through: 14
Discussion: https://postgr.es/m/CAHewXNmcXVFdB9_WwA8Ez0P+m_TQy_KzYk5Ri5dvg+fuwjD_yw@mail.gmail.com M src/backend/utils/adt/datum.c
psql: Make \d+ inheritance tables list formatting consistent with other objects
commit : 1a11405a436038293f425f2ffc41b02235eda912
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 30 Mar 2026 11:21:22 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 30 Mar 2026 11:21:22 +0900 This followw up on the previous change (commit 7bff9f106a5) for partitions by
applying the same formatting to inheritance tables lists.
Previously, \d+ <table> displayed inheritance tables differently from other
object lists: the first inheritance table appeared on the same line as the
"Inherits" header. For example:
Inherits: test_like_5,
test_like_5x
This commit updates the output so that inheritance tables are listed
consistently with other objects, with each entry on its own line starting
below the header:
Inherits:
test_like_5
test_like_5x
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>
Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com>
Reviewed-by: Soumya S Murali <soumyamurali.work@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pu1puO00C-OhgLnAcECzww8MB3Q8DCsvx0cZWHRfs4gBQ@mail.gmail.com M src/bin/psql/describe.c
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/constraints.out
M src/test/regress/expected/create_table_like.out
M src/test/regress/expected/foreign_data.out
M src/test/regress/expected/generated_stored.out
M src/test/regress/expected/generated_virtual.out
M src/test/regress/expected/inherit.out
M src/test/regress/expected/triggers.out
M src/test/regress/expected/without_overlaps.out
psql: Make \d+ partition list formatting consistent with other objects
commit : 7bff9f106a5ec36bd97829ca7eb97fc2a4705406
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 30 Mar 2026 11:06:42 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 30 Mar 2026 11:06:42 +0900 Previously, \d+ <table> displayed partitions differently from other object
lists: the first partition appeared on the same line as the "Partitions"
header. For example:
Partitions: pt12 FOR VALUES IN (1, 2),
pt34 FOR VALUES IN (3, 4)
This commit updates the output so that partitions are listed consistently
with other objects, with each entry on its own line starting below the header:
Partitions:
pt12 FOR VALUES IN (1, 2)
pt34 FOR VALUES IN (3, 4)
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>
Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com>
Reviewed-by: Soumya S Murali <soumyamurali.work@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pu1puO00C-OhgLnAcECzww8MB3Q8DCsvx0cZWHRfs4gBQ@mail.gmail.com M contrib/seg/expected/partition.out
M src/bin/psql/describe.c
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/constraints.out
M src/test/regress/expected/create_table.out
M src/test/regress/expected/foreign_data.out
M src/test/regress/expected/inherit.out
M src/test/regress/expected/insert.out
M src/test/regress/expected/partition_split.out
M src/test/regress/expected/replica_identity.out
M src/test/regress/expected/rowsecurity.out
M src/test/regress/expected/tablespace.out
Doc: fix stale text about partition locking with cached plans
commit : c57d8178eb06ec001b6538c3bb985e079b6d329b
author : Amit Langote <amitlan@postgresql.org>
date : Mon, 30 Mar 2026 10:29:21 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Mon, 30 Mar 2026 10:29:21 +0900 Commit 121d774caea added text to master describing pruning-aware
locking behavior introduced by 525392d57. That behavior was
reverted in May 2025, making the text incorrect. Replace it with
the text used in back branches, which correctly describes current
behavior: pruned partitions are still locked at the beginning of
execution.
Discussion: https://postgr.es/m/CA+HiwqFT0fPPoYBr0iUFWNB-Og7bEXB9hB=6ogk_qD9=OM8Vbw@mail.gmail.com M doc/src/sgml/ddl.sgml
Add comment explaining fire_triggers=false in ri_PerformCheck()
commit : 1ad7191f7e927ecda72928a9f1e69d40edfed3e4
author : Amit Langote <amitlan@postgresql.org>
date : Mon, 30 Mar 2026 10:10:17 +0900
committer: Amit Langote <amitlan@postgresql.org>
date : Mon, 30 Mar 2026 10:10:17 +0900 The reason for passing fire_triggers=false to SPI_execute_snapshot()
in ri_PerformCheck() was not documented, making it unclear why it was
done that way. Add a comment explaining that it ensures AFTER triggers
on rows modified by the RI action are queued in the outer query's
after-trigger context and fire only after all RI updates on the same
row are complete.
Author: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Discussion: https://postgr.es/m/20250331212648.ad4ab804559001d7f0788741@sraoss.co.jp M src/backend/utils/adt/ri_triggers.c
Make geometry cast functions error safe
commit : 45cdaf3665bedfbabb908bb84284f3db26781ad3
author : Peter Eisentraut <peter@eisentraut.org>
date : Sun, 29 Mar 2026 20:40:50 +0200
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sun, 29 Mar 2026 20:40:50 +0200 This adjusts cast functions of the geometry types to support soft
errors. This requires refactoring of various helper functions to
support error contexts. Also make the float8 to float4 cast error
safe. It requires some of the same helper functions.
This is in preparation for a future feature where conversion errors in
casts can be caught.
(The function casting type circle to type polygon is not yet made error
safe, because it is an SQL language function.)
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CADkLM%3Dfv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ%40mail.gmail.com M src/backend/utils/adt/float.c
M src/backend/utils/adt/geo_ops.c
M src/include/utils/float.h
Doc: document more incompatible pg_restore option pairs.
commit : d4cb9c37765a3d07784602679a1e7af7ecf15f1d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 29 Mar 2026 14:06:50 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 29 Mar 2026 14:06:50 -0400 Most of the pairs of incompatible options (such as --file and --dbname)
are pretty obvious and need no explanation. But it may not be obvious
that --single-transaction cannot be used together with --create or
multiple jobs, so let's mention that in the documentation.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Discussion: https://postgr.es/m/CAExHW5ti5igDwOOde6shgfS7JPtCY9gNrkB3xNr=FuGTYVDSjQ@mail.gmail.com M doc/src/sgml/ref/pg_restore.sgml
Doc: clarify introductory description of pg_dumpall.
commit : e7b809ae758636833e1e8a248ac6a6834eb034a1
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 29 Mar 2026 13:53:17 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 29 Mar 2026 13:53:17 -0400 Add a sentence that describes the parts of a cluster's state that are
*not* included in the output.
Also swap two sentences in the introductory paragraph. Without that,
it is not clear what the "it" at the beginning of the second sentence
is referring to. Also add a reference to pg_restore, since not all
output formats are restored with pg_dump.
Also clarify the recently-added text about where different output
formats go, and relocate it above the ancillary text about having
to run as superuser.
Reported-by: Dimitre Radoulov <cichomitiko@gmail.com>
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAGJBphSX2oMPPu=VM4U8NP4+qffFH_483tFQCJ_s-mOcN3DLDw@mail.gmail.com M doc/src/sgml/ref/pg_dumpall.sgml
Fix multiple bugs in astreamer pipeline code.
commit : 01d58d7e3ff3f7482ff478cb4a49c48aad276138
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 23 Mar 2026 16:17:08 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 23 Mar 2026 16:17:08 -0400 astreamer_tar_parser_content() sent the wrong data pointer when
forwarding MEMBER_TRAILER padding to the next streamer. After
astreamer_buffer_until() buffers the padding bytes, the 'data'
pointer has been advanced past them, but the code passed 'data'
instead of bbs_buffer.data. This caused the downstream consumer
to receive bytes from after the padding rather than the padding
itself, and could read past the end of the input buffer.
astreamer_gzip_decompressor_content() only checked for
Z_STREAM_ERROR from inflate(), silently ignoring Z_DATA_ERROR
(corrupted data) and Z_MEM_ERROR (out of memory). Fix by
treating any return other than Z_OK, Z_STREAM_END, and
Z_BUF_ERROR as fatal.
astreamer_gzip_decompressor_free() missed calling inflateEnd() to
release zlib's internal decompression state.
astreamer_tar_parser_free() neglected to pfree() the streamer
struct itself, leaking it.
astreamer_extractor_content() did not check the return value of
fclose() when closing an extracted file. A deferred write error
(e.g., disk full on buffered I/O) would be silently lost.
Discussion: https://postgr.es/m/results/98c6b630-acbb-44a7-97fa-1692ce2b827c@dunslane.net
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 15 M src/fe_utils/astreamer_file.c
M src/fe_utils/astreamer_gzip.c
M src/fe_utils/astreamer_tar.c
Sort InternalBGWorkers list alphabetically
commit : 0841b219bf0b2413e61cd1526781bedfdb50f458
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sun, 29 Mar 2026 14:15:00 +0200
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sun, 29 Mar 2026 14:15:00 +0200 This simplifies deciding where to add a new one. M src/backend/postmaster/bgworker.c
Make cast functions from jsonb error safe
commit : 10e4d8aaf46fb46b8b78e026560b68af84a6495b
author : Peter Eisentraut <peter@eisentraut.org>
date : Sat, 28 Mar 2026 15:44:13 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sat, 28 Mar 2026 15:44:13 +0100 This adjusts cast functions from jsonb to other types to support soft
errors. This just involves some refactoring of the underlying helper
functions to use ereturn.
This is in preparation for a future feature where conversion errors in
casts can be caught.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CADkLM%3Dfv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ%40mail.gmail.com M src/backend/utils/adt/jsonb.c
aio: Don't wait for already in-progress IO
commit : 999dec9ec6a81668057427c2e9312b20635fba02
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 19:51:53 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 19:51:53 -0400 When a backend attempts to start a read IO and finds the first buffer already
has I/O in progress, previously it waited for that I/O to complete before
initiating reads for any of the subsequent buffers.
Although it must wait for the I/O to finish when acquiring the buffer, there's
no reason for it to wait when setting up the read operation. Waiting at this
point prevents starting I/O on subsequent buffers and can significantly reduce
concurrency.
This matters in two workloads:
1) When multiple backends scan the same relation concurrently.
2) When a single backend requests the same block multiple times within the
readahead distance.
Waiting each time an in-progress read is encountered effectively degenerates
the access pattern into synchronous I/O.
To fix this, when encountering an already in-progress IO for the head buffer,
the wait reference is now recorded and waiting is deferred until
WaitReadBuffers(), when the buffer actually needs to be acquired.
In rare cases, a backend may still need to wait synchronously at IO
start time: If another backend has set BM_IO_IN_PROGRESS on the buffer
but has not yet set the wait reference. Such windows should be brief and
uncommon.
Author: Melanie Plageman <melanieplageman@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/flat/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw%403p3zu522yykv M src/backend/storage/buffer/bufmgr.c
M src/include/storage/bufmgr.h
M src/test/modules/test_aio/t/001_aio.pl
M src/test/modules/test_aio/test_aio–1.0.sql
M src/test/modules/test_aio/test_aio.c
bufmgr: Improve StartBufferIO interface
commit : 74eafeab1a576620879e889ec70bf826e3e7fce8
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 19:02:23 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 19:02:23 -0400 Until now StartBufferIO() had a few weaknesses:
- As it did not submit staged IOs, it was not safe to call StartBufferIO()
where there was a potential for unsubmitted IO, which required
AsyncReadBuffers() to use a wrapper (ReadBuffersCanStartIO()) around
StartBufferIO().
- With nowait = true, the boolean return value did not allow to distinguish
between no IO being necessary and having to wait, which would lead
ReadBuffersCanStartIO() to unnecessarily submit staged IO.
- Several callers needed to handle both local and shared buffers, requiring
the caller to differentiate between StartBufferIO() and StartLocalBufferIO()
- In a future commit some callers of StartBufferIO() want the BufferDesc's
io_wref to be returned, to asynchronously wait for in-progress IO
- Indicating whether to wait with the nowait parameter was somewhat confusing
compared to a wait parameter
Address these issues as follows:
- StartBufferIO() is renamed to StartSharedBufferIO()
- A new StartBufferIO() is introduced that supports both shared and local
buffers
- The boolean return value has been replaced with an enum, indicating whether
the IO is already done, already in progress or that the buffer has been
readied for IO
- A new PgAioWaitRef * argument allows the caller to get the wait reference is
desired. All current callers pass NULL, a user of this will be introduced
subsequently
- Instead of the nowait argument there now is wait
This probably would not have been worthwhile on its own, but since all these
lines needed to be touched anyway...
Author: Andres Freund <andres@anarazel.de>
Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/buffer/localbuf.c
M src/include/storage/buf_internals.h
M src/test/modules/test_aio/t/001_aio.pl
M src/test/modules/test_aio/test_aio–1.0.sql
M src/test/modules/test_aio/test_aio.c
M src/tools/pgindent/typedefs.list
Fix RequestNamedLWLockTranche in single-user mode
commit : 2407c8db159dbae5afd23080a92122e1acb2f5c1
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 28 Mar 2026 01:02:11 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sat, 28 Mar 2026 01:02:11 +0200 PostmasterContext is not available in single-user mode, use
TopMemoryContext instead. Also make sure that we use the correct
memory context in the lappend().
Author: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/acb_Eo1XtmCO_9z7@nathan M src/backend/storage/lmgr/lwlock.c
test_aio: Add read_stream test infrastructure & tests
commit : 1f6f200cab67e67f1c20d9c9ca5013e0f23f51e4
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 18:47:04 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 18:47:04 -0400 While we have a lot of indirect coverage of read streams, there are corner
cases that are hard to test when only indirectly controlling and observing the
read stream. This commit adds an SQL callable SRF interface for a read stream
and uses that in a few tests.
To make some of the tests possible, the injection point infrastructure in
test_aio had to be expanded to allow blocking IO completion.
While at it, fix a wrong debug message in inj_io_short_read_hook().
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/test/modules/test_aio/meson.build
A src/test/modules/test_aio/t/004_read_stream.pl
M src/test/modules/test_aio/test_aio–1.0.sql
M src/test/modules/test_aio/test_aio.c
M src/tools/pgindent/typedefs.list
test_aio: Add basic tests for StartReadBuffers()
commit : 020c02bd90896066964d173139b3adb154ec7426
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 18:44:35 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 18:44:35 -0400 Upcoming commits will change StartReadBuffers() and its building blocks,
making it worthwhile to directly test StartReadBuffers().
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/test/modules/test_aio/t/001_aio.pl
M src/test/modules/test_aio/test_aio–1.0.sql
M src/test/modules/test_aio/test_aio.c
Doc: split functions-posix-regexp section into multiple subsections.
commit : 00c025a001170979e99706ce746f75fcc615761d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Mar 2026 17:41:00 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Mar 2026 17:41:00 -0400 Create a <sect4> section for each function that the previous text
described in one long series of paragraphs. Also split the functions'
previously in-line syntax summaries into <synopsis> clauses, which is
more readable and allows us to sneak in an explicit mention of the
result data type.
This change gives us an opportunity to make cross-reference links
more specific, too, so do that.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CACJufxFuk9P=P4=BZ=qCkgvo6im8aL8NnCkjxx2S2MQDWNdouw@mail.gmail.com M doc/src/sgml/func/func-json.sgml
M doc/src/sgml/func/func-matching.sgml
M doc/src/sgml/func/func-string.sgml
M doc/src/sgml/ref/psql-ref.sgml
bufmgr: Make UnlockReleaseBuffer() more efficient
commit : f39cb8c011062d65e146c1e9d1aae221e96d8320
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 15:27:04 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 15:27:04 -0400 Now that the buffer content lock is implemented as part of BufferDesc.state,
releasing the lock and unpinning the buffer can be implemented as a single
atomic operation.
This improves workloads that have heavy contention on a small number of
buffers substantially, I e.g., see a ~20% improvement for pipelined readonly
pgbench on an older two socket machine.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d M src/backend/storage/buffer/bufmgr.c
Use UnlockReleaseBuffer() in more places
commit : 8df3c48e466cfe8a1f9ccd3fb367244d4a47e94a
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 15:27:04 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 15:27:04 -0400 An upcoming commit will make UnlockReleaseBuffer() considerably faster and
more scalable than doing LockBuffer(BUFFER_LOCK_UNLOCK); ReleaseBuffer();. But
it's a small performance benefit even as-is.
Most of the callsites changed in this patch are not performance sensitive,
however some, like the nbtree ones, are in critical paths.
This patch changes all the easily convertible places over to
UnlockReleaseBuffer() mainly because I needed to check all of them anyway, and
reducing cases where the operations are done separately makes the checking
easier.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d M contrib/amcheck/verify_gin.c
M contrib/pageinspect/rawpage.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/hio.c
M src/backend/access/nbtree/nbtpage.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/freespace/freespace.c
M src/test/modules/test_aio/test_aio.c
bufmgr: Don't copy pages while writing out
commit : 41d3d64e87af3f16833b095032affe404443659b
author : Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 15:27:04 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 27 Mar 2026 15:27:04 -0400 After the series of preceding commits introducing and using
BufferBeginSetHintBits()/BufferSetHintBits16(), hint bits are not set anymore
while IO is going on. Therefore we do not need to copy pages while they are
being written out anymore.
For the same reason XLogSaveBufferForHint() now does not need to operate on a
copy of the page anymore, but can instead use the normal XLogRegisterBuffer()
mechanism. For that the assertions and comments to XLogRegisterBuffer() had to
be updated to allow share-exclusive locked buffers to be registered.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d M src/backend/access/hash/hashpage.c
M src/backend/access/transam/xloginsert.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/buffer/localbuf.c
M src/backend/storage/page/bufpage.c
M src/backend/storage/smgr/bulk_write.c
M src/include/storage/bufpage.h
M src/test/modules/test_aio/test_aio.c
pgindent: ensure all C files end with a newline.
commit : 79ac82125ef6608b8a1c7e089eea17476537467c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Mar 2026 15:38:48 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Mar 2026 15:38:48 -0400 Not only is this good style, but it dodges some obscure bugs within
pg_bsd_indent. We could try to fix said bugs, but the amount of
effort required seems far out of proportion to the benefit.
Reported-by: Akshay Joshi <akshay.joshi@enterprisedb.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CANxoLDfca8O5SkeDxB_j6SVNXd+pNKaDmVmEW+2yyicdU8fy0w@mail.gmail.com M src/tools/pgindent/pgindent
doc: Clarify collation requirements for base32hex sortability.
commit : e752a2ccc98f324e7013cc4eabc1998d5a1020d0
author : Masahiko Sawada <msawada@postgresql.org>
date : Fri, 27 Mar 2026 12:13:29 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Fri, 27 Mar 2026 12:13:29 -0700 While fixing the base32hex UUID sortability test in commit
89210037a0a, it turned out that the expected lexicographical order is
only maintained under the C collation (or an equivalent byte-wise
collation). Natural language collations may employ different rules,
breaking the sortability.
This commit updates the documentation to explicitly state that
base32hex is "byte-wise sortable", ensuring users do not fall into the
trap of using natural language collations when querying their encoded
data.
Co-Authored-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CAD21AoAwX1D6baSGuQXm0mzPXPWB07kgaoaaahjNHHenbdY24A@mail.gmail.com M doc/src/sgml/func/func-binarystring.sgml
Add rudimentary table prioritization to autovacuum.
commit : d7965d65fc5bb2139bc51c051c11428414c65160
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 27 Mar 2026 10:17:05 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 27 Mar 2026 10:17:05 -0500 Autovacuum workers scan pg_class twice to collect the set of tables
to process. The first pass is for plain relations and materialized
views, and the second is for TOAST tables. When the worker finds a
table to process, it adds it to the end of a list. Later on, it
processes the tables in the same order as the list. This simple
strategy has worked surprisingly well for a long time, but there
have been many discussions over the years about trying to improve
it.
This commit introduces a scoring system that is used to sort the
aforementioned list of tables to process. The idea is to have
autovacuum workers prioritize tables that are furthest beyond their
thresholds (e.g., a table nearing transaction ID wraparound should
be vacuumed first). This prioritization scheme is certainly far
from perfect; there are simply too many possibilities for any
scoring technique to work across all workloads, and the situation
might change significantly between the time we calculate the score
and the time that autovacuum processes it. However, we have
attemped to develop something that is expected to work for a large
portion of workloads with reasonable parameter settings.
The score is calculated as the maximum of the ratios of each of the
table's relevant values to its threshold. For example, if the
number of inserted tuples is 100, and the insert threshold for the
table is 80, the insert score is 1.25. If all other scores are
below that value, the table's score will be 1.25. The other
criteria considered for the score are the table ages (both
relfrozenxid and relminmxid) compared to the corresponding
freeze-max-age setting, the number of update/deleted tuples
compared to the vacuum threshold, and the number of
inserted/updated/deleted tuples compared to the analyze threshold.
Once exception to the previous paragraph is for tables nearing
wraparound, i.e., those that have surpassed the effective failsafe
ages. In that case, the relfrozenxid/relminmxid-based score is
scaled aggressively so that the table has a decent chance of
sorting to the front of the list.
To adjust how strongly each component contributes to the score, the
following parameters can be adjusted from their default of 1.0 to
anywhere between 0.0 and 10.0 (inclusive). Setting all of these to
0.0 restores pre-v19 prioritization behavior:
autovacuum_freeze_score_weight
autovacuum_multixact_freeze_score_weight
autovacuum_vacuum_score_weight
autovacuum_vacuum_insert_score_weight
autovacuum_analyze_score_weight
This is intended to be a baby step towards smarter autovacuum
workers. Possible future improvements include, but are not limited
to, periodic reprioritization, automatic cost limit adjustments,
and better observability (e.g., a system view that shows current
scores). While we do not expect this commit to produce any
earth-shattering improvements, it is arguably a prerequisite for
the aforementioned follow-up changes.
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/aOaAuXREwnPZVISO%40nathan M doc/src/sgml/config.sgml
M doc/src/sgml/maintenance.sgml
M src/backend/postmaster/autovacuum.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/include/postmaster/autovacuum.h
M src/tools/pgindent/typedefs.list
Align tests for stored and virtual generated columns
commit : 9a9998163bda0d8c17d84ea22ced6a60f8018634
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 15:49:34 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 15:49:34 +0100 These tests were intended to be aligned with each other, but
additional tests for virtual generated columns disrupted that
alignment. The test confirming that user-defined types are not
allowed in virtual generated columns has also been moved to the
generated_virtual.sql-specific section.
Author: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Mutaamba Maasha <maasha@gmail.com>
Reviewed-by: Surya Poondla <s_poondla@apple.com>
Discussion: https://www.postgresql.org/message-id/flat/20250808115142.e9ccb81f35466a9a131a4c55@sraoss.co.jp 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
pgindent: Always clean up .BAK files from pg_bsd_indent
commit : 6857947db5bbec823226cd5234f088524f933caa
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 14:24:52 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 14:24:52 +0100 The previous commit let pgindent clean up File::Temp files on SIGINT.
This extends that to also cleaning up the .BAK files, created by
pg_bsd_indent.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/DFCDD5H4J7VX.3GJKRBBDCKQ86@jeltef.nl M src/tools/pgindent/pgindent
pgindent: Clean up temp files created by File::Temp on SIGINT
commit : 801de0bd443375ed3928ef44f2ee70a734d2a4d5
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 14:24:13 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 14:24:13 +0100 When pressing Ctrl+C while running pgindent, it would often leave around
files like pgtypedefAXUEEA. This slightly changes SIGINT handling so
those files are cleaned up.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/DFCDD5H4J7VX.3GJKRBBDCKQ86@jeltef.nl M src/tools/pgindent/pgindent
Refactor PredicateLockShmemInit to not reuse var for different things
commit : 3fd0577728277e66f072f3b07adf78299dfad7cc
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 27 Mar 2026 13:24:34 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 27 Mar 2026 13:24:34 +0200 The PredicateLockShmemInit function is pretty complicated, and one
source of confusion is that it reuses the same local variable for
sizes of things. Replace the different uses with separate variables
for clarity.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/113724ab-0028-493f-9605-6e8570f0939f@iki.fi M src/backend/storage/lmgr/predicate.c
Avoid memory leak on error while parsing pg_stat_statements dump file
commit : 3c74cb5762db6373187c3cf83f1b955e88773e33
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 27 Mar 2026 12:20:38 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 27 Mar 2026 12:20:38 +0200 By using palloc() instead of raw malloc().
Reported-by: Gaurav Singh <gaurav.singh@yugabyte.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAEcQ1bYR9s4eQLFDjzzJHU8fj-MTbmRpW-9J-r2gsCn+HEsynw@mail.gmail.com
Backpatch-through: 14 M contrib/pg_stat_statements/pg_stat_statements.c
Add a graph pattern variable only once
commit : 288ae968726ebaca587a446041fe0e0a6377562d
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 10:49:49 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 10:49:49 +0100 An element pattern variable may be repeated in the path pattern.
GraphTableParseState maintains a list of all variable names used in
the graph pattern. Add a new variable name to that list only when it
is not present already. This isn't a problem right now, but it could
be in the future.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5tR4O0vjeqTCPr2VB5pYjNYbJgbCBEQf63NtU5Pz1MiOQ%40mail.gmail.com M src/backend/parser/parse_graphtable.c
Minor comment fixes to yesterday's LWLock tranche refactoring
commit : 98993150c0a4c082cdb8864ae20c0bb934ad27cb
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 27 Mar 2026 11:44:10 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 27 Mar 2026 11:44:10 +0200 Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAA5RZ0sLENRM+BicUjQFs_rP38oPx3gm0SsGrD0-jMhhM+HZ_w@mail.gmail.com M src/backend/storage/lmgr/lwlock.c
Reject consecutive element patterns of same kind
commit : 720f0f89d696a5c12817359b5c0f3da8e7ebdfe8
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 10:30:01 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Mar 2026 10:30:01 +0100 Adding an implicit empty vertex pattern when a path pattern starts or
ends with an edge pattern or when two consecutive edge patterns appear
in the pattern is not supported right now. Prohibit such path
patterns.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/72a23702-6d96-4103-a54b-057c2352e885%2540eisentraut.org M src/backend/parser/parse_graphtable.c
M src/backend/rewrite/rewriteGraphTable.c
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/graph_table.sql
Enable warning like -Wstrict-prototypes on MSVC as well
commit : b4a132022444e051fb402648d08f9ed487b2c45e
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 15:03:30 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 15:03:30 +0100 This adds an MSVC warning option equivalent to those added in commit
29bf4ee7496 for GCC/Clang.
Note that this requires commit bccfc73acde (Disable warnings in system
headers in MSVC).
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal M meson.build
pg_plan_advice: pgindent
commit : 874da8b1f6143808a4433df645c1e81f6a8bbd1e
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 20:10:13 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 20:10:13 -0400 Reported-by: Lukas Fittl <lukas@fittl.com> M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/pgpa_planner.h
M contrib/pg_plan_advice/pgpa_walker.c
M src/include/nodes/pathnodes.h
Use ShmemInitStruct to allocate lwlock.c's shared memory
commit : 30d432502bf42343ec0f9ad599625cde0cb38e57
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:37 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:37 +0200 It's nice to have them show up in pg_shmem_allocations like all other
shmem areas. ShmemInitStruct() depends on ShmemIndexLock, but only
after postmaster startup.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi M src/backend/postmaster/launch_backend.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/lwlock.c
M src/include/storage/lwlock.h
Move ShmemIndexLock into ShmemAllocator
commit : 06d859aaf4e988ddef8adc55efb21324c5e30092
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:33 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:33 +0200 This makes shmem.c independent of the main LWLock array. That makes it
possible to stop passing MainLWLockArray through BackendParameters in
the next commit.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi M src/backend/storage/ipc/shmem.c
M src/backend/utils/activity/wait_event_names.txt
M src/include/storage/lwlocklist.h
Use a separate spinlock to protect LWLockTranches
commit : 12e3e0f2c8f7a47902b4c201ac31a12390f75657
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:29 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:29 +0200 Previously we reused the shmem allocator's ShmemLock to also protect
lwlock.c's shared memory structures. Introduce a separate spinlock for
lwlock.c for the sake of modularity. Now that lwlock.c has its own
shared memory struct (LWLockTranches), this is easy to do.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi M src/backend/storage/ipc/shmem.c
M src/backend/storage/lmgr/lwlock.c
M src/include/storage/shmem.h
Refactor how user-defined LWLock tranches are stored in shmem
commit : d6eba30a245cd258e0b62753088202284dc59dc0
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:22 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:47:22 +0200 Merge the LWLockTranches and NamedLWLockTrancheRequest data structures
in shared memory into one array of user-defined tranches. The
NamedLWLockTrancheRequest list is now only used in postmaster, to hold
the requests until shared memory is initialized.
Introduce a C struct, LWLockTranches, to hold all the different fields
kept in shared memory. This gives an easier overview of what are all
the things kept in shared memory. Previously, we had separate pointers
for LWLockTrancheNames, LWLockCounter and the (shared memory copy of)
NamedLWLockTrancheRequestArray.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi M src/backend/postmaster/launch_backend.c
M src/backend/storage/lmgr/lwlock.c
M src/include/storage/lwlock.h
M src/tools/pgindent/typedefs.list
Rename MAX_NAMED_TRANCHES to MAX_USER_DEFINED_TRANCHES
commit : cc88481aeb98326c528acb07114dd92f06de28c0
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:46:04 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 23:46:04 +0200 The "named tranches" term is a little confusing. In most places it
refers to tranches requested with RequestNamedLWLockTranche(), even
though all built-in tranches and tranches allocated with
LWLockNewTrancheId() also have a name. But in MAX_NAMED_TRANCHES, it
refers to tranches requested with either RequestNamedLWLockTranche()
or LWLockNewTrancheId(), as it's the maximum of all of those in total.
The "user defined" term is already used in
LWTRANCHE_FIRST_USER_DEFINED, so let's standardize on that to mean
tranches allocated with either RequestNamedLWLockTranche() or
LWLockNewTrancheId().
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://www.postgresql.org/message-id/47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi M src/backend/storage/lmgr/lwlock.c
Doc: declutter CREATE TABLE synopsis.
commit : a6d26e0fb29b8b644a495a6c2d5ed5c50b41addb
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 26 Mar 2026 17:27:32 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 26 Mar 2026 17:27:32 -0400 Factor out the "persistence mode" and storage/compression parts
of the syntax synopsis to reduce line lengths and increase
readability. Also add an introductory para about the persistence
modes so that the Description section still lines up with the
synopsis.
Author: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CAKFQuwYfMV-2SdrP-umr5SVNSqTn378BUvHsebetp5=DhT494w@mail.gmail.com M doc/src/sgml/ref/create_table.sgml
M doc/src/sgml/ref/create_table_as.sgml
pg_plan_advice: Invent DO_NOT_SCAN(relation_identifier).
commit : 6455e55b0da47255f332a96f005ba0dd1c7176c2
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 17:09:57 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 17:09:57 -0400 The premise of src/test/modules/test_plan_advice is that if we plan
a query once, generate plan advice, and then replan it using that
same advice, all of that advice should apply cleanly, since the
settings and everything else are the same. Unfortunately, that's
not the case: the test suite is the main regression tests, and
concurrent activity can change the statistics on tables involved
in the query, especially system catalogs. That's OK as long as it
only affects costing, but in a few cases, it affects which relations
appear in the final plan at all.
In the buildfarm failures observed to date, this happens because
we consider alternative subplans for the same portion of the query;
in theory, MinMaxAggPath is vulnerable to a similar hazard. In both
cases, the planner clones an entire subquery, and the clone has a
different plan name, and therefore different range table identifiers,
than the original. If a cost change results in flipping between one
of these plans and the other, the test_plan_advice tests will fail,
because the range table identifiers to which advice was applied won't
even be present in the output of the second planning cycle.
To fix, invent a new DO_NOT_SCAN advice tag. When generating advice,
emit it for relations that should not appear in the final plan at
all, because some alternative version of that relation was used
instead. When DO_NOT_SCAN is supplied, disable all scan methods for
that relation.
To make this work, we reuse a bunch of the machinery that previously
existed for the purpose of ensuring that we build the same set of
relation identifiers during planning as we do from the final
PlannedStmt. In the process, this commit slightly weakens the
cross-check mechanism: before this commit, it would fire whenever
the pg_plan_advice module was loaded, even if pg_plan_advice wasn't
actually doing anything; now, it will only engage when we have some
other reason to create a pgpa_planner_state. The old way was complex
and didn't add much useful test coverage, so this seems like an
acceptable sacrifice.
Discussion: http://postgr.es/m/CA+TgmoYuWmN-00Ec5pY7zAcpSFQUQLbgAdVWGR9kOR-HM-fHrA@mail.gmail.com
Reviewed-by: Lukas Fittl <lukas@fittl.com> M contrib/pg_plan_advice/README
A contrib/pg_plan_advice/expected/alternatives.out
M contrib/pg_plan_advice/expected/scan.out
M contrib/pg_plan_advice/meson.build
M contrib/pg_plan_advice/pgpa_ast.c
M contrib/pg_plan_advice/pgpa_ast.h
M contrib/pg_plan_advice/pgpa_output.c
M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/pgpa_planner.h
M contrib/pg_plan_advice/pgpa_trove.c
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_plan_advice/pgpa_walker.h
A contrib/pg_plan_advice/sql/alternatives.sql
M contrib/pg_plan_advice/sql/scan.sql
M doc/src/sgml/pgplanadvice.sgml
Add an alternative_plan_name field to PlannerInfo.
commit : 26255a320733de2d91a30bd6ae529dd01e7f3409
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 16:45:17 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 16:45:17 -0400 Typically, we have only one PlannerInfo for any given subquery, but
when we are considering a MinMaxAggPath or a hashed subplan, we end
up creating a second PlannerInfo for the same portion of the query,
with a clone of the original range table. In fact, in the MinMaxAggPath
case, we might end up creating several clones, one per aggregate.
At present, there's no easy way for a plugin, such as pg_plan_advice,
to understand the relationships between the original range table and
the copies of it that are created in these cases. To fix, add an
alternative_plan_name field to PlannerInfo. For a hashed subplan, this
is the plan name for the non-hashed alternative; for minmax aggregates,
this is the plan_name from the parent PlannerInfo; otherwise, it's the
same as plan_name.
Discussion: http://postgr.es/m/CA+TgmoYuWmN-00Ec5pY7zAcpSFQUQLbgAdVWGR9kOR-HM-fHrA@mail.gmail.com
Reviewed-by: Lukas Fittl <lukas@fittl.com> M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/plan/planagg.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/plan/subselect.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/prep/prepunion.c
M src/include/nodes/pathnodes.h
M src/include/optimizer/planner.h
Doc: commit performs rollback of aborted transactions.
commit : 10e2a8ac6a621352e032a0ca5c74a2be88d157e4
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 26 Mar 2026 15:14:21 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 26 Mar 2026 15:14:21 -0400 The COMMIT command handles an aborted transaction in the same
manner as the ROLLBACK command, but this wasn't explained in
its official reference page. Also mention that behavior in
the tutorial's material on transactions.
Also add a comment mentioning that we don't raise an exception
for COMMIT within an aborted transaction, as the SQL standard
would have us do.
Hyperlink a couple of cross-references while we're at it.
Author: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Gurjeet Singh <gurjeet@singh.im>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAKFQuwYgYR3rWt6vFXw=ZWZ__bv7PqvdOnHujG+UyqE11f+3sg@mail.gmail.com M doc/src/sgml/advanced.sgml
M doc/src/sgml/ref/commit.sgml
Address perlcritic complaint in response to 906a0469728
commit : 698ab40469841877aef82f619d06cbbe4d1cbb80
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 15:03:47 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 15:03:47 -0400 M src/test/modules/test_aio/t/TestAio.pm
bufmgr: Restructure AsyncReadBuffers()
commit : 8a1a1d6ab86217020a612ee2e03eae4fe00ae781
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:51:52 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:51:52 -0400 Restructure AsyncReadBuffers() to use early return when the head buffer is
already valid, instead of using a did_start_io flag and if/else branches. Also
move around a bit of the code to be located closer to where it is used. This
is a refactor only.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/backend/storage/buffer/bufmgr.c
bufmgr: Make buffer hit helper
commit : df09452c3209d542a19b9c4afa7a18c656cb4a80
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:51:25 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:51:25 -0400 Already two places count buffer hits, requiring quite a few lines of
code since we do accounting in so many places. Future commits will add
more locations, so refactor into a helper.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/backend/storage/buffer/bufmgr.c
bufmgr: Pass io_object and io_context through to PinBufferForBlock()
commit : c2a68e08b13f3cb437c92102fb11ab0f45dbd67f
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:50:44 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:50:44 -0400 PinBufferForBlock() is always_inline and called in a loop in
StartReadBuffersImpl(). Previously it computed io_context and io_object
internally, which required calling IOContextForStrategy() -- a non-inline
function the compiler cannot prove is side-effect-free. This could potential
cause unneeded redundant function calls.
Compute io_context and io_object in the callers instead, allowing
StartReadBuffersImpl() to do so once before entering the loop.
Author: Melanie Plageman <melanieplageman@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/backend/storage/buffer/bufmgr.c
pg_plan_advice: Refactor to invent pgpa_planner_info
commit : 5dcb15e89af2d9fbc3b038c2ea420905b279fdaf
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 11:57:33 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 26 Mar 2026 11:57:33 -0400 pg_plan_advice tracks two pieces of per-PlannerInfo data: (1) for each
RTI, the corresponding relation identifier, for purposes of
cross-checking those calculations against the final plan; and (2) the
set of semijoins seen during planning for which the strategy of making
one side unique was considered. The former is tracked using a hash
table that uses <plan_name, RTI> as the key, and the latter is
tracked using a List of <plan_name, relids>.
It seems better to track both of these things in the same way and
to try to reuse some code instead of having everything be completely
separate, so invent pgpa_planner_info; we'll create one every time we
see a new PlannerInfo and need to associate some data with it, and
we'll use the plan_name field to distinguish between PlannerInfo
objects, as it should always be unique. Then, refactor the two
systems mentioned above to use this new infrastructure.
(Note that the adjustment in pgpa_plan_walker is necessary in order
to avoid spuriously triggering the sanity check in that function,
in the case where a pgpa_planner_info is created for a purpose not
related to sj_unique_rels.)
Discussion: https://postgr.es/m/CA+TgmoaK=4w7-qknUo3QhUJ53pXZq=c=KgZmRyD+k7ytqfmgSg@mail.gmail.com
Reviewed-by: Lukas Fittl <lukas@fittl.com> M contrib/pg_plan_advice/pgpa_planner.c
M contrib/pg_plan_advice/pgpa_planner.h
M contrib/pg_plan_advice/pgpa_walker.c
M contrib/pg_plan_advice/pgpa_walker.h
M src/tools/pgindent/typedefs.list
Add labels to help make psql's hidden queries more understandable.
commit : 41d69e6dccad6ef26511a466e6484bc8807362cf
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 26 Mar 2026 11:36:38 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 26 Mar 2026 11:36:38 -0400 We recommend looking at psql's "-E" output to help understand the
system catalogs, but in some cases (particularly table displays)
there's a bunch of rather impenetrable SQL there. As a small
improvement, label each query issued by describe.c with a short
description of its purpose. The code is arranged so that the
labels also appear as SQL comments in the server log, if the
server is logging these commands.
We could expand this policy to every use of PSQLexec(), but most of
the ones outside describe.c are issuing simple commands like "BEGIN"
or "COMMIT", which don't seem to need such glosses. I did add
labels to the commands issued by \sf, \sv and friends.
Also, make the -E and log output for hidden queries say
"INTERNAL QUERY" not just "QUERY", to distinguish them from
user-written queries.
Author: Greg Sabino Mullane <htamfids@gmail.com>
Co-authored-by: David Christensen <david+pg@pgguru.net>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAKAnmmJz8Hh=8Ru8jgzySPWmLBhnv4=oc_0KRiz-UORJ0Dex+w@mail.gmail.com M src/bin/psql/command.c
M src/bin/psql/common.c
M src/bin/psql/describe.c
Fix off-by-one error in read IO tracing
commit : cf66978d7990b219a2eda03c3d4f978f68d046d3
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:07:59 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:07:59 -0400 AsyncReadBuffer()'s no-IO needed path passed
TRACE_POSTGRESQL_BUFFER_READ_DONE the wrong block number because it had
already incremented operation->nblocks_done. Fix by folding the
nblocks_done offset into the blocknum local variable at initialization.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/u73un3xeljr4fiidzwi4ikcr6vm7oqugn4fo5vqpstjio6anl2%40hph6fvdiiria
Backpatch-through: 18 M src/backend/storage/buffer/bufmgr.c
aio: Refactor tests in preparation for more tests
commit : 906a0469728e1dead174e0b738337f6f07a99601
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:07:59 -0400
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Mar 2026 10:07:59 -0400 In a future commit more AIO related tests are due to be introduced. However
001_aio.pl already is fairly large.
This commit introduces a new TestAio package with helpers for writing AIO
related tests. Then it uses the new helpers to simplify the existing
001_aio.pl by iterating over all supported io_methods. This will be
particularly helpful because additional methods already have been submitted.
Additionally this commit splits out testing of initdb using a non-default
method into its own test. While that test is somewhat important, it's fairly
slow and doesn't break that often. For development velocity it's helpful for
001_aio.pl to be faster.
While particularly the latter could benefit from being its own commit, it
seems to introduce more back-and-forth than it's worth.
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/zljergweqti7x67lg5ije2rzjusie37nslsnkjkkby4laqqbfw@3p3zu522yykv M src/test/modules/test_aio/meson.build
M src/test/modules/test_aio/t/001_aio.pl
A src/test/modules/test_aio/t/003_initdb.pl
A src/test/modules/test_aio/t/TestAio.pm
Respect disabled_nodes in fix_alternative_subplan.
commit : 47c110f77e75ed7efd54c3b152f7da2350522f8c
author : Robert Haas <rhaas@postgresql.org>
date : Fri, 20 Mar 2026 14:04:41 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Fri, 20 Mar 2026 14:04:41 -0400 When my commit e22253467942fdb100087787c3e1e3a8620c54b2 added the
concept of disabled_nodes, it failed to add a disabled_nodes field
to SubPlan. This is a regression: before that commit, when
fix_alternative_subplan compared the costs of two plans, the number
of disabled nodes affected the result, because it was just a
component of the total cost. After that commit, it no longer did,
making it possible for a disabled path to win on cost over one that
is not disabled. Fix that.
As usual for planner fixes that might destabilize plan choices,
no back-patch.
Discussion: https://postgr.es/m/CA+TgmoaK=4w7-qknUo3QhUJ53pXZq=c=KgZmRyD+k7ytqfmgSg@mail.gmail.com
Reviewed-by: Lukas Fittl <lukas@fittl.com> M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/plan/setrefs.c
M src/include/nodes/primnodes.h
Fix -Wcast-qual warning
commit : 119e791e9c7d7d122f7a9554514455c38115964a
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 26 Mar 2026 15:00:24 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 26 Mar 2026 15:00:24 +0100 This dials back a couple of the qualifiers added by commit
7724cb9935a. Specifically, in match_boolean_partition_clause() the
call to negate_clause() casts away the const, so we shouldn't make the
input argument const. M src/backend/partitioning/partprune.c
Avoid sending duplicate WAL locations in standby status replies
commit : 400a790a48eb7a1e76f23f9f6d8a6f7159395f65
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Mar 2026 20:54:32 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Mar 2026 20:54:32 +0900 Previously, when the startup process applied WAL and requested walreceiver
to send an apply notification to the primary, walreceiver sent a status reply
unconditionally, even if the WAL locations had not advanced since
the previous update.
As a result, the standby could send two consecutive status reply messages
with identical WAL locations even though wal_receiver_status_interval had
not yet elapsed. This could unexpectedly reset the reported replication lag,
making it difficult for users to monitor lag. The second message was also
unnecessary because it reported no progress.
This commit updates walreceiver to send a reply only when the apply location
has advanced since the last status update, even when the startup process
requests a notification.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAOzEurTzcUrEzrH97DD7+Yz=HGPU81kzWQonKZvqBwYhx2G9_A@mail.gmail.com M src/backend/access/transam/xlogrecovery.c
M src/backend/replication/walreceiver.c
M src/include/replication/walreceiver.h
Fix premature NULL lag reporting in pg_stat_replication
commit : eef1ba704ddeb73633e40f8cab41ab7402952684
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Mar 2026 20:49:31 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Mar 2026 20:49:31 +0900 pg_stat_replication is documented to keep the last measured lag values for
a short time after the standby catches up, and then set them to NULL when
there is no WAL activity. However, previously lag values could become NULL
prematurely even while WAL activity was ongoing, especially in logical
replication.
This happened because the code cleared lag when two consecutive reply messages
indicated that the apply location had caught up with the send location.
It did not verify that the reported positions were unchanged, so lag could be
cleared even when positions had advanced between messages. In logical
replication, where the apply location often quickly catches up, this issue was
more likely to occur.
This commit fixes the issue by clearing lag only when the standby reports that
it has fully replayed WAL (i.e., both flush and apply locations have caught up
with the send location) and the write/flush/apply positions remain unchanged
across two consecutive reply messages.
The second message with unchanged positions typically results from
wal_receiver_status_interval, so lag values are cleared after that interval
when there is no activity. This avoids showing stale lag data while preventing
premature NULL values.
Even with this fix, lag may rarely become NULL during activity if identical
position reports are sent repeatedly. Eliminating such duplicate messages
would address this fully, but that change is considered too invasive for stable
branches and will be handled in master only later.
Backpatch to all supported branches.
Author: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAOzEurTzcUrEzrH97DD7+Yz=HGPU81kzWQonKZvqBwYhx2G9_A@mail.gmail.com
Backpatch-through: 14 M src/backend/replication/walsender.c
Refactor ShmemIndex initialization
commit : 6b8238cb6aa76924fa63640fe421c421d2fa5472
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 11:35:55 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Thu, 26 Mar 2026 11:35:55 +0200 Initialize the ShmemIndex hash table in InitShmemAllocator() already,
removing the need for the separate InitShmemIndex() step.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/shmem.c
M src/include/storage/shmem.h
MSVC: Remove unnecessary warning option
commit : 515b0dc4bc74b43793ccf82965b7aaa79ad7161b
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 26 Mar 2026 09:10:42 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 26 Mar 2026 09:10:42 +0100 The MSVC warning option /w24777 added by commit 2307cfe3162 was a
typo, it should have been /w24477. But this option is already enabled
by default in level 1, so we don't need to add it explicitly. So just
remove it. M meson.build
Make fixed-length list building macros work in C++
commit : f8e7ca32851082a85d628b7821ae674be09bf1f3
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 26 Mar 2026 08:40:18 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 26 Mar 2026 08:40:18 +0100 Compound literals, as used in pg_list.h for list_makeN(), are not a
C++ feature. MSVC doesn't accept these. (GCC and Clang accept them,
but they would warn in -pedantic mode.) Replace with equivalent
inline functions. (These are the only instances of compound literals
used in PostgreSQL header files.)
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com M src/include/nodes/pg_list.h
Refactor replorigin_session_setup() for better readability.
commit : 735e8fe685359480e77d837493a5dc0a38866944
author : Amit Kapila <akapila@postgresql.org>
date : Thu, 26 Mar 2026 09:15:25 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Thu, 26 Mar 2026 09:15:25 +0530 Reorder the validation checks in replorigin_session_setup() to provide a
more logical flow. This makes the function easier to follow and ensures
that basic state checks are performed consistently.
Additionally, update an error message to align its phrasing with similar
diagnostics in the replication origin subsystem, improving overall
consistency.
Author: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/e0508305-bc6a-417c-b969-36564d632f9e@iki.fi M src/backend/replication/logical/origin.c
Fix UUID sortability tests in base32hex encoding.
commit : 89210037a0ab1f5e1375484edcfb8bbb4d9e7970
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 25 Mar 2026 20:12:26 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 25 Mar 2026 20:12:26 -0700 Commit 497c1170cb1 added base32hex encoding support, but its
regression test for UUIDs failed on buildfarm members hippopotamus and
jay using natural language locales (such as cs_CZ). This happened
because those collations may sort characters differently, which breaks
the strict byte-wise lexicographical ordering expected by base32hex
encoding.
This commit fixes the regression tests by explicitly using the C
collation.
Per buildfarm members hippopotamus and jay.
Analyzed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/682417.1774482047@sss.pgh.pa.us M src/test/regress/expected/uuid.out
M src/test/regress/sql/uuid.sql
Improve timeout handling of pg_promote()
commit : 4287c50fc21e6d1c7798955020f8438ae2327472
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 26 Mar 2026 10:39:40 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 26 Mar 2026 10:39:40 +0900 Previously, pg_promote() looped a fixed number of times, calculated from
the specified timeout, and waited 100ms on a latch, once per iteration,
for the promotion of a standby to complete. However, unrelated signals
to the backend could set the latch and wake up the backend early,
resulting in a faster consumption of the loops and an execution time of
the function that does not match with the timeout input given in input.
This could be confusing for the function caller, especially if some
backend-side timeout is aggressive, because the function would return
much earlier than expected and report that the promote request has not
completed within the time requested.
This commit refines the logic to track the time actually elapsed, by
looping until the requested duration has truly passed. The code
calculates the end time we expect, then uses it when looping.
Author: Robert Pang <robertpang@google.com>
Reviewed-by: Tiancheng Ge <getiancheng_2012@163.com>
Discussion: https://postgr.es/m/CAJhEC07OK8J7tLUbyiccnuOXRE7UKxBNqD2-pLfeFXa=tBoWtw@mail.gmail.com M src/backend/access/transam/xlogfuncs.c
Remove a low-value, high-risk optimization in pg_waldump.
commit : e9d723487b262e8d2bb883e4f8e799c3774265c7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Mar 2026 19:15:52 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Mar 2026 19:15:52 -0400 The code removed here deleted already-used data from a partially-read
WAL segment's hashtable entry. The intent was evidently to try to
keep the entry's memory consumption below the WAL segment's total
size, but we don't use WAL segments that are so large as to make that
a big win. The important memory-space optimization is to remove
hashtable entries altogether when done with them, and that's handled
elsewhere. To buy that, we must accept a substantially more complex
(and under-documented) logical invariant about what is in entry->buf,
as well as complex and under-documented interactions with the entry
spilling logic, various re-checking code paths in xlogreader.c,
and pg_waldump's overall data processing order. Any of those aspects
could have bugs lurking still, and are quite likely to be prone to
new bugs after future code changes.
Given the number of bugs we've already found in commit b15c15139,
I judge that simplifying anything we possibly can is a good decision.
While here, revise and extend some related comments.
Discussion: https://postgr.es/m/374225.1774459521@sss.pgh.pa.us M src/bin/pg_waldump/archive_waldump.c
Fix misuse of simplehash.h hash operations in pg_waldump.
commit : ff84efe4fdc081545ec68064588dffecfb026527
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Mar 2026 18:37:28 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Mar 2026 18:37:28 -0400 Both ArchivedWAL_insert() and ArchivedWAL_delete_item() can cause
existing hashtable entries to move. The code didn't account for this
and could leave privateInfo->cur_file pointing at a dead or incorrect
entry, with hilarity ensuing. Likewise, read_archive_wal_page calls
read_archive_file which could result in movement of the hashtable
entry it is working with.
I believe these bugs explain some odd buildfarm failures, although
the amount of data we use in pg_waldump's TAP tests isn't enough to
trigger them reliably.
This code's all new as of commit b15c15139, so no need for back-patch.
Discussion: https://postgr.es/m/374225.1774459521@sss.pgh.pa.us M src/bin/pg_waldump/archive_waldump.c
Fix file descriptor leakages in pg_waldump.
commit : 03b1e30e7aa5c0d83514db4156cfc80632f50493
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Mar 2026 18:28:42 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Mar 2026 18:28:42 -0400 TarWALDumpCloseSegment was of the opinion that it didn't need to
do anything. It was mistaken: it has to close the open file if
any, because nothing else will, leading to a descriptor leak.
In addition, we failed to ensure that any file being read by the
XLogReader machinery gets closed before the atexit callback tries to
cleanup the temporary directory holding spilled WAL files. While the
file would have been closed already in case of a success exit, this
doesn't happen in case of pg_fatal() exits. The least messy way
to fix that is to move the atexit function into pg_waldump.c,
where it has easier access to the XLogReaderState pointer and to
WALDumpCloseSegment.
These FD leakages are pretty insignificant on Unix-ish platforms,
but they're a bug on Windows, because they prevent successful cleanup
of the temporary directory for extracted WAL files. (Windows can't
delete a directory that holds a deleted-but-still-open file.)
This is visible in occasional buildfarm failures.
This code's all new as of commit b15c15139, so no need for back-patch.
Discussion: https://postgr.es/m/374225.1774459521@sss.pgh.pa.us M src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/pg_waldump.c
Add base32hex support to encode() and decode() functions.
commit : 497c1170cb108cd84fe13db19c049177376fec5f
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 25 Mar 2026 11:35:19 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 25 Mar 2026 11:35:19 -0700 This adds support for base32hex encoding and decoding, as defined in
RFC 4648 Section 7. Unlike standard base32, base32hex uses the
extended hex alphabet (0-9, A-V) which preserves the lexicographical
order of the encoded data.
This is particularly useful for representing UUIDv7 values in a
compact string format while maintaining their time-ordered sort
property.
The encode() function produces output padded with '=', while decode()
accepts both padded and unpadded input. Following the behavior of
other encoding types, decoding is case-insensitive.
Suggested-by: Sergey Prokhorenko <sergeyprokhorenko@yahoo.com.au>
Author: Andrey Borodin <x4mmm@yandex-team.ru>
Co-authored-by: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Илья Чердаков <i.cherdakov.pg@gmail.com>
Reviewed-by: Chengxi Sun <chengxisun92@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAJ7c6TOramr1UTLcyB128LWMqita1Y7%3Darq3KHaU%3Dqikf5yKOQ%40mail.gmail.com M doc/src/sgml/func/func-binarystring.sgml
M src/backend/utils/adt/encode.c
M src/test/regress/expected/strings.out
M src/test/regress/expected/uuid.out
M src/test/regress/sql/strings.sql
M src/test/regress/sql/uuid.sql
Remove unused autovac_table.at_sharedrel
commit : c8b4a3ec087b037b1f59554d622855cf9cc44cfb
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 25 Mar 2026 14:04:33 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 25 Mar 2026 14:04:33 +0100 The last use was removed by commit 38f7831d703b. After that, we compute
MyWorkerInfo->wi_sharedrel directly from the pg_class tuple of the table
being vacuumed rather than passing it around.
Author: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/20260325165734.7ab8e4e55fe4c2f1e55031d9@sraoss.co.jp M src/backend/postmaster/autovacuum.c
psql: Fix tab completion for FOREIGN DATA WRAPPER and SUBSCRIPTION.
commit : 5fa7837d9a3970c5ea372bb90b916b54478fb818
author : Masahiko Sawada <msawada@postgresql.org>
date : Wed, 25 Mar 2026 09:30:26 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Wed, 25 Mar 2026 09:30:26 -0700 Commit 8185bb5347 extended the CREATE/ALTER SUBSCRIPTION and
CREATE/ALTER FOREIGN DATA WRAPPER commands, but missed the
corresponding tab-completion logic. This commit fixes that oversight
by adding completion support for:
- The CONNECTION keyword in CREATE/ALTER FOREIGN DATA WRAPPER.
- The list of foreign servers in CREATE/ALTER SUBSCRIPTION.
Author: Yamaguchi Atsuo <acrobatcoder@gmail.com>
Discussion: https://postgr.es/m/CAKSyusJWdWcUKVd3qJXcEaQxJewGymQWV_r3-mc=Knrqo0AZ_g@mail.gmail.com M src/bin/psql/tab-complete.in.c
Remove compiler warning option -Wendif-labels
commit : 87e1891c459ecf7aa839de75d8afca3e1a6d154f
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 15:03:30 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 15:03:30 +0100 This warning has always been on by default in GCC (and in Clang at
least going back to 3.1), so we don't need the option explicitly.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal M configure
M configure.ac
M meson.build
Disable warnings in system headers in MSVC
commit : bccfc73acde97cdb76ba36558ed394e89d3c808b
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 15:03:30 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 15:03:30 +0100 This is similar to the standard behavior in GCC. For MSVC, we set all
headers in angle brackets to be considered system headers. (GCC goes
by path, not include style.)
The required option is available since VS 2017. (Before VS 2019
version 16.10, the additional option /experimental:external is
required, but per discussion in [0], we effectively require 16.11, so
this shouldn't be a problem.)
[0]: https://www.postgresql.org/message-id/04ab76a3-186c-4a37-8076-e6882ebf9d43%40eisentraut.org
Then, we can remove one workaround for avoiding a warning from a
system header. (And some warnings to be enabled in the future could
benefit from this.)
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal M meson.build
M src/backend/port/win32/crashdump.c
Fix some typos and make small stylistic improvements
commit : 5282bf535e474dc2517f2e835d147420ae2144de
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 09:17:40 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 09:17:40 +0100 for commit 2f094e7ac69
Author: zengman <zengman@halodbtech.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org M src/backend/rewrite/rewriteGraphTable.c
Fix typo
commit : c79e4141273caa1b4fb88c479bb90dc40f2fbbf2
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 07:09:44 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 25 Mar 2026 07:09:44 +0100 Mistake in commit e2f289e5b9b: SOFT_ERROR_OCCURRED was called with the
wrong fcinfo field.
Reported-by: Jianghua Yang <yjhjstz@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAAZLFmSGti716gWeY%3DDCZ9TTVOixnHZ4_4V4tDzoeE86D64vOA%40mail.gmail.com M src/backend/utils/adt/date.c
pg_createsubscriber: Add -l/--logdir option to redirect output to files.
commit : 6b5b7eae3ae65572e2abda20ef2b2c908527c28a
author : Amit Kapila <akapila@postgresql.org>
date : Wed, 25 Mar 2026 11:22:07 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Wed, 25 Mar 2026 11:22:07 +0530 This commit introduces a -l (or --logdir) argument to pg_createsubscriber,
allowing users to specify a directory for log files.
When enabled, a timestamped subdirectory is created within the specified
log directory, containing:
pg_createsubscriber_server.log: Captures logs from the standby server
during its start/stop cycles.
pg_createsubscriber_internal.log: Captures the tool's own internal
diagnostic and progress messages.
This ensures that transient server and utility messages are preserved for
troubleshooting after the subscriber creation process completes or errored
out.
Author: Gyan Sreejith <gyan.sreejith@gmail.com>
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc+G+f4oSUHw@mail.gmail.com M doc/src/sgml/ref/pg_createsubscriber.sgml
M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl
Refactor handling of x86 CPUID instructions
commit : be6a7494d2e387d1f5b7a5dcc6c2afcb403188d6
author : John Naylor <john.naylor@postgresql.org>
date : Wed, 25 Mar 2026 12:32:36 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Wed, 25 Mar 2026 12:32:36 +0700 Introduce two helpers for CPUID, pg_cpuid and pg_cpuid_subleaf that wrap
the platform specific __get_cpuid/__cpuid and __get_cpuid_count/__cpuidex
functions.
Additionally, use macros to specify registers names (e.g. EAX) for clarity,
instead of numeric integers into the result array.
Author: Lukas Fittl <lukas@fittl.com>
Suggested-By: John Naylor <john.naylor@postgresql.org>
Discussion: https://postgr.es/m/CANWCAZZ+Crjt5za9YmFsURRMDW7M4T2mutDezd_3s1gTLnrzGQ@mail.gmail.com M src/port/pg_cpu_x86.c
Remove isolation test lock-stats
commit : 7c64d56fd9765bb577937c07eabed971e605c67c
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 25 Mar 2026 08:48:15 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 25 Mar 2026 08:48:15 +0900 This test is proving to be unstable in the CI for Windows, at least.
The origin of the issue is that the deadlock_timeout requests may not
be processed, causing the lock stats to not be updated. This could be
mitigated by making the hardcoded sleep longer, however this would cost
in runtime on fast machines. On slow machines, there is no guarantee
that an augmented sleep would be enough.
An isolation test may not be the best method to write this test
(TAP test with injection point with a NOTICE+wait_for_log before
processing the deadlock_timeout request should remove the need of a
sleep). As we are late in the release cycle, I am removing the test for
now to keep the CI and the buildfarm a maximum stable. Let's revisit
this part later.
Discussion: https://postgr.es/m/hlkdrplgrmudbspibsuq6xooxrqxqsgwo6x5b6x5ptvkgjbe7w@xogt6xgua6dz D src/test/isolation/expected/lock-stats.out
M src/test/isolation/isolation_schedule
D src/test/isolation/specs/lock-stats.spec
Refactor to remove ForeignServerName().
commit : 11f8018ee6784476d8dcee3ef64b267fb16fc374
author : Jeff Davis <jdavis@postgresql.org>
date : Tue, 24 Mar 2026 15:20:28 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Tue, 24 Mar 2026 15:20:28 -0700 Callers either have a ForeignServer object or can readily construct
one.
Discussion: https://postgr.es/m/CAExHW5vV5znEvecX=ra2-v7UBj9-M6qvdDzuB78M-TxbYD1PEA@mail.gmail.com
Suggested-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> M src/backend/catalog/pg_subscription.c
M src/backend/commands/subscriptioncmds.c
M src/backend/foreign/foreign.c
M src/include/foreign/foreign.h
GetSubscription(): use per-object memory context.
commit : f16f5d608ca6830f452a3b1e9f72afc6851cab38
author : Jeff Davis <jdavis@postgresql.org>
date : Tue, 24 Mar 2026 15:10:03 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Tue, 24 Mar 2026 15:10:03 -0700 Constructing a Subcription object uses a number of small or temporary
allocations. Use a per-object memory context for easy cleanup.
Get rid of FreeSubscription() which did not free all the allocations
anyway. Also get rid of the PG_TRY()/PG_CATCH() logic in
ForeignServerConnectionString() which were used to avoid leaks during
GetSubscription().
Co-authored-by: Álvaro Herrera <alvherre@kurilemu.de>
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/xvdjrdqnpap3uq7owbaox3r7p5gf7sv62aaqf2ju3vb6yglatr%40kvvwhoudrlxq
Discussion: https://postgr.es/m/CAA4eK1K=WjZ1maBCmj=5ZdO66AwPORK5ZBxVKedS0xdCcb621A@mail.gmail.com M src/backend/catalog/pg_subscription.c
M src/backend/foreign/foreign.c
M src/backend/replication/logical/worker.c
M src/include/catalog/pg_subscription.h
Remove XLOG_HEAP2_VISIBLE entirely
commit : a881cc9c7e819fb26b73bb43b35d43db6b795cc7
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 17:58:12 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 17:58:12 -0400 There are no remaining users that emit XLOG_HEAP2_VISIBLE records, so it
can be removed. This includes deleting the xl_heap_visible struct and
all functions responsible for emitting or replaying XLOG_HEAP2_VISIBLE
records.
Bumps XLOG_PAGE_MAGIC because we removed a WAL record type.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com M src/backend/access/common/bufmask.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/vacuumlazy.c
M src/backend/access/heap/visibilitymap.c
M src/backend/access/rmgrdesc/heapdesc.c
M src/backend/replication/logical/decode.c
M src/backend/storage/ipc/standby.c
M src/include/access/heapam_xlog.h
M src/include/access/visibilitymap.h
M src/include/access/visibilitymapdefs.h
M src/include/access/xlog_internal.h
M src/tools/pgindent/typedefs.list
WAL log VM setting for empty pages in XLOG_HEAP2_PRUNE_VACUUM_SCAN
commit : a759ced2f1e2f817005c1b8ee92d0626764da7d1
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 17:28:05 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 17:28:05 -0400 As part of removing XLOG_HEAP2_VISIBLE records, phase I of VACUUM now
marks empty pages all-visible and all-frozen in a
XLOG_HEAP2_PRUNE_VACUUM_SCAN record.
This has no real independent benefit, but empty pages were the last user
of XLOG_HEAP2_VISIBLE, so by making this change we can next remove all
of the XLOG_HEAP2_VISIBLE code.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Earlier version Reviewed-by: Robert Haas <robertmhaas@gmail.com> M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
WAL log VM setting during vacuum phase I in XLOG_HEAP2_PRUNE_VACUUM_SCAN
commit : 1252a4ee28636734d68f1acd33be45399c83dc53
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 16:49:46 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 16:49:46 -0400 Vacuum no longer emits a separate WAL record for each page set
all-visible or all-frozen during phase I. Instead, visibility map
updates are now included in the XLOG_HEAP2_PRUNE_VACUUM_SCAN record that
is already emitted for pruning and freezing.
Previously, heap_page_prune_and_freeze() determined whether a page was
all-visible, but the corresponding VM bits were only set later in
lazy_scan_prune(). Now the VM is updated immediately in
heap_page_prune_and_freeze(), at the same time as the heap
modifications. This reduces WAL volume produced by vacuum.
For now, vacuum is still the only user of heap_page_prune_and_freeze()
allowed to set the VM. On-access pruning is not yet able to set the VM.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Earlier version Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/include/access/heapam.h
get_memoize_path: Don't exit quickly when PGS_NESTLOOP_PLAIN is unset.
commit : dc47beacaa0b0ad13d7ccd77399cccc98027964d
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 16:17:26 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 16:17:26 -0400 This function exits early in the case where the number of inner rows
is estimated to be less than 2, on the theory that in that case a
Nested Loop with inner Memoize must lose to a plain Nested Loop.
But since commit 4020b370f214315b8c10430301898ac21658143f it's
possible for a plain Nested Loop to be disabled, while a Nested Loop
with inner Memoize is still enabled. In that case, this reasoning
is not valid, so adjust the code not to exit early in that case.
This issue was revealed by a test_plan_advice failure on buildfarm
member skink, where NESTED_LOOP_MEMOIZE() couldn't be enforced on
replanning due to this early exit.
Discussion: http://postgr.es/m/CA+TgmoZUN8FT1Ah=m6Uis5bHa4FUa+_hMDWtcABG17toEfpiUg@mail.gmail.com M src/backend/optimizer/path/joinpath.c
Keep newest live XID up-to-date even if page not all-visible
commit : 9ba3ec076a68b82d49fb4d0ea008205befd2292b
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 15:36:34 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 15:36:34 -0400 During pruning, we keep track of the newest xmin of live tuples on the
page visible to all running and future transactions so that we can use
it later as the snapshot conflict horizon when setting the VM if the
page turns out to be all-visible.
Previously, we stopped updating this value once we determined the page
was not all-visible. However, maintaining it even when the page is not
all-visible is inexpensive and makes the snapshot conflict horizon
calculation clearer. This guarantees it won't contain a stale value.
Since we'll keep it up to date all the time now anyway, there's no
reason not to maintain set_all_visible for on-access pruning. This will
allow us to set the VM on-access in the future.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
Use GlobalVisState in vacuum to determine page level visibility
commit : dd5716f3c74df6ebc97f5886b755ba79a3f5b559
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 14:50:59 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 24 Mar 2026 14:50:59 -0400 During vacuum's first and third phases, we examine tuples' visibility to
determine if we can set the page all-visible in the visibility map.
Previously, this check compared tuple xmins against a single XID chosen
at the start of vacuum (OldestXmin). We now use GlobalVisState, which
enables future work to set the VM during on-access pruning, since
ordinary queries have access to GlobalVisState but not OldestXmin.
This also benefits vacuum: in some cases, GlobalVisState may advance
during a vacuum, allowing more pages to become considered all-visible.
And, in the future, we could easily add a heuristic to update
GlobalVisState more frequently during vacuums of large tables.
OldestXmin is still used for freezing and as a backstop to ensure we
don't freeze a dead tuple that wasn't yet prunable according to
GlobalVisState in the rare occurrences where GlobalVisState moves
backwards.
Because comparing a transaction ID against GlobalVisState is more
expensive than comparing against a single XID, we defer this check until
after scanning all tuples on the page. Therefore, we perform the
GlobalVisState check only once per page. This is safe because
visibility_cutoff_xid records the newest live xmin on the page; if it is
globally visible, then the entire page is all-visible.
Using GlobalVisState means on-access pruning can also maintain
visibility_cutoff_xid, which is required to set the visibility map
on-access in the future.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/flat/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk#c755ef151507aba58471ffaca607e493 M src/backend/access/heap/heapam_visibility.c
M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/access/spgist/spgvacuum.c
M src/backend/storage/ipc/procarray.c
M src/include/utils/snapmgr.h
Avoid including clog.h in proc.h
commit : f227b7b20c36b7348867eec48d539d28cfdf831c
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Mar 2026 17:30:40 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Mar 2026 17:30:40 +0100 The number of .c files that must include access/clog.h can currently be
counted on one's fingers and miss only one (assuming one has the usual
number of hands). However, due to indirect inclusion via proc.h,
there's a lot of files that are pointlessly including it. This is easy
to avoid with the easy trick implemented by this commit.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/202603221856.iwlhitt6dxxx@alvherre.pgsql M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h
Fix poorly-sized buffers in astreamer compression modules.
commit : 6e243d81c54966e640870c96d73576376ec125c6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 24 Mar 2026 12:17:04 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 24 Mar 2026 12:17:04 -0400 astreamer_gzip.c and astreamer_lz4.c left their decompression
output buffers at StringInfo's default allocation, merely 1kB.
This results in a lot of ping-ponging between the decompressor
and the next astreamer filter. This patch increases these buffer
sizes to 256kB. In a simple test this had a small but measurable
effect (saving a few percent) on the overall runtime of pg_waldump
for the gzipped-data case; I didn't bother measuring for lz4.
astreamer_zstd.c used ZSTD_DStreamOutSize() to size its
compression output buffer, but the libzstd API says you should use
ZSTD_CStreamOutSize(); ZSTD_DStreamOutSize() is for decompression.
The two functions seem to produce the same value (256kB) here, so
this is just cosmetic, but nonetheless we should play by the rules.
While these issues are old, they don't seem significant enough to
warrant back-patching.
Discussion: https://postgr.es/m/3424809.1774234940@sss.pgh.pa.us M src/fe_utils/astreamer_gzip.c
M src/fe_utils/astreamer_lz4.c
M src/fe_utils/astreamer_zstd.c
Remove read_archive_file()'s "count" parameter.
commit : ca1f1ade3f64f53c5319ee2c7db71a669a38cc83
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 24 Mar 2026 12:06:08 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Tue, 24 Mar 2026 12:06:08 -0400 Instead, always try to fill the allocated buffer completely.
The previous coding apparently intended (though it's undocumented)
to read only small amounts of data until we are able to identify the
WAL segment size and begin filtering out unwanted segments. However
this extra complication has no measurable value according to simple
testing here, and it could easily be a net loss if there is a
substantial amount of non-WAL data in the archive file before the
first WAL file.
Discussion: https://postgr.es/m/3341199.1774221191@sss.pgh.pa.us M src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/pg_waldump.h
Don't include storage/lock.h in so many headers
commit : 2102ebb1953fe656a46819e11ff4204e2f918dda
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Mar 2026 17:11:12 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Mar 2026 17:11:12 +0100 Since storage/locktags.h was added by commit 322bab79744d, many headers
can be made leaner by depending on that instead of on storage/lock.h,
which has many other dependencies.
(In fact, some of these changes were possible even before that.)
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/abvrRZo52Yx9ZzWQ@ip-10-97-1-34.eu-west-3.compute.internal M contrib/amcheck/verify_heapam.c
M src/backend/access/common/relation.c
M src/backend/access/common/reloptions.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/index/indexam.c
M src/backend/access/nbtree/nbtree.c
M src/backend/access/nbtree/nbtutils.c
M src/backend/catalog/pg_inherits.c
M src/backend/catalog/pg_subscription.c
M src/backend/commands/conversioncmds.c
M src/backend/commands/discard.c
M src/backend/commands/tablespace.c
M src/backend/optimizer/util/inherit.c
M src/backend/parser/parse_oper.c
M src/backend/replication/logical/sequencesync.c
M src/backend/utils/activity/wait_event.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/cache/syscache.c
M src/backend/utils/cache/ts_cache.c
M src/include/access/reloptions.h
M src/include/access/twophase.h
M src/include/catalog/namespace.h
M src/include/catalog/pg_inherits.h
M src/include/catalog/toasting.h
M src/include/commands/cluster.h
M src/include/commands/tablecmds.h
M src/include/commands/vacuum.h
M src/include/replication/worker_internal.h
M src/include/storage/lmgr.h
M src/include/storage/lock.h
M src/include/storage/predicate.h
M src/include/storage/procarray.h
M src/include/storage/sinvaladt.h
M src/include/storage/standby.h
Fix dereference in a couple of GUC check hooks
commit : 5f2350a043db08ab0ea48d22f51acfa5d9b374d9
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Mar 2026 16:45:39 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Mar 2026 16:45:39 +0100 check_backtrace_functions() and check_archive_directory() were doing an
empty-string check this way:
*newval[0] == '\0'
which, because of operator precedence, is interpreted as *(newval[0])
instead of (*newval)[0] -- but these variables are pointers to C-strings
and we want to check the first character therein, rather than check the
first pointer of the array, so that interpretation is wrong. This would
be wrong for any index element other than 0, as evidenced by every other
dereference of the same variable in check_backtrace_functions, which use
parentheses.
Add parentheses to make the intended dereference explicit.
This is just cosmetic at this stage, so no backpatch, although it's been
"wrong" for a long time.
Author: Zhang Hu <kongbaik228@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAB5m2QssN6UO+ckr6ZCcV0A71mKUB6WdiTw1nHo43v4DTW1Dfg@mail.gmail.com M contrib/basic_archive/basic_archive.c
M src/backend/utils/error/elog.c
test_bloomfilter: Fix error message.
commit : c7b9f16113325eca806e81b29a10b70290cc164b
author : Nathan Bossart <nathan@postgresql.org>
date : Tue, 24 Mar 2026 09:32:15 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Tue, 24 Mar 2026 09:32:15 -0500 The error message in question uses the wrong format specifier and
variable. This has been wrong for a while, but since it's in a
test module and wasn't noticed until just now, no back-patch.
Oversight in commit 51bc271790.
Author: Jianghua Yang <yjhjstz@gmail.com>
Discussion: https://postgr.es/m/CAAZLFmS2OMiwe65gdm-MKgO%3DLnKatGMSK6JWxhycGN3TWrhbnw%40mail.gmail.com M src/test/modules/test_bloomfilter/test_bloomfilter.c
Add a test for creating an index on a whole-row expression.
commit : 4647ee2da37c106f0b964171227df956082d39a4
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 10:06:38 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 10:06:38 -0400 Surprisingly, we have no existing test for this. Had this test
been present before commit 570e2fcc041a55ba8991a640cc3f3f0e122feac3
the Assert added in commit c98ad086ad9b1ca9dbb2725f246298fa8450d82f
would have caught the bug.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: http://postgr.es/m/CA+TgmoacixUZVvi00hOjk_d9B4iYKswWP1gNqQ8Vfray-AcOCA@mail.gmail.com M src/test/regress/expected/indexing.out
M src/test/regress/sql/indexing.sql
Fix accidentally casting away const
commit : 6bc7449eac31ca573572000a10660d5995a4f96a
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Mar 2026 14:28:56 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Mar 2026 14:28:56 +0100 Recently introduced in commit 4b5ba0c4ca5. M src/bin/pg_dump/pg_dump.c
Report detailed errors from XLogFindNextRecord() failures.
commit : 1c162c965a113192cd5137e6de38a10fbc0a5692
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 24 Mar 2026 22:33:09 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 24 Mar 2026 22:33:09 +0900 Previously, XLogFindNextRecord() did not return detailed error information
when it failed to find a valid WAL record. As a result, callers such as
the WAL summarizer, pg_waldump, and pg_walinspect could only report generic
errors (e.g., "could not find a valid record after ..."), making
troubleshooting difficult.
This commit fix the issue by extending XLogFindNextRecord() to return
detailed error information on failure, and updating its callers to include
those details in their error messages.
For example, when pg_waldump is run on a WAL file with an invalid magic number,
it now reports not only the generic error but also the specific cause
(e.g., "invalid magic number").
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Mircea Cadariu <cadariu.mircea@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAO6_XqoxJXddcT4wkd9Xd+cD6Sz-fyspRGuV4Bq-wbXG4pVNzA@mail.gmail.com M contrib/pg_walinspect/pg_walinspect.c
M src/backend/access/transam/xlogreader.c
M src/backend/postmaster/walsummarizer.c
M src/bin/pg_waldump/pg_waldump.c
M src/bin/pg_waldump/t/001_basic.pl
M src/include/access/xlogreader.h
Bounds-check access to TupleDescAttr with an Assert.
commit : c98ad086ad9b1ca9dbb2725f246298fa8450d82f
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 08:58:50 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 08:58:50 -0400 The second argument to TupleDescAttr should always be at least zero
and less than natts; otherwise, we index outside of the attribute
array. Assert that this is the case.
Various violations, or possible violations, of this rule that are
currently in the tree are actually harmless, because while
we do call TupleDescAttr() before verifying that the argument is
within range, we don't actually dereference it unless the argument
was within range all along. Nonetheless, the Assert means we
should be more careful, so tidy up accordingly.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: http://postgr.es/m/CA+TgmoacixUZVvi00hOjk_d9B4iYKswWP1gNqQ8Vfray-AcOCA@mail.gmail.com M src/backend/access/common/tupdesc.c
M src/include/access/tupdesc.h
M src/pl/plperl/plperl.c
M src/pl/plpgsql/src/pl_exec.c
Make many cast functions error safe
commit : e2f289e5b9b82acaf1523fda827e71b8fc8bd549
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Mar 2026 12:01:05 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Mar 2026 12:01:05 +0100 This adjusts many C functions underlying casts to support soft errors.
This is in preparation for a future feature where conversion errors in
casts can be caught.
This patch covers cast functions that can be adjusted easily by
changing ereport to ereturn or making other light changes. The
underlying helper functions were already changed to support soft
errors some time ago as part of soft error support in type input
functions.
Other casts and types will require some more work and are being kept
as separate patches.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CADkLM%3Dfv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ%40mail.gmail.com M src/backend/executor/execExprInterp.c
M src/backend/utils/adt/bytea.c
M src/backend/utils/adt/char.c
M src/backend/utils/adt/date.c
M src/backend/utils/adt/float.c
M src/backend/utils/adt/int.c
M src/backend/utils/adt/int8.c
M src/backend/utils/adt/mac8.c
M src/backend/utils/adt/network.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/adt/timestamp.c
M src/backend/utils/adt/varbit.c
M src/backend/utils/adt/varchar.c
M src/backend/utils/adt/xml.c
M src/include/utils/xml.h
Prevent spurious "indexes on virtual generated columns are not supported".
commit : 570e2fcc041a55ba8991a640cc3f3f0e122feac3
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 06:11:15 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 24 Mar 2026 06:11:15 -0400 Both of the checks in DefineIndex() that can produce this error
message have a guard against negative attribute numbers, but lack a
guard to ensure that attno is non-zero. As a result, we can index
off the beginning of the TupleDesc and read a garbage byte for
attgenerated. If that byte happens to be 'v', we'll incorrectly
produce the error mentioned above.
The first call site is easy to hit: any attempt to create an
expression index does so. The second one is not currently hit in
the regression tests, but can be hit by something like
CREATE INDEX ON some_table ((some_function(some_table))).
Found by study of a test_plan_advice failure on buildfarm member
skink, though this issue has nothing to do with test_plan_advice
and seems to have only been revealed by happenstance.
Backpatch-through: 18
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: http://postgr.es/m/CA+TgmoacixUZVvi00hOjk_d9B4iYKswWP1gNqQ8Vfray-AcOCA@mail.gmail.com M src/backend/commands/indexcmds.c
Fix copy-paste error in test_ginpostinglist
commit : d2a1aa77c25549bd0d285bdb29a89e29db4d30b2
author : John Naylor <john.naylor@postgresql.org>
date : Tue, 24 Mar 2026 16:40:33 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Tue, 24 Mar 2026 16:40:33 +0700 The check for a mismatch on the second decoded item pointer
was an exact copy of the first item pointer check, comparing
orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1]
with decoded_itemptrs[1]. The error message also reported (0, 1) as
the expected value instead of (blk, off). As a result, any decoding
error in the second item pointer (where the varbyte delta encoding
is exercised) would go undetected.
This has been wrong since commit bde7493d1, so backpatch to all
supported versions.
Author: Jianghua Yang <yjhjstz@gmail.com>
Discussion: https://postgr.es/m/CAAZLFmSOD8R7tZjRLZsmpKtJLoqjgawAaM-Pne1j8B_Q2aQK8w@mail.gmail.com
Backpatch-through: 14 M src/test/modules/test_ginpostinglist/test_ginpostinglist.c
Further improve commentary about ChangeVarNodesWalkExpression()
commit : 6888658516a20a2605087f557d96f3d0d0937608
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 24 Mar 2026 09:48:07 +0200
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Tue, 24 Mar 2026 09:48:07 +0200 The updated comment explains why we use ChangeVarNodes_walker() instead of
expression_tree_walker(), and provides a bit more detail about the differences
in processing top-level Query and subqueries.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAPpHfdvbjq342WTQ705Wmqhe8794pcp7wospz%2BWUJ2qB7vuOqA%40mail.gmail.com
Backpatch-through: 18 M src/backend/rewrite/rewriteManip.c
Add support for lock statistics in pgstats
commit : 4019f725f5d43f37b23222d06d20e3da1038d373
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Mar 2026 15:32:09 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Mar 2026 15:32:09 +0900 This commit adds a new stats kind, called PGSTAT_KIND_LOCK, implementing
statistics for lock tags, as reported by pg_locks. The implementation
is fixed-sized, as the data is caped based on the number of lock tags in
LockTagType.
The new statistics kind records the following fields, providing insight
regarding lock behavior, while avoiding impact on performance-critical
code paths (such as fast-path lock acquisition):
- waits and wait_time: respectively track the number of times a lock
required waiting and the total time spent acquiring it. These metrics
are only collected once a lock is successfully acquired and after
deadlock_timeout has been exceeded.
fastpath_exceeded: counts how often a lock could not be acquired via
the fast path due to the max_locks_per_transaction slot limits.
A new view called pg_stat_lock can be used to access this data, coupled
with a SQL function called pg_stat_get_lock().
Bump stat file format PGSTAT_FILE_FORMAT_ID.
Bump catalog version.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aIyNxBWFCybgBZBS%40ip-10-97-1-34.eu-west-3.compute.internal M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c
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_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/include/utils/pgstat_kind.h
A src/test/isolation/expected/lock-stats.out
M src/test/isolation/isolation_schedule
A src/test/isolation/specs/lock-stats.spec
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
Move some code blocks in lock.c and proc.c
commit : a90d86518243a077cdd1445ec8586ffb81dae408
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Mar 2026 13:34:54 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Mar 2026 13:34:54 +0900 This change will simplify an upcoming change that will introduce lock
statistics, reducting code churn.
This commit means that we begin to calculate the time it took to acquire
a lock after the deadlock check interrupt has run should log_lock_waits
be off, when taken in isolation. This is not a performance-critical
code path, and note that log_lock_waits is enabled by default since
2aac62be8cbb.
Extracted from a larger patch by the same author.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aIyNxBWFCybgBZBS@ip-10-97-1-34.eu-west-3.compute.internal M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c
Make implementation of SASLprep compliant for ASCII characters
commit : 3d10ece612f535be15a9cb7ca31620c80db6f0e9
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Mar 2026 08:29:23 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Mar 2026 08:29:23 +0900 This commit makes our implementation of SASLprep() compliant with RFC
3454 (Stringprep) and RFC 4013 (SASLprep). Originally, as introduced in
60f11b87a234, the operation considered a password made of only ASCII
characters as valid, performing an optimization for this case to skip
the internal NFKC transformation.
However, the RFCs listed above use a different definition, with the
following characters being prohibited:
- 0x00~0x1F (0~31), control characters.
- 0x7F (127, DEL).
In its SCRAM protocol, Postgres has the idea to apply a password as-is
if SASLprep() is not a success, so this change is safe on
backward-compatibility grounds:
- A libpq client with the compliant SASLprep can connect to a server
with a non-compliant SASLprep.
- A libpq client with the non-compliant SASLprep can connect to a server
with a compliant SASLprep.
This commit removes the all-ASCII optimization used in pg_saslprep() and
applies SASLprep even if a password is made only of ASCII characters,
making the operation compatible with the RFC. All the in-core callers
of pg_saslprep() do that:
- pg_be_scram_build_secret() in auth-scram.c, when generating a
SCRAM verifier for rolpassword in the backend.
- scram_init() in fe-auth-scram.c, when starting the SASL exchange.
- pg_fe_scram_build_secret() in fe-auth-scram.c, when generating a SCRAM
verifier for the frontend with libpq, to generate it for a ALTER/CREATE
ROLE command for example.
The test module test_saslprep shows the difference this change is
leading to.
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/aaEJ-El2seZHeFcG@paquier.xyz M src/common/saslprep.c
M src/test/modules/test_saslprep/expected/test_saslprep.out
M src/test/modules/test_saslprep/t/001_saslprep_ranges.pl
Silence compiler warning from older compilers.
commit : 2e123e3c2bd34f2377212a4e7cfcdbf9e2d9c7ff
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 17:25:12 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 17:25:12 -0400 Our RHEL7-vintage buildfarm animals are complaining about
"the comparison will always evaluate as true" for a usage of
SOFT_ERROR_OCCURRED() on a local variable. This is the same
issue addressed in 7bc88c3d6 and some earlier commits, so solve
it the same way: write "escontext.error_occurred" instead.
Problem dates to recent commit a0b6ef29a, no need for back-patch. M src/backend/commands/tablecmds.c
Doc: minor improvements to SNI documentation.
commit : 7c08a7e809721212b0c2b694cd19bd4379b8974f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 15:33:51 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 15:33:51 -0400 My attention was drawn to this new documentation by overlength-line
complaints in the PDF docs builds: the synopsis for hostname lines was
too wide. I initially thought of shortening the parameter names to
fit, but it turns out that adding <optional> markup is enough to
persuade DocBook to break the line, and that seems more helpful
anyway.
While here, I couldn't resist some copy-editing, mostly being
consistent about whether to use Oxford commas or not. The biggest
change was to re-order the entries in the hostname-values table to
match the running text. M doc/src/sgml/runtime.sgml
Doc: document how EXPLAIN ANALYZE reports parallel queries.
commit : 99d6aa64ef85a736f08b39e4e9b174c9bed035a7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 14:48:52 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 14:48:52 -0400 This wasn't covered anywhere before...
Reported-by: Marcos Pegoraro <marcos@f10.com.br>
Author: Maciek Sakrejda <maciek@pganalyze.com>
Reviewed-by: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAB-JLwYCgdiB=trauAV1HN5rAWQdvDGgaaY_mqziN88pBTvqqg@mail.gmail.com M doc/src/sgml/perform.sgml
doc: make "datadir" argument specification more specific
commit : 0a68fd70cb87ae08c72c3bb626d9b277dd5eb937
author : Bruce Momjian <bruce@momjian.us>
date : Mon, 23 Mar 2026 12:13:31 -0400
committer: Bruce Momjian <bruce@momjian.us>
date : Mon, 23 Mar 2026 12:13:31 -0400 Previously these cases were listed as "directory".
Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+PvCOQqMi0zRk3GecbYzm5xX1wQixxm9Qs3oXXr5fFCUgw@mail.gmail.com M doc/src/sgml/ref/initdb.sgml
M doc/src/sgml/ref/pg_checksums.sgml
M doc/src/sgml/ref/pg_createsubscriber.sgml
M doc/src/sgml/ref/pg_rewind.sgml
Improve commentary about ChangeVarNodesWalkExpression().
commit : 360dd6f7b4c522d9a48d4621feb6da0a91bd7594
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 11:14:24 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Mar 2026 11:14:24 -0400 IMO the proximate cause of the bug fixed in commit 07b7a964d
was sloppy thinking about what ChangeVarNodesWalkExpression()
is to be used for. Flesh out its header comment to try to
improve that situation.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1607553.1774017006@sss.pgh.pa.us
Backpatch-through: 18 M src/backend/rewrite/rewriteManip.c
Fix invalid value of pg_aios.pid, function pg_get_aios()
commit : 93b76db0ace674a29a5d2146a139d6dd87b99659
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 23 Mar 2026 18:13:56 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 23 Mar 2026 18:13:56 +0900 When the value of pg_aios.pid is found to be 0, the function had the
idea to set "nulls" to "false" instead of "true", without setting the
value stored in the tuplestore. This could lead to the display of buggy
data. The intention of the code is clearly to display NULL when a PID
of 0 is found, and this commit adjusts the logic to do so.
Issue introduced by 60f566b4f243.
Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/tencent_7D61A85D6143AD57CA8D8C00DEC541869D06@qq.com
Backpatch-through: 18 M src/backend/storage/aio/aio_funcs.c
ci: Run headerscheck and cpluspluscheck in parallel
commit : 085a531983e210318d9e7d7088482cf4090b1fa6
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Mar 2026 08:21:22 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Mar 2026 08:21:22 +0100 This can save several seconds of wall-clock time for that task.
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/b49e74d4-3cf9-4d1c-9dce-09f75e55d026%40eisentraut.org M .cirrus.tasks.yml
headerscheck: Get CXXFLAGS from Makefile.global
commit : 0f17d1dbfa6224b3ab0f4377c593b880be427f31
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Mar 2026 07:18:11 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Mar 2026 07:18:11 +0100 headerscheck in C++ mode (cpluspluscheck) previously hardcoded
CXXFLAGS and documented that you might need to override them manually
from the environment. Now that we have better C++ support in the
build system, we can just get CXXFLAGS from Makefile.global, like we
do for other variables.
Furthermore, this is necessary in some configurations to make
cpluspluscheck work under meson, because under meson, some -I options
end up in CXXFLAGS where under make they would be in CPPFLAGS.
Therefore, getting the correct CXXFLAGS is required in those cases.
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAMSWrt-PoQt4sHryWrB1ViuGBJF_PpbjoSGrWR2Ry47bHNLDqg%40mail.gmail.com M src/tools/pginclude/README
M src/tools/pginclude/headerscheck
pg_createsubscriber: Introduce module-specific logging functions.
commit : d6628a5ea0a56b62eb3feaa8d8210ce76e9afc2c
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 23 Mar 2026 09:23:20 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 23 Mar 2026 09:23:20 +0530 Replace generic pg_log_* calls with report_createsub_log() and
report_createsub_fatal(). This refactor provides the necessary
infrastructure to support logging to external files via the -l option.
These new functions enable the utility to route messages to both the
terminal and a log file based on the logging configuration and verbosity
levels provided by the user.
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Author: Gyan Sreejith <gyan.sreejith@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc+G+f4oSUHw@mail.gmail.com M src/bin/pg_basebackup/pg_createsubscriber.c
Add missing deflateEnd() for server-side gzip base backups
commit : ded9754804bcdee60d72cfb0e0aaeda03a2c2f44
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 23 Mar 2026 09:04:44 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 23 Mar 2026 09:04:44 +0900 The gzip basebackup sink called deflateInit2() in begin_archive() but
never called deflateEnd(), leaking zlib's internal compression state
(~256KB per archive) until the memory context of the base backup is
destroyed.
The code tree has already a matching deflateEnd() call for each
deflateInit[2]() call (pgrypto, etc.), except for the file touched in
this commit, so this brings more consistency for all the compression
methods. The server-side LZ4 and zstd implementations require a
dedicated cleanup callback as they allocate their state outside the
context of a palloc().
As currently used, deflateInit2() is called once per tablespace in a
single backup. Memory would slightly bloat only when dealing with many
tablespaces at once, not across multiple base backups so this is not
worth a backpatch. This change could matter for future uses of this
code.
zlib allows the definition of memory allocation and free callbacks in
the z_stream object given to a deflateInit[2](). The base backup
backend code relies on palloc() for the allocations and deflateEnd()
internally only cleans up memory (no fd allocation for example).
Author: Jianghua Yang <yjhjstz@gmail.com>
Discussion: https://postgr.es/m/CAAZLFmQNJ0QNArpWEOZXwv=vbumcWKEHz-b1me5gBqRqG67EwQ@mail.gmail.com M src/backend/backup/basebackup_gzip.c
Fix another buglet in archive_waldump.c.
commit : 69c57466a7521ee146cfdde766713181d45a2d36
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:48:38 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:48:38 -0400 While re-reading 860359ea0, I noticed another problem: when
spilling to a temp file, it did not bother to check the result
of fclose(). This is bad since write errors (like ENOSPC)
may not be reported until close time. M src/bin/pg_waldump/archive_waldump.c
Fix assorted bugs in archive_waldump.c.
commit : 860359ea029fa208202da0424300078e5781b5b6
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:24:42 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:24:42 -0400 1. archive_waldump.c called astreamer_finalize() nowhere. This meant
that any data retained in decompression buffers at the moment we
detect archive EOF would never reach astreamer_waldump_content(),
resulting in surprising failures if we actually need the last few
bytes of the archive file.
To fix that, make read_archive_file() do the finalize once it detects
EOF. Change its API to return a boolean "yes there's more data"
rather than the entirely-misleading raw count of bytes read.
2. init_archive_reader() relied on privateInfo->cur_file to track
which WAL segment was being read, but cur_file can become NULL if a
member trailer is processed during a read_archive_file() call. This
could cause unreproducible "could not find WAL in archive" failures,
particularly with compressed archives where all the WAL data fits in
a small number of compressed bytes.
Fix by scanning the hash table after each read to find any cached
WAL segment with sufficient data, instead of depending on cur_file.
Also reduce the minimum data requirement from XLOG_BLCKSZ to
sizeof(XLogLongPageHeaderData), since we only need the long page
header to extract the segment size.
We likewise need to fix init_archive_reader() to scan the whole
hash table for irrelevant entries, since we might have already
loaded more than one entry when the data is compressible enough.
3. get_archive_wal_entry() relied on tracking cur_file to identify
WAL hash table entries that need to be spilled to disk. However,
this can't work for entries that are read completely within a
single read_archive_file call: the caller will never see cur_file
pointing at such an entry. Instead, scan the WAL hash table to
find entries we should spill. This also fixes a buglet that any
hash table entries completely loaded during init_archive_reader
were never considered for spilling.
Also, simplify the logic tremendously by not attempting to spill
entries that haven't been read fully. I am not convinced that the old
logic handled that correctly in every path, and it's really not worth
the complication and risk of bugs to try to spill entries on the fly.
We can just write them in a single go once they are no longer the
cur_file.
4. Fix a rather critical performance problem: the code thought that
resetStringInfo() will reclaim storage, but it doesn't. So by the
end of the run we'd have consumed storage space equal to the total
amount of WAL read, negating all the effort of the spill logic.
Also document the contract that cur_file can change (or become NULL)
during a single read_archive_file() call, since the decompression
pipeline may produce enough output to trigger multiple astreamer
callbacks.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/2178517.1774064942@sss.pgh.pa.us M src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/pg_waldump.h
Remove nonfunctional tar file trailer size check.
commit : 5868372bbfb9ea788cd9621a6db3015ac1681cf7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:13:41 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:13:41 -0400 The ASTREAMER_ARCHIVE_TRAILER case in astreamer_tar_parser_content()
intended to reject tar files whose trailer exceeded 2 blocks. However,
the check compared 'len' after astreamer_buffer_bytes() had already
consumed all the data and set len to 0, so the pg_fatal() could never
fire.
Moreover, per the POSIX specification for the ustar format, the last
physical block of a tar archive is always full-sized, and "logical
records after the two zero logical records may contain undefined data."
GNU tar, for example, zero-pads its output to a 10kB boundary by
default. So rejecting extra data after the two zero blocks would be
wrong even if the check worked. (But if the check had worked, it
would have alerted us to the bug just fixed in 9aa1fcc54.)
Remove the dead check and update the comment to explain why trailing
data is expected and harmless.
Per report from Tom Lane.
Author: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/2178517.1774064942@sss.pgh.pa.us M src/fe_utils/astreamer_tar.c
Fix finalization of decompressor astreamers.
commit : 9aa1fcc547021c341606efbc7c343ff96a8bd964
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:06:48 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 22 Mar 2026 18:06:48 -0400 Send the correct amount of data to the next astreamer, not the
whole allocated buffer size. This bug escaped detection because
in present uses the next astreamer is always a tar-file parser
which is insensitive to trailing garbage. But that may not
be true in future uses.
Author: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/2178517.1774064942@sss.pgh.pa.us
Backpatch-through: 15 M src/fe_utils/astreamer_gzip.c
M src/fe_utils/astreamer_lz4.c
M src/fe_utils/astreamer_zstd.c
Add fake LSN support to hash index AM.
commit : e5836f7b7d9a2949414ae022c74c18070202d429
author : Peter Geoghegan <pg@bowt.ie>
date : Sun, 22 Mar 2026 17:31:43 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sun, 22 Mar 2026 17:31:43 -0400 Use fake LSNs in all hash AM critical sections that write a WAL record.
This gives us a reliable way (a way that works during scans of both
logged and unlogged relations) to detect when an index page was
concurrently modified during the window between when the page is
initially read (by _hash_readpage) and when the page has any known-dead
items LP_DEAD-marked (by _hash_kill_items).
Preparation for an upcoming patch that makes the hash index AM use the
amgetbatch interface, enabling I/O prefetching during hash index scans.
The amgetbatch design imposes certain rules on index AMs with respect to
how they hold on to index page buffer pins (at least in the case of pins
held as an interlock against unsafe concurrent TID recycling by VACUUM).
These rules have consequences for routines that set LP_DEAD bits on
index tuples from an amgetbatch index AM: such routines have an inherent
need to reason about concurrent TID recycling by VACUUM, but can no
longer rely on their amgettuple routine holding on to a buffer pin
(during the aforementioned window) as an interlock against such
recycling. Instead, they have to follow a new, standardized approach.
The new approach taken by amgetbatch index AMs when setting LP_DEAD bits
is heavily based on the current nbtree dropPin design, which was added
by commit 2ed5b87f. It also works by checking if the page's LSN
advanced during the window where unsafe concurrent TID recycling might
have taken place.
This commit is similar to commit 8a879119, which taught nbtree to use
fake LSNs to improve its dropPin behavior. However, unlike that commit,
this is not an independently useful enhancement, since hash doesn't
implement anything like nbtree's dropPin behavior (not yet).
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-WzkehuhxyuA8quc7rRN3EtNXpiKsjPfO8mhb+0Dr2K0Dtg@mail.gmail.com M src/backend/access/hash/hash.c
M src/backend/access/hash/hashinsert.c
M src/backend/access/hash/hashovfl.c
M src/backend/access/hash/hashpage.c
Add pruning fast path for all-visible and all-frozen pages
commit : 01b7e4a46d0fa8478c1142f65ee441fb0c32cca1
author : Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 22 Mar 2026 15:46:50 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 22 Mar 2026 15:46:50 -0400 Because of the SKIP_PAGES_THRESHOLD optimization or a stale prune XID,
heap_page_prune_and_freeze() can be invoked for pages with no pruning or
freezing work to do. To avoid this, if a page is already all-frozen or
it is all-visible and no freezing will be attempted, exit early. We
can't exit early if vacuum passed DISABLE_PAGE_SKIPPING, though.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/include/access/heapam.h
Make IndexScanInstrumentation a pointer in executor scan nodes.
commit : f026fbf059f2d9d7c8f1f52e9210018d38d795d8
author : Peter Geoghegan <pg@bowt.ie>
date : Sun, 22 Mar 2026 13:20:29 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Sun, 22 Mar 2026 13:20:29 -0400 Change the IndexScanInstrumentation fields in IndexScanState,
IndexOnlyScanState, and BitmapIndexScanState from inline structs to
pointers. This avoids additional space overhead whenever new fields are
added to IndexScanInstrumentation in the future, at least in the common
case where the instrumentation isn't used (i.e. when the executor node
isn't being run through an EXPLAIN ANALYZE).
Preparation for an upcoming patch series that will add index
prefetching. The new slot-based interface that will enable index
prefetching necessitates that we add at least one more field to
IndexScanInstrumentation (to count heap fetches during index-only
scans).
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wz=g=JTSyDB4UtB5su2ZcvsS7VbP+ZMvvaG6ABoCb+s8Lw@mail.gmail.com M src/backend/commands/explain.c
M src/backend/executor/nodeBitmapIndexscan.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/include/nodes/execnodes.h
Detect and fix visibility map corruption in more cases
commit : 4f7ecca84ddacbce27bdff3b78981a2bd9c9b242
author : Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 22 Mar 2026 11:52:40 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 22 Mar 2026 11:52:40 -0400 Move VM corruption detection and repair into heap page pruning. This
allows VM repair during on-access pruning, not only during vacuum.
Also, expand corruption detection to cover pages marked all-visible that
contain dead tuples and tuples inserted or deleted by in-progress
transactions, rather than only all-visible pages with LP_DEAD items.
Pinning the correct VM page before on-access pruning is cheap when
compared to the cost of actually pruning. The vmbuffer is saved in the
scan descriptor, so a query should only need to pin each VM page once,
and a single VM page covers a large number of heap pages.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/include/access/heapam.h
M src/tools/pgindent/typedefs.list
Don't reset 'latest_page_number' when replaying multixid truncation
commit : 516310ed4dba89bd300242df0d56b4782f33ed4d
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 22 Mar 2026 14:23:54 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 22 Mar 2026 14:23:54 +0200 'latest_page_number' is set to the correct value, according to
nextOffset, early at system startup. Contrary to the comment, it hence
should be set up correctly by the time we get to WAL replay.
This was committed to back-branches earlier already (commit
817f74600d), to fix a bug in a backwards-compatibility codepath. We
don't have that bug on 'master', but the change nevertheless makes
sense on 'master' too.
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://www.postgresql.org/message-id/20260214090150.GC2297@p46.dedyn.io;lightning.p46.dedyn.io
Discussion: https://www.postgresql.org/message-id/e1787b17-dc93-4621-a5a1-c713d1ac6a1b@iki.fi M src/backend/access/transam/multixact.c
Add test for single-page VACUUM of hash index on INSERT
commit : 1f7947a48d0c4b802f986ac32dc0e95b6f7f8f8f
author : Michael Paquier <michael@paquier.xyz>
date : Sun, 22 Mar 2026 15:24:33 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sun, 22 Mar 2026 15:24:33 +0900 _hash_vacuum_one_page() in hashinsert.c is a routine related to hash
indexes that can perform a single-page VACUUM when dead tuples are
detected during index insertion. This routine previously had no test
coverage, and this commit adds a test case for that purpose.
To safely create dead tuples in a way that works with parallel tests,
this uses a technique based on a rollbacked INSERT, following a
suggestion by Heikki Linnakangas.
Author: Alexander Kuzmenkov <akuzmenkov@tigerdata.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CALzhyqxrc1ZHYmf5V8NE+yMboqVg7xZrQM7K2c7VS0p1v8z42w@mail.gmail.com M src/test/regress/expected/hash_index.out
M src/test/regress/sql/hash_index.sql
Move declarations related to locktags from lock.h to new locktag.h
commit : 322bab79744dfb8f7ddb5191b3102cf7986d14a0
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 21 Mar 2026 14:34:47 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 21 Mar 2026 14:34:47 +0900 This commit moves all the declarations related to locktags from lock.h
to a new header called locktag.h. This header is useful so as code
paths that care about locktags but not the lock hashtable can know about
these without having to include lock.h and all its set of dependencies.
This move includes the basic locktag structures and the set of macros to
fill in the locktag fields before attempting to acquire a lock.
Based on a suggestion from me, suggestion done while discussing a
different feature.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/abufUya2oK-_PJ3E@paquier.xyz M src/include/storage/lock.h
A src/include/storage/locktag.h
plpgsql: optimize "SELECT simple-expression INTO var".
commit : ce8d5fe0e2802158b65699aeae1551d489948167
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 20 Mar 2026 18:23:45 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 20 Mar 2026 18:23:45 -0400 Previously, we always fed SELECT ... INTO to the SPI machinery.
While that works for all cases, it's a great deal slower than
the otherwise-equivalent "var := expression" if the expression
is "simple" and the INTO target is a single variable. Users
coming from MSSQL or T_SQL are likely to be surprised by this;
they are used to writing SELECT ... INTO since there is no
"var := expression" syntax in those dialects. Hence, check for
a simple expression and use the faster code path if possible.
(Here, "simple" means whatever exec_is_simple_query accepts,
which basically means "SELECT scalar-expression" without any
input tables, aggregates, qual clauses, etc.)
This optimization is not entirely transparent. Notably, one of
the reasons it's faster is that the hooks that pg_stat_statements
uses aren't called in this path, so that the evaluated expression
no longer appears in pg_stat_statements output as it did before.
There may be some other minor behavioral changes too, although
I tried hard to make error reporting look the same. Hopefully,
none of them are significant enough to not be acceptable as
routine changes in a PG major version.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Discussion: https://postgr.es/m/CAFj8pRDieSQOPDHD_svvR75875uRejS9cN87FoAC3iXMXS1saQ@mail.gmail.com M contrib/pg_stat_statements/expected/level_tracking.out
M contrib/pg_stat_statements/expected/plancache.out
M src/pl/plpgsql/src/expected/plpgsql_simple.out
M src/pl/plpgsql/src/pl_exec.c
M src/pl/plpgsql/src/sql/plpgsql_simple.sql
Fix dependency on FDW's connection function.
commit : 4a0b46b6e1e4988a317c8ec9a8917e3f6831e427
author : Jeff Davis <jdavis@postgresql.org>
date : Fri, 20 Mar 2026 12:42:59 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Fri, 20 Mar 2026 12:42:59 -0700 Missed in commit 8185bb5347.
Catalog version bump.
Discussion: https://postgr.es/m/fd49b44dc65da8e71ab20c1cf1ec7e65921c20f5.camel@j-davis.com M src/backend/commands/foreigncmds.c
M src/include/catalog/catversion.h
M src/test/regress/expected/foreign_data.out
M src/test/regress/expected/subscription.out
M src/test/regress/sql/foreign_data.sql
M src/test/regress/sql/subscription.sql
pg_verifybackup: Enable WAL parsing for tar-format backups
commit : b3cf461b3cf91c586ab94b4dddd6dcd8ff8fec47
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400 Now that pg_waldump supports reading WAL from tar archives, remove the
restriction that forced --no-parse-wal for tar-format backups.
pg_verifybackup now automatically locates the WAL archive: it looks for
a separate pg_wal.tar first, then falls back to the main base.tar. A
new --wal-path option (replacing the old --wal-directory, which is kept
as a silent alias) accepts either a directory or a tar archive path.
The default WAL directory preparation is deferred until the backup
format is known, since tar-format backups resolve the WAL path
differently from plain-format ones.
Author: Amul Sul <sulamul@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
discussion: https://postgr.es/m/CAAJ_b94bqdWN3h2J-PzzzQ2Npbwct5ZQHggn_QoYGhC2rn-=WQ@mail.gmail.com M doc/src/sgml/ref/pg_verifybackup.sgml
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_verifybackup/t/002_algorithm.pl
M src/bin/pg_verifybackup/t/003_corruption.pl
M src/bin/pg_verifybackup/t/007_wal.pl
M src/bin/pg_verifybackup/t/008_untar.pl
M src/bin/pg_verifybackup/t/010_client_untar.pl
pg_waldump: Add support for reading WAL from tar archives
commit : b15c1513984e6eafd264bf6e84a08549905621f1
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400 pg_waldump can now accept the path to a tar archive (optionally
compressed with gzip, lz4, or zstd) containing WAL files and decode
them. This was added primarily for pg_verifybackup, which previously
had to skip WAL parsing for tar-format backups.
The implementation uses the existing archive streamer infrastructure
with a hash table to track WAL segments read from the archive. If WAL
files within the archive are not in sequential order, out-of-order
segments are written to a temporary directory (created via mkdtemp under
$TMPDIR or the archive's directory) and read back when needed. An
atexit callback ensures the temporary directory is cleaned up.
The --follow option is not supported when reading from a tar archive.
Author: Amul Sul <sulamul@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
discussion: https://postgr.es/m/CAAJ_b94bqdWN3h2J-PzzzQ2Npbwct5ZQHggn_QoYGhC2rn-=WQ@mail.gmail.com M doc/src/sgml/ref/pg_waldump.sgml
M src/bin/pg_waldump/Makefile
A src/bin/pg_waldump/archive_waldump.c
M src/bin/pg_waldump/meson.build
M src/bin/pg_waldump/pg_waldump.c
M src/bin/pg_waldump/pg_waldump.h
M src/bin/pg_waldump/t/001_basic.pl
M src/tools/pgindent/typedefs.list
pg_waldump: Preparatory refactoring for tar archive WAL decoding.
commit : f8a0cd26717063b99d846b693b416187ab56d67b
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400 Several refactoring steps in preparation for adding tar archive WAL
decoding support to pg_waldump:
- Move XLogDumpPrivate and related declarations into a new pg_waldump.h
header, allowing a second source file to share them.
- Factor out required_read_len() so the read-size calculation can be
reused for both regular WAL files and tar-archived WAL.
- Move the WAL segment size variable into XLogDumpPrivate and rename it
to segsize, making it accessible to the archive streamer code.
Author: Amul Sul <sulamul@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
discussion: https://postgr.es/m/CAAJ_b94bqdWN3h2J-PzzzQ2Npbwct5ZQHggn_QoYGhC2rn-=WQ@mail.gmail.com M src/bin/pg_waldump/pg_waldump.c
A src/bin/pg_waldump/pg_waldump.h
Move tar detection and compression logic to common.
commit : c8a350a439826267186c187dbfbf1f839f7521aa
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 20 Mar 2026 15:31:35 -0400 Consolidate tar archive identification and compression-type detection
logic into a shared location. Currently used by pg_basebackup and
pg_verifybackup, this functionality is also required for upcoming
pg_waldump enhancements.
This change promotes code reuse and simplifies maintenance across
frontend tools.
Author: Amul Sul <sulamul@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
discussion: https://postgr.es/m/CAAJ_b94bqdWN3h2J-PzzzQ2Npbwct5ZQHggn_QoYGhC2rn-=WQ@mail.gmail.com M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/common/compression.c
M src/include/common/compression.h
Bump transaction/multixact ID warning limits to 100M.
commit : 48f11bfa06c6bc15369a2a0c89f7594392e02e2d
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 20 Mar 2026 14:15:33 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 20 Mar 2026 14:15:33 -0500 These warning limits were last changed to 40M by commit cd5e82256d.
For the benefit of workloads that rapidly consume transactions or
multixacts, this commit bumps the limits to 100M. This will
hopefully give users enough time to react.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Discussion: https://postgr.es/m/aRdhSSFb9zZH_0zc%40nathan M doc/src/sgml/maintenance.sgml
M src/backend/access/transam/multixact.c
M src/backend/access/transam/varsup.c
Add percentage of available IDs to wraparound warnings.
commit : e646450e609d690ced30d9e8e3fdc27ee6c3ff4c
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 20 Mar 2026 14:15:33 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 20 Mar 2026 14:15:33 -0500 This commit adds DETAIL messages to the existing wraparound
WARNINGs that include the percentage of transaction/multixact IDs
that remain available for use. The hope is that this more clearly
expresses the urgency of the situation.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Discussion: https://postgr.es/m/aRdhSSFb9zZH_0zc%40nathan M doc/src/sgml/maintenance.sgml
M src/backend/access/transam/multixact.c
M src/backend/access/transam/varsup.c
Discount the metapage when estimating number of index pages visited.
commit : 733f20df53721b5be0481afe9f26b9c2a4d51712
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 20 Mar 2026 14:50:53 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 20 Mar 2026 14:50:53 -0400 genericcostestimate() estimates the number of index leaf pages to
be visited as a pro-rata fraction of the total number of leaf pages.
Or at least that was the intention. What it actually used in the
calculation was the total number of index pages, so that non-leaf
pages were also counted. In a decent-sized index the error is
probably small, since we expect upper page fanout to be high.
But in a small index that's not true; in the worst case with one
data-bearing page plus a metapage, we had 100% relative error.
This led to surprising planning choices such as not using a small
partial index.
To fix, ask genericcostestimate's caller to supply an estimate of
the number of non-leaf pages, and subtract that. For the built-in
index AMs, it seems sufficient to count the index metapage (if the
AM uses one) as non-leaf. Per the above argument, counting upper
index pages shouldn't change the estimate much, and in most cases
we don't have any easy way of estimating the number of upper pages.
This might be an area for further research in future.
Any external genericcostestimate callers that do not set the new field
GenericCosts.numNonLeafPages will see the same behavior as before,
assuming they followed the advice to zero out that whole struct.
Unsurprisingly, this change affects a number of plans seen in the
core regression tests. I hacked up the existing tests to keep the
tests' plans the same, since in each case it appeared that the
test's intent was to test exactly that plan. Also add one new
test case demonstrating that a better index choice is now made.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Henson Choi <assam258@gmail.com>
Discussion: https://postgr.es/m/870521.1745860752@sss.pgh.pa.us M contrib/bloom/blcost.c
M src/backend/utils/adt/selfuncs.c
M src/include/utils/selfuncs.h
M src/test/regress/expected/join.out
M src/test/regress/expected/memoize.out
M src/test/regress/expected/select.out
M src/test/regress/sql/join.sql
M src/test/regress/sql/memoize.sql
M src/test/regress/sql/select.sql
Fix self-join removal to update bare Var references in join clauses
commit : 07b7a964d368e0618e1e1c788f3b998b4e571427
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Fri, 20 Mar 2026 15:32:52 +0200
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Fri, 20 Mar 2026 15:32:52 +0200 Self-join removal failed to update Var nodes when the join clause was a
bare Var (e.g., ON t1.bool_col) rather than an expression containing
Vars. ChangeVarNodesWalkExpression() used expression_tree_walker(),
which descends into child nodes but does not process the top-level node
itself. When a bare Var referencing the removed relation appeared as
the clause, its varno was left unchanged, leading to "no relation entry
for relid N" errors.
Fix by calling ChangeVarNodes_walker() directly instead of
expression_tree_walker(), so the top-level node is also processed.
Bug: #19435
Reported-by: Hang Ammmkilo <ammmkilo@163.com>
Author: Andrei Lepikhov <lepihov@gmail.com>
Co-authored-by: Tender Wang <tndrwang@gmail.com>
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/19435-3cc1a87f291129f1%40postgresql.org
Backpatch-through: 18 M src/backend/rewrite/rewriteManip.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql
SET NOT NULL: Call object-alter hook only after the catalog change
commit : e7975f1c06b585dcda645c6047e6f37cdfacce84
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 20 Mar 2026 14:38:50 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 20 Mar 2026 14:38:50 +0100 ... otherwise, the function invoked by the hook might consult the
catalog and not see that the new constraint exists.
This relies on set_attnotnull doing CommandCounterIncrement()
after successfully modifying the catalog.
Oversight in commit 14e87ffa5c54.
Author: Artur Zakirov <zaartur@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/CAKNkYnxUPCJk-3Xe0A3rmCC8B8V8kqVJbYMVN6ySGpjs_qd7dQ@mail.gmail.com M src/backend/commands/tablecmds.c
test_plan_advice: Set TAP test priority 50 in meson.build.
commit : 12444183e40187a9fb6002a3912053f302725f0a
author : Robert Haas <rhaas@postgresql.org>
date : Fri, 20 Mar 2026 08:39:55 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Fri, 20 Mar 2026 08:39:55 -0400 Since this runs the main regression tests, it can take some time to
complete. Therefore, it's better to start it earlier, as we also do
for the main regression test suite.
Author: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: http://postgr.es/m/1095d3fe-a6eb-4d83-866e-649d6f369908@gmail.com M src/test/modules/test_plan_advice/meson.build
Add option force_array for COPY JSON FORMAT
commit : 4c0390ac53b745c2800f6aa3d9ee2515d6ab499b
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 16 Mar 2026 16:51:12 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 16 Mar 2026 16:51:12 -0400 This adds the force_array option, which is available exclusively
when using COPY TO with the JSON format.
When enabled, this option wraps the output in a top-level JSON array
(enclosed in square brackets with comma-separated elements), making the
entire result a valid single JSON value. Without this option, the
default behavior is to output a stream of independent JSON objects.
Attempting to use this option with COPY FROM or with formats other than
JSON will raise an error.
Author: Joe Conway <mail@joeconway.com>
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Florents Tselai <florents.tselai@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CALvfUkBxTYy5uWPFVwpk_7ii2zgT07t3d-yR_cy4sfrrLU%3Dkcg%40mail.gmail.com
Discussion: https://postgr.es/m/6a04628d-0d53-41d9-9e35-5a8dc302c34c@joeconway.com M doc/src/sgml/ref/copy.sgml
M src/backend/commands/copy.c
M src/backend/commands/copyto.c
M src/bin/psql/tab-complete.in.c
M src/include/commands/copy.h
M src/test/regress/expected/copy.out
M src/test/regress/sql/copy.sql
json format for COPY TO
commit : 7dadd38cda95bf5bc0c4715d9ab71766d1693379
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 16 Mar 2026 16:50:24 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 16 Mar 2026 16:50:24 -0400 This introduces the JSON format option for the COPY TO command, allowing
users to export query results or table data directly as a stream of JSON
objects (one per line, NDJSON style).
The JSON format is currently supported only for COPY TO operations; it
is not available for COPY FROM.
JSON format is incompatible with some standard text/CSV formatting
options, including HEADER, DEFAULT, NULL, DELIMITER, FORCE QUOTE,
FORCE NOT NULL, and FORCE NULL.
Column list support is included: when a column list is specified, only
the named columns are emitted in each JSON object.
Regression tests covering valid JSON exports and error handling for
incompatible options have been added to src/test/regress/sql/copy.sql.
Author: Joe Conway <mail@joeconway.com>
Author: jian he <jian.universality@gmail.com>
Co-Authored-By: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Daniel Verite <daniel@manitou-mail.org>
Reviewed-by: Davin Shearer <davin@apache.org>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CALvfUkBxTYy5uWPFVwpk_7ii2zgT07t3d-yR_cy4sfrrLU%3Dkcg%40mail.gmail.com
Discussion: https://postgr.es/m/6a04628d-0d53-41d9-9e35-5a8dc302c34c@joeconway.com M doc/src/sgml/ref/copy.sgml
M src/backend/commands/copy.c
M src/backend/commands/copyto.c
M src/backend/parser/gram.y
M src/backend/utils/adt/json.c
M src/bin/psql/tab-complete.in.c
M src/include/commands/copy.h
M src/include/utils/json.h
M src/test/regress/expected/copy.out
M src/test/regress/sql/copy.sql
introduce CopyFormat, refactor CopyFormatOptions
commit : a2145605ee3d92faccd769010059b110c44104ff
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 16 Mar 2026 16:49:01 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 16 Mar 2026 16:49:01 -0400 Currently, the COPY command format is determined by two boolean fields
(binary, csv_mode) in CopyFormatOptions. This approach, while
functional, isn't ideal for implementing other formats in the future.
To simplify adding new formats, introduce a CopyFormat enum. This makes
the code cleaner and more maintainable, allowing for easier integration
of additional formats down the line.
Author: Joel Jacobson <joel@compiler.org>
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CALvfUkBxTYy5uWPFVwpk_7ii2zgT07t3d-yR_cy4sfrrLU%3Dkcg%40mail.gmail.com
Discussion: https://postgr.es/m/6a04628d-0d53-41d9-9e35-5a8dc302c34c@joeconway.com M src/backend/commands/copy.c
M src/backend/commands/copyfrom.c
M src/backend/commands/copyfromparse.c
M src/backend/commands/copyto.c
M src/include/commands/copy.h
M src/tools/pgindent/typedefs.list
Cleanup users and roles in graph_table_rls test
commit : 040a56be4bcc88cad98f092970a8c6521263bba1
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 20 Mar 2026 10:54:35 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 20 Mar 2026 10:54:35 +0100 This test leaves behind the roles and users it creates.
002_pg_upgrade test dumps and restore the regression when
PG_TEST_EXTRA contains regress_dump_restore. The global objects such
as users and roles are not dumped by pg_dump. But it still dumps the
policies associated with users, and commands to set the ownership.
Restoring these policies and the ownerships fails since the users and
roles do not exist. To fix this failure we could use --no-owner, but
it does not exclude the policy objects associated with users. Hence
drop the users, roles and policies that depend upon them at the end of
the test.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reported-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org M src/test/regress/expected/graph_table_rls.out
M src/test/regress/sql/graph_table_rls.sql
Update Unicode data to Unicode 17.0.0
commit : 57ee397953985feb95cffa65a06fcaf6a2cd5367
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 20 Mar 2026 08:42:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 20 Mar 2026 08:42:50 +0100 Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Alexander Borisov <lex.borisov@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/2a668979-ed92-49a3-abf9-a3ec2d460ec2%40eisentraut.org M contrib/unaccent/unaccent.rules
M src/Makefile.global.in
M src/common/unicode/meson.build
M src/include/common/unicode_case_table.h
M src/include/common/unicode_category_table.h
M src/include/common/unicode_east_asian_fw_table.h
M src/include/common/unicode_nonspacing_table.h
M src/include/common/unicode_norm_hashfunc.h
M src/include/common/unicode_norm_table.h
M src/include/common/unicode_normprops_table.h
M src/include/common/unicode_version.h
Add support for EXCEPT TABLE in ALTER PUBLICATION.
commit : 493f8c6439cf64d75883c650b5dd573d8fe0664b
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 20 Mar 2026 11:36:09 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 20 Mar 2026 11:36:09 +0530 Following commit fd366065e0, which added EXCEPT TABLE support to
CREATE PUBLICATION, this commit extends ALTER PUBLICATION to allow
modifying the exclusion list.
New Syntax:
ALTER PUBLICATION name SET publication_all_object [, ... ]
where publication_all_object is one of:
ALL TABLES [ EXCEPT TABLE ( except_table_object [, ... ] ) ]
ALL SEQUENCES
If the EXCEPT clause is provided, the existing exclusion list in
pg_publication_rel is replaced with the specified relations. If the
EXCEPT clause is omitted, any existing exclusions for the publication
are cleared. Similarly, SET ALL SEQUENCES updates
Note that because this is a SET command, specifying only one object
type (e.g., SET ALL SEQUENCES) will reset the other unspecified flags
(e.g., setting puballtables to false).
Consistent with CREATE PUBLICATION, only root partitioned tables or
standard tables can be specified in the EXCEPT list. Specifying a
partition child will result in an error.
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Discussion: https://postgr.es/m/CALDaNm3=JrucjhiiwsYQw5-PGtBHFONa6F7hhWCXMsGvh=tamA@mail.gmail.com M doc/src/sgml/ref/alter_publication.sgml
M src/backend/catalog/pg_publication.c
M src/backend/commands/publicationcmds.c
M src/backend/commands/tablecmds.c
M src/backend/parser/gram.y
M src/bin/psql/tab-complete.in.c
M src/include/catalog/pg_publication.h
M src/include/nodes/parsenodes.h
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql
M src/test/subscription/t/037_except.pl
Fix new tuple deforming code so it can support cstrings again
commit : 07d5bffe75d05b9c84803ea1ffaf5ce729f0e717
author : David Rowley <drowley@postgresql.org>
date : Fri, 20 Mar 2026 14:16:06 +1300
committer: David Rowley <drowley@postgresql.org>
date : Fri, 20 Mar 2026 14:16:06 +1300 In c456e3911, I mistakenly thought that the deformer code would never
see cstrings and that I could use pg_assume() to have the compiler omit
producing code for attlen == -2 attributes. That saves bloating the
deforming code a bit with the extra check and strlen() call. While this
is ok to do for tuples from the heap, it's not ok to do for
MinimalTuples as those *can* contain cstrings and
tts_minimal_getsomeattrs() implements deforming by inlining the
(slightly misleadingly named) slot_deform_heap_tuple() code.
To fix, add a new parameter to the slot_deform_heap_tuple() and have the
callers define which code to inline. Because this new parameter is
passed as a const, the compiler can choose to emit or not emit the
cstring-related code based on the parameter's value.
Author: David Rowley <dgrowleyml@gmail.com>
Reported-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAHewXNmSK+gKziAt_WvQoMVWt3_LRVMmRYY9dAbMPMcpPV0QmA@mail.gmail.com M src/backend/executor/execTuples.c
Fix dependency on FDW handler.
commit : 703fee3b25c45b3b336b95f91a6a89ade85815f4
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 19 Mar 2026 14:59:07 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 19 Mar 2026 14:59:07 -0700 ALTER FOREIGN DATA WRAPPER could drop the dependency on the handler
function if it wasn't explicitly specified.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/35c44a4b7fb76d35418c4d66b775a88f4ce60c86.camel@j-davis.com
Backpatch-through: 14 M src/backend/commands/foreigncmds.c
M src/test/regress/expected/foreign_data.out
M src/test/regress/sql/foreign_data.sql
Add parallel vacuum worker usage to VACUUM (VERBOSE) and autovacuum logs.
commit : adcdbe93860b16a069c6834062e56e731c54a1a1
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 19 Mar 2026 15:01:47 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 19 Mar 2026 15:01:47 -0700 This commit adds both the number of parallel workers planned and the
number of parallel workers actually launched to the output of
VACUUM (VERBOSE) and autovacuum logs.
Previously, this information was only reported as an INFO message
during VACUUM (VERBOSE), which meant it was not included in autovacuum
logs in practice. Although autovacuum does not yet support parallel
vacuum, a subsequent patch will enable it and utilize these logs in
its regression tests. This change also improves observability by
making it easier to verify if parallel vacuum is utilizing the
expected number of workers.
Author: Daniil Davydov <3danissimo@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CACG=ezZOrNsuLoETLD1gAswZMuH2nGGq7Ogcc0QOE5hhWaw=cw@mail.gmail.com M src/backend/access/heap/vacuumlazy.c
M src/backend/commands/vacuumparallel.c
M src/include/commands/vacuum.h
M src/tools/pgindent/typedefs.list
Allow explicit casting between bytea and uuid.
commit : ba21f5bf8aff277aa1659a51d26109e0914df182
author : Masahiko Sawada <msawada@postgresql.org>
date : Thu, 19 Mar 2026 13:51:50 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Thu, 19 Mar 2026 13:51:50 -0700 This enables the use of functions such as encode() and decode() with
UUID values, allowing them to be converted to and from alternative
formats like base64 or hex.
The cast maps the 16-byte internal representation of a UUID directly
to a bytea datum. This is more efficient than going through a text
forepresentation.
Bump catalog version.
Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Co-authored-by: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://postgr.es/m/CAJ7c6TOramr1UTLcyB128LWMqita1Y7%3Darq3KHaU%3Dqikf5yKOQ%40mail.gmail.com M doc/src/sgml/datatype.sgml
M src/backend/utils/adt/bytea.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_cast.dat
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/uuid.out
M src/test/regress/sql/uuid.sql
Improve hash join's handling of tuples with null join keys.
commit : 1811f1af98fb237fdd5adb588cd4b57c433b75f8
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 19 Mar 2026 15:21:36 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 19 Mar 2026 15:21:36 -0400 In a plain join, we can just summarily discard an input tuple
with null join key(s), since it cannot match anything from
the other side of the join (assuming a strict join operator).
However, if the tuple comes from the outer side of an outer join
then we have to emit it with null-extension of the other side.
Up to now, hash joins did that by inserting the tuple into the hash
table as though it were a normal tuple. This is unnecessarily
inefficient though, since the required processing is far simpler than
for a potentially-matchable tuple. Worse, if there are a lot of such
tuples they will bloat the hash bucket they go into, possibly causing
useless repeated attempts to split that bucket or increase the number
of batches. We have a report of a large join vainly creating many
thousands of batches when faced with such input.
This patch improves the situation by keeping such tuples out of the
hash table altogether, instead pushing them into a separate tuplestore
from which we return them later. (One might consider trying to return
them immediately; but that would require substantial refactoring, and
it doesn't work anyway for cases where we rescan an unmodified hash
table.) This works even in parallel hash joins, because whichever
worker reads a null-keyed tuple can just return it; there's no need
for consultation with other workers. Thus the tuplestores are local
storage even in a parallel join.
A pre-existing buglet that I noticed while analyzing the code's
behavior is that ExecHashRemoveNextSkewBucket fails to decrement
hashtable->skewTuples for tuples moved into the main hash table
from the skew hash table. This invalidates ExecHashTableInsert's
calculation of the number of main-hash-table tuples, though probably
not by a lot since we expect the skew table to be small relative
to the main one. Nonetheless, let's fix that too while we're here.
Bug: #18909
Reported-by: Sergey Koposov <Sergey.Koposov@ed.ac.uk>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/3061845.1746486714@sss.pgh.pa.us M src/backend/executor/execExpr.c
M src/backend/executor/nodeHash.c
M src/backend/executor/nodeHashjoin.c
M src/backend/utils/sort/tuplestore.c
M src/include/executor/executor.h
M src/include/executor/hashjoin.h
M src/include/executor/nodeHash.h
M src/include/nodes/execnodes.h
M src/include/utils/tuplestore.h
M src/test/regress/expected/join.out
M src/test/regress/expected/join_hash.out
M src/test/regress/sql/join.sql
M src/test/regress/sql/join_hash.sql
Avoid leaking duplicated file descriptors in corner cases.
commit : 8b02c22bb43cb480f437704dc547ea77196b7e93
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 19 Mar 2026 14:25:26 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 19 Mar 2026 14:25:26 -0400 pg_dump's compression modules had variations on the theme of
fp = fdopen(dup(fd), mode);
if (fp == NULL)
// fail, reporting errno
which is problematic for two reasons. First, if dup() succeeds but
fdopen() fails, we'd leak the duplicated FD. That's not important
at present since the program will just exit immediately after failure
anyway; but perhaps someday we'll try to continue, making the resource
leak potentially significant. Second, if dup() fails then fdopen()
will overwrite the useful errno (perhaps EMFILE) with a misleading
value EBADF, making it difficult to understand what went wrong.
Fix both issues by testing for dup() failure before proceeding to
the next call.
These failures are sufficiently unlikely, and the consequences minor
enough, that this doesn't seem worth the effort to back-patch.
But let's fix it in HEAD.
Author: Jianghua Yang <yjhjstz@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/62bbe34d-2315-4b42-b768-56d901aa83e1@gmail.com 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/compress_zstd.c
Allow choosing specific grantors via GRANT/REVOKE ... GRANTED BY.
commit : dd1398f1378799acc60c3ed85d82439b2ff69141
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 19 Mar 2026 11:41:39 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 19 Mar 2026 11:41:39 -0500 Except for GRANT and REVOKE on roles, the GRANTED BY clause
currently only accepts the current role to match the SQL standard.
And even if an acceptable grantor (i.e., the current role) is
specified, Postgres ignores it and chooses the "best" grantor for
the command. Allowing the user to select a specific grantor would
allow better control over the precise behavior of GRANT/REVOKE
statements. This commit adds that ability. For consistency with
select_best_grantor(), we only permit choosing grantor roles for
which the current role inherits privileges.
Author: Nathan Bossart <nathandbossart@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/aRYLkTpazxKhnS_w%40nathan M doc/src/sgml/ref/grant.sgml
M doc/src/sgml/ref/revoke.sgml
M src/backend/catalog/aclchk.c
M src/backend/utils/adt/acl.c
M src/include/nodes/parsenodes.h
M src/include/utils/acl.h
M src/include/utils/aclchk_internal.h
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql
dshash: Make it possible to suppress out of memory errors
commit : 6f0738ddec85b416e7186e3099be70a3420bf3ea
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 19 Mar 2026 11:51:17 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 19 Mar 2026 11:51:17 -0400 Introduce dshash_find_or_insert_extended, which is just like
dshash_find_or_insert except that it takes a flags argument.
Currently, the only supported flag is DSHASH_INSERT_NO_OOM, but
I have chosen to use an integer rather than a boolean in case we
end up with more flags in the future.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: http://postgr.es/m/CA+TgmoaJwUukUZGu7_yL74oMTQQz2=zqucMhF9+9xBmSC5us1w@mail.gmail.com M src/backend/lib/dshash.c
M src/include/lib/dshash.h
Fix transient memory leakage in jsonpath evaluation.
commit : 5a2043bf713113b0f6e9dbf2046499a5ca67883c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 19 Mar 2026 11:37:14 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 19 Mar 2026 11:37:14 -0400 This patch reimplements JsonValueList to be more space-efficient
and arranges for temporary JsonValueLists created during jsonpath
evaluation to be freed when no longer needed, rather than being
leaked till the end of the function evaluation cycle as before.
The motivation is to prevent indefinite memory bloat while
evaluating jsonpath expressions that traverse a lot of data.
As an example, this query
SELECT
jsonb_path_query((SELECT jsonb_agg(i) FROM generate_series(1,10000) i),
'$[*] ? (@ < $)');
formerly required about 6GB to execute, with the space required
growing quadratically with the length of the input array.
With this patch the memory consumption stays static. (The time
required is still quadratic, but we can't do much about that: this
path expression asks to compare each array element to each other one.)
The bloat happens because we construct a JsonValueList containing all
the array elements to represent the second occurrence of "$", and then
just leak it after evaluating the filter expression for any one value
generated from "$[*]". If I were implementing this functionality from
scratch I'd probably try to avoid materializing that representation at
all, but changing that now looks like more trouble than it's worth.
This patch takes the more conservative approach of just making sure
we free the list after we're done with it.
The existing representation of JsonValueList is neither especially
compact nor especially easy to free: it's a List containing pointers
to separately-palloc'd JsonbValue structs. We could theoretically
use list_free_deep, but it's not 100% clear that all the JsonbValues
are always safe for us to free. In any case we are talking about a
lot of palloc/pfree traffic if we keep it like this. This patch
replaces that with what's essentially an expansible array of
JsonbValues, so that even a long list requires relatively few
palloc requests. Also, for the very common case that only one or
two elements appear in the list, this representation uses *zero*
pallocs: the elements can be kept in the on-the-stack base struct.
Note that we are only interested in freeing the JsonbValue structs
themselves. While many types of JsonbValue include pointers to
external data such as strings or numerics, we expect that that data
is part of the original jsonb input Datum(s) and need not (indeed
cannot) be freed here.
In this reimplementation, JsonValueListAppend() always copies the
supplied JsonbValue struct into the JsonValueList data. This allows
simplifying and regularizing many call sites that sometimes palloc'd
JsonbValues and sometimes passed a local-variable JsonbValue. Always
doing the latter is simpler, faster, and less bug-prone.
I also removed JsonValueListLength() in favor of constant-time tests
for whether the list has zero, one, or more than one member, which is
what the callers really need to know. JsonValueListLength() was not
a hot code path, so this aspect of the patch won't move the needle in
the least performance-wise. But it seems neater.
I've not done any wide-ranging performance testing, but this should
be faster than the old code thanks to reduction of palloc overhead.
On the specific example shown above, it's about twice as fast as
before on not-very-large inputs; and of course it wins big if you
consider an input large enough to drive the old code into swapping.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/569394.1773783211@sss.pgh.pa.us M src/backend/utils/adt/jsonpath_exec.c
Add some const qualifiers enabled by typeof_unqual change on copyObject
commit : 7724cb9935a96eabba80f5e62ee4b32068967dd2
author : Peter Eisentraut <peter@eisentraut.org>
date : Thu, 19 Mar 2026 06:34:27 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Thu, 19 Mar 2026 06:34:27 +0100 The recent commit to change copyObject() to use typeof_unqual allows
cleaning up some APIs to take advantage of this improved qualifier
handling. EventTriggerCollectSimpleCommand() is a good example: It
takes a node tree and makes a copy that it keeps around for its
internal purposes, but it can't communicate via its function signature
that it promises not scribble on the passed node tree. That is now
fixed.
Reviewed-by: David Geier <geidav.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org M src/backend/catalog/index.c
M src/backend/commands/event_trigger.c
M src/backend/commands/indexcmds.c
M src/backend/commands/trigger.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/partitioning/partprune.c
M src/backend/rewrite/rewriteManip.c
M src/backend/utils/cache/plancache.c
M src/include/commands/defrem.h
M src/include/commands/event_trigger.h
M src/include/commands/trigger.h
M src/include/rewrite/rewriteManip.h
M src/include/utils/plancache.h
Add commit 015d32016d84 to .git-blame-ignore-revs.
commit : 46fb08aff69fd293961ac57e9339aef855555692
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 13:45:07 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 13:45:07 +0900 M .git-blame-ignore-revs
test_saslprep: Apply proper indentation
commit : 015d32016d845f8a29b3ec3ab7fa98a69cea1a0f
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 13:42:24 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 13:42:24 +0900 Noticed before koel has the idea to complain. Rebase thinko from commit
aa73838a5c94. M src/test/modules/test_saslprep/t/001_saslprep_ranges.pl
M src/test/modules/test_saslprep/test_saslprep.c
M src/tools/pgindent/typedefs.list
Short-circuit row estimation in NOT IN containing NULL consts
commit : c95cd2991f1e3ece689adfe662082f200126d255
author : David Rowley <drowley@postgresql.org>
date : Thu, 19 Mar 2026 17:16:36 +1300
committer: David Rowley <drowley@postgresql.org>
date : Thu, 19 Mar 2026 17:16:36 +1300 ScalarArrayOpExpr used for either NOT IN or <>/= ALL, when the array
contains a NULL constant, will never evaluate to true. Here we add an
explicit short-circuit in scalararraysel() to account for this and return
0.0 rows when we see that a NULL exists. When the array is a constant,
we can very quickly see if there are any NULL values and return early
before going to much effort in scalararraysel(). For non-const arrays,
we short-circuit after finding the first NULL and forego selectivity
estimations of any remaining elements.
In the future, it might be better to do something for this case in
constant folding. We would need to be careful to only do this for
strict operators on expressions located in places that don't care about
distinguishing false from NULL returns. i.e. EXPRKIND_QUAL expressions.
Doing that requires a bit more thought and effort, so here we just fix
some needlessly slow selectivity estimations for ScalarArrayOpExpr
containing many array elements and at least one NULL.
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/eaa2598c-5356-4e1e-9ec3-5fd6eb1cd704@tantorlabs.com M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/planner_est.out
M src/test/regress/sql/planner_est.sql
test_saslprep: Test module for SASLprep()
commit : aa73838a5c94457552d261968f63ee6ea6e366f5
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 13:03:30 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 13:03:30 +0900 This module includes two functions:
- test_saslprep(), that performs pg_saslprep on a bytea.
- test_saslprep_ranges(), able to check for all valid ranges of UTF-8
codepoints pg_saslprep() handles each one of them.
This provides a detailed coverage of our implementation of SASLprep()
used for SCRAM, with:
- ASCII characters.
- Incomplete UTF-8 sequences, for 390b3cbbb2af (later backpatched).
- A more advanced check for all the valid UTF-8 ranges of codepoints, to
check for cases where these generate an empty password, based on an
original suggestion from Heikki Linnakangas. This part consumes
resources and time, so it is implemented as a TAP test under a
new PG_TEST_EXTRA value.
A different patch is still under discussion to tweak our internal
SASLprep() implementation, and this module can be used to track any
changes in behavior.
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/aaEJ-El2seZHeFcG@paquier.xyz M doc/src/sgml/regress.sgml
M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_saslprep/.gitignore
A src/test/modules/test_saslprep/Makefile
A src/test/modules/test_saslprep/README
A src/test/modules/test_saslprep/expected/test_saslprep.out
A src/test/modules/test_saslprep/meson.build
A src/test/modules/test_saslprep/sql/test_saslprep.sql
A src/test/modules/test_saslprep/t/001_saslprep_ranges.pl
A src/test/modules/test_saslprep/test_saslprep–1.0.sql
A src/test/modules/test_saslprep/test_saslprep.c
A src/test/modules/test_saslprep/test_saslprep.control
Add more debugging information for bgworker termination tests of worker_spi
commit : 79a5911fe65be80d4a4cb6ca6f90ae7d2cc6e9bc
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 11:39:31 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 19 Mar 2026 11:39:31 +0900 widowbird has failed again after af8837a10bc7, with the same symptoms of
a backend still lying around when attempting a database rename with a
bgworker connected to the database being renamed.
We are still not sure yet how the failure can be reached, if this is a
timing issue in the test or an actual bug in the logic used for
interruptible bgworkers. This commit adds more debugging information in
the backend to help with the analysis as a temporary measure.
Another thing I have noticed is that the queries launching the dynamic
bgworkers or checking pg_stat_activity would connect to the database
renamed. These are switched to use 'postgres'. That will hopefully
remove some of the friction of the test, but I doubt that this is the
end of the story.
Discussion: https://postgr.es/m/abtJLEAsf1HZXWdR@paquier.xyz M src/backend/postmaster/bgworker.c
M src/test/modules/worker_spi/t/002_worker_terminate.pl
doc: Clarify BUFFERS behavior without ANALYZE in EXPLAIN
commit : 645c6d05cc37d06994b7423c1bf816c609bcb6be
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 19 Mar 2026 08:30:50 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 19 Mar 2026 08:30:50 +0900 This commit clarifies the documentation for the BUFFERS option of EXPLAIN
by explicitly describing its behavior when ANALYZE is not specified.
Author: Ryo Matsumura <matsumura.ryo@fujitsu.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/TYRPR01MB13457D31085CB5B246DBBA1AFE845A@TYRPR01MB13457.jpnprd01.prod.outlook.com M doc/src/sgml/ref/explain.sgml
pg_plan_advice: Fix multiple copy-and-paste-errors in test case.
commit : b335fe56f35506348a567648e3a7ac1b3ac0baf3
author : Robert Haas <rhaas@postgresql.org>
date : Wed, 18 Mar 2026 18:15:36 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Wed, 18 Mar 2026 18:15:36 -0400 The second half of this file is meant to test feedback, not
generated advice, and is meant to use the statements that it
prepares, not leftover prepared statements from earlier in the
file.
These mistakes resulted in failures under debug_discard_caches = 1,
because re-executing pt2 instead of executing pt4 for the first
time resulted in different output depending on whether the query
was replanned.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us> (per BF member avocet) M contrib/pg_plan_advice/expected/prepared.out
M contrib/pg_plan_advice/sql/prepared.sql
ssl: Skip passphrase reload tests in EXEC_BACKEND builds
commit : e87ab5049deb6ea2fe26d4d8395d3f3b7d496bfc
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 18 Mar 2026 22:59:57 +0100
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 18 Mar 2026 22:59:57 +0100 SSL password command reloading must be enabled on Windows and in
EXEC_BACKEND builds due to them always reloading the context. The
new tests in commit 4f433025 skipped under Windows but missed the
EXEC_BACKEND check. Reported by buildfarm member culicidae.
Author: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAOYmi+kXmCCgBWffzmSjaNhME5rD=gjyc_OP1FeWQTw2MmSNjg@mail.gmail.com M src/test/ssl/t/004_sni.pl
Fix -Wstrict-prototypes warning in ecpg_init_sqlca() declaration.
commit : f91b8ff6af910744e6e317c5c2bc2698addde59a
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 18 Mar 2026 15:25:12 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 18 Mar 2026 15:25:12 -0400 When headerscheck compiles ecpglib_extern.h, POSTGRES_ECPG_INTERNAL is
not defined, causing sqlca.h to expand "sqlca" as a macro
(*ECPGget_sqlca()). This causes the ecpg_init_sqlca() declaration to
trigger a -Wstrict-prototypes warning.
Fix by renaming the parameter from "sqlca" to "sqlca_p" in both the
declaration and definition, avoiding the macro expansion.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reported-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Diagnosed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAN55FZ1VDwJ-ZD092ChYf%2B%2BhuP%2B-S3Cg45tJ8jNH5wx2c4BHAg%40mail.gmail.com M src/interfaces/ecpg/ecpglib/ecpglib_extern.h
M src/interfaces/ecpg/ecpglib/misc.c
pg_restore: Remove unnecessary strlen() calls in options parsing.
commit : ec80215c033dfbea0e864b955ec9d2c0a7f4a4ca
author : Nathan Bossart <nathan@postgresql.org>
date : Wed, 18 Mar 2026 14:22:15 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Wed, 18 Mar 2026 14:22:15 -0500 Unlike pg_dump and pg_dumpall, pg_restore first checks whether the
argument passed to --format, --host, and --port is empty before
setting the corresponding variable. Consequently, pg_restore does
not error if given an empty format name, whereas pg_dump and
pg_dumpall do. Empty arguments for --host and --port are ignored
by all three applications, so this commit produces no functionality
changes there. This behavior should perhaps be reconsidered, but
that is left as a future exercise. As with other recent changes to
option handling for these applications (commits b2898baaf7,
7c8280eeb5, and be0d0b457c), no back-patch.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Discussion: https://postgr.es/m/CAKYtNApkh%3DVy2DpNRCnEJmPpxNuksbAh_QBav%3D2fLmVjBhGwFw%40mail.gmail.com M src/bin/pg_dump/pg_restore.c
M src/bin/pg_dump/t/001_basic.pl
ALTER SUBSCRIPTION ... SERVER test.
commit : 1c5bf1185af0128a8415fc48155045fb16b51dee
author : Jeff Davis <jdavis@postgresql.org>
date : Wed, 18 Mar 2026 10:15:51 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Wed, 18 Mar 2026 10:15:51 -0700 Test ALTER SUBSCRIPTION ... SERVER and ALTER SUBSCRIPTION
... CONNECTION, including invalidation.
Also run perltidy on the test file.
Discussion: https://postgr.es/m/CAExHW5vV5znEvecX=ra2-v7UBj9-M6qvdDzuB78M-TxbYD1PEA@mail.gmail.com
Suggested-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> M contrib/postgres_fdw/t/010_subscription.pl
Exclude contrib/pg_plan_advice/pgpa_parser.h from headerscheck.
commit : 8df3c7a85ec24d1598f7a3bf77458b453ee6e6fb
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 18 Mar 2026 13:10:14 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 18 Mar 2026 13:10:14 -0400 Like other Bison-written headers, it's not worth the trouble to
make this compilable standalone. (We might revisit this someday,
if we ever move up our minimum required Bison version.) M src/tools/pginclude/headerscheck
Fix pg_dump for CREATE FOREIGN DATA WRAPPER ... CONNECTION.
commit : b71bf3b8457027c445b5b3aa4914daa7e6718cf4
author : Jeff Davis <jdavis@postgresql.org>
date : Wed, 18 Mar 2026 09:58:42 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Wed, 18 Mar 2026 09:58:42 -0700 Discussion: https://postgr.es/m/7eb0c03b4312b32cb76d340023b39a751745a1f9.camel@j-davis.com M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
Enable -Wstrict-prototypes and -Wold-style-definition by default
commit : 29bf4ee7496ca594495deb2599e8a44c6338525e
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 14:31:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 14:31:50 +0100 Those are available in all gcc and clang versions that support C11 and as C11
is required as of f5e0186f865c, then we can add them without capability test.
Having them enabled by default avoid having to chase these manually like
11171fe1fc8, cdf4b9aff2, 0e72b9d440, 7069dbcc31, f1283ed6cc, 7b66e2c086,
e95126cf04 and 9f7c527af3 have done.
Also, readline headers trigger a lot of warnings with -Wstrict-prototypes, so
we make use of the system_header pragma to hide the warnings.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/13d51b20-a69c-4ac1-8546-ec4fc278064f%40eisentraut.org
Discussion: https://postgr.es/m/aTFctZwWSpl2/LG5%40ip-10-97-1-34.eu-west-3.compute.internal M configure
M configure.ac
M meson.build
M src/bin/psql/input.h
Update RELEASE_CHANGES
commit : 9b406a9e48545adf36c0dfcfc565be468d274f8b
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 13:36:44 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 13:36:44 +0100 The existing instructions did not cover meson. Point to
src/common/unicode/README instead, where there is more information.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/2a668979-ed92-49a3-abf9-a3ec2d460ec2%40eisentraut.org M src/tools/RELEASE_CHANGES
Implement unaccent Unicode data update in meson
commit : 1b0c269f2e4f1cdcfd6d7c71d8eaa8020c23ebdb
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 13:36:44 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 13:36:44 +0100 The meson/ninja update-unicode target did not cover the required
updates in contrib/unaccent/. This is fixed now.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Alexander Borisov <lex.borisov@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/2a668979-ed92-49a3-abf9-a3ec2d460ec2%40eisentraut.org M contrib/unaccent/meson.build
M meson.build
M src/common/unicode/README
M src/common/unicode/meson.build
ssl: Serverside SNI support for libpq
commit : 4f433025f666fa4a6209f0e847715767fb1c7ace
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 18 Mar 2026 12:37:11 +0100
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 18 Mar 2026 12:37:11 +0100 Support for SNI was added to clientside libpq in 5c55dc8b4733 with the
sslsni parameter, but there was no support for utilizing it serverside.
This adds support for serverside SNI such that certificate/key handling
is available per host. A new config file, $datadir/pg_hosts.conf, is
used for configuring which certificate and key should be used for which
hostname. In order to use SNI the ssl_sni GUC must be set to on, when
it is off the ssl configuration works just like before. If ssl_sni is
enabled and pg_hosts.conf is non-empty it will take precedence over
the regular SSL GUCs, if it is empty or missing the regular GUCs will
be used just as before this commit with no hostname specific handling.
The TLS init hook is not compatible with ssl_sni since it operates on
a single TLS configuration and SNI break that assumption. If the init
hook and ssl_sni are both enabled, a WARNING will be issued.
Host configuration can either be for a literal hostname to match, non-
SNI connections using the no_sni keyword or a default fallback matching
all connections. By omitting no_sni and the fallback a strict mode
can be achieved where only connections using sslsni=1 and a specified
hostname are allowed.
CRL file(s) are applied from postgresql.conf to all configured hostnames.
Serverside SNI requires OpenSSL, currently LibreSSL does not support
the required infrastructure to update the SSL context during the TLS
handshake.
Author: Daniel Gustafsson <daniel@yesql.se>
Co-authored-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Dewei Dai <daidewei1970@163.com>
Reviewed-by: Cary Huang <cary.huang@highgo.ca>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/1C81CD0D-407E-44F9-833A-DD0331C202E5@yesql.se M configure
M configure.ac
M doc/src/sgml/runtime.sgml
M meson.build
M src/backend/Makefile
M src/backend/commands/variable.c
M src/backend/libpq/be-secure-common.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/libpq/be-secure.c
M src/backend/libpq/meson.build
A src/backend/libpq/pg_hosts.conf.sample
M src/backend/utils/misc/guc.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/initdb/initdb.c
M src/include/libpq/hba.h
M src/include/libpq/libpq.h
M src/include/pg_config.h.in
M src/include/utils/guc.h
M src/include/utils/guc_hooks.h
M src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/ssl/meson.build
M src/test/ssl/t/001_ssltests.pl
A src/test/ssl/t/004_sni.pl
M src/tools/pgindent/typedefs.list
ssl: Add tests for client CA
commit : 25e568ba7ce712c41acf7058ef14dd49d912c3ab
author : Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 18 Mar 2026 12:36:53 +0100
committer: Daniel Gustafsson <dgustafsson@postgresql.org>
date : Wed, 18 Mar 2026 12:36:53 +0100 These tests were originally written to test the SSL SNI patchset
but they have merit on their own since we lack coverage for these
scenarios in the non SNI case as well.
Author: Jacob Champion <jacob.champion@enterprisedb.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/1C81CD0D-407E-44F9-833A-DD0331C202E5@yesql.se M src/test/ssl/t/001_ssltests.pl
M src/test/ssl/t/SSL/Backend/OpenSSL.pm
meson: Add headerscheck and cpluspluscheck targets
commit : e82fc27e095b5a84c578b6e6b43b3396463bd812
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 11:25:47 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 11:25:47 +0100 Author: Miłosz Bieniek <bieniek.milosz0@gmail.com>
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAMSWrt-PoQt4sHryWrB1ViuGBJF_PpbjoSGrWR2Ry47bHNLDqg%40mail.gmail.com M doc/src/sgml/targets-meson.txt
M meson.build
M src/tools/pginclude/README
meson: Add {perl|python}_includespec to generated Makefile.global
commit : 720c9b504ec6934e93d7304e789c445dc1c09f31
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 11:09:14 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 11:09:14 +0100 This is meant to help enable headerscheck under meson, but can also be
useful in general, for example for third-party extension that might
use these values.
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAMSWrt-PoQt4sHryWrB1ViuGBJF_PpbjoSGrWR2Ry47bHNLDqg%40mail.gmail.com M meson.build
M src/makefiles/meson.build
Allow setting the collation strength in ICU tailoring rules
commit : 905e44152a1d49b90cb8d800dcaaba7981288ae2
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 08:54:35 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 18 Mar 2026 08:54:35 +0100 There was a bug that if you created an ICU collation with tailoring
rules, any strength specification inside the rules was ignored. This
was because we called ucol_openRules() with UCOL_DEFAULT_STRENGTH for
the strength argument, which overrides the strength. This was because
of faulty guidance in the ICU documentation, which has since been
fixed. The correct invocation is to use UCOL_DEFAULT for the strength
argument.
This fixes bug #18771 and bug #19425.
Author: Daniel Verite <daniel@manitou-mail.org>
Reported-by: Ruben Ruiz <ruben.ruizcuadrado@gmail.com>
Reported-by: dorian.752@live.fr
Reported-by: Todd Lang <Todd.Lang@D2L.com>
Discussion: https://www.postgresql.org/message-id/flat/YT2PPF959236618377A072745A280E278F4BE1DA@YT2PPF959236618.CANPRD01.PROD.OUTLOOK.COM
Discussion: https://www.postgresql.org/message-id/flat/18771-98bb23e455b0f367@postgresql.org
Discussion: https://www.postgresql.org/message-id/flat/19425-58915e19dacd4f40%40postgresql.org M src/backend/utils/adt/pg_locale_icu.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
Move planner row-estimation tests to new planner_est.sql
commit : 374a6394c6ae2e6f8b70ca7897e1499ff72ae7e5
author : David Rowley <drowley@postgresql.org>
date : Wed, 18 Mar 2026 17:22:05 +1300
committer: David Rowley <drowley@postgresql.org>
date : Wed, 18 Mar 2026 17:22:05 +1300 Move explain_mask_costs() and the associated planner row-estimation
tests from misc_functions.sql to a new regression test file,
planner_est.sql.
Previously, there wasn't an ideal home for such tests, likely as there
were very few such tests due to width and selectivity estimations being
too dependent on statistics and hardware. That's not always the case, as
we have SupportRequestRows support functions. More such tests are
possibly on the way, so let's create a better home so that we don't have
to create the explain_mask_costs() function in each file we might have
added such tests to.
Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvphShGABn-3AoE36dTvGHW7gUpFSw0_ZZnH84wGCW3hHw@mail.gmail.com M src/test/regress/expected/misc_functions.out
A src/test/regress/expected/planner_est.out
M src/test/regress/parallel_schedule
M src/test/regress/sql/misc_functions.sql
A src/test/regress/sql/planner_est.sql
test_plan_advice: Add .gitignore
commit : ab697307dd0f0b4f6c6671421d4dd0bc20f176cb
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 18 Mar 2026 11:04:10 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 18 Mar 2026 11:04:10 +0900 Issue noticed while playing with the tree. A src/test/modules/test_plan_advice/.gitignore
Allow IS JSON predicate to work with domain types
commit : 3b4c2b9db25ee1c51e5133da529668a37aa02fc3
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 13 Mar 2026 11:51:26 +0800
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 13 Mar 2026 11:51:26 +0800 The IS JSON predicate only accepted the base types text, json, jsonb, and
bytea. Extend it to also accept domain types over those base types by
resolving through getBaseType() during parse analysis.
The base type OID is stored in the JsonIsPredicate node (as exprBaseType)
so the executor can dispatch to the correct validation path without
repeating the domain lookup at runtime.
When a non-supported type (or domain over a non-supported type) is used,
the error message displays the original type name as written by the user,
rather than the resolved base type.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/CACJufxEk34DnJFG72CRsPPT4tsJL9arobX0tNPsn7yH28J=zQg@mail.gmail.com M src/backend/executor/execExprInterp.c
M src/backend/nodes/makefuncs.c
M src/backend/parser/gram.y
M src/backend/parser/parse_expr.c
M src/include/nodes/makefuncs.h
M src/include/nodes/primnodes.h
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/sqljson.sql
Fix use of wrong variable in _hash_kill_items()
commit : f5eb854ab6d6281ec2d3143657944bdda6676341
author : Andres Freund <andres@anarazel.de>
date : Tue, 17 Mar 2026 14:54:41 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 17 Mar 2026 14:54:41 -0400 In 82467f627bd I somehow ended up using 'so->currPos.buf' instead of the 'buf'
variable, which is incorrect when the buffer is not already pinned. At the
very least this can lead to assertion failures
Unfortunately this shows that this code path was not covered. Expand
src/test/modules/index/specs/killtuples.spec to test it. Until now the
'result' step always reported either a 0 or 1 buffer accesses, but when
exercising hash overflows, more buffers are accessed. To avoid depending on
the precise number of accesses, change the result step to return whether there
were any heap accesses. That makes the change a lot more verbose, but still
seems worth it.
Reported-by: Alexander Kuzmenkov <akuzmenkov@tigerdata.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/vjtmvwvbxt7w5uyacxpzibpj65ewcb7uqaqbhd4arvnjbp5jqz%405ksdh6fsyqve
Discussion: https://postgr.es/m/b9de8d05-3b02-4a27-9b0b-03972fa4bfd3@iki.fi M src/backend/access/hash/hashutil.c
M src/test/modules/index/expected/killtuples.out
M src/test/modules/index/specs/killtuples.spec
pg_plan_advice: Avoid a crash under GEQO.
commit : 01b02c0ecad1bb4e884614a00a5c619f20480823
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 14:25:43 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 14:25:43 -0400 The previous code could allocate pgpa_sj_unique_rel objects in a context
that had too short a lifespan. Fix by allocating them (and any
associated List-related allocations) in the same context as the
pgpa_planner_state to which they are attached. We also need to copy
uniquerel->relids, because the associated RelOptInfo may also be
allocated within a short-lived context.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: http://postgr.es/m/a6e6d603-e847-44dc-acd5-879fb4570062@gmail.com M contrib/pg_plan_advice/pgpa_planner.c
Test pg_plan_advice using a new test_plan_advice module.
commit : e0e4c132ef2b59f42b9d01872c69607983f3ef31
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 14:00:45 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 14:00:45 -0400 The TAP test included in this new module runs the regression tests
with pg_plan_advice loaded. It arranges for each query to be planned
twice. The first time, we generate plan advice. The second time, we
replan the query using the resulting advice string. If the tests
fail, that means that using pg_plan_advice to tell the planner to
do what it was going to do anyway breaks something, which indicates
a problem either with pg_plan_advice or with the planner.
The test also enables pg_plan_advice.feedback_warnings, so that if the
plan advice fails to apply cleanly when the query is replanned, a
failure will occur.
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: http://postgr.es/m/CA%2BTgmoZzM2i%2Bp-Rxdphs4qx7sshn-kzxF91ASQ5duOo0dFRXLQ%40mail.gmail.com M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_plan_advice/Makefile
A src/test/modules/test_plan_advice/meson.build
A src/test/modules/test_plan_advice/t/001_replan_regress.pl
A src/test/modules/test_plan_advice/test_plan_advice.c
pg_plan_advice: Always install pg_plan_advice.h, and in the right place
commit : 59dcc19b397f69a3654d39bae5a13f1659d922d8
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 12:36:57 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 12:36:57 -0400 The Makefile failed to set HEADERS_pg_plan_advice, so the header wasn't
installed. Fixing that reveals another problem: since this is just a
loadable module, not an extension, the header file is installed into
$(includedir_server)/contrib rather than $(includedir_server)/extension.
While we have no existing cases of installing header files there, it
appears to be the intent of pgxs.mk. However, this is inconsistent with
meson.build, which was using dir_include_extension. Changing that to
dir_include_server / 'contrib' makes the install locations consistent
across the two builds.
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: http://postgr.es/m/CAN4CZFP6NOjv__4Mx+iQD8StdpbHvzDAatEQn2n15UKJ=MySSQ@mail.gmail.com M contrib/pg_plan_advice/Makefile
M contrib/pg_plan_advice/meson.build
pg_dump: Simplify query for retrieving attribute statistics.
commit : 4b5ba0c4ca5244d0ed589f67baf0204957886e6b
author : Nathan Bossart <nathan@postgresql.org>
date : Tue, 17 Mar 2026 11:32:40 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Tue, 17 Mar 2026 11:32:40 -0500 This query fetches information from pg_stats, which did not return
table OIDs until recent commit 3b88e50d6c. Because of this, we had
to cart around arrays of schema and table names, and we needed an
extra filter clause to hopefully convince the planner to use the
correct index. With the introduction of pg_stats.tableid, we can
instead just use an array of OIDs, and we no longer need the extra
filter clause hack.
Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CADkLM%3DcoCVy92QkVUUTLdo5eO2bMDtwMrzRn_8miAhX%2BuPaqXg%40mail.gmail.com M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
Hardcode typeof_unqual to __typeof_unqual__ for clang
commit : 2eb6cd327caea42b5f29e0b16d6053c52aa08c3c
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 17 Mar 2026 16:44:43 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 17 Mar 2026 16:44:43 +0100 A new attempt was made in 63275ce84d2 to make typeof_unqual work on all
configurations of CC and CLANG. This re-introduced an old problem
though, where CLANG would only support __typeof_unqual__ but the
configure check for CC detected support for typeof_unqual.
This fixes that by always defining typeof_unqual as __typeof_unqual__
under clang.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org M src/include/c.h
pg_plan_advice: Fix variable type confusion.
commit : 7560995a38dc408ae78973728965d052ccdbdb48
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 10:20:15 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 17 Mar 2026 10:20:15 -0400 pgs_mask values should always be uint64, but in a couple of
places I incorrectly used uint32. Fix that.
Reported-by: David Rowley <dgrowleyml@gmail.com>
Discussion: http://postgr.es/m/CAApHDvquH6wnp4fhpaCOkC4R3KAvr2BOTbhhDPDQCBNR3YbLMQ@mail.gmail.com M contrib/pg_plan_advice/pgpa_planner.c
make immutability tests in to_json and to_jsonb complete
commit : ecd9288624a1582a732cf86ac5a01475a1ce7815
author : Andrew Dunstan <andrew@dunslane.net>
date : Tue, 10 Mar 2026 14:25:29 +0800
committer: Andrew Dunstan <andrew@dunslane.net>
date : Tue, 10 Mar 2026 14:25:29 +0800 Complete the TODOs in to_json_is_immutable() and to_jsonb_is_immutable()
by recursing into container types (arrays, composites, ranges, multiranges,
domains) to check element/sub-type mutability, rather than conservatively
returning "mutable" for all arrays and composites.
The shared logic is factored into a single json_check_mutability() function
in jsonfuncs.c, with the existing exported functions as thin wrappers.
Composite type inspection uses lookup_rowtype_tupdesc() (typcache) instead
of relation_open() to avoid unnecessary lock acquisition in the optimizer.
Range and multirange types are now also checked recursively: if the
subtype's conversion is immutable, the range is considered immutable
for JSON purposes, even though range_out is generically marked STABLE.
This is a behavioral change: range types with immutable subtypes (e.g.,
int4range) can now appear in expression indexes via JSON_ARRAY/JSON_OBJECT,
whereas previously they were conservatively rejected.
Add regression tests for JSON_ARRAY and JSON_OBJECT mutability with
expression indexes and generated columns, covering arrays, composites,
domains, ranges, multiranges and combinations thereof.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CACJufxFz=OsXQdsMJ-cqoqspD9aJrwntsQP-U2A-UaV_M+-S9g@mail.gmail.com
Commitfest: https://commitfest.postgresql.org/patch/5759 M src/backend/utils/adt/json.c
M src/backend/utils/adt/jsonb.c
M src/backend/utils/adt/jsonfuncs.c
M src/include/utils/jsonfuncs.h
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/sqljson.sql
Add more columns to pg_stats, pg_stats_ext, and pg_stats_ext_exprs.
commit : 3b88e50d6c2ef972748378a10fc444efae90ed14
author : Nathan Bossart <nathan@postgresql.org>
date : Tue, 17 Mar 2026 09:26:27 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Tue, 17 Mar 2026 09:26:27 -0500 This commit adds table OID and attribute number columns to
pg_stats, and it adds table OID and statistics object OID columns
to pg_stats_ext and pg_stats_ext_exprs. A proposed follow-up
commit would use pg_stats.tableid to simplify a query in pg_dump.
The others have no immediate purpose but may be useful later.
Bumps catversion.
Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CADkLM%3DcoCVy92QkVUUTLdo5eO2bMDtwMrzRn_8miAhX%2BuPaqXg%40mail.gmail.com M doc/src/sgml/system-views.sgml
M src/backend/catalog/system_views.sql
M src/include/catalog/catversion.h
M src/test/regress/expected/rules.out
M src/test/regress/expected/stats_import.out
Dump labels in reproducible order
commit : c9babbc8816a4f5d5894eda555e39ba30781322f
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 17 Mar 2026 14:06:53 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 17 Mar 2026 14:06:53 +0100 In pg_get_propgraphdef(), sort the labels before writing out, for a
consistent dump order. Also, since we now have a list, we can get rid
of the separate table scan to get the count.
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
Co-authored-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org M src/backend/utils/adt/ruleutils.c
Don't leave behind files in src dir in 007_multixact_conversion.pl
commit : 2c1a7d421f92c14c8fedbd77200607b3df554add
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 17 Mar 2026 11:24:10 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Tue, 17 Mar 2026 11:24:10 +0200 pg_upgrade test 007_multixact_conversion.pl was leaving files like
delete_old_cluster.sh in the source directory for VPATH and meson
builds. To fix, change the tmp_check directory before running the
test, like in the other pg_upgrade tests.
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
https://www.postgresql.org/message-id/TYRPR01MB121563A4DA8B2FE9A2ECB79F5F541A@TYRPR01MB12156.jpnprd01.prod.outlook.com M src/bin/pg_upgrade/t/007_multixact_conversion.pl
pg_dump: Add appropriate version check
commit : 182cdf5aeaf7b34a288a135d66f2893dc288a24e
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 17 Mar 2026 09:46:06 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 17 Mar 2026 09:46:06 +0100 Some code added by commit 2f094e7ac69 needs to be behind a version
check so that it is not run against older databases.
Author: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/afe3f099-3271-4fc4-8e32-467b5309affb%40dunslane.net M src/bin/pg_dump/pg_dump.c
gen_guc_tables.pl: Improve detection of inconsistent data
commit : 233e6ae95330eac51880b050908b1e3ac9860d9b
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 17:38:55 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 17:38:55 +0900 This commit adds two improvements to gen_guc_tables.pl:
1) When finding two entries with the same name, the script complained
about these being not in alphabetical order, which was confusing.
Duplicated entries are now reported as their own error.
2) While the presence of the required fields is checked for all the
parameters, the script did not perform any checks on the non-required
fields. A check is added to check that any field defined matches with
what can be accepted. Previously, a typo in the name of a required
field would cause the field to be reported as missing. Non-mandatory
fields would be silently ignored, which was problematic as we could lose
some information.
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAN4CZFP=3xUoXb9jpn5OWwicg+rbyrca8-tVmgJsQAa4+OExkw@mail.gmail.com M src/backend/utils/misc/gen_guc_tables.pl
Refactor some code around ALTER TABLE [NO] INHERIT
commit : 1a7ccd2b332d5fafa9bf1121c82693c9a2a57298
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 14:34:29 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 14:34:29 +0900 [NO] INHERIT is not supported for partitioned tables, but this portion
of tablecmds.c did not apply the same rules as the other sub-commands,
checking the relkind in the execution phase, not the preparation phase.
This commit refactors the code to centralize the relkind and other
checks in the preparation phase for both command patterns, getting rid
of one translatable string on the way. ATT_PARTITIONED_TABLE is
removed from ATSimplePermissions(), and the child relation is checked
the same way for both sub-commands. The ALTER TABLE patterns that now
fail at preparation failed already at execution, hence there should be
no changes from the user perspective except more consistent error
messages generated.
Some comments at the top of ATPrepAddInherit() were incorrect,
CreateInheritance() being the routine checking the columns and
constraints between the parent and its to-be-child.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAEoWx2kggo1N2kDH6OSfXHL_5gKg3DqQ0PdNuL4LH4XSTKJ3-g@mail.gmail.com M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/typed_table.out
M src/test/regress/sql/alter_table.sql
Add regression test for ALTER TABLE .. NO INHERIT on typed tables
commit : cbf9a72993ec8148cdf1925e414e0b4e27f20f2f
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 13:14:02 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 13:14:02 +0900 This test addition has come up as a suggestion by me, while discussing a
patch that manipulates the area of the code related to this command
pattern.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAEoWx2kggo1N2kDH6OSfXHL_5gKg3DqQ0PdNuL4LH4XSTKJ3-g@mail.gmail.com M src/test/regress/expected/typed_table.out
M src/test/regress/sql/typed_table.sql
Tweak TAP test for worker terminations in worker_spi
commit : af8837a10bc70d5e815a1bda986429a2a73ad174
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 12:56:46 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 17 Mar 2026 12:56:46 +0900 The test has been reported as having a race condition for the case of a
worker that should be terminated after a database rename. Based on the
report received from buildfarm member jay, the database renamed is
accessed by a different session, preventing the ALTER DATABASE to
complete, ultimately failing the test.
Honestly, I am not completely sure what is the origin of this
disturbance, but two possibilities are an autovacuum or parallel worker
(due to debug_parallel_query being used by the host). In order to
(hopefully) stabilize the test, autovacuum and debug_parallel_query are
now disabled in the configuration of the node used in the test.
The failure is hard to reproduce, so it will take a few weeks to make
sure that the test has become stable. Let's see where it goes.
Reported-by: Aya Iwata <iwata.aya@fujitsu.com>
Discussion: https://postgr.es/m/OS3PR01MB8889505E2F3E443CCA4BD72EEA45A@OS3PR01MB8889.jpnprd01.prod.outlook.com M src/test/modules/worker_spi/t/002_worker_terminate.pl
Reduce size of CompactAttribute struct to 8 bytes
commit : d8a859d22b1accd8ea749394a488e4de014b2396
author : David Rowley <drowley@postgresql.org>
date : Tue, 17 Mar 2026 15:06:31 +1300
committer: David Rowley <drowley@postgresql.org>
date : Tue, 17 Mar 2026 15:06:31 +1300 Previously, this was 16 bytes. With the use of some bitflags and by
reducing the attcacheoff field size to a 16-bit type, we can halve the
size of the struct.
It's unlikely that caching the offsets for offsets larger than what will
fit in a 16-bit int will help much as the tuple is very likely to have
some non-fixed-width types anyway, the offsets of which we cannot cache.
Shrinking this down to 8 bytes helps by accessing fewer cachelines when
performing tuple deformation. The fields used there are all fully
fledged fields, which don't require any bitmasking to extract the value
of. It also helps to more efficiently calculate the address of a
compact_attrs[] element in TupleDesc as the x86 LEA instruction can work
with 8 byte offsets, which allows the element address to be calculated
from the TupleDesc's address in a single instruction using LEA's
concurrent shift and add.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAApHDvodSVBj3ypOYbYUCJX%2BNWL%3DVZs63RNBQ_FxB_F%2B6QXF-A%40mail.gmail.com M src/backend/access/common/tupdesc.c
M src/backend/executor/execTuples.c
M src/include/access/tupdesc.h
Fix WAL flush LSN used by logical walsender during shutdown
commit : d927b4bd97c8087c26254cb29a59c8b768cc6bd7
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 17 Mar 2026 08:10:20 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 17 Mar 2026 08:10:20 +0900 Commit 6eedb2a5fd8 made the logical walsender call
XLogFlush(GetXLogInsertRecPtr()) to ensure that all pending WAL is flushed,
fixing a publisher shutdown hang. However, if the last WAL record ends at
a page boundary, GetXLogInsertRecPtr() can return an LSN pointing past
the page header, which can cause XLogFlush() to report an error.
A similar issue previously existed in the GiST code. Commit b1f14c96720
introduced GetXLogInsertEndRecPtr(), which returns a safe WAL insertion end
location (returning the start of the page when the last record ends at a page
boundary), and updated the GiST code to use it with XLogFlush().
This commit fixes the issue by making the logical walsender use
XLogFlush(GetXLogInsertEndRecPtr()) when flushing pending WAL during shutdown.
Backpatch to all supported versions.
Reported-by: Andres Freund <andres@anarazel.de>
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/vzguaguldbcyfbyuq76qj7hx5qdr5kmh67gqkncyb2yhsygrdt@dfhcpteqifux
Backpatch-through: 14 M src/backend/replication/walsender.c
Clean up postgres_fdw/t/010_subscription.pl.
commit : f4af7849b3db1c71efdafbe7a9e37c7e7f27e006
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 16 Mar 2026 13:42:55 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 16 Mar 2026 13:42:55 -0700 The test was based on test/subscription/002_rep_changes.pl, but had
some leftover copy+paste problems that were useless and/or
distracting.
Discussion: https://postgr.es/m/CAA4eK1+=V_UFNHwcoMFqzy0F4AtS9_GyXhQDUzizgieQPWr=0A@mail.gmail.com
Reported-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> M contrib/postgres_fdw/t/010_subscription.pl
Fix thinko in nocachegetattr() and nocache_index_getattr()
commit : 7a2ab122a1c555ee4298863917ce68a2b9800cb8
author : David Rowley <drowley@postgresql.org>
date : Tue, 17 Mar 2026 09:00:39 +1300
committer: David Rowley <drowley@postgresql.org>
date : Tue, 17 Mar 2026 09:00:39 +1300 This code was recently adjusted by c456e3911, but that commit didn't get
the logic correct when finding the attnum to start walking the tuple in.
If there is a NULL, we need to start walking the tuple before it.
Author: David Rowley <dgrowleyml@gmail.com>
Reported-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAHewXNnb-s_=VdVUZ9h7dPA0u3hxV8x2aU3obZytnqQZ_MiROA@mail.gmail.com M src/backend/access/common/heaptuple.c
M src/backend/access/common/indextuple.c
pg_plan_advice: Fix failures to accept identifier keywords.
commit : 5e72ce2467c15340026955b57ff75f75e853a766
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 16 Mar 2026 14:37:12 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 16 Mar 2026 14:37:12 -0400 TOK_IDENT allows only non-keywords; identifier should be used
any place where either keywords or non-keywords should be accepted.
Hence, without this commit, any string that happens to be a keyword
can't be used as a partition schema, partition name, or plan name,
which is incorrect.
Author: Lukas Fittl <lukas@fittl.com>
Discussion: http://postgr.es/m/CAP53PkzKeD=t90OfeMsniYrcRe2THQbUx3g6wV17Y=ZtiwmWTQ@mail.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 whitespace
commit : 4f888d0f9425468e74cd3f0ca6a3047fd404807b
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 19:33:13 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 19:33:13 +0100 M contrib/pg_plan_advice/expected/prepared.out
M contrib/pg_plan_advice/sql/prepared.sql
Hardcode override of typeof_unqual for clang-for-bitcode
commit : 63275ce84d2f571136b585d7493e1ec351388014
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 18:56:30 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 18:56:30 +0100 The fundamental problem is that when we call clang to generate
bitcode, we might be using configure results from a different
compiler, which might not be fully compatible with the clang we are
using. In practice, clang supports most things other compilers
support, so this has apparently not been a problem in practice.
But commits 4cfce4e62c8, 0af05b5dbb4, and 59292f7aac7 have been
struggling to make typeof_unqual work in this situation. Clang added
support in version 19, GCC in version 14, so if you are using, say,
GCC 14 and Clang 16, the compilation with the latter will fail. Such
combinations are not very likely in practice, because GCC 14 and Clang
19 were released within a few months of each other, and so Linux
distributions are likely to have suitable combinations. But some
buildfarm members and some Fedora versions are affected, so this tries
to fix it.
The fully correct solution would be to run a separate set of configure
tests for that clang-for-bitcode, but that would be very difficult to
implement, and probably of limited use in practice. So the workaround
here is that we hardcodedly override the configure result under clang
based on the version number. As long as we only have a few of these
cases, this should be manageable.
Also swap the order of the tests of typeof_unqual: Commit 59292f7aac7
tested the underscore variant first, but the reasons for that are now
gone.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org M config/c-compiler.m4
M configure
M meson.build
M src/include/c.h
pg_dumpall: Fix handling of incompatible options.
commit : be0d0b457cb605f6e539f92af5e564fbe9d65e59
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 16 Mar 2026 11:01:20 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 16 Mar 2026 11:01:20 -0500 This commit teaches pg_dumpall to fail when both --clean and
--data-only are specified. Previously, it passed the options
through to pg_dump, which would fail after pg_dumpall had already
started producing output. Like recent commits b2898baaf7 and
7c8280eeb5, no back-patch.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Discussion: https://postgr.es/m/CAKYtNArrHiJ0LDB9BFZiUWs6tC78QkBN50wiwO07WhxewYDS3Q%40mail.gmail.com M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_dump/t/001_basic.pl
Make some tests more stable by adding more explicit ordering
commit : cd8844e7db64d57554c780ec9881457c573c51ab
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 16:24:22 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 16:24:22 +0100 for some tests added by commit 2f094e7ac69, based on buildfarm results M src/test/regress/expected/create_property_graph.out
M src/test/regress/expected/graph_table.out
M src/test/regress/sql/create_property_graph.sql
M src/test/regress/sql/graph_table.sql
Reduce header inclusions via execnodes.h
commit : fba4233c832870c8363438419743c48fdcb2151c
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 16 Mar 2026 14:34:57 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 16 Mar 2026 14:34:57 +0100 Remove a bunch of #include lines from execnodes.h. Most of these
requier suitable typedefs to be added, so that it still compiles
standalone. In one case, the fix is to move a struct definition to the
one .c file where it is needed.
Also some light clean up in plannodes.h and genam.h, though not as
extensive as in execnodes.h.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/202603131240.ihwqdxnj7w2o@alvherre.pgsql M contrib/amcheck/verify_heapam.c
M contrib/dblink/dblink.c
M contrib/hstore/hstore_subs.c
M contrib/pageinspect/brinfuncs.c
M contrib/pageinspect/gistfuncs.c
M contrib/pg_buffercache/pg_buffercache_pages.c
M contrib/pg_stat_statements/pg_stat_statements.c
M contrib/pg_walinspect/pg_walinspect.c
M contrib/pgrowlocks/pgrowlocks.c
M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/postgres_fdw.c
M contrib/tablefunc/tablefunc.c
M contrib/tsm_system_time/tsm_system_time.c
M contrib/xml2/xpath.c
M src/backend/access/brin/brin.c
M src/backend/access/gin/gininsert.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/transam/xlogprefetcher.c
M src/backend/backup/walsummaryfuncs.c
M src/backend/bootstrap/bootstrap.c
M src/backend/catalog/index.c
M src/backend/commands/analyze.c
M src/backend/commands/copyfrom.c
M src/backend/commands/copyfromparse.c
M src/backend/commands/copyto.c
M src/backend/commands/event_trigger.c
M src/backend/commands/explain.c
M src/backend/commands/extension.c
M src/backend/commands/indexcmds.c
M src/backend/commands/prepare.c
M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/commands/wait.c
M src/backend/executor/execAmi.c
M src/backend/executor/execAsync.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execMain.c
M src/backend/executor/execPartition.c
M src/backend/executor/execProcnode.c
M src/backend/executor/execSRF.c
M src/backend/executor/execUtils.c
M src/backend/executor/functions.c
M src/backend/executor/nodeAgg.c
M src/backend/executor/nodeBitmapAnd.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/executor/nodeBitmapIndexscan.c
M src/backend/executor/nodeBitmapOr.c
M src/backend/executor/nodeCtescan.c
M src/backend/executor/nodeFunctionscan.c
M src/backend/executor/nodeGatherMerge.c
M src/backend/executor/nodeGroup.c
M src/backend/executor/nodeHash.c
M src/backend/executor/nodeHashjoin.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/backend/executor/nodeMaterial.c
M src/backend/executor/nodeMergeAppend.c
M src/backend/executor/nodeMergejoin.c
M src/backend/executor/nodeModifyTable.c
M src/backend/executor/nodeNamedtuplestorescan.c
M src/backend/executor/nodeNestloop.c
M src/backend/executor/nodeRecursiveunion.c
M src/backend/executor/nodeSetOp.c
M src/backend/executor/nodeTableFuncscan.c
M src/backend/executor/nodeWindowAgg.c
M src/backend/executor/nodeWorktablescan.c
M src/backend/executor/spi.c
M src/backend/foreign/foreign.c
M src/backend/jit/jit.c
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/prep/preptlist.c
M src/backend/optimizer/prep/prepunion.c
M src/backend/optimizer/util/appendinfo.c
M src/backend/optimizer/util/predtest.c
M src/backend/parser/parse_utilcmd.c
M src/backend/postmaster/autovacuum.c
M src/backend/replication/logical/worker.c
M src/backend/rewrite/rewriteGraphTable.c
M src/backend/rewrite/rewriteManip.c
M src/backend/storage/ipc/dsm_registry.c
M src/backend/storage/ipc/shmem.c
M src/backend/tcop/postgres.c
M src/backend/utils/activity/wait_event_funcs.c
M src/backend/utils/adt/acl.c
M src/backend/utils/adt/arraysubs.c
M src/backend/utils/adt/datetime.c
M src/backend/utils/adt/hbafuncs.c
M src/backend/utils/adt/json.c
M src/backend/utils/adt/jsonbsubs.c
M src/backend/utils/adt/jsonfuncs.c
M src/backend/utils/adt/mcxtfuncs.c
M src/backend/utils/adt/misc.c
M src/backend/utils/adt/pgstatfuncs.c
M src/backend/utils/adt/rangetypes.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/fmgr/fmgr.c
M src/backend/utils/init/postinit.c
M src/backend/utils/misc/guc_funcs.c
M src/backend/utils/misc/pg_config.c
M src/backend/utils/mmgr/portalmem.c
M src/backend/utils/sort/tuplestore.c
M src/include/access/genam.h
M src/include/access/gin_private.h
M src/include/bootstrap/bootstrap.h
M src/include/catalog/index.h
M src/include/commands/explain.h
M src/include/commands/explain_state.h
M src/include/executor/execScan.h
M src/include/executor/executor.h
M src/include/executor/hashjoin.h
M src/include/lib/simplehash.h
M src/include/nodes/execnodes.h
M src/include/nodes/plannodes.h
M src/pl/plperl/plperl.c
M src/pl/tcl/pltcl.c
M src/test/modules/injection_points/injection_points.c
M src/test/modules/test_custom_stats/test_custom_var_stats.c
M src/test/modules/test_ddl_deparse/test_ddl_deparse.c
M src/test/modules/test_regex/test_regex.c
Remove unstable test for pg_statio_all_sequences stats reset
commit : 57b5543bb8517c15e3179e5ed2493edbb708457f
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 21:05:13 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 21:05:13 +0900 Commit 8fe315f18d4 added the stats_reset column to pg_statio_all_sequences and
included a regression test to verify that statistics in this view are reset
correctly. However, this test caused buildfarm member crake to report
a pg_upgradeCheck failure.
The failing test assumed that the blks_read and blks_hit counters
in pg_statio_all_sequences would be zero after calling
pg_stat_reset_single_table_counters(). On crake, however, either blks_read or
blks_hit sometimes appeared as 1 during the pg_upgradeCheck test, even right
after the reset.
Since these counters may change due to concurrent activity and the test is
unstable, this commit removes the checks for blks_read and blks_hit in
pg_statio_all_sequences from the regression test.
Per buildfarm member crake.
Discussion: https://postgr.es/m/CAHGQGwFcay_tX=7HSS=N=+Yd0FLEm2GrJgwxnqHM4wvxX0B=4g@mail.gmail.com M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql
Fix pg_upgrade failure when extension_control_path is used
commit : 1e67508730eb0c98bf6eec660d0ed04368982266
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 11:52:02 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 11:52:02 +0100 When an extension is located via extension_control_path and it has a
hardcoded $libdir/ path, this is stripped by the
extension_control_path mechanism. But when pg_upgrade verifies the
extension using LOAD, this stripping does not happen, and so
pg_upgrade will fail because it cannot load the extension. To work
around that, change pg_upgrade to itself strip the prefix when it runs
its checks. A test case is also added.
Author: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
Reviewed-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/43b3691c673a8b9158f5a09f06eacc3c63e2c02d.camel%40gmail.com M src/bin/pg_upgrade/Makefile
M src/bin/pg_upgrade/function.c
M src/bin/pg_upgrade/meson.build
A src/bin/pg_upgrade/t/008_extension_control_path.pl
M src/test/modules/test_extensions/Makefile
M src/test/modules/test_extensions/meson.build
A src/test/modules/test_extensions/test_ext.c
Use C11 alignas in typedef definitions
commit : 5c2a8d272b9aa95f36355357095a2838120b0fe2
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 10:41:38 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 10:41:38 +0100 They were already using pg_attribute_aligned. This replaces that with
alignas and moves that into the required syntactic position.
Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/d7a788fa-e609-4894-a8be-2f70e135424f%40eisentraut.org M src/backend/storage/aio/method_io_uring.c
M src/include/storage/proc.h
Prevent -Wstrict-prototypes and -Wold-style-definition warnings
commit : d7ad79e5069b3649bfd973f84d89be40519f8cba
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 10:53:24 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 10:53:24 +0100 A following commit will enable -Wstrict-prototypes and -Wold-style-definition
by default. This commit fixes the warnings that those new flags will generate
before actually adding the new flags.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/13d51b20-a69c-4ac1-8546-ec4fc278064f%40eisentraut.org M src/interfaces/ecpg/test/compat_informix/intoasc.pgc
M src/interfaces/ecpg/test/compat_oracle/char_array.pgc
M src/interfaces/ecpg/test/expected/compat_informix-intoasc.c
M src/interfaces/ecpg/test/expected/compat_oracle-char_array.c
M src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
M src/interfaces/ecpg/test/expected/preproc-autoprep.c
M src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
M src/interfaces/ecpg/test/expected/sql-code100.c
M src/interfaces/ecpg/test/expected/sql-copystdout.c
M src/interfaces/ecpg/test/expected/sql-declare.c
M src/interfaces/ecpg/test/expected/sql-dyntest.c
M src/interfaces/ecpg/test/expected/sql-fetch.c
M src/interfaces/ecpg/test/expected/sql-func.c
M src/interfaces/ecpg/test/expected/sql-indicators.c
M src/interfaces/ecpg/test/expected/sql-insupd.c
M src/interfaces/ecpg/test/expected/sql-parser.c
M src/interfaces/ecpg/test/expected/sql-quote.c
M src/interfaces/ecpg/test/expected/sql-show.c
M src/interfaces/ecpg/test/expected/sql-sqljson.c
M src/interfaces/ecpg/test/expected/sql-sqljson_jsontable.c
M src/interfaces/ecpg/test/expected/thread-alloc.c
M src/interfaces/ecpg/test/expected/thread-descriptor.c
M src/interfaces/ecpg/test/expected/thread-prep.c
M src/interfaces/ecpg/test/expected/thread-thread.c
M src/interfaces/ecpg/test/expected/thread-thread_implicit.c
M src/interfaces/ecpg/test/preproc/array_of_struct.pgc
M src/interfaces/ecpg/test/preproc/autoprep.pgc
M src/interfaces/ecpg/test/preproc/pointer_to_struct.pgc
M src/interfaces/ecpg/test/sql/code100.pgc
M src/interfaces/ecpg/test/sql/copystdout.pgc
M src/interfaces/ecpg/test/sql/declare.pgc
M src/interfaces/ecpg/test/sql/dyntest.pgc
M src/interfaces/ecpg/test/sql/fetch.pgc
M src/interfaces/ecpg/test/sql/func.pgc
M src/interfaces/ecpg/test/sql/indicators.pgc
M src/interfaces/ecpg/test/sql/insupd.pgc
M src/interfaces/ecpg/test/sql/parser.pgc
M src/interfaces/ecpg/test/sql/quote.pgc
M src/interfaces/ecpg/test/sql/show.pgc
M src/interfaces/ecpg/test/sql/sqljson.pgc
M src/interfaces/ecpg/test/sql/sqljson_jsontable.pgc
M src/interfaces/ecpg/test/thread/alloc.pgc
M src/interfaces/ecpg/test/thread/descriptor.pgc
M src/interfaces/ecpg/test/thread/prep.pgc
M src/interfaces/ecpg/test/thread/thread.pgc
M src/interfaces/ecpg/test/thread/thread_implicit.pgc
M src/interfaces/libpq/test/libpq_testclient.c
SQL Property Graph Queries (SQL/PGQ)
commit : 2f094e7ac691abc9d2fe0f4dcf0feac4a6ce1d9c
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 10:14:18 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 10:14:18 +0100 Implementation of SQL property graph queries, according to SQL/PGQ
standard (ISO/IEC 9075-16:2023).
This adds:
- GRAPH_TABLE table function for graph pattern matching
- DDL commands CREATE/ALTER/DROP PROPERTY GRAPH
- several new system catalogs and information schema views
- psql \dG command
- pg_get_propgraphdef() function for pg_dump and psql
A property graph is a relation with a new relkind RELKIND_PROPGRAPH.
It acts like a view in many ways. It is rewritten to a standard
relational query in the rewriter. Access privileges act similar to a
security invoker view. (The security definer variant is not currently
implemented.)
Starting documentation can be found in doc/src/sgml/ddl.sgml and
doc/src/sgml/queries.sgml.
Author: Peter Eisentraut <peter@eisentraut.org>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Ajay Pal <ajay.pal.k@gmail.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org 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
A doc/src/sgml/keywords/sql2023-16-nonreserved.txt
A 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
A doc/src/sgml/ref/alter_property_graph.sgml
M doc/src/sgml/ref/comment.sgml
A doc/src/sgml/ref/create_property_graph.sgml
A 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/security_label.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/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
A 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
A 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
A 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
A src/include/catalog/pg_propgraph_element.h
A src/include/catalog/pg_propgraph_element_label.h
A src/include/catalog/pg_propgraph_label.h
A src/include/catalog/pg_propgraph_label_property.h
A src/include/catalog/pg_propgraph_property.h
A 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
A src/include/parser/parse_graphtable.h
M src/include/parser/parse_node.h
M src/include/parser/parse_relation.h
A 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
A src/interfaces/ecpg/test/expected/sql-sqlpgq.c
A src/interfaces/ecpg/test/expected/sql-sqlpgq.stderr
A 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
A src/interfaces/ecpg/test/sql/sqlpgq.pgc
M src/test/regress/expected/alter_generic.out
A src/test/regress/expected/create_property_graph.out
A src/test/regress/expected/graph_table.out
A 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
A src/test/regress/sql/create_property_graph.sql
A src/test/regress/sql/graph_table.sql
A 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
Ensure "still waiting on lock" message is logged only once per wait.
commit : fd6ecbfa75ff0316f17c75d3931f20eb4f6e1231
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 18:10:57 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 18:10:57 +0900 When log_lock_waits is enabled, the "still waiting on lock" message is normally
emitted only once while a session continues waiting. However, if the wait is
interrupted, for example by wakeups from client_connection_check_interval,
SIGHUP for configuration reloads, or similar events, the message could be
emitted again each time the wait resumes.
For example, with very small client_connection_check_interval values
(e.g., 100 ms), this behavior could flood the logs with repeated messages,
making them difficult to use.
To prevent this, this commit guards the "still waiting on lock" message so
it is reported at most once during a lock wait, even if the wait is interrupted.
This preserves the intended behavior when no interrupts occur.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Hüseyin Demir <huseyin.d3r@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHZUmg+r4kMcPYt_Z-txxVX+CJJhfra+qemxKXvAxYbpw@mail.gmail.com M src/backend/storage/lmgr/proc.c
Reject ALTER TABLE .. CLUSTER earlier for partitioned tables
commit : c336133c65a7ac3223a3cb492b8bbf4fa3999375
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 16 Mar 2026 17:48:39 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 16 Mar 2026 17:48:39 +0900 ALTER TABLE .. CLUSTER ON and SET WITHOUT CLUSTER are not supported for
partitioned tables and already fail with a check happening when the
sub-command is executed, not when it is prepared.
This commit moves the relkind check for partitioned tables to happen
when the sub-command is prepared in ATSimplePermissions(). This matches
with the practice of the other sub-commands of ALTER TABLE, shaving one
translatable string.
mark_index_clustered() can be a bit simplified, switching one
elog(ERROR) to an assertion. Note that mark_index_clustered() can also
be called through a CLUSTER command, but it cannot be reached for a
partitioned table, per the assertion based on the relkind in
cluster_rel(), and there is only one caller of rebuild_relation().
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAEoWx2kggo1N2kDH6OSfXHL_5gKg3DqQ0PdNuL4LH4XSTKJ3-g@mail.gmail.com M src/backend/commands/cluster.c
M src/backend/commands/tablecmds.c
M src/test/regress/expected/cluster.out
Add stats_reset column to pg_statio_all_sequences
commit : 8fe315f18d4181d37385c8e62ea3009084ba303a
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 17:24:08 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 17:24:08 +0900 pg_statio_all_sequences lacked a stats_reset column, unlike the other
pg_statio_* views that already expose it. This commit adds the column so
users can see when the statistics in this view were last reset.
Also this commit updates the documentation for
pg_stat_reset_single_table_counters() to clarify that it can reset statistics
for sequences and materialized views as well.
Catalog version bumped.
Author: Sami Imseih <samimseih@gmail.com>
Co-authored-by: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0v0OPGyDpwxkX81CtTt9xsj9-TNxhm=8JdOvEKPsVVFNg@mail.gmail.com M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/include/catalog/catversion.h
M src/test/regress/expected/rules.out
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql
Fix accidentally casting away const
commit : a41bc38439a1929a741eb6f1d40ed9eb30d9a8d7
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 07:37:03 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 16 Mar 2026 07:37:03 +0100 Recently introduced in commit 8c2b30487cc. M src/backend/parser/analyze.c
Remove obsolete speculative insert cleanup in ReorderBuffer.
commit : 5f39698c9028554850fca6d3f764449c0da76d99
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 16 Mar 2026 10:14:22 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 16 Mar 2026 10:14:22 +0530 Commit 4daa140a2f introduced proper decoding for speculative aborts. As a
result, the internal state is guaranteed to be clean when a new
speculative insert is encountered. This patch removes the defensive
cleanup code that is no longer reachable.
Author: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/23256.1772702981@localhost M src/backend/replication/logical/reorderbuffer.c
file_fdw: Add regression test for file_fdw with ON_ERROR='set_null'
commit : d8879d34b9dd651080a4994b58fd7eb0e5049252
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 12:13:11 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 16 Mar 2026 12:13:11 +0900 Commit 2a525cc97e1 introduced the ON_ERROR = 'set_null' option for COPY,
allowing it to be used with foreign tables backed by file_fdw. However,
unlike ON_ERROR = 'ignore', no regression test was added to verify
this behavior for file_fdw.
This commit adds a regression test to ensure that foreign tables using
file_fdw work correctly with ON_ERROR = 'set_null', improving test coverage.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Yi Ding <dingyi_yale@163.com>
Discussion: https://postgr.es/m/CAHGQGwGmPc6aHpA5=WxKreiDePiOEitfOFsW2dSo5m81xWXgRA@mail.gmail.com M contrib/file_fdw/expected/file_fdw.out
M contrib/file_fdw/sql/file_fdw.sql
Optimize hash index bulk-deletion with streaming read
commit : bfa3c4f106b1fb858ead1c8f05332f09d34f664a
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 16 Mar 2026 09:22:09 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 16 Mar 2026 09:22:09 +0900 This commit refactors hashbulkdelete() to use streaming reads, improving
the efficiency of the operation by prefetching upcoming buckets while
processing a current bucket. There are some specific changes required
to make sure that the cleanup work happens in accordance to the data
pushed to the stream read callback. When the cached metadata page is
refreshed to be able to process the next set of buckets, the stream is
reset and the data fed to the stream read callback has to be updated.
The reset needs to happen in two code paths, when _hash_getcachedmetap()
is called.
The author has seen better performance numbers than myself on this one
(with tweaks similar to 6c228755add8). The numbers are good enough for
both of us that this change is worth doing, in terms of IO and runtime.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VrqfbcDXqGrdLQ2xaQ=K0RzExNuw6U_GGqzSJu32wfdQ@mail.gmail.com M src/backend/access/hash/hash.c
M src/tools/pgindent/typedefs.list
Move -ffast-math defense to float.c and remove the configure check.
commit : 82ff54377e557914d975d22c4847d98d0efa1dac
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 19:34:52 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 19:34:52 -0400 We had defenses against -ffast-math in timestamp-related files,
which is a pretty obsolete place for them since we've not supported
floating-point timestamps in a long time. Remove those and instead
put one in float.c, which is still broken by using this switch.
Add some commentary to put more color on why it's a bad idea.
Also remove the check from configure. That was just there to fail
faster, but it doesn't really seem necessary anymore, and besides
we have no corresponding check in meson.build.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/abFXfKC8zR0Oclon%40ip-10-97-1-34.eu-west-3.compute.internal M configure
M configure.ac
M src/backend/utils/adt/date.c
M src/backend/utils/adt/float.c
M src/backend/utils/adt/timestamp.c
M src/interfaces/ecpg/pgtypeslib/interval.c
M src/interfaces/ecpg/pgtypeslib/timestamp.c
Be more careful about int vs. Oid in ecpglib.
commit : c675d80d7221411689d0f8ab18386d2f517eed0c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 18:55:37 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 18:55:37 -0400 Print an OID value inserted into a SQL query with %u not %d.
The existing code accidentally fails to malfunction when
given an OID above 2^31, but only accidentally; future changes
to our SQL parser could perhaps break it.
Declare the Oid values that ecpg_type_infocache_push() and
ecpg_is_type_an_array() work with as "Oid" not "int".
This doesn't have any functional effect, but it's clearer.
At the moment I don't see a need to back-patch this.
Bug: #19429
Author: fairyfar@msn.com
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19429-aead3b1874be1a99@postgresql.org M src/interfaces/ecpg/ecpglib/ecpglib_extern.h
M src/interfaces/ecpg/ecpglib/execute.c
Optimize tuple deformation
commit : c456e39113809376f6604e720910ccd24e18e034
author : David Rowley <drowley@postgresql.org>
date : Mon, 16 Mar 2026 11:46:00 +1300
committer: David Rowley <drowley@postgresql.org>
date : Mon, 16 Mar 2026 11:46:00 +1300 This commit includes various optimizations to improve the performance of
tuple deformation.
We now precalculate CompactAttribute's attcacheoff, which allows us to
remove the code from the deform routines which was setting the
attcacheoff. Setting the attcacheoff is now handled by
TupleDescFinalize(), which must be called before the TupleDesc is used for
anything. Having TupleDescFinalize() means we can store the first
attribute in the TupleDesc which does not have an offset cached. That
allows us to add a dedicated deforming loop to deform all attributes up
to the final one with an attcacheoff set, or up to the first NULL
attribute, whichever comes first.
Here we also improve tuple deformation performance of tuples with NULLs.
Previously, if the HEAP_HASNULL bit was set in the tuple's t_infomask,
deforming would, one-by-one, check each and every bit in the NULL bitmap
to see if it was zero. Now, we process the NULL bitmap 1 byte at a time
rather than 1 bit at a time to find the attnum with the first NULL. We
can now deform the tuple without checking for NULLs up to just before that
attribute.
We also record the maximum attribute number which is guaranteed to exist
in the tuple, that is, has a NOT NULL constraint and isn't an
atthasmissing attribute. When deforming only attributes prior to the
guaranteed attnum, we've no need to access the tuple's natt count. As an
additional optimization, we only count fixed-width columns when
calculating the maximum guaranteed column, as this eliminates the need to
emit code to fetch byref types in the deformation loop for guaranteed
attributes.
Some locations in the code deform tuples that have yet to go through NOT
NULL constraint validation. We're unable to perform the guaranteed
attribute optimization when that's the case. This optimization is opt-in
via the TupleTableSlot using the TTS_FLAG_OBEYS_NOT_NULL_CONSTRAINTS
flag.
This commit also adds a more efficient way of populating the isnull
array by using a bit-wise SWAR trick which performs multiplication on the
inverse of the tuple's bitmap byte and masking out all but the lower bit
of each of the boolean's byte. This results in much more optimal code
when compared to determining the NULLness via att_isnull(). 8 isnull
elements are processed at once using this method, which means we need to
round the tts_isnull array size up to the next 8 bytes. The palloc code
does this anyway, but the round-up needed to be formalized so as not to
overwrite the sentinel byte in MEMORY_CONTEXT_CHECKING builds. Doing
this also allows the NULL-checking deforming loop to more efficiently
check the isnull array, rather than doing the bit-wise processing for each
attribute that att_isnull() does.
The level of performance improvement from these changes seems to vary
depending on the CPU architecture. Apple's M chips seem particularly
fond of the changes, with some of the tested deform-heavy queries going
over twice as fast as before. With x86-64, the speedups aren't quite as
large. With tables containing only a small number of columns, the
speedups will be less.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CAApHDvpoFjaj3%2Bw_jD5uPnGazaw41A71tVJokLDJg2zfcigpMQ%40mail.gmail.com M src/backend/access/common/heaptuple.c
M src/backend/access/common/indextuple.c
M src/backend/access/common/tupdesc.c
M src/backend/access/spgist/spgutils.c
M src/backend/executor/execMain.c
M src/backend/executor/execTuples.c
M src/backend/executor/execUtils.c
M src/backend/executor/nodeAgg.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/executor/nodeCtescan.c
M src/backend/executor/nodeCustom.c
M src/backend/executor/nodeForeignscan.c
M src/backend/executor/nodeFunctionscan.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/backend/executor/nodeNamedtuplestorescan.c
M src/backend/executor/nodeSamplescan.c
M src/backend/executor/nodeSeqscan.c
M src/backend/executor/nodeSubqueryscan.c
M src/backend/executor/nodeTableFuncscan.c
M src/backend/executor/nodeTidrangescan.c
M src/backend/executor/nodeTidscan.c
M src/backend/executor/nodeValuesscan.c
M src/backend/executor/nodeWorktablescan.c
M src/backend/jit/llvm/llvmjit_deform.c
M src/backend/replication/pgoutput/pgoutput.c
M src/backend/utils/cache/relcache.c
M src/include/access/tupdesc.h
M src/include/access/tupmacs.h
M src/include/executor/executor.h
M src/include/executor/tuptable.h
Add all required calls to TupleDescFinalize()
commit : 503620311e3fc127708b00d4cd7eff6fd3154753
author : David Rowley <drowley@postgresql.org>
date : Mon, 16 Mar 2026 11:45:49 +1300
committer: David Rowley <drowley@postgresql.org>
date : Mon, 16 Mar 2026 11:45:49 +1300 As of this commit all TupleDescs must have TupleDescFinalize() called on
them once the TupleDesc is set up and before BlessTupleDesc() is called.
In this commit, TupleDescFinalize() does nothing. This change has only
been separated out from the commit that properly implements this function
to make the change more obvious. Any extension which makes its own
TupleDesc will need to be modified to call the new function.
The follow-up commit which properly implements TupleDescFinalize() will
cause any code which forgets to do this to fail in assert-enabled builds in
BlessTupleDesc(). It may still be worth mentioning this change in the
release notes so that extension authors update their code.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CAApHDvpoFjaj3%2Bw_jD5uPnGazaw41A71tVJokLDJg2zfcigpMQ%40mail.gmail.com M contrib/dblink/dblink.c
M contrib/pg_buffercache/pg_buffercache_pages.c
M contrib/pg_visibility/pg_visibility.c
M src/backend/access/brin/brin_tuple.c
M src/backend/access/common/tupdesc.c
M src/backend/access/gin/ginutil.c
M src/backend/access/gist/gistscan.c
M src/backend/access/spgist/spgutils.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xlogfuncs.c
M src/backend/backup/basebackup_copy.c
M src/backend/catalog/index.c
M src/backend/catalog/pg_publication.c
M src/backend/catalog/toasting.c
M src/backend/commands/explain.c
M src/backend/commands/functioncmds.c
M src/backend/commands/sequence.c
M src/backend/commands/tablecmds.c
M src/backend/commands/wait.c
M src/backend/executor/execSRF.c
M src/backend/executor/execTuples.c
M src/backend/executor/nodeFunctionscan.c
M src/backend/parser/parse_relation.c
M src/backend/parser/parse_target.c
M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/backend/replication/walsender.c
M src/backend/utils/adt/acl.c
M src/backend/utils/adt/genfile.c
M src/backend/utils/adt/lockfuncs.c
M src/backend/utils/adt/orderedsetaggs.c
M src/backend/utils/adt/pgstatfuncs.c
M src/backend/utils/adt/tsvector_op.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/fmgr/funcapi.c
M src/backend/utils/misc/guc_funcs.c
M src/include/access/tupdesc.h
M src/pl/plpgsql/src/pl_comp.c
M src/test/modules/test_custom_stats/test_custom_fixed_stats.c
M src/test/modules/test_predtest/test_predtest.c
Save a few bytes per CatCTup.
commit : e5a77d876dbb6168e3013d32198794c535f1627d
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 18:05:38 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 18:05:38 -0400 CatalogCacheCreateEntry() computed the space needed for a CatCTup
as sizeof(CatCTup) + MAXIMUM_ALIGNOF. That's not our usual style,
and it wastes memory by allocating more padding than necessary.
On 64-bit machines sizeof(CatCTup) would be maxaligned already
since it contains pointer fields, therefore this code is wasting
8 bytes compared to the more usual MAXALIGN(sizeof(CatCTup)).
While at it, we don't really need to do MemoryContextSwitchTo()
when we're only allocating one block.
Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/tencent_A42E0544C6184FE940CD8E3B14A3F0A39605@qq.com M src/backend/utils/cache/catcache.c
Fix small memory leak in get_dbname_oid_list_from_mfile().
commit : bb53b8d359d33f10b6274be743c42f6e8ecfbb84
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 15:24:04 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 15 Mar 2026 15:24:04 -0400 Coverity complained that this function leaked the dumpdirpath string,
which it did. But we don't need to make a copy at all, because
there's not really any point in trimming trailing slashes from the
directory name here. If that were needed, the initial
file_exists_in_directory() test would have failed, since it doesn't
bother with that (and neither does anyplace else in this file).
Moreover, if we did want that, reimplementing canonicalize_path()
poorly is not the way to proceed. Arguably, all of this code should
be reexamined with an eye to using src/port/path.c's facilities, but
for today I'll settle for getting rid of the memory leak. M src/bin/pg_dump/pg_restore.c
pg_restore: Remove dead code in restore_all_databases()
commit : a793677e57bc27c674cb94b230164b2c28f4cbae
author : Andrew Dunstan <andrew@dunslane.net>
date : Sun, 15 Mar 2026 12:09:36 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sun, 15 Mar 2026 12:09:36 -0400 Cleanup from commit 763aaa06f03.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Discussion: https://postgr.es/m/CAKYtNAqN49Hqd4v0wWH3uW6d6QsH+8e8bR_MVf4CboTZSzd+Aw@mail.gmail.com M src/bin/pg_dump/pg_restore.c
Save vmbuffer in heap-specific scan descriptors for on-access pruning
commit : 99bf1f8aa6cd8029cb9ce17d4a804eed386bec97
author : Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 15 Mar 2026 11:09:10 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 15 Mar 2026 11:09:10 -0400 Future commits will use the visibility map in on-access pruning to fix
VM corruption and set the VM if the page is all-visible.
Saving the vmbuffer in the scan descriptor reduces the number of times
it would need to be pinned and unpinned, making the overhead of doing so
negligible.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/C3AB3F5B-626E-4AAA-9529-23E9A20C727F%40gmail.com M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_handler.c
M src/backend/access/heap/pruneheap.c
M src/include/access/heapam.h
Avoid BufferGetPage() calls in heap_update()
commit : 8d2c1df4f4c54d0a73fcabaf5e25bc55ce7fb5fa
author : Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 15 Mar 2026 10:42:34 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 15 Mar 2026 10:42:34 -0400 BufferGetPage() isn't cheap and heap_update() calls it multiple times
when it could just save the page from a single call. Do that.
While we are at it, make separate variables for old and new page in
heap_xlog_update(). It's confusing to reuse "page" for both pages.
Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/CAAKRu_a%2BhO4PCptyaPR7AMZd7FjcHfOFKKJT8ouU3KedMud0tQ%40mail.gmail.com M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_xlog.c
Initialize missing fields in CreateExecutorState()
commit : a3511443e5e1cb59bae86d0757aa727dda099704
author : Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 15 Mar 2026 10:12:16 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Sun, 15 Mar 2026 10:12:16 -0400 d47cbf474ec and cbc127917e0 forgot to initialize a few fields they
introduced in the EState, so do that now.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/F5CDD1B5-628C-44A1-9F85-3958C626F6A9%40gmail.com M src/backend/executor/execUtils.c
Make typeof and typeof_unqual fallback definitions work on C++11
commit : cd083b54bd675a6c941b2d52f398cebbf95b060f
author : Peter Eisentraut <peter@eisentraut.org>
date : Sun, 15 Mar 2026 07:36:27 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Sun, 15 Mar 2026 07:36:27 +0100 These macros were unintentionally using C++14 features. This replaces
them with valid C++11 code.
Tested locally by compiling with -std=c++11 (which reproduced the
original issue).
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org M src/include/c.h
Switch the semaphore API on Solaris to unnamed POSIX.
commit : 0123ce131fca454009439dfa3b2266d1d40737d7
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sat, 14 Mar 2026 14:10:32 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sat, 14 Mar 2026 14:10:32 -0400 Solaris descendants (Illumos, OpenIndiana, OmniOS, etc.) hit System V
semaphore limits ("No space left on device" from semget) when running
many parallel test scripts under default system settings. We could
tell people to raise those settings, but there's a better answer.
Unnamed POSIX semaphores have been available on Solaris for decades
and work well, so prefer them, as was recently done for AIX.
This patch also updates the documentation to remove now-unnecessary
advice about raising project.max-sem-ids and project.max-msg-ids.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/470305.1772417108@sss.pgh.pa.us M doc/src/sgml/runtime.sgml
M meson.build
M src/template/solaris
Fix aclitemout() to work during early bootstrap.
commit : 2eb87345e18e18395bc5051f72c9f4ca30d70c38
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sat, 14 Mar 2026 13:46:54 -0400
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sat, 14 Mar 2026 13:46:54 -0400 "initdb -d" has been broken since commit f95d73ed4, because I changed
aclitemin to work in bootstrap mode but failed to consider aclitemout.
That routine isn't reached by default, but it is if the elog message
level is high enough, so it needs to work without catalog access too.
This patch just makes it use its existing code paths to print role
OIDs numerically. We could alternatively invent an inverse of
boot_get_role_oid() and print them symbolically, but that would take
more code and it's not apparent that it'd be any better for debugging
purposes.
Reported-by: Greg Burd <greg@burd.me>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/4416.1773328045@sss.pgh.pa.us M src/backend/utils/adt/acl.c
Tighten asserts on ParallelWorkerNumber
commit : 02eecead8678a9afe6047d42692f752e3ec0639c
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Sat, 14 Mar 2026 15:24:37 +0100
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Sat, 14 Mar 2026 15:24:37 +0100 The comment about ParallelWorkerNumbr in parallel.c says:
In parallel workers, it will be set to a value >= 0 and < the number
of workers before any user code is invoked; each parallel worker will
get a different parallel worker number.
However asserts in various places collecting instrumentation allowed
(ParallelWorkerNumber == num_workers). That would be a bug, as the value
is used as index into an array with num_workers entries.
Fixed by adjusting the asserts accordingly. Backpatch to all supported
versions.
Discussion: https://postgr.es/m/5db067a1-2cdf-4afb-a577-a04f30b69167@vondra.me
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Backpatch-through: 14 M src/backend/executor/nodeAgg.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/executor/nodeBitmapIndexscan.c
M src/backend/executor/nodeIncrementalSort.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeIndexscan.c
M src/backend/executor/nodeMemoize.c
M src/backend/executor/nodeSort.c
pgstattuple: Optimize pgstattuple_approx() with streaming read
commit : ae58189a4d523f0156ebe30f4534180555669e88
author : Michael Paquier <michael@paquier.xyz>
date : Sat, 14 Mar 2026 15:06:13 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sat, 14 Mar 2026 15:06:13 +0900 This commit plugs into pgstattuple_approx(), the SQL function faster
than pgstattuple() that returns approximate results, the streaming read
APIs. A callback is used to be able to skip all-visible pages via VM
lookup, to match with the logic prior to this commit.
Under test conditions similar to 6c228755add8 (some dm_delay and
debug_io_direct=data), this can substantially improve the execution time
of the function, particularly for large relations.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VrqfbcDXqGrdLQ2xaQ=K0RzExNuw6U_GGqzSJu32wfdQ@mail.gmail.com M contrib/pgstattuple/pgstatapprox.c
M src/tools/pgindent/typedefs.list
Allow sibling call optimization in slot_getsomeattrs_int()
commit : 4deecb52affa4b6f791e8a57f6584610e4dd12f4
author : David Rowley <drowley@postgresql.org>
date : Sat, 14 Mar 2026 13:52:09 +1300
committer: David Rowley <drowley@postgresql.org>
date : Sat, 14 Mar 2026 13:52:09 +1300 This changes the TupleTableSlotOps contract to make it so the
getsomeattrs() function is in charge of calling
slot_getmissingattrs().
Since this removes all code from slot_getsomeattrs_int() aside from the
getsomeattrs() call itself, we may as well adjust slot_getsomeattrs() so
that it calls getsomeattrs() directly. We leave slot_getsomeattrs_int()
intact as this is still called from the JIT code.
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAApHDvodSVBj3ypOYbYUCJX%2BNWL%3DVZs63RNBQ_FxB_F%2B6QXF-A%40mail.gmail.com M src/backend/executor/execTuples.c
M src/include/executor/tuptable.h
Use fake LSNs to improve nbtree dropPin behavior.
commit : 8a879119a1d12ff0a410fe3b64ad15069c3a377c
author : Peter Geoghegan <pg@bowt.ie>
date : Fri, 13 Mar 2026 20:37:39 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Fri, 13 Mar 2026 20:37:39 -0400 Use fake LSNs in all nbtree critical sections that write a WAL record.
That way we can safely apply the _bt_killitems LSN trick with logged and
unlogged indexes alike. This brings the same benefits to plain scans of
unlogged relations that commit 2ed5b87f brought to plain scans of logged
relations: scans will drop their leaf page pin eagerly (by applying the
"dropPin" optimization), which avoids blocking progress by VACUUM. This
is particularly helpful with applications that allow a scrollable cursor
to remain idle for long periods.
Preparation for an upcoming commit that will add the amgetbatch
interface, and switch nbtree over to it (from amgettuple) to enable I/O
prefetching. The index prefetching read stream's effective prefetch
distance is adversely affected by any buffer pins held by the index AM.
At the same time, it can be useful for prefetching to read dozens of
leaf pages ahead of the scan to maintain an adequate prefetch distance.
The index prefetching patch avoids this tension by always eagerly
dropping index page pins of the kind traditionally held as an interlock
against unsafe concurrent TID recycling by VACUUM (essentially the same
way that amgetbitmap routines have always avoided holding onto pins).
The work from this commit makes that possible during scans of nbtree
unlogged indexes -- without our having to give up on setting LP_DEAD
bits on index tuples altogether.
Follow-up to commit d774072f, which moved the fake LSN infrastructure
out of GiST so that it could be used by other index AMs.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Reviewed-By: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAH2-WzkehuhxyuA8quc7rRN3EtNXpiKsjPfO8mhb+0Dr2K0Dtg@mail.gmail.com M src/backend/access/nbtree/README
M src/backend/access/nbtree/nbtdedup.c
M src/backend/access/nbtree/nbtinsert.c
M src/backend/access/nbtree/nbtpage.c
M src/backend/access/nbtree/nbtree.c
M src/backend/access/nbtree/nbtsearch.c
M src/backend/access/nbtree/nbtutils.c
Move fake LSN infrastructure out of GiST.
commit : d774072f0040f9acf148cc9740b79857fbde7042
author : Peter Geoghegan <pg@bowt.ie>
date : Fri, 13 Mar 2026 19:38:17 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Fri, 13 Mar 2026 19:38:17 -0400 Move utility functions used by GiST to generate fake LSNs into xlog.c
and xloginsert.c, so that other index AMs can also generate fake LSNs.
Preparation for an upcoming commit that will add support for fake LSNs
to nbtree, allowing its dropPin optimization to be used during scans of
unlogged relations. That commit is itself preparation for another
upcoming commit that will add a new amgetbatch/btgetbatch interface to
enable I/O prefetching.
Bump XLOG_PAGE_MAGIC due to XLOG_GIST_ASSIGN_LSN becoming
XLOG_ASSIGN_LSN.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Andres Freund <andres@anarazel.de>
Reviewed-By: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAH2-WzkehuhxyuA8quc7rRN3EtNXpiKsjPfO8mhb+0Dr2K0Dtg@mail.gmail.com M src/backend/access/gist/gist.c
M src/backend/access/gist/gistutil.c
M src/backend/access/gist/gistvacuum.c
M src/backend/access/gist/gistxlog.c
M src/backend/access/rmgrdesc/gistdesc.c
M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xloginsert.c
M src/backend/storage/buffer/bufmgr.c
M src/include/access/gist_private.h
M src/include/access/gistxlog.h
M src/include/access/xlog.h
M src/include/access/xlog_internal.h
M src/include/access/xloginsert.h
M src/include/catalog/pg_control.h
Add error code to user-visible message.
commit : 9b860373da5e2d05010e15ca697c8a11c5c0a395
author : Jeff Davis <jdavis@postgresql.org>
date : Fri, 13 Mar 2026 16:07:54 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Fri, 13 Mar 2026 16:07:54 -0700 Reported-by: Alexander Lakhin <exclusion@gmail.com> M src/backend/foreign/foreign.c
Use GetXLogInsertEndRecPtr in gistGetFakeLSN
commit : b1f14c9672026a647b826455f03552ca30846e48
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Fri, 13 Mar 2026 22:42:29 +0100
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Fri, 13 Mar 2026 22:42:29 +0100 The function used GetXLogInsertRecPtr() to generate the fake LSN. Most
of the time this is the same as what XLogInsert() would return, and so
it works fine with the XLogFlush() call. But if the last record ends at
a page boundary, GetXLogInsertRecPtr() returns LSN pointing after the
page header. In such case XLogFlush() fails with errors like this:
ERROR: xlog flush request 0/01BD2018 is not satisfied --- flushed only to 0/01BD2000
Such failures are very hard to trigger, particularly outside aggressive
test scenarios.
Fixed by introducing GetXLogInsertEndRecPtr(), returning the correct LSN
without skipping the header. This is the same as GetXLogInsertRecPtr(),
except that it calls XLogBytePosToEndRecPtr().
Initial investigation by me, root cause identified by Andres Freund.
This is a long-standing bug in gistGetFakeLSN(), probably introduced by
c6b92041d38 in PG13. Backpatch to all supported versions.
Reported-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/vf4hbwrotvhbgcnknrqmfbqlu75oyjkmausvy66ic7x7vuhafx@e4rvwavtjswo
Backpatch-through: 14 M src/backend/access/gist/gistutil.c
M src/backend/access/transam/xlog.c
M src/include/access/xlog.h
Free memory allocated for unrecognized_protocol_options
commit : 311a851436cb39145baff61a2936c5d327b040e3
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 23:37:19 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 23:37:19 +0200 Since 4966bd3ed95e Valgrind started to warn about little amount of
memory being leaked in ProcessStartupPacket(). This is not critical
but the warnings may distract from real issues. Fix it by freeing the
list after use.
Author: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://www.postgresql.org/message-id/CAJ7c6TN3Hbb5p=UHx0SPVN+h_JwPAV6rxoqOm7gHBMFKfnGK-Q@mail.gmail.com M src/backend/tcop/backend_startup.c
Add convenience view to stats import test.
commit : 233bbdf031e4832a409e3028b45d709e7ddb93c9
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 15:04:10 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 15:04:10 -0500 Presently, many statements in stats_import.sql select all columns
from the pg_stats system view. A proposed follow-up commit would
add columns to this view (some of which are not stable across test
runs), breaking all of these tests. This commit introduces a
convenience view for those statements so that future changes are
minimally disruptive.
Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CADkLM%3DcoCVy92QkVUUTLdo5eO2bMDtwMrzRn_8miAhX%2BuPaqXg%40mail.gmail.com M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql
Fix bug due to confusion about what IsMVCCSnapshot means
commit : ce5d489166e5c8437aa1a35f462f67f1aeae87d4
author : Andres Freund <andres@anarazel.de>
date : Fri, 13 Mar 2026 12:11:05 -0400
committer: Andres Freund <andres@anarazel.de>
date : Fri, 13 Mar 2026 12:11:05 -0400 In 0b96e734c59 I (Andres) relied on page_collect_tuples() being called only
with an MVCC snapshot, and added assertions to that end, but did not realize
that IsMVCCSnapshot() allows both proper MVCC snapshots and historical
snapshots, which behave quite similarly to MVCC snapshots.
Unfortunately that can lead to incorrect visibility results during logical
decoding, as a historical snapshot is interpreted as a plain MVCC
snapshot. The only reason this wasn't noticed earlier is that it's hard to
reach as most of the time there are no sequential scans during logical
decoding.
To fix the bug and avoid issues like this in the future, split
IsMVCCSnapshot() into IsMVCCSnapshot() and IsMVCCLikeSnapshot(), where now
only the latter includes historic snapshots.
One effect of this is that during logical decoding no page-at-a-time snapshots
are used, as otherwise runtime branches to handle historic snapshots would be
needed in some performance critical paths. Given how uncommon sequential scans
are during logical decoding, that seems acceptable.
Author: Antonin Houska <ah@cybertec.at>
Reported-by: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/61812.1770637345@localhost M src/backend/access/heap/heapam_handler.c
M src/backend/access/index/indexam.c
M src/backend/access/nbtree/nbtree.c
M src/include/utils/snapmgr.h
libpq-oauth: Fix Makefile dependencies
commit : b634c4e0e8f47186c664f7141e8ab0b73c50eb0c
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 13 Mar 2026 10:34:03 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 13 Mar 2026 10:34:03 -0700 As part of 6225403f2, I'd removed the override for the `stlib` target,
since NAME no longer contains a major version number. But I forgot that
its dependencies are declared before Makefile.shlib is included; those
dependencies were then omitted entirely.
Per buildfarm member indri, which appears to be the only system so far
that's bothered by an empty archive. M src/interfaces/libpq-oauth/Makefile
Add commit b6eb8dde6b to .git-blame-ignore-revs.
commit : 1c33a2d81db16212754845691817e22cd3501cb6
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 11:45:34 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 11:45:34 -0500 M .git-blame-ignore-revs
libpq-oauth: Never link against libpq's encoding functions
commit : dba35604485feff679893f22a79e8c0f3ee6fc0e
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 13 Mar 2026 09:38:04 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 13 Mar 2026 09:38:04 -0700 Now that libpq-oauth doesn't have to match the major version of libpq,
some things in pg_wchar.h are technically unsafe for us to use. (See
b6c7cfac8 for a fuller discussion.) This is unlikely to be a problem --
we only care about UTF-8 in the context of OAuth right now -- but if
anyone did introduce a way to hit it, it'd be extremely difficult to
debug or reproduce, and it'd be a potential security vulnerability to
boot.
Define USE_PRIVATE_ENCODING_FUNCS so that anyone who tries to add a
dependency on the exported APIs will simply fail to link the shared
module.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2BmrGg%2Bn_X2MOLgeWcj3v_M00gR8uz_D7mM8z%3DdX1JYVbg%40mail.gmail.com M src/interfaces/libpq-oauth/Makefile
M src/interfaces/libpq-oauth/meson.build
libpq-oauth: Use the PGoauthBearerRequestV2 API
commit : 6225403f2783dae16be57120618522d255bd6cc8
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 13 Mar 2026 09:37:59 -0700
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 13 Mar 2026 09:37:59 -0700 Switch the private libpq-oauth ABI to a public one, based on the new
PGoauthBearerRequestV2 API. A huge amount of glue code can be removed as
part of this, and several code paths can be deduplicated. Additionally,
the shared library no longer needs to change its name for every major
release; it's now just "libpq-oauth.so".
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2BmrGg%2Bn_X2MOLgeWcj3v_M00gR8uz_D7mM8z%3DdX1JYVbg%40mail.gmail.com M src/interfaces/libpq-oauth/Makefile
M src/interfaces/libpq-oauth/README
M src/interfaces/libpq-oauth/exports.txt
M src/interfaces/libpq-oauth/meson.build
M src/interfaces/libpq-oauth/oauth-curl.c
M src/interfaces/libpq-oauth/oauth-curl.h
M src/interfaces/libpq-oauth/oauth-utils.c
M src/interfaces/libpq-oauth/oauth-utils.h
M src/interfaces/libpq/fe-auth-oauth.c
M src/interfaces/libpq/fe-auth-oauth.h
M src/tools/pgindent/typedefs.list
Initialize variable to placate compiler.
commit : be43c48c22cc8a4f55258e5230d23909e13c5efd
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 11:32:14 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 11:32:14 -0500 Since commit 5883ff30b0, some compilers have been warning that the
rtekind variable in unique_nonjoin_rtekind() may be used
uninitialized. There doesn't appear to be any actual risk, so
let's just initialize it to something to silence the compiler
warnings.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0sieVNfniCKMDdDjuXGd1OuzMQfTS5%3D9vX3sa-iiujKUA%40mail.gmail.com M contrib/pg_plan_advice/pgpa_scan.c
Optimize COPY FROM (FORMAT {text,csv}) using SIMD.
commit : e0a3a3fd5361913502ff696ecf47770ca55975ae
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 11:07:32 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 13 Mar 2026 11:07:32 -0500 Presently, such commands scan the input buffer one byte at a time
looking for special characters. This commit adds a new path that
uses SIMD instructions to skip over chunks of data without any
special characters. This can be much faster.
To avoid regressions, SIMD processing is disabled for the remainder
of the COPY FROM command as soon as we encounter a short line or a
special character (except for end-of-line characters, else we'd
always disable it after the first line). This is perhaps too
conservative, but it could probably be made more lenient in the
future via fine-tuned heuristics.
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Co-authored-by: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Ayoub Kazar <ma_kazar@esi.dz>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Neil Conway <neil.conway@gmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Tested-by: Manni Wood <manni.wood@enterprisedb.com>
Tested-by: Mark Wong <markwkm@gmail.com>
Discussion: https://postgr.es/m/CAOzEurSW8cNr6TPKsjrstnPfhf4QyQqB4tnPXGGe8N4e_v7Jig%40mail.gmail.com M src/backend/commands/copyfrom.c
M src/backend/commands/copyfromparse.c
M src/include/commands/copyfrom_internal.h
Factor out constructSetOpTargetlist() from transformSetOperationTree()
commit : 8c2b30487cc7e8797ca78f3b089ae0fec199f1a9
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 13 Mar 2026 16:08:09 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 13 Mar 2026 16:08:09 +0100 This would be used separately by a future patch. It also makes a
little smaller.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org M src/backend/parser/analyze.c
Add callback for I/O error messages in SLRUs
commit : f9de9bf302d2df41da06c6377ba1904883cd9d51
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 16:21:06 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 16:21:06 +0200 Historically, all SLRUs were addressed by transaction IDs, but that
hasn't been true for a long time. However, the error message on I/O
error still always talked about accessing a transaction ID.
This commit adds a callback that allows subsystems to construct their
own error messages, which can then correctly refer to a transaction
ID, multixid or whatever else is used to address the particular SLRU.
Author: Maxim Orlov <orlovmg@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://www.postgresql.org/message-id/CACG=ezZZfurhYV+66ceubxQAyWqv9vaUi0yoO4-t48OE5xc0DQ@mail.gmail.com M src/backend/access/transam/clog.c
M src/backend/access/transam/commit_ts.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/slru.c
M src/backend/access/transam/subtrans.c
M src/backend/commands/async.c
M src/backend/storage/lmgr/predicate.c
M src/include/access/slru.h
M src/test/modules/test_slru/expected/test_slru.out
M src/test/modules/test_slru/sql/test_slru.sql
M src/test/modules/test_slru/test_slru–1.0.sql
M src/test/modules/test_slru/test_slru.c
M src/tools/pgindent/typedefs.list
Add stats_reset column to pg_stat_database_conflicts.
commit : 723619eaa3a85f32ce8c2d32c063da26f89ca8d2
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 13 Mar 2026 22:17:14 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 13 Mar 2026 22:17:14 +0900 This commit adds a stats_reset column to pg_stat_database_conflicts,
allowing users to see when the statistics in this view were last reset.
This makes the view consistent with pg_stat_database and other statistics
views.
Catalog version bumped.
Author: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqS98OebEWjax99_LVAECsxCB8i=BfsdAL34i-5QHfwyOQ@mail.gmail.com M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/include/catalog/catversion.h
M src/test/regress/expected/rules.out
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql
Check for interrupts during non-fast-update GIN insertion
commit : 2e1dcf8c5424309305182af4700314cf59bab6b0
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 15:12:32 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 15:12:32 +0200 ginExtractEntries() can produce a lot of entries for a single item.
During index build, we check for interrupts between entries, and the
fast-update codepath does it as part of vacuum_delay_point(), but the
non-fast update insertion codepath was uninterruptible. Add
CHECK_FOR_INTERRUPTS() between entries in the non-fast update codepath
too.
Author: Vinod Sridharan <vsridh90@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAFMdLD6mQvAuStiOGvBJxAEfo6wdjZhj3+JveTLxOX8MVn4zmA@mail.gmail.com M src/backend/access/gin/gininsert.c
Rework ginScanToDelete() to pass Buffers instead of BlockNumbers.
commit : fa6f2f624c01bba6e4c7b6920256afcc1ee17eb2
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Sat, 21 Feb 2026 11:08:08 +0200
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Sat, 21 Feb 2026 11:08:08 +0200 Previously, ginScanToDelete() and ginDeletePage() passed BlockNumbers and
re-read pages that were already pinned and locked during the tree walk. The
caller ginVacuumPostingTree()) held a cleanup-locked root buffer, yet
ginScanToDelete() re-read it by block number with special-case code to skip
re-locking.
At first, this commit gives both functions more appropriate names,
ginScanPostingTreeToDelete() and ginDeletePostingPage(), indicating they deal
with posting trees/pages. This is more descriptive and similar to the way we
name other GIN functions, for instance, ginVacuumPostingTree() and
ginVacuumPostingTreeLeaves().
Then rework both functions to pass Buffers directly. DataPageDeleteStack now
carries buffer, myoff (downlink offset in parent), and isRoot per level,
so ginScanPostingTreeToDelete() takes only GinVacuumState and
DataPageDeleteStack pointers. Also, ginDeletePostingPage() receives the three
Buffers directly, and no longer reads or releases them itself. The caller
reads and locks child pages before recursing, and manages buffer lifecycle
afterward.
This eliminates the confusing isRoot special cases in buffer management,
including the apparent (but unreachable) double release of the root
buffer identified by Andres Freund.
Add comments explaining the locking protocol and the DataPageDeleteStack
structure.
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/utrlxij43fbguzw4kldte2spc4btoldizutcqyrfakqnbrp3ir@ph3sphpj4asz
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Jinbinge <jinbinge@126.com> M src/backend/access/gin/README
M src/backend/access/gin/ginvacuum.c
Fix pointer type of ShmemAllocatorData->index
commit : f30cebb9542358702ca0f2c4be2cd504a2568606
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 11:00:15 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 13 Mar 2026 11:00:15 +0200 This went unnoticed in commit e2362eb2bd because the pointer is cast
to/from a void pointer. M src/backend/storage/ipc/shmem.c
xml2: Fix failure with xslt_process() under -fsanitize=undefined
commit : 7d64419f8073dafdb8ae28c20b1323bf6a93c55e
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 13 Mar 2026 16:06:28 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 13 Mar 2026 16:06:28 +0900 The logic of xslt_process() has never considered the fact that
xsltSaveResultToString() would return NULL for an empty string (the
upstream code has always done so, with a string length of 0). This
would cause memcpy() to be called with a NULL pointer, something
forbidden by POSIX.
Like 46ab07ffda9d and similar fixes, this is backpatched down to all the
supported branches, with a test case to cover this scenario. An empty
string has been always returned in xml2 in this case, based on the
history of the module, so this is an old issue.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/c516a0d9-4406-47e3-9087-5ca5176ebcf9@gmail.com
Backpatch-through: 14 M contrib/xml2/expected/xml2.out
M contrib/xml2/expected/xml2_1.out
M contrib/xml2/sql/xml2.sql
M contrib/xml2/xslt_proc.c
Change copyObject() to use typeof_unqual
commit : 59292f7aac72305f8e47f19155e6c7e0a070acb9
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 13 Mar 2026 06:34:24 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 13 Mar 2026 06:34:24 +0100 Currently, when the argument of copyObject() is const-qualified, the
return type is also, because the use of typeof carries over all the
qualifiers. This is incorrect, since the point of copyObject() is to
make a copy to mutate. But apparently no code ran into it.
The new implementation uses typeof_unqual, which drops the qualifiers,
making this work correctly.
typeof_unqual is standardized in C23, but all recent versions of all
the usual compilers support it even in non-C23 mode, at least as
__typeof_unqual__. We add a configure/meson test for typeof_unqual
and __typeof_unqual__ and use it if it's available, else we use the
existing fallback of just returning void *.
This is the second attempt, after the first attempt in commit
4cfce4e62c8 was reverted. The following two points address problems
with the earlier version:
We test the underscore variant first so that there is a higher chance
that clang used for bitcode also supports it, since we don't test that
separately.
Unlike the typeof test, the typeof_unqual test also tests with a void
pointer similar to how copyObject() would use it, because that is not
handled by MSVC, so we want the test to fail there.
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org M config/c-compiler.m4
M configure
M configure.ac
M meson.build
M src/include/c.h
M src/include/nodes/nodes.h
M src/include/pg_config.h.in
M src/test/modules/test_cplusplusext/test_cplusplusext.cpp
pgstattuple: Optimize btree and hash index functions with streaming read
commit : 213f0079b3415ad8f5f0a62d119ed1f0a448ad8f
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 13 Mar 2026 10:48:45 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 13 Mar 2026 10:48:45 +0900 This commit replaces the synchronous ReadBufferExtended() loops with the
streaming read routines, affecting pgstatindex() (for btree) and
pgstathashindex() (for hash indexes).
Under test conditions similar to 6c228755add8 (some dm_delay and
debug_io_direct=data), this can result in nice runtime and IO gains.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VrqfbcDXqGrdLQ2xaQ=K0RzExNuw6U_GGqzSJu32wfdQ@mail.gmail.com M contrib/pgstattuple/pgstatindex.c
Enable fast default for domains with non-volatile constraints
commit : a0b6ef29a51818a4073a5f390ed10ef6453d5c11
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 12 Mar 2026 17:53:09 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 12 Mar 2026 17:53:09 -0400 Previously, ALTER TABLE ADD COLUMN always forced a table rewrite when
the column type was a domain with constraints (CHECK or NOT NULL), even
if the default value satisfied those constraints. This was because
contain_volatile_functions() considers CoerceToDomain immutable, so
the code conservatively assumed any constrained domain might fail.
Improve this by using soft error handling (ErrorSaveContext) to evaluate
the CoerceToDomain expression at ALTER TABLE time. If the default value
passes the domain's constraints, the value is stored as a "missing"
attribute default and no table rewrite is needed. If the constraint
check fails, we fall back to a table rewrite, preserving the historical
behavior that constraint violations are only raised when the table
actually contains rows.
Domains with volatile constraint expressions always require a table
rewrite since the constraint result could differ per evaluation and
cannot be cached.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Viktor Holmberg <viktor.holmberg@aiven.io>
Discussion: https://postgr.es/m/CACJufxE_+iZBR1i49k_AHigppPwLTJi6km8NOsC7FWvKdEmmXg@mail.gmail.com M src/backend/commands/tablecmds.c
M src/backend/executor/execExpr.c
M src/include/executor/executor.h
M src/test/regress/expected/fast_default.out
M src/test/regress/sql/fast_default.sql
Extend DomainHasConstraints() to optionally check constraint volatility
commit : 487cf2cbd2f5a32cf9756eb9bd6dbf9f3956c8b7
author : Andrew Dunstan <andrew@dunslane.net>
date : Thu, 12 Mar 2026 17:52:33 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Thu, 12 Mar 2026 17:52:33 -0400 Add an optional bool *has_volatile output parameter to
DomainHasConstraints(). When non-NULL, the function checks whether any
CHECK constraint contains a volatile expression. Callers that don't
need this information pass NULL and get the same behavior as before.
This is needed by a subsequent commit that enables the fast default
optimization for domains with non-volatile constraints: we can safely
evaluate such constraints once at ALTER TABLE time, but volatile
constraints require a full table rewrite.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Viktor Holmberg <viktor.holmberg@aiven.io>
Discussion: https://postgr.es/m/CACJufxE_+iZBR1i49k_AHigppPwLTJi6km8NOsC7FWvKdEmmXg@mail.gmail.com M src/backend/commands/copyfrom.c
M src/backend/commands/tablecmds.c
M src/backend/executor/execExpr.c
M src/backend/optimizer/util/clauses.c
M src/backend/parser/parse_expr.c
M src/backend/utils/cache/typcache.c
M src/include/utils/typcache.h
Document the 'command' column of pg_stat_progress_repack
commit : a630ac5c2016e523a1c29df117b7c1a563a7f6f8
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 12 Mar 2026 19:19:23 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 12 Mar 2026 19:19:23 +0100 Commit ac58465e0618 added and documented a new progress-report view for
REPACK, but neglected to list the 'command' column in the docs. This is
my (Álvaro's) fail, as I added the column in v23 of the patch and forgot
to document it.
In passing, add a note in the docs for pg_stat_progress_cluster that it
might contain rows for sessions running REPACK, though mapping the
command name to either the older commands; and that it is for backwards-
compatibility only. (Maybe we should just remove this older view.)
Author: Noriyoshi Shinoda <noriyoshi.shinoda@hpe.com>
Discussion: https://postgr.es/m/LV8PR84MB37870F0F35EF2E8CB99768CBEE47A@LV8PR84MB3787.NAMPRD84.PROD.OUTLOOK.COM
Discussion: https://postgr.es/m/202510101352.vvp4p3p2dblu@alvherre.pgsql M doc/src/sgml/monitoring.sgml
Use simplehash for backend-private buffer pin refcounts.
commit : a367c433ad015b889ee296b07de00017819915c4
author : Peter Geoghegan <pg@bowt.ie>
date : Thu, 12 Mar 2026 13:26:16 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Thu, 12 Mar 2026 13:26:16 -0400 Replace dynahash with simplehash for the per-backend PrivateRefCountHash
overflow table. Simplehash generates inlined, open-addressed lookup
code, avoiding the per-call overhead of dynahash that becomes noticeable
when many buffers are pinned with a CPU-bound workload.
Motivated by testing of the index prefetching patch, which pins many
more buffers concurrently than typical index scans.
Author: Peter Geoghegan <pg@bowt.ie>
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-By: Tomas Vondra <tomas@vondra.me>
Reviewed-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAH2-Wz=g=JTSyDB4UtB5su2ZcvsS7VbP+ZMvvaG6ABoCb+s8Lw@mail.gmail.com M src/backend/storage/buffer/bufmgr.c
M src/tools/pgindent/typedefs.list
nbtree: Avoid allocating _bt_search stack.
commit : d071e1cfec23505e0f55f06988c0144f16235586
author : Peter Geoghegan <pg@bowt.ie>
date : Thu, 12 Mar 2026 13:22:36 -0400
committer: Peter Geoghegan <pg@bowt.ie>
date : Thu, 12 Mar 2026 13:22:36 -0400 Avoid allocating memory for an nbtree descent stack during index scans.
We only require a descent stack during inserts, when it is used to
determine where to insert a new pivot tuple/downlink into the target
leaf page's parent page in the event of a page split. (Page deletion's
first phase also performs a _bt_search that requires a descent stack.)
This optimization improves performance by minimizing palloc churn. It
speeds up index scans that call _bt_search frequently/descend the index
many times, especially when the cost of scanning the index dominates
(e.g., with index-only skip scans). Testing has shown that the
underlying issue causes performance problems for an upcoming patch that
will replace btgettuple with a new btgetbatch interface to enable I/O
prefetching.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAH2-Wzmy7NMba9k8m_VZ-XNDZJEUQBU8TeLEeL960-rAKb-+tQ@mail.gmail.com M contrib/amcheck/verify_nbtree.c
M src/backend/access/nbtree/nbtinsert.c
M src/backend/access/nbtree/nbtpage.c
M src/backend/access/nbtree/nbtsearch.c
M src/backend/access/nbtree/nbtutils.c
M src/include/access/nbtree.h
Add pg_plan_advice contrib module.
commit : 5883ff30b02ceed3c5eabba4d9c09a7766f9a8fc
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 12 Mar 2026 12:59:52 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 12 Mar 2026 12:59:52 -0400 Provide a facility that (1) can be used to stabilize certain plan choices
so that the planner cannot reverse course without authorization and
(2) can be used by knowledgeable users to insist on plan choices contrary
to what the planner believes best. In both cases, terrible outcomes are
possible: users should think twice and perhaps three times before
constraining the planner's ability to do as it thinks best; nevertheless,
there are problems that are much more easily solved with these facilities
than without them.
This patch takes the approach of analyzing a finished plan to produce
textual output, which we call "plan advice", that describes key
decisions made during plan; if that plan advice is provided during
future planning cycles, it will force those key decisions to be made in
the same way. Not all planner decisions can be controlled using advice;
for example, decisions about how to perform aggregation are currently
out of scope, as is choice of sort order. Plan advice can also be edited
by the user, or even written from scratch in simple cases, making it
possible to generate outcomes that the planner would not have produced.
Partial advice can be provided to control some planner outcomes but not
others.
Currently, plan advice is focused only on specific outcomes, such as
the choice to use a sequential scan for a particular relation, and not
on estimates that might contribute to those outcomes, such as a
possibly-incorrect selectivity estimate. While it would be useful to
users to be able to provide plan advice that affects selectivity
estimates or other aspects of costing, that is out of scope for this
commit.
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Reviewed-by: Dian Fay <di@nmfay.com>
Reviewed-by: Ajay Pal <ajay.pal.k@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Discussion: http://postgr.es/m/CA+TgmoZ-Jh1T6QyWoCODMVQdhTUPYkaZjWztzP1En4=ZHoKPzw@mail.gmail.com M contrib/Makefile
M contrib/meson.build
A contrib/pg_plan_advice/.gitignore
A contrib/pg_plan_advice/Makefile
A contrib/pg_plan_advice/README
A contrib/pg_plan_advice/expected/gather.out
A contrib/pg_plan_advice/expected/join_order.out
A contrib/pg_plan_advice/expected/join_strategy.out
A contrib/pg_plan_advice/expected/partitionwise.out
A contrib/pg_plan_advice/expected/prepared.out
A contrib/pg_plan_advice/expected/scan.out
A contrib/pg_plan_advice/expected/semijoin.out
A contrib/pg_plan_advice/expected/syntax.out
A contrib/pg_plan_advice/meson.build
A contrib/pg_plan_advice/pg_plan_advice.c
A contrib/pg_plan_advice/pg_plan_advice.h
A contrib/pg_plan_advice/pgpa_ast.c
A contrib/pg_plan_advice/pgpa_ast.h
A contrib/pg_plan_advice/pgpa_identifier.c
A contrib/pg_plan_advice/pgpa_identifier.h
A contrib/pg_plan_advice/pgpa_join.c
A contrib/pg_plan_advice/pgpa_join.h
A contrib/pg_plan_advice/pgpa_output.c
A contrib/pg_plan_advice/pgpa_output.h
A contrib/pg_plan_advice/pgpa_parser.y
A contrib/pg_plan_advice/pgpa_planner.c
A contrib/pg_plan_advice/pgpa_planner.h
A contrib/pg_plan_advice/pgpa_scan.c
A contrib/pg_plan_advice/pgpa_scan.h
A contrib/pg_plan_advice/pgpa_scanner.l
A contrib/pg_plan_advice/pgpa_trove.c
A contrib/pg_plan_advice/pgpa_trove.h
A contrib/pg_plan_advice/pgpa_walker.c
A contrib/pg_plan_advice/pgpa_walker.h
A contrib/pg_plan_advice/sql/gather.sql
A contrib/pg_plan_advice/sql/join_order.sql
A contrib/pg_plan_advice/sql/join_strategy.sql
A contrib/pg_plan_advice/sql/partitionwise.sql
A contrib/pg_plan_advice/sql/prepared.sql
A contrib/pg_plan_advice/sql/scan.sql
A contrib/pg_plan_advice/sql/semijoin.sql
A contrib/pg_plan_advice/sql/syntax.sql
M doc/src/sgml/contrib.sgml
M doc/src/sgml/filelist.sgml
A doc/src/sgml/pgplanadvice.sgml
M src/tools/pgindent/typedefs.list
doc: Document variables for path substitution in SQL tests
commit : 02976b0a1718037f73fded250411b013e81fdafa
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 12 Mar 2026 16:35:58 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 12 Mar 2026 16:35:58 +0900 Test suites driven by pg_regress can use the following environment
variables for path substitutions since d1029bb5a26c:
- PG_ABS_SRCDIR
- PG_ABS_BUILDDIR
- PG_DLSUFFIX
- PG_LIBDIR
These variables have never been documented, and they can be useful for
out-of-core code based on the options used by the pg_regress command
invoked by installcheck (or equivalent) to build paths to libraries for
various commands, like LOAD or CREATE FUNCTION.
Reviewed-by: Zhang Hu <kongbaik228@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/abDAWzHaesHLDFke@paquier.xyz M doc/src/sgml/regress.sgml
bloom: Optimize VACUUM and bulk-deletion with streaming read
commit : d841ca2d149666b823525e7f5258efd9ef9d7fb1
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 12 Mar 2026 12:00:22 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 12 Mar 2026 12:00:22 +0900 This commit replaces the synchronous ReadBufferExtended() loops done in
blbulkdelete() and blvacuumcleanup() with the streaming read equivalent,
to improve I/O efficiency during bloom index vacuum cleanup operations.
Under the same test conditions as 6c228755add8, the runtime is proving
to gain around 30% better, with most the benefits coming from a large
reduction of the IO operation based on the stats retrieved in the
scenarios run.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VrqfbcDXqGrdLQ2xaQ=K0RzExNuw6U_GGqzSJu32wfdQ@mail.gmail.com M contrib/bloom/blvacuum.c
Use streaming read for VACUUM cleanup of GIN
commit : 6c228755add8f0714677440d53a160f9ed332902
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 12 Mar 2026 11:48:31 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 12 Mar 2026 11:48:31 +0900 This commit replace the synchronous ReadBufferExtended() loop done in
ginvacuumcleanup() with the streaming read equivalent, to improve I/O
efficiency during GIN index vacuum cleanup operations.
With dm_delay to emulate some latency and debug_io_direct=data to force
synchronous writes and force the read path to be exercised, the author
has noticed a 5x improvement in runtime, with a substantial reduction in
IO stats numbers. I have reproduced similar numbers while running
similar tests, with improvements becoming better with more tuples and
more pages manipulated.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VrqfbcDXqGrdLQ2xaQ=K0RzExNuw6U_GGqzSJu32wfdQ@mail.gmail.com M src/backend/access/gin/ginvacuum.c
Convert NOT IN sublinks to anti-joins when safe
commit : 383eb21ebffe9ddd97dca03e529fa363580e7ccf
author : Richard Guo <rguo@postgresql.org>
date : Thu, 12 Mar 2026 09:45:18 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Thu, 12 Mar 2026 09:45:18 +0900 The planner has historically been unable to convert "x NOT IN (SELECT
y ...)" sublinks into anti-joins. This is because standard SQL
semantics for NOT IN require that if the comparison "x = y" returns
NULL, the "NOT IN" expression evaluates to NULL (effectively false),
causing the row to be discarded. In contrast, an anti-join preserves
the row if no match is found. Due to this semantic mismatch regarding
NULL handling, the conversion was previously considered unsafe.
However, if we can prove that neither side of the comparison can yield
NULL values, and further that the operator itself cannot return NULL
for non-null inputs, the behavior of NOT IN and anti-join becomes
identical. Enabling this conversion allows the planner to treat the
sublink as a first-class relation rather than an opaque SubPlan
filter. This unlocks global join ordering optimization and permits
the selection of the most efficient join algorithm based on cost,
often yielding significant performance improvements for large
datasets.
This patch verifies that neither side of the comparison can be NULL
and that the operator is safe regarding NULL results before performing
the conversion.
To verify operator safety, we require that the operator be a member of
a B-tree or Hash operator family. This serves as a proxy for standard
boolean behavior, ensuring the operator does not return NULL on valid
non-null inputs, as doing so would break index integrity.
For operand non-nullability, this patch makes use of several existing
mechanisms. It leverages the outer-join-aware-Var infrastructure to
verify that a Var does not come from the nullable side of an outer
join, and consults the NOT-NULL-attnums hash table to efficiently
verify schema-level NOT NULL constraints. Additionally, it employs
find_nonnullable_vars to identify Vars forced non-nullable by qual
clauses, and expr_is_nonnullable to deduce non-nullability for other
expression types.
The logic for verifying the non-nullability of the subquery outputs
was adapted from prior work by David Rowley and Tom Lane.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Reviewed-by: Zhang Mingli <zmlpostgres@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/CAMbWs495eF=-fSa5CwJS6B-BaEi3ARp0UNb4Lt3EkgUGZJwkAQ@mail.gmail.com M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/plan/subselect.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/util/clauses.c
M src/backend/optimizer/util/var.c
M src/backend/utils/adt/int8.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/cache/lsyscache.c
M src/include/optimizer/clauses.h
M src/include/optimizer/optimizer.h
M src/include/optimizer/subselect.h
M src/include/utils/lsyscache.h
M src/test/regress/expected/subselect.out
M src/test/regress/sql/subselect.sql
M src/tools/pgindent/typedefs.list
bufmgr: Fix use of wrong variable in GetPrivateRefCountEntrySlow()
commit : 6322a028fa437669022473be8af39bbd89b644c3
author : Andres Freund <andres@anarazel.de>
date : Wed, 11 Mar 2026 17:26:38 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 11 Mar 2026 17:26:38 -0400 Unfortunately, in 30df61990c67, I made GetPrivateRefCountEntrySlow() set a
wrong cache hint when moving entries from the hash table to the faster array.
There are no correctness concerns due to this, just an unnecessary loss of
performance.
Noticed while testing the index prefetching patch.
Discussion: https://postgr.es/m/CAH2-Wz=g=JTSyDB4UtB5su2ZcvsS7VbP+ZMvvaG6ABoCb+s8Lw@mail.gmail.com M src/backend/storage/buffer/bufmgr.c
Fix use of volatile.
commit : 547c15f9f8764af7b030a3b67dcbddab639da13c
author : Jeff Davis <jdavis@postgresql.org>
date : Wed, 11 Mar 2026 14:27:58 -0700
committer: Jeff Davis <jdavis@postgresql.org>
date : Wed, 11 Mar 2026 14:27:58 -0700 Commit 8185bb5347 misused volatile. Fix it. See also 6307b096e25.
Reported-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/1bb21c7d-885f-4f07-a3ed-21b60d7c92c6@eisentraut.org M src/backend/foreign/foreign.c
Add support for altering CHECK constraint enforceability
commit : 342051d73b386ad763e13930e15031f7ba5367f5
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 11 Mar 2026 16:15:35 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 11 Mar 2026 16:15:35 -0400 This commit adds support for ALTER TABLE ALTER CONSTRAINT ... [NOT]
ENFORCED for CHECK constraints. Previously, only foreign key
constraints could have their enforceability altered.
When changing from NOT ENFORCED to ENFORCED, the operation not only
updates catalog information but also performs a full table scan in
Phase 3 to validate that existing data satisfies the constraint.
For partitioned tables and inheritance hierarchies, the operation
recurses to all child tables. When changing to NOT ENFORCED, we must
recurse even if the parent is already NOT ENFORCED, since child
constraints may still be ENFORCED.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@cybertec.at>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CACJufxHCh_FU-FsEwsCvg9mN6-5tzR6H9ntn+0KUgTCaerDOmg@mail.gmail.com M doc/src/sgml/ref/alter_table.sgml
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
rename alter constraint enforceability related functions
commit : a9747153e14d38a72d2468744fab946643423924
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 11 Mar 2026 16:14:58 -0400
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 11 Mar 2026 16:14:58 -0400 The functions AlterConstrEnforceabilityRecurse and
ATExecAlterConstrEnforceability are being renamed to
AlterFKConstrEnforceabilityRecurse and ATExecAlterFKConstrEnforceability,
respectively.
The current alter constraint functions only handle Foreign Key constraints.
Renaming them to be more explicit about the constraint type is necessary;
otherwise, it will cause confusion when we later introduce the ability to alter
the enforceability of other constraints.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Discussion: https://postgr.es/m/CACJufxHCh_FU-FsEwsCvg9mN6-5tzR6H9ntn+0KUgTCaerDOmg@mail.gmail.com M src/backend/commands/tablecmds.c
bufmgr: Switch to standard order in MarkBufferDirtyHint()
commit : a766125efd60ddc8358979322496a8e0fd8746c4
author : Andres Freund <andres@anarazel.de>
date : Wed, 11 Mar 2026 13:58:44 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 11 Mar 2026 13:58:44 -0400 When we were updating hint bits with just a share lock MarkBufferDirtyHint()
had to use a non-standard order of operations, i.e. WAL log the buffer before
marking the buffer dirty. This was required because the lock level used to set
hints did not conflict with the lock level that was used to flush pages, which
would have allowed flushing the page out before the WAL record. The
non-standard order in turn required preventing the checkpoint from starting
between writing the WAL record and flushing out the page.
Now that setting hints and writing out buffers use share-exclusive, we can
revert back to the normal order of operations.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d M src/backend/access/transam/xloginsert.c
M src/backend/storage/buffer/bufmgr.c
bufmgr: Remove the, now obsolete, BM_JUST_DIRTIED
commit : b0f4ff3c92664e28615e2f885195c803156d47eb
author : Andres Freund <andres@anarazel.de>
date : Wed, 11 Mar 2026 13:53:37 -0400
committer: Andres Freund <andres@anarazel.de>
date : Wed, 11 Mar 2026 13:53:37 -0400 Due to the recent changes to use a share-exclusive mode for setting hint bits
and for flushing pages - instead of using share mode as before - a buffer
cannot be dirtied while the flush is ongoing. The reason we needed
JUST_DIRTIED was to handle the case where the buffer was dirtied while IO was
ongoing - which is not possible anymore.
Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/buffer/localbuf.c
M src/include/storage/buf_internals.h
Avoid WAL flush checks for unlogged buffers in GetVictimBuffer()
commit : 11e0824bd97e1639f9358260f389083135e0b5e3
author : Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 11 Mar 2026 14:48:26 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Wed, 11 Mar 2026 14:48:26 -0400 GetVictimBuffer() rejects a victim buffer if it is from a bulkread
strategy ring and reusing it would require flushing WAL. Unlogged table
buffers can have fake LSNs (e.g. unlogged GiST pages) and calling
XLogNeedsFlush() on a fake LSN is meaningless.
This is a bit of future-proofing because currently the bulkread strategy
is not used for relations with fake LSNs.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reported-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Earlier version reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/flat/fmkqmyeyy7bdpvcgkheb6yaqewemkik3ls6aaveyi5ibmvtxnd%40nu2kvy5rq3a6 M src/backend/storage/buffer/bufmgr.c
Do not lock in BufferGetLSNAtomic() on archs with 8 byte atomic reads
commit : 943e881733ca62ea2e1ceb20e79b3d149379755d
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Wed, 11 Mar 2026 18:32:03 +0100
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Wed, 11 Mar 2026 18:32:03 +0100 On platforms where we can read or write the whole LSN atomically, we do
not need to lock the buffer header to prevent torn LSNs. We can do this
only on platforms with PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY, and when the
pd_lsn field is properly aligned.
For historical reasons the PageXLogRecPtr was defined as a struct with
two uint32 fields. This replaces it with a single uint64 value, to make
the intent clearer. To prevent issues with weak typedefs the value is
still wrapped in a struct.
This also adjusts heapfuncs() in pageinspect, to ensure proper alignment
when reading the LSN from a page on alignment-sensitive hardware.
Idea by Andres Freund. Initial patch by Andreas Karlsson, improved by
Peter Geoghegan. Minor tweaks by me.
Author: Andreas Karlsson <andreas@proxel.se>
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/b6610c3b-3f59-465a-bdbb-8e9259f0abc4@proxel.se M contrib/pageinspect/heapfuncs.c
M contrib/pageinspect/rawpage.c
M src/backend/access/common/bufmask.c
M src/backend/storage/buffer/bufmgr.c
M src/include/access/gist.h
M src/include/storage/bufpage.h
Fix indentation from commit 29a0fb21577
commit : b6eb8dde6be32e394a4420dfeb671b5891a87c8b
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Wed, 11 Mar 2026 15:14:46 +0100
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Wed, 11 Mar 2026 15:14:46 +0100 Per buildfarm animal koel M src/backend/storage/aio/method_worker.c
Conditional locking in pgaio_worker_submit_internal
commit : 29a0fb215779d10fae0cbeb8ce57805f244bad9b
author : Tomas Vondra <tomas.vondra@postgresql.org>
date : Wed, 11 Mar 2026 12:11:04 +0100
committer: Tomas Vondra <tomas.vondra@postgresql.org>
date : Wed, 11 Mar 2026 12:11:04 +0100 With io_method=worker, there's a single I/O submission queue. With
enough workers, the backends and workers may end up spending a lot of
time competing for the AioWorkerSubmissionQueueLock lock. This can
happen with workloads that keep the queue full, in which case it's
impossible to add requests to the queue. Increasing the number of I/O
workers increases the pressure on the lock, worsening the issue.
This change improves the situation in two ways:
* If AioWorkerSubmissionQueueLock can't be acquired without waiting,
the I/O is performed synchronously (as if the queue was full).
* When an entry can't be added to a full queue, stop trying to add more
entries. All remaining entries are handled as synchronous I/O.
The regression was reported by Alexandre Felipe. Investigation and
patch by me, based on an idea by Andres Freund.
Reported-by: Alexandre Felipe <o.alexandre.felipe@gmail.com>
Author: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAE8JnxOn4+xUAnce+M7LfZWOqfrMMxasMaEmSKwiKbQtZr65uA@mail.gmail.com M src/backend/storage/aio/method_worker.c
Fixes for C++ typeof implementation
commit : 9c05f152b5dd7aeaa6e64bd4ed2fc86bab437073
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 11 Mar 2026 11:54:10 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 11 Mar 2026 11:54:10 +0100 This fixes two bugs in commit 1887d822f14.
First, if we are using the fallback C++ implementation of typeof, then
we need to include the C++ header <type_traits> for
std::remove_reference_t. This header is also likely to be used for
other C++ implementations of type tricks, so we'll put it into the
global includes.
Second, for the case that the C compiler supports typeof in a spelling
that is not "typeof" (for example, __typeof__), then we need to #undef
typeof in the C++ section to avoid warnings about duplicate macro
definitions.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org M src/include/c.h
Remove Int8GetDatum function
commit : d4a080b8a190c4ba434a390939c995a50da12cf6
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 11 Mar 2026 10:46:08 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 11 Mar 2026 10:46:08 +0100 We have no uses of Int8GetDatum in our tree and did not have for a
long time (or never), and the inverse does not exist either.
Author: Kirill Reshke <reshkekirill@gmail.com>
Suggested-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/CALdSSPhFyb9qLSHee73XtZm1CBWJNo9+JzFNf-zUEWCRW5yEiQ@mail.gmail.com M src/include/postgres.h
Sort out table_open vs. relation_open in rewriter
commit : d537f59fbbfcd3b50a7208b1320a0fa73ca589f5
author : Peter Eisentraut <peter@eisentraut.org>
date : Wed, 11 Mar 2026 09:22:11 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Wed, 11 Mar 2026 09:22:11 +0100 table_open() is a wrapper around relation_open() that checks that the
relkind is table-like and gives a user-facing error message if not.
It is best used in directly user-facing areas to check that the user
used the right kind of command for the relkind. In internal uses
where the relkind was previously checked from the user's perspective,
table_open() is not necessary and might even be confusing if it were
to give out-of-context error messages.
In rewriteHandler.c, there were several such table_open() calls, which
this changes to relation_open(). This currently doesn't make a
difference, but there are plans to have other relkinds that could
appear in the rewriter but that shouldn't be accessible via
table-specific commands, and this clears the way for that.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6d3fef19-a420-4e11-8235-8ea534bf2080%40eisentraut.org
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org M src/backend/rewrite/rewriteHandler.c
Require share-exclusive lock to set hint bits and to flush
commit : 82467f627bd478569de04f4a3f1993098e80c812
author : Andres Freund <andres@anarazel.de>
date : Tue, 10 Mar 2026 19:32:13 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 10 Mar 2026 19:32:13 -0400 At the moment hint bits can be set with just a share lock on a page (and,
until 45f658dacb9, in one case even without any lock). Because of this we need
to copy pages while writing them out, as otherwise the checksum could be
corrupted.
The need to copy the page is problematic to implement AIO writes:
1) Instead of just needing a single buffer for a copied page we need one for
each page that's potentially undergoing I/O
2) To be able to use the "worker" AIO implementation the copied page needs to
reside in shared memory
It also causes problems for using unbuffered/direct-IO, independent of AIO:
Some filesystems, raid implementations, ... do not tolerate the data being
written out to change during the write. E.g. they may compute internal
checksums that can be invalidated by concurrent modifications, leading e.g. to
filesystem errors (as the case with btrfs).
It also just is plain odd to allow modifications of buffers that are just
share locked.
To address these issues, this commit changes the rules so that modifications
to pages are not allowed anymore while holding a share lock. Instead the new
share-exclusive lock (introduced in fcb9c977aa5) allows at most one backend to
modify a buffer while other backends have the same page share locked. An
existing share-lock can be upgraded to a share-exclusive lock, if there are no
conflicting locks. For that BufferBeginSetHintBits()/BufferFinishSetHintBits()
and BufferSetHintBits16() have been introduced.
To prevent hint bits from being set while the buffer is being written out,
writing out buffers now requires a share-exclusive lock.
The use of share-exclusive to gate setting hint bits means that from now on
only one backend can set hint bits at a time. To allow multiple backends to
set hint bits would require more complicated locking: For setting hint bits
we'd need to store the count of backends currently setting hint bits and we
would need another lock-level for I/O conflicting with the lock-level to set
hint bits. Given that the share-exclusive lock for setting hint bits is only
held for a short time, that backends would often just set the same hint bits
and that the cost of occasionally not setting hint bits in hotly accessed
pages is fairly low, this seems like an acceptable tradeoff.
The biggest change to adapt to this is in heapam. To avoid performance
regressions for sequential scans that need to set a lot of hint bits, we need
to amortize the cost of BufferBeginSetHintBits() for cases where hint bits are
set at a high frequency. To that end HeapTupleSatisfiesMVCCBatch() uses the
new SetHintBitsExt(), which defers BufferFinishSetHintBits() until all hint
bits on a page have been set. Conversely, to avoid regressions in cases where
we can't set hint bits in bulk (because we're looking only at individual
tuples), use BufferSetHintBits16() when setting hint bits without batching.
Several other places also need to be adapted, but those changes are
comparatively simpler.
After this we do not need to copy buffers to write them out anymore. That
change is done separately however.
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/fvfmkr5kk4nyex56ejgxj3uzi63isfxovp2biecb4bspbjrze7@az2pljabhnff
Discussion: https://postgr.es/m/stj36ea6yyhoxtqkhpieia2z4krnam7qyetc57rfezgk4zgapf%40gcnactj4z56m M src/backend/access/gist/gistget.c
M src/backend/access/hash/hashutil.c
M src/backend/access/heap/heapam_visibility.c
M src/backend/access/nbtree/nbtinsert.c
M src/backend/access/nbtree/nbtutils.c
M src/backend/access/transam/xloginsert.c
M src/backend/storage/buffer/README
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/freespace/freespace.c
M src/backend/storage/freespace/fsmpage.c
M src/include/storage/bufmgr.h
M src/tools/pgindent/typedefs.list
bloom: Optimize bitmap scan path with streaming read
commit : 4c910f3bbe92aa4e84ff15fa27b4de2da0d7ae50
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 11 Mar 2026 07:36:10 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 11 Mar 2026 07:36:10 +0900 This commit replaces the per-page buffer read look in blgetbitmap() with
a reading stream, to improve scan efficiency, particularly useful for
large bloom indexes. Some benchmarking with a large number of rows has
shown a very nice improvement in terms of runtime and IO read reduction
with test cases up to 10M rows for a bloom index scan.
For the io_uring method, The author has reported a 3x in runtime with
io_uring while I was at close to a 7x. For the worker method with 3
workers, the author has reported better numbers than myself in runtime,
with the reduction in IO stats being appealing for all the cases
measured.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CABPTF7VrqfbcDXqGrdLQ2xaQ=K0RzExNuw6U_GGqzSJu32wfdQ@mail.gmail.com M contrib/bloom/blscan.c
Remove unused PruneState member frz_conflict_horizon
commit : 4c7362c553663d24b479e6f286720e5175c93d42
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 10 Mar 2026 18:28:18 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 10 Mar 2026 18:28:18 -0400 c2a23dcf9e3af1c removed use of PruneState.frz_conflict_horizon but
neglected to actually remove the member. Do that now. M src/backend/access/heap/pruneheap.c
Don't clear pendingRecoveryConflicts at end of transaction
commit : 138592d1b06634b85d4b0275ba6501676bb8113a
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 11 Mar 2026 00:06:09 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 11 Mar 2026 00:06:09 +0200 Commit 17f51ea818 introduced a new pendingRecoveryConflicts field in
PGPROC to replace the various ProcSignals. The new field was cleared
in ProcArrayEndTransaction(), which makes sense for conflicts with
e.g. locks or buffer pins which are gone at end of transaction. But it
is not appropriate for conflicts on a database, or a logical slot.
Because of this, the 035_standby_logical_decoding.pl test was
occasionally getting stuck in the buildfarm. It happens if the startup
process signals recovery conflict with the logical slot just when the
walsender process using the slot calls ProcArrayEndTransaction().
To fix, don't clear pendingRecoveryConflicts in
ProcArrayEndTransaction(). We could still clear certain conflict
flags, like conflicts on locks, but we didn't try to do that before
commit 17f51ea818 either.
In the passing, fix a misspelled comment, and make
InitAuxiliaryProcess() to also clear pendingRecoveryConflicts. I don't
think aux processes can have recovery conflicts, but it seems best to
initialize the field and keep InitAuxiliaryProcess() as close to
InitProcess() as possible.
Analyzed-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://www.postgresql.org/message-id/3e07149d-060b-48a0-8f94-3d5e4946ae45@gmail.com M src/backend/storage/ipc/procarray.c
M src/backend/storage/lmgr/proc.c
Use the newest to-be-frozen xid as the conflict horizon for freezing
commit : c2a23dcf9e3af1c80a99b4ee43f0885eb6894e3a
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 10 Mar 2026 15:24:39 -0400
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 10 Mar 2026 15:24:39 -0400 Previously WAL records that froze tuples used OldestXmin as the snapshot
conflict horizon, or the visibility cutoff if the page would become
all-frozen. Both are newer than (or equal to) the newst XID actually
frozen on the page.
Track the newest XID that will be frozen and use that as the snapshot
conflict horizon instead. This yields an older horizon resulting in
fewer query cancellations on standbys.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAAKRu_bbaUV8OUjAfVa_iALgKnTSfB4gO3jnkfpcFgrxEpSGJQ%40mail.gmail.com M src/backend/access/heap/heapam.c
M src/backend/access/heap/pruneheap.c
M src/include/access/heapam.h
Introduce the REPACK command
commit : ac58465e0618941842439eb3f5a2cf8bebd5a3f1
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 10 Mar 2026 19:56:39 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 10 Mar 2026 19:56:39 +0100 REPACK absorbs the functionality of VACUUM FULL and CLUSTER in a single
command. Because this functionality is completely different from
regular VACUUM, having it separate from VACUUM makes it easier for users
to understand; as for CLUSTER, the term is heavily overloaded in the
IT world and even in Postgres itself, so it's good that we can avoid it.
We retain those older commands, but de-emphasize them in the
documentation, in favor of REPACK; the difference between VACUUM FULL
and CLUSTER (namely, the fact that tuples are written in a specific
ordering) is neatly absorbed as two different modes of REPACK.
This allows us to introduce further functionality in the future that
works regardless of whether an ordering is being applied, such as (and
especially) a concurrent mode.
Author: Antonin Houska <ah@cybertec.at>
Reviewed-by: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://postgr.es/m/82651.1720540558@antos
Discussion: https://postgr.es/m/202507262156.sb455angijk6@alvherre.pgsql M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/allfiles.sgml
M doc/src/sgml/ref/cluster.sgml
A doc/src/sgml/ref/repack.sgml
M doc/src/sgml/ref/vacuum.sgml
M doc/src/sgml/reference.sgml
M src/backend/access/heap/heapam_handler.c
M src/backend/catalog/index.c
M src/backend/catalog/system_views.sql
M src/backend/commands/cluster.c
M src/backend/commands/vacuum.c
M src/backend/parser/gram.y
M src/backend/tcop/utility.c
M src/backend/utils/adt/pgstatfuncs.c
M src/bin/psql/tab-complete.in.c
M src/include/catalog/catversion.h
M src/include/commands/cluster.h
M src/include/commands/progress.h
M src/include/nodes/parsenodes.h
M src/include/parser/kwlist.h
M src/include/tcop/cmdtaglist.h
M src/include/utils/backend_progress.h
M src/test/regress/expected/cluster.out
M src/test/regress/expected/rules.out
M src/test/regress/sql/cluster.sql
M src/tools/pgindent/typedefs.list
Fix grammar in short description of effective_wal_level.
commit : a596d27d807974778513158cb0eafc76bae33d97
author : Masahiko Sawada <msawada@postgresql.org>
date : Tue, 10 Mar 2026 11:36:38 -0700
committer: Masahiko Sawada <msawada@postgresql.org>
date : Tue, 10 Mar 2026 11:36:38 -0700 Align with the convention of using third-person singular (e.g.,
"Shows" instead of "Show") for GUC parameter descriptions.
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20260210.143752.1113524465620875233.horikyota.ntt@gmail.com M src/backend/utils/misc/guc_parameters.dat
heapam: Don't mimic MarkBufferDirtyHint() in inplace updates
commit : f4a4ce52c0d1565c13c436ea17960d22787ea752
author : Andres Freund <andres@anarazel.de>
date : Tue, 10 Mar 2026 10:06:09 -0400
committer: Andres Freund <andres@anarazel.de>
date : Tue, 10 Mar 2026 10:06:09 -0400 Previously heap_inplace_update_and_unlock() used an operation order similar to
MarkBufferDirty(), to reduce the number of different approaches used for
updating buffers. However, in an upcoming patch, MarkBufferDirtyHint() will
switch to using the update protocol used by most other places (enabled by hint
bits only being set while holding a share-exclusive lock).
Luckily it's pretty easy to adjust heap_inplace_update_and_unlock(). As a
comment already foresaw, we can use the normal order, with the slight change
of updating the buffer contents after WAL logging.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d M src/backend/access/heap/heapam.c
pg_dumpall: simplify coding of dropDBs()
commit : a198c26dede50a1fd4c22fb134b53ce8d4f8f5e3
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 10 Mar 2026 16:00:19 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 10 Mar 2026 16:00:19 +0100 There's no need for a StringInfo when all you want is a string
being constructed in a single pass.
Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Ranier Vilela <ranier.vf@gmail.com>
Reviewed-by: Yang Yuanzhuo <1197620467@qq.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CAEudQAq2wyXZRdsh+wVHcOrungPU+_aQeQU12wbcgrmE0bQovA@mail.gmail.com M src/bin/pg_dump/pg_dumpall.c
Remove duplicate initialization in initialize_brin_buildstate().
commit : 59bae234352d10535da7e655bcd7bc8a1339f57f
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 10 Mar 2026 22:55:11 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 10 Mar 2026 22:55:11 +0900 Commit dae761a added initialization of some BrinBuildState fields
in initialize_brin_buildstate(). Later, commit b437571 inadvertently
added the same initialization again.
This commit removes that redundant initialization. No behavioral
change is intended.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Shinya Kato <shinya11.kato@gmail.com>
Discussion: https://postgr.es/m/CAEoWx2nmrca6-9SNChDvRYD6+r==fs9qg5J93kahS7vpoq8QVg@mail.gmail.com M src/backend/access/brin/brin.c
Rename grammar nonterminal to simplify reuse
commit : 8080f44f96a978ce94f7e6b44df1158880525e01
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 10 Mar 2026 13:56:52 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 10 Mar 2026 13:56:52 +0100 A list of expressions with optional AS-labels is useful in a few
different places. Right now, this is available as xml_attribute_list
because it was first used in the XMLATTRIBUTES construct, but it is
already used elsewhere, and there are other possible future uses. To
reduce possible confusion going forward, rename it to
labeled_expr_list (like existing expr_list plus ColLabel).
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org M src/backend/parser/gram.y
Allow extensions to mark an individual index as disabled.
commit : 0fbfd37cefb7eb30c0fa8a158751c19ddeddf1f0
author : Robert Haas <rhaas@postgresql.org>
date : Tue, 10 Mar 2026 08:33:55 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Tue, 10 Mar 2026 08:33:55 -0400 Up until now, the only way for a loadable module to disable the use of a
particular index was to use build_simple_rel_hook (or, previous to
yesterday's commit, get_relation_info_hook) to remove it from the index
list. While that works, it has some disadvantages. First, the index
becomes invisible for all purposes, and can no longer be used for
optimizations such as self-join elimination or left join removal, which
can severely degrade the resulting plan.
Second, if the module attempts to compel the use of a certain index
by removing all other indexes from the index list and disabling
other scan types, but the planner is unable to use the chosen index
for some reason, it will fall back to a sequential scan, because that
is only disabled, whereas the other indexes are, from the planner's
point of view, completely gone. While this situation ideally shouldn't
occur, it's hard for a loadable module to be completely sure whether
the planner will view a certain index as usable for a certain query.
If it isn't, it may be better to fall back to a scan using a disabled
index rather than falling back to an also-disabled sequential scan.
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Discussion: http://postgr.es/m/CA%2BTgmoYS4ZCVAF2jTce%3DbMP0Oq_db_srocR4cZyO0OBp9oUoGg%40mail.gmail.com M src/backend/optimizer/util/pathnode.c
M src/include/nodes/pathnodes.h
Switch to FATAL error for missing checkpoint record without backup_label
commit : 03facc1211b0ff1550f41bcd4da09329080c30f9
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 10 Mar 2026 12:00:05 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 10 Mar 2026 12:00:05 +0900 Crash recovery started without a backup_label previously crashed with a
PANIC if the checkpoint record could not be found. This commit lowers
the report generated to be a FATAL instead.
With recovery methods being more imaginative these days, this should
provide more flexibility when handling PostgreSQL recovery processing in
the event of a driver error, similarly to 15f68cebdcec. An extra
benefit of this change is that it becomes possible to add a test to
check that a FATAL is hit with an expected error message pattern. With
the recovery code becoming more complicated over the last couple of
years, I suspect that this will be benefitial to cover in the long-term.
The original PANIC behavior has been introduced in the early days of
crash recovery, as of 4d14fe0048cf (PANIC did not exist yet, the code
used STOP).
Author: Nitin Jadhav <nitinjadhavpostgres@gmail.com>
Discussion: https://postgr.es/m/CAMm1aWZbQ-Acp_xAxC7mX9uZZMH8+NpfepY9w=AOxbBVT9E=uA@mail.gmail.com M src/backend/access/transam/xlogrecovery.c
M src/test/recovery/meson.build
A src/test/recovery/t/052_checkpoint_segment_missing.pl
Fix misuse of "volatile" in xml.c
commit : 6307b096e2599edfe238816118b3f365a73fd12a
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 10 Mar 2026 07:05:32 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 10 Mar 2026 07:05:32 +0900 What should be used is not "volatile foo *ptr" but "foo *volatile ptr",
The incorrect (former) style means that what the pointer variable points
to is volatile. The correct (latter) style means that the pointer
variable itself needs to be treated as volatile. The latter style is
required to ensure a consistent treatment of these variables after a
longjmp with the TRY/CATCH blocks.
Some casts can be removed thanks to this change.
Issue introduced by 2e947217474c, so no backpatch is required. A
similar set of issues has been fixed in 93001888d85c for contrib/xml2/.
Author: ChangAo Chen <cca5507@qq.com>
Discussion: https://postgr.es/m/tencent_5BE8DAD985EE140ED62EA728C8D4E1311F0A@qq.com M src/backend/utils/adt/xml.c
pg_{dump,restore}: Refactor handling of conflicting options.
commit : 7c8280eeb5872f5c2663b562a9c6fcf8ec8a4b82
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 9 Mar 2026 11:37:46 -0500
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 9 Mar 2026 11:37:46 -0500 This commit makes use of the function added by commit b2898baaf7
for these applications' handling of conflicting options. It
doesn't fix any bugs, but it does trim several lines of code.
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Steven Niu <niushiji@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CACJufxHDYn%2B3-2jR_kwYB0U7UrNP%2B0EPvAWzBBD5EfUzzr1uiw%40mail.gmail.com M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_dump/pg_restore.c
M src/bin/pg_dump/t/001_basic.pl
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/pg_dump/t/007_pg_dumpall.pl
Replace get_relation_info_hook with build_simple_rel_hook.
commit : 91f33a2ae92a68ac89b36eb21e0c5c903d03a142
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 9 Mar 2026 09:48:26 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 9 Mar 2026 09:48:26 -0400 For a long time, PostgreSQL has had a get_relation_info_hook which
plugins can use to editorialize on the information that
get_relation_info obtains from the catalogs. However, this hook is
only called for baserels of type RTE_RELATION, and there is
potential utility in a similar call back for other types of
RTEs. This might have had utility even before commit
4020b370f214315b8c10430301898ac21658143f added pgs_mask to
RelOptInfo, but it certainly has utility now.
So, move the callback up one level, deleting get_relation_info_hook and
adding build_simple_rel_hook instead. The new callback is called just
slightly later than before and with slightly different arguments, but it
should be fairly straightforward to adjust existing code that currently
uses get_relation_info_hook: the values previously available as
relationObjectId and inhparent are now available via rte->relid and
rte->inh, and calls where rte->rtekind != RTE_RELATION can be ignored if
desired.
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Discussion: http://postgr.es/m/CA%2BTgmoYg8uUWyco7Pb3HYLMBRQoO6Zh9hwgm27V39Pb6Pdf%3Dug%40mail.gmail.com M src/backend/optimizer/util/plancat.c
M src/backend/optimizer/util/relnode.c
M src/include/optimizer/pathnode.h
M src/include/optimizer/plancat.h
Consider startup cost as a figure of merit for partial paths.
commit : 8300d3ad4aa73dc6beec8dca7d9362dbc21c9a83
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 9 Mar 2026 08:16:30 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 9 Mar 2026 08:16:30 -0400 Previously, the comments stated that there was no purpose to considering
startup cost for partial paths, but this is not the case: it's perfectly
reasonable to want a fast-start path for a plan that involves a LIMIT
(perhaps over an aggregate, so that there is enough data being processed
to justify parallel query but yet we don't want all the result rows).
Accordingly, rewrite add_partial_path and add_partial_path_precheck to
consider startup costs. This also fixes an independent bug in
add_partial_path_precheck: commit e22253467942fdb100087787c3e1e3a8620c54b2
failed to update it to do anything with the new disabled_nodes field.
That bug fix is formally separate from the rest of this patch and could
be committed separately, but I think it makes more sense to fix both
issues together, because then we can (as this commit does) just make
add_partial_path_precheck do the cost comparisons in the same way as
compare_path_costs_fuzzily, which hopefully reduces the chances of
ending up with something that's still incorrect.
This patch is based on earlier work on this topic by Tomas Vondra,
but I have rewritten a great deal of it.
Co-authored-by: Robert Haas <rhaas@postgresql.org>
Co-authored-by: Tomas Vondra <tomas@vondra.me>
Discussion: http://postgr.es/m/CA+TgmobRufbUSksBoxytGJS1P+mQY4rWctCk-d0iAUO6-k9Wrg@mail.gmail.com M src/backend/optimizer/path/joinpath.c
M src/backend/optimizer/util/pathnode.c
M src/include/optimizer/pathnode.h
M src/test/regress/expected/incremental_sort.out
M src/test/regress/expected/join_hash.out
M src/test/regress/sql/join_hash.sql
Prevent restore of incremental backup from bloating VM fork.
commit : ffc226ab64d4ebdb089c278396d5df3d0a3f83b9
author : Robert Haas <rhaas@postgresql.org>
date : Mon, 9 Mar 2026 06:36:42 -0400
committer: Robert Haas <rhaas@postgresql.org>
date : Mon, 9 Mar 2026 06:36:42 -0400 When I (rhaas) wrote the WAL summarizer code, I incorrectly believed
that XLOG_SMGR_TRUNCATE truncates all forks to the same length. In
fact, what other parts of the code do is compute the truncation length
for the FSM and VM forks from the truncation length used for the main
fork. But, because I was confused, I coded the WAL summarizer to set the
limit block for the VM fork to the same value as for the main fork.
(Incremental backup always copies FSM forks in full, so there is no
similar issue in that case.)
Doing that doesn't directly cause any data corruption, as far as I can
see. However, it does create a serious risk of consuming a large amount
of extra disk space, because pg_combinebackup's reconstruct.c believes
that the reconstructed file should always be at least as long as the
limit block value. We might want to be smarter about that at some point
in the future, because it's always safe to omit all-zeroes blocks at the
end of the last segment of a relation, and doing so could save disk
space, but the current algorithm will rarely waste enough disk space to
worry about unless we believe that a relation has been truncated to a
length much longer than its actual length on disk, which is exactly what
happens as a result of the problem mentioned in the previous paragraph.
To fix, create a new visibilitymap helper function and use it to include
the right limit block in the summary files. Incremental backups taken
with existing summary files will still have this issue, but this should
improve the situation going forward.
Diagnosed-by: Oleg Tkachenko <oatkachenko@gmail.com>
Diagnosed-by: Amul Sul <sulamul@gmail.com>
Discussion: http://postgr.es/m/CAAJ_b97PqG89hvPNJ8cGwmk94gJ9KOf_pLsowUyQGZgJY32o9g@mail.gmail.com
Discussion: http://postgr.es/m/6897DAF7-B699-41BF-A6FB-B818FCFFD585%40gmail.com
Backpatch-through: 17 M src/backend/access/heap/visibilitymap.c
M src/backend/postmaster/walsummarizer.c
M src/bin/pg_combinebackup/t/011_ib_truncation.pl
M src/include/access/visibilitymap.h
Remove trailing period from errmsg in subscriptioncmds.c.
commit : 06d83022628e6bfa9c4bd1feabe2b41e0bdc1310
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 9 Mar 2026 15:10:03 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 9 Mar 2026 15:10:03 +0530 Author: Sahitya Chandra <sahityajb@gmail.com>
Discussion: https://postgr.es/m/20260308142806.181309-1-sahityajb@gmail.com M src/backend/commands/subscriptioncmds.c
Move comment back to better place
commit : 2799e29fb8b1346bd6eab625ce8ad508eab5dc81
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 9 Mar 2026 09:46:36 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 9 Mar 2026 09:46:36 +0100 Commit f014b1b9bb8 inserted some new code in between existing code and
a trailing comment. Move the comment back to near the code it belongs
to. M configure
M configure.ac
doc: Document IF NOT EXISTS option for ALTER FOREIGN TABLE ADD COLUMN.
commit : 173aa8c5e89130c757c029262f10fc537b6f68ae
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 9 Mar 2026 18:23:36 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 9 Mar 2026 18:23:36 +0900 Commit 2cd40adb85d added the IF NOT EXISTS option to ALTER TABLE ADD COLUMN.
This also enabled IF NOT EXISTS for ALTER FOREIGN TABLE ADD COLUMN,
but the ALTER FOREIGN TABLE documentation was not updated to mention it.
This commit updates the documentation to describe the IF NOT EXISTS option for
ALTER FOREIGN TABLE ADD COLUMN.
While updating that section, also this commit clarifies that the COLUMN keyword
is optional in ALTER FOREIGN TABLE ADD/DROP COLUMN. Previously, part of
the documentation could be read as if COLUMN were required.
This commit adds regression tests covering these ALTER FOREIGN TABLE syntaxes.
Backpatch to all supported versions.
Suggested-by: Fujii Masao <masao.fujii@gmail.com>
Author: Chao Li <lic@highgo.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwFk=rrhrwGwPtQxBesbT4DzSZ86Q3ftcwCu3AR5bOiXLw@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/alter_foreign_table.sgml
M src/test/regress/expected/foreign_data.out
M src/test/regress/sql/foreign_data.sql
Fix size underestimation of DSA pagemap for odd-sized segments
commit : 4da2afd01f938af35c1a52bbf6bc40baa52462f6
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 9 Mar 2026 13:46:27 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 9 Mar 2026 13:46:27 +0900 When make_new_segment() creates an odd-sized segment, the pagemap was
only sized based on a number of usable_pages entries, forgetting that a
segment also contains metadata pages, and that the FreePageManager uses
absolute page indices that cover the entire segment. This
miscalculation could cause accesses to pagemap entries to be out of
bounds. During subsequent reuse of the allocated segment, allocations
landing on pages with indices higher than usable_pages could cause
out-of-bounds pagemap reads and/or writes. On write, 'span' pointers
are stored into the data area, corrupting the allocated objects. On
read (aka during a dsa_free), garbage is interpreted as a span pointer,
typically crashing the server in dsa_get_address().
The normal geometric path correctly sizes the pagemap for all pages in
the segment. The odd-sized path needs to do the same, but it works
forward from usable_pages rather than backward from total_size.
This commit fixes the sizing of the odd-sized case by adding pagemap
entries for the metadata pages after the initial metadata_bytes
calculation, using an integer ceiling division to compute the exact
number of additional entries needed in one go, avoiding any iteration in
the calculation.
An assertion is added in the code path for odd-sized segments, ensuring
that the pagemap includes the metadata area, and that the result is
appropriately sized.
This problem would show up depending on the size requested for the
allocation of a DSA segment. The reporter has noticed this issue when a
parallel hash join makes a DSA allocation large enough to trigger the
odd-sized segment path, but it could happen for anything that does a DSA
allocation.
A regression test is added to test_dsa, down to v17 where the test
module has been introduced. This adds a set of cheap tests to check the
problem, the new assertion being useful for this purpose. Sami has
proposed a test that took a longer time than what I have done here; the
test committed is faster and good enough to check the odd-sized
allocation path.
Author: Paul Bunn <paul.bunn@icloud.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/044401dcabac$fe432490$fac96db0$@icloud.com
Backpatch-through: 14 M src/backend/utils/mmgr/dsa.c
M src/test/modules/test_dsa/expected/test_dsa.out
M src/test/modules/test_dsa/sql/test_dsa.sql
M src/test/modules/test_dsa/test_dsa–1.0.sql
M src/test/modules/test_dsa/test_dsa.c
Refactor tests for catalog diff comparisons in stats_import.sql
commit : ccd7abaa456f34a41efe2e5198f0bb2227aa43d9
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 9 Mar 2026 08:46:06 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 9 Mar 2026 08:46:06 +0900 The tests of stats_import.sql include a set of queries to do
differential checks of the three statistics catalog relations, based on
the comparison of a source relation and a target relation, used for the
copy of the stats data with the restore functions:
- pg_statistic
- pg_stats_ext
- pg_stats_ext_exprs
This commit refactors the tests to reduce the bloat of such differential
queries, by creating a set of objects that make the differential queries
smaller:
- View for a base relation type.
- First function to retrieve stats data, that returns a type based on
the view previously created.
- Second function that checks the difference, based on two calls of the
first function.
This change leads to a nice reduction of stats_import.sql, with a larger
effect on the output file.
While on it, this adds some sanity checks for the three catalogs, to
warn developers that the stats import facilities may need to be updated
if any of the three catalogs change. These are rare in practice, see
918eee0c497c as one example. Another stylistic change is the use of the
extended output format for the differential queries, so as we avoid long
lines of output if a diff is caught.
Author: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/CADkLM=eEhxJpSUP+eC=eMGZZsVOpnfKDvVkuCbsFg9CajYwDsA@mail.gmail.com M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql
Fix typo in stats_import.sql
commit : 9e8193a26229a2a578619fb3ee0687761aff2ea1
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 9 Mar 2026 07:15:26 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 9 Mar 2026 07:15:26 +0900 The test mentioned pg_stat_ext_exprs, but the correct catalog name is
pg_stats_ext_exprs.
Thinko in ba97bf9cb7b4.
Discussion: https://postgr.es/m/CADkLM=eEhxJpSUP+eC=eMGZZsVOpnfKDvVkuCbsFg9CajYwDsA@mail.gmail.com M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql
Fix invalid boolean if-test
commit : eb2c867b0aab5fd6bbea1d8dbfea23d9d6fa1a94
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 7 Mar 2026 14:28:16 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 7 Mar 2026 14:28:16 +0100 We were testing the truth value of the array of booleans (which is
always true) instead of the boolean element specific to the affected
table column.
This causes a binary-upgrade dump fail to omit the name of a constraint;
that is, the correct constraint name is always printed, even when it's
not needed. The affected case is a binary-upgrade dump of a not-null
constraint in an inherited column, which must in addition have no
comment.
Another point is that in order for this to make a difference, the
constraint must have the default name in the child table. That is, the
constraint must have been created _in the parent table_ with the name
that it would have in the child table, like so:
CREATE TABLE parent (a int CONSTRAINT child_a_not_null NOT NULL);
CREATE TABLE child () INHERITS (parent);
Otherwise, the correct name must be printed by binary-upgrade pg_dump
anyway, since it wouldn't match the name produced at the parent.
Moreover, when it does hit, the pre-18-compatibility code (which has to
work with a constraint that has no name) gets involved and uses the
UPDATE on pg_constraint using the conkey instead of column name ... and
so everything ends up working correctly AFAICS.
I think it might cause a problem if the table and column names are
overly long, but I didn't want to spend time investigating further.
Still, it's wrong code, and static analyzers have twice complained about
it, so fix it by adding the array index accessor that was obviously
meant.
Reported-by: Ranier Vilela <ranier.vf@gmail.com>
Reported-by: George Tarasov <george.v.tarasov@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/CAEudQAo7ah=4TDheuEjtb0dsv6bHoK7uBNqv53Tsub2h-xBSJw@mail.gmail.com
Discussion: https://postgr.es/m/f3029f25-acc9-4cb9-a74f-fe93bcfb3a27@gmail.com M src/bin/pg_dump/pg_dump.c
libpq: Introduce PQAUTHDATA_OAUTH_BEARER_TOKEN_V2
commit : e982331b52083ee81f5f62f9872c874cbc1862c1
author : Jacob Champion <jchampion@postgresql.org>
date : Fri, 6 Mar 2026 12:00:32 -0800
committer: Jacob Champion <jchampion@postgresql.org>
date : Fri, 6 Mar 2026 12:00:32 -0800 For the libpq-oauth module to eventually make use of the
PGoauthBearerRequest API, it needs some additional functionality: the
derived Issuer ID for the authorization server needs to be provided, and
error messages need to be built without relying on PGconn internals.
These features seem useful for application hooks, too, so that they
don't each have to reinvent the wheel.
The original plan was for additions to PGoauthBearerRequest to be made
without a version bump to the PGauthData type. Applications would simply
check a LIBPQ_HAS_* macro at compile time to decide whether they could
use the new features. That theoretically works for applications linked
against libpq, since it's not safe to downgrade libpq from the version
you've compiled against.
We've since found that this strategy won't work for plugins, due to a
complication first noticed during the libpq-oauth module split: it's
normal for a plugin on disk to be *newer* than the libpq that's loading
it, because you might have upgraded your installation while an
application was running. (In other words, a plugin architecture causes
the compile-time and run-time dependency arrows to point in opposite
directions, so plugins won't be able to rely on the LIBPQ_HAS_* macros
to determine what APIs are available to them.)
Instead, extend the original PGoauthBearerRequest (now retroactively
referred to as "v1" in the code) with a v2 subclass-style struct. When
an application implements and accepts PQAUTHDATA_OAUTH_BEARER_TOKEN_V2,
it may safely cast the base request pointer it receives in its callbacks
to v2 in order to make use of the new functionality. libpq will query
the application for a v2 hook first, then v1 to maintain backwards
compatibility, before giving up and using the builtin flow.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2BmrGg%2Bn_X2MOLgeWcj3v_M00gR8uz_D7mM8z%3DdX1JYVbg%40mail.gmail.com M doc/src/sgml/libpq.sgml
M src/interfaces/libpq/fe-auth-oauth.c
M src/interfaces/libpq/libpq-fe.h
M src/test/modules/oauth_validator/oauth_hook_client.c
M src/test/modules/oauth_validator/t/002_client.pl
M src/tools/pgindent/typedefs.list
pg_dumpall: Fix handling of conflicting options.
commit : b2898baaf7e40a187de5b0134d53d944b38209cd
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 6 Mar 2026 14:00:04 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 6 Mar 2026 14:00:04 -0600 pg_dumpall is missing checks for some conflicting options,
including those passed through to pg_dump. To fix, introduce a
new function that checks whether mutually exclusive options are
set, and use that in pg_dumpall. A similar change could likely be
made for pg_dump and pg_restore, but that is left as a future
exercise.
This is arguably a bug fix, but since this might break existing
scripts, no back-patch for now.
Author: Jian He <jian.universality@gmail.com>
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Wang Peng <215722532@qq.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CACJufxFf5%3DwSv2MsuO8iZOvpLZQ1-meAMwhw7JX5gNvWo5PDug%40mail.gmail.com M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_dump/t/001_basic.pl
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/pg_dump/t/005_pg_dump_filterfile.pl
M src/fe_utils/option_utils.c
M src/include/fe_utils/option_utils.h
Use palloc_object() and palloc_array() in more areas of the logical replication.
commit : 50ea4e09b6c2331b4cc6434fa12b43bc62de682c
author : Masahiko Sawada <msawada@postgresql.org>
date : Fri, 6 Mar 2026 10:49:50 -0800
committer: Masahiko Sawada <msawada@postgresql.org>
date : Fri, 6 Mar 2026 10:49:50 -0800 The idea is to encourage the use of newer routines across the tree, as
these offer stronger type-safety guarantees than raw palloc().
Similar work has been done in commits 1b105f9472bd, 0c3c5c3b06a3,
31d3847a37be, and 4f7dacc5b82a. This commit extends those changes to
more locations within src/backend/replication/logical/.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAHut+Pv4N7Vpxo18+NAR1r9RGvR8b0BtwTkoeCE2PfFoXgmR6A@mail.gmail.com M src/backend/replication/logical/proto.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/replication/logical/snapbuild.c
M src/backend/replication/logical/tablesync.c
M src/backend/replication/logical/worker.c
Support grouping-expression references and GROUPING() in subqueries.
commit : 415100aa62bff1402672eec4b68deef2cd436126
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 6 Mar 2026 13:40:55 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 6 Mar 2026 13:40:55 -0500 Until now, substitute_grouped_columns and its predecessor
check_ungrouped_columns intentionally did not cope with references
to GROUP BY expressions (anything more complex than a Var) within
subqueries of the query having GROUP BY. Because they didn't try to
match subexpressions of subqueries to the GROUP BY list, they'd drill
down to raw Vars of the grouping level and then fail with "subquery
uses ungrouped column from outer query". There have been remarkably
few complaints about this deficiency, so nobody ever did anything
about it.
The reason for not wanting to deal with it is that within a subquery,
Vars will have varlevelsup different from zero and will thus not be
equal() to the expressions seen in the outer query. We recognized
this at least as far back as 96ca8ffeb, although I think the comment
I added about it then was just documenting a pre-existing deficiency.
It looks like at the time, the solutions I considered were
(1) write a version of equal() that permits an offset in varlevelsup,
or (2) dynamically apply IncrementVarSublevelsUp at each
subexpression. (1) would require an amount of new code that seems
rather out of proportion to the benefit, while (2) would add an
exponential amount of cost to the matching process. But rethinking
it now, what seems attractive is (3) apply IncrementVarSublevelsUp to
the groupingClause list not the subexpressions, and do so only once
per subquery depth level. Then we can still use plain equal() to
check for matches, and we're not incurring cost proportional to some
power of the subquery's complexity.
This patch continues to use the old logic when the GROUP BY list is
all Vars. We could discard the special comparison logic for that and
always do it the more general way, but that would be a good deal
slower. (Micro-benchmarking just parse analysis suggests it's about
50% slower than the Vars-only path. But we've not heard complaints
about the speed of matching within the main query, so I doubt that
applying the same matching logic within subqueries will be a problem.)
The lack of complaints suggests strongly that this is a very minority
use-case, so I don't want to make the typical case slower to fix it.
While testing that, I was surprised to discover a nearby bug:
GROUPING() within a subquery fails to match GROUP BY Vars that are
join alias Vars. It tries to apply flatten_join_alias_vars to make
such cases work, but that fails to work inside a subquery because
varlevelsup is wrong. Therefore, this patch invents a new entry point
flatten_join_alias_for_parser() that allows specification of a
sublevels_up offset. (It seems cleaner to give the parser its own
entry point rather than abuse the planner's conventions even further.)
While this is pretty clearly a bug fix, I'm hesitant to take the risk
of back-patching, seeing that the existing behavior has stood for so
long with so few complaints. Maybe we can reconsider once this patch
has baked awhile in master.
Reported-by: PALAYRET Jacques <jacques.palayret@meteo.fr>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/531183.1772058731@sss.pgh.pa.us M src/backend/optimizer/util/var.c
M src/backend/parser/parse_agg.c
M src/include/optimizer/optimizer.h
M src/test/regress/expected/aggregates.out
M src/test/regress/expected/groupingsets.out
M src/test/regress/sql/aggregates.sql
M src/test/regress/sql/groupingsets.sql
CREATE SUBSCRIPTION ... SERVER.
commit : 8185bb53476378443240d57f7d844347d5fae1bf
author : Jeff Davis <jdavis@postgresql.org>
date : Fri, 6 Mar 2026 08:27:56 -0800
committer: Jeff Davis <jdavis@postgresql.org>
date : Fri, 6 Mar 2026 08:27:56 -0800 Allow CREATE SUBSCRIPTION to accept a foreign server using the SERVER
clause instead of a raw connection string using the CONNECTION clause.
* Enables a user with sufficient privileges to create a subscription
using a foreign server by name without specifying the connection
details.
* Integrates with user mappings (and other FDW infrastructure) using
the subscription owner.
* Provides a layer of indirection to manage multiple subscriptions
to the same remote server more easily.
Also add CREATE FOREIGN DATA WRAPPER ... CONNECTION clause to specify
a connection_function. To be eligible for a subscription, the foreign
server's foreign data wrapper must specify a connection_function.
Add connection_function support to postgres_fdw, and bump postgres_fdw
version to 1.3.
Bump catversion.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/61831790a0a937038f78ce09f8dd4cef7de7456a.camel@j-davis.com M contrib/postgres_fdw/Makefile
M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/meson.build
A contrib/postgres_fdw/postgres_fdw–1.2–1.3.sql
M contrib/postgres_fdw/postgres_fdw.control
M contrib/postgres_fdw/sql/postgres_fdw.sql
A contrib/postgres_fdw/t/010_subscription.pl
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/postgres-fdw.sgml
M doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
M doc/src/sgml/ref/alter_subscription.sgml
M doc/src/sgml/ref/create_foreign_data_wrapper.sgml
M doc/src/sgml/ref/create_server.sgml
M doc/src/sgml/ref/create_subscription.sgml
M src/backend/catalog/dependency.c
M src/backend/catalog/pg_subscription.c
M src/backend/catalog/system_views.sql
M src/backend/commands/foreigncmds.c
M src/backend/commands/subscriptioncmds.c
M src/backend/foreign/foreign.c
M src/backend/parser/gram.y
M src/backend/replication/logical/worker.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/bin/psql/describe.c
M src/bin/psql/tab-complete.in.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_foreign_data_wrapper.h
M src/include/catalog/pg_subscription.h
M src/include/foreign/foreign.h
M src/include/nodes/parsenodes.h
M src/test/regress/expected/oidjoins.out
M src/test/regress/expected/subscription.out
M src/test/regress/regress.c
M src/test/regress/sql/subscription.sql
Don't include wait_event.h in pgstat.h
commit : 868825aaeb4099081364b563e532c30c1b31cabd
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 6 Mar 2026 16:24:58 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 6 Mar 2026 16:24:58 +0100 wait_event.h itself includes wait_event_types.h, which is a generated
file, so it's nice that we can avoid compiling >10% of the tree just
because that file is regenerated.
To avoid breaking too many third-party modules, we now #include
utils/wait_classes.h in storage/latch.h. Then, the very common case
of doing
WaitLatch(..., PG_WAIT_EXTENSION)
continues to work by including just storage/latch.h. (I didn't try to
determine how many modules would actually break if we don't do this, but
this seems a convenient and low-impact measure.)
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/202602181214.gcmhx2vhlxzp@alvherre.pgsql M contrib/pg_prewarm/autoprewarm.c
M src/backend/access/brin/brin.c
M src/backend/access/gin/gininsert.c
M src/backend/access/heap/rewriteheap.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/access/nbtree/nbtree.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/transam/clog.c
M src/backend/access/transam/parallel.c
M src/backend/access/transam/slru.c
M src/backend/access/transam/timeline.c
M src/backend/access/transam/twophase.c
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogarchive.c
M src/backend/access/transam/xlogfuncs.c
M src/backend/access/transam/xlogreader.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/access/transam/xlogwait.c
M src/backend/archive/shell_archive.c
M src/backend/backup/basebackup.c
M src/backend/backup/basebackup_throttle.c
M src/backend/commands/copyfromparse.c
M src/backend/commands/copyto.c
M src/backend/commands/dbcommands.c
M src/backend/commands/vacuum.c
M src/backend/executor/nodeAppend.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/backend/libpq/be-secure-gssapi.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/libpq/pqmq.c
M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/auxprocess.c
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/bgwriter.c
M src/backend/postmaster/checkpointer.c
M src/backend/postmaster/pgarch.c
M src/backend/postmaster/syslogger.c
M src/backend/postmaster/walwriter.c
M src/backend/replication/logical/applyparallelworker.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/origin.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/logical/snapbuild.c
M src/backend/replication/logical/tablesync.c
M src/backend/replication/logical/worker.c
M src/backend/replication/slot.c
M src/backend/replication/syncrep.c
M src/backend/replication/walreceiver.c
M src/backend/replication/walreceiverfuncs.c
M src/backend/replication/walsender.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/file/buffile.c
M src/backend/storage/file/copydir.c
M src/backend/storage/file/fd.c
M src/backend/storage/ipc/dsm_impl.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/procarray.c
M src/backend/storage/ipc/procsignal.c
M src/backend/storage/ipc/shm_mq.c
M src/backend/storage/ipc/signalfuncs.c
M src/backend/storage/ipc/standby.c
M src/backend/storage/ipc/waiteventset.c
M src/backend/storage/lmgr/lwlock.c
M src/backend/storage/lmgr/predicate.c
M src/backend/storage/lmgr/proc.c
M src/backend/storage/smgr/md.c
M src/backend/storage/sync/sync.c
M src/backend/utils/adt/misc.c
M src/backend/utils/adt/pgstatfuncs.c
M src/backend/utils/cache/relmapper.c
M src/backend/utils/init/miscinit.c
M src/common/controldata_utils.c
M src/include/pgstat.h
M src/include/storage/latch.h
M src/test/modules/test_shm_mq/setup.c
M src/test/modules/test_shm_mq/test.c
M src/test/modules/worker_spi/worker_spi.c
doc: Fix capitalization of Unicode
commit : 90ca7c1429d6ebfd89300ddcf1c8da6b3e671928
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:31:35 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:31:35 +0100 Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/2a668979-ed92-49a3-abf9-a3ec2d460ec2%40eisentraut.org M doc/src/sgml/targets-meson.txt
Fix Python deprecation warning
commit : 16686a853f1b0f479fbe716acecb3a264e70c824
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:31:35 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:31:35 +0100 Starting with Python 3.14, contrib/unaccent/generate_unaccent_rules.py
complains
DeprecationWarning: codecs.open() is deprecated. Use open() instead.
This makes that change. This works for all Python 3.x versions.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/2a668979-ed92-49a3-abf9-a3ec2d460ec2%40eisentraut.org M contrib/unaccent/generate_unaccent_rules.py
Make unconstify and unvolatize use StaticAssertVariableIsOfTypeMacro
commit : 258248d0bdbf1b1818e2c6a157b17227fd000d76
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:13:58 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:13:58 +0100 The unconstify and unvolatize macros had an almost identical assertion
as was already defined in StaticAssertVariableIsOfTypeMacro, only it
had a less useful error message and didn't have a sizeof fallback.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com M src/include/c.h
Use typeof everywhere instead of compiler specific spellings
commit : e2308350c9b775c0c66099ba16af34757c6b0367
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:13:49 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 10:13:49 +0100 We define typeof ourselves as __typeof__ if it does not exist. So
let's actually use that for consistency. The meson/autoconf checks
for __builtin_types_compatible_p still use __typeof__ though, because
there we have not redefined it.
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com M src/include/c.h
Portable StaticAssertExpr
commit : aa7c86852343dd18f5834f70e4caa50ae49326c9
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 09:15:44 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 6 Mar 2026 09:15:44 +0100 Use a different way to write StaticAssertExpr() that does not require
the GCC extension statement expressions.
For C, we put the static_assert into a struct. This appears to be a
common approach.
We still need to keep the fallback implementation to support buggy
MSVC < 19.33.
For C++, we put it into a lambda expression. (The C approach doesn't
work; it's not permitted to define a new type inside sizeof.)
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/5fa3a9f5-eb9a-4408-9baf-403d281f8b10%40eisentraut.org 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
Fix publisher shutdown hang caused by logical walsender busy loop.
commit : 6eedb2a5fd88da11fab92dcde9205366f6fff82f
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 6 Mar 2026 16:43:40 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 6 Mar 2026 16:43:40 +0900 Previously, when logical replication was running, shutting down
the publisher could cause the logical walsender to enter a busy loop
and prevent the publisher from completing shutdown.
During shutdown, the logical walsender waits for all pending WAL
to be written out. However, some WAL records could remain unflushed,
causing the walsender to wait indefinitely.
The issue occurred because the walsender used XLogBackgroundFlush() to
flush pending WAL. This function does not guarantee that all WAL is written.
For example, WAL generated by a transaction without an assigned
transaction ID that aborts might not be flushed.
This commit fixes the bug by making the logical walsender call XLogFlush()
instead, ensuring that all pending WAL is written and preventing
the busy loop during shutdown.
Backpatch to all supported versions.
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAO6_Xqo3co3BuUVEVzkaBVw9LidBgeeQ_2hfxeLMQcXwovB3GQ@mail.gmail.com
Backpatch-through: 14 M src/backend/replication/walsender.c
Improve tests for recovery_target_timeline GUC.
commit : 2007df43332b7c4d153bcd2153e32d5a76f7e3ac
author : Fujii Masao <fujii@postgresql.org>
date : Fri, 6 Mar 2026 16:02:09 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Fri, 6 Mar 2026 16:02:09 +0900 Commit fd7d7b71913 added regression tests to verify recovery_target_timeline
settings. To confirm that invalid values are rejected, those tests started the
server with an invalid setting and then verified that startup failed. While
functionally correct, this approach was expensive because it required
setting up and starting the server for each test case.
This commit updates the tests for recovery_target_timeline to use
the simpler approach introduced by commit bffd7130 for recovery_target_xid,
using ALTER SYSTEM SET to verify that invalid settings are rejected.
This avoids the need to set up and start the server when checking invalid
recovery_target_timeline values.
Author: David Steele <david@pgbackrest.org>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwG44vZbSoBmg076G+xkR6n=Tj2=q+fVkfP7yEsyF1daFA@mail.gmail.com M src/test/recovery/t/003_recovery_targets.pl
Fix inconsistency with HeapTuple freeing in extended_stats_funcs.c
commit : d5ea206728de7cb301d2f572055a76d4ea43bc8d
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 14:49:00 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 14:49:00 +0900 heap_freetuple() is a thin wrapper doing a pfree(), and the function
import_pg_statistic(), introduced by ba97bf9cb7b4, had the idea to call
directly pfree() rather than the "dedicated" heap tuple routine.
upsert_pg_statistic_ext_data already uses heap_freetuple(). This code
is harmless as-is, but let's be consistent across the board.
Reported-by: Yonghao Lee <yonghao_lee@qq.com>
Discussion: https://postgr.es/m/tencent_CA1315EE8FB9C62F742C71E95FAD72214205@qq.com M src/backend/statistics/extended_stats_funcs.c
Fix order of columns in pg_stat_recovery
commit : 2d4ead6f4bd0e30df15dc0ae654c9ce573f41bed
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 14:41:41 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 14:41:41 +0900 recovery_last_xact_time is listed before current_chunk_start_time in the
documentation, the function definition and the view definition, but
their order was reversed in the code.
Thinko in 01d485b142e4. Mea culpa.
Author: Shinya Kato <shinya11.kato@gmail.com>
Discussion: https://postgr.es/m/CAOzEurQQ1naKmPJhfE5WOUQjtf5tu08Kw3QCGY5UY=7Rt9fE=w@mail.gmail.com M src/backend/access/transam/xlogfuncs.c
Fix inconsistent elevel in pg_sync_replication_slots() retry logic.
commit : f1ddaa15357fccb03dea371f8cb481ce2c5e4808
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 6 Mar 2026 10:51:32 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 6 Mar 2026 10:51:32 +0530 The commit 0d2d4a0ec3 allowed pg_sync_replication_slots() to retry sync
attempts, but missed a case, when WAL prior to a slot's
confirmed_flush_lsn is not yet flushed locally.
By changing the elevel from ERROR to LOG, we allow the sync loop to
continue. This provides the opportunity for the slot to be synchronized
once the standby catches up with the necessary WAL.
Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAFPTHDZAA+gWDntpa5ucqKKba41=tXmoXqN3q4rpjO9cdxgQrw@mail.gmail.com M doc/src/sgml/func/func-admin.sgml
M src/backend/replication/logical/slotsync.c
Add system view pg_stat_recovery
commit : 01d485b142e4c89aef79da9fd60f203c1bd4458b
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 12:37:40 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 12:37:40 +0900 This commit introduces pg_stat_recovery, that exposes at SQL level the
state of recovery as tracked by XLogRecoveryCtlData in shared memory,
maintained by the startup process. This new view includes the following
fields, that are useful for monitoring purposes on a standby, once it
has reached a consistent state (making the execution of the SQL function
possible):
- Last-successfully replayed WAL record LSN boundaries and its timeline.
- Currently replaying WAL record end LSN and its timeline.
- Current WAL chunk start time.
- Promotion trigger state.
- Timestamp of latest processed commit/abort.
- Recovery pause state.
Some of this data can already be recovered from different system
functions, but not all of it. See pg_get_wal_replay_pause_state or
pg_last_xact_replay_timestamp. This new view offers a stronger
consistency guarantee, by grabbing the recovery state for all fields
through one spinlock acquisition.
The system view relies on a new function, called pg_stat_get_recovery().
Querying this data requires the pg_read_all_stats privilege. The view
returns no rows if the node is not in recovery.
This feature originates from a suggestion I have made while discussion
the addition of a CONNECTING state to the WAL receiver's shared memory
state, because we lacked access to some of the state data. The author
has taken the time to implement it, so thanks for that.
Bump catalog version.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/CABPTF7W+Nody-+P9y4PNk37-QWuLpfUrEonHuEhrX+Vx9Kq+Kw@mail.gmail.com
Discussion: https://postgr.es/m/aW13GJn_RfTJIFCa@paquier.xyz M doc/src/sgml/monitoring.sgml
M src/backend/access/transam/xlogfuncs.c
M src/backend/catalog/system_views.sql
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/recovery/t/001_stream_rep.pl
M src/test/regress/expected/rules.out
M src/test/regress/expected/sysviews.out
M src/test/regress/sql/sysviews.sql
Refactor code retrieving string for RecoveryPauseState
commit : 42a12856a6a09e6477a8e9156cfa39cc3a8708e0
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 11:53:23 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 6 Mar 2026 11:53:23 +0900 This refactoring is going to be useful in an upcoming commit, to avoid
some code duplication with the function pg_get_wal_replay_pause_state(),
that returns a string for the recovery pause state.
Refactoring opportunity noticed while hacking on a different patch.
Discussion: https://postgr.es/m/CABPTF7W+Nody-+P9y4PNk37-QWuLpfUrEonHuEhrX+Vx9Kq+Kw@mail.gmail.com M src/backend/access/transam/xlogfuncs.c
Simplify creation of built-in functions with non-default ACLs.
commit : f95d73ed433207c4323802dc96e52f3e5553a86c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 5 Mar 2026 17:43:09 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 5 Mar 2026 17:43:09 -0500 Up to now, to create such a function, one had to make a pg_proc.dat
entry and then modify it with GRANT/REVOKE commands, which we put in
system_functions.sql. That seems a little ugly though, because it
violates the idea of having a single source of truth about the initial
contents of pg_proc, and it results in leaving dead rows in the
initial contents of pg_proc.
This patch improves matters by allowing aclitemin to work during early
bootstrap, before pg_authid has been loaded. On the same principle
that we use for early access to pg_type details, put a table of known
built-in role names into bootstrap.c, and use that in bootstrap mode.
To create a built-in function with a non-default ACL, one should write
the desired ACL list in its pg_proc.dat entry, using a simplified
version of aclitemout's notation: omit the grantor (if it is the
bootstrap superuser, which it pretty much always should be) and spell
the bootstrap superuser's name as POSTGRES, similarly to the notation
used elsewhere in src/include/catalog. This results in entries like
proacl => '{POSTGRES=X,pg_monitor=X}'
which shows that we've revoked public execute permissions and instead
granted that to pg_monitor.
In addition to fixing up pg_proc.dat entries, I got rid of some
role grants that had been stuck into system_functions.sql,
and instead put them into a new file pg_auth_members.dat;
that seems like a far less random place to put the information.
The correctness of the data changes can be verified by comparing the
initial contents of pg_proc and pg_auth_members before and after.
pg_proc should match exactly, but the OID column of pg_auth_members
will probably be different because those OIDs now get assigned a
little earlier in bootstrap. (I forced a catversion bump out of
caution, but it wasn't really necessary.)
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/183292bb-4891-4c96-a3ca-e78b5e0e1358@dunslane.net M src/backend/bootstrap/bootstrap.c
M src/backend/catalog/system_functions.sql
M src/backend/catalog/system_views.sql
M src/backend/utils/adt/acl.c
M src/include/bootstrap/bootstrap.h
M src/include/catalog/Makefile
M src/include/catalog/catversion.h
M src/include/catalog/meson.build
A src/include/catalog/pg_auth_members.dat
M src/include/catalog/pg_auth_members.h
M src/include/catalog/pg_authid.dat
M src/include/catalog/pg_proc.dat
Be more wary of false matches in initdb's replace_token().
commit : 7664319ccb0288b3b13b111b0d88ec7881f3c5bf
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 5 Mar 2026 17:22:31 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 5 Mar 2026 17:22:31 -0500 Do not replace the target string unless the occurrence is surrounded
by whitespace or line start/end. This avoids potential false match
to a substring of a field. While we've not had trouble with that
up to now, the next patch creates hazards of false matches to
POSTGRES within an ACL field.
There is one call site that needs adjustment, as it was presuming
it could write "::1" and have that match "::1/128". For all the
others, this restriction is okay and strictly safer.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/183292bb-4891-4c96-a3ca-e78b5e0e1358@dunslane.net M src/bin/initdb/initdb.c
Prefix PruneState->all_{visible,frozen} with set_
commit : 34cb4254bdb6d344e2440c721abc11196982ccd5
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 5 Mar 2026 16:54:28 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 5 Mar 2026 16:54:28 -0500 The PruneState had members called "all_visible" and "all_frozen" which
reflect not the current state of the page but the state it could be in
once pruning and freezing have been executed. These are then saved in
the PruneFreezeResult so the caller can set the VM accordingly.
Prefix the PruneState members as well as the corresponsding
PruneFreezeResult members with "set_" to clarify that they represent the
proposed state of the all-visible and all-frozen bits for a heap page in
the visibility map, not the current state.
Author: Melanie Plageman <melanieplageman@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c
M src/include/access/heapam.h
Add PageGetPruneXid() helper
commit : 68c2dcb9130e8e3bc60676909676be1567c3cd51
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 5 Mar 2026 16:22:57 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 5 Mar 2026 16:22:57 -0500 This is similar to the other page accessors in bufpage.h. It improves
readability and avoids long lines.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/BD8B69E7-26D8-4706-9164-597C6AE57812%40gmail.com M src/backend/access/heap/pruneheap.c
M src/include/storage/bufpage.h
Move commonly used context into PruneState and simplify helpers
commit : 59663e4207fdbf8ffffad0c378f0c455ce2beb06
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 5 Mar 2026 16:10:29 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 5 Mar 2026 16:10:29 -0500 heap_page_prune_and_freeze() and many of its helpers use the heap
buffer, block number, and page. Other helpers took the heap page and
didn't use it. Initializing these values once during
prune_freeze_setup() simplifies the helpers' interfaces and avoids any
repeated calls to BufferGetBlockNumber() and BufferGetPage().
While updating PruneState, also reorganize its fields to make the layout
and member documentation more consistent.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/BD8B69E7-26D8-4706-9164-597C6AE57812%40gmail.com M src/backend/access/heap/pruneheap.c
Exit after fatal errors in client-side compression code.
commit : ac0accafd6b6eef1a86a50f42346e1e926505df2
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 5 Mar 2026 14:43:21 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Thu, 5 Mar 2026 14:43:21 -0500 It looks like whoever wrote the astreamer (nee bbstreamer) code
thought that pg_log_error() is equivalent to elog(ERROR), but
it's not; it just prints a message. So all these places tried to
continue on after a compression or decompression error return,
with the inevitable result being garbage output and possibly
cascading error messages. We should use pg_fatal() instead.
These error conditions are probably pretty unlikely in practice,
which no doubt accounts for the lack of field complaints.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/1531718.1772644615@sss.pgh.pa.us
Backpatch-through: 15 M src/bin/pg_dump/compress_lz4.c
M src/fe_utils/astreamer_gzip.c
M src/fe_utils/astreamer_lz4.c
M src/fe_utils/astreamer_zstd.c
oauth: Add TLS support for oauth_validator tests
commit : a6483f5ac9680801da0c8ad207c2870c0d6a61c2
author : Jacob Champion <jchampion@postgresql.org>
date : Thu, 5 Mar 2026 10:04:53 -0800
committer: Jacob Champion <jchampion@postgresql.org>
date : Thu, 5 Mar 2026 10:04:53 -0800 The oauth_validator tests don't currently support HTTPS, which makes
testing PGOAUTHCAFILE difficult. Add a localhost certificate to
src/test/ssl and make use of it in oauth_server.py.
In passing, explain the hardcoded use of IPv4 in our issuer identifier,
after intermittent failures on NetBSD led to commit 8d9d5843b. (The new
certificate is still set up for IPv6, to make it easier to improve that
behavior in the future.)
Patch by Jonathan Gonzalez V., with some additional tests and tweaks by
me.
Author: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
Discussion: https://postgr.es/m/8a296a2c128aba924bff0ae48af2b88bf8f9188d.camel@gmail.com M src/test/modules/oauth_validator/Makefile
M src/test/modules/oauth_validator/meson.build
M src/test/modules/oauth_validator/t/001_server.pl
M src/test/modules/oauth_validator/t/OAuth/Server.pm
M src/test/modules/oauth_validator/t/oauth_server.py
A src/test/ssl/conf/server-localhost-alt-names.config
A src/test/ssl/ssl/server-localhost-alt-names.crt
A src/test/ssl/ssl/server-localhost-alt-names.key
M src/test/ssl/sslfiles.mk
libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock()
commit : b8d76858353e40f888c809eb14a974cf13bf23ab
author : Jacob Champion <jchampion@postgresql.org>
date : Thu, 5 Mar 2026 10:04:48 -0800
committer: Jacob Champion <jchampion@postgresql.org>
date : Thu, 5 Mar 2026 10:04:48 -0800 Allow libpq clients to retrieve the current pg_g_threadlock pointer with
PQgetThreadLock(). Single-threaded applications could already do this in
a convoluted way:
pgthreadlock_t tlock;
tlock = PQregisterThreadLock(NULL);
PQregisterThreadLock(tlock); /* re-register the callback */
/* use tlock */
But a generic library can't do that without potentially breaking
concurrent libpq connections.
The motivation for doing this now is the libpq-oauth plugin, which
currently relies on direct injection of pg_g_threadlock, and should
ideally not.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2BmEU_q9sr1PMmE-4rLwFN%3DOjyndDwFZvpsMU3RNJLrM9g%40mail.gmail.com
Discussion: https://postgr.es/m/CAOYmi%2B%3DMHD%2BWKD4rsTn0v8220mYfyLGhEc5EfhmtqrAb7SmC5g%40mail.gmail.com M doc/src/sgml/libpq.sgml
M src/interfaces/libpq/exports.txt
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/libpq-fe.h
oauth: Report cleanup errors as warnings on stderr
commit : f8c0b91a6063fc8066f1ed22c463417f1f611dfd
author : Jacob Champion <jchampion@postgresql.org>
date : Thu, 5 Mar 2026 10:04:36 -0800
committer: Jacob Champion <jchampion@postgresql.org>
date : Thu, 5 Mar 2026 10:04:36 -0800 Using conn->errorMessage for these "shouldn't-happen" cases will only
work if the connection itself fails. Our SSL and password callbacks
print WARNINGs when they find themselves in similar situations, so
follow their lead.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2BmEU_q9sr1PMmE-4rLwFN%3DOjyndDwFZvpsMU3RNJLrM9g%40mail.gmail.com M src/interfaces/libpq-oauth/oauth-curl.c
Fix handling of updated tuples in the MERGE statement
commit : 177037341a4414f1089748686af9ce8bd9f8d383
author : Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 5 Mar 2026 19:47:20 +0200
committer: Alexander Korotkov <akorotkov@postgresql.org>
date : Thu, 5 Mar 2026 19:47:20 +0200 This branch missed the IsolationUsesXactSnapshot() check. That led to EPQ on
repeatable read and serializable isolation levels. This commit fixes the
issue and provides a simple isolation check for that. Backpatch through v15
where MERGE statement was introduced.
Reported-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAPpHfdvzZSaNYdj5ac-tYRi6MuuZnYHiUkZ3D-AoY-ny8v%2BS%2Bw%40mail.gmail.com
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Backpatch-through: 15 M src/backend/executor/nodeModifyTable.c
M src/test/isolation/expected/merge-update.out
M src/test/isolation/specs/merge-update.spec
Improve validation of recovery_target_xid GUC values.
commit : bffd7130e942e2bd45153ab09e5fab70e74ece58
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 5 Mar 2026 21:40:32 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 5 Mar 2026 21:40:32 +0900 Previously, the recovery_target_xid GUC values were not sufficiently validated.
As a result, clearly invalid inputs such as the string "bogus", a decimal value
like "1.1", or 0 (a transaction ID smaller than the minimum valid value of 3)
were unexpectedly accepted. In these cases, the value was interpreted as
transaction ID 0, which could cause recovery to behave unexpectedly.
This commit improves validation of recovery_target_xid GUC so that invalid
values are rejected with an error. This prevents recovery from proceeding
with misconfigured recovery_target_xid settings.
Also this commit updates the documentation to clarify the allowed values
for recovery_target_xid GUC.
Author: David Steele <david@pgbackrest.org>
Reviewed-by: Hüseyin Demir <huseyin.d3r@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/f14463ab-990b-4ae9-a177-998d2677aae0@pgbackrest.org M doc/src/sgml/config.sgml
M src/backend/access/transam/xlogrecovery.c
M src/test/recovery/t/003_recovery_targets.pl
doc: Clarify that COLUMN is optional in ALTER TABLE ... ADD/DROP COLUMN.
commit : 9b0e5bd5320f95cfb35f0402c0f4bb7a1d3ecb0f
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 5 Mar 2026 12:55:52 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 5 Mar 2026 12:55:52 +0900 In ALTER TABLE ... ADD/DROP COLUMN, the COLUMN keyword is optional. However,
part of the documentation could be read as if COLUMN were required, which may
mislead users about the command syntax.
This commit updates the ALTER TABLE documentation to clearly state that
COLUMN is optional for ADD and DROP.
Also this commit adds regression tests covering ALTER TABLE ... ADD/DROP
without the COLUMN keyword.
Backpatch to all supported versions.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAEoWx2n6ShLMOnjOtf63TjjgGbgiTVT5OMsSOFmbjGb6Xue1Bw@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/alter_table.sgml
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql
Move definition of XLogRecoveryCtlData to xlogrecovery.h
commit : 5f8124a0cf33fe421b915b57dcf04fea8b7a252c
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 12:17:47 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 12:17:47 +0900 XLogRecoveryCtlData is the structure that stores the shared-memory state
of WAL recovery, including information such as promotion requests, the
timeline ID (TLI), and the LSNs of replayed records.
This refactoring is independently useful because it allows code outside
of core to access the recovery state in live. It will be used by an
upcoming patch that introduces a SQL function for querying this
information, that can be accessed on a standby once a consistent state
has been reached. This only moves code around, changing nothing
functionally.
Author: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/CABPTF7W+Nody-+P9y4PNk37-QWuLpfUrEonHuEhrX+Vx9Kq+Kw@mail.gmail.com M src/backend/access/transam/xlogrecovery.c
M src/include/access/xlogrecovery.h
Fix rare instability in recovery TAP test 004_timeline_switch
commit : ea4744782b3f9d3dd69be20f31f970bee60f5f09
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 10:05:44 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 10:05:44 +0900 This fixes a problem similar to ad8c86d22cbd. In this case, the test
could fail under the following circumstances:
- The primary is stopped with teardown_node(), meaning that it may not
be able to send all its WAL records to standby_1 and standby_2.
- If standby_2 receives more records than standby_1, attempting to
reconnect standby_2 to the promoted standby_1 would fail because of a
timeline fork.
This race condition is fixed with a simple trick: instead of tearing
down the primary, it is stopped cleanly so as all the WAL records of the
primary are received and flushed by both standby_1 and standby_2. Once
we do that, there is no need for a wait_for_catchup() before stopping
the node. The test wants to check that a timeline jump can be achieved
when reconnecting a standby to a promoted standby in the same cluster,
hence an immediate stop of the primary is not required.
This failure is harder to reach than the previous instability of
009_twophase, still the buildfarm has been able to detect this failure
at least once. I have tried Alexander Lakhin's test trick with the
bgwriter and very aggressive standby snapshots, but I could not
reproduce it directly. It is reachable, as the buildfarm has proved.
Backpatch down to all supported branches, and this problem can lead to
spurious failures in the buildfarm.
Discussion: https://postgr.es/m/493401a8-063f-436a-8287-a235d9e065fc@gmail.com
Backpatch-through: 14 M src/test/recovery/t/004_timeline_switch.pl
Change default value of default_toast_compression to "lz4", take two
commit : 34dfca293432e206b8f80431f81535aff69782ca
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 09:24:35 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 09:24:35 +0900 The default value for default_toast_compression was "pglz". The main
reason for this choice is that this option is always available, pglz
code being embedded in Postgres. However, it is known that LZ4 is more
efficient than pglz: less CPU required, more compression on average. As
of this commit, the default value of default_toast_compression becomes
"lz4", if available. By switching to LZ4 as the default, users should
see natural speedups on TOAST data reads and/or writes.
Support for LZ4 in TOAST compression was added in Postgres v14, or 5
releases ago. This should be long enough to consider this feature as
stable.
While at it, quotes are removed from default_toast_compression in
postgresql.conf.sample. Quotes are not required in this case. The
in-place value replacement done by initdb if the build supports LZ4
would not use them in the postgresql.conf file added to a
freshly-initialized cluster.
Note that this is a version lighter than 7c1849311e49, that included a
replacement of --with-lz4 by --without-lz4 in configure builds, forcing
a requirement for LZ4 in all environments. The buildfarm did not like
it, at all. This commit switches default_toast_compression to lz4 as
default only when --with-lz4 is defined, which should keep the buildfarm
at bay while still allowing users to benefit from LZ4 compression in
TOAST as long as the code is compiled with it.
Author: Euler Taveira <euler@eulerto.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://posgr.es/m/435df33a-129e-4f0c-a803-f3935c5a5ecb@eisentraut.org M doc/src/sgml/config.sgml
M src/backend/access/common/toast_compression.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/bin/initdb/initdb.c
M src/include/access/toast_compression.h
Revert "Change default value of default_toast_compression to "lz4""
commit : 4f0b3afab4da87255ee159b96ba531157ee5af3b
author : Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 08:25:35 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Thu, 5 Mar 2026 08:25:35 +0900 This reverts commit 7c1849311e49, due to the fact that more than 60% of
the buildfarm members do not have lz4 installed. As we are in the last
commit fest of the development cycle, and that it could take a couple
of weeks to stabilize things, this change is reverted for now.
This commit will be reworked in a lighter version, as
default_toast_compression's default can be changed to "lz4" without the
switch from --with-lz4 to --without-lz4. This approach will keep the
buildfarm at bay, and still allow builds to take advantage of LZ4 in
TOAST by default, as long as the code is compiled with LZ4 support.
A harder requirement based on LZ4 should be achievable at some point,
but it is going to require some work from the buildfarm owners first.
Perhaps this part could be revisited at the beginning of the next
development cycle.
Discussion: https://postgr.es/m/CAOYmi+meTT0NbLbnVqOJD5OKwCtHL86PQ+RZZTrn6umfmHyWaw@mail.gmail.com M .cirrus.tasks.yml
M configure
M configure.ac
M doc/src/sgml/config.sgml
M doc/src/sgml/installation.sgml
M doc/src/sgml/ref/alter_table.sgml
M doc/src/sgml/ref/create_table.sgml
M doc/src/sgml/ref/pg_receivewal.sgml
M src/backend/access/common/toast_compression.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/bin/initdb/initdb.c
M src/include/access/toast_compression.h
pg_restore: add --no-globals option to skip globals
commit : 3c19983cc0816001ad849a9f0bcaf2ea8321b93d
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 27 Feb 2026 08:07:10 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 27 Feb 2026 08:07:10 -0500 This is a followup to commit 763aaa06f03 Add non-text output formats to
pg_dumpall.
Add a --no-globals option to pg_restore that skips restoring global
objects (roles and tablespaces) when restoring from a pg_dumpall
archive. When -C/--create is not specified, databases that do not
already exist on the target server are also skipped.
This is useful when restoring only specific databases from a pg_dumpall
archive without needing the global objects to be restored first.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
With small tweaks by me.
Discussion: https://postgr.es/m/CAKYtNArdcc5kx1MdTtTKFNYiauo3=zCA-NB0LmBCW-RU_kSb3A@mail.gmail.com M doc/src/sgml/ref/pg_restore.sgml
M src/bin/pg_dump/pg_restore.c
M src/bin/pg_dump/t/001_basic.pl
M src/bin/pg_dump/t/007_pg_dumpall.pl
Improve writing map.dat preamble
commit : c7572cd48d393d16b57461cf954ae06c084ca2ee
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 4 Mar 2026 16:08:04 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 4 Mar 2026 16:08:04 -0500 Fix code from commit 763aaa06f03
Suggestion from Alvaro Herrera following a bug discovered by Coverity. M src/bin/pg_dump/pg_dumpall.c
Fix casting away const-ness in pg_restore.c
commit : 01c729e0c7a5899b841e596147381f5437ab8aab
author : Andrew Dunstan <andrew@dunslane.net>
date : Wed, 4 Mar 2026 15:44:45 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Wed, 4 Mar 2026 15:44:45 -0500 This was intoduced in commit 763aaa06f03
per gripe from Peter Eistentrut.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Slightly tweaked by me.
Discussion: https://postgr.es/m/016819c0-666e-42a8-bfc8-2b93fd8d0176@eisentraut.org M src/bin/pg_dump/pg_restore.c
Fix estimate_hash_bucket_stats's correction for skewed data.
commit : e6a1d8f5acbc661d3165d92d0cc1ff6b8f997f16
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 4 Mar 2026 15:33:15 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 4 Mar 2026 15:33:15 -0500 The previous idea was "scale up the bucketsize estimate by the ratio
of the MCV's frequency to the average value's frequency". But we
should have been suspicious of that plan, since it frequently led to
impossible (> 1) values which we had to apply an ad-hoc clamp to.
Joel Jacobson demonstrated that it sometimes leads to making the
wrong choice about which side of the hash join should be inner.
Instead, drop the whole business of estimating average frequency, and
just clamp the bucketsize estimate to be at least the MCV's frequency.
This corresponds to the bucket size we'd get if only the MCV appears
in a bucket, and the MCV's frequency is not affected by the
WHERE-clause filters. (We were already making the latter assumption.)
This also matches the coding used since 4867d7f62 in the case where
only a default ndistinct estimate is available.
Interestingly, this change affects no existing regression test cases.
Add one to demonstrate that it helps pick the smaller table to be
hashed when the MCV is common enough to affect the results.
This leaves estimate_hash_bucket_stats not considering the effects of
null join keys at all, which we should probably improve. However,
I have a different patch in the queue that will change the executor's
handling of null join keys, so it seems appropriate to wait till
that's in before doing anything more here.
Reported-by: Joel Jacobson <joel@compiler.org>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Joel Jacobson <joel@compiler.org>
Discussion: https://postgr.es/m/341b723c-da45-4058-9446-1514dedb17c1@app.fastmail.com M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql
Fix yet another bug in archive streamer with LZ4 decompression.
commit : c70f6dc6bd793cca86c734865914a031ef88240f
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 4 Mar 2026 12:08:37 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 4 Mar 2026 12:08:37 -0500 The code path in astreamer_lz4_decompressor_content() that updated
the output pointers when the output buffer isn't full was wrong.
It advanced next_out by bytes_written, which could include previous
decompression output not just that of the current cycle. The
correct amount to advance is out_size. While at it, make the
output pointer updates look more like the input pointer updates.
This bug is pretty hard to reach, as it requires consecutive
compression frames that are too small to fill the output buffer.
pg_dump could have produced such data before 66ec01dc4, but
I'm unsure whether any files we use astreamer with would be
likely to contain problematic data.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/0594CC79-1544-45DD-8AA4-26270DE777A7@gmail.com
Backpatch-through: 15 M src/fe_utils/astreamer_lz4.c
Don't malloc(0) in EventTriggerCollectAlterTSConfig
commit : ce4fbe1ac6e9eeae08a825b7ce09efec3614632f
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 4 Mar 2026 15:04:53 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Wed, 4 Mar 2026 15:04:53 +0100 Author: Florin Irion <florin.irion@enterprisedb.com>
Discussion: https://postgr.es/m/c6fff161-9aee-4290-9ada-71e21e4d84de@gmail.com M src/backend/commands/event_trigger.c
M src/test/modules/test_ddl_deparse/Makefile
A src/test/modules/test_ddl_deparse/expected/textsearch.out
M src/test/modules/test_ddl_deparse/meson.build
A src/test/modules/test_ddl_deparse/sql/textsearch.sql
Allow table exclusions in publications via EXCEPT TABLE.
commit : fd366065e06ae953c4f2d973d5c5f0474f3b87b6
author : Amit Kapila <akapila@postgresql.org>
date : Wed, 4 Mar 2026 15:55:01 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Wed, 4 Mar 2026 15:55:01 +0530 Extend CREATE PUBLICATION ... FOR ALL TABLES to support the EXCEPT TABLE
syntax. This allows one or more tables to be excluded. The publisher will
not send the data of excluded tables to the subscriber.
To support this, pg_publication_rel now includes a prexcept column to flag
excluded relations. For partitioned tables, the exclusion is applied at
the root level; specifying a root table excludes all current and future
partitions in that tree.
Follow-up work will implement ALTER PUBLICATION support for managing these
exclusions.
Author: vignesh C <vignesh21@gmail.com>
Author: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Discussion: https://postgr.es/m/CALDaNm3=JrucjhiiwsYQw5-PGtBHFONa6F7hhWCXMsGvh=tamA@mail.gmail.com M doc/src/sgml/catalogs.sgml
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/create_publication.sgml
M doc/src/sgml/ref/psql-ref.sgml
M src/backend/catalog/pg_publication.c
M src/backend/commands/publicationcmds.c
M src/backend/commands/tablecmds.c
M src/backend/parser/gram.y
M src/backend/replication/pgoutput/pgoutput.c
M src/backend/utils/cache/relcache.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/psql/describe.c
M src/bin/psql/tab-complete.in.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_publication.h
M src/include/catalog/pg_publication_rel.h
M src/include/nodes/parsenodes.h
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql
M src/test/subscription/meson.build
A src/test/subscription/t/037_except.pl
Add test for row-locking and multixids with prepared transactions
commit : fe08113aefc9dec62f218d5d712dde4ffbb0f0a3
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 4 Mar 2026 11:29:02 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 4 Mar 2026 11:29:02 +0200 This is a repro for the issue fixed in commit ccae90abdb. Backpatch to
v17 like that commit, although that's a little arbitrary as this test
would work on older versions too.
Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAA5RZ0twq5bNMq0r0QNoopQnAEv+J3qJNCrLs7HVqTEntBhJ=g@mail.gmail.com
Backpatch-through: 17 M src/test/regress/expected/prepared_xacts.out
M src/test/regress/sql/prepared_xacts.sql
Skip prepared_xacts test if max_prepared_transactions < 2
commit : 19615a44b3e633a94aaae712c5c448e69d4996b2
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 4 Mar 2026 11:06:43 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Wed, 4 Mar 2026 11:06:43 +0200 This reduces maintenance overhead, as we no longer need to update the
dummy expected output file every time the .sql file changes.
Discussion: https://www.postgresql.org/message-id/1009073.1772551323@sss.pgh.pa.us
Backpatch-through: 14 M src/test/regress/expected/prepared_xacts.out
M src/test/regress/expected/prepared_xacts_1.out
M src/test/regress/sql/prepared_xacts.sql
Fix rare instability in recovery TAP test 009_twophase
commit : ad8c86d22cbd043cfb48cc3c18e43c4f267b2eb0
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 4 Mar 2026 16:30:51 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 4 Mar 2026 16:30:51 +0900 The phase of the test where we want to check that 2PC transactions
prepared on a primary can be committed on a promoted standby relied on
an immediate stop of the primary. This logic has a race condition: it
could be possible that some records (most likely standby snapshot
records) are generated on the primary before it finishes its shutdown,
without the promoted standby know about them. When the primary is
recycled as new standby, the test could fail because of a timeline fork
as an effect of these extra records.
This fix takes care of the instability by doing a clean stop of the
primary instead of a teardown (aka immediate stop), so as all records
generated on the primary are sent to the promoted standby and flushed
there. There is no need for a teardown of the primary in this test
scenario: the commit of 2PC transactions on a promoted standby do not
care about the state of the primary, only of the standby.
This race is very hard to hit in practice, even slow buildfarm members
like skink have a very low rate of reproduction. Alexander Lakhin has
come up with a recipe to improve the reproduction rate a lot:
- Enable -DWAL_DEBUG.
- Patch the bgwriter so as standby snapshots are generated every
milliseconds.
- Run 009_twophase tests under heavy parallelism.
With this method, the failure appears after a couple of iterations.
With the fix in place, I have been able to run more than 50 iterations
of the parallel test sequence, without seeing a failure.
Issue introduced in 30820982b295, due to a copy-pasto coming from the
surrounding tests. Thanks also to Hayato Kuroda for digging into the
details of the failure. He has proposed a fix different than the one of
this commit. Unfortunately, it relied on injection points, feature only
available in v17. The solution of this commit is simpler, and can be
applied to v14~v16.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/b0102688-6d6c-c86a-db79-e0e91d245b1a@gmail.com
Backpatch-through: 14 M src/test/recovery/t/009_twophase.pl
Change default value of default_toast_compression to "lz4", when available
commit : 7c1849311e49ec57cb86b32a9aa630456588c3f0
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 4 Mar 2026 13:05:31 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 4 Mar 2026 13:05:31 +0900 The default value for default_toast_compression was "pglz". The main
reason for this choice is that this option is always available, pglz
code being embedded in Postgres. However, it is known that LZ4 is more
efficient than pglz: less CPU required, more compression on average. As
of this commit, the default value of default_toast_compression becomes
"lz4", if available. By switching to LZ4 as the default, users should
see natural speedups on TOAST data reads and/or writes.
Support for LZ4 in TOAST compression was added in Postgres v14, or 5
releases ago. This should be long enough to consider this feature as
stable.
--with-lz4 is removed, replaced by a --without-lz4 to disable LZ4 in the
builds on an option-basis, following a practice similar to readline or
ICU. References to --with-lz4 are removed from the documentation.
While at it, quotes are removed from default_toast_compression in
postgresql.conf.sample. Quotes are not required in this case. The
in-place value replacement done by initdb if the build supports LZ4
would not use them in the postgresql.conf file added to a
freshly-initialized cluster.
For the reference, a similar switch has been done with ICU in
fcb21b3acdcb. Some of the changes done in this commit are consistent
with that.
Note: this is going to create some disturbance in the buildfarm, in
environments where lz4 is not installed.
Author: Euler Taveira <euler@eulerto.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>
Discussion: https://posgr.es/m/435df33a-129e-4f0c-a803-f3935c5a5ecb@eisentraut.org M .cirrus.tasks.yml
M configure
M configure.ac
M doc/src/sgml/config.sgml
M doc/src/sgml/installation.sgml
M doc/src/sgml/ref/alter_table.sgml
M doc/src/sgml/ref/create_table.sgml
M doc/src/sgml/ref/pg_receivewal.sgml
M src/backend/access/common/toast_compression.c
M src/backend/utils/misc/guc_parameters.dat
M src/backend/utils/misc/postgresql.conf.sample
M src/bin/initdb/initdb.c
M src/include/access/toast_compression.h
Remove redundant restriction checks in apply_child_basequals
commit : 1f4f87d79436cd04d549b3ad0a141a7a3adca28c
author : Richard Guo <rguo@postgresql.org>
date : Wed, 4 Mar 2026 10:57:43 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 4 Mar 2026 10:57:43 +0900 In apply_child_basequals, after translating a parent relation's
restriction quals for a child relation, we simplify each child qual by
calling eval_const_expressions. Historically, the code then called
restriction_is_always_false and restriction_is_always_true to reduce
NullTest quals that are provably false or true.
However, since commit e2debb643, the planner natively performs
NullTest deduction during constant folding. Therefore, calling
restriction_is_always_false and restriction_is_always_true immediately
afterward is redundant and wastes CPU cycles. We can safely remove
them and simply rely on the constant folding to handle the deduction.
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAMbWs4-vLmGXaUEZyOMacN0BVfqWCt2tM-eDVWdDfJnOQaauGg@mail.gmail.com M src/backend/optimizer/util/inherit.c
M src/backend/optimizer/util/relnode.c
Remove obsolete SAMESIGN macro
commit : ce1c17a3163fa5adaa7c6af90bb1b0164cc7a28f
author : Richard Guo <rguo@postgresql.org>
date : Wed, 4 Mar 2026 10:56:06 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 4 Mar 2026 10:56:06 +0900 The SAMESIGN macro was historically used as a helper for manual
integer overflow checks. However, since commit 4d6ad3125 introduced
overflow-aware integer operations, this manual sign-checking logic is
no longer necessary.
The macro remains defined in brin_minmax_multi.c and timestamp.c, but
is not used in either file. This patch removes these definitions to
clean things up.
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAMbWs4-NL3J3hQ3LzrwV-YUkQC18P+jM7ZiegQyAHzgdZev2qg@mail.gmail.com M src/backend/access/brin/brin_minmax_multi.c
M src/backend/utils/adt/timestamp.c
Add some tests for CREATE OR REPLACE VIEW with column additions
commit : 9ef6381829cb92a23ed7730335a669cb16af3580
author : Michael Paquier <michael@paquier.xyz>
date : Wed, 4 Mar 2026 09:55:58 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Wed, 4 Mar 2026 09:55:58 +0900 When working on an already-defined view with matching attributes, CREATE
OR REPLACE VIEW would internally generate an ALTER TABLE command with a
set of AT_AddColumnToView sub-commands, one for each attribute added.
Such a command is stored in event triggers twice:
- Once as a simple command.
- Once as an ALTER TABLE command, as it has sub-commands.
There was no test coverage to track this command pattern in terms of
event triggers and DDL deparsing:
- For the test module test_ddl_deparse, two command notices are issued.
- For event triggers, a CREATE VIEW command is logged twice, which may
look a bit weird first, but again this maps with the internal behavior
of how the commands are built, and how the event trigger code reacts in
terms of commands gathered.
While on it, this adds a test for CREATE SCHEMA with a CREATE VIEW
command embedded in it, case supported by the grammar but not covered
yet.
This hole in the test coverage has been found while digging into what
would be a similar behavior for sequences if adding attributes to them
with ALTER TABLE variants, after the initial relation creation.
Discussion: https://postgr.es/m/aaFG9bqkEn0RhLJG@paquier.xyz M src/test/modules/test_ddl_deparse/expected/create_view.out
M src/test/modules/test_ddl_deparse/sql/create_view.sql
M src/test/regress/expected/event_trigger.out
M src/test/regress/sql/event_trigger.sql
Add read_stream_{pause,resume}()
commit : 38229cb905165fe676ab8728cb9dd0833a5534ed
author : Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 3 Mar 2026 15:55:52 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Tue, 3 Mar 2026 15:55:52 -0500 Read stream users can now pause lookahead when no blocks are currently
available. After resuming, subsequent read_stream_next_buffer() calls
continue lookahead with the previous lookahead distance.
This is especially useful for read stream users with self-referential
access patterns (where consuming already-read buffers can produce
additional block numbers).
Author: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGJLT2JvWLEiBXMbkSSc5so_Y7%3DN%2BS2ce7npjLw8QL3d5w%40mail.gmail.com M src/backend/storage/aio/read_stream.c
M src/include/storage/read_stream.h
doc: Add restart on failure to example systemd file
commit : b30656ce0071806ce649f2b69a4d06018d5c01a4
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 3 Mar 2026 13:13:45 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 3 Mar 2026 13:13:45 +0100 The documentation previously had a systemd unit file that would not
attempt to recover from process failures such as OOM's, segfaults,
etc. This commit adds "Restart=on-failure",` which tells systemd to
attempt to restart the process after failure. This is the recommended
configuration per the systemd documentation: "Setting this to
on-failure is the recommended choice for long-running services". Many
PostgreSQL users will simply copy/paste what the PostgreSQL
documentation recommends and will probably do their own research and
change the service file to restart on failure, so might as well set
this as the default in the PostgreSQL documentation.
Author: Andrew Jackson <andrewjackson947@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAKK5BkFfMpAQnv8CLs%3Di%3DrZwurtCV_gmfRb0uZi-V%2Bd6wcryqg%40mail.gmail.com M doc/src/sgml/runtime.sgml
Reduce scope of for-loop-local variables to avoid shadowing
commit : cece37c9843c980b5be2f6d24c2b9cef1f9429a7
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 3 Mar 2026 11:19:23 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 3 Mar 2026 11:19:23 +0100 Adjust a couple of for-loops where a local variable was shadowed by
another in the same scope, by renaming it as well as reducing its scope
to the containing for-loop.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com M src/backend/backup/basebackup_incremental.c
M src/backend/parser/parse_target.c
Reduce the scope of volatile qualifiers
commit : f2d7570cdde75fd67acb279063b2701806662035
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 3 Mar 2026 10:01:44 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 3 Mar 2026 10:01:44 +0100 Commit c66a7d75e652 introduced a new "cast discards ‘volatile’"
warning (-Wcast-qual) in vac_truncate_clog().
Instead of making use of unvolatize(), remove the warning by reducing the
scope of the volatile qualifier (added in commit 2d2e40e3bef) to only
2 fields.
Also do the same for vac_update_datfrozenxid(), since the intent of
commit f65ab862e3b was to prevent the same kind of race condition that
commit 2d2e40e3bef was fixing.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aZ3a%2BV82uSfEjDmD%40ip-10-97-1-34.eu-west-3.compute.internal M src/backend/commands/vacuum.c
Add COPY (on_error set_null) option
commit : 2a525cc97e19868940c533787165bc7e7de3a80a
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 3 Mar 2026 07:23:38 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 3 Mar 2026 07:23:38 +0100 If ON_ERROR SET_NULL is specified during COPY FROM, any data type
conversion errors will result in the affected column being set to a
null value. A column's not-null constraints are still enforced, and
attempting to set a null value in such columns will raise a constraint
violation error. This applies to a column whose data type is a domain
with a NOT NULL constraint.
Author: Jian He <jian.universality@gmail.com>
Author: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: "David G. Johnston" <david.g.johnston@gmail.com>
Reviewed-by: Yugo NAGATA <nagata@sraoss.co.jp>
Reviewed-by: torikoshia <torikoshia@oss.nttdata.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Atsushi Torikoshi <torikoshia@oss.nttdata.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/CAKFQuwawy1e6YR4S%3Dj%2By7pXqg_Dw1WBVrgvf%3DBP3d1_aSfe_%2BQ%40mail.gmail.com M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/copy.sgml
M src/backend/commands/copy.c
M src/backend/commands/copyfrom.c
M src/backend/commands/copyfromparse.c
M src/bin/psql/tab-complete.in.c
M src/include/commands/copy.h
M src/include/commands/copyfrom_internal.h
M src/test/regress/expected/copy2.out
M src/test/regress/sql/copy2.sql
doc: Fix sentence of pg_walsummary page
commit : a1bd0c16157b71938f7bac118ff85b48902d8cc8
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 3 Mar 2026 15:27:50 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 3 Mar 2026 15:27:50 +0900 Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Discussion: https://postgr.es/m/CAHut+PvfYBL-ppX-i8DPeRu7cakYCZz+QYBhrmQzicx7z_Tj5w@mail.gmail.com
Backpatch-through: 17 M doc/src/sgml/ref/pg_walsummary.sgml
doc: Clarify that empty COMMENT string removes the comment.
commit : bae42a54e3dfb935e55f54c0ff350bdfd4503815
author : Fujii Masao <fujii@postgresql.org>
date : Tue, 3 Mar 2026 14:45:52 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Tue, 3 Mar 2026 14:45:52 +0900 Clarify the documentation of COMMENT ON to state that specifying an empty
string is treated as NULL, meaning that the comment is removed.
This makes the behavior explicit and avoids possible confusion about how
empty strings are handled.
Also adds regress test cases that use empty string to remove a comment.
Backpatch to all supported versions.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Reviewed-by: Shengbin Zhao <zshengbin91@gmail.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: zhangqiang <zhang_qiang81@163.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/26476097-B1C1-4BA8-AA92-0AD0B8EC7190@gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/comment.sgml
M src/test/regress/expected/create_index.out
M src/test/regress/expected/create_role.out
M src/test/regress/sql/create_index.sql
M src/test/regress/sql/create_role.sql
Add support for "exprs" in pg_restore_extended_stats()
commit : ba97bf9cb7b4ca184ab669569be2633a46cfdd0c
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 3 Mar 2026 14:19:54 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 3 Mar 2026 14:19:54 +0900 This commit adds support for the restore of extended statistics of the
kind "exprs", counting for the statistics data computed for expressions.
The input format consists of a jsonb object which must be an array of
objects which are keyed by statistics parameter names, like this:
[{"stat_type1": "...", "stat_type2": "...", ...},
{"stat_type1": "...", "stat_type2": "...", ...}, ...]
The outer array must have as many elements as there are expressions
defined in the statistics object, mapping with the way extended
statistics are built with one pg_statistic tuple stored for each
expression whose statistics have been computed. The elements of the
array must be either objects or null values (equivalent of invalid data,
case also supported by the stats computations when its data is inserted
in the catalogs).
The keys of the inner objects are names of the statistical columns in
pg_stats_ext_exprs (i.e. everything after "inherited"). Not all
parameter keys need to be provided, those omitted being silently
ignored. Key values that do not match a statistical column name will
cause a warning to be issued, but do not otherwise fail the expression
or the import as a whole.
The expected value type for all parameters is jbvString, which allows
us to validate the values using the input function specific to that
parameter. Any parameters with a null value are silently ignored, same
as if they were not provided in the first place.
This commit includes a battery of test cases:
- Sanity checks for what-should-be-all the failures in restore code
paths, including parsing errors, parameter sanity checks depending on
the extended stats object definition, etc.
- Value injection, for scalar, array, range, multi-range cases.
- Stats data cloning, with differential checks between the source
relation and its target. The source and the target should hold the same
stats data after restore.
- While expressions are supported in extended statistics since v14,
range_length_histogram, range_empty_frac, and range_bounds_histogram
have been added to pg_stat_ext_exprs only in v19. A test case has been
added to emulate a dump taken from v18, with expression stats restored
for a range data type where these three fields are NULL.
Support for pg_dump is included, with expressions supported since v14,
inherited since v15, and data for range types in expressions in v19.
pg_upgrade is the main use-case of this feature; it is also possible to
inject statistics, same as for the other extstat kinds.
As of this commit, ANALYZE should not be required after pg_upgrade when
the cluster upgrading from uses extended statistics, as MCV,
dependencies, expressions and ndistinct stats are all covered. The
stats data related to range types used in expressions requires v19,
whose support has also been added.
Author: Corey Huinker <corey.huinker@gmail.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CADkLM=fPcci6oPyuyEZ0F4bWqAA7HzaWO+ZPptufuX5_uWt6kw@mail.gmail.com M doc/src/sgml/func/func-admin.sgml
M src/backend/statistics/extended_stats_funcs.c
M src/bin/pg_dump/pg_dump.c
M src/test/regress/expected/stats_import.out
M src/test/regress/sql/stats_import.sql
style: define parameterless functions as foo(void).
commit : 11171fe1fc833c279f78e922c7f4b98c063b932b
author : Jeff Davis <jdavis@postgresql.org>
date : Mon, 2 Mar 2026 20:12:38 -0800
committer: Jeff Davis <jdavis@postgresql.org>
date : Mon, 2 Mar 2026 20:12:38 -0800 Change pg_icu_unicode_version() to pg_icu_unicode_version(void),
introduced by commit af2d4ca191. See commit 9b05e2ec08, which fixed
similar cases.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aaEhpwrj1FY/8/7n@ip-10-97-1-34.eu-west-3.compute.internal M src/backend/utils/adt/pg_locale.c
Fix local-variable shadowing in pg_trgm's printSourceNFA().
commit : cdaa67565867ba443afb66b9e82023d65487dc7c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 2 Mar 2026 14:40:29 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 2 Mar 2026 14:40:29 -0500 We hadn't noticed this violation of -Wshadow=compatible-local
because this function isn't compiled without -DTRGM_REGEXP_DEBUG.
As long as we have to clean it up, let's do so by converting all
this function's loops to use C99 loop-local control variables.
Reported-by: Sergei Kornilov <sk@zsrv.org>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3009911772478436@08341ecb-668d-43a9-af4d-b45f00c72521 M contrib/pg_trgm/trgm_regexp.c
Add commit 7b24959434 to .git-blame-ignore-revs.
commit : f191dc676632614ea1c74616f457096114f9fa29
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 2 Mar 2026 13:23:28 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 2 Mar 2026 13:23:28 -0600 M .git-blame-ignore-revs
basic_archive: Allow archive directory to be missing at startup.
commit : cc774c543b23e91175642a65559aae456f17d89e
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 2 Mar 2026 13:12:25 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 2 Mar 2026 13:12:25 -0600 Presently, the GUC check hook for basic_archive.archive_directory
checks that the specified directory exists. Consequently, if the
directory does not exist at server startup, archiving will be stuck
indefinitely, even if it appears later. To fix, remove this check
from the hook so that archiving will resume automatically once the
directory is present. basic_archive must already be prepared to
deal with the directory disappearing at any time, so no additional
special handling is required.
Reported-by: Олег Самойлов <splarv@ya.ru>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Sergei Kornilov <sk@zsrv.org>
Discussion: https://postgr.es/m/73271769675212%40mail.yandex.ru
Backpatch-through: 15 M contrib/basic_archive/basic_archive.c
Fix OldestMemberMXactId and OldestVisibleMXactId array usage
commit : ccae90abdbb61b43b4cb0625f8677f1ad079c61c
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 2 Mar 2026 19:19:22 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Mon, 2 Mar 2026 19:19:22 +0200 Commit ab355e3a88 changed how the OldestMemberMXactId array is
indexed. It's no longer indexed by synthetic dummyBackendId, but with
ProcNumber. The PGPROC entries for prepared xacts come after auxiliary
processes in the allProcs array, which rendered the calculation for
MaxOldestSlot and the indexes into the array incorrect. (The
OldestVisibleMXactId array is not used for prepared xacts, and thus
never accessed with ProcNumber's greater than MaxBackends, so this
only affects the OldestMemberMXactId array.)
As a result, a prepared xact would store its value past the end of the
OldestMemberMXactId array, overflowing into the OldestVisibleMXactId
array. That could cause a transaction's row lock to appear invisible
to other backends, or other such visibility issues. With a very small
max_connections setting, the store could even go beyond the
OldestVisibleMXactId array, stomping over the first element in the
BufferDescriptor array.
To fix, calculate the array sizes more precisely, and introduce helper
functions to calculate the array indexes correctly.
Author: Yura Sokolov <y.sokolov@postgrespro.ru>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/7acc94b0-ea82-4657-b1b0-77842cb7a60c@postgrespro.ru
Backpatch-through: 17 M src/backend/access/transam/multixact.c
M src/backend/access/transam/twophase.c
M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h
psql: Tab-complete ALTER ROLE ... IN DATABASE SET/RESET
commit : 344b572e3eff620ffc2e3680730103e33a502bc6
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 2 Mar 2026 18:03:44 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Mon, 2 Mar 2026 18:03:44 +0100 Detailed completion of the RESET clause is still missing. Not sure a
detailed implementation is worth the trouble.
Author: Ian Lawrence Barwick <barwick@gmail.com>
Author: Vasuki M <vasukianand0119@gmail.com>
Reviewed-by: zengman <zengman@halodbtech.com>
Reviewed-by: Dharin Shah <dharinshah95@gmail.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Discussion: https://postgr.es/m/CAB8KJ=iH_v1YB2ss1A=BqvOAf28OVYiWRqUdE6TJ3pP-RdsPig@mail.gmail.com M src/bin/psql/tab-complete.in.c
In pg_dumpall, don't skip role GRANTs with dangling grantor OIDs.
commit : 74b4438a70b9a2ea654501ce061ae7dea1e6a2ea
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 2 Mar 2026 11:14:58 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 2 Mar 2026 11:14:58 -0500 In commits 29d75b25b et al, I made pg_dumpall's dumpRoleMembership
logic treat a dangling grantor OID the same as dangling role and
member OIDs: print a warning and skip emitting the GRANT. This wasn't
terribly well thought out; instead, we should handle the case by
emitting the GRANT without the GRANTED BY clause. When the source
database is pre-v16, such cases are somewhat expected because those
versions didn't prevent dropping the grantor role; so don't even
print a warning that we did this. (This change therefore restores
pg_dumpall's pre-v16 behavior for these cases.) The case is not
expected in >= v16, so then we do print a warning, but soldiering on
with no GRANTED BY clause still seems like a reasonable strategy.
Per complaint from Robert Haas that we were now dropping GRANTs
altogether in easily-reachable scenarios.
Reported-by: Robert Haas <robertmhaas@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA+TgmoauoiW4ydDhdrseg+DD4Kwha=+TSZp18BrJeHKx3o1Fdw@mail.gmail.com
Backpatch-through: 16 M src/bin/pg_dump/pg_dumpall.c
Save prune cycles by consistently clearing prune hints on all-visible pages
commit : 8b9d42bf6bd29b855a6bee21aa6010c070980086
author : Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 2 Mar 2026 11:05:59 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Mon, 2 Mar 2026 11:05:59 -0500 All-visible pages can't contain prunable tuples. We already clear the
prune hint (pd_prune_xid) during pruning of all-visible pages, but we
were not doing so in vacuum phase three, nor initializing it for
all-frozen pages created by COPY FREEZE, and we were not clearing it on
standbys.
Because page hints are not WAL-logged, pages on a standby carry stale
pd_prune_xid values. After promotion, that stale hint triggers
unnecessary on-access pruning.
Fix this by clearing the prune hint everywhere we currently mark a heap
page all-visible. Clearing it when setting PD_ALL_VISIBLE ensures no
extra overhead.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/flat/CAAKRu_b-BMOyu0X-0jc_8bWNSbQ5K6JTEueayEhcQuw-OkCSKg%40mail.gmail.com M src/backend/access/heap/heapam.c
M src/backend/access/heap/heapam_xlog.c
M src/backend/access/heap/vacuumlazy.c
Support using copyObject in standard C++
commit : 1887d822f1428637c935b9f5e8be4a2a56fb77c7
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 2 Mar 2026 11:46:02 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 2 Mar 2026 11:46:02 +0100 Calling copyObject in C++ without GNU extensions (e.g. when using
-std=c++11 instead of -std=gnu++11) fails with an error like this:
error: use of undeclared identifier 'typeof'; did you mean 'typeid'
This is due to the C compiler used to compile PostgreSQL supporting
typeof, but that function actually not being present in the C++
compiler. This fixes that by explicitely checking for typeof support
in C++, and then either use that or define typeof ourselves as:
std::remove_reference_t<decltype(x)>
According to the paper that led to adding typeof to the C standard,
that's the C++ equivalent of the C typeof:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2927.htm#existing-decltype
Author: Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/DGPW5WCFY7WY.1IHCDNIVVT300%2540jeltef.nl 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
M src/test/modules/test_cplusplusext/test_cplusplusext.cpp
Check for memset_explicit() and explicit_memset()
commit : 386ca3908de28dd882a62b8f97a329db07b23138
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 2 Mar 2026 07:47:42 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 2 Mar 2026 07:47:42 +0100 We can use either of these to implement a missing explicit_bzero().
explicit_memset() is supported on NetBSD. NetBSD hitherto didn't have
a way to implement explicit_bzero() other than the fallback variant.
memset_explicit() is the C23 standard, so we use it as first
preference. It is currently supported on:
- NetBSD 11
- FreeBSD 15
- glibc 2.43
It doesn't provide additional coverage, but as it's the new standard,
its availability will presumably grow.
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/c4701776-8d99-41da-938d-88528a3adc15%40eisentraut.org M configure
M configure.ac
M meson.build
M src/include/pg_config.h.in
M src/port/explicit_bzero.c
Remove WAL page header flag XLP_BKP_REMOVABLE
commit : f68d7e7483d240d8c92b8fc245a3a10199d426dd
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 14:13:05 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 14:13:05 +0900 There are no known users of this flag. The last supposed user was
pglesslog, which is the reason why this flag has been introduced in
core, based on an historical search pointing at a8d539f12498.
I have mentioned that we may want to remove this flag back in 2018, due
to zero users of it in core. More recently, Noah has pointed out that
this flag is not safe to use: XLP_BKP_REMOVABLE can be set by the WAL
writer in a lock-free fashion with runningBackups > 0, meaning that some
full-page images could be required but not logged, ultimately corrupting
backups.
Bump XLOG_PAGE_MAGIC.
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/20250705001628.c3.nmisch@google.com
Discussion: https://postgr.es/m/CAEze2WhiwKSoAvfUggjDeoeY0-rz9cTpfrHcqvBMmJxv-K_5DA@mail.gmail.com M src/backend/access/transam/xlog.c
M src/include/access/xlog_internal.h
Fix memory allocation size in RegisterExtensionExplainOption()
commit : f7dc17aa9116a90a235ecf77c46afbbd6b6f8fbc
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 13:14:15 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 13:14:15 +0900 The allocations used for the static array ExplainExtensionOptionArray,
that tracks a set of ExplainExtensionOption, used "char *" instead of
ExplainExtensionOption as the memory size consumed by one element,
underestimating the memory required by half.
The initial allocation of ExplainExtensionNameArray wants to hold 16
elements before being reallocated, and with "char *" it meant that there
was enough space only for 8 ExplainExtensionOption elements, 16 bytes
required for each element. The backend would crash once one tries to
register a 9th EXPLAIN option.
As far as I can see, the allocation formulas of GetExplainExtensionId()
have been copy-pasted to RegisterExtensionExplainOption(), but the
internal maths of the copy were not adjusted accordingly.
Oversight in c65bc2e1d14a.
Author: Joel Jacobson <joel@compiler.org>
Discussion: https://postgr.es/m/2a4bd2f5-2a2f-409f-8ac7-110dd3fad4fc@app.fastmail.com
Backpatch-through: 18 M src/backend/commands/explain_state.c
test_custom_types: Test module with fancy custom data types
commit : 2176520089e8c78a2eadb693670f65eaabf8ede2
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 11:10:31 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 11:10:31 +0900 This commit adds a new test module called "test_custom_types", that can
be used to stress code paths related to custom data type
implementations.
Currently, this is used as a test suite to validate the set of fixes
done in 3b7a6fa15720, that requires some typanalyze callbacks that can
force very specific backend behaviors, as of:
- typanalyze callback that returns "false" as status, to mark a failure
in computing statistics.
- typanalyze callback that returns "true" but let's the backend know
that no interesting stats could be computed, with stats_valid set to
"false".
This could be extended more in the future if more problems are found.
For simplicity, the module uses a fake int4 data type, that requires a
btree operator class to be usable with extended statistics. The type is
created by the extension, and its properties are altered in the test.
Like 3b7a6fa15720, this module is backpatched down to v14, for coverage
purposes.
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aaDrJsE1I5mrE-QF@paquier.xyz
Backpatch-through: 14 M src/test/modules/Makefile
M src/test/modules/meson.build
A src/test/modules/test_custom_types/.gitignore
A src/test/modules/test_custom_types/Makefile
A src/test/modules/test_custom_types/README
A src/test/modules/test_custom_types/expected/test_custom_types.out
A src/test/modules/test_custom_types/meson.build
A src/test/modules/test_custom_types/sql/test_custom_types.sql
A src/test/modules/test_custom_types/test_custom_types–1.0.sql
A src/test/modules/test_custom_types/test_custom_types.c
A src/test/modules/test_custom_types/test_custom_types.control
psql: Add tab completion for DELETE ... USING.
commit : 0bf7d4ca9a6d0cd151de0209fd43671f158c1c88
author : Fujii Masao <fujii@postgresql.org>
date : Mon, 2 Mar 2026 11:07:42 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Mon, 2 Mar 2026 11:07:42 +0900 This implements the tab completion that was marked as XXX TODO in the
source code. The following completion is now supported:
DELETE FROM <table> USING <TAB> -> list of relations supporting SELECT
This uses Query_for_list_of_selectables (instead of Query_for_list_of_tables)
because the USING clause can reference not only tables but also views and
other selectable objects, following the same syntax as the FROM clause
of a SELECT statement.
Author: Tatsuya Kawata <kawatatatsuya0913@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Soumya S Murali <soumyamurali.work@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHza6qf0CLJuJr+5cQw0oWNebM5VyMB-ghoKBgnEjOQ_JtAiuw@mail.gmail.com M src/bin/psql/tab-complete.in.c
Fix set of issues with extended statistics on expressions
commit : 3b7a6fa1572000ffde0aa7dc951a1faf2f401618
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 09:38:37 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 2 Mar 2026 09:38:37 +0900 This commit addresses two defects regarding extended statistics on
expressions:
- When building extended statistics in lookup_var_attr_stats(), the call
to examine_attribute() did not account for the possibility of a NULL
return value. This can happen depending on the behavior of a typanalyze
callback — for example, if the callback returns false, if no rows are
sampled, or if no statistics are computed. In such cases, the code
attempted to build MCV, dependency, and ndistinct statistics using a
NULL pointer, incorrectly assuming valid statistics were available,
which could lead to a server crash.
- When loading extended statistics for expressions,
statext_expressions_load() did not account for NULL entries in the
pg_statistic array storing expression statistics. Such NULL entries can
be generated when statistics collection fails for an expression, as may
occur during the final step of serialize_expr_stats(). An extended
statistics object defining N expressions requires N corresponding
elements in the pg_statistic array stored for the expressions, and some
of these elements can be NULL. This situation is reachable when a
typanalyze callback returns true, but sets stats_valid to indicate that
no useful statistics could be computed.
While these scenarios cannot occur with in-core typanalyze callbacks, as
far as I have analyzed, they can be triggered by custom data types with
custom typanalyze implementations, at least.
No tests are added in this commit. A follow-up commit will introduce a
test module that can be extended to cover similar edge cases if
additional issues are discovered. This takes care of the core of the
problem.
Attribute and relation statistics already offer similar protections:
- ANALYZE detects and skips the build of invalid statistics.
- Invalid catalog data is handled defensively when loading statistics.
This issue exists since the support for extended statistics on
expressions has been added, down to v14 as of a4d75c86bf15. Backpatch
to all supported stable branches.
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aaDrJsE1I5mrE-QF@paquier.xyz
Backpatch-through: 14 M src/backend/statistics/extended_stats.c
M src/backend/utils/adt/selfuncs.c
Correctly calculate "MCV frequency" for a unique column.
commit : d80b0225010fd407c784bbecde116a28198b6eab
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 1 Mar 2026 12:56:55 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Sun, 1 Mar 2026 12:56:55 -0500 In commit bd3e3e9e5, I over-hastily used 1 / rel->rows as the assumed
frequency of entries in a column that ANALYZE has found to be unique.
However, rel->rows is the number of table rows that are estimated to
pass the query's restriction conditions, so that we got a too-large
result if the query has selective restrictions. What I should have
used is 1 / rel->tuples, since that is the estimated total number of
table rows. The pre-existing code path that digs a frequency out of
the histogram produces a frequency relative to the whole table, so
surely this new alternative code path must do so as well. Any
correction needed on the basis of selectivity must be done by the
user of the mcv_freq value.
Fixing this causes all the regression test plans changed by bd3e3e9e5
to revert to what they had been, except for the first change in
join.out. As I correctly argued in bd3e3e9e5, in that test case we
have no stats and should not risk a hash join. Evidently I was less
correct to argue that the other changes were improvements.
Reported-by: Joel Jacobson <joel@compiler.org>
Diagnosed-by: Tender Wang <tndrwang@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/341b723c-da45-4058-9446-1514dedb17c1@app.fastmail.com M src/backend/utils/adt/selfuncs.c
M src/test/regress/expected/join.out
M src/test/regress/expected/partition_join.out
psql: Show comments in \dRp+, \dRs+, and \dX+ psql meta-commands.
commit : aecc558666ad62fbecb08ff7af1394656811a581
author : Fujii Masao <fujii@postgresql.org>
date : Sat, 28 Feb 2026 23:56:46 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Sat, 28 Feb 2026 23:56:46 +0900 Previously, the psql meta-commands that list publications, subscriptions,
and extended statistics did not display their associated comments,
whereas other \d meta-commands did. This made it inconvenient for users
to view these objects together with their descriptions.
This commit improves \dRp+ and \dRs+ to include comments for publications
and subscriptions. It also extends the \dX meta-command to accept the + option,
allowing comments for extended statistics to be shown when requested.
Author: Fujii Masao <masao.fujii@gmail.com>
Co-authored-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwGL4JqiKA26fnGx-cTM=VzoTs_uzqejvj4Fawyr4uLUUw@mail.gmail.com M doc/src/sgml/ref/psql-ref.sgml
M src/bin/psql/command.c
M src/bin/psql/describe.c
M src/bin/psql/describe.h
M src/bin/psql/help.c
M src/test/regress/expected/publication.out
M src/test/regress/expected/stats_ext.out
M src/test/regress/expected/subscription.out
Refactor detection of x86 ZMM registers
commit : 51bb4a58ed23cb228e5dd2e5971843e785f4d913
author : John Naylor <john.naylor@postgresql.org>
date : Sat, 28 Feb 2026 16:28:09 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Sat, 28 Feb 2026 16:28:09 +0700 - Call _xgetbv within x86_set_runtime_features rather than in a
separate function
- Use symbols for XCR mask bits rather than a magic constant
A future commit will build on this to detect YMM registers without
code duplication.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CANWCAZbgEUFw7LuYSVeJ=Tj98R5HoOB1Ffeqk3aLvbw5rU5NTw@mail.gmail.com M src/port/pg_cpu_x86.c
Fix some -Wcast-qual warnings
commit : 3f9886298052802258261e1bdcd3f1dd0e8399b9
author : Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Feb 2026 21:57:33 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Fri, 27 Feb 2026 21:57:33 +0100 This fixes some warnings from -Wcast-qual that are easy to fix,
without using unconstify or the like.
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/990c9117-b013-4026-aaf5-261fe2832c3d%40eisentraut.org M src/backend/access/gin/ginbulk.c
M src/backend/postmaster/launch_backend.c
M src/backend/utils/adt/xml.c
M src/backend/utils/error/elog.c
M src/common/jsonapi.c
M src/fe_utils/astreamer_lz4.c
M src/include/access/gin_private.h
M src/include/port/pg_lfind.h
M src/include/postmaster/postmaster.h
M src/interfaces/ecpg/preproc/parser.c
Doc: improve user docs and code comments about EXISTS(SELECT * ...).
commit : 65a3ff8f1be0186a9c207821bcf0f543545a04d9
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Feb 2026 15:20:16 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Feb 2026 15:20:16 -0500 Point out that Postgres automatically optimizes away the target list
of an EXISTS' subquery, except in weird cases such as target lists
containing set-returning functions. Thus, both common conventions
EXISTS(SELECT * FROM ...) and EXISTS(SELECT 1 FROM ...) are
overhead-free and there's little reason to prefer one over the other.
In the code comments, mention that the SQL spec says that
EXISTS(SELECT * FROM ...) should be interpreted as EXISTS(SELECT
some-literal FROM ...), but we don't choose to do it exactly that way.
Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/9b301c70-3909-4f0f-98ca-9e3c4d142f3e@eisentraut.org M doc/src/sgml/func/func-subquery.sgml
M src/backend/optimizer/plan/subselect.c
Don't flatten join alias Vars that are stored within a GROUP RTE.
commit : 98616ac18b49ac9f84a96177d8a7822f34904183
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Feb 2026 12:54:02 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Fri, 27 Feb 2026 12:54:02 -0500 The RTE's groupexprs list is used for deparsing views, and for that
usage it must contain the original alias Vars; else we can get
incorrect SQL output. But since commit 247dea89f,
parseCheckAggregates put the GROUP BY expressions through
flatten_join_alias_vars before building the RTE_GROUP RTE.
Changing the order of operations there is enough to fix it.
This patch unfortunately can do nothing for already-created views:
if they use a coding pattern that is subject to the bug, they will
deparse incorrectly and hence present a dump/reload hazard in the
future. The only fix is to recreate the view from the original SQL.
But the trouble cases seem to be quite narrow. AFAICT the output
was only wrong for "SELECT ... t1 LEFT JOIN t2 USING (x) GROUP BY x"
where t1.x and t2.x were not of identical data types and t1.x was
the side that required an implicit coercion. If there was no hidden
coercion, or if the join was plain, RIGHT, or FULL, the deparsed
output was uglier than intended but not functionally wrong.
Reported-by: Swirl Smog Dowry <swirl-smog-dowry@duck.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CA+-gibjCg_vjcq3hWTM0sLs3_TUZ6Q9rkv8+pe2yJrdh4o4uoQ@mail.gmail.com
Backpatch-through: 18 M src/backend/parser/parse_agg.c
M src/test/regress/expected/aggregates.out
M src/test/regress/sql/aggregates.sql
Centralize detection of x86 CPU features
commit : 16743db061e431d40522547c6436af6616026caa
author : John Naylor <john.naylor@postgresql.org>
date : Fri, 27 Feb 2026 20:30:41 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Fri, 27 Feb 2026 20:30:41 +0700 We now maintain an array of booleans that indicate which features were
detected at runtime. When code wants to check for a given feature,
the array is automatically checked if it has been initialized and if
not, a single function checks all features at once.
Move all x86 feature detection to pg_cpu_x86.c, and move the CRC
function choosing logic to the file where the hardware-specific
functions are defined, consistent with more recent hardware-specific
files in src/port.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CANWCAZbgEUFw7LuYSVeJ=Tj98R5HoOB1Ffeqk3aLvbw5rU5NTw@mail.gmail.com A src/include/port/pg_cpu.h
M src/port/pg_cpu_x86.c
M src/port/pg_crc32c_sse42.c
M src/port/pg_popcount_x86.c
M src/tools/pgindent/typedefs.list
Clean up nodes that are no longer of use in 007_pgdumpall.pl
commit : d6d9b96b4044e5c744bf2c6474b2c5c2de355f85
author : Andrew Dunstan <andrew@dunslane.net>
date : Fri, 27 Feb 2026 07:14:06 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Fri, 27 Feb 2026 07:14:06 -0500 Oversight in commit 763aaa06f03. When nodes are going out of scope, we
should stop the underlying postmasters rather than waiting for the
script to end.
Per gripe from Tom Lane
Discussion: https://postgr.es/m/740033.1772142754@sss.pgh.pa.us M src/bin/pg_dump/t/007_pg_dumpall.pl
Use pg_malloc_object() and pg_alloc_array() variants in frontend code
commit : 574bee89c237d79e4dd3209f0fa3b10e0179b57a
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 27 Feb 2026 18:59:41 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 27 Feb 2026 18:59:41 +0900 This commit updates the frontend tools (src/bin/, contrib/ and
src/test/) to use the memory allocation variants based on
pg_malloc_object() and pg_malloc_array() in various code paths. This
does not cover all the allocations, but a good chunk of them.
Like all the changes of this kind (31d3847a37be, etc.), this should
encourage any future code to use this new style.
Author: Andreas Karlsson <andreas@proxel.se>
Discussion: https://postgr.es/m/cfb645da-6b3a-4f22-9bcc-5bc46b0e9c61@proxel.se M contrib/oid2name/oid2name.c
M src/bin/initdb/initdb.c
M src/bin/pg_amcheck/pg_amcheck.c
M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_basebackup/pg_recvlogical.c
M src/bin/pg_basebackup/streamutil.c
M src/bin/pg_basebackup/walmethods.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_combinebackup/write_manifest.c
M src/bin/pg_ctl/pg_ctl.c
M src/bin/pg_rewind/datapagemap.c
M src/bin/pg_rewind/libpq_source.c
M src/bin/pg_rewind/local_source.c
M src/bin/pg_rewind/pg_rewind.c
M src/bin/pg_rewind/timeline.c
M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/function.c
M src/bin/pg_upgrade/info.c
M src/bin/pg_upgrade/parallel.c
M src/bin/pg_upgrade/slru_io.c
M src/bin/pg_upgrade/tablespace.c
M src/bin/pg_upgrade/task.c
M src/bin/pg_verifybackup/astreamer_verify.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pgbench/exprparse.y
M src/bin/pgbench/pgbench.c
M src/bin/psql/command.c
M src/bin/psql/copy.c
M src/bin/psql/crosstabview.c
M src/bin/psql/describe.c
M src/bin/psql/tab-complete.in.c
M src/bin/psql/variables.c
M src/bin/scripts/reindexdb.c
M src/test/isolation/isolationtester.c
M src/test/isolation/specparse.y
M src/test/modules/libpq_pipeline/libpq_pipeline.c
M src/test/regress/pg_regress.c
Don't include proc.h in shm_mq.h
commit : a2c89835f5124f9a98edffd953f42639bf9a31b5
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 27 Feb 2026 10:53:47 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Fri, 27 Feb 2026 10:53:47 +0100 This prevents proliferation of proc.h to tons of other places; shm_mq.h
is widely included.
Discussion: https://postgr.es/m/202602261733.s2rkxezwuif6@alvherre.pgsql M src/backend/access/brin/brin.c
M src/backend/access/gin/gininsert.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/vacuumlazy.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/transam/parallel.c
M src/backend/catalog/namespace.c
M src/backend/commands/async.c
M src/backend/commands/vacuumparallel.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeAppend.c
M src/backend/executor/nodeGather.c
M src/backend/libpq/pqmq.c
M src/backend/optimizer/plan/createplan.c
M src/backend/replication/logical/applyparallelworker.c
M src/backend/replication/logical/tablesync.c
M src/backend/replication/logical/worker.c
M src/backend/storage/ipc/procsignal.c
M src/backend/storage/ipc/shm_mq.c
M src/backend/utils/activity/backend_progress.c
M src/backend/utils/misc/guc_tables.c
M src/include/access/parallel.h
M src/include/libpq/pqmq.h
M src/include/storage/shm_mq.h
M src/test/modules/test_shm_mq/setup.c
M src/test/modules/test_shm_mq/test.c
M src/test/modules/test_shm_mq/worker.c
postgres_fdw: Fix thinko in comment for UserMappingPasswordRequired().
commit : e7b97a22383a5310e0cf643468f648666de3970f
author : Etsuro Fujita <efujita@postgresql.org>
date : Fri, 27 Feb 2026 17:05:00 +0900
committer: Etsuro Fujita <efujita@postgresql.org>
date : Fri, 27 Feb 2026 17:05:00 +0900 This commit also rephrases this comment to improve readability.
Oversight in commit 6136e94dc.
Reported-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Author: Andreas Karlsson <andreas@proxel.se>
Co-authored-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/CAPmGK16pDnM_wU3kmquPj-M9MYqG3y0BdntRZ0eytqbCaFY3WQ%40mail.gmail.com
Backpatch-through: 14 M contrib/postgres_fdw/connection.c
Remove table_scan_analyze_next_tuple unneeded parameter OldestXmin
commit : 284925508ae685a63ee056f89a336caecab64a63
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 26 Feb 2026 15:35:32 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 26 Feb 2026 15:35:32 -0500 heapam_scan_analyze_next_tuple() doesn't distinguish between dead and
recently dead tuples when counting them, so it doesn't need OldestXmin.
GetOldestNonRemovableTransactionId() isn't free, so removing it is a
win.
Looking at other table AMs implementing table_scan_analyze_next_tuple(),
we couldn't find one using OldestXmin either, so remove it from the
callback.
Author: Melanie Plageman <melanieplageman@gmail.com>
Suggested-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CALdSSPjvhGXihT_9f-GJabYU%3D_PjrFDUxYaURuTbfLyQM6TErg%40mail.gmail.com M src/backend/access/heap/heapam_handler.c
M src/backend/commands/analyze.c
M src/include/access/tableam.h
Simplify visibility check in heap_page_would_be_all_visible()
commit : 3efe58febc3c6a48dc1be7d13243fd2183afe9a8
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 26 Feb 2026 15:33:36 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 26 Feb 2026 15:33:36 -0500 heap_page_would_be_all_visible() does not need to distinguish between
HEAPTUPLE_RECENTLY_DEAD and HEAPTUPLE_DEAD tuples: any tuple in a state
other than HEAPTUPLE_LIVE means the page is not all-visible and
heap_page_would_be_all_visible() returns false.
Given that, calling HeapTupleSatisfiesVacuum() is unnecessary, since it
performs extra work to distinguish between dead and recently dead tuples
using OldestXmin. Replace it with the more minimal
HeapTupleSatisfiesVacuumHorizon().
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CALdSSPjvhGXihT_9f-GJabYU%3D_PjrFDUxYaURuTbfLyQM6TErg%40mail.gmail.com M src/backend/access/heap/vacuumlazy.c
Fix more multibyte issues in ltree.
commit : c8308a984d9dd45b3111bd99c8fba23cb78aeaa0
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 26 Feb 2026 12:23:22 -0800
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 26 Feb 2026 12:23:22 -0800 Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.
Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().
Discussion: https://postgr.es/m/02c6ef6cf56a5013ede61ad03c7a26affd27d449.camel@j-davis.com
Backpatch-through: 14 M contrib/ltree/lquery_op.c
M contrib/ltree/ltree.h
M contrib/ltree/ltxtquery_op.c
Fix memory leaks in pg_locale_icu.c.
commit : d942511f08a0979d9042c9b1d0d56113a451382e
author : Jeff Davis <jdavis@postgresql.org>
date : Thu, 29 Jan 2026 10:37:09 -0800
committer: Jeff Davis <jdavis@postgresql.org>
date : Thu, 29 Jan 2026 10:37:09 -0800 The backport prior to 18 requires minor modification due to code
refactoring.
Discussion: https://postgr.es/m/e2b7a0a88aaadded7e2d19f42d5ab03c9e182ad8.camel@j-davis.com
Backpatch-through: 16 M src/backend/utils/adt/pg_locale_icu.c
Rename LVRelState VM-related logging counters
commit : 5aea60839ba30440b1e1448dffc8334bbcf1a59a
author : Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 26 Feb 2026 15:04:49 -0500
committer: Melanie Plageman <melanieplageman@gmail.com>
date : Thu, 26 Feb 2026 15:04:49 -0500 The LVRelState fields that track newly all-visible/all-frozen pages were
previously named vm_new_visible_pages, vm_new_frozen_pages, and
vm_new_visible_frozen_pages. The correct terminology is all-visible and
all-frozen; omitting “all” was open to misinterpretation, as the page
isn't visible or invisible, rather all the tuples on the page are
visible to all running and future transactions. Rename the members
accordingly.
Author: Melanie Plageman <melanieplageman@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk M src/backend/access/heap/vacuumlazy.c
Don't include latch.h in libpq/libpq.h
commit : 7b9b620d8fc764bda2b580dc7e654f6505934480
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 26 Feb 2026 17:58:52 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 26 Feb 2026 17:58:52 +0100 This reduces the inclusion footprint of latch.h a bit.
Per suggestion from Andres Freund.
Discussion: https://postgr.es/m/pap7mzhcxvuwlfdebjkh646ntyk4brtwm4dbocfpllwdccta5t@w3d7wz6mjpwv M src/backend/libpq/be-secure-gssapi.c
M src/backend/libpq/be-secure.c
M src/backend/libpq/pqcomm.c
M src/include/libpq/libpq.h
instrumentation: Drop INSTR_TIME_SET_CURRENT_LAZY macro
commit : 9d6294c09ed0015e0f16b518e6e53000c856dd01
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Feb 2026 10:38:20 -0500
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Feb 2026 10:38:20 -0500 This macro had exactly one user in InstrStartNode, and the caller can
instead use INSTR_TIME_IS_ZERO / INSTR_TIME_SET_CURRENT directly.
This supports a future change that intends to modify the time source being
used in the InstrStartNode case.
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53Pkx1bK1FB71_nBqYmzvSSXnp_MbE0ZDnU+baPJF6Ud2WDA@mail.gmail.com M src/backend/executor/instrument.c
M src/include/portability/instr_time.h
instrumentation: Rename INSTR_TIME_LT macro to INSTR_TIME_GT
commit : 3218825271bd5ea3921ecd18e373bc76947c70bc
author : Andres Freund <andres@anarazel.de>
date : Thu, 26 Feb 2026 10:19:23 -0500
committer: Andres Freund <andres@anarazel.de>
date : Thu, 26 Feb 2026 10:19:23 -0500 This was incorrectly named "LT" for "larger than" in e5a5e0a90750d66, but
that is against existing conventions, where "LT" means "less than".
Clarify by using "GT" for "greater than" in macro name, and add a missing
comment at the top of instr_time.h to note the macro's existence.
Reported by: Peter Smith <smithpb2250@gmail.com>
Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAHut%2BPut94CTpjQsqOJHdHkgJ2ZXq%2BqVSfMEcmDKLiWLW-hPfA%40mail.gmail.com M src/backend/executor/instrument.c
M src/include/portability/instr_time.h
Add non-text output formats to pg_dumpall
commit : 763aaa06f03401584d07db71256fc0ab47235cce
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 23 Feb 2026 15:08:55 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 23 Feb 2026 15:08:55 -0500 pg_dumpall can now produce output in custom, directory, or tar formats
in addition to plain text SQL scripts. When using non-text formats,
pg_dumpall creates a directory containing:
- toc.glo: global data (roles and tablespaces) in custom format
- map.dat: mapping between database OIDs and names
- databases/: subdirectory with per-database archives named by OID
pg_restore is extended to handle these pg_dumpall archives, restoring
globals and then each database. The --globals-only option can be used
to restore only the global objects.
This enables parallel restore of pg_dumpall output and selective
restoration of individual databases from a cluster-wide backup.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Co-Author: Andrew Dunstan <andrew@dunslane.net>
Reviewed-By: Tushar Ahuja <tushar.ahuja@enterprisedb.com>
Reviewed-By: Jian He <jian.universality@gmail.com>
Reviewed-By: Vaibhav Dalvi <vaibhav.dalvi@enterprisedb.com>
Reviewed-By: Srinath Reddy <srinath2133@gmail.com>
Discussion: https://postgr.es/m/cb103623-8ee6-4ba5-a2c9-f32e3a4933fa@dunslane.net M doc/src/sgml/ref/pg_dumpall.sgml
M doc/src/sgml/ref/pg_restore.sgml
M src/bin/pg_dump/meson.build
M src/bin/pg_dump/parallel.c
M src/bin/pg_dump/pg_backup.h
M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_archiver.h
M src/bin/pg_dump/pg_backup_tar.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_dump/pg_restore.c
M src/bin/pg_dump/t/001_basic.pl
A src/bin/pg_dump/t/007_pg_dumpall.pl
M src/tools/pgindent/typedefs.list
Reduce includes in pgstat.h
commit : 7bb50dd7d6b9f3cbad005aeb6eb9e4a065481b25
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 26 Feb 2026 13:50:12 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 26 Feb 2026 13:50:12 +0100 The lack of fallout here is somewhat surprising.
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/aY-UE-4t7FiYgH3t@alap3.anarazel.de M src/include/pgstat.h
pg_dump: Preserve NO INHERIT on NOT NULL on inheritance children
commit : d0833fdae7ebb520e14db20ebd8973c5999f636e
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 26 Feb 2026 11:50:26 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 26 Feb 2026 11:50:26 +0100 When the constraint is printed without the column, we were not printing
the NO INHERIT flag.
Author: Jian He <jian.universality@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/CACJufxEDEOO09G+OQFr=HmFr9ZDLZbRoV7+pj58h3_WeJ_K5UQ@mail.gmail.com M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/t/002_pg_dump.pl
EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing.
commit : 0163951b785e9b839706ce8e557066ad083beef1
author : Noah Misch <noah@leadboat.com>
date : Wed, 25 Feb 2026 18:13:22 -0800
committer: Noah Misch <noah@leadboat.com>
date : Wed, 25 Feb 2026 18:13:22 -0800 Settings that ran the new test euc_kr.sql to completion would fail these
older src/pl tests. Use alternative expected outputs, for which psql
\gset and \if have reduced the maintenance burden. This fixes
"LANG=ko_KR.euckr LC_MESSAGES=C make check-world". (LC_MESSAGES=C fixes
IO::Pty usage in tests 010_tab_completion and 001_password.) That file
is new in commit c67bef3f3252a3a38bf347f9f119944176a796ce. Back-patch
to v14, like that commit.
Discussion: https://postgr.es/m/20260217184758.da.noahmisch@microsoft.com
Backpatch-through: 14 M src/pl/plperl/GNUmakefile
M src/pl/plperl/expected/plperl_elog.out
M src/pl/plperl/expected/plperl_elog_1.out
A src/pl/plperl/expected/plperl_unicode.out
A src/pl/plperl/expected/plperl_unicode_1.out
M src/pl/plperl/meson.build
M src/pl/plperl/sql/plperl_elog.sql
A src/pl/plperl/sql/plperl_unicode.sql
M src/pl/plpython/expected/plpython_unicode.out
A src/pl/plpython/expected/plpython_unicode_1.out
M src/pl/plpython/sql/plpython_unicode.sql
M src/pl/tcl/expected/pltcl_unicode.out
A src/pl/tcl/expected/pltcl_unicode_1.out
M src/pl/tcl/sql/pltcl_unicode.sql
doc: Clarify INCLUDING COMMENTS behavior in CREATE TABLE LIKE.
commit : b2ff2a0b52962dcbcbc9c5a8d74fd4e8c28d1f2a
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Feb 2026 09:01:52 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Feb 2026 09:01:52 +0900 The documentation for the INCLUDING COMMENTS option of the LIKE clause
in CREATE TABLE was inaccurate and incomplete. It stated that comments for
copied columns, constraints, and indexes are copied, but regarding comments
on constraints in reality only comments on CHECK and NOT NULL constraints
are copied; comments on other constraints (such as primary keys) are not.
In addition, comments on extended statistics are copied, but this was not
documented.
The CREATE FOREIGN TABLE documentation had a similar omission: comments
on extended statistics are also copied, but this was not mentioned.
This commit updates the documentation to clarify the actual behavior.
The CREATE TABLE reference now specifies that comments on copied columns,
CHECK constraints, NOT NULL constraints, indexes, and extended statistics are
copied. The CREATE FOREIGN TABLE reference now notes that comments on
extended statistics are copied as well.
Backpatch to all supported versions. Documentation updates related to
CREATE FOREIGN TABLE LIKE and NOT NULL constraint comment copying are
not applied to v17 and earlier, since those features were introduced in v18.
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHSOSGcaYDvHF8EYCUCfGPjbRwGFsJ23cx5KbJ1X6JouQ@mail.gmail.com
Backpatch-through: 14 M doc/src/sgml/ref/create_foreign_table.sgml
M doc/src/sgml/ref/create_table.sgml
Fix ProcWakeup() resetting wrong waitStart field.
commit : 70f470314cb45578d929240dfd6be3a12003830e
author : Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Feb 2026 08:46:12 +0900
committer: Fujii Masao <fujii@postgresql.org>
date : Thu, 26 Feb 2026 08:46:12 +0900 Previously, when one process woke another that was waiting on a lock,
ProcWakeup() incorrectly cleared its own waitStart field (i.e.,
MyProc->waitStart) instead of that of the process being awakened.
As a result, the awakened process retained a stale lock-wait start timestamp.
This did not cause user-visible issues. pg_locks.waitstart was reported as
NULL for the awakened process (i.e., when pg_locks.granted is true),
regardless of the waitStart value.
This bug was introduced by commit 46d6e5f56790.
This commit fixes this by resetting the waitStart field of the process
being awakened in ProcWakeup().
Backpatch to all supported branches.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: ji xu <thanksgreed@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/537BD852-EC61-4D25-AB55-BE8BE46D07D7@gmail.com
Backpatch-through: 14 M src/backend/storage/lmgr/proc.c
Stabilize output of new isolation test insert-conflict-do-update-4.
commit : 4c1a27e53a508f74883cda52a6c8612121d7fd6b
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Feb 2026 10:51:42 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Wed, 25 Feb 2026 10:51:42 -0500 The test added by commit 4b760a181 assumed that a table's physical
row order would be predictable after an UPDATE. But a non-heap table
AM might produce some other order. Even with heap AM, the assumption
seems risky; compare a3fd53bab for instance. Adding an ORDER BY is
cheap insurance and doesn't break any goal of the test.
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CALT9ZEHcE6tpvumScYPO6pGk_ASjTjWojLkodHnk33dvRPHXVw@mail.gmail.com
Backpatch-through: 14 M src/test/isolation/expected/insert-conflict-do-update-4.out
M src/test/isolation/specs/insert-conflict-do-update-4.spec
Fix unsafe RTE_GROUP removal in simplify_EXISTS_query
commit : 77c7a17a6e5fefcd55edb6b47fc462a059b983dc
author : Richard Guo <rguo@postgresql.org>
date : Wed, 25 Feb 2026 11:13:21 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Wed, 25 Feb 2026 11:13:21 +0900 When simplify_EXISTS_query removes the GROUP BY clauses from an EXISTS
subquery, it previously deleted the RTE_GROUP RTE directly from the
subquery's range table.
This approach is dangerous because deleting an RTE from the middle of
the rtable list shifts the index of any subsequent RTE, which can
silently corrupt any Var nodes in the query tree that reference those
later relations. (Currently, this direct removal has not caused
problems because the RTE_GROUP RTE happens to always be the last entry
in the rtable list. However, relying on that is extremely fragile and
seems like trouble waiting to happen.)
Instead of deleting the RTE_GROUP RTE, this patch converts it in-place
to be RTE_RESULT type and clears its groupexprs list. This preserves
the length and indexing of the rtable list, ensuring all Var
references remain intact.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3472344.1771858107@sss.pgh.pa.us
Backpatch-through: 18 M src/backend/optimizer/plan/subselect.c
Fix USE_SLICING_BY_8_CRC32C builds on x86
commit : 3322f01a11b79d4b3c84ae9322c0984891349e46
author : John Naylor <john.naylor@postgresql.org>
date : Wed, 25 Feb 2026 08:44:59 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Wed, 25 Feb 2026 08:44:59 +0700 A future commit will move the CRC function choosing logic to the
file where the hardware-specific functions are defined, but until
then add guards for builds without those functions. Oversight in
commit b9278871f.
Per buildfarm animal rhinoceros
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/4014992.1771963187@sss.pgh.pa.us M src/port/pg_cpu_x86.c
pg_upgrade: Use max_protocol_version=3.0 for older servers
commit : a60a103386a1e8bde65fa80feb2486d23bacbbcd
author : Jacob Champion <jchampion@postgresql.org>
date : Tue, 24 Feb 2026 14:01:37 -0800
committer: Jacob Champion <jchampion@postgresql.org>
date : Tue, 24 Feb 2026 14:01:37 -0800 The grease patch in 4966bd3ed found its first problem: prior to the
February 2018 patch releases, no server knew how to negotiate protocol
versions, so pg_upgrade needs to take that into account when speaking to
those older servers.
This will be true even after the grease feature is reverted; we don't
need anyone to trip over this again in the future. Backpatch so that all
supported versions of pg_upgrade can gracefully handle an update to the
default protocol version. (This is needed for any distributions that
link older binaries against newer libpqs, such as Debian.) Branches
prior to 18 need an additional version check, for the existence of
max_protocol_version.
Per buildfarm member crake.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAOYmi%2B%3D4QhCjssfNEoZVK8LPtWxnfkwT5p-PAeoxtG9gpNjqOQ%40mail.gmail.com
Backpatch-through: 14 M src/bin/pg_upgrade/dump.c
M src/bin/pg_upgrade/pg_upgrade.h
M src/bin/pg_upgrade/server.c
M src/bin/pg_upgrade/task.c
M src/bin/pg_upgrade/version.c
Add backtrace support for Windows using DbgHelp API
commit : 65707ed9afc924e0eec19a706b24af5bae1f9574
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Feb 2026 17:34:56 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Tue, 24 Feb 2026 17:34:56 +0100 Previously, backtrace generation on Windows would return an "unsupported"
message. With this commit, we rely on CaptureStackBackTrace() to capture
the call stack and the DbgHelp API (SymFromAddrW, SymGetLineFromAddrW64)
for symbol resolution.
Symbol handler initialization (SymInitialize) is performed once per
process and cached. If initialization fails, the report for it is
returned as the backtrace output. The symbol handler is cleaned up via
on_proc_exit() to release DbgHelp resources.
The implementation provides symbol names, offsets, and addresses. When
PDB files are available, it also includes source file names and line
numbers. Symbol names and file paths are converted from UTF-16 to the
database encoding using wchar2char(), which properly handles both UTF-8
and non-UTF-8 databases on Windows. When symbol information is
unavailable or encoding conversion fails, it falls back to displaying raw
addresses.
The implementation uses the explicit UTF16 versions of the DbgHelp
functions (SYMBOL_INFOW, SymFromAddrW, IMAGEHLP_LINEW64,
SymGetLineFromAddrW64) rather than the generic versions. This allows us
to rely on predictable encoding conversion, rather than using the
haphazard ANSI codepage that we'd get otherwise.
DbgHelp is apparently available on all Windows platforms we support, so
there are no version number checks.
Author: Bryan Green <dbryan.green@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/a692c0fe-caca-4c08-9c5d-debfd0ef2504@gmail.com M src/backend/meson.build
M src/backend/utils/error/elog.c
doc: Add link targets to CREATE/ALTER FOREIGN TABLE reference pages
commit : dea0812cda1998d6940a4a27369e998046009ae1
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Feb 2026 11:27:49 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Feb 2026 11:27:49 +0100 This adds IDs to create_foreign_table.sgml's and
alter_foreign_table.sgml's <varlistentry> and <refsect1>, similar to
other reference pages.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Quan Zongliang <quanzongliang@yeah.net>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CACJufxE6fW2jFAyTFWEYdUSDP%3D9P2yYerdksPTgxqDM4DZvvvw%40mail.gmail.com M doc/src/sgml/ref/alter_foreign_table.sgml
M doc/src/sgml/ref/create_foreign_table.sgml
Make ALTER DOMAIN VALIDATE CONSTRAINT no-op when constraint is already validated
commit : a99c6b56ffa74dae49e6847cc6c113d000c8ebd0
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Feb 2026 10:56:17 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Feb 2026 10:56:17 +0100 Currently, AlterDomainValidateConstraint will re-validate a constraint
that has already been validated, which would just waste cycles. This
operation should be a no-op when the constraint is already validated.
This also aligns with ATExecValidateConstraint.
Author: jian he <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CACJufxG=-Dv9fPJHqkA9c-wGZ2dDOWOXSp-X-0K_G7r-DgaASw@mail.gmail.com M src/backend/commands/typecmds.c
Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK constraints
commit : f80bedd52b1501de51b7180cd817e3e1fc31429d
author : Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Feb 2026 10:30:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Tue, 24 Feb 2026 10:30:50 +0100 Previously, changing the generation expression of a virtual column was
prohibited if the column was referenced by a CHECK constraint. This
lifts that restriction.
RememberAllDependentForRebuilding within ATExecSetExpression will
rebuild all the dependent constraints, later ATPostAlterTypeCleanup
queues the required AlterTableStmt operations for ALTER TABLE Phase 3
execution.
Overall, ALTER COLUMN SET EXPRESSION on virtual columns may require
scanning the table to re-verify any associated CHECK constraints, but
it does not require a table rewrite in ALTER TABLE Phase 3.
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CACJufxH3VETr7orF5rW29GnDk3n1wWbOE3WdkHYd3iPGrQ9E_A@mail.gmail.com M doc/src/sgml/ref/alter_table.sgml
M src/backend/commands/tablecmds.c
M src/test/regress/expected/generated_virtual.out
M src/test/regress/sql/generated_virtual.sql
Fix variety of typos and grammar mistakes
commit : 462fe0ff6215ae222fc866af621e4b86462289b1
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Feb 2026 13:26:37 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Feb 2026 13:26:37 +0900 This commit includes a batch of fixes for various minor typos and
grammar mistakes, that have been proposed to the hackers mailing list
since the beginning of January.
Similar batches are planned on a bi-monthly basis depending on the
amount received, with the next one for the end of April. M contrib/amcheck/verify_nbtree.c
M src/backend/access/brin/brin_minmax_multi.c
M src/backend/access/gist/gistget.c
M src/backend/access/transam/multixact.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/backup/basebackup_copy.c
M src/backend/commands/extension.c
M src/backend/statistics/extended_stats_funcs.c
M src/backend/storage/smgr/smgr.c
M src/bin/pg_basebackup/pg_receivewal.c
M src/bin/pg_resetwal/pg_resetwal.c
M src/fe_utils/astreamer_zstd.c
M src/include/nodes/parsenodes.h
doc: Adjust some markups on pg_waldump page
commit : e2f3d82f89bb997d5340d8f3022c51dfab78ac06
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Feb 2026 12:54:23 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Feb 2026 12:54:23 +0900 Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/CAHut+PuuPps9bUPvouU5dH=tOTiF8QBzQox5O7DqXeOFdda79Q@mail.gmail.com M doc/src/sgml/ref/pg_waldump.sgml
fe_utils: Sprinkle some pg_malloc_object() and pg_malloc_array()
commit : ff393fa526648c091a3492da3bd6dd140e3c55e7
author : Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Feb 2026 12:34:42 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Tue, 24 Feb 2026 12:34:42 +0900 The idea is to encourage more the use of these allocation routines
across the tree, as these offer stronger type safety guarantees than
pg_malloc() & friends (type cast in the result, sizeof() embedded).
This commit updates some code paths of src/fe_utils/.
This commit is similar to 31d3847a37be.
Author: Henrik TJ <henrik@0x48.dk>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Discussion: https://postgr.es/m/6df1b64e-1314-9afd-41a3-3fefb76225e1@0x48.dk M src/fe_utils/conditional.c
M src/fe_utils/print.c
M src/fe_utils/psqlscan.l
M src/fe_utils/simple_list.c
Convert SpinLock* macros to static inline functions.
commit : bfc321b4723e8ca5fd3adb22a2727ec5c55d3808
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 15:32:01 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 15:32:01 -0600 This is preparatory work for a proposed follow-up commit that would
add assertions to these functions.
Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/aZX2oUcKf7IzHnnK%40nathan
Discussion: https://postgr.es/m/20200617183354.pm3biu3zbmo2pktq%40alap3.anarazel.de M src/include/storage/spin.h
Fix indentation from commit b380a56a3f9
commit : 7b24959434629970c14fc5ee668585e491e565e4
author : Andrew Dunstan <andrew@dunslane.net>
date : Mon, 23 Feb 2026 16:22:11 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Mon, 23 Feb 2026 16:22:11 -0500 Per buildfarm animal koel M src/bin/pg_upgrade/check.c
Allow pg_{read,write}_all_data to access large objects.
commit : d98197602790e60ddb63e491cd9768ab9fc410ed
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 14:55:21 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 14:55:21 -0600 Since the initial goal of pg_read_all_data was to be able to run
pg_dump as a non-superuser without explicitly granting access to
every object, it follows that it should allow reading all large
objects. For consistency, pg_write_all_data should allow writing
all large objects, too.
Author: Nitin Motiani <nitinmotiani@google.com>
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Discussion: https://postgr.es/m/CAH5HC96dxAEvP78s1-JK_nDABH5c4w2MDfyx4vEWxBEfofGWsw%40mail.gmail.com M doc/src/sgml/user-manag.sgml
M src/backend/catalog/aclchk.c
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql
Work around lgamma(NaN) bug on AIX.
commit : d743545d8471dbb0016313885392211f58ef2b1c
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 15:30:44 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 15:30:44 -0500 lgamma(NaN) should produce NaN, but on older versions of AIX
it reports an ERANGE error. While that's been fixed in the latest
version of libm, it'll take awhile for the fix to propagate. This
workaround is harmless even when the underlying bug does get fixed.
Discussion: https://postgr.es/m/3603369.1771877682@sss.pgh.pa.us M src/backend/utils/adt/float.c
Use LOCKMODE in parse_relation.c/.h
commit : aca61f7e5f8a8a96865d33d0a6f993bf346f47db
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 21:17:06 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 21:17:06 +0100 There were a couple of comments in parse_relation.c
> Note: properly, lockmode should be declared LOCKMODE not int, but that
> would require importing storage/lock.h into parse_relation.h. Since
> LOCKMODE is typedef'd as int anyway, that seems like overkill.
but actually LOCKMODE has been in storage/lockdefs.h for a while,
which is intentionally a more narrow header. So we can include that
one in parse_relation.h and just use LOCKMODE normally.
An alternative would be to add a duplicate typedef into
parse_relation.h, but that doesn't seem necessary here.
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/4bcd65fb-2497-484c-bb41-83cb435eb64d%40eisentraut.org M src/backend/parser/parse_relation.c
M src/include/parser/parse_relation.h
libpq: Grease the protocol by default
commit : 4966bd3ed95e0d02bf220c4bad2b292963827dd4
author : Jacob Champion <jchampion@postgresql.org>
date : Mon, 23 Feb 2026 10:48:20 -0800
committer: Jacob Champion <jchampion@postgresql.org>
date : Mon, 23 Feb 2026 10:48:20 -0800 Send PG_PROTOCOL_GREASE and _pq_.test_protocol_negotiation, which were
introduced in commit d8d7c5dc8, by default, and fail the connection if
the server attempts to claim support for them. The hope is to provide
feedback to noncompliant implementations and gain confidence in our
ability to advance the protocol. (See the other commit for details.)
To help end users navigate the situation, a link to our documentation
that explains the behavior is displayed. We append this to the error
message when the NegotiateProtocolVersion response is incorrect, or when
the peer sends an error during startup that appears to be grease-
related.
It's still possible for users to connect to servers that don't support
protocol negotiation, by adding max_protocol_version=3.0 to their
connection strings. Only the default connection behavior is impacted.
This commit is tracked as a PG19 open item and will be reverted before
RC1. (The implementation here doesn't handle negotiation with later
server versions, so it can't be released into the wild as a
five-year-supported feature. But an improved implementation might be
able to do so, in the future...)
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Co-authored-by: Jacob Champion <jacob.champion@enterprisedb.com>
Discussion: https://postgr.es/m/DDPR5BPWH1RJ.1LWAK6QAURVAY%40jeltef.nl 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
Restore AIX support.
commit : 4a1b05caa55dc14a1f936af78d8d19c843bfd8b9
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 13:34:22 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 13:34:22 -0500 The concerns that led us to remove AIX support in commit 0b16bb877
have now been alleviated:
1. IBM has stepped forward to provide support, including buildfarm
animal(s).
2. AIX 7.2 and later seem to be fine with large pg_attribute_aligned
requirements. Since 7.1 is now EOL anyway, we can just cease to
support it.
3. Tossing xlc support overboard seems okay as well. It's a bit
sad to drop one of the few remaining non-gcc-alike compilers, but
working around xlc's bugs and idiosyncrasies doesn't seem justified
by the theoretical portability benefits.
4. Likewise, we can stop supporting 32-bit AIX builds. This is
not so much about whether we could build such executables as that
they're too much of a pain to manage in the field, due to limited
address space available for dynamic library loading.
5. We hit on a way to manage catalog column alignment that doesn't
require continuing developer effort (see commit ecae09725).
Hence, this commit reverts 0b16bb877 and some follow-on commits
such as e6bb491bf, except for not putting back XLC support nor
the changes related to catalog column alignment.
Some other notable changes from the way things were in v16:
Prefer unnamed POSIX semaphores on AIX, rather than the default
choice of SysV semaphores.
Include /opt/freeware/lib in -Wl,-blibpath, even when it is not
mentioned anywhere in LDFLAGS.
Remove platform-specific adjustment of MEMSET_LOOP_LIMIT; maybe
that's still the right thing, but it really ought to be re-tested.
Silence compiler warnings related to getpeereid(), wcstombs_l(),
and PAM conversation procs.
Accept "libpythonXXX.a" as an okay name for the Python shared
library (but only on AIX!).
Author: Aditya Kamath <Aditya.Kamath1@ibm.com>
Author: Srirama Kucherlapati <sriram.rk@in.ibm.com>
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CY5PR11MB63928CC05906F27FB10D74D0FD322@CY5PR11MB6392.namprd11.prod.outlook.com M Makefile
M config/python.m4
M configure
M configure.ac
M doc/src/sgml/installation.sgml
M doc/src/sgml/runtime.sgml
M meson.build
M src/Makefile.shlib
M src/backend/Makefile
M src/backend/meson.build
A src/backend/port/aix/mkldexport.sh
M src/backend/utils/error/elog.c
M src/backend/utils/misc/ps_status.c
A src/include/port/aix.h
M src/interfaces/ecpg/compatlib/meson.build
M src/interfaces/ecpg/ecpglib/meson.build
M src/interfaces/ecpg/pgtypeslib/meson.build
M src/interfaces/libpq/Makefile
M src/interfaces/libpq/meson.build
A src/makefiles/Makefile.aix
M src/port/README
M src/port/strerror.c
A src/template/aix
M src/test/regress/Makefile
M src/tools/gen_export.pl
M src/tools/pginclude/headerscheck
Cope with AIX's alignment woes by using _Pragma("pack").
commit : ecae09725236f5ebd4b91eb0f2d5c17a8ae477ca
author : Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 12:34:51 -0500
committer: Tom Lane <tgl@sss.pgh.pa.us>
date : Mon, 23 Feb 2026 12:34:51 -0500 Because we assume that int64 and double have the same alignment
requirement, AIX's default behavior that alignof(double) = 4 while
alignof(int64) = 8 is a headache. There are two issues:
1. We align both int8 and float8 tuple columns per ALIGNOF_DOUBLE,
which is an ancient choice that can't be undone without breaking
pg_upgrade and creating some subtle SQL-level compatibility issues
too. However, the cost of that is just some marginal inefficiency
in fetching int8 values, which can't be too awful if the platform
architects were willing to pay the same costs for fetching float8s.
So our decision is to leave that alone. This patch makes our
alignment choices the same as they were pre-v17, namely that
ALIGNOF_DOUBLE and ALIGNOF_INT64_T are whatever the compiler prefers
and then MAXIMUM_ALIGNOF is the larger of the two. (On all supported
platforms other than AIX, all three values will be the same.)
2. We need to overlay C structs onto catalog tuples, and int8 fields
in those struct declarations may not be aligned to match this rule.
In the old branches we had some annoying rules about ordering catalog
columns to avoid alignment problems, but nobody wants to resurrect
those. However, there's a better answer: make the compiler construe
those struct declarations the way we need it to by using the pack(N)
pragma. This requires no manual effort to maintain going forward;
we only have to insert the pragma into all the catalog *.h files.
(As the catalogs stand at this writing, nothing actually changes
because we've not moved any affected columns since v16; hence no
catversion bump is required. The point of this is to not have
to worry about the issue going forward.)
We did not have this option when the AIX port was first made. This
patch depends on the C99 feature _Pragma(), as well as the pack(N)
pragma which dates to somewhere around gcc 4.0, and probably doesn't
exist in xlc at all. But now that we've agreed to toss xlc support
out the window, there doesn't seem to be a reason not to go this way.
In passing, I got rid of LONGALIGN[_DOWN] along with the configure
probes for ALIGNOF_LONG. We were not using those anywhere and it
seems highly unlikely that we'd do so in future. Instead supply
INT64ALIGN[_DOWN], which isn't used either but at least could
have a good reason to be used.
Discussion: https://postgr.es/m/1127261.1769649624@sss.pgh.pa.us M configure
M configure.ac
M meson.build
M src/include/c.h
M src/include/catalog/genbki.h
M src/include/catalog/pg_aggregate.h
M src/include/catalog/pg_am.h
M src/include/catalog/pg_amop.h
M src/include/catalog/pg_amproc.h
M src/include/catalog/pg_attrdef.h
M src/include/catalog/pg_attribute.h
M src/include/catalog/pg_auth_members.h
M src/include/catalog/pg_authid.h
M src/include/catalog/pg_cast.h
M src/include/catalog/pg_class.h
M src/include/catalog/pg_collation.h
M src/include/catalog/pg_constraint.h
M src/include/catalog/pg_conversion.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_depend.h
M src/include/catalog/pg_description.h
M src/include/catalog/pg_enum.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_index.h
M src/include/catalog/pg_inherits.h
M src/include/catalog/pg_init_privs.h
M src/include/catalog/pg_language.h
M src/include/catalog/pg_largeobject.h
M src/include/catalog/pg_largeobject_metadata.h
M src/include/catalog/pg_namespace.h
M src/include/catalog/pg_opclass.h
M src/include/catalog/pg_operator.h
M src/include/catalog/pg_opfamily.h
M src/include/catalog/pg_parameter_acl.h
M src/include/catalog/pg_partitioned_table.h
M src/include/catalog/pg_policy.h
M src/include/catalog/pg_proc.h
M src/include/catalog/pg_publication.h
M src/include/catalog/pg_publication_namespace.h
M src/include/catalog/pg_publication_rel.h
M src/include/catalog/pg_range.h
M src/include/catalog/pg_replication_origin.h
M src/include/catalog/pg_rewrite.h
M src/include/catalog/pg_seclabel.h
M src/include/catalog/pg_sequence.h
M src/include/catalog/pg_shdepend.h
M src/include/catalog/pg_shdescription.h
M src/include/catalog/pg_shseclabel.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_subscription_rel.h
M src/include/catalog/pg_tablespace.h
M src/include/catalog/pg_transform.h
M src/include/catalog/pg_trigger.h
M src/include/catalog/pg_ts_config.h
M src/include/catalog/pg_ts_config_map.h
M src/include/catalog/pg_ts_dict.h
M src/include/catalog/pg_ts_parser.h
M src/include/catalog/pg_ts_template.h
M src/include/catalog/pg_type.h
M src/include/catalog/pg_user_mapping.h
M src/include/pg_config.h.in
Warn upon successful MD5 password authentication.
commit : bc60ee86066520ee0f86abd3d47bb8ab9757842f
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 11:22:04 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 11:22:04 -0600 This uses the "connection warning" infrastructure introduced by
commit 1d92e0c2cc to emit a WARNING when an MD5 password is used to
authenticate. MD5 password support was marked as deprecated in
v18 and will be removed in a future release of Postgres. These
warnings are on by default but can be turned off via the existing
md5_password_warnings parameter.
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Xiangyu Liang <liangxiangyu_2013@163.com>
Discussion: https://postgr.es/m/aYzeAYEbodkkg5e-%40nathan M doc/src/sgml/config.sgml
M src/backend/libpq/crypt.c
M src/test/authentication/t/001_password.pl
Rename validate_relation_kind()
commit : 797872f6b9c929a78677999c323ddc1ccb4e30d0
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 17:38:06 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 17:38:06 +0100 There are three static definitions of validate_relation_kind() in the
codebase, one each in table.c, indexam.c and sequence.c, validating that
the given relation is a table, an index or a sequence respectively.
The compiler knows which definition to use where because they are static.
But this could be confusing to a reader. Rename these functions so that
their names reflect the kind of relation they are validating. While at
it, also update the comments in table.c to clarify the definition of
table-like relkinds so that we don't have to maintain the exclusion list
as the set of relkinds undergoes changes.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6d3fef19-a420-4e11-8235-8ea534bf2080%40eisentraut.org M src/backend/access/index/indexam.c
M src/backend/access/sequence/sequence.c
M src/backend/access/table/table.c
Flip logic in table validate_relation_kind
commit : d7be57ad85da54bf3c7e079e4941935e5d00fdf2
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 17:26:29 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 17:26:29 +0100 It instead of checking which relkinds it shouldn't be, explicitly list
the ones we accept. This is used to check which relkinds are accepted
in table_open() and related functions. Before this change, figuring
that out was always a few steps too complicated. This also makes
changes for new relkinds more explicit instead of accidental.
Finally, this makes this more aligned with the functions of the same
name in src/backend/access/index/indexam.c and
src/backend/access/sequence/sequence.c.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6d3fef19-a420-4e11-8235-8ea534bf2080%40eisentraut.org M src/backend/access/table/table.c
Disallow CR and LF in database, role, and tablespace names
commit : b380a56a3f9556588a89013b765d67947d54f7d0
author : Andrew Dunstan <andrew@dunslane.net>
date : Sat, 21 Feb 2026 17:17:48 -0500
committer: Andrew Dunstan <andrew@dunslane.net>
date : Sat, 21 Feb 2026 17:17:48 -0500 Previously, these characters could cause problems when passed through
shell commands, and were flagged with a comment in string_utils.c
suggesting they be rejected in a future major release.
The affected commands are CREATE DATABASE, CREATE ROLE, CREATE TABLESPACE,
ALTER DATABASE RENAME, ALTER ROLE RENAME, and ALTER TABLESPACE RENAME.
Also add a pg_upgrade check to detect these invalid names in clusters
being upgraded from pre-v19 versions, producing a report file listing
any offending objects that must be renamed before upgrading.
Tests have been modified accordingly.
Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Reviewed-By: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-By: Andrew Dunstan <andrew@dunslane.net>
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-By: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-By: Srinath Reddy <srinath2133@gmail.com>
Discussion: https://postgr.es/m/CAKYtNApkOi4FY0S7+3jpTqnHVyyZ6Tbzhtbah-NBbY-mGsiKAQ@mail.gmail.com M src/backend/commands/dbcommands.c
M src/backend/commands/tablespace.c
M src/backend/commands/user.c
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/pg_dump/t/003_pg_dump_with_server.pl
M src/bin/pg_dump/t/010_dump_connstr.pl
M src/bin/pg_upgrade/check.c
M src/bin/scripts/t/020_createdb.pl
M src/fe_utils/string_utils.c
M src/test/modules/unsafe_tests/expected/alter_system_table.out
M src/test/modules/unsafe_tests/expected/rolenames.out
M src/test/modules/unsafe_tests/sql/alter_system_table.sql
M src/test/modules/unsafe_tests/sql/rolenames.sql
M src/test/regress/expected/tablespace.out
M src/test/regress/sql/tablespace.sql
meson: allow disabling building/installation of static libraries.
commit : 78727dcba32ed374eb2e92df976649bff56e2056
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 16:25:54 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 16:25:54 +0100 We now support the common meson option -Ddefault_library, with values
'both' (the default), 'shared' (install only shared libraries), and
'static' (install only static libraries). The 'static' choice doesn't
actually work, since psql and other programs insist on linking to the
shared version of libpq, but it's there pro-forma. It could be built
out if we really wanted, but since we have never supported the
equivalent in the autoconf build system, there doesn't appear to be an
urgent need.
With an eye to re-supporting AIX, the internal implementation
distinguishes whether to install libpgport.a and other static-only
libraries from whether to build/install the static variant of
libraries that we can build both ways. This detail isn't exposed as a
meson option, though it could be if there's demand.
The Cirrus CI task SanityCheck now uses -Ddefault_library=shared to
save a little bit of build time (and to test this option).
Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/e8aa97db-872b-4087-b073-f296baae948d@eisentraut.org M .cirrus.tasks.yml
M doc/src/sgml/installation.sgml
M meson.build
M src/common/meson.build
M src/fe_utils/meson.build
M src/interfaces/ecpg/compatlib/meson.build
M src/interfaces/ecpg/ecpglib/meson.build
M src/interfaces/ecpg/pgtypeslib/meson.build
M src/interfaces/libpq-oauth/meson.build
M src/interfaces/libpq/meson.build
M src/port/meson.build
Make use of pg_popcount() in more places.
commit : f33b8793fd7306b81e8c614718ee8f01b4fa0cfd
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 09:26:00 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 09:26:00 -0600 This replaces some loops over word-length popcount functions with
calls to pg_popcount(). Since pg_popcount() may use a function
pointer for inputs with sizes >= a Bitmapset word, this produces a
small regression for the common one-word case in bms_num_members().
To deal with that, this commit adds an inlined fast-path for that
case. This fast-path could arguably go in pg_popcount() itself
(with an appropriate alignment check), but that is left for future
study.
Suggested-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CANWCAZY7R%2Biy%2Br9YM_sySNydHzNqUirx1xk0tB3ej5HO62GdgQ%40mail.gmail.com M src/backend/nodes/bitmapset.c
M src/include/lib/radixtree.h
Remove uses of popcount builtins.
commit : eb9ab7e0930aef9fe1da4b71d0979ebe5361ee48
author : Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 09:26:00 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Mon, 23 Feb 2026 09:26:00 -0600 This commit replaces the implementations of pg_popcount{32,64} with
branchless ones in plain C. While these new implementations do not
make use of more sophisticated population count instructions
available on some CPUs, testing indicates they perform well,
especially now that they are inlined. Newer versions of popular
compilers will automatically replace these with special
instructions if possible, anyway. A follow-up commit will replace
various loops over these functions with calls to pg_popcount(),
leaving us little reason to worry about micro-optimizing them
further.
Since this commit removes the only uses of the popcount builtins,
we can also remove the corresponding configuration checks.
Suggested-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CANWCAZY7R%2Biy%2Br9YM_sySNydHzNqUirx1xk0tB3ej5HO62GdgQ%40mail.gmail.com M configure
M configure.ac
M meson.build
M src/include/pg_config.h.in
M src/include/port/pg_bitutils.h
M src/port/pg_popcount_aarch64.c
Rename pg_crc32c_sse42_choose.c for general purpose
commit : b9278871f991e0c1419b96b7508fe5206903fb1a
author : John Naylor <john.naylor@postgresql.org>
date : Mon, 23 Feb 2026 19:19:49 +0700
committer: John Naylor <john.naylor@postgresql.org>
date : Mon, 23 Feb 2026 19:19:49 +0700 Future commits will consolidate the CPU feature detection functionality
now scattered around in various files, and the CRC "*_choose.c"
files seem to be the natural place for it. For now, just rename in
a separate commit to make it easier to follow the git log. Do the
minimum necessary to keep the build systems functional, and build the
new file pg_cpu_x86.c unconditionally using guards to control the
visibility of its contents, following the model of some more recent
files in src/port.
Limit scope to x86 to reduce the number of moving parts, since the
motivation for doing this now is to clear out some technical debt
before adding AVX2 detection. Arm is left for future work.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CANWCAZbgEUFw7LuYSVeJ=Tj98R5HoOB1Ffeqk3aLvbw5rU5NTw@mail.gmail.com M configure
M configure.ac
M src/port/Makefile
M src/port/meson.build
R094 src/port/pg_crc32c_sse42_choose.c src/port/pg_cpu_x86.c
Change error message for sequence validate_relation_kind()
commit : 55f385932920a232c490fe594d44fb9a9a236c5e
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 10:56:54 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 10:56:54 +0100 We can just say "... is not a sequence" instead of the more
complicated variant from before, which was probably copied from
src/backend/access/table/table.c.
Fix a typo in a comment in passing.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6d3fef19-a420-4e11-8235-8ea534bf2080%40eisentraut.org M src/backend/access/sequence/sequence.c
M src/test/regress/expected/sequence.out
meson: Refactor libpq targets variables
commit : 4bfbbeb679c09c28813d4545bb1f764c3041d475
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 10:37:38 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 10:37:38 +0100 Some of the knowledge of the libpq targets was spread around between
the top-level meson.build and src/interfaces/libpq*. This change
organizes it more like other targets by having a libpq_targets
variable that different subdirectories can add to.
Discussion: https://www.postgresql.org/message-id/flat/e8aa97db-872b-4087-b073-f296baae948d%40eisentraut.org M meson.build
M src/interfaces/libpq-oauth/meson.build
M src/interfaces/libpq/meson.build
test_cplusplusext: Add C++ pg_fallthrough test case
commit : 2f2c9d836373ed7f4c017a9d953264f33cc03e3e
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100 Discussion: https://www.postgresql.org/message-id/flat/76a8efcd-925a-4eaf-bdd1-d972cd1a32ff%40eisentraut.org M src/test/modules/test_cplusplusext/test_cplusplusext.cpp
Enable -Wimplicit-fallthrough option for clang
commit : 0284e07599a53d27d744042c10aec3e2e674d5b5
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100 On clang, -Wimplicit-fallthrough requires annotations with attributes,
but on gcc, -Wimplicit-fallthrough is the same as
-Wimplicit-fallthrough=3, which allows annotations with comments. In
order to enforce consistent annotations with attributes on both
compilers, we test first for -Wimplicit-fallthrough=5, which will
succeed on gcc, and if that is not found we test for
-Wimplicit-fallthrough.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/76a8efcd-925a-4eaf-bdd1-d972cd1a32ff%40eisentraut.org M configure
M configure.ac
M meson.build
Fix additional fallthrough warning
commit : 3f7a0e1e55eff9d96c6d4ac8aa03895de21e06bc
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100 Clang warns about this one, but GCC did not. (Apparently a bug in
GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122796)
Apparently, the previous "fall through" comment was introduced
manually in commit f76892c9ff7e without the compiler actually asking
for it.
This is in preparation for enabling fallthrough warnings on Clang.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/76a8efcd-925a-4eaf-bdd1-d972cd1a32ff%40eisentraut.org M src/bin/scripts/reindexdb.c
Fix additional fallthrough warnings from clang
commit : 3a63b76571ba253e2784ba34377cdcbdb8ad6796
author : Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100
committer: Peter Eisentraut <peter@eisentraut.org>
date : Mon, 23 Feb 2026 07:37:50 +0100 Clang warns if falling through to a case or default label that is
immediately followed by break, but GCC does
not (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432). (MSVC also
warns about the equivalent code in C++.)
This is in preparation for enabling fallthrough warnings on Clang.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/76a8efcd-925a-4eaf-bdd1-d972cd1a32ff%40eisentraut.org M contrib/isn/isn.c
M contrib/pg_overexplain/pg_overexplain.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/replication/logical/decode.c
M src/backend/tcop/dest.c
M src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
M src/pl/plpgsql/src/pl_comp.c
M src/tools/pg_bsd_indent/indent.c
Avoid including utils/timestamp.h in conflict.h.
commit : 308622edf1743aa407df0044cc4529aed8de15e6
author : Amit Kapila <akapila@postgresql.org>
date : Mon, 23 Feb 2026 10:19:05 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Mon, 23 Feb 2026 10:19:05 +0530 conflict.h currently includes utils/timestamp.h despite only requiring
basic timestamp type definitions. This creates unnecessary overhead.
Replace the include with datatype/timestamp.h to provide the necessary
types. This change requires explicitly including utils/timestamp.h in
test_custom_fixed_stats.c, which previously relied on the indirect
inclusion.
Extracted from the larger patch by Andres Freund.
Discussion: https://postgr.es/m/aY-UE-4t7FiYgH3t@alap3.anarazel.de M src/include/replication/conflict.h
M src/test/modules/test_custom_stats/test_custom_fixed_stats.c
doc: Add section "Options" for pg_controldata
commit : ee465848846efe6da0c73c99a0fcde6982831468
author : Michael Paquier <michael@paquier.xyz>
date : Mon, 23 Feb 2026 13:42:38 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Mon, 23 Feb 2026 13:42:38 +0900 Adding this section brings consistency with the pages of other tools,
potentially easing the introduction of new options in the future as
these are now showing in the shape of a list.
Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Discussion: https://postgr.es/m/CAHut+PtSF5AW3DHpYA-_muDLms2xBUzHpd545snVj8vFpmsmGg@mail.gmail.com M doc/src/sgml/ref/pg_controldata.sgml
Align PGPROC to cache line boundary
commit : 412f78c66eedbe9cf41a657f4566d86a69ab7af2
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 22 Feb 2026 13:13:43 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 22 Feb 2026 13:13:43 +0200 On common architectures, the PGPROC struct happened to be a multiple
of 64 bytes on PG 18, but it's changed on 'master' since. There was
worry that changing the alignment might hurt performance, due to false
cacheline sharing across elements in the proc array. However, there
was no explicit alignment, so any alignment to cache lines was
accidental. Add explicit alignment to remove worry about false
sharing.
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/3dd6f70c-b94d-4428-8e75-74a7136396be@iki.fi M src/include/storage/proc.h
Rearrange fields in PGPROC, for clarity
commit : 2e0853176f8f28a7684aa8b5af73446332960725
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 22 Feb 2026 12:45:13 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Sun, 22 Feb 2026 12:45:13 +0200 The ordering was pretty random, making it hard to get an overview of
what's in it. Group related fields together, and add comments to act
as separators between the groups.
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/3dd6f70c-b94d-4428-8e75-74a7136396be@iki.fi M src/include/storage/proc.h
doc: Add description of "filename" for pg_walsummary
commit : 4476106c65d2ed3aed35887f9b94fbc55d96074a
author : Michael Paquier <michael@paquier.xyz>
date : Sun, 22 Feb 2026 15:12:58 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Sun, 22 Feb 2026 15:12:58 +0900 This command requires an input file (WAL summary file), that has to be
specified without an option name. The shape of the command and how to
use this parameter is implied in its synopsis. However, this page
lacked a description of the parameter. Listing parameters that do
not require an option is a common practice across the docs. See for
example pg_dump, pg_restore, etc.
Author: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/CAHut+PtbQi8Dw_0upS9dd=Oh9OqfOdAo=0_DOKG=YSRT_a+0Fw@mail.gmail.com M doc/src/sgml/ref/pg_walsummary.sgml
Avoid name collision with NOT NULL constraints
commit : 0eeffd31bf9bb73446387cd7eebbbf43148aa281
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 21 Feb 2026 12:22:08 +0100
committer: Álvaro Herrera <alvherre@kurilemu.de>
date : Sat, 21 Feb 2026 12:22:08 +0100 If a CREATE TABLE statement defined a constraint whose name is identical
to the name generated for a NOT NULL constraint, we'd throw an
(unnecessary) unique key violation error on
pg_constraint_conrelid_contypid_conname_index: this can easily be
avoided by choosing a different name for the NOT NULL constraint.
Fix by passing the constraint names already created by
AddRelationNewConstraints() to AddRelationNotNullConstraints(), so that
the latter can avoid name collisions with them.
Bug: #19393
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reported-by: Hüseyin Demir <huseyin.d3r@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/19393-6a82427485a744cf@postgresql.org M src/backend/catalog/heap.c
M src/backend/commands/tablecmds.c
M src/include/catalog/heap.h
M src/test/regress/expected/create_table.out
M src/test/regress/sql/create_table.sql
Split PGPROC 'links' field into two, for clarity
commit : 36bbcd5be3ffee1aa03f69228022decef6ebd37a
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 20 Feb 2026 22:34:42 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 20 Feb 2026 22:34:42 +0200 The field was mainly used for the position in a LOCK's wait queue, but
also as the position in a the freelist when the PGPROC entry was not
in use. The reuse saves some memory at the expense of readability,
which seems like a bad tradeoff. If we wanted to make the struct
smaller there's other things we could do, but we're actually just
discussing adding padding to the struct for performance reasons.
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/3dd6f70c-b94d-4428-8e75-74a7136396be@iki.fi M src/backend/access/transam/twophase.c
M src/backend/storage/lmgr/deadlock.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h
Speedup COPY FROM with additional function inlining.
commit : dc592a41557b072178f1798700bf9c69cd8e4235
author : Nathan Bossart <nathan@postgresql.org>
date : Fri, 20 Feb 2026 12:07:27 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Fri, 20 Feb 2026 12:07:27 -0600 Following the example set by commit 58a359e585, we can squeeze out
a little more performance from COPY FROM (FORMAT {text,csv}) by
inlining CopyReadLineText() and passing the is_csv parameter as a
constant. This allows the compiler to emit specialized code with
fewer branches.
This is preparatory work for a proposed follow-up commit that would
further optimize this code with SIMD instructions.
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Ayoub Kazar <ma_kazar@esi.dz>
Tested-by: Manni Wood <manni.wood@enterprisedb.com>
Discussion: https://postgr.es/m/CAOzEurSW8cNr6TPKsjrstnPfhf4QyQqB4tnPXGGe8N4e_v7Jig%40mail.gmail.com M src/backend/commands/copyfromparse.c
Fix expanding 'bounds' in pg_trgm's calc_word_similarity() function
commit : 18bcdb75d155e68a9cb34b5b76d0bccd0a234110
author : Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 20 Feb 2026 11:56:42 +0200
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>
date : Fri, 20 Feb 2026 11:56:42 +0200 If the 'bounds' array needs to be expanded, because the input contains
more trigrams than the initial guess, the code didn't return the
reallocated array correctly to the caller. That could lead to a crash
in the rare case that the input string becomes longer when it's
lower-cased. The only known instance of that is when an ICU locale is
used with certain single-byte encodings. This was an oversight in
commit 00896ddaf41f.
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Backpatch-through: 18 M contrib/pg_trgm/trgm_op.c
Fix computation of varnullingrels when translating appendrel Var
commit : 691977d37037f30e39cc65f60e327f678f2cebe9
author : Richard Guo <rguo@postgresql.org>
date : Fri, 20 Feb 2026 17:57:53 +0900
committer: Richard Guo <rguo@postgresql.org>
date : Fri, 20 Feb 2026 17:57:53 +0900 When adjust_appendrel_attrs translates a Var referencing a parent
relation into a Var referencing a child relation, it propagates
varnullingrels from the parent Var to the translated Var. Previously,
the code simply overwrote the translated Var's varnullingrels with
those of the parent.
This was incorrect because the translated Var might already possess
nonempty varnullingrels. This happens, for example, when a LATERAL
subquery within a UNION ALL references a Var from the nullable side of
an outer join. In such cases, the translated Var correctly carries
the outer join's relid in its varnullingrels. Overwriting these bits
with the parent Var's set caused the planner to lose track of the fact
that the Var could be nulled by that outer join.
In the reported case, because the underlying column had a NOT NULL
constraint, the planner incorrectly deduced that the Var could never
be NULL and discarded essential IS NOT NULL filters. This led to
incorrect query results where NULL rows were returned instead of being
filtered out.
To fix, use bms_add_members to merge the parent Var's varnullingrels
into the translated Var's existing set, preserving both sources of
nullability.
Back-patch to v16. Although the reported case does not seem to cause
problems in v16, leaving incorrect varnullingrels in the tree seems
like a trap for the unwary.
Bug: #19412
Reported-by: Sergey Shinderuk <s.shinderuk@postgrespro.ru>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19412-1d0318089b86859e@postgresql.org
Backpatch-through: 16 M src/backend/optimizer/util/appendinfo.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql
Fix constant in error message for recovery_target_timeline
commit : 0dc22fff64716dc3937705f0b7d0980475b164c1
author : Michael Paquier <michael@paquier.xyz>
date : Fri, 20 Feb 2026 16:17:57 +0900
committer: Michael Paquier <michael@paquier.xyz>
date : Fri, 20 Feb 2026 16:17:57 +0900 The intention was to use PG_UINT32_MAX, not UINT_MAX. Let's be
consistent and use the same constant.
Thinko in fd7d7b719137.
Author: David Steele <david@pgbackrest.org>
Discussion: https://postgr.es/m/aZfXO97jSQaTTlfD@paquier.xyz M src/backend/access/transam/xlogrecovery.c
Avoid including worker_internal.h in pgstat.h.
commit : 9842e8aca096d9b988a3ae924cdf4aa7e1bb2ea2
author : Amit Kapila <akapila@postgresql.org>
date : Fri, 20 Feb 2026 09:26:33 +0530
committer: Amit Kapila <akapila@postgresql.org>
date : Fri, 20 Feb 2026 09:26:33 +0530 pgstat.h is a widely included header. Including worker_internal.h there is
unnecessary and creates tight coupling. By refactoring
pgstat_report_subscription_error() to fetch the required
LogicalRepWorkerType internally rather than receiving it as an argument,
we can eliminate the need for the internal header.
Reported-by: Andres Freund <andres@anarazel.de>
Author: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/aY-UE-4t7FiYgH3t@alap3.anarazel.de M src/backend/commands/functioncmds.c
M src/backend/replication/logical/sequencesync.c
M src/backend/replication/logical/tablesync.c
M src/backend/replication/logical/worker.c
M src/backend/storage/ipc/procsignal.c
M src/backend/utils/activity/pgstat_subscription.c
M src/include/pgstat.h
M src/include/replication/worker_internal.h
M src/test/modules/test_custom_stats/test_custom_var_stats.c
Remove SpinLockFree() and S_LOCK_FREE().
commit : ba401828c194c17031a6a2dedd97bc0defd80d4b
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 19 Feb 2026 16:19:41 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 19 Feb 2026 16:19:41 -0600 S_LOCK_FREE() is used by the test program in s_lock.c, but nobody
has voiced concerns about losing some coverage there.
SpinLockFree() appears to have been unused since it was introduced
by commit 499abb0c0f. There was agreement to remove these in 2020,
but it never happened. Since we still have agreement for removal
in 2026, let's do that now.
Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/aZX2oUcKf7IzHnnK%40nathan
Discussion: https://postgr.es/m/20200608225338.m5zho424w6lpwb2d%40alap3.anarazel.de M src/backend/storage/lmgr/s_lock.c
M src/include/storage/s_lock.h
M src/include/storage/spin.h
Assume "inline" keyword is available.
commit : aa71a35a40b504b33834238ee6d2d551ba4a3740
author : Nathan Bossart <nathan@postgresql.org>
date : Thu, 19 Feb 2026 14:37:29 -0600
committer: Nathan Bossart <nathan@postgresql.org>
date : Thu, 19 Feb 2026 14:37:29 -0600 This has been a keyword since C99, and we now require C11, so we no
longer need to use __inline__ or to check for it at configure time.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/aZdGbDaV4_yKCMc-%40nathan M configure
M configure.ac
M src/include/pg_config.h.in
M src/include/port/atomics/arch-x86.h
M src/include/storage/s_lock.h
Fix add_partial_path interaction with disabled_nodes
commit : 6e466e1e839e2d40b30af9cbda107af867d259f6
author : Robert Haas <rhaas@postgresql.org>
date : Thu, 19 Feb 2026 13:46:10 -0500
committer: Robert Haas <rhaas@postgresql.org>
date : Thu, 19 Feb 2026 13:46:10 -0500 Commit e22253467942fdb100087787c3e1e3a8620c54b2 adjusted the logic in
add_path() to keep the path list sorted by disabled_nodes and then by
total_cost, but failed to make the corresponding adjustment to
add_partial_path. As a result, add_partial_path might sort the path list
just by total cost, which could lead to later planner misbehavior.
In principle, this should be back-patched to v18, but we are typically
reluctant to back-patch planner fixes for fear of destabilizing working
installations, and it is unclear to me that this has sufficiently
serious consequences to justify an exception, so for now, no back-patch.
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: http://postgr.es/m/CAMbWs4-mO3jMK4t_LgcJ+7Eo=NmGgkxettgRaVbJzZvVZ1koMA@mail.gmail.com M src/backend/optimizer/util/pathnode.c
Add translator comment
commit : fc3896c786a2df86904e138d819c16f263bf7673
author : Álvaro Herrera <alvherre@kurilemu.de>
date : Thu, 19 Feb 2026 17:11:04 +0100