37
33
#define REC_STATUS_INFIMUM 2
38
34
#define REC_STATUS_SUPREMUM 3
40
/* The following four constants are needed in page0zip.c in order to
41
efficiently compress and decompress pages. */
43
/* The offset of heap_no in a compact record */
44
#define REC_NEW_HEAP_NO 4
45
/* The shift of heap_no in a compact record.
46
The status is stored in the low-order bits. */
47
#define REC_HEAP_NO_SHIFT 3
49
/* Length of a B-tree node pointer, in bytes */
50
#define REC_NODE_PTR_SIZE 4
53
/* Length of the rec_get_offsets() header */
54
# define REC_OFFS_HEADER_SIZE 4
55
#else /* UNIV_DEBUG */
56
/* Length of the rec_get_offsets() header */
57
# define REC_OFFS_HEADER_SIZE 2
58
#endif /* UNIV_DEBUG */
60
36
/* Number of elements that should be initially allocated for the
61
37
offsets[] array, first passed to rec_get_offsets() */
62
38
#define REC_OFFS_NORMAL_SIZE 100
63
39
#define REC_OFFS_SMALL_SIZE 10
65
41
/**********************************************************
66
The following function is used to get the pointer of the next chained record
70
rec_get_next_ptr_const(
71
/*===================*/
72
/* out: pointer to the next chained record, or
74
const rec_t* rec, /* in: physical record */
75
ulint comp); /* in: nonzero=compact page format */
76
/**********************************************************
77
The following function is used to get the pointer of the next chained record
83
/* out: pointer to the next chained record, or
85
rec_t* rec, /* in: physical record */
86
ulint comp); /* in: nonzero=compact page format */
87
/**********************************************************
88
42
The following function is used to get the offset of the
89
43
next chained record on the same page. */
94
/* out: the page offset of the next
95
chained record, or 0 if none */
96
const rec_t* rec, /* in: physical record */
97
ulint comp); /* in: nonzero=compact page format */
98
/**********************************************************
99
The following function is used to set the next record offset field
100
of an old-style record. */
103
rec_set_next_offs_old(
104
/*==================*/
105
rec_t* rec, /* in: old-style physical record */
106
ulint next); /* in: offset of the next record */
107
/**********************************************************
108
The following function is used to set the next record offset field
109
of a new-style record. */
112
rec_set_next_offs_new(
113
/*==================*/
114
rec_t* rec, /* in/out: new-style physical record */
48
/* out: the page offset of the next
50
rec_t* rec, /* in: physical record */
51
ulint comp); /* in: nonzero=compact page format */
52
/**********************************************************
53
The following function is used to set the next record offset field
59
rec_t* rec, /* in: physical record */
60
ulint comp, /* in: nonzero=compact page format */
115
61
ulint next); /* in: offset of the next record */
116
62
/**********************************************************
117
63
The following function is used to get the number of fields
132
/* out: number of data fields */
133
const rec_t* rec, /* in: physical record */
134
const dict_index_t* index); /* in: record descriptor */
78
/* out: number of data fields */
79
rec_t* rec, /* in: physical record */
80
dict_index_t* index); /* in: record descriptor */
135
81
/**********************************************************
136
The following function is used to get the number of records owned by the
137
previous directory record. */
82
The following function is used to get the number of records
83
owned by the previous directory record. */
142
/* out: number of owned records */
143
const rec_t* rec); /* in: old-style physical record */
88
/* out: number of owned records */
89
rec_t* rec, /* in: physical record */
90
ulint comp); /* in: nonzero=compact page format */
144
91
/**********************************************************
145
The following function is used to set the number of owned records. */
92
The following function is used to set the number of owned
150
/* out: TRUE on success */
151
rec_t* rec, /* in: old-style physical record */
98
rec_t* rec, /* in: physical record */
99
ulint comp, /* in: nonzero=compact page format */
152
100
ulint n_owned); /* in: the number of owned */
153
101
/**********************************************************
154
The following function is used to get the number of records owned by the
155
previous directory record. */
160
/* out: number of owned records */
161
const rec_t* rec); /* in: new-style physical record */
162
/**********************************************************
163
The following function is used to set the number of owned records. */
168
rec_t* rec, /* in/out: new-style physical record */
169
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
170
ulint n_owned);/* in: the number of owned */
171
/**********************************************************
172
102
The following function is used to retrieve the info bits of
176
106
rec_get_info_bits(
177
107
/*==============*/
179
const rec_t* rec, /* in: physical record */
180
ulint comp); /* in: nonzero=compact page format */
181
/**********************************************************
182
The following function is used to set the info bits of a record. */
185
rec_set_info_bits_old(
186
/*==================*/
187
rec_t* rec, /* in: old-style physical record */
188
ulint bits); /* in: info bits */
189
/**********************************************************
190
The following function is used to set the info bits of a record. */
193
rec_set_info_bits_new(
194
/*==================*/
195
rec_t* rec, /* in/out: new-style physical record */
109
rec_t* rec, /* in: physical record */
110
ulint comp); /* in: nonzero=compact page format */
111
/**********************************************************
112
The following function is used to set the info bits of a record. */
117
rec_t* rec, /* in: physical record */
118
ulint comp, /* in: nonzero=compact page format */
196
119
ulint bits); /* in: info bits */
197
120
/**********************************************************
198
121
The following function retrieves the status bits of a new-style record. */
239
163
rec_get_deleted_flag(
240
164
/*=================*/
241
/* out: nonzero if delete marked */
242
const rec_t* rec, /* in: physical record */
243
ulint comp); /* in: nonzero=compact page format */
165
/* out: nonzero if delete marked */
166
rec_t* rec, /* in: physical record */
167
ulint comp); /* in: nonzero=compact page format */
244
168
/**********************************************************
245
169
The following function is used to set the deleted bit. */
248
rec_set_deleted_flag_old(
249
/*=====================*/
250
rec_t* rec, /* in: old-style physical record */
172
rec_set_deleted_flag(
173
/*=================*/
174
rec_t* rec, /* in: physical record */
175
ulint comp, /* in: nonzero=compact page format */
251
176
ulint flag); /* in: nonzero if delete marked */
252
177
/**********************************************************
253
The following function is used to set the deleted bit. */
256
rec_set_deleted_flag_new(
257
/*=====================*/
258
rec_t* rec, /* in/out: new-style physical record */
259
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
260
ulint flag); /* in: nonzero if delete marked */
261
/**********************************************************
262
178
The following function tells if a new-style record is a node pointer. */
265
181
rec_get_node_ptr_flag(
266
182
/*==================*/
267
/* out: TRUE if node pointer */
268
const rec_t* rec); /* in: physical record */
269
/**********************************************************
270
The following function is used to get the order number
271
of an old-style record in the heap of the index page. */
276
/* out: heap order number */
277
const rec_t* rec); /* in: physical record */
278
/**********************************************************
279
The following function is used to set the heap number
280
field in an old-style record. */
285
rec_t* rec, /* in: physical record */
286
ulint heap_no);/* in: the heap number */
287
/**********************************************************
288
The following function is used to get the order number
289
of a new-style record in the heap of the index page. */
294
/* out: heap order number */
295
const rec_t* rec); /* in: physical record */
296
/**********************************************************
297
The following function is used to set the heap number
298
field in a new-style record. */
303
rec_t* rec, /* in/out: physical record */
183
/* out: TRUE if node pointer */
184
rec_t* rec); /* in: physical record */
185
/**********************************************************
186
The following function is used to get the order number
187
of the record in the heap of the index page. */
192
/* out: heap order number */
193
rec_t* rec, /* in: physical record */
194
ulint comp); /* in: nonzero=compact page format */
195
/**********************************************************
196
The following function is used to set the heap number
197
field in the record. */
202
rec_t* rec, /* in: physical record */
203
ulint comp, /* in: nonzero=compact page format */
304
204
ulint heap_no);/* in: the heap number */
305
205
/**********************************************************
306
206
The following function is used to test whether the data offsets
310
210
rec_get_1byte_offs_flag(
311
211
/*====================*/
312
/* out: TRUE if 1-byte form */
313
const rec_t* rec); /* in: physical record */
315
/**********************************************************
316
Determine how many of the first n columns in a compact
317
physical record are stored externally. */
320
rec_get_n_extern_new(
321
/*=================*/
322
/* out: number of externally stored columns */
323
const rec_t* rec, /* in: compact physical record */
324
dict_index_t* index, /* in: record descriptor */
325
ulint n); /* in: number of columns to scan */
212
/* out: TRUE if 1-byte form */
213
rec_t* rec); /* in: physical record */
327
214
/**********************************************************
328
215
The following function determines the offsets to each field
329
216
in the record. It can reuse a previously allocated array. */
332
219
rec_get_offsets_func(
333
220
/*=================*/
334
/* out: the new offsets */
335
const rec_t* rec, /* in: physical record */
336
const dict_index_t* index, /* in: record descriptor */
337
ulint* offsets,/* in/out: array consisting of
338
offsets[0] allocated elements,
339
or an array from rec_get_offsets(),
341
ulint n_fields,/* in: maximum number of
343
(ULINT_UNDEFINED if all fields) */
344
mem_heap_t** heap, /* in/out: memory heap */
345
const char* file, /* in: file name where called */
346
ulint line); /* in: line number where called */
221
/* out: the new offsets */
222
rec_t* rec, /* in: physical record */
223
dict_index_t* index, /* in: record descriptor */
224
ulint* offsets,/* in: array consisting of offsets[0]
225
allocated elements, or an array from
226
rec_get_offsets(), or NULL */
227
ulint n_fields,/* in: maximum number of initialized fields
228
(ULINT_UNDEFINED if all fields) */
229
mem_heap_t** heap, /* in/out: memory heap */
230
const char* file, /* in: file name where called */
231
ulint line); /* in: line number where called */
348
233
#define rec_get_offsets(rec,index,offsets,n,heap) \
349
234
rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
351
/**********************************************************
352
Determine the offset to each field in a leaf-page record
353
in ROW_FORMAT=COMPACT. This is a special case of
354
rec_init_offsets() and rec_get_offsets_func(). */
357
rec_init_offsets_comp_ordinary(
358
/*===========================*/
359
const rec_t* rec, /* in: physical record in
360
ROW_FORMAT=COMPACT */
361
ulint extra, /* in: number of bytes to reserve
362
between the record header and
364
(usually REC_N_NEW_EXTRA_BYTES) */
365
const dict_index_t* index, /* in: record descriptor */
366
ulint* offsets);/* in/out: array of offsets;
367
in: n=rec_offs_n_fields(offsets) */
369
/**********************************************************
370
The following function determines the offsets to each field
371
in the record. It can reuse a previously allocated array. */
374
rec_get_offsets_reverse(
375
/*====================*/
376
const byte* extra, /* in: the extra bytes of a
377
compact record in reverse order,
378
excluding the fixed-size
379
REC_N_NEW_EXTRA_BYTES */
380
const dict_index_t* index, /* in: record descriptor */
381
ulint node_ptr,/* in: nonzero=node pointer,
383
ulint* offsets);/* in/out: array consisting of
384
offsets[0] allocated elements */
386
236
/****************************************************************
387
237
Validates offsets returned by rec_get_offsets(). */
390
240
rec_offs_validate(
391
241
/*==============*/
392
/* out: TRUE if valid */
393
const rec_t* rec, /* in: record or NULL */
394
const dict_index_t* index, /* in: record descriptor or NULL */
395
const ulint* offsets);/* in: array returned by
242
/* out: TRUE if valid */
243
rec_t* rec, /* in: record or NULL */
244
dict_index_t* index, /* in: record descriptor or NULL */
245
const ulint* offsets);/* in: array returned by rec_get_offsets() */
398
246
/****************************************************************
399
247
Updates debug data in offsets, in order to avoid bogus
400
248
rec_offs_validate() failures. */
403
251
rec_offs_make_valid(
404
252
/*================*/
405
const rec_t* rec, /* in: record */
406
const dict_index_t* index, /* in: record descriptor */
407
ulint* offsets);/* in: array returned by
410
# define rec_offs_make_valid(rec, index, offsets) ((void) 0)
411
#endif /* UNIV_DEBUG */
253
rec_t* rec, /* in: record */
254
dict_index_t* index,/* in: record descriptor */
255
const ulint* offsets);/* in: array returned by rec_get_offsets() */
413
257
/****************************************************************
414
The following function is used to get the offset to the nth
258
The following function is used to get a pointer to the nth
415
259
data field in an old-style record. */
418
rec_get_nth_field_offs_old(
419
/*=======================*/
420
/* out: offset to the field */
421
const rec_t* rec, /* in: record */
422
ulint n, /* in: index of the field */
423
ulint* len); /* out: length of the field; UNIV_SQL_NULL
425
#define rec_get_nth_field_old(rec, n, len) \
426
((rec) + rec_get_nth_field_offs_old(rec, n, len))
262
rec_get_nth_field_old(
263
/*==================*/
264
/* out: pointer to the field */
265
rec_t* rec, /* in: record */
266
ulint n, /* in: index of the field */
267
ulint* len); /* out: length of the field; UNIV_SQL_NULL
427
269
/****************************************************************
428
270
Gets the physical size of an old-style field.
429
271
Also an SQL null may have a field of size > 0,
433
275
rec_get_nth_field_size(
434
276
/*===================*/
435
/* out: field size in bytes */
436
const rec_t* rec, /* in: record */
437
ulint n); /* in: index of the field */
277
/* out: field size in bytes */
278
rec_t* rec, /* in: record */
279
ulint n); /* in: index of the field */
438
280
/****************************************************************
439
The following function is used to get an offset to the nth
281
The following function is used to get a pointer to the nth
440
282
data field in a record. */
443
rec_get_nth_field_offs(
444
/*===================*/
445
/* out: offset from the origin of rec */
287
/* out: pointer to the field */
288
rec_t* rec, /* in: record */
446
289
const ulint* offsets,/* in: array returned by rec_get_offsets() */
447
290
ulint n, /* in: index of the field */
448
291
ulint* len); /* out: length of the field; UNIV_SQL_NULL
450
#define rec_get_nth_field(rec, offsets, n, len) \
451
((rec) + rec_get_nth_field_offs(offsets, n, len))
452
293
/**********************************************************
453
294
Determine if the offsets are for a record in the new
454
295
compact format. */
496
328
ulint n); /* in: nth field */
498
330
/**********************************************************
499
Returns the number of extern bits set in a record. */
331
Returns TRUE if the extern bit is set in any of the fields
504
/* out: number of externally stored fields */
337
/* out: TRUE if a field is stored externally */
505
338
const ulint* offsets);/* in: array returned by rec_get_offsets() */
506
339
/***************************************************************
340
Sets the value of the ith field extern storage bit. */
343
rec_set_nth_field_extern_bit(
344
/*=========================*/
345
rec_t* rec, /* in: record */
346
dict_index_t* index, /* in: record descriptor */
347
ulint i, /* in: ith field */
348
ibool val, /* in: value to set */
349
mtr_t* mtr); /* in: mtr holding an X-latch to the page
350
where rec is, or NULL; in the NULL case
351
we do not write to log about the change */
352
/***************************************************************
353
Sets TRUE the extern storage bits of fields mentioned in an array. */
356
rec_set_field_extern_bits(
357
/*======================*/
358
rec_t* rec, /* in: record */
359
dict_index_t* index, /* in: record descriptor */
360
const ulint* vec, /* in: array of field numbers */
361
ulint n_fields,/* in: number of fields numbers */
362
mtr_t* mtr); /* in: mtr holding an X-latch to the page
363
where rec is, or NULL; in the NULL case
364
we do not write to log about the change */
365
/***************************************************************
507
366
This is used to modify the value of an already existing field in a record.
508
367
The previous value must have exactly the same size as the new value. If len
509
368
is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
531
390
rec_get_data_size_old(
532
391
/*==================*/
534
const rec_t* rec); /* in: physical record */
535
/**************************************************************
536
The following function returns the number of allocated elements
537
for an array of offsets. */
540
rec_offs_get_n_alloc(
541
/*=================*/
542
/* out: number of elements */
543
const ulint* offsets);/* in: array for rec_get_offsets() */
544
/**************************************************************
545
The following function sets the number of allocated elements
546
for an array of offsets. */
549
rec_offs_set_n_alloc(
550
/*=================*/
551
ulint* offsets, /* out: array for rec_get_offsets(),
553
ulint n_alloc); /* in: number of elements */
554
#define rec_offs_init(offsets) \
555
rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)
393
rec_t* rec); /* in: physical record */
556
394
/**************************************************************
557
395
The following function returns the number of fields in a record. */
621
459
/******************************************************************
622
460
Copies the first n fields of a physical record to a new physical record in
626
464
rec_copy_prefix_to_buf(
627
465
/*===================*/
628
/* out, own: copied record */
629
const rec_t* rec, /* in: physical record */
630
const dict_index_t* index, /* in: record descriptor */
631
ulint n_fields, /* in: number of fields
633
byte** buf, /* in/out: memory buffer
634
for the copied prefix,
636
ulint* buf_size); /* in/out: buffer size */
466
/* out, own: copied record */
467
rec_t* rec, /* in: physical record */
468
dict_index_t* index, /* in: record descriptor */
469
ulint n_fields, /* in: number of fields to copy */
470
byte** buf, /* in/out: memory buffer
471
for the copied prefix, or NULL */
472
ulint* buf_size); /* in/out: buffer size */
637
473
/****************************************************************
638
474
Folds a prefix of a physical record to a ulint. */
643
479
/* out: the folded value */
644
const rec_t* rec, /* in: the physical record */
480
rec_t* rec, /* in: the physical record */
645
481
const ulint* offsets, /* in: array returned by
646
482
rec_get_offsets() */
647
483
ulint n_fields, /* in: number of complete
648
484
fields to fold */
649
485
ulint n_bytes, /* in: number of bytes to fold
650
486
in an incomplete last field */
651
dulint tree_id) /* in: index tree id */
652
__attribute__((pure));
653
/*************************************************************
654
Builds a ROW_FORMAT=COMPACT record out of a data tuple. */
657
rec_convert_dtuple_to_rec_comp(
658
/*===========================*/
659
rec_t* rec, /* in: origin of record */
660
ulint extra, /* in: number of bytes to
661
reserve between the record
662
header and the data payload
663
(normally REC_N_NEW_EXTRA_BYTES) */
664
const dict_index_t* index, /* in: record descriptor */
665
ulint status, /* in: status bits of the record */
666
const dfield_t* fields, /* in: array of data fields */
667
ulint n_fields);/* in: number of data fields */
668
/*************************************************************
669
Builds a physical record out of a data tuple and
670
stores it into the given buffer. */
487
dulint tree_id); /* in: index tree id */
488
/*************************************************************
489
Builds a physical record out of a data tuple and stores it beginning from
490
address destination. */
673
493
rec_convert_dtuple_to_rec(
674
494
/*======================*/
675
/* out: pointer to the origin
676
of physical record */
677
byte* buf, /* in: start address of the
679
const dict_index_t* index, /* in: record descriptor */
680
const dtuple_t* dtuple, /* in: data tuple */
681
ulint n_ext); /* in: number of
682
externally stored columns */
495
/* out: pointer to the origin
496
of physical record */
497
byte* buf, /* in: start address of the
499
dict_index_t* index, /* in: record descriptor */
500
dtuple_t* dtuple);/* in: data tuple */
683
501
/**************************************************************
684
502
Returns the extra size of an old-style physical record if we know its
685
503
data size and number of fields. */
689
507
/*=========================*/
690
508
/* out: extra size */
691
509
ulint data_size, /* in: data size */
692
ulint n_fields, /* in: number of fields */
693
ulint n_ext) /* in: number of externally stored columns */
694
__attribute__((__const__));
695
/**************************************************************
696
Determines the size of a data tuple in ROW_FORMAT=COMPACT. */
699
rec_get_converted_size_comp(
700
/*========================*/
701
/* out: total size */
702
const dict_index_t* index, /* in: record descriptor;
703
dict_table_is_comp() is
704
assumed to hold, even if
706
ulint status, /* in: status bits of the record */
707
const dfield_t* fields, /* in: array of data fields */
708
ulint n_fields,/* in: number of data fields */
709
ulint* extra); /* out: extra size */
510
ulint n_fields) /* in: number of fields */
511
__attribute__((const));
710
512
/**************************************************************
711
513
The following function returns the size of a data tuple when converted to
712
514
a physical record. */
716
518
/*===================*/
718
520
dict_index_t* index, /* in: record descriptor */
719
const dtuple_t* dtuple, /* in: data tuple */
720
ulint n_ext); /* in: number of externally stored columns */
521
dtuple_t* dtuple);/* in: data tuple */
721
522
/******************************************************************
722
523
Copies the first n fields of a physical record to a data tuple.
723
524
The fields are copied to the memory heap. */
726
527
rec_copy_prefix_to_dtuple(
727
528
/*======================*/
728
dtuple_t* tuple, /* out: data tuple */
729
const rec_t* rec, /* in: physical record */
730
const dict_index_t* index, /* in: record descriptor */
731
ulint n_fields, /* in: number of fields
733
mem_heap_t* heap); /* in: memory heap */
529
dtuple_t* tuple, /* in: data tuple */
530
rec_t* rec, /* in: physical record */
531
dict_index_t* index, /* in: record descriptor */
532
ulint n_fields, /* in: number of fields to copy */
533
mem_heap_t* heap); /* in: memory heap */
734
534
/*******************************************************************
735
535
Validates the consistency of a physical record. */
740
540
/* out: TRUE if ok */
741
const rec_t* rec, /* in: physical record */
541
rec_t* rec, /* in: physical record */
742
542
const ulint* offsets);/* in: array returned by rec_get_offsets() */
743
543
/*******************************************************************
744
544
Prints an old-style physical record. */
749
549
FILE* file, /* in: file where to print */
750
const rec_t* rec); /* in: physical record */
751
/*******************************************************************
752
Prints a physical record in ROW_FORMAT=COMPACT. Ignores the
758
FILE* file, /* in: file where to print */
759
const rec_t* rec, /* in: physical record */
760
const ulint* offsets);/* in: array returned by rec_get_offsets() */
550
rec_t* rec); /* in: physical record */
761
551
/*******************************************************************
762
552
Prints a physical record. */
767
557
FILE* file, /* in: file where to print */
768
const rec_t* rec, /* in: physical record */
558
rec_t* rec, /* in: physical record */
769
559
const ulint* offsets);/* in: array returned by rec_get_offsets() */
770
560
/*******************************************************************
771
561
Prints a physical record. */
776
566
FILE* file, /* in: file where to print */
777
const rec_t* rec, /* in: physical record */
567
rec_t* rec, /* in: physical record */
778
568
dict_index_t* index); /* in: record descriptor */
780
570
#define REC_INFO_BITS 6 /* This is single byte bit-field */