I am using the sqlite3_unlock_notify () mechanism along with shared cache in
a multithreaded application that uses SQLite version 3.7.13.  I have been
attaching sqlite3_trace () to all database connections in the application to
log all operations performed on the database.  In the sqlite3_trace ()
callback function that I registered, I simply lock a mutex, print the
statement to stdout, flush stdout, then unlock the mutex.

I have been getting seemingly random statements printed more than they are
supposed to be, but the database operation itself seemed to be executing
fine without errors.  I think that in the following code from
http://www.sqlite.org/unlock_notify.html:

int sqlite3_blocking_step(sqlite3_stmt *pStmt){
  int rc;
  while( SQLITE_LOCKED==(rc = sqlite3_step(pStmt)) ){
    rc = wait_for_unlock_notify(sqlite3_db_handle(pStmt));
    if( rc!=SQLITE_OK ) break;
    sqlite3_reset(pStmt);
  }
  return rc;
} 

the sqlite3_trace () callback function seems to be called even when
sqlite3_step () returns SQLITE_LOCKED and the operation is not successful. 
This seems to be why some statements are being duplicated from test programs
that I have written.  Is this analysis correct?  If so, is there any way to
get the sqlite3_trace () callback to only get called when sqlite3_step
returns SQLITE_DONE?  In other words, how do I have sql statements printed
in the callback only when it is actually performed on the database.

Thanks,
Eric



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/sqlite3-trace-threadsafe-tp64004p64224.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to