some variable renameing

pull/7643/head
paragjain 2024-07-14 10:45:16 +00:00
parent 2fc5e14ee8
commit 346422e7be
4 changed files with 14 additions and 5 deletions

View File

@ -857,8 +857,11 @@ ConvertRelationRTEIntoSubquery(Query *mergeQuery, RangeTblEntry *sourceRte,
/* set the FROM expression to the subquery */ /* set the FROM expression to the subquery */
newRangeTableRef->rtindex = SINGLE_RTE_INDEX; newRangeTableRef->rtindex = SINGLE_RTE_INDEX;
sourceResultsQuery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL); sourceResultsQuery->jointree = makeFromExpr(list_make1(newRangeTableRef), NULL);
bool isMergeQuery = true;
sourceResultsQuery->targetList = sourceResultsQuery->targetList =
CreateAllTargetListForRelation(sourceRte->relid, requiredAttributes); CreateAllTargetListForRelation(sourceRte->relid, requiredAttributes,
isMergeQuery);
List *restrictionList = List *restrictionList =
GetRestrictInfoListForRelation(sourceRte, plannerRestrictionContext); GetRestrictInfoListForRelation(sourceRte, plannerRestrictionContext);
List *copyRestrictionList = copyObject(restrictionList); List *copyRestrictionList = copyObject(restrictionList);

View File

@ -325,12 +325,14 @@ WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation,
* as a NULL column. * as a NULL column.
*/ */
List * List *
CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes) CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes, bool
isMergeQuery)
{ {
Relation relation = relation_open(relationId, AccessShareLock); Relation relation = relation_open(relationId, AccessShareLock);
int numberOfAttributes = RelationGetNumberOfAttributes(relation); int numberOfAttributes = RelationGetNumberOfAttributes(relation);
List *targetList = NIL; List *targetList = NIL;
int colAppendIdx = 1;
for (int attrNum = 1; attrNum <= numberOfAttributes; attrNum++) for (int attrNum = 1; attrNum <= numberOfAttributes; attrNum++)
{ {
@ -360,8 +362,9 @@ CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes)
} }
else else
{ {
int varAttNum = isMergeQuery ? attrNum : colAppendIdx++;
TargetEntry *targetEntry = TargetEntry *targetEntry =
CreateTargetEntryForColumn(attributeTuple, SINGLE_RTE_INDEX, attrNum, CreateTargetEntryForColumn(attributeTuple, SINGLE_RTE_INDEX, varAttNum,
resNo); resNo);
targetList = lappend(targetList, targetEntry); targetList = lappend(targetList, targetEntry);
} }

View File

@ -1767,8 +1767,10 @@ ReplaceRTERelationWithRteSubquery(RangeTblEntry *rangeTableEntry,
{ {
Query *subquery = WrapRteRelationIntoSubquery(rangeTableEntry, requiredAttrNumbers, Query *subquery = WrapRteRelationIntoSubquery(rangeTableEntry, requiredAttrNumbers,
perminfo); perminfo);
bool isMergeQuery = false;
List *outerQueryTargetList = CreateAllTargetListForRelation(rangeTableEntry->relid, List *outerQueryTargetList = CreateAllTargetListForRelation(rangeTableEntry->relid,
requiredAttrNumbers); requiredAttrNumbers,
isMergeQuery);
List *restrictionList = List *restrictionList =
GetRestrictInfoListForRelation(rangeTableEntry, GetRestrictInfoListForRelation(rangeTableEntry,

View File

@ -38,6 +38,7 @@ extern bool SubqueryColocated(Query *subquery, ColocatedJoinChecker *context);
extern Query * WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation, extern Query * WrapRteRelationIntoSubquery(RangeTblEntry *rteRelation,
List *requiredAttributes, List *requiredAttributes,
RTEPermissionInfo *perminfo); RTEPermissionInfo *perminfo);
extern List * CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes); extern List * CreateAllTargetListForRelation(Oid relationId, List *requiredAttributes,
bool isMergeQuery);
#endif /* QUERY_COLOCATION_CHECKER_H */ #endif /* QUERY_COLOCATION_CHECKER_H */