From 6cb6adfa7ef4c00c89f45f2b75ff7d5bcbbb471e Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 14 Apr 2023 02:41:29 +0000 Subject: [PATCH] Time hours convert to days and hours in prepare statement --- deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp b/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp index fb39c5c2f6..a4800a4a5b 100644 --- a/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp +++ b/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp @@ -675,13 +675,15 @@ int ObMySQLUtil::time_cell_str( LOG_WARN("convert usec to timestamp failed", K(ret)); } else { timelen = 12; + int ob_time_day = ob_time.parts_[DT_DATE] + ob_time.parts_[DT_HOUR] / 24; + int ob_time_hour = ob_time.parts_[DT_HOUR] % 24; if (OB_FAIL(ObMySQLUtil::store_int1(buf, len, timelen, pos))) {//length LOG_WARN("fail to store int", K(ret)); } else if (OB_FAIL(ObMySQLUtil::store_int1(buf, len, static_cast(DT_MODE_NEG & ob_time.mode_), pos))) {//is_negative(1) LOG_WARN("fail to store int", K(ret)); - } else if (OB_FAIL(ObMySQLUtil::store_int4(buf, len, static_cast(ob_time.parts_[DT_DATE]), pos))) {//days(4) + } else if (OB_FAIL(ObMySQLUtil::store_int4(buf, len, static_cast(ob_time_day), pos))) {//days(4) LOG_WARN("fail to store int", K(ret)); - } else if (OB_FAIL(ObMySQLUtil::store_int1(buf, len, static_cast(ob_time.parts_[DT_HOUR]), pos))) {//hour(1) + } else if (OB_FAIL(ObMySQLUtil::store_int1(buf, len, static_cast(ob_time_hour), pos))) {//hour(1) LOG_WARN("fail to store int", K(ret)); } else if (OB_FAIL(ObMySQLUtil::store_int1(buf, len, static_cast(ob_time.parts_[DT_MIN]), pos))) {//minute(1) LOG_WARN("fail to store int", K(ret));