pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniele Varrazzo <daniele.varrazzo@gmail.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: Internal error with types changes and prepared statements
Date: Wed, 22 Sep 2021 14:27:41 -0400
Message-ID: <2220999.1632335261@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+mi_8YAGf9qibDFTRNKgaTwaBa1OUcteKqLAxfMmKFbo3GHZg@mail.gmail.com>
References: <CA+mi_8YAGf9qibDFTRNKgaTwaBa1OUcteKqLAxfMmKFbo3GHZg@mail.gmail.com>

Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> 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

Hmm.  We have not historically discarded prepared statements at
ROLLBACK.  While this example suggests it'd be safer to do so,
I'm quite afraid that we would break a lot more applications
than we'd fix.

Actually ... you don't need the ROLLBACK anyway.  You can
reproduce this behavior by dropping and recreating the
type/table.

I'm inclined to shrug and say don't do that.  We could perhaps
track all the dependencies of a prepared statement as we do
for views, but it would add a lot of overhead that's not there
today, and for what?  All we'd accomplish is to give a cleaner
error message.  I don't think people should expect the above
to somehow work --- if it did, that would imply assorted
security holes, because the statement would no longer mean
what it meant before.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <2220999.1632335261@sss.pgh.pa.us>
Permalink:  ../2220999.1632335261@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2220999.1632335261@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, daniele.varrazzo@gmail.com
  Subject: Re: Internal error with types changes and prepared statements
  In-Reply-To: <2220999.1632335261@sss.pgh.pa.us>

* 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