diff --git a/src/sql/engine/expr/ob_expr_compress.cpp b/src/sql/engine/expr/ob_expr_compress.cpp index d00a3552fe..d11534db7e 100644 --- a/src/sql/engine/expr/ob_expr_compress.cpp +++ b/src/sql/engine/expr/ob_expr_compress.cpp @@ -141,7 +141,8 @@ static int eval_uncompress_length(const ObExpr &expr, { int ret = OB_SUCCESS; if (str_val.empty()) { - expr_datum.set_string(ObString::make_empty_string()); + orig_len = 0; + not_final = true; } else if (OB_UNLIKELY((str_val.length() <= COMPRESS_HEADER_LEN))) { expr_datum.set_null(); LOG_USER_WARN(OB_ERR_ZLIB_DATA); @@ -188,14 +189,18 @@ int ObExprUncompress::eval_uncompress(const ObExpr &expr, ObEvalCtx &ctx, ObDatu int64_t buf_size = 0; if (OB_FAIL(output_result.init(orig_len))) { LOG_WARN("init stringtext result failed"); - } else if (OB_FAIL(output_result.get_reserved_buffer(buf, buf_size))) { - LOG_WARN("stringtext result reserve buffer failed"); - } else if (OB_UNLIKELY(Z_OK != uncompress(reinterpret_cast(buf), &orig_len, - reinterpret_cast(str_val.ptr() + COMPRESS_HEADER_LEN), str_val.length()))) { - expr_datum.set_null(); - LOG_USER_WARN(OB_ERR_ZLIB_DATA); - } else if (OB_FAIL(output_result.lseek(orig_len, 0))) { - LOG_WARN("result lseek failed", K(ret)); + } else if (orig_len > 0) { + if (OB_FAIL(output_result.get_reserved_buffer(buf, buf_size))) { + LOG_WARN("stringtext result reserve buffer failed"); + } else if (OB_UNLIKELY(Z_OK != uncompress(reinterpret_cast(buf), &orig_len, + reinterpret_cast(str_val.ptr() + COMPRESS_HEADER_LEN), str_val.length()))) { + expr_datum.set_null(); + LOG_USER_WARN(OB_ERR_ZLIB_DATA); + } else if (OB_FAIL(output_result.lseek(orig_len, 0))) { + LOG_WARN("result lseek failed", K(ret)); + } else { + output_result.set_result(); + } } else { output_result.set_result(); }