Re: Wrong results with grouping sets
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2024-05-23T07:30:43Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove the RTE_GROUP RTE if we drop the groupClause
- ffe12d1d22e7 18.0 landed
-
Mark expressions nullable by grouping sets
- f5050f795aea 18.0 landed
-
Introduce an RTE for the grouping step
- 247dea89f761 18.0 landed
Attachments
- v5-0001-Introduce-a-RTE-for-the-grouping-step.patch (application/octet-stream) patch v5-0001
On Fri, May 17, 2024 at 5:41 PM Richard Guo <guofenglinux@gmail.com> wrote: > I've spent some more time on this patch, and now it passes all the > regression tests. But I had to hack explain.c and ruleutils.c to make > the varprefix stuff work as it did before, which is not great. > I've realized that I made a mistake in the v4 patch: If there are join alias vars in the targetlist and HAVING clause, we should first flatten them before replacing the grouped variables involved there with grouping-RTE Vars. To fix this issue, I decide to merge the newly added function substitute_group_exprs into check_ungrouped_columns by changing check_ungrouped_columns to also perform the replacement, which is Tom's initial suggestion I think. Now it seems that 'check_ungrouped_columns' is no longer an appropriate name for the function. So I rename it to 'substitute_grouped_columns'. But I'm open to other names if there are any suggestions. I've also worked on the comments. Thanks Richard