Skip to content

Instantly share code, notes, and snippets.

@maxim-s
Created March 14, 2017 14:49
Show Gist options
  • Save maxim-s/776d63b3733cc0807acec20e560fb555 to your computer and use it in GitHub Desktop.
Save maxim-s/776d63b3733cc0807acec20e560fb555 to your computer and use it in GitHub Desktop.
SELECT r.specific_name AS id,
r.routine_schema AS Schema,
r.routine_name AS Name,
r.data_type AS ReturnType,
r.routine_type AS RoutineType,
(SELECT STRING_AGG(x.param, E'\n')
FROM (SELECT p.parameter_mode || ';' || p.parameter_name || ';' || p.data_type AS param
FROM information_schema.parameters p
WHERE p.specific_name = r.specific_name
ORDER BY p.ordinal_position) x) AS InputArgs
FROM information_schema.routines r
WHERE r.routine_schema NOT IN ('pg_catalog', 'information_schema')
AND r.routine_name NOT IN (SELECT routine_name
FROM information_schema.routines
GROUP BY routine_name
HAVING COUNT(routine_name) > 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment