PG 18’s synthetic RTE_GROUP really is “another” RTE kind that you must treat just like the RTE_SUBQUERY and RTE_JOIN cases if you want your composite‐field logic to see through it.

Mehmet Yilmaz 2025-06-27 09:25:51 +00:00
parent bfcb3c63fd
commit 7aa347dfb6
1 changed files with 17 additions and 0 deletions

View File

@ -520,6 +520,23 @@ CompositeFieldRecursive(Expr *expression, Query *query)
compositeField = CompositeFieldRecursive(joinColumn, query); compositeField = CompositeFieldRecursive(joinColumn, query);
} }
#if PG_VERSION_NUM >= PG_VERSION_18
else if (rangeTableEntry->rtekind == RTE_GROUP)
{
/* PG 18 synthetic GROUP RTE: each groupexprs[i] matches varattno=i+1 */
List *gexprs = rangeTableEntry->groupexprs;
AttrNumber grpIndex = candidateColumn->varattno - 1;
if (grpIndex >= 0 && grpIndex < list_length(gexprs))
{
Expr *grpExpr = (Expr *) list_nth(gexprs, grpIndex);
compositeField = CompositeFieldRecursive(grpExpr, query);
}
/* else leave compositeField = NULL */
}
#endif
return compositeField; return compositeField;
} }