@@ -122,8 +122,12 @@ static Path *get_cheapest_parameterized_child_path(PlannerInfo *root, RelOptInfo
122
122
#define check_gt (flinfo ,arg1 ,arg2 ) \
123
123
((int) FunctionCall2(cmp_func, arg1, arg2) > 0)
124
124
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
+
127
131
#define ExtractConst (wcxt ,node ) \
128
132
( IsA((node), Param) ? extract_const((wcxt), (Param *) (node)) : ((Const *) (node)) )
129
133
@@ -1276,13 +1280,13 @@ handle_opexpr(WalkerContext *wcxt, const OpExpr *expr, const PartRelationInfo *p
1276
1280
firstarg = (Node * )linitial (expr -> args );
1277
1281
secondarg = (Node * )lsecond (expr -> args );
1278
1282
1279
- if (IsA (firstarg ,Var )&& IsConstValue (secondarg )&&
1283
+ if (IsA (firstarg ,Var )&& IsConstValue (wcxt , secondarg )&&
1280
1284
((Var * )firstarg )-> varattno == prel -> attnum )
1281
1285
{
1282
1286
handle_binary_opexpr (prel ,result , (Var * )firstarg ,ExtractConst (wcxt ,secondarg ));
1283
1287
return result ;
1284
1288
}
1285
- else if (IsA (secondarg ,Var )&& IsConstValue (firstarg )&&
1289
+ else if (IsA (secondarg ,Var )&& IsConstValue (wcxt , firstarg )&&
1286
1290
((Var * )secondarg )-> varattno == prel -> attnum )
1287
1291
{
1288
1292
handle_binary_opexpr (prel ,result , (Var * )secondarg ,ExtractConst (wcxt ,firstarg ));