Commit 3916e2ea authored by marko's avatar marko

Merge code from MySQL AB:

Make innobase_hton a pointer.
parent 5c1a1189
......@@ -33,6 +33,8 @@ have disables the InnoDB inlining in this file. */
#include <mysql_priv.h>
#ifdef WITH_INNOBASE_STORAGE_ENGINE
#include <m_ctype.h>
#include <hash.h>
#include <myisampack.h>
......@@ -206,7 +208,7 @@ static handler *innobase_create_handler(TABLE_SHARE *table,
static const char innobase_hton_name[]= "InnoDB";
handlerton innobase_hton;
handlerton *innobase_hton;
static handler *innobase_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
......@@ -387,7 +389,7 @@ innobase_release_temporary_latches(
return 0;
}
trx = (trx_t*) thd->ha_data[innobase_hton.slot];
trx = (trx_t*) thd->ha_data[innobase_hton->slot];
if (trx) {
innobase_release_stat_resources(trx);
......@@ -845,7 +847,7 @@ check_trx_exists(
ut_ad(thd == current_thd);
trx = (trx_t*) thd->ha_data[innobase_hton.slot];
trx = (trx_t*) thd->ha_data[innobase_hton->slot];
if (trx == NULL) {
DBUG_ASSERT(thd != NULL);
......@@ -859,7 +861,7 @@ check_trx_exists(
CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
thd->ha_data[innobase_hton.slot] = trx;
thd->ha_data[innobase_hton->slot] = trx;
} else {
if (trx->magic_n != TRX_MAGIC_N) {
mem_analyze_corruption(trx);
......@@ -888,7 +890,7 @@ check_trx_exists(
Construct ha_innobase handler. */
ha_innobase::ha_innobase(TABLE_SHARE *table_arg)
:handler(&innobase_hton, table_arg),
:handler(innobase_hton, table_arg),
int_table_flags(HA_REC_NOT_IN_SEQ |
HA_NULL_IN_KEY |
HA_CAN_INDEX_BLOBS |
......@@ -939,7 +941,7 @@ innobase_register_stmt(
THD* thd) /* in: MySQL thd (connection) object */
{
/* Register the statement */
trans_register_ha(thd, FALSE, &innobase_hton);
trans_register_ha(thd, FALSE, innobase_hton);
}
/*************************************************************************
......@@ -963,7 +965,7 @@ innobase_register_trx_and_stmt(
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
/* No autocommit mode, register for a transaction */
trans_register_ha(thd, TRUE, &innobase_hton);
trans_register_ha(thd, TRUE, innobase_hton);
}
}
......@@ -1327,7 +1329,7 @@ ha_innobase::init_table_handle_for_HANDLER(void)
Opens an InnoDB database. */
int
innobase_init(void)
innobase_init(void *p)
/*===============*/
{
static char current_dir[3]; /* Set if using current lib */
......@@ -1336,31 +1338,32 @@ innobase_init(void)
char *default_path;
DBUG_ENTER("innobase_init");
innobase_hton.state=have_innodb;
innobase_hton.db_type= DB_TYPE_INNODB;
innobase_hton.savepoint_offset=sizeof(trx_named_savept_t);
innobase_hton.close_connection=innobase_close_connection;
innobase_hton.savepoint_set=innobase_savepoint;
innobase_hton.savepoint_rollback=innobase_rollback_to_savepoint;
innobase_hton.savepoint_release=innobase_release_savepoint;
innobase_hton.commit=innobase_commit;
innobase_hton.rollback=innobase_rollback;
innobase_hton.prepare=innobase_xa_prepare;
innobase_hton.recover=innobase_xa_recover;
innobase_hton.commit_by_xid=innobase_commit_by_xid;
innobase_hton.rollback_by_xid=innobase_rollback_by_xid;
innobase_hton.create_cursor_read_view=innobase_create_cursor_view;
innobase_hton.set_cursor_read_view=innobase_set_cursor_view;
innobase_hton.close_cursor_read_view=innobase_close_cursor_view;
innobase_hton.create=innobase_create_handler;
innobase_hton.drop_database=innobase_drop_database;
innobase_hton.panic=innobase_end;
innobase_hton.start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
innobase_hton.flush_logs=innobase_flush_logs;
innobase_hton.show_status=innobase_show_status;
innobase_hton.flags=HTON_NO_FLAGS;
innobase_hton.release_temporary_latches=innobase_release_temporary_latches;
innobase_hton= (handlerton *)p;
innobase_hton->state=have_innodb;
innobase_hton->db_type= DB_TYPE_INNODB;
innobase_hton->savepoint_offset=sizeof(trx_named_savept_t);
innobase_hton->close_connection=innobase_close_connection;
innobase_hton->savepoint_set=innobase_savepoint;
innobase_hton->savepoint_rollback=innobase_rollback_to_savepoint;
innobase_hton->savepoint_release=innobase_release_savepoint;
innobase_hton->commit=innobase_commit;
innobase_hton->rollback=innobase_rollback;
innobase_hton->prepare=innobase_xa_prepare;
innobase_hton->recover=innobase_xa_recover;
innobase_hton->commit_by_xid=innobase_commit_by_xid;
innobase_hton->rollback_by_xid=innobase_rollback_by_xid;
innobase_hton->create_cursor_read_view=innobase_create_cursor_view;
innobase_hton->set_cursor_read_view=innobase_set_cursor_view;
innobase_hton->close_cursor_read_view=innobase_close_cursor_view;
innobase_hton->create=innobase_create_handler;
innobase_hton->drop_database=innobase_drop_database;
innobase_hton->panic=innobase_end;
innobase_hton->start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
innobase_hton->flush_logs=innobase_flush_logs;
innobase_hton->show_status=innobase_show_status;
innobase_hton->flags=HTON_NO_FLAGS;
innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
if (have_innodb != SHOW_OPTION_YES)
DBUG_RETURN(0); // nothing else to do
......@@ -1937,7 +1940,7 @@ innobase_commit_complete(
{
trx_t* trx;
trx = (trx_t*) thd->ha_data[innobase_hton.slot];
trx = (trx_t*) thd->ha_data[innobase_hton->slot];
if (trx && trx->active_trans) {
......@@ -2156,7 +2159,7 @@ innobase_close_connection(
{
trx_t* trx;
trx = (trx_t*)thd->ha_data[innobase_hton.slot];
trx = (trx_t*)thd->ha_data[innobase_hton->slot];
ut_a(trx);
......@@ -3251,11 +3254,11 @@ ha_innobase::write_row(
DBUG_ENTER("ha_innobase::write_row");
if (prebuilt->trx !=
(trx_t*) current_thd->ha_data[innobase_hton.slot]) {
(trx_t*) current_thd->ha_data[innobase_hton->slot]) {
sql_print_error("The transaction object for the table handle is at "
"%p, but for the current thread it is at %p",
prebuilt->trx,
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200);
......@@ -3263,7 +3266,7 @@ ha_innobase::write_row(
"InnoDB: Dump of 200 bytes around transaction.all: ",
stderr);
ut_print_buf(stderr,
((byte*)(&(current_thd->ha_data[innobase_hton.slot]))) - 100,
((byte*)(&(current_thd->ha_data[innobase_hton->slot]))) - 100,
200);
putc('\n', stderr);
ut_error;
......@@ -3639,7 +3642,7 @@ ha_innobase::update_row(
DBUG_ENTER("ha_innobase::update_row");
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
table->timestamp_field->set_time();
......@@ -3700,7 +3703,7 @@ ha_innobase::delete_row(
DBUG_ENTER("ha_innobase::delete_row");
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
if (last_query_id != user_thd->query_id) {
prebuilt->sql_stat_start = TRUE;
......@@ -3798,7 +3801,7 @@ ha_innobase::try_semi_consistent_read(bool yes)
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
/* Row read type is set to semi consistent read if this was
requested by the MySQL and either innodb_locks_unsafe_for_binlog
......@@ -3965,7 +3968,7 @@ ha_innobase::index_read(
DBUG_ENTER("index_read");
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
statistic_increment(current_thd->status_var.ha_read_key_count,
&LOCK_status);
......@@ -4080,7 +4083,7 @@ ha_innobase::change_active_index(
ut_ad(user_thd == current_thd);
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
active_index = keynr;
......@@ -4170,7 +4173,7 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch");
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
innodb_srv_conc_enter_innodb(prebuilt->trx);
......@@ -4406,7 +4409,7 @@ ha_innobase::rnd_pos(
&LOCK_status);
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we
......@@ -4456,7 +4459,7 @@ ha_innobase::position(
uint len;
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we
......@@ -4956,7 +4959,7 @@ ha_innobase::discard_or_import_tablespace(
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
dict_table = prebuilt->table;
trx = prebuilt->trx;
......@@ -5284,7 +5287,7 @@ ha_innobase::records_in_range(
DBUG_ENTER("records_in_range");
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
prebuilt->trx->op_info = (char*)"estimating records in index range";
......@@ -5726,7 +5729,7 @@ ha_innobase::check(
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
if (prebuilt->mysql_template == NULL) {
/* Build the template; we will use a dummy template
......@@ -6010,7 +6013,7 @@ ha_innobase::can_switch_engines(void)
DBUG_ENTER("ha_innobase::can_switch_engines");
ut_a(prebuilt->trx ==
(trx_t*) current_thd->ha_data[innobase_hton.slot]);
(trx_t*) current_thd->ha_data[innobase_hton->slot]);
prebuilt->trx->op_info =
"determining if there are foreign key constraints";
......@@ -7594,7 +7597,7 @@ SHOW_VAR innodb_status_variables_export[]= {
};
struct st_mysql_storage_engine innobase_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton};
{ MYSQL_HANDLERTON_INTERFACE_VERSION, innobase_hton};
mysql_declare_plugin(innobase)
{
......@@ -7606,9 +7609,10 @@ mysql_declare_plugin(innobase)
innobase_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
innodb_status_variables_export,
innodb_status_variables_export,/* status variables */
NULL, /* system variables */
NULL /* config options */
}
mysql_declare_plugin_end;
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment