From: Date: November 29 2007 7:37am Subject: bk commit into 5.0 tree (holyfoot:1.2581) BUG#32624 List-Archive: http://lists.mysql.com/commits/38786 X-Bug: 32624 Message-Id: <20071129063711.D766C2C380A5@hfmain.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of hf. When hf does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-11-29 10:37:07+04:00, holyfoot@stripped +3 -0 Bug #32624 Error with multi queries in MySQL embedded server 5.1.22. server status wasn't properly sent to the client after the error by the embedded server. Wasn't noticed before as one usually stopped retrieving results after he gets an error. libmysqld/lib_sql.cc@stripped, 2007-11-29 10:37:05+04:00, holyfoot@stripped +2 -0 Bug #32624 Error with multi queries in MySQL embedded server 5.1.22. server status transferred to the client after errors sql/protocol.cc@stripped, 2007-11-29 10:37:06+04:00, holyfoot@stripped +3 -2 Bug #32624 Error with multi queries in MySQL embedded server 5.1.22. set server status before net_send_error_packet() call as this function sends it to the client in the embedded server tests/mysql_client_test.c@stripped, 2007-11-29 10:37:06+04:00, holyfoot@stripped +14 -0 Bug #32624 Error with multi queries in MySQL embedded server 5.1.22. testcase added diff -Nrup a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc --- a/libmysqld/lib_sql.cc 2007-06-13 16:48:49 +05:00 +++ b/libmysqld/lib_sql.cc 2007-11-29 10:37:05 +04:00 @@ -73,6 +73,7 @@ void embedded_get_error(MYSQL *mysql, MY net->last_errno= ei->last_errno; strmake(net->last_error, ei->info, sizeof(net->last_error)); memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate)); + mysql->server_status= ei->server_status; my_free((gptr) data, MYF(0)); } @@ -1027,6 +1028,7 @@ void net_send_error_packet(THD *thd, uin ei->last_errno= sql_errno; strmake(ei->info, err, sizeof(ei->info)-1); strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno)); + ei->server_status= thd->server_status; thd->cur_data= 0; } diff -Nrup a/sql/protocol.cc b/sql/protocol.cc --- a/sql/protocol.cc 2007-09-22 12:48:36 +05:00 +++ b/sql/protocol.cc 2007-11-29 10:37:06 +04:00 @@ -110,13 +110,14 @@ void net_send_error(THD *thd, uint sql_e push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err); } + /* Abort multi-result sets */ + thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS; + net_send_error_packet(thd, sql_errno, err); thd->is_fatal_error=0; // Error message is given thd->net.report_error= 0; - /* Abort multi-result sets */ - thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS; DBUG_VOID_RETURN; } diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c --- a/tests/mysql_client_test.c 2007-11-22 15:53:37 +04:00 +++ b/tests/mysql_client_test.c 2007-11-29 10:37:06 +04:00 @@ -5643,6 +5643,20 @@ DROP TABLE IF EXISTS test_multi_tab"; (void) my_process_result_set(result); mysql_free_result(result); + /* + Check if errors in one of the queries handled properly. + */ + rc= mysql_query(mysql_local, "select 1; select * from not_existing_table"); + myquery(rc); + result= mysql_store_result(mysql_local); + mysql_free_result(result); + + rc= mysql_next_result(mysql_local); + DIE_UNLESS(rc > 0); + + rc= mysql_next_result(mysql_local); + DIE_UNLESS(rc < 0); + mysql_close(mysql_local); }