146
147
on the cursor page, we assume
147
148
the caller uses his search latch
148
149
to protect the record! */
149
btr_cur_t* cursor, /* in/out: tree cursor; the cursor page is
150
btr_cur_t* cursor, /*!< in/out: tree cursor; the cursor page is
150
151
s- or x-latched, but see also above! */
151
ulint has_search_latch,/* in: latch mode the caller
152
ulint has_search_latch,/*!< in: latch mode the caller
152
153
currently has on btr_search_latch:
153
154
RW_S_LATCH, or 0 */
154
mtr_t* mtr); /* in: mtr */
155
/*********************************************************************
155
mtr_t* mtr); /*!< in: mtr */
156
/*****************************************************************//**
156
157
Opens a cursor at either end of an index. */
159
160
btr_cur_open_at_index_side(
160
161
/*=======================*/
161
ibool from_left, /* in: TRUE if open to the low end,
162
ibool from_left, /*!< in: TRUE if open to the low end,
162
163
FALSE if to the high end */
163
dict_index_t* index, /* in: index */
164
ulint latch_mode, /* in: latch mode */
165
btr_cur_t* cursor, /* in: cursor */
166
mtr_t* mtr); /* in: mtr */
167
/**************************************************************************
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
/**********************************************************************//**
168
169
Positions a cursor at a randomly chosen position within a B-tree. */
171
172
btr_cur_open_at_rnd_pos(
172
173
/*====================*/
173
dict_index_t* index, /* in: index */
174
ulint latch_mode, /* in: BTR_SEARCH_LEAF, ... */
175
btr_cur_t* cursor, /* in/out: B-tree cursor */
176
mtr_t* mtr); /* in: mtr */
177
/*****************************************************************
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
/*************************************************************//**
178
179
Tries to perform an insert to a page in an index tree, next to cursor.
179
180
It is assumed that mtr holds an x-latch on the page. The operation does
180
181
not succeed if there is too little space on the page. If there is just
181
182
one record on the page, the insert will always succeed; this is to
182
prevent trying to split a page with just one record. */
183
prevent trying to split a page with just one record.
184
@return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */
185
187
btr_cur_optimistic_insert(
186
188
/*======================*/
187
/* out: DB_SUCCESS, DB_WAIT_LOCK,
188
DB_FAIL, or error number */
189
ulint flags, /* in: undo logging and locking flags: if not
189
ulint flags, /*!< in: undo logging and locking flags: if not
190
190
zero, the parameters index and thr should be
192
btr_cur_t* cursor, /* in: cursor on page after which to insert;
192
btr_cur_t* cursor, /*!< in: cursor on page after which to insert;
193
193
cursor stays valid */
194
dtuple_t* entry, /* in/out: entry to insert */
195
rec_t** rec, /* out: pointer to inserted record if
194
dtuple_t* entry, /*!< in/out: entry to insert */
195
rec_t** rec, /*!< out: pointer to inserted record if
197
big_rec_t** big_rec,/* out: big rec vector whose fields have to
197
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
198
198
be stored externally by the caller, or
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
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
203
203
DB_SUCCESS on a leaf page of a secondary
204
204
index in a compressed tablespace, the
205
205
mtr must be committed before latching
206
206
any further pages */
207
/*****************************************************************
207
/*************************************************************//**
208
208
Performs an insert on a page of an index tree. It is assumed that mtr
209
209
holds an x-latch on the tree and on the cursor page. If the insert is
210
210
made on the leaf level, to avoid deadlocks, mtr must also own x-latches
211
to brothers of page, if those brothers exist. */
211
to brothers of page, if those brothers exist.
212
@return DB_SUCCESS or error number */
214
215
btr_cur_pessimistic_insert(
215
216
/*=======================*/
216
/* out: DB_SUCCESS or error number */
217
ulint flags, /* in: undo logging and locking flags: if not
217
ulint flags, /*!< in: undo logging and locking flags: if not
218
218
zero, the parameter thr should be
219
219
specified; if no undo logging is specified,
220
220
then the caller must have reserved enough
221
221
free extents in the file space so that the
222
222
insertion will certainly succeed */
223
btr_cur_t* cursor, /* in: cursor after which to insert;
223
btr_cur_t* cursor, /*!< in: cursor after which to insert;
224
224
cursor stays valid */
225
dtuple_t* entry, /* in/out: entry to insert */
226
rec_t** rec, /* out: pointer to inserted record if
225
dtuple_t* entry, /*!< in/out: entry to insert */
226
rec_t** rec, /*!< out: pointer to inserted record if
228
big_rec_t** big_rec,/* out: big rec vector whose fields have to
228
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
229
229
be stored externally by the caller, or
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. */
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 */
238
239
btr_cur_update_in_place(
239
240
/*====================*/
240
/* out: DB_SUCCESS or error number */
241
ulint flags, /* in: undo logging and locking flags */
242
btr_cur_t* cursor, /* in: cursor on the record to update;
241
ulint flags, /*!< in: undo logging and locking flags */
242
btr_cur_t* cursor, /*!< in: cursor on the record to update;
243
243
cursor stays valid and positioned on the
245
const upd_t* update, /* in: update vector */
246
ulint cmpl_info,/* in: compiler info on secondary index
245
const upd_t* update, /*!< in: update vector */
246
ulint cmpl_info,/*!< in: compiler info on secondary index
248
que_thr_t* thr, /* in: query thread */
249
mtr_t* mtr); /* in: mtr; must be committed before
248
que_thr_t* thr, /*!< in: query thread */
249
mtr_t* mtr); /*!< in: mtr; must be committed before
250
250
latching any further pages */
251
/*****************************************************************
251
/*************************************************************//**
252
252
Tries to update a record on a page in an index tree. It is assumed that mtr
253
253
holds an x-latch on the page. The operation does not succeed if there is too
254
254
little space on the page or if the update would result in too empty a page,
255
so that tree compression is recommended. */
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 */
258
261
btr_cur_optimistic_update(
259
262
/*======================*/
260
/* out: DB_SUCCESS, or DB_OVERFLOW if the
261
updated record does not fit, DB_UNDERFLOW
262
if the page would become too empty, or
263
DB_ZIP_OVERFLOW if there is not enough
264
space left on the compressed page */
265
ulint flags, /* in: undo logging and locking flags */
266
btr_cur_t* cursor, /* in: cursor on the record to update;
263
ulint flags, /*!< in: undo logging and locking flags */
264
btr_cur_t* cursor, /*!< in: cursor on the record to update;
267
265
cursor stays valid and positioned on the
269
const upd_t* update, /* in: update vector; this must also
267
const upd_t* update, /*!< in: update vector; this must also
270
268
contain trx id and roll ptr fields */
271
ulint cmpl_info,/* in: compiler info on secondary index
269
ulint cmpl_info,/*!< in: compiler info on secondary index
273
que_thr_t* thr, /* in: query thread */
274
mtr_t* mtr); /* in: mtr; must be committed before
271
que_thr_t* thr, /*!< in: query thread */
272
mtr_t* mtr); /*!< in: mtr; must be committed before
275
273
latching any further pages */
276
/*****************************************************************
274
/*************************************************************//**
277
275
Performs an update of a record on a page of a tree. It is assumed
278
276
that mtr holds an x-latch on the tree and on the cursor page. If the
279
277
update is made on the leaf level, to avoid deadlocks, mtr must also
280
own x-latches to brothers of page, if those brothers exist. */
278
own x-latches to brothers of page, if those brothers exist.
279
@return DB_SUCCESS or error code */
283
282
btr_cur_pessimistic_update(
284
283
/*=======================*/
285
/* out: DB_SUCCESS or error code */
286
ulint flags, /* in: undo logging, locking, and rollback
284
ulint flags, /*!< in: undo logging, locking, and rollback
288
btr_cur_t* cursor, /* in: cursor on the record to update */
289
mem_heap_t** heap, /* in/out: pointer to memory heap, or NULL */
290
big_rec_t** big_rec,/* out: big rec vector whose fields have to
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
291
289
be stored externally by the caller, or NULL */
292
const upd_t* update, /* in: update vector; this is allowed also
290
const upd_t* update, /*!< in: update vector; this is allowed also
293
291
contain trx id and roll ptr fields, but
294
292
the values in update vector have no effect */
295
ulint cmpl_info,/* in: compiler info on secondary index
293
ulint cmpl_info,/*!< in: compiler info on secondary index
297
que_thr_t* thr, /* in: query thread */
298
mtr_t* mtr); /* in: mtr; must be committed before
295
que_thr_t* thr, /*!< in: query thread */
296
mtr_t* mtr); /*!< in: mtr; must be committed before
299
297
latching any further pages */
300
/***************************************************************
298
/***********************************************************//**
301
299
Marks a clustered index record deleted. Writes an undo log record to
302
300
undo log on this delete marking. Writes in the trx id field the id
303
301
of the deleting transaction, and in the roll ptr field pointer to the
304
undo log record created. */
302
undo log record created.
303
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
307
306
btr_cur_del_mark_set_clust_rec(
308
307
/*===========================*/
309
/* out: DB_SUCCESS, DB_LOCK_WAIT, or error
311
ulint flags, /* in: undo logging and locking flags */
312
btr_cur_t* cursor, /* in: cursor */
313
ibool val, /* in: value to set */
314
que_thr_t* thr, /* in: query thread */
315
mtr_t* mtr); /* in: mtr */
316
/***************************************************************
317
Sets a secondary index record delete mark to TRUE or FALSE. */
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 */
320
318
btr_cur_del_mark_set_sec_rec(
321
319
/*=========================*/
322
/* out: DB_SUCCESS, DB_LOCK_WAIT, or error
324
ulint flags, /* in: locking flag */
325
btr_cur_t* cursor, /* in: cursor */
326
ibool val, /* in: value to set */
327
que_thr_t* thr, /* in: query thread */
328
mtr_t* mtr); /* in: mtr */
329
/***************************************************************
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
/***********************************************************//**
330
326
Clear a secondary index record's delete mark. This function is only
331
327
used by the insert buffer insert merge mechanism. */
334
330
btr_cur_del_unmark_for_ibuf(
335
331
/*========================*/
336
rec_t* rec, /* in/out: record to delete unmark */
337
page_zip_des_t* page_zip, /* in/out: compressed page
332
rec_t* rec, /*!< in/out: record to delete unmark */
333
page_zip_des_t* page_zip, /*!< in/out: compressed page
338
334
corresponding to rec, or NULL
339
335
when the tablespace is
341
mtr_t* mtr); /* in: mtr */
342
/*****************************************************************
337
mtr_t* mtr); /*!< in: mtr */
338
/*************************************************************//**
343
339
Tries to compress a page of the tree if it seems useful. It is assumed
344
340
that mtr holds an x-latch on the tree and on the cursor page. To avoid
345
341
deadlocks, mtr must also own x-latches to brothers of page, if those
346
342
brothers exist. NOTE: it is assumed that the caller has reserved enough
347
free extents so that the compression will always succeed if done! */
343
free extents so that the compression will always succeed if done!
344
@return TRUE if compression occurred */
350
347
btr_cur_compress_if_useful(
351
348
/*=======================*/
352
/* out: TRUE if compression occurred */
353
btr_cur_t* cursor, /* in: cursor on the page to compress;
349
btr_cur_t* cursor, /*!< in: cursor on the page to compress;
354
350
cursor does not stay valid if compression
356
mtr_t* mtr); /* in: mtr */
357
/***********************************************************
352
mtr_t* mtr); /*!< in: mtr */
353
/*******************************************************//**
358
354
Removes the record on which the tree cursor is positioned. It is assumed
359
355
that the mtr has an x-latch on the page where the cursor is positioned,
360
but no latch on the whole tree. */
356
but no latch on the whole tree.
357
@return TRUE if success, i.e., the page did not become too empty */
363
360
btr_cur_optimistic_delete(
364
361
/*======================*/
365
/* out: TRUE if success, i.e., the page
366
did not become too empty */
367
btr_cur_t* cursor, /* in: cursor on the record to delete;
362
btr_cur_t* cursor, /*!< in: cursor on the record to delete;
368
363
cursor stays valid: if deletion succeeds,
369
364
on function exit it points to the successor
370
365
of the deleted record */
371
mtr_t* mtr); /* in: mtr; if this function returns
366
mtr_t* mtr); /*!< in: mtr; if this function returns
372
367
TRUE on a leaf page of a secondary
373
368
index, the mtr must be committed
374
369
before latching any further pages */
375
/*****************************************************************
370
/*************************************************************//**
376
371
Removes the record on which the tree cursor is positioned. Tries
377
372
to compress the page if its fillfactor drops below a threshold
378
373
or if it is the only page on the level. It is assumed that mtr holds
379
374
an x-latch on the tree and on the cursor page. To avoid deadlocks,
380
375
mtr must also own x-latches to brothers of page, if those brothers
377
@return TRUE if compression occurred */
384
380
btr_cur_pessimistic_delete(
385
381
/*=======================*/
386
/* out: TRUE if compression occurred */
387
ulint* err, /* out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE;
382
ulint* err, /*!< out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE;
388
383
the latter may occur because we may have
389
384
to update node pointers on upper levels,
390
385
and in the case of variable length keys
391
386
these may actually grow in size */
392
ibool has_reserved_extents, /* in: TRUE if the
387
ibool has_reserved_extents, /*!< in: TRUE if the
393
388
caller has already reserved enough free
394
389
extents so that he knows that the operation
396
btr_cur_t* cursor, /* in: cursor on the record to delete;
391
btr_cur_t* cursor, /*!< in: cursor on the record to delete;
397
392
if compression does not occur, the cursor
398
393
stays valid: it points to successor of
399
394
deleted record on function exit */
400
enum trx_rb_ctx rb_ctx, /* in: rollback context */
401
mtr_t* mtr); /* in: mtr */
402
/***************************************************************
403
Parses a redo log record of updating a record in-place. */
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 */
406
403
btr_cur_parse_update_in_place(
407
404
/*==========================*/
408
/* out: end of log record or NULL */
409
byte* ptr, /* in: buffer */
410
byte* end_ptr,/* in: buffer end */
411
page_t* page, /* in/out: page or NULL */
412
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
413
dict_index_t* index); /* in: index corresponding to page */
414
/********************************************************************
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
/****************************************************************//**
415
411
Parses the redo log record for delete marking or unmarking of a clustered
413
@return end of log record or NULL */
419
416
btr_cur_parse_del_mark_set_clust_rec(
420
417
/*=================================*/
421
/* out: end of log record or NULL */
422
byte* ptr, /* in: buffer */
423
byte* end_ptr,/* in: buffer end */
424
page_t* page, /* in/out: page or NULL */
425
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
426
dict_index_t* index); /* in: index corresponding to page */
427
/********************************************************************
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
/****************************************************************//**
428
424
Parses the redo log record for delete marking or unmarking of a secondary
426
@return end of log record or NULL */
432
429
btr_cur_parse_del_mark_set_sec_rec(
433
430
/*===============================*/
434
/* out: end of log record or NULL */
435
byte* ptr, /* in: buffer */
436
byte* end_ptr,/* in: buffer end */
437
page_t* page, /* in/out: page or NULL */
438
page_zip_des_t* page_zip);/* in/out: compressed page, or NULL */
439
/***********************************************************************
440
Estimates the number of rows in a given index range. */
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 */
443
441
btr_estimate_n_rows_in_range(
444
442
/*=========================*/
445
/* out: estimated number of rows */
446
dict_index_t* index, /* in: index */
447
const dtuple_t* tuple1, /* in: range start, may also be empty tuple */
448
ulint mode1, /* in: search mode for range start */
449
const dtuple_t* tuple2, /* in: range end, may also be empty tuple */
450
ulint mode2); /* in: search mode for range end */
451
/***********************************************************************
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
/*******************************************************************//**
452
449
Estimates the number of different key values in a given index, for
453
450
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
454
451
The estimates are stored in the array index->stat_n_diff_key_vals. */
530
527
from purge where 'data' is located on
531
528
an undo log page, not an index
533
byte* field_ref, /* in/out: field reference */
534
const rec_t* rec, /* in: record containing field_ref, for
530
byte* field_ref, /*!< in/out: field reference */
531
const rec_t* rec, /*!< in: record containing field_ref, for
535
532
page_zip_write_blob_ptr(), or NULL */
536
const ulint* offsets, /* in: rec_get_offsets(rec, index),
533
const ulint* offsets, /*!< in: rec_get_offsets(rec, index),
538
page_zip_des_t* page_zip, /* in: compressed page corresponding
535
page_zip_des_t* page_zip, /*!< in: compressed page corresponding
539
536
to rec, or NULL if rec == NULL */
540
ulint i, /* in: field number of field_ref;
537
ulint i, /*!< in: field number of field_ref;
541
538
ignored if rec == NULL */
542
enum trx_rb_ctx rb_ctx, /* in: rollback context */
543
mtr_t* local_mtr); /* in: mtr containing the latch to
539
enum trx_rb_ctx rb_ctx, /*!< in: rollback context */
540
mtr_t* local_mtr); /*!< in: mtr containing the latch to
544
541
data an an X-latch to the index
546
/***********************************************************************
543
/*******************************************************************//**
547
544
Copies the prefix of an externally stored field of a record. The
548
clustered index record must be protected by a lock or a page latch. */
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 */
551
550
btr_copy_externally_stored_field_prefix(
552
551
/*====================================*/
553
/* out: the length of the copied field,
554
or 0 if the column is being or has been
556
byte* buf, /* out: the field, or a prefix of it */
557
ulint len, /* in: length of buf, in bytes */
558
ulint zip_size,/* in: nonzero=compressed BLOB page size,
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,
559
555
zero for uncompressed BLOBs */
560
const byte* data, /* in: 'internally' stored part of the
556
const byte* data, /*!< in: 'internally' stored part of the
561
557
field containing also the reference to
562
558
the external part; must be protected by
563
559
a lock or a page latch */
564
ulint local_len);/* in: length of data, in bytes */
565
/***********************************************************************
566
Copies an externally stored field of a record to mem heap. */
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 */
569
566
btr_rec_copy_externally_stored_field(
570
567
/*=================================*/
571
/* out: the field copied to heap */
572
const rec_t* rec, /* in: record in a clustered index;
568
const rec_t* rec, /*!< in: record in a clustered index;
573
569
must be protected by a lock or a page latch */
574
const ulint* offsets,/* in: array returned by rec_get_offsets() */
575
ulint zip_size,/* in: nonzero=compressed BLOB page size,
570
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
571
ulint zip_size,/*!< in: nonzero=compressed BLOB page size,
576
572
zero for uncompressed BLOBs */
577
ulint no, /* in: field number */
578
ulint* len, /* out: length of the field */
579
mem_heap_t* heap); /* in: mem heap */
580
/***********************************************************************
573
ulint no, /*!< in: field number */
574
ulint* len, /*!< out: length of the field */
575
mem_heap_t* heap); /*!< in: mem heap */
576
/*******************************************************************//**
581
577
Flags the data tuple fields that are marked as extern storage in the
582
578
update vector. We use this function to remember which fields we must
583
mark as extern storage in a record inserted for an update. */
579
mark as extern storage in a record inserted for an update.
580
@return number of flagged external columns */
586
583
btr_push_update_extern_fields(
587
584
/*==========================*/
588
/* out: number of flagged external columns */
589
dtuple_t* tuple, /* in/out: data tuple */
590
const upd_t* update, /* in: update vector */
591
mem_heap_t* heap) /* in: memory heap */
585
dtuple_t* tuple, /*!< in/out: data tuple */
586
const upd_t* update, /*!< in: update vector */
587
mem_heap_t* heap) /*!< in: memory heap */
592
588
__attribute__((nonnull));
594
590
/*######################################################################*/
596
/* In the pessimistic delete, if the page data size drops below this
592
/** In the pessimistic delete, if the page data size drops below this
597
593
limit, merging it to a neighbor is tried */
599
594
#define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)
601
/* A slot in the path array. We store here info on a search path down the
596
/** A slot in the path array. We store here info on a search path down the
602
597
tree. Each slot contains data on a single level of the tree. */
604
599
typedef struct btr_path_struct btr_path_t;
605
600
struct btr_path_struct{
606
ulint nth_rec; /* index of the record
601
ulint nth_rec; /*!< index of the record
607
602
where the page cursor stopped on
608
603
this level (index in alphabetical
609
604
order); value ULINT_UNDEFINED
610
605
denotes array end */
611
ulint n_recs; /* number of records on the page */
614
#define BTR_PATH_ARRAY_N_SLOTS 250 /* size of path array (in slots) */
616
/* The tree cursor: the definition appears here only for the compiler
606
ulint n_recs; /*!< number of records on the page */
609
#define BTR_PATH_ARRAY_N_SLOTS 250 /*!< size of path array (in slots) */
611
/** Values for the flag documenting the used search method */
612
enum btr_cur_method {
613
BTR_CUR_HASH = 1, /*!< successful shortcut using
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
620
BTR_CUR_BINARY, /*!< success using the binary search */
621
BTR_CUR_INSERT_TO_IBUF, /*!< performed the intended insert to
625
/** The tree cursor: the definition appears here only for the compiler
617
626
to know struct size! */
619
627
struct btr_cur_struct {
620
dict_index_t* index; /* index where positioned */
621
page_cur_t page_cur; /* page cursor */
622
buf_block_t* left_block; /* this field is used to store
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
623
631
a pointer to the left neighbor
624
632
page, in the cases
625
633
BTR_SEARCH_PREV and
626
634
BTR_MODIFY_PREV */
627
635
/*------------------------------*/
628
que_thr_t* thr; /* this field is only used when
629
btr_cur_search_... is called for an
630
index entry insertion: the calling
631
query thread is passed here to be
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
632
641
used in the insert buffer */
633
642
/*------------------------------*/
634
/* The following fields are used in btr_cur_search... to pass
636
ulint flag; /* BTR_CUR_HASH, BTR_CUR_HASH_FAIL,
638
BTR_CUR_INSERT_TO_IBUF */
639
ulint tree_height; /* Tree height if the search is done
643
/** The following fields are used in
644
btr_cur_search_to_nth_level to pass information: */
646
enum btr_cur_method flag; /*!< Search method used */
647
ulint tree_height; /*!< Tree height if the search is done
640
648
for a pessimistic insert or update
642
ulint up_match; /* If the search mode was PAGE_CUR_LE,
650
ulint up_match; /*!< If the search mode was PAGE_CUR_LE,
643
651
the number of matched fields to the
644
652
the first user record to the right of
645
653
the cursor record after
654
btr_cur_search_to_nth_level;
647
655
for the mode PAGE_CUR_GE, the matched
648
656
fields to the first user record AT THE
649
657
CURSOR or to the right of it;
653
661
record if that record is on a
654
662
different leaf page! (See the note in
655
663
row_ins_duplicate_key.) */
656
ulint up_bytes; /* number of matched bytes to the
664
ulint up_bytes; /*!< number of matched bytes to the
657
665
right at the time cursor positioned;
658
666
only used internally in searches: not
659
667
defined after the search */
660
ulint low_match; /* if search mode was PAGE_CUR_LE,
668
ulint low_match; /*!< if search mode was PAGE_CUR_LE,
661
669
the number of matched fields to the
662
670
first user record AT THE CURSOR or
663
671
to the left of it after
672
btr_cur_search_to_nth_level;
665
673
NOT defined for PAGE_CUR_GE or any
666
674
other search modes; see also the NOTE
668
ulint low_bytes; /* number of matched bytes to the
676
ulint low_bytes; /*!< number of matched bytes to the
669
677
right at the time cursor positioned;
670
678
only used internally in searches: not
671
679
defined after the search */
672
ulint n_fields; /* prefix length used in a hash
680
ulint n_fields; /*!< prefix length used in a hash
673
681
search if hash_node != NULL */
674
ulint n_bytes; /* hash prefix bytes if hash_node !=
682
ulint n_bytes; /*!< hash prefix bytes if hash_node !=
676
ulint fold; /* fold value used in the search if
684
ulint fold; /*!< fold value used in the search if
677
685
flag is BTR_CUR_HASH */
678
686
/*------------------------------*/
679
btr_path_t* path_arr; /* in estimating the number of
688
btr_path_t* path_arr; /*!< in estimating the number of
680
689
rows in range, we store in this array
681
690
information of the path through
685
/* Values for the flag documenting the used search method */
686
#define BTR_CUR_HASH 1 /* successful shortcut using the hash
688
#define BTR_CUR_HASH_FAIL 2 /* failure using hash, success using
689
binary search: the misleading hash
690
reference is stored in the field
691
hash_node, and might be necessary to
693
#define BTR_CUR_BINARY 3 /* success using the binary search */
694
#define BTR_CUR_INSERT_TO_IBUF 4 /* performed the intended insert to
697
/* If pessimistic delete fails because of lack of file space,
698
there is still a good change of success a little later: try this many times,
699
and sleep this many microseconds in between */
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
700
697
#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
701
#define BTR_CUR_RETRY_SLEEP_TIME 50000
703
/* The reference in a field for which data is stored on a different page.
703
/** The reference in a field for which data is stored on a different page.
704
704
The reference is at the end of the 'locally' stored part of the field.
705
705
'Locally' means storage in the index record.
706
706
We store locally a long enough prefix of each column so that we can determine
707
707
the ordering parts of each index record without looking into the externally
710
/*--------------------------------------*/
711
#define BTR_EXTERN_SPACE_ID 0 /* space id where stored */
712
#define BTR_EXTERN_PAGE_NO 4 /* page no where stored */
713
#define BTR_EXTERN_OFFSET 8 /* offset of BLOB header
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
715
#define BTR_EXTERN_LEN 12 /* 8 bytes containing the
714
#define BTR_EXTERN_LEN 12 /*!< 8 bytes containing the
716
715
length of the externally
717
716
stored part of the BLOB.
718
717
The 2 highest bits are
719
718
reserved to the flags below. */
720
/*--------------------------------------*/
719
/*-------------------------------------- @} */
721
720
/* #define BTR_EXTERN_FIELD_REF_SIZE 20 // moved to btr0types.h */
723
/* The highest bit of BTR_EXTERN_LEN (i.e., the highest bit of the byte
724
at lowest address) is set to 1 if this field does not 'own' the externally
725
stored field; only the owner field is allowed to free the field in purge!
726
If the 2nd highest bit is 1 then it means that the externally stored field
727
was inherited from an earlier version of the row. In rollback we are not
728
allowed to free an inherited external field. */
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! */
730
726
#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. */
731
732
#define BTR_EXTERN_INHERITED_FLAG 64
734
/** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
733
735
extern ulint btr_cur_n_non_sea;
736
/** Number of successful adaptive hash index lookups in
737
btr_cur_search_to_nth_level(). */
734
738
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(). */
735
742
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(). */
736
746
extern ulint btr_cur_n_sea_old;
747
#endif /* !UNIV_HOTBACKUP */
738
749
#ifndef UNIV_NONINL
739
750
#include "btr0cur.ic"