Re: Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list - Mailing list pgsql-hackers

From David Rowley
Subject Re: Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list
Date
Msg-id CAApHDvqCeSV8eWx_aKFWqPszs=aGxd7jVg_e53ZdE4UA8GT=4g@mail.gmail.com
Whole thread Raw
In response to Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list  (Jean Landercy - BEEODIVERSITY <jean.landercy@beeodiversity.com>)
Responses RE: Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list
List pgsql-hackers
On Mon, 6 Jun 2022 at 21:34, Jean Landercy - BEEODIVERSITY
<jean.landercy@beeodiversity.com> wrote:
> SELECT COUNT(*) FROM items;
> -- ERROR:  variable not found in subplan target list
> -- SQL state: XX000

Can you share some more details about what "items" is. psql's "\d
items" output would be useful.  From what you've reported we can't
tell if this is a table or a view.

> The bug is tricky to reproduce, I could not succeed to replicate elsewhere (dump/restore does not preserve it).

Can you share the output of:

select attname,atttypid::regtype,attnum,atthasdef,atthasmissing,attgenerated,attisdropped
from pg_attribute where attrelid = 'items'::regclass order by attnum;

This will let us see if there's something strange going on with
dropped or has missing columns.  There may be some sequence of ALTER
TABLE ADD COLUMN ... DEFAULT / DROP COLUMN that is causing this. The
output of that might help us see if that could be a factor.

David



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: oat_post_create expected behavior
Next
From: David Rowley
Date:
Subject: Re: pgcon unconference / impact of block size on performance