• unknown's avatar
    Fixed bug #26560. · 6da758c2
    unknown authored
    The flag alias_name_used was not set on for the outer references
    in subqueries. It resulted in replacement of any outer reference
    resolved against an alias for a full field name when the frm 
    representation of a view with a subquery was generated. 
    If the subquery and the outer query referenced the same table in
    their from lists this replacement effectively changed the meaning
    of the view and led to wrong results for selects from this view. 
    
    Modified several functions to ensure setting the right value of
    the alias_name_used flag for outer references resolved against
    aliases.
     
    
    
    mysql-test/r/view.result:
      Added a test case for bug #26560.
    mysql-test/t/view.test:
      Added a test case for bug #26560.
    sql/item.cc:
      Fixed bug #26560.
      Made the function resolve_ref_in_select_and_group analyze the return
      value of the last parameter with the type of the name resolution for
      the submitted reference. If the reference has been resolved against 
      an alias name from select list then its flag alias_name_used is set on.
      Now this value is used in Item_field::fix_outer_field to initialize the flag
      when the item_ref object is created for an outer reference.
      Added a parameter for the second Item_ref::Item_ref constructor to initialize
      properly the flag alias_name_used. The default value of the parameter is FALSE.
      If this flag is set on at the creation of an object by this constructor it
      will never be changed. Corrected appropriately the Item_ref::set_properties
      function.
      The function Item_ref::print now prints alias name for an outer reference
      if the flag alias_name_used is set on.
    sql/item.h:
      Fixed bug #26560.
      Added a parameter for the second Item_ref::Item_ref constructor to initialize
      properly the flag alias_name_used. The default value of the parameter is FALSE.
      A similar change has been applied to the first Item_direct_ref::Item_direct_ref
      constructor.
    sql/mysql_priv.h:
      Fixed bug #26560.
      Added an an enumeration type enum_resolution_type to return info on
      how the function find_item_in_list has resolved the submitted item.
      The type is used only for this function.
    sql/sql_base.cc:
      Fixed bug #26560.
      Made the last parameter of the function find_field_in_tables return
      more detailed information on how the submitted item has been resolved.
      Now it says whether the item has been resolved
        against an alias name,
        or as a field name without alias,
        or as a field name hidden by alias, 
        or was resolved ignoring alias.
    sql/sql_select.cc:
      Fixed bug #26560.
      Took into account the new type of the last parameter of the function
      find_item_in_list.
    6da758c2
mysql_priv.h 66.1 KB