title: Before / after insert trigger using auto increment field
body: <p>I'm having troubles with an insert trigger that is supposed to fix a column in a table:</p>
  
  <pre><code>id        - auto increment int
  thread_id - int [NULL]
  </code></pre>
  
  <p>What I want to achieve is to set the <code>thread_id</code> to <code>id</code> if it's inserted as NULL. I have failed because:</p>
  
  <ul>
  <li>using <code>before insert</code> trigger still does not have the new value for <code>id</code> and mysteriously sets <code>thread_id</code> to 0</li>
  <li>using <code>after insert - update</code> trigger throws reasonable exception <code>can't update table because it is already used by the statement</code>.</li>
  <li>you can not add additional auto increment field</li>
  </ul>
  
  <p>What is the solution to this problem?</p>