From: Shigeru Hanada Date: Thu, 28 Oct 2010 08:14:59 +0000 (+0900) Subject: Add \dE psql command which shows list of foreign tables. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=e117fe24e94bb431f20f8da348b38ea8dfdca67a;p=users%2Fhanada%2Fpostgres.git Add \dE psql command which shows list of foreign tables. --- diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index f0eac0a77a..a48f1e79f3 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -897,9 +897,9 @@ testdb=> If \d is used without a pattern argument, it is - equivalent to \dtvs which will show a list of - all visible tables, views, and sequences. This is purely a convenience - measure. + equivalent to \dtvsE which will show a list of + all visible tables, views, sequences and foreign tables. + This is purely a convenience measure. @@ -1213,13 +1213,15 @@ testdb=> \ds[S+] [ pattern ] \dt[S+] [ pattern ] \dv[S+] [ pattern ] + \dE[S+] [ pattern ] In this group of commands, the letters i, s, t, and v - stand for index, sequence, table, and view, respectively. + stand for index, sequence, table, view, and foreign table, + respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dit lists indexes diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 9515a1249d..c8a95c2eae 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -369,7 +369,7 @@ exec_command(const char *cmd, success = describeTableDetails(pattern, show_verbose, show_system); else /* standard listing of interesting things */ - success = listTables("tvse", NULL, show_verbose, show_system); + success = listTables("tvsE", NULL, show_verbose, show_system); break; case 'a': success = describeAggregates(pattern, show_verbose, show_system); @@ -432,6 +432,7 @@ exec_command(const char *cmd, case 'v': case 'i': case 's': + case 'E': success = listTables(&cmd[1], pattern, show_verbose, show_system); break; case 'r': diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index bb555108bd..300ca8e259 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2402,9 +2402,9 @@ listDbRoleSettings(const char *pattern, const char *pattern2) * i - indexes * v - views * s - sequences - * e - foreign table(Note: different from 'f' for relkind) + * E - foreign table (Note: different from 'f', the relkind value) * (any order of the above is fine) - * If tabtypes is empty, we default to \dtvs. + * If tabtypes is empty, we default to \dtvsE. */ bool listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSystem) @@ -2413,15 +2413,15 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys bool showIndexes = strchr(tabtypes, 'i') != NULL; bool showViews = strchr(tabtypes, 'v') != NULL; bool showSeq = strchr(tabtypes, 's') != NULL; - bool showForeign = strchr(tabtypes, 'e') != NULL; + bool showForeign = strchr(tabtypes, 'E') != NULL; PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, true, false, false, false, false}; - if (!(showTables || showIndexes || showViews || showSeq)) - showTables = showViews = showSeq = true; + if (!(showTables || showIndexes || showViews || showSeq || showForeign)) + showTables = showViews = showSeq = showForeign = true; initPQExpBuffer(&buf); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 8ca8ec999f..5457bb67b6 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -158,7 +158,7 @@ slashUsage(unsigned short int pager) { FILE *output; - output = PageOutput(91, pager); + output = PageOutput(92, pager); /* if you add/remove a line here, change the row count above */ @@ -220,6 +220,7 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\dT[S+] [PATTERN] list data types\n")); fprintf(output, _(" \\du[+] [PATTERN] list roles (users)\n")); fprintf(output, _(" \\dv[S+] [PATTERN] list views\n")); + fprintf(output, _(" \\dE[S+] [PATTERN] list foreign tables\n")); fprintf(output, _(" \\l[+] list all databases\n")); fprintf(output, _(" \\sf[+] FUNCNAME show a function's definition\n")); fprintf(output, _(" \\z [PATTERN] same as \\dp\n"));