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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #19037: Planner fails on estimating array length with "no relation entry" error
Date: 2025-08-30 12:00:02
Message-ID: 19037-3d1c7bb553c7ce84@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19037
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 18beta3
Operating system: Ubuntu 24.04
Description:

The following script:
create table t(ia int[]);
select exists (select 1 from (select 1) where case when b then 1 else 0 end
= 1)
from (select 1 = any(ia) as b from t);

triggers:
ERROR: XX000: no relation entry for relid 2
LOCATION: find_base_rel, relnode.c:426

2025-08-30 11:28:26.036 UTC [2334676] LOG: statement: select exists (select
1 from (select 1) where case when b then 1 else 0 end = 1)
from (select 1 = any(ia) as b from t);
2025-08-30 11:28:26.038 UTC [2334676] ERROR: no relation entry for relid 2
2025-08-30 11:28:26.038 UTC [2334676] BACKTRACE:
find_base_rel at relnode.c:426:2
examine_variable at selfuncs.c:5319:16
estimate_array_length at selfuncs.c:2173:7
cost_qual_eval_walker at costsize.c:4874:25
expression_tree_walker_impl at nodeFuncs.c:2304:9
cost_qual_eval_walker at costsize.c:5043:1
expression_tree_walker_impl at nodeFuncs.c:2534:8
expression_tree_walker_impl at nodeFuncs.c:2215:8
cost_qual_eval_walker at costsize.c:5043:1
...

(Discovered with SQLsmith.)

Reproduced starting from 9391f7152.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-08-30 21:51:16 Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error
Previous Message ZhangChi 2025-08-30 02:09:36 Re: BUG #19036: Failed prepared INSERT statement make another SELECT query generate wrong result