diff options
author | Michael Widenius <monty@askmonty.org> | 2013-03-26 00:03:13 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-03-26 00:03:13 +0200 |
commit | 068c61978e3a81836d52b8caf11e044290159ad1 (patch) | |
tree | 2cbca861ab2cebe3bd99379ca9668bb483ca0d2a /storage/innobase/include/read0read.ic | |
parent | 35bc8f9f4353b64da215e52ff6f1612a8ce66f43 (diff) | |
download | mariadb-git-068c61978e3a81836d52b8caf11e044290159ad1.tar.gz |
Temporary commit of 10.0-merge
Diffstat (limited to 'storage/innobase/include/read0read.ic')
-rw-r--r-- | storage/innobase/include/read0read.ic | 93 |
1 files changed, 87 insertions, 6 deletions
diff --git a/storage/innobase/include/read0read.ic b/storage/innobase/include/read0read.ic index 436800e1585..82c1028f12e 100644 --- a/storage/innobase/include/read0read.ic +++ b/storage/innobase/include/read0read.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2012, 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 @@ -23,11 +23,64 @@ Cursor read Created 2/16/1997 Heikki Tuuri *******************************************************/ +#include "trx0sys.h" + +#ifdef UNIV_DEBUG +/*********************************************************************//** +Validates a read view object. */ +static +bool +read_view_validate( +/*===============*/ + const read_view_t* view) /*!< in: view to validate */ +{ + ut_ad(mutex_own(&trx_sys->mutex)); + + /* Check that the view->trx_ids array is in descending order. */ + for (ulint i = 1; i < view->n_trx_ids; ++i) { + + ut_a(view->trx_ids[i] < view->trx_ids[i - 1]); + } + + return(true); +} + +/** Functor to validate the view list. */ +struct ViewCheck { + + ViewCheck() : m_prev_view(0) { } + + void operator()(const read_view_t* view) + { + ut_a(m_prev_view == NULL + || m_prev_view->low_limit_no >= view->low_limit_no); + + m_prev_view = view; + } + + const read_view_t* m_prev_view; +}; + +/*********************************************************************//** +Validates a read view list. */ +static +bool +read_view_list_validate(void) +/*=========================*/ +{ + ut_ad(mutex_own(&trx_sys->mutex)); + + ut_list_map(trx_sys->view_list, &read_view_t::view_list, ViewCheck()); + + return(true); +} +#endif /* UNIV_DEBUG */ + /*********************************************************************//** Checks if a read view sees the specified transaction. -@return TRUE if sees */ +@return true if sees */ UNIV_INLINE -ibool +bool read_view_sees_trx_id( /*==================*/ const read_view_t* view, /*!< in: read view */ @@ -35,10 +88,10 @@ read_view_sees_trx_id( { if (trx_id < view->up_limit_id) { - return(TRUE); + return(true); } else if (trx_id >= view->low_limit_id) { - return(FALSE); + return(false); } else { ulint lower = 0; ulint upper = view->n_trx_ids - 1; @@ -63,5 +116,33 @@ read_view_sees_trx_id( } while (lower <= upper); } - return(TRUE); + return(true); +} + +/*********************************************************************//** +Remove a read view from the trx_sys->view_list. */ +UNIV_INLINE +void +read_view_remove( +/*=============*/ + read_view_t* view, /*!< in: read view, can be 0 */ + bool own_mutex) /*!< in: true if caller owns the + trx_sys_t::mutex */ +{ + if (view != 0) { + if (!own_mutex) { + mutex_enter(&trx_sys->mutex); + } + + ut_ad(read_view_validate(view)); + + UT_LIST_REMOVE(view_list, trx_sys->view_list, view); + + ut_ad(read_view_list_validate()); + + if (!own_mutex) { + mutex_exit(&trx_sys->mutex); + } + } } + |