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_lex.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_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bea3b14e607..634b6d1a3b8 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4122,6 +4122,15 @@ void SELECT_LEX::update_used_tables() TABLE *tab= tl->table; tab->covering_keys= tab->s->keys_for_keyread; tab->covering_keys.intersect(tab->keys_in_use_for_query); + /* + View/derived was merged. Need to recalculate read_set/vcol_set + bitmaps here. For example: + CREATE VIEW v1 AS SELECT f1,f2,f3 FROM t1; + SELECT f1 FROM v1; + Initially, the view definition will put all f1,f2,f3 in the + read_set for t1. But after the view is merged, only f1 should + be in the read_set. + */ bitmap_clear_all(tab->read_set); if (tab->vcol_set) bitmap_clear_all(tab->vcol_set); |