|
|
|
|
@ -1,7 +1,8 @@ |
|
|
|
|
|
|
|
|
|
# Copyright (c) 2021-2026, PostgreSQL Global Development Group |
|
|
|
|
|
|
|
|
|
# Basic logical replication test |
|
|
|
|
# Test postgres_fdw foreign server for use with a subscription. |
|
|
|
|
|
|
|
|
|
use strict; |
|
|
|
|
use warnings FATAL => 'all'; |
|
|
|
|
use PostgreSQL::Test::Cluster; |
|
|
|
|
@ -22,11 +23,6 @@ $node_subscriber->start; |
|
|
|
|
$node_publisher->safe_psql('postgres', |
|
|
|
|
"CREATE TABLE tab_ins AS SELECT a, a + 1 as b FROM generate_series(1,1002) AS a"); |
|
|
|
|
|
|
|
|
|
# Replicate the changes without columns |
|
|
|
|
$node_publisher->safe_psql('postgres', "CREATE TABLE tab_no_col()"); |
|
|
|
|
$node_publisher->safe_psql('postgres', |
|
|
|
|
"INSERT INTO tab_no_col default VALUES"); |
|
|
|
|
|
|
|
|
|
# Setup structure on subscriber |
|
|
|
|
$node_subscriber->safe_psql('postgres', "CREATE EXTENSION postgres_fdw"); |
|
|
|
|
$node_subscriber->safe_psql('postgres', "CREATE TABLE tab_ins (a int, b int)"); |
|
|
|
|
@ -45,9 +41,6 @@ $node_subscriber->safe_psql('postgres', |
|
|
|
|
"CREATE USER MAPPING FOR PUBLIC SERVER tap_server" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$node_subscriber->safe_psql('postgres', |
|
|
|
|
"CREATE FOREIGN TABLE f_tab_ins (a int, b int) SERVER tap_server OPTIONS(table_name 'tab_ins')" |
|
|
|
|
); |
|
|
|
|
$node_subscriber->safe_psql('postgres', |
|
|
|
|
"CREATE SUBSCRIPTION tap_sub SERVER tap_server PUBLICATION tap_pub WITH (password_required=false)" |
|
|
|
|
); |
|
|
|
|
@ -56,7 +49,7 @@ $node_subscriber->safe_psql('postgres', |
|
|
|
|
$node_subscriber->wait_for_subscription_sync($node_publisher, 'tap_sub'); |
|
|
|
|
|
|
|
|
|
my $result = |
|
|
|
|
$node_subscriber->safe_psql('postgres', "SELECT count(*) FROM (SELECT f.b = l.b as match FROM tab_ins l, f_tab_ins f WHERE l.a = f.a) WHERE match"); |
|
|
|
|
$node_subscriber->safe_psql('postgres', "SELECT count(*) FROM tab_ins"); |
|
|
|
|
is($result, qq(1002), 'check that initial data was copied to subscriber'); |
|
|
|
|
|
|
|
|
|
$node_publisher->safe_psql('postgres', |
|
|
|
|
@ -65,7 +58,7 @@ $node_publisher->safe_psql('postgres', |
|
|
|
|
$node_publisher->wait_for_catchup('tap_sub'); |
|
|
|
|
|
|
|
|
|
$result = |
|
|
|
|
$node_subscriber->safe_psql('postgres', "SELECT count(*) FROM (SELECT f.b = l.b as match FROM tab_ins l, f_tab_ins f WHERE l.a = f.a) WHERE match"); |
|
|
|
|
$node_subscriber->safe_psql('postgres', "SELECT count(*) FROM tab_ins"); |
|
|
|
|
is($result, qq(1050), 'check that inserted data was copied to subscriber'); |
|
|
|
|
|
|
|
|
|
done_testing(); |
|
|
|
|
|