[BUGFIX] fix uncompress process empty lob res

This commit is contained in:
obdev
2024-02-08 07:25:17 +00:00
committed by ob-robot
parent 9d8405a821
commit cda996a664

View File

@ -141,7 +141,8 @@ static int eval_uncompress_length(const ObExpr &expr,
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (str_val.empty()) { 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))) { } else if (OB_UNLIKELY((str_val.length() <= COMPRESS_HEADER_LEN))) {
expr_datum.set_null(); expr_datum.set_null();
LOG_USER_WARN(OB_ERR_ZLIB_DATA); 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; int64_t buf_size = 0;
if (OB_FAIL(output_result.init(orig_len))) { if (OB_FAIL(output_result.init(orig_len))) {
LOG_WARN("init stringtext result failed"); LOG_WARN("init stringtext result failed");
} else if (OB_FAIL(output_result.get_reserved_buffer(buf, buf_size))) { } else if (orig_len > 0) {
LOG_WARN("stringtext result reserve buffer failed"); if (OB_FAIL(output_result.get_reserved_buffer(buf, buf_size))) {
} else if (OB_UNLIKELY(Z_OK != uncompress(reinterpret_cast<unsigned char*>(buf), &orig_len, LOG_WARN("stringtext result reserve buffer failed");
reinterpret_cast<const unsigned char*>(str_val.ptr() + COMPRESS_HEADER_LEN), str_val.length()))) { } else if (OB_UNLIKELY(Z_OK != uncompress(reinterpret_cast<unsigned char*>(buf), &orig_len,
expr_datum.set_null(); reinterpret_cast<const unsigned char*>(str_val.ptr() + COMPRESS_HEADER_LEN), str_val.length()))) {
LOG_USER_WARN(OB_ERR_ZLIB_DATA); expr_datum.set_null();
} else if (OB_FAIL(output_result.lseek(orig_len, 0))) { LOG_USER_WARN(OB_ERR_ZLIB_DATA);
LOG_WARN("result lseek failed", K(ret)); } else if (OB_FAIL(output_result.lseek(orig_len, 0))) {
LOG_WARN("result lseek failed", K(ret));
} else {
output_result.set_result();
}
} else { } else {
output_result.set_result(); output_result.set_result();
} }