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