mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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 oprcode column. This is useful both as an additional form of documentation of what the operator does, and to save a step when finding out properties of the underlying function. Marko Tiikkaja, reviewed by Rushabh Lathia, adjusted a bit by me
This commit is contained in:
@ -1199,12 +1199,13 @@ testdb=>
|
|||||||
<literal>n</>, <literal>t</>, or <literal>w</> to the command.
|
<literal>n</>, <literal>t</>, or <literal>w</> to the command.
|
||||||
If <replaceable
|
If <replaceable
|
||||||
class="parameter">pattern</replaceable> is specified, only
|
class="parameter">pattern</replaceable> is specified, only
|
||||||
functions whose names match the pattern are shown. If the
|
functions whose names match the pattern are shown.
|
||||||
form <literal>\df+</literal> is used, additional information
|
By default, only user-created
|
||||||
about each function, including security, volatility, language, source
|
|
||||||
code and description, is shown. By default, only user-created
|
|
||||||
objects are shown; supply a pattern or the <literal>S</literal>
|
objects are shown; supply a pattern or the <literal>S</literal>
|
||||||
modifier to include system objects.
|
modifier to include system objects.
|
||||||
|
If the form <literal>\df+</literal> is used, additional information
|
||||||
|
about each function is shown, including security classification,
|
||||||
|
volatility, owner, language, source code and description.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<tip>
|
<tip>
|
||||||
@ -1337,15 +1338,18 @@ testdb=>
|
|||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><literal>\do[S] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
|
<term><literal>\do[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Lists operators with their operand and return types.
|
Lists operators with their operand and result types.
|
||||||
If <replaceable class="parameter">pattern</replaceable> is
|
If <replaceable class="parameter">pattern</replaceable> is
|
||||||
specified, only operators whose names match the pattern are listed.
|
specified, only operators whose names match the pattern are listed.
|
||||||
By default, only user-created objects are shown; supply a
|
By default, only user-created objects are shown; supply a
|
||||||
pattern or the <literal>S</literal> modifier to include system
|
pattern or the <literal>S</literal> modifier to include system
|
||||||
objects.
|
objects.
|
||||||
|
If <literal>+</literal> is appended to the command name,
|
||||||
|
additional information about each operator is shown, currently just
|
||||||
|
the name of the underlying function.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -410,7 +410,7 @@ exec_command(const char *cmd,
|
|||||||
success = listSchemas(pattern, show_verbose, show_system);
|
success = listSchemas(pattern, show_verbose, show_system);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
success = describeOperators(pattern, show_system);
|
success = describeOperators(pattern, show_verbose, show_system);
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
success = listCollations(pattern, show_verbose, show_system);
|
success = listCollations(pattern, show_verbose, show_system);
|
||||||
|
@ -577,9 +577,10 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
|
|||||||
|
|
||||||
|
|
||||||
/* \do
|
/* \do
|
||||||
|
* Describe operators
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
describeOperators(const char *pattern, bool showSystem)
|
describeOperators(const char *pattern, bool verbose, bool showSystem)
|
||||||
{
|
{
|
||||||
PQExpBufferData buf;
|
PQExpBufferData buf;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
@ -605,16 +606,23 @@ describeOperators(const char *pattern, bool showSystem)
|
|||||||
" o.oprname AS \"%s\",\n"
|
" o.oprname AS \"%s\",\n"
|
||||||
" CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
|
" CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
|
||||||
" CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
|
" CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
|
||||||
" pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n"
|
" pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n",
|
||||||
" coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
|
|
||||||
" pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
|
|
||||||
"FROM pg_catalog.pg_operator o\n"
|
|
||||||
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
|
|
||||||
gettext_noop("Schema"),
|
gettext_noop("Schema"),
|
||||||
gettext_noop("Name"),
|
gettext_noop("Name"),
|
||||||
gettext_noop("Left arg type"),
|
gettext_noop("Left arg type"),
|
||||||
gettext_noop("Right arg type"),
|
gettext_noop("Right arg type"),
|
||||||
gettext_noop("Result type"),
|
gettext_noop("Result type"));
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
appendPQExpBuffer(&buf,
|
||||||
|
" o.oprcode AS \"%s\",\n",
|
||||||
|
gettext_noop("Function"));
|
||||||
|
|
||||||
|
appendPQExpBuffer(&buf,
|
||||||
|
" coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
|
||||||
|
" pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
|
||||||
|
"FROM pg_catalog.pg_operator o\n"
|
||||||
|
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
|
||||||
gettext_noop("Description"));
|
gettext_noop("Description"));
|
||||||
|
|
||||||
if (!showSystem && !pattern)
|
if (!showSystem && !pattern)
|
||||||
|
@ -22,7 +22,7 @@ extern bool describeFunctions(const char *functypes, const char *pattern, bool v
|
|||||||
extern bool describeTypes(const char *pattern, bool verbose, bool showSystem);
|
extern bool describeTypes(const char *pattern, bool verbose, bool showSystem);
|
||||||
|
|
||||||
/* \do */
|
/* \do */
|
||||||
extern bool describeOperators(const char *pattern, bool showSystem);
|
extern bool describeOperators(const char *pattern, bool verbose, bool showSystem);
|
||||||
|
|
||||||
/* \du, \dg */
|
/* \du, \dg */
|
||||||
extern bool describeRoles(const char *pattern, bool verbose);
|
extern bool describeRoles(const char *pattern, bool verbose);
|
||||||
|
Reference in New Issue
Block a user