1 /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software Foundation, 21 Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 23 24 /* This file includes constants used with all databases */ 25 26 #ifndef _my_base_h 27 #define _my_base_h 28 29 #include "my_global.h" 30 31 /* The following is bits in the flag parameter to ha_open() */ 32 33 #define HA_OPEN_ABORT_IF_LOCKED 0 /* default */ 34 #define HA_OPEN_WAIT_IF_LOCKED 1 35 #define HA_OPEN_IGNORE_IF_LOCKED 2 36 #define HA_OPEN_TMP_TABLE 4 /* Table is a temp table */ 37 #define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */ 38 #define HA_OPEN_ABORT_IF_CRASHED 16 39 #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ 40 #define HA_OPEN_FROM_SQL_LAYER 64 41 #define HA_OPEN_MMAP 128 /* open memory mapped */ 42 #define HA_OPEN_COPY 256 /* Open copy (for repair) */ 43 /* Internal temp table, used for temporary results */ 44 #define HA_OPEN_INTERNAL_TABLE 512 45 /** 46 Don't connect any share_psi to the handler, since it is a partition. 47 It would not be used, since partitions don't call unbind_psi()/rebind_psi(). 48 */ 49 #define HA_OPEN_NO_PSI_CALL 1024 /* Don't call/connect PSI */ 50 51 /* The following is parameter to ha_rkey() how to use key */ 52 53 /* 54 We define a complete-field prefix of a key value as a prefix where 55 the last included field in the prefix contains the full field, not 56 just some bytes from the start of the field. A partial-field prefix 57 is allowed to contain only a few first bytes from the last included 58 field. 59 60 Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a 61 complete-field prefix of a key value as the search 62 key. HA_READ_PREFIX and HA_READ_PREFIX_LAST could also take a 63 partial-field prefix, but currently (4.0.10) they are only used with 64 complete-field prefixes. MySQL uses a padding trick to implement 65 LIKE 'abc%' queries. 66 67 NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a 68 partial-field prefix because InnoDB currently strips spaces from the 69 end of varchar fields! 70 */ 71 72 enum ha_rkey_function { 73 HA_READ_KEY_EXACT, /* Find first record else error */ 74 HA_READ_KEY_OR_NEXT, /* Record or next record */ 75 HA_READ_KEY_OR_PREV, /* Record or previous */ 76 HA_READ_AFTER_KEY, /* Find next rec. after key-record */ 77 HA_READ_BEFORE_KEY, /* Find next rec. before key-record */ 78 HA_READ_PREFIX, /* Key which as same prefix */ 79 HA_READ_PREFIX_LAST, /* Last key with the same prefix */ 80 HA_READ_PREFIX_LAST_OR_PREV, /* Last or prev key with the same prefix */ 81 HA_READ_MBR_CONTAIN, /* Minimum Bounding Rectangle contains */ 82 HA_READ_MBR_INTERSECT, /* Minimum Bounding Rectangle intersect */ 83 HA_READ_MBR_WITHIN, /* Minimum Bounding Rectangle within */ 84 HA_READ_MBR_DISJOINT, /* Minimum Bounding Rectangle disjoint */ 85 HA_READ_MBR_EQUAL, /* Minimum Bounding Rectangle equal */ 86 HA_READ_INVALID= -1 /* Invalid enumeration value, always last. */ 87 }; 88 89 /* Key algorithm types */ 90 91 enum ha_key_alg { 92 HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */ 93 HA_KEY_ALG_BTREE= 1, /* B-tree, default one */ 94 HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */ 95 HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */ 96 HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */ 97 }; 98 99 /* Storage media types */ 100 101 enum ha_storage_media { 102 HA_SM_DEFAULT= 0, /* Not specified (engine default) */ 103 HA_SM_DISK= 1, /* DISK storage */ 104 HA_SM_MEMORY= 2 /* MAIN MEMORY storage */ 105 }; 106 107 /* The following is parameter to ha_extra() */ 108 109 enum ha_extra_function { 110 HA_EXTRA_NORMAL=0, /* Optimize for space (def) */ 111 HA_EXTRA_QUICK=1, /* Optimize for speed */ 112 HA_EXTRA_NOT_USED=2, 113 HA_EXTRA_CACHE=3, /* Cache record in HA_rrnd() */ 114 HA_EXTRA_NO_CACHE=4, /* End caching of records (def) */ 115 HA_EXTRA_NO_READCHECK=5, /* No readcheck on update */ 116 HA_EXTRA_READCHECK=6, /* Use readcheck (def) */ 117 HA_EXTRA_KEYREAD=7, /* Read only key to database */ 118 HA_EXTRA_NO_KEYREAD=8, /* Normal read of records (def) */ 119 HA_EXTRA_NO_USER_CHANGE=9, /* No user is allowed to write */ 120 HA_EXTRA_KEY_CACHE=10, 121 HA_EXTRA_NO_KEY_CACHE=11, 122 HA_EXTRA_WAIT_LOCK=12, /* Wait until file is avalably (def) */ 123 HA_EXTRA_NO_WAIT_LOCK=13, /* If file is locked, return quickly */ 124 HA_EXTRA_WRITE_CACHE=14, /* Use write cache in ha_write() */ 125 HA_EXTRA_FLUSH_CACHE=15, /* flush write_record_cache */ 126 HA_EXTRA_NO_KEYS=16, /* Remove all update of keys */ 127 HA_EXTRA_KEYREAD_CHANGE_POS=17, /* Keyread, but change pos */ 128 /* xxxxchk -r must be used */ 129 HA_EXTRA_REMEMBER_POS=18, /* Remember pos for next/prev */ 130 HA_EXTRA_RESTORE_POS=19, 131 HA_EXTRA_REINIT_CACHE=20, /* init cache from current record */ 132 HA_EXTRA_FORCE_REOPEN=21, /* Datafile have changed on disk */ 133 HA_EXTRA_FLUSH, /* Flush tables to disk */ 134 HA_EXTRA_NO_ROWS, /* Don't write rows */ 135 HA_EXTRA_RESET_STATE, /* Reset positions */ 136 HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/ 137 HA_EXTRA_NO_IGNORE_DUP_KEY, 138 HA_EXTRA_PREPARE_FOR_DROP, 139 HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ 140 HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */ 141 /* 142 On-the-fly switching between unique and non-unique key inserting. 143 */ 144 HA_EXTRA_CHANGE_KEY_TO_UNIQUE, 145 HA_EXTRA_CHANGE_KEY_TO_DUP, 146 /* 147 When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep 148 other fields intact. When this is off (by default) InnoDB will use memcpy 149 to overwrite entire row. 150 */ 151 HA_EXTRA_KEYREAD_PRESERVE_FIELDS, 152 HA_EXTRA_MMAP, 153 /* 154 Ignore if the a tuple is not found, continue processing the 155 transaction and ignore that 'row'. Needed for idempotency 156 handling on the slave 157 158 Currently only used by NDB storage engine. Partition handler ignores flag. 159 */ 160 HA_EXTRA_IGNORE_NO_KEY, 161 HA_EXTRA_NO_IGNORE_NO_KEY, 162 /* 163 Mark the table as a log table. For some handlers (e.g. CSV) this results 164 in a special locking for the table. 165 */ 166 HA_EXTRA_MARK_AS_LOG_TABLE, 167 /* 168 Informs handler that write_row() which tries to insert new row into the 169 table and encounters some already existing row with same primary/unique 170 key can replace old row with new row instead of reporting error (basically 171 it informs handler that we do REPLACE instead of simple INSERT). 172 Off by default. 173 */ 174 HA_EXTRA_WRITE_CAN_REPLACE, 175 HA_EXTRA_WRITE_CANNOT_REPLACE, 176 /* 177 Inform handler that delete_row()/update_row() cannot batch deletes/updates 178 and should perform them immediately. This may be needed when table has 179 AFTER DELETE/UPDATE triggers which access to subject table. 180 These flags are reset by the handler::extra(HA_EXTRA_RESET) call. 181 */ 182 HA_EXTRA_DELETE_CANNOT_BATCH, 183 HA_EXTRA_UPDATE_CANNOT_BATCH, 184 /* 185 Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be 186 executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY. 187 */ 188 HA_EXTRA_INSERT_WITH_UPDATE, 189 /* Inform handler that we will do a rename */ 190 HA_EXTRA_PREPARE_FOR_RENAME, 191 /* 192 Special actions for MERGE tables. 193 */ 194 HA_EXTRA_ADD_CHILDREN_LIST, 195 HA_EXTRA_ATTACH_CHILDREN, 196 HA_EXTRA_IS_ATTACHED_CHILDREN, 197 HA_EXTRA_DETACH_CHILDREN, 198 /* 199 Prepare table for export 200 (e.g. quiesce the table and write table metadata). 201 */ 202 HA_EXTRA_EXPORT, 203 /** Do secondary sort by handler::ref (rowid) after key sort. */ 204 HA_EXTRA_SECONDARY_SORT_ROWID 205 }; 206 207 /* Compatible option, to be deleted in 6.0 */ 208 #define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP 209 210 /* The following is parameter to ha_panic() */ 211 212 enum ha_panic_function { 213 HA_PANIC_CLOSE, /* Close all databases */ 214 HA_PANIC_WRITE, /* Unlock and write status */ 215 HA_PANIC_READ /* Lock and read keyinfo */ 216 }; 217 218 /* The following is parameter to ha_create(); keytypes */ 219 220 enum ha_base_keytype { 221 HA_KEYTYPE_END=0, 222 HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */ 223 HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */ 224 HA_KEYTYPE_SHORT_INT=3, 225 HA_KEYTYPE_LONG_INT=4, 226 HA_KEYTYPE_FLOAT=5, 227 HA_KEYTYPE_DOUBLE=6, 228 HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */ 229 HA_KEYTYPE_USHORT_INT=8, 230 HA_KEYTYPE_ULONG_INT=9, 231 HA_KEYTYPE_LONGLONG=10, 232 HA_KEYTYPE_ULONGLONG=11, 233 HA_KEYTYPE_INT24=12, 234 HA_KEYTYPE_UINT24=13, 235 HA_KEYTYPE_INT8=14, 236 /* Varchar (0-255 bytes) with length packed with 1 byte */ 237 HA_KEYTYPE_VARTEXT1=15, /* Key is sorted as letters */ 238 HA_KEYTYPE_VARBINARY1=16, /* Key is sorted as unsigned chars */ 239 /* Varchar (0-65535 bytes) with length packed with 2 bytes */ 240 HA_KEYTYPE_VARTEXT2=17, /* Key is sorted as letters */ 241 HA_KEYTYPE_VARBINARY2=18, /* Key is sorted as unsigned chars */ 242 HA_KEYTYPE_BIT=19 243 }; 244 245 #define HA_MAX_KEYTYPE 31 /* Must be log2-1 */ 246 247 /* These flags kan be OR:ed to key-flag */ 248 249 #define HA_NOSAME 1 /* Set if not dupplicated records */ 250 #define HA_PACK_KEY 2 /* Pack string key to previous key */ 251 #define HA_AUTO_KEY 16 252 #define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */ 253 #define HA_FULLTEXT 128 /* For full-text search */ 254 #define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */ 255 #define HA_SPATIAL 1024 /* For spatial search */ 256 #define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */ 257 #define HA_GENERATED_KEY 8192 /* Automaticly generated key */ 258 #define HA_CLUSTERING (1<<31) /* TokuDB CLUSTERING key */ 259 260 /* The combination of the above can be used for key type comparison. */ 261 #define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \ 262 HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \ 263 HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY | \ 264 HA_CLUSTERING) 265 266 /* 267 Key contains partial segments. 268 269 This flag is internal to the MySQL server by design. It is not supposed 270 neither to be saved in FRM-files, nor to be passed to storage engines. 271 It is intended to pass information into internal static sort_keys(KEY *, 272 KEY *) function. 273 274 This flag can be calculated -- it's based on key lengths comparison. 275 */ 276 #define HA_KEY_HAS_PART_KEY_SEG 65536 277 /** 278 Key was renamed (or is result of renaming a key). 279 280 This is another flag internal to SQL-layer. 281 Used by in-place ALTER TABLE implementation. 282 283 @note This flag can be set for keys which have other changes than 284 simple renaming as well. So from the point of view of storage 285 engine such key might have to be dropped and re-created with 286 new definition. 287 */ 288 #define HA_KEY_RENAMED (1 << 17) 289 /** Set if a key is on any virtual generated columns */ 290 #define HA_VIRTUAL_GEN_KEY (1 << 18) 291 292 /* Automatic bits in key-flag */ 293 294 #define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */ 295 #define HA_VAR_LENGTH_KEY 8 296 #define HA_NULL_PART_KEY 64 297 #define HA_USES_COMMENT 4096 298 #define HA_USES_PARSER 16384 /* Fulltext index uses [pre]parser */ 299 #define HA_USES_BLOCK_SIZE ((uint) 32768) 300 #define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */ 301 302 /* These flags can be added to key-seg-flag */ 303 304 #define HA_SPACE_PACK 1 /* Pack space in key-seg */ 305 #define HA_PART_KEY_SEG 4 /* Used by MySQL for part-key-cols */ 306 #define HA_VAR_LENGTH_PART 8 307 #define HA_NULL_PART 16 308 #define HA_BLOB_PART 32 309 #define HA_SWAP_KEY 64 310 #define HA_REVERSE_SORT 128 /* Sort key in reverse order */ 311 #define HA_NO_SORT 256 /* do not bother sorting on this keyseg */ 312 /* 313 End space in unique/varchar are considered equal. (Like 'a' and 'a ') 314 Only needed for internal temporary tables. 315 */ 316 #define HA_END_SPACE_ARE_EQUAL 512 317 #define HA_BIT_PART 1024 318 319 /* optionbits for database */ 320 #define HA_OPTION_PACK_RECORD 1 321 #define HA_OPTION_PACK_KEYS 2 322 #define HA_OPTION_COMPRESS_RECORD 4 323 #define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */ 324 #define HA_OPTION_TMP_TABLE 16 325 #define HA_OPTION_CHECKSUM 32 326 #define HA_OPTION_DELAY_KEY_WRITE 64 327 #define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */ 328 #define HA_OPTION_CREATE_FROM_ENGINE 256 329 #define HA_OPTION_RELIES_ON_SQL_LAYER 512 330 #define HA_OPTION_NULL_FIELDS 1024 331 #define HA_OPTION_PAGE_CHECKSUM 2048 332 /** STATS_PERSISTENT=1 has been specified in the SQL command (either CREATE 333 or ALTER TABLE). Table and index statistics that are collected by the 334 storage engine and used by the optimizer for query optimization will be 335 stored on disk and will not change after a server restart. */ 336 #define HA_OPTION_STATS_PERSISTENT 4096 337 /** STATS_PERSISTENT=0 has been specified in CREATE/ALTER TABLE. Statistics 338 for the table will be wiped away on server shutdown and new ones recalculated 339 after the server is started again. If none of HA_OPTION_STATS_PERSISTENT or 340 HA_OPTION_NO_STATS_PERSISTENT is set, this means that the setting is not 341 explicitly set at table level and the corresponding table will use whatever 342 is the global server default. */ 343 #define HA_OPTION_NO_STATS_PERSISTENT 8192 344 #define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */ 345 #define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */ 346 347 /* Bits in flag to create() */ 348 349 #define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */ 350 #define HA_PACK_RECORD 2 /* Request packed record format */ 351 #define HA_CREATE_TMP_TABLE 4 352 #define HA_CREATE_CHECKSUM 8 353 #define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */ 354 #define HA_CREATE_PAGE_CHECKSUM 32 355 #define HA_CREATE_DELAY_KEY_WRITE 64 356 #define HA_CREATE_RELIES_ON_SQL_LAYER 128 357 #define HA_CREATE_INTERNAL_TABLE 256 358 359 /* 360 The following flags (OR-ed) are passed to handler::info() method. 361 The method copies misc handler information out of the storage engine 362 to data structures accessible from MySQL 363 364 Same flags are also passed down to mi_status, myrg_status, etc. 365 */ 366 367 /* this one is not used */ 368 #define HA_STATUS_POS 1 369 /* 370 assuming the table keeps shared actual copy of the 'info' and 371 local, possibly outdated copy, the following flag means that 372 it should not try to get the actual data (locking the shared structure) 373 slightly outdated version will suffice 374 */ 375 #define HA_STATUS_NO_LOCK 2 376 /* update the time of the last modification (in handler::update_time) */ 377 #define HA_STATUS_TIME 4 378 /* 379 update the 'constant' part of the info: 380 handler::max_data_file_length, max_index_file_length, create_time 381 sortkey, ref_length, block_size, data_file_name, index_file_name. 382 handler::table->s->keys_in_use, keys_for_keyread, rec_per_key 383 */ 384 #define HA_STATUS_CONST 8 385 /* 386 update the 'variable' part of the info: 387 handler::records, deleted, data_file_length, index_file_length, 388 check_time, mean_rec_length 389 */ 390 #define HA_STATUS_VARIABLE 16 391 /* 392 get the information about the key that caused last duplicate value error 393 update handler::errkey and handler::dupp_ref 394 see handler::get_dup_key() 395 */ 396 #define HA_STATUS_ERRKEY 32 397 /* 398 update handler::auto_increment_value 399 */ 400 #define HA_STATUS_AUTO 64 401 /* 402 Get also delete_length when HA_STATUS_VARIABLE is called. It's ok to set it also 403 when only HA_STATUS_VARIABLE but it won't be used. 404 */ 405 #define HA_STATUS_VARIABLE_EXTRA 128 406 407 /* 408 Errorcodes given by handler functions 409 410 opt_sum_query() assumes these codes are > 1 411 Do not add error numbers before HA_ERR_FIRST. 412 If necessary to add lower numbers, change HA_ERR_FIRST accordingly. 413 */ 414 #define HA_ERR_FIRST 120 /* Copy of first error nr.*/ 415 416 #define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update */ 417 #define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */ 418 #define HA_ERR_INTERNAL_ERROR 122 /* Internal error */ 419 #define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */ 420 #define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */ 421 #define HA_ERR_CRASHED 126 /* Indexfile is crashed */ 422 #define HA_ERR_WRONG_IN_RECORD 127 /* Record-file is crashed */ 423 #define HA_ERR_OUT_OF_MEM 128 /* Record-file is crashed */ 424 #define HA_ERR_NOT_A_TABLE 130 /* not a MYI file - no signature */ 425 #define HA_ERR_WRONG_COMMAND 131 /* Command not supported */ 426 #define HA_ERR_OLD_FILE 132 /* old databasfile */ 427 #define HA_ERR_NO_ACTIVE_RECORD 133 /* No record read in update() */ 428 #define HA_ERR_RECORD_DELETED 134 /* A record is not there */ 429 #define HA_ERR_RECORD_FILE_FULL 135 /* No more room in file */ 430 #define HA_ERR_INDEX_FILE_FULL 136 /* No more room in file */ 431 #define HA_ERR_END_OF_FILE 137 /* end in next/prev/first/last */ 432 #define HA_ERR_UNSUPPORTED 138 /* unsupported extension used */ 433 #define HA_ERR_TOO_BIG_ROW 139 /* Too big row */ 434 #define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */ 435 #define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */ 436 #define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */ 437 #define HA_ERR_WRONG_MRG_TABLE_DEF 143 /* conflicting tables in MERGE */ 438 #define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */ 439 #define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */ 440 #define HA_ERR_LOCK_WAIT_TIMEOUT 146 441 #define HA_ERR_LOCK_TABLE_FULL 147 442 #define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */ 443 #define HA_ERR_LOCK_DEADLOCK 149 444 #define HA_ERR_CANNOT_ADD_FOREIGN 150 /* Cannot add a foreign key constr. */ 445 #define HA_ERR_NO_REFERENCED_ROW 151 /* Cannot add a child row */ 446 #define HA_ERR_ROW_IS_REFERENCED 152 /* Cannot delete a parent row */ 447 #define HA_ERR_NO_SAVEPOINT 153 /* No savepoint with that name */ 448 #define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154 /* Non unique key block size */ 449 #define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine */ 450 #define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */ 451 #define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */ 452 /* NULLs are not supported in spatial index */ 453 #define HA_ERR_NULL_IN_SPATIAL 158 454 #define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine */ 455 /* There's no partition in table for given value */ 456 #define HA_ERR_NO_PARTITION_FOUND 160 457 #define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */ 458 #define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr */ 459 /* 460 Upholding foreign key constraints would lead to a duplicate key error 461 in some other table. 462 */ 463 #define HA_ERR_FOREIGN_DUPLICATE_KEY 163 464 /* The table changed in storage engine */ 465 #define HA_ERR_TABLE_NEEDS_UPGRADE 164 466 #define HA_ERR_TABLE_READONLY 165 /* The table is not writable */ 467 468 #define HA_ERR_AUTOINC_READ_FAILED 166 /* Failed to get next autoinc value */ 469 #define HA_ERR_AUTOINC_ERANGE 167 /* Failed to set row autoinc value */ 470 #define HA_ERR_GENERIC 168 /* Generic error */ 471 /* row not actually updated: new values same as the old values */ 472 #define HA_ERR_RECORD_IS_THE_SAME 169 473 /* It is not possible to log this statement */ 474 #define HA_ERR_LOGGING_IMPOSSIBLE 170 /* It is not possible to log this 475 statement */ 476 #define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to 477 illegal data being read */ 478 #define HA_ERR_NEW_FILE 172 /* New file format */ 479 #define HA_ERR_ROWS_EVENT_APPLY 173 /* The event could not be processed 480 no other hanlder error happened */ 481 #define HA_ERR_INITIALIZATION 174 /* Error during initialization */ 482 #define HA_ERR_FILE_TOO_SHORT 175 /* File too short */ 483 #define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */ 484 #define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */ 485 /* There's no explicitly listed partition in table for the given value */ 486 #define HA_ERR_NOT_IN_LOCK_PARTITIONS 178 487 #define HA_ERR_INDEX_COL_TOO_LONG 179 /* Index column length exceeds limit */ 488 #define HA_ERR_INDEX_CORRUPT 180 /* InnoDB index corrupted */ 489 #define HA_ERR_UNDO_REC_TOO_BIG 181 /* Undo log record too big */ 490 #define HA_FTS_INVALID_DOCID 182 /* Invalid InnoDB Doc ID */ 491 #define HA_ERR_TABLE_IN_FK_CHECK 183 /* Table being used in foreign key check */ 492 #define HA_ERR_TABLESPACE_EXISTS 184 /* The tablespace existed in storage engine */ 493 #define HA_ERR_TOO_MANY_FIELDS 185 /* Table has too many columns */ 494 #define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partition */ 495 #define HA_ERR_INNODB_READ_ONLY 187 /* InnoDB is in read only mode. */ 496 #define HA_ERR_FTS_EXCEED_RESULT_CACHE_LIMIT 188 /* FTS query exceeds result cache limit */ 497 #define HA_ERR_TEMP_FILE_WRITE_FAILURE 189 /* Temporary file write failure */ 498 #define HA_ERR_INNODB_FORCED_RECOVERY 190 /* Innodb is in force recovery mode */ 499 #define HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE 191 /* Too many words in a phrase */ 500 #define HA_ERR_FK_DEPTH_EXCEEDED 192 /* FK cascade depth exceeded */ 501 #define HA_MISSING_CREATE_OPTION 193 /* Option Missing during Create */ 502 #define HA_ERR_SE_OUT_OF_MEMORY 194 /* Out of memory in storage engine */ 503 #define HA_ERR_TABLE_CORRUPT 195 /* Table/Clustered index is corrupted. */ 504 #define HA_ERR_QUERY_INTERRUPTED 196 /* The query was interrupted */ 505 #define HA_ERR_TABLESPACE_MISSING 197 /* Missing Tablespace */ 506 #define HA_ERR_TABLESPACE_IS_NOT_EMPTY 198 /* Tablespace is not empty */ 507 #define HA_ERR_WRONG_FILE_NAME 199 /* Invalid Filename */ 508 #define HA_ERR_NOT_ALLOWED_COMMAND 200 /* Operation is not allowed */ 509 #define HA_ERR_COMPUTE_FAILED 201 /* Compute generated column value failed */ 510 #define HA_ERR_DEST_SCHEMA_NOT_EXIST 202 /* Destination schema does not exist */ 511 #define HA_ERR_CANNOT_INITIALIZE_PARTITIONING 203 /* Partitioning can't be initialized */ 512 #define HA_ERR_FTS_TOO_MANY_NESTED_EXP 204 /* Too many sub-expression in search string */ 513 #define HA_ERR_LAST 204 /* Copy of last error nr */ 514 515 /* Number of different errors */ 516 #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) 517 518 #define HA_ERR_DECRYPTION_FAILED 500 /* Table encrypted but decypt failed */ 519 520 521 /* Other constants */ 522 523 #define HA_NAMELEN 64 /* Max length of saved filename */ 524 #define NO_SUCH_KEY (~(uint)0) /* used as a key no. */ 525 526 typedef ulong key_part_map; 527 #define HA_WHOLE_KEY (~(key_part_map)0) 528 529 /* Intern constants in databases */ 530 531 /* bits in _search */ 532 #define SEARCH_FIND 1 533 #define SEARCH_NO_FIND 2 534 #define SEARCH_SAME 4 535 #define SEARCH_BIGGER 8 536 #define SEARCH_SMALLER 16 537 #define SEARCH_SAVE_BUFF 32 538 #define SEARCH_UPDATE 64 539 #define SEARCH_PREFIX 128 540 #define SEARCH_LAST 256 541 #define MBR_CONTAIN 512 542 #define MBR_INTERSECT 1024 543 #define MBR_WITHIN 2048 544 #define MBR_DISJOINT 4096 545 #define MBR_EQUAL 8192 546 #define MBR_DATA 16384 547 #define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */ 548 #define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */ 549 550 /* bits in opt_flag */ 551 #define QUICK_USED 1 552 #define READ_CACHE_USED 2 553 #define READ_CHECK_USED 4 554 #define KEY_READ_USED 8 555 #define WRITE_CACHE_USED 16 556 #define OPT_NO_ROWS 32 557 558 /* bits in update */ 559 #define HA_STATE_CHANGED 1 /* Database has changed */ 560 #define HA_STATE_AKTIV 2 /* Has a current record */ 561 #define HA_STATE_WRITTEN 4 /* Record is written */ 562 #define HA_STATE_DELETED 8 563 #define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */ 564 #define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */ 565 #define HA_STATE_NO_KEY 64 /* Last read didn't find record */ 566 #define HA_STATE_KEY_CHANGED 128 567 #define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */ 568 #define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */ 569 #define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */ 570 #define HA_STATE_EXTEND_BLOCK 2048 571 572 /* myisampack expects no more than 32 field types. */ 573 enum en_fieldtype { 574 FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE, 575 FIELD_SKIP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO, 576 FIELD_VARCHAR,FIELD_CHECK, 577 FIELD_enum_val_count 578 }; 579 580 enum data_file_type { 581 STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD 582 }; 583 584 /* For key ranges */ 585 586 enum key_range_flags { 587 NO_MIN_RANGE= 1 << 0, ///< from -inf 588 NO_MAX_RANGE= 1 << 1, ///< to +inf 589 /* X < key, i.e. not including the left endpoint */ 590 NEAR_MIN= 1 << 2, 591 /* X > key, i.e. not including the right endpoint */ 592 NEAR_MAX= 1 << 3, 593 /* 594 This flag means that index is a unique index, and the interval is 595 equivalent to "AND(keypart_i = const_i)", where all of const_i are 596 not NULLs. 597 */ 598 UNIQUE_RANGE= 1 << 4, 599 /* 600 This flag means that the interval is equivalent to 601 "AND(keypart_i = const_i)", where not all key parts may be used 602 but all of const_i are not NULLs. 603 */ 604 EQ_RANGE= 1 << 5, 605 /* 606 This flag has the same meaning as UNIQUE_RANGE, except that for at 607 least one keypart the condition is "keypart IS NULL". 608 */ 609 NULL_RANGE= 1 << 6, 610 /** 611 This flag means that the index is an rtree index, and the interval is 612 specified using HA_READ_MBR_XXX defined in enum ha_rkey_function. 613 */ 614 GEOM_FLAG= 1 << 7, 615 /* Deprecated, currently used only by NDB at row retrieval */ 616 SKIP_RANGE= 1 << 8, 617 /* 618 Used together with EQ_RANGE to indicate that index statistics 619 should be used instead of sampling the index. 620 */ 621 USE_INDEX_STATISTICS= 1 << 9 622 }; 623 624 625 typedef struct st_key_range 626 { 627 const uchar *key; 628 uint length; 629 key_part_map keypart_map; 630 enum ha_rkey_function flag; 631 } key_range; 632 633 typedef struct st_key_multi_range 634 { 635 key_range start_key; 636 key_range end_key; 637 char *ptr; /* Free to use by caller (ptr to row etc) */ 638 uint range_flag; /* key range flags see above */ 639 } KEY_MULTI_RANGE; 640 641 642 /* For number of records */ 643 #define rows2double(A) ulonglong2double(A) 644 typedef my_off_t ha_rows; 645 646 #define HA_POS_ERROR (~ (ha_rows) 0) 647 #define HA_OFFSET_ERROR (~ (my_off_t) 0) 648 649 #if SYSTEM_SIZEOF_OFF_T == 4 650 #define MAX_FILE_SIZE INT_MAX32 651 #else 652 #define MAX_FILE_SIZE LLONG_MAX 653 #endif 654 655 #define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2) 656 657 /* invalidator function reference for Query Cache */ 658 C_MODE_START 659 typedef void (* invalidator_by_filename)(const char * filename); 660 C_MODE_END 661 662 #endif /* _my_base_h */ 663