Skip to content

Commit fd8474f

Browse files
committed
Fix execution
1 parent bd44be0 commit fd8474f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/partition_creation.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,21 +1804,22 @@ get_part_expression_info(Oid relid, const char *expr_string,
18041804
}
18051805

18061806
if (!make_plan)
1807-
return expr_info;
1807+
goto end;
18081808

18091809
/* Plan this query. We reuse 'expr_node' here */
18101810
plan = pg_plan_query(query, 0, NULL);
18111811
target_entry = lfirst(list_head(plan->planTree->targetlist));
18121812
expr_node = (Node *) target_entry->expr;
18131813
expr_node = eval_const_expressions(NULL, expr_node);
18141814

1815-
/* Enable pathman */
1816-
hooks_enabled = true;
1817-
18181815
/* Convert expression to string and return it as datum */
18191816
out_string = nodeToString(expr_node);
18201817
expr_info->expr_datum = CStringGetTextDatum(out_string);
18211818
pfree(out_string);
18221819

1820+
end:
1821+
/* Enable pathman hooks */
1822+
hooks_enabled = true;
1823+
18231824
return expr_info;
18241825
}

src/partition_filter.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,12 @@ partition_filter_exec(CustomScanState *node)
634634

635635
old_cxt = MemoryContextSwitchTo(estate->es_query_cxt);
636636

637+
/* Prepare walker context */
638+
expr_walker_context.prel = prel;
639+
expr_walker_context.slot = slot;
640+
expr_walker_context.tup = ExecCopySlotTuple(slot);
641+
expr_walker_context.clear = false;
642+
637643
/* Fetch values from slot for expression */
638644
adapt_values(prel->expr, (void *) &expr_walker_context);
639645

@@ -645,12 +651,6 @@ partition_filter_exec(CustomScanState *node)
645651
/* Switch to per-tuple context */
646652
old_cxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
647653

648-
/* Prepare walker context */
649-
expr_walker_context.prel = prel;
650-
expr_walker_context.slot = slot;
651-
expr_walker_context.tup = ExecCopySlotTuple(slot);
652-
expr_walker_context.clear = false;
653-
654654
/* Execute expression */
655655
value = ExecEvalExpr(expr_state, econtext, &isnull, &itemIsDone);
656656

0 commit comments

Comments
 (0)