2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/IStorage.h>
|
2019-05-17 14:34:25 +00:00
|
|
|
|
2018-12-25 23:11:36 +00:00
|
|
|
#include <Storages/AlterCommands.h>
|
2019-08-07 15:21:45 +00:00
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
|
|
|
#include <Parsers/ASTSetQuery.h>
|
2020-02-10 15:50:12 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2019-11-19 12:46:07 +00:00
|
|
|
#include <Common/StringUtils/StringUtils.h>
|
2019-10-08 18:42:22 +00:00
|
|
|
#include <Common/quoteString.h>
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2019-10-21 16:26:29 +00:00
|
|
|
#include <Processors/Executors/TreeExecutorBlockInputStream.h>
|
2019-09-13 12:59:48 +00:00
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <sparsehash/dense_hash_map>
|
|
|
|
#include <sparsehash/dense_hash_set>
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int COLUMN_QUERIED_MORE_THAN_ONCE;
|
|
|
|
extern const int DUPLICATE_COLUMN;
|
|
|
|
extern const int EMPTY_LIST_OF_COLUMNS_PASSED;
|
|
|
|
extern const int EMPTY_LIST_OF_COLUMNS_QUERIED;
|
|
|
|
extern const int NO_SUCH_COLUMN_IN_TABLE;
|
|
|
|
extern const int NOT_FOUND_COLUMN_IN_BLOCK;
|
|
|
|
extern const int TYPE_MISMATCH;
|
2019-07-24 12:56:39 +00:00
|
|
|
extern const int SETTINGS_ARE_NOT_SUPPORTED;
|
2019-08-07 15:21:45 +00:00
|
|
|
extern const int UNKNOWN_SETTING;
|
2019-08-27 23:47:30 +00:00
|
|
|
extern const int TABLE_IS_DROPPED;
|
2019-12-26 18:17:05 +00:00
|
|
|
extern const int NOT_IMPLEMENTED;
|
2019-05-17 14:34:25 +00:00
|
|
|
}
|
|
|
|
|
2019-12-12 12:30:31 +00:00
|
|
|
IStorage::IStorage(StorageID storage_id_, ColumnsDescription virtuals_) : storage_id(std::move(storage_id_)), virtuals(std::move(virtuals_))
|
2019-05-17 14:34:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-21 11:24:32 +00:00
|
|
|
const ColumnsDescription & IStorage::getColumns() const
|
2019-05-17 14:34:25 +00:00
|
|
|
{
|
2019-05-21 11:24:32 +00:00
|
|
|
return columns;
|
2019-05-17 14:34:25 +00:00
|
|
|
}
|
|
|
|
|
2019-07-27 15:36:40 +00:00
|
|
|
const ColumnsDescription & IStorage::getVirtuals() const
|
|
|
|
{
|
|
|
|
return virtuals;
|
|
|
|
}
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
const IndicesDescription & IStorage::getIndices() const
|
|
|
|
{
|
|
|
|
return indices;
|
|
|
|
}
|
|
|
|
|
2019-05-19 06:08:25 +00:00
|
|
|
const ConstraintsDescription & IStorage::getConstraints() const
|
|
|
|
{
|
|
|
|
return constraints;
|
|
|
|
}
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
NameAndTypePair IStorage::getColumn(const String & column_name) const
|
|
|
|
{
|
|
|
|
/// By default, we assume that there are no virtual columns in the storage.
|
|
|
|
return getColumns().getPhysical(column_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IStorage::hasColumn(const String & column_name) const
|
|
|
|
{
|
|
|
|
/// By default, we assume that there are no virtual columns in the storage.
|
|
|
|
return getColumns().hasPhysical(column_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
Block IStorage::getSampleBlock() const
|
|
|
|
{
|
|
|
|
Block res;
|
|
|
|
|
|
|
|
for (const auto & column : getColumns().getAllPhysical())
|
|
|
|
res.insert({column.type->createColumn(), column.type, column.name});
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-06-18 16:32:37 +00:00
|
|
|
Block IStorage::getSampleBlockWithVirtuals() const
|
|
|
|
{
|
|
|
|
auto res = getSampleBlock();
|
|
|
|
|
|
|
|
for (const auto & column : getColumns().getVirtuals())
|
|
|
|
res.insert({column.type->createColumn(), column.type, column.name});
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
Block IStorage::getSampleBlockNonMaterialized() const
|
|
|
|
{
|
|
|
|
Block res;
|
|
|
|
|
|
|
|
for (const auto & column : getColumns().getOrdinary())
|
|
|
|
res.insert({column.type->createColumn(), column.type, column.name});
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
Block IStorage::getSampleBlockForColumns(const Names & column_names) const
|
|
|
|
{
|
|
|
|
Block res;
|
|
|
|
|
|
|
|
NamesAndTypesList all_columns = getColumns().getAll();
|
|
|
|
std::unordered_map<String, DataTypePtr> columns_map;
|
|
|
|
for (const auto & elem : all_columns)
|
|
|
|
columns_map.emplace(elem.name, elem.type);
|
|
|
|
|
|
|
|
for (const auto & name : column_names)
|
|
|
|
{
|
|
|
|
auto it = columns_map.find(name);
|
|
|
|
if (it != columns_map.end())
|
|
|
|
{
|
|
|
|
res.insert({it->second->createColumn(), it->second, it->first});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/// Virtual columns.
|
|
|
|
NameAndTypePair elem = getColumn(name);
|
|
|
|
res.insert({elem.type->createColumn(), elem.type, elem.name});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2019-09-17 21:08:20 +00:00
|
|
|
using NamesAndTypesMap = ::google::dense_hash_map<StringRef, const IDataType *, StringRefHash>;
|
|
|
|
using UniqueStrings = ::google::dense_hash_set<StringRef, StringRefHash>;
|
2019-05-17 14:34:25 +00:00
|
|
|
|
|
|
|
String listOfColumns(const NamesAndTypesList & available_columns)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
for (auto it = available_columns.begin(); it != available_columns.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != available_columns.begin())
|
|
|
|
ss << ", ";
|
|
|
|
ss << it->name;
|
|
|
|
}
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
NamesAndTypesMap getColumnsMap(const NamesAndTypesList & columns)
|
|
|
|
{
|
|
|
|
NamesAndTypesMap res;
|
|
|
|
res.set_empty_key(StringRef());
|
|
|
|
|
|
|
|
for (const auto & column : columns)
|
|
|
|
res.insert({column.name, column.type.get()});
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
UniqueStrings initUniqueStrings()
|
|
|
|
{
|
|
|
|
UniqueStrings strings;
|
|
|
|
strings.set_empty_key(StringRef());
|
|
|
|
return strings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-07 16:10:14 +00:00
|
|
|
void IStorage::check(const Names & column_names, bool include_virtuals) const
|
2019-05-17 14:34:25 +00:00
|
|
|
{
|
2019-08-07 16:10:14 +00:00
|
|
|
NamesAndTypesList available_columns = getColumns().getAllPhysical();
|
|
|
|
if (include_virtuals)
|
|
|
|
available_columns.splice(available_columns.end(), getColumns().getVirtuals());
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
const String list_of_columns = listOfColumns(available_columns);
|
|
|
|
|
|
|
|
if (column_names.empty())
|
|
|
|
throw Exception("Empty list of columns queried. There are columns: " + list_of_columns, ErrorCodes::EMPTY_LIST_OF_COLUMNS_QUERIED);
|
|
|
|
|
|
|
|
const auto columns_map = getColumnsMap(available_columns);
|
|
|
|
|
|
|
|
auto unique_names = initUniqueStrings();
|
|
|
|
for (const auto & name : column_names)
|
|
|
|
{
|
|
|
|
if (columns_map.end() == columns_map.find(name))
|
|
|
|
throw Exception(
|
2019-12-10 20:47:05 +00:00
|
|
|
"There is no column with name " + backQuote(name) + " in table " + getStorageID().getNameForLogs() + ". There are columns: " + list_of_columns,
|
2019-05-17 14:34:25 +00:00
|
|
|
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
|
|
|
|
|
|
|
|
if (unique_names.end() != unique_names.find(name))
|
|
|
|
throw Exception("Column " + name + " queried more than once", ErrorCodes::COLUMN_QUERIED_MORE_THAN_ONCE);
|
|
|
|
unique_names.insert(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IStorage::check(const NamesAndTypesList & provided_columns) const
|
|
|
|
{
|
|
|
|
const NamesAndTypesList & available_columns = getColumns().getAllPhysical();
|
|
|
|
const auto columns_map = getColumnsMap(available_columns);
|
|
|
|
|
|
|
|
auto unique_names = initUniqueStrings();
|
|
|
|
for (const NameAndTypePair & column : provided_columns)
|
|
|
|
{
|
|
|
|
auto it = columns_map.find(column.name);
|
|
|
|
if (columns_map.end() == it)
|
|
|
|
throw Exception(
|
|
|
|
"There is no column with name " + column.name + ". There are columns: " + listOfColumns(available_columns),
|
|
|
|
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
|
|
|
|
|
|
|
|
if (!column.type->equals(*it->second))
|
|
|
|
throw Exception(
|
|
|
|
"Type mismatch for column " + column.name + ". Column has type " + it->second->getName() + ", got type "
|
|
|
|
+ column.type->getName(),
|
|
|
|
ErrorCodes::TYPE_MISMATCH);
|
|
|
|
|
|
|
|
if (unique_names.end() != unique_names.find(column.name))
|
|
|
|
throw Exception("Column " + column.name + " queried more than once", ErrorCodes::COLUMN_QUERIED_MORE_THAN_ONCE);
|
|
|
|
unique_names.insert(column.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IStorage::check(const NamesAndTypesList & provided_columns, const Names & column_names) const
|
|
|
|
{
|
|
|
|
const NamesAndTypesList & available_columns = getColumns().getAllPhysical();
|
|
|
|
const auto available_columns_map = getColumnsMap(available_columns);
|
|
|
|
const auto & provided_columns_map = getColumnsMap(provided_columns);
|
|
|
|
|
|
|
|
if (column_names.empty())
|
|
|
|
throw Exception(
|
|
|
|
"Empty list of columns queried. There are columns: " + listOfColumns(available_columns),
|
|
|
|
ErrorCodes::EMPTY_LIST_OF_COLUMNS_QUERIED);
|
|
|
|
|
|
|
|
auto unique_names = initUniqueStrings();
|
|
|
|
for (const String & name : column_names)
|
|
|
|
{
|
|
|
|
auto it = provided_columns_map.find(name);
|
|
|
|
if (provided_columns_map.end() == it)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto jt = available_columns_map.find(name);
|
|
|
|
if (available_columns_map.end() == jt)
|
|
|
|
throw Exception(
|
|
|
|
"There is no column with name " + name + ". There are columns: " + listOfColumns(available_columns),
|
|
|
|
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
|
|
|
|
|
|
|
|
if (!it->second->equals(*jt->second))
|
|
|
|
throw Exception(
|
|
|
|
"Type mismatch for column " + name + ". Column has type " + jt->second->getName() + ", got type " + it->second->getName(),
|
|
|
|
ErrorCodes::TYPE_MISMATCH);
|
|
|
|
|
|
|
|
if (unique_names.end() != unique_names.find(name))
|
|
|
|
throw Exception("Column " + name + " queried more than once", ErrorCodes::COLUMN_QUERIED_MORE_THAN_ONCE);
|
|
|
|
unique_names.insert(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IStorage::check(const Block & block, bool need_all) const
|
|
|
|
{
|
|
|
|
const NamesAndTypesList & available_columns = getColumns().getAllPhysical();
|
|
|
|
const auto columns_map = getColumnsMap(available_columns);
|
|
|
|
|
|
|
|
NameSet names_in_block;
|
|
|
|
|
|
|
|
block.checkNumberOfRows();
|
|
|
|
|
|
|
|
for (const auto & column : block)
|
|
|
|
{
|
|
|
|
if (names_in_block.count(column.name))
|
|
|
|
throw Exception("Duplicate column " + column.name + " in block", ErrorCodes::DUPLICATE_COLUMN);
|
|
|
|
|
|
|
|
names_in_block.insert(column.name);
|
|
|
|
|
|
|
|
auto it = columns_map.find(column.name);
|
|
|
|
if (columns_map.end() == it)
|
|
|
|
throw Exception(
|
|
|
|
"There is no column with name " + column.name + ". There are columns: " + listOfColumns(available_columns),
|
|
|
|
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
|
|
|
|
|
|
|
|
if (!column.type->equals(*it->second))
|
|
|
|
throw Exception(
|
|
|
|
"Type mismatch for column " + column.name + ". Column has type " + it->second->getName() + ", got type "
|
|
|
|
+ column.type->getName(),
|
|
|
|
ErrorCodes::TYPE_MISMATCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_all && names_in_block.size() < columns_map.size())
|
|
|
|
{
|
|
|
|
for (auto it = available_columns.begin(); it != available_columns.end(); ++it)
|
|
|
|
{
|
|
|
|
if (!names_in_block.count(it->name))
|
|
|
|
throw Exception("Expected column " + it->name, ErrorCodes::NOT_FOUND_COLUMN_IN_BLOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 11:24:32 +00:00
|
|
|
void IStorage::setColumns(ColumnsDescription columns_)
|
|
|
|
{
|
|
|
|
if (columns_.getOrdinary().empty())
|
|
|
|
throw Exception("Empty list of columns passed", ErrorCodes::EMPTY_LIST_OF_COLUMNS_PASSED);
|
|
|
|
columns = std::move(columns_);
|
|
|
|
|
|
|
|
for (const auto & column : virtuals)
|
|
|
|
{
|
|
|
|
if (!columns.has(column.name))
|
|
|
|
columns.add(column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IStorage::setIndices(IndicesDescription indices_)
|
|
|
|
{
|
|
|
|
indices = std::move(indices_);
|
|
|
|
}
|
|
|
|
|
2019-07-04 19:40:00 +00:00
|
|
|
void IStorage::setConstraints(ConstraintsDescription constraints_)
|
|
|
|
{
|
|
|
|
constraints = std::move(constraints_);
|
|
|
|
}
|
|
|
|
|
2019-05-21 11:24:32 +00:00
|
|
|
bool IStorage::isVirtualColumn(const String & column_name) const
|
|
|
|
{
|
|
|
|
return getColumns().get(column_name).is_virtual;
|
|
|
|
}
|
|
|
|
|
2019-05-17 14:48:03 +00:00
|
|
|
TableStructureReadLockHolder IStorage::lockStructureForShare(bool will_add_new_data, const String & query_id)
|
|
|
|
{
|
|
|
|
TableStructureReadLockHolder result;
|
|
|
|
if (will_add_new_data)
|
|
|
|
result.new_data_structure_lock = new_data_structure_lock->getLock(RWLockImpl::Read, query_id);
|
|
|
|
result.structure_lock = structure_lock->getLock(RWLockImpl::Read, query_id);
|
|
|
|
|
|
|
|
if (is_dropped)
|
|
|
|
throw Exception("Table is dropped", ErrorCodes::TABLE_IS_DROPPED);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
TableStructureWriteLockHolder IStorage::lockAlterIntention(const String & query_id)
|
|
|
|
{
|
|
|
|
TableStructureWriteLockHolder result;
|
|
|
|
result.alter_intention_lock = alter_intention_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
|
|
|
|
if (is_dropped)
|
|
|
|
throw Exception("Table is dropped", ErrorCodes::TABLE_IS_DROPPED);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IStorage::lockNewDataStructureExclusively(TableStructureWriteLockHolder & lock_holder, const String & query_id)
|
|
|
|
{
|
|
|
|
if (!lock_holder.alter_intention_lock)
|
2019-12-10 20:47:05 +00:00
|
|
|
throw Exception("Alter intention lock for table " + getStorageID().getNameForLogs() + " was not taken. This is a bug.", ErrorCodes::LOGICAL_ERROR);
|
2019-05-17 14:48:03 +00:00
|
|
|
|
|
|
|
lock_holder.new_data_structure_lock = new_data_structure_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IStorage::lockStructureExclusively(TableStructureWriteLockHolder & lock_holder, const String & query_id)
|
|
|
|
{
|
|
|
|
if (!lock_holder.alter_intention_lock)
|
2019-12-10 20:47:05 +00:00
|
|
|
throw Exception("Alter intention lock for table " + getStorageID().getNameForLogs() + " was not taken. This is a bug.", ErrorCodes::LOGICAL_ERROR);
|
2019-05-17 14:48:03 +00:00
|
|
|
|
|
|
|
if (!lock_holder.new_data_structure_lock)
|
|
|
|
lock_holder.new_data_structure_lock = new_data_structure_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
lock_holder.structure_lock = structure_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
TableStructureWriteLockHolder IStorage::lockExclusively(const String & query_id)
|
|
|
|
{
|
|
|
|
TableStructureWriteLockHolder result;
|
|
|
|
result.alter_intention_lock = alter_intention_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
|
|
|
|
if (is_dropped)
|
|
|
|
throw Exception("Table is dropped", ErrorCodes::TABLE_IS_DROPPED);
|
|
|
|
|
|
|
|
result.new_data_structure_lock = new_data_structure_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
result.structure_lock = structure_lock->getLock(RWLockImpl::Write, query_id);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-12-26 18:17:05 +00:00
|
|
|
StorageInMemoryMetadata IStorage::getInMemoryMetadata() const
|
2019-08-07 15:21:45 +00:00
|
|
|
{
|
2019-12-26 18:17:05 +00:00
|
|
|
return
|
2019-08-07 15:21:45 +00:00
|
|
|
{
|
2019-12-26 18:17:05 +00:00
|
|
|
.columns = getColumns(),
|
|
|
|
.indices = getIndices(),
|
|
|
|
.constraints = getConstraints(),
|
2019-08-07 15:21:45 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
void IStorage::alter(
|
|
|
|
const AlterCommands & params,
|
|
|
|
const Context & context,
|
2019-12-29 16:34:32 +00:00
|
|
|
TableStructureWriteLockHolder & table_lock_holder)
|
2018-12-25 23:11:36 +00:00
|
|
|
{
|
2019-12-29 16:34:32 +00:00
|
|
|
lockStructureExclusively(table_lock_holder, context.getCurrentQueryId());
|
2019-12-10 20:47:05 +00:00
|
|
|
auto table_id = getStorageID();
|
2019-12-26 18:17:05 +00:00
|
|
|
StorageInMemoryMetadata metadata = getInMemoryMetadata();
|
|
|
|
params.apply(metadata);
|
2019-12-30 11:08:09 +00:00
|
|
|
context.getDatabase(table_id.database_name)->alterTable(context, table_id.table_name, metadata);
|
2019-12-26 18:17:05 +00:00
|
|
|
setColumns(std::move(metadata.columns));
|
|
|
|
}
|
2019-08-27 09:34:53 +00:00
|
|
|
|
2019-12-26 18:17:05 +00:00
|
|
|
|
|
|
|
void IStorage::checkAlterIsPossible(const AlterCommands & commands, const Settings & /* settings */)
|
|
|
|
{
|
|
|
|
for (const auto & command : commands)
|
2019-08-27 09:34:53 +00:00
|
|
|
{
|
2019-12-27 14:36:59 +00:00
|
|
|
if (!command.isCommentAlter())
|
2019-12-26 18:17:05 +00:00
|
|
|
throw Exception(
|
|
|
|
"Alter of type '" + alterTypeToString(command.type) + "' is not supported by storage " + getName(),
|
|
|
|
ErrorCodes::NOT_IMPLEMENTED);
|
2018-12-25 23:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-17 14:48:03 +00:00
|
|
|
|
2020-02-19 16:02:37 +00:00
|
|
|
BlockInputStreams IStorage::readStreams(
|
2019-09-13 12:59:48 +00:00
|
|
|
const Names & column_names,
|
|
|
|
const SelectQueryInfo & query_info,
|
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum processed_stage,
|
|
|
|
size_t max_block_size,
|
|
|
|
unsigned num_streams)
|
|
|
|
{
|
2020-02-17 10:42:14 +00:00
|
|
|
ForceTreeShapedPipeline enable_tree_shape(query_info);
|
2020-02-19 16:02:37 +00:00
|
|
|
auto pipes = read(column_names, query_info, context, processed_stage, max_block_size, num_streams);
|
2019-09-13 12:59:48 +00:00
|
|
|
|
|
|
|
BlockInputStreams res;
|
|
|
|
res.reserve(pipes.size());
|
|
|
|
|
|
|
|
for (auto & pipe : pipes)
|
2019-10-21 16:26:29 +00:00
|
|
|
res.emplace_back(std::make_shared<TreeExecutorBlockInputStream>(std::move(pipe)));
|
2019-09-13 12:59:48 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-12-27 19:30:22 +00:00
|
|
|
StorageID IStorage::getStorageID() const
|
2019-12-03 16:25:32 +00:00
|
|
|
{
|
2020-01-09 16:32:21 +00:00
|
|
|
std::lock_guard<std::mutex> lock(id_mutex);
|
2019-12-12 12:30:31 +00:00
|
|
|
return storage_id;
|
2019-12-03 16:25:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-27 19:30:22 +00:00
|
|
|
void IStorage::renameInMemory(const String & new_database_name, const String & new_table_name)
|
2019-12-03 16:25:32 +00:00
|
|
|
{
|
2020-01-09 16:32:21 +00:00
|
|
|
std::lock_guard<std::mutex> lock(id_mutex);
|
2019-12-12 12:30:31 +00:00
|
|
|
storage_id.database_name = new_database_name;
|
|
|
|
storage_id.table_name = new_table_name;
|
2019-12-03 16:25:32 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
}
|