From: dan Date: Thu, 26 Aug 2010 07:59:10 +0000 (+0000) Subject: Improve coverage of rtree.c some more. X-Git-Tag: experimental~115 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bf19178f791b08061b476f672fff4881bfb0af4;p=thirdparty%2Fsqlite.git Improve coverage of rtree.c some more. FossilOrigin-Name: bee1959dde19ebec20a7ffcb732aee0c8bb2e67d --- diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index b6abeeb9f0..65786fe967 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -2065,6 +2065,11 @@ splitnode_out: return rc; } +/* +** If node pLeaf is not the root of the r-tree and its pParent +** pointer is still NULL, locate the parent node of pLeaf and populate +** pLeaf->pParent. +*/ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){ int rc = SQLITE_OK; if( pLeaf->iNode!=1 && pLeaf->pParent==0 ){ @@ -2442,19 +2447,17 @@ static int rtreeUpdate( ** the root node (the operation that Gutman's paper says to perform ** in this scenario). */ - if( rc==SQLITE_OK && pRtree->iDepth>0 ){ - if( rc==SQLITE_OK && NCELL(pRoot)==1 ){ - RtreeNode *pChild; - i64 iChild = nodeGetRowid(pRtree, pRoot, 0); - rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); - if( rc==SQLITE_OK ){ - rc = removeNode(pRtree, pChild, pRtree->iDepth-1); - } - if( rc==SQLITE_OK ){ - pRtree->iDepth--; - writeInt16(pRoot->zData, pRtree->iDepth); - pRoot->isDirty = 1; - } + if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){ + RtreeNode *pChild; + i64 iChild = nodeGetRowid(pRtree, pRoot, 0); + rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); + if( rc==SQLITE_OK ){ + rc = removeNode(pRtree, pChild, pRtree->iDepth-1); + } + if( rc==SQLITE_OK ){ + pRtree->iDepth--; + writeInt16(pRoot->zData, pRtree->iDepth); + pRoot->isDirty = 1; } } diff --git a/ext/rtree/rtree3.test b/ext/rtree/rtree3.test index ac61829a65..5761329a6b 100644 --- a/ext/rtree/rtree3.test +++ b/ext/rtree/rtree3.test @@ -33,6 +33,8 @@ if {!$MEMDEBUG} { return } +if 1 { + do_faultsim_test rtree3-1 -faults oom* -prep { faultsim_delete_and_reopen } -body { @@ -94,6 +96,8 @@ do_faultsim_test rtree3-3b -faults oom* -prep { db eval COMMIT } +} + do_test rtree3-4.prep { faultsim_delete_and_reopen execsql { @@ -108,19 +112,87 @@ do_test rtree3-4.prep { faultsim_save_and_close } {} -do_faultsim_test rtree3-4a -faults oom-transient -prep { +do_faultsim_test rtree3-4a -faults oom-* -prep { faultsim_restore_and_reopen } -body { db eval { SELECT count(*) FROM rt } } -test { faultsim_test_result {0 1500} } -do_faultsim_test rtree3-4b -faults oom-transient -prep { + +do_faultsim_test rtree3-4b -faults oom-* -prep { faultsim_restore_and_reopen } -body { - db eval { DELETE FROM rt WHERE ii BETWEEN 880 AND 920 } + db eval { DELETE FROM rt WHERE ii BETWEEN 1 AND 100 } } -test { faultsim_test_result {0 {}} } +do_test rtree3-5.prep { + faultsim_delete_and_reopen + execsql { + BEGIN; + PRAGMA page_size = 512; + CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); + } + for {set i 0} {$i < 100} {incr i} { + execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) } + } + execsql { COMMIT } + faultsim_save_and_close +} {} +do_faultsim_test rtree3-5 -faults oom-* -prep { + faultsim_restore_and_reopen +} -body { + for {set i 100} {$i < 110} {incr i} { + execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) } + } +} -test { + faultsim_test_result {0 {}} +} + +do_test rtree3-6.prep { + faultsim_delete_and_reopen + execsql { + BEGIN; + PRAGMA page_size = 512; + CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); + } + for {set i 0} {$i < 50} {incr i} { + execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) } + } + execsql { COMMIT } + faultsim_save_and_close +} {} +do_faultsim_test rtree3-6 -faults oom-* -prep { + faultsim_restore_and_reopen +} -body { + execsql BEGIN + for {set i 0} {$i < 50} {incr i} { + execsql { DELETE FROM rt WHERE ii=$i } + } + execsql COMMIT +} -test { + faultsim_test_result {0 {}} +} + +do_test rtree3-7.prep { + faultsim_delete_and_reopen + execsql { CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2) } + faultsim_save_and_close +} {} +do_faultsim_test rtree3-7 -faults oom-* -prep { + faultsim_restore_and_reopen +} -body { + execsql { ALTER TABLE rt RENAME TO rt2 } +} -test { + faultsim_test_result {0 {}} +} + +do_faultsim_test rtree3-8 -faults oom-* -prep { + catch { db close } +} -body { + sqlite3 db test.db +} + finish_test diff --git a/ext/rtree/rtree8.test b/ext/rtree/rtree8.test index 7e24dd456d..c3777e8607 100644 --- a/ext/rtree/rtree8.test +++ b/ext/rtree/rtree8.test @@ -126,12 +126,46 @@ do_execsql_test rtree8-2.2.3 { # Test that trying to use the MATCH operator with the r-tree module does # not confuse it. # -breakpoint populate_t1 10 do_catchsql_test rtree8-3.1 { SELECT * FROM t1 WHERE x1 MATCH '1234' } {1 {unable to use function MATCH in the requested context}} +#------------------------------------------------------------------------- +# Test a couple of invalid arguments to rtreedepth(). +# +do_catchsql_test rtree8-4.1 { + SELECT rtreedepth('hello world') +} {1 {Invalid argument to rtreedepth()}} +do_catchsql_test rtree8-4.2 { + SELECT rtreedepth(X'00') +} {1 {Invalid argument to rtreedepth()}} + + +#------------------------------------------------------------------------- +# Delete half of a lopsided tree. +# +do_execsql_test rtree8-5.1 { + CREATE VIRTUAL TABLE t2 USING rtree_i32(id, x1, x2) +} {} +do_test rtree8-5.2 { + execsql BEGIN + for {set i 0} {$i < 100} {incr i} { + execsql { INSERT INTO t2 VALUES($i, 100, 101) } + } + for {set i 100} {$i < 200} {incr i} { + execsql { INSERT INTO t2 VALUES($i, 1000, 1001) } + } + execsql COMMIT +} {} +do_test rtree8-5.3 { + execsql BEGIN + for {set i 0} {$i < 200} {incr i} { + execsql { DELETE FROM t2 WHERE id = $i } + } + execsql COMMIT +} {} + finish_test diff --git a/manifest b/manifest index 8065ab70da..7810826e4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sof\schanges\sfor\sSQLITE_OMIT_WAL\ssupport\sin\spager.c. -D 2010-08-26T05:23:37 +C Improve\scoverage\sof\srtree.c\ssome\smore. +D 2010-08-26T07:59:11 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 543f91f24cd7fee774ecc0a61c19704c0c3e78fd F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,16 +78,16 @@ F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 586c8d6a72ff67060e3850d3a9ef86a85caf38dc +F ext/rtree/rtree.c e26a75709563c3638ea59960a11464985e3779d9 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 51bb0cd0405970501e63258401ae5ad235a4f468 F ext/rtree/rtree2.test 47b90f549a59e667e9fb01338956ead6f66c8d9d -F ext/rtree/rtree3.test d2a408858ef14a2bf50ec2e7031c35782243b94d +F ext/rtree/rtree3.test db7652535e339bbbf5f3909599a088c7daa4be87 F ext/rtree/rtree4.test 2adce44dc544f6eb570898c8d5270bdf6ca64bd8 F ext/rtree/rtree5.test 92508f5152a50110af6551fa5b769d1bbd7c4ef3 F ext/rtree/rtree6.test 903720aaab819764c3693aaac0affe8174104ac8 F ext/rtree/rtree7.test 6fd29fb8e13795c822f4ceeea92ab5d61c96976d -F ext/rtree/rtree8.test 7ba5d3b6ce7bb75fcce41a0a2da8796b99b69b5b +F ext/rtree/rtree8.test 64b83b163a6997202e11c4226a74e7e52f26e75c F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195 F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/tkt3363.test 2bf324f7908084a5f463de3109db9c6e607feb1b @@ -565,7 +565,7 @@ F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/rollback.test 1a83118ea6db4e7d8c10eaa63871b5e90502ffdc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287 -F test/rtree.test fb372aff108d4371bd0b5e63e106947587ff4310 +F test/rtree.test dbc0c5113c1d67e5cc44a495d682dda531c83fd4 F test/savepoint.test 992d6429b6bce16ac172f7431975044ceaeb0803 F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7 F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec @@ -847,7 +847,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 699cc6b48774be111f2e076cc1920ae79497dcea -R dbf929a2ab5b426ab9068f733752d8aa -U shaneh -Z 81bf9be826701101829ac75722805b4a +P afb2484c64bf0cdec8240b9ecd0a794c44a63066 +R c9799883c88c738cdee99f610758f82c +U dan +Z 3ec65e959402f5df9ce6352482675a71 diff --git a/manifest.uuid b/manifest.uuid index fcb87c39bf..1e65f7223e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afb2484c64bf0cdec8240b9ecd0a794c44a63066 \ No newline at end of file +bee1959dde19ebec20a7ffcb732aee0c8bb2e67d \ No newline at end of file diff --git a/test/rtree.test b/test/rtree.test index 5603b05cc4..cedc6f93dd 100644 --- a/test/rtree.test +++ b/test/rtree.test @@ -18,6 +18,7 @@ set RTREE_EXCLUDE { } if {[info exists G(isquick)] && $G(isquick)} { set RTREE_EXCLUDE rtree3.test } +set G(isquick) 1 set rtreedir [file join $testdir .. ext rtree]