• Alexander Barkov's avatar
    MDEV-16311 Server crash when using a NAME_CONST() with a CURSOR · 23ced2f8
    Alexander Barkov authored
    Problem:
    The problem was most likely introduced by a fix for MDEV-11597
    (commit 5f0c31f9) which removed
    the assignment "killed= KILL_BAD_DATA" from THD::raise_condition().
    
    Before MDEV-11597, sp_head::execute() tested thd->killed after
    looping through the SP instructions and exited with an error
    if thd->killed is set. After MDEV-11597, sp_head::execute()
    stopped to notice errors and set the OK status on top of the
    error status, which crashed on assert.
    
    Fix:
    Making sp_cursor::fetch() return -1 if server_side_cursor->fetch(1)
    left an error in the diagnostics area. This makes the statement
    "err_status= i->execute(thd, &ip)" in sp_head::execute() set the
    error code and correctly break the SP instruction loop and
    return on error without setting the OK status.
    23ced2f8
sp_rcontext.cc 14.5 KB