summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <gkodinov@dl145s.mysql.com>2006-09-15 11:52:49 +0200
committerunknown <gkodinov@dl145s.mysql.com>2006-09-15 11:52:49 +0200
commite4b044060ca806c3c6a78bc7fc89acf3641f62ad (patch)
treeaf058bb5d99db7c740c4e135bb2137cd924529ff /sql/item_cmpfunc.cc
parenta1c85e65f0615c57f30d3c20fbdaeb60679ff9bb (diff)
parent8fd0cf54983889377cdaaf5b5c7020687c9447a6 (diff)
downloadmariadb-git-e4b044060ca806c3c6a78bc7fc89acf3641f62ad.tar.gz
Merge dl145s.mysql.com:/data/bk/team_tree_merge/CLEAN/mysql-5.0
into dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt sql/item.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/item.h: SCCS merged
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc61
1 files changed, 55 insertions, 6 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 919a23ed65d..db4574411d1 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2747,16 +2747,16 @@ bool Item_cond::walk(Item_processor processor, byte *arg)
SYNOPSIS
transform()
- transformer the transformer callback function to be applied to the nodes
- of the tree of the object
- arg parameter to be passed to the transformer
+ transformer the transformer callback function to be applied to the nodes
+ of the tree of the object
+ arg parameter to be passed to the transformer
DESCRIPTION
- The function recursively applies the transform method with the
- same transformer to each member item of the condition list.
+ The function recursively applies the transform method to each
+ member item of the condition list.
If the call of the method for a member item returns a new item
the old item is substituted for a new one.
- After this the transform method is applied to the root node
+ After this the transformer is applied to the root node
of the Item_cond object.
RETURN VALUES
@@ -2787,6 +2787,55 @@ Item *Item_cond::transform(Item_transformer transformer, byte *arg)
return Item_func::transform(transformer, arg);
}
+
+/*
+ Compile Item_cond object with a processor and a transformer callback functions
+
+ SYNOPSIS
+ compile()
+ analyzer the analyzer callback function to be applied to the nodes
+ of the tree of the object
+ arg_p in/out parameter to be passed to the analyzer
+ transformer the transformer callback function to be applied to the nodes
+ of the tree of the object
+ arg_t parameter to be passed to the transformer
+
+ DESCRIPTION
+ First the function applies the analyzer to the root node of
+ the Item_func object. Then if the analyzer succeeeds (returns TRUE)
+ the function recursively applies the compile method to member
+ item of the condition list.
+ If the call of the method for a member item returns a new item
+ the old item is substituted for a new one.
+ After this the transformer is applied to the root node
+ of the Item_cond object.
+
+ RETURN VALUES
+ Item returned as the result of transformation of the root node
+*/
+
+Item *Item_cond::compile(Item_analyzer analyzer, byte **arg_p,
+ Item_transformer transformer, byte *arg_t)
+{
+ if (!(this->*analyzer)(arg_p))
+ return 0;
+
+ List_iterator<Item> li(list);
+ Item *item;
+ while ((item= li++))
+ {
+ /*
+ The same parameter value of arg_p must be passed
+ to analyze any argument of the condition formula.
+ */
+ byte *arg_v= *arg_p;
+ Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t);
+ if (new_item && new_item != item)
+ li.replace(new_item);
+ }
+ return Item_func::transform(transformer, arg_t);
+}
+
void Item_cond::traverse_cond(Cond_traverser traverser,
void *arg, traverse_order order)
{