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: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error
Date: Mon, 01 Sep 2025 10:57:37 -0400
Message-ID: <346889.1756738657@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMbWs4_5Q3V_M1FavN07TxcOHhE38vtBaHs-LM2-RN=paYGi-g@mail.gmail.com>
References: <19037-3d1c7bb553c7ce84@postgresql.org>
	<50858.1756590676@sss.pgh.pa.us>
	<CAMbWs4_5Q3V_M1FavN07TxcOHhE38vtBaHs-LM2-RN=paYGi-g@mail.gmail.com>

Richard Guo <guofenglinux@gmail.com> writes:
> On Sun, Aug 31, 2025 at 6:51 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The most expedient solution is probably to hack examine_variable
>> so that it doesn't fail if root->simple_rel_array isn't there yet.
>> That seems mighty ugly though.

> As an alternative, I wonder if we could pass root as NULL to
> cost_subplan() when it's called from build_subplan(), and possibly
> also from SS_process_ctes().  At those points, the root does not yet
> contain enough information to safely consult statistics.  Meanwhile,
> cost_qual_eval() and the functions it calls are already well-equipped
> to handle a NULL root.

Good suggestion, that does seem more in keeping with established
hacks^H^H^Hpractice.  It'll need some commentary about why.

I'm slightly tempted to do the dirty work in cost_subplan() itself,
ie pass a NULL down to cost_qual_eval from there.  Right now it
doesn't matter, but maybe in future there would be some other
safer use for the parent root in cost_subplan()?  This approach
would force the same behavior for the third caller of cost_subplan,
SS_make_initplan_from_plan.  But I don't think it matters there,
since an initplan will by definition not be consulting anything from
the parent plan.

			regards, tom lane





view thread (11+ messages)  latest in thread

Message-ID: <346889.1756738657@sss.pgh.pa.us>
Permalink:  ../346889.1756738657@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/346889.1756738657@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, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error
  In-Reply-To: <346889.1756738657@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