Download & Extend

table docapi_library: specified key was too long

Project:Document Import API
Version:6.x-2.0-alpha2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

When trying to enable the docapi module I got this warning.

user warning: Specified key was too long; max key length is    [error]
1000 bytes
query: CREATE TABLE docapi_library (
`doc_id` INT unsigned NOT NULL auto_increment,
`plugin_id` INT unsigned NOT NULL,
`uid` INT unsigned NOT NULL,
`filemime` VARCHAR(255) NOT NULL DEFAULT
'text/plain',
`filename` VARCHAR(255) NOT NULL DEFAULT '',
`filepath` VARCHAR(255) NOT NULL,
`filesize` INT unsigned NOT NULL,
`created` DATETIME NOT NULL,
`changed` DATETIME NOT NULL,
PRIMARY KEY (doc_id),
INDEX filepath_name (filepath, filename)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ in
/home/kris/workspace/drupal6/includes/database.inc on line 517.

Obviously, there's something wrong with the SQL syntax.

Comments

#1

I should add that when I just run the code through mysql, I got no error at all!

#2

I got the same problem and it seems to be a bug of MySQL. In docapi.install you can find for this table there is a key defined:

'indexes' => array(
  'filepath_name' => array('filepath', 'filename'),
),

If you are using UTF-8 as default encoding, each character holds up to 3 bytes. So for this key, length of both fields is 255. Total length is 3*(255+255) = 1530, which is longer than 1000.

One solution is not to use UTF-8 if you do not need it.

I changed the code above to:

'indexes' => array(
  'filepath' => array('filepath'),
  'filename' => array('filename'),
),

which also make it successful to install. But who can tell me if this change leads any problem? (sorry I do not understand how database index works...)

#3

Same:

user warning: Specified key was too long; max key length is 1000 bytes query: CREATE TABLE drp_docapi_library ( `doc_id` INT unsigned NOT NULL auto_increment, `plugin_id` INT unsigned NOT NULL, `uid` INT unsigned NOT NULL, `filemime` VARCHAR(255) NOT NULL DEFAULT 'text/plain', `filename` VARCHAR(255) NOT NULL DEFAULT '', `filepath` VARCHAR(255) NOT NULL, `filesize` INT unsigned NOT NULL, `created` DATETIME NOT NULL, `changed` DATETIME NOT NULL, PRIMARY KEY (doc_id), INDEX filepath_name (filepath, filename) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /srv/www/vhosts/xxxxxxxxxxxxxx.ro/httpdocs/includes/database.inc on line 529.

not to use utf-8 is not a solution for me