~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-12-08 01:15:27 UTC
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: monty@inaugust.com-20081208011527-lq9m47jsmiiqn999
Replaced my hacked up m4/ac_system_extensions.m4 with the one from gnulib.

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., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/btr0cur.h
 
1
/******************************************************
21
2
The index tree cursor
22
3
 
 
4
(c) 1994-1996 Innobase Oy
 
5
 
23
6
Created 10/16/1994 Heikki Tuuri
24
7
*******************************************************/
25
8
 
28
11
 
29
12
#include "univ.i"
30
13
#include "dict0dict.h"
 
14
#include "data0data.h"
31
15
#include "page0cur.h"
32
16
#include "btr0types.h"
 
17
#include "que0types.h"
 
18
#include "row0types.h"
 
19
#include "ha0ha.h"
33
20
 
34
21
/* Mode flags for btr_cur operations; these can be ORed */
35
22
#define BTR_NO_UNDO_LOG_FLAG    1       /* do no undo logging */
37
24
#define BTR_KEEP_SYS_FLAG       4       /* sys fields will be found from the
38
25
                                        update vector or inserted entry */
39
26
 
40
 
#ifndef UNIV_HOTBACKUP
41
 
#include "que0types.h"
42
 
#include "row0types.h"
43
 
#include "ha0ha.h"
44
 
 
45
27
#define BTR_CUR_ADAPT
46
28
#define BTR_CUR_HASH_ADAPT
47
29
 
48
30
#ifdef UNIV_DEBUG
49
 
/*********************************************************//**
50
 
Returns the page cursor component of a tree cursor.
51
 
@return pointer to page cursor component */
 
31
/*************************************************************
 
32
Returns the page cursor component of a tree cursor. */
52
33
UNIV_INLINE
53
34
page_cur_t*
54
35
btr_cur_get_page_cur(
55
36
/*=================*/
56
 
        const btr_cur_t*        cursor);/*!< in: tree cursor */
 
37
                                        /* out: pointer to page cursor
 
38
                                        component */
 
39
        const btr_cur_t*        cursor);/* in: tree cursor */
57
40
#else /* UNIV_DEBUG */
58
41
# define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
59
42
#endif /* UNIV_DEBUG */
60
 
/*********************************************************//**
61
 
Returns the buffer block on which the tree cursor is positioned.
62
 
@return pointer to buffer block */
 
43
/*************************************************************
 
44
Returns the buffer block on which the tree cursor is positioned. */
63
45
UNIV_INLINE
64
46
buf_block_t*
65
47
btr_cur_get_block(
66
48
/*==============*/
67
 
        btr_cur_t*      cursor);/*!< in: tree cursor */
68
 
/*********************************************************//**
69
 
Returns the record pointer of a tree cursor.
70
 
@return pointer to record */
 
49
                                /* out: pointer to buffer block */
 
50
        btr_cur_t*      cursor);/* in: tree cursor */
 
51
/*************************************************************
 
52
Returns the record pointer of a tree cursor. */
71
53
UNIV_INLINE
72
54
rec_t*
73
55
btr_cur_get_rec(
74
56
/*============*/
75
 
        btr_cur_t*      cursor);/*!< in: tree cursor */
76
 
/*********************************************************//**
77
 
Returns the compressed page on which the tree cursor is positioned.
78
 
@return pointer to compressed page, or NULL if the page is not compressed */
 
57
                                /* out: pointer to record */
 
58
        btr_cur_t*      cursor);/* in: tree cursor */
 
59
/*************************************************************
 
60
Returns the compressed page on which the tree cursor is positioned. */
79
61
UNIV_INLINE
80
62
page_zip_des_t*
81
63
btr_cur_get_page_zip(
82
64
/*=================*/
83
 
        btr_cur_t*      cursor);/*!< in: tree cursor */
84
 
/*********************************************************//**
 
65
                                /* out: pointer to compressed page,
 
66
                                or NULL if the page is not compressed */
 
67
        btr_cur_t*      cursor);/* in: tree cursor */
 
68
/*************************************************************
85
69
Invalidates a tree cursor by setting record pointer to NULL. */
86
70
UNIV_INLINE
87
71
void
88
72
btr_cur_invalidate(
89
73
/*===============*/
90
 
        btr_cur_t*      cursor);/*!< in: tree cursor */
91
 
/*********************************************************//**
92
 
Returns the page of a tree cursor.
93
 
@return pointer to page */
 
74
        btr_cur_t*      cursor);/* in: tree cursor */
 
75
/*************************************************************
 
76
Returns the page of a tree cursor. */
94
77
UNIV_INLINE
95
78
page_t*
96
79
btr_cur_get_page(
97
80
/*=============*/
98
 
        btr_cur_t*      cursor);/*!< in: tree cursor */
99
 
/*********************************************************//**
100
 
Returns the index of a cursor.
101
 
@return index */
 
81
                                /* out: pointer to page */
 
82
        btr_cur_t*      cursor);/* in: tree cursor */
 
83
/*************************************************************
 
84
Returns the index of a cursor. */
102
85
UNIV_INLINE
103
86
dict_index_t*
104
87
btr_cur_get_index(
105
88
/*==============*/
106
 
        btr_cur_t*      cursor);/*!< in: B-tree cursor */
107
 
/*********************************************************//**
 
89
                                /* out: index */
 
90
        btr_cur_t*      cursor);/* in: B-tree cursor */
 
91
/*************************************************************
108
92
Positions a tree cursor at a given record. */
109
93
UNIV_INLINE
110
94
void
111
95
btr_cur_position(
112
96
/*=============*/
113
 
        dict_index_t*   index,  /*!< in: index */
114
 
        rec_t*          rec,    /*!< in: record in tree */
115
 
        buf_block_t*    block,  /*!< in: buffer block of rec */
116
 
        btr_cur_t*      cursor);/*!< in: cursor */
117
 
/********************************************************************//**
 
97
        dict_index_t*   index,  /* in: index */
 
98
        rec_t*          rec,    /* in: record in tree */
 
99
        buf_block_t*    block,  /* in: buffer block of rec */
 
100
        btr_cur_t*      cursor);/* in: cursor */
 
101
/************************************************************************
118
102
Searches an index tree and positions a tree cursor on a given level.
119
103
NOTE: n_fields_cmp in tuple must be set so that it cannot be compared
120
104
to node pointer page number fields on the upper levels of the tree!
125
109
void
126
110
btr_cur_search_to_nth_level(
127
111
/*========================*/
128
 
        dict_index_t*   index,  /*!< in: index */
129
 
        ulint           level,  /*!< in: the tree level of search */
130
 
        const dtuple_t* tuple,  /*!< in: data tuple; NOTE: n_fields_cmp in
 
112
        dict_index_t*   index,  /* in: index */
 
113
        ulint           level,  /* in: the tree level of search */
 
114
        const dtuple_t* tuple,  /* in: data tuple; NOTE: n_fields_cmp in
131
115
                                tuple must be set so that it cannot get
132
116
                                compared to the node ptr page number field! */
133
 
        ulint           mode,   /*!< in: PAGE_CUR_L, ...;
 
117
        ulint           mode,   /* in: PAGE_CUR_L, ...;
134
118
                                NOTE that if the search is made using a unique
135
119
                                prefix of a record, mode should be PAGE_CUR_LE,
136
120
                                not PAGE_CUR_GE, as the latter may end up on
137
121
                                the previous page of the record! Inserts
138
122
                                should always be made using PAGE_CUR_LE to
139
123
                                search the position! */
140
 
        ulint           latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
 
124
        ulint           latch_mode, /* in: BTR_SEARCH_LEAF, ..., ORed with
141
125
                                BTR_INSERT and BTR_ESTIMATE;
142
126
                                cursor->left_block is used to store a pointer
143
127
                                to the left neighbor page, in the cases
147
131
                                on the cursor page, we assume
148
132
                                the caller uses his search latch
149
133
                                to protect the record! */
150
 
        btr_cur_t*      cursor, /*!< in/out: tree cursor; the cursor page is
 
134
        btr_cur_t*      cursor, /* in/out: tree cursor; the cursor page is
151
135
                                s- or x-latched, but see also above! */
152
 
        ulint           has_search_latch,/*!< in: latch mode the caller
 
136
        ulint           has_search_latch,/* in: latch mode the caller
153
137
                                currently has on btr_search_latch:
154
138
                                RW_S_LATCH, or 0 */
155
 
        mtr_t*          mtr);   /*!< in: mtr */
156
 
/*****************************************************************//**
 
139
        mtr_t*          mtr);   /* in: mtr */
 
140
/*********************************************************************
157
141
Opens a cursor at either end of an index. */
158
142
UNIV_INTERN
159
143
void
160
144
btr_cur_open_at_index_side(
161
145
/*=======================*/
162
 
        ibool           from_left,      /*!< in: TRUE if open to the low end,
 
146
        ibool           from_left,      /* in: TRUE if open to the low end,
163
147
                                        FALSE if to the high end */
164
 
        dict_index_t*   index,          /*!< in: index */
165
 
        ulint           latch_mode,     /*!< in: latch mode */
166
 
        btr_cur_t*      cursor,         /*!< in: cursor */
167
 
        mtr_t*          mtr);           /*!< in: mtr */
168
 
/**********************************************************************//**
 
148
        dict_index_t*   index,          /* in: index */
 
149
        ulint           latch_mode,     /* in: latch mode */
 
150
        btr_cur_t*      cursor,         /* in: cursor */
 
151
        mtr_t*          mtr);           /* in: mtr */
 
152
/**************************************************************************
169
153
Positions a cursor at a randomly chosen position within a B-tree. */
170
154
UNIV_INTERN
171
155
void
172
156
btr_cur_open_at_rnd_pos(
173
157
/*====================*/
174
 
        dict_index_t*   index,          /*!< in: index */
175
 
        ulint           latch_mode,     /*!< in: BTR_SEARCH_LEAF, ... */
176
 
        btr_cur_t*      cursor,         /*!< in/out: B-tree cursor */
177
 
        mtr_t*          mtr);           /*!< in: mtr */
178
 
/*************************************************************//**
 
158
        dict_index_t*   index,          /* in: index */
 
159
        ulint           latch_mode,     /* in: BTR_SEARCH_LEAF, ... */
 
160
        btr_cur_t*      cursor,         /* in/out: B-tree cursor */
 
161
        mtr_t*          mtr);           /* in: mtr */
 
162
/*****************************************************************
179
163
Tries to perform an insert to a page in an index tree, next to cursor.
180
164
It is assumed that mtr holds an x-latch on the page. The operation does
181
165
not succeed if there is too little space on the page. If there is just
182
166
one record on the page, the insert will always succeed; this is to
183
 
prevent trying to split a page with just one record.
184
 
@return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */
 
167
prevent trying to split a page with just one record. */
185
168
UNIV_INTERN
186
169
ulint
187
170
btr_cur_optimistic_insert(
188
171
/*======================*/
189
 
        ulint           flags,  /*!< in: undo logging and locking flags: if not
 
172
                                /* out: DB_SUCCESS, DB_WAIT_LOCK,
 
173
                                DB_FAIL, or error number */
 
174
        ulint           flags,  /* in: undo logging and locking flags: if not
190
175
                                zero, the parameters index and thr should be
191
176
                                specified */
192
 
        btr_cur_t*      cursor, /*!< in: cursor on page after which to insert;
 
177
        btr_cur_t*      cursor, /* in: cursor on page after which to insert;
193
178
                                cursor stays valid */
194
 
        dtuple_t*       entry,  /*!< in/out: entry to insert */
195
 
        rec_t**         rec,    /*!< out: pointer to inserted record if
 
179
        dtuple_t*       entry,  /* in/out: entry to insert */
 
180
        rec_t**         rec,    /* out: pointer to inserted record if
196
181
                                succeed */
197
 
        big_rec_t**     big_rec,/*!< out: big rec vector whose fields have to
 
182
        big_rec_t**     big_rec,/* out: big rec vector whose fields have to
198
183
                                be stored externally by the caller, or
199
184
                                NULL */
200
 
        ulint           n_ext,  /*!< in: number of externally stored columns */
201
 
        que_thr_t*      thr,    /*!< in: query thread or NULL */
202
 
        mtr_t*          mtr);   /*!< in: mtr; if this function returns
 
185
        ulint           n_ext,  /* in: number of externally stored columns */
 
186
        que_thr_t*      thr,    /* in: query thread or NULL */
 
187
        mtr_t*          mtr);   /* in: mtr; if this function returns
203
188
                                DB_SUCCESS on a leaf page of a secondary
204
189
                                index in a compressed tablespace, the
205
190
                                mtr must be committed before latching
206
191
                                any further pages */
207
 
/*************************************************************//**
 
192
/*****************************************************************
208
193
Performs an insert on a page of an index tree. It is assumed that mtr
209
194
holds an x-latch on the tree and on the cursor page. If the insert is
210
195
made on the leaf level, to avoid deadlocks, mtr must also own x-latches
211
 
to brothers of page, if those brothers exist.
212
 
@return DB_SUCCESS or error number */
 
196
to brothers of page, if those brothers exist. */
213
197
UNIV_INTERN
214
198
ulint
215
199
btr_cur_pessimistic_insert(
216
200
/*=======================*/
217
 
        ulint           flags,  /*!< in: undo logging and locking flags: if not
 
201
                                /* out: DB_SUCCESS or error number */
 
202
        ulint           flags,  /* in: undo logging and locking flags: if not
218
203
                                zero, the parameter thr should be
219
204
                                specified; if no undo logging is specified,
220
205
                                then the caller must have reserved enough
221
206
                                free extents in the file space so that the
222
207
                                insertion will certainly succeed */
223
 
        btr_cur_t*      cursor, /*!< in: cursor after which to insert;
 
208
        btr_cur_t*      cursor, /* in: cursor after which to insert;
224
209
                                cursor stays valid */
225
 
        dtuple_t*       entry,  /*!< in/out: entry to insert */
226
 
        rec_t**         rec,    /*!< out: pointer to inserted record if
 
210
        dtuple_t*       entry,  /* in/out: entry to insert */
 
211
        rec_t**         rec,    /* out: pointer to inserted record if
227
212
                                succeed */
228
 
        big_rec_t**     big_rec,/*!< out: big rec vector whose fields have to
 
213
        big_rec_t**     big_rec,/* out: big rec vector whose fields have to
229
214
                                be stored externally by the caller, or
230
215
                                NULL */
231
 
        ulint           n_ext,  /*!< in: number of externally stored columns */
232
 
        que_thr_t*      thr,    /*!< in: query thread or NULL */
233
 
        mtr_t*          mtr);   /*!< in: mtr */
234
 
/*************************************************************//**
235
 
Updates a record when the update causes no size changes in its fields.
236
 
@return DB_SUCCESS or error number */
 
216
        ulint           n_ext,  /* in: number of externally stored columns */
 
217
        que_thr_t*      thr,    /* in: query thread or NULL */
 
218
        mtr_t*          mtr);   /* in: mtr */
 
219
/*****************************************************************
 
220
Updates a record when the update causes no size changes in its fields. */
237
221
UNIV_INTERN
238
222
ulint
239
223
btr_cur_update_in_place(
240
224
/*====================*/
241
 
        ulint           flags,  /*!< in: undo logging and locking flags */
242
 
        btr_cur_t*      cursor, /*!< in: cursor on the record to update;
 
225
                                /* out: DB_SUCCESS or error number */
 
226
        ulint           flags,  /* in: undo logging and locking flags */
 
227
        btr_cur_t*      cursor, /* in: cursor on the record to update;
243
228
                                cursor stays valid and positioned on the
244
229
                                same record */
245
 
        const upd_t*    update, /*!< in: update vector */
246
 
        ulint           cmpl_info,/*!< in: compiler info on secondary index
 
230
        const upd_t*    update, /* in: update vector */
 
231
        ulint           cmpl_info,/* in: compiler info on secondary index
247
232
                                updates */
248
 
        que_thr_t*      thr,    /*!< in: query thread */
249
 
        mtr_t*          mtr);   /*!< in: mtr; must be committed before
 
233
        que_thr_t*      thr,    /* in: query thread */
 
234
        mtr_t*          mtr);   /* in: mtr; must be committed before
250
235
                                latching any further pages */
251
 
/*************************************************************//**
 
236
/*****************************************************************
252
237
Tries to update a record on a page in an index tree. It is assumed that mtr
253
238
holds an x-latch on the page. The operation does not succeed if there is too
254
239
little space on the page or if the update would result in too empty a page,
255
 
so that tree compression is recommended.
256
 
@return DB_SUCCESS, or DB_OVERFLOW if the updated record does not fit,
257
 
DB_UNDERFLOW if the page would become too empty, or DB_ZIP_OVERFLOW if
258
 
there is not enough space left on the compressed page */
 
240
so that tree compression is recommended. */
259
241
UNIV_INTERN
260
242
ulint
261
243
btr_cur_optimistic_update(
262
244
/*======================*/
263
 
        ulint           flags,  /*!< in: undo logging and locking flags */
264
 
        btr_cur_t*      cursor, /*!< in: cursor on the record to update;
 
245
                                /* out: DB_SUCCESS, or DB_OVERFLOW if the
 
246
                                updated record does not fit, DB_UNDERFLOW
 
247
                                if the page would become too empty, or
 
248
                                DB_ZIP_OVERFLOW if there is not enough
 
249
                                space left on the compressed page */
 
250
        ulint           flags,  /* in: undo logging and locking flags */
 
251
        btr_cur_t*      cursor, /* in: cursor on the record to update;
265
252
                                cursor stays valid and positioned on the
266
253
                                same record */
267
 
        const upd_t*    update, /*!< in: update vector; this must also
 
254
        const upd_t*    update, /* in: update vector; this must also
268
255
                                contain trx id and roll ptr fields */
269
 
        ulint           cmpl_info,/*!< in: compiler info on secondary index
 
256
        ulint           cmpl_info,/* in: compiler info on secondary index
270
257
                                updates */
271
 
        que_thr_t*      thr,    /*!< in: query thread */
272
 
        mtr_t*          mtr);   /*!< in: mtr; must be committed before
 
258
        que_thr_t*      thr,    /* in: query thread */
 
259
        mtr_t*          mtr);   /* in: mtr; must be committed before
273
260
                                latching any further pages */
274
 
/*************************************************************//**
 
261
/*****************************************************************
275
262
Performs an update of a record on a page of a tree. It is assumed
276
263
that mtr holds an x-latch on the tree and on the cursor page. If the
277
264
update is made on the leaf level, to avoid deadlocks, mtr must also
278
 
own x-latches to brothers of page, if those brothers exist.
279
 
@return DB_SUCCESS or error code */
 
265
own x-latches to brothers of page, if those brothers exist. */
280
266
UNIV_INTERN
281
267
ulint
282
268
btr_cur_pessimistic_update(
283
269
/*=======================*/
284
 
        ulint           flags,  /*!< in: undo logging, locking, and rollback
 
270
                                /* out: DB_SUCCESS or error code */
 
271
        ulint           flags,  /* in: undo logging, locking, and rollback
285
272
                                flags */
286
 
        btr_cur_t*      cursor, /*!< in: cursor on the record to update */
287
 
        mem_heap_t**    heap,   /*!< in/out: pointer to memory heap, or NULL */
288
 
        big_rec_t**     big_rec,/*!< out: big rec vector whose fields have to
 
273
        btr_cur_t*      cursor, /* in: cursor on the record to update */
 
274
        mem_heap_t**    heap,   /* in/out: pointer to memory heap, or NULL */
 
275
        big_rec_t**     big_rec,/* out: big rec vector whose fields have to
289
276
                                be stored externally by the caller, or NULL */
290
 
        const upd_t*    update, /*!< in: update vector; this is allowed also
 
277
        const upd_t*    update, /* in: update vector; this is allowed also
291
278
                                contain trx id and roll ptr fields, but
292
279
                                the values in update vector have no effect */
293
 
        ulint           cmpl_info,/*!< in: compiler info on secondary index
 
280
        ulint           cmpl_info,/* in: compiler info on secondary index
294
281
                                updates */
295
 
        que_thr_t*      thr,    /*!< in: query thread */
296
 
        mtr_t*          mtr);   /*!< in: mtr; must be committed before
 
282
        que_thr_t*      thr,    /* in: query thread */
 
283
        mtr_t*          mtr);   /* in: mtr; must be committed before
297
284
                                latching any further pages */
298
 
/***********************************************************//**
 
285
/***************************************************************
299
286
Marks a clustered index record deleted. Writes an undo log record to
300
287
undo log on this delete marking. Writes in the trx id field the id
301
288
of the deleting transaction, and in the roll ptr field pointer to the
302
 
undo log record created.
303
 
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
 
289
undo log record created. */
304
290
UNIV_INTERN
305
291
ulint
306
292
btr_cur_del_mark_set_clust_rec(
307
293
/*===========================*/
308
 
        ulint           flags,  /*!< in: undo logging and locking flags */
309
 
        btr_cur_t*      cursor, /*!< in: cursor */
310
 
        ibool           val,    /*!< in: value to set */
311
 
        que_thr_t*      thr,    /*!< in: query thread */
312
 
        mtr_t*          mtr);   /*!< in: mtr */
313
 
/***********************************************************//**
314
 
Sets a secondary index record delete mark to TRUE or FALSE.
315
 
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
 
294
                                /* out: DB_SUCCESS, DB_LOCK_WAIT, or error
 
295
                                number */
 
296
        ulint           flags,  /* in: undo logging and locking flags */
 
297
        btr_cur_t*      cursor, /* in: cursor */
 
298
        ibool           val,    /* in: value to set */
 
299
        que_thr_t*      thr,    /* in: query thread */
 
300
        mtr_t*          mtr);   /* in: mtr */
 
301
/***************************************************************
 
302
Sets a secondary index record delete mark to TRUE or FALSE. */
316
303
UNIV_INTERN
317
304
ulint
318
305
btr_cur_del_mark_set_sec_rec(
319
306
/*=========================*/
320
 
        ulint           flags,  /*!< in: locking flag */
321
 
        btr_cur_t*      cursor, /*!< in: cursor */
322
 
        ibool           val,    /*!< in: value to set */
323
 
        que_thr_t*      thr,    /*!< in: query thread */
324
 
        mtr_t*          mtr);   /*!< in: mtr */
325
 
/***********************************************************//**
 
307
                                /* out: DB_SUCCESS, DB_LOCK_WAIT, or error
 
308
                                number */
 
309
        ulint           flags,  /* in: locking flag */
 
310
        btr_cur_t*      cursor, /* in: cursor */
 
311
        ibool           val,    /* in: value to set */
 
312
        que_thr_t*      thr,    /* in: query thread */
 
313
        mtr_t*          mtr);   /* in: mtr */
 
314
/***************************************************************
326
315
Clear a secondary index record's delete mark.  This function is only
327
316
used by the insert buffer insert merge mechanism. */
328
317
UNIV_INTERN
329
318
void
330
319
btr_cur_del_unmark_for_ibuf(
331
320
/*========================*/
332
 
        rec_t*          rec,            /*!< in/out: record to delete unmark */
333
 
        page_zip_des_t* page_zip,       /*!< in/out: compressed page
 
321
        rec_t*          rec,            /* in/out: record to delete unmark */
 
322
        page_zip_des_t* page_zip,       /* in/out: compressed page
334
323
                                        corresponding to rec, or NULL
335
324
                                        when the tablespace is
336
325
                                        uncompressed */
337
 
        mtr_t*          mtr);           /*!< in: mtr */
338
 
/*************************************************************//**
 
326
        mtr_t*          mtr);           /* in: mtr */
 
327
/*****************************************************************
339
328
Tries to compress a page of the tree if it seems useful. It is assumed
340
329
that mtr holds an x-latch on the tree and on the cursor page. To avoid
341
330
deadlocks, mtr must also own x-latches to brothers of page, if those
342
331
brothers exist. NOTE: it is assumed that the caller has reserved enough
343
 
free extents so that the compression will always succeed if done!
344
 
@return TRUE if compression occurred */
 
332
free extents so that the compression will always succeed if done! */
345
333
UNIV_INTERN
346
334
ibool
347
335
btr_cur_compress_if_useful(
348
336
/*=======================*/
349
 
        btr_cur_t*      cursor, /*!< in: cursor on the page to compress;
 
337
                                /* out: TRUE if compression occurred */
 
338
        btr_cur_t*      cursor, /* in: cursor on the page to compress;
350
339
                                cursor does not stay valid if compression
351
340
                                occurs */
352
 
        mtr_t*          mtr);   /*!< in: mtr */
353
 
/*******************************************************//**
 
341
        mtr_t*          mtr);   /* in: mtr */
 
342
/***********************************************************
354
343
Removes the record on which the tree cursor is positioned. It is assumed
355
344
that the mtr has an x-latch on the page where the cursor is positioned,
356
 
but no latch on the whole tree.
357
 
@return TRUE if success, i.e., the page did not become too empty */
 
345
but no latch on the whole tree. */
358
346
UNIV_INTERN
359
347
ibool
360
348
btr_cur_optimistic_delete(
361
349
/*======================*/
362
 
        btr_cur_t*      cursor, /*!< in: cursor on the record to delete;
 
350
                                /* out: TRUE if success, i.e., the page
 
351
                                did not become too empty */
 
352
        btr_cur_t*      cursor, /* in: cursor on the record to delete;
363
353
                                cursor stays valid: if deletion succeeds,
364
354
                                on function exit it points to the successor
365
355
                                of the deleted record */
366
 
        mtr_t*          mtr);   /*!< in: mtr; if this function returns
367
 
                                TRUE on a leaf page of a secondary
368
 
                                index, the mtr must be committed
369
 
                                before latching any further pages */
370
 
/*************************************************************//**
 
356
        mtr_t*          mtr);   /* in: mtr */
 
357
/*****************************************************************
371
358
Removes the record on which the tree cursor is positioned. Tries
372
359
to compress the page if its fillfactor drops below a threshold
373
360
or if it is the only page on the level. It is assumed that mtr holds
374
361
an x-latch on the tree and on the cursor page. To avoid deadlocks,
375
362
mtr must also own x-latches to brothers of page, if those brothers
376
 
exist.
377
 
@return TRUE if compression occurred */
 
363
exist. */
378
364
UNIV_INTERN
379
365
ibool
380
366
btr_cur_pessimistic_delete(
381
367
/*=======================*/
382
 
        ulint*          err,    /*!< out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE;
 
368
                                /* out: TRUE if compression occurred */
 
369
        ulint*          err,    /* out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE;
383
370
                                the latter may occur because we may have
384
371
                                to update node pointers on upper levels,
385
372
                                and in the case of variable length keys
386
373
                                these may actually grow in size */
387
 
        ibool           has_reserved_extents, /*!< in: TRUE if the
 
374
        ibool           has_reserved_extents, /* in: TRUE if the
388
375
                                caller has already reserved enough free
389
376
                                extents so that he knows that the operation
390
377
                                will succeed */
391
 
        btr_cur_t*      cursor, /*!< in: cursor on the record to delete;
 
378
        btr_cur_t*      cursor, /* in: cursor on the record to delete;
392
379
                                if compression does not occur, the cursor
393
380
                                stays valid: it points to successor of
394
381
                                deleted record on function exit */
395
 
        enum trx_rb_ctx rb_ctx, /*!< in: rollback context */
396
 
        mtr_t*          mtr);   /*!< in: mtr */
397
 
#endif /* !UNIV_HOTBACKUP */
398
 
/***********************************************************//**
399
 
Parses a redo log record of updating a record in-place.
400
 
@return end of log record or NULL */
 
382
        enum trx_rb_ctx rb_ctx, /* in: rollback context */
 
383
        mtr_t*          mtr);   /* in: mtr */
 
384
/***************************************************************
 
385
Parses a redo log record of updating a record in-place. */
401
386
UNIV_INTERN
402
387
byte*
403
388
btr_cur_parse_update_in_place(
404
389
/*==========================*/
405
 
        byte*           ptr,    /*!< in: buffer */
406
 
        byte*           end_ptr,/*!< in: buffer end */
407
 
        page_t*         page,   /*!< in/out: page or NULL */
408
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
409
 
        dict_index_t*   index); /*!< in: index corresponding to page */
410
 
/****************************************************************//**
 
390
                                /* out: end of log record or NULL */
 
391
        byte*           ptr,    /* in: buffer */
 
392
        byte*           end_ptr,/* in: buffer end */
 
393
        page_t*         page,   /* in/out: page or NULL */
 
394
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
395
        dict_index_t*   index); /* in: index corresponding to page */
 
396
/********************************************************************
411
397
Parses the redo log record for delete marking or unmarking of a clustered
412
 
index record.
413
 
@return end of log record or NULL */
 
398
index record. */
414
399
UNIV_INTERN
415
400
byte*
416
401
btr_cur_parse_del_mark_set_clust_rec(
417
402
/*=================================*/
418
 
        byte*           ptr,    /*!< in: buffer */
419
 
        byte*           end_ptr,/*!< in: buffer end */
420
 
        page_t*         page,   /*!< in/out: page or NULL */
421
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
422
 
        dict_index_t*   index); /*!< in: index corresponding to page */
423
 
/****************************************************************//**
 
403
                                /* out: end of log record or NULL */
 
404
        byte*           ptr,    /* in: buffer */
 
405
        byte*           end_ptr,/* in: buffer end */
 
406
        page_t*         page,   /* in/out: page or NULL */
 
407
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
408
        dict_index_t*   index); /* in: index corresponding to page */
 
409
/********************************************************************
424
410
Parses the redo log record for delete marking or unmarking of a secondary
425
 
index record.
426
 
@return end of log record or NULL */
 
411
index record. */
427
412
UNIV_INTERN
428
413
byte*
429
414
btr_cur_parse_del_mark_set_sec_rec(
430
415
/*===============================*/
431
 
        byte*           ptr,    /*!< in: buffer */
432
 
        byte*           end_ptr,/*!< in: buffer end */
433
 
        page_t*         page,   /*!< in/out: page or NULL */
434
 
        page_zip_des_t* page_zip);/*!< in/out: compressed page, or NULL */
435
 
#ifndef UNIV_HOTBACKUP
436
 
/*******************************************************************//**
437
 
Estimates the number of rows in a given index range.
438
 
@return estimated number of rows */
 
416
                                /* out: end of log record or NULL */
 
417
        byte*           ptr,    /* in: buffer */
 
418
        byte*           end_ptr,/* in: buffer end */
 
419
        page_t*         page,   /* in/out: page or NULL */
 
420
        page_zip_des_t* page_zip);/* in/out: compressed page, or NULL */
 
421
/***********************************************************************
 
422
Estimates the number of rows in a given index range. */
439
423
UNIV_INTERN
440
424
ib_int64_t
441
425
btr_estimate_n_rows_in_range(
442
426
/*=========================*/
443
 
        dict_index_t*   index,  /*!< in: index */
444
 
        const dtuple_t* tuple1, /*!< in: range start, may also be empty tuple */
445
 
        ulint           mode1,  /*!< in: search mode for range start */
446
 
        const dtuple_t* tuple2, /*!< in: range end, may also be empty tuple */
447
 
        ulint           mode2); /*!< in: search mode for range end */
448
 
/*******************************************************************//**
 
427
                                /* out: estimated number of rows */
 
428
        dict_index_t*   index,  /* in: index */
 
429
        const dtuple_t* tuple1, /* in: range start, may also be empty tuple */
 
430
        ulint           mode1,  /* in: search mode for range start */
 
431
        const dtuple_t* tuple2, /* in: range end, may also be empty tuple */
 
432
        ulint           mode2); /* in: search mode for range end */
 
433
/***********************************************************************
449
434
Estimates the number of different key values in a given index, for
450
435
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
451
436
The estimates are stored in the array index->stat_n_diff_key_vals. */
453
438
void
454
439
btr_estimate_number_of_different_key_vals(
455
440
/*======================================*/
456
 
        dict_index_t*   index); /*!< in: index */
457
 
/*******************************************************************//**
 
441
        dict_index_t*   index); /* in: index */
 
442
/***********************************************************************
458
443
Marks not updated extern fields as not-owned by this record. The ownership
459
444
is transferred to the updated record which is inserted elsewhere in the
460
445
index tree. In purge only the owner of externally stored field is allowed
463
448
void
464
449
btr_cur_mark_extern_inherited_fields(
465
450
/*=================================*/
466
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed
 
451
        page_zip_des_t* page_zip,/* in/out: compressed page whose uncompressed
467
452
                                part will be updated, or NULL */
468
 
        rec_t*          rec,    /*!< in/out: record in a clustered index */
469
 
        dict_index_t*   index,  /*!< in: index of the page */
470
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
471
 
        const upd_t*    update, /*!< in: update vector */
472
 
        mtr_t*          mtr);   /*!< in: mtr, or NULL if not logged */
473
 
/*******************************************************************//**
 
453
        rec_t*          rec,    /* in/out: record in a clustered index */
 
454
        dict_index_t*   index,  /* in: index of the page */
 
455
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
456
        const upd_t*    update, /* in: update vector */
 
457
        mtr_t*          mtr);   /* in: mtr, or NULL if not logged */
 
