improved kill command support for MySQL and initial support for PgSQL

This commit is contained in:
Bernhard J. M. Gruen 2015-03-18 10:34:35 +01:00 committed by Jakub Vrana
parent c5a7174a2a
commit 3289eca040
5 changed files with 28 additions and 6 deletions

View file

@ -1015,6 +1015,16 @@ if (!defined("DRIVER")) {
return !preg_match("~scheme|sequence|type|view_trigger" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|routine|trigger|view" : "") : "") . "~", $feature); return !preg_match("~scheme|sequence|type|view_trigger" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|routine|trigger|view" : "") : "") . "~", $feature);
} }
function kill_process($val) {
return queries("KILL " . number($val));
}
function max_connections() {
global $connection;
return $connection->result("SELECT @@max_connections");
}
$id_name = "Id";
$jush = "sql"; ///< @var string JUSH identifier $jush = "sql"; ///< @var string JUSH identifier
$types = array(); ///< @var array ($type => $maximum_unsigned_length, ...) $types = array(); ///< @var array ($type => $maximum_unsigned_length, ...)
$structured_types = array(); ///< @var array ($description => array($type, ...), ...) $structured_types = array(); ///< @var array ($description => array($type, ...), ...)

View file

@ -631,9 +631,19 @@ AND typelem = 0"
function support($feature) { function support($feature) {
global $connection; global $connection;
return preg_match('~^(database|table|columns|sql|indexes|comment|view|' . ($connection->server_info >= 9.3 ? 'materializedview|' : '') . 'scheme|processlist|sequence|trigger|type|variables|drop_col)$~', $feature); //! routine| return preg_match('~^(database|table|columns|sql|indexes|comment|view|' . ($connection->server_info >= 9.3 ? 'materializedview|' : '') . 'scheme|processlist|sequence|trigger|type|variables|drop_col|kill)$~', $feature); //! routine|
} }
function kill_process($val) {
return queries("SELECT pg_terminate_backend(" . number($val).")");
}
function max_connections() {
global $connection;
return $connection->result("SHOW max_connections");
}
$id_name = "pid";
$jush = "pgsql"; $jush = "pgsql";
$types = array(); $types = array();
$structured_types = array(); $structured_types = array();

View file

@ -1,2 +1,2 @@
<?php <?php
$VERSION = "4.2.4"; $VERSION = "4.2.5-dev";

View file

@ -2,7 +2,7 @@
if (support("kill") && $_POST && !$error) { if (support("kill") && $_POST && !$error) {
$killed = 0; $killed = 0;
foreach ((array) $_POST["kill"] as $val) { foreach ((array) $_POST["kill"] as $val) {
if (queries("KILL " . number($val))) { if (kill_process($val)) {
$killed++; $killed++;
} }
} }
@ -30,8 +30,7 @@ foreach (process_list() as $i => $row) {
} }
echo "</thead>\n"; echo "</thead>\n";
} }
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row[$id_name], 0) : "");
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
echo "<td>" . ( echo "<td>" . (
($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "") || ($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "") ||
@ -49,7 +48,7 @@ foreach (process_list() as $i => $row) {
<p> <p>
<?php <?php
if (support("kill")) { if (support("kill")) {
echo ($i + 1) . "/" . lang('%d in total', $connection->result("SELECT @@max_connections")); echo ($i + 1) . "/" . lang('%d in total', max_connections());
echo "<p><input type='submit' value='" . lang('Kill') . "'>\n"; echo "<p><input type='submit' value='" . lang('Kill') . "'>\n";
} }
?> ?>

View file

@ -1,3 +1,6 @@
Adminer 4.2.5-dev:
PostgreSQL: Support KILL
Adminer 4.2.4 (released 2016-02-06): Adminer 4.2.4 (released 2016-02-06):
Fix remote execution in SQLite query Fix remote execution in SQLite query
MySQL: Support PHP 7 MySQL: Support PHP 7