MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
stmt.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 2022/5/22.
13//
14
15#pragma once
16
17#include "common/rc.h"
18#include "sql/parser/parse_defs.h"
19
20class Db;
21
32#define DEFINE_ENUM() \
33 DEFINE_ENUM_ITEM(CALC) \
34 DEFINE_ENUM_ITEM(SELECT) \
35 DEFINE_ENUM_ITEM(INSERT) \
36 DEFINE_ENUM_ITEM(UPDATE) \
37 DEFINE_ENUM_ITEM(DELETE) \
38 DEFINE_ENUM_ITEM(CREATE_TABLE) \
39 DEFINE_ENUM_ITEM(DROP_TABLE) \
40 DEFINE_ENUM_ITEM(CREATE_INDEX) \
41 DEFINE_ENUM_ITEM(DROP_INDEX) \
42 DEFINE_ENUM_ITEM(SYNC) \
43 DEFINE_ENUM_ITEM(SHOW_TABLES) \
44 DEFINE_ENUM_ITEM(DESC_TABLE) \
45 DEFINE_ENUM_ITEM(BEGIN) \
46 DEFINE_ENUM_ITEM(COMMIT) \
47 DEFINE_ENUM_ITEM(ROLLBACK) \
48 DEFINE_ENUM_ITEM(LOAD_DATA) \
49 DEFINE_ENUM_ITEM(HELP) \
50 DEFINE_ENUM_ITEM(EXIT) \
51 DEFINE_ENUM_ITEM(EXPLAIN) \
52 DEFINE_ENUM_ITEM(PREDICATE) \
53 DEFINE_ENUM_ITEM(SET_VARIABLE)
54
55enum class StmtType {
56 #define DEFINE_ENUM_ITEM(name) name,
58 #undef DEFINE_ENUM_ITEM
59};
60
61inline const char *stmt_type_name(StmtType type)
62{
63 switch (type) {
64 #define DEFINE_ENUM_ITEM(name) case StmtType::name: return #name;
66 #undef DEFINE_ENUM_ITEM
67 default: return "unkown";
68 }
69}
70
77class Stmt
78{
79public:
80 Stmt() = default;
81 virtual ~Stmt() = default;
82
83 virtual StmtType type() const = 0;
84
85public:
86 static RC create_stmt(Db *db, ParsedSqlNode &sql_node, Stmt *&stmt);
87
88private:
89};
一个DB实例负责管理一批表
Definition: db.h:34
表示一个SQL语句
Definition: parse_defs.h:290
Stmt for Statement
Definition: stmt.h:78
#define DEFINE_ENUM()
Statement的类型
Definition: stmt.h:32