@ -3,7 +3,7 @@ use strict;
use warnings ;
use warnings ;
use PostgresNode ;
use PostgresNode ;
use TestLib ;
use TestLib ;
use Test::More tests = > 15 ;
use Test::More tests = > 16 ;
# Initialize publisher node
# Initialize publisher node
my $ node_publisher = get_new_node ( 'publisher' ) ;
my $ node_publisher = get_new_node ( 'publisher' ) ;
@ -22,6 +22,10 @@ $node_publisher->safe_psql('postgres',
"CREATE TABLE tab_ins AS SELECT generate_series(1,1002) AS a" ) ;
"CREATE TABLE tab_ins AS SELECT generate_series(1,1002) AS a" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
"CREATE TABLE tab_full AS SELECT generate_series(1,10) AS a" ) ;
"CREATE TABLE tab_full AS SELECT generate_series(1,10) AS a" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
"CREATE TABLE tab_full2 (x text)" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
"INSERT INTO tab_full2 VALUES ('a'), ('b'), ('b')" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
"CREATE TABLE tab_rep (a int primary key)" ) ;
"CREATE TABLE tab_rep (a int primary key)" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
@ -33,6 +37,7 @@ $node_publisher->safe_psql('postgres',
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_notrep (a int)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_notrep (a int)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_ins (a int)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_ins (a int)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_full (a int)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_full (a int)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' , "CREATE TABLE tab_full2 (x text)" ) ;
$ node_subscriber - > safe_psql ( 'postgres' ,
$ node_subscriber - > safe_psql ( 'postgres' ,
"CREATE TABLE tab_rep (a int primary key)" ) ;
"CREATE TABLE tab_rep (a int primary key)" ) ;
# different column count and order than on publisher
# different column count and order than on publisher
@ -45,7 +50,7 @@ $node_publisher->safe_psql('postgres', "CREATE PUBLICATION tap_pub");
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)" ) ;
"CREATE PUBLICATION tap_pub_ins_only WITH (publish = insert)" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_mixed" ) ;
"ALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full, tab_full2, tab_ mixed" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins" ) ;
"ALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins" ) ;
@ -108,13 +113,18 @@ $node_publisher->safe_psql('postgres',
"ALTER TABLE tab_full REPLICA IDENTITY FULL" ) ;
"ALTER TABLE tab_full REPLICA IDENTITY FULL" ) ;
$ node_subscriber - > safe_psql ( 'postgres' ,
$ node_subscriber - > safe_psql ( 'postgres' ,
"ALTER TABLE tab_full REPLICA IDENTITY FULL" ) ;
"ALTER TABLE tab_full REPLICA IDENTITY FULL" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
"ALTER TABLE tab_full2 REPLICA IDENTITY FULL" ) ;
$ node_subscriber - > safe_psql ( 'postgres' ,
"ALTER TABLE tab_full2 REPLICA IDENTITY FULL" ) ;
$ node_publisher - > safe_psql ( 'postgres' ,
$ node_publisher - > safe_psql ( 'postgres' ,
"ALTER TABLE tab_ins REPLICA IDENTITY FULL" ) ;
"ALTER TABLE tab_ins REPLICA IDENTITY FULL" ) ;
$ node_subscriber - > safe_psql ( 'postgres' ,
$ node_subscriber - > safe_psql ( 'postgres' ,
"ALTER TABLE tab_ins REPLICA IDENTITY FULL" ) ;
"ALTER TABLE tab_ins REPLICA IDENTITY FULL" ) ;
# and do the update
# and do the updates
$ node_publisher - > safe_psql ( 'postgres' , "UPDATE tab_full SET a = a * a" ) ;
$ node_publisher - > safe_psql ( 'postgres' , "UPDATE tab_full SET a = a * a" ) ;
$ node_publisher - > safe_psql ( 'postgres' , "UPDATE tab_full2 SET x = 'bb' WHERE x = 'b'" ) ;
# Wait for subscription to catch up
# Wait for subscription to catch up
$ node_publisher - > poll_query_until ( 'postgres' , $ caughtup_query )
$ node_publisher - > poll_query_until ( 'postgres' , $ caughtup_query )
@ -125,6 +135,13 @@ $result = $node_subscriber->safe_psql('postgres',
is ( $ result , qq( 20|1|100 ) ,
is ( $ result , qq( 20|1|100 ) ,
'update works with REPLICA IDENTITY FULL and duplicate tuples' ) ;
'update works with REPLICA IDENTITY FULL and duplicate tuples' ) ;
$ result = $ node_subscriber - > safe_psql ( 'postgres' ,
"SELECT x FROM tab_full2 ORDER BY 1" ) ;
is ( $ result , qq( a
bb
bb ) ,
'update works with REPLICA IDENTITY FULL and text datums' ) ;
# check that change of connection string and/or publication list causes
# check that change of connection string and/or publication list causes
# restart of subscription workers. Not all of these are registered as tests
# restart of subscription workers. Not all of these are registered as tests
# as we need to poll for a change but the test suite will fail none the less
# as we need to poll for a change but the test suite will fail none the less