• malff/marcsql@weblab.(none)'s avatar
    Bug#25411 (trigger code truncated), PART I · fc809c70
    malff/marcsql@weblab.(none) authored
    The issue found with bug 25411 is due to the function skip_rear_comments()
    which damages the source code while implementing a work around.
    The root cause of the problem is in the lexical analyser, which does not
    process special comments properly.
    For special comments like :
    [1] aaa /*!50000 bbb */ ccc
    since 5.0 is a version older that the current code, the parser is in lining
    the content of the special comment, so that the query to process is
    [2] aaa bbb ccc
    However, the text of the query captured when processing a stored procedure,
    stored function or trigger (or event in 5.1), can be after rebuilding it:
    [3] aaa bbb */ ccc
    which is wrong.
    
    To fix bug 25411 properly, the lexical analyser needs to return [2] when
    in lining special comments.
    In order to implement this, some preliminary cleanup is required in the code,
    which is implemented by this patch.
    
    Before this change, the structure named LEX (or st_lex) contains attributes
    that belong to lexical analysis, as well as attributes that represents the
    abstract syntax tree (AST) of a statement.
    Creating a new LEX structure for each statements (which makes sense for the
    AST part) also re-initialized the lexical analysis phase each time, which
    is conceptually wrong.
    
    With this patch, the previous st_lex structure has been split in two:
    - st_lex represents the Abstract Syntax Tree for a statement. The name "lex"
    has not been changed to avoid a bigger impact in the code base.
    - class lex_input_stream represents the internal state of the lexical
      analyser, which by definition should *not* be reinitialized when parsing
      multiple statements from the same input stream.
    
    This change is a pre-requisite for bug 25411, since the implementation of
    lex_input_stream will later improve to deal properly with special comments,
    and this processing can not be done with the current implementation of
    sp_head::reset_lex and sp_head::restore_lex, which interfere with the lexer.
    
    This change set alone does not fix bug 25411.
    fc809c70
sql_view.cc 52 KB