• Sergey Petrunia's avatar
    MWL#17: Table elimination · fd485ad9
    Sergey Petrunia authored
    - Make elimination work with aggregate functions. The problem was that aggregate functions 
      reported all table bits in used_tables(), and that prevented table elimination. Fixed by 
      making aggregate functions return more correct value from used_tables(). 
    
    mysql-test/r/ps_11bugs.result:
      MWL#17: Table elimination
      - Update test results. The difference is because of Item_ref change: outer references to constants
        are now recognized as constants, too.
    mysql-test/r/subselect.result:
      - Update test results. The difference is because of Item_ref change: outer references to constants
        are now recognized as constants, too.
    mysql-test/r/table_elim.result:
      MWL#17: Table elimination
      - Check that elimination works in presense of aggreagate functions
    mysql-test/t/table_elim.test:
      MWL#17: Table elimination
      - Check that elimination works in presense of aggreagate functions
    sql/item.h:
      MWL#17: Table elimination
      - Add Item_ref::const_item() which calls (*ref)->const_item(). Before this diff Item_ref used the 
        default implementation of const_item(){ return used_tables()==0; }. This is no longer true, as 
        COUNT(*) now has used_tables()==0 but const_item()==FALSE.
    sql/item_sum.cc:
      MWL#17: Table elimination
      - Make Item_sum() and it descendants not to return all bits in used_tables(). This is needed 
        because otherwise table elimination can't work in presense of aggregate functions
      - COUNT(*) now has used_tables()==0 and const_item()==FALSE. Had to change 
        Item_ref::const_item() to account for this.
    sql/item_sum.h:
      MWL#17: Table elimination
      - Add comments
    fd485ad9
ps_11bugs.result 5.91 KB