sql_result.h 1.5 KB
Newer Older
羽飞's avatar
羽飞 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by WangYunlai on 2022/11/17.
//

#pragma once

#include <string>
羽飞's avatar
羽飞 已提交
18 19
#include <memory>

羽飞's avatar
羽飞 已提交
20
#include "sql/expr/tuple.h"
羽飞's avatar
羽飞 已提交
21
#include "sql/operator/physical_operator.h"
羽飞's avatar
羽飞 已提交
22 23 24 25 26 27 28 29 30 31 32 33

class SqlResult {
public:
  SqlResult() = default;
  ~SqlResult()
  {
  }

  void set_tuple_schema(const TupleSchema &schema);
  void set_return_code(RC rc) { return_code_ = rc; }
  void set_state_string(const std::string &state_string) { state_string_ = state_string; }

羽飞's avatar
羽飞 已提交
34
  void set_operator(std::unique_ptr<PhysicalOperator> oper) { operator_ = std::move(oper); }
羽飞's avatar
羽飞 已提交
35 36 37 38 39 40 41 42 43 44
  bool has_operator() const { return operator_ != nullptr; }
  const TupleSchema &tuple_schema() const { return tuple_schema_; }
  RC return_code() const { return return_code_; }
  const std::string &state_string() const { return state_string_; }

  RC open();
  RC close();
  RC next_tuple(Tuple *&tuple);

private:
羽飞's avatar
羽飞 已提交
45
  std::unique_ptr<PhysicalOperator> operator_;
羽飞's avatar
羽飞 已提交
46 47 48 49
  TupleSchema tuple_schema_;
  RC return_code_ = RC::SUCCESS;
  std::string state_string_;
};