Skip to content

Commit 9cbedf0

Browse files
committed
reinit script
1 parent ba0f875 commit 9cbedf0

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3951,7 +3951,7 @@ postgres_fdw_exec(PG_FUNCTION_ARGS)
39513951
ForeignTable *table = GetForeignTable(relid);
39523952
ForeignServer *server = GetForeignServer(table->serverid);
39533953
UserMapping *user = GetUserMapping(userid, server->serverid);
3954-
PGconn *conn = GetConnection(server, user, false);
3954+
PGconn *conn = GetConnection(user, false);
39553955
PGresult *res = PQexec(conn, sql);
39563956

39573957
PQclear(res);

contrib/postgres_fdw/postgres_fdw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ typedef struct PgFdwRelationInfo
9494
List *joinclauses;
9595
} PgFdwRelationInfo;
9696

97+
/* use transaction manager */
98+
extern bool UseTsDtmTransactions;
99+
97100
/* in postgres_fdw.c */
98101
extern int set_transmission_modes(void);
99102
extern void reset_transmission_modes(int nestlevel);

reinit.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/sh
2+
3+
reinit_master() {
4+
rm -rf install/data
5+
6+
./install/bin/initdb -A trust -D ./install/data
7+
echo "max_worker_processes = 10" >> ./install/data/postgresql.conf
8+
echo "shared_preload_libraries = 'pg_tsdtm'" >> ./install/data/postgresql.conf
9+
echo "postgres_fdw.use_tsdtm = 1" >> ./install/data/postgresql.conf
10+
echo '' > ./install/data/logfile
11+
./install/bin/pg_ctl -sw -D ./install/data -l ./install/data/logfile start
12+
./install/bin/createdb stas
13+
}
14+
15+
reinit_slave1() {
16+
rm -rf install/data_slave
17+
./install/bin/initdb -A trust -D ./install/data_slave
18+
echo "port = 5433" >> ./install/data_slave/postgresql.conf
19+
echo "shared_preload_libraries = 'pg_tsdtm'" >> ./install/data/postgresql.conf
20+
echo "postgres_fdw.use_tsdtm = 1" >> ./install/data/postgresql.conf
21+
echo '' > ./install/data_slave/logfile
22+
./install/bin/pg_ctl -sw -D ./install/data_slave -l ./install/data_slave/logfile start
23+
./install/bin/createdb -p5433 stas
24+
}
25+
26+
reinit_slave2() {
27+
rm -rf install/data_slave2
28+
./install/bin/initdb -A trust -D ./install/data_slave2
29+
echo "port = 5434" >> ./install/data_slave2/postgresql.conf
30+
echo "shared_preload_libraries = 'pg_tsdtm'" >> ./install/data/postgresql.conf
31+
echo "postgres_fdw.use_tsdtm = 1" >> ./install/data/postgresql.conf
32+
echo '' > ./install/data_slave2/logfile
33+
./install/bin/pg_ctl -sw -D ./install/data_slave2 -l ./install/data_slave2/logfile start
34+
./install/bin/createdb -p5434 stas
35+
}
36+
37+
make install > /dev/null
38+
39+
40+
cat <<MSG
41+
###############################################################################
42+
# Check that we can commit and abort after soft restart.
43+
# Here checkpoint happens before shutdown and no WAL replay will not occur
44+
# during start. So code should re-create memory state from files.
45+
###############################################################################
46+
MSG
47+
48+
pkill -9 postgres
49+
ulimit -c unlimited
50+
reinit_master
51+
reinit_slave1
52+
reinit_slave2
53+
54+
user=`whoami`
55+
56+
./install/bin/psql -c "CREATE EXTENSION postgres_fdw"
57+
./install/bin/psql -c "CREATE TABLE t(u integer primary key, v integer)"
58+
59+
./install/bin/psql -p 5433 -c "CREATE EXTENSION pg_tsdtm"
60+
./install/bin/psql -p 5433 -c "CREATE TABLE t(u integer primary key, v integer)"
61+
62+
./install/bin/psql -c "CREATE SERVER shard1 FOREIGN DATA WRAPPER postgres_fdw options(dbname '$user', host 'localhost', port '5433')"
63+
./install/bin/psql -c "CREATE FOREIGN TABLE t_fdw1() inherits (t) server shard1 options(table_name 't')"
64+
./install/bin/psql -c "CREATE USER MAPPING for $user SERVER shard1 options (user '$user')"
65+
66+
./install/bin/psql -p 5434 -c "CREATE EXTENSION pg_tsdtm"
67+
./install/bin/psql -p 5434 -c "CREATE TABLE t(u integer primary key, v integer)"
68+
69+
./install/bin/psql -c "CREATE SERVER shard2 FOREIGN DATA WRAPPER postgres_fdw options(dbname '$user', host 'localhost', port '5434')"
70+
./install/bin/psql -c "CREATE FOREIGN TABLE t_fdw2() inherits (t) server shard2 options(table_name 't')"
71+
./install/bin/psql -c "CREATE USER MAPPING for $user SERVER shard2 options (user '$user')"
72+
73+
###########
74+
75+
./install/bin/psql -c "insert into t_fdw1 (select generate_series(0, 100), 0)"
76+
./install/bin/psql -c "insert into t_fdw2 (select generate_series(100, 200), 0)"
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+

0 commit comments

Comments
 (0)