diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-04-07 23:02:16 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-04-07 23:02:21 -0400 |
commit | a3027e1e7f3d3a107ecd72d3b4d6333ea2aab6a5 (patch) | |
tree | 4fcc9b9bb3af4030fc0fd3fe3004926cbc86b54a /doc/src | |
parent | f57a2f5e03054ade221e554c70e628e1ffae1b66 (diff) | |
download | postgresql-a3027e1e7f3d3a107ecd72d3b4d6333ea2aab6a5.tar.gz postgresql-a3027e1e7f3d3a107ecd72d3b4d6333ea2aab6a5.zip |
Allow psql's \df and \do commands to specify argument types.
When dealing with overloaded function or operator names, having
to look through a long list of matches is tedious. Let's extend
these commands to allow specification of (input) argument types
to let such results be trimmed down. Each additional argument
is treated the same as the pattern argument of \dT and matched
against the appropriate argument's type name.
While at it, fix \dT (and these new options) to recognize the
usual notation of "foo[]" for "the array type over foo", and
to handle the special abbreviations allowed by the backend
grammar, such as "int" for "integer".
Greg Sabino Mullane, revised rather significantly by me
Discussion: https://postgr.es/m/CAKAnmmLF9Hhu02N+s7uAyLc5J1xZReg72HQUoiKhNiJV3_jACQ@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/psql-ref.sgml | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index c1451c16727..ddb70433625 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1567,7 +1567,7 @@ testdb=> <varlistentry> - <term><literal>\df[anptwS+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <term><literal>\df[anptwS+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> [ <replaceable class="parameter">arg_pattern</replaceable> ... ] ]</literal></term> <listitem> <para> @@ -1580,6 +1580,11 @@ testdb=> If <replaceable class="parameter">pattern</replaceable> is specified, only functions whose names match the pattern are shown. + Any additional arguments are type-name patterns, which are matched + to the type names of the first, second, and so on arguments of the + function. (Matching functions can have more arguments than what + you specify. To prevent that, write a dash <literal>-</literal> as + the last <replaceable class="parameter">arg_pattern</replaceable>.) By default, only user-created objects are shown; supply a pattern or the <literal>S</literal> modifier to include system objects. @@ -1589,14 +1594,6 @@ testdb=> language, source code and description. </para> - <tip> - <para> - To look up functions taking arguments or returning values of a specific - data type, use your pager's search capability to scroll through the - <literal>\df</literal> output. - </para> - </tip> - </listitem> </varlistentry> @@ -1721,12 +1718,19 @@ testdb=> <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> [ <replaceable class="parameter">arg_pattern</replaceable> [ <replaceable class="parameter">arg_pattern</replaceable> ] ] ]</literal></term> <listitem> <para> Lists operators with their operand and result types. If <replaceable class="parameter">pattern</replaceable> is specified, only operators whose names match the pattern are listed. + If one <replaceable class="parameter">arg_pattern</replaceable> is + specified, only prefix operators whose right argument's type name + matches that pattern are listed. + If two <replaceable class="parameter">arg_pattern</replaceable>s + are specified, only binary operators whose argument type names match + those patterns are listed. (Alternatively, write <literal>-</literal> + for the unused argument of a unary operator.) By default, only user-created objects are shown; supply a pattern or the <literal>S</literal> modifier to include system objects. @@ -4987,6 +4991,22 @@ second | four </para> <para> + Here is an example of using the <command>\df</command> command to + find only functions with names matching <literal>int*pl</literal> + and whose second argument is of type <type>bigint</type>: +<programlisting> +testdb=> <userinput>\df int*pl * bigint</userinput> + List of functions + Schema | Name | Result data type | Argument data types | Type +------------+---------+------------------+---------------------+------ + pg_catalog | int28pl | bigint | smallint, bigint | func + pg_catalog | int48pl | bigint | integer, bigint | func + pg_catalog | int8pl | bigint | bigint, bigint | func +(3 rows) +</programlisting> + </para> + + <para> When suitable, query results can be shown in a crosstab representation with the <command>\crosstabview</command> command: <programlisting> |