postgresql/src/backend/utils
Tom Lane 8f93bd8512 Fix roundoff problems in float8_timestamptz() and make_interval().
When converting a float value to integer microseconds, we should be careful
to round the value to the nearest integer, typically with rint(); simply
assigning to an int64 variable will truncate, causing apparently off-by-one
values in cases that should work.  Most places in the datetime code got
this right, but not these two.

float8_timestamptz() is new as of commit e511d878f (9.6).  Previous
versions effectively depended on interval_mul() to do roundoff correctly,
which it does, so this fixes an accuracy regression in 9.6.

The problem in make_interval() dates to its introduction in 9.4.  Aside
from being careful to round not truncate, let's incorporate the hours and
minutes inputs into the result with exact integer arithmetic, rather than
risk introducing roundoff error where there need not have been any.

float8_timestamptz() problem reported by Erik Nordström, though this is
not his proposed patch.  make_interval() problem found by me.

Discussion: https://postgr.es/m/CAHuQZDS76jTYk3LydPbKpNfw9KbACmD=49dC4BrzHcfPv6yA1A@mail.gmail.com
2017-02-08 18:04:59 -05:00
..
adt Fix roundoff problems in float8_timestamptz() and make_interval(). 2017-02-08 18:04:59 -05:00
cache Avoid returning stale attribute bitmaps in RelationGetIndexAttrBitmap(). 2017-02-06 13:20:19 -05:00
error Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
fmgr Fix typos in comments. 2017-02-06 11:33:58 +02:00
hash Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
init Fix typos in comments. 2017-02-06 11:33:58 +02:00
mb Add KOI8-U map files to Makefile. 2017-02-02 14:12:35 +02:00
misc Add WAL consistency checking facility. 2017-02-08 15:45:30 -05:00
mmgr Fix typos in comments. 2017-02-06 11:33:58 +02:00
resowner Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
sort Don't create "holes" in BufFiles, in the new logtape code. 2017-02-01 12:17:38 +02:00
time Fix typos in comments. 2017-02-06 11:33:58 +02:00
.gitignore Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
errcodes.txt Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
Gen_dummy_probes.pl Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
Gen_dummy_probes.sed Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
Gen_fmgrtab.pl Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
generate-errcodes.pl Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
Makefile Fix parallel make issue with new fmgrprotos.h 2017-01-23 15:36:27 -05:00
probes.d Update copyright via script for 2017 2017-01-03 13:48:53 -05:00