From 3923367cec9a4a578ac392990454dff59dcbc29f Mon Sep 17 00:00:00 2001 From: chriskl Date: Sat, 13 Dec 2003 09:28:46 +0000 Subject: [PATCH] show settings and show processes support (needs to be fixed for < 7.3, however --- BUGS | 7 +--- TODO | 6 +-- classes/Misc.php | 16 ++++---- classes/database/Postgres.php | 28 ++++++++++++- database.php | 77 ++++++++++++++++++++++++++++++++++- lang/english.php | 6 ++- lang/recoded/english.php | 6 ++- 7 files changed, 127 insertions(+), 19 deletions(-) diff --git a/BUGS b/BUGS index 27919576..dcb416a5 100644 --- a/BUGS +++ b/BUGS @@ -17,8 +17,5 @@ fix dumping clustering info can't edit SELECT results by oid investigate phpPgInfo -Fix ---- - -* Does dropping a database work at all? - +Need to fix: +* Variables and processes views for < 7.3 diff --git a/TODO b/TODO index 2f61f76e..c900ab00 100644 --- a/TODO +++ b/TODO @@ -30,7 +30,7 @@ Permissions Databases --------- -* Fix failure to drop database even tho seemingly no-one is connected to it +* -Fix failure to drop database even tho seemingly no-one is connected to it (chriskl, bryan) * Add alter database for 7.3+ * Dump database using pg_dump streaming @@ -43,7 +43,7 @@ Tables * -Cluster support * Vacuum & analyze (half done) * ORDER BY in Select function -* Unify Select and Browse functions +* -Unify Select and Browse functions (chriskl) Views ----- @@ -125,7 +125,7 @@ Casts (7.3) Settings -------- -* Postgres 7.3 returns SHOW ALL as a proper result set - makes it easy to do a phpMyAdmin style 'view settings'. +* -Postgres 7.3 returns SHOW ALL as a proper result set - makes it easy to do a phpMyAdmin style 'view settings'. Miscellaneous ------------- diff --git a/classes/Misc.php b/classes/Misc.php index 683c5bbd..a133926d 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -2,7 +2,7 @@ /** * Class to hold various commonly used functions * - * $Id: Misc.php,v 1.50 2003/12/10 16:03:30 chriskl Exp $ + * $Id: Misc.php,v 1.51 2003/12/13 09:28:46 chriskl Exp $ */ class Misc { @@ -176,7 +176,7 @@ // Send XHTML headers, or regular HTML headers if (isset($conf['use_xhtml']) && $conf['use_xhtml']) { echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; } else { echo "\n"; @@ -271,15 +271,17 @@ echo "\n"; // Only show schemas if available if ($data->hasSchemas()) { - echo "\n"; + echo "\n"; } // Only show database privs if available if (isset($data->privlist['database'])) { - echo "\n"; + echo "\n"; } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "
{$lang['strschemas']}{$lang['strschemas']}{$lang['strprivileges']}{$lang['strprivileges']}{$lang['strsql']}{$lang['strfind']}{$lang['stradmin']}{$lang['strsql']}{$lang['strfind']}{$lang['strvariables']}{$lang['strprocesses']}{$lang['stradmin']}
\n"; } diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index a947cc3c..62f479a6 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.165 2003/12/10 16:03:30 chriskl Exp $ + * $Id: Postgres.php,v 1.166 2003/12/13 09:28:46 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -229,6 +229,32 @@ class Postgres extends BaseDB { return $this->selectRow($sql); } + /** + * Returns all available variable information. + * @return A recordset + */ + function &getVariables() { + $sql = "SHOW ALL"; + + return $this->selectSet($sql); + } + + /** + * Returns all available process information. + * @param $database (optional) Find only connections to specified database + * @return A recordset + */ + function &getProcesses($database = null) { + if ($database === null) + $sql = "SELECT * FROM pg_stat_activity ORDER BY datname, usename, procpid"; + else { + $this->clean($database); + $sql = "SELECT * FROM pg_stat_activity WHERE datname='{$database}' ORDER BY usename, procpid"; + } + + return $this->selectSet($sql); + } + /** * Returns the current database encoding * @return The encoding. eg. SQL_ASCII, UTF-8, etc. diff --git a/database.php b/database.php index 9b3efac1..fd8f6074 100755 --- a/database.php +++ b/database.php @@ -3,7 +3,7 @@ /** * Manage schemas within a database * - * $Id: database.php,v 1.26 2003/12/10 16:03:29 chriskl Exp $ + * $Id: database.php,v 1.27 2003/12/13 09:28:46 chriskl Exp $ */ // Include application functions @@ -182,6 +182,75 @@ } } + /** + * Show the current status of all database variables + */ + function doVariables() { + global $PHP_SELF, $data, $misc; + global $lang; + + // Fetch the variables from the database + $variables = &$data->getVariables(); + + $misc->printDatabaseNav(); + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strvariables']}

\n"; + + if ($variables->recordCount() > 0) { + echo "\n"; + echo "\n"; + $i = 0; + while (!$variables->EOF) { + $id = (($i % 2) == 0 ? '1' : '2'); + echo ""; + echo ""; + echo ""; + echo "\n"; + $variables->moveNext(); + $i++; + } + echo "
{$lang['strname']}{$lang['strsetting']}
", $misc->printVal($variables->f['name']), "", $misc->printVal($variables->f['setting']), "
\n"; + } + else { + echo "

{$lang['strnodata']}

\n"; + } + } + + /** + * Show all current database connections and any queries they + * are running. + */ + function doProcesses() { + global $PHP_SELF, $data, $misc; + global $lang; + + // Fetch the processes from the database + $processes = &$data->getProcesses($_REQUEST['database']); + + $misc->printDatabaseNav(); + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strprocesses']}

\n"; + + if ($processes->recordCount() > 0) { + echo "\n"; + echo ""; + echo "\n"; + $i = 0; + while (!$processes->EOF) { + $id = (($i % 2) == 0 ? '1' : '2'); + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $processes->moveNext(); + $i++; + } + echo "
{$lang['strusername']}{$lang['strprocess']}{$lang['strsql']}
", $misc->printVal($processes->f['usename']), "", $misc->printVal($processes->f['procpid'], false, 'int4'), "", $misc->printVal($processes->f['current_query']), "
\n"; + } + else { + echo "

{$lang['strnodata']}

\n"; + } + } + /** * Allow database administration and tuning tasks */ @@ -416,6 +485,12 @@ case 'confirm_drop': doDrop(true); break; + case 'variables': + doVariables(); + break; + case 'processes': + doProcesses(); + break; default: doDefault(); break; diff --git a/lang/english.php b/lang/english.php index da3e2063..40f70899 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.120 2003/10/28 04:02:15 chriskl Exp $ + * $Id: english.php,v 1.121 2003/12/13 09:28:46 chriskl Exp $ */ // Language and character set @@ -111,6 +111,10 @@ $lang['strinfo'] = 'Info'; $lang['stroids'] = 'OIDs'; $lang['stradvanced'] = 'Advanced'; + $lang['strvariables'] = 'Variables'; + $lang['strprocess'] = 'Process'; + $lang['strprocesses'] = 'Processes'; + $lang['strsetting'] = 'Setting'; // Error handling $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 444425bd..8afc1b27 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.72 2003/10/28 04:02:16 chriskl Exp $ + * $Id: english.php,v 1.73 2003/12/13 09:28:46 chriskl Exp $ */ // Language and character set @@ -111,6 +111,10 @@ $lang['strinfo'] = 'Info'; $lang['stroids'] = 'OIDs'; $lang['stradvanced'] = 'Advanced'; + $lang['strvariables'] = 'Variables'; + $lang['strprocess'] = 'Process'; + $lang['strprocesses'] = 'Processes'; + $lang['strsetting'] = 'Setting'; // Error handling $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.'; -- 2.39.5