summaryrefslogtreecommitdiff
path: root/contrib/pgxc_clean/pgxc_clean_test.sh
blob: 87bc928173e963095705186d8ec80ff18384ed13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
#
# This script sets up test environment for pgxc_clean.
# Please note that all the prepared transactions are
# partially committed or aborted.
#
# You should configure PGPORT and PGHOST to connect, as
# well as node names for your test environment.
#
# Before you run this script, XC should be up and ready.
# Also, this may try to drop test databases.   You may need
# to run CLEAN CONNECTION satement for each coordinator in
# advance.
#

if [ $# -le 0 ]
then
	create=no
else
	if [ $1 = create ]
	then
		create=yes
	else
		create=no
	fi
fi

export PGPORT=20004
exprot PGHOST=localhost
sourcedb=postgres

if [ $create = yes ]
then
psql -e $sourcedb <<EOF
drop database if exists test1;
drop database if exists test2;
drop database if exists test3;
create database test1;
create database test2;
create database test3;
\q
EOF
fi

psql -e test1 <<EOF
drop table if exists t;
begin;
create table t (a int);
prepare transaction 'test1_1';
\q
EOF

psql -e test2 <<EOF
drop table if exists t;
begin;
create table t (a int);
prepare transaction 'test2_1';
\q
EOF

psql -e test3 <<EOF
drop table if exists t;
begin;
create table t (a int);
prepare transaction 'test3_1';
\q
EOF

psql -e test1 <<EOF
set xc_maintenance_mode = on;
execute direct on node1 'commit prepared ''test1_1'' ';
\q
EOF

psql -e test2 <<EOF
set xc_maintenance_mode = on;
execute direct on node2 'commit prepared ''test2_1'' ';
\q
EOF

psql -e test3 <<EOF
set xc_maintenance_mode = on;
execute direct on node1 'rollback prepared ''test3_1'' ';
\q
EOF