Bug #35524 Foreign keys: constraint name can be incorrect
Submitted: 24 Mar 2008 17:37 Modified: 20 Apr 2008 13:49
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:6.1.0-fk-debug OS:Linux (SUSE 10 | 32-bit)
Assigned to: Dmitry Lenev CPU Architecture:Any

[24 Mar 2008 17:37] Peter Gulutzan
Description:
I'm using mysql-6.1-fk.
I start mysqld with --foreign-key-all-engines=1.

I am able to create a table with a foreign key
constraint named `` or a foreign key constraint
named ` `. 

The usual rule is that "incorrect" names cause syntax
errors. For example "CREATE TABLE `` (s1 int);" causes
"ERROR 1103 (42000): Incorrect table name ''".
For example "CREATE PROCEDURE ` ` () set @a=5;" causes
"ERROR 1458 (42000): Incorrect routine name ''".

The usual rule should apply to constraints too.

How to repeat:
mysql> create table t1 (s1 int primary key);
Query OK, 0 rows affected (0.07 sec)

mysql> create table t2 (s1 int constraint `` references t1(s1));
Query OK, 0 rows affected (0.08 sec)

mysql> create table t3 (s1 int constraint ` ` references t1(s1));
Query OK, 0 rows affected (0.07 sec)

mysql> create procedure `` () set @a=5;
ERROR 1458 (42000): Incorrect routine name ''
mysql> create table `` (s1 int);
ERROR 1103 (42000): Incorrect table name ''
mysql> create table ` ` (s1 int);
ERROR 1103 (42000): Incorrect table name ' '
mysql> create procedure ` ` () set @a=5;
ERROR 1458 (42000): Incorrect routine name ' '
[24 Mar 2008 22:30] MySQL Verification Team
Thank you for the bug report.

Server version: 6.1.0-fk-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table t1 (s1 int primary key);
Query OK, 0 rows affected (0.01 sec)

mysql> create table t2 (s1 int constraint `` references t1(s1));
Query OK, 0 rows affected (0.00 sec)

mysql> show create table t2\G
*************************** 1. row ***************************
       Table: t2
Create Table: CREATE TABLE `t2` (
  `s1` int(11) DEFAULT NULL CONSTRAINT `` REFERENCES `t1` (`s1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> create table t3 (s1 int constraint ` ` references t1(s1));
Query OK, 0 rows affected (0.01 sec)

mysql> create procedure `` () set @a=5;
ERROR 1458 (42000): Incorrect routine name ''
mysql> create table `` (s1 int);
ERROR 1103 (42000): Incorrect table name ''
mysql>
[18 Apr 2008 19:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45625

ChangeSet@1.2606, 2008-04-18 23:00:57+04:00, dlenev@mockturtle.local +7 -0
  Fix for for bug #35524 "Foreign keys: constraint name can be incorrect".
  
  In --foreign-key-all-engines mode one was able to create foreign key
  constraints with empty name or name ending with space.
  
  This happened because we used check_identified_name() function instead
  of check_table_name() for checking of constraint names. The latter does
  all checks done by the former but also covers case with empty name and
  name ending with space. This fix simply uses correct function for
  checking of constraint names.
[20 Apr 2008 13:49] Dmitry Lenev
Fix for this bug was pushed into 6.1-fk tree. Since this tree is not publicly available yet I ams simply closing this bug.