bugfix : with ascii opt in json expr & json to bit in mysql & json uint to datetime & implicit cast in mysql

This commit is contained in:
obdev
2023-10-08 04:47:30 +00:00
committed by ob-robot
parent 9c0e0071ed
commit ac031addc0
8 changed files with 108 additions and 31 deletions

View File

@ -195,9 +195,9 @@ int ObExprJsonArray::eval_ora_json_array(const ObExpr &expr, ObEvalCtx &ctx, ObD
if (OB_FAIL(ret)) {
} else if (OB_FAIL(ObJsonExprHelper::eval_oracle_json_val(
expr.args_[i], ctx, &temp_allocator, j_val, is_format_json, is_strict, false))) {
expr.args_[i], ctx, &temp_allocator, j_val, is_format_json, is_strict, false, is_null_absent))) {
LOG_WARN("failed to get json value node.", K(ret), K(val_type));
} else if (is_null_absent && j_val->json_type() == ObJsonNodeType::J_NULL) {
} else if (OB_ISNULL(j_val)) {
} else if (OB_FAIL(j_arr.append(static_cast<ObJsonNode*>(j_val)))) {
LOG_WARN("failed to append in array.", K(ret), K(i));
}

View File

@ -314,7 +314,8 @@ int ObJsonExprHelper::eval_oracle_json_val(ObExpr *expr,
ObIJsonBase*& j_base,
bool is_format_json,
bool is_strict,
bool is_bin)
bool is_bin,
bool is_absent_null)
{
INIT_SUCC(ret);
ObDatum *json_datum = nullptr;
@ -323,6 +324,8 @@ int ObJsonExprHelper::eval_oracle_json_val(ObExpr *expr,
if (OB_FAIL(json_arg->eval(ctx, json_datum))) {
LOG_WARN("eval json arg failed", K(ret), K(json_arg->datum_meta_));
} else if ((json_datum->is_null() || ob_is_null(json_arg->obj_meta_.get_type()))
&& is_absent_null) {
} else if (OB_FAIL(oracle_datum2_json_val(json_datum,
json_arg->obj_meta_,
allocator,
@ -1598,7 +1601,7 @@ int ObJsonExprHelper::calc_asciistr_in_expr(const ObString &src,
} else {
buf[pos++] = '\\';
}
if (OB_SUCC(ret)) {
if (OB_SUCC(ret) && '\\' != wchar) {
int64_t hex_writtern_bytes = 0;
if (OB_FAIL(hex_print(temp_buf + i*utf16_minmb_len, utf16_minmb_len,
buf + pos, buf_len - pos, hex_writtern_bytes))) {

View File

@ -98,7 +98,7 @@ public:
bool format_json = false, bool is_strict = false, bool is_bin = false);
static int eval_oracle_json_val(ObExpr *expr, ObEvalCtx &ctx, common::ObIAllocator *allocator,
ObIJsonBase*& j_base, bool format_json = false, bool is_strict = false, bool is_bin = false);
ObIJsonBase*& j_base, bool format_json = false, bool is_strict = false, bool is_bin = false, bool is_absent_null = false);
/*
replace json_old with json_new in json_doc

View File

@ -332,7 +332,7 @@ int ObExprJsonObject::eval_ora_json_object(const ObExpr &expr, ObEvalCtx &ctx, O
bool is_format_json = format_type > 0;
if (OB_FAIL(ObJsonExprHelper::eval_oracle_json_val(
arg_value, ctx, &temp_allocator, j_val, is_format_json, is_strict, false))) {
arg_value, ctx, &temp_allocator, j_val, is_format_json, is_strict, false, is_null_absent))) {
LOG_WARN("failed to get json value node.", K(ret), K(value_data_type), K(i));
} else {
bool is_key_already_exist = (j_obj.get_value(key) != nullptr);
@ -340,7 +340,7 @@ int ObExprJsonObject::eval_ora_json_object(const ObExpr &expr, ObEvalCtx &ctx, O
if (is_key_already_exist && is_key_unique) {
ret = OB_ERR_DUPLICATE_KEY;
LOG_WARN("Found duplicate key inserted before!", K(key), K(ret));
} else if (is_null_absent && j_val->json_type() == ObJsonNodeType::J_NULL) {
} else if (OB_ISNULL(j_val)) {
} else if (OB_FAIL(j_obj.add(key, static_cast<ObJsonNode*>(j_val), false, false, is_overwrite))) {
LOG_WARN("failed to get json value node.", K(ret), K(val_type));
}