OLD | NEW |
1 /* | 1 /* |
2 ** 2014 May 31 | 2 ** 2014 May 31 |
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 ** |
11 ****************************************************************************** | 11 ****************************************************************************** |
12 ** | 12 ** |
13 */ | 13 */ |
14 #ifndef _FTS5INT_H | 14 #ifndef _FTS5INT_H |
15 #define _FTS5INT_H | 15 #define _FTS5INT_H |
16 | 16 |
17 #include "fts5.h" | 17 #include "fts5.h" |
18 #include "sqlite3ext.h" | 18 #include "sqlite3ext.h" |
19 SQLITE_EXTENSION_INIT1 | 19 SQLITE_EXTENSION_INIT1 |
20 | 20 |
21 #include <string.h> | 21 #include <string.h> |
22 #include <assert.h> | 22 #include <assert.h> |
23 | 23 |
24 #ifndef SQLITE_AMALGAMATION | 24 #ifndef SQLITE_AMALGAMATION |
25 | 25 |
26 typedef unsigned char u8; | 26 typedef unsigned char u8; |
27 typedef unsigned int u32; | 27 typedef unsigned int u32; |
28 typedef unsigned short u16; | 28 typedef unsigned short u16; |
| 29 typedef short i16; |
29 typedef sqlite3_int64 i64; | 30 typedef sqlite3_int64 i64; |
30 typedef sqlite3_uint64 u64; | 31 typedef sqlite3_uint64 u64; |
31 | 32 |
32 #define ArraySize(x) (sizeof(x) / sizeof(x[0])) | 33 #define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0]))) |
33 | 34 |
34 #define testcase(x) | 35 #define testcase(x) |
35 #define ALWAYS(x) 1 | 36 #define ALWAYS(x) 1 |
36 #define NEVER(x) 0 | 37 #define NEVER(x) 0 |
37 | 38 |
38 #define MIN(x,y) (((x) < (y)) ? (x) : (y)) | 39 #define MIN(x,y) (((x) < (y)) ? (x) : (y)) |
39 #define MAX(x,y) (((x) > (y)) ? (x) : (y)) | 40 #define MAX(x,y) (((x) > (y)) ? (x) : (y)) |
40 | 41 |
41 /* | 42 /* |
42 ** Constants for the largest and smallest possible 64-bit signed integers. | 43 ** Constants for the largest and smallest possible 64-bit signed integers. |
43 */ | 44 */ |
44 # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) | 45 # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
45 # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) | 46 # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
46 | 47 |
47 #endif | 48 #endif |
48 | 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 |
49 | 54 |
50 /* | 55 /* |
51 ** Maximum number of prefix indexes on single FTS5 table. This must be | 56 ** Maximum number of prefix indexes on single FTS5 table. This must be |
52 ** less than 32. If it is set to anything large than that, an #error | 57 ** less than 32. If it is set to anything large than that, an #error |
53 ** directive in fts5_index.c will cause the build to fail. | 58 ** directive in fts5_index.c will cause the build to fail. |
54 */ | 59 */ |
55 #define FTS5_MAX_PREFIX_INDEXES 31 | 60 #define FTS5_MAX_PREFIX_INDEXES 31 |
56 | 61 |
57 #define FTS5_DEFAULT_NEARDIST 10 | 62 #define FTS5_DEFAULT_NEARDIST 10 |
58 #define FTS5_DEFAULT_RANK "bm25" | 63 #define FTS5_DEFAULT_RANK "bm25" |
(...skipping 14 matching lines...) Expand all Loading... |
73 ** is used for assert() conditions that are true only if it can be | 78 ** is used for assert() conditions that are true only if it can be |
74 ** guranteed that the database is not corrupt. | 79 ** guranteed that the database is not corrupt. |
75 */ | 80 */ |
76 #ifdef SQLITE_DEBUG | 81 #ifdef SQLITE_DEBUG |
77 extern int sqlite3_fts5_may_be_corrupt; | 82 extern int sqlite3_fts5_may_be_corrupt; |
78 # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x)) | 83 # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x)) |
79 #else | 84 #else |
80 # define assert_nc(x) assert(x) | 85 # define assert_nc(x) assert(x) |
81 #endif | 86 #endif |
82 | 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 |
83 typedef struct Fts5Global Fts5Global; | 98 typedef struct Fts5Global Fts5Global; |
84 typedef struct Fts5Colset Fts5Colset; | 99 typedef struct Fts5Colset Fts5Colset; |
85 | 100 |
86 /* If a NEAR() clump or phrase may only match a specific set of columns, | 101 /* If a NEAR() clump or phrase may only match a specific set of columns, |
87 ** then an object of the following type is used to record the set of columns. | 102 ** then an object of the following type is used to record the set of columns. |
88 ** Each entry in the aiCol[] array is a column that may be matched. | 103 ** Each entry in the aiCol[] array is a column that may be matched. |
89 ** | 104 ** |
90 ** This object is used by fts5_expr.c and fts5_index.c. | 105 ** This object is used by fts5_expr.c and fts5_index.c. |
91 */ | 106 */ |
92 struct Fts5Colset { | 107 struct Fts5Colset { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 char *zName; /* Name of FTS index */ | 159 char *zName; /* Name of FTS index */ |
145 int nCol; /* Number of columns */ | 160 int nCol; /* Number of columns */ |
146 char **azCol; /* Column names */ | 161 char **azCol; /* Column names */ |
147 u8 *abUnindexed; /* True for unindexed columns */ | 162 u8 *abUnindexed; /* True for unindexed columns */ |
148 int nPrefix; /* Number of prefix indexes */ | 163 int nPrefix; /* Number of prefix indexes */ |
149 int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */ | 164 int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */ |
150 int eContent; /* An FTS5_CONTENT value */ | 165 int eContent; /* An FTS5_CONTENT value */ |
151 char *zContent; /* content table */ | 166 char *zContent; /* content table */ |
152 char *zContentRowid; /* "content_rowid=" option value */ | 167 char *zContentRowid; /* "content_rowid=" option value */ |
153 int bColumnsize; /* "columnsize=" option value (dflt==1) */ | 168 int bColumnsize; /* "columnsize=" option value (dflt==1) */ |
| 169 int eDetail; /* FTS5_DETAIL_XXX value */ |
154 char *zContentExprlist; | 170 char *zContentExprlist; |
155 Fts5Tokenizer *pTok; | 171 Fts5Tokenizer *pTok; |
156 fts5_tokenizer *pTokApi; | 172 fts5_tokenizer *pTokApi; |
157 | 173 |
158 /* Values loaded from the %_config table */ | 174 /* Values loaded from the %_config table */ |
159 int iCookie; /* Incremented when %_config is modified */ | 175 int iCookie; /* Incremented when %_config is modified */ |
160 int pgsz; /* Approximate page size used in %_data */ | 176 int pgsz; /* Approximate page size used in %_data */ |
161 int nAutomerge; /* 'automerge' setting */ | 177 int nAutomerge; /* 'automerge' setting */ |
162 int nCrisisMerge; /* Maximum allowed segments per level */ | 178 int nCrisisMerge; /* Maximum allowed segments per level */ |
| 179 int nUsermerge; /* 'usermerge' setting */ |
163 int nHashSize; /* Bytes of memory for in-memory hash */ | 180 int nHashSize; /* Bytes of memory for in-memory hash */ |
164 char *zRank; /* Name of rank function */ | 181 char *zRank; /* Name of rank function */ |
165 char *zRankArgs; /* Arguments to rank function */ | 182 char *zRankArgs; /* Arguments to rank function */ |
166 | 183 |
167 /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */ | 184 /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */ |
168 char **pzErrmsg; | 185 char **pzErrmsg; |
169 | 186 |
170 #ifdef SQLITE_DEBUG | 187 #ifdef SQLITE_DEBUG |
171 int bPrefixIndex; /* True to use prefix-indexes */ | 188 int bPrefixIndex; /* True to use prefix-indexes */ |
172 #endif | 189 #endif |
173 }; | 190 }; |
174 | 191 |
175 /* Current expected value of %_config table 'version' field */ | 192 /* Current expected value of %_config table 'version' field */ |
176 #define FTS5_CURRENT_VERSION 4 | 193 #define FTS5_CURRENT_VERSION 4 |
177 | 194 |
178 #define FTS5_CONTENT_NORMAL 0 | 195 #define FTS5_CONTENT_NORMAL 0 |
179 #define FTS5_CONTENT_NONE 1 | 196 #define FTS5_CONTENT_NONE 1 |
180 #define FTS5_CONTENT_EXTERNAL 2 | 197 #define FTS5_CONTENT_EXTERNAL 2 |
181 | 198 |
| 199 #define FTS5_DETAIL_FULL 0 |
| 200 #define FTS5_DETAIL_NONE 1 |
| 201 #define FTS5_DETAIL_COLUMNS 2 |
182 | 202 |
183 | 203 |
184 | 204 |
185 int sqlite3Fts5ConfigParse( | 205 int sqlite3Fts5ConfigParse( |
186 Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char** | 206 Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char** |
187 ); | 207 ); |
188 void sqlite3Fts5ConfigFree(Fts5Config*); | 208 void sqlite3Fts5ConfigFree(Fts5Config*); |
189 | 209 |
190 int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig); | 210 int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig); |
191 | 211 |
(...skipping 26 matching lines...) Expand all Loading... |
218 /* | 238 /* |
219 ** Buffer object for the incremental building of string data. | 239 ** Buffer object for the incremental building of string data. |
220 */ | 240 */ |
221 typedef struct Fts5Buffer Fts5Buffer; | 241 typedef struct Fts5Buffer Fts5Buffer; |
222 struct Fts5Buffer { | 242 struct Fts5Buffer { |
223 u8 *p; | 243 u8 *p; |
224 int n; | 244 int n; |
225 int nSpace; | 245 int nSpace; |
226 }; | 246 }; |
227 | 247 |
228 int sqlite3Fts5BufferSize(int*, Fts5Buffer*, int); | 248 int sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32); |
229 void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); | 249 void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); |
230 void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); | 250 void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*); |
231 void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); | 251 void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); |
232 void sqlite3Fts5BufferFree(Fts5Buffer*); | 252 void sqlite3Fts5BufferFree(Fts5Buffer*); |
233 void sqlite3Fts5BufferZero(Fts5Buffer*); | 253 void sqlite3Fts5BufferZero(Fts5Buffer*); |
234 void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); | 254 void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); |
235 void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); | 255 void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); |
236 | 256 |
237 char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); | 257 char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); |
238 | 258 |
239 #define fts5BufferZero(x) sqlite3Fts5BufferZero(x) | 259 #define fts5BufferZero(x) sqlite3Fts5BufferZero(x) |
240 #define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c) | 260 #define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c) |
241 #define fts5BufferFree(a) sqlite3Fts5BufferFree(a) | 261 #define fts5BufferFree(a) sqlite3Fts5BufferFree(a) |
242 #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d) | 262 #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d) |
243 #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) | 263 #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) |
244 | 264 |
245 #define fts5BufferGrow(pRc,pBuf,nn) ( \ | 265 #define fts5BufferGrow(pRc,pBuf,nn) ( \ |
246 (pBuf)->n + (nn) <= (pBuf)->nSpace ? 0 : \ | 266 (u32)((pBuf)->n) + (u32)(nn) <= (u32)((pBuf)->nSpace) ? 0 : \ |
247 sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \ | 267 sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \ |
248 ) | 268 ) |
249 | 269 |
250 /* Write and decode big-endian 32-bit integer values */ | 270 /* Write and decode big-endian 32-bit integer values */ |
251 void sqlite3Fts5Put32(u8*, int); | 271 void sqlite3Fts5Put32(u8*, int); |
252 int sqlite3Fts5Get32(const u8*); | 272 int sqlite3Fts5Get32(const u8*); |
253 | 273 |
254 #define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32) | 274 #define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32) |
255 #define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF) | 275 #define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF) |
256 | 276 |
(...skipping 14 matching lines...) Expand all Loading... |
271 const u8 *a, int n, /* Poslist buffer to iterate through */ | 291 const u8 *a, int n, /* Poslist buffer to iterate through */ |
272 Fts5PoslistReader *pIter /* Iterator object to initialize */ | 292 Fts5PoslistReader *pIter /* Iterator object to initialize */ |
273 ); | 293 ); |
274 int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader*); | 294 int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader*); |
275 | 295 |
276 typedef struct Fts5PoslistWriter Fts5PoslistWriter; | 296 typedef struct Fts5PoslistWriter Fts5PoslistWriter; |
277 struct Fts5PoslistWriter { | 297 struct Fts5PoslistWriter { |
278 i64 iPrev; | 298 i64 iPrev; |
279 }; | 299 }; |
280 int sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64); | 300 int sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64); |
| 301 void sqlite3Fts5PoslistSafeAppend(Fts5Buffer*, i64*, i64); |
281 | 302 |
282 int sqlite3Fts5PoslistNext64( | 303 int sqlite3Fts5PoslistNext64( |
283 const u8 *a, int n, /* Buffer containing poslist */ | 304 const u8 *a, int n, /* Buffer containing poslist */ |
284 int *pi, /* IN/OUT: Offset within a[] */ | 305 int *pi, /* IN/OUT: Offset within a[] */ |
285 i64 *piOff /* IN/OUT: Current offset */ | 306 i64 *piOff /* IN/OUT: Current offset */ |
286 ); | 307 ); |
287 | 308 |
288 /* Malloc utility */ | 309 /* Malloc utility */ |
289 void *sqlite3Fts5MallocZero(int *pRc, int nByte); | 310 void *sqlite3Fts5MallocZero(int *pRc, int nByte); |
290 char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn); | 311 char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn); |
291 | 312 |
292 /* Character set tests (like isspace(), isalpha() etc.) */ | 313 /* Character set tests (like isspace(), isalpha() etc.) */ |
293 int sqlite3Fts5IsBareword(char t); | 314 int sqlite3Fts5IsBareword(char t); |
294 | 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 |
295 /* | 323 /* |
296 ** End of interface to code in fts5_buffer.c. | 324 ** End of interface to code in fts5_buffer.c. |
297 **************************************************************************/ | 325 **************************************************************************/ |
298 | 326 |
299 /************************************************************************** | 327 /************************************************************************** |
300 ** Interface to code in fts5_index.c. fts5_index.c contains contains code | 328 ** Interface to code in fts5_index.c. fts5_index.c contains contains code |
301 ** to access the data stored in the %_data table. | 329 ** to access the data stored in the %_data table. |
302 */ | 330 */ |
303 | 331 |
304 typedef struct Fts5Index Fts5Index; | 332 typedef struct Fts5Index Fts5Index; |
305 typedef struct Fts5IndexIter Fts5IndexIter; | 333 typedef struct Fts5IndexIter Fts5IndexIter; |
306 | 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 |
307 /* | 344 /* |
308 ** Values used as part of the flags argument passed to IndexQuery(). | 345 ** Values used as part of the flags argument passed to IndexQuery(). |
309 */ | 346 */ |
310 #define FTS5INDEX_QUERY_PREFIX 0x0001 /* Prefix query */ | 347 #define FTS5INDEX_QUERY_PREFIX 0x0001 /* Prefix query */ |
311 #define FTS5INDEX_QUERY_DESC 0x0002 /* Docs in descending rowid order */ | 348 #define FTS5INDEX_QUERY_DESC 0x0002 /* Docs in descending rowid order */ |
312 #define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */ | 349 #define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */ |
313 #define FTS5INDEX_QUERY_SCAN 0x0008 /* Scan query (fts5vocab) */ | 350 #define FTS5INDEX_QUERY_SCAN 0x0008 /* Scan query (fts5vocab) */ |
314 | 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 |
315 /* | 358 /* |
316 ** Create/destroy an Fts5Index object. | 359 ** Create/destroy an Fts5Index object. |
317 */ | 360 */ |
318 int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**); | 361 int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**); |
319 int sqlite3Fts5IndexClose(Fts5Index *p); | 362 int sqlite3Fts5IndexClose(Fts5Index *p); |
320 | 363 |
321 /* | 364 /* |
322 ** for( | 365 ** Return a simple checksum value based on the arguments. |
323 ** sqlite3Fts5IndexQuery(p, "token", 5, 0, 0, &pIter); | |
324 ** 0==sqlite3Fts5IterEof(pIter); | |
325 ** sqlite3Fts5IterNext(pIter) | |
326 ** ){ | |
327 ** i64 iRowid = sqlite3Fts5IterRowid(pIter); | |
328 ** } | |
329 */ | 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 ); |
330 | 386 |
331 /* | 387 /* |
332 ** Open a new iterator to iterate though all rowids that match the | 388 ** Open a new iterator to iterate though all rowids that match the |
333 ** specified token or token prefix. | 389 ** specified token or token prefix. |
334 */ | 390 */ |
335 int sqlite3Fts5IndexQuery( | 391 int sqlite3Fts5IndexQuery( |
336 Fts5Index *p, /* FTS index to query */ | 392 Fts5Index *p, /* FTS index to query */ |
337 const char *pToken, int nToken, /* Token (or prefix) to query for */ | 393 const char *pToken, int nToken, /* Token (or prefix) to query for */ |
338 int flags, /* Mask of FTS5INDEX_QUERY_X flags */ | 394 int flags, /* Mask of FTS5INDEX_QUERY_X flags */ |
339 Fts5Colset *pColset, /* Match these columns only */ | 395 Fts5Colset *pColset, /* Match these columns only */ |
340 Fts5IndexIter **ppIter /* OUT: New iterator object */ | 396 Fts5IndexIter **ppIter /* OUT: New iterator object */ |
341 ); | 397 ); |
342 | 398 |
343 /* | 399 /* |
344 ** The various operations on open token or token prefix iterators opened | 400 ** The various operations on open token or token prefix iterators opened |
345 ** using sqlite3Fts5IndexQuery(). | 401 ** using sqlite3Fts5IndexQuery(). |
346 */ | 402 */ |
347 int sqlite3Fts5IterEof(Fts5IndexIter*); | |
348 int sqlite3Fts5IterNext(Fts5IndexIter*); | 403 int sqlite3Fts5IterNext(Fts5IndexIter*); |
349 int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch); | 404 int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch); |
350 i64 sqlite3Fts5IterRowid(Fts5IndexIter*); | |
351 int sqlite3Fts5IterPoslist(Fts5IndexIter*,Fts5Colset*, const u8**, int*, i64*); | |
352 int sqlite3Fts5IterPoslistBuffer(Fts5IndexIter *pIter, Fts5Buffer *pBuf); | |
353 | 405 |
354 /* | 406 /* |
355 ** Close an iterator opened by sqlite3Fts5IndexQuery(). | 407 ** Close an iterator opened by sqlite3Fts5IndexQuery(). |
356 */ | 408 */ |
357 void sqlite3Fts5IterClose(Fts5IndexIter*); | 409 void sqlite3Fts5IterClose(Fts5IndexIter*); |
358 | 410 |
359 /* | 411 /* |
360 ** This interface is used by the fts5vocab module. | 412 ** This interface is used by the fts5vocab module. |
361 */ | 413 */ |
362 const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*); | 414 const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 458 |
407 /* | 459 /* |
408 ** Get or set the "averages" values. | 460 ** Get or set the "averages" values. |
409 */ | 461 */ |
410 int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize); | 462 int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize); |
411 int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int); | 463 int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int); |
412 | 464 |
413 /* | 465 /* |
414 ** Functions called by the storage module as part of integrity-check. | 466 ** Functions called by the storage module as part of integrity-check. |
415 */ | 467 */ |
416 u64 sqlite3Fts5IndexCksum(Fts5Config*,i64,int,int,const char*,int); | |
417 int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum); | 468 int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum); |
418 | 469 |
419 /* | 470 /* |
420 ** Called during virtual module initialization to register UDF | 471 ** Called during virtual module initialization to register UDF |
421 ** fts5_decode() with SQLite | 472 ** fts5_decode() with SQLite |
422 */ | 473 */ |
423 int sqlite3Fts5IndexInit(sqlite3*); | 474 int sqlite3Fts5IndexInit(sqlite3*); |
424 | 475 |
425 int sqlite3Fts5IndexSetCookie(Fts5Index*, int); | 476 int sqlite3Fts5IndexSetCookie(Fts5Index*, int); |
426 | 477 |
427 /* | 478 /* |
428 ** Return the total number of entries read from the %_data table by | 479 ** Return the total number of entries read from the %_data table by |
429 ** this connection since it was created. | 480 ** this connection since it was created. |
430 */ | 481 */ |
431 int sqlite3Fts5IndexReads(Fts5Index *p); | 482 int sqlite3Fts5IndexReads(Fts5Index *p); |
432 | 483 |
433 int sqlite3Fts5IndexReinit(Fts5Index *p); | 484 int sqlite3Fts5IndexReinit(Fts5Index *p); |
434 int sqlite3Fts5IndexOptimize(Fts5Index *p); | 485 int sqlite3Fts5IndexOptimize(Fts5Index *p); |
435 int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge); | 486 int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge); |
| 487 int sqlite3Fts5IndexReset(Fts5Index *p); |
436 | 488 |
437 int sqlite3Fts5IndexLoadConfig(Fts5Index *p); | 489 int sqlite3Fts5IndexLoadConfig(Fts5Index *p); |
438 | 490 |
439 /* | 491 /* |
440 ** End of interface to code in fts5_index.c. | 492 ** End of interface to code in fts5_index.c. |
441 **************************************************************************/ | 493 **************************************************************************/ |
442 | 494 |
443 /************************************************************************** | 495 /************************************************************************** |
444 ** Interface to code in fts5_varint.c. | 496 ** Interface to code in fts5_varint.c. |
445 */ | 497 */ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 **************************************************************************/ | 537 **************************************************************************/ |
486 | 538 |
487 /************************************************************************** | 539 /************************************************************************** |
488 ** Interface to code in fts5_hash.c. | 540 ** Interface to code in fts5_hash.c. |
489 */ | 541 */ |
490 typedef struct Fts5Hash Fts5Hash; | 542 typedef struct Fts5Hash Fts5Hash; |
491 | 543 |
492 /* | 544 /* |
493 ** Create a hash table, free a hash table. | 545 ** Create a hash table, free a hash table. |
494 */ | 546 */ |
495 int sqlite3Fts5HashNew(Fts5Hash**, int *pnSize); | 547 int sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize); |
496 void sqlite3Fts5HashFree(Fts5Hash*); | 548 void sqlite3Fts5HashFree(Fts5Hash*); |
497 | 549 |
498 int sqlite3Fts5HashWrite( | 550 int sqlite3Fts5HashWrite( |
499 Fts5Hash*, | 551 Fts5Hash*, |
500 i64 iRowid, /* Rowid for this entry */ | 552 i64 iRowid, /* Rowid for this entry */ |
501 int iCol, /* Column token appears in (-ve -> delete) */ | 553 int iCol, /* Column token appears in (-ve -> delete) */ |
502 int iPos, /* Position of token within column */ | 554 int iPos, /* Position of token within column */ |
503 char bByte, | 555 char bByte, |
504 const char *pToken, int nToken /* Token to add or remove to or from index */ | 556 const char *pToken, int nToken /* Token to add or remove to or from index */ |
505 ); | 557 ); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 596 |
545 typedef struct Fts5Storage Fts5Storage; | 597 typedef struct Fts5Storage Fts5Storage; |
546 | 598 |
547 int sqlite3Fts5StorageOpen(Fts5Config*, Fts5Index*, int, Fts5Storage**, char**); | 599 int sqlite3Fts5StorageOpen(Fts5Config*, Fts5Index*, int, Fts5Storage**, char**); |
548 int sqlite3Fts5StorageClose(Fts5Storage *p); | 600 int sqlite3Fts5StorageClose(Fts5Storage *p); |
549 int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName); | 601 int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName); |
550 | 602 |
551 int sqlite3Fts5DropAll(Fts5Config*); | 603 int sqlite3Fts5DropAll(Fts5Config*); |
552 int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); | 604 int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); |
553 | 605 |
554 int sqlite3Fts5StorageDelete(Fts5Storage *p, i64); | 606 int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**); |
555 int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); | 607 int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); |
556 int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); | 608 int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); |
557 | 609 |
558 int sqlite3Fts5StorageIntegrity(Fts5Storage *p); | 610 int sqlite3Fts5StorageIntegrity(Fts5Storage *p); |
559 | 611 |
560 int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**); | 612 int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**); |
561 void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*); | 613 void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*); |
562 | 614 |
563 int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol); | 615 int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol); |
564 int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg); | 616 int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg); |
565 int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow); | 617 int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow); |
566 | 618 |
567 int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit); | 619 int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit); |
568 int sqlite3Fts5StorageRollback(Fts5Storage *p); | 620 int sqlite3Fts5StorageRollback(Fts5Storage *p); |
569 | 621 |
570 int sqlite3Fts5StorageConfigValue( | 622 int sqlite3Fts5StorageConfigValue( |
571 Fts5Storage *p, const char*, sqlite3_value*, int | 623 Fts5Storage *p, const char*, sqlite3_value*, int |
572 ); | 624 ); |
573 | 625 |
574 int sqlite3Fts5StorageSpecialDelete(Fts5Storage *p, i64 iDel, sqlite3_value**); | |
575 | |
576 int sqlite3Fts5StorageDeleteAll(Fts5Storage *p); | 626 int sqlite3Fts5StorageDeleteAll(Fts5Storage *p); |
577 int sqlite3Fts5StorageRebuild(Fts5Storage *p); | 627 int sqlite3Fts5StorageRebuild(Fts5Storage *p); |
578 int sqlite3Fts5StorageOptimize(Fts5Storage *p); | 628 int sqlite3Fts5StorageOptimize(Fts5Storage *p); |
579 int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge); | 629 int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge); |
| 630 int sqlite3Fts5StorageReset(Fts5Storage *p); |
580 | 631 |
581 /* | 632 /* |
582 ** End of interface to code in fts5_storage.c. | 633 ** End of interface to code in fts5_storage.c. |
583 **************************************************************************/ | 634 **************************************************************************/ |
584 | 635 |
585 | 636 |
586 /************************************************************************** | 637 /************************************************************************** |
587 ** Interface to code in fts5_expr.c. | 638 ** Interface to code in fts5_expr.c. |
588 */ | 639 */ |
589 typedef struct Fts5Expr Fts5Expr; | 640 typedef struct Fts5Expr Fts5Expr; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 673 |
623 void sqlite3Fts5ExprFree(Fts5Expr*); | 674 void sqlite3Fts5ExprFree(Fts5Expr*); |
624 | 675 |
625 /* Called during startup to register a UDF with SQLite */ | 676 /* Called during startup to register a UDF with SQLite */ |
626 int sqlite3Fts5ExprInit(Fts5Global*, sqlite3*); | 677 int sqlite3Fts5ExprInit(Fts5Global*, sqlite3*); |
627 | 678 |
628 int sqlite3Fts5ExprPhraseCount(Fts5Expr*); | 679 int sqlite3Fts5ExprPhraseCount(Fts5Expr*); |
629 int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase); | 680 int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase); |
630 int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **); | 681 int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **); |
631 | 682 |
632 int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); | 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 *); |
633 | 693 |
634 /******************************************* | 694 /******************************************* |
635 ** The fts5_expr.c API above this point is used by the other hand-written | 695 ** The fts5_expr.c API above this point is used by the other hand-written |
636 ** C code in this module. The interfaces below this point are called by | 696 ** C code in this module. The interfaces below this point are called by |
637 ** the parser code in fts5parse.y. */ | 697 ** the parser code in fts5parse.y. */ |
638 | 698 |
639 void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...); | 699 void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...); |
640 | 700 |
641 Fts5ExprNode *sqlite3Fts5ParseNode( | 701 Fts5ExprNode *sqlite3Fts5ParseNode( |
642 Fts5Parse *pParse, | 702 Fts5Parse *pParse, |
643 int eType, | 703 int eType, |
644 Fts5ExprNode *pLeft, | 704 Fts5ExprNode *pLeft, |
645 Fts5ExprNode *pRight, | 705 Fts5ExprNode *pRight, |
646 Fts5ExprNearset *pNear | 706 Fts5ExprNearset *pNear |
647 ); | 707 ); |
648 | 708 |
| 709 Fts5ExprNode *sqlite3Fts5ParseImplicitAnd( |
| 710 Fts5Parse *pParse, |
| 711 Fts5ExprNode *pLeft, |
| 712 Fts5ExprNode *pRight |
| 713 ); |
| 714 |
649 Fts5ExprPhrase *sqlite3Fts5ParseTerm( | 715 Fts5ExprPhrase *sqlite3Fts5ParseTerm( |
650 Fts5Parse *pParse, | 716 Fts5Parse *pParse, |
651 Fts5ExprPhrase *pPhrase, | 717 Fts5ExprPhrase *pPhrase, |
652 Fts5Token *pToken, | 718 Fts5Token *pToken, |
653 int bPrefix | 719 int bPrefix |
654 ); | 720 ); |
655 | 721 |
656 Fts5ExprNearset *sqlite3Fts5ParseNearset( | 722 Fts5ExprNearset *sqlite3Fts5ParseNearset( |
657 Fts5Parse*, | 723 Fts5Parse*, |
658 Fts5ExprNearset*, | 724 Fts5ExprNearset*, |
659 Fts5ExprPhrase* | 725 Fts5ExprPhrase* |
660 ); | 726 ); |
661 | 727 |
662 Fts5Colset *sqlite3Fts5ParseColset( | 728 Fts5Colset *sqlite3Fts5ParseColset( |
663 Fts5Parse*, | 729 Fts5Parse*, |
664 Fts5Colset*, | 730 Fts5Colset*, |
665 Fts5Token * | 731 Fts5Token * |
666 ); | 732 ); |
667 | 733 |
668 void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*); | 734 void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*); |
669 void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*); | 735 void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*); |
670 void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); | 736 void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); |
671 | 737 |
672 void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); | 738 void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); |
673 void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); | 739 void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); |
| 740 Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); |
674 void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); | 741 void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); |
675 void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); | 742 void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); |
676 | 743 |
677 /* | 744 /* |
678 ** End of interface to code in fts5_expr.c. | 745 ** End of interface to code in fts5_expr.c. |
679 **************************************************************************/ | 746 **************************************************************************/ |
680 | 747 |
681 | 748 |
682 | 749 |
683 /************************************************************************** | 750 /************************************************************************** |
(...skipping 29 matching lines...) Expand all Loading... |
713 ** Interface to automatically generated code in fts5_unicode2.c. | 780 ** Interface to automatically generated code in fts5_unicode2.c. |
714 */ | 781 */ |
715 int sqlite3Fts5UnicodeIsalnum(int c); | 782 int sqlite3Fts5UnicodeIsalnum(int c); |
716 int sqlite3Fts5UnicodeIsdiacritic(int c); | 783 int sqlite3Fts5UnicodeIsdiacritic(int c); |
717 int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic); | 784 int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic); |
718 /* | 785 /* |
719 ** End of interface to code in fts5_unicode2.c. | 786 ** End of interface to code in fts5_unicode2.c. |
720 **************************************************************************/ | 787 **************************************************************************/ |
721 | 788 |
722 #endif | 789 #endif |
OLD | NEW |