Skip site navigation (1) Skip section navigation (2)

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

From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: rene(dot)vanpaassen(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6517: Volatile function erroneously optimized, does not consider change in schema path
Date: 2012-03-12 17:42:56
Message-ID: CAJKUy5hF0gAW=i0cR_V0swpGV9kWOeuETzkc4yhC77bO3bEjxg@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, Mar 5, 2012 at 6:52 AM,  <rene(dot)vanpaassen(at)gmail(dot)com> wrote:
>
> set search_path to public;
>
> CREATE FUNCTION countusers()
> RETURNS INT
> AS $PROC$
> BEGIN
>    RETURN 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;
   RETURN counter;
END
$PROC$ LANGUAGE 'plpgsql' VOLATILE;

-- 
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación

In response to

pgsql-bugs by date

Next:From: samuel.gilbertDate: 2012-03-12 19:34:20
Subject: BUG #6527: Error in COPY documentation syntax
Previous:From: Stefano BaccianellaDate: 2012-03-12 17:38:08
Subject: Re: BUG #6512: Bug with prepared statement and timestamp + interval

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group