Snapshot of upstream SQLite 3.34.1
[sqlcipher.git] / test / tt3_index.c
blob62f06ade4aac194eda4d0a965a8d0109ea675593
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.
11 *************************************************************************
13 ** create_drop_index_1
17 static char *create_drop_index_thread(int iTid, void *pArg){
18 Error err = {0}; /* Error code and message */
19 Sqlite db = {0}; /* SQLite database connection */
21 while( !timetostop(&err) ){
22 opendb(&err, &db, "test.db", 0);
24 sql_script(&err, &db,
25 "DROP INDEX IF EXISTS i1;"
26 "DROP INDEX IF EXISTS i2;"
27 "DROP INDEX IF EXISTS i3;"
28 "DROP INDEX IF EXISTS i4;"
30 "CREATE INDEX IF NOT EXISTS i1 ON t11(a);"
31 "CREATE INDEX IF NOT EXISTS i2 ON t11(b);"
32 "CREATE INDEX IF NOT EXISTS i3 ON t11(c);"
33 "CREATE INDEX IF NOT EXISTS i4 ON t11(d);"
35 "SELECT * FROM t11 ORDER BY a;"
36 "SELECT * FROM t11 ORDER BY b;"
37 "SELECT * FROM t11 ORDER BY c;"
38 "SELECT * FROM t11 ORDER BY d;"
40 clear_error(&err, SQLITE_LOCKED);
42 closedb(&err, &db);
45 print_and_free_err(&err);
46 return sqlite3_mprintf("ok");
49 static void create_drop_index_1(int nMs){
50 Error err = {0};
51 Sqlite db = {0};
52 Threadset threads = {0};
54 opendb(&err, &db, "test.db", 1);
55 sql_script(&err, &db,
56 "CREATE TABLE t11(a, b, c, d);"
57 "WITH data(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM data WHERE x<100) "
58 "INSERT INTO t11 SELECT x,x,x,x FROM data;"
60 closedb(&err, &db);
62 setstoptime(&err, nMs);
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);
71 join_all_threads(&err, &threads);
72 sqlite3_enable_shared_cache(0);
73 print_and_free_err(&err);