MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
show_tables_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 "sql/operator/string_list_physical_operator.h"
19#include "event/sql_event.h"
20#include "event/session_event.h"
21#include "sql/executor/sql_result.h"
22#include "session/session.h"
23#include "storage/db/db.h"
24
31{
32public:
33 ShowTablesExecutor() = default;
34 virtual ~ShowTablesExecutor() = default;
35
36 RC execute(SQLStageEvent *sql_event)
37 {
38 SqlResult *sql_result = sql_event->session_event()->sql_result();
39 SessionEvent *session_event = sql_event->session_event();
40
41 Db *db = session_event->session()->get_current_db();
42
43 std::vector<std::string> all_tables;
44 db->all_tables(all_tables);
45
46 TupleSchema tuple_schema;
47 tuple_schema.append_cell(TupleCellSpec("", "Tables_in_SYS", "Tables_in_SYS"));
48 sql_result->set_tuple_schema(tuple_schema);
49
50 auto oper = new StringListPhysicalOperator;
51 for (const std::string &s : all_tables) {
52 oper->append(s);
53 }
54
55 sql_result->set_operator(std::unique_ptr<PhysicalOperator>(oper));
56 return RC::SUCCESS;
57 }
58};
一个DB实例负责管理一批表
Definition: db.h:34
与SessionEvent类似,也是处理SQL请求的事件,只是用在SQL的不同阶段
Definition: sql_event.h:30
表示一个SQL请求
Definition: session_event.h:32
显示所有表的执行器
Definition: show_tables_executor.h:31
SQL执行结果
Definition: sql_result.h:33
字符串列表物理算子
Definition: string_list_physical_operator.h:26
Definition: tuple_cell.h:22
元组的结构,包含哪些字段(这里成为Cell),每个字段的说明
Definition: tuple.h:52