blob: 023b9a125441440bdcaeb3515dc2b22ce0b8f583 [file] [log] [blame]
drhb19a2bc2001-09-16 00:13:26 +00001# 2001 September 15
drhb24fcbe2000-05-29 23:30:50 +00002#
drhb19a2bc2001-09-16 00:13:26 +00003# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
drhb24fcbe2000-05-29 23:30:50 +00005#
drhb19a2bc2001-09-16 00:13:26 +00006# 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.
drhb24fcbe2000-05-29 23:30:50 +00009#
10#***********************************************************************
11# This file implements regression tests for SQLite library. The
12# focus of this file is testing the CREATE INDEX statement.
13#
danielk197748dec7e2004-05-28 12:33:30 +000014# $Id: index.test,v 1.27 2004/05/28 12:33:32 danielk1977 Exp $
drhb24fcbe2000-05-29 23:30:50 +000015
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18
19# Create a basic index and verify it is added to sqlite_master
20#
drh1b6a71f2000-05-29 23:58:11 +000021do_test index-1.1 {
drhb24fcbe2000-05-29 23:30:50 +000022 execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)}
23 execsql {CREATE INDEX index1 ON test1(f1)}
drh28037572000-08-02 13:47:41 +000024 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +000025} {index1 test1}
drh1b6a71f2000-05-29 23:58:11 +000026do_test index-1.1b {
drhb24fcbe2000-05-29 23:30:50 +000027 execsql {SELECT name, sql, tbl_name, type FROM sqlite_master
28 WHERE name='index1'}
29} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index}
drh1b6a71f2000-05-29 23:58:11 +000030do_test index-1.1c {
drhb24fcbe2000-05-29 23:30:50 +000031 db close
drh5edc3122001-09-13 21:53:09 +000032 sqlite db test.db
drhb24fcbe2000-05-29 23:30:50 +000033 execsql {SELECT name, sql, tbl_name, type FROM sqlite_master
34 WHERE name='index1'}
35} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index}
drh1b6a71f2000-05-29 23:58:11 +000036do_test index-1.1d {
drhb24fcbe2000-05-29 23:30:50 +000037 db close
drh5edc3122001-09-13 21:53:09 +000038 sqlite db test.db
drh28037572000-08-02 13:47:41 +000039 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +000040} {index1 test1}
41
42# Verify that the index dies with the table
43#
drh1b6a71f2000-05-29 23:58:11 +000044do_test index-1.2 {
drhb24fcbe2000-05-29 23:30:50 +000045 execsql {DROP TABLE test1}
drh28037572000-08-02 13:47:41 +000046 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +000047} {}
48
49# Try adding an index to a table that does not exist
50#
drh1b6a71f2000-05-29 23:58:11 +000051do_test index-2.1 {
drhb24fcbe2000-05-29 23:30:50 +000052 set v [catch {execsql {CREATE INDEX index1 ON test1(f1)}} msg]
53 lappend v $msg
danielk197748dec7e2004-05-28 12:33:30 +000054} {1 {no such table: main.test1}}
drhb24fcbe2000-05-29 23:30:50 +000055
drh1ccde152000-06-17 13:12:39 +000056# Try adding an index on a column of a table where the table
57# exists but the column does not.
drhb24fcbe2000-05-29 23:30:50 +000058#
drh1b6a71f2000-05-29 23:58:11 +000059do_test index-2.1 {
drhb24fcbe2000-05-29 23:30:50 +000060 execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)}
61 set v [catch {execsql {CREATE INDEX index1 ON test1(f4)}} msg]
62 lappend v $msg
drh1ccde152000-06-17 13:12:39 +000063} {1 {table test1 has no column named f4}}
drhb24fcbe2000-05-29 23:30:50 +000064
drh1ccde152000-06-17 13:12:39 +000065# Try an index with some columns that match and others that do now.
drhb24fcbe2000-05-29 23:30:50 +000066#
drh1b6a71f2000-05-29 23:58:11 +000067do_test index-2.2 {
drhb24fcbe2000-05-29 23:30:50 +000068 set v [catch {execsql {CREATE INDEX index1 ON test1(f1, f2, f4, f3)}} msg]
69 execsql {DROP TABLE test1}
70 lappend v $msg
drh1ccde152000-06-17 13:12:39 +000071} {1 {table test1 has no column named f4}}
drhb24fcbe2000-05-29 23:30:50 +000072
73# Try creating a bunch of indices on the same table
74#
75set r {}
76for {set i 1} {$i<100} {incr i} {
drha9e99ae2002-08-13 23:02:57 +000077 lappend r [format index%02d $i]
drhb24fcbe2000-05-29 23:30:50 +000078}
drh1b6a71f2000-05-29 23:58:11 +000079do_test index-3.1 {
drhb24fcbe2000-05-29 23:30:50 +000080 execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)}
81 for {set i 1} {$i<100} {incr i} {
drha9e99ae2002-08-13 23:02:57 +000082 set sql "CREATE INDEX [format index%02d $i] ON test1(f[expr {($i%5)+1}])"
drhb24fcbe2000-05-29 23:30:50 +000083 execsql $sql
84 }
85 execsql {SELECT name FROM sqlite_master
86 WHERE type='index' AND tbl_name='test1'
87 ORDER BY name}
88} $r
89
drhb24fcbe2000-05-29 23:30:50 +000090
91# Verify that all the indices go away when we drop the table.
92#
drh1b6a71f2000-05-29 23:58:11 +000093do_test index-3.3 {
drhb24fcbe2000-05-29 23:30:50 +000094 execsql {DROP TABLE test1}
95 execsql {SELECT name FROM sqlite_master
96 WHERE type='index' AND tbl_name='test1'
97 ORDER BY name}
98} {}
drhb24fcbe2000-05-29 23:30:50 +000099
100# Create a table and insert values into that table. Then create
101# an index on that table. Verify that we can select values
102# from the table correctly using the index.
103#
drh7020f652000-06-03 18:06:52 +0000104# Note that the index names "index9" and "indext" are chosen because
105# they both have the same hash.
106#
drh1b6a71f2000-05-29 23:58:11 +0000107do_test index-4.1 {
drhb24fcbe2000-05-29 23:30:50 +0000108 execsql {CREATE TABLE test1(cnt int, power int)}
109 for {set i 1} {$i<20} {incr i} {
110 execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])"
111 }
drh7020f652000-06-03 18:06:52 +0000112 execsql {CREATE INDEX index9 ON test1(cnt)}
113 execsql {CREATE INDEX indext ON test1(power)}
drh28037572000-08-02 13:47:41 +0000114 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drh7020f652000-06-03 18:06:52 +0000115} {index9 indext test1}
drh1b6a71f2000-05-29 23:58:11 +0000116do_test index-4.2 {
drhb24fcbe2000-05-29 23:30:50 +0000117 execsql {SELECT cnt FROM test1 WHERE power=4}
118} {2}
drh1b6a71f2000-05-29 23:58:11 +0000119do_test index-4.3 {
drhb24fcbe2000-05-29 23:30:50 +0000120 execsql {SELECT cnt FROM test1 WHERE power=1024}
121} {10}
drh1b6a71f2000-05-29 23:58:11 +0000122do_test index-4.4 {
drhb24fcbe2000-05-29 23:30:50 +0000123 execsql {SELECT power FROM test1 WHERE cnt=6}
124} {64}
drh1b6a71f2000-05-29 23:58:11 +0000125do_test index-4.5 {
drh7020f652000-06-03 18:06:52 +0000126 execsql {DROP INDEX indext}
127 execsql {SELECT power FROM test1 WHERE cnt=6}
128} {64}
129do_test index-4.6 {
130 execsql {SELECT cnt FROM test1 WHERE power=1024}
131} {10}
132do_test index-4.7 {
133 execsql {CREATE INDEX indext ON test1(cnt)}
134 execsql {SELECT power FROM test1 WHERE cnt=6}
135} {64}
136do_test index-4.8 {
137 execsql {SELECT cnt FROM test1 WHERE power=1024}
138} {10}
139do_test index-4.9 {
140 execsql {DROP INDEX index9}
141 execsql {SELECT power FROM test1 WHERE cnt=6}
142} {64}
143do_test index-4.10 {
144 execsql {SELECT cnt FROM test1 WHERE power=1024}
145} {10}
146do_test index-4.11 {
147 execsql {DROP INDEX indext}
148 execsql {SELECT power FROM test1 WHERE cnt=6}
149} {64}
150do_test index-4.12 {
151 execsql {SELECT cnt FROM test1 WHERE power=1024}
152} {10}
153do_test index-4.13 {
drhb24fcbe2000-05-29 23:30:50 +0000154 execsql {DROP TABLE test1}
drh28037572000-08-02 13:47:41 +0000155 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +0000156} {}
drhed717fe2003-06-15 23:42:24 +0000157integrity_check index-4.14
drhb24fcbe2000-05-29 23:30:50 +0000158
159# Do not allow indices to be added to sqlite_master
160#
drh1b6a71f2000-05-29 23:58:11 +0000161do_test index-5.1 {
drhb24fcbe2000-05-29 23:30:50 +0000162 set v [catch {execsql {CREATE INDEX index1 ON sqlite_master(name)}} msg]
163 lappend v $msg
drh0be9df02003-03-30 00:19:49 +0000164} {1 {table sqlite_master may not be indexed}}
drh1b6a71f2000-05-29 23:58:11 +0000165do_test index-5.2 {
drh28037572000-08-02 13:47:41 +0000166 execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
drhb24fcbe2000-05-29 23:30:50 +0000167} {}
168
169# Do not allow indices with duplicate names to be added
170#
drh1b6a71f2000-05-29 23:58:11 +0000171do_test index-6.1 {
drhb24fcbe2000-05-29 23:30:50 +0000172 execsql {CREATE TABLE test1(f1 int, f2 int)}
173 execsql {CREATE TABLE test2(g1 real, g2 real)}
174 execsql {CREATE INDEX index1 ON test1(f1)}
175 set v [catch {execsql {CREATE INDEX index1 ON test2(g1)}} msg]
176 lappend v $msg
drh1d37e282000-05-30 03:12:21 +0000177} {1 {index index1 already exists}}
drh1b6a71f2000-05-29 23:58:11 +0000178do_test index-6.1b {
drh28037572000-08-02 13:47:41 +0000179 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +0000180} {index1 test1 test2}
drh1b6a71f2000-05-29 23:58:11 +0000181do_test index-6.2 {
drhb24fcbe2000-05-29 23:30:50 +0000182 set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg]
183 lappend v $msg
drh1d37e282000-05-30 03:12:21 +0000184} {1 {there is already a table named test1}}
drh1b6a71f2000-05-29 23:58:11 +0000185do_test index-6.2b {
drh28037572000-08-02 13:47:41 +0000186 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +0000187} {index1 test1 test2}
drh1b6a71f2000-05-29 23:58:11 +0000188do_test index-6.3 {
drhb24fcbe2000-05-29 23:30:50 +0000189 execsql {DROP TABLE test1}
190 execsql {DROP TABLE test2}
drh28037572000-08-02 13:47:41 +0000191 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
drhb24fcbe2000-05-29 23:30:50 +0000192} {}
drhf5bf0a72001-11-23 00:24:12 +0000193do_test index-6.4 {
194 execsql {
195 CREATE TABLE test1(a,b);
196 CREATE INDEX index1 ON test1(a);
197 CREATE INDEX index2 ON test1(b);
198 CREATE INDEX index3 ON test1(a,b);
199 DROP TABLE test1;
200 SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name;
201 }
202} {}
drhed717fe2003-06-15 23:42:24 +0000203integrity_check index-6.5
204
drhb24fcbe2000-05-29 23:30:50 +0000205
206# Create a primary key
207#
drh1b6a71f2000-05-29 23:58:11 +0000208do_test index-7.1 {
drhb24fcbe2000-05-29 23:30:50 +0000209 execsql {CREATE TABLE test1(f1 int, f2 int primary key)}
210 for {set i 1} {$i<20} {incr i} {
211 execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])"
212 }
drh767c2002000-10-19 14:10:08 +0000213 execsql {SELECT count(*) FROM test1}
214} {19}
drh1b6a71f2000-05-29 23:58:11 +0000215do_test index-7.2 {
drhb24fcbe2000-05-29 23:30:50 +0000216 execsql {SELECT f1 FROM test1 WHERE f2=65536}
217} {16}
drh1b6a71f2000-05-29 23:58:11 +0000218do_test index-7.3 {
drhadbca9c2001-09-27 15:11:53 +0000219 execsql {
220 SELECT name FROM sqlite_master
221 WHERE type='index' AND tbl_name='test1'
222 }
223} {{(test1 autoindex 1)}}
drh1b6a71f2000-05-29 23:58:11 +0000224do_test index-7.4 {
225 execsql {DROP table test1}
drh28037572000-08-02 13:47:41 +0000226 execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
drh1b6a71f2000-05-29 23:58:11 +0000227} {}
drhed717fe2003-06-15 23:42:24 +0000228integrity_check index-7.5
drh1b6a71f2000-05-29 23:58:11 +0000229
drh7020f652000-06-03 18:06:52 +0000230# Make sure we cannot drop a non-existant index.
drh1b6a71f2000-05-29 23:58:11 +0000231#
232do_test index-8.1 {
233 set v [catch {execsql {DROP INDEX index1}} msg]
234 lappend v $msg
drh1d37e282000-05-30 03:12:21 +0000235} {1 {no such index: index1}}
drh1b6a71f2000-05-29 23:58:11 +0000236
drh7020f652000-06-03 18:06:52 +0000237# Make sure we don't actually create an index when the EXPLAIN keyword
238# is used.
239#
240do_test index-9.1 {
241 execsql {CREATE TABLE tab1(a int)}
242 execsql {EXPLAIN CREATE INDEX idx1 ON tab1(a)}
243 execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1'}
244} {tab1}
245do_test index-9.2 {
246 execsql {CREATE INDEX idx1 ON tab1(a)}
247 execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name}
248} {idx1 tab1}
drhed717fe2003-06-15 23:42:24 +0000249integrity_check index-9.3
drhb24fcbe2000-05-29 23:30:50 +0000250
drhe8409722000-06-08 16:54:40 +0000251# Allow more than one entry with the same key.
252#
253do_test index-10.0 {
254 execsql {
255 CREATE TABLE t1(a int, b int);
256 CREATE INDEX i1 ON t1(a);
257 INSERT INTO t1 VALUES(1,2);
258 INSERT INTO t1 VALUES(2,4);
259 INSERT INTO t1 VALUES(3,8);
260 INSERT INTO t1 VALUES(1,12);
261 SELECT b FROM t1 WHERE a=1 ORDER BY b;
262 }
263} {2 12}
264do_test index-10.1 {
265 execsql {
266 SELECT b FROM t1 WHERE a=2 ORDER BY b;
267 }
268} {4}
269do_test index-10.2 {
270 execsql {
271 DELETE FROM t1 WHERE b=12;
272 SELECT b FROM t1 WHERE a=1 ORDER BY b;
273 }
274} {2}
drh353f57e2000-08-02 12:26:28 +0000275do_test index-10.3 {
drhe8409722000-06-08 16:54:40 +0000276 execsql {
277 DELETE FROM t1 WHERE b=2;
278 SELECT b FROM t1 WHERE a=1 ORDER BY b;
279 }
280} {}
drh353f57e2000-08-02 12:26:28 +0000281do_test index-10.4 {
282 execsql {
283 DELETE FROM t1;
284 INSERT INTO t1 VALUES (1,1);
285 INSERT INTO t1 VALUES (1,2);
286 INSERT INTO t1 VALUES (1,3);
287 INSERT INTO t1 VALUES (1,4);
288 INSERT INTO t1 VALUES (1,5);
289 INSERT INTO t1 VALUES (1,6);
290 INSERT INTO t1 VALUES (1,7);
291 INSERT INTO t1 VALUES (1,8);
292 INSERT INTO t1 VALUES (1,9);
293 INSERT INTO t1 VALUES (2,0);
294 SELECT b FROM t1 WHERE a=1 ORDER BY b;
295 }
296} {1 2 3 4 5 6 7 8 9}
297do_test index-10.5 {
298 execsql {
299 DELETE FROM t1 WHERE b IN (2, 4, 6, 8);
300 SELECT b FROM t1 WHERE a=1 ORDER BY b;
301 }
302} {1 3 5 7 9}
303do_test index-10.6 {
304 execsql {
305 DELETE FROM t1 WHERE b>2;
306 SELECT b FROM t1 WHERE a=1 ORDER BY b;
307 }
308} {1}
309do_test index-10.7 {
310 execsql {
311 DELETE FROM t1 WHERE b=1;
312 SELECT b FROM t1 WHERE a=1 ORDER BY b;
313 }
314} {}
315do_test index-10.8 {
316 execsql {
317 SELECT b FROM t1 ORDER BY b;
318 }
319} {0}
drhed717fe2003-06-15 23:42:24 +0000320integrity_check index-10.9
drh353f57e2000-08-02 12:26:28 +0000321
drhc4a3c772001-04-04 11:48:57 +0000322# Automatically create an index when we specify a primary key.
323#
324do_test index-11.1 {
325 execsql {
326 CREATE TABLE t3(
327 a text,
328 b int,
329 c float,
330 PRIMARY KEY(b)
331 );
332 }
333 for {set i 1} {$i<=50} {incr i} {
334 execsql "INSERT INTO t3 VALUES('x${i}x',$i,0.$i)"
335 }
drh487ab3c2001-11-08 00:45:21 +0000336 set sqlite_search_count 0
337 concat [execsql {SELECT c FROM t3 WHERE b==10}] $sqlite_search_count
danielk19773d1bfea2004-05-14 11:00:53 +0000338} {0.1 3}
drhed717fe2003-06-15 23:42:24 +0000339integrity_check index-11.2
340
drhe8409722000-06-08 16:54:40 +0000341
drh7a7c7392001-11-24 00:31:46 +0000342# Numeric strings should compare as if they were numbers. So even if the
343# strings are not character-by-character the same, if they represent the
344# same number they should compare equal to one another. Verify that this
345# is true in indices.
346#
danielk19773d1bfea2004-05-14 11:00:53 +0000347# Updated for sqlite v3: SQLite will now store these values as numbers
348# (because the affinity of column a is NUMERIC) so the quirky
349# representations are not retained. i.e. '+1.0' becomes '1'.
drh7a7c7392001-11-24 00:31:46 +0000350do_test index-12.1 {
351 execsql {
danielk197793edea92004-05-16 22:55:28 +0000352 CREATE TABLE t4(a NUM,b);
drh7a7c7392001-11-24 00:31:46 +0000353 INSERT INTO t4 VALUES('0.0',1);
354 INSERT INTO t4 VALUES('0.00',2);
355 INSERT INTO t4 VALUES('abc',3);
356 INSERT INTO t4 VALUES('-1.0',4);
357 INSERT INTO t4 VALUES('+1.0',5);
358 INSERT INTO t4 VALUES('0',6);
359 INSERT INTO t4 VALUES('00000',7);
360 SELECT a FROM t4 ORDER BY b;
361 }
danielk19773d1bfea2004-05-14 11:00:53 +0000362} {0 0 abc -1 1 0 0}
drh7a7c7392001-11-24 00:31:46 +0000363do_test index-12.2 {
364 execsql {
365 SELECT a FROM t4 WHERE a==0 ORDER BY b
366 }
danielk19773d1bfea2004-05-14 11:00:53 +0000367} {0 0 0 0}
drh7a7c7392001-11-24 00:31:46 +0000368do_test index-12.3 {
369 execsql {
370 SELECT a FROM t4 WHERE a<0.5 ORDER BY b
371 }
danielk19773d1bfea2004-05-14 11:00:53 +0000372} {0 0 -1 0 0}
drh7a7c7392001-11-24 00:31:46 +0000373do_test index-12.4 {
374 execsql {
375 SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
376 }
danielk19773d1bfea2004-05-14 11:00:53 +0000377} {0 0 abc 1 0 0}
drh7a7c7392001-11-24 00:31:46 +0000378do_test index-12.5 {
379 execsql {
380 CREATE INDEX t4i1 ON t4(a);
381 SELECT a FROM t4 WHERE a==0 ORDER BY b
382 }
danielk19773d1bfea2004-05-14 11:00:53 +0000383} {0 0 0 0}
drh7a7c7392001-11-24 00:31:46 +0000384do_test index-12.6 {
385 execsql {
386 SELECT a FROM t4 WHERE a<0.5 ORDER BY b
387 }
danielk19773d1bfea2004-05-14 11:00:53 +0000388} {0 0 -1 0 0}
drh7a7c7392001-11-24 00:31:46 +0000389do_test index-12.7 {
390 execsql {
391 SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
392 }
danielk19773d1bfea2004-05-14 11:00:53 +0000393} {0 0 abc 1 0 0}
drhed717fe2003-06-15 23:42:24 +0000394integrity_check index-12.8
drh7a7c7392001-11-24 00:31:46 +0000395
drh485b39b2002-07-13 03:11:52 +0000396# Make sure we cannot drop an automatically created index.
397#
398do_test index-13.1 {
399 execsql {
400 CREATE TABLE t5(
401 a int UNIQUE,
402 b float PRIMARY KEY,
403 c varchar(10),
404 UNIQUE(a,c)
405 );
406 INSERT INTO t5 VALUES(1,2,3);
407 SELECT * FROM t5;
408 }
409} {1 2 3}
410do_test index-13.2 {
411 set ::idxlist [execsql {
412 SELECT name FROM sqlite_master WHERE type="index" AND tbl_name="t5";
413 }]
414 llength $::idxlist
415} {3}
416for {set i 0} {$i<[llength $::idxlist]} {incr i} {
417 do_test index-13.3.$i {
418 catchsql "
419 DROP INDEX '[lindex $::idxlist $i]';
420 "
421 } {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
422}
423do_test index-13.4 {
424 execsql {
425 INSERT INTO t5 VALUES('a','b','c');
426 SELECT * FROM t5;
427 }
428} {1 2 3 a b c}
drhed717fe2003-06-15 23:42:24 +0000429integrity_check index-13.5
drh485b39b2002-07-13 03:11:52 +0000430
drh491791a2002-07-18 00:34:09 +0000431# Check the sort order of data in an index.
432#
433do_test index-14.1 {
434 execsql {
435 CREATE TABLE t6(a,b,c);
436 CREATE INDEX t6i1 ON t6(a,b);
437 INSERT INTO t6 VALUES('','',1);
438 INSERT INTO t6 VALUES('',NULL,2);
439 INSERT INTO t6 VALUES(NULL,'',3);
440 INSERT INTO t6 VALUES('abc',123,4);
441 INSERT INTO t6 VALUES(123,'abc',5);
442 SELECT c FROM t6 ORDER BY a,b;
443 }
444} {3 5 2 1 4}
445do_test index-14.2 {
446 execsql {
447 SELECT c FROM t6 WHERE a='';
448 }
449} {2 1}
450do_test index-14.3 {
451 execsql {
452 SELECT c FROM t6 WHERE b='';
453 }
454} {1 3}
455do_test index-14.4 {
456 execsql {
457 SELECT c FROM t6 WHERE a>'';
458 }
459} {4}
460do_test index-14.5 {
461 execsql {
462 SELECT c FROM t6 WHERE a>='';
463 }
464} {2 1 4}
465do_test index-14.6 {
466 execsql {
467 SELECT c FROM t6 WHERE a>123;
468 }
469} {2 1 4}
470do_test index-14.7 {
471 execsql {
472 SELECT c FROM t6 WHERE a>=123;
473 }
474} {5 2 1 4}
475do_test index-14.8 {
476 execsql {
477 SELECT c FROM t6 WHERE a<'abc';
478 }
drh562528c2003-09-27 00:41:27 +0000479} {5 2 1}
drh491791a2002-07-18 00:34:09 +0000480do_test index-14.9 {
481 execsql {
482 SELECT c FROM t6 WHERE a<='abc';
483 }
drh562528c2003-09-27 00:41:27 +0000484} {5 2 1 4}
drh491791a2002-07-18 00:34:09 +0000485do_test index-14.10 {
486 execsql {
487 SELECT c FROM t6 WHERE a<='';
488 }
drh562528c2003-09-27 00:41:27 +0000489} {5 2 1}
drh491791a2002-07-18 00:34:09 +0000490do_test index-14.11 {
491 execsql {
492 SELECT c FROM t6 WHERE a<'';
493 }
drh562528c2003-09-27 00:41:27 +0000494} {5}
drhed717fe2003-06-15 23:42:24 +0000495integrity_check index-14.12
drh491791a2002-07-18 00:34:09 +0000496
drhbb07e9a2003-04-16 02:17:35 +0000497do_test index-15.1 {
498 execsql {
499 DELETE FROM t1;
500 SELECT * FROM t1;
501 }
502} {}
503do_test index-15.2 {
504 execsql {
505 INSERT INTO t1 VALUES('1.234e5',1);
506 INSERT INTO t1 VALUES('12.33e04',2);
507 INSERT INTO t1 VALUES('12.35E4',3);
508 INSERT INTO t1 VALUES('12.34e',4);
509 INSERT INTO t1 VALUES('12.32e+4',5);
510 INSERT INTO t1 VALUES('12.36E+04',6);
511 INSERT INTO t1 VALUES('12.36E+',7);
512 INSERT INTO t1 VALUES('+123.10000E+0003',8);
513 INSERT INTO t1 VALUES('+',9);
514 INSERT INTO t1 VALUES('+12347.E+02',10);
515 INSERT INTO t1 VALUES('+12347E+02',11);
516 SELECT b FROM t1 ORDER BY a;
517 }
518} {8 5 2 1 3 6 11 9 10 4 7}
drhed717fe2003-06-15 23:42:24 +0000519integrity_check index-15.1
drh491791a2002-07-18 00:34:09 +0000520
drhb24fcbe2000-05-29 23:30:50 +0000521finish_test