summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-11-19 13:16:25 +0100
committerSergei Golubchik <sergii@pisem.net>2013-11-19 13:16:25 +0100
commitfa3f8a18b247d5d7d86d60d016681cc188522f80 (patch)
tree180232f5e13c81e22ae9374b41be168ed9578932 /sql/sql_prepare.cc
parentefab095c7f8f044525ce7d2313fad5f86032baab (diff)
parent543b6e02246db25d8a61574fc709b28e7720d1a0 (diff)
downloadmariadb-git-fa3f8a18b247d5d7d86d60d016681cc188522f80.tar.gz
mysql-5.5.34 merge
(some patches reverted, test case added)
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 0446e8bf18c..ad1e291a9d7 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2002, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2011, Monty Program Ab
+/* Copyright (c) 2002, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2013, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -115,6 +115,7 @@ When one supplies long data for a placeholder:
#endif
#include "lock.h" // MYSQL_OPEN_FORCE_SHARED_MDL
#include "sql_handler.h"
+#include "transaction.h" // trans_rollback_implicit
/**
A result class used to send cursor rows using the binary protocol.
@@ -3399,6 +3400,22 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
close_thread_tables(thd);
thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+
+ /*
+ Transaction rollback was requested since MDL deadlock was discovered
+ while trying to open tables. Rollback transaction in all storage
+ engines including binary log and release all locks.
+
+ Once dynamic SQL is allowed as substatements the below if-statement
+ has to be adjusted to not do rollback in substatement.
+ */
+ DBUG_ASSERT(! thd->in_sub_stmt);
+ if (thd->transaction_rollback_request)
+ {
+ trans_rollback_implicit(thd);
+ thd->mdl_context.release_transactional_locks();
+ }
+
lex_end(lex);
cleanup_stmt();
thd->restore_backup_statement(this, &stmt_backup);