diff --git a/ChangeLog b/ChangeLog
index 9d7362b3e..362855e3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,8 @@ danbarry
- bug #1845605 [i18n] translators.html still uses iso-8859-1
- bug #1823018 [charset] Edit(Delete) img-links pointing to wrong row
- bug #1826205 [export] Problems with yaml text export
+- bug #1344768 [database] create/alter table new field can not have empty string
+ as default
+ rfe #1840165 [interface] Enlarge column name field in vertical mode
+ patch #1847534 [interface] New "Inside field" in db search,
thanks to obiserver
@@ -63,6 +65,7 @@ danbarry
- bug #1955386 [session] Overriding session.hash_bits_per_character
- [interface] sanitize the table comments in table print view,
thanks to Norman Hippert
+- bug #1939031 Auto_Increment selected for TimeStamp by Default
- bug #1910621 [display] part 2: do not display a BINARY content as text
2.11.6.0 (2008-04-29)
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index 28898dad1..682102691 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -259,27 +259,23 @@ class PMA_Table {
* @param string $attribute
* @param string $collation
* @param string $null with 'NULL' or 'NOT NULL'
- * @param string $default default value
- * @param boolean $default_current_timestamp whether default value is
- * CURRENT_TIMESTAMP or not
- * this overrides $default value
+ * @param string $default_type whether default is CURRENT_TIMESTAMP,
+ * NULL, NONE, USER_DEFINED
+ * @param boolean $default_value default value for USER_DEFINED default type
* @param string $extra 'AUTO_INCREMENT'
* @param string $comment field comment
* @param array &$field_primary list of fields for PRIMARY KEY
* @param string $index
- * @param string $default_orig
* @return string field specification
*/
static function generateFieldSpec($name, $type, $length = '', $attribute = '',
- $collation = '', $null = false, $default = '',
- $default_current_timestamp = false, $extra = '', $comment = '',
+ $collation = '', $null = false, $default_type = 'USER_DEFINED',
+ $default_value = '', $extra = '', $comment = '',
&$field_primary, $index, $default_orig = false)
{
$is_timestamp = strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1;
- // $default_current_timestamp has priority over $default
-
/**
* @todo include db-name
*/
@@ -307,22 +303,25 @@ class PMA_Table {
}
}
- if ($default_current_timestamp && $is_timestamp) {
- $query .= ' DEFAULT CURRENT_TIMESTAMP';
- // auto_increment field cannot have a default value
- } elseif ($extra !== 'AUTO_INCREMENT'
- && $default !== false) {
- if (strtoupper($default) == 'NULL') {
- $query .= ' DEFAULT NULL';
- } elseif ($is_timestamp && $default === '0') {
- // a TIMESTAMP does not accept DEFAULT '0'
- // but DEFAULT 0 works
- $query .= ' DEFAULT ' . PMA_sqlAddslashes($default);
- } elseif ($type == 'BIT') {
- $query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default) . '\'';
- } else {
- $query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
- }
+ switch ($default_type) {
+ case 'USER_DEFINED' :
+ if ($is_timestamp && $default_value === '0') {
+ // a TIMESTAMP does not accept DEFAULT '0'
+ // but DEFAULT 0 works
+ $query .= ' DEFAULT 0';
+ } elseif ($type == 'BIT') {
+ $query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
+ } else {
+ $query .= ' DEFAULT \'' . PMA_sqlAddslashes($default_value) . '\'';
+ }
+ break;
+ case 'NULL' :
+ case 'CURRENT_TIMESTAMP' :
+ $query .= ' DEFAULT ' . $default_type;
+ break;
+ case 'NONE' :
+ default :
+ break;
}
if (!empty($extra)) {
@@ -440,15 +439,15 @@ class PMA_Table {
} // end of the 'PMA_Table::countRecords()' function
/**
- * @todo add documentation
+ * @see PMA_Table::generateFieldSpec()
*/
static public function generateAlter($oldcol, $newcol, $type, $length,
- $attribute, $collation, $null, $default, $default_current_timestamp,
- $extra, $comment='', &$field_primary, $index, $default_orig)
+ $attribute, $collation, $null, $default_type, $default_value,
+ $extra, $comment = '', &$field_primary, $index, $default_orig)
{
return PMA_backquote($oldcol) . ' '
. PMA_Table::generateFieldSpec($newcol, $type, $length, $attribute,
- $collation, $null, $default, $default_current_timestamp, $extra,
+ $collation, $null, $default_type, $default_value, $extra,
$comment, $field_primary, $index, $default_orig);
} // end function
diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php
index adbbbcd28..d00b8e82e 100644
--- a/libraries/tbl_properties.inc.php
+++ b/libraries/tbl_properties.inc.php
@@ -1,8 +1,9 @@
' . PMA_showMySQLDocu('SQL-Syntax', 'data-types') . '');
+$header_cells[] = $strType
+ . ($GLOBALS['cfg']['ReplaceHelpImg']
+ ? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
+ : '
' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
+ . '');
$header_cells[] = $strLengthSet . PMA_showHint($strSetEnumVal);
+$header_cells[] = $strDefault . PMA_showHint($strDefaultValueHelp);
$header_cells[] = $strCollation;
$header_cells[] = $strAttr;
$header_cells[] = $strNull;
-$header_cells[] = $strDefault . PMA_showHint($strDefaultValueHelp);
-$header_cells[] = $strExtra;
-
-
// lem9: We could remove this 'if' and let the key information be shown and
// editable. However, for this to work, tbl_alter must be modified to use the
// key fields, as tbl_addfield does.
if (!$is_backup) {
- $header_cells[] = $cfg['PropertiesIconic'] ? '
' : $strPrimary;
- $header_cells[] = $cfg['PropertiesIconic'] ? '
' : $strIndex;
- $header_cells[] = $cfg['PropertiesIconic'] ? '
' : $strUnique;
- $header_cells[] = '---';
- $header_cells[] = $cfg['PropertiesIconic'] ? '
' : $strIdxFulltext;
+ $header_cells[] = $strIndex;
}
+$header_cells[] = 'A_I';
+
require_once './libraries/relation.lib.php';
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
@@ -130,91 +130,138 @@ if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
$header_cells[] = $strMIME_MIMEtype;
$header_cells[] = $strMIME_transformation;
- $header_cells[] = $strMIME_transformation_options . PMA_showHint($strMIME_transformation_options_note . $hint);
+ $header_cells[] = $strMIME_transformation_options
+ . PMA_showHint($strMIME_transformation_options_note . $hint);
}
// garvin: workaround for field_fulltext, because its submitted indizes contain
// the index as a value, not a key. Inserted here for easier maintaineance
// and less code to change in existing files.
if (isset($field_fulltext) && is_array($field_fulltext)) {
- foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
+ foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
$submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
}
}
-for ($i = 0; $i <= $num_fields; $i++) {
+for ($i = 0; $i < $num_fields; $i++) {
if (! empty($regenerate)) {
// An error happened with previous inputs, so we will restore the data
// to embed it once again in this form.
- $row['Field'] = (isset($field_name[$i]) ? $field_name[$i] : FALSE);
- $row['Type'] = (isset($field_type[$i]) ? $field_type[$i] : FALSE);
- $row['Collation'] = (isset($field_collation[$i]) ? $field_collation[$i] : '');
- $row['Null'] = (isset($field_null[$i]) ? $field_null[$i] : '');
+ $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
+ $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
+ $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
+ $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
- if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
+ if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
$row['Key'] = 'PRI';
- } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
+ } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
$row['Key'] = 'MUL';
- } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
+ } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
$row['Key'] = 'UNI';
+ } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
+ $row['Key'] = 'FULLTEXT';
} else {
$row['Key'] = '';
}
- $row['Default'] = (isset($field_default[$i]) ? $field_default[$i] : FALSE);
- $row['Extra'] = (isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
- $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
+ $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'USER_DEFINED');
+ $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
- $submit_length = (isset($field_length[$i]) ? $field_length[$i] : FALSE);
- $submit_attribute = (isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
+ switch ($row['DefaultType']) {
+ case 'NONE' :
+ $row['Default'] = null;
+ break;
+ case 'USER_DEFINED' :
+ $row['Default'] = $row['DefaultValue'];
+ break;
+ case 'NULL' :
+ case 'CURRENT_TIMESTAMP' :
+ $row['Default'] = $row['DefaultType'];
+ break;
+ }
+
+ $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
+ $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
- $submit_default_current_timestamp = (isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
+ $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
+ $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
- if (isset($field_comments[$i])) {
- $comments_map[$row['Field']] = $field_comments[$i];
+ $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
+
+ if (isset($_REQUEST['field_comments'][$i])) {
+ $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
}
- if (isset($field_mimetype[$i])) {
- $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
+ if (isset($_REQUEST['field_mimetype'][$i])) {
+ $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
}
- if (isset($field_transformation[$i])) {
- $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
+ if (isset($_REQUEST['field_transformation'][$i])) {
+ $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
}
- if (isset($field_transformation_options[$i])) {
- $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
+ if (isset($_REQUEST['field_transformation_options'][$i])) {
+ $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
}
} elseif (isset($fields_meta[$i])) {
$row = $fields_meta[$i];
+ switch ($row['Default']) {
+ case null:
+ if ($row['Null'] == 'YES') {
+ $row['DefaultType'] = 'NULL';
+ } else {
+ $row['DefaultType'] = 'NONE';
+ }
+ $row['DefaultValue'] = '';
+ break;
+ case 'CURRENT_TIMESTAMP':
+ $row['DefaultType'] = 'CURRENT_TIMESTAMP';
+ $row['DefaultValue'] = '';
+ break;
+ default:
+ $row['DefaultType'] = 'USER_DEFINED';
+ $row['DefaultValue'] = $row['Default'];
+ break;
+ }
}
- if (isset($row) && isset($row['Type'])) {
+ if (isset($row['Type'])) {
$type_and_length = PMA_extract_type_length($row['Type']);
if ($type_and_length['type'] == 'bit') {
$row['Default'] = PMA_printable_bit_value($row['Default'], $type_and_length['length']);
}
}
- // Cell index: If certain fields get left out, the counter shouldn't chage.
+ // Cell index: If certain fields get left out, the counter shouldn't change.
$ci = 0;
// Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
// has to be incremented ($ci_offset++)
$ci_offset = -1;
+ // old column name
if ($is_backup) {
- $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
- $content_cells[$i][$ci] = "\n" . '' . "\n";
- } else {
- $content_cells[$i][$ci] = '';
+ if (! empty($true_selected[$i])) {
+ $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
+ } elseif (isset($row['Field'])) {
+ $_form_params['field_orig[' . $i . ']'] = $row['Field'];
+ } else {
+ $_form_params['field_orig[' . $i . ']'] = '';
+ }
}
- $content_cells[$i][$ci] .= "\n" . '';
+ // column name
+ $content_cells[$i][$ci] = '';
$ci++;
- $content_cells[$i][$ci] = '';
$ci++;
+ // old column length
if ($is_backup) {
- $content_cells[$i][$ci] = "\n" . '';
- } else {
- $content_cells[$i][$ci] = '';
+ $_form_params['field_length_orig[' . $i . ']'] = $length;
}
+ // column length
if (preg_match('@^(set|enum)$@i', $type)) {
$binary = 0;
$unsigned = 0;
@@ -292,20 +339,75 @@ for ($i = 0; $i <= $num_fields; $i++) {
$length_to_display = htmlspecialchars($length);
} else {
$length_to_display = $length;
- $binary = FALSE;
+ $binary = false;
$unsigned = stristr($row['Type'], 'unsigned');
$zerofill = stristr($row['Type'], 'zerofill');
}
- $content_cells[$i][$ci] .= "\n" . '' . "\n";
+ $content_cells[$i][$ci] = '';
$ci++;
+ // column default
+ /**
+ * having NULL enabled does not implicit having Default with NULL
+ *
+ if (isset($row)
+ && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
+ $row['Default'] = 'NULL';
+ }
+ */
+
+ // old column default
+ if ($is_backup) {
+ $_form_params['field_default_orig[' . $i . ']'] =
+ (isset($row['Default']) ? $row['Default'] : '');
+ }
+
+ $default_options = array(
+ 'USER_DEFINED' => 'strUserDefined',
+ 'NONE' => $strNone,
+ 'NULL' => 'NULL',
+ 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
+ );
+
+ // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
+ if ($type_upper == 'TIMESTAMP'
+ && $default_current_timestamp
+ && isset($row['Default'])) {
+ $row['Default'] = '';
+ }
+
+ $content_cells[$i][$ci] = '';
+ $content_cells[$i][$ci] .= '
';
+ $content_cells[$i][$ci] .= '';
+ $ci++;
+
+ // column collation
$tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
- $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
+ $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
+ PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
+ 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
unset($tmp_collation);
$ci++;
- $content_cells[$i][$ci] = '