pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: sully@msully.net, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17479: "plan should not reference subplan's variable" when calling `grouping` on result of subquery
Date: Thu, 12 May 2022 10:51:22 -0400
Message-ID: <327116.1652367082@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMbWs49peoSCckCr4ZtWxJ3-gTOL7kPof+492aDMocGEwGtJ4g@mail.gmail.com>
References: <17479-6260deceaf0ad304@postgresql.org>
	<CAMbWs4-AmKNFMKwpc1AsJWPUskuaJ3EAJ9-ymV=qe=JQx_e3qA@mail.gmail.com>
	<CAMbWs48m-p46J7-mWn3xZwstbo9HCq9oEom1usbKYb7EeGnTog@mail.gmail.com>
	<218738.1652310685@sss.pgh.pa.us>
	<CAMbWs49peoSCckCr4ZtWxJ3-gTOL7kPof+492aDMocGEwGtJ4g@mail.gmail.com>

Richard Guo <guofenglinux@gmail.com> writes:
> On Thu, May 12, 2022 at 7:11 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> What became of SubPlan 1?  Maybe this is fine but it looks a little
>> shaky.  We should at least run down why that's happening and make
>> sure we're not leaving dangling pointers anywhere.

> I did some debug on this. The 'SubPlan 1' is not explained because its
> SubPlanState is not created and added to AggState->subPlan.

Yeah, concur: there are two subplans in the plan tree, so no dangling
pointers.

> Not sure if this is fine or not.

It seems cosmetic.  We could somehow force initialization of the
GroupingFunc's argument tree, but that would just be wasted cycles
in non-EXPLAIN cases, and it seems semantically wrong anyway given
that evaluation of the argument is not supposed to happen.  (Right
now that's hypothetical, but what if ExecInitExpr started to
pre-evaluate some things?)

Given the history of this thing, maybe we will find something that
depends on such initialization happening.  But without evidence
for that I'm not inclined to add code for it.

I'll run with the patch as you suggested.

			regards, tom lane





view thread (6+ messages)

Message-ID: <327116.1652367082@sss.pgh.pa.us>
Permalink:  ../327116.1652367082@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/327116.1652367082@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, guofenglinux@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17479: "plan should not reference subplan's variable" when calling `grouping` on result of subquery
  In-Reply-To: <327116.1652367082@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox