• Dmitry Shulga's avatar
    MDEV-20516: Assertion `!lex->proc_list.first && !lex->result &&... · f99d141c
    Dmitry Shulga authored
    MDEV-20516: Assertion `!lex->proc_list.first && !lex->result && !lex->param_list.elements' failed in mysql_create_view
    
    Execution of the CREATE VIEW statement sent via binary protocol
    where the flags of the COM_STMT_EXECUTE request a cursor to be opened
    before running the statement results in an assert failure.
    
    This assert fails since the data member thd->lex->result has not null
    value pointing to an instance of the class Select_materialize.
    The data member thd->lex->result is assigned a pointer to the class
    Select_materialize in the function mysql_open_cursor() that invoked
    in case the packet COM_STMT_EXECUTE requests a cursor to be opened.
    
    After thd->lex->result is assigned a pointer to an instance of the
    class Select_materialize the function mysql_create_view() is called
    (indirectly via the function mysql_execute_statement()) and the assert
    fails.
    
    The assert
      DBUG_ASSERT(!lex->proc_list.first && !lex->result &&
                  !lex->param_list.elements);
    
    was added by the commit 591c06d4.
    Unfortunately , the condition
      !lex->result
    was specified incorrect. It was supposed that the thd->lex->result
    is set only by parser on handling the clauses SELECT ... INTO
    but indeed it is also set inside mysql_open_cursor() and
    that fact was missed by the assert's condition.
    
    So, the fix for this issue is to just remove the condition
      !lex->result
    from the failing assert.
    f99d141c
sql_view.cc 67.4 KB