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

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 14:12:18
Message-ID: 20070218141217.GM5088@merkur.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Feb 18, 2007 at 09:19:43PM +0900, Michael Glaesemann wrote:

> >What I don't understand, however, is exactly *why* date_trunc is
> >not immutable ?
>
> I believe it's because the result of date_trunc depends on the time
> zone setting for the session.

...

> So, given the same arguments, ('day', and current_timestamp),
> date_trunc is returning two different results. (Casting to date has
> the same issue.)

Ah, I see. That makes sense.

Now, if I'd write a

date_trunc_utc(precision, timestamp with time zone)

which converts input timestamps to UTC I could fairly safely
mark that IMMUTABLE, no ?

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2007-02-18 14:59:49 Re: open source - content management system - that uses PostGreSQL
Previous Message John DeSoi 2007-02-18 13:31:08 Re: Anticipatory privileges