PG18 - Handle PG18’s synthetic RTE_GROUP

Add ExprReferencesPartitionColumn function to check partition column references in queries

Add ExprMentionsPartitionColumn function to identify partition column references in queries

Revert "Add ExprReferencesPartitionColumn function to check partition column references in queries"

This reverts commit c507801c54.

indent

Enhance partition column handling in TargetListOnPartitionColumn for PostgreSQL 18 compatibility

Add support for synthetic GROUP RTE in FindReferencedTableColumn for PostgreSQL 18

Remove ExprMentionsPartitionColumn function for partition column reference checks

Remove unnecessary blank line in InsertPartitionColumnMatchesSelect function

Remove ExprMentionsPartitionColumn function and simplify partition column checks for PostgreSQL 18 compatibility

add RTE_GROUP to the non-complex whitelist for PG 18.

A synthetic RTE_GROUP is harmless; treating it as “complex” flips the flag and prevents a router plan.

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.

add an explicit RTE_GROUP clause that does nothing (or falls through like VALUES/RESULT) for PG 18

Without it, an UPDATE … FROM (SELECT … GROUP BY …) on PG 18 will raise “Unrecognized range table entry.”

Update version check for RTE_GROUP to use PG_VERSION_18 constant

some reverts

Remove citus-tools subproject reference
m3hm3t/pg18_pushdown_group_column
Mehmet Yilmaz 2025-05-08 15:46:04 +00:00
parent 3f9e12e010
commit cd017ee69c
1 changed files with 25 additions and 0 deletions

View File

@ -4557,6 +4557,31 @@ FindReferencedTableColumn(Expr *columnExpression, List *parentQueryList, Query *
FindReferencedTableColumn(joinColumn, parentQueryList, query, column,
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;
/* Safety check */
if (groupIndex < 0 || groupIndex >= list_length(groupexprs))
{
return; /* malformed Var */
}
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)
{
/*