diff options
author | unknown <monty@hundin.mysql.fi> | 2002-11-09 09:51:03 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-11-09 09:51:03 +0200 |
commit | b3a8b8bd193dc9b22b8d5bc28c894c49f6153647 (patch) | |
tree | 50d75360317401d22dd6d4a2f7a6a240f5ef68b0 /sql/item_cmpfunc.cc | |
parent | 34d29fca2d1089ca2468645080a042f1ec1dd6f5 (diff) | |
download | mariadb-git-b3a8b8bd193dc9b22b8d5bc28c894c49f6153647.tar.gz |
Fixed bug in MAX() optimization when used with JOIN and ON expressions
sql/item_cmpfunc.cc:
Create an AND expression from two expressions
sql/item_cmpfunc.h:
Create an AND expression from two 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 bf3c0af1ea6..3cd55934950 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1236,6 +1236,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() { /* |