add aggregates and opclasses to search results
authorchriskl <chriskl>
Fri, 30 Jan 2004 05:58:44 +0000 (05:58 +0000)
committerchriskl <chriskl>
Fri, 30 Jan 2004 05:58:44 +0000 (05:58 +0000)
BUGS
classes/database/Postgres.php
classes/database/Postgres73.php
database.php

diff --git a/BUGS b/BUGS
index d5fa5a36fa2b6f95dfdfd84a78528a83ea2abf8c..38da6525d4d78c6bcfd1c2b7817b68f5f02ad7de 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -11,14 +11,13 @@ need icons and Find 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?
+exclude system triggers from Find
 dump sequences when dumping tables
 fix dumping clustering info
 can't edit SELECT results by oid
 
 Need to fix:
 * Variables and processes views for < 7.3
-* Add aggregates and opclasses to Find feature
-* Aggregate and opclass support for < 7.3
 * The getType function needs to be ported to 7.2 and 7.3 classes to add
   pretty type name and schema support
 * Add query start time to processes view for 7.4+
index c0dfe633fec5f43bc3501aed281659fca8bdf5ac..9d270ab0a8a861d6e13cfe982ab6593f867ac696 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.178 2004/01/29 07:30:12 chriskl Exp $
+ * $Id: Postgres.php,v 1.179 2004/01/30 05:58:44 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -2194,6 +2194,20 @@ class Postgres extends BaseDB {
                                SELECT 'LANGUAGE', pl.oid, NULL, NULL, pl.lanname FROM pg_language pl
                                        WHERE lanname ~* '.*{$term}.*'";
                        if (!$conf['show_system']) $sql .= " AND pl.lanispl";
+
+                       // Aggregates
+                       $sql .= "                               
+                               UNION ALL
+                               SELECT DISTINCT ON (a.aggname) 'AGGREGATE', a.oid, NULL, NULL, a.aggname FROM pg_aggregate a 
+                                       WHERE aggname ~* '.*{$term}.*'";
+                       if (!$conf['show_system']) $sql .= " AND a.oid > '{$this->_lastSystemOID}'::oid";
+
+                       // Op Classes
+                       $sql .= "                               
+                               UNION ALL
+                               SELECT DISTINCT ON (po.opcname) 'OPCLASS', po.oid, NULL, NULL, po.opcname FROM pg_opclass po,
+                                       WHERE po.opcname ILIKE '%{$term}%'";
+                       if (!$conf['show_system']) $sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
                }
                                
                $sql .= " ORDER BY type, schemaname, relname, name";
index 8e4ca0077f4907ce598bf32e2c341c6b9405c985..8dcb7e834096187dbf7e253107e74071b7b5222f 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.87 2004/01/14 02:14:28 chriskl Exp $
+ * $Id: Postgres73.php,v 1.88 2004/01/30 05:58:45 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1185,7 +1185,7 @@ class Postgres73 extends Postgres72 {
                                AND pa.attname ILIKE '%{$term}%' AND pa.attnum > 0 AND NOT pa.attisdropped AND pc.relkind IN ('r', 'v') {$where}
                        UNION ALL
                        SELECT 'FUNCTION', pp.oid, pn.nspname, NULL, pp.proname FROM pg_catalog.pg_proc pp, pg_catalog.pg_namespace pn 
-                               WHERE pp.pronamespace=pn.oid AND proname ILIKE '%{$term}%' {$where}
+                               WHERE pp.pronamespace=pn.oid AND NOT pp.proisagg AND pp.proname ILIKE '%{$term}%' {$where}
                        UNION ALL
                        SELECT 'INDEX', NULL, pn.nspname, pc.relname, pc2.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn,
                                pg_catalog.pg_index pi, pg_catalog.pg_class pc2 WHERE pc.relnamespace=pn.oid AND pc.oid=pi.indrelid 
@@ -1236,6 +1236,14 @@ class Postgres73 extends Postgres72 {
                                UNION ALL
                                SELECT 'LANGUAGE', pl.oid, NULL, NULL, pl.lanname FROM pg_catalog.pg_language pl
                                        WHERE lanname ILIKE '%{$term}%' {$lan_where}
+                               UNION ALL
+                               SELECT DISTINCT ON (p.proname) 'AGGREGATE', p.oid, pn.nspname, NULL, p.proname FROM pg_catalog.pg_proc p
+                                       LEFT JOIN pg_catalog.pg_namespace pn ON p.pronamespace=pn.oid
+                                       WHERE p.proisagg AND p.proname ILIKE '%{$term}%' {$where}
+                               UNION ALL
+                               SELECT DISTINCT ON (po.opcname) 'OPCLASS', po.oid, pn.nspname, NULL, po.opcname FROM pg_catalog.pg_opclass po,
+                                       pg_catalog.pg_namespace pn WHERE po.opcnamespace=pn.oid
+                                       AND po.opcname ILIKE '%{$term}%' {$where}
                        ";
                }
                // Otherwise just add domains
index 74a5e5428563367696b72c514e481a285dfd07af..cab5097469a70f8d9a48d6dbd1fbf13499a2928f 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.32 2004/01/04 07:30:12 chriskl Exp $
+        * $Id: database.php,v 1.33 2004/01/30 05:58:44 chriskl Exp $
         */
 
        // Include application functions
                                                        case 'LANGUAGE':
                                                                echo $lang['strlanguages'];
                                                                break;
+                                                       case 'AGGREGATE':
+                                                               echo $lang['straggregates'];
+                                                               break;
+                                                       case 'OPCLASS':
+                                                               echo $lang['stropclasses'];
+                                                               break;
                                                }
                                                echo "</h2>";
                                                echo "<ul>\n";
                                                case 'LANGUAGE':
                                                        echo "<li><a href=\"languages.php?{$misc->href}\">", _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
                                                        break;
+                                               case 'AGGREGATE':
+                                                       echo "<li><a href=\"aggregates.php?{$misc->href}&amp;schema=", urlencode($rs->f['schemaname']), "\">",
+                                                               $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
+                                                       break;
+                                               case 'OPCLASS':
+                                                       echo "<li><a href=\"opclasses.php?{$misc->href}&amp;schema=", urlencode($rs->f['schemaname']), "\">",
+                                                               $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
+                                                       break;
                                        }
                                        $rs->moveNext();        
                                }