Bug #84392 strange behavior with one table name _greek
Submitted: 3 Jan 2017 14:24 Modified: 10 Jan 2017 8:13
Reporter: Brian Jouannes Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.7.16-0ubuntu0.16.04.1 OS:Ubuntu (16.04.1 LTS)
Assigned to: CPU Architecture:Any
Tags: mysql bug _greek greek table name issue strange

[3 Jan 2017 14:24] Brian Jouannes
Description:
Hello Mysql Hello Oracle,

I found this strange bug when I entered the command : 

CREATE TABLE _greek (id INT AUTO_INCREMENT NOT NULL, tr VARCHAR(255) NOT NULL, fr VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB

The error I get is : #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_greek (id INT AUTO_INCREMENT NOT NULL, tr VARCHAR(255) NOT NULL, fr VARCHAR(255' at line 1

I tried with other database name and the same command is working fine.
I doubt _greek is a reserved keyword but who knows.

Cheers and happy new year.

How to repeat:
Execute the following command with version mentioned above:

CREATE TABLE _greek (id INT AUTO_INCREMENT NOT NULL, tr VARCHAR(255) NOT NULL, fr VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB

Suggested fix:
I have no idea
[3 Jan 2017 15:55] MySQL Verification Team
Thank you for the bug report.

c:\dbs>c:\dbs\5.7\bin\mysql -uroot --port=3570 -p --prompt="mysql 5.7 > "
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 Source distribution PULL: 2016-DEC-25

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.7 > USE test
Database changed
mysql 5.7 > CREATE TABLE _greek (id INT AUTO_INCREMENT NOT NULL, tr VARCHAR(255) NOT NULL, fr VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_greek (id INT AUTO_INCREMENT NOT NULL, tr VARCHAR(255) NOT NULL, fr VARCHAR(255' at line 1
mysql 5.7 > CREATE TABLE `_greek` (id INT AUTO_INCREMENT NOT NULL, tr VARCHAR(255) NOT NULL, fr VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
Query OK, 0 rows affected (0.48 sec)

mysql 5.7 >
[10 Jan 2017 7:15] MySQL Verification Team
perhaps not a bug because those are character set introducers.  whether the parser should try consider them in that location is questionable though.

anyway,  the backtick is your friend;

mysql> create table _greek(a int)engine=innodb;
ERROR 1064 (42000): You have an error in your SQL syntax;
mysql> create table _big5(a int)engine=innodb;
ERROR 1064 (42000): You have an error in your SQL syntax;
mysql> create table `_big5`(a int)engine=innodb;
Query OK, 0 rows affected (0.10 sec)

mysql> create table `_greek`(a int)engine=innodb;
Query OK, 0 rows affected (0.09 sec)
[10 Jan 2017 7:20] MySQL Verification Team
https://dev.mysql.com/doc/refman/5.7/en/charset-introducer.html
http://dev.mysql.com/doc/refman/5.7/en/identifiers.html
[10 Jan 2017 8:13] Brian Jouannes
I had the problem during schema generation with Doctrine Entity on a Symfony3 project.

After checking at doctrine doctrine, it seems that the workaround for this was to enclosed with backtick the table name ORM annotation

/**
 * @ORM\Entity
 * @ORM\Table(name="`_greek`")
 */
class Greek extends SimpleDictionary {
    
}

Thanks for your help !