]> git.ipfire.org Git - thirdparty/postgresql.git/commit
I think I've finally identified the cause of the off-by-one-second
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 31 May 2004 18:32:23 +0000 (18:32 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 31 May 2004 18:32:23 +0000 (18:32 +0000)
commita757fd70e56a2e6c147f9947b305f681150fca9f
tree67502329a9b0dfd9ca0078d2fc78256d20a00fbc
parent54427e9a1b47b8dd6681d927ce1460ebe6b8cb9a
I think I've finally identified the cause of the off-by-one-second
issue in timestamp conversion that we hacked around for so long by
ignoring the seconds field from localtime().  It's simple: you have
to watch out for platform-specific roundoff error when reducing a
possibly-fractional timestamp to integral time_t form.  In particular
we should subtract off the already-determined fractional fsec field.
This should be enough to get an exact answer with int64 timestamps;
with float timestamps, throw in a rint() call just to be sure.
src/backend/utils/adt/timestamp.c