Welcome, Guest
Username: Password: Remember me

TOPIC: BUILD ERROR - index too big not using regex length

BUILD ERROR - index too big not using regex length 16 Oct 2012 22:03 #4599

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi @admin,

I'm getting an error on installing a component I'm working on com_jstoresocial.
The Error
JInstaller: :Install: Error SQL DB function failed with error number 1071
Specified key was too long; max key length is 1000 bytes SQL=CREATE TABLE IF NOT EXISTS `[PREFIX]demo6159_products` ( `id` int(11) NOT NULL auto_increment, `params` text NOT NULL DEFAULT '', `title` VARCHAR(255) NOT NULL , `alias` VARCHAR(255) , `category` INT(11) , `product_code` VARCHAR(255) NOT NULL , PRIMARY KEY (`id`), UNIQUE(title, product_code) );
SQL =

CREATE TABLE IF NOT EXISTS `#__demo6159_products` (
	`id` int(11) NOT NULL auto_increment,
	`params` text NOT NULL DEFAULT '',
	`title` VARCHAR(255) NOT NULL ,
	`alias` VARCHAR(255) ,
	`category` INT(11) ,
	`product_code` VARCHAR(255) NOT NULL ,

	PRIMARY KEY  (`id`),
	UNIQUE(title, product_code)
);

Component Install: SQL error file DB function failed with error number 1071
Specified key was too long; max key length is 1000 bytes SQL=CREATE TABLE IF NOT EXISTS `[PREFIX]demo6159_products` ( `id` int(11) NOT NULL auto_increment, `params` text NOT NULL DEFAULT '', `title` VARCHAR(255) NOT NULL , `alias` VARCHAR(255) , `category` INT(11) , `product_code` VARCHAR(255) NOT NULL , PRIMARY KEY (`id`), UNIQUE(title, product_code) );
SQL =

CREATE TABLE IF NOT EXISTS `#__demo6159_products` (
	`id` int(11) NOT NULL auto_increment,
	`params` text NOT NULL DEFAULT '',
	`title` VARCHAR(255) NOT NULL ,
	`alias` VARCHAR(255) ,
	`category` INT(11) ,
	`product_code` VARCHAR(255) NOT NULL ,

	PRIMARY KEY  (`id`),
	UNIQUE(title, product_code)
);
I understand that unique keys can only be 1000 bytes however, I'm limiting the length of the field in question, product_code to between 2 and 10 alphanumeric (uppercase) chars in a custom regex.

Here's the regex that works perfectly
^[A-Z0-9]{2,10}$

As you can see in the CREATE TABLE, product_code is set to VARCHAR(255) as opposed to the 10 defined in the regex.

Am I right in thinking that for some reason, the maxlength defined in my regex, or indeed any custom regex is not accounted for in the CREATE TABLE statement?

Many thanks!!!

Gez

CONFIG
  1. Joomla Version: 2.5
  2. Environment: Sandbox
  3. Cook Version: 2.0
  4. JS: JQuery
  5. Form Style: Condensed
  6. Features: Maximum
  7. ToDo: No
  8. DB Automation: Model
  9. Timeout: 20 secs
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: BUILD ERROR - index too big not using regex length 16 Oct 2012 22:31 #4601

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Because, you might write your varchar size in the correct property : Length
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy

[FIXED] BUILD ERROR -index too big not using regex 16 Oct 2012 22:34 #4602

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
the only issue is, when I write that in length, it auto-creates the regex defining only the length defined. That way, I can't also specify alphanumeric chars, right? *****EDIT WRONG!!!

Yes, OK I get it... Just need to update the handler and expression again after specifying the length property!
END EDIT******

Thanks,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 16 Oct 2012 22:41 by JoomGuy. Reason: [fixed]
The administrator has disabled public write access.
Time to create page: 0.072 seconds

Get Started