mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
find_all_keys: add an assert, remove current_thd
Filesort temporarily changes read_set to be tmp_set and marks only fields needed for filesort. Add an assert to ensure that it doesn't overwrite the old value of tmp_set, that is that read_set was *not* already tmp_set when filesort was invoked. Fix sql_update.cc that was was doing exactly that - changing read_set to tmp_set, configuring tmp_set for keyread, and then invoking filesort.
This commit is contained in:
@@ -534,16 +534,9 @@ int mysql_update(THD *thd,
|
||||
/*
|
||||
We can't update table directly; We must first search after all
|
||||
matching rows before updating the table!
|
||||
|
||||
note: We avoid sorting if we sort on the used index
|
||||
*/
|
||||
MY_BITMAP *save_read_set= table->read_set;
|
||||
MY_BITMAP *save_write_set= table->write_set;
|
||||
|
||||
if (query_plan.index < MAX_KEY && old_covering_keys.is_set(query_plan.index))
|
||||
table->prepare_for_keyread(query_plan.index);
|
||||
else
|
||||
table->use_all_columns();
|
||||
|
||||
/* note: We avoid sorting if we sort on the used index */
|
||||
if (query_plan.using_filesort)
|
||||
{
|
||||
/*
|
||||
@@ -569,6 +562,14 @@ int mysql_update(THD *thd,
|
||||
}
|
||||
else
|
||||
{
|
||||
MY_BITMAP *save_read_set= table->read_set;
|
||||
MY_BITMAP *save_write_set= table->write_set;
|
||||
|
||||
if (query_plan.index < MAX_KEY && old_covering_keys.is_set(query_plan.index))
|
||||
table->prepare_for_keyread(query_plan.index);
|
||||
else
|
||||
table->use_all_columns();
|
||||
|
||||
/*
|
||||
We are doing a search on a key that is updated. In this case
|
||||
we go trough the matching rows, save a pointer to them and
|
||||
@@ -681,9 +682,10 @@ int mysql_update(THD *thd,
|
||||
select->file=tempfile; // Read row ptrs from this file
|
||||
if (error >= 0)
|
||||
goto err;
|
||||
|
||||
table->file->ha_end_keyread();
|
||||
table->column_bitmaps_set(save_read_set, save_write_set);
|
||||
}
|
||||
table->file->ha_end_keyread();
|
||||
table->column_bitmaps_set(save_read_set, save_write_set);
|
||||
}
|
||||
|
||||
if (ignore)
|
||||
|
||||
Reference in New Issue
Block a user