~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/********************************************************************//**
20
 
@file include/rem0rec.ic
 
19
/************************************************************************
21
20
Record manager
22
21
 
23
22
Created 5/30/1994 Heikki Tuuri
144
143
# error "sum of new-style masks != 0xFFFFFFUL"
145
144
#endif
146
145
 
147
 
/***********************************************************//**
 
146
/***************************************************************
148
147
Sets the value of the ith field SQL null bit of an old-style record. */
149
148
UNIV_INTERN
150
149
void
151
150
rec_set_nth_field_null_bit(
152
151
/*=======================*/
153
 
        rec_t*  rec,    /*!< in: record */
154
 
        ulint   i,      /*!< in: ith field */
155
 
        ibool   val);   /*!< in: value to set */
156
 
/***********************************************************//**
 
152
        rec_t*  rec,    /* in: record */
 
153
        ulint   i,      /* in: ith field */
 
154
        ibool   val);   /* in: value to set */
 
155
/***************************************************************
157
156
Sets an old-style record field to SQL null.
158
157
The physical size of the field is not changed. */
159
158
UNIV_INTERN
160
159
void
161
160
rec_set_nth_field_sql_null(
162
161
/*=======================*/
163
 
        rec_t*  rec,    /*!< in: record */
164
 
        ulint   n);     /*!< in: index of the field */
 
162
        rec_t*  rec,    /* in: record */
 
163
        ulint   n);     /* in: index of the field */
165
164
 
166
 
/******************************************************//**
 
165
/**********************************************************
167
166
Gets a bit field from within 1 byte. */
168
167
UNIV_INLINE
169
168
ulint
170
169
rec_get_bit_field_1(
171
170
/*================*/
172
 
        const rec_t*    rec,    /*!< in: pointer to record origin */
173
 
        ulint           offs,   /*!< in: offset from the origin down */
174
 
        ulint           mask,   /*!< in: mask used to filter bits */
175
 
        ulint           shift)  /*!< in: shift right applied after masking */
 
171
        const rec_t*    rec,    /* in: pointer to record origin */
 
172
        ulint           offs,   /* in: offset from the origin down */
 
173
        ulint           mask,   /* in: mask used to filter bits */
 
174
        ulint           shift)  /* in: shift right applied after masking */
176
175
{
177
176
        ut_ad(rec);
178
177
 
179
178
        return((mach_read_from_1(rec - offs) & mask) >> shift);
180
179
}
181
180
 
182
 
/******************************************************//**
 
181
/**********************************************************
183
182
Sets a bit field within 1 byte. */
184
183
UNIV_INLINE
185
184
void
186
185
rec_set_bit_field_1(
187
186
/*================*/
188
 
        rec_t*  rec,    /*!< in: pointer to record origin */
189
 
        ulint   val,    /*!< in: value to set */
190
 
        ulint   offs,   /*!< in: offset from the origin down */
191
 
        ulint   mask,   /*!< in: mask used to filter bits */
192
 
        ulint   shift)  /*!< in: shift right applied after masking */
 
187
        rec_t*  rec,    /* in: pointer to record origin */
 
188
        ulint   val,    /* in: value to set */
 
189
        ulint   offs,   /* in: offset from the origin down */
 
190
        ulint   mask,   /* in: mask used to filter bits */
 
191
        ulint   shift)  /* in: shift right applied after masking */
193
192
{
194
193
        ut_ad(rec);
195
194
        ut_ad(offs <= REC_N_OLD_EXTRA_BYTES);
203
202
                        | (val << shift));
204
203
}
205
204
 
206
 
/******************************************************//**
 
205
/**********************************************************
207
206
Gets a bit field from within 2 bytes. */
208
207
UNIV_INLINE
209
208
ulint
210
209
rec_get_bit_field_2(
211
210
/*================*/
212
 
        const rec_t*    rec,    /*!< in: pointer to record origin */
213
 
        ulint           offs,   /*!< in: offset from the origin down */
214
 
        ulint           mask,   /*!< in: mask used to filter bits */
215
 
        ulint           shift)  /*!< in: shift right applied after masking */
 
211
        const rec_t*    rec,    /* in: pointer to record origin */
 
212
        ulint           offs,   /* in: offset from the origin down */
 
213
        ulint           mask,   /* in: mask used to filter bits */
 
214
        ulint           shift)  /* in: shift right applied after masking */
216
215
{
217
216
        ut_ad(rec);
218
217
 
219
218
        return((mach_read_from_2(rec - offs) & mask) >> shift);
220
219
}
221
220
 
222
 
/******************************************************//**
 
221
/**********************************************************
223
222
Sets a bit field within 2 bytes. */
224
223
UNIV_INLINE
225
224
void
226
225
rec_set_bit_field_2(
227
226
/*================*/
228
 
        rec_t*  rec,    /*!< in: pointer to record origin */
229
 
        ulint   val,    /*!< in: value to set */
230
 
        ulint   offs,   /*!< in: offset from the origin down */
231
 
        ulint   mask,   /*!< in: mask used to filter bits */
232
 
        ulint   shift)  /*!< in: shift right applied after masking */
 
227
        rec_t*  rec,    /* in: pointer to record origin */
 
228
        ulint   val,    /* in: value to set */
 
229
        ulint   offs,   /* in: offset from the origin down */
 
230
        ulint   mask,   /* in: mask used to filter bits */
 
231
        ulint   shift)  /* in: shift right applied after masking */
233
232
{
234
233
        ut_ad(rec);
235
234
        ut_ad(offs <= REC_N_OLD_EXTRA_BYTES);
245
244
                        | (val << shift));
246
245
}
247
246
 
248
 
/******************************************************//**
 
247
/**********************************************************
249
248
The following function is used to get the pointer of the next chained record
250
 
on the same page.
251
 
@return pointer to the next chained record, or NULL if none */
 
249
on the same page. */
252
250
UNIV_INLINE
253
251
const rec_t*
254
252
rec_get_next_ptr_const(
255
253
/*===================*/
256
 
        const rec_t*    rec,    /*!< in: physical record */
257
 
        ulint           comp)   /*!< in: nonzero=compact page format */
 
254
                                /* out: pointer to the next chained record, or
 
255
                                NULL if none */
 
256
        const rec_t*    rec,    /* in: physical record */
 
257
        ulint           comp)   /* in: nonzero=compact page format */
258
258
{
259
259
        ulint   field_value;
260
260
 
301
301
        }
302
302
}
303
303
 
304
 
/******************************************************//**
 
304
/**********************************************************
305
305
The following function is used to get the pointer of the next chained record
306
 
on the same page.
307
 
@return pointer to the next chained record, or NULL if none */
 
306
on the same page. */
308
307
UNIV_INLINE
309
308
rec_t*
310
309
rec_get_next_ptr(
311
310
/*=============*/
312
 
        rec_t*  rec,    /*!< in: physical record */
313
 
        ulint   comp)   /*!< in: nonzero=compact page format */
 
311
                        /* out: pointer to the next chained record, or
 
312
                        NULL if none */
 
313
        rec_t*  rec,    /* in: physical record */
 
314
        ulint   comp)   /* in: nonzero=compact page format */
314
315
{
315
316
        return((rec_t*) rec_get_next_ptr_const(rec, comp));
316
317
}
317
318
 
318
 
/******************************************************//**
 
319
/**********************************************************
319
320
The following function is used to get the offset of the next chained record
320
 
on the same page.
321
 
@return the page offset of the next chained record, or 0 if none */
 
321
on the same page. */
322
322
UNIV_INLINE
323
323
ulint
324
324
rec_get_next_offs(
325
325
/*==============*/
326
 
        const rec_t*    rec,    /*!< in: physical record */
327
 
        ulint           comp)   /*!< in: nonzero=compact page format */
 
326
                                /* out: the page offset of the next
 
327
                                chained record, or 0 if none */
 
328
        const rec_t*    rec,    /* in: physical record */
 
329
        ulint           comp)   /* in: nonzero=compact page format */
328
330
{
329
331
        ulint   field_value;
330
332
#if REC_NEXT_MASK != 0xFFFFUL
372
374
        }
373
375
}
374
376
 
375
 
/******************************************************//**
 
377
/**********************************************************
376
378
The following function is used to set the next record offset field
377
379
of an old-style record. */
378
380
UNIV_INLINE
379
381
void
380
382
rec_set_next_offs_old(
381
383
/*==================*/
382
 
        rec_t*  rec,    /*!< in: old-style physical record */
383
 
        ulint   next)   /*!< in: offset of the next record */
 
384
        rec_t*  rec,    /* in: old-style physical record */
 
385
        ulint   next)   /* in: offset of the next record */
384
386
{
385
387
        ut_ad(rec);
386
388
        ut_ad(UNIV_PAGE_SIZE > next);
394
396
        mach_write_to_2(rec - REC_NEXT, next);
395
397
}
396
398
 
397
 
/******************************************************//**
 
399
/**********************************************************
398
400
The following function is used to set the next record offset field
399
401
of a new-style record. */
400
402
UNIV_INLINE
401
403
void
402
404
rec_set_next_offs_new(
403
405
/*==================*/
404
 
        rec_t*  rec,    /*!< in/out: new-style physical record */
405
 
        ulint   next)   /*!< in: offset of the next record */
 
406
        rec_t*  rec,    /* in/out: new-style physical record */
 
407
        ulint   next)   /* in: offset of the next record */
406
408
{
407
409
        ulint   field_value;
408
410
 
425
427
        mach_write_to_2(rec - REC_NEXT, field_value);
426
428
}
427
429
 
428
 
/******************************************************//**
 
430
/**********************************************************
429
431
The following function is used to get the number of fields
430
 
in an old-style record.
431
 
@return number of data fields */
 
432
in an old-style record. */
432
433
UNIV_INLINE
433
434
ulint
434
435
rec_get_n_fields_old(
435
436
/*=================*/
436
 
        const rec_t*    rec)    /*!< in: physical record */
 
437
                                /* out: number of data fields */
 
438
        const rec_t*    rec)    /* in: physical record */
437
439
{
438
440
        ulint   ret;
439
441
 
448
450
        return(ret);
449
451
}
450
452
 
451
 
/******************************************************//**
 
453
/**********************************************************
452
454
The following function is used to set the number of fields
453
455
in an old-style record. */
454
456
UNIV_INLINE
455
457
void
456
458
rec_set_n_fields_old(
457
459
/*=================*/
458
 
        rec_t*  rec,            /*!< in: physical record */
459
 
        ulint   n_fields)       /*!< in: the number of fields */
 
460
        rec_t*  rec,            /* in: physical record */
 
461
        ulint   n_fields)       /* in: the number of fields */
460
462
{
461
463
        ut_ad(rec);
462
464
        ut_ad(n_fields <= REC_MAX_N_FIELDS);
466
468
                            REC_OLD_N_FIELDS_MASK, REC_OLD_N_FIELDS_SHIFT);
467
469
}
468
470
 
469
 
/******************************************************//**
470
 
The following function retrieves the status bits of a new-style record.
471
 
@return status bits */
 
471
/**********************************************************
 
472
The following function retrieves the status bits of a new-style record. */
472
473
UNIV_INLINE
473
474
ulint
474
475
rec_get_status(
475
476
/*===========*/
476
 
        const rec_t*    rec)    /*!< in: physical record */
 
477
                                /* out: status bits */
 
478
        const rec_t*    rec)    /* in: physical record */
477
479
{
478
480
        ulint   ret;
479
481
 
486
488
        return(ret);
487
489
}
488
490
 
489
 
/******************************************************//**
 
491
/**********************************************************
490
492
The following function is used to get the number of fields
491
 
in a record.
492
 
@return number of data fields */
 
493
in a record. */
493
494
UNIV_INLINE
494
495
ulint
495
496
rec_get_n_fields(
496
497
/*=============*/
497
 
        const rec_t*            rec,    /*!< in: physical record */
498
 
        const dict_index_t*     index)  /*!< in: record descriptor */
 
498
                                        /* out: number of data fields */
 
499
        const rec_t*            rec,    /* in: physical record */
 
500
        const dict_index_t*     index)  /* in: record descriptor */
499
501
{
500
502
        ut_ad(rec);
501
503
        ut_ad(index);
518
520
        }
519
521
}
520
522
 
521
 
/******************************************************//**
 
523
/**********************************************************
522
524
The following function is used to get the number of records owned by the
523
 
previous directory record.
524
 
@return number of owned records */
 
525
previous directory record. */
525
526
UNIV_INLINE
526
527
ulint
527
528
rec_get_n_owned_old(
528
529
/*================*/
529
 
        const rec_t*    rec)    /*!< in: old-style physical record */
 
530
                                /* out: number of owned records */
 
531
        const rec_t*    rec)    /* in: old-style physical record */
530
532
{
531
533
        return(rec_get_bit_field_1(rec, REC_OLD_N_OWNED,
532
534
                                   REC_N_OWNED_MASK, REC_N_OWNED_SHIFT));
533
535
}
534
536
 
535
 
/******************************************************//**
 
537
/**********************************************************
536
538
The following function is used to set the number of owned records. */
537
539
UNIV_INLINE
538
540
void
539
541
rec_set_n_owned_old(
540
542
/*================*/
541
 
        rec_t*  rec,            /*!< in: old-style physical record */
542
 
        ulint   n_owned)        /*!< in: the number of owned */
 
543
                                /* out: TRUE on success */
 
544
        rec_t*  rec,            /* in: old-style physical record */
 
545
        ulint   n_owned)        /* in: the number of owned */
543
546
{
544
547
        rec_set_bit_field_1(rec, n_owned, REC_OLD_N_OWNED,
545
548
                            REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
546
549
}
547
550
 
548
 
/******************************************************//**
 
551
/**********************************************************
549
552
The following function is used to get the number of records owned by the
550
 
previous directory record.
551
 
@return number of owned records */
 
553
previous directory record. */
552
554
UNIV_INLINE
553
555
ulint
554
556
rec_get_n_owned_new(
555
557
/*================*/
556
 
        const rec_t*    rec)    /*!< in: new-style physical record */
 
558
                                /* out: number of owned records */
 
559
        const rec_t*    rec)    /* in: new-style physical record */
557
560
{
558
561
        return(rec_get_bit_field_1(rec, REC_NEW_N_OWNED,
559
562
                                   REC_N_OWNED_MASK, REC_N_OWNED_SHIFT));
560
563
}
561
564
 
562
 
/******************************************************//**
 
565
/**********************************************************
563
566
The following function is used to set the number of owned records. */
564
567
UNIV_INLINE
565
568
void
566
569
rec_set_n_owned_new(
567
570
/*================*/
568
 
        rec_t*          rec,    /*!< in/out: new-style physical record */
569
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
570
 
        ulint           n_owned)/*!< in: the number of owned */
 
571
        rec_t*          rec,    /* in/out: new-style physical record */
 
572
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
573
        ulint           n_owned)/* in: the number of owned */
571
574
{
572
575
        rec_set_bit_field_1(rec, n_owned, REC_NEW_N_OWNED,
573
576
                            REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
578
581
        }
579
582
}
580
583
 
581
 
/******************************************************//**
582
 
The following function is used to retrieve the info bits of a record.
583
 
@return info bits */
 
584
/**********************************************************
 
585
The following function is used to retrieve the info bits of a record. */
584
586
UNIV_INLINE
585
587
ulint
586
588
rec_get_info_bits(
587
589
/*==============*/
588
 
        const rec_t*    rec,    /*!< in: physical record */
589
 
        ulint           comp)   /*!< in: nonzero=compact page format */
 
590
                                /* out: info bits */
 
591
        const rec_t*    rec,    /* in: physical record */
 
592
        ulint           comp)   /* in: nonzero=compact page format */
590
593
{
591
594
        return(rec_get_bit_field_1(
592
595
                       rec, comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS,
593
596
                       REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT));
594
597
}
595
598
 
596
 
/******************************************************//**
 
599
/**********************************************************
597
600
The following function is used to set the info bits of a record. */
598
601
UNIV_INLINE
599
602
void
600
603
rec_set_info_bits_old(
601
604
/*==================*/
602
 
        rec_t*  rec,    /*!< in: old-style physical record */
603
 
        ulint   bits)   /*!< in: info bits */
 
605
        rec_t*  rec,    /* in: old-style physical record */
 
606
        ulint   bits)   /* in: info bits */
604
607
{
605
608
        rec_set_bit_field_1(rec, bits, REC_OLD_INFO_BITS,
606
609
                            REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
607
610
}
608
 
/******************************************************//**
 
611
/**********************************************************
609
612
The following function is used to set the info bits of a record. */
610
613
UNIV_INLINE
611
614
void
612
615
rec_set_info_bits_new(
613
616
/*==================*/
614
 
        rec_t*  rec,    /*!< in/out: new-style physical record */
615
 
        ulint   bits)   /*!< in: info bits */
 
617
        rec_t*  rec,    /* in/out: new-style physical record */
 
618
        ulint   bits)   /* in: info bits */
616
619
{
617
620
        rec_set_bit_field_1(rec, bits, REC_NEW_INFO_BITS,
618
621
                            REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
619
622
}
620
623
 
621
 
/******************************************************//**
 
624
/**********************************************************
622
625
The following function is used to set the status bits of a new-style record. */
623
626
UNIV_INLINE
624
627
void
625
628
rec_set_status(
626
629
/*===========*/
627
 
        rec_t*  rec,    /*!< in/out: physical record */
628
 
        ulint   bits)   /*!< in: info bits */
 
630
        rec_t*  rec,    /* in/out: physical record */
 
631
        ulint   bits)   /* in: info bits */
629
632
{
630
633
        rec_set_bit_field_1(rec, bits, REC_NEW_STATUS,
631
634
                            REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT);
632
635
}
633
636
 
634
 
/******************************************************//**
 
637
/**********************************************************
635
638
The following function is used to retrieve the info and status
636
 
bits of a record.  (Only compact records have status bits.)
637
 
@return info bits */
 
639
bits of a record.  (Only compact records have status bits.) */
638
640
UNIV_INLINE
639
641
ulint
640
642
rec_get_info_and_status_bits(
641
643
/*=========================*/
642
 
        const rec_t*    rec,    /*!< in: physical record */
643
 
        ulint           comp)   /*!< in: nonzero=compact page format */
 
644
                                /* out: info bits */
 
645
        const rec_t*    rec,    /* in: physical record */
 
646
        ulint           comp)   /* in: nonzero=compact page format */
644
647
{
645
648
        ulint   bits;
646
649
#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \
655
658
        }
656
659
        return(bits);
657
660
}
658
 
/******************************************************//**
 
661
/**********************************************************
659
662
The following function is used to set the info and status
660
663
bits of a record.  (Only compact records have status bits.) */
661
664
UNIV_INLINE
662
665
void
663
666
rec_set_info_and_status_bits(
664
667
/*=========================*/
665
 
        rec_t*  rec,    /*!< in/out: physical record */
666
 
        ulint   bits)   /*!< in: info bits */
 
668
        rec_t*  rec,    /* in/out: physical record */
 
669
        ulint   bits)   /* in: info bits */
667
670
{
668
671
#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \
669
672
& (REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT)
673
676
        rec_set_info_bits_new(rec, bits & ~REC_NEW_STATUS_MASK);
674
677
}
675
678
 
676
 
/******************************************************//**
677
 
The following function tells if record is delete marked.
678
 
@return nonzero if delete marked */
 
679
/**********************************************************
 
680
The following function tells if record is delete marked. */
679
681
UNIV_INLINE
680
682
ulint
681
683
rec_get_deleted_flag(
682
684
/*=================*/
683
 
        const rec_t*    rec,    /*!< in: physical record */
684
 
        ulint           comp)   /*!< in: nonzero=compact page format */
 
685
                                /* out: nonzero if delete marked */
 
686
        const rec_t*    rec,    /* in: physical record */
 
687
        ulint           comp)   /* in: nonzero=compact page format */
685
688
{
686
689
        if (UNIV_EXPECT(comp, REC_OFFS_COMPACT)) {
687
690
                return(UNIV_UNLIKELY(
696
699
        }
697
700
}
698
701
 
699
 
/******************************************************//**
 
702
/**********************************************************
700
703
The following function is used to set the deleted bit. */
701
704
UNIV_INLINE
702
705
void
703
706
rec_set_deleted_flag_old(
704
707
/*=====================*/
705
 
        rec_t*  rec,    /*!< in: old-style physical record */
706
 
        ulint   flag)   /*!< in: nonzero if delete marked */
 
708
        rec_t*  rec,    /* in: old-style physical record */
 
709
        ulint   flag)   /* in: nonzero if delete marked */
707
710
{
708
711
        ulint   val;
709
712
 
718
721
        rec_set_info_bits_old(rec, val);
719
722
}
720
723
 
721
 
/******************************************************//**
 
724
/**********************************************************
722
725
The following function is used to set the deleted bit. */
723
726
UNIV_INLINE
724
727
void
725
728
rec_set_deleted_flag_new(
726
729
/*=====================*/
727
 
        rec_t*          rec,    /*!< in/out: new-style physical record */
728
 
        page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
729
 
        ulint           flag)   /*!< in: nonzero if delete marked */
 
730
        rec_t*          rec,    /* in/out: new-style physical record */
 
731
        page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
 
732
        ulint           flag)   /* in: nonzero if delete marked */
730
733
{
731
734
        ulint   val;
732
735
 
745
748
        }
746
749
}
747
750
 
748
 
