From 171613c0d0dbe1bdbc2979b8fe649e1e28ca7086 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 28 Sep 2005 11:50:50 +0000 Subject: [PATCH] bug #1262250, cannot change ENUM default value to empty --- ChangeLog | 4 ++++ libraries/common.lib.php | 4 ++-- libraries/relation.lib.php | 2 +- tbl_alter.php | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c48220947..168d03a09 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-09-28 Marc Delisle + * tbl_alter.php, libraries/common.lib.php, /relation.lib.php: + bug #1262250, cannot change ENUM default value to empty + 2005-09-27 Sebastian Mendel * libraries/sql_query_form.lib.php: removed unneeded variable, dont display bookmark selection fieldset if no bookmark exists diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 166055b10..fc35c125e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2737,7 +2737,7 @@ if (typeof(document.getElementById) != 'undefined' } // end function - function PMA_generateAlterTable($oldcol, $newcol, $full_field_type, $collation, $null, $default, $default_current_timestamp, $extra, $comment='') { + function PMA_generateAlterTable($oldcol, $newcol, $full_field_type, $collation, $null, $default, $default_current_timestamp, $extra, $comment='', $default_orig) { // $default_current_timestamp has priority over $default // TODO: on the interface, some js to clear the default value @@ -2758,7 +2758,7 @@ if (typeof(document.getElementById) != 'undefined' if ($default_current_timestamp && strpos(' ' . strtoupper($full_field_type),'TIMESTAMP') == 1) { $query .= ' DEFAULT CURRENT_TIMESTAMP'; // 0 is empty in PHP - } elseif (!empty($default) || $default == '0') { + } elseif (!empty($default) || $default == '0' || $default != $default_orig) { if (strtoupper($default) == 'NULL') { $query .= ' DEFAULT NULL'; } else { diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 467ddd160..7669cd707 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -611,7 +611,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut } $query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' - . PMA_generateAlterTable($col, $col, $types[$col], $collations[$col], $nulls[$col], $defaults[$col], $default_current_timestamps[$col], $extras[$col], $comment); + . PMA_generateAlterTable($col, $col, $types[$col], $collations[$col], $nulls[$col], $defaults[$col], $default_current_timestamps[$col], $extras[$col], $comment, ''); PMA_DBI_try_query($query, NULL, PMA_DBI_QUERY_STORE); return TRUE; diff --git a/tbl_alter.php b/tbl_alter.php index 4eed09f82..f2bad5a4f 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -67,7 +67,7 @@ if (isset($do_save_data)) { } // take care of native MySQL comments here - $query .= PMA_generateAlterTable($field_orig[$i], $field_name[$i], $full_field_type, (PMA_MYSQL_INT_VERSION >= 40100 && $field_collation[$i] != '' ? $field_collation[$i] : ''), $field_null[$i], $field_default[$i], (isset($field_default_current_timestamp[$i]) ? $field_default_current_timestamp[$i] : ''), $field_extra[$i], (PMA_MYSQL_INT_VERSION >= 40100 && isset($field_comments[$i]) && $field_comments[$i] != '' ? $field_comments[$i] : '')); + $query .= PMA_generateAlterTable($field_orig[$i], $field_name[$i], $full_field_type, (PMA_MYSQL_INT_VERSION >= 40100 && $field_collation[$i] != '' ? $field_collation[$i] : ''), $field_null[$i], $field_default[$i], (isset($field_default_current_timestamp[$i]) ? $field_default_current_timestamp[$i] : ''), $field_extra[$i], (PMA_MYSQL_INT_VERSION >= 40100 && isset($field_comments[$i]) && $field_comments[$i] != '' ? $field_comments[$i] : ''), $field_default_orig[$i]); } // end for // To allow replication, we first select the db to use and then run queries