458
/***********************************************************************
474
459
The complement of the previous function: in an update entry may inherit
475
460
some externally stored fields from a record. We must mark them as inherited
476
461
in entry, so that they are not freed in a rollback. */
478
463
void
479
464
btr_cur_mark_dtuple_inherited_extern(
480
465
/*=================================*/
481
 
        dtuple_t*       entry,          /*!< in/out: updated entry to be
 
466
        dtuple_t*       entry,          /* in/out: updated entry to be
482
467
                                        inserted to clustered index */
483
 
        const upd_t*    update);        /*!< in: update vector */
484
 
/*******************************************************************//**
 
468
        const upd_t*    update);        /* in: update vector */
 
469
/***********************************************************************
485
470
Marks all extern fields in a dtuple as owned by the record. */
486
471
UNIV_INTERN
487
472
void
488
473
btr_cur_unmark_dtuple_extern_fields(
489
474
/*================================*/
490
 
        dtuple_t*       entry);         /*!< in/out: clustered index entry */
491
 
/*******************************************************************//**
 
475
        dtuple_t*       entry);         /* in/out: clustered index entry */
 
476
/***********************************************************************
492
477
Stores the fields in big_rec_vec to the tablespace and puts pointers to
493
478
them in rec.  The extern flags in rec will have to be set beforehand.
494
479
The fields are stored on pages allocated from leaf node
495
 
file segment of the index tree.
496
 
@return DB_SUCCESS or error */
 
480
file segment of the index tree. */
497
481
UNIV_INTERN
498
482
ulint
499
483
btr_store_big_rec_extern_fields(
500
484
/*============================*/
501
 
        dict_index_t*   index,          /*!< in: index of rec; the index tree
 
485
                                        /* out: DB_SUCCESS or error */
 
486
        dict_index_t*   index,          /* in: index of rec; the index tree
502
487
                                        MUST be X-latched */
503
 
        buf_block_t*    rec_block,      /*!< in/out: block containing rec */
504
 
        rec_t*          rec,            /*!< in: record */
505
 
        const ulint*    offsets,        /*!< in: rec_get_offsets(rec, index);
 
488
        buf_block_t*    rec_block,      /* in/out: block containing rec */
 
489
        rec_t*          rec,            /* in: record */
 
490
        const ulint*    offsets,        /* in: rec_get_offsets(rec, index);
506
491
                                        the "external storage" flags in offsets
507
492
                                        will not correspond to rec when
508
493
                                        this function returns */
509
 
        big_rec_t*      big_rec_vec,    /*!< in: vector containing fields
 
494
        big_rec_t*      big_rec_vec,    /* in: vector containing fields
510
495
                                        to be stored externally */
511
 
        mtr_t*          local_mtr);     /*!< in: mtr containing the latch to
 
496
        mtr_t*          local_mtr);     /* in: mtr containing the latch to
512
497
                                        rec and to the tree */
513
 
/*******************************************************************//**
 
498
/***********************************************************************
514
499
Frees the space in an externally stored field to the file space
515
500
management if the field in data is owned the externally stored field,
516
501
in a rollback we may have the additional condition that the field must
519
504
void
520
505
btr_free_externally_stored_field(
521
506
/*=============================*/
522
 
        dict_index_t*   index,          /*!< in: index of the data, the index
 
507
        dict_index_t*   index,          /* in: index of the data, the index
523
508
                                        tree MUST be X-latched; if the tree
524
509
                                        height is 1, then also the root page
525
510
                                        must be X-latched! (this is relevant
527
512
                                        from purge where 'data' is located on
528
513
                                        an undo log page, not an index
529
514
                                        page) */
530
 
        byte*           field_ref,      /*!< in/out: field reference */
531
 
        const rec_t*    rec,            /*!< in: record containing field_ref, for
 
515
        byte*           field_ref,      /* in/out: field reference */
 
516
        const rec_t*    rec,            /* in: record containing field_ref, for
532
517
                                        page_zip_write_blob_ptr(), or NULL */
533
 
        const ulint*    offsets,        /*!< in: rec_get_offsets(rec, index),
 
518
        const ulint*    offsets,        /* in: rec_get_offsets(rec, index),
534
519
                                        or NULL */
535
 
        page_zip_des_t* page_zip,       /*!< in: compressed page corresponding
 
520
        page_zip_des_t* page_zip,       /* in: compressed page corresponding
536
521
                                        to rec, or NULL if rec == NULL */
537
 
        ulint           i,              /*!< in: field number of field_ref;
 
522
        ulint           i,              /* in: field number of field_ref;
538
523
                                        ignored if rec == NULL */
539
 
        enum trx_rb_ctx rb_ctx,         /*!< in: rollback context */
540
 
        mtr_t*          local_mtr);     /*!< in: mtr containing the latch to
 
524
        enum trx_rb_ctx rb_ctx,         /* in: rollback context */
 
525
        mtr_t*          local_mtr);     /* in: mtr containing the latch to
541
526
                                        data an an X-latch to the index
542
527
                                        tree */
543
 
/*******************************************************************//**
 
528
/***********************************************************************
544
529
Copies the prefix of an externally stored field of a record.  The
545
 
clustered index record must be protected by a lock or a page latch.
546
 
@return the length of the copied field, or 0 if the column was being
547
 
or has been deleted */
 
530
clustered index record must be protected by a lock or a page latch. */
548
531
UNIV_INTERN
549
532
ulint
550
533
btr_copy_externally_stored_field_prefix(
551
534
/*====================================*/
552
 
        byte*           buf,    /*!< out: the field, or a prefix of it */
553
 
        ulint           len,    /*!< in: length of buf, in bytes */
554
 
        ulint           zip_size,/*!< in: nonzero=compressed BLOB page size,
 
535
                                /* out: the length of the copied field,
 
536
                                or 0 if the column is being or has been
 
537
                                deleted */
 
538
        byte*           buf,    /* out: the field, or a prefix of it */
 
539
        ulint           len,    /* in: length of buf, in bytes */
 
540
        ulint           zip_size,/* in: nonzero=compressed BLOB page size,
555
541
                                zero for uncompressed BLOBs */
556
 
        const byte*     data,   /*!< in: 'internally' stored part of the
 
542
        const byte*     data,   /* in: 'internally' stored part of the
557
543
                                field containing also the reference to
558
544
                                the external part; must be protected by
559
545
                                a lock or a page latch */
560
 
        ulint           local_len);/*!< in: length of data, in bytes */
561
 
/*******************************************************************//**
562
 
Copies an externally stored field of a record to mem heap.
563
 
@return the field copied to heap */
 
546
        ulint           local_len);/* in: length of data, in bytes */
 