/******************************************************//**
749
 
The following function tells if a new-style record is a node pointer.
750
 
@return TRUE if node pointer */
 
751
/**********************************************************
 
752
The following function tells if a new-style record is a node pointer. */
751
753
UNIV_INLINE
752
754
ibool
753
755
rec_get_node_ptr_flag(
754
756
/*==================*/
755
 
        const rec_t*    rec)    /*!< in: physical record */
 
757
                                /* out: TRUE if node pointer */
 
758
        const rec_t*    rec)    /* in: physical record */
756
759
{
757
760
        return(REC_STATUS_NODE_PTR == rec_get_status(rec));
758
761
}
759
762
 
760
 
/******************************************************//**
 
763
/**********************************************************
761
764
The following function is used to get the order number
762
 
of an old-style record in the heap of the index page.
763
 
@return heap order number */
 
765
of an old-style record in the heap of the index page. */
764
766
UNIV_INLINE
765
767
ulint
766
768
rec_get_heap_no_old(
767
769
/*================*/
768
 
        const rec_t*    rec)    /*!< in: physical record */
 
770
                                /* out: heap order number */
 
771
        const rec_t*    rec)    /* in: physical record */
769
772
{
770
773
        return(rec_get_bit_field_2(rec, REC_OLD_HEAP_NO,
771
774
                                   REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT));
772
775
}
773
776
 
774
 
/******************************************************//**
 
777
/**********************************************************
775
778
The following function is used to set the heap number
776
779
field in an old-style record. */
777
780
UNIV_INLINE
778
781
void
779
782
rec_set_heap_no_old(
780
783
/*================*/
781
 
        rec_t*  rec,    /*!< in: physical record */
782
 
        ulint   heap_no)/*!< in: the heap number */
 
784
        rec_t*  rec,    /* in: physical record */
 
785
        ulint   heap_no)/* in: the heap number */
783
786
{
784
787
        rec_set_bit_field_2(rec, heap_no, REC_OLD_HEAP_NO,
785
788
                            REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
786
789
}
787
790
 
788
 
/******************************************************//**
 
791
/**********************************************************
789
792
The following function is used to get the order number
790
 
of a new-style record in the heap of the index page.
791
 
@return heap order number */
 
793
of a new-style record in the heap of the index page. */
792
794
UNIV_INLINE
793
795
ulint
794
796
rec_get_heap_no_new(
795
797
/*================*/
796
 
        const rec_t*    rec)    /*!< in: physical record */
 
798
                                /* out: heap order number */
 
799
        const rec_t*    rec)    /* in: physical record */
797
800
{
798
801
        return(rec_get_bit_field_2(rec, REC_NEW_HEAP_NO,
799
802
                                   REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT));
800
803
}
801
804
 
802
 
/******************************************************//**
 
805
/**********************************************************
803
806
The following function is used to set the heap number
804
807
field in a new-style record. */
805
808
UNIV_INLINE
806
809
void
807
810
rec_set_heap_no_new(
808
811
/*================*/
809
 
        rec_t*  rec,    /*!< in/out: physical record */
810
 
        ulint   heap_no)/*!< in: the heap number */
 
812
        rec_t*  rec,    /* in/out: physical record */
 
813
        ulint   heap_no)/* in: the heap number */
811
814
{
812
815
        rec_set_bit_field_2(rec, heap_no, REC_NEW_HEAP_NO,
813
816
                            REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
814
817
}
815
818
 
816
 
/******************************************************//**
 
819
/**********************************************************
817
820
The following function is used to test whether the data offsets in the record
818
 
are stored in one-byte or two-byte format.
819
 
@return TRUE if 1-byte form */
 
821
are stored in one-byte or two-byte format. */
820
822
UNIV_INLINE
821
823
ibool
822
824
rec_get_1byte_offs_flag(
823
825
/*====================*/
824
 
        const rec_t*    rec)    /*!< in: physical record */
 
826
                                /* out: TRUE if 1-byte form */
 
827
        const rec_t*    rec)    /* in: physical record */
825
828
{
826
829
#if TRUE != 1
827
830
#error "TRUE != 1"
831
834
                                   REC_OLD_SHORT_SHIFT));
832
835
}
833
836
 
834
 
/******************************************************//**
 
837
/**********************************************************
835
838
The following function is used to set the 1-byte offsets flag. */
836
839
UNIV_INLINE
837
840
void
838
841
rec_set_1byte_offs_flag(
839
842
/*====================*/
840
 
        rec_t*  rec,    /*!< in: physical record */
841
 
        ibool   flag)   /*!< in: TRUE if 1byte form */
 
843
        rec_t*  rec,    /* in: physical record */
 
844
        ibool   flag)   /* in: TRUE if 1byte form */
842
845
{
843
846
#if TRUE != 1
844
847
#error "TRUE != 1"
849
852
                            REC_OLD_SHORT_SHIFT);
850
853
}
851
854
 
852
 
/******************************************************//**
 
855
/**********************************************************
853
856
Returns the offset of nth field end if the record is stored in the 1-byte
854
857
offsets form. If the field is SQL null, the flag is ORed in the returned
855
 
value.
856
 
@return offset of the start of the field, SQL null flag ORed */
 
858
value. */
857
859
UNIV_INLINE
858
860
ulint
859
861
rec_1_get_field_end_info(
860
862
/*=====================*/
861
 
        const rec_t*    rec,    /*!< in: record */
862
 
        ulint           n)      /*!< in: field index */
 
863
                                /* out: offset of the start of the
 
864
                                field, SQL null flag ORed */
 
865
        const rec_t*    rec,    /* in: record */
 
866
        ulint           n)      /* in: field index */
863
867
{
864
868
        ut_ad(rec_get_1byte_offs_flag(rec));
865
869
        ut_ad(n < rec_get_n_fields_old(rec));
867
871
        return(mach_read_from_1(rec - (REC_N_OLD_EXTRA_BYTES + n + 1)));
868
872
}
869
873
 
870
 
/******************************************************//**
 
874
/**********************************************************
871
875
Returns the offset of nth field end if the record is stored in the 2-byte
872
876
offsets form. If the field is SQL null, the flag is ORed in the returned
873
 
value.
874
 
@return offset of the start of the field, SQL null flag and extern
875
 
storage flag ORed */
 
877
value. */
876
878
UNIV_INLINE
877
879
ulint
878
880
rec_2_get_field_end_info(
879
881
/*=====================*/
880
 
        const rec_t*    rec,    /*!< in: record */
881
 
        ulint           n)      /*!< in: field index */
 
882
                                /* out: offset of the start of the
 
883
                                field, SQL null flag and extern
 
884
                                storage flag ORed */
 
885
        const rec_t*    rec,    /* in: record */
 
886
        ulint           n)      /* in: field index */
882
887
{
883
888
        ut_ad(!rec_get_1byte_offs_flag(rec));
884
889
        ut_ad(n < rec_get_n_fields_old(rec));
891
896
the fields. */
892
897
#define rec_offs_base(offsets) (offsets + REC_OFFS_HEADER_SIZE)
893
898
 
894
 
/**********************************************************//**
 
899
/**************************************************************
895
900
The following function returns the number of allocated elements
896
 
for an array of offsets.
897
 
@return number of elements */
 
901
for an array of offsets. */
898
902
UNIV_INLINE
899
903
ulint
900
904
rec_offs_get_n_alloc(
901
905
/*=================*/
902
 
        const ulint*    offsets)/*!< in: array for rec_get_offsets() */
 
906
                                /* out: number of elements */
 
907
        const ulint*    offsets)/* in: array for rec_get_offsets() */
903
908
{
904
909
        ulint   n_alloc;
905
910
        ut_ad(offsets);
909
914
        return(n_alloc);
910
915
}
911
916
 
912
 
/**********************************************************//**
 
917
/**************************************************************
913
918
The following function sets the number of allocated elements
914
919
for an array of offsets. */
915
920
UNIV_INLINE
916
921
void
917
922
rec_offs_set_n_alloc(
918
923
/*=================*/
919
 
        ulint*  offsets,        /*!< out: array for rec_get_offsets(),
 
924
        ulint*  offsets,        /* out: array for rec_get_offsets(),
920
925
                                must be allocated */
921
 
        ulint   n_alloc)        /*!< in: number of elements */
 
926
        ulint   n_alloc)        /* in: number of elements */
922
927
{
923
928
        ut_ad(offsets);
924
929
        ut_ad(n_alloc > REC_OFFS_HEADER_SIZE);
926
931
        offsets[0] = n_alloc;
927
932
}
928
933
 
929
 
/**********************************************************//**
930
 
The following function returns the number of fields in a record.
931
 
@return number of fields */
 
934
/**************************************************************
 
935
The following function returns the number of fields in a record. */
932
936
UNIV_INLINE
933
937
ulint
934
938
rec_offs_n_fields(
935
939
/*==============*/
936
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
940
                                /* out: number of fields */
 
941
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
937
942
{
938
943
        ulint   n_fields;
939
944
        ut_ad(offsets);
945
950
        return(n_fields);
946
951
}
947
952
 
948
 
/************************************************************//**
949
 
Validates offsets returned by rec_get_offsets().
950
 
@return TRUE if valid */
 
953
/****************************************************************
 
954
Validates offsets returned by rec_get_offsets(). */
951
955
UNIV_INLINE
952
956
ibool
953
957
rec_offs_validate(
954
958
/*==============*/
955
 
        const rec_t*            rec,    /*!< in: record or NULL */
956
 
        const dict_index_t*     index,  /*!< in: record descriptor or NULL */
957
 
        const ulint*            offsets)/*!< in: array returned by
 
959
                                        /* out: TRUE if valid */
 
960
        const rec_t*            rec,    /* in: record or NULL */
 
961
        const dict_index_t*     index,  /* in: record descriptor or NULL */
 
962
        const ulint*            offsets)/* in: array returned by
958
963
                                        rec_get_offsets() */
959
964
{
960
965
        ulint   i       = rec_offs_n_fields(offsets);
1001
1006
        return(TRUE);
1002
1007
}
1003
1008
#ifdef UNIV_DEBUG
1004
 
/************************************************************//**
 
1009
/****************************************************************
1005
1010
Updates debug data in offsets, in order to avoid bogus
1006
1011
rec_offs_validate() failures. */
1007
1012
UNIV_INLINE
1008
1013
void
1009
1014
rec_offs_make_valid(
1010
1015
/*================*/
1011
 
        const rec_t*            rec,    /*!< in: record */
1012
 
        const dict_index_t*     index,  /*!< in: record descriptor */
1013
 
        ulint*                  offsets)/*!< in: array returned by
 
1016
        const rec_t*            rec,    /* in: record */
 
1017
        const dict_index_t*     index,  /* in: record descriptor */
 
1018
        ulint*                  offsets)/* in: array returned by
1014
1019
                                        rec_get_offsets() */
1015
1020
{
1016
1021
        ut_ad(rec);
1022
1027
}
1023
1028
#endif /* UNIV_DEBUG */
1024
1029
 
1025
 
/************************************************************//**
 
1030
/****************************************************************
1026
1031
The following function is used to get an offset to the nth
1027
 
data field in a record.
1028
 
@return offset from the origin of rec */
 
1032
data field in a record. */
1029
1033
UNIV_INLINE
1030
1034
ulint
1031
1035
rec_get_nth_field_offs(
1032
1036
/*===================*/
1033
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
1034
 
        ulint           n,      /*!< in: index of the field */
1035
 
        ulint*          len)    /*!< out: length of the field; UNIV_SQL_NULL
 
1037
                                /* out: offset from the origin of rec */
 
1038
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
1039
        ulint           n,      /* in: index of the field */
 
1040
        ulint*          len)    /* out: length of the field; UNIV_SQL_NULL
1036
1041
                                if SQL null */
1037
1042
{
1038
1043
        ulint   offs;
1059
1064
        return(offs);
1060
1065
}
1061
1066
 
1062
 
/******************************************************//**
 
1067
/**********************************************************
1063
1068
Determine if the offsets are for a record in the new
1064
 
compact format.
1065
 
@return nonzero if compact format */
 
1069
compact format. */
1066
1070
UNIV_INLINE
1067
1071
ulint
1068
1072
rec_offs_comp(
1069
1073
/*==========*/
1070
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1074
                                /* out: nonzero if compact format */
 
1075
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1071
1076
{
1072
1077
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1073
1078
        return(*rec_offs_base(offsets) & REC_OFFS_COMPACT);
1074
1079
}
1075
1080
 
1076
 
/******************************************************//**
 
1081
/**********************************************************
1077
1082
Determine if the offsets are for a record containing
1078
 
externally stored columns.
1079
 
@return nonzero if externally stored */
 
1083
externally stored columns. */
1080
1084
UNIV_INLINE
1081
1085
ulint
1082
1086
rec_offs_any_extern(
1083
1087
/*================*/
1084
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1088
                                /* out: nonzero if externally stored */
 
1089
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1085
1090
{
1086
1091
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1087
1092
        return(UNIV_UNLIKELY(*rec_offs_base(offsets) & REC_OFFS_EXTERNAL));
1088
1093
}
1089
1094
 
1090
 
/******************************************************//**
1091
 
Returns nonzero if the extern bit is set in nth field of rec.
1092
 
@return nonzero if externally stored */
 
1095
/**********************************************************
 
1096
Returns nonzero if the extern bit is set in nth field of rec. */
1093
1097
UNIV_INLINE
1094
1098
ulint
1095
1099
rec_offs_nth_extern(
1096
1100
/*================*/
1097
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
1098
 
        ulint           n)      /*!< in: nth field */
 
1101
                                /* out: nonzero if externally stored */
 
1102
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
1103
        ulint           n)      /* in: nth field */
1099
1104
{
1100
1105
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1101
1106
        ut_ad(n < rec_offs_n_fields(offsets));
1103
1108
                             & REC_OFFS_EXTERNAL));
1104
1109
}
1105
1110
 
1106
 
/******************************************************//**
1107
 
Returns nonzero if the SQL NULL bit is set in nth field of rec.
1108
 
@return nonzero if SQL NULL */
 
1111
/**********************************************************
 
1112
Returns nonzero if the SQL NULL bit is set in nth field of rec. */
1109
1113
UNIV_INLINE
1110
1114
ulint
1111
1115
rec_offs_nth_sql_null(
1112
1116
/*==================*/
1113
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
1114
 
        ulint           n)      /*!< in: nth field */
 
1117
                                /* out: nonzero if SQL NULL */
 
1118
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
1119
        ulint           n)      /* in: nth field */
1115
1120
{
1116
1121
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1117
1122
        ut_ad(n < rec_offs_n_fields(offsets));
1119
1124
                             & REC_OFFS_SQL_NULL));
1120
1125
}
1121
1126
 
1122
 
/******************************************************//**
1123
 
Gets the physical size of a field.
1124
 
@return length of field */
 
1127
/**********************************************************
 
1128
Gets the physical size of a field. */
1125
1129
UNIV_INLINE
1126
1130
ulint
1127
1131
rec_offs_nth_size(
1128
1132
/*==============*/
1129
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
1130
 
        ulint           n)      /*!< in: nth field */
 
1133
                                /* out: length of field */
 
1134
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
1135
        ulint           n)      /* in: nth field */
1131
1136
{
1132
1137
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1133
1138
        ut_ad(n < rec_offs_n_fields(offsets));
1138
1143
               & REC_OFFS_MASK);
1139
1144
}
1140
1145
 
1141
 
/******************************************************//**
1142
 
Returns the number of extern bits set in a record.
1143
 
@return number of externally stored fields */
 
1146
/**********************************************************
 
1147
Returns the number of extern bits set in a record. */
1144
1148
UNIV_INLINE
1145
1149
ulint
1146
1150
rec_offs_n_extern(
1147
1151
/*==============*/
1148
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1152
                                /* out: number of externally stored fields */
 
1153
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1149
1154
{
1150
1155
        ulint   n = 0;
1151
1156
 
1162
1167
        return(n);
1163
1168
}
1164
1169
 
1165
 
/******************************************************//**
 
1170
/**********************************************************
1166
1171
Returns the offset of n - 1th field end if the record is stored in the 1-byte
1167
1172
offsets form. If the field is SQL null, the flag is ORed in the returned
1168
1173
value. This function and the 2-byte counterpart are defined here because the
1169
1174
C-compiler was not able to sum negative and positive constant offsets, and
1170
 
warned of constant arithmetic overflow within the compiler.
1171
 
@return offset of the start of the PREVIOUS field, SQL null flag ORed */
 
1175
warned of constant arithmetic overflow within the compiler. */
1172
1176
UNIV_INLINE
1173
1177
ulint
1174
1178
rec_1_get_prev_field_end_info(
1175
1179
/*==========================*/
1176
 
        const rec_t*    rec,    /*!< in: record */
1177
 
        ulint           n)      /*!< in: field index */
 
1180
                                /* out: offset of the start of the
 
1181
                                PREVIOUS field, SQL null flag ORed */
 
1182
        const rec_t*    rec,    /* in: record */
 
1183
        ulint           n)      /* in: field index */
1178
1184
{
1179
1185
        ut_ad(rec_get_1byte_offs_flag(rec));
1180
1186
        ut_ad(n <= rec_get_n_fields_old(rec));
1182
1188
        return(mach_read_from_1(rec - (REC_N_OLD_EXTRA_BYTES + n)));
1183
1189
}
1184
1190
 
1185
 
/******************************************************//**
 
1191
/**********************************************************
1186
1192
Returns the offset of n - 1th field end if the record is stored in the 2-byte
1187
1193
offsets form. If the field is SQL null, the flag is ORed in the returned
1188
 
value.
1189
 
@return offset of the start of the PREVIOUS field, SQL null flag ORed */
 
1194
value. */
1190
1195
UNIV_INLINE
1191
1196
ulint
1192
1197
rec_2_get_prev_field_end_info(
1193
1198
/*==========================*/
1194
 
        const rec_t*    rec,    /*!< in: record */
1195
 
        ulint           n)      /*!< in: field index */
 
1199
                                /* out: offset of the start of the
 
1200
                                PREVIOUS field, SQL null flag ORed */
 
1201
        const rec_t*    rec,    /* in: record */
 
1202
        ulint           n)      /* in: field index */
1196
1203
{
1197
1204
        ut_ad(!rec_get_1byte_offs_flag(rec));
1198
1205
        ut_ad(n <= rec_get_n_fields_old(rec));
1200
1207
        return(mach_read_from_2(rec - (REC_N_OLD_EXTRA_BYTES + 2 * n)));
1201
1208
}
1202
1209
 
1203
 
/******************************************************//**
 
1210
/**********************************************************
1204
1211
Sets the field end info for the nth field if the record is stored in the
1205
1212
1-byte format. */
1206
1213
UNIV_INLINE
1207
1214
void
1208
1215
rec_1_set_field_end_info(
1209
1216
/*=====================*/
1210
 
        rec_t*  rec,    /*!< in: record */
1211
 
        ulint   n,      /*!< in: field index */
1212
 
        ulint   info)   /*!< in: value to set */
 
1217
        rec_t*  rec,    /* in: record */
 
1218
        ulint   n,      /* in: field index */
 
1219
        ulint   info)   /* in: value to set */
1213
1220
{
1214
1221
        ut_ad(rec_get_1byte_offs_flag(rec));
1215
1222
        ut_ad(n < rec_get_n_fields_old(rec));
1217
1224
        mach_write_to_1(rec - (REC_N_OLD_EXTRA_BYTES + n + 1), info);
1218
1225
}
1219
1226
 
1220
 
/******************************************************//**
 
1227
/**********************************************************
1221
1228
Sets the field end info for the nth field if the record is stored in the
1222
1229
2-byte format. */
1223
1230
UNIV_INLINE
1224
1231
void
1225
1232
rec_2_set_field_end_info(
1226
1233
/*=====================*/
1227
 
        rec_t*  rec,    /*!< in: record */
1228
 
        ulint   n,      /*!< in: field index */
1229
 
        ulint   info)   /*!< in: value to set */
 
1234
        rec_t*  rec,    /* in: record */
 
1235
        ulint   n,      /* in: field index */
 
1236
        ulint   info)   /* in: value to set */
1230
1237
{
1231
1238
        ut_ad(!rec_get_1byte_offs_flag(rec));
1232
1239
        ut_ad(n < rec_get_n_fields_old(rec));
1234
1241
        mach_write_to_2(rec - (REC_N_OLD_EXTRA_BYTES + 2 * n + 2), info);
1235
1242
}
1236
1243
 
1237
 
/******************************************************//**
 
1244
/**********************************************************
1238
1245
Returns the offset of nth field start if the record is stored in the 1-byte
1239
 
offsets form.
1240
 
@return offset of the start of the field */
 
1246
offsets form. */
1241
1247
UNIV_INLINE
1242
1248
ulint
1243
1249
rec_1_get_field_start_offs(
1244
1250
/*=======================*/
1245
 
        const rec_t*    rec,    /*!< in: record */
1246
 
        ulint           n)      /*!< in: field index */
 
1251
                                /* out: offset of the start of the field */
 
1252
        const rec_t*    rec,    /* in: record */
 
1253
        ulint           n)      /* in: field index */
1247
1254
{
1248
1255
        ut_ad(rec_get_1byte_offs_flag(rec));
1249
1256
        ut_ad(n <= rec_get_n_fields_old(rec));
1257
1264
               & ~REC_1BYTE_SQL_NULL_MASK);
1258
1265
}
1259
1266
 
1260
 
/******************************************************//**
 
1267
/**********************************************************
1261
1268
Returns the offset of nth field start if the record is stored in the 2-byte
1262
 
offsets form.
1263
 
@return offset of the start of the field */
 
1269
offsets form. */
1264
1270
UNIV_INLINE
1265
1271
ulint
1266
1272
rec_2_get_field_start_offs(
1267
1273
/*=======================*/
1268
 
        const rec_t*    rec,    /*!< in: record */
1269
 
        ulint           n)      /*!< in: field index */
 
1274
                                /* out: offset of the start of the field */
 
1275
        const rec_t*    rec,    /* in: record */
 
1276
        ulint           n)      /* in: field index */
1270
1277
{
1271
1278
        ut_ad(!rec_get_1byte_offs_flag(rec));
1272
1279
        ut_ad(n <= rec_get_n_fields_old(rec));
1280
1287
               & ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK));
1281
1288
}
1282
1289
 
1283
 
/******************************************************//**
 
1290
/**********************************************************
1284
1291
The following function is used to read the offset of the start of a data field
1285
1292
in the record. The start of an SQL null field is the end offset of the
1286
1293
previous non-null field, or 0, if none exists. If n is the number of the last
1287
 
field + 1, then the end offset of the last field is returned.
1288
 
@return offset of the start of the field */
 
1294
field + 1, then the end offset of the last field is returned. */
1289
1295
UNIV_INLINE
1290
1296
ulint
1291
1297
rec_get_field_start_offs(
1292
1298
/*=====================*/
1293
 
        const rec_t*    rec,    /*!< in: record */
1294
 
        ulint           n)      /*!< in: field index */
 
1299
                                /* out: offset of the start of the field */
 
1300
        const rec_t*    rec,    /* in: record */
 
1301
        ulint           n)      /* in: field index */
1295
1302
{
1296
1303
        ut_ad(rec);
1297
1304
        ut_ad(n <= rec_get_n_fields_old(rec));
1309
1316
        return(rec_2_get_field_start_offs(rec, n));
1310
1317
}
1311
1318
 
1312
 
/************************************************************//**
 
1319
/****************************************************************
1313
1320
Gets the physical size of an old-style field.
1314
1321
Also an SQL null may have a field of size > 0,
1315
 
if the data type is of a fixed size.
1316
 
@return field size in bytes */
 
1322
if the data type is of a fixed size. */
1317
1323
UNIV_INLINE
1318
1324
ulint
1319
1325
rec_get_nth_field_size(
1320
1326
/*===================*/
1321
 
        const rec_t*    rec,    /*!< in: record */
1322
 
        ulint           n)      /*!< in: index of the field */
 
1327
                                /* out: field size in bytes */
 
1328
        const rec_t*    rec,    /* in: record */
 
1329
        ulint           n)      /* in: index of the field */
1323
1330
{
1324
1331
        ulint   os;
1325
1332
        ulint   next_os;
1332
1339
        return(next_os - os);
1333
1340
}
1334
1341
 
1335
 
/***********************************************************//**
 
1342
/***************************************************************
1336
1343
This is used to modify the value of an already existing field in a record.
1337
1344
The previous value must have exactly the same size as the new value. If len
1338
1345
is UNIV_SQL_NULL then the field is treated as an SQL null.
1342
1349
void
1343
1350
rec_set_nth_field(
1344
1351
/*==============*/
1345
 
        rec_t*          rec,    /*!< in: record */
1346
 
        const ulint*    offsets,/*!< in: array returned by rec_get_offsets() */
1347
 
        ulint           n,      /*!< in: index number of the field */
1348
 
        const void*     data,   /*!< in: pointer to the data
 
1352
        rec_t*          rec,    /* in: record */
 
1353
        const ulint*    offsets,/* in: array returned by rec_get_offsets() */
 
1354
        ulint           n,      /* in: index number of the field */
 
1355
        const void*     data,   /* in: pointer to the data
1349
1356
                                if not SQL null */
1350
 
        ulint           len)    /*!< in: length of the data or UNIV_SQL_NULL */
 
1357
        ulint           len)    /* in: length of the data or UNIV_SQL_NULL */
1351
1358
{
1352
1359
        byte*   data2;
1353
1360
        ulint   len2;
1376
1383
        ut_memcpy(data2, data, len);
1377
1384
}
1378
1385
 
1379
 
/**********************************************************//**
 
1386
/**************************************************************
1380
1387
The following function returns the data size of an old-style physical
1381
1388
record, that is the sum of field lengths. SQL null fields
1382
1389
are counted as length 0 fields. The value returned by the function
1383
 
is the distance from record origin to record end in bytes.
1384
 
@return size */
 
1390
is the distance from record origin to record end in bytes. */
1385
1391
UNIV_INLINE
1386
1392
ulint
1387
1393
rec_get_data_size_old(
1388
1394
/*==================*/
1389
 
        const rec_t*    rec)    /*!< in: physical record */
 
1395
                                /* out: size */
 
1396
        const rec_t*    rec)    /* in: physical record */
1390
1397
{
1391
1398
        ut_ad(rec);
1392
1399
 
1393
1400
        return(rec_get_field_start_offs(rec, rec_get_n_fields_old(rec)));
1394
1401
}
1395
1402
 
1396
 
/**********************************************************//**
 
1403
/**************************************************************
1397
1404
The following function sets the number of fields in offsets. */
1398
1405
UNIV_INLINE
1399
1406
void
1400
1407
rec_offs_set_n_fields(
1401
1408
/*==================*/
1402
 
        ulint*  offsets,        /*!< in/out: array returned by
 
1409
        ulint*  offsets,        /* in/out: array returned by
1403
1410
                                rec_get_offsets() */
1404
 
        ulint   n_fields)       /*!< in: number of fields */
 
1411
        ulint   n_fields)       /* in: number of fields */
1405
1412
{
1406
1413
        ut_ad(offsets);
1407
1414
        ut_ad(n_fields > 0);
1411
1418
        offsets[1] = n_fields;
1412
1419
}
1413
1420
 
1414
 
/**********************************************************//**
 
1421
/**************************************************************
1415
1422
The following function returns the data size of a physical
1416
1423
record, that is the sum of field lengths. SQL null fields
1417
1424
are counted as length 0 fields. The value returned by the function
1418
 
is the distance from record origin to record end in bytes.
1419
 
@return size */
 
1425
is the distance from record origin to record end in bytes. */
1420
1426
UNIV_INLINE
1421
1427
ulint
1422
1428
rec_offs_data_size(
1423
1429
/*===============*/
1424
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1430
                                /* out: size */
 
1431
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1425
1432
{
1426
1433
        ulint   size;
1427
1434
 
1432
1439
        return(size);
1433
1440
}
1434
1441
 
1435
 
/**********************************************************//**
 
1442
/**************************************************************
1436
1443
Returns the total size of record minus data size of record. The value
1437
1444
returned by the function is the distance from record start to record origin
1438
 
in bytes.
1439
 
@return size */
 
1445
in bytes. */
1440
1446
UNIV_INLINE
1441
1447
ulint
1442
1448
rec_offs_extra_size(
1443
1449
/*================*/
1444
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1450
                                /* out: size */
 
1451
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1445
1452
{
1446
1453
        ulint   size;
1447
1454
        ut_ad(rec_offs_validate(NULL, NULL, offsets));
1450
1457
        return(size);
1451
1458
}
1452
1459
 
1453
 
/**********************************************************//**
1454
 
Returns the total size of a physical record.
1455
 
@return size */
 
1460
/**************************************************************
 
1461
Returns the total size of a physical record.  */
1456
1462
UNIV_INLINE
1457
1463
ulint
1458
1464
rec_offs_size(
1459
1465
/*==========*/
1460
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1466
                                /* out: size */
 
1467
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1461
1468
{
1462
1469
        return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets));
1463
1470
}
1464
1471
 
1465
 
/**********************************************************//**
1466
 
Returns a pointer to the end of the record.
1467
 
@return pointer to end */
 
1472
/**************************************************************
 
1473
Returns a pointer to the end of the record. */
1468
1474
UNIV_INLINE
1469
1475
byte*
1470
1476
rec_get_end(
1471
1477
/*========*/
1472
 
        rec_t*          rec,    /*!< in: pointer to record */
1473
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1478
                                /* out: pointer to end */
 
1479
        rec_t*          rec,    /* in: pointer to record */
 
1480
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1474
1481
{
1475
1482
        ut_ad(rec_offs_validate(rec, NULL, offsets));
1476
1483
        return(rec + rec_offs_data_size(offsets));
1477
1484
}
1478
1485
 
1479
 
/**********************************************************//**
1480
 
Returns a pointer to the start of the record.
1481
 
@return pointer to start */
 
1486
/**************************************************************
 
1487
Returns a pointer to the start of the record. */
1482
1488
UNIV_INLINE
1483
1489
byte*
1484
1490
rec_get_start(
1485
1491
/*==========*/
1486
 
        rec_t*          rec,    /*!< in: pointer to record */
1487
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1492
                                /* out: pointer to start */
 
1493
        rec_t*          rec,    /* in: pointer to record */
 
1494
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1488
1495
{
1489
1496
        ut_ad(rec_offs_validate(rec, NULL, offsets));
1490
1497
        return(rec - rec_offs_extra_size(offsets));
1491
1498
}
1492
1499
 
1493
 
/***************************************************************//**
1494
 
Copies a physical record to a buffer.
1495
 
@return pointer to the origin of the copy */
 
1500
/*******************************************************************
 
1501
Copies a physical record to a buffer. */
1496
1502
UNIV_INLINE
1497
1503
rec_t*
1498
1504
rec_copy(
1499
1505
/*=====*/
1500
 
        void*           buf,    /*!< in: buffer */
1501
 
        const rec_t*    rec,    /*!< in: physical record */
1502
 
        const ulint*    offsets)/*!< in: array returned by rec_get_offsets() */
 
1506
                                /* out: pointer to the origin of the copy */
 
1507
        void*           buf,    /* in: buffer */
 
1508
        const rec_t*    rec,    /* in: physical record */
 
1509
        const ulint*    offsets)/* in: array returned by rec_get_offsets() */
1503
1510
{
1504
1511
        ulint   extra_len;
1505
1512
        ulint   data_len;
1516
1523
        return((byte*)buf + extra_len);
1517
1524
}
1518
1525
 
1519
 
/**********************************************************//**
 
1526
/**************************************************************
1520
1527
Returns the extra size of an old-style physical record if we know its
1521
 
data size and number of fields.
1522
 
@return extra size */
 
1528
data size and number of fields. */
1523
1529
UNIV_INLINE
1524
1530
ulint
1525
1531
rec_get_converted_extra_size(
1526
1532
/*=========================*/
1527
 
        ulint   data_size,      /*!< in: data size */
1528
 
        ulint   n_fields,       /*!< in: number of fields */
1529
 
        ulint   n_ext)          /*!< in: number of externally stored columns */
 
1533
                                /* out: extra size */
 
1534
        ulint   data_size,      /* in: data size */
 
1535
        ulint   n_fields,       /* in: number of fields */
 
1536
        ulint   n_ext)          /* in: number of externally stored columns */
1530
1537
{
1531
1538
        if (!n_ext && data_size <= REC_1BYTE_OFFS_LIMIT) {
1532
1539
 
1536
1543
        return(REC_N_OLD_EXTRA_BYTES + 2 * n_fields);
1537
1544
}
1538
1545
 
1539
 
/**********************************************************//**
 
1546
/**************************************************************
1540
1547
The following function returns the size of a data tuple when converted to
1541
 
a physical record.
1542
 
@return size */
 
1548
a physical record. */
1543
1549
UNIV_INLINE
1544
1550
ulint
1545
1551
rec_get_converted_size(
1546
1552
/*===================*/
1547
 
        dict_index_t*   index,  /*!< in: record descriptor */
1548
 
        const dtuple_t* dtuple, /*!< in: data tuple */
1549
 
        ulint           n_ext)  /*!< in: number of externally stored columns */
 
1553
                                /* out: size */
 
1554
        dict_index_t*   index,  /* in: record descriptor */
 
1555
        const dtuple_t* dtuple, /* in: data tuple */
 
1556
        ulint           n_ext)  /* in: number of externally stored columns */
1550
1557
{
1551
1558
        ulint   data_size;
1552
1559
        ulint   extra_size;
1570
1577
                                                   dtuple->n_fields, NULL));
1571
1578
        }
1572
1579
 
1573
 
        data_size = dtuple_get_data_size(dtuple, 0);
 
1580
        data_size = dtuple_get_data_size(dtuple);
1574
1581
 
1575
1582
        extra_size = rec_get_converted_extra_size(
1576
1583
                data_size, dtuple_get_n_fields(dtuple), n_ext);
1578
1585
        return(data_size + extra_size);
1579
1586
}
1580
1587
 
1581
 
#ifndef UNIV_HOTBACKUP
1582
 
/************************************************************//**
 
1588
/****************************************************************
1583
1589
Folds a prefix of a physical record to a ulint. Folds only existing fields,
1584
 
that is, checks that we do not run out of the record.
1585
 
@return the folded value */
 
1590
that is, checks that we do not run out of the record. */
1586
1591
UNIV_INLINE
1587
1592
ulint
1588
1593
rec_fold(
1589
1594
/*=====*/
1590
 
        const rec_t*    rec,            /*!< in: the physical record */
1591
 
        const ulint*    offsets,        /*!< in: array returned by
 
1595
                                        /* out: the folded value */
 
1596
        const rec_t*    rec,            /* in: the physical record */
 
1597
        const ulint*    offsets,        /* in: array returned by
1592
1598
                                        rec_get_offsets() */
1593
 
        ulint           n_fields,       /*!< in: number of complete
 
1599
        ulint           n_fields,       /* in: number of complete
1594
1600
                                        fields to fold */
1595
 
        ulint           n_bytes,        /*!< in: number of bytes to fold
 
1601
        ulint           n_bytes,        /* in: number of bytes to fold
1596
1602
                                        in an incomplete last field */
1597
 
        dulint          tree_id)        /*!< in: index tree id */
 
1603
        dulint          tree_id)        /* in: index tree id */
1598
1604
{
1599
1605
        ulint           i;
1600
1606
        const byte*     data;
1644
1650
 
1645
1651
        return(fold);
1646
1652
}
1647
 
#endif /* !UNIV_HOTBACKUP */