ISSUES-117 support drop temporary table

This commit is contained in:
zhang2014 2018-01-28 00:17:05 +08:00
parent bfe48f1255
commit 19e7c291db
3 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,7 @@ BlockIO InterpreterDropQuery::execute()
} }
/// Drop temporary table. /// Drop temporary table.
if (drop.database.empty()) if (drop.temporary)
{ {
StoragePtr table = (context.hasSessionContext() ? context.getSessionContext() : context).tryRemoveExternalTable(drop.table); StoragePtr table = (context.hasSessionContext() ? context.getSessionContext() : context).tryRemoveExternalTable(drop.table);
if (table) if (table)

View File

@ -15,6 +15,7 @@ class ASTDropQuery : public ASTQueryWithOutput, public ASTQueryWithOnCluster
public: public:
bool detach{false}; /// DETACH query, not DROP. bool detach{false}; /// DETACH query, not DROP.
bool if_exists{false}; bool if_exists{false};
bool temporary{false};
String database; String database;
String table; String table;

View File

@ -17,6 +17,7 @@ bool ParserDropQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
ParserKeyword s_drop("DROP"); ParserKeyword s_drop("DROP");
ParserKeyword s_detach("DETACH"); ParserKeyword s_detach("DETACH");
ParserKeyword s_temporary("TEMPORARY");
ParserKeyword s_table("TABLE"); ParserKeyword s_table("TABLE");
ParserKeyword s_database("DATABASE"); ParserKeyword s_database("DATABASE");
ParserToken s_dot(TokenType::Dot); ParserToken s_dot(TokenType::Dot);
@ -28,6 +29,7 @@ bool ParserDropQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
String cluster_str; String cluster_str;
bool detach = false; bool detach = false;
bool if_exists = false; bool if_exists = false;
bool temporary = false;
if (!s_drop.ignore(pos, expected)) if (!s_drop.ignore(pos, expected))
{ {
@ -53,6 +55,9 @@ bool ParserDropQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
} }
else else
{ {
if (s_temporary.ignore(pos, expected))
temporary = true;
if (!s_table.ignore(pos, expected)) if (!s_table.ignore(pos, expected))
return false; return false;
@ -81,6 +86,7 @@ bool ParserDropQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
query->detach = detach; query->detach = detach;
query->if_exists = if_exists; query->if_exists = if_exists;
query->temporary = temporary;
if (database) if (database)
query->database = typeid_cast<ASTIdentifier &>(*database).name; query->database = typeid_cast<ASTIdentifier &>(*database).name;
if (table) if (table)