title: When can DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK have an effect?
body: <p><code>DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK</code> is &quot;supposed&quot; to be used before a transaction, to explicitly set the value on failure.</p>
  <p>However, the <a href="http://dev.mysql.com/doc/refman/5.1/en/declare-handler.html" rel="nofollow noreferrer">documentation</a> states that this is more or less the default behavior anyway?</p>
  <blockquote>
  <p>If a condition occurs for which no handler has been declared, the action taken depends on the condition class:</p>
  <p>For SQLEXCEPTION conditions, the stored program terminates at the statement that raised the condition, as if there were an EXIT handler. If the program was called by another stored program, the calling program handles the condition using the handler selection rules applied to its own handlers.</p>
  </blockquote>
  <p>But that means <code>COMMIT</code> is never called, so, same effect as having no handler.</p>
  <p>I'm not sure how to interpret that. It sounds like the &quot;obvious&quot; thing to do is exit the stored program, but if a calling program has handlers telling to do otherwise - perhaps a <code>DECLARE EXIT HANDLER FOR SQLEXCEPTION CONTINUE</code> - it's not clear to me whether the inside stored program continues or not, or what the &quot;handler selection rules&quot; are in general.</p>
  <p>If this (strange to me) interpretation is the case, then that means if hypothetically a stored program could assume it was never called by another stored program, the handler is extraneous, but it ensures consistent behavior</p>