From de7d33cb5a1fddb0b2677b421687a9b4a401ff6c Mon Sep 17 00:00:00 2001 From: Dipesh Dhameliya Date: Tue, 19 Nov 2024 13:32:57 +0530 Subject: [PATCH] Extend the ability of planner_node_transformer_hook to store the context of expression being processed (#469) Extend the ability of planner_node_transformer_hook to store the context of expression being process. This saved context will be used during planning to transform declared variable either as a Param (if it appears in TargetList) or as a const (all the other places). Extension: https://github.com/babelfish-for-postgresql/babelfish_extensions/pull/3011/ Task: BABEL-5188 Signed-off-by: Dipesh Dhameliya --- src/backend/optimizer/plan/planner.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index f2bf6956b6c..435cdd7d35d 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -1157,6 +1157,10 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) if (kind != EXPRKIND_RTFUNC) expr = eval_const_expressions(root, expr); + /* Reset context of expression */ + if(EXPRKIND_TARGET == kind && planner_node_transformer_hook) + (void) planner_node_transformer_hook(root, NULL, -1); + /* * If it's a qual or havingQual, canonicalize it. */