Fossil SCM

Update the built-in SQLite to the first 3.11.0 release candidate.

drh 2016-02-12 15:16 trunk
Commit b23be81fa6a06f9062be2d919a38bc522b00001f
3 files changed +1 -1 +306 -187 +1 -1
+1 -1
--- src/shell.c
+++ src/shell.c
@@ -910,11 +910,11 @@
910910
showHdr = p->showHeader;
911911
rowSep = p->rowSeparator;
912912
}else{
913913
colWidth = aExplainWidths;
914914
showHdr = 1;
915
- rowSep = "\n";
915
+ rowSep = SEP_Row;
916916
}
917917
if( p->cnt++==0 ){
918918
for(i=0; i<nArg; i++){
919919
int w, n;
920920
if( i<ArraySize(p->colWidth) ){
921921
--- src/shell.c
+++ src/shell.c
@@ -910,11 +910,11 @@
910 showHdr = p->showHeader;
911 rowSep = p->rowSeparator;
912 }else{
913 colWidth = aExplainWidths;
914 showHdr = 1;
915 rowSep = "\n";
916 }
917 if( p->cnt++==0 ){
918 for(i=0; i<nArg; i++){
919 int w, n;
920 if( i<ArraySize(p->colWidth) ){
921
--- src/shell.c
+++ src/shell.c
@@ -910,11 +910,11 @@
910 showHdr = p->showHeader;
911 rowSep = p->rowSeparator;
912 }else{
913 colWidth = aExplainWidths;
914 showHdr = 1;
915 rowSep = SEP_Row;
916 }
917 if( p->cnt++==0 ){
918 for(i=0; i<nArg; i++){
919 int w, n;
920 if( i<ArraySize(p->colWidth) ){
921
+306 -187
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -328,11 +328,11 @@
328328
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
329329
** [sqlite_version()] and [sqlite_source_id()].
330330
*/
331331
#define SQLITE_VERSION "3.11.0"
332332
#define SQLITE_VERSION_NUMBER 3011000
333
-#define SQLITE_SOURCE_ID "2016-02-09 20:11:14 751915cb7e4981661a40dc5e4d029ab27434c2d9"
333
+#define SQLITE_SOURCE_ID "2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc"
334334
335335
/*
336336
** CAPI3REF: Run-Time Library Version Numbers
337337
** KEYWORDS: sqlite3_version, sqlite3_sourceid
338338
**
@@ -13987,10 +13987,11 @@
1398713987
int n; /* A counter */
1398813988
int iCur; /* A cursor number */
1398913989
SrcList *pSrcList; /* FROM clause */
1399013990
struct SrcCount *pSrcCount; /* Counting column references */
1399113991
struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
13992
+ int *aiCol; /* array of column indexes */
1399213993
} u;
1399313994
};
1399413995
1399513996
/* Forward declarations */
1399613997
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -14056,10 +14057,17 @@
1405614057
SQLITE_PRIVATE int sqlite3CantopenError(int);
1405714058
#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
1405814059
#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
1405914060
#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
1406014061
14062
+/*
14063
+** FTS3 and FTS4 both require virtual table support
14064
+*/
14065
+#if defined(SQLITE_OMIT_VIRTUALTABLE)
14066
+# undef SQLITE_ENABLE_FTS3
14067
+# undef SQLITE_ENABLE_FTS4
14068
+#endif
1406114069
1406214070
/*
1406314071
** FTS4 is really an extension for FTS3. It is enabled using the
1406414072
** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call
1406514073
** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
@@ -14432,11 +14440,11 @@
1443214440
Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
1443314441
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
1443414442
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
1443514443
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
1443614444
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
14437
- u8,u8,int,int*);
14445
+ u8,u8,int,int*,int*);
1443814446
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
1443914447
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
1444014448
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
1444114449
SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
1444214450
SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
@@ -17745,18 +17753,40 @@
1774517753
*/
1774617754
#define _SQLITE_OS_C_ 1
1774717755
/* #include "sqliteInt.h" */
1774817756
#undef _SQLITE_OS_C_
1774917757
17758
+/*
17759
+** If we compile with the SQLITE_TEST macro set, then the following block
17760
+** of code will give us the ability to simulate a disk I/O error. This
17761
+** is used for testing the I/O recovery logic.
17762
+*/
17763
+#if defined(SQLITE_TEST)
17764
+SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
17765
+SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
17766
+SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
17767
+SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
17768
+SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
17769
+SQLITE_API int sqlite3_diskfull_pending = 0;
17770
+SQLITE_API int sqlite3_diskfull = 0;
17771
+#endif /* defined(SQLITE_TEST) */
17772
+
17773
+/*
17774
+** When testing, also keep a count of the number of open files.
17775
+*/
17776
+#if defined(SQLITE_TEST)
17777
+SQLITE_API int sqlite3_open_file_count = 0;
17778
+#endif /* defined(SQLITE_TEST) */
17779
+
1775017780
/*
1775117781
** The default SQLite sqlite3_vfs implementations do not allocate
1775217782
** memory (actually, os_unix.c allocates a small amount of memory
1775317783
** from within OsOpen()), but some third-party implementations may.
1775417784
** So we test the effects of a malloc() failing and the sqlite3OsXXX()
1775517785
** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.
1775617786
**
17757
-** The following functions are instrumented for malloc() failure
17787
+** The following functions are instrumented for malloc() failure
1775817788
** testing:
1775917789
**
1776017790
** sqlite3OsRead()
1776117791
** sqlite3OsWrite()
1776217792
** sqlite3OsSync()
@@ -17838,12 +17868,12 @@
1783817868
*/
1783917869
SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
1784017870
#ifdef SQLITE_TEST
1784117871
if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){
1784217872
/* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite
17843
- ** is using a regular VFS, it is called after the corresponding
17844
- ** transaction has been committed. Injecting a fault at this point
17873
+ ** is using a regular VFS, it is called after the corresponding
17874
+ ** transaction has been committed. Injecting a fault at this point
1784517875
** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM
1784617876
** but the transaction is committed anyway.
1784717877
**
1784817878
** The core must call OsFileControl() though, not OsFileControlHint(),
1784917879
** as if a custom VFS (e.g. zipvfs) returns an error here, it probably
@@ -17908,14 +17938,14 @@
1790817938
/*
1790917939
** The next group of routines are convenience wrappers around the
1791017940
** VFS methods.
1791117941
*/
1791217942
SQLITE_PRIVATE int sqlite3OsOpen(
17913
- sqlite3_vfs *pVfs,
17914
- const char *zPath,
17915
- sqlite3_file *pFile,
17916
- int flags,
17943
+ sqlite3_vfs *pVfs,
17944
+ const char *zPath,
17945
+ sqlite3_file *pFile,
17946
+ int flags,
1791717947
int *pFlagsOut
1791817948
){
1791917949
int rc;
1792017950
DO_OS_MALLOC_TEST(0);
1792117951
/* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
@@ -17930,22 +17960,22 @@
1793017960
DO_OS_MALLOC_TEST(0);
1793117961
assert( dirSync==0 || dirSync==1 );
1793217962
return pVfs->xDelete(pVfs, zPath, dirSync);
1793317963
}
1793417964
SQLITE_PRIVATE int sqlite3OsAccess(
17935
- sqlite3_vfs *pVfs,
17936
- const char *zPath,
17937
- int flags,
17965
+ sqlite3_vfs *pVfs,
17966
+ const char *zPath,
17967
+ int flags,
1793817968
int *pResOut
1793917969
){
1794017970
DO_OS_MALLOC_TEST(0);
1794117971
return pVfs->xAccess(pVfs, zPath, flags, pResOut);
1794217972
}
1794317973
SQLITE_PRIVATE int sqlite3OsFullPathname(
17944
- sqlite3_vfs *pVfs,
17945
- const char *zPath,
17946
- int nPathOut,
17974
+ sqlite3_vfs *pVfs,
17975
+ const char *zPath,
17976
+ int nPathOut,
1794717977
char *zPathOut
1794817978
){
1794917979
DO_OS_MALLOC_TEST(0);
1795017980
zPathOut[0] = 0;
1795117981
return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
@@ -17987,13 +18017,13 @@
1798718017
}
1798818018
return rc;
1798918019
}
1799018020
1799118021
SQLITE_PRIVATE int sqlite3OsOpenMalloc(
17992
- sqlite3_vfs *pVfs,
17993
- const char *zFile,
17994
- sqlite3_file **ppFile,
18022
+ sqlite3_vfs *pVfs,
18023
+ const char *zFile,
18024
+ sqlite3_file **ppFile,
1799518025
int flags,
1799618026
int *pOutFlags
1799718027
){
1799818028
int rc = SQLITE_NOMEM;
1799918029
sqlite3_file *pFile;
@@ -21212,12 +21242,12 @@
2121221242
** Macros for performance tracing. Normally turned off. Only works
2121321243
** on i486 hardware.
2121421244
*/
2121521245
#ifdef SQLITE_PERFORMANCE_TRACE
2121621246
21217
-/*
21218
-** hwtime.h contains inline assembler code for implementing
21247
+/*
21248
+** hwtime.h contains inline assembler code for implementing
2121921249
** high-performance timing routines.
2122021250
*/
2122121251
/************** Include hwtime.h in the middle of os_common.h ****************/
2122221252
/************** Begin file hwtime.h ******************************************/
2122321253
/*
@@ -21323,18 +21353,18 @@
2132321353
/*
2132421354
** If we compile with the SQLITE_TEST macro set, then the following block
2132521355
** of code will give us the ability to simulate a disk I/O error. This
2132621356
** is used for testing the I/O recovery logic.
2132721357
*/
21328
-#ifdef SQLITE_TEST
21329
-SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
21330
-SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
21331
-SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
21332
-SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
21333
-SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
21334
-SQLITE_API int sqlite3_diskfull_pending = 0;
21335
-SQLITE_API int sqlite3_diskfull = 0;
21358
+#if defined(SQLITE_TEST)
21359
+SQLITE_API extern int sqlite3_io_error_hit;
21360
+SQLITE_API extern int sqlite3_io_error_hardhit;
21361
+SQLITE_API extern int sqlite3_io_error_pending;
21362
+SQLITE_API extern int sqlite3_io_error_persist;
21363
+SQLITE_API extern int sqlite3_io_error_benign;
21364
+SQLITE_API extern int sqlite3_diskfull_pending;
21365
+SQLITE_API extern int sqlite3_diskfull;
2133621366
#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
2133721367
#define SimulateIOError(CODE) \
2133821368
if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
2133921369
|| sqlite3_io_error_pending-- == 1 ) \
2134021370
{ local_ioerr(); CODE; }
@@ -21356,21 +21386,21 @@
2135621386
}
2135721387
#else
2135821388
#define SimulateIOErrorBenign(X)
2135921389
#define SimulateIOError(A)
2136021390
#define SimulateDiskfullError(A)
21361
-#endif
21391
+#endif /* defined(SQLITE_TEST) */
2136221392
2136321393
/*
2136421394
** When testing, keep a count of the number of open files.
2136521395
*/
21366
-#ifdef SQLITE_TEST
21367
-SQLITE_API int sqlite3_open_file_count = 0;
21396
+#if defined(SQLITE_TEST)
21397
+SQLITE_API extern int sqlite3_open_file_count;
2136821398
#define OpenCounter(X) sqlite3_open_file_count+=(X)
2136921399
#else
2137021400
#define OpenCounter(X)
21371
-#endif
21401
+#endif /* defined(SQLITE_TEST) */
2137221402
2137321403
#endif /* !defined(_OS_COMMON_H_) */
2137421404
2137521405
/************** End of os_common.h *******************************************/
2137621406
/************** Continuing where we left off in mutex_w32.c ******************/
@@ -27373,12 +27403,12 @@
2737327403
** Macros for performance tracing. Normally turned off. Only works
2737427404
** on i486 hardware.
2737527405
*/
2737627406
#ifdef SQLITE_PERFORMANCE_TRACE
2737727407
27378
-/*
27379
-** hwtime.h contains inline assembler code for implementing
27408
+/*
27409
+** hwtime.h contains inline assembler code for implementing
2738027410
** high-performance timing routines.
2738127411
*/
2738227412
/************** Include hwtime.h in the middle of os_common.h ****************/
2738327413
/************** Begin file hwtime.h ******************************************/
2738427414
/*
@@ -27484,18 +27514,18 @@
2748427514
/*
2748527515
** If we compile with the SQLITE_TEST macro set, then the following block
2748627516
** of code will give us the ability to simulate a disk I/O error. This
2748727517
** is used for testing the I/O recovery logic.
2748827518
*/
27489
-#ifdef SQLITE_TEST
27490
-SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
27491
-SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
27492
-SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
27493
-SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
27494
-SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
27495
-SQLITE_API int sqlite3_diskfull_pending = 0;
27496
-SQLITE_API int sqlite3_diskfull = 0;
27519
+#if defined(SQLITE_TEST)
27520
+SQLITE_API extern int sqlite3_io_error_hit;
27521
+SQLITE_API extern int sqlite3_io_error_hardhit;
27522
+SQLITE_API extern int sqlite3_io_error_pending;
27523
+SQLITE_API extern int sqlite3_io_error_persist;
27524
+SQLITE_API extern int sqlite3_io_error_benign;
27525
+SQLITE_API extern int sqlite3_diskfull_pending;
27526
+SQLITE_API extern int sqlite3_diskfull;
2749727527
#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
2749827528
#define SimulateIOError(CODE) \
2749927529
if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
2750027530
|| sqlite3_io_error_pending-- == 1 ) \
2750127531
{ local_ioerr(); CODE; }
@@ -27517,21 +27547,21 @@
2751727547
}
2751827548
#else
2751927549
#define SimulateIOErrorBenign(X)
2752027550
#define SimulateIOError(A)
2752127551
#define SimulateDiskfullError(A)
27522
-#endif
27552
+#endif /* defined(SQLITE_TEST) */
2752327553
2752427554
/*
2752527555
** When testing, keep a count of the number of open files.
2752627556
*/
27527
-#ifdef SQLITE_TEST
27528
-SQLITE_API int sqlite3_open_file_count = 0;
27557
+#if defined(SQLITE_TEST)
27558
+SQLITE_API extern int sqlite3_open_file_count;
2752927559
#define OpenCounter(X) sqlite3_open_file_count+=(X)
2753027560
#else
2753127561
#define OpenCounter(X)
27532
-#endif
27562
+#endif /* defined(SQLITE_TEST) */
2753327563
2753427564
#endif /* !defined(_OS_COMMON_H_) */
2753527565
2753627566
/************** End of os_common.h *******************************************/
2753727567
/************** Continuing where we left off in os_unix.c ********************/
@@ -34896,12 +34926,12 @@
3489634926
** Macros for performance tracing. Normally turned off. Only works
3489734927
** on i486 hardware.
3489834928
*/
3489934929
#ifdef SQLITE_PERFORMANCE_TRACE
3490034930
34901
-/*
34902
-** hwtime.h contains inline assembler code for implementing
34931
+/*
34932
+** hwtime.h contains inline assembler code for implementing
3490334933
** high-performance timing routines.
3490434934
*/
3490534935
/************** Include hwtime.h in the middle of os_common.h ****************/
3490634936
/************** Begin file hwtime.h ******************************************/
3490734937
/*
@@ -35007,18 +35037,18 @@
3500735037
/*
3500835038
** If we compile with the SQLITE_TEST macro set, then the following block
3500935039
** of code will give us the ability to simulate a disk I/O error. This
3501035040
** is used for testing the I/O recovery logic.
3501135041
*/
35012
-#ifdef SQLITE_TEST
35013
-SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
35014
-SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
35015
-SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
35016
-SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
35017
-SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
35018
-SQLITE_API int sqlite3_diskfull_pending = 0;
35019
-SQLITE_API int sqlite3_diskfull = 0;
35042
+#if defined(SQLITE_TEST)
35043
+SQLITE_API extern int sqlite3_io_error_hit;
35044
+SQLITE_API extern int sqlite3_io_error_hardhit;
35045
+SQLITE_API extern int sqlite3_io_error_pending;
35046
+SQLITE_API extern int sqlite3_io_error_persist;
35047
+SQLITE_API extern int sqlite3_io_error_benign;
35048
+SQLITE_API extern int sqlite3_diskfull_pending;
35049
+SQLITE_API extern int sqlite3_diskfull;
3502035050
#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
3502135051
#define SimulateIOError(CODE) \
3502235052
if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
3502335053
|| sqlite3_io_error_pending-- == 1 ) \
3502435054
{ local_ioerr(); CODE; }
@@ -35040,21 +35070,21 @@
3504035070
}
3504135071
#else
3504235072
#define SimulateIOErrorBenign(X)
3504335073
#define SimulateIOError(A)
3504435074
#define SimulateDiskfullError(A)
35045
-#endif
35075
+#endif /* defined(SQLITE_TEST) */
3504635076
3504735077
/*
3504835078
** When testing, keep a count of the number of open files.
3504935079
*/
35050
-#ifdef SQLITE_TEST
35051
-SQLITE_API int sqlite3_open_file_count = 0;
35080
+#if defined(SQLITE_TEST)
35081
+SQLITE_API extern int sqlite3_open_file_count;
3505235082
#define OpenCounter(X) sqlite3_open_file_count+=(X)
3505335083
#else
3505435084
#define OpenCounter(X)
35055
-#endif
35085
+#endif /* defined(SQLITE_TEST) */
3505635086
3505735087
#endif /* !defined(_OS_COMMON_H_) */
3505835088
3505935089
/************** End of os_common.h *******************************************/
3506035090
/************** Continuing where we left off in os_win.c *********************/
@@ -104247,11 +104277,11 @@
104247104277
}else
104248104278
#endif
104249104279
{
104250104280
int isReplace; /* Set to true if constraints may cause a replace */
104251104281
sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
104252
- regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace
104282
+ regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0
104253104283
);
104254104284
sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);
104255104285
sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,
104256104286
regIns, aRegIdx, 0, appendFlag, isReplace==0);
104257104287
}
@@ -104328,10 +104358,63 @@
104328104358
#undef pTrigger
104329104359
#endif
104330104360
#ifdef tmask
104331104361
#undef tmask
104332104362
#endif
104363
+
104364
+/*
104365
+** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged()
104366
+*/
104367
+#define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */
104368
+#define CKCNSTRNT_ROWID 0x02 /* CHECK constraint references the ROWID */
104369
+
104370
+/* This is the Walker callback from checkConstraintUnchanged(). Set
104371
+** bit 0x01 of pWalker->eCode if
104372
+** pWalker->eCode to 0 if this expression node references any of the
104373
+** columns that are being modifed by an UPDATE statement.
104374
+*/
104375
+static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){
104376
+ if( pExpr->op==TK_COLUMN ){
104377
+ assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );
104378
+ if( pExpr->iColumn>=0 ){
104379
+ if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){
104380
+ pWalker->eCode |= CKCNSTRNT_COLUMN;
104381
+ }
104382
+ }else{
104383
+ pWalker->eCode |= CKCNSTRNT_ROWID;
104384
+ }
104385
+ }
104386
+ return WRC_Continue;
104387
+}
104388
+
104389
+/*
104390
+** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The
104391
+** only columns that are modified by the UPDATE are those for which
104392
+** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.
104393
+**
104394
+** Return true if CHECK constraint pExpr does not use any of the
104395
+** changing columns (or the rowid if it is changing). In other words,
104396
+** return true if this CHECK constraint can be skipped when validating
104397
+** the new row in the UPDATE statement.
104398
+*/
104399
+static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
104400
+ Walker w;
104401
+ memset(&w, 0, sizeof(w));
104402
+ w.eCode = 0;
104403
+ w.xExprCallback = checkConstraintExprNode;
104404
+ w.u.aiCol = aiChng;
104405
+ sqlite3WalkExpr(&w, pExpr);
104406
+ if( !chngRowid ){
104407
+ testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 );
104408
+ w.eCode &= ~CKCNSTRNT_ROWID;
104409
+ }
104410
+ testcase( w.eCode==0 );
104411
+ testcase( w.eCode==CKCNSTRNT_COLUMN );
104412
+ testcase( w.eCode==CKCNSTRNT_ROWID );
104413
+ testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
104414
+ return !w.eCode;
104415
+}
104333104416
104334104417
/*
104335104418
** Generate code to do constraint checks prior to an INSERT or an UPDATE
104336104419
** on table pTab.
104337104420
**
@@ -104423,11 +104506,12 @@
104423104506
int regNewData, /* First register in a range holding values to insert */
104424104507
int regOldData, /* Previous content. 0 for INSERTs */
104425104508
u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */
104426104509
u8 overrideError, /* Override onError to this if not OE_Default */
104427104510
int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
104428
- int *pbMayReplace /* OUT: Set to true if constraint may cause a replace */
104511
+ int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */
104512
+ int *aiChng /* column i is unchanged if aiChng[i]<0 */
104429104513
){
104430104514
Vdbe *v; /* VDBE under constrution */
104431104515
Index *pIdx; /* Pointer to one of the indices */
104432104516
Index *pPk = 0; /* The PRIMARY KEY index */
104433104517
sqlite3 *db; /* Database connection */
@@ -104469,14 +104553,18 @@
104469104553
104470104554
/* Test all NOT NULL constraints.
104471104555
*/
104472104556
for(i=0; i<nCol; i++){
104473104557
if( i==pTab->iPKey ){
104558
+ continue; /* ROWID is never NULL */
104559
+ }
104560
+ if( aiChng && aiChng[i]<0 ){
104561
+ /* Don't bother checking for NOT NULL on columns that do not change */
104474104562
continue;
104475104563
}
104476104564
onError = pTab->aCol[i].notNull;
104477
- if( onError==OE_None ) continue;
104565
+ if( onError==OE_None ) continue; /* This column is allowed to be NULL */
104478104566
if( overrideError!=OE_Default ){
104479104567
onError = overrideError;
104480104568
}else if( onError==OE_Default ){
104481104569
onError = OE_Abort;
104482104570
}
@@ -104521,12 +104609,15 @@
104521104609
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
104522104610
ExprList *pCheck = pTab->pCheck;
104523104611
pParse->ckBase = regNewData+1;
104524104612
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
104525104613
for(i=0; i<pCheck->nExpr; i++){
104526
- int allOk = sqlite3VdbeMakeLabel(v);
104527
- sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
104614
+ int allOk;
104615
+ Expr *pExpr = pCheck->a[i].pExpr;
104616
+ if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
104617
+ allOk = sqlite3VdbeMakeLabel(v);
104618
+ sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
104528104619
if( onError==OE_Ignore ){
104529104620
sqlite3VdbeGoto(v, ignoreDest);
104530104621
}else{
104531104622
char *zName = pCheck->a[i].zName;
104532104623
if( zName==0 ) zName = pTab->zName;
@@ -117677,11 +117768,12 @@
117677117768
int bReplace = 0; /* True if REPLACE conflict resolution might happen */
117678117769
117679117770
/* Do constraint checks. */
117680117771
assert( regOldRowid>0 );
117681117772
sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
117682
- regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace);
117773
+ regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
117774
+ aXRef);
117683117775
117684117776
/* Do FK constraint checks. */
117685117777
if( hasFK ){
117686117778
sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
117687117779
}
@@ -126572,11 +126664,10 @@
126572126664
** Return the cost of sorting nRow rows, assuming that the keys have
126573126665
** nOrderby columns and that the first nSorted columns are already in
126574126666
** order.
126575126667
*/
126576126668
static LogEst whereSortingCost(
126577
- WhereInfo *pWInfo,
126578126669
LogEst nRow,
126579126670
int nOrderBy,
126580126671
int nSorted
126581126672
){
126582126673
/* TUNING: Estimated cost of a full external sort, where N is
@@ -126594,18 +126685,10 @@
126594126685
** below. */
126595126686
LogEst rScale, rSortCost;
126596126687
assert( nOrderBy>0 && 66==sqlite3LogEst(100) );
126597126688
rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;
126598126689
rSortCost = nRow + estLog(nRow) + rScale + 16;
126599
-
126600
- /* TUNING: The cost of implementing DISTINCT using a B-TREE is
126601
- ** similar but with a larger constant of proportionality.
126602
- ** Multiply by an additional factor of 3.0. */
126603
- if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){
126604
- rSortCost += 16;
126605
- }
126606
-
126607126690
return rSortCost;
126608126691
}
126609126692
126610126693
/*
126611126694
** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
@@ -126735,11 +126818,11 @@
126735126818
revMask = pFrom->revLoop;
126736126819
}
126737126820
if( isOrdered>=0 && isOrdered<nOrderBy ){
126738126821
if( aSortCost[isOrdered]==0 ){
126739126822
aSortCost[isOrdered] = whereSortingCost(
126740
- pWInfo, nRowEst, nOrderBy, isOrdered
126823
+ nRowEst, nOrderBy, isOrdered
126741126824
);
126742126825
}
126743126826
rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]);
126744126827
126745126828
WHERETRACE(0x002,
@@ -137300,10 +137383,16 @@
137300137383
#define _FTSINT_H
137301137384
137302137385
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
137303137386
# define NDEBUG 1
137304137387
#endif
137388
+
137389
+/* FTS3/FTS4 require virtual tables */
137390
+#ifdef SQLITE_OMIT_VIRTUALTABLE
137391
+# undef SQLITE_ENABLE_FTS3
137392
+# undef SQLITE_ENABLE_FTS4
137393
+#endif
137305137394
137306137395
/*
137307137396
** FTS4 is really an extension for FTS3. It is enabled using the
137308137397
** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all
137309137398
** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
@@ -165637,11 +165726,15 @@
165637165726
/* #include <assert.h> */
165638165727
/* #include <string.h> */
165639165728
/* #include <stdlib.h> */
165640165729
/* #include <stdarg.h> */
165641165730
165642
-#define UNUSED_PARAM(X) (void)(X)
165731
+/* Mark a function parameter as unused, to suppress nuisance compiler
165732
+** warnings. */
165733
+#ifndef UNUSED_PARAM
165734
+# define UNUSED_PARAM(X) (void)(X)
165735
+#endif
165643165736
165644165737
#ifndef LARGEST_INT64
165645165738
# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
165646165739
# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
165647165740
#endif
@@ -167158,10 +167251,11 @@
167158167251
sqlite3_context *ctx,
167159167252
int argc,
167160167253
sqlite3_value **argv
167161167254
){
167162167255
JsonString *pStr;
167256
+ UNUSED_PARAM(argc);
167163167257
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
167164167258
if( pStr ){
167165167259
if( pStr->zBuf==0 ){
167166167260
jsonInit(pStr, ctx);
167167167261
jsonAppendChar(pStr, '[');
@@ -167203,10 +167297,11 @@
167203167297
sqlite3_value **argv
167204167298
){
167205167299
JsonString *pStr;
167206167300
const char *z;
167207167301
u32 n;
167302
+ UNUSED_PARAM(argc);
167208167303
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
167209167304
if( pStr ){
167210167305
if( pStr->zBuf==0 ){
167211167306
jsonInit(pStr, ctx);
167212167307
jsonAppendChar(pStr, '{');
@@ -168464,10 +168559,20 @@
168464168559
SQLITE_API extern int sqlite3_fts5_may_be_corrupt;
168465168560
# define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))
168466168561
#else
168467168562
# define assert_nc(x) assert(x)
168468168563
#endif
168564
+
168565
+/* Mark a function parameter as unused, to suppress nuisance compiler
168566
+** warnings. */
168567
+#ifndef UNUSED_PARAM
168568
+# define UNUSED_PARAM(X) (void)(X)
168569
+#endif
168570
+
168571
+#ifndef UNUSED_PARAM2
168572
+# define UNUSED_PARAM2(X, Y) (void)(X), (void)(Y)
168573
+#endif
168469168574
168470168575
typedef struct Fts5Global Fts5Global;
168471168576
typedef struct Fts5Colset Fts5Colset;
168472168577
168473168578
/* If a NEAR() clump or phrase may only match a specific set of columns,
@@ -168730,20 +168835,10 @@
168730168835
** Create/destroy an Fts5Index object.
168731168836
*/
168732168837
static int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);
168733168838
static int sqlite3Fts5IndexClose(Fts5Index *p);
168734168839
168735
-/*
168736
-** for(
168737
-** sqlite3Fts5IndexQuery(p, "token", 5, 0, 0, &pIter);
168738
-** 0==sqlite3Fts5IterEof(pIter);
168739
-** sqlite3Fts5IterNext(pIter)
168740
-** ){
168741
-** i64 iRowid = sqlite3Fts5IterRowid(pIter);
168742
-** }
168743
-*/
168744
-
168745168840
/*
168746168841
** Return a simple checksum value based on the arguments.
168747168842
*/
168748168843
static u64 sqlite3Fts5IndexEntryCksum(
168749168844
i64 iRowid,
@@ -168781,11 +168876,10 @@
168781168876
** The various operations on open token or token prefix iterators opened
168782168877
** using sqlite3Fts5IndexQuery().
168783168878
*/
168784168879
static int sqlite3Fts5IterNext(Fts5IndexIter*);
168785168880
static int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);
168786
-static i64 sqlite3Fts5IterRowid(Fts5IndexIter*);
168787168881
168788168882
/*
168789168883
** Close an iterator opened by sqlite3Fts5IndexQuery().
168790168884
*/
168791168885
static void sqlite3Fts5IterClose(Fts5IndexIter*);
@@ -169066,11 +169160,11 @@
169066169160
Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
169067169161
);
169068169162
static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
169069169163
static void sqlite3Fts5ExprClearEof(Fts5Expr*);
169070169164
169071
-static int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**);
169165
+static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
169072169166
169073169167
static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
169074169168
169075169169
/*******************************************
169076169170
** The fts5_expr.c API above this point is used by the other hand-written
@@ -169857,11 +169951,12 @@
169857169951
while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
169858169952
/* Here code is inserted which will execute if the parser
169859169953
** stack every overflows */
169860169954
/******** Begin %stack_overflow code ******************************************/
169861169955
169862
- assert( 0 );
169956
+ UNUSED_PARAM(fts5yypMinor); /* Silence a compiler warning */
169957
+ sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
169863169958
/******** End %stack_overflow code ********************************************/
169864169959
sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
169865169960
}
169866169961
169867169962
/*
@@ -170154,10 +170249,11 @@
170154170249
){
170155170250
sqlite3Fts5ParserARG_FETCH;
170156170251
#define FTS5TOKEN (fts5yyminor.fts5yy0)
170157170252
/************ Begin %syntax_error code ****************************************/
170158170253
170254
+ UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */
170159170255
sqlite3Fts5ParseError(
170160170256
pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p
170161170257
);
170162170258
/************ End %syntax_error code ******************************************/
170163170259
sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -170530,10 +170626,12 @@
170530170626
int iEndOff /* End offset of token */
170531170627
){
170532170628
HighlightContext *p = (HighlightContext*)pContext;
170533170629
int rc = SQLITE_OK;
170534170630
int iPos;
170631
+
170632
+ UNUSED_PARAM2(pToken, nToken);
170535170633
170536170634
if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK;
170537170635
iPos = p->iPos++;
170538170636
170539170637
if( p->iRangeEnd>0 ){
@@ -170764,10 +170862,11 @@
170764170862
const Fts5ExtensionApi *pApi,
170765170863
Fts5Context *pFts,
170766170864
void *pUserData /* Pointer to sqlite3_int64 variable */
170767170865
){
170768170866
sqlite3_int64 *pn = (sqlite3_int64*)pUserData;
170867
+ UNUSED_PARAM2(pApi, pFts);
170769170868
(*pn)++;
170770170869
return SQLITE_OK;
170771170870
}
170772170871
170773170872
/*
@@ -171169,11 +171268,11 @@
171169171268
static int sqlite3Fts5PoslistWriterAppend(
171170171269
Fts5Buffer *pBuf,
171171171270
Fts5PoslistWriter *pWriter,
171172171271
i64 iPos
171173171272
){
171174
- int rc;
171273
+ int rc = 0; /* Initialized only to suppress erroneous warning from Clang */
171175171274
if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;
171176171275
sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);
171177171276
return SQLITE_OK;
171178171277
}
171179171278
@@ -171323,13 +171422,10 @@
171323171422
}
171324171423
}
171325171424
sqlite3_free(p);
171326171425
}
171327171426
}
171328
-
171329
-
171330
-
171331171427
171332171428
/*
171333171429
** 2014 Jun 09
171334171430
**
171335171431
** The author disclaims copyright to this source code. In place of
@@ -171535,11 +171631,11 @@
171535171631
static int fts5ConfigSetEnum(
171536171632
const Fts5Enum *aEnum,
171537171633
const char *zEnum,
171538171634
int *peVal
171539171635
){
171540
- int nEnum = strlen(zEnum);
171636
+ int nEnum = (int)strlen(zEnum);
171541171637
int i;
171542171638
int iVal = -1;
171543171639
171544171640
for(i=0; aEnum[i].zName; i++){
171545171641
if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){
@@ -172273,11 +172369,10 @@
172273172369
pConfig->iCookie = iCookie;
172274172370
}
172275172371
return rc;
172276172372
}
172277172373
172278
-
172279172374
/*
172280172375
** 2014 May 31
172281172376
**
172282172377
** The author disclaims copyright to this source code. In place of
172283172378
** a legal notice, here is a blessing:
@@ -172596,12 +172691,10 @@
172596172691
/*
172597172692
** Argument pTerm must be a synonym iterator.
172598172693
*/
172599172694
static int fts5ExprSynonymList(
172600172695
Fts5ExprTerm *pTerm,
172601
- int bCollist,
172602
- Fts5Colset *pColset,
172603172696
i64 iRowid,
172604172697
Fts5Buffer *pBuf, /* Use this buffer for space if required */
172605172698
u8 **pa, int *pn
172606172699
){
172607172700
Fts5PoslistReader aStatic[4];
@@ -172681,11 +172774,10 @@
172681172774
** otherwise. It is not considered an error code if the current rowid is
172682172775
** not a match.
172683172776
*/
172684172777
static int fts5ExprPhraseIsMatch(
172685172778
Fts5ExprNode *pNode, /* Node pPhrase belongs to */
172686
- Fts5Colset *pColset, /* Restrict matches to these columns */
172687172779
Fts5ExprPhrase *pPhrase, /* Phrase object to initialize */
172688172780
int *pbMatch /* OUT: Set to true if really a match */
172689172781
){
172690172782
Fts5PoslistWriter writer = {0};
172691172783
Fts5PoslistReader aStatic[4];
@@ -172710,13 +172802,11 @@
172710172802
int n = 0;
172711172803
int bFlag = 0;
172712172804
u8 *a = 0;
172713172805
if( pTerm->pSynonym ){
172714172806
Fts5Buffer buf = {0, 0, 0};
172715
- rc = fts5ExprSynonymList(
172716
- pTerm, 0, pColset, pNode->iRowid, &buf, &a, &n
172717
- );
172807
+ rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n);
172718172808
if( rc ){
172719172809
sqlite3_free(a);
172720172810
goto ismatch_out;
172721172811
}
172722172812
if( a==buf.p ) bFlag = 1;
@@ -173003,11 +173093,11 @@
173003173093
** phrase is not a match, break out of the loop early. */
173004173094
for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){
173005173095
Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];
173006173096
if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){
173007173097
int bMatch = 0;
173008
- rc = fts5ExprPhraseIsMatch(pNode, pNear->pColset, pPhrase, &bMatch);
173098
+ rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch);
173009173099
if( bMatch==0 ) break;
173010173100
}else{
173011173101
Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;
173012173102
fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);
173013173103
}
@@ -173751,10 +173841,12 @@
173751173841
){
173752173842
int rc = SQLITE_OK;
173753173843
const int SZALLOC = 8;
173754173844
TokenCtx *pCtx = (TokenCtx*)pContext;
173755173845
Fts5ExprPhrase *pPhrase = pCtx->pPhrase;
173846
+
173847
+ UNUSED_PARAM2(iUnused1, iUnused2);
173756173848
173757173849
/* If an error has already occurred, this is a no-op */
173758173850
if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;
173759173851
173760173852
assert( pPhrase==0 || pPhrase->nTerm>0 );
@@ -173887,26 +173979,21 @@
173887173979
/*
173888173980
** Create a new FTS5 expression by cloning phrase iPhrase of the
173889173981
** expression passed as the second argument.
173890173982
*/
173891173983
static int sqlite3Fts5ExprClonePhrase(
173892
- Fts5Config *pConfig,
173893173984
Fts5Expr *pExpr,
173894173985
int iPhrase,
173895173986
Fts5Expr **ppNew
173896173987
){
173897173988
int rc = SQLITE_OK; /* Return code */
173898173989
Fts5ExprPhrase *pOrig; /* The phrase extracted from pExpr */
173899173990
int i; /* Used to iterate through phrase terms */
173900
-
173901173991
Fts5Expr *pNew = 0; /* Expression to return via *ppNew */
173902
-
173903173992
TokenCtx sCtx = {0,0}; /* Context object for fts5ParseTokenize */
173904173993
173905
-
173906173994
pOrig = pExpr->apExprPhrase[iPhrase];
173907
-
173908173995
pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));
173909173996
if( rc==SQLITE_OK ){
173910173997
pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc,
173911173998
sizeof(Fts5ExprPhrase*));
173912173999
}
@@ -174675,16 +174762,18 @@
174675174762
static int fts5ExprPopulatePoslistsCb(
174676174763
void *pCtx, /* Copy of 2nd argument to xTokenize() */
174677174764
int tflags, /* Mask of FTS5_TOKEN_* flags */
174678174765
const char *pToken, /* Pointer to buffer containing token */
174679174766
int nToken, /* Size of token in bytes */
174680
- int iStart, /* Byte offset of token within input text */
174681
- int iEnd /* Byte offset of end of token within input text */
174767
+ int iUnused1, /* Byte offset of token within input text */
174768
+ int iUnused2 /* Byte offset of end of token within input text */
174682174769
){
174683174770
Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx;
174684174771
Fts5Expr *pExpr = p->pExpr;
174685174772
int i;
174773
+
174774
+ UNUSED_PARAM2(iUnused1, iUnused2);
174686174775
174687174776
if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;
174688174777
for(i=0; i<pExpr->nPhrase; i++){
174689174778
Fts5ExprTerm *pTerm;
174690174779
if( p->aPopulator[i].bOk==0 ) continue;
@@ -174826,11 +174915,11 @@
174826174915
){
174827174916
Fts5ExprTerm *pTerm = &pPhrase->aTerm[0];
174828174917
if( pTerm->pSynonym ){
174829174918
Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1];
174830174919
rc = fts5ExprSynonymList(
174831
- pTerm, 1, 0, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist
174920
+ pTerm, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist
174832174921
);
174833174922
}else{
174834174923
*ppCollist = pPhrase->aTerm[0].pIter->pData;
174835174924
*pnCollist = pPhrase->aTerm[0].pIter->nData;
174836174925
}
@@ -175977,21 +176066,10 @@
175977176066
int nCmp = MIN(pLeft->n, pRight->n);
175978176067
int res = memcmp(pLeft->p, pRight->p, nCmp);
175979176068
return (res==0 ? (pLeft->n - pRight->n) : res);
175980176069
}
175981176070
175982
-#ifdef SQLITE_DEBUG
175983
-static int fts5BlobCompare(
175984
- const u8 *pLeft, int nLeft,
175985
- const u8 *pRight, int nRight
175986
-){
175987
- int nCmp = MIN(nLeft, nRight);
175988
- int res = memcmp(pLeft, pRight, nCmp);
175989
- return (res==0 ? (nLeft - nRight) : res);
175990
-}
175991
-#endif
175992
-
175993176071
static int fts5LeafFirstTermOff(Fts5Data *pLeaf){
175994176072
int ret;
175995176073
fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);
175996176074
return ret;
175997176075
}
@@ -176249,28 +176327,37 @@
176249176327
for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){
176250176328
Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl];
176251176329
int nTotal;
176252176330
int iSeg;
176253176331
176254
- i += fts5GetVarint32(&pData[i], pLvl->nMerge);
176255
- i += fts5GetVarint32(&pData[i], nTotal);
176256
- assert( nTotal>=pLvl->nMerge );
176257
- pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
176258
- nTotal * sizeof(Fts5StructureSegment)
176259
- );
176332
+ if( i>=nData ){
176333
+ rc = FTS5_CORRUPT;
176334
+ }else{
176335
+ i += fts5GetVarint32(&pData[i], pLvl->nMerge);
176336
+ i += fts5GetVarint32(&pData[i], nTotal);
176337
+ assert( nTotal>=pLvl->nMerge );
176338
+ pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
176339
+ nTotal * sizeof(Fts5StructureSegment)
176340
+ );
176341
+ }
176260176342
176261176343
if( rc==SQLITE_OK ){
176262176344
pLvl->nSeg = nTotal;
176263176345
for(iSeg=0; iSeg<nTotal; iSeg++){
176346
+ if( i>=nData ){
176347
+ rc = FTS5_CORRUPT;
176348
+ break;
176349
+ }
176264176350
i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
176265176351
i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
176266176352
i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
176267176353
}
176268
- }else{
176269
- fts5StructureRelease(pRet);
176270
- pRet = 0;
176271176354
}
176355
+ }
176356
+ if( rc!=SQLITE_OK ){
176357
+ fts5StructureRelease(pRet);
176358
+ pRet = 0;
176272176359
}
176273176360
}
176274176361
176275176362
*ppOut = pRet;
176276176363
return rc;
@@ -176934,10 +177021,14 @@
176934177021
u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
176935177022
int iOff = pIter->iLeafOffset; /* Offset to read at */
176936177023
int nNew; /* Bytes of new data */
176937177024
176938177025
iOff += fts5GetVarint32(&a[iOff], nNew);
177026
+ if( iOff+nNew>pIter->pLeaf->nn ){
177027
+ p->rc = FTS5_CORRUPT;
177028
+ return;
177029
+ }
176939177030
pIter->term.n = nKeep;
176940177031
fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
176941177032
iOff += nNew;
176942177033
pIter->iTermLeafOffset = iOff;
176943177034
pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -177140,14 +177231,16 @@
177140177231
** This version of fts5SegIterNext() is only used by reverse iterators.
177141177232
*/
177142177233
static void fts5SegIterNext_Reverse(
177143177234
Fts5Index *p, /* FTS5 backend object */
177144177235
Fts5SegIter *pIter, /* Iterator to advance */
177145
- int *pbNewTerm /* OUT: Set for new term */
177236
+ int *pbUnused /* Unused */
177146177237
){
177147177238
assert( pIter->flags & FTS5_SEGITER_REVERSE );
177148177239
assert( pIter->pNextLeaf==0 );
177240
+ UNUSED_PARAM(pbUnused);
177241
+
177149177242
if( pIter->iRowidOffset>0 ){
177150177243
u8 *a = pIter->pLeaf->p;
177151177244
int iOff;
177152177245
i64 iDelta;
177153177246
@@ -177620,11 +177713,10 @@
177620177713
** If an error occurs, Fts5Index.rc is set to an appropriate error code. If
177621177714
** an error has already occurred when this function is called, it is a no-op.
177622177715
*/
177623177716
static void fts5SegIterSeekInit(
177624177717
Fts5Index *p, /* FTS5 backend */
177625
- Fts5Buffer *pBuf, /* Buffer to use for loading pages */
177626177718
const u8 *pTerm, int nTerm, /* Term to seek to */
177627177719
int flags, /* Mask of FTS5INDEX_XXX flags */
177628177720
Fts5StructureSegment *pSeg, /* Description of segment */
177629177721
Fts5SegIter *pIter /* Object to populate */
177630177722
){
@@ -178007,11 +178099,11 @@
178007178099
178008178100
178009178101
/*
178010178102
** Free the iterator object passed as the second argument.
178011178103
*/
178012
-static void fts5MultiIterFree(Fts5Index *p, Fts5Iter *pIter){
178104
+static void fts5MultiIterFree(Fts5Iter *pIter){
178013178105
if( pIter ){
178014178106
int i;
178015178107
for(i=0; i<pIter->nSeg; i++){
178016178108
fts5SegIterClear(&pIter->aSeg[i]);
178017178109
}
@@ -178048,11 +178140,10 @@
178048178140
** If non-zero is returned, the caller should call fts5MultiIterAdvanced()
178049178141
** on the iterator instead. That function does the same as this one, except
178050178142
** that it deals with more complicated cases as well.
178051178143
*/
178052178144
static int fts5MultiIterAdvanceRowid(
178053
- Fts5Index *p, /* FTS5 backend to iterate within */
178054178145
Fts5Iter *pIter, /* Iterator to update aFirst[] array for */
178055178146
int iChanged, /* Index of sub-iterator just advanced */
178056178147
Fts5SegIter **ppFirst
178057178148
){
178058178149
Fts5SegIter *pNew = &pIter->aSeg[iChanged];
@@ -178123,11 +178214,11 @@
178123178214
}else{
178124178215
pSeg->xNext(p, pSeg, &bNewTerm);
178125178216
}
178126178217
178127178218
if( pSeg->pLeaf==0 || bNewTerm
178128
- || fts5MultiIterAdvanceRowid(p, pIter, iFirst, &pSeg)
178219
+ || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)
178129178220
){
178130178221
fts5MultiIterAdvanced(p, pIter, iFirst, 1);
178131178222
fts5MultiIterSetEof(pIter);
178132178223
pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];
178133178224
if( pSeg->pLeaf==0 ) return;
@@ -178156,11 +178247,11 @@
178156178247
int bNewTerm = 0;
178157178248
178158178249
assert( p->rc==SQLITE_OK );
178159178250
pSeg->xNext(p, pSeg, &bNewTerm);
178160178251
if( pSeg->pLeaf==0 || bNewTerm
178161
- || fts5MultiIterAdvanceRowid(p, pIter, iFirst, &pSeg)
178252
+ || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)
178162178253
){
178163178254
fts5MultiIterAdvanced(p, pIter, iFirst, 1);
178164178255
fts5MultiIterSetEof(pIter);
178165178256
*pbNewTerm = 1;
178166178257
}else{
@@ -178170,11 +178261,12 @@
178170178261
178171178262
}while( fts5MultiIterIsEmpty(p, pIter) );
178172178263
}
178173178264
}
178174178265
178175
-static void fts5IterSetOutputs_Noop(Fts5Iter *pIter, Fts5SegIter *pSeg){
178266
+static void fts5IterSetOutputs_Noop(Fts5Iter *pUnused1, Fts5SegIter *pUnused2){
178267
+ UNUSED_PARAM2(pUnused1, pUnused2);
178176178268
}
178177178269
178178178270
static Fts5Iter *fts5MultiIterAlloc(
178179178271
Fts5Index *p, /* FTS5 backend to iterate within */
178180178272
int nSeg
@@ -178196,14 +178288,15 @@
178196178288
}
178197178289
return pNew;
178198178290
}
178199178291
178200178292
static void fts5PoslistCallback(
178201
- Fts5Index *p,
178293
+ Fts5Index *pUnused,
178202178294
void *pContext,
178203178295
const u8 *pChunk, int nChunk
178204178296
){
178297
+ UNUSED_PARAM(pUnused);
178205178298
assert_nc( nChunk>=0 );
178206178299
if( nChunk>0 ){
178207178300
fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk);
178208178301
}
178209178302
}
@@ -178233,15 +178326,16 @@
178233178326
}
178234178327
return 0;
178235178328
}
178236178329
178237178330
static void fts5PoslistOffsetsCallback(
178238
- Fts5Index *p,
178331
+ Fts5Index *pUnused,
178239178332
void *pContext,
178240178333
const u8 *pChunk, int nChunk
178241178334
){
178242178335
PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext;
178336
+ UNUSED_PARAM(pUnused);
178243178337
assert_nc( nChunk>=0 );
178244178338
if( nChunk>0 ){
178245178339
int i = 0;
178246178340
while( i<nChunk ){
178247178341
int iVal;
@@ -178255,15 +178349,16 @@
178255178349
}
178256178350
}
178257178351
}
178258178352
178259178353
static void fts5PoslistFilterCallback(
178260
- Fts5Index *p,
178354
+ Fts5Index *pUnused,
178261178355
void *pContext,
178262178356
const u8 *pChunk, int nChunk
178263178357
){
178264178358
PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext;
178359
+ UNUSED_PARAM(pUnused);
178265178360
assert_nc( nChunk>=0 );
178266178361
if( nChunk>0 ){
178267178362
/* Search through to find the first varint with value 1. This is the
178268178363
** start of the next columns hits. */
178269178364
int i = 0;
@@ -178623,11 +178718,10 @@
178623178718
Fts5Iter **ppOut /* New object */
178624178719
){
178625178720
int nSeg = 0; /* Number of segment-iters in use */
178626178721
int iIter = 0; /* */
178627178722
int iSeg; /* Used to iterate through segments */
178628
- Fts5Buffer buf = {0,0,0}; /* Buffer used by fts5SegIterSeekInit() */
178629178723
Fts5StructureLevel *pLvl;
178630178724
Fts5Iter *pNew;
178631178725
178632178726
assert( (pTerm==0 && nTerm==0) || iLevel<0 );
178633178727
@@ -178666,11 +178760,11 @@
178666178760
Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
178667178761
Fts5SegIter *pIter = &pNew->aSeg[iIter++];
178668178762
if( pTerm==0 ){
178669178763
fts5SegIterInit(p, pSeg, pIter);
178670178764
}else{
178671
- fts5SegIterSeekInit(p, &buf, pTerm, nTerm, flags, pSeg, pIter);
178765
+ fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter);
178672178766
}
178673178767
}
178674178768
}
178675178769
}else{
178676178770
pLvl = &pStruct->aLevel[iLevel];
@@ -178703,15 +178797,13 @@
178703178797
Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst];
178704178798
pNew->xSetOutputs(pNew, pSeg);
178705178799
}
178706178800
178707178801
}else{
178708
- fts5MultiIterFree(p, pNew);
178802
+ fts5MultiIterFree(pNew);
178709178803
*ppOut = 0;
178710178804
}
178711
- fts5BufferFree(&buf);
178712
-
178713178805
}
178714178806
178715178807
/*
178716178808
** Create an Fts5Iter that iterates through the doclist provided
178717178809
** as the second argument.
@@ -178845,19 +178937,18 @@
178845178937
p->nPendingData = 0;
178846178938
}
178847178939
}
178848178940
178849178941
/*
178850
-** Return the size of the prefix, in bytes, that buffer (nNew/pNew) shares
178851
-** with buffer (nOld/pOld).
178942
+** Return the size of the prefix, in bytes, that buffer
178943
+** (pNew/<length-unknown>) shares with buffer (pOld/nOld).
178944
+**
178945
+** Buffer (pNew/<length-unknown>) is guaranteed to be greater
178946
+** than buffer (pOld/nOld).
178852178947
*/
178853
-static int fts5PrefixCompress(
178854
- int nOld, const u8 *pOld,
178855
- int nNew, const u8 *pNew
178856
-){
178948
+static int fts5PrefixCompress(int nOld, const u8 *pOld, const u8 *pNew){
178857178949
int i;
178858
- assert( fts5BlobCompare(pOld, nOld, pNew, nNew)<0 );
178859178950
for(i=0; i<nOld; i++){
178860178951
if( pOld[i]!=pNew[i] ) break;
178861178952
}
178862178953
return i;
178863178954
}
@@ -179163,17 +179254,17 @@
179163179254
** In this case the previous term is not available, so just write a
179164179255
** copy of (pTerm/nTerm) into the parent node. This is slightly
179165179256
** inefficient, but still correct. */
179166179257
int n = nTerm;
179167179258
if( pPage->term.n ){
179168
- n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, nTerm, pTerm);
179259
+ n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
179169179260
}
179170179261
fts5WriteBtreeTerm(p, pWriter, n, pTerm);
179171179262
pPage = &pWriter->writer;
179172179263
}
179173179264
}else{
179174
- nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, nTerm, pTerm);
179265
+ nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
179175179266
fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
179176179267
}
179177179268
179178179269
/* Append the number of bytes of new data, then the term data itself
179179179270
** to the page. */
@@ -179535,11 +179626,11 @@
179535179626
assert( pSeg->pgnoLast>0 );
179536179627
fts5TrimSegments(p, pIter);
179537179628
pLvl->nMerge = nInput;
179538179629
}
179539179630
179540
- fts5MultiIterFree(p, pIter);
179631
+ fts5MultiIterFree(pIter);
179541179632
fts5BufferFree(&term);
179542179633
if( pnRem ) *pnRem -= writer.nLeafWritten;
179543179634
}
179544179635
179545179636
/*
@@ -179911,13 +180002,14 @@
179911180002
}
179912180003
179913180004
static void fts5AppendRowid(
179914180005
Fts5Index *p,
179915180006
i64 iDelta,
179916
- Fts5Iter *pMulti,
180007
+ Fts5Iter *pUnused,
179917180008
Fts5Buffer *pBuf
179918180009
){
180010
+ UNUSED_PARAM(pUnused);
179919180011
fts5BufferAppendVarint(&p->rc, pBuf, iDelta);
179920180012
}
179921180013
179922180014
static void fts5AppendPoslist(
179923180015
Fts5Index *p,
@@ -180256,11 +180348,11 @@
180256180348
if( p->rc==SQLITE_OK ){
180257180349
xMerge(p, &doclist, &aBuf[i]);
180258180350
}
180259180351
fts5BufferFree(&aBuf[i]);
180260180352
}
180261
- fts5MultiIterFree(p, p1);
180353
+ fts5MultiIterFree(p1);
180262180354
180263180355
pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
180264180356
if( pData ){
180265180357
pData->p = (u8*)&pData[1];
180266180358
pData->nn = pData->szLeaf = doclist.n;
@@ -180537,11 +180629,11 @@
180537180629
}else{
180538180630
/* Scan multiple terms in the main index */
180539180631
int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
180540180632
buf.p[0] = FTS5_MAIN_PREFIX;
180541180633
fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet);
180542
- assert( pRet->pColset==0 );
180634
+ assert( p->rc!=SQLITE_OK || pRet->pColset==0 );
180543180635
fts5IterSetOutputCb(&p->rc, pRet);
180544180636
if( p->rc==SQLITE_OK ){
180545180637
Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
180546180638
if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
180547180639
}
@@ -180620,11 +180712,11 @@
180620180712
*/
180621180713
static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
180622180714
if( pIndexIter ){
180623180715
Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
180624180716
Fts5Index *pIndex = pIter->pIndex;
180625
- fts5MultiIterFree(pIter->pIndex, pIter);
180717
+ fts5MultiIterFree(pIter);
180626180718
fts5CloseReader(pIndex);
180627180719
}
180628180720
}
180629180721
180630180722
/*
@@ -181179,11 +181271,11 @@
181179181271
}
181180181272
}
181181181273
}
181182181274
fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
181183181275
181184
- fts5MultiIterFree(p, pIter);
181276
+ fts5MultiIterFree(pIter);
181185181277
if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
181186181278
181187181279
fts5StructureRelease(pStruct);
181188181280
#ifdef SQLITE_DEBUG
181189181281
fts5BufferFree(&term);
@@ -181416,10 +181508,11 @@
181416181508
int rc = SQLITE_OK; /* Return code */
181417181509
int nSpace = 0;
181418181510
int eDetailNone = (sqlite3_user_data(pCtx)!=0);
181419181511
181420181512
assert( nArg==2 );
181513
+ UNUSED_PARAM(nArg);
181421181514
memset(&s, 0, sizeof(Fts5Buffer));
181422181515
iRowid = sqlite3_value_int64(apVal[0]);
181423181516
181424181517
/* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]
181425181518
** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
@@ -182744,11 +182837,11 @@
182744182837
** 3. A full-table scan.
182745182838
*/
182746182839
static int fts5FilterMethod(
182747182840
sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
182748182841
int idxNum, /* Strategy index */
182749
- const char *idxStr, /* Unused */
182842
+ const char *zUnused, /* Unused */
182750182843
int nVal, /* Number of elements in apVal */
182751182844
sqlite3_value **apVal /* Arguments for the indexing scheme */
182752182845
){
182753182846
Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
182754182847
Fts5Config *pConfig = pTab->pConfig;
@@ -182761,10 +182854,13 @@
182761182854
sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */
182762182855
sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */
182763182856
sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */
182764182857
sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */
182765182858
char **pzErrmsg = pConfig->pzErrmsg;
182859
+
182860
+ UNUSED_PARAM(zUnused);
182861
+ UNUSED_PARAM(nVal);
182766182862
182767182863
if( pCsr->ePlan ){
182768182864
fts5FreeCursorComponents(pCsr);
182769182865
memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));
182770182866
}
@@ -183046,12 +183142,11 @@
183046183142
return rc;
183047183143
}
183048183144
183049183145
static int fts5SpecialDelete(
183050183146
Fts5Table *pTab,
183051
- sqlite3_value **apVal,
183052
- sqlite3_int64 *piRowid
183147
+ sqlite3_value **apVal
183053183148
){
183054183149
int rc = SQLITE_OK;
183055183150
int eType1 = sqlite3_value_type(apVal[1]);
183056183151
if( eType1==SQLITE_INTEGER ){
183057183152
sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);
@@ -183123,11 +183218,11 @@
183123183218
/* A "special" INSERT op. These are handled separately. */
183124183219
const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]);
183125183220
if( pConfig->eContent!=FTS5_CONTENT_NORMAL
183126183221
&& 0==sqlite3_stricmp("delete", z)
183127183222
){
183128
- rc = fts5SpecialDelete(pTab, apVal, pRowid);
183223
+ rc = fts5SpecialDelete(pTab, apVal);
183129183224
}else{
183130183225
rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
183131183226
}
183132183227
}else{
183133183228
/* A regular INSERT, UPDATE or DELETE statement. The trick here is that
@@ -183224,10 +183319,11 @@
183224183319
183225183320
/*
183226183321
** Implementation of xBegin() method.
183227183322
*/
183228183323
static int fts5BeginMethod(sqlite3_vtab *pVtab){
183324
+ UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
183229183325
fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
183230183326
return SQLITE_OK;
183231183327
}
183232183328
183233183329
/*
@@ -183234,10 +183330,11 @@
183234183330
** Implementation of xCommit() method. This is a no-op. The contents of
183235183331
** the pending-terms hash-table have already been flushed into the database
183236183332
** by fts5SyncMethod().
183237183333
*/
183238183334
static int fts5CommitMethod(sqlite3_vtab *pVtab){
183335
+ UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
183239183336
fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);
183240183337
return SQLITE_OK;
183241183338
}
183242183339
183243183340
/*
@@ -183487,16 +183584,18 @@
183487183584
}
183488183585
183489183586
static int fts5ColumnSizeCb(
183490183587
void *pContext, /* Pointer to int */
183491183588
int tflags,
183492
- const char *pToken, /* Buffer containing token */
183493
- int nToken, /* Size of token in bytes */
183494
- int iStart, /* Start offset of token */
183495
- int iEnd /* End offset of token */
183589
+ const char *pUnused, /* Buffer containing token */
183590
+ int nUnused, /* Size of token in bytes */
183591
+ int iUnused1, /* Start offset of token */
183592
+ int iUnused2 /* End offset of token */
183496183593
){
183497183594
int *pCnt = (int*)pContext;
183595
+ UNUSED_PARAM2(pUnused, nUnused);
183596
+ UNUSED_PARAM2(iUnused1, iUnused2);
183498183597
if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){
183499183598
(*pCnt)++;
183500183599
}
183501183600
return SQLITE_OK;
183502183601
}
@@ -183608,14 +183707,15 @@
183608183707
183609183708
return pRet;
183610183709
}
183611183710
183612183711
static void fts5ApiPhraseNext(
183613
- Fts5Context *pCtx,
183712
+ Fts5Context *pUnused,
183614183713
Fts5PhraseIter *pIter,
183615183714
int *piCol, int *piOff
183616183715
){
183716
+ UNUSED_PARAM(pUnused);
183617183717
if( pIter->a>=pIter->b ){
183618183718
*piCol = -1;
183619183719
*piOff = -1;
183620183720
}else{
183621183721
int iVal;
@@ -183763,16 +183863,15 @@
183763183863
int rc;
183764183864
Fts5Cursor *pNew = 0;
183765183865
183766183866
rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);
183767183867
if( rc==SQLITE_OK ){
183768
- Fts5Config *pConf = pTab->pConfig;
183769183868
pNew->ePlan = FTS5_PLAN_MATCH;
183770183869
pNew->iFirstRowid = SMALLEST_INT64;
183771183870
pNew->iLastRowid = LARGEST_INT64;
183772183871
pNew->base.pVtab = (sqlite3_vtab*)pTab;
183773
- rc = sqlite3Fts5ExprClonePhrase(pConf, pCsr->pExpr, iPhrase, &pNew->pExpr);
183872
+ rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);
183774183873
}
183775183874
183776183875
if( rc==SQLITE_OK ){
183777183876
for(rc = fts5CursorFirst(pTab, pNew, 0);
183778183877
rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;
@@ -183981,18 +184080,19 @@
183981184080
** This routine implements the xFindFunction method for the FTS3
183982184081
** virtual table.
183983184082
*/
183984184083
static int fts5FindFunctionMethod(
183985184084
sqlite3_vtab *pVtab, /* Virtual table handle */
183986
- int nArg, /* Number of SQL function arguments */
184085
+ int nUnused, /* Number of SQL function arguments */
183987184086
const char *zName, /* Name of SQL function */
183988184087
void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
183989184088
void **ppArg /* OUT: User data for *pxFunc */
183990184089
){
183991184090
Fts5Table *pTab = (Fts5Table*)pVtab;
183992184091
Fts5Auxiliary *pAux;
183993184092
184093
+ UNUSED_PARAM(nUnused);
183994184094
pAux = fts5FindAuxiliary(pTab, zName);
183995184095
if( pAux ){
183996184096
*pxFunc = fts5ApiCallback;
183997184097
*ppArg = (void*)pAux;
183998184098
return 1;
@@ -184018,10 +184118,11 @@
184018184118
**
184019184119
** Flush the contents of the pending-terms table to disk.
184020184120
*/
184021184121
static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
184022184122
Fts5Table *pTab = (Fts5Table*)pVtab;
184123
+ UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
184023184124
fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
184024184125
fts5TripCursors(pTab);
184025184126
return sqlite3Fts5StorageSync(pTab->pStorage, 0);
184026184127
}
184027184128
@@ -184030,10 +184131,11 @@
184030184131
**
184031184132
** This is a no-op.
184032184133
*/
184033184134
static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
184034184135
Fts5Table *pTab = (Fts5Table*)pVtab;
184136
+ UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
184035184137
fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
184036184138
fts5TripCursors(pTab);
184037184139
return sqlite3Fts5StorageSync(pTab->pStorage, 0);
184038184140
}
184039184141
@@ -184042,10 +184144,11 @@
184042184144
**
184043184145
** Discard the contents of the pending terms table.
184044184146
*/
184045184147
static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
184046184148
Fts5Table *pTab = (Fts5Table*)pVtab;
184149
+ UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
184047184150
fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
184048184151
fts5TripCursors(pTab);
184049184152
return sqlite3Fts5StorageRollback(pTab->pStorage);
184050184153
}
184051184154
@@ -184221,14 +184324,15 @@
184221184324
}
184222184325
184223184326
static void fts5Fts5Func(
184224184327
sqlite3_context *pCtx, /* Function call context */
184225184328
int nArg, /* Number of args */
184226
- sqlite3_value **apVal /* Function arguments */
184329
+ sqlite3_value **apUnused /* Function arguments */
184227184330
){
184228184331
Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);
184229184332
char buf[8];
184333
+ UNUSED_PARAM2(nArg, apUnused);
184230184334
assert( nArg==0 );
184231184335
assert( sizeof(buf)>=sizeof(pGlobal) );
184232184336
memcpy(buf, (void*)&pGlobal, sizeof(pGlobal));
184233184337
sqlite3_result_blob(pCtx, buf, sizeof(pGlobal), SQLITE_TRANSIENT);
184234184338
}
@@ -184237,14 +184341,15 @@
184237184341
** Implementation of fts5_source_id() function.
184238184342
*/
184239184343
static void fts5SourceIdFunc(
184240184344
sqlite3_context *pCtx, /* Function call context */
184241184345
int nArg, /* Number of args */
184242
- sqlite3_value **apVal /* Function arguments */
184346
+ sqlite3_value **apUnused /* Function arguments */
184243184347
){
184244184348
assert( nArg==0 );
184245
- sqlite3_result_text(pCtx, "fts5: 2016-02-09 18:28:20 51b6823f4c9376d549f572f5a33cac1e4c9783a2", -1, SQLITE_TRANSIENT);
184349
+ UNUSED_PARAM2(nArg, apUnused);
184350
+ sqlite3_result_text(pCtx, "fts5: 2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc", -1, SQLITE_TRANSIENT);
184246184351
}
184247184352
184248184353
static int fts5Init(sqlite3 *db){
184249184354
static const sqlite3_module fts5Mod = {
184250184355
/* iVersion */ 2,
@@ -184709,15 +184814,16 @@
184709184814
static int fts5StorageInsertCallback(
184710184815
void *pContext, /* Pointer to Fts5InsertCtx object */
184711184816
int tflags,
184712184817
const char *pToken, /* Buffer containing token */
184713184818
int nToken, /* Size of token in bytes */
184714
- int iStart, /* Start offset of token */
184715
- int iEnd /* End offset of token */
184819
+ int iUnused1, /* Start offset of token */
184820
+ int iUnused2 /* End offset of token */
184716184821
){
184717184822
Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;
184718184823
Fts5Index *pIdx = pCtx->pStorage->pIndex;
184824
+ UNUSED_PARAM2(iUnused1, iUnused2);
184719184825
if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
184720184826
pCtx->szCol++;
184721184827
}
184722184828
return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);
184723184829
}
@@ -185144,20 +185250,22 @@
185144185250
static int fts5StorageIntegrityCallback(
185145185251
void *pContext, /* Pointer to Fts5IntegrityCtx object */
185146185252
int tflags,
185147185253
const char *pToken, /* Buffer containing token */
185148185254
int nToken, /* Size of token in bytes */
185149
- int iStart, /* Start offset of token */
185150
- int iEnd /* End offset of token */
185255
+ int iUnused1, /* Start offset of token */
185256
+ int iUnused2 /* End offset of token */
185151185257
){
185152185258
Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext;
185153185259
Fts5Termset *pTermset = pCtx->pTermset;
185154185260
int bPresent;
185155185261
int ii;
185156185262
int rc = SQLITE_OK;
185157185263
int iPos;
185158185264
int iCol;
185265
+
185266
+ UNUSED_PARAM2(iUnused1, iUnused2);
185159185267
185160185268
if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
185161185269
pCtx->szCol++;
185162185270
}
185163185271
@@ -185532,16 +185640,17 @@
185532185640
185533185641
/*
185534185642
** Create an "ascii" tokenizer.
185535185643
*/
185536185644
static int fts5AsciiCreate(
185537
- void *pCtx,
185645
+ void *pUnused,
185538185646
const char **azArg, int nArg,
185539185647
Fts5Tokenizer **ppOut
185540185648
){
185541185649
int rc = SQLITE_OK;
185542185650
AsciiTokenizer *p = 0;
185651
+ UNUSED_PARAM(pUnused);
185543185652
if( nArg%2 ){
185544185653
rc = SQLITE_ERROR;
185545185654
}else{
185546185655
p = sqlite3_malloc(sizeof(AsciiTokenizer));
185547185656
if( p==0 ){
@@ -185586,11 +185695,11 @@
185586185695
** Tokenize some text using the ascii tokenizer.
185587185696
*/
185588185697
static int fts5AsciiTokenize(
185589185698
Fts5Tokenizer *pTokenizer,
185590185699
void *pCtx,
185591
- int flags,
185700
+ int iUnused,
185592185701
const char *pText, int nText,
185593185702
int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)
185594185703
){
185595185704
AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer;
185596185705
int rc = SQLITE_OK;
@@ -185599,10 +185708,12 @@
185599185708
185600185709
char aFold[64];
185601185710
int nFold = sizeof(aFold);
185602185711
char *pFold = aFold;
185603185712
unsigned char *a = p->aTokenChar;
185713
+
185714
+ UNUSED_PARAM(iUnused);
185604185715
185605185716
while( is<nText && rc==SQLITE_OK ){
185606185717
int nByte;
185607185718
185608185719
/* Skip any leading divider characters. */
@@ -185793,16 +185904,18 @@
185793185904
185794185905
/*
185795185906
** Create a "unicode61" tokenizer.
185796185907
*/
185797185908
static int fts5UnicodeCreate(
185798
- void *pCtx,
185909
+ void *pUnused,
185799185910
const char **azArg, int nArg,
185800185911
Fts5Tokenizer **ppOut
185801185912
){
185802185913
int rc = SQLITE_OK; /* Return code */
185803185914
Unicode61Tokenizer *p = 0; /* New tokenizer object */
185915
+
185916
+ UNUSED_PARAM(pUnused);
185804185917
185805185918
if( nArg%2 ){
185806185919
rc = SQLITE_ERROR;
185807185920
}else{
185808185921
p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));
@@ -185856,11 +185969,11 @@
185856185969
}
185857185970
185858185971
static int fts5UnicodeTokenize(
185859185972
Fts5Tokenizer *pTokenizer,
185860185973
void *pCtx,
185861
- int flags,
185974
+ int iUnused,
185862185975
const char *pText, int nText,
185863185976
int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)
185864185977
){
185865185978
Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer;
185866185979
int rc = SQLITE_OK;
@@ -185871,10 +185984,12 @@
185871185984
185872185985
/* Output buffer */
185873185986
char *aFold = p->aFold;
185874185987
int nFold = p->nFold;
185875185988
const char *pEnd = &aFold[nFold-6];
185989
+
185990
+ UNUSED_PARAM(iUnused);
185876185991
185877185992
/* Each iteration of this loop gobbles up a contiguous run of separators,
185878185993
** then the next token. */
185879185994
while( rc==SQLITE_OK ){
185880185995
int iCode; /* non-ASCII codepoint read from input */
@@ -187650,19 +187765,21 @@
187650187765
187651187766
/*
187652187767
** Implementation of the xBestIndex method.
187653187768
*/
187654187769
static int fts5VocabBestIndexMethod(
187655
- sqlite3_vtab *pVTab,
187770
+ sqlite3_vtab *pUnused,
187656187771
sqlite3_index_info *pInfo
187657187772
){
187658187773
int i;
187659187774
int iTermEq = -1;
187660187775
int iTermGe = -1;
187661187776
int iTermLe = -1;
187662187777
int idxNum = 0;
187663187778
int nArg = 0;
187779
+
187780
+ UNUSED_PARAM(pUnused);
187664187781
187665187782
for(i=0; i<pInfo->nConstraint; i++){
187666187783
struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
187667187784
if( p->usable==0 ) continue;
187668187785
if( p->iColumn==0 ){ /* term column */
@@ -187901,12 +188018,12 @@
187901188018
** This is the xFilter implementation for the virtual table.
187902188019
*/
187903188020
static int fts5VocabFilterMethod(
187904188021
sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
187905188022
int idxNum, /* Strategy index */
187906
- const char *idxStr, /* Unused */
187907
- int nVal, /* Number of elements in apVal */
188023
+ const char *zUnused, /* Unused */
188024
+ int nUnused, /* Number of elements in apVal */
187908188025
sqlite3_value **apVal /* Arguments for the indexing scheme */
187909188026
){
187910188027
Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
187911188028
int rc = SQLITE_OK;
187912188029
@@ -187916,10 +188033,12 @@
187916188033
int nTerm = 0;
187917188034
187918188035
sqlite3_value *pEq = 0;
187919188036
sqlite3_value *pGe = 0;
187920188037
sqlite3_value *pLe = 0;
188038
+
188039
+ UNUSED_PARAM2(zUnused, nUnused);
187921188040
187922188041
fts5VocabResetCursor(pCsr);
187923188042
if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++];
187924188043
if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++];
187925188044
if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++];
187926188045
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -328,11 +328,11 @@
328 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
329 ** [sqlite_version()] and [sqlite_source_id()].
330 */
331 #define SQLITE_VERSION "3.11.0"
332 #define SQLITE_VERSION_NUMBER 3011000
333 #define SQLITE_SOURCE_ID "2016-02-09 20:11:14 751915cb7e4981661a40dc5e4d029ab27434c2d9"
334
335 /*
336 ** CAPI3REF: Run-Time Library Version Numbers
337 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
338 **
@@ -13987,10 +13987,11 @@
13987 int n; /* A counter */
13988 int iCur; /* A cursor number */
13989 SrcList *pSrcList; /* FROM clause */
13990 struct SrcCount *pSrcCount; /* Counting column references */
13991 struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
 
13992 } u;
13993 };
13994
13995 /* Forward declarations */
13996 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -14056,10 +14057,17 @@
14056 SQLITE_PRIVATE int sqlite3CantopenError(int);
14057 #define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
14058 #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
14059 #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
14060
 
 
 
 
 
 
 
14061
14062 /*
14063 ** FTS4 is really an extension for FTS3. It is enabled using the
14064 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call
14065 ** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
@@ -14432,11 +14440,11 @@
14432 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
14433 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
14434 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
14435 SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
14436 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
14437 u8,u8,int,int*);
14438 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
14439 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
14440 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
14441 SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
14442 SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
@@ -17745,18 +17753,40 @@
17745 */
17746 #define _SQLITE_OS_C_ 1
17747 /* #include "sqliteInt.h" */
17748 #undef _SQLITE_OS_C_
17749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17750 /*
17751 ** The default SQLite sqlite3_vfs implementations do not allocate
17752 ** memory (actually, os_unix.c allocates a small amount of memory
17753 ** from within OsOpen()), but some third-party implementations may.
17754 ** So we test the effects of a malloc() failing and the sqlite3OsXXX()
17755 ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.
17756 **
17757 ** The following functions are instrumented for malloc() failure
17758 ** testing:
17759 **
17760 ** sqlite3OsRead()
17761 ** sqlite3OsWrite()
17762 ** sqlite3OsSync()
@@ -17838,12 +17868,12 @@
17838 */
17839 SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
17840 #ifdef SQLITE_TEST
17841 if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){
17842 /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite
17843 ** is using a regular VFS, it is called after the corresponding
17844 ** transaction has been committed. Injecting a fault at this point
17845 ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM
17846 ** but the transaction is committed anyway.
17847 **
17848 ** The core must call OsFileControl() though, not OsFileControlHint(),
17849 ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably
@@ -17908,14 +17938,14 @@
17908 /*
17909 ** The next group of routines are convenience wrappers around the
17910 ** VFS methods.
17911 */
17912 SQLITE_PRIVATE int sqlite3OsOpen(
17913 sqlite3_vfs *pVfs,
17914 const char *zPath,
17915 sqlite3_file *pFile,
17916 int flags,
17917 int *pFlagsOut
17918 ){
17919 int rc;
17920 DO_OS_MALLOC_TEST(0);
17921 /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
@@ -17930,22 +17960,22 @@
17930 DO_OS_MALLOC_TEST(0);
17931 assert( dirSync==0 || dirSync==1 );
17932 return pVfs->xDelete(pVfs, zPath, dirSync);
17933 }
17934 SQLITE_PRIVATE int sqlite3OsAccess(
17935 sqlite3_vfs *pVfs,
17936 const char *zPath,
17937 int flags,
17938 int *pResOut
17939 ){
17940 DO_OS_MALLOC_TEST(0);
17941 return pVfs->xAccess(pVfs, zPath, flags, pResOut);
17942 }
17943 SQLITE_PRIVATE int sqlite3OsFullPathname(
17944 sqlite3_vfs *pVfs,
17945 const char *zPath,
17946 int nPathOut,
17947 char *zPathOut
17948 ){
17949 DO_OS_MALLOC_TEST(0);
17950 zPathOut[0] = 0;
17951 return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
@@ -17987,13 +18017,13 @@
17987 }
17988 return rc;
17989 }
17990
17991 SQLITE_PRIVATE int sqlite3OsOpenMalloc(
17992 sqlite3_vfs *pVfs,
17993 const char *zFile,
17994 sqlite3_file **ppFile,
17995 int flags,
17996 int *pOutFlags
17997 ){
17998 int rc = SQLITE_NOMEM;
17999 sqlite3_file *pFile;
@@ -21212,12 +21242,12 @@
21212 ** Macros for performance tracing. Normally turned off. Only works
21213 ** on i486 hardware.
21214 */
21215 #ifdef SQLITE_PERFORMANCE_TRACE
21216
21217 /*
21218 ** hwtime.h contains inline assembler code for implementing
21219 ** high-performance timing routines.
21220 */
21221 /************** Include hwtime.h in the middle of os_common.h ****************/
21222 /************** Begin file hwtime.h ******************************************/
21223 /*
@@ -21323,18 +21353,18 @@
21323 /*
21324 ** If we compile with the SQLITE_TEST macro set, then the following block
21325 ** of code will give us the ability to simulate a disk I/O error. This
21326 ** is used for testing the I/O recovery logic.
21327 */
21328 #ifdef SQLITE_TEST
21329 SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
21330 SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
21331 SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
21332 SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
21333 SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
21334 SQLITE_API int sqlite3_diskfull_pending = 0;
21335 SQLITE_API int sqlite3_diskfull = 0;
21336 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
21337 #define SimulateIOError(CODE) \
21338 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
21339 || sqlite3_io_error_pending-- == 1 ) \
21340 { local_ioerr(); CODE; }
@@ -21356,21 +21386,21 @@
21356 }
21357 #else
21358 #define SimulateIOErrorBenign(X)
21359 #define SimulateIOError(A)
21360 #define SimulateDiskfullError(A)
21361 #endif
21362
21363 /*
21364 ** When testing, keep a count of the number of open files.
21365 */
21366 #ifdef SQLITE_TEST
21367 SQLITE_API int sqlite3_open_file_count = 0;
21368 #define OpenCounter(X) sqlite3_open_file_count+=(X)
21369 #else
21370 #define OpenCounter(X)
21371 #endif
21372
21373 #endif /* !defined(_OS_COMMON_H_) */
21374
21375 /************** End of os_common.h *******************************************/
21376 /************** Continuing where we left off in mutex_w32.c ******************/
@@ -27373,12 +27403,12 @@
27373 ** Macros for performance tracing. Normally turned off. Only works
27374 ** on i486 hardware.
27375 */
27376 #ifdef SQLITE_PERFORMANCE_TRACE
27377
27378 /*
27379 ** hwtime.h contains inline assembler code for implementing
27380 ** high-performance timing routines.
27381 */
27382 /************** Include hwtime.h in the middle of os_common.h ****************/
27383 /************** Begin file hwtime.h ******************************************/
27384 /*
@@ -27484,18 +27514,18 @@
27484 /*
27485 ** If we compile with the SQLITE_TEST macro set, then the following block
27486 ** of code will give us the ability to simulate a disk I/O error. This
27487 ** is used for testing the I/O recovery logic.
27488 */
27489 #ifdef SQLITE_TEST
27490 SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
27491 SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
27492 SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
27493 SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
27494 SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
27495 SQLITE_API int sqlite3_diskfull_pending = 0;
27496 SQLITE_API int sqlite3_diskfull = 0;
27497 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
27498 #define SimulateIOError(CODE) \
27499 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
27500 || sqlite3_io_error_pending-- == 1 ) \
27501 { local_ioerr(); CODE; }
@@ -27517,21 +27547,21 @@
27517 }
27518 #else
27519 #define SimulateIOErrorBenign(X)
27520 #define SimulateIOError(A)
27521 #define SimulateDiskfullError(A)
27522 #endif
27523
27524 /*
27525 ** When testing, keep a count of the number of open files.
27526 */
27527 #ifdef SQLITE_TEST
27528 SQLITE_API int sqlite3_open_file_count = 0;
27529 #define OpenCounter(X) sqlite3_open_file_count+=(X)
27530 #else
27531 #define OpenCounter(X)
27532 #endif
27533
27534 #endif /* !defined(_OS_COMMON_H_) */
27535
27536 /************** End of os_common.h *******************************************/
27537 /************** Continuing where we left off in os_unix.c ********************/
@@ -34896,12 +34926,12 @@
34896 ** Macros for performance tracing. Normally turned off. Only works
34897 ** on i486 hardware.
34898 */
34899 #ifdef SQLITE_PERFORMANCE_TRACE
34900
34901 /*
34902 ** hwtime.h contains inline assembler code for implementing
34903 ** high-performance timing routines.
34904 */
34905 /************** Include hwtime.h in the middle of os_common.h ****************/
34906 /************** Begin file hwtime.h ******************************************/
34907 /*
@@ -35007,18 +35037,18 @@
35007 /*
35008 ** If we compile with the SQLITE_TEST macro set, then the following block
35009 ** of code will give us the ability to simulate a disk I/O error. This
35010 ** is used for testing the I/O recovery logic.
35011 */
35012 #ifdef SQLITE_TEST
35013 SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
35014 SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
35015 SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
35016 SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
35017 SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
35018 SQLITE_API int sqlite3_diskfull_pending = 0;
35019 SQLITE_API int sqlite3_diskfull = 0;
35020 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
35021 #define SimulateIOError(CODE) \
35022 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
35023 || sqlite3_io_error_pending-- == 1 ) \
35024 { local_ioerr(); CODE; }
@@ -35040,21 +35070,21 @@
35040 }
35041 #else
35042 #define SimulateIOErrorBenign(X)
35043 #define SimulateIOError(A)
35044 #define SimulateDiskfullError(A)
35045 #endif
35046
35047 /*
35048 ** When testing, keep a count of the number of open files.
35049 */
35050 #ifdef SQLITE_TEST
35051 SQLITE_API int sqlite3_open_file_count = 0;
35052 #define OpenCounter(X) sqlite3_open_file_count+=(X)
35053 #else
35054 #define OpenCounter(X)
35055 #endif
35056
35057 #endif /* !defined(_OS_COMMON_H_) */
35058
35059 /************** End of os_common.h *******************************************/
35060 /************** Continuing where we left off in os_win.c *********************/
@@ -104247,11 +104277,11 @@
104247 }else
104248 #endif
104249 {
104250 int isReplace; /* Set to true if constraints may cause a replace */
104251 sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
104252 regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace
104253 );
104254 sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);
104255 sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,
104256 regIns, aRegIdx, 0, appendFlag, isReplace==0);
104257 }
@@ -104328,10 +104358,63 @@
104328 #undef pTrigger
104329 #endif
104330 #ifdef tmask
104331 #undef tmask
104332 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104333
104334 /*
104335 ** Generate code to do constraint checks prior to an INSERT or an UPDATE
104336 ** on table pTab.
104337 **
@@ -104423,11 +104506,12 @@
104423 int regNewData, /* First register in a range holding values to insert */
104424 int regOldData, /* Previous content. 0 for INSERTs */
104425 u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */
104426 u8 overrideError, /* Override onError to this if not OE_Default */
104427 int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
104428 int *pbMayReplace /* OUT: Set to true if constraint may cause a replace */
 
104429 ){
104430 Vdbe *v; /* VDBE under constrution */
104431 Index *pIdx; /* Pointer to one of the indices */
104432 Index *pPk = 0; /* The PRIMARY KEY index */
104433 sqlite3 *db; /* Database connection */
@@ -104469,14 +104553,18 @@
104469
104470 /* Test all NOT NULL constraints.
104471 */
104472 for(i=0; i<nCol; i++){
104473 if( i==pTab->iPKey ){
 
 
 
 
104474 continue;
104475 }
104476 onError = pTab->aCol[i].notNull;
104477 if( onError==OE_None ) continue;
104478 if( overrideError!=OE_Default ){
104479 onError = overrideError;
104480 }else if( onError==OE_Default ){
104481 onError = OE_Abort;
104482 }
@@ -104521,12 +104609,15 @@
104521 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
104522 ExprList *pCheck = pTab->pCheck;
104523 pParse->ckBase = regNewData+1;
104524 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
104525 for(i=0; i<pCheck->nExpr; i++){
104526 int allOk = sqlite3VdbeMakeLabel(v);
104527 sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
 
 
 
104528 if( onError==OE_Ignore ){
104529 sqlite3VdbeGoto(v, ignoreDest);
104530 }else{
104531 char *zName = pCheck->a[i].zName;
104532 if( zName==0 ) zName = pTab->zName;
@@ -117677,11 +117768,12 @@
117677 int bReplace = 0; /* True if REPLACE conflict resolution might happen */
117678
117679 /* Do constraint checks. */
117680 assert( regOldRowid>0 );
117681 sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
117682 regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace);
 
117683
117684 /* Do FK constraint checks. */
117685 if( hasFK ){
117686 sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
117687 }
@@ -126572,11 +126664,10 @@
126572 ** Return the cost of sorting nRow rows, assuming that the keys have
126573 ** nOrderby columns and that the first nSorted columns are already in
126574 ** order.
126575 */
126576 static LogEst whereSortingCost(
126577 WhereInfo *pWInfo,
126578 LogEst nRow,
126579 int nOrderBy,
126580 int nSorted
126581 ){
126582 /* TUNING: Estimated cost of a full external sort, where N is
@@ -126594,18 +126685,10 @@
126594 ** below. */
126595 LogEst rScale, rSortCost;
126596 assert( nOrderBy>0 && 66==sqlite3LogEst(100) );
126597 rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;
126598 rSortCost = nRow + estLog(nRow) + rScale + 16;
126599
126600 /* TUNING: The cost of implementing DISTINCT using a B-TREE is
126601 ** similar but with a larger constant of proportionality.
126602 ** Multiply by an additional factor of 3.0. */
126603 if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){
126604 rSortCost += 16;
126605 }
126606
126607 return rSortCost;
126608 }
126609
126610 /*
126611 ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
@@ -126735,11 +126818,11 @@
126735 revMask = pFrom->revLoop;
126736 }
126737 if( isOrdered>=0 && isOrdered<nOrderBy ){
126738 if( aSortCost[isOrdered]==0 ){
126739 aSortCost[isOrdered] = whereSortingCost(
126740 pWInfo, nRowEst, nOrderBy, isOrdered
126741 );
126742 }
126743 rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]);
126744
126745 WHERETRACE(0x002,
@@ -137300,10 +137383,16 @@
137300 #define _FTSINT_H
137301
137302 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
137303 # define NDEBUG 1
137304 #endif
 
 
 
 
 
 
137305
137306 /*
137307 ** FTS4 is really an extension for FTS3. It is enabled using the
137308 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all
137309 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
@@ -165637,11 +165726,15 @@
165637 /* #include <assert.h> */
165638 /* #include <string.h> */
165639 /* #include <stdlib.h> */
165640 /* #include <stdarg.h> */
165641
165642 #define UNUSED_PARAM(X) (void)(X)
 
 
 
 
165643
165644 #ifndef LARGEST_INT64
165645 # define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
165646 # define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
165647 #endif
@@ -167158,10 +167251,11 @@
167158 sqlite3_context *ctx,
167159 int argc,
167160 sqlite3_value **argv
167161 ){
167162 JsonString *pStr;
 
167163 pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
167164 if( pStr ){
167165 if( pStr->zBuf==0 ){
167166 jsonInit(pStr, ctx);
167167 jsonAppendChar(pStr, '[');
@@ -167203,10 +167297,11 @@
167203 sqlite3_value **argv
167204 ){
167205 JsonString *pStr;
167206 const char *z;
167207 u32 n;
 
167208 pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
167209 if( pStr ){
167210 if( pStr->zBuf==0 ){
167211 jsonInit(pStr, ctx);
167212 jsonAppendChar(pStr, '{');
@@ -168464,10 +168559,20 @@
168464 SQLITE_API extern int sqlite3_fts5_may_be_corrupt;
168465 # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))
168466 #else
168467 # define assert_nc(x) assert(x)
168468 #endif
 
 
 
 
 
 
 
 
 
 
168469
168470 typedef struct Fts5Global Fts5Global;
168471 typedef struct Fts5Colset Fts5Colset;
168472
168473 /* If a NEAR() clump or phrase may only match a specific set of columns,
@@ -168730,20 +168835,10 @@
168730 ** Create/destroy an Fts5Index object.
168731 */
168732 static int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);
168733 static int sqlite3Fts5IndexClose(Fts5Index *p);
168734
168735 /*
168736 ** for(
168737 ** sqlite3Fts5IndexQuery(p, "token", 5, 0, 0, &pIter);
168738 ** 0==sqlite3Fts5IterEof(pIter);
168739 ** sqlite3Fts5IterNext(pIter)
168740 ** ){
168741 ** i64 iRowid = sqlite3Fts5IterRowid(pIter);
168742 ** }
168743 */
168744
168745 /*
168746 ** Return a simple checksum value based on the arguments.
168747 */
168748 static u64 sqlite3Fts5IndexEntryCksum(
168749 i64 iRowid,
@@ -168781,11 +168876,10 @@
168781 ** The various operations on open token or token prefix iterators opened
168782 ** using sqlite3Fts5IndexQuery().
168783 */
168784 static int sqlite3Fts5IterNext(Fts5IndexIter*);
168785 static int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);
168786 static i64 sqlite3Fts5IterRowid(Fts5IndexIter*);
168787
168788 /*
168789 ** Close an iterator opened by sqlite3Fts5IndexQuery().
168790 */
168791 static void sqlite3Fts5IterClose(Fts5IndexIter*);
@@ -169066,11 +169160,11 @@
169066 Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
169067 );
169068 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
169069 static void sqlite3Fts5ExprClearEof(Fts5Expr*);
169070
169071 static int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**);
169072
169073 static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
169074
169075 /*******************************************
169076 ** The fts5_expr.c API above this point is used by the other hand-written
@@ -169857,11 +169951,12 @@
169857 while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
169858 /* Here code is inserted which will execute if the parser
169859 ** stack every overflows */
169860 /******** Begin %stack_overflow code ******************************************/
169861
169862 assert( 0 );
 
169863 /******** End %stack_overflow code ********************************************/
169864 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
169865 }
169866
169867 /*
@@ -170154,10 +170249,11 @@
170154 ){
170155 sqlite3Fts5ParserARG_FETCH;
170156 #define FTS5TOKEN (fts5yyminor.fts5yy0)
170157 /************ Begin %syntax_error code ****************************************/
170158
 
170159 sqlite3Fts5ParseError(
170160 pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p
170161 );
170162 /************ End %syntax_error code ******************************************/
170163 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -170530,10 +170626,12 @@
170530 int iEndOff /* End offset of token */
170531 ){
170532 HighlightContext *p = (HighlightContext*)pContext;
170533 int rc = SQLITE_OK;
170534 int iPos;
 
 
170535
170536 if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK;
170537 iPos = p->iPos++;
170538
170539 if( p->iRangeEnd>0 ){
@@ -170764,10 +170862,11 @@
170764 const Fts5ExtensionApi *pApi,
170765 Fts5Context *pFts,
170766 void *pUserData /* Pointer to sqlite3_int64 variable */
170767 ){
170768 sqlite3_int64 *pn = (sqlite3_int64*)pUserData;
 
170769 (*pn)++;
170770 return SQLITE_OK;
170771 }
170772
170773 /*
@@ -171169,11 +171268,11 @@
171169 static int sqlite3Fts5PoslistWriterAppend(
171170 Fts5Buffer *pBuf,
171171 Fts5PoslistWriter *pWriter,
171172 i64 iPos
171173 ){
171174 int rc;
171175 if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;
171176 sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);
171177 return SQLITE_OK;
171178 }
171179
@@ -171323,13 +171422,10 @@
171323 }
171324 }
171325 sqlite3_free(p);
171326 }
171327 }
171328
171329
171330
171331
171332 /*
171333 ** 2014 Jun 09
171334 **
171335 ** The author disclaims copyright to this source code. In place of
@@ -171535,11 +171631,11 @@
171535 static int fts5ConfigSetEnum(
171536 const Fts5Enum *aEnum,
171537 const char *zEnum,
171538 int *peVal
171539 ){
171540 int nEnum = strlen(zEnum);
171541 int i;
171542 int iVal = -1;
171543
171544 for(i=0; aEnum[i].zName; i++){
171545 if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){
@@ -172273,11 +172369,10 @@
172273 pConfig->iCookie = iCookie;
172274 }
172275 return rc;
172276 }
172277
172278
172279 /*
172280 ** 2014 May 31
172281 **
172282 ** The author disclaims copyright to this source code. In place of
172283 ** a legal notice, here is a blessing:
@@ -172596,12 +172691,10 @@
172596 /*
172597 ** Argument pTerm must be a synonym iterator.
172598 */
172599 static int fts5ExprSynonymList(
172600 Fts5ExprTerm *pTerm,
172601 int bCollist,
172602 Fts5Colset *pColset,
172603 i64 iRowid,
172604 Fts5Buffer *pBuf, /* Use this buffer for space if required */
172605 u8 **pa, int *pn
172606 ){
172607 Fts5PoslistReader aStatic[4];
@@ -172681,11 +172774,10 @@
172681 ** otherwise. It is not considered an error code if the current rowid is
172682 ** not a match.
172683 */
172684 static int fts5ExprPhraseIsMatch(
172685 Fts5ExprNode *pNode, /* Node pPhrase belongs to */
172686 Fts5Colset *pColset, /* Restrict matches to these columns */
172687 Fts5ExprPhrase *pPhrase, /* Phrase object to initialize */
172688 int *pbMatch /* OUT: Set to true if really a match */
172689 ){
172690 Fts5PoslistWriter writer = {0};
172691 Fts5PoslistReader aStatic[4];
@@ -172710,13 +172802,11 @@
172710 int n = 0;
172711 int bFlag = 0;
172712 u8 *a = 0;
172713 if( pTerm->pSynonym ){
172714 Fts5Buffer buf = {0, 0, 0};
172715 rc = fts5ExprSynonymList(
172716 pTerm, 0, pColset, pNode->iRowid, &buf, &a, &n
172717 );
172718 if( rc ){
172719 sqlite3_free(a);
172720 goto ismatch_out;
172721 }
172722 if( a==buf.p ) bFlag = 1;
@@ -173003,11 +173093,11 @@
173003 ** phrase is not a match, break out of the loop early. */
173004 for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){
173005 Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];
173006 if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){
173007 int bMatch = 0;
173008 rc = fts5ExprPhraseIsMatch(pNode, pNear->pColset, pPhrase, &bMatch);
173009 if( bMatch==0 ) break;
173010 }else{
173011 Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;
173012 fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);
173013 }
@@ -173751,10 +173841,12 @@
173751 ){
173752 int rc = SQLITE_OK;
173753 const int SZALLOC = 8;
173754 TokenCtx *pCtx = (TokenCtx*)pContext;
173755 Fts5ExprPhrase *pPhrase = pCtx->pPhrase;
 
 
173756
173757 /* If an error has already occurred, this is a no-op */
173758 if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;
173759
173760 assert( pPhrase==0 || pPhrase->nTerm>0 );
@@ -173887,26 +173979,21 @@
173887 /*
173888 ** Create a new FTS5 expression by cloning phrase iPhrase of the
173889 ** expression passed as the second argument.
173890 */
173891 static int sqlite3Fts5ExprClonePhrase(
173892 Fts5Config *pConfig,
173893 Fts5Expr *pExpr,
173894 int iPhrase,
173895 Fts5Expr **ppNew
173896 ){
173897 int rc = SQLITE_OK; /* Return code */
173898 Fts5ExprPhrase *pOrig; /* The phrase extracted from pExpr */
173899 int i; /* Used to iterate through phrase terms */
173900
173901 Fts5Expr *pNew = 0; /* Expression to return via *ppNew */
173902
173903 TokenCtx sCtx = {0,0}; /* Context object for fts5ParseTokenize */
173904
173905
173906 pOrig = pExpr->apExprPhrase[iPhrase];
173907
173908 pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));
173909 if( rc==SQLITE_OK ){
173910 pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc,
173911 sizeof(Fts5ExprPhrase*));
173912 }
@@ -174675,16 +174762,18 @@
174675 static int fts5ExprPopulatePoslistsCb(
174676 void *pCtx, /* Copy of 2nd argument to xTokenize() */
174677 int tflags, /* Mask of FTS5_TOKEN_* flags */
174678 const char *pToken, /* Pointer to buffer containing token */
174679 int nToken, /* Size of token in bytes */
174680 int iStart, /* Byte offset of token within input text */
174681 int iEnd /* Byte offset of end of token within input text */
174682 ){
174683 Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx;
174684 Fts5Expr *pExpr = p->pExpr;
174685 int i;
 
 
174686
174687 if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;
174688 for(i=0; i<pExpr->nPhrase; i++){
174689 Fts5ExprTerm *pTerm;
174690 if( p->aPopulator[i].bOk==0 ) continue;
@@ -174826,11 +174915,11 @@
174826 ){
174827 Fts5ExprTerm *pTerm = &pPhrase->aTerm[0];
174828 if( pTerm->pSynonym ){
174829 Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1];
174830 rc = fts5ExprSynonymList(
174831 pTerm, 1, 0, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist
174832 );
174833 }else{
174834 *ppCollist = pPhrase->aTerm[0].pIter->pData;
174835 *pnCollist = pPhrase->aTerm[0].pIter->nData;
174836 }
@@ -175977,21 +176066,10 @@
175977 int nCmp = MIN(pLeft->n, pRight->n);
175978 int res = memcmp(pLeft->p, pRight->p, nCmp);
175979 return (res==0 ? (pLeft->n - pRight->n) : res);
175980 }
175981
175982 #ifdef SQLITE_DEBUG
175983 static int fts5BlobCompare(
175984 const u8 *pLeft, int nLeft,
175985 const u8 *pRight, int nRight
175986 ){
175987 int nCmp = MIN(nLeft, nRight);
175988 int res = memcmp(pLeft, pRight, nCmp);
175989 return (res==0 ? (nLeft - nRight) : res);
175990 }
175991 #endif
175992
175993 static int fts5LeafFirstTermOff(Fts5Data *pLeaf){
175994 int ret;
175995 fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);
175996 return ret;
175997 }
@@ -176249,28 +176327,37 @@
176249 for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){
176250 Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl];
176251 int nTotal;
176252 int iSeg;
176253
176254 i += fts5GetVarint32(&pData[i], pLvl->nMerge);
176255 i += fts5GetVarint32(&pData[i], nTotal);
176256 assert( nTotal>=pLvl->nMerge );
176257 pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
176258 nTotal * sizeof(Fts5StructureSegment)
176259 );
 
 
 
 
176260
176261 if( rc==SQLITE_OK ){
176262 pLvl->nSeg = nTotal;
176263 for(iSeg=0; iSeg<nTotal; iSeg++){
 
 
 
 
176264 i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
176265 i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
176266 i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
176267 }
176268 }else{
176269 fts5StructureRelease(pRet);
176270 pRet = 0;
176271 }
 
 
 
 
176272 }
176273 }
176274
176275 *ppOut = pRet;
176276 return rc;
@@ -176934,10 +177021,14 @@
176934 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
176935 int iOff = pIter->iLeafOffset; /* Offset to read at */
176936 int nNew; /* Bytes of new data */
176937
176938 iOff += fts5GetVarint32(&a[iOff], nNew);
 
 
 
 
176939 pIter->term.n = nKeep;
176940 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
176941 iOff += nNew;
176942 pIter->iTermLeafOffset = iOff;
176943 pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -177140,14 +177231,16 @@
177140 ** This version of fts5SegIterNext() is only used by reverse iterators.
177141 */
177142 static void fts5SegIterNext_Reverse(
177143 Fts5Index *p, /* FTS5 backend object */
177144 Fts5SegIter *pIter, /* Iterator to advance */
177145 int *pbNewTerm /* OUT: Set for new term */
177146 ){
177147 assert( pIter->flags & FTS5_SEGITER_REVERSE );
177148 assert( pIter->pNextLeaf==0 );
 
 
177149 if( pIter->iRowidOffset>0 ){
177150 u8 *a = pIter->pLeaf->p;
177151 int iOff;
177152 i64 iDelta;
177153
@@ -177620,11 +177713,10 @@
177620 ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If
177621 ** an error has already occurred when this function is called, it is a no-op.
177622 */
177623 static void fts5SegIterSeekInit(
177624 Fts5Index *p, /* FTS5 backend */
177625 Fts5Buffer *pBuf, /* Buffer to use for loading pages */
177626 const u8 *pTerm, int nTerm, /* Term to seek to */
177627 int flags, /* Mask of FTS5INDEX_XXX flags */
177628 Fts5StructureSegment *pSeg, /* Description of segment */
177629 Fts5SegIter *pIter /* Object to populate */
177630 ){
@@ -178007,11 +178099,11 @@
178007
178008
178009 /*
178010 ** Free the iterator object passed as the second argument.
178011 */
178012 static void fts5MultiIterFree(Fts5Index *p, Fts5Iter *pIter){
178013 if( pIter ){
178014 int i;
178015 for(i=0; i<pIter->nSeg; i++){
178016 fts5SegIterClear(&pIter->aSeg[i]);
178017 }
@@ -178048,11 +178140,10 @@
178048 ** If non-zero is returned, the caller should call fts5MultiIterAdvanced()
178049 ** on the iterator instead. That function does the same as this one, except
178050 ** that it deals with more complicated cases as well.
178051 */
178052 static int fts5MultiIterAdvanceRowid(
178053 Fts5Index *p, /* FTS5 backend to iterate within */
178054 Fts5Iter *pIter, /* Iterator to update aFirst[] array for */
178055 int iChanged, /* Index of sub-iterator just advanced */
178056 Fts5SegIter **ppFirst
178057 ){
178058 Fts5SegIter *pNew = &pIter->aSeg[iChanged];
@@ -178123,11 +178214,11 @@
178123 }else{
178124 pSeg->xNext(p, pSeg, &bNewTerm);
178125 }
178126
178127 if( pSeg->pLeaf==0 || bNewTerm
178128 || fts5MultiIterAdvanceRowid(p, pIter, iFirst, &pSeg)
178129 ){
178130 fts5MultiIterAdvanced(p, pIter, iFirst, 1);
178131 fts5MultiIterSetEof(pIter);
178132 pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];
178133 if( pSeg->pLeaf==0 ) return;
@@ -178156,11 +178247,11 @@
178156 int bNewTerm = 0;
178157
178158 assert( p->rc==SQLITE_OK );
178159 pSeg->xNext(p, pSeg, &bNewTerm);
178160 if( pSeg->pLeaf==0 || bNewTerm
178161 || fts5MultiIterAdvanceRowid(p, pIter, iFirst, &pSeg)
178162 ){
178163 fts5MultiIterAdvanced(p, pIter, iFirst, 1);
178164 fts5MultiIterSetEof(pIter);
178165 *pbNewTerm = 1;
178166 }else{
@@ -178170,11 +178261,12 @@
178170
178171 }while( fts5MultiIterIsEmpty(p, pIter) );
178172 }
178173 }
178174
178175 static void fts5IterSetOutputs_Noop(Fts5Iter *pIter, Fts5SegIter *pSeg){
 
178176 }
178177
178178 static Fts5Iter *fts5MultiIterAlloc(
178179 Fts5Index *p, /* FTS5 backend to iterate within */
178180 int nSeg
@@ -178196,14 +178288,15 @@
178196 }
178197 return pNew;
178198 }
178199
178200 static void fts5PoslistCallback(
178201 Fts5Index *p,
178202 void *pContext,
178203 const u8 *pChunk, int nChunk
178204 ){
 
178205 assert_nc( nChunk>=0 );
178206 if( nChunk>0 ){
178207 fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk);
178208 }
178209 }
@@ -178233,15 +178326,16 @@
178233 }
178234 return 0;
178235 }
178236
178237 static void fts5PoslistOffsetsCallback(
178238 Fts5Index *p,
178239 void *pContext,
178240 const u8 *pChunk, int nChunk
178241 ){
178242 PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext;
 
178243 assert_nc( nChunk>=0 );
178244 if( nChunk>0 ){
178245 int i = 0;
178246 while( i<nChunk ){
178247 int iVal;
@@ -178255,15 +178349,16 @@
178255 }
178256 }
178257 }
178258
178259 static void fts5PoslistFilterCallback(
178260 Fts5Index *p,
178261 void *pContext,
178262 const u8 *pChunk, int nChunk
178263 ){
178264 PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext;
 
178265 assert_nc( nChunk>=0 );
178266 if( nChunk>0 ){
178267 /* Search through to find the first varint with value 1. This is the
178268 ** start of the next columns hits. */
178269 int i = 0;
@@ -178623,11 +178718,10 @@
178623 Fts5Iter **ppOut /* New object */
178624 ){
178625 int nSeg = 0; /* Number of segment-iters in use */
178626 int iIter = 0; /* */
178627 int iSeg; /* Used to iterate through segments */
178628 Fts5Buffer buf = {0,0,0}; /* Buffer used by fts5SegIterSeekInit() */
178629 Fts5StructureLevel *pLvl;
178630 Fts5Iter *pNew;
178631
178632 assert( (pTerm==0 && nTerm==0) || iLevel<0 );
178633
@@ -178666,11 +178760,11 @@
178666 Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
178667 Fts5SegIter *pIter = &pNew->aSeg[iIter++];
178668 if( pTerm==0 ){
178669 fts5SegIterInit(p, pSeg, pIter);
178670 }else{
178671 fts5SegIterSeekInit(p, &buf, pTerm, nTerm, flags, pSeg, pIter);
178672 }
178673 }
178674 }
178675 }else{
178676 pLvl = &pStruct->aLevel[iLevel];
@@ -178703,15 +178797,13 @@
178703 Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst];
178704 pNew->xSetOutputs(pNew, pSeg);
178705 }
178706
178707 }else{
178708 fts5MultiIterFree(p, pNew);
178709 *ppOut = 0;
178710 }
178711 fts5BufferFree(&buf);
178712
178713 }
178714
178715 /*
178716 ** Create an Fts5Iter that iterates through the doclist provided
178717 ** as the second argument.
@@ -178845,19 +178937,18 @@
178845 p->nPendingData = 0;
178846 }
178847 }
178848
178849 /*
178850 ** Return the size of the prefix, in bytes, that buffer (nNew/pNew) shares
178851 ** with buffer (nOld/pOld).
 
 
 
178852 */
178853 static int fts5PrefixCompress(
178854 int nOld, const u8 *pOld,
178855 int nNew, const u8 *pNew
178856 ){
178857 int i;
178858 assert( fts5BlobCompare(pOld, nOld, pNew, nNew)<0 );
178859 for(i=0; i<nOld; i++){
178860 if( pOld[i]!=pNew[i] ) break;
178861 }
178862 return i;
178863 }
@@ -179163,17 +179254,17 @@
179163 ** In this case the previous term is not available, so just write a
179164 ** copy of (pTerm/nTerm) into the parent node. This is slightly
179165 ** inefficient, but still correct. */
179166 int n = nTerm;
179167 if( pPage->term.n ){
179168 n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, nTerm, pTerm);
179169 }
179170 fts5WriteBtreeTerm(p, pWriter, n, pTerm);
179171 pPage = &pWriter->writer;
179172 }
179173 }else{
179174 nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, nTerm, pTerm);
179175 fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
179176 }
179177
179178 /* Append the number of bytes of new data, then the term data itself
179179 ** to the page. */
@@ -179535,11 +179626,11 @@
179535 assert( pSeg->pgnoLast>0 );
179536 fts5TrimSegments(p, pIter);
179537 pLvl->nMerge = nInput;
179538 }
179539
179540 fts5MultiIterFree(p, pIter);
179541 fts5BufferFree(&term);
179542 if( pnRem ) *pnRem -= writer.nLeafWritten;
179543 }
179544
179545 /*
@@ -179911,13 +180002,14 @@
179911 }
179912
179913 static void fts5AppendRowid(
179914 Fts5Index *p,
179915 i64 iDelta,
179916 Fts5Iter *pMulti,
179917 Fts5Buffer *pBuf
179918 ){
 
179919 fts5BufferAppendVarint(&p->rc, pBuf, iDelta);
179920 }
179921
179922 static void fts5AppendPoslist(
179923 Fts5Index *p,
@@ -180256,11 +180348,11 @@
180256 if( p->rc==SQLITE_OK ){
180257 xMerge(p, &doclist, &aBuf[i]);
180258 }
180259 fts5BufferFree(&aBuf[i]);
180260 }
180261 fts5MultiIterFree(p, p1);
180262
180263 pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
180264 if( pData ){
180265 pData->p = (u8*)&pData[1];
180266 pData->nn = pData->szLeaf = doclist.n;
@@ -180537,11 +180629,11 @@
180537 }else{
180538 /* Scan multiple terms in the main index */
180539 int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
180540 buf.p[0] = FTS5_MAIN_PREFIX;
180541 fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet);
180542 assert( pRet->pColset==0 );
180543 fts5IterSetOutputCb(&p->rc, pRet);
180544 if( p->rc==SQLITE_OK ){
180545 Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
180546 if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
180547 }
@@ -180620,11 +180712,11 @@
180620 */
180621 static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
180622 if( pIndexIter ){
180623 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
180624 Fts5Index *pIndex = pIter->pIndex;
180625 fts5MultiIterFree(pIter->pIndex, pIter);
180626 fts5CloseReader(pIndex);
180627 }
180628 }
180629
180630 /*
@@ -181179,11 +181271,11 @@
181179 }
181180 }
181181 }
181182 fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
181183
181184 fts5MultiIterFree(p, pIter);
181185 if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
181186
181187 fts5StructureRelease(pStruct);
181188 #ifdef SQLITE_DEBUG
181189 fts5BufferFree(&term);
@@ -181416,10 +181508,11 @@
181416 int rc = SQLITE_OK; /* Return code */
181417 int nSpace = 0;
181418 int eDetailNone = (sqlite3_user_data(pCtx)!=0);
181419
181420 assert( nArg==2 );
 
181421 memset(&s, 0, sizeof(Fts5Buffer));
181422 iRowid = sqlite3_value_int64(apVal[0]);
181423
181424 /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]
181425 ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
@@ -182744,11 +182837,11 @@
182744 ** 3. A full-table scan.
182745 */
182746 static int fts5FilterMethod(
182747 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
182748 int idxNum, /* Strategy index */
182749 const char *idxStr, /* Unused */
182750 int nVal, /* Number of elements in apVal */
182751 sqlite3_value **apVal /* Arguments for the indexing scheme */
182752 ){
182753 Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
182754 Fts5Config *pConfig = pTab->pConfig;
@@ -182761,10 +182854,13 @@
182761 sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */
182762 sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */
182763 sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */
182764 sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */
182765 char **pzErrmsg = pConfig->pzErrmsg;
 
 
 
182766
182767 if( pCsr->ePlan ){
182768 fts5FreeCursorComponents(pCsr);
182769 memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));
182770 }
@@ -183046,12 +183142,11 @@
183046 return rc;
183047 }
183048
183049 static int fts5SpecialDelete(
183050 Fts5Table *pTab,
183051 sqlite3_value **apVal,
183052 sqlite3_int64 *piRowid
183053 ){
183054 int rc = SQLITE_OK;
183055 int eType1 = sqlite3_value_type(apVal[1]);
183056 if( eType1==SQLITE_INTEGER ){
183057 sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);
@@ -183123,11 +183218,11 @@
183123 /* A "special" INSERT op. These are handled separately. */
183124 const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]);
183125 if( pConfig->eContent!=FTS5_CONTENT_NORMAL
183126 && 0==sqlite3_stricmp("delete", z)
183127 ){
183128 rc = fts5SpecialDelete(pTab, apVal, pRowid);
183129 }else{
183130 rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
183131 }
183132 }else{
183133 /* A regular INSERT, UPDATE or DELETE statement. The trick here is that
@@ -183224,10 +183319,11 @@
183224
183225 /*
183226 ** Implementation of xBegin() method.
183227 */
183228 static int fts5BeginMethod(sqlite3_vtab *pVtab){
 
183229 fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
183230 return SQLITE_OK;
183231 }
183232
183233 /*
@@ -183234,10 +183330,11 @@
183234 ** Implementation of xCommit() method. This is a no-op. The contents of
183235 ** the pending-terms hash-table have already been flushed into the database
183236 ** by fts5SyncMethod().
183237 */
183238 static int fts5CommitMethod(sqlite3_vtab *pVtab){
 
183239 fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);
183240 return SQLITE_OK;
183241 }
183242
183243 /*
@@ -183487,16 +183584,18 @@
183487 }
183488
183489 static int fts5ColumnSizeCb(
183490 void *pContext, /* Pointer to int */
183491 int tflags,
183492 const char *pToken, /* Buffer containing token */
183493 int nToken, /* Size of token in bytes */
183494 int iStart, /* Start offset of token */
183495 int iEnd /* End offset of token */
183496 ){
183497 int *pCnt = (int*)pContext;
 
 
183498 if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){
183499 (*pCnt)++;
183500 }
183501 return SQLITE_OK;
183502 }
@@ -183608,14 +183707,15 @@
183608
183609 return pRet;
183610 }
183611
183612 static void fts5ApiPhraseNext(
183613 Fts5Context *pCtx,
183614 Fts5PhraseIter *pIter,
183615 int *piCol, int *piOff
183616 ){
 
183617 if( pIter->a>=pIter->b ){
183618 *piCol = -1;
183619 *piOff = -1;
183620 }else{
183621 int iVal;
@@ -183763,16 +183863,15 @@
183763 int rc;
183764 Fts5Cursor *pNew = 0;
183765
183766 rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);
183767 if( rc==SQLITE_OK ){
183768 Fts5Config *pConf = pTab->pConfig;
183769 pNew->ePlan = FTS5_PLAN_MATCH;
183770 pNew->iFirstRowid = SMALLEST_INT64;
183771 pNew->iLastRowid = LARGEST_INT64;
183772 pNew->base.pVtab = (sqlite3_vtab*)pTab;
183773 rc = sqlite3Fts5ExprClonePhrase(pConf, pCsr->pExpr, iPhrase, &pNew->pExpr);
183774 }
183775
183776 if( rc==SQLITE_OK ){
183777 for(rc = fts5CursorFirst(pTab, pNew, 0);
183778 rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;
@@ -183981,18 +184080,19 @@
183981 ** This routine implements the xFindFunction method for the FTS3
183982 ** virtual table.
183983 */
183984 static int fts5FindFunctionMethod(
183985 sqlite3_vtab *pVtab, /* Virtual table handle */
183986 int nArg, /* Number of SQL function arguments */
183987 const char *zName, /* Name of SQL function */
183988 void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
183989 void **ppArg /* OUT: User data for *pxFunc */
183990 ){
183991 Fts5Table *pTab = (Fts5Table*)pVtab;
183992 Fts5Auxiliary *pAux;
183993
 
183994 pAux = fts5FindAuxiliary(pTab, zName);
183995 if( pAux ){
183996 *pxFunc = fts5ApiCallback;
183997 *ppArg = (void*)pAux;
183998 return 1;
@@ -184018,10 +184118,11 @@
184018 **
184019 ** Flush the contents of the pending-terms table to disk.
184020 */
184021 static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
184022 Fts5Table *pTab = (Fts5Table*)pVtab;
 
184023 fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
184024 fts5TripCursors(pTab);
184025 return sqlite3Fts5StorageSync(pTab->pStorage, 0);
184026 }
184027
@@ -184030,10 +184131,11 @@
184030 **
184031 ** This is a no-op.
184032 */
184033 static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
184034 Fts5Table *pTab = (Fts5Table*)pVtab;
 
184035 fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
184036 fts5TripCursors(pTab);
184037 return sqlite3Fts5StorageSync(pTab->pStorage, 0);
184038 }
184039
@@ -184042,10 +184144,11 @@
184042 **
184043 ** Discard the contents of the pending terms table.
184044 */
184045 static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
184046 Fts5Table *pTab = (Fts5Table*)pVtab;
 
184047 fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
184048 fts5TripCursors(pTab);
184049 return sqlite3Fts5StorageRollback(pTab->pStorage);
184050 }
184051
@@ -184221,14 +184324,15 @@
184221 }
184222
184223 static void fts5Fts5Func(
184224 sqlite3_context *pCtx, /* Function call context */
184225 int nArg, /* Number of args */
184226 sqlite3_value **apVal /* Function arguments */
184227 ){
184228 Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);
184229 char buf[8];
 
184230 assert( nArg==0 );
184231 assert( sizeof(buf)>=sizeof(pGlobal) );
184232 memcpy(buf, (void*)&pGlobal, sizeof(pGlobal));
184233 sqlite3_result_blob(pCtx, buf, sizeof(pGlobal), SQLITE_TRANSIENT);
184234 }
@@ -184237,14 +184341,15 @@
184237 ** Implementation of fts5_source_id() function.
184238 */
184239 static void fts5SourceIdFunc(
184240 sqlite3_context *pCtx, /* Function call context */
184241 int nArg, /* Number of args */
184242 sqlite3_value **apVal /* Function arguments */
184243 ){
184244 assert( nArg==0 );
184245 sqlite3_result_text(pCtx, "fts5: 2016-02-09 18:28:20 51b6823f4c9376d549f572f5a33cac1e4c9783a2", -1, SQLITE_TRANSIENT);
 
184246 }
184247
184248 static int fts5Init(sqlite3 *db){
184249 static const sqlite3_module fts5Mod = {
184250 /* iVersion */ 2,
@@ -184709,15 +184814,16 @@
184709 static int fts5StorageInsertCallback(
184710 void *pContext, /* Pointer to Fts5InsertCtx object */
184711 int tflags,
184712 const char *pToken, /* Buffer containing token */
184713 int nToken, /* Size of token in bytes */
184714 int iStart, /* Start offset of token */
184715 int iEnd /* End offset of token */
184716 ){
184717 Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;
184718 Fts5Index *pIdx = pCtx->pStorage->pIndex;
 
184719 if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
184720 pCtx->szCol++;
184721 }
184722 return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);
184723 }
@@ -185144,20 +185250,22 @@
185144 static int fts5StorageIntegrityCallback(
185145 void *pContext, /* Pointer to Fts5IntegrityCtx object */
185146 int tflags,
185147 const char *pToken, /* Buffer containing token */
185148 int nToken, /* Size of token in bytes */
185149 int iStart, /* Start offset of token */
185150 int iEnd /* End offset of token */
185151 ){
185152 Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext;
185153 Fts5Termset *pTermset = pCtx->pTermset;
185154 int bPresent;
185155 int ii;
185156 int rc = SQLITE_OK;
185157 int iPos;
185158 int iCol;
 
 
185159
185160 if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
185161 pCtx->szCol++;
185162 }
185163
@@ -185532,16 +185640,17 @@
185532
185533 /*
185534 ** Create an "ascii" tokenizer.
185535 */
185536 static int fts5AsciiCreate(
185537 void *pCtx,
185538 const char **azArg, int nArg,
185539 Fts5Tokenizer **ppOut
185540 ){
185541 int rc = SQLITE_OK;
185542 AsciiTokenizer *p = 0;
 
185543 if( nArg%2 ){
185544 rc = SQLITE_ERROR;
185545 }else{
185546 p = sqlite3_malloc(sizeof(AsciiTokenizer));
185547 if( p==0 ){
@@ -185586,11 +185695,11 @@
185586 ** Tokenize some text using the ascii tokenizer.
185587 */
185588 static int fts5AsciiTokenize(
185589 Fts5Tokenizer *pTokenizer,
185590 void *pCtx,
185591 int flags,
185592 const char *pText, int nText,
185593 int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)
185594 ){
185595 AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer;
185596 int rc = SQLITE_OK;
@@ -185599,10 +185708,12 @@
185599
185600 char aFold[64];
185601 int nFold = sizeof(aFold);
185602 char *pFold = aFold;
185603 unsigned char *a = p->aTokenChar;
 
 
185604
185605 while( is<nText && rc==SQLITE_OK ){
185606 int nByte;
185607
185608 /* Skip any leading divider characters. */
@@ -185793,16 +185904,18 @@
185793
185794 /*
185795 ** Create a "unicode61" tokenizer.
185796 */
185797 static int fts5UnicodeCreate(
185798 void *pCtx,
185799 const char **azArg, int nArg,
185800 Fts5Tokenizer **ppOut
185801 ){
185802 int rc = SQLITE_OK; /* Return code */
185803 Unicode61Tokenizer *p = 0; /* New tokenizer object */
 
 
185804
185805 if( nArg%2 ){
185806 rc = SQLITE_ERROR;
185807 }else{
185808 p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));
@@ -185856,11 +185969,11 @@
185856 }
185857
185858 static int fts5UnicodeTokenize(
185859 Fts5Tokenizer *pTokenizer,
185860 void *pCtx,
185861 int flags,
185862 const char *pText, int nText,
185863 int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)
185864 ){
185865 Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer;
185866 int rc = SQLITE_OK;
@@ -185871,10 +185984,12 @@
185871
185872 /* Output buffer */
185873 char *aFold = p->aFold;
185874 int nFold = p->nFold;
185875 const char *pEnd = &aFold[nFold-6];
 
 
185876
185877 /* Each iteration of this loop gobbles up a contiguous run of separators,
185878 ** then the next token. */
185879 while( rc==SQLITE_OK ){
185880 int iCode; /* non-ASCII codepoint read from input */
@@ -187650,19 +187765,21 @@
187650
187651 /*
187652 ** Implementation of the xBestIndex method.
187653 */
187654 static int fts5VocabBestIndexMethod(
187655 sqlite3_vtab *pVTab,
187656 sqlite3_index_info *pInfo
187657 ){
187658 int i;
187659 int iTermEq = -1;
187660 int iTermGe = -1;
187661 int iTermLe = -1;
187662 int idxNum = 0;
187663 int nArg = 0;
 
 
187664
187665 for(i=0; i<pInfo->nConstraint; i++){
187666 struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
187667 if( p->usable==0 ) continue;
187668 if( p->iColumn==0 ){ /* term column */
@@ -187901,12 +188018,12 @@
187901 ** This is the xFilter implementation for the virtual table.
187902 */
187903 static int fts5VocabFilterMethod(
187904 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
187905 int idxNum, /* Strategy index */
187906 const char *idxStr, /* Unused */
187907 int nVal, /* Number of elements in apVal */
187908 sqlite3_value **apVal /* Arguments for the indexing scheme */
187909 ){
187910 Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
187911 int rc = SQLITE_OK;
187912
@@ -187916,10 +188033,12 @@
187916 int nTerm = 0;
187917
187918 sqlite3_value *pEq = 0;
187919 sqlite3_value *pGe = 0;
187920 sqlite3_value *pLe = 0;
 
 
187921
187922 fts5VocabResetCursor(pCsr);
187923 if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++];
187924 if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++];
187925 if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++];
187926
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -328,11 +328,11 @@
328 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
329 ** [sqlite_version()] and [sqlite_source_id()].
330 */
331 #define SQLITE_VERSION "3.11.0"
332 #define SQLITE_VERSION_NUMBER 3011000
333 #define SQLITE_SOURCE_ID "2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc"
334
335 /*
336 ** CAPI3REF: Run-Time Library Version Numbers
337 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
338 **
@@ -13987,10 +13987,11 @@
13987 int n; /* A counter */
13988 int iCur; /* A cursor number */
13989 SrcList *pSrcList; /* FROM clause */
13990 struct SrcCount *pSrcCount; /* Counting column references */
13991 struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
13992 int *aiCol; /* array of column indexes */
13993 } u;
13994 };
13995
13996 /* Forward declarations */
13997 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -14056,10 +14057,17 @@
14057 SQLITE_PRIVATE int sqlite3CantopenError(int);
14058 #define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
14059 #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
14060 #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
14061
14062 /*
14063 ** FTS3 and FTS4 both require virtual table support
14064 */
14065 #if defined(SQLITE_OMIT_VIRTUALTABLE)
14066 # undef SQLITE_ENABLE_FTS3
14067 # undef SQLITE_ENABLE_FTS4
14068 #endif
14069
14070 /*
14071 ** FTS4 is really an extension for FTS3. It is enabled using the
14072 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call
14073 ** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
@@ -14432,11 +14440,11 @@
14440 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
14441 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
14442 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
14443 SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
14444 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
14445 u8,u8,int,int*,int*);
14446 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
14447 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
14448 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
14449 SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
14450 SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
@@ -17745,18 +17753,40 @@
17753 */
17754 #define _SQLITE_OS_C_ 1
17755 /* #include "sqliteInt.h" */
17756 #undef _SQLITE_OS_C_
17757
17758 /*
17759 ** If we compile with the SQLITE_TEST macro set, then the following block
17760 ** of code will give us the ability to simulate a disk I/O error. This
17761 ** is used for testing the I/O recovery logic.
17762 */
17763 #if defined(SQLITE_TEST)
17764 SQLITE_API int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
17765 SQLITE_API int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
17766 SQLITE_API int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
17767 SQLITE_API int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
17768 SQLITE_API int sqlite3_io_error_benign = 0; /* True if errors are benign */
17769 SQLITE_API int sqlite3_diskfull_pending = 0;
17770 SQLITE_API int sqlite3_diskfull = 0;
17771 #endif /* defined(SQLITE_TEST) */
17772
17773 /*
17774 ** When testing, also keep a count of the number of open files.
17775 */
17776 #if defined(SQLITE_TEST)
17777 SQLITE_API int sqlite3_open_file_count = 0;
17778 #endif /* defined(SQLITE_TEST) */
17779
17780 /*
17781 ** The default SQLite sqlite3_vfs implementations do not allocate
17782 ** memory (actually, os_unix.c allocates a small amount of memory
17783 ** from within OsOpen()), but some third-party implementations may.
17784 ** So we test the effects of a malloc() failing and the sqlite3OsXXX()
17785 ** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.
17786 **
17787 ** The following functions are instrumented for malloc() failure
17788 ** testing:
17789 **
17790 ** sqlite3OsRead()
17791 ** sqlite3OsWrite()
17792 ** sqlite3OsSync()
@@ -17838,12 +17868,12 @@
17868 */
17869 SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
17870 #ifdef SQLITE_TEST
17871 if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){
17872 /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite
17873 ** is using a regular VFS, it is called after the corresponding
17874 ** transaction has been committed. Injecting a fault at this point
17875 ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM
17876 ** but the transaction is committed anyway.
17877 **
17878 ** The core must call OsFileControl() though, not OsFileControlHint(),
17879 ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably
@@ -17908,14 +17938,14 @@
17938 /*
17939 ** The next group of routines are convenience wrappers around the
17940 ** VFS methods.
17941 */
17942 SQLITE_PRIVATE int sqlite3OsOpen(
17943 sqlite3_vfs *pVfs,
17944 const char *zPath,
17945 sqlite3_file *pFile,
17946 int flags,
17947 int *pFlagsOut
17948 ){
17949 int rc;
17950 DO_OS_MALLOC_TEST(0);
17951 /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
@@ -17930,22 +17960,22 @@
17960 DO_OS_MALLOC_TEST(0);
17961 assert( dirSync==0 || dirSync==1 );
17962 return pVfs->xDelete(pVfs, zPath, dirSync);
17963 }
17964 SQLITE_PRIVATE int sqlite3OsAccess(
17965 sqlite3_vfs *pVfs,
17966 const char *zPath,
17967 int flags,
17968 int *pResOut
17969 ){
17970 DO_OS_MALLOC_TEST(0);
17971 return pVfs->xAccess(pVfs, zPath, flags, pResOut);
17972 }
17973 SQLITE_PRIVATE int sqlite3OsFullPathname(
17974 sqlite3_vfs *pVfs,
17975 const char *zPath,
17976 int nPathOut,
17977 char *zPathOut
17978 ){
17979 DO_OS_MALLOC_TEST(0);
17980 zPathOut[0] = 0;
17981 return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
@@ -17987,13 +18017,13 @@
18017 }
18018 return rc;
18019 }
18020
18021 SQLITE_PRIVATE int sqlite3OsOpenMalloc(
18022 sqlite3_vfs *pVfs,
18023 const char *zFile,
18024 sqlite3_file **ppFile,
18025 int flags,
18026 int *pOutFlags
18027 ){
18028 int rc = SQLITE_NOMEM;
18029 sqlite3_file *pFile;
@@ -21212,12 +21242,12 @@
21242 ** Macros for performance tracing. Normally turned off. Only works
21243 ** on i486 hardware.
21244 */
21245 #ifdef SQLITE_PERFORMANCE_TRACE
21246
21247 /*
21248 ** hwtime.h contains inline assembler code for implementing
21249 ** high-performance timing routines.
21250 */
21251 /************** Include hwtime.h in the middle of os_common.h ****************/
21252 /************** Begin file hwtime.h ******************************************/
21253 /*
@@ -21323,18 +21353,18 @@
21353 /*
21354 ** If we compile with the SQLITE_TEST macro set, then the following block
21355 ** of code will give us the ability to simulate a disk I/O error. This
21356 ** is used for testing the I/O recovery logic.
21357 */
21358 #if defined(SQLITE_TEST)
21359 SQLITE_API extern int sqlite3_io_error_hit;
21360 SQLITE_API extern int sqlite3_io_error_hardhit;
21361 SQLITE_API extern int sqlite3_io_error_pending;
21362 SQLITE_API extern int sqlite3_io_error_persist;
21363 SQLITE_API extern int sqlite3_io_error_benign;
21364 SQLITE_API extern int sqlite3_diskfull_pending;
21365 SQLITE_API extern int sqlite3_diskfull;
21366 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
21367 #define SimulateIOError(CODE) \
21368 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
21369 || sqlite3_io_error_pending-- == 1 ) \
21370 { local_ioerr(); CODE; }
@@ -21356,21 +21386,21 @@
21386 }
21387 #else
21388 #define SimulateIOErrorBenign(X)
21389 #define SimulateIOError(A)
21390 #define SimulateDiskfullError(A)
21391 #endif /* defined(SQLITE_TEST) */
21392
21393 /*
21394 ** When testing, keep a count of the number of open files.
21395 */
21396 #if defined(SQLITE_TEST)
21397 SQLITE_API extern int sqlite3_open_file_count;
21398 #define OpenCounter(X) sqlite3_open_file_count+=(X)
21399 #else
21400 #define OpenCounter(X)
21401 #endif /* defined(SQLITE_TEST) */
21402
21403 #endif /* !defined(_OS_COMMON_H_) */
21404
21405 /************** End of os_common.h *******************************************/
21406 /************** Continuing where we left off in mutex_w32.c ******************/
@@ -27373,12 +27403,12 @@
27403 ** Macros for performance tracing. Normally turned off. Only works
27404 ** on i486 hardware.
27405 */
27406 #ifdef SQLITE_PERFORMANCE_TRACE
27407
27408 /*
27409 ** hwtime.h contains inline assembler code for implementing
27410 ** high-performance timing routines.
27411 */
27412 /************** Include hwtime.h in the middle of os_common.h ****************/
27413 /************** Begin file hwtime.h ******************************************/
27414 /*
@@ -27484,18 +27514,18 @@
27514 /*
27515 ** If we compile with the SQLITE_TEST macro set, then the following block
27516 ** of code will give us the ability to simulate a disk I/O error. This
27517 ** is used for testing the I/O recovery logic.
27518 */
27519 #if defined(SQLITE_TEST)
27520 SQLITE_API extern int sqlite3_io_error_hit;
27521 SQLITE_API extern int sqlite3_io_error_hardhit;
27522 SQLITE_API extern int sqlite3_io_error_pending;
27523 SQLITE_API extern int sqlite3_io_error_persist;
27524 SQLITE_API extern int sqlite3_io_error_benign;
27525 SQLITE_API extern int sqlite3_diskfull_pending;
27526 SQLITE_API extern int sqlite3_diskfull;
27527 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
27528 #define SimulateIOError(CODE) \
27529 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
27530 || sqlite3_io_error_pending-- == 1 ) \
27531 { local_ioerr(); CODE; }
@@ -27517,21 +27547,21 @@
27547 }
27548 #else
27549 #define SimulateIOErrorBenign(X)
27550 #define SimulateIOError(A)
27551 #define SimulateDiskfullError(A)
27552 #endif /* defined(SQLITE_TEST) */
27553
27554 /*
27555 ** When testing, keep a count of the number of open files.
27556 */
27557 #if defined(SQLITE_TEST)
27558 SQLITE_API extern int sqlite3_open_file_count;
27559 #define OpenCounter(X) sqlite3_open_file_count+=(X)
27560 #else
27561 #define OpenCounter(X)
27562 #endif /* defined(SQLITE_TEST) */
27563
27564 #endif /* !defined(_OS_COMMON_H_) */
27565
27566 /************** End of os_common.h *******************************************/
27567 /************** Continuing where we left off in os_unix.c ********************/
@@ -34896,12 +34926,12 @@
34926 ** Macros for performance tracing. Normally turned off. Only works
34927 ** on i486 hardware.
34928 */
34929 #ifdef SQLITE_PERFORMANCE_TRACE
34930
34931 /*
34932 ** hwtime.h contains inline assembler code for implementing
34933 ** high-performance timing routines.
34934 */
34935 /************** Include hwtime.h in the middle of os_common.h ****************/
34936 /************** Begin file hwtime.h ******************************************/
34937 /*
@@ -35007,18 +35037,18 @@
35037 /*
35038 ** If we compile with the SQLITE_TEST macro set, then the following block
35039 ** of code will give us the ability to simulate a disk I/O error. This
35040 ** is used for testing the I/O recovery logic.
35041 */
35042 #if defined(SQLITE_TEST)
35043 SQLITE_API extern int sqlite3_io_error_hit;
35044 SQLITE_API extern int sqlite3_io_error_hardhit;
35045 SQLITE_API extern int sqlite3_io_error_pending;
35046 SQLITE_API extern int sqlite3_io_error_persist;
35047 SQLITE_API extern int sqlite3_io_error_benign;
35048 SQLITE_API extern int sqlite3_diskfull_pending;
35049 SQLITE_API extern int sqlite3_diskfull;
35050 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
35051 #define SimulateIOError(CODE) \
35052 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
35053 || sqlite3_io_error_pending-- == 1 ) \
35054 { local_ioerr(); CODE; }
@@ -35040,21 +35070,21 @@
35070 }
35071 #else
35072 #define SimulateIOErrorBenign(X)
35073 #define SimulateIOError(A)
35074 #define SimulateDiskfullError(A)
35075 #endif /* defined(SQLITE_TEST) */
35076
35077 /*
35078 ** When testing, keep a count of the number of open files.
35079 */
35080 #if defined(SQLITE_TEST)
35081 SQLITE_API extern int sqlite3_open_file_count;
35082 #define OpenCounter(X) sqlite3_open_file_count+=(X)
35083 #else
35084 #define OpenCounter(X)
35085 #endif /* defined(SQLITE_TEST) */
35086
35087 #endif /* !defined(_OS_COMMON_H_) */
35088
35089 /************** End of os_common.h *******************************************/
35090 /************** Continuing where we left off in os_win.c *********************/
@@ -104247,11 +104277,11 @@
104277 }else
104278 #endif
104279 {
104280 int isReplace; /* Set to true if constraints may cause a replace */
104281 sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
104282 regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0
104283 );
104284 sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);
104285 sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,
104286 regIns, aRegIdx, 0, appendFlag, isReplace==0);
104287 }
@@ -104328,10 +104358,63 @@
104358 #undef pTrigger
104359 #endif
104360 #ifdef tmask
104361 #undef tmask
104362 #endif
104363
104364 /*
104365 ** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged()
104366 */
104367 #define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */
104368 #define CKCNSTRNT_ROWID 0x02 /* CHECK constraint references the ROWID */
104369
104370 /* This is the Walker callback from checkConstraintUnchanged(). Set
104371 ** bit 0x01 of pWalker->eCode if
104372 ** pWalker->eCode to 0 if this expression node references any of the
104373 ** columns that are being modifed by an UPDATE statement.
104374 */
104375 static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){
104376 if( pExpr->op==TK_COLUMN ){
104377 assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );
104378 if( pExpr->iColumn>=0 ){
104379 if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){
104380 pWalker->eCode |= CKCNSTRNT_COLUMN;
104381 }
104382 }else{
104383 pWalker->eCode |= CKCNSTRNT_ROWID;
104384 }
104385 }
104386 return WRC_Continue;
104387 }
104388
104389 /*
104390 ** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The
104391 ** only columns that are modified by the UPDATE are those for which
104392 ** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.
104393 **
104394 ** Return true if CHECK constraint pExpr does not use any of the
104395 ** changing columns (or the rowid if it is changing). In other words,
104396 ** return true if this CHECK constraint can be skipped when validating
104397 ** the new row in the UPDATE statement.
104398 */
104399 static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
104400 Walker w;
104401 memset(&w, 0, sizeof(w));
104402 w.eCode = 0;
104403 w.xExprCallback = checkConstraintExprNode;
104404 w.u.aiCol = aiChng;
104405 sqlite3WalkExpr(&w, pExpr);
104406 if( !chngRowid ){
104407 testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 );
104408 w.eCode &= ~CKCNSTRNT_ROWID;
104409 }
104410 testcase( w.eCode==0 );
104411 testcase( w.eCode==CKCNSTRNT_COLUMN );
104412 testcase( w.eCode==CKCNSTRNT_ROWID );
104413 testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
104414 return !w.eCode;
104415 }
104416
104417 /*
104418 ** Generate code to do constraint checks prior to an INSERT or an UPDATE
104419 ** on table pTab.
104420 **
@@ -104423,11 +104506,12 @@
104506 int regNewData, /* First register in a range holding values to insert */
104507 int regOldData, /* Previous content. 0 for INSERTs */
104508 u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */
104509 u8 overrideError, /* Override onError to this if not OE_Default */
104510 int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
104511 int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */
104512 int *aiChng /* column i is unchanged if aiChng[i]<0 */
104513 ){
104514 Vdbe *v; /* VDBE under constrution */
104515 Index *pIdx; /* Pointer to one of the indices */
104516 Index *pPk = 0; /* The PRIMARY KEY index */
104517 sqlite3 *db; /* Database connection */
@@ -104469,14 +104553,18 @@
104553
104554 /* Test all NOT NULL constraints.
104555 */
104556 for(i=0; i<nCol; i++){
104557 if( i==pTab->iPKey ){
104558 continue; /* ROWID is never NULL */
104559 }
104560 if( aiChng && aiChng[i]<0 ){
104561 /* Don't bother checking for NOT NULL on columns that do not change */
104562 continue;
104563 }
104564 onError = pTab->aCol[i].notNull;
104565 if( onError==OE_None ) continue; /* This column is allowed to be NULL */
104566 if( overrideError!=OE_Default ){
104567 onError = overrideError;
104568 }else if( onError==OE_Default ){
104569 onError = OE_Abort;
104570 }
@@ -104521,12 +104609,15 @@
104609 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
104610 ExprList *pCheck = pTab->pCheck;
104611 pParse->ckBase = regNewData+1;
104612 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
104613 for(i=0; i<pCheck->nExpr; i++){
104614 int allOk;
104615 Expr *pExpr = pCheck->a[i].pExpr;
104616 if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
104617 allOk = sqlite3VdbeMakeLabel(v);
104618 sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
104619 if( onError==OE_Ignore ){
104620 sqlite3VdbeGoto(v, ignoreDest);
104621 }else{
104622 char *zName = pCheck->a[i].zName;
104623 if( zName==0 ) zName = pTab->zName;
@@ -117677,11 +117768,12 @@
117768 int bReplace = 0; /* True if REPLACE conflict resolution might happen */
117769
117770 /* Do constraint checks. */
117771 assert( regOldRowid>0 );
117772 sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
117773 regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
117774 aXRef);
117775
117776 /* Do FK constraint checks. */
117777 if( hasFK ){
117778 sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
117779 }
@@ -126572,11 +126664,10 @@
126664 ** Return the cost of sorting nRow rows, assuming that the keys have
126665 ** nOrderby columns and that the first nSorted columns are already in
126666 ** order.
126667 */
126668 static LogEst whereSortingCost(
 
126669 LogEst nRow,
126670 int nOrderBy,
126671 int nSorted
126672 ){
126673 /* TUNING: Estimated cost of a full external sort, where N is
@@ -126594,18 +126685,10 @@
126685 ** below. */
126686 LogEst rScale, rSortCost;
126687 assert( nOrderBy>0 && 66==sqlite3LogEst(100) );
126688 rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;
126689 rSortCost = nRow + estLog(nRow) + rScale + 16;
 
 
 
 
 
 
 
 
126690 return rSortCost;
126691 }
126692
126693 /*
126694 ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
@@ -126735,11 +126818,11 @@
126818 revMask = pFrom->revLoop;
126819 }
126820 if( isOrdered>=0 && isOrdered<nOrderBy ){
126821 if( aSortCost[isOrdered]==0 ){
126822 aSortCost[isOrdered] = whereSortingCost(
126823 nRowEst, nOrderBy, isOrdered
126824 );
126825 }
126826 rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]);
126827
126828 WHERETRACE(0x002,
@@ -137300,10 +137383,16 @@
137383 #define _FTSINT_H
137384
137385 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
137386 # define NDEBUG 1
137387 #endif
137388
137389 /* FTS3/FTS4 require virtual tables */
137390 #ifdef SQLITE_OMIT_VIRTUALTABLE
137391 # undef SQLITE_ENABLE_FTS3
137392 # undef SQLITE_ENABLE_FTS4
137393 #endif
137394
137395 /*
137396 ** FTS4 is really an extension for FTS3. It is enabled using the
137397 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all
137398 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
@@ -165637,11 +165726,15 @@
165726 /* #include <assert.h> */
165727 /* #include <string.h> */
165728 /* #include <stdlib.h> */
165729 /* #include <stdarg.h> */
165730
165731 /* Mark a function parameter as unused, to suppress nuisance compiler
165732 ** warnings. */
165733 #ifndef UNUSED_PARAM
165734 # define UNUSED_PARAM(X) (void)(X)
165735 #endif
165736
165737 #ifndef LARGEST_INT64
165738 # define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
165739 # define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
165740 #endif
@@ -167158,10 +167251,11 @@
167251 sqlite3_context *ctx,
167252 int argc,
167253 sqlite3_value **argv
167254 ){
167255 JsonString *pStr;
167256 UNUSED_PARAM(argc);
167257 pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
167258 if( pStr ){
167259 if( pStr->zBuf==0 ){
167260 jsonInit(pStr, ctx);
167261 jsonAppendChar(pStr, '[');
@@ -167203,10 +167297,11 @@
167297 sqlite3_value **argv
167298 ){
167299 JsonString *pStr;
167300 const char *z;
167301 u32 n;
167302 UNUSED_PARAM(argc);
167303 pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
167304 if( pStr ){
167305 if( pStr->zBuf==0 ){
167306 jsonInit(pStr, ctx);
167307 jsonAppendChar(pStr, '{');
@@ -168464,10 +168559,20 @@
168559 SQLITE_API extern int sqlite3_fts5_may_be_corrupt;
168560 # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))
168561 #else
168562 # define assert_nc(x) assert(x)
168563 #endif
168564
168565 /* Mark a function parameter as unused, to suppress nuisance compiler
168566 ** warnings. */
168567 #ifndef UNUSED_PARAM
168568 # define UNUSED_PARAM(X) (void)(X)
168569 #endif
168570
168571 #ifndef UNUSED_PARAM2
168572 # define UNUSED_PARAM2(X, Y) (void)(X), (void)(Y)
168573 #endif
168574
168575 typedef struct Fts5Global Fts5Global;
168576 typedef struct Fts5Colset Fts5Colset;
168577
168578 /* If a NEAR() clump or phrase may only match a specific set of columns,
@@ -168730,20 +168835,10 @@
168835 ** Create/destroy an Fts5Index object.
168836 */
168837 static int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);
168838 static int sqlite3Fts5IndexClose(Fts5Index *p);
168839
 
 
 
 
 
 
 
 
 
 
168840 /*
168841 ** Return a simple checksum value based on the arguments.
168842 */
168843 static u64 sqlite3Fts5IndexEntryCksum(
168844 i64 iRowid,
@@ -168781,11 +168876,10 @@
168876 ** The various operations on open token or token prefix iterators opened
168877 ** using sqlite3Fts5IndexQuery().
168878 */
168879 static int sqlite3Fts5IterNext(Fts5IndexIter*);
168880 static int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);
 
168881
168882 /*
168883 ** Close an iterator opened by sqlite3Fts5IndexQuery().
168884 */
168885 static void sqlite3Fts5IterClose(Fts5IndexIter*);
@@ -169066,11 +169160,11 @@
169160 Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
169161 );
169162 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
169163 static void sqlite3Fts5ExprClearEof(Fts5Expr*);
169164
169165 static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
169166
169167 static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
169168
169169 /*******************************************
169170 ** The fts5_expr.c API above this point is used by the other hand-written
@@ -169857,11 +169951,12 @@
169951 while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
169952 /* Here code is inserted which will execute if the parser
169953 ** stack every overflows */
169954 /******** Begin %stack_overflow code ******************************************/
169955
169956 UNUSED_PARAM(fts5yypMinor); /* Silence a compiler warning */
169957 sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
169958 /******** End %stack_overflow code ********************************************/
169959 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
169960 }
169961
169962 /*
@@ -170154,10 +170249,11 @@
170249 ){
170250 sqlite3Fts5ParserARG_FETCH;
170251 #define FTS5TOKEN (fts5yyminor.fts5yy0)
170252 /************ Begin %syntax_error code ****************************************/
170253
170254 UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */
170255 sqlite3Fts5ParseError(
170256 pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p
170257 );
170258 /************ End %syntax_error code ******************************************/
170259 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -170530,10 +170626,12 @@
170626 int iEndOff /* End offset of token */
170627 ){
170628 HighlightContext *p = (HighlightContext*)pContext;
170629 int rc = SQLITE_OK;
170630 int iPos;
170631
170632 UNUSED_PARAM2(pToken, nToken);
170633
170634 if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK;
170635 iPos = p->iPos++;
170636
170637 if( p->iRangeEnd>0 ){
@@ -170764,10 +170862,11 @@
170862 const Fts5ExtensionApi *pApi,
170863 Fts5Context *pFts,
170864 void *pUserData /* Pointer to sqlite3_int64 variable */
170865 ){
170866 sqlite3_int64 *pn = (sqlite3_int64*)pUserData;
170867 UNUSED_PARAM2(pApi, pFts);
170868 (*pn)++;
170869 return SQLITE_OK;
170870 }
170871
170872 /*
@@ -171169,11 +171268,11 @@
171268 static int sqlite3Fts5PoslistWriterAppend(
171269 Fts5Buffer *pBuf,
171270 Fts5PoslistWriter *pWriter,
171271 i64 iPos
171272 ){
171273 int rc = 0; /* Initialized only to suppress erroneous warning from Clang */
171274 if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;
171275 sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);
171276 return SQLITE_OK;
171277 }
171278
@@ -171323,13 +171422,10 @@
171422 }
171423 }
171424 sqlite3_free(p);
171425 }
171426 }
 
 
 
