29

Using PostgreSQL with pgAdmin, and was wondering if there is a way to search ALL of the functions of a database for a particular text.

Is this possible?

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
jlars62
  • 6,816
  • 7
  • 37
  • 57

3 Answers3

51

Something like this should work:

select proname, prosrc from pg_proc where prosrc like '%search text%';

see How to display the function, procedure, triggers source code in postgresql?

Andreas
  • 4,650
  • 2
  • 23
  • 31
2

If schema info is required too (we work with many):

select
    nspname,
    proname,
    prosrc 
from pg_catalog.pg_proc pr
join pg_catalog.pg_namespace ns on ns.oid = pr.pronamespace
where prosrc ilike '%search text%'
steevee
  • 1,928
  • 18
  • 15
0

Answers posted by @Andreas and @steevee didn't work out for me, so I had to do the following way:

  1. First enabled extended display by running \x
  2. Then \df+ to list down all stored procedures (in less mode by enabling extended display above) then press / key to search for a keyword.
Ahsaan Yousuf
  • 643
  • 7
  • 16