Add analyze to table level actions (ioguix)
authorxzilla <xzilla>
Sun, 1 Apr 2007 16:02:06 +0000 (16:02 +0000)
committerxzilla <xzilla>
Sun, 1 Apr 2007 16:02:06 +0000 (16:02 +0000)
classes/database/Postgres.php
classes/database/Postgres72.php
database.php
lang/english.php
lang/french.php
lang/recoded/english.php
lang/recoded/french.php
tables.php

index 21299e92cf2d3a780f43eac5b71e3f71be71fda7..7cbf1d24cc75823384b16926526861bb296861ce 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.295 2007/03/03 14:25:14 xzilla Exp $
+ * $Id: Postgres.php,v 1.296 2007/04/01 16:02:07 xzilla Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -4657,6 +4657,7 @@ class Postgres extends ADODB_base {
        function hasDisableTriggers() { return false; }
        function hasAlterAggregate() { return false; }
        function hasSharedComments() {return false;}
+       function hasAnalyze() {return false;}
 }
 
 ?>
index b6c2999b5229375cda62b58e5d023a57682c86c4..4c5a583f1c0b86f1e8b25459eb9ecff0bb7574bb 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres72.php,v 1.88 2007/01/10 02:01:17 soranzo Exp $
+ * $Id: Postgres72.php,v 1.89 2007/04/01 16:02:07 xzilla Exp $
  */
 
 
@@ -677,6 +677,7 @@ class Postgres72 extends Postgres71 {
        function hasProcesses() { return true; }
        function hasStatsCollector() { return true; }
        function hasFullVacuum() { return true; }
+       function hasAnalyze() { return true; }
 
 }
 
index a2501d2f470ccfedff9af6fb50d051137c16a438..fa2f35765d4704e6af1e97deaac8fe0056c38366 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.89 2007/03/25 16:16:21 xzilla Exp $
+        * $Id: database.php,v 1.90 2007/04/01 16:02:07 xzilla Exp $
         */
 
        // Include application functions
                                echo "<th class=\"data\">";
                                $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum')."</th>\n";
                                echo "</th>";
-                               echo "<th class=\"data\">";
-                               $misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
-                               echo "</th>";
+                               if ($data->hasAnalyze()){
+                                       echo "<th class=\"data\">";
+                                       $misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
+                                       echo "</th>";
+                               }
                                if ($data->hasRecluster()){
                                        echo "<th class=\"data\">";
                                        $misc->printHelp($lang['strclusterindex'],'pg.index.cluster');
                                echo "</td>\n";
 
                                // Analyze
-                               echo "<td class=\"data1\" align=\"center\" valign=\"bottom\">\n";
-                               echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
-                               echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" />\n";
-                               echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
-                               echo $misc->form;
-                               echo "</form>\n";
-                               echo "</td>\n";
+                               if ($data->hasAnalyze()) {
+                                       echo "<td class=\"data1\" align=\"center\" valign=\"bottom\">\n";
+                                       echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
+                                       echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" />\n";
+                                       echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
+                                       echo $misc->form;
+                                       echo "</form>\n";
+                                       echo "</td>\n";
+                               }
                                
                                // Recluster
                                if ($data->hasRecluster()){
index b9e668a488887d231fbe4378355470e2734ea9e5..eddef8096adf1069cda534fe2280e0afc056531a 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.201 2007/03/03 20:00:48 xzilla Exp $
+        * $Id: english.php,v 1.202 2007/04/01 16:02:07 xzilla Exp $
         */
 
        // Language and character set
        $lang['strtabbed'] = 'Tabbed';
        $lang['strauto'] = 'Auto';
        $lang['strconfvacuumtable'] = 'Are you sure you want to vacuum "%s"?';
+       $lang['strconfanalyzetable'] = 'Are you sure you want to analyze "%s"?';
        $lang['strestimatedrowcount'] = 'Estimated row count';
 
        // Columns
index 33f1604d69e8b6c0fc5988beba06686fe3ecdfd3..f8c91451eb38aa11b37112a8f6e212ccc7d5c37e 100644 (file)
@@ -4,7 +4,7 @@
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.21 2007/03/13 02:39:22 xzilla Exp $
+     * $Id: french.php,v 1.22 2007/04/01 16:02:07 xzilla Exp $
      */
 
     // Language and character set
     $lang['strfile']  =  'Fichier';
     $lang['strfileimported']  =  'Fichier importé.';
     $lang['strtrycred']  =  'Utilisez ces identifiants pour tous les serveurs';
-       $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
-       $lang['strcheckall']  =  'Sélectionner tout';
-       $lang['struncheckall']  =  'Desélectionner tout';
+               $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
+               $lang['strcheckall']  =  'Sélectionner tout';
+               $lang['struncheckall']  =  'Desélectionner tout';
 
     // Database Sizes
     $lang['strsize']  =  'Taille';
     $lang['strstructureanddata']  =  'Structure et données';
     $lang['strtabbed']  =  'Tabulé';
     $lang['strauto']  =  'Auto';
-    $lang['strconfvacuumtable']  =  'Êtes-vous sur de vouloir faire un vacuum de « %s » ?';
+    $lang['strconfvacuumtable']  =  'Êtes-vous sûr de vouloir faire un vacuum de « %s » ?';
+               $lang['strconfanalyzetable']  =  'Êtes-vous sûr de vouloir éffectuer un ANALYZE sur « %s » ?';
     $lang['strestimatedrowcount']  =  'Nombre d\'enregistrements estimés';
 
        // Columns
index 5cd3d68004d2408647b46330ce37a9ed0697a1d5..1cd431f47a66fc81ed785fd7cdc32d142cc41564 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.153 2007/03/03 20:00:48 xzilla Exp $
+        * $Id: english.php,v 1.154 2007/04/01 16:02:06 xzilla Exp $
         */
 
        // Language and character set
        $lang['strtabbed'] = 'Tabbed';
        $lang['strauto'] = 'Auto';
        $lang['strconfvacuumtable'] = 'Are you sure you want to vacuum &quot;%s&quot;?';
+       $lang['strconfanalyzetable'] = 'Are you sure you want to analyze &quot;%s&quot;?';
        $lang['strestimatedrowcount'] = 'Estimated row count';
 
        // Columns
index f9d7fc01cbbc8d03f9d0b97ded75d1fff24e7258..645c92f51cc4aaba86f4143e9dbf138e26264d8f 100644 (file)
@@ -4,7 +4,7 @@
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.20 2007/03/13 02:39:22 xzilla Exp $
+     * $Id: french.php,v 1.21 2007/04/01 16:02:06 xzilla Exp $
      */
 
     // Language and character set
     $lang['strfile']  =  'Fichier';
     $lang['strfileimported']  =  'Fichier import&#233;.';
     $lang['strtrycred']  =  'Utilisez ces identifiants pour tous les serveurs';
-       $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
-       $lang['strcheckall']  =  'S&#233;lectionner tout';
-       $lang['struncheckall']  =  'Des&#233;lectionner tout';
+               $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
+               $lang['strcheckall']  =  'S&#233;lectionner tout';
+               $lang['struncheckall']  =  'Des&#233;lectionner tout';
 
     // Database Sizes
     $lang['strsize']  =  'Taille';
     $lang['strstructureanddata']  =  'Structure et donn&#233;es';
     $lang['strtabbed']  =  'Tabul&#233;';
     $lang['strauto']  =  'Auto';
-    $lang['strconfvacuumtable']  =  '&#202;tes-vous sur de vouloir faire un vacuum de &#171; %s &#187; ?';
+    $lang['strconfvacuumtable']  =  '&#202;tes-vous s&#251;r de vouloir faire un vacuum de &#171; %s &#187; ?';
+               $lang['strconfanalyzetable']  =  '&#202;tes-vous s&#251;r de vouloir &#233;ffectuer un ANALYZE sur &#171; %s &#187; ?';
     $lang['strestimatedrowcount']  =  'Nombre d\'enregistrements estim&#233;s';
 
        // Columns
index ff999da0f0eebbfd76b4c1f420e81de0879855a8..ef0b5ea8cf9f2c8754791335932ac42116d9f134 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.87 2007/03/03 20:00:48 xzilla Exp $
+        * $Id: tables.php,v 1.88 2007/04/01 16:02:07 xzilla Exp $
         */
 
        // Include application functions
                }
        }
 
+       /**
+        * Show confirmation of analyze and perform analyze
+        */
+       function doAnalyze($confirm) {
+               global $data, $misc;
+               global $lang, $_reload_browser;
+               global $PHP_SELF;
+
+               if (empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
+                       doDefault('No table(s) given to analyze...'); //TODO i18n
+                       exit();
+               }
+               if ($confirm) {
+                       if (isset($_REQUEST['ma'])) {
+                               $misc->printTrail('schema');
+                               $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO
+
+                               echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                               foreach($_REQUEST['ma'] as $v) {
+                                       $a = unserialize(html_entity_decode($v));
+                                       echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($a['table'])), "</p>\n";
+                                       echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
+                               }
+                       } // END if multi analyze
+                       else {
+                               $misc->printTrail('table');
+                               $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO
+
+                               echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($_REQUEST['table'])), "</p>\n";
+
+                               echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                               echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
+                       }
+                       echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
+                       echo $misc->form;
+
+                       echo "<input type=\"submit\" name=\"analyze\" value=\"{$lang['stranalyze']}\" />\n"; //TODO
+                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "</form>\n";
+               } // END single analyze
+               else {
+                       //If multi drop
+                       if (is_array($_REQUEST['table'])) {
+                               $msg='';
+                               foreach($_REQUEST['table'] as $t) {
+                                       $status = $data->analyzeDB($t);
+                                       if ($status == 0)
+                                               $msg.= sprintf('%s: %s<br />', $t, $lang['stranalyzegood']);
+                                       else {
+                                               doDefault(sprintf('%s%s: %s<br />', $msg, $t, $lang['stranalyzebad']));
+                                               return;
+                                       }
+                               }
+                                // Everything went fine, back to the Default page....
+                                $_reload_browser = true;
+                                doDefault($msg);
+                       }
+                       else {
+                               $status = $data->analyzeDB($_POST['table']);
+                               if ($status == 0) {
+                                       $_reload_browser = true;
+                                       doDefault($lang['stranalyzegood']);
+                               }
+                               else
+                                       doDefault($lang['stranalyzebad']);
+                       }
+               }
+       }
+
        /**
         * Show default list of tables in the database
         */
                                'vacuum' => array(
                                        'action' => 'confirm_vacuum',
                                        'title' => $lang['strvacuum'],
+                               ),
+                               'analyze' => array(
+                                       'action' => 'confirm_analyze',
+                                       'title' => $lang['stranalyze'],
                                )
                        )
                );
                                'url'   => "{$PHP_SELF}?action=confirm_vacuum&amp;{$misc->href}&amp;",
                                'vars'  => array('table' => 'relname'),
                        ),
+                       'analyze' => array(
+                               'title' => $lang['stranalyze'],
+                               'url'   => "{$PHP_SELF}?action=confirm_analyze&amp;{$misc->href}&amp;",
+                               'vars'  => array('table' => 'relname'),
+                       ),
                );
                
+               if (!$data->hasAnalyze()) unset($actions['analyze'], $multiactions['actions']['analyze']);
                if (!$data->hasTablespaces()) unset($columns['tablespace']);
 
                $misc->printTable($tables, $columns, $actions, $lang['strnotables'], null, $multiactions);
                case 'confirm_vacuum':
                        doVacuum(true);
                        break;
+               case 'analyze':
+                       if (isset($_POST['analyze'])) doAnalyze(false);
+                       else doDefault();
+                       break;
+               case 'confirm_analyze':
+                       doAnalyze(true);
+                       break;
                default:
                        doDefault();
                        break;