mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 03:12:43 +00:00
Fix alter named collection if exists
This commit is contained in:
parent
ae4406cd80
commit
686ed14e71
@ -428,9 +428,21 @@ void updateFromSQL(const ASTAlterNamedCollectionQuery & query, ContextPtr contex
|
|||||||
{
|
{
|
||||||
auto lock = lockNamedCollectionsTransaction();
|
auto lock = lockNamedCollectionsTransaction();
|
||||||
loadIfNotUnlocked(lock);
|
loadIfNotUnlocked(lock);
|
||||||
|
auto & instance = NamedCollectionFactory::instance();
|
||||||
|
if (!instance.exists(query.collection_name))
|
||||||
|
{
|
||||||
|
if (!query.if_exists)
|
||||||
|
{
|
||||||
|
throw Exception(
|
||||||
|
ErrorCodes::NAMED_COLLECTION_DOESNT_EXIST,
|
||||||
|
"Cannot remove collection `{}`, because it doesn't exist",
|
||||||
|
query.collection_name);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
LoadFromSQL(context).update(query);
|
LoadFromSQL(context).update(query);
|
||||||
|
|
||||||
auto collection = NamedCollectionFactory::instance().getMutable(query.collection_name);
|
auto collection = instance.getMutable(query.collection_name);
|
||||||
auto collection_lock = collection->lock();
|
auto collection_lock = collection->lock();
|
||||||
|
|
||||||
for (const auto & [name, value] : query.changes)
|
for (const auto & [name, value] : query.changes)
|
||||||
|
Loading…
Reference in New Issue
Block a user