Internal error with types changes and prepared statements

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Internal error with types changes and prepared statements
Date: 2021-09-22 18:13:21
Message-ID: CA+mi_8YAGf9qibDFTRNKgaTwaBa1OUcteKqLAxfMmKFbo3GHZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

From https://github.com/sqlalchemy/sqlalchemy/issues/6842#issuecomment-925131836

The issue can be reproduced in psql with the following commands
(tested with PostgreSQL 12.8):

BEGIN;
CREATE TYPE an_enum AS ENUM ('foo', 'bar', 'baz');
CREATE TABLE foo(id integer, bar an_enum[]);
PREPARE stmt (an_enum[]) AS INSERT INTO foo (bar) VALUES ($1);
EXECUTE stmt ('{foo}');
ROLLBACK;

BEGIN;
CREATE TYPE an_enum AS ENUM ('foo', 'bar', 'baz');
CREATE TABLE foo(id integer, bar an_enum[]);
EXECUTE stmt ('{foo}');
ERROR: cache lookup failed for type 8072147

\errverbose
ERROR: XX000: cache lookup failed for type 8072147
LOCATION: getBaseTypeAndTypmod, lsyscache.c:2355

Note: the issue is caused by Psycopg 3 use of prepared statements. Do
you suggest discarding prepared statements on a rollback on the
connection? I haven't seen documentation describing the interaction
between transactions and prepared statements.

Cheers

-- Daniele

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-09-22 18:27:41 Re: Internal error with types changes and prepared statements
Previous Message PG Bug reporting form 2021-09-22 13:17:29 BUG #17200: PostgreSQL-Support Profile Guide Optimization(Clang/GCC)?