title: How can I check whether we are in a transaction in SQLite?
body: <p>I have multiple functions which need to write to the database and they call each other. Until now, I have been using SAVEPOINT in order to allow nesting of transactions. The problem is that I need to get an EXCLUSIVE lock on the first SAVEPOINT instead of the default DEFERRED lock (this is neccesary to ensure that I wont get halted later by a SQLITE_BUSY). Therefore, I want to do something like follows:</p>
  
  <pre>
  int foo(sqlite3 *db){
      unsigned char wasIn = 1;
      if (!sqlite3_isInTransaction(db)){
           sqlite3_query(db, "BEGIN EXCLUSIVE TRANSACTION");
           wasIn = 0;
      }
      ...do stuff....
      if (!wasIn){
           sqlite3_query(db, "COMMIT TRANSACTION");
      }
  }
  </pre>
  
  <p>Any idea how to accomplish this?</p>