Skip to content

Commit 88f3130

Browse files
committed
add regression tests for function create_range_partitions (bounds array)
1 parent 1df43cb commit 88f3130

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

expected/pathman_basic.out

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,77 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.improved_dummy WHERE id = 101 OR id = 5 A
261261

262262
DROP TABLE test.improved_dummy CASCADE;
263263
NOTICE: drop cascades to 11 other objects
264+
/* since rel_1_4_beta: check create_range_partitions(bounds array) */
265+
CREATE TABLE test.improved_dummy (val INT NOT NULL);
266+
SELECT pathman.create_range_partitions('test.improved_dummy', 'val',
267+
pathman.generate_range_bounds(1, 1, 2));
268+
create_range_partitions
269+
-------------------------
270+
2
271+
(1 row)
272+
273+
SELECT * FROM pathman.pathman_partition_list
274+
WHERE parent = 'test.improved_dummy'::REGCLASS
275+
ORDER BY partition;
276+
parent | partition | parttype | partattr | range_min | range_max
277+
---------------------+-----------------------+----------+----------+-----------+-----------
278+
test.improved_dummy | test.improved_dummy_1 | 2 | val | 1 | 2
279+
test.improved_dummy | test.improved_dummy_2 | 2 | val | 2 | 3
280+
(2 rows)
281+
282+
SELECT pathman.drop_partitions('test.improved_dummy');
283+
NOTICE: 0 rows copied from test.improved_dummy_1
284+
NOTICE: 0 rows copied from test.improved_dummy_2
285+
drop_partitions
286+
-----------------
287+
2
288+
(1 row)
289+
290+
SELECT pathman.create_range_partitions('test.improved_dummy', 'val',
291+
pathman.generate_range_bounds(1, 1, 2),
292+
partition_names := '{p1, p2}');
293+
create_range_partitions
294+
-------------------------
295+
2
296+
(1 row)
297+
298+
SELECT * FROM pathman.pathman_partition_list
299+
WHERE parent = 'test.improved_dummy'::REGCLASS
300+
ORDER BY partition;
301+
parent | partition | parttype | partattr | range_min | range_max
302+
---------------------+-----------+----------+----------+-----------+-----------
303+
test.improved_dummy | p1 | 2 | val | 1 | 2
304+
test.improved_dummy | p2 | 2 | val | 2 | 3
305+
(2 rows)
306+
307+
SELECT pathman.drop_partitions('test.improved_dummy');
308+
NOTICE: 0 rows copied from p1
309+
NOTICE: 0 rows copied from p2
310+
drop_partitions
311+
-----------------
312+
2
313+
(1 row)
314+
315+
SELECT pathman.create_range_partitions('test.improved_dummy', 'val',
316+
pathman.generate_range_bounds(1, 1, 2),
317+
partition_names := '{p1, p2}',
318+
tablespaces := '{pg_default, pg_default}');
319+
create_range_partitions
320+
-------------------------
321+
2
322+
(1 row)
323+
324+
SELECT * FROM pathman.pathman_partition_list
325+
WHERE parent = 'test.improved_dummy'::REGCLASS
326+
ORDER BY partition;
327+
parent | partition | parttype | partattr | range_min | range_max
328+
---------------------+-----------+----------+----------+-----------+-----------
329+
test.improved_dummy | p1 | 2 | val | 1 | 2
330+
test.improved_dummy | p2 | 2 | val | 2 | 3
331+
(2 rows)
332+
333+
DROP TABLE test.improved_dummy CASCADE;
334+
NOTICE: drop cascades to 2 other objects
264335
/* Test pathman_rel_pathlist_hook() with INSERT query */
265336
CREATE TABLE test.insert_into_select(val int NOT NULL);
266337
INSERT INTO test.insert_into_select SELECT generate_series(1, 100);

sql/pathman_basic.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.improved_dummy WHERE id = 101 OR id = 5 A
7878
DROP TABLE test.improved_dummy CASCADE;
7979

8080

81+
/* since rel_1_4_beta: check create_range_partitions(bounds array) */
82+
CREATE TABLE test.improved_dummy (val INT NOT NULL);
83+
84+
SELECT pathman.create_range_partitions('test.improved_dummy', 'val',
85+
pathman.generate_range_bounds(1, 1, 2));
86+
87+
SELECT * FROM pathman.pathman_partition_list
88+
WHERE parent = 'test.improved_dummy'::REGCLASS
89+
ORDER BY partition;
90+
91+
SELECT pathman.drop_partitions('test.improved_dummy');
92+
93+
SELECT pathman.create_range_partitions('test.improved_dummy', 'val',
94+
pathman.generate_range_bounds(1, 1, 2),
95+
partition_names := '{p1, p2}');
96+
97+
SELECT * FROM pathman.pathman_partition_list
98+
WHERE parent = 'test.improved_dummy'::REGCLASS
99+
ORDER BY partition;
100+
101+
SELECT pathman.drop_partitions('test.improved_dummy');
102+
103+
SELECT pathman.create_range_partitions('test.improved_dummy', 'val',
104+
pathman.generate_range_bounds(1, 1, 2),
105+
partition_names := '{p1, p2}',
106+
tablespaces := '{pg_default, pg_default}');
107+
108+
SELECT * FROM pathman.pathman_partition_list
109+
WHERE parent = 'test.improved_dummy'::REGCLASS
110+
ORDER BY partition;
111+
112+
DROP TABLE test.improved_dummy CASCADE;
113+
114+
81115
/* Test pathman_rel_pathlist_hook() with INSERT query */
82116
CREATE TABLE test.insert_into_select(val int NOT NULL);
83117
INSERT INTO test.insert_into_select SELECT generate_series(1, 100);

0 commit comments

Comments
 (0)