~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
#include "univ.i"
13
13
 
14
 
#include "page0types.h"
 
14
#include "buf0types.h"
15
15
#include "page0page.h"
16
16
#include "rem0rec.h"
17
17
#include "data0data.h"
35
35
# define PAGE_CUR_DBG   6       /* As PAGE_CUR_LE, but skips search shortcut */
36
36
#endif /* UNIV_SEARCH_DEBUG */
37
37
 
38
 
#ifdef PAGE_CUR_ADAPT
39
 
# ifdef UNIV_SEARCH_PERF_STAT
40
 
extern ulint    page_cur_short_succ;
41
 
# endif /* UNIV_SEARCH_PERF_STAT */
42
 
#endif /* PAGE_CUR_ADAPT */
43
 
 
 
38
#ifdef UNIV_DEBUG
44
39
/*************************************************************
45
40
Gets pointer to the page frame where the cursor is positioned. */
46
41
UNIV_INLINE
50
45
                                /* out: page */
51
46
        page_cur_t*     cur);   /* in: page cursor */
52
47
/*************************************************************
 
48
Gets pointer to the buffer block where the cursor is positioned. */
 
49
UNIV_INLINE
 
50
buf_block_t*
 
51
page_cur_get_block(
 
52
/*===============*/
 
53
                                /* out: page */
 
54
        page_cur_t*     cur);   /* in: page cursor */
 
55
/*************************************************************
 
56
Gets pointer to the page frame where the cursor is positioned. */
 
57
UNIV_INLINE
 
58
page_zip_des_t*
 
59
page_cur_get_page_zip(
 
60
/*==================*/
 
61
                                /* out: page */
 
62
        page_cur_t*     cur);   /* in: page cursor */
 
63
/*************************************************************
53
64
Gets the record where the cursor is positioned. */
54
65
UNIV_INLINE
55
66
rec_t*
57
68
/*=============*/
58
69
                                /* out: record */
59
70
        page_cur_t*     cur);   /* in: page cursor */
 
71
#else /* UNIV_DEBUG */
 
72
# define page_cur_get_page(cur)         page_align((cur)->rec)
 
73
# define page_cur_get_block(cur)        (cur)->block
 
74
# define page_cur_get_page_zip(cur)     buf_block_get_page_zip((cur)->block)
 
75
# define page_cur_get_rec(cur)          (cur)->rec
 
76
#endif /* UNIV_DEBUG */
60
77
/*************************************************************
61
78
Sets the cursor object to point before the first user record
62
79
on the page. */
64
81
void
65
82
page_cur_set_before_first(
66
83
/*======================*/
67
 
        page_t*         page,   /* in: index page */
68
 
        page_cur_t*     cur);   /* in: cursor */
 
84
        const buf_block_t*      block,  /* in: index page */
 
85
        page_cur_t*             cur);   /* in: cursor */
69
86
/*************************************************************
70
87
Sets the cursor object to point after the last user record on
71
88
the page. */
73
90
void
74
91
page_cur_set_after_last(
75
92
/*====================*/
76
 
        page_t*         page,   /* in: index page */
77
 
        page_cur_t*     cur);   /* in: cursor */
 
93
        const buf_block_t*      block,  /* in: index page */
 
94
        page_cur_t*             cur);   /* in: cursor */
78
95
/*************************************************************
79
96
Returns TRUE if the cursor is before first user record on page. */
80
97
UNIV_INLINE
97
114
void
98
115
page_cur_position(
99
116
/*==============*/
100
 
        rec_t*          rec,    /* in: record on a page */
101
 
        page_cur_t*     cur);   /* in: page cursor */
 
117
        const rec_t*            rec,    /* in: record on a page */
 
118
        const buf_block_t*      block,  /* in: buffer block containing
 
119
                                        the record */
 
120
        page_cur_t*             cur);   /* out: page cursor */
102
121
/**************************************************************
103
122
Invalidates a page cursor by setting the record pointer NULL. */
104
123
UNIV_INLINE
105
124
void
106
125
page_cur_invalidate(
107
126
/*================*/
108
 
        page_cur_t*     cur);   /* in: page cursor */
 
127
        page_cur_t*     cur);   /* out: page cursor */
109
128
/**************************************************************
110
129
Moves the cursor to the next record on page. */
111
130
UNIV_INLINE
112
131
void
113
132
page_cur_move_to_next(
114
133
/*==================*/
115
 
        page_cur_t*     cur);   /* in: cursor; must not be after last */
 
134
        page_cur_t*     cur);   /* in/out: cursor; must not be after last */
116
135
/**************************************************************
117
136
Moves the cursor to the previous record on page. */
118
137
UNIV_INLINE
119
138
void
120
139
page_cur_move_to_prev(
121
140
/*==================*/
122
 
        page_cur_t*     cur);   /* in: cursor; must not before first */
 
141
        page_cur_t*     cur);   /* in/out: cursor; not before first */
123
142
/***************************************************************
124
143
Inserts a record next to page cursor. Returns pointer to inserted record if
125
144
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
126
 
the same position. */
 
145
the same logical position, but the physical position may change if it is
 
146
pointing to a compressed page that was reorganized. */
127
147
UNIV_INLINE
128
148
rec_t*
129
149
page_cur_tuple_insert(
130
150
/*==================*/
131
151
                                /* out: pointer to record if succeed, NULL
132
152
                                otherwise */
133
 
        page_cur_t*     cursor, /* in: a page cursor */
134
 
        dtuple_t*       tuple,  /* in: pointer to a data tuple */
 
153
        page_cur_t*     cursor, /* in/out: a page cursor */
 
154
        const dtuple_t* tuple,  /* in: pointer to a data tuple */
135
155
        dict_index_t*   index,  /* in: record descriptor */
136
 
        mtr_t*          mtr);   /* in: mini-transaction handle */
 
156
        ulint           n_ext,  /* in: number of externally stored columns */
 
157
        mtr_t*          mtr);   /* in: mini-transaction handle, or NULL */
137
158
/***************************************************************
138
159
Inserts a record next to page cursor. Returns pointer to inserted record if
139
160
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
140
 
the same position. */
 
161
the same logical position, but the physical position may change if it is
 
162
pointing to a compressed page that was reorganized. */
141
163
UNIV_INLINE
142
164
rec_t*
143
165
page_cur_rec_insert(
144
166
/*================*/
145
167
                                /* out: pointer to record if succeed, NULL
146
168
                                otherwise */
147
 
        page_cur_t*     cursor, /* in: a page cursor */
148
 
        rec_t*          rec,    /* in: record to insert */
 
169
        page_cur_t*     cursor, /* in/out: a page cursor */
 
170
        const rec_t*    rec,    /* in: record to insert */
149
171
        dict_index_t*   index,  /* in: record descriptor */
150
 
        ulint*          offsets,/* in: rec_get_offsets(rec, index) */
151
 
        mtr_t*          mtr);   /* in: mini-transaction handle */
 
172
        ulint*          offsets,/* in/out: rec_get_offsets(rec, index) */
 
173
        mtr_t*          mtr);   /* in: mini-transaction handle, or NULL */
152
174
/***************************************************************
153
 
Inserts a record next to page cursor. Returns pointer to inserted record if
154
 
succeed, i.e., enough space available, NULL otherwise. The record to be
155
 
inserted can be in a data tuple or as a physical record. The other parameter
156
 
must then be NULL. The cursor stays at the same position. */
157
 
 
 
175
Inserts a record next to page cursor on an uncompressed page.
 
176
Returns pointer to inserted record if succeed, i.e., enough
 
177
space available, NULL otherwise. The cursor stays at the same position. */
 
178
UNIV_INTERN
158
179
rec_t*
159
180
page_cur_insert_rec_low(
160
181
/*====================*/
161
182
                                /* out: pointer to record if succeed, NULL
162
183
                                otherwise */
163
 
        page_cur_t*     cursor, /* in: a page cursor */
164
 
        dtuple_t*       tuple,  /* in: pointer to a data tuple or NULL */
165
 
        dict_index_t*   index,  /* in: record descriptor */
166
 
        rec_t*          rec,    /* in: pointer to a physical record or NULL */
167
 
        ulint*          offsets,/* in: rec_get_offsets(rec, index) or NULL */
168
 
        mtr_t*          mtr);   /* in: mini-transaction handle */
 
184
        rec_t*          current_rec,/* in: pointer to current record after
 
185
                                which the new record is inserted */
 
186
        dict_index_t*   index,  /* in: record descriptor */
 
187
        const rec_t*    rec,    /* in: pointer to a physical record */
 
188
        ulint*          offsets,/* in/out: rec_get_offsets(rec, index) */
 
