Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all MySQL Stored Procedure calls?

For a given MySQL DB that I use and modify occasionally I had to recently make some changes to some tables and stored procedures. There are places in this DB where procedures make calls to other procedures. I found the task of hunting down everywhere that I needed to modify the parameters to these modified procedures a hassle and resorted to dumping the DB and doing a text search on the dumped file to find all the CALL statements.

I'm wondering if there's a better and easier way to do this. I did some cursory searching here on SO and also googled for a solution but really didn't find an answer. I suspect that there's a way to come up with a list of the calls made or some utility out there that makes it simple, but I haven't found this solution.

Any ideas?

like image 988
itsmatt Avatar asked May 29 '09 16:05

itsmatt


People also ask

How can I see all procedures in MySQL?

To view the list of the stored procedure, you can query the information_schema. routines table. It contains the list of the stored procedure and stored functions created on the database.

Where are MySQL Stored Procedures stored?

Where are stored procedures stored? Stored procedures are stored in the mysql. routines and mysql. parameters tables, which are part of the data dictionary.


2 Answers

Well, I finally stumbled upon the following solution:

The INFORMATION_SCHEMA.ROUTINES table has information that can be very useful when trying to track down CALLs from one SP to another. I used the following:

SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE "%SomeProc%";

And this retrieved all the store procedures that contained SomeProc.

like image 154
itsmatt Avatar answered Sep 27 '22 22:09

itsmatt


Wow this is awesome! I'm using this to search for text in my MySQL database:

SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE "%search_string%";
like image 45
Lucas Avatar answered Sep 27 '22 20:09

Lucas