8000 tests · postgrespro/postgres_cluster@75e6e6b · GitHub
[go: up one dir, main page]

Skip to content

Commit 75e6e6b

Browse files
committed
tests
1 parent f8617e2 commit 75e6e6b

File tree

3 files changed

+169
-1
lines changed

3 files changed

+169
-1
lines changed

contrib/pglogical/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OBJS = pglogical_apply.o pglogical_conflict.o pglogical_manager.o \
1515
PG_CPPFLAGS = -I$(libpq_srcdir) -I$(top_srcdir)/contrib/pglogical_output
1616
SHLIB_LINK = $(libpq)
1717

18-
REGRESS = preseed infofuncs init_fail init preseed_check basic extended toasted replication_set add_table matview bidirectional primary_key foreign_key functions copy drop
18+
REGRESS = preseed infofuncs init_fail init preseed_check basic extended twophase toasted replication_set add_table matview bidirectional primary_key foreign_key functions copy drop
1919

2020
# In-tree builds only
2121
subdir = contrib/pglogical
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/* First test whether a table's replication set can be properly manipulated */
2+
SELECT * FROM pglogical_regress_variables()
3+
\gset
4+
\c :provider_dsn
5+
SELECT pglogical.replicate_ddl_command($$
6+
CREATE TABLE public.test2pc_tbl(id serial primary key, value int);
7+
$$);
8+
replicate_ddl_command
9+
-----------------------
10+
t
11+
(1 row)
12+
13+
SELECT * FROM pglogical.replication_set_add_all_tables('default', '{public}');
14+
replication_set_add_all_tables
15+
--------------------------------
16+
t
17+
(1 row)
18+
19+
-- Check that prapeared state is visible on slave and data available after commit
20+
BEGIN;
21+
INSERT INTO test2pc_tbl VALUES (1, 10);
22+
PREPARE TRANSACTION 'tx1';
23+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
24+
pg_xlog_wait_remote_apply
25+
---------------------------
26+
27+
(1 row)
28+
29+
\c :subscriber_dsn
30+
SELECT gid, owner, database FROM pg_prepared_xacts;
31+
gid | owner | database
32+
-----+-------+--------------------
33+
tx1 | stas | contrib_regression
34+
(1 row)
35+
36+
SELECT * FROM test2pc_tbl;
37+
id | value
38+
----+-------
39+
(0 rows)
40+
41+
\c :provider_dsn
42+
COMMIT PREPARED 'tx1';
43+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
44+
pg_xlog_wait_remote_apply
45+
---------------------------
46+
47+
(1 row)
48+
49+
\c :subscriber_dsn
50+
SELECT gid, owner, database FROM pg_prepared_xacts;
51+
gid | owner | database
52+
-----+-------+----------
53< 10000 span class="diff-text-marker">+
(0 rows)
54+
55+
SELECT * FROM test2pc_tbl;
56+
id | value
57+
----+-------
58+
1 | 10
59+
(1 row)
60+
61+
-- Check that prapeared state is visible on slave and data is ignored after abort
62+
\c :provider_dsn
63+
BEGIN;
64+
INSERT INTO test2pc_tbl VALUES (2, 20);
65+
PREPARE TRANSACTION 'tx2';
66+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
67+
pg_xlog_wait_remote_apply
68+
---------------------------
69+
70+
(1 row)
71+
72+
\c :subscriber_dsn
73+
SELECT gid, owner, database FROM pg_prepared_xacts;
74+
gid | owner | database
75+
-----+-------+--------------------
76+
tx2 | stas | contrib_regression
77+
(1 row)
78+
79+
SELECT * FROM test2pc_tbl;
80+
id | value
81+
----+-------
82+
1 | 10
83+
(1 row)
84+
85+
\c :provider_dsn
86+
ROLLBACK PREPARED 'tx2';
87+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
88+
pg_xlog_wait_remote_apply
89+
---------------------------
90+
91+
(1 row)
92+
93+
\c :subscriber_dsn
94+
SELECT gid, owner, database FROM pg_prepared_xacts;
95+
gid | owner | database
96+
-----+-------+----------
97+
(0 rows)
98+
99+
SELECT * FROM test2pc_tbl;
100+
id | value
101+
----+-------
102+
1 | 10
103+
(1 row)
104+
105+
-- Clean up
106+
\set VERBOSITY terse
107+
SELECT pglogical.replicate_ddl_command($$
108+
DROP TABLE public.test2pc_tbl CASCADE;
109+
$$);
110+
replicate_ddl_command
111+
-----------------------
112+
t
113+
(1 row)
114+

contrib/pglogical/sql/twophase.sql

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* First test whether a table's replication set can be properly manipulated */
2+
SELECT * FROM pglogical_regress_variables()
3+
\gset
4+
5+
\c :provider_dsn
6+
SELECT pglogical.replicate_ddl_command($$
7+
CREATE TABLE public.test2pc_tbl(id serial primary key, value int);
8+
$$);
9+
SELECT * FROM pglogical.replication_set_add_all_tables('default', '{public}');
10+
11+
12+
-- Check that prapeared state is visible on slave and data available after commit
13+
BEGIN;
14+
INSERT INTO test2pc_tbl VALUES (1, 10);
15+
PREPARE TRANSACTION 'tx1';
16+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
17+
18+
\c :subscriber_dsn
19+
SELECT gid, owner, database FROM pg_prepared_xacts;
20+
SELECT * FROM test2pc_tbl;
21+
22+
\c :provider_dsn
23+
COMMIT PREPARED 'tx1';
24+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
25+
26+
\c :subscriber_dsn
27+
SELECT gid, owner, database FROM pg_prepared_xacts;
28+
SELECT * FROM test2pc_tbl;
29+
30+
31+
-- Check that prapeared state is visible on slave and data is ignored after abort
32+
\c :provider_dsn
33+
BEGIN;
34+
INSERT INTO test2pc_tbl VALUES (2, 20);
35+
PREPARE TRANSACTION 'tx2';
36+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
37+
38+
\c :subscriber_dsn
39+
SELECT gid, owner, database FROM pg_prepared_xacts;
40+
SELECT * FROM test2pc_tbl;
41+
42+
\c :provider_dsn
43+
ROLLBACK PREPARED 'tx2';
44+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
45+
46+
\c :subscriber_dsn
47+
SELECT gid, owner, database FROM pg_prepared_xacts;
48+
SELECT * FROM test2pc_tbl;
49+
50+
-- Clean up
51+
\set VERBOSITY terse
52+
SELECT pglogical.replicate_ddl_command($$
53+
DROP TABLE public.test2pc_tbl CASCADE;
54+
$$);

0 commit comments

Comments
 (0)
0