stmt.cpp 1.3 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 23 24 25 26

RC Stmt::create_stmt(Db *db, const Query &query, Stmt *&stmt)
{
  stmt = nullptr;

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

    case SCF_EXPLAIN: {
      return ExplainStmt::create(db, query.explain, stmt);
    }
    default: {
W
wangyunlai.wyl 已提交
41 42 43 44 45 46 47 48
      LOG_WARN("unknown query command");
    }
    break;
  }
  return RC::UNIMPLENMENT;
}