[BUGS] BUG #8516: Calling VOLATILE from STABLE function
The following bug has been logged on the website: Bug reference: 8516 Logged by: Dwayne Towell Email address: dwa...@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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs
Re: [BUGS] BUG #8516: Calling VOLATILE from STABLE function
> 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. -- I understand it's an error (at least usually), my question/issue is why does PostgreSQL NOT give at least a warning when a programmer (probably accidentally) calls a VOLATILE function in one that he has specifically tagged as STABLE? The compiler has all the information to notify the programmer of a mistake, but isn't. This violates a fundamental principle of software engineering--take every opportunity to prevent errors. Dwayne -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs