diff options
author | unknown <igor@rurik.mysql.com> | 2006-09-07 11:06:37 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2006-09-07 11:06:37 -0700 |
commit | 87166702295a95036698a0ef1cda51be76666e90 (patch) | |
tree | b1bdc6b4045f15b19a43e57ecd9fe14212f34de5 /sql/item.cc | |
parent | a1d03bd6321d4db38006140d3113f819bb34a83c (diff) | |
download | mariadb-git-87166702295a95036698a0ef1cda51be76666e90.tar.gz |
Fixed bug #21698: erroneously a field could be replaced by an
equal constant under any circumstances.
In fact this substitution can be allowed if the field is
not of a type string or if the field reference serves as
an argument of a comparison predicate.
mysql-test/r/func_str.result:
Added test cases for bug #21698.
mysql-test/r/heap_hash.result:
Adjusted results after the fix for bug #21198.
mysql-test/t/func_str.test:
Added test cases for bug #21698.
sql/item.cc:
Fixed bug #21198.
Added a method to check whether a field reference can be
substituted for a constant equal to the field.
This substitution is allowed if the field is not of a type string
or if the field reference serves as an argument of a comparison
predicate.
sql/item.h:
Fixed bug #21698.
Added a new virtual transformation method for a item 'compile'
with two callback function parameters.
Added a new virtual method 'subst_argument_checker' to be used
as an amnalyzer method.
This method is supposed to set its in/out argument to NULL for
the nodes where substitution of a string field for a constant
is not valid.
sql/item_cmpfunc.cc:
Fixed bug #21698.
Added an implementation of the compile method for class Item_cond.
First it processes the Item_cond node with a callback function and if
the latter returns TRUE it proceeds with a transformation performed by
another callback function.
sql/item_cmpfunc.h:
Fixed bug #21698.
Added the implementations of 'subst_argument_checker'
for the Item_func and Item_cond classes.
This method is supposed to set its in/out argument to NULL for
the nodes where substitution of a string field for a constant
is not valid.
Added the declaration of an implementation of the compile method for
class Item_cond.
First it processes the Item_cond node with a callback function and if
the latter returns TRUE it proceeds with a transformation performed by
another callback function.
sql/item_func.cc:
Fixed bug #21698.
Added an implementation of the compile method for class Item_func.
First it processes the Item_func node with a callback function and if
the latter returns TRUE it proceeds with a transformation performed by
another callback function.
sql/item_func.h:
Fixed bug #21698.
Added the declaration of the implementation of the compile method for
class Item_func.
First it processes the Item_func node with a callback function and if
the latter returns TRUE it proceeds with a transformation performed by
another callback function.
sql/sql_select.cc:
Fixed bug #21698.
Limited the conditions at which a field can be substituted
a for an equal constant in a formula.
This substitution is allowed if the field is not of a type string
or if the field reference serves as an argument of a comparison
predicate.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/sql/item.cc b/sql/item.cc index 96b20d0f0bb..c3b950bc32b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3746,13 +3746,48 @@ Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal) /* + Check whether a field can be substituted by an equal item + + SYNOPSIS + equal_fields_propagator() + arg - *arg != NULL <-> the field is in the context where + substitution for an equal item is valid + + DESCRIPTION + The function checks whether a substitution of the field + occurrence for an equal item is valid. + + NOTES + The following statement is not always true: + x=y => F(x)=F(x/y). + This means substitution of an item for an equal item not always + yields an equavalent condition. + Here's an example: + 'a'='a ' + (LENGTH('a')=1) != (LENGTH('a ')=2) + Such a substitution is surely valid if either the substituted + field is not of a STRING type or if it is an argument of + a comparison predicate. + + RETURN + TRUE substitution is valid + FALSE otherwise +*/ + +bool Item_field::subst_argument_checker(byte **arg) +{ + return (result_type() != STRING_RESULT) || (*arg); +} + + +/* Set a pointer to the multiple equality the field reference belongs to (if any) SYNOPSIS equal_fields_propagator() - arg - reference to list of multiple equalities where - the field (this object) is to be looked for + arg - reference to list of multiple equalities where + the field (this object) is to be looked for DESCRIPTION The function looks for a multiple equality containing the field item @@ -3764,7 +3799,7 @@ Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal) NOTES This function is supposed to be called as a callback parameter in calls - of the transform method. + of the compile method. RETURN VALUES pointer to the replacing constant item, if the field item was substituted |