allow create table with array columns, support -n pg_dump option in 7.4+ to specify...
authorchriskl <chriskl>
Mon, 29 Mar 2004 02:05:31 +0000 (02:05 +0000)
committerchriskl <chriskl>
Mon, 29 Mar 2004 02:05:31 +0000 (02:05 +0000)
HISTORY
classes/database/BaseDB.php
classes/database/Postgres.php
classes/database/Postgres74.php
dataexport.php
dbexport.php
tables.php

diff --git a/HISTORY b/HISTORY
index 65b902882ebaa2b089f144e1699d3b843dc0683c..741807bdaa83bc4032d0270e345d4c3d105406df 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -7,9 +7,11 @@ Version 3.4-dev
 Features
 * Add CACHE and CYCLE parameters in sequence creation
 * View, add, edit and delete comments on views, schemas and columns (Dan Boren)
+* Allow creating array columns in tables
 
 Bugs
 * Fix pg_dump output for PostgreSQL 7.0.x and 7.1.x
+* In 7.4 pg_dump, specify schema when dumping tables
 
 Version 3.3.1
 -------------
index 513c9a9663690c88c5b4978d49a643e8a709f334..4b88ee90410c2608ed8037180e7f23b6e324a3e4 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.41 2004/03/06 11:30:00 chriskl Exp $
+ * $Id: BaseDB.php,v 1.42 2004/03/29 02:05:31 chriskl Exp $
  */
 
 include_once('./classes/database/ADODB_base.php');
@@ -272,6 +272,7 @@ class BaseDB extends ADODB_base {
        function hasVariables() { return false; }
        function hasFullExplain() { return false; }
        function hasStatsCollector() { return false; }
+       function hasSchemaDump() { return false; }
 }
 
 ?>
index 46e9e20134c0b871ebb653690a8dd2919f1ce0b5..dd370f3b32a3572cbc7f8639d49668a3aa7469e3 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.186 2004/03/12 08:56:53 chriskl Exp $
+ * $Id: Postgres.php,v 1.187 2004/03/29 02:05:31 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1132,6 +1132,7 @@ class Postgres extends BaseDB {
         * @param $fields The number of fields
         * @param $field An array of field names
         * @param $type An array of field types
+        * @param $array An array of '' or [] for each type if it's an array or not
         * @param $length An array of field lengths
         * @param $notnull An array of not null
         * @param $default An array of default values
@@ -1140,7 +1141,8 @@ class Postgres extends BaseDB {
         * @return 0 success
         * @return -1 no fields supplied
         */
-       function createTable($name, $fields, $field, $type, $length, $notnull, $default, $withoutoids, $colcomment, $tblcomment) {
+       function createTable($name, $fields, $field, $type, $array, $length, $notnull, 
+                                                                       $default, $withoutoids, $colcomment, $tblcomment) {
                $this->fieldClean($name);
                $this->fieldClean($tblcomment);
 
@@ -1180,7 +1182,9 @@ class Postgres extends BaseDB {
                                        $sql .= "\"{$field[$i]}\" {$type[$i]}";
                                        if ($length[$i] != '') $sql .= "({$length[$i]})";
                        }
-
+                       // Add array qualifier if necessary
+                       if ($array[$i] == '[]') $sql .= '[]';
+                       // Add other qualifiers
                        if (isset($notnull[$i])) $sql .= " NOT NULL";
                        if ($default[$i] != '') $sql .= " DEFAULT {$default[$i]}";
                        if ($i != $fields - 1) $sql .= ", ";
index 3a3bddf1d9b0bb2b30c2c56132547cbfdd37c0e8..c41d530f5caef81d061c5829f06d8764b0a9c1ec 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres74.php,v 1.25 2004/03/12 08:56:54 chriskl Exp $
+ * $Id: Postgres74.php,v 1.26 2004/03/29 02:05:31 chriskl Exp $
  */
 
 include_once('./classes/database/Postgres73.php');
@@ -411,6 +411,7 @@ class Postgres74 extends Postgres73 {
        function hasGrantOption() { return true; }
        function hasDomainConstraints() { return true; }
        function hasUserRename() { return true; }
+       function hasSchemaDump() { return true; }
        
 }
 
index 2db816cf15dbc217c30ea4d8acb28f5546afd4e4..a515cb56c713b3d224993b97400d018a341c24e5 100644 (file)
@@ -4,7 +4,7 @@
         * Does an export to the screen or as a download.  This checks to
         * see if they have pg_dump set up, and will use it if possible.
         *
-        * $Id: dataexport.php,v 1.11 2004/01/29 07:30:11 chriskl Exp $
+        * $Id: dataexport.php,v 1.12 2004/03/29 02:05:31 chriskl Exp $
         */
 
        $extensions = array(
@@ -35,6 +35,7 @@
                                        $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
+                                       $url .= '&schema=' . urlencode($_REQUEST['schema']);
                                        $url .= '&d_format=' . urlencode($_REQUEST['d_format']);
                                        $url .= '&output=' . urlencode($_REQUEST['output']);
                                        if (isset($_REQUEST['d_oids'])) $url .= '&d_oids=' . urlencode($_REQUEST['d_oids']);
@@ -55,6 +56,7 @@
                                        $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
+                                       $url .= '&schema=' . urlencode($_REQUEST['schema']);
                                        $url .= '&output=' . urlencode($_REQUEST['output']);
                                        if (isset($_REQUEST['s_clean'])) $url .= '&s_clean=' . urlencode($_REQUEST['s_clean']);
                                        $url .= "&" . SID;
@@ -71,6 +73,7 @@
                                        $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
+                                       $url .= '&schema=' . urlencode($_REQUEST['schema']);
                                        $url .= '&sd_format=' . urlencode($_REQUEST['sd_format']);
                                        $url .= '&output=' . urlencode($_REQUEST['output']);
                                        if (isset($_REQUEST['sd_clean'])) $url .= '&sd_clean=' . urlencode($_REQUEST['sd_clean']);
index 33ad393fa4d7a1b5c98a85bd2cebfdc2f3ef766b..4c3a3b72dac732850951d6208f6388539775d19d 100644 (file)
@@ -3,13 +3,13 @@
         * Does an export of a database or a table (via pg_dump)
         * to the screen or as a download.
         *
-        * $Id: dbexport.php,v 1.9 2004/03/14 06:55:53 chriskl Exp $
+        * $Id: dbexport.php,v 1.10 2004/03/29 02:05:31 chriskl Exp $
         */
 
        // Include application functions
        $_no_output = true;
        include_once('./libraries/lib.inc.php');
-       
+
        // Check that database dumps are enabled.
        if ($misc->isDumpEnabled()) {
 
                // Check for a table specified
                if (isset($_REQUEST['table'])) {
                        $cmd .= " -t " . escapeshellarg($_REQUEST['table']);
+                       // If we are 7.4 or higher, assume they are using 7.4 pg_dump and
+                       // set dump schema as well.
+                       if ($data->hasSchemaDump()) {
+                               $cmd .= " -n " . escapeshellarg($_REQUEST['schema']);
+                       }                       
                }
 
                // Check for GZIP compression specified
index baa131cd945c344df978d438d4698967a2a94df3..88f3d4fc6463ca310732354847a2d86e5db3c4bc 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.45 2004/03/12 08:56:51 chriskl Exp $
+        * $Id: tables.php,v 1.46 2004/03/29 02:05:31 chriskl Exp $
         */
 
        // Include application functions
                                                        $misc->printVal($typname), "</option>\n";
                                                $types->moveNext();
                                        }
-                                       echo "</select></td>";
+                                       echo "</select>";
+                                       
+                                       // Output array type selector
+                                       echo "<select name=\"array[{$i}]\">\n";
+                                       echo "<option value=\"\"", (isset($_REQUEST['array'][$i]) && $_REQUEST['array'][$i] == '') ? ' selected="selected"' : '', "></option>\n";
+                                       echo "<option value=\"[]\"", (isset($_REQUEST['array'][$i]) && $_REQUEST['array'][$i] == '[]') ? ' selected="selected"' : '', ">[ ]</option>\n";
+                                       echo "</select></td>\n";
+                                       
                                        echo "<td><input name=\"length[{$i}]\" size=\"10\" value=\"", 
                                                htmlspecialchars($_REQUEST['length'][$i]), "\" /></td>";
                                        echo "<td><input type=\"checkbox\" name=\"notnull[{$i}]\"", (isset($_REQUEST['notnull'][$i])) ? ' checked="checked"' : '', " /></td>";
                                }
                                
                                $status = $data->createTable($_REQUEST['name'], $_REQUEST['fields'], $_REQUEST['field'],
-                                                               $_REQUEST['type'], $_REQUEST['length'], $_REQUEST['notnull'], $_REQUEST['default'],
+                                                               $_REQUEST['type'], $_REQUEST['array'], $_REQUEST['length'], $_REQUEST['notnull'], $_REQUEST['default'],
                                                                isset($_REQUEST['withoutoids']), $_REQUEST['colcomment'], $_REQUEST['tblcomment']);
                                if ($status == 0) {
                                        $_reload_browser = true;