|
| 1 | +# Test materialized views behavior |
| 2 | +use strict; |
| 3 | +use warnings; |
| 4 | +use PostgresNode; |
| 5 | +use TestLib; |
| 6 | +use Test::More tests => 1; |
| 7 | + |
| 8 | +my $node_publisher = get_new_node('publisher'); |
| 9 | +$node_publisher->init(allows_streaming => 'logical'); |
| 10 | +$node_publisher->start; |
| 11 | + |
| 12 | +my $node_subscriber = get_new_node('subscriber'); |
| 13 | +$node_subscriber->init(allows_streaming => 'logical'); |
| 14 | +$node_subscriber->start; |
| 15 | + |
| 16 | +my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; |
| 17 | +my $appname = 'replication_test'; |
| 18 | + |
| 19 | +$node_publisher->safe_psql('postgres', |
| 20 | + "CREATE PUBLICATION mypub FOR ALL TABLES;"); |
| 21 | +$node_subscriber->safe_psql('postgres', |
| 22 | +"CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION mypub;" |
| 23 | +); |
| 24 | + |
| 25 | +$node_publisher->safe_psql('postgres', q{CREATE TABLE test1 (a int PRIMARY KEY, b text)}); |
| 26 | +$node_publisher->safe_psql('postgres', q{INSERT INTO test1 (a, b) VALUES (1, 'one'), (2, 'two');}); |
| 27 | + |
| 28 | +$node_subscriber->safe_psql('postgres', q{CREATE TABLE test1 (a int PRIMARY KEY, b text);}); |
| 29 | + |
| 30 | +$node_publisher->wait_for_catchup($appname); |
| 31 | + |
| 32 | +# Materialized views are not supported by logical replication, but |
| 33 | +# logical decoding does produce change information for them, so we |
| 34 | +# need to make sure they are properly ignored. (bug #15044) |
| 35 | + |
| 36 | +# create a MV with some data |
| 37 | +$node_publisher->safe_psql('postgres', q{CREATE MATERIALIZED VIEW testmv1 AS SELECT * FROM test1;}); |
| 38 | +$node_publisher->wait_for_catchup($appname); |
| 39 | +# There is no equivalent relation on the subscriber, but MV data is |
| 40 | +# not replicated, so this does not hang. |
| 41 | + |
| 42 | +pass "materialized view data not replicated"; |
| 43 | + |
| 44 | +$node_subscriber->stop; |
| 45 | +$node_publisher->stop; |
0 commit comments