• Igor Babaev's avatar
    MDEV-22846 Server crashes in handler_index_cond_check on SELECT · 8265d6d9
    Igor Babaev authored
    If the optimizer decides to rewrites a NOT IN predicand of the form
      outer_expr IN (SELECT inner_col FROM ... WHERE subquery_where)
    into the EXISTS subquery
      EXISTS (SELECT 1 FROM ... WHERE subquery_where AND
            (outer_expr=inner_col OR inner_col IS NULL))
    then the pushed equality predicate outer_expr=inner_col can be used for
    ref[or_null] access if inner_col is a reference to an indexed column.
    In this case if there is a selective range condition over this column then
    a Rowid filter may be employed coupled the with ref[or_null] access. The
    filter is 'pushed' into the engine and in InnoDB currently it cannot be
    used with index look-ups by primary key. The ref[or_null] access can be
    used only when outer_expr is not NULL. Otherwise the original predicand
    is evaluated to TRUE only if the result set returned by the query
     SELECT 1 FROM ... WHERE subquery_where
    is empty. When performing this evaluation the executor switches to the
    table scan by primary key. Before this patch the pushed filter still
    remained marked as active and the engine tried to apply the filter. This
    was incorrect and in InnoDB this attempt to use the filter led to an
    assertion failure.
    
    This patch fixes the problem by disabling usage of the filter when
    outer_expr is evaluated to NULL.
    8265d6d9
item_subselect.cc 199 KB