Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd759c1a

Browse files
author
Amit Kapila
committed
Stabilize the test added by commit022564f.
The test was unstable in branches 14 and 15 as we were relying on thenumber of changes in the table having a toast column to start streaming.On branches >= 16, we have a GUC debug_logical_replication_streaming whichcan stream each change, so the test was stable in those branches.Change the test to use PREPARE TRANSACTION as that should make the resultconsistent and test the code changed in022564f.Reported-by: Daniel Gustafsson as per buildfarmAuthor: Hou Zhijie, Amit KapilaBackpatch-through: 14Discussion:https://postgr.es/m/8C2F86AA-981E-4803-B14D-E264C0255330@yesql.se
1 parent4572d59 commitd759c1a

File tree

4 files changed

+45
-44
lines changed

4 files changed

+45
-44
lines changed

‎contrib/test_decoding/expected/stream.out

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,6 @@ SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL,
128128
5
129129
(1 row)
130130

131-
-- Test that accessing a TOAST table in streaming mode is allowed.
132-
-- Create a table with a column that uses a TOASTed default value.
133-
-- (temporarily hide query, to avoid the long CREATE TABLE stmt)
134-
\set ECHO none
135-
SET debug_logical_replication_streaming = immediate;
136-
BEGIN;
137-
INSERT INTO test_tab VALUES(1);
138-
-- Force WAL flush, so that the above changes will be streamed.
139-
SELECT 'force flush' FROM pg_switch_wal();
140-
?column?
141-
-------------
142-
force flush
143-
(1 row)
144-
145-
SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
146-
count
147-
-------
148-
3
149-
(1 row)
150-
151-
COMMIT;
152-
RESET debug_logical_replication_streaming;
153131
DROP TABLE stream_test;
154132
SELECT pg_drop_replication_slot('regression_slot');
155133
pg_drop_replication_slot

‎contrib/test_decoding/expected/twophase.out

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,34 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
205205
COMMIT
206206
(3 rows)
207207

208+
-- Test that accessing a TOAST table is permitted during the decoding of a
209+
-- prepared transaction.
210+
-- Create a table with a column that uses a TOASTed default value.
211+
-- (temporarily hide query, to avoid the long CREATE TABLE stmt)
212+
\set ECHO none
213+
BEGIN;
214+
INSERT INTO test_tab VALUES('test');
215+
PREPARE TRANSACTION 'test_toast_table_access';
216+
SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
217+
count
218+
-------
219+
3
220+
(1 row)
221+
222+
COMMIT PREPARED 'test_toast_table_access';
223+
-- consume commit prepared
224+
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
225+
data
226+
-------------------------------------------
227+
COMMIT PREPARED 'test_toast_table_access'
228+
(1 row)
229+
208230
-- Test 8:
209231
-- cleanup and make sure results are also empty
210232
DROP TABLE test_prepared1;
211233
DROP TABLE test_prepared2;
212234
DROP TABLE test_prepared_savepoint;
235+
DROP TABLE test_tab;
213236
-- show results. There should be nothing to show
214237
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
215238
data

‎contrib/test_decoding/sql/stream.sql

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,5 @@ ROLLBACK TO s1;
5959
COMMIT;
6060
SELECTcount(*)FROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','stream-changes','1');
6161

62-
-- Test that accessing a TOAST table in streaming mode is allowed.
63-
64-
-- Create a table with a column that uses a TOASTed default value.
65-
-- (temporarily hide query, to avoid the long CREATE TABLE stmt)
66-
\set ECHO none
67-
SELECT'CREATE TABLE test_tab (a text DEFAULT'''|| string_agg('toast value','')||''');'FROM generate_series(1,4000)
68-
\gexec
69-
\set ECHO all
70-
71-
SET debug_logical_replication_streaming= immediate;
72-
73-
BEGIN;
74-
INSERT INTO test_tabVALUES(1);
75-
76-
-- Force WAL flush, so that the above changes will be streamed.
77-
SELECT'force flush'FROM pg_switch_wal();
78-
79-
SELECTcount(*)FROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','stream-changes','1');
80-
COMMIT;
81-
82-
RESET debug_logical_replication_streaming;
83-
8462
DROPTABLE stream_test;
8563
SELECT pg_drop_replication_slot('regression_slot');

‎contrib/test_decoding/sql/twophase.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,33 @@ COMMIT PREPARED 'test_prepared_nodecode';
104104
-- should be decoded now
105105
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1');
106106

107+
-- Test that accessing a TOAST table is permitted during the decoding of a
108+
-- prepared transaction.
109+
110+
-- Create a table with a column that uses a TOASTed default value.
111+
-- (temporarily hide query, to avoid the long CREATE TABLE stmt)
112+
\set ECHO none
113+
SELECT'CREATE TABLE test_tab (a text DEFAULT'''|| string_agg('toast value','')||''');'FROM generate_series(1,4000)
114+
\gexec
115+
\set ECHO all
116+
117+
BEGIN;
118+
INSERT INTO test_tabVALUES('test');
119+
PREPARE TRANSACTION'test_toast_table_access';
120+
121+
SELECTcount(*)FROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','stream-changes','1');
122+
123+
COMMIT PREPARED'test_toast_table_access';
124+
125+
-- consume commit prepared
126+
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','stream-changes','1');
127+
107128
-- Test 8:
108129
-- cleanup and make sure results are also empty
109130
DROPTABLE test_prepared1;
110131
DROPTABLE test_prepared2;
111132
DROPTABLE test_prepared_savepoint;
133+
DROPTABLE test_tab;
112134
-- show results. There should be nothing to show
113135
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1');
114136

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp