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

Side by Side Diff: third_party/sqlite/src/ext/fts1/fulltext.c

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 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
1 /* The author disclaims copyright to this source code. 1 /* The author disclaims copyright to this source code.
2 * 2 *
3 * This is an SQLite module implementing full-text search. 3 * This is an SQLite module implementing full-text search.
4 */ 4 */
5 5
6 #include <assert.h> 6 #include <assert.h>
7 #if !defined(__APPLE__) 7 #if !defined(__APPLE__)
8 #include <malloc.h> 8 #include <malloc.h>
9 #else 9 #else
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 free(v); 845 free(v);
846 } 846 }
847 847
848 /* Current interface: 848 /* Current interface:
849 ** argv[0] - module name 849 ** argv[0] - module name
850 ** argv[1] - database name 850 ** argv[1] - database name
851 ** argv[2] - table name 851 ** argv[2] - table name
852 ** argv[3] - tokenizer name (optional, a sensible default is provided) 852 ** argv[3] - tokenizer name (optional, a sensible default is provided)
853 ** argv[4..] - passed to tokenizer (optional based on tokenizer) 853 ** argv[4..] - passed to tokenizer (optional based on tokenizer)
854 **/ 854 **/
855 static int fulltextConnect(sqlite3 *db, void *pAux, int argc, char **argv, 855 static int fulltextConnect(
856 sqlite3_vtab **ppVTab){ 856 sqlite3 *db,
857 void *pAux,
858 int argc,
859 const char * const *argv,
860 sqlite3_vtab **ppVTab,
861 char **pzErr
862 ){
857 int rc; 863 int rc;
858 fulltext_vtab *v; 864 fulltext_vtab *v;
859 sqlite3_tokenizer_module *m = NULL; 865 sqlite3_tokenizer_module *m = NULL;
860 866
861 assert( argc>=3 ); 867 assert( argc>=3 );
862 v = (fulltext_vtab *) malloc(sizeof(fulltext_vtab)); 868 v = (fulltext_vtab *) malloc(sizeof(fulltext_vtab));
863 /* sqlite will initialize v->base */ 869 /* sqlite will initialize v->base */
864 v->db = db; 870 v->db = db;
865 v->zName = string_dup(argv[2]); 871 v->zName = string_dup(argv[2]);
866 v->pTokenizer = NULL; 872 v->pTokenizer = NULL;
(...skipping 24 matching lines...) Expand all
891 897
892 rc = sqlite3_declare_vtab(db, "create table x(content text)"); 898 rc = sqlite3_declare_vtab(db, "create table x(content text)");
893 if( rc!=SQLITE_OK ) return rc; 899 if( rc!=SQLITE_OK ) return rc;
894 900
895 memset(v->pFulltextStatements, 0, sizeof(v->pFulltextStatements)); 901 memset(v->pFulltextStatements, 0, sizeof(v->pFulltextStatements));
896 902
897 *ppVTab = &v->base; 903 *ppVTab = &v->base;
898 return SQLITE_OK; 904 return SQLITE_OK;
899 } 905 }
900 906
901 static int fulltextCreate(sqlite3 *db, void *pAux, int argc, char **argv, 907 static int fulltextCreate(
902 sqlite3_vtab **ppVTab){ 908 sqlite3 *db,
909 void *pAux,
910 int argc,
911 const char * const *argv,
912 sqlite3_vtab **ppVTab,
913 char **pzErr
914 ){
903 int rc; 915 int rc;
904 assert( argc>=3 ); 916 assert( argc>=3 );
905 917
906 /* The %_content table holds the text of each full-text item, with 918 /* The %_content table holds the text of each full-text item, with
907 ** the rowid used as the docid. 919 ** the rowid used as the docid.
908 ** 920 **
909 ** The %_term table maps each term to a document list blob 921 ** The %_term table maps each term to a document list blob
910 ** containing elements sorted by ascending docid, each element 922 ** containing elements sorted by ascending docid, each element
911 ** encoded as: 923 ** encoded as:
912 ** 924 **
(...skipping 14 matching lines...) Expand all
927 ** first from that row. I _believe_ this does not matter to the 939 ** first from that row. I _believe_ this does not matter to the
928 ** operation of the system, but it might be reasonable to update 940 ** operation of the system, but it might be reasonable to update
929 ** appropriately in case this assumption becomes more important. 941 ** appropriately in case this assumption becomes more important.
930 */ 942 */
931 rc = sql_exec(db, argv[2], 943 rc = sql_exec(db, argv[2],
932 "create table %_content(content text);" 944 "create table %_content(content text);"
933 "create table %_term(term text, first integer, doclist blob);" 945 "create table %_term(term text, first integer, doclist blob);"
934 "create index %_index on %_term(term, first)"); 946 "create index %_index on %_term(term, first)");
935 if( rc!=SQLITE_OK ) return rc; 947 if( rc!=SQLITE_OK ) return rc;
936 948
937 return fulltextConnect(db, pAux, argc, argv, ppVTab); 949 return fulltextConnect(db, pAux, argc, argv, ppVTab, pzErr);
938 } 950 }
939 951
940 /* Decide how to handle an SQL query. 952 /* Decide how to handle an SQL query.
941 * At the moment, MATCH queries can include implicit boolean ANDs; we 953 * At the moment, MATCH queries can include implicit boolean ANDs; we
942 * haven't implemented phrase searches or OR yet. */ 954 * haven't implemented phrase searches or OR yet. */
943 static int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ 955 static int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
944 int i; 956 int i;
945 957
946 for(i=0; i<pInfo->nConstraint; ++i){ 958 for(i=0; i<pInfo->nConstraint; ++i){
947 const struct sqlite3_index_constraint *pConstraint; 959 const struct sqlite3_index_constraint *pConstraint;
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 fulltextColumn, 1493 fulltextColumn,
1482 fulltextRowid, 1494 fulltextRowid,
1483 fulltextUpdate 1495 fulltextUpdate
1484 }; 1496 };
1485 1497
1486 int fulltext_init(sqlite3 *db){ 1498 int fulltext_init(sqlite3 *db){
1487 return sqlite3_create_module(db, "fulltext", &fulltextModule, 0); 1499 return sqlite3_create_module(db, "fulltext", &fulltextModule, 0);
1488 } 1500 }
1489 1501
1490 #if !SQLITE_CORE 1502 #if !SQLITE_CORE
1491 int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, 1503 #ifdef _WIN32
1492 const sqlite3_api_routines *pApi){ 1504 __declspec(dllexport)
1505 #endif
1506 int sqlite3_fulltext_init(sqlite3 *db, char **pzErrMsg,
1507 const sqlite3_api_routines *pApi){
1493 SQLITE_EXTENSION_INIT2(pApi) 1508 SQLITE_EXTENSION_INIT2(pApi)
1494 return fulltext_init(db); 1509 return fulltext_init(db);
1495 } 1510 }
1496 #endif 1511 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698