Re: BUG #8516: Calling VOLATILE from STABLE function

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: dwayne(at)docketnavigator(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8516: Calling VOLATILE from STABLE function
Date: 2013-10-10 22:59:31
Message-ID: 20131010225931.GZ7092@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Oct 9, 2013 at 08:58:46PM +0000, dwayne(at)docketnavigator(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 8516
> Logged by: Dwayne Towell
> Email address: dwayne(at)docketnavigator(dot)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.

I think the answer is that function authors are required to prevent
functions they mark as STABLE from calling VOLATILE functions.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dwayne Towell 2013-10-10 23:10:35 Re: BUG #8516: Calling VOLATILE from STABLE function
Previous Message Sergey Konoplev 2013-10-10 22:01:46 Re: Completely broken replica after PANIC: WAL contains references to invalid pages