diff options
| author | Tom Lane | 2004-06-18 06:14:31 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-06-18 06:14:31 +0000 |
| commit | 2467394ee1566e82d0314d12a0d1c0a5670a28c9 (patch) | |
| tree | 57b87b8c181a9c3eb0f33bf775a5f31b9de8b890 /src/bin/psql | |
| parent | 474875f4438ea0d18f9f4170117bc407e6812515 (diff) | |
Tablespaces. Alternate database locations are dead, long live tablespaces.
There are various things left to do: contrib dbsize and oid2name modules
need work, and so does the documentation. Also someone should think about
COMMENT ON TABLESPACE and maybe RENAME TABLESPACE. Also initlocation is
dead, it just doesn't know it yet.
Gavin Sherry and Tom Lane.
Diffstat (limited to 'src/bin/psql')
| -rw-r--r-- | src/bin/psql/command.c | 5 | ||||
| -rw-r--r-- | src/bin/psql/describe.c | 43 | ||||
| -rw-r--r-- | src/bin/psql/describe.h | 5 | ||||
| -rw-r--r-- | src/bin/psql/help.c | 5 |
4 files changed, 52 insertions, 6 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index d880afbd27..af8c225448 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.116 2004/05/07 00:24:58 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.117 2004/06/18 06:14:04 tgl Exp $ */ #include "postgres_fe.h" #include "command.h" @@ -301,6 +301,9 @@ exec_command(const char *cmd, case 'a': success = describeAggregates(pattern, show_verbose); break; + case 'b': + success = describeTablespaces(pattern); + break; case 'c': success = listConversions(pattern); break; diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e06c200158..0f75d97d23 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.98 2004/05/07 00:24:58 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.99 2004/06/18 06:14:04 tgl Exp $ */ #include "postgres_fe.h" #include "describe.h" @@ -99,6 +99,45 @@ describeAggregates(const char *pattern, bool verbose) return true; } +/* \db + * Takes an optional regexp to select particular tablespaces + */ +bool +describeTablespaces(const char *pattern) +{ + PQExpBufferData buf; + PGresult *res; + printQueryOpt myopt = pset.popt; + + initPQExpBuffer(&buf); + + 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", + _("Name"), _("Owner"), _("Location")); + + processNamePattern(&buf, pattern, false, false, + NULL, "spcname", NULL, + NULL); + + appendPQExpBuffer(&buf, "ORDER BY 1;"); + + res = PSQLexec(buf.data, false); + termPQExpBuffer(&buf); + if (!res) + return false; + + myopt.nullPrint = NULL; + myopt.title = _("List of tablespaces"); + + printQuery(res, &myopt, pset.queryFout); + + PQclear(res); + return true; +} + /* \df * Takes an optional regexp to select particular functions @@ -351,7 +390,7 @@ permissionsList(const char *pattern) printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" " c.relname as \"%s\",\n" - " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'S' THEN '%s' END as \"%s\",\n" + " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'S' THEN '%s' END as \"%s\",\n" " c.relacl as \"%s\"\n" "FROM pg_catalog.pg_class c\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index acc841a02b..195bf0e557 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.23 2003/12/01 22:21:54 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.24 2004/06/18 06:14:04 tgl Exp $ */ #ifndef DESCRIBE_H #define DESCRIBE_H @@ -13,6 +13,9 @@ /* \da */ bool describeAggregates(const char *pattern, bool verbose); +/* \db */ +bool describeTablespaces(const char *pattern); + /* \df */ bool describeFunctions(const char *pattern, bool verbose); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index f7e9022e42..ed9574a229 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.87 2004/05/07 00:24:58 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.88 2004/06/18 06:14:04 tgl Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -211,6 +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, _(" \\dc [PATTERN] list conversions\n")); fprintf(output, _(" \\dC list casts\n")); fprintf(output, _(" \\dd [PATTERN] show comment for object\n")); @@ -308,7 +309,7 @@ helpSQL(const char *topic, unsigned short int pager) size_t len; int nl_count = 0; char *ch; - + /* don't care about trailing spaces */ len = strlen(topic); while (topic[len - 1] == ' ') |
