Re: Internal error with types changes and prepared statements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Internal error with types changes and prepared statements
Date: 2021-09-22 18:27:41
Message-ID: 2220999.1632335261@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniele Varrazzo 2021-09-22 18:32:05 Re: Internal error with types changes and prepared statements
Previous Message Daniele Varrazzo 2021-09-22 18:13:21 Internal error with types changes and prepared statements