Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a490D-0004rj-UG for pgsql-admin@arkaria.postgresql.org; Wed, 02 Dec 2015 15:07:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a490D-0003l9-BM for pgsql-admin@arkaria.postgresql.org; Wed, 02 Dec 2015 15:07:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a48yY-0001nV-Gt for pgsql-admin@postgresql.org; Wed, 02 Dec 2015 15:05:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a48yW-00035W-4Z for pgsql-admin@postgresql.org; Wed, 02 Dec 2015 15:05:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id tB2F5eh9015738; Wed, 2 Dec 2015 10:05:40 -0500 From: Tom Lane To: Sumeet Shukla cc: pgsql-admin Subject: Re: Find if a function is being referenced in another function in the database In-reply-to: References: Comments: In-reply-to Sumeet Shukla message dated "Wed, 02 Dec 2015 13:32:05 +0530" Date: Wed, 02 Dec 2015 10:05:40 -0500 Message-ID: <15737.1449068740@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Sumeet Shukla 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