1*78f04753Sdan /*
2*78f04753Sdan ** 2020 September 5
3*78f04753Sdan **
4*78f04753Sdan ** The author disclaims copyright to this source code. In place of
5*78f04753Sdan ** a legal notice, here is a blessing:
6*78f04753Sdan **
7*78f04753Sdan ** May you do good and not evil.
8*78f04753Sdan ** May you find forgiveness for yourself and forgive others.
9*78f04753Sdan ** May you share freely, never taking more than you give.
10*78f04753Sdan **
11*78f04753Sdan *************************************************************************
12*78f04753Sdan **
13*78f04753Sdan **
14*78f04753Sdan */
15*78f04753Sdan
16*78f04753Sdan
17*78f04753Sdan /*
18*78f04753Sdan */
shared_thread1(int iTid,void * pArg)19*78f04753Sdan static char *shared_thread1(int iTid, void *pArg){
20*78f04753Sdan Error err = {0}; /* Error code and message */
21*78f04753Sdan
22*78f04753Sdan while( !timetostop(&err) ){
23*78f04753Sdan Sqlite db = {0}; /* SQLite database connection */
24*78f04753Sdan opendb(&err, &db, "test.db", 0);
25*78f04753Sdan sql_script(&err, &db, "SELECT * FROM t1");
26*78f04753Sdan closedb(&err, &db);
27*78f04753Sdan }
28*78f04753Sdan print_and_free_err(&err);
29*78f04753Sdan return sqlite3_mprintf("done!");
30*78f04753Sdan }
31*78f04753Sdan
32*78f04753Sdan
shared1(int nMs)33*78f04753Sdan static void shared1(int nMs){
34*78f04753Sdan Error err = {0};
35*78f04753Sdan Sqlite db = {0}; /* SQLite database connection */
36*78f04753Sdan Threadset threads = {0};
37*78f04753Sdan int ii;
38*78f04753Sdan
39*78f04753Sdan opendb(&err, &db, "test.db", 1);
40*78f04753Sdan sql_script(&err, &db, "CREATE TABLE t1(x)");
41*78f04753Sdan closedb(&err, &db);
42*78f04753Sdan
43*78f04753Sdan setstoptime(&err, nMs);
44*78f04753Sdan sqlite3_enable_shared_cache(1);
45*78f04753Sdan
46*78f04753Sdan for(ii=0; ii<5; ii++){
47*78f04753Sdan launch_thread(&err, &threads, shared_thread1, 0);
48*78f04753Sdan }
49*78f04753Sdan
50*78f04753Sdan join_all_threads(&err, &threads);
51*78f04753Sdan sqlite3_enable_shared_cache(0);
52*78f04753Sdan
53*78f04753Sdan print_and_free_err(&err);
54*78f04753Sdan }
55*78f04753Sdan
56