BUG #19037: Planner fails on estimating array length with "no relation entry" error - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19037: Planner fails on estimating array length with "no relation entry" error
Date
Msg-id 19037-3d1c7bb553c7ce84@postgresql.org
Whole thread Raw
Responses Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error
List pgsql-bugs
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.


pgsql-bugs by date:

Previous
From: "ZhangChi"
Date:
Subject: Re: BUG #19036: Failed prepared INSERT statement make another SELECT query generate wrong result
Next
From: Tom Lane
Date:
Subject: Re: BUG #19037: Planner fails on estimating array length with "no relation entry" error