I get this when enabling the module:

user warning: Specified key was too long; max key length is 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 filepathfilename (filepath, filename) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /Applications/MAMP/htdocs/soc6x/includes/database.inc on line 509.

Comments

bradfordcp’s picture

I think this depends on the settings of your MySQL server, but as a precaution I will trim down the length of the name on the key on line 75 of docapi.install. Thanks!

bradfordcp’s picture

Status: Active » Fixed

I have created a new release with the fix in place. Please see ALPHA2 located at http://drupal.org/node/280342

agentrickard’s picture

This is a weird core limitation of MySQL. I'm surprised we haven't been bitten by it. SchemaAPI might want to handle some of this.

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

agentrickard’s picture

Status: Fixed » Needs work

Here's the corrected schema.

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

      'indexes' => array(
        'plugin_id' => array('plugin_id'),
        'mimetype' => array('mimetype'),
      ),

Unless we are not doing lookups on these columns, in which case, the indexes are ot necessary.

webchick’s picture

I disabled, uninstalled, cvs upped, reinstalled, and same error still.

agentrickard’s picture

Alpha2 had the same issue. See #4 for a fix. Schema update pending tomorrow.

vojnar’s picture

This problem still exists!!!
What do we have to do step by step to fix this issue?

Rgards,
Gabor

adam_b’s picture

Version: 6.x-2.x-dev » 6.x-2.0-alpha2

I'm having the same problem using Alpha2 - any progress, please?

the_g_bomb’s picture

This is to do with a bug in MySQL. It is listed in bug tracker as a "feature request". http://bugs.mysql.com/bug.php?id=4541 MySQL utf-8 key size bug

The problem is with using utf-8 in MySQL tables. Basically 3 bytes are reserved for every character and the compound key used. As there are 2 keys each requiring 255 characters, it ends up exceeding the maximum size of 1000 bytes set for keys.

The key 'filepath', 'filename' uses 3x (255+255) characters = 1530 bytes.

2 ways to jury rig this to get the module to install:

1. Reduce the lengths for 'filepath' and 'filename' from 255 to 165. Line 46 and 53 in docapi.install. This will mean the total key size will be lower than 1000 bytes (3x (165+165) = 990). (If you really want to you can then go into mysql and change the charset of that table from utf-8 to latin1 and return the sizes back to 255)

2. Change your MySQL config so that the default charset is Latin1 instead of UTF-8