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

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Why *exactly* is date_trunc() not immutable ?
Дата
Msg-id 20070219095850.GC30737@svana.org
обсуждение исходный текст
Ответ на Re: Why *exactly* is date_trunc() not immutable ?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: Why *exactly* is date_trunc() not immutable ?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Список pgsql-general
On Mon, Feb 19, 2007 at 10:36:36AM +0100, Karsten Hilbert wrote:
> On Mon, Feb 19, 2007 at 10:16:12AM +0100, Alban Hertroys wrote:
>
> > 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.
> That is precisely why I didn't get the idea upfront that
> date_trunc() wouldn't be immutable just so.
>
> I'll solve it with a date_trunc_utc() wrapper.

It should be noted the date_truc(timestamptz) is not immutable, whereas
date_trunc(timestamp) is. Thus you should be able to make an index on:

date_trunc( timestamptz_column AT TIME ZONE 'UTC', 'foo' )

OTOH, if you're only storing times in UTC, then timestamp without
timezone might be better anyway.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

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

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: Why *exactly* is date_trunc() not immutable ?
Следующее
От: "Joris Dobbelsteen"
Дата:
Сообщение: Re: complex referential integrity constraints