Skip to content

Commit 8135456

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_update_node
2 parents ea1a91d + 82507b6 commit 8135456

40 files changed

+1260
-1045
lines changed

META.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "pg_pathman",
3+
"abstract": "Partitioning tool",
4+
"description": "The `pg_pathman` module provides optimized partitioning mechanism and functions to manage partitions.",
5+
"version": "1.3.1",
6+
"maintainer": [
7+
"Ildar Musin <i.musin@postgrespro.ru>",
8+
"Dmitry Ivanov <d.ivanov@postgrespro.ru>",
9+
"Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>"
10+
],
11+
"license": "postgresql",
12+
"resources": {
13+
"bugtracker": {
14+
"web": "https://github.com/postgrespro/pg_pathman/issues"
15+
},
16+
"repository": {
17+
"url": "git://github.com:postgrespro/pg_pathman.git",
18+
"web": "https://github.com/postgrespro/pg_pathman",
19+
"type": "git"
20+
}
21+
},
22+
"generated_by": "Ildar Musin",
23+
"provides": {
24+
"pg_pathman": {
25+
"file": "pg_pathman--1.3.sql",
26+
"docfile": "README.md",
27+
"version": "1.3.1",
28+
"abstract": "Partitioning tool"
29+
}
30+
},
31+
"meta-spec": {
32+
"version": "1.0.0",
33+
"url": "http://pgxn.org/meta/spec.txt"
34+
},
35+
"tags": [
36+
"partitioning",
37+
"partition",
38+
"optimization"
39+
]
40+
}

expected/pathman_basic.out

+223-60
Large diffs are not rendered by default.

expected/pathman_bgw.out

+24-29
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ CREATE SCHEMA test_bgw;
88
/* int4, size of Datum == 4 */
99
CREATE TABLE test_bgw.test_1(val INT4 NOT NULL);
1010
SELECT create_range_partitions('test_bgw.test_1', 'val', 1, 5, 2);
11-
NOTICE: sequence "test_1_seq" does not exist, skipping
1211
create_range_partitions
1312
-------------------------
1413
2
@@ -22,19 +21,18 @@ SELECT set_spawn_using_bgw('test_bgw.test_1', true);
2221

2322
INSERT INTO test_bgw.test_1 VALUES (11);
2423
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
25-
parent | partition | parttype | partattr | range_min | range_max
26-
-----------------+-------------------+----------+----------+-----------+-----------
27-
test_bgw.test_1 | test_bgw.test_1_1 | 2 | val | 1 | 6
28-
test_bgw.test_1 | test_bgw.test_1_2 | 2 | val | 6 | 11
29-
test_bgw.test_1 | test_bgw.test_1_3 | 2 | val | 11 | 16
24+
parent | partition | parttype | expr | range_min | range_max
25+
-----------------+-------------------+----------+------+-----------+-----------
26+
test_bgw.test_1 | test_bgw.test_1_1 | 2 | val | 1 | 6
27+
test_bgw.test_1 | test_bgw.test_1_2 | 2 | val | 6 | 11
28+
test_bgw.test_1 | test_bgw.test_1_3 | 2 | val | 11 | 16
3029
(3 rows)
3130

3231
DROP TABLE test_bgw.test_1 CASCADE;
33-
NOTICE: drop cascades to 3 other objects
32+
NOTICE: drop cascades to 4 other objects
3433
/* int8, size of Datum == 8 */
3534
CREATE TABLE test_bgw.test_2(val INT8 NOT NULL);
3635
SELECT create_range_partitions('test_bgw.test_2', 'val', 1, 5, 2);
37-
NOTICE: sequence "test_2_seq" does not exist, skipping
3836
create_range_partitions
3937
-------------------------
4038
2
@@ -48,19 +46,18 @@ SELECT set_spawn_using_bgw('test_bgw.test_2', true);
4846

