diff --git a/manifest b/manifest index b8cb6b4d46..be3153a3f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\slatest\schanges\sof\strunk\sinto\sthe\ssession\sbranch. -D 2011-04-04T13:19:36.696 +C Pull\sthe\slatest\strunk\schanges\s(and\shence\sthe\sschema-parse-refactor\schanges)\ninto\sthe\ssessions\sbranch. +D 2011-04-05T13:27:30.706 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,35 +124,35 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 -F src/analyze.c d0a673d303f611690fc7a3293aaefed57cccc5c8 -F src/attach.c 438ea6f6b5d5961c1f49b737f2ce0f14ce7c6877 +F src/analyze.c a1ad9f4d8aac055c4a4bbd99073e2e78fe66129c +F src/attach.c 7cae2cf0c14762ce14c074a860ec52890a973a56 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 537f89c7ef5021cb580f31f782e556ffffcb2ed1 +F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef -F src/btmutex.c 3e595ee1bb99e3a1f16824137b435ffc97c98e5f +F src/btmutex.c b81062220a4f91b0bd785d13d57205d68449be88 F src/btree.c 107723ed4f9bdb55213ba6164c30c49af75f4bf9 -F src/btree.h a840a20c1969391f98ee06960d5ee2dc460186b3 +F src/btree.h c0e0ff5c85effe9fc757e3085bbdded6d1cca000 F src/btreeInt.h 6714ce2f5e879eb9a904a6a4575dc4faa4f29991 -F src/build.c 3a8c6c4b1e16798755d46e699b7fcc12b9f27b2b -F src/callback.c 5069f224882cbdccd559f591271d28d7f37745bc +F src/build.c d809f57250b10e83586bc23921de02055890b239 +F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b -F src/delete.c 44800af91a90f9d9445a266129313f27487614d8 -F src/expr.c 00817c672af554321fd67c44325afd7cef0e4648 +F src/delete.c ad9fa1cbf91a83ec6990d0aecb7e21cd5ff07e71 +F src/expr.c e3cf0957c6b8faaaf7386a3bc69e53c0dc9705be F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 418b840007c873975fd0d071746d952f8bca20ce +F src/fkey.c a43ba8a005fb5efd1deeee06853e3a6120d46a91 F src/func.c 3a8cb2fb2de3e3aed7f39106daf4878d9d17fcce F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c e354eadb2ca3e8d939ba928f229e2268974f380c +F src/insert.c ef33ce1522a77f6d8077f0bdb6ab22d306900950 F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e -F src/main.c bed41512fabb19492b61d37fd988d79f6225e624 +F src/main.c 50d70810f4cd625c7a8408030efad899aaccccad F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -179,8 +179,8 @@ F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c d548e31beafa792d1994b663a29a5303569efc4e -F src/pragma.c 4221eb822d7cdb1fb69be555b189e15e5a24b6b5 -F src/prepare.c eb4944d9f7bfa13eb42a7416ed9aaed4de4d0bf3 +F src/pragma.c 49c90ab27a4339d4b5bc0b03c08cbcf20ed8d454 +F src/prepare.c 206e1f06479fb5f756592bded468bd3ece3f41d4 F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 @@ -189,18 +189,18 @@ F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a F src/sqlite.h.in 235300cdca517ce148385d3ab816e7e8cf9e1ff3 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h bb9e764799e8c48ca547fbd1ddc3978aeb035bc5 +F src/sqliteInt.h 0873a71099f763cdf24cfabf04a237ad100e20d0 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 -F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc +F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c fe0da0eb0ebd8d21eec90683b779456e64351de6 F src/test1.c 9ca440e80e16e53920904a0a5ac7feffb9b2c9a1 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc -F src/test4.c 0528360b5025688002a5feb6be906ddce52eaaee +F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 F src/test5.c e1a19845625144caf038031234a12185e40d315c F src/test6.c c7256cc21d2409486d094277d5b017e8eced44ba -F src/test7.c d67f65d82815eb0b57699b122ca0145dbea55bbb +F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 F src/test8.c 6b1d12912a04fe6fca8c45bb9c3ea022f4352228 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad @@ -208,7 +208,7 @@ F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 F src/test_config.c 3050df9faf023fb52937f7e9998004c2415d4122 -F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5 +F src/test_demovfs.c 31050680fa6925b4f677cfd4fa965b5f19195e50 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5 F src/test_fuzzer.c f884f6f32e8513d34248d6e1ac8a32047fead254 @@ -223,36 +223,36 @@ F src/test_multiplex.c fdabd793ee7a9642c5a8a470def2347144c46d05 F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec -F src/test_osinst.c f408c6a181f2fb04c56273afd5c3e1e82f60392c +F src/test_osinst.c 62b0b8ef21ce754cc94e17bb42377ed8795dba32 F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8 F src/test_quota.c b5576f17d701af461effd7ca1e71f0d100071192 F src/test_rtree.c 30c981837445a4e187ee850a49c4760d9642f7c3 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 -F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 +F src/test_server.c 88caa13d33cb85a4f924229bd9693acd8e1429ba F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd -F src/test_syscall.c 34ce1be806cd180e241bc688ae3762e5e7825bda +F src/test_syscall.c 162c4ec0137a549c009bb9ecab550527743cfc5d F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa -F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 +F src/test_thread.c 361ae0a0f1cbf5a28ad0388a258b104017a370c0 F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86 F src/test_vfstrace.c 2265c9895f350c8d3c39b079998fbe7481505cc1 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 -F src/trigger.c ec4813709e990a169b6923293e839fa5dfd64282 +F src/trigger.c d5bc8b9ffa2b54569ce635084765c6e41aa9d174 F src/update.c 3f3f3bb734a0da1dffd0ed33e504642b35ed3605 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c cd997077bad039efc0597eb027c929658f93c018 -F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f -F src/vdbe.c e4afe80d602eb2e59d384e7e8e7cb19b06858bde -F src/vdbe.h edef9c4f0be83e1f1dccd049da37b40e021b63d9 +F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e +F src/vdbe.c f38def1fc23013c13d8e97a1551c2ed0e23136fe +F src/vdbe.h 44fd57aeed86da0cd31206626c13cdde0e72cc0e F src/vdbeInt.h 36dddc4cc333867d27f00d326e29af30062a102a F src/vdbeapi.c 7ef519083e3420bf7793d8b4eae2961d894d98ab -F src/vdbeaux.c 15eff6a3202145a54e7a6e65374652045ece3545 +F src/vdbeaux.c 12765fcaa529846f547f9e31a042968f84056dcd F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 -F src/vtab.c e1edca38c4c4310710635bb91bb3c87fdf60f21d +F src/vtab.c b0abc931f95af94c9ffdf9f747eb191cda953123 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -377,7 +377,7 @@ F test/e_createtable.test b40fc61bc4f1ad2a3c84590bd1d711507263d921 F test/e_delete.test 55d868b647acc091c261a10b9b0cb0ab660a6acb F test/e_droptrigger.test ddd4b28ed8a3d81bd5153fa0ab7559529a2ca03a F test/e_dropview.test b347bab30fc8de67b131594b3cd6f3d3bdaa753d -F test/e_expr.test 4e004d1f5187d4bbc9ca3d55660a8d164dd59f4e +F test/e_expr.test 9e8b9790803df4de23c2d68d566959934a6179d4 F test/e_fkey.test 38039b840ab19331000b0f0eb1d82baa7208a67a F test/e_fts3.test 75bb0aee26384ef586165e21018a17f7cd843469 F test/e_insert.test 7390c2da39f16a134dc9a439144768c727757d2c @@ -386,7 +386,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test bf385ae3aa0f014c4933ae66fd3e1302138493eb F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 963d6876064e65f318d1c93aaed36a02b9b389bf -F test/e_vacuum.test 057cc29445746fc1d2542984ff0253d511a234bd +F test/e_vacuum.test 6c09c2af7f2f140518f371c5342100118f779dcf F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041 @@ -554,7 +554,7 @@ F test/lock_common.tcl d279887a0ab16cdb6d935c1203e64113c5a000e9 F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2 F test/main.test 9d7bbfcc1b52c88ba7b2ba6554068ecf9939f252 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 -F test/malloc.test 927e6c8668a1d48c23aa6189bda02aff5a1b83de +F test/malloc.test e56c9c3358da2c18385aea15a42dc970913986c2 F test/malloc3.test 4128b1e6ffa506103b278ad97af89174f310c7ca F test/malloc4.test 957337613002b7058a85116493a262f679f3a261 F test/malloc5.test 4d16d1bb26d2deddd7c4f480deec341f9b2d0e22 @@ -628,7 +628,7 @@ F test/randexpr1.test 1084050991e9ba22c1c10edd8d84673b501cc25a F test/rdonly.test c267d050a1d9a6a321de502b737daf28821a518d F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/releasetest.mk 2eced2f9ae701fd0a29e714a241760503ccba25a -F test/releasetest.tcl 627ccd04a113a193c375594bd5d6d051d8220658 +F test/releasetest.tcl 02497b7fb9c53fa65fc8757de7675987cd571068 F test/rollback.test 1a83118ea6db4e7d8c10eaa63871b5e90502ffdc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287 @@ -695,7 +695,7 @@ F test/tclsqlite.test 1ce9b6340d6d412420634e129a2e3722c651056a F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 -F test/tester.tcl dafe0d30279f6d380d5d2a535781dda91b8cfc3f +F test/tester.tcl 6fa3d2f581b479a3a088b1b5b0d145e548ebe662 F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d184cf00574b52b93f1f089025d6a0addca57558 425e3edb146c497817855dd741878709a25c8b98 -R ffd652e7771374b0d07d334e1f6024f2 +P 95d53c44320b9639f2623aa9cc88d0d3e1a3be8f 5db4511d8a77b74be3503a7c34257ef6b07541f5 +R 674c9237ca4fa927463c92020097f885 U drh -Z 333cd8aa259ea963e7224b1b34eb509c +Z 76b761508ba82daab535ead06aca81f1 diff --git a/manifest.uuid b/manifest.uuid index 5524b4073a..d499c43cc8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95d53c44320b9639f2623aa9cc88d0d3e1a3be8f \ No newline at end of file +03ca83422f0259ae5525aeecc14171811252a67d \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 231d414314..fd040a7ec2 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -149,6 +149,7 @@ static void analyzeOneTable( assert( sqlite3BtreeHoldsAllMutexes(db) ); iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( iDb>=0 ); + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); #ifndef SQLITE_OMIT_AUTHORIZATION if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0, db->aDb[iDb].zName ) ){ @@ -390,6 +391,7 @@ static void analyzeDatabase(Parse *pParse, int iDb){ pParse->nTab += 2; openStatTable(pParse, iDb, iStatCur, 0, 0); iMem = pParse->nMem+1; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ Table *pTab = (Table*)sqliteHashData(k); analyzeOneTable(pParse, pTab, 0, iStatCur, iMem); @@ -600,9 +602,9 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ assert( iDb>=0 && iDbnDb ); assert( db->aDb[iDb].pBt!=0 ); - assert( sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) ); /* Clear any prior statistics */ + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ Index *pIdx = sqliteHashData(i); sqlite3DefaultRowEst(pIdx); diff --git a/src/attach.c b/src/attach.c index 37b61935f3..fe88aa73cd 100644 --- a/src/attach.c +++ b/src/attach.c @@ -200,7 +200,7 @@ static void attachFunc( db->aDb[iDb].pBt = 0; db->aDb[iDb].pSchema = 0; } - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); db->nDb = iDb; if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ db->mallocFailed = 1; @@ -272,7 +272,7 @@ static void detachFunc( sqlite3BtreeClose(pDb->pBt); pDb->pBt = 0; pDb->pSchema = 0; - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); return; detach_error: diff --git a/src/backup.c b/src/backup.c index 82be9635b1..c062744c5c 100644 --- a/src/backup.c +++ b/src/backup.c @@ -401,7 +401,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ int nDestTruncate; if( p->pDestDb ){ - sqlite3ResetInternalSchema(p->pDestDb, 0); + sqlite3ResetInternalSchema(p->pDestDb, -1); } /* Set nDestTruncate to the final number of pages in the destination diff --git a/src/btmutex.c b/src/btmutex.c index 42d0bdcbc7..33b9f86a0c 100644 --- a/src/btmutex.c +++ b/src/btmutex.c @@ -288,6 +288,31 @@ int sqlite3BtreeHoldsAllMutexes(sqlite3 *db){ } #endif /* NDEBUG */ +#ifndef NDEBUG +/* +** Return true if the correct mutexes are held for accessing the +** db->aDb[iDb].pSchema structure. The mutexes required for schema +** access are: +** +** (1) The mutex on db +** (2) if iDb!=1, then the mutex on db->aDb[iDb].pBt. +** +** If pSchema is not NULL, then iDb is computed from pSchema and +** db using sqlite3SchemaToIndex(). +*/ +int sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *pSchema){ + Btree *p; + assert( db!=0 ); + if( pSchema ) iDb = sqlite3SchemaToIndex(db, pSchema); + assert( iDb>=0 && iDbnDb ); + if( !sqlite3_mutex_held(db->mutex) ) return 0; + if( iDb==1 ) return 1; + p = db->aDb[iDb].pBt; + assert( p!=0 ); + return p->sharable==0 || p->locked==1; +} +#endif /* NDEBUG */ + #else /* SQLITE_THREADSAFE>0 above. SQLITE_THREADSAFE==0 below */ /* ** The following are special cases for mutex enter routines for use diff --git a/src/btree.h b/src/btree.h index 4fd4f67685..3eebfe20b5 100644 --- a/src/btree.h +++ b/src/btree.h @@ -220,6 +220,7 @@ void sqlite3BtreeCursorList(Btree*); /* These routines are used inside assert() statements only. */ int sqlite3BtreeHoldsMutex(Btree*); int sqlite3BtreeHoldsAllMutexes(sqlite3*); + int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*); u32 sqlite3BtreeMutexCounter(Btree*); #endif #else @@ -232,6 +233,7 @@ void sqlite3BtreeCursorList(Btree*); # define sqlite3BtreeHoldsMutex(X) 1 # define sqlite3BtreeHoldsAllMutexes(X) 1 +# define sqlite3BtreeSchemaMutexHeld(X,Y) 1 #endif diff --git a/src/build.c b/src/build.c index b4528347d5..7e73b6a8eb 100644 --- a/src/build.c +++ b/src/build.c @@ -156,6 +156,7 @@ void sqlite3FinishCoding(Parse *pParse){ sqlite3VdbeUsesBtree(v, iDb); sqlite3VdbeAddOp2(v,OP_Transaction, iDb, (mask & pParse->writeMask)!=0); if( db->init.busy==0 ){ + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); sqlite3VdbeAddOp3(v, OP_VerifyCookie, iDb, pParse->cookieValue[iDb], db->aDb[iDb].pSchema->iGeneration); @@ -271,9 +272,12 @@ Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){ int nName; assert( zName!=0 ); nName = sqlite3Strlen30(zName); + /* All mutexes are required for schema access. Make sure we hold them. */ + assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) ); for(i=OMIT_TEMPDB; inDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue; + assert( sqlite3SchemaMutexHeld(db, j, 0) ); p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName, nName); if( p ) break; } @@ -333,11 +337,14 @@ Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){ Index *p = 0; int i; int nName = sqlite3Strlen30(zName); + /* All mutexes are required for schema access. Make sure we hold them. */ + assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) ); for(i=OMIT_TEMPDB; inDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ Schema *pSchema = db->aDb[j].pSchema; assert( pSchema ); if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zName) ) continue; + assert( sqlite3SchemaMutexHeld(db, j, 0) ); p = sqlite3HashFind(&pSchema->idxHash, zName, nName); if( p ) break; } @@ -364,8 +371,10 @@ static void freeIndex(sqlite3 *db, Index *p){ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){ Index *pIndex; int len; - Hash *pHash = &db->aDb[iDb].pSchema->idxHash; + Hash *pHash; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + pHash = &db->aDb[iDb].pSchema->idxHash; len = sqlite3Strlen30(zIdxName); pIndex = sqlite3HashInsert(pHash, zIdxName, len, 0); if( ALWAYS(pIndex) ){ @@ -393,26 +402,40 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){ ** if there were schema changes during the transaction or if a ** schema-cookie mismatch occurs. ** -** If iDb==0 then reset the internal schema tables for all database -** files. If iDb>=1 then reset the internal schema for only the +** If iDb<0 then reset the internal schema tables for all database +** files. If iDb>=0 then reset the internal schema for only the ** single file indicated. */ void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){ int i, j; - assert( iDb>=0 && iDbnDb ); + assert( iDbnDb ); - if( iDb==0 ){ - sqlite3BtreeEnterAll(db); + if( iDb>=0 ){ + /* Case 1: Reset the single schema identified by iDb */ + Db *pDb = &db->aDb[iDb]; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + if( ALWAYS(pDb->pSchema) ){ + sqlite3SchemaClear(pDb->pSchema); + } + /* If any database other than TEMP is reset, then also reset TEMP + ** since TEMP might be holding triggers that reference tables in the + ** other database. + */ + if( iDb!=1 && (pDb = &db->aDb[1])!=0 && ALWAYS(pDb->pSchema) ){ + sqlite3SchemaClear(pDb->pSchema); + } + return; } - for(i=iDb; inDb; i++){ + /* Case 2 (from here to the end): Reset all schemas for all attached + ** databases. */ + assert( iDb<0 ); + sqlite3BtreeEnterAll(db); + for(i=0; inDb; i++){ Db *pDb = &db->aDb[i]; if( pDb->pSchema ){ - assert(i==1 || (pDb->pBt && sqlite3BtreeHoldsMutex(pDb->pBt))); - sqlite3SchemaFree(pDb->pSchema); + sqlite3SchemaClear(pDb->pSchema); } - if( iDb>0 ) return; } - assert( iDb==0 ); db->flags &= ~SQLITE_InternChanges; sqlite3VtabUnlockList(db); sqlite3BtreeLeaveAll(db); @@ -498,6 +521,7 @@ void sqlite3DeleteTable(sqlite3 *db, Table *pTable){ TESTONLY ( Index *pOld = ) sqlite3HashInsert( &pIndex->pSchema->idxHash, zName, sqlite3Strlen30(zName), 0 ); + assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); assert( pOld==pIndex || pOld==0 ); } freeIndex(db, pIndex); @@ -532,6 +556,7 @@ void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){ assert( db!=0 ); assert( iDb>=0 && iDbnDb ); assert( zTabName ); + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */ pDb = &db->aDb[iDb]; p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, @@ -816,6 +841,7 @@ void sqlite3StartTable( */ #ifndef SQLITE_OMIT_AUTOINCREMENT if( !pParse->nested && strcmp(zName, "sqlite_sequence")==0 ){ + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); pTable->pSchema->pSeqTab = pTable; } #endif @@ -1276,6 +1302,7 @@ void sqlite3ChangeCookie(Parse *pParse, int iDb){ int r1 = sqlite3GetTempReg(pParse); sqlite3 *db = pParse->db; Vdbe *v = pParse->pVdbe; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); sqlite3VdbeAddOp2(v, OP_Integer, db->aDb[iDb].pSchema->schema_cookie+1, r1); sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1); sqlite3ReleaseTempReg(pParse, r1); @@ -1578,6 +1605,7 @@ void sqlite3EndTable( */ if( p->tabFlags & TF_Autoincrement ){ Db *pDb = &db->aDb[iDb]; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); if( pDb->pSchema->pSeqTab==0 ){ sqlite3NestedParse(pParse, "CREATE TABLE %Q.sqlite_sequence(name,seq)", @@ -1598,6 +1626,7 @@ void sqlite3EndTable( if( db->init.busy ){ Table *pOld; Schema *pSchema = p->pSchema; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, sqlite3Strlen30(p->zName),p); if( pOld ){ @@ -1782,6 +1811,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ pSelTab->nCol = 0; pSelTab->aCol = 0; sqlite3DeleteTable(db, pSelTab); + assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); pTable->pSchema->flags |= DB_UnresetViews; }else{ pTable->nCol = 0; @@ -1802,6 +1832,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ */ static void sqliteViewResetAll(sqlite3 *db, int idx){ HashElem *i; + assert( sqlite3SchemaMutexHeld(db, idx, 0) ); if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){ Table *pTab = sqliteHashData(i); @@ -1835,10 +1866,13 @@ static void sqliteViewResetAll(sqlite3 *db, int idx){ ** in order to be certain that we got the right one. */ #ifndef SQLITE_OMIT_AUTOVACUUM -void sqlite3RootPageMoved(Db *pDb, int iFrom, int iTo){ +void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){ HashElem *pElem; Hash *pHash; + Db *pDb; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + pDb = &db->aDb[iDb]; pHash = &pDb->pSchema->tblHash; for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); @@ -2212,6 +2246,7 @@ void sqlite3CreateForeignKey( pFKey->aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */ pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */ + assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) ); pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash, pFKey->zTo, sqlite3Strlen30(pFKey->zTo), (void *)pFKey ); @@ -2567,6 +2602,7 @@ Index *sqlite3CreateIndex( pIndex->onError = (u8)onError; pIndex->autoIndex = (u8)(pName==0); pIndex->pSchema = db->aDb[iDb].pSchema; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); /* Check to see if we should honor DESC requests on index columns */ @@ -2696,6 +2732,7 @@ Index *sqlite3CreateIndex( */ if( db->init.busy ){ Index *p; + assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); p = sqlite3HashInsert(&pIndex->pSchema->idxHash, pIndex->zName, sqlite3Strlen30(pIndex->zName), pIndex); @@ -3449,6 +3486,7 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ assert( iDbnDb ); assert( db->aDb[iDb].pBt!=0 || iDb==1 ); assert( iDbcookieMask & mask)==0 ){ pToplevel->cookieMask |= mask; @@ -3576,6 +3614,7 @@ static void reindexDatabases(Parse *pParse, char const *zColl){ HashElem *k; /* For looping over tables in pDb */ Table *pTab; /* A table in the database */ + assert( sqlite3BtreeHoldsAllMutexes(db) ); /* Needed for schema access */ for(iDb=0, pDb=db->aDb; iDbnDb; iDb++, pDb++){ assert( pDb!=0 ); for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){ diff --git a/src/callback.c b/src/callback.c index fdee9bc09c..ce849085c2 100644 --- a/src/callback.c +++ b/src/callback.c @@ -400,12 +400,12 @@ FuncDef *sqlite3FindFunction( /* ** Free all resources held by the schema structure. The void* argument points ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the -** pointer itself, it just cleans up subsiduary resources (i.e. the contents +** pointer itself, it just cleans up subsidiary resources (i.e. the contents ** of the schema hash tables). ** ** The Schema.cache_size variable is not cleared. */ -void sqlite3SchemaFree(void *p){ +void sqlite3SchemaClear(void *p){ Hash temp1; Hash temp2; HashElem *pElem; @@ -440,7 +440,7 @@ void sqlite3SchemaFree(void *p){ Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){ Schema * p; if( pBt ){ - p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaFree); + p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear); }else{ p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema)); } diff --git a/src/delete.c b/src/delete.c index 8a44d12247..8789fd2e5e 100644 --- a/src/delete.c +++ b/src/delete.c @@ -15,9 +15,18 @@ #include "sqliteInt.h" /* -** Look up every table that is named in pSrc. If any table is not found, -** add an error message to pParse->zErrMsg and return NULL. If all tables -** are found, return a pointer to the last table. +** While a SrcList can in general represent multiple tables and subqueries +** (as in the FROM clause of a SELECT statement) in this case it contains +** the name of a single table, as one might find in an INSERT, DELETE, +** or UPDATE statement. Look up that table in the symbol table and +** return a pointer. Set an error message and return NULL if the table +** name is not found or if any other error occurs. +** +** The following fields are initialized appropriate in pSrc: +** +** pSrc->a[0].pTab Pointer to the Table object +** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one +** */ Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ struct SrcList_item *pItem = pSrc->a; @@ -639,7 +648,7 @@ int sqlite3GenerateIndexKey( } if( doMakeRec ){ sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0); + sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); } sqlite3ReleaseTempRange(pParse, regBase, nCol+1); return regBase; diff --git a/src/expr.c b/src/expr.c index f80ae2ba2d..c0e9ba6fd5 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2345,7 +2345,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ assert( pExpr->u.zToken[0]!=0 ); sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target); if( pExpr->u.zToken[1]!=0 ){ - sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, 0); + sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, P4_TRANSIENT); } break; } diff --git a/src/fkey.c b/src/fkey.c index 653cc1833a..34fdfda5d9 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -398,7 +398,7 @@ static void fkLookupParent( } sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec); - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0); + sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); sqlite3ReleaseTempReg(pParse, regRec); @@ -1154,6 +1154,7 @@ void sqlite3FkDelete(sqlite3 *db, Table *pTab){ FKey *pFKey; /* Iterator variable */ FKey *pNext; /* Copy of pFKey->pNextFrom */ + assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){ /* Remove the FK from the fkeyHash hash table. */ diff --git a/src/insert.c b/src/insert.c index 364e68460f..c76e8249b6 100644 --- a/src/insert.c +++ b/src/insert.c @@ -123,7 +123,7 @@ void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){ pTab->zColAff = zColAff; } - sqlite3VdbeChangeP4(v, -1, pTab->zColAff, 0); + sqlite3VdbeChangeP4(v, -1, pTab->zColAff, P4_TRANSIENT); } /* @@ -237,6 +237,7 @@ void sqlite3AutoincrementBegin(Parse *pParse){ for(p = pParse->pAinc; p; p = p->pNext){ pDb = &db->aDb[p->iDb]; memId = p->regCtr; + assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) ); sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead); addr = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, p->pTab->zName, 0); @@ -287,6 +288,7 @@ void sqlite3AutoincrementEnd(Parse *pParse){ int memId = p->regCtr; iRec = sqlite3GetTempReg(pParse); + assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) ); sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite); j1 = sqlite3VdbeAddOp1(v, OP_NotNull, memId+1); j2 = sqlite3VdbeAddOp0(v, OP_Rewind); @@ -1337,7 +1339,7 @@ void sqlite3GenerateConstraintChecks( } sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i); sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn+1, aRegIdx[iCur]); - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0); + sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn+1); #ifdef SQLITE_OMIT_UNIQUE_ENFORCEMENT diff --git a/src/main.c b/src/main.c index 21991c558f..1d566fecb1 100644 --- a/src/main.c +++ b/src/main.c @@ -687,7 +687,8 @@ int sqlite3_close(sqlite3 *db){ } sqlite3_mutex_enter(db->mutex); - sqlite3ResetInternalSchema(db, 0); + /* Force xDestroy calls on all virtual tables */ + sqlite3ResetInternalSchema(db, -1); /* If a transaction is open, the ResetInternalSchema() call above ** will not have called the xDisconnect() method on any virtual @@ -730,7 +731,7 @@ int sqlite3_close(sqlite3 *db){ } } } - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); /* Tell the code in notify.c that the connection no longer holds any ** locks and does not require any further unlock-notify callbacks. @@ -821,7 +822,7 @@ void sqlite3RollbackAll(sqlite3 *db){ if( db->flags&SQLITE_InternChanges ){ sqlite3ExpirePreparedStatements(db); - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); } /* Any deferred constraint violations have now been resolved. */ diff --git a/src/pragma.c b/src/pragma.c index db55e4bb41..75ab26d441 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -115,7 +115,7 @@ static int invalidateTempStorage(Parse *pParse){ } sqlite3BtreeClose(db->aDb[1].pBt); db->aDb[1].pBt = 0; - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); } return SQLITE_OK; } @@ -388,6 +388,7 @@ void sqlite3Pragma( sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3VdbeAddOp2(v, OP_Integer, size, 1); sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1); + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); pDb->pSchema->cache_size = size; sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); } @@ -690,6 +691,7 @@ void sqlite3Pragma( */ if( sqlite3StrICmp(zLeft,"cache_size")==0 ){ if( sqlite3ReadSchema(pParse) ) goto pragma_out; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); if( !zRight ){ returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size); }else{ @@ -1110,6 +1112,7 @@ void sqlite3Pragma( ** Begin by filling registers 2, 3, ... with the root pages numbers ** for all tables and indices in the database. */ + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); pTbls = &db->aDb[i].pSchema->tblHash; for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ Table *pTab = sqliteHashData(x); @@ -1175,7 +1178,7 @@ void sqlite3Pragma( addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC); sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC); - sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_STATIC); + sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT); sqlite3VdbeJumpHere(v, addr+9); sqlite3VdbeJumpHere(v, jmp2); } @@ -1205,7 +1208,7 @@ void sqlite3Pragma( sqlite3VdbeJumpHere(v, addr+4); sqlite3VdbeChangeP4(v, addr+6, "wrong # of entries in index ", P4_STATIC); - sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_STATIC); + sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT); } } } diff --git a/src/prepare.c b/src/prepare.c index 45654ecfca..b5edaf5032 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -338,7 +338,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ } if( db->mallocFailed ){ rc = SQLITE_NOMEM; - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); } if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){ /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider @@ -470,7 +470,9 @@ static void schemaIsValid(Parse *pParse){ ** value stored as part of the in-memory schema representation, ** set Parse.rc to SQLITE_SCHEMA. */ sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie); + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){ + sqlite3ResetInternalSchema(db, iDb); pParse->rc = SQLITE_SCHEMA; } @@ -612,9 +614,6 @@ static int sqlite3Prepare( if( pParse->checkSchema ){ schemaIsValid(pParse); } - if( pParse->rc==SQLITE_SCHEMA ){ - sqlite3ResetInternalSchema(db, 0); - } if( db->mallocFailed ){ pParse->rc = SQLITE_NOMEM; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ce1e106df8..33e4aba842 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -669,6 +669,20 @@ struct Db { /* ** An instance of the following structure stores a database schema. +** +** Most Schema objects are associated with a Btree. The exception is +** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. +** In shared cache mode, a single Schema object can be shared by multiple +** Btrees that refer to the same underlying BtShared object. +** +** Schema objects are automatically deallocated when the last Btree that +** references them is destroyed. The TEMP Schema is manually freed by +** sqlite3_close(). +* +** A thread must be holding a mutex on the corresponding Btree in order +** to access Schema content. This implies that the thread must also be +** holding a mutex on the sqlite3 connection pointer that owns the Btree. +** For a TEMP Schema, on the connection mutex is required. */ struct Schema { int schema_cookie; /* Database schema version number for this file */ @@ -1192,7 +1206,7 @@ struct CollSeq { ** schema is shared, as the implementation often stores the database ** connection handle passed to it via the xConnect() or xCreate() method ** during initialization internally. This database connection handle may -** then used by the virtual table implementation to access real tables +** then be used by the virtual table implementation to access real tables ** within the database. So that they appear as part of the callers ** transaction, these accesses need to be made via the same database ** connection as that used to execute SQL operations on the virtual table. @@ -2951,7 +2965,7 @@ extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions; extern int sqlite3PendingByte; #endif #endif -void sqlite3RootPageMoved(Db*, int, int); +void sqlite3RootPageMoved(sqlite3*, int, int, int); void sqlite3Reindex(Parse*, Token*, Token*); void sqlite3AlterFunctions(void); void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); @@ -2978,7 +2992,7 @@ void sqlite3DefaultRowEst(Index*); void sqlite3RegisterLikeFunctions(sqlite3*, int); int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*); void sqlite3MinimumFileFormat(Parse*, int, int); -void sqlite3SchemaFree(void *); +void sqlite3SchemaClear(void *); Schema *sqlite3SchemaGet(sqlite3 *, Btree *); int sqlite3SchemaToIndex(sqlite3 *db, Schema *); KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *); diff --git a/src/status.c b/src/status.c index 96759fda7e..b8c1d58df7 100644 --- a/src/status.c +++ b/src/status.c @@ -163,6 +163,7 @@ int sqlite3_db_status( int i; /* Used to iterate through schemas */ int nByte = 0; /* Used to accumulate return value */ + sqlite3BtreeEnterAll(db); db->pnBytesFreed = &nByte; for(i=0; inDb; i++){ Schema *pSchema = db->aDb[i].pSchema; @@ -189,6 +190,7 @@ int sqlite3_db_status( } } db->pnBytesFreed = 0; + sqlite3BtreeLeaveAll(db); *pHighwater = 0; *pCurrent = nByte; diff --git a/src/test4.c b/src/test4.c index 49447d351e..5c94370a3d 100644 --- a/src/test4.c +++ b/src/test4.c @@ -13,7 +13,7 @@ */ #include "sqliteInt.h" #include "tcl.h" -#if defined(SQLITE_OS_UNIX) && OS_UNIX==1 && SQLITE_THREADSAFE +#if SQLITE_OS_UNIX && SQLITE_THREADSAFE #include #include #include diff --git a/src/test7.c b/src/test7.c index 3383d868d3..852cd1db5e 100644 --- a/src/test7.c +++ b/src/test7.c @@ -20,7 +20,7 @@ ** the SQLITE_SERVER option. */ #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) && \ - defined(SQLITE_OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE + SQLITE_OS_UNIX && SQLITE_THREADSAFE #include #include diff --git a/src/test_demovfs.c b/src/test_demovfs.c index 8c51192b4c..e56e8065cf 100644 --- a/src/test_demovfs.c +++ b/src/test_demovfs.c @@ -115,7 +115,7 @@ ** operations. */ -#if !defined(SQLITE_TEST) || defined(SQLITE_OS_UNIX) +#if !defined(SQLITE_TEST) || SQLITE_OS_UNIX #include @@ -637,14 +637,14 @@ sqlite3_vfs *sqlite3_demovfs(void){ return &demovfs; } -#endif /* !defined(SQLITE_TEST) || defined(SQLITE_OS_UNIX) */ +#endif /* !defined(SQLITE_TEST) || SQLITE_OS_UNIX */ #ifdef SQLITE_TEST #include -#ifdef SQLITE_OS_UNIX +#if SQLITE_OS_UNIX static int register_demovfs( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ diff --git a/src/test_osinst.c b/src/test_osinst.c index 25e9bcbfb0..50d6250e6c 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -213,14 +213,14 @@ static sqlite3_io_methods vfslog_io_methods = { vfslogShmUnmap /* xShmUnmap */ }; -#if defined(SQLITE_OS_UNIX) && !defined(NO_GETTOD) +#if SQLITE_OS_UNIX && !defined(NO_GETTOD) #include static sqlite3_uint64 vfslog_time(){ struct timeval sTime; gettimeofday(&sTime, 0); return sTime.tv_usec + (sqlite3_uint64)sTime.tv_sec * 1000000; } -#elif defined(SQLITE_OS_WIN) +#elif SQLITE_OS_WIN #include #include static sqlite3_uint64 vfslog_time(){ diff --git a/src/test_server.c b/src/test_server.c index 3eb7544428..f7b596c78a 100644 --- a/src/test_server.c +++ b/src/test_server.c @@ -206,7 +206,7 @@ ** and only if the SQLITE_SERVER macro is defined. */ #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) -#if defined(SQLITE_OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE +#if SQLITE_OS_UNIX && SQLITE_THREADSAFE /* ** We require only pthreads and the public interface of SQLite. @@ -487,5 +487,5 @@ void sqlite3_server_stop(void){ pthread_mutex_unlock(&g.serverMutex); } -#endif /* defined(SQLITE_OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE */ +#endif /* SQLITE_OS_UNIX && SQLITE_THREADSAFE */ #endif /* defined(SQLITE_SERVER) */ diff --git a/src/test_syscall.c b/src/test_syscall.c index c570b71e81..b8b05c5903 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -75,7 +75,8 @@ #include #include -#ifdef SQLITE_OS_UNIX +#include "sqliteInt.h" +#if SQLITE_OS_UNIX /* From test1.c */ extern const char *sqlite3TestErrorName(int); diff --git a/src/test_thread.c b/src/test_thread.c index af38d91843..ef191bc2d7 100644 --- a/src/test_thread.c +++ b/src/test_thread.c @@ -53,7 +53,7 @@ struct EvalEvent { static Tcl_ObjCmdProc sqlthread_proc; static Tcl_ObjCmdProc clock_seconds_proc; -#if defined(SQLITE_OS_UNIX) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) +#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) static Tcl_ObjCmdProc blocking_step_proc; static Tcl_ObjCmdProc blocking_prepare_v2_proc; #endif @@ -116,7 +116,7 @@ static Tcl_ThreadCreateType tclScriptThread(ClientData pSqlThread){ interp = Tcl_CreateInterp(); Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0); Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, pSqlThread, 0); -#if defined(SQLITE_OS_UNIX) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) +#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) Tcl_CreateObjCommand(interp, "sqlite3_blocking_step", blocking_step_proc,0,0); Tcl_CreateObjCommand(interp, "sqlite3_blocking_prepare_v2", blocking_prepare_v2_proc, (void *)1, 0); @@ -392,7 +392,7 @@ static int clock_seconds_proc( ** should be considered if these functions are to be extended (i.e. to ** support windows) in the future. */ -#if defined(SQLITE_OS_UNIX) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) +#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) /* BEGIN_SQLITE_BLOCKING_STEP */ /* This example uses the pthreads API */ @@ -614,7 +614,7 @@ static int blocking_prepare_v2_proc( int SqlitetestThread_Init(Tcl_Interp *interp){ Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, 0, 0); Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0); -#if defined(SQLITE_OS_UNIX) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) +#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) Tcl_CreateObjCommand(interp, "sqlite3_blocking_step", blocking_step_proc,0,0); Tcl_CreateObjCommand(interp, "sqlite3_blocking_prepare_v2", blocking_prepare_v2_proc, (void *)1, 0); diff --git a/src/trigger.c b/src/trigger.c index f66833522b..8a050eac50 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -54,6 +54,7 @@ Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){ if( pTmpSchema!=pTab->pSchema ){ HashElem *p; + assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) ); for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){ Trigger *pTrig = (Trigger *)sqliteHashData(p); if( pTrig->pTabSchema==pTab->pSchema @@ -165,6 +166,7 @@ void sqlite3BeginTrigger( if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto trigger_cleanup; } + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName, sqlite3Strlen30(zName)) ){ if( !noErr ){ @@ -304,6 +306,7 @@ void sqlite3FinishTrigger( if( db->init.busy ){ Trigger *pLink = pTrig; Hash *pHash = &db->aDb[iDb].pSchema->trigHash; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); pTrig = sqlite3HashInsert(pHash, zName, sqlite3Strlen30(zName), pTrig); if( pTrig ){ db->mallocFailed = 1; @@ -485,9 +488,11 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){ zDb = pName->a[0].zDatabase; zName = pName->a[0].zName; nName = sqlite3Strlen30(zName); + assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) ); for(i=OMIT_TEMPDB; inDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue; + assert( sqlite3SchemaMutexHeld(db, j, 0) ); pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName); if( pTrigger ) break; } @@ -561,7 +566,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3OpenMasterTable(pParse, iDb); base = sqlite3VdbeAddOpList(v, ArraySize(dropTrigger), dropTrigger); - sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, 0); + sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT); sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC); sqlite3ChangeCookie(pParse, iDb); sqlite3VdbeAddOp2(v, OP_Close, 0, 0); @@ -576,8 +581,11 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ ** Remove a trigger from the hash tables of the sqlite* pointer. */ void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){ - Hash *pHash = &(db->aDb[iDb].pSchema->trigHash); Trigger *pTrigger; + Hash *pHash; + + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + pHash = &(db->aDb[iDb].pSchema->trigHash); pTrigger = sqlite3HashInsert(pHash, zName, sqlite3Strlen30(zName), 0); if( ALWAYS(pTrigger) ){ if( pTrigger->pSchema==pTrigger->pTabSchema ){ diff --git a/src/vacuum.c b/src/vacuum.c index 4babf5b409..5a4ed32052 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -335,8 +335,11 @@ end_of_vacuum: pDb->pSchema = 0; } - sqlite3ResetInternalSchema(db, 0); + /* This both clears the schemas and reduces the size of the db->aDb[] + ** array. */ + sqlite3ResetInternalSchema(db, -1); return rc; } + #endif /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ diff --git a/src/vdbe.c b/src/vdbe.c index b0e66317c6..4820ab5094 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -561,7 +561,7 @@ int sqlite3VdbeExec( Op *pOp; /* Current operation */ int rc = SQLITE_OK; /* Value to return */ sqlite3 *db = p->db; /* The database */ - u8 resetSchemaOnFault = 0; /* Reset schema after an error if true */ + u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ u8 encoding = ENC(db); /* The database encoding */ #ifndef SQLITE_OMIT_PROGRESS_CALLBACK int checkProgress; /* True if progress callbacks are enabled */ @@ -2669,7 +2669,7 @@ case OP_Savepoint: { } if( p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){ sqlite3ExpirePreparedStatements(db); - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); sqlite3VdbeMutexResync(p); db->flags = (db->flags | SQLITE_InternChanges); } @@ -2890,6 +2890,7 @@ case OP_SetCookie: { /* in3 */ assert( (p->btreeMask & (((yDbMask)1)<p1))!=0 ); pDb = &db->aDb[pOp->p1]; assert( pDb->pBt!=0 ); + assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) ); pIn3 = &aMem[pOp->p3]; sqlite3VdbeMemIntegerify(pIn3); /* See note about index shifting on OP_ReadCookie */ @@ -2936,6 +2937,7 @@ case OP_VerifyCookie: { assert( pOp->p1>=0 && pOp->p1nDb ); assert( (p->btreeMask & (((yDbMask)1)<p1))!=0 ); + assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) ); pBt = db->aDb[pOp->p1].pBt; if( pBt ){ sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta); @@ -2961,7 +2963,6 @@ case OP_VerifyCookie: { */ if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){ sqlite3ResetInternalSchema(db, pOp->p1); - sqlite3VdbeMutexResync(p); } p->expired = 1; @@ -3046,6 +3047,7 @@ case OP_OpenWrite: { assert( pX!=0 ); if( pOp->opcode==OP_OpenWrite ){ wrFlag = 1; + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); if( pDb->pSchema->file_format < p->minWriteFileFormat ){ p->minWriteFileFormat = pDb->pSchema->file_format; } @@ -4583,8 +4585,10 @@ case OP_Destroy: { /* out2-prerelease */ pOut->u.i = iMoved; #ifndef SQLITE_OMIT_AUTOVACUUM if( rc==SQLITE_OK && iMoved!=0 ){ - sqlite3RootPageMoved(&db->aDb[iDb], iMoved, pOp->p1); - resetSchemaOnFault = 1; + sqlite3RootPageMoved(db, iDb, iMoved, pOp->p1); + /* All OP_Destroy operations occur on the same btree */ + assert( resetSchemaOnFault==0 || resetSchemaOnFault==iDb+1 ); + resetSchemaOnFault = iDb+1; } #endif } @@ -6018,9 +6022,8 @@ vdbe_error_halt: sqlite3VdbeHalt(p); if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1; rc = SQLITE_ERROR; - if( resetSchemaOnFault ){ - sqlite3ResetInternalSchema(db, 0); - sqlite3VdbeMutexResync(p); + if( resetSchemaOnFault>0 ){ + sqlite3ResetInternalSchema(db, resetSchemaOnFault-1); } /* This is the only way out of this procedure. We have to diff --git a/src/vdbe.h b/src/vdbe.h index 2a6fe95fd4..ef6b99fb38 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -109,7 +109,7 @@ typedef struct VdbeOpList VdbeOpList; #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */ #define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */ #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */ -#define P4_TRANSIENT (-9) /* P4 is a pointer to a transient string */ +#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */ #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */ #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */ #define P4_REAL (-12) /* P4 is a 64-bit floating point value */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 16eeb5ce18..488c1d60ce 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2279,7 +2279,7 @@ int sqlite3VdbeHalt(Vdbe *p){ /* Rollback or commit any schema changes that occurred. */ if( p->rc!=SQLITE_OK && db->flags&SQLITE_InternChanges ){ - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); db->flags = (db->flags | SQLITE_InternChanges); } diff --git a/src/vtab.c b/src/vtab.c index b9f1e6f348..b052de23a5 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -48,7 +48,7 @@ static int createModule( if( pDel==pMod ){ db->mallocFailed = 1; } - sqlite3ResetInternalSchema(db, 0); + sqlite3ResetInternalSchema(db, -1); }else if( xDestroy ){ xDestroy(pAux); } @@ -145,10 +145,9 @@ static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){ ** that contains table p is held by the caller. See header comments ** above function sqlite3VtabUnlockList() for an explanation of why ** this makes it safe to access the sqlite3.pDisconnect list of any - ** database connection that may have an entry in the p->pVTable list. */ - assert( db==0 || - sqlite3BtreeHoldsMutex(db->aDb[sqlite3SchemaToIndex(db, p->pSchema)].pBt) - ); + ** database connection that may have an entry in the p->pVTable list. + */ + assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) ); while( pVTable ){ sqlite3 *db2 = pVTable->db; @@ -387,6 +386,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ Schema *pSchema = pTab->pSchema; const char *zName = pTab->zName; int nName = sqlite3Strlen30(zName); + assert( sqlite3SchemaMutexHeld(db, 0, pSchema) ); pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab); if( pOld ){ db->mallocFailed = 1; diff --git a/test/e_expr.test b/test/e_expr.test index 437e88b1d8..1e7685352e 100644 --- a/test/e_expr.test +++ b/test/e_expr.test @@ -1444,16 +1444,20 @@ do_qexpr_test e_expr-27.4.2 { CAST(456 AS blob) } X'343536' do_qexpr_test e_expr-27.4.3 { CAST(1.78 AS blob) } X'312E3738' rename db db2 sqlite3 db :memory: +ifcapable {utf16} { db eval { PRAGMA encoding = 'utf-16le' } do_qexpr_test e_expr-27.4.4 { CAST('ghi' AS blob) } X'670068006900' do_qexpr_test e_expr-27.4.5 { CAST(456 AS blob) } X'340035003600' do_qexpr_test e_expr-27.4.6 { CAST(1.78 AS blob) } X'31002E0037003800' +} db close sqlite3 db :memory: db eval { PRAGMA encoding = 'utf-16be' } +ifcapable {utf16} { do_qexpr_test e_expr-27.4.7 { CAST('ghi' AS blob) } X'006700680069' do_qexpr_test e_expr-27.4.8 { CAST(456 AS blob) } X'003400350036' do_qexpr_test e_expr-27.4.9 { CAST(1.78 AS blob) } X'0031002E00370038' +} db close rename db2 db @@ -1466,8 +1470,10 @@ do_expr_test e_expr-28.1.2 { CAST (X'670068006900' AS text) } text g rename db db2 sqlite3 db :memory: db eval { PRAGMA encoding = 'utf-16le' } +ifcapable {utf16} { do_expr_test e_expr-28.1.3 { CAST (X'676869' AS text) == 'ghi' } integer 0 do_expr_test e_expr-28.1.4 { CAST (X'670068006900' AS text) } text ghi +} db close rename db2 db @@ -1493,6 +1499,7 @@ do_expr_test e_expr-29.1.3 { CAST (X'2D392E3837' AS REAL) } real -9.87 do_expr_test e_expr-29.1.4 { CAST (X'302E30303031' AS REAL) } real 0.0001 rename db db2 sqlite3 db :memory: +ifcapable {utf16} { db eval { PRAGMA encoding = 'utf-16le' } do_expr_test e_expr-29.1.5 { CAST (X'31002E0032003300' AS REAL) } real 1.23 @@ -1502,6 +1509,7 @@ do_expr_test e_expr-29.1.7 { CAST (X'2D0039002E0038003700' AS REAL) } real -9.87 do_expr_test e_expr-29.1.8 { CAST (X'30002E003000300030003100' AS REAL) } real 0.0001 +} db close rename db2 db @@ -1543,6 +1551,7 @@ do_expr_test e_expr-30.1.4 { rename db db2 sqlite3 db :memory: +ifcapable {utf16} { execsql { PRAGMA encoding = 'utf-16be' } do_expr_test e_expr-30.1.5 { CAST(X'003100320033' AS INTEGER) } integer 123 do_expr_test e_expr-30.1.6 { CAST(X'002D003600370038' AS INTEGER) } integer -678 @@ -1552,6 +1561,7 @@ do_expr_test e_expr-30.1.7 { do_expr_test e_expr-30.1.8 { CAST(X'002D0031003100320035003800390039003900300036003800340032003600320034' AS INTEGER) } integer -1125899906842624 +} db close rename db2 db @@ -1632,6 +1642,7 @@ do_expr_test e_expr-32.2.4 { # into a non-BLOB value may be different depending on whether the # database encoding is UTF-8, UTF-16be, or UTF-16le. # +ifcapable {utf16} { sqlite3 db1 :memory: ; db1 eval { PRAGMA encoding = 'utf-8' } sqlite3 db2 :memory: ; db2 eval { PRAGMA encoding = 'utf-16le' } sqlite3 db3 :memory: ; db3 eval { PRAGMA encoding = 'utf-16be' } @@ -1658,6 +1669,7 @@ foreach {tn castexpr differs} { db1 close db2 close db3 close +} #------------------------------------------------------------------------- # Test statements related to the EXISTS and NOT EXISTS operators. diff --git a/test/e_vacuum.test b/test/e_vacuum.test index a7863c4568..414c854d11 100644 --- a/test/e_vacuum.test +++ b/test/e_vacuum.test @@ -175,6 +175,7 @@ do_test e_vacuum-1.3.2.1 { # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the # auto_vacuum support property can be changed using VACUUM. # +ifcapable wal { do_test e_vacuum-1.3.3.1 { execsql { PRAGMA journal_mode = wal } execsql { PRAGMA page_size ; PRAGMA auto_vacuum } @@ -185,6 +186,7 @@ do_test e_vacuum-1.3.3.2 { execsql VACUUM execsql { PRAGMA page_size ; PRAGMA auto_vacuum } } {2048 1} +} # EVIDENCE-OF: R-38001-03952 VACUUM only works on the main database. It # is not possible to VACUUM an attached database file. diff --git a/test/malloc.test b/test/malloc.test index f1eee17ecd..678b2be075 100644 --- a/test/malloc.test +++ b/test/malloc.test @@ -867,7 +867,7 @@ if {[db eval {PRAGMA locking_mode}]!="exclusive"} { catch { db2 close } } -ifcapable stat2 { +ifcapable stat2&&utf16 { do_malloc_test 38 -tclprep { add_test_collate db 0 0 1 execsql { diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 71ad4311b5..788816b169 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -64,7 +64,6 @@ array set ::Configs { -O2 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_THREADSAFE - -DOS_UNIX -DSQLITE_TCL_DEFAULT_FULLMUTEX=1 } "Secure-Delete" { diff --git a/test/tester.tcl b/test/tester.tcl index 4c7c10ed73..bae10530c6 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -154,6 +154,7 @@ if {[info exists cmdlinearg]==0} { # --backtrace=N # --binarylog=N # --soak=N + # --start=[$permutation:]$testfile # set cmdlinearg(soft-heap-limit) 0 set cmdlinearg(maxerror) 1000 @@ -161,6 +162,7 @@ if {[info exists cmdlinearg]==0} { set cmdlinearg(backtrace) 10 set cmdlinearg(binarylog) 0 set cmdlinearg(soak) 0 + set cmdlinearg(start) "" set leftover [list] foreach a $argv { @@ -195,6 +197,16 @@ if {[info exists cmdlinearg]==0} { foreach {dummy cmdlinearg(soak)} [split $a =] break set ::G(issoak) $cmdlinearg(soak) } + {^-+start=.+$} { + foreach {dummy cmdlinearg(start)} [split $a =] break + + set ::G(start:file) $cmdlinearg(start) + if {[regexp {(.*):(.*)} $cmdlinearg(start) -> s.perm s.file]} { + set ::G(start:permutation) ${s.perm} + set ::G(start:file) ${s.file} + } + if {$::G(start:file) == ""} {unset ::G(start:file)} + } default { lappend leftover $a } @@ -1325,6 +1337,15 @@ proc slave_test_script {script} { proc slave_test_file {zFile} { set tail [file tail $zFile] + if {[info exists ::G(start:permutation)]} { + if {[permutation] != $::G(start:permutation)} return + unset ::G(start:permutation) + } + if {[info exists ::G(start:file)]} { + if {$tail != $::G(start:file) && $tail!="$::G(start:file).test"} return + unset ::G(start:file) + } + # Remember the value of the shared-cache setting. So that it is possible # to check afterwards that it was not modified by the test script. #