144
143
# error "sum of new-style masks != 0xFFFFFFUL"
147
/***********************************************************//**
146
/***************************************************************
148
147
Sets the value of the ith field SQL null bit of an old-style record. */
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. */
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 */
166
/******************************************************//**
165
/**********************************************************
167
166
Gets a bit field from within 1 byte. */
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 */
179
178
return((mach_read_from_1(rec - offs) & mask) >> shift);
182
/******************************************************//**
181
/**********************************************************
183
182
Sets a bit field within 1 byte. */
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 */
195
194
ut_ad(offs <= REC_N_OLD_EXTRA_BYTES);
203
202
| (val << shift));
206
/******************************************************//**
205
/**********************************************************
207
206
Gets a bit field from within 2 bytes. */
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 */
219
218
return((mach_read_from_2(rec - offs) & mask) >> shift);
222
/******************************************************//**
221
/**********************************************************
223
222
Sets a bit field within 2 bytes. */
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 */
235
234
ut_ad(offs <= REC_N_OLD_EXTRA_BYTES);
245
244
| (val << shift));
248
/******************************************************//**
247
/**********************************************************
249
248
The following function is used to get the pointer of the next chained record
251
@return pointer to the next chained record, or NULL if none */
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
256
const rec_t* rec, /* in: physical record */
257
ulint comp) /* in: nonzero=compact page format */
259
259
ulint field_value;
304
/******************************************************//**
304
/**********************************************************
305
305
The following function is used to get the pointer of the next chained record
307
@return pointer to the next chained record, or NULL if none */
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
313
rec_t* rec, /* in: physical record */
314
ulint comp) /* in: nonzero=compact page format */
315
316
return((rec_t*) rec_get_next_ptr_const(rec, comp));
318
/******************************************************//**
319
/**********************************************************
319
320
The following function is used to get the offset of the next chained record
321
@return the page offset of the next chained record, or 0 if none */
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 */
329
331
ulint field_value;
330
332
#if REC_NEXT_MASK != 0xFFFFUL
394
396
mach_write_to_2(rec - REC_NEXT, next);
397
/******************************************************//**
399
/**********************************************************
398
400
The following function is used to set the next record offset field
399
401
of a new-style record. */
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 */
407
409
ulint field_value;
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. */
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 */
531
533
return(rec_get_bit_field_1(rec, REC_OLD_N_OWNED,
532
534
REC_N_OWNED_MASK, REC_N_OWNED_SHIFT));
535
/******************************************************//**
537
/**********************************************************
536
538
The following function is used to set the number of owned records. */
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 */
544
547
rec_set_bit_field_1(rec, n_owned, REC_OLD_N_OWNED,
545
548
REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
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. */
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 */
558
561
return(rec_get_bit_field_1(rec, REC_NEW_N_OWNED,
559
562
REC_N_OWNED_MASK, REC_N_OWNED_SHIFT));
562
/******************************************************//**
565
/**********************************************************
563
566
The following function is used to set the number of owned records. */
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 */
572
575
rec_set_bit_field_1(rec, n_owned, REC_NEW_N_OWNED,
573
576
REC_N_OWNED_MASK, REC_N_OWNED_SHIFT);
581
/******************************************************//**
582
The following function is used to retrieve the info bits of a record.
584
/**********************************************************
585
The following function is used to retrieve the info bits of a record. */
586
588
rec_get_info_bits(
587
589
/*==============*/
588
const rec_t* rec, /*!< in: physical record */
589
ulint comp) /*!< in: nonzero=compact page format */
591
const rec_t* rec, /* in: physical record */
592
ulint comp) /* in: nonzero=compact page format */
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));
596
/******************************************************//**
599
/**********************************************************
597
600
The following function is used to set the info bits of a record. */
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 */
605
608
rec_set_bit_field_1(rec, bits, REC_OLD_INFO_BITS,
606
609
REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
608
/******************************************************//**
611
/**********************************************************
609
612
The following function is used to set the info bits of a record. */
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 */
617
620
rec_set_bit_field_1(rec, bits, REC_NEW_INFO_BITS,
618
621
REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT);
621
/******************************************************//**
624
/**********************************************************
622
625
The following function is used to set the status bits of a new-style record. */
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 */
630
633
rec_set_bit_field_1(rec, bits, REC_NEW_STATUS,
631
634
REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT);
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.)
639
bits of a record. (Only compact records have status bits.) */
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 */
645
const rec_t* rec, /* in: physical record */
646
ulint comp) /* in: nonzero=compact page format */
646
649
#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \
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.) */
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 */
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);
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. */
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 */
686
689
if (UNIV_EXPECT(comp, REC_OFFS_COMPACT)) {
687
690
return(UNIV_UNLIKELY(
718
721
rec_set_info_bits_old(rec, val);
721
/******************************************************//**
724
/**********************************************************
722
725
The following function is used to set the deleted bit. */
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 */
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. */
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 */
757
760
return(REC_STATUS_NODE_PTR == rec_get_status(rec));
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. */
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 */
770
773
return(rec_get_bit_field_2(rec, REC_OLD_HEAP_NO,
771
774
REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT));
774
/******************************************************//**
777
/**********************************************************
775
778
The following function is used to set the heap number
776
779
field in an old-style record. */
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 */
784
787
rec_set_bit_field_2(rec, heap_no, REC_OLD_HEAP_NO,
785
788
REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
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. */
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 */
798
801
return(rec_get_bit_field_2(rec, REC_NEW_HEAP_NO,
799
802
REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT));
802
/******************************************************//**
805
/**********************************************************
803
806
The following function is used to set the heap number
804
807
field in a new-style record. */
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 */
812
815
rec_set_bit_field_2(rec, heap_no, REC_NEW_HEAP_NO,
813
816
REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT);
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. */
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 */
827
830
#error "TRUE != 1"
849
852
REC_OLD_SHORT_SHIFT);
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
856
@return offset of the start of the field, SQL null flag ORed */
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 */
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)));
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
874
@return offset of the start of the field, SQL null flag and extern
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
885
const rec_t* rec, /* in: record */
886
ulint n) /* in: field index */
883
888
ut_ad(!rec_get_1byte_offs_flag(rec));
884
889
ut_ad(n < rec_get_n_fields_old(rec));
912
/**********************************************************//**
917
/**************************************************************
913
918
The following function sets the number of allocated elements
914
919
for an array of offsets. */
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 */
924
929
ut_ad(n_alloc > REC_OFFS_HEADER_SIZE);
945
950
return(n_fields);
948
/************************************************************//**
949
Validates offsets returned by rec_get_offsets().
950
@return TRUE if valid */
953
/****************************************************************
954
Validates offsets returned by rec_get_offsets(). */
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() */
960
965
ulint i = rec_offs_n_fields(offsets);
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. */
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() */
1023
1028
#endif /* UNIV_DEBUG */
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. */
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
1062
/******************************************************//**
1067
/**********************************************************
1063
1068
Determine if the offsets are for a record in the new
1065
@return nonzero if compact format */
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() */
1072
1077
ut_ad(rec_offs_validate(NULL, NULL, offsets));
1073
1078
return(*rec_offs_base(offsets) & REC_OFFS_COMPACT);
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. */
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() */
1086
1091
ut_ad(rec_offs_validate(NULL, NULL, offsets));
1087
1092
return(UNIV_UNLIKELY(*rec_offs_base(offsets) & REC_OFFS_EXTERNAL));
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. */
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 */
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));
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. */
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 */
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));
1122
/******************************************************//**
1123
Gets the physical size of a field.
1124
@return length of field */
1127
/**********************************************************
1128
Gets the physical size of a field. */
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 */
1132
1137
ut_ad(rec_offs_validate(NULL, NULL, offsets));
1133
1138
ut_ad(n < rec_offs_n_fields(offsets));
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. */
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 */
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)));
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
1189
@return offset of the start of the PREVIOUS field, SQL null flag ORed */
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 */
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)));
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. */
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 */
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);
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. */
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 */
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);
1237
/******************************************************//**
1244
/**********************************************************
1238
1245
Returns the offset of nth field start if the record is stored in the 1-byte
1240
@return offset of the start of the field */
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 */
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);
1260
/******************************************************//**
1267
/**********************************************************
1261
1268
Returns the offset of nth field start if the record is stored in the 2-byte
1263
@return offset of the start of the field */
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 */
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));
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. */
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 */
1297
1304
ut_ad(n <= rec_get_n_fields_old(rec));
1309
1316
return(rec_2_get_field_start_offs(rec, n));
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. */
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 */
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 */
1376
1383
ut_memcpy(data2, data, len);
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.
1390
is the distance from record origin to record end in bytes. */
1387
1393
rec_get_data_size_old(
1388
1394
/*==================*/
1389
const rec_t* rec) /*!< in: physical record */
1396
const rec_t* rec) /* in: physical record */
1393
1400
return(rec_get_field_start_offs(rec, rec_get_n_fields_old(rec)));
1396
/**********************************************************//**
1403
/**************************************************************
1397
1404
The following function sets the number of fields in offsets. */
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 */
1406
1413
ut_ad(offsets);
1407
1414
ut_ad(n_fields > 0);
1453
/**********************************************************//**
1454
Returns the total size of a physical record.
1460
/**************************************************************
1461
Returns the total size of a physical record. */
1460
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
1467
const ulint* offsets)/* in: array returned by rec_get_offsets() */
1462
1469
return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets));
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. */
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() */
1475
1482
ut_ad(rec_offs_validate(rec, NULL, offsets));
1476
1483
return(rec + rec_offs_data_size(offsets));
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. */
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() */
1489
1496
ut_ad(rec_offs_validate(rec, NULL, offsets));
1490
1497
return(rec - rec_offs_extra_size(offsets));
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. */
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() */
1504
1511
ulint extra_len;
1505
1512
ulint data_len;
1516
1523
return((byte*)buf + extra_len);
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. */
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 */
1531
1538
if (!n_ext && data_size <= REC_1BYTE_OFFS_LIMIT) {
1536
1543
return(REC_N_OLD_EXTRA_BYTES + 2 * n_fields);
1539
/**********************************************************//**
1546
/**************************************************************
1540
1547
The following function returns the size of a data tuple when converted to
1548
a physical record. */
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 */
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 */
1551
1558
ulint data_size;
1552
1559
ulint extra_size;
1578
1585
return(data_size + extra_size);
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. */
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 */
1600
1606
const byte* data;