Re: Grep'ing for a string in all functions in a schema?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: bricklen <bricklen(at)gmail(dot)com>
Cc: Wells Oliver <wellsoliver(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Grep'ing for a string in all functions in a schema?
Date: 2014-01-31 12:37:12
Message-ID: 20140131123712.GA21358@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 30, 2014 at 12:52:35PM -0800, bricklen wrote:
> > Since Postgres does not consider a table as a dependency of a function if
> > that table is referenced in the function (probably a good reason), I often
> > find myself in a position of asking "is this table/sequence/index
> > referenced in any of these N number of functions?"
> >
> > Is there an easy way of essentially grep'ing all of the functions in a
> > given schema for a string?
> A method I've used in the past is to create a view of function source which
> can then be searched.

Why not simply:

select p.oid::regproc from pg_proc p join pg_namespace n on p.pronamespace = n.oid where n.nspname = 'your-schema' and p.prosrc ~ 'searched-string';

depesz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2014-01-31 12:51:43 Re: Temporary table already exists
Previous Message mephysto 2014-01-31 11:04:47 Re: Temporary table already exists