Thread: BUG #4853: millisecond is incorrect?

BUG #4853: millisecond is incorrect?

From
"Hiromichi Nakajima"
Date:
The following bug has been logged online:

Bug reference:      4853
Logged by:          Hiromichi Nakajima
Email address:      hirolin7@yahoo.co.jp
PostgreSQL version: 8.3.7
Operating system:   RedHatEnterpriseLinux ES3
Description:        millisecond is incorrect?
Details:

for example
'OPE_DATE' field is timestamp with time zone.
I execute sql below:
INSERT INTO A_TBL  ( OPE_DATE) VALUES  ( '2009-06-15 18:29:58.156')
and show value with sql below:
select TO_CHAR ( OP_DATE, 'YYYY-MM-DD HH24:MI:SS.MS.US')
It must show as '2009-06-15 18:29:58.156.156000'
but sometimes '2009-06-15 18:29:58.156.155999'
Is it bug?
This doesn't occur on 8.2.4.
Thank you.

Re: BUG #4853: millisecond is incorrect?

From
Tom Lane
Date:
"Hiromichi Nakajima" <hirolin7@yahoo.co.jp> writes:
> I execute sql below:
> INSERT INTO A_TBL  ( OPE_DATE) VALUES  ( '2009-06-15 18:29:58.156')
> and show value with sql below:
> select TO_CHAR ( OP_DATE, 'YYYY-MM-DD HH24:MI:SS.MS.US')
> It must show as '2009-06-15 18:29:58.156.156000'
> but sometimes '2009-06-15 18:29:58.156.155999'
> Is it bug?

No, it's an inherent consequence of the fact that floating-point
timestamps aren't infinitely precise.

> This doesn't occur on 8.2.4.

The 8.2 coding had a different set of problems :-(
http://archives.postgresql.org/pgsql-bugs/2007-02/msg00090.php

            regards, tom lane