Fixed bad code

This commit is contained in:
Alexey Milovidov 2019-05-03 02:56:42 +03:00
parent 0a072ccc57
commit e4ba3a6792
5 changed files with 14 additions and 12 deletions

View File

@ -214,7 +214,7 @@ void AlterCommand::apply(ColumnsDescription & columns_description, IndicesDescri
column.codec = codec;
}
if (!is_mutable())
if (!isMutable())
{
column.comment = comment;
return;
@ -306,7 +306,7 @@ void AlterCommand::apply(ColumnsDescription & columns_description, IndicesDescri
throw Exception("Wrong parameter type in ALTER query", ErrorCodes::LOGICAL_ERROR);
}
bool AlterCommand::is_mutable() const
bool AlterCommand::isMutable() const
{
if (type == COMMENT_COLUMN)
return false;
@ -328,6 +328,7 @@ void AlterCommands::apply(ColumnsDescription & columns_description, IndicesDescr
for (const AlterCommand & command : *this)
if (!command.ignore)
command.apply(new_columns_description, new_indices_description, new_order_by_ast, new_primary_key_ast, new_ttl_table_ast);
columns_description = std::move(new_columns_description);
indices_description = std::move(new_indices_description);
order_by_ast = std::move(new_order_by_ast);
@ -495,7 +496,7 @@ void AlterCommands::validate(const IStorage & table, const Context & context)
/// column has no associated alter command, let's create it
/// add a new alter command to modify existing column
this->emplace_back(AlterCommand{AlterCommand::MODIFY_COLUMN,
column.name, explicit_type, column.default_desc.kind, column.default_desc.expression});
column.name, explicit_type, column.default_desc.kind, column.default_desc.expression, {}, {}, {}, {}});
command = &back();
}
@ -534,11 +535,11 @@ void AlterCommands::apply(ColumnsDescription & columns_description) const
columns_description = std::move(out_columns_description);
}
bool AlterCommands::is_mutable() const
bool AlterCommands::isMutable() const
{
for (const auto & param : *this)
{
if (param.is_mutable())
if (param.isMutable())
return true;
}

View File

@ -73,8 +73,8 @@ struct AlterCommand
AlterCommand() = default;
AlterCommand(const Type type, const String & column_name, const DataTypePtr & data_type,
const ColumnDefaultKind default_kind, const ASTPtr & default_expression,
const String & after_column = String{}, const String & comment = "",
const bool if_exists = false, const bool if_not_exists = false) // TODO: разобраться здесь с параметром по умолчанию
const String & after_column, const String & comment,
const bool if_exists, const bool if_not_exists)
: type{type}, column_name{column_name}, data_type{data_type}, default_kind{default_kind},
default_expression{default_expression}, comment(comment), after_column{after_column},
if_exists(if_exists), if_not_exists(if_not_exists)
@ -84,8 +84,9 @@ struct AlterCommand
void apply(ColumnsDescription & columns_description, IndicesDescription & indices_description,
ASTPtr & order_by_ast, ASTPtr & primary_key_ast, ASTPtr & ttl_table_ast) const;
/// Checks that not only metadata touched by that command
bool is_mutable() const;
bool isMutable() const;
};
class IStorage;
@ -101,7 +102,7 @@ public:
void apply(ColumnsDescription & columns_description) const;
void validate(const IStorage & table, const Context & context);
bool is_mutable() const;
bool isMutable() const;
};
}

View File

@ -9,7 +9,7 @@ void IStorage::alter(const AlterCommands & params, const String & database_name,
{
for (const auto & param : params)
{
if (param.is_mutable())
if (param.isMutable())
throw Exception("Method alter supports only change comment of column for storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}

View File

@ -1233,7 +1233,7 @@ void MergeTreeData::checkAlter(const AlterCommands & commands, const Context & c
for (const AlterCommand & command : commands)
{
if (!command.is_mutable())
if (!command.isMutable())
{
continue;
}

View File

@ -200,7 +200,7 @@ void StorageMergeTree::alter(
const Context & context,
TableStructureWriteLockHolder & table_lock_holder)
{
if (!params.is_mutable())
if (!params.isMutable())
{
lockStructureExclusively(table_lock_holder, context.getCurrentQueryId());
auto new_columns = getColumns();