From 8b3739715701b3f8af7bf39dbf36baea7c24ce0e Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 9 Feb 2024 14:40:34 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddump=E7=9A=84=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98=EF=BC=8C=E5=9C=A8=E8=B6=85?= =?UTF-8?q?=E5=87=BABUF=E6=97=B6=E8=BF=9B=E8=A1=8C=E6=88=AA=E6=96=AD?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sql/engine/expr/ob_expr_func_dump.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/sql/engine/expr/ob_expr_func_dump.cpp b/src/sql/engine/expr/ob_expr_func_dump.cpp index ee609a09a2..55a8c13b98 100644 --- a/src/sql/engine/expr/ob_expr_func_dump.cpp +++ b/src/sql/engine/expr/ob_expr_func_dump.cpp @@ -26,7 +26,7 @@ using namespace common; namespace sql { -const int64_t MAX_DUMP_BUFFER_SIZE = 1024; +const int64_t MAX_DUMP_BUFFER_SIZE = 4000; const char *CONST_HEADER = "Typ=%d Len=%ld: "; enum ReturnFormat { @@ -76,11 +76,15 @@ int print_value(char *tmp_buf, const int64_t buff_size, int64_t &pos, for (int64_t i = 0; i < print_value_string.length() && OB_SUCC(ret); ++i) { if (isprint(print_value_string[i])) { if (OB_FAIL(databuff_printf(tmp_buf, buff_size, pos, "%c,", print_value_string[i]))) { - LOG_WARN("failed to databuff_printf", K(ret), K(pos)); + if (OB_SIZE_OVERFLOW != ret) { + LOG_WARN("failed to databuff_printf", K(ret), K(pos)); + } } } else { if (OB_FAIL(databuff_printf(tmp_buf, buff_size, pos, "%x,", (unsigned)(unsigned char)print_value_string[i]))) { - LOG_WARN("failed to databuff_printf", K(ret), K(pos)); + if (OB_SIZE_OVERFLOW != ret) { + LOG_WARN("failed to databuff_printf", K(ret), K(pos)); + } } } } @@ -92,10 +96,15 @@ int print_value(char *tmp_buf, const int64_t buff_size, int64_t &pos, for (int64_t i = 0; i < print_value_string.length() && OB_SUCC(ret); ++i) { if (OB_FAIL(databuff_printf(tmp_buf, buff_size, pos, fmt_str, (unsigned)(unsigned char)print_value_string[i]))) { - LOG_WARN("failed to databuff_printf", K(ret), K(pos)); + if (OB_SIZE_OVERFLOW != ret) { + LOG_WARN("failed to databuff_printf", K(ret), K(pos)); + } } } } + if (OB_SIZE_OVERFLOW == ret) { + ret = common::OB_SUCCESS; // result string length > MAX_DUMP_BUFFER_SIZE, cut the result string and return + } } if (OB_SUCC(ret)) { @@ -631,7 +640,7 @@ int ObExprFuncDump::eval_dump(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_ bool dumped = false; if (OB_FAIL(databuff_printf(buf, buf_len, buf_pos, CONST_HEADER, expr.args_[0]->datum_meta_.type_, - static_cast(input->len_)))) { + min(static_cast(input->len_), MAX_DUMP_BUFFER_SIZE)))) { LOG_WARN("data buffer print fail", K(ret)); } else if (ReturnFormat::RF_OB_SEPC == fmt_val) { if (OB_FAIL(dump_ob_spec(buf, buf_len, buf_pos, dumped, *expr.args_[0], *input))) {