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

Commit0c40d90

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 parenteba8cc1 commit0c40d90

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
@@ -106,28 +106,6 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'incl
106106
committing streamed transaction
107107
(17 rows)
108108

109-
-- Test that accessing a TOAST table in streaming mode is allowed.
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-
SET debug_logical_replication_streaming = immediate;
114-
BEGIN;
115-
INSERT INTO test_tab VALUES(1);
116-
-- Force WAL flush, so that the above changes will be streamed.
117-
SELECT 'force flush' FROM pg_switch_wal();
118-
?column?
119-
-------------
120-
force flush
121-
(1 row)
122-
123-
SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
124-
count
125-
-------
126-
3
127-
(1 row)
128-
129-
COMMIT;
130-
RESET debug_logical_replication_streaming;
131109
DROP TABLE stream_test;
132110
SELECT pg_drop_replication_slot('regression_slot');
133111
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,10 +205,33 @@ 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;
234+
DROP TABLE test_tab;
212235
-- show results. There should be nothing to show
213236
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
214237
data

‎contrib/test_decoding/sql/stream.sql

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,5 @@ toasted-123456789012345678901234567890123456789012345678901234567890123456789012
4444

4545
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','stream-changes','1');
4646

47-
-- Test that accessing a TOAST table in streaming mode is allowed.
48-
49-
-- Create a table with a column that uses a TOASTed default value.
50-
-- (temporarily hide query, to avoid the long CREATE TABLE stmt)
51-
\set ECHO none
52-
SELECT'CREATE TABLE test_tab (a text DEFAULT'''|| string_agg('toast value','')||''');'FROM generate_series(1,4000)
53-
\gexec
54-
\set ECHO all
55-
56-
SET debug_logical_replication_streaming= immediate;
57-
58-
BEGIN;
59-
INSERT INTO test_tabVALUES(1);
60-
61-
-- Force WAL flush, so that the above changes will be streamed.
62-
SELECT'force flush'FROM pg_switch_wal();
63-
64-
SELECTcount(*)FROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','stream-changes','1');
65-
COMMIT;
66-
67-
RESET debug_logical_replication_streaming;
68-
6947
DROPTABLE stream_test;
7048
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,10 +104,32 @@ 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;
132+
DROPTABLE test_tab;
111133
-- show results. There should be nothing to show
112134
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1');
113135

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp