diff options
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 1e42d75465e..bd01ec0526f 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -1084,8 +1084,10 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) /* * Simplify constant expressions. For function RTEs, this was already - * done by preprocess_function_rtes ... but we have to do it again if the - * RTE is LATERAL and might have contained join alias variables. + * done by preprocess_function_rtes. (But note we must do it again for + * EXPRKIND_RTFUNC_LATERAL, because those might by now contain + * un-simplified subexpressions inserted by flattening of subqueries or + * join alias variables.) * * Note: an essential effect of this is to convert named-argument function * calls to positional notation and insert the current actual values of @@ -1099,8 +1101,7 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) * careful to maintain AND/OR flatness --- that is, do not generate a tree * with AND directly under AND, nor OR directly under OR. */ - if (!(kind == EXPRKIND_RTFUNC || - (kind == EXPRKIND_RTFUNC_LATERAL && !root->hasJoinRTEs))) + if (kind != EXPRKIND_RTFUNC) expr = eval_const_expressions(root, expr); /* |