Skip to content

Commit 4bbab4c

Browse files
committed
extend calamity tests
1 parent 41e1e7a commit 4bbab4c

File tree

2 files changed

+159
-1
lines changed

2 files changed

+159
-1
lines changed

expected/pathman_calamity.out

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,127 @@ SELECT debug_capture();
1212
set client_min_messages = NOTICE;
1313
/* create table to be partitioned */
1414
CREATE TABLE calamity.part_test(val serial);
15+
/* test pg_pathman's cache */
16+
INSERT INTO calamity.part_test SELECT generate_series(1, 30);
17+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
18+
NOTICE: sequence "part_test_seq" does not exist, skipping
19+
create_range_partitions
20+
-------------------------
21+
3
22+
(1 row)
23+
24+
SELECT drop_partitions('calamity.part_test');
25+
NOTICE: function calamity.part_test_upd_trig_func() does not exist, skipping
26+
NOTICE: 10 rows copied from calamity.part_test_1
27+
NOTICE: 10 rows copied from calamity.part_test_2
28+
NOTICE: 10 rows copied from calamity.part_test_3
29+
drop_partitions
30+
-----------------
31+
3
32+
(1 row)
33+
34+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
35+
create_range_partitions
36+
-------------------------
37+
3
38+
(1 row)
39+
40+
SELECT drop_partitions('calamity.part_test');
41+
NOTICE: function calamity.part_test_upd_trig_func() does not exist, skipping
42+
NOTICE: 10 rows copied from calamity.part_test_1
43+
NOTICE: 10 rows copied from calamity.part_test_2
44+
NOTICE: 10 rows copied from calamity.part_test_3
45+
drop_partitions
46+
-----------------
47+
3
48+
(1 row)
49+
50+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
51+
create_range_partitions
52+
-------------------------
53+
3
54+
(1 row)
55+
56+
SELECT append_range_partition('calamity.part_test');
57+
append_range_partition
58+
------------------------
59+
calamity.part_test_4
60+
(1 row)
61+
62+
SELECT drop_partitions('calamity.part_test');
63+
NOTICE: function calamity.part_test_upd_trig_func() does not exist, skipping
64+
NOTICE: 10 rows copied from calamity.part_test_1
65+
NOTICE: 10 rows copied from calamity.part_test_2
66+
NOTICE: 10 rows copied from calamity.part_test_3
67+
NOTICE: 0 rows copied from calamity.part_test_4
68+
drop_partitions
69+
-----------------
70+
4
71+
(1 row)
72+
73+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
74+
create_range_partitions
75+
-------------------------
76+
3
77+
(1 row)
78+
79+
SELECT append_range_partition('calamity.part_test');
80+
append_range_partition
81+
------------------------
82+
calamity.part_test_4
83+
(1 row)
84+
85+
SELECT drop_partitions('calamity.part_test');
86+
NOTICE: function calamity.part_test_upd_trig_func() does not exist, skipping
87+
NOTICE: 10 rows copied from calamity.part_test_1
88+
NOTICE: 10 rows copied from calamity.part_test_2
89+
NOTICE: 10 rows copied from calamity.part_test_3
90+
NOTICE: 0 rows copied from calamity.part_test_4
91+
drop_partitions
92+
-----------------
93+
4
94+
(1 row)
95+
96+
SELECT count(*) FROM calamity.part_test;
97+
count
98+
-------
99+
30
100+
(1 row)
101+
102+
DELETE FROM calamity.part_test;
103+
/* test stub 'enable_parent' value for PATHMAN_CONFIG_PARAMS */
104+
INSERT INTO calamity.part_test SELECT generate_series(1, 30);
105+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
106+
create_range_partitions
107+
-------------------------
108+
3
109+
(1 row)
110+
111+
DELETE FROM pathman_config_params WHERE partrel = 'calamity.part_test'::regclass;
112+
SELECT append_range_partition('calamity.part_test');
113+
append_range_partition
114+
------------------------
115+
calamity.part_test_4
116+
(1 row)
117+
118+
EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_test;
119+
QUERY PLAN
120+
-------------------------------
121+
Append
122+
-> Seq Scan on part_test_1
123+
-> Seq Scan on part_test_2
124+
-> Seq Scan on part_test_3
125+
-> Seq Scan on part_test_4
126+
(5 rows)
127+
128+
SELECT drop_partitions('calamity.part_test', true);
129+
NOTICE: function calamity.part_test_upd_trig_func() does not exist, skipping
130+
drop_partitions
131+
-----------------
132+
4
133+
(1 row)
134+
135+
DELETE FROM calamity.part_test;
15136
/* check function build_hash_condition() */
16137
SELECT build_hash_condition('int4', 'val', 10, 1);
17138
build_hash_condition
@@ -204,6 +325,9 @@ SELECT build_update_trigger_func_name(NULL) IS NULL;
204325
t
205326
(1 row)
206327

