Commit d82d8486 authored by Robert Haas's avatar Robert Haas

Display both per-table and per-column FDW options in psql's \d output.

Along the way, rename "Options" to "FDW Options" in various places for
consistency and clarity.

Shigeru Hanada
parent 5057366e
...@@ -892,15 +892,14 @@ testdb=> ...@@ -892,15 +892,14 @@ testdb=>
<para> <para>
For some types of relation, <literal>\d</> shows additional information For some types of relation, <literal>\d</> shows additional information
for each column: column values for sequences, indexed expression for for each column: column values for sequences, indexed expression for
indexes and per-column foreign data wrapper options for foreign tables. indexes and foreign data wrapper options for foreign tables.
</para> </para>
<para> <para>
The command form <literal>\d+</literal> is identical, except that The command form <literal>\d+</literal> is identical, except that
more information is displayed: any comments associated with the more information is displayed: any comments associated with the
columns of the table are shown, as is the presence of OIDs in the columns of the table are shown, as is the presence of OIDs in the
table, the view definition if the relation is a view, and the generic table, the view definition if the relation is a view.
options if the relation is a foreign table.
</para> </para>
<para> <para>
......
...@@ -1367,7 +1367,7 @@ describeOneTableDetails(const char *schemaname, ...@@ -1367,7 +1367,7 @@ describeOneTableDetails(const char *schemaname,
headers[cols++] = gettext_noop("Definition"); headers[cols++] = gettext_noop("Definition");
if (tableinfo.relkind == 'f' && pset.sversion >= 90200) if (tableinfo.relkind == 'f' && pset.sversion >= 90200)
headers[cols++] = gettext_noop("Options"); headers[cols++] = gettext_noop("FDW Options");
if (verbose) if (verbose)
{ {
...@@ -2033,9 +2033,12 @@ describeOneTableDetails(const char *schemaname, ...@@ -2033,9 +2033,12 @@ describeOneTableDetails(const char *schemaname,
/* print foreign server name */ /* print foreign server name */
if (tableinfo.relkind == 'f') if (tableinfo.relkind == 'f')
{ {
char *ftoptions;
/* Footer information about foreign table */ /* Footer information about foreign table */
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT s.srvname\n" "SELECT s.srvname,\n"
" f.ftoptions\n"
"FROM pg_catalog.pg_foreign_table f,\n" "FROM pg_catalog.pg_foreign_table f,\n"
" pg_catalog.pg_foreign_server s\n" " pg_catalog.pg_foreign_server s\n"
"WHERE f.ftrelid = %s AND s.oid = f.ftserver;", "WHERE f.ftrelid = %s AND s.oid = f.ftserver;",
...@@ -2049,9 +2052,18 @@ describeOneTableDetails(const char *schemaname, ...@@ -2049,9 +2052,18 @@ describeOneTableDetails(const char *schemaname,
goto error_return; goto error_return;
} }
/* Print server name */
printfPQExpBuffer(&buf, "Server: %s", printfPQExpBuffer(&buf, "Server: %s",
PQgetvalue(result, 0, 0)); PQgetvalue(result, 0, 0));
printTableAddFooter(&cont, buf.data); printTableAddFooter(&cont, buf.data);
/* Print per-table FDW options, if any */
ftoptions = PQgetvalue(result, 0, 1);
if (ftoptions && ftoptions[0] != '\0')
{
printfPQExpBuffer(&buf, "FDW Options: %s", ftoptions);
printTableAddFooter(&cont, buf.data);
}
PQclear(result); PQclear(result);
} }
...@@ -3668,7 +3680,7 @@ listForeignDataWrappers(const char *pattern, bool verbose) ...@@ -3668,7 +3680,7 @@ listForeignDataWrappers(const char *pattern, bool verbose)
printACLColumn(&buf, "fdwacl"); printACLColumn(&buf, "fdwacl");
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
",\n fdwoptions AS \"%s\"", ",\n fdwoptions AS \"%s\"",
gettext_noop("Options")); gettext_noop("FDW Options"));
if (pset.sversion >= 90100) if (pset.sversion >= 90100)
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
...@@ -3744,7 +3756,7 @@ listForeignServers(const char *pattern, bool verbose) ...@@ -3744,7 +3756,7 @@ listForeignServers(const char *pattern, bool verbose)
" d.description AS \"%s\"", " d.description AS \"%s\"",
gettext_noop("Type"), gettext_noop("Type"),
gettext_noop("Version"), gettext_noop("Version"),
gettext_noop("Options"), gettext_noop("FDW Options"),
gettext_noop("Description")); gettext_noop("Description"));
} }
...@@ -3807,7 +3819,7 @@ listUserMappings(const char *pattern, bool verbose) ...@@ -3807,7 +3819,7 @@ listUserMappings(const char *pattern, bool verbose)
if (verbose) if (verbose)
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
",\n um.umoptions AS \"%s\"", ",\n um.umoptions AS \"%s\"",
gettext_noop("Options")); gettext_noop("FDW Options"));
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_user_mappings um\n"); appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_user_mappings um\n");
...@@ -3863,7 +3875,7 @@ listForeignTables(const char *pattern, bool verbose) ...@@ -3863,7 +3875,7 @@ listForeignTables(const char *pattern, bool verbose)
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
",\n ft.ftoptions AS \"%s\",\n" ",\n ft.ftoptions AS \"%s\",\n"
" d.description AS \"%s\"", " d.description AS \"%s\"",
gettext_noop("Options"), gettext_noop("FDW Options"),
gettext_noop("Description")); gettext_noop("Description"));
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment