From d4aa3cea4b87afacae6aa0e735d128503ee09895 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Tue, 5 May 2020 23:07:53 +0800 Subject: [PATCH] fix merge state Fix style && build --- src/Interpreters/InterpreterAlterQuery.cpp | 8 ++++---- src/Parsers/ASTAlterQuery.cpp | 3 --- src/Parsers/ASTAlterQuery.h | 2 +- src/Storages/StorageReplicatedMergeTree.cpp | 4 ++-- src/Storages/StorageReplicatedMergeTree.h | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Interpreters/InterpreterAlterQuery.cpp b/src/Interpreters/InterpreterAlterQuery.cpp index 36c3266291d..5da178e5a9f 100644 --- a/src/Interpreters/InterpreterAlterQuery.cpp +++ b/src/Interpreters/InterpreterAlterQuery.cpp @@ -106,10 +106,10 @@ BlockIO InterpreterAlterQuery::execute() replica_commands.validate(*table); auto replicate_table = std::dynamic_pointer_cast(table); - auto table_lock_holder = table->lockAlterIntention(context.getCurrentQueryId()); + auto table_lock_holder = table->lockAlterIntention(context.getCurrentQueryId(), context.getSettingsRef().lock_acquire_timeout); for (auto & command : replica_commands) - { - replicate_table->dropReplica(table_lock_holder, command.replica_name); + { + replicate_table->dropReplica(command.replica_name); } } @@ -294,7 +294,7 @@ AccessRightsElements InterpreterAlterQuery::getRequiredAccessForCommand(const AS } case ASTAlterCommand::DROP_REPLICA: { - required_access.emplace_back(AccessType::ALTER_DELETE, alter.database, alter.table); + required_access.emplace_back(AccessType::ALTER_DELETE, database, table); break; } case ASTAlterCommand::MODIFY_QUERY: diff --git a/src/Parsers/ASTAlterQuery.cpp b/src/Parsers/ASTAlterQuery.cpp index 44486fd8a23..c1f12ddd0fd 100644 --- a/src/Parsers/ASTAlterQuery.cpp +++ b/src/Parsers/ASTAlterQuery.cpp @@ -294,7 +294,6 @@ void ASTAlterCommand::formatImpl( { settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "REFRESH " << (settings.hilite ? hilite_none : ""); } -<<<<<<< HEAD else if (type == ASTAlterCommand::RENAME_COLUMN) { settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "RENAME COLUMN " << (if_exists ? "IF EXISTS " : "") @@ -303,11 +302,9 @@ void ASTAlterCommand::formatImpl( settings.ostr << (settings.hilite ? hilite_keyword : "") << " TO "; rename_to->formatImpl(settings, state, frame); -======= else if (type == ASTAlterCommand::DROP_REPLICA) { settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "DROP " << (settings.hilite ? hilite_none : "") << " " << std::quoted(replica_name, '\''); ->>>>>>> b3fa746... Add drop replica alter support } else throw Exception("Unexpected type of ALTER", ErrorCodes::UNEXPECTED_AST_STRUCTURE); diff --git a/src/Parsers/ASTAlterQuery.h b/src/Parsers/ASTAlterQuery.h index d6ea600851a..dbaaa8546cf 100644 --- a/src/Parsers/ASTAlterQuery.h +++ b/src/Parsers/ASTAlterQuery.h @@ -58,7 +58,7 @@ public: NO_TYPE, LIVE_VIEW_REFRESH, - + DROP_REPLICA, }; diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 0b5ceed4f7d..25abf9e7e24 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -4119,11 +4119,11 @@ void StorageReplicatedMergeTree::drop() dropAllData(); } -void StorageReplicatedMergeTree::dropReplica(TableStructureWriteLockHolder & holder, const String & replica) +void StorageReplicatedMergeTree::dropReplica(const String & replica) { if (replica_name == replica) { - drop(holder); + drop(); return; } removeReplica(replica); diff --git a/src/Storages/StorageReplicatedMergeTree.h b/src/Storages/StorageReplicatedMergeTree.h index b46fd6147ad..7933cb483cf 100644 --- a/src/Storages/StorageReplicatedMergeTree.h +++ b/src/Storages/StorageReplicatedMergeTree.h @@ -117,7 +117,7 @@ public: /** Removes a specific replica from Zookeeper. If replica is local, it works same as `drop` method. */ - void dropReplica(TableStructureWriteLockHolder &, const String & replica_name); + void dropReplica(const String & replica_name); void truncate(const ASTPtr &, const Context &, TableStructureWriteLockHolder &) override;