pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Floris Van Nee <florisvannee@Optiver.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: error cache lookup failed in plpgsql function
Date: Tue, 18 Jun 2024 09:19:41 +0000
Message-ID: <148fde845019499db7d14776f46b3ad4@Optiver.com> (raw)

Hi hackers,

I ran into a bug with plpgsql not invalidating its cache.
Experienced it on 15.5, but it reproduces on master.
It involves a function that references a custom type
which gets "replaced" by a new type with the same name.
Reconnecting makes the error go away.

Reproducible example:

create type test_t as (a int);
create table t1 (a test_t);
insert into t1 (values ('(1)'));
create or replace function test_f()
returns int
language plpgsql
as $function$
declare
  t t1;
begin
  select * into t from t1;
  return (t.a).a;
end;
$function$
;
select test_f(); -- OK

-- create a new type and replace the old with the new one
create type test_t2 as (a int);
alter table t1 alter column a type test_t2 using a::text::test_t2;
drop type test_t;
alter type test_t2 rename to test_t;
select test_f(); -- ERROR

ERROR:  XX000: cache lookup failed for type 16403
CONTEXT:  PL/pgSQL function test_f() line 6 at RETURN
LOCATION:  format_type_extended, format_type.c:137

view thread (2+ messages)  latest in thread

Message-ID: <148fde845019499db7d14776f46b3ad4@Optiver.com>
Permalink:  ../148fde845019499db7d14776f46b3ad4@Optiver.com/
Also on:    postgresql.org/message-id/148fde845019499db7d14776f46b3ad4@Optiver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: florisvannee@Optiver.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: error cache lookup failed in plpgsql function
  In-Reply-To: <148fde845019499db7d14776f46b3ad4@Optiver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox