trx_end_stmt.h 1.2 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
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. */

//
羽飞's avatar
羽飞 已提交
12
// Created by Wangyunlai on 2023/6/14.
羽飞's avatar
羽飞 已提交
13 14
//

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

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

羽飞's avatar
羽飞 已提交
20
#include "sql/stmt/stmt.h"
羽飞's avatar
羽飞 已提交
21

羽飞's avatar
羽飞 已提交
22 23
/**
 * @brief 事务的 Commit/Rollback 语句,现在什么成员都没有
羽飞's avatar
羽飞 已提交
24
 * @ingroup Statement
羽飞's avatar
羽飞 已提交
25 26
 */
class TrxEndStmt : public Stmt
羽飞's avatar
羽飞 已提交
27
{
羽飞's avatar
羽飞 已提交
28
public:
羽飞's avatar
羽飞 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
  TrxEndStmt(StmtType type)
          : type_(type)
  {}
  virtual ~TrxEndStmt() = default;

  StmtType type() const override { return type_; }

  static RC create(SqlCommandFlag flag, Stmt *&stmt)
  {
    StmtType type = flag == SqlCommandFlag::SCF_COMMIT ? StmtType::COMMIT : StmtType::ROLLBACK;
    stmt = new TrxEndStmt(type);
    return RC::SUCCESS;
  }

private:
  StmtType type_;
};