Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitlather/54021529a06d39bba56881e59ba223f9 to your computer and use it in GitHub Desktop.
Save bitlather/54021529a06d39bba56881e59ba223f9 to your computer and use it in GitHub Desktop.
-- PostgreSQL 9.3.14 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit
-- ============================================================================
-- Returns the comments for all functions we'll create.
--
-- Precondition:
--
-- Assumes you are currently using a database.
--
-- Usage:
--
-- SELECT * FROM function_documentation;
--
-- ============================================================================
CREATE OR REPLACE VIEW function_documentation AS
SELECT
-- n.nspname as "Schema",
p.proname::TEXT AS "function_name",
pg_catalog.pg_get_function_result(p.oid) as "result_data_type",
pg_catalog.pg_get_function_arguments(p.oid) as "argument_data_types",
d.description as "comment"
-- CASE
-- WHEN p.proisagg THEN 'agg'
-- WHEN p.proiswindow THEN 'window'
-- WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'
-- ELSE 'normal'
-- END as "Type"
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
LEFT JOIN pg_catalog.pg_description As d ON (d.objoid = p.oid )
WHERE pg_catalog.pg_function_is_visible(p.oid)
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
ORDER BY 1, 2;
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment