Fix postgresql_fdw_connections view to not use COALESCE but CASE WHEN.
authorShigeru Hanada <[email protected]>
Wed, 13 Oct 2010 12:17:34 +0000 (21:17 +0900)
committerShigeru Hanada <[email protected]>
Wed, 13 Oct 2010 12:17:34 +0000 (21:17 +0900)
contrib/postgresql_fdw/postgresql_fdw.sql.in

index 60f26a2817f8ab7bf6f4d8f56f8e4b7397de9e4b..be6e23e77e8ba677a85a9911e83b5b5d08c352c2 100644 (file)
@@ -14,12 +14,16 @@ CREATE OR REPLACE FUNCTION postgresql_fdw_connections(conname OUT text, serverid
     LANGUAGE C STRICT;
 
 CREATE OR REPLACE VIEW postgresql_fdw_connections AS
-    SELECT c.conname as conname,
-           s.srvname as srvname,
-           COALESCE(a.rolname, 'public') as usename
+    SELECT c.conname AS conname,
+           s.srvname AS srvname,
+           CASE WHEN c.userid = 0 THEN
+               'public'
+           ELSE
+               a.rolname
+           END AS usename
       FROM postgresql_fdw_connections() c
            JOIN pg_foreign_server s ON (s.oid = c.serverid)
-           LEFT OUTER JOIN pg_authid a ON (a.oid = c.userid);
+           LEFT JOIN pg_authid a ON (a.oid = c.userid);
 
 GRANT EXECUTE ON FUNCTION postgresql_fdw_connections(conname OUT text, serverid OUT oid, userid OUT oid) TO public;
 GRANT SELECT ON postgresql_fdw_connections TO public;