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