mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 14:11:58 +00:00
fix
This commit is contained in:
parent
42a976fe3d
commit
cd8c3bbcc5
@ -379,10 +379,14 @@ void DatabaseOnDisk::renameTable(
|
||||
if (dictionary && table && !table->isDictionary())
|
||||
throw Exception(ErrorCodes::INCORRECT_QUERY, "Use RENAME/EXCHANGE TABLE (instead of RENAME/EXCHANGE DICTIONARY) for tables");
|
||||
|
||||
table_lock = table->lockExclusively(
|
||||
local_context->getCurrentQueryId(), local_context->getSettingsRef().lock_acquire_timeout);
|
||||
/// We have to lock the table before detaching, because otherwise lockExclusively will throw. But the table may not exist.
|
||||
bool need_lock = table != nullptr;
|
||||
if (need_lock)
|
||||
table_lock = table->lockExclusively(local_context->getCurrentQueryId(), local_context->getSettingsRef().lock_acquire_timeout);
|
||||
|
||||
detachTable(local_context, table_name);
|
||||
if (!need_lock)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Table was detached without locking, it's a bug");
|
||||
|
||||
UUID prev_uuid = UUIDHelpers::Nil;
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user