mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-13 19:14:30 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
#include <Storages/StorageNull.h>
|
|
#include <Storages/StorageFactory.h>
|
|
#include <Storages/AlterCommands.h>
|
|
|
|
#include <Interpreters/InterpreterAlterQuery.h>
|
|
#include <Interpreters/Context.h>
|
|
#include <Databases/IDatabase.h>
|
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int NOT_IMPLEMENTED;
|
|
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
|
}
|
|
|
|
|
|
void registerStorageNull(StorageFactory & factory)
|
|
{
|
|
factory.registerStorage("Null", [](const StorageFactory::Arguments & args)
|
|
{
|
|
if (!args.engine_args.empty())
|
|
throw Exception(
|
|
"Engine " + args.engine_name + " doesn't support any arguments (" + toString(args.engine_args.size()) + " given)",
|
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
|
|
return StorageNull::create(args.table_id, args.columns, args.constraints);
|
|
});
|
|
}
|
|
|
|
void StorageNull::checkAlterIsPossible(const AlterCommands & commands, const Settings & /* settings */)
|
|
{
|
|
for (const auto & command : commands)
|
|
{
|
|
if (command.type != AlterCommand::Type::ADD_COLUMN && command.type != AlterCommand::Type::MODIFY_COLUMN
|
|
&& command.type != AlterCommand::Type::DROP_COLUMN && command.type != AlterCommand::Type::COMMENT_COLUMN)
|
|
throw Exception(
|
|
"Alter of type '" + alterTypeToString(command.type) + "' is not supported by storage " + getName(),
|
|
ErrorCodes::NOT_IMPLEMENTED);
|
|
}
|
|
}
|
|
|
|
|
|
void StorageNull::alter(
|
|
const AlterCommands & params, const Context & context, TableStructureWriteLockHolder & table_lock_holder)
|
|
{
|
|
lockStructureExclusively(table_lock_holder, context.getCurrentQueryId());
|
|
auto table_id = getStorageID();
|
|
|
|
StorageInMemoryMetadata metadata = getInMemoryMetadata();
|
|
params.apply(metadata);
|
|
DatabaseCatalog::instance().getDatabase(table_id.database_name)->alterTable(context, table_id.table_name, metadata);
|
|
setColumns(std::move(metadata.columns));
|
|
}
|
|
|
|
}
|