Made setSchema support more odd cases when some objects depends upon
authorjollytoad <jollytoad>
Thu, 22 Jul 2004 13:26:03 +0000 (13:26 +0000)
committerjollytoad <jollytoad>
Thu, 22 Jul 2004 13:26:03 +0000 (13:26 +0000)
the users search_path setting.

classes/database/Postgres73.php
sqledit.php

index cc54624d10a2bb23cf5b9e105e76e6714dd84cee..ca25e24e4e3032739cd34956c2b75bc7ba38fef1 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.131 2004/07/15 10:59:55 soranzo Exp $
+ * $Id: Postgres73.php,v 1.132 2004/07/22 13:26:03 jollytoad Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -63,7 +63,11 @@ class Postgres73 extends Postgres72 {
         * @return 0 success
         */
        function setSchema($schema) {
-               $status = $this->setSearchPath(array($schema, 'pg_catalog'));
+               // Get the current schema search path, including 'pg_catalog'.
+               $search_path = $this->getSearchPath();
+               // Prepend $schema to search path
+               array_unshift($search_path, $schema);
+               $status = $this->setSearchPath($search_path);
                if ($status == 0) {
                        $this->clean($schema);
                        $this->_schema = $schema;
@@ -90,11 +94,12 @@ class Postgres73 extends Postgres72 {
        }
        
        /**
-        * Return the default schema search path
+        * Return the current schema search path
+        * @return Array of schema names
         */
        function getSearchPath() {
-               $sql = 'SHOW search_path';
-               return $this->selectField($sql, 'search_path');
+               $sql = 'SELECT current_schemas(true) AS search_path';
+               return $this->phpArray($this->selectField($sql, 'search_path'));
        }
 
        /**
index cd6c91e685d3145469b20656c319167d8a854db1..f5c18ddfff76b2912962db5667eab5b2f23e0276 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Alternative SQL editing window
         *
-        * $Id: sqledit.php,v 1.22 2004/07/16 16:01:06 soranzo Exp $
+        * $Id: sqledit.php,v 1.23 2004/07/22 13:26:03 jollytoad Exp $
         */
 
        // Include application functions
 
                if ($data->hasSchemas()) {
                        if (!isset($_REQUEST['search_path']))
-                               $_REQUEST['search_path'] = $data->getSearchPath();
+                               $_REQUEST['search_path'] = implode(',',$data->getSearchPath());
                
                        echo "\n<label>{$lang['strsearchpath']}: <input type=\"text\" name=\"search_path\" size=\"30\" value=\"",
                                htmlspecialchars($_REQUEST['search_path']), "\" /></label>";