189
        mtr_t*          mtr);   /* in: mini-transaction handle, or NULL */
 
190
/***************************************************************
 
191
Inserts a record next to page cursor on a compressed and uncompressed
 
192
page. Returns pointer to inserted record if succeed, i.e.,
 
193
enough space available, NULL otherwise.
 
194
The cursor stays at the same position. */
 
195
UNIV_INTERN
 
196
rec_t*
 
197
page_cur_insert_rec_zip(
 
198
/*====================*/
 
199
                                /* out: pointer to record if succeed, NULL
 
200
                                otherwise */
 
201
        rec_t**         current_rec,/* in/out: pointer to current record after
 
202
                                which the new record is inserted */
 
203
        buf_block_t*    block,  /* in: buffer block of *current_rec */
 
204
        dict_index_t*   index,  /* in: record descriptor */
 
205
        const rec_t*    rec,    /* in: pointer to a physical record */
 
206
        ulint*          offsets,/* in/out: rec_get_offsets(rec, index) */
 
207
        mtr_t*          mtr);   /* in: mini-transaction handle, or NULL */
169
208
/*****************************************************************
170
209
Copies records from page to a newly created page, from a given record onward,
171
210
including that record. Infimum and supremum records are not copied. */
172
 
 
 
211
UNIV_INTERN
173
212
void
174
213
page_copy_rec_list_end_to_created_page(
175
214
/*===================================*/
176
 
        page_t*         new_page,       /* in: index page to copy to */
177
 
        page_t*         page,           /* in: index page */
 
215
        page_t*         new_page,       /* in/out: index page to copy to */
178
216
        rec_t*          rec,            /* in: first record to copy */
179
217
        dict_index_t*   index,          /* in: record descriptor */
180
218
        mtr_t*          mtr);           /* in: mtr */
181
219
/***************************************************************
182
220
Deletes a record at the page cursor. The cursor is moved to the
183
221
next record after the deleted one. */
184
 
 
 
222
UNIV_INTERN
185
223
void
186
224
page_cur_delete_rec(
187
225
/*================*/
188
 
        page_cur_t*     cursor, /* in: a page cursor */
 
226
        page_cur_t*     cursor, /* in/out: a page cursor */
189
227
        dict_index_t*   index,  /* in: record descriptor */
190
228
        const ulint*    offsets,/* in: rec_get_offsets(cursor->rec, index) */
191
229
        mtr_t*          mtr);   /* in: mini-transaction handle */
195
233
ulint
196
234
page_cur_search(
197
235
/*============*/
198
 
                                /* out: number of matched fields on the left */
199
 
        page_t*         page,   /* in: index page */
200
 
        dict_index_t*   index,  /* in: record descriptor */
201
 
        dtuple_t*       tuple,  /* in: data tuple */
202
 
        ulint           mode,   /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
203
 
                                or PAGE_CUR_GE */
204
 
        page_cur_t*     cursor);/* out: page cursor */
 
236
                                        /* out: number of matched
 
237
                                        fields on the left */
 
238
        const buf_block_t*      block,  /* in: buffer block */
 
239
        const dict_index_t*     index,  /* in: record descriptor */
 
240
        const dtuple_t*         tuple,  /* in: data tuple */
 
241
        ulint                   mode,   /* in: PAGE_CUR_L,
 
242
                                        PAGE_CUR_LE, PAGE_CUR_G, or
 
243
                                        PAGE_CUR_GE */
 
244
        page_cur_t*             cursor);/* out: page cursor */
205
245
/********************************************************************
206
246
Searches the right position for a page cursor. */
207
 
 
 
247
UNIV_INTERN
208
248
void
209
249
page_cur_search_with_match(
210
250
/*=======================*/
211
 
        page_t*         page,   /* in: index page */
212
 
        dict_index_t*   index,  /* in: record descriptor */
213
 
        dtuple_t*       tuple,  /* in: data tuple */
214
 
        ulint           mode,   /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
215
 
                                or PAGE_CUR_GE */
216
 
        ulint*          iup_matched_fields,
217
 
                                /* in/out: already matched fields in upper
218
 
                                limit record */
219
 
        ulint*          iup_matched_bytes,
220
 
                                /* in/out: already matched bytes in a field
221
 
                                not yet completely matched */
222
 
        ulint*          ilow_matched_fields,
223
 
                                /* in/out: already matched fields in lower
224
 
                                limit record */
225
 
        ulint*          ilow_matched_bytes,
226
 
                                /* in/out: already matched bytes in a field
227
 
                                not yet completely matched */
228
 
        page_cur_t*     cursor); /* out: page cursor */
 
