• unknown's avatar
    Fixed bug#20503: Server crash due to the ORDER clause not taken into account · 4fd71723
    unknown authored
    while space allocation
    
    Under some circumstances DISTINCT clause can be converted to grouping.
    In such cases grouping is performed by all items in the select list.
    If an ORDER clause is present then items from it is prepended to group list.
    But the case with ORDER wasn't taken into account when allocating the
    array for sum functions. This leads to memory corruption and crash.
    
    The JOIN::alloc_func_list() function now allocates additional space if there
    is an ORDER by clause is specified and DISTINCT -> GROUP BY optimization is
    possible.
    
    
    mysql-test/t/select.test:
      Added the test case for bug#20503: Server crash due to the ORDER clause not taken into account while space allocation
    mysql-test/r/select.result:
      Added the test case for bug#20503: Server crash due to the ORDER clause not taken into account while space allocation
    sql/sql_select.cc:
      Fixed bug#20503: Server crash due to the ORDER clause not taken into account
      while space allocation
      The JOIN::alloc_func_list() function now allocates additional space if there
      is an ORDER by clause is specified and DISTINCT -> GROUP BY optimization is
      possible.
    4fd71723
select.result 94.6 KB