drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame^] | 1 | # 2001 September 15 |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 2 | # |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame^] | 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 5 | # |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame^] | 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. |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 9 | # |
| 10 | #*********************************************************************** |
| 11 | # This file implements regression tests for SQLite library. The |
| 12 | # focus of this file is testing the UPDATE statement. |
| 13 | # |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame^] | 14 | # $Id: update.test,v 1.6 2001/09/16 00:13:28 drh Exp $ |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 15 | |
| 16 | set testdir [file dirname $argv0] |
| 17 | source $testdir/tester.tcl |
| 18 | |
| 19 | # Try to update an non-existent table |
| 20 | # |
| 21 | do_test update-1.1 { |
| 22 | set v [catch {execsql {UPDATE test1 SET f2=5 WHERE f1<1}} msg] |
| 23 | lappend v $msg |
| 24 | } {1 {no such table: test1}} |
| 25 | |
| 26 | # Try to update a read-only table |
| 27 | # |
| 28 | do_test update-2.1 { |
| 29 | set v [catch \ |
| 30 | {execsql {UPDATE sqlite_master SET name='xyz' WHERE name='123'}} msg] |
| 31 | lappend v $msg |
| 32 | } {1 {table sqlite_master may not be modified}} |
| 33 | |
| 34 | # Create a table to work with |
| 35 | # |
| 36 | do_test update-3.1 { |
| 37 | execsql {CREATE TABLE test1(f1 int,f2 int)} |
| 38 | for {set i 1} {$i<=10} {incr i} { |
| 39 | set sql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])" |
| 40 | execsql $sql |
| 41 | } |
| 42 | execsql {SELECT * FROM test1 ORDER BY f1} |
| 43 | } {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024} |
| 44 | |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 45 | # Unknown column name in an expression |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 46 | # |
| 47 | do_test update-3.2 { |
| 48 | set v [catch {execsql {UPDATE test1 SET f1=f3*2 WHERE f2==32}} msg] |
| 49 | lappend v $msg |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 50 | } {1 {no such column: f3}} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 51 | do_test update-3.3 { |
| 52 | set v [catch {execsql {UPDATE test1 SET f1=test2.f1*2 WHERE f2==32}} msg] |
| 53 | lappend v $msg |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 54 | } {1 {no such column: test2.f1}} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 55 | do_test update-3.4 { |
| 56 | set v [catch {execsql {UPDATE test1 SET f3=f1*2 WHERE f2==32}} msg] |
| 57 | lappend v $msg |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 58 | } {1 {no such column: f3}} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 59 | |
| 60 | # Actually do some updates |
| 61 | # |
| 62 | do_test update-3.5 { |
| 63 | execsql {UPDATE test1 SET f2=f2*3} |
| 64 | execsql {SELECT * FROM test1 ORDER BY f1} |
| 65 | } {1 6 2 12 3 24 4 48 5 96 6 192 7 384 8 768 9 1536 10 3072} |
| 66 | do_test update-3.6 { |
| 67 | execsql {UPDATE test1 SET f2=f2/3 WHERE f1<=5} |
| 68 | execsql {SELECT * FROM test1 ORDER BY f1} |
| 69 | } {1 2 2 4 3 8 4 16 5 32 6 192 7 384 8 768 9 1536 10 3072} |
| 70 | do_test update-3.7 { |
| 71 | execsql {UPDATE test1 SET f2=f2/3 WHERE f1>5} |
| 72 | execsql {SELECT * FROM test1 ORDER BY f1} |
| 73 | } {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024} |
| 74 | |
| 75 | # Swap the values of f1 and f2 for all elements |
| 76 | # |
| 77 | do_test update-3.8 { |
drh | 6206d50 | 2000-06-19 19:09:08 +0000 | [diff] [blame] | 78 | execsql {UPDATE test1 SET F2=f1, F1=f2} |
| 79 | execsql {SELECT * FROM test1 ORDER BY F1} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 80 | } {2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1024 10} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 81 | do_test update-3.9 { |
drh | 4f3c63e | 2001-02-19 18:24:21 +0000 | [diff] [blame] | 82 | execsql {UPDATE test1 SET F2=f1, F1=f2} |
| 83 | execsql {SELECT * FROM test1 ORDER BY F1} |
| 84 | } {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024} |
| 85 | |
| 86 | # Create duplicate entries and make sure updating still |
| 87 | # works. |
| 88 | # |
| 89 | do_test update-4.0 { |
| 90 | execsql { |
| 91 | DELETE FROM test1 WHERE f1<=5; |
| 92 | INSERT INTO test1(f1,f2) VALUES(8,88); |
| 93 | INSERT INTO test1(f1,f2) VALUES(8,888); |
| 94 | INSERT INTO test1(f1,f2) VALUES(77,128); |
| 95 | INSERT INTO test1(f1,f2) VALUES(777,128); |
| 96 | } |
| 97 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 98 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 99 | do_test update-4.1 { |
| 100 | execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8} |
| 101 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 102 | } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128} |
| 103 | do_test update-4.2 { |
| 104 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800} |
| 105 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 106 | } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128} |
| 107 | do_test update-4.3 { |
| 108 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800} |
| 109 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 110 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 111 | do_test update-4.4 { |
| 112 | execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128} |
| 113 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 114 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128} |
| 115 | do_test update-4.5 { |
| 116 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128} |
| 117 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 118 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128} |
| 119 | do_test update-4.6 { |
| 120 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128} |
| 121 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 122 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 123 | |
| 124 | # Repeat the previous sequence of tests with an index. |
| 125 | # |
| 126 | do_test update-5.0 { |
| 127 | execsql {CREATE INDEX idx1 ON test1(f1)} |
| 128 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 129 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 130 | do_test update-5.1 { |
| 131 | execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8} |
| 132 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 133 | } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128} |
| 134 | do_test update-5.2 { |
| 135 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800} |
| 136 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 137 | } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128} |
| 138 | do_test update-5.3 { |
| 139 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800} |
| 140 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 141 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 142 | do_test update-5.4 { |
| 143 | execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128} |
| 144 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 145 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128} |
| 146 | do_test update-5.4.1 { |
| 147 | execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2} |
| 148 | } {78 128} |
| 149 | do_test update-5.4.2 { |
| 150 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 151 | } {778 128} |
| 152 | do_test update-5.4.3 { |
| 153 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 154 | } {8 88 8 128 8 256 8 888} |
| 155 | do_test update-5.5 { |
| 156 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128} |
| 157 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 158 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128} |
| 159 | do_test update-5.5.1 { |
| 160 | execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2} |
| 161 | } {78 128} |
| 162 | do_test update-5.5.2 { |
| 163 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 164 | } {} |
| 165 | do_test update-5.5.3 { |
| 166 | execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2} |
| 167 | } {777 128} |
| 168 | do_test update-5.5.4 { |
| 169 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 170 | } {8 88 8 128 8 256 8 888} |
| 171 | do_test update-5.6 { |
| 172 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128} |
| 173 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 174 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 175 | do_test update-5.6.1 { |
| 176 | execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2} |
| 177 | } {77 128} |
| 178 | do_test update-5.6.2 { |
| 179 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 180 | } {} |
| 181 | do_test update-5.6.3 { |
| 182 | execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2} |
| 183 | } {777 128} |
| 184 | do_test update-5.6.4 { |
| 185 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 186 | } {8 88 8 256 8 888} |
| 187 | |
| 188 | # Repeat the previous sequence of tests with a different index. |
| 189 | # |
| 190 | do_test update-6.0 { |
| 191 | execsql {DROP INDEX idx1} |
| 192 | execsql {CREATE INDEX idx1 ON test1(f2)} |
| 193 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 194 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 195 | do_test update-6.1 { |
| 196 | execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8} |
| 197 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 198 | } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128} |
| 199 | do_test update-6.1.1 { |
| 200 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 201 | } {8 89 8 257 8 889} |
| 202 | do_test update-6.1.2 { |
| 203 | execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2} |
| 204 | } {8 89} |
| 205 | do_test update-6.1.3 { |
| 206 | execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2} |
| 207 | } {} |
| 208 | do_test update-6.2 { |
| 209 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800} |
| 210 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 211 | } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128} |
| 212 | do_test update-6.3 { |
| 213 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800} |
| 214 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 215 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 216 | do_test update-6.3.1 { |
| 217 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 218 | } {8 88 8 256 8 888} |
| 219 | do_test update-6.3.2 { |
| 220 | execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2} |
| 221 | } {} |
| 222 | do_test update-6.3.3 { |
| 223 | execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2} |
| 224 | } {8 88} |
| 225 | do_test update-6.4 { |
| 226 | execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128} |
| 227 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 228 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128} |
| 229 | do_test update-6.4.1 { |
| 230 | execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2} |
| 231 | } {78 128} |
| 232 | do_test update-6.4.2 { |
| 233 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 234 | } {778 128} |
| 235 | do_test update-6.4.3 { |
| 236 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 237 | } {8 88 8 128 8 256 8 888} |
| 238 | do_test update-6.5 { |
| 239 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128} |
| 240 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 241 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128} |
| 242 | do_test update-6.5.1 { |
| 243 | execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2} |
| 244 | } {78 128} |
| 245 | do_test update-6.5.2 { |
| 246 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 247 | } {} |
| 248 | do_test update-6.5.3 { |
| 249 | execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2} |
| 250 | } {777 128} |
| 251 | do_test update-6.5.4 { |
| 252 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 253 | } {8 88 8 128 8 256 8 888} |
| 254 | do_test update-6.6 { |
| 255 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128} |
| 256 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 257 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 258 | do_test update-6.6.1 { |
| 259 | execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2} |
| 260 | } {77 128} |
| 261 | do_test update-6.6.2 { |
| 262 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 263 | } {} |
| 264 | do_test update-6.6.3 { |
| 265 | execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2} |
| 266 | } {777 128} |
| 267 | do_test update-6.6.4 { |
| 268 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 269 | } {8 88 8 256 8 888} |
| 270 | |
| 271 | # Repeat the previous sequence of tests with multiple |
| 272 | # indices |
| 273 | # |
| 274 | do_test update-7.0 { |
| 275 | execsql {CREATE INDEX idx2 ON test1(f2)} |
| 276 | execsql {CREATE INDEX idx3 ON test1(f1,f2)} |
| 277 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 278 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 279 | do_test update-7.1 { |
| 280 | execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8} |
| 281 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 282 | } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128} |
| 283 | do_test update-7.1.1 { |
| 284 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 285 | } {8 89 8 257 8 889} |
| 286 | do_test update-7.1.2 { |
| 287 | execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2} |
| 288 | } {8 89} |
| 289 | do_test update-7.1.3 { |
| 290 | execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2} |
| 291 | } {} |
| 292 | do_test update-7.2 { |
| 293 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800} |
| 294 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 295 | } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128} |
| 296 | do_test update-7.3 { |
| 297 | execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800} |
| 298 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 299 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 300 | do_test update-7.3.1 { |
| 301 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 302 | } {8 88 8 256 8 888} |
| 303 | do_test update-7.3.2 { |
| 304 | execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2} |
| 305 | } {} |
| 306 | do_test update-7.3.3 { |
| 307 | execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2} |
| 308 | } {8 88} |
| 309 | do_test update-7.4 { |
| 310 | execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128} |
| 311 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 312 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128} |
| 313 | do_test update-7.4.1 { |
| 314 | execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2} |
| 315 | } {78 128} |
| 316 | do_test update-7.4.2 { |
| 317 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 318 | } {778 128} |
| 319 | do_test update-7.4.3 { |
| 320 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 321 | } {8 88 8 128 8 256 8 888} |
| 322 | do_test update-7.5 { |
| 323 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128} |
| 324 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 325 | } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128} |
| 326 | do_test update-7.5.1 { |
| 327 | execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2} |
| 328 | } {78 128} |
| 329 | do_test update-7.5.2 { |
| 330 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 331 | } {} |
| 332 | do_test update-7.5.3 { |
| 333 | execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2} |
| 334 | } {777 128} |
| 335 | do_test update-7.5.4 { |
| 336 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 337 | } {8 88 8 128 8 256 8 888} |
| 338 | do_test update-7.6 { |
| 339 | execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128} |
| 340 | execsql {SELECT * FROM test1 ORDER BY f1,f2} |
| 341 | } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128} |
| 342 | do_test update-7.6.1 { |
| 343 | execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2} |
| 344 | } {77 128} |
| 345 | do_test update-7.6.2 { |
| 346 | execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2} |
| 347 | } {} |
| 348 | do_test update-7.6.3 { |
| 349 | execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2} |
| 350 | } {777 128} |
| 351 | do_test update-7.6.4 { |
| 352 | execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2} |
| 353 | } {8 88 8 256 8 888} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 354 | |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 355 | # Error messages |
| 356 | # |
drh | 4f3c63e | 2001-02-19 18:24:21 +0000 | [diff] [blame] | 357 | do_test update-9.1 { |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 358 | set v [catch {execsql { |
| 359 | UPDATE test1 SET x=11 WHERE f1=1025 |
| 360 | }} msg] |
| 361 | lappend v $msg |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 362 | } {1 {no such column: x}} |
drh | 4f3c63e | 2001-02-19 18:24:21 +0000 | [diff] [blame] | 363 | do_test update-9.2 { |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 364 | set v [catch {execsql { |
| 365 | UPDATE test1 SET f1=x(11) WHERE f1=1025 |
| 366 | }} msg] |
| 367 | lappend v $msg |
| 368 | } {1 {no such function: x}} |
drh | 4f3c63e | 2001-02-19 18:24:21 +0000 | [diff] [blame] | 369 | do_test update-9.3 { |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 370 | set v [catch {execsql { |
| 371 | UPDATE test1 SET f1=11 WHERE x=1025 |
| 372 | }} msg] |
| 373 | lappend v $msg |
drh | 967e8b7 | 2000-06-21 13:59:10 +0000 | [diff] [blame] | 374 | } {1 {no such column: x}} |
drh | 4f3c63e | 2001-02-19 18:24:21 +0000 | [diff] [blame] | 375 | do_test update-9.4 { |
drh | c837e70 | 2000-06-08 16:26:24 +0000 | [diff] [blame] | 376 | set v [catch {execsql { |
| 377 | UPDATE test1 SET f1=11 WHERE x(f1)=1025 |
| 378 | }} msg] |
| 379 | lappend v $msg |
| 380 | } {1 {no such function: x}} |
drh | 1d37e28 | 2000-05-30 03:12:21 +0000 | [diff] [blame] | 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | finish_test |