• Sergey Glukhov's avatar
    Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL · 3f3318c3
    Sergey Glukhov authored
    There are two problems with ANALYSE():
    
    1. Memory leak 
       it happens because do_select() can overwrite
       JOIN::procedure field(with zero value in our case) and
       JOIN destructor don't free the memory allocated for
       JOIN::procedure. The fix is to save original JOIN::procedure
       before do_select() call and restore it after do_select
       execution.
    
    2. Wrong result
       If ANALYSE() procedure is used for the statement with LIMIT clause
       it could retrun empty result set. It happens because of missing 
       analyse::end_of_records() call. First end_send() function call
       returns NESTED_LOOP_QUERY_LIMIT and second call of end_send() with
       end_of_records flag enabled does not happen. The fix is to return
       NESTED_LOOP_OK from end_send() if procedure is active.
    3f3318c3
analyse.result 7.78 KB