]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Merge trunk changes into experimental branch.
authordan <dan@noemail.net>
Thu, 21 Oct 2010 15:49:47 +0000 (15:49 +0000)
committerdan <dan@noemail.net>
Thu, 21 Oct 2010 15:49:47 +0000 (15:49 +0000)
FossilOrigin-Name: fd1e5cade04961c2f5438a1dfcc2e15eafb4503f

1  2 
ext/fts3/fts3.c
ext/fts3/fts3Int.h
manifest
manifest.uuid
src/vdbeblob.c

diff --cc ext/fts3/fts3.c
index 752d0e9bcf40a0e45abc37ca2a2e001d510e7726,5323a5c1aecbba3face53ca47bffaba04c06596d..c3bbb08297ec96e0d3744012732896b2577e9f7e
@@@ -441,6 -441,6 +441,7 @@@ static int fts3DisconnectMethod(sqlite3
    int i;
  
    assert( p->nPendingData==0 );
++  assert( p->pSegments==0 );
  
    /* Free any prepared statements held */
    for(i=0; i<SizeofArray(p->aStmt); i++){
@@@ -2045,67 -1880,12 +2046,66 @@@ static int fts3TermSelect
      }
    }
  
 -finished:
 -  sqlite3_reset(pStmt);
 -  for(i=0; i<nSegment; i++){
 -    sqlite3Fts3SegReaderFree(p, apSegment[i]);
 +  fts3SegReaderArrayFree(pArray);
 +  pTok->pArray = 0;
 +  return rc;
 +}
 +
 +/*
 +** This function counts the total number of docids in the doclist stored
 +** in buffer aList[], size nList bytes.
 +**
 +** If the isPoslist argument is true, then it is assumed that the doclist
 +** contains a position-list following each docid. Otherwise, it is assumed
 +** that the doclist is simply a list of docids stored as delta encoded 
 +** varints.
 +*/
 +static int fts3DoclistCountDocids(int isPoslist, char *aList, int nList){
 +  int nDoc = 0;                   /* Return value */
 +  if( aList ){
 +    char *aEnd = &aList[nList];   /* Pointer to one byte after EOF */
 +    char *p = aList;              /* Cursor */
 +    if( !isPoslist ){
 +      /* The number of docids in the list is the same as the number of 
 +      ** varints. In FTS3 a varint consists of a single byte with the 0x80 
 +      ** bit cleared and zero or more bytes with the 0x80 bit set. So to
 +      ** count the varints in the buffer, just count the number of bytes
 +      ** with the 0x80 bit clear.  */
 +      while( p<aEnd ) nDoc += (((*p++)&0x80)==0);
 +    }else{
 +      while( p<aEnd ){
 +        nDoc++;
 +        while( (*p++)&0x80 );     /* Skip docid varint */
 +        fts3PoslistCopy(0, &p);   /* Skip over position list */
 +      }
 +    }
 +  }
 +
 +  return nDoc;
 +}
 +
 +/*
 +** Call sqlite3Fts3DeferToken() for each token in the expression pExpr.
 +*/
 +static int fts3DeferExpression(Fts3Cursor *pCsr, Fts3Expr *pExpr){
 +  int rc = SQLITE_OK;
 +  if( pExpr ){
 +    rc = fts3DeferExpression(pCsr, pExpr->pLeft);
 +    if( rc==SQLITE_OK ){
 +      rc = fts3DeferExpression(pCsr, pExpr->pRight);
 +    }
 +    if( pExpr->eType==FTSQUERY_PHRASE ){
 +      int iCol = pExpr->pPhrase->iColumn;
 +      int i;
 +      pExpr->bDeferred = 1;
 +      for(i=0; rc==SQLITE_OK && i<pExpr->pPhrase->nToken; i++){
 +        Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];
 +        if( pToken->pDeferred==0 ){
 +          rc = sqlite3Fts3DeferToken(pCsr, pToken, iCol);
 +        }
 +      }
 +    }
    }
 -  sqlite3_free(apSegment);
    return rc;
  }
  
index e905dfc716cd8979fa828a8a6d016043bec30a1c,8ed31aedd882b59f5abc024138fda60a8221f170..c982717294547f3fc9e7e4e8a1f0735ec195204e
@@@ -129,8 -134,6 +129,7 @@@ struct Fts3Table 
    int nNodeSize;                  /* Soft limit for node size */
    u8 bHasContent;                 /* True if %_content table exists */
    u8 bHasDocsize;                 /* True if %_docsize table exists */
 +  sqlite3_blob *pSegments;        /* Blob handle open on %_segments table */
  
    /* The following hash table is used to buffer pending index updates during
    ** transactions. Variable nPendingData estimates the memory size of the 
diff --cc manifest
index 2d3d7d30aef416f93442dc6d13d3b4db918df86f,f1ff38cd7fe8186a0f9eaa29f1659a62c7bf9c0f..334c32ac0cc56bd425dac74a8d6119813c0f98cb
+++ b/manifest
@@@ -1,7 -1,7 +1,7 @@@
- C Updates\sto\sFTS4\sto\simprove\sperformance\sand\smake\smore\saccurate\scost\sestimates\sfor\sprefix\sterms.
- D 2010-10-20T18:56:04
 -C Fix\ssome\ssegfaults\sthat\scould\soccur\sin\sobscure\scircumstances\swhere\serror\smessages\scontained\scharacters\sthat\scould\sbe\smistaken\sfor\sprintf\sformat\sspecifiers.
 -D 2010-10-21T15:12:44
++C Merge\strunk\schanges\sinto\sexperimental\sbranch.
++D 2010-10-21T15:49:47
  F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
- F Makefile.in b01fdfcfecf8a0716c29867a67959f6148b79961
+ F Makefile.in 2c8cefd962eca0147132c7cf9eaa4bb24c656f3f
  F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
  F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151
  F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6
@@@ -61,10 -61,10 +61,10 @@@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f
  F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
  F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
  F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
- F ext/fts3/fts3.c ce7bcd1f42e74912149fe6201fc63a6ac0db42a8
 -F ext/fts3/fts3.c 03be86c59ac1a60d448c6eda460a8975ff2f170d
++F ext/fts3/fts3.c f423181b76fc35c38c4dcf4d8aac012813817f34
  F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
- F ext/fts3/fts3Int.h 9fbe422f7d0e005371702acaa3cd44283a67c389
 -F ext/fts3/fts3Int.h b4f0b05ccafe1e5b4be2f052e9840dbd78a0395f
 -F ext/fts3/fts3_expr.c 42d5697731cd30fbeabd081bb3e6d3df5531f606
++F ext/fts3/fts3Int.h f80be5abfb24e51cb816287230c0d0c8f1712f59
 +F ext/fts3/fts3_expr.c a5aee50edde20e5c9116199bd58be869a3a22c9f
  F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c
  F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec
  F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295
@@@ -231,10 -230,10 +231,10 @@@ F src/vdbe.h 4de0efb4b0fdaaa900cf419b35
  F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4
  F src/vdbeapi.c 5368714fa750270cf6430160287c21adff44582d
  F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716
- F src/vdbeblob.c c8cbe6ce28cc8bf806ea0818b5167dd9a27c48a3
 -F src/vdbeblob.c 6e10c214efa3514ca2f1714773cc4cc5c7b05175
++F src/vdbeblob.c e6e485934fcc9201dd1bfd65864be2bb14243b5d
  F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9
  F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
- F src/vtab.c 6c90e3e65b2f026fc54703a8f3c917155f419d87
+ F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30
  F src/wal.c 0dc7eb9e907a2c280cdcde876d313e07ea4ad811
  F src/wal.h 96669b645e27cd5a111ba59f0cae7743a207bc3c
  F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
@@@ -875,7 -873,7 +875,7 @@@ F tool/speedtest2.tcl ee2149167303ba8e9
  F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
  F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
  F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
- P 5ae0ba447a561e3b6637b52f9b83a9fc683d2572
- R acd75bd5094c2beea7f56f4633b47ea2
 -P 2c3c4ba035e548e97101142692133cf685da16bc
 -R 18a7b139ced85b4a9a48c95f0f44b0f9
++P d0a450ce78e99f55c862f26f9332786660007a0a f91471e7234db490f97298b1ccb8d6c7fc45b089
++R 3c9178950d1e4be3aecf1d9f3dffa25a
  U dan
- Z 910cba31e6572b93e93d39c91f91b9da
 -Z ed59bb88307b21a6af9f1327c9400518
++Z 5bbfebd98739f68617c4d86986bdd88f
diff --cc manifest.uuid
index ab22dd85a7ca3a3fbe3c868f184bd9b73d1824a0,2ff27688e54e3805412a417b3b4b0c7a0d4eb852..278a75661449baa0e15dffac4dc090224cdf97cd
@@@ -1,1 -1,1 +1,1 @@@
- d0a450ce78e99f55c862f26f9332786660007a0a
 -f91471e7234db490f97298b1ccb8d6c7fc45b089
++fd1e5cade04961c2f5438a1dfcc2e15eafb4503f
diff --cc src/vdbeblob.c
index f7ee670f26aa19bea3242cb5deef38a5ea576cf1,38587ee5674821697c9a5f395584bbdf9d12c8dd..129aad7363094b1b0fa358038b1755c6adeb6d68
@@@ -285,20 -224,60 +285,18 @@@ int sqlite3_blob_open
      if( db->mallocFailed ){
        goto blob_open_out;
      }
 -
 -    sqlite3_bind_int64((sqlite3_stmt *)v, 1, iRow);
 -    rc = sqlite3_step((sqlite3_stmt *)v);
 -    if( rc!=SQLITE_ROW ){
 -      nAttempt++;
 -      rc = sqlite3_finalize((sqlite3_stmt *)v);
 -      sqlite3DbFree(db, zErr);
 -      zErr = sqlite3MPrintf(db, "%s", sqlite3_errmsg(db));
 -      v = 0;
 -    }
 -  } while( nAttempt<5 && rc==SQLITE_SCHEMA );
 -
 -  if( rc==SQLITE_ROW ){
 -    /* The row-record has been opened successfully. Check that the
 -    ** column in question contains text or a blob. If it contains
 -    ** text, it is up to the caller to get the encoding right.
 -    */
 -    Incrblob *pBlob;
 -    u32 type = v->apCsr[0]->aType[iCol];
--
 -    if( type<12 ){
 -      sqlite3DbFree(db, zErr);
 -      zErr = sqlite3MPrintf(db, "cannot open value of type %s",
 -          type==0?"null": type==7?"real": "integer"
 -      );
 -      rc = SQLITE_ERROR;
 -      goto blob_open_out;
 -    }
 -    pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));
 -    if( db->mallocFailed ){
 -      sqlite3DbFree(db, pBlob);
 -      goto blob_open_out;
 -    }
 -    pBlob->flags = flags;
 -    pBlob->pCsr =  v->apCsr[0]->pCursor;
 -    sqlite3BtreeEnterCursor(pBlob->pCsr);
 -    sqlite3BtreeCacheOverflow(pBlob->pCsr);
 -    sqlite3BtreeLeaveCursor(pBlob->pCsr);
 -    pBlob->pStmt = (sqlite3_stmt *)v;
 -    pBlob->iOffset = v->apCsr[0]->aOffset[iCol];
 -    pBlob->nByte = sqlite3VdbeSerialTypeLen(type);
 -    pBlob->db = db;
 -    *ppBlob = (sqlite3_blob *)pBlob;
 -    rc = SQLITE_OK;
 -  }else if( rc==SQLITE_OK ){
 -    sqlite3DbFree(db, zErr);
 -    zErr = sqlite3MPrintf(db, "no such rowid: %lld", iRow);
 -    rc = SQLITE_ERROR;
 -  }
 +    sqlite3_bind_int64(pBlob->pStmt, 1, iRow);
 +    rc = blobSeekToRow(pBlob, iRow, &zErr);
 +  } while( (++nAttempt)<5 && rc==SQLITE_SCHEMA );
  
  blob_open_out:
 -  if( v && (rc!=SQLITE_OK || db->mallocFailed) ){
 -    sqlite3VdbeFinalize(v);
 +  if( rc==SQLITE_OK && db->mallocFailed==0 ){
 +    *ppBlob = (sqlite3_blob *)pBlob;
 +  }else{
 +    if( v ) sqlite3VdbeFinalize(v);
 +    if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);
 +    sqlite3DbFree(db, pBlob);
    }
    sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr);
    sqlite3DbFree(db, zErr);
    sqlite3StackFree(db, pParse);