• Rex's avatar
    MDEV-32829 Crash when executing PS for query with eliminated subquery using view · 32c68497
    Rex authored
    Statements affected by this bug have all the following
    1) select statements with a sub-query
    2) that sub-query includes a group-by clause
    3) that group-by clause contains an expression
    4) that expression has a reference to view
    
    When a view is used in a group by expression, and that group by can be
    eliminated in a sub-query simplification as part of and outer condition
    that could be in, exists, > or <, then the table structure left behind
    will have a unit that contains a null select_lex pointer.
    
    If this happens as part of a prepared statement, or execute in a stored
    procedure for the second time, then, when the statement is executed, the table
    list entry for that, now eliminated, view is "opened" and "reinit"ialized.
    This table entry's unit no longer has a select_lex pointer.
    Prior to MDEV-31995 this was of little consequence, but now following this
    null pointer will cause a crash.
    
    Reviewed by Igor Babaev (igor@mariadb.com)
    32c68497
derived_view.result 150 KB