Fix an obscure bug causing sqlite3_close() to fail if there are virtual tables on the disconnect list when it is called.
FossilOrigin-Name: 6504aa47a8ebb13827be017c4cb4b2dc3c4c55f4
This commit is contained in:
parent
82d25da5b0
commit
d88e521f59
@ -3241,6 +3241,8 @@ static int rtreeInit(
|
|||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
*ppVtab = (sqlite3_vtab *)pRtree;
|
*ppVtab = (sqlite3_vtab *)pRtree;
|
||||||
}else{
|
}else{
|
||||||
|
assert( *ppVtab==0 );
|
||||||
|
assert( pRtree->nBusy==1 );
|
||||||
rtreeRelease(pRtree);
|
rtreeRelease(pRtree);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -243,6 +243,32 @@ do_eqp_test 5.8 {
|
|||||||
0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 1:}
|
0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 1:}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Test that having a second connection drop the sqlite_stat1 table
|
||||||
|
# before it is required by rtreeConnect() does not cause problems.
|
||||||
|
#
|
||||||
|
ifcapable rtree {
|
||||||
|
reset_db
|
||||||
|
do_execsql_test 6.1 {
|
||||||
|
CREATE TABLE t1(x);
|
||||||
|
CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
|
||||||
|
INSERT INTO t1 VALUES(1);
|
||||||
|
INSERT INTO rt VALUES(1,2,3);
|
||||||
|
ANALYZE;
|
||||||
|
}
|
||||||
|
db close
|
||||||
|
sqlite3 db test.db
|
||||||
|
do_execsql_test 6.2 { SELECT * FROM t1 } {1}
|
||||||
|
|
||||||
|
do_test 6.3 {
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
db2 eval { DROP TABLE sqlite_stat1 }
|
||||||
|
db2 close
|
||||||
|
execsql { SELECT * FROM rt }
|
||||||
|
} {1 2.0 3.0}
|
||||||
|
db close
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
20
manifest
20
manifest
@ -1,5 +1,5 @@
|
|||||||
C Changes\sto\sFTS\sto\sensure\sthat\sit\sdoes\snot\saccess\sthe\sdatabase\sfrom\swithin\sthe\sxConnect\smethod.
|
C Fix\san\sobscure\sbug\scausing\ssqlite3_close()\sto\sfail\sif\sthere\sare\svirtual\stables\son\sthe\sdisconnect\slist\swhen\sit\sis\scalled.
|
||||||
D 2014-03-12T19:20:36.904
|
D 2014-03-12T19:38:38.004
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
|
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -120,7 +120,7 @@ F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
|
|||||||
F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
|
F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
|
||||||
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
||||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||||
F ext/rtree/rtree.c d963b961f7ebb3842a6dbc959ed8c3f3534206c4
|
F ext/rtree/rtree.c 2d9f95da404d850474e628c720c5ce15d29b47de
|
||||||
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
|
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
|
||||||
F ext/rtree/rtree1.test cf679265ecafff494a768ac9c2f43a70915a6290
|
F ext/rtree/rtree1.test cf679265ecafff494a768ac9c2f43a70915a6290
|
||||||
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
|
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
|
||||||
@ -133,7 +133,7 @@ F ext/rtree/rtree8.test db79c812f9e4a11f9b1f3f9934007884610a713a
|
|||||||
F ext/rtree/rtree9.test d86ebf08ff6328895613ed577dd8a2a37c472c34
|
F ext/rtree/rtree9.test d86ebf08ff6328895613ed577dd8a2a37c472c34
|
||||||
F ext/rtree/rtreeA.test ace05e729a36e342d40cf94e9efc7b4723d9dcdf
|
F ext/rtree/rtreeA.test ace05e729a36e342d40cf94e9efc7b4723d9dcdf
|
||||||
F ext/rtree/rtreeB.test 983e567b49b5dca165940f66b87e161aa30e82b2
|
F ext/rtree/rtreeB.test 983e567b49b5dca165940f66b87e161aa30e82b2
|
||||||
F ext/rtree/rtreeC.test afe930ac948c79fd12e48691c478d3f3bfc763d8
|
F ext/rtree/rtreeC.test 16d7aa86ecb6a876d2a38cf590a1471a41b3a46d
|
||||||
F ext/rtree/rtreeD.test 636630357638f5983701550b37f0f5867130d2ca
|
F ext/rtree/rtreeD.test 636630357638f5983701550b37f0f5867130d2ca
|
||||||
F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195
|
F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195
|
||||||
F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
|
F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
|
||||||
@ -186,7 +186,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
|||||||
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
|
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
|
||||||
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
|
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
|
||||||
F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303
|
F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303
|
||||||
F src/main.c e054917b1beb3081b0f23e8bdd3d6c0e12933dd3
|
F src/main.c 691b25754bef596108fe60ff1bcbe8445369c9db
|
||||||
F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be
|
F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be
|
||||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||||
F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b
|
F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b
|
||||||
@ -523,7 +523,7 @@ F test/fts3ak.test bd14deafe9d1586e8e9bf032411026ac4f8c925d
|
|||||||
F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f
|
F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f
|
||||||
F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
|
F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
|
||||||
F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
|
F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
|
||||||
F test/fts3ao.test 71b0675e3df5c512a5a03daaa95ee1916de23dda
|
F test/fts3ao.test 3e4e3d5e75c076520341d0bdf4eb17c00e8cbde2
|
||||||
F test/fts3atoken.test fca30fd86db9241d571c637751e9a8a2f50f1451
|
F test/fts3atoken.test fca30fd86db9241d571c637751e9a8a2f50f1451
|
||||||
F test/fts3auto.test b981fea19b132b4e6878f50d7c1f369b28f68eb9
|
F test/fts3auto.test b981fea19b132b4e6878f50d7c1f369b28f68eb9
|
||||||
F test/fts3aux1.test f8f287a4a73f381f8fa15b6a70f36245f903d221
|
F test/fts3aux1.test f8f287a4a73f381f8fa15b6a70f36245f903d221
|
||||||
@ -1047,7 +1047,7 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61
|
|||||||
F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e
|
F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e
|
||||||
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
||||||
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
||||||
F test/vtab_shared.test 6acafaae7126c9f49be72c2f57eb8bef3024f1cb
|
F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772
|
||||||
F test/wal.test 40073e54359d43354925b2b700b7eebd5e207285
|
F test/wal.test 40073e54359d43354925b2b700b7eebd5e207285
|
||||||
F test/wal2.test a8e3963abf6b232cf0b852b09b53665ef34007af
|
F test/wal2.test a8e3963abf6b232cf0b852b09b53665ef34007af
|
||||||
F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0
|
F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0
|
||||||
@ -1156,7 +1156,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||||
P 7ce03c1b5552d830300575c5b41a874db7a2ec77
|
P c67a52c356416cc200f51f9168d942e78db11d34
|
||||||
R deefc2d49a0ad1f14f370fa09b6f4e09
|
R 675a28e896dc8931c7ccad371f04b002
|
||||||
U dan
|
U dan
|
||||||
Z 287a2bd2233940be3dc25c35e9cb956e
|
Z 867ad6b65f1e7902a3a764dd985f4266
|
||||||
|
@ -1 +1 @@
|
|||||||
c67a52c356416cc200f51f9168d942e78db11d34
|
6504aa47a8ebb13827be017c4cb4b2dc3c4c55f4
|
@ -800,6 +800,7 @@ static void disconnectAllVtab(sqlite3 *db){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sqlite3VtabUnlockList(db);
|
||||||
sqlite3BtreeLeaveAll(db);
|
sqlite3BtreeLeaveAll(db);
|
||||||
#else
|
#else
|
||||||
UNUSED_PARAMETER(db);
|
UNUSED_PARAMETER(db);
|
||||||
|
@ -219,4 +219,32 @@ do_execsql_test 5.2 {
|
|||||||
SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';
|
SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';
|
||||||
} {0 6}
|
} {0 6}
|
||||||
|
|
||||||
|
# At one point this was causing a memory leak.
|
||||||
|
#
|
||||||
|
foreach {tn sql} {
|
||||||
|
1 {}
|
||||||
|
2 { INSERT INTO ft(ft) VALUES('merge=2,2'); }
|
||||||
|
} {
|
||||||
|
reset_db
|
||||||
|
do_execsql_test 6.$tn.1 "
|
||||||
|
CREATE TABLE t1(x);
|
||||||
|
CREATE VIRTUAL TABLE ft USING fts3;
|
||||||
|
INSERT INTO ft VALUES('hello world');
|
||||||
|
$sql
|
||||||
|
"
|
||||||
|
|
||||||
|
db close
|
||||||
|
sqlite3 db test.db
|
||||||
|
do_execsql_test 6.$tn.2 { SELECT * FROM t1 } {}
|
||||||
|
|
||||||
|
do_test 6.$tn.3 {
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
db2 eval { DROP TABLE t1 }
|
||||||
|
db2 close
|
||||||
|
set stmt [sqlite3_prepare db { SELECT * FROM ft } -1 dummy]
|
||||||
|
sqlite3_finalize $stmt
|
||||||
|
} {SQLITE_OK}
|
||||||
|
db close
|
||||||
|
}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
|
set testprefix vtab_shared
|
||||||
|
|
||||||
ifcapable !vtab||!shared_cache {
|
ifcapable !vtab||!shared_cache {
|
||||||
finish_test
|
finish_test
|
||||||
@ -228,5 +229,51 @@ do_test vtab_shared_1.15.3 {
|
|||||||
|
|
||||||
db close
|
db close
|
||||||
db2 close
|
db2 close
|
||||||
|
|
||||||
|
#---------------------------------------------------------------
|
||||||
|
# Test calling sqlite3_close() with vtabs on the disconnect list.
|
||||||
|
#
|
||||||
|
ifcapable rtree {
|
||||||
|
reset_db
|
||||||
|
do_test 2.1.1 {
|
||||||
|
sqlite3 db test.db
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
|
||||||
|
# Create a virtual table using [db].
|
||||||
|
execsql {
|
||||||
|
CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
|
||||||
|
INSERT INTO rt VALUES(1, 2 ,3);
|
||||||
|
SELECT * FROM rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Drop the virtual table using [db2]. The sqlite3_vtab object belonging
|
||||||
|
# to [db] is moved to the sqlite3.pDisconnect list.
|
||||||
|
execsql { DROP TABLE rt } db2
|
||||||
|
|
||||||
|
# Immediately close [db]. At one point this would fail due to the
|
||||||
|
# unfinalized statements held by the un-xDisconnect()ed sqlite3_vtab.
|
||||||
|
db close
|
||||||
|
} {}
|
||||||
|
db2 close
|
||||||
|
}
|
||||||
|
|
||||||
|
ifcapable fts3 {
|
||||||
|
# Same test as above, except using fts3 instead of rtree.
|
||||||
|
reset_db
|
||||||
|
do_test 2.2.1 {
|
||||||
|
sqlite3 db test.db
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
execsql {
|
||||||
|
CREATE VIRTUAL TABLE ft USING fts3;
|
||||||
|
INSERT INTO ft VALUES('hello world');
|
||||||
|
SELECT * FROM ft;
|
||||||
|
}
|
||||||
|
execsql { DROP TABLE ft } db2
|
||||||
|
db close
|
||||||
|
} {}
|
||||||
|
db2 close
|
||||||
|
}
|
||||||
|
|
||||||
sqlite3_enable_shared_cache 0
|
sqlite3_enable_shared_cache 0
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user