we should consider all kinds of tables as colocated if their relation ids are same

fix-noncolocated-insert-select-pushdown
aykutbozkurt 2023-05-09 22:20:59 +03:00
parent 0668246a8a
commit 15b62979e2
1 changed files with 31 additions and 0 deletions

View File

@ -171,6 +171,7 @@ static bool FindQueryContainingRTEIdentityInternal(Node *node,
static int ParentCountPriorToAppendRel(List *appendRelList, AppendRelInfo *appendRelInfo);
static bool AllRelationsSame(List *relationList);
/*
* AllDistributionKeysInQueryAreEqual returns true if either
@ -1960,6 +1961,31 @@ AllDistributedRelationsInRTEListColocated(List *rangeTableEntryList)
}
/*
* AllRelationsSame determines whether all of the relations are the same.
*/
static bool
AllRelationsSame(List *relationList)
{
if (relationList == NULL || list_length(relationList) == 0)
{
return true;
}
Oid firstRelationId = linitial_oid(relationList);
Oid relationId = InvalidOid;
foreach_oid(relationId, relationList)
{
if (relationId != firstRelationId)
{
return false;
}
}
return true;
}
/*
* AllDistributedRelationsInListColocated determines whether all of the
* distributed relations in the given list are co-located.
@ -1967,6 +1993,11 @@ AllDistributedRelationsInRTEListColocated(List *rangeTableEntryList)
bool
AllDistributedRelationsInListColocated(List *relationList)
{
if (AllRelationsSame(relationList))
{
return true;
}
int initialColocationId = INVALID_COLOCATION_ID;
Oid relationId = InvalidOid;