getAggregates support for < 7.3
authorchriskl <chriskl>
Sun, 18 Jan 2004 10:39:45 +0000 (10:39 +0000)
committerchriskl <chriskl>
Sun, 18 Jan 2004 10:39:45 +0000 (10:39 +0000)
classes/database/Postgres.php
classes/database/Postgres71.php

index e97e72c296809b58f270d368925e74ecddf7fe3b..581b92b42b0901480f43b3b40bdb46418c4f1512 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.175 2004/01/14 02:14:28 chriskl Exp $
+ * $Id: Postgres.php,v 1.176 2004/01/18 10:39:45 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -3485,6 +3485,37 @@ class Postgres extends BaseDB {
                return $this->selectSet($sql);
        }
 
+       // Aggregate functions
+       
+       /**
+        * Gets all aggregates
+        * @return A recordset
+        */
+       function &getAggregates() {
+               global $conf;
+               
+               if ($conf['show_system'])
+                       $where = '';
+               else
+                       $where = "WHERE a.oid > '{$this->_lastSystemOID}'::oid";
+
+               $sql = "
+                       SELECT
+                               a.aggname AS proname,
+                               CASE a.aggbasetype
+                                       WHEN 0 THEN NULL
+                                       ELSE (SELECT typname FROM pg_type t WHERE t.oid=a.aggbasetype)
+                               END AS proargtypes
+                       FROM 
+                               pg_aggregate a
+                       {$where}
+                       ORDER BY
+                               1, 2;
+               ";
+
+               return $this->selectSet($sql);
+       }
+       
        // Type conversion routines
 
        /**
index d01a1b7f83cf74457198da8e2ce058173ca8cf31..7e4bda1eea164d53e165457814979641cd1cec24 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres71.php,v 1.51 2004/01/03 19:15:44 soranzo Exp $
+ * $Id: Postgres71.php,v 1.52 2004/01/18 10:39:45 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -331,6 +331,37 @@ class Postgres71 extends Postgres {
 
                return $this->selectSet($sql);
        }       
+
+       // Aggregate functions
+       
+       /**
+        * Gets all aggregates
+        * @return A recordset
+        */
+       function &getAggregates() {
+               global $conf;
+               
+               if ($conf['show_system'])
+                       $where = '';
+               else
+                       $where = "WHERE a.oid > '{$this->_lastSystemOID}'::oid";
+
+               $sql = "
+                       SELECT
+                               a.aggname AS proname,
+                               CASE a.aggbasetype
+                                       WHEN 0 THEN NULL
+                                       ELSE format_type(a.aggbasetype, NULL)
+                               END AS proargtypes
+                       FROM 
+                               pg_aggregate a
+                       {$where}
+                       ORDER BY
+                               1, 2;
+               ";
+
+               return $this->selectSet($sql);
+       }
                
        // Capabilities
        function hasAlterTableOwner() { return true; }