mirror of https://github.com/citusdata/citus.git
wip
parent
e4b8c7c183
commit
f98efe6c2c
|
@ -1793,13 +1793,35 @@ RelationRestrictionPartitionKeyIndex(Query* originalQuery, RelationRestriction *
|
||||||
partitionKeyTargetAttrIndex++;
|
partitionKeyTargetAttrIndex++;
|
||||||
|
|
||||||
if (!targetEntry->resjunk &&
|
if (!targetEntry->resjunk &&
|
||||||
IsA(targetExpression, Var) &&
|
IsA(targetExpression, Var))
|
||||||
IsPartitionColumn(targetExpression, relationPlannerParseQuery))
|
|
||||||
{
|
{
|
||||||
Var *targetColumn = (Var *) targetExpression;
|
Var *targetColumn = (Var *) targetExpression;
|
||||||
|
|
||||||
|
// elog(WARNING, "%d %d", targetColumn->varno, targetColumn->varattno);
|
||||||
|
|
||||||
|
if (!IsPartitionColumn(targetExpression, relationPlannerParseQuery)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Oid relationId = InvalidOid;
|
||||||
|
Var *column = NULL;
|
||||||
|
|
||||||
RangeTblEntry* res = (RangeTblEntry*) list_nth(relationPlannerParseQuery->rtable, targetColumn->varno - 1);
|
RangeTblEntry* res = (RangeTblEntry*) list_nth(relationPlannerParseQuery->rtable, targetColumn->varno - 1);
|
||||||
|
if (res->rtekind == RTE_JOIN) {
|
||||||
|
Var* cur = NULL;
|
||||||
|
int index = 1;
|
||||||
|
foreach_ptr(cur, res->joinaliasvars) {
|
||||||
|
if (index == targetColumn->varattno) {
|
||||||
|
res = (RangeTblEntry*) list_nth(relationPlannerParseQuery->rtable, cur->varno - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (res->rtekind == RTE_RELATION && GetRTEIdentity(res) == findRteIdentityContext->rteIdentity)
|
if (res->rtekind == RTE_RELATION && GetRTEIdentity(res) == findRteIdentityContext->rteIdentity)
|
||||||
{
|
{
|
||||||
|
FindReferencedTableColumn(targetExpression, NIL, relationPlannerParseQuery, &relationId, &column);
|
||||||
|
targetColumn = column;
|
||||||
*partitionKeyIndex = partitionKeyTargetAttrIndex;
|
*partitionKeyIndex = partitionKeyTargetAttrIndex;
|
||||||
return (Var*)copyObject(targetColumn);
|
return (Var*)copyObject(targetColumn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue