summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorSergey Petrunia <psergey@askmonty.org>2009-06-10 01:11:33 +0400
committerSergey Petrunia <psergey@askmonty.org>2009-06-10 01:11:33 +0400
commitfd485ad9889f2d8db6a2de6c61efb720cb97e96a (patch)
treef462823874fbcb7842e5dabe052c8b376323d1c1 /sql/item.h
parentcf028a54746d6b166e9ffe8fa1e2e08569fe0dc1 (diff)
downloadmariadb-git-fd485ad9889f2d8db6a2de6c61efb720cb97e96a.tar.gz
MWL#17: Table elimination
- Make elimination work with aggregate functions. The problem was that aggregate functions reported all table bits in used_tables(), and that prevented table elimination. Fixed by making aggregate functions return more correct value from used_tables(). mysql-test/r/ps_11bugs.result: MWL#17: Table elimination - Update test results. The difference is because of Item_ref change: outer references to constants are now recognized as constants, too. mysql-test/r/subselect.result: - Update test results. The difference is because of Item_ref change: outer references to constants are now recognized as constants, too. mysql-test/r/table_elim.result: MWL#17: Table elimination - Check that elimination works in presense of aggreagate functions mysql-test/t/table_elim.test: MWL#17: Table elimination - Check that elimination works in presense of aggreagate functions sql/item.h: MWL#17: Table elimination - Add Item_ref::const_item() which calls (*ref)->const_item(). Before this diff Item_ref used the default implementation of const_item(){ return used_tables()==0; }. This is no longer true, as COUNT(*) now has used_tables()==0 but const_item()==FALSE. sql/item_sum.cc: MWL#17: Table elimination - Make Item_sum() and it descendants not to return all bits in used_tables(). This is needed because otherwise table elimination can't work in presense of aggregate functions - COUNT(*) now has used_tables()==0 and const_item()==FALSE. Had to change Item_ref::const_item() to account for this. sql/item_sum.h: MWL#17: Table elimination - Add comments
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h
index 9daf353998d..4b609d58776 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2203,6 +2203,10 @@ public:
if (!depended_from)
(*ref)->update_used_tables();
}
+ bool const_item() const
+ {
+ return (*ref)->const_item();
+ }
table_map not_null_tables() const { return (*ref)->not_null_tables(); }
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }