]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an fts5 bug in large incremental merges.
authordan <dan@noemail.net>
Thu, 26 Feb 2015 14:54:03 +0000 (14:54 +0000)
committerdan <dan@noemail.net>
Thu, 26 Feb 2015 14:54:03 +0000 (14:54 +0000)
FossilOrigin-Name: 208e3cb6b6dc8c7d824b64dec2034004c9fcbba5

ext/fts5/fts5_index.c
manifest
manifest.uuid

index b90e5308d637c2f91f78c45ba3e2ba0fb2a0027d..f24be525d9173162ebdb8fcfec9f2645c680641e 100644 (file)
@@ -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; il<pStruct->nLevel; 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; il<pStruct->nLevel; 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);
index e43204b80305636dc922675ff5207fe47adc0a99..94a134ea1d502d1b3c9d746c30d02900df0b55a4 100644 (file)
--- 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
index c4c9f580d3384f3f74230afa5d1af28e20a0cc4a..32c499775ff6c0de1cb2de40be2baa4ae3b72d35 100644 (file)
@@ -1 +1 @@
-7eb022d7e5fdb180af823c82c47c938e4a7a355f
\ No newline at end of file
+208e3cb6b6dc8c7d824b64dec2034004c9fcbba5
\ No newline at end of file