Skip to content

Commit b240a48

Browse files
Add COPY test
Fixes #50
1 parent 3bf5636 commit b240a48

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SCRIPTS_built = pglogical_create_subscriber
1818
PG_CPPFLAGS = -I$(libpq_srcdir)
1919
SHLIB_LINK = $(libpq)
2020

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

2323
EXTRA_CLEAN += pglogical.control
2424

expected/copy.out

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
--test COPY
2+
\c regression
3+
SELECT pglogical.replicate_ddl_command($$
4+
CREATE TABLE public.x (
5+
a serial primary key,
6+
b int,
7+
c text not null default 'stuff',
8+
d text,
9+
e text
10+
);
11+
$$);
12+
replicate_ddl_command
13+
-----------------------
14+
t
15+
(1 row)
16+
17+
SELECT * FROM pglogical.replication_set_add_table('default', 'x');
18+
replication_set_add_table
19+
---------------------------
20+
t
21+
(1 row)
22+
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+
COPY x (a, b, c, d, e) from stdin;
30+
COPY x (b, d) from stdin;
31+
COPY x (b, d) from stdin;
32+
COPY x (a, b, c, d, e) from stdin;
33+
SELECT * FROM x ORDER BY a;
34+
a | b | c | d | e
35+
-------+----+-------+--------+----
36+
1 | 1 | stuff | test_1 |
37+
2 | 2 | stuff | test_2 |
38+
3 | 3 | stuff | test_3 |
39+
4 | 4 | stuff | test_4 |
40+
5 | 5 | stuff | test_5 |
41+
9999 | | \N | NN |
42+
10000 | 21 | 31 | 41 | 51
43+
10001 | 22 | 32 | 42 | 52
44+
10002 | 23 | 33 | 43 | 53
45+
10003 | 24 | 34 | 44 | 54
46+
10004 | 25 | 35 | 45 | 55
47+
10005 | 26 | 36 | 46 | 56
48+
(12 rows)
49+
50+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
51+
pg_xlog_wait_remote_apply
52+
---------------------------
53+
54+
(1 row)
55+
56+
\c postgres
57+
SELECT * FROM x ORDER BY a;
58+
a | b | c | d | e
59+
-------+----+-------+--------+----
60+
1 | 1 | stuff | test_1 |
61+
2 | 2 | stuff | test_2 |
62+
3 | 3 | stuff | test_3 |
63+
4 | 4 | stuff | test_4 |
64+
5 | 5 | stuff | test_5 |
65+
9999 | | \N | NN |
66+
10000 | 21 | 31 | 41 | 51
67+
10001 | 22 | 32 | 42 | 52
68+
10002 | 23 | 33 | 43 | 53
69+
10003 | 24 | 34 | 44 | 54
70+
10004 | 25 | 35 | 45 | 55
71+
10005 | 26 | 36 | 46 | 56
72+
(12 rows)
73+

sql/copy.sql

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--test COPY
2+
\c regression
3+
4+
SELECT pglogical.replicate_ddl_command($$
5+
CREATE TABLE public.x (
6+
a serial primary key,
7+
b int,
8+
c text not null default 'stuff',
9+
d text,
10+
e text
11+
);
12+
$$);
13+
14+
SELECT * FROM pglogical.replication_set_add_table('default', 'x');
15+
16+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
17+
18+
COPY x (a, b, c, d, e) from stdin;
19+
9999 \N \\N \NN \N
20+
10000 21 31 41 51
21+
\.
22+
23+
COPY x (b, d) from stdin;
24+
1 test_1
25+
\.
26+
27+
COPY x (b, d) from stdin;
28+
2 test_2
29+
3 test_3
30+
4 test_4
31+
5 test_5
32+
\.
33+
34+
COPY x (a, b, c, d, e) from stdin;
35+
10001 22 32 42 52
36+
10002 23 33 43 53
37+
10003 24 34 44 54
38+
10004 25 35 45 55
39+
10005 26 36 46 56
40+
\.
41+
42+
SELECT * FROM x ORDER BY a;
43+
SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), 0);
44+
45+
\c postgres
46+
SELECT * FROM x ORDER BY a;

0 commit comments

Comments
 (0)