• unknown's avatar
    Bug#16218 - Crash on insert delayed · ab5ebc0f
    unknown authored
    Bug#17294 - INSERT DELAYED puting an \n before data
    Bug#16611 - INSERT DELAYED corrupts data
    Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
    Combined as Bug#16218.
    
    INSERT DELAYED crashed in 5.0 on a table with a varchar that 
    could be NULL and was created pre-5.0 (Bugs 16218 and 13707).
    INSERT DELAYED corrupted data in 5.0 on a table with varchar 
    fields that was created pre-5.0 (Bugs 17294 and 16611).
    
    In case of INSERT DELAYED the open table is copied from the
    delayed insert thread to be able to create a record for the 
    queue. When copying the fields, a method was used that did 
    convert old varchar to new varchar fields and did not set up 
    some pointers into the record buffer of the table.
    
    The field conversion was guilty for the misinterpretation of 
    the record contents by the delayed insert thread. The wrong
    pointer setup was guilty for the crashes.
    
    For Bug 13707 (Server crash with INSERT DELAYED on MyISAM table)
    I fixed the above mentioned method to set up one of the pointers.
    For Bug 16218 I set up the other pointers too.
    
    But when looking at the corruptions I got aware that converting
    the field type was totally wrong for INSERT DELAYED. The copied
    table is used to create a record that is to be sent to the
    delayed insert thread. Of course it can interpret the record
    correctly only if all field types are the same in both table
    objects.
    
    So I revoked the fix for Bug 13707 and changed the new_field() 
    method so that it can suppress conversions.
    
    No test case as this is a migration problem. One needs to
    create a table with 4.x and use it with 5.x. I added two
    test scripts to the bug report.
    
    
    sql/field.cc:
      Bug#16218 - Crash on insert delayed
      Bug#17294 - INSERT DELAYED puting an \n before data
      Bug#16611 - INSERT DELAYED corrupts data
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      Added parameter 'keep_type' to Field::new_field().
      
      Undid the change from Bug 13707 (Server crash with INSERT 
      DELAYED on MyISAM table).
      I solved all four bugs in sql/sql_insert.cc by making exact
      duplicates of the fields. The new_field() method converts
      certain field types, which is wrong for INSERT DELAYED.
    sql/field.h:
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      Added parameter 'keep_type' to Field::new_field().
    sql/sql_insert.cc:
      Bug#16218 - Crash on insert delayed
      Bug#17294 - INSERT DELAYED puting an \n before data
      Bug#16611 - INSERT DELAYED corrupts data
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      Added comments. Made small style fixes.
      Used the new parameter 'keep_type' of Field::new_field()
      to avoid field type conversion. The table copy must have
      exactly the same types of fields as the original table.
      Otherwise the record contents created by the foreground 
      thread could be misinterpreted by the delayed insert thread.
    sql/sql_select.cc:
      Bug#16218 - Crash on insert delayed
      Bug#17294 - INSERT DELAYED puting an \n before data
      Bug#16611 - INSERT DELAYED corrupts data
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      Added parameter 'keep_type' to Field::new_field().
      
      Undid the change from Bug 13707 (Server crash with INSERT 
      DELAYED on MyISAM table).
      I solved all four bugs in sql/sql_insert.cc by making exact
      duplicates of the fields. The new_field() method converts
      certain field types, which is wrong for INSERT DELAYED.
    sql/sql_trigger.cc:
      Bug#16218 - Crash on insert delayed
      Bug#17294 - INSERT DELAYED puting an \n before data
      Bug#16611 - INSERT DELAYED corrupts data
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      Added parameter 'keep_type' to Field::new_field().
      
      Undid the change from Bug 13707 (Server crash with INSERT 
      DELAYED on MyISAM table).
      I solved all four bugs in sql/sql_insert.cc by making exact
      duplicates of the fields. The new_field() method converts
      certain field types, which is wrong for INSERT DELAYED.
    sql/table.cc:
      Bug#16218 - Crash on insert delayed
      Bug#17294 - INSERT DELAYED puting an \n before data
      Bug#16611 - INSERT DELAYED corrupts data
      Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
      Combined as Bug#16218.
      
      Added parameter 'keep_type' to Field::new_field().
      
      Undid the change from Bug 13707 (Server crash with INSERT 
      DELAYED on MyISAM table).
      I solved all four bugs in sql/sql_insert.cc by making exact
      duplicates of the fields. The new_field() method converts
      certain field types, which is wrong for INSERT DELAYED.
    ab5ebc0f
sql_select.cc 448 KB