/ Check-in [b6402b20]
Login

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

Overview
Comment:Add some missing comments to fts3 files. No source code changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b6402b2065b844acb3f1bb94ad964568706bcb86
User & Date: dan 2009-11-21 03:03:22
Context
2009-11-23
13:17
Bump the version number to 3.6.21. check-in: 39214aee user: drh tags: trunk
2009-11-21
03:03
Add some missing comments to fts3 files. No source code changes. check-in: b6402b20 user: dan tags: trunk
01:33
Fix a bug in transaction rollback during backup when the CODEC is enabled that can result in a corrupt backup file. This is only a problem when SQLITE_HAS_CODEC is defined. check-in: f3398fc4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/fts3/fts3.c.

  1256   1256   #define MERGE_OR         4        /* D + D -> D */
  1257   1257   #define MERGE_POS_OR     5        /* P + P -> P */
  1258   1258   #define MERGE_PHRASE     6        /* P + P -> D */
  1259   1259   #define MERGE_POS_PHRASE 7        /* P + P -> P */
  1260   1260   #define MERGE_NEAR       8        /* P + P -> D */
  1261   1261   #define MERGE_POS_NEAR   9        /* P + P -> P */
  1262   1262   
         1263  +/*
         1264  +** Merge the two doclists passed in buffer a1 (size n1 bytes) and a2
         1265  +** (size n2 bytes). The output is written to pre-allocated buffer aBuffer,
         1266  +** which is guaranteed to be large enough to hold the results. The number
         1267  +** of bytes written to aBuffer is stored in *pnBuffer before returning.
         1268  +**
         1269  +** If successful, SQLITE_OK is returned. Otherwise, if a malloc error
         1270  +** occurs while allocating a temporary buffer as part of the merge operation,
         1271  +** SQLITE_NOMEM is returned.
         1272  +*/
  1263   1273   static int fts3DoclistMerge(
  1264   1274     int mergetype,                  /* One of the MERGE_XXX constants */
  1265         -  int nParam1,
  1266         -  int nParam2,
         1275  +  int nParam1,                    /* Used by MERGE_NEAR and MERGE_POS_NEAR */
         1276  +  int nParam2,                    /* Used by MERGE_NEAR and MERGE_POS_NEAR */
  1267   1277     char *aBuffer,                  /* Pre-allocated output buffer */
  1268   1278     int *pnBuffer,                  /* OUT: Bytes written to aBuffer */
  1269   1279     char *a1,                       /* Buffer containing first doclist */
  1270   1280     int n1,                         /* Size of buffer a1 */
  1271   1281     char *a2,                       /* Buffer containing second doclist */
  1272   1282     int n2                          /* Size of buffer a2 */
  1273   1283   ){
................................................................................
  1421   1431   typedef struct TermSelect TermSelect;
  1422   1432   struct TermSelect {
  1423   1433     int isReqPos;
  1424   1434     char *aOutput;                  /* Malloc'd output buffer */
  1425   1435     int nOutput;                    /* Size of output in bytes */
  1426   1436   };
  1427   1437   
         1438  +/*
         1439  +** This function is used as the sqlite3Fts3SegReaderIterate() callback when
         1440  +** querying the full-text index for a doclist associated with a term or
         1441  +** term-prefix.
         1442  +*/
  1428   1443   static int fts3TermSelectCb(
  1429   1444     Fts3Table *p,                   /* Virtual table object */
  1430   1445     void *pContext,                 /* Pointer to TermSelect structure */
  1431   1446     char *zTerm,
  1432   1447     int nTerm,
  1433   1448     char *aDoclist,
  1434   1449     int nDoclist
................................................................................
  1580   1595     sqlite3_free(apSegment);
  1581   1596     return rc;
  1582   1597   }
  1583   1598   
  1584   1599   
  1585   1600   /* 
  1586   1601   ** Return a DocList corresponding to the phrase *pPhrase.
  1587         -**
  1588         -** The resulting DL_DOCIDS doclist is stored in pResult, which is
  1589         -** overwritten.
  1590   1602   */
  1591   1603   static int fts3PhraseSelect(
  1592   1604     Fts3Table *p,                   /* Virtual table handle */
  1593   1605     Fts3Phrase *pPhrase,            /* Phrase to return a doclist for */
  1594   1606     int isReqPos,                   /* True if output should contain positions */
  1595   1607     char **paOut,                   /* OUT: Pointer to malloc'd result buffer */
  1596   1608     int *pnOut                      /* OUT: Size of buffer at *paOut */
................................................................................
  1643   1655     }else{
  1644   1656       sqlite3_free(pOut);
  1645   1657     }
  1646   1658     return rc;
  1647   1659   }
  1648   1660   
  1649   1661   /*
  1650         -** Evaluate the full-text expression pExpr against fts3 table pTab. Write
  1651         -** the results into pRes.
         1662  +** Evaluate the full-text expression pExpr against fts3 table pTab. Store
         1663  +** the resulting doclist in *paOut and *pnOut.
  1652   1664   */
  1653   1665   static int evalFts3Expr(
  1654   1666     Fts3Table *p,                   /* Virtual table handle */
  1655   1667     Fts3Expr *pExpr,                /* Parsed fts3 expression */
  1656   1668     char **paOut,                   /* OUT: Pointer to malloc'd result buffer */
  1657   1669     int *pnOut                      /* OUT: Size of buffer at *paOut */
  1658   1670   ){
................................................................................
  1831   1843   ** This is the xEof method of the virtual table. SQLite calls this 
  1832   1844   ** routine to find out if it has reached the end of a result set.
  1833   1845   */
  1834   1846   static int fts3EofMethod(sqlite3_vtab_cursor *pCursor){
  1835   1847     return ((Fts3Cursor *)pCursor)->isEof;
  1836   1848   }
  1837   1849   
  1838         -/* This is the xColumn method of the virtual table.  The SQLite
         1850  +/* 
         1851  +** This is the xColumn method of the virtual table.  The SQLite
  1839   1852   ** core calls this method during a query when it needs the value
  1840   1853   ** of a column from the virtual table.  This method needs to use
  1841   1854   ** one of the sqlite3_result_*() routines to store the requested
  1842   1855   ** value back in the pContext.
  1843   1856   */
  1844   1857   static int fts3ColumnMethod(sqlite3_vtab_cursor *pCursor,
  1845   1858                             sqlite3_context *pContext, int idxCol){

Changes to ext/fts3/fts3_write.c.

  1718   1718     char *aDoclist,
  1719   1719     int nDoclist
  1720   1720   ){
  1721   1721     SegmentWriter **ppW = (SegmentWriter **)pContext;
  1722   1722     return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist);
  1723   1723   }
  1724   1724   
         1725  +/*
         1726  +** This function is used to iterate through a contiguous set of terms 
         1727  +** stored in the full-text index. It merges data contained in one or 
         1728  +** more segments to support this.
         1729  +**
         1730  +** The second argument is passed an array of pointers to SegReader objects
         1731  +** allocated with sqlite3Fts3SegReaderNew(). This function merges the range 
         1732  +** of terms selected by each SegReader. If a single term is present in
         1733  +** more than one segment, the associated doclists are merged. For each
         1734  +** term and (possibly merged) doclist in the merged range, the callback
         1735  +** function xFunc is invoked with its arguments set as follows.
         1736  +**
         1737  +**   arg 0: Copy of 'p' parameter passed to this function
         1738  +**   arg 1: Copy of 'pContext' parameter passed to this function
         1739  +**   arg 2: Pointer to buffer containing term
         1740  +**   arg 3: Size of arg 2 buffer in bytes
         1741  +**   arg 4: Pointer to buffer containing doclist
         1742  +**   arg 5: Size of arg 2 buffer in bytes
         1743  +**
         1744  +** The 4th argument to this function is a pointer to a structure of type
         1745  +** Fts3SegFilter, defined in fts3Int.h. The contents of this structure
         1746  +** further restrict the range of terms that callbacks are made for and
         1747  +** modify the behaviour of this function. See comments above structure
         1748  +** definition for details.
         1749  +*/
  1725   1750   int sqlite3Fts3SegReaderIterate(
  1726   1751     Fts3Table *p,                   /* Virtual table handle */
  1727   1752     Fts3SegReader **apSegment,      /* Array of Fts3SegReader objects */
  1728   1753     int nSegment,                   /* Size of apSegment array */
  1729   1754     Fts3SegFilter *pFilter,         /* Restrictions on range of iteration */
  1730   1755     int (*xFunc)(Fts3Table *, void *, char *, int, char *, int),  /* Callback */
  1731   1756     void *pContext                  /* Callback context (2nd argument) */