Hello all,
I have found that busy_timeout doesn work in this case:

-------%<--------------------------------------------------------------------------------
#include <stdio.h>
#include <sqlite3.h>


int check_error (int rc, char *zErrMsg)
{
  if( rc!=SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg);
    sqlite3_free(zErrMsg);
  }
}

int main(int argc, char **argv){
  sqlite3 *db, *db2;
  char *zErrMsg = 0;
  int rc;

  rc = sqlite3_open("test.db", &db);
  rc = sqlite3_open("test.db", &db2);

  printf("db1 start trans\n");
  rc = sqlite3_exec(db, "BEGIN TRANSACTION" , NULL, NULL, &zErrMsg);
  check_error(rc, zErrMsg);

  printf("db1 insert\n");
  rc = sqlite3_exec(db, "INSERT INTO Blah VALUES ( 1, 'Test1' )" ,
NULL, NULL, &zErrMsg);
  check_error(rc, zErrMsg);


  sqlite3_busy_timeout(db2, 30000);

  printf("db2 start trans\n");
  rc = sqlite3_exec(db2, "BEGIN TRANSACTION" , NULL, NULL, &zErrMsg);
  check_error(rc, zErrMsg);

  /* SQLITE should wait for 3 second before returning error, but it doesn't  */
  printf("db2 insert\n");
  rc = sqlite3_exec(db2, "INSERT INTO Blah VALUES ( 1, 'Test1' )" ,
NULL, NULL, &zErrMsg);
  check_error(rc, zErrMsg);

  sqlite3_close(db);
  return 0;
}

-------%<--------------------------------------------------------------------------------

Most interesting thing that If you try to INSERT in db2 WITHOUT
transaction busy_timeout() will work correctly.
--
Alexander Batyrshin aka bash
Biomechanical Artificial Sabotage Humanoid
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to