Bug #68618 Similar "Can't find file" (ER_FILE_NOT_FOUND) errors are treated differently
Submitted: 9 Mar 2013 16:14 Modified: 11 Mar 2013 23:31
Reporter: Chris Calender Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.6.10, 5.5.30 OS:Any
Assigned to: CPU Architecture:Any
Tags: can't find file, ER_FILE_NOT_FOUND, errno 2, errno 22

[9 Mar 2013 16:14] Chris Calender
Description:
Similar "Can't find file" (ER_FILE_NOT_FOUND) errors are treated differently - one is logged to the error log and the other is not.

I would think they should be handled the same, whether that be writing them to the error log or not.  This occurs in both 5.5.30 and 5.6.10.

For instance, this command logs an error on the console *and* the error log (issue "use test" first):

show create table `select * from t1`;

Console Error (5.5):
ERROR 1017 (HY000): Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 22)

Error in Error Log (5.5):
130307 23:22:04 [ERROR] C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 22)

However, this command logs an error on the console, but not the error log:

rename table `select * from t1` to `t2`;
ERROR 1017 (HY000): Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 2)

The only real difference, in the actual error, is that one reports errno 22 while the other errno 2:

c:>perror 2
OS error code   2:  No such file or directory
Win32 error code 2: The system cannot find the file specified.

c:>perror 22
OS error code  22:  Invalid argument
Win32 error code 22: The device does not recognize the command.

I will say that in 5.6, the error message is a bit more descriptive by mentioning the text of the errno:

Console (5.6.10):
mysql> show create table `select * from t1`;
ERROR 1017 (HY000): Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 22 - Invalid argument)
mysql> rename table `select * from t1` to `t2`;
ERROR 1017 (HY000): Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 2 - No such file or directory)

Error Log (5.6.10):
mysql> show create table `select * from t1`;
ERROR 1017 (HY000): Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 22 - Invalid argument)
mysql> rename table `select * from t1` to `t2`;
ERROR 1017 (HY000): Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 2 - No such file or directory)

How to repeat:
use test
show create table `select * from t1`;
rename table `select * from t1` to `t2`;

check error log - you will see the "show-error" was logged to the error log and the "rename-error" is not

Suggested fix:
The relevant files are - I'm just not sure which method should be preferred:

./sql/sql_rename.cc
./sql/sql_show.cc
[9 Mar 2013 22:56] Chris Calender
The very last "Error Log (5.6.10)" output should read:

Error Log (5.6.10):
2013-03-09 10:33:38 6340 [ERROR] C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld: Can't find file: '.\test\select@0020@002a@0020from@0020t1.frm' (errno: 22 - Invalid argument)
[11 Mar 2013 9:12] Shane Bester
Hi Chris,

At least on Windows with mysql-trunk (5.7.2), this is fixed.

mysql> select * from `t"`;
ERROR 1146 (42S02): Table 'test.t"' doesn't exist
mysql> select version();
+-----------------+
| version()       |
+-----------------+
| 5.7.2-m12-debug |
+-----------------+
1 row in set (0.00 sec)

And not spam in the error log either.

Therefore this is a duplicate of existing internal bug, which was deemed a minor problem, and not worthy to fix in 5.6.

Bug 14642248 - NONSENSE ERROR ON WINDOWS (ERRNO: 22 - INVALID ARGUMENT)
[11 Mar 2013 23:31] Chris Calender
Hi Shane,

Excellent, many thanks! :)

Best wishes,
Chris