Drizzled Public API Documentation

rem0rec.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4 
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.
8 
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.
12 
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., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /********************************************************************/
26 #pragma once
27 #ifndef rem0rec_h
28 #define rem0rec_h
29 
30 #include "univ.i"
31 #include "data0data.h"
32 #include "rem0types.h"
33 #include "mtr0types.h"
34 #include "page0types.h"
35 
36 /* Info bit denoting the predefined minimum record: this bit is set
37 if and only if the record is the first user record on a non-leaf
38 B-tree page that is the leftmost page on its level
39 (PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
40 #define REC_INFO_MIN_REC_FLAG 0x10UL
41 /* The deleted flag in info bits */
42 #define REC_INFO_DELETED_FLAG 0x20UL /* when bit is set to 1, it means the
43  record has been delete marked */
44 
45 /* Number of extra bytes in an old-style record,
46 in addition to the data and the offsets */
47 #define REC_N_OLD_EXTRA_BYTES 6
48 /* Number of extra bytes in a new-style record,
49 in addition to the data and the offsets */
50 #define REC_N_NEW_EXTRA_BYTES 5
51 
52 /* Record status values */
53 #define REC_STATUS_ORDINARY 0
54 #define REC_STATUS_NODE_PTR 1
55 #define REC_STATUS_INFIMUM 2
56 #define REC_STATUS_SUPREMUM 3
57 
58 /* The following four constants are needed in page0zip.c in order to
59 efficiently compress and decompress pages. */
60 
61 /* The offset of heap_no in a compact record */
62 #define REC_NEW_HEAP_NO 4
63 /* The shift of heap_no in a compact record.
64 The status is stored in the low-order bits. */
65 #define REC_HEAP_NO_SHIFT 3
66 
67 /* Length of a B-tree node pointer, in bytes */
68 #define REC_NODE_PTR_SIZE 4
69 
70 #ifdef UNIV_DEBUG
71 /* Length of the rec_get_offsets() header */
72 # define REC_OFFS_HEADER_SIZE 4
73 #else /* UNIV_DEBUG */
74 /* Length of the rec_get_offsets() header */
75 # define REC_OFFS_HEADER_SIZE 2
76 #endif /* UNIV_DEBUG */
77 
78 /* Number of elements that should be initially allocated for the
79 offsets[] array, first passed to rec_get_offsets() */
80 #define REC_OFFS_NORMAL_SIZE 100
81 #define REC_OFFS_SMALL_SIZE 10
82 
83 /******************************************************/
87 UNIV_INLINE
88 const rec_t*
90 /*===================*/
91  const rec_t* rec,
92  ulint comp);
93 /******************************************************/
97 UNIV_INLINE
98 rec_t*
100 /*=============*/
101  rec_t* rec,
102  ulint comp);
103 /******************************************************/
107 UNIV_INLINE
108 ulint
110 /*==============*/
111  const rec_t* rec,
112  ulint comp);
113 /******************************************************/
116 UNIV_INLINE
117 void
119 /*==================*/
120  rec_t* rec,
121  ulint next);
122 /******************************************************/
125 UNIV_INLINE
126 void
128 /*==================*/
129  rec_t* rec,
130  ulint next);
131 /******************************************************/
135 UNIV_INLINE
136 ulint
138 /*=================*/
139  const rec_t* rec);
140 /******************************************************/
144 UNIV_INLINE
145 ulint
147 /*=============*/
148  const rec_t* rec,
149  const dict_index_t* index);
150 /******************************************************/
154 UNIV_INLINE
155 ulint
157 /*================*/
158  const rec_t* rec);
159 /******************************************************/
161 UNIV_INLINE
162 void
164 /*================*/
165  rec_t* rec,
166  ulint n_owned);
167 /******************************************************/
171 UNIV_INLINE
172 ulint
174 /*================*/
175  const rec_t* rec);
176 /******************************************************/
178 UNIV_INLINE
179 void
181 /*================*/
182  rec_t* rec,
183  page_zip_des_t* page_zip,
184  ulint n_owned);
185 /******************************************************/
189 UNIV_INLINE
190 ulint
192 /*==============*/
193  const rec_t* rec,
194  ulint comp);
195 /******************************************************/
197 UNIV_INLINE
198 void
200 /*==================*/
201  rec_t* rec,
202  ulint bits);
203 /******************************************************/
205 UNIV_INLINE
206 void
208 /*==================*/
209  rec_t* rec,
210  ulint bits);
211 /******************************************************/
214 UNIV_INLINE
215 ulint
217 /*===========*/
218  const rec_t* rec);
220 /******************************************************/
222 UNIV_INLINE
223 void
225 /*===========*/
226  rec_t* rec,
227  ulint bits);
229 /******************************************************/
233 UNIV_INLINE
234 ulint
236 /*=========================*/
237  const rec_t* rec,
238  ulint comp);
239 /******************************************************/
242 UNIV_INLINE
243 void
245 /*=========================*/
246  rec_t* rec,
247  ulint bits);
249 /******************************************************/
252 UNIV_INLINE
253 ulint
255 /*=================*/
256  const rec_t* rec,
257  ulint comp);
258 /******************************************************/
260 UNIV_INLINE
261 void
263 /*=====================*/
264  rec_t* rec,
265  ulint flag);
266 /******************************************************/
268 UNIV_INLINE
269 void
271 /*=====================*/
272  rec_t* rec,
273  page_zip_des_t* page_zip,
274  ulint flag);
275 /******************************************************/
278 UNIV_INLINE
279 ibool
281 /*==================*/
282  const rec_t* rec);
283 /******************************************************/
287 UNIV_INLINE
288 ulint
290 /*================*/
291  const rec_t* rec);
292 /******************************************************/
295 UNIV_INLINE
296 void
298 /*================*/
299  rec_t* rec,
300  ulint heap_no);
301 /******************************************************/
305 UNIV_INLINE
306 ulint
308 /*================*/
309  const rec_t* rec);
310 /******************************************************/
313 UNIV_INLINE
314 void
316 /*================*/
317  rec_t* rec,
318  ulint heap_no);
319 /******************************************************/
323 UNIV_INLINE
324 ibool
326 /*====================*/
327  const rec_t* rec);
329 /******************************************************/
333 UNIV_INTERN
334 ulint
336 /*=================*/
337  const rec_t* rec,
338  dict_index_t* index,
339  ulint n);
341 /******************************************************/
345 UNIV_INTERN
346 ulint*
348 /*=================*/
349  const rec_t* rec,
350  const dict_index_t* index,
351  ulint* offsets,
355  ulint n_fields,
358  mem_heap_t** heap,
359  const char* file,
360  ulint line);
362 #define rec_get_offsets(rec,index,offsets,n,heap) \
363  rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
364 
365 /******************************************************/
369 UNIV_INTERN
370 void
372 /*===========================*/
373  const rec_t* rec,
375  ulint extra,
379  const dict_index_t* index,
380  ulint* offsets);
383 /******************************************************/
386 UNIV_INTERN
387 void
389 /*====================*/
390  const byte* extra,
394  const dict_index_t* index,
395  ulint node_ptr,
397  ulint* offsets);
400 /************************************************************/
403 UNIV_INLINE
404 ibool
406 /*==============*/
407  const rec_t* rec,
408  const dict_index_t* index,
409  const ulint* offsets);
411 #ifdef UNIV_DEBUG
412 /************************************************************/
415 UNIV_INLINE
416 void
417 rec_offs_make_valid(
418 /*================*/
419  const rec_t* rec,
420  const dict_index_t* index,
421  ulint* offsets);
423 #else
424 # define rec_offs_make_valid(rec, index, offsets) ((void) 0)
425 #endif /* UNIV_DEBUG */
426 
427 /************************************************************/
431 UNIV_INTERN
432 ulint
434 /*=======================*/
435  const rec_t* rec,
436  ulint n,
437  ulint* len);
439 #define rec_get_nth_field_old(rec, n, len) \
440 ((rec) + rec_get_nth_field_offs_old(rec, n, len))
441 /************************************************************/
446 UNIV_INLINE
447 ulint
449 /*===================*/
450  const rec_t* rec,
451  ulint n);
452 /************************************************************/
456 UNIV_INLINE
457 ulint
459 /*===================*/
460  const ulint* offsets,
461  ulint n,
462  ulint* len);
464 #define rec_get_nth_field(rec, offsets, n, len) \
465 ((rec) + rec_get_nth_field_offs(offsets, n, len))
466 /******************************************************/
470 UNIV_INLINE
471 ulint
473 /*==========*/
474  const ulint* offsets);
475 /******************************************************/
479 UNIV_INLINE
480 ulint
482 /*================*/
483  const ulint* offsets);
484 /******************************************************/
487 UNIV_INLINE
488 ulint
490 /*================*/
491  const ulint* offsets,
492  ulint n);
493 /******************************************************/
496 UNIV_INLINE
497 ulint
499 /*==================*/
500  const ulint* offsets,
501  ulint n);
502 /******************************************************/
505 UNIV_INLINE
506 ulint
508 /*==============*/
509  const ulint* offsets,
510  ulint n);
512 /******************************************************/
515 UNIV_INLINE
516 ulint
518 /*==============*/
519  const ulint* offsets);
520 /***********************************************************/
526 UNIV_INLINE
527 void
529 /*==============*/
530  rec_t* rec,
531  const ulint* offsets,
532  ulint n,
533  const void* data,
534  ulint len);
535 /**********************************************************/
541 UNIV_INLINE
542 ulint
544 /*==================*/
545  const rec_t* rec);
546 /**********************************************************/
550 UNIV_INLINE
551 ulint
553 /*=================*/
554  const ulint* offsets);
555 /**********************************************************/
558 UNIV_INLINE
559 void
561 /*=================*/
562  ulint* offsets,
564  ulint n_alloc);
565 #define rec_offs_init(offsets) \
566  rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)
567 /**********************************************************/
570 UNIV_INLINE
571 ulint
573 /*==============*/
574  const ulint* offsets);
575 /**********************************************************/
581 UNIV_INLINE
582 ulint
584 /*===============*/
585  const ulint* offsets);
586 /**********************************************************/
591 UNIV_INLINE
592 ulint
594 /*================*/
595  const ulint* offsets);
596 /**********************************************************/
599 UNIV_INLINE
600 ulint
602 /*==========*/
603  const ulint* offsets);
604 #ifdef UNIV_DEBUG
605 /**********************************************************/
608 UNIV_INLINE
609 byte*
610 rec_get_start(
611 /*==========*/
612  const rec_t* rec,
613  const ulint* offsets);
614 /**********************************************************/
617 UNIV_INLINE
618 byte*
619 rec_get_end(
620 /*========*/
621  const rec_t* rec,
622  const ulint* offsets);
623 #else /* UNIV_DEBUG */
624 # define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets))
625 # define rec_get_end(rec, offsets) ((rec) + rec_offs_data_size(offsets))
626 #endif /* UNIV_DEBUG */
627 /***************************************************************/
630 UNIV_INLINE
631 rec_t*
632 rec_copy(
633 /*=====*/
634  void* buf,
635  const rec_t* rec,
636  const ulint* offsets);
637 #ifndef UNIV_HOTBACKUP
638 /**************************************************************/
642 UNIV_INTERN
643 rec_t*
645 /*===================*/
646  const rec_t* rec,
647  const dict_index_t* index,
648  ulint n_fields,
650  byte** buf,
653  ulint* buf_size);
654 /************************************************************/
657 UNIV_INLINE
658 ulint
659 rec_fold(
660 /*=====*/
661  const rec_t* rec,
662  const ulint* offsets,
664  ulint n_fields,
666  ulint n_bytes,
668  index_id_t tree_id)
669  __attribute__((pure));
670 #endif /* !UNIV_HOTBACKUP */
671 /*********************************************************/
673 UNIV_INTERN
674 void
676 /*===========================*/
677  rec_t* rec,
678  ulint extra,
682  const dict_index_t* index,
683  ulint status,
684  const dfield_t* fields,
685  ulint n_fields);
686 /*********************************************************/
690 UNIV_INTERN
691 rec_t*
693 /*======================*/
694  byte* buf,
696  const dict_index_t* index,
697  const dtuple_t* dtuple,
698  ulint n_ext);
700 /**********************************************************/
704 UNIV_INLINE
705 ulint
707 /*=========================*/
708  ulint data_size,
709  ulint n_fields,
710  ulint n_ext)
711  __attribute__((const));
712 /**********************************************************/
715 UNIV_INTERN
716 ulint
718 /*===============================*/
719  const dict_index_t* index,
723  const dfield_t* fields,
724  ulint n_fields,
725  ulint* extra);
726 /**********************************************************/
729 UNIV_INTERN
730 ulint
732 /*========================*/
733  const dict_index_t* index,
737  ulint status,
738  const dfield_t* fields,
739  ulint n_fields,
740  ulint* extra);
741 /**********************************************************/
745 UNIV_INLINE
746 ulint
748 /*===================*/
749  dict_index_t* index,
750  const dtuple_t* dtuple,
751  ulint n_ext);
752 #ifndef UNIV_HOTBACKUP
753 /**************************************************************/
756 UNIV_INTERN
757 void
759 /*======================*/
760  dtuple_t* tuple,
761  const rec_t* rec,
762  const dict_index_t* index,
763  ulint n_fields,
765  mem_heap_t* heap);
766 #endif /* !UNIV_HOTBACKUP */
767 /***************************************************************/
770 UNIV_INTERN
771 ibool
773 /*=========*/
774  const rec_t* rec,
775  const ulint* offsets);
776 /***************************************************************/
778 UNIV_INTERN
779 void
780 rec_print_old(
781 /*==========*/
782  FILE* file,
783  const rec_t* rec);
784 #ifndef UNIV_HOTBACKUP
785 /***************************************************************/
788 UNIV_INTERN
789 void
791 /*===========*/
792  FILE* file,
793  const rec_t* rec,
794  const ulint* offsets);
795 /***************************************************************/
797 UNIV_INTERN
798 void
800 /*==========*/
801  FILE* file,
802  const rec_t* rec,
803  const ulint* offsets);
804 /***************************************************************/
806 UNIV_INTERN
807 void
808 rec_print(
809 /*======*/
810  FILE* file,
811  const rec_t* rec,
812  const dict_index_t* index);
813 #endif /* UNIV_HOTBACKUP */
814 
815 #define REC_INFO_BITS 6 /* This is single byte bit-field */
816 
817 /* Maximum lengths for the data in a physical record if the offsets
818 are given in one byte (resp. two byte) format. */
819 #define REC_1BYTE_OFFS_LIMIT 0x7FUL
820 #define REC_2BYTE_OFFS_LIMIT 0x7FFFUL
821 
822 /* The data size of record must be smaller than this because we reserve
823 two upmost bits in a two byte offset for special purposes */
824 #define REC_MAX_DATA_SIZE (16 * 1024)
825 
826 #ifndef UNIV_NONINL
827 #include "rem0rec.ic"
828 #endif
829 
830 #endif