251
        const buf_block_t*      block,  /* in: buffer block */
 
252
        const dict_index_t*     index,  /* in: record descriptor */
 
253
        const dtuple_t*         tuple,  /* in: data tuple */
 
254
        ulint                   mode,   /* in: PAGE_CUR_L,
 
255
                                        PAGE_CUR_LE, PAGE_CUR_G, or
 
256
                                        PAGE_CUR_GE */
 
257
        ulint*                  iup_matched_fields,
 
258
                                        /* in/out: already matched
 
259
                                        fields in upper limit record */
 
260
        ulint*                  iup_matched_bytes,
 
261
                                        /* in/out: already matched
 
262
                                        bytes in a field not yet
 
263
                                        completely matched */
 
264
        ulint*                  ilow_matched_fields,
 
265
                                        /* in/out: already matched
 
266
                                        fields in lower limit record */
 
267
        ulint*                  ilow_matched_bytes,
 
268
                                        /* in/out: already matched
 
269
                                        bytes in a field not yet
 
270
                                        completely matched */
 
271
        page_cur_t*             cursor);/* out: page cursor */
229
272
/***************************************************************
230
273
Positions a page cursor on a randomly chosen user record on a page. If there
231
274
are no user records, sets the cursor on the infimum record. */
232
 
 
 
275
UNIV_INTERN
233
276
void
234
277
page_cur_open_on_rnd_user_rec(
235
278
/*==========================*/
236
 
        page_t*         page,   /* in: page */
237
 
        page_cur_t*     cursor);/* in/out: page cursor */
 
279
        buf_block_t*    block,  /* in: page */
 
280
        page_cur_t*     cursor);/* out: page cursor */
238
281
/***************************************************************
239
282
Parses a log record of a record insert on a page. */
240
 
 
 
283
UNIV_INTERN
241
284
byte*
242
285
page_cur_parse_insert_rec(
243
286
/*======================*/
245
288
        ibool           is_short,/* in: TRUE if short inserts */
246
289
        byte*           ptr,    /* in: buffer */
247
290
        byte*           end_ptr,/* in: buffer end */
 
291
        buf_block_t*    block,  /* in: page or NULL */
248
292
        dict_index_t*   index,  /* in: record descriptor */
249
 
        page_t*         page,   /* in: page or NULL */
250
293
        mtr_t*          mtr);   /* in: mtr or NULL */
251
294
/**************************************************************
252
295
Parses a log record of copying a record list end to a new created page. */
253
 
 
 
296
UNIV_INTERN
254
297
byte*
255
298
page_parse_copy_rec_list_to_created_page(
256
299
/*=====================================*/
257
300
                                /* out: end of log record or NULL */
258
301
        byte*           ptr,    /* in: buffer */
259
302
        byte*           end_ptr,/* in: buffer end */
 
303
        buf_block_t*    block,  /* in: page or NULL */
260
304
        dict_index_t*   index,  /* in: record descriptor */
261
 
        page_t*         page,   /* in: page or NULL */
262
305
        mtr_t*          mtr);   /* in: mtr or NULL */
263
306
/***************************************************************
264
307
Parses log record of a record delete on a page. */
265
 
 
 
308
UNIV_INTERN
266
309
byte*
267
310
page_cur_parse_delete_rec(
268
311
/*======================*/
269
312
                                /* out: pointer to record end or NULL */
270
313
        byte*           ptr,    /* in: buffer */
271
314
        byte*           end_ptr,/* in: buffer end */
 
315
        buf_block_t*    block,  /* in: page or NULL */
272
316
        dict_index_t*   index,  /* in: record descriptor */
273
 
        page_t*         page,   /* in: page or NULL */
274
317
        mtr_t*          mtr);   /* in: mtr or NULL */
275
318
 
276
319
/* Index page cursor */
277
320
 
278
321
struct page_cur_struct{
279
 
        byte*   rec;    /* pointer to a record on page */
 
322
        byte*           rec;    /* pointer to a record on page */
 
323
        buf_block_t*    block;  /* pointer to the block containing rec */
280
324
};
281
325
 
282
326
#ifndef UNIV_NONINL