Re: Prepared statements fail after schema changes with surprising error

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter van Hardenberg <pvh(at)pvh(dot)ca>, Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Prepared statements fail after schema changes with surprising error
Date: 2013-01-22 11:27:19
Message-ID: CA+TgmoaYSW0gGi0Y6rM13p2DBWRjQjHSrtUNbBF2v7H-Tor8AQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 22, 2013 at 2:17 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter van Hardenberg <pvh(at)pvh(dot)ca> writes:
>> Okay - I've narrowed it down to an interaction with schema recreation.
>> Here's a minimal test-case I created by paring back the restore from the
>> pg_restore output until I only had the essence remaining:
>
> Hm ... I'm too tired to trace through the code to prove this theory, but
> I think what's happening is that this bit:
>
>> DROP SCHEMA public;
>> CREATE SCHEMA public;
>
> changes the OID of schema public, whereas the search_path that's cached
> for the cached plan is cached in terms of OIDs. So while there is a
> table named public.z1 at the end of the sequence, it's not in any schema
> found in the cached search path.
>
> We could possibly fix that by making the path be cached as textual names
> not OIDs, but then people would complain (rightly, I think) that
> renaming a schema caused unexpected behavior.

What sort of unexpected behavior?

I mean, search_path in its original form is stored as text, anyway.
So if the unexpected behavior is merely that they're going to be
referencing a different schema, that's going to happen anyway, as soon
as they reconnect. I'm not sure there's any logic in trying to
postpone the inevitable.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2013-01-22 12:02:04 Re: Event Triggers: adding information
Previous Message Stefan Kaltenbrunner 2013-01-22 11:24:48 Re: pg_dump transaction's read-only mode