@@ -1272,7 +1272,9 @@ describeOneTableDetails(const char *schemaname,
1272
1272
else
1273
1273
appendPQExpBuffer (& buf , ",\n NULL AS indexdef" );
1274
1274
if (tableinfo .relkind == 'f' && pset .sversion >= 90200 )
1275
- appendPQExpBuffer (& buf , ",\n a.attfdwoptions" );
1275
+ appendPQExpBuffer (& buf , ",\n CASE WHEN attfdwoptions IS NULL THEN '' ELSE "
1276
+ " '(' || array_to_string(ARRAY(SELECT quote_ident(option_name) || ' ' || quote_literal(option_value) FROM "
1277
+ " pg_options_to_table(attfdwoptions)), ', ') || ')' END AS attfdwoptions" );
1276
1278
else
1277
1279
appendPQExpBuffer (& buf , ",\n NULL AS attfdwoptions" );
1278
1280
if (verbose )
@@ -2038,7 +2040,10 @@ describeOneTableDetails(const char *schemaname,
2038
2040
/* Footer information about foreign table */
2039
2041
printfPQExpBuffer (& buf ,
2040
2042
"SELECT s.srvname,\n"
2041
- " f.ftoptions\n"
2043
+ " array_to_string(ARRAY(SELECT "
2044
+ " quote_ident(option_name) || ' ' || "
2045
+ " quote_literal(option_value) FROM "
2046
+ " pg_options_to_table(ftoptions)), ', ') "
2042
2047
"FROM pg_catalog.pg_foreign_table f,\n"
2043
2048
" pg_catalog.pg_foreign_server s\n"
2044
2049
"WHERE f.ftrelid = %s AND s.oid = f.ftserver;" ,
@@ -2061,7 +2066,7 @@ describeOneTableDetails(const char *schemaname,
2061
2066
ftoptions = PQgetvalue (result , 0 , 1 );
2062
2067
if (ftoptions && ftoptions [0 ] != '\0' )
2063
2068
{
2064
- printfPQExpBuffer (& buf , "FDW Options: %s " , ftoptions );
2069
+ printfPQExpBuffer (& buf , "FDW Options: (%s) " , ftoptions );
2065
2070
printTableAddFooter (& cont , buf .data );
2066
2071
}
2067
2072
PQclear (result );
@@ -3679,7 +3684,12 @@ listForeignDataWrappers(const char *pattern, bool verbose)
3679
3684
appendPQExpBuffer (& buf , ",\n " );
3680
3685
printACLColumn (& buf , "fdwacl" );
3681
3686
appendPQExpBuffer (& buf ,
3682
- ",\n fdwoptions AS \"%s\"" ,
3687
+ ",\n CASE WHEN fdwoptions IS NULL THEN '' ELSE "
3688
+ " '(' || array_to_string(ARRAY(SELECT "
3689
+ " quote_ident(option_name) || ' ' || "
3690
+ " quote_literal(option_value) FROM "
3691
+ " pg_options_to_table(fdwoptions)), ', ') || ')' "
3692
+ " END AS \"%s\"" ,
3683
3693
gettext_noop ("FDW Options" ));
3684
3694
3685
3695
if (pset .sversion >= 90100 )
@@ -3752,7 +3762,12 @@ listForeignServers(const char *pattern, bool verbose)
3752
3762
",\n"
3753
3763
" s.srvtype AS \"%s\",\n"
3754
3764
" s.srvversion AS \"%s\",\n"
3755
- " s.srvoptions AS \"%s\",\n"
3765
+ " CASE WHEN srvoptions IS NULL THEN '' ELSE "
3766
+ " '(' || array_to_string(ARRAY(SELECT "
3767
+ " quote_ident(option_name) || ' ' || "
3768
+ " quote_literal(option_value) FROM "
3769
+ " pg_options_to_table(srvoptions)), ', ') || ')' "
3770
+ " END AS \"%s\",\n"
3756
3771
" d.description AS \"%s\"" ,
3757
3772
gettext_noop ("Type" ),
3758
3773
gettext_noop ("Version" ),
@@ -3818,7 +3833,12 @@ listUserMappings(const char *pattern, bool verbose)
3818
3833
3819
3834
if (verbose )
3820
3835
appendPQExpBuffer (& buf ,
3821
- ",\n um.umoptions AS \"%s\"" ,
3836
+ ",\n CASE WHEN umoptions IS NULL THEN '' ELSE "
3837
+ " '(' || array_to_string(ARRAY(SELECT "
3838
+ " quote_ident(option_name) || ' ' || "
3839
+ " quote_literal(option_value) FROM "
3840
+ " pg_options_to_table(umoptions)), ', ') || ')' "
3841
+ " END AS \"%s\"" ,
3822
3842
gettext_noop ("FDW Options" ));
3823
3843
3824
3844
appendPQExpBuffer (& buf , "\nFROM pg_catalog.pg_user_mappings um\n" );
@@ -3873,7 +3893,12 @@ listForeignTables(const char *pattern, bool verbose)
3873
3893
3874
3894
if (verbose )
3875
3895
appendPQExpBuffer (& buf ,
3876
- ",\n ft.ftoptions AS \"%s\",\n"
3896
+ ",\n CASE WHEN ftoptions IS NULL THEN '' ELSE "
3897
+ " '(' || array_to_string(ARRAY(SELECT "
3898
+ " quote_ident(option_name) || ' ' || "
3899
+ " quote_literal(option_value) FROM "
3900
+ " pg_options_to_table(ftoptions)), ', ') || ')' "
3901
+ " END AS \"%s\",\n"
3877
3902
" d.description AS \"%s\"" ,
3878
3903
gettext_noop ("FDW Options" ),
3879
3904
gettext_noop ("Description" ));
0 commit comments