summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2020-05-14 17:06:38 +0000
committerTom Lane2020-05-14 17:06:50 +0000
commit5cbfce562f7cd2aab0cdc4694ce298ec3567930e (patch)
tree64e722d72fc5f1803cb6f6371d6cf12863e2812f /src/test
parent1255466f8358ecac29581aa5ecec76628dc2e33c (diff)
Initial pgindent and pgperltidy run for v13.
Includes some manual cleanup of places that pgindent messed up, most of which weren't per project style anyway. Notably, it seems some people didn't absorb the style rules of commit c9d297751, because there were a bunch of new occurrences of function calls with a newline just after the left paren, all with faulty expectations about how the rest of the call would get indented.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/authentication/t/001_password.pl3
-rw-r--r--src/test/authentication/t/002_saslprep.pl3
-rw-r--r--src/test/modules/dummy_index_am/dummy_index_am.c11
-rw-r--r--src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c6
-rw-r--r--src/test/perl/PostgresNode.pm5
-rw-r--r--src/test/perl/TestLib.pm4
-rw-r--r--src/test/recovery/t/001_stream_rep.pl23
-rw-r--r--src/test/recovery/t/003_recovery_targets.pl22
-rw-r--r--src/test/recovery/t/006_logical_decoding.pl22
-rw-r--r--src/test/recovery/t/019_replslot_limit.pl89
-rw-r--r--src/test/ssl/t/001_ssltests.pl47
-rw-r--r--src/test/subscription/t/003_constraints.pl6
-rw-r--r--src/test/subscription/t/008_diff_schema.pl17
-rw-r--r--src/test/subscription/t/013_partition.pl280
14 files changed, 289 insertions, 249 deletions
diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl
index b8d6cc52e9d..82536eb60fb 100644
--- a/src/test/authentication/t/001_password.pl
+++ b/src/test/authentication/t/001_password.pl
@@ -12,7 +12,8 @@ use TestLib;
use Test::More;
if (!$use_unix_sockets)
{
- plan skip_all => "authentication tests cannot run without Unix-domain sockets";
+ plan skip_all =>
+ "authentication tests cannot run without Unix-domain sockets";
}
else
{
diff --git a/src/test/authentication/t/002_saslprep.pl b/src/test/authentication/t/002_saslprep.pl
index bf57933d94b..32d4e43fc7d 100644
--- a/src/test/authentication/t/002_saslprep.pl
+++ b/src/test/authentication/t/002_saslprep.pl
@@ -9,7 +9,8 @@ use TestLib;
use Test::More;
if (!$use_unix_sockets)
{
- plan skip_all => "authentication tests cannot run without Unix-domain sockets";
+ plan skip_all =>
+ "authentication tests cannot run without Unix-domain sockets";
}
else
{
diff --git a/src/test/modules/dummy_index_am/dummy_index_am.c b/src/test/modules/dummy_index_am/dummy_index_am.c
index f32632089b1..e97a32d5be2 100644
--- a/src/test/modules/dummy_index_am/dummy_index_am.c
+++ b/src/test/modules/dummy_index_am/dummy_index_am.c
@@ -31,10 +31,11 @@ relopt_parse_elt di_relopt_tab[6];
/* Kind of relation options for dummy index */
relopt_kind di_relopt_kind;
-typedef enum DummyAmEnum {
+typedef enum DummyAmEnum
+{
DUMMY_AM_ENUM_ONE,
DUMMY_AM_ENUM_TWO
-} DummyAmEnum;
+} DummyAmEnum;
/* Dummy index options */
typedef struct DummyIndexOptions
@@ -43,16 +44,16 @@ typedef struct DummyIndexOptions
int option_int;
double option_real;
bool option_bool;
- DummyAmEnum option_enum;
+ DummyAmEnum option_enum;
int option_string_val_offset;
int option_string_null_offset;
-} DummyIndexOptions;
+} DummyIndexOptions;
relopt_enum_elt_def dummyAmEnumValues[] =
{
{"one", DUMMY_AM_ENUM_ONE},
{"two", DUMMY_AM_ENUM_TWO},
- {(const char *)NULL} /* list terminator */
+ {(const char *) NULL} /* list terminator */
};
/* Handler for index AM */
diff --git a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c
index c95cb509458..563ff144cc1 100644
--- a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c
+++ b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c
@@ -26,9 +26,11 @@ void _PG_fini(void);
static char *ssl_passphrase = NULL;
/* callback function */
-static int rot13_passphrase(char *buf, int size, int rwflag, void *userdata);
+static int rot13_passphrase(char *buf, int size, int rwflag, void *userdata);
+
/* hook function to set the callback */
static void set_rot13(SSL_CTX *context, bool isServerStart);
+
/*
* Module load callback
*/
@@ -60,7 +62,7 @@ static void
set_rot13(SSL_CTX *context, bool isServerStart)
{
/* warn if the user has set ssl_passphrase_command */
- if(ssl_passphrase_command[0])
+ if (ssl_passphrase_command[0])
ereport(WARNING,
(errmsg("ssl_passphrase_command setting ignored by ssl_passphrase_func module")));
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 1d5450758e4..3f3a1d81f68 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -672,7 +672,7 @@ sub init_from_backup
$params{has_streaming} = 0 unless defined $params{has_streaming};
$params{has_restoring} = 0 unless defined $params{has_restoring};
- $params{standby} = 1 unless defined $params{standby};
+ $params{standby} = 1 unless defined $params{standby};
print
"# Initializing node \"$node_name\" from backup \"$backup_name\" of node \"$root_name\"\n";
@@ -703,7 +703,8 @@ port = $port
"unix_socket_directories = '$host'");
}
$self->enable_streaming($root_node) if $params{has_streaming};
- $self->enable_restoring($root_node, $params{standby}) if $params{has_restoring};
+ $self->enable_restoring($root_node, $params{standby})
+ if $params{has_restoring};
return;
}
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 0e6c4819e4c..d579d5c177b 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -1,3 +1,4 @@
+
=pod
=head1 NAME
@@ -122,7 +123,8 @@ BEGIN
# Specifies whether to use Unix sockets for test setups. On
# Windows we don't use them by default since it's not universally
# supported, but it can be overridden if desired.
- $use_unix_sockets = (!$windows_os || defined $ENV{PG_TEST_USE_UNIX_SOCKETS});
+ $use_unix_sockets =
+ (!$windows_os || defined $ENV{PG_TEST_USE_UNIX_SOCKETS});
}
=pod
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl
index 52585a10149..0c316c18082 100644
--- a/src/test/recovery/t/001_stream_rep.pl
+++ b/src/test/recovery/t/001_stream_rep.pl
@@ -348,8 +348,7 @@ is($catalog_xmin, '',
'catalog xmin of cascaded slot still null with hs_feedback reset');
note "check change primary_conninfo without restart";
-$node_standby_2->append_conf('postgresql.conf',
- "primary_slot_name = ''");
+$node_standby_2->append_conf('postgresql.conf', "primary_slot_name = ''");
$node_standby_2->enable_streaming($node_master);
$node_standby_2->reload;
@@ -357,7 +356,7 @@ $node_standby_2->reload;
$node_standby_1->stop;
my $newval = $node_master->safe_psql('postgres',
-'INSERT INTO replayed(val) SELECT coalesce(max(val),0) + 1 AS newval FROM replayed RETURNING val'
+ 'INSERT INTO replayed(val) SELECT coalesce(max(val),0) + 1 AS newval FROM replayed RETURNING val'
);
$node_master->wait_for_catchup($node_standby_2, 'replay',
$node_master->lsn('insert'));
@@ -370,22 +369,26 @@ is($is_replayed, qq(1), "standby_2 didn't replay master value $newval");
my $phys_slot = 'phys_slot';
$node_master->safe_psql('postgres',
"SELECT pg_create_physical_replication_slot('$phys_slot', true);");
-$node_master->psql('postgres', "
+$node_master->psql(
+ 'postgres', "
CREATE TABLE tab_phys_slot (a int);
INSERT INTO tab_phys_slot VALUES (generate_series(1,10));");
-my $current_lsn = $node_master->safe_psql('postgres',
- "SELECT pg_current_wal_lsn();");
+my $current_lsn =
+ $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
chomp($current_lsn);
my $psql_rc = $node_master->psql('postgres',
- "SELECT pg_replication_slot_advance('$phys_slot', '$current_lsn'::pg_lsn);");
+ "SELECT pg_replication_slot_advance('$phys_slot', '$current_lsn'::pg_lsn);"
+);
is($psql_rc, '0', 'slot advancing with physical slot');
my $phys_restart_lsn_pre = $node_master->safe_psql('postgres',
- "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$phys_slot';");
+ "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$phys_slot';"
+);
chomp($phys_restart_lsn_pre);
# Slot advance should persist across clean restarts.
$node_master->restart;
my $phys_restart_lsn_post = $node_master->safe_psql('postgres',
- "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$phys_slot';");
+ "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$phys_slot';"
+);
chomp($phys_restart_lsn_post);
-ok(($phys_restart_lsn_pre cmp $phys_restart_lsn_post) == 0,
+ok( ($phys_restart_lsn_pre cmp $phys_restart_lsn_post) == 0,
"physical slot advance persists across restarts");
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 86333e7758d..8d114eb7ad5 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -150,20 +150,26 @@ ok($logfile =~ qr/multiple recovery targets specified/,
# Check behavior when recovery ends before target is reached
$node_standby = get_new_node('standby_8');
-$node_standby->init_from_backup($node_master, 'my_backup',
- has_restoring => 1, standby => 0);
+$node_standby->init_from_backup(
+ $node_master, 'my_backup',
+ has_restoring => 1,
+ standby => 0);
$node_standby->append_conf('postgresql.conf',
- "recovery_target_name = 'does_not_exist'");
+ "recovery_target_name = 'does_not_exist'");
-run_log(['pg_ctl', '-D', $node_standby->data_dir,
- '-l', $node_standby->logfile, 'start']);
+run_log(
+ [
+ 'pg_ctl', '-D', $node_standby->data_dir, '-l',
+ $node_standby->logfile, 'start'
+ ]);
# wait up to 180s for postgres to terminate
-foreach my $i (0..1800)
+foreach my $i (0 .. 1800)
{
- last if ! -f $node_standby->data_dir . '/postmaster.pid';
+ last if !-f $node_standby->data_dir . '/postmaster.pid';
usleep(100_000);
}
$logfile = slurp_file($node_standby->logfile());
-ok($logfile =~ qr/FATAL: recovery ended before configured recovery target was reached/,
+ok( $logfile =~
+ qr/FATAL: recovery ended before configured recovery target was reached/,
'recovery end before target reached is a fatal error');
diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl
index 1334bf6a601..d40a500ed47 100644
--- a/src/test/recovery/t/006_logical_decoding.pl
+++ b/src/test/recovery/t/006_logical_decoding.pl
@@ -93,8 +93,7 @@ $stdout_recv = $node_master->pg_recvlogical_upto(
'include-xids' => '0',
'skip-empty-xacts' => '1');
chomp($stdout_recv);
-is($stdout_recv, '',
- 'pg_recvlogical acknowledged changes');
+is($stdout_recv, '', 'pg_recvlogical acknowledged changes');
$node_master->safe_psql('postgres', 'CREATE DATABASE otherdb');
@@ -143,23 +142,28 @@ is($node_master->slot('otherdb_slot')->{'slot_name'},
# Test logical slot advancing and its durability.
my $logical_slot = 'logical_slot';
$node_master->safe_psql('postgres',
- "SELECT pg_create_logical_replication_slot('$logical_slot', 'test_decoding', false);");
-$node_master->psql('postgres', "
+ "SELECT pg_create_logical_replication_slot('$logical_slot', 'test_decoding', false);"
+);
+$node_master->psql(
+ 'postgres', "
CREATE TABLE tab_logical_slot (a int);
INSERT INTO tab_logical_slot VALUES (generate_series(1,10));");
-my $current_lsn = $node_master->safe_psql('postgres',
- "SELECT pg_current_wal_lsn();");
+my $current_lsn =
+ $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();");
chomp($current_lsn);
my $psql_rc = $node_master->psql('postgres',
- "SELECT pg_replication_slot_advance('$logical_slot', '$current_lsn'::pg_lsn);");
+ "SELECT pg_replication_slot_advance('$logical_slot', '$current_lsn'::pg_lsn);"
+);
is($psql_rc, '0', 'slot advancing with logical slot');
my $logical_restart_lsn_pre = $node_master->safe_psql('postgres',
- "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$logical_slot';");
+ "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$logical_slot';"
+);
chomp($logical_restart_lsn_pre);
# Slot advance should persist across clean restarts.
$node_master->restart;
my $logical_restart_lsn_post = $node_master->safe_psql('postgres',
- "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$logical_slot';");
+ "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$logical_slot';"
+);
chomp($logical_restart_lsn_post);
ok(($logical_restart_lsn_pre cmp $logical_restart_lsn_post) == 0,
"logical slot advance persists across restarts");
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 634f2bec8bb..cba7df920c0 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -16,16 +16,20 @@ $ENV{PGDATABASE} = 'postgres';
# Initialize master node, setting wal-segsize to 1MB
my $node_master = get_new_node('master');
$node_master->init(allows_streaming => 1, extra => ['--wal-segsize=1']);
-$node_master->append_conf('postgresql.conf', qq(
+$node_master->append_conf(
+ 'postgresql.conf', qq(
min_wal_size = 2MB
max_wal_size = 4MB
log_checkpoints = yes
));
$node_master->start;
-$node_master->safe_psql('postgres', "SELECT pg_create_physical_replication_slot('rep1')");
+$node_master->safe_psql('postgres',
+ "SELECT pg_create_physical_replication_slot('rep1')");
# The slot state and remain should be null before the first connection
-my $result = $node_master->safe_psql('postgres', "SELECT restart_lsn IS NULL, wal_status is NULL, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'");
+my $result = $node_master->safe_psql('postgres',
+ "SELECT restart_lsn IS NULL, wal_status is NULL, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
is($result, "t|t|t", 'check the state of non-reserved slot is "unknown"');
@@ -35,7 +39,8 @@ $node_master->backup($backup_name);
# Create a standby linking to it using the replication slot
my $node_standby = get_new_node('standby_1');
-$node_standby->init_from_backup($node_master, $backup_name, has_streaming => 1);
+$node_standby->init_from_backup($node_master, $backup_name,
+ has_streaming => 1);
$node_standby->append_conf('postgresql.conf', "primary_slot_name = 'rep1'");
$node_standby->start;
@@ -48,7 +53,9 @@ $node_master->wait_for_catchup($node_standby, 'replay', $start_lsn);
$node_standby->stop;
# Preparation done, the slot is the state "normal" now
-$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
is($result, "normal|t", 'check the catching-up state');
# Advance WAL by five segments (= 5MB) on master
@@ -56,14 +63,18 @@ advance_wal($node_master, 1);
$node_master->safe_psql('postgres', "CHECKPOINT;");
# The slot is always "safe" when fitting max_wal_size
-$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
is($result, "normal|t", 'check that it is safe if WAL fits in max_wal_size');
advance_wal($node_master, 4);
$node_master->safe_psql('postgres', "CHECKPOINT;");
# The slot is always "safe" when max_slot_wal_keep_size is not set
-$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
is($result, "normal|t", 'check that slot is working');
# The standby can reconnect to master
@@ -76,7 +87,8 @@ $node_standby->stop;
# Set max_slot_wal_keep_size on master
my $max_slot_wal_keep_size_mb = 6;
-$node_master->append_conf('postgresql.conf', qq(
+$node_master->append_conf(
+ 'postgresql.conf', qq(
max_slot_wal_keep_size = ${max_slot_wal_keep_size_mb}MB
));
$node_master->reload;
@@ -85,7 +97,8 @@ $node_master->reload;
# be as almost (max_slot_wal_keep_size - 1) times large as the segment
# size
-$result = $node_master->safe_psql('postgres', "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
is($result, "normal", 'check that max_slot_wal_keep_size is working');
# Advance WAL again then checkpoint, reducing remain by 2 MB.
@@ -93,8 +106,10 @@ advance_wal($node_master, 2);
$node_master->safe_psql('postgres', "CHECKPOINT;");
# The slot is still working
-$result = $node_master->safe_psql('postgres', "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
-is($result, "normal", 'check that min_safe_lsn gets close to the current LSN');
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
+is($result, "normal",
+ 'check that min_safe_lsn gets close to the current LSN');
# The standby can reconnect to master
$node_standby->start;
@@ -103,13 +118,18 @@ $node_master->wait_for_catchup($node_standby, 'replay', $start_lsn);
$node_standby->stop;
# wal_keep_segments overrides max_slot_wal_keep_size
-$result = $node_master->safe_psql('postgres', "ALTER SYSTEM SET wal_keep_segments to 8; SELECT pg_reload_conf();");
+$result = $node_master->safe_psql('postgres',
+ "ALTER SYSTEM SET wal_keep_segments to 8; SELECT pg_reload_conf();");
# Advance WAL again then checkpoint, reducing remain by 6 MB.
advance_wal($node_master, 6);
-$result = $node_master->safe_psql('postgres', "SELECT wal_status as remain FROM pg_replication_slots WHERE slot_name = 'rep1'");
-is($result, "normal", 'check that wal_keep_segments overrides max_slot_wal_keep_size');
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status as remain FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
+is($result, "normal",
+ 'check that wal_keep_segments overrides max_slot_wal_keep_size');
# restore wal_keep_segments
-$result = $node_master->safe_psql('postgres', "ALTER SYSTEM SET wal_keep_segments to 0; SELECT pg_reload_conf();");
+$result = $node_master->safe_psql('postgres',
+ "ALTER SYSTEM SET wal_keep_segments to 0; SELECT pg_reload_conf();");
# The standby can reconnect to master
$node_standby->start;
@@ -121,7 +141,8 @@ $node_standby->stop;
advance_wal($node_master, 6);
# Slot gets into 'reserved' state
-$result = $node_master->safe_psql('postgres', "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep1'");
is($result, "reserved", 'check that the slot state changes to "reserved"');
# do checkpoint so that the next checkpoint runs too early
@@ -131,7 +152,9 @@ $node_master->safe_psql('postgres', "CHECKPOINT;");
advance_wal($node_master, 1);
# Slot gets into 'lost' state
-$result = $node_master->safe_psql('postgres', "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT wal_status, min_safe_lsn is NULL FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
is($result, "lost|t", 'check that the slot state changes to "lost"');
# The standby still can connect to master before a checkpoint
@@ -142,9 +165,10 @@ $node_master->wait_for_catchup($node_standby, 'replay', $start_lsn);
$node_standby->stop;
-ok(!find_in_log($node_standby,
- "requested WAL segment [0-9A-F]+ has already been removed"),
- 'check that required WAL segments are still available');
+ok( !find_in_log(
+ $node_standby,
+ "requested WAL segment [0-9A-F]+ has already been removed"),
+ 'check that required WAL segments are still available');
# Advance WAL again, the slot loses the oldest segment.
my $logstart = get_log_size($node_master);
@@ -152,13 +176,16 @@ advance_wal($node_master, 7);
$node_master->safe_psql('postgres', "CHECKPOINT;");
# WARNING should be issued
-ok(find_in_log($node_master,
- "invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
- $logstart),
- 'check that the warning is logged');
+ok( find_in_log(
+ $node_master,
+ "invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
+ $logstart),
+ 'check that the warning is logged');
# This slot should be broken
-$result = $node_master->safe_psql('postgres', "SELECT slot_name, active, restart_lsn IS NULL, wal_status, min_safe_lsn FROM pg_replication_slots WHERE slot_name = 'rep1'");
+$result = $node_master->safe_psql('postgres',
+ "SELECT slot_name, active, restart_lsn IS NULL, wal_status, min_safe_lsn FROM pg_replication_slots WHERE slot_name = 'rep1'"
+);
is($result, "rep1|f|t||", 'check that the slot became inactive');
# The standby no longer can connect to the master
@@ -168,9 +195,10 @@ $node_standby->start;
my $failed = 0;
for (my $i = 0; $i < 10000; $i++)
{
- if (find_in_log($node_standby,
- "requested WAL segment [0-9A-F]+ has already been removed",
- $logstart))
+ if (find_in_log(
+ $node_standby,
+ "requested WAL segment [0-9A-F]+ has already been removed",
+ $logstart))
{
$failed = 1;
last;
@@ -228,9 +256,10 @@ sub advance_wal
my ($node, $n) = @_;
# Advance by $n segments (= (16 * $n) MB) on master
- for (my $i = 0 ; $i < $n ; $i++)
+ for (my $i = 0; $i < $n; $i++)
{
- $node->safe_psql('postgres', "CREATE TABLE t (); DROP TABLE t; SELECT pg_switch_wal();");
+ $node->safe_psql('postgres',
+ "CREATE TABLE t (); DROP TABLE t; SELECT pg_switch_wal();");
}
return;
}
diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl
index 3e68a49ca93..a454bb0274a 100644
--- a/src/test/ssl/t/001_ssltests.pl
+++ b/src/test/ssl/t/001_ssltests.pl
@@ -37,13 +37,17 @@ my $common_connstr;
#
# This changes ssl/client.key to ssl/client_tmp.key etc for the rest
# of the tests.
-my @keys = ("client", "client-revoked", "client-der", "client-encrypted-pem", "client-encrypted-der");
+my @keys = (
+ "client", "client-revoked",
+ "client-der", "client-encrypted-pem",
+ "client-encrypted-der");
foreach my $key (@keys)
{
- copy("ssl/${key}.key", "ssl/${key}_tmp.key")
- or die "couldn't copy ssl/${key}.key to ssl/${key}_tmp.key for permissions change: $!";
- chmod 0600, "ssl/${key}_tmp.key"
- or die "failed to change permissions on ssl/${key}_tmp.key: $!";
+ copy("ssl/${key}.key", "ssl/${key}_tmp.key")
+ or die
+ "couldn't copy ssl/${key}.key to ssl/${key}_tmp.key for permissions change: $!";
+ chmod 0600, "ssl/${key}_tmp.key"
+ or die "failed to change permissions on ssl/${key}_tmp.key: $!";
}
# Also make a copy of that explicitly world-readable. We can't
@@ -99,15 +103,17 @@ $node->_update_pid(1);
# Test compatibility of SSL protocols.
# TLSv1.1 is lower than TLSv1.2, so it won't work.
-$node->append_conf('postgresql.conf',
- qq{ssl_min_protocol_version='TLSv1.2'
+$node->append_conf(
+ 'postgresql.conf',
+ qq{ssl_min_protocol_version='TLSv1.2'
ssl_max_protocol_version='TLSv1.1'});
command_fails(
[ 'pg_ctl', '-D', $node->data_dir, '-l', $node->logfile, 'restart' ],
'restart fails with incorrect SSL protocol bounds');
# Go back to the defaults, this works.
-$node->append_conf('postgresql.conf',
- qq{ssl_min_protocol_version='TLSv1.2'
+$node->append_conf(
+ 'postgresql.conf',
+ qq{ssl_min_protocol_version='TLSv1.2'
ssl_max_protocol_version=''});
command_ok(
[ 'pg_ctl', '-D', $node->data_dir, '-l', $node->logfile, 'restart' ],
@@ -395,32 +401,37 @@ test_connect_fails(
test_connect_ok(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
- "certificate authorization succeeds with correct client cert in PEM format");
+ "certificate authorization succeeds with correct client cert in PEM format"
+);
# correct client cert in unencrypted DER
test_connect_ok(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-der_tmp.key",
- "certificate authorization succeeds with correct client cert in DER format");
+ "certificate authorization succeeds with correct client cert in DER format"
+);
# correct client cert in encrypted PEM
test_connect_ok(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key sslpassword='dUmmyP^#+'",
- "certificate authorization succeeds with correct client cert in encrypted PEM format");
+ "certificate authorization succeeds with correct client cert in encrypted PEM format"
+);
# correct client cert in encrypted DER
test_connect_ok(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-der_tmp.key sslpassword='dUmmyP^#+'",
- "certificate authorization succeeds with correct client cert in encrypted DER format");
+ "certificate authorization succeeds with correct client cert in encrypted DER format"
+);
# correct client cert in encrypted PEM with wrong password
test_connect_fails(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key sslpassword='wrong'",
qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": bad decrypt\E!,
- "certificate authorization fails with correct client cert and wrong password in encrypted PEM format");
+ "certificate authorization fails with correct client cert and wrong password in encrypted PEM format"
+);
TODO:
{
@@ -434,14 +445,16 @@ TODO:
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key sslpassword=''",
qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!,
- "certificate authorization fails with correct client cert and empty password in encrypted PEM format");
+ "certificate authorization fails with correct client cert and empty password in encrypted PEM format"
+ );
# correct client cert in encrypted PEM with no password
test_connect_fails(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key",
qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!,
- "certificate authorization fails with correct client cert and no password in encrypted PEM format");
+ "certificate authorization fails with correct client cert and no password in encrypted PEM format"
+ );
}
@@ -533,5 +546,5 @@ test_connect_fails($common_connstr, "sslmode=require sslcert=ssl/client.crt",
# clean up
foreach my $key (@keys)
{
- unlink("ssl/${key}_tmp.key");
+ unlink("ssl/${key}_tmp.key");
}
diff --git a/src/test/subscription/t/003_constraints.pl b/src/test/subscription/t/003_constraints.pl
index 34ab11e7fed..3a590f871a5 100644
--- a/src/test/subscription/t/003_constraints.pl
+++ b/src/test/subscription/t/003_constraints.pl
@@ -115,7 +115,8 @@ $node_publisher->wait_for_catchup('tap_sub');
# The trigger should cause the update to be skipped on subscriber
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(bid), max(bid) FROM tab_fk_ref;");
-is($result, qq(2|1|2), 'check replica update column trigger applied on subscriber');
+is($result, qq(2|1|2),
+ 'check replica update column trigger applied on subscriber');
# Update on a column not specified in the trigger, but it will trigger
# anyway because logical replication ships all columns in an update.
@@ -126,7 +127,8 @@ $node_publisher->wait_for_catchup('tap_sub');
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(id), max(id) FROM tab_fk_ref;");
-is($result, qq(2|1|2), 'check column trigger applied on even for other column');
+is($result, qq(2|1|2),
+ 'check column trigger applied on even for other column');
$node_subscriber->stop('fast');
$node_publisher->stop('fast');
diff --git a/src/test/subscription/t/008_diff_schema.pl b/src/test/subscription/t/008_diff_schema.pl
index 81520a73329..963334ed89d 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -95,11 +95,9 @@ is($result, qq(3|3|3|3),
# progressing.
# (https://www.postgresql.org/message-id/flat/a9139c29-7ddd-973b-aa7f-71fed9c38d75%40minerva.info)
-$node_publisher->safe_psql('postgres',
- "CREATE TABLE test_tab2 (a int)");
+$node_publisher->safe_psql('postgres', "CREATE TABLE test_tab2 (a int)");
-$node_subscriber->safe_psql('postgres',
- "CREATE TABLE test_tab2 (a int)");
+$node_subscriber->safe_psql('postgres', "CREATE TABLE test_tab2 (a int)");
$node_subscriber->safe_psql('postgres',
"ALTER SUBSCRIPTION tap_sub REFRESH PUBLICATION");
@@ -113,15 +111,14 @@ $node_subscriber->poll_query_until('postgres', $synced_query)
$node_subscriber->safe_psql('postgres',
"ALTER TABLE test_tab2 ADD COLUMN b serial PRIMARY KEY");
-$node_publisher->safe_psql('postgres',
- "INSERT INTO test_tab2 VALUES (1)");
+$node_publisher->safe_psql('postgres', "INSERT INTO test_tab2 VALUES (1)");
$node_publisher->wait_for_catchup('tap_sub');
-is($node_subscriber->safe_psql('postgres',
- "SELECT count(*), min(a), max(a) FROM test_tab2"),
- qq(1|1|1),
- 'check replicated inserts on subscriber');
+is( $node_subscriber->safe_psql(
+ 'postgres', "SELECT count(*), min(a), max(a) FROM test_tab2"),
+ qq(1|1|1),
+ 'check replicated inserts on subscriber');
$node_subscriber->stop;
diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl
index 208bb556ce4..a04c03a7e24 100644
--- a/src/test/subscription/t/013_partition.pl
+++ b/src/test/subscription/t/013_partition.pl
@@ -22,8 +22,7 @@ $node_subscriber2->start;
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
# publisher
-$node_publisher->safe_psql('postgres',
- "CREATE PUBLICATION pub1");
+$node_publisher->safe_psql('postgres', "CREATE PUBLICATION pub1");
$node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub_all FOR ALL TABLES");
$node_publisher->safe_psql('postgres',
@@ -45,13 +44,16 @@ $node_publisher->safe_psql('postgres',
# subpartitioned. This tests the tuple routing code on the
# subscriber.
$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab1 (c text, a int PRIMARY KEY, b text) PARTITION BY LIST (a)");
+ "CREATE TABLE tab1 (c text, a int PRIMARY KEY, b text) PARTITION BY LIST (a)"
+);
$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab1_1 (b text, c text DEFAULT 'sub1_tab1', a int NOT NULL)");
+ "CREATE TABLE tab1_1 (b text, c text DEFAULT 'sub1_tab1', a int NOT NULL)"
+);
$node_subscriber1->safe_psql('postgres',
"ALTER TABLE tab1 ATTACH PARTITION tab1_1 FOR VALUES IN (1, 2, 3)");
$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab1_2 PARTITION OF tab1 (c DEFAULT 'sub1_tab1') FOR VALUES IN (4, 5, 6) PARTITION BY LIST (a)");
+ "CREATE TABLE tab1_2 PARTITION OF tab1 (c DEFAULT 'sub1_tab1') FOR VALUES IN (4, 5, 6) PARTITION BY LIST (a)"
+);
$node_subscriber1->safe_psql('postgres',
"CREATE TABLE tab1_2_1 (c text, b text, a int NOT NULL)");
$node_subscriber1->safe_psql('postgres',
@@ -59,24 +61,31 @@ $node_subscriber1->safe_psql('postgres',
$node_subscriber1->safe_psql('postgres',
"CREATE TABLE tab1_2_2 PARTITION OF tab1_2 FOR VALUES IN (4, 6)");
$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab1_def PARTITION OF tab1 (c DEFAULT 'sub1_tab1') DEFAULT");
+ "CREATE TABLE tab1_def PARTITION OF tab1 (c DEFAULT 'sub1_tab1') DEFAULT"
+);
$node_subscriber1->safe_psql('postgres',
- "CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1");
+ "CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1"
+);
# subscriber 2
#
# This does not use partitioning. The tables match the leaf tables on
# the publisher.
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1', b text)");
+ "CREATE TABLE tab1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1', b text)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab1_1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1_1', b text)");
+ "CREATE TABLE tab1_1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1_1', b text)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab1_2 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1_2', b text)");
+ "CREATE TABLE tab1_2 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1_2', b text)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab1_def (a int PRIMARY KEY, b text, c text DEFAULT 'sub2_tab1_def')");
+ "CREATE TABLE tab1_def (a int PRIMARY KEY, b text, c text DEFAULT 'sub2_tab1_def')"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE SUBSCRIPTION sub2 CONNECTION '$publisher_connstr' PUBLICATION pub_all");
+ "CREATE SUBSCRIPTION sub2 CONNECTION '$publisher_connstr' PUBLICATION pub_all"
+);
# Wait for initial sync of all subscriptions
my $synced_query =
@@ -89,21 +98,17 @@ $node_subscriber2->poll_query_until('postgres', $synced_query)
# Tests for replication using leaf partition identity and schema
# insert
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1 VALUES (1)");
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1_1 (a) VALUES (3)");
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1_2 VALUES (5)");
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1 VALUES (0)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1 VALUES (1)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1_1 (a) VALUES (3)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1_2 VALUES (5)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1 VALUES (0)");
$node_publisher->wait_for_catchup('sub1');
$node_publisher->wait_for_catchup('sub2');
my $result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab1 ORDER BY 1, 2");
-is($result, qq(sub1_tab1|0
+is( $result, qq(sub1_tab1|0
sub1_tab1|1
sub1_tab1|3
sub1_tab1|5), 'inserts into tab1 and its partitions replicated');
@@ -118,7 +123,7 @@ is($result, qq(), 'inserts into tab1_2 replicated into tab1_2_2 correctly');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1_1 ORDER BY 1, 2");
-is($result, qq(sub2_tab1_1|1
+is( $result, qq(sub2_tab1_1|1
sub2_tab1_1|3), 'inserts into tab1_1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
@@ -130,24 +135,20 @@ $result = $node_subscriber2->safe_psql('postgres',
is($result, qq(sub2_tab1_def|0), 'inserts into tab1_def replicated');
# update (replicated as update)
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 2 WHERE a = 1");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 2 WHERE a = 1");
# All of the following cause an update to be applied to a partitioned
# table on subscriber1: tab1_2 is leaf partition on publisher, whereas
# it's sub-partitioned on subscriber1.
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 6 WHERE a = 5");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 4 WHERE a = 6");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 6 WHERE a = 4");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 6 WHERE a = 5");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 4 WHERE a = 6");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 6 WHERE a = 4");
$node_publisher->wait_for_catchup('sub1');
$node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab1 ORDER BY 1, 2");
-is($result, qq(sub1_tab1|0
+is( $result, qq(sub1_tab1|0
sub1_tab1|2
sub1_tab1|3
sub1_tab1|6), 'update of tab1_1, tab1_2 replicated');
@@ -162,7 +163,7 @@ is($result, qq(6), 'updates of tab1_2 replicated into tab1_2_2 correctly');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1_1 ORDER BY 1, 2");
-is($result, qq(sub2_tab1_1|2
+is( $result, qq(sub2_tab1_1|2
sub2_tab1_1|3), 'update of tab1_1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
@@ -174,34 +175,33 @@ $result = $node_subscriber2->safe_psql('postgres',
is($result, qq(sub2_tab1_def|0), 'tab1_def unchanged');
# update (replicated as delete+insert)
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 1 WHERE a = 0");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 4 WHERE a = 1");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 1 WHERE a = 0");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 4 WHERE a = 1");
$node_publisher->wait_for_catchup('sub1');
$node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab1 ORDER BY 1, 2");
-is($result, qq(sub1_tab1|2
+is( $result, qq(sub1_tab1|2
sub1_tab1|3
sub1_tab1|4
-sub1_tab1|6), 'update of tab1 (delete from tab1_def + insert into tab1_1) replicated');
+sub1_tab1|6),
+ 'update of tab1 (delete from tab1_def + insert into tab1_1) replicated');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT a FROM tab1_2_2 ORDER BY 1");
-is($result, qq(4
+is( $result, qq(4
6), 'updates of tab1 (delete + insert) replicated into tab1_2_2 correctly');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1_1 ORDER BY 1, 2");
-is($result, qq(sub2_tab1_1|2
+is( $result, qq(sub2_tab1_1|2
sub2_tab1_1|3), 'tab1_1 unchanged');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1_2 ORDER BY 1, 2");
-is($result, qq(sub2_tab1_2|4
+is( $result, qq(sub2_tab1_2|4
sub2_tab1_2|6), 'insert into tab1_2 replicated');
$result = $node_subscriber2->safe_psql('postgres',
@@ -211,62 +211,54 @@ is($result, qq(), 'delete from tab1_def replicated');
# delete
$node_publisher->safe_psql('postgres',
"DELETE FROM tab1 WHERE a IN (2, 3, 5)");
-$node_publisher->safe_psql('postgres',
- "DELETE FROM tab1_2");
+$node_publisher->safe_psql('postgres', "DELETE FROM tab1_2");
$node_publisher->wait_for_catchup('sub1');
$node_publisher->wait_for_catchup('sub2');
-$result = $node_subscriber1->safe_psql('postgres',
- "SELECT a FROM tab1");
+$result = $node_subscriber1->safe_psql('postgres', "SELECT a FROM tab1");
is($result, qq(), 'delete from tab1_1, tab1_2 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1_1");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1_1");
is($result, qq(), 'delete from tab1_1 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1_2");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1_2");
is($result, qq(), 'delete from tab1_2 replicated');
# truncate
$node_subscriber1->safe_psql('postgres',
"INSERT INTO tab1 (a) VALUES (1), (2), (5)");
-$node_subscriber2->safe_psql('postgres',
- "INSERT INTO tab1_2 (a) VALUES (2)");
-$node_publisher->safe_psql('postgres',
- "TRUNCATE tab1_2");
+$node_subscriber2->safe_psql('postgres', "INSERT INTO tab1_2 (a) VALUES (2)");
+$node_publisher->safe_psql('postgres', "TRUNCATE tab1_2");
$node_publisher->wait_for_catchup('sub1');
$node_publisher->wait_for_catchup('sub2');
-$result = $node_subscriber1->safe_psql('postgres',
- "SELECT a FROM tab1 ORDER BY 1");
-is($result, qq(1
+$result =
+ $node_subscriber1->safe_psql('postgres', "SELECT a FROM tab1 ORDER BY 1");
+is( $result, qq(1
2), 'truncate of tab1_2 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1_2 ORDER BY 1");
+$result =
+ $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1_2 ORDER BY 1");
is($result, qq(), 'truncate of tab1_2 replicated');
-$node_publisher->safe_psql('postgres',
- "TRUNCATE tab1");
+$node_publisher->safe_psql('postgres', "TRUNCATE tab1");
$node_publisher->wait_for_catchup('sub1');
$node_publisher->wait_for_catchup('sub2');
-$result = $node_subscriber1->safe_psql('postgres',
- "SELECT a FROM tab1 ORDER BY 1");
+$result =
+ $node_subscriber1->safe_psql('postgres', "SELECT a FROM tab1 ORDER BY 1");
is($result, qq(), 'truncate of tab1_1 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1 ORDER BY 1");
+$result =
+ $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1 ORDER BY 1");
is($result, qq(), 'truncate of tab1 replicated');
# Tests for replication using root table identity and schema
# publisher
-$node_publisher->safe_psql('postgres',
- "DROP PUBLICATION pub1");
+$node_publisher->safe_psql('postgres', "DROP PUBLICATION pub1");
$node_publisher->safe_psql('postgres',
"CREATE TABLE tab2 (a int PRIMARY KEY, b text) PARTITION BY LIST (a)");
$node_publisher->safe_psql('postgres',
@@ -285,40 +277,49 @@ $node_publisher->safe_psql('postgres',
# Note: tab3_1's parent is not in the publication, in which case its
# changes are published using own identity.
$node_publisher->safe_psql('postgres',
- "CREATE PUBLICATION pub_viaroot FOR TABLE tab2, tab3_1 WITH (publish_via_partition_root = true)");
+ "CREATE PUBLICATION pub_viaroot FOR TABLE tab2, tab3_1 WITH (publish_via_partition_root = true)"
+);
# subscriber 1
+$node_subscriber1->safe_psql('postgres', "DROP SUBSCRIPTION sub1");
$node_subscriber1->safe_psql('postgres',
- "DROP SUBSCRIPTION sub1");
+ "CREATE TABLE tab2 (a int PRIMARY KEY, c text DEFAULT 'sub1_tab2', b text) PARTITION BY RANGE (a)"
+);
$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab2 (a int PRIMARY KEY, c text DEFAULT 'sub1_tab2', b text) PARTITION BY RANGE (a)");
-$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab2_1 (c text DEFAULT 'sub1_tab2', b text, a int NOT NULL)");
+ "CREATE TABLE tab2_1 (c text DEFAULT 'sub1_tab2', b text, a int NOT NULL)"
+);
$node_subscriber1->safe_psql('postgres',
"ALTER TABLE tab2 ATTACH PARTITION tab2_1 FOR VALUES FROM (0) TO (10)");
$node_subscriber1->safe_psql('postgres',
- "CREATE TABLE tab3_1 (c text DEFAULT 'sub1_tab3_1', b text, a int NOT NULL PRIMARY KEY)");
+ "CREATE TABLE tab3_1 (c text DEFAULT 'sub1_tab3_1', b text, a int NOT NULL PRIMARY KEY)"
+);
$node_subscriber1->safe_psql('postgres',
- "CREATE SUBSCRIPTION sub_viaroot CONNECTION '$publisher_connstr' PUBLICATION pub_viaroot");
+ "CREATE SUBSCRIPTION sub_viaroot CONNECTION '$publisher_connstr' PUBLICATION pub_viaroot"
+);
# subscriber 2
+$node_subscriber2->safe_psql('postgres', "DROP TABLE tab1");
$node_subscriber2->safe_psql('postgres',
- "DROP TABLE tab1");
-$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1', b text) PARTITION BY HASH (a)");
+ "CREATE TABLE tab1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab1', b text) PARTITION BY HASH (a)"
+);
# Note: tab1's partitions are named tab1_1 and tab1_2 on the publisher.
$node_subscriber2->safe_psql('postgres',
"CREATE TABLE tab1_part1 (b text, c text, a int NOT NULL)");
$node_subscriber2->safe_psql('postgres',
- "ALTER TABLE tab1 ATTACH PARTITION tab1_part1 FOR VALUES WITH (MODULUS 2, REMAINDER 0)");
+ "ALTER TABLE tab1 ATTACH PARTITION tab1_part1 FOR VALUES WITH (MODULUS 2, REMAINDER 0)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab1_part2 PARTITION OF tab1 FOR VALUES WITH (MODULUS 2, REMAINDER 1)");
+ "CREATE TABLE tab1_part2 PARTITION OF tab1 FOR VALUES WITH (MODULUS 2, REMAINDER 1)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab2 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab2', b text)");
+ "CREATE TABLE tab2 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab2', b text)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab3 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab3', b text)");
+ "CREATE TABLE tab3 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab3', b text)"
+);
$node_subscriber2->safe_psql('postgres',
- "CREATE TABLE tab3_1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab3_1', b text)");
+ "CREATE TABLE tab3_1 (a int PRIMARY KEY, c text DEFAULT 'sub2_tab3_1', b text)"
+);
# Publication that sub2 points to now publishes via root, so must update
# subscription target relations.
$node_subscriber2->safe_psql('postgres',
@@ -331,12 +332,9 @@ $node_subscriber2->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
# insert
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1 VALUES (1), (0)");
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1_1 (a) VALUES (3)");
-$node_publisher->safe_psql('postgres',
- "INSERT INTO tab1_2 VALUES (5)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1 VALUES (1), (0)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1_1 (a) VALUES (3)");
+$node_publisher->safe_psql('postgres', "INSERT INTO tab1_2 VALUES (5)");
$node_publisher->safe_psql('postgres',
"INSERT INTO tab2 VALUES (1), (0), (3), (5)");
$node_publisher->safe_psql('postgres',
@@ -347,156 +345,143 @@ $node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab2 ORDER BY 1, 2");
-is($result, qq(sub1_tab2|0
+is( $result, qq(sub1_tab2|0
sub1_tab2|1
sub1_tab2|3
sub1_tab2|5), 'inserts into tab2 replicated');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab3_1 ORDER BY 1, 2");
-is($result, qq(sub1_tab3_1|0
+is( $result, qq(sub1_tab3_1|0
sub1_tab3_1|1
sub1_tab3_1|3
sub1_tab3_1|5), 'inserts into tab3_1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1 ORDER BY 1, 2");
-is($result, qq(sub2_tab1|0
+is( $result, qq(sub2_tab1|0
sub2_tab1|1
sub2_tab1|3
sub2_tab1|5), 'inserts into tab1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab2 ORDER BY 1, 2");
-is($result, qq(sub2_tab2|0
+is( $result, qq(sub2_tab2|0
sub2_tab2|1
sub2_tab2|3
sub2_tab2|5), 'inserts into tab2 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab3 ORDER BY 1, 2");
-is($result, qq(sub2_tab3|0
+is( $result, qq(sub2_tab3|0
sub2_tab3|1
sub2_tab3|3
sub2_tab3|5), 'inserts into tab3 replicated');
# update (replicated as update)
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 6 WHERE a = 5");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab2 SET a = 6 WHERE a = 5");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab3 SET a = 6 WHERE a = 5");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 6 WHERE a = 5");
+$node_publisher->safe_psql('postgres', "UPDATE tab2 SET a = 6 WHERE a = 5");
+$node_publisher->safe_psql('postgres', "UPDATE tab3 SET a = 6 WHERE a = 5");
$node_publisher->wait_for_catchup('sub_viaroot');
$node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab2 ORDER BY 1, 2");
-is($result, qq(sub1_tab2|0
+is( $result, qq(sub1_tab2|0
sub1_tab2|1
sub1_tab2|3
sub1_tab2|6), 'update of tab2 replicated');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab3_1 ORDER BY 1, 2");
-is($result, qq(sub1_tab3_1|0
+is( $result, qq(sub1_tab3_1|0
sub1_tab3_1|1
sub1_tab3_1|3
sub1_tab3_1|6), 'update of tab3_1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1 ORDER BY 1, 2");
-is($result, qq(sub2_tab1|0
+is( $result, qq(sub2_tab1|0
sub2_tab1|1
sub2_tab1|3
sub2_tab1|6), 'inserts into tab1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab2 ORDER BY 1, 2");
-is($result, qq(sub2_tab2|0
+is( $result, qq(sub2_tab2|0
sub2_tab2|1
sub2_tab2|3
sub2_tab2|6), 'inserts into tab2 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab3 ORDER BY 1, 2");
-is($result, qq(sub2_tab3|0
+is( $result, qq(sub2_tab3|0
sub2_tab3|1
sub2_tab3|3
sub2_tab3|6), 'inserts into tab3 replicated');
# update (replicated as delete+insert)
-$node_publisher->safe_psql('postgres',
- "UPDATE tab1 SET a = 2 WHERE a = 6");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab2 SET a = 2 WHERE a = 6");
-$node_publisher->safe_psql('postgres',
- "UPDATE tab3 SET a = 2 WHERE a = 6");
+$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 2 WHERE a = 6");
+$node_publisher->safe_psql('postgres', "UPDATE tab2 SET a = 2 WHERE a = 6");
+$node_publisher->safe_psql('postgres', "UPDATE tab3 SET a = 2 WHERE a = 6");
$node_publisher->wait_for_catchup('sub_viaroot');
$node_publisher->wait_for_catchup('sub2');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab2 ORDER BY 1, 2");
-is($result, qq(sub1_tab2|0
+is( $result, qq(sub1_tab2|0
sub1_tab2|1
sub1_tab2|2
sub1_tab2|3), 'update of tab2 replicated');
$result = $node_subscriber1->safe_psql('postgres',
"SELECT c, a FROM tab3_1 ORDER BY 1, 2");
-is($result, qq(sub1_tab3_1|0
+is( $result, qq(sub1_tab3_1|0
sub1_tab3_1|1
sub1_tab3_1|2
sub1_tab3_1|3), 'update of tab3_1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab1 ORDER BY 1, 2");
-is($result, qq(sub2_tab1|0
+is( $result, qq(sub2_tab1|0
sub2_tab1|1
sub2_tab1|2
sub2_tab1|3), 'update of tab1 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab2 ORDER BY 1, 2");
-is($result, qq(sub2_tab2|0
+is( $result, qq(sub2_tab2|0
sub2_tab2|1
sub2_tab2|2
sub2_tab2|3), 'update of tab2 replicated');
$result = $node_subscriber2->safe_psql('postgres',
"SELECT c, a FROM tab3 ORDER BY 1, 2");
-is($result, qq(sub2_tab3|0
+is( $result, qq(sub2_tab3|0
sub2_tab3|1
sub2_tab3|2
sub2_tab3|3), 'update of tab3 replicated');
# delete
-$node_publisher->safe_psql('postgres',
- "DELETE FROM tab1");
-$node_publisher->safe_psql('postgres',
- "DELETE FROM tab2");
-$node_publisher->safe_psql('postgres',
- "DELETE FROM tab3");
+$node_publisher->safe_psql('postgres', "DELETE FROM tab1");
+$node_publisher->safe_psql('postgres', "DELETE FROM tab2");
+$node_publisher->safe_psql('postgres', "DELETE FROM tab3");
$node_publisher->wait_for_catchup('sub_viaroot');
$node_publisher->wait_for_catchup('sub2');
-$result = $node_subscriber1->safe_psql('postgres',
- "SELECT a FROM tab2");
+$result = $node_subscriber1->safe_psql('postgres', "SELECT a FROM tab2");
is($result, qq(), 'delete tab2 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1");
is($result, qq(), 'delete from tab1 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab2");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab2");
is($result, qq(), 'delete from tab2 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab3");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab3");
is($result, qq(), 'delete from tab3 replicated');
# truncate
@@ -505,52 +490,45 @@ $node_publisher->safe_psql('postgres',
$node_publisher->safe_psql('postgres',
"INSERT INTO tab2 VALUES (1), (2), (5)");
# these will NOT be replicated
-$node_publisher->safe_psql('postgres',
- "TRUNCATE tab1_2, tab2_1, tab3_1");
+$node_publisher->safe_psql('postgres', "TRUNCATE tab1_2, tab2_1, tab3_1");
$node_publisher->wait_for_catchup('sub_viaroot');
$node_publisher->wait_for_catchup('sub2');
-$result = $node_subscriber1->safe_psql('postgres',
- "SELECT a FROM tab2 ORDER BY 1");
-is($result, qq(1
+$result =
+ $node_subscriber1->safe_psql('postgres', "SELECT a FROM tab2 ORDER BY 1");
+is( $result, qq(1
2
5), 'truncate of tab2_1 NOT replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1 ORDER BY 1");
-is($result, qq(1
+$result =
+ $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1 ORDER BY 1");
+is( $result, qq(1
2
5), 'truncate of tab1_2 NOT replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab2 ORDER BY 1");
-is($result, qq(1
+$result =
+ $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab2 ORDER BY 1");
+is( $result, qq(1
2
5), 'truncate of tab2_1 NOT replicated');
-$node_publisher->safe_psql('postgres',
- "TRUNCATE tab1, tab2, tab3");
+$node_publisher->safe_psql('postgres', "TRUNCATE tab1, tab2, tab3");
$node_publisher->wait_for_catchup('sub_viaroot');
$node_publisher->wait_for_catchup('sub2');
-$result = $node_subscriber1->safe_psql('postgres',
- "SELECT a FROM tab2");
+$result = $node_subscriber1->safe_psql('postgres', "SELECT a FROM tab2");
is($result, qq(), 'truncate of tab2 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab1");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab1");
is($result, qq(), 'truncate of tab1 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab2");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab2");
is($result, qq(), 'truncate of tab2 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab3");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab3");
is($result, qq(), 'truncate of tab3 replicated');
-$result = $node_subscriber2->safe_psql('postgres',
- "SELECT a FROM tab3_1");
+$result = $node_subscriber2->safe_psql('postgres', "SELECT a FROM tab3_1");
is($result, qq(), 'truncate of tab3_1 replicated');