mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
Fix tests with database replicated
This commit is contained in:
parent
518d4b4357
commit
a176c38876
@ -156,10 +156,10 @@ BlockIO InterpreterAlterQuery::executeToTable(const ASTAlterQuery & alter)
|
||||
if (typeid_cast<DatabaseReplicated *>(database.get()))
|
||||
{
|
||||
int command_types_count = !mutation_commands.empty() + !partition_commands.empty() + !alter_commands.empty();
|
||||
bool mixed_settings_amd_metadata_alter = alter_commands.hasSettingsAlterCommand() && !alter_commands.isSettingsAlter();
|
||||
bool mixed_settings_amd_metadata_alter = alter_commands.hasNonReplicatedAlterCommand() && !alter_commands.areNonReplicatedAlterCommands();
|
||||
if (1 < command_types_count || mixed_settings_amd_metadata_alter)
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "For Replicated databases it's not allowed "
|
||||
"to execute ALTERs of different types in single query");
|
||||
"to execute ALTERs of different types (replicated and non replicated) in single query");
|
||||
}
|
||||
|
||||
if (mutation_commands.hasNonEmptyMutationCommands())
|
||||
|
@ -1350,9 +1350,14 @@ void AlterCommands::validate(const StoragePtr & table, ContextPtr context) const
|
||||
validateColumnsDefaultsAndGetSampleBlock(default_expr_list, all_columns.getAll(), context);
|
||||
}
|
||||
|
||||
bool AlterCommands::hasSettingsAlterCommand() const
|
||||
bool AlterCommands::hasNonReplicatedAlterCommand() const
|
||||
{
|
||||
return std::any_of(begin(), end(), [](const AlterCommand & c) { return c.isSettingsAlter(); });
|
||||
return std::any_of(begin(), end(), [](const AlterCommand & c) { return c.isSettingsAlter() || c.isCommentAlter(); });
|
||||
}
|
||||
|
||||
bool AlterCommands::areNonReplicatedAlterCommands() const
|
||||
{
|
||||
return std::all_of(begin(), end(), [](const AlterCommand & c) { return c.isSettingsAlter() || c.isCommentAlter(); });
|
||||
}
|
||||
|
||||
bool AlterCommands::isSettingsAlter() const
|
||||
|
@ -196,8 +196,11 @@ public:
|
||||
/// Commands have to be prepared before apply.
|
||||
void apply(StorageInMemoryMetadata & metadata, ContextPtr context) const;
|
||||
|
||||
/// At least one command modify settings.
|
||||
bool hasSettingsAlterCommand() const;
|
||||
/// At least one command modify settings or comments.
|
||||
bool hasNonReplicatedAlterCommand() const;
|
||||
|
||||
/// All commands modify settings or comments.
|
||||
bool areNonReplicatedAlterCommands() const;
|
||||
|
||||
/// All commands modify settings only.
|
||||
bool isSettingsAlter() const;
|
||||
|
@ -1,3 +1,6 @@
|
||||
-- Tags: no-replicated-database
|
||||
-- Tag no-replicated-database: Unsupported type of ALTER query
|
||||
|
||||
DROP TABLE IF EXISTS t;
|
||||
|
||||
# Memory, MergeTree, and ReplicatedMergeTree
|
||||
|
Loading…
Reference in New Issue
Block a user