Merge pull request #3825 from annando/index-length

Bugfix for "Index column size too large"
This commit is contained in:
Tobias Diekershoff 2017-10-25 07:16:45 +02:00 committed by GitHub
commit b8a8bb21d0
4 changed files with 25 additions and 27 deletions

View file

@ -43,7 +43,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.6-dev' ); define ( 'FRIENDICA_VERSION', '3.6-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1234 ); define ( 'DB_UPDATE_VERSION', 1235 );
/** /**
* @brief Constant with a HTML line break. * @brief Constant with a HTML line break.

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 3.6-dev (Asparagus) -- Friendica 3.6-dev (Asparagus)
-- DB_UPDATE_VERSION 1234 -- DB_UPDATE_VERSION 1235
-- ------------------------------------------ -- ------------------------------------------
@ -184,8 +184,8 @@ CREATE TABLE IF NOT EXISTS `contact` (
INDEX `addr_uid` (`addr`(32),`uid`), INDEX `addr_uid` (`addr`(32),`uid`),
INDEX `nurl_uid` (`nurl`(32),`uid`), INDEX `nurl_uid` (`nurl`(32),`uid`),
INDEX `nick_uid` (`nick`(32),`uid`), INDEX `nick_uid` (`nick`(32),`uid`),
INDEX `dfrn-id` (`dfrn-id`), INDEX `dfrn-id` (`dfrn-id`(64)),
INDEX `issued-id` (`issued-id`) INDEX `issued-id` (`issued-id`(64))
) DEFAULT COLLATE utf8mb4_general_ci; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
@ -529,11 +529,11 @@ CREATE TABLE IF NOT EXISTS `item` (
`rendered-html` mediumtext, `rendered-html` mediumtext,
`global` tinyint(1) NOT NULL DEFAULT 0, `global` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `guid` (`guid`), INDEX `guid` (`guid`(191)),
INDEX `uri` (`uri`), INDEX `uri` (`uri`(191)),
INDEX `parent` (`parent`), INDEX `parent` (`parent`),
INDEX `parent-uri` (`parent-uri`), INDEX `parent-uri` (`parent-uri`(191)),
INDEX `extid` (`extid`), INDEX `extid` (`extid`(191)),
INDEX `uid_id` (`uid`,`id`), INDEX `uid_id` (`uid`,`id`),
INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`), INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
INDEX `uid_created` (`uid`,`created`), INDEX `uid_created` (`uid`,`created`),
@ -546,7 +546,7 @@ CREATE TABLE IF NOT EXISTS `item` (
INDEX `authorid_created` (`author-id`,`created`), INDEX `authorid_created` (`author-id`,`created`),
INDEX `ownerid` (`owner-id`), INDEX `ownerid` (`owner-id`),
INDEX `uid_uri` (`uid`,`uri`(190)), INDEX `uid_uri` (`uid`,`uri`(190)),
INDEX `resource-id` (`resource-id`), INDEX `resource-id` (`resource-id`(191)),
INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)), INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)),
INDEX `uid_type_changed` (`uid`,`type`(190),`changed`), INDEX `uid_type_changed` (`uid`,`type`(190),`changed`),
INDEX `contactid_verb` (`contact-id`,`verb`(190)), INDEX `contactid_verb` (`contact-id`,`verb`(190)),
@ -568,7 +568,7 @@ CREATE TABLE IF NOT EXISTS `item_id` (
`service` varchar(255) NOT NULL DEFAULT '', `service` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`), INDEX `uid` (`uid`),
INDEX `sid` (`sid`), INDEX `sid` (`sid`(32)),
INDEX `service` (`service`(32)), INDEX `service` (`service`(32)),
INDEX `iid` (`iid`) INDEX `iid` (`iid`)
) DEFAULT COLLATE utf8mb4_general_ci; ) DEFAULT COLLATE utf8mb4_general_ci;
@ -610,7 +610,7 @@ CREATE TABLE IF NOT EXISTS `mail` (
INDEX `convid` (`convid`), INDEX `convid` (`convid`),
INDEX `uri` (`uri`(64)), INDEX `uri` (`uri`(64)),
INDEX `parent-uri` (`parent-uri`(64)), INDEX `parent-uri` (`parent-uri`(64)),
INDEX `contactid` (`contact-id`) INDEX `contactid` (`contact-id`(32))
) DEFAULT COLLATE utf8mb4_general_ci; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
@ -961,7 +961,7 @@ CREATE TABLE IF NOT EXISTS `spam` (
INDEX `uid` (`uid`), INDEX `uid` (`uid`),
INDEX `spam` (`spam`), INDEX `spam` (`spam`),
INDEX `ham` (`ham`), INDEX `ham` (`ham`),
INDEX `term` (`term`) INDEX `term` (`term`(32))
) DEFAULT COLLATE utf8mb4_general_ci; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --

View file

@ -130,10 +130,8 @@ function table_structure($table) {
} }
$column = $index["Column_name"]; $column = $index["Column_name"];
// On utf8mb4 a varchar index can only have a length of 191
// The "show index" command sometimes returns this value although this value wasn't added manually. if (($index["Sub_part"] != "")) {
// Because we don't want to add this number to every index, we ignore bigger numbers
if (($index["Sub_part"] != "") && (($index["Sub_part"] < 191) || ($index["Key_name"] == "PRIMARY"))) {
$column .= "(".$index["Sub_part"].")"; $column .= "(".$index["Sub_part"].")";
} }
@ -817,8 +815,8 @@ function db_definition() {
"addr_uid" => array("addr(32)", "uid"), "addr_uid" => array("addr(32)", "uid"),
"nurl_uid" => array("nurl(32)", "uid"), "nurl_uid" => array("nurl(32)", "uid"),
"nick_uid" => array("nick(32)", "uid"), "nick_uid" => array("nick(32)", "uid"),
"dfrn-id" => array("dfrn-id"), "dfrn-id" => array("dfrn-id(64)"),
"issued-id" => array("issued-id"), "issued-id" => array("issued-id(64)"),
) )
); );
$database["conv"] = array( $database["conv"] = array(
@ -1162,11 +1160,11 @@ function db_definition() {
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"guid" => array("guid"), "guid" => array("guid(191)"),
"uri" => array("uri"), "uri" => array("uri(191)"),
"parent" => array("parent"), "parent" => array("parent"),
"parent-uri" => array("parent-uri"), "parent-uri" => array("parent-uri(191)"),
"extid" => array("extid"), "extid" => array("extid(191)"),
"uid_id" => array("uid","id"), "uid_id" => array("uid","id"),
"uid_contactid_id" => array("uid","contact-id","id"), "uid_contactid_id" => array("uid","contact-id","id"),
"uid_created" => array("uid","created"), "uid_created" => array("uid","created"),
@ -1179,7 +1177,7 @@ function db_definition() {
"authorid_created" => array("author-id","created"), "authorid_created" => array("author-id","created"),
"ownerid" => array("owner-id"), "ownerid" => array("owner-id"),
"uid_uri" => array("uid", "uri(190)"), "uid_uri" => array("uid", "uri(190)"),
"resource-id" => array("resource-id"), "resource-id" => array("resource-id(191)"),
"contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), // "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
"uid_type_changed" => array("uid","type(190)","changed"), "uid_type_changed" => array("uid","type(190)","changed"),
"contactid_verb" => array("contact-id","verb(190)"), "contactid_verb" => array("contact-id","verb(190)"),
@ -1201,7 +1199,7 @@ function db_definition() {
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"uid" => array("uid"), "uid" => array("uid"),
"sid" => array("sid"), "sid" => array("sid(32)"),
"service" => array("service(32)"), "service" => array("service(32)"),
"iid" => array("iid"), "iid" => array("iid"),
) )
@ -1243,7 +1241,7 @@ function db_definition() {
"convid" => array("convid"), "convid" => array("convid"),
"uri" => array("uri(64)"), "uri" => array("uri(64)"),
"parent-uri" => array("parent-uri(64)"), "parent-uri" => array("parent-uri(64)"),
"contactid" => array("contact-id"), "contactid" => array("contact-id(32)"),
) )
); );
$database["mailacct"] = array( $database["mailacct"] = array(
@ -1594,7 +1592,7 @@ function db_definition() {
"uid" => array("uid"), "uid" => array("uid"),
"spam" => array("spam"), "spam" => array("spam"),
"ham" => array("ham"), "ham" => array("ham"),
"term" => array("term"), "term" => array("term(32)"),
) )
); );
$database["term"] = array( $database["term"] = array(

View file

@ -1,6 +1,6 @@
<?php <?php
define('UPDATE_VERSION' , 1234); define('UPDATE_VERSION' , 1235);
/** /**
* *