From 2b762c7aa951900a6ab07f929b1d0809aa89de94 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 18 May 2015 23:28:40 +0300 Subject: [PATCH] dbms: fixed error with StorageBuffer when destination table doesn't exist [#METR-16352]. --- dbms/src/Storages/StorageBuffer.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/dbms/src/Storages/StorageBuffer.cpp b/dbms/src/Storages/StorageBuffer.cpp index 9e20fddb72a..eef6b61b9e8 100644 --- a/dbms/src/Storages/StorageBuffer.cpp +++ b/dbms/src/Storages/StorageBuffer.cpp @@ -164,18 +164,21 @@ public: { destination = storage.context.tryGetTable(storage.destination_database, storage.destination_table); - if (destination.get() == &storage) - throw Exception("Destination table is myself. Write will cause infinite loop.", ErrorCodes::INFINITE_LOOP); + if (destination) + { + if (destination.get() == &storage) + throw Exception("Destination table is myself. Write will cause infinite loop.", ErrorCodes::INFINITE_LOOP); - /// Проверяем структуру таблицы. - try - { - destination->check(block, true); - } - catch (Exception & e) - { - e.addMessage("(when looking at destination table " + storage.destination_database + "." + storage.destination_table + ")"); - throw; + /// Проверяем структуру таблицы. + try + { + destination->check(block, true); + } + catch (Exception & e) + { + e.addMessage("(when looking at destination table " + storage.destination_database + "." + storage.destination_table + ")"); + throw; + } } }