pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Lockhart <lockhart@alumni.caltech.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tulassay Zsolt <zsolt@tek.bke.hu>
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] timespan problem
Date: Mon, 03 Jan 2000 08:48:10 +0000
Message-ID: <3870624A.BA0E8BE5@alumni.caltech.edu> (raw)
References: <Pine.LNX.4.10.10001012142220.17313-100000@tek.bke.hu>
	<20530.946771110@sss.pgh.pa.us>

> 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@alumni.caltech.edu
South Pasadena, California



view thread (5+ messages)  latest in thread

Message-ID: <3870624A.BA0E8BE5@alumni.caltech.edu>
Permalink:  ../3870624A.BA0E8BE5@alumni.caltech.edu/
Also on:    postgresql.org/message-id/3870624A.BA0E8BE5@alumni.caltech.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: lockhart@alumni.caltech.edu, tgl@sss.pgh.pa.us, zsolt@tek.bke.hu, pgsql-sql@hub.org
  Subject: Re: [SQL] timespan problem
  In-Reply-To: <3870624A.BA0E8BE5@alumni.caltech.edu>
  References: <Pine.LNX.4.10.10001012142220.17313-100000@tek.bke.hu> <20530.946771110@sss.pgh.pa.us> <3870624A.BA0E8BE5@alumni.caltech.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox