Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search 'grep-alike' through PostgreSql functions

When refactoring PostgreSql functions (and more specific: while searching for 'unused' functions) it would be handy to have a function available to search for a specific string within the function definitions.

Does anyone know if this is the best approach (trying to 'grep'-search the function definitions) or are there alternative methods available?

How would one implement this functionality?

like image 681
ChristopheD Avatar asked Dec 15 '10 10:12

ChristopheD


1 Answers

SELECT 
  proname AS functionname, 
  prosrc AS source 
FROM 
  pg_proc 
WHERE 
  prosrc ~* 'your_string';

Details about how to use a regex in PostgreSQL, can be found in the manual.

like image 163
Frank Heikens Avatar answered Sep 18 '22 13:09

Frank Heikens