1 /*****************************************************************************
3 Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *****************************************************************************/
19 /**************************************************//**
20 @file include/read0read.ic
23 Created 2/16/1997 Heikki Tuuri
24 *******************************************************/
26 /*********************************************************************//**
27 Gets the nth trx id in a read view.
31 read_view_get_nth_trx_id(
32 /*=====================*/
33 const read_view_t* view, /*!< in: read view */
34 ulint n) /*!< in: position */
36 ut_ad(n < view->n_trx_ids);
38 return(*(view->trx_ids + n));
41 /*********************************************************************//**
42 Sets the nth trx id in a read view. */
45 read_view_set_nth_trx_id(
46 /*=====================*/
47 read_view_t* view, /*!< in: read view */
48 ulint n, /*!< in: position */
49 trx_id_t trx_id) /*!< in: trx id to set */
51 ut_ad(n < view->n_trx_ids);
53 *(view->trx_ids + n) = trx_id;
56 /*********************************************************************//**
57 Checks if a read view sees the specified transaction.
58 @return TRUE if sees */
61 read_view_sees_trx_id(
62 /*==================*/
63 const read_view_t* view, /*!< in: read view */
64 trx_id_t trx_id) /*!< in: trx id */
70 if (ut_dulint_cmp(trx_id, view->up_limit_id) < 0) {
75 if (ut_dulint_cmp(trx_id, view->low_limit_id) >= 0) {
80 /* We go through the trx ids in the array smallest first: this order
81 may save CPU time, because if there was a very long running
82 transaction in the trx id array, its trx id is looked at first, and
83 the first two comparisons may well decide the visibility of trx_id. */
85 n_ids = view->n_trx_ids;
87 for (i = 0; i < n_ids; i++) {
91 read_view_get_nth_trx_id(view, n_ids - i - 1));