Fix for bug #3092826 "schema owner is blank for role with nologin", reported by Sompop
authorGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Fri, 22 Oct 2010 15:47:09 +0000 (17:47 +0200)
committerGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Fri, 22 Oct 2010 15:47:09 +0000 (17:47 +0200)
classes/database/Postgres.php
classes/database/Postgres80.php

index f579f29978aab253853e3074e6410e9bc33ebe48..5e4dba0bbf0581950c3debda1f670c90655ac1d9 100755 (executable)
@@ -861,10 +861,10 @@ class Postgres extends ADODB_base {
                }
                else $where = "WHERE nspname !~ '^pg_t(emp_[0-9]+|oast)$'";
                $sql = "
-                       SELECT pn.nspname, pu.usename AS nspowner,
+                       SELECT pn.nspname, pu.rolname AS nspowner,
                                pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment
                        FROM pg_catalog.pg_namespace pn
-                               LEFT JOIN pg_catalog.pg_user pu ON (pn.nspowner = pu.usesysid)
+                               LEFT JOIN pg_catalog.pg_authid pu ON (pn.nspowner = pu.oid)
                        {$where}
                        ORDER BY nspname";
 
index b64327b767cdb05e055d289578a5993b13baaf63..0bb9db6492c4b8e94e8e234b4b6cb2148ea22d67 100644 (file)
@@ -105,6 +105,34 @@ class Postgres80 extends Postgres81 {
 
        // Schema functions
 
+       /**
+        * Return all schemas in the current database.
+        * @return All schemas, sorted alphabetically
+        */
+       function getSchemas() {
+               global $conf, $slony;
+
+               if (!$conf['show_system']) {
+                       $where = "WHERE nspname NOT LIKE 'pg@_%' ESCAPE '@' AND nspname != 'information_schema'";
+                       if (isset($slony) && $slony->isEnabled()) {
+                               $temp = $slony->slony_schema;
+                               $this->clean($temp);
+                               $where .= " AND nspname != '{$temp}'";
+                       }
+
+               }
+               else $where = "WHERE nspname !~ '^pg_t(emp_[0-9]+|oast)$'";
+               $sql = "
+                       SELECT pn.nspname, pu.usename AS nspowner,
+                               pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment
+                       FROM pg_catalog.pg_namespace pn
+                               LEFT JOIN pg_catalog.pg_user pu ON (pn.nspowner = pu.usesysid)
+                       {$where}
+                       ORDER BY nspname";
+
+               return $this->selectSet($sql);
+       }
+
        /**
         * Return all information relating to a schema
         * @param $schema The name of the schema