Robert Haas <robertmhaas@gmail.com> writes:
> Couldn't you apply this argument to any built-in immutable function whatsoever?
No, only the ones that are built on top of other functions that aren't
immutable.
I did go looking for other potential problems of the same ilk. The only
one I can find at present is to_timestamp(double), which is an immutable
SQL function but it uses timestamptz + interval, which is marked as not
immutable. I believe the reason for that is that if the interval
includes month or day components then the addition result can depend on
the timezone setting. However, the usage in to_timestamp() involves only
a pure seconds component so the immutable marking should be correct.
Still, we might want to think about reimplementing to_timestamp() as a
pure C function sometime, because the current implementation is many
times slower than it needs to be.
regards, tom lane