summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-02-03 19:09:19 +0100
committerSergei Golubchik <serg@mariadb.org>2017-02-13 18:12:05 +0100
commitdafb507e3ed09699230e3dd52fdc68c6094ee148 (patch)
treea1022c0b43ab611ed2324e3122f16e35d78c115c /sql/sql_update.cc
parente46c42217f4fc7ba43992ca54c039f2556d1859f (diff)
downloadmariadb-git-dafb507e3ed09699230e3dd52fdc68c6094ee148.tar.gz
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.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r--sql/sql_update.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 9c0e9443b0d..35e1fe24b97 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -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!
- */
- 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 */
+ 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)