|
3 | 3 | use warnings;
|
4 | 4 | use PostgresNode;
|
5 | 5 | use TestLib;
|
6 |
| -use Test::More tests => 3; |
| 6 | +use Test::More tests => 4; |
7 | 7 |
|
8 | 8 | # Create publisher node
|
9 | 9 | my $node_publisher = get_new_node('publisher');
|
|
22 | 22 | "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
|
23 | 23 |
|
24 | 24 | # Setup structure on subscriber
|
25 |
| -$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"); |
| 25 | +$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999, e int GENERATED BY DEFAULT AS IDENTITY)"); |
26 | 26 |
|
27 | 27 | # Setup logical replication
|
28 | 28 | my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
|
|
52 | 52 | $node_publisher->wait_for_catchup($appname);
|
53 | 53 |
|
54 | 54 | $result =
|
55 |
| - $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999) FROM test_tab"); |
56 |
| -is($result, qq(2|2|2), 'check extra columns contain local defaults'); |
| 55 | + $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab"); |
| 56 | +is($result, qq(2|2|2|2), 'check extra columns contain local defaults after copy'); |
57 | 57 |
|
58 | 58 | # Change the local values of the extra columns on the subscriber,
|
59 | 59 | # update publisher, and check that subscriber retains the expected
|
|
67 | 67 | $node_subscriber->safe_psql('postgres', "SELECT count(*), count(extract(epoch from c) = 987654321), count(d = 999) FROM test_tab");
|
68 | 68 | is($result, qq(2|2|2), 'check extra columns contain locally changed data');
|
69 | 69 |
|
| 70 | +# Another insert |
| 71 | +$node_publisher->safe_psql('postgres', |
| 72 | + "INSERT INTO test_tab VALUES (3, 'baz')"); |
| 73 | + |
| 74 | +$node_publisher->wait_for_catchup($appname); |
| 75 | + |
| 76 | +$result = |
| 77 | + $node_subscriber->safe_psql('postgres', "SELECT count(*), count(c), count(d = 999), count(e) FROM test_tab"); |
| 78 | +is($result, qq(3|3|3|3), 'check extra columns contain local defaults after apply'); |
| 79 | + |
70 | 80 | $node_subscriber->stop;
|
71 | 81 | $node_publisher->stop;
|
0 commit comments