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