Re: BUG #17088: FailedAssertion in prepagg.c
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>,
Michael Paquier <michael@paquier.xyz>, cyg0810@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2021-07-08T05:44:07Z
Lists: pgsql-bugs
On Thu, Jul 8, 2021 at 5:56 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> > "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
> > Tom> Hmm. Maybe it'd be better if the default behavior in
> > Tom> expression_tree_walker/mutator did not include recursing into the
> > Tom> args, then?
>
> > You'd think, but as I recall (I will re-check this to confirm) there
> > were more places where we _did_ need to recurse (especially during parse
> > analysis before we've matched up the sortgrouprefs), while most of the
> > places where recursion needed to be explicitly avoided already needed
> > special-case handling, so having the default the other way would likely
> > have required a special-case almost everywhere.
>
> Fair enough. This is the kind of design choice that can be worth
> revisiting later; but if the conclusion is still the same, fine with me.
>
I think the culprit is that when replacing correlation uplevel vars with
Params, we do not handle the SubLinks in the arguments of uplevel
GroupingFunc. We expect build_subplan should take care of it. But in
build_subplan, we ignore GroupingFunc incorrectly.
diff --git a/src/backend/optimizer/plan/subselect.c
b/src/backend/optimizer/plan/subselect.c
index 0881a208ac..e4918f275e 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -364,7 +364,8 @@ build_subplan(PlannerInfo *root, Plan *plan,
PlannerInfo *subroot,
* SS_replace_correlation_vars). Do that now.
*/
if (IsA(arg, PlaceHolderVar) ||
- IsA(arg, Aggref))
+ IsA(arg, Aggref) ||
+ IsA(arg, GroupingFunc))
arg = SS_process_sublinks(root, arg, false);
Thanks
Richard
Commits
-
Fix assorted missing logic for GroupingFunc nodes.
- dfefe38fbea4 13.7 landed
- 69c88e2fb0aa 12.11 landed
- 5de244196a5b 11.16 landed
- 48b6035f0f72 14.3 landed
- 2afa031ac552 10.21 landed
- 2591ee8ec44d 15.0 landed