postgresql/src/backend/utils/adt
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
..
acl.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
amutils.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
array_expanded.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
array_selfuncs.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
array_typanalyze.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
array_userfuncs.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
arrayfuncs.c Fix handling of empty arrays in array_fill(). 2017-01-05 11:33:51 -05:00
arrayutils.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
ascii.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
bool.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
cash.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
char.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
date.c Allow negative years in make_date to represent BC years 2017-01-19 09:45:38 -03:00
datetime.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
datum.c Don't invoke arbitrary code inside a possibly-aborted transaction. 2017-01-24 08:57:10 -05:00
dbsize.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
domains.c Remove obsoleted code relating to targetlist SRF evaluation. 2017-01-19 14:40:41 -08:00
encode.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
enum.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
expandeddatum.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
float.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
format_type.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
formatting.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
genfile.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
geo_ops.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
geo_selfuncs.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
geo_spgist.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
inet_cidr_ntop.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
inet_net_pton.c Fix validation of overly-long IPv6 addresses. 2016-06-16 17:16:32 -04:00
int.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
int8.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
json.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
jsonb.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
jsonb_gin.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
jsonb_op.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
jsonb_util.c Introduce convenience macros to hide JsonbContainer header accesses better. 2017-01-25 13:28:38 -05:00
jsonfuncs.c Introduce convenience macros to hide JsonbContainer header accesses better. 2017-01-25 13:28:38 -05:00
levenshtein.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
like.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
like_match.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
lockfuncs.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
mac.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
Makefile Create an SP-GiST opclass for inet/cidr. 2016-08-23 15:16:30 -04:00
misc.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
nabstime.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
name.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
network.c Move code shared between libpq and backend from backend/libpq/ to common/. 2016-09-02 13:49:59 +03:00
network_gist.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
network_selfuncs.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
network_spgist.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
numeric.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
numutils.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
oid.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
oracle_compat.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
orderedsetaggs.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
pg_locale.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
pg_lsn.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
pg_upgrade_support.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
pgstatfuncs.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
pseudotypes.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
quote.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
rangetypes.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
rangetypes_gist.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
rangetypes_selfuncs.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
rangetypes_spgist.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
rangetypes_typanalyze.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
regexp.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
regproc.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
ri_triggers.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
rowtypes.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
ruleutils.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
selfuncs.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
tid.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
timestamp.c Fix roundoff problems in float8_timestamptz() and make_interval(). 2017-02-08 18:04:59 -05:00
trigfuncs.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
tsginidx.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
tsgistidx.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
tsquery.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
tsquery_cleanup.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
tsquery_gist.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
tsquery_op.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
tsquery_rewrite.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
tsquery_util.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
tsrank.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
tsvector.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
tsvector_op.c Ensure that a tsquery like '!foo' matches empty tsvectors. 2017-01-26 12:18:07 -05:00
tsvector_parser.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
txid.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
uuid.c Make messages mentioning type names more uniform 2017-01-18 16:08:20 -03:00
varbit.c Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
varchar.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
varlena.c Move some things from builtins.h to new header files 2017-01-20 20:29:53 -05:00
version.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
windowfuncs.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
xid.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
xml.c Remove obsoleted code relating to targetlist SRF evaluation. 2017-01-19 14:40:41 -08:00