简体   繁体   中英

PostgreSQL: getting all functions related to 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 uses TableName. However it doesn't ignore notes. For example if in function A there will be a line like:

-- select * from TableName

it will show A in the result even though its a note and A doesn't really uses TableName .

How can I make a query that does the same thing but ignore all notes?

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

There is all sorts of dependency views depending on you PostgreSQL version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM