fix json-array exceeding max depth bug

This commit is contained in:
obdev
2023-09-13 04:17:18 +00:00
committed by ob-robot
parent b8b81a070c
commit 105d1b66c2
2 changed files with 11 additions and 4 deletions

View File

@ -3544,7 +3544,9 @@ int ObIJsonBase::print_object(ObJsonBuffer &j_buf, uint64_t depth, bool is_prett
LOG_WARN("fail to get key", K(ret), K(i));
} else if (is_pretty && OB_FAIL(ObJsonBaseUtil::append_newline_and_indent(j_buf, depth))) {
LOG_WARN("fail to newline and indent", K(ret), K(depth), K(i), K(key));
} else if (OB_FAIL(ObJsonBaseUtil::append_string(j_buf, true, key.ptr(), key.length()))) { // key
} else if (key.empty() && OB_FAIL(ObJsonBaseUtil::append_string(j_buf, false, "\"\"", 2))) {
LOG_WARN("fail to newline and indent", K(ret), K(depth), K(i), K(key));
} else if (!key.empty() && OB_FAIL(ObJsonBaseUtil::append_string(j_buf, true, key.ptr(), key.length()))) { // key
LOG_WARN("fail to print string", K(ret), K(depth), K(i), K(key));
} else if (OB_FAIL(j_buf.append(":"))) {
LOG_WARN("fail to append \":\"", K(ret), K(depth), K(i), K(key));

View File

@ -204,11 +204,13 @@ int ObExprJsonArray::eval_ora_json_array(const ObExpr &expr, ObEvalCtx &ctx, ObD
}
if (OB_SUCC(ret)) {
ObJsonBuffer string_buffer(&temp_allocator);
ObString res_string;
if (dst_type == ObJsonType) {
if (ObJsonParser::is_json_doc_over_depth(j_arr.depth())) {
ret = OB_ERR_JSON_OUT_OF_DEPTH;
LOG_WARN("current json over depth", K(ret), K(j_arr.depth()));
} else if (dst_type == ObJsonType) {
if (OB_FAIL(j_arr.get_raw_binary(res_string, &temp_allocator))) {
LOG_WARN("failed: get json raw binary", K(ret));
}
@ -267,7 +269,10 @@ int ObExprJsonArray::eval_json_array(const ObExpr &expr, ObEvalCtx &ctx, ObDatum
if (OB_SUCC(ret)) {
ObString raw_bin;
if (OB_FAIL(j_base->get_raw_binary(raw_bin, &temp_allocator))) {
if (ObJsonParser::is_json_doc_over_depth(j_arr.depth())) {
ret = OB_ERR_JSON_OUT_OF_DEPTH;
LOG_WARN("current json over depth", K(ret), K(j_arr.depth()));
} else if (OB_FAIL(j_base->get_raw_binary(raw_bin, &temp_allocator))) {
LOG_WARN("failed: json get binary", K(ret));
} else if (OB_FAIL(ObJsonExprHelper::pack_json_str_res(expr, ctx, res, raw_bin))) {
LOG_WARN("fail to pack json result", K(ret));