• unknown's avatar
    Fix for BUG#13410 - qualified reference to a view column in the HAVING clause cannot be resolved. · 58263844
    unknown authored
    The problem was then when a column reference was resolved to a view column, the new Item
    created for this column contained the name of the view, and not the view alias.
    
    
    mysql-test/r/view.result:
      Additional test for BUG#13410.
    mysql-test/t/view.test:
      Additional test for BUG#13410.
    sql/item.cc:
      Correctly cast 'cur_field' to Item_ident because if the original item is
      an Item_field, the cur_field is either an Item_field or an Item_ref.
      Thus we have to cast cur_field to a common super-class of both.
    sql/item.h:
      - real_item() may be called before Item_ref::ref is set
        (i.e. the Item_ref object was resolved).
      - To avoid a crash and to return some meaningful value
        in such cases we return 'this'.
    sql/sql_base.cc:
      - 'item' may be an Item_ref, so we test for the type of the actual
        referenced item.
      - Correctly cast 'cur_field' to Item_ident because if the original
        item is an Item_field, the cur_field is either an Item_field or an
        Item_ref. Thus we have to cast cur_field to a common super-class
        of both.
    sql/table.cc:
      - When creating a new Item for a reference to a view column, use the view alias,
        and not the real view name.
      - Removed old code
    58263844
item.cc 156 KB