This commit is contained in:
Alexander Tokmakov 2020-02-11 20:25:26 +03:00
parent 18dd0c8f8c
commit 3c5d6cf6f1
3 changed files with 13 additions and 10 deletions

View File

@ -770,7 +770,7 @@ bool Context::isDictionaryExists(const String & database_name, const String & di
{
auto lock = getLock();
String db = resolveDatabase(database_name);
auto db_ptr = DatabaseCatalog::instance().tryGetDatabase(database_name);
auto db_ptr = DatabaseCatalog::instance().tryGetDatabase(db);
return db_ptr && db_ptr->isDictionaryExist(*this, dictionary_name);
}

View File

@ -83,17 +83,20 @@ StoragePtr DatabaseCatalog::getTable(const StorageID & table_id, const Context &
// return db_and_table.second;
//}
std::lock_guard _lock{databases_mutex};
auto it = databases.find(table_id.getDatabaseName());
if (databases.end() == it)
DatabasePtr database;
{
if (exception)
exception->emplace("Database " + backQuoteIfNeed(table_id.getDatabaseName()) + " doesn't exist", ErrorCodes::UNKNOWN_DATABASE);
return {};
std::lock_guard _lock{databases_mutex};
auto it = databases.find(table_id.getDatabaseName());
if (databases.end() == it)
{
if (exception)
exception->emplace("Database " + backQuoteIfNeed(table_id.getDatabaseName()) + " doesn't exist",
ErrorCodes::UNKNOWN_DATABASE);
return {};
}
database = it->second;
}
auto database = it->second;
auto table = database->tryGetTable(local_context, table_id.table_name);
if (!table && exception)
exception->emplace("Table " + table_id.getNameForLogs() + " doesn't exist.", ErrorCodes::UNKNOWN_TABLE);

View File

@ -113,7 +113,7 @@ private:
private:
//[[maybe_unused]] Context & global_context;
mutable std::mutex databases_mutex;
mutable std::recursive_mutex databases_mutex;
//const String default_database;
Databases databases;
UUIDToStorageMap uuid_map;