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
v6-0001-Introduce-a-RTE-for-the-grouping-step.patch
Description: Binary data
v6-0002-Mark-expressions-nullable-by-grouping-sets.patch
Description: Binary data