-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "sql/executor/drop_table_executor.h" | ||
|
||
#include "session/session.h" | ||
#include "common/log/log.h" | ||
#include "storage/table/table.h" | ||
#include "sql/stmt/drop_table_stmt.h" | ||
#include "event/sql_event.h" | ||
#include "event/session_event.h" | ||
#include "storage/db/db.h" | ||
|
||
RC DropTableExecutor::execute(SQLStageEvent *sql_event) | ||
{ | ||
Stmt *stmt = sql_event->stmt(); | ||
Session *session = sql_event->session_event()->session(); | ||
ASSERT(stmt->type() == StmtType::DROP_TABLE, | ||
"drop table executor can not run this command: %d", static_cast<int>(stmt->type())); | ||
|
||
DropTableStmt *drop_table_stmt = static_cast<DropTableStmt *>(stmt); | ||
const char *table_name = drop_table_stmt->table_name().c_str(); | ||
RC rc = session->get_current_db()->drop_table(table_name); | ||
return rc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include "common/rc.h" | ||
|
||
class SQLStageEvent; | ||
|
||
/** | ||
* @brief 删除表的执行器 | ||
* @ingroup Executor | ||
*/ | ||
class DropTableExecutor | ||
{ | ||
public: | ||
DropTableExecutor() = default; | ||
virtual ~DropTableExecutor() = default; | ||
|
||
RC execute(SQLStageEvent *sql_event); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "sql/stmt/drop_table_stmt.h" | ||
#include "event/sql_debug.h" | ||
|
||
RC DropTableStmt::create(Db *db, const DropTableSqlNode &drop_table, Stmt *&stmt) | ||
{ | ||
stmt = new DropTableStmt(drop_table.relation_name); | ||
sql_debug("drop table statement: table name %s", drop_table.relation_name.c_str()); | ||
return RC::SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "sql/stmt/stmt.h" | ||
|
||
class Db; | ||
|
||
/** | ||
* @brief 表示删除表的语句 | ||
* @ingroup Statement | ||
* @details | ||
*/ | ||
class DropTableStmt : public Stmt | ||
{ | ||
public: | ||
DropTableStmt(const std::string &table_name) | ||
: table_name_(table_name) | ||
{} | ||
virtual ~DropTableStmt() = default; | ||
|
||
StmtType type() const override { return StmtType::DROP_TABLE; } | ||
|
||
const std::string &table_name() const { return table_name_; } | ||
|
||
static RC create(Db *db, const DropTableSqlNode &drop_table, Stmt *&stmt); | ||
|
||
private: | ||
std::string table_name_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters