• Martin Hansson's avatar
    · 543885d1
    Martin Hansson authored
    Bug#44653: Server crash noticed when executing random queries with partitions.
    
    When opening a table, it is imperative that the flag
    TABLE::auto_increment_field_not_null be false. But if an error occured during
    the creation of a table (e.g. the table exists already) with an auto_increment
    column and a BEFORE trigger that used the INSERT ... SELECT construct, the
    flag was not reset until after error checking. Thus if an error occured,
    select_insert::send_data() returned immediately and it was not reset (see * in
    pseudocode below).  Crash happened if the table was opened again. Fixed by
    resetting the flag after error checking.
    
    nested-loops_join():
      for each row in SELECT table {
        select_insert::send_data():
          if a values is supplied for AUTO_INCREMENT column
             table->auto_increment_field_not_null= TRUE
           else
             table->auto_increment_field_not_null= FALSE
           if (error)
             return 1; *
           if (table->auto_increment_field_not_null == FALSE)
             ...
           table->auto_increment_field_not_null == FALSE 
      }
    <-- table returned to table cache and later retrieved by open_table: 
    open_table():
      assert(table->auto_increment_field_not_null)
    
    
    mysql-test/r/trigger.result:
      Bug#44653: Test result
    mysql-test/t/trigger.test:
      Bug#44653: Test case
    sql/sql_insert.cc:
      Bug#44653: Fix: Make sure to unset this field before returning in case of error
    543885d1
sql_insert.cc 124 KB