Skip to content

Commit d82d848

Browse files
committed
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
1 parent 5057366 commit d82d848

File tree

3 files changed

+92
-78
lines changed

3 files changed

+92
-78
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,15 +892,14 @@ testdb=>
892892
<para>
893893
For some types of relation, <literal>\d</> shows additional information
894894
for each column: column values for sequences, indexed expression for
895-
indexes and per-column foreign data wrapper options for foreign tables.
895+
indexes and foreign data wrapper options for foreign tables.
896896
</para>
897897

898898
<para>
899899
The command form <literal>\d+</literal> is identical, except that
900900
more information is displayed: any comments associated with the
901901
columns of the table are shown, as is the presence of OIDs in the
902-
table, the view definition if the relation is a view, and the generic
903-
options if the relation is a foreign table.
902+
table, the view definition if the relation is a view.
904903
</para>
905904

906905
<para>

src/bin/psql/describe.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ describeOneTableDetails(const char *schemaname,
13671367
headers[cols++] = gettext_noop("Definition");
13681368

13691369
if (tableinfo.relkind == 'f' && pset.sversion >= 90200)
1370-
headers[cols++] = gettext_noop("Options");
1370+
headers[cols++] = gettext_noop("FDW Options");
13711371

13721372
if (verbose)
13731373
{
@@ -2033,9 +2033,12 @@ describeOneTableDetails(const char *schemaname,
20332033
/* print foreign server name */
20342034
if (tableinfo.relkind == 'f')
20352035
{
2036+
char *ftoptions;
2037+
20362038
/* Footer information about foreign table */
20372039
printfPQExpBuffer(&buf,
2038-
"SELECT s.srvname\n"
2040+
"SELECT s.srvname,\n"
2041+
" f.ftoptions\n"
20392042
"FROM pg_catalog.pg_foreign_table f,\n"
20402043
" pg_catalog.pg_foreign_server s\n"
20412044
"WHERE f.ftrelid = %s AND s.oid = f.ftserver;",
@@ -2049,9 +2052,18 @@ describeOneTableDetails(const char *schemaname,
20492052
goto error_return;
20502053
}
20512054

2055+
/* Print server name */
20522056
printfPQExpBuffer(&buf, "Server: %s",
20532057
PQgetvalue(result, 0, 0));
20542058
printTableAddFooter(&cont, buf.data);
2059+
2060+
/* Print per-table FDW options, if any */
2061+
ftoptions = PQgetvalue(result, 0, 1);
2062+
if (ftoptions && ftoptions[0] != '\0')
2063+
{
2064+
printfPQExpBuffer(&buf, "FDW Options: %s", ftoptions);
2065+
printTableAddFooter(&cont, buf.data);
2066+
}
20552067
PQclear(result);
20562068
}
20572069

@@ -3668,7 +3680,7 @@ listForeignDataWrappers(const char *pattern, bool verbose)
36683680
printACLColumn(&buf, "fdwacl");
36693681
appendPQExpBuffer(&buf,
36703682
",\n fdwoptions AS \"%s\"",
3671-
gettext_noop("Options"));
3683+
gettext_noop("FDW Options"));
36723684

36733685
if (pset.sversion >= 90100)
36743686
appendPQExpBuffer(&buf,
@@ -3744,7 +3756,7 @@ listForeignServers(const char *pattern, bool verbose)
37443756
" d.description AS \"%s\"",
37453757
gettext_noop("Type"),
37463758
gettext_noop("Version"),
3747-
gettext_noop("Options"),
3759+
gettext_noop("FDW Options"),
37483760
gettext_noop("Description"));
37493761
}
37503762

@@ -3807,7 +3819,7 @@ listUserMappings(const char *pattern, bool verbose)
38073819
if (verbose)
38083820
appendPQExpBuffer(&buf,
38093821
",\n um.umoptions AS \"%s\"",
3810-
gettext_noop("Options"));
3822+
gettext_noop("FDW Options"));
38113823

38123824
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_user_mappings um\n");
38133825

@@ -3863,7 +3875,7 @@ listForeignTables(const char *pattern, bool verbose)
38633875
appendPQExpBuffer(&buf,
38643876
",\n ft.ftoptions AS \"%s\",\n"
38653877
" d.description AS \"%s\"",
3866-
gettext_noop("Options"),
3878+
gettext_noop("FDW Options"),
38673879
gettext_noop("Description"));
38683880

38693881
appendPQExpBuffer(&buf,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy