diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 13045302c4e..8ded9c49f96 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -1889,8 +1889,9 @@ BlockOutputStreamPtr StorageReplicatedMergeTree::write(ASTPtr query) throw Exception("Table is in read only mode", ErrorCodes::TABLE_IS_READ_ONLY); String insert_id; - if (ASTInsertQuery * insert = typeid_cast(&*query)) - insert_id = insert->insert_id; + if (query) + if (ASTInsertQuery * insert = typeid_cast(&*query)) + insert_id = insert->insert_id; return new ReplicatedMergeTreeBlockOutputStream(*this, insert_id); }