X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdbstructure.php;h=0fe157f329abab5282bacb8d052d380e827c765b;hb=1360a0a003ca6a2aa0ebaec92156d296e92bf14d;hp=c694014f68fae8b11b7d952bc538b1efac9b8f56;hpb=52f12ee28db97b29ce0f10c8ecf76144b80d4216;p=friendica.git diff --git a/include/dbstructure.php b/include/dbstructure.php index c694014f68..0fe157f329 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){ } // every admin could had different language - foreach ($adminlist as $admin) { $lang = (($admin['language'])?$admin['language']:'en'); push_lang($lang); @@ -56,11 +55,11 @@ function update_fail($update_id, $error_message){ $email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_msg = replace_macros($email_tpl, array( '$sitename' => $a->config['sitename'], - '$siteurl' => $a->get_baseurl(), + '$siteurl' => App::get_baseurl(), '$update' => DB_UPDATE_VERSION, '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION) )); - $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); + $subject=sprintf(t('Update Error at %s'), App::get_baseurl()); require_once('include/email.php'); $subject = email_header_encode($subject,'UTF-8'); mail($a->config['admin_email'], $subject, $email_msg, @@ -83,8 +82,9 @@ function table_structure($table) { if (dbm::is_result($indexes)) foreach ($indexes AS $index) { - if ($index["Index_type"] == "FULLTEXT") + if ($index["Index_type"] == "FULLTEXT") { continue; + } if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { $indexdata[$index["Key_name"]] = array('UNIQUE'); @@ -95,26 +95,31 @@ function table_structure($table) { // To avoid the need to add this to every index definition we just ignore it here. // Exception are primary indexes // Since there are some combindex primary indexes we use the limit of 180 here. - if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) + if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) { $column .= "(".$index["Sub_part"].")"; + } $indexdata[$index["Key_name"]][] = $column; } if (dbm::is_result($structures)) { - foreach($structures AS $field) { + foreach ($structures AS $field) { $fielddata[$field["Field"]]["type"] = $field["Type"]; - if ($field["Null"] == "NO") + if ($field["Null"] == "NO") { $fielddata[$field["Field"]]["not null"] = true; + } - if (isset($field["Default"])) + if (isset($field["Default"])) { $fielddata[$field["Field"]]["default"] = $field["Default"]; + } - if ($field["Extra"] != "") + if ($field["Extra"] != "") { $fielddata[$field["Field"]]["extra"] = $field["Extra"]; + } - if ($field["Key"] == "PRI") + if ($field["Key"] == "PRI") { $fielddata[$field["Field"]]["primary"] = true; + } } } return(array("fields"=>$fielddata, "indexes"=>$indexdata)); @@ -138,13 +143,15 @@ function print_structure($database, $charset) { function update_structure($verbose, $action, $tables=null, $definition=null) { global $a, $db; - if ($action) + if ($action) { set_config('system', 'maintenance', 1); + } - if (isset($a->config["system"]["db_charset"])) + if (isset($a->config["system"]["db_charset"])) { $charset = $a->config["system"]["db_charset"]; - else + } else { $charset = "utf8"; + } $errors = false; @@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { // Get the current structure $database = array(); - if (is_null($tables)) - $tables = q("show tables"); + if (is_null($tables)) { + $tables = q("SHOW TABLES"); + } foreach ($tables AS $table) { $table = current($table); @@ -164,21 +172,15 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } // Get the definition - if (is_null($definition)) + if (is_null($definition)) { $definition = db_definition($charset); - - // Ensure index conversion to unique removes duplicates - $sql_config = "SET session old_alter_table=1;"; - if ($verbose) - echo $sql_config."\n"; - if ($action) - @$db->q($sql_config); + } // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements if ((version_compare($db->server_info(), '5.7.4') >= 0) AND !(strpos($db->server_info(), 'MariaDB') !== false)) { $ignore = ''; - }else { + } else { $ignore = ' IGNORE'; } @@ -193,10 +195,33 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } $is_new_table = True; } else { - // Drop the index if it isn't present in the definition - // or the definition differ from current status - // and index name doesn't start with "local_" - foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) { + $is_unique = false; + $temp_name = $name; + + foreach ($structure["indexes"] AS $indexname => $fieldnames) { + if (isset($database[$name]["indexes"][$indexname])) { + $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]); + } else { + $current_index_definition = "__NOT_SET__"; + } + $new_index_definition = implode(",",$fieldnames); + if ($current_index_definition != $new_index_definition) { + if ($fieldnames[0] == "UNIQUE") { + $is_unique = true; + // Deactivated. See below for the reason + //if ($ignore == "") { + // $temp_name = "temp-".$name; + //} + } + } + } + + /* + * Drop the index if it isn't present in the definition + * or the definition differ from current status + * and index name doesn't start with "local_" + */ + foreach ($database[$name]["indexes"] as $indexname => $fieldnames) { $current_index_definition = implode(",",$fieldnames); if (isset($structure["indexes"][$indexname])) { $new_index_definition = implode(",",$structure["indexes"][$indexname]); @@ -205,39 +230,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') { $sql2=db_drop_index($indexname); - if ($sql3 == "") - $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2; - else + if ($sql3 == "") { + $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2; + } else { $sql3 .= ", ".$sql2; + } } } // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { $sql2=db_add_table_field($fieldname, $parameters); - if ($sql3 == "") - $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + if ($sql3 == "") { + $sql3 = "ALTER TABLE `".$temp_name."` ".$sql2; + } else { $sql3 .= ", ".$sql2; + } } else { // Compare the field definition $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); $new_field_definition = implode(",",$parameters); if ($current_field_definition != $new_field_definition) { $sql2=db_modify_table_field($fieldname, $parameters); - if ($sql3 == "") - $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + if ($sql3 == "") { + $sql3 = "ALTER TABLE `".$temp_name."` ".$sql2; + } else { $sql3 .= ", ".$sql2; + } } } } } - // Create the index if the index don't exists in database - // or the definition differ from the current status. - // Don't create keys if table is new + /* + * Create the index if the index don't exists in database + * or the definition differ from the current status. + * Don't create keys if table is new + */ if (!$is_new_table) { foreach ($structure["indexes"] AS $indexname => $fieldnames) { if (isset($database[$name]["indexes"][$indexname])) { @@ -250,7 +280,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { $sql2=db_create_index($indexname, $fieldnames); if ($sql2 != "") { if ($sql3 == "") - $sql3 = "ALTER" . $ignore . " TABLE `".$name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; else $sql3 .= ", ".$sql2; } @@ -260,13 +290,77 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { if ($sql3 != "") { $sql3 .= ";"; - if ($verbose) + if ($verbose) { + // Ensure index conversion to unique removes duplicates + if ($is_unique) { + // By now the alternative is commented out. + // This is a preparation for the time when we found a good SQL routine. + //if ($ignore != "") { + echo "SET session old_alter_table=1;\n"; + //} else { + // echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n"; + //} + } + echo $sql3."\n"; + if ($is_unique) { + // By now the alternative is commented out. + // This is a preparation for the time when we found a good SQL routine. + //if ($ignore != "") { + echo "SET session old_alter_table=0;\n"; + //} else { + // echo "INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;\n"; + // echo "DROP TABLE `".$name."`;\n"; + // echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n"; + //} + } + } + if ($action) { + // Ensure index conversion to unique removes duplicates + if ($is_unique) { + // By now the alternative is commented out. + // This is a preparation for the time when we found a good SQL routine. + //if ($ignore != "") { + $db->q("SET session old_alter_table=1;"); + //} else { + // $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;"); + // if (!dbm::is_result($r)) { + // $errors .= t('Errors encountered performing database changes.').$sql3.EOL; + // return $errors; + // } + //} + } + $r = @$db->q($sql3); - if (dbm::is_result($r)) + if (!dbm::is_result($r)) $errors .= t('Errors encountered performing database changes.').$sql3.EOL; + + if ($is_unique) { + // By now the alternative is commented out. + // This is a preparation for the time when we found a good SQL routine. + //if ($ignore != "") { + $db->q("SET session old_alter_table=0;"); + //} else { + // We have to check if "INSERT IGNORE" will work on newer MySQL versions + // $r = $db->q("INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;"); + // if (!dbm::is_result($r)) { + // $errors .= t('Errors encountered performing database changes.').$sql3.EOL; + // return $errors; + // } + // $r = $db->q("DROP TABLE `".$name."`;"); + // if (!dbm::is_result($r)) { + // $errors .= t('Errors encountered performing database changes.').$sql3.EOL; + // return $errors; + // } + // $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;"); + // if (!dbm::is_result($r)) { + // $errors .= t('Errors encountered performing database changes.').$sql3.EOL; + // return $errors; + // } + //} + } } } } @@ -367,10 +461,11 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { if ($names != "") $names .= ","; - if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) + if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")"; - else + } else { $names .= "`".dbesc($fieldname)."`"; + } } if ($indexname == "PRIMARY") { @@ -383,8 +478,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { } function db_index_suffix($charset, $reduce = 0) { - if ($charset != "utf8mb4") + if ($charset != "utf8mb4") { return ""; + } // On utf8mb4 indexes can only have a length of 191 $indexlength = 191 - $reduce; @@ -399,7 +495,7 @@ function db_definition($charset) { $database["addon"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""), "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), @@ -408,6 +504,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), + "name" => array("UNIQUE", "name"), ) ); $database["attach"] = array( @@ -444,14 +541,13 @@ function db_definition($charset) { ); $database["cache"] = array( "fields" => array( - "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), - "v" => array("type" => "text"), + "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"), + "v" => array("type" => "mediumtext"), "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( - "PRIMARY" => array("k".db_index_suffix($charset)), - "updated" => array("updated"), + "PRIMARY" => array("k"), "expire_mode_updated" => array("expire_mode", "updated"), ) ); @@ -484,13 +580,13 @@ function db_definition($charset) { $database["config"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), - "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), - "v" => array("type" => "text"), + "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), + "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), + "v" => array("type" => "mediumtext"), ), "indexes" => array( "PRIMARY" => array("id"), - "cat_k" => array("UNIQUE", "cat(30)","k(30)"), + "cat_k" => array("UNIQUE", "cat", "k"), ) ); $database["contact"] = array( @@ -562,25 +658,34 @@ function db_definition($charset) { "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"), "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), - "ffi_keyword_blacklist" => array("type" => "mediumtext"), + "ffi_keyword_blacklist" => array("type" => "text"), ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), - "addr_uid" => array("addr", "uid"), - "nurl" => array("nurl"), + "uid_name" => array("uid", "name"), + "self_uid" => array("self", "uid"), + "alias_uid" => array("alias(32)", "uid"), + "pending_uid" => array("pending", "uid"), + "blocked_uid" => array("blocked", "uid"), + "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"), + "uid_network_batch" => array("uid", "network", "batch(64)"), + "addr_uid" => array("addr(32)", "uid"), + "nurl_uid" => array("nurl(32)", "uid"), + "nick_uid" => array("nick(32)", "uid"), + "dfrn-id" => array("dfrn-id"), + "issued-id" => array("issued-id"), ) ); $database["conv"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), - "recips" => array("type" => "mediumtext"), + "recips" => array("type" => "text"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), - "subject" => array("type" => "mediumtext"), + "subject" => array("type" => "text"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -590,7 +695,7 @@ function db_definition($charset) { $database["deliverq"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""), "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), @@ -602,6 +707,7 @@ function db_definition($charset) { $database["event"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), + "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), @@ -623,7 +729,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), + "uid_start" => array("uid", "start"), ) ); $database["fcontact"] = array( @@ -648,7 +754,8 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "addr" => array("addr"), + "addr" => array("addr(32)"), + "url" => array("url"), ) ); $database["ffinder"] = array( @@ -671,7 +778,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "server" => array("server"), + "server" => array("server(32)"), ) ); $database["fsuggest"] = array( @@ -733,10 +840,11 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "nurl" => array("nurl"), - "name" => array("name"), - "nick" => array("nick"), - "addr" => array("addr"), + "nurl" => array("nurl(32)"), + "name" => array("name(32)"), + "nick" => array("nick(32)"), + "addr" => array("addr(32)"), + "hide_network_updated" => array("hide", "network", "updated"), "updated" => array("updated"), ) ); @@ -751,9 +859,8 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"), + "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"), "gcid" => array("gcid"), - "zcid" => array("zcid"), ) ); $database["group"] = array( @@ -778,7 +885,9 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid_gid_contactid" => array("uid","gid","contact-id"), + "contactid" => array("contact-id"), + "gid_contactid" => array("gid", "contact-id"), + "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"), ) ); $database["gserver"] = array( @@ -801,7 +910,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "nurl" => array("nurl"), + "nurl" => array("nurl(32)"), ) ); $database["hook"] = array( @@ -814,7 +923,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "hook_file_function" => array("hook(30)","file(60)","function(30)"), + "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"), ) ); $database["intro"] = array( @@ -914,26 +1023,14 @@ function db_definition($charset) { "uid_created" => array("uid","created"), "uid_unseen_contactid" => array("uid","unseen","contact-id"), "uid_network_received" => array("uid","network","received"), - "uid_received" => array("uid","received"), "uid_network_commented" => array("uid","network","commented"), - "uid_commented" => array("uid","commented"), - "uid_title" => array("uid","title"), "uid_thrparent" => array("uid","thr-parent"), "uid_parenturi" => array("uid","parent-uri"), - "uid_contactid_id" => array("uid","contact-id","id"), "uid_contactid_created" => array("uid","contact-id","created"), - "gcontactid_uid_created" => array("gcontact-id","uid","created"), "authorid_created" => array("author-id","created"), - "ownerid_created" => array("owner-id","created"), - "wall_body" => array("wall","body(6)"), - "uid_visible_moderated_created" => array("uid","visible","moderated","created"), "uid_uri" => array("uid", "uri"), - "uid_wall_created" => array("uid","wall","created"), "resource-id" => array("resource-id"), - "uid_type" => array("uid","type"), - "uid_starred_id" => array("uid","starred", "id"), - "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), - "uid_wall_parent_created" => array("uid","wall","parent","created"), + "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","changed"), "contactid_verb" => array("contact-id","verb"), "deleted_changed" => array("deleted","changed"), @@ -955,7 +1052,7 @@ function db_definition($charset) { "PRIMARY" => array("id"), "uid" => array("uid"), "sid" => array("sid"), - "service" => array("service"), + "service" => array("service(32)"), "iid" => array("iid"), ) ); @@ -992,12 +1089,10 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), - "guid" => array("guid"), + "uid_seen" => array("uid", "seen"), "convid" => array("convid"), - "reply" => array("reply"), - "uri" => array("uri"), - "parent-uri" => array("parent-uri"), + "uri" => array("uri(64)"), + "parent-uri" => array("parent-uri(64)"), ) ); $database["mailacct"] = array( @@ -1028,7 +1123,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid_mid" => array("uid","mid"), + "uid_mid" => array("UNIQUE", "uid","mid"), ) ); $database["notify"] = array( @@ -1053,7 +1148,10 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), + "hash_uid" => array("hash", "uid"), + "seen_uid_date" => array("seen", "uid", "date"), + "uid_date" => array("uid", "date"), + "uid_type_link" => array("uid", "type", "link"), ) ); $database["notify-threads"] = array( @@ -1066,31 +1164,29 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "master-parent-item" => array("master-parent-item"), - "receiver-uid" => array("receiver-uid"), ) ); $database["oembed"] = array( "fields" => array( - "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), - "content" => array("type" => "text"), + "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"), + "content" => array("type" => "mediumtext"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( - "PRIMARY" => array("url".db_index_suffix($charset)), + "PRIMARY" => array("url"), "created" => array("created"), ) ); $database["parsed_url"] = array( "fields" => array( - "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), + "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"), "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"), "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"), - "content" => array("type" => "text"), + "content" => array("type" => "mediumtext"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( - "PRIMARY" => array("url".db_index_suffix($charset), "guessing", "oembed"), + "PRIMARY" => array("url", "guessing", "oembed"), "created" => array("created"), ) ); @@ -1098,13 +1194,13 @@ function db_definition($charset) { "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), - "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), + "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), "v" => array("type" => "mediumtext"), ), "indexes" => array( "PRIMARY" => array("id"), - "uid_cat_k" => array("UNIQUE", "uid","cat(30)","k(30)"), + "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"), ) ); $database["photo"] = array( @@ -1136,25 +1232,25 @@ function db_definition($charset) { "PRIMARY" => array("id"), "uid_contactid" => array("uid", "contact-id"), "uid_profile" => array("uid", "profile"), - "uid_album_created" => array("uid", "album", "created"), - "resource-id" => array("resource-id"), - "guid" => array("guid"), + "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"), + "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"), + "resource-id" => array("resource-id(64)"), ) ); $database["poll"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "q0" => array("type" => "mediumtext"), - "q1" => array("type" => "mediumtext"), - "q2" => array("type" => "mediumtext"), - "q3" => array("type" => "mediumtext"), - "q4" => array("type" => "mediumtext"), - "q5" => array("type" => "mediumtext"), - "q6" => array("type" => "mediumtext"), - "q7" => array("type" => "mediumtext"), - "q8" => array("type" => "mediumtext"), - "q9" => array("type" => "mediumtext"), + "q0" => array("type" => "text"), + "q1" => array("type" => "text"), + "q2" => array("type" => "text"), + "q3" => array("type" => "text"), + "q4" => array("type" => "text"), + "q5" => array("type" => "text"), + "q6" => array("type" => "text"), + "q7" => array("type" => "text"), + "q8" => array("type" => "text"), + "q9" => array("type" => "text"), ), "indexes" => array( "PRIMARY" => array("id"), @@ -1176,7 +1272,7 @@ function db_definition($charset) { $database["process"] = array( "fields" => array( "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"), - "command" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( @@ -1231,7 +1327,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "hometown" => array("hometown"), + "uid_is-default" => array("uid", "is-default"), ) ); $database["profile_check"] = array( @@ -1304,19 +1400,18 @@ function db_definition($charset) { "indexes" => array( "PRIMARY" => array("id"), "uid" => array("uid"), - "term" => array("term"), ) ); $database["session"] = array( "fields" => array( "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), "data" => array("type" => "text"), "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), ), "indexes" => array( "PRIMARY" => array("id"), - "sid" => array("sid"), + "sid" => array("sid(64)"), "expire" => array("expire"), ) ); @@ -1368,12 +1463,9 @@ function db_definition($charset) { "indexes" => array( "PRIMARY" => array("tid"), "oid_otype_type_term" => array("oid","otype","type","term"), - "uid_term_tid" => array("uid","term","tid"), - "type_term" => array("type","term"), - "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"), - "otype_type_term_tid" => array("otype","type","term","tid"), - "uid_otype_type_url" => array("uid","otype","type","url"), - "guid" => array("guid"), + "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"), + "uid_otype_type_url" => array("uid","otype","type","url(64)"), + "guid" => array("guid(64)"), ) ); $database["thread"] = array( @@ -1407,15 +1499,10 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("iid"), - "created" => array("created"), - "commented" => array("commented"), "uid_network_commented" => array("uid","network","commented"), "uid_network_created" => array("uid","network","created"), "uid_contactid_commented" => array("uid","contact-id","commented"), "uid_contactid_created" => array("uid","contact-id","created"), - "uid_gcontactid_commented" => array("uid","gcontact-id","commented"), - "uid_gcontactid_created" => array("uid","gcontact-id","created"), - "wall_private_received" => array("wall","private","received"), "uid_created" => array("uid","created"), "uid_commented" => array("uid","commented"), ) @@ -1481,7 +1568,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("uid"), - "nickname" => array("nickname"), + "nickname" => array("nickname(32)"), ) ); $database["userd"] = array( @@ -1491,7 +1578,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "username" => array("username"), + "username" => array("username(32)"), ) ); $database["workerqueue"] = array( @@ -1505,7 +1592,6 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "created" => array("created"), ) ); @@ -1573,9 +1659,6 @@ function dbstructure_run(&$argv, &$argc) { echo "dumpsql dump database schema\n"; return; - - - } if (array_search(__file__,get_included_files())===0){