• Dmitry Shulga's avatar
    MDEV-5816: Stored programs: validation of stored program statements · 6840af6e
    Dmitry Shulga authored
    This is the prerequisite patch introducing the class sp_lex_instr
    that encapsulates access to an instance of the class sp_lex_keeper.
    Every SP instruction that need to get access to a LEX object on its
    processing should inherit this class and implement two abstract methods:
      is_invalid(),
      invalidate().
    
    These methods will be used in subsequent patches to implement recompilation of
    SP instructions on failure.
    
    Currently, the following instructions are derived from the class sp_lex_instr:
      sp_instr_stmt,
      sp_instr_set,
      sp_instr_set_trigger_field,
      sp_instr_jump_if_not,
      sp_instr_freturn,
      sp_instr_cpush,
      sp_instr_cursor_copy_struct,
      sp_instr_set_case_expr
    
    Additionally, this patch converts the class sp_instr_opt_meta
    to a base abstract class (that is, not inherited from the class
    sp_instr). Since this class originally was designed to provide a way
    for opimizer to update a destination address for jump SP-instructions,
    the only useful method at the interface of this class is set_destination
    and therefore inheritance from the class sp_instr is meaningless.
    
    Every jump SP instruction now must be inherited directly from
    the class sp_instr_opt_meta and additionally from either the class
    sp_lex_instr or sp_instr depending on whether this SP instruction
    need to get access to a LEX object or not.
    
    Moreover, the class sp_cursor doesn't own a data member of
    the class sp_lex_keeper any more. Instead, the virtual method
    get_lex_keeper() has been added to the class sp_cursor() that
    returns nullptr and this method is overridden in the derived class
    sp_instr_cpush to provide a pointer to a real instance of
    the class sp_lex_keeper. Doing this way we exclude duplication
    of a data member of the type sp_lex_keeper at the class sp_instr_cpush
    since it is derived both from sp_lex_instr and sp_cursor, and sp_lex_instr
    already encapsulates a data member of the class sp_lex_keeper.
    6840af6e
sp_instr.h 28.8 KB