diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-11-27 17:43:16 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-11-27 17:43:16 +0400 |
commit | 928543ca6c3f37fb1f401d5fc41c71e597e76927 (patch) | |
tree | 57a7c43805378632443e3b1e2318978f571542fb /sql/opt_table_elimination.cc | |
parent | 998ed51497ae46b2478d490e22cccd16295701f8 (diff) | |
download | mariadb-git-928543ca6c3f37fb1f401d5fc41c71e597e76927.tar.gz |
MDEV-5344: LEFT OUTER JOIN table data is lost in ON DUPLICATE KEY UPDATE section
- For INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, table elimination should
check which tables are referenced in the ON DUPLICATE KEY UPDATE clause.
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 545001c9df1..1df35e93e45 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -594,6 +594,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); |