1
by brian
clean slate |
1 |
/******************************************************
|
2 |
Cursor read
|
|
3 |
||
4 |
(c) 1997 Innobase Oy
|
|
5 |
||
6 |
Created 2/16/1997 Heikki Tuuri
|
|
7 |
*******************************************************/
|
|
8 |
||
9 |
/*************************************************************************
|
|
10 |
Gets the nth trx id in a read view. */
|
|
11 |
UNIV_INLINE |
|
12 |
dulint |
|
13 |
read_view_get_nth_trx_id(
|
|
14 |
/*=====================*/
|
|
15 |
/* out: trx id */ |
|
16 |
read_view_t* view, /* in: read view */ |
|
17 |
ulint n) /* in: position */ |
|
18 |
{
|
|
19 |
ut_ad(n < view->n_trx_ids); |
|
20 |
||
21 |
return(*(view->trx_ids + n)); |
|
22 |
}
|
|
23 |
||
24 |
/*************************************************************************
|
|
25 |
Sets the nth trx id in a read view. */
|
|
26 |
UNIV_INLINE |
|
27 |
void |
|
28 |
read_view_set_nth_trx_id(
|
|
29 |
/*=====================*/
|
|
30 |
read_view_t* view, /* in: read view */ |
|
31 |
ulint n, /* in: position */ |
|
32 |
dulint trx_id) /* in: trx id to set */ |
|
33 |
{
|
|
34 |
ut_ad(n < view->n_trx_ids); |
|
35 |
||
36 |
*(view->trx_ids + n) = trx_id; |
|
37 |
}
|
|
38 |
||
39 |
/*************************************************************************
|
|
40 |
Checks if a read view sees the specified transaction. */
|
|
41 |
UNIV_INLINE |
|
42 |
ibool |
|
43 |
read_view_sees_trx_id(
|
|
44 |
/*==================*/
|
|
45 |
/* out: TRUE if sees */ |
|
46 |
read_view_t* view, /* in: read view */ |
|
47 |
dulint trx_id) /* in: trx id */ |
|
48 |
{
|
|
49 |
ulint n_ids; |
|
50 |
int cmp; |
|
51 |
ulint i; |
|
52 |
||
53 |
if (ut_dulint_cmp(trx_id, view->up_limit_id) < 0) { |
|
54 |
||
55 |
return(TRUE); |
|
56 |
} |
|
57 |
||
58 |
if (ut_dulint_cmp(trx_id, view->low_limit_id) >= 0) { |
|
59 |
||
60 |
return(FALSE); |
|
61 |
} |
|
62 |
||
63 |
/* We go through the trx ids in the array smallest first: this order |
|
64 |
may save CPU time, because if there was a very long running
|
|
65 |
transaction in the trx id array, its trx id is looked at first, and
|
|
66 |
the first two comparisons may well decide the visibility of trx_id. */
|
|
67 |
||
68 |
n_ids = view->n_trx_ids; |
|
69 |
||
70 |
for (i = 0; i < n_ids; i++) { |
|
71 |
||
72 |
cmp = ut_dulint_cmp( |
|
73 |
trx_id, |
|
74 |
read_view_get_nth_trx_id(view, n_ids - i - 1)); |
|
75 |
if (cmp <= 0) { |
|
76 |
return(cmp < 0); |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
return(TRUE); |
|
81 |
}
|