4947
INSERT INTO test_bgw.test_2 VALUES (11);
5048
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
51-
parent | partition | parttype | partattr | range_min | range_max
52-
-----------------+-------------------+----------+----------+-----------+-----------
53-
test_bgw.test_2 | test_bgw.test_2_1 | 2 | val | 1 | 6
54-
test_bgw.test_2 | test_bgw.test_2_2 | 2 | val | 6 | 11
55-
test_bgw.test_2 | test_bgw.test_2_3 | 2 | val | 11 | 16
49+
parent | partition | parttype | expr | range_min | range_max
50+
-----------------+-------------------+----------+------+-----------+-----------
51+
test_bgw.test_2 | test_bgw.test_2_1 | 2 | val | 1 | 6
52+
test_bgw.test_2 | test_bgw.test_2_2 | 2 | val | 6 | 11
53+
test_bgw.test_2 | test_bgw.test_2_3 | 2 | val | 11 | 16
5654
(3 rows)
5755

5856
DROP TABLE test_bgw.test_2 CASCADE;
59-
NOTICE: drop cascades to 3 other objects
57+
NOTICE: drop cascades to 4 other objects
6058
/* numeric, size of Datum == var */
6159
CREATE TABLE test_bgw.test_3(val NUMERIC NOT NULL);
6260
SELECT create_range_partitions('test_bgw.test_3', 'val', 1, 5, 2);
63-
NOTICE: sequence "test_3_seq" does not exist, skipping
6461
create_range_partitions
6562
-------------------------
6663
2
@@ -74,19 +71,18 @@ SELECT set_spawn_using_bgw('test_bgw.test_3', true);
7471

7572
INSERT INTO test_bgw.test_3 VALUES (11);
7673
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
77-
parent | partition | parttype | partattr | range_min | range_max
78-
-----------------+-------------------+----------+----------+-----------+-----------
79-
test_bgw.test_3 | test_bgw.test_3_1 | 2 | val | 1 | 6
80-
test_bgw.test_3 | test_bgw.test_3_2 | 2 | val | 6 | 11
81-
test_bgw.test_3 | test_bgw.test_3_3 | 2 | val | 11 | 16
74+
parent | partition | parttype | expr | range_min | range_max
75+
-----------------+-------------------+----------+------+-----------+-----------
76+
test_bgw.test_3 | test_bgw.test_3_1 | 2 | val | 1 | 6
77+
test_bgw.test_3 | test_bgw.test_3_2 | 2 | val | 6 | 11
78+
test_bgw.test_3 | test_bgw.test_3_3 | 2 | val | 11 | 16
8279
(3 rows)
8380

8481
DROP TABLE test_bgw.test_3 CASCADE;
85-
NOTICE: drop cascades to 3 other objects
82+
NOTICE: drop cascades to 4 other objects
8683
/* date, size of Datum == var */
8784
CREATE TABLE test_bgw.test_4(val DATE NOT NULL);
8885
SELECT create_range_partitions('test_bgw.test_4', 'val', '20170213'::date, '1 day'::interval, 2);
89-
NOTICE: sequence "test_4_seq" does not exist, skipping
9086
create_range_partitions
9187
-------------------------
9288
2
@@ -100,15 +96,14 @@ SELECT set_spawn_using_bgw('test_bgw.test_4', true);
10096

10197
INSERT INTO test_bgw.test_4 VALUES ('20170215');
10298
SELECT * FROM pathman_partition_list ORDER BY partition; /* should contain 3 partitions */
103-
parent | partition | parttype | partattr | range_min | range_max
104-
-----------------+-------------------+----------+----------+------------+------------
105-
test_bgw.test_4 | test_bgw.test_4_1 | 2 | val | 02-13-2017 | 02-14-2017
106-
test_bgw.test_4 | test_bgw.test_4_2 | 2 | val | 02-14-2017 | 02-15-2017
107-
test_bgw.test_4 | test_bgw.test_4_3 | 2 | val | 02-15-2017 | 02-16-2017
99+
parent | partition | parttype | expr | range_min | range_max
100+
-----------------+-------------------+----------+------+------------+------------
101+
test_bgw.test_4 | test_bgw.test_4_1 | 2 | val | 02-13-2017 | 02-14-2017
102+
test_bgw.test_4 | test_bgw.test_4_2 | 2 | val | 02-14-2017 | 02-15-2017
103+
test_bgw.test_4 | test_bgw.test_4_3 | 2 | val | 02-15-2017 | 02-16-2017
108104
(3 rows)
109105

110106
DROP TABLE test_bgw.test_4 CASCADE;
111-
NOTICE: drop cascades to 3 other objects
112-
DROP SCHEMA test_bgw CASCADE;
113107
NOTICE: drop cascades to 4 other objects
108+
DROP SCHEMA test_bgw CASCADE;
114109
DROP EXTENSION pg_pathman;

expected/pathman_calamity.out

+88-23
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ CREATE TABLE calamity.part_test(val serial);
2121
/* test pg_pathman's cache */
2222
INSERT INTO calamity.part_test SELECT generate_series(1, 30);
2323
SELECT create_range_partitions('calamity.part_test', 'val', 1, 10);
24-
NOTICE: sequence "part_test_seq" does not exist, skipping
2524
create_range_partitions
2625
-------------------------
2726
3
@@ -270,19 +269,21 @@ SELECT build_range_condition('calamity.part_test', 'val', NULL, 10); /* OK */
270269
(1 row)
271270

