summaryrefslogtreecommitdiff
path: root/sql/opt_table_elimination.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2009-08-24 10:12:42 +0200
committerSergey Petrunya <psergey@askmonty.org>2009-08-24 10:12:42 +0200
commit21d25739088a125804db1c084b91078e8ea1c5b0 (patch)
tree199f13818211e879cf90d4137a6a38dbd9d69df8 /sql/opt_table_elimination.cc
parentf3d0b1c04e0d7edf21e1ae1378b2bafe9580f147 (diff)
downloadmariadb-git-21d25739088a125804db1c084b91078e8ea1c5b0.tar.gz
MWL#17: Table elimination
- Correctly handle the case where we have multi-table DELETE and a table that we're deleting from looks like it could be eliminated.
Diffstat (limited to 'sql/opt_table_elimination.cc')
-rw-r--r--sql/opt_table_elimination.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc
index f13ada782f4..3c32e8de3e0 100644
--- a/sql/opt_table_elimination.cc
+++ b/sql/opt_table_elimination.cc
@@ -1069,16 +1069,26 @@ void eliminate_tables(JOIN *join)
if (join->select_lex == &thd->lex->select_lex)
{
- /* Multi-table UPDATE and DELETE: don't eliminate the tables we modify: */
- used_tables |= thd->table_map_for_update;
/* Multi-table UPDATE: don't eliminate tables referred from SET statement */
if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI)
{
+ /* Multi-table UPDATE and DELETE: don't eliminate the tables we modify: */
+ used_tables |= thd->table_map_for_update;
List_iterator<Item> it2(thd->lex->value_list);
while ((item= it2++))
used_tables |= item->used_tables();
}
+
+ if (thd->lex->sql_command == SQLCOM_DELETE_MULTI)
+ {
+ TABLE_LIST *tbl;
+ for (tbl= (TABLE_LIST*)thd->lex->auxiliary_table_list.first;
+ tbl; tbl= tbl->next_local)
+ {
+ used_tables |= tbl->table->map;
+ }
+ }
}
table_map all_tables= join->all_tables_map();