Refactor TargetListOnPartitionColumn

multi-column-distribution
Jelte Fennema 2021-06-09 12:45:20 +02:00
parent 13ff1e2b40
commit bb26c3b9f7
1 changed files with 10 additions and 19 deletions

View File

@ -206,13 +206,11 @@ FindNodeMatchingCheckFunction(Node *node, CheckNodeFunc checker)
bool
TargetListOnPartitionColumn(Query *query, List *targetEntryList)
{
bool targetListOnPartitionColumn = false;
List *compositeFieldList = NIL;
ListCell *targetEntryCell = NULL;
foreach(targetEntryCell, targetEntryList)
TargetEntry *targetEntry = NULL;
foreach_ptr(targetEntry, targetEntryList)
{
TargetEntry *targetEntry = (TargetEntry *) lfirst(targetEntryCell);
Expr *targetExpression = targetEntry->expr;
bool isPartitionColumn = IsPartitionColumn(targetExpression, query);
@ -240,36 +238,29 @@ TargetListOnPartitionColumn(Query *query, List *targetEntryList)
}
else
{
targetListOnPartitionColumn = true;
break;
return true;
}
}
}
/* check composite fields */
if (!targetListOnPartitionColumn)
bool fullCompositeFieldList = FullCompositeFieldList(compositeFieldList);
if (fullCompositeFieldList)
{
bool fullCompositeFieldList = FullCompositeFieldList(compositeFieldList);
if (fullCompositeFieldList)
{
targetListOnPartitionColumn = true;
}
return true;
}
/*
* We could still behave as if the target list is on partition column if
* range table entries don't contain a distributed table.
*/
if (!targetListOnPartitionColumn)
if (!FindNodeMatchingCheckFunctionInRangeTableList(query->rtable,
IsDistributedTableRTE))
{
if (!FindNodeMatchingCheckFunctionInRangeTableList(query->rtable,
IsDistributedTableRTE))
{
targetListOnPartitionColumn = true;
}
return true;
}
return targetListOnPartitionColumn;
return false;
}