1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 01:24:17 +02:00

Allow '' in enum

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@100 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2007-07-10 14:07:49 +00:00
parent 98ccf0fd6c
commit 06d4b9c8db
2 changed files with 3 additions and 2 deletions

View 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);

View 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")