Skip to content

Commit f495fd6

Browse files
committed
bugfix: check that variable is the partitioning key (Ildar)
1 parent 4b25335 commit f495fd6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pg_pathman.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,11 +1409,9 @@ handle_arrexpr(const ScalarArrayOpExpr *expr, WalkerContext *context)
14091409
result->args = NIL;
14101410
result->paramsel = 1.0;
14111411

1412-
if (varnode == NULL || !IsA(varnode, Var))
1413-
{
1414-
result->rangeset = list_make1_irange(make_irange(0, prel->children_count - 1, true));
1415-
return result;
1416-
}
1412+
/* If variable is not the partition key then skip it */
1413+
if (!varnode || !IsA(varnode, Var) || ((Var *) varnode)->varattno != prel->attnum)
1414+
goto handle_arrexpr_return;
14171415

14181416
if (arraynode && IsA(arraynode, Const) &&
14191417
!((Const *) arraynode)->constisnull)
@@ -1458,6 +1456,7 @@ handle_arrexpr(const ScalarArrayOpExpr *expr, WalkerContext *context)
14581456
result->paramsel = DEFAULT_INEQ_SEL;
14591457
}
14601458

1459+
handle_arrexpr_return:
14611460
result->rangeset = list_make1_irange(make_irange(0, prel->children_count - 1, true));
14621461
return result;
14631462
}

0 commit comments

Comments
 (0)