1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
/* Definitions for parameters to do with handler-routines */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
23
#include <mysys/my_handler.h>
24
#include <storage/myisam/keycache.h>
27
#define NO_HASH /* Not yet implemented */
30
// the following is for checking tables
32
#define HA_ADMIN_ALREADY_DONE 1
34
#define HA_ADMIN_NOT_IMPLEMENTED -1
35
#define HA_ADMIN_FAILED -2
36
#define HA_ADMIN_CORRUPT -3
37
#define HA_ADMIN_INTERNAL_ERROR -4
38
#define HA_ADMIN_INVALID -5
39
#define HA_ADMIN_REJECT -6
40
#define HA_ADMIN_TRY_ALTER -7
41
#define HA_ADMIN_WRONG_CHECKSUM -8
42
#define HA_ADMIN_NOT_BASE_TABLE -9
43
#define HA_ADMIN_NEEDS_UPGRADE -10
44
#define HA_ADMIN_NEEDS_ALTER -11
45
#define HA_ADMIN_NEEDS_CHECK -12
47
/* Bits to show what an alter table will do */
48
#include <drizzled/sql_bitmap.h>
50
#define HA_MAX_ALTER_FLAGS 39
51
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
53
#define HA_ADD_INDEX (0)
54
#define HA_DROP_INDEX (1)
55
#define HA_ALTER_INDEX (2)
56
#define HA_RENAME_INDEX (3)
57
#define HA_ADD_UNIQUE_INDEX (4)
58
#define HA_DROP_UNIQUE_INDEX (5)
59
#define HA_ALTER_UNIQUE_INDEX (6)
60
#define HA_RENAME_UNIQUE_INDEX (7)
61
#define HA_ADD_PK_INDEX (8)
62
#define HA_DROP_PK_INDEX (9)
63
#define HA_ALTER_PK_INDEX (10)
64
#define HA_ADD_COLUMN (11)
65
#define HA_DROP_COLUMN (12)
66
#define HA_CHANGE_COLUMN (13)
67
#define HA_ALTER_COLUMN_NAME (14)
68
#define HA_ALTER_COLUMN_TYPE (15)
69
#define HA_ALTER_COLUMN_ORDER (16)
70
#define HA_ALTER_COLUMN_NULLABLE (17)
71
#define HA_COLUMN_DEFAULT_VALUE (18)
72
#define HA_COLUMN_STORAGE (19)
73
#define HA_COLUMN_FORMAT (20)
74
#define HA_ADD_FOREIGN_KEY (21)
75
#define HA_DROP_FOREIGN_KEY (22)
76
#define HA_ALTER_FOREIGN_KEY (23)
77
#define HA_ADD_CONSTRAINT (24)
78
#define HA_CHANGE_CHARACTER_SET (30)
79
#define HA_SET_DEFAULT_CHARACTER_SET (31)
80
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
81
#define HA_ALTER_STORAGE (33)
82
#define HA_ALTER_TABLESPACE (34)
83
#define HA_ALTER_ROW_FORMAT (35)
84
#define HA_RENAME_TABLE (36)
85
#define HA_ALTER_STORAGE_ENGINE (37)
86
#define HA_RECREATE (38)
87
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
89
/* Return values for check_if_supported_alter */
91
#define HA_ALTER_ERROR -1
92
#define HA_ALTER_SUPPORTED_WAIT_LOCK 0
93
#define HA_ALTER_SUPPORTED_NO_LOCK 1
94
#define HA_ALTER_NOT_SUPPORTED 2
96
/* Bits in table_flags() to show what database can do */
98
#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */
99
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
100
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
102
The following should be set if the following is not true when scanning
103
a table with rnd_next()
104
- We will see all rows (including deleted ones)
105
- Row positions are 'table->s->db_record_offset' apart
106
If this flag is not set, filesort will do a postion() call for each matched
107
row to be able to find the row later.
109
#define HA_REC_NOT_IN_SEQ (1 << 3)
110
/* This is now a dead option, just left for compatibility */
111
#define HA_CAN_GEOMETRY (1 << 4)
113
Reading keys in random order is as fast as reading keys in sort order
114
(Used in records.cc to decide if we should use a record cache and by
115
filesort to decide if we should sort key + data or key + pointer-to-row
117
#define HA_FAST_KEY_READ (1 << 5)
119
Set the following flag if we on delete should force all key to be read
120
and on update read all keys that changes
122
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
123
#define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */
124
#define HA_DUPLICATE_POS (1 << 8) /* ha_position() gives dup row */
125
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
126
#define HA_CAN_INDEX_BLOBS (1 << 10)
127
#define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */
128
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
129
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
131
INSERT_DELAYED only works with handlers that uses MySQL internal table
134
#define HA_CAN_INSERT_DELAYED (1 << 14)
136
If we get the primary key columns for free when we do an index read
137
It also implies that we have to retrive the primary key when using
138
position() and rnd_pos().
140
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
142
If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
143
uses a primary key. Without primary key, we can't call position().
145
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
146
#define HA_CAN_RTREEKEYS (1 << 17) /* Historical, no longer supported */
147
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
149
The following is we need to a primary key to delete (and update) a row.
150
If there is no primary key, all columns needs to be read on update and delete
152
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
153
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
154
#define HA_CAN_FULLTEXT (1 << 21) /* Historical, no longer supported */
155
#define HA_CAN_SQL_HANDLER (1 << 22) /* Historical, no longer supported */
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_NO_VARCHAR (1 << 27) /* Historical, no longer supported */
161
#define HA_CAN_BIT_FIELD (1 << 28) /* Historical, no longer supported */
162
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
163
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
164
#define HA_NO_COPY_ON_ALTER (1LL << 31)
165
#define HA_HAS_RECORDS (1LL << 32) /* records() gives exact count*/
166
/* Has it's own method of binlog logging */
167
#define HA_HAS_OWN_BINLOGGING (1LL << 33) /* Historical, no longer supported */
168
#define HA_MRR_CANT_SORT (1LL << 34)
171
Engine is capable of row-format and statement-format logging,
174
#define HA_BINLOG_ROW_CAPABLE (1LL << 35)
175
#define HA_BINLOG_STMT_CAPABLE (1LL << 36)
177
#define HA_ONLINE_ALTER (1LL << 37)
180
Set of all binlog flags. Currently only contain the capabilities
20
#ifndef DRIZZLED_CURSOR_H
21
#define DRIZZLED_CURSOR_H
23
#include <drizzled/xid.h>
24
#include <drizzled/discrete_interval.h>
25
#include <drizzled/identifier.h>
26
#include <drizzled/definitions.h>
27
#include <drizzled/key_map.h>
29
/* Definitions for parameters to do with Cursor-routines */
31
#include <drizzled/thr_lock.h>
32
#include <drizzled/sql_string.h>
33
#include <drizzled/sql_list.h>
34
#include <drizzled/plugin/storage_engine.h>
35
#include <drizzled/handler_structs.h>
36
#include <drizzled/ha_statistics.h>
37
#include <drizzled/atomics.h>
39
#include <drizzled/message/table.pb.h>
183
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
185
/* bits in index_flags(index_number) for what you can do with index */
186
#define HA_READ_NEXT 1 /* TODO really use this flag */
187
#define HA_READ_PREV 2 /* supports ::index_prev */
188
#define HA_READ_ORDER 4 /* index_next/prev follow sort order */
189
#define HA_READ_RANGE 8 /* can find all records in a range */
190
#define HA_ONLY_WHOLE_INDEX 16 /* Can't use part key searches */
191
#define HA_KEYREAD_ONLY 64 /* Support HA_EXTRA_KEYREAD */
193
Index scan will not return records in rowid order. Not guaranteed to be
194
set for unordered (e.g. HASH) indexes.
196
#define HA_KEY_SCAN_NOT_ROR 128
197
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
202
HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
204
HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
205
exists but they are not necessarily done online.
207
HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
208
the new partition and to the old partitions when updating through the
209
old partitioning schema while performing a change of the partitioning.
210
This means that we can support updating of the table while performing
211
the copy phase of the change. For no lock at all also a double write
212
from new to old must exist and this is not required when this flag is
214
This is actually removed even before it was introduced the first time.
215
The new idea is that handlers will handle the lock level already in
216
store_lock for ALTER Table partitions.
218
HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
219
care of changing the partitions online and in one phase. Thus all phases
220
needed to handle the change are implemented inside the storage engine.
221
The storage engine must also support auto-discovery since the frm file
222
is changed as part of the change and this change must be controlled by
223
the storage engine. A typical engine to support this is NDB (through
226
#define HA_PARTITION_FUNCTION_SUPPORTED (1L << 1)
227
#define HA_FAST_CHANGE_PARTITION (1L << 2)
228
#define HA_PARTITION_ONE_PHASE (1L << 3)
230
/* operations for disable/enable indexes */
231
#define HA_KEY_SWITCH_NONUNIQ 0
232
#define HA_KEY_SWITCH_ALL 1
233
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
234
#define HA_KEY_SWITCH_ALL_SAVE 3
237
Note: the following includes binlog and closing 0.
238
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
239
example + csv + heap + blackhole + federated + 0
240
(yes, the sum is deliberately inaccurate)
241
TODO remove the limit, use dynarrays
246
Parameters for open() (in register form->filestat)
247
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
250
#define HA_OPEN_KEYFILE 1
251
#define HA_OPEN_RNDFILE 2
252
#define HA_GET_INDEX 4
253
#define HA_GET_INFO 8 /* do a ha_info() after open */
254
#define HA_READ_ONLY 16 /* File opened as readonly */
255
/* Try readonly if can't open with read and write */
256
#define HA_TRY_READ_ONLY 32
257
#define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */
258
#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/
259
#define HA_BLOCK_LOCK 256 /* unlock when reading some records */
260
#define HA_OPEN_TEMPORARY 512
262
/* For transactional LOCK Table. handler::lock_table() */
263
#define HA_LOCK_IN_SHARE_MODE F_RDLCK
264
#define HA_LOCK_IN_EXCLUSIVE_MODE F_WRLCK
266
/* Some key definitions */
267
#define HA_KEY_NULL_LENGTH 1
268
#define HA_KEY_BLOB_LENGTH 2
270
#define HA_LEX_CREATE_TMP_TABLE 1
271
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
272
#define HA_LEX_CREATE_TABLE_LIKE 4
273
#define HA_OPTION_NO_CHECKSUM (1L << 17)
274
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
275
#define HA_MAX_REC_LENGTH 65535
277
/* Table caching type */
278
#define HA_CACHE_TBL_NONTRANSACT 0
279
#define HA_CACHE_TBL_NOCACHE 1
280
#define HA_CACHE_TBL_ASKTRANSACT 2
281
#define HA_CACHE_TBL_TRANSACT 4
283
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
284
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
286
/* Flags for method is_fatal_error */
287
#define HA_CHECK_DUP_KEY 1
288
#define HA_CHECK_DUP_UNIQUE 2
289
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
47
#define HA_MAX_ALTER_FLAGS 40
49
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
51
extern uint64_t refresh_version; /* Increments on each reload */
293
DB_TYPE_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1,
294
DB_TYPE_HASH,DB_TYPE_MISAM,DB_TYPE_PISAM,
295
DB_TYPE_RMS_ISAM, DB_TYPE_HEAP, DB_TYPE_ISAM,
296
DB_TYPE_MRG_ISAM, DB_TYPE_MYISAM, DB_TYPE_MRG_MYISAM,
297
DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB,
298
DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER,
299
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB,
300
DB_TYPE_FEDERATED_DB,
301
DB_TYPE_BLACKHOLE_DB,
302
DB_TYPE_PARTITION_DB,
306
DB_TYPE_TABLE_FUNCTION,
310
DB_TYPE_FIRST_DYNAMIC=42,
311
DB_TYPE_DEFAULT=127 // Must be last
314
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
315
ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
316
ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
318
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
319
COLUMN_FORMAT_TYPE_DEFAULT= 0,
320
COLUMN_FORMAT_TYPE_FIXED= 1,
321
COLUMN_FORMAT_TYPE_DYNAMIC= 2 };
323
enum enum_binlog_func {
328
BFN_BINLOG_PURGE_FILE= 5
331
enum enum_binlog_command {
341
/* struct to hold information about the table that should be created */
343
/* Bits in used_fields */
344
#define HA_CREATE_USED_AUTO (1L << 0)
346
#define HA_CREATE_USED_RAID (1L << 1) /* Historical, no longer supported */
347
#define HA_CREATE_USED_UNION (1L << 2)
348
#define HA_CREATE_USED_PASSWORD (1L << 17)
350
#define HA_CREATE_USED_INSERT_METHOD (1L << 3)
351
#define HA_CREATE_USED_MIN_ROWS (1L << 4)
352
#define HA_CREATE_USED_MAX_ROWS (1L << 5)
353
#define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6)
354
#define HA_CREATE_USED_PACK_KEYS (1L << 7)
355
#define HA_CREATE_USED_CHARSET (1L << 8)
356
#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
357
#define HA_CREATE_USED_DATADIR (1L << 10)
358
#define HA_CREATE_USED_INDEXDIR (1L << 11)
359
#define HA_CREATE_USED_ENGINE (1L << 12)
360
#define HA_CREATE_USED_CHECKSUM (1L << 13)
361
#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14)
362
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
363
#define HA_CREATE_USED_COMMENT (1L << 16)
364
#define HA_CREATE_USED_CONNECTION (1L << 18)
365
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
366
#define HA_CREATE_USED_TRANSACTIONAL (1L << 20)
367
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
368
#define HA_CREATE_USED_BLOCK_SIZE (1L << 22)
370
typedef uint64_t my_xid; // this line is the same as in log_event.h
371
#define DRIZZLE_XID_PREFIX "MySQLXid"
372
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
373
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
374
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
376
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
377
#define MAXGTRIDSIZE 64
378
#define MAXBQUALSIZE 64
380
#define COMPATIBLE_DATA_YES 0
381
#define COMPATIBLE_DATA_NO 1
383
typedef bool (*qc_engine_callback)(THD *thd, char *table_key,
385
uint64_t *engine_data);
388
struct xid_t is binary compatible with the XID structure as
389
in the X/Open CAE Specification, Distributed Transaction Processing:
390
The XA Specification, X/Open Company Ltd., 1991.
391
http://www.opengroup.org/bookstore/catalog/c193.htm
393
@see DRIZZLE_XID in mysql/plugin.h
399
char data[XIDDATASIZE]; // not \0-terminated !
401
xid_t() {} /* Remove gcc warning */
402
bool eq(struct xid_t *xid)
403
{ return eq(xid->gtrid_length, xid->bqual_length, xid->data); }
404
bool eq(long g, long b, const char *d)
405
{ return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); }
406
void set(struct xid_t *xid)
407
{ memcpy(this, xid, xid->length()); }
408
void set(long f, const char *g, long gl, const char *b, long bl)
411
memcpy(data, g, gtrid_length= gl);
412
memcpy(data+gl, b, bqual_length= bl);
414
void set(uint64_t xid)
418
set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX);
419
memcpy(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id));
421
memcpy(data+DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp));
422
gtrid_length=DRIZZLE_XID_GTRID_LEN;
424
void set(long g, long b, const char *d)
429
memcpy(data, d, g+b);
431
bool is_null() { return formatID == -1; }
432
void null() { formatID= -1; }
433
my_xid quick_get_my_xid()
436
memcpy(&tmp, data+DRIZZLE_XID_OFFSET, sizeof(tmp));
441
return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 &&
442
!memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
443
!memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ?
444
quick_get_my_xid() : 0;
448
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
449
gtrid_length+bqual_length;
453
return (uchar *)>rid_length;
457
return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
460
typedef struct xid_t XID;
462
/* for recover() handlerton call */
463
#define MIN_XID_LIST_SIZE 128
464
#define MAX_XID_LIST_SIZE (1024*128)
468
/* The handler for a table type. Will be included in the Table structure */
56
class Select_Lex_Unit;
471
typedef struct st_table_share TABLE_SHARE;
472
struct st_foreign_key_info;
473
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
474
typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
475
const char *file, uint file_len,
476
const char *status, uint status_len);
477
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
478
extern st_plugin_int *hton2plugin[MAX_HA];
481
handlerton is a singleton structure - one instance per storage engine -
482
to provide access to storage engine functionality that works on the
483
"global" level (unlike handler class that works on a per-table basis)
485
usually handlerton instance is defined statically in ha_xxx.cc as
487
static handlerton { ... } xxx_hton;
489
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
494
Historical marker for if the engine is available of not
496
SHOW_COMP_OPTION state;
499
Historical number used for frm file to determine the correct storage engine.
500
This is going away and new engines will just use "name" for this.
502
enum legacy_db_type db_type;
504
each storage engine has it's own memory area (actually a pointer)
505
in the thd, for storing per-connection information.
508
thd->ha_data[xxx_hton.slot]
510
slot number is initialized by MySQL after xxx_init() is called.
514
to store per-savepoint data storage engine is provided with an area
515
of a requested size (0 is ok here).
516
savepoint_offset must be initialized statically to the size of
517
the needed memory to store per-savepoint information.
518
After xxx_init it is changed to be an offset to savepoint storage
519
area and need not be used by storage engine.
520
see binlog_hton and binlog_savepoint_set/rollback for an example.
522
uint savepoint_offset;
526
close_connection is only called if
527
thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
528
this storage area - set it to something, so that MySQL would know
529
this storage engine was accessed in this connection
531
int (*close_connection)(handlerton *hton, THD *thd);
533
sv points to an uninitialized storage area of requested size
534
(see savepoint_offset description)
536
int (*savepoint_set)(handlerton *hton, THD *thd, void *sv);
538
sv points to a storage area, that was earlier passed
539
to the savepoint_set call
541
int (*savepoint_rollback)(handlerton *hton, THD *thd, void *sv);
542
int (*savepoint_release)(handlerton *hton, THD *thd, void *sv);
544
'all' is true if it's a real commit, that makes persistent changes
545
'all' is false if it's not in fact a commit but an end of the
546
statement that is part of the transaction.
547
NOTE 'all' is also false in auto-commit mode where 'end of statement'
548
and 'real commit' mean the same event.
550
int (*commit)(handlerton *hton, THD *thd, bool all);
551
int (*rollback)(handlerton *hton, THD *thd, bool all);
552
int (*prepare)(handlerton *hton, THD *thd, bool all);
553
int (*recover)(handlerton *hton, XID *xid_list, uint len);
554
int (*commit_by_xid)(handlerton *hton, XID *xid);
555
int (*rollback_by_xid)(handlerton *hton, XID *xid);
556
void *(*create_cursor_read_view)(handlerton *hton, THD *thd);
557
void (*set_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
558
void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
559
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
560
void (*drop_database)(handlerton *hton, char* path);
561
int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
562
bool (*flush_logs)(handlerton *hton);
563
bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
564
int (*fill_files_table)(handlerton *hton, THD *thd,
567
uint32_t flags; /* global handler flags */
568
int (*release_temporary_latches)(handlerton *hton, THD *thd);
570
int (*discover)(handlerton *hton, THD* thd, const char *db,
574
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
576
uint32_t license; /* Flag for Engine License */
577
void *data; /* Location for engines to keep personal structures */
581
/* Possible flags of a handlerton (there can be 32 of them) */
582
#define HTON_NO_FLAGS 0
583
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
584
#define HTON_ALTER_NOT_SUPPORTED (1 << 1) //Engine does not support alter
585
#define HTON_CAN_RECREATE (1 << 2) //Delete all is used fro truncate
586
#define HTON_HIDDEN (1 << 3) //Engine does not appear in lists
587
#define HTON_FLUSH_AFTER_RENAME (1 << 4)
588
#define HTON_NOT_USER_SELECTABLE (1 << 5)
589
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
590
#define HTON_SUPPORT_LOG_TABLES (1 << 7) //Engine supports log tables
591
#define HTON_NO_PARTITION (1 << 8) //You can not partition these tables
597
/* true is not all entries in the ht[] support 2pc */
599
/* storage engines that registered in this transaction */
600
Ha_trx_info *ha_list;
602
The purpose of this flag is to keep track of non-transactional
603
tables that were modified in scope of:
604
- transaction, when the variable is a member of
606
- top-level statement or sub-statement, when the variable is a
607
member of THD::transaction.stmt
608
This member has the following life cycle:
609
* stmt.modified_non_trans_table is used to keep track of
610
modified non-transactional tables of top-level statements. At
611
the end of the previous statement and at the beginning of the session,
612
it is reset to false. If such functions
613
as mysql_insert, mysql_update, mysql_delete etc modify a
614
non-transactional table, they set this flag to true. At the
615
end of the statement, the value of stmt.modified_non_trans_table
616
is merged with all.modified_non_trans_table and gets reset.
617
* all.modified_non_trans_table is reset at the end of transaction
619
* Since we do not have a dedicated context for execution of a
620
sub-statement, to keep track of non-transactional changes in a
621
sub-statement, we re-use stmt.modified_non_trans_table.
622
At entrance into a sub-statement, a copy of the value of
623
stmt.modified_non_trans_table (containing the changes of the
624
outer statement) is saved on stack. Then
625
stmt.modified_non_trans_table is reset to false and the
626
substatement is executed. Then the new value is merged with the
629
bool modified_non_trans_table;
631
void reset() { no_2pc= false; modified_non_trans_table= false; }
636
Either statement transaction or normal transaction - related
637
thread-specific storage engine data.
639
If a storage engine participates in a statement/transaction,
640
an instance of this class is present in
641
thd->transaction.{stmt|all}.ha_list. The addition to
642
{stmt|all}.ha_list is made by trans_register_ha().
644
When it's time to commit or rollback, each element of ha_list
645
is used to access storage engine's prepare()/commit()/rollback()
646
methods, and also to evaluate if a full two phase commit is
649
@sa General description of transaction handling in handler.cc.
655
/** Register this storage engine in the given transaction context. */
656
void register_ha(THD_TRANS *trans, handlerton *ht_arg)
658
assert(m_flags == 0);
659
assert(m_ht == NULL);
660
assert(m_next == NULL);
663
m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
665
m_next= trans->ha_list;
666
trans->ha_list= this;
669
/** Clear, prepare for reuse. */
677
Ha_trx_info() { reset(); }
679
void set_trx_read_write()
681
assert(is_started());
682
m_flags|= (int) TRX_READ_WRITE;
684
bool is_trx_read_write() const
686
assert(is_started());
687
return m_flags & (int) TRX_READ_WRITE;
689
bool is_started() const { return m_ht != NULL; }
690
/** Mark this transaction read-write if the argument is read-write. */
691
void coalesce_trx_with(const Ha_trx_info *stmt_trx)
694
Must be called only after the transaction has been started.
695
Can be called many times, e.g. when we have many
696
read-write statements in a transaction.
698
assert(is_started());
699
if (stmt_trx->is_trx_read_write())
700
set_trx_read_write();
702
Ha_trx_info *next() const
704
assert(is_started());
707
handlerton *ht() const
709
assert(is_started());
713
enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
714
/** Auxiliary, used for ha_list management */
717
Although a given Ha_trx_info instance is currently always used
718
for the same storage engine, 'ht' is not-NULL only when the
719
corresponding storage is a part of a transaction.
723
Transaction flags related to this engine.
724
Not-null only if this instance is a part of transaction.
725
May assume a combination of enum values above.
731
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
732
ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
735
uint64_t data_file_length;
736
uint64_t max_data_file_length;
737
uint64_t index_file_length;
738
uint64_t delete_length;
740
uint32_t mean_rec_length;
747
#define UNDEF_NODEGROUP 65535
70
typedef List<Item> List_item;
749
struct st_table_log_memory_entry;
751
#define NOT_A_PARTITION_ID ((uint32_t)-1)
753
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
755
typedef struct st_ha_create_information
757
const CHARSET_INFO *table_charset, *default_table_charset;
758
LEX_STRING connect_string;
760
const char *data_file_name, *index_file_name;
762
uint64_t max_rows,min_rows;
763
uint64_t auto_increment_value;
764
uint32_t table_options;
765
uint32_t avg_row_length;
766
uint32_t used_fields;
767
uint32_t key_block_size;
771
enum row_type row_type;
772
uint null_bits; /* NULL bits at start of record */
773
uint options; /* OR of HA_CREATE_ options */
774
uint merge_insert_method;
775
uint extra_size; /* length of extra data segment */
776
/* 0 not used, 1 if not transactional, 2 if transactional */
777
enum ha_choice transactional;
778
bool table_existed; /* 1 in create if table existed */
779
bool frm_only; /* 1 if no ha_create_table() */
780
bool varchar; /* 1 if table has a VARCHAR */
781
enum ha_choice page_checksum; /* If we have page_checksums */
784
typedef struct st_ha_alter_information
786
KEY *key_info_buffer;
788
uint index_drop_count;
789
uint *index_drop_buffer;
790
uint index_add_count;
791
uint *index_add_buffer;
796
typedef struct st_key_create_information
798
enum ha_key_alg algorithm;
800
LEX_STRING parser_name;
806
Class for maintaining hooks used inside operations on tables such
807
as: create table functions, delete table functions, and alter table
810
Class is using the Template Method pattern to separate the public
811
usage interface from the private inheritance interface. This
812
imposes no overhead, since the public non-virtual function is small
813
enough to be inlined.
815
The hooks are usually used for functions that does several things,
816
e.g., create_table_from_items(), which both create a table and lock
823
virtual ~TABLEOP_HOOKS() {}
825
inline void prelock(Table **tables, uint count)
827
do_prelock(tables, count);
830
inline int postlock(Table **tables, uint count)
832
return do_postlock(tables, count);
835
/* Function primitive that is called prior to locking tables */
836
virtual void do_prelock(Table **tables __attribute__((unused)),
837
uint count __attribute__((unused)))
839
/* Default is to do nothing */
843
Primitive called after tables are locked.
845
If an error is returned, the tables will be unlocked and error
848
@return Error code or zero.
850
virtual int do_postlock(Table **tables __attribute__((unused)),
851
uint count __attribute__((unused)))
853
return 0; /* Default is to do nothing */
857
typedef struct st_savepoint SAVEPOINT;
858
extern uint32_t savepoint_alloc_size;
71
859
extern KEY_CREATE_INFO default_key_create_info;
73
861
/* Forward declaration for condition pushdown to storage engine */
74
862
typedef class Item COND;
76
typedef struct system_status_var system_status_var;
864
typedef struct st_ha_check_opt
866
st_ha_check_opt() {} /* Remove gcc warning */
867
uint32_t sort_buffer_size;
868
uint flags; /* isam layer flags (e.g. for myisamchk) */
869
uint sql_flags; /* sql layer flags - for something myisamchk cannot do */
870
KEY_CACHE *key_cache; /* new key cache when changing key cache */
877
This is a buffer area that the handler can use to store rows.
878
'end_of_used_area' should be kept updated after calls to
879
read-functions so that other parts of the code can use the
880
remaining area (until next read calls is issued).
883
typedef struct st_handler_buffer
885
uchar *buffer; /* Buffer one can start using */
886
uchar *buffer_end; /* End of buffer */
887
uchar *end_of_used_area; /* End of area that was used by handler */
890
typedef struct system_status_var SSV;
893
typedef void *range_seq_t;
895
typedef struct st_range_seq_if
898
Initialize the traversal of range sequence
902
init_params The seq_init_param parameter
903
n_ranges The number of ranges obtained
904
flags A combination of HA_MRR_SINGLE_POINT, HA_MRR_FIXED_KEY
907
An opaque value to be used as RANGE_SEQ_IF::next() parameter
909
range_seq_t (*init)(void *init_params, uint n_ranges, uint flags);
913
Get the next range in the range sequence
917
seq The value returned by RANGE_SEQ_IF::init()
918
range OUT Information about the next range
921
0 - Ok, the range structure filled with info about the next range
924
uint (*next) (range_seq_t seq, KEY_MULTI_RANGE *range);
927
uint16_t &mrr_persistent_flag_storage(range_seq_t seq, uint idx);
928
char* &mrr_get_ptr_by_idx(range_seq_t seq, uint idx);
933
double io_count; /* number of I/O */
934
double avg_io_cost; /* cost of an average I/O oper. */
935
double cpu_cost; /* cost of operations in CPU */
936
double mem_cost; /* cost of used memory */
937
double import_cost; /* cost of remote operations */
940
enum { CPU_COEFF=1 };
941
enum { MEM_COEFF=1 };
942
enum { IMPORT_COEFF=1 };
944
COST_VECT() {} // keep gcc happy
948
return IO_COEFF*io_count*avg_io_cost + CPU_COEFF * cpu_cost +
949
MEM_COEFF*mem_cost + IMPORT_COEFF*import_cost;
955
io_count= cpu_cost= mem_cost= import_cost= 0.0;
958
void multiply(double m)
963
/* Don't multiply mem_cost */
966
void add(const COST_VECT* cost)
968
double io_count_sum= io_count + cost->io_count;
969
add_io(cost->io_count, cost->avg_io_cost);
970
io_count= io_count_sum;
971
cpu_cost += cost->cpu_cost;
973
void add_io(double add_io_cnt, double add_avg_cost)
975
double io_count_sum= io_count + add_io_cnt;
976
avg_io_cost= (io_count * avg_io_cost +
977
add_io_cnt * add_avg_cost) / io_count_sum;
978
io_count= io_count_sum;
982
void get_sweep_read_cost(Table *table, ha_rows nrows, bool interrupted,
986
The below two are not used (and not handled) in this milestone of this WL
987
entry because there seems to be no use for them at this stage of
990
#define HA_MRR_SINGLE_POINT 1
991
#define HA_MRR_FIXED_KEY 2
994
Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
997
#define HA_MRR_NO_ASSOCIATION 4
1000
The MRR user will provide ranges in key order, and MRR implementation
1001
must return rows in key order.
1003
#define HA_MRR_SORTED 8
1005
/* MRR implementation doesn't have to retrieve full records */
1006
#define HA_MRR_INDEX_ONLY 16
1009
The passed memory buffer is of maximum possible size, the caller can't
1010
assume larger buffer.
1012
#define HA_MRR_LIMITS 32
1016
Flag set <=> default MRR implementation is used
1017
(The choice is made by **_info[_const]() function which may set this
1018
flag. SQL layer remembers the flag value and then passes it to
1019
multi_read_range_init().
1021
#define HA_MRR_USE_DEFAULT_IMPL 64
1024
Used only as parameter to multi_range_read_info():
1025
Flag set <=> the caller guarantees that the bounds of the scanned ranges
1026
will not have NULL values.
1028
#define HA_MRR_NO_NULL_ENDPOINTS 128
1034
uint64_t data_file_length; /* Length off data file */
1035
uint64_t max_data_file_length; /* Length off data file */
1036
uint64_t index_file_length;
1037
uint64_t max_index_file_length;
1038
uint64_t delete_length; /* Free bytes */
1039
uint64_t auto_increment_value;
1041
The number of records in the table.
1042
0 - means the table has exactly 0 rows
1043
other - if (table_flags() & HA_STATS_RECORDS_IS_EXACT)
1044
the value is the exact number of records in the table
1049
ha_rows deleted; /* Deleted records */
1050
uint32_t mean_rec_length; /* physical reclength */
1051
time_t create_time; /* When table was created */
1054
uint block_size; /* index block size */
1057
data_file_length(0), max_data_file_length(0),
1058
index_file_length(0), delete_length(0), auto_increment_value(0),
1059
records(0), deleted(0), mean_rec_length(0), create_time(0),
1060
check_time(0), update_time(0), block_size(0)
1064
uint calculate_key_len(Table *, uint, const uchar *, key_part_map);
84
1066
bitmap with first N+1 bits set
85
1067
(keypart_map for a key prefix of [0..N] keyparts)
88
inline key_part_map make_keypart_map(T a)
90
return (((key_part_map)2 << a) - 1);
1069
#define make_keypart_map(N) (((key_part_map)2 << (N)) - 1)
94
1071
bitmap with first N bits set
95
1072
(keypart_map for a key prefix of [0..N-1] keyparts)
98
inline key_part_map make_prev_keypart_map(T a)
100
return (((key_part_map)1 << a) - 1);
1074
#define make_prev_keypart_map(N) (((key_part_map)1 << (N)) - 1)
104
The Cursor class is the interface for dynamically loadable
1077
The handler class is the interface for dynamically loadable
105
1078
storage engines. Do not add ifdefs and take care when adding or
106
1079
changing virtual functions to avoid vtable confusion
225
1198
Discrete_interval auto_inc_interval_for_cur_row;
227
Cursor(plugin::StorageEngine &engine_arg, Table &share_arg);
228
virtual ~Cursor(void);
229
virtual Cursor *clone(memory::Root *mem_root);
1200
handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
1201
:table_share(share_arg), table(0),
1202
estimation_rows_to_insert(0), ht(ht_arg),
1203
ref(0), in_range_check_pushed_down(false),
1204
key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
1205
ref_length(sizeof(my_off_t)),
1207
locked(false), implicit_emptied(0),
1208
pushed_cond(0), pushed_idx_cond(NULL), pushed_idx_cond_keyno(MAX_KEY),
1209
next_insert_id(0), insert_id_for_cur_row(0)
1211
virtual ~handler(void)
1213
assert(locked == false);
1214
/* TODO: assert(inited == NONE); */
1216
virtual handler *clone(MEM_ROOT *mem_root);
1217
/** This is called after create to allow us to set up cached variables */
1220
cached_table_flags= table_flags();
231
1222
/* ha_ methods: pubilc wrappers for private virtual API */
233
int ha_open(const TableIdentifier &identifier, int mode, int test_if_locked);
234
int startIndexScan(uint32_t idx, bool sorted);
236
int startTableScan(bool scan);
1224
int ha_open(Table *table, const char *name, int mode, int test_if_locked);
1225
int ha_index_init(uint idx, bool sorted)
1228
assert(inited==NONE);
1229
if (!(result= index_init(idx, sorted)))
1236
assert(inited==INDEX);
1239
return(index_end());
1241
int ha_rnd_init(bool scan)
1244
assert(inited==NONE || (inited==RND && scan));
1245
inited= (result= rnd_init(scan)) ? NONE: RND;
1250
assert(inited==RND);
240
1255
/* this is necessary in many places, e.g. in HANDLER command */
241
int ha_index_or_rnd_end();
1256
int ha_index_or_rnd_end()
1258
return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
1260
Table_flags ha_table_flags() const { return cached_table_flags; }
244
1262
These functions represent the public interface to *users* of the
245
Cursor class, hence they are *not* virtual. For the inheritance
246
interface, see the (private) functions doInsertRecord(), doUpdateRecord(),
247
and doDeleteRecord() below.
1263
handler class, hence they are *not* virtual. For the inheritance
1264
interface, see the (private) functions write_row(), update_row(),
1265
and delete_row() below.
249
int ha_external_lock(Session *session, int lock_type);
250
int insertRecord(unsigned char * buf);
251
int updateRecord(const unsigned char * old_data, unsigned char * new_data);
252
int deleteRecord(const unsigned char * buf);
1267
int ha_external_lock(THD *thd, int lock_type);
1268
int ha_write_row(uchar * buf);
1269
int ha_update_row(const uchar * old_data, uchar * new_data);
1270
int ha_delete_row(const uchar * buf);
253
1271
void ha_release_auto_increment();
1273
int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
255
1274
/** to be actually called to get 'check()' functionality*/
256
int ha_check(Session *session, HA_CHECK_OPT *check_opt);
258
void ha_start_bulk_insert(ha_rows rows);
259
int ha_end_bulk_insert();
1275
int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
1276
int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
1277
void ha_start_bulk_insert(ha_rows rows)
1279
estimation_rows_to_insert= rows;
1280
start_bulk_insert(rows);
1282
int ha_end_bulk_insert()
1284
estimation_rows_to_insert= 0;
1285
return end_bulk_insert();
1287
int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
1288
uint *dup_key_found);
260
1289
int ha_delete_all_rows();
261
1290
int ha_reset_auto_increment(uint64_t value);
262
int ha_analyze(Session* session, HA_CHECK_OPT* check_opt);
264
int ha_disable_indexes(uint32_t mode);
265
int ha_enable_indexes(uint32_t mode);
1291
int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1292
int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1293
bool ha_check_and_repair(THD *thd);
1294
int ha_disable_indexes(uint mode);
1295
int ha_enable_indexes(uint mode);
266
1296
int ha_discard_or_import_tablespace(bool discard);
267
void closeMarkForDelete(const char *name);
1297
void ha_prepare_for_alter();
1298
int ha_rename_table(const char *from, const char *to);
1299
int ha_delete_table(const char *name);
1300
void ha_drop_table(const char *name);
1302
int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
1304
int ha_create_handler_files(const char *name, const char *old_name,
1305
int action_flag, HA_CREATE_INFO *info);
269
1307
void adjust_next_insert_id_after_explicit_value(uint64_t nr);
270
1308
int update_auto_increment();
1309
void print_keydup_error(uint key_nr, const char *msg);
1310
virtual void print_error(int error, myf errflag);
1311
virtual bool get_error_message(int error, String *buf);
1312
uint get_dup_key(int error);
1313
virtual void change_table_ptr(Table *table_arg, TABLE_SHARE *share)
272
1318
/* Estimates calculation */
273
1319
virtual double scan_time(void)
274
1320
{ return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
275
virtual double read_time(uint32_t, uint32_t ranges, ha_rows rows)
1321
virtual double read_time(uint index __attribute__((unused)),
1322
uint ranges, ha_rows rows)
276
1323
{ return rows2double(ranges+rows); }
278
virtual double index_only_read_time(uint32_t keynr, double records);
280
virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
281
void *seq_init_param,
282
uint32_t n_ranges, uint32_t *bufsz,
283
uint32_t *flags, optimizer::CostVector *cost);
284
virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
285
uint32_t *bufsz, uint32_t *flags, optimizer::CostVector *cost);
1325
virtual double index_only_read_time(uint keynr, double records);
1327
virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
1328
void *seq_init_param,
1329
uint n_ranges, uint *bufsz,
1330
uint *flags, COST_VECT *cost);
1331
virtual int multi_range_read_info(uint keyno, uint n_ranges, uint keys,
1332
uint *bufsz, uint *flags, COST_VECT *cost);
286
1333
virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
287
uint32_t n_ranges, uint32_t mode);
1334
uint n_ranges, uint mode,
1335
HANDLER_BUFFER *buf);
288
1336
virtual int multi_range_read_next(char **range_info);
291
virtual const key_map *keys_to_use_for_scanning();
292
bool has_transactions();
1339
virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; }
1340
bool has_transactions()
1341
{ return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0; }
1342
virtual uint extra_rec_buf_length() const { return 0; }
295
1345
This method is used to analyse the error to see whether the error
296
1346
is ignorable or not, certain handlers can have more error that are
297
ignorable than others. E.g. the partition Cursor can get inserts
1347
ignorable than others. E.g. the partition handler can get inserts
298
1348
into a range where there is no partition and this is an ignorable
300
1350
HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
301
1351
same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to
302
1352
a slightly different error message.
304
virtual bool is_fatal_error(int error, uint32_t flags);
1354
virtual bool is_fatal_error(int error, uint flags)
1357
((flags & HA_CHECK_DUP_KEY) &&
1358
(error == HA_ERR_FOUND_DUPP_KEY ||
1359
error == HA_ERR_FOUND_DUPP_UNIQUE)))
307
1365
Number of rows in table. It will only be called if
308
1366
(table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
310
virtual ha_rows records();
311
virtual uint64_t tableSize();
312
virtual uint64_t rowSize();
1368
virtual ha_rows records() { return stats.records; }
314
1370
Return upper bound of current number of records in the table
315
1371
(max. of how many records one will retrieve when doing a full table scan)
477
1687
@note that one can NOT rely on table->in_use in store_lock(). It may
478
refer to a different thread if called from abortLockForThread().
1688
refer to a different thread if called from mysql_lock_abort_for_thread().
480
1690
@note If the table is MERGE, store_lock() can return less locks
481
1691
than lock_count() claimed. This can happen when the MERGE children
482
1692
are not attached when this is called from another thread.
484
virtual THR_LOCK_DATA **store_lock(Session *,
1694
virtual THR_LOCK_DATA **store_lock(THD *thd,
485
1695
THR_LOCK_DATA **to,
1696
enum thr_lock_type lock_type)=0;
1698
/** Type of table for caching query */
1699
virtual uint8_t table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; }
1703
@brief Register a named table with a call back function to the query cache.
1705
@param thd The thread handle
1706
@param table_key A pointer to the table name in the table cache
1707
@param key_length The length of the table name
1708
@param[out] engine_callback The pointer to the storage engine call back
1710
@param[out] engine_data Storage engine specific data which could be
1713
This method offers the storage engine, the possibility to store a reference
1714
to a table name which is going to be used with query cache.
1715
The method is called each time a statement is written to the cache and can
1716
be used to verify if a specific statement is cachable. It also offers
1717
the possibility to register a generic (but static) call back function which
1718
is called each time a statement is matched against the query cache.
1720
@note If engine_data supplied with this function is different from
1721
engine_data supplied with the callback function, and the callback returns
1722
false, a table invalidation on the current table will occur.
1724
@return Upon success the engine_callback will point to the storage engine
1725
call back function, if any, and engine_data will point to any storage
1726
engine data used in the specific implementation.
1727
@retval true Success
1728
@retval false The specified table or current statement should not be
1733
register_query_cache_table(THD *thd __attribute__((unused)),
1734
char *table_key __attribute__((unused)),
1735
uint key_length __attribute__((unused)),
1736
qc_engine_callback *engine_callback,
1737
uint64_t *engine_data __attribute__((unused)))
488
assert(0); // Impossible programming situation
1739
*engine_callback= 0;
494
1745
@retval true Primary key (if there is one) is clustered
495
1746
key covering all fields
496
1747
@retval false otherwise
498
1749
virtual bool primary_key_is_clustered() { return false; }
499
virtual int cmp_ref(const unsigned char *ref1, const unsigned char *ref2)
1750
virtual int cmp_ref(const uchar *ref1, const uchar *ref2)
501
1752
return memcmp(ref1, ref2, ref_length);
504
virtual bool isOrdered(void)
1756
Condition pushdown to storage engines
1760
Push condition down to the table handler.
1762
@param cond Condition to be pushed. The condition tree must not be
1763
modified by the by the caller.
1766
The 'remainder' condition that caller must use to filter out records.
1767
NULL means the handler will not return rows that do not match the
1771
The pushed conditions form a stack (from which one can remove the
1772
last pushed condition using cond_pop).
1773
The table handler filters out rows using (pushed_cond1 AND pushed_cond2
1774
AND ... AND pushed_condN)
1775
or less restrictive condition, depending on handler's capabilities.
1777
handler->ha_reset() call empties the condition stack.
1778
Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
1781
virtual const COND *cond_push(const COND *cond) { return cond; }
1784
Pop the top condition from the condition stack of the handler instance.
1786
Pops the top if condition stack, if stack is not empty.
1788
virtual void cond_pop(void) { return; }
1791
*idx_cond_push(uint keyno __attribute__((unused)),
1792
Item* idx_cond __attribute__((unused)))
1793
{ return idx_cond; }
1796
Part of old fast alter table, to be depricated
1799
check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((unused)),
1800
uint table_changes __attribute__((unused)))
1801
{ return COMPATIBLE_DATA_NO; }
1803
/* On-line ALTER Table interface */
1806
Check if a storage engine supports a particular alter table on-line
1808
@param altered_table A temporary table show what table is to
1810
@param create_info Information from the parsing phase about new
1812
@param alter_flags Bitmask that shows what will be changed
1813
@param table_changes Shows if table layout has changed (for
1814
backwards compatibility with
1815
check_if_incompatible_data
1817
@retval HA_ALTER_ERROR Unexpected error
1818
@retval HA_ALTER_SUPPORTED_WAIT_LOCK Supported, but requires DDL lock
1819
@retval HA_ALTER_SUPPORTED_NO_LOCK Supported
1820
@retval HA_ALTER_NOT_SUPPORTED Not supported
1823
The default implementation is implemented to support fast
1824
alter table (storage engines that support some changes by
1825
just changing the frm file) without any change in the handler
1829
check_if_supported_alter(Table *altered_table __attribute__((unused)),
1830
HA_CREATE_INFO *create_info,
1831
HA_ALTER_FLAGS *alter_flags __attribute__((unused)),
1834
if (this->check_if_incompatible_data(create_info, table_changes)
1835
== COMPATIBLE_DATA_NO)
1836
return(HA_ALTER_NOT_SUPPORTED);
1838
return(HA_ALTER_SUPPORTED_WAIT_LOCK);
1841
Tell storage engine to prepare for the on-line alter table (pre-alter)
1843
@param thd The thread handle
1844
@param altered_table A temporary table show what table is to
1846
@param alter_info Storage place for data used during phase1
1848
@param alter_flags Bitmask that shows what will be changed
1851
@retval error error code passed from storage engine
1853
virtual int alter_table_phase1(THD *thd __attribute__((unused)),
1854
Table *altered_table __attribute__((unused)),
1855
HA_CREATE_INFO *create_info __attribute__((unused)),
1856
HA_ALTER_INFO *alter_info __attribute__((unused)),
1857
HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
1859
return HA_ERR_UNSUPPORTED;
1862
Tell storage engine to perform the on-line alter table (alter)
1864
@param thd The thread handle
1865
@param altered_table A temporary table show what table is to
1867
@param alter_info Storage place for data used during phase1
1869
@param alter_flags Bitmask that shows what will be changed
1872
@retval error error code passed from storage engine
1875
If check_if_supported_alter returns HA_ALTER_SUPPORTED_WAIT_LOCK
1876
this call is to be wrapped with a DDL lock. This is currently NOT
1879
virtual int alter_table_phase2(THD *thd __attribute__((unused)),
1880
Table *altered_table __attribute__((unused)),
1881
HA_CREATE_INFO *create_info __attribute__((unused)),
1882
HA_ALTER_INFO *alter_info __attribute__((unused)),
1883
HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
1885
return HA_ERR_UNSUPPORTED;
1888
Tell storage engine that changed frm file is now on disk and table
1889
has been re-opened (post-alter)
1891
@param thd The thread handle
1892
@param table The altered table, re-opened
1894
virtual int alter_table_phase3(THD *thd __attribute__((unused)),
1895
Table *table __attribute__((unused)))
1897
return HA_ERR_UNSUPPORTED;
1901
use_hidden_primary_key() is called in case of an update/delete when
1902
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
1903
but we don't have a primary key
1905
virtual void use_hidden_primary_key();
1910
@param thd Thread handle
1911
@param lock_type HA_LOCK_IN_SHARE_MODE (F_RDLCK)
1912
HA_LOCK_IN_EXCLUSIVE_MODE (F_WRLCK)
1913
@param lock_timeout -1 default timeout
1915
>0 wait timeout in milliseconds.
1918
lock_timeout >0 is not used by MySQL currently. If the storage
1919
engine does not support NOWAIT (lock_timeout == 0) it should
1920
return an error. But if it does not support WAIT X (lock_timeout
1921
>0) it should treat it as lock_timeout == -1 and wait a default
1922
(or even hard-coded) timeout.
1924
@retval HA_ERR_WRONG_COMMAND Storage engine does not support
1926
@retval HA_ERR_UNSUPPORTED Storage engine does not support NOWAIT
1927
@retval HA_ERR_LOCK_WAIT_TIMEOUT Lock request timed out or
1928
lock conflict with NOWAIT option
1929
@retval HA_ERR_LOCK_DEADLOCK Deadlock detected
1931
virtual int lock_table(THD *thd __attribute__((unused)),
1932
int lock_type __attribute__((unused)),
1933
int lock_timeout __attribute__((unused)))
1935
return HA_ERR_WRONG_COMMAND;
511
1939
/* Service methods for use by storage engines. */
512
void ha_statistic_increment(uint64_t system_status_var::*offset) const;
513
void **ha_data(Session *) const;
1940
void ha_statistic_increment(ulong SSV::*offset) const;
1941
void **ha_data(THD *) const;
1942
THD *ha_thd(void) const;
1945
Default rename_table() and delete_table() rename/delete files with a
1946
given name and extensions from bas_ext().
1948
These methods can be overridden, but their default implementation
1949
provide useful functionality.
1951
virtual int rename_table(const char *from, const char *to);
1953
Delete a table in the engine. Called for base as well as temporary
1956
virtual int delete_table(const char *name);
516
1959
/* Private helpers */
517
inline void setTransactionReadWrite();
1960
inline void mark_trx_read_write();
520
1963
Low-level primitives for storage engines. These should be
579
2024
@return non-0 in case of failure, 0 in case of success.
580
2025
When lock_type is F_UNLCK, the return value is ignored.
582
virtual int external_lock(Session *, int)
2027
virtual int external_lock(THD *thd __attribute__((unused)),
2028
int lock_type __attribute__((unused)))
586
virtual void release_auto_increment(void) { return; }
2032
virtual void release_auto_increment(void) { return; };
587
2033
/** admin commands - called from mysql_admin_table */
588
virtual int check(Session *)
2034
virtual int check_for_upgrade(HA_CHECK_OPT *check_opt __attribute__((unused)))
2036
virtual int check(THD* thd __attribute__((unused)),
2037
HA_CHECK_OPT* check_opt __attribute__((unused)))
589
2038
{ return HA_ADMIN_NOT_IMPLEMENTED; }
591
virtual void start_bulk_insert(ha_rows)
2041
In this method check_opt can be modified
2042
to specify CHECK option to use to call check()
2045
virtual int repair(THD* thd __attribute__((unused)),
2046
HA_CHECK_OPT* check_opt __attribute__((unused)))
2047
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2048
virtual void start_bulk_insert(ha_rows rows __attribute__((unused)))
593
2050
virtual int end_bulk_insert(void) { return 0; }
594
virtual int index_read(unsigned char *, const unsigned char *,
595
uint32_t, enum ha_rkey_function)
2051
virtual int index_read(uchar * buf __attribute__((unused)),
2052
const uchar * key __attribute__((unused)),
2053
uint key_len __attribute__((unused)),
2054
enum ha_rkey_function find_flag __attribute__((unused)))
596
2055
{ return HA_ERR_WRONG_COMMAND; }
597
virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)
598
{ return (errno= HA_ERR_WRONG_COMMAND); }
2056
virtual int index_read_last(uchar * buf __attribute__((unused)),
2057
const uchar * key __attribute__((unused)),
2058
uint key_len __attribute__((unused)))
2059
{ return (my_errno= HA_ERR_WRONG_COMMAND); }
2061
This method is similar to update_row, however the handler doesn't need
2062
to execute the updates at this point in time. The handler can be certain
2063
that another call to bulk_update_row will occur OR a call to
2064
exec_bulk_update before the set of updates in this query is concluded.
2066
@param old_data Old record
2067
@param new_data New record
2068
@param dup_key_found Number of duplicate keys found
2070
@retval 0 Bulk delete used by handler
2071
@retval 1 Bulk delete not used, normal operation used
2073
virtual int bulk_update_row(const uchar *old_data __attribute__((unused)),
2074
uchar *new_data __attribute__((unused)),
2075
uint *dup_key_found __attribute__((unused)))
2078
return HA_ERR_WRONG_COMMAND;
600
2081
This is called to delete all rows in a table
601
If the Cursor don't support this, then this function will
2082
If the handler don't support this, then this function will
602
2083
return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
605
2086
virtual int delete_all_rows(void)
606
{ return (errno=HA_ERR_WRONG_COMMAND); }
2087
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
608
2089
Reset the auto-increment counter to the given value, i.e. the next row
609
2090
inserted will get the given value. This is called e.g. after TRUNCATE
610
2091
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
611
2092
returned by storage engines that don't support this operation.
613
virtual int reset_auto_increment(uint64_t)
614
{ return HA_ERR_WRONG_COMMAND; }
616
virtual int analyze(Session *)
617
{ return HA_ADMIN_NOT_IMPLEMENTED; }
619
virtual int disable_indexes(uint32_t)
620
{ return HA_ERR_WRONG_COMMAND; }
622
virtual int enable_indexes(uint32_t)
623
{ return HA_ERR_WRONG_COMMAND; }
625
virtual int discard_or_import_tablespace(bool)
626
{ return (errno=HA_ERR_WRONG_COMMAND); }
629
@todo this is just for the HEAP engine, it should
630
be removed at some point in the future (and
631
no new engine should ever use it). Right
632
now HEAP does rely on it, so we cannot remove it.
2094
virtual int reset_auto_increment(uint64_t value __attribute__((unused)))
2095
{ return HA_ERR_WRONG_COMMAND; }
2096
virtual int optimize(THD* thd __attribute__((unused)),
2097
HA_CHECK_OPT* check_opt __attribute__((unused)))
2098
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2099
virtual int analyze(THD* thd __attribute__((unused)),
2100
HA_CHECK_OPT* check_opt __attribute__((unused)))
2101
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2102
virtual bool check_and_repair(THD *thd __attribute__((unused)))
2104
virtual int disable_indexes(uint mode __attribute__((unused)))
2105
{ return HA_ERR_WRONG_COMMAND; }
2106
virtual int enable_indexes(uint mode __attribute__((unused)))
2107
{ return HA_ERR_WRONG_COMMAND; }
2108
virtual int discard_or_import_tablespace(bool discard __attribute__((unused)))
2109
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
2110
virtual void prepare_for_alter(void) { return; }
634
2111
virtual void drop_table(const char *name);
2112
virtual int create(const char *name __attribute__((unused)),
2113
Table *form __attribute__((unused)),
2114
HA_CREATE_INFO *info __attribute__((unused)))=0;
2116
virtual int create_handler_files(const char *name __attribute__((unused)),
2117
const char *old_name __attribute__((unused)),
2118
int action_flag __attribute__((unused)),
2119
HA_CREATE_INFO *info __attribute__((unused)))
2126
A Disk-Sweep MRR interface implementation
2128
This implementation makes range (and, in the future, 'ref') scans to read
2129
table rows in disk sweeps.
2131
Currently it is used by MyISAM and InnoDB. Potentially it can be used with
2132
any table handler that has non-clustered indexes and on-disk rows.
2138
typedef void (handler::*range_check_toggle_func_t)(bool on);
2143
handler *h; /* The "owner" handler object. It is used for scanning the index */
2144
Table *table; /* Always equal to h->table */
2147
Secondary handler object. It is used to retrieve full table rows by
2152
/* Buffer to store rowids, or (rowid, range_id) pairs */
2154
uchar *rowids_buf_cur; /* Current position when reading/writing */
2155
uchar *rowids_buf_last; /* When reading: end of used buffer space */
2156
uchar *rowids_buf_end; /* End of the buffer */
2158
bool dsmrr_eof; /* true <=> We have reached EOF when reading index tuples */
2160
/* true <=> need range association, buffer holds {rowid, range_id} pairs */
2163
bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
2165
void init(handler *h_arg, Table *table_arg)
2170
int dsmrr_init(handler *h, KEY *key, RANGE_SEQ_IF *seq_funcs,
2171
void *seq_init_param, uint n_ranges, uint mode,
2172
HANDLER_BUFFER *buf);
2174
int dsmrr_fill_buffer(handler *h);
2175
int dsmrr_next(handler *h, char **range_info);
2177
int dsmrr_info(uint keyno, uint n_ranges, uint keys, uint *bufsz,
2178
uint *flags, COST_VECT *cost);
2180
ha_rows dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq,
2181
void *seq_init_param, uint n_ranges, uint *bufsz,
2182
uint *flags, COST_VECT *cost);
2184
bool key_uses_partial_cols(uint keyno);
2185
bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz,
2187
bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
2188
uint *buffer_size, COST_VECT *cost);
637
2191
extern const char *ha_row_type[];
2192
extern const char *tx_isolation_names[];
2193
extern const char *binlog_format_names[];
2194
extern TYPELIB tx_isolation_typelib;
2195
extern TYPELIB myisam_stats_method_typelib;
2196
extern uint32_t total_ha, total_ha_2pc;
2198
/* Wrapper functions */
2199
#define ha_commit(thd) (ha_commit_trans((thd), true))
2200
#define ha_rollback(thd) (ha_rollback_trans((thd), true))
2203
handlerton *ha_default_handlerton(THD *thd);
2204
plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name);
2205
plugin_ref ha_lock_engine(THD *thd, handlerton *hton);
2206
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
2207
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
2208
handlerton *db_type);
2209
handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
2210
bool no_substitute, bool report_error);
2213
static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type)
2215
return (db_type == NULL) ? DB_TYPE_UNKNOWN : db_type->db_type;
2218
static inline const char *ha_resolve_storage_engine_name(const handlerton *db_type)
2220
return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name.str;
2223
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32_t flag)
2225
return db_type == NULL ? false : test(db_type->flags & flag);
2228
static inline bool ha_storage_engine_is_enabled(const handlerton *db_type)
2230
return (db_type && db_type->create) ?
2231
(db_type->state == SHOW_OPTION_YES) : false;
639
2234
/* basic stuff */
640
void ha_init_errors(void);
643
SortField *make_unireg_sortorder(Order *order, uint32_t *length,
644
SortField *sortorder);
645
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
646
List<Item> &fields, List <Item> &all_fields, Order *order);
647
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
648
List<Item> &fields, List<Item> &all_fields, Order *order,
649
bool *hidden_group_fields);
650
bool fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select,
651
Item **ref_pointer_array);
653
bool handle_select(Session *session, LEX *lex, select_result *result,
654
uint64_t setup_tables_done_option);
655
void free_underlaid_joins(Session *session, Select_Lex *select);
657
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
660
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
661
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
662
int prepare_create_field(CreateField *sql_field,
663
uint32_t *blob_columns,
664
int *timestamps, int *timestamps_with_niladic);
666
bool mysql_create_table(Session *session,
667
const TableIdentifier &identifier,
668
HA_CREATE_INFO *create_info,
669
message::Table &table_proto,
670
AlterInfo *alter_info,
671
bool tmp_table, uint32_t select_field_count,
672
bool is_if_not_exists);
674
bool mysql_create_table_no_lock(Session *session,
675
const TableIdentifier &identifier,
676
HA_CREATE_INFO *create_info,
677
message::Table &table_proto,
678
AlterInfo *alter_info,
679
bool tmp_table, uint32_t select_field_count,
680
bool is_if_not_exists);
682
bool mysql_create_like_table(Session* session,
683
const TableIdentifier &destination_identifier,
684
TableList* table, TableList* src_table,
685
message::Table &create_table_proto,
686
bool is_if_not_exists,
689
bool mysql_rename_table(Session &session,
690
plugin::StorageEngine *base,
691
const TableIdentifier &old_identifier,
692
const TableIdentifier &new_identifier);
694
bool mysql_prepare_update(Session *session, TableList *table_list,
695
Item **conds, uint32_t order_num, Order *order);
696
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
697
List<Item> &values,COND *conds,
698
uint32_t order_num, Order *order, ha_rows limit,
699
enum enum_duplicates handle_duplicates, bool ignore);
700
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
701
List<Item> &fields, List_item *values,
702
List<Item> &update_fields,
703
List<Item> &update_values, enum_duplicates duplic,
704
COND **where, bool select_insert,
705
bool check_fields, bool abort_on_warning);
706
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
707
List<List_item> &values, List<Item> &update_fields,
708
List<Item> &update_values, enum_duplicates flag,
710
int check_that_all_fields_are_given_values(Session *session, Table *entry,
711
TableList *table_list);
712
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
713
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
714
SQL_LIST *order, ha_rows rows, uint64_t options,
715
bool reset_auto_increment);
716
bool mysql_truncate(Session& session, TableList *table_list);
717
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
718
uint32_t key_length, uint32_t db_flags, int *error);
719
TableShare *get_cached_table_share(const char *db, const char *table_name);
720
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
721
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
722
void close_handle_and_leave_table_as_lock(Table *table);
723
bool wait_for_tables(Session *session);
724
bool table_is_used(Table *table, bool wait_for_name_lock);
725
Table *drop_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
726
void abort_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
727
extern Field *not_found_field;
728
extern Field *view_ref_found;
731
find_field_in_tables(Session *session, Item_ident *item,
732
TableList *first_table, TableList *last_table,
733
Item **ref, find_item_error_report_type report_error,
734
bool register_tree_change);
736
find_field_in_table_ref(Session *session, TableList *table_list,
737
const char *name, uint32_t length,
738
const char *item_name, const char *db_name,
739
const char *table_name, Item **ref,
741
uint32_t *cached_field_index_ptr,
742
bool register_tree_change, TableList **actual_table);
744
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
745
bool allow_rowid, uint32_t *cached_field_index_ptr);
747
} /* namespace drizzled */
749
#endif /* DRIZZLED_CURSOR_H */
2235
int ha_init_errors(void);
2238
int ha_initialize_handlerton(st_plugin_int *plugin);
2239
int ha_finalize_handlerton(st_plugin_int *plugin);
2241
TYPELIB *ha_known_exts(void);
2242
void ha_close_connection(THD* thd);
2243
bool ha_flush_logs(handlerton *db_type);
2244
void ha_drop_database(char* path);
2245
int ha_create_table(THD *thd, const char *path,
2246
const char *db, const char *table_name,
2247
HA_CREATE_INFO *create_info,
2248
bool update_create_info);
2249
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
2250
const char *db, const char *alias, bool generate_warning);
2252
/* statistics and info */
2253
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
2256
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
2257
int ha_discover(THD* thd, const char* dbname, const char* name,
2258
uchar** frmblob, size_t* frmlen);
2259
int ha_find_files(THD *thd,const char *db,const char *path,
2260
const char *wild, bool dir, List<LEX_STRING>* files);
2261
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
2264
extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache);
2265
int ha_resize_key_cache(KEY_CACHE *key_cache);
2266
int ha_change_key_cache_param(KEY_CACHE *key_cache);
2267
int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
2268
int ha_end_key_cache(KEY_CACHE *key_cache);
2270
/* report to InnoDB that control passes to the client */
2271
int ha_release_temporary_latches(THD *thd);
2273
/* transactions: interface to handlerton functions */
2274
int ha_start_consistent_snapshot(THD *thd);
2275
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
2276
int ha_commit_one_phase(THD *thd, bool all);
2277
int ha_rollback_trans(THD *thd, bool all);
2278
int ha_prepare(THD *thd);
2279
int ha_recover(HASH *commit_list);
2281
/* transactions: these functions never call handlerton functions directly */
2282
int ha_commit_trans(THD *thd, bool all);
2283
int ha_autocommit_or_rollback(THD *thd, int error);
2284
int ha_enable_transaction(THD *thd, bool on);
2287
int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv);
2288
int ha_savepoint(THD *thd, SAVEPOINT *sv);
2289
int ha_release_savepoint(THD *thd, SAVEPOINT *sv);
2291
/* these are called by storage engines */
2292
void trans_register_ha(THD *thd, bool all, handlerton *ht);
2295
Storage engine has to assume the transaction will end up with 2pc if
2296
- there is more than one 2pc-capable storage engine available
2297
- in the current transaction 2pc was not disabled yet
2299
#define trans_need_2pc(thd, all) ((total_ha_2pc > 1) && \
2300
!((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
2302
#ifdef HAVE_NDB_BINLOG
2303
int ha_reset_logs(THD *thd);
2304
int ha_binlog_index_purge_file(THD *thd, const char *file);
2305
void ha_reset_slave(THD *thd);
2306
void ha_binlog_log_query(THD *thd, handlerton *db_type,
2307
enum_binlog_command binlog_command,
2308
const char *query, uint query_length,
2309
const char *db, const char *table_name);
2310
void ha_binlog_wait(THD *thd);
2311
int ha_binlog_end(THD *thd);
2313
#define ha_reset_logs(a) do {} while (0)
2314
#define ha_binlog_index_purge_file(a,b) do {} while (0)
2315
#define ha_reset_slave(a) do {} while (0)
2316
#define ha_binlog_log_query(a,b,c,d,e,f,g) do {} while (0)
2317
#define ha_binlog_wait(a) do {} while (0)
2318
#define ha_binlog_end(a) do {} while (0)