~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-02-10 00:14:40 UTC
  • Revision ID: brian@tangent.org-20090210001440-qjg8eofh3h93064b
Adding Multi-threaded Scheduler into the system.

Show diffs side-by-side

added added

removed removed

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