pull/8034/merge
Mehmet YILMAZ 2025-07-10 12:32:14 +00:00 committed by GitHub
commit e0d3a04622
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -4557,6 +4557,29 @@ FindReferencedTableColumn(Expr *columnExpression, List *parentQueryList, Query *
FindReferencedTableColumn(joinColumn, parentQueryList, query, column, FindReferencedTableColumn(joinColumn, parentQueryList, query, column,
rteContainingReferencedColumn, skipOuterVars); rteContainingReferencedColumn, skipOuterVars);
} }
#if PG_VERSION_NUM >= PG_VERSION_18
else if (rangeTableEntry->rtekind == RTE_GROUP)
{
/*
* PG 18: synthetic GROUP RTE. Each groupexprs item corresponds to the
* columns produced by the grouping step, in the *same ordinal order* as
* the Vars that reference them.
*/
List *groupexprs = rangeTableEntry->groupexprs;
AttrNumber groupIndex = candidateColumn->varattno - 1;
/* this must always hold unless upstream Postgres mis-constructed the RTE_GROUP */
Assert(groupIndex >= 0 && groupIndex < list_length(groupexprs));
Expr *groupExpr = (Expr *) list_nth(groupexprs, groupIndex);
/* Recurse on the underlying expression (stay in the same query) */
FindReferencedTableColumn(groupExpr, parentQueryList, query,
column, rteContainingReferencedColumn,
skipOuterVars);
}
#endif /* PG_VERSION_NUM >= 180000 */
else if (rangeTableEntry->rtekind == RTE_CTE) else if (rangeTableEntry->rtekind == RTE_CTE)
{ {
/* /*