Re: [SQL] timespan problem

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tulassay Zsolt <zsolt(at)tek(dot)bke(dot)hu>, pgsql-sql(at)hub(dot)org
Subject: Re: [SQL] timespan problem
Date: 2000-01-03 08:48:10
Message-ID: 3870624A.BA0E8BE5@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> The problem appears to be an internal
> overflow in timespan_in...
> Looking into it, the guilty party seems to be tm2timespan() which
> blithely assumes that it need not worry about overflow from its
> "time" field to its "month" field:
> span->month = ((tm->tm_year * 12) + tm->tm_mon);
> span->time = ((((((tm->tm_mday * 24) + tm->tm_hour) * 60) +
> tm->tm_min) * 60) + tm->tm_sec);
> span->time = JROUND(span->time + fsec);
> Thomas, you want to deal with this one?

Sure. In the meantime, change the "24" to "24.0" (in the file
src/backend/utils/adt/dt.c around line 2444; hmm, is that line number
a coincidence??) and things will start working :(

btw, there is no possibility for overflow from "time" to "month"; see
below...

> Or is this code all going away in 7.0 anyway?

No, the code is likely to stay since timespan needs to distinguish
between "qualitative time" like months and years and "quantitative
time" like hours and seconds. "time" is stored as a double, but the
calculation was being done with all integers, which lead to the
overflow problem in intermediate results.

Sorry about that. Will commit changes soon.

- Thomas

--
Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
South Pasadena, California

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-01-03 15:05:15 Re: [SQL] timespan problem
Previous Message Thomas Lockhart 2000-01-03 07:38:40 Re: [SQL] timespan problem