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

Commitce69636

Browse files
committed
Merge branch 'rel_future_beta' into rel_future_strings
2 parents69a751c +69028ca commitce69636

12 files changed

+303
-54
lines changed

‎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: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
SET search_path = 'public';
33
CREATE EXTENSION pg_pathman;
44
CREATE SCHEMA test_column_type;
5+
/*
6+
* RANGE partitioning.
7+
*/
58
/* create new table (val int) */
69
CREATE TABLE test_column_type.test(val INT4 NOT NULL);
710
SELECT create_range_partitions('test_column_type.test', 'val', 1, 10, 10);
@@ -51,6 +54,106 @@ SELECT tableoid::regclass, * FROM test_column_type.test;
5154
test_column_type.test_1 | 1
5255
(1 row)
5356

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;
54157
DROP SCHEMA test_column_type CASCADE;
55-
NOTICE: drop cascades to12 other objects
158+
NOTICE: drop cascades tosequence test_column_type.test_seq
56159
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)
@@ -170,7 +170,7 @@ LANGUAGE plpgsql;
170170
CREATEOR REPLACE FUNCTION @extschema@.create_hash_partitions_internal(
171171
parent_relidREGCLASS,
172172
attributeTEXT,
173-
partitions_countINTEGER,
173+
partitions_countINT4,
174174
partition_namesTEXT[] DEFAULTNULL,
175175
tablespacesTEXT[] DEFAULTNULL)
176176
RETURNS VOIDAS'pg_pathman','create_hash_partitions_internal'
@@ -186,7 +186,7 @@ LANGUAGE C STRICT;
186186
/*
187187
* Calculates hash for integer value
188188
*/
189-
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INTEGER,INTEGER)
189+
CREATEOR REPLACE FUNCTION @extschema@.get_hash_part_idx(INT4, INT4)
190190
RETURNSINTEGERAS'pg_pathman','get_hash_part_idx'
191191
LANGUAGE C STRICT;
192192

@@ -197,6 +197,6 @@ CREATE OR REPLACE FUNCTION @extschema@.build_hash_condition(
197197
attribute_typeREGTYPE,
198198
attributeTEXT,
199199
partitions_countINT4,
200-
partitions_indexINT4)
200+
partition_indexINT4)
201201
RETURNSTEXTAS'pg_pathman','build_hash_condition'
202202
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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ CREATE EXTENSION pg_pathman;
55
CREATESCHEMAtest_column_type;
66

77

8+
/*
9+
* RANGE partitioning.
10+
*/
11+
812
/* create new table (val int)*/
913
CREATETABLEtest_column_type.test(val INT4NOT NULL);
1014
SELECT create_range_partitions('test_column_type.test','val',1,10,10);
@@ -24,6 +28,43 @@ SELECT context, entries FROM pathman_cache_stats ORDER BY context;
2428
INSERT INTOtest_column_type.testVALUES (1);
2529
SELECT tableoid::regclass,*FROMtest_column_type.test;
2630

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+
2768

2869
DROPSCHEMA test_column_type CASCADE;
2970
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
@@ -177,7 +177,7 @@ typedef struct
177177
boolbyval;
178178

179179
/* For HASH partitions */
180-
uint32hash;
180+
uint32part_idx;
181181
}PartBoundInfo;
182182

183183
/*

‎src/include/utility_stmt_hooking.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#defineCOPY_STMT_HOOKING_H
1414

1515

16+
#include"relation_info.h"
17+
1618
#include"postgres.h"
1719
#include"commands/copy.h"
1820
#include"nodes/nodes.h"
@@ -23,6 +25,10 @@ bool is_pathman_related_copy(Node *parsetree);
2325
boolis_pathman_related_table_rename(Node*parsetree,
2426
Oid*partition_relid_out,
2527
AttrNumber*partitioned_col_out);
28+
boolis_pathman_related_alter_column_type(Node*parsetree,
29+
Oid*parent_relid_out,
30+
AttrNumber*attr_number_out,
31+
PartType*part_type_out);
2632

2733
/* Statement handlers */
2834
voidPathmanDoCopy(constCopyStmt*stmt,constchar*queryString,uint64*processed);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp