summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a8dbebe012d..bf07bae379d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3012,6 +3012,7 @@ end_with_restore_list:
break;
case SQLCOM_LOCK_TABLES:
unlock_locked_tables(thd);
+ /* we must end the trasaction first, regardless of anything */
if (end_active_trans(thd))
goto error;
if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, 0))
@@ -3030,7 +3031,15 @@ end_with_restore_list:
send_ok(thd);
}
else
+ {
+ /*
+ Need to end the current transaction, so the storage engine (InnoDB)
+ can free its locks if LOCK TABLES locked some tables before finding
+ that it can't lock a table in its list
+ */
+ end_active_trans(thd);
thd->options&= ~(ulong) (OPTION_TABLE_LOCK);
+ }
thd->in_lock_tables=0;
break;
case SQLCOM_CREATE_DB: