From daf0940efd4cb5de1a143243a34588c93c49ed03 Mon Sep 17 00:00:00 2001 From: xzilla Date: Fri, 17 Mar 2006 21:14:30 +0000 Subject: [PATCH] Partial implementation of autovacuum editor. Does the display, edit link, and page holder for edit. --- classes/database/Postgres.php | 3 +- classes/database/Postgres81.php | 15 +++- database.php | 126 ++++++++++++++++++++++++++++---- lang/english.php | 12 ++- lang/recoded/english.php | 12 ++- 5 files changed, 150 insertions(+), 18 deletions(-) diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index d8d74cb5..d0d2ff31 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.281 2006/01/06 21:06:57 xzilla Exp $ + * $Id: Postgres.php,v 1.282 2006/03/17 21:14:30 xzilla Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -4513,6 +4513,7 @@ class Postgres extends ADODB_base { function hasReadOnlyQueries() { return false; } function hasFuncPrivs() { return false; } function hasServerAdminFuncs() { return false; } + function hasAutovacuum() { return false; } } diff --git a/classes/database/Postgres81.php b/classes/database/Postgres81.php index 3f4bac95..4237ee4f 100644 --- a/classes/database/Postgres81.php +++ b/classes/database/Postgres81.php @@ -3,7 +3,7 @@ /** * PostgreSQL 8.1 support * - * $Id: Postgres81.php,v 1.4 2006/01/06 21:06:57 xzilla Exp $ + * $Id: Postgres81.php,v 1.5 2006/03/17 21:14:30 xzilla Exp $ */ include_once('./classes/database/Postgres80.php'); @@ -110,10 +110,21 @@ class Postgres81 extends Postgres80 { return $this->selectSet($sql); } + /** + * Returns all available process information. + * @param $database (optional) Find only connections to specified database + * @return A recordset + */ + function getAutovacuum() { + $sql = "SELECT vacrelid, nspname, relname, enabled, vac_base_thresh, vac_scale_factor, anl_base_thresh, anl_scale_factor, vac_cost_delay, vac_cost_limit + FROM pg_autovacuum join pg_class on (oid=vacrelid) join pg_namespace on (oid=relnamespace) ORDER BY nspname, relname"; + + return $this->selectSet($sql); + } // Capabilities function hasServerAdminFuncs() { return true; } - + function hasAutovacuum() { return true; } } ?> diff --git a/database.php b/database.php index 391f6056..8f691196 100755 --- a/database.php +++ b/database.php @@ -3,7 +3,7 @@ /** * Manage schemas within a database * - * $Id: database.php,v 1.80 2006/01/09 05:43:48 chriskl Exp $ + * $Id: database.php,v 1.81 2006/03/17 21:14:30 xzilla Exp $ */ // Include application functions @@ -438,11 +438,28 @@ $misc->printTabs('database','admin'); $misc->printMsg($msg); + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + if ($data->hasRecluster()){ + echo ""; + } + echo ""; + echo ""; + // Vacuum + echo "\n"; + echo "\n"; // Analyze + echo "\n"; // Recluster if ($data->hasRecluster()){ + echo "\n"; } // Reindex + echo "\n"; + echo "\n"; + echo "
"; + $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum').""; + $misc->printHelp($lang['stranalyze'],'pg.admin.analyze'); + echo ""; + $misc->printHelp($lang['strclusterindex'],'pg.index.cluster'); + echo ""; + $misc->printHelp($lang['strreindex'],'pg.index.reindex'); + echo "
\n"; echo "
\n"; - echo "

"; - $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum'); - echo "

\n"; echo "{$lang['stranalyze']}
\n"; if ($data->hasFullVacuum()) { echo "{$lang['strfull']}
\n"; @@ -452,43 +469,123 @@ echo "\n"; echo $misc->form; echo "
\n"; + echo "
\n"; echo "
\n"; - echo "

"; - $misc->printHelp($lang['stranalyze'],'pg.admin.analyze'); - echo "

\n"; echo "\n"; echo "\n"; echo $misc->form; echo "
\n"; + echo "
\n"; echo "
\n"; - echo "

"; - $misc->printHelp($lang['strclusterindex'],'pg.index.cluster'); - echo "

\n"; echo "\n"; echo "\n"; echo $misc->form; echo "
\n"; + echo "
\n"; echo "
\n"; - echo "

"; - $misc->printHelp($lang['strreindex'],'pg.index.reindex'); - echo "

\n"; echo "{$lang['strforce']}
\n"; echo "\n"; echo "\n"; echo $misc->form; echo "
\n"; + echo "
\n"; + + echo "
"; + echo "
"; + echo "

{$lang['strautovacuum']}

"; + // Autovacuum + // Fetch the processes from the database + $autovac = $data->getAutovacuum(); + + $columns = array( + 'namespace' => array( + 'title' => $lang['strschema'], + 'field' => 'nspname', + ), + 'relname' => array( + 'title' => $lang['strtable'], + 'field' => 'relname', + ), + 'enabled' => array( + 'title' => $lang['strenabled'], + 'field' => 'enabled', + ), + 'vac_base_thresh' => array( + 'title' => $lang['strvacuumbasethreshold'], + 'field' => 'vac_base_thresh', + ), + 'vac_scale_factor' => array( + 'title' => $lang['strvacuumscalefactor'], + 'field' => 'vac_scale_factor', + ), + 'anl_base_thresh' => array( + 'title' => $lang['stranalybasethreshold'], + 'field' => 'anl_base_thresh', + ), + 'anl_scale_factor' => array( + 'title' => $lang['stranalyzescalefactor'], + 'field' => 'anl_scale_factor', + ), + 'vac_cost_delay' => array( + 'title' => $lang['strvacuumcostdelay'], + 'field' => 'vac_cost_delay', + ), + 'vac_cost_limit' => array( + 'title' => $lang['strvacuumcostlimit'], + 'field' => 'vac_cost_limit', + ), + ); + + + // 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&{$misc->href}&", + 'vars' => array('vacrelid' => 'vacrelid') + ) + ); + + $misc->printTable($autovac, $columns, $actions, $lang['strnodata']); + break; } } + + /** + * Modify specific entries in the autovacuum table + */ + function doAutovacuum() { + global $PHP_SELF, $data, $misc; + global $lang; + + if (!isset($_REQUEST['query'])) $_REQUEST['query'] = ''; + + + echo " editing a specific autovacuum row goes here "; + + $misc->printTrail('database'); + $misc->printTabs('database','admin'); + + } + + /** * Allow execution of arbitrary SQL statements on a database */ @@ -600,6 +697,9 @@ case 'signal': doSignal(); break; + case 'autovacuum': + doAutovacuum(); + break; default: doSQL(); break; diff --git a/lang/english.php b/lang/english.php index 36443623..ea1a6444 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.184 2006/01/06 21:06:57 xzilla Exp $ + * $Id: english.php,v 1.185 2006/03/17 21:14:31 xzilla Exp $ */ // Language and character set @@ -774,4 +774,14 @@ $lang['strerrorloading'] = 'Error Loading'; $lang['strclicktoreload'] = 'Click to reload'; + //Autovacuum + $lang['strautovacuum'] = 'Autovacuum'; + $lang['strenabled'] = 'Enabled'; + $lang['strvacuumbasethreshold'] = 'Vacuum Base Threshold'; + $lang['strvacuumscalefactor'] = 'Vacuum Scale Factor'; + $lang['stranalybasethreshold'] = 'Analyze Base Threshold'; + $lang['stranalyzescalefactor'] = 'Analyze Scale Factor'; + $lang['strvacuumcostdelay'] = 'Vacuum Cost Delay'; + $lang['strvacuumcostlimit'] = 'Vacuum Cost Limit'; + ?> diff --git a/lang/recoded/english.php b/lang/recoded/english.php index d6a64cec..ead3b92d 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.137 2006/01/06 21:06:58 xzilla Exp $ + * $Id: english.php,v 1.138 2006/03/17 21:14:31 xzilla Exp $ */ // Language and character set @@ -774,4 +774,14 @@ $lang['strerrorloading'] = 'Error Loading'; $lang['strclicktoreload'] = 'Click to reload'; + //Autovacuum + $lang['strautovacuum'] = 'Autovacuum'; + $lang['strenabled'] = 'Enabled'; + $lang['strvacuumbasethreshold'] = 'Vacuum Base Threshold'; + $lang['strvacuumscalefactor'] = 'Vacuum Scale Factor'; + $lang['stranalybasethreshold'] = 'Analyze Base Threshold'; + $lang['stranalyzescalefactor'] = 'Analyze Scale Factor'; + $lang['strvacuumcostdelay'] = 'Vacuum Cost Delay'; + $lang['strvacuumcostlimit'] = 'Vacuum Cost Limit'; + ?> -- 2.39.5