sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 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. |
| 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** |
| 13 | ** |
| 14 | */ |
| 15 | |
| 16 | |
| 17 | /* |
| 18 | */ |
| 19 | static char *shared_thread1(int iTid, void *pArg){ |
| 20 | Error err = {0}; /* Error code and message */ |
| 21 | |
| 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); |
| 27 | } |
| 28 | print_and_free_err(&err); |
| 29 | return sqlite3_mprintf("done!"); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | static void shared1(int nMs){ |
| 34 | Error err = {0}; |
| 35 | Sqlite db = {0}; /* SQLite database connection */ |
| 36 | Threadset threads = {0}; |
| 37 | int ii; |
| 38 | |
| 39 | opendb(&err, &db, "test.db", 1); |
| 40 | sql_script(&err, &db, "CREATE TABLE t1(x)"); |
| 41 | closedb(&err, &db); |
| 42 | |
| 43 | setstoptime(&err, nMs); |
| 44 | sqlite3_enable_shared_cache(1); |
| 45 | |
| 46 | for(ii=0; ii<5; ii++){ |
| 47 | launch_thread(&err, &threads, shared_thread1, 0); |
| 48 | } |
| 49 | |
| 50 | join_all_threads(&err, &threads); |
| 51 | sqlite3_enable_shared_cache(0); |
| 52 | |
| 53 | print_and_free_err(&err); |
| 54 | } |
| 55 |