sql_event.h 1.8 KB
Newer Older
羽飞's avatar
羽飞 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* 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 Longda on 2021/4/14.
//

羽飞's avatar
羽飞 已提交
15
#pragma once
羽飞's avatar
羽飞 已提交
16 17

#include <string>
羽飞's avatar
羽飞 已提交
18
#include <memory>
W
wangyunlai.wyl 已提交
19
#include "common/seda/stage_event.h"
羽飞's avatar
羽飞 已提交
20
#include "sql/operator/physical_operator.h"
羽飞's avatar
羽飞 已提交
21 22

class SessionEvent;
W
wangyunlai.wyl 已提交
23
class Stmt;
24
class Command;
羽飞's avatar
羽飞 已提交
25

L
Longda Feng 已提交
26
class SQLStageEvent : public common::StageEvent {
羽飞's avatar
羽飞 已提交
27
public:
W
wangyunlai.wyl 已提交
28
  SQLStageEvent(SessionEvent *event, const std::string &sql);
羽飞's avatar
羽飞 已提交
29 30
  virtual ~SQLStageEvent() noexcept;

31 32
  SessionEvent *session_event() const
  {
羽飞's avatar
羽飞 已提交
33 34
    return session_event_;
  }
35

L
Longda Feng 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  const std::string &sql() const
  {
    return sql_;
  }
  const std::unique_ptr<Command> &command() const
  {
    return command_;
  }
  Stmt *stmt() const
  {
    return stmt_;
  }
  std::unique_ptr<PhysicalOperator> &physical_operator()
  {
    return operator_;
  }
  const std::unique_ptr<PhysicalOperator> &physical_operator() const
  {
    return operator_;
  }
W
wangyunlai.wyl 已提交
56

L
Longda Feng 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  void set_sql(const char *sql)
  {
    sql_ = sql;
  }
  void set_command(std::unique_ptr<Command> cmd)
  {
    command_ = std::move(cmd);
  }
  void set_stmt(Stmt *stmt)
  {
    stmt_ = stmt;
  }
  void set_operator(std::unique_ptr<PhysicalOperator> oper)
  {
    operator_ = std::move(oper);
  }
W
wangyunlai.wyl 已提交
73

羽飞's avatar
羽飞 已提交
74
private:
W
wangyunlai.wyl 已提交
75 76
  SessionEvent *session_event_ = nullptr;
  std::string sql_;
77
  std::unique_ptr<Command> command_;
W
wangyunlai.wyl 已提交
78
  Stmt *stmt_ = nullptr;
羽飞's avatar
羽飞 已提交
79
  std::unique_ptr<PhysicalOperator> operator_;
羽飞's avatar
羽飞 已提交
80
};