summaryrefslogtreecommitdiff
path: root/storage/xtradb/include/read0read.ic
blob: 2b69167282d35b3c78daeca27f437c101f549575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*****************************************************************************

Copyright (c) 1997, 2009, Innobase Oy. 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
Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT
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., 
51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA

*****************************************************************************/

/**************************************************//**
@file include/read0read.ic
Cursor read

Created 2/16/1997 Heikki Tuuri
*******************************************************/

/*********************************************************************//**
Gets the nth trx id in a read view.

Upstream code stores array of trx_ids in the descending order. Percona Server
keeps it in the ascending order for performance reasons. Let us keep the
semantics.

@return	trx id */
UNIV_INLINE
trx_id_t
read_view_get_nth_trx_id(
/*=====================*/
	const read_view_t*	view,	/*!< in: read view */
	ulint			n)	/*!< in: position */
{
	ut_ad(n < view->n_descr);

	return(view->descriptors[view->n_descr - 1 - n]);
}

/*********************************************************************//**
Sets the nth trx id in a read view.

Upstream code stores array of trx_ids in the descending order. Percona Server
keeps it in the ascending order for performance reasons. Let us keep the
semantics. */
UNIV_INLINE
void
read_view_set_nth_trx_id(
/*=====================*/
	read_view_t*	view,	/*!< in: read view */
	ulint		n,	/*!< in: position */
	trx_id_t	trx_id)	/*!< in: trx id to set */
{
	ut_ad(n < view->n_descr);

	view->descriptors[view->n_descr - 1 - n] = trx_id;
}

/*********************************************************************//**
Checks if a read view sees the specified transaction.
@return	TRUE if sees */
UNIV_INLINE
ibool
read_view_sees_trx_id(
/*==================*/
	const read_view_t*	view,	/*!< in: read view */
	trx_id_t		trx_id)	/*!< in: trx id */
{
	if (trx_id < view->up_limit_id) {

		return(TRUE);
	}

	if (trx_id >= view->low_limit_id) {

		return(FALSE);
	}

	/* Do a binary search over this view's descriptors array */

	return(trx_find_descriptor(view->descriptors, view->n_descr,
				   trx_id) == NULL);
}