diff --git a/src/storage/access/ob_block_batched_row_store.cpp b/src/storage/access/ob_block_batched_row_store.cpp index 133ce1a9bf..24f5700189 100644 --- a/src/storage/access/ob_block_batched_row_store.cpp +++ b/src/storage/access/ob_block_batched_row_store.cpp @@ -169,9 +169,9 @@ int ObBlockBatchedRowStore::get_row_ids( start = min(context_.limit_param_->offset_ - context_.out_cnt_, row_count); } if (context_.limit_param_->limit_ >= 0 && - context_.out_cnt_ + row_count >= context_.limit_param_->offset_ + context_.limit_param_->limit_) { + context_.out_cnt_ + row_count - context_.limit_param_->offset_ >= context_.limit_param_->limit_) { iter_end_flag_ = IterEndState::LIMIT_ITER_END; - end = context_.limit_param_->offset_ + context_.limit_param_->limit_ - context_.out_cnt_; + end = context_.limit_param_->limit_ - context_.out_cnt_ + context_.limit_param_->offset_; } context_.out_cnt_ += end; row_count = end - start;