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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Jean Landercy - BEEODIVERSITY <jean(dot)landercy(at)beeodiversity(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "andersk(at)mit(dot)edu" <andersk(at)mit(dot)edu>
Subject: Re: Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list
Date: 2022-06-06 21:27:45
Message-ID: CAApHDvqCeSV8eWx_aKFWqPszs=aGxd7jVg_e53ZdE4UA8GT=4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 6 Jun 2022 at 21:34, Jean Landercy - BEEODIVERSITY
<jean(dot)landercy(at)beeodiversity(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-06-06 22:39:53 Re: pgcon unconference / impact of block size on performance
Previous Message Tom Lane 2022-06-06 21:11:19 Re: oat_post_create expected behavior