641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
3 |
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
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
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
15 |
St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
16 |
|
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/btr0pcur.ic
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
The index tree persistent cursor
|
22 |
||
23 |
Created 2/23/1996 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
27 |
/*********************************************************//**
|
28 |
Gets the rel_pos field for a cursor whose position has been stored.
|
|
29 |
@return BTR_PCUR_ON, ... */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
30 |
UNIV_INLINE
|
31 |
ulint
|
|
32 |
btr_pcur_get_rel_pos( |
|
33 |
/*=================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
34 |
const btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
35 |
{
|
36 |
ut_ad(cursor); |
|
37 |
ut_ad(cursor->old_rec); |
|
38 |
ut_ad(cursor->old_stored == BTR_PCUR_OLD_STORED); |
|
39 |
ut_ad(cursor->pos_state == BTR_PCUR_WAS_POSITIONED |
|
40 |
|| cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
41 |
||
42 |
return(cursor->rel_pos); |
|
43 |
}
|
|
44 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
45 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
46 |
Sets the mtr field for a pcur. */
|
47 |
UNIV_INLINE
|
|
48 |
void
|
|
49 |
btr_pcur_set_mtr( |
|
50 |
/*=============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
51 |
btr_pcur_t* cursor, /*!< in: persistent cursor */ |
52 |
mtr_t* mtr) /*!< in, own: mtr */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
53 |
{
|
54 |
ut_ad(cursor); |
|
55 |
||
56 |
cursor->mtr = mtr; |
|
57 |
}
|
|
58 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
59 |
/*********************************************************//**
|
60 |
Gets the mtr field for a pcur.
|
|
61 |
@return mtr */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
62 |
UNIV_INLINE
|
63 |
mtr_t* |
|
64 |
btr_pcur_get_mtr( |
|
65 |
/*=============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
66 |
btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
67 |
{
|
68 |
ut_ad(cursor); |
|
69 |
||
70 |
return(cursor->mtr); |
|
71 |
}
|
|
72 |
||
73 |
#ifdef UNIV_DEBUG |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
74 |
/*********************************************************//**
|
75 |
Returns the btr cursor component of a persistent cursor.
|
|
76 |
@return pointer to btr cursor component */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
77 |
UNIV_INLINE
|
78 |
btr_cur_t* |
|
79 |
btr_pcur_get_btr_cur( |
|
80 |
/*=================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
81 |
const btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
82 |
{
|
83 |
const btr_cur_t* btr_cur = &cursor->btr_cur; |
|
84 |
return((btr_cur_t*) btr_cur); |
|
85 |
}
|
|
86 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
87 |
/*********************************************************//**
|
88 |
Returns the page cursor component of a persistent cursor.
|
|
89 |
@return pointer to page cursor component */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
90 |
UNIV_INLINE
|
91 |
page_cur_t* |
|
92 |
btr_pcur_get_page_cur( |
|
93 |
/*==================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
94 |
const btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
95 |
{
|
96 |
return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor))); |
|
97 |
}
|
|
98 |
#endif /* UNIV_DEBUG */ |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
99 |
/*********************************************************//**
|
100 |
Returns the page of a persistent cursor.
|
|
101 |
@return pointer to the page */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
102 |
UNIV_INLINE
|
103 |
page_t* |
|
104 |
btr_pcur_get_page( |
|
105 |
/*==============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
106 |
btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
107 |
{
|
108 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
109 |
||
110 |
return(btr_cur_get_page(btr_pcur_get_btr_cur(cursor))); |
|
111 |
}
|
|
112 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
113 |
/*********************************************************//**
|
114 |
Returns the buffer block of a persistent cursor.
|
|
115 |
@return pointer to the block */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
116 |
UNIV_INLINE
|
117 |
buf_block_t* |
|
118 |
btr_pcur_get_block( |
|
119 |
/*===============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
120 |
btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
121 |
{
|
122 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
123 |
||
124 |
return(btr_cur_get_block(btr_pcur_get_btr_cur(cursor))); |
|
125 |
}
|
|
126 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
127 |
/*********************************************************//**
|
128 |
Returns the record of a persistent cursor.
|
|
129 |
@return pointer to the record */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
130 |
UNIV_INLINE
|
131 |
rec_t* |
|
132 |
btr_pcur_get_rec( |
|
133 |
/*=============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
134 |
btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
135 |
{
|
136 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
137 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
138 |
||
139 |
return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor))); |
|
140 |
}
|
|
141 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
142 |
/**************************************************************//**
|
143 |
Gets the up_match value for a pcur after a search.
|
|
144 |
@return number of matched fields at the cursor or to the right if
|
|
145 |
search mode was PAGE_CUR_GE, otherwise undefined */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
146 |
UNIV_INLINE
|
147 |
ulint
|
|
148 |
btr_pcur_get_up_match( |
|
149 |
/*==================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
150 |
btr_pcur_t* cursor) /*!< in: memory buffer for persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
151 |
{
|
152 |
btr_cur_t* btr_cursor; |
|
153 |
||
154 |
ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED) |
|
155 |
|| (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); |
|
156 |
||
157 |
btr_cursor = btr_pcur_get_btr_cur(cursor); |
|
158 |
||
159 |
ut_ad(btr_cursor->up_match != ULINT_UNDEFINED); |
|
160 |
||
161 |
return(btr_cursor->up_match); |
|
162 |
}
|
|
163 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
164 |
/**************************************************************//**
|
165 |
Gets the low_match value for a pcur after a search.
|
|
166 |
@return number of matched fields at the cursor or to the right if
|
|
167 |
search mode was PAGE_CUR_LE, otherwise undefined */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
168 |
UNIV_INLINE
|
169 |
ulint
|
|
170 |
btr_pcur_get_low_match( |
|
171 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
172 |
btr_pcur_t* cursor) /*!< in: memory buffer for persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
173 |
{
|
174 |
btr_cur_t* btr_cursor; |
|
175 |
||
176 |
ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED) |
|
177 |
|| (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); |
|
178 |
||
179 |
btr_cursor = btr_pcur_get_btr_cur(cursor); |
|
180 |
ut_ad(btr_cursor->low_match != ULINT_UNDEFINED); |
|
181 |
||
182 |
return(btr_cursor->low_match); |
|
183 |
}
|
|
184 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
185 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
186 |
Checks if the persistent cursor is after the last user record on
|
187 |
a page. */
|
|
188 |
UNIV_INLINE
|
|
189 |
ibool
|
|
190 |
btr_pcur_is_after_last_on_page( |
|
191 |
/*===========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
192 |
const btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
193 |
{
|
194 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
195 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
196 |
||
197 |
return(page_cur_is_after_last(btr_pcur_get_page_cur(cursor))); |
|
198 |
}
|
|
199 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
200 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
201 |
Checks if the persistent cursor is before the first user record on
|
202 |
a page. */
|
|
203 |
UNIV_INLINE
|
|
204 |
ibool
|
|
205 |
btr_pcur_is_before_first_on_page( |
|
206 |
/*=============================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
207 |
const btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
208 |
{
|
209 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
210 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
211 |
||
212 |
return(page_cur_is_before_first(btr_pcur_get_page_cur(cursor))); |
|
213 |
}
|
|
214 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
215 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
216 |
Checks if the persistent cursor is on a user record. */
|
217 |
UNIV_INLINE
|
|
218 |
ibool
|
|
219 |
btr_pcur_is_on_user_rec( |
|
220 |
/*====================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
221 |
const btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
222 |
{
|
223 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
224 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
225 |
||
226 |
if (btr_pcur_is_before_first_on_page(cursor) |
|
227 |
|| btr_pcur_is_after_last_on_page(cursor)) { |
|
228 |
||
229 |
return(FALSE); |
|
230 |
} |
|
231 |
||
232 |
return(TRUE); |
|
233 |
}
|
|
234 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
235 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
236 |
Checks if the persistent cursor is before the first user record in
|
237 |
the index tree. */
|
|
238 |
UNIV_INLINE
|
|
239 |
ibool
|
|
240 |
btr_pcur_is_before_first_in_tree( |
|
241 |
/*=============================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
242 |
btr_pcur_t* cursor, /*!< in: persistent cursor */ |
243 |
mtr_t* mtr) /*!< in: mtr */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
244 |
{
|
245 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
246 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
247 |
||
248 |
if (btr_page_get_prev(btr_pcur_get_page(cursor), mtr) != FIL_NULL) { |
|
249 |
||
250 |
return(FALSE); |
|
251 |
} |
|
252 |
||
253 |
return(page_cur_is_before_first(btr_pcur_get_page_cur(cursor))); |
|
254 |
}
|
|
255 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
256 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
257 |
Checks if the persistent cursor is after the last user record in
|
258 |
the index tree. */
|
|
259 |
UNIV_INLINE
|
|
260 |
ibool
|
|
261 |
btr_pcur_is_after_last_in_tree( |
|
262 |
/*===========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
263 |
btr_pcur_t* cursor, /*!< in: persistent cursor */ |
264 |
mtr_t* mtr) /*!< in: mtr */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
265 |
{
|
266 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
267 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
268 |
||
269 |
if (btr_page_get_next(btr_pcur_get_page(cursor), mtr) != FIL_NULL) { |
|
270 |
||
271 |
return(FALSE); |
|
272 |
} |
|
273 |
||
274 |
return(page_cur_is_after_last(btr_pcur_get_page_cur(cursor))); |
|
275 |
}
|
|
276 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
277 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
278 |
Moves the persistent cursor to the next record on the same page. */
|
279 |
UNIV_INLINE
|
|
280 |
void
|
|
281 |
btr_pcur_move_to_next_on_page( |
|
282 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
283 |
btr_pcur_t* cursor) /*!< in/out: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
284 |
{
|
285 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
286 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
287 |
||
288 |
page_cur_move_to_next(btr_pcur_get_page_cur(cursor)); |
|
289 |
||
290 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
291 |
}
|
|
292 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
293 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
294 |
Moves the persistent cursor to the previous record on the same page. */
|
295 |
UNIV_INLINE
|
|
296 |
void
|
|
297 |
btr_pcur_move_to_prev_on_page( |
|
298 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
299 |
btr_pcur_t* cursor) /*!< in/out: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
300 |
{
|
301 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
302 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
303 |
||
304 |
page_cur_move_to_prev(btr_pcur_get_page_cur(cursor)); |
|
305 |
||
306 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
307 |
}
|
|
308 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
309 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
310 |
Moves the persistent cursor to the last record on the same page. */
|
311 |
UNIV_INLINE
|
|
312 |
void
|
|
313 |
btr_pcur_move_to_last_on_page( |
|
314 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
315 |
btr_pcur_t* cursor, /*!< in: persistent cursor */ |
316 |
mtr_t* mtr) /*!< in: mtr */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
317 |
{
|
318 |
UT_NOT_USED(mtr); |
|
319 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
320 |
||
321 |
page_cur_set_after_last(btr_pcur_get_block(cursor), |
|
322 |
btr_pcur_get_page_cur(cursor)); |
|
323 |
||
324 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
325 |
}
|
|
326 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
327 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
328 |
Moves the persistent cursor to the next user record in the tree. If no user
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
329 |
records are left, the cursor ends up 'after last in tree'.
|
330 |
@return TRUE if the cursor moved forward, ending on a user record */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
331 |
UNIV_INLINE
|
332 |
ibool
|
|
333 |
btr_pcur_move_to_next_user_rec( |
|
334 |
/*===========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
335 |
btr_pcur_t* cursor, /*!< in: persistent cursor; NOTE that the |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
336 |
function may release the page latch */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
337 |
mtr_t* mtr) /*!< in: mtr */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
338 |
{
|
339 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
340 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
341 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
342 |
loop: |
|
343 |
if (btr_pcur_is_after_last_on_page(cursor)) { |
|
344 |
||
345 |
if (btr_pcur_is_after_last_in_tree(cursor, mtr)) { |
|
346 |
||
347 |
return(FALSE); |
|
348 |
} |
|
349 |
||
350 |
btr_pcur_move_to_next_page(cursor, mtr); |
|
351 |
} else { |
|
352 |
btr_pcur_move_to_next_on_page(cursor); |
|
353 |
} |
|
354 |
||
355 |
if (btr_pcur_is_on_user_rec(cursor)) { |
|
356 |
||
357 |
return(TRUE); |
|
358 |
} |
|
359 |
||
360 |
goto loop; |
|
361 |
}
|
|
362 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
363 |
/*********************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
364 |
Moves the persistent cursor to the next record in the tree. If no records are
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
365 |
left, the cursor stays 'after last in tree'.
|
366 |
@return TRUE if the cursor was not after last in tree */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
367 |
UNIV_INLINE
|
368 |
ibool
|
|
369 |
btr_pcur_move_to_next( |
|
370 |
/*==================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
371 |
btr_pcur_t* cursor, /*!< in: persistent cursor; NOTE that the |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
372 |
function may release the page latch */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
373 |
mtr_t* mtr) /*!< in: mtr */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
374 |
{
|
375 |
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
|
376 |
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); |
|
377 |
||
378 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
379 |
||
380 |
if (btr_pcur_is_after_last_on_page(cursor)) { |
|
381 |
||
382 |
if (btr_pcur_is_after_last_in_tree(cursor, mtr)) { |
|
383 |
||
384 |
return(FALSE); |
|
385 |
} |
|
386 |
||
387 |
btr_pcur_move_to_next_page(cursor, mtr); |
|
388 |
||
389 |
return(TRUE); |
|
390 |
} |
|
391 |
||
392 |
btr_pcur_move_to_next_on_page(cursor); |
|
393 |
||
394 |
return(TRUE); |
|
395 |
}
|
|
396 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
397 |
/**************************************************************//**
|
1819.5.191
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6595 from MySQL InnoDB |
398 |
Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES,
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
399 |
that is, the cursor becomes detached. If there have been modifications
|
400 |
to the page where pcur is positioned, this can be used instead of
|
|
401 |
btr_pcur_release_leaf. Function btr_pcur_store_position should be used
|
|
402 |
before calling this, if restoration of cursor is wanted later. */
|
|
403 |
UNIV_INLINE
|
|
404 |
void
|
|
405 |
btr_pcur_commit_specify_mtr( |
|
406 |
/*========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
407 |
btr_pcur_t* pcur, /*!< in: persistent cursor */ |
408 |
mtr_t* mtr) /*!< in: mtr to commit */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
409 |
{
|
410 |
ut_a(pcur->pos_state == BTR_PCUR_IS_POSITIONED); |
|
411 |
||
412 |
pcur->latch_mode = BTR_NO_LATCHES; |
|
413 |
||
414 |
mtr_commit(mtr); |
|
415 |
||
416 |
pcur->pos_state = BTR_PCUR_WAS_POSITIONED; |
|
417 |
}
|
|
418 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
419 |
/**************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
420 |
Sets the pcur latch mode to BTR_NO_LATCHES. */
|
421 |
UNIV_INLINE
|
|
422 |
void
|
|
423 |
btr_pcur_detach( |
|
424 |
/*============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
425 |
btr_pcur_t* pcur) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
426 |
{
|
427 |
ut_a(pcur->pos_state == BTR_PCUR_IS_POSITIONED); |
|
428 |
||
429 |
pcur->latch_mode = BTR_NO_LATCHES; |
|
430 |
||
431 |
pcur->pos_state = BTR_PCUR_WAS_POSITIONED; |
|
432 |
}
|
|
433 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
434 |
/**************************************************************//**
|
435 |
Tests if a cursor is detached: that is the latch mode is BTR_NO_LATCHES.
|
|
436 |
@return TRUE if detached */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
437 |
UNIV_INLINE
|
438 |
ibool
|
|
439 |
btr_pcur_is_detached( |
|
440 |
/*=================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
441 |
btr_pcur_t* pcur) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
442 |
{
|
443 |
if (pcur->latch_mode == BTR_NO_LATCHES) { |
|
444 |
||
445 |
return(TRUE); |
|
446 |
} |
|
447 |
||
448 |
return(FALSE); |
|
449 |
}
|
|
450 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
451 |
/**************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
452 |
Sets the old_rec_buf field to NULL. */
|
453 |
UNIV_INLINE
|
|
454 |
void
|
|
455 |
btr_pcur_init( |
|
456 |
/*==========*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
457 |
btr_pcur_t* pcur) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
458 |
{
|
459 |
pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
460 |
pcur->old_rec_buf = NULL; |
|
461 |
pcur->old_rec = NULL; |
|
462 |
}
|
|
463 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
464 |
/**************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
465 |
Initializes and opens a persistent cursor to an index tree. It should be
|
466 |
closed with btr_pcur_close. */
|
|
467 |
UNIV_INLINE
|
|
468 |
void
|
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
469 |
btr_pcur_open_func( |
470 |
/*===============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
471 |
dict_index_t* index, /*!< in: index */ |
472 |
const dtuple_t* tuple, /*!< in: tuple on which search done */ |
|
473 |
ulint mode, /*!< in: PAGE_CUR_L, ...; |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
474 |
NOTE that if the search is made using a unique
|
475 |
prefix of a record, mode should be
|
|
476 |
PAGE_CUR_LE, not PAGE_CUR_GE, as the latter
|
|
477 |
may end up on the previous page from the
|
|
478 |
record! */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
479 |
ulint latch_mode,/*!< in: BTR_SEARCH_LEAF, ... */ |
480 |
btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */ |
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
481 |
const char* file, /*!< in: file name */ |
482 |
ulint line, /*!< in: line where called */ |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
483 |
mtr_t* mtr) /*!< in: mtr */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
484 |
{
|
485 |
btr_cur_t* btr_cursor; |
|
486 |
||
487 |
/* Initialize the cursor */ |
|
488 |
||
489 |
btr_pcur_init(cursor); |
|
490 |
||
491 |
cursor->latch_mode = latch_mode; |
|
492 |
cursor->search_mode = mode; |
|
493 |
||
494 |
/* Search with the tree cursor */ |
|
495 |
||
496 |
btr_cursor = btr_pcur_get_btr_cur(cursor); |
|
497 |
||
498 |
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, |
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
499 |
btr_cursor, 0, file, line, mtr); |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
500 |
cursor->pos_state = BTR_PCUR_IS_POSITIONED; |
501 |
||
502 |
cursor->trx_if_known = NULL; |
|
503 |
}
|
|
504 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
505 |
/**************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
506 |
Opens an persistent cursor to an index tree without initializing the
|
507 |
cursor. */
|
|
508 |
UNIV_INLINE
|
|
509 |
void
|
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
510 |
btr_pcur_open_with_no_init_func( |
511 |
/*============================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
512 |
dict_index_t* index, /*!< in: index */ |
513 |
const dtuple_t* tuple, /*!< in: tuple on which search done */ |
|
514 |
ulint mode, /*!< in: PAGE_CUR_L, ...; |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
515 |
NOTE that if the search is made using a unique
|
516 |
prefix of a record, mode should be
|
|
517 |
PAGE_CUR_LE, not PAGE_CUR_GE, as the latter
|
|
518 |
may end up on the previous page of the
|
|
519 |
record! */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
520 |
ulint latch_mode,/*!< in: BTR_SEARCH_LEAF, ...; |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
521 |
NOTE that if has_search_latch != 0 then
|
522 |
we maybe do not acquire a latch on the cursor
|
|
523 |
page, but assume that the caller uses his
|
|
524 |
btr search latch to protect the record! */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
525 |
btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */ |
526 |
ulint has_search_latch,/*!< in: latch mode the caller |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
527 |
currently has on btr_search_latch:
|
528 |
RW_S_LATCH, or 0 */
|
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
529 |
const char* file, /*!< in: file name */ |
530 |
ulint line, /*!< in: line where called */ |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
531 |
mtr_t* mtr) /*!< in: mtr */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
532 |
{
|
533 |
btr_cur_t* btr_cursor; |
|
534 |
||
535 |
cursor->latch_mode = latch_mode; |
|
536 |
cursor->search_mode = mode; |
|
537 |
||
538 |
/* Search with the tree cursor */ |
|
539 |
||
540 |
btr_cursor = btr_pcur_get_btr_cur(cursor); |
|
541 |
||
542 |
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, |
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
543 |
btr_cursor, has_search_latch, |
544 |
file, line, mtr); |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
545 |
cursor->pos_state = BTR_PCUR_IS_POSITIONED; |
546 |
||
547 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
548 |
||
549 |
cursor->trx_if_known = NULL; |
|
550 |
}
|
|
551 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
552 |
/*****************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
553 |
Opens a persistent cursor at either end of an index. */
|
554 |
UNIV_INLINE
|
|
555 |
void
|
|
556 |
btr_pcur_open_at_index_side( |
|
557 |
/*========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
558 |
ibool from_left, /*!< in: TRUE if open to the low end, |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
559 |
FALSE if to the high end */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
560 |
dict_index_t* index, /*!< in: index */ |
561 |
ulint latch_mode, /*!< in: latch mode */ |
|
562 |
btr_pcur_t* pcur, /*!< in: cursor */ |
|
563 |
ibool do_init, /*!< in: TRUE if should be initialized */ |
|
564 |
mtr_t* mtr) /*!< in: mtr */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
565 |
{
|
566 |
pcur->latch_mode = latch_mode; |
|
567 |
||
568 |
if (from_left) { |
|
569 |
pcur->search_mode = PAGE_CUR_G; |
|
570 |
} else { |
|
571 |
pcur->search_mode = PAGE_CUR_L; |
|
572 |
} |
|
573 |
||
574 |
if (do_init) { |
|
575 |
btr_pcur_init(pcur); |
|
576 |
} |
|
577 |
||
578 |
btr_cur_open_at_index_side(from_left, index, latch_mode, |
|
579 |
btr_pcur_get_btr_cur(pcur), mtr); |
|
580 |
pcur->pos_state = BTR_PCUR_IS_POSITIONED; |
|
581 |
||
582 |
pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
583 |
||
584 |
pcur->trx_if_known = NULL; |
|
585 |
}
|
|
586 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
587 |
/**********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
588 |
Positions a cursor at a randomly chosen position within a B-tree. */
|
589 |
UNIV_INLINE
|
|
590 |
void
|
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
591 |
btr_pcur_open_at_rnd_pos_func( |
592 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
593 |
dict_index_t* index, /*!< in: index */ |
594 |
ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ |
|
595 |
btr_pcur_t* cursor, /*!< in/out: B-tree pcur */ |
|
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
596 |
const char* file, /*!< in: file name */ |
597 |
ulint line, /*!< in: line where called */ |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
598 |
mtr_t* mtr) /*!< in: mtr */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
599 |
{
|
600 |
/* Initialize the cursor */ |
|
601 |
||
602 |
cursor->latch_mode = latch_mode; |
|
603 |
cursor->search_mode = PAGE_CUR_G; |
|
604 |
||
605 |
btr_pcur_init(cursor); |
|
606 |
||
1819.5.187
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6559 from MySQL InnoDB |
607 |
btr_cur_open_at_rnd_pos_func(index, latch_mode, |
608 |
btr_pcur_get_btr_cur(cursor), |
|
609 |
file, line, mtr); |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
610 |
cursor->pos_state = BTR_PCUR_IS_POSITIONED; |
611 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
612 |
||
613 |
cursor->trx_if_known = NULL; |
|
614 |
}
|
|
615 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
616 |
/**************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
617 |
Frees the possible memory heap of a persistent cursor and sets the latch
|
618 |
mode of the persistent cursor to BTR_NO_LATCHES. */
|
|
619 |
UNIV_INLINE
|
|
620 |
void
|
|
621 |
btr_pcur_close( |
|
622 |
/*===========*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
623 |
btr_pcur_t* cursor) /*!< in: persistent cursor */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
624 |
{
|
625 |
if (cursor->old_rec_buf != NULL) { |
|
626 |
||
627 |
mem_free(cursor->old_rec_buf); |
|
628 |
||
629 |
cursor->old_rec = NULL; |
|
630 |
cursor->old_rec_buf = NULL; |
|
631 |
} |
|
632 |
||
633 |
cursor->btr_cur.page_cur.rec = NULL; |
|
634 |
cursor->btr_cur.page_cur.block = NULL; |
|
635 |
cursor->old_rec = NULL; |
|
636 |
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; |
|
637 |
||
638 |
cursor->latch_mode = BTR_NO_LATCHES; |
|
639 |
cursor->pos_state = BTR_PCUR_NOT_POSITIONED; |
|
640 |
||
641 |
cursor->trx_if_known = NULL; |
|
642 |
}
|