From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Hussein Patni <security(at)cosbit(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: problem creating rtree index on timestamptz |
Date: | 2005-02-28 22:13:05 |
Message-ID: | 2876.1109628785@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hussein Patni <security(at)cosbit(dot)com> writes:
> It seems subraction of an interval from a
> timestamptz is not immutable. Should this be the case?
Yes, because the results depend on your local timezone. For example:
regression=# set TimeZone TO 'EST5EDT';
SET
regression=# select '2005-02-28 17:00-05'::timestamptz - '6 months'::interval;
?column?
------------------------
2004-08-28 17:00:00-04
(1 row)
regression=# set TimeZone TO 'GMT';
SET
regression=# select '2005-02-28 17:00-05'::timestamptz - '6 months'::interval;
?column?
------------------------
2004-08-28 22:00:00+00
(1 row)
regression=# select '2004-08-28 17:00:00-04'::timestamptz - '2004-08-28 22:00:00+00';
?column?
-----------
-01:00:00
(1 row)
regression=#
It's probably true that subtracting an interval expressed in seconds (or
equivalent units) is an immutable operation, but we don't have a way to
capture that statement in data types, since there's no such restricted
interval datatype.
You might consider making a function defined like timestamptz - integer
(or float) in which the integer is considered as a number of seconds.
You could safely mark that as immutable, I think.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Clouse | 2005-03-01 02:04:30 | BUG #1512: Assertion failure (lock.c:1537) with SELECT FOR UPDATE and savepoints |
Previous Message | Hussein Patni | 2005-02-28 21:33:12 | problem creating rtree index on timestamptz |