1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

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.
This commit is contained in:
unknown
2006-09-07 11:06:37 -07:00
parent a1d03bd632
commit 8716670229
10 changed files with 247 additions and 24 deletions

View File

@ -6593,8 +6593,8 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
SYNOPSIS
build_equal_items_for_cond()
cond condition(expression) where to make replacement
inherited path to all inherited multiple equality items
cond condition(expression) where to make replacement
inherited path to all inherited multiple equality items
DESCRIPTION
At each 'and' level the function detects items for equality predicates
@ -6608,7 +6608,9 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
The function also traverses the cond tree and and for each field reference
sets a pointer to the multiple equality item containing the field, if there
is any. If this multiple equality equates fields to a constant the
function replace the field reference by the constant.
function replaces the field reference by the constant in the cases
when the field is not of a string type or when the field reference is
just an argument of a comparison predicate.
The function also determines the maximum number of members in
equality lists of each Item_cond_and object assigning it to
cond_equal->max_members of this object and updating accordingly
@ -6756,9 +6758,14 @@ static COND *build_equal_items_for_cond(COND *cond,
/*
For each field reference in cond, not from equal item predicates,
set a pointer to the multiple equality it belongs to (if there is any)
as soon the field is not of a string type or the field reference is
an argument of a comparison predicate.
*/
cond= cond->transform(&Item::equal_fields_propagator,
(byte *) inherited);
byte *dummy;
cond= cond->compile(&Item::subst_argument_checker,
&dummy,
&Item::equal_fields_propagator,
(byte *) inherited);
cond->update_used_tables();
}
return cond;