Re: Showing parallel status in \df+

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Masao Fujii <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: Showing parallel status in \df+
Date: 2016-08-22 08:49:49
Message-ID: CAFj8pRDR=UiwxB0JtN-PDeBawuD_dU7THYJQ_iJo91q=owZ6aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

2016-07-13 19:01 GMT+02:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> > On 7/12/16 7:11 PM, Stephen Frost wrote:
> >> I'm curious how it's useful and in what way \sf does not accomplish what
> >> you use \df+ for.
>
> > One main use is to see multiple related functions next to each other and
> > compare their source code. But also because one is used to \df and
> > wants to see everything there and not in a different format like \sf.
>
> Well, how about my suggestion of moving source code to a footer?
> I had just been experimenting to see how painful that would be, and
> it doesn't seem awful --- see attached.
>

I am sending a review of this patch:

This feature shows source code for PL function when \df statement was used.
I am not too sure, if this functionality is necessary - but I don't see any
argument against. Sometimes it can be useful, mainly when we work with
overloaded functions.

This patch is trivial and there is not any problem with patching,
compilation and test. I have few ideas:

1. show full source code of function - like \sf output - the only body
outside table looks strange

2. is there possibility to isolate sources by some visual element (border,
line)?

Current output:

Source code of function public.bubble(a anyarray, OUT b anyarray):

declare loop_again boolean := true;
begin
while loop_again
loop
loop_again := false;
for i in array_lower(a,1) .. array_upper(a,1) - 1
loop
if (a[i] > a[i+1]) then
b[1] = a[i+1];
a[i+1] = a[i]; a[i] := b[1];
loop_again = true;
end if;
end loop;
end loop;
b := a;
end

Source code of function public.bubble2(a anyarray, OUT b anyarray):

declare loop_again boolean := true;
begin
while loop_again
loop
loop_again := false;
for i in array_lower(a,1) .. array_upper(a,1) - 1
loop
if (a[i] > a[i+1]) then
b[1] = a[i+1];
a[i+1] = a[i]; a[i] := b[1];
loop_again = true;
end if;
end loop;
end loop;
b := a;
end

Preferred output:

Source code of function public.bubble(a anyarray, OUT b anyarray):
------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.bubble(a anyarray, OUT b anyarray)
RETURNS anyarray
LANGUAGE plpgsql
AS $function$
declare loop_again boolean := true;
begin
while loop_again
loop
loop_again := false;
for i in array_lower(a,1) .. array_upper(a,1) - 1
loop
if (a[i] > a[i+1]) then
b[1] = a[i+1];
a[i+1] = a[i]; a[i] := b[1];
loop_again = true;
end if;
end loop;
end loop;
b := a;
end;

Source code of function public.bubble2(a anyarray, OUT b anyarray):
-------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.bubble2(a anyarray, OUT b anyarray)
RETURNS anyarray
LANGUAGE plpgsql
AS $function$
declare loop_again boolean := true;
begin
while loop_again
loop
loop_again := false;
for i in array_lower(a,1) .. array_upper(a,1) - 1
loop
if (a[i] > a[i+1]) then
b[1] = a[i+1];
a[i+1] = a[i]; a[i] := b[1];
loop_again = true;
end if;
end loop;
end loop;
b := a;
end;

3. append semicolon on the end - so copy/paste should to work

Regards

Pavel Stehule

>
> regards, tom lane
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2016-08-22 09:09:01 Re: Tracking wait event for latches
Previous Message Tatsuo Ishii 2016-08-22 08:28:31 Re: UTF-8 docs?