Skip site navigation (1) Skip section navigation (2)

Re: Fix for timestamp rouding

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>,PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Fix for timestamp rouding
Date: 2005-05-26 18:46:31
Message-ID: 4172.1117133191@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> OK, I have a new patch, which simplifies the code by using
> TrimTrailingZeros(), gives more consistent subsecond display, and
> subpresses the rounding problem:

Does anyone have any idea why the existing code is designed to keep the
number of displayed fractional digits even?   It seems a bit silly to
me too, but we probably ought not remove what was clearly an intentional
behavior without understanding why it was intentional.

Also, I will point out once more that the problem is not "we only have
nine digits of precision not ten".  The problem is that the precision
degrades as the interval gets larger.

regression=# select '20 days 15 hours 57 mins 12.1 secs ago'::interval;
           interval
-------------------------------
 -20 days -15:57:12.1000000001
(1 row)

regression=# select '100020 days 15 hours 57 mins 12.1 secs ago'::interval;
             interval
-----------------------------------
 -100020 days -15:57:12.1000003815
(1 row)

regression=# select '100000020 days 15 hours 57 mins 12.1 secs ago'::interval;
              interval
-------------------------------------
 -100000020 days -15:57:12.099609375
(1 row)

regression=#

Without accounting for that fundamental fact, you will not have a
solution, only a kluge.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Joe ConwayDate: 2005-05-26 19:06:44
Subject: Re: ARRAY() returning NULL instead of ARRAY[] resp. {}
Previous:From: Bruce MomjianDate: 2005-05-26 18:18:08
Subject: Fix for timestamp rouding

pgsql-patches by date

Next:From: Joe ConwayDate: 2005-05-26 19:06:44
Subject: Re: ARRAY() returning NULL instead of ARRAY[] resp. {}
Previous:From: Bruce MomjianDate: 2005-05-26 18:18:08
Subject: Fix for timestamp rouding

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group