1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +03:00

Initial pgperltidy run for v12.

Make all the perl code look nice, too (for some value of "nice").
This commit is contained in:
Tom Lane
2019-05-22 13:36:19 -04:00
parent 8255c7a5ee
commit db6e2b4c52
38 changed files with 487 additions and 384 deletions

View File

@@ -85,8 +85,9 @@ $node_master->restart;
# Move commit timestamps across page boundaries. Things should still
# be able to work across restarts with those transactions committed while
# track_commit_timestamp is disabled.
$node_master->safe_psql('postgres',
qq(CREATE PROCEDURE consume_xid(cnt int)
$node_master->safe_psql(
'postgres',
qq(CREATE PROCEDURE consume_xid(cnt int)
AS \$\$
DECLARE
i int;

View File

@@ -288,7 +288,7 @@ sub check_mode_recursive
unless (defined($file_stat))
{
my $is_ENOENT = $!{ENOENT};
my $msg = "unable to stat $File::Find::name: $!";
my $msg = "unable to stat $File::Find::name: $!";
if ($is_ENOENT)
{
warn $msg;

View File

@@ -9,8 +9,9 @@ use Test::More tests => 32;
my $node_master = get_new_node('master');
# A specific role is created to perform some tests related to replication,
# and it needs proper authentication configuration.
$node_master->init(allows_streaming => 1,
auth_extra => ['--create-role', 'repl_role']);
$node_master->init(
allows_streaming => 1,
auth_extra => [ '--create-role', 'repl_role' ]);
$node_master->start;
my $backup_name = 'my_backup';
@@ -124,50 +125,59 @@ test_target_session_attrs($node_standby_1, $node_master, $node_standby_1,
# role.
note "testing SHOW commands for replication connection";
$node_master->psql('postgres',"
$node_master->psql(
'postgres', "
CREATE ROLE repl_role REPLICATION LOGIN;
GRANT pg_read_all_settings TO repl_role;");
my $master_host = $node_master->host;
my $master_port = $node_master->port;
my $master_host = $node_master->host;
my $master_port = $node_master->port;
my $connstr_common = "host=$master_host port=$master_port user=repl_role";
my $connstr_rep = "$connstr_common replication=1";
my $connstr_db = "$connstr_common replication=database dbname=postgres";
my $connstr_rep = "$connstr_common replication=1";
my $connstr_db = "$connstr_common replication=database dbname=postgres";
# Test SHOW ALL
my ($ret, $stdout, $stderr) =
$node_master->psql('postgres', 'SHOW ALL;',
on_error_die => 1,
extra_params => [ '-d', $connstr_rep ]);
my ($ret, $stdout, $stderr) = $node_master->psql(
'postgres', 'SHOW ALL;',
on_error_die => 1,
extra_params => [ '-d', $connstr_rep ]);
ok($ret == 0, "SHOW ALL with replication role and physical replication");
($ret, $stdout, $stderr) =
$node_master->psql('postgres', 'SHOW ALL;',
on_error_die => 1,
extra_params => [ '-d', $connstr_db ]);
($ret, $stdout, $stderr) = $node_master->psql(
'postgres', 'SHOW ALL;',
on_error_die => 1,
extra_params => [ '-d', $connstr_db ]);
ok($ret == 0, "SHOW ALL with replication role and logical replication");
# Test SHOW with a user-settable parameter
($ret, $stdout, $stderr) =
$node_master->psql('postgres', 'SHOW work_mem;',
on_error_die => 1,
extra_params => [ '-d', $connstr_rep ]);
ok($ret == 0, "SHOW with user-settable parameter, replication role and physical replication");
($ret, $stdout, $stderr) =
$node_master->psql('postgres', 'SHOW work_mem;',
on_error_die => 1,
extra_params => [ '-d', $connstr_db ]);
ok($ret == 0, "SHOW with user-settable parameter, replication role and logical replication");
($ret, $stdout, $stderr) = $node_master->psql(
'postgres', 'SHOW work_mem;',
on_error_die => 1,
extra_params => [ '-d', $connstr_rep ]);
ok( $ret == 0,
"SHOW with user-settable parameter, replication role and physical replication"
);
($ret, $stdout, $stderr) = $node_master->psql(
'postgres', 'SHOW work_mem;',
on_error_die => 1,
extra_params => [ '-d', $connstr_db ]);
ok( $ret == 0,
"SHOW with user-settable parameter, replication role and logical replication"
);
# Test SHOW with a superuser-settable parameter
($ret, $stdout, $stderr) =
$node_master->psql('postgres', 'SHOW primary_conninfo;',
on_error_die => 1,
extra_params => [ '-d', $connstr_rep ]);
ok($ret == 0, "SHOW with superuser-settable parameter, replication role and physical replication");
($ret, $stdout, $stderr) =
$node_master->psql('postgres', 'SHOW primary_conninfo;',
on_error_die => 1,
extra_params => [ '-d', $connstr_db ]);
ok($ret == 0, "SHOW with superuser-settable parameter, replication role and logical replication");
($ret, $stdout, $stderr) = $node_master->psql(
'postgres', 'SHOW primary_conninfo;',
on_error_die => 1,
extra_params => [ '-d', $connstr_rep ]);
ok( $ret == 0,
"SHOW with superuser-settable parameter, replication role and physical replication"
);
($ret, $stdout, $stderr) = $node_master->psql(
'postgres', 'SHOW primary_conninfo;',
on_error_die => 1,
extra_params => [ '-d', $connstr_db ]);
ok( $ret == 0,
"SHOW with superuser-settable parameter, replication role and logical replication"
);
note "switching to physical replication slot";

View File

@@ -122,21 +122,26 @@ test_recovery_standby('LSN', 'standby_5', $node_master, \@recovery_params,
# different one is allowed.
@recovery_params = (
"recovery_target_name = '$recovery_name'",
"recovery_target_name = ''",
"recovery_target_time = '$recovery_time'");
"recovery_target_name = '$recovery_name'",
"recovery_target_name = ''",
"recovery_target_time = '$recovery_time'");
test_recovery_standby('multiple overriding settings',
'standby_6', $node_master, \@recovery_params, "3000", $lsn3);
'standby_6', $node_master, \@recovery_params, "3000", $lsn3);
my $node_standby = get_new_node('standby_7');
$node_standby->init_from_backup($node_master, 'my_backup', has_restoring => 1);
$node_standby->append_conf('postgresql.conf', "recovery_target_name = '$recovery_name'
$node_standby->init_from_backup($node_master, 'my_backup',
has_restoring => 1);
$node_standby->append_conf(
'postgresql.conf', "recovery_target_name = '$recovery_name'
recovery_target_time = '$recovery_time'");
my $res = run_log(['pg_ctl', '-D', $node_standby->data_dir,
'-l', $node_standby->logfile, 'start']);
ok(! $res, 'invalid recovery startup fails');
my $res = run_log(
[
'pg_ctl', '-D', $node_standby->data_dir, '-l',
$node_standby->logfile, 'start'
]);
ok(!$res, 'invalid recovery startup fails');
my $logfile = slurp_file($node_standby->logfile());
ok ($logfile =~ qr/multiple recovery targets specified/,
ok($logfile =~ qr/multiple recovery targets specified/,
'multiple conflicting settings');

View File

@@ -42,7 +42,9 @@ $node_master->teardown_node;
# promote standby 1 using "pg_promote", switching it to a new timeline
my $psql_out = '';
$node_standby_1->psql('postgres', "SELECT pg_promote(wait_seconds => 300)",
$node_standby_1->psql(
'postgres',
"SELECT pg_promote(wait_seconds => 300)",
stdout => \$psql_out);
is($psql_out, 't', "promotion of standby with pg_promote");

View File

@@ -196,8 +196,10 @@ $killme_stdin .= q[
SELECT 1;
];
ok( pump_until(
$killme, \$killme_stderr,
qr/server closed the connection unexpectedly|connection to server was lost/m),
$killme,
\$killme_stderr,
qr/server closed the connection unexpectedly|connection to server was lost/m
),
"psql query died successfully after SIGKILL");
$killme->finish;

View File

@@ -32,7 +32,8 @@ $bravo->start;
# Dummy table for the upcoming tests.
$alpha->safe_psql('postgres', 'create table test1 (a int)');
$alpha->safe_psql('postgres', 'insert into test1 select generate_series(1, 10000)');
$alpha->safe_psql('postgres',
'insert into test1 select generate_series(1, 10000)');
# take a checkpoint
$alpha->safe_psql('postgres', 'checkpoint');
@@ -41,8 +42,7 @@ $alpha->safe_psql('postgres', 'checkpoint');
# problematic WAL records.
$alpha->safe_psql('postgres', 'vacuum verbose test1');
# Wait for last record to have been replayed on the standby.
$alpha->wait_for_catchup($bravo, 'replay',
$alpha->lsn('insert'));
$alpha->wait_for_catchup($bravo, 'replay', $alpha->lsn('insert'));
# Now force a checkpoint on the standby. This seems unnecessary but for "some"
# reason, the previous checkpoint on the primary does not reflect on the standby
@@ -53,12 +53,12 @@ $bravo->safe_psql('postgres', 'checkpoint');
# Now just use a dummy table and run some operations to move minRecoveryPoint
# beyond the previous vacuum.
$alpha->safe_psql('postgres', 'create table test2 (a int, b text)');
$alpha->safe_psql('postgres', 'insert into test2 select generate_series(1,10000), md5(random()::text)');
$alpha->safe_psql('postgres',
'insert into test2 select generate_series(1,10000), md5(random()::text)');
$alpha->safe_psql('postgres', 'truncate test2');
# Wait again for all records to be replayed.
$alpha->wait_for_catchup($bravo, 'replay',
$alpha->lsn('insert'));
$alpha->wait_for_catchup($bravo, 'replay', $alpha->lsn('insert'));
# Do the promotion, which reinitializes minRecoveryPoint in the control
# file so as WAL is replayed up to the end.
@@ -69,7 +69,8 @@ $bravo->promote;
# has not happened yet.
$bravo->safe_psql('postgres', 'truncate test1');
$bravo->safe_psql('postgres', 'vacuum verbose test1');
$bravo->safe_psql('postgres', 'insert into test1 select generate_series(1,1000)');
$bravo->safe_psql('postgres',
'insert into test1 select generate_series(1,1000)');
# Now crash-stop the promoted standby and restart. This makes sure that
# replay does not see invalid page references because of an invalid
@@ -80,8 +81,5 @@ $bravo->start;
# Check state of the table after full crash recovery. All its data should
# be here.
my $psql_out;
$bravo->psql(
'postgres',
"SELECT count(*) FROM test1",
stdout => \$psql_out);
$bravo->psql('postgres', "SELECT count(*) FROM test1", stdout => \$psql_out);
is($psql_out, '1000', "Check that table state is correct");

View File

@@ -17,20 +17,20 @@ use Test::More tests => 1;
sub find_largest_lsn
{
my $blocksize = int(shift);
my $filename = shift;
my ($max_hi,$max_lo) = (0,0);
my $filename = shift;
my ($max_hi, $max_lo) = (0, 0);
open(my $fh, "<:raw", $filename)
or die "failed to open $filename: $!";
my ($buf,$len);
my ($buf, $len);
while ($len = read($fh, $buf, $blocksize))
{
$len == $blocksize
or die "read only $len of $blocksize bytes from $filename";
my ($hi,$lo) = unpack("LL", $buf);
my ($hi, $lo) = unpack("LL", $buf);
if ($hi > $max_hi or ($hi == $max_hi and $lo > $max_lo))
{
($max_hi,$max_lo) = ($hi,$lo);
($max_hi, $max_lo) = ($hi, $lo);
}
}
defined($len) or die "read error on $filename: $!";
@@ -63,7 +63,8 @@ $standby->init_from_backup($primary, 'bkp', has_streaming => 1);
$standby->start;
# Create base table whose data consistency is checked.
$primary->safe_psql('postgres', "
$primary->safe_psql(
'postgres', "
CREATE TABLE test1 (a int) WITH (fillfactor = 10);
INSERT INTO test1 SELECT generate_series(1, 10000);");
@@ -74,8 +75,7 @@ $primary->safe_psql('postgres', 'CHECKPOINT;');
$primary->safe_psql('postgres', 'UPDATE test1 SET a = a + 1;');
# Wait for last record to have been replayed on the standby.
$primary->wait_for_catchup($standby, 'replay',
$primary->lsn('insert'));
$primary->wait_for_catchup($standby, 'replay', $primary->lsn('insert'));
# Fill in the standby's shared buffers with the data filled in
# previously.
@@ -96,8 +96,7 @@ my $relfilenode = $primary->safe_psql('postgres',
"SELECT pg_relation_filepath('test1'::regclass);");
# Wait for last record to have been replayed on the standby.
$primary->wait_for_catchup($standby, 'replay',
$primary->lsn('insert'));
$primary->wait_for_catchup($standby, 'replay', $primary->lsn('insert'));
# Issue a restart point on the standby now, which makes the checkpointer
# update minRecoveryPoint.
@@ -115,11 +114,11 @@ $standby->stop('fast');
# done by directly scanning the on-disk relation blocks and what
# pg_controldata lets know.
my $standby_data = $standby->data_dir;
my $offline_max_lsn = find_largest_lsn($blocksize,
"$standby_data/$relfilenode");
my $offline_max_lsn =
find_largest_lsn($blocksize, "$standby_data/$relfilenode");
# Fetch minRecoveryPoint from the control file itself
my ($stdout, $stderr) = run_command(['pg_controldata', $standby_data]);
my ($stdout, $stderr) = run_command([ 'pg_controldata', $standby_data ]);
my @control_data = split("\n", $stdout);
my $offline_recovery_lsn = undef;
foreach (@control_data)
@@ -131,9 +130,9 @@ foreach (@control_data)
}
}
die "No minRecoveryPoint in control file found\n"
unless defined($offline_recovery_lsn);
unless defined($offline_recovery_lsn);
# minRecoveryPoint should never be older than the maximum LSN for all
# the pages on disk.
ok($offline_recovery_lsn ge $offline_max_lsn,
"Check offline that table data is consistent with minRecoveryPoint");
"Check offline that table data is consistent with minRecoveryPoint");

View File

@@ -315,14 +315,18 @@ test_connect_fails(
"does not connect with client-side CRL");
# pg_stat_ssl
command_like([
'psql', '-X', '-A', '-F', ',', '-P', 'null=_null_',
'-d', "$common_connstr sslrootcert=invalid",
'-c', "SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()"
],
qr{^pid,ssl,version,cipher,bits,compression,client_dn,client_serial,issuer_dn\n
command_like(
[
'psql', '-X',
'-A', '-F',
',', '-P',
'null=_null_', '-d',
"$common_connstr sslrootcert=invalid", '-c',
"SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()"
],
qr{^pid,ssl,version,cipher,bits,compression,client_dn,client_serial,issuer_dn\n
^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,_null_,_null_,_null_$}mx,
'pg_stat_ssl view without client certificate');
'pg_stat_ssl view without client certificate');
### Server-side tests.
###
@@ -347,14 +351,23 @@ test_connect_ok(
"certificate authorization succeeds with correct client cert");
# pg_stat_ssl
command_like([
'psql', '-X', '-A', '-F', ',', '-P', 'null=_null_',
'-d', "$common_connstr user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
'-c', "SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()"
],
qr{^pid,ssl,version,cipher,bits,compression,client_dn,client_serial,issuer_dn\n
command_like(
[
'psql',
'-X',
'-A',
'-F',
',',
'-P',
'null=_null_',
'-d',
"$common_connstr user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
'-c',
"SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()"
],
qr{^pid,ssl,version,cipher,bits,compression,client_dn,client_serial,issuer_dn\n
^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,/CN=ssltestuser,1,\Q/CN=Test CA for PostgreSQL SSL regression test client certs\E$}mx,
'pg_stat_ssl with client certificate');
'pg_stat_ssl with client certificate');
# client key with wrong permissions
test_connect_fails(
@@ -382,22 +395,28 @@ test_connect_fails(
# works, iff username matches Common Name
# fails, iff username doesn't match Common Name.
$common_connstr =
"sslrootcert=ssl/root+server_ca.crt sslmode=require dbname=verifydb hostaddr=$SERVERHOSTADDR";
"sslrootcert=ssl/root+server_ca.crt sslmode=require dbname=verifydb hostaddr=$SERVERHOSTADDR";
test_connect_ok($common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
"auth_option clientcert=verify-full succeeds with matching username and Common Name");
test_connect_ok(
$common_connstr,
"user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
"auth_option clientcert=verify-full succeeds with matching username and Common Name"
);
test_connect_fails($common_connstr,
"user=anotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
qr/FATAL/,
"auth_option clientcert=verify-full fails with mismatching username and Common Name");
test_connect_fails(
$common_connstr,
"user=anotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
qr/FATAL/,
"auth_option clientcert=verify-full fails with mismatching username and Common Name"
);
# Check that connecting with auth-optionverify-ca in pg_hba :
# works, when username doesn't match Common Name
test_connect_ok($common_connstr,
"user=yetanotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
"auth_option clientcert=verify-ca succeeds with mismatching username and Common Name");
test_connect_ok(
$common_connstr,
"user=yetanotheruser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key",
"auth_option clientcert=verify-ca succeeds with mismatching username and Common Name"
);
# intermediate client_ca.crt is provided by client, and isn't in server's ssl_ca_file
switch_server_cert($node, 'server-cn-only', 'root_ca');

View File

@@ -47,7 +47,6 @@ $common_connstr =
"user=ssltestuser dbname=trustdb sslmode=require sslcert=invalid sslrootcert=invalid hostaddr=$SERVERHOSTADDR";
# Default settings
test_connect_ok($common_connstr, '',
"Basic SCRAM authentication with SSL");
test_connect_ok($common_connstr, '', "Basic SCRAM authentication with SSL");
done_testing($number_of_tests);

View File

@@ -551,12 +551,14 @@ e|{e,d}
# Test a domain with a constraint backed by a SQL-language function,
# which needs an active snapshot in order to operate.
$node_publisher->safe_psql('postgres', "INSERT INTO tst_dom_constr VALUES (11)");
$node_publisher->safe_psql('postgres',
"INSERT INTO tst_dom_constr VALUES (11)");
$node_publisher->wait_for_catchup('tap_sub');
$result =
$node_subscriber->safe_psql('postgres', "SELECT sum(a) FROM tst_dom_constr");
$node_subscriber->safe_psql('postgres',
"SELECT sum(a) FROM tst_dom_constr");
is($result, '21', 'sql-function constraint on domain');
$node_subscriber->stop('fast');

View File

@@ -18,15 +18,17 @@ $node_subscriber->start;
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
$node_publisher->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED)");
"CREATE TABLE tab1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED)"
);
$node_subscriber->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 22) STORED)");
"CREATE TABLE tab1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 22) STORED)"
);
# data for initial sync
$node_publisher->safe_psql('postgres',
"INSERT INTO tab1 (a) VALUES (1), (2), (3)");
"INSERT INTO tab1 (a) VALUES (1), (2), (3)");
$node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub1 FOR ALL TABLES");
@@ -40,25 +42,21 @@ my $synced_query =
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
my $result = $node_subscriber->safe_psql('postgres',
"SELECT a, b FROM tab1");
is($result, qq(1|22
my $result = $node_subscriber->safe_psql('postgres', "SELECT a, b FROM tab1");
is( $result, qq(1|22
2|44
3|66), 'generated columns initial sync');
# data to replicate
$node_publisher->safe_psql('postgres',
"INSERT INTO tab1 VALUES (4), (5)");
$node_publisher->safe_psql('postgres', "INSERT INTO tab1 VALUES (4), (5)");
$node_publisher->safe_psql('postgres',
"UPDATE tab1 SET a = 6 WHERE a = 5");
$node_publisher->safe_psql('postgres', "UPDATE tab1 SET a = 6 WHERE a = 5");
$node_publisher->wait_for_catchup('sub1');
$result = $node_subscriber->safe_psql('postgres',
"SELECT a, b FROM tab1");
is($result, qq(1|22
$result = $node_subscriber->safe_psql('postgres', "SELECT a, b FROM tab1");
is( $result, qq(1|22
2|44
3|66
4|88

View File

@@ -16,11 +16,15 @@ else
}
my $node_publisher = get_new_node('publisher');
$node_publisher->init(allows_streaming => 'logical', extra => [ '--locale=C', '--encoding=UTF8' ]);
$node_publisher->init(
allows_streaming => 'logical',
extra => [ '--locale=C', '--encoding=UTF8' ]);
$node_publisher->start;
my $node_subscriber = get_new_node('subscriber');
$node_subscriber->init(allows_streaming => 'logical', extra => [ '--locale=C', '--encoding=UTF8' ]);
$node_subscriber->init(
allows_streaming => 'logical',
extra => [ '--locale=C', '--encoding=UTF8' ]);
$node_subscriber->start;
my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
@@ -36,7 +40,8 @@ my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
# full, since those have different code paths internally.
$node_subscriber->safe_psql('postgres',
q{CREATE COLLATION ctest_nondet (provider = icu, locale = 'und', deterministic = false)});
q{CREATE COLLATION ctest_nondet (provider = icu, locale = 'und', deterministic = false)}
);
# table with replica identity index
@@ -54,8 +59,7 @@ $node_subscriber->safe_psql('postgres',
# table with replica identity full
$node_publisher->safe_psql('postgres',
q{CREATE TABLE tab2 (a text, b text)});
$node_publisher->safe_psql('postgres', q{CREATE TABLE tab2 (a text, b text)});
$node_publisher->safe_psql('postgres',
q{ALTER TABLE tab2 REPLICA IDENTITY FULL});
@@ -76,7 +80,8 @@ $node_publisher->safe_psql('postgres',
q{CREATE PUBLICATION pub1 FOR ALL TABLES});
$node_subscriber->safe_psql('postgres',
qq{CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1 WITH (copy_data = false)});
qq{CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1 WITH (copy_data = false)}
);
$node_publisher->wait_for_catchup('sub1');
@@ -88,8 +93,7 @@ $node_publisher->safe_psql('postgres',
$node_publisher->wait_for_catchup('sub1');
is($node_subscriber->safe_psql('postgres', q{SELECT b FROM tab1}),
qq(bar),
'update with primary key with nondeterministic collation');
qq(bar), 'update with primary key with nondeterministic collation');
# test with replica identity full
@@ -99,5 +103,5 @@ $node_publisher->safe_psql('postgres',
$node_publisher->wait_for_catchup('sub1');
is($node_subscriber->safe_psql('postgres', q{SELECT b FROM tab2}),
qq(bar),
'update with replica identity full with nondeterministic collation');
qq(bar),
'update with replica identity full with nondeterministic collation');

View File

@@ -30,7 +30,8 @@ $node_publisher->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_publisher->safe_psql('postgres',
"CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'");
"CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
);
# an index with a predicate that lends itself to constant expressions
# evaluation
@@ -42,7 +43,8 @@ $node_subscriber->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_subscriber->safe_psql('postgres',
"CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'");
"CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
);
$node_subscriber->safe_psql('postgres',
"CREATE INDEX ON tab1 (b) WHERE a > double(1)");
@@ -51,14 +53,14 @@ $node_publisher->safe_psql('postgres',
"CREATE PUBLICATION pub1 FOR ALL TABLES");
$node_subscriber->safe_psql('postgres',
"CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1");
"CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1"
);
$node_publisher->wait_for_catchup('sub1');
# This would crash, first on the publisher, and then (if the publisher
# is fixed) on the subscriber.
$node_publisher->safe_psql('postgres',
"INSERT INTO tab1 VALUES (1, 2)");
$node_publisher->safe_psql('postgres', "INSERT INTO tab1 VALUES (1, 2)");
$node_publisher->wait_for_catchup('sub1');