00001 /****************************************************** 00002 Interface between Innobase row operations and MySQL. 00003 Contains also create table and other data dictionary operations. 00004 00005 (c) 2000 Innobase Oy 00006 00007 Created 9/17/2000 Heikki Tuuri 00008 *******************************************************/ 00009 00010 #ifndef row0mysql_h 00011 #define row0mysql_h 00012 00013 #include "univ.i" 00014 #include "data0data.h" 00015 #include "que0types.h" 00016 #include "dict0types.h" 00017 #include "trx0types.h" 00018 #include "row0types.h" 00019 #include "btr0pcur.h" 00020 #include "trx0types.h" 00021 00022 typedef struct row_prebuilt_struct row_prebuilt_t; 00023 00024 /*********************************************************************** 00025 Frees the blob heap in prebuilt when no longer needed. */ 00026 00027 void 00028 row_mysql_prebuilt_free_blob_heap( 00029 /*==============================*/ 00030 row_prebuilt_t* prebuilt); /* in: prebuilt struct of a 00031 ha_innobase:: table handle */ 00032 /*********************************************************************** 00033 Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row 00034 format. */ 00035 00036 byte* 00037 row_mysql_store_true_var_len( 00038 /*=========================*/ 00039 /* out: pointer to the data, we skip the 1 or 2 bytes 00040 at the start that are used to store the len */ 00041 byte* dest, /* in: where to store */ 00042 ulint len, /* in: length, must fit in two bytes */ 00043 ulint lenlen);/* in: storage length of len: either 1 or 2 bytes */ 00044 /*********************************************************************** 00045 Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and 00046 returns a pointer to the data. */ 00047 00048 byte* 00049 row_mysql_read_true_varchar( 00050 /*========================*/ 00051 /* out: pointer to the data, we skip the 1 or 2 bytes 00052 at the start that are used to store the len */ 00053 ulint* len, /* out: variable-length field length */ 00054 byte* field, /* in: field in the MySQL format */ 00055 ulint lenlen);/* in: storage length of len: either 1 or 2 bytes */ 00056 /*********************************************************************** 00057 Stores a reference to a BLOB in the MySQL format. */ 00058 00059 void 00060 row_mysql_store_blob_ref( 00061 /*=====================*/ 00062 byte* dest, /* in: where to store */ 00063 ulint col_len, /* in: dest buffer size: determines into 00064 how many bytes the BLOB length is stored, 00065 this may vary from 1 to 4 bytes */ 00066 byte* data, /* in: BLOB data */ 00067 ulint len); /* in: BLOB length */ 00068 /*********************************************************************** 00069 Reads a reference to a BLOB in the MySQL format. */ 00070 00071 byte* 00072 row_mysql_read_blob_ref( 00073 /*====================*/ 00074 /* out: pointer to BLOB data */ 00075 ulint* len, /* out: BLOB length */ 00076 byte* ref, /* in: BLOB reference in the MySQL format */ 00077 ulint col_len); /* in: BLOB reference length (not BLOB 00078 length) */ 00079 /****************************************************************** 00080 Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. 00081 The counterpart of this function is row_sel_field_store_in_mysql_format() in 00082 row0sel.c. */ 00083 00084 byte* 00085 row_mysql_store_col_in_innobase_format( 00086 /*===================================*/ 00087 /* out: up to which byte we used 00088 buf in the conversion */ 00089 dfield_t* dfield, /* in/out: dfield where dtype 00090 information must be already set when 00091 this function is called! */ 00092 byte* buf, /* in/out: buffer for a converted 00093 integer value; this must be at least 00094 col_len long then! */ 00095 ibool row_format_col, /* TRUE if the mysql_data is from 00096 a MySQL row, FALSE if from a MySQL 00097 key value; 00098 in MySQL, a true VARCHAR storage 00099 format differs in a row and in a 00100 key value: in a key value the length 00101 is always stored in 2 bytes! */ 00102 byte* mysql_data, /* in: MySQL column value, not 00103 SQL NULL; NOTE that dfield may also 00104 get a pointer to mysql_data, 00105 therefore do not discard this as long 00106 as dfield is used! */ 00107 ulint col_len, /* in: MySQL column length; NOTE that 00108 this is the storage length of the 00109 column in the MySQL format row, not 00110 necessarily the length of the actual 00111 payload data; if the column is a true 00112 VARCHAR then this is irrelevant */ 00113 ulint comp); /* in: nonzero=compact format */ 00114 /******************************************************************** 00115 Handles user errors and lock waits detected by the database engine. */ 00116 00117 ibool 00118 row_mysql_handle_errors( 00119 /*====================*/ 00120 /* out: TRUE if it was a lock wait and 00121 we should continue running the query thread */ 00122 ulint* new_err,/* out: possible new error encountered in 00123 rollback, or the old error which was 00124 during the function entry */ 00125 trx_t* trx, /* in: transaction */ 00126 que_thr_t* thr, /* in: query thread */ 00127 trx_savept_t* savept);/* in: savepoint */ 00128 /************************************************************************ 00129 Create a prebuilt struct for a MySQL table handle. */ 00130 00131 row_prebuilt_t* 00132 row_create_prebuilt( 00133 /*================*/ 00134 /* out, own: a prebuilt struct */ 00135 dict_table_t* table); /* in: Innobase table handle */ 00136 /************************************************************************ 00137 Free a prebuilt struct for a MySQL table handle. */ 00138 00139 void 00140 row_prebuilt_free( 00141 /*==============*/ 00142 row_prebuilt_t* prebuilt); /* in, own: prebuilt struct */ 00143 /************************************************************************* 00144 Updates the transaction pointers in query graphs stored in the prebuilt 00145 struct. */ 00146 00147 void 00148 row_update_prebuilt_trx( 00149 /*====================*/ 00150 /* out: prebuilt dtuple */ 00151 row_prebuilt_t* prebuilt, /* in: prebuilt struct in MySQL 00152 handle */ 00153 trx_t* trx); /* in: transaction handle */ 00154 /************************************************************************* 00155 Unlocks an AUTO_INC type lock possibly reserved by trx. */ 00156 00157 void 00158 row_unlock_table_autoinc_for_mysql( 00159 /*===============================*/ 00160 trx_t* trx); /* in: transaction */ 00161 /************************************************************************* 00162 Sets an AUTO_INC type lock on the table mentioned in prebuilt. The 00163 AUTO_INC lock gives exclusive access to the auto-inc counter of the 00164 table. The lock is reserved only for the duration of an SQL statement. 00165 It is not compatible with another AUTO_INC or exclusive lock on the 00166 table. */ 00167 00168 int 00169 row_lock_table_autoinc_for_mysql( 00170 /*=============================*/ 00171 /* out: error code or DB_SUCCESS */ 00172 row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL 00173 table handle */ 00174 /************************************************************************* 00175 Sets a table lock on the table mentioned in prebuilt. */ 00176 00177 int 00178 row_lock_table_for_mysql( 00179 /*=====================*/ 00180 /* out: error code or DB_SUCCESS */ 00181 row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL 00182 table handle */ 00183 dict_table_t* table, /* in: table to lock, or NULL 00184 if prebuilt->table should be 00185 locked as 00186 prebuilt->select_lock_type */ 00187 ulint mode); /* in: lock mode of table 00188 (ignored if table==NULL) */ 00189 00190 /************************************************************************* 00191 Does an insert for MySQL. */ 00192 00193 int 00194 row_insert_for_mysql( 00195 /*=================*/ 00196 /* out: error code or DB_SUCCESS */ 00197 byte* mysql_rec, /* in: row in the MySQL format */ 00198 row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL 00199 handle */ 00200 /************************************************************************* 00201 Builds a dummy query graph used in selects. */ 00202 00203 void 00204 row_prebuild_sel_graph( 00205 /*===================*/ 00206 row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL 00207 handle */ 00208 /************************************************************************* 00209 Gets pointer to a prebuilt update vector used in updates. If the update 00210 graph has not yet been built in the prebuilt struct, then this function 00211 first builds it. */ 00212 00213 upd_t* 00214 row_get_prebuilt_update_vector( 00215 /*===========================*/ 00216 /* out: prebuilt update vector */ 00217 row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL 00218 handle */ 00219 /************************************************************************* 00220 Checks if a table is such that we automatically created a clustered 00221 index on it (on row id). */ 00222 00223 ibool 00224 row_table_got_default_clust_index( 00225 /*==============================*/ 00226 dict_table_t* table); 00227 /************************************************************************* 00228 Calculates the key number used inside MySQL for an Innobase index. We have 00229 to take into account if we generated a default clustered index for the table */ 00230 00231 ulint 00232 row_get_mysql_key_number_for_index( 00233 /*===============================*/ 00234 dict_index_t* index); 00235 /************************************************************************* 00236 Does an update or delete of a row for MySQL. */ 00237 00238 int 00239 row_update_for_mysql( 00240 /*=================*/ 00241 /* out: error code or DB_SUCCESS */ 00242 byte* mysql_rec, /* in: the row to be updated, in 00243 the MySQL format */ 00244 row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL 00245 handle */ 00246 /************************************************************************* 00247 This can only be used when srv_locks_unsafe_for_binlog is TRUE or 00248 session is using a READ COMMITTED isolation level. Before 00249 calling this function we must use trx_reset_new_rec_lock_info() and 00250 trx_register_new_rec_lock() to store the information which new record locks 00251 really were set. This function removes a newly set lock under prebuilt->pcur, 00252 and also under prebuilt->clust_pcur. Currently, this is only used and tested 00253 in the case of an UPDATE or a DELETE statement, where the row lock is of the 00254 LOCK_X type. 00255 Thus, this implements a 'mini-rollback' that releases the latest record 00256 locks we set. */ 00257 00258 int 00259 row_unlock_for_mysql( 00260 /*=================*/ 00261 /* out: error code or DB_SUCCESS */ 00262 row_prebuilt_t* prebuilt, /* in: prebuilt struct in MySQL 00263 handle */ 00264 ibool has_latches_on_recs);/* TRUE if called so that we have 00265 the latches on the records under pcur 00266 and clust_pcur, and we do not need to 00267 reposition the cursors. */ 00268 /************************************************************************* 00269 Creates an query graph node of 'update' type to be used in the MySQL 00270 interface. */ 00271 00272 upd_node_t* 00273 row_create_update_node_for_mysql( 00274 /*=============================*/ 00275 /* out, own: update node */ 00276 dict_table_t* table, /* in: table to update */ 00277 mem_heap_t* heap); /* in: mem heap from which allocated */ 00278 /************************************************************************** 00279 Does a cascaded delete or set null in a foreign key operation. */ 00280 00281 ulint 00282 row_update_cascade_for_mysql( 00283 /*=========================*/ 00284 /* out: error code or DB_SUCCESS */ 00285 que_thr_t* thr, /* in: query thread */ 00286 upd_node_t* node, /* in: update node used in the cascade 00287 or set null operation */ 00288 dict_table_t* table); /* in: table where we do the operation */ 00289 /************************************************************************* 00290 Locks the data dictionary exclusively for performing a table create or other 00291 data dictionary modification operation. */ 00292 00293 void 00294 row_mysql_lock_data_dictionary( 00295 /*===========================*/ 00296 trx_t* trx); /* in: transaction */ 00297 /************************************************************************* 00298 Unlocks the data dictionary exclusive lock. */ 00299 00300 void 00301 row_mysql_unlock_data_dictionary( 00302 /*=============================*/ 00303 trx_t* trx); /* in: transaction */ 00304 /************************************************************************* 00305 Locks the data dictionary in shared mode from modifications, for performing 00306 foreign key check, rollback, or other operation invisible to MySQL. */ 00307 00308 void 00309 row_mysql_freeze_data_dictionary( 00310 /*=============================*/ 00311 trx_t* trx); /* in: transaction */ 00312 /************************************************************************* 00313 Unlocks the data dictionary shared lock. */ 00314 00315 void 00316 row_mysql_unfreeze_data_dictionary( 00317 /*===============================*/ 00318 trx_t* trx); /* in: transaction */ 00319 /************************************************************************* 00320 Does a table creation operation for MySQL. If the name of the created 00321 table ends to characters INNODB_MONITOR, then this also starts 00322 printing of monitor output by the master thread. */ 00323 00324 int 00325 row_create_table_for_mysql( 00326 /*=======================*/ 00327 /* out: error code or DB_SUCCESS */ 00328 dict_table_t* table, /* in: table definition */ 00329 trx_t* trx); /* in: transaction handle */ 00330 /************************************************************************* 00331 Does an index creation operation for MySQL. TODO: currently failure 00332 to create an index results in dropping the whole table! This is no problem 00333 currently as all indexes must be created at the same time as the table. */ 00334 00335 int 00336 row_create_index_for_mysql( 00337 /*=======================*/ 00338 /* out: error number or DB_SUCCESS */ 00339 dict_index_t* index, /* in: index definition */ 00340 trx_t* trx, /* in: transaction handle */ 00341 const ulint* field_lengths); /* in: if not NULL, must contain 00342 dict_index_get_n_fields(index) 00343 actual field lengths for the 00344 index columns, which are 00345 then checked for not being too 00346 large. */ 00347 /************************************************************************* 00348 Scans a table create SQL string and adds to the data dictionary 00349 the foreign key constraints declared in the string. This function 00350 should be called after the indexes for a table have been created. 00351 Each foreign key constraint must be accompanied with indexes in 00352 bot participating tables. The indexes are allowed to contain more 00353 fields than mentioned in the constraint. */ 00354 00355 int 00356 row_table_add_foreign_constraints( 00357 /*==============================*/ 00358 /* out: error code or DB_SUCCESS */ 00359 trx_t* trx, /* in: transaction */ 00360 const char* sql_string, /* in: table create statement where 00361 foreign keys are declared like: 00362 FOREIGN KEY (a, b) REFERENCES table2(c, d), 00363 table2 can be written also with the 00364 database name before it: test.table2 */ 00365 const char* name, /* in: table full name in the 00366 normalized form 00367 database_name/table_name */ 00368 ibool reject_fks); /* in: if TRUE, fail with error 00369 code DB_CANNOT_ADD_CONSTRAINT if 00370 any foreign keys are found. */ 00371 00372 /************************************************************************* 00373 The master thread in srv0srv.c calls this regularly to drop tables which 00374 we must drop in background after queries to them have ended. Such lazy 00375 dropping of tables is needed in ALTER TABLE on Unix. */ 00376 00377 ulint 00378 row_drop_tables_for_mysql_in_background(void); 00379 /*=========================================*/ 00380 /* out: how many tables dropped 00381 + remaining tables in list */ 00382 /************************************************************************* 00383 Get the background drop list length. NOTE: the caller must own the kernel 00384 mutex! */ 00385 00386 ulint 00387 row_get_background_drop_list_len_low(void); 00388 /*======================================*/ 00389 /* out: how many tables in list */ 00390 /************************************************************************* 00391 Truncates a table for MySQL. */ 00392 00393 int 00394 row_truncate_table_for_mysql( 00395 /*=========================*/ 00396 /* out: error code or DB_SUCCESS */ 00397 dict_table_t* table, /* in: table handle */ 00398 trx_t* trx); /* in: transaction handle */ 00399 /************************************************************************* 00400 Drops a table for MySQL. If the name of the dropped table ends to 00401 characters INNODB_MONITOR, then this also stops printing of monitor 00402 output by the master thread. */ 00403 00404 int 00405 row_drop_table_for_mysql( 00406 /*=====================*/ 00407 /* out: error code or DB_SUCCESS */ 00408 const char* name, /* in: table name */ 00409 trx_t* trx, /* in: transaction handle */ 00410 ibool drop_db);/* in: TRUE=dropping whole database */ 00411 00412 /************************************************************************* 00413 Discards the tablespace of a table which stored in an .ibd file. Discarding 00414 means that this function deletes the .ibd file and assigns a new table id for 00415 the table. Also the flag table->ibd_file_missing is set TRUE. */ 00416 00417 int 00418 row_discard_tablespace_for_mysql( 00419 /*=============================*/ 00420 /* out: error code or DB_SUCCESS */ 00421 const char* name, /* in: table name */ 00422 trx_t* trx); /* in: transaction handle */ 00423 /********************************************************************* 00424 Imports a tablespace. The space id in the .ibd file must match the space id 00425 of the table in the data dictionary. */ 00426 00427 int 00428 row_import_tablespace_for_mysql( 00429 /*============================*/ 00430 /* out: error code or DB_SUCCESS */ 00431 const char* name, /* in: table name */ 00432 trx_t* trx); /* in: transaction handle */ 00433 /************************************************************************* 00434 Drops a database for MySQL. */ 00435 00436 int 00437 row_drop_database_for_mysql( 00438 /*========================*/ 00439 /* out: error code or DB_SUCCESS */ 00440 const char* name, /* in: database name which ends to '/' */ 00441 trx_t* trx); /* in: transaction handle */ 00442 /************************************************************************* 00443 Renames a table for MySQL. */ 00444 00445 int 00446 row_rename_table_for_mysql( 00447 /*=======================*/ 00448 /* out: error code or DB_SUCCESS */ 00449 const char* old_name, /* in: old table name */ 00450 const char* new_name, /* in: new table name */ 00451 trx_t* trx); /* in: transaction handle */ 00452 /************************************************************************* 00453 Checks a table for corruption. */ 00454 00455 ulint 00456 row_check_table_for_mysql( 00457 /*======================*/ 00458 /* out: DB_ERROR or DB_SUCCESS */ 00459 row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL 00460 handle */ 00461 00462 /* A struct describing a place for an individual column in the MySQL 00463 row format which is presented to the table handler in ha_innobase. 00464 This template struct is used to speed up row transformations between 00465 Innobase and MySQL. */ 00466 00467 typedef struct mysql_row_templ_struct mysql_row_templ_t; 00468 struct mysql_row_templ_struct { 00469 ulint col_no; /* column number of the column */ 00470 ulint rec_field_no; /* field number of the column in an 00471 Innobase record in the current index; 00472 not defined if template_type is 00473 ROW_MYSQL_WHOLE_ROW */ 00474 ulint mysql_col_offset; /* offset of the column in the MySQL 00475 row format */ 00476 ulint mysql_col_len; /* length of the column in the MySQL 00477 row format */ 00478 ulint mysql_null_byte_offset; /* MySQL NULL bit byte offset in a 00479 MySQL record */ 00480 ulint mysql_null_bit_mask; /* bit mask to get the NULL bit, 00481 zero if column cannot be NULL */ 00482 ulint type; /* column type in Innobase mtype 00483 numbers DATA_CHAR... */ 00484 ulint mysql_type; /* MySQL type code; this is always 00485 < 256 */ 00486 ulint mysql_length_bytes; /* if mysql_type 00487 == DATA_MYSQL_TRUE_VARCHAR, this tells 00488 whether we should use 1 or 2 bytes to 00489 store the MySQL true VARCHAR data 00490 length at the start of row in the MySQL 00491 format (NOTE that the MySQL key value 00492 format always uses 2 bytes for the data 00493 len) */ 00494 ulint charset; /* MySQL charset-collation code 00495 of the column, or zero */ 00496 ulint mbminlen; /* minimum length of a char, in bytes, 00497 or zero if not a char type */ 00498 ulint mbmaxlen; /* maximum length of a char, in bytes, 00499 or zero if not a char type */ 00500 ulint is_unsigned; /* if a column type is an integer 00501 type and this field is != 0, then 00502 it is an unsigned integer type */ 00503 }; 00504 00505 #define MYSQL_FETCH_CACHE_SIZE 8 00506 /* After fetching this many rows, we start caching them in fetch_cache */ 00507 #define MYSQL_FETCH_CACHE_THRESHOLD 4 00508 00509 #define ROW_PREBUILT_ALLOCATED 78540783 00510 #define ROW_PREBUILT_FREED 26423527 00511 00512 /* A struct for (sometimes lazily) prebuilt structures in an Innobase table 00513 handle used within MySQL; these are used to save CPU time. */ 00514 00515 struct row_prebuilt_struct { 00516 ulint magic_n; /* this magic number is set to 00517 ROW_PREBUILT_ALLOCATED when created 00518 and to ROW_PREBUILT_FREED when the 00519 struct has been freed; used in 00520 debugging */ 00521 dict_table_t* table; /* Innobase table handle */ 00522 trx_t* trx; /* current transaction handle */ 00523 ibool sql_stat_start; /* TRUE when we start processing of 00524 an SQL statement: we may have to set 00525 an intention lock on the table, 00526 create a consistent read view etc. */ 00527 ibool mysql_has_locked; /* this is set TRUE when MySQL 00528 calls external_lock on this handle 00529 with a lock flag, and set FALSE when 00530 with the F_UNLOCK flag */ 00531 ibool clust_index_was_generated; 00532 /* if the user did not define a 00533 primary key in MySQL, then Innobase 00534 automatically generated a clustered 00535 index where the ordering column is 00536 the row id: in this case this flag 00537 is set to TRUE */ 00538 dict_index_t* index; /* current index for a search, if 00539 any */ 00540 ulint read_just_key; /* set to 1 when MySQL calls 00541 ha_innobase::extra with the 00542 argument HA_EXTRA_KEYREAD; it is enough 00543 to read just columns defined in 00544 the index (i.e., no read of the 00545 clustered index record necessary) */ 00546 ibool used_in_HANDLER;/* TRUE if we have been using this 00547 handle in a MySQL HANDLER low level 00548 index cursor command: then we must 00549 store the pcur position even in a 00550 unique search from a clustered index, 00551 because HANDLER allows NEXT and PREV 00552 in such a situation */ 00553 ulint template_type; /* ROW_MYSQL_WHOLE_ROW, 00554 ROW_MYSQL_REC_FIELDS, 00555 ROW_MYSQL_DUMMY_TEMPLATE, or 00556 ROW_MYSQL_NO_TEMPLATE */ 00557 ulint n_template; /* number of elements in the 00558 template */ 00559 ulint null_bitmap_len;/* number of bytes in the SQL NULL 00560 bitmap at the start of a row in the 00561 MySQL format */ 00562 ibool need_to_access_clustered; /* if we are fetching 00563 columns through a secondary index 00564 and at least one column is not in 00565 the secondary index, then this is 00566 set to TRUE */ 00567 ibool templ_contains_blob;/* TRUE if the template contains 00568 BLOB column(s) */ 00569 mysql_row_templ_t* mysql_template;/* template used to transform 00570 rows fast between MySQL and Innobase 00571 formats; memory for this template 00572 is not allocated from 'heap' */ 00573 mem_heap_t* heap; /* memory heap from which 00574 these auxiliary structures are 00575 allocated when needed */ 00576 ins_node_t* ins_node; /* Innobase SQL insert node 00577 used to perform inserts 00578 to the table */ 00579 byte* ins_upd_rec_buff;/* buffer for storing data converted 00580 to the Innobase format from the MySQL 00581 format */ 00582 ulint hint_need_to_fetch_extra_cols; 00583 /* normally this is set to 0; if this 00584 is set to ROW_RETRIEVE_PRIMARY_KEY, 00585 then we should at least retrieve all 00586 columns in the primary key; if this 00587 is set to ROW_RETRIEVE_ALL_COLS, then 00588 we must retrieve all columns in the 00589 key (if read_just_key == 1), or all 00590 columns in the table */ 00591 upd_node_t* upd_node; /* Innobase SQL update node used 00592 to perform updates and deletes */ 00593 que_fork_t* ins_graph; /* Innobase SQL query graph used 00594 in inserts */ 00595 que_fork_t* upd_graph; /* Innobase SQL query graph used 00596 in updates or deletes */ 00597 btr_pcur_t* pcur; /* persistent cursor used in selects 00598 and updates */ 00599 btr_pcur_t* clust_pcur; /* persistent cursor used in 00600 some selects and updates */ 00601 que_fork_t* sel_graph; /* dummy query graph used in 00602 selects */ 00603 dtuple_t* search_tuple; /* prebuilt dtuple used in selects */ 00604 byte row_id[DATA_ROW_ID_LEN]; 00605 /* if the clustered index was generated, 00606 the row id of the last row fetched is 00607 stored here */ 00608 dtuple_t* clust_ref; /* prebuilt dtuple used in 00609 sel/upd/del */ 00610 ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */ 00611 ulint stored_select_lock_type;/* this field is used to 00612 remember the original select_lock_type 00613 that was decided in ha_innodb.cc, 00614 ::store_lock(), ::external_lock(), 00615 etc. */ 00616 ulint row_read_type; /* ROW_READ_WITH_LOCKS if row locks 00617 should be the obtained for records 00618 under an UPDATE or DELETE cursor. 00619 If innodb_locks_unsafe_for_binlog 00620 is TRUE, this can be set to 00621 ROW_READ_TRY_SEMI_CONSISTENT, so that 00622 if the row under an UPDATE or DELETE 00623 cursor was locked by another 00624 transaction, InnoDB will resort 00625 to reading the last committed value 00626 ('semi-consistent read'). Then, 00627 this field will be set to 00628 ROW_READ_DID_SEMI_CONSISTENT to 00629 indicate that. If the row does not 00630 match the WHERE condition, MySQL will 00631 invoke handler::unlock_row() to 00632 clear the flag back to 00633 ROW_READ_TRY_SEMI_CONSISTENT and 00634 to simply skip the row. If 00635 the row matches, the next call to 00636 row_search_for_mysql() will lock 00637 the row. 00638 This eliminates lock waits in some 00639 cases; note that this breaks 00640 serializability. */ 00641 ulint mysql_prefix_len;/* byte offset of the end of 00642 the last requested column */ 00643 ulint mysql_row_len; /* length in bytes of a row in the 00644 MySQL format */ 00645 ulint n_rows_fetched; /* number of rows fetched after 00646 positioning the current cursor */ 00647 ulint fetch_direction;/* ROW_SEL_NEXT or ROW_SEL_PREV */ 00648 byte* fetch_cache[MYSQL_FETCH_CACHE_SIZE]; 00649 /* a cache for fetched rows if we 00650 fetch many rows from the same cursor: 00651 it saves CPU time to fetch them in a 00652 batch; we reserve mysql_row_len 00653 bytes for each such row; these 00654 pointers point 4 bytes past the 00655 allocated mem buf start, because 00656 there is a 4 byte magic number at the 00657 start and at the end */ 00658 ibool keep_other_fields_on_keyread; /* when using fetch 00659 cache with HA_EXTRA_KEYREAD, don't 00660 overwrite other fields in mysql row 00661 row buffer.*/ 00662 ulint fetch_cache_first;/* position of the first not yet 00663 fetched row in fetch_cache */ 00664 ulint n_fetch_cached; /* number of not yet fetched rows 00665 in fetch_cache */ 00666 mem_heap_t* blob_heap; /* in SELECTS BLOB fie lds are copied 00667 to this heap */ 00668 mem_heap_t* old_vers_heap; /* memory heap where a previous 00669 version is built in consistent read */ 00670 ulint magic_n2; /* this should be the same as 00671 magic_n */ 00672 }; 00673 00674 #define ROW_PREBUILT_FETCH_MAGIC_N 465765687 00675 00676 #define ROW_MYSQL_WHOLE_ROW 0 00677 #define ROW_MYSQL_REC_FIELDS 1 00678 #define ROW_MYSQL_NO_TEMPLATE 2 00679 #define ROW_MYSQL_DUMMY_TEMPLATE 3 /* dummy template used in 00680 row_scan_and_check_index */ 00681 00682 /* Values for hint_need_to_fetch_extra_cols */ 00683 #define ROW_RETRIEVE_PRIMARY_KEY 1 00684 #define ROW_RETRIEVE_ALL_COLS 2 00685 00686 /* Values for row_read_type */ 00687 #define ROW_READ_WITH_LOCKS 0 00688 #define ROW_READ_TRY_SEMI_CONSISTENT 1 00689 #define ROW_READ_DID_SEMI_CONSISTENT 2 00690 00691 #ifndef UNIV_NONINL 00692 #include "row0mysql.ic" 00693 #endif 00694 00695 #endif
1.4.7

