Skip to content
Extraits de code Groupes Projets
Valider c69e250b rédigé par benakamoorthi's avatar benakamoorthi
Parcourir les fichiers

Fixes #3289, don't optimize InnoDB tables.

git-svn-id: http://dev.piwik.org/svn/trunk@7096 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 92dd264c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -159,7 +159,23 @@ class Piwik_Sql
$tables = array($tables);
}
return self::query("OPTIMIZE TABLE ".implode(',', $tables));
// filter out all InnoDB tables
$nonInnoDbTables = array();
foreach (Piwik_FetchAll("SHOW TABLE STATUS") as $row)
{
if (strtolower($row['Engine']) != 'innodb' && in_array($row['Name'], $tables))
{
$nonInnoDbTables[] = $row['Name'];
}
}
if (empty($nonInnoDbTables))
{
return false;
}
// optimize the tables
return self::query("OPTIMIZE TABLE ".implode(',', $nonInnoDbTables));
}
/**
......
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @version $Id$
*/
class UnzipTest extends DatabaseTestCase
{
public function setUp()
{
parent::setUp();
// create two myisam tables
Piwik_Exec("CREATE TABLE table1 (a INT) ENGINE=MYISAM");
Piwik_Exec("CREATE TABLE table2 (b INT) ENGINE=MYISAM");
// create two innodb tables
Piwik_Exec("CREATE TABLE table3 (c INT) ENGINE=InnoDB");
Piwik_Exec("CREATE TABLE table4 (d INT) ENGINE=InnoDB");
}
public function tearDown()
{
parent::tearDown();
}
/**
* @group Core
* @group Unzip
*/
public function testOptimize()
{
// make sure optimizing myisam tables works
$this->assertTrue(Piwik_OptimizeTables(array('table1', 'table2')) !== false);
// make sure optimizing both myisam & innodb results in optimizations
$this->assertTrue(Piwik_OptimizeTables(array('table1', 'table2', 'table3', 'table4')) !== false);
// make sure innodb tables are skipped
$this->assertTrue(Piwik_OptimizeTables(array('table3', 'table4')) === false);
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter