1
/*****************************************************************************
3
Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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
17
*****************************************************************************/
19
/********************************************************************//**
20
@file include/page0cur.h
23
Created 10/4/1994 Heikki Tuuri
24
*************************************************************************/
31
#include "buf0types.h"
32
#include "page0page.h"
34
#include "data0data.h"
38
#define PAGE_CUR_ADAPT
40
/* Page cursor search modes; the values must be in this order! */
42
#define PAGE_CUR_UNSUPP 0
47
/*#define PAGE_CUR_LE_OR_EXTENDS 5*/ /* This is a search mode used in
48
"column LIKE 'abc%' ORDER BY column DESC";
49
we have to find strings which are <= 'abc' or
51
#ifdef UNIV_SEARCH_DEBUG
52
# define PAGE_CUR_DBG 6 /* As PAGE_CUR_LE, but skips search shortcut */
53
#endif /* UNIV_SEARCH_DEBUG */
56
/*********************************************************//**
57
Gets pointer to the page frame where the cursor is positioned.
63
page_cur_t* cur); /*!< in: page cursor */
64
/*********************************************************//**
65
Gets pointer to the buffer block where the cursor is positioned.
71
page_cur_t* cur); /*!< in: page cursor */
72
/*********************************************************//**
73
Gets pointer to the page frame where the cursor is positioned.
77
page_cur_get_page_zip(
78
/*==================*/
79
page_cur_t* cur); /*!< in: page cursor */
80
/*********************************************************//**
81
Gets the record where the cursor is positioned.
87
page_cur_t* cur); /*!< in: page cursor */
88
#else /* UNIV_DEBUG */
89
# define page_cur_get_page(cur) page_align((cur)->rec)
90
# define page_cur_get_block(cur) (cur)->block
91
# define page_cur_get_page_zip(cur) buf_block_get_page_zip((cur)->block)
92
# define page_cur_get_rec(cur) (cur)->rec
93
#endif /* UNIV_DEBUG */
94
/*********************************************************//**
95
Sets the cursor object to point before the first user record
99
page_cur_set_before_first(
100
/*======================*/
101
const buf_block_t* block, /*!< in: index page */
102
page_cur_t* cur); /*!< in: cursor */
103
/*********************************************************//**
104
Sets the cursor object to point after the last user record on
108
page_cur_set_after_last(
109
/*====================*/
110
const buf_block_t* block, /*!< in: index page */
111
page_cur_t* cur); /*!< in: cursor */
112
/*********************************************************//**
113
Returns TRUE if the cursor is before first user record on page.
114
@return TRUE if at start */
117
page_cur_is_before_first(
118
/*=====================*/
119
const page_cur_t* cur); /*!< in: cursor */
120
/*********************************************************//**
121
Returns TRUE if the cursor is after last user record.
122
@return TRUE if at end */
125
page_cur_is_after_last(
126
/*===================*/
127
const page_cur_t* cur); /*!< in: cursor */
128
/**********************************************************//**
129
Positions the cursor on the given record. */
134
const rec_t* rec, /*!< in: record on a page */
135
const buf_block_t* block, /*!< in: buffer block containing
137
page_cur_t* cur); /*!< out: page cursor */
138
/**********************************************************//**
139
Invalidates a page cursor by setting the record pointer NULL. */
144
page_cur_t* cur); /*!< out: page cursor */
145
/**********************************************************//**
146
Moves the cursor to the next record on page. */
149
page_cur_move_to_next(
150
/*==================*/
151
page_cur_t* cur); /*!< in/out: cursor; must not be after last */
152
/**********************************************************//**
153
Moves the cursor to the previous record on page. */
156
page_cur_move_to_prev(
157
/*==================*/
158
page_cur_t* cur); /*!< in/out: cursor; not before first */
159
#ifndef UNIV_HOTBACKUP
160
/***********************************************************//**
161
Inserts a record next to page cursor. Returns pointer to inserted record if
162
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
163
the same logical position, but the physical position may change if it is
164
pointing to a compressed page that was reorganized.
165
@return pointer to record if succeed, NULL otherwise */
168
page_cur_tuple_insert(
169
/*==================*/
170
page_cur_t* cursor, /*!< in/out: a page cursor */
171
const dtuple_t* tuple, /*!< in: pointer to a data tuple */
172
dict_index_t* index, /*!< in: record descriptor */
173
ulint n_ext, /*!< in: number of externally stored columns */
174
mtr_t* mtr); /*!< in: mini-transaction handle, or NULL */
175
#endif /* !UNIV_HOTBACKUP */
176
/***********************************************************//**
177
Inserts a record next to page cursor. Returns pointer to inserted record if
178
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
179
the same logical position, but the physical position may change if it is
180
pointing to a compressed page that was reorganized.
181
@return pointer to record if succeed, NULL otherwise */
186
page_cur_t* cursor, /*!< in/out: a page cursor */
187
const rec_t* rec, /*!< in: record to insert */
188
dict_index_t* index, /*!< in: record descriptor */
189
ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */
190
mtr_t* mtr); /*!< in: mini-transaction handle, or NULL */
191
/***********************************************************//**
192
Inserts a record next to page cursor on an uncompressed page.
193
Returns pointer to inserted record if succeed, i.e., enough
194
space available, NULL otherwise. The cursor stays at the same position.
195
@return pointer to record if succeed, NULL otherwise */
198
page_cur_insert_rec_low(
199
/*====================*/
200
rec_t* current_rec,/*!< in: pointer to current record after
201
which the new record is inserted */
202
dict_index_t* index, /*!< in: record descriptor */
203
const rec_t* rec, /*!< in: pointer to a physical record */
204
ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */
205
mtr_t* mtr); /*!< in: mini-transaction handle, or NULL */
206
/***********************************************************//**
207
Inserts a record next to page cursor on a compressed and uncompressed
208
page. Returns pointer to inserted record if succeed, i.e.,
209
enough space available, NULL otherwise.
210
The cursor stays at the same position.
211
@return pointer to record if succeed, NULL otherwise */
214
page_cur_insert_rec_zip(
215
/*====================*/
216
rec_t** current_rec,/*!< in/out: pointer to current record after
217
which the new record is inserted */
218
buf_block_t* block, /*!< in: buffer block of *current_rec */
219
dict_index_t* index, /*!< in: record descriptor */
220
const rec_t* rec, /*!< in: pointer to a physical record */
221
ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */
222
mtr_t* mtr); /*!< in: mini-transaction handle, or NULL */
223
/*************************************************************//**
224
Copies records from page to a newly created page, from a given record onward,
225
including that record. Infimum and supremum records are not copied. */
228
page_copy_rec_list_end_to_created_page(
229
/*===================================*/
230
page_t* new_page, /*!< in/out: index page to copy to */
231
rec_t* rec, /*!< in: first record to copy */
232
dict_index_t* index, /*!< in: record descriptor */
233
mtr_t* mtr); /*!< in: mtr */
234
/***********************************************************//**
235
Deletes a record at the page cursor. The cursor is moved to the
236
next record after the deleted one. */
241
page_cur_t* cursor, /*!< in/out: a page cursor */
242
dict_index_t* index, /*!< in: record descriptor */
243
const ulint* offsets,/*!< in: rec_get_offsets(cursor->rec, index) */
244
mtr_t* mtr); /*!< in: mini-transaction handle */
245
#ifndef UNIV_HOTBACKUP
246
/****************************************************************//**
247
Searches the right position for a page cursor.
248
@return number of matched fields on the left */
253
const buf_block_t* block, /*!< in: buffer block */
254
const dict_index_t* index, /*!< in: record descriptor */
255
const dtuple_t* tuple, /*!< in: data tuple */
256
ulint mode, /*!< in: PAGE_CUR_L,
257
PAGE_CUR_LE, PAGE_CUR_G, or
259
page_cur_t* cursor);/*!< out: page cursor */
260
/****************************************************************//**
261
Searches the right position for a page cursor. */
264
page_cur_search_with_match(
265
/*=======================*/
266
const buf_block_t* block, /*!< in: buffer block */
267
const dict_index_t* index, /*!< in: record descriptor */
268
const dtuple_t* tuple, /*!< in: data tuple */
269
ulint mode, /*!< in: PAGE_CUR_L,
270
PAGE_CUR_LE, PAGE_CUR_G, or
272
ulint* iup_matched_fields,
273
/*!< in/out: already matched
274
fields in upper limit record */
275
ulint* iup_matched_bytes,
276
/*!< in/out: already matched
277
bytes in a field not yet
278
completely matched */
279
ulint* ilow_matched_fields,
280
/*!< in/out: already matched
281
fields in lower limit record */
282
ulint* ilow_matched_bytes,
283
/*!< in/out: already matched
284
bytes in a field not yet
285
completely matched */
286
page_cur_t* cursor);/*!< out: page cursor */
287
/***********************************************************//**
288
Positions a page cursor on a randomly chosen user record on a page. If there
289
are no user records, sets the cursor on the infimum record. */
292
page_cur_open_on_rnd_user_rec(
293
/*==========================*/
294
buf_block_t* block, /*!< in: page */
295
page_cur_t* cursor);/*!< out: page cursor */
296
#endif /* !UNIV_HOTBACKUP */
297
/***********************************************************//**
298
Parses a log record of a record insert on a page.
299
@return end of log record or NULL */
302
page_cur_parse_insert_rec(
303
/*======================*/
304
ibool is_short,/*!< in: TRUE if short inserts */
305
byte* ptr, /*!< in: buffer */
306
byte* end_ptr,/*!< in: buffer end */
307
buf_block_t* block, /*!< in: page or NULL */
308
dict_index_t* index, /*!< in: record descriptor */
309
mtr_t* mtr); /*!< in: mtr or NULL */
310
/**********************************************************//**
311
Parses a log record of copying a record list end to a new created page.
312
@return end of log record or NULL */
315
page_parse_copy_rec_list_to_created_page(
316
/*=====================================*/
317
byte* ptr, /*!< in: buffer */
318
byte* end_ptr,/*!< in: buffer end */
319
buf_block_t* block, /*!< in: page or NULL */
320
dict_index_t* index, /*!< in: record descriptor */
321
mtr_t* mtr); /*!< in: mtr or NULL */
322
/***********************************************************//**
323
Parses log record of a record delete on a page.
324
@return pointer to record end or NULL */
327
page_cur_parse_delete_rec(
328
/*======================*/
329
byte* ptr, /*!< in: buffer */
330
byte* end_ptr,/*!< in: buffer end */
331
buf_block_t* block, /*!< in: page or NULL */
332
dict_index_t* index, /*!< in: record descriptor */
333
mtr_t* mtr); /*!< in: mtr or NULL */
335
/** Index page cursor */
337
struct page_cur_struct{
338
byte* rec; /*!< pointer to a record on page */
339
buf_block_t* block; /*!< pointer to the block containing rec */
343
#include "page0cur.ic"