PostgreSQL: get all functions related to a table

I have this function:

SELECT n.nspname AS schema_name
      ,p.proname AS function_name
      ,pg_get_function_arguments(p.oid) AS args
      ,pg_get_functiondef(p.oid) AS func_def
FROM   (SELECT oid, * FROM pg_proc p WHERE NOT p.proisagg) p
JOIN   pg_namespace n ON n.oid = p.pronamespace
WHERE  n.nspname !~~ 'pg_%'
AND    n.nspname <> 'information_schema'
AND    pg_get_functiondef(p.oid) ~ '\mTableName\M';

      

it gives me a list of functions that use TableName. However, he doesn't ignore the notes. For example, if there function A

is a string like:

-- select * from TableName

      

it will show A

the result, even though its note A

is not actually being used TableName

.

How can I make a request that does the same, but ignore all notes?

+3


source to share


1 answer


You can find everything you need right on this wiki page: https://wiki.postgresql.org/wiki/Pg_depend_display



All kinds of dependencies exist depending on your version of PostgreSQL.

0


source







All Articles