CRM-16251 - Change DROP TABLE to DROP TEMPORARY TABLE
authorTim Otten <totten@civicrm.org>
Wed, 13 May 2015 21:31:55 +0000 (14:31 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 13 May 2015 21:31:55 +0000 (14:31 -0700)
If a table was created as a temporary table, then it should be dropped as a
temporary table. MySQL will accept DROP TABLE on temporary tables, but
doing so will break transactions.

CRM/Campaign/BAO/Query.php
CRM/Campaign/Form/Task/Interview.php
CRM/Contact/Import/Form/DataSource.php
CRM/Report/Form/Member/ContributionDetail.php

index 498a035a98915358d563d1378a57e08fa8f68490..a6e7b2f090302fae6decf8cf64b146f3fdd6af56 100755 (executable)
@@ -527,7 +527,7 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
 
         //create temporary table to store voter ids.
         $tempTableName = CRM_Core_DAO::createTempTableName('civicrm_survey_respondent');
-        CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS {$tempTableName}");
+        CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS {$tempTableName}");
 
         $query = "
      CREATE TEMPORARY TABLE {$tempTableName} (
index cfee48b717ac8ecc8f29fe00691a928fbae768df..42644658fbc46a4ba6812799d0d460c5880d5704 100755 (executable)
@@ -625,7 +625,7 @@ WHERE {$clause}
 
         //create temporary table to store voter ids.
         $tempTableName = CRM_Core_DAO::createTempTableName('civicrm_survey_respondent');
-        CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS {$tempTableName}");
+        CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS {$tempTableName}");
         $query = "
      CREATE TEMPORARY TABLE {$tempTableName} (
             id int unsigned NOT NULL AUTO_INCREMENT,
index 455cc344abd55cc10ace09beae34892a32ed416d..8c2eed2308a1a7012a6b67f43bb6c48ae1908888 100644 (file)
@@ -59,7 +59,7 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form {
     $daoTestPrivilege = new CRM_Core_DAO();
     $daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
     $daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
-    $daoTestPrivilege->query("DROP TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
+    $daoTestPrivilege->query("DROP TEMPORARY TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
     unset($errorScope);
 
     if ($daoTestPrivilege->_lastError) {
index f9a483dba95d52b411bba75cc974c9dfa6827cf0..9ecc911e5b477bdeeb9009d0626bbe16aeb38fa5 100644 (file)
@@ -534,7 +534,7 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
    */
   public function tempTable($applyLimit = TRUE) {
     // create temp table with contact ids,contribtuion id,membership id
-    $dropTempTable = 'DROP TABLE IF EXISTS civireport_membership_contribution_detail';
+    $dropTempTable = 'DROP TEMPORARY TABLE IF EXISTS civireport_membership_contribution_detail';
     CRM_Core_DAO::executeQuery($dropTempTable);
 
     $sql = 'CREATE TEMPORARY TABLE civireport_membership_contribution_detail