Sharma, Gaurav wrote:
> Please clear my one more doubt. Is it true that either using the
> SQLITE_THREADSAFE=1 as compile time flag or using
> SQLITE_OPEN_FULLMUTEX with sqlite3_open_v2 are same thing. Both can
> be used interchangeably. Correct me if I am wrong.

Once you compile with SQLITE_THREADSAFE=0, all threading and mutex 
related code is removed at compile time, and SQLite can only be used in 
single-threaded mode.

If you compile with SQLITE_THREADSAFE=1 or 2, you can then switch 
between multi-threaded and serialized mode at run time, by specifying 
SQLITE_OPEN_NOMUTEX or SQLITE_OPEN_FULLMUTEX flags to sqlite3_open_v2. 
SQLITE_THREADSAFE determines the default setting when neither flag is 
specified. You can also change the default at run-time with 
sqlite3_config (but again, once you compile with SQLITE_THREADSAFE=0, 
there's no way to switch to any of the two thread-safe modes).

See http://www.sqlite.org/threadsafe.html

> Secondly, Is it possible by any mean that for shared connection
> amongst thread, the insert on one thread does not become part of the
> transaction on other thread.

No. A transaction is a property of a connection, not that of a thread. 
You'd have to use separate connections, perhaps in shared-cache mode: 
http://www.sqlite.org/sharedcache.html

> And one last thing just to confirm that it is not at all possible to
> open different in memory db connection from different threads?

Every time you open a connection to :memory:, a new in-memory db is 
created. So yes, it's possible to open multiple connections to in-memory 
databases (whether from multiple threads or otherwise) - but not to the 
same in-memory database.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to