Have \dn+ show permissions and description for schemas.
authorBruce Momjian <bruce@momjian.us>
Tue, 13 Jul 2004 16:48:16 +0000 (16:48 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 13 Jul 2004 16:48:16 +0000 (16:48 +0000)
Dennis Bjorklund

doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/command.c
src/bin/psql/describe.c
src/bin/psql/describe.h
src/bin/psql/help.c

index 44b4a91f68fb5d4bf5388e1072f322ea8a424c4f..37c73e2281718fc62afcf8c0efcb5bcbdfc6aeb3 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.117 2004/07/12 20:41:08 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.118 2004/07/13 16:48:15 momjian Exp $
 PostgreSQL documentation
 -->
 
@@ -990,7 +990,9 @@ testdb=>
         Lists all available schemas (namespaces). If <replaceable
         class="parameter">pattern</replaceable> (a regular expression)
         is specified, only schemas whose names match the pattern are listed.
-        Non-local temporary schemas are suppressed.
+        Non-local temporary schemas are suppressed.  If <literal>+</literal>
+        is appended to the command name, each object is listed with its associated
+        permissions and description, if any.
         </para>
         </listitem>
       </varlistentry>
index ba8d623731c030ae80772f0032108c06314fa039..222d761163f2401fab86cfad2c8522ae3a0f26dd 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.120 2004/07/11 21:34:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.121 2004/07/13 16:48:16 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "command.h"
@@ -326,7 +326,7 @@ exec_command(const char *cmd,
                                success = do_lo_list();
                                break;
                        case 'n':
-                               success = listSchemas(pattern);
+                               success = listSchemas(pattern, show_verbose);
                                break;
                        case 'o':
                                success = describeOperators(pattern);
index e9758ec0837d4648bf76ce566416e3bd98b3641d..432063640dbb8a15647243044090297d2e61fd85 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.101 2004/07/13 02:46:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.102 2004/07/13 16:48:16 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -1693,7 +1693,7 @@ listCasts(const char *pattern)
  * Describes schemas (namespaces)
  */
 bool
-listSchemas(const char *pattern)
+listSchemas(const char *pattern, bool verbose)
 {
        PQExpBufferData buf;
        PGresult   *res;
@@ -1702,13 +1702,21 @@ listSchemas(const char *pattern)
        initPQExpBuffer(&buf);
        printfPQExpBuffer(&buf,
                "SELECT n.nspname AS \"%s\",\n"
-               "       u.usename AS \"%s\"\n"
-               "FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
+               "       u.usename AS \"%s\"",
+               _("Name"), _("Owner"));
+               
+       if (verbose)
+               appendPQExpBuffer(&buf,
+                       ",\n  n.nspacl as \"%s\","
+                       "  pg_catalog.obj_description(n.oid, 'pg_namespace') as \"%s\"",
+                       _("Access privileges"), _("Description"));
+                                                 
+       appendPQExpBuffer(&buf,
+               "\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
                "       ON n.nspowner=u.usesysid\n"
                "WHERE  (n.nspname NOT LIKE 'pg\\\\_temp\\\\_%%' OR\n"
-               "                n.nspname = (pg_catalog.current_schemas(true))[1])\n", /* temp schema is first */
-                                         _("Name"),
-                                         _("Owner"));
+               "                n.nspname = (pg_catalog.current_schemas(true))[1])\n");        /* temp schema is first */
+
        processNamePattern(&buf, pattern, true, false,
                                           NULL, "n.nspname", NULL,
                                           NULL);
index 195bf0e557878cc4aafe373ae199d82ad84b4599..8dcca7598901678a976a25047e0584043c7cd060 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.24 2004/06/18 06:14:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.25 2004/07/13 16:48:16 momjian Exp $
  */
 #ifndef DESCRIBE_H
 #define DESCRIBE_H
@@ -56,7 +56,7 @@ bool          listConversions(const char *pattern);
 bool           listCasts(const char *pattern);
 
 /* \dn */
-bool           listSchemas(const char *pattern);
+bool           listSchemas(const char *pattern, bool verbose);
 
 
 #endif   /* DESCRIBE_H */
index ed9574a22973c6ab0c7bbfb08492b4e3e73fc137..1fffbd25b4d5e4600e33e0f257cc2293718b54a9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.88 2004/06/18 06:14:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.89 2004/07/13 16:48:16 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "common.h"
@@ -218,7 +218,7 @@ slashUsage(unsigned short int pager)
        fprintf(output, _("  \\dD [PATTERN]  list domains\n"));
        fprintf(output, _("  \\df [PATTERN]  list functions (add \"+\" for more detail)\n"));
        fprintf(output, _("  \\dg [PATTERN]  list groups\n"));
-       fprintf(output, _("  \\dn [PATTERN]  list schemas\n"));
+       fprintf(output, _("  \\dn [PATTERN]  list schemas (add \"+\" for more detail)\n"));
        fprintf(output, _("  \\do [NAME]     list operators\n"));
        fprintf(output, _("  \\dl            list large objects, same as \\lo_list\n"));
        fprintf(output, _("  \\dp [PATTERN]  list table, view and sequence access privileges\n"));