From 4bc9424081b17d1740a1e764f6995bf7bbe1dcb4 Mon Sep 17 00:00:00 2001 From: bit-dance <2634358021@qq.com> Date: Fri, 8 Nov 2024 07:45:14 +0000 Subject: [PATCH] [CP] [#2024101600104721501]Fix to catch error code in fast parse --- src/pl/parser/ob_pl_parser.cpp | 37 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/pl/parser/ob_pl_parser.cpp b/src/pl/parser/ob_pl_parser.cpp index 7d652456f..c0c79997a 100644 --- a/src/pl/parser/ob_pl_parser.cpp +++ b/src/pl/parser/ob_pl_parser.cpp @@ -86,24 +86,27 @@ int ObPLParser::fast_parse(const ObString &query, parse_ctx.no_param_sql_buf_len_ = new_length; } if (OB_SUCC(ret)) { - ret = parse_stmt_block(parse_ctx, parse_result.result_tree_); - if (OB_ERR_PARSE_SQL == ret) { - int err_len = 0; - const char *err_str = "", *global_errmsg = ""; - int err_line = 0; - if (parse_ctx.cur_error_info_ != NULL) { - int first_column = parse_ctx.cur_error_info_->stmt_loc_.first_column_; - int last_column = parse_ctx.cur_error_info_->stmt_loc_.last_column_; - err_len = last_column - first_column + 1; - err_str = parse_ctx.stmt_str_ + first_column; - err_line = parse_ctx.cur_error_info_->stmt_loc_.last_line_ + 1; - global_errmsg = parse_ctx.global_errmsg_; + if (OB_FAIL(parse_stmt_block(parse_ctx, parse_result.result_tree_))) { + if (OB_ERR_PARSE_SQL == ret) { + int err_len = 0; + const char *err_str = "", *global_errmsg = ""; + int err_line = 0; + if (parse_ctx.cur_error_info_ != NULL) { + int first_column = parse_ctx.cur_error_info_->stmt_loc_.first_column_; + int last_column = parse_ctx.cur_error_info_->stmt_loc_.last_column_; + err_len = last_column - first_column + 1; + err_str = parse_ctx.stmt_str_ + first_column; + err_line = parse_ctx.cur_error_info_->stmt_loc_.last_line_ + 1; + global_errmsg = parse_ctx.global_errmsg_; + } + ObString stmt(parse_ctx.stmt_len_, parse_ctx.stmt_str_); + LOG_WARN("failed to parse pl stmt", + K(ret), K(err_line), K(global_errmsg), K(stmt)); + LOG_USER_ERROR(OB_ERR_PARSE_SQL, ob_errpkt_strerror(OB_ERR_PARSER_SYNTAX, false), + err_len, err_str, err_line); + } else { + LOG_WARN("failed to parse pl stmt", K(ret)); } - ObString stmt(parse_ctx.stmt_len_, parse_ctx.stmt_str_); - LOG_WARN("failed to parser pl stmt", - K(ret), K(err_line), K(global_errmsg), K(stmt)); - LOG_USER_ERROR(OB_ERR_PARSE_SQL, ob_errpkt_strerror(OB_ERR_PARSER_SYNTAX, false), - err_len, err_str, err_line); } else { memmove(parse_ctx.no_param_sql_ + parse_ctx.no_param_sql_len_, parse_ctx.stmt_str_ + parse_ctx.copied_pos_,