phase 1 of tablespaces. still more to do
authorchriskl <chriskl>
Sun, 4 Jul 2004 15:02:34 +0000 (15:02 +0000)
committerchriskl <chriskl>
Sun, 4 Jul 2004 15:02:34 +0000 (15:02 +0000)
BUGS
TODO
classes/database/ADODB_base.php
classes/database/BaseDB.php
classes/database/Connection.php
classes/database/Postgres75.php
lang/english.php
lang/recoded/english.php
topbar.php

diff --git a/BUGS b/BUGS
index cc37cbe47b5f5656c0c8457a47ec93e681ed1898..dac20f1ff3b76b0d84bbfdf443d5ec221578f6d0 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -34,5 +34,6 @@ NEEDS TESTING
 * Fix SQL window parent update to not update any random window
 * Show owner on privileges screen?
  http://devilock.mine.nu/textarea_tab.html
-
-* DOMAINS NOT SHOWN IN TYPE LISTS!
+* privs on tablespaces
+* creating objects in tablespaces
+* fix test for MINGW backend
diff --git a/TODO b/TODO
index b6ab673ea1aec9e85c00390b5f306d1cc7e2822b..266065b64b545c2255e33fe2585bd78117154171 100644 (file)
--- a/TODO
+++ b/TODO
@@ -20,7 +20,6 @@ Users
 Groups
 ------
 
-* -Alter group (chriskl)
 
 Permissions
 -----------
@@ -30,15 +29,14 @@ Permissions
 Databases
 ---------
 
-* -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 (chriskl)
 * Comments on databases
 * -Vacuum & analyze (bryan)
 
 Tables
 ------
 
+* Allow PK and UNIQUE and FKs during create table
 * -Not using proper attFields array for attribute info (i was being lazy) (wontfix)
 * -Rename table
 * -Change table owner
@@ -51,7 +49,6 @@ Tables
 Views
 -----
 
-* Display, add, edit and drop rules on views
 
 Sequences
 ---------
@@ -60,13 +57,11 @@ Sequences
 Functions
 ---------
 
-* Browse function (set-returning-functions only)
 * Syntax highlighting?
 
 Indexes 
 -------
 
-* -Partial indexes (chriskl)
 * Functional indexes
 
 Types
@@ -77,19 +72,16 @@ Types
 Operators
 ---------
 
-* -Properties (chriskl)
-* -Drop (chriskl)
 * Create
 
 Operator Classes
 ----------------
 
-* Unimplemented
+* Create
 
 Triggers
 --------
 
-* -Alter trigger (7.3+) (eg. rename trigger) (chriskl)
 
 Aggregates
 ----------
@@ -101,7 +93,6 @@ Aggregates
 Languages
 ---------
 
-* -Display (chriskl)
 * Drop
 * Create
 
@@ -113,7 +104,6 @@ Domains (7.3)
 Conversions (7.3)
 -----------------
 
-* -Display (chriskl)
 * Properties
 * Drop
 * Create
@@ -121,16 +111,10 @@ Conversions (7.3)
 Casts (7.3)
 -----------
 
-* -Display (chriskl)
 * Properties
 * Drop
 * Create
 
-Settings
---------
-
-* -Postgres 7.3 returns SHOW ALL as a proper result set - makes it easy to do a phpMyAdmin style 'view settings'.
-
 Miscellaneous
 -------------
 
@@ -141,15 +125,12 @@ Miscellaneous
 * Allow setting/dropping comments for all objects (Dan Boren)
 * Show owner for all objects
 * Allow changing owner for objects that have this feature (7.4+ generally)
-* -Config option to disallow pgsql and postgres logins
-* Do David Smith's redireect idea to prevent refresh login resending password
 * Translated FAQ
 
 Exotic
 ------
 
 * Support contrib/tsearch2 for easy full text indexes
-* -Search for object feature (chriskl)
 * Pivot reports (ADODB has a feature for this)
 * Parameratised reports (use prepared queries)
 * Full web accessability conformance
index 1eea55618cb836149ba7da3d804e20e122f250d7..fc09bbfa05c89133570d7269ad16efdd7881277d 100644 (file)
@@ -3,7 +3,7 @@
 /*
  * Parent class of all ADODB objects.
  *
- * $Id: ADODB_base.php,v 1.16 2003/12/17 09:11:32 chriskl Exp $
+ * $Id: ADODB_base.php,v 1.17 2004/07/04 15:02:35 chriskl Exp $
  */
 
 include_once('./libraries/errorhandler.inc.php');
@@ -274,6 +274,15 @@ class ADODB_base {
                return !$this->conn->RollbackTrans();
        }
 
+       /**
+        * Get the backend platform
+        * @return The backend platform
+        */
+       function getPlatform() {
+               //return $this->conn->platform;
+               return "UNKNOWN";
+       }
+
        // Type conversion routines
 
        /**
index 244c589cb60e53764b38609ab581be55e92ae9b9..4f355873e8070e8a41ed953fb62b82f1906152c6 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.48 2004/05/30 14:31:35 chriskl Exp $
+ * $Id: BaseDB.php,v 1.49 2004/07/04 15:02:35 chriskl Exp $
  */
 
 include_once('./classes/database/ADODB_base.php');
