From ab11383e321d5b138e373f464e5db2d06185038a Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 11 Dec 2024 18:10:52 +0000 Subject: [PATCH] Backport #73045 to 24.9: 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 259fddc6713..296d9434f79 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -578,7 +578,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;