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.
if (drop.database.empty())
if (drop.temporary)
{
StoragePtr table = (context.hasSessionContext() ? context.getSessionContext() : context).tryRemoveExternalTable(drop.table);
if (table)

View File

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

View File

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