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>
|
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
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2018-01-30 17:47:04 +00:00
|
|
|
extern const int CANNOT_GET_CREATE_TABLE_QUERY;
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
DatabaseMemory::DatabaseMemory(String name_)
|
|
|
|
: DatabaseWithOwnTablesBase(std::move(name_))
|
|
|
|
, log(&Logger::get("DatabaseMemory(" + name + ")"))
|
|
|
|
{}
|
|
|
|
|
2017-09-11 12:39:01 +00:00
|
|
|
void DatabaseMemory::loadTables(
|
2017-12-01 20:21:35 +00:00
|
|
|
Context & /*context*/,
|
|
|
|
ThreadPool * /*thread_pool*/,
|
|
|
|
bool /*has_force_restore_data_flag*/)
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
/// Nothing to load.
|
2016-10-25 13:49:07 +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
|
|
|
}
|
|
|
|
|
|
|
|
void DatabaseMemory::renameTable(
|
2017-12-01 20:21:35 +00:00
|
|
|
const Context &,
|
|
|
|
const String &,
|
|
|
|
IDatabase &,
|
|
|
|
const String &)
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
throw Exception("DatabaseMemory: renameTable() is not supported", ErrorCodes::NOT_IMPLEMENTED);
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
2017-09-11 12:39:01 +00:00
|
|
|
void DatabaseMemory::alterTable(
|
2017-12-01 20:21:35 +00:00
|
|
|
const Context &,
|
|
|
|
const String &,
|
2018-03-06 20:18:34 +00:00
|
|
|
const ColumnsDescription &,
|
2017-12-01 20:21:35 +00:00
|
|
|
const ASTModifier &)
|
2017-09-11 12:39:01 +00:00
|
|
|
{
|
|
|
|
throw Exception("DatabaseMemory: alterTable() is not supported", ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
time_t DatabaseMemory::getTableMetadataModificationTime(
|
2017-12-01 20:21:35 +00:00
|
|
|
const Context &,
|
|
|
|
const String &)
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
return static_cast<time_t>(0);
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
2018-03-13 13:28:32 +00:00
|
|
|
ASTPtr DatabaseMemory::getCreateTableQuery(
|
2017-12-01 20:21:35 +00:00
|
|
|
const Context &,
|
|
|
|
const String &) const
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
2018-01-30 17:47:04 +00:00
|
|
|
throw Exception("There is no CREATE TABLE query for DatabaseMemory tables", ErrorCodes::CANNOT_GET_CREATE_TABLE_QUERY);
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
2018-03-29 00:01:07 +00:00
|
|
|
ASTPtr DatabaseMemory::getCreateDatabaseQuery(
|
|
|
|
const Context &) const
|
2018-03-13 13:28:32 +00:00
|
|
|
{
|
|
|
|
throw Exception("There is no CREATE DATABASE query for DatabaseMemory", ErrorCodes::CANNOT_GET_CREATE_TABLE_QUERY);
|
|
|
|
}
|
|
|
|
|
2018-05-10 15:56:38 +00:00
|
|
|
String DatabaseMemory::getDatabaseName() const
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2016-10-25 13:49:07 +00:00
|
|
|
}
|