From abea9481b7985fb2d9cf69eeddea3a8297e96ccd Mon Sep 17 00:00:00 2001 From: Gagan Goel Date: Thu, 19 Sep 2019 15:47:07 -0400 Subject: [PATCH] Preserve the sign when a double is -0 in fetchNextRow() --- dbcon/mysql/ha_calpont_impl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 67a524eef..0fe389a30 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -766,7 +766,15 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h // 2.2250738585072014E-308 to 1.7976931348623157E+308. (*f)->field_length = 310; - f2->store(dl); + // The server converts dl=-0 to dl=0 in f2->store(). + // This happens in the call to truncate_double(). + // This is an unexpected behaviour, so we directly store the + // double value using the lower level float8store() function. + // TODO Remove this when f2->store() handles this properly. + if (dl == 0) + float8store(f2->ptr,dl); + else + f2->store(dl); if ((*f)->null_ptr) *(*f)->null_ptr &= ~(*f)->null_bit;