1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

after review patch

mysql-test/r/negation_elimination.result:
  new tests of negation elimination
mysql-test/t/negation_elimination.test:
  new tests of negation elimination
sql/item.h:
  test of boolean functions added
sql/item_cmpfunc.cc:
  NOT subtree is already checked, so wee need to return just argument
sql/item_cmpfunc.h:
  test of boolean functions added
sql/mysql_priv.h:
  'place' to detect WHERE clause
sql/sql_parse.cc:
  function for creation negated expression
sql/sql_select.cc:
  removed unused function
sql/sql_select.h:
  removed unused function
sql/sql_yacc.yy:
  'place' to detect WHERE clause
This commit is contained in:
unknown
2004-08-31 21:10:57 +03:00
parent f45c482aa9
commit 1dc52f0763
10 changed files with 74 additions and 70 deletions

View File

@@ -4339,60 +4339,6 @@ propagate_cond_constants(I_List<COND_CMP> *save_list,COND *and_father,
}
/*
Eliminate NOT functions from the condition tree.
SYNPOSIS
eliminate_not_funcs()
thd thread handler
cond condition tree
DESCRIPTION
Eliminate NOT functions from the condition tree where it's possible.
Recursively traverse condition tree to find all NOT functions.
Call neg_transformer() method for negated arguments.
NOTE
If neg_transformer() returned a new condition we call fix_fields().
We don't delete any items as it's not needed. They will be deleted
later at once.
RETURN
New condition tree
*/
COND *eliminate_not_funcs(THD *thd, COND *cond)
{
if (!cond)
return cond;
if (cond->type() == Item::COND_ITEM) /* OR or AND */
{
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item= li++))
{
Item *new_item= eliminate_not_funcs(thd, item);
if (item != new_item)
VOID(li.replace(new_item)); /* replace item with a new condition */
}
}
else if (cond->type() == Item::FUNC_ITEM && /* 'NOT' operation? */
((Item_func*) cond)->functype() == Item_func::NOT_FUNC)
{
COND *new_cond= ((Item_func*) cond)->arguments()[0]->neg_transformer(thd);
if (new_cond)
{
/*
Here we can delete the NOT function. Something like: delete cond;
But we don't need to do it. All items will be deleted later at once.
*/
cond= new_cond;
}
}
return cond;
}
static COND *
optimize_cond(THD *thd, COND *conds, Item::cond_result *cond_value)
{