Skip to content

Fix first/last aggregates in HAVING clause#10111

Merged
svenklemm merged 1 commit into
2.28.xfrom
sven/backport_10059
Jun 22, 2026
Merged

Fix first/last aggregates in HAVING clause#10111
svenklemm merged 1 commit into
2.28.xfrom
sven/backport_10059

Conversation

@svenklemm

Copy link
Copy Markdown
Member

The optimization that turns first/last aggregates into index-backed
subqueries replaced the aggregate references in the target list but not
in the HAVING clause. The leftover reference then reached the executor
and raised "Aggref found in non-Agg plan node".

Replace the references in the HAVING clause as well so the query runs.

Fixes #10059

The optimization that turns first/last aggregates into index-backed
subqueries replaced the aggregate references in the target list but not
in the HAVING clause. The leftover reference then reached the executor
and raised "Aggref found in non-Agg plan node".

Replace the references in the HAVING clause as well so the query runs.

Fixes #10059
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@svenklemm svenklemm merged commit 22a52fc into 2.28.x Jun 22, 2026
56 of 57 checks passed
@svenklemm svenklemm deleted the sven/backport_10059 branch June 22, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant