/ Check-in [a6fcf910]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix gcc gripe about parens in a ||/&& in mergePosList(). Drop unused pBlob/nBlob in index_insert_term(). Fix NULL deref in an assertion in docListUpdate() delete case. Minor code tightening in docListUpdate(). (CVS 3367)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a6fcf9101a831bf5f129c6045eabf30376d365dc
User & Date: shess 2006-08-25 19:20:26
Context
2006-08-25
23:42
Add support for INSERT INTO ... DEFAULT VALUES. Tickets #299, #1940. (CVS 3368) check-in: bc84cb54 user: drh tags: trunk
19:20
Fix gcc gripe about parens in a ||/&& in mergePosList(). Drop unused pBlob/nBlob in index_insert_term(). Fix NULL deref in an assertion in docListUpdate() delete case. Minor code tightening in docListUpdate(). (CVS 3367) check-in: a6fcf910 user: shess tags: trunk
2006-08-24
15:18
Documentation updates for the new SQLITE_FUNCTION authorization. (CVS 3366) check-in: e029637e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/fts1/fulltext.c.

   290    290    * otherwise pUpdate, which must contain only the single docid [iDocid], is
   291    291    * inserted (if not present) or updated (if already present). */
   292    292   static int docListUpdate(DocList *d, sqlite_int64 iDocid, DocList *pUpdate){
   293    293     int modified = 0;
   294    294     DocListReader reader;
   295    295     char *p;
   296    296   
   297         -  assert( d->iType==pUpdate->iType);
   298    297     if( pUpdate!=NULL ){
          298  +    assert( d->iType==pUpdate->iType);
   299    299       assert( iDocid==firstDocid(pUpdate) );
   300    300     }
   301    301   
   302    302     readerInit(&reader, d);
   303         -  while( !readerAtEnd(&reader) ){
   304         -    if( peekDocid(&reader) >= iDocid ) break;
          303  +  while( !readerAtEnd(&reader) && peekDocid(&reader)<iDocid ){
   305    304       skipDocument(&reader);
   306    305     }
   307    306   
   308    307     p = reader.p;
   309    308     /* Delete if there is a matching element. */
   310    309     if( !readerAtEnd(&reader) && iDocid==peekDocid(&reader) ){
   311    310       skipDocument(&reader);
................................................................................
   312    311       memmove(p, reader.p, docListEnd(d) - reader.p);
   313    312       d->nData -= (reader.p - p);
   314    313       modified = 1;
   315    314     }
   316    315   
   317    316     /* Insert if indicated. */
   318    317     if( pUpdate!=NULL ){
   319         -    int iDoclist;
   320         -    int nNeed;
          318  +    int iDoclist = p-d->pData;
   321    319       docListAddEndPos(pUpdate);
   322         -    nNeed = pUpdate->nData;
   323    320   
   324         -    iDoclist = p - d->pData;
   325         -    d->pData = realloc(d->pData, d->nData+nNeed);
          321  +    d->pData = realloc(d->pData, d->nData+pUpdate->nData);
   326    322       p = d->pData + iDoclist;
   327    323   
   328         -    memmove(p+nNeed, p, docListEnd(d) - p);
   329         -    memcpy(p, pUpdate->pData, nNeed);
   330         -    p += nNeed;
   331         -    d->nData += nNeed;
          324  +    memmove(p+pUpdate->nData, p, docListEnd(d) - p);
          325  +    memcpy(p, pUpdate->pData, pUpdate->nData);
          326  +    d->nData += pUpdate->nData;
   332    327       modified = 1;
   333    328     }
   334    329   
   335    330     return modified;
   336    331   }
   337    332   
   338    333   /* Split the second half of doclist d into a separate doclist d2.  Returns 1
................................................................................
   409    404           match = 1;
   410    405         }
   411    406         if( m->pOut->iType >= DL_POSITIONS ){
   412    407           docListAddPos(m->pOut, in_pos);
   413    408         }
   414    409         block_pos = readPosition(pBlockReader);
   415    410         in_pos = readPosition(&m->in);
   416         -    } else if( in_pos==-1 || block_pos!=-1 && block_pos-m->iOffset<in_pos ){
          411  +    } else if( in_pos==-1 || (block_pos!=-1 && block_pos-m->iOffset<in_pos) ){
   417    412         block_pos = readPosition(pBlockReader);
   418    413       } else {
   419    414         in_pos = readPosition(&m->in);
   420    415       }
   421    416     }
   422    417     if( m->pOut->iType >= DL_POSITIONS && match ){
   423    418       docListAddEndPos(m->pOut);
................................................................................
  1334   1329   }
  1335   1330   /* Update the %_terms table to map the term [zTerm] to the given rowid. */
  1336   1331   static int index_insert_term(fulltext_vtab *v, const char *zTerm, int nTerm,
  1337   1332                                sqlite_int64 iDocid, DocList *p){
  1338   1333     sqlite_int64 iFirst;
  1339   1334     sqlite_int64 iIndexRow;
  1340   1335     DocList doclist;
  1341         -  char *pBlob = NULL;
  1342         -  int nBlob = 0;
  1343   1336   
  1344   1337     int rc = term_chunk_select(v, zTerm, nTerm, iDocid, &iFirst);
  1345   1338     if( rc==SQLITE_DONE ){
  1346   1339       docListInit(&doclist, DL_POSITIONS_OFFSETS, 0, 0);
  1347   1340       if( docListUpdate(&doclist, iDocid, p) ){
  1348   1341         rc = term_insert(v, zTerm, nTerm, iDocid, &doclist);
  1349   1342         docListDestroy(&doclist);