diff --git a/src/Interpreters/StorageID.cpp b/src/Interpreters/StorageID.cpp index 2d6a4900dd3..a7d02601dbf 100644 --- a/src/Interpreters/StorageID.cpp +++ b/src/Interpreters/StorageID.cpp @@ -79,6 +79,15 @@ bool StorageID::operator<(const StorageID & rhs) const return !hasUUID(); } +bool StorageID::operator==(const StorageID & rhs) const +{ + assertNotEmpty(); + if (!hasUUID() && !rhs.hasUUID()) + return std::tie(database_name, table_name) == std::tie(rhs.database_name, rhs.table_name); + else + return hasUUID() && rhs.hasUUID() && uuid == rhs.uuid; +} + String StorageID::getFullTableName() const { return backQuoteIfNeed(getDatabaseName()) + "." + backQuoteIfNeed(table_name); diff --git a/src/Interpreters/StorageID.h b/src/Interpreters/StorageID.h index 9343f67fe7a..d42dfda06fd 100644 --- a/src/Interpreters/StorageID.h +++ b/src/Interpreters/StorageID.h @@ -68,6 +68,7 @@ struct StorageID return uuid != UUIDHelpers::Nil; } + bool operator==(const StorageID & rhs) const; bool operator<(const StorageID & rhs) const; void assertNotEmpty() const