]> git.joonet.de Git - adminer.git/commitdiff
Type aliases in routine
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 16 Aug 2007 08:32:11 +0000 (08:32 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 16 Aug 2007 08:32:11 +0000 (08:32 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@341 7c3ca157-0c34-0410-bff1-cbf682f78f5c

editing.inc.php

index 0c789588674c2f4e0f332c5acf879e510915682b..49a506b89683e69bcbf9121b2771e1eac9c5a458 100644 (file)
@@ -172,16 +172,18 @@ function normalize_enum($match) {
 
 function routine($name, $type) {
        global $mysql, $enum_length, $inout;
-       $type_pattern = "([a-z]+)(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
+       $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 = "([ a-z]+)(?:\\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 = $mysql->result($mysql->query("SHOW CREATE $type " . idf_escape($name)), 2);
        preg_match("~\\(((?:$pattern\\s*,?)*)\\)" . ($type == "FUNCTION" ? "\\s*RETURNS\\s+$type_pattern" : "") . "\\s*(.*)~is", $create, $match);
        $fields = array();
        preg_match_all("~$pattern\\s*,?~is", $match[1], $matches, PREG_SET_ORDER);
        foreach ($matches as $i => $param) {
+               $data_type = strtolower($param[4]);
                $fields[$i] = array(
                        "field" => str_replace("``", "`", $param[2]) . $param[3],
-                       "type" => strtolower($param[4]), //! type aliases
+                       "type" => (isset($aliases[$data_type]) ? $aliases[$data_type] : $data_type),
                        "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[5]),
                        "unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$param[7] $param[6]"))),
                        "inout" => strtoupper($param[1]),