~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/rem0rec.ic

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
#define REC_NEW_STATUS_SHIFT    0
85
85
 
86
86
#define REC_OLD_HEAP_NO         5
 
87
#define REC_HEAP_NO_MASK        0xFFF8UL
 
88
#if 0 /* defined in rem0rec.h for use of page0zip.c */
87
89
#define REC_NEW_HEAP_NO         4
88
 
#define REC_HEAP_NO_MASK        0xFFF8UL
89
90
#define REC_HEAP_NO_SHIFT       3
 
91
#endif
90
92
 
91
93
#define REC_OLD_N_OWNED         6       /* This is single byte bit-field */
92
94
#define REC_NEW_N_OWNED         5       /* This is single byte bit-field */
98
100
#define REC_INFO_BITS_MASK      0xF0UL
99
101
#define REC_INFO_BITS_SHIFT     0
100
102
 
101
 
/* The deleted flag in info bits */
102
 
#define REC_INFO_DELETED_FLAG   0x20UL  /* when bit is set to 1, it means the
103
 
                                        record has been delete marked */
104
103
/* The following masks are used to filter the SQL null bit from
105
104
one-byte and two-byte offsets */
106
105
 
130
129
 
131
130
/***************************************************************
132
131
Sets the value of the ith field SQL null bit of an old-style record. */
133
 
 
 
132
UNIV_INTERN
134
133
void
135
134
rec_set_nth_field_null_bit(
136
135
/*=======================*/
140
139
/***************************************************************
141
140
Sets an old-style record field to SQL null.
142
141
The physical size of the field is not changed. */
143
 
 
 
142
UNIV_INTERN
144
143
void
145
144
rec_set_nth_field_sql_null(
146
145
/*=======================*/
147
146
        rec_t*  rec,    /* in: record */
148
147
        ulint   n);     /* in: index of the field */
149
148
 
150
 
/***************************************************************
151
 
Sets the value of the ith field extern storage bit of an old-style record. */
152
 
 
153
 
void
154
 
rec_set_nth_field_extern_bit_old(
155
 
/*=============================*/
156
 
        rec_t*  rec,    /* in: old-style record */
157
 
        ulint   i,      /* in: ith field */
158
 
        ibool   val,    /* in: value to set */
159
 
        mtr_t*  mtr);   /* in: mtr holding an X-latch to the page where
160
 
                        rec is, or NULL; in the NULL case we do not
161
 
                        write to log about the change */
162
 
/***************************************************************
163
 
Sets the value of the ith field extern storage bit of a new-style record. */
164
 
 
165
 
void
166
 
rec_set_nth_field_extern_bit_new(
167
 
/*=============================*/
168
 
        rec_t*          rec,    /* in: record */
169
 
        dict_index_t*   index,  /* in: record descriptor */
170
 
        ulint           ith,    /* in: ith field */
171
 
        ibool           val,    /* in: value to set */
172
 
        mtr_t*          mtr);   /* in: mtr holding an X-latch to the page
173
 
                                where rec is, or NULL; in the NULL case
174
 
                                we do not write to log about the change */
175
 
 
176
149
/**********************************************************
177
150
Gets a bit field from within 1 byte. */
178
151
UNIV_INLINE
179
152
ulint
180
153
rec_get_bit_field_1(
181
154
/*================*/
182
 
        rec_t*  rec,    /* in: pointer to record origin */
183
 
        ulint   offs,   /* in: offset from the origin down */
184
 
        ulint   mask,   /* in: mask used to filter bits */
185
 
        ulint   shift)  /* in: shift right applied after masking */
 
155
        const rec_t*    rec,    /* in: pointer to record origin */
 
156
        ulint           offs,   /* in: offset from the origin down */
 
157
        ulint           mask,   /* in: mask used to filter bits */
 
158
        ulint           shift)  /* in: shift right applied after masking */
186
159
{
187
160
        ut_ad(rec);
188
161
 
219
192
ulint
220
193
rec_get_bit_field_2(
221
194
/*================*/
222
 
        rec_t*  rec,    /* in: pointer to record origin */
223
 
        ulint   offs,   /* in: offset from the origin down */
224
 
        ulint   mask,   /* in: mask used to filter bits */
225
 
        ulint   shift)  /* in: shift right applied after masking */
 
195
        const rec_t*    rec,    /* in: pointer to record origin */
 
196
        ulint           offs,   /* in: offset from the origin down */
 
197
        ulint           mask,   /* in: mask used to filter bits */
 
198
        ulint           shift)  /* in: shift right applied after masking */
226
199
{
227
200
        ut_ad(rec);
228
201
 
256
229
}
257
230
 
258
231
/**********************************************************
 
232
The following function is used to get the pointer of the next chained record
 
233
on the same page. */
 
234
UNIV_INLINE
 
235
const rec_t*
 
236
rec_get_next_ptr_const(
 
237
/*===================*/
 
238
                                /* out: pointer to the next chained record, or
 
239
                                NULL if none */
 
240
        const rec_t*    rec,    /* in: physical record */
 
241
        ulint           comp)   /* in: nonzero=compact page format */
 
242
{
 
243
        ulint   field_value;
 
244
 
 
245
        ut_ad(REC_NEXT_MASK == 0xFFFFUL);
 
246
        ut_ad(REC_NEXT_SHIFT == 0);
 
247
 
 
248
        field_value = mach_read_from_2(rec - REC_NEXT);
 
249
 
 
250
        if (UNIV_UNLIKELY(field_value == 0)) {
 
251
 
 
252
                return(NULL);
 
253
        }
 
254
 
 
255
        if (UNIV_EXPECT(comp, REC_OFFS_COMPACT)) {
 
256
#if UNIV_PAGE_SIZE <= 32768
 
257
                /* Note that for 64 KiB pages, field_value can 'wrap around'
 
258
                and the debug assertion is not valid */
 
259
 
 
260
                /* In the following assertion, field_value is interpreted
 
261
                as signed 16-bit integer in 2's complement arithmetics.
 
262
                If all platforms defined int16_t in the standard headers,
 
263
                the expression could be written simpler as
 
264
                (int16_t) field_value + ut_align_offset(...) < UNIV_PAGE_SIZE
 
265
                */
 
266
                ut_ad((field_value >= 32768
 
267
                       ? field_value - 65536
 
268
                       : field_value)
 
269
                      + ut_align_offset(rec, UNIV_PAGE_SIZE)
 
270
                      < UNIV_PAGE_SIZE);
 
271
#endif
 
272
                /* There must be at least REC_N_NEW_EXTRA_BYTES + 1
 
273
                between each record. */
 
274
                ut_ad((field_value > REC_N_NEW_EXTRA_BYTES
 
275
                       && field_value < 32768)
 
276
                      || field_value < (uint16) -REC_N_NEW_EXTRA_BYTES);
 
277
 
 
278
                return((byte*) ut_align_down(rec, UNIV_PAGE_SIZE)
 
279
                       + ut_align_offset(rec + field_value, UNIV_PAGE_SIZE));
 
280
        } else {
 
281
                ut_ad(field_value < UNIV_PAGE_SIZE);
 
282
 
 
283
                return((byte*) ut_align_down(rec, UNIV_PAGE_SIZE)
 
284
                       + field_value);
 
285
        }
 
286
}
 
287
 
 
288
/**********************************************************
 
289
The following function is used to get the pointer of the next chained record
 
290
on the same page. */
 
291
UNIV_INLINE
 
292
rec_t*
 
293
rec_get_next_ptr(
 
294
/*=============*/
 
295
                        /* out: pointer to the next chained record, or
 
296
                        NULL if none */
 
297
        rec_t*  rec,    /* in: physical record */
 
298
        ulint   comp)   /* in: nonzero=compact page format */
 
299
{
 
300
        return((rec_t*) rec_get_next_ptr_const(rec, comp));
 
301
}
 
302
 
 
303
/**********************************************************
259
304
The following function is used to get the offset of the next chained record
260
305
on the same page. */
261
306
UNIV_INLINE
262
307
ulint
263
308
rec_get_next_offs(
264
309
/*==============*/
265
 
                        /* out: the page offset of the next chained record, or
266
 
                        0 if none */
267
 
        rec_t*  rec,    /* in: physical record */
268
 
        ulint   comp)   /* in: nonzero=compact page format */
 
310
                                /* out: the page offset of the next
 
311
                                chained record, or 0 if none */
 
312
        const rec_t*    rec,    /* in: physical record */
 
313
        ulint           comp)   /* in: nonzero=compact page format */
269
314
{
270
315
        ulint   field_value;
271
316
#if REC_NEXT_MASK != 0xFFFFUL
277
322
 
278
323
        field_value = mach_read_from_2(rec - REC_NEXT);
279
324
 
280
 
        if (comp) {
 
325
        if (UNIV_EXPECT(comp, REC_OFFS_COMPACT)) {
281
326
#if UNIV_PAGE_SIZE <= 32768
282
327
                /* Note that for 64 KiB pages, field_value can 'wrap around'
283
328
                and the debug assertion is not valid */
294
339
                      + ut_align_offset(rec, UNIV_PAGE_SIZE)
295
340
                      < UNIV_PAGE_SIZE);
296
341
#endif
297
 
                if (field_value == 0) {
 
342
                if (UNIV_UNLIKELY(field_value == 0)) {
298
343
 
299
344
                        return(0);
300
345
                }
301
346
 
 
347
                /* There must be at least REC_N_NEW_EXTRA_BYTES + 1
 
348
                between each record. */
 
349
                ut_ad((field_value > REC_N_NEW_EXTRA_BYTES
 
350
                       && field_value < 32768)
 
351
                      || field_value < (uint16) -REC_N_NEW_EXTRA_BYTES);
 
352
 
302
353
                return(ut_align_offset(rec + field_value, UNIV_PAGE_SIZE));
303
354
        } else {
304
355
                ut_ad(field_value < UNIV_PAGE_SIZE);
308
359
}
309
360
 
310
361
/**********************************************************
311
 
The following function is used to set the next record offset field of the
312
 
record. */
 
362
The following function is used to set the next record offset field
 
363
of an old-style record. */
313
364
UNIV_INLINE
314
365
void
315
 
rec_set_next_offs(
316
 
/*==============*/
317
 
        rec_t*  rec,    /* in: physical record */
318
 
        ulint   comp,   /* in: nonzero=compact page format */
319
 
        ulint   next)   /* in: offset of the next record, or 0 if none */
 
366
rec_set_next_offs_old(
 
367
/*==================*/
 
368
        rec_t*  rec,    /* in: old-style physical record */
 
369
        ulint   next)   /* in: offset of the next record */
320
370
{
321
371
        ut_ad(rec);
322
372
        ut_ad(UNIV_PAGE_SIZE > next);
327
377
# error "REC_NEXT_SHIFT != 0"
328
378
#endif
329
379
 
330
 
        if (comp) {
331
 
                ulint field_value;
332
 
 
333
 
                if (next) {
334
 
                        /* The following two statements calculate
335
 
                        next - offset_of_rec mod 64Ki, where mod is the modulo
336
 
                        as a non-negative number */
337
 
 
338
 
                        field_value = (ulint)((lint)next
339
 
                                              - (lint)ut_align_offset(
340
 
                                                      rec, UNIV_PAGE_SIZE));
341
 
                        field_value &= REC_NEXT_MASK;
342
 
                } else {
343
 
                        field_value = 0;
344
 
                }
345
 
 
346
 
                mach_write_to_2(rec - REC_NEXT, field_value);
 
380
        mach_write_to_2(rec - REC_NEXT, next);
 
381
}
 
382
 
 
383
/**********************************************************
 
384
The following function is used to set the next record offset field
 
385
of a new-style record. */
 
386
UNIV_INLINE
 
387
void
 
388
rec_set_next_offs_new(
 
389
/*==================*/
 
390
        rec_t*  rec,    /* in/out: new-style physical record */
 
391
        ulint   next)   /* in: offset of the next record */
 
392
{
 
393
        ulint   field_value;
 
394
 
 
395
        ut_ad(rec);
 
396
        ut_ad(UNIV_PAGE_SIZE > next);
 
397
 
 
398
        if (UNIV_UNLIKELY(!next)) {
 
399
                field_value = 0;
347
400
        } else {
348
 
                mach_write_to_2(rec - REC_NEXT, next);
 
401
                /* The following two statements calculate
 
402
                next - offset_of_rec mod 64Ki, where mod is the modulo
 
403
                as a non-negative number */
 
404
 
 
405
                field_value = (ulint)
 
406
                        ((lint) next 
 
407
                         - (lint) ut_align_offset(rec, UNIV_PAGE_SIZE));
 
408
                field_value &= REC_NEXT_MASK;
349
409
        }
 
410
 
 
411
        mach_write_to_2(rec - REC_NEXT, field_value);
350
412
}
351
413
 
352
414
/**********************************************************
356
418
ulint
357
419
rec_get_n_fields_old(
358
420
/*=================*/
359
 
                        /* out: number of data fields */
360
 
        rec_t*  rec)    /* in: physical record */
 
421
                                /* out: number of data fields */
 
422
        const rec_t*    rec)    /* in: physical record */
361
423
{
362
424
        ulint   ret;
363
425
 
396
458
ulint
397
459
rec_get_status(
398
460
/*===========*/
399
 
                        /* out: status bits */
400
 
        rec_t*  rec)    /* in: physical record */
 
461
                                /* out: status bits */
 
462
        const rec_t*    rec)    /* in: physical record */
401
463
{
402
464
        ulint   ret;
403
465
 
417
479
ulint
418
480
rec_get_n_fields(
419
481
/*=============*/
420
 
                                /* out: number of data fields */
421
 
        rec_t*          rec,    /* in: physical record */
422
 
        dict_index_t*   index)  /* in: record descriptor */
 
482
                                        /* out: number of data fields */
 
483
        const rec_t*            rec,    /* in: physical record */
 
484
        const dict_index_t*     index)  /* in: record descriptor */
423
485
{
424
486
        ut_ad(rec);
425
487
        ut_ad(index);
447
509
previous directory record. */
448
510
UNIV_INLINE
449
511
ulint
450
 
rec_get_n_owned(
451
 
/*============*/
452
 
                        /* out: number of owned records */
453
 
        rec_t*  rec,    /* in: physical record */
454
 
        ulint   comp)   /* in: nonzero=compact page format */
 
512
rec_get_n_owned_old(
 
513
/*================*/
 
514
                                /* out: number of owned records */
 
515
        const rec_t*    rec)    /* in: old-style physical record */
455
516
{
456
 
        ulint   ret;
457
 
 
458
 
        ut_ad(rec);
459
 
 
460
 
        ret = rec_get_bit_field_1(rec,
461
 
                                  comp ? REC_NEW_N_OWNED : REC_OLD_N_OWNED,
462
 
                                  REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
463
 
        ut_ad(ret <= REC_MAX_N_OWNED);
464
 
 
465
 
        return(ret);
 
517
        return(rec_get_bit_field_1(rec, REC_OLD_N_OWNED,
 
518
                                   REC_N_OWNED_MASK, REC_N_OWNED_SHIFT));
466
519
}
467
520
 
468
521
/**********************************************************
469
522
The following function is used to set the number of owned records. */
470
523
UNIV_INLINE
471
524
void
472
 
rec_set_n_owned(
473
 
/*============*/
474
 
        rec_t*  rec,            /* in: physical record */
475
 
        ulint   comp,           /* in: nonzero=compact page format */
 
525
rec_set_n_owned_old(
 
526
/*================*/
 
527
                                /* out: TRUE on success */
 
528
        rec_t*  rec,            /* in: old-style physical record */
476
529
        ulint   n_owned)        /* in: the number of owned */
477
530
{
478
 
        ut_ad(rec);
479
 
        ut_ad(n_owned <= REC_MAX_N_OWNED);
480
 
 
481
 
        rec_set_bit_field_1(rec, n_owned,
482
 
                            comp ? REC_NEW_N_OWNED : REC_OLD_N_OWNED,
483
 
                            REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
 
531
        rec_set_bit_field_1(rec, n_owned, REC_OLD_N_OWNED,
 
532
                            REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
 
533
}
 
534
 
 
535
/**********************************************************
 
536
The following function is used to get the number of records owned by the
 
537
previous directory record. */
 
538
UNIV_INLINE
 
539
ulint
 
540
rec_get_n_owned_new(
 
541
/*================*/
 
542
                                /* out: number of owned records */
 
543
        const rec_t*    rec)    /* in: new-style physical record */
 
544
{
 
545
        return(rec_get_bit_field_1(rec, REC_NEW_N_OWNED,
 
546
                                   REC_N_OWNED_MASK, REC_N_OWNED_SHIFT));
 
547
}
 
548
 
 
549
/**********************************************************
 
550
The following function is used to set the number of owned records. */
 
551
UNIV_INLINE
 
552
void
 
553
rec_set_n_owned_new(
 
554
/*================*/
 
555
        rec_t*          rec,    /* in/out: new-style physical record */
 
556
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
557
        ulint           n_owned)/* in: the number of owned */
 
558
{
 
559
        rec_set_bit_field_1(rec, n_owned, REC_NEW_N_OWNED,
 
560
                            REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
 
561
        if (UNIV_LIKELY_NULL(page_zip)
 
562
            && UNIV_LIKELY(rec_get_status(rec)
 
563
                           != REC_STATUS_SUPREMUM)) {
 
564
                page_zip_rec_set_owned(page_zip, rec, n_owned);
 
565
        }
484
566
}
485
567
 
486
568
/**********************************************************
489
571
ulint
490
572
rec_get_info_bits(
491
573
/*==============*/
492
 
                        /* out: info bits */
493
 
        rec_t*  rec,    /* in: physical record */
494
 
        ulint   comp)   /* in: nonzero=compact page format */
495
 
{
496
 
        ulint   ret;
497
 
 
498
 
        ut_ad(rec);
499
 
 
500
 
        ret = rec_get_bit_field_1(rec,
501
 
                                  comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS,
502
 
                                  REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
503
 
        ut_ad((ret & ~REC_INFO_BITS_MASK) == 0);
504
 
 
505
 
        return(ret);
506
 
}
507
 
 
508
 
/**********************************************************
509
 
The following function is used to set the info bits of a record. */
510
 
UNIV_INLINE
511
 
void
512
 
rec_set_info_bits(
513
 
/*==============*/
514
 
        rec_t*  rec,    /* in: physical record */
515
 
        ulint   comp,   /* in: nonzero=compact page format */
516
 
        ulint   bits)   /* in: info bits */
517
 
{
518
 
        ut_ad(rec);
519
 
        ut_ad((bits & ~REC_INFO_BITS_MASK) == 0);
520
 
 
521
 
        rec_set_bit_field_1(rec, bits,
522
 
                            comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS,
 
574
                                /* out: info bits */
 
575
        const rec_t*    rec,    /* in: physical record */
 
576
        ulint           comp)   /* in: nonzero=compact page format */
 
577
{
 
578
        return(rec_get_bit_field_1(
 
579
                       rec, comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS,
 
580
                       REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT));
 
581
}
 
582
 
 
583
/**********************************************************
 
584
The following function is used to set the info bits of a record. */
 
585
UNIV_INLINE
 
586
void
 
587
rec_set_info_bits_old(
 
588
/*==================*/
 
589
        rec_t*  rec,    /* in: old-style physical record */
 
590
        ulint   bits)   /* in: info bits */
 
591
{
 
592
        rec_set_bit_field_1(rec, bits, REC_OLD_INFO_BITS,
 
593
                            REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
 
594
}
 
595
/**********************************************************
 
596
The following function is used to set the info bits of a record. */
 
597
UNIV_INLINE
 
598
void
 
599
rec_set_info_bits_new(
 
600
/*==================*/
 
601
        rec_t*  rec,    /* in/out: new-style physical record */
 
602
        ulint   bits)   /* in: info bits */
 
603
{
 
604
        rec_set_bit_field_1(rec, bits, REC_NEW_INFO_BITS,
523
605
                            REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
524
606
}
525
607
 
529
611
void
530
612
rec_set_status(
531
613
/*===========*/
532
 
        rec_t*  rec,    /* in: physical record */
 
614
        rec_t*  rec,    /* in/out: physical record */
533
615
        ulint   bits)   /* in: info bits */
534
616
{
535
 
        ut_ad(rec);
536
 
        ut_ad((bits & ~REC_NEW_STATUS_MASK) == 0);
537
 
 
538
617
        rec_set_bit_field_1(rec, bits, REC_NEW_STATUS,
539
618
                            REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT);
540
619
}
546
625
ulint
547
626
rec_get_info_and_status_bits(
548
627
/*=========================*/
549
 
                        /* out: info bits */
550
 
        rec_t*  rec,    /* in: physical record */
551
 
        ulint   comp)   /* in: nonzero=compact page format */
 
628
                                /* out: info bits */
 
629
        const rec_t*    rec,    /* in: physical record */
 
630
        ulint           comp)   /* in: nonzero=compact page format */
552
631
{
553
632
        ulint   bits;
554
633
#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \
570
649
void
571
650
rec_set_info_and_status_bits(
572
651
/*=========================*/
573
 
        rec_t*  rec,    /* in: physical record */
574
 
        ulint   comp,   /* in: nonzero=compact page format */
 
652
        rec_t*  rec,    /* in/out: physical record */
575
653
        ulint   bits)   /* in: info bits */
576
654
{
577
655
#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \
578
656
& (REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT)
579
657
# error "REC_NEW_STATUS_MASK and REC_INFO_BITS_MASK overlap"
580
658
#endif
581
 
        if (comp) {
582
 
                rec_set_status(rec, bits & REC_NEW_STATUS_MASK);
583
 
        } else {
584
 
                ut_ad(!(bits & ~(REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT)));
585
 
        }
586
 
        rec_set_info_bits(rec, comp, bits & ~REC_NEW_STATUS_MASK);
 
659
        rec_set_status(rec, bits & REC_NEW_STATUS_MASK);
 
660
        rec_set_info_bits_new(rec, bits & ~REC_NEW_STATUS_MASK);
587
661
}
588
662
 
589
663
/**********************************************************
592
666
ulint
593
667
rec_get_deleted_flag(
594
668
/*=================*/
595
 
                        /* out: nonzero if delete marked */
596
 
        rec_t*  rec,    /* in: physical record */
597
 
        ulint   comp)   /* in: nonzero=compact page format */
 
669
                                /* out: nonzero if delete marked */
 
670
        const rec_t*    rec,    /* in: physical record */
 
671
        ulint           comp)   /* in: nonzero=compact page format */
598
672
{
599
673
        if (UNIV_EXPECT(comp, REC_OFFS_COMPACT)) {
600
674
                return(UNIV_UNLIKELY(
613
687
The following function is used to set the deleted bit. */
614
688
UNIV_INLINE
615
689
void
616
 
rec_set_deleted_flag(
617
 
/*=================*/
618
 
        rec_t*  rec,    /* in: physical record */
619
 
        ulint   comp,   /* in: nonzero=compact page format */
 
690
rec_set_deleted_flag_old(
 
691
/*=====================*/
 
692
        rec_t*  rec,    /* in: old-style physical record */
620
693
        ulint   flag)   /* in: nonzero if delete marked */
621
694
{
622
695
        ulint   val;
623
696
 
624
 
        val = rec_get_info_bits(rec, comp);
625
 
 
626
 
        if (flag) {
627
 
                val |= REC_INFO_DELETED_FLAG;
628
 
        } else {
629
 
                val &= ~REC_INFO_DELETED_FLAG;
630
 
        }
631
 
 
632
 
        rec_set_info_bits(rec, comp, val);
 
697
        val = rec_get_info_bits(rec, FALSE);
 
698
 
 
699
        if (flag) {
 
700
                val |= REC_INFO_DELETED_FLAG;
 
701
        } else {
 
702
                val &= ~REC_INFO_DELETED_FLAG;
 
703
        }
 
704
 
 
705
        rec_set_info_bits_old(rec, val);
 
706
}
 
707
 
 
708
/**********************************************************
 
709
The following function is used to set the deleted bit. */
 
710
UNIV_INLINE
 
711
void
 
712
rec_set_deleted_flag_new(
 
713
/*=====================*/
 
714
        rec_t*          rec,    /* in/out: new-style physical record */
 
715
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
716
        ulint           flag)   /* in: nonzero if delete marked */
 
717
{
 
718
        ulint   val;
 
719
 
 
720
        val = rec_get_info_bits(rec, TRUE);
 
721
 
 
722
        if (flag) {
 
723
                val |= REC_INFO_DELETED_FLAG;
 
724
        } else {
 
725
                val &= ~REC_INFO_DELETED_FLAG;
 
726
        }
 
727
 
 
728
        rec_set_info_bits_new(rec, val);
 
729
 
 
730
        if (UNIV_LIKELY_NULL(page_zip)) {
 
731
                page_zip_rec_set_deleted(page_zip, rec, flag);
 
732
        }
633
733
}
634
734
 
635
735
/**********************************************************
638
738
ibool
639
739
rec_get_node_ptr_flag(
640
740
/*==================*/
641
 
                        /* out: TRUE if node pointer */
642
 
        rec_t*  rec)    /* in: physical record */
 
741
                                /* out: TRUE if node pointer */
 
742
        const rec_t*    rec)    /* in: physical record */
643
743
{
644
744
        return(REC_STATUS_NODE_PTR == rec_get_status(rec));
645
745
}
646
746
 
647
747
/**********************************************************
648
 
The following function is used to get the order number of the record in the
649
 
heap of the index page. */
650
 
UNIV_INLINE
651
 
ulint
652
 
rec_get_heap_no(
653
 
/*============*/
654
 
                        /* out: heap order number */
655
 
        rec_t*  rec,    /* in: physical record */
656
 
        ulint   comp)   /* in: nonzero=compact page format */
657
 
{
658
 
        ulint   ret;
659
 
 
660
 
        ut_ad(rec);
661
 
 
662
 
        ret = rec_get_bit_field_2(rec,
663
 
                                  comp ? REC_NEW_HEAP_NO : REC_OLD_HEAP_NO,
664
 
                                  REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
665
 
        ut_ad(ret <= REC_MAX_HEAP_NO);
666
 
 
667
 
        return(ret);
668
 
}
669
 
 
670
 
/**********************************************************
671
 
The following function is used to set the heap number field in the record. */
672
 
UNIV_INLINE
673
 
void
674
 
rec_set_heap_no(
675
 
/*============*/
676
 
        rec_t*  rec,    /* in: physical record */
677
 
        ulint   comp,   /* in: nonzero=compact page format */
678
 
        ulint   heap_no)/* in: the heap number */
679
 
{
680
 
        ut_ad(heap_no <= REC_MAX_HEAP_NO);
681
 
 
682
 
        rec_set_bit_field_2(rec, heap_no,
683
 
                            comp ? REC_NEW_HEAP_NO : REC_OLD_HEAP_NO,
 
748
The following function is used to get the order number
 
749
of an old-style record in the heap of the index page. */
 
750
UNIV_INLINE
 
751
ulint
 
752
rec_get_heap_no_old(
 
753
/*================*/
 
754
                                /* out: heap order number */
 
755
        const rec_t*    rec)    /* in: physical record */
 
756
{
 
757
        return(rec_get_bit_field_2(rec, REC_OLD_HEAP_NO,
 
758
                                   REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT));
 
759
}
 
760
 
 
761
/**********************************************************
 
762
The following function is used to set the heap number
 
763
field in an old-style record. */
 
764
UNIV_INLINE
 
765
void
 
766
rec_set_heap_no_old(
 
767
/*================*/
 
768
        rec_t*  rec,    /* in: physical record */
 
769
        ulint   heap_no)/* in: the heap number */
 
770
{
 
771
        rec_set_bit_field_2(rec, heap_no, REC_OLD_HEAP_NO,
 
772
                            REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
 
773
}
 
774
 
 
775
/**********************************************************
 
776
The following function is used to get the order number
 
777
of a new-style record in the heap of the index page. */
 
778
UNIV_INLINE
 
779
ulint
 
780
rec_get_heap_no_new(
 
781
/*================*/
 
782
                                /* out: heap order number */
 
783
        const rec_t*    rec)    /* in: physical record */
 
784
{
 
785
        return(rec_get_bit_field_2(rec, REC_NEW_HEAP_NO,
 
786
                                   REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT));
 
787
}
 
788
 
 
789
/**********************************************************
 
790
The following function is used to set the heap number
 
791
field in a new-style record. */
 
792
UNIV_INLINE
 
793
void
 
794
rec_set_heap_no_new(
 
795
/*================*/
 
796
        rec_t*  rec,    /* in/out: physical record */
 
797
        ulint   heap_no)/* in: the heap number */
 
798
{
 
799
        rec_set_bit_field_2(rec, heap_no, REC_NEW_HEAP_NO,
684
800
                            REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
685
801
}
686
802
 
691
807
ibool
692
808
rec_get_1byte_offs_flag(
693
809
/*====================*/
694
 
                        /* out: TRUE if 1-byte form */
695
 
        rec_t*  rec)    /* in: physical record */
 
810
                                /* out: TRUE if 1-byte form */
 
811
        const rec_t*    rec)    /* in: physical record */
696
812
{
697
813
#if TRUE != 1
698
814
#error "TRUE != 1"
728
844
ulint
729
845
rec_1_get_field_end_info(
730
846
/*=====================*/
731
 
                        /* out: offset of the start of the field, SQL null
732
 
                        flag ORed */
733
 
        rec_t*  rec,    /* in: record */
734
 
        ulint   n)      /* in: field index */
 
847
                                /* out: offset of the start of the
 
848
                                field, SQL null flag ORed */
 
849
        const rec_t*    rec,    /* in: record */
 
850
        ulint           n)      /* in: field index */
735
851
{
736
852
        ut_ad(rec_get_1byte_offs_flag(rec));
737
853
        ut_ad(n < rec_get_n_fields_old(rec));
747
863
ulint
748
864
rec_2_get_field_end_info(
749
865
/*=====================*/
750
 
                        /* out: offset of the start of the field, SQL null
751
 
                        flag and extern storage flag ORed */
752
 
        rec_t*  rec,    /* in: record */
753
 
        ulint   n)      /* in: field index */
 
866
                                /* out: offset of the start of the
 
867
                                field, SQL null flag and extern
 
868
                                storage flag ORed */
 
869
        const rec_t*    rec,    /* in: record */
 
870
        ulint           n)      /* in: field index */
754
871
{
755
872
        ut_ad(!rec_get_1byte_offs_flag(rec));
756
873
        ut_ad(n < rec_get_n_fields_old(rec));
758
875
        return(mach_read_from_2(rec - (REC_N_OLD_EXTRA_BYTES + 2 * n + 2)));
759
876
}
760
877
 
761
 
#ifdef UNIV_DEBUG
762
 
/* Length of the rec_get_offsets() header */
763
 
# define REC_OFFS_HEADER_SIZE   4
764
 
#else /* UNIV_DEBUG */
765
 
/* Length of the rec_get_offsets() header */
766
 
# define REC_OFFS_HEADER_SIZE   2
767
 
#endif /* UNIV_DEBUG */
768
 
 
769
878
/* Get the base address of offsets.  The extra_size is stored at
770
879
this position, and following positions hold the end offsets of
771
880
the fields. */
784
893
        ulint   n_alloc;
785
894
        ut_ad(offsets);
786
895
        n_alloc = offsets[0];
787
 
        ut_ad(n_alloc > 0);
 
896
        ut_ad(n_alloc > REC_OFFS_HEADER_SIZE);
 
897
        UNIV_MEM_ASSERT_W(offsets, n_alloc * sizeof *offsets);
788
898
        return(n_alloc);
789
899
}
790
900
 
800
910
        ulint   n_alloc)        /* in: number of elements */
801
911
{
802
912
        ut_ad(offsets);
803
 
        ut_ad(n_alloc > 0);
 
913
        ut_ad(n_alloc > REC_OFFS_HEADER_SIZE);
804
914
        UNIV_MEM_ASSERT_AND_ALLOC(offsets, n_alloc * sizeof *offsets);
805
915
        offsets[0] = n_alloc;
806
916
}
830
940
ibool
831
941
rec_offs_validate(
832
942
/*==============*/
833
 
                                /* out: TRUE if valid */
834
 
        rec_t*          rec,    /* in: record or NULL */
835
 
        dict_index_t*   index,  /* in: record descriptor or NULL */
836
 
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
 
943
                                        /* out: TRUE if valid */
 
944
        const rec_t*            rec,    /* in: record or NULL */
 
945
        const dict_index_t*     index,  /* in: record descriptor or NULL */
 
946
        const ulint*            offsets)/* in: array returned by
 
947
                                        rec_get_offsets() */
837
948
{
838
949
        ulint   i       = rec_offs_n_fields(offsets);
839
950
        ulint   last    = ULINT_MAX;
878
989
        }
879
990
        return(TRUE);
880
991
}
 
992
#ifdef UNIV_DEBUG
881
993
/****************************************************************
882
994
Updates debug data in offsets, in order to avoid bogus
883
995
rec_offs_validate() failures. */
885
997
void
886
998
rec_offs_make_valid(
887
999
/*================*/
888
 
        rec_t*          rec __attribute__((unused)),
889
 
                                /* in: record */
890
 
        dict_index_t*   index __attribute__((unused)),
891
 
                                /* in: record descriptor */
892
 
        const ulint*            offsets __attribute__((unused)))
893
 
                                /* in: array returned by rec_get_offsets() */
 
1000
        const rec_t*            rec,    /* in: record */
 
1001
        const dict_index_t*     index,  /* in: record descriptor */
 
1002
        ulint*                  offsets)/* in: array returned by
 
1003
                                        rec_get_offsets() */
894
1004
{
895
 
#ifdef UNIV_DEBUG
 
1005
        ut_ad(rec);
 
1006
        ut_ad(index);
 
1007
        ut_ad(offsets);
896
1008
        ut_ad(rec_get_n_fields(rec, index) >= rec_offs_n_fields(offsets));
897
1009
        offsets[2] = (ulint) rec;
898
1010
        offsets[3] = (ulint) index;
 
1011
}
899
1012
#endif /* UNIV_DEBUG */
900
 
}
901
1013
 
902
1014
/****************************************************************
903
 
The following function is used to get a pointer to the nth
 
1015
The following function is used to get an offset to the nth
904
1016
data field in a record. */
905
1017
UNIV_INLINE
906
 
byte*
907
 
rec_get_nth_field(
908
 
/*==============*/
909
 
                                /* out: pointer to the field */
910
 
        rec_t*          rec,    /* in: record */
 
1018
ulint
 
1019
rec_get_nth_field_offs(
 
1020
/*===================*/
 
1021
                                /* out: offset from the origin of rec */
911
1022
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
912
1023
        ulint           n,      /* in: index of the field */
913
1024
        ulint*          len)    /* out: length of the field; UNIV_SQL_NULL
914
1025
                                if SQL null */
915
1026
{
916
 
        byte*   field;
 
1027
        ulint   offs;
917
1028
        ulint   length;
918
 
        ut_ad(rec);
919
 
        ut_ad(rec_offs_validate(rec, NULL, offsets));
920
1029
        ut_ad(n < rec_offs_n_fields(offsets));
921
1030
        ut_ad(len);
922
1031
 
923
1032
        if (UNIV_UNLIKELY(n == 0)) {
924
 
                field = rec;
 
1033
                offs = 0;
925
1034
        } else {
926
 
                field = rec + (rec_offs_base(offsets)[n] & REC_OFFS_MASK);
 
1035
                offs = rec_offs_base(offsets)[n] & REC_OFFS_MASK;
927
1036
        }
928
1037
 
929
1038
        length = rec_offs_base(offsets)[1 + n];
932
1041
                length = UNIV_SQL_NULL;
933
1042
        } else {
934
1043
                length &= REC_OFFS_MASK;
935
 
                length -= field - rec;
 
1044
                length -= offs;
936
1045
        }
937
1046
 
938
1047
        *len = length;
939
 
        return(field);
 
1048
        return(offs);
940
1049
}
941
1050
 
942
1051
/**********************************************************
954
1063
}
955
1064
 
956
1065
/**********************************************************
 
1066
Determine if the offsets are for a record containing
 
1067
externally stored columns. */
 
1068
UNIV_INLINE
 
1069
ulint
 
1070
rec_offs_any_extern(
 
1071
/*================*/
 
1072
                                /* out: nonzero if externally stored */
 
1073
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
 
1074
{
 
1075
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
 
1076
        return(UNIV_UNLIKELY(*rec_offs_base(offsets) & REC_OFFS_EXTERNAL));
 
1077
}
 
1078
 
 
1079
/**********************************************************
957
1080
Returns nonzero if the extern bit is set in nth field of rec. */
958
1081
UNIV_INLINE
959
1082
ulint
1005
1128
}
1006
1129
 
1007
1130
/**********************************************************
1008
 
Returns TRUE if the extern bit is set in any of the fields
1009
 
of an old-style record. */
 
1131
Returns the number of extern bits set in a record. */
1010
1132
UNIV_INLINE
1011
 
ibool
1012
 
rec_offs_any_extern(
1013
 
/*================*/
1014
 
                                /* out: TRUE if a field is stored externally */
 
1133
ulint
 
1134
rec_offs_n_extern(
 
1135
/*==============*/
 
1136
                                /* out: number of externally stored fields */
1015
1137
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1016
1138
{
1017
 
        ulint   i;
1018
 
        for (i = rec_offs_n_fields(offsets); i--; ) {
1019
 
                if (rec_offs_nth_extern(offsets, i)) {
1020
 
                        return(TRUE);
 
1139
        ulint   n = 0;
 
1140
 
 
1141
        if (rec_offs_any_extern(offsets)) {
 
1142
                ulint   i;
 
1143
 
 
1144
                for (i = rec_offs_n_fields(offsets); i--; ) {
 
1145
                        if (rec_offs_nth_extern(offsets, i)) {
 
1146
                                n++;
 
1147
                        }
1021
1148
                }
1022
1149
        }
1023
 
        return(FALSE);
1024
 
}
1025
1150
 
1026
 
/***************************************************************
1027
 
Sets the value of the ith field extern storage bit. */
1028
 
UNIV_INLINE
1029
 
void
1030
 
rec_set_nth_field_extern_bit(
1031
 
/*=========================*/
1032
 
        rec_t*          rec,    /* in: record */
1033
 
        dict_index_t*   index,  /* in: record descriptor */
1034
 
        ulint           i,      /* in: ith field */
1035
 
        ibool           val,    /* in: value to set */
1036
 
        mtr_t*          mtr)    /* in: mtr holding an X-latch to the page
1037
 
                                where rec is, or NULL; in the NULL case
1038
 
                                we do not write to log about the change */
1039
 
{
1040
 
        if (dict_table_is_comp(index->table)) {
1041
 
                rec_set_nth_field_extern_bit_new(rec, index, i, val, mtr);
1042
 
        } else {
1043
 
                rec_set_nth_field_extern_bit_old(rec, i, val, mtr);
1044
 
        }
 
1151
        return(n);
1045
1152
}
1046
1153
 
1047
1154
/**********************************************************
1054
1161
ulint
1055
1162
rec_1_get_prev_field_end_info(
1056
1163
/*==========================*/
1057
 
                        /* out: offset of the start of the PREVIOUS field, SQL
1058
 
                        null flag ORed */
1059
 
        rec_t*  rec,    /* in: record */
1060
 
        ulint   n)      /* in: field index */
 
1164
                                /* out: offset of the start of the
 
1165
                                PREVIOUS field, SQL null flag ORed */
 
1166
        const rec_t*    rec,    /* in: record */
 
1167
        ulint           n)      /* in: field index */
1061
1168
{
1062
1169
        ut_ad(rec_get_1byte_offs_flag(rec));
1063
1170
        ut_ad(n <= rec_get_n_fields_old(rec));
1073
1180
ulint
1074
1181
rec_2_get_prev_field_end_info(
1075
1182
/*==========================*/
1076
 
                        /* out: offset of the start of the PREVIOUS field, SQL
1077
 
                        null flag ORed */
1078
 
        rec_t*  rec,    /* in: record */
1079
 
        ulint   n)      /* in: field index */
 
1183
                                /* out: offset of the start of the
 
1184
                                PREVIOUS field, SQL null flag ORed */
 
1185
        const rec_t*    rec,    /* in: record */
 
1186
        ulint           n)      /* in: field index */
1080
1187
{
1081
1188
        ut_ad(!rec_get_1byte_offs_flag(rec));
1082
1189
        ut_ad(n <= rec_get_n_fields_old(rec));
1125
1232
ulint
1126
1233
rec_1_get_field_start_offs(
1127
1234
/*=======================*/
1128
 
                        /* out: offset of the start of the field */
1129
 
        rec_t*  rec,    /* in: record */
1130
 
        ulint   n)      /* in: field index */
 
1235
                                /* out: offset of the start of the field */
 
1236
        const rec_t*    rec,    /* in: record */
 
1237
        ulint           n)      /* in: field index */
1131
1238
{
1132
1239
        ut_ad(rec_get_1byte_offs_flag(rec));
1133
1240
        ut_ad(n <= rec_get_n_fields_old(rec));
1148
1255
ulint
1149
1256
rec_2_get_field_start_offs(
1150
1257
/*=======================*/
1151
 
                        /* out: offset of the start of the field */
1152
 
        rec_t*  rec,    /* in: record */
1153
 
        ulint   n)      /* in: field index */
 
1258
                                /* out: offset of the start of the field */
 
1259
        const rec_t*    rec,    /* in: record */
 
1260
        ulint           n)      /* in: field index */
1154
1261
{
1155
1262
        ut_ad(!rec_get_1byte_offs_flag(rec));
1156
1263
        ut_ad(n <= rec_get_n_fields_old(rec));
1173
1280
ulint
1174
1281
rec_get_field_start_offs(
1175
1282
/*=====================*/
1176
 
                        /* out: offset of the start of the field */
1177
 
        rec_t*  rec,    /* in: record */
1178
 
        ulint   n)      /* in: field index */
 
1283
                                /* out: offset of the start of the field */
 
1284
        const rec_t*    rec,    /* in: record */
 
1285
        ulint           n)      /* in: field index */
1179
1286
{
1180
1287
        ut_ad(rec);
1181
1288
        ut_ad(n <= rec_get_n_fields_old(rec));
1201
1308
ulint
1202
1309
rec_get_nth_field_size(
1203
1310
/*===================*/
1204
 
                        /* out: field size in bytes */
1205
 
        rec_t*  rec,    /* in: record */
1206
 
        ulint   n)      /* in: index of the field */
 
1311
                                /* out: field size in bytes */
 
1312
        const rec_t*    rec,    /* in: record */
 
1313
        ulint           n)      /* in: index of the field */
1207
1314
{
1208
1315
        ulint   os;
1209
1316
        ulint   next_os;
1271
1378
rec_get_data_size_old(
1272
1379
/*==================*/
1273
1380
                                /* out: size */
1274
 
        rec_t*  rec)    /* in: physical record */
 
1381
        const rec_t*    rec)    /* in: physical record */
1275
1382
{
1276
1383
        ut_ad(rec);
1277
1384
 
1330
1437
{
1331
1438
        ulint   size;
1332
1439
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1333
 
        size = *rec_offs_base(offsets) & ~REC_OFFS_COMPACT;
 
1440
        size = *rec_offs_base(offsets) & ~(REC_OFFS_COMPACT | REC_OFFS_EXTERNAL);
1334
1441
        ut_ad(size < UNIV_PAGE_SIZE);
1335
1442
        return(size);
1336
1443
}
1357
1464
        rec_t*          rec,    /* in: pointer to record */
1358
1465
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1359
1466
{
 
1467
        ut_ad(rec_offs_validate(rec, NULL, offsets));
1360
1468
        return(rec + rec_offs_data_size(offsets));
1361
1469
}
1362
1470
 
1370
1478
        rec_t*          rec,    /* in: pointer to record */
1371
1479
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1372
1480
{
 
1481
        ut_ad(rec_offs_validate(rec, NULL, offsets));
1373
1482
        return(rec - rec_offs_extra_size(offsets));
1374
1483
}
1375
1484
 
1389
1498
 
1390
1499
        ut_ad(rec && buf);
1391
1500
        ut_ad(rec_offs_validate((rec_t*) rec, NULL, offsets));
1392
 
        ut_ad(rec_validate((rec_t*) rec, offsets));
 
1501
        ut_ad(rec_validate(rec, offsets));
1393
1502
 
1394
1503
        extra_len = rec_offs_extra_size(offsets);
1395
1504
        data_len = rec_offs_data_size(offsets);
1408
1517
/*=========================*/
1409
1518
                                /* out: extra size */
1410
1519
        ulint   data_size,      /* in: data size */
1411
 
        ulint   n_fields)       /* in: number of fields */
 
1520
        ulint   n_fields,       /* in: number of fields */
 
1521
        ulint   n_ext)          /* in: number of externally stored columns */
1412
1522
{
1413
 
        if (data_size <= REC_1BYTE_OFFS_LIMIT) {
 
1523
        if (!n_ext && data_size <= REC_1BYTE_OFFS_LIMIT) {
1414
1524
 
1415
1525
                return(REC_N_OLD_EXTRA_BYTES + n_fields);
1416
1526
        }
1420
1530
 
1421
1531
/**************************************************************
1422
1532
The following function returns the size of a data tuple when converted to
1423
 
a new-style physical record. */
1424
 
 
1425
 
ulint
1426
 
rec_get_converted_size_new(
1427
 
/*=======================*/
1428
 
                                /* out: size */
1429
 
        dict_index_t*   index,  /* in: record descriptor */
1430
 
        dtuple_t*       dtuple);/* in: data tuple */
1431
 
/**************************************************************
1432
 
The following function returns the size of a data tuple when converted to
1433
1533
a physical record. */
1434
1534
UNIV_INLINE
1435
1535
ulint
1437
1537
/*===================*/
1438
1538
                                /* out: size */
1439
1539
        dict_index_t*   index,  /* in: record descriptor */
1440
 
        dtuple_t*       dtuple) /* in: data tuple */
 
1540
        const dtuple_t* dtuple, /* in: data tuple */
 
1541
        ulint           n_ext)  /* in: number of externally stored columns */
1441
1542
{
1442
1543
        ulint   data_size;
1443
1544
        ulint   extra_size;
1454
1555
                  : dict_index_get_n_fields(index)));
1455
1556
 
1456
1557
        if (dict_table_is_comp(index->table)) {
1457
 
                return(rec_get_converted_size_new(index, dtuple));
 
1558
                return(rec_get_converted_size_comp(index,
 
1559
                                                   dtuple_get_info_bits(dtuple)
 
1560
                                                   & REC_NEW_STATUS_MASK,
 
1561
                                                   dtuple->fields,
 
1562
                                                   dtuple->n_fields, NULL));
1458
1563
        }
1459
1564
 
1460
1565
        data_size = dtuple_get_data_size(dtuple);
1461
1566
 
1462
1567
        extra_size = rec_get_converted_extra_size(
1463
 
                data_size, dtuple_get_n_fields(dtuple));
 
1568
                data_size, dtuple_get_n_fields(dtuple), n_ext);
1464
1569
 
1465
1570
        return(data_size + extra_size);
1466
1571
}
1473
1578
rec_fold(
1474
1579
/*=====*/
1475
1580
                                        /* out: the folded value */
1476
 
        rec_t*          rec,            /* in: the physical record */
 
1581
        const rec_t*    rec,            /* in: the physical record */
1477
1582
        const ulint*    offsets,        /* in: array returned by
1478
1583
                                        rec_get_offsets() */
1479
1584
        ulint           n_fields,       /* in: number of complete
1482
1587
                                        in an incomplete last field */
1483
1588
        dulint          tree_id)        /* in: index tree id */
1484
1589
{
1485
 
        ulint   i;
1486
 
        byte*   data;
1487
 
        ulint   len;
1488
 
        ulint   fold;
1489
 
        ulint   n_fields_rec;
 
1590
        ulint           i;
 
1591
        const byte*     data;
 
1592
        ulint           len;
 
1593
        ulint           fold;
 
1594
        ulint           n_fields_rec;
1490
1595
 
1491
1596
        ut_ad(rec_offs_validate(rec, NULL, offsets));
1492
 
        ut_ad(rec_validate((rec_t*) rec, offsets));
 
1597
        ut_ad(rec_validate(rec, offsets));
1493
1598
        ut_ad(n_fields + n_bytes > 0);
1494
1599
 
1495
1600
        n_fields_rec = rec_offs_n_fields(offsets);