Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / third_party / sqlite / src / test / tt3_index.c
blobb79768c6c71905faa59bdf9826ac30ac4d7f6a25
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, int iArg){
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,
26 "DROP INDEX IF EXISTS i1;"
27 "DROP INDEX IF EXISTS i2;"
28 "DROP INDEX IF EXISTS i3;"
29 "DROP INDEX IF EXISTS i4;"
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);"
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;"
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 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;"
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);
70 sqlite3_enable_shared_cache(0);
72 join_all_threads(&err, &threads);
73 print_and_free_err(&err);