Add ability to delete rows from pg_autovaccum from within the admin section
authorxzilla <xzilla>
Thu, 28 Sep 2006 13:04:00 +0000 (13:04 +0000)
committerxzilla <xzilla>
Thu, 28 Sep 2006 13:04:00 +0000 (13:04 +0000)
classes/database/Postgres81.php
database.php

index 1f2afc24c0883549a4c934ca57f1fe59646f0512..2192b480acbfa12758ca6630eb99ef663b9c4131 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 8.1 support
  *
- * $Id: Postgres81.php,v 1.10 2006/08/13 15:31:13 xzilla Exp $
+ * $Id: Postgres81.php,v 1.11 2006/09/28 13:04:00 xzilla Exp $
  */
 
 include_once('./classes/database/Postgres80.php');
@@ -257,7 +257,6 @@ class Postgres81 extends Postgres80 {
 
        /**
         * Returns all available process information.
-        * @param $database (optional) Find only connections to specified database
         * @return A recordset
         */
        function getAutovacuum() {
@@ -266,6 +265,7 @@ class Postgres81 extends Postgres80 {
                
                return $this->selectSet($sql);
        }
+       
 
        /**
         * Enables a trigger
index d50f9b4a8c1b1e44bb3d20dfd6115271482600c0..52377bdcd5194049429e3bb279393af9779e1642 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.86 2006/06/20 14:06:08 xzilla Exp $
+        * $Id: database.php,v 1.87 2006/09/28 13:04:00 xzilla Exp $
         */
 
        // Include application functions
 
                                        // Maybe we need to check permissions here?
                                        $columns['actions'] = array('title' => $lang['stractions']);
-                       
+
                                        $actions = array(
                                                'edit' => array(
                                                'title' => $lang['stredit'],
                                                'url'   => "{$PHP_SELF}?action=autovacuum&amp;{$misc->href}&amp;",
-                                               'vars'  => array('vacrelid' => 'vacrelid')
+                                               'vars'  => array('key' => 'vacrelid')
+                                               ),
+                                               'delete' => array(
+                                               'title' => $lang['strdelete'],
+                                               'url'   => "{$PHP_SELF}?action=delautovac&amp;{$misc->href}&amp;",
+                                               'vars'  => array('key[vacrelid]' => 'vacrelid')
                                                )
                                        );
 
 
        }
 
+       /**
+        * Delete rows from the autovacuum table
+     */
+       function doDelAutovacuum($confirm) {
+               global $PHP_SELF, $data, $misc;
+               global $lang;
+
+               if ($confirm) {
+                       $misc->printTrail('database');
+                       $misc->printTabs('database','admin');
+                       $misc->printTitle($lang['strdeleterow']);
+
+                       echo "<p>{$lang['strconfdeleterow']}</p>\n";
+                       
+                       echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                       echo "<input type=\"hidden\" name=\"action\" value=\"confdelautovac\" />\n";
+                       echo $misc->form;
+                       echo "<input type=\"hidden\" name=\"table\" value=\"pg_autovacuum\" />\n";
+                       echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($_REQUEST['key'])), "\" />\n";
+                       echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
+                       echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
+                       echo "</form>\n";
+               }
+               else {
+                       $status = $data->deleteRow($_POST['table'], unserialize($_POST['key']));
+                       if ($status == 0)
+                               doAdmin('',$lang['strrowdeleted']);
+                       elseif ($status == -2)
+                               doAdmin('',$lang['strrownotunique']);
+                       else                    
+                               doAdmin('',$lang['strrowdeletedbad']);
+               }
+       }
 
        /**
         * Allow execution of arbitrary SQL statements on a database
                case 'signal':
                        doSignal();
                        break;
+               case 'delautovac':
+                       doDelAutovacuum(true);
+                       break;
+               case 'confdelautovac':
+                       if (isset($_POST['yes'])) doDelAutovacuum(false);
+                       else doAdmin();
+                       break;
                case 'autovacuum':
                        doAutovacuum();
                        break;