160
140
#define PAGE_DIR_SLOT_MAX_N_OWNED 8
161
141
#define PAGE_DIR_SLOT_MIN_N_OWNED 4
163
/************************************************************//**
164
Gets the start of a page.
165
@return start of the page */
143
/****************************************************************
144
Gets the start of a page. */
170
const void* ptr) /*!< in: pointer to page frame */
171
__attribute__((const));
172
/************************************************************//**
173
Gets the offset within a page.
174
@return offset from the start of the page */
149
/* out: start of the page */
150
const void* ptr) /* in: pointer to page frame */
151
__attribute__((__const__));
152
/****************************************************************
153
Gets the offset within a page. */
179
const void* ptr) /*!< in: pointer to page frame */
180
__attribute__((const));
181
/*************************************************************//**
158
/* out: offset from the start of the page */
159
const void* ptr) /* in: pointer to page frame */
160
__attribute__((__const__));
161
/*****************************************************************
182
162
Returns the max trx id field value. */
185
165
page_get_max_trx_id(
186
166
/*================*/
187
const page_t* page); /*!< in: page */
188
/*************************************************************//**
167
const page_t* page); /* in: page */
168
/*****************************************************************
189
169
Sets the max trx id field value. */
192
172
page_set_max_trx_id(
193
173
/*================*/
194
buf_block_t* block, /*!< in/out: page */
195
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
196
trx_id_t trx_id, /*!< in: transaction id */
197
mtr_t* mtr); /*!< in/out: mini-transaction, or NULL */
198
/*************************************************************//**
174
buf_block_t* block, /* in/out: page */
175
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
176
dulint trx_id);/* in: transaction id */
177
/*****************************************************************
199
178
Sets the max trx id field value if trx_id is bigger than the previous
203
182
page_update_max_trx_id(
204
183
/*===================*/
205
buf_block_t* block, /*!< in/out: page */
206
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
184
buf_block_t* block, /* in/out: page */
185
page_zip_des_t* page_zip,/* in/out: compressed page whose
207
186
uncompressed part will be updated, or NULL */
208
trx_id_t trx_id, /*!< in: transaction id */
209
mtr_t* mtr); /*!< in/out: mini-transaction */
210
/*************************************************************//**
187
dulint trx_id);/* in: transaction id */
188
/*****************************************************************
211
189
Reads the given header field. */
214
192
page_header_get_field(
215
193
/*==================*/
216
const page_t* page, /*!< in: page */
217
ulint field); /*!< in: PAGE_N_DIR_SLOTS, ... */
218
/*************************************************************//**
194
const page_t* page, /* in: page */
195
ulint field); /* in: PAGE_N_DIR_SLOTS, ... */
196
/*****************************************************************
219
197
Sets the given header field. */
222
200
page_header_set_field(
223
201
/*==================*/
224
page_t* page, /*!< in/out: page */
225
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
202
page_t* page, /* in/out: page */
203
page_zip_des_t* page_zip,/* in/out: compressed page whose
226
204
uncompressed part will be updated, or NULL */
227
ulint field, /*!< in: PAGE_N_DIR_SLOTS, ... */
228
ulint val); /*!< in: value */
229
/*************************************************************//**
230
Returns the offset stored in the given header field.
231
@return offset from the start of the page, or 0 */
205
ulint field, /* in: PAGE_N_DIR_SLOTS, ... */
206
ulint val); /* in: value */
207
/*****************************************************************
208
Returns the offset stored in the given header field. */
234
211
page_header_get_offs(
235
212
/*=================*/
236
const page_t* page, /*!< in: page */
237
ulint field) /*!< in: PAGE_FREE, ... */
213
/* out: offset from the start of the page,
215
const page_t* page, /* in: page */
216
ulint field) /* in: PAGE_FREE, ... */
238
217
__attribute__((nonnull, pure));
240
/*************************************************************//**
219
/*****************************************************************
241
220
Returns the pointer stored in the given header field, or NULL. */
242
221
#define page_header_get_ptr(page, field) \
243
222
(page_header_get_offs(page, field) \
244
223
? page + page_header_get_offs(page, field) : NULL)
245
/*************************************************************//**
224
/*****************************************************************
246
225
Sets the pointer stored in the given header field. */
249
228
page_header_set_ptr(
250
229
/*================*/
251
page_t* page, /*!< in/out: page */
252
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
230
page_t* page, /* in/out: page */
231
page_zip_des_t* page_zip,/* in/out: compressed page whose
253
232
uncompressed part will be updated, or NULL */
254
ulint field, /*!< in/out: PAGE_FREE, ... */
255
const byte* ptr); /*!< in: pointer or NULL*/
256
#ifndef UNIV_HOTBACKUP
257
/*************************************************************//**
233
ulint field, /* in/out: PAGE_FREE, ... */
234
const byte* ptr); /* in: pointer or NULL*/
235
/*****************************************************************
258
236
Resets the last insert info field in the page header. Writes to mlog
259
237
about this operation. */
262
240
page_header_reset_last_insert(
263
241
/*==========================*/
264
page_t* page, /*!< in: page */
265
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
242
page_t* page, /* in: page */
243
page_zip_des_t* page_zip,/* in/out: compressed page whose
266
244
uncompressed part will be updated, or NULL */
267
mtr_t* mtr); /*!< in: mtr */
268
#endif /* !UNIV_HOTBACKUP */
269
/************************************************************//**
270
Gets the offset of the first record on the page.
271
@return offset of the first record in record list, relative from page */
245
mtr_t* mtr); /* in: mtr */
246
/****************************************************************
247
Gets the offset of the first record on the page. */
274
250
page_get_infimum_offset(
275
251
/*====================*/
276
const page_t* page); /*!< in: page which must have record(s) */
277
/************************************************************//**
278
Gets the offset of the last record on the page.
279
@return offset of the last record in record list, relative from page */
252
/* out: offset of the first record
253
in record list, relative from page */
254
const page_t* page); /* in: page which must have record(s) */
255
/****************************************************************
256
Gets the offset of the last record on the page. */
282
259
page_get_supremum_offset(
283
260
/*=====================*/
284
const page_t* page); /*!< in: page which must have record(s) */
261
/* out: offset of the last record in
262
record list, relative from page */
263
const page_t* page); /* in: page which must have record(s) */
285
264
#define page_get_infimum_rec(page) ((page) + page_get_infimum_offset(page))
286
265
#define page_get_supremum_rec(page) ((page) + page_get_supremum_offset(page))
287
/************************************************************//**
266
/****************************************************************
288
267
Returns the middle record of record list. If there are an even number
289
of records in the list, returns the first record of upper half-list.
290
@return middle record */
268
of records in the list, returns the first record of upper half-list. */
293
271
page_get_middle_rec(
294
272
/*================*/
295
page_t* page); /*!< in: page */
296
#ifndef UNIV_HOTBACKUP
297
/*************************************************************//**
273
/* out: middle record */
274
page_t* page); /* in: page */
275
/*****************************************************************
298
276
Compares a data tuple to a physical record. Differs from the function
299
277
cmp_dtuple_rec_with_match in the way that the record must reside on an
300
278
index page, and also page infimum and supremum records can be given in
301
279
the parameter rec. These are considered as the negative infinity and
302
the positive infinity in the alphabetical order.
303
@return 1, 0, -1, if dtuple is greater, equal, less than rec,
304
respectively, when only the common first fields are compared */
280
the positive infinity in the alphabetical order. */
307
283
page_cmp_dtuple_rec_with_match(
308
284
/*===========================*/
309
const dtuple_t* dtuple, /*!< in: data tuple */
310
const rec_t* rec, /*!< in: physical record on a page; may also
285
/* out: 1, 0, -1, if dtuple is greater, equal,
286
less than rec, respectively, when only the
287
common first fields are compared */
288
const dtuple_t* dtuple, /* in: data tuple */
289
const rec_t* rec, /* in: physical record on a page; may also
311
290
be page infimum or supremum, in which case
312
291
matched-parameter values below are not
314
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
315
ulint* matched_fields, /*!< in/out: number of already completely
293
const ulint* offsets,/* in: array returned by rec_get_offsets() */
294
ulint* matched_fields, /* in/out: number of already completely
316
295
matched fields; when function returns
317
296
contains the value for current comparison */
318
ulint* matched_bytes); /*!< in/out: number of already matched
297
ulint* matched_bytes); /* in/out: number of already matched
319
298
bytes within the first field not completely
320
299
matched; when function returns contains the
321
300
value for current comparison */
322
#endif /* !UNIV_HOTBACKUP */
323
/*************************************************************//**
324
Gets the page number.
325
@return page number */
301
/*****************************************************************
302
Gets the page number. */
328
305
page_get_page_no(
329
306
/*=============*/
330
const page_t* page); /*!< in: page */
331
/*************************************************************//**
332
Gets the tablespace identifier.
307
/* out: page number */
308
const page_t* page); /* in: page */
309
/*****************************************************************
310
Gets the tablespace identifier. */
336
313
page_get_space_id(
337
314
/*==============*/
338
const page_t* page); /*!< in: page */
339
/*************************************************************//**
316
const page_t* page); /* in: page */
317
/*****************************************************************
340
318
Gets the number of user records on page (the infimum and supremum records
341
are not user records).
342
@return number of user records */
319
are not user records). */
347
const page_t* page); /*!< in: index page */
348
/***************************************************************//**
324
/* out: number of user records */
325
const page_t* page); /* in: index page */
326
/*******************************************************************
349
327
Returns the number of records before the given record in chain.
350
The number includes infimum and supremum records.
351
@return number of records */
328
The number includes infimum and supremum records. */
354
331
page_rec_get_n_recs_before(
355
332
/*=======================*/
356
const rec_t* rec); /*!< in: the physical record */
357
/*************************************************************//**
358
Gets the number of records in the heap.
359
@return number of user records */
333
/* out: number of records */
334
const rec_t* rec); /* in: the physical record */
335
/*****************************************************************
336
Gets the number of records in the heap. */
362
339
page_dir_get_n_heap(
363
340
/*================*/
364
const page_t* page); /*!< in: index page */
365
/*************************************************************//**
341
/* out: number of user records */
342
const page_t* page); /* in: index page */
343
/*****************************************************************
366
344
Sets the number of records in the heap. */
369
347
page_dir_set_n_heap(
370
348
/*================*/
371
page_t* page, /*!< in/out: index page */
372
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
349
page_t* page, /* in/out: index page */
350
page_zip_des_t* page_zip,/* in/out: compressed page whose
373
351
uncompressed part will be updated, or NULL.
374
352
Note that the size of the dense page directory
375
353
in the compressed page trailer is
376
354
n_heap * PAGE_ZIP_DIR_SLOT_SIZE. */
377
ulint n_heap);/*!< in: number of records */
378
/*************************************************************//**
379
Gets the number of dir slots in directory.
380
@return number of slots */
355
ulint n_heap);/* in: number of records */
356
/*****************************************************************
357
Gets the number of dir slots in directory. */
383
360
page_dir_get_n_slots(
384
361
/*=================*/
385
const page_t* page); /*!< in: index page */
386
/*************************************************************//**
362
/* out: number of slots */
363
const page_t* page); /* in: index page */
364
/*****************************************************************
387
365
Sets the number of dir slots in directory. */
390
368
page_dir_set_n_slots(
391
369
/*=================*/
392
page_t* page, /*!< in/out: page */
393
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
370
page_t* page, /* in/out: page */
371
page_zip_des_t* page_zip,/* in/out: compressed page whose
394
372
uncompressed part will be updated, or NULL */
395
ulint n_slots);/*!< in: number of slots */
373
ulint n_slots);/* in: number of slots */
396
374
#ifdef UNIV_DEBUG
397
/*************************************************************//**
398
Gets pointer to nth directory slot.
399
@return pointer to dir slot */
375
/*****************************************************************
376
Gets pointer to nth directory slot. */
402
379
page_dir_get_nth_slot(
403
380
/*==================*/
404
const page_t* page, /*!< in: index page */
405
ulint n); /*!< in: position */
381
/* out: pointer to dir slot */
382
const page_t* page, /* in: index page */
383
ulint n); /* in: position */
406
384
#else /* UNIV_DEBUG */
407
385
# define page_dir_get_nth_slot(page, n) \
408
386
((page) + UNIV_PAGE_SIZE - PAGE_DIR \
409
387
- (n + 1) * PAGE_DIR_SLOT_SIZE)
410
388
#endif /* UNIV_DEBUG */
411
/**************************************************************//**
412
Used to check the consistency of a record on a page.
413
@return TRUE if succeed */
389
/******************************************************************
390
Used to check the consistency of a record on a page. */
418
const rec_t* rec); /*!< in: record */
419
/***************************************************************//**
420
Gets the record pointed to by a directory slot.
421
@return pointer to record */
395
/* out: TRUE if succeed */
396
const rec_t* rec); /* in: record */
397
/*******************************************************************
398
Gets the record pointed to by a directory slot. */
424
401
page_dir_slot_get_rec(
425
402
/*==================*/
426
const page_dir_slot_t* slot); /*!< in: directory slot */
427
/***************************************************************//**
403
/* out: pointer to record */
404
const page_dir_slot_t* slot); /* in: directory slot */
405
/*******************************************************************
428
406
This is used to set the record offset in a directory slot. */
431
409
page_dir_slot_set_rec(
432
410
/*==================*/
433
page_dir_slot_t* slot, /*!< in: directory slot */
434
rec_t* rec); /*!< in: record on the page */
435
/***************************************************************//**
436
Gets the number of records owned by a directory slot.
437
@return number of records */
411
page_dir_slot_t* slot, /* in: directory slot */
412
rec_t* rec); /* in: record on the page */
413
/*******************************************************************
414
Gets the number of records owned by a directory slot. */
440
417
page_dir_slot_get_n_owned(
441
418
/*======================*/
442
const page_dir_slot_t* slot); /*!< in: page directory slot */
443
/***************************************************************//**
419
/* out: number of records */
420
const page_dir_slot_t* slot); /* in: page directory slot */
421
/*******************************************************************
444
422
This is used to set the owned records field of a directory slot. */
447
425
page_dir_slot_set_n_owned(
448
426
/*======================*/
449
page_dir_slot_t*slot, /*!< in/out: directory slot */
450
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
451
ulint n); /*!< in: number of records owned by the slot */
452
/************************************************************//**
427
page_dir_slot_t*slot, /* in/out: directory slot */
428
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
429
ulint n); /* in: number of records owned by the slot */
430
/****************************************************************
453
431
Calculates the space reserved for directory slots of a given
454
432
number of records. The exact value is a fraction number
455
433
n * PAGE_DIR_SLOT_SIZE / PAGE_DIR_SLOT_MIN_N_OWNED, and it is
459
437
page_dir_calc_reserved_space(
460
438
/*=========================*/
461
ulint n_recs); /*!< in: number of records */
462
/***************************************************************//**
463
Looks for the directory slot which owns the given record.
464
@return the directory slot number */
439
ulint n_recs); /* in: number of records */
440
/*******************************************************************
441
Looks for the directory slot which owns the given record. */
467
444
page_dir_find_owner_slot(
468
445
/*=====================*/
469
const rec_t* rec); /*!< in: the physical record */
470
/************************************************************//**
471
Determine whether the page is in new-style compact format.
472
@return nonzero if the page is in compact format, zero if it is in
446
/* out: the directory slot number */
447
const rec_t* rec); /* in: the physical record */
448
/****************************************************************
449
Determine whether the page is in new-style compact format. */
478
const page_t* page); /*!< in: index page */
479
/************************************************************//**
480
TRUE if the record is on a page in compact format.
481
@return nonzero if in compact format */
454
/* out: nonzero if the page is in compact
455
format, zero if it is in old-style format */
456
const page_t* page); /* in: index page */
457
/****************************************************************
458
TRUE if the record is on a page in compact format. */
484
461
page_rec_is_comp(
485
462
/*=============*/
486
const rec_t* rec); /*!< in: record */
487
/***************************************************************//**
488
Returns the heap number of a record.
489
@return heap number */
463
/* out: nonzero if in compact format */
464
const rec_t* rec); /* in: record */
465
/*******************************************************************
466
Returns the heap number of a record. */
492
469
page_rec_get_heap_no(
493
470
/*=================*/
494
const rec_t* rec); /*!< in: the physical record */
495
/************************************************************//**
496
Determine whether the page is a B-tree leaf.
497
@return TRUE if the page is a B-tree leaf */
471
/* out: heap number */
472
const rec_t* rec); /* in: the physical record */
473
/****************************************************************
474
Determine whether the page is a B-tree leaf. */
502
const page_t* page) /*!< in: page */
479
/* out: TRUE if the page is a B-tree leaf */
480
const page_t* page) /* in: page */
503
481
__attribute__((nonnull, pure));
504
/************************************************************//**
505
Gets the pointer to the next record on the page.
506
@return pointer to next record */
482
/****************************************************************
483
Gets the pointer to the next record on the page. */
509
486
page_rec_get_next_low(
510
487
/*==================*/
511
const rec_t* rec, /*!< in: pointer to record */
512
ulint comp); /*!< in: nonzero=compact page layout */
513
/************************************************************//**
514
Gets the pointer to the next record on the page.
515
@return pointer to next record */
488
/* out: pointer to next record */
489
const rec_t* rec, /* in: pointer to record */
490
ulint comp); /* in: nonzero=compact page layout */
491
/****************************************************************
492
Gets the pointer to the next record on the page. */
518
495
page_rec_get_next(
519
496
/*==============*/
520
rec_t* rec); /*!< in: pointer to record */
521
/************************************************************//**
522
Gets the pointer to the next record on the page.
523
@return pointer to next record */
497
/* out: pointer to next record */
498
rec_t* rec); /* in: pointer to record */
499
/****************************************************************
500
Gets the pointer to the next record on the page. */
526
503
page_rec_get_next_const(
527
504
/*====================*/
528
const rec_t* rec); /*!< in: pointer to record */
529
/************************************************************//**
505
/* out: pointer to next record */
506
const rec_t* rec); /* in: pointer to record */
507
/****************************************************************
530
508
Sets the pointer to the next record on the page. */
533
511
page_rec_set_next(
534
512
/*==============*/
535
rec_t* rec, /*!< in: pointer to record,
513
rec_t* rec, /* in: pointer to record,
536
514
must not be page supremum */
537
rec_t* next); /*!< in: pointer to next record,
515
rec_t* next); /* in: pointer to next record,
538
516
must not be page infimum */
539
/************************************************************//**
540
Gets the pointer to the previous record.
541
@return pointer to previous record */
517
/****************************************************************
518
Gets the pointer to the previous record. */
544
521
page_rec_get_prev_const(
545
522
/*====================*/
546
const rec_t* rec); /*!< in: pointer to record, must not be page
523
/* out: pointer to previous record */
524
const rec_t* rec); /* in: pointer to record, must not be page
548
/************************************************************//**
549
Gets the pointer to the previous record.
550
@return pointer to previous record */
526
/****************************************************************
527
Gets the pointer to the previous record. */
553
530
page_rec_get_prev(
554
531
/*==============*/
555
rec_t* rec); /*!< in: pointer to record,
532
/* out: pointer to previous record */
533
rec_t* rec); /* in: pointer to record,
556
534
must not be page infimum */
557
/************************************************************//**
558
TRUE if the record is a user record on the page.
559
@return TRUE if a user record */
535
/****************************************************************
536
TRUE if the record is a user record on the page. */
562
539
page_rec_is_user_rec_low(
563
540
/*=====================*/
564
ulint offset) /*!< in: record offset on page */
565
__attribute__((const));
566
/************************************************************//**
567
TRUE if the record is the supremum record on a page.
568
@return TRUE if the supremum record */
541
/* out: TRUE if a user record */
542
ulint offset) /* in: record offset on page */
543
__attribute__((__const__));
544
/****************************************************************
545
TRUE if the record is the supremum record on a page. */
571
548
page_rec_is_supremum_low(
572
549
/*=====================*/
573
ulint offset) /*!< in: record offset on page */
574
__attribute__((const));
575
/************************************************************//**
576
TRUE if the record is the infimum record on a page.
577
@return TRUE if the infimum record */
550
/* out: TRUE if the supremum record */
551
ulint offset) /* in: record offset on page */
552
__attribute__((__const__));
553
/****************************************************************
554
TRUE if the record is the infimum record on a page. */
580
557
page_rec_is_infimum_low(
581
558
/*====================*/
582
ulint offset) /*!< in: record offset on page */
583
__attribute__((const));
559
/* out: TRUE if the infimum record */
560
ulint offset) /* in: record offset on page */
561
__attribute__((__const__));
585
/************************************************************//**
586
TRUE if the record is a user record on the page.
587
@return TRUE if a user record */
563
/****************************************************************
564
TRUE if the record is a user record on the page. */
590
567
page_rec_is_user_rec(
591
568
/*=================*/
592
const rec_t* rec) /*!< in: record */
593
__attribute__((const));
594
/************************************************************//**
595
TRUE if the record is the supremum record on a page.
596
@return TRUE if the supremum record */
569
/* out: TRUE if a user record */
570
const rec_t* rec) /* in: record */
571
__attribute__((__const__));
572
/****************************************************************
573
TRUE if the record is the supremum record on a page. */
599
576
page_rec_is_supremum(
600
577
/*=================*/
601
const rec_t* rec) /*!< in: record */
602
__attribute__((const));
578
/* out: TRUE if the supremum record */
579
const rec_t* rec) /* in: record */
580
__attribute__((__const__));
604
/************************************************************//**
605
TRUE if the record is the infimum record on a page.
606
@return TRUE if the infimum record */
582
/****************************************************************
583
TRUE if the record is the infimum record on a page. */
609
586
page_rec_is_infimum(
610
587
/*================*/
611
const rec_t* rec) /*!< in: record */
612
__attribute__((const));
613
/***************************************************************//**
614
Looks for the record which owns the given record.
615
@return the owner record */
588
/* out: TRUE if the infimum record */
589
const rec_t* rec) /* in: record */
590
__attribute__((__const__));
591
/*******************************************************************
592
Looks for the record which owns the given record. */
618
595
page_rec_find_owner_rec(
619
596
/*====================*/
620
rec_t* rec); /*!< in: the physical record */
621
/***********************************************************************//**
597
/* out: the owner record */
598
rec_t* rec); /* in: the physical record */
599
/***************************************************************************
622
600
This is a low-level operation which is used in a database index creation
623
601
to update the page number of a created B-tree to a data dictionary
627
605
page_rec_write_index_page_no(
628
606
/*=========================*/
629
rec_t* rec, /*!< in: record to update */
630
ulint i, /*!< in: index of the field to update */
631
ulint page_no,/*!< in: value to write */
632
mtr_t* mtr); /*!< in: mtr */
633
/************************************************************//**
607
rec_t* rec, /* in: record to update */
608
ulint i, /* in: index of the field to update */
609
ulint page_no,/* in: value to write */
610
mtr_t* mtr); /* in: mtr */
611
/****************************************************************
634
612
Returns the maximum combined size of records which can be inserted on top
636
@return maximum combined size for inserted records */
639
616
page_get_max_insert_size(
640
617
/*=====================*/
641
const page_t* page, /*!< in: index page */
642
ulint n_recs);/*!< in: number of records */
643
/************************************************************//**
618
/* out: maximum combined size for
620
const page_t* page, /* in: index page */
621
ulint n_recs);/* in: number of records */
622
/****************************************************************
644
623
Returns the maximum combined size of records which can be inserted on top
645
of record heap if page is first reorganized.
646
@return maximum combined size for inserted records */
624
of record heap if page is first reorganized. */
649
627
page_get_max_insert_size_after_reorganize(
650
628
/*======================================*/
651
const page_t* page, /*!< in: index page */
652
ulint n_recs);/*!< in: number of records */
653
/*************************************************************//**
654
Calculates free space if a page is emptied.
655
@return free space */
629
/* out: maximum combined size for
631
const page_t* page, /* in: index page */
632
ulint n_recs);/* in: number of records */
633
/*****************************************************************
634
Calculates free space if a page is emptied. */
658
637
page_get_free_space_of_empty(
659
638
/*=========================*/
660
ulint comp) /*!< in: nonzero=compact page format */
661
__attribute__((const));
662
/**********************************************************//**
639
/* out: free space */
640
ulint comp) /* in: nonzero=compact page format */
641
__attribute__((__const__));
642
/**************************************************************
663
643
Returns the base extra size of a physical record. This is the
664
size of the fixed header, independent of the record size.
665
@return REC_N_NEW_EXTRA_BYTES or REC_N_OLD_EXTRA_BYTES */
644
size of the fixed header, independent of the record size. */
668
647
page_rec_get_base_extra_size(
669
648
/*=========================*/
670
const rec_t* rec); /*!< in: physical record */
671
/************************************************************//**
649
/* out: REC_N_NEW_EXTRA_BYTES
650
or REC_N_OLD_EXTRA_BYTES */
651
const rec_t* rec); /* in: physical record */
652
/****************************************************************
672
653
Returns the sum of the sizes of the records in the record list
673
excluding the infimum and supremum records.
674
@return data in bytes */
654
excluding the infimum and supremum records. */
677
657
page_get_data_size(
678
658
/*===============*/
679
const page_t* page); /*!< in: index page */
680
/************************************************************//**
659
/* out: data in bytes */
660
const page_t* page); /* in: index page */
661
/****************************************************************
681
662
Allocates a block of memory from the head of the free list
682
663
of an index page. */
685
666
page_mem_alloc_free(
686
667
/*================*/
687
page_t* page, /*!< in/out: index page */
688
page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
668
page_t* page, /* in/out: index page */
669
page_zip_des_t* page_zip,/* in/out: compressed page with enough
689
670
space available for inserting the record,
691
rec_t* next_rec,/*!< in: pointer to the new head of the
672
rec_t* next_rec,/* in: pointer to the new head of the
692
673
free record list */
693
ulint need); /*!< in: number of bytes allocated */
694
/************************************************************//**
695
Allocates a block of memory from the heap of an index page.
696
@return pointer to start of allocated buffer, or NULL if allocation fails */
674
ulint need); /* in: number of bytes allocated */
675
/****************************************************************
676
Allocates a block of memory from the heap of an index page. */
699
679
page_mem_alloc_heap(
700
680
/*================*/
701
page_t* page, /*!< in/out: index page */
702
page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
681
/* out: pointer to start of allocated
682
buffer, or NULL if allocation fails */
683
page_t* page, /* in/out: index page */
684
page_zip_des_t* page_zip,/* in/out: compressed page with enough
703
685
space available for inserting the record,
705
ulint need, /*!< in: total number of bytes needed */
706
ulint* heap_no);/*!< out: this contains the heap number
687
ulint need, /* in: total number of bytes needed */
688
ulint* heap_no);/* out: this contains the heap number
707
689
of the allocated record
708
690
if allocation succeeds */
709
/************************************************************//**
691
/****************************************************************
710
692
Puts a record to free list. */
715
page_t* page, /*!< in/out: index page */
716
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
717
rec_t* rec, /*!< in: pointer to the (origin of) record */
718
dict_index_t* index, /*!< in: index of rec */
719
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
720
/**********************************************************//**
721
Create an uncompressed B-tree index page.
722
@return pointer to the page */
697
page_t* page, /* in/out: index page */
698
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
699
rec_t* rec, /* in: pointer to the (origin of) record */
700
dict_index_t* index, /* in: index of rec */
701
const ulint* offsets);/* in: array returned by rec_get_offsets() */
702
/**************************************************************
703
Create an uncompressed B-tree index page. */
727
buf_block_t* block, /*!< in: a buffer block where the
708
/* out: pointer to the page */
709
buf_block_t* block, /* in: a buffer block where the
728
710
page is created */
729
mtr_t* mtr, /*!< in: mini-transaction handle */
730
ulint comp); /*!< in: nonzero=compact page format */
731
/**********************************************************//**
732
Create a compressed B-tree index page.
733
@return pointer to the page */
711
mtr_t* mtr, /* in: mini-transaction handle */
712
ulint comp); /* in: nonzero=compact page format */
713
/**************************************************************
714
Create a compressed B-tree index page. */
738
buf_block_t* block, /*!< in/out: a buffer frame where the
719
/* out: pointer to the page */
720
buf_block_t* block, /* in/out: a buffer frame where the
739
721
page is created */
740
dict_index_t* index, /*!< in: the index of the page */
741
ulint level, /*!< in: the B-tree level of the page */
742
mtr_t* mtr); /*!< in: mini-transaction handle */
722
dict_index_t* index, /* in: the index of the page */
723
ulint level, /* in: the B-tree level of the page */
724
mtr_t* mtr); /* in: mini-transaction handle */
744
/*************************************************************//**
726
/*****************************************************************
745
727
Differs from page_copy_rec_list_end, because this function does not
746
728
touch the lock table and max trx id on page or compress the page. */
749
731
page_copy_rec_list_end_no_locks(
750
732
/*============================*/
751
buf_block_t* new_block, /*!< in: index page to copy to */
752
buf_block_t* block, /*!< in: index page of rec */
753
rec_t* rec, /*!< in: record on page */
754
dict_index_t* index, /*!< in: record descriptor */
755
mtr_t* mtr); /*!< in: mtr */
756
/*************************************************************//**
733
buf_block_t* new_block, /* in: index page to copy to */
734
buf_block_t* block, /* in: index page of rec */
735
rec_t* rec, /* in: record on page */
736
dict_index_t* index, /* in: record descriptor */
737
mtr_t* mtr); /* in: mtr */
738
/*****************************************************************
757
739
Copies records from page to new_page, from the given record onward,
758
740
including that record. Infimum and supremum records are not copied.
759
The records are copied to the start of the record list on new_page.
760
@return pointer to the original successor of the infimum record on
761
new_page, or NULL on zip overflow (new_block will be decompressed) */
741
The records are copied to the start of the record list on new_page. */
764
744
page_copy_rec_list_end(
765
745
/*===================*/
766
buf_block_t* new_block, /*!< in/out: index page to copy to */
767
buf_block_t* block, /*!< in: index page containing rec */
768
rec_t* rec, /*!< in: record on page */
769
dict_index_t* index, /*!< in: record descriptor */
770
mtr_t* mtr) /*!< in: mtr */
746
/* out: pointer to the original
747
successor of the infimum record
748
on new_page, or NULL on zip overflow
749
(new_block will be decompressed) */
750
buf_block_t* new_block, /* in/out: index page to copy to */
751
buf_block_t* block, /* in: index page containing rec */
752
rec_t* rec, /* in: record on page */
753
dict_index_t* index, /* in: record descriptor */
754
mtr_t* mtr) /* in: mtr */
771
755
__attribute__((nonnull));
772
/*************************************************************//**
756
/*****************************************************************
773
757
Copies records from page to new_page, up to the given record, NOT
774
758
including that record. Infimum and supremum records are not copied.
775
The records are copied to the end of the record list on new_page.
776
@return pointer to the original predecessor of the supremum record on
777
new_page, or NULL on zip overflow (new_block will be decompressed) */
759
The records are copied to the end of the record list on new_page. */
780
762
page_copy_rec_list_start(
781
763
/*=====================*/
782
buf_block_t* new_block, /*!< in/out: index page to copy to */
783
buf_block_t* block, /*!< in: index page containing rec */
784
rec_t* rec, /*!< in: record on page */
785
dict_index_t* index, /*!< in: record descriptor */
786
mtr_t* mtr) /*!< in: mtr */
764
/* out: pointer to the original
765
predecessor of the supremum record
766
on new_page, or NULL on zip overflow
767
(new_block will be decompressed) */
768
buf_block_t* new_block, /* in/out: index page to copy to */
769
buf_block_t* block, /* in: index page containing rec */
770
rec_t* rec, /* in: record on page */
771
dict_index_t* index, /* in: record descriptor */
772
mtr_t* mtr) /* in: mtr */
787
773
__attribute__((nonnull));
788
/*************************************************************//**
774
/*****************************************************************
789
775
Deletes records from a page from a given record onward, including that record.
790
776
The infimum and supremum records are not deleted. */
793
779
page_delete_rec_list_end(
794
780
/*=====================*/
795
rec_t* rec, /*!< in: pointer to record on page */
796
buf_block_t* block, /*!< in: buffer block of the page */
797
dict_index_t* index, /*!< in: record descriptor */
798
ulint n_recs, /*!< in: number of records to delete,
781
rec_t* rec, /* in: pointer to record on page */
782
buf_block_t* block, /* in: buffer block of the page */
783
dict_index_t* index, /* in: record descriptor */
784
ulint n_recs, /* in: number of records to delete,
799
785
or ULINT_UNDEFINED if not known */
800
ulint size, /*!< in: the sum of the sizes of the
786
ulint size, /* in: the sum of the sizes of the
801
787
records in the end of the chain to
802
788
delete, or ULINT_UNDEFINED if not known */
803
mtr_t* mtr) /*!< in: mtr */
789
mtr_t* mtr) /* in: mtr */
804
790
__attribute__((nonnull));
805
/*************************************************************//**
791
/*****************************************************************
806
792
Deletes records from page, up to the given record, NOT including
807
793
that record. Infimum and supremum records are not deleted. */
810
796
page_delete_rec_list_start(
811
797
/*=======================*/
812
rec_t* rec, /*!< in: record on page */
813
buf_block_t* block, /*!< in: buffer block of the page */
814
dict_index_t* index, /*!< in: record descriptor */
815
mtr_t* mtr) /*!< in: mtr */
798
rec_t* rec, /* in: record on page */
799
buf_block_t* block, /* in: buffer block of the page */
800
dict_index_t* index, /* in: record descriptor */
801
mtr_t* mtr) /* in: mtr */
816
802
__attribute__((nonnull));
817
/*************************************************************//**
803
/*****************************************************************
818
804
Moves record list end to another page. Moved records include
820
@return TRUE on success; FALSE on compression failure (new_block will
824
808
page_move_rec_list_end(
825
809
/*===================*/
826
buf_block_t* new_block, /*!< in/out: index page where to move */
827
buf_block_t* block, /*!< in: index page from where to move */
828
rec_t* split_rec, /*!< in: first record to move */
829
dict_index_t* index, /*!< in: record descriptor */
830
mtr_t* mtr) /*!< in: mtr */
810
/* out: TRUE on success; FALSE on
812
(new_block will be decompressed) */
813
buf_block_t* new_block, /* in/out: index page where to move */
814
buf_block_t* block, /* in: index page from where to move */
815
rec_t* split_rec, /* in: first record to move */
816
dict_index_t* index, /* in: record descriptor */
817
mtr_t* mtr) /* in: mtr */
831
818
__attribute__((nonnull(1, 2, 4, 5)));
832
/*************************************************************//**
819
/*****************************************************************
833
820
Moves record list start to another page. Moved records do not include
835
@return TRUE on success; FALSE on compression failure */
838
824
page_move_rec_list_start(
839
825
/*=====================*/
840
buf_block_t* new_block, /*!< in/out: index page where to move */
841
buf_block_t* block, /*!< in/out: page containing split_rec */
842
rec_t* split_rec, /*!< in: first record not to move */
843
dict_index_t* index, /*!< in: record descriptor */
844
mtr_t* mtr) /*!< in: mtr */
826
/* out: TRUE on success; FALSE on
827
compression failure */
828
buf_block_t* new_block, /* in/out: index page where to move */
829
buf_block_t* block, /* in/out: page containing split_rec */
830
rec_t* split_rec, /* in: first record not to move */
831
dict_index_t* index, /* in: record descriptor */
832
mtr_t* mtr) /* in: mtr */
845
833
__attribute__((nonnull(1, 2, 4, 5)));
846
/****************************************************************//**
834
/********************************************************************
847
835
Splits a directory slot which owns too many records. */
850
838
page_dir_split_slot(
851
839
/*================*/
852
page_t* page, /*!< in: index page */
853
page_zip_des_t* page_zip,/*!< in/out: compressed page whose
840
page_t* page, /* in: index page */
841
page_zip_des_t* page_zip,/* in/out: compressed page whose
854
842
uncompressed part will be written, or NULL */
855
ulint slot_no)/*!< in: the directory slot */
843
ulint slot_no)/* in: the directory slot */
856
844
__attribute__((nonnull(1)));
857
/*************************************************************//**
845
/*****************************************************************
858
846
Tries to balance the given directory slot with too few records
859
847
with the upper neighbor, so that there are at least the minimum number
860
848
of records owned by the slot; this may result in the merging of
864
852
page_dir_balance_slot(
865
853
/*==================*/
866
page_t* page, /*!< in/out: index page */
867
page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
868
ulint slot_no)/*!< in: the directory slot */
854
page_t* page, /* in/out: index page */
855
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
856
ulint slot_no)/* in: the directory slot */
869
857
__attribute__((nonnull(1)));
870
/**********************************************************//**
871
Parses a log record of a record list end or start deletion.
872
@return end of log record or NULL */
858
/**************************************************************
859
Parses a log record of a record list end or start deletion. */
875
862
page_parse_delete_rec_list(
876
863
/*=======================*/
877
byte type, /*!< in: MLOG_LIST_END_DELETE,
864
/* out: end of log record or NULL */
865
byte type, /* in: MLOG_LIST_END_DELETE,
878
866
MLOG_LIST_START_DELETE,
879
867
MLOG_COMP_LIST_END_DELETE or
880
868
MLOG_COMP_LIST_START_DELETE */
881
byte* ptr, /*!< in: buffer */
882
byte* end_ptr,/*!< in: buffer end */
883
buf_block_t* block, /*!< in/out: buffer block or NULL */
884
dict_index_t* index, /*!< in: record descriptor */
885
mtr_t* mtr); /*!< in: mtr or NULL */
886
/***********************************************************//**
887
Parses a redo log record of creating a page.
888
@return end of log record or NULL */
869
byte* ptr, /* in: buffer */
870
byte* end_ptr,/* in: buffer end */
871
buf_block_t* block, /* in/out: buffer block or NULL */
872
dict_index_t* index, /* in: record descriptor */
873
mtr_t* mtr); /* in: mtr or NULL */
874
/***************************************************************
875
Parses a redo log record of creating a page. */
891
878
page_parse_create(
892
879
/*==============*/
893
byte* ptr, /*!< in: buffer */
894
byte* end_ptr,/*!< in: buffer end */
895
ulint comp, /*!< in: nonzero=compact page format */
896
buf_block_t* block, /*!< in: block or NULL */
897
mtr_t* mtr); /*!< in: mtr or NULL */
898
/************************************************************//**
880
/* out: end of log record or NULL */
881
byte* ptr, /* in: buffer */
882
byte* end_ptr,/* in: buffer end */
883
ulint comp, /* in: nonzero=compact page format */
884
buf_block_t* block, /* in: block or NULL */
885
mtr_t* mtr); /* in: mtr or NULL */
886
/****************************************************************
899
887
Prints record contents including the data relevant only in
900
888
the index page context. */
905
const rec_t* rec, /*!< in: physical record */
906
const ulint* offsets);/*!< in: record descriptor */
907
/***************************************************************//**
893
const rec_t* rec, /* in: physical record */
894
const ulint* offsets);/* in: record descriptor */
895
/*******************************************************************
908
896
This is used to print the contents of the directory for
909
897
debugging purposes. */
914
page_t* page, /*!< in: index page */
915
ulint pr_n); /*!< in: print n first and n last entries */
916
/***************************************************************//**
902
page_t* page, /* in: index page */
903
ulint pr_n); /* in: print n first and n last entries */
904
/*******************************************************************
917
905
This is used to print the contents of the page record list for
918
906
debugging purposes. */
923
buf_block_t* block, /*!< in: index page */
924
dict_index_t* index, /*!< in: dictionary index of the page */
925
ulint pr_n); /*!< in: print n first and n last entries */
926
/***************************************************************//**
911
buf_block_t* block, /* in: index page */
912
dict_index_t* index, /* in: dictionary index of the page */
913
ulint pr_n); /* in: print n first and n last entries */
914
/*******************************************************************
927
915
Prints the info in a page header. */
930
918
page_header_print(
931
919
/*==============*/
932
const page_t* page); /*!< in: index page */
933
/***************************************************************//**
921
/*******************************************************************
934
922
This is used to print the contents of the page for
935
923
debugging purposes. */
940
buf_block_t* block, /*!< in: index page */
941
dict_index_t* index, /*!< in: dictionary index of the page */
942
ulint dn, /*!< in: print dn first and last entries
944
ulint rn); /*!< in: print rn first and last records
946
/***************************************************************//**
928
buf_block_t* block, /* in: index page */
929
dict_index_t* index, /* in: dictionary index of the page */
930
ulint dn, /* in: print dn first and last entries
932
ulint rn); /* in: print rn first and last records
934
/*******************************************************************
947
935
The following is used to validate a record on a page. This function
948
936
differs from rec_validate as it can also check the n_owned field and
950
@return TRUE if ok */
937
the heap_no field. */
953
940
page_rec_validate(
954
941
/*==============*/
955
rec_t* rec, /*!< in: physical record */
956
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
957
/***************************************************************//**
942
/* out: TRUE if ok */
943
rec_t* rec, /* in: physical record */
944
const ulint* offsets);/* in: array returned by rec_get_offsets() */
945
/*******************************************************************
958
946
Checks that the first directory slot points to the infimum record and
959
947
the last to the supremum. This function is intended to track if the
960
948
bug fixed in 4.0.14 has caused corruption to users' databases. */