Skip to content

Commit

Permalink
MDEV-16708: Fixed ths issue with handling of ERR packet received by m…
Browse files Browse the repository at this point in the history
…ysqltest

on response to COM_STMT_EXECUTE

The test cases like the following one
  delimiter |;
  CREATE PROCEDURE SP001()
  BEGIN
    DECLARE C1 CURSOR FOR SELECT 1;

    OPEN C1;

    SELECT 1;
    CLOSE C1;
    CLOSE C1;
  END|
  delimiter ;|
  --error 1326
  call SP001();

are failed since processing of ERR packet was missed by mysqltest
in case it is run with --ps-protocol

Additionally, the test sp-error was changed to don't run multi-statements
since they are not supported by PS protocol
  • Loading branch information
dmitryshulga authored and vuvova committed Jun 17, 2021
1 parent a720984 commit fc71746
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8324,6 +8324,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
goto end;
}

int err;
do
{
/*
Expand Down Expand Up @@ -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)
{
/*
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/sp-error.result
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/sp-error.test
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -3721,7 +3721,7 @@ END|
--echo
CALL p1()|
--echo
SET sql_mode = DEFAULT;
SET sql_mode = DEFAULT|

CREATE PROCEDURE p2()
BEGIN
Expand Down

0 comments on commit fc71746

Please sign in to comment.