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
20
#ifndef DRIZZLED_HANDLER_H
21
#define DRIZZLED_HANDLER_H
23
#include <drizzled/xid.h>
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 */
25
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>
27
24
#include <storage/myisam/keycache.h>
28
#include <mysys/thr_lock.h>
29
#include <mysys/hash.h>
30
#include <drizzled/sql_string.h>
31
#include <drizzled/sql_list.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
33
47
/* Bits to show what an alter table will do */
34
48
#include <drizzled/sql_bitmap.h>
36
#define HA_MAX_ALTER_FLAGS 40
50
#define HA_MAX_ALTER_FLAGS 39
37
51
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
40
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
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
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)
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,
42
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)
45
466
struct handlerton;
47
468
/* The handler for a table type. Will be included in the Table structure */
51
471
typedef struct st_table_share TABLE_SHARE;
52
472
struct st_foreign_key_info;
53
473
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
54
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
55
const char *file, uint32_t file_len,
56
const char *status, uint32_t status_len);
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);
57
477
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
58
478
extern st_plugin_int *hton2plugin[MAX_HA];
127
547
NOTE 'all' is also false in auto-commit mode where 'end of statement'
128
548
and 'real commit' mean the same event.
130
int (*commit)(handlerton *hton, Session *session, bool all);
131
int (*rollback)(handlerton *hton, Session *session, bool all);
132
int (*prepare)(handlerton *hton, Session *session, bool all);
133
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
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);
134
554
int (*commit_by_xid)(handlerton *hton, XID *xid);
135
555
int (*rollback_by_xid)(handlerton *hton, XID *xid);
136
void *(*create_cursor_read_view)(handlerton *hton, Session *session);
137
void (*set_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
138
void (*close_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
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);
139
559
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
140
560
void (*drop_database)(handlerton *hton, char* path);
141
int (*start_consistent_snapshot)(handlerton *hton, Session *session);
561
int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
142
562
bool (*flush_logs)(handlerton *hton);
143
bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat);
144
int (*fill_files_table)(handlerton *hton, Session *session,
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,
145
565
TableList *tables,
146
566
class Item *cond);
147
567
uint32_t flags; /* global handler flags */
148
int (*release_temporary_latches)(handlerton *hton, Session *session);
568
int (*release_temporary_latches)(handlerton *hton, THD *thd);
150
int (*discover)(handlerton *hton, Session* session, const char *db,
570
int (*discover)(handlerton *hton, THD* thd, const char *db,
151
571
const char *name,
152
unsigned char **frmblob,
154
int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db,
574
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
155
575
const char *name);
156
576
uint32_t license; /* Flag for Engine License */
157
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
162
593
class Ha_trx_info;
166
597
/* true is not all entries in the ht[] support 2pc */
1793
2268
int ha_end_key_cache(KEY_CACHE *key_cache);
1795
2270
/* report to InnoDB that control passes to the client */
1796
int ha_release_temporary_latches(Session *session);
2271
int ha_release_temporary_latches(THD *thd);
1798
2273
/* transactions: interface to handlerton functions */
1799
int ha_start_consistent_snapshot(Session *session);
2274
int ha_start_consistent_snapshot(THD *thd);
1800
2275
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
1801
int ha_commit_one_phase(Session *session, bool all);
1802
int ha_rollback_trans(Session *session, bool all);
1803
int ha_prepare(Session *session);
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);
1804
2279
int ha_recover(HASH *commit_list);
1806
2281
/* transactions: these functions never call handlerton functions directly */
1807
int ha_commit_trans(Session *session, bool all);
1808
int ha_autocommit_or_rollback(Session *session, int error);
1809
int ha_enable_transaction(Session *session, bool on);
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);
1811
2286
/* savepoints */
1812
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv);
1813
int ha_savepoint(Session *session, SAVEPOINT *sv);
1814
int ha_release_savepoint(Session *session, SAVEPOINT *sv);
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);
1816
2291
/* these are called by storage engines */
1817
void trans_register_ha(Session *session, bool all, handlerton *ht);
1819
void table_case_convert(char * name, uint32_t length);
1820
const char *table_case_name(HA_CREATE_INFO *info, const char *name);
1822
extern char reg_ext[FN_EXTLEN];
1823
extern uint32_t reg_ext_length;
1824
extern ulong specialflag;
1825
extern uint32_t lower_case_table_names;
1826
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
1827
uint32_t tablename_to_filename(const char *from, char *to, uint32_t to_length);
2292
void trans_register_ha(THD *thd, bool all, handlerton *ht);
1831
2295
Storage engine has to assume the transaction will end up with 2pc if
1832
2296
- there is more than one 2pc-capable storage engine available
1833
2297
- in the current transaction 2pc was not disabled yet
1835
#define trans_need_2pc(session, all) ((total_ha_2pc > 1) && \
1836
!((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
2299
#define trans_need_2pc(thd, all) ((total_ha_2pc > 1) && \
2300
!((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
1838
#endif /* DRIZZLED_HANDLER_H */
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)