summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2013-12-02 15:17:21 +0400
committerAlexander Barkov <bar@mnogosearch.org>2013-12-02 15:17:21 +0400
commit87355a453d4661a75f3b451b30b1867910915675 (patch)
tree4dda09b490a01966a52fedca63b9e679bdfdedd9 /sql
parentf130443707aee0a9880532069afe5191d634cb4a (diff)
parent928543ca6c3f37fb1f401d5fc41c71e597e76927 (diff)
downloadmariadb-git-87355a453d4661a75f3b451b30b1867910915675.tar.gz
Merge 5.3 -> 5.5
pending merges: Sergey Petrunya 2013-11-27 MDEV-5344: LEFT OUTER JOIN table data is lost...
Diffstat (limited to 'sql')
-rw-r--r--sql/opt_table_elimination.cc15
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);