1
/*****************************************************************************
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/page0page.h
23
Created 2/2/1994 Heikki Tuuri
24
*******************************************************/
31
#include "page0types.h"
34
#include "data0data.h"
35
#include "dict0dict.h"
40
#ifdef UNIV_MATERIALIZE
48
Index page header starts at the first offset left free by the FIL-module */
50
typedef byte page_header_t;
52
#define PAGE_HEADER FSEG_PAGE_DATA /* index page header starts at this
54
/*-----------------------------*/
55
#define PAGE_N_DIR_SLOTS 0 /* number of slots in page directory */
56
#define PAGE_HEAP_TOP 2 /* pointer to record heap top */
57
#define PAGE_N_HEAP 4 /* number of records in the heap,
58
bit 15=flag: new-style compact page format */
59
#define PAGE_FREE 6 /* pointer to start of page free record list */
60
#define PAGE_GARBAGE 8 /* number of bytes in deleted records */
61
#define PAGE_LAST_INSERT 10 /* pointer to the last inserted record, or
62
NULL if this info has been reset by a delete,
64
#define PAGE_DIRECTION 12 /* last insert direction: PAGE_LEFT, ... */
65
#define PAGE_N_DIRECTION 14 /* number of consecutive inserts to the same
67
#define PAGE_N_RECS 16 /* number of user records on the page */
68
#define PAGE_MAX_TRX_ID 18 /* highest id of a trx which may have modified
69
a record on the page; a dulint; defined only
70
in secondary indexes and in the insert buffer
71
tree; NOTE: this may be modified only
72
when the thread has an x-latch to the page,
73
and ALSO an x-latch to btr_search_latch
74
if there is a hash index to the page! */
75
#define PAGE_HEADER_PRIV_END 26 /* end of private data structure of the page
76
header which are set in a page create */
78
#define PAGE_LEVEL 26 /* level of the node in an index tree; the
79
leaf level is the level 0 */
80
#define PAGE_INDEX_ID 28 /* index id where the page belongs */
81
#define PAGE_BTR_SEG_LEAF 36 /* file segment header for the leaf pages in
82
a B-tree: defined only on the root page of a
83
B-tree, but not in the root of an ibuf tree */
84
#define PAGE_BTR_IBUF_FREE_LIST PAGE_BTR_SEG_LEAF
85
#define PAGE_BTR_IBUF_FREE_LIST_NODE PAGE_BTR_SEG_LEAF
86
/* in the place of PAGE_BTR_SEG_LEAF and _TOP
87
there is a free list base node if the page is
88
the root page of an ibuf tree, and at the same
89
place is the free list node if the page is in
91
#define PAGE_BTR_SEG_TOP (36 + FSEG_HEADER_SIZE)
92
/* file segment header for the non-leaf pages
93
in a B-tree: defined only on the root page of
94
a B-tree, but not in the root of an ibuf
97
#define PAGE_DATA (PAGE_HEADER + 36 + 2 * FSEG_HEADER_SIZE)
98
/* start of data on the page */
100
#define PAGE_OLD_INFIMUM (PAGE_DATA + 1 + REC_N_OLD_EXTRA_BYTES)
101
/* offset of the page infimum record on an
103
#define PAGE_OLD_SUPREMUM (PAGE_DATA + 2 + 2 * REC_N_OLD_EXTRA_BYTES + 8)
104
/* offset of the page supremum record on an
106
#define PAGE_OLD_SUPREMUM_END (PAGE_OLD_SUPREMUM + 9)
107
/* offset of the page supremum record end on
109
#define PAGE_NEW_INFIMUM (PAGE_DATA + REC_N_NEW_EXTRA_BYTES)
110
/* offset of the page infimum record on a
111
new-style compact page */
112
#define PAGE_NEW_SUPREMUM (PAGE_DATA + 2 * REC_N_NEW_EXTRA_BYTES + 8)
113
/* offset of the page supremum record on a
114
new-style compact page */
115
#define PAGE_NEW_SUPREMUM_END (PAGE_NEW_SUPREMUM + 8)
116
/* offset of the page supremum record end on
117
a new-style compact page */
118
/*-----------------------------*/
121
#define PAGE_HEAP_NO_INFIMUM 0 /* page infimum */
122
#define PAGE_HEAP_NO_SUPREMUM 1 /* page supremum */
123
#define PAGE_HEAP_NO_USER_LOW 2 /* first user record in
124
creation (insertion) order,
125
not necessarily collation order;
126
this record may have been deleted */
128
/* Directions of cursor movement */
131
#define PAGE_SAME_REC 3
132
#define PAGE_SAME_PAGE 4
133
#define PAGE_NO_DIRECTION 5
139
typedef byte page_dir_slot_t;
140
typedef page_dir_slot_t page_dir_t;
142
/* Offset of the directory start down from the page end. We call the
143
slot with the highest file address directory start, as it points to
144
the first record in the list of records. */
145
#define PAGE_DIR FIL_PAGE_DATA_END
147
/* We define a slot in the page directory as two bytes */
148
#define PAGE_DIR_SLOT_SIZE 2
150
/* The offset of the physically lower end of the directory, counted from
151
page end, when the page is empty */
152
#define PAGE_EMPTY_DIR_START (PAGE_DIR + 2 * PAGE_DIR_SLOT_SIZE)
154
/* The maximum and minimum number of records owned by a directory slot. The
155
number may drop below the minimum in the first and the last slot in the
157
#define PAGE_DIR_SLOT_MAX_N_OWNED 8
158
#define PAGE_DIR_SLOT_MIN_N_OWNED 4
160
/************************************************************//**
161
Gets the start of a page.
162
@return start of the page */
167
const void* ptr) /*!< in: pointer to page frame */
168
__attribute__((const));
169
/************************************************************//**
170
Gets the offset within a page.
171
@return offset from the start of the page */
176
const void* ptr) /*!< in: pointer to page frame */
177
__attribute__((const));
178
/*************************************************************//**
179
Returns the max trx id field value. */
184
const page_t* page); /*!< in: page */
185
/*************************************************************//**
186
Sets the max trx id field value. */
191
buf_block_t* block, /*!< in/out: page */
192
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
193
trx_id_t trx_id, /*!< in: transaction id */
194
mtr_t* mtr); /*!< in/out: mini-transaction, or NULL */
195
/*************************************************************//**
196
Sets the max trx id field value if trx_id is bigger than the previous
200
page_update_max_trx_id(
201
/*===================*/
202
buf_block_t* block, /*!< in/out: page */
203
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
204
uncompressed part will be updated, or NULL */
205
trx_id_t trx_id, /*!< in: transaction id */
206
mtr_t* mtr); /*!< in/out: mini-transaction */
207
/*************************************************************//**
208
Reads the given header field. */
211
page_header_get_field(
212
/*==================*/
213
const page_t* page, /*!< in: page */
214
ulint field); /*!< in: PAGE_N_DIR_SLOTS, ... */
215
/*************************************************************//**
216
Sets the given header field. */
219
page_header_set_field(
220
/*==================*/
221
page_t* page, /*!< in/out: page */
222
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
223
uncompressed part will be updated, or NULL */
224
ulint field, /*!< in: PAGE_N_DIR_SLOTS, ... */
225
ulint val); /*!< in: value */
226
/*************************************************************//**
227
Returns the offset stored in the given header field.
228
@return offset from the start of the page, or 0 */
231
page_header_get_offs(
232
/*=================*/
233
const page_t* page, /*!< in: page */
234
ulint field) /*!< in: PAGE_FREE, ... */
235
__attribute__((nonnull, pure));
237
/*************************************************************//**
238
Returns the pointer stored in the given header field, or NULL. */
239
#define page_header_get_ptr(page, field) \
240
(page_header_get_offs(page, field) \
241
? page + page_header_get_offs(page, field) : NULL)
242
/*************************************************************//**
243
Sets the pointer stored in the given header field. */
248
page_t* page, /*!< in/out: page */
249
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
250
uncompressed part will be updated, or NULL */
251
ulint field, /*!< in/out: PAGE_FREE, ... */
252
const byte* ptr); /*!< in: pointer or NULL*/
253
#ifndef UNIV_HOTBACKUP
254
/*************************************************************//**
255
Resets the last insert info field in the page header. Writes to mlog
256
about this operation. */
259
page_header_reset_last_insert(
260
/*==========================*/
261
page_t* page, /*!< in: page */
262
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
263
uncompressed part will be updated, or NULL */
264
mtr_t* mtr); /*!< in: mtr */
265
#endif /* !UNIV_HOTBACKUP */
266
/************************************************************//**
267
Gets the offset of the first record on the page.
268
@return offset of the first record in record list, relative from page */
271
page_get_infimum_offset(
272
/*====================*/
273
const page_t* page); /*!< in: page which must have record(s) */
274
/************************************************************//**
275
Gets the offset of the last record on the page.
276
@return offset of the last record in record list, relative from page */
279
page_get_supremum_offset(
280
/*=====================*/
281
const page_t* page); /*!< in: page which must have record(s) */
282
#define page_get_infimum_rec(page) ((page) + page_get_infimum_offset(page))
283
#define page_get_supremum_rec(page) ((page) + page_get_supremum_offset(page))
284
/************************************************************//**
285
Returns the middle record of record list. If there are an even number
286
of records in the list, returns the first record of upper half-list.
287
@return middle record */
292
page_t* page); /*!< in: page */
293
#ifndef UNIV_HOTBACKUP
294
/*************************************************************//**
295
Compares a data tuple to a physical record. Differs from the function
296
cmp_dtuple_rec_with_match in the way that the record must reside on an
297
index page, and also page infimum and supremum records can be given in
298
the parameter rec. These are considered as the negative infinity and
299
the positive infinity in the alphabetical order.
300
@return 1, 0, -1, if dtuple is greater, equal, less than rec,
301
respectively, when only the common first fields are compared */
304
page_cmp_dtuple_rec_with_match(
305
/*===========================*/
306
const dtuple_t* dtuple, /*!< in: data tuple */
307
const rec_t* rec, /*!< in: physical record on a page; may also
308
be page infimum or supremum, in which case
309
matched-parameter values below are not
311
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
312
ulint* matched_fields, /*!< in/out: number of already completely
313
matched fields; when function returns
314
contains the value for current comparison */
315
ulint* matched_bytes); /*!< in/out: number of already matched
316
bytes within the first field not completely
317
matched; when function returns contains the
318
value for current comparison */
319
#endif /* !UNIV_HOTBACKUP */
320
/*************************************************************//**
321
Gets the page number.
322
@return page number */
327
const page_t* page); /*!< in: page */
328
/*************************************************************//**
329
Gets the tablespace identifier.
335
const page_t* page); /*!< in: page */
336
/*************************************************************//**
337
Gets the number of user records on page (the infimum and supremum records
338
are not user records).
339
@return number of user records */
344
const page_t* page); /*!< in: index page */
345
/***************************************************************//**
346
Returns the number of records before the given record in chain.
347
The number includes infimum and supremum records.
348
@return number of records */
351
page_rec_get_n_recs_before(
352
/*=======================*/
353
const rec_t* rec); /*!< in: the physical record */
354
/*************************************************************//**
355
Gets the number of records in the heap.
356
@return number of user records */
361
const page_t* page); /*!< in: index page */
362
/*************************************************************//**
363
Sets the number of records in the heap. */
368
page_t* page, /*!< in/out: index page */
369
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
370
uncompressed part will be updated, or NULL.
371
Note that the size of the dense page directory
372
in the compressed page trailer is
373
n_heap * PAGE_ZIP_DIR_SLOT_SIZE. */
374
ulint n_heap);/*!< in: number of records */
375
/*************************************************************//**
376
Gets the number of dir slots in directory.
377
@return number of slots */
380
page_dir_get_n_slots(
381
/*=================*/
382
const page_t* page); /*!< in: index page */
383
/*************************************************************//**
384
Sets the number of dir slots in directory. */
387
page_dir_set_n_slots(
388
/*=================*/
389
page_t* page, /*!< in/out: page */
390
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
391
uncompressed part will be updated, or NULL */
392
ulint n_slots);/*!< in: number of slots */
394
/*************************************************************//**
395
Gets pointer to nth directory slot.
396
@return pointer to dir slot */
399
page_dir_get_nth_slot(
400
/*==================*/
401
const page_t* page, /*!< in: index page */
402
ulint n); /*!< in: position */
403
#else /* UNIV_DEBUG */
404
# define page_dir_get_nth_slot(page, n) \
405
((page) + UNIV_PAGE_SIZE - PAGE_DIR \
406
- (n + 1) * PAGE_DIR_SLOT_SIZE)
407
#endif /* UNIV_DEBUG */
408
/**************************************************************//**
409
Used to check the consistency of a record on a page.
410
@return TRUE if succeed */
415
const rec_t* rec); /*!< in: record */
416
/***************************************************************//**
417
Gets the record pointed to by a directory slot.
418
@return pointer to record */
421
page_dir_slot_get_rec(
422
/*==================*/
423
const page_dir_slot_t* slot); /*!< in: directory slot */
424
/***************************************************************//**
425
This is used to set the record offset in a directory slot. */
428
page_dir_slot_set_rec(
429
/*==================*/
430
page_dir_slot_t* slot, /*!< in: directory slot */
431
rec_t* rec); /*!< in: record on the page */
432
/***************************************************************//**
433
Gets the number of records owned by a directory slot.
434
@return number of records */
437
page_dir_slot_get_n_owned(
438
/*======================*/
439
const page_dir_slot_t* slot); /*!< in: page directory slot */
440
/***************************************************************//**
441
This is used to set the owned records field of a directory slot. */
444
page_dir_slot_set_n_owned(
445
/*======================*/
446
page_dir_slot_t*slot, /*!< in/out: directory slot */
447
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
448
ulint n); /*!< in: number of records owned by the slot */
449
/************************************************************//**
450
Calculates the space reserved for directory slots of a given
451
number of records. The exact value is a fraction number
452
n * PAGE_DIR_SLOT_SIZE / PAGE_DIR_SLOT_MIN_N_OWNED, and it is
453
rounded upwards to an integer. */
456
page_dir_calc_reserved_space(
457
/*=========================*/
458
ulint n_recs); /*!< in: number of records */
459
/***************************************************************//**
460
Looks for the directory slot which owns the given record.
461
@return the directory slot number */
464
page_dir_find_owner_slot(
465
/*=====================*/
466
const rec_t* rec); /*!< in: the physical record */
467
/************************************************************//**
468
Determine whether the page is in new-style compact format.
469
@return nonzero if the page is in compact format, zero if it is in
475
const page_t* page); /*!< in: index page */
476
/************************************************************//**
477
TRUE if the record is on a page in compact format.
478
@return nonzero if in compact format */
483
const rec_t* rec); /*!< in: record */
484
/***************************************************************//**
485
Returns the heap number of a record.
486
@return heap number */
489
page_rec_get_heap_no(
490
/*=================*/
491
const rec_t* rec); /*!< in: the physical record */
492
/************************************************************//**
493
Determine whether the page is a B-tree leaf.
494
@return TRUE if the page is a B-tree leaf */
499
const page_t* page) /*!< in: page */
500
__attribute__((nonnull, pure));
501
/************************************************************//**
502
Gets the pointer to the next record on the page.
503
@return pointer to next record */
506
page_rec_get_next_low(
507
/*==================*/
508
const rec_t* rec, /*!< in: pointer to record */
509
ulint comp); /*!< in: nonzero=compact page layout */
510
/************************************************************//**
511
Gets the pointer to the next record on the page.
512
@return pointer to next record */
517
rec_t* rec); /*!< in: pointer to record */
518
/************************************************************//**
519
Gets the pointer to the next record on the page.
520
@return pointer to next record */
523
page_rec_get_next_const(
524
/*====================*/
525
const rec_t* rec); /*!< in: pointer to record */
526
/************************************************************//**
527
Sets the pointer to the next record on the page. */
532
rec_t* rec, /*!< in: pointer to record,
533
must not be page supremum */
534
rec_t* next); /*!< in: pointer to next record,
535
must not be page infimum */
536
/************************************************************//**
537
Gets the pointer to the previous record.
538
@return pointer to previous record */
541
page_rec_get_prev_const(
542
/*====================*/
543
const rec_t* rec); /*!< in: pointer to record, must not be page
545
/************************************************************//**
546
Gets the pointer to the previous record.
547
@return pointer to previous record */
552
rec_t* rec); /*!< in: pointer to record,
553
must not be page infimum */
554
/************************************************************//**
555
TRUE if the record is a user record on the page.
556
@return TRUE if a user record */
559
page_rec_is_user_rec_low(
560
/*=====================*/
561
ulint offset) /*!< in: record offset on page */
562
__attribute__((const));
563
/************************************************************//**
564
TRUE if the record is the supremum record on a page.
565
@return TRUE if the supremum record */
568
page_rec_is_supremum_low(
569
/*=====================*/
570
ulint offset) /*!< in: record offset on page */
571
__attribute__((const));
572
/************************************************************//**
573
TRUE if the record is the infimum record on a page.
574
@return TRUE if the infimum record */
577
page_rec_is_infimum_low(
578
/*====================*/
579
ulint offset) /*!< in: record offset on page */
580
__attribute__((const));
582
/************************************************************//**
583
TRUE if the record is a user record on the page.
584
@return TRUE if a user record */
587
page_rec_is_user_rec(
588
/*=================*/
589
const rec_t* rec) /*!< in: record */
590
__attribute__((const));
591
/************************************************************//**
592
TRUE if the record is the supremum record on a page.
593
@return TRUE if the supremum record */
596
page_rec_is_supremum(
597
/*=================*/
598
const rec_t* rec) /*!< in: record */
599
__attribute__((const));
601
/************************************************************//**
602
TRUE if the record is the infimum record on a page.
603
@return TRUE if the infimum record */
608
const rec_t* rec) /*!< in: record */
609
__attribute__((const));
610
/***************************************************************//**
611
Looks for the record which owns the given record.
612
@return the owner record */
615
page_rec_find_owner_rec(
616
/*====================*/
617
rec_t* rec); /*!< in: the physical record */
618
/***********************************************************************//**
619
This is a low-level operation which is used in a database index creation
620
to update the page number of a created B-tree to a data dictionary
624
page_rec_write_index_page_no(
625
/*=========================*/
626
rec_t* rec, /*!< in: record to update */
627
ulint i, /*!< in: index of the field to update */
628
ulint page_no,/*!< in: value to write */
629
mtr_t* mtr); /*!< in: mtr */
630
/************************************************************//**
631
Returns the maximum combined size of records which can be inserted on top
633
@return maximum combined size for inserted records */
636
page_get_max_insert_size(
637
/*=====================*/
638
const page_t* page, /*!< in: index page */
639
ulint n_recs);/*!< in: number of records */
640
/************************************************************//**
641
Returns the maximum combined size of records which can be inserted on top
642
of record heap if page is first reorganized.
643
@return maximum combined size for inserted records */
646
page_get_max_insert_size_after_reorganize(
647
/*======================================*/
648
const page_t* page, /*!< in: index page */
649
ulint n_recs);/*!< in: number of records */
650
/*************************************************************//**
651
Calculates free space if a page is emptied.
652
@return free space */
655
page_get_free_space_of_empty(
656
/*=========================*/
657
ulint comp) /*!< in: nonzero=compact page format */
658
__attribute__((const));
659
/**********************************************************//**
660
Returns the base extra size of a physical record. This is the
661
size of the fixed header, independent of the record size.
662
@return REC_N_NEW_EXTRA_BYTES or REC_N_OLD_EXTRA_BYTES */
665
page_rec_get_base_extra_size(
666
/*=========================*/
667
const rec_t* rec); /*!< in: physical record */
668
/************************************************************//**
669
Returns the sum of the sizes of the records in the record list
670
excluding the infimum and supremum records.
671
@return data in bytes */
676
const page_t* page); /*!< in: index page */
677
/************************************************************//**
678
Allocates a block of memory from the head of the free list
684
page_t* page, /*!< in/out: index page */
685
page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
686
space available for inserting the record,
688
rec_t* next_rec,/*!< in: pointer to the new head of the
690
ulint need); /*!< in: number of bytes allocated */
691
/************************************************************//**
692
Allocates a block of memory from the heap of an index page.
693
@return pointer to start of allocated buffer, or NULL if allocation fails */
698
page_t* page, /*!< in/out: index page */
699
page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
700
space available for inserting the record,
702
ulint need, /*!< in: total number of bytes needed */
703
ulint* heap_no);/*!< out: this contains the heap number
704
of the allocated record
705
if allocation succeeds */
706
/************************************************************//**
707
Puts a record to free list. */
712
page_t* page, /*!< in/out: index page */
713
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
714
rec_t* rec, /*!< in: pointer to the (origin of) record */
715
dict_index_t* index, /*!< in: index of rec */
716
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
717
/**********************************************************//**
718
Create an uncompressed B-tree index page.
719
@return pointer to the page */
724
buf_block_t* block, /*!< in: a buffer block where the
726
mtr_t* mtr, /*!< in: mini-transaction handle */
727
ulint comp); /*!< in: nonzero=compact page format */
728
/**********************************************************//**
729
Create a compressed B-tree index page.
730
@return pointer to the page */
735
buf_block_t* block, /*!< in/out: a buffer frame where the
737
dict_index_t* index, /*!< in: the index of the page */
738
ulint level, /*!< in: the B-tree level of the page */
739
mtr_t* mtr); /*!< in: mini-transaction handle */
741
/*************************************************************//**
742
Differs from page_copy_rec_list_end, because this function does not
743
touch the lock table and max trx id on page or compress the page. */
746
page_copy_rec_list_end_no_locks(
747
/*============================*/
748
buf_block_t* new_block, /*!< in: index page to copy to */
749
buf_block_t* block, /*!< in: index page of rec */
750
rec_t* rec, /*!< in: record on page */
751
dict_index_t* index, /*!< in: record descriptor */
752
mtr_t* mtr); /*!< in: mtr */
753
/*************************************************************//**
754
Copies records from page to new_page, from the given record onward,
755
including that record. Infimum and supremum records are not copied.
756
The records are copied to the start of the record list on new_page.
757
@return pointer to the original successor of the infimum record on
758
new_page, or NULL on zip overflow (new_block will be decompressed) */
761
page_copy_rec_list_end(
762
/*===================*/
763
buf_block_t* new_block, /*!< in/out: index page to copy to */
764
buf_block_t* block, /*!< in: index page containing rec */
765
rec_t* rec, /*!< in: record on page */
766
dict_index_t* index, /*!< in: record descriptor */
767
mtr_t* mtr) /*!< in: mtr */
768
__attribute__((nonnull));
769
/*************************************************************//**
770
Copies records from page to new_page, up to the given record, NOT
771
including that record. Infimum and supremum records are not copied.
772
The records are copied to the end of the record list on new_page.
773
@return pointer to the original predecessor of the supremum record on
774
new_page, or NULL on zip overflow (new_block will be decompressed) */
777
page_copy_rec_list_start(
778
/*=====================*/
779
buf_block_t* new_block, /*!< in/out: index page to copy to */
780
buf_block_t* block, /*!< in: index page containing rec */
781
rec_t* rec, /*!< in: record on page */
782
dict_index_t* index, /*!< in: record descriptor */
783
mtr_t* mtr) /*!< in: mtr */
784
__attribute__((nonnull));
785
/*************************************************************//**
786
Deletes records from a page from a given record onward, including that record.
787
The infimum and supremum records are not deleted. */
790
page_delete_rec_list_end(
791
/*=====================*/
792
rec_t* rec, /*!< in: pointer to record on page */
793
buf_block_t* block, /*!< in: buffer block of the page */
794
dict_index_t* index, /*!< in: record descriptor */
795
ulint n_recs, /*!< in: number of records to delete,
796
or ULINT_UNDEFINED if not known */
797
ulint size, /*!< in: the sum of the sizes of the
798
records in the end of the chain to
799
delete, or ULINT_UNDEFINED if not known */
800
mtr_t* mtr) /*!< in: mtr */
801
__attribute__((nonnull));
802
/*************************************************************//**
803
Deletes records from page, up to the given record, NOT including
804
that record. Infimum and supremum records are not deleted. */
807
page_delete_rec_list_start(
808
/*=======================*/
809
rec_t* rec, /*!< in: record on page */
810
buf_block_t* block, /*!< in: buffer block of the page */
811
dict_index_t* index, /*!< in: record descriptor */
812
mtr_t* mtr) /*!< in: mtr */
813
__attribute__((nonnull));
814
/*************************************************************//**
815
Moves record list end to another page. Moved records include
817
@return TRUE on success; FALSE on compression failure (new_block will
821
page_move_rec_list_end(
822
/*===================*/
823
buf_block_t* new_block, /*!< in/out: index page where to move */
824
buf_block_t* block, /*!< in: index page from where to move */
825
rec_t* split_rec, /*!< in: first record to move */
826
dict_index_t* index, /*!< in: record descriptor */
827
mtr_t* mtr) /*!< in: mtr */
828
__attribute__((nonnull(1, 2, 4, 5)));
829
/*************************************************************//**
830
Moves record list start to another page. Moved records do not include
832
@return TRUE on success; FALSE on compression failure */
835
page_move_rec_list_start(
836
/*=====================*/
837
buf_block_t* new_block, /*!< in/out: index page where to move */
838
buf_block_t* block, /*!< in/out: page containing split_rec */
839
rec_t* split_rec, /*!< in: first record not to move */
840
dict_index_t* index, /*!< in: record descriptor */
841
mtr_t* mtr) /*!< in: mtr */
842
__attribute__((nonnull(1, 2, 4, 5)));
843
/****************************************************************//**
844
Splits a directory slot which owns too many records. */
849
page_t* page, /*!< in: index page */
850
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
851
uncompressed part will be written, or NULL */
852
ulint slot_no)/*!< in: the directory slot */
853
__attribute__((nonnull(1)));
854
/*************************************************************//**
855
Tries to balance the given directory slot with too few records
856
with the upper neighbor, so that there are at least the minimum number
857
of records owned by the slot; this may result in the merging of
861
page_dir_balance_slot(
862
/*==================*/
863
page_t* page, /*!< in/out: index page */
864
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
865
ulint slot_no)/*!< in: the directory slot */
866
__attribute__((nonnull(1)));
867
/**********************************************************//**
868
Parses a log record of a record list end or start deletion.
869
@return end of log record or NULL */
872
page_parse_delete_rec_list(
873
/*=======================*/
874
byte type, /*!< in: MLOG_LIST_END_DELETE,
875
MLOG_LIST_START_DELETE,
876
MLOG_COMP_LIST_END_DELETE or
877
MLOG_COMP_LIST_START_DELETE */
878
byte* ptr, /*!< in: buffer */
879
byte* end_ptr,/*!< in: buffer end */
880
buf_block_t* block, /*!< in/out: buffer block or NULL */
881
dict_index_t* index, /*!< in: record descriptor */
882
mtr_t* mtr); /*!< in: mtr or NULL */
883
/***********************************************************//**
884
Parses a redo log record of creating a page.
885
@return end of log record or NULL */
890
byte* ptr, /*!< in: buffer */
891
byte* end_ptr,/*!< in: buffer end */
892
ulint comp, /*!< in: nonzero=compact page format */
893
buf_block_t* block, /*!< in: block or NULL */
894
mtr_t* mtr); /*!< in: mtr or NULL */
895
/************************************************************//**
896
Prints record contents including the data relevant only in
897
the index page context. */
902
const rec_t* rec, /*!< in: physical record */
903
const ulint* offsets);/*!< in: record descriptor */
904
/***************************************************************//**
905
This is used to print the contents of the directory for
906
debugging purposes. */
911
page_t* page, /*!< in: index page */
912
ulint pr_n); /*!< in: print n first and n last entries */
913
/***************************************************************//**
914
This is used to print the contents of the page record list for
915
debugging purposes. */
920
buf_block_t* block, /*!< in: index page */
921
dict_index_t* index, /*!< in: dictionary index of the page */
922
ulint pr_n); /*!< in: print n first and n last entries */
923
/***************************************************************//**
924
Prints the info in a page header. */
929
const page_t* page); /*!< in: index page */
930
/***************************************************************//**
931
This is used to print the contents of the page for
932
debugging purposes. */
937
buf_block_t* block, /*!< in: index page */
938
dict_index_t* index, /*!< in: dictionary index of the page */
939
ulint dn, /*!< in: print dn first and last entries
941
ulint rn); /*!< in: print rn first and last records
943
/***************************************************************//**
944
The following is used to validate a record on a page. This function
945
differs from rec_validate as it can also check the n_owned field and
947
@return TRUE if ok */
952
rec_t* rec, /*!< in: physical record */
953
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
954
/***************************************************************//**
955
Checks that the first directory slot points to the infimum record and
956
the last to the supremum. This function is intended to track if the
957
bug fixed in 4.0.14 has caused corruption to users' databases. */
962
const page_t* page); /*!< in: index page */
963
/***************************************************************//**
964
This function checks the consistency of an index page when we do not
965
know the index. This is also resilient so that this should never crash
966
even if the page is total garbage.
967
@return TRUE if ok */
970
page_simple_validate_old(
971
/*=====================*/
972
page_t* page); /*!< in: old-style index page */
973
/***************************************************************//**
974
This function checks the consistency of an index page when we do not
975
know the index. This is also resilient so that this should never crash
976
even if the page is total garbage.
977
@return TRUE if ok */
980
page_simple_validate_new(
981
/*=====================*/
982
page_t* block); /*!< in: new-style index page */
983
/***************************************************************//**
984
This function checks the consistency of an index page.
985
@return TRUE if ok */
990
page_t* page, /*!< in: index page */
991
dict_index_t* index); /*!< in: data dictionary index containing
992
the page record type definition */
993
/***************************************************************//**
994
Looks in the page record list for a record with the given heap number.
995
@return record, NULL if not found */
998
page_find_rec_with_heap_no(
999
/*=======================*/
1000
const page_t* page, /*!< in: index page */
1001
ulint heap_no);/*!< in: heap number */
1003
#ifdef UNIV_MATERIALIZE
1005
#define UNIV_INLINE UNIV_INLINE_ORIGINAL
1009
#include "page0page.ic"