Show database access privileges in psql's \l command. For \l+, also show
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Mar 2008 18:10:20 +0000 (18:10 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Mar 2008 18:10:20 +0000 (18:10 +0000)
database size, when available to the current user.

Andrew Gilligan

doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/describe.c

index bf1162fcec37e2da241f6d4f813df4da8b10b1a6..bcaa7aedd8aa179af8e69139fe3dffb0c5e10d89 100644 (file)
@@ -1328,9 +1328,12 @@ Tue Oct 26 21:40:57 CEST 1999
         <term><literal>\l+</literal> (or <literal>\list+</literal>)</term>
         <listitem>
         <para>
-        List the names, owners, and character set encodings of all the databases in
-        the server. If <literal>+</literal> is appended to the command
-        name, database descriptions are also displayed.
+        List the names, owners, character set encodings, and access privileges
+        of all the databases in the server.
+        If <literal>+</literal> is appended to the command name, database
+        sizes, default tablespaces, and descriptions are also displayed.
+        (Size information is only available for databases that the current
+        user can connect to.)
         </para>
         </listitem>
       </varlistentry>
index e60a8c0c1ed328605e6553420e24b66b72529118..793a91a5efaacaefdb713771116e5b6291432d51 100644 (file)
@@ -417,12 +417,20 @@ listAllDbs(bool verbose)
        printfPQExpBuffer(&buf,
                                          "SELECT d.datname as \"%s\",\n"
                                          "       r.rolname as \"%s\",\n"
-                                         "       pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"",
+                                         "       pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n"
+                                         "       d.datacl as \"%s\"",
                                          gettext_noop("Name"),
                                          gettext_noop("Owner"),
-                                         gettext_noop("Encoding"));
+                                         gettext_noop("Encoding"),
+                                         gettext_noop("Access Privileges"));
        if (verbose)
        {
+               appendPQExpBuffer(&buf,
+                                                 ",\n       CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
+                                                 "            THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
+                                                 "            ELSE 'No Access'\n"
+                                                 "       END as \"%s\"",
+                                                 gettext_noop("Size"));
                appendPQExpBuffer(&buf,
                                                  ",\n       t.spcname as \"%s\"",
                                                  gettext_noop("Tablespace"));