272271
/* check function validate_interval_value() */
273-
SELECT validate_interval_value(1::REGCLASS, 'expr', 2, '1 mon', 'cooked_expr'); /* not ok */
272+
SELECT validate_interval_value(1::REGCLASS, 'expr', 2, '1 mon', 'cooked_expr'); /* not ok */
274273
ERROR: relation "1" does not exist
275-
SELECT validate_interval_value(NULL, 'expr', 2, '1 mon', 'cooked_expr'); /* not ok */
274+
SELECT validate_interval_value(NULL, 'expr', 2, '1 mon', 'cooked_expr'); /* not ok */
276275
ERROR: 'partrel' should not be NULL
277-
SELECT validate_interval_value('pg_class', NULL, 2, '1 mon', 'cooked_expr'); /* not ok */
276+
SELECT validate_interval_value('pg_class', NULL, 2, '1 mon', 'cooked_expr'); /* not ok */
278277
ERROR: 'expression' should not be NULL
279-
SELECT validate_interval_value('pg_class', 'oid', 1, 'HASH', NULL); /* not ok */
278+
SELECT validate_interval_value('pg_class', 'oid', NULL, '1 mon', 'cooked_expr'); /* not ok */
279+
ERROR: 'parttype' should not be NULL
280+
SELECT validate_interval_value('pg_class', 'oid', 1, 'HASH', NULL); /* not ok */
280281
ERROR: interval should be NULL for HASH partitioned table
281-
SELECT validate_interval_value('pg_class', 'expr', 2, '1 mon', NULL); /* not ok */
282+
SELECT validate_interval_value('pg_class', 'expr', 2, '1 mon', NULL); /* not ok */
282283
ERROR: cannot find type name for attribute "expr" of relation "pg_class"
283-
SELECT validate_interval_value('pg_class', 'expr', 2, NULL, 'cooked_expr'); /* not ok */
284+
SELECT validate_interval_value('pg_class', 'expr', 2, NULL, 'cooked_expr'); /* not ok */
284285
ERROR: unrecognized token: "cooked_expr"
285-
SELECT validate_interval_value('pg_class', 'EXPR', 1, 'HASH', NULL); /* not ok */
286+
SELECT validate_interval_value('pg_class', 'EXPR', 1, 'HASH', NULL); /* not ok */
286287
ERROR: cannot find type name for attribute "expr" of relation "pg_class"
287288
/* check function validate_relname() */
288289
SELECT validate_relname('calamity.part_test');
@@ -471,7 +472,7 @@ SELECT generate_range_bounds('1-jan-2017'::DATE,
471472
SELECT check_range_available(NULL, NULL::INT4, NULL); /* not ok */
472473
ERROR: 'parent_relid' should not be NULL
473474
SELECT check_range_available('pg_class', 1, 10); /* OK (not partitioned) */
474-
WARNING: relation "pg_class" is not partitioned
475+
WARNING: table "pg_class" is not partitioned
475476
check_range_available
476477
-----------------------
477478

@@ -702,7 +703,6 @@ SELECT count(*) FROM pathman_config_params WHERE partrel = 'calamity.to_be_disab
702703
/* check function get_part_range_by_idx() */
703704
CREATE TABLE calamity.test_range_idx(val INT4 NOT NULL);
704705
SELECT create_range_partitions('calamity.test_range_idx', 'val', 1, 10, 1);
705-
NOTICE: sequence "test_range_idx_seq" does not exist, skipping
706706
create_range_partitions
707707
-------------------------
708708
1
@@ -725,11 +725,10 @@ SELECT get_part_range('calamity.test_range_idx', 0, NULL::INT4); /* OK */
725725
(1 row)
726726

727727
DROP TABLE calamity.test_range_idx CASCADE;
728-
NOTICE: drop cascades to table calamity.test_range_idx_1
728+
NOTICE: drop cascades to 2 other objects
729729
/* check function get_part_range_by_oid() */
730730
CREATE TABLE calamity.test_range_oid(val INT4 NOT NULL);
731731
SELECT create_range_partitions('calamity.test_range_oid', 'val', 1, 10, 1);
732-
NOTICE: sequence "test_range_oid_seq" does not exist, skipping
733732
create_range_partitions
734733
-------------------------
735734
1
@@ -748,9 +747,79 @@ SELECT get_part_range('calamity.test_range_oid_1', NULL::INT4); /* OK */
748747
(1 row)
749748

750749
DROP TABLE calamity.test_range_oid CASCADE;
751-
NOTICE: drop cascades to table calamity.test_range_oid_1
750+
NOTICE: drop cascades to 2 other objects
751+
/* check function merge_range_partitions() */
752+
SELECT merge_range_partitions('{pg_class}'); /* not ok */
753+
ERROR: cannot merge partitions
754+
SELECT merge_range_partitions('{pg_class, pg_inherits}'); /* not ok */
755+
ERROR: cannot merge partitions
756+
CREATE TABLE calamity.merge_test_a(val INT4 NOT NULL);
757+
CREATE TABLE calamity.merge_test_b(val INT4 NOT NULL);
758+
SELECT create_range_partitions('calamity.merge_test_a', 'val', 1, 10, 2);
759+
create_range_partitions
760+
-------------------------
761+
2
762+
(1 row)
763+
764+
SELECT create_range_partitions('calamity.merge_test_b', 'val', 1, 10, 2);
765+
create_range_partitions
766+
-------------------------
767+
2
768+
(1 row)
769+
770+
SELECT merge_range_partitions('{calamity.merge_test_a_1,
771+
calamity.merge_test_b_1}'); /* not ok */
772+
ERROR: cannot merge partitions
773+
DROP TABLE calamity.merge_test_a,calamity.merge_test_b CASCADE;
774+
NOTICE: drop cascades to 6 other objects
775+
/* check function drop_triggers() */
776+
CREATE TABLE calamity.trig_test_tbl(val INT4 NOT NULL);
777+
SELECT create_hash_partitions('calamity.trig_test_tbl', 'val', 2);
778+
create_hash_partitions
779+
------------------------
780+
2
781+
(1 row)
782+
783+
SELECT create_update_triggers('calamity.trig_test_tbl');
784+
create_update_triggers
785+
------------------------
786+
787+
(1 row)
788+
789+
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl'::REGCLASS;
790+
count
791+
-------
792+
1
793+
(1 row)
794+
795+
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl_1'::REGCLASS;
796+
count
797+
-------
798+
1
799+
(1 row)
800+
801+
SELECT drop_triggers('calamity.trig_test_tbl'); /* OK */
802+
drop_triggers
803+
---------------
804+
805+
(1 row)
806+
807+
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl'::REGCLASS;
808+
count
809+
-------
810+
0
811+
(1 row)
812+
813+
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'calamity.trig_test_tbl_1'::REGCLASS;
814+
count
815+
-------
816+
0
817+
(1 row)
818+
819+
DROP TABLE calamity.trig_test_tbl CASCADE;
820+
NOTICE: drop cascades to 2 other objects
752821
DROP SCHEMA calamity CASCADE;
753-
NOTICE: drop cascades to 18 other objects
822+
NOTICE: drop cascades to 15 other objects
754823
DROP EXTENSION pg_pathman;
755824
/*
756825
* -------------------------------------
@@ -764,7 +833,6 @@ SET pg_pathman.enable_bounds_cache = false;
764833
/* check view pathman_cache_stats */
765834
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
766835
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
767-
NOTICE: sequence "test_pathman_cache_stats_seq" does not exist, skipping
768836
create_range_partitions
769837
-------------------------
770838
10
@@ -851,7 +919,6 @@ SELECT context, entries FROM pathman_cache_stats ORDER BY context; /* OK */
851919

852920
DROP TABLE calamity.test_pathman_cache_stats;
853921
DROP SCHEMA calamity CASCADE;
854-
NOTICE: drop cascades to sequence calamity.test_pathman_cache_stats_seq
855922
DROP EXTENSION pg_pathman;
856923
/*
857924
* ------------------------------------------
@@ -863,7 +930,6 @@ CREATE EXTENSION pg_pathman;
863930
/* check function pathman_cache_search_relid() */
864931
CREATE TABLE calamity.survivor(val INT NOT NULL);
865932
SELECT create_range_partitions('calamity.survivor', 'val', 1, 10, 2);
866-
NOTICE: sequence "survivor_seq" does not exist, skipping
867933
create_range_partitions
868934
-------------------------
869935
2
@@ -903,10 +969,10 @@ SELECT add_to_pathman_config('calamity.survivor', 'val', '10'); /* OK */
903969
(1 row)
904970

905971
SELECT * FROM pathman_partition_list; /* OK */
906-
parent | partition | parttype | partattr | range_min | range_max
907-
-------------------+---------------------+----------+----------+-----------+-----------
908-
calamity.survivor | calamity.survivor_1 | 2 | val | 1 | 11
909-
calamity.survivor | calamity.survivor_2 | 2 | val | 11 | 21
972+
parent | partition | parttype | expr | range_min | range_max
973+
-------------------+---------------------+----------+------+-----------+-----------
974+
calamity.survivor | calamity.survivor_1 | 2 | val | 1 | 11
975+
calamity.survivor | calamity.survivor_2 | 2 | val | 11 | 21
910976
(2 rows)
911977

912978
SELECT get_part_range('calamity.survivor', 0, NULL::INT); /* OK */
@@ -924,7 +990,6 @@ EXPLAIN (COSTS OFF) SELECT * FROM calamity.survivor; /* OK */
924990
(3 rows)
925991

926992
DROP TABLE calamity.survivor CASCADE;
927-
NOTICE: drop cascades to 2 other objects
993+
NOTICE: drop cascades to 3 other objects
928994
DROP SCHEMA calamity CASCADE;
929-
NOTICE: drop cascades to sequence calamity.survivor_seq
930995
DROP EXTENSION pg_pathman;

0 commit comments

Comments
 (0)