Received: from smtp10.atl.mindspring.net (smtp10.atl.mindspring.net [207.69.200.246]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA67592 for ; Sun, 2 Jan 2000 10:36:05 -0500 (EST) (envelope-from lyman1@mindspring.com) From: lyman1@mindspring.com Received: from win98p266 (user-38lci7r.dialup.mindspring.com [209.86.72.251]) by smtp10.atl.mindspring.net (8.9.3/8.8.5) with SMTP id KAA23798 for ; Sun, 2 Jan 2000 10:36:03 -0500 (EST) Message-ID: <001b01bf5533$ce0e4d00$0201a8c0@win98p266> To: Subject: unsubscribe Date: Sun, 2 Jan 2000 10:12:36 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 unsubscribe -----Original Message----- From: pgsql-sql-digest To: pgsql-sql-digest@hub.org Date: Saturday, January 01, 2000 11:00 PM Subject: pgsql-sql-digest V1 #453 > >pgsql-sql-digest Saturday, January 1 2000 Volume 01 : Number 453 > > > >Index: > >timespan problem >Re: [SQL] timespan problem > >---------------------------------------------------------------------- > >Date: Sat, 1 Jan 2000 21:48:47 +0100 (CET) >From: Tulassay Zsolt >Subject: timespan problem > >hi, >i ran into a strange result using the timespan type. No, >it's not related to y2k, but i don't know whether it is a >bug or i just used wrong typecasting. >here it is: > > >forum=> select datetime(now()) as ido; >ido >- ---------------------------- >Sat Jan 01 21:35:32 2000 CET >(1 row) > >forum=> select datetime(now())+'74565 days'::timespan as ido; >ido >- ------------------------ >Thu Jan 19 14:07:30 2068 >(1 row) > >forum=> select datetime(now())+'74566 days'::timespan as ido; >ido >- ---------------------------- >Tue Dec 15 08:39:21 1931 CET >(1 row) > >forum=> select datetime(now())+'70 years'::timespan as ido; >ido >- ------------------------ >Wed Jan 01 20:36:01 2070 >(1 row) > >forum=> > > >I don't see anything wrong in the third query, but the result >is a bit surprising... and notice the error in the second query >too: the time fields don't match. > >I'm using version 6.5.2 on Red Hat Linux 6.0 > >Zsolt Tulassay >zsolt@tek.bke.hu > >------------------------------ > >Date: Sat, 01 Jan 2000 18:58:30 -0500 >From: Tom Lane >Subject: Re: [SQL] timespan problem > >Tulassay Zsolt writes: >> forum=> select datetime(now())+'74565 days'::timespan as ido; >> ido >> ------------------------ >> Thu Jan 19 14:07:30 2068 >> (1 row) > >> forum=> select datetime(now())+'74566 days'::timespan as ido; >> ido >> ---------------------------- >> Tue Dec 15 08:39:21 1931 CET >> (1 row) > >Of course, both of the above are drastically wrong, since 74575 days >should be upwards of 200 years. The problem appears to be an internal >overflow in timespan_in, since you can show wrong results just with: > >regression=> select '74565 days'::timespan; >?column? >- ------------------------------------- >@ 24854 days 17 hours 31 mins 44 secs >(1 row) > >regression=> select '74566 days'::timespan; >?column? >- ----------------------------------------- >@ 24854 days 12 hours 56 mins 32 secs ago >(1 row) > >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? Or is this code all going >away in 7.0 anyway? > > regards, tom lane > >------------------------------ > >End of pgsql-sql-digest V1 #453 >******************************* > > >************