summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-08-29 23:14:46 +0300
committerunknown <bell@sanja.is.com.ua>2004-08-29 23:14:46 +0300
commitf45c482aa9a546ca6ad0f258aa0a8358522f5c2f (patch)
tree15e9f105403916895459b6c2b74f5c03ab99f91c
parentebf4ce0501486f5eba7b69fe77fb1c49bbd22763 (diff)
downloadmariadb-git-f45c482aa9a546ca6ad0f258aa0a8358522f5c2f.tar.gz
NOT elimination moved in parsing (suggested by Monty)
sql/item_cmpfunc.cc: NOT elimination moved in parsing (we do not need fix fields in it and PS processing) sql/item_cmpfunc.h: NOT elimination moved in parsing (we do not need fix fields in it and PS processing) sql/sql_select.cc: NOT elimination moved in parsing (we do not need fix fields in it and PS processing) sql/sql_yacc.yy: NOT elimination moved in parsing
-rw-r--r--sql/item_cmpfunc.cc33
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/sql_select.cc13
-rw-r--r--sql/sql_yacc.yy12
4 files changed, 11 insertions, 49 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index bf7813eb9ba..de37e858bac 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2030,15 +2030,6 @@ void Item_cond::neg_arguments(THD *thd)
{
if (!(new_item= new Item_func_not(item)))
return; // Fatal OEM error
- /*
- We can use 0 as tables list because Item_func_not do not use it
- on fix_fields and its arguments are already fixed.
-
- We do not check results of fix_fields, because there are not way
- to return error in this functions interface, thd->net.report_error
- will be checked on upper level call.
- */
- new_item->fix_fields(thd, 0, &new_item);
}
VOID(li.replace(new_item));
}
@@ -2734,18 +2725,6 @@ Item *Item_func_not::neg_transformer(THD *thd) /* NOT(x) -> x */
Item *Item_bool_rowready_func2::neg_transformer(THD *thd)
{
Item *item= negated_item();
- if (item)
- {
- /*
- We can use 0 as tables list because Item_func* family do not use it
- on fix_fields and its arguments are already fixed.
-
- We do not check results of fix_fields, because there are not way
- to return error in this functions interface, thd->net.report_error
- will be checked on upper level call.
- */
- item->fix_fields(thd, 0, &item);
- }
return item;
}
@@ -2754,9 +2733,6 @@ Item *Item_bool_rowready_func2::neg_transformer(THD *thd)
Item *Item_func_isnull::neg_transformer(THD *thd)
{
Item *item= new Item_func_isnotnull(args[0]);
- // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
- if (item)
- item->fix_fields(thd, 0, &item);
return item;
}
@@ -2765,9 +2741,6 @@ Item *Item_func_isnull::neg_transformer(THD *thd)
Item *Item_func_isnotnull::neg_transformer(THD *thd)
{
Item *item= new Item_func_isnull(args[0]);
- // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
- if (item)
- item->fix_fields(thd, 0, &item);
return item;
}
@@ -2777,9 +2750,6 @@ Item *Item_cond_and::neg_transformer(THD *thd) /* NOT(a AND b AND ...) -> */
{
neg_arguments(thd);
Item *item= new Item_cond_or(list);
- // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
- if (item)
- item->fix_fields(thd, 0, &item);
return item;
}
@@ -2789,9 +2759,6 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
{
neg_arguments(thd);
Item *item= new Item_cond_and(list);
- // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
- if (item)
- item->fix_fields(thd, 0, &item);
return item;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 4f2dcb6a412..c3551b35d63 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -274,7 +274,7 @@ public:
enum Functype rev_functype() const { return EQUAL_FUNC; }
cond_result eq_cmp_result() const { return COND_TRUE; }
const char *func_name() const { return "<=>"; }
- Item* neg_transformer(THD *thd) { return 0; }
+ Item *neg_transformer(THD *thd) { return 0; }
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4ca8008c518..701d2597d3d 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4401,19 +4401,6 @@ optimize_cond(THD *thd, COND *conds, Item::cond_result *cond_value)
if (conds)
{
DBUG_EXECUTE("where", print_where(conds, "original"););
- /* Eliminate NOT operators; in case of PS/SP do it once */
- if (thd->current_arena->is_first_stmt_execute())
- {
- Item_arena *arena= thd->current_arena, backup;
- thd->set_n_backup_item_arena(arena, &backup);
- conds= eliminate_not_funcs(thd, conds);
- select->prep_where= conds->copy_andor_structure(thd);
- thd->restore_backup_item_arena(arena, &backup);
- }
- else
- conds= eliminate_not_funcs(thd, conds);
- DBUG_EXECUTE("where", print_where(conds, "after negation elimination"););
-
/* change field = field to field = const for each found field = const */
propagate_cond_constants((I_List<COND_CMP> *) 0, conds, conds);
/*
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 1c057e03a11..afb55463ad1 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2755,8 +2755,16 @@ simple_expr:
| '+' expr %prec NEG { $$= $2; }
| '-' expr %prec NEG { $$= new Item_func_neg($2); }
| '~' expr %prec NEG { $$= new Item_func_bit_neg($2); }
- | NOT expr %prec NEG { $$= new Item_func_not($2); }
- | '!' expr %prec NEG { $$= new Item_func_not($2); }
+ | NOT expr %prec NEG
+ {
+ if (($$= $2->neg_transformer(YYTHD)) == 0)
+ $$= new Item_func_not($2);
+ }
+ | '!' expr %prec NEG
+ {
+ if (($$= $2->neg_transformer(YYTHD)) == 0)
+ $$= new Item_func_not($2);
+ }
| '(' expr ')' { $$= $2; }
| '(' expr ',' expr_list ')'
{