From f076b3840e0f7786b1812205b6e7daea43f104f9 Mon Sep 17 00:00:00 2001 From: hezuojiao Date: Tue, 12 Sep 2023 10:14:05 +0000 Subject: [PATCH] [CP] Fix incorrent ret code when buffer is full during number formatting --- deps/oblib/src/lib/number/ob_number_v2.cpp | 9 ++++----- deps/oblib/src/rpc/obmysql/ob_mysql_row.cpp | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/deps/oblib/src/lib/number/ob_number_v2.cpp b/deps/oblib/src/lib/number/ob_number_v2.cpp index 58150f5f80..787926ad59 100644 --- a/deps/oblib/src/lib/number/ob_number_v2.cpp +++ b/deps/oblib/src/lib/number/ob_number_v2.cpp @@ -3255,13 +3255,12 @@ int ObNumber::format_v2( bool is_finish = false; const int64_t orig_pos = pos; const int64_t max_need_size = get_max_format_length() + ((!is_oracle_mode() && scale > 0) ? scale : 0); - if (OB_ISNULL(buf) - || OB_UNLIKELY((buf_len - pos) < 0)) { + if (OB_ISNULL(buf) || OB_UNLIKELY(max_need_size < 0)) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("argument is invalid", KP(buf), K(buf_len), K(pos), K(ret)); + LOG_WARN("argument is invalid", KP(buf), K(max_need_size), K(ret)); } else if (OB_UNLIKELY((buf_len - pos) < max_need_size)) { - ret = OB_SIZE_OVERFLOW; - LOG_TRACE("size is overflow", K(buf_len), K(pos), K(max_need_size), + ret = OB_SIZE_OVERFLOW; + LOG_TRACE("size is overflow", K(buf_len), K(pos), K(max_need_size), KPC(this), K(scale), K(ret)); } else if (OB_FAIL(format_int64(buf, pos, scale, is_finish))) { LOG_ERROR("format_int64 failed", KPC(this), K(ret)); diff --git a/deps/oblib/src/rpc/obmysql/ob_mysql_row.cpp b/deps/oblib/src/rpc/obmysql/ob_mysql_row.cpp index 0e58ee2ed7..1f9121e267 100644 --- a/deps/oblib/src/rpc/obmysql/ob_mysql_row.cpp +++ b/deps/oblib/src/rpc/obmysql/ob_mysql_row.cpp @@ -62,10 +62,10 @@ int ObMySQLRow::serialize(char *buf, const int64_t len, int64_t &pos) const } if (OB_FAIL(ret)) { - pos = pos_bk; if (OB_LIKELY(OB_SIZE_OVERFLOW != ret && OB_BUF_NOT_ENOUGH != ret)) { - LOG_WARN("serialize ob row fail", K(ret)); + LOG_WARN("serialize ob row fail", K(ret), K(len), K(pos), K(pos_bk)); } + pos = pos_bk; } return ret; }