summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kapila2024-10-08 06:31:35 +0000
committerAmit Kapila2024-10-08 06:31:35 +0000
commit0c40d901907ab16dcfc3895a16d718231e2f8729 (patch)
tree3fd372d2e8330a19e0644f4dae796345aacc5530
parenteba8cc1af8ec57aff99f11ef9cdf24a641c159b0 (diff)
Stabilize the test added by commit 022564f60c.
The test was unstable in branches 14 and 15 as we were relying on the number of changes in the table having a toast column to start streaming. On branches >= 16, we have a GUC debug_logical_replication_streaming which can stream each change, so the test was stable in those branches. Change the test to use PREPARE TRANSACTION as that should make the result consistent and test the code changed in 022564f60c. Reported-by: Daniel Gustafsson as per buildfarm Author: Hou Zhijie, Amit Kapila Backpatch-through: 14 Discussion: https://postgr.es/m/[email protected]
-rw-r--r--contrib/test_decoding/expected/stream.out22
-rw-r--r--contrib/test_decoding/expected/twophase.out23
-rw-r--r--contrib/test_decoding/sql/stream.sql22
-rw-r--r--contrib/test_decoding/sql/twophase.sql22
4 files changed, 45 insertions, 44 deletions
diff --git a/contrib/test_decoding/expected/stream.out b/contrib/test_decoding/expected/stream.out
index d4bfbf975db..0f21dcb8e0e 100644
--- a/contrib/test_decoding/expected/stream.out
+++ b/contrib/test_decoding/expected/stream.out
@@ -106,28 +106,6 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'incl
committing streamed transaction
(17 rows)
--- 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
-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();
- ?column?
--------------
- force flush
-(1 row)
-
-SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
- count
--------
- 3
-(1 row)
-
-COMMIT;
-RESET debug_logical_replication_streaming;
DROP TABLE stream_test;
SELECT pg_drop_replication_slot('regression_slot');
pg_drop_replication_slot
diff --git a/contrib/test_decoding/expected/twophase.out b/contrib/test_decoding/expected/twophase.out
index e89dc74a5e4..22d128d431f 100644
--- a/contrib/test_decoding/expected/twophase.out
+++ b/contrib/test_decoding/expected/twophase.out
@@ -205,10 +205,33 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
COMMIT
(3 rows)
+-- Test that accessing a TOAST table is permitted during the decoding of a
+-- prepared transaction.
+-- 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
+BEGIN;
+INSERT INTO test_tab VALUES('test');
+PREPARE TRANSACTION 'test_toast_table_access';
+SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
+ count
+-------
+ 3
+(1 row)
+
+COMMIT PREPARED 'test_toast_table_access';
+-- consume commit prepared
+SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
+ data
+-------------------------------------------
+ COMMIT PREPARED 'test_toast_table_access'
+(1 row)
+
-- Test 8:
-- cleanup and make sure results are also empty
DROP TABLE test_prepared1;
DROP TABLE test_prepared2;
+DROP TABLE test_tab;
-- show results. There should be nothing to show
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
data
diff --git a/contrib/test_decoding/sql/stream.sql b/contrib/test_decoding/sql/stream.sql
index 0549d3204a2..4feec62972a 100644
--- a/contrib/test_decoding/sql/stream.sql
+++ b/contrib/test_decoding/sql/stream.sql
@@ -44,27 +44,5 @@ toasted-123456789012345678901234567890123456789012345678901234567890123456789012
SELECT data 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');
diff --git a/contrib/test_decoding/sql/twophase.sql b/contrib/test_decoding/sql/twophase.sql
index aff5114eb10..0ff6ede1f38 100644
--- a/contrib/test_decoding/sql/twophase.sql
+++ b/contrib/test_decoding/sql/twophase.sql
@@ -104,10 +104,32 @@ COMMIT PREPARED 'test_prepared_nodecode';
-- should be decoded now
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
+-- Test that accessing a TOAST table is permitted during the decoding of a
+-- prepared transaction.
+
+-- 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
+
+BEGIN;
+INSERT INTO test_tab VALUES('test');
+PREPARE TRANSACTION 'test_toast_table_access';
+
+SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
+
+COMMIT PREPARED 'test_toast_table_access';
+
+-- consume commit prepared
+SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
+
-- Test 8:
-- cleanup and make sure results are also empty
DROP TABLE test_prepared1;
DROP TABLE test_prepared2;
+DROP TABLE test_tab;
-- show results. There should be nothing to show
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');