1*4520Snw141292 2*4520Snw141292#pragma ident "%Z%%M% %I% %E% SMI" 3*4520Snw141292 4*4520Snw141292# 2001 September 15 5*4520Snw141292# 6*4520Snw141292# The author disclaims copyright to this source code. In place of 7*4520Snw141292# a legal notice, here is a blessing: 8*4520Snw141292# 9*4520Snw141292# May you do good and not evil. 10*4520Snw141292# May you find forgiveness for yourself and forgive others. 11*4520Snw141292# May you share freely, never taking more than you give. 12*4520Snw141292# 13*4520Snw141292#*********************************************************************** 14*4520Snw141292# This file implements regression tests for SQLite library. The 15*4520Snw141292# focus of this file is testing the CREATE INDEX statement. 16*4520Snw141292# 17*4520Snw141292# $Id: index.test,v 1.24.2.1 2004/07/20 00:50:30 drh Exp $ 18*4520Snw141292 19*4520Snw141292set testdir [file dirname $argv0] 20*4520Snw141292source $testdir/tester.tcl 21*4520Snw141292 22*4520Snw141292# Create a basic index and verify it is added to sqlite_master 23*4520Snw141292# 24*4520Snw141292do_test index-1.1 { 25*4520Snw141292 execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)} 26*4520Snw141292 execsql {CREATE INDEX index1 ON test1(f1)} 27*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 28*4520Snw141292} {index1 test1} 29*4520Snw141292do_test index-1.1b { 30*4520Snw141292 execsql {SELECT name, sql, tbl_name, type FROM sqlite_master 31*4520Snw141292 WHERE name='index1'} 32*4520Snw141292} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index} 33*4520Snw141292do_test index-1.1c { 34*4520Snw141292 db close 35*4520Snw141292 sqlite db test.db 36*4520Snw141292 execsql {SELECT name, sql, tbl_name, type FROM sqlite_master 37*4520Snw141292 WHERE name='index1'} 38*4520Snw141292} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index} 39*4520Snw141292do_test index-1.1d { 40*4520Snw141292 db close 41*4520Snw141292 sqlite db test.db 42*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 43*4520Snw141292} {index1 test1} 44*4520Snw141292 45*4520Snw141292# Verify that the index dies with the table 46*4520Snw141292# 47*4520Snw141292do_test index-1.2 { 48*4520Snw141292 execsql {DROP TABLE test1} 49*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 50*4520Snw141292} {} 51*4520Snw141292 52*4520Snw141292# Try adding an index to a table that does not exist 53*4520Snw141292# 54*4520Snw141292do_test index-2.1 { 55*4520Snw141292 set v [catch {execsql {CREATE INDEX index1 ON test1(f1)}} msg] 56*4520Snw141292 lappend v $msg 57*4520Snw141292} {1 {no such table: test1}} 58*4520Snw141292 59*4520Snw141292# Try adding an index on a column of a table where the table 60*4520Snw141292# exists but the column does not. 61*4520Snw141292# 62*4520Snw141292do_test index-2.1 { 63*4520Snw141292 execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)} 64*4520Snw141292 set v [catch {execsql {CREATE INDEX index1 ON test1(f4)}} msg] 65*4520Snw141292 lappend v $msg 66*4520Snw141292} {1 {table test1 has no column named f4}} 67*4520Snw141292 68*4520Snw141292# Try an index with some columns that match and others that do now. 69*4520Snw141292# 70*4520Snw141292do_test index-2.2 { 71*4520Snw141292 set v [catch {execsql {CREATE INDEX index1 ON test1(f1, f2, f4, f3)}} msg] 72*4520Snw141292 execsql {DROP TABLE test1} 73*4520Snw141292 lappend v $msg 74*4520Snw141292} {1 {table test1 has no column named f4}} 75*4520Snw141292 76*4520Snw141292# Try creating a bunch of indices on the same table 77*4520Snw141292# 78*4520Snw141292set r {} 79*4520Snw141292for {set i 1} {$i<100} {incr i} { 80*4520Snw141292 lappend r [format index%02d $i] 81*4520Snw141292} 82*4520Snw141292do_test index-3.1 { 83*4520Snw141292 execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)} 84*4520Snw141292 for {set i 1} {$i<100} {incr i} { 85*4520Snw141292 set sql "CREATE INDEX [format index%02d $i] ON test1(f[expr {($i%5)+1}])" 86*4520Snw141292 execsql $sql 87*4520Snw141292 } 88*4520Snw141292 execsql {SELECT name FROM sqlite_master 89*4520Snw141292 WHERE type='index' AND tbl_name='test1' 90*4520Snw141292 ORDER BY name} 91*4520Snw141292} $r 92*4520Snw141292 93*4520Snw141292 94*4520Snw141292# Verify that all the indices go away when we drop the table. 95*4520Snw141292# 96*4520Snw141292do_test index-3.3 { 97*4520Snw141292 execsql {DROP TABLE test1} 98*4520Snw141292 execsql {SELECT name FROM sqlite_master 99*4520Snw141292 WHERE type='index' AND tbl_name='test1' 100*4520Snw141292 ORDER BY name} 101*4520Snw141292} {} 102*4520Snw141292 103*4520Snw141292# Create a table and insert values into that table. Then create 104*4520Snw141292# an index on that table. Verify that we can select values 105*4520Snw141292# from the table correctly using the index. 106*4520Snw141292# 107*4520Snw141292# Note that the index names "index9" and "indext" are chosen because 108*4520Snw141292# they both have the same hash. 109*4520Snw141292# 110*4520Snw141292do_test index-4.1 { 111*4520Snw141292 execsql {CREATE TABLE test1(cnt int, power int)} 112*4520Snw141292 for {set i 1} {$i<20} {incr i} { 113*4520Snw141292 execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])" 114*4520Snw141292 } 115*4520Snw141292 execsql {CREATE INDEX index9 ON test1(cnt)} 116*4520Snw141292 execsql {CREATE INDEX indext ON test1(power)} 117*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 118*4520Snw141292} {index9 indext test1} 119*4520Snw141292do_test index-4.2 { 120*4520Snw141292 execsql {SELECT cnt FROM test1 WHERE power=4} 121*4520Snw141292} {2} 122*4520Snw141292do_test index-4.3 { 123*4520Snw141292 execsql {SELECT cnt FROM test1 WHERE power=1024} 124*4520Snw141292} {10} 125*4520Snw141292do_test index-4.4 { 126*4520Snw141292 execsql {SELECT power FROM test1 WHERE cnt=6} 127*4520Snw141292} {64} 128*4520Snw141292do_test index-4.5 { 129*4520Snw141292 execsql {DROP INDEX indext} 130*4520Snw141292 execsql {SELECT power FROM test1 WHERE cnt=6} 131*4520Snw141292} {64} 132*4520Snw141292do_test index-4.6 { 133*4520Snw141292 execsql {SELECT cnt FROM test1 WHERE power=1024} 134*4520Snw141292} {10} 135*4520Snw141292do_test index-4.7 { 136*4520Snw141292 execsql {CREATE INDEX indext ON test1(cnt)} 137*4520Snw141292 execsql {SELECT power FROM test1 WHERE cnt=6} 138*4520Snw141292} {64} 139*4520Snw141292do_test index-4.8 { 140*4520Snw141292 execsql {SELECT cnt FROM test1 WHERE power=1024} 141*4520Snw141292} {10} 142*4520Snw141292do_test index-4.9 { 143*4520Snw141292 execsql {DROP INDEX index9} 144*4520Snw141292 execsql {SELECT power FROM test1 WHERE cnt=6} 145*4520Snw141292} {64} 146*4520Snw141292do_test index-4.10 { 147*4520Snw141292 execsql {SELECT cnt FROM test1 WHERE power=1024} 148*4520Snw141292} {10} 149*4520Snw141292do_test index-4.11 { 150*4520Snw141292 execsql {DROP INDEX indext} 151*4520Snw141292 execsql {SELECT power FROM test1 WHERE cnt=6} 152*4520Snw141292} {64} 153*4520Snw141292do_test index-4.12 { 154*4520Snw141292 execsql {SELECT cnt FROM test1 WHERE power=1024} 155*4520Snw141292} {10} 156*4520Snw141292do_test index-4.13 { 157*4520Snw141292 execsql {DROP TABLE test1} 158*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 159*4520Snw141292} {} 160*4520Snw141292integrity_check index-4.14 161*4520Snw141292 162*4520Snw141292# Do not allow indices to be added to sqlite_master 163*4520Snw141292# 164*4520Snw141292do_test index-5.1 { 165*4520Snw141292 set v [catch {execsql {CREATE INDEX index1 ON sqlite_master(name)}} msg] 166*4520Snw141292 lappend v $msg 167*4520Snw141292} {1 {table sqlite_master may not be indexed}} 168*4520Snw141292do_test index-5.2 { 169*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta'} 170*4520Snw141292} {} 171*4520Snw141292 172*4520Snw141292# Do not allow indices with duplicate names to be added 173*4520Snw141292# 174*4520Snw141292do_test index-6.1 { 175*4520Snw141292 execsql {CREATE TABLE test1(f1 int, f2 int)} 176*4520Snw141292 execsql {CREATE TABLE test2(g1 real, g2 real)} 177*4520Snw141292 execsql {CREATE INDEX index1 ON test1(f1)} 178*4520Snw141292 set v [catch {execsql {CREATE INDEX index1 ON test2(g1)}} msg] 179*4520Snw141292 lappend v $msg 180*4520Snw141292} {1 {index index1 already exists}} 181*4520Snw141292do_test index-6.1b { 182*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 183*4520Snw141292} {index1 test1 test2} 184*4520Snw141292do_test index-6.2 { 185*4520Snw141292 set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg] 186*4520Snw141292 lappend v $msg 187*4520Snw141292} {1 {there is already a table named test1}} 188*4520Snw141292do_test index-6.2b { 189*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 190*4520Snw141292} {index1 test1 test2} 191*4520Snw141292do_test index-6.3 { 192*4520Snw141292 execsql {DROP TABLE test1} 193*4520Snw141292 execsql {DROP TABLE test2} 194*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} 195*4520Snw141292} {} 196*4520Snw141292do_test index-6.4 { 197*4520Snw141292 execsql { 198*4520Snw141292 CREATE TABLE test1(a,b); 199*4520Snw141292 CREATE INDEX index1 ON test1(a); 200*4520Snw141292 CREATE INDEX index2 ON test1(b); 201*4520Snw141292 CREATE INDEX index3 ON test1(a,b); 202*4520Snw141292 DROP TABLE test1; 203*4520Snw141292 SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name; 204*4520Snw141292 } 205*4520Snw141292} {} 206*4520Snw141292integrity_check index-6.5 207*4520Snw141292 208*4520Snw141292 209*4520Snw141292# Create a primary key 210*4520Snw141292# 211*4520Snw141292do_test index-7.1 { 212*4520Snw141292 execsql {CREATE TABLE test1(f1 int, f2 int primary key)} 213*4520Snw141292 for {set i 1} {$i<20} {incr i} { 214*4520Snw141292 execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])" 215*4520Snw141292 } 216*4520Snw141292 execsql {SELECT count(*) FROM test1} 217*4520Snw141292} {19} 218*4520Snw141292do_test index-7.2 { 219*4520Snw141292 execsql {SELECT f1 FROM test1 WHERE f2=65536} 220*4520Snw141292} {16} 221*4520Snw141292do_test index-7.3 { 222*4520Snw141292 execsql { 223*4520Snw141292 SELECT name FROM sqlite_master 224*4520Snw141292 WHERE type='index' AND tbl_name='test1' 225*4520Snw141292 } 226*4520Snw141292} {{(test1 autoindex 1)}} 227*4520Snw141292do_test index-7.4 { 228*4520Snw141292 execsql {DROP table test1} 229*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE type!='meta'} 230*4520Snw141292} {} 231*4520Snw141292integrity_check index-7.5 232*4520Snw141292 233*4520Snw141292# Make sure we cannot drop a non-existant index. 234*4520Snw141292# 235*4520Snw141292do_test index-8.1 { 236*4520Snw141292 set v [catch {execsql {DROP INDEX index1}} msg] 237*4520Snw141292 lappend v $msg 238*4520Snw141292} {1 {no such index: index1}} 239*4520Snw141292 240*4520Snw141292# Make sure we don't actually create an index when the EXPLAIN keyword 241*4520Snw141292# is used. 242*4520Snw141292# 243*4520Snw141292do_test index-9.1 { 244*4520Snw141292 execsql {CREATE TABLE tab1(a int)} 245*4520Snw141292 execsql {EXPLAIN CREATE INDEX idx1 ON tab1(a)} 246*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1'} 247*4520Snw141292} {tab1} 248*4520Snw141292do_test index-9.2 { 249*4520Snw141292 execsql {CREATE INDEX idx1 ON tab1(a)} 250*4520Snw141292 execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name} 251*4520Snw141292} {idx1 tab1} 252*4520Snw141292integrity_check index-9.3 253*4520Snw141292 254*4520Snw141292# Allow more than one entry with the same key. 255*4520Snw141292# 256*4520Snw141292do_test index-10.0 { 257*4520Snw141292 execsql { 258*4520Snw141292 CREATE TABLE t1(a int, b int); 259*4520Snw141292 CREATE INDEX i1 ON t1(a); 260*4520Snw141292 INSERT INTO t1 VALUES(1,2); 261*4520Snw141292 INSERT INTO t1 VALUES(2,4); 262*4520Snw141292 INSERT INTO t1 VALUES(3,8); 263*4520Snw141292 INSERT INTO t1 VALUES(1,12); 264*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 265*4520Snw141292 } 266*4520Snw141292} {2 12} 267*4520Snw141292do_test index-10.1 { 268*4520Snw141292 execsql { 269*4520Snw141292 SELECT b FROM t1 WHERE a=2 ORDER BY b; 270*4520Snw141292 } 271*4520Snw141292} {4} 272*4520Snw141292do_test index-10.2 { 273*4520Snw141292 execsql { 274*4520Snw141292 DELETE FROM t1 WHERE b=12; 275*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 276*4520Snw141292 } 277*4520Snw141292} {2} 278*4520Snw141292do_test index-10.3 { 279*4520Snw141292 execsql { 280*4520Snw141292 DELETE FROM t1 WHERE b=2; 281*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 282*4520Snw141292 } 283*4520Snw141292} {} 284*4520Snw141292do_test index-10.4 { 285*4520Snw141292 execsql { 286*4520Snw141292 DELETE FROM t1; 287*4520Snw141292 INSERT INTO t1 VALUES (1,1); 288*4520Snw141292 INSERT INTO t1 VALUES (1,2); 289*4520Snw141292 INSERT INTO t1 VALUES (1,3); 290*4520Snw141292 INSERT INTO t1 VALUES (1,4); 291*4520Snw141292 INSERT INTO t1 VALUES (1,5); 292*4520Snw141292 INSERT INTO t1 VALUES (1,6); 293*4520Snw141292 INSERT INTO t1 VALUES (1,7); 294*4520Snw141292 INSERT INTO t1 VALUES (1,8); 295*4520Snw141292 INSERT INTO t1 VALUES (1,9); 296*4520Snw141292 INSERT INTO t1 VALUES (2,0); 297*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 298*4520Snw141292 } 299*4520Snw141292} {1 2 3 4 5 6 7 8 9} 300*4520Snw141292do_test index-10.5 { 301*4520Snw141292 execsql { 302*4520Snw141292 DELETE FROM t1 WHERE b IN (2, 4, 6, 8); 303*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 304*4520Snw141292 } 305*4520Snw141292} {1 3 5 7 9} 306*4520Snw141292do_test index-10.6 { 307*4520Snw141292 execsql { 308*4520Snw141292 DELETE FROM t1 WHERE b>2; 309*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 310*4520Snw141292 } 311*4520Snw141292} {1} 312*4520Snw141292do_test index-10.7 { 313*4520Snw141292 execsql { 314*4520Snw141292 DELETE FROM t1 WHERE b=1; 315*4520Snw141292 SELECT b FROM t1 WHERE a=1 ORDER BY b; 316*4520Snw141292 } 317*4520Snw141292} {} 318*4520Snw141292do_test index-10.8 { 319*4520Snw141292 execsql { 320*4520Snw141292 SELECT b FROM t1 ORDER BY b; 321*4520Snw141292 } 322*4520Snw141292} {0} 323*4520Snw141292integrity_check index-10.9 324*4520Snw141292 325*4520Snw141292# Automatically create an index when we specify a primary key. 326*4520Snw141292# 327*4520Snw141292do_test index-11.1 { 328*4520Snw141292 execsql { 329*4520Snw141292 CREATE TABLE t3( 330*4520Snw141292 a text, 331*4520Snw141292 b int, 332*4520Snw141292 c float, 333*4520Snw141292 PRIMARY KEY(b) 334*4520Snw141292 ); 335*4520Snw141292 } 336*4520Snw141292 for {set i 1} {$i<=50} {incr i} { 337*4520Snw141292 execsql "INSERT INTO t3 VALUES('x${i}x',$i,0.$i)" 338*4520Snw141292 } 339*4520Snw141292 set sqlite_search_count 0 340*4520Snw141292 concat [execsql {SELECT c FROM t3 WHERE b==10}] $sqlite_search_count 341*4520Snw141292} {0.10 3} 342*4520Snw141292integrity_check index-11.2 343*4520Snw141292 344*4520Snw141292 345*4520Snw141292# Numeric strings should compare as if they were numbers. So even if the 346*4520Snw141292# strings are not character-by-character the same, if they represent the 347*4520Snw141292# same number they should compare equal to one another. Verify that this 348*4520Snw141292# is true in indices. 349*4520Snw141292# 350*4520Snw141292do_test index-12.1 { 351*4520Snw141292 execsql { 352*4520Snw141292 CREATE TABLE t4(a,b); 353*4520Snw141292 INSERT INTO t4 VALUES('0.0',1); 354*4520Snw141292 INSERT INTO t4 VALUES('0.00',2); 355*4520Snw141292 INSERT INTO t4 VALUES('abc',3); 356*4520Snw141292 INSERT INTO t4 VALUES('-1.0',4); 357*4520Snw141292 INSERT INTO t4 VALUES('+1.0',5); 358*4520Snw141292 INSERT INTO t4 VALUES('0',6); 359*4520Snw141292 INSERT INTO t4 VALUES('00000',7); 360*4520Snw141292 SELECT a FROM t4 ORDER BY b; 361*4520Snw141292 } 362*4520Snw141292} {0.0 0.00 abc -1.0 +1.0 0 00000} 363*4520Snw141292do_test index-12.2 { 364*4520Snw141292 execsql { 365*4520Snw141292 SELECT a FROM t4 WHERE a==0 ORDER BY b 366*4520Snw141292 } 367*4520Snw141292} {0.0 0.00 0 00000} 368*4520Snw141292do_test index-12.3 { 369*4520Snw141292 execsql { 370*4520Snw141292 SELECT a FROM t4 WHERE a<0.5 ORDER BY b 371*4520Snw141292 } 372*4520Snw141292} {0.0 0.00 -1.0 0 00000} 373*4520Snw141292do_test index-12.4 { 374*4520Snw141292 execsql { 375*4520Snw141292 SELECT a FROM t4 WHERE a>-0.5 ORDER BY b 376*4520Snw141292 } 377*4520Snw141292} {0.0 0.00 abc +1.0 0 00000} 378*4520Snw141292do_test index-12.5 { 379*4520Snw141292 execsql { 380*4520Snw141292 CREATE INDEX t4i1 ON t4(a); 381*4520Snw141292 SELECT a FROM t4 WHERE a==0 ORDER BY b 382*4520Snw141292 } 383*4520Snw141292} {0.0 0.00 0 00000} 384*4520Snw141292do_test index-12.6 { 385*4520Snw141292 execsql { 386*4520Snw141292 SELECT a FROM t4 WHERE a<0.5 ORDER BY b 387*4520Snw141292 } 388*4520Snw141292} {0.0 0.00 -1.0 0 00000} 389*4520Snw141292do_test index-12.7 { 390*4520Snw141292 execsql { 391*4520Snw141292 SELECT a FROM t4 WHERE a>-0.5 ORDER BY b 392*4520Snw141292 } 393*4520Snw141292} {0.0 0.00 abc +1.0 0 00000} 394*4520Snw141292integrity_check index-12.8 395*4520Snw141292 396*4520Snw141292# Make sure we cannot drop an automatically created index. 397*4520Snw141292# 398*4520Snw141292do_test index-13.1 { 399*4520Snw141292 execsql { 400*4520Snw141292 CREATE TABLE t5( 401*4520Snw141292 a int UNIQUE, 402*4520Snw141292 b float PRIMARY KEY, 403*4520Snw141292 c varchar(10), 404*4520Snw141292 UNIQUE(a,c) 405*4520Snw141292 ); 406*4520Snw141292 INSERT INTO t5 VALUES(1,2,3); 407*4520Snw141292 SELECT * FROM t5; 408*4520Snw141292 } 409*4520Snw141292} {1 2 3} 410*4520Snw141292do_test index-13.2 { 411*4520Snw141292 set ::idxlist [execsql { 412*4520Snw141292 SELECT name FROM sqlite_master WHERE type="index" AND tbl_name="t5"; 413*4520Snw141292 }] 414*4520Snw141292 llength $::idxlist 415*4520Snw141292} {3} 416*4520Snw141292for {set i 0} {$i<[llength $::idxlist]} {incr i} { 417*4520Snw141292 do_test index-13.3.$i { 418*4520Snw141292 catchsql " 419*4520Snw141292 DROP INDEX '[lindex $::idxlist $i]'; 420*4520Snw141292 " 421*4520Snw141292 } {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}} 422*4520Snw141292} 423*4520Snw141292do_test index-13.4 { 424*4520Snw141292 execsql { 425*4520Snw141292 INSERT INTO t5 VALUES('a','b','c'); 426*4520Snw141292 SELECT * FROM t5; 427*4520Snw141292 } 428*4520Snw141292} {1 2 3 a b c} 429*4520Snw141292integrity_check index-13.5 430*4520Snw141292 431*4520Snw141292# Check the sort order of data in an index. 432*4520Snw141292# 433*4520Snw141292do_test index-14.1 { 434*4520Snw141292 execsql { 435*4520Snw141292 CREATE TABLE t6(a,b,c); 436*4520Snw141292 CREATE INDEX t6i1 ON t6(a,b); 437*4520Snw141292 INSERT INTO t6 VALUES('','',1); 438*4520Snw141292 INSERT INTO t6 VALUES('',NULL,2); 439*4520Snw141292 INSERT INTO t6 VALUES(NULL,'',3); 440*4520Snw141292 INSERT INTO t6 VALUES('abc',123,4); 441*4520Snw141292 INSERT INTO t6 VALUES(123,'abc',5); 442*4520Snw141292 SELECT c FROM t6 ORDER BY a,b; 443*4520Snw141292 } 444*4520Snw141292} {3 5 2 1 4} 445*4520Snw141292do_test index-14.2 { 446*4520Snw141292 execsql { 447*4520Snw141292 SELECT c FROM t6 WHERE a=''; 448*4520Snw141292 } 449*4520Snw141292} {2 1} 450*4520Snw141292do_test index-14.3 { 451*4520Snw141292 execsql { 452*4520Snw141292 SELECT c FROM t6 WHERE b=''; 453*4520Snw141292 } 454*4520Snw141292} {1 3} 455*4520Snw141292do_test index-14.4 { 456*4520Snw141292 execsql { 457*4520Snw141292 SELECT c FROM t6 WHERE a>''; 458*4520Snw141292 } 459*4520Snw141292} {4} 460*4520Snw141292do_test index-14.5 { 461*4520Snw141292 execsql { 462*4520Snw141292 SELECT c FROM t6 WHERE a>=''; 463*4520Snw141292 } 464*4520Snw141292} {2 1 4} 465*4520Snw141292do_test index-14.6 { 466*4520Snw141292 execsql { 467*4520Snw141292 SELECT c FROM t6 WHERE a>123; 468*4520Snw141292 } 469*4520Snw141292} {2 1 4} 470*4520Snw141292do_test index-14.7 { 471*4520Snw141292 execsql { 472*4520Snw141292 SELECT c FROM t6 WHERE a>=123; 473*4520Snw141292 } 474*4520Snw141292} {5 2 1 4} 475*4520Snw141292do_test index-14.8 { 476*4520Snw141292 execsql { 477*4520Snw141292 SELECT c FROM t6 WHERE a<'abc'; 478*4520Snw141292 } 479*4520Snw141292} {5 2 1} 480*4520Snw141292do_test index-14.9 { 481*4520Snw141292 execsql { 482*4520Snw141292 SELECT c FROM t6 WHERE a<='abc'; 483*4520Snw141292 } 484*4520Snw141292} {5 2 1 4} 485*4520Snw141292do_test index-14.10 { 486*4520Snw141292 execsql { 487*4520Snw141292 SELECT c FROM t6 WHERE a<=''; 488*4520Snw141292 } 489*4520Snw141292} {5 2 1} 490*4520Snw141292do_test index-14.11 { 491*4520Snw141292 execsql { 492*4520Snw141292 SELECT c FROM t6 WHERE a<''; 493*4520Snw141292 } 494*4520Snw141292} {5} 495*4520Snw141292integrity_check index-14.12 496*4520Snw141292 497*4520Snw141292do_test index-15.1 { 498*4520Snw141292 execsql { 499*4520Snw141292 DELETE FROM t1; 500*4520Snw141292 SELECT * FROM t1; 501*4520Snw141292 } 502*4520Snw141292} {} 503*4520Snw141292do_test index-15.2 { 504*4520Snw141292 execsql { 505*4520Snw141292 INSERT INTO t1 VALUES('1.234e5',1); 506*4520Snw141292 INSERT INTO t1 VALUES('12.33e04',2); 507*4520Snw141292 INSERT INTO t1 VALUES('12.35E4',3); 508*4520Snw141292 INSERT INTO t1 VALUES('12.34e',4); 509*4520Snw141292 INSERT INTO t1 VALUES('12.32e+4',5); 510*4520Snw141292 INSERT INTO t1 VALUES('12.36E+04',6); 511*4520Snw141292 INSERT INTO t1 VALUES('12.36E+',7); 512*4520Snw141292 INSERT INTO t1 VALUES('+123.10000E+0003',8); 513*4520Snw141292 INSERT INTO t1 VALUES('+',9); 514*4520Snw141292 INSERT INTO t1 VALUES('+12347.E+02',10); 515*4520Snw141292 INSERT INTO t1 VALUES('+12347E+02',11); 516*4520Snw141292 SELECT b FROM t1 ORDER BY a; 517*4520Snw141292 } 518*4520Snw141292} {8 5 2 1 3 6 11 9 10 4 7} 519*4520Snw141292integrity_check index-15.1 520*4520Snw141292 521*4520Snw141292# Drop index with a quoted name. Ticket #695. 522*4520Snw141292# 523*4520Snw141292do_test index-16.1 { 524*4520Snw141292 execsql { 525*4520Snw141292 CREATE INDEX "t6i2" ON t6(c); 526*4520Snw141292 DROP INDEX "t6i2"; 527*4520Snw141292 } 528*4520Snw141292} {} 529*4520Snw141292do_test index-16.2 { 530*4520Snw141292 execsql { 531*4520Snw141292 DROP INDEX "t6i1"; 532*4520Snw141292 } 533*4520Snw141292} {} 534*4520Snw141292 535*4520Snw141292 536*4520Snw141292finish_test 537