Skip to content

Commit

Permalink
Added ER_... labels to mtr fatal error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
montywi authored and vuvova committed May 19, 2021
1 parent cc125be commit 0bc3a08
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
23 changes: 16 additions & 7 deletions client/mysqltest.cc
Expand Up @@ -8110,7 +8110,8 @@ void handle_error(struct st_command *command,
*/
if (err_errno == CR_SERVER_LOST ||
err_errno == CR_SERVER_GONE_ERROR)
die("require query '%s' failed: %d: %s", command->query,
die("require query '%s' failed: %s (%d): %s", command->query,
get_errname_from_code(err_errno),
err_errno, err_error);

/* Abort the run of this test, pass the failed query as reason */
Expand All @@ -8120,7 +8121,9 @@ void handle_error(struct st_command *command,

if (command->abort_on_error)
{
report_or_die("query '%s' failed: %d: %s", command->query, err_errno,
report_or_die("query '%s' failed: %s (%d): %s", command->query,
get_errname_from_code(err_errno),
err_errno,
err_error);
DBUG_VOID_RETURN;
}
Expand Down Expand Up @@ -8169,9 +8172,12 @@ void handle_error(struct st_command *command,
if (command->expected_errors.count > 0)
{
if (command->expected_errors.err[0].type == ERR_ERRNO)
report_or_die("query '%s' failed with wrong errno %d: '%s', instead of "
"%d...",
command->query, err_errno, err_error,
report_or_die("query '%s' failed with wrong errno %s (%d): '%s', "
"instead of %s (%d)...",
command->query,
get_errname_from_code(err_errno),
err_errno, err_error,
get_errname_from_code(command->expected_errors.err[0].code.errnum),
command->expected_errors.err[0].code.errnum);
else
report_or_die("query '%s' failed with wrong sqlstate %s: '%s', "
Expand Down Expand Up @@ -8204,8 +8210,11 @@ void handle_no_error(struct st_command *command)
command->expected_errors.err[0].code.errnum != 0)
{
/* Error code we wanted was != 0, i.e. not an expected success */
report_or_die("query '%s' succeeded - should have failed with errno %d...",
command->query, command->expected_errors.err[0].code.errnum);
report_or_die("query '%s' succeeded - should have failed with error "
"%s (%d)...",
command->query,
get_errname_from_code(command->expected_errors.err[0].code.errnum),
command->expected_errors.err[0].code.errnum);
}
else if (command->expected_errors.err[0].type == ERR_SQLSTATE &&
strcmp(command->expected_errors.err[0].code.sqlstate,"00000") != 0)
Expand Down
26 changes: 13 additions & 13 deletions mysql-test/main/mysqltest.result
Expand Up @@ -8,7 +8,7 @@ select otto from (select 1 as otto) as t1;
otto
1
select friedrich from (select 1 as otto) as t1;
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed: 1054: Unknown column 'friedrich' in 'field list'
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed: ER_BAD_FIELD_ERROR (1054): Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1;
Expand Down Expand Up @@ -155,7 +155,7 @@ select 1146 as "after_!errno_masked_error" ;
after_!errno_masked_error
1146
select 3 from t1;
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1000...
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno ER_NO_SUCH_TABLE (1146): 'Table 'test.t1' doesn't exist', instead of ER_HASHCHK (1000)...
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1
is empty
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'nonsense' at line 1
Expand All @@ -169,7 +169,7 @@ after_--enable_abort_on_error
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1;
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064...
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno ER_NO_SUCH_TABLE (1146): 'Table 'test.t1' doesn't exist', instead of ER_PARSE_ERROR (1064)...
garbage;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1
select 2;
Expand Down Expand Up @@ -360,7 +360,7 @@ insert into t1 values ('$dollar');
$dollar
`select 42`
drop table t1;
mysqltest: At line 1: query 'let $var2= `failing query`' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'failing query' at line 1
mysqltest: At line 1: query 'let $var2= `failing query`' failed: ER_PARSE_ERROR (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'failing query' at line 1
mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open 'non_existingFile' for reading, errno: 2
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql":
Expand All @@ -383,7 +383,7 @@ At line 1: Source directives are nesting too deep
garbage ;
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql":
included from <stdin> at line 1:
At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1
At line 1: query 'garbage ' failed: ER_PARSE_ERROR (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1

2 = outer loop variable after while
here is the sourced script
Expand Down Expand Up @@ -520,7 +520,7 @@ mysqltest: At line 1: Missing '{' after while. Found "dec $i"
mysqltest: At line 1: Stray '}' - end of block before beginning
mysqltest: At line 1: Stray 'end' command - end of block before beginning
{;
mysqltest: At line 1: query '{' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '{' at line 1
mysqltest: At line 1: query '{' failed: ER_PARSE_ERROR (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '{' at line 1
mysqltest: At line 1: Missing '{' after while. Found "echo hej"
mysqltest: At line 3: Missing end of block
mysqltest: At line 3: Missing end of block
Expand Down Expand Up @@ -560,7 +560,7 @@ mysqltest: At line 1: Missing required argument 'connection name' to command 'co
mysqltest: At line 1: Missing required argument 'connection name' to command 'connect'
mysqltest: At line 1: Missing required argument 'host' to command 'connect'
mysqltest: At line 1: Missing required argument 'host' to command 'connect'
mysqltest: At line 1: query 'connect con2,localhost,root,,illegal_db' failed: 1049: Unknown database 'illegal_db'
mysqltest: At line 1: query 'connect con2,localhost,root,,illegal_db' failed: ER_BAD_DB_ERROR (1049): Unknown database 'illegal_db'
mysqltest: At line 1: Illegal argument for port: 'illegal_port'
mysqltest: At line 1: Illegal option to connect: SMTP
200 connects succeeded
Expand Down Expand Up @@ -631,12 +631,12 @@ insertz 'error query'||||
mysqltest: At line 3: query 'create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
insertz 'error query'' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'insertz 'error query'' at line 1
insertz 'error query'' failed: ER_PARSE_ERROR (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'insertz 'error query'' at line 1
drop table t1;
mysqltest: At line 3: query 'create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
insertz 'error query'' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'insertz 'error query'' at line 1
insertz 'error query'' failed: ER_PARSE_ERROR (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'insertz 'error query'' at line 1
drop table t1;
Multi statement using expected error
create table t1 (a int primary key);
Expand Down Expand Up @@ -931,7 +931,7 @@ mysqltest: At line 1: Could not find column 'column_not_exists' in the result of
mysqltest: At line 1: Query 'SET @A = 1' didn't return a result set
mysqltest: At line 1: Could not find column '1 AS B' in the result of 'SELECT 1 AS A'
value= No such row
mysqltest: At line 1: query 'let $value= query_get_value(SHOW COLNS FROM t1, Field, 1)' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'COLNS FROM t1' at line 1
mysqltest: At line 1: query 'let $value= query_get_value(SHOW COLNS FROM t1, Field, 1)' failed: ER_PARSE_ERROR (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'COLNS FROM t1' at line 1

Field Type Null Key Default Extra
a int(11) YES -><- NULL
Expand All @@ -946,9 +946,9 @@ a int(11) YES NULL
b varchar(255) YES NULL
c datetime YES NULL
drop table t1;
mysqltest: At line 1: query 'change_user root,,inexistent' failed: 1049: Unknown database 'inexistent'
mysqltest: At line 1: query 'change_user inexistent,,test' failed: 1045: Access denied for user 'inexistent'@'localhost' (using password: NO)
mysqltest: At line 1: query 'change_user root,inexistent,test' failed: 1045: Access denied for user 'root'@'localhost' (using password: YES)
mysqltest: At line 1: query 'change_user root,,inexistent' failed: ER_BAD_DB_ERROR (1049): Unknown database 'inexistent'
mysqltest: At line 1: query 'change_user inexistent,,test' failed: ER_ACCESS_DENIED_ERROR (1045): Access denied for user 'inexistent'@'localhost' (using password: NO)
mysqltest: At line 1: query 'change_user root,inexistent,test' failed: ER_ACCESS_DENIED_ERROR (1045): Access denied for user 'root'@'localhost' (using password: YES)
REPLACED_FILE1.txt
file1.txt
file2.txt
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/mysqltest_cont_on_error.result
@@ -1,7 +1,7 @@
select error;
mysqltest: At line 1: query 'select error' failed: 1054: Unknown column 'error' in 'field list'
mysqltest: At line 1: query 'select error' failed: ER_BAD_FIELD_ERROR (1054): Unknown column 'error' in 'field list'
SELECT ERROR;
mysqltest: At line 1: query 'SELECT ERROR' failed: 1054: Unknown column 'ERROR' in 'field list'
mysqltest: At line 1: query 'SELECT ERROR' failed: ER_BAD_FIELD_ERROR (1054): Unknown column 'ERROR' in 'field list'
SELECT 2;
2
2

0 comments on commit 0bc3a08

Please sign in to comment.