pg_get_function_result()

A function generating the RETURNS clause of a function

pg_get_function_result() is a system function for generating the RETURNS clause of the specified function.

pg_get_function_result() was added in PostgreSQL 8.4.

Usage

pg_get_function_result ( oid ) → text

pg_get_function_result() returns NULL if the provided object is a procedure.

Change history

Examples

Basic usage example for pg_get_function_result():

postgres=# CREATE FUNCTION foo() RETURNS INT LANGUAGE SQL AS 'SELECT 1';
CREATE FUNCTION

postgres=# SELECT pg_get_function_result('foo()'::regprocedure);
 pg_get_function_result 
------------------------
 integer
(1 row)

NULL is returned if the provided object is not a function:

postgres=# SELECT pg_get_function_result('foo'::regclass) IS NULL;
 ?column? 
----------
 t
(1 row)

Categories

Functions and procedures, System catalogue, System function

See also

pg_get_functiondef(), pg_get_function_arguments(), pg_get_function_identity_arguments()