| From: | Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Why *exactly* is date_trunc() not immutable ? |
| Date: | 2007-02-18 11:44:51 |
| Message-ID: | 20070218114451.GK5088@merkur.hilbert.loc |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Glaesemann | 2007-02-18 12:19:43 | Re: Why *exactly* is date_trunc() not immutable ? |
| Previous Message | Karsten Hilbert | 2007-02-18 11:29:17 | Why *exactly* is date_trunc() not immutable ? |