Skip to content

Commit c713fb8

Browse files
committed
change Param-related macros used in expr. walker
1 parent 6760448 commit c713fb8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pg_pathman.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,12 @@ static Path *get_cheapest_parameterized_child_path(PlannerInfo *root, RelOptInfo
122122
#define check_gt(flinfo, arg1, arg2) \
123123
((int) FunctionCall2(cmp_func, arg1, arg2) > 0)
124124

125-
#define IsConstValue(node) \
126-
( IsA((node), Const) || IsA((node), Param) )
125+
#define WcxtHasExprContext(wcxt) ( (wcxt) && (wcxt)->econtext )
126+
127+
/* We can transform Param into Const provided that 'econtext' is available */
128+
#define IsConstValue(wcxt, node) \
129+
( IsA((node), Const) || (WcxtHasExprContext(wcxt) ? IsA((node), Param) : false) )
130+
127131
#define ExtractConst(wcxt, node) \
128132
( IsA((node), Param) ? extract_const((wcxt), (Param *) (node)) : ((Const *) (node)) )
129133

@@ -1276,13 +1280,13 @@ handle_opexpr(WalkerContext *wcxt, const OpExpr *expr, const PartRelationInfo *p
12761280
firstarg = (Node *) linitial(expr->args);
12771281
secondarg = (Node *) lsecond(expr->args);
12781282

1279-
if (IsA(firstarg, Var) && IsConstValue(secondarg) &&
1283+
if (IsA(firstarg, Var) && IsConstValue(wcxt, secondarg) &&
12801284
((Var *)firstarg)->varattno == prel->attnum)
12811285
{
12821286
handle_binary_opexpr(prel, result, (Var *)firstarg, ExtractConst(wcxt, secondarg));
12831287
return result;
12841288
}
1285-
else if (IsA(secondarg, Var) && IsConstValue(firstarg) &&
1289+
else if (IsA(secondarg, Var) && IsConstValue(wcxt, firstarg) &&
12861290
((Var *)secondarg)->varattno == prel->attnum)
12871291
{
12881292
handle_binary_opexpr(prel, result, (Var *)secondarg, ExtractConst(wcxt, firstarg));

0 commit comments

Comments
 (0)