]> git.joonet.de Git - adminer.git/commitdiff
Respect unsupported types
authorJakub Vrana <jakub@vrana.cz>
Tue, 25 May 2010 11:29:53 +0000 (13:29 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 26 May 2010 16:10:11 +0000 (18:10 +0200)
adminer/drivers/mysql.inc.php
adminer/include/editing.inc.php

index 994c1a0f19f566f62b563b6371057f8e20e8312b..aca228d6e3bb33e8c53bd46560a2264a21ee7c2c 100644 (file)
@@ -705,8 +705,8 @@ if (!defined("DRIVER")) {
        */
        function routine($name, $type) {
                global $connection, $enum_length, $inout, $types;
-               $aliases = array("bit" => "tinyint", "bool" => "tinyint", "boolean" => "tinyint", "integer" => "int", "double precision" => "float", "real" => "float", "dec" => "decimal", "numeric" => "decimal", "fixed" => "decimal", "national char" => "char", "national varchar" => "varchar");
-               $type_pattern = "((" . implode("|", array_keys($types + $aliases)) . ")(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
+               $aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar");
+               $type_pattern = "((" . implode("|", array_merge(array_keys($types), $aliases)) . ")(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
                $pattern = "\\s*(" . ($type == "FUNCTION" ? "" : implode("|", $inout)) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern";
                $create = $connection->result("SHOW CREATE $type " . idf_escape($name), 2);
                preg_match("~\\(((?:$pattern\\s*,?)*)\\)" . ($type == "FUNCTION" ? "\\s*RETURNS\\s+$type_pattern" : "") . "\\s*(.*)~is", $create, $match);
@@ -714,10 +714,9 @@ if (!defined("DRIVER")) {
                preg_match_all("~$pattern\\s*,?~is", $match[1], $matches, PREG_SET_ORDER);
                foreach ($matches as $param) {
                        $name = str_replace("``", "`", $param[2]) . $param[3];
-                       $data_type = strtolower($param[5]);
                        $fields[] = array(
                                "field" => $name,
-                               "type" => (isset($aliases[$data_type]) ? $aliases[$data_type] : $data_type),
+                               "type" => strtolower($param[5]),
                                "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[6]),
                                "unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$param[8] $param[7]"))),
                                "full_type" => $param[4],
index 0e4ccd8b41a740d7b83aa422b9b60380438b2fd5..1ebdb422066c256c54f5fc1d8e36d1dc717319f5 100644 (file)
@@ -108,9 +108,9 @@ function referencable_primary($self) {
 * @return null
 */
 function edit_type($key, $field, $collations, $foreign_keys = array()) {
-       global $structured_types, $unsigned, $inout, $on_actions;
+       global $structured_types, $types, $unsigned, $inout, $on_actions;
        ?>
-<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
+<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"><?php echo optionlist((isset($types[$field["type"]]) ? array() : array($field["type"])) + $structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
 <td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"><td><?php
        echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
@@ -132,9 +132,8 @@ function process_length($length) {
 * @return string
 */
 function process_type($field, $collate = "COLLATE") {
-       global $types, $connection, $unsigned;
-       $type = $field["type"];
-       return " " . (isset($types[$type]) ? $type : idf_escape($type))
+       global $connection, $unsigned;
+       return " $field[type]"
                . ($field["length"] != "" ? "(" . process_length($field["length"]) . ")" : "")
                . (ereg('int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
                . (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . $connection->quote($field["collation"]) : "")
@@ -144,7 +143,7 @@ function process_type($field, $collate = "COLLATE") {
 /** Create SQL string from field
 * @param array basic field information
 * @param array information about field type
-* @return array array("field", " type", " NULL", " DEFAULT", " ON UPDATE", " COMMENT", " AUTO_INCREMENT")
+* @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
 */
 function process_field($field, $type_field) {
        global $connection;