• Davi Arnaut's avatar
    Bug#47627 SET @@{global.session}.local_variable in stored routine causes crash · 4beeb3fa
    Davi Arnaut authored
    This patch borrows ideas, text and code from Kristofer
    Pettersson's patch.
    
    An assignment of a system variable sharing the same base
    name as a declared stored procedure variable in the same
    context could lead to a crash.
    
    The reason was that during the parsing of the syntactic
    rule 'option_value' an uninitialized set_var object was
    pushed to the parameter stack of the SET statement. The
    parent rule 'option_type_value' interpreted the existence
    of variables on the parameter stack as an assignment and
    wrapped it in a sp_instr_set object.
    
    As the procedure later was executed an attempt was made
    to run the method 'check()' on an uninitialized member
    object (NULL value) belonging to the previously created
    but uninitialized object.
    
    This patch refactors the 'internal_variable_name' rule and
    copies the semantic analysis part to the depending parent
    rule: 'option_value'. This makes it possible to account
    for any prefixes affecting the interpretation of the
    internal_variable_name.
    4beeb3fa
sql_yacc.yy 402 KB