diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 0f052397d4fbd..a873618bf5591 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8324,6 +8324,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, goto end; } + int err; do { /* @@ -8357,8 +8358,6 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, goto end; } - /* If we got here the statement was both executed and read successfully */ - handle_no_error(command); if (!disable_result_log) { /* @@ -8436,8 +8435,14 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, } } } - } while ( !mysql_stmt_next_result(stmt)); + } while ( !(err= mysql_stmt_next_result(stmt))); + if (err > 0) + /* We got an error from mysql_next_result, maybe expected */ + handle_error(command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), ds); + else + handle_no_error(command); end: if (!disable_warnings) { diff --git a/mysql-test/main/sp-error.result b/mysql-test/main/sp-error.result index f64735f8006d0..3832d63c073ee 100644 --- a/mysql-test/main/sp-error.result +++ b/mysql-test/main/sp-error.result @@ -2771,7 +2771,7 @@ DROP TABLE t2; DROP PROCEDURE IF EXISTS p1; DROP PROCEDURE IF EXISTS p2; -SET sql_mode = ''; +SET sql_mode = ''| CREATE PROCEDURE p1() BEGIN DECLARE var1 INTEGER DEFAULT 'string'; @@ -2782,7 +2782,7 @@ CALL p1()| Warnings: Warning 1366 Incorrect integer value: 'string' for column ``.``.`var1` at row 1 -SET sql_mode = DEFAULT; +SET sql_mode = DEFAULT| CREATE PROCEDURE p2() BEGIN DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H2'; diff --git a/mysql-test/main/sp-error.test b/mysql-test/main/sp-error.test index d2af983482300..3ce3623be18a9 100644 --- a/mysql-test/main/sp-error.test +++ b/mysql-test/main/sp-error.test @@ -3711,7 +3711,7 @@ DROP PROCEDURE IF EXISTS p2; delimiter |; -SET sql_mode = ''; +SET sql_mode = ''| CREATE PROCEDURE p1() BEGIN DECLARE var1 INTEGER DEFAULT 'string'; @@ -3721,7 +3721,7 @@ END| --echo CALL p1()| --echo -SET sql_mode = DEFAULT; +SET sql_mode = DEFAULT| CREATE PROCEDURE p2() BEGIN