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

Commita670c24

Browse files
committed
Improve output of psql's \df+ command.
Add display of proparallel (parallel-safety) when the server is >= 9.6,and display of proacl (access privileges) for all server versions.Minor tweak of column ordering to keep related columns together.Michael PaquierDiscussion: <CAB7nPqTR3Vu3xKOZOYqSm-+bSZV0kqgeGAXD6w5GLbkbfd5Q6w@mail.gmail.com>
1 parent740bf39 commita670c24

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,9 @@ testdb=&gt;
13671367

13681368
<listitem>
13691369
<para>
1370-
Lists functions, together with theirarguments, return types,and
1371-
function types, which are classified as <quote>agg</> (aggregate),
1372-
<quote>normal</>, <quote>trigger</>, or <quote>window</>.
1370+
Lists functions, together with theirresult data types,argument data
1371+
types, andfunction types, which are classified as <quote>agg</>
1372+
(aggregate),<quote>normal</>, <quote>trigger</>, or <quote>window</>.
13731373
To display only functions
13741374
of specific type(s), add the corresponding letters <literal>a</>,
13751375
<literal>n</>, <literal>t</>, or <literal>w</> to the command.
@@ -1380,14 +1380,15 @@ testdb=&gt;
13801380
objects are shown; supply a pattern or the <literal>S</literal>
13811381
modifier to include system objects.
13821382
If the form <literal>\df+</literal> is used, additional information
1383-
about each function is shown, including security classification,
1384-
volatility, owner, language, source code and description.
1383+
about each function is shown, including volatility,
1384+
parallel safety, owner, security classification, access privileges,
1385+
language, source code and description.
13851386
</para>
13861387

13871388
<tip>
13881389
<para>
13891390
To look up functions taking arguments or returning values of a specific
1390-
type, use your pager's search capability to scroll through the
1391+
datatype, use your pager's search capability to scroll through the
13911392
<literal>\df</> output.
13921393
</para>
13931394
</tip>

‎src/bin/psql/describe.c

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
298298
PQExpBufferDatabuf;
299299
PGresult*res;
300300
printQueryOptmyopt=pset.popt;
301-
staticconstbooltranslate_columns[]= {false, false, false, false, true, true, true, false, false, false, false};
301+
staticconstbooltranslate_columns[]= {false, false, false, false, true, true, true, false, true, false, false, false, false};
302+
303+
/* No "Parallel" column before 9.6 */
304+
staticconstbooltranslate_columns_pre_96[]= {false, false, false, false, true, true, false, true, false, false, false, false};
302305

303306
if (strlen(functypes)!=strspn(functypes,"antwS+"))
304307
{
@@ -410,28 +413,45 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
410413
gettext_noop("Type"));
411414

412415
if (verbose)
416+
{
413417
appendPQExpBuffer(&buf,
414-
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
415418
",\n CASE\n"
416419
" WHEN p.provolatile = 'i' THEN '%s'\n"
417420
" WHEN p.provolatile = 's' THEN '%s'\n"
418421
" WHEN p.provolatile = 'v' THEN '%s'\n"
419-
" END as \"%s\""
420-
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\",\n"
421-
" l.lanname as \"%s\",\n"
422-
" p.prosrc as \"%s\",\n"
423-
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
424-
gettext_noop("definer"),
425-
gettext_noop("invoker"),
426-
gettext_noop("Security"),
422+
" END as \"%s\"",
427423
gettext_noop("immutable"),
428424
gettext_noop("stable"),
429425
gettext_noop("volatile"),
430-
gettext_noop("Volatility"),
426+
gettext_noop("Volatility"));
427+
if (pset.sversion >=90600)
428+
appendPQExpBuffer(&buf,
429+
",\n CASE\n"
430+
" WHEN p.proparallel = 'r' THEN '%s'\n"
431+
" WHEN p.proparallel = 's' THEN '%s'\n"
432+
" WHEN p.proparallel = 'u' THEN '%s'\n"
433+
" END as \"%s\"",
434+
gettext_noop("restricted"),
435+
gettext_noop("safe"),
436+
gettext_noop("unsafe"),
437+
gettext_noop("Parallel"));
438+
appendPQExpBuffer(&buf,
439+
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
440+
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\"",
431441
gettext_noop("Owner"),
442+
gettext_noop("definer"),
443+
gettext_noop("invoker"),
444+
gettext_noop("Security"));
445+
appendPQExpBufferStr(&buf,",\n ");
446+
printACLColumn(&buf,"p.proacl");
447+
appendPQExpBuffer(&buf,
448+
",\n l.lanname as \"%s\""
449+
",\n p.prosrc as \"%s\""
450+
",\n pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
432451
gettext_noop("Language"),
433452
gettext_noop("Source code"),
434453
gettext_noop("Description"));
454+
}
435455

436456
appendPQExpBufferStr(&buf,
437457
"\nFROM pg_catalog.pg_proc p"
@@ -530,8 +550,16 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
530550
myopt.nullPrint=NULL;
531551
myopt.title=_("List of functions");
532552
myopt.translate_header= true;
533-
myopt.translate_columns=translate_columns;
534-
myopt.n_translate_columns=lengthof(translate_columns);
553+
if (pset.sversion >=90600)
554+
{
555+
myopt.translate_columns=translate_columns;
556+
myopt.n_translate_columns=lengthof(translate_columns);
557+
}
558+
else
559+
{
560+
myopt.translate_columns=translate_columns_pre_96;
561+
myopt.n_translate_columns=lengthof(translate_columns_pre_96);
562+
}
535563

536564
printQuery(res,&myopt,pset.queryFout, false,pset.logfile);
537565

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp