MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
default_handler.h
1/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and 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 Meiyi & Longda on 2021/5/11.
13//
14#pragma once
15
16#include <string>
17#include <map>
18
19#include "storage/db/db.h"
20
21class Trx;
22
24public:
26
27 virtual ~DefaultHandler() noexcept;
28
29 RC init(const char *base_dir);
30 void destroy();
31
40 RC create_db(const char *dbname);
41
48 RC drop_db(const char *dbname);
49
55 RC open_db(const char *dbname);
56
62 RC close_db(const char *dbname);
63
70 RC execute(const char *sql);
71
83 RC create_table(const char *dbname, const char *relation_name, int attribute_count, const AttrInfoSqlNode *attributes);
84
90 RC drop_table(const char *dbname, const char *relation_name);
91
92public:
93 Db *find_db(const char *dbname) const;
94 Table *find_table(const char *dbname, const char *table_name) const;
95
96 RC sync();
97
98public:
99 static void set_default(DefaultHandler *handler);
100 static DefaultHandler &get_default();
101
102private:
103 std::string base_dir_;
104 std::string db_dir_;
105 std::map<std::string, Db *> opened_dbs_;
106}; // class Handler
一个DB实例负责管理一批表
Definition: db.h:34
Definition: default_handler.h:23
RC execute(const char *sql)
Definition: default_handler.cpp:156
RC create_db(const char *dbname)
Definition: default_handler.cpp:97
RC create_table(const char *dbname, const char *relation_name, int attribute_count, const AttrInfoSqlNode *attributes)
Definition: default_handler.cpp:161
RC close_db(const char *dbname)
Definition: default_handler.cpp:151
RC drop_table(const char *dbname, const char *relation_name)
Definition: default_handler.cpp:171
RC drop_db(const char *dbname)
Definition: default_handler.cpp:118
RC open_db(const char *dbname)
Definition: default_handler.cpp:123
Definition: table.h:37
事务接口
Definition: trx.h:142
描述一个属性
Definition: parse_defs.h:149