diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-11-23 12:54:59 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-12-12 20:27:38 +0100 |
commit | aebb1038aab6cadc3408fc194d1d9331d2b673ff (patch) | |
tree | 1924ac0249294fe9437b981668ce825b0b6ced5c /sql/sql_update.cc | |
parent | 0e401bf7bfe4a14609e25c4335b9d4e0619e35ec (diff) | |
download | mariadb-git-aebb1038aab6cadc3408fc194d1d9331d2b673ff.tar.gz |
bugfix: multi-UPDATE, vcols, const tables
multi-update was setting up read_set/vcol_set in
multi_update::initialize_tables() that is invoked after
the optimizer (JOIN::optimize_inner()). But some rows - if they're from
const tables - will be read already in the optimizer, and these rows
will not have all necessary column/vcol values.
* multi_update::initialize_tables() uses results from the optimizer
and cannot be moved to be called earlier.
* multi_update::prepare() is called before the optimizer, but
it cannot set up read_set/vcol_set, because the optimizer
might reset them (see SELECT_LEX::update_used_tables()).
As a fix I've added a new method, select_result::prepare_to_read_rows(),
it's called from inside the optimizer just before make_join_statistics().
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index da0e6cd2116..05f7080609a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1800,6 +1800,21 @@ void multi_update::update_used_tables() } } +void multi_update::prepare_to_read_rows() +{ + /* + update column maps now. it cannot be done in ::prepare() before the + optimizer, because the optimize might reset them (in + SELECT_LEX::update_used_tables()), it cannot be done in + ::initialize_tables() after the optimizer, because the optimizer + might read rows from const tables + */ + + for (TABLE_LIST *tl= update_tables; tl; tl= tl->next_local) + tl->table->mark_columns_needed_for_update(); +} + + /* Check if table is safe to update on fly @@ -1916,12 +1931,10 @@ multi_update::initialize_tables(JOIN *join) { if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables)) { - table->mark_columns_needed_for_update(); table_to_update= table; // Update table on the fly continue; } } - table->mark_columns_needed_for_update(); table->prepare_for_position(); /* |