1#include <common/logger_useful.h>
2#include <Databases/DatabaseMemory.h>
3#include <Databases/DatabasesCommon.h>
4#include <Parsers/ASTCreateQuery.h>
5
6
7namespace DB
8{
9
10DatabaseMemory::DatabaseMemory(const String & name_)
11 : DatabaseWithOwnTablesBase(name_, "DatabaseMemory(" + name_ + ")")
12{}
13
14void DatabaseMemory::createTable(
15 const Context & /*context*/,
16 const String & table_name,
17 const StoragePtr & table,
18 const ASTPtr & /*query*/)
19{
20 attachTable(table_name, table);
21}
22
23void DatabaseMemory::removeTable(
24 const Context & /*context*/,
25 const String & table_name)
26{
27 detachTable(table_name);
28}
29
30ASTPtr DatabaseMemory::getCreateDatabaseQuery() const
31{
32 auto create_query = std::make_shared<ASTCreateQuery>();
33 create_query->database = database_name;
34 create_query->set(create_query->storage, std::make_shared<ASTStorage>());
35 create_query->storage->set(create_query->storage->engine, makeASTFunction(getEngineName()));
36 return create_query;
37}
38
39}
40