Skip to content
  • Norvald H. Ryeng's avatar
    835e0721
    Bug#13801019 ASSERTION `0' FAILED IN CREATE_MYISAM_TMP_TABLE · 835e0721
    Norvald H. Ryeng authored
    Problem: JOIN::exec() tries to create temporary tables for derived
    tables that the optimizer has decided to treat as constant tables.
    
    Consider the query from the test case:
    
    SELECT *
    FROM (SELECT * FROM t1) AS a1
      RIGHT JOIN t3
      LEFT JOIN t2 ON d=c ON a=c;
    
    The optimizer first decides to materialize a1. In
    make_join_statistics() it calls update_ref_and_keys() to identify all
    possible keys for the table. Later on, make_join_statistics()
    discovers that the join conditions are impossible and tags a1 as a
    constant table returning only NULL values. Unused keys are supposed to
    be removed later on by JOIN::drop_unused_derived_keys(), but since a1
    has been marked as a constant table, it is ignored and all the
    possible keys are left.
    
    At the start of query execution, JOIN::prepare_result() calls
    st_select_lex::handle_derived() to create the necessary temporary
    tables. When it tries to create a temporary table for a1, the attempt
    triggers an assertion in create_myisam_tmp_table() since it tries to
    create a temporary table with more than one key.
    
    Fix: Check that a derived table is not marked as constant before
    creating a temporary table for it.
    835e0721
    Bug#13801019 ASSERTION `0' FAILED IN CREATE_MYISAM_TMP_TABLE
    Norvald H. Ryeng authored
    Problem: JOIN::exec() tries to create temporary tables for derived
    tables that the optimizer has decided to treat as constant tables.
    
    Consider the query from the test case:
    
    SELECT *
    FROM (SELECT * FROM t1) AS a1
      RIGHT JOIN t3
      LEFT JOIN t2 ON d=c ON a=c;
    
    The optimizer first decides to materialize a1. In
    make_join_statistics() it calls update_ref_and_keys() to identify all
    possible keys for the table. Later on, make_join_statistics()
    discovers that the join conditions are impossible and tags a1 as a
    constant table returning only NULL values. Unused keys are supposed to
    be removed later on by JOIN::drop_unused_derived_keys(), but since a1
    has been marked as a constant table, it is ignored and all the
    possible keys are left.
    
    At the start of query execution, JOIN::prepare_result() calls
    st_select_lex::handle_derived() to create the necessary temporary
    tables. When it tries to create a temporary table for a1, the attempt
    triggers an assertion in create_myisam_tmp_table() since it tries to
    create a temporary table with more than one key.
    
    Fix: Check that a derived table is not marked as constant before
    creating a temporary table for it.
Loading