summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/cache_innodb.result11
-rw-r--r--mysql-test/t/cache_innodb.test15
-rw-r--r--sql/sql_cache.cc10
3 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/r/cache_innodb.result b/mysql-test/r/cache_innodb.result
index 600ed84c3c9..293d7a3f412 100644
--- a/mysql-test/r/cache_innodb.result
+++ b/mysql-test/r/cache_innodb.result
@@ -220,3 +220,14 @@ Variable_name Value
Qcache_hits 1
set GLOBAL query_cache_size=1048576;
drop table t2;
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t1 VALUES(1);
+ROLLBACK WORK AND CHAIN NO RELEASE;
+SELECT a FROM t1;
+a
+ROLLBACK WORK AND CHAIN NO RELEASE;
+SELECT a FROM t1;
+a
+ROLLBACK;
+DROP TABLE t1;
diff --git a/mysql-test/t/cache_innodb.test b/mysql-test/t/cache_innodb.test
index 33a328d1d6c..f7102627506 100644
--- a/mysql-test/t/cache_innodb.test
+++ b/mysql-test/t/cache_innodb.test
@@ -14,3 +14,18 @@ let $engine_type= InnoDB;
let $test_foreign_keys= 1;
--source include/query_cache.inc
+
+#
+# Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() ||
+# thd->in_sub_stmt
+#
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+BEGIN;
+ INSERT INTO t1 VALUES(1);
+ROLLBACK WORK AND CHAIN NO RELEASE;
+SELECT a FROM t1;
+ROLLBACK WORK AND CHAIN NO RELEASE;
+SELECT a FROM t1;
+ROLLBACK;
+DROP TABLE t1;
+
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index b57c851edf4..a10e470afd4 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -341,6 +341,7 @@ TODO list:
#include "../storage/myisammrg/ha_myisammrg.h"
#include "../storage/myisammrg/myrg_def.h"
#include "probes_mysql.h"
+#include "transaction.h"
#ifdef EMBEDDED_LIBRARY
#include "emb_qcache.h"
@@ -1683,6 +1684,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
}
else
thd->lex->safe_to_cache_query= 0; // Don't try to cache this
+ /* End the statement transaction potentially started by engine. */
+ trans_rollback_stmt(thd);
goto err_unlock; // Parse query
}
else
@@ -1724,6 +1727,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
thd->limit_found_rows = query->found_rows();
thd->status_var.last_query_cost= 0.0;
+ /*
+ End the statement transaction potentially started by an
+ engine callback. We ignore the return value for now,
+ since as long as EOF packet is part of the query cache
+ response, we can't handle it anyway.
+ */
+ (void) trans_commit_stmt(thd);
if (!thd->stmt_da->is_set())
thd->stmt_da->disable_status();