From b5fd1cecbc6f79362b85410271d515c9952d6464 Mon Sep 17 00:00:00 2001 From: bf0 Date: Sun, 29 Aug 2021 01:47:38 +0800 Subject: [PATCH] fix load data case failed --- src/observer/ob_inner_sql_connection.cpp | 2 +- src/sql/engine/cmd/ob_load_data_impl.cpp | 38 +++++++++++------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/observer/ob_inner_sql_connection.cpp b/src/observer/ob_inner_sql_connection.cpp index 86f7852303..b750dc87d9 100644 --- a/src/observer/ob_inner_sql_connection.cpp +++ b/src/observer/ob_inner_sql_connection.cpp @@ -424,7 +424,7 @@ int ObInnerSQLConnection::process_retry( is_get_location_timeout_error(last_ret) || is_try_lock_row_err(last_ret) || is_has_no_readable_replica_err(last_ret) || is_select_dup_follow_replic_err(last_ret) || is_trans_stmt_need_retry_error(last_ret) || is_transaction_set_violation_err(last_ret) || - is_snapshot_discarded_err(last_ret) || OB_AUTOINC_SERVICE_BUSY == last_ret)) { + is_snapshot_discarded_err(last_ret))) { need_retry = true; const uint64_t* trace_id = ObCurTraceId::get(); bool sql_trigger_by_user_req = (NULL != trace_id && 0 != trace_id[0] && 0 != trace_id[1]); diff --git a/src/sql/engine/cmd/ob_load_data_impl.cpp b/src/sql/engine/cmd/ob_load_data_impl.cpp index f57c6c68cd..afb5d22b0e 100644 --- a/src/sql/engine/cmd/ob_load_data_impl.cpp +++ b/src/sql/engine/cmd/ob_load_data_impl.cpp @@ -1264,19 +1264,18 @@ int ObCSVParser::next_line(bool& yield_line) bool yield = false; int with_back_slash = 0; - for (; !yield && cur_pos_ != buf_end_pos_; ++cur_pos_, ++cur_field_end_pos_) { + for (; !yield && cur_pos_ < buf_end_pos_; ++cur_pos_, ++cur_field_end_pos_) { bool line_term_matched = false; if (*cur_pos_ == formats_.enclose_char_ && !in_enclose_flag_ && cur_pos_ == cur_field_begin_pos_) { in_enclose_flag_ = true; last_end_enclosed_ = NULL; - } else if ((*cur_pos_ == formats_.escape_char_ && formats_.escape_char_ != formats_.enclose_char_) || - (in_enclose_flag_ && formats_.enclose_char_ == *cur_pos_ && cur_pos_ < buf_end_pos_ && - formats_.enclose_char_ == *(cur_pos_ + 1))) { - if (cur_pos_ < buf_end_pos_) { - cur_pos_++; - if (!is_fast_parse_) { - *cur_field_end_pos_ = escaped_char(*cur_pos_, &with_back_slash); - } + } else if (cur_pos_ + 1 < buf_end_pos_ && + ((*cur_pos_ == formats_.escape_char_ && formats_.escape_char_ != formats_.enclose_char_) || + (in_enclose_flag_ && formats_.enclose_char_ == *cur_pos_ && + formats_.enclose_char_ == *(cur_pos_ + 1)))) { + cur_pos_++; + if (!is_fast_parse_) { + *cur_field_end_pos_ = escaped_char(*cur_pos_, &with_back_slash); } } else { if (cur_field_end_pos_ != cur_pos_ && !is_fast_parse_) { @@ -1369,19 +1368,16 @@ int ObCSVParser::fast_parse_lines( if (OB_UNLIKELY(!buffer.is_valid())) { ret = OB_INVALID_ARGUMENT; } else if (formats.is_simple_format_) { - char* cur_pos = buffer.begin_ptr(); - bool in_escaped = false; - for (char* p = buffer.begin_ptr(); p != buffer.current_ptr(); ++p) { + char *cur_pos = buffer.begin_ptr(); + for (char *p = buffer.begin_ptr(); p < buffer.current_ptr(); ++p) { char cur_char = *p; - if (!in_escaped) { - if (formats.enclose_char_ == cur_char) { - in_escaped = true; - } else if (formats.line_term_char_ == cur_char) { - cur_lines++; - cur_pos = p + 1; - if (cur_lines >= line_count) { - break; - } + if (formats.escape_char_ == cur_char && p + 1 < buffer.current_ptr()) { + p++; + } else if (formats.line_term_char_ == cur_char) { + cur_lines++; + cur_pos = p + 1; + if (cur_lines >= line_count) { + break; } } } -- GitLab