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

Commit685dafc

Browse files
committed
pathman: some RANGE partitioning fixes
1 parent63e03ac commit685dafc

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

‎contrib/pathman/pathman.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,10 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEnt
319319

320320
/* replace old relids with new ones */
321321
change_varnos(new_rinfo->clause,rel->relid,childrel->relid);
322-
change_varnos(new_rinfo->left_em->em_expr,rel->relid,childrel->relid);
323-
change_varnos(new_rinfo->right_em->em_expr,rel->relid,childrel->relid);
322+
if (new_rinfo->left_em)
323+
change_varnos(new_rinfo->left_em->em_expr,rel->relid,childrel->relid);
324+
if (new_rinfo->right_em)
325+
change_varnos(new_rinfo->right_em->em_expr,rel->relid,childrel->relid);
324326

325327
/* TODO: find some elegant way to do this */
326328
if (bms_is_member(rel->relid,new_rinfo->clause_relids))
@@ -800,8 +802,11 @@ on_partitions_updated(PG_FUNCTION_ARGS) {
800802
relid=DatumGetInt32(PG_GETARG_DATUM(0));
801803
prel= (PartRelationInfo*)
802804
hash_search(relations, (constvoid*)&relid,HASH_FIND,0);
803-
prel->children_count=0;
804-
load_part_relations_hashtable();
805+
if (prel!=NULL)
806+
{
807+
prel->children_count=0;
808+
load_part_relations_hashtable();
809+
}
805810
LWLockRelease(AddinShmemInitLock);
806811

807812
PG_RETURN_NULL();

‎contrib/pathman/sql/range.sql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION create_range_partitions(
55
v_relationTEXT
66
, v_attributeTEXT
77
, v_start_timestampTIMESTAMP
8-
, v_intervalINTERVAL
8+
, v_intervalTEXT
99
, v_premakeINTEGER)
1010
RETURNS VOIDAS
1111
$$
@@ -26,10 +26,14 @@ BEGIN
2626
SELECTcurrent_date INTO v_dt;
2727
END IF;
2828

29+
/* create first partition*/
2930
PERFORM create_single_range_partition(v_relation
3031
, v_dt
3132
, v_interval);
3233

34+
/* premake further partitions*/
35+
PERFORM append_range_partitions(v_relation, v_interval, v_premake);
36+
3337
INSERT INTO pg_pathman_rels (
3438
relname
3539
, attname
@@ -76,7 +80,7 @@ BEGIN
7680
LOOP
7781
PERFORM create_single_range_partition(v_relation
7882
, v_part_timestamp
79-
, v_interval::INTERVAL);
83+
, v_interval);
8084
v_part_timestamp := v_part_timestamp+ v_interval::INTERVAL;
8185
END LOOP;
8286
ELSIF NOT v_part_num ISNULL THEN
@@ -85,7 +89,7 @@ BEGIN
8589
LOOP
8690
PERFORM create_single_range_partition(v_relation
8791
, v_part_timestamp
88-
, v_interval::INTEGER);
92+
, v_interval);
8993
v_part_timestamp := v_part_timestamp+ v_interval;
9094
END LOOP;
9195
END IF;
@@ -99,8 +103,8 @@ $$ LANGUAGE plpgsql;
99103
*/
100104
CREATE OR REPLACEFUNCTIONcreate_single_range_partition(
101105
v_parent_relnameTEXT
102-
, v_start_timestampTIMESTAMPTZ
103-
, v_intervalINTERVAL)
106+
, v_start_timestampTIMESTAMP
107+
, v_intervalTEXT)
104108
RETURNS VOIDAS
105109
$$
106110
DECLARE
@@ -127,7 +131,7 @@ BEGIN
127131
INSERT INTO pg_pathman_range_rels (parent, min_dt, max_dt, child)
128132
VALUES (v_parent_relname
129133
, v_start_timestamp
130-
, v_start_timestamp+ v_interval
134+
, v_start_timestamp+ v_interval::INTERVAL
131135
, v_child_relname);
132136
END
133137
$$ LANGUAGE plpgsql;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp