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

Commitd7665c3

Browse files
committed
enable/disable auto partition creation
1 parent3007f79 commitd7665c3

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

‎expected/pg_pathman.out

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,23 @@ SELECT * FROM test.range_rel WHERE dt = '2015-03-15';
12561256
74 | Sun Mar 15 00:00:00 2015
12571257
(1 row)
12581258

1259+
SELECT pathman.disable_auto('test.range_rel');
1260+
disable_auto
1261+
--------------
1262+
1263+
(1 row)
1264+
1265+
INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
1266+
ERROR: There is no suitable partition for key 'Mon Jun 01 00:00:00 2015'
1267+
SELECT pathman.enable_auto('test.range_rel');
1268+
enable_auto
1269+
-------------
1270+
1271+
(1 row)
1272+
1273+
INSERT INTO test.range_rel (dt) VALUES ('2015-06-01');
12591274
DROP TABLE test.range_rel CASCADE;
1260-
NOTICE: drop cascades to16 other objects
1275+
NOTICE: drop cascades to20 other objects
12611276
SELECT partrel, attname, parttype, range_interval FROM pathman.pathman_config;
12621277
partrel | attname | parttype | range_interval
12631278
---------+---------+----------+----------------

‎sql/pg_pathman.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ SELECT * FROM test.range_rel WHERE dt = '2014-12-15';
525525
EXPLAIN (COSTS OFF)SELECT*FROMtest.range_relWHERE dt='2015-03-15';
526526
SELECT*FROMtest.range_relWHERE dt='2015-03-15';
527527

528+
SELECTpathman.disable_auto('test.range_rel');
529+
INSERT INTOtest.range_rel (dt)VALUES ('2015-06-01');
530+
SELECTpathman.enable_auto('test.range_rel');
531+
INSERT INTOtest.range_rel (dt)VALUES ('2015-06-01');
532+
528533
DROPTABLEtest.range_rel CASCADE;
529534
SELECT partrel, attname, parttype, range_intervalFROMpathman.pathman_config;
530535

‎src/partition_filter.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,20 @@ partition_filter_exec(CustomScanState *node)
204204
elog(ERROR,"PartitionFilter selected more than one partition");
205205
elseif (nparts==0)
206206
{
207-
selected_partid=create_partitions(state->partitioned_table,
208-
state->temp_const.constvalue,
209-
state->temp_const.consttype);
207+
if (prel->auto_partition)
208+
{
209+
selected_partid=create_partitions(state->partitioned_table,
210+
state->temp_const.constvalue,
211+
state->temp_const.consttype);
210212

211-
/* get_pathman_relation_info() will refresh this entry */
212-
invalidate_pathman_relation_info(state->partitioned_table,NULL);
213+
/* get_pathman_relation_info() will refresh this entry */
214+
invalidate_pathman_relation_info(state->partitioned_table,NULL);
215+
}
216+
else
217+
elog(ERROR,
218+
"There is no suitable partition for key '%s'",
219+
datum_to_cstring(state->temp_const.constvalue,
220+
state->temp_const.consttype));
213221
}
214222
else
215223
selected_partid=parts[0];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp