From 3ad62d55c8bece6a0aef655c52959b17f34947c7 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 23 Feb 2025 16:35:11 +0100 Subject: [PATCH] Show comments at routine call (bug #874) --- adminer/call.inc.php | 19 +++++++++++++++++++ adminer/drivers/mysql.inc.php | 11 +++++++---- changes.txt | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 3976f668..1e753870 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -88,3 +88,22 @@ if ($in) { + +
+', preg_replace('~\|~', '', preg_replace('~\|$~m', "", rtrim($s))));
+}
+$table = '(?:\+--[-+]+\+\n)';
+$row = '(?:\| .* \|\n)';
+echo
+	preg_replace_callback("~^($table?)($row)$table?($row*)$table?~m", function ($match) {
+		$first_row = pre_tr($match[2]);
+		return "\n" . ($match[1] ? "$first_row\n" : $first_row) . pre_tr($match[3]) . "\n
"; + }, + preg_replace('~(\n( -|mysql)> )(.+)~', "\\1\\3", + preg_replace('~(.+)\n---+\n~', "\\1\n", + h($routine['comment']) +))); +?> +
diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 9feaa054..ba6a044a 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -926,11 +926,14 @@ if (!defined("DRIVER")) { "collation" => strtolower($param[9]), ); } - if ($type != "FUNCTION") { - return array("fields" => $fields, "definition" => $match[11]); - } - return array( + $return = array( "fields" => $fields, + "comment" => $connection->result("SELECT ROUTINE_COMMENT FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . q(DB) . " AND ROUTINE_NAME = " . q($name)), + ); + if ($type != "FUNCTION") { + return $return + array("definition" => $match[11]); + } + return $return + array( "returns" => array("type" => $match[12], "length" => $match[13], "unsigned" => $match[15], "collation" => $match[16]), "definition" => $match[17], "language" => "SQL", // available in information_schema.ROUTINES.PARAMETER_STYLE diff --git a/changes.txt b/changes.txt index 0e4e0564..02a6d2ff 100644 --- a/changes.txt +++ b/changes.txt @@ -2,6 +2,7 @@ Adminer 4.17.0-dev: Hide index column options by default Offer original values in multi-row editing (regression from 4.16.0) MySQL, PostgreSQL, MS SQL: Support CHECK constraint +MySQL: Show comments at routine call (bug #874) MySQL: Don't offer empty enum value in edit PostgreSQL: Link user defined types PostgreSQL: Constraint enum values in editing (bug #270)