@@ -282,6 +282,7 @@ class BaseDB extends ADODB_base {
        function hasFullVacuum() { return false; }
        function hasForeignKeysInfo() { return false; }
        function hasViewColumnRename() { return false; }
+       function hasTablespaces() { return false; }
 
 }
 
index 7cab90be8afd50303d0e0d8a36109c10a818548a..3e9f6da56154be6f4a01af4046064073398174a7 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * Class to represent a database connection
  *
- * $Id: Connection.php,v 1.4 2004/06/07 11:38:39 soranzo Exp $
+ * $Id: Connection.php,v 1.5 2004/07/04 15:02:35 chriskl Exp $
  */
 
 include_once('./classes/database/ADODB_base.php');
@@ -11,7 +11,10 @@ include_once('./classes/database/ADODB_base.php');
 class Connection {
 
        var $conn;
-
+       
+       // The backend platform.  Set to UNKNOWN by default.
+       var $platform = 'UNKNOWN';
+       
        /**
         * Creates a new connection.  Will actually make a database connection.
         * @param $fetchMode Defaults to associative.  Override for different behaviour
@@ -30,7 +33,8 @@ class Connection {
        }
 
        /**
-        * Gets the name of the correct database driver to use
+        * Gets the name of the correct database driver to use.  As a side effect,
+        * sets the platform.
         * @param (return-by-ref) $description A description of the database and version
         * @return The class name of the driver eg. Postgres73
         * @return null if version is < 7.0
@@ -42,6 +46,10 @@ class Connection {
                $sql = "SELECT VERSION() AS version";
                $field = $adodb->selectField($sql, 'version');
 
+               // Check the platform, if it's mingw, set it
+               if (eregi(' mingw ', $field))
+                       $this->platform = 'MINGW';
+
                $params = explode(' ', $field);
                if (!isset($params[1])) return -3;
 
index f5a620c39c4745e37b1b7d1a77f8edc715d7b119..654d0208145a5befca3046f907bd59aa3d60e1a3 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 7.5 support
  *
- * $Id: Postgres75.php,v 1.6 2004/06/06 08:50:28 chriskl Exp $
+ * $Id: Postgres75.php,v 1.7 2004/07/04 15:02:35 chriskl Exp $
  */
 
 include_once('./classes/database/Postgres74.php');
@@ -137,7 +137,121 @@ class Postgres75 extends Postgres74 {
 
                return $this->endTransaction();
        }
+       
+       // Tablespace functions
+       
+       /**
+        * Retrieves information for all tablespaces
+        * @return A recordset
+        */
+       function getTablespaces() {
+               global $conf;
+               
+               $sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation
+                                       FROM pg_catalog.pg_tablespace";
+                                       
+               if (!$conf['show_system']) {
+                       $sql .= " WHERE spcname NOT LIKE 'pg\\\\_%'";
+               }
+               
+               $sql .= " ORDER BY spcname";
+                                       
+               return $this->selectSet($sql);
+       }
+       
+       /**
+        * Retrieves a tablespace's information
+        * @return A recordset
+        */
+       function getTablespace($spcname) {
+               $this->clean($spcname);
+               
+               $sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation
+                                       FROM pg_catalog.pg_tablespace WHERE spcname='{$spcname}'";
+                                       
+               return $this->selectSet($sql);
+       }
+       
+       /**
+        * Creates a tablespace
+        * @param $spcname The name of the tablespace to create
+        * @param $spcowner The owner of the tablespace. '' for current
+        * @param $spcloc The directory in which to create the tablespace
+        * @return 0 success
+        */
+       function createTablespace($spcname, $spcowner, $spcloc) {
+               $this->fieldClean($spcname);
+               $this->clean($spcloc);
+               
+               $sql = "CREATE TABLESPACE \"{$spcname}\"";
+               
+               if ($spcowner != '') {
+                       $this->fieldClean($spcowner);
+                       $sql .= " OWNER \"{$spcowner}\"";
+               }
+               
+               $sql .= " LOCATION '{$spcloc}'";
 
-       function hasAlterColumnType() { return true; }
+               return $this->execute($sql);
+       }
+
+       /**
+        * Drops a tablespace
+        * @param $spcname The name of the domain to drop
+        * @return 0 success
+        */
+       function dropTablespace($spcname) {
+               $this->fieldClean($spcname);
+
+               $sql = "DROP TABLESPACE \"{$spcname}\"";
+
+               return $this->execute($sql);
+       }
+
+       /**
+        * Alters a tablespace
+        * @param $spcname The name of the tablespace
+        * @param $name The new name for the tablespace
+        * @param $owner The new owner for the tablespace
+        * @return 0 success
+        * @return -1 transaction error
+        * @return -2 owner error
+        * @return -3 rename error
+        */
+       function alterTablespace($spcname, $name, $owner) {
+               $this->fieldClean($spcname);
+               $this->fieldClean($name);
+               $this->fieldClean($owner);
+
+               // Begin transaction
+               $status = $this->beginTransaction();
+               if ($status != 0) return -1;
+
+               // Owner
+               $sql = "ALTER TABLESPACE \"{$spcname}\" OWNER TO \"{$owner}\"";
+               $status = $this->execute($sql);
+               if ($status != 0) {
+                       $this->rollbackTransaction();
+                       return -2;
+               }
+
+               // Rename (only if name has changed)
+               if ($name != $spcname) {
+                       $sql = "ALTER TABLESPACE \"{$spcname}\" RENAME TO \"{$name}\"";
+                       $status = $this->execute($sql);
+                       if ($status != 0) {
+                               $this->rollbackTransaction();
+                               return -3;
+                       }
+               }
+                               
+               return $this->endTransaction();
+       }
                
+       function hasAlterColumnType() { return true; }
+       function hasTablespaces() { 
+               $platform = $this->getPlatform();
+               return $platform != 'MINGW';
+       }
+       
 }
