From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sumeet Shukla <sumeet.k.shukla@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Find if a function is being referenced in another function in the database
Date: Wed, 02 Dec 2015 10:05:40 -0500
Message-ID: <15737.1449068740@sss.pgh.pa.us> (raw)
In-Reply-To: <CABUL136Sn-F+DSWVBsr=YhZse0nThZ3YUVN+v1hhWV4f8Xtc3w@mail.gmail.com>
References: <CABUL136Sn-F+DSWVBsr=YhZse0nThZ3YUVN+v1hhWV4f8Xtc3w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>
Sumeet Shukla <sumeet.k.shukla@gmail.com> writes:
> Can someone guide me on how can I find if a given function is being
> referenced by other functions in the same database. If being referenced
> then a list of functions that are referencing it?
Postgres does not track this in any way, because function bodies are for
the most part just black boxes to the core database.
As a first approximation, you could grep (LIKE/regexp search) the
pg_proc.prosrc column for the names of functions you're interested in.
This would have some problems with overloaded functions, and it's
certainly possible to hide calls from it if you want to, but it's a start.
Something like
select s.proname as caller, t.proname as callee
from pg_proc t, pg_proc s
where s.prosrc ~ ('\W' || t.proname || '\(')
and s.prolang > 13 and t.prolang > 13;
(The prolang conditions exclude C/internal functions; this query will
run quite a long time if you include those.)
regards, tom lane
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, sumeet.k.shukla@gmail.com
Subject: Re: Find if a function is being referenced in another function in the database
In-Reply-To: <15737.1449068740@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox