From: dan Date: Thu, 26 Feb 2015 14:54:03 +0000 (+0000) Subject: Fix an fts5 bug in large incremental merges. X-Git-Tag: version-3.8.11~114^2~85 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a7e11c6299c2e4816531cde21dafc086d609a8f;p=thirdparty%2Fsqlite.git Fix an fts5 bug in large incremental merges. FossilOrigin-Name: 208e3cb6b6dc8c7d824b64dec2034004c9fcbba5 --- diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index b90e5308d6..f24be525d9 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1183,6 +1183,7 @@ static void fts5StructureWrite(Fts5Index *p, int iIdx, Fts5Structure *pStruct){ } #if 0 +static void fts5DebugStructure(int*,Fts5Buffer*,Fts5Structure*); static void fts5PrintStructure(const char *zCaption, Fts5Structure *pStruct){ int rc = SQLITE_OK; Fts5Buffer buf; @@ -1201,8 +1202,9 @@ static int fts5SegmentSize(Fts5StructureSegment *pSeg){ } /* -** Return a copy of index structure pStruct. Except, promote as many segments -** as possible to level iPromote. If an OOM occurs, NULL is returned. +** Return a copy of index structure pStruct. Except, promote as many +** segments as possible to level iPromote. If an OOM occurs, NULL is +** returned. */ static void fts5StructurePromoteTo( Fts5Index *p, @@ -1213,17 +1215,19 @@ static void fts5StructurePromoteTo( int il, is; Fts5StructureLevel *pOut = &pStruct->aLevel[iPromote]; - for(il=iPromote+1; ilnLevel; il++){ - Fts5StructureLevel *pLvl = &pStruct->aLevel[il]; - if( pLvl->nMerge ) return; - for(is=pLvl->nSeg-1; is>=0; is--){ - int sz = fts5SegmentSize(&pLvl->aSeg[is]); - if( sz>szPromote ) return; - fts5StructureExtendLevel(&p->rc, pStruct, iPromote, 1, 1); - if( p->rc ) return; - memcpy(pOut->aSeg, &pLvl->aSeg[is], sizeof(Fts5StructureSegment)); - pOut->nSeg++; - pLvl->nSeg--; + if( pOut->nMerge==0 ){ + for(il=iPromote+1; ilnLevel; il++){ + Fts5StructureLevel *pLvl = &pStruct->aLevel[il]; + if( pLvl->nMerge ) return; + for(is=pLvl->nSeg-1; is>=0; is--){ + int sz = fts5SegmentSize(&pLvl->aSeg[is]); + if( sz>szPromote ) return; + fts5StructureExtendLevel(&p->rc, pStruct, iPromote, 1, 1); + if( p->rc ) return; + memcpy(pOut->aSeg, &pLvl->aSeg[is], sizeof(Fts5StructureSegment)); + pOut->nSeg++; + pLvl->nSeg--; + } } } } @@ -3343,6 +3347,7 @@ static void fts5IndexWork( } *ppStruct = pStruct; } + } } @@ -3464,6 +3469,7 @@ static void fts5FlushOneHash(Fts5Index *p, int iHash, int *pnLeaf){ fts5StructurePromote(p, 0, pStruct); } + if( p->pConfig->nAutomerge>0 ) fts5IndexWork(p, iHash, &pStruct, pgnoLast); fts5IndexCrisisMerge(p, iHash, &pStruct); fts5StructureWrite(p, iHash, pStruct); diff --git a/manifest b/manifest index e43204b803..94a134ea1d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Instead\sof\sthe\s4-byte\sfields,\suse\sregular\svarints\sfor\sthe\sposlist-size\sfield\sin\sfts5_hash.c. -D 2015-02-25T19:24:37.378 +C Fix\san\sfts5\sbug\sin\slarge\sincremental\smerges. +D 2015-02-26T14:54:03.688 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -112,7 +112,7 @@ F ext/fts5/fts5_buffer.c b92ba0eb67532d174934087f93716caf9a2168c7 F ext/fts5/fts5_config.c e3421a76c2abd33a05ac09df0c97c64952d1e700 F ext/fts5/fts5_expr.c eee52c9df84eade48eaa3f50c8876f44b552ff9b F ext/fts5/fts5_hash.c 9032dd35bf8da6f9d4fc8c955c348dd6d229d8e4 -F ext/fts5/fts5_index.c 220321d06ae87496e22bb92fe52b65d84549ef0e +F ext/fts5/fts5_index.c 97ce5c919be5a70b623f89c66c60bda15408d577 F ext/fts5/fts5_storage.c f7c12c9f454b2a525827b3d85fd222789236f548 F ext/fts5/fts5_tcl.c 1293fac2bb26903fd3d5cdee59c5885ba7e620d5 F ext/fts5/fts5_tokenize.c 0d108148c26132448487926fe683425002aee369 @@ -1284,7 +1284,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bc7be2fcfd29d6f1b567b69b3b20896eceb99798 -R 79d1ace6d8bc7671e8fd6ed98da16ffb +P 7eb022d7e5fdb180af823c82c47c938e4a7a355f +R a31df37a1e652372bc458cec184c4145 U dan -Z a35e490814ed578ad02ebd09e2509be2 +Z ba5b725699c58a1a7e341156a5c76451 diff --git a/manifest.uuid b/manifest.uuid index c4c9f580d3..32c499775f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7eb022d7e5fdb180af823c82c47c938e4a7a355f \ No newline at end of file +208e3cb6b6dc8c7d824b64dec2034004c9fcbba5 \ No newline at end of file