2017-01-21 04:24:28 +00:00
|
|
|
#include <common/logger_useful.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Databases/DatabaseMemory.h>
|
|
|
|
#include <Databases/DatabasesCommon.h>
|
2019-12-05 13:44:22 +00:00
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
2016-10-25 13:49:07 +00:00
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2016-10-25 13:49:07 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-11-06 16:05:04 +00:00
|
|
|
DatabaseMemory::DatabaseMemory(const String & name_)
|
|
|
|
: DatabaseWithOwnTablesBase(name_, "DatabaseMemory(" + name_ + ")")
|
2020-01-20 20:08:47 +00:00
|
|
|
, data_path("data/" + escapeForFileName(database_name) + "/")
|
2018-03-23 20:46:43 +00:00
|
|
|
{}
|
|
|
|
|
2017-01-23 18:05:07 +00:00
|
|
|
void DatabaseMemory::createTable(
|
2017-12-01 20:21:35 +00:00
|
|
|
const Context & /*context*/,
|
2017-09-11 12:39:01 +00:00
|
|
|
const String & table_name,
|
|
|
|
const StoragePtr & table,
|
2017-12-01 20:21:35 +00:00
|
|
|
const ASTPtr & /*query*/)
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
attachTable(table_name, table);
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
2017-09-11 12:39:01 +00:00
|
|
|
void DatabaseMemory::removeTable(
|
2017-12-01 20:21:35 +00:00
|
|
|
const Context & /*context*/,
|
2017-09-11 12:39:01 +00:00
|
|
|
const String & table_name)
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
detachTable(table_name);
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 11:11:01 +00:00
|
|
|
ASTPtr DatabaseMemory::getCreateDatabaseQuery(const Context & /*context*/) const
|
2018-03-13 13:28:32 +00:00
|
|
|
{
|
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;
|
2018-03-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|