From 14ccc17b8c466bde38dcb65e5512e5baf5ff26c0 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 1 Dec 2022 04:05:41 +0000 Subject: [PATCH] fix some signal resolve bug --- src/pl/ob_pl_resolver.cpp | 17 +++++++++++++++-- src/pl/ob_pl_resolver.h | 3 ++- src/pl/parser/pl_parser_mysql_mode.y | 2 +- src/sql/ob_spi.cpp | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pl/ob_pl_resolver.cpp b/src/pl/ob_pl_resolver.cpp index 5b28e53b2..6ea53e78b 100644 --- a/src/pl/ob_pl_resolver.cpp +++ b/src/pl/ob_pl_resolver.cpp @@ -5204,7 +5204,7 @@ int ObPLResolver::resolve_declare_handler(const ObStmtNodeTree *parse_tree, ObPL ObPLConditionType actual_type = INVALID_TYPE; if (OB_FAIL(resolve_handler_condition(handler_list->children_[i], value, func))) { LOG_WARN("failed to resolve condition value", K(handler_list->children_[i]), K(ret)); - } else if (OB_FAIL(check_duplicate_condition(*stmt, value, dup))) { + } else if (OB_FAIL(check_duplicate_condition(*stmt, value, dup, desc))) { LOG_WARN("failed to check duplication", K(value), K(ret)); } else if (dup) { ret = OB_ERR_SP_DUP_HANDLER; @@ -5289,6 +5289,8 @@ int ObPLResolver::resolve_resignal( if (lib::is_oracle_mode()) { ret = OB_ERR_SP_COND_MISMATCH; LOG_WARN("PLS-00367: a RAISE statement with no exception name must be inside an exception handler", K(ret)); + } else if(OB_NOT_NULL(parse_tree->children_[0]) && OB_FAIL(resolve_signal(parse_tree, stmt, func))) { + LOG_WARN("resolve resignal fail", K(ret)); } else { ret = OB_ERR_RESIGNAL_WITHOUT_ACTIVE_HANDLER; LOG_WARN("RESIGNAL when handler not active", K(ret)); @@ -12215,7 +12217,8 @@ int ObPLResolver::resolve_condition_value(const ObStmtNodeTree *parse_tree, int ObPLResolver::check_duplicate_condition(const ObPLDeclareHandlerStmt &stmt, const ObPLConditionValue &value, - bool &dup) + bool &dup, + ObPLDeclareHandlerStmt::DeclareHandler::HandlerDesc* cur_desc) { int ret = OB_SUCCESS; dup = false; @@ -12258,6 +12261,16 @@ int ObPLResolver::check_duplicate_condition(const ObPLDeclareHandlerStmt &stmt, break; } } + if (OB_NOT_NULL(cur_desc)) { + for (int64_t j = 0; !dup && j < cur_desc->get_conditions().count(); ++j) { + if (value.type_ == cur_desc->get_condition(j).type_ && + value.error_code_ == cur_desc->get_condition(j).error_code_ && + value.str_len_ == cur_desc->get_condition(j).str_len_ && + 0 == STRNCMP(value.sql_state_, cur_desc->get_condition(j).sql_state_, value.str_len_)) { + dup = true; + } + } + } return ret; } diff --git a/src/pl/ob_pl_resolver.h b/src/pl/ob_pl_resolver.h index e0e4f55bd..c5c35b297 100644 --- a/src/pl/ob_pl_resolver.h +++ b/src/pl/ob_pl_resolver.h @@ -776,7 +776,8 @@ private: ObIArray &access_idxs); private: - int check_duplicate_condition(const ObPLDeclareHandlerStmt &stmt, const ObPLConditionValue &value, bool &dup); + int check_duplicate_condition(const ObPLDeclareHandlerStmt &stmt, const ObPLConditionValue &value, + bool &dup, ObPLDeclareHandlerStmt::DeclareHandler::HandlerDesc* cur_desc); int analyze_actual_condition_type(const ObPLConditionValue &value, ObPLConditionType &type); int check_subprogram_variable_read_only(ObPLBlockNS &ns, uint64_t subprogram_id, int64_t var_idx); int check_package_variable_read_only(uint64_t package_id, uint64_t var_idx); diff --git a/src/pl/parser/pl_parser_mysql_mode.y b/src/pl/parser/pl_parser_mysql_mode.y index 44fa31011..0d92e677d 100644 --- a/src/pl/parser/pl_parser_mysql_mode.y +++ b/src/pl/parser/pl_parser_mysql_mode.y @@ -1489,7 +1489,7 @@ sp_hcond_list: sp_hcond: sp_cond { $$ = $1; } - | IDENT { $$ = $1; } + | ident { $$ = $1; } | SQLWARNING { malloc_terminal_node($$, parse_ctx->mem_pool_, T_SQL_WARNING); } | NOT FOUND { malloc_terminal_node($$, parse_ctx->mem_pool_, T_SQL_NOT_FOUND); } | SQLEXCEPTION { malloc_terminal_node($$, parse_ctx->mem_pool_, T_SQL_EXCEPTION); } diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 4eb5b77a5..fd4ef0233 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -4243,7 +4243,7 @@ int ObSPIService::spi_process_resignal(pl::ObPLExecCtx *ctx, if (result.is_null()) { ret = OB_ERR_WRONG_VALUE_FOR_VAR; LOG_WARN("error code is NULL", K(ret)); - LOG_USER_ERROR(OB_ERR_WRONG_VALUE_FOR_VAR, static_cast(STRLEN("MYSQL_ERRNO")), "MYSQL_ERRNO", + LOG_USER_ERROR(OB_ERR_WRONG_VALUE_FOR_VAR, static_cast(STRLEN("MESSAGE_TEXT")), "MESSAGE_TEXT", static_cast(STRLEN("NULL")), "NULL"); } }