From 19ec26904b42f466ed18f64d915321374b9f9fec Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Wed, 6 Jul 2011 18:22:55 +0200 Subject: [PATCH] Revert "Provide proper function list in Insert dropdowns and proper column types in field type dropdowns (Drizzle)" This reverts commit 35843439dfdabd7bb65ebafd2c832bcc60ff6140. --- libraries/common.lib.php | 59 +++-------------- libraries/config.default.php | 106 ++----------------------------- libraries/tbl_properties.inc.php | 11 ++-- 3 files changed, 18 insertions(+), 158 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e79b9a0f6d..e480a0d0a6 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2871,14 +2871,10 @@ function PMA_getSupportedDatatypes($html = false, $selected = '') { global $cfg; - $column_types = PMA_DRIZZLE - ? $cfg['DrizzleColumnTypes'] - : $cfg['ColumnTypes']; - if ($html) { // NOTE: the SELECT tag in not included in this snippet. $retval = ''; - foreach ($column_types as $key => $value) { + foreach ($cfg['ColumnTypes'] as $key => $value) { if (is_array($value)) { $retval .= ""; foreach ($value as $subkey => $subvalue) { @@ -2905,7 +2901,7 @@ function PMA_getSupportedDatatypes($html = false, $selected = '') } } else { $retval = array(); - foreach ($column_types as $key => $value) { + foreach ($cfg['ColumnTypes'] as $key => $value) { if (is_array($value)) { foreach ($value as $subkey => $subvalue) { if ($subvalue !== '-') { @@ -2962,50 +2958,15 @@ function PMA_unsupportedDatatypes() { function PMA_getFunctionsForField($field, $insert_mode) { global $cfg, $analyzed_sql, $data; - static $functions, $restrict_functions; - - if (!isset($functions)) { - if (PMA_DRIZZLE) { - // Remove unavailable functions - $functions = array_diff($cfg['Functions'], $cfg['DrizzleRemoveFunctions']); - $restrict_functions = $cfg['RestrictFunctions']; - unset($restrict_functions['FUNC_SPATIAL']); - foreach ($restrict_functions as &$v) { - $v = array_diff($v, $cfg['DrizzleRemoveFunctions']); - } - unset($v); - - // Add new functions - $sql = "SELECT upper(plugin_name) f - FROM data_dictionary.plugins - WHERE plugin_name IN ('" . implode("','", array_keys($cfg['DrizzleAddFunctions'])) . "') - AND plugin_type = 'Function' - AND is_active"; - $drizzle_funcs = PMA_DBI_fetch_result($sql, 'f', 'f'); - $functions = array_merge($functions, $drizzle_funcs); - sort($functions); - foreach ($drizzle_funcs as $function) { - $category = $cfg['DrizzleAddFunctions'][$function]; - $restrict_functions[$category][] = $function; - } - foreach ($restrict_functions as &$v) { - sort($v); - } - unset($v); - } else { - $functions = &$cfg['Functions']; - $restrict_functions = &$cfg['RestrictFunctions']; - } - } $selected = ''; // Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR' // or something similar. Then directly look up the entry in the RestrictFunctions array, // which will then reveal the available dropdown options if (isset($cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]) - && isset($restrict_functions[$cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]])) { + && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]])) { $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]; - $dropdown = $restrict_functions[$current_func_type]; + $dropdown = $cfg['RestrictFunctions'][$current_func_type]; $default_function = $cfg['DefaultFunctions'][$current_func_type]; } else { $dropdown = array(); @@ -3031,7 +2992,7 @@ function PMA_getFunctionsForField($field, $insert_mode) && $field['Key'] == 'PRI' && ($field['Type'] == 'char(36)' || $field['Type'] == 'varchar(36)') ) { - $default_function = $cfg['DefaultFunctions']['FUNC_UUID']; + $default_function = $cfg['DefaultFunctions']['pk_char36']; } // this is set only when appropriate and is always true if (isset($field['display_binary_as_hex'])) { @@ -3054,12 +3015,12 @@ function PMA_getFunctionsForField($field, $insert_mode) // For compatibility's sake, do not let out all other functions. Instead // print a separator (blank) and then show ALL functions which weren't shown // yet. - $cnt_functions = count($functions); + $cnt_functions = count($cfg['Functions']); for ($j = 0; $j < $cnt_functions; $j++) { - if (! isset($dropdown_built[$functions[$j]]) || $dropdown_built[$functions[$j]] != 'true') { + if (! isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'true') { // Is current function defined as default? - $selected = ($field['first_timestamp'] && $functions[$j] == $cfg['DefaultFunctions']['first_timestamp']) - || (!$field['first_timestamp'] && $functions[$j] == $default_function) + $selected = ($field['first_timestamp'] && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp']) + || (!$field['first_timestamp'] && $cfg['Functions'][$j] == $default_function) ? ' selected="selected"' : ''; if ($op_spacing_needed == true) { @@ -3069,7 +3030,7 @@ function PMA_getFunctionsForField($field, $insert_mode) } $retval .= ' '; - $retval .= '' . $functions[$j] . '' . "\n"; + $retval .= '' . $cfg['Functions'][$j] . '' . "\n"; } } // end for diff --git a/libraries/config.default.php b/libraries/config.default.php index dc9e29acca..f2e40ee199 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -2809,51 +2809,6 @@ $cfg['ColumnTypes'] = array( ), ); -/** - * Column types for Drizzle database; - * VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity - * - * @global array $cfg['ColumnTypesDrizzle'] - */ -$cfg['DrizzleColumnTypes'] = array( - // most used - 'INTEGER', - 'VARCHAR', - 'TEXT', - 'DATE', - - // numeric - 'NUMERIC' => array( - 'INTEGER', - 'BIGINT', - '-', - 'DECIMAL', - 'DOUBLE', - '-', - 'BOOLEAN', - 'SERIAL', - 'UUID', - ), - - - // Date/Time - 'DATE and TIME' => array( - 'DATE', - 'DATETIME', - 'TIMESTAMP', - 'TIME', - ), - - // Text - 'STRING' => array( - 'VARCHAR', - 'TEXT', - 'VARBINARY', - 'BLOB', - 'ENUM', - ), -); - /** * Attributes * @@ -2867,15 +2822,6 @@ $cfg['AttributeTypes'] = array( 'on update CURRENT_TIMESTAMP', ); -/** - * Attributes for Drizzle database - * - * @global array $cfg['AttributeTypesDrizzle'] - */ -$cfg['DrizzleAttributeTypes'] = array( - '', - 'on update CURRENT_TIMESTAMP', -); if ($cfg['ShowFunctionFields']) { /** @@ -2981,45 +2927,6 @@ if ($cfg['ShowFunctionFields']) { 'YEARWEEK', ); - /** - * MySQL functions that are unavailable in Drizzle - * - * @global array $cfg['DrizzleRemoveFunctions'] - */ - $cfg['DrizzleRemoveFunctions'] = array( - 'BIT_LENGTH', - 'DES_DECRYPT', - 'DES_ENCRYPT', - 'ENCRYPT', - 'INET_ATON', - 'INET_NTOA', - 'OLD_PASSWORD', - 'PASSWORD', - 'SEC_TO_TIME', - 'SHA1', - 'SOUNDEX', // https://bugs.launchpad.net/drizzle/+bug/804566 - 'SYSDATE', - 'TIME', // https://bugs.launchpad.net/drizzle/+bug/804571 - 'TIMESTAMP', - 'TIME_TO_SEC', - 'UTC_DATE', - 'UTC_TIME', - 'WEEK', // same as TIME - 'WEEKOFYEAR', - 'YEARWEEK', - ); - - /** - * Drizzle functions that are unavailable in MySQL - * This list will be verified by a lookup to data_dictionary.plugins - * - * @global array $cfg['DrizzleAddFunctions'] - */ - $cfg['DrizzleAddFunctions'] = array( - 'MYSQL_PASSWORD' => 'FUNC_CHAR', - 'ROT13' => 'FUNC_CHAR', - ); - /** * Which column types will be mapped to which Group? * @@ -3030,7 +2937,6 @@ if ($cfg['ShowFunctionFields']) { 'SMALLINT' => 'FUNC_NUMBER', 'MEDIUMINT' => 'FUNC_NUMBER', 'INT' => 'FUNC_NUMBER', - 'INTEGER' => 'FUNC_NUMBER', // Drizzle 'BIGINT' => 'FUNC_NUMBER', 'DECIMAL' => 'FUNC_NUMBER', 'FLOAT' => 'FUNC_NUMBER', @@ -3058,7 +2964,6 @@ if ($cfg['ShowFunctionFields']) { 'MEDIUMBLOB' => 'FUNC_CHAR', 'BLOB' => 'FUNC_CHAR', 'LONGBLOB' => 'FUNC_CHAR', - 'UUID' => 'FUNC_UUID', // Drizzle 'ENUM' => '', 'SET' => '', @@ -3070,6 +2975,7 @@ if ($cfg['ShowFunctionFields']) { 'MULTILINESTRING' => 'FUNC_SPATIAL', 'MULTIPOLYGON' => 'FUNC_SPATIAL', 'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL', + ); /** @@ -3111,13 +3017,9 @@ if ($cfg['ShowFunctionFields']) { 'UUID', ), - 'FUNC_UUID' => array( - 'UUID', // Drizzle - ), - 'FUNC_DATE' => array( - 'CURRENT_DATE', - 'CURRENT_TIME', + 'CURDATE', + 'CURTIME', 'DATE', 'FROM_DAYS', 'FROM_UNIXTIME', @@ -3217,7 +3119,7 @@ if ($cfg['ShowFunctionFields']) { 'FUNC_DATE' => '', 'FUNC_NUMBER' => '', 'first_timestamp' => 'NOW', - 'FUNC_UUID' => 'UUID', + 'pk_char36' => 'UUID', ); } // end if diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php index 788e41f704..da3d93945a 100644 --- a/libraries/tbl_properties.inc.php +++ b/libraries/tbl_properties.inc.php @@ -464,16 +464,13 @@ for ($i = 0; $i < $num_fields; $i++) { $default_current_timestamp = false; } - $attribute_types = PMA_DRIZZLE - ? $cfg['DrizzleAttributeTypes'] - : $cfg['AttributeTypes']; - $cnt_attribute_types = count($attribute_types); + $cnt_attribute_types = count($cfg['AttributeTypes']); for ($j = 0; $j < $cnt_attribute_types; $j++) { - $content_cells[$i][$ci] .= ' '; } $content_cells[$i][$ci] .= '';