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

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

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

W
wangyunlai.wyl 已提交
37
  const std::string &sql() const { return sql_; }
38
  const std::unique_ptr<Command> &command() const { return command_; }
W
wangyunlai.wyl 已提交
39
  Stmt *stmt() const { return stmt_; }
羽飞's avatar
羽飞 已提交
40 41
  std::unique_ptr<PhysicalOperator> &physical_operator()  { return operator_; }
  const std::unique_ptr<PhysicalOperator> &physical_operator() const { return operator_; }
W
wangyunlai.wyl 已提交
42 43

  void set_sql(const char *sql) { sql_ = sql; }
44
  void set_command(std::unique_ptr<Command> cmd) { command_ = std::move(cmd); }
W
wangyunlai.wyl 已提交
45
  void set_stmt(Stmt *stmt) { stmt_ = stmt; }
羽飞's avatar
羽飞 已提交
46
  void set_operator(std::unique_ptr<PhysicalOperator> oper) { operator_ = std::move(oper); }
W
wangyunlai.wyl 已提交
47

羽飞's avatar
羽飞 已提交
48
private:
W
wangyunlai.wyl 已提交
49 50
  SessionEvent *session_event_ = nullptr;
  std::string sql_;
51
  std::unique_ptr<Command> command_;
W
wangyunlai.wyl 已提交
52
  Stmt *stmt_ = nullptr;
羽飞's avatar
羽飞 已提交
53
  std::unique_ptr<PhysicalOperator> operator_;
羽飞's avatar
羽飞 已提交
54 55
};