WHERE TABLE_SCHEMA = '" . CRM_Core_DAO::getDatabaseName() . "'
AND TABLE_NAME LIKE 'civicrm_%'
AND TABLE_NAME NOT LIKE 'civicrm_import_job_%'
- AND TABLE_NAME NOT LIKE '%temp'
+ AND TABLE_NAME NOT LIKE '%_temp%'
");
while ($dao->fetch()) {
AND TABLE_SCHEMA = '" . CRM_Core_DAO::getDatabaseName() . "'
AND TABLE_NAME LIKE 'civicrm_%'
AND TABLE_NAME NOT LIKE 'civicrm_import_job_%'
- AND TABLE_NAME NOT LIKE '%temp'
+ AND TABLE_NAME NOT LIKE '%_temp%'
");
}
* Test the function designed to find myIsam tables.
*/
public function testMyISAMCheck() {
+ // Cleanup previous, failed tests.
+ CRM_Core_DAO::executeQuery('DROP TABLE IF EXISTS civicrm_my_isam');
+
+ // A manually created MyISAM table should raise a redflag.
$this->assertEquals(0, CRM_Core_DAO::isDBMyISAM());
CRM_Core_DAO::executeQuery('CREATE TABLE civicrm_my_isam (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM');
$this->assertEquals(1, CRM_Core_DAO::isDBMyISAM());
CRM_Core_DAO::executeQuery('DROP TABLE civicrm_my_isam');
+
+ // A temp table should not raise flag (static naming).
+ $tempName = CRM_Core_DAO::createTempTableName('civicrm', FALSE);
+ $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM());
+ CRM_Core_DAO::executeQuery("CREATE TABLE $tempName (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM");
+ $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); // Ignore temp tables
+ CRM_Core_DAO::executeQuery("DROP TABLE $tempName");
+
+ // A temp table should not raise flag (randomized naming).
+ $tempName = CRM_Core_DAO::createTempTableName('civicrm', TRUE);
+ $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM());
+ CRM_Core_DAO::executeQuery("CREATE TABLE $tempName (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM");
+ $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); // Ignore temp tables
+ CRM_Core_DAO::executeQuery("DROP TABLE $tempName");
}
}