Commit 12b80747 authored by osku's avatar osku

Change this in ha_innobase:

 void*           innobase_prebuilt;

to this:

 row_prebuilt_t* prebuilt;

by introducing the typedef in ha_innodb.h, and remove all the now needless
local variables and casts in ha_innodb.cc.
parent 03b9c45e
......@@ -926,7 +926,6 @@ ha_innobase::update_thd(
/* out: 0 or error code */
THD* thd) /* in: thd to use the handle */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
trx = check_trx_exists(ht, thd);
......@@ -1269,8 +1268,6 @@ void
ha_innobase::init_table_handle_for_HANDLER(void)
/*============================================*/
{
row_prebuilt_t* prebuilt;
/* If current thd does not yet have a trx struct, create one.
If the current handle does not yet have a prebuilt struct, create
one. Update the trx pointers in the prebuilt struct. Normally
......@@ -1281,8 +1278,6 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/* Initialize the prebuilt struct much like it would be inited in
external_lock */
prebuilt = (row_prebuilt_t*)innobase_prebuilt;
innobase_release_stat_resources(prebuilt->trx);
/* If the transaction is not started yet, start it */
......@@ -2212,8 +2207,6 @@ ha_innobase::get_row_type() const
/*=============================*/
/* out: ROW_TYPE_REDUNDANT or ROW_TYPE_COMPACT */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (prebuilt && prebuilt->table) {
if (dict_table_is_comp_noninline(prebuilt->table)) {
return(ROW_TYPE_COMPACT);
......@@ -2378,10 +2371,9 @@ ha_innobase::open(
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
}
innobase_prebuilt = row_create_prebuilt(ib_table);
prebuilt = row_create_prebuilt(ib_table);
((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len =
table->s->reclength;
prebuilt->mysql_row_len = table->s->reclength;
/* Looks like MySQL-3.23 sometimes has primary key number != 0 */
......@@ -2400,8 +2392,8 @@ ha_innobase::open(
"dictionary, but not in MySQL!", name);
}
((row_prebuilt_t*)innobase_prebuilt)
->clust_index_was_generated = FALSE;
prebuilt->clust_index_was_generated = FALSE;
/* MySQL allocates the buffer for ref. key_info->key_length
includes space for all key columns + one byte for each column
that may be NULL. ref_length must be as exact as possible to
......@@ -2422,8 +2414,7 @@ ha_innobase::open(
"of the table.", name);
}
((row_prebuilt_t*)innobase_prebuilt)
->clust_index_was_generated = TRUE;
prebuilt->clust_index_was_generated = TRUE;
ref_length = DATA_ROW_ID_LEN;
......@@ -2470,7 +2461,7 @@ ha_innobase::close(void)
{
DBUG_ENTER("ha_innobase::close");
row_prebuilt_free((row_prebuilt_t*) innobase_prebuilt);
row_prebuilt_free(prebuilt);
my_free((gptr) upd_buff, MYF(0));
free_share(share);
......@@ -3257,7 +3248,6 @@ ha_innobase::write_row(
/* out: error code */
mysql_byte* record) /* in: a row in MySQL format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
int error;
longlong auto_inc;
longlong dummy;
......@@ -3648,7 +3638,6 @@ ha_innobase::update_row(
const mysql_byte* old_row,/* in: old row in MySQL format */
mysql_byte* new_row)/* in: new row in MySQL format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
upd_t* uvect;
int error = 0;
......@@ -3710,7 +3699,6 @@ ha_innobase::delete_row(
/* out: error number or 0 */
const mysql_byte* record) /* in: a row in MySQL format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
int error = 0;
DBUG_ENTER("ha_innobase::delete_row");
......@@ -3758,8 +3746,6 @@ void
ha_innobase::unlock_row(void)
/*=========================*/
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
DBUG_ENTER("ha_innobase::unlock_row");
if (UNIV_UNLIKELY(last_query_id != user_thd->query_id)) {
......@@ -3801,8 +3787,6 @@ bool
ha_innobase::was_semi_consistent_read(void)
/*=======================================*/
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
return(prebuilt->row_read_type == ROW_READ_DID_SEMI_CONSISTENT);
}
......@@ -3811,8 +3795,6 @@ void
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[ht->slot]);
......@@ -3971,7 +3953,6 @@ ha_innobase::index_read(
uint key_len,/* in: key value length */
enum ha_rkey_function find_flag)/* in: search flags from my_base.h */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint mode;
dict_index_t* index;
ulint match_mode = 0;
......@@ -4088,7 +4069,6 @@ ha_innobase::change_active_index(
index, even if it was internally generated by
InnoDB */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key=0;
statistic_increment(current_thd->status_var.ha_read_key_count,
&LOCK_status);
......@@ -4179,7 +4159,6 @@ ha_innobase::general_fetch(
uint match_mode) /* in: 0, ROW_SEL_EXACT, or
ROW_SEL_EXACT_PREFIX */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint ret;
int error = 0;
......@@ -4333,8 +4312,6 @@ ha_innobase::rnd_init(
{
int err;
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
/* Store the active index value so that we can restore the original
value after a scan */
......@@ -4412,7 +4389,6 @@ ha_innobase::rnd_pos(
the length of data in pos has to be
ref_length */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
int error;
uint keynr = active_index;
DBUG_ENTER("rnd_pos");
......@@ -4468,7 +4444,6 @@ ha_innobase::position(
/*==================*/
const mysql_byte* record) /* in: row in MySQL format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
uint len;
ut_a(prebuilt->trx ==
......@@ -4963,7 +4938,6 @@ ha_innobase::discard_or_import_tablespace(
/* out: 0 == success, -1 == error */
my_bool discard) /* in: TRUE if discard, else import */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_table_t* dict_table;
trx_t* trx;
int err;
......@@ -4996,7 +4970,6 @@ ha_innobase::delete_all_rows(void)
/*==============================*/
/* out: error number */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
int error;
THD* thd = current_thd;
......@@ -5281,7 +5254,6 @@ ha_innobase::records_in_range(
key_range *max_key) /* in: range end key val, may
also be 0 */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key;
dict_index_t* index;
mysql_byte* key_val_buff2 = (mysql_byte*) my_malloc(
......@@ -5375,7 +5347,6 @@ ha_innobase::estimate_rows_upper_bound(void)
/*======================================*/
/* out: upper bound of rows */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_index_t* index;
ulonglong estimate;
ulonglong local_data_file_length;
......@@ -5424,8 +5395,6 @@ ha_innobase::scan_time()
/*====================*/
/* out: estimated time measured in disk seeks */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
/* Since MySQL seems to favor table scans too much over index
searches, we pretend that a sequential read takes the same time
as a random disk read, that is, we do not divide the following
......@@ -5481,7 +5450,6 @@ ha_innobase::info(
/*==============*/
uint flag) /* in: what information MySQL requests */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_table_t* ib_table;
dict_index_t* index;
ha_rows rec_per_key;
......@@ -5732,7 +5700,6 @@ ha_innobase::check(
HA_CHECK_OPT* check_opt) /* in: check options, currently
ignored */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint ret;
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
......@@ -5767,9 +5734,8 @@ ha_innobase::update_table_comment(
info on foreign keys */
const char* comment)/* in: table comment defined by user */
{
uint length = (uint) strlen(comment);
char* str;
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
uint length = (uint) strlen(comment);
char* str;
long flen;
/* We do not know if MySQL can call this function before calling
......@@ -5842,7 +5808,6 @@ ha_innobase::get_foreign_key_create_info(void)
can be inserted to the CREATE TABLE statement,
MUST be freed with ::free_foreign_key_create_info */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
char* str = 0;
long flen;
......@@ -5900,7 +5865,6 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
dict_foreign_t* foreign;
DBUG_ENTER("get_foreign_key_list");
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
ut_a(prebuilt != NULL);
update_thd(current_thd);
prebuilt->trx->op_info = (char*)"getting list of foreign keys";
......@@ -6015,7 +5979,6 @@ bool
ha_innobase::can_switch_engines(void)
/*=================================*/
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
bool can_switch;
DBUG_ENTER("ha_innobase::can_switch_engines");
......@@ -6047,8 +6010,6 @@ ha_innobase::referenced_by_foreign_key(void)
/*========================================*/
/* out: > 0 if referenced by a FOREIGN KEY */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
if (dict_table_referenced_by_foreign_key(prebuilt->table)) {
return(1);
......@@ -6081,8 +6042,6 @@ ha_innobase::extra(
enum ha_extra_function operation)
/* in: HA_EXTRA_FLUSH or some other flag */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
/* Warning: since it is not sure that MySQL calls external_lock
before calling this function, the trx field in prebuilt can be
obsolete! */
......@@ -6115,7 +6074,6 @@ ha_innobase::extra(
int ha_innobase::reset()
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (prebuilt->blob_heap) {
row_mysql_prebuilt_free_blob_heap(prebuilt);
}
......@@ -6144,7 +6102,6 @@ ha_innobase::start_stmt(
THD* thd, /* in: handle to the user thread */
thr_lock_type lock_type)
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
update_thd(thd);
......@@ -6243,7 +6200,6 @@ ha_innobase::external_lock(
THD* thd, /* in: handle to the user thread */
int lock_type) /* in: lock type */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
DBUG_ENTER("ha_innobase::external_lock");
......@@ -6385,7 +6341,6 @@ ha_innobase::transactional_table_lock(
THD* thd, /* in: handle to the user thread */
int lock_type) /* in: lock type */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
DBUG_ENTER("ha_innobase::transactional_table_lock");
......@@ -6773,7 +6728,6 @@ ha_innobase::store_lock(
'lock'; this may also be
TL_IGNORE */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
/* Note that trx in this function is NOT necessarily prebuilt->trx
......@@ -6965,7 +6919,6 @@ ha_innobase::innobase_read_and_init_auto_inc(
timeout */
longlong* ret) /* out: auto-inc value */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
longlong auto_inc;
ulint old_select_lock_type;
ibool trx_was_not_started = FALSE;
......@@ -7145,8 +7098,7 @@ ha_innobase::reset_auto_increment(ulonglong value)
{
DBUG_ENTER("ha_innobase::reset_auto_increment");
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
int error;
int error;
update_thd(current_thd);
......@@ -7190,7 +7142,6 @@ ha_innobase::cmp_ref(
const mysql_byte* ref2) /* in: an (internal) primary key value in the
MySQL key value format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
enum_field_types mysql_type;
Field* field;
KEY_PART_INFO* key_part;
......
......@@ -33,6 +33,7 @@ typedef struct st_innobase_share {
struct row_prebuilt_struct;
typedef struct row_prebuilt_struct row_prebuilt_t;
my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name,
uint full_name_len,
......@@ -41,9 +42,8 @@ my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name,
/* The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
void* innobase_prebuilt;/* (row_prebuilt_t*) prebuilt
struct in InnoDB, used to save
CPU time with prebuilt data
row_prebuilt_t* prebuilt; /* prebuilt struct in InnoDB, used
to save CPU time with prebuilt data
structures*/
THD* user_thd; /* the thread handle of the user
currently using the handle; this is
......
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