SQL to return all function parameters- its working - Mailing list pgsql-general

From Postgres User
Subject SQL to return all function parameters- its working
Date
Msg-id b88c3460905291540o7961d537o91f95c3010303d30@mail.gmail.com
Whole thread Raw
List pgsql-general
Based on replies to another post (recommending use of
'generate_series'), I was able to write the following query that
returns all paramters of a given function.
Only one interesting thing to note- in order to return the proper
argument type, I had to use
  proargtypes[i - 1]     when I expected this to work:    proargtypes[i]

Any feedback would be appreciated...


SELECT n.nspname AS name_space,
    p.proname AS function_name,
    p.oid AS function_oid, t.typname AS rettype,
    p.prosrc AS body,
   argument, argument_type
FROM pg_proc p
INNER JOIN (SELECT oid, proargnames[i] AS argument, proargtypes[i-1]
AS argument_type
 FROM
    (SELECT oid, proargnames, proargtypes,
           generate_series(1, array_upper(proargnames,1)) AS i
    FROM pg_proc) s
 ) arg
    ON p.oid = arg.oid
INNER JOIN pg_namespace n
    ON p.pronamespace = n.oid
LEFT OUTER JOIN pg_type t
    ON t.oid = p.prorettype
-- WHERE p.proname =  'func_name'

pgsql-general by date:

Previous
From: Postgres User
Date:
Subject: Re: Converting each item in array to a query result row
Next
From: Scott Bailey
Date:
Subject: Switching databases over JDBC/ODBC