Skip to content

Commit 405c509

Browse files
committed
Make last changes
1 parent 58ef2a5 commit 405c509

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/partition_creation.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,8 @@ get_expression_node(Oid relid, const char *expr, bool analyze)
17831783
hooks_enabled = true;
17841784

17851785
result = (Node *)target_entry->expr;
1786+
1787+
/* We keep expression in top context */
17861788
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
17871789

17881790
/* We need relid and range table list for mutator */

src/partition_filter.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,16 @@ partition_filter_exec(CustomScanState *node)
632632
return slot;
633633
}
634634

635+
old_cxt = MemoryContextSwitchTo(estate->es_query_cxt);
636+
637+
/* Fetch values from slot for expression */
638+
adapt_values((Node *)prel->expr, (void *) &expr_walker_context);
639+
640+
MemoryContextSwitchTo(old_cxt);
641+
642+
/* Prepare state for execution */
643+
expr_state = ExecPrepareExpr(prel->expr, estate);
644+
635645
/* Switch to per-tuple context */
636646
old_cxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
637647

@@ -641,12 +651,6 @@ partition_filter_exec(CustomScanState *node)
641651
expr_walker_context.tup = ExecCopySlotTuple(slot);
642652
expr_walker_context.clear = false;
643653

644-
/* Fetch values from slot for expression */
645-
adapt_values((Node *)prel->expr, (void *) &expr_walker_context);
646-
647-
/* Prepare state before execution */
648-
expr_state = ExecPrepareExpr(prel->expr, estate);
649-
650654
/* Execute expression */
651655
value = ExecEvalExpr(expr_state, econtext, &isnull, &itemIsDone);
652656

0 commit comments

Comments
 (0)