stmt.cpp 1.5 KB
Newer Older
羽飞's avatar
羽飞 已提交
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
W
wangyunlai.wyl 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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. */

//
// Created by Wangyunlai on 2022/5/22.
//

#include "rc.h"
#include "common/log/log.h"
#include "sql/stmt/insert_stmt.h"
#include "sql/stmt/delete_stmt.h"
#include "sql/stmt/select_stmt.h"
羽飞's avatar
羽飞 已提交
20
#include "sql/stmt/explain_stmt.h"
羽飞's avatar
羽飞 已提交
21
#include "sql/stmt/create_index_stmt.h"
W
wangyunlai.wyl 已提交
22

23
RC Stmt::create_stmt(Db *db, const Command &cmd, Stmt *&stmt)
W
wangyunlai.wyl 已提交
24 25 26
{
  stmt = nullptr;

27
  switch (cmd.flag) {
羽飞's avatar
羽飞 已提交
28
    case SCF_INSERT: {
29
      return InsertStmt::create(db, cmd.insertion, stmt);
W
wangyunlai.wyl 已提交
30
    }
羽飞's avatar
羽飞 已提交
31
    case SCF_DELETE: {
32
      return DeleteStmt::create(db, cmd.deletion, stmt);
W
wangyunlai.wyl 已提交
33
    }
羽飞's avatar
羽飞 已提交
34
    case SCF_SELECT: {
35
      return SelectStmt::create(db, cmd.selection, stmt);
羽飞's avatar
羽飞 已提交
36 37 38
    }

    case SCF_EXPLAIN: {
39
      return ExplainStmt::create(db, cmd.explain, stmt);
羽飞's avatar
羽飞 已提交
40
    }
羽飞's avatar
羽飞 已提交
41 42 43 44

    case SCF_CREATE_INDEX: {
      return CreateIndexStmt::create(db, cmd.create_index, stmt);
    }
羽飞's avatar
羽飞 已提交
45
    default: {
46
      LOG_INFO("Command::type %d doesn't need to create statement.", cmd.flag);
L
Longda Feng 已提交
47
    } break;
W
wangyunlai.wyl 已提交
48 49 50
  }
  return RC::UNIMPLENMENT;
}