~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/page0page.h

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

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