Skip to content

Commit ad5235c

Browse files
author
Pavan Naik
committed
BUG#13687542 : MTR BEHAVES WRONG WHEN EXECUTING 'ERROR $VAR' IN A LOOP
Description : ============= MTR's 'error' command can be used when a statement is expected to fail. It is possible to give the error code either hard-coded or as an mtr variable, like: --error $variable. However, if an 'error $variable' statement is inside a loop, it evaluates to the same value every iteration. Issue : ======= 'expected_errors' array was not getting updated with the 'error' command value after the first iteration. Fix : ===== Check for 'error' command and update the 'expected_errors' array for each iteration of the loop. Reviewed-by: Sayantan Dutta <[email protected]> RB: 11463
1 parent 9ccd5f1 commit ad5235c

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

client/mysqltest.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -8392,6 +8392,13 @@ void get_command_type(struct st_command* command)
83928392
"use # if you intended to write a comment");
83938393
}
83948394
}
8395+
DBUG_VOID_RETURN;
8396+
}
8397+
8398+
8399+
void update_expected_errors(struct st_command* command)
8400+
{
8401+
DBUG_ENTER("update_expected_errors");
83958402

83968403
/* Set expected error on command */
83978404
memcpy(&command->expected_errors, &saved_expected_errors,
@@ -8771,6 +8778,9 @@ int main(int argc, char **argv)
87718778
if (command->type == Q_UNKNOWN || command->type == Q_COMMENT_WITH_COMMAND)
87728779
get_command_type(command);
87738780

8781+
if(saved_expected_errors.count > 0)
8782+
update_expected_errors(command);
8783+
87748784
if (parsing_disabled &&
87758785
command->type != Q_ENABLE_PARSING &&
87768786
command->type != Q_DISABLE_PARSING)

mysql-test/r/mysqltest.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ mysqltest: At line 1: Unknown SQL error name 'E9999'
244244
mysqltest: At line 1: Invalid argument to error: '999e9' - the errno may only consist of digits[0-9]
245245
mysqltest: At line 1: Invalid argument to error: '9b' - the errno may only consist of digits[0-9]
246246
mysqltest: At line 1: Too many errorcodes specified
247+
CREATE TABLE t1 (a INT);
248+
CREATE TABLE t1 (a INT);
249+
ERROR 42S01: Table 't1' already exists
250+
CREATE TABLE t1 (a INT);
251+
ERROR 42S01: Table 't1' already exists
252+
DROP TABLE t1;
247253
MySQL
248254
"MySQL"
249255
MySQL: The world''s most popular open source database

mysql-test/t/mysqltest.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,18 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
710710
--error 1
711711
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $MYSQL_TEST 2>&1
712712

713+
# BUG#13687542 MTR BEHAVES WRONG WHEN EXECUTING 'ERROR $VAR' IN A LOOP
714+
--let $i= 0
715+
--let $error= 0
716+
while ($i < 3)
717+
{
718+
--error $error
719+
CREATE TABLE t1 (a INT);
720+
--let $error= 1050
721+
--inc $i
722+
}
723+
724+
DROP TABLE t1;
713725

714726
# ----------------------------------------------------------------------------
715727
# Test echo command

0 commit comments

Comments
 (0)