Re: Wrong results with grouping sets

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Wrong results with grouping sets
Date: 2024-05-24 13:08:22
Message-ID: CAMbWs4_UkgZp=OC=eeawJn=4ZdZfU-FGjOg_2mhKAdxTyU-HQQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On the basis of the parser infrastructure fixup, 0002 patch adds the
nullingrel bit that references the grouping RTE to the grouping
expressions.

However, it seems to me that we have to manually remove this nullingrel
bit from expressions in various cases where these expressions are
logically below the grouping step, such as when we generate groupClause
pathkeys for grouping sets, or when we generate PathTarget for initial
input to grouping nodes.

Furthermore, in set_upper_references, the targetlist and quals of an Agg
node should have nullingrels that include the effects of the grouping
step, ie they will have nullingrels equal to the input Vars/PHVs'
nullingrels plus the nullingrel bit that references the grouping RTE.
In order to perform exact nullingrels matches, I think we also need to
manually remove this nullingrel bit.

Thanks
Richard

Attachment Content-Type Size
v6-0001-Introduce-a-RTE-for-the-grouping-step.patch application/octet-stream 47.8 KB
v6-0002-Mark-expressions-nullable-by-grouping-sets.patch application/octet-stream 21.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2024-05-24 13:20:53 Re: Schema variables - new implementation for Postgres 15
Previous Message Pavel Stehule 2024-05-24 13:00:48 Re: Schema variables - new implementation for Postgres 15