442
442
typedef struct st_table_share TABLE_SHARE;
443
443
struct st_foreign_key_info;
444
444
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
445
typedef bool (stat_print_fn)(THD *thd, const char *type, uint32_t type_len,
445
typedef bool (stat_print_fn)(Session *thd, const char *type, uint32_t type_len,
446
446
const char *file, uint32_t file_len,
447
447
const char *status, uint32_t status_len);
448
448
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
499
499
this storage area - set it to something, so that MySQL would know
500
500
this storage engine was accessed in this connection
502
int (*close_connection)(handlerton *hton, THD *thd);
502
int (*close_connection)(handlerton *hton, Session *thd);
504
504
sv points to an uninitialized storage area of requested size
505
505
(see savepoint_offset description)
507
int (*savepoint_set)(handlerton *hton, THD *thd, void *sv);
507
int (*savepoint_set)(handlerton *hton, Session *thd, void *sv);
509
509
sv points to a storage area, that was earlier passed
510
510
to the savepoint_set call
512
int (*savepoint_rollback)(handlerton *hton, THD *thd, void *sv);
513
int (*savepoint_release)(handlerton *hton, THD *thd, void *sv);
512
int (*savepoint_rollback)(handlerton *hton, Session *thd, void *sv);
513
int (*savepoint_release)(handlerton *hton, Session *thd, void *sv);
515
515
'all' is true if it's a real commit, that makes persistent changes
516
516
'all' is false if it's not in fact a commit but an end of the
518
518
NOTE 'all' is also false in auto-commit mode where 'end of statement'
519
519
and 'real commit' mean the same event.
521
int (*commit)(handlerton *hton, THD *thd, bool all);
522
int (*rollback)(handlerton *hton, THD *thd, bool all);
523
int (*prepare)(handlerton *hton, THD *thd, bool all);
521
int (*commit)(handlerton *hton, Session *thd, bool all);
522
int (*rollback)(handlerton *hton, Session *thd, bool all);
523
int (*prepare)(handlerton *hton, Session *thd, bool all);
524
524
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
525
525
int (*commit_by_xid)(handlerton *hton, XID *xid);
526
526
int (*rollback_by_xid)(handlerton *hton, XID *xid);
527
void *(*create_cursor_read_view)(handlerton *hton, THD *thd);
528
void (*set_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
529
void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
527
void *(*create_cursor_read_view)(handlerton *hton, Session *thd);
528
void (*set_cursor_read_view)(handlerton *hton, Session *thd, void *read_view);
529
void (*close_cursor_read_view)(handlerton *hton, Session *thd, void *read_view);
530
530
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
531
531
void (*drop_database)(handlerton *hton, char* path);
532
int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
532
int (*start_consistent_snapshot)(handlerton *hton, Session *thd);
533
533
bool (*flush_logs)(handlerton *hton);
534
bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
535
int (*fill_files_table)(handlerton *hton, THD *thd,
534
bool (*show_status)(handlerton *hton, Session *thd, stat_print_fn *print, enum ha_stat_type stat);
535
int (*fill_files_table)(handlerton *hton, Session *thd,
536
536
TableList *tables,
537
537
class Item *cond);
538
538
uint32_t flags; /* global handler flags */
539
int (*release_temporary_latches)(handlerton *hton, THD *thd);
539
int (*release_temporary_latches)(handlerton *hton, Session *thd);
541
int (*discover)(handlerton *hton, THD* thd, const char *db,
541
int (*discover)(handlerton *hton, Session* thd, const char *db,
542
542
const char *name,
543
543
unsigned char **frmblob,
545
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
545
int (*table_exists_in_engine)(handlerton *hton, Session* thd, const char *db,
546
546
const char *name);
547
547
uint32_t license; /* Flag for Engine License */
548
548
void *data; /* Location for engines to keep personal structures */
573
573
The purpose of this flag is to keep track of non-transactional
574
574
tables that were modified in scope of:
575
575
- transaction, when the variable is a member of
576
Session::transaction.all
577
577
- top-level statement or sub-statement, when the variable is a
578
member of THD::transaction.stmt
578
member of Session::transaction.stmt
579
579
This member has the following life cycle:
580
580
* stmt.modified_non_trans_table is used to keep track of
581
581
modified non-transactional tables of top-level statements. At
1240
1240
int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
1241
1241
/** to be actually called to get 'check()' functionality*/
1242
int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
1243
int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
1242
int ha_check(Session *thd, HA_CHECK_OPT *check_opt);
1243
int ha_repair(Session* thd, HA_CHECK_OPT* check_opt);
1244
1244
void ha_start_bulk_insert(ha_rows rows)
1246
1246
estimation_rows_to_insert= rows;
1255
1255
uint32_t *dup_key_found);
1256
1256
int ha_delete_all_rows();
1257
1257
int ha_reset_auto_increment(uint64_t value);
1258
int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1259
int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1260
bool ha_check_and_repair(THD *thd);
1258
int ha_optimize(Session* thd, HA_CHECK_OPT* check_opt);
1259
int ha_analyze(Session* thd, HA_CHECK_OPT* check_opt);
1260
bool ha_check_and_repair(Session *thd);
1261
1261
int ha_disable_indexes(uint32_t mode);
1262
1262
int ha_enable_indexes(uint32_t mode);
1263
1263
int ha_discard_or_import_tablespace(bool discard);
2069
2069
virtual int reset_auto_increment(uint64_t value __attribute__((unused)))
2070
2070
{ return HA_ERR_WRONG_COMMAND; }
2071
virtual int optimize(THD* thd __attribute__((unused)),
2071
virtual int optimize(Session* thd __attribute__((unused)),
2072
2072
HA_CHECK_OPT* check_opt __attribute__((unused)))
2073
2073
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2074
virtual int analyze(THD* thd __attribute__((unused)),
2074
virtual int analyze(Session* thd __attribute__((unused)),
2075
2075
HA_CHECK_OPT* check_opt __attribute__((unused)))
2076
2076
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2077
virtual bool check_and_repair(THD *thd __attribute__((unused)))
2077
virtual bool check_and_repair(Session *thd __attribute__((unused)))
2078
2078
{ return true; }
2079
2079
virtual int disable_indexes(uint32_t mode __attribute__((unused)))
2080
2080
{ return HA_ERR_WRONG_COMMAND; }
2175
2175
#define ha_rollback(thd) (ha_rollback_trans((thd), true))
2178
handlerton *ha_default_handlerton(THD *thd);
2179
plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name);
2180
plugin_ref ha_lock_engine(THD *thd, handlerton *hton);
2181
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
2178
handlerton *ha_default_handlerton(Session *thd);
2179
plugin_ref ha_resolve_by_name(Session *thd, const LEX_STRING *name);
2180
plugin_ref ha_lock_engine(Session *thd, handlerton *hton);
2181
handlerton *ha_resolve_by_legacy_type(Session *thd, enum legacy_db_type db_type);
2182
2182
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
2183
2183
handlerton *db_type);
2184
handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
2184
handlerton *ha_checktype(Session *thd, enum legacy_db_type database_type,
2185
2185
bool no_substitute, bool report_error);
2214
2214
int ha_finalize_handlerton(st_plugin_int *plugin);
2216
2216
TYPELIB *ha_known_exts(void);
2217
void ha_close_connection(THD* thd);
2217
void ha_close_connection(Session* thd);
2218
2218
bool ha_flush_logs(handlerton *db_type);
2219
2219
void ha_drop_database(char* path);
2220
int ha_create_table(THD *thd, const char *path,
2220
int ha_create_table(Session *thd, const char *path,
2221
2221
const char *db, const char *table_name,
2222
2222
HA_CREATE_INFO *create_info,
2223
2223
bool update_create_info);
2224
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
2224
int ha_delete_table(Session *thd, handlerton *db_type, const char *path,
2225
2225
const char *db, const char *alias, bool generate_warning);
2227
2227
/* statistics and info */
2228
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
2228
bool ha_show_status(Session *thd, handlerton *db_type, enum ha_stat_type stat);
2230
2230
/* discovery */
2231
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
2232
int ha_discover(THD* thd, const char* dbname, const char* name,
2231
int ha_create_table_from_engine(Session* thd, const char *db, const char *name);
2232
int ha_discover(Session* thd, const char* dbname, const char* name,
2233
2233
unsigned char** frmblob, size_t* frmlen);
2234
int ha_find_files(THD *thd,const char *db,const char *path,
2234
int ha_find_files(Session *thd,const char *db,const char *path,
2235
2235
const char *wild, bool dir, List<LEX_STRING>* files);
2236
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
2236
int ha_table_exists_in_engine(Session* thd, const char* db, const char* name);
2238
2238
/* key cache */
2239
2239
extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache);
2243
2243
int ha_end_key_cache(KEY_CACHE *key_cache);
2245
2245
/* report to InnoDB that control passes to the client */
2246
int ha_release_temporary_latches(THD *thd);
2246
int ha_release_temporary_latches(Session *thd);
2248
2248
/* transactions: interface to handlerton functions */
2249
int ha_start_consistent_snapshot(THD *thd);
2249
int ha_start_consistent_snapshot(Session *thd);
2250
2250
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
2251
int ha_commit_one_phase(THD *thd, bool all);
2252
int ha_rollback_trans(THD *thd, bool all);
2253
int ha_prepare(THD *thd);
2251
int ha_commit_one_phase(Session *thd, bool all);
2252
int ha_rollback_trans(Session *thd, bool all);
2253
int ha_prepare(Session *thd);
2254
2254
int ha_recover(HASH *commit_list);
2256
2256
/* transactions: these functions never call handlerton functions directly */
2257
int ha_commit_trans(THD *thd, bool all);
2258
int ha_autocommit_or_rollback(THD *thd, int error);
2259
int ha_enable_transaction(THD *thd, bool on);
2257
int ha_commit_trans(Session *thd, bool all);
2258
int ha_autocommit_or_rollback(Session *thd, int error);
2259
int ha_enable_transaction(Session *thd, bool on);
2261
2261
/* savepoints */
2262
int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv);
2263
int ha_savepoint(THD *thd, SAVEPOINT *sv);
2264
int ha_release_savepoint(THD *thd, SAVEPOINT *sv);
2262
int ha_rollback_to_savepoint(Session *thd, SAVEPOINT *sv);
2263
int ha_savepoint(Session *thd, SAVEPOINT *sv);
2264
int ha_release_savepoint(Session *thd, SAVEPOINT *sv);
2266
2266
/* these are called by storage engines */
2267
void trans_register_ha(THD *thd, bool all, handlerton *ht);
2267
void trans_register_ha(Session *thd, bool all, handlerton *ht);
2270
2270
Storage engine has to assume the transaction will end up with 2pc if