pg_get_function_arguments()

A function for generating a function/procedure argument list

pg_get_function_arguments() is a system function for generating the argument list for a function or procedure as a text string.

pg_get_function_arguments() was added in PostgreSQL 8.4.

Usage

pg_get_function_arguments ( oid ) → text

Change history

Examples

Basic usage example for pg_get_function_arguments():

postgres=# CREATE FUNCTION foo(id INT, message TEXT)
             RETURNS TEXT
             LANGUAGE SQL
           AS $$
             SELECT message || ':' || id::TEXT
           $$;
CREATE FUNCTION

postgres=# SELECT pg_get_function_arguments('foo(int, text)'::regprocedure);
 pg_get_function_arguments 
---------------------------
 id integer, message text
(1 row)

Any default values are also emitted:

postgres=# CREATE FUNCTION bar (message TEXT DEFAULT 'no message supplied')
             RETURNS TEXT
             LANGUAGE SQL
           AS $$
             SELECT 'The message is: ' || message
           $$;
CREATE FUNCTION

postgres=# SELECT pg_get_function_arguments('bar(text)'::regprocedure);
            pg_get_function_arguments             
--------------------------------------------------
 message text DEFAULT 'no message supplied'::text
(1 row)

Categories

Functions and procedures, System catalogue, System function

See also

pg_get_functiondef(), pg_get_function_identity_arguments(), pg_get_function_result()