OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ** 2014 December 9 |
| 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 ** create_drop_index_1 |
| 14 */ |
| 15 |
| 16 |
| 17 static char *create_drop_index_thread(int iTid, int iArg){ |
| 18 Error err = {0}; /* Error code and message */ |
| 19 Sqlite db = {0}; /* SQLite database connection */ |
| 20 |
| 21 while( !timetostop(&err) ){ |
| 22 opendb(&err, &db, "test.db", 0); |
| 23 |
| 24 sql_script(&err, &db, |
| 25 |
| 26 "DROP INDEX IF EXISTS i1;" |
| 27 "DROP INDEX IF EXISTS i2;" |
| 28 "DROP INDEX IF EXISTS i3;" |
| 29 "DROP INDEX IF EXISTS i4;" |
| 30 |
| 31 "CREATE INDEX IF NOT EXISTS i1 ON t1(a);" |
| 32 "CREATE INDEX IF NOT EXISTS i2 ON t1(b);" |
| 33 "CREATE INDEX IF NOT EXISTS i3 ON t1(c);" |
| 34 "CREATE INDEX IF NOT EXISTS i4 ON t1(d);" |
| 35 |
| 36 "SELECT * FROM t1 ORDER BY a;" |
| 37 "SELECT * FROM t1 ORDER BY b;" |
| 38 "SELECT * FROM t1 ORDER BY c;" |
| 39 "SELECT * FROM t1 ORDER BY d;" |
| 40 ); |
| 41 |
| 42 closedb(&err, &db); |
| 43 } |
| 44 |
| 45 print_and_free_err(&err); |
| 46 return sqlite3_mprintf("ok"); |
| 47 } |
| 48 |
| 49 static void create_drop_index_1(int nMs){ |
| 50 Error err = {0}; |
| 51 Sqlite db = {0}; |
| 52 Threadset threads = {0}; |
| 53 |
| 54 opendb(&err, &db, "test.db", 1); |
| 55 sql_script(&err, &db, |
| 56 "CREATE TABLE t1(a, b, c, d);" |
| 57 "WITH data(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM data WHERE x<100) " |
| 58 "INSERT INTO t1 SELECT x,x,x,x FROM data;" |
| 59 ); |
| 60 closedb(&err, &db); |
| 61 |
| 62 setstoptime(&err, nMs); |
| 63 |
| 64 sqlite3_enable_shared_cache(1); |
| 65 launch_thread(&err, &threads, create_drop_index_thread, 0); |
| 66 launch_thread(&err, &threads, create_drop_index_thread, 0); |
| 67 launch_thread(&err, &threads, create_drop_index_thread, 0); |
| 68 launch_thread(&err, &threads, create_drop_index_thread, 0); |
| 69 launch_thread(&err, &threads, create_drop_index_thread, 0); |
| 70 sqlite3_enable_shared_cache(0); |
| 71 |
| 72 join_all_threads(&err, &threads); |
| 73 print_and_free_err(&err); |
| 74 } |
OLD | NEW |