]> git.joonet.de Git - adminer.git/commitdiff
Process list for PostgreSQL
authorJan Dolecek <juzna.cz@gmail.com>
Wed, 11 May 2011 09:48:51 +0000 (10:48 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 22 Jul 2011 12:32:16 +0000 (14:32 +0200)
adminer/drivers/mysql.inc.php
adminer/drivers/pgsql.inc.php
adminer/processlist.inc.php
changes.txt

index 78604545517153137989f63184736e7d3e92a671..3b4becd99a603ff94a27c75d7cd612b233590ec6 100644 (file)
@@ -902,6 +902,13 @@ if (!defined("DRIVER")) {
                return get_key_vals("SHOW VARIABLES");
        }
        
+       /** Get process list
+       * @return array ($row)
+       */
+       function process_list() {
+               return get_rows("SHOW FULL PROCESSLIST");
+       }
+       
        /** Get status variables
        * @return array ($name => $value)
        */
@@ -910,7 +917,7 @@ if (!defined("DRIVER")) {
        }
        
        /** Check whether a feature is supported
-       * @param string "comment", "copy", "drop_col", "dump", "event", "partitioning", "privileges", "procedure", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "variables", "view"
+       * @param string "comment", "copy", "drop_col", "dump", "event", "kill", "partitioning", "privileges", "procedure", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "variables", "view"
        * @return bool
        */
        function support($feature) {
index 42f5a1a782ed01768f6d52c7ff533d329d941fe3..c32c1adf55dc0f97503868ab191334f743c9448d 100644 (file)
@@ -545,12 +545,16 @@ AND typelem = 0"
        function show_variables() {
                return get_key_vals("SHOW ALL");
        }
+
+       function process_list() {
+               return get_rows("SELECT * FROM pg_stat_activity ORDER BY procpid");
+       }
        
        function show_status() {
        }
        
        function support($feature) {
-               return ereg('^(comment|view|scheme|sequence|trigger|type|variables|drop_col)$', $feature); //! routine|
+               return ereg('^(comment|view|scheme|processlist|sequence|trigger|type|variables|drop_col)$', $feature); //! routine|
        }
        
        $jush = "pgsql";
index aac3f50224cb25d1b2ff9019d2311acf0cb8c1aa..96eff8ad65164cb196f5eb5ad5aee960e7564b3c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-if ($_POST && !$error) {
+if (support("kill") && $_POST && !$error) {
        $killed = 0;
        foreach ((array) $_POST["kill"] as $val) {
                if (queries("KILL " . (+$val))) {
@@ -16,20 +16,24 @@ page_header(lang('Process list'), $error);
 <table cellspacing="0" onclick="tableClick(event);" class="nowrap">
 <?php
 $i = -1;
-foreach (get_rows("SHOW FULL PROCESSLIST") as $i => $row) {
+foreach (process_list() as $i => $row) {
        if (!$i) {
-               echo "<thead><tr lang='en'><th>&nbsp;<th>" . implode("<th>", array_keys($row)) . "</thead>\n";
+               echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "") . "<th>" . implode("<th>", array_keys($row)) . "</thead>\n";
        }
-       echo "<tr" . odd() . "><td>" . checkbox("kill[]", $row["Id"], 0);
+       echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
        foreach ($row as $key => $val) {
-               echo "<td>" . ($key == "Info" && $val != "" ? "<code class='jush-$jush'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Edit') . '</a>' : nbsp($val));
+               echo "<td>" . (($jush == "sql" ? $key == "Info" && $val != "" : $key == "current_query" && $val != "<IDLE>") ? "<code class='jush-$jush'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Edit') . '</a>' : nbsp($val));
        }
        echo "\n";
 }
 ?>
 </table>
-<p><?php echo ($i + 1) . "/" . lang('%d in total', $connection->result("SELECT @@max_connections")); ?>
 <p>
-<input type="submit" value="<?php echo lang('Kill'); ?>">
+<?php
+if (support("kill")) {
+       echo ($i + 1) . "/" . lang('%d in total', $connection->result("SELECT @@max_connections"));
+       echo "<p><input type='submit' value='" . lang('Kill') . "'>\n";
+}
+?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index 7823841e724c7b75cbec47af50f4c1b452451d83..700d68d38b6e707cc74c102843933358cf27a740 100644 (file)
@@ -1,3 +1,6 @@
+Adminer 3.3.1-dev:
+Process list (PostgreSQL)
+
 Adminer 3.3.0 (released 2011-07-19):
 Use Esc to disable in-place edit
 Shortcut for database privileges