From 62163ea611f3f66818d89411d0df591e0cea7402 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 11 Dec 2024 18:11:18 +0000 Subject: [PATCH] Backport #73045 to 24.10: Fix crash in transactions with unsupported storage --- src/Interpreters/InterpreterSelectQuery.cpp | 2 +- .../0_stateless/03282_memory_transaction_crash.reference | 0 .../0_stateless/03282_memory_transaction_crash.sql | 9 +++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/03282_memory_transaction_crash.reference create mode 100644 tests/queries/0_stateless/03282_memory_transaction_crash.sql diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index 3918c1c37ea..24a8c22dfc0 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -582,7 +582,7 @@ InterpreterSelectQuery::InterpreterSelectQuery( auto maybe_storage = DatabaseCatalog::instance().tryGetTable({table.table.database, table.table.table}, context); if (!maybe_storage) continue; - checkStorageSupportsTransactionsIfNeeded(storage, context, /* is_readonly_query */ true); + checkStorageSupportsTransactionsIfNeeded(maybe_storage, context, /* is_readonly_query */ true); } } diff --git a/tests/queries/0_stateless/03282_memory_transaction_crash.reference b/tests/queries/0_stateless/03282_memory_transaction_crash.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/03282_memory_transaction_crash.sql b/tests/queries/0_stateless/03282_memory_transaction_crash.sql new file mode 100644 index 00000000000..996d6ff7d87 --- /dev/null +++ b/tests/queries/0_stateless/03282_memory_transaction_crash.sql @@ -0,0 +1,9 @@ +-- Tags: zookeeper +-- https://github.com/ClickHouse/ClickHouse/issues/72887 +DROP TABLE IF EXISTS t0; + +CREATE TABLE t0 (c0 Int) ENGINE = Memory(); +BEGIN TRANSACTION; +EXPLAIN SYNTAX SELECT 1 FROM (SELECT 1) tx JOIN t0 ON TRUE; -- { serverError NOT_IMPLEMENTED } +ROLLBACK; +DROP TABLE IF EXISTS t0;