BUG #8516: Calling VOLATILE from STABLE function - Mailing list pgsql-bugs

From dwayne@docketnavigator.com
Subject BUG #8516: Calling VOLATILE from STABLE function
Date
Msg-id E1VU0qE-0003bl-7o@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #8516: Calling VOLATILE from STABLE function  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8516
Logged by:          Dwayne Towell
Email address:      dwayne@docketnavigator.com
PostgreSQL version: 9.2.4
Operating system:   CentOS
Description:

Why doesn't PostgreSQL give a warning when calling a volatile function from
a stable function?


For example:
CREATE TABLE x (val double);


CREATE FUNCTION g() RETURNS boolean AS $$
    INSERT INTO x SELECT rand() RETURNING val>0.5;
$$ LANGUAGE SQL VOLATILE;


CREATE FUNCTION f() RETURNS boolean AS $$
    SELECT g();         -- this is where the stability-violation happens
$$ LANGUAGE SQL STABLE; -- this is a lie


According to the documentation, f() should be marked VOLATILE also, since
calling f() produces side effects. PostgreSQL does not give a warning (or
better yet, an error); I think it should.

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: BUG #8467: Slightly confusing pgcrypto example in docs
Next
From: Gabriel Ciubotaru
Date:
Subject: Bit String expand bug