3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the CREATE INDEX statement.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
23 INSERT INTO t1 VALUES(randomblob(102));
24 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 2
25 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 4
26 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 8
27 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 16
28 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 32
29 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 64
30 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 128
31 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 256
32 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 512
33 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 1024
34 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 2048
35 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 4096
36 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 8192
37 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 16384
38 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 32768
39 INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 65536
44 CREATE INDEX i1 ON t1(x);
47 PRAGMA integrity_check
50 # The same test again - this time with limited memory.
52 ifcapable memorymanage {
53 set soft_limit [sqlite3_soft_heap_limit 50000]
59 PRAGMA cache_size = 10;
60 CREATE INDEX i2 ON t1(x);
63 PRAGMA integrity_check
66 sqlite3_soft_heap_limit $soft_limit
74 INSERT INTO t1 VALUES('a');
75 INSERT INTO t1 VALUES('b');
76 INSERT INTO t1 VALUES('c');
77 INSERT INTO t1 VALUES('d');
78 INSERT INTO t1 VALUES('e');
79 INSERT INTO t1 VALUES('f');
80 INSERT INTO t1 VALUES('g');
81 INSERT INTO t1 VALUES(NULL);
82 INSERT INTO t1 SELECT randomblob(1202) FROM t1; -- 16
83 INSERT INTO t1 SELECT randomblob(2202) FROM t1; -- 32
84 INSERT INTO t1 SELECT randomblob(3202) FROM t1; -- 64
85 INSERT INTO t1 SELECT randomblob(4202) FROM t1; -- 128
86 INSERT INTO t1 SELECT randomblob(5202) FROM t1; -- 256
88 CREATE INDEX i1 ON t1(x);
89 PRAGMA integrity_check
96 INSERT INTO t1 VALUES('a');
98 CREATE INDEX i1 ON t1(x);
99 PRAGMA integrity_check
102 do_execsql_test 1.8 {
107 CREATE INDEX i1 ON t1(x);
108 PRAGMA integrity_check
111 do_execsql_test 2.1 {
114 INSERT INTO t2 VALUES(14);
115 INSERT INTO t2 VALUES(35);
116 INSERT INTO t2 VALUES(15);
117 INSERT INTO t2 VALUES(35);
118 INSERT INTO t2 VALUES(16);
121 do_catchsql_test 2.2 {
122 CREATE UNIQUE INDEX i3 ON t2(x);
123 } {1 {UNIQUE constraint failed: t2.x}}