diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-10-03 19:10:49 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-10-03 19:10:49 +0300 |
commit | 3a088a328d3b394b2ac678e2a1e73288708aba47 (patch) | |
tree | 2d95e02edb6d62681f4f58f187a5310bdac13873 | |
parent | 28ebf117dd95c831289b7027b44e64b441bb950c (diff) | |
download | mariadb-git-3a088a328d3b394b2ac678e2a1e73288708aba47.tar.gz |
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
-rw-r--r-- | sql/ha_innobase.cc | 44 | ||||
-rw-r--r-- | sql/ha_innobase.h | 2 |
2 files changed, 45 insertions, 1 deletions
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index ef58b5b7dbb..ccf53eeb5d7 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -1977,7 +1977,8 @@ convert_search_mode_to_innobase( case HA_READ_AFTER_KEY: return(PAGE_CUR_G); case HA_READ_BEFORE_KEY: return(PAGE_CUR_L); 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 field in the key value may just be a prefix of the complete fixed length field */ @@ -3413,6 +3414,47 @@ ha_innobase::reset(void) 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 starts to process an SQL statement, we can use this function to store the diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index 694d403a2d5..4fd42d08390 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -139,6 +139,8 @@ class ha_innobase: public handler int extra(enum ha_extra_function operation); int reset(void); int external_lock(THD *thd, int lock_type); + int start_stmt(THD *thd); + void position(byte *record); ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len, |