Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb418ef

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_expressions. Update expression
on change of column type.
2 parentsb1d13fd +d464d97 commitdb418ef

22 files changed

+597
-125
lines changed

‎Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ REGRESS = pathman_basic \
3838
pathman_rowmarks\
3939
pathman_runtime_nodes\
4040
pathman_utility_stmt\
41-
pathman_calamity
41+
pathman_column_type\
42+
pathman_calamity\
43+
pathman_expressions
4244

4345
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
4446

‎README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![Build Status](https://travis-ci.org/postgrespro/pg_pathman.svg?branch=master)](https://travis-ci.org/postgrespro/pg_pathman)
22
[![PGXN version](https://badge.fury.io/pg/pg_pathman.svg)](https://badge.fury.io/pg/pg_pathman)
33
[![codecov](https://codecov.io/gh/postgrespro/pg_pathman/branch/master/graph/badge.svg)](https://codecov.io/gh/postgrespro/pg_pathman)
4+
[![GitHub license](https://img.shields.io/badge/license-PostgreSQL-blue.svg)](https://raw.githubusercontent.com/postgrespro/pg_pathman/master/LICENSE)
45

56
#pg_pathman
67

@@ -266,21 +267,21 @@ Set partition creation callback to be invoked for each attached or created parti
266267
```json
267268
/* RANGE-partitioned table abc (child abc_4) */
268269
{
269-
"parent":"abc",
270-
"parent_schema":"public",
271-
"parttype":"2",
272-
"partition":"abc_4",
270+
"parent":"abc",
271+
"parent_schema":"public",
272+
"parttype":"2",
273+
"partition":"abc_4",
273274
"partition_schema":"public",
274-
"range_max":"401",
275-
"range_min":"301"
275+
"range_max":"401",
276+
"range_min":"301"
276277
}
277278

278279
/* HASH-partitioned table abc (child abc_0) */
279280
{
280-
"parent":"abc",
281-
"parent_schema":"public",
282-
"parttype":"1",
283-
"partition":"abc_0"
281+
"parent":"abc",
282+
"parent_schema":"public",
283+
"parttype":"1",
284+
"partition":"abc_0",
284285
"partition_schema":"public"
285286
}
286287
```
@@ -309,7 +310,7 @@ CREATE TABLE IF NOT EXISTS pathman_config_params (
309310
enable_parentBOOLEANNOT NULL DEFAULT TRUE,
310311
autoBOOLEANNOT NULL DEFAULT TRUE,
311312
init_callback REGPROCEDURENOT NULL DEFAULT0,
312-
spawn_using_bgwBOOLEANNOT NULL DEFAULT FALSE);
313+
spawn_using_bgwBOOLEANNOT NULL DEFAULT FALSE);
313314
```
314315
This table stores optional parameters which override standard behavior.
315316

@@ -656,6 +657,7 @@ There are several user-accessible [GUC](https://www.postgresql.org/docs/9.5/stat
656657
-`pg_pathman.enable_runtimemergeappend` --- toggle`RuntimeMergeAppend` custom node on\off
657658
-`pg_pathman.enable_partitionfilter` --- toggle`PartitionFilter` custom node on\off
658659
-`pg_pathman.enable_auto_partition` --- toggle automatic partition creation on\off (per session)
660+
-`pg_pathman.enable_bounds_cache` --- toggle bounds cache on\off (faster updates of partitioning scheme)
659661
-`pg_pathman.insert_into_fdw` --- allow INSERTs into various FDWs`(disabled | postgres | any_fdw)`
660662
-`pg_pathman.override_copy` --- toggle COPY statement hooking on\off
661663

‎expected/pathman_basic.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,16 +1424,16 @@ INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
14241424
*/
14251425
ALTER TABLE test.range_rel DROP COLUMN data;
14261426
SELECT * FROM pathman.pathman_config;
1427-
partrel | attname | parttype | range_interval | expression_p | atttype
1428-
----------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------
1429-
test.range_rel | dt | 2 | @ 10 days | {VAR :varno 1 :varattno 2 :vartype 1114 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 2 :location 8} | 1114
1427+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
1428+
----------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------+----------
1429+
test.range_rel | dt | 2 | @ 10 days | {VAR :varno 1 :varattno 2 :vartype 1114 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 2 :location 8} | 1114 | f
14301430
(1 row)
14311431

14321432
DROP TABLE test.range_rel CASCADE;
14331433
NOTICE: drop cascades to 20 other objects
14341434
SELECT * FROM pathman.pathman_config;
1435-
partrel | attname | parttype | range_interval | expression_p | atttype
1436-
---------+---------+----------+----------------+--------------+---------
1435+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
1436+
---------+---------+----------+----------------+--------------+---------+----------
14371437
(0 rows)
14381438

14391439
/* Check overlaps */
@@ -1596,9 +1596,9 @@ SELECT pathman.create_partitions_from_range('test."RangeRel"', 'dt', '2015-01-01
15961596
DROP TABLE test."RangeRel" CASCADE;
15971597
NOTICE: drop cascades to 5 other objects
15981598
SELECT * FROM pathman.pathman_config;
1599-
partrel | attname | parttype | range_interval | expression_p | atttype
1600-
--------------------+---------+----------+----------------+------------------------------------------------------------------------------------------------------------------------+---------
1601-
test.num_range_rel | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 23
1599+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
1600+
--------------------+---------+----------+----------------+------------------------------------------------------------------------------------------------------------------------+---------+----------
1601+
test.num_range_rel | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 23 | f
16021602
(1 row)
16031603

16041604
CREATE TABLE test."RangeRel" (

‎expected/pathman_column_type.out

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
\set VERBOSITY terse
2+
SET search_path = 'public';
3+
CREATE EXTENSION pg_pathman;
4+
CREATE SCHEMA test_column_type;
5+
/*
6+
* RANGE partitioning.
7+
*/
8+
/* create new table (val int) */
9+
CREATE TABLE test_column_type.test(val INT4 NOT NULL);
10+
SELECT create_range_partitions('test_column_type.test', 'val', 1, 10, 10);
11+
NOTICE: sequence "test_seq" does not exist, skipping
12+
create_range_partitions
13+
-------------------------
14+
10
15+
(1 row)
16+
17+
/* make sure that bounds and dispatch info has been cached */
18+
SELECT * FROM test_column_type.test;
19+
val
20+
-----
21+
(0 rows)
22+
23+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
24+
context | entries
25+
--------------------------+---------
26+
maintenance | 0
27+
partition bounds cache | 10
28+
partition dispatch cache | 1
29+
partition parents cache | 10
30+
(4 rows)
31+
32+
/* change column's type (should flush caches) */
33+
ALTER TABLE test_column_type.test ALTER val TYPE NUMERIC;
34+
/* check that upd_expr is true */
35+
SELECT * FROM pathman_config;
36+
partrel | attname | parttype | range_interval | expression_p | atttype | upd_expr
37+
-----------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
38+
test_column_type.test | val | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23 | t
39+
(1 row)
40+
41+
/* make sure that everything works properly */
42+
SELECT * FROM test_column_type.test;
43+
val
44+
-----
45+
(0 rows)
46+
47+
/* check that expression, atttype is changed and upd_expr is false */
48+
SELECT * FROM pathman_config;
49+
partrel | attname | parttype | range_interval | expression_p | atttype | upd_expr
50+
-----------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------+----------
51+
test_column_type.test | val | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 1700 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1700 | f
52+
(1 row)
53+
54+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
55+
context | entries
56+
--------------------------+---------
57+
maintenance | 0
58+
partition bounds cache | 10
59+
partition dispatch cache | 1
60+
partition parents cache | 10
61+
(4 rows)
62+
63+
/* check insert dispatching */
64+
INSERT INTO test_column_type.test VALUES (1);
65+
SELECT tableoid::regclass, * FROM test_column_type.test;
66+
tableoid | val
67+
-------------------------+-----
68+
test_column_type.test_1 | 1
69+
(1 row)
70+
71+
SELECT drop_partitions('test_column_type.test');
72+
NOTICE: function test_column_type.test_upd_trig_func() does not exist, skipping
73+
NOTICE: 1 rows copied from test_column_type.test_1
74+
NOTICE: 0 rows copied from test_column_type.test_2
75+
NOTICE: 0 rows copied from test_column_type.test_3
76+
NOTICE: 0 rows copied from test_column_type.test_4
77+
NOTICE: 0 rows copied from test_column_type.test_5
78+
NOTICE: 0 rows copied from test_column_type.test_6
79+
NOTICE: 0 rows copied from test_column_type.test_7
80+
NOTICE: 0 rows copied from test_column_type.test_8
81+
NOTICE: 0 rows copied from test_column_type.test_9
82+
NOTICE: 0 rows copied from test_column_type.test_10
83+
drop_partitions
84+
-----------------
85+
10
86+
(1 row)
87+
88+
DROP TABLE test_column_type.test CASCADE;
89+
/*
90+
* HASH partitioning.
91+
*/
92+
/* create new table (id int, val int) */
93+
CREATE TABLE test_column_type.test(id INT4 NOT NULL, val INT4);
94+
SELECT create_hash_partitions('test_column_type.test', 'id', 5);
95+
create_hash_partitions
96+
------------------------
97+
5
98+
(1 row)
99+
100+
/* make sure that bounds and dispatch info has been cached */
101+
SELECT * FROM test_column_type.test;
102+
id | val
103+
----+-----
104+
(0 rows)
105+
106+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
107+
context | entries
108+
--------------------------+---------
109+
maintenance | 0
110+
partition bounds cache | 5
111+
partition dispatch cache | 1
112+
partition parents cache | 5
113+
(4 rows)
114+
115+
/* change column's type (should NOT work) */
116+
ALTER TABLE test_column_type.test ALTER id TYPE NUMERIC;
117+
ERROR: cannot change type of column "id" of table "test" partitioned by HASH
118+
/* make sure that everything works properly */
119+
SELECT * FROM test_column_type.test;
120+
id | val
121+
----+-----
122+
(0 rows)
123+
124+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
125+
context | entries
126+
--------------------------+---------
127+
maintenance | 0
128+
partition bounds cache | 5
129+
partition dispatch cache | 1
130+
partition parents cache | 5
131+
(4 rows)
132+
133+
/* change column's type (should flush caches) */
134+
ALTER TABLE test_column_type.test ALTER val TYPE NUMERIC;
135+
/* make sure that everything works properly */
136+
SELECT * FROM test_column_type.test;
137+
id | val
138+
----+-----
139+
(0 rows)
140+
141+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
142+
context | entries
143+
--------------------------+---------
144+
maintenance | 0
145+
partition bounds cache | 5
146+
partition dispatch cache | 1
147+
partition parents cache | 5
148+
(4 rows)
149+
150+
/* check insert dispatching */
151+
INSERT INTO test_column_type.test VALUES (1);
152+
SELECT tableoid::regclass, * FROM test_column_type.test;
153+
tableoid | id | val
154+
-------------------------+----+-----
155+
test_column_type.test_0 | 1 |
156+
(1 row)
157+
158+
SELECT drop_partitions('test_column_type.test');
159+
NOTICE: function test_column_type.test_upd_trig_func() does not exist, skipping
160+
NOTICE: 1 rows copied from test_column_type.test_0
161+
NOTICE: 0 rows copied from test_column_type.test_1
162+
NOTICE: 0 rows copied from test_column_type.test_2
163+
NOTICE: 0 rows copied from test_column_type.test_3
164+
NOTICE: 0 rows copied from test_column_type.test_4
165+
drop_partitions
166+
-----------------
167+
5
168+
(1 row)
169+
170+
DROP TABLE test_column_type.test CASCADE;
171+
DROP SCHEMA test_column_type CASCADE;
172+
NOTICE: drop cascades to sequence test_column_type.test_seq
173+
DROP EXTENSION pg_pathman;

‎expected/pathman_interval.out

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ SELECT set_interval('test_interval.abc', 1000);
3838

3939
INSERT INTO test_interval.abc VALUES (250);
4040
SELECT * FROM pathman_config;
41-
partrel | attname | parttype | range_interval | expression_p | atttype
42-
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
43-
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 21 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 21
41+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
42+
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
43+
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 21 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 21 | f
4444
(1 row)
4545

4646
DROP TABLE test_interval.abc CASCADE;
@@ -81,9 +81,9 @@ SELECT set_interval('test_interval.abc', 1000);
8181

8282
INSERT INTO test_interval.abc VALUES (250);
8383
SELECT * FROM pathman_config;
84-
partrel | attname | parttype | range_interval | expression_p | atttype
85-
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
86-
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23
84+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
85+
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
86+
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23 | f
8787
(1 row)
8888

8989
DROP TABLE test_interval.abc CASCADE;
@@ -124,9 +124,9 @@ SELECT set_interval('test_interval.abc', 1000);
124124

125125
INSERT INTO test_interval.abc VALUES (250);
126126
SELECT * FROM pathman_config;
127-
partrel | attname | parttype | range_interval | expression_p | atttype
128-
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
129-
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 20 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 20
127+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
128+
-------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
129+
test_interval.abc | id | 2 | 1000 | {VAR :varno 1 :varattno 1 :vartype 20 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 20 | f
130130
(1 row)
131131

132132
DROP TABLE test_interval.abc CASCADE;
@@ -157,9 +157,9 @@ SELECT set_interval('test_interval.abc', '1 month'::INTERVAL);
157157
(1 row)
158158

159159
SELECT * FROM pathman_config;
160-
partrel | attname | parttype | range_interval | expression_p | atttype
161-
-------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------
162-
test_interval.abc | dt | 2 | @ 1 mon | {VAR :varno 1 :varattno 1 :vartype 1082 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1082
160+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
161+
-------------------+---------+----------+----------------+-------------------------------------------------------------------------------------------------------------------------+---------+----------
162+
test_interval.abc | dt | 2 | @ 1 mon | {VAR :varno 1 :varattno 1 :vartype 1082 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 1082 | f
163163
(1 row)
164164

165165
DROP TABLE test_interval.abc CASCADE;

‎expected/pathman_permissions.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ NOTICE: sequence "user1_table_seq" does not exist, skipping
3232
/* Should be able to see */
3333
SET ROLE user2;
3434
SELECT * FROM pathman_config;
35-
partrel | attname | parttype | range_interval | expression_p | atttype
36-
-------------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------
37-
permissions.user1_table | id | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23
35+
partrel | attname | parttype | range_interval | expression_p | atttype| upd_expr
36+
-------------------------+---------+----------+----------------+-----------------------------------------------------------------------------------------------------------------------+---------+----------
37+
permissions.user1_table | id | 2 | 10 | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location 8} | 23 | f
3838
(1 row)
3939

4040
SELECT * FROM pathman_config_params;

‎hash.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
CREATEOR REPLACE FUNCTION @extschema@.create_hash_partitions(
1515
parent_relidREGCLASS,
1616
expressionTEXT,
17-
partitions_countINTEGER,
17+
partitions_countINT4,
1818
partition_dataBOOLEAN DEFAULT TRUE,
1919
partition_namesTEXT[] DEFAULTNULL,
2020
tablespacesTEXT[] DEFAULTNULL)
@@ -279,7 +279,7 @@ $$ LANGUAGE plpgsql;
279279
CREATEOR REPLACE FUNCTION @extschema@.create_hash_partitions_internal(
280280
parent_relidREGCLASS,
281281
attributeTEXT,
282-
partitions_countINTEGER,
282+
partitions_countINT4,
283283
partition_namesTEXT[] DEFAULTNULL,
284284
tablespacesTEXT[] DEFAULTNULL)
285285
RETURNS VOIDAS'pg_pathman','create_hash_partitions_internal'
@@ -295,6 +295,6 @@ LANGUAGE C STRICT;
295295
/*
296296
* Calculates hash for integer value
297297
*/
298-
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INTEGER,INTEGER)
298+
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INT4, INT4)
299299
RETURNSINTEGERAS'pg_pathman','get_hash_part_idx'
300300
LANGUAGE C STRICT;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp