~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innobase/include/page0cur.ic

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************
 
2
The page cursor
 
3
 
 
4
(c) 1994-1996 Innobase Oy
 
5
 
 
6
Created 10/4/1994 Heikki Tuuri
 
7
*************************************************************************/
 
8
 
 
9
#include "page0page.h"
 
10
 
 
11
 
 
12
/*************************************************************
 
13
Gets pointer to the page frame where the cursor is positioned. */
 
14
UNIV_INLINE
 
15
page_t*
 
16
page_cur_get_page(
 
17
/*==============*/
 
18
                                /* out: page */
 
19
        page_cur_t*     cur)    /* in: page cursor */
 
20
{
 
21
        ut_ad(cur);
 
22
 
 
23
        return(buf_frame_align(cur->rec));
 
24
}
 
25
 
 
26
/*************************************************************
 
27
Gets the record where the cursor is positioned. */
 
28
UNIV_INLINE
 
29
rec_t*
 
30
page_cur_get_rec(
 
31
/*=============*/
 
32
                                /* out: record */
 
33
        page_cur_t*     cur)    /* in: page cursor */
 
34
{
 
35
        ut_ad(cur);
 
36
 
 
37
        return(cur->rec);
 
38
}
 
39
 
 
40
/*************************************************************
 
41
Sets the cursor object to point before the first user record
 
42
on the page. */
 
43
UNIV_INLINE
 
44
void
 
45
page_cur_set_before_first(
 
46
/*======================*/
 
47
        page_t*         page,   /* in: index page */
 
48
        page_cur_t*     cur)    /* in: cursor */
 
49
{
 
50
        cur->rec = page_get_infimum_rec(page);
 
51
}
 
52
 
 
53
/*************************************************************
 
54
Sets the cursor object to point after the last user record on
 
55
the page. */
 
56
UNIV_INLINE
 
57
void
 
58
page_cur_set_after_last(
 
59
/*====================*/
 
60
        page_t*         page,   /* in: index page */
 
61
        page_cur_t*     cur)    /* in: cursor */
 
62
{
 
63
        cur->rec = page_get_supremum_rec(page);
 
64
}
 
65
 
 
66
/*************************************************************
 
67
Returns TRUE if the cursor is before first user record on page. */
 
68
UNIV_INLINE
 
69
ibool
 
70
page_cur_is_before_first(
 
71
/*=====================*/
 
72
                                        /* out: TRUE if at start */
 
73
        const page_cur_t*       cur)    /* in: cursor */
 
74
{
 
75
        return(page_rec_is_infimum(cur->rec));
 
76
}
 
77
 
 
78
/*************************************************************
 
79
Returns TRUE if the cursor is after last user record. */
 
80
UNIV_INLINE
 
81
ibool
 
82
page_cur_is_after_last(
 
83
/*===================*/
 
84
                                        /* out: TRUE if at end */
 
85
        const page_cur_t*       cur)    /* in: cursor */
 
86
{
 
87
        return(page_rec_is_supremum(cur->rec));
 
88
}
 
89
 
 
90
/**************************************************************
 
91
Positions the cursor on the given record. */
 
92
UNIV_INLINE
 
93
void
 
94
page_cur_position(
 
95
/*==============*/
 
96
        rec_t*          rec,    /* in: record on a page */
 
97
        page_cur_t*     cur)    /* in: page cursor */
 
98
{
 
99
        ut_ad(rec && cur);
 
100
 
 
101
        cur->rec = rec;
 
102
}
 
103
 
 
104
/**************************************************************
 
105
Invalidates a page cursor by setting the record pointer NULL. */
 
106
UNIV_INLINE
 
107
void
 
108
page_cur_invalidate(
 
109
/*================*/
 
110
        page_cur_t*     cur)    /* in: page cursor */
 
111
{
 
112
        ut_ad(cur);
 
113
 
 
114
        cur->rec = NULL;
 
115
}
 
116
 
 
117
/**************************************************************
 
118
Moves the cursor to the next record on page. */
 
119
UNIV_INLINE
 
120
void
 
121
page_cur_move_to_next(
 
122
/*==================*/
 
123
        page_cur_t*     cur)    /* in: cursor; must not be after last */
 
124
{
 
125
        ut_ad(!page_cur_is_after_last(cur));
 
126
 
 
127
        cur->rec = page_rec_get_next(cur->rec);
 
128
}
 
129
 
 
130
/**************************************************************
 
131
Moves the cursor to the previous record on page. */
 
132
UNIV_INLINE
 
133
void
 
134
page_cur_move_to_prev(
 
135
/*==================*/
 
136
        page_cur_t*     cur)    /* in: page cursor, not before first */
 
137
{
 
138
        ut_ad(!page_cur_is_before_first(cur));
 
139
 
 
140
        cur->rec = page_rec_get_prev(cur->rec);
 
141
}
 
142
 
 
143
/********************************************************************
 
144
Searches the right position for a page cursor. */
 
145
UNIV_INLINE
 
146
ulint
 
147
page_cur_search(
 
148
/*============*/
 
149
                                /* out: number of matched fields on the left */
 
150
        page_t*         page,   /* in: index page */
 
151
        dict_index_t*   index,  /* in: record descriptor */
 
152
        dtuple_t*       tuple,  /* in: data tuple */
 
153
        ulint           mode,   /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
 
154
                                or PAGE_CUR_GE */
 
155
        page_cur_t*     cursor) /* out: page cursor */
 
156
{
 
157
        ulint           low_matched_fields = 0;
 
158
        ulint           low_matched_bytes = 0;
 
159
        ulint           up_matched_fields = 0;
 
160
        ulint           up_matched_bytes = 0;
 
161
 
 
162
        ut_ad(dtuple_check_typed(tuple));
 
163
 
 
164
        page_cur_search_with_match(page, index, tuple, mode,
 
165
                                   &up_matched_fields,
 
166
                                   &up_matched_bytes,
 
167
                                   &low_matched_fields,
 
168
                                   &low_matched_bytes,
 
169
                                   cursor);
 
170
        return(low_matched_fields);
 
171
}
 
172
 
 
173
/***************************************************************
 
174
Inserts a record next to page cursor. Returns pointer to inserted record if
 
175
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
 
176
the same position. */
 
177
UNIV_INLINE
 
178
rec_t*
 
179
page_cur_tuple_insert(
 
180
/*==================*/
 
181
                                /* out: pointer to record if succeed, NULL
 
182
                                otherwise */
 
183
        page_cur_t*     cursor, /* in: a page cursor */
 
184
        dtuple_t*       tuple,  /* in: pointer to a data tuple */
 
185
        dict_index_t*   index,  /* in: record descriptor */
 
186
        mtr_t*          mtr)    /* in: mini-transaction handle */
 
187
{
 
188
        return(page_cur_insert_rec_low(cursor, tuple, index, NULL, NULL, mtr));
 
189
}
 
190
 
 
191
/***************************************************************
 
192
Inserts a record next to page cursor. Returns pointer to inserted record if
 
193
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
 
194
the same position. */
 
195
UNIV_INLINE
 
196
rec_t*
 
197
page_cur_rec_insert(
 
198
/*================*/
 
199
                                /* out: pointer to record if succeed, NULL
 
200
                                otherwise */
 
201
        page_cur_t*     cursor, /* in: a page cursor */
 
202
        rec_t*          rec,    /* in: record to insert */
 
203
        dict_index_t*   index,  /* in: record descriptor */
 
204
        ulint*          offsets,/* in: rec_get_offsets(rec, index) */
 
205
        mtr_t*          mtr)    /* in: mini-transaction handle */
 
206
{
 
207
        return(page_cur_insert_rec_low(cursor, NULL, index, rec,
 
208
                                       offsets, mtr));
 
209
}
 
210