OLD | NEW |
1 /* fts2 has a design flaw which can lead to database corruption (see | 1 /* fts2 has a design flaw which can lead to database corruption (see |
2 ** below). It is recommended not to use it any longer, instead use | 2 ** below). It is recommended not to use it any longer, instead use |
3 ** fts3 (or higher). If you believe that your use of fts2 is safe, | 3 ** fts3 (or higher). If you believe that your use of fts2 is safe, |
4 ** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS. | 4 ** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS. |
5 */ | 5 */ |
6 #if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \ | 6 #if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \ |
7 && !defined(SQLITE_ENABLE_BROKEN_FTS2) | 7 && !defined(SQLITE_ENABLE_BROKEN_FTS2) |
8 #error fts2 has a design flaw and has been deprecated. | 8 #error fts2 has a design flaw and has been deprecated. |
9 #endif | 9 #endif |
10 /* The flaw is that fts2 uses the content table's unaliased rowid as | 10 /* The flaw is that fts2 uses the content table's unaliased rowid as |
(...skipping 5270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5281 | 5281 |
5282 /* loadSegmentLeaves() may not read all the way to SQLITE_DONE, thus | 5282 /* loadSegmentLeaves() may not read all the way to SQLITE_DONE, thus |
5283 ** leaving the statement handle open, which locks the table. | 5283 ** leaving the statement handle open, which locks the table. |
5284 */ | 5284 */ |
5285 /* TODO(shess) This "solution" is not satisfactory. Really, there | 5285 /* TODO(shess) This "solution" is not satisfactory. Really, there |
5286 ** should be check-in function for all statement handles which | 5286 ** should be check-in function for all statement handles which |
5287 ** arranges to call sqlite3_reset(). This most likely will require | 5287 ** arranges to call sqlite3_reset(). This most likely will require |
5288 ** modification to control flow all over the place, though, so for now | 5288 ** modification to control flow all over the place, though, so for now |
5289 ** just punt. | 5289 ** just punt. |
5290 ** | 5290 ** |
5291 ** Note the the current system assumes that segment merges will run to | 5291 ** Note the current system assumes that segment merges will run to |
5292 ** completion, which is why this particular probably hasn't arisen in | 5292 ** completion, which is why this particular probably hasn't arisen in |
5293 ** this case. Probably a brittle assumption. | 5293 ** this case. Probably a brittle assumption. |
5294 */ | 5294 */ |
5295 static int leavesReaderReset(LeavesReader *pReader){ | 5295 static int leavesReaderReset(LeavesReader *pReader){ |
5296 return sqlite3_reset(pReader->pStmt); | 5296 return sqlite3_reset(pReader->pStmt); |
5297 } | 5297 } |
5298 | 5298 |
5299 static void leavesReaderDestroy(LeavesReader *pReader){ | 5299 static void leavesReaderDestroy(LeavesReader *pReader){ |
5300 /* If idx is -1, that means we're using a non-cached statement | 5300 /* If idx is -1, that means we're using a non-cached statement |
5301 ** handle in the optimize() case, so we need to release it. | 5301 ** handle in the optimize() case, so we need to release it. |
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7199 ** Function ...PorterTokenizerModule() sets *pModule to point to the | 7199 ** Function ...PorterTokenizerModule() sets *pModule to point to the |
7200 ** porter tokenizer/stemmer implementation. | 7200 ** porter tokenizer/stemmer implementation. |
7201 */ | 7201 */ |
7202 void sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule); | 7202 void sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
7203 void sqlite3Fts2PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule); | 7203 void sqlite3Fts2PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
7204 void sqlite3Fts2IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); | 7204 void sqlite3Fts2IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
7205 | 7205 |
7206 int sqlite3Fts2InitHashTable(sqlite3 *, fts2Hash *, const char *); | 7206 int sqlite3Fts2InitHashTable(sqlite3 *, fts2Hash *, const char *); |
7207 | 7207 |
7208 /* | 7208 /* |
7209 ** Initialise the fts2 extension. If this extension is built as part | 7209 ** Initialize the fts2 extension. If this extension is built as part |
7210 ** of the sqlite library, then this function is called directly by | 7210 ** of the sqlite library, then this function is called directly by |
7211 ** SQLite. If fts2 is built as a dynamically loadable extension, this | 7211 ** SQLite. If fts2 is built as a dynamically loadable extension, this |
7212 ** function is called by the sqlite3_extension_init() entry point. | 7212 ** function is called by the sqlite3_extension_init() entry point. |
7213 */ | 7213 */ |
7214 int sqlite3Fts2Init(sqlite3 *db){ | 7214 int sqlite3Fts2Init(sqlite3 *db){ |
7215 int rc = SQLITE_OK; | 7215 int rc = SQLITE_OK; |
7216 fts2Hash *pHash = 0; | 7216 fts2Hash *pHash = 0; |
7217 const sqlite3_tokenizer_module *pSimple = 0; | 7217 const sqlite3_tokenizer_module *pSimple = 0; |
7218 const sqlite3_tokenizer_module *pPorter = 0; | 7218 const sqlite3_tokenizer_module *pPorter = 0; |
7219 const sqlite3_tokenizer_module *pIcu = 0; | 7219 const sqlite3_tokenizer_module *pIcu = 0; |
7220 | 7220 |
7221 sqlite3Fts2SimpleTokenizerModule(&pSimple); | 7221 sqlite3Fts2SimpleTokenizerModule(&pSimple); |
7222 sqlite3Fts2PorterTokenizerModule(&pPorter); | 7222 sqlite3Fts2PorterTokenizerModule(&pPorter); |
7223 #ifdef SQLITE_ENABLE_ICU | 7223 #ifdef SQLITE_ENABLE_ICU |
7224 sqlite3Fts2IcuTokenizerModule(&pIcu); | 7224 sqlite3Fts2IcuTokenizerModule(&pIcu); |
7225 #endif | 7225 #endif |
7226 | 7226 |
7227 /* Allocate and initialise the hash-table used to store tokenizers. */ | 7227 /* Allocate and initialize the hash-table used to store tokenizers. */ |
7228 pHash = sqlite3_malloc(sizeof(fts2Hash)); | 7228 pHash = sqlite3_malloc(sizeof(fts2Hash)); |
7229 if( !pHash ){ | 7229 if( !pHash ){ |
7230 rc = SQLITE_NOMEM; | 7230 rc = SQLITE_NOMEM; |
7231 }else{ | 7231 }else{ |
7232 sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1); | 7232 sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1); |
7233 } | 7233 } |
7234 | 7234 |
7235 /* Load the built-in tokenizers into the hash table */ | 7235 /* Load the built-in tokenizers into the hash table */ |
7236 if( rc==SQLITE_OK ){ | 7236 if( rc==SQLITE_OK ){ |
7237 if( sqlite3Fts2HashInsert(pHash, "simple", 7, (void *)pSimple) | 7237 if( sqlite3Fts2HashInsert(pHash, "simple", 7, (void *)pSimple) |
(...skipping 30 matching lines...) Expand all Loading... |
7268 /* An error has occurred. Delete the hash table and return the error code. */ | 7268 /* An error has occurred. Delete the hash table and return the error code. */ |
7269 assert( rc!=SQLITE_OK ); | 7269 assert( rc!=SQLITE_OK ); |
7270 if( pHash ){ | 7270 if( pHash ){ |
7271 sqlite3Fts2HashClear(pHash); | 7271 sqlite3Fts2HashClear(pHash); |
7272 sqlite3_free(pHash); | 7272 sqlite3_free(pHash); |
7273 } | 7273 } |
7274 return rc; | 7274 return rc; |
7275 } | 7275 } |
7276 | 7276 |
7277 #if !SQLITE_CORE | 7277 #if !SQLITE_CORE |
7278 int sqlite3_extension_init( | 7278 #ifdef _WIN32 |
| 7279 __declspec(dllexport) |
| 7280 #endif |
| 7281 int sqlite3_fts2_init( |
7279 sqlite3 *db, | 7282 sqlite3 *db, |
7280 char **pzErrMsg, | 7283 char **pzErrMsg, |
7281 const sqlite3_api_routines *pApi | 7284 const sqlite3_api_routines *pApi |
7282 ){ | 7285 ){ |
7283 SQLITE_EXTENSION_INIT2(pApi) | 7286 SQLITE_EXTENSION_INIT2(pApi) |
7284 return sqlite3Fts2Init(db); | 7287 return sqlite3Fts2Init(db); |
7285 } | 7288 } |
7286 #endif | 7289 #endif |
7287 | 7290 |
7288 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ | 7291 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ |
OLD | NEW |