diff options
| author | Konstantin Osipov <kostja@sun.com> | 2010-07-27 14:25:53 +0400 |
|---|---|---|
| committer | Konstantin Osipov <kostja@sun.com> | 2010-07-27 14:25:53 +0400 |
| commit | ec2c3bf2c1c27e4401c767a6cdcb3172453ff42c (patch) | |
| tree | daa2c75e6ac3ede954eb788e81dd95c711da1569 /sql/sql_insert.cc | |
| parent | c67cf159e928fe63582a4233d130dada0f866cb7 (diff) | |
| download | mariadb-git-ec2c3bf2c1c27e4401c767a6cdcb3172453ff42c.tar.gz | |
A pre-requisite patch for the fix for Bug#52044.
This patch also fixes Bug#55452 "SET PASSWORD is
replicated twice in RBR mode".
The goal of this patch is to remove the release of
metadata locks from close_thread_tables().
This is necessary to not mistakenly release
the locks in the course of a multi-step
operation that involves multiple close_thread_tables()
or close_tables_for_reopen().
On the same token, move statement commit outside
close_thread_tables().
Other cleanups:
Cleanup COM_FIELD_LIST.
Don't call close_thread_tables() in COM_SHUTDOWN -- there
are no open tables there that can be closed (we leave
the locked tables mode in THD destructor, and this
close_thread_tables() won't leave it anyway).
Make open_and_lock_tables() and open_and_lock_tables_derived()
call close_thread_tables() upon failure.
Remove the calls to close_thread_tables() that are now
unnecessary.
Simplify the back off condition in Open_table_context.
Streamline metadata lock handling in LOCK TABLES
implementation.
Add asserts to ensure correct life cycle of
statement transaction in a session.
Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
Diffstat (limited to 'sql/sql_insert.cc')
| -rw-r--r-- | sql/sql_insert.cc | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c783d74b363..cc0b6ba3a2d 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1862,7 +1862,10 @@ public: while ((row=rows.get())) delete row; if (table) + { close_thread_tables(&thd); + thd.mdl_context.release_transactional_locks(); + } mysql_mutex_lock(&LOCK_thread_count); mysql_mutex_destroy(&mutex); mysql_cond_destroy(&cond); @@ -2414,6 +2417,8 @@ bool Delayed_insert::open_and_lock_table() } if (!(table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED)) { + /* To rollback InnoDB statement transaction. */ + trans_rollback_stmt(&thd); my_error(ER_DELAYED_NOT_SUPPORTED, MYF(ME_FATALERROR), table_list.table_name); return TRUE; @@ -2480,12 +2485,6 @@ pthread_handler_t handle_delayed_insert(void *arg) goto err; } - /* - Open table requires an initialized lex in case the table is - partitioned. The .frm file contains a partial SQL string which is - parsed using a lex, that depends on initialized thd->lex. - */ - lex_start(thd); thd->lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock() /* Statement-based replication of INSERT DELAYED has problems with RAND() @@ -2619,28 +2618,11 @@ pthread_handler_t handle_delayed_insert(void *arg) } err: - /* - mysql_lock_tables() can potentially start a transaction and write - a table map. In the event of an error, that transaction has to be - rolled back. We only need to roll back a potential statement - transaction, since real transactions are rolled back in - close_thread_tables(). - - TODO: This is not true any more, table maps are generated on the - first call to ha_*_row() instead. Remove code that are used to - cover for the case outlined above. - */ - trans_rollback_stmt(thd); - DBUG_LEAVE; } - /* - di should be unlinked from the thread handler list and have no active - clients - */ - close_thread_tables(thd); // Free the table + thd->mdl_context.release_transactional_locks(); di->table=0; thd->killed= THD::KILL_CONNECTION; // If error mysql_cond_broadcast(&di->cond_client); // Safety @@ -2648,6 +2630,10 @@ pthread_handler_t handle_delayed_insert(void *arg) mysql_mutex_lock(&LOCK_delayed_create); // Because of delayed_get_table mysql_mutex_lock(&LOCK_delayed_insert); + /* + di should be unlinked from the thread handler list and have no active + clients + */ delete di; mysql_mutex_unlock(&LOCK_delayed_insert); mysql_mutex_unlock(&LOCK_delayed_create); |
