**Does it reproduce on recent release?**

```sql
DROP TABLE IF EXISTS kek;
DROP TABLE IF EXISTS kekv;

CREATE TABLE kek (a UInt32) ENGINE = MergeTree ORDER BY a;
CREATE MATERIALIZED VIEW kekv ENGINE = MergeTree ORDER BY tuple() AS SELECT * FROM kek;

INSERT INTO kek VALUES (1);
DELETE FROM kekv WHERE a = 1; -- actually any condition here

DROP TABLE IF EXISTS kek;
DROP TABLE IF EXISTS kekv;
```

**Enable crash reporting**

```
2022.12.27 23:48:52.071005 [ 4090961 ] <Fatal> BaseDaemon: ########################################
2022.12.27 23:48:52.071101 [ 4090961 ] <Fatal> BaseDaemon: (version 22.13.1.1, build id: 71CAD059AB226CD1299F680DAC2E55D17A70489B) (from thread 4090648) (query_id: 97abba4b-654a-44bb-8c1f-2a3639ea613f) (query: DELETE FROM kekv WHERE a = 1;) Received signal Segmentation fault (11)
2022.12.27 23:48:52.071145 [ 4090961 ] <Fatal> BaseDaemon: Address: NULL pointer. Access: read. Address not mapped to object.
2022.12.27 23:48:52.071181 [ 4090961 ] <Fatal> BaseDaemon: Stack trace: 0x1602108a 0x16021164 0x1667b50c 0x1665f48e 0x1666206b 0x160c042d 0x158fbb49 0x15c3256e 0x15c2fbd6 0x167942c4 0x167a29f9 0x18bc07c7 0x18bc0cad 0x18d314e7 0x18d2f0c3 0x7fa61aa55609 0x7fa61a97a163
2022.12.27 23:48:52.080770 [ 4090961 ] <Fatal> BaseDaemon: 3. ./build_clang/./src/Storages/MutationCommands.cpp:163: DB::MutationCommands::ast(bool) const @ 0x1602108a in /usr/local/bin/clickhouse
2022.12.27 23:48:52.088590 [ 4090961 ] <Fatal> BaseDaemon: 4. ./build_clang/./src/Storages/MutationCommands.cpp:172: DB::MutationCommands::writeText(DB::WriteBuffer&, bool) const @ 0x16021164 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.097455 [ 4090961 ] <Fatal> BaseDaemon: 5.1. inlined from ./build_clang/./src/IO/WriteHelpers.h:187: DB::writeString(char const*, unsigned long, DB::WriteBuffer&)
2022.12.27 23:48:52.097504 [ 4090961 ] <Fatal> BaseDaemon: 5.2. inlined from ./build_clang/./src/IO/WriteHelpers.h:878: DB::writeText(std::__1::basic_string_view<char, std::__1::char_traits<char>>, DB::WriteBuffer&)
2022.12.27 23:48:52.097522 [ 4090961 ] <Fatal> BaseDaemon: 5.3. inlined from ./build_clang/./src/IO/Operators.h:44: DB::WriteBuffer& DB::operator<<<char [2]>(DB::WriteBuffer&, char const (&) [2])
2022.12.27 23:48:52.097551 [ 4090961 ] <Fatal> BaseDaemon: 5. ./build_clang/./src/Storages/MergeTree/MergeTreeMutationEntry.cpp:65: DB::MergeTreeMutationEntry::MergeTreeMutationEntry(DB::MutationCommands, std::__1::shared_ptr<DB::IDisk>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, unsigned long, DB::TransactionID const&, DB::WriteSettings const&) @ 0x1667b50c in /usr/local/bin/clickhouse
2022.12.27 23:48:52.160053 [ 4090961 ] <Fatal> BaseDaemon: 6. ./build_clang/./src/Storages/StorageMergeTree.cpp:423: DB::StorageMergeTree::startMutation(DB::MutationCommands const&, std::__1::shared_ptr<DB::Context const>) @ 0x1665f48e in /usr/local/bin/clickhouse
2022.12.27 23:48:52.222058 [ 4090961 ] <Fatal> BaseDaemon: 7. ./build_clang/./src/Storages/StorageMergeTree.cpp:0: DB::StorageMergeTree::mutate(DB::MutationCommands const&, std::__1::shared_ptr<DB::Context const>) @ 0x1666206b in /usr/local/bin/clickhouse
2022.12.27 23:48:52.257567 [ 4090961 ] <Fatal> BaseDaemon: 8.1. inlined from ./build_clang/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:701: ~shared_ptr
2022.12.27 23:48:52.257604 [ 4090961 ] <Fatal> BaseDaemon: 8. ./build_clang/./src/Storages/StorageMaterializedView.cpp:326: DB::StorageMaterializedView::mutate(DB::MutationCommands const&, std::__1::shared_ptr<DB::Context const>) @ 0x160c042d in /usr/local/bin/clickhouse
2022.12.27 23:48:52.269200 [ 4090961 ] <Fatal> BaseDaemon: 9.1. inlined from ./build_clang/./src/QueryPipeline/BlockIO.h:14: BlockIO
2022.12.27 23:48:52.269228 [ 4090961 ] <Fatal> BaseDaemon: 9. ./build_clang/./src/Interpreters/InterpreterDeleteQuery.cpp:77: DB::InterpreterDeleteQuery::execute() @ 0x158fbb49 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.312177 [ 4090961 ] <Fatal> BaseDaemon: 10. ./build_clang/./src/Interpreters/executeQuery.cpp:0: DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x15c3256e in /usr/local/bin/clickhouse
2022.12.27 23:48:52.358332 [ 4090961 ] <Fatal> BaseDaemon: 11. ./build_clang/./src/Interpreters/executeQuery.cpp:1083: DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x15c2fbd6 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.390551 [ 4090961 ] <Fatal> BaseDaemon: 12. ./build_clang/./src/Server/TCPHandler.cpp:0: DB::TCPHandler::runImpl() @ 0x167942c4 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.440488 [ 4090961 ] <Fatal> BaseDaemon: 13. ./build_clang/./src/Server/TCPHandler.cpp:1922: DB::TCPHandler::run() @ 0x167a29f9 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.442312 [ 4090961 ] <Fatal> BaseDaemon: 14. ./build_clang/./contrib/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0x18bc07c7 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.445233 [ 4090961 ] <Fatal> BaseDaemon: 15.1. inlined from ./build_clang/./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:48: std::__1::default_delete<Poco::Net::TCPServerConnection>::operator()[abi:v15000](Poco::Net::TCPServerConnection*) const
2022.12.27 23:48:52.445255 [ 4090961 ] <Fatal> BaseDaemon: 15.2. inlined from ./build_clang/./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:305: std::__1::unique_ptr<Poco::Net::TCPServerConnection, std::__1::default_delete<Poco::Net::TCPServerConnection>>::reset[abi:v15000](Poco::Net::TCPServerConnection*)
2022.12.27 23:48:52.445278 [ 4090961 ] <Fatal> BaseDaemon: 15.3. inlined from ./build_clang/./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:259: ~unique_ptr
2022.12.27 23:48:52.445312 [ 4090961 ] <Fatal> BaseDaemon: 15. ./build_clang/./contrib/poco/Net/src/TCPServerDispatcher.cpp:116: Poco::Net::TCPServerDispatcher::run() @ 0x18bc0cad in /usr/local/bin/clickhouse
2022.12.27 23:48:52.448782 [ 4090961 ] <Fatal> BaseDaemon: 16. ./build_clang/./contrib/poco/Foundation/src/ThreadPool.cpp:213: Poco::PooledThread::run() @ 0x18d314e7 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.451637 [ 4090961 ] <Fatal> BaseDaemon: 17.1. inlined from ./build_clang/./contrib/poco/Foundation/include/Poco/SharedPtr.h:156: Poco::SharedPtr<Poco::Runnable, Poco::ReferenceCounter, Poco::ReleasePolicy<Poco::Runnable>>::assign(Poco::Runnable*)
2022.12.27 23:48:52.451660 [ 4090961 ] <Fatal> BaseDaemon: 17.2. inlined from ./build_clang/./contrib/poco/Foundation/include/Poco/SharedPtr.h:208: Poco::SharedPtr<Poco::Runnable, Poco::ReferenceCounter, Poco::ReleasePolicy<Poco::Runnable>>::operator=(Poco::Runnable*)
2022.12.27 23:48:52.451685 [ 4090961 ] <Fatal> BaseDaemon: 17. ./build_clang/./contrib/poco/Foundation/src/Thread_POSIX.cpp:360: Poco::ThreadImpl::runnableEntry(void*) @ 0x18d2f0c3 in /usr/local/bin/clickhouse
2022.12.27 23:48:52.451721 [ 4090961 ] <Fatal> BaseDaemon: 18. ? @ 0x7fa61aa55609 in ?
2022.12.27 23:48:52.451762 [ 4090961 ] <Fatal> BaseDaemon: 19. clone @ 0x7fa61a97a163 in ?
2022.12.27 23:48:52.451794 [ 4090961 ] <Fatal> BaseDaemon: Integrity check of the executable skipped because the reference checksum could not be read.
Error on processing query: Code: 32. DB::Exception: Attempt to read after eof: while receiving packet from localhost:9000. (ATTEMPT_TO_READ_AFTER_EOF) (version 22.13.1.1)
(query: DELETE FROM kekv WHERE a = 1; -- actually any condition here)
```


**Additional context**

The bug is [here](https://github.com/ClickHouse/ClickHouse/blob/2892d447d4acfc9878108c17f775db8b62aa48c4/src/Interpreters/InterpreterDeleteQuery.cpp#L61-L80).
#pragma once
#include <memory>
#include <shared_mutex>
#include <Storages/IStorage.h>
#include <Interpreters/IKeyValueEntity.h>
#include <rocksdb/status.h>
namespace rocksdb
{
    class DB;
    class Statistics;
}
namespace DB
{
class Context;