Re: Interval overflow? - Mailing list pgsql-general

From Tom Lane
Subject Re: Interval overflow?
Date
Msg-id 8797.1183152692@sss.pgh.pa.us
Whole thread Raw
In response to Re: Interval overflow?  (Michael Glaesemann <grzm@seespotcode.net>)
Responses Re: Interval overflow?  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
Michael Glaesemann <grzm@seespotcode.net> writes:
> On Jun 29, 2007, at 16:07 , Jeff Davis wrote:
>> Is this expected behavior or a bug?

> Bug. In general the range checking in the date time code can
> definitely be improved.

Apparently Jeff's using enable-integer-datetimes; what I see is

regression=# select '2000000000 hours'::interval + '2000000000 hours'::interval;
     ?column?
------------------
 2147483647:00:00
(1 row)

It looks like his case is overflowing the int8 microseconds field of
the interval.  On my machine, the seconds field is double so it does not
overflow, but interval_out tries to convert the computed hours value
to int32, and *that* overflows.

The best we can do for Jeff is throw an error in interval addition.
In the float case it could be wished that we could print any result
we can store ...

            regards, tom lane

pgsql-general by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Interval overflow?
Next
From: ptjm@interlog.com (Patrick TJ McPhee)
Date:
Subject: Re: Move a database from one server to other