| 1 |
# Test decoding of in-progress transaction containing dml and a concurrent |
| 2 |
# transaction with ddl operation. The transaction containing ddl operation |
| 3 |
# should not get streamed as it doesn't have any changes. |
| 4 |
|
| 5 |
setup |
| 6 |
{ |
| 7 |
SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding'); |
| 8 |
|
| 9 |
-- consume DDL |
| 10 |
SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); |
| 11 |
CREATE OR REPLACE FUNCTION large_val() RETURNS bytea LANGUAGE SQL AS $$ select string_agg(sha256(g::text::bytea), '') from generate_series(1, 83000) g $$; |
| 12 |
} |
| 13 |
|
| 14 |
teardown |
| 15 |
{ |
| 16 |
DROP TABLE IF EXISTS stream_test; |
| 17 |
DROP TABLE IF EXISTS stream_test1; |
| 18 |
SELECT 'stop' FROM pg_drop_replication_slot('isolation_slot'); |
| 19 |
} |
| 20 |
|
| 21 |
session "s0" |
| 22 |
setup { SET synchronous_commit=on; } |
| 23 |
step "s0_begin" { BEGIN; } |
| 24 |
step "s0_ddl" {CREATE TABLE stream_test1(data bytea);} |
| 25 |
|
| 26 |
session "s2" |
| 27 |
setup { SET synchronous_commit=on; } |
| 28 |
step "s2_ddl" {CREATE TABLE stream_test2(data bytea);} |
| 29 |
|
| 30 |
# The transaction commit for s1_ddl will add the INTERNAL_SNAPSHOT change to |
| 31 |
# the currently running s0_ddl and we want to test that s0_ddl should not get |
| 32 |
# streamed when user asked to skip-empty-xacts. Similarly, the |
| 33 |
# INTERNAL_SNAPSHOT change added by s2_ddl should not change the results for |
| 34 |
# what gets streamed. |
| 35 |
session "s1" |
| 36 |
setup { SET synchronous_commit=on; } |
| 37 |
step "s1_ddl" { CREATE TABLE stream_test(data bytea); } |
| 38 |
step "s1_begin" { BEGIN; } |
| 39 |
step "s1_toast_insert" {INSERT INTO stream_test SELECT large_val();} |
| 40 |
step "s1_commit" { COMMIT; } |
| 41 |
step "s1_get_stream_changes" { SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');} |
| 42 |
|
| 43 |
permutation "s0_begin" "s0_ddl" "s1_ddl" "s1_begin" "s1_toast_insert" "s2_ddl" "s1_commit" "s1_get_stream_changes" |