Re: patch for datetime.c

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-patches(at)postgresql(dot)org" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: patch for datetime.c
Date: 2001-05-04 20:38:48
Message-ID: 3AF31358.EECAFD94@selectacast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
>
> Joseph Shraibman <jks(at)selectacast(dot)net> writes:
> > [root(at)d1 ~/postgresql-7.1/src/backend/utils/adt] diff -C 3
> > datetime.c.orig datetime.c
> > *** datetime.c.orig Thu May 3 21:16:37 2001
> > --- datetime.c Thu May 3 21:19:51 2001
> > ***************
> > *** 2087,2092 ****
> > --- 2087,2096 ----
>
> > sec = (tm->tm_sec + fsec);
>
> > + if (sec >= 59.995)
> > + sec = 59.99; /* Round down to avoid times like
> > 2001-05-03 21:18:60.00-04 */
> > +
> > +
> > switch (style)
> > {
> > /* compatible with ISO date formats */
>
> This is a horrid solution.

Well not horrid, but stopgap. There needed to be soemthing that kept
there from being 60 seconds in the output.

>
> The correct solution is to round the original timestamp to two
> fractional digits before it's ever broken down into y/m/d/h/m/s.

I was afraid to modify the timestamp object. I didn't know what side
affects that might have. And I wasn't sure how to create a timestamp
from another timestamp.
>
> At least if you only want two digits of precision. I think Thomas
> has been resisting making that change because he wants to allow
> displaying more than two digits, instead.
>
That was the other thing I considered, but I thought two digits was
there because it was standard.

> BTW, is there really only one routine with this problem?
>
Err, sort of. There is another method in the same file that operates on
time and appears to have the same bug, but times aren't supposed to have
fractional seconds.

playpen=# select '5:33:59.999'::time;
?column?
----------
05:33:59
(1 row)

So I'm not sure if that other function is a problem or not.

--
Joseph Shraibman
jks(at)selectacast(dot)net
Increase signal to noise ratio. http://www.targabot.com

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Ashley Clark 2001-05-05 17:09:33 Strange notices, should I worry?
Previous Message Tom Lane 2001-05-04 20:11:15 Re: patch for datetime.c