Skip to content
Permalink
Browse files

Merge PR #3564: Don't drop indices on MySQL

  • Loading branch information...
davidebeatrici committed Dec 18, 2018
2 parents d7ef517 + e5aadf2 commit 16c1145b6fb0df4172f343f90ba115803f816798
Showing with 0 additions and 25 deletions.
  1. +0 −25 src/murmur/ServerDB.cpp
@@ -439,31 +439,6 @@ ServerDB::ServerDB() {
if (key.first.startsWith(Meta::mp.qsDBPrefix))
ServerDB::exec(query, QString::fromLatin1("ALTER TABLE `%1` DROP FOREIGN KEY `%2`").arg(key.first).arg(key.second), true);
}


SQLPREP("SELECT TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA=? AND CONSTRAINT_TYPE='UNIQUE'");
query.addBindValue(Meta::mp.qsDatabase);
SQLEXEC();
while (query.next())
qlIndexes << qsp(query.value(0).toString(), query.value(1).toString());

foreach(const qsp &key, qlIndexes) {
if (key.first.startsWith(Meta::mp.qsDBPrefix))
ServerDB::exec(query, QString::fromLatin1("ALTER TABLE `%1` DROP INDEX `%2`").arg(key.first).arg(key.second), true);
}

qlIndexes.clear();

SQLPREP("SELECT DISTINCT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA=? AND INDEX_NAME != 'PRIMARY';");
query.addBindValue(Meta::mp.qsDatabase);
SQLEXEC();
while (query.next())
qlIndexes << qsp(query.value(0).toString(), query.value(1).toString());

foreach(const qsp &key, qlIndexes) {
if (key.first.startsWith(Meta::mp.qsDBPrefix))
ServerDB::exec(query, QString::fromLatin1("ALTER TABLE `%1` DROP INDEX `%2`").arg(key.first).arg(key.second), true);
}
}
SQLDO("CREATE TABLE `%1servers`(`server_id` INTEGER PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin");

0 comments on commit 16c1145

Please sign in to comment.
You can’t perform that action at this time.