Re: BUG #6517: Volatile function erroneously optimized, does not consider change in schema path - Mailing list pgsql-bugs

From Jaime Casanova
Subject Re: BUG #6517: Volatile function erroneously optimized, does not consider change in schema path
Date
Msg-id CAJKUy5hF0gAW=i0cR_V0swpGV9kWOeuETzkc4yhC77bO3bEjxg@mail.gmail.com
Whole thread Raw
In response to BUG #6517: Volatile function erroneously optimized, does not consider change in schema path  (rene.vanpaassen@gmail.com)
List pgsql-bugs
On Mon, Mar 5, 2012 at 6:52 AM,  <rene.vanpaassen@gmail.com> wrote:
>
> set search_path to public;
>
> CREATE FUNCTION countusers()
> RETURNS INT
> AS $PROC$
> BEGIN
> =A0 =A0RETURN count(*) FROM users;
> END
> $PROC$ LANGUAGE 'plpgsql' VOLATILE;
>

i think you can workaround your problem using EXECUTE:

CREATE FUNCTION countusers()
RETURNS INT
AS $PROC$
DECLARE
   counter INT;
BEGIN
   EXECUTE 'SELECT count(*) FROM users' INTO counter;
=A0 =A0RETURN counter;
END
$PROC$ LANGUAGE 'plpgsql' VOLATILE;

--=20
Jaime Casanova=A0 =A0 =A0 =A0=A0 www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitaci=F3n

pgsql-bugs by date:

Previous
From: Jeff Davis
Date:
Subject: Re: check_locale() and the empty string
Next
From: Marti Raudsepp
Date:
Subject: Re: BUG #6513: explain (analyze, buffers) and toasted fields