From c87912c8da17ee9734b1b37cbc59c76bc68f41d2 Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Sun, 20 Mar 2005 20:29:03 +0300 Subject: [PATCH] Fix for spurious failures of sp.test on many platforms (aka Bug #9161 "Warnings on 'drop procedure' platform-specific"). In mysqltest we should not issue "SHOW WARNINGS" until we have not read results from all statements in multi-statement. Otherwise such "SHOW WARNINGS" will either cause "Packets out of order" error and thus will ruin current connection (but we may not notice this as it happened in sp.test because we ignore errors from such auxilary SHOW WARNINGS and use auto-reconnecting connections) or will succeed but consume first packet from next statement in multi-statement sequence (this happens if "SHOW WARNINGS" is issued when this packet is already received by client. Packet is thrown away by net_clear() call which is issued when "SHOW WARNINGS" is sent to server). In our case sp.test failed because usually we had first situation but sometimes second situation occured causing warning to pop-up. --- client/mysqltest.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index f6f6f469e8..c1ff16e5d8 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2746,8 +2746,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags) append_result(ds, res); } - /* Add all warnings to the result */ - if (!disable_warnings && mysql_warning_count(mysql)) + /* + Add all warnings to the result. We can't do this if we are in + the middle of processing results from multi-statement, because + this will break protocol. + */ + if (!disable_warnings && !mysql_more_results(mysql) && + mysql_warning_count(mysql)) { MYSQL_RES *warn_res=0; uint count= mysql_warning_count(mysql); @@ -3363,6 +3368,13 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds) if (!disable_warnings && (count= mysql_warning_count(mysql))) { + /* + If one day we will support execution of multi-statements + through PS API we should not issue SHOW WARNINGS until + we have not read all results... + */ + DBUG_ASSERT(!mysql_more_results(mysql)); + if (mysql_real_query(mysql, "SHOW WARNINGS", 13) == 0) { MYSQL_RES *warn_res= mysql_store_result(mysql); -- 2.30.9