Re: Set search_path + server-prepared statements = cached plan must not change result type

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Set search_path + server-prepared statements = cached plan must not change result type
Date: 2016-02-07 11:24:19
Message-ID: CA+TgmoaCViAXM33idt=tYZPLdRvH9Hy8TPUs8p=93n9+g858yQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 27, 2016 at 10:18 PM, David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> Prepare creates a plan and a plan has a known output structure. What you
> want is an ability to give a name to a parsed but unplanned query. This is
> not something that prepare should do as it is not a natural extension of its
> present responsibility.

The distinction you're talking about here actually does exist at the
Protocol level. You can send a Parse message to create a prepared
statement (which is parsed but unplanned), a Bind message to create a
portal (which is planned), and then you can send an Execute message to
execute a previously-created portal.

However, I'm not really sure this helps. It seems like what Vladimir
wants is basically automatic plan caching. He wants the server to
re-parse-analyze and re-plan the statement any time that would produce
a different outcome, but ideally also consider holding onto the old
plan in case the search_path or whatever is switched back. I gather
that the reason he wants to use prepared statements at all is just to
minimize parse-plan overhead.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2016-02-07 12:11:35 Re: postgres_fdw join pushdown (was Re: Custom/Foreign-Join-APIs)
Previous Message Vik Fearing 2016-02-07 10:54:04 Re: proposal: make NOTIFY list de-duplication optional