title: How do I check if a stored procedure exists before trying to create it in MySQL?
body: <p>I'm trying to do <code>CREATE PROCEDURE IF NOT EXISTS</code> in MySQL. However it looks like MySQL does not natively support this, which seems like a major oversight to me.</p>
  
  <p>I've created a Spring Batch Java application which contains business schema definitions, which includes both table definitions and the stored procedure definitions. The table definitions are fine, since they say <code>CREATE TABLE IF NOT EXISTS</code>. I would like the stored procedure definitions to be the same, since this business schema script will be run any time the application is launched.</p>
  
  <p>MySQL does have <code>DROP PROCEDURE IF EXISTS</code>, but I worry that running that before a create runs into a possible race condition. What if I've got multiple instances of this application running, and one of the other instances is running one of the stored procedures when I do the DROP and subsequent CREATE? That seems like an all around bad idea. I don't want it to interrupt anything already running.</p>
  
  <p>Someone else must have encountered this same problem by now. What's the solution?</p>