pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedFind if a function is being referenced in another function in the database
3+ messages / 2 participants
[nested] [flat]
* Find if a function is being referenced in another function in the database
@ 2015-12-02 08:02 Sumeet Shukla <sumeet.k.shukla@gmail.com>
2015-12-02 15:05 ` Re: Find if a function is being referenced in another function in the database Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Sumeet Shukla @ 2015-12-02 08:02 UTC (permalink / raw)
To: pgsql-admin
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?
Any help would be highly appreciated.
Please let me know if you need more details from me to answer this.
Thanks & Regards,
Sumeet Shukla
Ph. No. 962 323 4700
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Find if a function is being referenced in another function in the database
2015-12-02 08:02 Find if a function is being referenced in another function in the database Sumeet Shukla <sumeet.k.shukla@gmail.com>
@ 2015-12-02 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-12-03 06:39 ` Re: Find if a function is being referenced in another function in the database Sumeet Shukla <sumeet.k.shukla@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2015-12-02 15:05 UTC (permalink / raw)
To: Sumeet Shukla <sumeet.k.shukla@gmail.com>; +Cc: pgsql-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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Find if a function is being referenced in another function in the database
2015-12-02 08:02 Find if a function is being referenced in another function in the database Sumeet Shukla <sumeet.k.shukla@gmail.com>
2015-12-02 15:05 ` Re: Find if a function is being referenced in another function in the database Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-12-03 06:39 ` Sumeet Shukla <sumeet.k.shukla@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Sumeet Shukla @ 2015-12-03 06:39 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin
Thank You for answering the query :-)
Thanks & Regards,
Sumeet Shukla
Ph. No. 962 323 4700
On Wed, Dec 2, 2015 at 8:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 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
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2015-12-03 06:39 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 08:02 Find if a function is being referenced in another function in the database Sumeet Shukla <sumeet.k.shukla@gmail.com>
2015-12-02 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-12-03 06:39 ` Sumeet Shukla <sumeet.k.shukla@gmail.com>
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