36
36
#define HA_MAX_ALTER_FLAGS 40
37
37
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
40
#define NO_HASH /* Not yet implemented */
43
// the following is for checking tables
45
#define HA_ADMIN_ALREADY_DONE 1
47
#define HA_ADMIN_NOT_IMPLEMENTED -1
48
#define HA_ADMIN_FAILED -2
49
#define HA_ADMIN_CORRUPT -3
50
#define HA_ADMIN_INTERNAL_ERROR -4
51
#define HA_ADMIN_INVALID -5
52
#define HA_ADMIN_REJECT -6
53
#define HA_ADMIN_TRY_ALTER -7
54
#define HA_ADMIN_WRONG_CHECKSUM -8
55
#define HA_ADMIN_NOT_BASE_TABLE -9
56
#define HA_ADMIN_NEEDS_UPGRADE -10
57
#define HA_ADMIN_NEEDS_ALTER -11
58
#define HA_ADMIN_NEEDS_CHECK -12
61
#define HA_ADD_INDEX (0)
62
#define HA_DROP_INDEX (1)
63
#define HA_ALTER_INDEX (2)
64
#define HA_RENAME_INDEX (3)
65
#define HA_ADD_UNIQUE_INDEX (4)
66
#define HA_DROP_UNIQUE_INDEX (5)
67
#define HA_ALTER_UNIQUE_INDEX (6)
68
#define HA_RENAME_UNIQUE_INDEX (7)
69
#define HA_ADD_PK_INDEX (8)
70
#define HA_DROP_PK_INDEX (9)
71
#define HA_ALTER_PK_INDEX (10)
72
#define HA_ADD_COLUMN (11)
73
#define HA_DROP_COLUMN (12)
74
#define HA_CHANGE_COLUMN (13)
75
#define HA_ALTER_COLUMN_NAME (14)
76
#define HA_ALTER_COLUMN_TYPE (15)
77
#define HA_ALTER_COLUMN_ORDER (16)
78
#define HA_ALTER_COLUMN_NULLABLE (17)
79
#define HA_COLUMN_DEFAULT_VALUE (18)
80
#define HA_COLUMN_STORAGE (19)
81
#define HA_COLUMN_FORMAT (20)
82
#define HA_ADD_FOREIGN_KEY (21)
83
#define HA_DROP_FOREIGN_KEY (22)
84
#define HA_ALTER_FOREIGN_KEY (23)
85
#define HA_ADD_CONSTRAINT (24)
86
#define HA_CHANGE_CHARACTER_SET (30)
87
#define HA_SET_DEFAULT_CHARACTER_SET (31)
88
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
89
#define HA_ALTER_STORAGE (33)
90
#define HA_ALTER_TABLESPACE (34)
91
#define HA_ALTER_ROW_FORMAT (35)
92
#define HA_RENAME_TABLE (36)
93
#define HA_ALTER_STORAGE_ENGINE (37)
94
#define HA_RECREATE (38)
95
#define HA_ALTER_STORED_VCOL (39)
96
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
98
/* Return values for check_if_supported_alter */
100
#define HA_ALTER_ERROR -1
101
#define HA_ALTER_SUPPORTED_WAIT_LOCK 0
102
#define HA_ALTER_SUPPORTED_NO_LOCK 1
103
#define HA_ALTER_NOT_SUPPORTED 2
105
/* Bits in table_flags() to show what database can do */
107
#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */
108
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
109
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
111
The following should be set if the following is not true when scanning
112
a table with rnd_next()
113
- We will see all rows (including deleted ones)
114
- Row positions are 'table->s->db_record_offset' apart
115
If this flag is not set, filesort will do a postion() call for each matched
116
row to be able to find the row later.
118
#define HA_REC_NOT_IN_SEQ (1 << 3)
121
Reading keys in random order is as fast as reading keys in sort order
122
(Used in records.cc to decide if we should use a record cache and by
123
filesort to decide if we should sort key + data or key + pointer-to-row
125
#define HA_FAST_KEY_READ (1 << 5)
127
Set the following flag if we on delete should force all key to be read
128
and on update read all keys that changes
130
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
131
#define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */
132
#define HA_DUPLICATE_POS (1 << 8) /* ha_position() gives dup row */
133
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
134
#define HA_CAN_INDEX_BLOBS (1 << 10)
135
#define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */
136
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
137
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
139
If we get the primary key columns for free when we do an index read
140
It also implies that we have to retrive the primary key when using
141
position() and rnd_pos().
143
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
145
If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
146
uses a primary key. Without primary key, we can't call position().
148
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
149
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
151
The following is we need to a primary key to delete (and update) a row.
152
If there is no primary key, all columns needs to be read on update and delete
154
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
155
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
156
#define HA_NO_AUTO_INCREMENT (1 << 23)
157
#define HA_HAS_CHECKSUM (1 << 24)
158
/* Table data are stored in separate files (for lower_case_table_names) */
159
#define HA_FILE_BASED (1 << 26)
160
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
161
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
162
#define HA_NO_COPY_ON_ALTER (INT64_C(1) << 31)
163
#define HA_HAS_RECORDS (INT64_C(1) << 32) /* records() gives exact count*/
164
#define HA_MRR_CANT_SORT (INT64_C(1) << 34)
167
Engine is capable of row-format and statement-format logging,
170
#define HA_BINLOG_ROW_CAPABLE (INT64_C(1) << 35)
171
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
173
#define HA_ONLINE_ALTER (INT64_C(1) << 37)
176
Set of all binlog flags. Currently only contain the capabilities
179
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
181
/* bits in index_flags(index_number) for what you can do with index */
182
#define HA_READ_NEXT 1 /* TODO really use this flag */
183
#define HA_READ_PREV 2 /* supports ::index_prev */
184
#define HA_READ_ORDER 4 /* index_next/prev follow sort order */
185
#define HA_READ_RANGE 8 /* can find all records in a range */
186
#define HA_ONLY_WHOLE_INDEX 16 /* Can't use part key searches */
187
#define HA_KEYREAD_ONLY 64 /* Support HA_EXTRA_KEYREAD */
189
Index scan will not return records in rowid order. Not guaranteed to be
190
set for unordered (e.g. HASH) indexes.
192
#define HA_KEY_SCAN_NOT_ROR 128
193
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
198
HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
200
HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
201
exists but they are not necessarily done online.
203
HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
204
the new partition and to the old partitions when updating through the
205
old partitioning schema while performing a change of the partitioning.
206
This means that we can support updating of the table while performing
207
the copy phase of the change. For no lock at all also a double write
208
from new to old must exist and this is not required when this flag is
210
This is actually removed even before it was introduced the first time.
211
The new idea is that handlers will handle the lock level already in
212
store_lock for ALTER Table partitions.
214
HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
215
care of changing the partitions online and in one phase. Thus all phases
216
needed to handle the change are implemented inside the storage engine.
217
The storage engine must also support auto-discovery since the frm file
218
is changed as part of the change and this change must be controlled by
219
the storage engine. A typical engine to support this is NDB (through
222
#define HA_PARTITION_FUNCTION_SUPPORTED (1L << 1)
223
#define HA_FAST_CHANGE_PARTITION (1L << 2)
224
#define HA_PARTITION_ONE_PHASE (1L << 3)
226
/* operations for disable/enable indexes */
227
#define HA_KEY_SWITCH_NONUNIQ 0
228
#define HA_KEY_SWITCH_ALL 1
229
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
230
#define HA_KEY_SWITCH_ALL_SAVE 3
233
Note: the following includes binlog and closing 0.
234
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
235
example + csv + heap + blackhole + federated + 0
236
(yes, the sum is deliberately inaccurate)
237
TODO remove the limit, use dynarrays
242
Parameters for open() (in register form->filestat)
243
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
246
#define HA_OPEN_KEYFILE 1
247
#define HA_OPEN_RNDFILE 2
248
#define HA_GET_INDEX 4
249
#define HA_GET_INFO 8 /* do a ha_info() after open */
250
#define HA_READ_ONLY 16 /* File opened as readonly */
251
/* Try readonly if can't open with read and write */
252
#define HA_TRY_READ_ONLY 32
253
#define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */
254
#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/
255
#define HA_BLOCK_LOCK 256 /* unlock when reading some records */
256
#define HA_OPEN_TEMPORARY 512
258
/* For transactional LOCK Table. handler::lock_table() */
259
#define HA_LOCK_IN_SHARE_MODE F_RDLCK
260
#define HA_LOCK_IN_EXCLUSIVE_MODE F_WRLCK
262
/* Some key definitions */
263
#define HA_KEY_NULL_LENGTH 1
264
#define HA_KEY_BLOB_LENGTH 2
266
#define HA_LEX_CREATE_TMP_TABLE 1
267
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
268
#define HA_LEX_CREATE_TABLE_LIKE 4
269
#define HA_OPTION_NO_CHECKSUM (1L << 17)
270
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
271
#define HA_MAX_REC_LENGTH 65535
273
/* Table caching type */
274
#define HA_CACHE_TBL_NONTRANSACT 0
275
#define HA_CACHE_TBL_NOCACHE 1
276
#define HA_CACHE_TBL_ASKTRANSACT 2
277
#define HA_CACHE_TBL_TRANSACT 4
279
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
280
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
282
/* Flags for method is_fatal_error */
283
#define HA_CHECK_DUP_KEY 1
284
#define HA_CHECK_DUP_UNIQUE 2
285
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
290
DB_TYPE_FIRST_DYNAMIC=42,
291
DB_TYPE_DEFAULT=127 // Must be last
294
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
295
ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
296
ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
298
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
299
COLUMN_FORMAT_TYPE_DEFAULT= 0,
300
COLUMN_FORMAT_TYPE_FIXED= 1,
301
COLUMN_FORMAT_TYPE_DYNAMIC= 2 };
303
enum enum_binlog_func {
308
BFN_BINLOG_PURGE_FILE= 5
311
enum enum_binlog_command {
321
/* struct to hold information about the table that should be created */
323
/* Bits in used_fields */
324
#define HA_CREATE_USED_AUTO (1L << 0)
326
#define HA_CREATE_USED_UNION (1L << 2)
327
#define HA_CREATE_USED_PASSWORD (1L << 17)
329
#define HA_CREATE_USED_INSERT_METHOD (1L << 3)
330
#define HA_CREATE_USED_MIN_ROWS (1L << 4)
331
#define HA_CREATE_USED_MAX_ROWS (1L << 5)
332
#define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6)
333
#define HA_CREATE_USED_PACK_KEYS (1L << 7)
334
#define HA_CREATE_USED_CHARSET (1L << 8)
335
#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
336
#define HA_CREATE_USED_DATADIR (1L << 10)
337
#define HA_CREATE_USED_INDEXDIR (1L << 11)
338
#define HA_CREATE_USED_ENGINE (1L << 12)
339
#define HA_CREATE_USED_CHECKSUM (1L << 13)
340
#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14)
341
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
342
#define HA_CREATE_USED_COMMENT (1L << 16)
343
#define HA_CREATE_USED_CONNECTION (1L << 18)
344
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
345
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
346
#define HA_CREATE_USED_BLOCK_SIZE (1L << 22)
348
#define MAXGTRIDSIZE 64
349
#define MAXBQUALSIZE 64
351
#define COMPATIBLE_DATA_YES 0
352
#define COMPATIBLE_DATA_NO 1
354
40
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
355
41
uint32_t key_length,