• Ramil Kalimullin's avatar
    Fix for bug#42009: SELECT into variable gives different results to direct SELECT · d615a11b
    Ramil Kalimullin authored
    Problem: storing "SELECT ... INTO @var ..." results in variables we used val_xxx()
    methods which returned results of the current row. 
    So, in some cases (e.g. SELECT DISTINCT, GROUP BY or HAVING) we got data
    from the first row of a new group (where we evaluate a clause) instead of
    data from the last row of the previous group.
    
    Fix: use val_xxx_result() counterparts to get proper results.
    
    
    mysql-test/r/distinct.result:
      Fix for bug#42009: SELECT into variable gives different results to direct SELECT
        - results adjusted.
    mysql-test/r/user_var.result:
      Fix for bug#42009: SELECT into variable gives different results to direct SELECT
        - test result.
    mysql-test/t/user_var.test:
      Fix for bug#42009: SELECT into variable gives different results to direct SELECT
        - test case.
    sql/item_func.cc:
      Fix for bug#42009: SELECT into variable gives different results to direct SELECT
        - Item_func_set_user_var::save_item_result() added to evaluate and store 
          an item's result into a user variable.
    sql/item_func.h:
      Fix for bug#42009: SELECT into variable gives different results to direct SELECT
        - Item_func_set_user_var::save_item_result() added to evaluate and store 
          an item's result into a user variable.
    sql/sql_class.cc:
      Fix for bug#42009: SELECT into variable gives different results to direct SELECT
        - use Item_func_set_user_var::save_item_result() to store results into user 
          variables.
    d615a11b
sql_class.cc 65 KB