pgsql: Fix some edge cases with characteristics after COMMIT/ROLLBACK A

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix some edge cases with characteristics after COMMIT/ROLLBACK A
Date: 2026-11-12 22:55:42
Message-ID: E1xRdhm-00000000UV4-0Msn@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix some edge cases with characteristics after COMMIT/ROLLBACK AND CHAIN

Certain combinations of transaction sequences with AND CHAIN failed to
preserve the top-transaction characteristics, in some cases:
* When a transaction block failed, the chained transaction used the
default characteristics, not the characteristics of the transaction
chaining from.
* When COMMIT AND CHAIN was issued in a subtransaction that had the idea
to switch read_only, the chained transaction inherited the read-only
state of the subtransaction, not of the top transaction. The state is
reset when the subtransaction ends, like RELEASE. The characteristics
are now saved once all the subtransactions are committed.

Narek has reported the first problem. I have discovered the second
pattern while digging through this area of the code. Tests are added
for all the patterns spotted.

Author: Narek Galstyan <narek(dot)galstyan(at)enterprisedb(dot)com>
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/CAHsn6_z-ewqXWe2h--SK93AdnPSOvjvF9KLodWckFZKAjxcONw@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dc9b5687c8db55a64dd9b3ebff966c9eb0f9198f

Modified Files
--------------
src/backend/access/transam/xact.c | 18 +++++++
src/test/regress/expected/transactions.out | 76 ++++++++++++++++++++++++++++++
src/test/regress/sql/transactions.sql | 34 +++++++++++++
3 files changed, 128 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Richard Guo 2026-11-13 00:54:38 pgsql: Fix GROUP BY column removal for NULLS NOT DISTINCT indexes
Previous Message Dean Rasheed 2026-11-12 21:22:16 pgsql: Fix MERGE into inheritance parent with extra child columns.