Details
Description
See MySQL's Bug#34660.
The fix isn't quite complete, the crash can occur even without subqueries. Doing
INSERT IGNORE ... SELECT ...
and imitating a failure in JOIN::optimize (forcing table->file->print_error() in make_join_statistics),
the error status is properly returned all the way up to mysql_parse, but the error packet is not sent
(see my_message_sql() in 5.3) because of the IGNORE clause.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Re: crash if JOIN::optimize fails in INSERT IGNORE
Monty thinks that my_message_sql should not check for select_lex->no_errors and always send an error packet.
Trying it, mysql-test fails in three different ways (because of errors that were not happening before):
1. INSERT IGNORE ... SELECT: ERROR 1048: Column 'c1' cannot be null
This can be fixed with
=== modified file 'sql/sql_insert.cc' --- sql/sql_insert.cc 2011-09-26 20:54:00 +0000 +++ sql/sql_insert.cc 2011-11-04 14:02:57 +0000 @@ -3271,7 +3271,8 @@ int select_insert::send_data(List<Item> thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields store_values(values); - thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; + if (!info.ignore) + thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; if (thd->is_error()) { table->auto_increment_field_not_null= FALSE;2. UPDATE IGNORE T1 SET B=(SELECT ...) ERROR 1242: Subquery returns more than 1 row
In my opinion this needs no fix. It correctly fails as it should. This error
should not be ignored.
3. DELETE IGNORE ... ERROR 1451: Cannot delete or update a parent row: a foreign key constraint fails
This one is a bit more difficult to fix.