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

Commit515d2c5

Browse files
committed
Add display of oprcode (the underlying function's name) to psql's \do+.
The + modifier of \do didn't use to do anything, but now it adds an oprcodecolumn. This is useful both as an additional form of documentation of whatthe operator does, and to save a step when finding out properties of theunderlying function.Marko Tiikkaja, reviewed by Rushabh Lathia, adjusted a bit by me
1 parent3291301 commit515d2c5

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,12 +1199,13 @@ testdb=>
11991199
<literal>n</>, <literal>t</>, or <literal>w</> to the command.
12001200
If <replaceable
12011201
class="parameter">pattern</replaceable> is specified, only
1202-
functions whose names match the pattern are shown. If the
1203-
form <literal>\df+</literal> is used, additional information
1204-
about each function, including security, volatility, language, source
1205-
code and description, is shown. By default, only user-created
1202+
functions whose names match the pattern are shown.
1203+
By default, only user-created
12061204
objects are shown; supply a pattern or the <literal>S</literal>
12071205
modifier to include system objects.
1206+
If the form <literal>\df+</literal> is used, additional information
1207+
about each function is shown, including security classification,
1208+
volatility, owner, language, source code and description.
12081209
</para>
12091210

12101211
<tip>
@@ -1337,15 +1338,18 @@ testdb=&gt;
13371338

13381339

13391340
<varlistentry>
1340-
<term><literal>\do[S] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
1341+
<term><literal>\do[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
13411342
<listitem>
13421343
<para>
1343-
Lists operators with their operand andreturn types.
1344+
Lists operators with their operand andresult types.
13441345
If <replaceable class="parameter">pattern</replaceable> is
13451346
specified, only operators whose names match the pattern are listed.
1346-
By default, only user-created objects are shown;supply a
1347+
By default, only user-created objects are shown; supply a
13471348
pattern or the <literal>S</literal> modifier to include system
13481349
objects.
1350+
If <literal>+</literal> is appended to the command name,
1351+
additional information about each operator is shown, currently just
1352+
the name of the underlying function.
13491353
</para>
13501354
</listitem>
13511355
</varlistentry>

‎src/bin/psql/command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ exec_command(const char *cmd,
410410
success=listSchemas(pattern,show_verbose,show_system);
411411
break;
412412
case'o':
413-
success=describeOperators(pattern,show_system);
413+
success=describeOperators(pattern,show_verbose,show_system);
414414
break;
415415
case'O':
416416
success=listCollations(pattern,show_verbose,show_system);

‎src/bin/psql/describe.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,10 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
577577

578578

579579
/* \do
580+
* Describe operators
580581
*/
581582
bool
582-
describeOperators(constchar*pattern,boolshowSystem)
583+
describeOperators(constchar*pattern,boolverbose,boolshowSystem)
583584
{
584585
PQExpBufferDatabuf;
585586
PGresult*res;
@@ -605,16 +606,23 @@ describeOperators(const char *pattern, bool showSystem)
605606
" o.oprname AS \"%s\",\n"
606607
" CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
607608
" CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
608-
" pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n"
609-
" coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
610-
" pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
611-
"FROM pg_catalog.pg_operator o\n"
612-
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
609+
" pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n",
613610
gettext_noop("Schema"),
614611
gettext_noop("Name"),
615612
gettext_noop("Left arg type"),
616613
gettext_noop("Right arg type"),
617-
gettext_noop("Result type"),
614+
gettext_noop("Result type"));
615+
616+
if (verbose)
617+
appendPQExpBuffer(&buf,
618+
" o.oprcode AS \"%s\",\n",
619+
gettext_noop("Function"));
620+
621+
appendPQExpBuffer(&buf,
622+
" coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
623+
" pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
624+
"FROM pg_catalog.pg_operator o\n"
625+
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
618626
gettext_noop("Description"));
619627

620628
if (!showSystem&& !pattern)

‎src/bin/psql/describe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern bool describeFunctions(const char *functypes, const char *pattern, bool v
2222
externbooldescribeTypes(constchar*pattern,boolverbose,boolshowSystem);
2323

2424
/* \do */
25-
externbooldescribeOperators(constchar*pattern,boolshowSystem);
25+
externbooldescribeOperators(constchar*pattern,boolverbose,boolshowSystem);
2626

2727
/* \du, \dg */
2828
externbooldescribeRoles(constchar*pattern,boolverbose);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp