Re: Showing parallel status in \df+ - Mailing list pgsql-hackers
From | Pavel Stehule |
---|---|
Subject | Re: Showing parallel status in \df+ |
Date | |
Msg-id | CAFj8pRDR=UiwxB0JtN-PDeBawuD_dU7THYJQ_iJo91q=owZ6aw@mail.gmail.com Whole thread Raw |
In response to | Re: Showing parallel status in \df+ (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: Showing parallel status in \df+
(Robert Haas <robertmhaas@gmail.com>)
|
List | pgsql-hackers |
Hi
2016-07-13 19:01 GMT+02:00 Tom Lane <tgl@sss.pgh.pa.us>:
Peter Eisentraut <peter.eisentraut@2ndquadrant.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
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;
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
pgsql-hackers by date: