| 1637 | } |
| 1638 | |
| 1639 | bool InterpreterSystemQuery::dropStorageReplica(const String & query_replica, const StoragePtr & storage) |
| 1640 | { |
| 1641 | auto * storage_replicated = dynamic_cast<StorageReplicatedMergeTree *>(storage.get()); |
| 1642 | if (!storage_replicated) |
| 1643 | return false; |
| 1644 | |
| 1645 | const auto & replica_name = storage_replicated->getReplicaName(); |
| 1646 | |
| 1647 | /// Do not allow to drop local replicas and active remote replicas |
| 1648 | if (query_replica == replica_name) |
| 1649 | throw Exception(ErrorCodes::TABLE_WAS_NOT_DROPPED, |
| 1650 | "We can't drop local replica, please use `DROP TABLE` if you want " |
| 1651 | "to clean the data and drop this replica"); |
| 1652 | |
| 1653 | storage_replicated->dropReplica(query_replica, log); |
| 1654 | LOG_TRACE(log, "Dropped replica {} of {}", query_replica, storage->getStorageID().getNameForLogs()); |
| 1655 | |
| 1656 | return true; |
| 1657 | } |
| 1658 | |
| 1659 | void InterpreterSystemQuery::dropStorageReplicasFromDatabase(const String & query_replica, DatabasePtr database) |
| 1660 | { |
nothing calls this directly
no test coverage detected