Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error
Date: 2025-09-02 06:49:51
Message-ID: CAMbWs4_KfP=2Rkne2+fAHE8yQAuZL2C8wH4DSLrOa4s5v=yN7g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Sep 1, 2025 at 11:57 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 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()?

Fair point.

> 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.

Yeah, it should be safe to use a NULL root for initplans. Besides, in
the case of SS_make_initplan_from_plan, testexpr will be NULL, and
cost_qual_eval() becomes a no-op.

Here is the patch that passes root as NULL to cost_qual_eval() in
cost_subplan(), along with some commentary about why.

- Richard

Attachment Content-Type Size
v2-0001-Fix-planner-error-when-estimating-SubPlan-cost.patch application/octet-stream 4.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-09-02 07:06:18 BUG #19039: UNREACHABLE_CODE: Remove unreachable code in network_send - replace with assertion
Previous Message Srinath Reddy Sadipiralla 2025-09-02 04:59:53 Re: bug reapper: Empty query_id in pg_stat_activity