add basic support for listing aggregates and opclasses. we now display ALL postgres...
authorchriskl <chriskl>
Wed, 24 Dec 2003 11:12:20 +0000 (11:12 +0000)
committerchriskl <chriskl>
Wed, 24 Dec 2003 11:12:20 +0000 (11:12 +0000)
BUGS
HISTORY
aggregates.php [new file with mode: 0644]
browser.php
classes/database/BaseDB.php
classes/database/Postgres.php
classes/database/Postgres73.php
lang/english.php
lang/recoded/english.php
opclasses.php [new file with mode: 0644]
schema.php

diff --git a/BUGS b/BUGS
index 0b95d270af117e87054ce2a7a9f9773bb2a213f7..0b1d5b8a4b8f555325f9365787261bb15d59b91c 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -7,7 +7,7 @@ fix getIndexes() and getConstraints() for < 7.3 to know about index type
   (eg. constraints can only be btree indexes)
 re-enable help system
 all DROP and ALTER commands MUST be fully schema-qualified otherwise you can accidentally drop stuff in pg_catalog :(
-need icons for Casts and Conversions and Languages
+need icons for Casts and Conversions, Languages, Aggs and OpClasses
 submit changes to HTML_TreeMenu maintainer
 test < 7.3 Find feature for all new objects
 fix constraint search to get domain and table constraints?
@@ -18,4 +18,5 @@ investigate phpPgInfo
 
 Need to fix:
 * Variables and processes views for < 7.3
-* Viewing database properties is broken...
+* Add aggregates and opclasses to Find feature
+* Aggregate and opclass support for < 7.3
\ No newline at end of file
diff --git a/HISTORY b/HISTORY
index cf65e870d139e32f7fdc69fca305a8681477ad0e..2458a84ae86dfa615fc331c459df98e0784b920c 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -9,6 +9,7 @@ Features
 * Large speed improvements by reducing number of database
   connections and using external style sheet.
 * SQL pop-up window now defaults to the current database
+* Display aggregates and operator classes
 
 Bugs
 * Object browser fixed for databases with no schemas
diff --git a/aggregates.php b/aggregates.php
new file mode 100644 (file)
index 0000000..a9409e8
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+       /**
+        * Manage aggregates in a database
+        *
+        * $Id: aggregates.php,v 1.1 2003/12/24 11:12:20 chriskl Exp $
+        */
+
+       // Include application functions
+       include_once('./libraries/lib.inc.php');
+       
+       $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+       if (!isset($msg)) $msg = '';
+
+       /**
+        * Show default list of aggregates in the database
+        */
+       function doDefault($msg = '') {
+               global $data, $misc;
+               global $lang;
+
+               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['straggregates']}</h2>\n";
+               $misc->printMsg($msg);
+               
+               $aggregates = &$data->getAggregates();
+
+               if ($aggregates->recordCount() > 0) {
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strtype']}</th>";
+                       echo "</tr>\n";
+                       $i = 0;
+                       while (!$aggregates->EOF) {
+                               $id = (($i % 2) == 0 ? '1' : '2');
+                               echo "<tr><td class=\"data{$id}\">", $misc->printVal($aggregates->f['proname']), "</td>\n";
+                               echo "<td class=\"data{$id}\">";
+                               // If arg type is NULL, then we need to output "all types"
+                               if ($aggregates->f['proargtypes'] === null)
+                                       echo $lang['stralltypes'];
+                               else
+                                       echo $misc->printVal($aggregates->f['proargtypes']);
+                               echo "</td>\n";
+                               echo "</tr>\n";
+                               $aggregates->moveNext();
+                               $i++;
+                       }
+                       echo "</table>\n";
+               }
+               else {
+                       echo "<p>{$lang['strnoaggregates']}</p>\n";
+               }
+       }
+
+       $misc->printHeader($lang['straggregates']);
+       $misc->printBody();
+
+       switch ($action) {
+               default:
+                       doDefault();
+                       break;
+       }       
+
+       $misc->printFooter();
+
+?>
index e62a49eef4c1476de43e8f7eb4faa87b59d8dbc1..f63a32834a5c7330f46037e2eb50106e749e46b3 100644 (file)
@@ -5,7 +5,7 @@
         * if you click on a database it shows a list of database objects in that
         * database.
         *
-        * $Id: browser.php,v 1.33 2003/12/17 09:11:32 chriskl Exp $
+        * $Id: browser.php,v 1.34 2003/12/24 11:12:20 chriskl Exp $
         */
 
        // Include application functions
                }
                // Advanced
                if ($conf['show_advanced']) {
-                       if ($data->hasTypes() || $data->hasOperators() || $data->hasConversions()) {
+                       if ($data->hasTypes() || $data->hasOperators() || $data->hasConversions()
+                                       || $data->hasAggregates() || $data->hasOpClasses()) {
                                $adv_node = &new HTML_TreeNode(array(
                                                                'text' => $lang['stradvanced'], 
                                                                'link' => ($data->hasSchemas()) ? addslashes(htmlspecialchars("schema.php?{$querystr}&" . SID)) : null, 
                                // Add folder to schema
                                $schemanode->addItem($adv_node);                        
                        }
+                       // Aggregates
+                       if ($data->hasAggregates()) {
+                               $agg_node = &new HTML_TreeNode(array(
+                                                               'text' => addslashes($lang['straggregates']), 
+                                                               'link' => addslashes(htmlspecialchars("aggregates.php?{$querystr}")), 
+                                                               'icon' => "../../../images/themes/{$conf['theme']}/types.png", 
+                                                               'expandedIcon' => "../../../images/themes/{$conf['theme']}/types.png",
+                                                               'expanded' => false,
+                                                               'linkTarget' => 'detail'));
+
+                               // Add folder to schema
+                               $adv_node->addItem($agg_node);
+                       }
                        // Types
                        if ($data->hasTypes()) {
                                $type_node = &new HTML_TreeNode(array(
                                // Add folder to schema
                                $adv_node->addItem($opr_node);
                        }
+                       // Operator Classes
+                       if ($data->hasOpClasses()) {
+                               $opc_node = &new HTML_TreeNode(array(
+                                                               'text' => addslashes($lang['stropclasses']), 
+                                                               'link' => addslashes(htmlspecialchars("opclasses.php?{$querystr}")), 
+                                                               'icon' => "../../../images/themes/{$conf['theme']}/operators.png", 
+                                                               'expandedIcon' => "../../../images/themes/{$conf['theme']}/operators.png",
+                                                               'expanded' => false,
+                                                               'linkTarget' => 'detail'));
+
+                               // Add folder to schema
+                               $adv_node->addItem($opc_node);
+                       }
                        // Conversions
                        if ($data->hasConversions()) {
                                $con_node = &new HTML_TreeNode(array(
index 2ca304ccd5619511ef5752c9cb51fb012d082798..be5f45470c121bee83849ea523d93e4f578f5d90 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: BaseDB.php,v 1.36 2003/12/19 05:53:19 chriskl Exp $
+ * $Id: BaseDB.php,v 1.37 2003/12/24 11:12:20 chriskl Exp $
  */
 
 include_once('./classes/database/ADODB_base.php');
@@ -258,7 +258,8 @@ class BaseDB extends ADODB_base {
        function hasPartialIndexes() { return false; }
        function hasCasts() { return false; }
        function hasFullSubqueries() { return false; }
-
+       function hasPrepare() { return false; }
+       function hasOpClasses() { return false; }
 }
 
 ?>
index 0b01e3d080ea445103cc231f16c2621da3a6a093..8dc1a13dfa33eea0e68a7fdeb3df265cd371f28d 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.168 2003/12/17 09:11:32 chriskl Exp $
+ * $Id: Postgres.php,v 1.169 2003/12/24 11:12:20 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -3388,7 +3388,7 @@ class Postgres extends BaseDB {
                
                return $this->selectSet($sql);
        }
-
+       
        // Type conversion routines
 
        /**
@@ -3425,7 +3425,7 @@ class Postgres extends BaseDB {
        function hasLanguages() { return true; }
        function hasDropColumn() { return false; }
        function hasSRFs() { return true; }
-
+       function hasOpClasses() { return true; }
 }
 
 ?>
index c4a645dd3c07924f56594cd39de7ff3be657076e..9a77dd9bfe5f3dfe7dfb2df1d9481c62ac41433e 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.83 2003/12/17 09:11:32 chriskl Exp $
+ * $Id: Postgres73.php,v 1.84 2003/12/24 11:12:20 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1354,15 +1354,15 @@ class Postgres73 extends Postgres72 {
         */      
        function &getConversions() {
                $sql = "
-                       SELECT\r
-                              c.conname,\r
-                              pg_catalog.pg_encoding_to_char(c.conforencoding) AS conforencoding,\r
+                       SELECT
+                              c.conname,
+                              pg_catalog.pg_encoding_to_char(c.conforencoding) AS conforencoding,
                               pg_catalog.pg_encoding_to_char(c.contoencoding) AS contoencoding,
-                              c.condefault\r
-                       FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\r
-                       WHERE n.oid = c.connamespace\r
-                             AND n.nspname='{$this->_schema}'\r
-                       ORDER BY 1;\r
+                              c.condefault
+                       FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n
+                       WHERE n.oid = c.connamespace
+                             AND n.nspname='{$this->_schema}'
+                       ORDER BY 1;
                ";
 
                return $this->selectSet($sql);
@@ -1396,7 +1396,55 @@ class Postgres73 extends Postgres72 {
                ";
                
                return $this->selectSet($sql);
-       }       
+       }
+
+       // Aggregate functions
+       
+       /**
+        * Gets all aggregates
+        * @return A recordset
+        */
+       function &getAggregates() {
+               $sql = "
+                       SELECT
+                               p.proname,
+                               CASE p.proargtypes[0]
+                                       WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype
+                                       THEN NULL
+                                       ELSE pg_catalog.format_type(p.proargtypes[0], NULL)
+                               END AS proargtypes
+                       FROM pg_catalog.pg_proc p
+                               LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
+                       WHERE
+                               p.proisagg
+                               AND n.nspname='{$this->_schema}'
+                       ORDER BY 1, 2
+               ";
+
+               return $this->selectSet($sql);
+       }
+       
+       // Operator Class functions
+       
+       /**
+        * Gets all opclasses
+        * @return A recordset
+        */
+       function &getOpClasses() {
+               $sql = "
+                       SELECT
+                               pa.amname, po.opcname, po.opcintype::pg_catalog.regtype AS opcintype, po.opcdefault
+                       FROM
+                               pg_catalog.pg_opclass po, pg_catalog.pg_am pa, pg_catalog.pg_namespace pn
+                       WHERE
+                               po.opcamid=pa.oid
+                               AND po.opcnamespace=pn.oid
+                               AND pn.nspname='{$this->_schema}'
+                       ORDER BY 1,2
+               ";
+
+               return $this->selectSet($sql);
+       }
                
        // Capabilities
        function hasSchemas() { return true; }
@@ -1407,6 +1455,7 @@ class Postgres73 extends Postgres72 {
        function hasDomains() { return true; }
        function hasAlterTrigger() { return true; }
        function hasCasts() { return true; }
+       function hasPrepare() { return true; }
 
 }
 
index 55c00448817765acc81f21fd3b948600a2b4f1eb..23433733c2950dbe9039d26636b5edcb56331463 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.123 2003/12/16 00:32:28 soranzo Exp $
+        * $Id: english.php,v 1.124 2003/12/24 11:12:20 chriskl Exp $
         */
 
        // Language and character set
        $lang['strprocess'] = 'Process';
        $lang['strprocesses'] = 'Processes';
        $lang['strsetting'] = 'Setting';
+       $lang['strparameters'] = 'Parameters';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strreferringtables'] = 'Referring tables';
        $lang['strparenttables'] = 'Parent tables';
        $lang['strchildtables'] = 'Child tables';
+       
+       // Aggregates
+       $lang['straggregates'] = 'Aggregates';
+       $lang['strnoaggregates'] = 'No aggregates found.';
+       $lang['stralltypes'] = '(All types)';
+
+       // Operator Classes
+       $lang['stropclasses'] = 'Op Classes';
+       $lang['strnoopclasses'] = 'No operator classes found.';
+       $lang['straccessmethod'] = 'Access method';
 
        // Miscellaneous
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user "%s", %s';
index 70b29143f19897308b75796c7c1a7cfd89c9c335..2b13aea1402532267cd83909b338e0b3a1081d7f 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.75 2003/12/16 00:32:28 soranzo Exp $
+        * $Id: english.php,v 1.76 2003/12/24 11:12:21 chriskl Exp $
         */
 
        // Language and character set
        $lang['strprocess'] = 'Process';
        $lang['strprocesses'] = 'Processes';
        $lang['strsetting'] = 'Setting';
+       $lang['strparameters'] = 'Parameters';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strreferringtables'] = 'Referring tables';
        $lang['strparenttables'] = 'Parent tables';
        $lang['strchildtables'] = 'Child tables';
+       
+       // Aggregates
+       $lang['straggregates'] = 'Aggregates';
+       $lang['strnoaggregates'] = 'No aggregates found.';
+       $lang['stralltypes'] = '(All types)';
+
+       // Operator Classes
+       $lang['stropclasses'] = 'Op Classes';
+       $lang['strnoopclasses'] = 'No operator classes found.';
+       $lang['straccessmethod'] = 'Access method';
 
        // Miscellaneous
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user &quot;%s&quot;, %s';
diff --git a/opclasses.php b/opclasses.php
new file mode 100644 (file)
index 0000000..55905b9
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+       /**
+        * Manage opclasss in a database
+        *
+        * $Id: opclasses.php,v 1.1 2003/12/24 11:12:20 chriskl Exp $
+        */
+
+       // Include application functions
+       include_once('./libraries/lib.inc.php');
+       
+       $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+       if (!isset($msg)) $msg = '';
+
+       /**
+        * Show default list of opclasss in the database
+        */
+       function doDefault($msg = '') {
+               global $data, $misc;
+               global $lang;
+
+               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['stropclasses']}</h2>\n";
+               $misc->printMsg($msg);
+               
+               $opclasses = &$data->getOpClasses();
+
+               if ($opclasses->recordCount() > 0) {
+                       echo "<table><tr>\n";
+                       echo "<th class=\"data\">{$lang['straccessmethod']}</th>";
+                       echo "<th class=\"data\">{$lang['strname']}</th>";
+                       echo "<th class=\"data\">{$lang['strtype']}</th>";
+                       echo "<th class=\"data\">{$lang['strdefault']}</th>";
+                       echo "</tr>\n";
+                       $i = 0;
+                       while (!$opclasses->EOF) {
+                               $opclasses->f['opcdefault'] = $data->phpBool($opclasses->f['opcdefault']);
+                               $id = (($i % 2) == 0 ? '1' : '2');
+                               echo "<tr><td class=\"data{$id}\">", $misc->printVal($opclasses->f['amname']), "</td>\n";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($opclasses->f['opcname']), "</td>\n";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($opclasses->f['opcintype']), "</td>\n";
+                               echo "<td class=\"data{$id}\">", (($opclasses->f['opcdefault']) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+                               echo "</tr>\n";
+                               $opclasses->moveNext();
+                               $i++;
+                       }
+                       echo "</table>\n";
+               }
+               else {
+                       echo "<p>{$lang['strnoopclasses']}</p>\n";
+               }
+       }
+
+       $misc->printHeader($lang['stropclasses']);
+       $misc->printBody();
+
+       switch ($action) {
+               default:
+                       doDefault();
+                       break;
+       }       
+
+       $misc->printFooter();
+
+?>
index 658ea7cdb1e6f77c6f2c52bc4b2980df95726dd3..81616dcb6232ef28622892c9bf0b79d738a05db4 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Display properties of a schema
         *
-        * $Id: schema.php,v 1.12 2003/12/17 09:11:32 chriskl Exp $
+        * $Id: schema.php,v 1.13 2003/12/24 11:12:20 chriskl Exp $
         */
 
        // Include application functions (no db conn)
                if ($conf['show_advanced']) {
                        echo "<li>{$lang['stradvanced']}</li>\n";
                        echo "<ul>\n";
+                       echo "<li><a href=\"aggregates.php?{$misc->href}\">{$lang['straggregates']}</a></li>\n";
                        echo "<li><a href=\"types.php?{$misc->href}\">{$lang['strtypes']}</a></li>\n";
                        echo "<li><a href=\"operators.php?{$misc->href}\">{$lang['stroperators']}</a></li>\n";
+                       echo "<li><a href=\"opclasses.php?{$misc->href}\">{$lang['stropclasses']}</a></li>\n";
                        echo "<li><a href=\"conversions.php?{$misc->href}\">{$lang['strconversions']}</a></li>\n";
                        echo "</ul>\n";
                }