File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ import psycopg2
2+ from psycopg2 .extras import LogicalReplicationConnection
3+
4+ conn = psycopg2 .connect ("dbname=regression" , connection_factory = LogicalReplicationConnection )
5+ cur = conn .cursor ()
6+
7+ cur .create_replication_slot ("slotpy" ,
8+ slot_type = psycopg2 .extras .REPLICATION_LOGICAL ,
9+ output_plugin = 'test_decoding' )
10+
11+ cur .start_replication ("slotpy" )
12+
13+ def consumer (msg ):
14+ print (msg .payload )
15+
16+ cur .consume_stream (consumer )
17+
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # this script assumes that postgres and test_decodong is installed
4+ # (srcdir)/tmp_install
5+
6+ rm -rf tmp_install/data1
7+ ./tmp_install/bin/initdb -D ./tmp_install/data1
8+ ./tmp_install/bin/pg_ctl -w -D ./tmp_install/data1 -l logfile start
9+ ./tmp_install/bin/createdb regression
10+
11+ cat >> ./tmp_install/data1/postgresql.conf << -CONF
12+ wal_level=logical
13+ max_replication_slots=4
14+ max_prepared_transactions=20
15+ shared_preload_libraries='test_decoding'
16+ wal_sender_timeout=600000
17+ CONF
18+ ./tmp_install/bin/pg_ctl -w -D ./tmp_install/data1 -l logfile restart
19+
20+ python3 repconsumer.py > xlog_decoded &
21+ REPCONSUMER_PID=$!
22+
23+ sleep 3
24+
25+ cd src/test/regress
26+
27+ # ./pg_regress --inputdir=. --bindir='../../../tmp_install/bin' --dlpath=. --schedule=./parallel_schedule --use-existing
28+
29+ ./pg_regress --inputdir=. --bindir=' ../../../tmp_install/bin' --dlpath=. --schedule=./serial_schedule --use-existing
30+
31+ cd ../../..
32+
33+ kill $REPCONSUMER_PID
34+ ./tmp_install/bin/pg_ctl -D ./tmp_install/data1 -l logfile stop
You can’t perform that action at this time.
0 commit comments