This is an automated backport of #7091: Use processed group clause in PG16 (take 2).
This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.
In #6377 we fixed an ORDER BY/GROUP BY expression not found in targetlist by using the root->processed_groupClause instead of parse->groupClause due to an optimization introduced in PG16 that removes redundant grouping and distinct columns.
But looks like we didn't change all necessary places, specially our HashAggregate optimization.
This is an automated backport of #7091: Use processed group clause in PG16 (take 2). This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.
For more details, please see the documentation
Original description
Use processed group clause in PG16 (take 2)
In #6377 we fixed an
ORDER BY/GROUP BY expression not found in targetlist
by using theroot->processed_groupClause
instead ofparse->groupClause
due to an optimization introduced in PG16 that removes redundant grouping and distinct columns.But looks like we didn't change all necessary places, specially our HashAggregate optimization.
Disable-check: force-changelog-file