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.