00001 /* Copyright (C) 2000,2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 /* Definitions for parameters to do with handler-routines */ 00019 00020 #ifdef USE_PRAGMA_INTERFACE 00021 #pragma interface /* gcc class implementation */ 00022 #endif 00023 00024 #include <ft_global.h> 00025 #include <keycache.h> 00026 00027 #ifndef NO_HASH 00028 #define NO_HASH /* Not yet implemented */ 00029 #endif 00030 00031 #define USING_TRANSACTIONS 00032 00033 // the following is for checking tables 00034 00035 #define HA_ADMIN_ALREADY_DONE 1 00036 #define HA_ADMIN_OK 0 00037 #define HA_ADMIN_NOT_IMPLEMENTED -1 00038 #define HA_ADMIN_FAILED -2 00039 #define HA_ADMIN_CORRUPT -3 00040 #define HA_ADMIN_INTERNAL_ERROR -4 00041 #define HA_ADMIN_INVALID -5 00042 #define HA_ADMIN_REJECT -6 00043 #define HA_ADMIN_TRY_ALTER -7 00044 #define HA_ADMIN_WRONG_CHECKSUM -8 00045 #define HA_ADMIN_NOT_BASE_TABLE -9 00046 #define HA_ADMIN_NEEDS_UPGRADE -10 00047 #define HA_ADMIN_NEEDS_ALTER -11 00048 #define HA_ADMIN_NEEDS_CHECK -12 00049 00050 /* Bits in table_flags() to show what database can do */ 00051 00052 #define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */ 00053 #define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */ 00054 #define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */ 00055 /* 00056 The following should be set if the following is not true when scanning 00057 a table with rnd_next() 00058 - We will see all rows (including deleted ones) 00059 - Row positions are 'table->s->db_record_offset' apart 00060 If this flag is not set, filesort will do a postion() call for each matched 00061 row to be able to find the row later. 00062 */ 00063 #define HA_REC_NOT_IN_SEQ (1 << 3) 00064 #define HA_CAN_GEOMETRY (1 << 4) 00065 /* 00066 Reading keys in random order is as fast as reading keys in sort order 00067 (Used in records.cc to decide if we should use a record cache and by 00068 filesort to decide if we should sort key + data or key + pointer-to-row 00069 */ 00070 #define HA_FAST_KEY_READ (1 << 5) 00071 /* 00072 Set the following flag if we on delete should force all key to be read 00073 and on update read all keys that changes 00074 */ 00075 #define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6) 00076 #define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */ 00077 #define HA_DUPLICATE_POS (1 << 8) /* ha_position() gives dup row */ 00078 #define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */ 00079 #define HA_CAN_INDEX_BLOBS (1 << 10) 00080 #define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */ 00081 #define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */ 00082 #define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */ 00083 /* 00084 INSERT_DELAYED only works with handlers that uses MySQL internal table 00085 level locks 00086 */ 00087 #define HA_CAN_INSERT_DELAYED (1 << 14) 00088 /* 00089 If we get the primary key columns for free when we do an index read 00090 It also implies that we have to retrive the primary key when using 00091 position() and rnd_pos(). 00092 */ 00093 #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) 00094 /* 00095 If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position() 00096 uses a primary key. Without primary key, we can't call position(). 00097 */ 00098 #define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) 00099 #define HA_CAN_RTREEKEYS (1 << 17) 00100 #define HA_NOT_DELETE_WITH_CACHE (1 << 18) 00101 /* 00102 The following is we need to a primary key to delete (and update) a row. 00103 If there is no primary key, all columns needs to be read on update and delete 00104 */ 00105 #define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19) 00106 #define HA_NO_PREFIX_CHAR_KEYS (1 << 20) 00107 #define HA_CAN_FULLTEXT (1 << 21) 00108 #define HA_CAN_SQL_HANDLER (1 << 22) 00109 #define HA_NO_AUTO_INCREMENT (1 << 23) 00110 #define HA_HAS_CHECKSUM (1 << 24) 00111 /* Table data are stored in separate files (for lower_case_table_names) */ 00112 #define HA_FILE_BASED (1 << 26) 00113 #define HA_NO_VARCHAR (1 << 27) 00114 #define HA_CAN_BIT_FIELD (1 << 28) /* supports bit fields */ 00115 #define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */ 00116 #define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30) 00117 #define HA_NO_COPY_ON_ALTER (LL(1) << 31) 00118 #define HA_HAS_RECORDS (LL(1) << 32) /* records() gives exact count*/ 00119 /* Has it's own method of binlog logging */ 00120 #define HA_HAS_OWN_BINLOGGING (LL(1) << 33) 00121 00122 /* bits in index_flags(index_number) for what you can do with index */ 00123 #define HA_READ_NEXT 1 /* TODO really use this flag */ 00124 #define HA_READ_PREV 2 /* supports ::index_prev */ 00125 #define HA_READ_ORDER 4 /* index_next/prev follow sort order */ 00126 #define HA_READ_RANGE 8 /* can find all records in a range */ 00127 #define HA_ONLY_WHOLE_INDEX 16 /* Can't use part key searches */ 00128 #define HA_KEYREAD_ONLY 64 /* Support HA_EXTRA_KEYREAD */ 00129 00130 /* 00131 bits in alter_table_flags: 00132 */ 00133 /* 00134 These bits are set if different kinds of indexes can be created 00135 off-line without re-create of the table (but with a table lock). 00136 */ 00137 #define HA_ONLINE_ADD_INDEX_NO_WRITES (1L << 0) /*add index w/lock*/ 00138 #define HA_ONLINE_DROP_INDEX_NO_WRITES (1L << 1) /*drop index w/lock*/ 00139 #define HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES (1L << 2) /*add unique w/lock*/ 00140 #define HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES (1L << 3) /*drop uniq. w/lock*/ 00141 #define HA_ONLINE_ADD_PK_INDEX_NO_WRITES (1L << 4) /*add prim. w/lock*/ 00142 #define HA_ONLINE_DROP_PK_INDEX_NO_WRITES (1L << 5) /*drop prim. w/lock*/ 00143 /* 00144 These are set if different kinds of indexes can be created on-line 00145 (without a table lock). If a handler is capable of one or more of 00146 these, it should also set the corresponding *_NO_WRITES bit(s). 00147 */ 00148 #define HA_ONLINE_ADD_INDEX (1L << 6) /*add index online*/ 00149 #define HA_ONLINE_DROP_INDEX (1L << 7) /*drop index online*/ 00150 #define HA_ONLINE_ADD_UNIQUE_INDEX (1L << 8) /*add unique online*/ 00151 #define HA_ONLINE_DROP_UNIQUE_INDEX (1L << 9) /*drop uniq. online*/ 00152 #define HA_ONLINE_ADD_PK_INDEX (1L << 10)/*add prim. online*/ 00153 #define HA_ONLINE_DROP_PK_INDEX (1L << 11)/*drop prim. online*/ 00154 /* 00155 HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is 00156 supported at all. 00157 HA_FAST_CHANGE_PARTITION means that optimised variants of the changes 00158 exists but they are not necessarily done online. 00159 00160 HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both 00161 the new partition and to the old partitions when updating through the 00162 old partitioning schema while performing a change of the partitioning. 00163 This means that we can support updating of the table while performing 00164 the copy phase of the change. For no lock at all also a double write 00165 from new to old must exist and this is not required when this flag is 00166 set. 00167 This is actually removed even before it was introduced the first time. 00168 The new idea is that handlers will handle the lock level already in 00169 store_lock for ALTER TABLE partitions. 00170 00171 HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take 00172 care of changing the partitions online and in one phase. Thus all phases 00173 needed to handle the change are implemented inside the storage engine. 00174 The storage engine must also support auto-discovery since the frm file 00175 is changed as part of the change and this change must be controlled by 00176 the storage engine. A typical engine to support this is NDB (through 00177 WL #2498). 00178 */ 00179 #define HA_PARTITION_FUNCTION_SUPPORTED (1L << 12) 00180 #define HA_FAST_CHANGE_PARTITION (1L << 13) 00181 #define HA_PARTITION_ONE_PHASE (1L << 14) 00182 00183 /* 00184 Index scan will not return records in rowid order. Not guaranteed to be 00185 set for unordered (e.g. HASH) indexes. 00186 */ 00187 #define HA_KEY_SCAN_NOT_ROR 128 00188 00189 /* operations for disable/enable indexes */ 00190 #define HA_KEY_SWITCH_NONUNIQ 0 00191 #define HA_KEY_SWITCH_ALL 1 00192 #define HA_KEY_SWITCH_NONUNIQ_SAVE 2 00193 #define HA_KEY_SWITCH_ALL_SAVE 3 00194 00195 /* 00196 Note: the following includes binlog and closing 0. 00197 so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive + 00198 example + csv + heap + blackhole + federated + 0 00199 (yes, the sum is deliberately inaccurate) 00200 TODO remove the limit, use dynarrays 00201 */ 00202 #define MAX_HA 15 00203 00204 /* 00205 Parameters for open() (in register form->filestat) 00206 HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED 00207 */ 00208 00209 #define HA_OPEN_KEYFILE 1 00210 #define HA_OPEN_RNDFILE 2 00211 #define HA_GET_INDEX 4 00212 #define HA_GET_INFO 8 /* do a ha_info() after open */ 00213 #define HA_READ_ONLY 16 /* File opened as readonly */ 00214 /* Try readonly if can't open with read and write */ 00215 #define HA_TRY_READ_ONLY 32 00216 #define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */ 00217 #define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/ 00218 #define HA_BLOCK_LOCK 256 /* unlock when reading some records */ 00219 #define HA_OPEN_TEMPORARY 512 00220 00221 /* Some key definitions */ 00222 #define HA_KEY_NULL_LENGTH 1 00223 #define HA_KEY_BLOB_LENGTH 2 00224 00225 #define HA_LEX_CREATE_TMP_TABLE 1 00226 #define HA_LEX_CREATE_IF_NOT_EXISTS 2 00227 #define HA_OPTION_NO_CHECKSUM (1L << 17) 00228 #define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18) 00229 #define HA_MAX_REC_LENGTH 65535 00230 00231 /* Table caching type */ 00232 #define HA_CACHE_TBL_NONTRANSACT 0 00233 #define HA_CACHE_TBL_NOCACHE 1 00234 #define HA_CACHE_TBL_ASKTRANSACT 2 00235 #define HA_CACHE_TBL_TRANSACT 4 00236 00237 /* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */ 00238 #define MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1 00239 00240 /* Flags for method is_fatal_error */ 00241 #define HA_CHECK_DUP_KEY 1 00242 #define HA_CHECK_DUP_UNIQUE 2 00243 #define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE) 00244 00245 enum legacy_db_type 00246 { 00247 DB_TYPE_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1, 00248 DB_TYPE_HASH,DB_TYPE_MISAM,DB_TYPE_PISAM, 00249 DB_TYPE_RMS_ISAM, DB_TYPE_HEAP, DB_TYPE_ISAM, 00250 DB_TYPE_MRG_ISAM, DB_TYPE_MYISAM, DB_TYPE_MRG_MYISAM, 00251 DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB, 00252 DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER, 00253 DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB, 00254 DB_TYPE_FEDERATED_DB, 00255 DB_TYPE_BLACKHOLE_DB, 00256 DB_TYPE_PARTITION_DB, 00257 DB_TYPE_BINLOG, 00258 DB_TYPE_FIRST_DYNAMIC=32, 00259 DB_TYPE_DEFAULT=127 // Must be last 00260 }; 00261 00262 enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, 00263 ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED, 00264 ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGES }; 00265 00266 enum enum_binlog_func { 00267 BFN_RESET_LOGS= 1, 00268 BFN_RESET_SLAVE= 2, 00269 BFN_BINLOG_WAIT= 3, 00270 BFN_BINLOG_END= 4, 00271 BFN_BINLOG_PURGE_FILE= 5 00272 }; 00273 00274 enum enum_binlog_command { 00275 LOGCOM_CREATE_TABLE, 00276 LOGCOM_ALTER_TABLE, 00277 LOGCOM_RENAME_TABLE, 00278 LOGCOM_DROP_TABLE, 00279 LOGCOM_CREATE_DB, 00280 LOGCOM_ALTER_DB, 00281 LOGCOM_DROP_DB 00282 }; 00283 00284 /* struct to hold information about the table that should be created */ 00285 00286 /* Bits in used_fields */ 00287 #define HA_CREATE_USED_AUTO (1L << 0) 00288 #define HA_CREATE_USED_RAID (1L << 1) //RAID is no longer availble 00289 #define HA_CREATE_USED_UNION (1L << 2) 00290 #define HA_CREATE_USED_INSERT_METHOD (1L << 3) 00291 #define HA_CREATE_USED_MIN_ROWS (1L << 4) 00292 #define HA_CREATE_USED_MAX_ROWS (1L << 5) 00293 #define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6) 00294 #define HA_CREATE_USED_PACK_KEYS (1L << 7) 00295 #define HA_CREATE_USED_CHARSET (1L << 8) 00296 #define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9) 00297 #define HA_CREATE_USED_DATADIR (1L << 10) 00298 #define HA_CREATE_USED_INDEXDIR (1L << 11) 00299 #define HA_CREATE_USED_ENGINE (1L << 12) 00300 #define HA_CREATE_USED_CHECKSUM (1L << 13) 00301 #define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14) 00302 #define HA_CREATE_USED_ROW_FORMAT (1L << 15) 00303 #define HA_CREATE_USED_COMMENT (1L << 16) 00304 #define HA_CREATE_USED_PASSWORD (1L << 17) 00305 #define HA_CREATE_USED_CONNECTION (1L << 18) 00306 #define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19) 00307 00308 typedef ulonglong my_xid; // this line is the same as in log_event.h 00309 #define MYSQL_XID_PREFIX "MySQLXid" 00310 #define MYSQL_XID_PREFIX_LEN 8 // must be a multiple of 8 00311 #define MYSQL_XID_OFFSET (MYSQL_XID_PREFIX_LEN+sizeof(server_id)) 00312 #define MYSQL_XID_GTRID_LEN (MYSQL_XID_OFFSET+sizeof(my_xid)) 00313 00314 #define XIDDATASIZE 128 00315 #define MAXGTRIDSIZE 64 00316 #define MAXBQUALSIZE 64 00317 00318 #define COMPATIBLE_DATA_YES 0 00319 #define COMPATIBLE_DATA_NO 1 00320 00321 struct xid_t { 00322 long formatID; 00323 long gtrid_length; 00324 long bqual_length; 00325 char data[XIDDATASIZE]; // not \0-terminated ! 00326 00327 xid_t() {} /* Remove gcc warning */ 00328 bool eq(struct xid_t *xid) 00329 { return eq(xid->gtrid_length, xid->bqual_length, xid->data); } 00330 bool eq(long g, long b, const char *d) 00331 { return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); } 00332 void set(struct xid_t *xid) 00333 { memcpy(this, xid, xid->length()); } 00334 void set(long f, const char *g, long gl, const char *b, long bl) 00335 { 00336 formatID= f; 00337 memcpy(data, g, gtrid_length= gl); 00338 memcpy(data+gl, b, bqual_length= bl); 00339 } 00340 void set(ulonglong xid) 00341 { 00342 my_xid tmp; 00343 formatID= 1; 00344 set(MYSQL_XID_PREFIX_LEN, 0, MYSQL_XID_PREFIX); 00345 memcpy(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)); 00346 tmp= xid; 00347 memcpy(data+MYSQL_XID_OFFSET, &tmp, sizeof(tmp)); 00348 gtrid_length=MYSQL_XID_GTRID_LEN; 00349 } 00350 void set(long g, long b, const char *d) 00351 { 00352 formatID= 1; 00353 gtrid_length= g; 00354 bqual_length= b; 00355 memcpy(data, d, g+b); 00356 } 00357 bool is_null() { return formatID == -1; } 00358 void null() { formatID= -1; } 00359 my_xid quick_get_my_xid() 00360 { 00361 my_xid tmp; 00362 memcpy(&tmp, data+MYSQL_XID_OFFSET, sizeof(tmp)); 00363 return tmp; 00364 } 00365 my_xid get_my_xid() 00366 { 00367 return gtrid_length == MYSQL_XID_GTRID_LEN && bqual_length == 0 && 00368 !memcmp(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)) && 00369 !memcmp(data, MYSQL_XID_PREFIX, MYSQL_XID_PREFIX_LEN) ? 00370 quick_get_my_xid() : 0; 00371 } 00372 uint length() 00373 { 00374 return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+ 00375 gtrid_length+bqual_length; 00376 } 00377 byte *key() 00378 { 00379 return (byte *)>rid_length; 00380 } 00381 uint key_length() 00382 { 00383 return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length; 00384 } 00385 }; 00386 typedef struct xid_t XID; 00387 00388 /* for recover() handlerton call */ 00389 #define MIN_XID_LIST_SIZE 128 00390 #ifdef SAFEMALLOC 00391 #define MAX_XID_LIST_SIZE 256 00392 #else 00393 #define MAX_XID_LIST_SIZE (1024*128) 00394 #endif 00395 00396 /* 00397 These structures are used to pass information from a set of SQL commands 00398 on add/drop/change tablespace definitions to the proper hton. 00399 */ 00400 #define UNDEF_NODEGROUP 65535 00401 enum ts_command_type 00402 { 00403 TS_CMD_NOT_DEFINED = -1, 00404 CREATE_TABLESPACE = 0, 00405 ALTER_TABLESPACE = 1, 00406 CREATE_LOGFILE_GROUP = 2, 00407 ALTER_LOGFILE_GROUP = 3, 00408 DROP_TABLESPACE = 4, 00409 DROP_LOGFILE_GROUP = 5, 00410 CHANGE_FILE_TABLESPACE = 6, 00411 ALTER_ACCESS_MODE_TABLESPACE = 7 00412 }; 00413 00414 enum ts_alter_tablespace_type 00415 { 00416 TS_ALTER_TABLESPACE_TYPE_NOT_DEFINED = -1, 00417 ALTER_TABLESPACE_ADD_FILE = 1, 00418 ALTER_TABLESPACE_DROP_FILE = 2 00419 }; 00420 00421 enum tablespace_access_mode 00422 { 00423 TS_NOT_DEFINED= -1, 00424 TS_READ_ONLY = 0, 00425 TS_READ_WRITE = 1, 00426 TS_NOT_ACCESSIBLE = 2 00427 }; 00428 00429 struct handlerton; 00430 class st_alter_tablespace : public Sql_alloc 00431 { 00432 public: 00433 const char *tablespace_name; 00434 const char *logfile_group_name; 00435 enum ts_command_type ts_cmd_type; 00436 enum ts_alter_tablespace_type ts_alter_tablespace_type; 00437 const char *data_file_name; 00438 const char *undo_file_name; 00439 const char *redo_file_name; 00440 ulonglong extent_size; 00441 ulonglong undo_buffer_size; 00442 ulonglong redo_buffer_size; 00443 ulonglong initial_size; 00444 ulonglong autoextend_size; 00445 ulonglong max_size; 00446 uint nodegroup_id; 00447 const handlerton *storage_engine; 00448 bool wait_until_completed; 00449 const char *ts_comment; 00450 enum tablespace_access_mode ts_access_mode; 00451 st_alter_tablespace() 00452 { 00453 tablespace_name= NULL; 00454 logfile_group_name= "DEFAULT_LG"; //Default log file group 00455 ts_cmd_type= TS_CMD_NOT_DEFINED; 00456 data_file_name= NULL; 00457 undo_file_name= NULL; 00458 redo_file_name= NULL; 00459 extent_size= 1024*1024; //Default 1 MByte 00460 undo_buffer_size= 8*1024*1024; //Default 8 MByte 00461 redo_buffer_size= 8*1024*1024; //Default 8 MByte 00462 initial_size= 128*1024*1024; //Default 128 MByte 00463 autoextend_size= 0; //No autoextension as default 00464 max_size= 0; //Max size == initial size => no extension 00465 storage_engine= NULL; 00466 nodegroup_id= UNDEF_NODEGROUP; 00467 wait_until_completed= TRUE; 00468 ts_comment= NULL; 00469 ts_access_mode= TS_NOT_DEFINED; 00470 } 00471 }; 00472 00473 /* The handler for a table type. Will be included in the TABLE structure */ 00474 00475 struct st_table; 00476 typedef struct st_table TABLE; 00477 typedef struct st_table_share TABLE_SHARE; 00478 struct st_foreign_key_info; 00479 typedef struct st_foreign_key_info FOREIGN_KEY_INFO; 00480 typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len, 00481 const char *file, uint file_len, 00482 const char *status, uint status_len); 00483 enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX }; 00484 extern st_plugin_int *hton2plugin[MAX_HA]; 00485 00486 /* Transaction log maintains type definitions */ 00487 enum log_status 00488 { 00489 HA_LOG_STATUS_FREE= 0, /* log is free and can be deleted */ 00490 HA_LOG_STATUS_INUSE= 1, /* log can't be deleted because it is in use */ 00491 HA_LOG_STATUS_NOSUCHLOG= 2 /* no such log (can't be returned by 00492 the log iterator status) */ 00493 }; 00494 /* 00495 Function for signaling that the log file changed its state from 00496 LOG_STATUS_INUSE to LOG_STATUS_FREE 00497 00498 Now it do nothing, will be implemented as part of new transaction 00499 log management for engines. 00500 TODO: implement the function. 00501 */ 00502 void signal_log_not_needed(struct handlerton, char *log_file); 00503 /* 00504 Data of transaction log iterator. 00505 */ 00506 struct handler_log_file_data { 00507 LEX_STRING filename; 00508 enum log_status status; 00509 }; 00510 00511 00512 enum handler_iterator_type 00513 { 00514 /* request of transaction log iterator */ 00515 HA_TRANSACTLOG_ITERATOR= 1 00516 }; 00517 enum handler_create_iterator_result 00518 { 00519 HA_ITERATOR_OK, /* iterator created */ 00520 HA_ITERATOR_UNSUPPORTED, /* such type of iterator is not supported */ 00521 HA_ITERATOR_ERROR /* error during iterator creation */ 00522 }; 00523 00524 /* 00525 Iterator structure. Can be used by handler/handlerton for different purposes. 00526 00527 Iterator should be created in the way to point "before" the first object 00528 it iterate, so next() call move it to the first object or return !=0 if 00529 there is nothing to iterate through. 00530 */ 00531 struct handler_iterator { 00532 /* 00533 Moves iterator to next record and return 0 or return !=0 00534 if there is no records. 00535 iterator_object will be filled by this function if next() returns 0. 00536 Content of the iterator_object depend on iterator type. 00537 */ 00538 int (*next)(struct handler_iterator *, void *iterator_object); 00539 /* 00540 Free resources allocated by iterator, after this call iterator 00541 is not usable. 00542 */ 00543 void (*destroy)(struct handler_iterator *); 00544 /* 00545 Pointer to buffer for the iterator to use. 00546 Should be allocated by function which created the iterator and 00547 destroied by freed by above "destroy" call 00548 */ 00549 void *buffer; 00550 }; 00551 00552 /* 00553 handlerton is a singleton structure - one instance per storage engine - 00554 to provide access to storage engine functionality that works on the 00555 "global" level (unlike handler class that works on a per-table basis) 00556 00557 usually handlerton instance is defined statically in ha_xxx.cc as 00558 00559 static handlerton { ... } xxx_hton; 00560 00561 savepoint_*, prepare, recover, and *_by_xid pointers can be 0. 00562 */ 00563 struct handlerton 00564 { 00565 /* 00566 Historical marker for if the engine is available of not 00567 */ 00568 SHOW_COMP_OPTION state; 00569 00570 /* 00571 Historical number used for frm file to determine the correct storage engine. 00572 This is going away and new engines will just use "name" for this. 00573 */ 00574 enum legacy_db_type db_type; 00575 /* 00576 each storage engine has it's own memory area (actually a pointer) 00577 in the thd, for storing per-connection information. 00578 It is accessed as 00579 00580 thd->ha_data[xxx_hton.slot] 00581 00582 slot number is initialized by MySQL after xxx_init() is called. 00583 */ 00584 uint slot; 00585 /* 00586 to store per-savepoint data storage engine is provided with an area 00587 of a requested size (0 is ok here). 00588 savepoint_offset must be initialized statically to the size of 00589 the needed memory to store per-savepoint information. 00590 After xxx_init it is changed to be an offset to savepoint storage 00591 area and need not be used by storage engine. 00592 see binlog_hton and binlog_savepoint_set/rollback for an example. 00593 */ 00594 uint savepoint_offset; 00595 /* 00596 handlerton methods: 00597 00598 close_connection is only called if 00599 thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need 00600 this storage area - set it to something, so that MySQL would know 00601 this storage engine was accessed in this connection 00602 */ 00603 int (*close_connection)(THD *thd); 00604 /* 00605 sv points to an uninitialized storage area of requested size 00606 (see savepoint_offset description) 00607 */ 00608 int (*savepoint_set)(THD *thd, void *sv); 00609 /* 00610 sv points to a storage area, that was earlier passed 00611 to the savepoint_set call 00612 */ 00613 int (*savepoint_rollback)(THD *thd, void *sv); 00614 int (*savepoint_release)(THD *thd, void *sv); 00615 /* 00616 'all' is true if it's a real commit, that makes persistent changes 00617 'all' is false if it's not in fact a commit but an end of the 00618 statement that is part of the transaction. 00619 NOTE 'all' is also false in auto-commit mode where 'end of statement' 00620 and 'real commit' mean the same event. 00621 */ 00622 int (*commit)(THD *thd, bool all); 00623 int (*rollback)(THD *thd, bool all); 00624 int (*prepare)(THD *thd, bool all); 00625 int (*recover)(XID *xid_list, uint len); 00626 int (*commit_by_xid)(XID *xid); 00627 int (*rollback_by_xid)(XID *xid); 00628 void *(*create_cursor_read_view)(); 00629 void (*set_cursor_read_view)(void *); 00630 void (*close_cursor_read_view)(void *); 00631 handler *(*create)(TABLE_SHARE *table, MEM_ROOT *mem_root); 00632 void (*drop_database)(char* path); 00633 int (*panic)(enum ha_panic_function flag); 00634 int (*start_consistent_snapshot)(THD *thd); 00635 bool (*flush_logs)(); 00636 bool (*show_status)(THD *thd, stat_print_fn *print, enum ha_stat_type stat); 00637 uint (*partition_flags)(); 00638 uint (*alter_table_flags)(uint flags); 00639 int (*alter_tablespace)(THD *thd, st_alter_tablespace *ts_info); 00640 int (*fill_files_table)(THD *thd, 00641 struct st_table_list *tables, 00642 class Item *cond); 00643 uint32 flags; /* global handler flags */ 00644 /* 00645 Those handlerton functions below are properly initialized at handler 00646 init. 00647 */ 00648 int (*binlog_func)(THD *thd, enum_binlog_func fn, void *arg); 00649 void (*binlog_log_query)(THD *thd, enum_binlog_command binlog_command, 00650 const char *query, uint query_length, 00651 const char *db, const char *table_name); 00652 int (*release_temporary_latches)(THD *thd); 00653 00654 /* 00655 Get log status. 00656 If log_status is null then the handler do not support transaction 00657 log information (i.e. log iterator can't be created). 00658 (see example of implementation in handler.cc, TRANS_LOG_MGM_EXAMPLE_CODE) 00659 00660 */ 00661 enum log_status (*get_log_status)(char *log); 00662 00663 /* 00664 Iterators creator. 00665 Presence of the pointer should be checked before using 00666 */ 00667 enum handler_create_iterator_result 00668 (*create_iterator)(enum handler_iterator_type type, 00669 struct handler_iterator *fill_this_in); 00670 }; 00671 00672 00673 /* Possible flags of a handlerton */ 00674 #define HTON_NO_FLAGS 0 00675 #define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0) 00676 #define HTON_ALTER_NOT_SUPPORTED (1 << 1) //Engine does not support alter 00677 #define HTON_CAN_RECREATE (1 << 2) //Delete all is used fro truncate 00678 #define HTON_HIDDEN (1 << 3) //Engine does not appear in lists 00679 #define HTON_FLUSH_AFTER_RENAME (1 << 4) 00680 #define HTON_NOT_USER_SELECTABLE (1 << 5) 00681 #define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported 00682 00683 typedef struct st_thd_trans 00684 { 00685 /* number of entries in the ht[] */ 00686 uint nht; 00687 /* true is not all entries in the ht[] support 2pc */ 00688 bool no_2pc; 00689 /* storage engines that registered themselves for this transaction */ 00690 handlerton *ht[MAX_HA]; 00691 } THD_TRANS; 00692 00693 enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED, 00694 ISO_REPEATABLE_READ, ISO_SERIALIZABLE}; 00695 00696 00697 enum ndb_distribution { ND_KEYHASH= 0, ND_LINHASH= 1 }; 00698 00699 00700 typedef struct { 00701 ulonglong data_file_length; 00702 ulonglong max_data_file_length; 00703 ulonglong index_file_length; 00704 ulonglong delete_length; 00705 ha_rows records; 00706 ulong mean_rec_length; 00707 time_t create_time; 00708 time_t check_time; 00709 time_t update_time; 00710 ulonglong check_sum; 00711 } PARTITION_INFO; 00712 00713 #define UNDEF_NODEGROUP 65535 00714 class Item; 00715 struct st_table_log_memory_entry; 00716 00717 class partition_info; 00718 00719 struct st_partition_iter; 00720 #define NOT_A_PARTITION_ID ((uint32)-1) 00721 00722 00723 typedef struct st_ha_create_information 00724 { 00725 CHARSET_INFO *table_charset, *default_table_charset; 00726 LEX_STRING connect_string; 00727 const char *password, *tablespace; 00728 LEX_STRING comment; 00729 const char *data_file_name, *index_file_name; 00730 const char *alias; 00731 ulonglong max_rows,min_rows; 00732 ulonglong auto_increment_value; 00733 ulong table_options; 00734 ulong avg_row_length; 00735 ulong used_fields; 00736 ulong key_block_size; 00737 SQL_LIST merge_list; 00738 handlerton *db_type; 00739 enum row_type row_type; 00740 uint null_bits; /* NULL bits at start of record */ 00741 uint options; /* OR of HA_CREATE_ options */ 00742 uint merge_insert_method; 00743 uint extra_size; /* length of extra data segment */ 00744 bool table_existed; /* 1 in create if table existed */ 00745 bool frm_only; /* 1 if no ha_create_table() */ 00746 bool varchar; /* 1 if table has a VARCHAR */ 00747 bool store_on_disk; /* 1 if table stored on disk */ 00748 } HA_CREATE_INFO; 00749 00750 00751 typedef struct st_key_create_information 00752 { 00753 enum ha_key_alg algorithm; 00754 ulong block_size; 00755 LEX_STRING parser_name; 00756 } KEY_CREATE_INFO; 00757 00758 00759 /* 00760 Class for maintaining hooks used inside operations on tables such 00761 as: create table functions, delete table functions, and alter table 00762 functions. 00763 00764 Class is using the Template Method pattern to separate the public 00765 usage interface from the private inheritance interface. This 00766 imposes no overhead, since the public non-virtual function is small 00767 enough to be inlined. 00768 00769 The hooks are usually used for functions that does several things, 00770 e.g., create_table_from_items(), which both create a table and lock 00771 it. 00772 */ 00773 class TABLEOP_HOOKS 00774 { 00775 public: 00776 inline void prelock(TABLE **tables, uint count) 00777 { 00778 do_prelock(tables, count); 00779 } 00780 virtual ~TABLEOP_HOOKS() {} 00781 TABLEOP_HOOKS() {} 00782 00783 private: 00784 /* Function primitive that is called prior to locking tables */ 00785 virtual void do_prelock(TABLE **tables, uint count) 00786 { 00787 /* Default is to do nothing */ 00788 } 00789 }; 00790 00791 typedef struct st_savepoint SAVEPOINT; 00792 extern ulong savepoint_alloc_size; 00793 extern KEY_CREATE_INFO default_key_create_info; 00794 00795 /* Forward declaration for condition pushdown to storage engine */ 00796 typedef class Item COND; 00797 00798 typedef struct st_ha_check_opt 00799 { 00800 st_ha_check_opt() {} /* Remove gcc warning */ 00801 ulong sort_buffer_size; 00802 uint flags; /* isam layer flags (e.g. for myisamchk) */ 00803 uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ 00804 KEY_CACHE *key_cache; /* new key cache when changing key cache */ 00805 void init(); 00806 } HA_CHECK_OPT; 00807 00808 00809 00810 /* 00811 This is a buffer area that the handler can use to store rows. 00812 'end_of_used_area' should be kept updated after calls to 00813 read-functions so that other parts of the code can use the 00814 remaining area (until next read calls is issued). 00815 */ 00816 00817 typedef struct st_handler_buffer 00818 { 00819 const byte *buffer; /* Buffer one can start using */ 00820 const byte *buffer_end; /* End of buffer */ 00821 byte *end_of_used_area; /* End of area that was used by handler */ 00822 } HANDLER_BUFFER; 00823 00824 typedef struct system_status_var SSV; 00825 00826 class ha_statistics 00827 { 00828 public: 00829 ulonglong data_file_length; /* Length off data file */ 00830 ulonglong max_data_file_length; /* Length off data file */ 00831 ulonglong index_file_length; 00832 ulonglong max_index_file_length; 00833 ulonglong delete_length; /* Free bytes */ 00834 ulonglong auto_increment_value; 00835 ha_rows records; /* Estimated records in table */ 00836 ha_rows deleted; /* Deleted records */ 00837 ulong mean_rec_length; /* physical reclength */ 00838 time_t create_time; /* When table was created */ 00839 time_t check_time; 00840 time_t update_time; 00841 uint block_size; /* index block size */ 00842 00843 ha_statistics(): 00844 data_file_length(0), max_data_file_length(0), 00845 index_file_length(0), delete_length(0), auto_increment_value(0), 00846 records(0), deleted(0), mean_rec_length(0), create_time(0), 00847 check_time(0), update_time(0), block_size(0) 00848 {} 00849 }; 00850 00851 /* 00852 The handler class is the interface for dynamically loadable 00853 storage engines. Do not add ifdefs and take care when adding or 00854 changing virtual functions to avoid vtable confusion 00855 */ 00856 00857 class handler :public Sql_alloc 00858 { 00859 friend class ha_partition; 00860 00861 protected: 00862 struct st_table_share *table_share; /* The table definition */ 00863 struct st_table *table; /* The current open table */ 00864 ulonglong cached_table_flags; /* Set on init() and open() */ 00865 00866 virtual int index_init(uint idx, bool sorted) { active_index=idx; return 0; } 00867 virtual int index_end() { active_index=MAX_KEY; return 0; } 00868 /* 00869 rnd_init() can be called two times without rnd_end() in between 00870 (it only makes sense if scan=1). 00871 then the second call should prepare for the new table scan (e.g 00872 if rnd_init allocates the cursor, second call should position it 00873 to the start of the table, no need to deallocate and allocate it again 00874 */ 00875 virtual int rnd_init(bool scan) =0; 00876 virtual int rnd_end() { return 0; } 00877 virtual ulonglong table_flags(void) const =0; 00878 void ha_statistic_increment(ulong SSV::*offset) const; 00879 00880 ha_rows estimation_rows_to_insert; 00881 virtual void start_bulk_insert(ha_rows rows) {} 00882 virtual int end_bulk_insert() {return 0; } 00883 public: 00884 const handlerton *ht; /* storage engine of this handler */ 00885 byte *ref; /* Pointer to current row */ 00886 byte *dup_ref; /* Pointer to duplicate row */ 00887 00888 ha_statistics stats; 00889 00890 /* The following are for read_multi_range */ 00891 bool multi_range_sorted; 00892 KEY_MULTI_RANGE *multi_range_curr; 00893 KEY_MULTI_RANGE *multi_range_end; 00894 HANDLER_BUFFER *multi_range_buffer; 00895 00896 /* The following are for read_range() */ 00897 key_range save_end_range, *end_range; 00898 KEY_PART_INFO *range_key_part; 00899 int key_compare_result_on_equal; 00900 bool eq_range; 00901 00902 uint errkey; /* Last dup key */ 00903 uint key_used_on_scan; 00904 uint active_index; 00905 /* Length of ref (1-8 or the clustered key length) */ 00906 uint ref_length; 00907 FT_INFO *ft_handler; 00908 enum {NONE=0, INDEX, RND} inited; 00909 bool implicit_emptied; /* Can be !=0 only if HEAP */ 00910 const COND *pushed_cond; 00911 /* 00912 next_insert_id is the next value which should be inserted into the 00913 auto_increment column: in a inserting-multi-row statement (like INSERT 00914 SELECT), for the first row where the autoinc value is not specified by the 00915 statement, get_auto_increment() called and asked to generate a value, 00916 next_insert_id is set to the next value, then for all other rows 00917 next_insert_id is used (and increased each time) without calling 00918 get_auto_increment(). 00919 */ 00920 ulonglong next_insert_id; 00921 /* 00922 insert id for the current row (*autogenerated*; if not 00923 autogenerated, it's 0). 00924 At first successful insertion, this variable is stored into 00925 THD::first_successful_insert_id_in_cur_stmt. 00926 */ 00927 ulonglong insert_id_for_cur_row; 00928 /* 00929 Interval returned by get_auto_increment() and being consumed by the 00930 inserter. 00931 */ 00932 Discrete_interval auto_inc_interval_for_cur_row; 00933 00934 handler(const handlerton *ht_arg, TABLE_SHARE *share_arg) 00935 :table_share(share_arg), estimation_rows_to_insert(0), ht(ht_arg), 00936 ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), 00937 ref_length(sizeof(my_off_t)), 00938 ft_handler(0), inited(NONE), implicit_emptied(0), 00939 pushed_cond(NULL), next_insert_id(0), insert_id_for_cur_row(0) 00940 {} 00941 virtual ~handler(void) 00942 { 00943 /* TODO: DBUG_ASSERT(inited == NONE); */ 00944 } 00945 /* This is called after create to allow us to set up cached variables */ 00946 void init() 00947 { 00948 cached_table_flags= table_flags(); 00949 } 00950 /* 00951 Check whether a handler allows to lock the table. 00952 00953 SYNOPSIS 00954 check_if_locking_is_allowed() 00955 thd Handler of the thread, trying to lock the table 00956 table Table handler to check 00957 count Number of locks already granted to the table 00958 00959 DESCRIPTION 00960 Check whether a handler allows to lock the table. For instance, 00961 MyISAM does not allow to lock mysql.proc along with other tables. 00962 This limitation stems from the fact that MyISAM does not support 00963 row-level locking and we have to add this limitation to avoid 00964 deadlocks. 00965 00966 RETURN 00967 TRUE Locking is allowed 00968 FALSE Locking is not allowed. The error was thrown. 00969 */ 00970 virtual bool check_if_locking_is_allowed(uint sql_command, 00971 ulong type, TABLE *table, 00972 uint count, 00973 bool called_by_logger_thread) 00974 { 00975 return TRUE; 00976 } 00977 bool check_if_log_table_locking_is_allowed(uint sql_command, 00978 ulong type, TABLE *table); 00979 int ha_open(TABLE *table, const char *name, int mode, int test_if_locked); 00980 void adjust_next_insert_id_after_explicit_value(ulonglong nr); 00981 bool update_auto_increment(); 00982 void print_keydup_error(uint key_nr, const char *msg); 00983 virtual void print_error(int error, myf errflag); 00984 virtual bool get_error_message(int error, String *buf); 00985 uint get_dup_key(int error); 00986 void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) 00987 { 00988 table= table_arg; 00989 table_share= share; 00990 } 00991 virtual double scan_time() 00992 { return ulonglong2double(stats.data_file_length) / IO_SIZE + 2; } 00993 virtual double read_time(uint index, uint ranges, ha_rows rows) 00994 { return rows2double(ranges+rows); } 00995 virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; } 00996 bool has_transactions() 00997 { return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0; } 00998 virtual uint extra_rec_buf_length() const { return 0; } 00999 01000 /* 01001 This method is used to analyse the error to see whether the error 01002 is ignorable or not, certain handlers can have more error that are 01003 ignorable than others. E.g. the partition handler can get inserts 01004 into a range where there is no partition and this is an ignorable 01005 error. 01006 HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the 01007 same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to 01008 a slightly different error message. 01009 */ 01010 virtual bool is_fatal_error(int error, uint flags) 01011 { 01012 if (!error || 01013 ((flags & HA_CHECK_DUP_KEY) && 01014 (error == HA_ERR_FOUND_DUPP_KEY || 01015 error == HA_ERR_FOUND_DUPP_UNIQUE))) 01016 return FALSE; 01017 return TRUE; 01018 } 01019 01020 /* 01021 Number of rows in table. It will only be called if 01022 (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0 01023 */ 01024 virtual ha_rows records() { return stats.records; } 01025 /* 01026 Return upper bound of current number of records in the table 01027 (max. of how many records one will retrieve when doing a full table scan) 01028 If upper bound is not known, HA_POS_ERROR should be returned as a max 01029 possible upper bound. 01030 */ 01031 virtual ha_rows estimate_rows_upper_bound() 01032 { return stats.records+EXTRA_RECORDS; } 01033 01034 /* 01035 Get the row type from the storage engine. If this method returns 01036 ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used. 01037 */ 01038 virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; } 01039 01040 virtual const char *index_type(uint key_number) { DBUG_ASSERT(0); return "";} 01041 01042 int ha_index_init(uint idx, bool sorted) 01043 { 01044 DBUG_ENTER("ha_index_init"); 01045 DBUG_ASSERT(inited==NONE); 01046 inited=INDEX; 01047 DBUG_RETURN(index_init(idx, sorted)); 01048 } 01049 int ha_index_end() 01050 { 01051 DBUG_ENTER("ha_index_end"); 01052 DBUG_ASSERT(inited==INDEX); 01053 inited=NONE; 01054 DBUG_RETURN(index_end()); 01055 } 01056 int ha_rnd_init(bool scan) 01057 { 01058 DBUG_ENTER("ha_rnd_init"); 01059 DBUG_ASSERT(inited==NONE || (inited==RND && scan)); 01060 inited=RND; 01061 DBUG_RETURN(rnd_init(scan)); 01062 } 01063 int ha_rnd_end() 01064 { 01065 DBUG_ENTER("ha_rnd_end"); 01066 DBUG_ASSERT(inited==RND); 01067 inited=NONE; 01068 DBUG_RETURN(rnd_end()); 01069 } 01070 int ha_reset(); 01071 01072 /* this is necessary in many places, e.g. in HANDLER command */ 01073 int ha_index_or_rnd_end() 01074 { 01075 return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0; 01076 } 01077 longlong ha_table_flags() { return cached_table_flags; } 01078 01079 /* 01080 Signal that the table->read_set and table->write_set table maps changed 01081 The handler is allowed to set additional bits in the above map in this 01082 call. Normally the handler should ignore all calls until we have done 01083 a ha_rnd_init() or ha_index_init(), write_row(), update_row or delete_row() 01084 as there may be several calls to this routine. 01085 */ 01086 virtual void column_bitmaps_signal(); 01087 uint get_index(void) const { return active_index; } 01088 virtual int open(const char *name, int mode, uint test_if_locked)=0; 01089 virtual int close(void)=0; 01090 01091 /* 01092 These functions represent the public interface to *users* of the 01093 handler class, hence they are *not* virtual. For the inheritance 01094 interface, see the (private) functions write_row(), update_row(), 01095 and delete_row() below. 01096 */ 01097 int ha_external_lock(THD *thd, int lock_type); 01098 int ha_write_row(byte * buf); 01099 int ha_update_row(const byte * old_data, byte * new_data); 01100 int ha_delete_row(const byte * buf); 01101 01102 /* 01103 SYNOPSIS 01104 start_bulk_update() 01105 RETURN 01106 0 Bulk update used by handler 01107 1 Bulk update not used, normal operation used 01108 */ 01109 virtual bool start_bulk_update() { return 1; } 01110 /* 01111 SYNOPSIS 01112 start_bulk_delete() 01113 RETURN 01114 0 Bulk delete used by handler 01115 1 Bulk delete not used, normal operation used 01116 */ 01117 virtual bool start_bulk_delete() { return 1; } 01118 /* 01119 SYNOPSIS 01120 This method is similar to update_row, however the handler doesn't need 01121 to execute the updates at this point in time. The handler can be certain 01122 that another call to bulk_update_row will occur OR a call to 01123 exec_bulk_update before the set of updates in this query is concluded. 01124 01125 bulk_update_row() 01126 old_data Old record 01127 new_data New record 01128 dup_key_found Number of duplicate keys found 01129 RETURN 01130 0 Bulk delete used by handler 01131 1 Bulk delete not used, normal operation used 01132 */ 01133 virtual int bulk_update_row(const byte *old_data, byte *new_data, 01134 uint *dup_key_found) 01135 { 01136 DBUG_ASSERT(FALSE); 01137 return HA_ERR_WRONG_COMMAND; 01138 } 01139 /* 01140 SYNOPSIS 01141 After this call all outstanding updates must be performed. The number 01142 of duplicate key errors are reported in the duplicate key parameter. 01143 It is allowed to continue to the batched update after this call, the 01144 handler has to wait until end_bulk_update with changing state. 01145 01146 exec_bulk_update() 01147 dup_key_found Number of duplicate keys found 01148 RETURN 01149 0 Success 01150 >0 Error code 01151 */ 01152 virtual int exec_bulk_update(uint *dup_key_found) 01153 { 01154 DBUG_ASSERT(FALSE); 01155 return HA_ERR_WRONG_COMMAND; 01156 } 01157 /* 01158 SYNOPSIS 01159 Perform any needed clean-up, no outstanding updates are there at the 01160 moment. 01161 01162 end_bulk_update() 01163 RETURN 01164 Nothing 01165 */ 01166 virtual void end_bulk_update() { return; } 01167 /* 01168 SYNOPSIS 01169 Execute all outstanding deletes and close down the bulk delete. 01170 01171 end_bulk_delete() 01172 RETURN 01173 0 Success 01174 >0 Error code 01175 */ 01176 virtual int end_bulk_delete() 01177 { 01178 DBUG_ASSERT(FALSE); 01179 return HA_ERR_WRONG_COMMAND; 01180 } 01181 virtual int index_read(byte * buf, const byte * key, 01182 uint key_len, enum ha_rkey_function find_flag) 01183 { return HA_ERR_WRONG_COMMAND; } 01184 virtual int index_read_idx(byte * buf, uint index, const byte * key, 01185 uint key_len, enum ha_rkey_function find_flag); 01186 virtual int index_next(byte * buf) 01187 { return HA_ERR_WRONG_COMMAND; } 01188 virtual int index_prev(byte * buf) 01189 { return HA_ERR_WRONG_COMMAND; } 01190 virtual int index_first(byte * buf) 01191 { return HA_ERR_WRONG_COMMAND; } 01192 virtual int index_last(byte * buf) 01193 { return HA_ERR_WRONG_COMMAND; } 01194 virtual int index_next_same(byte *buf, const byte *key, uint keylen); 01195 virtual int index_read_last(byte * buf, const byte * key, uint key_len) 01196 { return (my_errno=HA_ERR_WRONG_COMMAND); } 01197 virtual int read_multi_range_first(KEY_MULTI_RANGE **found_range_p, 01198 KEY_MULTI_RANGE *ranges, uint range_count, 01199 bool sorted, HANDLER_BUFFER *buffer); 01200 virtual int read_multi_range_next(KEY_MULTI_RANGE **found_range_p); 01201 virtual int read_range_first(const key_range *start_key, 01202 const key_range *end_key, 01203 bool eq_range, bool sorted); 01204 virtual int read_range_next(); 01205 int compare_key(key_range *range); 01206 virtual int ft_init() { return HA_ERR_WRONG_COMMAND; } 01207 void ft_end() { ft_handler=NULL; } 01208 virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key) 01209 { return NULL; } 01210 virtual int ft_read(byte *buf) { return HA_ERR_WRONG_COMMAND; } 01211 virtual int rnd_next(byte *buf)=0; 01212 virtual int rnd_pos(byte * buf, byte *pos)=0; 01213 virtual int read_first_row(byte *buf, uint primary_key); 01214 /* 01215 The following function is only needed for tables that may be temporary 01216 tables during joins 01217 */ 01218 virtual int restart_rnd_next(byte *buf, byte *pos) 01219 { return HA_ERR_WRONG_COMMAND; } 01220 virtual int rnd_same(byte *buf, uint inx) 01221 { return HA_ERR_WRONG_COMMAND; } 01222 virtual ha_rows records_in_range(uint inx, key_range *min_key, 01223 key_range *max_key) 01224 { return (ha_rows) 10; } 01225 virtual void position(const byte *record)=0; 01226 virtual void info(uint)=0; // see my_base.h for full description 01227 virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info, 01228 uint part_id); 01229 virtual int extra(enum ha_extra_function operation) 01230 { return 0; } 01231 virtual int extra_opt(enum ha_extra_function operation, ulong cache_size) 01232 { return extra(operation); } 01233 01234 /* 01235 Reset state of file to after 'open' 01236 This function is called after every statement for all tables used 01237 by that statement. 01238 */ 01239 virtual int reset() { return 0; } 01240 /* 01241 In an UPDATE or DELETE, if the row under the cursor was locked by another 01242 transaction, and the engine used an optimistic read of the last 01243 committed row value under the cursor, then the engine returns 1 from this 01244 function. MySQL must NOT try to update this optimistic value. If the 01245 optimistic value does not match the WHERE condition, MySQL can decide to 01246 skip over this row. Currently only works for InnoDB. This can be used to 01247 avoid unnecessary lock waits. 01248 01249 If this method returns nonzero, it will also signal the storage 01250 engine that the next read will be a locking re-read of the row. 01251 */ 01252 virtual bool was_semi_consistent_read() { return 0; } 01253 /* 01254 Tell the engine whether it should avoid unnecessary lock waits. 01255 If yes, in an UPDATE or DELETE, if the row under the cursor was locked 01256 by another transaction, the engine may try an optimistic read of 01257 the last committed row value under the cursor. 01258 */ 01259 virtual void try_semi_consistent_read(bool) {} 01260 virtual void unlock_row() {} 01261 virtual int start_stmt(THD *thd, thr_lock_type lock_type) {return 0;} 01262 /* 01263 This is called to delete all rows in a table 01264 If the handler don't support this, then this function will 01265 return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one 01266 by one. 01267 */ 01268 virtual int delete_all_rows() 01269 { return (my_errno=HA_ERR_WRONG_COMMAND); } 01270 virtual void get_auto_increment(ulonglong offset, ulonglong increment, 01271 ulonglong nb_desired_values, 01272 ulonglong *first_value, 01273 ulonglong *nb_reserved_values); 01274 private: 01275 virtual void release_auto_increment() { return; }; 01276 public: 01277 void ha_release_auto_increment(); 01278 void set_next_insert_id(ulonglong id) 01279 { 01280 DBUG_PRINT("info",("auto_increment: next value %lu", (ulong)id)); 01281 next_insert_id= id; 01282 } 01283 void restore_auto_increment(ulonglong prev_insert_id) 01284 { 01285 /* 01286 Insertion of a row failed, re-use the lastly generated auto_increment 01287 id, for the next row. This is achieved by resetting next_insert_id to 01288 what it was before the failed insertion (that old value is provided by 01289 the caller). If that value was 0, it was the first row of the INSERT; 01290 then if insert_id_for_cur_row contains 0 it means no id was generated 01291 for this first row, so no id was generated since the INSERT started, so 01292 we should set next_insert_id to 0; if insert_id_for_cur_row is not 0, it 01293 is the generated id of the first and failed row, so we use it. 01294 */ 01295 next_insert_id= (prev_insert_id > 0) ? prev_insert_id : 01296 insert_id_for_cur_row; 01297 } 01298 /* 01299 Reset the auto-increment counter to the given value, i.e. the next row 01300 inserted will get the given value. This is called e.g. after TRUNCATE 01301 is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is 01302 returned by storage engines that don't support this operation. 01303 */ 01304 virtual int reset_auto_increment(ulonglong value) 01305 { return HA_ERR_WRONG_COMMAND; } 01306 01307 virtual void update_create_info(HA_CREATE_INFO *create_info) {} 01308 protected: 01309 /* to be implemented in handlers */ 01310 01311 /* admin commands - called from mysql_admin_table */ 01312 virtual int check(THD* thd, HA_CHECK_OPT* check_opt) 01313 { return HA_ADMIN_NOT_IMPLEMENTED; } 01314 01315 /* 01316 in these two methods check_opt can be modified 01317 to specify CHECK option to use to call check() 01318 upon the table 01319 */ 01320 virtual int check_for_upgrade(HA_CHECK_OPT *check_opt) 01321 { return 0; } 01322 public: 01323 int ha_check_for_upgrade(HA_CHECK_OPT *check_opt); 01324 int check_old_types(); 01325 /* to be actually called to get 'check()' functionality*/ 01326 int ha_check(THD *thd, HA_CHECK_OPT *check_opt); 01327 01328 virtual int backup(THD* thd, HA_CHECK_OPT* check_opt) 01329 { return HA_ADMIN_NOT_IMPLEMENTED; } 01330 /* 01331 restore assumes .frm file must exist, and that generate_table() has been 01332 called; It will just copy the data file and run repair. 01333 */ 01334 virtual int restore(THD* thd, HA_CHECK_OPT* check_opt) 01335 { return HA_ADMIN_NOT_IMPLEMENTED; } 01336 protected: 01337 virtual int repair(THD* thd, HA_CHECK_OPT* check_opt) 01338 { return HA_ADMIN_NOT_IMPLEMENTED; } 01339 public: 01340 int ha_repair(THD* thd, HA_CHECK_OPT* check_opt); 01341 virtual int optimize(THD* thd, HA_CHECK_OPT* check_opt) 01342 { return HA_ADMIN_NOT_IMPLEMENTED; } 01343 virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt) 01344 { return HA_ADMIN_NOT_IMPLEMENTED; } 01345 virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt) 01346 { return HA_ADMIN_NOT_IMPLEMENTED; } 01347 virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt) 01348 { return HA_ADMIN_NOT_IMPLEMENTED; } 01349 /* end of the list of admin commands */ 01350 01351 virtual bool check_and_repair(THD *thd) { return HA_ERR_WRONG_COMMAND; } 01352 virtual int dump(THD* thd, int fd = -1) { return HA_ERR_WRONG_COMMAND; } 01353 virtual int disable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; } 01354 virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; } 01355 virtual int indexes_are_disabled(void) {return 0;} 01356 void ha_start_bulk_insert(ha_rows rows) 01357 { 01358 estimation_rows_to_insert= rows; 01359 start_bulk_insert(rows); 01360 } 01361 int ha_end_bulk_insert() 01362 { 01363 estimation_rows_to_insert= 0; 01364 return end_bulk_insert(); 01365 } 01366 virtual int discard_or_import_tablespace(my_bool discard) 01367 {return HA_ERR_WRONG_COMMAND;} 01368 virtual int net_read_dump(NET* net) { return HA_ERR_WRONG_COMMAND; } 01369 virtual char *update_table_comment(const char * comment) 01370 { return (char*) comment;} 01371 virtual void append_create_info(String *packet) {} 01372 /* 01373 SYNOPSIS 01374 is_fk_defined_on_table_or_index() 01375 index Index to check if foreign key uses it 01376 RETURN VALUE 01377 TRUE Foreign key defined on table or index 01378 FALSE No foreign key defined 01379 DESCRIPTION 01380 If index == MAX_KEY then a check for table is made and if index < 01381 MAX_KEY then a check is made if the table has foreign keys and if 01382 a foreign key uses this index (and thus the index cannot be dropped). 01383 */ 01384 virtual bool is_fk_defined_on_table_or_index(uint index) 01385 { return FALSE; } 01386 virtual char* get_foreign_key_create_info() 01387 { return(NULL);} /* gets foreign key create string from InnoDB */ 01388 virtual char* get_tablespace_name(THD *thd) 01389 { return(NULL);} /* gets tablespace name from handler */ 01390 /* used in ALTER TABLE; 1 if changing storage engine is allowed */ 01391 virtual bool can_switch_engines() { return 1; } 01392 /* used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */ 01393 virtual int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) 01394 { return 0; } 01395 virtual uint referenced_by_foreign_key() { return 0;} 01396 virtual void init_table_handle_for_HANDLER() 01397 { return; } /* prepare InnoDB for HANDLER */ 01398 virtual void free_foreign_key_create_info(char* str) {} 01399 /* The following can be called without an open handler */ 01400 virtual const char *table_type() const =0; 01401 virtual const char **bas_ext() const =0; 01402 01403 virtual int get_default_no_partitions(HA_CREATE_INFO *info) { return 1;} 01404 virtual void set_auto_partitions(partition_info *part_info) { return; } 01405 virtual bool get_no_parts(const char *name, 01406 uint *no_parts) 01407 { 01408 *no_parts= 0; 01409 return 0; 01410 } 01411 virtual void set_part_info(partition_info *part_info) {return;} 01412 01413 virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0; 01414 01415 virtual void prepare_for_alter() { return; } 01416 virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) 01417 { return (HA_ERR_WRONG_COMMAND); } 01418 virtual int prepare_drop_index(TABLE *table_arg, uint *key_num, 01419 uint num_of_keys) 01420 { return (HA_ERR_WRONG_COMMAND); } 01421 virtual int final_drop_index(TABLE *table_arg) 01422 { return (HA_ERR_WRONG_COMMAND); } 01423 01424 uint max_record_length() const 01425 { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); } 01426 uint max_keys() const 01427 { return min(MAX_KEY, max_supported_keys()); } 01428 uint max_key_parts() const 01429 { return min(MAX_REF_PARTS, max_supported_key_parts()); } 01430 uint max_key_length() const 01431 { return min(MAX_KEY_LENGTH, max_supported_key_length()); } 01432 uint max_key_part_length() const 01433 { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); } 01434 01435 virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; } 01436 virtual uint max_supported_keys() const { return 0; } 01437 virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; } 01438 virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; } 01439 virtual uint max_supported_key_part_length() const { return 255; } 01440 virtual uint min_record_length(uint options) const { return 1; } 01441 01442 virtual bool low_byte_first() const { return 1; } 01443 virtual uint checksum() const { return 0; } 01444 virtual bool is_crashed() const { return 0; } 01445 virtual bool auto_repair() const { return 0; } 01446 01447 /* 01448 default rename_table() and delete_table() rename/delete files with a 01449 given name and extensions from bas_ext() 01450 */ 01451 virtual int rename_table(const char *from, const char *to); 01452 virtual int delete_table(const char *name); 01453 virtual void drop_table(const char *name); 01454 01455 virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0; 01456 01457 #define CHF_CREATE_FLAG 0 01458 #define CHF_DELETE_FLAG 1 01459 #define CHF_RENAME_FLAG 2 01460 #define CHF_INDEX_FLAG 3 01461 01462 virtual int create_handler_files(const char *name, const char *old_name, 01463 int action_flag, HA_CREATE_INFO *info) 01464 { return FALSE; } 01465 01466 virtual int change_partitions(HA_CREATE_INFO *create_info, 01467 const char *path, 01468 ulonglong *copied, 01469 ulonglong *deleted, 01470 const void *pack_frm_data, 01471 uint pack_frm_len) 01472 { return HA_ERR_WRONG_COMMAND; } 01473 virtual int drop_partitions(const char *path) 01474 { return HA_ERR_WRONG_COMMAND; } 01475 virtual int rename_partitions(const char *path) 01476 { return HA_ERR_WRONG_COMMAND; } 01477 virtual int optimize_partitions(THD *thd) 01478 { return HA_ERR_WRONG_COMMAND; } 01479 virtual int analyze_partitions(THD *thd) 01480 { return HA_ERR_WRONG_COMMAND; } 01481 virtual int check_partitions(THD *thd) 01482 { return HA_ERR_WRONG_COMMAND; } 01483 virtual int repair_partitions(THD *thd) 01484 { return HA_ERR_WRONG_COMMAND; } 01485 01486 /* lock_count() can be more than one if the table is a MERGE */ 01487 virtual uint lock_count(void) const { return 1; } 01488 virtual THR_LOCK_DATA **store_lock(THD *thd, 01489 THR_LOCK_DATA **to, 01490 enum thr_lock_type lock_type)=0; 01491 01492 /* Type of table for caching query */ 01493 virtual uint8 table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; } 01494 /* ask handler about permission to cache table when query is to be cached */ 01495 virtual my_bool register_query_cache_table(THD *thd, char *table_key, 01496 uint key_length, 01497 qc_engine_callback 01498 *engine_callback, 01499 ulonglong *engine_data) 01500 { 01501 *engine_callback= 0; 01502 return 1; 01503 } 01504 /* 01505 RETURN 01506 true Primary key (if there is one) is clustered key covering all fields 01507 false otherwise 01508 */ 01509 virtual bool primary_key_is_clustered() { return FALSE; } 01510 virtual int cmp_ref(const byte *ref1, const byte *ref2) 01511 { 01512 return memcmp(ref1, ref2, ref_length); 01513 } 01514 01515 /* 01516 Condition pushdown to storage engines 01517 */ 01518 01519 /* 01520 Push condition down to the table handler. 01521 SYNOPSIS 01522 cond_push() 01523 cond Condition to be pushed. The condition tree must not be 01524 modified by the by the caller. 01525 01526 RETURN 01527 The 'remainder' condition that caller must use to filter out records. 01528 NULL means the handler will not return rows that do not match the 01529 passed condition. 01530 01531 NOTES 01532 The pushed conditions form a stack (from which one can remove the 01533 last pushed condition using cond_pop). 01534 The table handler filters out rows using (pushed_cond1 AND pushed_cond2 01535 AND ... AND pushed_condN) 01536 or less restrictive condition, depending on handler's capabilities. 01537 01538 handler->ha_reset() call empties the condition stack. 01539 Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the 01540 condition stack. 01541 */ 01542 virtual const COND *cond_push(const COND *cond) { return cond; }; 01543 /* 01544 Pop the top condition from the condition stack of the handler instance. 01545 SYNOPSIS 01546 cond_pop() 01547 Pops the top if condition stack, if stack is not empty 01548 */ 01549 virtual void cond_pop() { return; }; 01550 virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info, 01551 uint table_changes) 01552 { return COMPATIBLE_DATA_NO; } 01553 01554 /* These are only called from sql_select for internal temporary tables */ 01555 virtual int write_row(byte *buf __attribute__((unused))) 01556 { 01557 return HA_ERR_WRONG_COMMAND; 01558 } 01559 01560 virtual int update_row(const byte *old_data __attribute__((unused)), 01561 byte *new_data __attribute__((unused))) 01562 { 01563 return HA_ERR_WRONG_COMMAND; 01564 } 01565 01566 virtual int delete_row(const byte *buf __attribute__((unused))) 01567 { 01568 return HA_ERR_WRONG_COMMAND; 01569 } 01570 /* 01571 use_hidden_primary_key() is called in case of an update/delete when 01572 (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined 01573 but we don't have a primary key 01574 */ 01575 virtual void use_hidden_primary_key(); 01576 01577 private: 01578 /* 01579 Row-level primitives for storage engines. These should be 01580 overridden by the storage engine class. To call these methods, use 01581 the corresponding 'ha_*' method above. 01582 */ 01583 virtual int external_lock(THD *thd __attribute__((unused)), 01584 int lock_type __attribute__((unused))) 01585 { 01586 return 0; 01587 } 01588 }; 01589 01590 /* Some extern variables used with handlers */ 01591 01592 extern handlerton *sys_table_types[]; 01593 extern const char *ha_row_type[]; 01594 extern TYPELIB tx_isolation_typelib; 01595 extern TYPELIB myisam_stats_method_typelib; 01596 extern ulong total_ha, total_ha_2pc; 01597 01598 /* Wrapper functions */ 01599 #define ha_commit_stmt(thd) (ha_commit_trans((thd), FALSE)) 01600 #define ha_rollback_stmt(thd) (ha_rollback_trans((thd), FALSE)) 01601 #define ha_commit(thd) (ha_commit_trans((thd), TRUE)) 01602 #define ha_rollback(thd) (ha_rollback_trans((thd), TRUE)) 01603 01604 /* lookups */ 01605 handlerton *ha_default_handlerton(THD *thd); 01606 handlerton *ha_resolve_by_name(THD *thd, const LEX_STRING *name); 01607 handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type); 01608 const char *ha_get_storage_engine(enum legacy_db_type db_type); 01609 handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, 01610 handlerton *db_type); 01611 handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type, 01612 bool no_substitute, bool report_error); 01613 01614 01615 static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type) 01616 { 01617 return (db_type == NULL) ? DB_TYPE_UNKNOWN : db_type->db_type; 01618 } 01619 01620 static inline const char *ha_resolve_storage_engine_name(const handlerton *db_type) 01621 { 01622 return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name.str; 01623 } 01624 01625 static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag) 01626 { 01627 return db_type == NULL ? FALSE : test(db_type->flags & flag); 01628 } 01629 01630 static inline bool ha_storage_engine_is_enabled(const handlerton *db_type) 01631 { 01632 return (db_type && db_type->create) ? 01633 (db_type->state == SHOW_OPTION_YES) : FALSE; 01634 } 01635 01636 /* basic stuff */ 01637 int ha_init(void); 01638 int ha_initialize_handlerton(st_plugin_int *plugin); 01639 int ha_finalize_handlerton(st_plugin_int *plugin); 01640 01641 TYPELIB *ha_known_exts(void); 01642 int ha_panic(enum ha_panic_function flag); 01643 void ha_close_connection(THD* thd); 01644 bool ha_flush_logs(handlerton *db_type); 01645 void ha_drop_database(char* path); 01646 int ha_create_table(THD *thd, const char *path, 01647 const char *db, const char *table_name, 01648 HA_CREATE_INFO *create_info, 01649 bool update_create_info); 01650 int ha_delete_table(THD *thd, handlerton *db_type, const char *path, 01651 const char *db, const char *alias, bool generate_warning); 01652 01653 /* statistics and info */ 01654 bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat); 01655 01656 /* discovery */ 01657 int ha_create_table_from_engine(THD* thd, const char *db, const char *name); 01658 int ha_discover(THD* thd, const char* dbname, const char* name, 01659 const void** frmblob, uint* frmlen); 01660 int ha_find_files(THD *thd,const char *db,const char *path, 01661 const char *wild, bool dir,List<char>* files); 01662 int ha_table_exists_in_engine(THD* thd, const char* db, const char* name); 01663 01664 /* key cache */ 01665 int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); 01666 int ha_resize_key_cache(KEY_CACHE *key_cache); 01667 int ha_change_key_cache_param(KEY_CACHE *key_cache); 01668 int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache); 01669 int ha_end_key_cache(KEY_CACHE *key_cache); 01670 01671 /* report to InnoDB that control passes to the client */ 01672 int ha_release_temporary_latches(THD *thd); 01673 01674 /* transactions: interface to handlerton functions */ 01675 int ha_start_consistent_snapshot(THD *thd); 01676 int ha_commit_or_rollback_by_xid(XID *xid, bool commit); 01677 int ha_commit_one_phase(THD *thd, bool all); 01678 int ha_rollback_trans(THD *thd, bool all); 01679 int ha_prepare(THD *thd); 01680 int ha_recover(HASH *commit_list); 01681 01682 /* transactions: these functions never call handlerton functions directly */ 01683 int ha_commit_trans(THD *thd, bool all); 01684 int ha_autocommit_or_rollback(THD *thd, int error); 01685 int ha_enable_transaction(THD *thd, bool on); 01686 01687 /* savepoints */ 01688 int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv); 01689 int ha_savepoint(THD *thd, SAVEPOINT *sv); 01690 int ha_release_savepoint(THD *thd, SAVEPOINT *sv); 01691 01692 /* these are called by storage engines */ 01693 void trans_register_ha(THD *thd, bool all, handlerton *ht); 01694 01695 /* 01696 Storage engine has to assume the transaction will end up with 2pc if 01697 - there is more than one 2pc-capable storage engine available 01698 - in the current transaction 2pc was not disabled yet 01699 */ 01700 #define trans_need_2pc(thd, all) ((total_ha_2pc > 1) && \ 01701 !((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc)) 01702 01703 #ifdef HAVE_NDB_BINLOG 01704 int ha_reset_logs(THD *thd); 01705 int ha_binlog_index_purge_file(THD *thd, const char *file); 01706 void ha_reset_slave(THD *thd); 01707 void ha_binlog_log_query(THD *thd, const handlerton *db_type, 01708 enum_binlog_command binlog_command, 01709 const char *query, uint query_length, 01710 const char *db, const char *table_name); 01711 void ha_binlog_wait(THD *thd); 01712 int ha_binlog_end(THD *thd); 01713 #else 01714 #define ha_reset_logs(a) do {} while (0) 01715 #define ha_binlog_index_purge_file(a,b) do {} while (0) 01716 #define ha_reset_slave(a) do {} while (0) 01717 #define ha_binlog_log_query(a,b,c,d,e,f,g) do {} while (0) 01718 #define ha_binlog_wait(a) do {} while (0) 01719 #define ha_binlog_end(a) do {} while (0) 01720 #endif
1.4.7

