diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-12-15 15:57:26 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-12-15 15:57:26 +0100 |
commit | 6bf10fac445d73fb796d4863612c87bff5f28b66 (patch) | |
tree | 4d51e193684163c21e47e9de6536cd8dae0613eb /sql/opt_table_elimination.cc | |
parent | 8efaff4959efe32ff9bc47c1bf1710cfe9ab21b5 (diff) | |
parent | 39a8d7965d912d8fb32436735449ce04e85583d1 (diff) | |
download | mariadb-git-6bf10fac445d73fb796d4863612c87bff5f28b66.tar.gz |
5.5 merge
Diffstat (limited to 'sql/opt_table_elimination.cc')
-rw-r--r-- | sql/opt_table_elimination.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index 4a10d402fac..9f304ad043b 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -609,6 +609,21 @@ void eliminate_tables(JOIN *join) /* Find the tables that are referred to from WHERE/HAVING */ used_tables= (join->conds? join->conds->used_tables() : 0) | (join->having? join->having->used_tables() : 0); + + /* + For "INSERT ... SELECT ... ON DUPLICATE KEY UPDATE column = val" + we should also take into account tables mentioned in "val". + */ + if (join->thd->lex->sql_command == SQLCOM_INSERT_SELECT && + join->select_lex == &thd->lex->select_lex) + { + List_iterator<Item> val_it(thd->lex->value_list); + while ((item= val_it++)) + { + DBUG_ASSERT(item->fixed); + used_tables |= item->used_tables(); + } + } /* Add tables referred to from the select list */ List_iterator<Item> it(join->fields_list); |