328+
/* check function stop_concurrent_part_task() */
329+
SELECT stop_concurrent_part_task(1::regclass);
330+
ERROR: cannot find worker for relation "1"
207331
/* check invoke_on_partition_created_callback() for RANGE */
208332
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1, NULL, NULL::int);
209333
ERROR: both bounds must be provided for RANGE partition
@@ -393,5 +517,5 @@ SELECT count(*) FROM pathman_config_params WHERE partrel = 'calamity.to_be_disab
393517
(1 row)
394518

395519
DROP SCHEMA calamity CASCADE;
396-
NOTICE: drop cascades to 15 other objects
520+
NOTICE: drop cascades to 16 other objects
397521
DROP EXTENSION pg_pathman;

sql/pathman_calamity.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,37 @@ set client_min_messages = NOTICE;
1414
CREATE TABLE calamity.part_test(val serial);
1515

1616

17+
/* test pg_pathman's cache */
18+
INSERT INTO calamity.part_test SELECT generate_series(1, 30);
19+
20+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
21+
SELECT drop_partitions('calamity.part_test');
22+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
23+
SELECT drop_partitions('calamity.part_test');
24+
25+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
26+
SELECT append_range_partition('calamity.part_test');
27+
SELECT drop_partitions('calamity.part_test');
28+
29+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
30+
SELECT append_range_partition('calamity.part_test');
31+
SELECT drop_partitions('calamity.part_test');
32+
33+
SELECT count(*) FROM calamity.part_test;
34+
35+
DELETE FROM calamity.part_test;
36+
37+
38+
/* test stub 'enable_parent' value for PATHMAN_CONFIG_PARAMS */
39+
INSERT INTO calamity.part_test SELECT generate_series(1, 30);
40+
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
41+
DELETE FROM pathman_config_params WHERE partrel = 'calamity.part_test'::regclass;
42+
SELECT append_range_partition('calamity.part_test');
43+
EXPLAIN (COSTS OFF) SELECT * FROM calamity.part_test;
44+
SELECT drop_partitions('calamity.part_test', true);
45+
DELETE FROM calamity.part_test;
46+
47+
1748
/* check function build_hash_condition() */
1849
SELECT build_hash_condition('int4', 'val', 10, 1);
1950
SELECT build_hash_condition('text', 'val', 10, 1);
@@ -71,6 +102,9 @@ SELECT build_update_trigger_name(NULL) IS NULL;
71102
SELECT build_update_trigger_func_name('calamity.part_test');
72103
SELECT build_update_trigger_func_name(NULL) IS NULL;
73104

105+
/* check function stop_concurrent_part_task() */
106+
SELECT stop_concurrent_part_task(1::regclass);
107+
74108
/* check invoke_on_partition_created_callback() for RANGE */
75109
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1, NULL, NULL::int);
76110
SELECT invoke_on_partition_created_callback('calamity.part_test', 'calamity.part_test', 1, 1, NULL);

0 commit comments

Comments
 (0)