| OLD | NEW |
| (Empty) |
| 1 # 2008 Feb 19 | |
| 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 # | |
| 12 # The focus of this file is testing that the r-tree correctly handles | |
| 13 # out-of-memory conditions. | |
| 14 # | |
| 15 # $Id: rtree3.test,v 1.2 2008/06/23 15:55:52 danielk1977 Exp $ | |
| 16 # | |
| 17 | |
| 18 if {![info exists testdir]} { | |
| 19 set testdir [file join [file dirname $argv0] .. .. test] | |
| 20 } | |
| 21 source $testdir/tester.tcl | |
| 22 | |
| 23 ifcapable !rtree { | |
| 24 finish_test | |
| 25 return | |
| 26 } | |
| 27 | |
| 28 # Only run these tests if memory debugging is turned on. | |
| 29 # | |
| 30 source $testdir/malloc_common.tcl | |
| 31 if {!$MEMDEBUG} { | |
| 32 puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..." | |
| 33 finish_test | |
| 34 return | |
| 35 } | |
| 36 | |
| 37 do_malloc_test rtree3-1 -sqlbody { | |
| 38 BEGIN TRANSACTION; | |
| 39 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); | |
| 40 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9); | |
| 41 INSERT INTO rt VALUES(NULL, 13, 15, 17, 19); | |
| 42 DELETE FROM rt WHERE ii = 1; | |
| 43 SELECT * FROM rt; | |
| 44 SELECT ii FROM rt WHERE ii = 2; | |
| 45 COMMIT; | |
| 46 } | |
| 47 do_malloc_test rtree3-2 -sqlprep { | |
| 48 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); | |
| 49 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9); | |
| 50 } -sqlbody { | |
| 51 DROP TABLE rt; | |
| 52 } | |
| 53 | |
| 54 | |
| 55 do_malloc_test rtree3-3 -sqlprep { | |
| 56 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); | |
| 57 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9); | |
| 58 } -tclbody { | |
| 59 db eval BEGIN | |
| 60 for {set ii 0} {$ii < 100} {incr ii} { | |
| 61 set f [expr rand()] | |
| 62 db eval {INSERT INTO rt VALUES(NULL, $f*10.0, $f*10.0, $f*15.0, $f*15.0)} | |
| 63 } | |
| 64 db eval COMMIT | |
| 65 db eval BEGIN | |
| 66 for {set ii 0} {$ii < 100} {incr ii} { | |
| 67 set f [expr rand()] | |
| 68 db eval { DELETE FROM rt WHERE x1<($f*10.0) AND x1>($f*10.5) } | |
| 69 } | |
| 70 db eval COMMIT | |
| 71 } | |
| 72 | |
| 73 finish_test | |
| 74 | |
| OLD | NEW |