Skip to content
  • Roy Lyseng's avatar
    8101f1dc
    Bug#21067109: Assert 'join == __NULL' failed in ::optimize() · 8101f1dc
    Roy Lyseng authored
    Patch # 4 of 5
    
    Currently, optimize_cond() builds multiple equalities for all WHERE
    conditions and all join conditions. But there is one omission: If
    WHERE condition is NULL, then no multiple equalities are built for
    any join conditions.
    
    This patch fixes that problem by the following logic:
    - Invoke optimize_cond() when we have a WHERE condition or an outer join
      (an outer join usually implies at least one join condition).
    - Inside optimize_cond(), call build_equal_items() whenever there is a
      join list (ie this is not called for HAVING).
    - build_equal_items() then inspects the WHERE clause and the various
      join conditions, and analyzes any conditions that are not NULL.
    
    There are several test changes due to this patch. Most changes just
    reverse the order that operands are tested, this is due to the nature
    of multiple equality processing. The more interesting test changes are
    documented below.
    
    Test change in main.subquery_sj_all:
    
     select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10));
    
    Due to multiple equality analysis, a table with REF access is shifted up
    so that it can be evaluated before a table where table scan is applied.
    
     SELECT *
     FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND
     (ot1.a, ot2.a) IN (SELECT it1.a, it2.a
    
    Due to multiple equality analysis, a join condition can be evaluated earlier
    than it used to be.
    
    Test change in main.derived:
    
      SELECT * FROM (SELECT v1.a
                     FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b
                     WHERE v1.a = 3
                     GROUP BY v1.a) p, t q
      WHERE q.id BETWEEN 1 AND 10;
    
    Due to the multiple equality analysis, a "func" ref is changed to a "const",
    which is slightly simpler to evaluate.
    
    Test change in main.join_nested:
    
    Two queries have a WHERE clause moved from third to second table in
    join order.
    
    Test change in main.join_outer:
    
    Comparison against column is replaced with comparison against literal due
    to multiple equality analysis.
    8101f1dc
    Bug#21067109: Assert 'join == __NULL' failed in ::optimize()
    Roy Lyseng authored
    Patch # 4 of 5
    
    Currently, optimize_cond() builds multiple equalities for all WHERE
    conditions and all join conditions. But there is one omission: If
    WHERE condition is NULL, then no multiple equalities are built for
    any join conditions.
    
    This patch fixes that problem by the following logic:
    - Invoke optimize_cond() when we have a WHERE condition or an outer join
      (an outer join usually implies at least one join condition).
    - Inside optimize_cond(), call build_equal_items() whenever there is a
      join list (ie this is not called for HAVING).
    - build_equal_items() then inspects the WHERE clause and the various
      join conditions, and analyzes any conditions that are not NULL.
    
    There are several test changes due to this patch. Most changes just
    reverse the order that operands are tested, this is due to the nature
    of multiple equality processing. The more interesting test changes are
    documented below.
    
    Test change in main.subquery_sj_all:
    
     select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10));
    
    Due to multiple equality analysis, a table with REF access is shifted up
    so that it can be evaluated before a table where table scan is applied.
    
     SELECT *
     FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND
     (ot1.a, ot2.a) IN (SELECT it1.a, it2.a
    
    Due to multiple equality analysis, a join condition can be evaluated earlier
    than it used to be.
    
    Test change in main.derived:
    
      SELECT * FROM (SELECT v1.a
                     FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b
                     WHERE v1.a = 3
                     GROUP BY v1.a) p, t q
      WHERE q.id BETWEEN 1 AND 10;
    
    Due to the multiple equality analysis, a "func" ref is changed to a "const",
    which is slightly simpler to evaluate.
    
    Test change in main.join_nested:
    
    Two queries have a WHERE clause moved from third to second table in
    join order.
    
    Test change in main.join_outer:
    
    Comparison against column is replaced with comparison against literal due
    to multiple equality analysis.
Loading