why VOLATILE attribute is required? - Mailing list pgsql-general

From Rafal Pietrak
Subject why VOLATILE attribute is required?
Date
Msg-id 1316687319.31744.50.camel@localhost.localdomain
Whole thread Raw
In response to Re: Is 9.1 considered more stable/robust than 9.0.4 ?  (Devrim GÜNDÜZ <devrim@gunduz.org>)
Responses Re: why VOLATILE attribute is required?
Re: why VOLATILE attribute is required?
List pgsql-general
Hi All,

I have this function:
CREATE FUNCTION mypass(newpass text) returns text ....
EXECUTE 'ALTER USER ' || quote_ident(session_user) || ' PASSWORD ' ||
quote_literal(newpass); return session_user::text;

to varify user passwords before allowing a change.

I've put that function in a RULE that some housekeeping, like updating
user state (last pass change, etc):

CREATE RULE pass AS  ON UPDATE TO myself  WHERE old.pass <> new.pass DO
INSTEAD UPDATE people SET ....  WHERE username=mypass(new.username)

but I get:
ERROR:  ALTER ROLE is not allowed in a non-volatile function

Why???

1. The function is "obviously STABLE", since it's outcome will not
change enything in datatables (I think) - and I can arrange for its
output being stable within a transaction (if I don't do SET
AUTHORIZATION within the transation, right?).
2. for the purpose I need, the function could/should be "computted
once", and result used "meny times" (for filtering PEOPLE rows). Having
it get evaluated for every row is a signifficant unnecesary cost
panelty.


Probably I miss something. So my question is: why the database enforces
the VOLATILE attribute when function contains "ALTER ROLE ..."?

BTW: my postgres is 8.3

-R


pgsql-general by date:

Previous
From: Rajesh Kumar Mallah
Date:
Subject: Re: 10GbE / iSCSI storage for postgresql.
Next
From: Rohan Malhotra
Date:
Subject: limitby without orderby