diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2018-11-01 11:35:28 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2018-11-05 21:10:15 +0300 |
commit | e058a251c10350f3727ca1df022dc5786933535b (patch) | |
tree | 6b8a46552a2c70e602e6f39c67d1936fb917edab /sql | |
parent | f0cf85fd15509179bf6e33176cb89761fc89e5a9 (diff) | |
download | mariadb-git-e058a251c10350f3727ca1df022dc5786933535b.tar.gz |
MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
Part#2: take into account that join nest that we are marking as constant
might already have constant tables in it. Don't count these tables twice.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 39c77dc4dc2..a99b991af96 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4316,14 +4316,17 @@ void mark_join_nest_as_const(JOIN *join, } JOIN_TAB *tab= tbl->table->reginfo.join_tab; - tab->type= JT_CONST; - tab->info= ET_IMPOSSIBLE_ON_CONDITION; - tab->table->const_table= 1; - - join->const_table_map|= tab->table->map; - *found_const_table_map|= tab->table->map; - set_position(join,(*const_count)++,tab,(KEYUSE*) 0); - mark_as_null_row(tab->table); // All fields are NULL + if (!(join->const_table_map & tab->table->map)) + { + tab->type= JT_CONST; + tab->info= ET_IMPOSSIBLE_ON_CONDITION; + tab->table->const_table= 1; + + join->const_table_map|= tab->table->map; + *found_const_table_map|= tab->table->map; + set_position(join,(*const_count)++,tab,(KEYUSE*) 0); + mark_as_null_row(tab->table); // All fields are NULL + } } } |