Re: [pgsql-hackers] UPDATE is not allowed in a non-volatile function - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: [pgsql-hackers] UPDATE is not allowed in a non-volatile function
Date
Msg-id 200411020858.28471.josh@agliodbs.com
Whole thread Raw
Responses Re: [pgsql-hackers] UPDATE is not allowed in a non-volatile function  (Gaetano Mendola <mendola@bigfoot.com>)
List pgsql-hackers
Gaetano,

> I do not consider my design as "unsafe", this is for example how a
> cache works: expose a "read" without side effect but updating internal
> statistics. After all the read will not alter the data that it expose
> but other data that the user even don't know the existence.

At issue is the working definitions of the function states (and yes, I know 
these aren't the formal definitions but these are what is useful):
IMMUTABLE: result of function will always be the same given the same inputs;
STABLE: result of function will be the same for the duration of the 
transaction.
VOLATILE: you can't count on any particular result based on the inputs

Any function involving an UPDATE -- and I write a LOT of them -- clearly falls 
into the last group.   You never know what you're going to get as a result of 
an UPDATE; you could get an index violation, a lock wait, a deadlock, a 
constraint violation, etc.    

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-hackers by date:

Previous
From: oozmen@cs.uwaterloo.ca
Date:
Subject: How to create/initialize/access an execution plan
Next
From: Gaetano Mendola
Date:
Subject: Re: [pgsql-hackers] UPDATE is not allowed in a non-volatile function