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

Commitde97834

Browse files
committed
Merge branch 'rel_future_beta' of github.com:postgrespro/pg_pathman into rel_future_beta
2 parentse0ea7b9 +69028ca commitde97834

13 files changed

+406
-63
lines changed

‎Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ REGRESS = pathman_basic \
3838
pathman_rowmarks\
3939
pathman_runtime_nodes\
4040
pathman_utility_stmt\
41+
pathman_column_type\
4142
pathman_calamity
4243

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

‎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_column_type.out

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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+
/* make sure that everything works properly */
35+
SELECT * FROM test_column_type.test;
36+
val
37+
-----
38+
(0 rows)
39+
40+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
41+
context | entries
42+
--------------------------+---------
43+
maintenance | 0
44+
partition bounds cache | 10
45+
partition dispatch cache | 1
46+
partition parents cache | 10
47+
(4 rows)
48+
49+
/* check insert dispatching */
50+
INSERT INTO test_column_type.test VALUES (1);
51+
SELECT tableoid::regclass, * FROM test_column_type.test;
52+
tableoid | val
53+
-------------------------+-----
54+
test_column_type.test_1 | 1
55+
(1 row)
56+
57+
SELECT drop_partitions('test_column_type.test');
58+
NOTICE: function test_column_type.test_upd_trig_func() does not exist, skipping
59+
NOTICE: 1 rows copied from test_column_type.test_1
60+
NOTICE: 0 rows copied from test_column_type.test_2
61+
NOTICE: 0 rows copied from test_column_type.test_3
62+
NOTICE: 0 rows copied from test_column_type.test_4
63+
NOTICE: 0 rows copied from test_column_type.test_5
64+
NOTICE: 0 rows copied from test_column_type.test_6
65+
NOTICE: 0 rows copied from test_column_type.test_7
66+
NOTICE: 0 rows copied from test_column_type.test_8
67+
NOTICE: 0 rows copied from test_column_type.test_9
68+
NOTICE: 0 rows copied from test_column_type.test_10
69+
drop_partitions
70+
-----------------
71+
10
72+
(1 row)
73+
74+
DROP TABLE test_column_type.test CASCADE;
75+
/*
76+
* HASH partitioning.
77+
*/
78+
/* create new table (id int, val int) */
79+
CREATE TABLE test_column_type.test(id INT4 NOT NULL, val INT4);
80+
SELECT create_hash_partitions('test_column_type.test', 'id', 5);
81+
create_hash_partitions
82+
------------------------
83+
5
84+
(1 row)
85+
86+
/* make sure that bounds and dispatch info has been cached */
87+
SELECT * FROM test_column_type.test;
88+
id | val
89+
----+-----
90+
(0 rows)
91+
92+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
93+
context | entries
94+
--------------------------+---------
95+
maintenance | 0
96+
partition bounds cache | 5
97+
partition dispatch cache | 1
98+
partition parents cache | 5
99+
(4 rows)
100+
101+
/* change column's type (should NOT work) */
102+
ALTER TABLE test_column_type.test ALTER id TYPE NUMERIC;
103+
ERROR: cannot change type of column "id" of table "test" partitioned by HASH
104+
/* make sure that everything works properly */
105+
SELECT * FROM test_column_type.test;
106+
id | val
107+
----+-----
108+
(0 rows)
109+
110+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
111+
context | entries
112+
--------------------------+---------
113+
maintenance | 0
114+
partition bounds cache | 5
115+
partition dispatch cache | 1
116+
partition parents cache | 5
117+
(4 rows)
118+
119+
/* change column's type (should flush caches) */
120+
ALTER TABLE test_column_type.test ALTER val TYPE NUMERIC;
121+
/* make sure that everything works properly */
122+
SELECT * FROM test_column_type.test;
123+
id | val
124+
----+-----
125+
(0 rows)
126+
127+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;
128+
context | entries
129+
--------------------------+---------
130+
maintenance | 0
131+
partition bounds cache | 5
132+
partition dispatch cache | 1
133+
partition parents cache | 5
134+
(4 rows)
135+
136+
/* check insert dispatching */
137+
INSERT INTO test_column_type.test VALUES (1);
138+
SELECT tableoid::regclass, * FROM test_column_type.test;
139+
tableoid | id | val
140+
-------------------------+----+-----
141+
test_column_type.test_0 | 1 |
142+
(1 row)
143+
144+
SELECT drop_partitions('test_column_type.test');
145+
NOTICE: function test_column_type.test_upd_trig_func() does not exist, skipping
146+
NOTICE: 1 rows copied from test_column_type.test_0
147+
NOTICE: 0 rows copied from test_column_type.test_1
148+
NOTICE: 0 rows copied from test_column_type.test_2
149+
NOTICE: 0 rows copied from test_column_type.test_3
150+
NOTICE: 0 rows copied from test_column_type.test_4
151+
drop_partitions
152+
-----------------
153+
5
154+
(1 row)
155+
156+
DROP TABLE test_column_type.test CASCADE;
157+
DROP SCHEMA test_column_type CASCADE;
158+
NOTICE: drop cascades to sequence test_column_type.test_seq
159+
DROP EXTENSION pg_pathman;

