MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
trx_end_executor.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by Wangyunlai on 2023/6/14.
13//
14
15#pragma once
16
17#include "common/rc.h"
18#include "event/sql_event.h"
19#include "event/session_event.h"
20#include "sql/executor/sql_result.h"
21#include "session/session.h"
22#include "storage/trx/trx.h"
23#include "sql/stmt/stmt.h"
24
30{
31public:
32 TrxEndExecutor() = default;
33 virtual ~TrxEndExecutor() = default;
34
35 RC execute(SQLStageEvent *sql_event)
36 {
37 Stmt *stmt = sql_event->stmt();
38 SessionEvent *session_event = sql_event->session_event();
39
40 Session *session = session_event->session();
41 session->set_trx_multi_operation_mode(false);
42 Trx *trx = session->current_trx();
43
44 if (stmt->type() == StmtType::COMMIT) {
45 return trx->commit();
46 }
47 else {
48 return trx->rollback();
49 }
50 }
51};
与SessionEvent类似,也是处理SQL请求的事件,只是用在SQL的不同阶段
Definition: sql_event.h:30
表示一个SQL请求
Definition: session_event.h:32
表示会话
Definition: session.h:28
Trx * current_trx()
当前会话关联的事务
Definition: session.cpp:74
void set_trx_multi_operation_mode(bool multi_operation_mode)
设置当前事务为多语句模式,需要明确的指出提交或回滚
Definition: session.cpp:64
Stmt for Statement
Definition: stmt.h:78
事务结束的执行器,可以是提交或回滚
Definition: trx_end_executor.h:30
事务接口
Definition: trx.h:142