From 134f4eedae91eaf861f024575e56f492466b29a2 Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 7 Apr 2023 10:56:32 +0000 Subject: [PATCH] bugfix : null in json expr clause has core dump in fast parser --- src/objit/include/objit/common/ob_item_type.h | 1 + src/sql/plan_cache/ob_sql_parameterization.cpp | 6 ++++-- .../resolver/expr/ob_raw_expr_resolver_impl.cpp | 15 +++++++++++++++ src/sql/resolver/expr/ob_raw_expr_resolver_impl.h | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/objit/include/objit/common/ob_item_type.h b/src/objit/include/objit/common/ob_item_type.h index 15ac491334..ab52531772 100755 --- a/src/objit/include/objit/common/ob_item_type.h +++ b/src/objit/include/objit/common/ob_item_type.h @@ -791,6 +791,7 @@ typedef enum ObItemType T_FUN_ORA_JSON_OBJECTAGG = 1685, T_FUN_SYS_JSON_EXISTS = 1686, T_FUN_SYS_TREAT = 1687, + T_NULLX_CLAUSE = 1688, // null clause on json expr ///< @note add new oracle only function type before this line diff --git a/src/sql/plan_cache/ob_sql_parameterization.cpp b/src/sql/plan_cache/ob_sql_parameterization.cpp index 08ec081019..6fabf5f21a 100644 --- a/src/sql/plan_cache/ob_sql_parameterization.cpp +++ b/src/sql/plan_cache/ob_sql_parameterization.cpp @@ -253,6 +253,7 @@ int ObSqlParameterization::is_fast_parse_const(TransformTreeCtx &ctx) || T_QUESTIONMARK == ctx.tree_->type_ || T_COLLATION == ctx.tree_->type_ || T_CAST_ARGUMENT == ctx.tree_->type_ + || T_NULLX_CLAUSE == ctx.tree_->type_ || (T_SFU_INT == ctx.tree_->type_ && -1 != ctx.tree_->value_) || T_SFU_DECIMAL == ctx.tree_->type_); } @@ -1459,8 +1460,9 @@ int ObSqlParameterization::add_not_param_flag(const ParseNode *node, SqlInfo &sq } else if (OB_FAIL(sql_info.not_param_index_.add_member(node->value_))) { SQL_PC_LOG(WARN, "failed to add member", K(node->value_)); } - } else if (T_CAST_ARGUMENT == node->type_ - || T_COLLATION == node->type_) { //如果是cast类型,则需要添加N个cast节点对应的常数, 因为正常parse不识别为常量, 但fast parse时会识别为常量 + } else if (T_CAST_ARGUMENT == node->type_ //如果是cast类型,则需要添加N个cast节点对应的常数, 因为正常parse不识别为常量, 但fast parse时会识别为常量 + || T_COLLATION == node->type_ + || T_NULLX_CLAUSE == node->type_) { // deal null clause on json expr for (int i = 0; OB_SUCC(ret) && i < node->param_num_; ++i) { if (OB_FAIL(sql_info.not_param_index_.add_member(sql_info.total_++))) { SQL_PC_LOG(WARN, "failed to add member", K(sql_info.total_)); diff --git a/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp b/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp index 89ccb3d60f..d2f97b9693 100644 --- a/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp @@ -931,6 +931,15 @@ int ObRawExprResolverImpl::do_recursive_resolve(const ParseNode *node, ObRawExpr } break; } + case T_NULLX_CLAUSE: { + modification_type_to_int(const_cast(*node)); + // deal node + if (OB_FAIL(SMART_CALL(recursive_resolve(node, expr)))) { + LOG_WARN("fail to process node with children only", K(ret), + K(node->type_), K(node)); + } + break; + } case T_FUN_SYS_REGEXP_LIKE: case T_FUN_SYS: { if (OB_FAIL(process_fun_sys_node(node, expr))) { @@ -5350,6 +5359,12 @@ int ObRawExprResolverImpl::pre_check_json_path_valid(const ParseNode *node) return ret; } +// json expr change T_NULLX_CLAUSE to T_INT +void ObRawExprResolverImpl::modification_type_to_int(ParseNode &node) +{ + node.type_ = T_INT; +} + int ObRawExprResolverImpl::process_json_value_node(const ParseNode *node, ObRawExpr *&expr) { INIT_SUCC(ret); diff --git a/src/sql/resolver/expr/ob_raw_expr_resolver_impl.h b/src/sql/resolver/expr/ob_raw_expr_resolver_impl.h index 6fccdea6f3..0f390033f3 100644 --- a/src/sql/resolver/expr/ob_raw_expr_resolver_impl.h +++ b/src/sql/resolver/expr/ob_raw_expr_resolver_impl.h @@ -122,6 +122,7 @@ private: int process_json_exists_node(const ParseNode *node, ObRawExpr *&expr); int process_json_array_node(const ParseNode *node, ObRawExpr *&expr); int process_json_mergepatch_node(const ParseNode *node, ObRawExpr *&expr); + static void modification_type_to_int(ParseNode &node); int process_fun_sys_node(const ParseNode *node, ObRawExpr *&expr); int process_dll_udf_node(const ParseNode *node, ObRawExpr *&expr); int process_agg_udf_node(const ParseNode *node,