Re: Why extract( ... from timestamp ) is not immutable? - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: Why extract( ... from timestamp ) is not immutable?
Date
Msg-id 20120125163017.GA13120@depesz.com
Whole thread Raw
In response to Re: Why extract( ... from timestamp ) is not immutable?  (Adrian Klaver <adrian.klaver@gmail.com>)
Responses Re: Why extract( ... from timestamp ) is not immutable?  (Adrian Klaver <adrian.klaver@gmail.com>)
List pgsql-general
On Wed, Jan 25, 2012 at 08:22:26AM -0800, Adrian Klaver wrote:
> The issue seems to be the definition of same arguments. Since epoch is anchored
> at 1970-01-01 00:00:00 UTC the timestamp passed to extract need to be normalized
> to UTC.  Once a timestamp is in UTC then the epoch can be determined. The
> variability lies in the initial data fed to the function. Since time does not
> stand still, every time you do now() you are getting a different argument. Throw
> in time zone considerations and you see the results you are getting.

??? Sorry?
what are you talking about?

Simple:
extract(epoch from '2012-01-01 12:34:56'::timestamp)
which doesn't contain now(), is not immutable.

Personally, I think that extract(epoch from timestamp) should assume
that the timestamp is UTC.
Or that there should be a way to do it - by "it" i mean - extract epoch
value from timestamp value in immutable way.

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Why extract( ... from timestamp ) is not immutable?
Next
From: Tom Lane
Date:
Subject: Re: Why extract( ... from timestamp ) is not immutable?