Description:
This bug was introduced in scope of WL#1895 "Print message to error log in
case of detected MyISAM corruption".
Function mi_report_error() not only writes a message to the error log,
but generates a warning. However, a warning is also always generated
on the upper layer, ergo we get two warnings.
The warning generated by mi_report_error() has a wrong warning code -- not
one of the ER_ listed in ha_errmsg.cc, but the internal myisam error code, like 126 or 145.
How to repeat:
Add SHOW WARNINGS statement to myisam_keycache_coverate.test:
=== modified file 'mysql-test/t/myisam_keycache_coverage.test'
--- mysql-test/t/myisam_keycache_coverage.test 2009-04-14 13:40:06 +0000
+++ mysql-test/t/myisam_keycache_coverage.test 2009-08-14 10:48:04 +0000
@@ -35,6 +35,7 @@ SET debug='+d,key_cache_read_block_error
--replace_regex /'.*[\/\\]/'/
--error 126
SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5;
+show warnings;
--echo # Reset debug variable to its original value.
--disable_query_log
eval SET debug= '$debug';
You will see that there are duplicate warnings:
main.myisam_keycache_coverage [ fail ]
Test ended at 2009-08-14 14:48:17
CURRENT_TEST: main.myisam_keycache_coverage
--- /opt/local/work/5.4-azalea/mysql-test/r/myisam_keycache_coverage.result 2009-07-14 23:38:07.291880919 +0300
+++ /opt/local/work/5.4-azalea/mysql-test/r/myisam_keycache_coverage.reject 2009-08-14 13:48:17.436835210 +0300
@@ -28,6 +28,10 @@
SET debug='+d,key_cache_read_block_error';
SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5;
ERROR HY000: Incorrect key file for table 't1.MYI'; try to repair it
+show warnings;
+Level Code Message
+Error 126 Incorrect key file for table './test/t1.MYI'; try to repair it
+Error 1034 Incorrect key file for table 't1'; try to repair it
# Reset debug variable to its original value.
FLUSH TABLE t1;
#
Suggested fix:
Patch:
=== modified file 'include/my_sys.h'
--- include/my_sys.h 2009-07-16 12:51:04 +0000
+++ include/my_sys.h 2009-08-14 10:47:19 +0000
@@ -107,8 +107,9 @@ extern int NEAR my_errno; /* Last error
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
#define ME_FATALERROR 1024 /* Fatal statement error */
-#define ME_JUST_INFO 8192 /**< not error but just info */
-#define ME_JUST_WARNING 16384 /**< not error but just warning */
+#define ME_JUST_INFO 8192 /**< not error but just info in error log */
+#define ME_JUST_WARNING 16384 /**< not error but just warning in error log */
+#define ME_JUST_ERROR 32768 /**< just error message in error log */
/* Bits in last argument to fn_format */
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
=== modified file 'mysql-test/t/myisam_keycache_coverage.test'
--- mysql-test/t/myisam_keycache_coverage.test 2009-04-14 13:40:06 +0000
+++ mysql-test/t/myisam_keycache_coverage.test 2009-08-14 10:46:36 +0000
@@ -36,6 +36,7 @@ SET debug='+d,key_cache_read_block_error
--error 126
SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5;
--echo # Reset debug variable to its original value.
+show warnings;
--disable_query_log
eval SET debug= '$debug';
--enable_query_log
=== modified file 'sql/mysqld.cc'
--- sql/mysqld.cc 2009-08-12 20:20:51 +0000
+++ sql/mysqld.cc 2009-08-14 10:05:12 +0000
@@ -3083,6 +3083,12 @@ void my_message_sql(uint error, const ch
DBUG_VOID_RETURN;
}
+ if (MyFlags & ME_JUST_ERROR)
+ {
+ sql_print_error("%s: %s", my_progname, str);
+ DBUG_VOID_RETURN;
+ }
+
if (thd)
{
if (MyFlags & ME_FATALERROR)
=== modified file 'storage/myisam/mi_info.c'
--- storage/myisam/mi_info.c 2008-04-09 00:56:49 +0000
+++ storage/myisam/mi_info.c 2009-08-14 10:05:36 +0000
@@ -126,7 +126,7 @@ void mi_report_error(int errcode, const
if ((lgt= strlen(file_name)) > 64)
file_name+= lgt - 64;
- my_error(errcode, MYF(ME_NOREFRESH), file_name);
+ my_error(errcode, MYF(ME_JUST_ERROR), file_name);
DBUG_VOID_RETURN;
}
Description: This bug was introduced in scope of WL#1895 "Print message to error log in case of detected MyISAM corruption". Function mi_report_error() not only writes a message to the error log, but generates a warning. However, a warning is also always generated on the upper layer, ergo we get two warnings. The warning generated by mi_report_error() has a wrong warning code -- not one of the ER_ listed in ha_errmsg.cc, but the internal myisam error code, like 126 or 145. How to repeat: Add SHOW WARNINGS statement to myisam_keycache_coverate.test: === modified file 'mysql-test/t/myisam_keycache_coverage.test' --- mysql-test/t/myisam_keycache_coverage.test 2009-04-14 13:40:06 +0000 +++ mysql-test/t/myisam_keycache_coverage.test 2009-08-14 10:48:04 +0000 @@ -35,6 +35,7 @@ SET debug='+d,key_cache_read_block_error --replace_regex /'.*[\/\\]/'/ --error 126 SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5; +show warnings; --echo # Reset debug variable to its original value. --disable_query_log eval SET debug= '$debug'; You will see that there are duplicate warnings: main.myisam_keycache_coverage [ fail ] Test ended at 2009-08-14 14:48:17 CURRENT_TEST: main.myisam_keycache_coverage --- /opt/local/work/5.4-azalea/mysql-test/r/myisam_keycache_coverage.result 2009-07-14 23:38:07.291880919 +0300 +++ /opt/local/work/5.4-azalea/mysql-test/r/myisam_keycache_coverage.reject 2009-08-14 13:48:17.436835210 +0300 @@ -28,6 +28,10 @@ SET debug='+d,key_cache_read_block_error'; SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5; ERROR HY000: Incorrect key file for table 't1.MYI'; try to repair it +show warnings; +Level Code Message +Error 126 Incorrect key file for table './test/t1.MYI'; try to repair it +Error 1034 Incorrect key file for table 't1'; try to repair it # Reset debug variable to its original value. FLUSH TABLE t1; # Suggested fix: Patch: === modified file 'include/my_sys.h' --- include/my_sys.h 2009-07-16 12:51:04 +0000 +++ include/my_sys.h 2009-08-14 10:47:19 +0000 @@ -107,8 +107,9 @@ extern int NEAR my_errno; /* Last error #define ME_COLOUR2 ((2 << ME_HIGHBYTE)) #define ME_COLOUR3 ((3 << ME_HIGHBYTE)) #define ME_FATALERROR 1024 /* Fatal statement error */ -#define ME_JUST_INFO 8192 /**< not error but just info */ -#define ME_JUST_WARNING 16384 /**< not error but just warning */ +#define ME_JUST_INFO 8192 /**< not error but just info in error log */ +#define ME_JUST_WARNING 16384 /**< not error but just warning in error log */ +#define ME_JUST_ERROR 32768 /**< just error message in error log */ /* Bits in last argument to fn_format */ #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ === modified file 'mysql-test/t/myisam_keycache_coverage.test' --- mysql-test/t/myisam_keycache_coverage.test 2009-04-14 13:40:06 +0000 +++ mysql-test/t/myisam_keycache_coverage.test 2009-08-14 10:46:36 +0000 @@ -36,6 +36,7 @@ SET debug='+d,key_cache_read_block_error --error 126 SELECT COUNT(*) FROM t1 FORCE INDEX(i1) WHERE c2 < 5; --echo # Reset debug variable to its original value. +show warnings; --disable_query_log eval SET debug= '$debug'; --enable_query_log === modified file 'sql/mysqld.cc' --- sql/mysqld.cc 2009-08-12 20:20:51 +0000 +++ sql/mysqld.cc 2009-08-14 10:05:12 +0000 @@ -3083,6 +3083,12 @@ void my_message_sql(uint error, const ch DBUG_VOID_RETURN; } + if (MyFlags & ME_JUST_ERROR) + { + sql_print_error("%s: %s", my_progname, str); + DBUG_VOID_RETURN; + } + if (thd) { if (MyFlags & ME_FATALERROR) === modified file 'storage/myisam/mi_info.c' --- storage/myisam/mi_info.c 2008-04-09 00:56:49 +0000 +++ storage/myisam/mi_info.c 2009-08-14 10:05:36 +0000 @@ -126,7 +126,7 @@ void mi_report_error(int errcode, const if ((lgt= strlen(file_name)) > 64) file_name+= lgt - 64; - my_error(errcode, MYF(ME_NOREFRESH), file_name); + my_error(errcode, MYF(ME_JUST_ERROR), file_name); DBUG_VOID_RETURN; }