~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-02-10 00:14:40 UTC
  • Revision ID: brian@tangent.org-20090210001440-qjg8eofh3h93064b
Adding Multi-threaded Scheduler into the system.

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