summaryrefslogtreecommitdiff
path: root/src/bin/psql/describe.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2006-02-12 03:22:21 +0000
committerBruce Momjian <bruce@momjian.us>2006-02-12 03:22:21 +0000
commitf9a726aa883e1690f66bec535d85b34e1f9ed7e7 (patch)
tree764d3d849a2614ea5edcd05eaa36496a79f06c87 /src/bin/psql/describe.c
parent95dbf9c02f9a37fc171e0b94b37f9f903abc3942 (diff)
downloadpostgresql-f9a726aa883e1690f66bec535d85b34e1f9ed7e7.tar.gz
I've created a new shared catalog table pg_shdescription to store
comments on cluster global objects like databases, tablespaces, and roles. It touches a lot of places, but not much in the way of big changes. The only design decision I made was to duplicate the query and manipulation functions rather than to try and have them handle both shared and local comments. I believe this is simpler for the code and not an issue for callers because they know what type of object they are dealing with. This has resulted in a shobj_description function analagous to obj_description and backend functions [Create/Delete]SharedComments mirroring the existing [Create/Delete]Comments functions. pg_shdescription.h goes into src/include/catalog/ Kris Jurka
Diffstat (limited to 'src/bin/psql/describe.c')
-rw-r--r--src/bin/psql/describe.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 5caf16df8c..17ca722f30 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.130 2005/11/22 18:17:29 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.131 2006/02/12 03:22:19 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
@@ -127,8 +127,9 @@ describeTablespaces(const char *pattern, bool verbose)
if (verbose)
appendPQExpBuffer(&buf,
- ",\n spcacl as \"%s\"",
- _("Access privileges"));
+ ",\n spcacl as \"%s\""
+ ",\n pg_catalog.shobj_description(oid, 'pg_tablespace') AS \"%s\"",
+ _("Access privileges"), _("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_tablespace\n");
@@ -362,7 +363,7 @@ listAllDbs(bool verbose)
_("Encoding"));
if (verbose)
appendPQExpBuffer(&buf,
- ",\n pg_catalog.obj_description(d.oid, 'pg_database') as \"%s\"",
+ ",\n pg_catalog.shobj_description(d.oid, 'pg_database') as \"%s\"",
_("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_database d"
@@ -1382,7 +1383,7 @@ add_tablespace_footer(char relkind, Oid tablespace, char **footers,
* Describes roles. Any schema portion of the pattern is ignored.
*/
bool
-describeRoles(const char *pattern)
+describeRoles(const char *pattern, bool verbose)
{
PQExpBufferData buf;
PGresult *res;
@@ -1398,8 +1399,7 @@ describeRoles(const char *pattern)
" CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)\n"
" ELSE CAST(r.rolconnlimit AS pg_catalog.text)\n"
" END AS \"%s\", \n"
- " ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) as \"%s\"\n"
- "FROM pg_catalog.pg_roles r\n",
+ " ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) as \"%s\"",
_("Role name"),
_("yes"), _("no"), _("Superuser"),
_("yes"), _("no"), _("Create role"),
@@ -1407,6 +1407,12 @@ describeRoles(const char *pattern)
_("no limit"), _("Connections"),
_("Member of"));
+ if (verbose)
+ appendPQExpBuffer(&buf, "\n, pg_catalog.shobj_description(r.oid, 'pg_authid') AS \"%s\"",
+ _("Description"));
+
+ appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_roles r\n");
+
processNamePattern(&buf, pattern, false, false,
NULL, "r.rolname", NULL, NULL);