547
/***********************************************************************
 
548
Copies an externally stored field of a record to mem heap. */
564
549
UNIV_INTERN
565
550
byte*
566
551
btr_rec_copy_externally_stored_field(
567
552
/*=================================*/
568
 
        const rec_t*    rec,    /*!< in: record in a clustered index;
 
553
                                /* out: the field copied to heap */
 
554
        const rec_t*    rec,    /* in: record in a clustered index;
569
555
                                must be protected by a lock or a page latch */
570
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
571
 
        ulint           zip_size,/*!< in: nonzero=compressed BLOB page size,
 
556
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
557
        ulint           zip_size,/* in: nonzero=compressed BLOB page size,
572
558
                                zero for uncompressed BLOBs */
573
 
        ulint           no,     /*!< in: field number */
574
 
        ulint*          len,    /*!< out: length of the field */
575
 
        mem_heap_t*     heap);  /*!< in: mem heap */
576
 
/*******************************************************************//**
 
559
        ulint           no,     /* in: field number */
 
560
        ulint*          len,    /* out: length of the field */
 
561
        mem_heap_t*     heap);  /* in: mem heap */
 
562
/***********************************************************************
577
563
Flags the data tuple fields that are marked as extern storage in the
578
564
update vector.  We use this function to remember which fields we must
579
 
mark as extern storage in a record inserted for an update.
580
 
@return number of flagged external columns */
 
565
mark as extern storage in a record inserted for an update. */
581
566
UNIV_INTERN
582
567
ulint
583
568
btr_push_update_extern_fields(
584
569
/*==========================*/
585
 
        dtuple_t*       tuple,  /*!< in/out: data tuple */
586
 
        const upd_t*    update, /*!< in: update vector */
587
 
        mem_heap_t*     heap)   /*!< in: memory heap */
 
570
                                /* out: number of flagged external columns */
 
571
        dtuple_t*       tuple,  /* in/out: data tuple */
 
572
        const upd_t*    update, /* in: update vector */
 
573
        mem_heap_t*     heap)   /* in: memory heap */
588
574
        __attribute__((nonnull));
589
575
 
590
576
/*######################################################################*/
591
577
 
592
 
/** In the pessimistic delete, if the page data size drops below this
 
578
/* In the pessimistic delete, if the page data size drops below this
593
579
limit, merging it to a neighbor is tried */
 
580
 
594
581
#define BTR_CUR_PAGE_COMPRESS_LIMIT     (UNIV_PAGE_SIZE / 2)
595
582
 
596
 
/** A slot in the path array. We store here info on a search path down the
 
583
/* A slot in the path array. We store here info on a search path down the
597
584
tree. Each slot contains data on a single level of the tree. */
598
585
 
599
586
typedef struct btr_path_struct  btr_path_t;
600
587
struct btr_path_struct{
601
 
        ulint   nth_rec;        /*!< index of the record
 
588
        ulint   nth_rec;        /* index of the record
602
589
                                where the page cursor stopped on
603
590
                                this level (index in alphabetical
604
591
                                order); value ULINT_UNDEFINED
605
592
                                denotes array end */
606
 
        ulint   n_recs;         /*!< number of records on the page */
607
 
};
608
 
 
609
 
#define BTR_PATH_ARRAY_N_SLOTS  250     /*!< size of path array (in slots) */
610
 
 
611
 
/** Values for the flag documenting the used search method */
612
 
enum btr_cur_method {
613
 
        BTR_CUR_HASH = 1,       /*!< successful shortcut using
614
 
                                the hash index */
615
 
        BTR_CUR_HASH_FAIL,      /*!< failure using hash, success using
616
 
                                binary search: the misleading hash
617
 
                                reference is stored in the field
618
 
                                hash_node, and might be necessary to
619
 
                                update */
620
 
        BTR_CUR_BINARY,         /*!< success using the binary search */
621
 
        BTR_CUR_INSERT_TO_IBUF  /*!< performed the intended insert to
622
 
                                the insert buffer */
623
 
};
624
 
 
625
 
/** The tree cursor: the definition appears here only for the compiler
 
593
        ulint   n_recs;         /* number of records on the page */
 
594
};
 
595
 
 
596
#define BTR_PATH_ARRAY_N_SLOTS  250     /* size of path array (in slots) */
 
597
 
 
598
/* The tree cursor: the definition appears here only for the compiler
626
599
to know struct size! */
 
600
 
627
601
struct btr_cur_struct {
628
 
        dict_index_t*   index;          /*!< index where positioned */
629
 
        page_cur_t      page_cur;       /*!< page cursor */
630
 
        buf_block_t*    left_block;     /*!< this field is used to store
 
602
        dict_index_t*   index;          /* index where positioned */
 
603
        page_cur_t      page_cur;       /* page cursor */
 
604
        buf_block_t*    left_block;     /* this field is used to store
631
605
                                        a pointer to the left neighbor
632
606
                                        page, in the cases
633
607
                                        BTR_SEARCH_PREV and
634
608
                                        BTR_MODIFY_PREV */
635
609
        /*------------------------------*/
636
 
        que_thr_t*      thr;            /*!< this field is only used
637
 
                                        when btr_cur_search_to_nth_level
638
 
                                        is called for an index entry
639
 
                                        insertion: the calling query
640
 
                                        thread is passed here to be
 
610
        que_thr_t*      thr;            /* this field is only used when
 
611
                                        btr_cur_search_... is called for an
 
612
                                        index entry insertion: the calling
 
613
                                        query thread is passed here to be
641
614
                                        used in the insert buffer */
642
615
        /*------------------------------*/
643
 
        /** The following fields are used in
644
 
        btr_cur_search_to_nth_level to pass information: */
645
 
        /* @{ */
646
 
        enum btr_cur_method     flag;   /*!< Search method used */
647
 
        ulint           tree_height;    /*!< Tree height if the search is done
 
616
        /* The following fields are used in btr_cur_search... to pass
 
617
        information: */
 
618
        ulint           flag;           /* BTR_CUR_HASH, BTR_CUR_HASH_FAIL,
 
619
                                        BTR_CUR_BINARY, or
 
620
                                        BTR_CUR_INSERT_TO_IBUF */
 
621
        ulint           tree_height;    /* Tree height if the search is done
648
622
                                        for a pessimistic insert or update
649
623
                                        operation */
650
 
        ulint           up_match;       /*!< If the search mode was PAGE_CUR_LE,
 
624
        ulint           up_match;       /* If the search mode was PAGE_CUR_LE,
651
625
                                        the number of matched fields to the
652
626
                                        the first user record to the right of
653
627
                                        the cursor record after
654
 
                                        btr_cur_search_to_nth_level;
 
628
                                        btr_cur_search_...;
655
629
                                        for the mode PAGE_CUR_GE, the matched
656
630
                                        fields to the first user record AT THE
657
631
                                        CURSOR or to the right of it;
661
635
                                        record if that record is on a
662
636
                                        different leaf page! (See the note in
663
637
                                        row_ins_duplicate_key.) */
664
 
        ulint           up_bytes;       /*!< number of matched bytes to the
 
638
        ulint           up_bytes;       /* number of matched bytes to the
665
639
                                        right at the time cursor positioned;
666
640
                                        only used internally in searches: not
667
641
                                        defined after the search */
668
 
        ulint           low_match;      /*!< if search mode was PAGE_CUR_LE,
 
642
        ulint           low_match;      /* if search mode was PAGE_CUR_LE,
669
643
                                        the number of matched fields to the
670
644
                                        first user record AT THE CURSOR or
671
645
                                        to the left of it after
672
 
                                        btr_cur_search_to_nth_level;
 
646
                                        btr_cur_search_...;
673
647
                                        NOT defined for PAGE_CUR_GE or any
674
648
                                        other search modes; see also the NOTE
675
649
                                        in up_match! */
676
 
        ulint           low_bytes;      /*!< number of matched bytes to the
 
650
        ulint           low_bytes;      /* number of matched bytes to the
677
651
                                        right at the time cursor positioned;
678
652
                                        only used internally in searches: not
679
653
                                        defined after the search */
680
 
        ulint           n_fields;       /*!< prefix length used in a hash
 
654
        ulint           n_fields;       /* prefix length used in a hash
681
655
                                        search if hash_node != NULL */
682
 
        ulint           n_bytes;        /*!< hash prefix bytes if hash_node !=
 
656
        ulint           n_bytes;        /* hash prefix bytes if hash_node !=
683
657
                                        NULL */
684
 
        ulint           fold;           /*!< fold value used in the search if
 
658
        ulint           fold;           /* fold value used in the search if
685
659
                                        flag is BTR_CUR_HASH */
686
660
        /*------------------------------*/
687
 
        /* @} */
688
 
        btr_path_t*     path_arr;       /*!< in estimating the number of
 
661
        btr_path_t*     path_arr;       /* in estimating the number of
689
662
                                        rows in range, we store in this array
690
663
                                        information of the path through
691
664
                                        the tree */
692
665
};
693
666
 
694
 
/** If pessimistic delete fails because of lack of file space, there
695
 
is still a good change of success a little later.  Try this many
696
 
times. */
 
667
/* Values for the flag documenting the used search method */
 
668
#define BTR_CUR_HASH            1       /* successful shortcut using the hash
 
669
                                        index */
 
670
#define BTR_CUR_HASH_FAIL       2       /* failure using hash, success using
 
671
                                        binary search: the misleading hash
 
672
                                        reference is stored in the field
 
673
                                        hash_node, and might be necessary to
 
674
                                        update */
 
675
#define BTR_CUR_BINARY          3       /* success using the binary search */
 
676
#define BTR_CUR_INSERT_TO_IBUF  4       /* performed the intended insert to
 
677
                                        the insert buffer */
 
678
 
 
679
/* If pessimistic delete fails because of lack of file space,
 
680
there is still a good change of success a little later: try this many times,
 
681
and sleep this many microseconds in between */
697
682
#define BTR_CUR_RETRY_DELETE_N_TIMES    100
698
 
/** If pessimistic delete fails because of lack of file space, there
699
 
is still a good change of success a little later.  Sleep this many
700
 
microseconds between retries. */
701
683
#define BTR_CUR_RETRY_SLEEP_TIME        50000
702
684
 
703
 
/** The reference in a field for which data is stored on a different page.
 
685
/* The reference in a field for which data is stored on a different page.
704
686
The reference is at the end of the 'locally' stored part of the field.
705
687
'Locally' means storage in the index record.
706
688
We store locally a long enough prefix of each column so that we can determine
707
689
the ordering parts of each index record without looking into the externally
708
690
stored part. */
709
 
/*-------------------------------------- @{ */
710
 
#define BTR_EXTERN_SPACE_ID             0       /*!< space id where stored */
711
 
#define BTR_EXTERN_PAGE_NO              4       /*!< page no where stored */
712
 
#define BTR_EXTERN_OFFSET               8       /*!< offset of BLOB header
 
691
 
 
692
/*--------------------------------------*/
 
693
#define BTR_EXTERN_SPACE_ID             0       /* space id where stored */
 
694
#define BTR_EXTERN_PAGE_NO              4       /* page no where stored */
 
695
#define BTR_EXTERN_OFFSET               8       /* offset of BLOB header
713
696
                                                on that page */
714
 
#define BTR_EXTERN_LEN                  12      /*!< 8 bytes containing the
 
697
#define BTR_EXTERN_LEN                  12      /* 8 bytes containing the
715
698
                                                length of the externally
716
699
                                                stored part of the BLOB.
717
700
                                                The 2 highest bits are
718
701
                                                reserved to the flags below. */
719
 
/*-------------------------------------- @} */
 
702
/*--------------------------------------*/
720
703
/* #define BTR_EXTERN_FIELD_REF_SIZE    20 // moved to btr0types.h */
721
704
 
722
 
/** The most significant bit of BTR_EXTERN_LEN (i.e., the most
723
 
significant bit of the byte at smallest address) is set to 1 if this
724
 
field does not 'own' the externally stored field; only the owner field
725
 
is allowed to free the field in purge! */
 
705
/* The highest bit of BTR_EXTERN_LEN (i.e., the highest bit of the byte
 
706
at lowest address) is set to 1 if this field does not 'own' the externally
 
707
stored field; only the owner field is allowed to free the field in purge!
 
708
If the 2nd highest bit is 1 then it means that the externally stored field
 
709
was inherited from an earlier version of the row. In rollback we are not
 
710
allowed to free an inherited external field. */
 
711
 
726
712
#define BTR_EXTERN_OWNER_FLAG           128
727
 
/** If the second most significant bit of BTR_EXTERN_LEN (i.e., the
728
 
second most significant bit of the byte at smallest address) is 1 then
729
 
it means that the externally stored field was inherited from an
730
 
earlier version of the row.  In rollback we are not allowed to free an
731
 
inherited external field. */
732
713
#define BTR_EXTERN_INHERITED_FLAG       64
733
714
 
734
 
/** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
735
715
extern ulint    btr_cur_n_non_sea;
736
 
/** Number of successful adaptive hash index lookups in
737
 
btr_cur_search_to_nth_level(). */
738
716
extern ulint    btr_cur_n_sea;
739
 
/** Old value of btr_cur_n_non_sea.  Copied by
740
 
srv_refresh_innodb_monitor_stats().  Referenced by
741
 
srv_printf_innodb_monitor(). */
742
717
extern ulint    btr_cur_n_non_sea_old;
743
 
/** Old value of btr_cur_n_sea.  Copied by
744
 
srv_refresh_innodb_monitor_stats().  Referenced by
745
 
srv_printf_innodb_monitor(). */
746
718
extern ulint    btr_cur_n_sea_old;
747
 
#endif /* !UNIV_HOTBACKUP */
748
719
 
749
720
#ifndef UNIV_NONINL
750
721
#include "btr0cur.ic"