fts1.c File Reference

Go to the source code of this file.

Classes

struct  StringBuffer
struct  DocList
struct  DocListReader
struct  QueryTerm
struct  Query
struct  Snippet
struct  Snippet::snippetMatch
struct  fulltext_vtab
struct  fulltext_cursor
struct  Token
struct  TableSpec

Defines

#define TRACE(A)
#define VARINT_MAX   10
#define DL_DEFAULT   DL_POSITIONS
#define CHUNK_MAX   256
#define TOKEN_EOF   0
#define TOKEN_SPACE   1
#define TOKEN_ID   2
#define TOKEN_STRING   3
#define TOKEN_PUNCT   4
#define IdChar(C)   (((c=C)&0x80)!=0 || (c>0x1f && isIdChar[c-0x20]))
#define FTS1_ROTOR_SZ   (32)
#define FTS1_ROTOR_MASK   (FTS1_ROTOR_SZ-1)
#define SNIPPET_IGNORE   0
#define SNIPPET_DESIRED   1

Typedefs

typedef struct fulltext_vtab fulltext_vtab

Enumerations

enum  DocListType {
  DL_DOCIDS, DL_POSITIONS, DL_POSITIONS_OFFSETS, DL_DOCIDS,
  DL_POSITIONS, DL_POSITIONS_OFFSETS, DL_DOCIDS, DL_POSITIONS,
  DL_POSITIONS_OFFSETS
}
enum  { POS_END = 0, POS_COLUMN, POS_BASE }
enum  QueryType {
  QUERY_GENERIC, QUERY_ROWID, QUERY_FULLTEXT, QUERY_GENERIC,
  QUERY_ROWID, QUERY_FULLTEXT, QUERY_GENERIC, QUERY_DOCID,
  QUERY_FULLTEXT
}
enum  fulltext_statement {
  CONTENT_INSERT_STMT, CONTENT_SELECT_STMT, CONTENT_UPDATE_STMT, CONTENT_DELETE_STMT,
  TERM_SELECT_STMT, TERM_SELECT_ALL_STMT, TERM_INSERT_STMT, TERM_UPDATE_STMT,
  TERM_DELETE_STMT, MAX_STMT, CONTENT_INSERT_STMT, CONTENT_SELECT_STMT,
  CONTENT_UPDATE_STMT, CONTENT_DELETE_STMT, CONTENT_EXISTS_STMT, BLOCK_INSERT_STMT,
  BLOCK_SELECT_STMT, BLOCK_DELETE_STMT, BLOCK_DELETE_ALL_STMT, SEGDIR_MAX_INDEX_STMT,
  SEGDIR_SET_STMT, SEGDIR_SELECT_LEVEL_STMT, SEGDIR_SPAN_STMT, SEGDIR_DELETE_STMT,
  SEGDIR_SELECT_SEGMENT_STMT, SEGDIR_SELECT_ALL_STMT, SEGDIR_DELETE_ALL_STMT, SEGDIR_COUNT_STMT,
  MAX_STMT, CONTENT_INSERT_STMT, CONTENT_SELECT_STMT, CONTENT_UPDATE_STMT,
  CONTENT_DELETE_STMT, CONTENT_EXISTS_STMT, BLOCK_INSERT_STMT, BLOCK_SELECT_STMT,
  BLOCK_DELETE_STMT, BLOCK_DELETE_ALL_STMT, SEGDIR_MAX_INDEX_STMT, SEGDIR_SET_STMT,
  SEGDIR_SELECT_LEVEL_STMT, SEGDIR_SPAN_STMT, SEGDIR_DELETE_STMT, SEGDIR_SELECT_SEGMENT_STMT,
  SEGDIR_SELECT_ALL_STMT, SEGDIR_DELETE_ALL_STMT, SEGDIR_COUNT_STMT, MAX_STMT
}

Functions

static void initStringBuffer (StringBuffer *sb)
static void nappend (StringBuffer *sb, const char *zFrom, int nFrom)
static void append (StringBuffer *sb, const char *zFrom)
static int putVarint (char *p, sqlite_int64 v)
static int getVarint (const char *p, sqlite_int64 *v)
static int getVarint32 (const char *p, int *pi)
static int safe_isspace (char c)
static int safe_tolower (char c)
static int safe_isalnum (char c)
static void docListInit (DocList *d, DocListType iType, const char *pData, int nData)
static DocListdocListNew (DocListType iType)
static void docListDestroy (DocList *d)
static void docListDelete (DocList *d)
static char * docListEnd (DocList *d)
static void appendVarint (DocList *d, sqlite_int64 i)
static void docListAddDocid (DocList *d, sqlite_int64 iDocid)
static void addPos (DocList *d, int iColumn, int iPos)
static void docListAddPos (DocList *d, int iColumn, int iPos)
static void docListAddPosOffset (DocList *d, int iColumn, int iPos, int iStartOffset, int iEndOffset)
static void readerInit (DocListReader *r, DocList *pDoclist)
static int atEnd (DocListReader *pReader)
static sqlite_int64 peekDocid (DocListReader *pReader)
static sqlite_int64 readDocid (DocListReader *pReader)
static int readPosition (DocListReader *pReader, int *iColumn)
static void skipPositionList (DocListReader *pReader)
static void skipDocument (DocListReader *pReader)
static int skipToDocid (DocListReader *pReader, sqlite_int64 iDocid)
static sqlite_int64 firstDocid (DocList *d)
static void docListRestrictColumn (DocList *in, int iRestrictColumn)
static void docListDiscardEmpty (DocList *in)
static void docListSpliceElement (DocListReader *r, sqlite_int64 iDocid, const char *pSource, int nSource)
static void docListUpdate (DocList *d, DocList *pUpdate)
static void docListAccumulate (DocList *pAcc, DocList *pUpdate)
static sqlite_int64 nextDocid (DocListReader *pIn)
static void mergePosList (DocListReader *pLeft, DocListReader *pRight, sqlite_int64 iDocid, DocList *pOut)
static void docListPhraseMerge (DocList *pLeft, DocList *pRight, DocList *pOut)
static void docListAndMerge (DocList *pLeft, DocList *pRight, DocList *pOut)
static void docListOrMerge (DocList *pLeft, DocList *pRight, DocList *pOut)
static void docListExceptMerge (DocList *pLeft, DocList *pRight, DocList *pOut)
static char * string_dup_n (const char *s, int n)
static char * string_dup (const char *s)
static char * string_format (const char *zFormat, const char *zDb, const char *zName)
static int sql_exec (sqlite3 *db, const char *zDb, const char *zName, const char *zFormat)
static int sql_prepare (sqlite3 *db, const char *zDb, const char *zName, sqlite3_stmt **ppStmt, const char *zFormat)
static struct fulltext_vtabcursor_vtab (fulltext_cursor *c)
static void appendList (StringBuffer *sb, int nString, char **azString)
static const char * contentInsertStatement (fulltext_vtab *v)
static const char * contentUpdateStatement (fulltext_vtab *v)
static int sql_get_statement (fulltext_vtab *v, fulltext_statement iStmt, sqlite3_stmt **ppStmt)
static int sql_step_statement (fulltext_vtab *v, fulltext_statement iStmt, sqlite3_stmt **ppStmt)
static int sql_single_step_statement (fulltext_vtab *v, fulltext_statement iStmt, sqlite3_stmt **ppStmt)
static int content_insert (fulltext_vtab *v, sqlite3_value *rowid, sqlite3_value **pValues)
static int content_update (fulltext_vtab *v, sqlite3_value **pValues, sqlite_int64 iRowid)
static void freeStringArray (int nString, const char **pString)
static int content_select (fulltext_vtab *v, sqlite_int64 iRow, const char ***pValues)
static int content_delete (fulltext_vtab *v, sqlite_int64 iRow)
static int term_select (fulltext_vtab *v, const char *pTerm, int nTerm, int iSegment, sqlite_int64 *rowid, DocList *out)
static int term_select_all (fulltext_vtab *v, int iColumn, const char *pTerm, int nTerm, DocList *out)
static int term_insert (fulltext_vtab *v, sqlite_int64 *piRowid, const char *pTerm, int nTerm, int iSegment, DocList *doclist)
static int term_update (fulltext_vtab *v, sqlite_int64 rowid, DocList *doclist)
static int term_delete (fulltext_vtab *v, sqlite_int64 rowid)
static void fulltext_vtab_destroy (fulltext_vtab *v)
static int getToken (const char *z, int *tokenType)
static char ** tokenizeString (const char *z, int *pnToken)
static void dequoteString (char *z)
static void tokenListToIdList (char **azIn)
static char * firstToken (char *zIn, char **pzTail)
static int startsWith (const char *s, const char *t)
static void clearTableSpec (TableSpec *p)
static int parseSpec (TableSpec *pSpec, int argc, const char *const *argv, char **pzErr)
static char * fulltextSchema (int nColumn, const char *const *azColumn, const char *zTableName)
static int constructVtab (sqlite3 *db, TableSpec *spec, sqlite3_vtab **ppVTab, char **pzErr)
static int fulltextConnect (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlite3_vtab **ppVTab, char **pzErr)
static int fulltextCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlite3_vtab **ppVTab, char **pzErr)
static int fulltextBestIndex (sqlite3_vtab *pVTab, sqlite3_index_info *pInfo)
static int fulltextDisconnect (sqlite3_vtab *pVTab)
static int fulltextDestroy (sqlite3_vtab *pVTab)
static int fulltextOpen (sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor)
static void queryClear (Query *q)
static void snippetClear (Snippet *p)
static void snippetAppendMatch (Snippet *p, int iCol, int iTerm, int iStart, int nByte)
static void snippetOffsetsOfColumn (Query *pQuery, Snippet *pSnippet, int iColumn, const char *zDoc, int nDoc)
static void snippetAllOffsets (fulltext_cursor *p)
static void snippetOffsetText (Snippet *p)
static int wordBoundary (int iBreak, const char *zDoc, int nDoc, struct snippetMatch *aMatch, int nMatch, int iCol)
static void appendWhiteSpace (StringBuffer *p)
static void trimWhiteSpace (StringBuffer *p)
static void snippetText (fulltext_cursor *pCursor, const char *zStartMark, const char *zEndMark, const char *zEllipsis)
static int fulltextClose (sqlite3_vtab_cursor *pCursor)
static int fulltextNext (sqlite3_vtab_cursor *pCursor)
static int docListOfTerm (fulltext_vtab *v, int iColumn, QueryTerm *pQTerm, DocList **ppResult)
static void queryAdd (Query *q, const char *pTerm, int nTerm)
static int checkColumnSpecifier (fulltext_vtab *pVtab, const char *zToken, int nToken)
static int tokenizeSegment (sqlite3_tokenizer *pTokenizer, const char *pSegment, int nSegment, int inPhrase, Query *pQuery)
static int parseQuery (fulltext_vtab *v, const char *zInput, int nInput, int dfltColumn, Query *pQuery)
static int fulltextQuery (fulltext_vtab *v, int iColumn, const char *zInput, int nInput, DocList **pResult, Query *pQuery)
static int fulltextFilter (sqlite3_vtab_cursor *pCursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv)
static int fulltextEof (sqlite3_vtab_cursor *pCursor)
static int fulltextColumn (sqlite3_vtab_cursor *pCursor, sqlite3_context *pContext, int idxCol)
static int fulltextRowid (sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid)
static int buildTerms (fulltext_vtab *v, fts1Hash *terms, sqlite_int64 iDocid, const char *zText, int iColumn)
static int index_insert_term (fulltext_vtab *v, const char *pTerm, int nTerm, DocList *d)
static int insertTerms (fulltext_vtab *v, fts1Hash *terms, sqlite_int64 iRowid, sqlite3_value **pValues)
static int deleteTerms (fulltext_vtab *v, fts1Hash *pTerms, sqlite_int64 iRowid)
static int index_insert (fulltext_vtab *v, sqlite3_value *pRequestRowid, sqlite3_value **pValues, sqlite_int64 *piRowid, fts1Hash *pTerms)
static int index_delete (fulltext_vtab *v, sqlite_int64 iRow, fts1Hash *pTerms)
static int index_update (fulltext_vtab *v, sqlite_int64 iRow, sqlite3_value **pValues, fts1Hash *pTerms)
static int fulltextUpdate (sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg, sqlite_int64 *pRowid)
static void snippetFunc (sqlite3_context *pContext, int argc, sqlite3_value **argv)
static void snippetOffsetsFunc (sqlite3_context *pContext, int argc, sqlite3_value **argv)
static int fulltextFindFunction (sqlite3_vtab *pVtab, int nArg, const char *zName, void(**pxFunc)(sqlite3_context *, int, sqlite3_value **), void **ppArg)
static int fulltextRename (sqlite3_vtab *pVtab, const char *zName)
int sqlite3Fts1Init (sqlite3 *db)
int sqlite3_extension_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi)

Variables

static const char *const fulltext_zStatement [MAX_STMT]
static const sqlite3_module fulltextModule
static const char isIdChar []

Define Documentation

#define CHUNK_MAX   256

Definition at line 1038 of file fts1.c.

Referenced by index_insert_term().

#define DL_DEFAULT   DL_POSITIONS
#define FTS1_ROTOR_MASK   (FTS1_ROTOR_SZ-1)

Definition at line 2205 of file fts1.c.

Referenced by snippetOffsetsOfColumn().

#define FTS1_ROTOR_SZ   (32)

Definition at line 2204 of file fts1.c.

Referenced by snippetOffsetsOfColumn().

#define IdChar (  )     (((c=C)&0x80)!=0 || (c>0x1f && isIdChar[c-0x20]))

Definition at line 1559 of file fts1.c.

Referenced by getToken(), sqlite3_complete(), and sqlite3GetToken().

#define SNIPPET_DESIRED   1

Definition at line 2404 of file fts1.c.

Referenced by snippetText().

#define SNIPPET_IGNORE   0

Definition at line 2403 of file fts1.c.

Referenced by snippetText().

#define TOKEN_EOF   0

Definition at line 1531 of file fts1.c.

Referenced by firstToken(), ftsGetToken(), and getToken().

#define TOKEN_ID   2

Definition at line 1533 of file fts1.c.

Referenced by ftsGetToken(), and getToken().

#define TOKEN_PUNCT   4

Definition at line 1535 of file fts1.c.

Referenced by ftsGetToken(), and getToken().

#define TOKEN_SPACE   1

Definition at line 1532 of file fts1.c.

Referenced by firstToken(), ftsGetToken(), getToken(), and tokenizeString().

#define TOKEN_STRING   3

Definition at line 1534 of file fts1.c.

Referenced by ftsGetToken(), and getToken().

#define TRACE (  ) 

Definition at line 60 of file fts1.c.

#define VARINT_MAX   10

Typedef Documentation

typedef struct fulltext_vtab fulltext_vtab

Definition at line 946 of file fts1.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
POS_END 
POS_COLUMN 
POS_BASE 

Definition at line 243 of file fts1.c.

Enumerator:
DL_DOCIDS 
DL_POSITIONS 
DL_POSITIONS_OFFSETS 
DL_DOCIDS 
DL_POSITIONS 
DL_POSITIONS_OFFSETS 
DL_DOCIDS 
DL_POSITIONS 
DL_POSITIONS_OFFSETS 

Definition at line 217 of file fts1.c.

Enumerator:
CONTENT_INSERT_STMT 
CONTENT_SELECT_STMT 
CONTENT_UPDATE_STMT 
CONTENT_DELETE_STMT 
TERM_SELECT_STMT 
TERM_SELECT_ALL_STMT 
TERM_INSERT_STMT 
TERM_UPDATE_STMT 
TERM_DELETE_STMT 
MAX_STMT 
CONTENT_INSERT_STMT 
CONTENT_SELECT_STMT 
CONTENT_UPDATE_STMT 
CONTENT_DELETE_STMT 
CONTENT_EXISTS_STMT 
BLOCK_INSERT_STMT 
BLOCK_SELECT_STMT 
BLOCK_DELETE_STMT 
BLOCK_DELETE_ALL_STMT 
SEGDIR_MAX_INDEX_STMT 
SEGDIR_SET_STMT 
SEGDIR_SELECT_LEVEL_STMT 
SEGDIR_SPAN_STMT 
SEGDIR_DELETE_STMT 
SEGDIR_SELECT_SEGMENT_STMT 
SEGDIR_SELECT_ALL_STMT 
SEGDIR_DELETE_ALL_STMT 
SEGDIR_COUNT_STMT 
MAX_STMT 
CONTENT_INSERT_STMT 
CONTENT_SELECT_STMT 
CONTENT_UPDATE_STMT 
CONTENT_DELETE_STMT 
CONTENT_EXISTS_STMT 
BLOCK_INSERT_STMT 
BLOCK_SELECT_STMT 
BLOCK_DELETE_STMT 
BLOCK_DELETE_ALL_STMT 
SEGDIR_MAX_INDEX_STMT 
SEGDIR_SET_STMT 
SEGDIR_SELECT_LEVEL_STMT 
SEGDIR_SPAN_STMT 
SEGDIR_DELETE_STMT 
SEGDIR_SELECT_SEGMENT_STMT 
SEGDIR_SELECT_ALL_STMT 
SEGDIR_DELETE_ALL_STMT 
SEGDIR_COUNT_STMT 
MAX_STMT 

Definition at line 1040 of file fts1.c.

enum QueryType
Enumerator:
QUERY_GENERIC 
QUERY_ROWID 
QUERY_FULLTEXT 
QUERY_GENERIC 
QUERY_ROWID 
QUERY_FULLTEXT 
QUERY_GENERIC 
QUERY_DOCID 
QUERY_FULLTEXT 

Definition at line 1021 of file fts1.c.


Function Documentation

static void addPos ( DocList d,
int  iColumn,
int  iPos 
) [static]
static void append ( StringBuffer sb,
const char *  zFrom 
) [static]
static void appendList ( StringBuffer sb,
int  nString,
char **  azString 
) [static]

Definition at line 1123 of file fts1.c.

References append().

Referenced by contentInsertStatement(), and fulltextCreate().

static void appendVarint ( DocList d,
sqlite_int64  i 
) [static]

Definition at line 288 of file fts1.c.

References DocList::nData, DocList::pData, putVarint, and VARINT_MAX.

Referenced by addPos(), docListAddDocid(), docListAddPos(), and docListAddPosOffset().

static void appendWhiteSpace ( StringBuffer p  )  [static]

Definition at line 2383 of file fts1.c.

References append(), StringBuffer::len, StringBuffer::s, and safe_isspace().

Referenced by snippetText().

static int atEnd ( DocListReader pReader  )  [static]
static int buildTerms ( fulltext_vtab v,
fts1Hash terms,
sqlite_int64  iDocid,
const char *  zText,
int  iColumn 
) [static]
static int checkColumnSpecifier ( fulltext_vtab pVtab,
const char *  zToken,
int  nToken 
) [static]

Definition at line 2646 of file fts1.c.

References fulltext_vtab::azColumn, and fulltext_vtab::nColumn.

Referenced by tokenizeSegment().

static void clearTableSpec ( TableSpec p  )  [static]
static int constructVtab ( sqlite3 db,
TableSpec spec,
sqlite3_vtab **  ppVTab,
char **  pzErr 
) [static]
static int content_delete ( fulltext_vtab v,
sqlite_int64  iRow 
) [static]
static int content_insert ( fulltext_vtab v,
sqlite3_value rowid,
sqlite3_value **  pValues 
) [static]
static int content_select ( fulltext_vtab v,
sqlite_int64  iRow,
const char ***  pValues 
) [static]
static int content_update ( fulltext_vtab v,
sqlite3_value **  pValues,
sqlite_int64  iRowid 
) [static]
static const char* contentInsertStatement ( fulltext_vtab v  )  [static]
static const char* contentUpdateStatement ( fulltext_vtab v  )  [static]
static struct fulltext_vtab* cursor_vtab ( fulltext_cursor c  )  [static, read]

Definition at line 1116 of file fts1.c.

References fulltext_cursor::base, and sqlite3_vtab_cursor::pVtab.

Referenced by fulltextColumn(), and fulltextFilter().

static int deleteTerms ( fulltext_vtab v,
fts1Hash pTerms,
sqlite_int64  iRowid 
) [static]

Definition at line 3096 of file fts1.c.

References buildTerms(), content_select(), freeStringArray(), fulltext_vtab::nColumn, and SQLITE_OK.

Referenced by index_delete(), and index_update().

static void dequoteString ( char *  z  )  [static]

Definition at line 1681 of file fts1.c.

Referenced by firstToken(), and tokenListToIdList().

static void docListAccumulate ( DocList pAcc,
DocList pUpdate 
) [static]
static void docListAddDocid ( DocList d,
sqlite_int64  iDocid 
) [static]
static void docListAddPos ( DocList d,
int  iColumn,
int  iPos 
) [static]
static void docListAddPosOffset ( DocList d,
int  iColumn,
int  iPos,
int  iStartOffset,
int  iEndOffset 
) [static]
static void docListAndMerge ( DocList pLeft,
DocList pRight,
DocList pOut 
) [static]

Definition at line 762 of file fts1.c.

References DL_POSITIONS, docListAddDocid(), DocList::iType, left, nextDocid(), readerInit(), and right.

Referenced by fulltextQuery().

static void docListDelete ( DocList d  )  [static]

Definition at line 278 of file fts1.c.

References docListDestroy().

Referenced by docListOfTerm(), fulltextClose(), fulltextFilter(), fulltextQuery(), and fulltextUpdate().

static void docListDestroy ( DocList d  )  [static]
static void docListDiscardEmpty ( DocList in  )  [static]
static char* docListEnd ( DocList d  )  [static]

Definition at line 283 of file fts1.c.

References DocList::nData, and DocList::pData.

Referenced by atEnd(), and docListSpliceElement().

static void docListExceptMerge ( DocList pLeft,
DocList pRight,
DocList pOut 
) [static]

Definition at line 841 of file fts1.c.

References docListAddDocid(), left, nextDocid(), readerInit(), and right.

Referenced by fulltextQuery().

static void docListInit ( DocList d,
DocListType  iType,
const char *  pData,
int  nData 
) [static]
static DocList* docListNew ( DocListType  iType  )  [static]

Definition at line 265 of file fts1.c.

References d(), and docListInit().

Referenced by buildTerms(), docListOfTerm(), and fulltextQuery().

static int docListOfTerm ( fulltext_vtab v,
int  iColumn,
QueryTerm pQTerm,
DocList **  ppResult 
) [static]
static void docListOrMerge ( DocList pLeft,
DocList pRight,
DocList pOut 
) [static]

Definition at line 796 of file fts1.c.

References docListAddDocid(), left, nextDocid(), readerInit(), and right.

Referenced by fulltextQuery().

static void docListPhraseMerge ( DocList pLeft,
DocList pRight,
DocList pOut 
) [static]

Definition at line 730 of file fts1.c.

References left, mergePosList(), nextDocid(), readerInit(), and right.

Referenced by docListOfTerm().

static void docListRestrictColumn ( DocList in,
int  iRestrictColumn 
) [static]
static void docListSpliceElement ( DocListReader r,
sqlite_int64  iDocid,
const char *  pSource,
int  nSource 
) [static]
static void docListUpdate ( DocList d,
DocList pUpdate 
) [static]
static sqlite_int64 firstDocid ( DocList d  )  [static]

Definition at line 483 of file fts1.c.

References readDocid(), and readerInit().

Referenced by docListUpdate().

static char* firstToken ( char *  zIn,
char **  pzTail 
) [static]

Definition at line 1745 of file fts1.c.

References dequoteString(), getToken(), TOKEN_EOF, TOKEN_SPACE, and ttype.

Referenced by parseSpec().

static void freeStringArray ( int  nString,
const char **  pString 
) [static]

Definition at line 1283 of file fts1.c.

Referenced by content_select(), and deleteTerms().

static void fulltext_vtab_destroy ( fulltext_vtab v  )  [static]
static int fulltextBestIndex ( sqlite3_vtab pVTab,
sqlite3_index_info pInfo 
) [static]
static int fulltextClose ( sqlite3_vtab_cursor pCursor  )  [static]
static int fulltextColumn ( sqlite3_vtab_cursor pCursor,
sqlite3_context pContext,
int  idxCol 
) [static]
static int fulltextConnect ( sqlite3 db,
void *  pAux,
int  argc,
const char *const *  argv,
sqlite3_vtab **  ppVTab,
char **  pzErr 
) [static]

Definition at line 2004 of file fts1.c.

References clearTableSpec(), constructVtab(), parseSpec(), and SQLITE_OK.

static int fulltextCreate ( sqlite3 db,
void *  pAux,
int  argc,
const char *const *  argv,
sqlite3_vtab **  ppVTab,
char **  pzErr 
) [static]
static int fulltextDestroy ( sqlite3_vtab pVTab  )  [static]
static int fulltextDisconnect ( sqlite3_vtab pVTab  )  [static]

Definition at line 2121 of file fts1.c.

References fulltext_vtab_destroy(), SQLITE_OK, and TRACE.

static int fulltextEof ( sqlite3_vtab_cursor pCursor  )  [static]

Definition at line 2928 of file fts1.c.

References fulltext_cursor::eof.

static int fulltextFilter ( sqlite3_vtab_cursor pCursor,
int  idxNum,
const char *  idxStr,
int  argc,
sqlite3_value **  argv 
) [static]
static int fulltextFindFunction ( sqlite3_vtab pVtab,
int  nArg,
const char *  zName,
void(**)(sqlite3_context *, int, sqlite3_value **)  pxFunc,
void **  ppArg 
) [static]

Definition at line 3269 of file fts1.c.

References snippetFunc(), and snippetOffsetsFunc().

static int fulltextNext ( sqlite3_vtab_cursor pCursor  )  [static]
static int fulltextOpen ( sqlite3_vtab pVTab,
sqlite3_vtab_cursor **  ppCursor 
) [static]

Definition at line 2142 of file fts1.c.

References fulltext_cursor::base, SQLITE_OK, and TRACE.

static int fulltextQuery ( fulltext_vtab v,
int  iColumn,
const char *  zInput,
int  nInput,
DocList **  pResult,
Query pQuery 
) [static]
static int fulltextRename ( sqlite3_vtab pVtab,
const char *  zName 
) [static]
static int fulltextRowid ( sqlite3_vtab_cursor pCursor,
sqlite_int64 pRowid 
) [static]

Definition at line 2960 of file fts1.c.

References fulltext_cursor::pStmt, sqlite3_column_int64(), and SQLITE_OK.

static char* fulltextSchema ( int  nColumn,
const char *const *  azColumn,
const char *  zTableName 
) [static]

Definition at line 1912 of file fts1.c.

References sqlite3_free(), and sqlite3_mprintf().

Referenced by constructVtab().

static int fulltextUpdate ( sqlite3_vtab pVtab,
int  nArg,
sqlite3_value **  ppArg,
sqlite_int64 pRowid 
) [static]
static int getToken ( const char *  z,
int *  tokenType 
) [static]

Definition at line 1566 of file fts1.c.

References IdChar, safe_isspace(), TOKEN_EOF, TOKEN_ID, TOKEN_PUNCT, TOKEN_SPACE, and TOKEN_STRING.

Referenced by firstToken(), and tokenizeString().

static int getVarint ( const char *  p,
sqlite_int64 v 
) [static]

Definition at line 129 of file fts1.c.

References VARINT_MAX.

static int getVarint32 ( const char *  p,
int *  pi 
) [static]

Definition at line 145 of file fts1.c.

References getVarint.

static int index_delete ( fulltext_vtab v,
sqlite_int64  iRow,
fts1Hash pTerms 
) [static]

Definition at line 3127 of file fts1.c.

References content_delete(), deleteTerms(), and SQLITE_OK.

Referenced by fulltextUpdate().

static int index_insert ( fulltext_vtab v,
sqlite3_value pRequestRowid,
sqlite3_value **  pValues,
sqlite_int64 piRowid,
fts1Hash pTerms 
) [static]

Definition at line 3114 of file fts1.c.

References content_insert(), fulltext_vtab::db, insertTerms(), sqlite3_last_insert_rowid(), and SQLITE_OK.

Referenced by fulltextUpdate().

static int index_insert_term ( fulltext_vtab v,
const char *  pTerm,
int  nTerm,
DocList d 
) [static]
static int index_update ( fulltext_vtab v,
sqlite_int64  iRow,
sqlite3_value **  pValues,
fts1Hash pTerms 
) [static]

Definition at line 3135 of file fts1.c.

References content_update(), deleteTerms(), insertTerms(), and SQLITE_OK.

Referenced by fulltextUpdate().

static void initStringBuffer ( StringBuffer sb  )  [static]
static int insertTerms ( fulltext_vtab v,
fts1Hash terms,
sqlite_int64  iRowid,
sqlite3_value **  pValues 
) [static]

Definition at line 3083 of file fts1.c.

References buildTerms(), fulltext_vtab::nColumn, sqlite3_value_text(), and SQLITE_OK.

Referenced by index_insert(), and index_update().

static void mergePosList ( DocListReader pLeft,
DocListReader pRight,
sqlite_int64  iDocid,
DocList pOut 
) [static]
static void nappend ( StringBuffer sb,
const char *  zFrom,
int  nFrom 
) [static]

Definition at line 78 of file fts1.c.

References StringBuffer::alloced, initStringBuffer(), StringBuffer::len, and StringBuffer::s.

Referenced by append(), and snippetText().

static sqlite_int64 nextDocid ( DocListReader pIn  )  [static]
static int parseQuery ( fulltext_vtab v,
const char *  zInput,
int  nInput,
int  dfltColumn,
Query pQuery 
) [static]
static int parseSpec ( TableSpec pSpec,
int  argc,
const char *const *  argv,
char **  pzErr 
) [static]
static sqlite_int64 peekDocid ( DocListReader pReader  )  [static]

Definition at line 396 of file fts1.c.

References atEnd(), getVarint, DocListReader::iLastPos, and DocListReader::p.

Referenced by skipToDocid().

static int putVarint ( char *  p,
sqlite_int64  v 
) [static]

Definition at line 114 of file fts1.c.

References VARINT_MAX.

static void queryAdd ( Query q,
const char *  pTerm,
int  nTerm 
) [static]
static void queryClear ( Query q  )  [static]

Definition at line 2156 of file fts1.c.

References Query::nTerms, QueryTerm::pTerm, and Query::pTerms.

Referenced by fulltextClose(), fulltextFilter(), fulltextQuery(), and parseQuery().

static sqlite_int64 readDocid ( DocListReader pReader  )  [static]
static void readerInit ( DocListReader r,
DocList pDoclist 
) [static]
static int readPosition ( DocListReader pReader,
int *  iColumn 
) [static]
static int safe_isalnum ( char  c  )  [static]

Definition at line 213 of file fts1.c.

Referenced by parseSpec(), startsWith(), and tokenListToIdList().

static int safe_isspace ( char  c  )  [static]

Definition at line 207 of file fts1.c.

Referenced by appendWhiteSpace(), getToken(), startsWith(), trimWhiteSpace(), and wordBoundary().

static int safe_tolower ( char  c  )  [static]

Definition at line 210 of file fts1.c.

Referenced by startsWith().

static void skipDocument ( DocListReader pReader  )  [static]

Definition at line 466 of file fts1.c.

References readDocid(), and skipPositionList().

Referenced by docListSpliceElement(), and skipToDocid().

static void skipPositionList ( DocListReader pReader  )  [static]
static int skipToDocid ( DocListReader pReader,
sqlite_int64  iDocid 
) [static]

Definition at line 473 of file fts1.c.

References atEnd(), d(), peekDocid(), and skipDocument().

Referenced by docListSpliceElement().

static void snippetAllOffsets ( fulltext_cursor p  )  [static]
static void snippetAppendMatch ( Snippet p,
int  iCol,
int  iTerm,
int  iStart,
int  nByte 
) [static]
static void snippetClear ( Snippet p  )  [static]

Definition at line 2168 of file fts1.c.

References Snippet::aMatch, Snippet::zOffset, and Snippet::zSnippet.

Referenced by fulltextClose(), and fulltextNext().

static void snippetFunc ( sqlite3_context pContext,
int  argc,
sqlite3_value **  argv 
) [static]
static void snippetOffsetsFunc ( sqlite3_context pContext,
int  argc,
sqlite3_value **  argv 
) [static]
static void snippetOffsetsOfColumn ( Query pQuery,
Snippet pSnippet,
int  iColumn,
const char *  zDoc,
int  nDoc 
) [static]
static void snippetOffsetText ( Snippet p  )  [static]
static void snippetText ( fulltext_cursor pCursor,
const char *  zStartMark,
const char *  zEndMark,
const char *  zEllipsis 
) [static]
static int sql_exec ( sqlite3 db,
const char *  zDb,
const char *  zName,
const char *  zFormat 
) [static]

Definition at line 923 of file fts1.c.

References sqlite3_exec(), string_format(), and TRACE.

Referenced by fulltextCreate(), and fulltextDestroy().

static int sql_get_statement ( fulltext_vtab v,
fulltext_statement  iStmt,
sqlite3_stmt **  ppStmt 
) [static]
static int sql_prepare ( sqlite3 db,
const char *  zDb,
const char *  zName,
sqlite3_stmt **  ppStmt,
const char *  zFormat 
) [static]

Definition at line 933 of file fts1.c.

References sqlite3_prepare(), string_format(), and TRACE.

Referenced by fulltextFilter(), and sql_get_statement().

static int sql_single_step_statement ( fulltext_vtab v,
fulltext_statement  iStmt,
sqlite3_stmt **  ppStmt 
) [static]
static int sql_step_statement ( fulltext_vtab v,
fulltext_statement  iStmt,
sqlite3_stmt **  ppStmt 
) [static]
int sqlite3_extension_init ( sqlite3 db,
char **  pzErrMsg,
const sqlite3_api_routines pApi 
)

Definition at line 3338 of file fts1.c.

References sqlite3Fts1Init(), and SQLITE_EXTENSION_INIT2.

int sqlite3Fts1Init ( sqlite3 db  ) 

Definition at line 3331 of file fts1.c.

References sqlite3_create_module(), and sqlite3_overload_function().

Referenced by openDatabase(), and sqlite3_extension_init().

static int startsWith ( const char *  s,
const char *  t 
) [static]

Definition at line 1775 of file fts1.c.

References safe_isalnum(), safe_isspace(), and safe_tolower().

Referenced by constructVtab(), and parseSpec().

static char* string_dup ( const char *  s  )  [static]

Definition at line 882 of file fts1.c.

References string_dup_n().

Referenced by content_select().

static char* string_dup_n ( const char *  s,
int  n 
) [static]

Definition at line 872 of file fts1.c.

Referenced by string_dup().

static char* string_format ( const char *  zFormat,
const char *  zDb,
const char *  zName 
) [static]

Definition at line 890 of file fts1.c.

Referenced by sql_exec(), and sql_prepare().

static int term_delete ( fulltext_vtab v,
sqlite_int64  rowid 
) [static]
static int term_insert ( fulltext_vtab v,
sqlite_int64 piRowid,
const char *  pTerm,
int  nTerm,
int  iSegment,
DocList doclist 
) [static]
static int term_select ( fulltext_vtab v,
const char *  pTerm,
int  nTerm,
int  iSegment,
sqlite_int64 rowid,
DocList out 
) [static]
static int term_select_all ( fulltext_vtab v,
int  iColumn,
const char *  pTerm,
int  nTerm,
DocList out 
) [static]
static int term_update ( fulltext_vtab v,
sqlite_int64  rowid,
DocList doclist 
) [static]
static int tokenizeSegment ( sqlite3_tokenizer pTokenizer,
const char *  pSegment,
int  nSegment,
int  inPhrase,
Query pQuery 
) [static]
static char** tokenizeString ( const char *  z,
int *  pnToken 
) [static]

Definition at line 1634 of file fts1.c.

References getToken(), Token::n, TOKEN_SPACE, and Token::z.

Referenced by parseSpec().

static void tokenListToIdList ( char **  azIn  )  [static]

Definition at line 1723 of file fts1.c.

References dequoteString(), and safe_isalnum().

Referenced by parseSpec().

static void trimWhiteSpace ( StringBuffer p  )  [static]

Definition at line 2392 of file fts1.c.

References StringBuffer::len, StringBuffer::s, and safe_isspace().

Referenced by snippetText().

static int wordBoundary ( int  iBreak,
const char *  zDoc,
int  nDoc,
struct snippetMatch *  aMatch,
int  nMatch,
int  iCol 
) [static]

Definition at line 2343 of file fts1.c.

References safe_isspace().

Referenced by snippetText().


Variable Documentation

const char* const fulltext_zStatement[MAX_STMT] [static]
Initial value:
 {
   NULL,  
   "select * from %_content where rowid = ?",
   NULL,  
   "delete from %_content where rowid = ?",

  
  "select rowid, doclist from %_term where term = ? and segment = ?",
  
  "select doclist from %_term where term = ? order by segment",
  
  "insert into %_term (rowid, term, segment, doclist) values (?, ?, ?, ?)",
   "update %_term set doclist = ? where rowid = ?",
   "delete from %_term where rowid = ?",
}

Definition at line 1061 of file fts1.c.

static const sqlite3_module fulltextModule [static]
const char isIdChar[] [static]
Initial value:
 {

    0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  
    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  
    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  
}

Definition at line 1550 of file fts1.c.


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:58 2011 by Doxygen 1.6.1