title: How to get COMPLETE function definition script in postgresql?
body: <p>I'm trying to get FULL definition text of a function, but the query that everyone suggests returns the functions script without the header and footer parts.</p>
  
  <p>Here's what I'm using:</p>
  
  <pre><code>select prosrc from pg_proc where proname='my_func';
  </code></pre>
  
  <p>Here's what is returned:</p>
  
  <pre><code>DECLARE
  some_var1 TEXT;
  some_var2 TEXT;
  Status character varying;
  
  BEGIN
  --SCRIPT CODE HERE
  
  RETURN retval;
  END;
  </code></pre>
  
  <p>But what I want is this:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION my_func(logdate_utc date)
  RETURNS character varying
  LANGUAGE 'plpgsql'
  
  COST 100
  VOLATILE 
  AS $BODY$
  DECLARE
  some_var1 TEXT;
  some_var2 TEXT;
  Status character varying;
  
  BEGIN
  --SCRIPT CODE HERE
  
  RETURN retval;
  END;
  $BODY$;
  
  ALTER FUNCTION my_func(date)
      OWNER TO some_owner;
  </code></pre>
  
  <p>Searched around and haven't found much. How can I get that result?</p>