From 2b1f0bf1f516e968c41b8da2bccfe467b54f126c Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Thu, 24 Feb 2005 13:56:09 +0100 Subject: [PATCH] Fixed BUG#8638: Test 'sp' fails: Stored Procedure often sends warning 1329 The warning sent is by itself ok, the problem was rather why it wasn't sent on some other platforms... The real problem was that a total_warn_count which was inconsistent with warn_list was sent back with send_eof() during SP execution, which in turn cause a protocol error in mysqltest. --- mysql-test/r/sp.result | 9 ++++----- sql/protocol.cc | 4 +++- sql/sql_parse.cc | 6 ++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index f3a42d75258..f2b99b7074a 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -656,7 +656,6 @@ delete from t1| drop table if exists t3| create table t3 ( s char(16), d int)| call into_test4()| -Warnings: select * from t3| s d into4 NULL @@ -1344,9 +1343,7 @@ end if; insert into t4 values (2, rc, t3); end| call bug1863(10)| -Warnings: call bug1863(10)| -Warnings: select * from t4| f1 rc t3 2 0 NULL @@ -1643,9 +1640,7 @@ begin end| call bug4579_1()| call bug4579_1()| -Warnings: call bug4579_1()| -Warnings: drop procedure bug4579_1| drop procedure bug4579_2| drop table t3| @@ -2118,12 +2113,16 @@ var call bug7743("OneWord")| var NULL +Warnings: +Warning 1329 No data to FETCH call bug7743("anotherword")| var 2 call bug7743("AnotherWord")| var NULL +Warnings: +Warning 1329 No data to FETCH drop procedure bug7743| drop table t4| delete from t3| diff --git a/sql/protocol.cc b/sql/protocol.cc index f31462ddad1..e14262fdbe0 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -359,7 +359,9 @@ send_eof(THD *thd, bool no_flush) if (thd->client_capabilities & CLIENT_PROTOCOL_41) { uchar buff[5]; - uint tmp= min(thd->total_warn_count, 65535); + /* Don't send warn count during SP execution, as the warn_list + is cleared between substatements, and mysqltest gets confused */ + uint tmp= (thd->spcont ? 0 : min(thd->total_warn_count, 65535)); buff[0]=254; int2store(buff+1, tmp); /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9a1b2eb0430..6e28f5bcefb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4185,6 +4185,12 @@ unsent_create_error: thd->row_count_func= 0; res= sp->execute_procedure(thd, &lex->value_list); + /* If warnings have been cleared, we have to clear total_warn_count + * too, otherwise the clients get confused. + */ + if (thd->warn_list.is_empty()) + thd->total_warn_count= 0; + thd->variables.select_limit= select_limit; #ifndef NO_EMBEDDED_ACCESS_CHECKS sp_restore_security_context(thd, sp, &save_ctx);