@@ -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
12761280firstarg = (Node * )linitial (expr -> args );
12771281secondarg = (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{
12821286handle_binary_opexpr (prel ,result , (Var * )firstarg ,ExtractConst (wcxt ,secondarg ));
12831287return 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{
12881292handle_binary_opexpr (prel ,result , (Var * )secondarg ,ExtractConst (wcxt ,firstarg ));