From dc6fd172a28298a6f3479f3111ffc3f3357499dd Mon Sep 17 00:00:00 2001 From: XieHan Date: Fri, 22 Apr 2022 19:27:49 +0800 Subject: [PATCH] update MySQLCell::as_XXX error return values --- src/protocol/MySQLResult.inl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/protocol/MySQLResult.inl b/src/protocol/MySQLResult.inl index 2a66ffa7..24a01f10 100644 --- a/src/protocol/MySQLResult.inl +++ b/src/protocol/MySQLResult.inl @@ -16,6 +16,7 @@ Authors: Li Yingxin (liyingxin@sogou-inc.com) */ +#include #include #include #include "mysql_byteorder.h" @@ -189,7 +190,7 @@ inline bool MySQLCell::is_float() const inline float MySQLCell::as_float() const { if (!this->is_float()) - return 0; + return NAN; char num[MYSQL_FLOAT_STR_LENGTH + 1]; memcpy(num, this->data, this->len); @@ -205,7 +206,7 @@ inline bool MySQLCell::is_double() const inline double MySQLCell::as_double() const { if (!this->is_double()) - return 0; + return NAN; char num[MYSQL_DOUBLE_STR_LENGTH + 1]; memcpy(num, this->data, this->len); @@ -221,7 +222,7 @@ inline bool MySQLCell::is_ulonglong() const inline unsigned long long MySQLCell::as_ulonglong() const { if (!this->is_ulonglong()) - return 0; + return (unsigned long long)-1; char num[MYSQL_LONG_STR_LENGTH + 1]; memcpy(num, this->data, this->len);