00001 /****************************************************** 00002 General row routines 00003 00004 (c) 1996 Innobase Oy 00005 00006 Created 4/20/1996 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef row0row_h 00010 #define row0row_h 00011 00012 #include "univ.i" 00013 #include "data0data.h" 00014 #include "dict0types.h" 00015 #include "trx0types.h" 00016 #include "que0types.h" 00017 #include "mtr0mtr.h" 00018 #include "rem0types.h" 00019 #include "read0types.h" 00020 #include "btr0types.h" 00021 00022 /************************************************************************* 00023 Reads the trx id field from a clustered index record. */ 00024 UNIV_INLINE 00025 dulint 00026 row_get_rec_trx_id( 00027 /*===============*/ 00028 /* out: value of the field */ 00029 rec_t* rec, /* in: record */ 00030 dict_index_t* index, /* in: clustered index */ 00031 const ulint* offsets);/* in: rec_get_offsets(rec, index) */ 00032 /************************************************************************* 00033 Reads the roll pointer field from a clustered index record. */ 00034 UNIV_INLINE 00035 dulint 00036 row_get_rec_roll_ptr( 00037 /*=================*/ 00038 /* out: value of the field */ 00039 rec_t* rec, /* in: record */ 00040 dict_index_t* index, /* in: clustered index */ 00041 const ulint* offsets);/* in: rec_get_offsets(rec, index) */ 00042 /************************************************************************* 00043 Writes the trx id field to a clustered index record. */ 00044 UNIV_INLINE 00045 void 00046 row_set_rec_trx_id( 00047 /*===============*/ 00048 rec_t* rec, /* in: record */ 00049 dict_index_t* index, /* in: clustered index */ 00050 const ulint* offsets,/* in: rec_get_offsets(rec, index) */ 00051 dulint trx_id);/* in: value of the field */ 00052 /************************************************************************* 00053 Sets the roll pointer field in a clustered index record. */ 00054 UNIV_INLINE 00055 void 00056 row_set_rec_roll_ptr( 00057 /*=================*/ 00058 rec_t* rec, /* in: record */ 00059 dict_index_t* index, /* in: clustered index */ 00060 const ulint* offsets,/* in: rec_get_offsets(rec, index) */ 00061 dulint roll_ptr);/* in: value of the field */ 00062 /********************************************************************* 00063 When an insert to a table is performed, this function builds the entry which 00064 has to be inserted to an index on the table. */ 00065 00066 dtuple_t* 00067 row_build_index_entry( 00068 /*==================*/ 00069 /* out: index entry which should be inserted */ 00070 dtuple_t* row, /* in: row which should be inserted to the 00071 table */ 00072 dict_index_t* index, /* in: index on the table */ 00073 mem_heap_t* heap); /* in: memory heap from which the memory for 00074 the index entry is allocated */ 00075 /*********************************************************************** 00076 An inverse function to dict_row_build_index_entry. Builds a row from a 00077 record in a clustered index. */ 00078 00079 dtuple_t* 00080 row_build( 00081 /*======*/ 00082 /* out, own: row built; see the NOTE below! */ 00083 ulint type, /* in: ROW_COPY_POINTERS, ROW_COPY_DATA, or 00084 ROW_COPY_ALSO_EXTERNALS, 00085 the two last copy also the data fields to 00086 heap as the first only places pointers to 00087 data fields on the index page, and thus is 00088 more efficient */ 00089 dict_index_t* index, /* in: clustered index */ 00090 rec_t* rec, /* in: record in the clustered index; 00091 NOTE: in the case ROW_COPY_POINTERS 00092 the data fields in the row will point 00093 directly into this record, therefore, 00094 the buffer page of this record must be 00095 at least s-latched and the latch held 00096 as long as the row dtuple is used! */ 00097 const ulint* offsets,/* in: rec_get_offsets(rec, index) 00098 or NULL, in which case this function 00099 will invoke rec_get_offsets() */ 00100 mem_heap_t* heap); /* in: memory heap from which the memory 00101 needed is allocated */ 00102 /*********************************************************************** 00103 Converts an index record to a typed data tuple. */ 00104 00105 dtuple_t* 00106 row_rec_to_index_entry( 00107 /*===================*/ 00108 /* out, own: index entry built; see the 00109 NOTE below! */ 00110 ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS: 00111 the former copies also the data fields to 00112 heap as the latter only places pointers to 00113 data fields on the index page */ 00114 dict_index_t* index, /* in: index */ 00115 rec_t* rec, /* in: record in the index; 00116 NOTE: in the case ROW_COPY_POINTERS 00117 the data fields in the row will point 00118 directly into this record, therefore, 00119 the buffer page of this record must be 00120 at least s-latched and the latch held 00121 as long as the dtuple is used! */ 00122 mem_heap_t* heap); /* in: memory heap from which the memory 00123 needed is allocated */ 00124 /*********************************************************************** 00125 Builds from a secondary index record a row reference with which we can 00126 search the clustered index record. */ 00127 00128 dtuple_t* 00129 row_build_row_ref( 00130 /*==============*/ 00131 /* out, own: row reference built; see the 00132 NOTE below! */ 00133 ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS: 00134 the former copies also the data fields to 00135 heap, whereas the latter only places pointers 00136 to data fields on the index page */ 00137 dict_index_t* index, /* in: index */ 00138 rec_t* rec, /* in: record in the index; 00139 NOTE: in the case ROW_COPY_POINTERS 00140 the data fields in the row will point 00141 directly into this record, therefore, 00142 the buffer page of this record must be 00143 at least s-latched and the latch held 00144 as long as the row reference is used! */ 00145 mem_heap_t* heap); /* in: memory heap from which the memory 00146 needed is allocated */ 00147 /*********************************************************************** 00148 Builds from a secondary index record a row reference with which we can 00149 search the clustered index record. */ 00150 00151 void 00152 row_build_row_ref_in_tuple( 00153 /*=======================*/ 00154 dtuple_t* ref, /* in/out: row reference built; see the 00155 NOTE below! */ 00156 dict_index_t* index, /* in: index */ 00157 rec_t* rec, /* in: record in the index; 00158 NOTE: the data fields in ref will point 00159 directly into this record, therefore, 00160 the buffer page of this record must be 00161 at least s-latched and the latch held 00162 as long as the row reference is used! */ 00163 trx_t* trx); /* in: transaction */ 00164 /*********************************************************************** 00165 From a row build a row reference with which we can search the clustered 00166 index record. */ 00167 00168 void 00169 row_build_row_ref_from_row( 00170 /*=======================*/ 00171 dtuple_t* ref, /* in/out: row reference built; see the 00172 NOTE below! ref must have the right number 00173 of fields! */ 00174 dict_table_t* table, /* in: table */ 00175 dtuple_t* row); /* in: row 00176 NOTE: the data fields in ref will point 00177 directly into data of this row */ 00178 /*********************************************************************** 00179 Builds from a secondary index record a row reference with which we can 00180 search the clustered index record. */ 00181 UNIV_INLINE 00182 void 00183 row_build_row_ref_fast( 00184 /*===================*/ 00185 dtuple_t* ref, /* in: typed data tuple where the 00186 reference is built */ 00187 const ulint* map, /* in: array of field numbers in rec 00188 telling how ref should be built from 00189 the fields of rec */ 00190 rec_t* rec, /* in: record in the index; must be 00191 preserved while ref is used, as we do 00192 not copy field values to heap */ 00193 const ulint* offsets);/* in: array returned by rec_get_offsets() */ 00194 /******************************************************************* 00195 Searches the clustered index record for a row, if we have the row 00196 reference. */ 00197 00198 ibool 00199 row_search_on_row_ref( 00200 /*==================*/ 00201 /* out: TRUE if found */ 00202 btr_pcur_t* pcur, /* in/out: persistent cursor, which must 00203 be closed by the caller */ 00204 ulint mode, /* in: BTR_MODIFY_LEAF, ... */ 00205 dict_table_t* table, /* in: table */ 00206 dtuple_t* ref, /* in: row reference */ 00207 mtr_t* mtr); /* in: mtr */ 00208 /************************************************************************* 00209 Fetches the clustered index record for a secondary index record. The latches 00210 on the secondary index record are preserved. */ 00211 00212 rec_t* 00213 row_get_clust_rec( 00214 /*==============*/ 00215 /* out: record or NULL, if no record found */ 00216 ulint mode, /* in: BTR_MODIFY_LEAF, ... */ 00217 rec_t* rec, /* in: record in a secondary index */ 00218 dict_index_t* index, /* in: secondary index */ 00219 dict_index_t** clust_index,/* out: clustered index */ 00220 mtr_t* mtr); /* in: mtr */ 00221 /******************************************************************* 00222 Searches an index record. */ 00223 00224 ibool 00225 row_search_index_entry( 00226 /*===================*/ 00227 /* out: TRUE if found */ 00228 dict_index_t* index, /* in: index */ 00229 dtuple_t* entry, /* in: index entry */ 00230 ulint mode, /* in: BTR_MODIFY_LEAF, ... */ 00231 btr_pcur_t* pcur, /* in/out: persistent cursor, which must 00232 be closed by the caller */ 00233 mtr_t* mtr); /* in: mtr */ 00234 00235 00236 #define ROW_COPY_DATA 1 00237 #define ROW_COPY_POINTERS 2 00238 #define ROW_COPY_ALSO_EXTERNALS 3 00239 00240 /* The allowed latching order of index records is the following: 00241 (1) a secondary index record -> 00242 (2) the clustered index record -> 00243 (3) rollback segment data for the clustered index record. 00244 00245 No new latches may be obtained while the kernel mutex is reserved. 00246 However, the kernel mutex can be reserved while latches are owned. */ 00247 00248 #ifndef UNIV_NONINL 00249 #include "row0row.ic" 00250 #endif 00251 00252 #endif
1.4.7

