|
| 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