Commit b65a5097 authored by Tom Lane's avatar Tom Lane

Show database access privileges in psql's \l command. For \l+, also show

database size, when available to the current user.

Andrew Gilligan
parent 2be368a5
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.198 2007/12/11 19:57:32 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.199 2008/03/30 18:10:20 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -1328,9 +1328,12 @@ Tue Oct 26 21:40:57 CEST 1999 ...@@ -1328,9 +1328,12 @@ Tue Oct 26 21:40:57 CEST 1999
<term><literal>\l+</literal> (or <literal>\list+</literal>)</term> <term><literal>\l+</literal> (or <literal>\list+</literal>)</term>
<listitem> <listitem>
<para> <para>
List the names, owners, and character set encodings of all the databases in List the names, owners, character set encodings, and access privileges
the server. If <literal>+</literal> is appended to the command of all the databases in the server.
name, database descriptions are also displayed. 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> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2008, PostgreSQL Global Development Group * Copyright (c) 2000-2008, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.165 2008/03/30 17:50:11 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.166 2008/03/30 18:10:20 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "describe.h" #include "describe.h"
...@@ -417,12 +417,20 @@ listAllDbs(bool verbose) ...@@ -417,12 +417,20 @@ listAllDbs(bool verbose)
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT d.datname as \"%s\",\n" "SELECT d.datname as \"%s\",\n"
" r.rolname 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("Name"),
gettext_noop("Owner"), gettext_noop("Owner"),
gettext_noop("Encoding")); gettext_noop("Encoding"),
gettext_noop("Access Privileges"));
if (verbose) 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, appendPQExpBuffer(&buf,
",\n t.spcname as \"%s\"", ",\n t.spcname as \"%s\"",
gettext_noop("Tablespace")); gettext_noop("Tablespace"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment