Fix a problem causing the recovery extension to use excessive memory and CPU time...
[sqlite.git] / test / tt3_shared.c
blob5bdadd1e03f0d541ea002407a1a64b6d76f7093b
1 /*
2 ** 2020 September 5
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
11 *************************************************************************
19 static char *shared_thread1(int iTid, void *pArg){
20 Error err = {0}; /* Error code and message */
22 while( !timetostop(&err) ){
23 Sqlite db = {0}; /* SQLite database connection */
24 opendb(&err, &db, "test.db", 0);
25 sql_script(&err, &db, "SELECT * FROM t1");
26 closedb(&err, &db);
28 print_and_free_err(&err);
29 return sqlite3_mprintf("done!");
33 static void shared1(int nMs){
34 Error err = {0};
35 Sqlite db = {0}; /* SQLite database connection */
36 Threadset threads = {0};
37 int ii;
39 opendb(&err, &db, "test.db", 1);
40 sql_script(&err, &db, "CREATE TABLE t1(x)");
41 closedb(&err, &db);
43 setstoptime(&err, nMs);
44 sqlite3_enable_shared_cache(1);
46 for(ii=0; ii<5; ii++){
47 launch_thread(&err, &threads, shared_thread1, 0);
50 join_all_threads(&err, &threads);
51 sqlite3_enable_shared_cache(0);
53 print_and_free_err(&err);