Description:
I have been running into some very odd behavior when creating a table that has the same name as another table with a space at the end:
`member`
`member `
Any data in `member` gets truncated when `member ` is created. On the filesystem, a `member .FRM` is created, but `member .MYD` and `member .MYI` are not.
I have run into very irregular errors when attempting to select/drop the tables. They have included "File does not exist" and "Got error 127 from table handler" and it also worked once.
I have included the exact commandline text that I used to replicate this error.
Thanks,
Jason Garber
How to repeat:
-- Creating the database
mysql> CREATE DATABASE tmp;
Query OK, 1 row affected (0.00 sec)
-- Using it
mysql> USE tmp;
Database changed
-- Creating `member` Table
mysql> CREATE TABLE `member` (x int);
Query OK, 0 rows affected (0.00 sec)
-- Inserting 3 records
mysql> INSERT INTO member VALUES (1),(2),(3);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
-- Here are the 3 records
mysql> SELECT * FROM `member`;
+------+
| x |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec)
mysql> exit
Bye
----------------------------------------------------------------
-- Here is the database directory
[root@lithium tmp]# cd /var/lib/mysql/tmp
[root@lithium tmp]# ls -l
total 20
-rw-rw---- 1 mysql mysql 8548 Feb 27 00:10 member.frm
-rw-rw---- 1 mysql mysql 15 Feb 27 00:10 member.MYD
-rw-rw---- 1 mysql mysql 1024 Feb 27 00:10 member.MYI
----------------------------------------------------------------
-- Here are the tables
mysql> show tables;
+---------------+
| Tables_in_tmp |
+---------------+
| member |
+---------------+
1 row in set (0.00 sec)
-- Creating the `member ` table
mysql> CREATE TABLE `member ` (x int);
Query OK, 0 rows affected (0.00 sec)
-- There it is
mysql> SHOW TABLES;
+---------------+
| Tables_in_tmp |
+---------------+
| member |
| member |
+---------------+
2 rows in set (0.00 sec)
-- Some errors
mysql> SELECT * FROM `member`;
ERROR 1030: Got error 127 from table handler
mysql> SELECT * FROM `member `;
ERROR 1030: Got error 127 from table handler
----------------------------------------------------------------
-- Here is the database directory
[root@lithium tmp]# ls -l
total 28
-rw-rw---- 1 mysql mysql 8548 Feb 27 00:11 member .frm
-rw-rw---- 1 mysql mysql 8548 Feb 27 00:10 member.frm
-rw-rw---- 1 mysql mysql 0 Feb 27 00:11 member.MYD
-rw-rw---- 1 mysql mysql 1024 Feb 27 00:11 member.MYI
----------------------------------------------------------------
--One more thing:
mysql> show tables;
+---------------+
| Tables_in_tmp |
+---------------+
| member |
| member |
+---------------+
2 rows in set (0.00 sec)
-- Dropping the `member ` table
mysql> drop table `member `;
Query OK, 0 rows affected (0.00 sec)
-- More errors
mysql> select * from member;
ERROR 1030: Got error 127 from table handler
----------------------------------------------------------------
-- Here is the database directory
[root@lithium tmp]# ls -l
total 12
-rw-rw---- 1 mysql mysql 8548 Feb 27 00:10 member.frm
[root@lithium tmp]#
----------------------------------------------------------------
Suggested fix:
I believe that some better ` ` handling would do it. I also think that while this is an important bug that may be indications of deeper logic flaws in that section of the code, it is not that urgent...
Who creates tables with spaces at the end?