From 5048204f426da3dbc4674e2acf507dca1ca7e653 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 15 Nov 2022 07:08:07 +0000 Subject: [PATCH] Fix core of table scan iter --- src/sql/engine/expr/ob_expr_to_outfile_row.cpp | 6 +++--- src/storage/ls/ob_ls_tablet_service.cpp | 11 +++++------ src/storage/tx_storage/ob_access_service.cpp | 11 ++--------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/sql/engine/expr/ob_expr_to_outfile_row.cpp b/src/sql/engine/expr/ob_expr_to_outfile_row.cpp index db083d61d1..a72eef2134 100644 --- a/src/sql/engine/expr/ob_expr_to_outfile_row.cpp +++ b/src/sql/engine/expr/ob_expr_to_outfile_row.cpp @@ -250,9 +250,9 @@ int ObExprToOutfileRow::print_field(char *buf, const int64_t buf_len, int64_t &p auto escape_func = [buf, buf_len, &pos, need_enclose, &out_info] (ObString &code_point, int32_t wchar) -> int { int ret = OB_SUCCESS; - if (wchar == '\0') { - OZ(out_info.escape_.print_plain_str_literal(buf, buf_len, pos, out_info.print_params_)); - OZ(print_wchar_to_buf(buf, buf_len, pos, '0', out_info.print_params_.cs_type_)); + if (wchar == '\0') { + OZ(out_info.escape_.print_plain_str_literal(buf, buf_len, pos, out_info.print_params_)); + OZ(print_wchar_to_buf(buf, buf_len, pos, '0', out_info.print_params_.cs_type_)); } else if (wchar == out_info.wchar_enclose_ || wchar == out_info.wchar_escape_) { OZ(out_info.escape_.print_plain_str_literal(buf, buf_len, pos, out_info.print_params_)); OZ(copy_string_to_buf(buf, buf_len, pos, code_point)); diff --git a/src/storage/ls/ob_ls_tablet_service.cpp b/src/storage/ls/ob_ls_tablet_service.cpp index f5fd1b9131..18f940de64 100644 --- a/src/storage/ls/ob_ls_tablet_service.cpp +++ b/src/storage/ls/ob_ls_tablet_service.cpp @@ -730,17 +730,16 @@ int ObLSTabletService::table_scan(ObTableScanIterator &iter, ObTableScanParam &p } else if (OB_FAIL(get_tablet_with_timeout(param.tablet_id_, data_tablet, param.timeout_))) { LOG_WARN("failed to check and get tablet", K(ret), K(param)); } else if (OB_FAIL(inner_table_scan(data_tablet, iter, param))) { - LOG_WARN("failed to do table scan", K(ret), K(param)); + LOG_WARN("failed to do table scan", K(ret), KP(&iter), K(param)); } else { - result = &iter; - } - - if (OB_SUCC(ret)) { bool is_same = false; allow_to_read_mgr_.check_read_info_same(read_info, is_same); if (!is_same) { ret = OB_REPLICA_NOT_READABLE; - LOG_WARN("ls is not allow to read", K(ret), KPC(ls_)); + LOG_WARN("ls is not allow to read", K(ret), KPC(ls_), KP(&iter)); + } else { + // result should be assigned at the last + result = &iter; } } NG_TRACE(S_table_scan_end); diff --git a/src/storage/tx_storage/ob_access_service.cpp b/src/storage/tx_storage/ob_access_service.cpp index a5ca345a3d..69d396794d 100644 --- a/src/storage/tx_storage/ob_access_service.cpp +++ b/src/storage/tx_storage/ob_access_service.cpp @@ -271,18 +271,11 @@ int ObAccessService::table_rescan( ret = OB_NOT_SUPPORTED; LOG_WARN("only table scan iter can be rescan", K(ret), K(result->get_type())); } else if (!param.need_switch_param_) { - if (ObNewRowIterator::ObTableScanIterator == result->get_type() && - OB_FAIL(static_cast(result)->rescan(param))) { + if (OB_FAIL(static_cast(result)->rescan(param))) { LOG_WARN("rescan ObTableScanIterator failed", K(ret), K(result), K(vparam)); } } else { - ObTableScanIterator *iter = nullptr; - if (ObNewRowIterator::ObTableScanIterator == result->get_type()) { - iter = static_cast(result); - } else { - ret = OB_ERR_UNEXPECTED; - STORAGE_LOG(WARN, "Unexpected table iter type", K(ret), K(result->get_type())); - } + ObTableScanIterator *iter = static_cast(result); const share::ObLSID &ls_id = vparam.ls_id_; const common::ObTabletID &data_tablet_id = vparam.tablet_id_; ObLS *ls = nullptr;