psql: edit function, show function commands patch

Started by Pavel Stehuleabout 16 years ago3 messageshackers
Jump to latest
#1Pavel Stehule
pavel.stehule@gmail.com

Hello

this simple patch allow to specify cursor row when some function is
opened in editor.

\e aaa.txt
\a aaa.txt 3 ... move cursor on 3nd line of text
\ef foo
\ef foo 3 ... move cursor on 3nd line of function body
\sf foo ... show function body
\sf+ foo ... show function body - use line numbers
\sf[+] foo n ... show function body from line n

postgres=# \sf foo

CREATE OR REPLACE FUNCTION public.foo()
RETURNS integer
LANGUAGE plpgsql
AS $function$
begin
return 10/0;
end;
$function$

postgres=# \sf+ foo

**** CREATE OR REPLACE FUNCTION public.foo()
**** RETURNS integer
**** LANGUAGE plpgsql
1 AS $function$
2 begin
3 return 10/0;
4 end;
**** $function$

Regards
Pavel Stehule

Attachments:

editfce.diffapplication/octet-stream; name=editfce.diffDownload+231-58
#2Bruce Momjian
bruce@momjian.us
In reply to: Pavel Stehule (#1)
Re: psql: edit function, show function commands patch

I have added this to the next commit-fest.

---------------------------------------------------------------------------

Pavel Stehule wrote:

Hello

this simple patch allow to specify cursor row when some function is
opened in editor.

\e aaa.txt
\a aaa.txt 3 ... move cursor on 3nd line of text
\ef foo
\ef foo 3 ... move cursor on 3nd line of function body
\sf foo ... show function body
\sf+ foo ... show function body - use line numbers
\sf[+] foo n ... show function body from line n

postgres=# \sf foo

CREATE OR REPLACE FUNCTION public.foo()
RETURNS integer
LANGUAGE plpgsql
AS $function$
begin
return 10/0;
end;
$function$

postgres=# \sf+ foo

**** CREATE OR REPLACE FUNCTION public.foo()
**** RETURNS integer
**** LANGUAGE plpgsql
1 AS $function$
2 begin
3 return 10/0;
4 end;
**** $function$

Regards
Pavel Stehule

[ Attachment, skipping... ]

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Bruce Momjian (#2)
Re: psql: edit function, show function commands patch

2010/4/1 Bruce Momjian <bruce@momjian.us>:

I have added this to the next commit-fest.

thank you
Pavel

Show quoted text

---------------------------------------------------------------------------

Pavel Stehule wrote:

Hello

this simple patch allow to specify cursor row when some function is
opened in editor.

\e aaa.txt
\a aaa.txt 3 ... move cursor on 3nd line of text
\ef foo
\ef foo 3 ... move cursor on 3nd line of function body
\sf foo ... show function body
\sf+ foo ... show function body - use line numbers
\sf[+] foo n ... show function body from line n

postgres=# \sf foo

CREATE OR REPLACE FUNCTION public.foo()
 RETURNS integer
 LANGUAGE plpgsql
AS $function$
begin
  return 10/0;
end;
$function$

postgres=# \sf+ foo

****  CREATE OR REPLACE FUNCTION public.foo()
****   RETURNS integer
****   LANGUAGE plpgsql
   1  AS $function$
   2  begin
   3    return 10/0;
   4  end;
****  $function$

Regards
Pavel Stehule

[ Attachment, skipping... ]

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
 Bruce Momjian  <bruce@momjian.us>        http://momjian.us
 EnterpriseDB                             http://enterprisedb.com