From f6e3e31625898710c298adeaf1a6cec749e62d21 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Aug 2022 14:43:34 +0000 Subject: [PATCH 01/16] Ensure that every pcache page always has either the PGHDR_DIRTY or the PGHDR_CLEAN bit set, even during transient page reshuffling during btree balancing. FossilOrigin-Name: e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 3 ++- src/pcache.c | 35 +++++++++++++++++++++++------------ 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index fe50b5d9fb..5204cf1680 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\ssqlite3_prepare()\sinputs\salways\shave\sa\ssemicolon\sterminator\sin\nspeedtest1. -D 2022-08-25T19:29:35.476 +C Ensure\sthat\severy\spcache\spage\salways\shas\seither\sthe\sPGHDR_DIRTY\sor\sthe\nPGHDR_CLEAN\sbit\sset,\seven\sduring\stransient\spage\sreshuffling\sduring\sbtree\nbalancing. +D 2022-08-27T14:43:34.272 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -528,7 +528,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7 F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d F src/btmutex.c 6ffb0a22c19e2f9110be0964d0731d2ef1c67b5f7fabfbaeb7b9dabc4b7740ca -F src/btree.c 4a8d349b9ed4dc6d252c535227699d75319b633058a56432ebf43c9f56f9085e +F src/btree.c 971276350a2f5703da4ee9b333b0bb14d67e180b9775df6860e09ef4233c60a2 F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22 F src/btreeInt.h 8ce1332edd89dfd2461d561ac10a0ab5601c8e06200cb5230596c3caaf54482e F src/build.c 898884afd67d953808cb687babc15b66a10213f99fe2ce7db98960e959881f98 @@ -578,7 +578,7 @@ F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 -F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b +F src/pcache.c e82ef04f65c0d8c28648f79be10b5ed28f4c5e1b887e21364b09a290109bfdba F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache1.c 0b4245cd4964e635f2630908c2533cd8e9da7af3ca592e23ae8730aa25ae5eb9 F src/pragma.c b57a859a366472131194a9ad35cd76d5920577226b04c884b1b9085605faa280 @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c87d7c58d5aec83f9e2ae3771a81aa17cfae0cf06169025a5db085e2d5749f9 -R 03aae009b62262596bf019082ce9ceed +P c72756b0f2db30c622f00f43be9245d50e36049bd7740ee6332164f0c48f9c3d +R ec0ec294ce77eea8b112655cdb3d953c U drh -Z 8bd158a0ccc4257762e239c65a25bd98 +Z ddf747439ae76e336531030fc778367f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8361278db9..73b1b2c4a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c72756b0f2db30c622f00f43be9245d50e36049bd7740ee6332164f0c48f9c3d \ No newline at end of file +e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 09835fca03..9169199281 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8350,7 +8350,8 @@ static int balance_nonroot( aPgOrder[iBest] = 0xffffffff; if( iBest!=i ){ if( iBest>i ){ - sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, 0); + sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, + aPgFlags[iBest]); } sqlite3PagerRekey(apNew[i]->pDbPage, pgno, aPgFlags[iBest]); apNew[i]->pgno = pgno; diff --git a/src/pcache.c b/src/pcache.c index 14d1e7cde0..379e4ca9e6 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -66,12 +66,20 @@ struct PCache { int sqlite3PcacheTrace = 2; /* 0: off 1: simple 2: cache dumps */ int sqlite3PcacheMxDump = 9999; /* Max cache entries for pcacheDump() */ # define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;} - void pcacheDump(PCache *pCache){ - int N; - int i, j; - sqlite3_pcache_page *pLower; + static void pcachePageTrace(int i, sqlite3_pcache_page *pLower){ PgHdr *pPg; unsigned char *a; + int j; + pPg = (PgHdr*)pLower->pExtra; + printf("%3d: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags); + a = (unsigned char *)pLower->pBuf; + for(j=0; j<12; j++) printf("%02x", a[j]); + printf(" ptr %p\n", pPg); + } + static void pcacheDump(PCache *pCache){ + int N; + int i; + sqlite3_pcache_page *pLower; if( sqlite3PcacheTrace<2 ) return; if( pCache->pCache==0 ) return; @@ -80,18 +88,15 @@ struct PCache { for(i=1; i<=N; i++){ pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0); if( pLower==0 ) continue; - pPg = (PgHdr*)pLower->pExtra; - printf("%3d: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags); - a = (unsigned char *)pLower->pBuf; - for(j=0; j<12; j++) printf("%02x", a[j]); - printf("\n"); - if( pPg->pPage==0 ){ + pcachePageTrace(i, pLower); + if( ((PgHdr*)pLower)->pPage==0 ){ sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0); } } } - #else +#else # define pcacheTrace(X) +# define pcachePageTrace(PGNO, X) # define pcacheDump(X) #endif @@ -115,6 +120,11 @@ int sqlite3PcachePageSanity(PgHdr *pPg){ assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */ assert( pCache->pDirty!=pPg ); /* CLEAN pages not on dirty list */ assert( pCache->pDirtyTail!=pPg ); + }else{ + assert( (pPg->flags & PGHDR_DIRTY)!=0 );/* If not CLEAN must be DIRTY */ + assert( pPg->pDirtyNext==0 || pPg->pDirtyNext->pDirtyPrev==pPg ); + assert( pPg->pDirtyPrev==0 || pPg->pDirtyPrev->pDirtyNext==pPg ); + assert( pPg->pDirtyPrev!=0 || pCache->pDirty==pPg ); } /* WRITEABLE pages must also be DIRTY */ if( pPg->flags & PGHDR_WRITEABLE ){ @@ -388,8 +398,9 @@ sqlite3_pcache_page *sqlite3PcacheFetch( assert( createFlag==0 || pCache->eCreate==eCreate ); assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) ); pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate); - pcacheTrace(("%p.FETCH %d%s (result: %p)\n",pCache,pgno, + pcacheTrace(("%p.FETCH %d%s (result: %p) ",pCache,pgno, createFlag?" create":"",pRes)); + pcachePageTrace(pgno, pRes); return pRes; } From f0f025b340a0af5e183888c5f43e0106a1945502 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 27 Aug 2022 16:11:00 +0000 Subject: [PATCH 02/16] More assert() statements in the page cache. FossilOrigin-Name: 7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache.c | 21 +++++++++++++++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 5204cf1680..30df2a1352 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\severy\spcache\spage\salways\shas\seither\sthe\sPGHDR_DIRTY\sor\sthe\nPGHDR_CLEAN\sbit\sset,\seven\sduring\stransient\spage\sreshuffling\sduring\sbtree\nbalancing. -D 2022-08-27T14:43:34.272 +C More\sassert()\sstatements\sin\sthe\spage\scache. +D 2022-08-27T16:11:00.802 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -578,7 +578,7 @@ F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 -F src/pcache.c e82ef04f65c0d8c28648f79be10b5ed28f4c5e1b887e21364b09a290109bfdba +F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache1.c 0b4245cd4964e635f2630908c2533cd8e9da7af3ca592e23ae8730aa25ae5eb9 F src/pragma.c b57a859a366472131194a9ad35cd76d5920577226b04c884b1b9085605faa280 @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c72756b0f2db30c622f00f43be9245d50e36049bd7740ee6332164f0c48f9c3d -R ec0ec294ce77eea8b112655cdb3d953c +P e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92 +R c207204f107e850d8e2aa83942d0fc9c U drh -Z ddf747439ae76e336531030fc778367f +Z 3df13e569c05286e45e508a55914ef8f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 73b1b2c4a7..a04ed0e9ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92 \ No newline at end of file +7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index 379e4ca9e6..38093dd7a1 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -100,6 +100,20 @@ struct PCache { # define pcacheDump(X) #endif +/* +** Return 1 if pPg is on the dirty list for pCache. Return 0 if not. +** This routine runs inside of assert() statements only. +*/ +#ifdef SQLITE_DEBUG +static int pageOnDirtyList(PCache *pCache, PgHdr *pPg){ + PgHdr *p; + for(p=pCache->pDirty; p; p=p->pDirtyNext){ + if( p==pPg ) return 1; + } + return 0; +} +#endif + /* ** Check invariants on a PgHdr entry. Return true if everything is OK. ** Return false if any invariant is violated. @@ -118,13 +132,13 @@ int sqlite3PcachePageSanity(PgHdr *pPg){ assert( pCache!=0 ); /* Every page has an associated PCache */ if( pPg->flags & PGHDR_CLEAN ){ assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */ - assert( pCache->pDirty!=pPg ); /* CLEAN pages not on dirty list */ - assert( pCache->pDirtyTail!=pPg ); + assert( !pageOnDirtyList(pCache, pPg) );/* CLEAN pages not on dirty list */ }else{ assert( (pPg->flags & PGHDR_DIRTY)!=0 );/* If not CLEAN must be DIRTY */ assert( pPg->pDirtyNext==0 || pPg->pDirtyNext->pDirtyPrev==pPg ); assert( pPg->pDirtyPrev==0 || pPg->pDirtyPrev->pDirtyNext==pPg ); assert( pPg->pDirtyPrev!=0 || pCache->pDirty==pPg ); + assert( pageOnDirtyList(pCache, pPg) ); } /* WRITEABLE pages must also be DIRTY */ if( pPg->flags & PGHDR_WRITEABLE ){ @@ -528,6 +542,7 @@ void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){ pcacheUnpin(p); }else{ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); + assert( sqlite3PcachePageSanity(p) ); } } } @@ -571,6 +586,7 @@ void sqlite3PcacheMakeDirty(PgHdr *p){ pcacheTrace(("%p.DIRTY %d\n",p->pCache,p->pgno)); assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY ); pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD); + assert( sqlite3PcachePageSanity(p) ); } assert( sqlite3PcachePageSanity(p) ); } @@ -641,6 +657,7 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){ p->pgno = newPgno; if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); + assert( sqlite3PcachePageSanity(p) ); } } From 4d28830861c195fcae94d115b926c1a245409106 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Aug 2022 00:11:51 +0000 Subject: [PATCH 03/16] Any function call can abort. Take this into account when deciding if a DML statement needs a statement journal. See [forum:/forumpost/9b9e4716c0d7bbd1|forum thread 9b9e4716c0d7bbd1] for more information. FossilOrigin-Name: 5c95ae6c9b93b9bcf698bb1cad93b2da2e28121b35e7c539b1ddc0ef2de33cfe --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 2 ++ test/json101.test | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 30df2a1352..3c24e60572 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\sassert()\sstatements\sin\sthe\spage\scache. -D 2022-08-27T16:11:00.802 +C Any\sfunction\scall\scan\sabort.\s\sTake\sthis\sinto\saccount\swhen\sdeciding\sif\sa\sDML\nstatement\sneeds\sa\sstatement\sjournal.\s\sSee\n[forum:/forumpost/9b9e4716c0d7bbd1|forum\sthread\s9b9e4716c0d7bbd1]\sfor\smore\ninformation. +D 2022-08-30T00:11:51.654 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -664,7 +664,7 @@ F src/vdbe.c d27ec9a57f752fc2acf6a64d43bbf6072d2415efc976184f6d8a146e65819d3b F src/vdbe.h 64619af62603dc3c4f5ff6ff6d2c8f389abd667a29ce6007ed44bd22b3211cd0 F src/vdbeInt.h 17b7461ffcf9ee760d1341731715a419f6b8c763089a7ece25c2e8098d702b3f F src/vdbeapi.c fc3183daf72808b4311b228989120fdbc2dc44972fb0d77d5c453460cc0e5b2c -F src/vdbeaux.c 1f33d20fc19f13ad781ee083276ffad2204a182617859895db9daa3412456457 +F src/vdbeaux.c c719cebaffa75e166f16a405b3dee96e7150d60fc563ab2dea716b60c6a51312 F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd F src/vdbemem.c c3ce80af15e2ff5c2824a8db881681cbf511376f13613da020bac6d320c535b1 F src/vdbesort.c 43756031ca7430f7aec3ef904824a7883c4ede783e51f280d99b9b65c0796e35 @@ -1202,7 +1202,7 @@ F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ff F test/jrnlmode.test 9b5bc01dac22223cb60ec2d5f97acf568d73820794386de5634dcadbea9e1946 F test/jrnlmode2.test 8759a1d4657c064637f8b079592651530db738419e1d649c6df7048cd724363d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa -F test/json101.test 9d46b8e254c4e23306da175dd226d5c4f164db6b294bcea98e5dcd891ba48c91 +F test/json101.test 9f6337e7423d2c1774d1d485c919fc4e11c8f7e423a2f8831f73471983432108 F test/json102.test 327e77275f338c028faefa2da5164daf6b142a165e3015ff2a6e4251ddc6a0ac F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe F test/json104.test a502dc01853aada95d721b3b275afbe2dc18fffdac1fea6e96fb20c13586bbb5 @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92 -R c207204f107e850d8e2aa83942d0fc9c +P 7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85 +R d226864f8cee6eb0d81fc9d58efcbd85 U drh -Z 3df13e569c05286e45e508a55914ef8f +Z 9f6d1bb5822b24330e59c622b60a8f90 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a04ed0e9ef..7a3219289b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85 \ No newline at end of file +5c95ae6c9b93b9bcf698bb1cad93b2da2e28121b35e7c539b1ddc0ef2de33cfe \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a4b4516c04..8785e3b568 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -388,6 +388,7 @@ int sqlite3VdbeAddFunctionCall( addr = sqlite3VdbeAddOp4(v, eCallCtx ? OP_PureFunc : OP_Function, p1, p2, p3, (char*)pCtx, P4_FUNCCTX); sqlite3VdbeChangeP5(v, eCallCtx & NC_SelfRef); + sqlite3MayAbort(pParse); return addr; } @@ -723,6 +724,7 @@ int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){ || opcode==OP_VDestroy || opcode==OP_VCreate || opcode==OP_ParseSchema + || opcode==OP_Function || opcode==OP_PureFunc || ((opcode==OP_Halt || opcode==OP_HaltIfNull) && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort)) ){ diff --git a/test/json101.test b/test/json101.test index b84846d888..135c988e97 100644 --- a/test/json101.test +++ b/test/json101.test @@ -867,4 +867,22 @@ do_catchsql_test json-18.5 { SELECT json_extract('{"":8}', '$.'); } {1 {JSON path error near ''}} +# 2022-08-29 https://sqlite.org/forum/forumpost/9b9e4716c0d7bbd1 +# This is not a problem specifically with JSON functions. It is +# a problem with transaction control. But the json() function makes +# the problem more easily accessible, so it is tested here. +# +do_execsql_test json-19.1 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(x); +} {} +do_catchsql_test json-19.2 { + BEGIN; + INSERT INTO t1 VALUES(0), (json('not-valid-json')); +} {1 {malformed JSON}} +do_execsql_test json-19.3 { + COMMIT; + SELECT * FROM t1; +} {} + finish_test From 78d15f097a416d25086c31782599af072cad8875 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 30 Aug 2022 16:54:41 +0000 Subject: [PATCH 04/16] Improved comments in pcache1.c. No changes to code. FossilOrigin-Name: dd017bb1b3e31c7692d29dc4865d6bda871e429978c8738a39160d0114e5bf9b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache1.c | 27 ++++++++++++++++----------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 3c24e60572..f883c6ec5e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Any\sfunction\scall\scan\sabort.\s\sTake\sthis\sinto\saccount\swhen\sdeciding\sif\sa\sDML\nstatement\sneeds\sa\sstatement\sjournal.\s\sSee\n[forum:/forumpost/9b9e4716c0d7bbd1|forum\sthread\s9b9e4716c0d7bbd1]\sfor\smore\ninformation. -D 2022-08-30T00:11:51.654 +C Improved\scomments\sin\spcache1.c.\s\sNo\schanges\sto\scode. +D 2022-08-30T16:54:41.472 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -580,7 +580,7 @@ F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 -F src/pcache1.c 0b4245cd4964e635f2630908c2533cd8e9da7af3ca592e23ae8730aa25ae5eb9 +F src/pcache1.c 31c0ae1ee1582138f3efbd807fa242211b79abbcdea7ee9a0e85d05d211a5254 F src/pragma.c b57a859a366472131194a9ad35cd76d5920577226b04c884b1b9085605faa280 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 971d5819a4bda88038c2283d71fc0a2974ffc3dd480f9bd941341017abacfd1b @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85 -R d226864f8cee6eb0d81fc9d58efcbd85 +P 5c95ae6c9b93b9bcf698bb1cad93b2da2e28121b35e7c539b1ddc0ef2de33cfe +R e00004b023ae908464c855a26263b4c9 U drh -Z 9f6d1bb5822b24330e59c622b60a8f90 +Z 3fc6b968a7555fec27eea68c831ab165 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7a3219289b..408f5a079e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c95ae6c9b93b9bcf698bb1cad93b2da2e28121b35e7c539b1ddc0ef2de33cfe \ No newline at end of file +dd017bb1b3e31c7692d29dc4865d6bda871e429978c8738a39160d0114e5bf9b \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 4f84a20b50..d40d9cf4fc 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -106,19 +106,24 @@ typedef struct PGroup PGroup; ** corrupt, code at the b-tree layer may overread the page buffer and ** read part of this structure before the corruption is detected. This ** can cause a valgrind error if the unitialized gap is accessed. Using u16 -** ensures there is no such gap, and therefore no bytes of unitialized memory -** in the structure. +** ensures there is no such gap, and therefore no bytes of uninitialized +** memory in the structure. +** +** The pLruNext and pLruPrev pointers form a double-linked circular list +** of all pages that are unpinned. The PGroup.lru element (which should be +** the only element on the list with PgHdr1.isAnchor set to 1) forms the +** beginning and the end of the list. */ struct PgHdr1 { - sqlite3_pcache_page page; /* Base class. Must be first. pBuf & pExtra */ - unsigned int iKey; /* Key value (page number) */ - u16 isBulkLocal; /* This page from bulk local storage */ - u16 isAnchor; /* This is the PGroup.lru element */ - PgHdr1 *pNext; /* Next in hash table chain */ - PCache1 *pCache; /* Cache that currently owns this page */ - PgHdr1 *pLruNext; /* Next in LRU list of unpinned pages */ - PgHdr1 *pLruPrev; /* Previous in LRU list of unpinned pages */ - /* NB: pLruPrev is only valid if pLruNext!=0 */ + sqlite3_pcache_page page; /* Base class. Must be first. pBuf & pExtra */ + unsigned int iKey; /* Key value (page number) */ + u16 isBulkLocal; /* This page from bulk local storage */ + u16 isAnchor; /* This is the PGroup.lru element */ + PgHdr1 *pNext; /* Next in hash table chain */ + PCache1 *pCache; /* Cache that currently owns this page */ + PgHdr1 *pLruNext; /* Next in circular LRU list of unpinned pages */ + PgHdr1 *pLruPrev; /* Previous in LRU list of unpinned pages */ + /* NB: pLruPrev is only valid if pLruNext!=0 */ }; /* From 9c3a114ca057e319bc0923d25366d1cbf29e225d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 31 Aug 2022 15:04:42 +0000 Subject: [PATCH 05/16] Enhance the b-tree page sorting code to ensure that sqlite3PagerRekey() never overloads a page number and uses only the PENDING_BYTE page for temporary storage. FossilOrigin-Name: 5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435 --- manifest | 14 ++++++------- manifest.uuid | 2 +- src/btree.c | 58 +++++++++++++++++++++++---------------------------- src/pcache1.c | 5 ++++- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/manifest b/manifest index f883c6ec5e..746bbe3c38 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomments\sin\spcache1.c.\s\sNo\schanges\sto\scode. -D 2022-08-30T16:54:41.472 +C Enhance\sthe\sb-tree\spage\ssorting\scode\sto\sensure\sthat\ssqlite3PagerRekey()\snever\noverloads\sa\spage\snumber\sand\suses\sonly\sthe\sPENDING_BYTE\spage\sfor\stemporary\nstorage. +D 2022-08-31T15:04:42.204 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -528,7 +528,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7 F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d F src/btmutex.c 6ffb0a22c19e2f9110be0964d0731d2ef1c67b5f7fabfbaeb7b9dabc4b7740ca -F src/btree.c 971276350a2f5703da4ee9b333b0bb14d67e180b9775df6860e09ef4233c60a2 +F src/btree.c 138804ba7c054533573e87facdfcf9f8aa003c7123152dda8d9281f837ab2622 F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22 F src/btreeInt.h 8ce1332edd89dfd2461d561ac10a0ab5601c8e06200cb5230596c3caaf54482e F src/build.c 898884afd67d953808cb687babc15b66a10213f99fe2ce7db98960e959881f98 @@ -580,7 +580,7 @@ F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 -F src/pcache1.c 31c0ae1ee1582138f3efbd807fa242211b79abbcdea7ee9a0e85d05d211a5254 +F src/pcache1.c 5cde56d6bb057b0d7420f89bebd3bb9103f4ed9acfc17cef765dca8c33cd3a1f F src/pragma.c b57a859a366472131194a9ad35cd76d5920577226b04c884b1b9085605faa280 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 971d5819a4bda88038c2283d71fc0a2974ffc3dd480f9bd941341017abacfd1b @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c95ae6c9b93b9bcf698bb1cad93b2da2e28121b35e7c539b1ddc0ef2de33cfe -R e00004b023ae908464c855a26263b4c9 +P dd017bb1b3e31c7692d29dc4865d6bda871e429978c8738a39160d0114e5bf9b +R 98122ff0aaf5ca87deda59c5c8a25251 U drh -Z 3fc6b968a7555fec27eea68c831ab165 +Z 8d73d18db9ab73a94a9689d17f937c1d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 408f5a079e..00cb077051 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dd017bb1b3e31c7692d29dc4865d6bda871e429978c8738a39160d0114e5bf9b \ No newline at end of file +5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 9169199281..577de2bee2 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7893,8 +7893,6 @@ static int balance_nonroot( Pgno pgno; /* Temp var to store a page number in */ u8 abDone[NB+2]; /* True after i'th new page is populated */ Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */ - Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */ - u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */ CellArray b; /* Parsed information on cells being balanced */ memset(abDone, 0, sizeof(abDone)); @@ -8318,43 +8316,39 @@ static int balance_nonroot( ** of the table is closer to a linear scan through the file. That in turn ** helps the operating system to deliver pages from the disk more rapidly. ** - ** An O(n^2) insertion sort algorithm is used, but since n is never more - ** than (NB+2) (a small constant), that should not be a problem. + ** An O(N*N) sort algorithm is used, but since N is never more than NB+2 + ** (5), that is not a performance concern. ** ** When NB==3, this one optimization makes the database about 25% faster ** for large insertions and deletions. */ for(i=0; ipgno; - aPgFlags[i] = apNew[i]->pDbPage->flags; - for(j=0; jpgno; + assert( apNew[i]->pDbPage->flags & PGHDR_WRITEABLE ); + assert( apNew[i]->pDbPage->flags & PGHDR_DIRTY ); } - for(i=0; ipgno < apNew[iB]->pgno ) iB = j; } - pgno = aPgOrder[iBest]; - aPgOrder[iBest] = 0xffffffff; - if( iBest!=i ){ - if( iBest>i ){ - sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, - aPgFlags[iBest]); - } - sqlite3PagerRekey(apNew[i]->pDbPage, pgno, aPgFlags[iBest]); - apNew[i]->pgno = pgno; + + /* If apNew[i] has a page number that is bigger than any of the + ** subsequence apNew[i] entries, then swap apNew[i] with the subsequent + ** entry that has the smallest page number (which we know to be + ** entry apNew[iB]). + */ + if( iB!=i ){ + Pgno pgnoA = apNew[i]->pgno; + Pgno pgnoB = apNew[iB]->pgno; + Pgno pgnoTemp = (PENDING_BYTE/pBt->pageSize)+1; + u16 fgA = apNew[i]->pDbPage->flags; + u16 fgB = apNew[iB]->pDbPage->flags; + sqlite3PagerRekey(apNew[i]->pDbPage, pgnoTemp, fgB); + sqlite3PagerRekey(apNew[iB]->pDbPage, pgnoA, fgA); + sqlite3PagerRekey(apNew[i]->pDbPage, pgnoB, fgB); + apNew[i]->pgno = pgnoB; + apNew[iB]->pgno = pgnoA; } } diff --git a/src/pcache1.c b/src/pcache1.c index d40d9cf4fc..3e406a7a89 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -1122,9 +1122,11 @@ static void pcache1Rekey( unsigned int h; assert( pPage->iKey==iOld ); assert( pPage->pCache==pCache ); + assert( iOld!=iNew ); /* The page number really is changing */ pcache1EnterMutex(pCache->pGroup); - + + assert( pcache1FetchNoMutex(p, iOld, 0)==pPage ); /* pPg really is iOld */ h = iOld%pCache->nHash; pp = &pCache->apHash[h]; while( (*pp)!=pPage ){ @@ -1132,6 +1134,7 @@ static void pcache1Rekey( } *pp = pPage->pNext; + assert( pcache1FetchNoMutex(p, iNew, 0)==0 ); /* iNew not previously used */ h = iNew%pCache->nHash; pPage->iKey = iNew; pPage->pNext = pCache->apHash[h]; From a3fc683c80c41292b03aa89a689ee25ab987fa12 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Sep 2022 10:29:02 +0000 Subject: [PATCH 06/16] In the query planner, add a heuristic that will reduce the cost of a full table scan for a materialized view or subquery if the full scan is the outer-most loop. This is shown to speed up some queries. FossilOrigin-Name: 609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/where.c | 10 ++++++++++ src/whereInt.h | 1 + test/window1.test | 5 +++-- test/with3.test | 4 ++-- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 746bbe3c38..6a1a80007e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sb-tree\spage\ssorting\scode\sto\sensure\sthat\ssqlite3PagerRekey()\snever\noverloads\sa\spage\snumber\sand\suses\sonly\sthe\sPENDING_BYTE\spage\sfor\stemporary\nstorage. -D 2022-08-31T15:04:42.204 +C In\sthe\squery\splanner,\sadd\sa\sheuristic\sthat\swill\sreduce\sthe\scost\sof\sa\sfull\ntable\sscan\sfor\sa\smaterialized\sview\sor\ssubquery\sif\sthe\sfull\sscan\sis\sthe\nouter-most\sloop.\s\sThis\sis\sshown\sto\sspeed\sup\ssome\squeries. +D 2022-09-01T10:29:02.873 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -675,8 +675,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b -F src/where.c 6d1ee6f6bc048406554176eb6146b27ac16ec96cca018848aa0b9836b2b71143 -F src/whereInt.h b48ca529ffe293c18cbfa8326af18a09e39910de66fb3e96ef788c7cbf8ef3a7 +F src/where.c 424c42590b71968a9b81cd890df2671902028613fee38a50ed4c2f7ca65315d3 +F src/whereInt.h 70cd30de9ed784aa33fa6bd1245f060617de7a00d992469b6d8e419eed915743 F src/wherecode.c 6bb1cf9d0a4e3e04dab0bf0ea4a8d936a0dcc05a7e2207beeda6c61aea6dd341 F src/whereexpr.c 55a39f42aaf982574fbf52906371a84cceed98a994422198dfd03db4fce4cc46 F src/window.c 928e215840e2f2d9a2746e018c9643ef42c66c4ab6630ef0df7fa388fa145e86 @@ -1852,7 +1852,7 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2 F test/win32lock.test e0924eb8daac02bf80e9da88930747bd44dd9b230b7759fed927b1655b467c9c F test/win32longpath.test 4baffc3acb2e5188a5e3a895b2b543ed09e62f7c72d713c1feebf76222fe9976 F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc -F test/window1.test ae87c4ea4e689725c7e1c826ab2b10704d5b6d31f9b9e5abadded996ba53a1d4 +F test/window1.test 08bac934238ff66987635ea3367c5aed5b4c088c414441beaba426e68a8257c1 F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476 F test/window2.test e466a88bd626d66edc3d352d7d7e1d5531e0079b549ba44efb029d1fbff9fd3c F test/window3.tcl acea6e86a4324a210fd608d06741010ca83ded9fde438341cb978c49928faf03 @@ -1876,7 +1876,7 @@ F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c F test/windowpushd.test d8895d08870b7226f7693665bd292eb177e62ca06799184957b3ca7dc03067df F test/with1.test 9ad67fdeb2bbd808a5763c9060e214ea232f9b18d846ea3a59756dc38bdc3880 F test/with2.test a1df41b987198383b9b70bf5e5fda390582e46398653858dbc6ceb24253b28df -F test/with3.test ad32d13ad50661e6fa305f62a0717649c348792e7b658bf2644976227a9e0373 +F test/with3.test 1e2e8d5e7b1d955342d0d18c250aaaa6e6bcf36ef2a818477bd01cb74f9a5d66 F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205 F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8 F test/with6.test c18592592b5a1c5802fd4e933d506f7b34ebbe8fdd585229793e960ae58d433f @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dd017bb1b3e31c7692d29dc4865d6bda871e429978c8738a39160d0114e5bf9b -R 98122ff0aaf5ca87deda59c5c8a25251 +P 5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435 +R 5af1ce0d7f6d60d5f513975f3a1b9fe9 U drh -Z 8d73d18db9ab73a94a9689d17f937c1d +Z 1d09512c855de39ee2d5b2ad872e6d10 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 00cb077051..231675a657 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435 \ No newline at end of file +609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 0a6f5e6273..3e90fa9a7c 100644 --- a/src/where.c +++ b/src/where.c @@ -3463,6 +3463,9 @@ static int whereLoopAddBtree( #else pNew->rRun = rSize + 16; #endif + if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){ + pNew->wsFlags |= WHERE_VIEWSCAN; + } ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); rc = whereLoopInsert(pBuilder, pNew); @@ -4843,6 +4846,13 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ } + /* TUNING: A full-scan of a VIEW or subquery in the outer loop + ** is not so bad. */ + if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 ){ + rCost += -10; + nOut += -30; + } + /* Check to see if pWLoop should be added to the set of ** mxChoice best-so-far paths. ** diff --git a/src/whereInt.h b/src/whereInt.h index bc96ff7e67..fda207890c 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -648,5 +648,6 @@ void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*); #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ +#define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */ #endif /* !defined(SQLITE_WHEREINT_H) */ diff --git a/test/window1.test b/test/window1.test index fd71ed6bb9..0f22829847 100644 --- a/test/window1.test +++ b/test/window1.test @@ -212,10 +212,11 @@ do_execsql_test 6.1 { } {1 1 2 2 3 3 4 4 5 5 6 6 7 7} do_execsql_test 6.2 { - SELECT * FROM t2, (SELECT x, count(*) OVER (ORDER BY x) FROM t1); + SELECT * FROM t2, (SELECT x, count(*) OVER (ORDER BY x) FROM t1) + ORDER BY 1, 2; } { - b 1 1 b 2 2 b 3 3 b 4 4 b 5 5 b 6 6 b 7 7 a 1 1 a 2 2 a 3 3 a 4 4 a 5 5 a 6 6 a 7 7 + b 1 1 b 2 2 b 3 3 b 4 4 b 5 5 b 6 6 b 7 7 } do_catchsql_test 6.3 { diff --git a/test/with3.test b/test/with3.test index 8e8eba89f6..1aed92a99a 100644 --- a/test/with3.test +++ b/test/with3.test @@ -131,8 +131,8 @@ do_eqp_test 3.2.2 { | | `--SCALAR SUBQUERY xxxxxx | | `--SCAN w2 | `--RECURSIVE STEP - | |--SCAN w1 - | `--SCAN c + | |--SCAN c + | `--SCAN w1 |--SCAN c |--SEARCH w2 USING INTEGER PRIMARY KEY (rowid=?) `--SEARCH w1 USING INTEGER PRIMARY KEY (rowid=?) From 44132244fab1d9754a9cc2091372fef1cc1c7997 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 1 Sep 2022 13:51:09 +0000 Subject: [PATCH 07/16] Defer deleting a transient SELECT statement associated with a flattening of one arm of a compound SELECT until after the parse has completed. FossilOrigin-Name: 1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6a1a80007e..503827d8d2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\squery\splanner,\sadd\sa\sheuristic\sthat\swill\sreduce\sthe\scost\sof\sa\sfull\ntable\sscan\sfor\sa\smaterialized\sview\sor\ssubquery\sif\sthe\sfull\sscan\sis\sthe\nouter-most\sloop.\s\sThis\sis\sshown\sto\sspeed\sup\ssome\squeries. -D 2022-09-01T10:29:02.873 +C Defer\sdeleting\sa\stransient\sSELECT\sstatement\sassociated\swith\sa\sflattening\nof\sone\sarm\sof\sa\scompound\sSELECT\suntil\safter\sthe\sparse\shas\scompleted. +D 2022-09-01T13:51:09.528 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -588,7 +588,7 @@ F src/printf.c e99ee9741e79ae3873458146f59644276657340385ade4e76a5f5d1c25793764 F src/random.c 546d6feb15ec69c1aafe9bb351a277cbb498fd5410e646add673acb805714960 F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 -F src/select.c ccce37e7fbe71089cf6aec91e7134c9c0c1d4840cff9f02587bbc71240d914a5 +F src/select.c d69dfb5b082f9a25e6700e152ddb3d942359b847b1df504eb09f9b4531844f8d F src/shell.c.in e7e7c2c69ae86c5ee9e8ad66227203d46ff6dce8700a1b1dababff01c71d33df F src/sqlite.h.in b9b7fd73239d94db20332bb6e504688001e5564b655e1318a4427a1caef4b99e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435 -R 5af1ce0d7f6d60d5f513975f3a1b9fe9 +P 609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137 +R 487a3bf9c59a00f1f5680d4b9fe8f377 U drh -Z 1d09512c855de39ee2d5b2ad872e6d10 +Z 09e47f999161ac29a61ba026e8089efe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 231675a657..aafbfad5ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137 \ No newline at end of file +1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 39ec70f2b5..950d0db62b 100644 --- a/src/select.c +++ b/src/select.c @@ -3690,10 +3690,11 @@ static int multiSelectOrderBy( */ sqlite3VdbeResolveLabel(v, labelEnd); - /* Reassembly the compound query so that it will be freed correctly + /* Reassemble the compound query so that it will be freed correctly ** by the calling function */ if( pSplit->pPrior ){ - sqlite3SelectDelete(db, pSplit->pPrior); + sqlite3ParserAddCleanup(pParse, + (void(*)(sqlite3*,void*))sqlite3SelectDelete, pSplit->pPrior); } pSplit->pPrior = pPrior; pPrior->pNext = pSplit; From 18a3a48db1ff3f4fef94915e2021c5d0a790d24b Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Sep 2022 00:36:16 +0000 Subject: [PATCH 08/16] Experimental changes to put sqlite3_temp_directory behind a mutex. FossilOrigin-Name: 5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/os_unix.c | 31 ++++++++++++++++++++----------- src/os_win.c | 35 +++++++++++++++++++++++++++++++---- src/pragma.c | 6 ++++++ src/sqliteInt.h | 5 +++++ 6 files changed, 75 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 503827d8d2..f63a1088ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Defer\sdeleting\sa\stransient\sSELECT\sstatement\sassociated\swith\sa\sflattening\nof\sone\sarm\sof\sa\scompound\sSELECT\suntil\safter\sthe\sparse\shas\scompleted. -D 2022-09-01T13:51:09.528 +C Experimental\schanges\sto\sput\ssqlite3_temp_directory\sbehind\sa\smutex. +D 2022-09-02T00:36:16.247 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -572,8 +572,8 @@ F src/os.c 0eb831ba3575af5277e47f4edd14fdfc90025c67eb25ce5cda634518d308d4e9 F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 81e24bcad127faf32da162a4bb06e7a4604bea76fe7b1ed5b01742e9eb320554 -F src/os_win.c a8ea80037e81127ca01959daa87387cc135f325c88dc745376c4f760de852a10 +F src/os_unix.c 102f7e5c5b59c18ea3dbc929dc3be8acb3afc0e0b6ad572e032335c9c27f44f1 +F src/os_win.c d9ebd8bfce17d8fe49a08a87804dfa644c8fb20e28bca817ab62350c6ee2d4a5 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 @@ -581,7 +581,7 @@ F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache1.c 5cde56d6bb057b0d7420f89bebd3bb9103f4ed9acfc17cef765dca8c33cd3a1f -F src/pragma.c b57a859a366472131194a9ad35cd76d5920577226b04c884b1b9085605faa280 +F src/pragma.c 9bf7d8a2a9ad3bc36df3ec0d61817a44c38a1da527d59c26c203047f906e334a F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 971d5819a4bda88038c2283d71fc0a2974ffc3dd480f9bd941341017abacfd1b F src/printf.c e99ee9741e79ae3873458146f59644276657340385ade4e76a5f5d1c25793764 @@ -593,7 +593,7 @@ F src/shell.c.in e7e7c2c69ae86c5ee9e8ad66227203d46ff6dce8700a1b1dababff01c71d33d F src/sqlite.h.in b9b7fd73239d94db20332bb6e504688001e5564b655e1318a4427a1caef4b99e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d -F src/sqliteInt.h ebf18764e404a2cef39ae5bfc8dd4a83bf0d70be1c444a4fbd8539eb35ef6ffd +F src/sqliteInt.h 9c46510e108e6a525918c8d2c618a4c4527c53bc0c78c866edf5ee3315646726 F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657 F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -1999,8 +1999,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137 -R 487a3bf9c59a00f1f5680d4b9fe8f377 +P 1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7 +R 76adaad53bd26cbe572b84e819c193a2 +T *branch * tempdir-mutex +T *sym-tempdir-mutex * +T -sym-trunk * U drh -Z 09e47f999161ac29a61ba026e8089efe +Z 159fcca8739ffc7d9b735c4f860ae553 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aafbfad5ac..6ab0e1756c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7 \ No newline at end of file +5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index f809eca9fe..fd7a50dcdb 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5855,6 +5855,7 @@ static const char *unixTempFileDir(void){ static int unixGetTempname(int nBuf, char *zBuf){ const char *zDir; int iLimit = 0; + int rc = SQLITE_OK; /* It's odd to simulate an io-error here, but really this is just ** using the io-error infrastructure to test that SQLite handles this @@ -5863,18 +5864,26 @@ static int unixGetTempname(int nBuf, char *zBuf){ zBuf[0] = 0; SimulateIOError( return SQLITE_IOERR ); + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); zDir = unixTempFileDir(); - if( zDir==0 ) return SQLITE_IOERR_GETTEMPPATH; - do{ - u64 r; - sqlite3_randomness(sizeof(r), &r); - assert( nBuf>2 ); - zBuf[nBuf-2] = 0; - sqlite3_snprintf(nBuf, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX"%llx%c", - zDir, r, 0); - if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ) return SQLITE_ERROR; - }while( osAccess(zBuf,0)==0 ); - return SQLITE_OK; + if( zDir==0 ){ + rc = SQLITE_IOERR_GETTEMPPATH; + }else{ + do{ + u64 r; + sqlite3_randomness(sizeof(r), &r); + assert( nBuf>2 ); + zBuf[nBuf-2] = 0; + sqlite3_snprintf(nBuf, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX"%llx%c", + zDir, r, 0); + if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ){ + rc = SQLITE_ERROR; + break; + } + }while( osAccess(zBuf,0)==0 ); + } + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); + return rc; } #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) diff --git a/src/os_win.c b/src/os_win.c index 8832c8012a..591f57ee5c 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1922,6 +1922,7 @@ int sqlite3_win32_set_directory8( int rc = sqlite3_initialize(); if( rc ) return rc; #endif + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){ ppDirectory = &sqlite3_data_directory; }else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){ @@ -1936,14 +1937,19 @@ int sqlite3_win32_set_directory8( if( zValue && zValue[0] ){ zCopy = sqlite3_mprintf("%s", zValue); if ( zCopy==0 ){ - return SQLITE_NOMEM_BKPT; + rc = SQLITE_NOMEM_BKPT; + goto set_directory8_done; } } sqlite3_free(*ppDirectory); *ppDirectory = zCopy; - return SQLITE_OK; + rc = SQLITE_OK; + }else{ + rc = SQLITE_ERROR; } - return SQLITE_ERROR; +set_directory8_done: + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); + return rc; } /* @@ -4717,6 +4723,18 @@ static int winMakeEndInDirSep(int nBuf, char *zBuf){ return 0; } +/* +** If sqlite3_temp_directory is not, take the mutex and return true. +** +** If sqlite3_temp_directory is NULL, omit the mutex and return false. +*/ +static int winTempDirDefined(void){ + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); + if( sqlite3_temp_directory!=0 ) return 1; + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); + return 0; +} + /* ** Create a temporary file name and store the resulting pointer into pzBuf. ** The pointer returned in pzBuf must be freed via sqlite3_free(). @@ -4753,20 +4771,23 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ */ nDir = nMax - (nPre + 15); assert( nDir>0 ); - if( sqlite3_temp_directory ){ + if( winTempDirDefined() ){ int nDirLen = sqlite3Strlen30(sqlite3_temp_directory); if( nDirLen>0 ){ if( !winIsDirSep(sqlite3_temp_directory[nDirLen-1]) ){ nDirLen++; } if( nDirLen>nDir ){ + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); sqlite3_free(zBuf); OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); return winLogError(SQLITE_ERROR, 0, "winGetTempname1", 0); } sqlite3_snprintf(nMax, zBuf, "%s", sqlite3_temp_directory); } + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); } + #if defined(__CYGWIN__) else{ static const char *azDirs[] = { @@ -5579,6 +5600,7 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); assert( nFull>=pVfs->mxPathname ); + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5629,6 +5651,7 @@ static int winFullPathname( sqlite3_free(zOut); } } + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; #endif @@ -5636,6 +5659,7 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5648,6 +5672,7 @@ static int winFullPathname( }else{ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); } + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; #endif @@ -5658,6 +5683,7 @@ static int winFullPathname( ** current working directory has been unlinked. */ SimulateIOError( return SQLITE_ERROR ); + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5667,6 +5693,7 @@ static int winFullPathname( */ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", sqlite3_data_directory, winGetDirSep(), zRelative); + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; } zConverted = winConvertFromUtf8Filename(zRelative); diff --git a/src/pragma.c b/src/pragma.c index 2dd792f274..9d46a10dcd 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -965,6 +965,7 @@ void sqlite3Pragma( ** */ case PragTyp_TEMP_STORE_DIRECTORY: { + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if( !zRight ){ returnSingleText(v, sqlite3_temp_directory); }else{ @@ -974,6 +975,7 @@ void sqlite3Pragma( rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res); if( rc!=SQLITE_OK || res==0 ){ sqlite3ErrorMsg(pParse, "not a writable directory"); + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); goto pragma_out; } } @@ -991,6 +993,7 @@ void sqlite3Pragma( } #endif /* SQLITE_OMIT_WSD */ } + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); break; } @@ -1009,6 +1012,7 @@ void sqlite3Pragma( ** */ case PragTyp_DATA_STORE_DIRECTORY: { + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if( !zRight ){ returnSingleText(v, sqlite3_data_directory); }else{ @@ -1018,6 +1022,7 @@ void sqlite3Pragma( rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res); if( rc!=SQLITE_OK || res==0 ){ sqlite3ErrorMsg(pParse, "not a writable directory"); + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); goto pragma_out; } } @@ -1029,6 +1034,7 @@ void sqlite3Pragma( } #endif /* SQLITE_OMIT_WSD */ } + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); break; } #endif diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 21d15378f1..eef09e1f0e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -198,6 +198,11 @@ */ #include "sqlite3.h" +/* +** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory. +*/ +#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_LRU + /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build From fee6431392efdbf83d4efdbd639f1f37f4ebb275 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Sep 2022 11:12:16 +0000 Subject: [PATCH 09/16] Improved mutex protection of the sqlite3_temp_directory and sqlite3_data_directory global variables. FossilOrigin-Name: ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/os_win.c | 21 ++++++++++++++------- src/sqliteInt.h | 3 ++- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index f63a1088ae..4a5639fda2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Experimental\schanges\sto\sput\ssqlite3_temp_directory\sbehind\sa\smutex. -D 2022-09-02T00:36:16.247 +C Improved\smutex\sprotection\sof\sthe\ssqlite3_temp_directory\sand\nsqlite3_data_directory\sglobal\svariables. +D 2022-09-02T11:12:16.831 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -573,7 +573,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 102f7e5c5b59c18ea3dbc929dc3be8acb3afc0e0b6ad572e032335c9c27f44f1 -F src/os_win.c d9ebd8bfce17d8fe49a08a87804dfa644c8fb20e28bca817ab62350c6ee2d4a5 +F src/os_win.c d55025aeb5b36b5d92d7c09fe709edaf2be901420782540ba4adad86729636a0 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 @@ -593,7 +593,7 @@ F src/shell.c.in e7e7c2c69ae86c5ee9e8ad66227203d46ff6dce8700a1b1dababff01c71d33d F src/sqlite.h.in b9b7fd73239d94db20332bb6e504688001e5564b655e1318a4427a1caef4b99e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d -F src/sqliteInt.h 9c46510e108e6a525918c8d2c618a4c4527c53bc0c78c866edf5ee3315646726 +F src/sqliteInt.h a46ea998c6fdc3390a414db276c7410d9322ce40a2562775ddf5d1082f820763 F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657 F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -1999,11 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7 -R 76adaad53bd26cbe572b84e819c193a2 -T *branch * tempdir-mutex -T *sym-tempdir-mutex * -T -sym-trunk * +P 5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d +R c72d5281577d5a05e206ee4555729db3 U drh -Z 159fcca8739ffc7d9b735c4f860ae553 +Z 7b1cb313ea01e869890e1646257d0d7e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6ab0e1756c..88932bc11f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5ee3515fbb88bf1ae5f8b507844f82dcc429380b6ebeab9b09b52b25ee60a60d \ No newline at end of file +ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 591f57ee5c..4191db6bb7 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5576,7 +5576,7 @@ static BOOL winIsVerbatimPathname( ** pathname into zOut[]. zOut[] will be at least pVfs->mxPathname ** bytes in size. */ -static int winFullPathname( +static int winFullPathnameNoMutex( sqlite3_vfs *pVfs, /* Pointer to vfs object */ const char *zRelative, /* Possibly relative input path */ int nFull, /* Size of output buffer in bytes */ @@ -5600,7 +5600,6 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); assert( nFull>=pVfs->mxPathname ); - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5651,7 +5650,6 @@ static int winFullPathname( sqlite3_free(zOut); } } - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; #endif @@ -5659,7 +5657,6 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5672,7 +5669,6 @@ static int winFullPathname( }else{ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); } - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; #endif @@ -5683,7 +5679,6 @@ static int winFullPathname( ** current working directory has been unlinked. */ SimulateIOError( return SQLITE_ERROR ); - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5693,7 +5688,6 @@ static int winFullPathname( */ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", sqlite3_data_directory, winGetDirSep(), zRelative); - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; } zConverted = winConvertFromUtf8Filename(zRelative); @@ -5761,6 +5755,19 @@ static int winFullPathname( } #endif } +static int winFullPathname( + sqlite3_vfs *pVfs, /* Pointer to vfs object */ + const char *zRelative, /* Possibly relative input path */ + int nFull, /* Size of output buffer in bytes */ + char *zFull /* Output buffer */ +){ + int rc; + sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); + sqlite3_mutex_enter(pMutex); + rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull); + sqlite3_mutex_leave(pMutex); + return rc; +} #ifndef SQLITE_OMIT_LOAD_EXTENSION /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index eef09e1f0e..aeb4cac439 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -201,7 +201,7 @@ /* ** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory. */ -#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_LRU +#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_VFS1 /* ** Include the configuration header output by 'configure' if we're using the @@ -4561,6 +4561,7 @@ int sqlite3IndexHasDuplicateRootPage(Index*); int sqlite3Init(sqlite3*, char**); int sqlite3InitCallback(void*, int, char**, char**); int sqlite3InitOne(sqlite3*, int, char**, u32); +char *sqlite3TempDirectory(void); void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); #ifndef SQLITE_OMIT_VIRTUALTABLE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName); From 4e9bf5ace34a29d04386bfa9bcdda1861750b744 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Sep 2022 14:29:54 +0000 Subject: [PATCH 10/16] Enhance the pcache1 implementation so that during an xRekey operation if another page already exists at the destination, that other page gets moved to the source key. FossilOrigin-Name: aadd38f99a3e5abcf9bef49f4367752f163cc79500a28f812bb71969d7de419c --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/pcache1.c | 29 ++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 881f344e8d..36e32cc367 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Mutex\sprotect\saccess\sto\sthe\ssqlite3_test_directory\sand\ssqlite3_data_directory\nglobal\svariables.\s\sSee\n[forum:/forumpost/719a11e1314d1c70|forum\sthread\s719a11e1314d1c70]. -D 2022-09-02T11:45:26.675 +C Enhance\sthe\spcache1\simplementation\sso\sthat\sduring\san\sxRekey\soperation\sif\nanother\spage\salready\sexists\sat\sthe\sdestination,\sthat\sother\spage\sgets\smoved\nto\sthe\ssource\skey. +D 2022-09-02T14:29:54.641 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -580,7 +580,7 @@ F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 -F src/pcache1.c 5cde56d6bb057b0d7420f89bebd3bb9103f4ed9acfc17cef765dca8c33cd3a1f +F src/pcache1.c 849a26ea9dc1e6a176b75dc576672a598170b0b46aeef87a981dd25e0af0ccf9 F src/pragma.c 9bf7d8a2a9ad3bc36df3ec0d61817a44c38a1da527d59c26c203047f906e334a F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 971d5819a4bda88038c2283d71fc0a2974ffc3dd480f9bd941341017abacfd1b @@ -1999,9 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c4157c71cd1e062a9c2c79787d17e34e340f28ce1e40573851dfe174f5da7d7 ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec -R ceab41e21a2b5216a46a28807cd5555b -T +closed ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec +P 8e6ad3a3e942a326cf16432e16d6596c7206c05b6f45cd0ff3a9b836bcfc9deb +R 01ad42a8d2f31eadbe33e5f4a288db74 U drh -Z 6792df766aacf245b78e8d274ef8f48f +Z dced8cd032db7b035db78c488a02a704 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ee3a8ffbf8..dc8be391e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e6ad3a3e942a326cf16432e16d6596c7206c05b6f45cd0ff3a9b836bcfc9deb \ No newline at end of file +aadd38f99a3e5abcf9bef49f4367752f163cc79500a28f812bb71969d7de419c \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 3e406a7a89..a47087fa11 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -1119,7 +1119,7 @@ static void pcache1Rekey( PCache1 *pCache = (PCache1 *)p; PgHdr1 *pPage = (PgHdr1 *)pPg; PgHdr1 **pp; - unsigned int h; + unsigned int hOld, hNew; assert( pPage->iKey==iOld ); assert( pPage->pCache==pCache ); assert( iOld!=iNew ); /* The page number really is changing */ @@ -1127,18 +1127,33 @@ static void pcache1Rekey( pcache1EnterMutex(pCache->pGroup); assert( pcache1FetchNoMutex(p, iOld, 0)==pPage ); /* pPg really is iOld */ - h = iOld%pCache->nHash; - pp = &pCache->apHash[h]; + hOld = iOld%pCache->nHash; + pp = &pCache->apHash[hOld]; while( (*pp)!=pPage ){ pp = &(*pp)->pNext; } *pp = pPage->pNext; - assert( pcache1FetchNoMutex(p, iNew, 0)==0 ); /* iNew not previously used */ - h = iNew%pCache->nHash; + hNew = iNew%pCache->nHash; + pp = &pCache->apHash[hNew]; + while( *pp ){ + if( (*pp)->iKey==iNew ){ + /* If there is already another pcache entry at iNew, change it to iOld, + ** thus swapping the positions of iNew and iOld */ + PgHdr1 *pOld = *pp; + *pp = pOld->pNext; + pOld->pNext = pCache->apHash[hOld]; + pCache->apHash[hOld] = pOld; + pOld->iKey = iOld; + break; + }else{ + pp = &(*pp)->pNext; + } + } + pPage->iKey = iNew; - pPage->pNext = pCache->apHash[h]; - pCache->apHash[h] = pPage; + pPage->pNext = pCache->apHash[hNew]; + pCache->apHash[hNew] = pPage; if( iNew>pCache->iMaxKey ){ pCache->iMaxKey = iNew; } From 5fc3a8a32fe76b50f39b73b1c6fbc4827e68529f Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Sep 2022 15:09:55 +0000 Subject: [PATCH 11/16] If sqlite3PcacheMove() really performs a swap, then be sure to renumber the second page. FossilOrigin-Name: 81cff9f1955874aade55daa94263f58f06d966bd51ad558755f92777069a7347 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache.c | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 36e32cc367..a1a424a211 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\spcache1\simplementation\sso\sthat\sduring\san\sxRekey\soperation\sif\nanother\spage\salready\sexists\sat\sthe\sdestination,\sthat\sother\spage\sgets\smoved\nto\sthe\ssource\skey. -D 2022-09-02T14:29:54.641 +C If\ssqlite3PcacheMove()\sreally\sperforms\sa\sswap,\sthen\sbe\ssure\sto\srenumber\sthe\nsecond\spage. +D 2022-09-02T15:09:55.423 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -578,7 +578,7 @@ F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 -F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb +F src/pcache.c 22a6ebe498d1d26c85fd1e3bcb246d97b882c060027c1e1688fbea905f5ac3cf F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache1.c 849a26ea9dc1e6a176b75dc576672a598170b0b46aeef87a981dd25e0af0ccf9 F src/pragma.c 9bf7d8a2a9ad3bc36df3ec0d61817a44c38a1da527d59c26c203047f906e334a @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e6ad3a3e942a326cf16432e16d6596c7206c05b6f45cd0ff3a9b836bcfc9deb -R 01ad42a8d2f31eadbe33e5f4a288db74 +P aadd38f99a3e5abcf9bef49f4367752f163cc79500a28f812bb71969d7de419c +R 15f4aa96b5fcd17c040bad40e6f9e29d U drh -Z dced8cd032db7b035db78c488a02a704 +Z 44f09c245350ada0933c5922c4c18b91 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dc8be391e2..e6737916dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aadd38f99a3e5abcf9bef49f4367752f163cc79500a28f812bb71969d7de419c \ No newline at end of file +81cff9f1955874aade55daa94263f58f06d966bd51ad558755f92777069a7347 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index 38093dd7a1..8c57f5b1eb 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -649,11 +649,20 @@ void sqlite3PcacheClearSyncFlags(PCache *pCache){ */ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){ PCache *pCache = p->pCache; + sqlite3_pcache_page *pOther; assert( p->nRef>0 ); assert( newPgno>0 ); assert( sqlite3PcachePageSanity(p) ); pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); + pOther = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, newPgno, 0); sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); + if( pOther ){ + PgHdr *pPg = (PgHdr*)pOther->pExtra; + pPg->pgno = p->pgno; + if( pPg->pPage==0 ){ + sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pOther, 0); + } + } p->pgno = newPgno; if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); From 173b418e60b910be114d949bed679f7bdf6fa7ba Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 2 Sep 2022 17:25:25 +0000 Subject: [PATCH 12/16] Fix an assert() associated with the dbsqlfuzz error at [8372468bb5d8922c]. FossilOrigin-Name: 54251f81ebc43839cc97f91d2df4c320c1b96b5690cc11ce45b60c087c9becd6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a1a424a211..6d5a66eef8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\ssqlite3PcacheMove()\sreally\sperforms\sa\sswap,\sthen\sbe\ssure\sto\srenumber\sthe\nsecond\spage. -D 2022-09-02T15:09:55.423 +C Fix\san\sassert()\sassociated\swith\sthe\sdbsqlfuzz\serror\sat\s[8372468bb5d8922c]. +D 2022-09-02T17:25:25.196 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -658,7 +658,7 @@ F src/trigger.c 61bea163b1fa3039bc572ed8312461b978e5c527e5301f302b078f4c1ccdec6a F src/update.c c52a7991bece0453d22c77c08469512ee2f1391c12503fd347d1c939220c5877 F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 -F src/util.c 602fe229f32a96ceccae4f40824129669582096f7c355f53dbac156c9fecef23 +F src/util.c 0be191521ff6d2805995f4910f0b6231b42843678b2efdc1abecaf39929a673f F src/vacuum.c bb346170b0b54c6683bba4a5983aea40485597fdf605c87ec8bc2e199fe88cd8 F src/vdbe.c d27ec9a57f752fc2acf6a64d43bbf6072d2415efc976184f6d8a146e65819d3b F src/vdbe.h 64619af62603dc3c4f5ff6ff6d2c8f389abd667a29ce6007ed44bd22b3211cd0 @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aadd38f99a3e5abcf9bef49f4367752f163cc79500a28f812bb71969d7de419c -R 15f4aa96b5fcd17c040bad40e6f9e29d +P 81cff9f1955874aade55daa94263f58f06d966bd51ad558755f92777069a7347 +R e3f3854237e6ccbd24e5faf8a81d6554 U drh -Z 44f09c245350ada0933c5922c4c18b91 +Z 5ecc0e1668a222228dc4637f535ad91a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e6737916dd..fce2af451d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -81cff9f1955874aade55daa94263f58f06d966bd51ad558755f92777069a7347 \ No newline at end of file +54251f81ebc43839cc97f91d2df4c320c1b96b5690cc11ce45b60c087c9becd6 \ No newline at end of file diff --git a/src/util.c b/src/util.c index 84608739ae..32e9c27786 100644 --- a/src/util.c +++ b/src/util.c @@ -190,7 +190,7 @@ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ va_list ap; sqlite3 *db = pParse->db; assert( db!=0 ); - assert( db->pParse==pParse ); + assert( db->pParse==pParse || db->pParse->pToplevel==pParse ); db->errByteOffset = -2; va_start(ap, zFormat); zMsg = sqlite3VMPrintf(db, zFormat, ap); From ad617b4d6d508486a04b17bf6ac315b1b20aa94f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 2 Sep 2022 21:19:24 +0000 Subject: [PATCH 13/16] Ensure the Pager.journalOff variable is zeroed if an error occurs while writing the initial header to the journal file. FossilOrigin-Name: da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6d5a66eef8..d7b1deb4ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sassociated\swith\sthe\sdbsqlfuzz\serror\sat\s[8372468bb5d8922c]. -D 2022-09-02T17:25:25.196 +C Ensure\sthe\sPager.journalOff\svariable\sis\szeroed\sif\san\serror\soccurs\swhile\swriting\sthe\sinitial\sheader\sto\sthe\sjournal\sfile. +D 2022-09-02T21:19:24.442 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -575,7 +575,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 102f7e5c5b59c18ea3dbc929dc3be8acb3afc0e0b6ad572e032335c9c27f44f1 F src/os_win.c d55025aeb5b36b5d92d7c09fe709edaf2be901420782540ba4adad86729636a0 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781 +F src/pager.c 6176d9752eb580419e8fef4592dc417a6b00ddfd43ee22f818819bf8840ceee8 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 F src/pcache.c 22a6ebe498d1d26c85fd1e3bcb246d97b882c060027c1e1688fbea905f5ac3cf @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 81cff9f1955874aade55daa94263f58f06d966bd51ad558755f92777069a7347 -R e3f3854237e6ccbd24e5faf8a81d6554 -U drh -Z 5ecc0e1668a222228dc4637f535ad91a +P 54251f81ebc43839cc97f91d2df4c320c1b96b5690cc11ce45b60c087c9becd6 +R 87dafa73318986b955e7b84411151a61 +U dan +Z acee053f656d75b425260930781b7440 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fce2af451d..d002876e21 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54251f81ebc43839cc97f91d2df4c320c1b96b5690cc11ce45b60c087c9becd6 \ No newline at end of file +da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index ca406b8c5d..883e6532cf 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5822,6 +5822,7 @@ static int pager_open_journal(Pager *pPager){ if( rc!=SQLITE_OK ){ sqlite3BitvecDestroy(pPager->pInJournal); pPager->pInJournal = 0; + pPager->journalOff = 0; }else{ assert( pPager->eState==PAGER_WRITER_LOCKED ); pPager->eState = PAGER_WRITER_CACHEMOD; From 6e440ab3dea8494b46432485382d89a96949a65d Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 5 Sep 2022 18:17:03 +0000 Subject: [PATCH 14/16] Fix the windows build so that it works with -DSQLITE_OMIT_AUTOINIT. FossilOrigin-Name: f74a5ea8c986dc33d3afcda169c38abbe55728c56716cf9991a5e2ef7fc4917a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d7b1deb4ae..0884004347 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthe\sPager.journalOff\svariable\sis\szeroed\sif\san\serror\soccurs\swhile\swriting\sthe\sinitial\sheader\sto\sthe\sjournal\sfile. -D 2022-09-02T21:19:24.442 +C Fix\sthe\swindows\sbuild\sso\sthat\sit\sworks\swith\s-DSQLITE_OMIT_AUTOINIT. +D 2022-09-05T18:17:03.632 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -573,7 +573,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 102f7e5c5b59c18ea3dbc929dc3be8acb3afc0e0b6ad572e032335c9c27f44f1 -F src/os_win.c d55025aeb5b36b5d92d7c09fe709edaf2be901420782540ba4adad86729636a0 +F src/os_win.c e9454cb141908e8eef2102180bad353a36480612d5b736e4c2bd5777d9b25a34 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 6176d9752eb580419e8fef4592dc417a6b00ddfd43ee22f818819bf8840ceee8 F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3 @@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 54251f81ebc43839cc97f91d2df4c320c1b96b5690cc11ce45b60c087c9becd6 -R 87dafa73318986b955e7b84411151a61 -U dan -Z acee053f656d75b425260930781b7440 +P da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c +R 6331ff40a11387db72be313b77cf6d6b +U drh +Z c1acc1c86c32ffeafe2e7e809812c8dc # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d002876e21..aac27db64a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c \ No newline at end of file +f74a5ea8c986dc33d3afcda169c38abbe55728c56716cf9991a5e2ef7fc4917a \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 4191db6bb7..2827b0b49b 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1918,8 +1918,9 @@ int sqlite3_win32_set_directory8( const char *zValue /* New value for directory being set or reset */ ){ char **ppDirectory = 0; + int rc; #ifndef SQLITE_OMIT_AUTOINIT - int rc = sqlite3_initialize(); + rc = sqlite3_initialize(); if( rc ) return rc; #endif sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); From 4c8404e555a6df7b6f42b0d7855b81496b31ee7e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 5 Sep 2022 20:42:01 +0000 Subject: [PATCH 15/16] Add a prototype for a script, similar to tool/omittest.tcl, that is designed to test builds using MSVC to ensure they work with various OMIT options. FossilOrigin-Name: b1e37a0bd31fa9f8e58c2859a80c23a682b4702eefab2c55b243f1e21d475d6c --- manifest | 14 ++++-- manifest.uuid | 2 +- tool/omittest-msvc.tcl | 106 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 tool/omittest-msvc.tcl diff --git a/manifest b/manifest index 0884004347..4fca0b4944 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\swindows\sbuild\sso\sthat\sit\sworks\swith\s-DSQLITE_OMIT_AUTOINIT. -D 2022-09-05T18:17:03.632 +C Add\sa\sprototype\sfor\sa\sscript,\ssimilar\sto\stool/omittest.tcl,\sthat\sis\sdesigned\nto\stest\sbuilds\susing\sMSVC\sto\sensure\sthey\swork\swith\svarious\sOMIT\soptions. +D 2022-09-05T20:42:01.229 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1942,6 +1942,7 @@ F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845 +F tool/omittest-msvc.tcl 64617a970928ac35057e0161dfea0bf9a97743664d5a1a50c437e24ed20bc59f F tool/omittest.tcl 3bc9609aceea871e1ca6ed6749df9ce79b89369d22b492f6ce6078f40647cc3f F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b @@ -1999,8 +2000,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c -R 6331ff40a11387db72be313b77cf6d6b +P f74a5ea8c986dc33d3afcda169c38abbe55728c56716cf9991a5e2ef7fc4917a +R 0dcc81f6b8e95b18a530cbbb2b49ddaa +T *branch * msvc-omit-test +T *sym-msvc-omit-test * +T -sym-trunk * U drh -Z c1acc1c86c32ffeafe2e7e809812c8dc +Z 69c1027a1b81005d7e51238e645ea142 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aac27db64a..030340e28e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f74a5ea8c986dc33d3afcda169c38abbe55728c56716cf9991a5e2ef7fc4917a \ No newline at end of file +b1e37a0bd31fa9f8e58c2859a80c23a682b4702eefab2c55b243f1e21d475d6c \ No newline at end of file diff --git a/tool/omittest-msvc.tcl b/tool/omittest-msvc.tcl new file mode 100644 index 0000000000..a47b086fa8 --- /dev/null +++ b/tool/omittest-msvc.tcl @@ -0,0 +1,106 @@ +# Run this TCL script in order to build using MSVC multiple times +# with various compile-time options. Use this to verify that the various +# compile-time options all work with MSVC. +# +set OPTIONS [list \ + SQLITE_OMIT_ALTERTABLE \ + SQLITE_OMIT_ANALYZE \ + SQLITE_OMIT_ATTACH \ + SQLITE_OMIT_AUTHORIZATION \ + SQLITE_OMIT_AUTOINCREMENT \ + SQLITE_OMIT_AUTOINIT \ + SQLITE_OMIT_AUTOMATIC_INDEX \ + SQLITE_OMIT_AUTORESET \ + SQLITE_OMIT_AUTOVACUUM \ + SQLITE_OMIT_BETWEEN_OPTIMIZATION \ + SQLITE_OMIT_BLOB_LITERAL \ + SQLITE_OMIT_BTREECOUNT \ + SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA \ + SQLITE_OMIT_CAST \ + SQLITE_OMIT_CHECK \ + SQLITE_OMIT_COMPILEOPTION_DIAGS \ + SQLITE_OMIT_COMPLETE \ + SQLITE_OMIT_COMPOUND_SELECT \ + SQLITE_OMIT_CONFLICT_CLAUSE \ + SQLITE_OMIT_CTE \ + SQLITE_OMIT_DATETIME_FUNCS \ + SQLITE_OMIT_DECLTYPE \ + SQLITE_OMIT_DEPRECATED \ + SQLITE_OMIT_DESERIALIZE \ + SQLITE_OMIT_DISKIO \ + SQLITE_OMIT_EXPLAIN \ + SQLITE_OMIT_FLAG_PRAGMAS \ + SQLITE_OMIT_FLOATING_POINT \ + SQLITE_OMIT_FOREIGN_KEY \ + SQLITE_OMIT_GENERATED_COLUMNS \ + SQLITE_OMIT_GET_TABLE \ + SQLITE_OMIT_HEX_INTEGER \ + SQLITE_OMIT_INCRBLOB \ + SQLITE_OMIT_INTEGRITY_CHECK \ + SQLITE_OMIT_INTROSPECTION_PRAGMAS \ + SQLITE_OMIT_JSON \ + SQLITE_OMIT_LIKE_OPTIMIZATION \ + SQLITE_OMIT_LOAD_EXTENSION \ + SQLITE_OMIT_LOCALTIME \ + SQLITE_OMIT_LOOKASIDE \ + SQLITE_OMIT_MEMORYDB \ + SQLITE_OMIT_OR_OPTIMIZATION \ + SQLITE_OMIT_PAGER_PRAGMAS \ + SQLITE_OMIT_PARSER_TRACE \ + SQLITE_OMIT_POPEN \ + SQLITE_OMIT_PRAGMA \ + SQLITE_OMIT_PROGRESS_CALLBACK \ + SQLITE_OMIT_QUICKBALANCE \ + SQLITE_OMIT_RANDOMNESS \ + SQLITE_OMIT_REINDEX \ + SQLITE_OMIT_SCHEMA_PRAGMAS \ + SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ + SQLITE_OMIT_SHARED_CACHE \ + SQLITE_OMIT_SHUTDOWN_DIRECTORIES \ + SQLITE_OMIT_SUBQUERY \ + SQLITE_OMIT_TCL_VARIABLE \ + SQLITE_OMIT_TEMPDB \ + SQLITE_OMIT_TEST_CONTROL \ + SQLITE_OMIT_TRACE \ + SQLITE_OMIT_TRIGGER \ + SQLITE_OMIT_TRUNCATE_OPTIMIZATION \ + SQLITE_OMIT_UPSERT \ + SQLITE_OMIT_UTF16 \ + SQLITE_OMIT_VACUUM \ + SQLITE_OMIT_VIEW \ + SQLITE_OMIT_VIRTUALTABLE \ + SQLITE_OMIT_WAL \ + SQLITE_OMIT_WINDOWFUNC \ + SQLITE_OMIT_WSD \ + SQLITE_OMIT_XFER_OPT \ + SQLITE_ALLOW_ROWID_IN_VIEW \ + SQLITE_DISABLE_DIRSYNC \ + SQLITE_DISABLE_LFS \ + SQLITE_ENABLE_ATOMIC_WRITE \ + SQLITE_ENABLE_COLUMN_METADATA \ + SQLITE_ENABLE_EXPENSIVE_ASSERT \ + SQLITE_ENABLE_FTS3 \ + SQLITE_ENABLE_FTS3_PARENTHESIS \ + SQLITE_ENABLE_FTS4 \ + SQLITE_ENABLE_IOTRACE \ + SQLITE_ENABLE_LOAD_EXTENSION \ + SQLITE_ENABLE_LOCKING_STYLE \ + SQLITE_ENABLE_MEMORY_MANAGEMENT \ + SQLITE_ENABLE_MEMSYS3 \ + SQLITE_ENABLE_MEMSYS5 \ + SQLITE_ENABLE_OVERSIZE_CELL_CHECK \ + SQLITE_ENABLE_RTREE \ + SQLITE_ENABLE_STAT3 \ + SQLITE_ENABLE_UNLOCK_NOTIFY \ + SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ +] +foreach opt $OPTIONS { + exec fossil clean -x + set cmd "nmake /f Makefile.msc CCOPTS=-D$opt USE_FULLWARN=0" + puts $cmd + set res [catch {eval exec $cmd} outtxt] + if {$res} { + puts "FAILED:\n$outtxt" + exit + } +} From 0c4517a61aff270cd71af3402f7188f65cf80a80 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 5 Sep 2022 22:53:24 +0000 Subject: [PATCH 16/16] Get the tool/omittest-msvc.tcl script working. FossilOrigin-Name: 82b89f8a074858a81d841dfc26436e8d39ce4907b8f989eba4d848db16758303 --- manifest | 15 ++++------ manifest.uuid | 2 +- tool/omittest-msvc.tcl | 65 +++++++++++++++++++----------------------- 3 files changed, 36 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 4fca0b4944..1666661e3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sprototype\sfor\sa\sscript,\ssimilar\sto\stool/omittest.tcl,\sthat\sis\sdesigned\nto\stest\sbuilds\susing\sMSVC\sto\sensure\sthey\swork\swith\svarious\sOMIT\soptions. -D 2022-09-05T20:42:01.229 +C Get\sthe\stool/omittest-msvc.tcl\sscript\sworking. +D 2022-09-05T22:53:24.940 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1942,7 +1942,7 @@ F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845 -F tool/omittest-msvc.tcl 64617a970928ac35057e0161dfea0bf9a97743664d5a1a50c437e24ed20bc59f +F tool/omittest-msvc.tcl d6b8f501ac1d7798c4126065030f89812379012cad98a1735d6d7221492abc08 F tool/omittest.tcl 3bc9609aceea871e1ca6ed6749df9ce79b89369d22b492f6ce6078f40647cc3f F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b @@ -2000,11 +2000,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f74a5ea8c986dc33d3afcda169c38abbe55728c56716cf9991a5e2ef7fc4917a -R 0dcc81f6b8e95b18a530cbbb2b49ddaa -T *branch * msvc-omit-test -T *sym-msvc-omit-test * -T -sym-trunk * +P b1e37a0bd31fa9f8e58c2859a80c23a682b4702eefab2c55b243f1e21d475d6c +R 6ca49c20c002174082011fae5352b9a2 U drh -Z 69c1027a1b81005d7e51238e645ea142 +Z 569284e867ffbb9e9a0c2176429e582b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 030340e28e..c61a2eaf21 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b1e37a0bd31fa9f8e58c2859a80c23a682b4702eefab2c55b243f1e21d475d6c \ No newline at end of file +82b89f8a074858a81d841dfc26436e8d39ce4907b8f989eba4d848db16758303 \ No newline at end of file diff --git a/tool/omittest-msvc.tcl b/tool/omittest-msvc.tcl index a47b086fa8..28c4b98317 100644 --- a/tool/omittest-msvc.tcl +++ b/tool/omittest-msvc.tcl @@ -3,9 +3,18 @@ # compile-time options all work with MSVC. # set OPTIONS [list \ - SQLITE_OMIT_ALTERTABLE \ - SQLITE_OMIT_ANALYZE \ - SQLITE_OMIT_ATTACH \ + SQLITE_ALLOW_ROWID_IN_VIEW \ + SQLITE_ENABLE_COLUMN_METADATA \ + SQLITE_ENABLE_EXPENSIVE_ASSERT \ + SQLITE_ENABLE_IOTRACE \ + SQLITE_ENABLE_MEMORY_MANAGEMENT \ + SQLITE_ENABLE_MEMSYS3 \ + SQLITE_ENABLE_MEMSYS5 \ + SQLITE_ENABLE_OVERSIZE_CELL_CHECK \ + SQLITE_ENABLE_UNLOCK_NOTIFY \ + SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ + SQLITE_OMIT_ALTERTABLE-x \ + SQLITE_OMIT_ATTACH-x \ SQLITE_OMIT_AUTHORIZATION \ SQLITE_OMIT_AUTOINCREMENT \ SQLITE_OMIT_AUTOINIT \ @@ -27,15 +36,15 @@ set OPTIONS [list \ SQLITE_OMIT_DECLTYPE \ SQLITE_OMIT_DEPRECATED \ SQLITE_OMIT_DESERIALIZE \ - SQLITE_OMIT_DISKIO \ - SQLITE_OMIT_EXPLAIN \ + SQLITE_OMIT_DISKIO-x \ + SQLITE_OMIT_EXPLAIN-x \ SQLITE_OMIT_FLAG_PRAGMAS \ SQLITE_OMIT_FLOATING_POINT \ SQLITE_OMIT_FOREIGN_KEY \ SQLITE_OMIT_GENERATED_COLUMNS \ SQLITE_OMIT_GET_TABLE \ SQLITE_OMIT_HEX_INTEGER \ - SQLITE_OMIT_INCRBLOB \ + SQLITE_OMIT_INCRBLOB-x \ SQLITE_OMIT_INTEGRITY_CHECK \ SQLITE_OMIT_INTROSPECTION_PRAGMAS \ SQLITE_OMIT_JSON \ @@ -45,19 +54,19 @@ set OPTIONS [list \ SQLITE_OMIT_LOOKASIDE \ SQLITE_OMIT_MEMORYDB \ SQLITE_OMIT_OR_OPTIMIZATION \ - SQLITE_OMIT_PAGER_PRAGMAS \ + SQLITE_OMIT_PAGER_PRAGMAS-x \ SQLITE_OMIT_PARSER_TRACE \ SQLITE_OMIT_POPEN \ - SQLITE_OMIT_PRAGMA \ + SQLITE_OMIT_PRAGMA-x \ SQLITE_OMIT_PROGRESS_CALLBACK \ SQLITE_OMIT_QUICKBALANCE \ SQLITE_OMIT_RANDOMNESS \ - SQLITE_OMIT_REINDEX \ + SQLITE_OMIT_REINDEX-x \ SQLITE_OMIT_SCHEMA_PRAGMAS \ SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ SQLITE_OMIT_SHARED_CACHE \ SQLITE_OMIT_SHUTDOWN_DIRECTORIES \ - SQLITE_OMIT_SUBQUERY \ + SQLITE_OMIT_SUBQUERY-x \ SQLITE_OMIT_TCL_VARIABLE \ SQLITE_OMIT_TEMPDB \ SQLITE_OMIT_TEST_CONTROL \ @@ -66,40 +75,24 @@ set OPTIONS [list \ SQLITE_OMIT_TRUNCATE_OPTIMIZATION \ SQLITE_OMIT_UPSERT \ SQLITE_OMIT_UTF16 \ - SQLITE_OMIT_VACUUM \ - SQLITE_OMIT_VIEW \ - SQLITE_OMIT_VIRTUALTABLE \ + SQLITE_OMIT_VACUUM-x \ + SQLITE_OMIT_VIEW-x \ + SQLITE_OMIT_VIRTUALTABLE-x \ SQLITE_OMIT_WAL \ - SQLITE_OMIT_WINDOWFUNC \ + SQLITE_OMIT_WINDOWFUNC-x \ SQLITE_OMIT_WSD \ SQLITE_OMIT_XFER_OPT \ - SQLITE_ALLOW_ROWID_IN_VIEW \ - SQLITE_DISABLE_DIRSYNC \ - SQLITE_DISABLE_LFS \ - SQLITE_ENABLE_ATOMIC_WRITE \ - SQLITE_ENABLE_COLUMN_METADATA \ - SQLITE_ENABLE_EXPENSIVE_ASSERT \ - SQLITE_ENABLE_FTS3 \ - SQLITE_ENABLE_FTS3_PARENTHESIS \ - SQLITE_ENABLE_FTS4 \ - SQLITE_ENABLE_IOTRACE \ - SQLITE_ENABLE_LOAD_EXTENSION \ - SQLITE_ENABLE_LOCKING_STYLE \ - SQLITE_ENABLE_MEMORY_MANAGEMENT \ - SQLITE_ENABLE_MEMSYS3 \ - SQLITE_ENABLE_MEMSYS5 \ - SQLITE_ENABLE_OVERSIZE_CELL_CHECK \ - SQLITE_ENABLE_RTREE \ - SQLITE_ENABLE_STAT3 \ - SQLITE_ENABLE_UNLOCK_NOTIFY \ - SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ ] +set start [lindex $argv 0] foreach opt $OPTIONS { + if {[regexp x $opt]} continue + if {[string compare $opt $start]<0} continue exec fossil clean -x - set cmd "nmake /f Makefile.msc CCOPTS=-D$opt USE_FULLWARN=0" + set cmd "nmake /f Makefile.msc USE_FULLWARN=0 OPTIMIZATIONS=0" + append cmd " CCOPTS=-D$opt" puts $cmd set res [catch {eval exec $cmd} outtxt] - if {$res} { + if {[regexp {sqlite3.c.\d+.: error} $outtxt]} { puts "FAILED:\n$outtxt" exit }