index 36a4a59832629bdef291f7617d0bfc39d8ebf0d9..12f3952ee00083738d45b3cf3744c572e023fd57 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.147 2004/06/07 11:38:39 soranzo Exp $
+        * $Id: english.php,v 1.148 2004/07/04 15:02:35 chriskl Exp $
         */
 
        // Language and character set
        $lang['strdisk'] = 'Disk';
        $lang['strrows2'] = 'Rows';
 
+       // Tablespaces
+       $lang['strtablespaces'] = 'Tablespaces';
+       $lang['strnotablespaces'] = 'No tablespaces found.';
+       $lang['strcreatetablespace'] = 'Create tablespace';
+       $lang['strlocation'] = 'Location';
+       $lang['strtablespaceneedsname'] = 'You must give a name for your tablespace.';
+       $lang['strtablespaceneedsloc'] = 'You must give a directory in which to create the tablespace.';
+       $lang['strtablespacecreated'] = 'Tablespace created';
+       $lang['strtablespacecreatedbad'] = 'Tablespace creation failed';
+       $lang['strconfdroptablespace'] = 'Are you sure you want to drop the tablespace "%s"?';
+       $lang['strtablespacedropped'] = 'Tablespace dropped.';
+       $lang['strtablespacedroppedbad'] = 'Tablespace drop failed.';
+       $lang['strtablespacealtered'] = 'Tablespace altered.';
+       $lang['strtablespacealteredbad'] = 'Tablespace alteration failed.';
+
        // Miscellaneous
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user "%s", %s';
        $lang['strtimefmt'] = 'jS M, Y g:iA';
index 3c3fd6e7548c67aa7acd34d2656173de44a09715..ea535d1c5244637f7a9d7ac5f55d3207da8b2e0a 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.100 2004/06/07 11:38:39 soranzo Exp $
+        * $Id: english.php,v 1.101 2004/07/04 15:02:35 chriskl Exp $
         */
 
        // Language and character set
        $lang['strdisk'] = 'Disk';
        $lang['strrows2'] = 'Rows';
 
+       // Tablespaces
+       $lang['strtablespaces'] = 'Tablespaces';
+       $lang['strnotablespaces'] = 'No tablespaces found.';
+       $lang['strcreatetablespace'] = 'Create tablespace';
+       $lang['strlocation'] = 'Location';
+       $lang['strtablespaceneedsname'] = 'You must give a name for your tablespace.';
+       $lang['strtablespaceneedsloc'] = 'You must give a directory in which to create the tablespace.';
+       $lang['strtablespacecreated'] = 'Tablespace created';
+       $lang['strtablespacecreatedbad'] = 'Tablespace creation failed';
+       $lang['strconfdroptablespace'] = 'Are you sure you want to drop the tablespace &quot;%s&quot;?';
+       $lang['strtablespacedropped'] = 'Tablespace dropped.';
+       $lang['strtablespacedroppedbad'] = 'Tablespace drop failed.';
+       $lang['strtablespacealtered'] = 'Tablespace altered.';
+       $lang['strtablespacealteredbad'] = 'Tablespace alteration failed.';
+
        // Miscellaneous
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user &quot;%s&quot;, %s';
        $lang['strtimefmt'] = 'jS M, Y g:iA';
index b85eae5ea4b2d776c241d4e6fa9121d38e784629..f03351e5260f77bb6d316585473494b3ced75214 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Top menu for phpPgAdmin
         *
-        * $Id: topbar.php,v 1.23 2004/05/31 09:46:37 soranzo Exp $
+        * $Id: topbar.php,v 1.24 2004/07/04 15:02:35 chriskl Exp $
         */
 
        // Include application functions
@@ -39,6 +39,9 @@
        endif;
 ?>
                        <a class="toplink" href="users.php?action=account" target="detail"><?php echo $lang['straccount'] ?></a> |
+<?php if ($data->hasTablespaces()) : ?>
+                       <a class="toplink" href="tablespaces.php" target="detail"><?php echo $lang['strtablespaces'] ?></a> | 
+<?php endif; ?>
 <?php if ($conf['show_reports']) : ?>
                        <a class="toplink" href="reports.php" target="detail"><?php echo $lang['strreports'] ?></a> |
 <?php endif; ?>