Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd82a9d2

Browse files
committed
Teach psql to display the comments on SQL/MED objects in verbose mode.
The relevant backslash commands already exist, so we're just adding anadditional column. With this commit, all objects that have psql backslashcommands and accept comments should now display those comments at leastin verbose mode.Josh Kupershmidt, with doc additions by me.
1 parentc9ac00e commitd82a9d2

File tree

3 files changed

+202
-174
lines changed

3 files changed

+202
-174
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ testdb=>
10981098
specified, only those servers whose name matches the pattern
10991099
are listed. If the form <literal>\des+</literal> is used, a
11001100
full description of each server is shown, including the
1101-
server's ACL, type, version, andoptions.
1101+
server's ACL, type, version,options,anddescription.
11021102
</para>
11031103
</listitem>
11041104
</varlistentry>
@@ -1112,7 +1112,8 @@ testdb=&gt;
11121112
If <replaceable class="parameter">pattern</replaceable> is
11131113
specified, only entries whose table name or schema name matches
11141114
the pattern are listed. If the form <literal>\det+</literal>
1115-
is used, generic options are also displayed.
1115+
is used, generic options and the foreign table description
1116+
are also displayed.
11161117
</para>
11171118
</listitem>
11181119
</varlistentry>
@@ -1150,8 +1151,8 @@ testdb=&gt;
11501151
If <replaceable class="parameter">pattern</replaceable> is
11511152
specified, only those foreign-data wrappers whose name matches
11521153
the pattern are listed. If the form <literal>\dew+</literal>
1153-
is used, the ACLandoptions of the foreign-data wrapper are
1154-
also shown.
1154+
is used, the ACL, options,anddescription of the foreign-data
1155+
wrapper arealso shown.
11551156
</para>
11561157
</listitem>
11571158
</varlistentry>

‎src/bin/psql/describe.c

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,16 +3680,16 @@ listForeignDataWrappers(const char *pattern, bool verbose)
36803680

36813681
initPQExpBuffer(&buf);
36823682
printfPQExpBuffer(&buf,
3683-
"SELECT fdwname AS \"%s\",\n"
3684-
" pg_catalog.pg_get_userbyid(fdwowner) AS \"%s\",\n",
3683+
"SELECTfdw.fdwname AS \"%s\",\n"
3684+
" pg_catalog.pg_get_userbyid(fdw.fdwowner) AS \"%s\",\n",
36853685
gettext_noop("Name"),
36863686
gettext_noop("Owner"));
36873687
if (pset.sversion >=90100)
36883688
appendPQExpBuffer(&buf,
3689-
" fdwhandler::pg_catalog.regproc AS \"%s\",\n",
3689+
"fdw.fdwhandler::pg_catalog.regproc AS \"%s\",\n",
36903690
gettext_noop("Handler"));
36913691
appendPQExpBuffer(&buf,
3692-
" fdwvalidator::pg_catalog.regproc AS \"%s\"",
3692+
"fdw.fdwvalidator::pg_catalog.regproc AS \"%s\"",
36933693
gettext_noop("Validator"));
36943694

36953695
if (verbose)
@@ -3699,9 +3699,20 @@ listForeignDataWrappers(const char *pattern, bool verbose)
36993699
appendPQExpBuffer(&buf,
37003700
",\n fdwoptions AS \"%s\"",
37013701
gettext_noop("Options"));
3702+
3703+
if (pset.sversion >=90100)
3704+
appendPQExpBuffer(&buf,
3705+
",\n d.description AS \"%s\" ",
3706+
gettext_noop("Description"));
37023707
}
37033708

3704-
appendPQExpBuffer(&buf,"\nFROM pg_catalog.pg_foreign_data_wrapper\n");
3709+
appendPQExpBuffer(&buf,"\nFROM pg_catalog.pg_foreign_data_wrapper fdw\n");
3710+
3711+
if (verbose&&pset.sversion >=90100)
3712+
appendPQExpBuffer(&buf,
3713+
"LEFT JOIN pg_catalog.pg_description d\n"
3714+
" ON d.classoid = fdw.tableoid "
3715+
"AND d.objoid = fdw.oid AND d.objsubid = 0\n");
37053716

