mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / include / rem0rec.h
blob47aa78fd3b25c08493a01b03af90727c10167af3
1 /*****************************************************************************
3 Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *****************************************************************************/
19 /********************************************************************//**
20 @file include/rem0rec.h
21 Record manager
23 Created 5/30/1994 Heikki Tuuri
24 *************************************************************************/
26 #ifndef rem0rec_h
27 #define rem0rec_h
29 #include "univ.i"
30 #include "data0data.h"
31 #include "rem0types.h"
32 #include "mtr0types.h"
33 #include "page0types.h"
35 /* Info bit denoting the predefined minimum record: this bit is set
36 if and only if the record is the first user record on a non-leaf
37 B-tree page that is the leftmost page on its level
38 (PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
39 #define REC_INFO_MIN_REC_FLAG 0x10UL
40 /* The deleted flag in info bits */
41 #define REC_INFO_DELETED_FLAG 0x20UL /* when bit is set to 1, it means the
42 record has been delete marked */
44 /* Number of extra bytes in an old-style record,
45 in addition to the data and the offsets */
46 #define REC_N_OLD_EXTRA_BYTES 6
47 /* Number of extra bytes in a new-style record,
48 in addition to the data and the offsets */
49 #define REC_N_NEW_EXTRA_BYTES 5
51 /* Record status values */
52 #define REC_STATUS_ORDINARY 0
53 #define REC_STATUS_NODE_PTR 1
54 #define REC_STATUS_INFIMUM 2
55 #define REC_STATUS_SUPREMUM 3
57 /* The following four constants are needed in page0zip.c in order to
58 efficiently compress and decompress pages. */
60 /* The offset of heap_no in a compact record */
61 #define REC_NEW_HEAP_NO 4
62 /* The shift of heap_no in a compact record.
63 The status is stored in the low-order bits. */
64 #define REC_HEAP_NO_SHIFT 3
66 /* Length of a B-tree node pointer, in bytes */
67 #define REC_NODE_PTR_SIZE 4
69 #ifdef UNIV_DEBUG
70 /* Length of the rec_get_offsets() header */
71 # define REC_OFFS_HEADER_SIZE 4
72 #else /* UNIV_DEBUG */
73 /* Length of the rec_get_offsets() header */
74 # define REC_OFFS_HEADER_SIZE 2
75 #endif /* UNIV_DEBUG */
77 /* Number of elements that should be initially allocated for the
78 offsets[] array, first passed to rec_get_offsets() */
79 #define REC_OFFS_NORMAL_SIZE 100
80 #define REC_OFFS_SMALL_SIZE 10
82 /******************************************************//**
83 The following function is used to get the pointer of the next chained record
84 on the same page.
85 @return pointer to the next chained record, or NULL if none */
86 UNIV_INLINE
87 const rec_t*
88 rec_get_next_ptr_const(
89 /*===================*/
90 const rec_t* rec, /*!< in: physical record */
91 ulint comp); /*!< in: nonzero=compact page format */
92 /******************************************************//**
93 The following function is used to get the pointer of the next chained record
94 on the same page.
95 @return pointer to the next chained record, or NULL if none */
96 UNIV_INLINE
97 rec_t*
98 rec_get_next_ptr(
99 /*=============*/
100 rec_t* rec, /*!< in: physical record */
101 ulint comp); /*!< in: nonzero=compact page format */
102 /******************************************************//**
103 The following function is used to get the offset of the
104 next chained record on the same page.
105 @return the page offset of the next chained record, or 0 if none */
106 UNIV_INLINE
107 ulint
108 rec_get_next_offs(
109 /*==============*/
110 const rec_t* rec, /*!< in: physical record */
111 ulint comp); /*!< in: nonzero=compact page format */
112 /******************************************************//**
113 The following function is used to set the next record offset field
114 of an old-style record. */
115 UNIV_INLINE
116 void
117 rec_set_next_offs_old(
118 /*==================*/
119 rec_t* rec, /*!< in: old-style physical record */
120 ulint next); /*!< in: offset of the next record */
121 /******************************************************//**
122 The following function is used to set the next record offset field
123 of a new-style record. */
124 UNIV_INLINE
125 void
126 rec_set_next_offs_new(
127 /*==================*/
128 rec_t* rec, /*!< in/out: new-style physical record */
129 ulint next); /*!< in: offset of the next record */
130 /******************************************************//**
131 The following function is used to get the number of fields
132 in an old-style record.
133 @return number of data fields */
134 UNIV_INLINE
135 ulint
136 rec_get_n_fields_old(
137 /*=================*/
138 const rec_t* rec); /*!< in: physical record */
139 /******************************************************//**
140 The following function is used to get the number of fields
141 in a record.
142 @return number of data fields */
143 UNIV_INLINE
144 ulint
145 rec_get_n_fields(
146 /*=============*/
147 const rec_t* rec, /*!< in: physical record */
148 const dict_index_t* index); /*!< in: record descriptor */
149 /******************************************************//**
150 The following function is used to get the number of records owned by the
151 previous directory record.
152 @return number of owned records */
153 UNIV_INLINE
154 ulint
155 rec_get_n_owned_old(
156 /*================*/
157 const rec_t* rec); /*!< in: old-style physical record */
158 /******************************************************//**
159 The following function is used to set the number of owned records. */
160 UNIV_INLINE
161 void
162 rec_set_n_owned_old(
163 /*================*/
164 rec_t* rec, /*!< in: old-style physical record */
165 ulint n_owned); /*!< in: the number of owned */
166 /******************************************************//**
167 The following function is used to get the number of records owned by the
168 previous directory record.
169 @return number of owned records */
170 UNIV_INLINE
171 ulint
172 rec_get_n_owned_new(
173 /*================*/
174 const rec_t* rec); /*!< in: new-style physical record */
175 /******************************************************//**
176 The following function is used to set the number of owned records. */
177 UNIV_INLINE
178 void
179 rec_set_n_owned_new(
180 /*================*/
181 rec_t* rec, /*!< in/out: new-style physical record */
182 page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
183 ulint n_owned);/*!< in: the number of owned */
184 /******************************************************//**
185 The following function is used to retrieve the info bits of
186 a record.
187 @return info bits */
188 UNIV_INLINE
189 ulint
190 rec_get_info_bits(
191 /*==============*/
192 const rec_t* rec, /*!< in: physical record */
193 ulint comp); /*!< in: nonzero=compact page format */
194 /******************************************************//**
195 The following function is used to set the info bits of a record. */
196 UNIV_INLINE
197 void
198 rec_set_info_bits_old(
199 /*==================*/
200 rec_t* rec, /*!< in: old-style physical record */
201 ulint bits); /*!< in: info bits */
202 /******************************************************//**
203 The following function is used to set the info bits of a record. */
204 UNIV_INLINE
205 void
206 rec_set_info_bits_new(
207 /*==================*/
208 rec_t* rec, /*!< in/out: new-style physical record */
209 ulint bits); /*!< in: info bits */
210 /******************************************************//**
211 The following function retrieves the status bits of a new-style record.
212 @return status bits */
213 UNIV_INLINE
214 ulint
215 rec_get_status(
216 /*===========*/
217 const rec_t* rec); /*!< in: physical record */
219 /******************************************************//**
220 The following function is used to set the status bits of a new-style record. */
221 UNIV_INLINE
222 void
223 rec_set_status(
224 /*===========*/
225 rec_t* rec, /*!< in/out: physical record */
226 ulint bits); /*!< in: info bits */
228 /******************************************************//**
229 The following function is used to retrieve the info and status
230 bits of a record. (Only compact records have status bits.)
231 @return info bits */
232 UNIV_INLINE
233 ulint
234 rec_get_info_and_status_bits(
235 /*=========================*/
236 const rec_t* rec, /*!< in: physical record */
237 ulint comp); /*!< in: nonzero=compact page format */
238 /******************************************************//**
239 The following function is used to set the info and status
240 bits of a record. (Only compact records have status bits.) */
241 UNIV_INLINE
242 void
243 rec_set_info_and_status_bits(
244 /*=========================*/
245 rec_t* rec, /*!< in/out: compact physical record */
246 ulint bits); /*!< in: info bits */
248 /******************************************************//**
249 The following function tells if record is delete marked.
250 @return nonzero if delete marked */
251 UNIV_INLINE
252 ulint
253 rec_get_deleted_flag(
254 /*=================*/
255 const rec_t* rec, /*!< in: physical record */
256 ulint comp); /*!< in: nonzero=compact page format */
257 /******************************************************//**
258 The following function is used to set the deleted bit. */
259 UNIV_INLINE
260 void
261 rec_set_deleted_flag_old(
262 /*=====================*/
263 rec_t* rec, /*!< in: old-style physical record */
264 ulint flag); /*!< in: nonzero if delete marked */
265 /******************************************************//**
266 The following function is used to set the deleted bit. */
267 UNIV_INLINE
268 void
269 rec_set_deleted_flag_new(
270 /*=====================*/
271 rec_t* rec, /*!< in/out: new-style physical record */
272 page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
273 ulint flag); /*!< in: nonzero if delete marked */
274 /******************************************************//**
275 The following function tells if a new-style record is a node pointer.
276 @return TRUE if node pointer */
277 UNIV_INLINE
278 ibool
279 rec_get_node_ptr_flag(
280 /*==================*/
281 const rec_t* rec); /*!< in: physical record */
282 /******************************************************//**
283 The following function is used to get the order number
284 of an old-style record in the heap of the index page.
285 @return heap order number */
286 UNIV_INLINE
287 ulint
288 rec_get_heap_no_old(
289 /*================*/
290 const rec_t* rec); /*!< in: physical record */
291 /******************************************************//**
292 The following function is used to set the heap number
293 field in an old-style record. */
294 UNIV_INLINE
295 void
296 rec_set_heap_no_old(
297 /*================*/
298 rec_t* rec, /*!< in: physical record */
299 ulint heap_no);/*!< in: the heap number */
300 /******************************************************//**
301 The following function is used to get the order number
302 of a new-style record in the heap of the index page.
303 @return heap order number */
304 UNIV_INLINE
305 ulint
306 rec_get_heap_no_new(
307 /*================*/
308 const rec_t* rec); /*!< in: physical record */
309 /******************************************************//**
310 The following function is used to set the heap number
311 field in a new-style record. */
312 UNIV_INLINE
313 void
314 rec_set_heap_no_new(
315 /*================*/
316 rec_t* rec, /*!< in/out: physical record */
317 ulint heap_no);/*!< in: the heap number */
318 /******************************************************//**
319 The following function is used to test whether the data offsets
320 in the record are stored in one-byte or two-byte format.
321 @return TRUE if 1-byte form */
322 UNIV_INLINE
323 ibool
324 rec_get_1byte_offs_flag(
325 /*====================*/
326 const rec_t* rec); /*!< in: physical record */
328 /******************************************************//**
329 Determine how many of the first n columns in a compact
330 physical record are stored externally.
331 @return number of externally stored columns */
332 UNIV_INTERN
333 ulint
334 rec_get_n_extern_new(
335 /*=================*/
336 const rec_t* rec, /*!< in: compact physical record */
337 dict_index_t* index, /*!< in: record descriptor */
338 ulint n); /*!< in: number of columns to scan */
340 /******************************************************//**
341 The following function determines the offsets to each field
342 in the record. It can reuse a previously allocated array.
343 @return the new offsets */
344 UNIV_INTERN
345 ulint*
346 rec_get_offsets_func(
347 /*=================*/
348 const rec_t* rec, /*!< in: physical record */
349 const dict_index_t* index, /*!< in: record descriptor */
350 ulint* offsets,/*!< in/out: array consisting of
351 offsets[0] allocated elements,
352 or an array from rec_get_offsets(),
353 or NULL */
354 ulint n_fields,/*!< in: maximum number of
355 initialized fields
356 (ULINT_UNDEFINED if all fields) */
357 mem_heap_t** heap, /*!< in/out: memory heap */
358 const char* file, /*!< in: file name where called */
359 ulint line); /*!< in: line number where called */
361 #define rec_get_offsets(rec,index,offsets,n,heap) \
362 rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
364 /******************************************************//**
365 The following function determines the offsets to each field
366 in the record. It can reuse a previously allocated array. */
367 UNIV_INTERN
368 void
369 rec_get_offsets_reverse(
370 /*====================*/
371 const byte* extra, /*!< in: the extra bytes of a
372 compact record in reverse order,
373 excluding the fixed-size
374 REC_N_NEW_EXTRA_BYTES */
375 const dict_index_t* index, /*!< in: record descriptor */
376 ulint node_ptr,/*!< in: nonzero=node pointer,
377 0=leaf node */
378 ulint* offsets);/*!< in/out: array consisting of
379 offsets[0] allocated elements */
381 /************************************************************//**
382 Validates offsets returned by rec_get_offsets().
383 @return TRUE if valid */
384 UNIV_INLINE
385 ibool
386 rec_offs_validate(
387 /*==============*/
388 const rec_t* rec, /*!< in: record or NULL */
389 const dict_index_t* index, /*!< in: record descriptor or NULL */
390 const ulint* offsets);/*!< in: array returned by
391 rec_get_offsets() */
392 #ifdef UNIV_DEBUG
393 /************************************************************//**
394 Updates debug data in offsets, in order to avoid bogus
395 rec_offs_validate() failures. */
396 UNIV_INLINE
397 void
398 rec_offs_make_valid(
399 /*================*/
400 const rec_t* rec, /*!< in: record */
401 const dict_index_t* index, /*!< in: record descriptor */
402 ulint* offsets);/*!< in: array returned by
403 rec_get_offsets() */
404 #else
405 # define rec_offs_make_valid(rec, index, offsets) ((void) 0)
406 #endif /* UNIV_DEBUG */
408 /************************************************************//**
409 The following function is used to get the offset to the nth
410 data field in an old-style record.
411 @return offset to the field */
412 UNIV_INTERN
413 ulint
414 rec_get_nth_field_offs_old(
415 /*=======================*/
416 const rec_t* rec, /*!< in: record */
417 ulint n, /*!< in: index of the field */
418 ulint* len); /*!< out: length of the field; UNIV_SQL_NULL
419 if SQL null */
420 #define rec_get_nth_field_old(rec, n, len) \
421 ((rec) + rec_get_nth_field_offs_old(rec, n, len))
422 /************************************************************//**
423 Gets the physical size of an old-style field.
424 Also an SQL null may have a field of size > 0,
425 if the data type is of a fixed size.
426 @return field size in bytes */
427 UNIV_INLINE
428 ulint
429 rec_get_nth_field_size(
430 /*===================*/
431 const rec_t* rec, /*!< in: record */
432 ulint n); /*!< in: index of the field */
433 /************************************************************//**
434 The following function is used to get an offset to the nth
435 data field in a record.
436 @return offset from the origin of rec */
437 UNIV_INLINE
438 ulint
439 rec_get_nth_field_offs(
440 /*===================*/
441 const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
442 ulint n, /*!< in: index of the field */
443 ulint* len); /*!< out: length of the field; UNIV_SQL_NULL
444 if SQL null */
445 #define rec_get_nth_field(rec, offsets, n, len) \
446 ((rec) + rec_get_nth_field_offs(offsets, n, len))
447 /******************************************************//**
448 Determine if the offsets are for a record in the new
449 compact format.
450 @return nonzero if compact format */
451 UNIV_INLINE
452 ulint
453 rec_offs_comp(
454 /*==========*/
455 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
456 /******************************************************//**
457 Determine if the offsets are for a record containing
458 externally stored columns.
459 @return nonzero if externally stored */
460 UNIV_INLINE
461 ulint
462 rec_offs_any_extern(
463 /*================*/
464 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
465 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
466 /******************************************************//**
467 Determine if the offsets are for a record containing null BLOB pointers.
468 @return first field containing a null BLOB pointer, or NULL if none found */
469 UNIV_INLINE
470 const byte*
471 rec_offs_any_null_extern(
472 /*=====================*/
473 const rec_t* rec, /*!< in: record */
474 const ulint* offsets) /*!< in: rec_get_offsets(rec) */
475 __attribute__((nonnull, warn_unused_result));
476 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
477 /******************************************************//**
478 Returns nonzero if the extern bit is set in nth field of rec.
479 @return nonzero if externally stored */
480 UNIV_INLINE
481 ulint
482 rec_offs_nth_extern(
483 /*================*/
484 const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
485 ulint n); /*!< in: nth field */
486 /******************************************************//**
487 Returns nonzero if the SQL NULL bit is set in nth field of rec.
488 @return nonzero if SQL NULL */
489 UNIV_INLINE
490 ulint
491 rec_offs_nth_sql_null(
492 /*==================*/
493 const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
494 ulint n); /*!< in: nth field */
495 /******************************************************//**
496 Gets the physical size of a field.
497 @return length of field */
498 UNIV_INLINE
499 ulint
500 rec_offs_nth_size(
501 /*==============*/
502 const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
503 ulint n); /*!< in: nth field */
505 /******************************************************//**
506 Returns the number of extern bits set in a record.
507 @return number of externally stored fields */
508 UNIV_INLINE
509 ulint
510 rec_offs_n_extern(
511 /*==============*/
512 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
513 /***********************************************************//**
514 This is used to modify the value of an already existing field in a record.
515 The previous value must have exactly the same size as the new value. If len
516 is UNIV_SQL_NULL then the field is treated as an SQL null.
517 For records in ROW_FORMAT=COMPACT (new-style records), len must not be
518 UNIV_SQL_NULL unless the field already is SQL null. */
519 UNIV_INLINE
520 void
521 rec_set_nth_field(
522 /*==============*/
523 rec_t* rec, /*!< in: record */
524 const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
525 ulint n, /*!< in: index number of the field */
526 const void* data, /*!< in: pointer to the data if not SQL null */
527 ulint len); /*!< in: length of the data or UNIV_SQL_NULL */
528 /**********************************************************//**
529 The following function returns the data size of an old-style physical
530 record, that is the sum of field lengths. SQL null fields
531 are counted as length 0 fields. The value returned by the function
532 is the distance from record origin to record end in bytes.
533 @return size */
534 UNIV_INLINE
535 ulint
536 rec_get_data_size_old(
537 /*==================*/
538 const rec_t* rec); /*!< in: physical record */
539 /**********************************************************//**
540 The following function returns the number of allocated elements
541 for an array of offsets.
542 @return number of elements */
543 UNIV_INLINE
544 ulint
545 rec_offs_get_n_alloc(
546 /*=================*/
547 const ulint* offsets);/*!< in: array for rec_get_offsets() */
548 /**********************************************************//**
549 The following function sets the number of allocated elements
550 for an array of offsets. */
551 UNIV_INLINE
552 void
553 rec_offs_set_n_alloc(
554 /*=================*/
555 ulint* offsets, /*!< out: array for rec_get_offsets(),
556 must be allocated */
557 ulint n_alloc); /*!< in: number of elements */
558 #define rec_offs_init(offsets) \
559 rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)
560 /**********************************************************//**
561 The following function returns the number of fields in a record.
562 @return number of fields */
563 UNIV_INLINE
564 ulint
565 rec_offs_n_fields(
566 /*==============*/
567 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
568 /**********************************************************//**
569 The following function returns the data size of a physical
570 record, that is the sum of field lengths. SQL null fields
571 are counted as length 0 fields. The value returned by the function
572 is the distance from record origin to record end in bytes.
573 @return size */
574 UNIV_INLINE
575 ulint
576 rec_offs_data_size(
577 /*===============*/
578 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
579 /**********************************************************//**
580 Returns the total size of record minus data size of record.
581 The value returned by the function is the distance from record
582 start to record origin in bytes.
583 @return size */
584 UNIV_INLINE
585 ulint
586 rec_offs_extra_size(
587 /*================*/
588 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
589 /**********************************************************//**
590 Returns the total size of a physical record.
591 @return size */
592 UNIV_INLINE
593 ulint
594 rec_offs_size(
595 /*==========*/
596 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
597 /**********************************************************//**
598 Returns a pointer to the start of the record.
599 @return pointer to start */
600 UNIV_INLINE
601 byte*
602 rec_get_start(
603 /*==========*/
604 rec_t* rec, /*!< in: pointer to record */
605 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
606 /**********************************************************//**
607 Returns a pointer to the end of the record.
608 @return pointer to end */
609 UNIV_INLINE
610 byte*
611 rec_get_end(
612 /*========*/
613 rec_t* rec, /*!< in: pointer to record */
614 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
615 /***************************************************************//**
616 Copies a physical record to a buffer.
617 @return pointer to the origin of the copy */
618 UNIV_INLINE
619 rec_t*
620 rec_copy(
621 /*=====*/
622 void* buf, /*!< in: buffer */
623 const rec_t* rec, /*!< in: physical record */
624 const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
625 __attribute__((nonnull));
626 #ifndef UNIV_HOTBACKUP
627 /**********************************************************//**
628 Determines the size of a data tuple prefix in a temporary file.
629 @return total size */
630 UNIV_INTERN
631 ulint
632 rec_get_converted_size_temp(
633 /*========================*/
634 const dict_index_t* index, /*!< in: record descriptor */
635 const dfield_t* fields, /*!< in: array of data fields */
636 ulint n_fields,/*!< in: number of data fields */
637 ulint* extra) /*!< out: extra size */
638 __attribute__((warn_unused_result, nonnull));
640 /******************************************************//**
641 Determine the offset to each field in temporary file.
642 @see rec_convert_dtuple_to_temp() */
643 UNIV_INTERN
644 void
645 rec_init_offsets_temp(
646 /*==================*/
647 const rec_t* rec, /*!< in: temporary file record */
648 const dict_index_t* index, /*!< in: record descriptor */
649 ulint* offsets)/*!< in/out: array of offsets;
650 in: n=rec_offs_n_fields(offsets) */
651 __attribute__((nonnull));
653 /*********************************************************//**
654 Builds a temporary file record out of a data tuple.
655 @see rec_init_offsets_temp() */
656 UNIV_INTERN
657 void
658 rec_convert_dtuple_to_temp(
659 /*=======================*/
660 rec_t* rec, /*!< out: record */
661 const dict_index_t* index, /*!< in: record descriptor */
662 const dfield_t* fields, /*!< in: array of data fields */
663 ulint n_fields) /*!< in: number of fields */
664 __attribute__((nonnull));
666 /**************************************************************//**
667 Copies the first n fields of a physical record to a new physical record in
668 a buffer.
669 @return own: copied record */
670 UNIV_INTERN
671 rec_t*
672 rec_copy_prefix_to_buf(
673 /*===================*/
674 const rec_t* rec, /*!< in: physical record */
675 const dict_index_t* index, /*!< in: record descriptor */
676 ulint n_fields, /*!< in: number of fields
677 to copy */
678 byte** buf, /*!< in/out: memory buffer
679 for the copied prefix,
680 or NULL */
681 ulint* buf_size); /*!< in/out: buffer size */
682 /************************************************************//**
683 Folds a prefix of a physical record to a ulint.
684 @return the folded value */
685 UNIV_INLINE
686 ulint
687 rec_fold(
688 /*=====*/
689 const rec_t* rec, /*!< in: the physical record */
690 const ulint* offsets, /*!< in: array returned by
691 rec_get_offsets() */
692 ulint n_fields, /*!< in: number of complete
693 fields to fold */
694 ulint n_bytes, /*!< in: number of bytes to fold
695 in an incomplete last field */
696 dulint tree_id) /*!< in: index tree id */
697 __attribute__((pure));
698 #endif /* !UNIV_HOTBACKUP */
699 /*********************************************************//**
700 Builds a physical record out of a data tuple and
701 stores it into the given buffer.
702 @return pointer to the origin of physical record */
703 UNIV_INTERN
704 rec_t*
705 rec_convert_dtuple_to_rec(
706 /*======================*/
707 byte* buf, /*!< in: start address of the
708 physical record */
709 const dict_index_t* index, /*!< in: record descriptor */
710 const dtuple_t* dtuple, /*!< in: data tuple */
711 ulint n_ext); /*!< in: number of
712 externally stored columns */
713 /**********************************************************//**
714 Returns the extra size of an old-style physical record if we know its
715 data size and number of fields.
716 @return extra size */
717 UNIV_INLINE
718 ulint
719 rec_get_converted_extra_size(
720 /*=========================*/
721 ulint data_size, /*!< in: data size */
722 ulint n_fields, /*!< in: number of fields */
723 ulint n_ext) /*!< in: number of externally stored columns */
724 __attribute__((const));
725 /**********************************************************//**
726 Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT.
727 @return total size */
728 UNIV_INTERN
729 ulint
730 rec_get_converted_size_comp_prefix(
731 /*===============================*/
732 const dict_index_t* index, /*!< in: record descriptor */
733 const dfield_t* fields, /*!< in: array of data fields */
734 ulint n_fields,/*!< in: number of data fields */
735 ulint* extra); /*!< out: extra size */
736 /**********************************************************//**
737 Determines the size of a data tuple in ROW_FORMAT=COMPACT.
738 @return total size */
739 UNIV_INTERN
740 ulint
741 rec_get_converted_size_comp(
742 /*========================*/
743 const dict_index_t* index, /*!< in: record descriptor;
744 dict_table_is_comp() is
745 assumed to hold, even if
746 it does not */
747 ulint status, /*!< in: status bits of the record */
748 const dfield_t* fields, /*!< in: array of data fields */
749 ulint n_fields,/*!< in: number of data fields */
750 ulint* extra); /*!< out: extra size */
751 /**********************************************************//**
752 The following function returns the size of a data tuple when converted to
753 a physical record.
754 @return size */
755 UNIV_INLINE
756 ulint
757 rec_get_converted_size(
758 /*===================*/
759 dict_index_t* index, /*!< in: record descriptor */
760 const dtuple_t* dtuple, /*!< in: data tuple */
761 ulint n_ext); /*!< in: number of externally stored columns */
762 #ifndef UNIV_HOTBACKUP
763 /**************************************************************//**
764 Copies the first n fields of a physical record to a data tuple.
765 The fields are copied to the memory heap. */
766 UNIV_INTERN
767 void
768 rec_copy_prefix_to_dtuple(
769 /*======================*/
770 dtuple_t* tuple, /*!< out: data tuple */
771 const rec_t* rec, /*!< in: physical record */
772 const dict_index_t* index, /*!< in: record descriptor */
773 ulint n_fields, /*!< in: number of fields
774 to copy */
775 mem_heap_t* heap); /*!< in: memory heap */
776 #endif /* !UNIV_HOTBACKUP */
777 /***************************************************************//**
778 Validates the consistency of a physical record.
779 @return TRUE if ok */
780 UNIV_INTERN
781 ibool
782 rec_validate(
783 /*=========*/
784 const rec_t* rec, /*!< in: physical record */
785 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
786 /***************************************************************//**
787 Prints an old-style physical record. */
788 UNIV_INTERN
789 void
790 rec_print_old(
791 /*==========*/
792 FILE* file, /*!< in: file where to print */
793 const rec_t* rec); /*!< in: physical record */
794 #ifndef UNIV_HOTBACKUP
795 /***************************************************************//**
796 Prints a physical record in ROW_FORMAT=COMPACT. Ignores the
797 record header. */
798 UNIV_INTERN
799 void
800 rec_print_comp(
801 /*===========*/
802 FILE* file, /*!< in: file where to print */
803 const rec_t* rec, /*!< in: physical record */
804 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
805 /***************************************************************//**
806 Prints a physical record. */
807 UNIV_INTERN
808 void
809 rec_print_new(
810 /*==========*/
811 FILE* file, /*!< in: file where to print */
812 const rec_t* rec, /*!< in: physical record */
813 const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
814 /***************************************************************//**
815 Prints a physical record. */
816 UNIV_INTERN
817 void
818 rec_print(
819 /*======*/
820 FILE* file, /*!< in: file where to print */
821 const rec_t* rec, /*!< in: physical record */
822 dict_index_t* index); /*!< in: record descriptor */
823 #endif /* UNIV_HOTBACKUP */
825 #define REC_INFO_BITS 6 /* This is single byte bit-field */
827 /* Maximum lengths for the data in a physical record if the offsets
828 are given in one byte (resp. two byte) format. */
829 #define REC_1BYTE_OFFS_LIMIT 0x7FUL
830 #define REC_2BYTE_OFFS_LIMIT 0x7FFFUL
832 /* The data size of record must be smaller than this because we reserve
833 two upmost bits in a two byte offset for special purposes */
834 #define REC_MAX_DATA_SIZE (16 * 1024)
836 #ifndef UNIV_NONINL
837 #include "rem0rec.ic"
838 #endif
840 #endif