[CP]: Oracle json bugfix

This commit is contained in:
obdev
2024-02-08 13:45:25 +00:00
committed by ob-robot
parent d5c68a0ef4
commit 6baacf7f0f
6 changed files with 169 additions and 215 deletions

View File

@ -92,14 +92,6 @@ int ObExprJsonEqual::eval_json_equal(const ObExpr &expr, ObEvalCtx &ctx, ObDatum
uint8_t option_on_error = 0;
// json数据解析出错或非标量,此时根据on error参数返回结果
bool is_cover_by_error = false;
bool both_json = false;
// 检查是否均为 json 类型,如果均为json类型,标量相比不报错
// 只要有一个参数不是json类型,标量相比就会报错
if (expr.args_[0]->datum_meta_.type_ == ObJsonType
|| expr.args_[1]->datum_meta_.type_ == ObJsonType) {
both_json = true;
}
ObExpr *json_arg_l = expr.args_[0];
ObObjType val_type_l = json_arg_l->datum_meta_.type_;
@ -116,8 +108,9 @@ int ObExprJsonEqual::eval_json_equal(const ObExpr &expr, ObEvalCtx &ctx, ObDatum
json_candidate, is_null_result))) {
if (ret == OB_ERR_JSON_SYNTAX_ERROR) is_cover_by_error = true;
LOG_WARN("get_json_doc failed", K(ret));
} else if(!is_null_result && !both_json && (is_json_scalar(json_target)
|| is_json_scalar(json_candidate))) {
// if is scalar, must be json type
} else if(!is_null_result && ((is_json_scalar(json_target) && expr.args_[0]->datum_meta_.type_ != ObJsonType)
|| (is_json_scalar(json_candidate) && expr.args_[1]->datum_meta_.type_ != ObJsonType))) {
ret = OB_ERR_JSON_SYNTAX_ERROR;
is_cover_by_error = true;
LOG_USER_ERROR(OB_ERR_JSON_SYNTAX_ERROR);

View File

@ -5718,7 +5718,7 @@ int ObRawExprResolverImpl::process_json_query_node(const ParseNode *node, ObRawE
}
// pre check default returning type with item method
if (OB_SUCC(ret)) {
if (returning_type->type_ == T_NULL) {
if (returning_type->type_ == T_NULL || returning_type->int16_values_[OB_NODE_CAST_TYPE_IDX] == T_JSON) {
ObString path_str(node->children_[1]->text_len_, node->children_[1]->raw_text_);
if (OB_FAIL(ObJsonPath::change_json_expr_res_type_if_need(ctx_.expr_factory_.get_allocator(), path_str, const_cast<ParseNode&>(*returning_type), OPT_JSON_QUERY))) {
LOG_WARN("set return type by path item method fail", K(ret), K(path_str));