tests: fix Specified key was too long; in a schema
authorAntoine Musso <hashar@free.fr>
Thu, 15 Mar 2018 21:23:40 +0000 (22:23 +0100)
committerAntoine Musso <hashar@free.fr>
Thu, 15 Mar 2018 21:28:41 +0000 (22:28 +0100)
MediaWikiTestCaseSchemaTest.sql comes with two varchar(255) combined
into a PRIMARY KEY.

That caused the testsuite to fail creating that imagelinks table with:
Error: 1071 Specified key was too long; max key length is 767 bytes

That is the limit for innodb and when using UTF8 it allows up to 3 bytes
per characters. Hence the key can be (255+255)*3 = 1530.

One can tune MySQL to bump the limit to ~ 3k with:
    innodb_large_prefix            = 1

Seems easier to just use smaller fields.

Change-Id: Ic4965b9eddc7ad9105c896e678ab9048ce0be8ef

tests/phpunit/tests/MediaWikiTestCaseSchemaTest.sql

index 43e8e9b..58460e2 100644 (file)
@@ -7,7 +7,7 @@ CREATE TABLE /*_*/MediaWikiTestCaseTestTable (
 CREATE TABLE /*_*/imagelinks (
   il_from int NOT NULL DEFAULT 0,
   il_from_namespace int NOT NULL DEFAULT 0,
-  il_to varchar(255) NOT NULL DEFAULT '',
-  il_frobniz varchar(255) NOT NULL DEFAULT 'FROB',
+  il_to varchar(127) NOT NULL DEFAULT '',
+  il_frobniz varchar(127) NOT NULL DEFAULT 'FROB',
   PRIMARY KEY (il_from,il_to)
 ) /*$wgDBTableOptions*/;