summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-05-19 18:28:38 -0700
committerIgor Babaev <igor@askmonty.org>2011-05-19 18:28:38 -0700
commit016a09cb7d40236c3530ae4c5c4815072aa8dacb (patch)
tree84f543c79596e3b48a96f3cc344ec02dc6bce829 /sql/item_func.h
parent20c9084deb6075f675ebabc5fd073f8ff93130e2 (diff)
downloadmariadb-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.h')
-rw-r--r--sql/item_func.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 5c5ea33f247..0ddf4acf035 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -251,6 +251,21 @@ public:
}
/*
+ By default only substitution for a field whose two different values
+ are never equal is allowed in the arguments of a function.
+ This is overruled for the direct arguments of comparison functions.
+ */
+ bool subst_argument_checker(uchar **arg)
+ {
+ if (*arg)
+ {
+ *arg= (uchar *) Item::IDENTITY_SUBST;
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ /*
We assume the result of any function that has a TIMESTAMP argument to be
timezone-dependent, since a TIMESTAMP value in both numeric and string
contexts is interpreted according to the current timezone.