~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************
 
2
The page cursor
 
3
 
 
4
(c) 1994-1996 Innobase Oy
 
5
 
 
6
Created 10/4/1994 Heikki Tuuri
 
7
*************************************************************************/
 
8
 
 
9
#ifndef page0cur_h
 
10
#define page0cur_h
 
11
 
 
12
#include "univ.i"
 
13
 
 
14
#include "page0types.h"
 
15
#include "page0page.h"
 
16
#include "rem0rec.h"
 
17
#include "data0data.h"
 
18
#include "mtr0mtr.h"
 
19
 
 
20
 
 
21
#define PAGE_CUR_ADAPT
 
22
 
 
23
/* Page cursor search modes; the values must be in this order! */
 
24
 
 
25
#define PAGE_CUR_UNSUPP 0
 
26
#define PAGE_CUR_G      1
 
27
#define PAGE_CUR_GE     2
 
28
#define PAGE_CUR_L      3
 
29
#define PAGE_CUR_LE     4
 
30
/*#define PAGE_CUR_LE_OR_EXTENDS 5*/ /* This is a search mode used in
 
31
                                 "column LIKE 'abc%' ORDER BY column DESC";
 
32
                                 we have to find strings which are <= 'abc' or
 
33
                                 which extend it */
 
34
#ifdef UNIV_SEARCH_DEBUG
 
35
# define PAGE_CUR_DBG   6       /* As PAGE_CUR_LE, but skips search shortcut */
 
36
#endif /* UNIV_SEARCH_DEBUG */
 
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
 
 
44
/*************************************************************
 
45
Gets pointer to the page frame where the cursor is positioned. */
 
46
UNIV_INLINE
 
47
page_t*
 
48
page_cur_get_page(
 
49
/*==============*/
 
50
                                /* out: page */
 
51
        page_cur_t*     cur);   /* in: page cursor */
 
52
/*************************************************************
 
53
Gets the record where the cursor is positioned. */
 
54
UNIV_INLINE
 
55
rec_t*
 
56
page_cur_get_rec(
 
57
/*=============*/
 
58
                                /* out: record */
 
59
        page_cur_t*     cur);   /* in: page cursor */
 
60
/*************************************************************
 
61
Sets the cursor object to point before the first user record
 
62
on the page. */
 
63
UNIV_INLINE
 
64
void
 
65
page_cur_set_before_first(
 
66
/*======================*/
 
67
        page_t*         page,   /* in: index page */
 
68
        page_cur_t*     cur);   /* in: cursor */
 
69
/*************************************************************
 
70
Sets the cursor object to point after the last user record on
 
71
the page. */
 
72
UNIV_INLINE
 
73
void
 
74
page_cur_set_after_last(
 
75
/*====================*/
 
76
        page_t*         page,   /* in: index page */
 
77
        page_cur_t*     cur);   /* in: cursor */
 
78
/*************************************************************
 
79
Returns TRUE if the cursor is before first user record on page. */
 
80
UNIV_INLINE
 
81
ibool
 
82
page_cur_is_before_first(
 
83
/*=====================*/
 
84
                                        /* out: TRUE if at start */
 
85
        const page_cur_t*       cur);   /* in: cursor */
 
86
/*************************************************************
 
87
Returns TRUE if the cursor is after last user record. */
 
88
UNIV_INLINE
 
89
ibool
 
90
page_cur_is_after_last(
 
91
/*===================*/
 
92
                                        /* out: TRUE if at end */
 
93
        const page_cur_t*       cur);   /* in: cursor */
 
94
/**************************************************************
 
95
Positions the cursor on the given record. */
 
96
UNIV_INLINE
 
97
void
 
98
page_cur_position(
 
99
/*==============*/
 
100
        rec_t*          rec,    /* in: record on a page */
 
101
        page_cur_t*     cur);   /* in: page cursor */
 
102
/**************************************************************
 
103
Invalidates a page cursor by setting the record pointer NULL. */
 
104
UNIV_INLINE
 
105
void
 
106
page_cur_invalidate(
 
107
/*================*/
 
108
        page_cur_t*     cur);   /* in: page cursor */
 
109
/**************************************************************
 
110
Moves the cursor to the next record on page. */
 
111
UNIV_INLINE
 
112
void
 
113
page_cur_move_to_next(
 
114
/*==================*/
 
115
        page_cur_t*     cur);   /* in: cursor; must not be after last */
 
116
/**************************************************************
 
117
Moves the cursor to the previous record on page. */
 
118
UNIV_INLINE
 
119
void
 
120
page_cur_move_to_prev(
 
121
/*==================*/
 
122
        page_cur_t*     cur);   /* in: cursor; must not before first */
 
123
/***************************************************************
 
124
Inserts a record next to page cursor. Returns pointer to inserted record if
 
125
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
 
126
the same position. */
 
127
UNIV_INLINE
 
128
rec_t*
 
129
page_cur_tuple_insert(
 
130
/*==================*/
 
131
                                /* out: pointer to record if succeed, NULL
 
132
                                otherwise */
 
133
        page_cur_t*     cursor, /* in: a page cursor */
 
134
        dtuple_t*       tuple,  /* in: pointer to a data tuple */
 
135
        dict_index_t*   index,  /* in: record descriptor */
 
136
        mtr_t*          mtr);   /* in: mini-transaction handle */
 
137
/***************************************************************
 
138
Inserts a record next to page cursor. Returns pointer to inserted record if
 
139
succeed, i.e., enough space available, NULL otherwise. The cursor stays at
 
140
the same position. */
 
141
UNIV_INLINE
 
142
rec_t*
 
143
page_cur_rec_insert(
 
144
/*================*/
 
145
                                /* out: pointer to record if succeed, NULL
 
146
                                otherwise */
 
147
        page_cur_t*     cursor, /* in: a page cursor */
 
148
        rec_t*          rec,    /* in: record to insert */
 
149
        dict_index_t*   index,  /* in: record descriptor */
 
150
        ulint*          offsets,/* in: rec_get_offsets(rec, index) */
 
151
        mtr_t*          mtr);   /* in: mini-transaction handle */
 
152
/***************************************************************
 
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
 
 
158
rec_t*
 
159
page_cur_insert_rec_low(
 
160
/*====================*/
 
161
                                /* out: pointer to record if succeed, NULL
 
162
                                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 */
 
169
/*****************************************************************
 
170
Copies records from page to a newly created page, from a given record onward,
 
171
including that record. Infimum and supremum records are not copied. */
 
172
 
 
173
void
 
174
page_copy_rec_list_end_to_created_page(
 
175
/*===================================*/
 
176
        page_t*         new_page,       /* in: index page to copy to */
 
177
        page_t*         page,           /* in: index page */
 
178
        rec_t*          rec,            /* in: first record to copy */
 
179
        dict_index_t*   index,          /* in: record descriptor */
 
180
        mtr_t*          mtr);           /* in: mtr */
 
181
/***************************************************************
 
182
Deletes a record at the page cursor. The cursor is moved to the
 
183
next record after the deleted one. */
 
184
 
 
185
void
 
186
page_cur_delete_rec(
 
187
/*================*/
 
188
        page_cur_t*     cursor, /* in: a page cursor */
 
189
        dict_index_t*   index,  /* in: record descriptor */
 
190
        const ulint*    offsets,/* in: rec_get_offsets(cursor->rec, index) */
 
191
        mtr_t*          mtr);   /* in: mini-transaction handle */
 
192
/********************************************************************
 
193
Searches the right position for a page cursor. */
 
194
UNIV_INLINE
 
195
ulint
 
196
page_cur_search(
 
197
/*============*/
 
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 */
 
205
/********************************************************************
 
206
Searches the right position for a page cursor. */
 
207
 
 
208
void
 
209
page_cur_search_with_match(
 
210
/*=======================*/
 
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 */
 
229
/***************************************************************
 
230
Positions a page cursor on a randomly chosen user record on a page. If there
 
231
are no user records, sets the cursor on the infimum record. */
 
232
 
 
233
void
 
234
page_cur_open_on_rnd_user_rec(
 
235
/*==========================*/
 
236
        page_t*         page,   /* in: page */
 
237
        page_cur_t*     cursor);/* in/out: page cursor */
 
238
/***************************************************************
 
239
Parses a log record of a record insert on a page. */
 
240
 
 
241
byte*
 
242
page_cur_parse_insert_rec(
 
243
/*======================*/
 
244
                                /* out: end of log record or NULL */
 
245
        ibool           is_short,/* in: TRUE if short inserts */
 
246
        byte*           ptr,    /* in: buffer */
 
247
        byte*           end_ptr,/* in: buffer end */
 
248
        dict_index_t*   index,  /* in: record descriptor */
 
249
        page_t*         page,   /* in: page or NULL */
 
250
        mtr_t*          mtr);   /* in: mtr or NULL */
 
251
/**************************************************************
 
252
Parses a log record of copying a record list end to a new created page. */
 
253
 
 
254
byte*
 
255
page_parse_copy_rec_list_to_created_page(
 
256
/*=====================================*/
 
257
                                /* out: end of log record or NULL */
 
258
        byte*           ptr,    /* in: buffer */
 
259
        byte*           end_ptr,/* in: buffer end */
 
260
        dict_index_t*   index,  /* in: record descriptor */
 
261
        page_t*         page,   /* in: page or NULL */
 
262
        mtr_t*          mtr);   /* in: mtr or NULL */
 
263
/***************************************************************
 
264
Parses log record of a record delete on a page. */
 
265
 
 
266
byte*
 
267
page_cur_parse_delete_rec(
 
268
/*======================*/
 
269
                                /* out: pointer to record end or NULL */
 
270
        byte*           ptr,    /* in: buffer */
 
271
        byte*           end_ptr,/* in: buffer end */
 
272
        dict_index_t*   index,  /* in: record descriptor */
 
273
        page_t*         page,   /* in: page or NULL */
 
274
        mtr_t*          mtr);   /* in: mtr or NULL */
 
275
 
 
276
/* Index page cursor */
 
277
 
 
278
struct page_cur_struct{
 
279
        byte*   rec;    /* pointer to a record on page */
 
280
};
 
281
 
 
282
#ifndef UNIV_NONINL
 
283
#include "page0cur.ic"
 
284
#endif
 
285
 
 
286
#endif