Re: Showing parallel status in \df+ - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Showing parallel status in \df+
Date
Msg-id 15880.1472048662@sss.pgh.pa.us
Whole thread Raw
In response to Re: Showing parallel status in \df+  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wrote:
> Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>> What does it do if you are displaying more than one function?

> It prints more than one footer.  It's very much like the way that, say,
> rules are printed for tables by \d.

Or to be concrete: instead of


regression=# \df+ foo*
     List of functionsSchema |  Name   | Result data type | Argument data types |  Type  | Volatility | Parallel |
Owner  | Security | Access privileges | Language |                            Source code                             |
Description
 

--------+---------+------------------+---------------------+--------+------------+----------+----------+----------+-------------------+----------+--------------------------------------------------------------------+-------------public
|foo1    | integer          | integer             | normal | volatile   | unsafe   | postgres | invoker  |
    | plpgsql  |                                                                   +|        |         |
 |                     |        |            |          |          |          |                   |          | begin
                                                        +|        |         |                  |                     |
     |            |          |          |          |                   |          |   return $1 + 1;
                             +|        |         |                  |                     |        |            |
  |          |          |                   |          | end
  +|        |         |                  |                     |        |            |          |          |          |
                 |          |                                                                    | public | foo2    |
integer         | integer             | normal | volatile   | unsafe   | postgres | invoker  |                   | sql
   |  select $1 + 2                                                     | public | footest | void             |
           | normal | volatile   | unsafe   | postgres | invoker  |                   | plpgsql  |
                                            +|        |         |                  |                     |        |
      |          |          |          |                   |          | -- override the global
                 +|        |         |                  |                     |        |            |          |
 |          |                   |          | #print_strict_params on                                           +|
|         |                  |                     |        |            |          |          |          |
     |          | declare                                                           +|        |         |
  |                     |        |            |          |          |          |                   |          | x
record;                                                        +|        |         |                  |
   |        |            |          |          |          |                   |          | p1 int := 2;
                                    +|        |         |                  |                     |        |
|         |          |          |                   |          | p3 text := 'foo';
          +|        |         |                  |                     |        |            |          |          |
     |                   |          | begin                                                             +|        |
   |                  |                     |        |            |          |          |          |
|         |   -- too many rows                                                +|        |         |                  |
                  |        |            |          |          |          |                   |          |   select *
fromfoo where f1 > p1 or f1::text = p3  into strict x;+|        |         |                  |                     |
   |            |          |          |          |                   |          |   raise notice 'x.f1 = %, x.f2 = %',
x.f1,x.f2;                  +|        |         |                  |                     |        |            |
 |          |          |                   |          | end
  | 
 
(3 rows)


you get


regression=# \df+ foo*                                                                              List of
functionsSchema|  Name   | Result data type | Argument data types |  Type  | Volatility | Parallel |  Owner   |
Security| Access privileges | Language | Internal name | Description 
 

--------+---------+------------------+---------------------+--------+------------+----------+----------+----------+-------------------+----------+---------------+-------------public
|foo1    | integer          | integer             | normal | volatile   | unsafe   | postgres | invoker  |
    | plpgsql  |               | public | foo2    | integer          | integer             | normal | volatile   |
unsafe  | postgres | invoker  |                   | sql      |               | public | footest | void             |
                | normal | volatile   | unsafe   | postgres | invoker  |                   | plpgsql  |               |

Source code of function public.foo1(integer):

begin return $1 + 1;
end

Source code of function public.foo2(integer):select $1 + 2 
Source code of function public.footest():

-- override the global
#print_strict_params on
declare
x record;
p1 int := 2;
p3 text := 'foo';
begin -- too many rows select * from foo where f1 > p1 or f1::text = p3  into strict x; raise notice 'x.f1 = %, x.f2 =
%',x.f1, x.f2;
 
end


C functions are still compact, and they're more sanely labeled too:

regression=# \df+ sin*                                                                               List of functions
Schema  | Name | Result data type | Argument data types |  Type  | Volatility | Parallel |  Owner   | Security | Access
privileges| Language | Internal name |  Description  
 

------------+------+------------------+---------------------+--------+------------+----------+----------+----------+-------------------+----------+---------------+---------------pg_catalog
|sin  | double precision | double precision    | normal | immutable  | safe     | postgres | invoker  |
 | internal | dsin          | sinepg_catalog | sind | double precision | double precision    | normal | immutable  |
safe    | postgres | invoker  |                   | internal | dsind         | sine, degrees
 
(2 rows)


Admittedly, this is not a huge improvement when working in expanded
display mode, but in normal mode I think it's the difference between a
usable display and a useless one.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: pg_dump with tables created in schemas created by extensions
Next
From: Emre Hasegeli
Date:
Subject: Re: [PATCH] Alter or rename enum value