• unknown's avatar
    Bug#34587 Creating a view inside a stored procedure leads to a server crash · 58b8295b
    unknown authored
    The problem is that when a stored procedure is being parsed for
    the first execution, the body is copied to a temporary buffer
    which is disregarded sometime after the statement is parsed.
    And during this parsing phase, the rule for CREATE VIEW was
    holding a reference to the string being parsed for use during
    the execution of the CREATE VIEW statement, leading to invalid
    memory access later.
    
    The solution is to allocate and copy the SELECT of a CREATE
    VIEW statement using the thread memory root, which is set to
    the permanent arena of the stored procedure. 
    
    
    mysql-test/r/view.result:
      Add test case result for Bug#34587
    mysql-test/t/view.test:
      Add test case for Bug#34587
    sql/sql_lex.h:
      Remove start and end position variables. The SELECT of a
      CREATE VIEW is now allocated at parse time.
    sql/sql_view.cc:
      Remove assertion that is not true when the statement is
      being re-executed. Use string that was trimmed of leading
      and trailing whitespace at parse time.
    sql/sql_yacc.yy:
      Allocate the SELECT of a CREATE VIEW using the current thread
      memory root and remove any leading and trailing whitespace.
    58b8295b
sql_lex.h 55.6 KB