fix schema support for views. fix not having textarea for comment when creating...
authorchriskl <chriskl>
Thu, 3 Jun 2004 07:34:56 +0000 (07:34 +0000)
committerchriskl <chriskl>
Thu, 3 Jun 2004 07:34:56 +0000 (07:34 +0000)
BUGS
HISTORY
classes/database/Postgres73.php
classes/database/Postgres74.php
database.php

diff --git a/BUGS b/BUGS
index c55b529a26b38947f9c19e42dcd9dd5f260a2914..853273430ac8ebcfe2ea757d29767df24d8490d3 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -30,6 +30,5 @@ NEEDS TESTING
 * highlight things on the info stats page
 * advanced stats functions
 * prevent the user from dropping all the superusers
-* getView() isn't schema-aware for 7.3+?
 * rename function in 7.2 and below doesn't come back to the correct function
 * 7.5 function named parameters are not supported
diff --git a/HISTORY b/HISTORY
index 093edf9adde83c00f0af2fae03d0d818969bb7d4..ef2c4da3badf4408b019069dfc9f7b82bee94955 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -46,6 +46,7 @@ Bugs
   not want to use the same pop-up.
 * Fix create table if you don't supply as many fields as you originally
   specified.
+* Fix schema support for views
 
 Translations
 * Trad. Chinese from Chih-Hsin Lee
index b2102c606a5b1e45f2977980f09531c892b99823..9c7ef6f3eafbc7a520b9bc53f9f8adb4595c3d4b 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.116 2004/06/03 06:42:20 chriskl Exp $
+ * $Id: Postgres73.php,v 1.117 2004/06/03 07:34:56 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -532,6 +532,23 @@ class Postgres73 extends Postgres72 {
                return $this->selectSet($sql);
        }
        
+       /**
+        * Returns all details for a particular view
+        * @param $view The name of the view to retrieve
+        * @return View info
+        */
+       function &getView($view) {
+               $this->clean($view);
+
+               $sql = "SELECT c.relname AS viewname, pg_catalog.pg_get_userbyid(c.relowner) AS viewowner, 
+                          pg_catalog.pg_get_viewdef(c.oid) AS definition, pg_catalog.obj_description(c.oid, 'pg_class') AS comment
+                        FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
+                        WHERE (c.relname = '$view')
+                        AND n.nspname='{$this->_schema}'";
+               return $this->selectSet($sql);
+       }
+       
        /**
         * Updates a view.
         * @param $viewname The name fo the view to update
index 81e6ca3eea01ca66e64ac1edc7fc29909088e7b6..edb12bf2b67d5d5d83d94ce665f9d047d28a1c97 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.31 2004/05/19 01:28:35 soranzo Exp $
+ * $Id: Postgres74.php,v 1.32 2004/06/03 07:34:56 chriskl Exp $
  */
 
 include_once('./classes/database/Postgres73.php');
@@ -163,10 +163,12 @@ class Postgres74 extends Postgres73 {
         */
        function &getView($view) {
                $this->clean($view);
+               
                $sql = "SELECT c.relname AS viewname, pg_catalog.pg_get_userbyid(c.relowner) AS viewowner, 
                           pg_catalog.pg_get_viewdef(c.oid, true) AS definition, pg_catalog.obj_description(c.oid, 'pg_class') AS comment
-                        FROM pg_catalog.pg_class c 
-                        WHERE (c.relname = '$view')";
+                        FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
+                        WHERE (c.relname = '$view')
+                        AND n.nspname='{$this->_schema}'";
  
                return $this->selectSet($sql);
        }       
index 5cab3db572cf5027e26eb11c1348d870712cfe4e..f397d0cef4465604e52f547f27ff384ceccfeced 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.46 2004/05/28 08:17:21 chriskl Exp $
+        * $Id: database.php,v 1.47 2004/06/03 07:34:56 chriskl Exp $
         */
 
        // Include application functions
                echo "\t\t\t</select>\n\t\t</td>\n\t\n";
                
                echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
-               echo "\t\t<td class=\"data1\"><input name=\"formComment\" size=\"60\" value=\"",
-                       htmlspecialchars($_POST['formComment']), "\" /></td>\n\t</tr>\n";
+               echo "\t\t<td class=\"data1\"><textarea name=\"formComment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
+                       htmlspecialchars($_POST['formComment']), "</textarea></td>\n\t</tr>\n";
+                       
                echo "\t</tr>\n";
                echo "</table>\n";
                echo "<p>\n";
                                        echo "<td class=\"opbutton{$id}\"><a href=\"schema.php?database=",
                                                urlencode($_REQUEST['database']), "&amp;schema=",
                                                urlencode($schemas->f[$data->nspFields['nspname']]), "&amp;action=alter\">{$lang['stralter']}</a></td>\n";
+                                       // Trim long comments
+                                       if (strlen($schemas->f[$data->nspFields['nspcomment']]) > $conf['max_chars']) {
+                                               $schemas->f[$data->nspFields['nspcomment']] = substr($schemas->f[$data->nspFields['nspcomment']], 0, $conf['max_chars'] - 1) . $lang['strellipsis'];
+                                       }
                                        if ($conf['show_comments']) echo "<td class=\"data{$id}\">", $misc->printVal($schemas->f[$data->nspFields['nspcomment']]), "</td>\n";
                                        echo "</tr>\n";
                                        $schemas->moveNext();