Improve safety check in FindReferencedTableColumn to assert valid groupIndex

m3hm3t/pg18_pushdown_group_column
Mehmet Yilmaz 2025-07-04 08:16:49 +00:00
parent cd017ee69c
commit 2b30606970
1 changed files with 3 additions and 5 deletions

View File

@ -4568,11 +4568,9 @@ FindReferencedTableColumn(Expr *columnExpression, List *parentQueryList, Query *
List *groupexprs = rangeTableEntry->groupexprs; List *groupexprs = rangeTableEntry->groupexprs;
AttrNumber groupIndex = candidateColumn->varattno - 1; AttrNumber groupIndex = candidateColumn->varattno - 1;
/* Safety check */ /* this must always hold unless upstream Postgres mis-constructed the RTE_GROUP */
if (groupIndex < 0 || groupIndex >= list_length(groupexprs)) Assert(groupIndex >= 0 && groupIndex < list_length(groupexprs));
{
return; /* malformed Var */
}
Expr *groupExpr = (Expr *) list_nth(groupexprs, groupIndex); Expr *groupExpr = (Expr *) list_nth(groupexprs, groupIndex);
/* Recurse on the underlying expression (stay in the same query) */ /* Recurse on the underlying expression (stay in the same query) */