Skip to content

Commit fce7945

Browse files
committed
introduce pathman_copy_stmt_hooking regression test
1 parent e4e95cf commit fce7945

File tree

3 files changed

+206
-1
lines changed

3 files changed

+206
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ REGRESS = pathman_basic \
1919
pathman_domains \
2020
pathman_foreign_keys \
2121
pathman_permissions \
22-
pathman_rowmarks
22+
pathman_rowmarks \
23+
pathman_copy_stmt_hooking
2324
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
2425
EXTRA_CLEAN = pg_pathman--$(EXTVERSION).sql ./isolation_output
2526

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
\set VERBOSITY terse
2+
CREATE EXTENSION pg_pathman;
3+
CREATE SCHEMA copy_stmt_hooking;
4+
CREATE TABLE copy_stmt_hooking.test(val int not null, comment text);
5+
INSERT INTO copy_stmt_hooking.test SELECT generate_series(1, 20), 'comment';
6+
/* test for RANGE partitioning */
7+
SELECT create_range_partitions('copy_stmt_hooking.test', 'val', 1, 5);
8+
NOTICE: sequence "test_seq" does not exist, skipping
9+
create_range_partitions
10+
-------------------------
11+
4
12+
(1 row)
13+
14+
/* perform VACUUM */
15+
VACUUM FULL copy_stmt_hooking.test_1;
16+
VACUUM FULL copy_stmt_hooking.test_2;
17+
VACUUM FULL copy_stmt_hooking.test_3;
18+
VACUUM FULL copy_stmt_hooking.test_4;
19+
/* COPY TO */
20+
COPY copy_stmt_hooking.test TO stdout;
21+
1 comment
22+
2 comment
23+
3 comment
24+
4 comment
25+
5 comment
26+
6 comment
27+
7 comment
28+
8 comment
29+
9 comment
30+
10 comment
31+
11 comment
32+
12 comment
33+
13 comment
34+
14 comment
35+
15 comment
36+
16 comment
37+
17 comment
38+
18 comment
39+
19 comment
40+
20 comment
41+
\copy copy_stmt_hooking.test to stdout (format csv)
42+
1,comment
43+
2,comment
44+
3,comment
45+
4,comment
46+
5,comment
47+
6,comment
48+
7,comment
49+
8,comment
50+
9,comment
51+
10,comment
52+
11,comment
53+
12,comment
54+
13,comment
55+
14,comment
56+
15,comment
57+
16,comment
58+
17,comment
59+
18,comment
60+
19,comment
61+
20,comment
62+
\copy copy_stmt_hooking.test(comment) to stdout
63+
comment
64+
comment
65+
comment
66+
comment
67+
comment
68+
comment
69+
comment
70+
comment
71+
comment
72+
comment
73+
comment
74+
comment
75+
comment
76+
comment
77+
comment
78+
comment
79+
comment
80+
comment
81+
comment
82+
comment
83+
/* DELETE ROWS, COPY FROM */
84+
DELETE FROM copy_stmt_hooking.test;
85+
COPY copy_stmt_hooking.test FROM stdin;
86+
SELECT count(*) FROM ONLY copy_stmt_hooking.test;
87+
count
88+
-------
89+
0
90+
(1 row)
91+
92+
SELECT *, tableoid::REGCLASS FROM copy_stmt_hooking.test ORDER BY val;
93+
val | comment | tableoid
94+
-----+---------+--------------------------
95+
1 | test_1 | copy_stmt_hooking.test_1
96+
6 | test_2 | copy_stmt_hooking.test_2
97+
7 | test_2 | copy_stmt_hooking.test_2
98+
11 | test_3 | copy_stmt_hooking.test_3
99+
16 | test_4 | copy_stmt_hooking.test_4
100+
(5 rows)
101+
102+
/* COPY TO (partition does not exist) */
103+
COPY copy_stmt_hooking.test FROM stdin;
104+
ERROR: no suitable partition for key '21'
105+
COPY copy_stmt_hooking.test(comment) FROM stdin;
106+
ERROR: partitioned column's value should not be NULL
107+
/* delete all data */
108+
SELECT drop_partitions('copy_stmt_hooking.test', true);
109+
NOTICE: function copy_stmt_hooking.test_upd_trig_func() does not exist, skipping
110+
drop_partitions
111+
-----------------
112+
4
113+
(1 row)
114+
115+
/* test for HASH partitioning */
116+
SELECT create_hash_partitions('copy_stmt_hooking.test', 'val', 5);
117+
create_hash_partitions
118+
------------------------
119+
5
120+
(1 row)
121+
122+
/* DELETE ROWS, COPY FROM */
123+
DELETE FROM copy_stmt_hooking.test;
124+
COPY copy_stmt_hooking.test FROM stdin;
125+
SELECT count(*) FROM ONLY copy_stmt_hooking.test;
126+
count
127+
-------
128+
0
129+
(1 row)
130+
131+
SELECT * FROM copy_stmt_hooking.test ORDER BY val;
132+
val | comment
133+
-----+---------
134+
1 | hash_1
135+
6 | hash_2
136+
(2 rows)
137+
138+
DROP SCHEMA copy_stmt_hooking CASCADE;
139+
NOTICE: drop cascades to 7 other objects
140+
DROP EXTENSION pg_pathman;

