1
0
mirror of https://github.com/MariaDB/server.git synced 2025-04-28 06:45:23 +03:00

This patch adds handlerton passing to functions. NDB and Innodb still require a global hanlderton in the main code due to the nature of the sql_cache call back function (should be solveable... another patch).

Partitioning now has a flag to allow disabling of engines from being compatible with partitioning. Cleaned up heap naming convention on panic call.
This commit is contained in:
brian@zim.(none) 2006-09-30 12:49:46 -07:00
parent a756fd36ef
commit 46ae2113ba
27 changed files with 350 additions and 248 deletions

View File

@ -225,6 +225,7 @@ extern int heap_indexes_are_disabled(HP_INFO *info);
extern void heap_update_auto_increment(HP_INFO *info, const byte *record); extern void heap_update_auto_increment(HP_INFO *info, const byte *record);
ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key, ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
key_range *max_key); key_range *max_key);
int hp_panic(enum ha_panic_function flag);
int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key,
uint key_len, enum ha_rkey_function find_flag); uint key_len, enum ha_rkey_function find_flag);
extern gptr heap_find(HP_INFO *info,int inx,const byte *key); extern gptr heap_find(HP_INFO *info,int inx,const byte *key);

View File

@ -75,10 +75,17 @@ static const int max_transactions= 3; // should really be 2 but there is a trans
static uint ndbcluster_partition_flags(); static uint ndbcluster_partition_flags();
static uint ndbcluster_alter_table_flags(uint flags); static uint ndbcluster_alter_table_flags(uint flags);
static int ndbcluster_init(void *); static int ndbcluster_init(void *);
static int ndbcluster_end(ha_panic_function flag); static int ndbcluster_end(handlerton *hton, ha_panic_function flag);
static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type); static bool ndbcluster_show_status(handlerton *hton, THD*,
static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info); stat_print_fn *,
static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond); enum ha_stat_type);
static int ndbcluster_alter_tablespace(handlerton *hton,
THD* thd,
st_alter_tablespace *info);
static int ndbcluster_fill_files_table(handlerton *hton,
THD *thd,
TABLE_LIST *tables,
COND *cond);
handlerton *ndbcluster_hton; handlerton *ndbcluster_hton;
@ -4202,7 +4209,7 @@ int ha_ndbcluster::start_stmt(THD *thd, thr_lock_type lock_type)
Commit a transaction started in NDB Commit a transaction started in NDB
*/ */
static int ndbcluster_commit(THD *thd, bool all) static int ndbcluster_commit(handlerton *hton, THD *thd, bool all)
{ {
int res= 0; int res= 0;
Thd_ndb *thd_ndb= get_thd_ndb(thd); Thd_ndb *thd_ndb= get_thd_ndb(thd);
@ -4253,7 +4260,7 @@ static int ndbcluster_commit(THD *thd, bool all)
Rollback a transaction started in NDB Rollback a transaction started in NDB
*/ */
static int ndbcluster_rollback(THD *thd, bool all) static int ndbcluster_rollback(handlerton *hton, THD *thd, bool all)
{ {
int res= 0; int res= 0;
Thd_ndb *thd_ndb= get_thd_ndb(thd); Thd_ndb *thd_ndb= get_thd_ndb(thd);
@ -5817,7 +5824,7 @@ int ha_ndbcluster::check_ndb_connection(THD* thd)
} }
static int ndbcluster_close_connection(THD *thd) static int ndbcluster_close_connection(handlerton *hton, THD *thd)
{ {
Thd_ndb *thd_ndb= get_thd_ndb(thd); Thd_ndb *thd_ndb= get_thd_ndb(thd);
DBUG_ENTER("ndbcluster_close_connection"); DBUG_ENTER("ndbcluster_close_connection");
@ -5834,8 +5841,10 @@ static int ndbcluster_close_connection(THD *thd)
Try to discover one table from NDB Try to discover one table from NDB
*/ */
int ndbcluster_discover(THD* thd, const char *db, const char *name, int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
const void** frmblob, uint* frmlen) const char *name,
const void** frmblob,
uint* frmlen)
{ {
int error= 0; int error= 0;
NdbError ndb_error; NdbError ndb_error;
@ -5915,7 +5924,8 @@ err:
*/ */
int ndbcluster_table_exists_in_engine(THD* thd, const char *db, int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
const char *db,
const char *name) const char *name)
{ {
Ndb* ndb; Ndb* ndb;
@ -6015,7 +6025,7 @@ int ndbcluster_drop_database_impl(const char *path)
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
static void ndbcluster_drop_database(char *path) static void ndbcluster_drop_database(handlerton *hton, char *path)
{ {
THD *thd= current_thd; THD *thd= current_thd;
DBUG_ENTER("ndbcluster_drop_database"); DBUG_ENTER("ndbcluster_drop_database");
@ -6176,7 +6186,9 @@ int ndbcluster_find_all_files(THD *thd)
DBUG_RETURN(-(skipped + unhandled)); DBUG_RETURN(-(skipped + unhandled));
} }
int ndbcluster_find_files(THD *thd,const char *db,const char *path, int ndbcluster_find_files(handlerton *hton, THD *thd,
const char *db,
const char *path,
const char *wild, bool dir, List<char> *files) const char *wild, bool dir, List<char> *files)
{ {
DBUG_ENTER("ndbcluster_find_files"); DBUG_ENTER("ndbcluster_find_files");
@ -6286,7 +6298,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
DBUG_PRINT("info", ("%s existed on disk", name)); DBUG_PRINT("info", ("%s existed on disk", name));
// The .ndb file exists on disk, but it's not in list of tables in ndb // The .ndb file exists on disk, but it's not in list of tables in ndb
// Verify that handler agrees table is gone. // Verify that handler agrees table is gone.
if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0) if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == 0)
{ {
DBUG_PRINT("info", ("NDB says %s does not exists", file_name)); DBUG_PRINT("info", ("NDB says %s does not exists", file_name));
it.remove(); it.remove();
@ -6540,7 +6552,7 @@ ndbcluster_init_error:
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
static int ndbcluster_end(ha_panic_function type) static int ndbcluster_end(handlerton *hton, ha_panic_function type)
{ {
DBUG_ENTER("ndbcluster_end"); DBUG_ENTER("ndbcluster_end");
@ -9704,7 +9716,7 @@ err:
Implements the SHOW NDB STATUS command. Implements the SHOW NDB STATUS command.
*/ */
bool bool
ndbcluster_show_status(THD* thd, stat_print_fn *stat_print, ndbcluster_show_status(handlerton *hton, THD* thd, stat_print_fn *stat_print,
enum ha_stat_type stat_type) enum ha_stat_type stat_type)
{ {
char buf[IO_SIZE]; char buf[IO_SIZE];
@ -10168,7 +10180,7 @@ bool set_up_undofile(st_alter_tablespace *info,
return false; return false;
} }
int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info) int ndbcluster_alter_tablespace(handlerton *hton, THD* thd, st_alter_tablespace *info)
{ {
DBUG_ENTER("ha_ndbcluster::alter_tablespace"); DBUG_ENTER("ha_ndbcluster::alter_tablespace");
@ -10429,7 +10441,9 @@ bool ha_ndbcluster::get_no_parts(const char *name, uint *no_parts)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, static int ndbcluster_fill_files_table(handlerton *hton,
THD *thd,
TABLE_LIST *tables,
COND *cond) COND *cond)
{ {
TABLE* table= tables->table; TABLE* table= tables->table;

View File

@ -506,7 +506,7 @@ ndbcluster_binlog_index_purge_file(THD *thd, const char *file)
} }
static void static void
ndbcluster_binlog_log_query(THD *thd, enum_binlog_command binlog_command, ndbcluster_binlog_log_query(handlerton *hton, THD *thd, enum_binlog_command binlog_command,
const char *query, uint query_length, const char *query, uint query_length,
const char *db, const char *table_name) const char *db, const char *table_name)
{ {
@ -637,7 +637,9 @@ static void ndbcluster_reset_slave(THD *thd)
/* /*
Initialize the binlog part of the ndb handlerton Initialize the binlog part of the ndb handlerton
*/ */
static int ndbcluster_binlog_func(THD *thd, enum_binlog_func fn, void *arg) static int ndbcluster_binlog_func(handlerton *hton, THD *thd,
enum_binlog_func fn,
void *arg)
{ {
switch(fn) switch(fn)
{ {

View File

@ -376,7 +376,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
case SHOW_OPTION_YES: case SHOW_OPTION_YES:
if (installed_htons[hton->db_type] == hton) if (installed_htons[hton->db_type] == hton)
installed_htons[hton->db_type]= NULL; installed_htons[hton->db_type]= NULL;
if (hton->panic && hton->panic(HA_PANIC_CLOSE)) if (hton->panic && hton->panic(hton, HA_PANIC_CLOSE))
DBUG_RETURN(1); DBUG_RETURN(1);
break; break;
}; };
@ -465,6 +465,28 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
hton->state= SHOW_OPTION_DISABLED; hton->state= SHOW_OPTION_DISABLED;
break; break;
} }
/*
This is entirely for legacy. We will create a new "disk based" hton and a "memory" hton
which will be configurable longterm.
*/
switch (hton->db_type) {
case DB_TYPE_MRG_ISAM:
myisammrg_hton= hton;
break;
case DB_TYPE_HEAP:
heap_hton= hton;
break;
case DB_TYPE_MYISAM:
myisam_hton= hton;
break;
case DB_TYPE_PARTITION_DB:
partition_hton= hton;
break;
default:
break;
};
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
DBUG_RETURN(1); DBUG_RETURN(1);
@ -498,7 +520,7 @@ static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin, void *arg)
{ {
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->panic) if (hton->state == SHOW_OPTION_YES && hton->panic)
((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]); ((int*)arg)[0]|= hton->panic(hton, (enum ha_panic_function)((int*)arg)[1]);
return FALSE; return FALSE;
} }
@ -520,7 +542,7 @@ static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin,
{ {
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->drop_database) if (hton->state == SHOW_OPTION_YES && hton->drop_database)
hton->drop_database((char *)path); hton->drop_database(hton, (char *)path);
return FALSE; return FALSE;
} }
@ -541,7 +563,7 @@ static my_bool closecon_handlerton(THD *thd, st_plugin_int *plugin,
*/ */
if (hton->state == SHOW_OPTION_YES && hton->close_connection && if (hton->state == SHOW_OPTION_YES && hton->close_connection &&
thd->ha_data[hton->slot]) thd->ha_data[hton->slot])
hton->close_connection(thd); hton->close_connection(hton, thd);
return FALSE; return FALSE;
} }
@ -617,7 +639,7 @@ int ha_prepare(THD *thd)
statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status); statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status);
if ((*ht)->prepare) if ((*ht)->prepare)
{ {
if ((err= (*(*ht)->prepare)(thd, all))) if ((err= (*(*ht)->prepare)(*ht, thd, all)))
{ {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
ha_rollback_trans(thd, all); ha_rollback_trans(thd, all);
@ -691,7 +713,7 @@ int ha_commit_trans(THD *thd, bool all)
for (; *ht && !error; ht++) for (; *ht && !error; ht++)
{ {
int err; int err;
if ((err= (*(*ht)->prepare)(thd, all))) if ((err= (*(*ht)->prepare)(*ht, thd, all)))
{ {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error= 1; error= 1;
@ -738,7 +760,7 @@ int ha_commit_one_phase(THD *thd, bool all)
for (ht=trans->ht; *ht; ht++) for (ht=trans->ht; *ht; ht++)
{ {
int err; int err;
if ((err= (*(*ht)->commit)(thd, all))) if ((err= (*(*ht)->commit)(*ht, thd, all)))
{ {
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error=1; error=1;
@ -794,7 +816,7 @@ int ha_rollback_trans(THD *thd, bool all)
for (handlerton **ht=trans->ht; *ht; ht++) for (handlerton **ht=trans->ht; *ht; ht++)
{ {
int err; int err;
if ((err= (*(*ht)->rollback)(thd, all))) if ((err= (*(*ht)->rollback)(*ht, thd, all)))
{ // cannot happen { // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1; error=1;
@ -871,7 +893,7 @@ static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin,
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->recover) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
hton->commit_by_xid(((struct xahton_st *)arg)->xid); hton->commit_by_xid(hton, ((struct xahton_st *)arg)->xid);
((struct xahton_st *)arg)->result= 0; ((struct xahton_st *)arg)->result= 0;
} }
return FALSE; return FALSE;
@ -883,7 +905,7 @@ static my_bool xarollback_handlerton(THD *unused1, st_plugin_int *plugin,
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->recover) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
hton->rollback_by_xid(((struct xahton_st *)arg)->xid); hton->rollback_by_xid(hton, ((struct xahton_st *)arg)->xid);
((struct xahton_st *)arg)->result= 0; ((struct xahton_st *)arg)->result= 0;
} }
return FALSE; return FALSE;
@ -993,7 +1015,7 @@ static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
if (hton->state == SHOW_OPTION_YES && hton->recover) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
while ((got= hton->recover(info->list, info->len)) > 0 ) while ((got= hton->recover(hton, info->list, info->len)) > 0 )
{ {
sql_print_information("Found %d prepared transaction(s) in %s", sql_print_information("Found %d prepared transaction(s) in %s",
got, hton2plugin[hton->slot]->name.str); got, hton2plugin[hton->slot]->name.str);
@ -1024,7 +1046,7 @@ static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
char buf[XIDDATASIZE*4+6]; // see xid_to_str char buf[XIDDATASIZE*4+6]; // see xid_to_str
sql_print_information("commit xid %s", xid_to_str(buf, info->list+i)); sql_print_information("commit xid %s", xid_to_str(buf, info->list+i));
#endif #endif
hton->commit_by_xid(info->list+i); hton->commit_by_xid(hton, info->list+i);
} }
else else
{ {
@ -1033,7 +1055,7 @@ static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
sql_print_information("rollback xid %s", sql_print_information("rollback xid %s",
xid_to_str(buf, info->list+i)); xid_to_str(buf, info->list+i));
#endif #endif
hton->rollback_by_xid(info->list+i); hton->rollback_by_xid(hton, info->list+i);
} }
} }
if (got < info->len) if (got < info->len)
@ -1179,7 +1201,7 @@ static my_bool release_temporary_latches(THD *thd, st_plugin_int *plugin,
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches) if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches)
hton->release_temporary_latches(thd); hton->release_temporary_latches(hton, thd);
return FALSE; return FALSE;
} }
@ -1212,7 +1234,7 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv)
{ {
int err; int err;
DBUG_ASSERT((*ht)->savepoint_set != 0); DBUG_ASSERT((*ht)->savepoint_set != 0);
if ((err= (*(*ht)->savepoint_rollback)(thd, (byte *)(sv+1)+(*ht)->savepoint_offset))) if ((err= (*(*ht)->savepoint_rollback)(*ht, thd, (byte *)(sv+1)+(*ht)->savepoint_offset)))
{ // cannot happen { // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1; error=1;
@ -1228,7 +1250,7 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv)
for (; *ht ; ht++) for (; *ht ; ht++)
{ {
int err; int err;
if ((err= (*(*ht)->rollback)(thd, !thd->in_sub_stmt))) if ((err= (*(*ht)->rollback)(*ht, thd, !thd->in_sub_stmt)))
{ // cannot happen { // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1; error=1;
@ -1262,7 +1284,7 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv)
error=1; error=1;
break; break;
} }
if ((err= (*(*ht)->savepoint_set)(thd, (byte *)(sv+1)+(*ht)->savepoint_offset))) if ((err= (*(*ht)->savepoint_set)(*ht, thd, (byte *)(sv+1)+(*ht)->savepoint_offset)))
{ // cannot happen { // cannot happen
my_error(ER_GET_ERRNO, MYF(0), err); my_error(ER_GET_ERRNO, MYF(0), err);
error=1; error=1;
@ -1288,7 +1310,9 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
int err; int err;
if (!(*ht)->savepoint_release) if (!(*ht)->savepoint_release)
continue; continue;
if ((err= (*(*ht)->savepoint_release)(thd, (byte *)(sv+1)+(*ht)->savepoint_offset))) if ((err= (*(*ht)->savepoint_release)(*ht, thd,
(byte *)(sv+1)+
(*ht)->savepoint_offset)))
{ // cannot happen { // cannot happen
my_error(ER_GET_ERRNO, MYF(0), err); my_error(ER_GET_ERRNO, MYF(0), err);
error=1; error=1;
@ -1305,7 +1329,7 @@ static my_bool snapshot_handlerton(THD *thd, st_plugin_int *plugin,
if (hton->state == SHOW_OPTION_YES && if (hton->state == SHOW_OPTION_YES &&
hton->start_consistent_snapshot) hton->start_consistent_snapshot)
{ {
hton->start_consistent_snapshot(thd); hton->start_consistent_snapshot(hton, thd);
*((bool *)arg)= false; *((bool *)arg)= false;
} }
return FALSE; return FALSE;
@ -1333,7 +1357,8 @@ static my_bool flush_handlerton(THD *thd, st_plugin_int *plugin,
void *arg) void *arg)
{ {
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->flush_logs && hton->flush_logs()) if (hton->state == SHOW_OPTION_YES && hton->flush_logs &&
hton->flush_logs(hton))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
@ -1350,7 +1375,7 @@ bool ha_flush_logs(handlerton *db_type)
else else
{ {
if (db_type->state != SHOW_OPTION_YES || if (db_type->state != SHOW_OPTION_YES ||
(db_type->flush_logs && db_type->flush_logs())) (db_type->flush_logs && db_type->flush_logs(db_type)))
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -2765,7 +2790,9 @@ static my_bool discover_handlerton(THD *thd, st_plugin_int *plugin,
st_discover_args *vargs= (st_discover_args *)arg; st_discover_args *vargs= (st_discover_args *)arg;
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->discover && if (hton->state == SHOW_OPTION_YES && hton->discover &&
(!(hton->discover(thd, vargs->db, vargs->name, vargs->frmblob, vargs->frmlen)))) (!(hton->discover(hton, thd, vargs->db, vargs->name,
vargs->frmblob,
vargs->frmlen))))
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -2814,7 +2841,7 @@ static my_bool find_files_handlerton(THD *thd, st_plugin_int *plugin,
if (hton->state == SHOW_OPTION_YES && hton->find_files) if (hton->state == SHOW_OPTION_YES && hton->find_files)
if (hton->find_files(thd, vargs->db, vargs->path, vargs->wild, if (hton->find_files(hton, thd, vargs->db, vargs->path, vargs->wild,
vargs->dir, vargs->files)) vargs->dir, vargs->files))
return TRUE; return TRUE;
@ -2861,7 +2888,7 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->table_exists_in_engine) if (hton->state == SHOW_OPTION_YES && hton->table_exists_in_engine)
if ((hton->table_exists_in_engine(thd, vargs->db, vargs->name)) == 1) if ((hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name)) == 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -2930,7 +2957,7 @@ static my_bool binlog_func_foreach(THD *thd, binlog_func_st *bfn)
uint i= 0, sz= hton_list.sz; uint i= 0, sz= hton_list.sz;
while(i < sz) while(i < sz)
hton_list.hton[i++]->binlog_func(thd, bfn->fn, bfn->arg); hton_list.hton[i++]->binlog_func(hton, thd, bfn->fn, bfn->arg);
return FALSE; return FALSE;
} }
@ -2977,12 +3004,12 @@ struct binlog_log_query_st
}; };
static my_bool binlog_log_query_handlerton2(THD *thd, static my_bool binlog_log_query_handlerton2(THD *thd,
const handlerton *hton, handlerton *hton,
void *args) void *args)
{ {
struct binlog_log_query_st *b= (struct binlog_log_query_st*)args; struct binlog_log_query_st *b= (struct binlog_log_query_st*)args;
if (hton->state == SHOW_OPTION_YES && hton->binlog_log_query) if (hton->state == SHOW_OPTION_YES && hton->binlog_log_query)
hton->binlog_log_query(thd, hton->binlog_log_query(hton, thd,
b->binlog_command, b->binlog_command,
b->query, b->query,
b->query_length, b->query_length,
@ -2995,10 +3022,10 @@ static my_bool binlog_log_query_handlerton(THD *thd,
st_plugin_int *plugin, st_plugin_int *plugin,
void *args) void *args)
{ {
return binlog_log_query_handlerton2(thd, (const handlerton *)plugin->data, args); return binlog_log_query_handlerton2(thd, (handlerton *)plugin->data, args);
} }
void ha_binlog_log_query(THD *thd, const handlerton *hton, void ha_binlog_log_query(THD *thd, handlerton *hton,
enum_binlog_command binlog_command, enum_binlog_command binlog_command,
const char *query, uint query_length, const char *query, uint query_length,
const char *db, const char *table_name) const char *db, const char *table_name)
@ -3371,7 +3398,7 @@ static my_bool showstat_handlerton(THD *thd, st_plugin_int *plugin,
enum ha_stat_type stat= *(enum ha_stat_type *) arg; enum ha_stat_type stat= *(enum ha_stat_type *) arg;
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->show_status && if (hton->state == SHOW_OPTION_YES && hton->show_status &&
hton->show_status(thd, stat_print, stat)) hton->show_status(hton, thd, stat_print, stat))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
@ -3405,7 +3432,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
} }
else else
result= db_type->show_status && result= db_type->show_status &&
db_type->show_status(thd, stat_print, stat) ? 1 : 0; db_type->show_status(db_type, thd, stat_print, stat) ? 1 : 0;
} }
if (!result) if (!result)
@ -3726,7 +3753,7 @@ int example_of_iterator_using_for_logs_cleanup(handlerton *hton)
if (!hton->create_iterator) if (!hton->create_iterator)
return 1; /* iterator creator is not supported */ return 1; /* iterator creator is not supported */
if ((*hton->create_iterator)(HA_TRANSACTLOG_ITERATOR, &iterator) != if ((*hton->create_iterator)(hton, HA_TRANSACTLOG_ITERATOR, &iterator) !=
HA_ITERATOR_OK) HA_ITERATOR_OK)
{ {
/* error during creation of log iterator or iterator is not supported */ /* error during creation of log iterator or iterator is not supported */

View File

@ -449,7 +449,7 @@ class st_alter_tablespace : public Sql_alloc
ulonglong autoextend_size; ulonglong autoextend_size;
ulonglong max_size; ulonglong max_size;
uint nodegroup_id; uint nodegroup_id;
const handlerton *storage_engine; handlerton *storage_engine;
bool wait_until_completed; bool wait_until_completed;
const char *ts_comment; const char *ts_comment;
enum tablespace_access_mode ts_access_mode; enum tablespace_access_mode ts_access_mode;
@ -605,18 +605,18 @@ struct handlerton
this storage area - set it to something, so that MySQL would know this storage area - set it to something, so that MySQL would know
this storage engine was accessed in this connection this storage engine was accessed in this connection
*/ */
int (*close_connection)(THD *thd); int (*close_connection)(handlerton *hton, THD *thd);
/* /*
sv points to an uninitialized storage area of requested size sv points to an uninitialized storage area of requested size
(see savepoint_offset description) (see savepoint_offset description)
*/ */
int (*savepoint_set)(THD *thd, void *sv); int (*savepoint_set)(handlerton *hton, THD *thd, void *sv);
/* /*
sv points to a storage area, that was earlier passed sv points to a storage area, that was earlier passed
to the savepoint_set call to the savepoint_set call
*/ */
int (*savepoint_rollback)(THD *thd, void *sv); int (*savepoint_rollback)(handlerton *hton, THD *thd, void *sv);
int (*savepoint_release)(THD *thd, void *sv); int (*savepoint_release)(handlerton *hton, THD *thd, void *sv);
/* /*
'all' is true if it's a real commit, that makes persistent changes 'all' is true if it's a real commit, that makes persistent changes
'all' is false if it's not in fact a commit but an end of the 'all' is false if it's not in fact a commit but an end of the
@ -624,25 +624,25 @@ struct handlerton
NOTE 'all' is also false in auto-commit mode where 'end of statement' NOTE 'all' is also false in auto-commit mode where 'end of statement'
and 'real commit' mean the same event. and 'real commit' mean the same event.
*/ */
int (*commit)(THD *thd, bool all); int (*commit)(handlerton *hton, THD *thd, bool all);
int (*rollback)(THD *thd, bool all); int (*rollback)(handlerton *hton, THD *thd, bool all);
int (*prepare)(THD *thd, bool all); int (*prepare)(handlerton *hton, THD *thd, bool all);
int (*recover)(XID *xid_list, uint len); int (*recover)(handlerton *hton, XID *xid_list, uint len);
int (*commit_by_xid)(XID *xid); int (*commit_by_xid)(handlerton *hton, XID *xid);
int (*rollback_by_xid)(XID *xid); int (*rollback_by_xid)(handlerton *hton, XID *xid);
void *(*create_cursor_read_view)(); void *(*create_cursor_read_view)(handlerton *hton);
void (*set_cursor_read_view)(void *); void (*set_cursor_read_view)(handlerton *hton, void *);
void (*close_cursor_read_view)(void *); void (*close_cursor_read_view)(handlerton *hton, void *);
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
void (*drop_database)(char* path); void (*drop_database)(handlerton *hton, char* path);
int (*panic)(enum ha_panic_function flag); int (*panic)(handlerton *hton, enum ha_panic_function flag);
int (*start_consistent_snapshot)(THD *thd); int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
bool (*flush_logs)(); bool (*flush_logs)(handlerton *hton);
bool (*show_status)(THD *thd, stat_print_fn *print, enum ha_stat_type stat); bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
uint (*partition_flags)(); uint (*partition_flags)();
uint (*alter_table_flags)(uint flags); uint (*alter_table_flags)(uint flags);
int (*alter_tablespace)(THD *thd, st_alter_tablespace *ts_info); int (*alter_tablespace)(handlerton *hton, THD *thd, st_alter_tablespace *ts_info);
int (*fill_files_table)(THD *thd, int (*fill_files_table)(handlerton *hton, THD *thd,
struct st_table_list *tables, struct st_table_list *tables,
class Item *cond); class Item *cond);
uint32 flags; /* global handler flags */ uint32 flags; /* global handler flags */
@ -650,11 +650,12 @@ struct handlerton
Those handlerton functions below are properly initialized at handler Those handlerton functions below are properly initialized at handler
init. init.
*/ */
int (*binlog_func)(THD *thd, enum_binlog_func fn, void *arg); int (*binlog_func)(handlerton *hton, THD *thd, enum_binlog_func fn, void *arg);
void (*binlog_log_query)(THD *thd, enum_binlog_command binlog_command, void (*binlog_log_query)(handlerton *hton, THD *thd,
enum_binlog_command binlog_command,
const char *query, uint query_length, const char *query, uint query_length,
const char *db, const char *table_name); const char *db, const char *table_name);
int (*release_temporary_latches)(THD *thd); int (*release_temporary_latches)(handlerton *hton, THD *thd);
/* /*
Get log status. Get log status.
@ -663,20 +664,24 @@ struct handlerton
(see example of implementation in handler.cc, TRANS_LOG_MGM_EXAMPLE_CODE) (see example of implementation in handler.cc, TRANS_LOG_MGM_EXAMPLE_CODE)
*/ */
enum log_status (*get_log_status)(char *log); enum log_status (*get_log_status)(handlerton *hton, char *log);
/* /*
Iterators creator. Iterators creator.
Presence of the pointer should be checked before using Presence of the pointer should be checked before using
*/ */
enum handler_create_iterator_result enum handler_create_iterator_result
(*create_iterator)(enum handler_iterator_type type, (*create_iterator)(handlerton *hton, enum handler_iterator_type type,
struct handler_iterator *fill_this_in); struct handler_iterator *fill_this_in);
int (*discover)(THD* thd, const char *db, const char *name, int (*discover)(handlerton *hton, THD* thd, const char *db,
const void** frmblob, uint* frmlen); const char *name,
int (*find_files)(THD *thd,const char *db,const char *path, const void** frmblob,
uint* frmlen);
int (*find_files)(handlerton *hton, THD *thd,
const char *db,
const char *path,
const char *wild, bool dir, List<char> *files); const char *wild, bool dir, List<char> *files);
int (*table_exists_in_engine)(THD* thd, const char *db, int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
const char *name); const char *name);
}; };
@ -690,6 +695,7 @@ struct handlerton
#define HTON_FLUSH_AFTER_RENAME (1 << 4) #define HTON_FLUSH_AFTER_RENAME (1 << 4)
#define HTON_NOT_USER_SELECTABLE (1 << 5) #define HTON_NOT_USER_SELECTABLE (1 << 5)
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported #define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
#define HTON_NO_PARTITION (1 << 7) //You can not partition these tables
typedef struct st_thd_trans typedef struct st_thd_trans
{ {
@ -892,7 +898,7 @@ class handler :public Sql_alloc
virtual void start_bulk_insert(ha_rows rows) {} virtual void start_bulk_insert(ha_rows rows) {}
virtual int end_bulk_insert() {return 0; } virtual int end_bulk_insert() {return 0; }
public: public:
const handlerton *ht; /* storage engine of this handler */ handlerton *ht; /* storage engine of this handler */
byte *ref; /* Pointer to current row */ byte *ref; /* Pointer to current row */
byte *dup_ref; /* Pointer to duplicate row */ byte *dup_ref; /* Pointer to duplicate row */
@ -942,7 +948,7 @@ public:
*/ */
Discrete_interval auto_inc_interval_for_cur_row; Discrete_interval auto_inc_interval_for_cur_row;
handler(const handlerton *ht_arg, TABLE_SHARE *share_arg) handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
:table_share(share_arg), estimation_rows_to_insert(0), ht(ht_arg), :table_share(share_arg), estimation_rows_to_insert(0), ht(ht_arg),
ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
ref_length(sizeof(my_off_t)), ref_length(sizeof(my_off_t)),
@ -1715,7 +1721,7 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht);
int ha_reset_logs(THD *thd); int ha_reset_logs(THD *thd);
int ha_binlog_index_purge_file(THD *thd, const char *file); int ha_binlog_index_purge_file(THD *thd, const char *file);
void ha_reset_slave(THD *thd); void ha_reset_slave(THD *thd);
void ha_binlog_log_query(THD *thd, const handlerton *db_type, void ha_binlog_log_query(THD *thd, handlerton *db_type,
enum_binlog_command binlog_command, enum_binlog_command binlog_command,
const char *query, uint query_length, const char *query, uint query_length,
const char *db, const char *table_name); const char *db, const char *table_name);

View File

@ -46,13 +46,13 @@ static Muted_query_log_event invisible_commit;
static bool test_if_number(const char *str, static bool test_if_number(const char *str,
long *res, bool allow_wildcards); long *res, bool allow_wildcards);
static int binlog_init(); static int binlog_init(void *p);
static int binlog_close_connection(THD *thd); static int binlog_close_connection(handlerton *hton, THD *thd);
static int binlog_savepoint_set(THD *thd, void *sv); static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv);
static int binlog_savepoint_rollback(THD *thd, void *sv); static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv);
static int binlog_commit(THD *thd, bool all); static int binlog_commit(handlerton *hton, THD *thd, bool all);
static int binlog_rollback(THD *thd, bool all); static int binlog_rollback(handlerton *hton, THD *thd, bool all);
static int binlog_prepare(THD *thd, bool all); static int binlog_prepare(handlerton *hton, THD *thd, bool all);
sql_print_message_func sql_print_message_handlers[3] = sql_print_message_func sql_print_message_handlers[3] =
{ {
@ -1171,7 +1171,7 @@ int binlog_init(void *p)
return 0; return 0;
} }
static int binlog_close_connection(THD *thd) static int binlog_close_connection(handlerton *hton, THD *thd)
{ {
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd->ha_data[binlog_hton->slot];
@ -1184,7 +1184,8 @@ static int binlog_close_connection(THD *thd)
} }
static int static int
binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev) binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
Log_event *end_ev)
{ {
DBUG_ENTER("binlog_end_trans"); DBUG_ENTER("binlog_end_trans");
int error=0; int error=0;
@ -1238,7 +1239,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev)
DBUG_RETURN(error); DBUG_RETURN(error);
} }
static int binlog_prepare(THD *thd, bool all) static int binlog_prepare(handlerton *hton, THD *thd, bool all)
{ {
/* /*
do nothing. do nothing.
@ -1249,7 +1250,7 @@ static int binlog_prepare(THD *thd, bool all)
return 0; return 0;
} }
static int binlog_commit(THD *thd, bool all) static int binlog_commit(handlerton *hton, THD *thd, bool all)
{ {
DBUG_ENTER("binlog_commit"); DBUG_ENTER("binlog_commit");
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
@ -1273,7 +1274,7 @@ static int binlog_commit(THD *thd, bool all)
DBUG_RETURN(binlog_end_trans(thd, trx_data, &invisible_commit)); DBUG_RETURN(binlog_end_trans(thd, trx_data, &invisible_commit));
} }
static int binlog_rollback(THD *thd, bool all) static int binlog_rollback(handlerton *hton, THD *thd, bool all)
{ {
DBUG_ENTER("binlog_rollback"); DBUG_ENTER("binlog_rollback");
int error=0; int error=0;
@ -1326,7 +1327,7 @@ static int binlog_rollback(THD *thd, bool all)
that case there is no need to have it in the binlog). that case there is no need to have it in the binlog).
*/ */
static int binlog_savepoint_set(THD *thd, void *sv) static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
{ {
DBUG_ENTER("binlog_savepoint_set"); DBUG_ENTER("binlog_savepoint_set");
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
@ -1342,7 +1343,7 @@ static int binlog_savepoint_set(THD *thd, void *sv)
DBUG_RETURN(error); DBUG_RETURN(error);
} }
static int binlog_savepoint_rollback(THD *thd, void *sv) static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
{ {
DBUG_ENTER("binlog_savepoint_rollback"); DBUG_ENTER("binlog_savepoint_rollback");
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=

View File

@ -1638,19 +1638,11 @@ extern SHOW_COMP_OPTION have_ndbcluster;
extern SHOW_COMP_OPTION have_partition_db; extern SHOW_COMP_OPTION have_partition_db;
extern SHOW_COMP_OPTION have_merge_db; extern SHOW_COMP_OPTION have_merge_db;
#ifdef WITH_CSV_STORAGE_ENGINE
extern handlerton *tina_hton;
#endif
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
extern handlerton *ndbcluster_hton; extern handlerton *ndbcluster_hton;
#endif #endif
#ifdef WITH_PARTITION_STORAGE_ENGINE
extern handlerton *partition_hton; extern handlerton *partition_hton;
#endif
#ifdef WITH_MYISAMMRG_STORAGE_ENGINE
extern handlerton *myisammrg_hton; extern handlerton *myisammrg_hton;
#endif
extern handlerton *myisam_hton; extern handlerton *myisam_hton;
extern handlerton *heap_hton; extern handlerton *heap_hton;

View File

@ -354,6 +354,15 @@ my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0; my_bool opt_log_slave_updates= 0;
my_bool opt_innodb; my_bool opt_innodb;
/*
Legacy global handlerton. These will be removed (please do not add more).
*/
handlerton *ndbclusert_hton;
handlerton *myisammrg_hton;
handlerton *heap_hton;
handlerton *myisam_hton;
#ifdef WITH_INNOBASE_STORAGE_ENGINE #ifdef WITH_INNOBASE_STORAGE_ENGINE
extern ulong innobase_fast_shutdown; extern ulong innobase_fast_shutdown;
extern ulong innobase_large_page_size; extern ulong innobase_large_page_size;

View File

@ -443,8 +443,7 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
} while (++i < no_parts); } while (++i < no_parts);
if (engine_array[0] == myisammrg_hton || if (engine_array[0]->flags & HTON_NO_PARTITION)
engine_array[0] == tina_hton)
{ {
my_error(ER_PARTITION_MERGE_ERROR, MYF(0), my_error(ER_PARTITION_MERGE_ERROR, MYF(0),
engine_array[0] == myisammrg_hton ? "MyISAM Merge" : "CSV"); engine_array[0] == myisammrg_hton ? "MyISAM Merge" : "CSV");

View File

@ -45,7 +45,7 @@ class Sensitive_cursor: public Server_side_cursor
query_id_t query_id; query_id_t query_id;
struct Engine_info struct Engine_info
{ {
const handlerton *ht; handlerton *ht;
void *read_view; void *read_view;
}; };
Engine_info ht_info[MAX_HA]; Engine_info ht_info[MAX_HA];
@ -318,12 +318,12 @@ Sensitive_cursor::post_open(THD *thd)
info= &ht_info[0]; info= &ht_info[0];
for (handlerton **pht= thd->transaction.stmt.ht; *pht; pht++) for (handlerton **pht= thd->transaction.stmt.ht; *pht; pht++)
{ {
const handlerton *ht= *pht; handlerton *ht= *pht;
close_at_commit|= test(ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT); close_at_commit|= test(ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT);
if (ht->create_cursor_read_view) if (ht->create_cursor_read_view)
{ {
info->ht= ht; info->ht= ht;
info->read_view= (ht->create_cursor_read_view)(); info->read_view= (ht->create_cursor_read_view)(ht);
++info; ++info;
} }
} }
@ -433,7 +433,7 @@ Sensitive_cursor::fetch(ulong num_rows)
thd->set_n_backup_active_arena(this, &backup_arena); thd->set_n_backup_active_arena(this, &backup_arena);
for (info= ht_info; info->read_view ; info++) for (info= ht_info; info->read_view ; info++)
(info->ht->set_cursor_read_view)(info->read_view); (info->ht->set_cursor_read_view)(info->ht, info->read_view);
join->fetch_limit+= num_rows; join->fetch_limit+= num_rows;
@ -454,7 +454,7 @@ Sensitive_cursor::fetch(ulong num_rows)
reset_thd(thd); reset_thd(thd);
for (info= ht_info; info->read_view; info++) for (info= ht_info; info->read_view; info++)
(info->ht->set_cursor_read_view)(0); (info->ht->set_cursor_read_view)(info->ht, 0);
if (error == NESTED_LOOP_CURSOR_LIMIT) if (error == NESTED_LOOP_CURSOR_LIMIT)
{ {
@ -487,7 +487,7 @@ Sensitive_cursor::close()
for (Engine_info *info= ht_info; info->read_view; info++) for (Engine_info *info= ht_info; info->read_view; info++)
{ {
(info->ht->close_cursor_read_view)(info->read_view); (info->ht->close_cursor_read_view)(info->ht, info->read_view);
info->read_view= 0; info->read_view= 0;
info->ht= 0; info->ht= 0;
} }

View File

@ -5001,7 +5001,7 @@ static my_bool run_hton_fill_schema_files(THD *thd, st_plugin_int *plugin,
(run_hton_fill_schema_files_args *) arg; (run_hton_fill_schema_files_args *) arg;
handlerton *hton= (handlerton *)plugin->data; handlerton *hton= (handlerton *)plugin->data;
if(hton->fill_files_table && hton->state == SHOW_OPTION_YES) if(hton->fill_files_table && hton->state == SHOW_OPTION_YES)
hton->fill_files_table(thd, args->tables, args->cond); hton->fill_files_table(hton, thd, args->tables, args->cond);
return false; return false;
} }

View File

@ -21,7 +21,7 @@
int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info) int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
{ {
int error= HA_ADMIN_NOT_IMPLEMENTED; int error= HA_ADMIN_NOT_IMPLEMENTED;
const handlerton *hton= ts_info->storage_engine; handlerton *hton= ts_info->storage_engine;
DBUG_ENTER("mysql_alter_tablespace"); DBUG_ENTER("mysql_alter_tablespace");
/* /*
@ -42,7 +42,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
if (hton->alter_tablespace) if (hton->alter_tablespace)
{ {
if ((error= hton->alter_tablespace(thd, ts_info))) if ((error= hton->alter_tablespace(hton, thd, ts_info)))
{ {
if (error == HA_ADMIN_NOT_IMPLEMENTED) if (error == HA_ADMIN_NOT_IMPLEMENTED)
{ {

View File

@ -142,13 +142,13 @@ static HASH archive_open_tables;
static handler *archive_create_handler(handlerton *hton, static handler *archive_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
int archive_db_end(handlerton *hton, ha_panic_function type);
/* /*
Number of rows that will force a bulk insert. Number of rows that will force a bulk insert.
*/ */
#define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2 #define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2
handlerton *archive_hton;
static handler *archive_create_handler(handlerton *hton, static handler *archive_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
@ -182,6 +182,7 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
int archive_db_init(void *p) int archive_db_init(void *p)
{ {
DBUG_ENTER("archive_db_init"); DBUG_ENTER("archive_db_init");
handlerton *archive_hton;
if (archive_inited) if (archive_inited)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
archive_hton= (handlerton *)p; archive_hton= (handlerton *)p;
@ -230,7 +231,7 @@ int archive_db_done(void *p)
} }
int archive_db_end(ha_panic_function type) int archive_db_end(handlerton *hton, ha_panic_function type)
{ {
return archive_db_done(NULL); return archive_db_done(NULL);
} }

View File

@ -139,5 +139,3 @@ public:
bool check_and_repair(THD *thd); bool check_and_repair(THD *thd);
}; };
int archive_db_end(ha_panic_function type);

View File

@ -24,7 +24,6 @@
/* Static declarations for handlerton */ /* Static declarations for handlerton */
handlerton *blackhole_hton;
static handler *blackhole_create_handler(handlerton *hton, static handler *blackhole_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
@ -205,6 +204,7 @@ int ha_blackhole::index_last(byte * buf)
static int blackhole_init(void *p) static int blackhole_init(void *p)
{ {
handlerton *blackhole_hton;
blackhole_hton= (handlerton *)p; blackhole_hton= (handlerton *)p;
blackhole_hton->state= SHOW_OPTION_YES; blackhole_hton->state= SHOW_OPTION_YES;
blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB; blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB;

View File

@ -77,6 +77,8 @@ static int tina_init= 0;
static handler *tina_create_handler(handlerton *hton, static handler *tina_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
int tina_end(handlerton *hton, ha_panic_function type);
off_t Transparent_file::read_next() off_t Transparent_file::read_next()
{ {
@ -125,7 +127,6 @@ char Transparent_file::get_value(off_t offset)
return buff[0]; return buff[0];
} }
} }
handlerton *tina_hton;
/***************************************************************************** /*****************************************************************************
** TINA tables ** TINA tables
@ -152,6 +153,8 @@ static byte* tina_get_key(TINA_SHARE *share,uint *length,
static int tina_init_func(void *p) static int tina_init_func(void *p)
{ {
handlerton *tina_hton;
if (!tina_init) if (!tina_init)
{ {
tina_hton= (handlerton *)p; tina_hton= (handlerton *)p;
@ -163,7 +166,7 @@ static int tina_init_func(void *p)
tina_hton->db_type= DB_TYPE_CSV_DB; tina_hton->db_type= DB_TYPE_CSV_DB;
tina_hton->create= tina_create_handler; tina_hton->create= tina_create_handler;
tina_hton->panic= tina_end; tina_hton->panic= tina_end;
tina_hton->flags= HTON_CAN_RECREATE; tina_hton->flags= HTON_CAN_RECREATE|HTON_NO_PARTITION;
} }
return 0; return 0;
} }
@ -451,7 +454,7 @@ static int free_share(TINA_SHARE *share)
DBUG_RETURN(result_code); DBUG_RETURN(result_code);
} }
int tina_end(ha_panic_function type) int tina_end(handlerton *hton, ha_panic_function type)
{ {
return tina_done_func(NULL); return tina_done_func(NULL);
} }

View File

@ -212,5 +212,3 @@ public:
int chain_append(); int chain_append();
}; };
int tina_end(ha_panic_function type);

View File

@ -362,13 +362,14 @@ static const uint sizeof_trailing_where= sizeof(" WHERE ") - 1;
static handler *federated_create_handler(handlerton *hton, static handler *federated_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
static int federated_commit(THD *thd, bool all); static int federated_commit(handlerton *hton, THD *thd, bool all);
static int federated_rollback(THD *thd, bool all); static int federated_rollback(handlerton *hton, THD *thd, bool all);
static int federated_db_init(void);
static int federated_db_end(handlerton *hton, ha_panic_function type);
/* Federated storage engine handlerton */ /* Federated storage engine handlerton */
handlerton *federated_hton;
static handler *federated_create_handler(handlerton *hton, static handler *federated_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
@ -401,7 +402,7 @@ static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
int federated_db_init(void *p) int federated_db_init(void *p)
{ {
DBUG_ENTER("federated_db_init"); DBUG_ENTER("federated_db_init");
federated_hton= (handlerton *)p; handlerton *federated_hton= (handlerton *)p;
federated_hton->state= SHOW_OPTION_YES; federated_hton->state= SHOW_OPTION_YES;
federated_hton->db_type= DB_TYPE_FEDERATED_DB; federated_hton->db_type= DB_TYPE_FEDERATED_DB;
federated_hton->commit= federated_commit; federated_hton->commit= federated_commit;
@ -436,7 +437,7 @@ error:
FALSE OK FALSE OK
*/ */
int federated_db_end(ha_panic_function type) int federated_db_end(handlerton *hton, ha_panic_function type)
{ {
if (federated_init) if (federated_init)
{ {
@ -2739,7 +2740,7 @@ bool ha_federated::get_error_message(int error, String* buf)
int ha_federated::external_lock(THD *thd, int lock_type) int ha_federated::external_lock(THD *thd, int lock_type)
{ {
int error= 0; int error= 0;
ha_federated *trx= (ha_federated *)thd->ha_data[federated_hton->slot]; ha_federated *trx= (ha_federated *)thd->ha_data[ht->slot];
DBUG_ENTER("ha_federated::external_lock"); DBUG_ENTER("ha_federated::external_lock");
if (lock_type != F_UNLCK) if (lock_type != F_UNLCK)
@ -2757,7 +2758,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
DBUG_PRINT("info", ("error setting autocommit TRUE: %d", error)); DBUG_PRINT("info", ("error setting autocommit TRUE: %d", error));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
trans_register_ha(thd, FALSE, federated_hton); trans_register_ha(thd, FALSE, ht);
} }
else else
{ {
@ -2773,8 +2774,8 @@ int ha_federated::external_lock(THD *thd, int lock_type)
DBUG_PRINT("info", ("error setting autocommit FALSE: %d", error)); DBUG_PRINT("info", ("error setting autocommit FALSE: %d", error));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
thd->ha_data[federated_hton->slot]= this; thd->ha_data[ht->slot]= this;
trans_register_ha(thd, TRUE, federated_hton); trans_register_ha(thd, TRUE, ht);
/* /*
Send a lock table to the remote end. Send a lock table to the remote end.
We do not support this at the moment We do not support this at the moment
@ -2799,10 +2800,10 @@ int ha_federated::external_lock(THD *thd, int lock_type)
} }
static int federated_commit(THD *thd, bool all) static int federated_commit(handlerton *hton, THD *thd, bool all)
{ {
int return_val= 0; int return_val= 0;
ha_federated *trx= (ha_federated *)thd->ha_data[federated_hton->slot]; ha_federated *trx= (ha_federated *)thd->ha_data[hton->slot];
DBUG_ENTER("federated_commit"); DBUG_ENTER("federated_commit");
if (all) if (all)
@ -2817,7 +2818,7 @@ static int federated_commit(THD *thd, bool all)
if (error && !return_val); if (error && !return_val);
return_val= error; return_val= error;
} }
thd->ha_data[federated_hton->slot]= NULL; thd->ha_data[hton->slot]= NULL;
} }
DBUG_PRINT("info", ("error val: %d", return_val)); DBUG_PRINT("info", ("error val: %d", return_val));
@ -2825,10 +2826,10 @@ static int federated_commit(THD *thd, bool all)
} }
static int federated_rollback(THD *thd, bool all) static int federated_rollback(handlerton *hton, THD *thd, bool all)
{ {
int return_val= 0; int return_val= 0;
ha_federated *trx= (ha_federated *)thd->ha_data[federated_hton->slot]; ha_federated *trx= (ha_federated *)thd->ha_data[hton->slot];
DBUG_ENTER("federated_rollback"); DBUG_ENTER("federated_rollback");
if (all) if (all)
@ -2843,7 +2844,7 @@ static int federated_rollback(THD *thd, bool all)
if (error && !return_val) if (error && !return_val)
return_val= error; return_val= error;
} }
thd->ha_data[federated_hton->slot]= NULL; thd->ha_data[hton->slot]= NULL;
} }
DBUG_PRINT("info", ("error val: %d", return_val)); DBUG_PRINT("info", ("error val: %d", return_val));

View File

@ -236,6 +236,3 @@ public:
MYSQL_RES **result); MYSQL_RES **result);
}; };
int federated_db_init(void);
int federated_db_end(ha_panic_function type);

View File

@ -29,10 +29,16 @@ static handler *heap_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
handlerton *heap_hton; int heap_panic(handlerton *hton, ha_panic_function flag)
{
return hp_panic(flag);
}
int heap_init(void *p) int heap_init(void *p)
{ {
handlerton *heap_hton;
heap_hton= (handlerton *)p; heap_hton= (handlerton *)p;
heap_hton->state= SHOW_OPTION_YES; heap_hton->state= SHOW_OPTION_YES;
heap_hton->db_type= DB_TYPE_HEAP; heap_hton->db_type= DB_TYPE_HEAP;

View File

@ -19,10 +19,10 @@
/* if flag == HA_PANIC_CLOSE then all files are removed for more /* if flag == HA_PANIC_CLOSE then all files are removed for more
memory */ memory */
int heap_panic(enum ha_panic_function flag) int hp_panic(enum ha_panic_function flag)
{ {
LIST *element,*next_open; LIST *element,*next_open;
DBUG_ENTER("heap_panic"); DBUG_ENTER("hp_panic");
pthread_mutex_lock(&THR_LOCK_heap); pthread_mutex_lock(&THR_LOCK_heap);
for (element=heap_open_list ; element ; element=next_open) for (element=heap_open_list ; element ; element=next_open)
@ -54,4 +54,4 @@ int heap_panic(enum ha_panic_function flag)
} }
pthread_mutex_unlock(&THR_LOCK_heap); pthread_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(0); DBUG_RETURN(0);
} /* heap_panic */ } /* hp_panic */

View File

@ -155,7 +155,7 @@ int main(int argc, char **argv)
} }
#endif #endif
if (heap_close(file) || heap_panic(HA_PANIC_CLOSE)) if (heap_close(file) || hp_panic(HA_PANIC_CLOSE))
goto err; goto err;
my_end(MY_GIVE_INFO); my_end(MY_GIVE_INFO);
return(0); return(0);

View File

@ -603,7 +603,7 @@ end:
if (heap_close(file) || (file2 && heap_close(file2))) if (heap_close(file) || (file2 && heap_close(file2)))
goto err; goto err;
heap_delete_table(filename2); heap_delete_table(filename2);
heap_panic(HA_PANIC_CLOSE); hp_panic(HA_PANIC_CLOSE);
my_end(MY_GIVE_INFO); my_end(MY_GIVE_INFO);
return(0); return(0);
err: err:
@ -669,7 +669,7 @@ static sig_handler endprog(int sig_number __attribute__((unused)))
else else
#endif #endif
{ {
heap_panic(HA_PANIC_CLOSE); hp_panic(HA_PANIC_CLOSE);
my_end(1); my_end(1);
exit(1); exit(1);
} }

View File

@ -54,6 +54,12 @@ pthread_cond_t commit_cond;
pthread_mutex_t commit_cond_m; pthread_mutex_t commit_cond_m;
bool innodb_inited= 0; bool innodb_inited= 0;
/*
This needs to exist until the query cache callback is removed
or learns to pass hton.
*/
static handlerton *legacy_innodb_hton;
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
/* These variables are used to implement (semi-)synchronous MySQL binlog /* These variables are used to implement (semi-)synchronous MySQL binlog
replication for InnoDB tables. */ replication for InnoDB tables. */
@ -197,20 +203,20 @@ static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
my_bool not_used __attribute__((unused))); my_bool not_used __attribute__((unused)));
static INNOBASE_SHARE *get_share(const char *table_name); static INNOBASE_SHARE *get_share(const char *table_name);
static void free_share(INNOBASE_SHARE *share); static void free_share(INNOBASE_SHARE *share);
static int innobase_close_connection(THD* thd); static int innobase_close_connection(handlerton *hton, THD* thd);
static int innobase_commit(THD* thd, bool all); static int innobase_commit(handlerton *hton, THD* thd, bool all);
static int innobase_rollback(THD* thd, bool all); static int innobase_rollback(handlerton *hton, THD* thd, bool all);
static int innobase_rollback_to_savepoint(THD* thd, void *savepoint); static int innobase_rollback_to_savepoint(handlerton *hton, THD* thd,
static int innobase_savepoint(THD* thd, void *savepoint); void *savepoint);
static int innobase_release_savepoint(THD* thd, void *savepoint); static int innobase_savepoint(handlerton *hton, THD* thd, void *savepoint);
static int innobase_release_savepoint(handlerton *hton, THD* thd,
void *savepoint);
static handler *innobase_create_handler(handlerton *hton, static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
static const char innobase_hton_name[]= "InnoDB"; static const char innobase_hton_name[]= "InnoDB";
handlerton *innobase_hton;
static handler *innobase_create_handler(handlerton *hton, static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
@ -383,7 +389,8 @@ documentation, see handler.cc. */
int int
innobase_release_temporary_latches( innobase_release_temporary_latches(
/*===============================*/ /*===============================*/
THD *thd) handlerton *hton,
THD *thd)
{ {
trx_t* trx; trx_t* trx;
@ -392,7 +399,7 @@ innobase_release_temporary_latches(
return 0; return 0;
} }
trx = (trx_t*) thd->ha_data[innobase_hton->slot]; trx = (trx_t*) thd->ha_data[hton->slot];
if (trx) { if (trx) {
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
@ -844,13 +851,14 @@ trx_t*
check_trx_exists( check_trx_exists(
/*=============*/ /*=============*/
/* out: InnoDB transaction handle */ /* out: InnoDB transaction handle */
handlerton* hton, /* in: handlerton for innodb */
THD* thd) /* in: user thread handle */ THD* thd) /* in: user thread handle */
{ {
trx_t* trx; trx_t* trx;
ut_ad(thd == current_thd); ut_ad(thd == current_thd);
trx = (trx_t*) thd->ha_data[innobase_hton->slot]; trx = (trx_t*) thd->ha_data[hton->slot];
if (trx == NULL) { if (trx == NULL) {
DBUG_ASSERT(thd != NULL); DBUG_ASSERT(thd != NULL);
@ -864,7 +872,7 @@ check_trx_exists(
CPU time */ CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa); trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
thd->ha_data[innobase_hton->slot] = trx; thd->ha_data[hton->slot] = trx;
} else { } else {
if (trx->magic_n != TRX_MAGIC_N) { if (trx->magic_n != TRX_MAGIC_N) {
mem_analyze_corruption(trx); mem_analyze_corruption(trx);
@ -893,7 +901,7 @@ check_trx_exists(
Construct ha_innobase handler. */ Construct ha_innobase handler. */
ha_innobase::ha_innobase(handlerton *hton, TABLE_SHARE *table_arg) ha_innobase::ha_innobase(handlerton *hton, TABLE_SHARE *table_arg)
:handler(innobase_hton, table_arg), :handler(hton, table_arg),
int_table_flags(HA_REC_NOT_IN_SEQ | int_table_flags(HA_REC_NOT_IN_SEQ |
HA_NULL_IN_KEY | HA_NULL_IN_KEY |
HA_CAN_INDEX_BLOBS | HA_CAN_INDEX_BLOBS |
@ -920,7 +928,7 @@ ha_innobase::update_thd(
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
trx = check_trx_exists(thd); trx = check_trx_exists(ht, thd);
if (prebuilt->trx != trx) { if (prebuilt->trx != trx) {
@ -941,10 +949,11 @@ inline
void void
innobase_register_stmt( innobase_register_stmt(
/*===================*/ /*===================*/
handlerton* hton, /* in: Innobase hton */
THD* thd) /* in: MySQL thd (connection) object */ THD* thd) /* in: MySQL thd (connection) object */
{ {
/* Register the statement */ /* Register the statement */
trans_register_ha(thd, FALSE, innobase_hton); trans_register_ha(thd, FALSE, hton);
} }
/************************************************************************* /*************************************************************************
@ -958,17 +967,18 @@ inline
void void
innobase_register_trx_and_stmt( innobase_register_trx_and_stmt(
/*===========================*/ /*===========================*/
handlerton *hton, /* in: Innobase handlerton */
THD* thd) /* in: MySQL thd (connection) object */ THD* thd) /* in: MySQL thd (connection) object */
{ {
/* NOTE that actually innobase_register_stmt() registers also /* NOTE that actually innobase_register_stmt() registers also
the transaction in the AUTOCOMMIT=1 mode. */ the transaction in the AUTOCOMMIT=1 mode. */
innobase_register_stmt(thd); innobase_register_stmt(hton, thd);
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
/* No autocommit mode, register for a transaction */ /* No autocommit mode, register for a transaction */
trans_register_ha(thd, TRUE, innobase_hton); trans_register_ha(thd, TRUE, hton);
} }
} }
@ -1064,7 +1074,7 @@ innobase_query_caching_of_table_permitted(
return((my_bool)FALSE); return((my_bool)FALSE);
} }
trx = check_trx_exists(thd); trx = check_trx_exists(legacy_innodb_hton, thd);
if (trx->has_search_latch) { if (trx->has_search_latch) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
sql_print_error("The calling thread is holding the adaptive " sql_print_error("The calling thread is holding the adaptive "
@ -1123,7 +1133,7 @@ innobase_query_caching_of_table_permitted(
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(thd); innobase_register_trx_and_stmt(legacy_innodb_hton, thd);
trx->active_trans = 1; trx->active_trans = 1;
} }
@ -1298,7 +1308,7 @@ ha_innobase::init_table_handle_for_HANDLER(void)
if (prebuilt->trx->active_trans == 0) { if (prebuilt->trx->active_trans == 0) {
innobase_register_trx_and_stmt(current_thd); innobase_register_trx_and_stmt(ht, current_thd);
prebuilt->trx->active_trans = 1; prebuilt->trx->active_trans = 1;
} }
@ -1341,7 +1351,8 @@ innobase_init(void *p)
char *default_path; char *default_path;
DBUG_ENTER("innobase_init"); DBUG_ENTER("innobase_init");
innobase_hton= (handlerton *)p; handlerton *innobase_hton= (handlerton *)p;
legacy_innodb_hton= innobase_hton;
innobase_hton->state=have_innodb; innobase_hton->state=have_innodb;
innobase_hton->db_type= DB_TYPE_INNODB; innobase_hton->db_type= DB_TYPE_INNODB;
@ -1616,7 +1627,7 @@ error:
Closes an InnoDB database. */ Closes an InnoDB database. */
int int
innobase_end(ha_panic_function type) innobase_end(handlerton *hton, ha_panic_function type)
/*==============*/ /*==============*/
/* out: TRUE if error */ /* out: TRUE if error */
{ {
@ -1654,7 +1665,7 @@ Flushes InnoDB logs to disk and makes a checkpoint. Really, a commit flushes
the logs, and the name of this function should be innobase_checkpoint. */ the logs, and the name of this function should be innobase_checkpoint. */
bool bool
innobase_flush_logs(void) innobase_flush_logs(handlerton *hton)
/*=====================*/ /*=====================*/
/* out: TRUE if error */ /* out: TRUE if error */
{ {
@ -1693,6 +1704,7 @@ int
innobase_start_trx_and_assign_read_view( innobase_start_trx_and_assign_read_view(
/*====================================*/ /*====================================*/
/* out: 0 */ /* out: 0 */
handlerton *hton, /* in: Innodb handlerton */
THD* thd) /* in: MySQL thread handle of the user for whom THD* thd) /* in: MySQL thread handle of the user for whom
the transaction should be committed */ the transaction should be committed */
{ {
@ -1702,7 +1714,7 @@ innobase_start_trx_and_assign_read_view(
/* Create a new trx struct for thd, if it does not yet have one */ /* Create a new trx struct for thd, if it does not yet have one */
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
/* This is just to play safe: release a possible FIFO ticket and /* This is just to play safe: release a possible FIFO ticket and
search latch. Since we will reserve the kernel mutex, we have to search latch. Since we will reserve the kernel mutex, we have to
@ -1721,9 +1733,7 @@ innobase_start_trx_and_assign_read_view(
/* Set the MySQL flag to mark that there is an active transaction */ /* Set the MySQL flag to mark that there is an active transaction */
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(hton, current_thd);
innobase_register_trx_and_stmt(current_thd);
trx->active_trans = 1; trx->active_trans = 1;
} }
@ -1738,7 +1748,8 @@ int
innobase_commit( innobase_commit(
/*============*/ /*============*/
/* out: 0 */ /* out: 0 */
THD* thd, /* in: MySQL thread handle of the user for whom handlerton *hton, /* in: Innodb handlerton */
THD* thd, /* in: MySQL thread handle of the user for whom
the transaction should be committed */ the transaction should be committed */
bool all) /* in: TRUE - commit transaction bool all) /* in: TRUE - commit transaction
FALSE - the current SQL statement ended */ FALSE - the current SQL statement ended */
@ -1748,7 +1759,7 @@ innobase_commit(
DBUG_ENTER("innobase_commit"); DBUG_ENTER("innobase_commit");
DBUG_PRINT("trans", ("ending transaction")); DBUG_PRINT("trans", ("ending transaction"));
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
/* Update the info whether we should skip XA steps that eat CPU time */ /* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa); trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
@ -1874,6 +1885,7 @@ int
innobase_report_binlog_offset_and_commit( innobase_report_binlog_offset_and_commit(
/*=====================================*/ /*=====================================*/
/* out: 0 */ /* out: 0 */
handlerton *hton, /* in: Innodb handlerton */
THD* thd, /* in: user thread */ THD* thd, /* in: user thread */
void* trx_handle, /* in: InnoDB trx handle */ void* trx_handle, /* in: InnoDB trx handle */
char* log_file_name, /* in: latest binlog file name */ char* log_file_name, /* in: latest binlog file name */
@ -1891,7 +1903,7 @@ innobase_report_binlog_offset_and_commit(
trx->flush_log_later = TRUE; trx->flush_log_later = TRUE;
innobase_commit(thd, TRUE); innobase_commit(hton, thd, TRUE);
trx->flush_log_later = FALSE; trx->flush_log_later = FALSE;
@ -1939,11 +1951,12 @@ int
innobase_commit_complete( innobase_commit_complete(
/*=====================*/ /*=====================*/
/* out: 0 */ /* out: 0 */
handlerton *hton, /* in: Innodb handlerton */
THD* thd) /* in: user thread */ THD* thd) /* in: user thread */
{ {
trx_t* trx; trx_t* trx;
trx = (trx_t*) thd->ha_data[innobase_hton->slot]; trx = (trx_t*) thd->ha_data[hton->slot];
if (trx && trx->active_trans) { if (trx && trx->active_trans) {
@ -1967,6 +1980,7 @@ static int
innobase_rollback( innobase_rollback(
/*==============*/ /*==============*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton, /* in: Innodb handlerton */
THD* thd, /* in: handle to the MySQL thread of the user THD* thd, /* in: handle to the MySQL thread of the user
whose transaction should be rolled back */ whose transaction should be rolled back */
bool all) /* in: TRUE - commit transaction bool all) /* in: TRUE - commit transaction
@ -1978,7 +1992,7 @@ innobase_rollback(
DBUG_ENTER("innobase_rollback"); DBUG_ENTER("innobase_rollback");
DBUG_PRINT("trans", ("aborting transaction")); DBUG_PRINT("trans", ("aborting transaction"));
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
/* Update the info whether we should skip XA steps that eat CPU time */ /* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa); trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
@ -2050,6 +2064,7 @@ innobase_rollback_to_savepoint(
/*===========================*/ /*===========================*/
/* out: 0 if success, HA_ERR_NO_SAVEPOINT if /* out: 0 if success, HA_ERR_NO_SAVEPOINT if
no savepoint with the given name */ no savepoint with the given name */
handlerton *hton, /* in: Innodb handlerton */
THD* thd, /* in: handle to the MySQL thread of the user THD* thd, /* in: handle to the MySQL thread of the user
whose transaction should be rolled back */ whose transaction should be rolled back */
void* savepoint) /* in: savepoint data */ void* savepoint) /* in: savepoint data */
@ -2061,7 +2076,7 @@ innobase_rollback_to_savepoint(
DBUG_ENTER("innobase_rollback_to_savepoint"); DBUG_ENTER("innobase_rollback_to_savepoint");
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
/* Release a possible FIFO ticket and search latch. Since we will /* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
@ -2086,6 +2101,7 @@ innobase_release_savepoint(
/*=======================*/ /*=======================*/
/* out: 0 if success, HA_ERR_NO_SAVEPOINT if /* out: 0 if success, HA_ERR_NO_SAVEPOINT if
no savepoint with the given name */ no savepoint with the given name */
handlerton* hton, /* in: handlerton for Innodb */
THD* thd, /* in: handle to the MySQL thread of the user THD* thd, /* in: handle to the MySQL thread of the user
whose transaction should be rolled back */ whose transaction should be rolled back */
void* savepoint) /* in: savepoint data */ void* savepoint) /* in: savepoint data */
@ -2096,7 +2112,7 @@ innobase_release_savepoint(
DBUG_ENTER("innobase_release_savepoint"); DBUG_ENTER("innobase_release_savepoint");
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
/* TODO: use provided savepoint data area to store savepoint data */ /* TODO: use provided savepoint data area to store savepoint data */
@ -2114,6 +2130,7 @@ int
innobase_savepoint( innobase_savepoint(
/*===============*/ /*===============*/
/* out: always 0, that is, always succeeds */ /* out: always 0, that is, always succeeds */
handlerton* hton, /* in: handle to the Innodb handlerton */
THD* thd, /* in: handle to the MySQL thread */ THD* thd, /* in: handle to the MySQL thread */
void* savepoint) /* in: savepoint data */ void* savepoint) /* in: savepoint data */
{ {
@ -2130,7 +2147,7 @@ innobase_savepoint(
DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) || DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
thd->in_sub_stmt); thd->in_sub_stmt);
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
/* Release a possible FIFO ticket and search latch. Since we will /* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
@ -2157,12 +2174,13 @@ int
innobase_close_connection( innobase_close_connection(
/*======================*/ /*======================*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton* hton, /* in: innobase handlerton */
THD* thd) /* in: handle to the MySQL thread of the user THD* thd) /* in: handle to the MySQL thread of the user
whose resources should be free'd */ whose resources should be free'd */
{ {
trx_t* trx; trx_t* trx;
trx = (trx_t*)thd->ha_data[innobase_hton->slot]; trx = (trx_t*)thd->ha_data[hton->slot];
ut_a(trx); ut_a(trx);
@ -3255,11 +3273,11 @@ ha_innobase::write_row(
DBUG_ENTER("ha_innobase::write_row"); DBUG_ENTER("ha_innobase::write_row");
if (prebuilt->trx != if (prebuilt->trx !=
(trx_t*) current_thd->ha_data[innobase_hton->slot]) { (trx_t*) current_thd->ha_data[ht->slot]) {
sql_print_error("The transaction object for the table handle is at " sql_print_error("The transaction object for the table handle is at "
"%p, but for the current thread it is at %p", "%p, but for the current thread it is at %p",
prebuilt->trx, prebuilt->trx,
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr); fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200); ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200);
@ -3267,7 +3285,7 @@ ha_innobase::write_row(
"InnoDB: Dump of 200 bytes around transaction.all: ", "InnoDB: Dump of 200 bytes around transaction.all: ",
stderr); stderr);
ut_print_buf(stderr, ut_print_buf(stderr,
((byte*)(&(current_thd->ha_data[innobase_hton->slot]))) - 100, ((byte*)(&(current_thd->ha_data[ht->slot]))) - 100,
200); 200);
putc('\n', stderr); putc('\n', stderr);
ut_error; ut_error;
@ -3321,7 +3339,7 @@ no_commit:
no need to re-acquire locks on it. */ no need to re-acquire locks on it. */
/* Altering to InnoDB format */ /* Altering to InnoDB format */
innobase_commit(user_thd, 1); innobase_commit(ht, user_thd, 1);
/* Note that this transaction is still active. */ /* Note that this transaction is still active. */
prebuilt->trx->active_trans = 1; prebuilt->trx->active_trans = 1;
/* We will need an IX lock on the destination table. */ /* We will need an IX lock on the destination table. */
@ -3337,7 +3355,7 @@ no_commit:
/* Commit the transaction. This will release the table /* Commit the transaction. This will release the table
locks, so they have to be acquired again. */ locks, so they have to be acquired again. */
innobase_commit(user_thd, 1); innobase_commit(ht, user_thd, 1);
/* Note that this transaction is still active. */ /* Note that this transaction is still active. */
prebuilt->trx->active_trans = 1; prebuilt->trx->active_trans = 1;
/* Re-acquire the table lock on the source table. */ /* Re-acquire the table lock on the source table. */
@ -3640,7 +3658,7 @@ ha_innobase::update_row(
DBUG_ENTER("ha_innobase::update_row"); DBUG_ENTER("ha_innobase::update_row");
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
@ -3701,7 +3719,7 @@ ha_innobase::delete_row(
DBUG_ENTER("ha_innobase::delete_row"); DBUG_ENTER("ha_innobase::delete_row");
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
if (last_query_id != user_thd->query_id) { if (last_query_id != user_thd->query_id) {
prebuilt->sql_stat_start = TRUE; prebuilt->sql_stat_start = TRUE;
@ -3799,7 +3817,7 @@ ha_innobase::try_semi_consistent_read(bool yes)
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
/* Row read type is set to semi consistent read if this was /* Row read type is set to semi consistent read if this was
requested by the MySQL and either innodb_locks_unsafe_for_binlog requested by the MySQL and either innodb_locks_unsafe_for_binlog
@ -3966,7 +3984,7 @@ ha_innobase::index_read(
DBUG_ENTER("index_read"); DBUG_ENTER("index_read");
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
statistic_increment(current_thd->status_var.ha_read_key_count, statistic_increment(current_thd->status_var.ha_read_key_count,
&LOCK_status); &LOCK_status);
@ -4081,7 +4099,7 @@ ha_innobase::change_active_index(
ut_ad(user_thd == current_thd); ut_ad(user_thd == current_thd);
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
active_index = keynr; active_index = keynr;
@ -4171,7 +4189,7 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch"); DBUG_ENTER("general_fetch");
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
innodb_srv_conc_enter_innodb(prebuilt->trx); innodb_srv_conc_enter_innodb(prebuilt->trx);
@ -4407,7 +4425,7 @@ ha_innobase::rnd_pos(
&LOCK_status); &LOCK_status);
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
if (prebuilt->clust_index_was_generated) { if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we /* No primary key was defined for the table and we
@ -4457,7 +4475,7 @@ ha_innobase::position(
uint len; uint len;
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
if (prebuilt->clust_index_was_generated) { if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we /* No primary key was defined for the table and we
@ -4785,7 +4803,7 @@ ha_innobase::create(
/* Get the transaction associated with the current thd, or create one /* Get the transaction associated with the current thd, or create one
if not yet created */ if not yet created */
parent_trx = check_trx_exists(thd); parent_trx = check_trx_exists(ht, thd);
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
@ -4958,7 +4976,7 @@ ha_innobase::discard_or_import_tablespace(
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
dict_table = prebuilt->table; dict_table = prebuilt->table;
trx = prebuilt->trx; trx = prebuilt->trx;
@ -5038,7 +5056,7 @@ ha_innobase::delete_table(
/* Get the transaction associated with the current thd, or create one /* Get the transaction associated with the current thd, or create one
if not yet created */ if not yet created */
parent_trx = check_trx_exists(thd); parent_trx = check_trx_exists(ht, thd);
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
@ -5105,6 +5123,7 @@ void
innobase_drop_database( innobase_drop_database(
/*===================*/ /*===================*/
/* out: error number */ /* out: error number */
handlerton *hton, /* in: handlerton of Innodb */
char* path) /* in: database path; inside InnoDB the name char* path) /* in: database path; inside InnoDB the name
of the last directory in the path is used as of the last directory in the path is used as
the database name: for example, in 'mysql/data/test' the database name: for example, in 'mysql/data/test'
@ -5120,7 +5139,7 @@ innobase_drop_database(
/* Get the transaction associated with the current thd, or create one /* Get the transaction associated with the current thd, or create one
if not yet created */ if not yet created */
parent_trx = check_trx_exists(current_thd); parent_trx = check_trx_exists(hton, current_thd);
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
@ -5199,7 +5218,7 @@ ha_innobase::rename_table(
/* Get the transaction associated with the current thd, or create one /* Get the transaction associated with the current thd, or create one
if not yet created */ if not yet created */
parent_trx = check_trx_exists(current_thd); parent_trx = check_trx_exists(ht, current_thd);
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
@ -5286,7 +5305,7 @@ ha_innobase::records_in_range(
DBUG_ENTER("records_in_range"); DBUG_ENTER("records_in_range");
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
prebuilt->trx->op_info = (char*)"estimating records in index range"; prebuilt->trx->op_info = (char*)"estimating records in index range";
@ -5728,7 +5747,7 @@ ha_innobase::check(
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
if (prebuilt->mysql_template == NULL) { if (prebuilt->mysql_template == NULL) {
/* Build the template; we will use a dummy template /* Build the template; we will use a dummy template
@ -6012,7 +6031,7 @@ ha_innobase::can_switch_engines(void)
DBUG_ENTER("ha_innobase::can_switch_engines"); DBUG_ENTER("ha_innobase::can_switch_engines");
ut_a(prebuilt->trx == ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton->slot]); (trx_t*) current_thd->ha_data[ht->slot]);
prebuilt->trx->op_info = prebuilt->trx->op_info =
"determining if there are foreign key constraints"; "determining if there are foreign key constraints";
@ -6205,10 +6224,10 @@ ha_innobase::start_stmt(
/* Set the MySQL flag to mark that there is an active transaction */ /* Set the MySQL flag to mark that there is an active transaction */
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(thd); innobase_register_trx_and_stmt(ht, thd);
trx->active_trans = 1; trx->active_trans = 1;
} else { } else {
innobase_register_stmt(thd); innobase_register_stmt(ht, thd);
} }
return(0); return(0);
@ -6281,10 +6300,10 @@ ha_innobase::external_lock(
transaction */ transaction */
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(thd); innobase_register_trx_and_stmt(ht, thd);
trx->active_trans = 1; trx->active_trans = 1;
} else if (trx->n_mysql_tables_in_use == 0) { } else if (trx->n_mysql_tables_in_use == 0) {
innobase_register_stmt(thd); innobase_register_stmt(ht, thd);
} }
trx->n_mysql_tables_in_use++; trx->n_mysql_tables_in_use++;
@ -6362,7 +6381,7 @@ ha_innobase::external_lock(
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
if (trx->active_trans != 0) { if (trx->active_trans != 0) {
innobase_commit(thd, TRUE); innobase_commit(ht, thd, TRUE);
} }
} else { } else {
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
@ -6443,7 +6462,7 @@ ha_innobase::transactional_table_lock(
/* Set the MySQL flag to mark that there is an active transaction */ /* Set the MySQL flag to mark that there is an active transaction */
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(thd); innobase_register_trx_and_stmt(ht, thd);
trx->active_trans = 1; trx->active_trans = 1;
} }
@ -6491,6 +6510,7 @@ Monitor to the client. */
bool bool
innodb_show_status( innodb_show_status(
/*===============*/ /*===============*/
handlerton* hton, /* in: the innodb handlerton */
THD* thd, /* in: the MySQL query thread of the caller */ THD* thd, /* in: the MySQL query thread of the caller */
stat_print_fn *stat_print) stat_print_fn *stat_print)
{ {
@ -6506,7 +6526,7 @@ innodb_show_status(
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
trx = check_trx_exists(thd); trx = check_trx_exists(hton, thd);
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
@ -6581,6 +6601,7 @@ Implements the SHOW MUTEX STATUS command. . */
bool bool
innodb_mutex_show_status( innodb_mutex_show_status(
/*=====================*/ /*=====================*/
handlerton* hton, /* in: the innodb handlerton */
THD* thd, /* in: the MySQL query thread of the THD* thd, /* in: the MySQL query thread of the
caller */ caller */
stat_print_fn* stat_print) stat_print_fn* stat_print)
@ -6662,14 +6683,15 @@ innodb_mutex_show_status(
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
bool innobase_show_status(THD* thd, stat_print_fn* stat_print, bool innobase_show_status(handlerton *hton, THD* thd,
enum ha_stat_type stat_type) stat_print_fn* stat_print,
enum ha_stat_type stat_type)
{ {
switch (stat_type) { switch (stat_type) {
case HA_ENGINE_STATUS: case HA_ENGINE_STATUS:
return innodb_show_status(thd, stat_print); return innodb_show_status(hton, thd, stat_print);
case HA_ENGINE_MUTEX: case HA_ENGINE_MUTEX:
return innodb_mutex_show_status(thd, stat_print); return innodb_mutex_show_status(hton, thd, stat_print);
default: default:
return FALSE; return FALSE;
} }
@ -6769,7 +6791,7 @@ ha_innobase::store_lock(
because we call update_thd() later, in ::external_lock()! Failure to because we call update_thd() later, in ::external_lock()! Failure to
understand this caused a serious memory corruption bug in 5.1.11. */ understand this caused a serious memory corruption bug in 5.1.11. */
trx = check_trx_exists(thd); trx = check_trx_exists(ht, thd);
/* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE!
Be careful to ignore TL_IGNORE if we are going to do something with Be careful to ignore TL_IGNORE if we are going to do something with
@ -7155,7 +7177,7 @@ ha_innobase::reset_auto_increment(ulonglong value)
bool bool
ha_innobase::get_error_message(int error, String *buf) ha_innobase::get_error_message(int error, String *buf)
{ {
trx_t* trx = check_trx_exists(current_thd); trx_t* trx = check_trx_exists(ht, current_thd);
buf->copy(trx->detailed_error, strlen(trx->detailed_error), buf->copy(trx->detailed_error, strlen(trx->detailed_error),
system_charset_info); system_charset_info);
@ -7374,13 +7396,14 @@ int
innobase_xa_prepare( innobase_xa_prepare(
/*================*/ /*================*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton,
THD* thd, /* in: handle to the MySQL thread of the user THD* thd, /* in: handle to the MySQL thread of the user
whose XA transaction should be prepared */ whose XA transaction should be prepared */
bool all) /* in: TRUE - commit transaction bool all) /* in: TRUE - commit transaction
FALSE - the current SQL statement ended */ FALSE - the current SQL statement ended */
{ {
int error = 0; int error = 0;
trx_t* trx = check_trx_exists(thd); trx_t* trx = check_trx_exists(hton, thd);
if (thd->lex->sql_command != SQLCOM_XA_PREPARE && if (thd->lex->sql_command != SQLCOM_XA_PREPARE &&
(all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))))
@ -7470,6 +7493,7 @@ innobase_xa_recover(
/*================*/ /*================*/
/* out: number of prepared transactions /* out: number of prepared transactions
stored in xid_list */ stored in xid_list */
handlerton *hton,
XID* xid_list, /* in/out: prepared transactions */ XID* xid_list, /* in/out: prepared transactions */
uint len) /* in: number of slots in xid_list */ uint len) /* in: number of slots in xid_list */
{ {
@ -7489,6 +7513,7 @@ int
innobase_commit_by_xid( innobase_commit_by_xid(
/*===================*/ /*===================*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton,
XID* xid) /* in: X/Open XA transaction identification */ XID* xid) /* in: X/Open XA transaction identification */
{ {
trx_t* trx; trx_t* trx;
@ -7512,6 +7537,7 @@ int
innobase_rollback_by_xid( innobase_rollback_by_xid(
/*=====================*/ /*=====================*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton,
XID *xid) /* in: X/Open XA transaction identification */ XID *xid) /* in: X/Open XA transaction identification */
{ {
trx_t* trx; trx_t* trx;
@ -7532,12 +7558,13 @@ This consistent view is then used inside of MySQL when accessing records
using a cursor. */ using a cursor. */
void* void*
innobase_create_cursor_view(void) innobase_create_cursor_view(
/*=============================*/ /*=============================*/
/* out: Pointer to cursor view or NULL */ /* out: Pointer to cursor view or NULL */
handlerton *hton) /* in: innobase hton */
{ {
return(read_cursor_view_create_for_mysql( return(read_cursor_view_create_for_mysql(
check_trx_exists(current_thd))); check_trx_exists(hton, current_thd)));
} }
/*********************************************************************** /***********************************************************************
@ -7548,9 +7575,10 @@ corresponding MySQL thread still lacks one. */
void void
innobase_close_cursor_view( innobase_close_cursor_view(
/*=======================*/ /*=======================*/
handlerton *hton,
void* curview)/* in: Consistent read view to be closed */ void* curview)/* in: Consistent read view to be closed */
{ {
read_cursor_view_close_for_mysql(check_trx_exists(current_thd), read_cursor_view_close_for_mysql(check_trx_exists(hton, current_thd),
(cursor_view_t*) curview); (cursor_view_t*) curview);
} }
@ -7563,9 +7591,10 @@ restored to a transaction read view. */
void void
innobase_set_cursor_view( innobase_set_cursor_view(
/*=====================*/ /*=====================*/
handlerton *hton,
void* curview)/* in: Consistent cursor view to be set */ void* curview)/* in: Consistent cursor view to be set */
{ {
read_cursor_set_for_mysql(check_trx_exists(current_thd), read_cursor_set_for_mysql(check_trx_exists(hton, current_thd),
(cursor_view_t*) curview); (cursor_view_t*) curview);
} }

View File

@ -240,8 +240,8 @@ extern ulong srv_flush_log_at_trx_commit;
} }
int innobase_init(void); int innobase_init(void);
int innobase_end(ha_panic_function type); int innobase_end(handlerton *hton, ha_panic_function type);
bool innobase_flush_logs(void); bool innobase_flush_logs(handlerton *hton);
uint innobase_get_free_space(void); uint innobase_get_free_space(void);
/* /*
@ -258,14 +258,14 @@ int innobase_commit_complete(void* trx_handle);
void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset); void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
#endif #endif
void innobase_drop_database(char *path); void innobase_drop_database(handlerton *hton, char *path);
bool innobase_show_status(THD* thd, stat_print_fn*, enum ha_stat_type); bool innobase_show_status(handlerton *hton, THD* thd, stat_print_fn*, enum ha_stat_type);
int innobase_release_temporary_latches(THD *thd); int innobase_release_temporary_latches(handlerton *hton, THD *thd);
void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset); void innobase_store_binlog_offset_and_flush_log(handlerton *hton, char *binlog_name,longlong offset);
int innobase_start_trx_and_assign_read_view(THD* thd); int innobase_start_trx_and_assign_read_view(handlerton *hton, THD* thd);
/*********************************************************************** /***********************************************************************
This function is used to prepare X/Open XA distributed transaction */ This function is used to prepare X/Open XA distributed transaction */
@ -273,6 +273,7 @@ This function is used to prepare X/Open XA distributed transaction */
int innobase_xa_prepare( int innobase_xa_prepare(
/*====================*/ /*====================*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton, /* in: innobase hton */
THD* thd, /* in: handle to the MySQL thread of the user THD* thd, /* in: handle to the MySQL thread of the user
whose XA transaction should be prepared */ whose XA transaction should be prepared */
bool all); /* in: TRUE - commit transaction bool all); /* in: TRUE - commit transaction
@ -285,6 +286,7 @@ int innobase_xa_recover(
/*====================*/ /*====================*/
/* out: number of prepared transactions /* out: number of prepared transactions
stored in xid_list */ stored in xid_list */
handlerton *hton, /* in: innobase hton */
XID* xid_list, /* in/out: prepared transactions */ XID* xid_list, /* in/out: prepared transactions */
uint len); /* in: number of slots in xid_list */ uint len); /* in: number of slots in xid_list */
@ -295,6 +297,7 @@ which is in the prepared state */
int innobase_commit_by_xid( int innobase_commit_by_xid(
/*=======================*/ /*=======================*/
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton, /* in: innobase hton */
XID* xid); /* in : X/Open XA Transaction Identification */ XID* xid); /* in : X/Open XA Transaction Identification */
/*********************************************************************** /***********************************************************************
@ -303,6 +306,7 @@ which is in the prepared state */
int innobase_rollback_by_xid( int innobase_rollback_by_xid(
/* out: 0 or error number */ /* out: 0 or error number */
handlerton *hton, /* in: innobase hton */
XID *xid); /* in : X/Open XA Transaction Identification */ XID *xid); /* in : X/Open XA Transaction Identification */
@ -313,9 +317,10 @@ This consistent view is then used inside of MySQL when accessing records
using a cursor. */ using a cursor. */
void* void*
innobase_create_cursor_view(void); innobase_create_cursor_view(
/*=============================*/ /*=============================*/
/* out: Pointer to cursor view or NULL */ /* out: Pointer to cursor view or NULL */
handlerton *hton); /* in: innobase hton */
/*********************************************************************** /***********************************************************************
Close the given consistent cursor view of a transaction and restore Close the given consistent cursor view of a transaction and restore
@ -325,6 +330,7 @@ corresponding MySQL thread still lacks one. */
void void
innobase_close_cursor_view( innobase_close_cursor_view(
/*=======================*/ /*=======================*/
handlerton *hton, /* in: innobase hton */
void* curview); /* in: Consistent read view to be closed */ void* curview); /* in: Consistent read view to be closed */
/*********************************************************************** /***********************************************************************
@ -336,4 +342,5 @@ restored to a transaction read view. */
void void
innobase_set_cursor_view( innobase_set_cursor_view(
/*=====================*/ /*=====================*/
handlerton *hton, /* in: innobase hton */
void* curview); /* in: Consistent read view to be set */ void* curview); /* in: Consistent read view to be set */

View File

@ -1789,16 +1789,23 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES; return COMPATIBLE_DATA_YES;
} }
handlerton *myisam_hton; extern int mi_panic(enum ha_panic_function flag);
int myisam_panic(handlerton *hton, ha_panic_function flag)
{
return mi_panic(flag);
}
static int myisam_init(void *p) static int myisam_init(void *p)
{ {
handlerton *myisam_hton;
myisam_hton= (handlerton *)p; myisam_hton= (handlerton *)p;
myisam_hton->state= SHOW_OPTION_YES; myisam_hton->state= SHOW_OPTION_YES;
myisam_hton->db_type= DB_TYPE_MYISAM; myisam_hton->db_type= DB_TYPE_MYISAM;
myisam_hton->create= myisam_create_handler; myisam_hton->create= myisam_create_handler;
myisam_hton->panic= mi_panic; myisam_hton->panic= myisam_panic;
myisam_hton->flags= HTON_CAN_RECREATE; myisam_hton->flags= HTON_CAN_RECREATE;
return 0; return 0;
} }

View File

@ -34,10 +34,6 @@
static handler *myisammrg_create_handler(TABLE_SHARE *table, static handler *myisammrg_create_handler(TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
/* MyISAM MERGE handlerton */
handlerton *myisammrg_hton;
static handler *myisammrg_create_handler(handlerton *hton, static handler *myisammrg_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
@ -555,15 +551,23 @@ bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_NO; return COMPATIBLE_DATA_NO;
} }
extern int myrg_panic(enum ha_panic_function flag);
int myisammrg_panic(handlerton *hton, ha_panic_function flag)
{
return myrg_panic(flag);
}
static int myisammrg_init(void *p) static int myisammrg_init(void *p)
{ {
handlerton *myisammrg_hton;
myisammrg_hton= (handlerton *)p; myisammrg_hton= (handlerton *)p;
myisammrg_hton->state=have_merge_db; myisammrg_hton->state= have_merge_db;
myisammrg_hton->db_type=DB_TYPE_MRG_MYISAM; myisammrg_hton->db_type= DB_TYPE_MRG_MYISAM;
myisammrg_hton->create=myisammrg_create_handler; myisammrg_hton->create= myisammrg_create_handler;
myisammrg_hton->panic=myrg_panic; myisammrg_hton->panic= myisammrg_panic;
myisammrg_hton->flags= HTON_CAN_RECREATE; myisammrg_hton->flags= HTON_CAN_RECREATE|HTON_NO_PARTITION;
return 0; return 0;
} }