mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 18:14:03 +00:00
Revert "temporary tables: new non-shared variable in context, function getTemporaryTable and update in getTable [METR-10071]"
This reverts commit de688967bb3be4296a3d94551a9a3cee100411f6.
This commit is contained in:
parent
4a03fea462
commit
792e5cf3f7
@ -155,7 +155,7 @@ private:
|
||||
|
||||
String default_format; /// Формат, используемый, если сервер сам форматирует данные, и если в запросе не задан FORMAT.
|
||||
/// То есть, используется в HTTP-интерфейсе. Может быть не задан - тогда используется некоторый глобальный формат по-умолчанию.
|
||||
Tables temporary_tables; /// Временные таблицы.
|
||||
|
||||
Context * session_context; /// Контекст сессии или NULL, если его нет. (Возможно, равен this.)
|
||||
Context * global_context; /// Глобальный контекст или NULL, если его нет. (Возможно, равен this.)
|
||||
|
||||
@ -192,7 +192,6 @@ public:
|
||||
void assertDatabaseExists(const String & database_name) const;
|
||||
void assertDatabaseDoesntExist(const String & database_name) const;
|
||||
|
||||
StoragePtr tryGetTemporaryTable(const String & table_name) const;
|
||||
StoragePtr getTable(const String & database_name, const String & table_name) const;
|
||||
StoragePtr tryGetTable(const String & database_name, const String & table_name) const;
|
||||
void addTable(const String & database_name, const String & table_name, StoragePtr table);
|
||||
|
@ -160,39 +160,18 @@ void Context::assertDatabaseDoesntExist(const String & database_name) const
|
||||
throw Exception("Database " + db + " already exists.", ErrorCodes::DATABASE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
StoragePtr Context::tryGetTemporaryTable(const String & table_name) const
|
||||
{
|
||||
Poco::ScopedLock<Poco::Mutex> lock(shared->mutex);
|
||||
|
||||
Tables::const_iterator jt;
|
||||
if (temporary_tables.end() != (jt = temporary_tables.find(table_name)))
|
||||
return StoragePtr();
|
||||
|
||||
return jt->second;
|
||||
}
|
||||
|
||||
StoragePtr Context::getTable(const String & database_name, const String & table_name) const
|
||||
{
|
||||
Poco::ScopedLock<Poco::Mutex> lock(shared->mutex);
|
||||
Databases::const_iterator it;
|
||||
Tables::const_iterator jt;
|
||||
StoragePtr res;
|
||||
|
||||
if (database_name.empty())
|
||||
{
|
||||
if (res = tryGetTemporaryTable(table_name))
|
||||
return res;
|
||||
if (res = session_context->tryGetTemporaryTable(table_name))
|
||||
return res;
|
||||
if (res = global_context->tryGetTemporaryTable(table_name))
|
||||
return res;
|
||||
}
|
||||
|
||||
String db = database_name.empty() ? current_database : database_name;
|
||||
|
||||
Databases::const_iterator it;
|
||||
if (shared->databases.end() == (it = shared->databases.find(db)))
|
||||
throw Exception("Database " + db + " doesn't exist", ErrorCodes::UNKNOWN_DATABASE);
|
||||
|
||||
Tables::const_iterator jt;
|
||||
if (it->second.end() == (jt = it->second.find(table_name)))
|
||||
throw Exception("Table " + db + "." + table_name + " doesn't exist.", ErrorCodes::UNKNOWN_TABLE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user