Re: BUG #6517: Volatile function erroneously optimized, does not consider change in schema path

From: Rene van Paassen <rene(dot)vanpaassen(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6517: Volatile function erroneously optimized, does not consider change in schema path
Date: 2012-03-14 08:13:29
Message-ID: CAOVCA=vOBdYav8xBYF0-2t80wPy4M9RpYFRGvcBxuh-VpVuXzQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 12 March 2012 16:32, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Mon, Mar 12, 2012 at 11:16 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> >> On Mon, Mar 5, 2012 at 6:52 AM, <rene(dot)vanpaassen(at)gmail(dot)com> wrote:
> >>> I found some unexpected behaviour when changing the schema search path
> in
> >>> combination with plpgsql functions (may be true for other function
> types
> >>> too, did not check). This occurs both in 9.1.2 (on Fedora, 64 bit) and
> 8.4.9
> >>> (Centos 6, 32 bit). I created a small example run with psql, to
> demonstrate
> >>> this.
> >
> >> I have a vague feeling this is a known issue. It sure seems like we
> >> should handle it better, but I'm not sure how hard that would be to
> >> implement.
> >
> > plpgsql intentionally caches the plan for the query as it was built with
> > the original search_path. There's been talk of adjusting that behavior
> > but I'm worried that we might break as many cases as we fix ...
>
> IMHO, the problem with the current behavior is that it's neither all
> one thing nor all the other. Using the definition-time search_path
> seems defensible, and using the run-time search_path does, too. But
> we're not consistently doing either one, which doesn't seem good.
>
>
Isn't this what the VOLATILE, STABLE and IMMUTABLE keywords should be for?
I don't like the current behaviour, because now VOLATILE is not volatile,
unless you close and re-open the database connection. There should at least
be a big fat warning about combining functions with changing search path
somewhere in the documentation.

Implementation-wise (but I have to admit I don't know the underlying code
at all), would it be possible to cache with the search_path as an index?

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

--
René van Paassen <Rene(dot)vanPaassen(at)gmail(dot)com>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Rene van Paassen 2012-03-14 08:22:42 Re: BUG #6517: Volatile function erroneously optimized, does not consider change in schema path
Previous Message Merlin Moncure 2012-03-13 19:49:45 Re: BUG #6489: Alter table with composite type/table