From 90cfe272a96ab87f128f85f95db21220b7e9e772 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 15 Aug 2024 17:17:03 +1000 Subject: [PATCH v1] Add missing test case --- src/test/subscription/t/004_sync.pl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl index a2d9462..8c3630e 100644 --- a/src/test/subscription/t/004_sync.pl +++ b/src/test/subscription/t/004_sync.pl @@ -172,6 +172,41 @@ ok( $node_publisher->poll_query_until( 'postgres', 'SELECT count(*) = 0 FROM pg_replication_slots'), 'DROP SUBSCRIPTION during error can clean up the slots on the publisher'); +# clean up +$node_publisher->safe_psql('postgres', "DROP TABLE tab_rep"); +$node_subscriber->safe_psql('postgres', "DROP TABLE tab_rep"); + +########## +# TEST: +# +# When a subscriber table has a column missing that was specified on +# the publisher table. +########## + +# setup structure with existing data on publisher +$node_publisher->safe_psql('postgres', "CREATE TABLE tab_rep (a int, b int, c int)"); +$node_publisher->safe_psql('postgres', + "INSERT INTO tab_rep VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3)"); + +# add table on subscriber; note columns 'b' and 'c' are missing +$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_rep (a int)"); +my $offset = -s $node_subscriber->logfile; + +# create the subscription +$node_subscriber->safe_psql('postgres', + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub" +); + +# confirm missing column error is reported +$node_subscriber->wait_for_log( + qr/ERROR: ( [A-Z0-9]+:)? logical replication target relation "public.tab_rep" is missing replicated columns: "b", "c"/, + $offset); + +# clean up +$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub"); +$node_subscriber->safe_psql('postgres', "DROP TABLE tab_rep"); +$node_publisher->safe_psql('postgres', "DROP TABLE tab_rep"); + $node_subscriber->stop('fast'); $node_publisher->stop('fast'); -- 1.8.3.1