pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maxo EtDirloth <etdirloth@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6019: invalid cached plan on inherited table
Date: Wed, 11 May 2011 08:21:59 +0200
Message-ID: <BANLkTi=29JjraqCcgfKPpDf1qn7dkNryZA@mail.gmail.com> (raw)
In-Reply-To: <19015.1305087444@sss.pgh.pa.us>
References: <201105101229.p4ACTpnU013375@wwwmaster.postgresql.org>
	<19015.1305087444@sss.pgh.pa.us>

No big deal to me, I just couldn't verify that it may occur only within
single transaction - not even in documentation.

thanks for the answer
.et.


On Wed, May 11, 2011 at 6:17 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "" <etdirloth@gmail.com> writes:
> > Cached execution plan of SQL stored procedure (which select from
> inherited
> > table) executed from within PLPGSQL function is used even when
> inheritance
> > descendant is already removed.
>
> Don't hold your breath waiting for a fix for that :-(.  There isn't any
> support for detecting plan-invalidation events for SQL-language
> functions, and in most situations it would be overkill because the plans
> are only cached for the lifespan of one calling query anyway.  The only
> case where the plan could survive longer is this specific example of a
> SQL function called from a "simple expression" in a plpgsql function,
> and even then it only survives for one complete transaction.
>
> I've thought for some time that SQL functions should be reimplemented
> to cache information more the way plpgsql functions do, ie, with a
> session-lifespan data structure for each function.  If we did that
> and made the individual query plans be stored in plancache, then
> invalidation of this type would occur automatically --- and, not
> insignificantly, the plans would survive long enough to pay back the
> added overhead of tracking invalidation causes for them.
>
> A somewhat related point is that people have occasionally complained
> because all the queries in a SQL function are run through parse analysis
> at once, causing things like
>
>                CREATE TABLE foo ... ;
>                INSERT INTO foo ... ;
>
> to not work because the second command is analyzed before the first is
> executed.  If we were reimplementing SQL functions then it'd make sense
> to try to do something about that at the same time.
>
> None of this is on the TODO list, but I'll go fix that momentarily.
>
>                        regards, tom lane
>

view thread (3+ messages)

Message-ID: <BANLkTi=29JjraqCcgfKPpDf1qn7dkNryZA@mail.gmail.com>
Permalink:  ../BANLkTi=29JjraqCcgfKPpDf1qn7dkNryZA@mail.gmail.com/
Also on:    postgresql.org/message-id/BANLkTi=29JjraqCcgfKPpDf1qn7dkNryZA@mail.gmail.com

 · 

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: etdirloth@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #6019: invalid cached plan on inherited table
  In-Reply-To: <BANLkTi=29JjraqCcgfKPpDf1qn7dkNryZA@mail.gmail.com>
  References: <201105101229.p4ACTpnU013375@wwwmaster.postgresql.org> <19015.1305087444@sss.pgh.pa.us> <BANLkTi=29JjraqCcgfKPpDf1qn7dkNryZA@mail.gmail.com>

* 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