From a12d26b9d6b52148ca3b18cbd4b905c0596922c7 Mon Sep 17 00:00:00 2001 From: yishenglanlingzui <395329313@qq.com> Date: Tue, 26 Mar 2024 13:45:28 +0000 Subject: [PATCH] fix create outline with error -4016 --- src/sql/parser/ob_fast_parser.cpp | 16 ++++++++++------ src/sql/parser/ob_fast_parser.h | 8 +++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/sql/parser/ob_fast_parser.cpp b/src/sql/parser/ob_fast_parser.cpp index 7368fb77aa..e0ee90f2be 100644 --- a/src/sql/parser/ob_fast_parser.cpp +++ b/src/sql/parser/ob_fast_parser.cpp @@ -105,7 +105,7 @@ ObFastParserBase::ObFastParserBase( tmp_buf_(nullptr), tmp_buf_len_(0), last_escape_check_pos_(0), param_node_list_(nullptr), tail_param_node_(nullptr), cur_token_type_(INVALID_TOKEN), allocator_(allocator), - get_insert_(false), values_token_pos_(0), + found_insert_status_(NOT_FOUND_INSERT_TOKEN), values_token_pos_(0), parse_next_token_func_(nullptr), process_idf_func_(nullptr) { question_mark_ctx_.count_ = 0; @@ -154,7 +154,9 @@ int ObFastParserBase::parse(const ObString &stmt, no_param_sql_len = no_param_sql_len_; param_list = param_node_list_; param_num = param_num_; - values_token_pos = values_token_pos_; + if (found_insert_status_ == FOUND_INSERT_TOKEN_ONCE) { + values_token_pos = values_token_pos_; + } } return ret; } @@ -772,9 +774,11 @@ int ObFastParserBase::process_insert_or_replace(const char *str, const int64_t s raw_sql_.scan(size); if (OB_FAIL(process_hint())) { LOG_WARN("failed to process hint", K(ret), K(raw_sql_.to_string()), K_(raw_sql_.cur_pos)); - } else { + } else if (found_insert_status_ == NOT_FOUND_INSERT_TOKEN) { // 说明是insert token - get_insert_ = true; + found_insert_status_ = FOUND_INSERT_TOKEN_ONCE; + } else if (found_insert_status_ == FOUND_INSERT_TOKEN_ONCE) { + found_insert_status_ = INVALID_TOKEN_STATUS; } } return ret; @@ -2517,7 +2521,7 @@ int ObFastParserMysql::process_identifier_begin_with_n() int ObFastParserMysql::process_values(const char *str) { int ret = OB_SUCCESS; - if (get_insert_) { + if (found_insert_status_ == FOUND_INSERT_TOKEN_ONCE) { if (!is_oracle_mode_) { // mysql support: insert ... values / value (xx, ...); if (CHECK_EQ_STRNCASECMP("alues", 5)) { @@ -2977,7 +2981,7 @@ int ObFastParserOracle::process_identifier_begin_with_n() int ObFastParserOracle::process_values(const char *str) { int ret = OB_SUCCESS; - if (get_insert_) { + if (found_insert_status_ == FOUND_INSERT_TOKEN_ONCE) { if (is_oracle_mode_) { if (CHECK_EQ_STRNCASECMP("alues", 5)) { values_token_pos_ = raw_sql_.cur_pos_; diff --git a/src/sql/parser/ob_fast_parser.h b/src/sql/parser/ob_fast_parser.h index fc5c39ced7..13244984b4 100644 --- a/src/sql/parser/ob_fast_parser.h +++ b/src/sql/parser/ob_fast_parser.h @@ -618,6 +618,12 @@ protected: bool skip_space(ObRawSql &raw_sql); protected: + enum FoundInsertTokenStatus + { + NOT_FOUND_INSERT_TOKEN, + FOUND_INSERT_TOKEN_ONCE, // find one insert token + INVALID_TOKEN_STATUS, // find insert token more than one time + }; ObRawSql raw_sql_; char *no_param_sql_; int64_t no_param_sql_len_; @@ -639,7 +645,7 @@ protected: common::ObIAllocator &allocator_; common::ObCharsetType charset_type_; const ObCharsetInfo *charset_info_; - bool get_insert_; + FoundInsertTokenStatus found_insert_status_; int64_t values_token_pos_; ParseNextTokenFunc parse_next_token_func_; ProcessIdfFunc process_idf_func_;