Re: BUG #1993: Adding/subtracting negative time intervals

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1993: Adding/subtracting negative time intervals
Date: 2005-10-26 19:10:43
Message-ID: slrndlvl5j.g61.andrew+nonews@trinity.supernews.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2005-10-26, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew - Supernews <andrew+nonews(at)supernews(dot)com> writes:
>> Um, what? Under what conditions is it permissable for simple arithmetic on
>> (only) timestamptz values (which may have originated in different timezones
>> neither of which is the current one) to be dependent on the current timezone
>> setting?
>
> Timestamp subtraction will give different answers depending on whether
> there's a DST adjustment in between.

no, it _WILL NOT_.

In your example, the result is different between timezones because the
_input data_ is different. '2005-10-31'::timestamptz designates a different
time in US/Eastern than it does in Japan, or UTC, or whatever.

Or to put it in terms of the code: in 8.0, timestamptz_in is stable
rather than immutable (since it depends on timezone), while timestamptz_mi
is immutable (result depends only on the input values).

In 8.0, I'm guaranteed that for timestamptz values, a+(b-a) = b in all
cases regardless of timezone. 8.1 has broken that.

> BTW, if we were doing subtraction symbolically as I think we should,
> these *would* give the same answer, ie, '3 days' in both cases. Care to
> rethink your opposition to that idea?

No. If you want symbolic subtraction, that's what age() is for. If you
break the subtraction operator, you leave no means of doing _accurate_
subtraction.

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2005-10-27 02:53:13 Re: BUG #1993: Adding/subtracting negative time intervals
Previous Message Tom Lane 2005-10-26 16:30:04 Re: Index name different from constraint name

Browse pgsql-hackers by date

  From Date Subject
Next Message Alon Goldshuv 2005-10-26 19:20:41 Re: Libpq optimization
Previous Message Tom Lane 2005-10-26 18:59:55 Re: pidfile location missing after restarting crashed server in 8.1