title: MySQL - How to check if START TRANSACTION is active
body: <p>I have noticed that <code>START TRANSACTION</code> automatically <code>COMMIT</code> the previous queries. Because of this and the fact that I have several stored procedure called before the end of the whole transaction, I need to check if I am inside a <code>START TRANSACTION</code> or not. Reading the manual I understood that autocommit is set to false inside a <code>START TRANSACTION</code>, but it doesn't seem like this. I have written the following procedure:</p>
  
  <pre><code>    CREATE DEFINER=`root`@`localhost` PROCEDURE `test_transaction`()
  BEGIN
  
  show session variables like 'autocommit';
  
  start transaction;
  
  show session variables like 'autocommit';
  
  COMMIT;
  
  show session variables like 'autocommit';
  
  END
  </code></pre>
  
  <p>But each <code>show session variables like 'autocommit';</code> show autocommit=ON while I expected the second to be autocommit=OFF.</p>
  
  <p>How can I check if I am inside a <code>START TRANSACTION</code>?</p>
  
  <p>I need to perform this check because I have procedure1 that need <code>START TRANSACTION</code> then it calls procedure2 that also need <code>START TRANSACTION</code>. But let's suppose I have a third procedure different_procedure that also need to call procedure2 but in this case different_procedure doesn't use <code>START TRANSACTION</code>. In this scenario I need procedure2 to check if <code>START TRANSACTION</code> was initiated. I hope this is enough clear.</p>