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