Drizzled Public API Documentation

rem0rec.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /********************************************************************/
00026 #pragma once
00027 #ifndef rem0rec_h
00028 #define rem0rec_h
00029 
00030 #include "univ.i"
00031 #include "data0data.h"
00032 #include "rem0types.h"
00033 #include "mtr0types.h"
00034 #include "page0types.h"
00035 
00036 /* Info bit denoting the predefined minimum record: this bit is set
00037 if and only if the record is the first user record on a non-leaf
00038 B-tree page that is the leftmost page on its level
00039 (PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
00040 #define REC_INFO_MIN_REC_FLAG 0x10UL
00041 /* The deleted flag in info bits */
00042 #define REC_INFO_DELETED_FLAG 0x20UL  /* when bit is set to 1, it means the
00043           record has been delete marked */
00044 
00045 /* Number of extra bytes in an old-style record,
00046 in addition to the data and the offsets */
00047 #define REC_N_OLD_EXTRA_BYTES 6
00048 /* Number of extra bytes in a new-style record,
00049 in addition to the data and the offsets */
00050 #define REC_N_NEW_EXTRA_BYTES 5
00051 
00052 /* Record status values */
00053 #define REC_STATUS_ORDINARY 0
00054 #define REC_STATUS_NODE_PTR 1
00055 #define REC_STATUS_INFIMUM  2
00056 #define REC_STATUS_SUPREMUM 3
00057 
00058 /* The following four constants are needed in page0zip.c in order to
00059 efficiently compress and decompress pages. */
00060 
00061 /* The offset of heap_no in a compact record */
00062 #define REC_NEW_HEAP_NO   4
00063 /* The shift of heap_no in a compact record.
00064 The status is stored in the low-order bits. */
00065 #define REC_HEAP_NO_SHIFT 3
00066 
00067 /* Length of a B-tree node pointer, in bytes */
00068 #define REC_NODE_PTR_SIZE 4
00069 
00070 #ifdef UNIV_DEBUG
00071 /* Length of the rec_get_offsets() header */
00072 # define REC_OFFS_HEADER_SIZE 4
00073 #else /* UNIV_DEBUG */
00074 /* Length of the rec_get_offsets() header */
00075 # define REC_OFFS_HEADER_SIZE 2
00076 #endif /* UNIV_DEBUG */
00077 
00078 /* Number of elements that should be initially allocated for the
00079 offsets[] array, first passed to rec_get_offsets() */
00080 #define REC_OFFS_NORMAL_SIZE  100
00081 #define REC_OFFS_SMALL_SIZE 10
00082 
00083 /******************************************************/
00087 UNIV_INLINE
00088 const rec_t*
00089 rec_get_next_ptr_const(
00090 /*===================*/
00091   const rec_t*  rec,  
00092   ulint   comp);  
00093 /******************************************************/
00097 UNIV_INLINE
00098 rec_t*
00099 rec_get_next_ptr(
00100 /*=============*/
00101   rec_t*  rec,  
00102   ulint comp);  
00103 /******************************************************/
00107 UNIV_INLINE
00108 ulint
00109 rec_get_next_offs(
00110 /*==============*/
00111   const rec_t*  rec,  
00112   ulint   comp);  
00113 /******************************************************/
00116 UNIV_INLINE
00117 void
00118 rec_set_next_offs_old(
00119 /*==================*/
00120   rec_t*  rec,  
00121   ulint next);  
00122 /******************************************************/
00125 UNIV_INLINE
00126 void
00127 rec_set_next_offs_new(
00128 /*==================*/
00129   rec_t*  rec,  
00130   ulint next);  
00131 /******************************************************/
00135 UNIV_INLINE
00136 ulint
00137 rec_get_n_fields_old(
00138 /*=================*/
00139   const rec_t*  rec); 
00140 /******************************************************/
00144 UNIV_INLINE
00145 ulint
00146 rec_get_n_fields(
00147 /*=============*/
00148   const rec_t*    rec,  
00149   const dict_index_t* index); 
00150 /******************************************************/
00154 UNIV_INLINE
00155 ulint
00156 rec_get_n_owned_old(
00157 /*================*/
00158   const rec_t*  rec); 
00159 /******************************************************/
00161 UNIV_INLINE
00162 void
00163 rec_set_n_owned_old(
00164 /*================*/
00165   rec_t*  rec,    
00166   ulint n_owned); 
00167 /******************************************************/
00171 UNIV_INLINE
00172 ulint
00173 rec_get_n_owned_new(
00174 /*================*/
00175   const rec_t*  rec); 
00176 /******************************************************/
00178 UNIV_INLINE
00179 void
00180 rec_set_n_owned_new(
00181 /*================*/
00182   rec_t*    rec,  
00183   page_zip_des_t* page_zip,
00184   ulint   n_owned);
00185 /******************************************************/
00189 UNIV_INLINE
00190 ulint
00191 rec_get_info_bits(
00192 /*==============*/
00193   const rec_t*  rec,  
00194   ulint   comp);  
00195 /******************************************************/
00197 UNIV_INLINE
00198 void
00199 rec_set_info_bits_old(
00200 /*==================*/
00201   rec_t*  rec,  
00202   ulint bits);  
00203 /******************************************************/
00205 UNIV_INLINE
00206 void
00207 rec_set_info_bits_new(
00208 /*==================*/
00209   rec_t*  rec,  
00210   ulint bits);  
00211 /******************************************************/
00214 UNIV_INLINE
00215 ulint
00216 rec_get_status(
00217 /*===========*/
00218   const rec_t*  rec); 
00220 /******************************************************/
00222 UNIV_INLINE
00223 void
00224 rec_set_status(
00225 /*===========*/
00226   rec_t*  rec,  
00227   ulint bits);  
00229 /******************************************************/
00233 UNIV_INLINE
00234 ulint
00235 rec_get_info_and_status_bits(
00236 /*=========================*/
00237   const rec_t*  rec,  
00238   ulint   comp);  
00239 /******************************************************/
00242 UNIV_INLINE
00243 void
00244 rec_set_info_and_status_bits(
00245 /*=========================*/
00246   rec_t*  rec,  
00247   ulint bits);  
00249 /******************************************************/
00252 UNIV_INLINE
00253 ulint
00254 rec_get_deleted_flag(
00255 /*=================*/
00256   const rec_t*  rec,  
00257   ulint   comp);  
00258 /******************************************************/
00260 UNIV_INLINE
00261 void
00262 rec_set_deleted_flag_old(
00263 /*=====================*/
00264   rec_t*  rec,  
00265   ulint flag);  
00266 /******************************************************/
00268 UNIV_INLINE
00269 void
00270 rec_set_deleted_flag_new(
00271 /*=====================*/
00272   rec_t*    rec,  
00273   page_zip_des_t* page_zip,
00274   ulint   flag);  
00275 /******************************************************/
00278 UNIV_INLINE
00279 ibool
00280 rec_get_node_ptr_flag(
00281 /*==================*/
00282   const rec_t*  rec); 
00283 /******************************************************/
00287 UNIV_INLINE
00288 ulint
00289 rec_get_heap_no_old(
00290 /*================*/
00291   const rec_t*  rec); 
00292 /******************************************************/
00295 UNIV_INLINE
00296 void
00297 rec_set_heap_no_old(
00298 /*================*/
00299   rec_t*  rec,  
00300   ulint heap_no);
00301 /******************************************************/
00305 UNIV_INLINE
00306 ulint
00307 rec_get_heap_no_new(
00308 /*================*/
00309   const rec_t*  rec); 
00310 /******************************************************/
00313 UNIV_INLINE
00314 void
00315 rec_set_heap_no_new(
00316 /*================*/
00317   rec_t*  rec,  
00318   ulint heap_no);
00319 /******************************************************/
00323 UNIV_INLINE
00324 ibool
00325 rec_get_1byte_offs_flag(
00326 /*====================*/
00327   const rec_t*  rec); 
00329 /******************************************************/
00333 UNIV_INTERN
00334 ulint
00335 rec_get_n_extern_new(
00336 /*=================*/
00337   const rec_t*  rec,  
00338   dict_index_t* index,  
00339   ulint   n); 
00341 /******************************************************/
00345 UNIV_INTERN
00346 ulint*
00347 rec_get_offsets_func(
00348 /*=================*/
00349   const rec_t*    rec,  
00350   const dict_index_t* index,  
00351   ulint*      offsets,
00355   ulint     n_fields,
00358   mem_heap_t**    heap, 
00359   const char*   file, 
00360   ulint     line);  
00362 #define rec_get_offsets(rec,index,offsets,n,heap) \
00363   rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
00364 
00365 /******************************************************/
00369 UNIV_INTERN
00370 void
00371 rec_init_offsets_comp_ordinary(
00372 /*===========================*/
00373   const rec_t*    rec,  
00375   ulint     extra,  
00379   const dict_index_t* index,  
00380   ulint*      offsets);
00383 /******************************************************/
00386 UNIV_INTERN
00387 void
00388 rec_get_offsets_reverse(
00389 /*====================*/
00390   const byte*   extra,  
00394   const dict_index_t* index,  
00395   ulint     node_ptr,
00397   ulint*      offsets);
00400 /************************************************************/
00403 UNIV_INLINE
00404 ibool
00405 rec_offs_validate(
00406 /*==============*/
00407   const rec_t*    rec,  
00408   const dict_index_t* index,  
00409   const ulint*    offsets);
00411 #ifdef UNIV_DEBUG
00412 /************************************************************/
00415 UNIV_INLINE
00416 void
00417 rec_offs_make_valid(
00418 /*================*/
00419   const rec_t*    rec,  
00420   const dict_index_t* index,  
00421   ulint*      offsets);
00423 #else
00424 # define rec_offs_make_valid(rec, index, offsets) ((void) 0)
00425 #endif /* UNIV_DEBUG */
00426 
00427 /************************************************************/
00431 UNIV_INTERN
00432 ulint
00433 rec_get_nth_field_offs_old(
00434 /*=======================*/
00435   const rec_t*  rec,  
00436   ulint   n,  
00437   ulint*    len); 
00439 #define rec_get_nth_field_old(rec, n, len) \
00440 ((rec) + rec_get_nth_field_offs_old(rec, n, len))
00441 /************************************************************/
00446 UNIV_INLINE
00447 ulint
00448 rec_get_nth_field_size(
00449 /*===================*/
00450   const rec_t*  rec,  
00451   ulint   n); 
00452 /************************************************************/
00456 UNIV_INLINE
00457 ulint
00458 rec_get_nth_field_offs(
00459 /*===================*/
00460   const ulint*  offsets,
00461   ulint   n,  
00462   ulint*    len); 
00464 #define rec_get_nth_field(rec, offsets, n, len) \
00465 ((rec) + rec_get_nth_field_offs(offsets, n, len))
00466 /******************************************************/
00470 UNIV_INLINE
00471 ulint
00472 rec_offs_comp(
00473 /*==========*/
00474   const ulint*  offsets);
00475 /******************************************************/
00479 UNIV_INLINE
00480 ulint
00481 rec_offs_any_extern(
00482 /*================*/
00483   const ulint*  offsets);
00484 /******************************************************/
00487 UNIV_INLINE
00488 ulint
00489 rec_offs_nth_extern(
00490 /*================*/
00491   const ulint*  offsets,
00492   ulint   n); 
00493 /******************************************************/
00496 UNIV_INLINE
00497 ulint
00498 rec_offs_nth_sql_null(
00499 /*==================*/
00500   const ulint*  offsets,
00501   ulint   n); 
00502 /******************************************************/
00505 UNIV_INLINE
00506 ulint
00507 rec_offs_nth_size(
00508 /*==============*/
00509   const ulint*  offsets,
00510   ulint   n); 
00512 /******************************************************/
00515 UNIV_INLINE
00516 ulint
00517 rec_offs_n_extern(
00518 /*==============*/
00519   const ulint*  offsets);
00520 /***********************************************************/
00526 UNIV_INLINE
00527 void
00528 rec_set_nth_field(
00529 /*==============*/
00530   rec_t*    rec,  
00531   const ulint*  offsets,
00532   ulint   n,  
00533   const void* data, 
00534   ulint   len); 
00535 /**********************************************************/
00541 UNIV_INLINE
00542 ulint
00543 rec_get_data_size_old(
00544 /*==================*/
00545   const rec_t*  rec); 
00546 /**********************************************************/
00550 UNIV_INLINE
00551 ulint
00552 rec_offs_get_n_alloc(
00553 /*=================*/
00554   const ulint*  offsets);
00555 /**********************************************************/
00558 UNIV_INLINE
00559 void
00560 rec_offs_set_n_alloc(
00561 /*=================*/
00562   ulint*  offsets,  
00564   ulint n_alloc); 
00565 #define rec_offs_init(offsets) \
00566   rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)
00567 /**********************************************************/
00570 UNIV_INLINE
00571 ulint
00572 rec_offs_n_fields(
00573 /*==============*/
00574   const ulint*  offsets);
00575 /**********************************************************/
00581 UNIV_INLINE
00582 ulint
00583 rec_offs_data_size(
00584 /*===============*/
00585   const ulint*  offsets);
00586 /**********************************************************/
00591 UNIV_INLINE
00592 ulint
00593 rec_offs_extra_size(
00594 /*================*/
00595   const ulint*  offsets);
00596 /**********************************************************/
00599 UNIV_INLINE
00600 ulint
00601 rec_offs_size(
00602 /*==========*/
00603   const ulint*  offsets);
00604 /**********************************************************/
00607 UNIV_INLINE
00608 byte*
00609 rec_get_start(
00610 /*==========*/
00611   rec_t*    rec,  
00612   const ulint*  offsets);
00613 /**********************************************************/
00616 UNIV_INLINE
00617 byte*
00618 rec_get_end(
00619 /*========*/
00620   rec_t*    rec,  
00621   const ulint*  offsets);
00622 /***************************************************************/
00625 UNIV_INLINE
00626 rec_t*
00627 rec_copy(
00628 /*=====*/
00629   void*   buf,  
00630   const rec_t*  rec,  
00631   const ulint*  offsets);
00632 #ifndef UNIV_HOTBACKUP
00633 /**************************************************************/
00637 UNIV_INTERN
00638 rec_t*
00639 rec_copy_prefix_to_buf(
00640 /*===================*/
00641   const rec_t*    rec,    
00642   const dict_index_t* index,    
00643   ulint     n_fields, 
00645   byte**      buf,    
00648   ulint*      buf_size);  
00649 /************************************************************/
00652 UNIV_INLINE
00653 ulint
00654 rec_fold(
00655 /*=====*/
00656   const rec_t*  rec,    
00657   const ulint*  offsets,  
00659   ulint   n_fields, 
00661   ulint   n_bytes,  
00663   index_id_t  tree_id)  
00664   __attribute__((pure));
00665 #endif /* !UNIV_HOTBACKUP */
00666 /*********************************************************/
00668 UNIV_INTERN
00669 void
00670 rec_convert_dtuple_to_rec_comp(
00671 /*===========================*/
00672   rec_t*      rec,  
00673   ulint     extra,  
00677   const dict_index_t* index,  
00678   ulint     status, 
00679   const dfield_t*   fields, 
00680   ulint     n_fields);
00681 /*********************************************************/
00685 UNIV_INTERN
00686 rec_t*
00687 rec_convert_dtuple_to_rec(
00688 /*======================*/
00689   byte*     buf,  
00691   const dict_index_t* index,  
00692   const dtuple_t*   dtuple, 
00693   ulint     n_ext); 
00695 /**********************************************************/
00699 UNIV_INLINE
00700 ulint
00701 rec_get_converted_extra_size(
00702 /*=========================*/
00703   ulint data_size,  
00704   ulint n_fields, 
00705   ulint n_ext)    
00706     __attribute__((const));
00707 /**********************************************************/
00710 UNIV_INTERN
00711 ulint
00712 rec_get_converted_size_comp_prefix(
00713 /*===============================*/
00714   const dict_index_t* index,  
00718   const dfield_t*   fields, 
00719   ulint     n_fields,
00720   ulint*      extra); 
00721 /**********************************************************/
00724 UNIV_INTERN
00725 ulint
00726 rec_get_converted_size_comp(
00727 /*========================*/
00728   const dict_index_t* index,  
00732   ulint     status, 
00733   const dfield_t*   fields, 
00734   ulint     n_fields,
00735   ulint*      extra); 
00736 /**********************************************************/
00740 UNIV_INLINE
00741 ulint
00742 rec_get_converted_size(
00743 /*===================*/
00744   dict_index_t* index,  
00745   const dtuple_t* dtuple, 
00746   ulint   n_ext); 
00747 #ifndef UNIV_HOTBACKUP
00748 /**************************************************************/
00751 UNIV_INTERN
00752 void
00753 rec_copy_prefix_to_dtuple(
00754 /*======================*/
00755   dtuple_t*   tuple,    
00756   const rec_t*    rec,    
00757   const dict_index_t* index,    
00758   ulint     n_fields, 
00760   mem_heap_t*   heap);    
00761 #endif /* !UNIV_HOTBACKUP */
00762 /***************************************************************/
00765 UNIV_INTERN
00766 ibool
00767 rec_validate(
00768 /*=========*/
00769   const rec_t*  rec,  
00770   const ulint*  offsets);
00771 /***************************************************************/
00773 UNIV_INTERN
00774 void
00775 rec_print_old(
00776 /*==========*/
00777   FILE*   file, 
00778   const rec_t*  rec); 
00779 #ifndef UNIV_HOTBACKUP
00780 /***************************************************************/
00783 UNIV_INTERN
00784 void
00785 rec_print_comp(
00786 /*===========*/
00787   FILE*   file, 
00788   const rec_t*  rec,  
00789   const ulint*  offsets);
00790 /***************************************************************/
00792 UNIV_INTERN
00793 void
00794 rec_print_new(
00795 /*==========*/
00796   FILE*   file, 
00797   const rec_t*  rec,  
00798   const ulint*  offsets);
00799 /***************************************************************/
00801 UNIV_INTERN
00802 void
00803 rec_print(
00804 /*======*/
00805   FILE*     file, 
00806   const rec_t*    rec,  
00807   const dict_index_t* index); 
00808 #endif /* UNIV_HOTBACKUP */
00809 
00810 #define REC_INFO_BITS   6 /* This is single byte bit-field */
00811 
00812 /* Maximum lengths for the data in a physical record if the offsets
00813 are given in one byte (resp. two byte) format. */
00814 #define REC_1BYTE_OFFS_LIMIT  0x7FUL
00815 #define REC_2BYTE_OFFS_LIMIT  0x7FFFUL
00816 
00817 /* The data size of record must be smaller than this because we reserve
00818 two upmost bits in a two byte offset for special purposes */
00819 #define REC_MAX_DATA_SIZE (16 * 1024)
00820 
00821 #ifndef UNIV_NONINL
00822 #include "rem0rec.ic"
00823 #endif
00824 
00825 #endif