stmt.cpp 1.4 KB
Newer Older
W
wangyunlai.wyl 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
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"
W
wangyunlai.wyl 已提交
21

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

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

    case SCF_EXPLAIN: {
38
      return ExplainStmt::create(db, cmd.explain, stmt);
羽飞's avatar
羽飞 已提交
39 40
    }
    default: {
41
      LOG_INFO("Command::type %d doesn't need to create statement.", cmd.flag);
W
wangyunlai.wyl 已提交
42 43 44 45 46 47 48
    }
    break;
  }
  return RC::UNIMPLENMENT;
}