OLD | NEW |
1 # 2012 July 12 | 1 # 2012 July 12 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } {keener {} | 276 } {keener {} |
277 {SELECT word, rank, NULL, langid, id FROM "main"."t3_vocab" WHERE rowid=?} | 277 {SELECT word, rank, NULL, langid, id FROM "main"."t3_vocab" WHERE rowid=?} |
278 } | 278 } |
279 do_tracesql_test 6.2.3 { | 279 do_tracesql_test 6.2.3 { |
280 SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner'; | 280 SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner'; |
281 } {keener 300 | 281 } {keener 300 |
282 {SELECT id, word, rank, k1 FROM "main"."t3_vocab" WHERE langid=0 AND k2>=?1
AND k2<?2} | 282 {SELECT id, word, rank, k1 FROM "main"."t3_vocab" WHERE langid=0 AND k2>=?1
AND k2<?2} |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
| 286 #------------------------------------------------------------------------- |
| 287 # Test that the spellfix1 table supports conflict handling (OR REPLACE |
| 288 # and so on). |
| 289 # |
| 290 do_execsql_test 7.1 { |
| 291 CREATE VIRTUAL TABLE t4 USING spellfix1; |
| 292 PRAGMA table_info = t4; |
| 293 } { |
| 294 0 word {} 0 {} 0 |
| 295 1 rank {} 0 {} 0 |
| 296 2 distance {} 0 {} 0 |
| 297 3 langid {} 0 {} 0 |
| 298 4 score {} 0 {} 0 |
| 299 5 matchlen {} 0 {} 0 |
| 300 } |
286 | 301 |
| 302 do_execsql_test 7.2.1 { |
| 303 INSERT INTO t4(rowid, word) VALUES(1, 'Archilles'); |
| 304 INSERT INTO t4(rowid, word) VALUES(2, 'Pluto'); |
| 305 INSERT INTO t4(rowid, word) VALUES(3, 'Atrides'); |
| 306 INSERT OR REPLACE INTO t4(rowid, word) VALUES(2, 'Apollo'); |
| 307 SELECT rowid, word FROM t4; |
| 308 } { |
| 309 1 Archilles 2 Apollo 3 Atrides |
| 310 } |
| 311 do_catchsql_test 7.2.2 { |
| 312 INSERT OR ABORT INTO t4(rowid, word) VALUES(1, 'Leto'); |
| 313 } {1 {constraint failed}} |
| 314 do_catchsql_test 7.2.3 { |
| 315 INSERT OR ROLLBACK INTO t4(rowid, word) VALUES(3, 'Zeus'); |
| 316 } {1 {constraint failed}} |
| 317 do_catchsql_test 7.2.4 { |
| 318 INSERT OR FAIL INTO t4(rowid, word) VALUES(3, 'Zeus'); |
| 319 } {1 {constraint failed}} |
| 320 do_execsql_test 7.2.5 { |
| 321 INSERT OR IGNORE INTO t4(rowid, word) VALUES(3, 'Zeus'); |
| 322 SELECT rowid, word FROM t4; |
| 323 } { |
| 324 1 Archilles 2 Apollo 3 Atrides |
| 325 } |
287 | 326 |
| 327 do_execsql_test 7.3.1 { |
| 328 UPDATE OR REPLACE t4 SET rowid=3 WHERE rowid=1; |
| 329 SELECT rowid, word FROM t4; |
| 330 } {2 Apollo 3 Archilles} |
| 331 do_catchsql_test 7.3.2 { |
| 332 UPDATE OR ABORT t4 SET rowid=3 WHERE rowid=2; |
| 333 } {1 {constraint failed}} |
| 334 do_catchsql_test 7.3.3 { |
| 335 UPDATE OR ROLLBACK t4 SET rowid=3 WHERE rowid=2; |
| 336 } {1 {constraint failed}} |
| 337 do_catchsql_test 7.3.4 { |
| 338 UPDATE OR FAIL t4 SET rowid=3 WHERE rowid=2; |
| 339 } {1 {constraint failed}} |
| 340 do_execsql_test 7.3.5 { |
| 341 UPDATE OR IGNORE t4 SET rowid=3 WHERE rowid=2; |
| 342 SELECT rowid, word FROM t4; |
| 343 } {2 Apollo 3 Archilles} |
| 344 |
| 345 do_execsql_test 7.4.1 { |
| 346 DELETE FROM t4; |
| 347 INSERT INTO t4(rowid, word) VALUES(10, 'Agamemnon'); |
| 348 INSERT INTO t4(rowid, word) VALUES(20, 'Patroclus'); |
| 349 INSERT INTO t4(rowid, word) VALUES(30, 'Chryses'); |
| 350 |
| 351 CREATE TABLE t5(i, w); |
| 352 INSERT INTO t5 VALUES(5, 'Poseidon'); |
| 353 INSERT INTO t5 VALUES(20, 'Chronos'); |
| 354 INSERT INTO t5 VALUES(30, 'Hera'); |
| 355 } |
| 356 |
| 357 db_save_and_close |
| 358 foreach {tn conflict err bRollback res} { |
| 359 0 "" {1 {constraint failed}} 0 |
| 360 {10 Agamemnon 20 Patroclus 30 Chryses} |
| 361 1 "OR REPLACE" {0 {}} 0 |
| 362 {5 Poseidon 10 Agamemnon 20 Chronos 30 Hera} |
| 363 2 "OR ABORT" {1 {constraint failed}} 0 |
| 364 {10 Agamemnon 20 Patroclus 30 Chryses} |
| 365 3 "OR ROLLBACK" {1 {constraint failed}} 1 |
| 366 {10 Agamemnon 20 Patroclus 30 Chryses} |
| 367 5 "OR IGNORE" {0 {}} 0 |
| 368 {5 Poseidon 10 Agamemnon 20 Patroclus 30 Chryses} |
| 369 } { |
| 370 db_restore_and_reopen |
| 371 load_static_extension db spellfix nextchar |
| 372 |
| 373 execsql BEGIN |
| 374 set sql "INSERT $conflict INTO t4(rowid, word) SELECT i, w FROM t5" |
| 375 do_catchsql_test 7.4.2.$tn.1 $sql $err |
| 376 do_execsql_test 7.4.2.$tn.2 { SELECT rowid, word FROM t4 } $res |
| 377 |
| 378 do_test 7.4.2.$tn.3 { sqlite3_get_autocommit db } $bRollback |
| 379 catchsql ROLLBACK |
| 380 } |
| 381 |
| 382 foreach {tn conflict err bRollback res} { |
| 383 0 "" {1 {constraint failed}} 0 |
| 384 {10 Agamemnon 20 Patroclus 30 Chryses} |
| 385 1 "OR REPLACE" {0 {}} 0 |
| 386 {15 Agamemnon 45 Chryses} |
| 387 2 "OR ABORT" {1 {constraint failed}} 0 |
| 388 {10 Agamemnon 20 Patroclus 30 Chryses} |
| 389 3 "OR ROLLBACK" {1 {constraint failed}} 1 |
| 390 {10 Agamemnon 20 Patroclus 30 Chryses} |
| 391 5 "OR IGNORE" {0 {}} 0 |
| 392 {15 Agamemnon 20 Patroclus 45 Chryses} |
| 393 } { |
| 394 db_restore_and_reopen |
| 395 load_static_extension db spellfix nextchar |
| 396 |
| 397 execsql BEGIN |
| 398 set sql "UPDATE $conflict t4 SET rowid=rowid + (rowid/2)" |
| 399 do_catchsql_test 7.5.2.$tn.1 $sql $err |
| 400 do_execsql_test 7.5.2.$tn.2 { SELECT rowid, word FROM t4 } $res |
| 401 do_test 7.5.2.$tn.3 { sqlite3_get_autocommit db } $bRollback |
| 402 catchsql ROLLBACK |
| 403 } |
288 | 404 |
289 finish_test | 405 finish_test |
| 406 |
OLD | NEW |