00001 /************************************************************************ 00002 The page cursor 00003 00004 (c) 1994-1996 Innobase Oy 00005 00006 Created 10/4/1994 Heikki Tuuri 00007 *************************************************************************/ 00008 00009 #ifndef page0cur_h 00010 #define page0cur_h 00011 00012 #include "univ.i" 00013 00014 #include "page0types.h" 00015 #include "page0page.h" 00016 #include "rem0rec.h" 00017 #include "data0data.h" 00018 #include "mtr0mtr.h" 00019 00020 00021 #define PAGE_CUR_ADAPT 00022 00023 /* Page cursor search modes; the values must be in this order! */ 00024 00025 #define PAGE_CUR_G 1 00026 #define PAGE_CUR_GE 2 00027 #define PAGE_CUR_L 3 00028 #define PAGE_CUR_LE 4 00029 /*#define PAGE_CUR_LE_OR_EXTENDS 5*/ /* This is a search mode used in 00030 "column LIKE 'abc%' ORDER BY column DESC"; 00031 we have to find strings which are <= 'abc' or 00032 which extend it */ 00033 #ifdef UNIV_SEARCH_DEBUG 00034 # define PAGE_CUR_DBG 6 /* As PAGE_CUR_LE, but skips search shortcut */ 00035 #endif /* UNIV_SEARCH_DEBUG */ 00036 00037 #ifdef PAGE_CUR_ADAPT 00038 # ifdef UNIV_SEARCH_PERF_STAT 00039 extern ulint page_cur_short_succ; 00040 # endif /* UNIV_SEARCH_PERF_STAT */ 00041 #endif /* PAGE_CUR_ADAPT */ 00042 00043 /************************************************************* 00044 Gets pointer to the page frame where the cursor is positioned. */ 00045 UNIV_INLINE 00046 page_t* 00047 page_cur_get_page( 00048 /*==============*/ 00049 /* out: page */ 00050 page_cur_t* cur); /* in: page cursor */ 00051 /************************************************************* 00052 Gets the record where the cursor is positioned. */ 00053 UNIV_INLINE 00054 rec_t* 00055 page_cur_get_rec( 00056 /*=============*/ 00057 /* out: record */ 00058 page_cur_t* cur); /* in: page cursor */ 00059 /************************************************************* 00060 Sets the cursor object to point before the first user record 00061 on the page. */ 00062 UNIV_INLINE 00063 void 00064 page_cur_set_before_first( 00065 /*======================*/ 00066 page_t* page, /* in: index page */ 00067 page_cur_t* cur); /* in: cursor */ 00068 /************************************************************* 00069 Sets the cursor object to point after the last user record on 00070 the page. */ 00071 UNIV_INLINE 00072 void 00073 page_cur_set_after_last( 00074 /*====================*/ 00075 page_t* page, /* in: index page */ 00076 page_cur_t* cur); /* in: cursor */ 00077 /************************************************************* 00078 Returns TRUE if the cursor is before first user record on page. */ 00079 UNIV_INLINE 00080 ibool 00081 page_cur_is_before_first( 00082 /*=====================*/ 00083 /* out: TRUE if at start */ 00084 const page_cur_t* cur); /* in: cursor */ 00085 /************************************************************* 00086 Returns TRUE if the cursor is after last user record. */ 00087 UNIV_INLINE 00088 ibool 00089 page_cur_is_after_last( 00090 /*===================*/ 00091 /* out: TRUE if at end */ 00092 const page_cur_t* cur); /* in: cursor */ 00093 /************************************************************** 00094 Positions the cursor on the given record. */ 00095 UNIV_INLINE 00096 void 00097 page_cur_position( 00098 /*==============*/ 00099 rec_t* rec, /* in: record on a page */ 00100 page_cur_t* cur); /* in: page cursor */ 00101 /************************************************************** 00102 Invalidates a page cursor by setting the record pointer NULL. */ 00103 UNIV_INLINE 00104 void 00105 page_cur_invalidate( 00106 /*================*/ 00107 page_cur_t* cur); /* in: page cursor */ 00108 /************************************************************** 00109 Moves the cursor to the next record on page. */ 00110 UNIV_INLINE 00111 void 00112 page_cur_move_to_next( 00113 /*==================*/ 00114 page_cur_t* cur); /* in: cursor; must not be after last */ 00115 /************************************************************** 00116 Moves the cursor to the previous record on page. */ 00117 UNIV_INLINE 00118 void 00119 page_cur_move_to_prev( 00120 /*==================*/ 00121 page_cur_t* cur); /* in: cursor; must not before first */ 00122 /*************************************************************** 00123 Inserts a record next to page cursor. Returns pointer to inserted record if 00124 succeed, i.e., enough space available, NULL otherwise. The cursor stays at 00125 the same position. */ 00126 UNIV_INLINE 00127 rec_t* 00128 page_cur_tuple_insert( 00129 /*==================*/ 00130 /* out: pointer to record if succeed, NULL 00131 otherwise */ 00132 page_cur_t* cursor, /* in: a page cursor */ 00133 dtuple_t* tuple, /* in: pointer to a data tuple */ 00134 dict_index_t* index, /* in: record descriptor */ 00135 mtr_t* mtr); /* in: mini-transaction handle */ 00136 /*************************************************************** 00137 Inserts a record next to page cursor. Returns pointer to inserted record if 00138 succeed, i.e., enough space available, NULL otherwise. The cursor stays at 00139 the same position. */ 00140 UNIV_INLINE 00141 rec_t* 00142 page_cur_rec_insert( 00143 /*================*/ 00144 /* out: pointer to record if succeed, NULL 00145 otherwise */ 00146 page_cur_t* cursor, /* in: a page cursor */ 00147 rec_t* rec, /* in: record to insert */ 00148 dict_index_t* index, /* in: record descriptor */ 00149 ulint* offsets,/* in: rec_get_offsets(rec, index) */ 00150 mtr_t* mtr); /* in: mini-transaction handle */ 00151 /*************************************************************** 00152 Inserts a record next to page cursor. Returns pointer to inserted record if 00153 succeed, i.e., enough space available, NULL otherwise. The record to be 00154 inserted can be in a data tuple or as a physical record. The other parameter 00155 must then be NULL. The cursor stays at the same position. */ 00156 00157 rec_t* 00158 page_cur_insert_rec_low( 00159 /*====================*/ 00160 /* out: pointer to record if succeed, NULL 00161 otherwise */ 00162 page_cur_t* cursor, /* in: a page cursor */ 00163 dtuple_t* tuple, /* in: pointer to a data tuple or NULL */ 00164 dict_index_t* index, /* in: record descriptor */ 00165 rec_t* rec, /* in: pointer to a physical record or NULL */ 00166 ulint* offsets,/* in: rec_get_offsets(rec, index) or NULL */ 00167 mtr_t* mtr); /* in: mini-transaction handle */ 00168 /***************************************************************** 00169 Copies records from page to a newly created page, from a given record onward, 00170 including that record. Infimum and supremum records are not copied. */ 00171 00172 void 00173 page_copy_rec_list_end_to_created_page( 00174 /*===================================*/ 00175 page_t* new_page, /* in: index page to copy to */ 00176 page_t* page, /* in: index page */ 00177 rec_t* rec, /* in: first record to copy */ 00178 dict_index_t* index, /* in: record descriptor */ 00179 mtr_t* mtr); /* in: mtr */ 00180 /*************************************************************** 00181 Deletes a record at the page cursor. The cursor is moved to the 00182 next record after the deleted one. */ 00183 00184 void 00185 page_cur_delete_rec( 00186 /*================*/ 00187 page_cur_t* cursor, /* in: a page cursor */ 00188 dict_index_t* index, /* in: record descriptor */ 00189 const ulint* offsets,/* in: rec_get_offsets(cursor->rec, index) */ 00190 mtr_t* mtr); /* in: mini-transaction handle */ 00191 /******************************************************************** 00192 Searches the right position for a page cursor. */ 00193 UNIV_INLINE 00194 ulint 00195 page_cur_search( 00196 /*============*/ 00197 /* out: number of matched fields on the left */ 00198 page_t* page, /* in: index page */ 00199 dict_index_t* index, /* in: record descriptor */ 00200 dtuple_t* tuple, /* in: data tuple */ 00201 ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, 00202 or PAGE_CUR_GE */ 00203 page_cur_t* cursor);/* out: page cursor */ 00204 /******************************************************************** 00205 Searches the right position for a page cursor. */ 00206 00207 void 00208 page_cur_search_with_match( 00209 /*=======================*/ 00210 page_t* page, /* in: index page */ 00211 dict_index_t* index, /* in: record descriptor */ 00212 dtuple_t* tuple, /* in: data tuple */ 00213 ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, 00214 or PAGE_CUR_GE */ 00215 ulint* iup_matched_fields, 00216 /* in/out: already matched fields in upper 00217 limit record */ 00218 ulint* iup_matched_bytes, 00219 /* in/out: already matched bytes in a field 00220 not yet completely matched */ 00221 ulint* ilow_matched_fields, 00222 /* in/out: already matched fields in lower 00223 limit record */ 00224 ulint* ilow_matched_bytes, 00225 /* in/out: already matched bytes in a field 00226 not yet completely matched */ 00227 page_cur_t* cursor); /* out: page cursor */ 00228 /*************************************************************** 00229 Positions a page cursor on a randomly chosen user record on a page. If there 00230 are no user records, sets the cursor on the infimum record. */ 00231 00232 void 00233 page_cur_open_on_rnd_user_rec( 00234 /*==========================*/ 00235 page_t* page, /* in: page */ 00236 page_cur_t* cursor);/* in/out: page cursor */ 00237 /*************************************************************** 00238 Parses a log record of a record insert on a page. */ 00239 00240 byte* 00241 page_cur_parse_insert_rec( 00242 /*======================*/ 00243 /* out: end of log record or NULL */ 00244 ibool is_short,/* in: TRUE if short inserts */ 00245 byte* ptr, /* in: buffer */ 00246 byte* end_ptr,/* in: buffer end */ 00247 dict_index_t* index, /* in: record descriptor */ 00248 page_t* page, /* in: page or NULL */ 00249 mtr_t* mtr); /* in: mtr or NULL */ 00250 /************************************************************** 00251 Parses a log record of copying a record list end to a new created page. */ 00252 00253 byte* 00254 page_parse_copy_rec_list_to_created_page( 00255 /*=====================================*/ 00256 /* out: end of log record or NULL */ 00257 byte* ptr, /* in: buffer */ 00258 byte* end_ptr,/* in: buffer end */ 00259 dict_index_t* index, /* in: record descriptor */ 00260 page_t* page, /* in: page or NULL */ 00261 mtr_t* mtr); /* in: mtr or NULL */ 00262 /*************************************************************** 00263 Parses log record of a record delete on a page. */ 00264 00265 byte* 00266 page_cur_parse_delete_rec( 00267 /*======================*/ 00268 /* out: pointer to record end or NULL */ 00269 byte* ptr, /* in: buffer */ 00270 byte* end_ptr,/* in: buffer end */ 00271 dict_index_t* index, /* in: record descriptor */ 00272 page_t* page, /* in: page or NULL */ 00273 mtr_t* mtr); /* in: mtr or NULL */ 00274 00275 /* Index page cursor */ 00276 00277 struct page_cur_struct{ 00278 byte* rec; /* pointer to a record on page */ 00279 }; 00280 00281 #ifndef UNIV_NONINL 00282 #include "page0cur.ic" 00283 #endif 00284 00285 #endif
1.4.7

