Re: Why *exactly* is date_trunc() not immutable ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Why *exactly* is date_trunc() not immutable ?
Дата
Msg-id 9690.1171898720@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Why *exactly* is date_trunc() not immutable ?  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
Alban Hertroys <alban@magproductions.nl> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Jerry LeVan
Дата:
Сообщение: Re: Synchronize tables question....
Следующее
От: "David Legault"
Дата:
Сообщение: Per Database Roles