openphoto/frontend — Issue #423: mysql: Specified key was too long; max key length is 1000 bytes
Author: gladiac
Created: 2012-01-02 21:00:24+00:00
State: open

Error from error log:

[Mon Jan 02 21:51:09 2012] [error] [client 77.190.6.33] {severity:crit, description:"Query error: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes - CREATE TABLE IF NOT EXISTS `elementTag` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `owner` varchar(255) NOT NULL,\n `type` enum('photo') NOT NULL,\n `element` varchar(6) NOT NULL DEFAULT 'photo',\n `tag` varchar(255) NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `id` (`owner`,`type`,`element`,`tag`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tag mapping table for photos (and videos in the future)';", additional:}

MySQL has a limit on keys for 1000 bytes. As the table is utf8 one char needs 4 bytes. the 'owner' and the 'tag' have together already (255 + 255) * 3 = 1503 bytes.

Smaller varchar values should just be fine.

See also http://bugs.mysql.com/bug.php?id=4541