From f22c31647cd7b2fb3a475fdc6d2620ce6b91435f Mon Sep 17 00:00:00 2001 From: xzilla Date: Sun, 1 Apr 2007 16:02:06 +0000 Subject: [PATCH] Add analyze to table level actions (ioguix) --- classes/database/Postgres.php | 3 +- classes/database/Postgres72.php | 3 +- database.php | 26 +++++----- lang/english.php | 3 +- lang/french.php | 11 +++-- lang/recoded/english.php | 3 +- lang/recoded/french.php | 11 +++-- tables.php | 88 ++++++++++++++++++++++++++++++++- 8 files changed, 122 insertions(+), 26 deletions(-) diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 21299e92..7cbf1d24 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -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;} } ?> diff --git a/classes/database/Postgres72.php b/classes/database/Postgres72.php index b6c2999b..4c5a583f 100644 --- a/classes/database/Postgres72.php +++ b/classes/database/Postgres72.php @@ -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; } } diff --git a/database.php b/database.php index a2501d2f..fa2f3576 100755 --- a/database.php +++ b/database.php @@ -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 @@ -518,9 +518,11 @@ echo ""; $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum')."\n"; echo ""; - echo ""; - $misc->printHelp($lang['stranalyze'],'pg.admin.analyze'); - echo ""; + if ($data->hasAnalyze()){ + echo ""; + $misc->printHelp($lang['stranalyze'],'pg.admin.analyze'); + echo ""; + } if ($data->hasRecluster()){ echo ""; $misc->printHelp($lang['strclusterindex'],'pg.index.cluster'); @@ -547,13 +549,15 @@ echo "\n"; // Analyze - echo "\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo $misc->form; - echo "
\n"; - echo "\n"; + if ($data->hasAnalyze()) { + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo $misc->form; + echo "
\n"; + echo "\n"; + } // Recluster if ($data->hasRecluster()){ diff --git a/lang/english.php b/lang/english.php index b9e668a4..eddef809 100755 --- a/lang/english.php +++ b/lang/english.php @@ -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 @@ -225,6 +225,7 @@ $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 diff --git a/lang/french.php b/lang/french.php index 33f1604d..f8c91451 100644 --- a/lang/french.php +++ b/lang/french.php @@ -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 @@ -136,9 +136,9 @@ $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'; @@ -224,7 +224,8 @@ $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 diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 5cd3d680..1cd431f4 100644 --- a/lang/recoded/english.php +++ b/lang/recoded/english.php @@ -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 @@ -225,6 +225,7 @@ $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 diff --git a/lang/recoded/french.php b/lang/recoded/french.php index f9d7fc01..645c92f5 100644 --- a/lang/recoded/french.php +++ b/lang/recoded/french.php @@ -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 @@ -136,9 +136,9 @@ $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'; @@ -224,7 +224,8 @@ $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 diff --git a/tables.php b/tables.php index ff999da0..ef0b5ea8 100644 --- a/tables.php +++ b/tables.php @@ -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 @@ -702,6 +702,75 @@ } } + /** + * 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 "
\n"; + foreach($_REQUEST['ma'] as $v) { + $a = unserialize(html_entity_decode($v)); + echo "

", sprintf($lang['strconfanalyzetable'], $misc->printVal($a['table'])), "

\n"; + echo "\n"; + } + } // END if multi analyze + else { + $misc->printTrail('table'); + $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO + + echo "

", sprintf($lang['strconfanalyzetable'], $misc->printVal($_REQUEST['table'])), "

\n"; + + echo "\n"; + echo "\n"; + } + echo "\n"; + echo $misc->form; + + echo "\n"; //TODO + echo "\n"; + echo "
\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
', $t, $lang['stranalyzegood']); + else { + doDefault(sprintf('%s%s: %s
', $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 */ @@ -732,6 +801,10 @@ 'vacuum' => array( 'action' => 'confirm_vacuum', 'title' => $lang['strvacuum'], + ), + 'analyze' => array( + 'action' => 'confirm_analyze', + 'title' => $lang['stranalyze'], ) ) ); @@ -799,8 +872,14 @@ 'url' => "{$PHP_SELF}?action=confirm_vacuum&{$misc->href}&", 'vars' => array('table' => 'relname'), ), + 'analyze' => array( + 'title' => $lang['stranalyze'], + 'url' => "{$PHP_SELF}?action=confirm_analyze&{$misc->href}&", + '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); @@ -888,6 +967,13 @@ 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; -- 2.39.5