From 2eb2e4cf41909dc82ccf5cd30c02f81941e40e36 Mon Sep 17 00:00:00 2001 From: Alexander Kazakov Date: Sun, 12 Apr 2020 20:17:41 +0300 Subject: [PATCH] Added proper nullptr check --- src/Storages/System/StorageSystemTables.cpp | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Storages/System/StorageSystemTables.cpp b/src/Storages/System/StorageSystemTables.cpp index f4ce4a8b71..81ff6a03e1 100644 --- a/src/Storages/System/StorageSystemTables.cpp +++ b/src/Storages/System/StorageSystemTables.cpp @@ -239,20 +239,25 @@ protected: StoragePtr table = nullptr; TableStructureReadLockHolder lock; - try + if (need_lock_structure) { - if (need_lock_structure) + table = tables_it->table(); + if (table == nullptr) + { + // Table might have just been removed or detached for Lazy engine (see DatabaseLazy::tryGetTable()) + continue; + } + try { - table = tables_it->table(); lock = table->lockStructureForShare( false, context.getCurrentQueryId(), context.getSettingsRef().lock_acquire_timeout); } - } - catch (const Exception & e) - { - if (e.code() == ErrorCodes::TABLE_IS_DROPPED) - continue; - throw; + catch (const Exception & e) + { + if (e.code() == ErrorCodes::TABLE_IS_DROPPED) + continue; + throw; + } } ++rows_count; -- GitLab