Index: third_party/sqlite/src/ext/fts5/fts5Int.h |
diff --git a/third_party/sqlite/src/ext/fts5/fts5Int.h b/third_party/sqlite/src/ext/fts5/fts5Int.h |
index 83a71723ff9b78dc5da80b911d121171d4793dc5..9ef338e8215d8a000df9430a7b9aa7dc7d5583aa 100644 |
--- a/third_party/sqlite/src/ext/fts5/fts5Int.h |
+++ b/third_party/sqlite/src/ext/fts5/fts5Int.h |
@@ -26,10 +26,11 @@ SQLITE_EXTENSION_INIT1 |
typedef unsigned char u8; |
typedef unsigned int u32; |
typedef unsigned short u16; |
+typedef short i16; |
typedef sqlite3_int64 i64; |
typedef sqlite3_uint64 u64; |
-#define ArraySize(x) (sizeof(x) / sizeof(x[0])) |
+#define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0]))) |
#define testcase(x) |
#define ALWAYS(x) 1 |
@@ -46,6 +47,10 @@ typedef sqlite3_uint64 u64; |
#endif |
+/* Truncate very long tokens to this many bytes. Hard limit is |
+** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset |
+** field that occurs at the start of each leaf page (see fts5_index.c). */ |
+#define FTS5_MAX_TOKEN_SIZE 32768 |
/* |
** Maximum number of prefix indexes on single FTS5 table. This must be |
@@ -80,6 +85,16 @@ extern int sqlite3_fts5_may_be_corrupt; |
# define assert_nc(x) assert(x) |
#endif |
+/* Mark a function parameter as unused, to suppress nuisance compiler |
+** warnings. */ |
+#ifndef UNUSED_PARAM |
+# define UNUSED_PARAM(X) (void)(X) |
+#endif |
+ |
+#ifndef UNUSED_PARAM2 |
+# define UNUSED_PARAM2(X, Y) (void)(X), (void)(Y) |
+#endif |
+ |
typedef struct Fts5Global Fts5Global; |
typedef struct Fts5Colset Fts5Colset; |
@@ -151,6 +166,7 @@ struct Fts5Config { |
char *zContent; /* content table */ |
char *zContentRowid; /* "content_rowid=" option value */ |
int bColumnsize; /* "columnsize=" option value (dflt==1) */ |
+ int eDetail; /* FTS5_DETAIL_XXX value */ |
char *zContentExprlist; |
Fts5Tokenizer *pTok; |
fts5_tokenizer *pTokApi; |
@@ -160,6 +176,7 @@ struct Fts5Config { |
int pgsz; /* Approximate page size used in %_data */ |
int nAutomerge; /* 'automerge' setting */ |
int nCrisisMerge; /* Maximum allowed segments per level */ |
+ int nUsermerge; /* 'usermerge' setting */ |
int nHashSize; /* Bytes of memory for in-memory hash */ |
char *zRank; /* Name of rank function */ |
char *zRankArgs; /* Arguments to rank function */ |
@@ -179,6 +196,9 @@ struct Fts5Config { |
#define FTS5_CONTENT_NONE 1 |
#define FTS5_CONTENT_EXTERNAL 2 |
+#define FTS5_DETAIL_FULL 0 |
+#define FTS5_DETAIL_NONE 1 |
+#define FTS5_DETAIL_COLUMNS 2 |
@@ -225,9 +245,9 @@ struct Fts5Buffer { |
int nSpace; |
}; |
-int sqlite3Fts5BufferSize(int*, Fts5Buffer*, int); |
+int sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32); |
void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); |
-void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); |
+void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*); |
void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); |
void sqlite3Fts5BufferFree(Fts5Buffer*); |
void sqlite3Fts5BufferZero(Fts5Buffer*); |
@@ -243,7 +263,7 @@ char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); |
#define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) |
#define fts5BufferGrow(pRc,pBuf,nn) ( \ |
- (pBuf)->n + (nn) <= (pBuf)->nSpace ? 0 : \ |
+ (u32)((pBuf)->n) + (u32)(nn) <= (u32)((pBuf)->nSpace) ? 0 : \ |
sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \ |
) |
@@ -278,6 +298,7 @@ struct Fts5PoslistWriter { |
i64 iPrev; |
}; |
int sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64); |
+void sqlite3Fts5PoslistSafeAppend(Fts5Buffer*, i64*, i64); |
int sqlite3Fts5PoslistNext64( |
const u8 *a, int n, /* Buffer containing poslist */ |
@@ -292,6 +313,13 @@ char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn); |
/* Character set tests (like isspace(), isalpha() etc.) */ |
int sqlite3Fts5IsBareword(char t); |
+ |
+/* Bucket of terms object used by the integrity-check in offsets=0 mode. */ |
+typedef struct Fts5Termset Fts5Termset; |
+int sqlite3Fts5TermsetNew(Fts5Termset**); |
+int sqlite3Fts5TermsetAdd(Fts5Termset*, int, const char*, int, int *pbPresent); |
+void sqlite3Fts5TermsetFree(Fts5Termset*); |
+ |
/* |
** End of interface to code in fts5_buffer.c. |
**************************************************************************/ |
@@ -304,6 +332,15 @@ int sqlite3Fts5IsBareword(char t); |
typedef struct Fts5Index Fts5Index; |
typedef struct Fts5IndexIter Fts5IndexIter; |
+struct Fts5IndexIter { |
+ i64 iRowid; |
+ const u8 *pData; |
+ int nData; |
+ u8 bEof; |
+}; |
+ |
+#define sqlite3Fts5IterEof(x) ((x)->bEof) |
+ |
/* |
** Values used as part of the flags argument passed to IndexQuery(). |
*/ |
@@ -312,6 +349,12 @@ typedef struct Fts5IndexIter Fts5IndexIter; |
#define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */ |
#define FTS5INDEX_QUERY_SCAN 0x0008 /* Scan query (fts5vocab) */ |
+/* The following are used internally by the fts5_index.c module. They are |
+** defined here only to make it easier to avoid clashes with the flags |
+** above. */ |
+#define FTS5INDEX_QUERY_SKIPEMPTY 0x0010 |
+#define FTS5INDEX_QUERY_NOOUTPUT 0x0020 |
+ |
/* |
** Create/destroy an Fts5Index object. |
*/ |
@@ -319,14 +362,27 @@ int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**); |
int sqlite3Fts5IndexClose(Fts5Index *p); |
/* |
-** for( |
-** sqlite3Fts5IndexQuery(p, "token", 5, 0, 0, &pIter); |
-** 0==sqlite3Fts5IterEof(pIter); |
-** sqlite3Fts5IterNext(pIter) |
-** ){ |
-** i64 iRowid = sqlite3Fts5IterRowid(pIter); |
-** } |
+** Return a simple checksum value based on the arguments. |
*/ |
+u64 sqlite3Fts5IndexEntryCksum( |
+ i64 iRowid, |
+ int iCol, |
+ int iPos, |
+ int iIdx, |
+ const char *pTerm, |
+ int nTerm |
+); |
+ |
+/* |
+** Argument p points to a buffer containing utf-8 text that is n bytes in |
+** size. Return the number of bytes in the nChar character prefix of the |
+** buffer, or 0 if there are less than nChar characters in total. |
+*/ |
+int sqlite3Fts5IndexCharlenToBytelen( |
+ const char *p, |
+ int nByte, |
+ int nChar |
+); |
/* |
** Open a new iterator to iterate though all rowids that match the |
@@ -344,12 +400,8 @@ int sqlite3Fts5IndexQuery( |
** The various operations on open token or token prefix iterators opened |
** using sqlite3Fts5IndexQuery(). |
*/ |
-int sqlite3Fts5IterEof(Fts5IndexIter*); |
int sqlite3Fts5IterNext(Fts5IndexIter*); |
int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch); |
-i64 sqlite3Fts5IterRowid(Fts5IndexIter*); |
-int sqlite3Fts5IterPoslist(Fts5IndexIter*,Fts5Colset*, const u8**, int*, i64*); |
-int sqlite3Fts5IterPoslistBuffer(Fts5IndexIter *pIter, Fts5Buffer *pBuf); |
/* |
** Close an iterator opened by sqlite3Fts5IndexQuery(). |
@@ -413,7 +465,6 @@ int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int); |
/* |
** Functions called by the storage module as part of integrity-check. |
*/ |
-u64 sqlite3Fts5IndexCksum(Fts5Config*,i64,int,int,const char*,int); |
int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum); |
/* |
@@ -433,6 +484,7 @@ int sqlite3Fts5IndexReads(Fts5Index *p); |
int sqlite3Fts5IndexReinit(Fts5Index *p); |
int sqlite3Fts5IndexOptimize(Fts5Index *p); |
int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge); |
+int sqlite3Fts5IndexReset(Fts5Index *p); |
int sqlite3Fts5IndexLoadConfig(Fts5Index *p); |
@@ -492,7 +544,7 @@ typedef struct Fts5Hash Fts5Hash; |
/* |
** Create a hash table, free a hash table. |
*/ |
-int sqlite3Fts5HashNew(Fts5Hash**, int *pnSize); |
+int sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize); |
void sqlite3Fts5HashFree(Fts5Hash*); |
int sqlite3Fts5HashWrite( |
@@ -551,7 +603,7 @@ int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName); |
int sqlite3Fts5DropAll(Fts5Config*); |
int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); |
-int sqlite3Fts5StorageDelete(Fts5Storage *p, i64); |
+int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**); |
int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); |
int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); |
@@ -571,12 +623,11 @@ int sqlite3Fts5StorageConfigValue( |
Fts5Storage *p, const char*, sqlite3_value*, int |
); |
-int sqlite3Fts5StorageSpecialDelete(Fts5Storage *p, i64 iDel, sqlite3_value**); |
- |
int sqlite3Fts5StorageDeleteAll(Fts5Storage *p); |
int sqlite3Fts5StorageRebuild(Fts5Storage *p); |
int sqlite3Fts5StorageOptimize(Fts5Storage *p); |
int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge); |
+int sqlite3Fts5StorageReset(Fts5Storage *p); |
/* |
** End of interface to code in fts5_storage.c. |
@@ -629,7 +680,16 @@ int sqlite3Fts5ExprPhraseCount(Fts5Expr*); |
int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase); |
int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **); |
-int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); |
+typedef struct Fts5PoslistPopulator Fts5PoslistPopulator; |
+Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int); |
+int sqlite3Fts5ExprPopulatePoslists( |
+ Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int |
+); |
+void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); |
+ |
+int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**); |
+ |
+int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *); |
/******************************************* |
** The fts5_expr.c API above this point is used by the other hand-written |
@@ -646,6 +706,12 @@ Fts5ExprNode *sqlite3Fts5ParseNode( |
Fts5ExprNearset *pNear |
); |
+Fts5ExprNode *sqlite3Fts5ParseImplicitAnd( |
+ Fts5Parse *pParse, |
+ Fts5ExprNode *pLeft, |
+ Fts5ExprNode *pRight |
+); |
+ |
Fts5ExprPhrase *sqlite3Fts5ParseTerm( |
Fts5Parse *pParse, |
Fts5ExprPhrase *pPhrase, |
@@ -671,6 +737,7 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); |
void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); |
void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); |
+Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); |
void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); |
void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); |