diff options
author | Amit Kapila | 2024-10-07 10:08:45 +0000 |
---|---|---|
committer | Amit Kapila | 2024-10-07 10:08:45 +0000 |
commit | 022564f60ca5cade8fd663906f3ee514573b4b5e (patch) | |
tree | b8059494ae9ea7082beeaf0dba0c2d90586bc281 /contrib/test_decoding/sql | |
parent | 6ae387eb6334e71c94347b50b711b6750ef71b50 (diff) |
Fix fetching default toast value during decoding of in-progress transactions.
During logical decoding of in-progress transactions, we perform the toast
table scan while fetching the default toast value for an attribute. We
forgot to initialize the flag during this scan to indicate that the system
table scan is in progress. We need this flag to ensure that during logical
decoding we never directly access the tableam or heap APIs because we check
for concurrent aborts only in systable_* APIs.
Reported-by: Alexander Lakhin
Author: Takeshi Ideriha, Hou Zhijie
Reviewed-by: Amit Kapila, Hou Zhijie
Backpatch-through: 14
Discussion: https://postgr.es/m/18641-6687273b7f15269d@postgresql.org
Diffstat (limited to 'contrib/test_decoding/sql')
-rw-r--r-- | contrib/test_decoding/sql/stream.sql | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/test_decoding/sql/stream.sql b/contrib/test_decoding/sql/stream.sql index 7f43f0c2ab7..d7a696586e9 100644 --- a/contrib/test_decoding/sql/stream.sql +++ b/contrib/test_decoding/sql/stream.sql @@ -59,5 +59,27 @@ ROLLBACK TO s1; COMMIT; SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); +-- Test that accessing a TOAST table in streaming mode is allowed. + +-- Create a table with a column that uses a TOASTed default value. +-- (temporarily hide query, to avoid the long CREATE TABLE stmt) +\set ECHO none +SELECT 'CREATE TABLE test_tab (a text DEFAULT ''' || string_agg('toast value', '') || ''');' FROM generate_series(1, 4000) +\gexec +\set ECHO all + +SET debug_logical_replication_streaming = immediate; + +BEGIN; +INSERT INTO test_tab VALUES(1); + +-- Force WAL flush, so that the above changes will be streamed. +SELECT 'force flush' FROM pg_switch_wal(); + +SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); +COMMIT; + +RESET debug_logical_replication_streaming; + DROP TABLE stream_test; SELECT pg_drop_replication_slot('regression_slot'); |