~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/read0read.ic

  • Committer: Brian Aker
  • Date: 2010-06-28 16:17:36 UTC
  • mfrom: (1637.4.1 drizzle)
  • Revision ID: brian@gaz-20100628161736-eormhb2mnd551i2h
MergeĀ unused

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
4
 
 
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.
8
 
 
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.
12
 
 
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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/read0read.ic
21
 
Cursor read
22
 
 
23
 
Created 2/16/1997 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
/*********************************************************************//**
27
 
Gets the nth trx id in a read view.
28
 
@return trx id */
29
 
UNIV_INLINE
30
 
trx_id_t
31
 
read_view_get_nth_trx_id(
32
 
/*=====================*/
33
 
        const read_view_t*      view,   /*!< in: read view */
34
 
        ulint                   n)      /*!< in: position */
35
 
{
36
 
        ut_ad(n < view->n_trx_ids);
37
 
 
38
 
        return(*(view->trx_ids + n));
39
 
}
40
 
 
41
 
/*********************************************************************//**
42
 
Sets the nth trx id in a read view. */
43
 
UNIV_INLINE
44
 
void
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 */
50
 
{
51
 
        ut_ad(n < view->n_trx_ids);
52
 
 
53
 
        *(view->trx_ids + n) = trx_id;
54
 
}
55
 
 
56
 
/*********************************************************************//**
57
 
Checks if a read view sees the specified transaction.
58
 
@return TRUE if sees */
59
 
UNIV_INLINE
60
 
ibool
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 */
65
 
{
66
 
        ulint   n_ids;
67
 
        ulint   i;
68
 
 
69
 
        if (trx_id < view->up_limit_id) {
70
 
 
71
 
                return(TRUE);
72
 
        }
73
 
 
74
 
        if (trx_id >= view->low_limit_id) {
75
 
 
76
 
                return(FALSE);
77
 
        }
78
 
 
79
 
        /* We go through the trx ids in the array smallest first: this order
80
 
        may save CPU time, because if there was a very long running
81
 
        transaction in the trx id array, its trx id is looked at first, and
82
 
        the first two comparisons may well decide the visibility of trx_id. */
83
 
 
84
 
        n_ids = view->n_trx_ids;
85
 
 
86
 
        for (i = 0; i < n_ids; i++) {
87
 
                trx_id_t        view_trx_id
88
 
                        = read_view_get_nth_trx_id(view, n_ids - i - 1);
89
 
 
90
 
                if (trx_id <= view_trx_id) {
91
 
                        return(trx_id != view_trx_id);
92
 
                }
93
 
        }
94
 
 
95
 
        return(TRUE);
96
 
}