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

Side by Side Diff: third_party/sqlite/sqlite-src-3170000/ext/fts5/fts5Int.h

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
(Empty)
1 /*
2 ** 2014 May 31
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
10 **
11 ******************************************************************************
12 **
13 */
14 #ifndef _FTS5INT_H
15 #define _FTS5INT_H
16
17 #include "fts5.h"
18 #include "sqlite3ext.h"
19 SQLITE_EXTENSION_INIT1
20
21 #include <string.h>
22 #include <assert.h>
23
24 #ifndef SQLITE_AMALGAMATION
25
26 typedef unsigned char u8;
27 typedef unsigned int u32;
28 typedef unsigned short u16;
29 typedef short i16;
30 typedef sqlite3_int64 i64;
31 typedef sqlite3_uint64 u64;
32
33 #define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
34
35 #define testcase(x)
36 #define ALWAYS(x) 1
37 #define NEVER(x) 0
38
39 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
40 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
41
42 /*
43 ** Constants for the largest and smallest possible 64-bit signed integers.
44 */
45 # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
46 # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
47
48 #endif
49
50 /* Truncate very long tokens to this many bytes. Hard limit is
51 ** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset
52 ** field that occurs at the start of each leaf page (see fts5_index.c). */
53 #define FTS5_MAX_TOKEN_SIZE 32768
54
55 /*
56 ** Maximum number of prefix indexes on single FTS5 table. This must be
57 ** less than 32. If it is set to anything large than that, an #error
58 ** directive in fts5_index.c will cause the build to fail.
59 */
60 #define FTS5_MAX_PREFIX_INDEXES 31
61
62 #define FTS5_DEFAULT_NEARDIST 10
63 #define FTS5_DEFAULT_RANK "bm25"
64
65 /* Name of rank and rowid columns */
66 #define FTS5_RANK_NAME "rank"
67 #define FTS5_ROWID_NAME "rowid"
68
69 #ifdef SQLITE_DEBUG
70 # define FTS5_CORRUPT sqlite3Fts5Corrupt()
71 int sqlite3Fts5Corrupt(void);
72 #else
73 # define FTS5_CORRUPT SQLITE_CORRUPT_VTAB
74 #endif
75
76 /*
77 ** The assert_nc() macro is similar to the assert() macro, except that it
78 ** is used for assert() conditions that are true only if it can be
79 ** guranteed that the database is not corrupt.
80 */
81 #ifdef SQLITE_DEBUG
82 extern int sqlite3_fts5_may_be_corrupt;
83 # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))
84 #else
85 # define assert_nc(x) assert(x)
86 #endif
87
88 /* Mark a function parameter as unused, to suppress nuisance compiler
89 ** warnings. */
90 #ifndef UNUSED_PARAM
91 # define UNUSED_PARAM(X) (void)(X)
92 #endif
93
94 #ifndef UNUSED_PARAM2
95 # define UNUSED_PARAM2(X, Y) (void)(X), (void)(Y)
96 #endif
97
98 typedef struct Fts5Global Fts5Global;
99 typedef struct Fts5Colset Fts5Colset;
100
101 /* If a NEAR() clump or phrase may only match a specific set of columns,
102 ** then an object of the following type is used to record the set of columns.
103 ** Each entry in the aiCol[] array is a column that may be matched.
104 **
105 ** This object is used by fts5_expr.c and fts5_index.c.
106 */
107 struct Fts5Colset {
108 int nCol;
109 int aiCol[1];
110 };
111
112
113
114 /**************************************************************************
115 ** Interface to code in fts5_config.c. fts5_config.c contains contains code
116 ** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.
117 */
118
119 typedef struct Fts5Config Fts5Config;
120
121 /*
122 ** An instance of the following structure encodes all information that can
123 ** be gleaned from the CREATE VIRTUAL TABLE statement.
124 **
125 ** And all information loaded from the %_config table.
126 **
127 ** nAutomerge:
128 ** The minimum number of segments that an auto-merge operation should
129 ** attempt to merge together. A value of 1 sets the object to use the
130 ** compile time default. Zero disables auto-merge altogether.
131 **
132 ** zContent:
133 **
134 ** zContentRowid:
135 ** The value of the content_rowid= option, if one was specified. Or
136 ** the string "rowid" otherwise. This text is not quoted - if it is
137 ** used as part of an SQL statement it needs to be quoted appropriately.
138 **
139 ** zContentExprlist:
140 **
141 ** pzErrmsg:
142 ** This exists in order to allow the fts5_index.c module to return a
143 ** decent error message if it encounters a file-format version it does
144 ** not understand.
145 **
146 ** bColumnsize:
147 ** True if the %_docsize table is created.
148 **
149 ** bPrefixIndex:
150 ** This is only used for debugging. If set to false, any prefix indexes
151 ** are ignored. This value is configured using:
152 **
153 ** INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex);
154 **
155 */
156 struct Fts5Config {
157 sqlite3 *db; /* Database handle */
158 char *zDb; /* Database holding FTS index (e.g. "main") */
159 char *zName; /* Name of FTS index */
160 int nCol; /* Number of columns */
161 char **azCol; /* Column names */
162 u8 *abUnindexed; /* True for unindexed columns */
163 int nPrefix; /* Number of prefix indexes */
164 int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */
165 int eContent; /* An FTS5_CONTENT value */
166 char *zContent; /* content table */
167 char *zContentRowid; /* "content_rowid=" option value */
168 int bColumnsize; /* "columnsize=" option value (dflt==1) */
169 int eDetail; /* FTS5_DETAIL_XXX value */
170 char *zContentExprlist;
171 Fts5Tokenizer *pTok;
172 fts5_tokenizer *pTokApi;
173
174 /* Values loaded from the %_config table */
175 int iCookie; /* Incremented when %_config is modified */
176 int pgsz; /* Approximate page size used in %_data */
177 int nAutomerge; /* 'automerge' setting */
178 int nCrisisMerge; /* Maximum allowed segments per level */
179 int nUsermerge; /* 'usermerge' setting */
180 int nHashSize; /* Bytes of memory for in-memory hash */
181 char *zRank; /* Name of rank function */
182 char *zRankArgs; /* Arguments to rank function */
183
184 /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */
185 char **pzErrmsg;
186
187 #ifdef SQLITE_DEBUG
188 int bPrefixIndex; /* True to use prefix-indexes */
189 #endif
190 };
191
192 /* Current expected value of %_config table 'version' field */
193 #define FTS5_CURRENT_VERSION 4
194
195 #define FTS5_CONTENT_NORMAL 0
196 #define FTS5_CONTENT_NONE 1
197 #define FTS5_CONTENT_EXTERNAL 2
198
199 #define FTS5_DETAIL_FULL 0
200 #define FTS5_DETAIL_NONE 1
201 #define FTS5_DETAIL_COLUMNS 2
202
203
204
205 int sqlite3Fts5ConfigParse(
206 Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char**
207 );
208 void sqlite3Fts5ConfigFree(Fts5Config*);
209
210 int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig);
211
212 int sqlite3Fts5Tokenize(
213 Fts5Config *pConfig, /* FTS5 Configuration object */
214 int flags, /* FTS5_TOKENIZE_* flags */
215 const char *pText, int nText, /* Text to tokenize */
216 void *pCtx, /* Context passed to xToken() */
217 int (*xToken)(void*, int, const char*, int, int, int) /* Callback */
218 );
219
220 void sqlite3Fts5Dequote(char *z);
221
222 /* Load the contents of the %_config table */
223 int sqlite3Fts5ConfigLoad(Fts5Config*, int);
224
225 /* Set the value of a single config attribute */
226 int sqlite3Fts5ConfigSetValue(Fts5Config*, const char*, sqlite3_value*, int*);
227
228 int sqlite3Fts5ConfigParseRank(const char*, char**, char**);
229
230 /*
231 ** End of interface to code in fts5_config.c.
232 **************************************************************************/
233
234 /**************************************************************************
235 ** Interface to code in fts5_buffer.c.
236 */
237
238 /*
239 ** Buffer object for the incremental building of string data.
240 */
241 typedef struct Fts5Buffer Fts5Buffer;
242 struct Fts5Buffer {
243 u8 *p;
244 int n;
245 int nSpace;
246 };
247
248 int sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32);
249 void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64);
250 void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*);
251 void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*);
252 void sqlite3Fts5BufferFree(Fts5Buffer*);
253 void sqlite3Fts5BufferZero(Fts5Buffer*);
254 void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*);
255 void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...);
256
257 char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...);
258
259 #define fts5BufferZero(x) sqlite3Fts5BufferZero(x)
260 #define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c)
261 #define fts5BufferFree(a) sqlite3Fts5BufferFree(a)
262 #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d)
263 #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d)
264
265 #define fts5BufferGrow(pRc,pBuf,nn) ( \
266 (u32)((pBuf)->n) + (u32)(nn) <= (u32)((pBuf)->nSpace) ? 0 : \
267 sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \
268 )
269
270 /* Write and decode big-endian 32-bit integer values */
271 void sqlite3Fts5Put32(u8*, int);
272 int sqlite3Fts5Get32(const u8*);
273
274 #define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)
275 #define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF)
276
277 typedef struct Fts5PoslistReader Fts5PoslistReader;
278 struct Fts5PoslistReader {
279 /* Variables used only by sqlite3Fts5PoslistIterXXX() functions. */
280 const u8 *a; /* Position list to iterate through */
281 int n; /* Size of buffer at a[] in bytes */
282 int i; /* Current offset in a[] */
283
284 u8 bFlag; /* For client use (any custom purpose) */
285
286 /* Output variables */
287 u8 bEof; /* Set to true at EOF */
288 i64 iPos; /* (iCol<<32) + iPos */
289 };
290 int sqlite3Fts5PoslistReaderInit(
291 const u8 *a, int n, /* Poslist buffer to iterate through */
292 Fts5PoslistReader *pIter /* Iterator object to initialize */
293 );
294 int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader*);
295
296 typedef struct Fts5PoslistWriter Fts5PoslistWriter;
297 struct Fts5PoslistWriter {
298 i64 iPrev;
299 };
300 int sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64);
301 void sqlite3Fts5PoslistSafeAppend(Fts5Buffer*, i64*, i64);
302
303 int sqlite3Fts5PoslistNext64(
304 const u8 *a, int n, /* Buffer containing poslist */
305 int *pi, /* IN/OUT: Offset within a[] */
306 i64 *piOff /* IN/OUT: Current offset */
307 );
308
309 /* Malloc utility */
310 void *sqlite3Fts5MallocZero(int *pRc, int nByte);
311 char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);
312
313 /* Character set tests (like isspace(), isalpha() etc.) */
314 int sqlite3Fts5IsBareword(char t);
315
316
317 /* Bucket of terms object used by the integrity-check in offsets=0 mode. */
318 typedef struct Fts5Termset Fts5Termset;
319 int sqlite3Fts5TermsetNew(Fts5Termset**);
320 int sqlite3Fts5TermsetAdd(Fts5Termset*, int, const char*, int, int *pbPresent);
321 void sqlite3Fts5TermsetFree(Fts5Termset*);
322
323 /*
324 ** End of interface to code in fts5_buffer.c.
325 **************************************************************************/
326
327 /**************************************************************************
328 ** Interface to code in fts5_index.c. fts5_index.c contains contains code
329 ** to access the data stored in the %_data table.
330 */
331
332 typedef struct Fts5Index Fts5Index;
333 typedef struct Fts5IndexIter Fts5IndexIter;
334
335 struct Fts5IndexIter {
336 i64 iRowid;
337 const u8 *pData;
338 int nData;
339 u8 bEof;
340 };
341
342 #define sqlite3Fts5IterEof(x) ((x)->bEof)
343
344 /*
345 ** Values used as part of the flags argument passed to IndexQuery().
346 */
347 #define FTS5INDEX_QUERY_PREFIX 0x0001 /* Prefix query */
348 #define FTS5INDEX_QUERY_DESC 0x0002 /* Docs in descending rowid order */
349 #define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */
350 #define FTS5INDEX_QUERY_SCAN 0x0008 /* Scan query (fts5vocab) */
351
352 /* The following are used internally by the fts5_index.c module. They are
353 ** defined here only to make it easier to avoid clashes with the flags
354 ** above. */
355 #define FTS5INDEX_QUERY_SKIPEMPTY 0x0010
356 #define FTS5INDEX_QUERY_NOOUTPUT 0x0020
357
358 /*
359 ** Create/destroy an Fts5Index object.
360 */
361 int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);
362 int sqlite3Fts5IndexClose(Fts5Index *p);
363
364 /*
365 ** Return a simple checksum value based on the arguments.
366 */
367 u64 sqlite3Fts5IndexEntryCksum(
368 i64 iRowid,
369 int iCol,
370 int iPos,
371 int iIdx,
372 const char *pTerm,
373 int nTerm
374 );
375
376 /*
377 ** Argument p points to a buffer containing utf-8 text that is n bytes in
378 ** size. Return the number of bytes in the nChar character prefix of the
379 ** buffer, or 0 if there are less than nChar characters in total.
380 */
381 int sqlite3Fts5IndexCharlenToBytelen(
382 const char *p,
383 int nByte,
384 int nChar
385 );
386
387 /*
388 ** Open a new iterator to iterate though all rowids that match the
389 ** specified token or token prefix.
390 */
391 int sqlite3Fts5IndexQuery(
392 Fts5Index *p, /* FTS index to query */
393 const char *pToken, int nToken, /* Token (or prefix) to query for */
394 int flags, /* Mask of FTS5INDEX_QUERY_X flags */
395 Fts5Colset *pColset, /* Match these columns only */
396 Fts5IndexIter **ppIter /* OUT: New iterator object */
397 );
398
399 /*
400 ** The various operations on open token or token prefix iterators opened
401 ** using sqlite3Fts5IndexQuery().
402 */
403 int sqlite3Fts5IterNext(Fts5IndexIter*);
404 int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);
405
406 /*
407 ** Close an iterator opened by sqlite3Fts5IndexQuery().
408 */
409 void sqlite3Fts5IterClose(Fts5IndexIter*);
410
411 /*
412 ** This interface is used by the fts5vocab module.
413 */
414 const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
415 int sqlite3Fts5IterNextScan(Fts5IndexIter*);
416
417
418 /*
419 ** Insert or remove data to or from the index. Each time a document is
420 ** added to or removed from the index, this function is called one or more
421 ** times.
422 **
423 ** For an insert, it must be called once for each token in the new document.
424 ** If the operation is a delete, it must be called (at least) once for each
425 ** unique token in the document with an iCol value less than zero. The iPos
426 ** argument is ignored for a delete.
427 */
428 int sqlite3Fts5IndexWrite(
429 Fts5Index *p, /* Index to write to */
430 int iCol, /* Column token appears in (-ve -> delete) */
431 int iPos, /* Position of token within column */
432 const char *pToken, int nToken /* Token to add or remove to or from index */
433 );
434
435 /*
436 ** Indicate that subsequent calls to sqlite3Fts5IndexWrite() pertain to
437 ** document iDocid.
438 */
439 int sqlite3Fts5IndexBeginWrite(
440 Fts5Index *p, /* Index to write to */
441 int bDelete, /* True if current operation is a delete */
442 i64 iDocid /* Docid to add or remove data from */
443 );
444
445 /*
446 ** Flush any data stored in the in-memory hash tables to the database.
447 ** If the bCommit flag is true, also close any open blob handles.
448 */
449 int sqlite3Fts5IndexSync(Fts5Index *p, int bCommit);
450
451 /*
452 ** Discard any data stored in the in-memory hash tables. Do not write it
453 ** to the database. Additionally, assume that the contents of the %_data
454 ** table may have changed on disk. So any in-memory caches of %_data
455 ** records must be invalidated.
456 */
457 int sqlite3Fts5IndexRollback(Fts5Index *p);
458
459 /*
460 ** Get or set the "averages" values.
461 */
462 int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize);
463 int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);
464
465 /*
466 ** Functions called by the storage module as part of integrity-check.
467 */
468 int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum);
469
470 /*
471 ** Called during virtual module initialization to register UDF
472 ** fts5_decode() with SQLite
473 */
474 int sqlite3Fts5IndexInit(sqlite3*);
475
476 int sqlite3Fts5IndexSetCookie(Fts5Index*, int);
477
478 /*
479 ** Return the total number of entries read from the %_data table by
480 ** this connection since it was created.
481 */
482 int sqlite3Fts5IndexReads(Fts5Index *p);
483
484 int sqlite3Fts5IndexReinit(Fts5Index *p);
485 int sqlite3Fts5IndexOptimize(Fts5Index *p);
486 int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge);
487 int sqlite3Fts5IndexReset(Fts5Index *p);
488
489 int sqlite3Fts5IndexLoadConfig(Fts5Index *p);
490
491 /*
492 ** End of interface to code in fts5_index.c.
493 **************************************************************************/
494
495 /**************************************************************************
496 ** Interface to code in fts5_varint.c.
497 */
498 int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v);
499 int sqlite3Fts5GetVarintLen(u32 iVal);
500 u8 sqlite3Fts5GetVarint(const unsigned char*, u64*);
501 int sqlite3Fts5PutVarint(unsigned char *p, u64 v);
502
503 #define fts5GetVarint32(a,b) sqlite3Fts5GetVarint32(a,(u32*)&b)
504 #define fts5GetVarint sqlite3Fts5GetVarint
505
506 #define fts5FastGetVarint32(a, iOff, nVal) { \
507 nVal = (a)[iOff++]; \
508 if( nVal & 0x80 ){ \
509 iOff--; \
510 iOff += fts5GetVarint32(&(a)[iOff], nVal); \
511 } \
512 }
513
514
515 /*
516 ** End of interface to code in fts5_varint.c.
517 **************************************************************************/
518
519
520 /**************************************************************************
521 ** Interface to code in fts5.c.
522 */
523
524 int sqlite3Fts5GetTokenizer(
525 Fts5Global*,
526 const char **azArg,
527 int nArg,
528 Fts5Tokenizer**,
529 fts5_tokenizer**,
530 char **pzErr
531 );
532
533 Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **);
534
535 /*
536 ** End of interface to code in fts5.c.
537 **************************************************************************/
538
539 /**************************************************************************
540 ** Interface to code in fts5_hash.c.
541 */
542 typedef struct Fts5Hash Fts5Hash;
543
544 /*
545 ** Create a hash table, free a hash table.
546 */
547 int sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize);
548 void sqlite3Fts5HashFree(Fts5Hash*);
549
550 int sqlite3Fts5HashWrite(
551 Fts5Hash*,
552 i64 iRowid, /* Rowid for this entry */
553 int iCol, /* Column token appears in (-ve -> delete) */
554 int iPos, /* Position of token within column */
555 char bByte,
556 const char *pToken, int nToken /* Token to add or remove to or from index */
557 );
558
559 /*
560 ** Empty (but do not delete) a hash table.
561 */
562 void sqlite3Fts5HashClear(Fts5Hash*);
563
564 int sqlite3Fts5HashQuery(
565 Fts5Hash*, /* Hash table to query */
566 const char *pTerm, int nTerm, /* Query term */
567 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
568 int *pnDoclist /* OUT: Size of doclist in bytes */
569 );
570
571 int sqlite3Fts5HashScanInit(
572 Fts5Hash*, /* Hash table to query */
573 const char *pTerm, int nTerm /* Query prefix */
574 );
575 void sqlite3Fts5HashScanNext(Fts5Hash*);
576 int sqlite3Fts5HashScanEof(Fts5Hash*);
577 void sqlite3Fts5HashScanEntry(Fts5Hash *,
578 const char **pzTerm, /* OUT: term (nul-terminated) */
579 const u8 **ppDoclist, /* OUT: pointer to doclist */
580 int *pnDoclist /* OUT: size of doclist in bytes */
581 );
582
583
584 /*
585 ** End of interface to code in fts5_hash.c.
586 **************************************************************************/
587
588 /**************************************************************************
589 ** Interface to code in fts5_storage.c. fts5_storage.c contains contains
590 ** code to access the data stored in the %_content and %_docsize tables.
591 */
592
593 #define FTS5_STMT_SCAN_ASC 0 /* SELECT rowid, * FROM ... ORDER BY 1 ASC */
594 #define FTS5_STMT_SCAN_DESC 1 /* SELECT rowid, * FROM ... ORDER BY 1 DESC */
595 #define FTS5_STMT_LOOKUP 2 /* SELECT rowid, * FROM ... WHERE rowid=? */
596
597 typedef struct Fts5Storage Fts5Storage;
598
599 int sqlite3Fts5StorageOpen(Fts5Config*, Fts5Index*, int, Fts5Storage**, char**);
600 int sqlite3Fts5StorageClose(Fts5Storage *p);
601 int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName);
602
603 int sqlite3Fts5DropAll(Fts5Config*);
604 int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);
605
606 int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);
607 int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);
608 int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
609
610 int sqlite3Fts5StorageIntegrity(Fts5Storage *p);
611
612 int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
613 void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);
614
615 int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);
616 int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg);
617 int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow);
618
619 int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit);
620 int sqlite3Fts5StorageRollback(Fts5Storage *p);
621
622 int sqlite3Fts5StorageConfigValue(
623 Fts5Storage *p, const char*, sqlite3_value*, int
624 );
625
626 int sqlite3Fts5StorageDeleteAll(Fts5Storage *p);
627 int sqlite3Fts5StorageRebuild(Fts5Storage *p);
628 int sqlite3Fts5StorageOptimize(Fts5Storage *p);
629 int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge);
630 int sqlite3Fts5StorageReset(Fts5Storage *p);
631
632 /*
633 ** End of interface to code in fts5_storage.c.
634 **************************************************************************/
635
636
637 /**************************************************************************
638 ** Interface to code in fts5_expr.c.
639 */
640 typedef struct Fts5Expr Fts5Expr;
641 typedef struct Fts5ExprNode Fts5ExprNode;
642 typedef struct Fts5Parse Fts5Parse;
643 typedef struct Fts5Token Fts5Token;
644 typedef struct Fts5ExprPhrase Fts5ExprPhrase;
645 typedef struct Fts5ExprNearset Fts5ExprNearset;
646
647 struct Fts5Token {
648 const char *p; /* Token text (not NULL terminated) */
649 int n; /* Size of buffer p in bytes */
650 };
651
652 /* Parse a MATCH expression. */
653 int sqlite3Fts5ExprNew(
654 Fts5Config *pConfig,
655 const char *zExpr,
656 Fts5Expr **ppNew,
657 char **pzErr
658 );
659
660 /*
661 ** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc);
662 ** rc==SQLITE_OK && 0==sqlite3Fts5ExprEof(pExpr);
663 ** rc = sqlite3Fts5ExprNext(pExpr)
664 ** ){
665 ** // The document with rowid iRowid matches the expression!
666 ** i64 iRowid = sqlite3Fts5ExprRowid(pExpr);
667 ** }
668 */
669 int sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);
670 int sqlite3Fts5ExprNext(Fts5Expr*, i64 iMax);
671 int sqlite3Fts5ExprEof(Fts5Expr*);
672 i64 sqlite3Fts5ExprRowid(Fts5Expr*);
673
674 void sqlite3Fts5ExprFree(Fts5Expr*);
675
676 /* Called during startup to register a UDF with SQLite */
677 int sqlite3Fts5ExprInit(Fts5Global*, sqlite3*);
678
679 int sqlite3Fts5ExprPhraseCount(Fts5Expr*);
680 int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase);
681 int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **);
682
683 typedef struct Fts5PoslistPopulator Fts5PoslistPopulator;
684 Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);
685 int sqlite3Fts5ExprPopulatePoslists(
686 Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
687 );
688 void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
689
690 int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
691
692 int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
693
694 /*******************************************
695 ** The fts5_expr.c API above this point is used by the other hand-written
696 ** C code in this module. The interfaces below this point are called by
697 ** the parser code in fts5parse.y. */
698
699 void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...);
700
701 Fts5ExprNode *sqlite3Fts5ParseNode(
702 Fts5Parse *pParse,
703 int eType,
704 Fts5ExprNode *pLeft,
705 Fts5ExprNode *pRight,
706 Fts5ExprNearset *pNear
707 );
708
709 Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(
710 Fts5Parse *pParse,
711 Fts5ExprNode *pLeft,
712 Fts5ExprNode *pRight
713 );
714
715 Fts5ExprPhrase *sqlite3Fts5ParseTerm(
716 Fts5Parse *pParse,
717 Fts5ExprPhrase *pPhrase,
718 Fts5Token *pToken,
719 int bPrefix
720 );
721
722 Fts5ExprNearset *sqlite3Fts5ParseNearset(
723 Fts5Parse*,
724 Fts5ExprNearset*,
725 Fts5ExprPhrase*
726 );
727
728 Fts5Colset *sqlite3Fts5ParseColset(
729 Fts5Parse*,
730 Fts5Colset*,
731 Fts5Token *
732 );
733
734 void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*);
735 void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*);
736 void sqlite3Fts5ParseNodeFree(Fts5ExprNode*);
737
738 void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*);
739 void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*);
740 Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*);
741 void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p);
742 void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*);
743
744 /*
745 ** End of interface to code in fts5_expr.c.
746 **************************************************************************/
747
748
749
750 /**************************************************************************
751 ** Interface to code in fts5_aux.c.
752 */
753
754 int sqlite3Fts5AuxInit(fts5_api*);
755 /*
756 ** End of interface to code in fts5_aux.c.
757 **************************************************************************/
758
759 /**************************************************************************
760 ** Interface to code in fts5_tokenizer.c.
761 */
762
763 int sqlite3Fts5TokenizerInit(fts5_api*);
764 /*
765 ** End of interface to code in fts5_tokenizer.c.
766 **************************************************************************/
767
768 /**************************************************************************
769 ** Interface to code in fts5_vocab.c.
770 */
771
772 int sqlite3Fts5VocabInit(Fts5Global*, sqlite3*);
773
774 /*
775 ** End of interface to code in fts5_vocab.c.
776 **************************************************************************/
777
778
779 /**************************************************************************
780 ** Interface to automatically generated code in fts5_unicode2.c.
781 */
782 int sqlite3Fts5UnicodeIsalnum(int c);
783 int sqlite3Fts5UnicodeIsdiacritic(int c);
784 int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
785 /*
786 ** End of interface to code in fts5_unicode2.c.
787 **************************************************************************/
788
789 #endif
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3170000/ext/fts5/fts5.h ('k') | third_party/sqlite/sqlite-src-3170000/ext/fts5/fts5_aux.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698