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 5033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5044 | 5044 |
5045 /* loadSegmentLeaves() may not read all the way to SQLITE_DONE, thus | 5045 /* loadSegmentLeaves() may not read all the way to SQLITE_DONE, thus |
5046 ** leaving the statement handle open, which locks the table. | 5046 ** leaving the statement handle open, which locks the table. |
5047 */ | 5047 */ |
5048 /* TODO(shess) This "solution" is not satisfactory. Really, there | 5048 /* TODO(shess) This "solution" is not satisfactory. Really, there |
5049 ** should be check-in function for all statement handles which | 5049 ** should be check-in function for all statement handles which |
5050 ** arranges to call sqlite3_reset(). This most likely will require | 5050 ** arranges to call sqlite3_reset(). This most likely will require |
5051 ** modification to control flow all over the place, though, so for now | 5051 ** modification to control flow all over the place, though, so for now |
5052 ** just punt. | 5052 ** just punt. |
5053 ** | 5053 ** |
5054 ** Note the the current system assumes that segment merges will run to | 5054 ** Note the current system assumes that segment merges will run to |
5055 ** completion, which is why this particular probably hasn't arisen in | 5055 ** completion, which is why this particular probably hasn't arisen in |
5056 ** this case. Probably a brittle assumption. | 5056 ** this case. Probably a brittle assumption. |
5057 */ | 5057 */ |
5058 static int leavesReaderReset(LeavesReader *pReader){ | 5058 static int leavesReaderReset(LeavesReader *pReader){ |
5059 return sqlite3_reset(pReader->pStmt); | 5059 return sqlite3_reset(pReader->pStmt); |
5060 } | 5060 } |
5061 | 5061 |
5062 static void leavesReaderDestroy(LeavesReader *pReader){ | 5062 static void leavesReaderDestroy(LeavesReader *pReader){ |
5063 /* If idx is -1, that means we're using a non-cached statement | 5063 /* If idx is -1, that means we're using a non-cached statement |
5064 ** handle in the optimize() case, so we need to release it. | 5064 ** handle in the optimize() case, so we need to release it. |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6772 ** Function ...PorterTokenizerModule() sets *pModule to point to the | 6772 ** Function ...PorterTokenizerModule() sets *pModule to point to the |
6773 ** porter tokenizer/stemmer implementation. | 6773 ** porter tokenizer/stemmer implementation. |
6774 */ | 6774 */ |
6775 void sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule); | 6775 void sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
6776 void sqlite3Fts2PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule); | 6776 void sqlite3Fts2PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
6777 void sqlite3Fts2IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); | 6777 void sqlite3Fts2IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
6778 | 6778 |
6779 int sqlite3Fts2InitHashTable(sqlite3 *, fts2Hash *, const char *); | 6779 int sqlite3Fts2InitHashTable(sqlite3 *, fts2Hash *, const char *); |
6780 | 6780 |
6781 /* | 6781 /* |
6782 ** Initialise the fts2 extension. If this extension is built as part | 6782 ** Initialize the fts2 extension. If this extension is built as part |
6783 ** of the sqlite library, then this function is called directly by | 6783 ** of the sqlite library, then this function is called directly by |
6784 ** SQLite. If fts2 is built as a dynamically loadable extension, this | 6784 ** SQLite. If fts2 is built as a dynamically loadable extension, this |
6785 ** function is called by the sqlite3_extension_init() entry point. | 6785 ** function is called by the sqlite3_extension_init() entry point. |
6786 */ | 6786 */ |
6787 int sqlite3Fts2Init(sqlite3 *db){ | 6787 int sqlite3Fts2Init(sqlite3 *db){ |
6788 int rc = SQLITE_OK; | 6788 int rc = SQLITE_OK; |
6789 fts2Hash *pHash = 0; | 6789 fts2Hash *pHash = 0; |
6790 const sqlite3_tokenizer_module *pSimple = 0; | 6790 const sqlite3_tokenizer_module *pSimple = 0; |
6791 const sqlite3_tokenizer_module *pPorter = 0; | 6791 const sqlite3_tokenizer_module *pPorter = 0; |
6792 const sqlite3_tokenizer_module *pIcu = 0; | 6792 const sqlite3_tokenizer_module *pIcu = 0; |
6793 | 6793 |
6794 sqlite3Fts2SimpleTokenizerModule(&pSimple); | 6794 sqlite3Fts2SimpleTokenizerModule(&pSimple); |
6795 sqlite3Fts2PorterTokenizerModule(&pPorter); | 6795 sqlite3Fts2PorterTokenizerModule(&pPorter); |
6796 #ifdef SQLITE_ENABLE_ICU | 6796 #ifdef SQLITE_ENABLE_ICU |
6797 sqlite3Fts2IcuTokenizerModule(&pIcu); | 6797 sqlite3Fts2IcuTokenizerModule(&pIcu); |
6798 #endif | 6798 #endif |
6799 | 6799 |
6800 /* Allocate and initialise the hash-table used to store tokenizers. */ | 6800 /* Allocate and initialize the hash-table used to store tokenizers. */ |
6801 pHash = sqlite3_malloc(sizeof(fts2Hash)); | 6801 pHash = sqlite3_malloc(sizeof(fts2Hash)); |
6802 if( !pHash ){ | 6802 if( !pHash ){ |
6803 rc = SQLITE_NOMEM; | 6803 rc = SQLITE_NOMEM; |
6804 }else{ | 6804 }else{ |
6805 sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1); | 6805 sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1); |
6806 } | 6806 } |
6807 | 6807 |
6808 /* Load the built-in tokenizers into the hash table */ | 6808 /* Load the built-in tokenizers into the hash table */ |
6809 if( rc==SQLITE_OK ){ | 6809 if( rc==SQLITE_OK ){ |
6810 if( sqlite3Fts2HashInsert(pHash, "simple", 7, (void *)pSimple) | 6810 if( sqlite3Fts2HashInsert(pHash, "simple", 7, (void *)pSimple) |
(...skipping 26 matching lines...) Expand all Loading... |
6837 /* An error has occurred. Delete the hash table and return the error code. */ | 6837 /* An error has occurred. Delete the hash table and return the error code. */ |
6838 assert( rc!=SQLITE_OK ); | 6838 assert( rc!=SQLITE_OK ); |
6839 if( pHash ){ | 6839 if( pHash ){ |
6840 sqlite3Fts2HashClear(pHash); | 6840 sqlite3Fts2HashClear(pHash); |
6841 sqlite3_free(pHash); | 6841 sqlite3_free(pHash); |
6842 } | 6842 } |
6843 return rc; | 6843 return rc; |
6844 } | 6844 } |
6845 | 6845 |
6846 #if !SQLITE_CORE | 6846 #if !SQLITE_CORE |
6847 int sqlite3_extension_init( | 6847 #ifdef _WIN32 |
| 6848 __declspec(dllexport) |
| 6849 #endif |
| 6850 int sqlite3_fts2_init( |
6848 sqlite3 *db, | 6851 sqlite3 *db, |
6849 char **pzErrMsg, | 6852 char **pzErrMsg, |
6850 const sqlite3_api_routines *pApi | 6853 const sqlite3_api_routines *pApi |
6851 ){ | 6854 ){ |
6852 SQLITE_EXTENSION_INIT2(pApi) | 6855 SQLITE_EXTENSION_INIT2(pApi) |
6853 return sqlite3Fts2Init(db); | 6856 return sqlite3Fts2Init(db); |
6854 } | 6857 } |
6855 #endif | 6858 #endif |
6856 | 6859 |
6857 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ | 6860 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ |
OLD | NEW |