Merge pull request #57083 from evillique/better-metadata-path

Better metadata path
This commit is contained in:
Nikolay Degterinsky 2023-11-23 19:27:55 +01:00 committed by GitHub
commit 644e671e81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1046,9 +1046,17 @@ String DatabaseCatalog::getPathForDroppedMetadata(const StorageID & table_id) co
String DatabaseCatalog::getPathForMetadata(const StorageID & table_id) const
{
return getContext()->getPath() + "metadata/" +
escapeForFileName(table_id.getDatabaseName()) + "/" +
escapeForFileName(table_id.getTableName()) + ".sql";
auto database = getDatabase(table_id.getDatabaseName());
auto * database_ptr = dynamic_cast<DatabaseOnDisk *>(database.get());
if (!database_ptr)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Failed to get metadata path from database {}", table_id.getDatabaseName());
auto metadata_path = database_ptr->getMetadataPath();
if (metadata_path.empty())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Empty metadata path in database {}", table_id.getDatabaseName());
return metadata_path + escapeForFileName(table_id.getTableName()) + ".sql";
}
void DatabaseCatalog::enqueueDroppedTableCleanup(StorageID table_id, StoragePtr table, String dropped_metadata_path, bool ignore_delay)