diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 417484b2ef7..18ab3c45359 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -81,7 +81,8 @@ static void init_signals(void) inline bool end_active_trans(THD *thd) { int error=0; - if (thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)) + if (thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN | + OPTION_TABLE_LOCK)) { thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); thd->server_status&= ~SERVER_STATUS_IN_TRANS; @@ -1825,7 +1826,11 @@ mysql_execute_command(void) { thd->lock=thd->locked_tables; thd->locked_tables=0; // Will be automaticly closed + } + if (thd->options & OPTION_TABLE_LOCK) + { end_active_trans(thd); + thd->options&= ~(ulong) (OPTION_TABLE_LOCK); } if (thd->global_read_lock) { @@ -1847,12 +1852,15 @@ mysql_execute_command(void) if (check_db_used(thd,tables) || end_active_trans(thd)) goto error; thd->in_lock_tables=1; + thd->options|= OPTION_TABLE_LOCK; if (!(res=open_and_lock_tables(thd,tables))) { thd->locked_tables=thd->lock; thd->lock=0; send_ok(&thd->net); } + else + thd->options&= ~(ulong) (OPTION_TABLE_LOCK); thd->in_lock_tables=0; break; case SQLCOM_CREATE_DB: |