summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2010-11-05 14:42:58 +0200
committerunknown <timour@askmonty.org>2010-11-05 14:42:58 +0200
commitbc7369b74b52cde8aa4a74102178838b214c0ee3 (patch)
tree487833e19157a719f37e3cd1cffcabc66c19d61c /sql/item_cmpfunc.cc
parent2dc2098e5989cd92cf6d90b66324c37bc105d5ad (diff)
parent9f2bddbd80fae92840c2db07b75968e816adc213 (diff)
downloadmariadb-git-bc7369b74b52cde8aa4a74102178838b214c0ee3.tar.gz
MWL#89: Cost-based choice between Materialization and IN->EXISTS transformation
Merge 5.3-mwl89 into 5.3 main. There is one remaining test failure in this merge: innodb_mysql_lock2. All other tests have been checked to deliver the same results/explains as 5.3-mwl89, including the few remaining wrong results.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc50
1 files changed, 26 insertions, 24 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 2b331fd4bf3..88bc5707dbe 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1985,6 +1985,18 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, uchar *argument
}
+bool Item_in_optimizer::is_expensive_processor(uchar *arg)
+{
+ return args[1]->is_expensive_processor(arg);
+}
+
+
+bool Item_in_optimizer::is_expensive()
+{
+ return args[1]->is_expensive();
+}
+
+
longlong Item_func_eq::val_int()
{
DBUG_ASSERT(fixed == 1);
@@ -4650,12 +4662,6 @@ Item *and_expressions(Item *a, Item *b, Item **org_item)
longlong Item_func_isnull::val_int()
{
DBUG_ASSERT(fixed == 1);
- /*
- Handle optimization if the argument can't be null
- This has to be here because of the test in update_used_tables().
- */
- if (!used_tables_cache && !with_subselect)
- return cached_value;
return args[0]->is_null() ? 1: 0;
}
@@ -4663,12 +4669,6 @@ longlong Item_is_not_null_test::val_int()
{
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_is_not_null_test::val_int");
- if (!used_tables_cache && !with_subselect)
- {
- owner->was_null|= (!cached_value);
- DBUG_PRINT("info", ("cached: %ld", (long) cached_value));
- DBUG_RETURN(cached_value);
- }
if (args[0]->is_null())
{
DBUG_PRINT("info", ("null"));
@@ -4685,19 +4685,9 @@ longlong Item_is_not_null_test::val_int()
void Item_is_not_null_test::update_used_tables()
{
if (!args[0]->maybe_null)
- {
used_tables_cache= 0; /* is always true */
- cached_value= (longlong) 1;
- }
else
- {
args[0]->update_used_tables();
- if (!(used_tables_cache=args[0]->used_tables()) && !with_subselect)
- {
- /* Remember if the value is always NULL or never NULL */
- cached_value= (longlong) !args[0]->is_null();
- }
- }
}
@@ -5373,7 +5363,7 @@ Item *Item_func_nop_all::neg_transformer(THD *thd)
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
Item_func_not_all *new_item= new Item_func_not_all(args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
- allany->func= allany->func_creator(FALSE);
+ allany->create_comp_func(FALSE);
allany->all= !allany->all;
allany->upper_item= new_item;
return new_item;
@@ -5385,7 +5375,7 @@ Item *Item_func_not_all::neg_transformer(THD *thd)
Item_func_nop_all *new_item= new Item_func_nop_all(args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
allany->all= !allany->all;
- allany->func= allany->func_creator(TRUE);
+ allany->create_comp_func(TRUE);
allany->upper_item= new_item;
return new_item;
}
@@ -5668,6 +5658,9 @@ longlong Item_equal::val_int()
Item_field *item_field;
if (cond_false)
return 0;
+ /* If there is a single constant and no fields, the equality is TRUE. */
+ if (const_item && !fields.elements)
+ return 1;
List_iterator_fast<Item_field> it(fields);
Item *item= const_item ? const_item : it++;
if ((null_value= item->is_null()))
@@ -5688,6 +5681,15 @@ longlong Item_equal::val_int()
void Item_equal::fix_length_and_dec()
{
Item *item= get_first(NULL);
+ if (!item)
+ {
+ /*
+ If there are no fields, there must be at least a constant, in which
+ case Item_equal::val_int evaluates to TRUE.
+ */
+ DBUG_ASSERT(const_item);
+ return;
+ }
eval_item= cmp_item::get_comparator(item->result_type(),
item->collation.collation);
}