|
3 | 3 | use warnings;
|
4 | 4 | use PostgresNode;
|
5 | 5 | use TestLib;
|
6 |
| -use Test::More tests => 4; |
| 6 | +use Test::More tests => 5; |
7 | 7 |
|
8 | 8 | # Create publisher node
|
9 | 9 | my $node_publisher = get_new_node('publisher');
|
|
29 | 29 | # Setup logical replication
|
30 | 30 | my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
|
31 | 31 | $node_publisher->safe_psql('postgres',
|
32 |
| - "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); |
| 32 | + "CREATE PUBLICATION tap_pub FOR ALL TABLES"); |
33 | 33 |
|
34 | 34 | $node_subscriber->safe_psql('postgres',
|
35 | 35 | "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub"
|
|
88 | 88 | is($result, qq(3|3|3|3),
|
89 | 89 | 'check extra columns contain local defaults after apply');
|
90 | 90 |
|
| 91 | + |
| 92 | +# Check a bug about adding a replica identity column on the subscriber |
| 93 | +# that was not yet mapped to a column on the publisher. This would |
| 94 | +# result in errors on the subscriber and replication thus not |
| 95 | +# progressing. |
| 96 | +# (https://www.postgresql.org/message-id/flat/a9139c29-7ddd-973b-aa7f-71fed9c38d75%40minerva.info) |
| 97 | + |
| 98 | +$node_publisher->safe_psql('postgres', |
| 99 | + "CREATE TABLE test_tab2 (a int)"); |
| 100 | + |
| 101 | +$node_subscriber->safe_psql('postgres', |
| 102 | + "CREATE TABLE test_tab2 (a int)"); |
| 103 | + |
| 104 | +$node_subscriber->safe_psql('postgres', |
| 105 | + "ALTER SUBSCRIPTION tap_sub REFRESH PUBLICATION"); |
| 106 | + |
| 107 | +# Add replica identity column. (The serial is not necessary, but it's |
| 108 | +# a convenient way to get a default on the new column so that rows |
| 109 | +# from the publisher that don't have the column yet can be inserted.) |
| 110 | +$node_subscriber->safe_psql('postgres', |
| 111 | + "ALTER TABLE test_tab2 ADD COLUMN b serial PRIMARY KEY"); |
| 112 | + |
| 113 | +$node_publisher->safe_psql('postgres', |
| 114 | + "INSERT INTO test_tab2 VALUES (1)"); |
| 115 | + |
| 116 | +$node_publisher->wait_for_catchup('tap_sub'); |
| 117 | + |
| 118 | +is($node_subscriber->safe_psql('postgres', |
| 119 | + "SELECT count(*), min(a), max(a) FROM test_tab2"), |
| 120 | + qq(1|1|1), |
| 121 | + 'check replicated inserts on subscriber'); |
| 122 | + |
| 123 | + |
91 | 124 | $node_subscriber->stop;
|
92 | 125 | $node_publisher->stop;
|
0 commit comments