Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: third_party/sqlite/src/ext/fts3/fts3Int.h

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/ext/fts3/fts3.c ('k') | third_party/sqlite/src/ext/fts3/fts3_aux.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2009 Nov 12 2 ** 2009 Nov 12
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ** amalgamation. 127 ** amalgamation.
128 */ 128 */
129 #ifndef SQLITE_AMALGAMATION 129 #ifndef SQLITE_AMALGAMATION
130 /* 130 /*
131 ** Macros indicating that conditional expressions are always true or 131 ** Macros indicating that conditional expressions are always true or
132 ** false. 132 ** false.
133 */ 133 */
134 #ifdef SQLITE_COVERAGE_TEST 134 #ifdef SQLITE_COVERAGE_TEST
135 # define ALWAYS(x) (1) 135 # define ALWAYS(x) (1)
136 # define NEVER(X) (0) 136 # define NEVER(X) (0)
137 #elif defined(SQLITE_DEBUG)
138 # define ALWAYS(x) sqlite3Fts3Always((x)!=0)
139 # define NEVER(x) sqlite3Fts3Never((x)!=0)
140 int sqlite3Fts3Always(int b);
141 int sqlite3Fts3Never(int b);
137 #else 142 #else
138 # define ALWAYS(x) (x) 143 # define ALWAYS(x) (x)
139 # define NEVER(x) (x) 144 # define NEVER(x) (x)
140 #endif 145 #endif
141 146
142 /* 147 /*
143 ** Internal types used by SQLite. 148 ** Internal types used by SQLite.
144 */ 149 */
145 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */ 150 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
146 typedef short int i16; /* 2-byte (or larger) signed integer */ 151 typedef short int i16; /* 2-byte (or larger) signed integer */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 typedef struct Fts3Expr Fts3Expr; 190 typedef struct Fts3Expr Fts3Expr;
186 typedef struct Fts3Phrase Fts3Phrase; 191 typedef struct Fts3Phrase Fts3Phrase;
187 typedef struct Fts3PhraseToken Fts3PhraseToken; 192 typedef struct Fts3PhraseToken Fts3PhraseToken;
188 193
189 typedef struct Fts3Doclist Fts3Doclist; 194 typedef struct Fts3Doclist Fts3Doclist;
190 typedef struct Fts3SegFilter Fts3SegFilter; 195 typedef struct Fts3SegFilter Fts3SegFilter;
191 typedef struct Fts3DeferredToken Fts3DeferredToken; 196 typedef struct Fts3DeferredToken Fts3DeferredToken;
192 typedef struct Fts3SegReader Fts3SegReader; 197 typedef struct Fts3SegReader Fts3SegReader;
193 typedef struct Fts3MultiSegReader Fts3MultiSegReader; 198 typedef struct Fts3MultiSegReader Fts3MultiSegReader;
194 199
200 typedef struct MatchinfoBuffer MatchinfoBuffer;
201
195 /* 202 /*
196 ** A connection to a fulltext index is an instance of the following 203 ** A connection to a fulltext index is an instance of the following
197 ** structure. The xCreate and xConnect methods create an instance 204 ** structure. The xCreate and xConnect methods create an instance
198 ** of this structure and xDestroy and xDisconnect free that instance. 205 ** of this structure and xDestroy and xDisconnect free that instance.
199 ** All other methods receive a pointer to the structure as one of their 206 ** All other methods receive a pointer to the structure as one of their
200 ** arguments. 207 ** arguments.
201 */ 208 */
202 struct Fts3Table { 209 struct Fts3Table {
203 sqlite3_vtab base; /* Base class used by SQLite core */ 210 sqlite3_vtab base; /* Base class used by SQLite core */
204 sqlite3 *db; /* The database connection */ 211 sqlite3 *db; /* The database connection */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 */ 257 */
251 int nIndex; /* Size of aIndex[] */ 258 int nIndex; /* Size of aIndex[] */
252 struct Fts3Index { 259 struct Fts3Index {
253 int nPrefix; /* Prefix length (0 for main terms index) */ 260 int nPrefix; /* Prefix length (0 for main terms index) */
254 Fts3Hash hPending; /* Pending terms table for this index */ 261 Fts3Hash hPending; /* Pending terms table for this index */
255 } *aIndex; 262 } *aIndex;
256 int nMaxPendingData; /* Max pending data before flush to disk */ 263 int nMaxPendingData; /* Max pending data before flush to disk */
257 int nPendingData; /* Current bytes of pending data */ 264 int nPendingData; /* Current bytes of pending data */
258 sqlite_int64 iPrevDocid; /* Docid of most recently inserted document */ 265 sqlite_int64 iPrevDocid; /* Docid of most recently inserted document */
259 int iPrevLangid; /* Langid of recently inserted document */ 266 int iPrevLangid; /* Langid of recently inserted document */
267 int bPrevDelete; /* True if last operation was a delete */
260 268
261 #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) 269 #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
262 /* State variables used for validating that the transaction control 270 /* State variables used for validating that the transaction control
263 ** methods of the virtual table are called at appropriate times. These 271 ** methods of the virtual table are called at appropriate times. These
264 ** values do not contribute to FTS functionality; they are used for 272 ** values do not contribute to FTS functionality; they are used for
265 ** verifying the operation of the SQLite core. 273 ** verifying the operation of the SQLite core.
266 */ 274 */
267 int inTransaction; /* True after xBegin but before xCommit/xRollback */ 275 int inTransaction; /* True after xBegin but before xCommit/xRollback */
268 int mxSavepoint; /* Largest valid xSavepoint integer */ 276 int mxSavepoint; /* Largest valid xSavepoint integer */
269 #endif 277 #endif
(...skipping 24 matching lines...) Expand all
294 char *pNextId; /* Pointer into the body of aDoclist */ 302 char *pNextId; /* Pointer into the body of aDoclist */
295 char *aDoclist; /* List of docids for full-text queries */ 303 char *aDoclist; /* List of docids for full-text queries */
296 int nDoclist; /* Size of buffer at aDoclist */ 304 int nDoclist; /* Size of buffer at aDoclist */
297 u8 bDesc; /* True to sort in descending order */ 305 u8 bDesc; /* True to sort in descending order */
298 int eEvalmode; /* An FTS3_EVAL_XX constant */ 306 int eEvalmode; /* An FTS3_EVAL_XX constant */
299 int nRowAvg; /* Average size of database rows, in pages */ 307 int nRowAvg; /* Average size of database rows, in pages */
300 sqlite3_int64 nDoc; /* Documents in table */ 308 sqlite3_int64 nDoc; /* Documents in table */
301 i64 iMinDocid; /* Minimum docid to return */ 309 i64 iMinDocid; /* Minimum docid to return */
302 i64 iMaxDocid; /* Maximum docid to return */ 310 i64 iMaxDocid; /* Maximum docid to return */
303 int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */ 311 int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */
304 u32 *aMatchinfo; /* Information about most recent match */ 312 MatchinfoBuffer *pMIBuffer; /* Buffer for matchinfo data */
305 int nMatchinfo; /* Number of elements in aMatchinfo[] */
306 char *zMatchinfo; /* Matchinfo specification */
307 }; 313 };
308 314
309 #define FTS3_EVAL_FILTER 0 315 #define FTS3_EVAL_FILTER 0
310 #define FTS3_EVAL_NEXT 1 316 #define FTS3_EVAL_NEXT 1
311 #define FTS3_EVAL_MATCHINFO 2 317 #define FTS3_EVAL_MATCHINFO 2
312 318
313 /* 319 /*
314 ** The Fts3Cursor.eSearch member is always set to one of the following. 320 ** The Fts3Cursor.eSearch member is always set to one of the following.
315 ** Actualy, Fts3Cursor.eSearch can be greater than or equal to 321 ** Actualy, Fts3Cursor.eSearch can be greater than or equal to
316 ** FTS3_FULLTEXT_SEARCH. If so, then Fts3Cursor.eSearch - 2 is the index 322 ** FTS3_FULLTEXT_SEARCH. If so, then Fts3Cursor.eSearch - 2 is the index
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 Fts3DeferredToken *pDeferred; /* Deferred token object for this token */ 374 Fts3DeferredToken *pDeferred; /* Deferred token object for this token */
369 Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */ 375 Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */
370 }; 376 };
371 377
372 struct Fts3Phrase { 378 struct Fts3Phrase {
373 /* Cache of doclist for this phrase. */ 379 /* Cache of doclist for this phrase. */
374 Fts3Doclist doclist; 380 Fts3Doclist doclist;
375 int bIncr; /* True if doclist is loaded incrementally */ 381 int bIncr; /* True if doclist is loaded incrementally */
376 int iDoclistToken; 382 int iDoclistToken;
377 383
384 /* Used by sqlite3Fts3EvalPhrasePoslist() if this is a descendent of an
385 ** OR condition. */
386 char *pOrPoslist;
387 i64 iOrDocid;
388
378 /* Variables below this point are populated by fts3_expr.c when parsing 389 /* Variables below this point are populated by fts3_expr.c when parsing
379 ** a MATCH expression. Everything above is part of the evaluation phase. 390 ** a MATCH expression. Everything above is part of the evaluation phase.
380 */ 391 */
381 int nToken; /* Number of tokens in the phrase */ 392 int nToken; /* Number of tokens in the phrase */
382 int iColumn; /* Index of column this phrase must match */ 393 int iColumn; /* Index of column this phrase must match */
383 Fts3PhraseToken aToken[1]; /* One entry for each token in the phrase */ 394 Fts3PhraseToken aToken[1]; /* One entry for each token in the phrase */
384 }; 395 };
385 396
386 /* 397 /*
387 ** A tree of these objects forms the RHS of a MATCH operator. 398 ** A tree of these objects forms the RHS of a MATCH operator.
(...skipping 23 matching lines...) Expand all
411 Fts3Expr *pLeft; /* Left operand */ 422 Fts3Expr *pLeft; /* Left operand */
412 Fts3Expr *pRight; /* Right operand */ 423 Fts3Expr *pRight; /* Right operand */
413 Fts3Phrase *pPhrase; /* Valid if eType==FTSQUERY_PHRASE */ 424 Fts3Phrase *pPhrase; /* Valid if eType==FTSQUERY_PHRASE */
414 425
415 /* The following are used by the fts3_eval.c module. */ 426 /* The following are used by the fts3_eval.c module. */
416 sqlite3_int64 iDocid; /* Current docid */ 427 sqlite3_int64 iDocid; /* Current docid */
417 u8 bEof; /* True this expression is at EOF already */ 428 u8 bEof; /* True this expression is at EOF already */
418 u8 bStart; /* True if iDocid is valid */ 429 u8 bStart; /* True if iDocid is valid */
419 u8 bDeferred; /* True if this expression is entirely deferred */ 430 u8 bDeferred; /* True if this expression is entirely deferred */
420 431
421 u32 *aMI; 432 /* The following are used by the fts3_snippet.c module. */
433 int iPhrase; /* Index of this phrase in matchinfo() results */
434 u32 *aMI; /* See above */
422 }; 435 };
423 436
424 /* 437 /*
425 ** Candidate values for Fts3Query.eType. Note that the order of the first 438 ** Candidate values for Fts3Query.eType. Note that the order of the first
426 ** four values is in order of precedence when parsing expressions. For 439 ** four values is in order of precedence when parsing expressions. For
427 ** example, the following: 440 ** example, the following:
428 ** 441 **
429 ** "a OR b AND c NOT d NEAR e" 442 ** "a OR b AND c NOT d NEAR e"
430 ** 443 **
431 ** is equivalent to: 444 ** is equivalent to:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 int nDoclist; /* Size of aDoclist[] in bytes */ 535 int nDoclist; /* Size of aDoclist[] in bytes */
523 }; 536 };
524 537
525 int sqlite3Fts3Incrmerge(Fts3Table*,int,int); 538 int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
526 539
527 #define fts3GetVarint32(p, piVal) ( \ 540 #define fts3GetVarint32(p, piVal) ( \
528 (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \ 541 (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \
529 ) 542 )
530 543
531 /* fts3.c */ 544 /* fts3.c */
545 void sqlite3Fts3ErrMsg(char**,const char*,...);
532 int sqlite3Fts3PutVarint(char *, sqlite3_int64); 546 int sqlite3Fts3PutVarint(char *, sqlite3_int64);
533 int sqlite3Fts3GetVarint(const char *, sqlite_int64 *); 547 int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
534 int sqlite3Fts3GetVarint32(const char *, int *); 548 int sqlite3Fts3GetVarint32(const char *, int *);
535 int sqlite3Fts3VarintLen(sqlite3_uint64); 549 int sqlite3Fts3VarintLen(sqlite3_uint64);
536 void sqlite3Fts3Dequote(char *); 550 void sqlite3Fts3Dequote(char *);
537 void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*); 551 void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
538 int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *); 552 int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
539 int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *); 553 int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
540 void sqlite3Fts3CreateStatTable(int*, Fts3Table*); 554 void sqlite3Fts3CreateStatTable(int*, Fts3Table*);
555 int sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc);
541 556
542 /* fts3_tokenizer.c */ 557 /* fts3_tokenizer.c */
543 const char *sqlite3Fts3NextToken(const char *, int *); 558 const char *sqlite3Fts3NextToken(const char *, int *);
544 int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *); 559 int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
545 int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *, 560 int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
546 sqlite3_tokenizer **, char ** 561 sqlite3_tokenizer **, char **
547 ); 562 );
548 int sqlite3Fts3IsIdChar(char); 563 int sqlite3Fts3IsIdChar(char);
549 564
550 /* fts3_snippet.c */ 565 /* fts3_snippet.c */
551 void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*); 566 void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);
552 void sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *, 567 void sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *,
553 const char *, const char *, int, int 568 const char *, const char *, int, int
554 ); 569 );
555 void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *); 570 void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *);
571 void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p);
556 572
557 /* fts3_expr.c */ 573 /* fts3_expr.c */
558 int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int, 574 int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,
559 char **, int, int, int, const char *, int, Fts3Expr **, char ** 575 char **, int, int, int, const char *, int, Fts3Expr **, char **
560 ); 576 );
561 void sqlite3Fts3ExprFree(Fts3Expr *); 577 void sqlite3Fts3ExprFree(Fts3Expr *);
562 #ifdef SQLITE_TEST 578 #ifdef SQLITE_TEST
563 int sqlite3Fts3ExprInitTestInterface(sqlite3 *db); 579 int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
564 int sqlite3Fts3InitTerm(sqlite3 *db); 580 int sqlite3Fts3InitTerm(sqlite3 *db);
565 #endif 581 #endif
(...skipping 20 matching lines...) Expand all
586 602
587 /* fts3_unicode2.c (functions generated by parsing unicode text files) */ 603 /* fts3_unicode2.c (functions generated by parsing unicode text files) */
588 #ifndef SQLITE_DISABLE_FTS3_UNICODE 604 #ifndef SQLITE_DISABLE_FTS3_UNICODE
589 int sqlite3FtsUnicodeFold(int, int); 605 int sqlite3FtsUnicodeFold(int, int);
590 int sqlite3FtsUnicodeIsalnum(int); 606 int sqlite3FtsUnicodeIsalnum(int);
591 int sqlite3FtsUnicodeIsdiacritic(int); 607 int sqlite3FtsUnicodeIsdiacritic(int);
592 #endif 608 #endif
593 609
594 #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ 610 #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */
595 #endif /* _FTSINT_H */ 611 #endif /* _FTSINT_H */
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts3/fts3.c ('k') | third_party/sqlite/src/ext/fts3/fts3_aux.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698