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

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: Why *exactly* is date_trunc() not immutable ?
Дата
Msg-id 20070218114451.GK5088@merkur.hilbert.loc
обсуждение исходный текст
Ответ на Why *exactly* is date_trunc() not immutable ?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: Why *exactly* is date_trunc() not immutable ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Why *exactly* is date_trunc() not immutable ?  ("jungmin shin" <jungmin.shin@gmail.com>)
Список pgsql-general
followup to self:

On Sun, Feb 18, 2007 at 12:29:17PM +0100, Karsten Hilbert wrote:

> So I figured it would make sense to add a functional index
> on date_trunc('day', dob) to the patients table. Which
> worked (appeared to, at least) with PG 7.4.
>
> One of our users is on PG 8.2
PostgreSQL 8.1 I was to say.

> and gets the warning that
> date_trunc() is not immutable and can thus not be used in a
> functional index.
The code to create the index:

    create index idx_identity_dob_ymd on dem.identity(date_trunc('day', dob))

The exact error it emits:

    functions in index expression must be marked IMMUTABLE

Those were lifted from the error log without further editing.

I know that I could fake immutability by wrapping
date_trunc() in a stored procedure marked IMMUTABLE but
I wonder what pitfalls that might hold.

Thanks,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

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

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Why *exactly* is date_trunc() not immutable ?
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: Why *exactly* is date_trunc() not immutable ?