On Sat, Dec 22, 2012 at 2:25 AM, David Johnston <polobo@yahoo.com> wrote:
> You have defined the function as "IMMUTABLE". The system is allowed to cache the results of a given call (i.e.
"ps3(2)")and return the value without actually executing the function ("never executed"). Your second example returns
"1"without a warning regarding the "2" invocation due to this. The Query Plan you show also matches this behavior.
Further reading on this subject:
http://www.postgresql.org/docs/9.1/static/xfunc-volatility.html
See particularly the second paragraph after the bullet list.
ChrisA