[Phpmyadmin-devel] Bug #449858, Error Changing Column DataType

Ignacio Vazquez-Abrams ignacio at openservices.net
Sat Aug 11 01:59:39 CEST 2001


On Fri, 10 Aug 2001, Robin Johnson wrote:

> Could somebody else please have a look at the sf bug page for this one,
> and see if they have any other possible solutions that could be used for
> this bug? I'll give 12 hours before I work on it.

How does this patch look?

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>
-------------- next part --------------
--- tbl_alter.php3.orig	Fri Aug 10 18:44:28 2001
+++ tbl_alter.php3	Fri Aug 10 18:48:28 2001
@@ -28,9 +28,27 @@
         $query = '';
     }
     $query .= ' ' . backquote($field_orig[0]) . ' ' . backquote($field_name[0]) . ' ' . $field_type[0] . ' ';
-    if ($field_length[0] != '') {
-        $query .= '(' . $field_length[0] . ') ';
-    }
+    // Some field types shouldn't have lengths
+    switch (strtoupper($field_type[0]))
+    {
+        case 'DATE':
+        case 'DATETIME':
+        case 'TIME':
+        case 'TINYBLOB':
+        case 'TINYTEXT':
+        case 'BLOB':
+        case 'TEXT':
+        case 'MEDIUMBLOB':
+        case 'MEDIUMTEXT':
+        case 'LONGBLOB':
+        case 'LONGTEXT':
+            break;
+
+        default:
+            if ($field_length[0] != '') {
+                $query .= '(' . $field_length[0] . ') ';
+            };
+    };
     if ($field_attribute[0] != '') {
         $query .= $field_attribute[0] . ' ';
     }


More information about the Developers mailing list