gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/wherelfault.test (about) 1 # 2008 October 6 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 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. 9 # 10 #*********************************************************************** 11 # This file implements regression tests for SQLite library. The 12 # focus of this file is testing fault-injection with the 13 # LIMIT ... OFFSET ... clause of UPDATE and DELETE statements. 14 # 15 16 set testdir [file dirname $argv0] 17 source $testdir/tester.tcl 18 source $testdir/malloc_common.tcl 19 set testprefix wherelfault 20 21 ifcapable !update_delete_limit { 22 finish_test 23 return 24 } 25 26 do_execsql_test 1.0 { 27 CREATE TABLE t1(a, b); 28 INSERT INTO t1 VALUES(1, 'f'); 29 INSERT INTO t1 VALUES(2, 'e'); 30 INSERT INTO t1 VALUES(3, 'd'); 31 INSERT INTO t1 VALUES(4, 'c'); 32 INSERT INTO t1 VALUES(5, 'b'); 33 INSERT INTO t1 VALUES(6, 'a'); 34 35 CREATE VIEW v1 AS SELECT a,b FROM t1; 36 CREATE TABLE log(op, a); 37 38 CREATE TRIGGER v1del INSTEAD OF DELETE ON v1 BEGIN 39 INSERT INTO log VALUES('delete', old.a); 40 END; 41 42 CREATE TRIGGER v1upd INSTEAD OF UPDATE ON v1 BEGIN 43 INSERT INTO log VALUES('update', old.a); 44 END; 45 } 46 47 faultsim_save_and_close 48 do_faultsim_test 1.1 -prep { 49 faultsim_restore_and_reopen 50 db eval {SELECT * FROM sqlite_master} 51 } -body { 52 execsql { DELETE FROM v1 ORDER BY a LIMIT 3; } 53 } -test { 54 faultsim_test_result {0 {}} 55 } 56 57 do_faultsim_test 1.2 -prep { 58 faultsim_restore_and_reopen 59 db eval {SELECT * FROM sqlite_master} 60 } -body { 61 execsql { UPDATE v1 SET b = 555 ORDER BY a LIMIT 3 } 62 } -test { 63 faultsim_test_result {0 {}} 64 } 65 66 #------------------------------------------------------------------------- 67 sqlite3 db test.db 68 do_execsql_test 2.1.0 { 69 CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID; 70 } 71 faultsim_save_and_close 72 73 do_faultsim_test 2.1 -prep { 74 faultsim_restore_and_reopen 75 db eval {SELECT * FROM sqlite_master} 76 } -body { 77 execsql { DELETE FROM t2 WHERE c=? ORDER BY a DESC LIMIT 10 } 78 } -test { 79 faultsim_test_result {0 {}} 80 } 81 82 finish_test