From ed52f9ff488acfc66fdd3155fbe8b395f1330d49 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 26 Jun 2015 04:34:36 +0000 Subject: [PATCH] Initial changes to get FTS5 working with MSVC. FossilOrigin-Name: ef2052f81e33ca98e85a60f8a78cdd19a7c1c35c --- Makefile.msc | 41 +++++++++++++++++++++++++++++++++++++++++ ext/fts5/fts5Int.h | 2 +- ext/fts5/fts5_buffer.c | 2 +- ext/fts5/fts5_config.c | 1 - ext/fts5/fts5_expr.c | 4 ++-- ext/fts5/fts5_index.c | 10 +++++----- ext/fts5/fts5_main.c | 4 ++-- ext/fts5/fts5_storage.c | 4 +++- manifest | 31 +++++++++++++++++-------------- manifest.uuid | 2 +- 10 files changed, 73 insertions(+), 28 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 70c16b11c3..0582459b06 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -827,6 +827,7 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \ fts3.lo fts3_aux.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo \ fts3_porter.lo fts3_snippet.lo fts3_tokenizer.lo fts3_tokenizer1.lo \ fts3_tokenize_vtab.lo fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \ + fts5.lo \ func.lo global.lo hash.lo \ icu.lo insert.lo journal.lo legacy.lo loadext.lo \ main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \ @@ -1078,6 +1079,7 @@ TESTEXT = \ $(TOP)\ext\misc\eval.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\fuzzer.c \ + $(TOP)\ext\fts5\fts5_tcl.c \ $(TOP)\ext\misc\ieee754.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\percentile.c \ @@ -1653,6 +1655,44 @@ fts3_write.lo: $(TOP)\ext\fts3\fts3_write.c $(HDR) $(EXTHDR) rtree.lo: $(TOP)\ext\rtree\rtree.c $(HDR) $(EXTHDR) $(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c $(TOP)\ext\rtree\rtree.c +# FTS5 things +# +FTS5_SRC = \ + $(TOP)\ext\fts5\fts5.h \ + $(TOP)\ext\fts5\fts5Int.h \ + $(TOP)\ext\fts5\fts5_aux.c \ + $(TOP)\ext\fts5\fts5_buffer.c \ + $(TOP)\ext\fts5\fts5_main.c \ + $(TOP)\ext\fts5\fts5_config.c \ + $(TOP)\ext\fts5\fts5_expr.c \ + $(TOP)\ext\fts5\fts5_hash.c \ + $(TOP)\ext\fts5\fts5_index.c \ + fts5parse.c fts5parse.h \ + $(TOP)\ext\fts5\fts5_storage.c \ + $(TOP)\ext\fts5\fts5_tokenize.c \ + $(TOP)\ext\fts5\fts5_unicode2.c \ + $(TOP)\ext\fts5\fts5_varint.c \ + $(TOP)\ext\fts5\fts5_vocab.c + +fts5parse.c: $(TOP)\ext\fts5\fts5parse.y lemon.exe + copy $(TOP)\ext\fts5\fts5parse.y . + del /Q fts5parse.h 2>NUL + .\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) fts5parse.y + move fts5parse.c fts5parse.c.orig + echo #ifdef SQLITE_ENABLE_FTS5 > $@ + type fts5parse.c.orig \ + | $(NAWK) "/.*/ { gsub(/yy/,\"fts5yy\");print }" \ + | $(NAWK) "/.*/ { gsub(/YY/,\"fts5YY\");print }" \ + | $(NAWK) "/.*/ { gsub(/TOKEN/,\"FTS5TOKEN\");print }" >> $@ + echo #endif /* SQLITE_ENABLE_FTS5 */ >> $@ + +fts5parse.h: fts5parse.c + +fts5.c: $(FTS5_SRC) + $(TCLSH_CMD) $(TOP)\ext\fts5\tool\mkfts5c.tcl + +fts5.lo: fts5.c $(HDR) $(EXTHDR) + $(LTCOMPILE) $(NO_WARN) -DSQLITE_ENABLE_FTS5 -c fts5.c # Rules to build the 'testfixture' application. # @@ -1792,6 +1832,7 @@ clean: del /Q sqlite3_analyzer.exe sqlite3_analyzer.c 2>NUL del /Q sqlite-*-output.vsix 2>NUL del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe 2>NUL + del /Q fts5.c fts5parse.* 2>NUL # Dynamic link library section. # diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 07d1e4fecb..7b8066ef34 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -204,7 +204,7 @@ void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); void sqlite3Fts5BufferAppend32(int*, Fts5Buffer*, int); -char *sqlite3Fts5Mprintf(int *pRc, char *zFmt, ...); +char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); #define fts5BufferZero(x) sqlite3Fts5BufferZero(x) #define fts5BufferGrow(a,b,c) sqlite3Fts5BufferGrow(a,b,c) diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index b900ada744..33e648a931 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -125,7 +125,7 @@ void sqlite3Fts5BufferAppendPrintf( } } -char *sqlite3Fts5Mprintf(int *pRc, char *zFmt, ...){ +char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...){ char *zRet = 0; if( *pRc==SQLITE_OK ){ va_list ap; diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 4c478d79c9..6342b92cb0 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -602,7 +602,6 @@ int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig){ int i; int rc = SQLITE_OK; char *zSql; - char *zOld; zSql = sqlite3Fts5Mprintf(&rc, "CREATE TABLE x("); for(i=0; zSql && inCol; i++){ diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 9707e517aa..b29684561c 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1046,7 +1046,7 @@ static int fts5ExprNodeNext( case FTS5_OR: { int i; - int iLast = pNode->iRowid; + i64 iLast = pNode->iRowid; for(i=0; rc==SQLITE_OK && inChild; i++){ Fts5ExprNode *p1 = pNode->apChild[i]; @@ -1915,7 +1915,7 @@ static void fts5ExprFunction( sqlite3_result_error_code(pCtx, rc); } } - sqlite3_free(azConfig); + sqlite3_free((void *)azConfig); sqlite3Fts5ConfigFree(pConfig); sqlite3Fts5ExprFree(pExpr); } diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index ec930f1a3b..c5516db07c 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -3549,15 +3549,15 @@ static void fts5IndexAutomerge( ){ if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){ Fts5Structure *pStruct = *ppStruct; - i64 nWrite; /* Initial value of write-counter */ + u64 nWrite; /* Initial value of write-counter */ int nWork; /* Number of work-quanta to perform */ int nRem; /* Number of leaf pages left to write */ /* Update the write-counter. While doing so, set nWork. */ nWrite = pStruct->nWriteCounter; - nWork = ((nWrite + nLeaf) / p->nWorkUnit) - (nWrite / p->nWorkUnit); + nWork = (int)(((nWrite + nLeaf) / p->nWorkUnit) - (nWrite / p->nWorkUnit)); pStruct->nWriteCounter += nLeaf; - nRem = p->nWorkUnit * nWork * pStruct->nLevel; + nRem = (int)(p->nWorkUnit * nWork * pStruct->nLevel); fts5IndexMerge(p, ppStruct, nRem); } @@ -4552,11 +4552,11 @@ int sqlite3Fts5IndexSetCookie(Fts5Index *p, int iNew){ int rc; /* Return code */ Fts5Config *pConfig = p->pConfig; /* Configuration object */ u8 aCookie[4]; /* Binary representation of iNew */ + sqlite3_blob *pBlob = 0; assert( p->rc==SQLITE_OK ); - sqlite3Fts5Put32(aCookie, iNew); - sqlite3_blob *pBlob = 0; + rc = sqlite3_blob_open(pConfig->db, pConfig->zDb, p->zDataTbl, "block", FTS5_STRUCTURE_ROWID, 1, &pBlob ); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 3b8241f132..a598f1cfce 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1387,8 +1387,8 @@ static int fts5UpdateMethod( rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel); } }else{ - assert( nArg>1 ); sqlite3_value *pCmd = apVal[2 + pConfig->nCol]; + assert( nArg>1 ); if( SQLITE_NULL!=sqlite3_value_type(pCmd) ){ const char *z = (const char*)sqlite3_value_text(pCmd); if( pConfig->eContent!=FTS5_CONTENT_NORMAL @@ -2224,7 +2224,7 @@ static void fts5Fts5Func( sqlite3_result_blob(pCtx, buf, sizeof(pGlobal), SQLITE_TRANSIENT); } -#ifdef _WIN32_ +#ifdef _WIN32 __declspec(dllexport) #endif int sqlite3_fts5_init( diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 60c6401716..f57c2e2620 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -158,8 +158,10 @@ static int fts5ExecPrintf( ){ int rc; va_list ap; /* ... printf arguments */ + char *zSql; + va_start(ap, zFormat); - char *zSql = sqlite3_vmprintf(zFormat, ap); + zSql = sqlite3_vmprintf(zFormat, ap); if( zSql==0 ){ rc = SQLITE_NOMEM; diff --git a/manifest b/manifest index 81ca8a12d1..27528f47eb 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sMakefile.in\sto\saccount\sfor\srecent\schanges.\sUpdate\sfts5\stest\sscripts\sso\sthat\sthey\sdo\snot\srun\sif\sSQLITE_ENABLE_FTS5\sis\snot\sdefined. -D 2015-06-25T20:36:36.724 +C Initial\schanges\sto\sget\sFTS5\sworking\swith\sMSVC. +D 2015-06-26T04:34:36.916 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc b7db9ccbbad1c495b98e5326a06cac03aa206127 +F Makefile.msc 3ba6a2d04472e98b2aa882f47d959ec12af7c34c F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION ce0ae95abd7121c534f6917c1c8f2b70d9acd4db @@ -106,15 +106,15 @@ F ext/fts3/unicode/mkunicode.tcl ed0534dd51efce39878bce33944c6073d37a1e20 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl 55a6d648d516f35d9a1e580ac00de27154e1904a F ext/fts5/fts5.h 81d1a92fc2b4bd477af7e4e0b38b456f3e199fba -F ext/fts5/fts5Int.h 41e9ed1f073770f660b1b59116357f504a8c5ff1 +F ext/fts5/fts5Int.h 918e947c0c20122ed5eb9ea695d83c6c8cf7239a F ext/fts5/fts5_aux.c d53f00f31ad615ca4f139dd8751f9041afa00971 -F ext/fts5/fts5_buffer.c be0dc80a9406151b350be27c7ec2956722578771 -F ext/fts5/fts5_config.c c232d181d6324f0ae3a2a31319924473999e5816 -F ext/fts5/fts5_expr.c 549bda1f7edcf10365fbfbc002bdea1be3c287bb +F ext/fts5/fts5_buffer.c 7428b0bcb257641cbecc3bacce7f40686cf99f36 +F ext/fts5/fts5_config.c d40da53f5e94214c553b2af3d6fd9aebac5f3f05 +F ext/fts5/fts5_expr.c 3386ab0a71dbab7e1259c3b16d6113c97d14123e F ext/fts5/fts5_hash.c c1cfdb2cae0fad00b06fae38a40eaf9261563ccc -F ext/fts5/fts5_index.c 438b245e9e44be3cfa848c71351a4e769b75876a -F ext/fts5/fts5_main.c 35e90d3d8fafe4c936f232108e891d5f9a6294ca -F ext/fts5/fts5_storage.c b2fa301fce865d582d367a5e1bb438fe60c03cb5 +F ext/fts5/fts5_index.c 11dbb41cd9f1acbf6beb5c959b913e1be91dabc4 +F ext/fts5/fts5_main.c c5b2a219d65967c07fd1bc8fd45206863a2fe360 +F ext/fts5/fts5_storage.c 3e672a0d35f63979556903861b324e7b8932cecc F ext/fts5/fts5_tcl.c 7ea165878e4ae3598e89acd470a0ee1b5a00e33c F ext/fts5/fts5_tokenize.c 97251d68d7a6a9415bde1203f9382864dfc1f989 F ext/fts5/fts5_unicode2.c da3cf712f05cd8347c8c5bc00964cc0361c88da9 @@ -1364,7 +1364,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fcd8f7ce601729dc51d880d16b97040c1be16aa2 -R d44c4485fa78076f45f58b5b04b05b9b -U dan -Z cdc9c7cdbdc63c34e596c23a4d9ea399 +P 3175220747f5d4dadd17e09fb1899dc782c90926 +R d72f4db2847a4a23ecfc8905fb081d41 +T *branch * fts5Msvc +T *sym-fts5Msvc * +T -sym-fts5 * +U mistachkin +Z cca0d5b27b94cebaae71758fdb2c5cae diff --git a/manifest.uuid b/manifest.uuid index 70e4e52c4d..f3b9d6f26c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3175220747f5d4dadd17e09fb1899dc782c90926 \ No newline at end of file +ef2052f81e33ca98e85a60f8a78cdd19a7c1c35c \ No newline at end of file