diff options
Diffstat (limited to 'storage/innobase/include/trx0trx.ic')
-rw-r--r-- | storage/innobase/include/trx0trx.ic | 93 |
1 files changed, 60 insertions, 33 deletions
diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic index 4a1d3bcde0b..ceeb121ab70 100644 --- a/storage/innobase/include/trx0trx.ic +++ b/storage/innobase/include/trx0trx.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -23,37 +23,48 @@ The transaction Created 3/26/1996 Heikki Tuuri *******************************************************/ -/*************************************************************//** -Starts the transaction if it is not yet started. */ -UNIV_INLINE -void -trx_start_if_not_started( -/*=====================*/ - trx_t* trx) /*!< in: transaction */ -{ - ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY); - - if (trx->conc_state == TRX_NOT_STARTED) { - - trx_start(trx, ULINT_UNDEFINED); - } -} - -/*************************************************************//** -Starts the transaction if it is not yet started. Assumes we have reserved -the kernel mutex! */ +/**********************************************************************//** +Determines if a transaction is in the given state. +The caller must hold trx_sys->mutex, or it must be the thread +that is serving a running transaction. +A running transaction must be in trx_sys->ro_trx_list or trx_sys->rw_trx_list +unless it is a non-locking autocommit read only transaction, which is only +in trx_sys->mysql_trx_list. +@return TRUE if trx->state == state */ UNIV_INLINE -void -trx_start_if_not_started_low( -/*=========================*/ - trx_t* trx) /*!< in: transaction */ +ibool +trx_state_eq( +/*=========*/ + const trx_t* trx, /*!< in: transaction */ + trx_state_t state) /*!< in: state; + if state != TRX_STATE_NOT_STARTED + asserts that + trx->state != TRX_STATE_NOT_STARTED */ { - ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY); - - if (trx->conc_state == TRX_NOT_STARTED) { - - trx_start_low(trx, ULINT_UNDEFINED); +#ifdef UNIV_DEBUG + switch (trx->state) { + case TRX_STATE_PREPARED: + assert_trx_in_rw_list(trx); + return(trx->state == state); + + case TRX_STATE_ACTIVE: + assert_trx_nonlocking_or_in_list(trx); + return(state == trx->state); + + case TRX_STATE_COMMITTED_IN_MEMORY: + assert_trx_in_list(trx); + return(state == trx->state); + + case TRX_STATE_NOT_STARTED: + /* This state is not allowed for running transactions. */ + ut_a(state == TRX_STATE_NOT_STARTED); + ut_ad(!trx->in_rw_trx_list); + ut_ad(!trx->in_ro_trx_list); + return(state == trx->state); } + ut_error; +#endif /* UNIV_DEBUG */ + return(trx->state == state); } /****************************************************************//** @@ -79,7 +90,7 @@ trx_get_que_state_str( const trx_t* trx) /*!< in: transaction */ { /* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */ - switch (trx->que_state) { + switch (trx->lock.que_state) { case TRX_QUE_RUNNING: return("RUNNING"); case TRX_QUE_LOCK_WAIT: @@ -113,7 +124,7 @@ trx_get_dict_operation( } ut_error; #endif /* UNIV_DEBUG */ - return((enum trx_dict_op) UNIV_EXPECT(op, TRX_DICT_OP_NONE)); + return((enum trx_dict_op) op); } /**********************************************************************//** Flag a transaction a dictionary operation. */ @@ -150,3 +161,19 @@ ok: trx->dict_operation = op; } + +/********************************************************************//** +Releases the search latch if trx has reserved it. */ +UNIV_INLINE +void +trx_search_latch_release_if_reserved( +/*=================================*/ + trx_t* trx) /*!< in: transaction */ +{ + if (trx->has_search_latch) { + rw_lock_s_unlock(&btr_search_latch); + + trx->has_search_latch = FALSE; + } +} + |