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 */
21
17
/* Definitions for parameters to do with handler-routines */
149
152
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
150
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 */
151
156
#define HA_NO_AUTO_INCREMENT (1 << 23)
152
157
#define HA_HAS_CHECKSUM (1 << 24)
153
158
/* Table data are stored in separate files (for lower_case_table_names) */
154
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 */
155
162
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
156
163
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
157
#define HA_NO_COPY_ON_ALTER (INT64_C(1) << 31)
158
#define HA_HAS_RECORDS (INT64_C(1) << 32) /* records() gives exact count*/
159
#define HA_MRR_CANT_SORT (INT64_C(1) << 34)
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)
162
171
Engine is capable of row-format and statement-format logging,
165
#define HA_BINLOG_ROW_CAPABLE (INT64_C(1) << 35)
166
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
174
#define HA_BINLOG_ROW_CAPABLE (1LL << 35)
175
#define HA_BINLOG_STMT_CAPABLE (1LL << 36)
168
#define HA_ONLINE_ALTER (INT64_C(1) << 37)
177
#define HA_ONLINE_ALTER (1LL << 37)
171
180
Set of all binlog flags. Currently only contain the capabilities
282
291
enum legacy_db_type
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,
285
310
DB_TYPE_FIRST_DYNAMIC=42,
286
311
DB_TYPE_DEFAULT=127 // Must be last
336
358
#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14)
337
359
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
338
360
#define HA_CREATE_USED_COMMENT (1L << 16)
361
#define HA_CREATE_USED_PASSWORD (1L << 17)
339
362
#define HA_CREATE_USED_CONNECTION (1L << 18)
340
363
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
364
#define HA_CREATE_USED_TRANSACTIONAL (1L << 20)
341
365
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
342
#define HA_CREATE_USED_BLOCK_SIZE (1L << 22)
344
367
typedef uint64_t my_xid; // this line is the same as in log_event.h
345
#define DRIZZLE_XID_PREFIX "MySQLXid"
346
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
347
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
348
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
368
#define MYSQL_XID_PREFIX "MySQLXid"
369
#define MYSQL_XID_PREFIX_LEN 8 // must be a multiple of 8
370
#define MYSQL_XID_OFFSET (MYSQL_XID_PREFIX_LEN+sizeof(server_id))
371
#define MYSQL_XID_GTRID_LEN (MYSQL_XID_OFFSET+sizeof(my_xid))
350
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
373
#define XIDDATASIZE MYSQL_XIDDATASIZE
351
374
#define MAXGTRIDSIZE 64
352
375
#define MAXBQUALSIZE 64
354
377
#define COMPATIBLE_DATA_YES 0
355
378
#define COMPATIBLE_DATA_NO 1
357
typedef bool (*qc_engine_callback)(THD *thd, char *table_key,
359
uint64_t *engine_data);
362
381
struct xid_t is binary compatible with the XID structure as
363
382
in the X/Open CAE Specification, Distributed Transaction Processing:
364
383
The XA Specification, X/Open Company Ltd., 1991.
365
384
http://www.opengroup.org/bookstore/catalog/c193.htm
367
@see DRIZZLE_XID in mysql/plugin.h
386
@see MYSQL_XID in mysql/plugin.h
392
set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX);
393
memcpy(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id));
411
set(MYSQL_XID_PREFIX_LEN, 0, MYSQL_XID_PREFIX);
412
memcpy(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id));
395
memcpy(data+DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp));
396
gtrid_length=DRIZZLE_XID_GTRID_LEN;
414
memcpy(data+MYSQL_XID_OFFSET, &tmp, sizeof(tmp));
415
gtrid_length=MYSQL_XID_GTRID_LEN;
398
417
void set(long g, long b, const char *d)
407
426
my_xid quick_get_my_xid()
410
memcpy(&tmp, data+DRIZZLE_XID_OFFSET, sizeof(tmp));
429
memcpy(&tmp, data+MYSQL_XID_OFFSET, sizeof(tmp));
413
432
my_xid get_my_xid()
415
return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 &&
416
!memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
417
!memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ?
434
return gtrid_length == MYSQL_XID_GTRID_LEN && bqual_length == 0 &&
435
!memcmp(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
436
!memcmp(data, MYSQL_XID_PREFIX, MYSQL_XID_PREFIX_LEN) ?
418
437
quick_get_my_xid() : 0;
422
441
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
423
442
gtrid_length+bqual_length;
427
return (unsigned char *)>rid_length;
446
return (uchar *)>rid_length;
429
uint32_t key_length()
431
450
return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
440
459
struct handlerton;
442
/* The handler for a table type. Will be included in the Table structure */
461
/* The handler for a table type. Will be included in the TABLE structure */
464
typedef struct st_table TABLE;
445
465
typedef struct st_table_share TABLE_SHARE;
446
466
struct st_foreign_key_info;
447
467
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
448
typedef bool (stat_print_fn)(THD *thd, const char *type, uint32_t type_len,
449
const char *file, uint32_t file_len,
450
const char *status, uint32_t status_len);
468
typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
469
const char *file, uint file_len,
470
const char *status, uint status_len);
451
471
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
452
472
extern st_plugin_int *hton2plugin[MAX_HA];
524
544
int (*commit)(handlerton *hton, THD *thd, bool all);
525
545
int (*rollback)(handlerton *hton, THD *thd, bool all);
526
546
int (*prepare)(handlerton *hton, THD *thd, bool all);
527
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
547
int (*recover)(handlerton *hton, XID *xid_list, uint len);
528
548
int (*commit_by_xid)(handlerton *hton, XID *xid);
529
549
int (*rollback_by_xid)(handlerton *hton, XID *xid);
530
550
void *(*create_cursor_read_view)(handlerton *hton, THD *thd);
532
552
void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
533
553
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
534
554
void (*drop_database)(handlerton *hton, char* path);
555
int (*panic)(handlerton *hton, enum ha_panic_function flag);
535
556
int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
536
557
bool (*flush_logs)(handlerton *hton);
537
558
bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
538
559
int (*fill_files_table)(handlerton *hton, THD *thd,
540
561
class Item *cond);
541
uint32_t flags; /* global handler flags */
562
uint32 flags; /* global handler flags */
542
563
int (*release_temporary_latches)(handlerton *hton, THD *thd);
544
565
int (*discover)(handlerton *hton, THD* thd, const char *db,
545
566
const char *name,
546
unsigned char **frmblob,
548
569
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
549
570
const char *name);
550
uint32_t license; /* Flag for Engine License */
571
uint32 license; /* Flag for Engine License */
551
572
void *data; /* Location for engines to keep personal structures */
792
820
TABLEOP_HOOKS() {}
793
821
virtual ~TABLEOP_HOOKS() {}
795
inline void prelock(Table **tables, uint32_t count)
823
inline void prelock(TABLE **tables, uint count)
797
825
do_prelock(tables, count);
800
inline int postlock(Table **tables, uint32_t count)
828
inline int postlock(TABLE **tables, uint count)
802
830
return do_postlock(tables, count);
805
833
/* Function primitive that is called prior to locking tables */
806
virtual void do_prelock(Table **tables __attribute__((unused)),
807
uint32_t count __attribute__((unused)))
834
virtual void do_prelock(TABLE **tables __attribute__((__unused__)),
835
uint count __attribute__((__unused__)))
809
837
/* Default is to do nothing */
1097
1125
typedef uint64_t Table_flags;
1099
1127
struct st_table_share *table_share; /* The table definition */
1100
Table *table; /* The current open table */
1128
struct st_table *table; /* The current open table */
1101
1129
Table_flags cached_table_flags; /* Set on init() and open() */
1103
1131
ha_rows estimation_rows_to_insert;
1105
1133
handlerton *ht; /* storage engine of this handler */
1106
unsigned char *ref; /* Pointer to current row */
1107
unsigned char *dup_ref; /* Pointer to duplicate row */
1134
uchar *ref; /* Pointer to current row */
1135
uchar *dup_ref; /* Pointer to duplicate row */
1109
1137
ha_statistics stats;
1110
1138
/** MultiRangeRead-related members: */
1111
1139
range_seq_t mrr_iter; /* Interator to traverse the range sequence */
1112
1140
RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */
1113
1141
HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
1114
uint32_t ranges_in_seq; /* Total number of ranges in the traversed sequence */
1142
uint ranges_in_seq; /* Total number of ranges in the traversed sequence */
1115
1143
/* true <=> source MRR ranges and the output are ordered */
1116
1144
bool mrr_is_output_sorted;
1254
1282
estimation_rows_to_insert= 0;
1255
1283
return end_bulk_insert();
1257
int ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data,
1258
uint32_t *dup_key_found);
1285
int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
1286
uint *dup_key_found);
1259
1287
int ha_delete_all_rows();
1260
1288
int ha_reset_auto_increment(uint64_t value);
1261
1289
int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1262
1290
int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1263
1291
bool ha_check_and_repair(THD *thd);
1264
int ha_disable_indexes(uint32_t mode);
1265
int ha_enable_indexes(uint32_t mode);
1266
int ha_discard_or_import_tablespace(bool discard);
1292
int ha_disable_indexes(uint mode);
1293
int ha_enable_indexes(uint mode);
1294
int ha_discard_or_import_tablespace(my_bool discard);
1267
1295
void ha_prepare_for_alter();
1268
1296
int ha_rename_table(const char *from, const char *to);
1269
1297
int ha_delete_table(const char *name);
1270
1298
void ha_drop_table(const char *name);
1272
int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
1300
int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info);
1274
1302
int ha_create_handler_files(const char *name, const char *old_name,
1275
1303
int action_flag, HA_CREATE_INFO *info);
1277
1305
void adjust_next_insert_id_after_explicit_value(uint64_t nr);
1278
1306
int update_auto_increment();
1279
void print_keydup_error(uint32_t key_nr, const char *msg);
1307
void print_keydup_error(uint key_nr, const char *msg);
1280
1308
virtual void print_error(int error, myf errflag);
1281
1309
virtual bool get_error_message(int error, String *buf);
1282
uint32_t get_dup_key(int error);
1283
virtual void change_table_ptr(Table *table_arg, TABLE_SHARE *share)
1310
uint get_dup_key(int error);
1311
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
1285
1313
table= table_arg;
1286
1314
table_share= share;
1288
1316
/* Estimates calculation */
1289
1317
virtual double scan_time(void)
1290
1318
{ return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
1291
virtual double read_time(uint32_t index __attribute__((unused)),
1292
uint32_t ranges, ha_rows rows)
1319
virtual double read_time(uint index __attribute__((__unused__)),
1320
uint ranges, ha_rows rows)
1293
1321
{ return rows2double(ranges+rows); }
1295
virtual double index_only_read_time(uint32_t keynr, double records);
1323
virtual double index_only_read_time(uint keynr, double records);
1297
virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
1325
virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
1298
1326
void *seq_init_param,
1299
uint32_t n_ranges, uint32_t *bufsz,
1300
uint32_t *flags, COST_VECT *cost);
1301
virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
1302
uint32_t *bufsz, uint32_t *flags, COST_VECT *cost);
1327
uint n_ranges, uint *bufsz,
1328
uint *flags, COST_VECT *cost);
1329
virtual int multi_range_read_info(uint keyno, uint n_ranges, uint keys,
1330
uint *bufsz, uint *flags, COST_VECT *cost);
1303
1331
virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
1304
uint32_t n_ranges, uint32_t mode,
1332
uint n_ranges, uint mode,
1305
1333
HANDLER_BUFFER *buf);
1306
1334
virtual int multi_range_read_next(char **range_info);
1414
1442
row if available. If the key value is null, begin at the first key of the
1417
virtual int index_read_map(unsigned char * buf, const unsigned char * key,
1445
virtual int index_read_map(uchar * buf, const uchar * key,
1418
1446
key_part_map keypart_map,
1419
1447
enum ha_rkey_function find_flag)
1421
uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map);
1449
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
1422
1450
return index_read(buf, key, key_len, find_flag);
1427
1455
row if available. If the key value is null, begin at the first key of the
1430
virtual int index_read_idx_map(unsigned char * buf, uint32_t index, const unsigned char * key,
1458
virtual int index_read_idx_map(uchar * buf, uint index, const uchar * key,
1431
1459
key_part_map keypart_map,
1432
1460
enum ha_rkey_function find_flag);
1433
virtual int index_next(unsigned char * buf __attribute__((unused)))
1434
{ return HA_ERR_WRONG_COMMAND; }
1435
virtual int index_prev(unsigned char * buf __attribute__((unused)))
1436
{ return HA_ERR_WRONG_COMMAND; }
1437
virtual int index_first(unsigned char * buf __attribute__((unused)))
1438
{ return HA_ERR_WRONG_COMMAND; }
1439
virtual int index_last(unsigned char * buf __attribute__((unused)))
1440
{ return HA_ERR_WRONG_COMMAND; }
1441
virtual int index_next_same(unsigned char *buf __attribute__((unused)),
1442
const unsigned char *key __attribute__((unused)),
1443
uint32_t keylen __attribute__((unused)));
1461
virtual int index_next(uchar * buf __attribute__((__unused__)))
1462
{ return HA_ERR_WRONG_COMMAND; }
1463
virtual int index_prev(uchar * buf __attribute__((__unused__)))
1464
{ return HA_ERR_WRONG_COMMAND; }
1465
virtual int index_first(uchar * buf __attribute__((__unused__)))
1466
{ return HA_ERR_WRONG_COMMAND; }
1467
virtual int index_last(uchar * buf __attribute__((__unused__)))
1468
{ return HA_ERR_WRONG_COMMAND; }
1469
virtual int index_next_same(uchar *buf __attribute__((__unused__)),
1470
const uchar *key __attribute__((__unused__)),
1471
uint keylen __attribute__((__unused__)));
1446
1474
The following functions works like index_read, but it find the last
1447
1475
row with the current key value or prefix.
1449
virtual int index_read_last_map(unsigned char * buf, const unsigned char * key,
1477
virtual int index_read_last_map(uchar * buf, const uchar * key,
1450
1478
key_part_map keypart_map)
1452
uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map);
1480
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
1453
1481
return index_read_last(buf, key, key_len);
1455
1483
virtual int read_range_first(const key_range *start_key,
1458
1486
virtual int read_range_next();
1459
1487
int compare_key(key_range *range);
1460
1488
int compare_key2(key_range *range);
1461
virtual int rnd_next(unsigned char *buf __attribute__((unused)))=0;
1462
virtual int rnd_pos(unsigned char * buf __attribute__((unused)),
1463
unsigned char *pos __attribute__((unused)))=0;
1489
virtual int rnd_next(uchar *buf __attribute__((__unused__)))=0;
1490
virtual int rnd_pos(uchar * buf __attribute__((__unused__)),
1491
uchar *pos __attribute__((__unused__)))=0;
1465
1493
One has to use this method when to find
1466
1494
random position by record as the plain
1467
1495
position() call doesn't work for some
1468
1496
handlers for random position.
1470
virtual int rnd_pos_by_record(unsigned char *record);
1471
virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
1498
virtual int rnd_pos_by_record(uchar *record);
1499
virtual int read_first_row(uchar *buf, uint primary_key);
1473
1501
The following function is only needed for tables that may be temporary
1474
1502
tables during joins.
1476
virtual int restart_rnd_next(unsigned char *buf __attribute__((unused)),
1477
unsigned char *pos __attribute__((unused)))
1478
{ return HA_ERR_WRONG_COMMAND; }
1479
virtual int rnd_same(unsigned char *buf __attribute__((unused)),
1480
uint32_t inx __attribute__((unused)))
1481
{ return HA_ERR_WRONG_COMMAND; }
1482
virtual ha_rows records_in_range(uint32_t inx __attribute__((unused)),
1483
key_range *min_key __attribute__((unused)),
1484
key_range *max_key __attribute__((unused)))
1504
virtual int restart_rnd_next(uchar *buf __attribute__((__unused__)),
1505
uchar *pos __attribute__((__unused__)))
1506
{ return HA_ERR_WRONG_COMMAND; }
1507
virtual int rnd_same(uchar *buf __attribute__((__unused__)),
1508
uint inx __attribute__((__unused__)))
1509
{ return HA_ERR_WRONG_COMMAND; }
1510
virtual ha_rows records_in_range(uint inx __attribute__((__unused__)),
1511
key_range *min_key __attribute__((__unused__)),
1512
key_range *max_key __attribute__((__unused__)))
1485
1513
{ return (ha_rows) 10; }
1486
virtual void position(const unsigned char *record)=0;
1514
virtual void position(const uchar *record)=0;
1487
1515
virtual int info(uint)=0; // see my_base.h for full description
1488
virtual uint32_t calculate_key_hash_value(Field **field_array __attribute__((unused)))
1516
virtual uint32 calculate_key_hash_value(Field **field_array __attribute__((__unused__)))
1489
1517
{ assert(0); return 0; }
1490
virtual int extra(enum ha_extra_function operation __attribute__((unused)))
1518
virtual int extra(enum ha_extra_function operation __attribute__((__unused__)))
1492
1520
virtual int extra_opt(enum ha_extra_function operation,
1493
uint32_t cache_size __attribute__((unused)))
1521
uint32_t cache_size __attribute__((__unused__)))
1494
1522
{ return extra(operation); }
1541
1569
insert_id_for_cur_row;
1544
virtual void update_create_info(HA_CREATE_INFO *create_info __attribute__((unused))) {}
1572
virtual void update_create_info(HA_CREATE_INFO *create_info __attribute__((__unused__))) {}
1545
1573
int check_old_types(void);
1546
virtual int assign_to_keycache(THD* thd __attribute__((unused)),
1547
HA_CHECK_OPT* check_opt __attribute__((unused)))
1574
virtual int assign_to_keycache(THD* thd __attribute__((__unused__)),
1575
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1548
1576
{ return HA_ADMIN_NOT_IMPLEMENTED; }
1549
1577
/* end of the list of admin commands */
1551
1579
virtual int indexes_are_disabled(void) {return 0;}
1552
1580
virtual char *update_table_comment(const char * comment)
1553
1581
{ return (char*) comment;}
1554
virtual void append_create_info(String *packet __attribute__((unused)))
1582
virtual void append_create_info(String *packet __attribute__((__unused__)))
1557
1585
If index == MAX_KEY then a check for table is made and if index <
1563
1591
@retval true Foreign key defined on table or index
1564
1592
@retval false No foreign key defined
1566
virtual bool is_fk_defined_on_table_or_index(uint32_t index __attribute__((unused)))
1594
virtual bool is_fk_defined_on_table_or_index(uint index __attribute__((__unused__)))
1567
1595
{ return false; }
1568
1596
virtual char* get_foreign_key_create_info(void)
1569
1597
{ return(NULL);} /* gets foreign key create string from InnoDB */
1570
/** used in ALTER Table; 1 if changing storage engine is allowed */
1598
/** used in ALTER TABLE; 1 if changing storage engine is allowed */
1571
1599
virtual bool can_switch_engines(void) { return 1; }
1572
1600
/** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
1573
virtual int get_foreign_key_list(THD *thd __attribute__((unused)),
1574
List<FOREIGN_KEY_INFO> *f_key_list __attribute__((unused)))
1601
virtual int get_foreign_key_list(THD *thd __attribute__((__unused__)),
1602
List<FOREIGN_KEY_INFO> *f_key_list __attribute__((__unused__)))
1576
virtual uint32_t referenced_by_foreign_key() { return 0;}
1604
virtual uint referenced_by_foreign_key() { return 0;}
1577
1605
virtual void init_table_handle_for_HANDLER()
1578
1606
{ return; } /* prepare InnoDB for HANDLER */
1579
virtual void free_foreign_key_create_info(char* str __attribute__((unused))) {}
1607
virtual void free_foreign_key_create_info(char* str __attribute__((__unused__))) {}
1580
1608
/** The following can be called without an open handler */
1581
1609
virtual const char *table_type() const =0;
1588
1616
and data file), the order of elements is relevant. First element of engine
1589
1617
file name extentions array should be meta/index file extention. Second
1590
1618
element - data file extention. This order is assumed by
1591
prepare_for_repair() when REPAIR Table ... USE_FRM is issued.
1619
prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
1593
1621
virtual const char **bas_ext() const =0;
1595
virtual int get_default_no_partitions(HA_CREATE_INFO *info __attribute__((unused))) { return 1;}
1596
virtual bool get_no_parts(const char *name __attribute__((unused)),
1623
virtual int get_default_no_partitions(HA_CREATE_INFO *info __attribute__((__unused__))) { return 1;}
1624
virtual bool get_no_parts(const char *name __attribute__((__unused__)),
1603
virtual uint32_t index_flags(uint32_t idx, uint32_t part, bool all_parts) const =0;
1605
virtual int add_index(Table *table_arg __attribute__((unused)),
1606
KEY *key_info __attribute__((unused)),
1607
uint32_t num_of_keys __attribute__((unused)))
1608
{ return (HA_ERR_WRONG_COMMAND); }
1609
virtual int prepare_drop_index(Table *table_arg __attribute__((unused)),
1610
uint32_t *key_num __attribute__((unused)),
1611
uint32_t num_of_keys __attribute__((unused)))
1612
{ return (HA_ERR_WRONG_COMMAND); }
1613
virtual int final_drop_index(Table *table_arg __attribute__((unused)))
1614
{ return (HA_ERR_WRONG_COMMAND); }
1616
uint32_t max_record_length() const
1617
{ return cmin((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
1618
uint32_t max_keys() const
1619
{ return cmin((unsigned int)MAX_KEY, max_supported_keys()); }
1620
uint32_t max_key_parts() const
1621
{ return cmin((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
1622
uint32_t max_key_length() const
1623
{ return cmin((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
1624
uint32_t max_key_part_length(void) const
1625
{ return cmin((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
1627
virtual uint32_t max_supported_record_length(void) const
1631
virtual uint32_t index_flags(uint idx, uint part, bool all_parts) const =0;
1633
virtual int add_index(TABLE *table_arg __attribute__((__unused__)),
1634
KEY *key_info __attribute__((__unused__)),
1635
uint num_of_keys __attribute__((__unused__)))
1636
{ return (HA_ERR_WRONG_COMMAND); }
1637
virtual int prepare_drop_index(TABLE *table_arg __attribute__((__unused__)),
1638
uint *key_num __attribute__((__unused__)),
1639
uint num_of_keys __attribute__((__unused__)))
1640
{ return (HA_ERR_WRONG_COMMAND); }
1641
virtual int final_drop_index(TABLE *table_arg __attribute__((__unused__)))
1642
{ return (HA_ERR_WRONG_COMMAND); }
1644
uint max_record_length() const
1645
{ return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
1646
uint max_keys() const
1647
{ return min(MAX_KEY, max_supported_keys()); }
1648
uint max_key_parts() const
1649
{ return min(MAX_REF_PARTS, max_supported_key_parts()); }
1650
uint max_key_length() const
1651
{ return min(MAX_KEY_LENGTH, max_supported_key_length()); }
1652
uint max_key_part_length(void) const
1653
{ return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
1655
virtual uint max_supported_record_length(void) const
1628
1656
{ return HA_MAX_REC_LENGTH; }
1629
virtual uint32_t max_supported_keys(void) const { return 0; }
1630
virtual uint32_t max_supported_key_parts(void) const { return MAX_REF_PARTS; }
1631
virtual uint32_t max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
1632
virtual uint32_t max_supported_key_part_length(void) const { return 255; }
1633
virtual uint32_t min_record_length(uint32_t options __attribute__((unused))) const
1657
virtual uint max_supported_keys(void) const { return 0; }
1658
virtual uint max_supported_key_parts(void) const { return MAX_REF_PARTS; }
1659
virtual uint max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
1660
virtual uint max_supported_key_part_length(void) const { return 255; }
1661
virtual uint min_record_length(uint options __attribute__((__unused__))) const
1636
1664
virtual bool low_byte_first(void) const { return 1; }
1637
virtual uint32_t checksum(void) const { return 0; }
1665
virtual uint checksum(void) const { return 0; }
1638
1666
virtual bool is_crashed(void) const { return 0; }
1639
1667
virtual bool auto_repair(void) const { return 0; }
1758
1786
virtual void cond_pop(void) { return; }
1761
*idx_cond_push(uint32_t keyno __attribute__((unused)),
1762
Item* idx_cond __attribute__((unused)))
1789
*idx_cond_push(uint keyno __attribute__((__unused__)),
1790
Item* idx_cond __attribute__((__unused__)))
1763
1791
{ return idx_cond; }
1766
1794
Part of old fast alter table, to be depricated
1769
check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((unused)),
1770
uint32_t table_changes __attribute__((unused)))
1797
check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((__unused__)),
1798
uint table_changes __attribute__((__unused__)))
1771
1799
{ return COMPATIBLE_DATA_NO; }
1773
/* On-line ALTER Table interface */
1801
/* On-line ALTER TABLE interface */
1776
1804
Check if a storage engine supports a particular alter table on-line
1821
1849
@retval error error code passed from storage engine
1823
virtual int alter_table_phase1(THD *thd __attribute__((unused)),
1824
Table *altered_table __attribute__((unused)),
1825
HA_CREATE_INFO *create_info __attribute__((unused)),
1826
HA_ALTER_INFO *alter_info __attribute__((unused)),
1827
HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
1851
virtual int alter_table_phase1(THD *thd __attribute__((__unused__)),
1852
TABLE *altered_table __attribute__((__unused__)),
1853
HA_CREATE_INFO *create_info __attribute__((__unused__)),
1854
HA_ALTER_INFO *alter_info __attribute__((__unused__)),
1855
HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)))
1829
1857
return HA_ERR_UNSUPPORTED;
1846
1874
this call is to be wrapped with a DDL lock. This is currently NOT
1849
virtual int alter_table_phase2(THD *thd __attribute__((unused)),
1850
Table *altered_table __attribute__((unused)),
1851
HA_CREATE_INFO *create_info __attribute__((unused)),
1852
HA_ALTER_INFO *alter_info __attribute__((unused)),
1853
HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
1877
virtual int alter_table_phase2(THD *thd __attribute__((__unused__)),
1878
TABLE *altered_table __attribute__((__unused__)),
1879
HA_CREATE_INFO *create_info __attribute__((__unused__)),
1880
HA_ALTER_INFO *alter_info __attribute__((__unused__)),
1881
HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)))
1855
1883
return HA_ERR_UNSUPPORTED;
1950
1978
virtual int rnd_init(bool scan)= 0;
1951
1979
virtual int rnd_end() { return 0; }
1952
virtual int write_row(unsigned char *buf __attribute__((unused)))
1954
return HA_ERR_WRONG_COMMAND;
1957
virtual int update_row(const unsigned char *old_data __attribute__((unused)),
1958
unsigned char *new_data __attribute__((unused)))
1960
return HA_ERR_WRONG_COMMAND;
1963
virtual int delete_row(const unsigned char *buf __attribute__((unused)))
1980
virtual int write_row(uchar *buf __attribute__((unused)))
1982
return HA_ERR_WRONG_COMMAND;
1985
virtual int update_row(const uchar *old_data __attribute__((unused)),
1986
uchar *new_data __attribute__((unused)))
1988
return HA_ERR_WRONG_COMMAND;
1991
virtual int delete_row(const uchar *buf __attribute__((unused)))
1965
1993
return HA_ERR_WRONG_COMMAND;
2012
2040
to specify CHECK option to use to call check()
2013
2041
upon the table.
2015
virtual int repair(THD* thd __attribute__((unused)),
2016
HA_CHECK_OPT* check_opt __attribute__((unused)))
2043
virtual int repair(THD* thd __attribute__((__unused__)),
2044
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2017
2045
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2018
virtual void start_bulk_insert(ha_rows rows __attribute__((unused)))
2046
virtual void start_bulk_insert(ha_rows rows __attribute__((__unused__)))
2020
2048
virtual int end_bulk_insert(void) { return 0; }
2021
virtual int index_read(unsigned char * buf __attribute__((unused)),
2022
const unsigned char * key __attribute__((unused)),
2023
uint32_t key_len __attribute__((unused)),
2024
enum ha_rkey_function find_flag __attribute__((unused)))
2049
virtual int index_read(uchar * buf __attribute__((__unused__)),
2050
const uchar * key __attribute__((__unused__)),
2051
uint key_len __attribute__((__unused__)),
2052
enum ha_rkey_function find_flag __attribute__((__unused__)))
2025
2053
{ return HA_ERR_WRONG_COMMAND; }
2026
virtual int index_read_last(unsigned char * buf __attribute__((unused)),
2027
const unsigned char * key __attribute__((unused)),
2028
uint32_t key_len __attribute__((unused)))
2054
virtual int index_read_last(uchar * buf __attribute__((__unused__)),
2055
const uchar * key __attribute__((__unused__)),
2056
uint key_len __attribute__((__unused__)))
2029
2057
{ return (my_errno= HA_ERR_WRONG_COMMAND); }
2031
2059
This method is similar to update_row, however the handler doesn't need
2061
2089
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
2062
2090
returned by storage engines that don't support this operation.
2064
virtual int reset_auto_increment(uint64_t value __attribute__((unused)))
2092
virtual int reset_auto_increment(uint64_t value __attribute__((__unused__)))
2065
2093
{ return HA_ERR_WRONG_COMMAND; }
2066
virtual int optimize(THD* thd __attribute__((unused)),
2067
HA_CHECK_OPT* check_opt __attribute__((unused)))
2068
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2069
virtual int analyze(THD* thd __attribute__((unused)),
2070
HA_CHECK_OPT* check_opt __attribute__((unused)))
2071
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2072
virtual bool check_and_repair(THD *thd __attribute__((unused)))
2094
virtual int optimize(THD* thd __attribute__((__unused__)),
2095
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2096
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2097
virtual int analyze(THD* thd __attribute__((__unused__)),
2098
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2099
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2100
virtual bool check_and_repair(THD *thd __attribute__((__unused__)))
2073
2101
{ return true; }
2074
virtual int disable_indexes(uint32_t mode __attribute__((unused)))
2075
{ return HA_ERR_WRONG_COMMAND; }
2076
virtual int enable_indexes(uint32_t mode __attribute__((unused)))
2077
{ return HA_ERR_WRONG_COMMAND; }
2078
virtual int discard_or_import_tablespace(bool discard __attribute__((unused)))
2102
virtual int disable_indexes(uint mode __attribute__((__unused__)))
2103
{ return HA_ERR_WRONG_COMMAND; }
2104
virtual int enable_indexes(uint mode __attribute__((__unused__)))
2105
{ return HA_ERR_WRONG_COMMAND; }
2106
virtual int discard_or_import_tablespace(my_bool discard __attribute__((__unused__)))
2079
2107
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
2080
2108
virtual void prepare_for_alter(void) { return; }
2081
2109
virtual void drop_table(const char *name);
2082
virtual int create(const char *name __attribute__((unused)),
2083
Table *form __attribute__((unused)),
2084
HA_CREATE_INFO *info __attribute__((unused)))=0;
2110
virtual int create(const char *name __attribute__((__unused__)),
2111
TABLE *form __attribute__((__unused__)),
2112
HA_CREATE_INFO *info __attribute__((__unused__)))=0;
2086
virtual int create_handler_files(const char *name __attribute__((unused)),
2087
const char *old_name __attribute__((unused)),
2088
int action_flag __attribute__((unused)),
2089
HA_CREATE_INFO *info __attribute__((unused)))
2114
virtual int create_handler_files(const char *name __attribute__((__unused__)),
2115
const char *old_name __attribute__((__unused__)),
2116
int action_flag __attribute__((__unused__)),
2117
HA_CREATE_INFO *info __attribute__((__unused__)))
2090
2118
{ return false; }
2133
2161
bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
2135
void init(handler *h_arg, Table *table_arg)
2163
void init(handler *h_arg, TABLE *table_arg)
2138
2166
table= table_arg;
2140
2168
int dsmrr_init(handler *h, KEY *key, RANGE_SEQ_IF *seq_funcs,
2141
void *seq_init_param, uint32_t n_ranges, uint32_t mode,
2169
void *seq_init_param, uint n_ranges, uint mode,
2142
2170
HANDLER_BUFFER *buf);
2143
2171
void dsmrr_close();
2144
2172
int dsmrr_fill_buffer(handler *h);
2145
2173
int dsmrr_next(handler *h, char **range_info);
2147
int dsmrr_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys, uint32_t *bufsz,
2148
uint32_t *flags, COST_VECT *cost);
2175
int dsmrr_info(uint keyno, uint n_ranges, uint keys, uint *bufsz,
2176
uint *flags, COST_VECT *cost);
2150
ha_rows dsmrr_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
2151
void *seq_init_param, uint32_t n_ranges, uint32_t *bufsz,
2152
uint32_t *flags, COST_VECT *cost);
2178
ha_rows dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq,
2179
void *seq_init_param, uint n_ranges, uint *bufsz,
2180
uint *flags, COST_VECT *cost);
2154
bool key_uses_partial_cols(uint32_t keyno);
2155
bool choose_mrr_impl(uint32_t keyno, ha_rows rows, uint32_t *flags, uint32_t *bufsz,
2182
bool key_uses_partial_cols(uint keyno);
2183
bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz,
2156
2184
COST_VECT *cost);
2157
bool get_disk_sweep_mrr_cost(uint32_t keynr, ha_rows rows, uint32_t flags,
2158
uint32_t *buffer_size, COST_VECT *cost);
2185
bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
2186
uint *buffer_size, COST_VECT *cost);
2161
2189
extern const char *ha_row_type[];
2269
2298
#define trans_need_2pc(thd, all) ((total_ha_2pc > 1) && \
2270
2299
!((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
2301
#ifdef HAVE_NDB_BINLOG
2302
int ha_reset_logs(THD *thd);
2303
int ha_binlog_index_purge_file(THD *thd, const char *file);
2304
void ha_reset_slave(THD *thd);
2305
void ha_binlog_log_query(THD *thd, handlerton *db_type,
2306
enum_binlog_command binlog_command,
2307
const char *query, uint query_length,
2308
const char *db, const char *table_name);
2309
void ha_binlog_wait(THD *thd);
2310
int ha_binlog_end(THD *thd);
2312
#define ha_reset_logs(a) do {} while (0)
2313
#define ha_binlog_index_purge_file(a,b) do {} while (0)
2314
#define ha_reset_slave(a) do {} while (0)
2315
#define ha_binlog_log_query(a,b,c,d,e,f,g) do {} while (0)
2316
#define ha_binlog_wait(a) do {} while (0)
2317
#define ha_binlog_end(a) do {} while (0)