ClickHouse/dbms/src/Databases/DatabaseMemory.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

#include <common/logger_useful.h>
#include <Databases/DatabaseMemory.h>
#include <Databases/DatabasesCommon.h>
2019-12-05 13:44:22 +00:00
#include <Parsers/ASTCreateQuery.h>
namespace DB
{
DatabaseMemory::DatabaseMemory(const String & name_)
: DatabaseWithOwnTablesBase(name_, "DatabaseMemory(" + name_ + ")")
2020-01-20 20:08:47 +00:00
, data_path("data/" + escapeForFileName(database_name) + "/")
{}
void DatabaseMemory::createTable(
2017-12-01 20:21:35 +00:00
const Context & /*context*/,
const String & table_name,
const StoragePtr & table,
2017-12-01 20:21:35 +00:00
const ASTPtr & /*query*/)
{
attachTable(table_name, table);
}
void DatabaseMemory::removeTable(
2017-12-01 20:21:35 +00:00
const Context & /*context*/,
const String & table_name)
{
detachTable(table_name);
}
ASTPtr DatabaseMemory::getCreateDatabaseQuery(const Context & /*context*/) const
{
2019-12-05 13:44:22 +00:00
auto create_query = std::make_shared<ASTCreateQuery>();
create_query->database = database_name;
create_query->set(create_query->storage, std::make_shared<ASTStorage>());
create_query->storage->set(create_query->storage->engine, makeASTFunction(getEngineName()));
return create_query;
}
}