‎hash.sql

Lines changed: 4 additions & 4 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
attributeTEXT,
17-
partitions_countINTEGER,
17+
partitions_countINT4,
1818
partition_dataBOOLEAN DEFAULT TRUE,
1919
partition_namesTEXT[] DEFAULTNULL,
2020
tablespacesTEXT[] DEFAULTNULL)
@@ -280,7 +280,7 @@ $$ LANGUAGE plpgsql;
280280
CREATEOR REPLACE FUNCTION @extschema@.create_hash_partitions_internal(
281281
parent_relidREGCLASS,
282282
attributeTEXT,
283-
partitions_countINTEGER,
283+
partitions_countINT4,
284284
partition_namesTEXT[] DEFAULTNULL,
285285
tablespacesTEXT[] DEFAULTNULL)
286286
RETURNS VOIDAS'pg_pathman','create_hash_partitions_internal'
@@ -296,7 +296,7 @@ LANGUAGE C STRICT;
296296
/*
297297
* Calculates hash for integer value
298298
*/
299-
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INTEGER,INTEGER)
299+
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INT4, INT4)
300300
RETURNSINTEGERAS'pg_pathman','get_hash_part_idx'
301301
LANGUAGE C STRICT;
302302

@@ -307,6 +307,6 @@ CREATE OR REPLACE FUNCTION @extschema@.build_hash_condition(
307307
attribute_typeREGTYPE,
308308
attributeTEXT,
309309
partitions_countINT4,
310-
partitions_indexINT4)
310+
partition_indexINT4)
311311
RETURNSTEXTAS'pg_pathman','build_hash_condition'
312312
LANGUAGE C STRICT;

‎pg_pathman.control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# pg_pathman extension
2-
comment 'Partitioning tool'
2+
comment='Partitioning tool for PostgreSQL'
33
default_version = '1.3'
4-
module_pathname='$libdir/pg_pathman'
4+
module_pathname ='$libdir/pg_pathman'

‎sql/pathman_column_type.sql

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
\set VERBOSITY terse
2+
3+
SET search_path='public';
4+
CREATE EXTENSION pg_pathman;
5+
CREATESCHEMAtest_column_type;
6+
7+
8+
/*
9+
* RANGE partitioning.
10+
*/
11+
12+
/* create new table (val int)*/
13+
CREATETABLEtest_column_type.test(val INT4NOT NULL);
14+
SELECT create_range_partitions('test_column_type.test','val',1,10,10);
15+
16+
/* make sure that bounds and dispatch info has been cached*/
17+
SELECT*FROMtest_column_type.test;
18+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;
19+
20+
/* change column's type (should flush caches)*/
21+
ALTERTABLEtest_column_type.test ALTER val TYPENUMERIC;
22+
23+
/* make sure that everything works properly*/
24+
SELECT*FROMtest_column_type.test;
25+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;
26+
27+
/* check insert dispatching*/
28+
INSERT INTOtest_column_type.testVALUES (1);
29+
SELECT tableoid::regclass,*FROMtest_column_type.test;
30+
31+
SELECT drop_partitions('test_column_type.test');
32+
DROPTABLEtest_column_type.test CASCADE;
33+
34+
35+
/*
36+
* HASH partitioning.
37+
*/
38+
39+
/* create new table (id int, val int)*/
40+
CREATETABLEtest_column_type.test(id INT4NOT NULL, val INT4);
41+
SELECT create_hash_partitions('test_column_type.test','id',5);
42+
43+
/* make sure that bounds and dispatch info has been cached*/
44+
SELECT*FROMtest_column_type.test;
45+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;
46+
47+
/* change column's type (should NOT work)*/
48+
ALTERTABLEtest_column_type.test ALTER id TYPENUMERIC;
49+
50+
/* make sure that everything works properly*/
51+
SELECT*FROMtest_column_type.test;
52+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;
53+
54+
/* change column's type (should flush caches)*/
55+
ALTERTABLEtest_column_type.test ALTER val TYPENUMERIC;
56+
57+
/* make sure that everything works properly*/
58+
SELECT*FROMtest_column_type.test;
59+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;
60+
61+
/* check insert dispatching*/
62+
INSERT INTOtest_column_type.testVALUES (1);
63+
SELECT tableoid::regclass,*FROMtest_column_type.test;
64+
65+
SELECT drop_partitions('test_column_type.test');
66+
DROPTABLEtest_column_type.test CASCADE;
67+
68+
69+
DROPSCHEMA test_column_type CASCADE;
70+
DROP EXTENSION pg_pathman;

‎src/hooks.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,9 @@ pathman_process_utility_hook(Node *parsetree,
712712
{
713713
if (IsPathmanReady())
714714
{
715-
Oidpartition_relid;
716-
AttrNumberpartitioned_col;
715+
Oidrelation_oid;
716+
PartTypepart_type;
717+
AttrNumberattr_number;
717718

718719
/* Override standard COPY statement if needed */
719720
if (is_pathman_related_copy(parsetree))
@@ -730,12 +731,25 @@ pathman_process_utility_hook(Node *parsetree,
730731
}
731732

732733
/* Override standard RENAME statement if needed */
733-
if (is_pathman_related_table_rename(parsetree,
734-
&partition_relid,
735-
&partitioned_col))
736-
PathmanRenameConstraint(partition_relid,
737-
partitioned_col,
734+
elseif (is_pathman_related_table_rename(parsetree,
735+
&relation_oid,
736+
&attr_number))
737+
PathmanRenameConstraint(relation_oid,
738+
attr_number,
738739
(constRenameStmt*)parsetree);
740+
741+
/* Override standard ALTER COLUMN TYPE statement if needed */
742+
elseif (is_pathman_related_alter_column_type(parsetree,
743+
&relation_oid,
744+
&attr_number,
745+
&part_type)&&
746+
part_type==PT_HASH)
747+
ereport(ERROR,
748+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
749+
errmsg("cannot change type of column \"%s\""
750+
" of table \"%s\" partitioned by HASH",
751+
get_attname(relation_oid,attr_number),
752+
get_rel_name(relation_oid))));
739753
}
740754

741755
/* Call hooks set by other extensions if needed */

‎src/include/init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool validate_range_constraint(const Expr *expr,
218218
boolvalidate_hash_constraint(constExpr*expr,
219219
constPartRelationInfo*prel,
220220
constAttrNumberpart_attno,
221-
uint32*part_hash);
221+
uint32*part_idx);
222222

223223

224224
#endif/* PATHMAN_INIT_H */

‎src/include/relation_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ typedef struct
176176
boolbyval;
177177

178178
/* For HASH partitions */
179-
uint32hash;
179+
uint32part_idx;
180180
}PartBoundInfo;
181181

182182
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp