remove data on DROP DATABASE

This commit is contained in:
Alexander Tokmakov 2020-05-18 16:51:01 +03:00
parent bfcbc08bba
commit 6af9c78476
2 changed files with 9 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include <Parsers/ASTCreateQuery.h>
#include <Storages/IStorage.h>
#include <Poco/File.h>
#include <filesystem>
namespace DB
@ -84,4 +85,10 @@ UUID DatabaseMemory::tryGetTableUUID(const String & table_name) const
return UUIDHelpers::Nil;
}
void DatabaseMemory::drop(const Context & context)
{
/// Remove data on explicit DROP DATABASE
std::filesystem::remove_all(context.getPath() + data_path);
}
}

View File

@ -46,6 +46,8 @@ public:
UUID tryGetTableUUID(const String & table_name) const override;
void drop(const Context & context) override;
private:
String data_path;
using NameToASTCreate = std::unordered_map<String, ASTPtr>;