]> git.joonet.de Git - adminer.git/commitdiff
Allow '' in enum
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 10 Jul 2007 14:07:49 +0000 (14:07 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 10 Jul 2007 14:07:49 +0000 (14:07 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@100 7c3ca157-0c34-0410-bff1-cbf682f78f5c

call.inc.php
create.inc.php

index f1f29e77d13910ffb2b6844ecfd501947daf55db..772802fad5300f3956bd9fd6c4ba6ff8984b0fa3 100644 (file)
@@ -5,7 +5,7 @@ function normalize_enum($match) {
        return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0]{0} . $match[0]{0}, $match[0]{0}, substr($match[0], 1, -1))), '\\')) . "'";
 }
 
-$length = '\'(?:[^\'\\\\]*|\\\\.)+\'|"(?:[^"\\\\]*|\\\\.)+"';
+$length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"';
 $pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
 $create = $mysql->result($mysql->query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 0, 2);
 preg_match("~\\($pattern(?:\\s*,$pattern)*~is", $create, $match);
index f30eb96d823d6358d88b39ce8cee1df0a3a0199d..776401b5609bcfc7501bb27258a12b7e8050e927 100644 (file)
@@ -23,11 +23,12 @@ if ($_POST && !$error && !$_POST["add"]) {
                $fields = array();
                ksort($_POST["fields"]);
                $after = "FIRST";
+               $length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"';
                foreach ($_POST["fields"] as $key => $field) {
                        if (strlen($field["field"]) && isset($types[$field["type"]])) {
                                $fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
                                        . idf_escape($field["field"]) . " $field[type]"
-                                       . ($field["length"] ? "($field[length])" : "")
+                                       . ($field["length"] ? "(" . (preg_match("~^\\s*(?:$length)(?:\\s*,\\s*(?:$length))*\\s*\$~", $field["length"]) && preg_match_all("~$length~", $field["length"], $matches) ? implode(",", $matches[0]) : intval($field["length"])) . ")" : "")
                                        . (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
                                        . (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " COLLATE '" . $mysql->real_escape_string($field["collation"]) . "'" : "")
                                        . ($field["null"] ? "" : " NOT NULL")