Bug #6166 index prefix length of 0 not rejected
Submitted: 19 Oct 2004 21:27 Modified: 26 Oct 2004 7:03
Reporter: Paul Dubois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0,4.1,... OS:
Assigned to: Sergei Glukhov CPU Architecture:Any

[19 Oct 2004 21:27] Paul Dubois
Description:
MySQL correctly catches when you attempt to index a column prefix
that is longer than the column itself: 

mysql> create table t (c char(10), index (c(11)));
ERROR 1089 (HY000): Incorrect sub part key; the used key part isn't a string,
the used length is longer than the key part, or the storage engine doesn't
support unique sub keys

However, it doesn't catch when the prefix length is 0.  Instead, it acts as
though no prefix was specified.

mysql> create table t (c char(10), index (c(0)));
Query OK, 0 rows affected (0.01 sec)

mysql> show create table t;
+-------
+--------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------
+--------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `c` char(10) default NULL,   
  KEY `c` (`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.08 sec)

How to repeat:
See above.
[22 Oct 2004 13:37] Sergei Glukhov
ChangeSet
  1.2124 04/10/22
  Fix for bug #6166: index prefix length of 0 not rejected
[26 Oct 2004 7:03] Sergei Glukhov
Fixed in 4.1 source tree
ChangeSet
  1.2043 04/10/26
  Fix for bug #6166: index prefix length of 0 not rejected