bug #2895894 [structure] Empty default value not set properly

This commit is contained in:
Marc Delisle
2009-11-13 11:14:10 +00:00
parent ae360e4ec1
commit 5aced3414e
4 changed files with 24 additions and 18 deletions

View File

@@ -14,6 +14,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
- bug #2893931 [lang] Typo and empty message
+ [lang] Russian update, thanks to Victor Volkov
- bug #2823599 [edit] UUID Primary Key wrongly updated
- bug #2895894 [structure] Empty default value not set properly
3.2.3.0 (2009-10-30)
- patch #2856664 [export] Date, time, and datetime column types now export correctly to

View File

@@ -922,8 +922,9 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* create_table_fields
* -------------------
*
* For now, mostly used to detect the DEFAULT CURRENT_TIMESTAMP and
* Used to detect the DEFAULT CURRENT_TIMESTAMP and
* ON UPDATE CURRENT_TIMESTAMP clauses of the CREATE TABLE query.
* Also used to store the default value of the field.
* An array, each element is the identifier name.
* Note that for now, the timestamp_not_null element is created
* even for non-TIMESTAMP fields.
@@ -1898,6 +1899,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
if ($seen_create_table && $in_create_table_fields) {
if ($upper_data == 'DEFAULT') {
$seen_default = TRUE;
$create_table_fields[$current_identifier]['default_value'] = $arr[$i + 1]['data'];
}
}
}

View File

@@ -222,10 +222,16 @@ for ($i = 0; $i < $num_fields; $i++) {
case null:
if ($row['Null'] == 'YES') {
$row['DefaultType'] = 'NULL';
$row['DefaultValue'] = '';
// SHOW FULL FIELDS does not report the case when there is a DEFAULT value
// which is empty so we need to use the results of SHOW CREATE TABLE
} elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
$row['DefaultType'] = 'USER_DEFINED';
$row['DefaultValue'] = $row['Default'];
} else {
$row['DefaultType'] = 'NONE';
}
$row['DefaultValue'] = '';
}
break;
case 'CURRENT_TIMESTAMP':
$row['DefaultType'] = 'CURRENT_TIMESTAMP';
@@ -388,9 +394,9 @@ for ($i = 0; $i < $num_fields; $i++) {
'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
);
// for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
// for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
if ($type_upper == 'TIMESTAMP'
&& $default_current_timestamp
&& ! empty($default_current_timestamp)
&& isset($row['Default'])) {
$row['Default'] = '';
}

View File

@@ -176,26 +176,23 @@ if ($abort == false) {
$num_fields = count($fields_meta);
$action = 'tbl_alter.php';
// Get more complete field information
// For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
// but later, if the analyser returns more information, it
// could be executed for any MySQL version and replace
// the info given by SHOW FULL FIELDS FROM.
// Get more complete field information.
// For now, this is done to obtain MySQL 4.1.2+ new TIMESTAMP options
// and to know when there is an empty DEFAULT value.
// Later, if the analyser returns more information, it
// could be executed to replace the info given by SHOW FULL FIELDS FROM.
/**
* @todo put this code into a require()
* or maybe make it part of PMA_DBI_get_fields();
*/
if (PMA_MYSQL_INT_VERSION < 50025) {
// We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
// SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested
// in MySQL 4.0.25).
$show_create_table = PMA_DBI_fetch_value(
'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
0, 1);
$show_create_table = PMA_DBI_fetch_value('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0, 1);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
}
unset($show_create_table);
/**
* Form for changing properties.