Tatsuo Ishii <ishii(at)postgresql(dot)org> writes:
> I'm wondering if we could detect a funcion has a side effect,
> i.e. does a write to database.
> Currently we have three properties of functions: IMMUTABLE, STABLE and
> VOLATILE. According to docs IMMUTABLE or STABLE functions do not write
> to database.
Those classifications are meant as planner directives; they are NOT
meant to be bulletproof. Hanging database integrity guarantees on
whether a "non volatile" function changes anything is entirely unsafe.
To give just one illustration of the problems, a nonvolatile function
is allowed to call a volatile one.
regards, tom lane