Commit 3a088a32 authored by unknown's avatar unknown

ha_innobase.cc, ha_innobase.h:

  Backport from 4.0.4 the bug fix of the crash when a temporary table was created inside LOCK TABLES and used


sql/ha_innobase.h:
  Backport from 4.0.4 the bug fix of the crash when a temporary table was created inside LOCK TABLES and used
sql/ha_innobase.cc:
  Backport from 4.0.4 the bug fix of the crash when a temporary table was created inside LOCK TABLES and used
parent 28ebf117
...@@ -1977,7 +1977,8 @@ convert_search_mode_to_innobase( ...@@ -1977,7 +1977,8 @@ convert_search_mode_to_innobase(
case HA_READ_AFTER_KEY: return(PAGE_CUR_G); case HA_READ_AFTER_KEY: return(PAGE_CUR_G);
case HA_READ_BEFORE_KEY: return(PAGE_CUR_L); case HA_READ_BEFORE_KEY: return(PAGE_CUR_L);
case HA_READ_PREFIX: return(PAGE_CUR_GE); case HA_READ_PREFIX: return(PAGE_CUR_GE);
case HA_READ_PREFIX_LAST: return(PAGE_CUR_LE); case HA_READ_PREFIX_LAST: ut_a(0); return(PAGE_CUR_LE);
/* HA_READ_PREFIX_LAST does not yet work in InnoDB! */
/* the above PREFIX flags mean that the last /* the above PREFIX flags mean that the last
field in the key value may just be a prefix field in the key value may just be a prefix
of the complete fixed length field */ of the complete fixed length field */
...@@ -3413,6 +3414,47 @@ ha_innobase::reset(void) ...@@ -3413,6 +3414,47 @@ ha_innobase::reset(void)
return(0); return(0);
} }
/**********************************************************************
When we create a temporary table inside MySQL LOCK TABLES, MySQL will
not call external_lock for the temporary table when it uses it. Instead,
it will call this function. */
int
ha_innobase::start_stmt(
/*====================*/
/* out: 0 or error code */
THD* thd) /* in: handle to the user thread */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
update_thd(thd);
trx = prebuilt->trx;
innobase_release_stat_resources(trx);
trx_mark_sql_stat_end(trx);
auto_inc_counter_for_this_stat = 0;
prebuilt->sql_stat_start = TRUE;
prebuilt->hint_no_need_to_fetch_extra_cols = TRUE;
prebuilt->read_just_key = 0;
if (prebuilt->select_lock_type == LOCK_NONE) {
/* This handle is for a temporary table created inside
this same LOCK TABLES; since MySQL does NOT call external_lock
in this case, we must use x-row locks inside InnoDB to be
prepared for an update of a row */
prebuilt->select_lock_type = LOCK_X;
}
thd->transaction.all.innodb_active_trans = 1;
return(0);
}
/********************************************************************** /**********************************************************************
As MySQL will execute an external lock for every new table it uses when it As MySQL will execute an external lock for every new table it uses when it
starts to process an SQL statement, we can use this function to store the starts to process an SQL statement, we can use this function to store the
......
...@@ -139,6 +139,8 @@ class ha_innobase: public handler ...@@ -139,6 +139,8 @@ class ha_innobase: public handler
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int reset(void); int reset(void);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
int start_stmt(THD *thd);
void position(byte *record); void position(byte *record);
ha_rows records_in_range(int inx, ha_rows records_in_range(int inx,
const byte *start_key,uint start_key_len, const byte *start_key,uint start_key_len,
......
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