summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-07-09 22:34:56 -0700
committerIgor Babaev <igor@askmonty.org>2011-07-09 22:34:56 -0700
commita515802c5b1bda9444a2d19b5725deeabeb5fb02 (patch)
tree2d4f1a37781f60f6af6307df89536a3c97209505 /sql/sql_lex.cc
parent9e7495df836a93e610ccd1a9e9f6ce11930a7767 (diff)
downloadmariadb-git-a515802c5b1bda9444a2d19b5725deeabeb5fb02.tar.gz
Fixed LP bug #806097.
The value of THD::used tables should be re-evaluated after merges of views and derived tables into the main query. Now it's done in the function SELECT_LEX::update_used_tables. The re-evaluation of the 'used_table' bitmaps for the items in HAVING, GROUP BY and ORDER BY clauses has been added as well.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 8633fcc98f0..39672d0c19b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3501,6 +3501,33 @@ void SELECT_LEX::update_used_tables()
join->conds->update_used_tables();
join->conds->walk(&Item::eval_not_null_tables, 0, NULL);
}
+ if (join->having)
+ {
+ join->having->update_used_tables();
+ }
+
+ Item *item;
+ List_iterator_fast<Item> it(join->fields_list);
+ while ((item= it++))
+ {
+ item->update_used_tables();
+ join->thd->used_tables|= item->used_tables();
+ }
+ Item_outer_ref *ref;
+ List_iterator_fast<Item_outer_ref> ref_it(inner_refs_list);
+ while ((ref= ref_it++))
+ {
+ item= ref->outer_ref;
+ item->update_used_tables();
+ join->thd->used_tables|= item->used_tables();
+ }
+ for (ORDER *order= group_list.first; order; order= order->next)
+ (*order->item)->update_used_tables();
+ if (!master_unit()->is_union())
+ {
+ for (ORDER *order= order_list.first; order; order= order->next)
+ (*order->item)->update_used_tables();
+ }
}