From 8670cfc31b9f00482b29c8296b17e6149afa57e1 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 15 Mar 2014 14:30:07 -0700 Subject: [PATCH] Fix enum types in routines (bug #391) --- adminer/drivers/mysql.inc.php | 2 +- adminer/index.php | 2 +- changes.txt | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 7068ac0d..f332d693 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -796,7 +796,7 @@ if (!defined("DRIVER")) { function routine($name, $type) { global $connection, $enum_length, $inout, $types; $aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar"); - $type_pattern = "((" . implode("|", array_merge(array_keys($types), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]*|$enum_length)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?"; + $type_pattern = "((" . implode("|", array_merge(array_keys($types), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]|$enum_length)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?"; $pattern = "\\s*(" . ($type == "FUNCTION" ? "" : $inout) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern"; $create = $connection->result("SHOW CREATE $type " . idf_escape($name), 2); preg_match("~\\(((?:$pattern\\s*,?)*)\\)\\s*" . ($type == "FUNCTION" ? "RETURNS\\s+$type_pattern\\s+" : "") . "(.*)~is", $create, $match); diff --git a/adminer/index.php b/adminer/index.php index 523baf3c..f6eeeb21 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -10,7 +10,7 @@ include "./include/bootstrap.inc.php"; include "./include/tmpfile.inc.php"; -$enum_length = "'(?:''|[^'\\\\]|\\\\.)*+'"; +$enum_length = "'(?:''|[^'\\\\]|\\\\.)*'"; $inout = "IN|OUT|INOUT"; if (isset($_GET["select"]) && ($_POST["edit"] || $_POST["clone"]) && !$_POST["save"]) { diff --git a/changes.txt b/changes.txt index 26aedb88..537e0788 100644 --- a/changes.txt +++ b/changes.txt @@ -5,6 +5,7 @@ Display edit form after error in clone or multi-edit Display time of the select command Print elapsed time in HTML instead of SQL command comment Improve gzip export ratio (bug #387) +Fix enum types in routines (bug #391) MySQL: Fix editing rows by binary values, bug since Adminer 3.7.1 MySQL: Respect daylight saving time in dump, bug since Adminer 3.6.4 MySQL 5.6.5+: Support ON UPDATE on datatime column