~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/page0cur.h

Merge Stewart's dead code removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
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
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/********************************************************************//**
20
 
@file include/page0cur.h
21
 
The page cursor
22
 
 
23
 
Created 10/4/1994 Heikki Tuuri
24
 
*************************************************************************/
25
 
 
26
 
#ifndef page0cur_h
27
 
#define page0cur_h
28
 
 
29
 
#include "univ.i"
30
 
 
31
 
#include "buf0types.h"
32
 
#include "page0page.h"
33
 
#include "rem0rec.h"
34
 
#include "data0data.h"
35
 
#include "mtr0mtr.h"
36
 
 
37
 
 
38
 
#define PAGE_CUR_ADAPT
39
 
 
40
 
/* Page cursor search modes; the values must be in this order! */
41
 
 
42
 
#define PAGE_CUR_UNSUPP 0
43
 
#define PAGE_CUR_G      1
44
 
#define PAGE_CUR_GE     2
45
 
#define PAGE_CUR_L      3
46
 
#define PAGE_CUR_LE     4
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
50
 
                                 which extend it */
51
 
#ifdef UNIV_SEARCH_DEBUG
52
 
# define PAGE_CUR_DBG   6       /* As PAGE_CUR_LE, but skips search shortcut */
53
 
#endif /* UNIV_SEARCH_DEBUG */
54
 
 
55
 
#ifdef UNIV_DEBUG
56
 
/*********************************************************//**
57
 
Gets pointer to the page frame where the cursor is positioned.
58
 
@return page */
59
 
UNIV_INLINE
60
 
page_t*
61
 
page_cur_get_page(
62
 
/*==============*/
63
 
        page_cur_t*     cur);   /*!< in: page cursor */
64
 
/*********************************************************//**
65
 
Gets pointer to the buffer block where the cursor is positioned.
66
 
@return page */
67
 
UNIV_INLINE
68
 
buf_block_t*
69
 
page_cur_get_block(
70
 
/*===============*/
71
 
        page_cur_t*     cur);   /*!< in: page cursor */
72
 
/*********************************************************//**
73
 
Gets pointer to the page frame where the cursor is positioned.
74
 
@return page */
75
 
UNIV_INLINE
76
 
page_zip_des_t*
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.
82
 
@return record */
83
 
UNIV_INLINE
84
 
rec_t*
85
 
page_cur_get_rec(
86
 
/*=============*/
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
96
 
on the page. */
97
 
UNIV_INLINE
98
 
void
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
105
 
the page. */
106
 
UNIV_INLINE
107
 
void
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 */
115
 
UNIV_INLINE
116
 
ibool
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 */
123
 
UNIV_INLINE
124
 
ibool
125
 
page_cur_is_after_last(
126
 
/*===================*/
127
 
        const page_cur_t*       cur);   /*!< in: cursor */
128
 
/**********************************************************//**
129
 
Positions the cursor on the given record. */
130
 
UNIV_INLINE
131
 
void
132
 
page_cur_position(
133
 
/*==============*/
134
 
        const rec_t*            rec,    /*!< in: record on a page */
135
 
        const buf_block_t*      block,  /*!< in: buffer block containing
136
 
                                        the record */
137
 
        page_cur_t*             cur);   /*!< out: page cursor */
138
 
/**********************************************************//**
139
 
Invalidates a page cursor by setting the record pointer NULL. */
140
 
UNIV_INLINE
141
 
void
142
 
page_cur_invalidate(
143
 
/*================*/
144
 
        page_cur_t*     cur);   /*!< out: page cursor */
145
 
/**********************************************************//**
146
 
Moves the cursor to the next record on page. */
147
 
UNIV_INLINE
148
 
void
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. */
154
 
UNIV_INLINE
155
 
void
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 */
166
 
UNIV_INLINE
167
 
rec_t*
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 */
182
 
UNIV_INLINE
183
 
rec_t*
184
 
page_cur_rec_insert(
185
 
/*================*/
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 */
196
 
UNIV_INTERN
197
 
rec_t*
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 */
212
 
UNIV_INTERN
213
 
rec_t*
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. */
226
 
UNIV_INTERN
227
 
void
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. */
237
 
UNIV_INTERN
238
 
void
239
 
page_cur_delete_rec(
240
 
/*================*/
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 */
249
 
UNIV_INLINE
250
 
ulint
251
 
page_cur_search(
252
 
/*============*/
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
258
 
                                        PAGE_CUR_GE */
259
 
        page_cur_t*             cursor);/*!< out: page cursor */
260
 
/****************************************************************//**
261
 
Searches the right position for a page cursor. */
262
 
UNIV_INTERN
263
 
void
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
271
 
                                        PAGE_CUR_GE */
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. */
290
 
UNIV_INTERN
291
 
void
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 */
300
 
UNIV_INTERN
301
 
byte*
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 */
313
 
UNIV_INTERN
314
 
byte*
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 */
325
 
UNIV_INTERN
326
 
byte*
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 */
334
 
 
335
 
/** Index page cursor */
336
 
 
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 */
340
 
};
341
 
 
342
 
#ifndef UNIV_NONINL
343
 
#include "page0cur.ic"
344
 
#endif
345
 
 
346
 
#endif