Yura Sokolov <y.soko...@postgrespro.ru> writes: > I found, than declaration of function as IMMUTABLE/STABLE is not enough to be > sure > function doesn't manipulate data.
Of course not. It is the user's responsibility to mark functions properly. Trying to enforce that completely is a fool's errand; you soon get into trying to solve the halting problem. I don't like anything about the proposed patch. It's necessarily only a partial solution, and it probably breaks cases that are perfectly safe in context. regards, tom lane