diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:28:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:28:19 +0000 |
commit | 18657a960e125336f704ea058e25c27bd3900dcb (patch) | |
tree | 17b438b680ed45a996d7b59951e6aa34023783f2 /test/tt3_shared.c | |
parent | Initial commit. (diff) | |
download | sqlite3-18657a960e125336f704ea058e25c27bd3900dcb.tar.xz sqlite3-18657a960e125336f704ea058e25c27bd3900dcb.zip |
Adding upstream version 3.40.1.upstream/3.40.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/tt3_shared.c')
-rw-r--r-- | test/tt3_shared.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/tt3_shared.c b/test/tt3_shared.c new file mode 100644 index 0000000..5bdadd1 --- /dev/null +++ b/test/tt3_shared.c @@ -0,0 +1,55 @@ +/* +** 2020 September 5 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** +*/ + + +/* +*/ +static char *shared_thread1(int iTid, void *pArg){ + Error err = {0}; /* Error code and message */ + + while( !timetostop(&err) ){ + Sqlite db = {0}; /* SQLite database connection */ + opendb(&err, &db, "test.db", 0); + sql_script(&err, &db, "SELECT * FROM t1"); + closedb(&err, &db); + } + print_and_free_err(&err); + return sqlite3_mprintf("done!"); +} + + +static void shared1(int nMs){ + Error err = {0}; + Sqlite db = {0}; /* SQLite database connection */ + Threadset threads = {0}; + int ii; + + opendb(&err, &db, "test.db", 1); + sql_script(&err, &db, "CREATE TABLE t1(x)"); + closedb(&err, &db); + + setstoptime(&err, nMs); + sqlite3_enable_shared_cache(1); + + for(ii=0; ii<5; ii++){ + launch_thread(&err, &threads, shared_thread1, 0); + } + + join_all_threads(&err, &threads); + sqlite3_enable_shared_cache(0); + + print_and_free_err(&err); +} + |