From 93a1fce5ccd23a19b681c9804b63bc3c5423933f Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 15 Jul 2004 03:56:06 +0000 Subject: [PATCH] Add permission display to \db+. --- doc/src/sgml/ref/psql-ref.sgml | 4 +++- src/bin/psql/command.c | 4 ++-- src/bin/psql/describe.c | 15 +++++++++++---- src/bin/psql/describe.h | 4 ++-- src/bin/psql/help.c | 4 ++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 37c73e2281..497c6885aa 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1,5 +1,5 @@ @@ -832,6 +832,8 @@ testdb=> Lists all available tablespaces. If pattern is specified, only tablespaces whose names match the pattern are shown. + If + is appended to the command name, each object + is listed with its associated permissions. diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 222d761163..da2ab92b35 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.121 2004/07/13 16:48:16 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.122 2004/07/15 03:56:06 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" @@ -302,7 +302,7 @@ exec_command(const char *cmd, success = describeAggregates(pattern, show_verbose); break; case 'b': - success = describeTablespaces(pattern); + success = describeTablespaces(pattern, show_verbose); break; case 'c': success = listConversions(pattern); diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 432063640d..328a1c079f 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.102 2004/07/13 16:48:16 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.103 2004/07/15 03:56:06 momjian Exp $ */ #include "postgres_fe.h" #include "describe.h" @@ -106,7 +106,7 @@ describeAggregates(const char *pattern, bool verbose) * Takes an optional regexp to select particular tablespaces */ bool -describeTablespaces(const char *pattern) +describeTablespaces(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; @@ -117,10 +117,17 @@ describeTablespaces(const char *pattern) printfPQExpBuffer(&buf, "SELECT spcname AS \"%s\",\n" " pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n" - " spclocation AS \"%s\"\n" - "FROM pg_catalog.pg_tablespace\n", + " spclocation AS \"%s\"", _("Name"), _("Owner"), _("Location")); + if (verbose) + appendPQExpBuffer(&buf, + ",\n spcacl as \"%s\"", + _("Access privileges")); + + appendPQExpBuffer(&buf, + "\nFROM pg_catalog.pg_tablespace\n"); + processNamePattern(&buf, pattern, false, false, NULL, "spcname", NULL, NULL); diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 8dcca75989..39b9563fe0 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.25 2004/07/13 16:48:16 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.26 2004/07/15 03:56:06 momjian Exp $ */ #ifndef DESCRIBE_H #define DESCRIBE_H @@ -14,7 +14,7 @@ bool describeAggregates(const char *pattern, bool verbose); /* \db */ -bool describeTablespaces(const char *pattern); +bool describeTablespaces(const char *pattern, bool verbose); /* \df */ bool describeFunctions(const char *pattern, bool verbose); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 1fffbd25b4..f55ee7a0b0 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.89 2004/07/13 16:48:16 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.90 2004/07/15 03:56:06 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -211,7 +211,7 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\d{t|i|s|v|S} [PATTERN] (add \"+\" for more detail)\n" " list tables/indexes/sequences/views/system tables\n")); fprintf(output, _(" \\da [PATTERN] list aggregate functions\n")); - fprintf(output, _(" \\db [PATTERN] list tablespaces\n")); + fprintf(output, _(" \\db [PATTERN] list tablespaces (add \"+\" for more detail)\n")); fprintf(output, _(" \\dc [PATTERN] list conversions\n")); fprintf(output, _(" \\dC list casts\n")); fprintf(output, _(" \\dd [PATTERN] show comment for object\n"));