From a87f15d50696aae8d17adddeec6b6ee7c07aeb05 Mon Sep 17 00:00:00 2001
From: Andrew Dunstan <andrew@dunslane.net>
Date: Mon, 5 May 2008 01:21:03 +0000
Subject: [PATCH] Display ACLS using multiple lines for psql's \z. Brendan
 Jurd.

---
 doc/src/sgml/ref/grant.sgml              | 12 +++++++-----
 src/bin/psql/describe.c                  |  4 ++--
 src/test/regress/expected/dependency.out | 18 ++++++++++--------
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml
index 02941fc9cde..7b1295f9eb6 100644
--- a/doc/src/sgml/ref/grant.sgml
+++ b/doc/src/sgml/ref/grant.sgml
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.67 2007/10/30 19:43:30 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.68 2008/05/05 01:21:03 adunstan Exp $
 PostgreSQL documentation
 -->
 
@@ -405,10 +405,12 @@ GRANT <replaceable class="PARAMETER">role</replaceable> [, ...] TO <replaceable
     to obtain information about existing privileges, for example:
 <programlisting>
 =&gt; \z mytable
-                  Access privileges for database "lusitania"
- Schema |  Name   | Type  |                 Access privileges                 
---------+---------+-------+---------------------------------------------------
- public | mytable | table | {miriam=arwdxt/miriam,=r/miriam,admin=arw/miriam}
+   Access privileges for database "lusitania"
+ Schema |  Name   | Type  |  Access privileges   
+--------+---------+-------+----------------------
+ public | mytable | table | miriam=arwdxt/miriam
+                          : =r/miriam
+                          : admin=arw/miriam
 (1 row)
 </programlisting>
     The entries shown by <command>\z</command> are interpreted thus:
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 89a3f219615..97c3a82efeb 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2008, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.169 2008/05/05 00:11:31 adunstan Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.170 2008/05/05 01:21:03 adunstan Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -493,7 +493,7 @@ permissionsList(const char *pattern)
 					  "SELECT n.nspname as \"%s\",\n"
 					  "  c.relname as \"%s\",\n"
 					  "  CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'S' THEN '%s' END as \"%s\",\n"
-					  "  c.relacl as \"%s\"\n"
+					  "  pg_catalog.array_to_string(c.relacl, E'\\n') as \"%s\"\n"
 					  "FROM pg_catalog.pg_class c\n"
 	   "     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
 					  "WHERE c.relkind IN ('r', 'v', 'S')\n",
diff --git a/src/test/regress/expected/dependency.out b/src/test/regress/expected/dependency.out
index 82c1bf01383..6f62ce70108 100644
--- a/src/test/regress/expected/dependency.out
+++ b/src/test/regress/expected/dependency.out
@@ -68,19 +68,21 @@ NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "deptest_pkey" fo
 GRANT ALL ON deptest1 TO regression_user2;
 RESET SESSION AUTHORIZATION;
 \z deptest1
-                                                          Access privileges for database "regression"
- Schema |   Name   | Type  |                                                         Access privileges                                                          
---------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------
- public | deptest1 | table | {regression_user0=arwdxt/regression_user0,regression_user1=a*r*w*d*x*t*/regression_user0,regression_user2=arwdxt/regression_user1}
+                Access privileges for database "regression"
+ Schema |   Name   | Type  |               Access privileges                
+--------+----------+-------+------------------------------------------------
+ public | deptest1 | table | regression_user0=arwdxt/regression_user0
+                           : regression_user1=a*r*w*d*x*t*/regression_user0
+                           : regression_user2=arwdxt/regression_user1
 (1 row)
 
 DROP OWNED BY regression_user1;
 -- all grants revoked
 \z deptest1
-              Access privileges for database "regression"
- Schema |   Name   | Type  |             Access privileges              
---------+----------+-------+--------------------------------------------
- public | deptest1 | table | {regression_user0=arwdxt/regression_user0}
+             Access privileges for database "regression"
+ Schema |   Name   | Type  |            Access privileges             
+--------+----------+-------+------------------------------------------
+ public | deptest1 | table | regression_user0=arwdxt/regression_user0
 (1 row)
 
 -- table was dropped
-- 
GitLab