Doing a clean installation (with any old table deleted) of version 6.x-0-3, I got this ugly error:

* user warning: Incorrect table definition; there can be only one auto column and it must be defined as a key query: CREATE TABLE node_limit_role ( `lid` INT NOT NULL, `rid` INT unsigned NOT NULL auto_increment, PRIMARY KEY (lid, rid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /*******/includes/database.inc on line 515.

Deleted second key in node_limit_role and node_limit_user install files, and defined rid and uid as integers instead than serial (other error about repeated rid when created a second rule when serial).

CommentFileSizeAuthor
#2 437730_pk.patch1.54 KBnnewton
node_limit_install.patch1.49 KBjcmarco

Comments

dungiis’s picture

I am running drupal 6.13 and get the problem

user warning: Incorrect table definition; there can be only one auto column and it must be defined as a key query: CREATE TABLE node_limit_role ( `lid` INT NOT NULL, `rid` INT unsigned NOT NULL auto_increment, PRIMARY KEY (lid, rid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in C:\Program Files\Apache Group\Apache2\htdocs\drupal\includes\database.inc on line 517.

I also apply the patch as recommend but it seems not work as i expected

nnewton’s picture

StatusFileSize
new1.54 KB

Attached is a patch for this issue.

I've only tested the node_limit_role section, but the other is a direct translation. The issue here is that while MyISAM doesn't particularly care, InnoDB requires the auto_increment column be the PK and if its in a multi-column index, it should be the leading column. This module violates that. To fix this I've switched the PK to just rid/uid and added a secondary multi-column index as I saw a few queries in this module that use it.

duaelfr’s picture

Assigned: Unassigned » duaelfr

This has been pushed to 6.x branch but I keeped the double primary keys until there is no feature to apply a limit to more than one user/role

duaelfr’s picture

Status: Needs review » Closed (fixed)

No news, good news