BUG #17669: Invalid TOAST pointer in PL/pgSQL variable

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: s(dot)shinderuk(at)postgrespro(dot)ru
Subject: BUG #17669: Invalid TOAST pointer in PL/pgSQL variable
Date: 2022-10-27 19:45:14
Message-ID: 17669-2238da15dce5c53c@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17669
Logged by: Sergey Shinderuk
Email address: s(dot)shinderuk(at)postgrespro(dot)ru
PostgreSQL version: 15.0
Operating system: Ubuntu 22.04
Description:

Is it a bug or a known limitation?

create table t (a int, b text);
alter table t alter column b set storage external;
insert into t values (1, repeat('a',3000));

create function f() returns text as $$
declare
s text;
begin
select b into s from t where a = 1;
truncate t;
return s;
end;
$$ language plpgsql;

postgres=# select f();
ERROR: missing chunk number 0 for toast value 24727 in pg_toast_24722

If I replace "truncate" with "drop table", then I get:
ERROR: could not open relation with OID 24725

With "delete from t" it just works.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Julien Rouhaud 2022-10-28 01:28:41 Re: BUG #17668: Query normalization generates multiple queryId:s for calls to the same procedure
Previous Message Tom Lane 2022-10-27 18:28:17 Re: BUG #17668: Query normalization generates multiple queryId:s for calls to the same procedure