diff --git a/src/share/ob_errno.cpp b/src/share/ob_errno.cpp index 387a176019..6b07840771 100644 --- a/src/share/ob_errno.cpp +++ b/src/share/ob_errno.cpp @@ -12777,8 +12777,8 @@ static const _error _error_OB_ERR_DEPRECATED_SYNTAX_NO_REP = { .oracle_str_error = "ORA-00600: internal error code, arguments: -5518, This syntax is deprecated and will be removed in a future release", .oracle_str_user_error = "ORA-00600: internal error code, arguments: -5518, %s is deprecated and will be removed in a future release" }; -static const _error _error_OB_ERR_CAST_ARRAY_SUPPORT = { - .error_name = "OB_ERR_CAST_ARRAY_SUPPORT", +static const _error _error_OB_NOT_MULTIVALUE_SUPPORT = { + .error_name = "OB_NOT_MULTIVALUE_SUPPORT", .error_cause = "Internal Error", .error_solution = "Contact OceanBase Support", .mysql_errno = ER_NOT_SUPPORTED_YET, @@ -28079,7 +28079,7 @@ struct ObStrErrorInit _errors[-OB_ERR_DEPRECATED_SYNTAX] = &_error_OB_ERR_DEPRECATED_SYNTAX; _errors[-OB_ERR_NON_STRING_NOT_SUPPORT] = &_error_OB_ERR_NON_STRING_NOT_SUPPORT; _errors[-OB_ERR_DEPRECATED_SYNTAX_NO_REP] = &_error_OB_ERR_DEPRECATED_SYNTAX_NO_REP; - _errors[-OB_ERR_CAST_ARRAY_SUPPORT] = &_error_OB_ERR_CAST_ARRAY_SUPPORT; + _errors[-OB_NOT_MULTIVALUE_SUPPORT] = &_error_OB_NOT_MULTIVALUE_SUPPORT; _errors[-OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX] = &_error_OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX; _errors[-OB_ERR_JSON_CONTAINER_CAST_SCALAR] = &_error_OB_ERR_JSON_CONTAINER_CAST_SCALAR; _errors[-OB_ERR_INVALID_IDENTIFIER_JSON_TABLE] = &_error_OB_ERR_INVALID_IDENTIFIER_JSON_TABLE; diff --git a/src/share/ob_errno.def b/src/share/ob_errno.def index bd7b33d36d..16bf720372 100755 --- a/src/share/ob_errno.def +++ b/src/share/ob_errno.def @@ -1227,7 +1227,7 @@ DEFINE_ERROR(OB_ERR_TABLE_WITHOUT_ALIAS, -5515, ER_TF_MUST_HAVE_ALIAS, "42000", DEFINE_ERROR_EXT(OB_ERR_DEPRECATED_SYNTAX, -5516, ER_WARN_DEPRECATED_SYNTAX, "HY000", "This syntax is deprecated and will be removed in a future release", "%s is deprecated and will be removed in a future release. Please use \'%s\' instead"); DEFINE_ERROR(OB_ERR_NON_STRING_NOT_SUPPORT, -5517, ER_NOT_SUPPORTED_YET, "42000", "This version of MySQL doesn't yet support 'non-string DEFAULT value for a column in a JSON_TABLE expression'"); DEFINE_ERROR_EXT(OB_ERR_DEPRECATED_SYNTAX_NO_REP, -5518, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, "HY000", "This syntax is deprecated and will be removed in a future release", "%s is deprecated and will be removed in a future release"); -DEFINE_ERROR(OB_ERR_CAST_ARRAY_SUPPORT, -5519, ER_NOT_SUPPORTED_YET, "42000", "This version of MySQL doesn't yet support %s"); +DEFINE_ERROR(OB_NOT_MULTIVALUE_SUPPORT, -5519, ER_NOT_SUPPORTED_YET, "42000", "This version of MySQL doesn't yet support %s"); DEFINE_ERROR(OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX, -5520, ER_CAST_INDEX_JSON_VALUE, "42000", "Invalid JSON value for CAST for functional index."); DEFINE_ERROR(OB_ERR_JSON_CONTAINER_CAST_SCALAR, -5521, ER_ARRAY_CAST_INDEX_SCALAR, "42000", "Cannot store an array or an object in a scalar key part of the index."); DEFINE_ORACLE_ERROR(OB_ERR_INVALID_IDENTIFIER_JSON_TABLE, -5522, -1, "22000", "invalid identifier used for path expression in JSON_TABLE", 40680, "invalid identifier used for path expression in JSON_TABLE"); diff --git a/src/share/ob_errno.h b/src/share/ob_errno.h index 4223ecb654..f4d20354c9 100644 --- a/src/share/ob_errno.h +++ b/src/share/ob_errno.h @@ -891,7 +891,7 @@ constexpr int OB_ERR_TABLE_WITHOUT_ALIAS = -5515; constexpr int OB_ERR_DEPRECATED_SYNTAX = -5516; constexpr int OB_ERR_NON_STRING_NOT_SUPPORT = -5517; constexpr int OB_ERR_DEPRECATED_SYNTAX_NO_REP = -5518; -constexpr int OB_ERR_CAST_ARRAY_SUPPORT = -5519; +constexpr int OB_NOT_MULTIVALUE_SUPPORT = -5519; constexpr int OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX = -5520; constexpr int OB_ERR_JSON_CONTAINER_CAST_SCALAR = -5521; constexpr int OB_ERR_INVALID_IDENTIFIER_JSON_TABLE = -5522; @@ -2943,7 +2943,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219; #define OB_ERR_DEPRECATED_SYNTAX__USER_ERROR_MSG "%s is deprecated and will be removed in a future release. Please use \'%s\' instead" #define OB_ERR_NON_STRING_NOT_SUPPORT__USER_ERROR_MSG "This version of MySQL doesn't yet support 'non-string DEFAULT value for a column in a JSON_TABLE expression'" #define OB_ERR_DEPRECATED_SYNTAX_NO_REP__USER_ERROR_MSG "%s is deprecated and will be removed in a future release" -#define OB_ERR_CAST_ARRAY_SUPPORT__USER_ERROR_MSG "This version of MySQL doesn't yet support %s" +#define OB_NOT_MULTIVALUE_SUPPORT__USER_ERROR_MSG "This version of MySQL doesn't yet support %s" #define OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX__USER_ERROR_MSG "Invalid JSON value for CAST for functional index." #define OB_ERR_JSON_CONTAINER_CAST_SCALAR__USER_ERROR_MSG "Cannot store an array or an object in a scalar key part of the index." #define OB_ERR_INVALID_IDENTIFIER_JSON_TABLE__USER_ERROR_MSG "invalid identifier used for path expression in JSON_TABLE" @@ -5195,7 +5195,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219; #define OB_ERR_DEPRECATED_SYNTAX__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5516, %s is deprecated and will be removed in a future release. Please use \'%s\' instead" #define OB_ERR_NON_STRING_NOT_SUPPORT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5517, This version of MySQL doesn't yet support 'non-string DEFAULT value for a column in a JSON_TABLE expression'" #define OB_ERR_DEPRECATED_SYNTAX_NO_REP__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5518, %s is deprecated and will be removed in a future release" -#define OB_ERR_CAST_ARRAY_SUPPORT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5519, This version of MySQL doesn't yet support %s" +#define OB_NOT_MULTIVALUE_SUPPORT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5519, This version of MySQL doesn't yet support %s" #define OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5520, Invalid JSON value for CAST for functional index." #define OB_ERR_JSON_CONTAINER_CAST_SCALAR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5521, Cannot store an array or an object in a scalar key part of the index." #define OB_ERR_INVALID_IDENTIFIER_JSON_TABLE__ORA_USER_ERROR_MSG "ORA-40680: invalid identifier used for path expression in JSON_TABLE" diff --git a/src/share/ob_fts_index_builder_util.cpp b/src/share/ob_fts_index_builder_util.cpp index 7a1b4be268..0dcb5889f3 100644 --- a/src/share/ob_fts_index_builder_util.cpp +++ b/src/share/ob_fts_index_builder_util.cpp @@ -2376,6 +2376,7 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns( HEAP_VAR(ObRowDesc, row_desc) { common::ObOrderType order_type; const ObColumnSchemaV2 *mvi_array_column = nullptr; + int32_t multi_column_cnt = 0; for (int64_t i = 0; OB_SUCC(ret) && i < arg.index_columns_.count(); ++i) { const ObColumnSchemaV2 *mvi_column = nullptr; const ObColumnSortItem &mvi_col_item = arg.index_columns_.at(i); @@ -2400,6 +2401,12 @@ int ObMulValueIndexBuilderUtil::set_multivalue_index_table_columns( false/*is_specified_storing_col*/))) { LOG_WARN("add column failed", "mvi_column", *mvi_column, "rowkey_order_type", mvi_col_item.order_type_, K(row_desc), K(ret)); + } else if (mvi_column->is_multivalue_generated_column()) { + multi_column_cnt++; + if (multi_column_cnt > 1) { + ret = OB_NOT_MULTIVALUE_SUPPORT; + LOG_USER_ERROR(OB_NOT_MULTIVALUE_SUPPORT, "more than one multi-valued key part per index"); + } } } else if (mvi_column->is_multivalue_generated_array_column()) { mvi_array_column = mvi_column; diff --git a/src/sql/engine/expr/ob_expr_json_overlaps.cpp b/src/sql/engine/expr/ob_expr_json_overlaps.cpp index 41cc20f638..8b461e5e0e 100644 --- a/src/sql/engine/expr/ob_expr_json_overlaps.cpp +++ b/src/sql/engine/expr/ob_expr_json_overlaps.cpp @@ -44,9 +44,6 @@ int ObExprJsonOverlaps::calc_result_type2(ObExprResType &type, type.set_precision(DEFAULT_PRECISION_FOR_BOOL); type.set_scale(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].scale_); - if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(type2, 2, N_JSON_OVERLAPS))) { - LOG_WARN("wrong type for json doc.", K(ret), K(type2.get_type())); - } return ret; } diff --git a/src/sql/engine/expr/ob_expr_json_query.cpp b/src/sql/engine/expr/ob_expr_json_query.cpp index aece7b5e65..4f29203aec 100644 --- a/src/sql/engine/expr/ob_expr_json_query.cpp +++ b/src/sql/engine/expr/ob_expr_json_query.cpp @@ -374,11 +374,11 @@ int ObExprJsonQuery::check_enable_cast_index_array(ObIJsonBase* json_base, bool ret = OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX; LOG_USER_ERROR(OB_ERR_JSON_VALUE_CAST_FUNCTION_INDEX); } else if (json_base->json_type() == ObJsonNodeType::J_BOOLEAN) { - ret = OB_ERR_CAST_ARRAY_SUPPORT; - LOG_USER_ERROR(OB_ERR_CAST_ARRAY_SUPPORT, "CAST-ing JSON BOOLEAN type to array"); + ret = OB_NOT_MULTIVALUE_SUPPORT; + LOG_USER_ERROR(OB_NOT_MULTIVALUE_SUPPORT, "CAST-ing JSON BOOLEAN type to array"); } else if (!disable_container && json_base->json_type() == ObJsonNodeType::J_OBJECT) { - ret = OB_ERR_CAST_ARRAY_SUPPORT; - LOG_USER_ERROR(OB_ERR_CAST_ARRAY_SUPPORT, "CAST-ing JSON OBJECT type to array"); + ret = OB_NOT_MULTIVALUE_SUPPORT; + LOG_USER_ERROR(OB_NOT_MULTIVALUE_SUPPORT, "CAST-ing JSON OBJECT type to array"); } if (OB_FAIL(ret)) { diff --git a/src/sql/optimizer/ob_join_order.cpp b/src/sql/optimizer/ob_join_order.cpp index 20b55b1cc6..c3100b583d 100644 --- a/src/sql/optimizer/ob_join_order.cpp +++ b/src/sql/optimizer/ob_join_order.cpp @@ -3729,18 +3729,15 @@ int ObJoinOrder::check_exprs_overlap_multivalue_index( } else if (qual->get_expr_type() != T_OP_BOOL) { } else if (!qual->is_domain_json_expr()) { } else { - const ObColumnSchemaV2 *mulvalue_col = nullptr; for (int64_t k = 0; k < keys.count() && !match; k++) { ObColumnRefRawExpr *ref = static_cast(keys.at(k)); ObRawExpr *column_expr = nullptr; ObRawExpr *depend_expr = nullptr; if (!ref->is_multivalue_generated_column()) { } else if (OB_ISNULL(column_expr = stmt->get_column_expr_by_id(table_id, ref->get_column_id()))) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("failed to get multivalue column, null expr", K(ret)); + // quals not contains json multivalue index is normal, need not return error } else if (OB_ISNULL(depend_expr = (static_cast(column_expr))->get_dependant_expr())) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("failed to get multivalue depend expr, null expr", K(ret)); + // quals not contains json multivalue index is normal, need not return error } else { qual = ObRawExprUtils::skip_inner_added_expr(qual); ObExprEqualCheckContext equal_ctx; diff --git a/src/sql/resolver/expr/ob_raw_expr.cpp b/src/sql/resolver/expr/ob_raw_expr.cpp index 1240e9582e..92f9d1d898 100644 --- a/src/sql/resolver/expr/ob_raw_expr.cpp +++ b/src/sql/resolver/expr/ob_raw_expr.cpp @@ -619,6 +619,9 @@ ObRawExpr* ObRawExpr::get_json_domain_param_expr() param_expr = get_param_expr(0); } else if (get_expr_type() == T_FUN_SYS_JSON_OVERLAPS) { param_expr = get_param_expr(0); + if (OB_NOT_NULL(param_expr) && param_expr->is_const_expr()) { + param_expr = get_param_expr(1); + } } return param_expr; @@ -4092,21 +4095,34 @@ bool ObSysFunRawExpr::inner_json_expr_same_as( && r_expr->is_domain_json_expr()) { const ObRawExpr *r_param_expr = nullptr; const ObRawExpr *l_param_expr = l_expr->get_param_expr(1); + + const ObRawExpr *r_column_expr = nullptr; + const ObRawExpr *l_column_expr = l_expr->get_param_expr(0); + if (r_expr->get_expr_type() == T_FUN_SYS_JSON_MEMBER_OF) { r_param_expr = r_expr->get_param_expr(1); } else { r_param_expr = r_expr->get_param_expr(0); + if (r_expr->get_expr_type() == T_FUN_SYS_JSON_OVERLAPS && OB_NOT_NULL(r_param_expr) && r_param_expr->is_const_expr()) { + r_param_expr = r_expr->get_param_expr(1); + } } if (OB_ISNULL(r_param_expr)) { } else if (r_param_expr->is_wrappered_json_extract()) { r_param_expr = r_param_expr->get_param_expr(0)->get_param_expr(1); + r_column_expr = r_param_expr->get_param_expr(0)->get_param_expr(0); } else if (r_param_expr->get_expr_type() == T_FUN_SYS_JSON_EXTRACT) { + r_column_expr = r_param_expr->get_param_expr(0); r_param_expr = r_param_expr->get_param_expr(1); } if (OB_NOT_NULL(r_param_expr)) { bool_ret = l_param_expr->same_as(*r_param_expr, check_context); } + + if (bool_ret) { + bool_ret = r_column_expr == l_column_expr; + } } else if (l_expr->get_expr_type() == r_expr->get_expr_type()) { bool_ret = l_expr->same_as(*r_expr, check_context); } else if (l_expr->is_wrappered_json_extract() diff --git a/src/sql/resolver/expr/ob_raw_expr_util.cpp b/src/sql/resolver/expr/ob_raw_expr_util.cpp index 532dbf6afc..bed4ec17fb 100644 --- a/src/sql/resolver/expr/ob_raw_expr_util.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_util.cpp @@ -4613,6 +4613,8 @@ int ObRawExprUtils::replace_qual_param_if_need(ObRawExpr* qual, { INIT_SUCC(ret); ObRawExpr* qual_expr = nullptr; + const ObRawExpr* param_expr = nullptr; + int32_t idx = 0; if (qual->get_expr_type() == T_OP_BOOL && OB_NOT_NULL(qual_expr = qual->get_param_expr(0)) @@ -4621,8 +4623,14 @@ int ObRawExprUtils::replace_qual_param_if_need(ObRawExpr* qual, if (OB_FAIL(static_cast(qual_expr)->replace_param_expr(1, col_expr))) { LOG_WARN("replace const int expr failed", K(ret)); } - } else if (OB_FAIL(static_cast(qual_expr)->replace_param_expr(0, col_expr))) { - LOG_WARN("replace const int expr failed", K(ret)); + } else { + if (OB_NOT_NULL(param_expr = qual_expr->get_param_expr(0)) && param_expr->is_const_expr()) { + idx = 1; + } + + if (OB_FAIL(static_cast(qual_expr)->replace_param_expr(idx, col_expr))) { + LOG_WARN("replace const int expr failed", K(ret)); + } } }