MySQL 9.6.0
Source Code Documentation
my_base.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2025, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file include/my_base.h
26 This file includes constants used by all storage engines.
27*/
28
29#ifndef _my_base_h
30#define _my_base_h
31
32#include <limits.h>
33#include <sys/types.h>
34
35#include "my_config.h"
36#include "my_double2ulonglong.h"
37#include "my_inttypes.h"
38#include "my_macros.h"
39
40/* The following is bits in the flag parameter to ha_open() */
41
42#define HA_OPEN_ABORT_IF_LOCKED 0 /* default */
43#define HA_OPEN_WAIT_IF_LOCKED 1
44#define HA_OPEN_IGNORE_IF_LOCKED 2
45#define HA_OPEN_TMP_TABLE 4 /* Table is a temp table */
46#define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */
47#define HA_OPEN_ABORT_IF_CRASHED 16
48#define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */
49#define HA_OPEN_FROM_SQL_LAYER 64
50#define HA_OPEN_COPY 256 /* Open copy (for repair) */
51/**
52 Internal temp table, used for temporary results; one or more instance of it
53 may be be created.
54*/
55#define HA_OPEN_INTERNAL_TABLE 512
56
57/* The following is parameter to ha_rkey() how to use key */
58
59/*
60 We define a complete-field prefix of a key value as a prefix where
61 the last included field in the prefix contains the full field, not
62 just some bytes from the start of the field. A partial-field prefix
63 is allowed to contain only a few first bytes from the last included
64 field.
65
66 Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a
67 complete-field prefix of a key value as the search
68 key. HA_READ_PREFIX and HA_READ_PREFIX_LAST could also take a
69 partial-field prefix, but currently (4.0.10) they are only used with
70 complete-field prefixes. MySQL uses a padding trick to implement
71 LIKE 'abc%' queries.
72
73 NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a
74 partial-field prefix because InnoDB currently strips spaces from the
75 end of varchar fields!
76*/
77
79 HA_READ_KEY_EXACT, /* Find first record else error */
80 HA_READ_KEY_OR_NEXT, /* Record or next record */
81 HA_READ_KEY_OR_PREV, /* Record or previous */
82 HA_READ_AFTER_KEY, /* Find next rec. after key-record */
83 HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
84 HA_READ_PREFIX, /* Key which as same prefix */
85 HA_READ_PREFIX_LAST, /* Last key with the same prefix */
86 HA_READ_PREFIX_LAST_OR_PREV, /* Last or prev key with the same prefix */
87 HA_READ_MBR_CONTAIN, /* Minimum Bounding Rectangle contains */
88 HA_READ_MBR_INTERSECT, /* Minimum Bounding Rectangle intersect */
89 HA_READ_MBR_WITHIN, /* Minimum Bounding Rectangle within */
90 HA_READ_MBR_DISJOINT, /* Minimum Bounding Rectangle disjoint */
91 HA_READ_MBR_EQUAL, /* Minimum Bounding Rectangle equal */
92 HA_READ_NEAREST_NEIGHBOR, /* Nearest Neighbor search */
93 HA_READ_INVALID = -1 /* Invalid enumeration value, always last. */
94};
95
96/* Key algorithm types */
97
99 /**
100 Used for cases when key algorithm which is supported by SE can't be
101 described by one of other classes from this enum (@sa Federated,
102 PerfSchema SE, @sa dd::Index::IA_SE_SPECIFIC).
103
104 @note Assigned as default value for key algorithm by parser, replaced by
105 SEs default algorithm for keys in mysql_prepare_create_table().
106 */
108 HA_KEY_ALG_BTREE = 1, /* B-tree. */
109 HA_KEY_ALG_RTREE = 2, /* R-tree, for spatial searches */
110 HA_KEY_ALG_HASH = 3, /* HASH keys (HEAP, NDB). */
111 HA_KEY_ALG_FULLTEXT = 4 /* FULLTEXT. */
113
114/* Storage media types */
115
117 HA_SM_DEFAULT = 0, /* Not specified (engine default) */
118 HA_SM_DISK = 1, /* DISK storage */
119 HA_SM_MEMORY = 2 /* MAIN MEMORY storage */
121
122/* The following is parameter to ha_extra() */
123
124/*
125 We divide the HA_EXTRA entries into the following categories:
126
127 1) Operations used by most handlers:
128 HA_EXTRA_KEYREAD
129 HA_EXTRA_NO_KEYREAD
130 HA_EXTRA_FLUSH
131 HA_EXTRA_PREPARE_FOR_RENAME
132 HA_EXTRA_FORCE_REOPEN
133
134 2) Operations used by some non-MyISAM handlers
135 HA_EXTRA_KEYREAD_PRESERVE_FIELDS
136 HA_EXTRA_IGNORE_DUP_KEY
137 HA_EXTRA_NO_IGNORE_DUP_KEY
138
139 3) Operations used only by MyISAM
140 HA_EXTRA_NORMAL
141 HA_EXTRA_QUICK
142 HA_EXTRA_PREPARE_FOR_UPDATE
143 HA_EXTRA_PREPARE_FOR_DROP
144 HA_EXTRA_READCHECK
145 HA_EXTRA_NO_READCHECK
146
147 4) Operations only used by temporary tables for query processing
148 HA_EXTRA_RESET_STATE
149 HA_EXTRA_NO_ROWS
150
151 5) Operations only used by MyISAM internally
152 HA_EXTRA_NO_USER_CHANGE
153 HA_EXTRA_WAIT_LOCK
154 HA_EXTRA_WAIT_NOLOCK
155 HA_EXTRA_NO_KEYS
156 HA_EXTRA_KEYREAD_CHANGE_POS
157 HA_EXTRA_REMEMBER_POS
158 HA_EXTRA_RESTORE_POS
159 HA_EXTRA_PRELOAD_BUFFER_SIZE
160 HA_EXTRA_CHANGE_KEY_TO_DUP
161 HA_EXTRA_CHANGE_KEY_TO_UNIQUE
162
163 6) Operations only used by federated tables for query processing
164 HA_EXTRA_INSERT_WITH_UPDATE
165
166 7) Operations only used by NDB
167 HA_EXTRA_DELETE_CANNOT_BATCH
168 HA_EXTRA_UPDATE_CANNOT_BATCH
169
170 8) Operations only used by MERGE
171 HA_EXTRA_ADD_CHILDREN_LIST
172 HA_EXTRA_ATTACH_CHILDREN
173 HA_EXTRA_IS_ATTACHED_CHILDREN
174 HA_EXTRA_DETACH_CHILDREN
175
176 9) Operations only used by InnoDB
177 HA_EXTRA_EXPORT
178
179 10) Operations only used by partitioning
180 HA_EXTRA_SECONDARY_SORT_ROWID
181
182 The individual entries are described in more detail below.
183*/
184
186 /*
187 Optimize for space (def).
188 Only used in MyISAM to reset quick mode, not implemented by any other
189 handler. Quick mode is also reset in MyISAM by handler::reset().
190
191 It is called after completing a successful DELETE query if the QUICK
192 option is set.
193 */
195 /*
196 Optimize for speed.
197 When the user does DELETE QUICK FROM table where-clause; this extra
198 option is called before the delete query is performed and
199 HA_EXTRA_NORMAL is called after the delete query is completed.
200 Temporary tables used internally in MySQL always set this option
201
202 The meaning of quick mode is that when deleting in a B-tree no merging
203 of leafs is performed. This is a common method and many large DBMS's
204 actually only support this quick mode since it is very difficult to
205 merge leaves in a tree used by many threads concurrently.
206 */
209 /*
210 Only one call to HA_EXTRA_NO_READCHECK from ha_open where it says that
211 this is not needed in SQL. The reason for this call is that MyISAM sets
212 the READ_CHECK_USED in the open call so the call is needed for MyISAM
213 to reset this feature.
214 The idea with this parameter was to inform of doing/not doing a read
215 check before applying an update. Since SQL always performs a read before
216 applying the update No Read Check is needed in MyISAM as well.
217
218 This is a cut from Docs/myisam.txt
219 Sometimes you might want to force an update without checking whether
220 another user has changed the record since you last read it. This is
221 somewhat dangerous, so it should ideally not be used. That can be
222 accomplished by wrapping the mi_update() call in two calls to mi_extra(),
223 using the flags HA_EXTRA_NO_READCHECK and HA_EXTRA_READCHECK.
224 */
227 /*
228 These parameters are used to provide an optimisation hint to the handler.
229 If HA_EXTRA_KEYREAD is set it is enough to read the index fields, for
230 many handlers this means that the index-only scans can be used and it
231 is not necessary to use the real records to satisfy this part of the
232 query. Index-only scans is a very important optimisation for disk-based
233 indexes. For main-memory indexes most indexes contain a reference to the
234 record and thus KEYREAD only says that it is enough to read key fields.
235 HA_EXTRA_NO_KEYREAD disables this for the handler, also, handler::reset()
236 will disable this option.
237 The handler will set HA_KEYREAD_ONLY in its table flags to indicate this
238 feature is supported.
239 */
242 /*
243 No user is allowed to write. Only used by MyISAM, never called.
244 Simulates lock_type as locked.
245 */
247 /*
248 Only used by MyISAM, called from MyISAM handler but never from server
249 code on top of the handler.
250 Sets lock_wait on/off:
251 Wait until file is available (def).
252 If file is locked, return quickly.
253 */
256 /*
257 Remove all update of keys. Only used by MyISAM, only used internally in
258 MyISAM handler, never called from server level.
259 */
261 HA_EXTRA_KEYREAD_CHANGE_POS = 17, /* Keyread, but change pos */
262 /* xxxxchk -r must be used */
263 HA_EXTRA_REMEMBER_POS = 18, /* Remember pos for next/prev */
265 /*
266 Only used by MyISAM and Archive, called when altering table,
267 closing tables to enforce a reopen of the table files.
268 */
270 /*
271 Indication to flush tables to disk, is supposed to be used to
272 ensure disk based tables are flushed at end of query execution.
273 Currently is never used.
274 */
276 /*
277 Don't insert rows indication to HEAP and MyISAM, only used by temporary
278 tables used in query processing.
279 */
281 /*
282 This option is used by most handlers and it resets the handler state
283 to the same state as after an open call.
284
285 It is called from the reset method in the handler interface. There are
286 three instances where this is called.
287
288 1) After completing a INSERT ... SELECT ... query the handler for the
289 table inserted into is reset
290 2) It is called from close_thread_table which in turn is called from
291 close_thread_tables except in the case where the tables are locked
292 in which case ha_commit_stmt is called instead.
293 It is only called from here if refresh_version hasn't changed and the
294 table is not an old table when calling close_thread_table.
295 close_thread_tables is called from many places as a general clean up
296 function after completing a query.
297 3) It is called when deleting the IndexRangeScanIterator object if the
298 IndexRangeScanIterator object had its own handler object. It is called
299 immediately before close of this local handler object.
300
301 If there is a READ CACHE it is reinit'ed. A cache is reinit'ed to
302 restart reading or to change type of cache between READ CACHE and
303 WRITE CACHE.
304
305 This extra function is always called immediately before calling
306 delete_all_rows on the handler for temporary tables.
307 There are cases however when HA_EXTRA_RESET_STATE isn't called in
308 a similar case for a temporary table in sql_union.cc.
309
310 The only case that delete_all_rows is called on non-temporary tables
311 is in sql_delete.cc when DELETE FROM table; is called by a user.
312 In this case no special extra calls are performed before or after this
313 call.
314 */
316 /*
317 Informs the handler that we will not stop the transaction if we get
318 duplicate key errors during insert/update.
319 Always called in pair, triggered by INSERT IGNORE and other similar
320 SQL constructs.
321 Not used by MyISAM.
322 */
325 /*
326 Only used by MyISAM, called in preparation for a DROP TABLE.
327 It's used mostly by Windows that cannot handle dropping an open file.
328 On other platforms it has the same effect as HA_EXTRA_FORCE_REOPEN.
329 */
331 /*
332 Remove read cache if problems.
333 This is called as part of a multi-table update. When the table to be
334 updated is also scanned then this informs MyISAM handler to drop any
335 caches if dynamic records are used (fixed size records do not care
336 about this call).
337 */
339 HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */
340 /*
341 On-the-fly switching between unique and non-unique key inserting.
342 */
345 /*
346 When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep
347 other fields intact. When this is off (by default) InnoDB will use memcpy
348 to overwrite entire row.
349 This is a strictly InnoDB feature that is more or less undocumented.
350 */
352 /*
353 Ignore if the a tuple is not found, continue processing the
354 transaction and ignore that 'row'. Needed for idempotency
355 handling on the slave
356
357 Currently only used by NDB storage engine.
358 */
361 /*
362 Mark the table as a log table. For some handlers (e.g. CSV) this results
363 in a special locking for the table.
364 */
366 /*
367 Informs handler that write_row() which tries to insert new row into the
368 table and encounters some already existing row with same primary/unique
369 key can replace old row with new row instead of reporting error (basically
370 it informs handler that we do REPLACE instead of simple INSERT).
371 Off by default.
372 */
375 /*
376 Inform handler that delete_row()/update_row() cannot batch deletes/updates
377 and should perform them immediately. This may be needed when table has
378 AFTER DELETE/UPDATE triggers which access to subject table.
379 These flags are reset by the handler::reset() call.
380 */
383 /*
384 Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be
385 executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY.
386 */
388 /*
389 Informs the handler we are about to attempt a rename of the table.
390 For handlers that have share open files (MyISAM key-file and
391 Archive writer) they must close the files before rename is possible
392 on Windows.
393 */
395 /*
396 Special actions for MERGE tables.
397 */
402 /*
403 Prepare table for export
404 (e.g. quiesce the table and write table metadata).
405 */
407 /** Do secondary sort by handler::ref (rowid) after key sort. */
409 /** Skip acquiring locks when reading from ACL tables or views on DD
410 tables in order to make such reads non blocking. */
412 /* Begin of insertion into intermediate table during copy alter operation. */
414 /* Insertion is done in intermediate table during copy alter operation. */
416 /* Do not use auto-increment locking. */
418 /*
419 Allocate and use unique filter to weed out duplicates.
420 Used with multi-valued index.
421 */
423 /* Disable and free unique record filter. */
425 /* Enable locking read. Used for foreign key check */
427 /* Reset locking read. */
430
431/* Compatible option, to be deleted in 6.0 */
432#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
433
434/* The following is parameter to ha_panic() */
435
437 HA_PANIC_CLOSE, /* Close all databases */
438 HA_PANIC_WRITE, /* Unlock and write status */
439 HA_PANIC_READ /* Lock and read keyinfo */
441
442/* The following is parameter to ha_create(); keytypes */
443
446 HA_KEYTYPE_TEXT = 1, /* Key is sorted as letters */
447 HA_KEYTYPE_BINARY = 2, /* Key is sorted as unsigned chars */
452 HA_KEYTYPE_NUM = 7, /* Not packed num with pre-space */
460 /* Varchar (0-255 bytes) with length packed with 1 byte */
461 HA_KEYTYPE_VARTEXT1 = 15, /* Key is sorted as letters */
462 HA_KEYTYPE_VARBINARY1 = 16, /* Key is sorted as unsigned chars */
463 /* Varchar (0-65535 bytes) with length packed with 2 bytes */
464 HA_KEYTYPE_VARTEXT2 = 17, /* Key is sorted as letters */
465 HA_KEYTYPE_VARBINARY2 = 18, /* Key is sorted as unsigned chars */
466 HA_KEYTYPE_BIT = 19
468
469#define HA_MAX_KEYTYPE 31 /* Must be log2-1 */
470
471/*
472 Flags for KEY::flags bitmap.
473
474 Also used for similar bitmaps in storage engines (HP_KEYDEF::flag,
475 MI_KEYDEF::flag, ...).
476*/
477
478/** Do not allow duplicate records. */
479#define HA_NOSAME 1
480/** Pack string key to previous key (optimization supported by MyISAM). */
481#define HA_PACK_KEY (1 << 1)
482/*
483 Bits in KEY::flags, MI/HP_KEYDEF::flag which are automatically
484 calculated based on other flags/members in these structures
485 (often from info about key parts).
486*/
487/** Some key part packs space. Internal to MyISAM. */
488#define HA_SPACE_PACK_USED (1 << 2)
489/** Some key part has variable length. Internal to MyISAM and Heap engines. */
490#define HA_VAR_LENGTH_KEY (1 << 3)
491/**
492 Auto-increment key.
493
494 @note Not used by SQL-layer/ for KEY::flags. Only set by MyISAM and
495 Heap SEs in MI/HP_KEYDEF::flag.
496*/
497#define HA_AUTO_KEY (1 << 4)
498/** Packing of all keys to previous key (optimization supported by MyISAM). */
499#define HA_BINARY_PACK_KEY (1 << 5)
500/** Some key part is nullable. */
501#define HA_NULL_PART_KEY (1 << 6)
502/** Full-text key. */
503#define HA_FULLTEXT (1 << 7)
504/**
505 Flag in MI_KEYDEF::flag which marks MyISAM's "uniques".
506
507 @note Internal to MyISAM. Current server doesn't use this feature.
508*/
509#define HA_UNIQUE_CHECK (1 << 8)
510/** Internal bit used when sorting records. Internal to MyISAM. */
511#define HA_SORT_ALLOWS_SAME (1 << 9)
512/** Spatial key. */
513#define HA_SPATIAL (1 << 10)
514/**
515 NULLs in key are compared as equal.
516
517 @note Used only for internal temporary tables created by optimizer.
518*/
519#define HA_NULL_ARE_EQUAL (1 << 11)
520/** Key has comment. */
521#define HA_USES_COMMENT (1 << 12)
522/** Key was automatically created to support Foreign Key constraint. */
523#define HA_GENERATED_KEY (1 << 13)
524
525/* The combination of the above can be used for key type comparison. */
526#define HA_KEYFLAG_MASK \
527 (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | HA_BINARY_PACK_KEY | HA_FULLTEXT | \
528 HA_UNIQUE_CHECK | HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
529
530/** Fulltext index uses [pre]parser */
531#define HA_USES_PARSER (1 << 14)
532/** Key uses KEY_BLOCK_SIZE option. */
533#define HA_USES_BLOCK_SIZE (1 << 15)
534/**
535 Key contains partial segments.
536
537 @note This flag is internal to SQL-layer by design. It is not supposed to
538 be used to storage engines. It is intended to pass information into
539 internal static sort_keys(KEY *, KEY *) function.
540
541 This flag can be calculated -- it's based on key lengths comparison.
542*/
543#define HA_KEY_HAS_PART_KEY_SEG (1 << 16)
544/**
545 Key was renamed (or is result of renaming a key).
546
547 This is another flag internal to SQL-layer.
548 Used by in-place ALTER TABLE implementation.
549
550 @note This flag can be set for keys which have other changes than
551 simple renaming as well. So from the point of view of storage
552 engine such key might have to be dropped and re-created with
553 new definition.
554*/
555#define HA_KEY_RENAMED (1 << 17)
556/** Set if a key is on any virtual generated columns */
557#define HA_VIRTUAL_GEN_KEY (1 << 18)
558/** Multi-valued key */
559#define HA_MULTI_VALUED_KEY (1 << 19)
560
561constexpr const ulong HA_INDEX_USES_ENGINE_ATTRIBUTE{1UL << 20};
562constexpr const ulong HA_INDEX_USES_SECONDARY_ENGINE_ATTRIBUTE{1UL << 21};
563
564/* These flags can be added to key-seg-flag */
565
566#define HA_SPACE_PACK 1 /* Pack space in key-seg */
567#define HA_PART_KEY_SEG 4 /* Used by MySQL for part-key-cols */
568#define HA_VAR_LENGTH_PART 8
569#define HA_NULL_PART 16
570#define HA_BLOB_PART 32
571#define HA_SWAP_KEY 64
572#define HA_REVERSE_SORT 128 /* Sort key in reverse order */
573#define HA_NO_SORT 256 /* do not bother sorting on this keyseg */
574/*
575 End space in unique/varchar are considered equal. (Like 'a' and 'a ')
576 Only needed for internal temporary tables.
577*/
578#define HA_END_SPACE_ARE_EQUAL 512
579#define HA_BIT_PART 1024
580
581/*
582 Flags for HA_CREATE_INFO::table_options and TABLE_SHARE::db_create_options
583 TABLE_SHARE::db_options_in_use bitmaps.
584
585 @note These bitmaps are used for storing information about some table
586 option values/attributes.
587 @note HA_CREATE_INFO::table_options and TABLE_SHARE::db_create_options
588 are basically the same bitmap at the time of table creation and
589 at the time of table opening/usage correspondingly.
590 @note TABLE_SHARE::db_options_in_use is normally copy of db_create_options
591 but can be overridden by SE. E.g. MyISAM does this at handler::open()
592 and handler::info() time.
593
594 Also used for similar bitmaps in MyISAM (MYISAM_SHARE::options,
595 MI_ISAMINFO::options).
596*/
597
598/**
599 Indicates that storage engine needs to use packed row format.
600 Set for tables with ROW_FORMAT=DYNAMIC clause, for tables with BLOB fields,
601 and for tables with VARCHAR columns without ROW_FORMAT=FIXED.
602
603 This flag is respected by MyISAM only (it might also decide to use this
604 optimization for its own reasons). InnoDB relies on HA_CREATE_INFO::row_type
605 directly instead.
606*/
607#define HA_OPTION_PACK_RECORD 1
608/**
609 PACK_KEYS=1 option was specified.
610
611 PACK_KEYS=# option specifies whether key packing - optimization supported
612 by MyISAM, should be used.
613 * PACK_KEYS=1 means all keys should be packed,
614 * PACK_KEYS=0 (denoted by @sa HA_OPTION_NO_PACK_KEYS flag) means that key
615 packing should not be used at all.
616 * Not using this option or using PACK_KEYS=DEFAULT clause (denoted by
617 absence of both HA_OPTION_PACK_KEYS and HA_OPTION_NO_PACK_KEYS flags)
618 means that key packing will be used for long string columns.
619*/
620#define HA_OPTION_PACK_KEYS 2
621/**
622 Flag indicating that table is compressed. Used by MyISAM storage engine to
623 tell SQL-layer that tables is compressed. Not set or stored by SQL-layer,
624
625 MyISAM doesn't respect ROW_FORMAT=COMPRESSED clause and doesn't allow direct
626 creation of compressed tables. Existing tables can be compressed by external
627 tool. This tool marks such tables with HA_OPTION_COMPRESS_RECORD flag in
628 MYISAM_SHARE::options, MI_ISAMINFO::options. Then storage engine sets this
629 flag in TABLE_SHARE::db_options_in_use to let SQL-layer know about the fact.
630 It is never set in HA_CREATE_INFO::table_options or
631 TABLE_SHARE::db_create_options.
632*/
633#define HA_OPTION_COMPRESS_RECORD 4
634/**
635 Unused. Formerly HA_OPTION_LONG_BLOB_PTR - new ISAM format/portable
636 BLOB pointers.
637*/
638#define HA_OPTION_UNUSED1 8
639/**
640 Storage engine (MyISAM) internal flag for marking temporary tables.
641
642 Used in MYISAM_SHARE::options, MI_ISAMINFO::options, not used by SQL-layer,
643 in HA_CREATE_INFO::table_options or TABLE_SHARE::db_create_options.
644*/
645#define HA_OPTION_TMP_TABLE 16
646/**
647 CHECKSUM=1 option was specified.
648
649 This option enables live checksumming for MyISAM tables. Not used by InnoDB.
650 @sa HA_OPTION_NO_CHECKSUM.
651*/
652#define HA_OPTION_CHECKSUM 32
653/**
654 DELAY_KEY_WRITE=1 option was specified. This option enables MyISAM
655 optimization which postpones key updates until table is closed/expelled from
656 the table cache.
657
658 @sa HA_OPTION_NO_DELAY_KEY_WRITE.
659*/
660#define HA_OPTION_DELAY_KEY_WRITE 64
661/**
662 PACK_KEYS=0 option was specified.
663
664 @sa HA_OPTION_PACK_KEYS for further description.
665 @note Unlike HA_OPTION_PACK_KEYS this flag is SQL-layer only.
666*/
667#define HA_OPTION_NO_PACK_KEYS 128
668/**
669 Flag specific to table creation and HA_CREATE_INFO::table_options.
670 Indicates that storage engine instead of creating new table, needs
671 to discover existing one (which metadata was discovered from SE
672 earlier).
673 Not used in TABLE_SHARE::db_create_options/db_options_in_use.
674*/
675#define HA_OPTION_CREATE_FROM_ENGINE 256
676/**
677 Storage engine (MyISAM) internal flag for marking tables which
678 rely on SQL-layer because they have keys using fulltext parser plugin.
679
680 Used in MYISAM_SHARE::options, MI_ISAMINFO::options, not used by SQL-layer,
681 in HA_CREATE_INFO::table_options or TABLE_SHARE::db_create_options.
682*/
683#define HA_OPTION_RELIES_ON_SQL_LAYER 512
684/** Unused. Formerly HA_OPTION_NULL_FIELDS - reserved for Maria SE. */
685#define HA_OPTION_UNUSED2 1024
686/** Unused. Formerly HA_OPTION_PAGE_CHECKSUM - reserved for Maria SE. */
687#define HA_OPTION_UNUSED3 2048
688/** STATS_PERSISTENT=1 has been specified in the SQL command (either CREATE
689or ALTER TABLE). Table and index statistics that are collected by the
690storage engine and used by the optimizer for query optimization will be
691stored on disk and will not change after a server restart. */
692#define HA_OPTION_STATS_PERSISTENT 4096
693/** STATS_PERSISTENT=0 has been specified in CREATE/ALTER TABLE. Statistics
694for the table will be wiped away on server shutdown and new ones recalculated
695after the server is started again. If none of HA_OPTION_STATS_PERSISTENT or
696HA_OPTION_NO_STATS_PERSISTENT is set, this means that the setting is not
697explicitly set at table level and the corresponding table will use whatever
698is the global server default. */
699#define HA_OPTION_NO_STATS_PERSISTENT 8192
700/**
701 MyISAM internal flag used by myisamchk external tool.
702
703 Not used by SQL-layer/in HA_CREATE_INFO::table_options and
704 TABLE_SHARE::db_create_options.
705*/
706#define HA_OPTION_TEMP_COMPRESS_RECORD 16384
707/**
708 MyISAM internal flag which marks table as read-only.
709 Set by myisampack external tool.
710
711 Not used by SQL-layer/in HA_CREATE_INFO::table_options and
712 TABLE_SHARE::db_create_options.
713*/
714#define HA_OPTION_READ_ONLY_DATA 32768
715/**
716 CHECKSUM=0 option was specified. Only used by SQL-layer, in
717 HA_CREATE_INFO::table_options. Not persisted in data-dictionary.
718*/
719#define HA_OPTION_NO_CHECKSUM (1L << 17)
720/**
721 DELAY_KEY_WRITE=0 option was specified. Only used by SQL-layer, in
722 HA_CREATE_INFO::table_options. Not persisted in data-dictionary.
723*/
724#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
725/**
726 Table was created with CREATE EXTERNAL TABLE syntax.
727 Used in TABLE_SHARE::db_create_options to preserve EXTERNAL keyword
728 for SHOW CREATE TABLE output.
729*/
730#define HA_OPTION_CREATE_EXTERNAL_TABLE (1L << 19)
731
732/**
733 ALLOW_MISSING_FILES=1 has been specified in the SQL command
734 (either CREATE or ALTER TABLE). When loading external tables, the
735 loading will NOT fail if some of the specified files can not be found.
736 This option will not be persisted in data-dictionary, but encoded in the
737 ENGINE_ATTRIBUTE option.
738*/
739#define HA_OPTION_ALLOW_MISSING_FILES (1L << 19)
740/**
741 ALLOW_MISSING_FILES=0 has been specified in the SQL command
742 (either CREATE or ALTER TABLE). When loading external tables, the
743 loading will fail if some of the specified files can not be found.
744 This option will not be persisted in data-dictionary, but encoded in the
745 ENGINE_ATTRIBUTE option. If neither HA_OPTION_ALLOW_MISSING_FILES nor
746 HA_OPTION_NO_ALLOW_MISSING_FILES is set, ENGINE_ATTRIBUTE will not be
747 affected, and the default behavior for the storage engine will be used.
748*/
749#define HA_OPTION_NO_ALLOW_MISSING_FILES (1L << 20)
750/**
751 VERIFY_KEY_CONSTRAINTS=1 has been specified in the SQL command (either
752 CREATE or ALTER TABLE). When loading external tables, primary key
753 and unique key constraints will be validated.
754 This option will not be persisted in data-dictionary, but encoded in the
755 ENGINE_ATTRIBUTE option.
756*/
757#define HA_OPTION_VERIFY_KEY_CONSTRAINTS (1L << 21)
758/**
759 VERIFY_KEY_CONSTRAINTS=0 has been specified in the SQL command (either
760 CREATE or ALTER TABLE). When loading external tables, primary key
761 and unique key constraints will NOT be validated.
762 This option will not be persisted in data-dictionary, but encoded in the
763 ENGINE_ATTRIBUTE option.
764*/
765#define HA_OPTION_NO_VERIFY_KEY_CONSTRAINTS (1L << 22)
766/**
767 STRICT_LOAD=1 has been specified in the SQL command (either CREATE
768 or ALTER TABLE). When loading external tables, the loading will
769 fail if there are rows that does not match the specified file format etc.
770 This option will not be persisted in data-dictionary, but encoded in the
771 ENGINE_ATTRIBUTE option. If neither HA_OPTION_VERIFY_KEY_CONSTRAINTS_FILES nor
772 HA_OPTION_NO_VERIFY_KEY_CONSTRAINTS_FILES is set, ENGINE_ATTRIBUTE will not be
773 affected, and the default behavior for the storage engine will be used.
774*/
775#define HA_OPTION_STRICT_LOAD (1L << 23)
776/**
777 STRICT_LOAD=0 has been specified in the SQL command (either CREATE
778 or ALTER TABLE). When loading external tables, the loading will
779 just generate a warning and continue loading if a row does not
780 match the specified file format etc.
781 This option will not be persisted in data-dictionary, but encoded in the
782 ENGINE_ATTRIBUTE option.
783*/
784#define HA_OPTION_NO_STRICT_LOAD (1L << 24)
785/**
786 AUTO_REFRESH=1 has been specified in the SQL command (either CREATE
787 or ALTER TABLE). This will turn off automatic refresh.
788 This option will not be persisted in data-dictionary, but encoded in the
789 ENGINE_ATTRIBUTE option. If neither HA_OPTION_STRICT_LOAD_FILES nor
790 HA_OPTION_NO_STRICT_LOAD_FILES is set, ENGINE_ATTRIBUTE will not be
791 affected, and the default behavior for the storage engine will be used.
792*/
793#define HA_OPTION_AUTO_REFRESH (1L << 25)
794/**
795 AUTO_REFRESH=0 has been specified in the SQL command (either CREATE
796 or ALTER TABLE). This will turn off automatic refresh.
797 This option will not be persisted in data-dictionary, but encoded in the
798 ENGINE_ATTRIBUTE option.
799*/
800#define HA_OPTION_NO_AUTO_REFRESH (1L << 26)
801
802/* Bits in flag to create() */
803
804#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
805#define HA_PACK_RECORD 2 /* Request packed record format */
806#define HA_CREATE_TMP_TABLE 4
807#define HA_CREATE_CHECKSUM 8
808#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
809#define HA_CREATE_PAGE_CHECKSUM 32
810#define HA_CREATE_DELAY_KEY_WRITE 64
811#define HA_CREATE_RELIES_ON_SQL_LAYER 128
812#define HA_CREATE_INTERNAL_TABLE 256
813
814/*
815 The following flags (OR-ed) are passed to handler::info() method.
816 The method copies misc handler information out of the storage engine
817 to data structures accessible from MySQL
818
819 Same flags are also passed down to mi_status, myrg_status, etc.
820*/
821
822/* this one is not used */
823#define HA_STATUS_POS 1
824/*
825 assuming the table keeps shared actual copy of the 'info' and
826 local, possibly outdated copy, the following flag means that
827 it should not try to get the actual data (locking the shared structure)
828 slightly outdated version will suffice
829*/
830#define HA_STATUS_NO_LOCK 2
831/* update the time of the last modification (in handler::update_time) */
832#define HA_STATUS_TIME 4
833/*
834 Recalculate loads of constant variables. MyISAM also sets things
835 directly on the table share object.
836
837 Check whether this should be fixed since handlers should not
838 change things directly on the table object.
839
840 Monty comment: This should NOT be changed! It's the handlers
841 responsibility to correct table->s->keys_xxxx information if keys
842 have been disabled.
843
844 The most important parameters set here is records per key on
845 all indexes. block_size and primary key ref_length.
846
847 For each index there is an array of rec_per_key.
848 As an example if we have an index with three attributes a,b and c
849 we will have an array of 3 rec_per_key.
850 rec_per_key[0] is an estimate of number of records divided by
851 number of unique values of the field a.
852 rec_per_key[1] is an estimate of the number of records divided
853 by the number of unique combinations of the fields a and b.
854 rec_per_key[2] is an estimate of the number of records divided
855 by the number of unique combinations of the fields a,b and c.
856
857 Many handlers only set the value of rec_per_key when all fields
858 are bound (rec_per_key[2] in the example above).
859
860 If the handler doesn't support statistics, it should set all of the
861 above to 0.
862
863 update the 'constant' part of the info:
864 handler::max_data_file_length, max_index_file_length, create_time
865 sortkey, ref_length, block_size, data_file_name, index_file_name.
866 handler::table->s->keys_in_use, keys_for_keyread, rec_per_key
867*/
868#define HA_STATUS_CONST 8
869/*
870 update the 'variable' part of the info:
871 handler::records, deleted, data_file_length, index_file_length,
872 check_time, mean_rec_length
873*/
874#define HA_STATUS_VARIABLE 16
875/*
876 This flag is used to get index number of the unique index that
877 reported duplicate key.
878 update handler::errkey and handler::dupp_ref
879 see handler::get_dup_key()
880*/
881#define HA_STATUS_ERRKEY 32
882/*
883 update handler::auto_increment_value
884*/
885#define HA_STATUS_AUTO 64
886/*
887 Get also delete_length when HA_STATUS_VARIABLE is called. It's ok to set it
888 also when only HA_STATUS_VARIABLE but it won't be used.
889*/
890#define HA_STATUS_VARIABLE_EXTRA 128
891/*
892 Get the same statistics as HA_STATUS_CONST, but only if those statistics
893 where updated since open_table_for_share i.e. by the background statistics
894 thread. Do not ask for HA_STATUS_CONST otherwise. This way the optimizer can
895 make sure its statistics are always up-to-date with engine ones.
896*/
897#define HA_STATUS_CONST_WHEN_UPDATED 256
898
899/*
900 Errorcodes given by handler functions
901
902 Do not add error numbers before HA_ERR_FIRST.
903 If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
904*/
905/** Copy of first error nr.*/
906#define HA_ERR_FIRST 120
907/** Didn't find key on read or update */
908#define HA_ERR_KEY_NOT_FOUND 120
909/** Duplicate key on write */
910#define HA_ERR_FOUND_DUPP_KEY 121
911/** Internal error */
912#define HA_ERR_INTERNAL_ERROR 122
913/** Uppdate with is recoverable */
914#define HA_ERR_RECORD_CHANGED 123
915/** Wrong index given to function */
916#define HA_ERR_WRONG_INDEX 124
917/** Transaction has been rolled back */
918#define HA_ERR_ROLLED_BACK 125
919/** Indexfile is crashed */
920#define HA_ERR_CRASHED 126
921/** Record-file is crashed */
922#define HA_ERR_WRONG_IN_RECORD 127
923/** Record-file is crashed */
924#define HA_ERR_OUT_OF_MEM 128
925/** not a MYI file - no signature */
926#define HA_ERR_NOT_A_TABLE 130
927/** Command not supported */
928#define HA_ERR_WRONG_COMMAND 131
929/** old database file */
930#define HA_ERR_OLD_FILE 132
931/** No record read in update() */
932#define HA_ERR_NO_ACTIVE_RECORD 133
933/** A record is not there */
934#define HA_ERR_RECORD_DELETED 134
935/** No more room in file */
936#define HA_ERR_RECORD_FILE_FULL 135
937/** No more room in file */
938#define HA_ERR_INDEX_FILE_FULL 136
939/** end in next/prev/first/last */
940#define HA_ERR_END_OF_FILE 137
941/** unsupported extension used */
942#define HA_ERR_UNSUPPORTED 138
943/** Too big row */
944#define HA_ERR_TOO_BIG_ROW 139
945/** Wrong create option */
946#define HA_WRONG_CREATE_OPTION 140
947/** Duplicate unique on write */
948#define HA_ERR_FOUND_DUPP_UNIQUE 141
949/** Can't open charset */
950#define HA_ERR_UNKNOWN_CHARSET 142
951/** conflicting tables in MERGE */
952#define HA_ERR_WRONG_MRG_TABLE_DEF 143
953/** Last (automatic?) repair failed */
954#define HA_ERR_CRASHED_ON_REPAIR 144
955/** Table must be repaired */
956#define HA_ERR_CRASHED_ON_USAGE 145
957#define HA_ERR_LOCK_WAIT_TIMEOUT 146
958#define HA_ERR_LOCK_TABLE_FULL 147
959/** Updates not allowed */
960#define HA_ERR_READ_ONLY_TRANSACTION 148
961#define HA_ERR_LOCK_DEADLOCK 149
962/** Cannot add a foreign key constr. */
963#define HA_ERR_CANNOT_ADD_FOREIGN 150
964/** Cannot add a child row */
965#define HA_ERR_NO_REFERENCED_ROW 151
966/** Cannot delete a parent row */
967#define HA_ERR_ROW_IS_REFERENCED 152
968/** No savepoint with that name */
969#define HA_ERR_NO_SAVEPOINT 153
970/** Non unique key block size */
971#define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154
972/** The table does not exist in engine */
973#define HA_ERR_NO_SUCH_TABLE 155
974/** The table existed in storage engine */
975#define HA_ERR_TABLE_EXIST 156
976/** Could not connect to storage engine */
977#define HA_ERR_NO_CONNECTION 157
978/** NULLs are not supported in spatial index */
979#define HA_ERR_NULL_IN_SPATIAL 158
980/** The table changed in storage engine */
981#define HA_ERR_TABLE_DEF_CHANGED 159
982/** There's no partition in table for given value */
983#define HA_ERR_NO_PARTITION_FOUND 160
984/** Row-based binlogging of row failed */
985#define HA_ERR_RBR_LOGGING_FAILED 161
986/** Index needed in foreign key constraint */
987#define HA_ERR_DROP_INDEX_FK 162
988/** Upholding foreign key constraints would lead to a duplicate key error
989in some other table. */
990#define HA_ERR_FOREIGN_DUPLICATE_KEY 163
991/** The table changed in storage engine */
992#define HA_ERR_TABLE_NEEDS_UPGRADE 164
993/** The table is not writable */
994#define HA_ERR_TABLE_READONLY 165
995/** Failed to get next autoinc value */
996#define HA_ERR_AUTOINC_READ_FAILED 166
997/** Failed to set row autoinc value */
998#define HA_ERR_AUTOINC_ERANGE 167
999/** Generic error */
1000#define HA_ERR_GENERIC 168
1001/** row not actually updated: new values same as the old values */
1002#define HA_ERR_RECORD_IS_THE_SAME 169
1003/** It is not possible to log this statement */
1004#define HA_ERR_LOGGING_IMPOSSIBLE 170
1005/** The event was corrupt, leading to illegal data being read */
1006#define HA_ERR_CORRUPT_EVENT 171
1007/** New file format */
1008#define HA_ERR_NEW_FILE 172
1009/** The event could not be processed no other handler error happened */
1010#define HA_ERR_ROWS_EVENT_APPLY 173
1011/** Error during initialization */
1012#define HA_ERR_INITIALIZATION 174
1013/** File too short */
1014#define HA_ERR_FILE_TOO_SHORT 175
1015/** Wrong CRC on page */
1016#define HA_ERR_WRONG_CRC 176
1017/** Too many active concurrent transactions */
1018#define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177
1019/** There's no explicitly listed partition in table for the given value */
1020#define HA_ERR_NOT_IN_LOCK_PARTITIONS 178
1021/** Index column length exceeds limit */
1022#define HA_ERR_INDEX_COL_TOO_LONG 179
1023/** InnoDB index corrupted */
1024#define HA_ERR_INDEX_CORRUPT 180
1025/** Undo log record too big */
1026#define HA_ERR_UNDO_REC_TOO_BIG 181
1027/** Invalid InnoDB Doc ID */
1028#define HA_FTS_INVALID_DOCID 182
1029/** Table being used in foreign key check */
1030#define HA_ERR_TABLE_IN_FK_CHECK 183
1031/** The tablespace existed in storage engine */
1032#define HA_ERR_TABLESPACE_EXISTS 184
1033/** Table has too many columns */
1034#define HA_ERR_TOO_MANY_FIELDS 185
1035/** Row in wrong partition */
1036#define HA_ERR_ROW_IN_WRONG_PARTITION 186
1037/** InnoDB is in read only mode. */
1038#define HA_ERR_INNODB_READ_ONLY 187
1039/** FTS query exceeds result cache limit */
1040#define HA_ERR_FTS_EXCEED_RESULT_CACHE_LIMIT 188
1041/** Temporary file write failure */
1042#define HA_ERR_TEMP_FILE_WRITE_FAILURE 189
1043/** Innodb is in force recovery mode */
1044#define HA_ERR_INNODB_FORCED_RECOVERY 190
1045/** Too many words in a phrase */
1046#define HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE 191
1047/** FK cascade depth exceeded */
1048#define HA_ERR_FK_DEPTH_EXCEEDED 192
1049/** Option Missing during Create */
1050#define HA_MISSING_CREATE_OPTION 193
1051/** Out of memory in storage engine */
1052#define HA_ERR_SE_OUT_OF_MEMORY 194
1053/** Table/Clustered index is corrupted. */
1054#define HA_ERR_TABLE_CORRUPT 195
1055/** The query was interrupted */
1056#define HA_ERR_QUERY_INTERRUPTED 196
1057/** Missing Tablespace */
1058#define HA_ERR_TABLESPACE_MISSING 197
1059/** Tablespace is not empty */
1060#define HA_ERR_TABLESPACE_IS_NOT_EMPTY 198
1061/** Invalid Filename */
1062#define HA_ERR_WRONG_FILE_NAME 199
1063/** Operation is not allowed */
1064#define HA_ERR_NOT_ALLOWED_COMMAND 200
1065/** Compute generated column value failed */
1066#define HA_ERR_COMPUTE_FAILED 201
1067/** Table's row format has changed in the storage engine.
1068Information in the data-dictionary needs to be updated. */
1069#define HA_ERR_ROW_FORMAT_CHANGED 202
1070/** Don't wait for record lock */
1071#define HA_ERR_NO_WAIT_LOCK 203
1072/** No more room in disk */
1073#define HA_ERR_DISK_FULL_NOWAIT 204
1074/** No session temporary space available */
1075#define HA_ERR_NO_SESSION_TEMP 205
1076/** Wrong or Invalid table name */
1077#define HA_ERR_WRONG_TABLE_NAME 206
1078/** Path is too long for the OS */
1079#define HA_ERR_TOO_LONG_PATH 207
1080/** Histogram sampling initialization failed */
1081#define HA_ERR_SAMPLING_INIT_FAILED 208
1082/** Too many sub-expression in search string */
1083#define HA_ERR_FTS_TOO_MANY_NESTED_EXP 209
1084/** Copy of last error number */
1085#define HA_ERR_LAST 209
1086
1087/* Number of different errors */
1088#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
1089
1090/* Other constants */
1091
1092#define HA_NAMELEN 64 /* Max length of saved filename */
1093#define NO_SUCH_KEY (~(uint)0) /* used as a key no. */
1094
1095typedef ulong key_part_map;
1096#define HA_WHOLE_KEY (~(key_part_map)0)
1097
1098/* Intern constants in databases */
1099
1100/* bits in _search */
1101#define SEARCH_FIND 1
1102#define SEARCH_NO_FIND 2
1103#define SEARCH_SAME 4
1104#define SEARCH_BIGGER 8
1105#define SEARCH_SMALLER 16
1106#define SEARCH_SAVE_BUFF 32
1107#define SEARCH_UPDATE 64
1108#define SEARCH_PREFIX 128
1109#define SEARCH_LAST 256
1110#define MBR_CONTAIN 512
1111#define MBR_INTERSECT 1024
1112#define MBR_WITHIN 2048
1113#define MBR_DISJOINT 4096
1114#define MBR_EQUAL 8192
1115#define MBR_DATA 16384
1116#define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */
1117#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
1118
1119/* bits in opt_flag */
1120#define QUICK_USED 1
1121#define READ_CACHE_USED 2
1122#define READ_CHECK_USED 4
1123#define KEY_READ_USED 8
1124#define WRITE_CACHE_USED 16
1125#define OPT_NO_ROWS 32
1126
1127/* bits in update */
1128#define HA_STATE_CHANGED 1 /* Database has changed */
1129#define HA_STATE_AKTIV 2 /* Has a current record */
1130#define HA_STATE_WRITTEN 4 /* Record is written */
1131#define HA_STATE_DELETED 8
1132#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
1133#define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */
1134#define HA_STATE_NO_KEY 64 /* Last read didn't find record */
1135#define HA_STATE_KEY_CHANGED 128
1136#define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */
1137#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
1138#define HA_STATE_ROW_CHANGED 1024 /* To invalidate ROW cache */
1139#define HA_STATE_EXTEND_BLOCK 2048
1140
1141/* myisampack expects no more than 32 field types. */
1156
1163
1164/* For key ranges */
1165
1167 NO_MIN_RANGE = 1 << 0, ///< from -inf
1168 NO_MAX_RANGE = 1 << 1, ///< to +inf
1169 /* X < key, i.e. not including the left endpoint */
1170 NEAR_MIN = 1 << 2,
1171 /* X > key, i.e. not including the right endpoint */
1172 NEAR_MAX = 1 << 3,
1173 /*
1174 This flag means that index is a unique index, and the interval is
1175 equivalent to "AND(keypart_i = const_i)", where all of const_i are
1176 not NULLs.
1177 */
1179 /*
1180 This flag means that the interval is equivalent to
1181 "AND(keypart_i = const_i)", where not all key parts may be used
1182 but all of const_i are not NULLs.
1183 */
1184 EQ_RANGE = 1 << 5,
1185 /*
1186 This flag has the same meaning as UNIQUE_RANGE, except that for at
1187 least one keypart the condition is "keypart IS NULL".
1188 */
1189 NULL_RANGE = 1 << 6,
1190 /**
1191 This flag means that the index is an rtree index, and the interval is
1192 specified using HA_READ_MBR_XXX defined in enum ha_rkey_function.
1193 */
1194 GEOM_FLAG = 1 << 7,
1195 /* Deprecated, currently used only by NDB at row retrieval */
1196 // Update: Seems to be unused, even by NDB
1197 SKIP_RANGE = 1 << 8,
1198 /*
1199 Used to indicate that index dives can be skipped. This can happen when:
1200 a) Query satisfies JOIN_TAB::check_skip_records_in_range_qualification. OR
1201 b) Used together with EQ_RANGE to indicate that index statistics should be
1202 used instead of sampling the index.
1203 */
1205 /*
1206 Keypart is reverse-ordered (DESC) and ranges needs to be scanned
1207 backward. @see quick_range_seq_init, get_quick_keys.
1208 */
1209 DESC_FLAG = 1 << 10,
1210};
1211
1213 const uchar *key;
1217};
1218
1222 char *ptr; /* Free to use by caller (ptr to row etc) */
1223 uint range_flag; /* key range flags see above */
1224};
1225
1226/* For number of records */
1227#define rows2double(A) ulonglong2double(A)
1229
1230#define HA_POS_ERROR (~(ha_rows)0)
1231#define HA_OFFSET_ERROR (~(my_off_t)0)
1232
1233#define MAX_FILE_SIZE LLONG_MAX
1234
1235#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 : 2)
1236
1237#endif /* _my_base_h */
ha_base_keytype
Definition: my_base.h:444
@ HA_KEYTYPE_VARBINARY2
Definition: my_base.h:465
@ HA_KEYTYPE_BINARY
Definition: my_base.h:447
@ HA_KEYTYPE_USHORT_INT
Definition: my_base.h:453
@ HA_KEYTYPE_ULONGLONG
Definition: my_base.h:456
@ HA_KEYTYPE_UINT24
Definition: my_base.h:458
@ HA_KEYTYPE_VARTEXT2
Definition: my_base.h:464
@ HA_KEYTYPE_FLOAT
Definition: my_base.h:450
@ HA_KEYTYPE_BIT
Definition: my_base.h:466
@ HA_KEYTYPE_END
Definition: my_base.h:445
@ HA_KEYTYPE_ULONG_INT
Definition: my_base.h:454
@ HA_KEYTYPE_SHORT_INT
Definition: my_base.h:448
@ HA_KEYTYPE_NUM
Definition: my_base.h:452
@ HA_KEYTYPE_DOUBLE
Definition: my_base.h:451
@ HA_KEYTYPE_LONG_INT
Definition: my_base.h:449
@ HA_KEYTYPE_INT8
Definition: my_base.h:459
@ HA_KEYTYPE_INT24
Definition: my_base.h:457
@ HA_KEYTYPE_VARTEXT1
Definition: my_base.h:461
@ HA_KEYTYPE_VARBINARY1
Definition: my_base.h:462
@ HA_KEYTYPE_TEXT
Definition: my_base.h:446
@ HA_KEYTYPE_LONGLONG
Definition: my_base.h:455
ha_panic_function
Definition: my_base.h:436
@ HA_PANIC_WRITE
Definition: my_base.h:438
@ HA_PANIC_CLOSE
Definition: my_base.h:437
@ HA_PANIC_READ
Definition: my_base.h:439
data_file_type
Definition: my_base.h:1157
@ COMPRESSED_RECORD
Definition: my_base.h:1160
@ DYNAMIC_RECORD
Definition: my_base.h:1159
@ BLOCK_RECORD
Definition: my_base.h:1161
@ STATIC_RECORD
Definition: my_base.h:1158
ha_key_alg
Definition: my_base.h:98
@ HA_KEY_ALG_RTREE
Definition: my_base.h:109
@ HA_KEY_ALG_HASH
Definition: my_base.h:110
@ HA_KEY_ALG_SE_SPECIFIC
Used for cases when key algorithm which is supported by SE can't be described by one of other classes...
Definition: my_base.h:107
@ HA_KEY_ALG_BTREE
Definition: my_base.h:108
@ HA_KEY_ALG_FULLTEXT
Definition: my_base.h:111
ha_rkey_function
Definition: my_base.h:78
@ HA_READ_MBR_EQUAL
Definition: my_base.h:91
@ HA_READ_KEY_OR_PREV
Definition: my_base.h:81
@ HA_READ_PREFIX_LAST
Definition: my_base.h:85
@ HA_READ_NEAREST_NEIGHBOR
Definition: my_base.h:92
@ HA_READ_PREFIX_LAST_OR_PREV
Definition: my_base.h:86
@ HA_READ_KEY_EXACT
Definition: my_base.h:79
@ HA_READ_AFTER_KEY
Definition: my_base.h:82
@ HA_READ_MBR_DISJOINT
Definition: my_base.h:90
@ HA_READ_INVALID
Definition: my_base.h:93
@ HA_READ_MBR_INTERSECT
Definition: my_base.h:88
@ HA_READ_BEFORE_KEY
Definition: my_base.h:83
@ HA_READ_MBR_CONTAIN
Definition: my_base.h:87
@ HA_READ_MBR_WITHIN
Definition: my_base.h:89
@ HA_READ_KEY_OR_NEXT
Definition: my_base.h:80
@ HA_READ_PREFIX
Definition: my_base.h:84
key_range_flags
Definition: my_base.h:1166
@ UNIQUE_RANGE
Definition: my_base.h:1178
@ SKIP_RANGE
Definition: my_base.h:1197
@ NEAR_MIN
Definition: my_base.h:1170
@ DESC_FLAG
Definition: my_base.h:1209
@ NO_MIN_RANGE
from -inf
Definition: my_base.h:1167
@ NO_MAX_RANGE
to +inf
Definition: my_base.h:1168
@ EQ_RANGE
Definition: my_base.h:1184
@ SKIP_RECORDS_IN_RANGE
Definition: my_base.h:1204
@ NEAR_MAX
Definition: my_base.h:1172
@ NULL_RANGE
Definition: my_base.h:1189
@ GEOM_FLAG
This flag means that the index is an rtree index, and the interval is specified using HA_READ_MBR_XXX...
Definition: my_base.h:1194
ulong key_part_map
Definition: my_base.h:1095
my_off_t ha_rows
Definition: my_base.h:1228
ha_extra_function
Definition: my_base.h:185
@ HA_EXTRA_NO_USER_CHANGE
Definition: my_base.h:246
@ HA_EXTRA_ENABLE_UNIQUE_RECORD_FILTER
Definition: my_base.h:422
@ HA_EXTRA_NO_KEYREAD
Definition: my_base.h:241
@ HA_EXTRA_KEYREAD_CHANGE_POS
Definition: my_base.h:261
@ HA_EXTRA_ADD_CHILDREN_LIST
Definition: my_base.h:398
@ HA_EXTRA_REMEMBER_POS
Definition: my_base.h:263
@ HA_EXTRA_FORCE_REOPEN
Definition: my_base.h:269
@ HA_EXTRA_DELETE_CANNOT_BATCH
Definition: my_base.h:381
@ HA_EXTRA_NORMAL
Definition: my_base.h:194
@ HA_EXTRA_IS_ATTACHED_CHILDREN
Definition: my_base.h:400
@ HA_EXTRA_NO_AUTOINC_LOCKING
Definition: my_base.h:417
@ HA_EXTRA_WAIT_LOCK
Definition: my_base.h:254
@ HA_EXTRA_WRITE_CAN_REPLACE
Definition: my_base.h:373
@ HA_EXTRA_FLUSH
Definition: my_base.h:275
@ HA_EXTRA_IGNORE_NO_KEY
Definition: my_base.h:359
@ HA_EXTRA_NO_READ_LOCKING
Skip acquiring locks when reading from ACL tables or views on DD tables in order to make such reads n...
Definition: my_base.h:411
@ HA_EXTRA_SECONDARY_SORT_ROWID
Do secondary sort by handler::ref (rowid) after key sort.
Definition: my_base.h:408
@ HA_EXTRA_PREPARE_FOR_UPDATE
Definition: my_base.h:338
@ HA_EXTRA_ENABLE_LOCKING_RECORD
Definition: my_base.h:426
@ HA_EXTRA_DETACH_CHILDREN
Definition: my_base.h:401
@ HA_EXTRA_CHANGE_KEY_TO_DUP
Definition: my_base.h:344
@ HA_EXTRA_READCHECK
Definition: my_base.h:226
@ HA_EXTRA_UPDATE_CANNOT_BATCH
Definition: my_base.h:382
@ HA_EXTRA_NO_READCHECK
Definition: my_base.h:225
@ HA_EXTRA_DISABLE_UNIQUE_RECORD_FILTER
Definition: my_base.h:424
@ HA_EXTRA_NO_IGNORE_DUP_KEY
Definition: my_base.h:324
@ HA_EXTRA_CHANGE_KEY_TO_UNIQUE
Definition: my_base.h:343
@ HA_EXTRA_PREPARE_FOR_DROP
Definition: my_base.h:330
@ HA_EXTRA_MARK_AS_LOG_TABLE
Definition: my_base.h:365
@ HA_EXTRA_NO_IGNORE_NO_KEY
Definition: my_base.h:360
@ HA_EXTRA_PREPARE_FOR_RENAME
Definition: my_base.h:394
@ HA_EXTRA_INSERT_WITH_UPDATE
Definition: my_base.h:387
@ HA_EXTRA_KEYREAD
Definition: my_base.h:240
@ HA_EXTRA_KEYREAD_PRESERVE_FIELDS
Definition: my_base.h:351
@ HA_EXTRA_ATTACH_CHILDREN
Definition: my_base.h:399
@ HA_EXTRA_EXPORT
Definition: my_base.h:406
@ HA_EXTRA_NO_KEYS
Definition: my_base.h:260
@ HA_EXTRA_NO_WAIT_LOCK
Definition: my_base.h:255
@ HA_EXTRA_QUICK
Definition: my_base.h:207
@ HA_EXTRA_RESTORE_POS
Definition: my_base.h:264
@ HA_EXTRA_PRELOAD_BUFFER_SIZE
Definition: my_base.h:339
@ HA_EXTRA_NO_ROWS
Definition: my_base.h:280
@ HA_EXTRA_RESET_STATE
Definition: my_base.h:315
@ HA_EXTRA_WRITE_CANNOT_REPLACE
Definition: my_base.h:374
@ HA_EXTRA_RESET_LOCKING_RECORD
Definition: my_base.h:428
@ HA_EXTRA_BEGIN_ALTER_COPY
Definition: my_base.h:413
@ HA_EXTRA_IGNORE_DUP_KEY
Definition: my_base.h:323
@ HA_EXTRA_NOT_USED
Definition: my_base.h:208
@ HA_EXTRA_END_ALTER_COPY
Definition: my_base.h:415
constexpr const ulong HA_INDEX_USES_SECONDARY_ENGINE_ATTRIBUTE
Definition: my_base.h:562
ha_storage_media
Definition: my_base.h:116
@ HA_SM_MEMORY
Definition: my_base.h:119
@ HA_SM_DISK
Definition: my_base.h:118
@ HA_SM_DEFAULT
Definition: my_base.h:117
en_fieldtype
Definition: my_base.h:1142
@ FIELD_CONSTANT
Definition: my_base.h:1149
@ FIELD_VARCHAR
Definition: my_base.h:1152
@ FIELD_BLOB
Definition: my_base.h:1148
@ FIELD_enum_val_count
Definition: my_base.h:1154
@ FIELD_ZERO
Definition: my_base.h:1151
@ FIELD_SKIP_PRESPACE
Definition: my_base.h:1146
@ FIELD_SKIP_ENDSPACE
Definition: my_base.h:1145
@ FIELD_CHECK
Definition: my_base.h:1153
@ FIELD_SKIP_ZERO
Definition: my_base.h:1147
@ FIELD_INTERVALL
Definition: my_base.h:1150
@ FIELD_LAST
Definition: my_base.h:1143
@ FIELD_NORMAL
Definition: my_base.h:1144
constexpr const ulong HA_INDEX_USES_ENGINE_ATTRIBUTE
Definition: my_base.h:561
Utility functions for converting between ulonglong and double.
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
Some common macros.
Definition: my_base.h:1219
uint range_flag
Definition: my_base.h:1223
key_range end_key
Definition: my_base.h:1221
key_range start_key
Definition: my_base.h:1220
char * ptr
Definition: my_base.h:1222
Definition: my_base.h:1212
uint length
Definition: my_base.h:1214
enum ha_rkey_function flag
Definition: my_base.h:1216
key_part_map keypart_map
Definition: my_base.h:1215
const uchar * key
Definition: my_base.h:1213