]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11555 temporary patch for too long index on mysql - in mysql the limit is 333...
authorskodak <skodak>
Tue, 2 Oct 2007 16:20:45 +0000 (16:20 +0000)
committerskodak <skodak>
Tue, 2 Oct 2007 16:20:45 +0000 (16:20 +0000)
move the gradebook cleanup to the end of upgrade.php - please keep it there

lib/db/install.xml
lib/db/upgrade.php
version.php

index b5313dbedbbaafcf6634369f518baa8fb9a94b85..8811be30d34f74a897ac57e03aa44352f85b8741 100644 (file)
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
-        <INDEX NAME="typename" UNIQUE="true" FIELDS="flagtype, name"/>
+        <INDEX NAME="flagtype" UNIQUE="false" FIELDS="flagtype"/>
+        <INDEX NAME="name" UNIQUE="false" FIELDS="name"/>
       </INDEXES>
     </TABLE>
   </TABLES>
index b0e08993cef8aa6c6b842ceb6ebfc57fdbe23738..25594cb8d4a2d5a1b097a08e0b0a771bdafedd16 100644 (file)
@@ -2258,7 +2258,6 @@ function xmldb_main_upgrade($oldversion=0) {
 
     if ($result && $oldversion < 2007100100) {
 
-
     /// Define table cache_flags to be created
         $table = new XMLDBTable('cache_flags');
 
@@ -2273,31 +2272,19 @@ function xmldb_main_upgrade($oldversion=0) {
     /// Adding keys to table cache_flags
         $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
 
+    /*
+     * Note: mysql can not create indexes on text fields larger than 333 chars! 
+     */
+
     /// Adding indexes to table cache_flags
-        $table->addIndexInfo('typename', XMLDB_INDEX_UNIQUE, array('flagtype', 'name'));
+        $table->addIndexInfo('flagtype', XMLDB_INDEX_NOTUNIQUE, array('flagtype'));
+        $table->addIndexInfo('name', XMLDB_INDEX_NOTUNIQUE, array('name'));
 
     /// Launch create table for cache_flags
-        $result = $result && create_table($table);
-    }
-
-
-/*
-    /// drop old gradebook tables
-    if ($result && $oldversion < xxxxxxxx) {
-        $tables = array('grade_category',
-                        'grade_item',
-                        'grade_letter',
-                        'grade_preferences',
-                        'grade_exceptions');
-
-        foreach ($tables as $table) {
-            $table = new XMLDBTable($table);
-            if (table_exists($table)) {
-                drop_table($table);
-            }
+        if (!table_exists($table)) {
+            $result = $result && create_table($table);
         }
     }
-*/
 
     if ($oldversion < 2007100300) {
         //
@@ -2318,6 +2305,51 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && add_field($table, $field);
     }
 
+    if ($result && $oldversion < 2007100301) {
+
+    /// Define table cache_flags to be created
+        $table = new XMLDBTable('cache_flags');
+        $index = new XMLDBIndex('typename');
+        if (index_exists($table, $index)) {
+            $result = $result && drop_index($table, $index);
+        }
+        
+        $table = new XMLDBTable('cache_flags');
+        $index = new XMLDBIndex('flagtype');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('flagtype'));
+        if (!index_exists($table, $index)) {
+            $result = $result && add_index($table, $index);
+        }
+
+        $table = new XMLDBTable('cache_flags');
+        $index = new XMLDBIndex('name');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('name'));
+        if (!index_exists($table, $index)) {
+            $result = $result && add_index($table, $index);
+        }
+    }
+
+
+
+/* NOTE: please keep this at the end of upgrade file for now ;-)
+    /// drop old gradebook tables
+    if ($result && $oldversion < xxxxxxxx) {
+        $tables = array('grade_category',
+                        'grade_item',
+                        'grade_letter',
+                        'grade_preferences',
+                        'grade_exceptions');
+
+        foreach ($tables as $table) {
+            $table = new XMLDBTable($table);
+            if (table_exists($table)) {
+                drop_table($table);
+            }
+        }
+    }
+*/
+
+
     return $result;
 }
 
index 14db001e145f31f4c983e31df9ec8e0ff159062c..69209bf1758de46148a750e3d6593b3e1d996e51 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2007100300;  // YYYYMMDD = date
+    $version = 2007100301;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 Beta +';   // Human-friendly version name