From 71a7b79bcbfe90c3118e3d4379ad734dc72c9f39 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 25 Sep 2020 13:38:48 +0300 Subject: [PATCH] Added asssert to init_of_queries() to make it more safe Part of review of 10.4 code by Sergei. Other things: - Changed return type if is_active() from my_bool to bool as this is only used by C++ code. --- sql/sql_class.cc | 1 + sql/sql_class.h | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4986889b3c8..e57196ee056 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1386,6 +1386,7 @@ void THD::init_for_queries() We don't need to call ha_enable_transaction() as we can't have any active transactions that has to be committed */ + DBUG_ASSERT(transaction.is_empty()); transaction.on= TRUE; reset_root_defaults(mem_root, variables.query_alloc_block_size, diff --git a/sql/sql_class.h b/sql/sql_class.h index 0c2d03a516a..64cd1ed6ba3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2630,10 +2630,14 @@ public: free_root(&mem_root,MYF(MY_KEEP_PREALLOC)); DBUG_VOID_RETURN; } - my_bool is_active() + bool is_active() { return (all.ha_list != NULL); } + bool is_empty() + { + return all.is_empty() && stmt.is_empty(); + } st_transactions() { bzero((char*)this, sizeof(*this));