• malff/marcsql@weblab.(none)'s avatar
    Bug#8153 (Stored procedure with subquery and continue handler, wrong result) · 21f00113
    malff/marcsql@weblab.(none) authored
    Before this fix,
    - a runtime error in a statement in a stored procedure with no error handlers
    was properly detected (as expected)
    - a runtime error in a statement with an error handler inherited from a non
    local runtime context (i.e., proc a with a handler, calling proc b) was
    properly detected (as expected)
    - a runtime error in a statement with a *local* error handler was executed
    as follows :
    a) the statement would succeed, regardless of the error condition, (bug)
    b) the error handler would be called (as expected).
    
    The root cause is that functions like my_messqge_sql would "forget" to set
    the thread flag thd->net.report_error to 1, because of the check involving
    sp_rcontext::found_handler_here().
    Failure to set this flag would cause, later in the call stack,
    in Item_func::fix_fields() at line 190, the code to return FALSE and consider
    that executing the statement was successful.
    
    With this fix :
    - error handling code, that was duplicated in different places in the code,
    is now implemented in sp_rcontext::handle_error(),
    - handle_error() correctly sets thd->net.report_error when a handler is
    present, regardless of the handler location (local, or in the call stack).
    
    A test case, bug8153_subselect, has been written to demonstrate the change
    of behavior before and after the fix.
    
    Another test case, bug8153_function_a, as also been writen.
    This test has the same behavior before and after the fix.
    This test has been written to demonstrate that the previous expected
    result of procedure bug18787, was incorrect, since select no_such_function()
    should fail and therefore not produce a result.
    
    The incorrect result for bug18787 has the same root cause as Bug#8153,
    and the expected result has been adjusted.
    21f00113
sql_error.cc 7.3 KB