From: Date: March 20 2009 12:00am Subject: bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:2842) Bug#40127 List-Archive: http://lists.mysql.com/commits/69876 X-Bug: 40127 Message-Id: <0KGR00F6ZZTSKWD0@fe-emea-10.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_x+ODrSwNMDadRW0di1Glbg)" --Boundary_(ID_x+ODrSwNMDadRW0di1Glbg) MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline #At file:///home/thek/Development/cpp/mysqlbzr/51-bug40127/ based on revid:gni@stripped 2842 Kristofer Pettersson 2009-03-20 Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 The server crashes on an assert in net_end_statement indicating that the Diagnostics area wasn't set properly during execution. This happened on a multi table DELETE operation using the IGNORE keyword. The keyword is suppose to allow for execution to continue on a best effort despite some non-fatal errors. Instead execution stopped and no client response was sent which would have led to a protocol error if it hadn't been for the assert. This patch corrects this issue by checking for the existance of an IGNORE option before setting an error state during row-by-row delete iteration. @ sql/sql_delete.cc * IGNORE option wasn't implemented in multi_delete::send_data and multi_delete::do_deletes modified: sql/sql_delete.cc === modified file 'sql/sql_delete.cc' --- a/sql/sql_delete.cc 2009-02-09 22:51:59 +0000 +++ b/sql/sql_delete.cc 2009-03-19 23:00:17 +0000 @@ -709,6 +709,8 @@ bool multi_delete::send_data(List TABLE_LIST *del_table; DBUG_ENTER("multi_delete::send_data"); + bool no_error= thd->lex->current_select->no_error; + for (del_table= delete_tables; del_table; del_table= del_table->next_local, secure_counter++) @@ -729,9 +731,28 @@ bool multi_delete::send_data(List if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_BEFORE, FALSE)) - DBUG_RETURN(1); + { + /* + If the IGNORE option is used the errors will be translated into + warnings and we should not interrupt the loop. + */ + if (!no_error) + DBUG_RETURN(1); + } table->status|= STATUS_DELETED; - if (!(error=table->file->ha_delete_row(table->record[0]))) + error=table->file->ha_delete_row(table->record[0]); + + /* + If an error occurred and there is no IGNORE flag; + Signal an error and exit. + */ + if (!no_error && error) + { + table->file->print_error(error,MYF(0)); + DBUG_RETURN(1); + } + + if (!error) { deleted++; if (!table->file->has_transactions()) @@ -739,12 +760,14 @@ bool multi_delete::send_data(List if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_AFTER, FALSE)) - DBUG_RETURN(1); - } - else - { - table->file->print_error(error,MYF(0)); - DBUG_RETURN(1); + { + /* + If the IGNORE option is used the errors will be translated into + warning messages and we should not stop. + */ + if (!no_error) + DBUG_RETURN(1); + } } } else @@ -834,6 +857,11 @@ int multi_delete::do_deletes() { int local_error= 0, counter= 0, tmp_error; bool will_batch; + /* + If the IGNORE option is used all non fatal errors will be translated + to warnings and we should not break the row-by-row iteration. + */ + bool no_errors= thd->lex->current_select->no_error; DBUG_ENTER("do_deletes"); DBUG_ASSERT(do_delete); @@ -869,21 +897,30 @@ int multi_delete::do_deletes() table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_BEFORE, FALSE)) { - local_error= 1; - break; + if (!no_errors) + { + local_error= 1; + break; + } } if ((local_error=table->file->ha_delete_row(table->record[0]))) { - table->file->print_error(local_error,MYF(0)); - break; + if (!no_errors) + { + table->file->print_error(local_error,MYF(0)); + break; + } } deleted++; if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_AFTER, FALSE)) { - local_error= 1; - break; + if (!no_errors) + { + local_error= 1; + break; + } } } if (will_batch && (tmp_error= table->file->end_bulk_delete())) --Boundary_(ID_x+ODrSwNMDadRW0di1Glbg) MIME-version: 1.0 Content-type: text/bzr-bundle; name="bzr/kristofer.pettersson@stripped"; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline; filename="bzr/kristofer.pettersson@stripped" # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kristofer.pettersson@stripped\ # 3vhzkefc3nsy7eq2 # target_branch: file:///home/thek/Development/cpp/mysqlbzr/51-\ # bug40127/ # testament_sha1: e5d283ff3ca4d6ee20c51c7b6e0942d76201616a # timestamp: 2009-03-20 00:00:32 +0100 # base_revision_id: gni@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWdcc5UAAAxTfgFVweff//1ev 3iq////6YAdtdnOPtetS7trbNu3dVbuxbVnp5wkkmgmTU2hPIaE9EankZJtTNTRo0AyGmjQZBkhp NMTTVPT1Kfqm9U9GSGgaBoA0AAAADU0aYpkSNB6TQ0aNAAaAAAA0AaBIimmkMpkZBkmg0xNAGjQ0 aAABoAcNNMEMhppkZMIBpoAwmjTJgAQNBJE1DEEAQTMmqepoeFNpB6jRpk9QB6gZqG/HIIQys8XF MB5WRv4NBHFU0jLu/PAcOP425c7ZqJ5yK66gkvONFIRAU4KYUxYjF6N1WGsuvAgKiSVXackIgB4S 9918w6arjw1Ph2zR1iSSlSSMxXP2Jb0RxHZcYbAt+RbfSJ748pm7pIXW2V0RBLJduepOwwxbk7gn m1wAuW51qFulahgf5pbUfIC0s7KhoKIFHDSj34J/poyyIbrzBVNYOCNDHkkfi6KUsymbwTiEZPZy YxzN9BCWUFwEWRdQwYcGKjVESFubhFuCCd70ehFzIudpqgIbRBkTHAI7ebKAZKaFxY+zm0eVebd4 ncvX2tp0bcL887R0idn377wVWTD4NUmS6z5q9A1jGFMXt419+oc3KHs5+jdPMZFnviNPGKhbfE0h oJByu1ES4688WrWSxKKU/g57ZNOW7MiEvJhUpecMFddcBFdte4WqafmgkQt5/aSfuayxekXNIRCd co4vNsIToHtHjcWZiLS5y8EQgXC77oPyO50sS5HoGVM5zBfsaKjBnK8Xd3LLCVfAva4bVYTVCotf Ttqt+pxXL71GYyD4NYwN7yJ0chNyRhGwbMmghLOYrYgkGGZSG7duKhW+LaMJiqbS6CJNNPxTuNkr lUjzmRM2SxWe4TCnth1HenlaYviauQO1im/1KiYzF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