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 contains tests for the r-tree module.
13 # This file contains test cases for the ticket
14 # [369d57fb8e5ccdff06f197a37147a88f9de95cda] (2014-08-21)
16 # The following SQL causes an assertion fault while running
17 # sqlite3_prepare() on the DELETE statement:
21 # CREATE VIRTUAL TABLE t3 USING rtree(a,b,c);
22 # CREATE TRIGGER t2del AFTER DELETE ON t2 WHEN (SELECT 1 from t1) BEGIN
23 # DELETE FROM t3 WHERE a=old.y;
25 # DELETE FROM t2 WHERE y=1;
28 if {![info exists testdir]} {
29 set testdir [file join [file dirname [info script]] .. .. test]
31 source [file join [file dirname [info script]] rtree_util.tcl]
32 source $testdir/tester.tcl
33 ifcapable !rtree { finish_test ; return }
35 do_execsql_test rtreeF-1.1 {
38 CREATE VIRTUAL TABLE t3 USING rtree(a,b,c);
39 CREATE TRIGGER t2dwl AFTER DELETE ON t2 WHEN (SELECT 1 from t1) BEGIN
40 DELETE FROM t3 WHERE a=old.y;
43 INSERT INTO t1(x) VALUES(999);
44 INSERT INTO t2(y) VALUES(1),(2),(3),(4),(5);
45 INSERT INTO t3(a,b,c) VALUES(1,2,3),(2,3,4),(3,4,5),(4,5,6),(5,6,7);
47 SELECT a FROM t3 ORDER BY a;
49 SELECT y FROM t2 ORDER BY y;
50 } {1 2 3 4 5 | 1 2 3 4 5}
51 do_execsql_test rtreeF-1.2 {
52 DELETE FROM t2 WHERE y=3;
54 SELECT a FROM t3 ORDER BY a;
56 SELECT y FROM t2 ORDER BY y;
58 do_execsql_test rtreeF-1.3 {
60 DELETE FROM t2 WHERE y=5;
62 SELECT a FROM t3 ORDER BY a;
64 SELECT y FROM t2 ORDER BY y;
66 do_execsql_test rtreeF-1.4 {
67 INSERT INTO t1 DEFAULT VALUES;
68 DELETE FROM t2 WHERE y=5;
70 SELECT a FROM t3 ORDER BY a;
72 SELECT y FROM t2 ORDER BY y;
74 do_execsql_test rtreeF-1.5 {
75 DELETE FROM t2 WHERE y=2;
77 SELECT a FROM t3 ORDER BY a;
79 SELECT y FROM t2 ORDER BY y;
82 do_rtree_integrity_test rtreeF-1.6 t3