drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 1 | # Copyright (c) 1999, 2000 D. Richard Hipp |
| 2 | # |
| 3 | # This program is free software; you can redistribute it and/or |
| 4 | # modify it under the terms of the GNU General Public |
| 5 | # License as published by the Free Software Foundation; either |
| 6 | # version 2 of the License, or (at your option) any later version. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | # General Public License for more details. |
| 12 | # |
| 13 | # You should have received a copy of the GNU General Public |
| 14 | # License along with this library; if not, write to the |
| 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | # Boston, MA 02111-1307, USA. |
| 17 | # |
| 18 | # Author contact information: |
| 19 | # drh@hwaci.com |
| 20 | # http://www.hwaci.com/drh/ |
| 21 | # |
| 22 | #*********************************************************************** |
| 23 | # This file implements regression tests for SQLite library. The |
| 24 | # focus of this file is testing the CREATE INDEX statement. |
| 25 | # |
drh | 767c200 | 2000-10-19 14:10:08 +0000 | [diff] [blame^] | 26 | # $Id: index.test,v 1.8 2000/10/19 14:10:09 drh Exp $ |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 27 | |
| 28 | set testdir [file dirname $argv0] |
| 29 | source $testdir/tester.tcl |
| 30 | |
| 31 | # Create a basic index and verify it is added to sqlite_master |
| 32 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 33 | do_test index-1.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 34 | execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)} |
| 35 | execsql {CREATE INDEX index1 ON test1(f1)} |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 36 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 37 | } {index1 test1} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 38 | do_test index-1.1b { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 39 | execsql {SELECT name, sql, tbl_name, type FROM sqlite_master |
| 40 | WHERE name='index1'} |
| 41 | } {index1 {CREATE INDEX index1 ON test1(f1)} test1 index} |
drh | 767c200 | 2000-10-19 14:10:08 +0000 | [diff] [blame^] | 42 | skipif memory: |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 43 | do_test index-1.1c { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 44 | db close |
| 45 | sqlite db testdb |
| 46 | execsql {SELECT name, sql, tbl_name, type FROM sqlite_master |
| 47 | WHERE name='index1'} |
| 48 | } {index1 {CREATE INDEX index1 ON test1(f1)} test1 index} |
drh | 767c200 | 2000-10-19 14:10:08 +0000 | [diff] [blame^] | 49 | skipif memory: |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 50 | do_test index-1.1d { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 51 | db close |
| 52 | sqlite db testdb |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 53 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 54 | } {index1 test1} |
| 55 | |
| 56 | # Verify that the index dies with the table |
| 57 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 58 | do_test index-1.2 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 59 | execsql {DROP TABLE test1} |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 60 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 61 | } {} |
| 62 | |
| 63 | # Try adding an index to a table that does not exist |
| 64 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 65 | do_test index-2.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 66 | set v [catch {execsql {CREATE INDEX index1 ON test1(f1)}} msg] |
| 67 | lappend v $msg |
| 68 | } {1 {no such table: test1}} |
| 69 | |
drh | 1ccde15 | 2000-06-17 13:12:39 +0000 | [diff] [blame] | 70 | # Try adding an index on a column of a table where the table |
| 71 | # exists but the column does not. |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 72 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 73 | do_test index-2.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 74 | execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)} |
| 75 | set v [catch {execsql {CREATE INDEX index1 ON test1(f4)}} msg] |
| 76 | lappend v $msg |
drh | 1ccde15 | 2000-06-17 13:12:39 +0000 | [diff] [blame] | 77 | } {1 {table test1 has no column named f4}} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 78 | |
drh | 1ccde15 | 2000-06-17 13:12:39 +0000 | [diff] [blame] | 79 | # Try an index with some columns that match and others that do now. |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 80 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 81 | do_test index-2.2 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 82 | set v [catch {execsql {CREATE INDEX index1 ON test1(f1, f2, f4, f3)}} msg] |
| 83 | execsql {DROP TABLE test1} |
| 84 | lappend v $msg |
drh | 1ccde15 | 2000-06-17 13:12:39 +0000 | [diff] [blame] | 85 | } {1 {table test1 has no column named f4}} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 86 | |
| 87 | # Try creating a bunch of indices on the same table |
| 88 | # |
| 89 | set r {} |
| 90 | for {set i 1} {$i<100} {incr i} { |
| 91 | lappend r index$i |
| 92 | } |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 93 | do_test index-3.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 94 | execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)} |
| 95 | for {set i 1} {$i<100} {incr i} { |
| 96 | set sql "CREATE INDEX index$i ON test1(f[expr {($i%5)+1}])" |
| 97 | execsql $sql |
| 98 | } |
| 99 | execsql {SELECT name FROM sqlite_master |
| 100 | WHERE type='index' AND tbl_name='test1' |
| 101 | ORDER BY name} |
| 102 | } $r |
| 103 | |
| 104 | # Add a single entry to the table. Verify that files are created |
| 105 | # for every index. |
| 106 | # |
| 107 | set r {} |
| 108 | for {set i 1} {$i<100} {incr i} { |
| 109 | lappend r testdb/index$i.tbl |
| 110 | } |
drh | 767c200 | 2000-10-19 14:10:08 +0000 | [diff] [blame^] | 111 | skipif memory: |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 112 | do_test index-3.2 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 113 | execsql {INSERT INTO test1 VALUES(1,2,3,4,5)} |
| 114 | lsort -dictionary [glob testdb/index*.tbl] |
| 115 | } $r |
| 116 | |
| 117 | # Verify that all the indices go away when we drop the table. |
| 118 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 119 | do_test index-3.3 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 120 | execsql {DROP TABLE test1} |
| 121 | execsql {SELECT name FROM sqlite_master |
| 122 | WHERE type='index' AND tbl_name='test1' |
| 123 | ORDER BY name} |
| 124 | } {} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 125 | do_test index-3.4 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 126 | lsort -dictionary [glob -nocomplain testdb/index*.tbl] |
| 127 | } {} |
| 128 | |
| 129 | # Create a table and insert values into that table. Then create |
| 130 | # an index on that table. Verify that we can select values |
| 131 | # from the table correctly using the index. |
| 132 | # |
drh | 7020f65 | 2000-06-03 18:06:52 +0000 | [diff] [blame] | 133 | # Note that the index names "index9" and "indext" are chosen because |
| 134 | # they both have the same hash. |
| 135 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 136 | do_test index-4.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 137 | execsql {CREATE TABLE test1(cnt int, power int)} |
| 138 | for {set i 1} {$i<20} {incr i} { |
| 139 | execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])" |
| 140 | } |
drh | 7020f65 | 2000-06-03 18:06:52 +0000 | [diff] [blame] | 141 | execsql {CREATE INDEX index9 ON test1(cnt)} |
| 142 | execsql {CREATE INDEX indext ON test1(power)} |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 143 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | 7020f65 | 2000-06-03 18:06:52 +0000 | [diff] [blame] | 144 | } {index9 indext test1} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 145 | do_test index-4.2 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 146 | execsql {SELECT cnt FROM test1 WHERE power=4} |
| 147 | } {2} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 148 | do_test index-4.3 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 149 | execsql {SELECT cnt FROM test1 WHERE power=1024} |
| 150 | } {10} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 151 | do_test index-4.4 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 152 | execsql {SELECT power FROM test1 WHERE cnt=6} |
| 153 | } {64} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 154 | do_test index-4.5 { |
drh | 7020f65 | 2000-06-03 18:06:52 +0000 | [diff] [blame] | 155 | execsql {DROP INDEX indext} |
| 156 | execsql {SELECT power FROM test1 WHERE cnt=6} |
| 157 | } {64} |
| 158 | do_test index-4.6 { |
| 159 | execsql {SELECT cnt FROM test1 WHERE power=1024} |
| 160 | } {10} |
| 161 | do_test index-4.7 { |
| 162 | execsql {CREATE INDEX indext ON test1(cnt)} |
| 163 | execsql {SELECT power FROM test1 WHERE cnt=6} |
| 164 | } {64} |
| 165 | do_test index-4.8 { |
| 166 | execsql {SELECT cnt FROM test1 WHERE power=1024} |
| 167 | } {10} |
| 168 | do_test index-4.9 { |
| 169 | execsql {DROP INDEX index9} |
| 170 | execsql {SELECT power FROM test1 WHERE cnt=6} |
| 171 | } {64} |
| 172 | do_test index-4.10 { |
| 173 | execsql {SELECT cnt FROM test1 WHERE power=1024} |
| 174 | } {10} |
| 175 | do_test index-4.11 { |
| 176 | execsql {DROP INDEX indext} |
| 177 | execsql {SELECT power FROM test1 WHERE cnt=6} |
| 178 | } {64} |
| 179 | do_test index-4.12 { |
| 180 | execsql {SELECT cnt FROM test1 WHERE power=1024} |
| 181 | } {10} |
| 182 | do_test index-4.13 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 183 | execsql {DROP TABLE test1} |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 184 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 185 | } {} |
| 186 | |
| 187 | # Do not allow indices to be added to sqlite_master |
| 188 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 189 | do_test index-5.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 190 | set v [catch {execsql {CREATE INDEX index1 ON sqlite_master(name)}} msg] |
| 191 | lappend v $msg |
| 192 | } {1 {table sqlite_master may not have new indices added}} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 193 | do_test index-5.2 { |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 194 | execsql {SELECT name FROM sqlite_master WHERE type!='meta'} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 195 | } {} |
| 196 | |
| 197 | # Do not allow indices with duplicate names to be added |
| 198 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 199 | do_test index-6.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 200 | execsql {CREATE TABLE test1(f1 int, f2 int)} |
| 201 | execsql {CREATE TABLE test2(g1 real, g2 real)} |
| 202 | execsql {CREATE INDEX index1 ON test1(f1)} |
| 203 | set v [catch {execsql {CREATE INDEX index1 ON test2(g1)}} msg] |
| 204 | lappend v $msg |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 205 | } {1 {index index1 already exists}} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 206 | do_test index-6.1b { |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 207 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 208 | } {index1 test1 test2} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 209 | do_test index-6.2 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 210 | set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg] |
| 211 | lappend v $msg |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 212 | } {1 {there is already a table named test1}} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 213 | do_test index-6.2b { |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 214 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 215 | } {index1 test1 test2} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 216 | do_test index-6.3 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 217 | execsql {DROP TABLE test1} |
| 218 | execsql {DROP TABLE test2} |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 219 | execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 220 | } {} |
| 221 | |
| 222 | # Create a primary key |
| 223 | # |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 224 | do_test index-7.1 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 225 | execsql {CREATE TABLE test1(f1 int, f2 int primary key)} |
| 226 | for {set i 1} {$i<20} {incr i} { |
| 227 | execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])" |
| 228 | } |
drh | 767c200 | 2000-10-19 14:10:08 +0000 | [diff] [blame^] | 229 | execsql {SELECT count(*) FROM test1} |
| 230 | } {19} |
| 231 | skipif memory: |
| 232 | do_test index-7.1b { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 233 | lsort -dictionary [glob testdb/test1*.tbl] |
| 234 | } {testdb/test1.tbl testdb/test1__primary_key.tbl} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 235 | do_test index-7.2 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 236 | execsql {SELECT f1 FROM test1 WHERE f2=65536} |
| 237 | } {16} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 238 | do_test index-7.3 { |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 239 | set code [execsql {EXPLAIN SELECT f1 FROM test1 WHERE f2=65536}] |
| 240 | expr {[lsearch $code test1__primary_key]>0} |
| 241 | } {1} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 242 | do_test index-7.4 { |
| 243 | execsql {DROP table test1} |
drh | 2803757 | 2000-08-02 13:47:41 +0000 | [diff] [blame] | 244 | execsql {SELECT name FROM sqlite_master WHERE type!='meta'} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 245 | } {} |
| 246 | |
drh | 7020f65 | 2000-06-03 18:06:52 +0000 | [diff] [blame] | 247 | # Make sure we cannot drop a non-existant index. |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 248 | # |
| 249 | do_test index-8.1 { |
| 250 | set v [catch {execsql {DROP INDEX index1}} msg] |
| 251 | lappend v $msg |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 252 | } {1 {no such index: index1}} |
drh | 1b6a71f | 2000-05-29 23:58:11 +0000 | [diff] [blame] | 253 | |
drh | 7020f65 | 2000-06-03 18:06:52 +0000 | [diff] [blame] | 254 | # Make sure we don't actually create an index when the EXPLAIN keyword |
| 255 | # is used. |
| 256 | # |
| 257 | do_test index-9.1 { |
| 258 | execsql {CREATE TABLE tab1(a int)} |
| 259 | execsql {EXPLAIN CREATE INDEX idx1 ON tab1(a)} |
| 260 | execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1'} |
| 261 | } {tab1} |
| 262 | do_test index-9.2 { |
| 263 | execsql {CREATE INDEX idx1 ON tab1(a)} |
| 264 | execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name} |
| 265 | } {idx1 tab1} |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 266 | |
drh | e840972 | 2000-06-08 16:54:40 +0000 | [diff] [blame] | 267 | # Allow more than one entry with the same key. |
| 268 | # |
| 269 | do_test index-10.0 { |
| 270 | execsql { |
| 271 | CREATE TABLE t1(a int, b int); |
| 272 | CREATE INDEX i1 ON t1(a); |
| 273 | INSERT INTO t1 VALUES(1,2); |
| 274 | INSERT INTO t1 VALUES(2,4); |
| 275 | INSERT INTO t1 VALUES(3,8); |
| 276 | INSERT INTO t1 VALUES(1,12); |
| 277 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 278 | } |
| 279 | } {2 12} |
| 280 | do_test index-10.1 { |
| 281 | execsql { |
| 282 | SELECT b FROM t1 WHERE a=2 ORDER BY b; |
| 283 | } |
| 284 | } {4} |
| 285 | do_test index-10.2 { |
| 286 | execsql { |
| 287 | DELETE FROM t1 WHERE b=12; |
| 288 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 289 | } |
| 290 | } {2} |
drh | 353f57e | 2000-08-02 12:26:28 +0000 | [diff] [blame] | 291 | do_test index-10.3 { |
drh | e840972 | 2000-06-08 16:54:40 +0000 | [diff] [blame] | 292 | execsql { |
| 293 | DELETE FROM t1 WHERE b=2; |
| 294 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 295 | } |
| 296 | } {} |
drh | 353f57e | 2000-08-02 12:26:28 +0000 | [diff] [blame] | 297 | do_test index-10.4 { |
| 298 | execsql { |
| 299 | DELETE FROM t1; |
| 300 | INSERT INTO t1 VALUES (1,1); |
| 301 | INSERT INTO t1 VALUES (1,2); |
| 302 | INSERT INTO t1 VALUES (1,3); |
| 303 | INSERT INTO t1 VALUES (1,4); |
| 304 | INSERT INTO t1 VALUES (1,5); |
| 305 | INSERT INTO t1 VALUES (1,6); |
| 306 | INSERT INTO t1 VALUES (1,7); |
| 307 | INSERT INTO t1 VALUES (1,8); |
| 308 | INSERT INTO t1 VALUES (1,9); |
| 309 | INSERT INTO t1 VALUES (2,0); |
| 310 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 311 | } |
| 312 | } {1 2 3 4 5 6 7 8 9} |
| 313 | do_test index-10.5 { |
| 314 | execsql { |
| 315 | DELETE FROM t1 WHERE b IN (2, 4, 6, 8); |
| 316 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 317 | } |
| 318 | } {1 3 5 7 9} |
| 319 | do_test index-10.6 { |
| 320 | execsql { |
| 321 | DELETE FROM t1 WHERE b>2; |
| 322 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 323 | } |
| 324 | } {1} |
| 325 | do_test index-10.7 { |
| 326 | execsql { |
| 327 | DELETE FROM t1 WHERE b=1; |
| 328 | SELECT b FROM t1 WHERE a=1 ORDER BY b; |
| 329 | } |
| 330 | } {} |
| 331 | do_test index-10.8 { |
| 332 | execsql { |
| 333 | SELECT b FROM t1 ORDER BY b; |
| 334 | } |
| 335 | } {0} |
| 336 | |
drh | e840972 | 2000-06-08 16:54:40 +0000 | [diff] [blame] | 337 | |
drh | b24fcbe | 2000-05-29 23:30:50 +0000 | [diff] [blame] | 338 | finish_test |