ClickHouse/dbms/src/Storages/StorageNull.cpp

43 lines
1.2 KiB
C++
Raw Normal View History

#include <Storages/StorageNull.h>
#include <Storages/StorageFactory.h>
2018-01-11 19:13:19 +00:00
#include <Interpreters/InterpreterAlterQuery.h>
#include <Databases/IDatabase.h>
#include <IO/WriteHelpers.h>
namespace DB
{
namespace ErrorCodes
{
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_name, args.columns);
});
}
2018-01-11 19:13:19 +00:00
void StorageNull::alter(const AlterCommands & params, const String & database_name, const String & table_name, const Context & context)
{
auto lock = lockStructureForAlter(__PRETTY_FUNCTION__);
ColumnsDescription new_columns = getColumns();
params.apply(new_columns);
context.getDatabase(database_name)->alterTable(context, table_name, new_columns, {});
setColumns(std::move(new_columns));
2018-01-11 19:13:19 +00:00
}
}