Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit44aeecd

Browse files
committed
Fix global_snapshot bank tests.
* getpwuid is unheard on windows;* safe_psql instead of psql to actually see if something goes wrong;* track global snapshots on shards;
1 parentf18a8ae commit44aeecd

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

‎contrib/postgres_fdw/t/001_bank_check.pl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
my$shard1 = get_new_node("shard1");
2222
$shard1->init;
2323
$shard1->append_conf('postgresql.conf',qq(
24+
track_global_snapshots = on
2425
max_prepared_transactions = 30
2526
log_checkpoints = true
2627
));
@@ -29,34 +30,33 @@
2930
my$shard2 = get_new_node("shard2");
3031
$shard2->init;
3132
$shard2->append_conf('postgresql.conf',qq(
33+
track_global_snapshots = on
3234
max_prepared_transactions = 30
3335
log_checkpoints = true
3436
));
3537
$shard2->start;
3638

3739
###############################################################################
3840

39-
$master->psql('postgres',"CREATE EXTENSION postgres_fdw");
40-
$master->psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
41+
$master->safe_psql('postgres',"CREATE EXTENSION postgres_fdw");
42+
$master->safe_psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
4143

4244
foreachmy$node ($shard1,$shard2)
4345
{
4446
my$port =$node->port;
4547
my$host =$node->host;
4648

47-
# $node->psql('postgres', "CREATE EXTENSION pg_tsdtm");
48-
$node->psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
49+
$node->safe_psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
4950

50-
$master->psql('postgres',"CREATE SERVER shard_$port FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host '$host', port '$port')");
51-
$master->psql('postgres',"CREATE FOREIGN TABLE accounts_fdw_$port() inherits (accounts) server shard_$port options(table_name 'accounts')");
52-
my$me =scalar(getpwuid($<));
53-
$master->psql('postgres',"CREATE USER MAPPING for$me SERVER shard_$port options (user '$me')");
51+
$master->safe_psql('postgres',"CREATE SERVER shard_$port FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host '$host', port '$port')");
52+
$master->safe_psql('postgres',"CREATE FOREIGN TABLE accounts_fdw_$port() inherits (accounts) server shard_$port options(table_name 'accounts')");
53+
$master->safe_psql('postgres',"CREATE USER MAPPING for CURRENT_USER SERVER shard_$port");
5454

5555
# diag("done $host $port");
5656
}
5757

58-
$shard1->psql('postgres',"insert into accounts select 2*id-1, 0 from generate_series(1, 10010) as id;");
59-
$shard2->psql('postgres',"insert into accounts select 2*id, 0 from generate_series(1, 10010) as id;");
58+
$shard1->safe_psql('postgres',"insert into accounts select 2*id-1, 0 from generate_series(1, 10010) as id;");
59+
$shard2->safe_psql('postgres',"insert into accounts select 2*id, 0 from generate_series(1, 10010) as id;");
6060

6161
# diag( $master->connstr() );
6262
# sleep(3600);
@@ -76,7 +76,7 @@
7676
my$started =time();
7777
while (time() -$started <$seconds)
7878
{
79-
($rc,$total,$err) =$master->psql('postgres',"select sum(amount) from accounts");
79+
($rc,$total,$err) =$master->safe_psql('postgres',"select sum(amount) from accounts");
8080
if ( ($totalne$oldtotal)and ($totalne'') )
8181
{
8282
$isolation_error = 1;

‎contrib/postgres_fdw/t/002_bank_check_self.pl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@
2121
my$shard1 = get_new_node("shard1");
2222
$shard1->init;
2323
$shard1->append_conf('postgresql.conf',qq(
24+
track_global_snapshots = on
2425
max_prepared_transactions = 30
2526
log_checkpoints = true
2627
));
2728
$shard1->start;
2829

2930
###############################################################################
3031

31-
$master->psql('postgres',"CREATE EXTENSION postgres_fdw");
32-
$master->psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
32+
$master->safe_psql('postgres',"CREATE EXTENSION postgres_fdw");
33+
$master->safe_psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
3334
my$master_port =$master->port;
34-
$master->psql('postgres',"CREATE TABLE accounts_$master_port() inherits (accounts)");
35+
$master->safe_psql('postgres',"CREATE TABLE accounts_$master_port() inherits (accounts)");
3536

3637

3738
my$port =$shard1->port;
3839
my$host =$shard1->host;
3940

40-
$shard1->psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
41+
$shard1->safe_psql('postgres',"CREATE TABLE accounts(id integer primary key, amount integer)");
4142

42-
$master->psql('postgres',"CREATE SERVER shard_$port FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host '$host', port '$port')");
43-
$master->psql('postgres',"CREATE FOREIGN TABLE accounts_fdw_$port() inherits (accounts) server shard_$port options(table_name 'accounts')");
44-
my$me =scalar(getpwuid($<));
45-
$master->psql('postgres',"CREATE USER MAPPING for$me SERVER shard_$port options (user '$me')");
43+
$master->safe_psql('postgres',"CREATE SERVER shard_$port FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host '$host', port '$port')");
44+
$master->safe_psql('postgres',"CREATE FOREIGN TABLE accounts_fdw_$port() inherits (accounts) server shard_$port options(table_name 'accounts')");
45+
$master->safe_psql('postgres',"CREATE USER MAPPING for CURRENT_USER SERVER shard_$port");
4646

4747
# diag("done $host $port");
4848

49-
$master->psql('postgres',"insert into accounts select 2*id-1, 0 from generate_series(1, 10010) as id;");
50-
$shard1->psql('postgres',"insert into accounts select 2*id, 0 from generate_series(1, 10010) as id;");
49+
$master->safe_psql('postgres',"insert into accounts select 2*id-1, 0 from generate_series(1, 10010) as id;");
50+
$shard1->safe_psql('postgres',"insert into accounts select 2*id, 0 from generate_series(1, 10010) as id;");
5151

5252
# diag( $master->connstr() );
5353
# sleep(3600);
@@ -67,7 +67,7 @@
6767
my$started =time();
6868
while (time() -$started <$seconds)
6969
{
70-
($rc,$total,$err) =$master->psql('postgres',"select sum(amount) from accounts");
70+
($rc,$total,$err) =$master->safe_psql('postgres',"select sum(amount) from accounts");
7171
if ( ($totalne$oldtotal)and ($totalne'') )
7272
{
7373
$isolation_error = 1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp