9
3

my_base.h 25 KB

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