171427
171428 /*
171429 ** 2014 Jun 09
171430 **
171431 ** The author disclaims copyright to this source code. In place of
@@ -171535,11 +171631,11 @@
171631 static int fts5ConfigSetEnum(
171632 const Fts5Enum *aEnum,
171633 const char *zEnum,
171634 int *peVal
171635 ){
171636 int nEnum = (int)strlen(zEnum);
171637 int i;
171638 int iVal = -1;
171639
171640 for(i=0; aEnum[i].zName; i++){
171641 if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){
@@ -172273,11 +172369,10 @@
172369 pConfig->iCookie = iCookie;
172370 }
172371 return rc;
172372 }
172373
 
172374 /*
172375 ** 2014 May 31
172376 **
172377 ** The author disclaims copyright to this source code. In place of
172378 ** a legal notice, here is a blessing:
@@ -172596,12 +172691,10 @@
172691 /*
172692 ** Argument pTerm must be a synonym iterator.
172693 */
172694 static int fts5ExprSynonymList(
172695 Fts5ExprTerm *pTerm,
 
 
172696 i64 iRowid,
172697 Fts5Buffer *pBuf, /* Use this buffer for space if required */
172698 u8 **pa, int *pn
172699 ){
172700 Fts5PoslistReader aStatic[4];
@@ -172681,11 +172774,10 @@
172774 ** otherwise. It is not considered an error code if the current rowid is
172775 ** not a match.
172776 */
172777 static int fts5ExprPhraseIsMatch(
172778 Fts5ExprNode *pNode, /* Node pPhrase belongs to */
 
172779 Fts5ExprPhrase *pPhrase, /* Phrase object to initialize */
172780 int *pbMatch /* OUT: Set to true if really a match */
172781 ){
172782 Fts5PoslistWriter writer = {0};
172783 Fts5PoslistReader aStatic[4];
@@ -172710,13 +172802,11 @@
172802 int n = 0;
172803 int bFlag = 0;
172804 u8 *a = 0;
172805 if( pTerm->pSynonym ){
172806 Fts5Buffer buf = {0, 0, 0};
172807 rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n);
 
 
172808 if( rc ){
172809 sqlite3_free(a);
172810 goto ismatch_out;
172811 }
172812 if( a==buf.p ) bFlag = 1;
@@ -173003,11 +173093,11 @@
173093 ** phrase is not a match, break out of the loop early. */
173094 for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){
173095 Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];
173096 if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){
173097 int bMatch = 0;
173098 rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch);
173099 if( bMatch==0 ) break;
173100 }else{
173101 Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;
173102 fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);
173103 }
@@ -173751,10 +173841,12 @@
173841 ){
173842 int rc = SQLITE_OK;
173843 const int SZALLOC = 8;
173844 TokenCtx *pCtx = (TokenCtx*)pContext;
173845 Fts5ExprPhrase *pPhrase = pCtx->pPhrase;
173846
173847 UNUSED_PARAM2(iUnused1, iUnused2);
173848
173849 /* If an error has already occurred, this is a no-op */
173850 if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;
173851
173852 assert( pPhrase==0 || pPhrase->nTerm>0 );
@@ -173887,26 +173979,21 @@
173979 /*
173980 ** Create a new FTS5 expression by cloning phrase iPhrase of the
173981 ** expression passed as the second argument.
173982 */
173983 static int sqlite3Fts5ExprClonePhrase(
 
173984 Fts5Expr *pExpr,
173985 int iPhrase,
173986 Fts5Expr **ppNew
173987 ){
173988 int rc = SQLITE_OK; /* Return code */
173989 Fts5ExprPhrase *pOrig; /* The phrase extracted from pExpr */
173990 int i; /* Used to iterate through phrase terms */
 
173991 Fts5Expr *pNew = 0; /* Expression to return via *ppNew */
 
173992 TokenCtx sCtx = {0,0}; /* Context object for fts5ParseTokenize */
173993
 
173994 pOrig = pExpr->apExprPhrase[iPhrase];
 
173995 pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));
173996 if( rc==SQLITE_OK ){
173997 pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc,
173998 sizeof(Fts5ExprPhrase*));
173999 }
@@ -174675,16 +174762,18 @@
174762 static int fts5ExprPopulatePoslistsCb(
174763 void *pCtx, /* Copy of 2nd argument to xTokenize() */
174764 int tflags, /* Mask of FTS5_TOKEN_* flags */
174765 const char *pToken, /* Pointer to buffer containing token */
174766 int nToken, /* Size of token in bytes */
174767 int iUnused1, /* Byte offset of token within input text */
174768 int iUnused2 /* Byte offset of end of token within input text */
174769 ){
174770 Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx;
174771 Fts5Expr *pExpr = p->pExpr;
174772 int i;
174773
174774 UNUSED_PARAM2(iUnused1, iUnused2);
174775
174776 if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;
174777 for(i=0; i<pExpr->nPhrase; i++){
174778 Fts5ExprTerm *pTerm;
174779 if( p->aPopulator[i].bOk==0 ) continue;
@@ -174826,11 +174915,11 @@
174915 ){
174916 Fts5ExprTerm *pTerm = &pPhrase->aTerm[0];
174917 if( pTerm->pSynonym ){
174918 Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1];
174919 rc = fts5ExprSynonymList(
174920 pTerm, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist
174921 );
174922 }else{
174923 *ppCollist = pPhrase->aTerm[0].pIter->pData;
174924 *pnCollist = pPhrase->aTerm[0].pIter->nData;
174925 }
@@ -175977,21 +176066,10 @@
176066 int nCmp = MIN(pLeft->n, pRight->n);
176067 int res = memcmp(pLeft->p, pRight->p, nCmp);
176068 return (res==0 ? (pLeft->n - pRight->n) : res);
176069 }
176070
 
 
 
 
 
 
 
 
 
 
 
176071 static int fts5LeafFirstTermOff(Fts5Data *pLeaf){
176072 int ret;
176073 fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);
176074 return ret;
176075 }
@@ -176249,28 +176327,37 @@
176327 for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){
176328 Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl];
176329 int nTotal;
176330 int iSeg;
176331
176332 if( i>=nData ){
176333 rc = FTS5_CORRUPT;
176334 }else{
176335 i += fts5GetVarint32(&pData[i], pLvl->nMerge);
176336 i += fts5GetVarint32(&pData[i], nTotal);
176337 assert( nTotal>=pLvl->nMerge );
176338 pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
176339 nTotal * sizeof(Fts5StructureSegment)
176340 );
176341 }
176342
176343 if( rc==SQLITE_OK ){
176344 pLvl->nSeg = nTotal;
176345 for(iSeg=0; iSeg<nTotal; iSeg++){
176346 if( i>=nData ){
176347 rc = FTS5_CORRUPT;
176348 break;
176349 }
176350 i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
176351 i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
176352 i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
176353 }
 
 
 
176354 }
176355 }
176356 if( rc!=SQLITE_OK ){
176357 fts5StructureRelease(pRet);
176358 pRet = 0;
176359 }
176360 }
176361
176362 *ppOut = pRet;
176363 return rc;
@@ -176934,10 +177021,14 @@
177021 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
177022 int iOff = pIter->iLeafOffset; /* Offset to read at */
177023 int nNew; /* Bytes of new data */
177024
177025 iOff += fts5GetVarint32(&a[iOff], nNew);
177026 if( iOff+nNew>pIter->pLeaf->nn ){
177027 p->rc = FTS5_CORRUPT;
177028 return;
177029 }
177030 pIter->term.n = nKeep;
177031 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
177032 iOff += nNew;
177033 pIter->iTermLeafOffset = iOff;
177034 pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -177140,14 +177231,16 @@
177231 ** This version of fts5SegIterNext() is only used by reverse iterators.
177232 */
177233 static void fts5SegIterNext_Reverse(
177234 Fts5Index *p, /* FTS5 backend object */
177235 Fts5SegIter *pIter, /* Iterator to advance */
177236 int *pbUnused /* Unused */
177237 ){
177238 assert( pIter->flags & FTS5_SEGITER_REVERSE );
177239 assert( pIter->pNextLeaf==0 );
177240 UNUSED_PARAM(pbUnused);
177241
177242 if( pIter->iRowidOffset>0 ){
177243 u8 *a = pIter->pLeaf->p;
177244 int iOff;
177245 i64 iDelta;
177246
@@ -177620,11 +177713,10 @@
177713 ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If
177714 ** an error has already occurred when this function is called, it is a no-op.
177715 */
177716 static void fts5SegIterSeekInit(
177717 Fts5Index *p, /* FTS5 backend */
 
177718 const u8 *pTerm, int nTerm, /* Term to seek to */
177719 int flags, /* Mask of FTS5INDEX_XXX flags */
177720 Fts5StructureSegment *pSeg, /* Description of segment */
177721 Fts5SegIter *pIter /* Object to populate */
177722 ){
@@ -178007,11 +178099,11 @@
178099
178100
178101 /*
178102 ** Free the iterator object passed as the second argument.
178103 */
178104 static void fts5MultiIterFree(Fts5Iter *pIter){
178105 if( pIter ){
178106 int i;
178107 for(i=0; i<pIter->nSeg; i++){
178108 fts5SegIterClear(&pIter->aSeg[i]);
178109 }
@@ -178048,11 +178140,10 @@
178140 ** If non-zero is returned, the caller should call fts5MultiIterAdvanced()
178141 ** on the iterator instead. That function does the same as this one, except
178142 ** that it deals with more complicated cases as well.
178143 */
178144 static int fts5MultiIterAdvanceRowid(
 
178145 Fts5Iter *pIter, /* Iterator to update aFirst[] array for */
178146 int iChanged, /* Index of sub-iterator just advanced */
178147 Fts5SegIter **ppFirst
178148 ){
178149 Fts5SegIter *pNew = &pIter->aSeg[iChanged];
@@ -178123,11 +178214,11 @@
178214 }else{
178215 pSeg->xNext(p, pSeg, &bNewTerm);
178216 }
178217
178218 if( pSeg->pLeaf==0 || bNewTerm
178219 || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)
178220 ){
178221 fts5MultiIterAdvanced(p, pIter, iFirst, 1);
178222 fts5MultiIterSetEof(pIter);
178223 pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];
178224 if( pSeg->pLeaf==0 ) return;
@@ -178156,11 +178247,11 @@
178247 int bNewTerm = 0;
178248
178249 assert( p->rc==SQLITE_OK );
178250 pSeg->xNext(p, pSeg, &bNewTerm);
178251 if( pSeg->pLeaf==0 || bNewTerm
178252 || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)
178253 ){
178254 fts5MultiIterAdvanced(p, pIter, iFirst, 1);
178255 fts5MultiIterSetEof(pIter);
178256 *pbNewTerm = 1;
178257 }else{
@@ -178170,11 +178261,12 @@
178261
178262 }while( fts5MultiIterIsEmpty(p, pIter) );
178263 }
178264 }
178265
178266 static void fts5IterSetOutputs_Noop(Fts5Iter *pUnused1, Fts5SegIter *pUnused2){
178267 UNUSED_PARAM2(pUnused1, pUnused2);
178268 }
178269
178270 static Fts5Iter *fts5MultiIterAlloc(
178271 Fts5Index *p, /* FTS5 backend to iterate within */
178272 int nSeg
@@ -178196,14 +178288,15 @@
178288 }
178289 return pNew;
178290 }
178291
178292 static void fts5PoslistCallback(
178293 Fts5Index *pUnused,
178294 void *pContext,
178295 const u8 *pChunk, int nChunk
178296 ){
178297 UNUSED_PARAM(pUnused);
178298 assert_nc( nChunk>=0 );
178299 if( nChunk>0 ){
178300 fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk);
178301 }
178302 }
@@ -178233,15 +178326,16 @@
178326 }
178327 return 0;
178328 }
178329
178330 static void fts5PoslistOffsetsCallback(
178331 Fts5Index *pUnused,
178332 void *pContext,
178333 const u8 *pChunk, int nChunk
178334 ){
178335 PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext;
178336 UNUSED_PARAM(pUnused);
178337 assert_nc( nChunk>=0 );
178338 if( nChunk>0 ){
178339 int i = 0;
178340 while( i<nChunk ){
178341 int iVal;
@@ -178255,15 +178349,16 @@
178349 }
178350 }
178351 }
178352
178353 static void fts5PoslistFilterCallback(
178354 Fts5Index *pUnused,
178355 void *pContext,
178356 const u8 *pChunk, int nChunk
178357 ){
178358 PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext;
178359 UNUSED_PARAM(pUnused);
178360 assert_nc( nChunk>=0 );
178361 if( nChunk>0 ){
178362 /* Search through to find the first varint with value 1. This is the
178363 ** start of the next columns hits. */
178364 int i = 0;
@@ -178623,11 +178718,10 @@
178718 Fts5Iter **ppOut /* New object */
178719 ){
178720 int nSeg = 0; /* Number of segment-iters in use */
178721 int iIter = 0; /* */
178722 int iSeg; /* Used to iterate through segments */
 
178723 Fts5StructureLevel *pLvl;
178724 Fts5Iter *pNew;
178725
178726 assert( (pTerm==0 && nTerm==0) || iLevel<0 );
178727
@@ -178666,11 +178760,11 @@
178760 Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
178761 Fts5SegIter *pIter = &pNew->aSeg[iIter++];
178762 if( pTerm==0 ){
178763 fts5SegIterInit(p, pSeg, pIter);
178764 }else{
178765 fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter);
178766 }
178767 }
178768 }
178769 }else{
178770 pLvl = &pStruct->aLevel[iLevel];
@@ -178703,15 +178797,13 @@
178797 Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst];
178798 pNew->xSetOutputs(pNew, pSeg);
178799 }
178800
178801 }else{
178802 fts5MultiIterFree(pNew);
178803 *ppOut = 0;
178804 }
 
 
178805 }
178806
178807 /*
178808 ** Create an Fts5Iter that iterates through the doclist provided
178809 ** as the second argument.
@@ -178845,19 +178937,18 @@
178937 p->nPendingData = 0;
178938 }
178939 }
178940
178941 /*
178942 ** Return the size of the prefix, in bytes, that buffer
178943 ** (pNew/<length-unknown>) shares with buffer (pOld/nOld).
178944 **
178945 ** Buffer (pNew/<length-unknown>) is guaranteed to be greater
178946 ** than buffer (pOld/nOld).
178947 */
178948 static int fts5PrefixCompress(int nOld, const u8 *pOld, const u8 *pNew){
 
 
 
178949 int i;
 
178950 for(i=0; i<nOld; i++){
178951 if( pOld[i]!=pNew[i] ) break;
178952 }
178953 return i;
178954 }
@@ -179163,17 +179254,17 @@
179254 ** In this case the previous term is not available, so just write a
179255 ** copy of (pTerm/nTerm) into the parent node. This is slightly
179256 ** inefficient, but still correct. */
179257 int n = nTerm;
179258 if( pPage->term.n ){
179259 n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
179260 }
179261 fts5WriteBtreeTerm(p, pWriter, n, pTerm);
179262 pPage = &pWriter->writer;
179263 }
179264 }else{
179265 nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
179266 fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
179267 }
179268
179269 /* Append the number of bytes of new data, then the term data itself
179270 ** to the page. */
@@ -179535,11 +179626,11 @@
179626 assert( pSeg->pgnoLast>0 );
179627 fts5TrimSegments(p, pIter);
179628 pLvl->nMerge = nInput;
179629 }
179630
179631 fts5MultiIterFree(pIter);
179632 fts5BufferFree(&term);
179633 if( pnRem ) *pnRem -= writer.nLeafWritten;
179634 }
179635
179636 /*
@@ -179911,13 +180002,14 @@
180002 }
180003
180004 static void fts5AppendRowid(
180005 Fts5Index *p,
180006 i64 iDelta,
180007 Fts5Iter *pUnused,
180008 Fts5Buffer *pBuf
180009 ){
180010 UNUSED_PARAM(pUnused);
180011 fts5BufferAppendVarint(&p->rc, pBuf, iDelta);
180012 }
180013
180014 static void fts5AppendPoslist(
180015 Fts5Index *p,
@@ -180256,11 +180348,11 @@
180348 if( p->rc==SQLITE_OK ){
180349 xMerge(p, &doclist, &aBuf[i]);
180350 }
180351 fts5BufferFree(&aBuf[i]);
180352 }
180353 fts5MultiIterFree(p1);
180354
180355 pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
180356 if( pData ){
180357 pData->p = (u8*)&pData[1];
180358 pData->nn = pData->szLeaf = doclist.n;
@@ -180537,11 +180629,11 @@
180629 }else{
180630 /* Scan multiple terms in the main index */
180631 int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
180632 buf.p[0] = FTS5_MAIN_PREFIX;
180633 fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet);
180634 assert( p->rc!=SQLITE_OK || pRet->pColset==0 );
180635 fts5IterSetOutputCb(&p->rc, pRet);
180636 if( p->rc==SQLITE_OK ){
180637 Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
180638 if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
180639 }
@@ -180620,11 +180712,11 @@
180712 */
180713 static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
180714 if( pIndexIter ){
180715 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
180716 Fts5Index *pIndex = pIter->pIndex;
180717 fts5MultiIterFree(pIter);
180718 fts5CloseReader(pIndex);
180719 }
180720 }
180721
180722 /*
@@ -181179,11 +181271,11 @@
181271 }
181272 }
181273 }
181274 fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
181275
181276 fts5MultiIterFree(pIter);
181277 if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
181278
181279 fts5StructureRelease(pStruct);
181280 #ifdef SQLITE_DEBUG
181281 fts5BufferFree(&term);
@@ -181416,10 +181508,11 @@
181508 int rc = SQLITE_OK; /* Return code */
181509 int nSpace = 0;
181510 int eDetailNone = (sqlite3_user_data(pCtx)!=0);
181511
181512 assert( nArg==2 );
181513 UNUSED_PARAM(nArg);
181514 memset(&s, 0, sizeof(Fts5Buffer));
181515 iRowid = sqlite3_value_int64(apVal[0]);
181516
181517 /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]
181518 ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
@@ -182744,11 +182837,11 @@
182837 ** 3. A full-table scan.
182838 */
182839 static int fts5FilterMethod(
182840 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
182841 int idxNum, /* Strategy index */
182842 const char *zUnused, /* Unused */
182843 int nVal, /* Number of elements in apVal */
182844 sqlite3_value **apVal /* Arguments for the indexing scheme */
182845 ){
182846 Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
182847 Fts5Config *pConfig = pTab->pConfig;
@@ -182761,10 +182854,13 @@
182854 sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */
182855 sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */
182856 sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */
182857 sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */
182858 char **pzErrmsg = pConfig->pzErrmsg;
182859
182860 UNUSED_PARAM(zUnused);
182861 UNUSED_PARAM(nVal);
182862
182863 if( pCsr->ePlan ){
182864 fts5FreeCursorComponents(pCsr);
182865 memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));
182866 }
@@ -183046,12 +183142,11 @@
183142 return rc;
183143 }
183144
183145 static int fts5SpecialDelete(
183146 Fts5Table *pTab,
183147 sqlite3_value **apVal
 
183148 ){
183149 int rc = SQLITE_OK;
183150 int eType1 = sqlite3_value_type(apVal[1]);
183151 if( eType1==SQLITE_INTEGER ){
183152 sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);
@@ -183123,11 +183218,11 @@
183218 /* A "special" INSERT op. These are handled separately. */
183219 const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]);
183220 if( pConfig->eContent!=FTS5_CONTENT_NORMAL
183221 && 0==sqlite3_stricmp("delete", z)
183222 ){
183223 rc = fts5SpecialDelete(pTab, apVal);
183224 }else{
183225 rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
183226 }
183227 }else{
183228 /* A regular INSERT, UPDATE or DELETE statement. The trick here is that
@@ -183224,10 +183319,11 @@
183319
183320 /*
183321 ** Implementation of xBegin() method.
183322 */
183323 static int fts5BeginMethod(sqlite3_vtab *pVtab){
183324 UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
183325 fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
183326 return SQLITE_OK;
183327 }
183328
183329 /*
@@ -183234,10 +183330,11 @@
183330 ** Implementation of xCommit() method. This is a no-op. The contents of
183331 ** the pending-terms hash-table have already been flushed into the database
183332 ** by fts5SyncMethod().
183333 */
183334 static int fts5CommitMethod(sqlite3_vtab *pVtab){
183335 UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
183336 fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);
183337 return SQLITE_OK;
183338 }
183339
183340 /*
@@ -183487,16 +183584,18 @@
183584 }
183585
183586 static int fts5ColumnSizeCb(
183587 void *pContext, /* Pointer to int */
183588 int tflags,
183589 const char *pUnused, /* Buffer containing token */
183590 int nUnused, /* Size of token in bytes */
183591 int iUnused1, /* Start offset of token */
183592 int iUnused2 /* End offset of token */
183593 ){
183594 int *pCnt = (int*)pContext;
183595 UNUSED_PARAM2(pUnused, nUnused);
183596 UNUSED_PARAM2(iUnused1, iUnused2);
183597 if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){
183598 (*pCnt)++;
183599 }
183600 return SQLITE_OK;
183601 }
@@ -183608,14 +183707,15 @@
183707
183708 return pRet;
183709 }
183710
183711 static void fts5ApiPhraseNext(
183712 Fts5Context *pUnused,
183713 Fts5PhraseIter *pIter,
183714 int *piCol, int *piOff
183715 ){
183716 UNUSED_PARAM(pUnused);
183717 if( pIter->a>=pIter->b ){
183718 *piCol = -1;
183719 *piOff = -1;
183720 }else{
183721 int iVal;
@@ -183763,16 +183863,15 @@
183863 int rc;
183864 Fts5Cursor *pNew = 0;
183865
183866 rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);
183867 if( rc==SQLITE_OK ){
 
183868 pNew->ePlan = FTS5_PLAN_MATCH;
183869 pNew->iFirstRowid = SMALLEST_INT64;
183870 pNew->iLastRowid = LARGEST_INT64;
183871 pNew->base.pVtab = (sqlite3_vtab*)pTab;
183872 rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);
183873 }
183874
183875 if( rc==SQLITE_OK ){
183876 for(rc = fts5CursorFirst(pTab, pNew, 0);
183877 rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;
@@ -183981,18 +184080,19 @@
184080 ** This routine implements the xFindFunction method for the FTS3
184081 ** virtual table.
184082 */
184083 static int fts5FindFunctionMethod(
184084 sqlite3_vtab *pVtab, /* Virtual table handle */
184085 int nUnused, /* Number of SQL function arguments */
184086 const char *zName, /* Name of SQL function */
184087 void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
184088 void **ppArg /* OUT: User data for *pxFunc */
184089 ){
184090 Fts5Table *pTab = (Fts5Table*)pVtab;
184091 Fts5Auxiliary *pAux;
184092
184093 UNUSED_PARAM(nUnused);
184094 pAux = fts5FindAuxiliary(pTab, zName);
184095 if( pAux ){
184096 *pxFunc = fts5ApiCallback;
184097 *ppArg = (void*)pAux;
184098 return 1;
@@ -184018,10 +184118,11 @@
184118 **
184119 ** Flush the contents of the pending-terms table to disk.
184120 */
184121 static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
184122 Fts5Table *pTab = (Fts5Table*)pVtab;
184123 UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
184124 fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
184125 fts5TripCursors(pTab);
184126 return sqlite3Fts5StorageSync(pTab->pStorage, 0);
184127 }
184128
@@ -184030,10 +184131,11 @@
184131 **
184132 ** This is a no-op.
184133 */
184134 static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
184135 Fts5Table *pTab = (Fts5Table*)pVtab;
184136 UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
184137 fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
184138 fts5TripCursors(pTab);
184139 return sqlite3Fts5StorageSync(pTab->pStorage, 0);
184140 }
184141
@@ -184042,10 +184144,11 @@
184144 **
184145 ** Discard the contents of the pending terms table.
184146 */
184147 static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
184148 Fts5Table *pTab = (Fts5Table*)pVtab;
184149 UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
184150 fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
184151 fts5TripCursors(pTab);
184152 return sqlite3Fts5StorageRollback(pTab->pStorage);
184153 }
184154
@@ -184221,14 +184324,15 @@
184324 }
184325
184326 static void fts5Fts5Func(
184327 sqlite3_context *pCtx, /* Function call context */
184328 int nArg, /* Number of args */
184329 sqlite3_value **apUnused /* Function arguments */
184330 ){
184331 Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);
184332 char buf[8];
184333 UNUSED_PARAM2(nArg, apUnused);
184334 assert( nArg==0 );
184335 assert( sizeof(buf)>=sizeof(pGlobal) );
184336 memcpy(buf, (void*)&pGlobal, sizeof(pGlobal));
184337 sqlite3_result_blob(pCtx, buf, sizeof(pGlobal), SQLITE_TRANSIENT);
184338 }
@@ -184237,14 +184341,15 @@
184341 ** Implementation of fts5_source_id() function.
184342 */
184343 static void fts5SourceIdFunc(
184344 sqlite3_context *pCtx, /* Function call context */
184345 int nArg, /* Number of args */
184346 sqlite3_value **apUnused /* Function arguments */
184347 ){
184348 assert( nArg==0 );
184349 UNUSED_PARAM2(nArg, apUnused);
184350 sqlite3_result_text(pCtx, "fts5: 2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc", -1, SQLITE_TRANSIENT);
184351 }
184352
184353 static int fts5Init(sqlite3 *db){
184354 static const sqlite3_module fts5Mod = {
184355 /* iVersion */ 2,
@@ -184709,15 +184814,16 @@
184814 static int fts5StorageInsertCallback(
184815 void *pContext, /* Pointer to Fts5InsertCtx object */
184816 int tflags,
184817 const char *pToken, /* Buffer containing token */
184818 int nToken, /* Size of token in bytes */
184819 int iUnused1, /* Start offset of token */
184820 int iUnused2 /* End offset of token */
184821 ){
184822 Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;
184823 Fts5Index *pIdx = pCtx->pStorage->pIndex;
184824 UNUSED_PARAM2(iUnused1, iUnused2);
184825 if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
184826 pCtx->szCol++;
184827 }
184828 return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);
184829 }
@@ -185144,20 +185250,22 @@
185250 static int fts5StorageIntegrityCallback(
185251 void *pContext, /* Pointer to Fts5IntegrityCtx object */
185252 int tflags,
185253 const char *pToken, /* Buffer containing token */
185254 int nToken, /* Size of token in bytes */
185255 int iUnused1, /* Start offset of token */
185256 int iUnused2 /* End offset of token */
185257 ){
185258 Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext;
185259 Fts5Termset *pTermset = pCtx->pTermset;
185260 int bPresent;
185261 int ii;
185262 int rc = SQLITE_OK;
185263 int iPos;
185264 int iCol;
185265
185266 UNUSED_PARAM2(iUnused1, iUnused2);
185267
185268 if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){
185269 pCtx->szCol++;
185270 }
185271
@@ -185532,16 +185640,17 @@
185640
185641 /*
185642 ** Create an "ascii" tokenizer.
185643 */
185644 static int fts5AsciiCreate(
185645 void *pUnused,
185646 const char **azArg, int nArg,
185647 Fts5Tokenizer **ppOut
185648 ){
185649 int rc = SQLITE_OK;
185650 AsciiTokenizer *p = 0;
185651 UNUSED_PARAM(pUnused);
185652 if( nArg%2 ){
185653 rc = SQLITE_ERROR;
185654 }else{
185655 p = sqlite3_malloc(sizeof(AsciiTokenizer));
185656 if( p==0 ){
@@ -185586,11 +185695,11 @@
185695 ** Tokenize some text using the ascii tokenizer.
185696 */
185697 static int fts5AsciiTokenize(
185698 Fts5Tokenizer *pTokenizer,
185699 void *pCtx,
185700 int iUnused,
185701 const char *pText, int nText,
185702 int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)
185703 ){
185704 AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer;
185705 int rc = SQLITE_OK;
@@ -185599,10 +185708,12 @@
185708
185709 char aFold[64];
185710 int nFold = sizeof(aFold);
185711 char *pFold = aFold;
185712 unsigned char *a = p->aTokenChar;
185713
185714 UNUSED_PARAM(iUnused);
185715
185716 while( is<nText && rc==SQLITE_OK ){
185717 int nByte;
185718
185719 /* Skip any leading divider characters. */
@@ -185793,16 +185904,18 @@
185904
185905 /*
185906 ** Create a "unicode61" tokenizer.
185907 */
185908 static int fts5UnicodeCreate(
185909 void *pUnused,
185910 const char **azArg, int nArg,
185911 Fts5Tokenizer **ppOut
185912 ){
185913 int rc = SQLITE_OK; /* Return code */
185914 Unicode61Tokenizer *p = 0; /* New tokenizer object */
185915
185916 UNUSED_PARAM(pUnused);
185917
185918 if( nArg%2 ){
185919 rc = SQLITE_ERROR;
185920 }else{
185921 p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));
@@ -185856,11 +185969,11 @@
185969 }
185970
185971 static int fts5UnicodeTokenize(
185972 Fts5Tokenizer *pTokenizer,
185973 void *pCtx,
185974 int iUnused,
185975 const char *pText, int nText,
185976 int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)
185977 ){
185978 Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer;
185979 int rc = SQLITE_OK;
@@ -185871,10 +185984,12 @@
185984
185985 /* Output buffer */
185986 char *aFold = p->aFold;
185987 int nFold = p->nFold;
185988 const char *pEnd = &aFold[nFold-6];
185989
185990 UNUSED_PARAM(iUnused);
185991
185992 /* Each iteration of this loop gobbles up a contiguous run of separators,
185993 ** then the next token. */
185994 while( rc==SQLITE_OK ){
185995 int iCode; /* non-ASCII codepoint read from input */
@@ -187650,19 +187765,21 @@
187765
187766 /*
187767 ** Implementation of the xBestIndex method.
187768 */
187769 static int fts5VocabBestIndexMethod(
187770 sqlite3_vtab *pUnused,
187771 sqlite3_index_info *pInfo
187772 ){
187773 int i;
187774 int iTermEq = -1;
187775 int iTermGe = -1;
187776 int iTermLe = -1;
187777 int idxNum = 0;
187778 int nArg = 0;
187779
187780 UNUSED_PARAM(pUnused);
187781
187782 for(i=0; i<pInfo->nConstraint; i++){
187783 struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
187784 if( p->usable==0 ) continue;
187785 if( p->iColumn==0 ){ /* term column */
@@ -187901,12 +188018,12 @@
188018 ** This is the xFilter implementation for the virtual table.
188019 */
188020 static int fts5VocabFilterMethod(
188021 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
188022 int idxNum, /* Strategy index */
188023 const char *zUnused, /* Unused */
188024 int nUnused, /* Number of elements in apVal */
188025 sqlite3_value **apVal /* Arguments for the indexing scheme */
188026 ){
188027 Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
188028 int rc = SQLITE_OK;
188029
@@ -187916,10 +188033,12 @@
188033 int nTerm = 0;
188034
188035 sqlite3_value *pEq = 0;
188036 sqlite3_value *pGe = 0;
188037 sqlite3_value *pLe = 0;
188038
188039 UNUSED_PARAM2(zUnused, nUnused);
188040
188041 fts5VocabResetCursor(pCsr);
188042 if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++];
188043 if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++];
188044 if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++];
188045
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112112
** [sqlite_version()] and [sqlite_source_id()].
113113
*/
114114
#define SQLITE_VERSION "3.11.0"
115115
#define SQLITE_VERSION_NUMBER 3011000
116
-#define SQLITE_SOURCE_ID "2016-02-09 20:11:14 751915cb7e4981661a40dc5e4d029ab27434c2d9"
116
+#define SQLITE_SOURCE_ID "2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc"
117117
118118
/*
119119
** CAPI3REF: Run-Time Library Version Numbers
120120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
121121
**
122122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.11.0"
115 #define SQLITE_VERSION_NUMBER 3011000
116 #define SQLITE_SOURCE_ID "2016-02-09 20:11:14 751915cb7e4981661a40dc5e4d029ab27434c2d9"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.11.0"
115 #define SQLITE_VERSION_NUMBER 3011000
116 #define SQLITE_SOURCE_ID "2016-02-12 05:19:29 717c1fc41a2246e27b324a4071073c286bac4efc"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button