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

Commit39295b6

Browse files
committed
Fix data relocation after partitions created
1 parent385728b commit39295b6

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

‎hash.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ BEGIN
4747
/* Notify backend about changes*/
4848
PERFORM @extschema@.on_create_partitions(parent_relid);
4949

50-
/* Copy data
50+
/* Copy data*/
5151
IF partition_data= true THEN
5252
PERFORM @extschema@.set_enable_parent(parent_relid, false);
5353
PERFORM @extschema@.partition_data(parent_relid);
5454
ELSE
5555
PERFORM @extschema@.set_enable_parent(parent_relid, true);
56-
END IF;*/
56+
END IF;
5757

5858
RETURN partitions_count;
5959
END

‎range.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ BEGIN
164164
/* Notify backend about changes*/
165165
PERFORM @extschema@.on_create_partitions(parent_relid);
166166

167-
/* Relocate data if asked to
167+
/* Relocate data if asked to*/
168168
IF partition_data= true THEN
169169
PERFORM @extschema@.set_enable_parent(parent_relid, false);
170170
PERFORM @extschema@.partition_data(parent_relid);
171171
ELSE
172172
PERFORM @extschema@.set_enable_parent(parent_relid, true);
173-
END IF;*/
173+
END IF;
174174

175175
RETURN p_count;
176176
END

‎src/partition_creation.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,9 +1735,14 @@ get_part_expression_info(Oid relid, const char *expr_string,
17351735
List*querytree_list;
17361736
PlannedStmt*plan;
17371737
TargetEntry*target_entry;
1738+
MemoryContextpathman_parse_context,oldcontext;
17381739

17391740
expr_info=palloc(sizeof(PartExpressionInfo));
17401741

1742+
pathman_parse_context=AllocSetContextCreate(TopMemoryContext,
1743+
"pathman parse context",
1744+
ALLOCSET_DEFAULT_SIZES);
1745+
17411746
/* Keep raw expression */
17421747
expr_info->raw_expr=get_raw_expression(relid,expr_string,
17431748
&query_string,&parsetree);
@@ -1746,6 +1751,12 @@ get_part_expression_info(Oid relid, const char *expr_string,
17461751
/* We don't need pathman activity initialization for this relation yet */
17471752
pathman_hooks_enabled= false;
17481753

1754+
/* We use separate memory context here, just to make sure we don't leave
1755+
* anything behind after analyze and planning.
1756+
* Parsed raw expression will stay in context of caller
1757+
*/
1758+
oldcontext=MemoryContextSwitchTo(pathman_parse_context);
1759+
17491760
/* This will fail with elog in case of wrong expression
17501761
*with more or less understable text */
17511762
querytree_list=pg_analyze_and_rewrite(parsetree,
@@ -1776,11 +1787,13 @@ get_part_expression_info(Oid relid, const char *expr_string,
17761787
target_entry=lfirst(list_head(plan->planTree->targetlist));
17771788
expr_node= (Node*)target_entry->expr;
17781789
expr_node=eval_const_expressions(NULL,expr_node);
1790+
out_string=nodeToString(expr_node);
1791+
1792+
MemoryContextSwitchTo(oldcontext);
17791793

17801794
/* Convert expression to string and return it as datum */
1781-
out_string=nodeToString(expr_node);
17821795
expr_info->expr_datum=CStringGetTextDatum(out_string);
1783-
pfree(out_string);
1796+
MemoryContextReset(pathman_parse_context);
17841797

17851798
end:
17861799
/* Enable pathman hooks */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp