3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
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.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 source $testdir/malloc_common.tcl
19 set testprefix wherelfault
21 ifcapable !update_delete_limit {
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');
35 CREATE VIEW v1 AS SELECT a,b FROM t1;
36 CREATE TABLE log(op, a);
38 CREATE TRIGGER v1del INSTEAD OF DELETE ON v1 BEGIN
39 INSERT INTO log VALUES('delete', old.a);
42 CREATE TRIGGER v1upd INSTEAD OF UPDATE ON v1 BEGIN
43 INSERT INTO log VALUES('update', old.a);
47 faultsim_save_and_close
48 do_faultsim_test 1.1 -prep {
49 faultsim_restore_and_reopen
50 db eval {SELECT * FROM sqlite_master}
52 execsql { DELETE FROM v1 ORDER BY a LIMIT 3; }
54 faultsim_test_result {0 {}}
57 do_faultsim_test 1.2 -prep {
58 faultsim_restore_and_reopen
59 db eval {SELECT * FROM sqlite_master}
61 execsql { UPDATE v1 SET b = 555 ORDER BY a LIMIT 3 }
63 faultsim_test_result {0 {}}
66 #-------------------------------------------------------------------------
68 do_execsql_test 2.1.0 {
69 CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;
71 faultsim_save_and_close
73 do_faultsim_test 2.1 -prep {
74 faultsim_restore_and_reopen
75 db eval {SELECT * FROM sqlite_master}
77 execsql { DELETE FROM t2 WHERE c=? ORDER BY a DESC LIMIT 10 }
79 faultsim_test_result {0 {}}