Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb65a509

Browse files
committed
Show database access privileges in psql's \l command. For \l+, also show
database size, when available to the current user.Andrew Gilligan
1 parent2be368a commitb65a509

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.198 2007/12/11 19:57:32 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.199 2008/03/30 18:10:20 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1328,9 +1328,12 @@ Tue Oct 26 21:40:57 CEST 1999
13281328
<term><literal>\l+</literal> (or <literal>\list+</literal>)</term>
13291329
<listitem>
13301330
<para>
1331-
List the names, owners, and character set encodings of all the databases in
1332-
the server. If <literal>+</literal> is appended to the command
1333-
name, database descriptions are also displayed.
1331+
List the names, owners, character set encodings, and access privileges
1332+
of all the databases in the server.
1333+
If <literal>+</literal> is appended to the command name, database
1334+
sizes, default tablespaces, and descriptions are also displayed.
1335+
(Size information is only available for databases that the current
1336+
user can connect to.)
13341337
</para>
13351338
</listitem>
13361339
</varlistentry>

‎src/bin/psql/describe.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.165 2008/03/3017:50:11 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.166 2008/03/3018:10:20 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"describe.h"
@@ -417,12 +417,20 @@ listAllDbs(bool verbose)
417417
printfPQExpBuffer(&buf,
418418
"SELECT d.datname as \"%s\",\n"
419419
" r.rolname as \"%s\",\n"
420-
" pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"",
420+
" pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n"
421+
" d.datacl as \"%s\"",
421422
gettext_noop("Name"),
422423
gettext_noop("Owner"),
423-
gettext_noop("Encoding"));
424+
gettext_noop("Encoding"),
425+
gettext_noop("Access Privileges"));
424426
if (verbose)
425427
{
428+
appendPQExpBuffer(&buf,
429+
",\n CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
430+
" THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
431+
" ELSE 'No Access'\n"
432+
" END as \"%s\"",
433+
gettext_noop("Size"));
426434
appendPQExpBuffer(&buf,
427435
",\n t.spcname as \"%s\"",
428436
gettext_noop("Tablespace"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp