title: Debugging MySQL Triggers
body: <p>I love triggers for one reason - they just work. I hate triggers for one reason - when they don't work, forget about trying to debug. O the sweet frustration.</p>
  
  <p>Basically, I want to see THE update, delete, insert, etc query that was ran. I want to see that query ... somewhere, in my terminal or a log, exactly how and when MySQL executes it, and possibly any corresponding output/errors. Thoughts/hacks?</p>
  
  <p>I'm trying to debug an update query with a few joins and what not. My queries are much more complex but for brevity here's an example. </p>
  
  <pre><code>DELIMITER |
  CREATE TRIGGER ireallyhateyourightnow AFTER UPDATE ON watch_this_table
  FOR EACH ROW BEGIN
   IF (OLD.my_value != NEW.my_value) THEN
    update 
     my_table
    set 
     my_column = NEW.my_value;
   END IF;
  END|
  DELIMITER ;
  </code></pre>
  
  <p>Here is some additional context that may help influence a suggestion or answer. Again, I'm less interested in semantics/syntax and more interested in seeing MySQL run the query but by all means, I'm open to anything at this point.</p>
  
  <ul>
  <li>Strace does not work/show query.</li>
  <li>Non-replicated environment BUT if the bin logs show trigger statements I will certainly set this up.</li>
  <li>Does "show full processlist" show trigger execution and/or statements executed within (I never see them after running show full processlist as fast as perl can run it but I might just be missing it)?</li>
  <li>General query log does not show these queries (certainly not the error log).</li>
  <li>I'm not using aliases (anymore).</li>
  <li>No syntax errors when creating the trigger.</li>
  <li>The IF statement works.</li>
  <li>When I insert the NEW values into a "test/temp" table and manually run the update query it works (I've even went so far as to actually inserting the whole update query)</li>
  <li>I can't show you the query but as I just mentioned, it works when I run manually if that helps.</li>
  <li>I've removed all erroneous characters, tabs, carriage returns, newlines, etc.</li>
  <li>The MySQL socket would only show local connection/data but not MySQL internal workings, I think.</li>
  <li>MyISAM so INNODB logs aren't an option</li>
  <li>lsof didn't seem to show anything else to be of use.</li>
  <li>I'm using MySQL 5.0.77 on CentOS 5.5.</li>
  </ul>