diff options
author | Igor Babaev <igor@askmonty.org> | 2011-05-19 18:28:38 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-05-19 18:28:38 -0700 |
commit | 016a09cb7d40236c3530ae4c5c4815072aa8dacb (patch) | |
tree | 84f543c79596e3b48a96f3cc344ec02dc6bce829 /sql/item_func.cc | |
parent | 20c9084deb6075f675ebabc5fd073f8ff93130e2 (diff) | |
download | mariadb-git-016a09cb7d40236c3530ae4c5c4815072aa8dacb.tar.gz |
Fixed LP bug #777745.
Fields belonging to views in general cannot be substituted for
equal items, in particular for constants, because all references
to a view field refer to the same Item_field object while they
could be used in different OR parts of the where condition and
belong to different equivalence classes (to different Item_equals).
That's why substitution for equal items in any context is allowed
only in place of Item_direct_view_ref objects, but not in place of
Item_fields these objects refer to.
Due to some erroneous code in the patch for bug 717577 substitution
for view fields were allowed in some context.This could lead
to wrong results returned by queries using views.
The fix prohibits substitution of view fields for equal items
in any context.
The patch also changes slightly the compile method for the Item_func
class. Now if the analyze method returns NULL in his parameter the
compile method is not called for the arguments of the function
at all. A similar change was made for the Item_ref class.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 63b8419aaaa..f345c2f29df 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -352,6 +352,8 @@ Item *Item_func::transform(Item_transformer transformer, uchar *argument) the old item is substituted for a new one. After this the transformer is applied to the root node of the Item_func object. + The compile function is not called if the analyzer returns NULL + in the parameter arg_p. @param analyzer the analyzer callback function to be applied to the nodes of the tree of the object @@ -369,7 +371,7 @@ Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p, { if (!(this->*analyzer)(arg_p)) return 0; - if (arg_count) + if (*arg_p && arg_count) { Item **arg,**arg_end; for (arg= args, arg_end= args+arg_count; arg != arg_end; arg++) @@ -377,7 +379,7 @@ Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p, /* The same parameter value of arg_p must be passed to analyze any argument of the condition formula. - */ + */ uchar *arg_v= *arg_p; Item *new_item= (*arg)->compile(analyzer, &arg_v, transformer, arg_t); if (new_item && *arg != new_item) |