0

I am using the following command to describe the function in Unix.

\df+ functionName

Problem: Unable to read the description of the function.

Is there any other method to look the function with the proper indentation.

2

1 Answer 1

2

If you start psql with key -E (psql -E) and run your \df+ functionName, you will see, that it takes definition from pg_catalog.pg_proc, so you can just query it like select prosrc from pg_proc where proname = 'functionName';'

Same for \sf functionName - it's is a wrap up for pg_catalog.pg_get_functiondef.

Lastly if you do it your way, with \df+, just run \x before it and Source code will look much better.

Anyway in ALL those case indentation is saved:

b=# create function p() returns text
b-# as
b-# $$
b$# begin
b$#   --tab
b$#   --two spaces
b$#    --three spaces
b$#   return 't';
b$# end;
b$# $$ language plpgsql
b-# ;
CREATE FUNCTION
b=# \x
Expanded display is on.
b=# \df+ p
List of functions
-[ RECORD 1 ]-------+------------------
Schema              | public
Name                | p
Result data type    | text
Argument data types |
Type                | normal
Security            | invoker
Volatility          | volatile
Owner               | postgres
Language            | plpgsql
Source code         |                  +
                    | begin            +
                    |   --tab          +
                    |   --two spaces   +
                    |    --three spaces+
                    |   return 't';    +
                    | end;             +
                    |
Description         |

b=# \sf p
CREATE OR REPLACE FUNCTION public.p()
 RETURNS text
 LANGUAGE plpgsql
AS $function$
begin
  --tab
  --two spaces
   --three spaces
  return 't';
end;
$function$
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.