提交 d82a9d2a 编写于 作者: R Robert Haas

Teach psql to display the comments on SQL/MED objects in verbose mode.

The relevant backslash commands already exist, so we're just adding an
additional column.  With this commit, all objects that have psql backslash
commands and accept comments should now display those comments at least
in verbose mode.

Josh Kupershmidt, with doc additions by me.
上级 c9ac00e6
......@@ -1098,7 +1098,7 @@ testdb=>
specified, only those servers whose name matches the pattern
are listed. If the form <literal>\des+</literal> is used, a
full description of each server is shown, including the
server's ACL, type, version, and options.
server's ACL, type, version, options, and description.
</para>
</listitem>
</varlistentry>
......@@ -1112,7 +1112,8 @@ testdb=&gt;
If <replaceable class="parameter">pattern</replaceable> is
specified, only entries whose table name or schema name matches
the pattern are listed. If the form <literal>\det+</literal>
is used, generic options are also displayed.
is used, generic options and the foreign table description
are also displayed.
</para>
</listitem>
</varlistentry>
......@@ -1150,8 +1151,8 @@ testdb=&gt;
If <replaceable class="parameter">pattern</replaceable> is
specified, only those foreign-data wrappers whose name matches
the pattern are listed. If the form <literal>\dew+</literal>
is used, the ACL and options of the foreign-data wrapper are
also shown.
is used, the ACL, options, and description of the foreign-data
wrapper are also shown.
</para>
</listitem>
</varlistentry>
......
......@@ -3680,16 +3680,16 @@ listForeignDataWrappers(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT fdwname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(fdwowner) AS \"%s\",\n",
"SELECT fdw.fdwname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(fdw.fdwowner) AS \"%s\",\n",
gettext_noop("Name"),
gettext_noop("Owner"));
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
" fdwhandler::pg_catalog.regproc AS \"%s\",\n",
" fdw.fdwhandler::pg_catalog.regproc AS \"%s\",\n",
gettext_noop("Handler"));
appendPQExpBuffer(&buf,
" fdwvalidator::pg_catalog.regproc AS \"%s\"",
" fdw.fdwvalidator::pg_catalog.regproc AS \"%s\"",
gettext_noop("Validator"));
if (verbose)
......@@ -3699,9 +3699,20 @@ listForeignDataWrappers(const char *pattern, bool verbose)
appendPQExpBuffer(&buf,
",\n fdwoptions AS \"%s\"",
gettext_noop("Options"));
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
",\n d.description AS \"%s\" ",
gettext_noop("Description"));
}
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_foreign_data_wrapper\n");
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_foreign_data_wrapper fdw\n");
if (verbose && pset.sversion >= 90100)
appendPQExpBuffer(&buf,
"LEFT JOIN pg_catalog.pg_description d\n"
" ON d.classoid = fdw.tableoid "
"AND d.objoid = fdw.oid AND d.objsubid = 0\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "fdwname", NULL, NULL);
......@@ -3759,16 +3770,24 @@ listForeignServers(const char *pattern, bool verbose)
",\n"
" s.srvtype AS \"%s\",\n"
" s.srvversion AS \"%s\",\n"
" s.srvoptions AS \"%s\"",
" s.srvoptions AS \"%s\",\n"
" d.description AS \"%s\"",
gettext_noop("Type"),
gettext_noop("Version"),
gettext_noop("Options"));
gettext_noop("Options"),
gettext_noop("Description"));
}
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_foreign_server s\n"
" JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid=s.srvfdw\n");
if (verbose)
appendPQExpBuffer(&buf,
"LEFT JOIN pg_description d\n "
"ON d.classoid = s.tableoid AND d.objoid = s.oid "
"AND d.objsubid = 0\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "s.srvname", NULL, NULL);
......@@ -3872,18 +3891,26 @@ listForeignTables(const char *pattern, bool verbose)
if (verbose)
appendPQExpBuffer(&buf,
",\n ft.ftoptions AS \"%s\"",
gettext_noop("Options"));
",\n ft.ftoptions AS \"%s\",\n"
" d.description AS \"%s\"",
gettext_noop("Options"),
gettext_noop("Description"));
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_foreign_table ft,");
appendPQExpBuffer(&buf, "\n pg_catalog.pg_class c,");
appendPQExpBuffer(&buf, "\n pg_catalog.pg_namespace n,");
appendPQExpBuffer(&buf, "\n pg_catalog.pg_foreign_server s\n");
appendPQExpBuffer(&buf, "\nWHERE c.oid = ft.ftrelid");
appendPQExpBuffer(&buf, "\nAND s.oid = ft.ftserver\n");
appendPQExpBuffer(&buf, "\nAND n.oid = c.relnamespace\n");
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_foreign_table ft\n"
" INNER JOIN pg_catalog.pg_class c"
" ON c.oid = ft.ftrelid\n"
" INNER JOIN pg_catalog.pg_namespace n"
" ON n.oid = c.relnamespace\n"
" INNER JOIN pg_catalog.pg_foreign_server s"
" ON s.oid = ft.ftserver\n");
if (verbose)
appendPQExpBuffer(&buf,
" LEFT JOIN pg_catalog.pg_description d\n"
" ON d.classoid = c.tableoid AND "
"d.objoid = c.oid AND d.objsubid = 0\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "n.nspname", "c.relname", NULL);
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册