Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VUPCk-0007QV-GB for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2013 22:59:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VUPCj-0001Ox-Ue for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2013 22:59:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VUPCi-0001NC-9X for pgsql-bugs@postgresql.org; Thu, 10 Oct 2013 22:59:36 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VUPCd-0004pd-NF for pgsql-bugs@postgresql.org; Thu, 10 Oct 2013 22:59:35 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1VUPCd-0005mc-AE; Thu, 10 Oct 2013 18:59:31 -0400 Date: Thu, 10 Oct 2013 18:59:31 -0400 From: Bruce Momjian To: dwayne@docketnavigator.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #8516: Calling VOLATILE from STABLE function Message-ID: <20131010225931.GZ7092@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Wed, Oct 9, 2013 at 08:58:46PM +0000, dwayne@docketnavigator.com wrote: > 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. I think the answer is that function authors are required to prevent functions they mark as STABLE from calling VOLATILE functions. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs