MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / dropStorageReplica

Method dropStorageReplica

src/Interpreters/InterpreterSystemQuery.cpp:1639–1657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1637}
1638
1639bool 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
1659void InterpreterSystemQuery::dropStorageReplicasFromDatabase(const String & query_replica, DatabasePtr database)
1660{

Callers

nothing calls this directly

Calls 6

getReplicaNameMethod · 0.80
ExceptionClass · 0.70
getMethod · 0.45
dropReplicaMethod · 0.45
getNameForLogsMethod · 0.45
getStorageIDMethod · 0.45

Tested by

no test coverage detected