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 /**********************************************************/
607 UNIV_INLINE
608 byte*
610 /*==========*/
611  rec_t* rec,
612  const ulint* offsets);
613 /**********************************************************/
616 UNIV_INLINE
617 byte*
619 /*========*/
620  rec_t* rec,
621  const ulint* offsets);
622 /***************************************************************/
625 UNIV_INLINE
626 rec_t*
627 rec_copy(
628 /*=====*/
629  void* buf,
630  const rec_t* rec,
631  const ulint* offsets);
632 #ifndef UNIV_HOTBACKUP
633 /**************************************************************/
637 UNIV_INTERN
638 rec_t*
640 /*===================*/
641  const rec_t* rec,
642  const dict_index_t* index,
643  ulint n_fields,
645  byte** buf,
648  ulint* buf_size);
649 /************************************************************/
652 UNIV_INLINE
653 ulint
654 rec_fold(
655 /*=====*/
656  const rec_t* rec,
657  const ulint* offsets,
659  ulint n_fields,
661  ulint n_bytes,
663  index_id_t tree_id)
664  __attribute__((pure));
665 #endif /* !UNIV_HOTBACKUP */
666 /*********************************************************/
668 UNIV_INTERN
669 void
671 /*===========================*/
672  rec_t* rec,
673  ulint extra,
677  const dict_index_t* index,
678  ulint status,
679  const dfield_t* fields,
680  ulint n_fields);
681 /*********************************************************/
685 UNIV_INTERN
686 rec_t*
688 /*======================*/
689  byte* buf,
691  const dict_index_t* index,
692  const dtuple_t* dtuple,
693  ulint n_ext);
695 /**********************************************************/
699 UNIV_INLINE
700 ulint
702 /*=========================*/
703  ulint data_size,
704  ulint n_fields,
705  ulint n_ext)
706  __attribute__((const));
707 /**********************************************************/
710 UNIV_INTERN
711 ulint
713 /*===============================*/
714  const dict_index_t* index,
718  const dfield_t* fields,
719  ulint n_fields,
720  ulint* extra);
721 /**********************************************************/
724 UNIV_INTERN
725 ulint
727 /*========================*/
728  const dict_index_t* index,
732  ulint status,
733  const dfield_t* fields,
734  ulint n_fields,
735  ulint* extra);
736 /**********************************************************/
740 UNIV_INLINE
741 ulint
743 /*===================*/
744  dict_index_t* index,
745  const dtuple_t* dtuple,
746  ulint n_ext);
747 #ifndef UNIV_HOTBACKUP
748 /**************************************************************/
751 UNIV_INTERN
752 void
754 /*======================*/
755  dtuple_t* tuple,
756  const rec_t* rec,
757  const dict_index_t* index,
758  ulint n_fields,
760  mem_heap_t* heap);
761 #endif /* !UNIV_HOTBACKUP */
762 /***************************************************************/
765 UNIV_INTERN
766 ibool
768 /*=========*/
769  const rec_t* rec,
770  const ulint* offsets);
771 /***************************************************************/
773 UNIV_INTERN
774 void
775 rec_print_old(
776 /*==========*/
777  FILE* file,
778  const rec_t* rec);
779 #ifndef UNIV_HOTBACKUP
780 /***************************************************************/
783 UNIV_INTERN
784 void
786 /*===========*/
787  FILE* file,
788  const rec_t* rec,
789  const ulint* offsets);
790 /***************************************************************/
792 UNIV_INTERN
793 void
795 /*==========*/
796  FILE* file,
797  const rec_t* rec,
798  const ulint* offsets);
799 /***************************************************************/
801 UNIV_INTERN
802 void
803 rec_print(
804 /*======*/
805  FILE* file,
806  const rec_t* rec,
807  const dict_index_t* index);
808 #endif /* UNIV_HOTBACKUP */
809 
810 #define REC_INFO_BITS 6 /* This is single byte bit-field */
811 
812 /* Maximum lengths for the data in a physical record if the offsets
813 are given in one byte (resp. two byte) format. */
814 #define REC_1BYTE_OFFS_LIMIT 0x7FUL
815 #define REC_2BYTE_OFFS_LIMIT 0x7FFFUL
816 
817 /* The data size of record must be smaller than this because we reserve
818 two upmost bits in a two byte offset for special purposes */
819 #define REC_MAX_DATA_SIZE (16 * 1024)
820 
821 #ifndef UNIV_NONINL
822 #include "rem0rec.ic"
823 #endif
824 
825 #endif