ERROR: XX000: variable not found in subplan target list

Ryan Kelly <rpkelly22@gmail.com>

From: Ryan Kelly <rpkelly22@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Date: 2022-02-11T03:21:56Z
Lists: pgsql-bugs
Hello,

After upgrading to 11.15 we have queries failing as follows:
(postgres@[local]:5432 02:52:54) [capitalrx_test_adjudication_master]>
EXPLAIN SELECT count(*) FROM adjudication.claims;
ERROR:  XX000: variable not found in subplan target list
LOCATION:  fix_upper_expr_mutator, setrefs.c:2427
Time: 0.697 ms
(postgres@[local]:5432 02:53:00) [capitalrx_test_adjudication_master]>
EXPLAIN SELECT count(1) FROM adjudication.claims;
ERROR:  XX000: variable not found in subplan target list
LOCATION:  fix_upper_expr_mutator, setrefs.c:2427
Time: 0.541 ms
(postgres@[local]:5432 02:53:03) [capitalrx_test_adjudication_master]>
EXPLAIN SELECT count(null) FROM adjudication.claims;
ERROR:  XX000: variable not found in subplan target list
LOCATION:  fix_upper_expr_mutator, setrefs.c:2427
Time: 0.890 ms
(postgres@[local]:5432 02:53:06) [capitalrx_test_adjudication_master]>
EXPLAIN SELECT count(id) FROM adjudication.claims;
                                     QUERY PLAN

-------------------------------------------------------------------------------------
 Aggregate  (cost=8.14..8.15 rows=1 width=8)
   ->  Index Only Scan using claims_pkey on claims  (cost=0.12..8.14 rows=1
width=8)
(2 rows)

Time: 1.423 ms

Thanks,
-Ryan Kelly

Commits

  1. Don't use_physical_tlist for an IOS with non-returnable columns.