--- orig/sql/ha_innodb.cc 2009-05-29 11:19:22.000000000 -0700 +++ new/sql/ha_innodb.cc 2009-07-30 15:08:21.000000000 -0700 @@ -7250,6 +7250,18 @@ int error = 0; trx_t* trx = check_trx_exists(thd); + /* Release a possible FIFO ticket and search latch. Since we will + reserve the kernel mutex, we have to release the search system latch + first to obey the latching order. */ + innobase_release_stat_resources(trx); + + if (trx->auto_inc_lock) { + /* If we had reserved the auto-inc lock for some + table in this SQL statement we release it now */ + + row_unlock_table_autoinc_for_mysql(trx); + } + if (thd->lex->sql_command != SQLCOM_XA_PREPARE) { /* For ibbackup to work the order of transactions in binlog @@ -7282,12 +7294,6 @@ trx->xid=thd->transaction.xid_state.xid; - /* Release a possible FIFO ticket and search latch. Since we will - reserve the kernel mutex, we have to release the search system latch - first to obey the latching order. */ - - innobase_release_stat_resources(trx); - if (trx->active_trans == 0 && trx->conc_state != TRX_NOT_STARTED) { sql_print_error("trx->active_trans == 0, but trx->conc_state != " @@ -7307,12 +7313,6 @@ /* We just mark the SQL statement ended and do not do a transaction prepare */ - if (trx->auto_inc_lock) { - /* If we had reserved the auto-inc lock for some - table in this SQL statement we release it now */ - - row_unlock_table_autoinc_for_mysql(trx); - } /* Store the current undo_no of the transaction so that we know where to roll back if we have to roll back the next SQL statement */