session_event.h 1.4 KB
Newer Older
羽飞's avatar
羽飞 已提交
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
羽飞's avatar
羽飞 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14
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/13.
//

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

#include <string.h>
#include <string>

#include "common/seda/stage_event.h"
羽飞's avatar
羽飞 已提交
21
#include "sql/executor/sql_result.h"
羽飞's avatar
羽飞 已提交
22
#include "event/sql_debug.h"
羽飞's avatar
羽飞 已提交
23

W
wangyunlai.wyl 已提交
24
class Session;
羽飞's avatar
羽飞 已提交
25
class Communicator;
W
wangyunlai.wyl 已提交
26

羽飞's avatar
羽飞 已提交
27 28 29 30
/**
 * @brief 表示一个SQL请求
 * 
 */
羽飞's avatar
羽飞 已提交
31 32
class SessionEvent : public common::StageEvent 
{
羽飞's avatar
羽飞 已提交
33
public:
羽飞's avatar
羽飞 已提交
34
  SessionEvent(Communicator *client);
羽飞's avatar
羽飞 已提交
35 36
  virtual ~SessionEvent();

羽飞's avatar
羽飞 已提交
37
  Communicator *get_communicator() const;
W
wangyunlai.wyl 已提交
38
  Session *session() const;
羽飞's avatar
羽飞 已提交
39

羽飞's avatar
羽飞 已提交
40
  void set_query(const std::string &query) { query_ = query; }
羽飞's avatar
羽飞 已提交
41

羽飞's avatar
羽飞 已提交
42
  const std::string &query() const { return query_; }
羽飞's avatar
羽飞 已提交
43

羽飞's avatar
羽飞 已提交
44 45 46
  SqlResult *sql_result() { return &sql_result_; }

  SqlDebug &sql_debug() { return sql_debug_; }
羽飞's avatar
羽飞 已提交
47

羽飞's avatar
羽飞 已提交
48 49 50 51 52
private:
  Communicator *communicator_ = nullptr;  ///< 与客户端通讯的对象
  SqlResult     sql_result_;  ///< SQL执行结果
  SqlDebug      sql_debug_; ///< SQL调试信息
  std::string   query_; ///< SQL语句
羽飞's avatar
羽飞 已提交
53
};