开发者

How to check SQLite connection's threading mode?

开发者 https://www.devze.com 2023-01-24 12:39 出处:网络
Is it possible to check the threading mode of an active SQLite connection? I know about sqlite3_threadsafe(), but

Is it possible to check the threading mode of an active SQLite connection? I know about sqlite3_threadsafe(), but

The return value of th开发者_开发百科e sqlite3_threadsafe() function shows only the compile-time setting of thread safety, not any run-time changes to that setting made by sqlite3_config().


Hmmm, seven year old question. You have answered it yourself, though. For the next person who comes looking:

sqlite3_db_mutex will return NULL if threading mode is Single-thread or Multi-thread.

So we have:

(sqlite3_threadsafe , sqlite3_db_mutex) : threading mode

(0 , NULL) : Single-thread

(1 , NULL) : Mutli-thread

(1 , valid) : Serialized


Here is a partial answer:

sqlite3_mutex *sqlite3_db_mutex(sqlite3*);

This interface returns a pointer the sqlite3_mutex object that serializes access to the database connection given in the argument when the threading mode is Serialized. If the threading mode is Single-thread or Multi-thread then this routine returns a NULL pointer.

Now I only need a way to distinguish Single-thread from Multi-thread...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号