diff --git a/boot.php b/boot.php index cd6db384a..e95cbc9d2 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1212 ); +define ( 'DB_UPDATE_VERSION', 1213 ); /** * @brief Constant with a HTML line break. diff --git a/include/dbstructure.php b/include/dbstructure.php index 9a84cfbc8..c1dc1ba87 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -208,9 +208,10 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { if ($current_index_definition != $new_index_definition) { if ($fieldnames[0] == "UNIQUE") { $is_unique = true; - if ($ignore == "") { - $temp_name = "temp-".$name; - } + // Deactivated. See below for the reason + //if ($ignore == "") { + // $temp_name = "temp-".$name; + //} } } } @@ -292,44 +293,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { if ($verbose) { // Ensure index conversion to unique removes duplicates if ($is_unique) { - if ($ignore != "") { + // 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 "DROP TABLE IF EXISTS `".$temp_name."`;\n"; - echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n"; - } + //} else { + // echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n"; + //} } echo $sql3."\n"; if ($is_unique) { - if ($ignore != "") { + // 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"; - } + //} 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) { - if ($ignore != "") { + // 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("DROP TABLE IF EXISTS `".$temp_name."`;"); - if (!dbm::is_result($r)) { - $errors .= t('Errors encountered performing database changes.').$sql3.EOL; - return $errors; - } - $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; - } - } + //} 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); @@ -337,25 +338,28 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { $errors .= t('Errors encountered performing database changes.').$sql3.EOL; if ($is_unique) { - if ($ignore != "") { + // 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 { - $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; - } - } + //} 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; + // } + //} } } } @@ -1260,7 +1264,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "poll_id" => array("poll_id"), + "poll_id" => array("UNIQUE", "poll_id"), "choice" => array("choice"), ) ); diff --git a/update.php b/update.php index 058536d82..25d6cb9cb 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@