diff options
author | unknown <monty@hundin.mysql.fi> | 2002-12-02 13:41:08 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-12-02 13:41:08 +0200 |
commit | e3cecfd10c8006c6a9dabbb149225adbf5ce4deb (patch) | |
tree | 258b8df362d265455a76f9aca82b19e34555e89a /sql/item_cmpfunc.cc | |
parent | a3f9f721bca6d7d2dcd414fa295812995219ca86 (diff) | |
download | mariadb-git-e3cecfd10c8006c6a9dabbb149225adbf5ce4deb.tar.gz |
Fixed bug in MAX() optimization when used with JOIN and ON expressions
(Patch from 4.0.5)
mysql-test/r/group_by.result:
Updated results
mysql-test/t/group_by.test:
Test for bug
sql/item_cmpfunc.cc:
Fixed bug in MAX() optimization when used with JOIN and ON expressions
sql/item_cmpfunc.h:
Fixed bug in MAX() optimization when used with JOIN and ON expressions
sql/opt_sum.cc:
Fixed bug in MAX() optimization when used with JOIN and ON expressions
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 36ecde337a7..c50a1bc088f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1207,6 +1207,45 @@ longlong Item_cond_or::val_int() return 0; } +/* + Create an AND expression from two expressions + + SYNOPSIS + and_expressions() + a expression or NULL + b expression. + org_item Don't modify a if a == *org_item + If a == NULL, org_item is set to point at b, + to ensure that future calls will not modify b. + + NOTES + This will not modify item pointed to by org_item or b + The idea is that one can call this in a loop and create and + 'and' over all items without modifying any of the original items. + + RETURN + NULL Error + Item +*/ + +Item *and_expressions(Item *a, Item *b, Item **org_item) +{ + if (!a) + return (*org_item= (Item*) b); + if (a == *org_item) + { + Item_cond *res; + if ((res= new Item_cond_and(a, (Item*) b))) + res->used_tables_cache= a->used_tables() | b->used_tables(); + return res; + } + if (((Item_cond_and*) a)->add((Item*) b)) + return 0; + ((Item_cond_and*) a)->used_tables_cache|= b->used_tables(); + return a; +} + + longlong Item_func_isnull::val_int() { /* |