Alban Hertroys <alban@xxxxxxxxxxxxxxxxx> writes: > What I'm trying to say is not that it _is_ immutable, but that it > _behaves_ immutable (under said conditions). > This could imply that if a certain condition is available in a query on > which such a function operates, it would behave immutable. Right, but we don't have any way to represent such a fact in date_trunc's pg_proc entry, so we have to mark it as "not immutable". There was a related discussion awhile ago when designing the current set of "what time is it" functions --- transaction_timestamp(), statement_timestamp(), and clock_timestamp(). The original proposal had just a single function that took a parameter telling which value you wanted. The trouble with that was that it'd have had to be marked volatile, thereby defeating any ability to optimize conditions using it. By splitting into three functions, we were able to limit the "volatile" label to clock_timestamp(). regards, tom lane