BUG #19037: Planner fails on estimating array length with "no relation entry" error
PG Bug reporting form <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2025-08-30T12:00:02Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix planner error when estimating SubPlan cost
- 8c02d92c6475 13.23 landed
- 160ef51c8dba 14.20 landed
- 53e35fb560ab 15.15 landed
- 79ade5873232 16.11 landed
- f34202f51867 17.7 landed
- ab4a35b4ea9d 18.0 landed
- aba8f61c3091 19 (unreleased) landed
The following bug has been logged on the website:
Bug reference: 19037
Logged by: Alexander Lakhin
Email address: exclusion@gmail.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.