pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Cramer <pg@fastcrypt.com>
Cc: KUNES Michael <Michael.KUNES@frequentis.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: Mail an JDBC driver
Date: Tue, 02 Aug 2016 10:22:58 -0400
Message-ID: <25254.1470147778@sss.pgh.pa.us> (raw)
In-Reply-To: <CADK3HH+dBHU54QvRF9wfkSQWB69GAv6S6GobMxWOC-T8f+4rmA@mail.gmail.com>
References: <0B5AA3EC05A9C9438B5CC2B8A46AB60D011A8FC9A8@vie197nt>
	<8B4125EAC2E43647B4FC5ED8275851EE011972DB6B@vie196nt>
	<0B5AA3EC05A9C9438B5CC2B8A46AB60D011A8FE5D8@vie197nt>
	<CADK3HHJE9c0kbC4ba4-mDXr+r2mj5BocbkYrWKmDYStbkU-OLw@mail.gmail.com>
	<CADK3HH+dBHU54QvRF9wfkSQWB69GAv6S6GobMxWOC-T8f+4rmA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Dave Cramer <pg@fastcrypt.com> writes:
> So I just tried using prepared statements and wasn't able to duplicate
> this. It would be really nice if you could test this against at recent
> version of PostgreSQL, and provide us with a self contained test case?

I think that this is probably affected by this 9.3-era backend change:

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL9_3_BR [0d5fbdc15] 2013-01-25 14:14:41 -0500

    Change plan caching to honor, not resist, changes in search_path.
    
    In the initial implementation of plan caching, we saved the active
    search_path when a plan was first cached, then reinstalled that path
    anytime we needed to reparse or replan.  The idea of that was to try to
    reselect the same referenced objects, in somewhat the same way that views
    continue to refer to the same objects in the face of schema or name
    changes.  Of course, that analogy doesn't bear close inspection, since
    holding the search_path fixed doesn't cope with object drops or renames.
    Moreover sticking with the old path seems to create more surprises than
    it avoids.  So instead of doing that, consider that the cached plan depends
    on search_path, and force reparse/replan if the active search_path is
    different than it was when we last saved the plan.
    
    This gets us fairly close to having "transparency" of plan caching, in the
    sense that the cached statement acts the same as if you'd just resubmitted
    the original query text for another execution.  There are still some corner
    cases where this fails though: a new object added in the search path
    schema(s) might capture a reference in the query text, but we'd not realize
    that and force a reparse.  We might try to fix that in the future, but for
    the moment it looks too expensive and complicated.


With the 9.2 database, if you cache a DELETE query as a prepared
statement, then it will retain the original search path and continue to
use that if the statement needs to be replanned.  Moreover I'm pretty
sure that its notion of "original search path" was defined in terms of
schema OIDs not names, so that the table in the renamed schema would
continue to be targeted.

We got rid of that behavior precisely because it turned out to be more
surprising than useful ... but 9.2 is operating as designed.  The apparent
dependency on JDBC version probably has to do with different driver
choices about whether/when to prepare the DELETE statement.

			regards, tom lane


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



view thread (13+ messages)  latest in thread

Message-ID: <25254.1470147778@sss.pgh.pa.us>
Permalink:  ../25254.1470147778@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25254.1470147778@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-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pg@fastcrypt.com, Michael.KUNES@frequentis.com
  Subject: Re: Mail an JDBC driver
  In-Reply-To: <25254.1470147778@sss.pgh.pa.us>
  References: <0B5AA3EC05A9C9438B5CC2B8A46AB60D011A8FC9A8@vie197nt> <8B4125EAC2E43647B4FC5ED8275851EE011972DB6B@vie196nt> <0B5AA3EC05A9C9438B5CC2B8A46AB60D011A8FE5D8@vie197nt> <CADK3HHJE9c0kbC4ba4-mDXr+r2mj5BocbkYrWKmDYStbkU-OLw@mail.gmail.com> <CADK3HH+dBHU54QvRF9wfkSQWB69GAv6S6GobMxWOC-T8f+4rmA@mail.gmail.com> <25254.1470147778@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