rtreeF.test 2.3 KB

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