drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
rem0rec.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/********************************************************************/
25
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
37if and only if the record is the first user record on a non-leaf
38B-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,
46in 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,
49in 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
59efficiently 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.
64The 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
79offsets[] array, first passed to rec_get_offsets() */
80#define REC_OFFS_NORMAL_SIZE 100
81#define REC_OFFS_SMALL_SIZE 10
82
83/******************************************************/
87UNIV_INLINE
88const rec_t*
90/*===================*/
91 const rec_t* rec,
92 ulint comp);
93/******************************************************/
97UNIV_INLINE
98rec_t*
100/*=============*/
101 rec_t* rec,
102 ulint comp);
103/******************************************************/
107UNIV_INLINE
108ulint
110/*==============*/
111 const rec_t* rec,
112 ulint comp);
113/******************************************************/
116UNIV_INLINE
117void
119/*==================*/
120 rec_t* rec,
121 ulint next);
122/******************************************************/
125UNIV_INLINE
126void
128/*==================*/
129 rec_t* rec,
130 ulint next);
131/******************************************************/
135UNIV_INLINE
136ulint
138/*=================*/
139 const rec_t* rec);
140/******************************************************/
144UNIV_INLINE
145ulint
147/*=============*/
148 const rec_t* rec,
149 const dict_index_t* index);
150/******************************************************/
154UNIV_INLINE
155ulint
157/*================*/
158 const rec_t* rec);
159/******************************************************/
161UNIV_INLINE
162void
164/*================*/
165 rec_t* rec,
166 ulint n_owned);
167/******************************************************/
171UNIV_INLINE
172ulint
174/*================*/
175 const rec_t* rec);
176/******************************************************/
178UNIV_INLINE
179void
181/*================*/
182 rec_t* rec,
183 page_zip_des_t* page_zip,
184 ulint n_owned);
185/******************************************************/
189UNIV_INLINE
190ulint
192/*==============*/
193 const rec_t* rec,
194 ulint comp);
195/******************************************************/
197UNIV_INLINE
198void
200/*==================*/
201 rec_t* rec,
202 ulint bits);
203/******************************************************/
205UNIV_INLINE
206void
208/*==================*/
209 rec_t* rec,
210 ulint bits);
211/******************************************************/
214UNIV_INLINE
215ulint
217/*===========*/
218 const rec_t* rec);
219
220/******************************************************/
222UNIV_INLINE
223void
225/*===========*/
226 rec_t* rec,
227 ulint bits);
228
229/******************************************************/
233UNIV_INLINE
234ulint
236/*=========================*/
237 const rec_t* rec,
238 ulint comp);
239/******************************************************/
242UNIV_INLINE
243void
245/*=========================*/
246 rec_t* rec,
247 ulint bits);
248
249/******************************************************/
252UNIV_INLINE
253ulint
255/*=================*/
256 const rec_t* rec,
257 ulint comp);
258/******************************************************/
260UNIV_INLINE
261void
263/*=====================*/
264 rec_t* rec,
265 ulint flag);
266/******************************************************/
268UNIV_INLINE
269void
271/*=====================*/
272 rec_t* rec,
273 page_zip_des_t* page_zip,
274 ulint flag);
275/******************************************************/
278UNIV_INLINE
279ibool
281/*==================*/
282 const rec_t* rec);
283/******************************************************/
287UNIV_INLINE
288ulint
290/*================*/
291 const rec_t* rec);
292/******************************************************/
295UNIV_INLINE
296void
298/*================*/
299 rec_t* rec,
300 ulint heap_no);
301/******************************************************/
305UNIV_INLINE
306ulint
308/*================*/
309 const rec_t* rec);
310/******************************************************/
313UNIV_INLINE
314void
316/*================*/
317 rec_t* rec,
318 ulint heap_no);
319/******************************************************/
323UNIV_INLINE
324ibool
326/*====================*/
327 const rec_t* rec);
328
329/******************************************************/
333UNIV_INTERN
334ulint
336/*=================*/
337 const rec_t* rec,
338 dict_index_t* index,
339 ulint n);
340
341/******************************************************/
345UNIV_INTERN
346ulint*
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);
361
362#define rec_get_offsets(rec,index,offsets,n,heap) \
363 rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
364
365/******************************************************/
369UNIV_INTERN
370void
372/*===========================*/
373 const rec_t* rec,
375 ulint extra,
379 const dict_index_t* index,
380 ulint* offsets);
382
383/******************************************************/
386UNIV_INTERN
387void
389/*====================*/
390 const byte* extra,
394 const dict_index_t* index,
395 ulint node_ptr,
397 ulint* offsets);
399
400/************************************************************/
403UNIV_INLINE
404ibool
406/*==============*/
407 const rec_t* rec,
408 const dict_index_t* index,
409 const ulint* offsets);
411#ifdef UNIV_DEBUG
412/************************************************************/
415UNIV_INLINE
416void
417rec_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/************************************************************/
431UNIV_INTERN
432ulint
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/************************************************************/
446UNIV_INLINE
447ulint
449/*===================*/
450 const rec_t* rec,
451 ulint n);
452/************************************************************/
456UNIV_INLINE
457ulint
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/******************************************************/
470UNIV_INLINE
471ulint
473/*==========*/
474 const ulint* offsets);
475/******************************************************/
479UNIV_INLINE
480ulint
482/*================*/
483 const ulint* offsets);
484/******************************************************/
487UNIV_INLINE
488ulint
490/*================*/
491 const ulint* offsets,
492 ulint n);
493/******************************************************/
496UNIV_INLINE
497ulint
499/*==================*/
500 const ulint* offsets,
501 ulint n);
502/******************************************************/
505UNIV_INLINE
506ulint
508/*==============*/
509 const ulint* offsets,
510 ulint n);
511
512/******************************************************/
515UNIV_INLINE
516ulint
518/*==============*/
519 const ulint* offsets);
520/***********************************************************/
526UNIV_INLINE
527void
529/*==============*/
530 rec_t* rec,
531 const ulint* offsets,
532 ulint n,
533 const void* data,
534 ulint len);
535/**********************************************************/
541UNIV_INLINE
542ulint
544/*==================*/
545 const rec_t* rec);
546/**********************************************************/
550UNIV_INLINE
551ulint
553/*=================*/
554 const ulint* offsets);
555/**********************************************************/
558UNIV_INLINE
559void
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/**********************************************************/
570UNIV_INLINE
571ulint
573/*==============*/
574 const ulint* offsets);
575/**********************************************************/
581UNIV_INLINE
582ulint
584/*===============*/
585 const ulint* offsets);
586/**********************************************************/
591UNIV_INLINE
592ulint
594/*================*/
595 const ulint* offsets);
596/**********************************************************/
599UNIV_INLINE
600ulint
602/*==========*/
603 const ulint* offsets);
604#ifdef UNIV_DEBUG
605/**********************************************************/
608UNIV_INLINE
609byte*
610rec_get_start(
611/*==========*/
612 const rec_t* rec,
613 const ulint* offsets);
614/**********************************************************/
617UNIV_INLINE
618byte*
619rec_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/***************************************************************/
630UNIV_INLINE
631rec_t*
633/*=====*/
634 void* buf,
635 const rec_t* rec,
636 const ulint* offsets);
637#ifndef UNIV_HOTBACKUP
638/**************************************************************/
642UNIV_INTERN
643rec_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/************************************************************/
657UNIV_INLINE
658ulint
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/*********************************************************/
673UNIV_INTERN
674void
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/*********************************************************/
690UNIV_INTERN
691rec_t*
693/*======================*/
694 byte* buf,
696 const dict_index_t* index,
697 const dtuple_t* dtuple,
698 ulint n_ext);
700/**********************************************************/
704UNIV_INLINE
705ulint
707/*=========================*/
708 ulint data_size,
709 ulint n_fields,
710 ulint n_ext)
711 __attribute__((const));
712/**********************************************************/
715UNIV_INTERN
716ulint
718/*===============================*/
719 const dict_index_t* index,
723 const dfield_t* fields,
724 ulint n_fields,
725 ulint* extra);
726/**********************************************************/
729UNIV_INTERN
730ulint
732/*========================*/
733 const dict_index_t* index,
737 ulint status,
738 const dfield_t* fields,
739 ulint n_fields,
740 ulint* extra);
741/**********************************************************/
745UNIV_INLINE
746ulint
748/*===================*/
749 dict_index_t* index,
750 const dtuple_t* dtuple,
751 ulint n_ext);
752#ifndef UNIV_HOTBACKUP
753/**************************************************************/
756UNIV_INTERN
757void
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/***************************************************************/
770UNIV_INTERN
771ibool
773/*=========*/
774 const rec_t* rec,
775 const ulint* offsets);
776/***************************************************************/
778UNIV_INTERN
779void
781/*==========*/
782 FILE* file,
783 const rec_t* rec);
784#ifndef UNIV_HOTBACKUP
785/***************************************************************/
788UNIV_INTERN
789void
791/*===========*/
792 FILE* file,
793 const rec_t* rec,
794 const ulint* offsets);
795/***************************************************************/
797UNIV_INTERN
798void
800/*==========*/
801 FILE* file,
802 const rec_t* rec,
803 const ulint* offsets);
804/***************************************************************/
806UNIV_INTERN
807void
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
818are 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
823two 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
struct page_zip_des_struct page_zip_des_t
Definition page0types.h:44
UNIV_INLINE ulint rec_offs_extra_size(const ulint *offsets)
UNIV_INLINE ulint rec_get_heap_no_old(const rec_t *rec)
UNIV_INLINE ulint rec_offs_comp(const ulint *offsets)
UNIV_INLINE ulint rec_get_n_fields(const rec_t *rec, const dict_index_t *index)
UNIV_INLINE void rec_set_next_offs_old(rec_t *rec, ulint next)
UNIV_INLINE ulint rec_get_converted_extra_size(ulint data_size, ulint n_fields, ulint n_ext) __attribute__((const))
UNIV_INLINE ulint rec_offs_n_extern(const ulint *offsets)
UNIV_INTERN ulint * rec_get_offsets_func(const rec_t *rec, const dict_index_t *index, ulint *offsets, ulint n_fields, mem_heap_t **heap, const char *file, ulint line)
Definition rem0rec.cc:524
UNIV_INLINE ulint rec_get_nth_field_size(const rec_t *rec, ulint n)
UNIV_INTERN ulint rec_get_nth_field_offs_old(const rec_t *rec, ulint n, ulint *len)
Definition rem0rec.cc:718
UNIV_INLINE void rec_set_heap_no_old(rec_t *rec, ulint heap_no)
UNIV_INLINE ulint rec_fold(const rec_t *rec, const ulint *offsets, ulint n_fields, ulint n_bytes, index_id_t tree_id) __attribute__((pure))
UNIV_INLINE void rec_offs_set_n_alloc(ulint *offsets, ulint n_alloc)
UNIV_INTERN rec_t * rec_copy_prefix_to_buf(const rec_t *rec, const dict_index_t *index, ulint n_fields, byte **buf, ulint *buf_size)
Definition rem0rec.cc:1383
UNIV_INTERN void rec_init_offsets_comp_ordinary(const rec_t *rec, ulint extra, const dict_index_t *index, ulint *offsets)
Definition rem0rec.cc:244
UNIV_INLINE void rec_set_n_owned_new(rec_t *rec, page_zip_des_t *page_zip, ulint n_owned)
UNIV_INTERN void rec_print_new(FILE *file, const rec_t *rec, const ulint *offsets)
Definition rem0rec.cc:1722
UNIV_INLINE ulint rec_offs_size(const ulint *offsets)
UNIV_INLINE rec_t * rec_copy(void *buf, const rec_t *rec, const ulint *offsets)
UNIV_INTERN ulint rec_get_n_extern_new(const rec_t *rec, dict_index_t *index, ulint n)
Definition rem0rec.cc:162
UNIV_INTERN void rec_convert_dtuple_to_rec_comp(rec_t *rec, ulint extra, const dict_index_t *index, ulint status, const dfield_t *fields, ulint n_fields)
Definition rem0rec.cc:1073
UNIV_INLINE void rec_set_heap_no_new(rec_t *rec, ulint heap_no)
UNIV_INLINE rec_t * rec_get_next_ptr(rec_t *rec, ulint comp)
UNIV_INTERN void rec_print_comp(FILE *file, const rec_t *rec, const ulint *offsets)
Definition rem0rec.cc:1684
UNIV_INTERN ulint rec_get_converted_size_comp_prefix(const dict_index_t *index, const dfield_t *fields, ulint n_fields, ulint *extra)
Definition rem0rec.cc:771
UNIV_INLINE ulint rec_get_converted_size(dict_index_t *index, const dtuple_t *dtuple, ulint n_ext)
UNIV_INLINE void rec_set_deleted_flag_old(rec_t *rec, ulint flag)
UNIV_INLINE ulint rec_offs_get_n_alloc(const ulint *offsets)
UNIV_INTERN ulint rec_get_converted_size_comp(const dict_index_t *index, ulint status, const dfield_t *fields, ulint n_fields, ulint *extra)
Definition rem0rec.cc:854
UNIV_INLINE void rec_set_status(rec_t *rec, ulint bits)
UNIV_INLINE ulint rec_offs_n_fields(const ulint *offsets)
UNIV_INLINE ulint rec_get_info_bits(const rec_t *rec, ulint comp)
UNIV_INLINE ulint rec_get_data_size_old(const rec_t *rec)
UNIV_INLINE ulint rec_get_info_and_status_bits(const rec_t *rec, ulint comp)
UNIV_INLINE ulint rec_get_nth_field_offs(const ulint *offsets, ulint n, ulint *len)
UNIV_INLINE void rec_set_info_bits_old(rec_t *rec, ulint bits)
UNIV_INLINE void rec_set_nth_field(rec_t *rec, const ulint *offsets, ulint n, const void *data, ulint len)
UNIV_INLINE void rec_set_n_owned_old(rec_t *rec, ulint n_owned)
UNIV_INLINE ibool rec_get_node_ptr_flag(const rec_t *rec)
UNIV_INLINE ibool rec_get_1byte_offs_flag(const rec_t *rec)
UNIV_INTERN void rec_copy_prefix_to_dtuple(dtuple_t *tuple, const rec_t *rec, const dict_index_t *index, ulint n_fields, mem_heap_t *heap)
Definition rem0rec.cc:1293
UNIV_INLINE ulint rec_get_n_fields_old(const rec_t *rec)
UNIV_INLINE ulint rec_get_heap_no_new(const rec_t *rec)
UNIV_INLINE void rec_set_next_offs_new(rec_t *rec, ulint next)
UNIV_INTERN ibool rec_validate(const rec_t *rec, const ulint *offsets)
Definition rem0rec.cc:1564
UNIV_INLINE ulint rec_get_n_owned_new(const rec_t *rec)
UNIV_INLINE ulint rec_get_status(const rec_t *rec)
UNIV_INLINE ulint rec_offs_data_size(const ulint *offsets)
UNIV_INTERN void rec_get_offsets_reverse(const byte *extra, const dict_index_t *index, ulint node_ptr, ulint *offsets)
Definition rem0rec.cc:595
UNIV_INLINE ulint rec_offs_nth_extern(const ulint *offsets, ulint n)
UNIV_INTERN void rec_print(FILE *file, const rec_t *rec, const dict_index_t *index)
Definition rem0rec.cc:1750
UNIV_INTERN rec_t * rec_convert_dtuple_to_rec(byte *buf, const dict_index_t *index, const dtuple_t *dtuple, ulint n_ext)
Definition rem0rec.cc:1240
UNIV_INLINE ulint rec_get_next_offs(const rec_t *rec, ulint comp)
UNIV_INLINE void rec_set_info_and_status_bits(rec_t *rec, ulint bits)
UNIV_INLINE ulint rec_offs_any_extern(const ulint *offsets)
UNIV_INLINE ulint rec_offs_nth_sql_null(const ulint *offsets, ulint n)
UNIV_INTERN void rec_print_old(FILE *file, const rec_t *rec)
Definition rem0rec.cc:1630
UNIV_INLINE const rec_t * rec_get_next_ptr_const(const rec_t *rec, ulint comp)
UNIV_INLINE void rec_set_info_bits_new(rec_t *rec, ulint bits)
UNIV_INLINE ulint rec_offs_nth_size(const ulint *offsets, ulint n)
UNIV_INLINE void rec_set_deleted_flag_new(rec_t *rec, page_zip_des_t *page_zip, ulint flag)
UNIV_INLINE ulint rec_get_n_owned_old(const rec_t *rec)
UNIV_INLINE ulint rec_get_deleted_flag(const rec_t *rec, ulint comp)
UNIV_INLINE ibool rec_offs_validate(const rec_t *rec, const dict_index_t *index, const ulint *offsets)