pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: marko@joh.to
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #11402: Prepared statement cache invalidation and unknown types
Date: Thu, 11 Sep 2014 21:55:15 -0400
Message-ID: <29786.1410486915@sss.pgh.pa.us> (raw)
In-Reply-To: <20140911215805.2484.10673@wrigleys.postgresql.org>
References: <20140911215805.2484.10673@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

marko@joh.to writes:
> I hit the behaviour on 9.1 originally with functions, but tested it against
> a reasonably fresh HEAD and it was still broken.  Somehow it seems that the
> prepared statement isn't willing to forget the data type of the argument
> after it has been resolved once (even though it was specified to be unknown
> :-( ).  This leads to some grotesque cache invalidation code in our API.

I'm not exactly convinced that this is a bug.  Having a prepared statement
silently change its input parameter types seems a lot more dangerous than
just failing; especially since we lack any signaling mechanism by which
the client application could be warned that whatever it may have known
about the statement is now invalid.

For largely the same reason, we don't allow a prepared statement to
change output column types:

regression=# create table tt (f1 int);
CREATE TABLE
regression=# insert into tt values(1);
INSERT 0 1
regression=# prepare foo as select * from tt;
PREPARE
regression=# execute foo;
 f1 
----
  1
(1 row)

regression=# alter table tt alter column f1 type real;
ALTER TABLE
regression=# execute foo;
ERROR:  cached plan must not change result type

I'm not sure why we would think that changing input parameter types is any
safer.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)  latest in thread

Message-ID: <29786.1410486915@sss.pgh.pa.us>
Permalink:  ../29786.1410486915@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29786.1410486915@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, marko@joh.to
  Subject: Re: BUG #11402: Prepared statement cache invalidation and unknown types
  In-Reply-To: <29786.1410486915@sss.pgh.pa.us>
  References: <20140911215805.2484.10673@wrigleys.postgresql.org> <29786.1410486915@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