2017-12-30 00:36:06 +00:00
|
|
|
#include <Storages/StorageNull.h>
|
|
|
|
#include <Storages/StorageFactory.h>
|
2018-12-25 23:18:07 +00:00
|
|
|
#include <Storages/AlterCommands.h>
|
2017-12-30 00:36:06 +00:00
|
|
|
|
2018-01-11 19:13:19 +00:00
|
|
|
#include <Interpreters/InterpreterAlterQuery.h>
|
|
|
|
#include <Databases/IDatabase.h>
|
|
|
|
|
2017-12-30 00:36:06 +00:00
|
|
|
#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);
|
|
|
|
|
2018-03-06 20:18:34 +00:00
|
|
|
return StorageNull::create(args.table_name, args.columns);
|
2017-12-30 00:36:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-04 12:10:00 +00:00
|
|
|
void StorageNull::alter(const AlterCommands & params, const String & current_database_name, const String & current_table_name, const Context & context)
|
2018-01-11 19:13:19 +00:00
|
|
|
{
|
2018-11-28 15:50:52 +00:00
|
|
|
auto lock = lockStructureForAlter();
|
2018-01-11 19:13:19 +00:00
|
|
|
|
2018-03-13 14:18:11 +00:00
|
|
|
ColumnsDescription new_columns = getColumns();
|
|
|
|
params.apply(new_columns);
|
2019-01-04 12:10:00 +00:00
|
|
|
context.getDatabase(current_database_name)->alterTable(context, current_table_name, new_columns, {});
|
2018-03-13 14:18:11 +00:00
|
|
|
setColumns(std::move(new_columns));
|
2018-01-11 19:13:19 +00:00
|
|
|
}
|
|
|
|
|
2017-12-30 00:36:06 +00:00
|
|
|
}
|