Re: Wrong results with grouping sets - Mailing list pgsql-hackers

From Richard Guo
Subject Re: Wrong results with grouping sets
Date
Msg-id CAMbWs4_UkgZp=OC=eeawJn=4ZdZfU-FGjOg_2mhKAdxTyU-HQQ@mail.gmail.com
Whole thread Raw
In response to Re: Wrong results with grouping sets  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Wrong results with grouping sets
List 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

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Schema variables - new implementation for Postgres 15
Next
From: Pavel Stehule
Date:
Subject: Re: Schema variables - new implementation for Postgres 15