From d57466124f66ed276b7ab1f009fa659bd9987454 Mon Sep 17 00:00:00 2001 From: Zhijie Hou Date: Sun, 8 Nov 2026 22:44:19 +0800 Subject: [PATCH] Top-up for 0001: Add regression test for spilled txn with empty subxact Author: Zhijie Hou --- contrib/test_decoding/expected/stream.out | 24 +++++++++++++++++++++++ contrib/test_decoding/sql/stream.sql | 15 ++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/contrib/test_decoding/expected/stream.out b/contrib/test_decoding/expected/stream.out index 0ec5c933610..9c164847b03 100644 --- a/contrib/test_decoding/expected/stream.out +++ b/contrib/test_decoding/expected/stream.out @@ -157,6 +157,30 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc COMMIT (3 rows) +-- bug #19839 +-- +-- A subtransaction without decoded changes must not be marked as serialized +-- when its parent transaction spills to disk during a partial TOAST change +-- (stream_test.data has EXTERNAL storage set above). Otherwise, truncating +-- the transaction after streaming fails on the subtransaction's invalid +-- final_lsn. +BEGIN; +SAVEPOINT s; +SELECT 1 FROM stream_test LIMIT 1 FOR UPDATE; + ?column? +---------- + 1 +(1 row) + +RELEASE SAVEPOINT s; +INSERT INTO stream_test VALUES (repeat('a', 100000)); +COMMIT; +SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); + count +------- + 4 +(1 row) + DROP TABLE stream_test; SELECT pg_drop_replication_slot('regression_slot'); pg_drop_replication_slot diff --git a/contrib/test_decoding/sql/stream.sql b/contrib/test_decoding/sql/stream.sql index 5e45a8e9b64..f3159335564 100644 --- a/contrib/test_decoding/sql/stream.sql +++ b/contrib/test_decoding/sql/stream.sql @@ -82,5 +82,20 @@ ROLLBACK; INSERT INTO stream_test VALUES ('after-abort'); SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); +-- bug #19839 +-- +-- A subtransaction without decoded changes must not be marked as serialized +-- when its parent transaction spills to disk during a partial TOAST change +-- (stream_test.data has EXTERNAL storage set above). Otherwise, truncating +-- the transaction after streaming fails on the subtransaction's invalid +-- final_lsn. +BEGIN; +SAVEPOINT s; +SELECT 1 FROM stream_test LIMIT 1 FOR UPDATE; +RELEASE SAVEPOINT s; +INSERT INTO stream_test VALUES (repeat('a', 100000)); +COMMIT; +SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); + DROP TABLE stream_test; SELECT pg_drop_replication_slot('regression_slot'); -- 2.54.0 (Apple Git-157)