Commit c4aa83a6 authored by sunny's avatar sunny

branches/zip: Fix a regression introduced by the fix for bug#26316. We check

whether a transaction holds any AUTOINC locks before we acquire the kernel
mutex and release those locks.

Fix for rb://153. Approved by Marko.
parent 66771d73
...@@ -630,6 +630,14 @@ lock_number_of_rows_locked( ...@@ -630,6 +630,14 @@ lock_number_of_rows_locked(
/*=======================*/ /*=======================*/
trx_t* trx); /*!< in: transaction */ trx_t* trx); /*!< in: transaction */
/*******************************************************************//** /*******************************************************************//**
Check if a transaction holds any autoinc locks.
@return TRUE if the transaction holds any AUTOINC locks. */
UNIV_INTERN
ibool
lock_trx_holds_autoinc_locks(
/*=========================*/
const trx_t* trx); /*!< in: transaction */
/*******************************************************************//**
Release all the transaction's autoinc locks. */ Release all the transaction's autoinc locks. */
UNIV_INTERN UNIV_INTERN
void void
......
...@@ -177,7 +177,9 @@ row_update_prebuilt_trx( ...@@ -177,7 +177,9 @@ row_update_prebuilt_trx(
in MySQL handle */ in MySQL handle */
trx_t* trx); /*!< in: transaction handle */ trx_t* trx); /*!< in: transaction handle */
/*********************************************************************//** /*********************************************************************//**
Unlocks AUTO_INC type locks that were possibly reserved by a trx. */ Unlocks AUTO_INC type locks that were possibly reserved by a trx. This
function should be called at the the end of an SQL statement, by the
connection thread that owns the transaction (trx->mysql_thd). */
UNIV_INTERN UNIV_INTERN
void void
row_unlock_table_autoinc_for_mysql( row_unlock_table_autoinc_for_mysql(
......
...@@ -5371,6 +5371,20 @@ lock_release_autoinc_last_lock( ...@@ -5371,6 +5371,20 @@ lock_release_autoinc_last_lock(
lock_table_dequeue(lock); lock_table_dequeue(lock);
} }
/*******************************************************************//**
Check if a transaction holds any autoinc locks.
@return TRUE if the transaction holds any AUTOINC locks. */
UNIV_INTERN
ibool
lock_trx_holds_autoinc_locks(
/*=========================*/
const trx_t* trx) /*!< in: transaction */
{
ut_a(trx->autoinc_locks != NULL);
return(!ib_vector_is_empty(trx->autoinc_locks));
}
/*******************************************************************//** /*******************************************************************//**
Release all the transaction's autoinc locks. */ Release all the transaction's autoinc locks. */
UNIV_INTERN UNIV_INTERN
......
...@@ -866,18 +866,22 @@ row_update_statistics_if_needed( ...@@ -866,18 +866,22 @@ row_update_statistics_if_needed(
} }
/*********************************************************************//** /*********************************************************************//**
Unlocks AUTO_INC type locks that were possibly reserved by a trx. */ Unlocks AUTO_INC type locks that were possibly reserved by a trx. This
function should be called at the the end of an SQL statement, by the
connection thread that owns the transaction (trx->mysql_thd). */
UNIV_INTERN UNIV_INTERN
void void
row_unlock_table_autoinc_for_mysql( row_unlock_table_autoinc_for_mysql(
/*===============================*/ /*===============================*/
trx_t* trx) /*!< in/out: transaction */ trx_t* trx) /*!< in/out: transaction */
{ {
mutex_enter(&kernel_mutex); if (lock_trx_holds_autoinc_locks(trx)) {
mutex_enter(&kernel_mutex);
lock_release_autoinc_locks(trx); lock_release_autoinc_locks(trx);
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
}
} }
/*********************************************************************//** /*********************************************************************//**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment