Re: Error: timestamp with timezone + interval is not immutable while creating index

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: Error: timestamp with timezone + interval is not immutable while creating index
Дата
Msg-id 4E977906.1020208@pinpointresearch.com
обсуждение исходный текст
Ответ на Re: Error: timestamp with timezone + interval is not immutable while creating index  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Error: timestamp with timezone + interval is not immutable while creating index
Список pgsql-general
On 10/13/2011 04:32 PM, Tom Lane wrote:
> Phil Couling<couling@gmail.com>  writes:
>> main=>  create index foo_next_update on foo( (last_updated + update_cycle) ) ;
>> ERROR:  functions in index expression must be marked IMMUTABLE...
>
> timestamptz + interval is not immutable because the results can vary
> depending on timezone.  For instance, in my zone (America/New_York):
>
So it seems like a potential workaround, depending on the nature of your
data and applications, would be to convert the timestamptz into a
timestamp at a reference TZ:

steve=# create table testfoo (a_timestamptz timestamptz, an_interval
interval);
CREATE TABLE
steve=# create index testfoo_index on testfoo ((a_timestamptz at time
zone 'UTC' + an_interval));
CREATE INDEX

You will have to be sure you are getting the results you want in the
vicinity of DST changes and if you are handling multiple timezones.

Cheers,
Steve


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

Предыдущее
От: David Salisbury
Дата:
Сообщение: Re: Error: timestamp with timezone + interval is not immutable while creating index
Следующее
От: Tom Lane
Дата:
Сообщение: Re: exclusive OR possible within a where clause?