sql/pathman_copy_stmt_hooking.sql

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
\set VERBOSITY terse
2+
3+
CREATE EXTENSION pg_pathman;
4+
CREATE SCHEMA copy_stmt_hooking;
5+
6+
7+
CREATE TABLE copy_stmt_hooking.test(val int not null, comment text);
8+
INSERT INTO copy_stmt_hooking.test SELECT generate_series(1, 20), 'comment';
9+
10+
11+
/* test for RANGE partitioning */
12+
SELECT create_range_partitions('copy_stmt_hooking.test', 'val', 1, 5);
13+
14+
/* perform VACUUM */
15+
VACUUM FULL copy_stmt_hooking.test_1;
16+
VACUUM FULL copy_stmt_hooking.test_2;
17+
VACUUM FULL copy_stmt_hooking.test_3;
18+
VACUUM FULL copy_stmt_hooking.test_4;
19+
20+
/* COPY TO */
21+
COPY copy_stmt_hooking.test TO stdout;
22+
\copy copy_stmt_hooking.test to stdout (format csv)
23+
\copy copy_stmt_hooking.test(comment) to stdout
24+
25+
/* DELETE ROWS, COPY FROM */
26+
DELETE FROM copy_stmt_hooking.test;
27+
COPY copy_stmt_hooking.test FROM stdin;
28+
1 test_1
29+
6 test_2
30+
7 test_2
31+
11 test_3
32+
16 test_4
33+
\.
34+
SELECT count(*) FROM ONLY copy_stmt_hooking.test;
35+
SELECT *, tableoid::REGCLASS FROM copy_stmt_hooking.test ORDER BY val;
36+
37+
/* COPY TO (partition does not exist) */
38+
COPY copy_stmt_hooking.test FROM stdin;
39+
21 test_no_part
40+
\.
41+
COPY copy_stmt_hooking.test(comment) FROM stdin;
42+
test_no_part
43+
\.
44+
45+
46+
/* delete all data */
47+
SELECT drop_partitions('copy_stmt_hooking.test', true);
48+
49+
50+
/* test for HASH partitioning */
51+
SELECT create_hash_partitions('copy_stmt_hooking.test', 'val', 5);
52+
53+
/* DELETE ROWS, COPY FROM */
54+
DELETE FROM copy_stmt_hooking.test;
55+
COPY copy_stmt_hooking.test FROM stdin;
56+
1 hash_1
57+
6 hash_2
58+
\.
59+
SELECT count(*) FROM ONLY copy_stmt_hooking.test;
60+
SELECT * FROM copy_stmt_hooking.test ORDER BY val;
61+
62+
63+
DROP SCHEMA copy_stmt_hooking CASCADE;
64+
DROP EXTENSION pg_pathman;

0 commit comments

Comments
 (0)