From 01dbcd83720bf7a5e4bd7d80fc755c204b9568b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 14 Dec 2021 13:59:58 +0200 Subject: [PATCH] MXS-3915: Never cache autocommit queries As both `SET autocommit=1` and `SET autocommit=0` share the same canonical query form but do not have the same types, they should not be stored in the cache. --- server/core/query_classifier.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/core/query_classifier.cc b/server/core/query_classifier.cc index 924914844..30174cda9 100644 --- a/server/core/query_classifier.cc +++ b/server/core/query_classifier.cc @@ -399,7 +399,7 @@ public: ~QCInfoCacheScope() { - if (!m_canonical.empty()) + if (store_in_cache()) { void* pData = gwbuf_get_buffer_object_data(m_pStmt, GWBUF_PARSING_INFO); mxb_assert(pData); @@ -412,6 +412,12 @@ public: private: GWBUF* m_pStmt; std::string m_canonical; + + bool store_in_cache() const + { + constexpr const int is_autocommit = QUERY_TYPE_ENABLE_AUTOCOMMIT | QUERY_TYPE_DISABLE_AUTOCOMMIT; + return !m_canonical.empty() && (qc_get_type_mask(m_pStmt) & is_autocommit) == 0; + } }; }