37063717
processSQLNamePattern(pset.db,&buf,pattern, false, false,
37073718
NULL,"fdwname",NULL,NULL);
@@ -3759,16 +3770,24 @@ listForeignServers(const char *pattern, bool verbose)
37593770
",\n"
37603771
" s.srvtype AS \"%s\",\n"
37613772
" s.srvversion AS \"%s\",\n"
3762-
" s.srvoptions AS \"%s\"",
3773+
" s.srvoptions AS \"%s\",\n"
3774+
" d.description AS \"%s\"",
37633775
gettext_noop("Type"),
37643776
gettext_noop("Version"),
3765-
gettext_noop("Options"));
3777+
gettext_noop("Options"),
3778+
gettext_noop("Description"));
37663779
}
37673780

37683781
appendPQExpBuffer(&buf,
37693782
"\nFROM pg_catalog.pg_foreign_server s\n"
37703783
" JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid=s.srvfdw\n");
37713784

3785+
if (verbose)
3786+
appendPQExpBuffer(&buf,
3787+
"LEFT JOIN pg_description d\n "
3788+
"ON d.classoid = s.tableoid AND d.objoid = s.oid "
3789+
"AND d.objsubid = 0\n");
3790+
37723791
processSQLNamePattern(pset.db,&buf,pattern, false, false,
37733792
NULL,"s.srvname",NULL,NULL);
37743793

@@ -3872,18 +3891,26 @@ listForeignTables(const char *pattern, bool verbose)
38723891

38733892
if (verbose)
38743893
appendPQExpBuffer(&buf,
3875-
",\n ft.ftoptions AS \"%s\"",
3876-
gettext_noop("Options"));
3894+
",\n ft.ftoptions AS \"%s\",\n"
3895+
" d.description AS \"%s\"",
3896+
gettext_noop("Options"),
3897+
gettext_noop("Description"));
38773898

3878-
appendPQExpBuffer(&buf,"\nFROM pg_catalog.pg_foreign_table ft,");
3879-
appendPQExpBuffer(&buf,"\n pg_catalog.pg_class c,");
3880-
appendPQExpBuffer(&buf,"\n pg_catalog.pg_namespace n,");
3881-
appendPQExpBuffer(&buf,"\n pg_catalog.pg_foreign_server s\n");
3882-
appendPQExpBuffer(&buf,"\nWHERE c.oid = ft.ftrelid");
3883-
appendPQExpBuffer(&buf,"\nAND s.oid = ft.ftserver\n");
3884-
appendPQExpBuffer(&buf,"\nAND n.oid = c.relnamespace\n");
3899+
appendPQExpBuffer(&buf,
3900+
"\nFROM pg_catalog.pg_foreign_table ft\n"
3901+
" INNER JOIN pg_catalog.pg_class c"
3902+
" ON c.oid = ft.ftrelid\n"
3903+
" INNER JOIN pg_catalog.pg_namespace n"
3904+
" ON n.oid = c.relnamespace\n"
3905+
" INNER JOIN pg_catalog.pg_foreign_server s"
3906+
" ON s.oid = ft.ftserver\n");
3907+
if (verbose)
3908+
appendPQExpBuffer(&buf,
3909+
" LEFT JOIN pg_catalog.pg_description d\n"
3910+
" ON d.classoid = c.tableoid AND "
3911+
"d.objoid = c.oid AND d.objsubid = 0\n");
38853912

3886-
processSQLNamePattern(pset.db,&buf,pattern,true, false,
3913+
processSQLNamePattern(pset.db,&buf,pattern,false, false,
38873914
NULL,"n.nspname","c.relname",NULL);
38883915

38893916
appendPQExpBuffer(&buf,"ORDER BY 1, 2;");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp