From: danielk1977 Date: Mon, 22 Dec 2008 15:04:32 +0000 (+0000) Subject: Fix a reference counting bug in rtree. Ticket #3549. (CVS 6054) X-Git-Tag: version-3.6.10~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7974759cb48fd9461c132b6d186c5b73ef71e538;p=thirdparty%2Fsqlite.git Fix a reference counting bug in rtree. Ticket #3549. (CVS 6054) FossilOrigin-Name: bbdc0e9f2481f8d59e05ea282b615f97e09fb471 --- diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 7d88a031c5..13de73aa85 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -12,7 +12,7 @@ ** This file contains code for implementations of the r-tree and r*-tree ** algorithms packaged as an SQLite virtual table module. ** -** $Id: rtree.c,v 1.11 2008/11/12 15:24:27 drh Exp $ +** $Id: rtree.c,v 1.12 2008/12/22 15:04:32 danielk1977 Exp $ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) @@ -400,7 +400,8 @@ nodeAcquire( */ if( (pNode = nodeHashLookup(pRtree, iNode)) ){ assert( !pParent || !pNode->pParent || pNode->pParent==pParent ); - if( pParent ){ + if( pParent && !pNode->pParent ){ + nodeReference(pParent); pNode->pParent = pParent; } pNode->nRef++; diff --git a/ext/rtree/rtree1.test b/ext/rtree/rtree1.test index ee9866f9cc..0c88d5cd78 100644 --- a/ext/rtree/rtree1.test +++ b/ext/rtree/rtree1.test @@ -11,7 +11,7 @@ # # The focus of this file is testing the r-tree extension. # -# $Id: rtree1.test,v 1.5 2008/07/14 15:37:01 danielk1977 Exp $ +# $Id: rtree1.test,v 1.6 2008/12/22 15:04:32 danielk1977 Exp $ # if {![info exists testdir]} { @@ -360,5 +360,37 @@ do_test rtree-8.1.6 { execsql { SELECT ii FROM t6 WHERE x1<3 } } {} do_test rtree-8.1.7 { execsql { SELECT ii FROM t6 WHERE x1<4 } } {1} do_test rtree-8.1.8 { execsql { SELECT ii FROM t6 WHERE x1<5 } } {1 2} +#---------------------------------------------------------------------------- +# Test cases rtree-9.* +# +# Test that ticket #3549 is fixed. +do_test rtree-9.1 { + execsql { + CREATE TABLE foo (id INTEGER PRIMARY KEY); + CREATE VIRTUAL TABLE bar USING rtree (id, minX, maxX, minY, maxY); + INSERT INTO foo VALUES (null); + INSERT INTO foo SELECT null FROM foo; + INSERT INTO foo SELECT null FROM foo; + INSERT INTO foo SELECT null FROM foo; + INSERT INTO foo SELECT null FROM foo; + INSERT INTO foo SELECT null FROM foo; + INSERT INTO foo SELECT null FROM foo; + DELETE FROM foo WHERE id > 40; + INSERT INTO bar SELECT NULL, 0, 0, 0, 0 FROM foo; + } +} {} + +# This used to crash. +do_test rtree-9.2 { + execsql { + SELECT count(*) FROM bar b1, bar b2, foo s1 WHERE s1.id = b1.id; + } +} {1600} +do_test rtree-9.3 { + execsql { + SELECT count(*) FROM bar b1, bar b2, foo s1 + WHERE b1.minX <= b2.maxX AND s1.id = b1.id; + } +} {1600} finish_test diff --git a/manifest b/manifest index 76fde2e4f6..b67af0417e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\stest\sscripts\sso\sthat\sveryquick.test\sruns\swith\sSQLITE_TEMP_STORE=3\sdefined.\sAlso\sa\sfix\sto\sstop\sthe\ssame\sswitch\scausing\sa\scrash\sin\sthe\ssavepoint\scode.\s(CVS\s6053) -D 2008-12-22T11:43:36 +C Fix\sa\sreference\scounting\sbug\sin\srtree.\sTicket\s#3549.\s(CVS\s6054) +D 2008-12-22T15:04:32 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 77635d0909c2067cee03889a1e04ce910d8fb809 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -69,9 +69,9 @@ F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33 F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 05d517734dad60165255581cc8dacea00c03b5c0 +F ext/rtree/rtree.c a1c43d0f58aaa6ba22eaf02875f8c55311f74a5d F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e -F ext/rtree/rtree1.test 620223886bf1a319317e63235aac20790375c544 +F ext/rtree/rtree1.test ebcef111192a034c64e9f3b6bd42533a539c2062 F ext/rtree/rtree2.test 9ac9d28fa948779df66916c67a5dcf9704c3cb74 F ext/rtree/rtree3.test 877a09c1a0c2b87af0f94f3a286e7dd3b65adf22 F ext/rtree/rtree4.test 11724f766a74f48710998cdd7552cec140c55bf9 @@ -684,7 +684,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P bb177e3072ab61d0af7af91660ebe4dafa487b42 -R 848b232f02845492e2937b3a6e6c7ff8 +P ee0e6eae9f984472e44d7ee8f195c6e5d33f2efd +R 84a43cb77701b394bb942c42ab498d4d U danielk1977 -Z 297d4aaaf79becd658366040aca809fd +Z a3c50f9a13d9f2d8f7a301ea5204d232 diff --git a/manifest.uuid b/manifest.uuid index 1cbcf1fbe5..71c17be5fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ee0e6eae9f984472e44d7ee8f195c6e5d33f2efd \ No newline at end of file +bbdc0e9f2481f8d59e05ea282b615f97e09fb471 \ No newline at end of file