Fossil SCM

Update the built-in SQLite to the latest 3.7.7 release candidate.

drh 2011-06-21 00:51 trunk
Commit 74cbfc69adb528de5990c300ffbf12786d320973
2 files changed +308 -197 +10 -10
+308 -197
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -650,11 +650,11 @@
650650
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
651651
** [sqlite_version()] and [sqlite_source_id()].
652652
*/
653653
#define SQLITE_VERSION "3.7.7"
654654
#define SQLITE_VERSION_NUMBER 3007007
655
-#define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389"
655
+#define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee"
656656
657657
/*
658658
** CAPI3REF: Run-Time Library Version Numbers
659659
** KEYWORDS: sqlite3_version, sqlite3_sourceid
660660
**
@@ -851,11 +851,11 @@
851851
** semicolon-separate SQL statements passed into its 2nd argument,
852852
** in the context of the [database connection] passed in as its 1st
853853
** argument. ^If the callback function of the 3rd argument to
854854
** sqlite3_exec() is not NULL, then it is invoked for each result row
855855
** coming out of the evaluated SQL statements. ^The 4th argument to
856
-** to sqlite3_exec() is relayed through to the 1st argument of each
856
+** sqlite3_exec() is relayed through to the 1st argument of each
857857
** callback invocation. ^If the callback pointer to sqlite3_exec()
858858
** is NULL, then no callback is ever invoked and result rows are
859859
** ignored.
860860
**
861861
** ^If an error occurs while evaluating the SQL statements passed into
@@ -1443,11 +1443,11 @@
14431443
** The xSleep() method causes the calling thread to sleep for at
14441444
** least the number of microseconds given. ^The xCurrentTime()
14451445
** method returns a Julian Day Number for the current date and time as
14461446
** a floating point value.
14471447
** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
1448
-** Day Number multipled by 86400000 (the number of milliseconds in
1448
+** Day Number multiplied by 86400000 (the number of milliseconds in
14491449
** a 24-hour day).
14501450
** ^SQLite will use the xCurrentTimeInt64() method to get the current
14511451
** date and time if that method is available (if iVersion is 2 or
14521452
** greater and the function pointer is not NULL) and will fall back
14531453
** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
@@ -1881,11 +1881,11 @@
18811881
** scratch memory beyond what is provided by this configuration option, then
18821882
** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
18831883
**
18841884
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
18851885
** <dd> ^This option specifies a static memory buffer that SQLite can use for
1886
-** the database page cache with the default page cache implemenation.
1886
+** the database page cache with the default page cache implementation.
18871887
** This configuration should not be used if an application-define page
18881888
** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
18891889
** There are three arguments to this option: A pointer to 8-byte aligned
18901890
** memory, the size of each page buffer (sz), and the number of pages (N).
18911891
** The sz argument should be the size of the largest database page
@@ -2979,16 +2979,16 @@
29792979
** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
29802980
**
29812981
** ^If [URI filename] interpretation is enabled, and the filename argument
29822982
** begins with "file:", then the filename is interpreted as a URI. ^URI
29832983
** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2984
-** is set in the fourth argument to sqlite3_open_v2(), or if it has
2984
+** set in the fourth argument to sqlite3_open_v2(), or if it has
29852985
** been enabled globally using the [SQLITE_CONFIG_URI] option with the
29862986
** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
29872987
** As of SQLite version 3.7.7, URI filename interpretation is turned off
29882988
** by default, but future releases of SQLite might enable URI filename
2989
-** intepretation by default. See "[URI filenames]" for additional
2989
+** interpretation by default. See "[URI filenames]" for additional
29902990
** information.
29912991
**
29922992
** URI filenames are parsed according to RFC 3986. ^If the URI contains an
29932993
** authority, then it must be either an empty string or the string
29942994
** "localhost". ^If the authority is not an empty string or "localhost", an
@@ -3803,11 +3803,11 @@
38033803
** [extended result codes] might be returned as well.
38043804
**
38053805
** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
38063806
** database locks it needs to do its job. ^If the statement is a [COMMIT]
38073807
** or occurs outside of an explicit transaction, then you can retry the
3808
-** statement. If the statement is not a [COMMIT] and occurs within a
3808
+** statement. If the statement is not a [COMMIT] and occurs within an
38093809
** explicit transaction then you should rollback the transaction before
38103810
** continuing.
38113811
**
38123812
** ^[SQLITE_DONE] means that the statement has finished executing
38133813
** successfully. sqlite3_step() should not be called again on this virtual
@@ -4082,11 +4082,11 @@
40824082
40834083
/*
40844084
** CAPI3REF: Destroy A Prepared Statement Object
40854085
**
40864086
** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4087
-** ^If the most recent evaluation of the statement encountered no errors or
4087
+** ^If the most recent evaluation of the statement encountered no errors
40884088
** or if the statement is never been evaluated, then sqlite3_finalize() returns
40894089
** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
40904090
** sqlite3_finalize(S) returns the appropriate [error code] or
40914091
** [extended error code].
40924092
**
@@ -5996,11 +5996,11 @@
59965996
** versions of these routines, it should at least provide stubs that always
59975997
** return true so that one does not get spurious assertion failures.
59985998
**
59995999
** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
60006000
** the routine should return 1. This seems counter-intuitive since
6001
-** clearly the mutex cannot be held if it does not exist. But the
6001
+** clearly the mutex cannot be held if it does not exist. But
60026002
** the reason the mutex does not exist is because the build is not
60036003
** using mutexes. And we do not want the assert() containing the
60046004
** call to sqlite3_mutex_held() to fail, so a non-zero return is
60056005
** the appropriate thing to do. ^The sqlite3_mutex_notheld()
60066006
** interface should also return 1 when given a NULL pointer.
@@ -6505,11 +6505,11 @@
65056505
** [[the xFetch() page cache methods]]
65066506
** The xFetch() method locates a page in the cache and returns a pointer to
65076507
** the page, or a NULL pointer.
65086508
** A "page", in this context, means a buffer of szPage bytes aligned at an
65096509
** 8-byte boundary. The page to be fetched is determined by the key. ^The
6510
-** mimimum key value is 1. After it has been retrieved using xFetch, the page
6510
+** minimum key value is 1. After it has been retrieved using xFetch, the page
65116511
** is considered to be "pinned".
65126512
**
65136513
** If the requested page is already in the page cache, then the page cache
65146514
** implementation must return a pointer to the page buffer with its content
65156515
** intact. If the requested page is not already in the cache, then the
@@ -24364,10 +24364,14 @@
2436424364
2436524365
#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
2436624366
# include <sys/mount.h>
2436724367
#endif
2436824368
24369
+#ifdef HAVE_UTIME
24370
+# include <utime.h>
24371
+#endif
24372
+
2436924373
/*
2437024374
** Allowed values of unixFile.fsFlags
2437124375
*/
2437224376
#define SQLITE_FSFLAGS_IS_MSDOS 0x1
2437324377
@@ -26369,12 +26373,14 @@
2636926373
/* If we have any lock, then the lock file already exists. All we have
2637026374
** to do is adjust our internal record of the lock level.
2637126375
*/
2637226376
if( pFile->eFileLock > NO_LOCK ){
2637326377
pFile->eFileLock = eFileLock;
26374
-#if !OS_VXWORKS
2637526378
/* Always update the timestamp on the old file */
26379
+#ifdef HAVE_UTIME
26380
+ utime(zLockFile, NULL);
26381
+#else
2637626382
utimes(zLockFile, NULL);
2637726383
#endif
2637826384
return SQLITE_OK;
2637926385
}
2638026386
@@ -32254,11 +32260,12 @@
3225432260
rc = 1;
3225532261
}
3225632262
}
3225732263
3225832264
if( rc ){
32259
- if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){
32265
+ if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
32266
+ || ( pFile->lastErrno==ERROR_DISK_FULL )){
3226032267
return SQLITE_FULL;
3226132268
}
3226232269
return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath);
3226332270
}
3226432271
return SQLITE_OK;
@@ -63496,11 +63503,11 @@
6349663503
break;
6349763504
}
6349863505
6349963506
/* Opcode: HaltIfNull P1 P2 P3 P4 *
6350063507
**
63501
-** Check the value in register P3. If is is NULL then Halt using
63508
+** Check the value in register P3. If it is NULL then Halt using
6350263509
** parameter P1, P2, and P4 as if this were a Halt instruction. If the
6350363510
** value in register P3 is not NULL, then this routine is a no-op.
6350463511
*/
6350563512
case OP_HaltIfNull: { /* in3 */
6350663513
pIn3 = &aMem[pOp->p3];
@@ -64433,11 +64440,11 @@
6443364440
** additional information.
6443464441
**
6443564442
** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
6443664443
** true or false and is never NULL. If both operands are NULL then the result
6443764444
** of comparison is false. If either operand is NULL then the result is true.
64438
-** If neither operand is NULL the the result is the same as it would be if
64445
+** If neither operand is NULL the result is the same as it would be if
6443964446
** the SQLITE_NULLEQ flag were omitted from P5.
6444064447
*/
6444164448
/* Opcode: Eq P1 P2 P3 P4 P5
6444264449
**
6444364450
** This works just like the Lt opcode except that the jump is taken if
@@ -64445,11 +64452,11 @@
6444564452
** See the Lt opcode for additional information.
6444664453
**
6444764454
** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
6444864455
** true or false and is never NULL. If both operands are NULL then the result
6444964456
** of comparison is true. If either operand is NULL then the result is false.
64450
-** If neither operand is NULL the the result is the same as it would be if
64457
+** If neither operand is NULL the result is the same as it would be if
6445164458
** the SQLITE_NULLEQ flag were omitted from P5.
6445264459
*/
6445364460
/* Opcode: Le P1 P2 P3 P4 P5
6445464461
**
6445564462
** This works just like the Lt opcode except that the jump is taken if
@@ -64730,17 +64737,17 @@
6473064737
break;
6473164738
}
6473264739
6473364740
/* Opcode: If P1 P2 P3 * *
6473464741
**
64735
-** Jump to P2 if the value in register P1 is true. The value is
64742
+** Jump to P2 if the value in register P1 is true. The value
6473664743
** is considered true if it is numeric and non-zero. If the value
6473764744
** in P1 is NULL then take the jump if P3 is true.
6473864745
*/
6473964746
/* Opcode: IfNot P1 P2 P3 * *
6474064747
**
64741
-** Jump to P2 if the value in register P1 is False. The value is
64748
+** Jump to P2 if the value in register P1 is False. The value
6474264749
** is considered true if it has a numeric value of zero. If the value
6474364750
** in P1 is NULL then take the jump if P3 is true.
6474464751
*/
6474564752
case OP_If: /* jump, in1 */
6474664753
case OP_IfNot: { /* jump, in1 */
@@ -66390,11 +66397,11 @@
6639066397
break;
6639166398
}
6639266399
6639366400
/* Opcode: NotExists P1 P2 P3 * *
6639466401
**
66395
-** Use the content of register P3 as a integer key. If a record
66402
+** Use the content of register P3 as an integer key. If a record
6639666403
** with that key does not exist in table of P1, then jump to P2.
6639766404
** If the record does exist, then fall through. The cursor is left
6639866405
** pointing to the record if it exists.
6639966406
**
6640066407
** The difference between this operation and NotFound is that this
@@ -66468,11 +66475,11 @@
6646866475
** written to register P2.
6646966476
**
6647066477
** If P3>0 then P3 is a register in the root frame of this VDBE that holds
6647166478
** the largest previously generated record number. No new record numbers are
6647266479
** allowed to be less than this value. When this value reaches its maximum,
66473
-** a SQLITE_FULL error is generated. The P3 register is updated with the '
66480
+** an SQLITE_FULL error is generated. The P3 register is updated with the '
6647466481
** generated record number. This P3 mechanism is used to help implement the
6647566482
** AUTOINCREMENT feature.
6647666483
*/
6647766484
case OP_NewRowid: { /* out2-prerelease */
6647866485
#if 0 /* local variables moved into u.be */
@@ -67110,11 +67117,11 @@
6711067117
break;
6711167118
}
6711267119
6711367120
/* Opcode: IdxInsert P1 P2 P3 * P5
6711467121
**
67115
-** Register P2 holds a SQL index key made using the
67122
+** Register P2 holds an SQL index key made using the
6711667123
** MakeRecord instructions. This opcode writes that key
6711767124
** into the index P1. Data for the entry is nil.
6711867125
**
6711967126
** P3 is a flag that provides a hint to the b-tree layer that this
6712067127
** insert is likely to be an append.
@@ -111420,16 +111427,10 @@
111420111427
** TODO(shess) Provide a VACUUM type operation to clear out all
111421111428
** deletions and duplications. This would basically be a forced merge
111422111429
** into a single segment.
111423111430
*/
111424111431
111425
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
111426
-
111427
-#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)
111428
-# define SQLITE_CORE 1
111429
-#endif
111430
-
111431111432
/************** Include fts3Int.h in the middle of fts3.c ********************/
111432111433
/************** Begin file fts3Int.h *****************************************/
111433111434
/*
111434111435
** 2009 Nov 12
111435111436
**
@@ -111441,18 +111442,27 @@
111441111442
** May you share freely, never taking more than you give.
111442111443
**
111443111444
******************************************************************************
111444111445
**
111445111446
*/
111446
-
111447111447
#ifndef _FTSINT_H
111448111448
#define _FTSINT_H
111449111449
111450111450
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
111451111451
# define NDEBUG 1
111452111452
#endif
111453111453
111454
+/*
111455
+** FTS4 is really an extension for FTS3. It is enabled using the
111456
+** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all
111457
+** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
111458
+*/
111459
+#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
111460
+# define SQLITE_ENABLE_FTS3
111461
+#endif
111462
+
111463
+#ifdef SQLITE_ENABLE_FTS3
111454111464
/************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
111455111465
/************** Begin file fts3_tokenizer.h **********************************/
111456111466
/*
111457111467
** 2006 July 10
111458111468
**
@@ -111940,11 +111950,11 @@
111940111950
char *aDoclist; /* List of docids for full-text queries */
111941111951
int nDoclist; /* Size of buffer at aDoclist */
111942111952
u8 bDesc; /* True to sort in descending order */
111943111953
int eEvalmode; /* An FTS3_EVAL_XX constant */
111944111954
int nRowAvg; /* Average size of database rows, in pages */
111945
- int nDoc; /* Documents in table */
111955
+ sqlite3_int64 nDoc; /* Documents in table */
111946111956
111947111957
int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */
111948111958
u32 *aMatchinfo; /* Information about most recent match */
111949111959
int nMatchinfo; /* Number of elements in aMatchinfo[] */
111950111960
char *zMatchinfo; /* Matchinfo specification */
@@ -111997,19 +112007,19 @@
111997112007
int isPrefix; /* True if token ends with a "*" character */
111998112008
111999112009
/* Variables above this point are populated when the expression is
112000112010
** parsed (by code in fts3_expr.c). Below this point the variables are
112001112011
** used when evaluating the expression. */
112002
- int bFulltext; /* True if full-text index was used */
112003112012
Fts3DeferredToken *pDeferred; /* Deferred token object for this token */
112004112013
Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */
112005112014
};
112006112015
112007112016
struct Fts3Phrase {
112008112017
/* Cache of doclist for this phrase. */
112009112018
Fts3Doclist doclist;
112010112019
int bIncr; /* True if doclist is loaded incrementally */
112020
+ int iDoclistToken;
112011112021
112012112022
/* Variables below this point are populated by fts3_expr.c when parsing
112013112023
** a MATCH expression. Everything above is part of the evaluation phase.
112014112024
*/
112015112025
int nToken; /* Number of tokens in the phrase */
@@ -112130,10 +112140,11 @@
112130112140
Fts3SegFilter *pFilter; /* Pointer to filter object */
112131112141
char *aBuffer; /* Buffer to merge doclists in */
112132112142
int nBuffer; /* Allocated size of aBuffer[] in bytes */
112133112143
112134112144
int iColFilter; /* If >=0, filter for this column */
112145
+ int bRestart;
112135112146
112136112147
/* Used by fts3.c only. */
112137112148
int nCost; /* Cost of running iterator */
112138112149
int bLookup; /* True if a lookup of a single entry. */
112139112150
@@ -112199,18 +112210,24 @@
112199112210
Fts3Table*, Fts3MultiSegReader*, int, const char*, int);
112200112211
SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
112201112212
Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
112202112213
SQLITE_PRIVATE char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol);
112203112214
SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
112215
+SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
112204112216
112205112217
SQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);
112206112218
112207
-
112219
+#endif /* SQLITE_ENABLE_FTS3 */
112208112220
#endif /* _FTSINT_H */
112209112221
112210112222
/************** End of fts3Int.h *********************************************/
112211112223
/************** Continuing where we left off in fts3.c ***********************/
112224
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
112225
+
112226
+#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)
112227
+# define SQLITE_CORE 1
112228
+#endif
112212112229
112213112230
112214112231
#ifndef SQLITE_CORE
112215112232
SQLITE_EXTENSION_INIT1
112216112233
#endif
@@ -112995,11 +113012,11 @@
112995113012
zCsr += nDb;
112996113013
112997113014
/* Fill in the azColumn array */
112998113015
for(iCol=0; iCol<nCol; iCol++){
112999113016
char *z;
113000
- int n;
113017
+ int n = 0;
113001113018
z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);
113002113019
memcpy(zCsr, z, n);
113003113020
zCsr[n] = '\0';
113004113021
sqlite3Fts3Dequote(zCsr);
113005113022
p->azColumn[iCol] = zCsr;
@@ -114581,12 +114598,12 @@
114581114598
114582114599
/*
114583114600
** Implementation of xBegin() method. This is a no-op.
114584114601
*/
114585114602
static int fts3BeginMethod(sqlite3_vtab *pVtab){
114586
- UNUSED_PARAMETER(pVtab);
114587114603
TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
114604
+ UNUSED_PARAMETER(pVtab);
114588114605
assert( p->pSegments==0 );
114589114606
assert( p->nPendingData==0 );
114590114607
assert( p->inTransaction!=1 );
114591114608
TESTONLY( p->inTransaction = 1 );
114592114609
TESTONLY( p->mxSavepoint = -1; );
@@ -114597,12 +114614,12 @@
114597114614
** Implementation of xCommit() method. This is a no-op. The contents of
114598114615
** the pending-terms hash-table have already been flushed into the database
114599114616
** by fts3SyncMethod().
114600114617
*/
114601114618
static int fts3CommitMethod(sqlite3_vtab *pVtab){
114602
- UNUSED_PARAMETER(pVtab);
114603114619
TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
114620
+ UNUSED_PARAMETER(pVtab);
114604114621
assert( p->nPendingData==0 );
114605114622
assert( p->inTransaction!=0 );
114606114623
assert( p->pSegments==0 );
114607114624
TESTONLY( p->inTransaction = 0 );
114608114625
TESTONLY( p->mxSavepoint = -1; );
@@ -115083,75 +115100,105 @@
115083115100
if( rc!=SQLITE_OK ){
115084115101
*pRc = rc;
115085115102
return;
115086115103
}
115087115104
}
115105
+ assert( pExpr->pPhrase->iDoclistToken==0 );
115106
+ pExpr->pPhrase->iDoclistToken = -1;
115088115107
}else{
115089115108
*pnOr += (pExpr->eType==FTSQUERY_OR);
115090115109
fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);
115091115110
fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);
115092115111
}
115093115112
}
115094115113
}
115114
+
115115
+static void fts3EvalPhraseMergeToken(
115116
+ Fts3Table *pTab,
115117
+ Fts3Phrase *p,
115118
+ int iToken,
115119
+ char *pList,
115120
+ int nList
115121
+){
115122
+ assert( iToken!=p->iDoclistToken );
115123
+
115124
+ if( pList==0 ){
115125
+ sqlite3_free(p->doclist.aAll);
115126
+ p->doclist.aAll = 0;
115127
+ p->doclist.nAll = 0;
115128
+ }
115129
+
115130
+ else if( p->iDoclistToken<0 ){
115131
+ p->doclist.aAll = pList;
115132
+ p->doclist.nAll = nList;
115133
+ }
115134
+
115135
+ else if( p->doclist.aAll==0 ){
115136
+ sqlite3_free(pList);
115137
+ }
115138
+
115139
+ else {
115140
+ char *pLeft;
115141
+ char *pRight;
115142
+ int nLeft;
115143
+ int nRight;
115144
+ int nDiff;
115145
+
115146
+ if( p->iDoclistToken<iToken ){
115147
+ pLeft = p->doclist.aAll;
115148
+ nLeft = p->doclist.nAll;
115149
+ pRight = pList;
115150
+ nRight = nList;
115151
+ nDiff = iToken - p->iDoclistToken;
115152
+ }else{
115153
+ pRight = p->doclist.aAll;
115154
+ nRight = p->doclist.nAll;
115155
+ pLeft = pList;
115156
+ nLeft = nList;
115157
+ nDiff = p->iDoclistToken - iToken;
115158
+ }
115159
+
115160
+ fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);
115161
+ sqlite3_free(pLeft);
115162
+ p->doclist.aAll = pRight;
115163
+ p->doclist.nAll = nRight;
115164
+ }
115165
+
115166
+ if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
115167
+}
115095115168
115096115169
static int fts3EvalPhraseLoad(
115097115170
Fts3Cursor *pCsr,
115098115171
Fts3Phrase *p
115099115172
){
115100115173
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
115101115174
int iToken;
115102115175
int rc = SQLITE_OK;
115103115176
115104
- char *aDoclist = 0;
115105
- int nDoclist = 0;
115106
- int iPrev = -1;
115107
-
115108115177
for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){
115109115178
Fts3PhraseToken *pToken = &p->aToken[iToken];
115110
- assert( pToken->pSegcsr || pToken->pDeferred );
115179
+ assert( pToken->pDeferred==0 || pToken->pSegcsr==0 );
115111115180
115112
- if( pToken->pDeferred==0 ){
115181
+ if( pToken->pSegcsr ){
115113115182
int nThis = 0;
115114115183
char *pThis = 0;
115115115184
rc = fts3TermSelect(pTab, pToken, p->iColumn, 1, &nThis, &pThis);
115116115185
if( rc==SQLITE_OK ){
115117
- if( pThis==0 ){
115118
- sqlite3_free(aDoclist);
115119
- aDoclist = 0;
115120
- nDoclist = 0;
115121
- break;
115122
- }else if( aDoclist==0 ){
115123
- aDoclist = pThis;
115124
- nDoclist = nThis;
115125
- }else{
115126
- assert( iPrev>=0 );
115127
- fts3DoclistPhraseMerge(pTab->bDescIdx,
115128
- iToken-iPrev, aDoclist, nDoclist, pThis, &nThis
115129
- );
115130
- sqlite3_free(aDoclist);
115131
- aDoclist = pThis;
115132
- nDoclist = nThis;
115133
- }
115134
- iPrev = iToken;
115135
- }
115136
- }
115137
- }
115138
-
115139
- if( rc==SQLITE_OK ){
115140
- p->doclist.aAll = aDoclist;
115141
- p->doclist.nAll = nDoclist;
115142
- }else{
115143
- sqlite3_free(aDoclist);
115144
- }
115186
+ fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
115187
+ }
115188
+ }
115189
+ assert( pToken->pSegcsr==0 );
115190
+ }
115191
+
115145115192
return rc;
115146115193
}
115147115194
115148115195
static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
115149115196
int iToken;
115150115197
int rc = SQLITE_OK;
115151115198
115152
- int nMaxUndeferred = -1;
115199
+ int nMaxUndeferred = pPhrase->iDoclistToken;
115153115200
char *aPoslist = 0;
115154115201
int nPoslist = 0;
115155115202
int iPrev = -1;
115156115203
115157115204
assert( pPhrase->doclist.bFreeList==0 );
@@ -115192,12 +115239,10 @@
115192115239
pPhrase->doclist.nList = 0;
115193115240
return SQLITE_OK;
115194115241
}
115195115242
}
115196115243
iPrev = iToken;
115197
- }else{
115198
- nMaxUndeferred = iToken;
115199115244
}
115200115245
}
115201115246
115202115247
if( iPrev>=0 ){
115203115248
if( nMaxUndeferred<0 ){
@@ -115252,13 +115297,15 @@
115252115297
static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){
115253115298
int rc;
115254115299
Fts3PhraseToken *pFirst = &p->aToken[0];
115255115300
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
115256115301
115257
- assert( p->doclist.aAll==0 );
115258
- if( pCsr->bDesc==pTab->bDescIdx && bOptOk==1 && p->nToken==1
115259
- && pFirst->pSegcsr && pFirst->pSegcsr->bLookup
115302
+ if( pCsr->bDesc==pTab->bDescIdx
115303
+ && bOptOk==1
115304
+ && p->nToken==1
115305
+ && pFirst->pSegcsr
115306
+ && pFirst->pSegcsr->bLookup
115260115307
){
115261115308
/* Use the incremental approach. */
115262115309
int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);
115263115310
rc = sqlite3Fts3MsrIncrStart(
115264115311
pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n);
@@ -115394,11 +115441,11 @@
115394115441
** with this case by advancing pIter past the zero-padding added by
115395115442
** fts3EvalNearTrim2(). */
115396115443
while( pIter<pEnd && *pIter==0 ) pIter++;
115397115444
115398115445
pDL->pNextDocid = pIter;
115399
- assert( *pIter || pIter>=&pDL->aAll[pDL->nAll] );
115446
+ assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );
115400115447
*pbEof = 0;
115401115448
}
115402115449
}
115403115450
115404115451
return rc;
@@ -115425,17 +115472,18 @@
115425115472
pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
115426115473
}
115427115474
}
115428115475
}
115429115476
115430
-
115431115477
typedef struct Fts3TokenAndCost Fts3TokenAndCost;
115432115478
struct Fts3TokenAndCost {
115433
- Fts3PhraseToken *pToken;
115434
- Fts3Expr *pRoot;
115479
+ Fts3Phrase *pPhrase; /* The phrase the token belongs to */
115480
+ int iToken; /* Position of token in phrase */
115481
+ Fts3PhraseToken *pToken; /* The token itself */
115482
+ Fts3Expr *pRoot;
115435115483
int nOvfl;
115436
- int iCol;
115484
+ int iCol; /* The column the token must match */
115437115485
};
115438115486
115439115487
static void fts3EvalTokenCosts(
115440115488
Fts3Cursor *pCsr,
115441115489
Fts3Expr *pRoot,
@@ -115448,10 +115496,12 @@
115448115496
if( pExpr->eType==FTSQUERY_PHRASE ){
115449115497
Fts3Phrase *pPhrase = pExpr->pPhrase;
115450115498
int i;
115451115499
for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){
115452115500
Fts3TokenAndCost *pTC = (*ppTC)++;
115501
+ pTC->pPhrase = pPhrase;
115502
+ pTC->iToken = i;
115453115503
pTC->pRoot = pRoot;
115454115504
pTC->pToken = &pPhrase->aToken[i];
115455115505
pTC->iCol = pPhrase->iColumn;
115456115506
*pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);
115457115507
}
@@ -115560,23 +115610,19 @@
115560115610
/* At this point pTC points to the cheapest remaining token. */
115561115611
if( ii==0 ){
115562115612
if( pTC->nOvfl ){
115563115613
nDocEst = (pTC->nOvfl * pTab->nPgsz + pTab->nPgsz) / 10;
115564115614
}else{
115565
- /* TODO: Fix this so that the doclist need not be read twice. */
115566115615
Fts3PhraseToken *pToken = pTC->pToken;
115567115616
int nList = 0;
115568115617
char *pList = 0;
115569115618
rc = fts3TermSelect(pTab, pToken, pTC->iCol, 1, &nList, &pList);
115619
+ assert( rc==SQLITE_OK || pList==0 );
115620
+
115570115621
if( rc==SQLITE_OK ){
115571115622
nDocEst = fts3DoclistCountDocids(1, pList, nList);
115572
- }
115573
- sqlite3_free(pList);
115574
- if( rc==SQLITE_OK ){
115575
- rc = sqlite3Fts3TermSegReaderCursor(pCsr,
115576
- pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr
115577
- );
115623
+ fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);
115578115624
}
115579115625
}
115580115626
}else{
115581115627
if( pTC->nOvfl>=(nDocEst*nDocSize) ){
115582115628
Fts3PhraseToken *pToken = pTC->pToken;
@@ -116032,17 +116078,18 @@
116032116078
Fts3Phrase *pPhrase = pExpr->pPhrase;
116033116079
116034116080
if( pPhrase ){
116035116081
fts3EvalZeroPoslist(pPhrase);
116036116082
if( pPhrase->bIncr ){
116037
- sqlite3Fts3EvalPhraseCleanup(pPhrase);
116038
- memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist));
116039
- *pRc = sqlite3Fts3EvalStart(pCsr, pExpr, 0);
116040
- }else{
116041
- pPhrase->doclist.pNextDocid = 0;
116042
- pPhrase->doclist.iDocid = 0;
116083
+ assert( pPhrase->nToken==1 );
116084
+ assert( pPhrase->aToken[0].pSegcsr );
116085
+ sqlite3Fts3MsrIncrRestart(pPhrase->aToken[0].pSegcsr);
116086
+ *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);
116043116087
}
116088
+
116089
+ pPhrase->doclist.pNextDocid = 0;
116090
+ pPhrase->doclist.iDocid = 0;
116044116091
}
116045116092
116046116093
pExpr->iDocid = 0;
116047116094
pExpr->bEof = 0;
116048116095
pExpr->bStart = 0;
@@ -116225,12 +116272,12 @@
116225116272
int iCol;
116226116273
116227116274
if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){
116228116275
assert( pCsr->nDoc>0 );
116229116276
for(iCol=0; iCol<pTab->nColumn; iCol++){
116230
- aiOut[iCol*3 + 1] = pCsr->nDoc;
116231
- aiOut[iCol*3 + 2] = pCsr->nDoc;
116277
+ aiOut[iCol*3 + 1] = (u32)pCsr->nDoc;
116278
+ aiOut[iCol*3 + 2] = (u32)pCsr->nDoc;
116232116279
}
116233116280
}else{
116234116281
rc = fts3EvalGatherStats(pCsr, pExpr);
116235116282
if( rc==SQLITE_OK ){
116236116283
assert( pExpr->aMI );
@@ -116334,11 +116381,10 @@
116334116381
** May you share freely, never taking more than you give.
116335116382
**
116336116383
******************************************************************************
116337116384
**
116338116385
*/
116339
-
116340116386
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
116341116387
116342116388
116343116389
typedef struct Fts3auxTable Fts3auxTable;
116344116390
typedef struct Fts3auxCursor Fts3auxCursor;
@@ -118168,11 +118214,10 @@
118168118214
*/
118169118215
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118170118216
118171118217
118172118218
118173
-
118174118219
/*
118175118220
** Class derived from sqlite3_tokenizer
118176118221
*/
118177118222
typedef struct porter_tokenizer {
118178118223
sqlite3_tokenizer base; /* Base class */
@@ -118808,15 +118853,15 @@
118808118853
** (in which case SQLITE_CORE is not defined), or
118809118854
**
118810118855
** * The FTS3 module is being built into the core of
118811118856
** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
118812118857
*/
118813
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118814
-
118815118858
#ifndef SQLITE_CORE
118816118859
SQLITE_EXTENSION_INIT1
118817118860
#endif
118861
+
118862
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118818118863
118819118864
118820118865
/*
118821118866
** Implementation of the SQL scalar function for accessing the underlying
118822118867
** hash table. This function may be called as follows:
@@ -118937,11 +118982,11 @@
118937118982
sqlite3_tokenizer **ppTok, /* OUT: Tokenizer (if applicable) */
118938118983
char **pzErr /* OUT: Set to malloced error message */
118939118984
){
118940118985
int rc;
118941118986
char *z = (char *)zArg;
118942
- int n;
118987
+ int n = 0;
118943118988
char *zCopy;
118944118989
char *zEnd; /* Pointer to nul-term of zCopy */
118945118990
sqlite3_tokenizer_module *m;
118946118991
118947118992
zCopy = sqlite3_mprintf("%s", zArg);
@@ -119299,11 +119344,10 @@
119299119344
**
119300119345
** * The FTS3 module is being built into the core of
119301119346
** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
119302119347
*/
119303119348
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
119304
-
119305119349
119306119350
119307119351
119308119352
typedef struct simple_tokenizer {
119309119353
sqlite3_tokenizer base;
@@ -120750,10 +120794,11 @@
120750120794
pReader->pOffsetList = 0;
120751120795
}else{
120752120796
pReader->pOffsetList = p;
120753120797
}
120754120798
}else{
120799
+ char *pEnd = &pReader->aDoclist[pReader->nDoclist];
120755120800
120756120801
/* Pointer p currently points at the first byte of an offset list. The
120757120802
** following block advances it to point one byte past the end of
120758120803
** the same offset list. */
120759120804
while( 1 ){
@@ -120778,17 +120823,19 @@
120778120823
*/
120779120824
if( ppOffsetList ){
120780120825
*ppOffsetList = pReader->pOffsetList;
120781120826
*pnOffsetList = (int)(p - pReader->pOffsetList - 1);
120782120827
}
120828
+
120829
+ while( p<pEnd && *p==0 ) p++;
120783120830
120784120831
/* If there are no more entries in the doclist, set pOffsetList to
120785120832
** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and
120786120833
** Fts3SegReader.pOffsetList to point to the next offset list before
120787120834
** returning.
120788120835
*/
120789
- if( p>=&pReader->aDoclist[pReader->nDoclist] ){
120836
+ if( p>=pEnd ){
120790120837
pReader->pOffsetList = 0;
120791120838
}else{
120792120839
rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
120793120840
if( rc==SQLITE_OK ){
120794120841
sqlite3_int64 iDelta;
@@ -120823,11 +120870,11 @@
120823120870
for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
120824120871
Fts3SegReader *pReader = pMsr->apSegment[ii];
120825120872
if( !fts3SegReaderIsPending(pReader)
120826120873
&& !fts3SegReaderIsRootOnly(pReader)
120827120874
){
120828
- int jj;
120875
+ sqlite3_int64 jj;
120829120876
for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){
120830120877
int nBlob;
120831120878
rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);
120832120879
if( rc!=SQLITE_OK ) break;
120833120880
if( (nBlob+35)>pgsz ){
@@ -121768,55 +121815,31 @@
121768121815
121769121816
*ppList = pList;
121770121817
*pnList = nList;
121771121818
}
121772121819
121773
-SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(
121774
- Fts3Table *p, /* Virtual table handle */
121775
- Fts3MultiSegReader *pCsr, /* Cursor object */
121776
- int iCol, /* Column to match on. */
121777
- const char *zTerm, /* Term to iterate through a doclist for */
121778
- int nTerm /* Number of bytes in zTerm */
121820
+/*
121821
+** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any
121822
+** existing data). Grow the buffer if required.
121823
+**
121824
+** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered
121825
+** trying to resize the buffer, return SQLITE_NOMEM.
121826
+*/
121827
+static int fts3MsrBufferData(
121828
+ Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */
121829
+ char *pList,
121830
+ int nList
121779121831
){
121780
- int i;
121781
- int nSegment = pCsr->nSegment;
121782
- int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (
121783
- p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp
121784
- );
121785
-
121786
- assert( pCsr->pFilter==0 );
121787
- assert( zTerm && nTerm>0 );
121788
-
121789
- /* Advance each segment iterator until it points to the term zTerm/nTerm. */
121790
- for(i=0; i<nSegment; i++){
121791
- Fts3SegReader *pSeg = pCsr->apSegment[i];
121792
- do {
121793
- int rc = fts3SegReaderNext(p, pSeg, 1);
121794
- if( rc!=SQLITE_OK ) return rc;
121795
- }while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 );
121796
- }
121797
- fts3SegReaderSort(pCsr->apSegment, nSegment, nSegment, fts3SegReaderCmp);
121798
-
121799
- /* Determine how many of the segments actually point to zTerm/nTerm. */
121800
- for(i=0; i<nSegment; i++){
121801
- Fts3SegReader *pSeg = pCsr->apSegment[i];
121802
- if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){
121803
- break;
121804
- }
121805
- }
121806
- pCsr->nAdvance = i;
121807
-
121808
- /* Advance each of the segments to point to the first docid. */
121809
- for(i=0; i<pCsr->nAdvance; i++){
121810
- int rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);
121811
- if( rc!=SQLITE_OK ) return rc;
121812
- }
121813
- fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);
121814
-
121815
- assert( iCol<0 || iCol<p->nColumn );
121816
- pCsr->iColFilter = iCol;
121817
-
121832
+ if( nList>pMsr->nBuffer ){
121833
+ char *pNew;
121834
+ pMsr->nBuffer = nList*2;
121835
+ pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);
121836
+ if( !pNew ) return SQLITE_NOMEM;
121837
+ pMsr->aBuffer = pNew;
121838
+ }
121839
+
121840
+ memcpy(pMsr->aBuffer, pList, nList);
121818121841
return SQLITE_OK;
121819121842
}
121820121843
121821121844
SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
121822121845
Fts3Table *p, /* Virtual table handle */
@@ -121866,52 +121889,138 @@
121866121889
if( pMsr->iColFilter>=0 ){
121867121890
fts3ColumnFilter(pMsr->iColFilter, &pList, &nList);
121868121891
}
121869121892
121870121893
if( nList>0 ){
121894
+ if( fts3SegReaderIsPending(apSegment[0]) ){
121895
+ rc = fts3MsrBufferData(pMsr, pList, nList+1);
121896
+ if( rc!=SQLITE_OK ) return rc;
121897
+ *paPoslist = pMsr->aBuffer;
121898
+ assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );
121899
+ }else{
121900
+ *paPoslist = pList;
121901
+ }
121871121902
*piDocid = iDocid;
121872
- *paPoslist = pList;
121873121903
*pnPoslist = nList;
121874121904
break;
121875121905
}
121876121906
}
121877
-
121878121907
}
121879121908
121909
+ return SQLITE_OK;
121910
+}
121911
+
121912
+static int fts3SegReaderStart(
121913
+ Fts3Table *p, /* Virtual table handle */
121914
+ Fts3MultiSegReader *pCsr, /* Cursor object */
121915
+ const char *zTerm, /* Term searched for (or NULL) */
121916
+ int nTerm /* Length of zTerm in bytes */
121917
+){
121918
+ int i;
121919
+ int nSeg = pCsr->nSegment;
121920
+
121921
+ /* If the Fts3SegFilter defines a specific term (or term prefix) to search
121922
+ ** for, then advance each segment iterator until it points to a term of
121923
+ ** equal or greater value than the specified term. This prevents many
121924
+ ** unnecessary merge/sort operations for the case where single segment
121925
+ ** b-tree leaf nodes contain more than one term.
121926
+ */
121927
+ for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){
121928
+ Fts3SegReader *pSeg = pCsr->apSegment[i];
121929
+ do {
121930
+ int rc = fts3SegReaderNext(p, pSeg, 0);
121931
+ if( rc!=SQLITE_OK ) return rc;
121932
+ }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 );
121933
+ }
121934
+ fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp);
121935
+
121880121936
return SQLITE_OK;
121881121937
}
121882121938
121883121939
SQLITE_PRIVATE int sqlite3Fts3SegReaderStart(
121884121940
Fts3Table *p, /* Virtual table handle */
121885121941
Fts3MultiSegReader *pCsr, /* Cursor object */
121886121942
Fts3SegFilter *pFilter /* Restrictions on range of iteration */
121887121943
){
121888
- int i;
121889
-
121890
- /* Initialize the cursor object */
121891121944
pCsr->pFilter = pFilter;
121892
-
121893
- /* If the Fts3SegFilter defines a specific term (or term prefix) to search
121894
- ** for, then advance each segment iterator until it points to a term of
121895
- ** equal or greater value than the specified term. This prevents many
121896
- ** unnecessary merge/sort operations for the case where single segment
121897
- ** b-tree leaf nodes contain more than one term.
121898
- */
121899
- for(i=0; i<pCsr->nSegment; i++){
121900
- int nTerm = pFilter->nTerm;
121901
- const char *zTerm = pFilter->zTerm;
121945
+ return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm);
121946
+}
121947
+
121948
+SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(
121949
+ Fts3Table *p, /* Virtual table handle */
121950
+ Fts3MultiSegReader *pCsr, /* Cursor object */
121951
+ int iCol, /* Column to match on. */
121952
+ const char *zTerm, /* Term to iterate through a doclist for */
121953
+ int nTerm /* Number of bytes in zTerm */
121954
+){
121955
+ int i;
121956
+ int rc;
121957
+ int nSegment = pCsr->nSegment;
121958
+ int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (
121959
+ p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp
121960
+ );
121961
+
121962
+ assert( pCsr->pFilter==0 );
121963
+ assert( zTerm && nTerm>0 );
121964
+
121965
+ /* Advance each segment iterator until it points to the term zTerm/nTerm. */
121966
+ rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);
121967
+ if( rc!=SQLITE_OK ) return rc;
121968
+
121969
+ /* Determine how many of the segments actually point to zTerm/nTerm. */
121970
+ for(i=0; i<nSegment; i++){
121902121971
Fts3SegReader *pSeg = pCsr->apSegment[i];
121903
- do {
121904
- int rc = fts3SegReaderNext(p, pSeg, 0);
121905
- if( rc!=SQLITE_OK ) return rc;
121906
- }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 );
121972
+ if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){
121973
+ break;
121974
+ }
121907121975
}
121908
- fts3SegReaderSort(
121909
- pCsr->apSegment, pCsr->nSegment, pCsr->nSegment, fts3SegReaderCmp);
121976
+ pCsr->nAdvance = i;
121977
+
121978
+ /* Advance each of the segments to point to the first docid. */
121979
+ for(i=0; i<pCsr->nAdvance; i++){
121980
+ rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);
121981
+ if( rc!=SQLITE_OK ) return rc;
121982
+ }
121983
+ fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);
121984
+
121985
+ assert( iCol<0 || iCol<p->nColumn );
121986
+ pCsr->iColFilter = iCol;
121987
+
121988
+ return SQLITE_OK;
121989
+}
121990
+
121991
+/*
121992
+** This function is called on a MultiSegReader that has been started using
121993
+** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also
121994
+** have been made. Calling this function puts the MultiSegReader in such
121995
+** a state that if the next two calls are:
121996
+**
121997
+** sqlite3Fts3SegReaderStart()
121998
+** sqlite3Fts3SegReaderStep()
121999
+**
122000
+** then the entire doclist for the term is available in
122001
+** MultiSegReader.aDoclist/nDoclist.
122002
+*/
122003
+SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){
122004
+ int i; /* Used to iterate through segment-readers */
122005
+
122006
+ assert( pCsr->zTerm==0 );
122007
+ assert( pCsr->nTerm==0 );
122008
+ assert( pCsr->aDoclist==0 );
122009
+ assert( pCsr->nDoclist==0 );
122010
+
122011
+ pCsr->nAdvance = 0;
122012
+ pCsr->bRestart = 1;
122013
+ for(i=0; i<pCsr->nSegment; i++){
122014
+ pCsr->apSegment[i]->pOffsetList = 0;
122015
+ pCsr->apSegment[i]->nOffsetList = 0;
122016
+ pCsr->apSegment[i]->iDocid = 0;
122017
+ }
121910122018
121911122019
return SQLITE_OK;
121912122020
}
122021
+
121913122022
121914122023
SQLITE_PRIVATE int sqlite3Fts3SegReaderStep(
121915122024
Fts3Table *p, /* Virtual table handle */
121916122025
Fts3MultiSegReader *pCsr /* Cursor object */
121917122026
){
@@ -121981,13 +122090,18 @@
121981122090
assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );
121982122091
if( nMerge==1
121983122092
&& !isIgnoreEmpty
121984122093
&& (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)
121985122094
){
121986
- pCsr->aDoclist = apSegment[0]->aDoclist;
121987122095
pCsr->nDoclist = apSegment[0]->nDoclist;
121988
- rc = SQLITE_ROW;
122096
+ if( fts3SegReaderIsPending(apSegment[0]) ){
122097
+ rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);
122098
+ pCsr->aDoclist = pCsr->aBuffer;
122099
+ }else{
122100
+ pCsr->aDoclist = apSegment[0]->aDoclist;
122101
+ }
122102
+ if( rc==SQLITE_OK ) rc = SQLITE_ROW;
121989122103
}else{
121990122104
int nDoclist = 0; /* Size of doclist */
121991122105
sqlite3_int64 iPrev = 0; /* Previous docid stored in doclist */
121992122106
121993122107
/* The current term of the first nMerge entries in the array
@@ -123725,11 +123839,11 @@
123725123839
if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;
123726123840
break;
123727123841
123728123842
case FTS3_MATCHINFO_NDOC:
123729123843
if( bGlobal ){
123730
- sqlite3_int64 nDoc;
123844
+ sqlite3_int64 nDoc = 0;
123731123845
rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);
123732123846
pInfo->aMatchinfo[0] = (u32)nDoc;
123733123847
}
123734123848
break;
123735123849
@@ -125620,11 +125734,11 @@
125620125734
*/
125621125735
static float cellArea(Rtree *pRtree, RtreeCell *p){
125622125736
float area = 1.0;
125623125737
int ii;
125624125738
for(ii=0; ii<(pRtree->nDim*2); ii+=2){
125625
- area = area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));
125739
+ area = (float)(area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])));
125626125740
}
125627125741
return area;
125628125742
}
125629125743
125630125744
/*
@@ -125633,11 +125747,11 @@
125633125747
*/
125634125748
static float cellMargin(Rtree *pRtree, RtreeCell *p){
125635125749
float margin = 0.0;
125636125750
int ii;
125637125751
for(ii=0; ii<(pRtree->nDim*2); ii+=2){
125638
- margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));
125752
+ margin += (float)(DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));
125639125753
}
125640125754
return margin;
125641125755
}
125642125756
125643125757
/*
@@ -125718,11 +125832,11 @@
125718125832
125719125833
if( x2<x1 ){
125720125834
o = 0.0;
125721125835
break;
125722125836
}else{
125723
- o = o * (x2-x1);
125837
+ o = o * (float)(x2-x1);
125724125838
}
125725125839
}
125726125840
overlap += o;
125727125841
}
125728125842
}
@@ -125737,16 +125851,16 @@
125737125851
RtreeCell *pInsert,
125738125852
RtreeCell *aCell,
125739125853
int nCell,
125740125854
int iExclude
125741125855
){
125742
- float before;
125743
- float after;
125856
+ double before;
125857
+ double after;
125744125858
before = cellOverlap(pRtree, p, aCell, nCell, iExclude);
125745125859
cellUnion(pRtree, p, pInsert);
125746125860
after = cellOverlap(pRtree, p, aCell, nCell, iExclude);
125747
- return after-before;
125861
+ return (float)(after-before);
125748125862
}
125749125863
#endif
125750125864
125751125865
125752125866
/*
@@ -125764,15 +125878,15 @@
125764125878
RtreeNode *pNode;
125765125879
rc = nodeAcquire(pRtree, 1, 0, &pNode);
125766125880
125767125881
for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){
125768125882
int iCell;
125769
- sqlite3_int64 iBest;
125883
+ sqlite3_int64 iBest = 0;
125770125884
125771
- float fMinGrowth;
125772
- float fMinArea;
125773
- float fMinOverlap;
125885
+ float fMinGrowth = 0.0;
125886
+ float fMinArea = 0.0;
125887
+ float fMinOverlap = 0.0;
125774125888
125775125889
int nCell = NCELL(pNode);
125776125890
RtreeCell cell;
125777125891
RtreeNode *pChild;
125778125892
@@ -126198,13 +126312,13 @@
126198126312
){
126199126313
int **aaSorted;
126200126314
int *aSpare;
126201126315
int ii;
126202126316
126203
- int iBestDim;
126204
- int iBestSplit;
126205
- float fBestMargin;
126317
+ int iBestDim = 0;
126318
+ int iBestSplit = 0;
126319
+ float fBestMargin = 0.0;
126206126320
126207126321
int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
126208126322
126209126323
aaSorted = (int **)sqlite3_malloc(nByte);
126210126324
if( !aaSorted ){
@@ -126222,13 +126336,13 @@
126222126336
SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);
126223126337
}
126224126338
126225126339
for(ii=0; ii<pRtree->nDim; ii++){
126226126340
float margin = 0.0;
126227
- float fBestOverlap;
126228
- float fBestArea;
126229
- int iBestLeft;
126341
+ float fBestOverlap = 0.0;
126342
+ float fBestArea = 0.0;
126343
+ int iBestLeft = 0;
126230126344
int nLeft;
126231126345
126232126346
for(
126233126347
nLeft=RTREE_MINCELLS(pRtree);
126234126348
nLeft<=(nCell-RTREE_MINCELLS(pRtree));
@@ -126539,11 +126653,11 @@
126539126653
static int deleteCell(Rtree *, RtreeNode *, int, int);
126540126654
126541126655
static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
126542126656
int rc;
126543126657
int rc2;
126544
- RtreeNode *pParent;
126658
+ RtreeNode *pParent = 0;
126545126659
int iCell;
126546126660
126547126661
assert( pNode->nRef==1 );
126548126662
126549126663
/* Remove the entry in the parent cell. */
@@ -126687,23 +126801,23 @@
126687126801
}else{
126688126802
nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
126689126803
}
126690126804
aOrder[ii] = ii;
126691126805
for(iDim=0; iDim<pRtree->nDim; iDim++){
126692
- aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);
126693
- aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);
126806
+ aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2]);
126807
+ aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2+1]);
126694126808
}
126695126809
}
126696126810
for(iDim=0; iDim<pRtree->nDim; iDim++){
126697
- aCenterCoord[iDim] = aCenterCoord[iDim]/((float)nCell*2.0);
126811
+ aCenterCoord[iDim] = (float)(aCenterCoord[iDim]/((float)nCell*2.0));
126698126812
}
126699126813
126700126814
for(ii=0; ii<nCell; ii++){
126701126815
aDistance[ii] = 0.0;
126702126816
for(iDim=0; iDim<pRtree->nDim; iDim++){
126703
- float coord = DCOORD(aCell[ii].aCoord[iDim*2+1]) -
126704
- DCOORD(aCell[ii].aCoord[iDim*2]);
126817
+ float coord = (float)(DCOORD(aCell[ii].aCoord[iDim*2+1]) -
126818
+ DCOORD(aCell[ii].aCoord[iDim*2]));
126705126819
aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);
126706126820
}
126707126821
}
126708126822
126709126823
SortByDistance(aOrder, nCell, aDistance, aSpare);
@@ -126798,14 +126912,14 @@
126798126912
nodeGetCell(pRtree, pNode, ii, &cell);
126799126913
126800126914
/* Find a node to store this cell in. pNode->iNode currently contains
126801126915
** the height of the sub-tree headed by the cell.
126802126916
*/
126803
- rc = ChooseLeaf(pRtree, &cell, pNode->iNode, &pInsert);
126917
+ rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
126804126918
if( rc==SQLITE_OK ){
126805126919
int rc2;
126806
- rc = rtreeInsertCell(pRtree, pInsert, &cell, pNode->iNode);
126920
+ rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);
126807126921
rc2 = nodeRelease(pRtree, pInsert);
126808126922
if( rc==SQLITE_OK ){
126809126923
rc = rc2;
126810126924
}
126811126925
}
@@ -127190,11 +127304,11 @@
127190127304
int isCreate /* True for xCreate, false for xConnect */
127191127305
){
127192127306
int rc;
127193127307
char *zSql;
127194127308
if( isCreate ){
127195
- int iPageSize;
127309
+ int iPageSize = 0;
127196127310
zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb);
127197127311
rc = getIntFromStmt(db, zSql, &iPageSize);
127198127312
if( rc==SQLITE_OK ){
127199127313
pRtree->iNodeSize = iPageSize-64;
127200127314
if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){
@@ -127993,14 +128107,11 @@
127993128107
** May you find forgiveness for yourself and forgive others.
127994128108
** May you share freely, never taking more than you give.
127995128109
**
127996128110
*************************************************************************
127997128111
** This file implements a tokenizer for fts3 based on the ICU library.
127998
-**
127999
-** $Id: fts3_icu.c,v 1.3 2008/09/01 18:34:20 danielk1977 Exp $
128000128112
*/
128001
-
128002128113
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
128003128114
#ifdef SQLITE_ENABLE_ICU
128004128115
128005128116
128006128117
#include <unicode/ubrk.h>
128007128118
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -650,11 +650,11 @@
650 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
651 ** [sqlite_version()] and [sqlite_source_id()].
652 */
653 #define SQLITE_VERSION "3.7.7"
654 #define SQLITE_VERSION_NUMBER 3007007
655 #define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389"
656
657 /*
658 ** CAPI3REF: Run-Time Library Version Numbers
659 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
660 **
@@ -851,11 +851,11 @@
851 ** semicolon-separate SQL statements passed into its 2nd argument,
852 ** in the context of the [database connection] passed in as its 1st
853 ** argument. ^If the callback function of the 3rd argument to
854 ** sqlite3_exec() is not NULL, then it is invoked for each result row
855 ** coming out of the evaluated SQL statements. ^The 4th argument to
856 ** to sqlite3_exec() is relayed through to the 1st argument of each
857 ** callback invocation. ^If the callback pointer to sqlite3_exec()
858 ** is NULL, then no callback is ever invoked and result rows are
859 ** ignored.
860 **
861 ** ^If an error occurs while evaluating the SQL statements passed into
@@ -1443,11 +1443,11 @@
1443 ** The xSleep() method causes the calling thread to sleep for at
1444 ** least the number of microseconds given. ^The xCurrentTime()
1445 ** method returns a Julian Day Number for the current date and time as
1446 ** a floating point value.
1447 ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
1448 ** Day Number multipled by 86400000 (the number of milliseconds in
1449 ** a 24-hour day).
1450 ** ^SQLite will use the xCurrentTimeInt64() method to get the current
1451 ** date and time if that method is available (if iVersion is 2 or
1452 ** greater and the function pointer is not NULL) and will fall back
1453 ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
@@ -1881,11 +1881,11 @@
1881 ** scratch memory beyond what is provided by this configuration option, then
1882 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
1883 **
1884 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1885 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1886 ** the database page cache with the default page cache implemenation.
1887 ** This configuration should not be used if an application-define page
1888 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1889 ** There are three arguments to this option: A pointer to 8-byte aligned
1890 ** memory, the size of each page buffer (sz), and the number of pages (N).
1891 ** The sz argument should be the size of the largest database page
@@ -2979,16 +2979,16 @@
2979 ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
2980 **
2981 ** ^If [URI filename] interpretation is enabled, and the filename argument
2982 ** begins with "file:", then the filename is interpreted as a URI. ^URI
2983 ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2984 ** is set in the fourth argument to sqlite3_open_v2(), or if it has
2985 ** been enabled globally using the [SQLITE_CONFIG_URI] option with the
2986 ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
2987 ** As of SQLite version 3.7.7, URI filename interpretation is turned off
2988 ** by default, but future releases of SQLite might enable URI filename
2989 ** intepretation by default. See "[URI filenames]" for additional
2990 ** information.
2991 **
2992 ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
2993 ** authority, then it must be either an empty string or the string
2994 ** "localhost". ^If the authority is not an empty string or "localhost", an
@@ -3803,11 +3803,11 @@
3803 ** [extended result codes] might be returned as well.
3804 **
3805 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3806 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3807 ** or occurs outside of an explicit transaction, then you can retry the
3808 ** statement. If the statement is not a [COMMIT] and occurs within a
3809 ** explicit transaction then you should rollback the transaction before
3810 ** continuing.
3811 **
3812 ** ^[SQLITE_DONE] means that the statement has finished executing
3813 ** successfully. sqlite3_step() should not be called again on this virtual
@@ -4082,11 +4082,11 @@
4082
4083 /*
4084 ** CAPI3REF: Destroy A Prepared Statement Object
4085 **
4086 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4087 ** ^If the most recent evaluation of the statement encountered no errors or
4088 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
4089 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
4090 ** sqlite3_finalize(S) returns the appropriate [error code] or
4091 ** [extended error code].
4092 **
@@ -5996,11 +5996,11 @@
5996 ** versions of these routines, it should at least provide stubs that always
5997 ** return true so that one does not get spurious assertion failures.
5998 **
5999 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
6000 ** the routine should return 1. This seems counter-intuitive since
6001 ** clearly the mutex cannot be held if it does not exist. But the
6002 ** the reason the mutex does not exist is because the build is not
6003 ** using mutexes. And we do not want the assert() containing the
6004 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6005 ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
6006 ** interface should also return 1 when given a NULL pointer.
@@ -6505,11 +6505,11 @@
6505 ** [[the xFetch() page cache methods]]
6506 ** The xFetch() method locates a page in the cache and returns a pointer to
6507 ** the page, or a NULL pointer.
6508 ** A "page", in this context, means a buffer of szPage bytes aligned at an
6509 ** 8-byte boundary. The page to be fetched is determined by the key. ^The
6510 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
6511 ** is considered to be "pinned".
6512 **
6513 ** If the requested page is already in the page cache, then the page cache
6514 ** implementation must return a pointer to the page buffer with its content
6515 ** intact. If the requested page is not already in the cache, then the
@@ -24364,10 +24364,14 @@
24364
24365 #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
24366 # include <sys/mount.h>
24367 #endif
24368
 
 
 
 
24369 /*
24370 ** Allowed values of unixFile.fsFlags
24371 */
24372 #define SQLITE_FSFLAGS_IS_MSDOS 0x1
24373
@@ -26369,12 +26373,14 @@
26369 /* If we have any lock, then the lock file already exists. All we have
26370 ** to do is adjust our internal record of the lock level.
26371 */
26372 if( pFile->eFileLock > NO_LOCK ){
26373 pFile->eFileLock = eFileLock;
26374 #if !OS_VXWORKS
26375 /* Always update the timestamp on the old file */
 
 
 
26376 utimes(zLockFile, NULL);
26377 #endif
26378 return SQLITE_OK;
26379 }
26380
@@ -32254,11 +32260,12 @@
32254 rc = 1;
32255 }
32256 }
32257
32258 if( rc ){
32259 if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){
 
32260 return SQLITE_FULL;
32261 }
32262 return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath);
32263 }
32264 return SQLITE_OK;
@@ -63496,11 +63503,11 @@
63496 break;
63497 }
63498
63499 /* Opcode: HaltIfNull P1 P2 P3 P4 *
63500 **
63501 ** Check the value in register P3. If is is NULL then Halt using
63502 ** parameter P1, P2, and P4 as if this were a Halt instruction. If the
63503 ** value in register P3 is not NULL, then this routine is a no-op.
63504 */
63505 case OP_HaltIfNull: { /* in3 */
63506 pIn3 = &aMem[pOp->p3];
@@ -64433,11 +64440,11 @@
64433 ** additional information.
64434 **
64435 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
64436 ** true or false and is never NULL. If both operands are NULL then the result
64437 ** of comparison is false. If either operand is NULL then the result is true.
64438 ** If neither operand is NULL the the result is the same as it would be if
64439 ** the SQLITE_NULLEQ flag were omitted from P5.
64440 */
64441 /* Opcode: Eq P1 P2 P3 P4 P5
64442 **
64443 ** This works just like the Lt opcode except that the jump is taken if
@@ -64445,11 +64452,11 @@
64445 ** See the Lt opcode for additional information.
64446 **
64447 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
64448 ** true or false and is never NULL. If both operands are NULL then the result
64449 ** of comparison is true. If either operand is NULL then the result is false.
64450 ** If neither operand is NULL the the result is the same as it would be if
64451 ** the SQLITE_NULLEQ flag were omitted from P5.
64452 */
64453 /* Opcode: Le P1 P2 P3 P4 P5
64454 **
64455 ** This works just like the Lt opcode except that the jump is taken if
@@ -64730,17 +64737,17 @@
64730 break;
64731 }
64732
64733 /* Opcode: If P1 P2 P3 * *
64734 **
64735 ** Jump to P2 if the value in register P1 is true. The value is
64736 ** is considered true if it is numeric and non-zero. If the value
64737 ** in P1 is NULL then take the jump if P3 is true.
64738 */
64739 /* Opcode: IfNot P1 P2 P3 * *
64740 **
64741 ** Jump to P2 if the value in register P1 is False. The value is
64742 ** is considered true if it has a numeric value of zero. If the value
64743 ** in P1 is NULL then take the jump if P3 is true.
64744 */
64745 case OP_If: /* jump, in1 */
64746 case OP_IfNot: { /* jump, in1 */
@@ -66390,11 +66397,11 @@
66390 break;
66391 }
66392
66393 /* Opcode: NotExists P1 P2 P3 * *
66394 **
66395 ** Use the content of register P3 as a integer key. If a record
66396 ** with that key does not exist in table of P1, then jump to P2.
66397 ** If the record does exist, then fall through. The cursor is left
66398 ** pointing to the record if it exists.
66399 **
66400 ** The difference between this operation and NotFound is that this
@@ -66468,11 +66475,11 @@
66468 ** written to register P2.
66469 **
66470 ** If P3>0 then P3 is a register in the root frame of this VDBE that holds
66471 ** the largest previously generated record number. No new record numbers are
66472 ** allowed to be less than this value. When this value reaches its maximum,
66473 ** a SQLITE_FULL error is generated. The P3 register is updated with the '
66474 ** generated record number. This P3 mechanism is used to help implement the
66475 ** AUTOINCREMENT feature.
66476 */
66477 case OP_NewRowid: { /* out2-prerelease */
66478 #if 0 /* local variables moved into u.be */
@@ -67110,11 +67117,11 @@
67110 break;
67111 }
67112
67113 /* Opcode: IdxInsert P1 P2 P3 * P5
67114 **
67115 ** Register P2 holds a SQL index key made using the
67116 ** MakeRecord instructions. This opcode writes that key
67117 ** into the index P1. Data for the entry is nil.
67118 **
67119 ** P3 is a flag that provides a hint to the b-tree layer that this
67120 ** insert is likely to be an append.
@@ -111420,16 +111427,10 @@
111420 ** TODO(shess) Provide a VACUUM type operation to clear out all
111421 ** deletions and duplications. This would basically be a forced merge
111422 ** into a single segment.
111423 */
111424
111425 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
111426
111427 #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)
111428 # define SQLITE_CORE 1
111429 #endif
111430
111431 /************** Include fts3Int.h in the middle of fts3.c ********************/
111432 /************** Begin file fts3Int.h *****************************************/
111433 /*
111434 ** 2009 Nov 12
111435 **
@@ -111441,18 +111442,27 @@
111441 ** May you share freely, never taking more than you give.
111442 **
111443 ******************************************************************************
111444 **
111445 */
111446
111447 #ifndef _FTSINT_H
111448 #define _FTSINT_H
111449
111450 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
111451 # define NDEBUG 1
111452 #endif
111453
 
 
 
 
 
 
 
 
 
 
111454 /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
111455 /************** Begin file fts3_tokenizer.h **********************************/
111456 /*
111457 ** 2006 July 10
111458 **
@@ -111940,11 +111950,11 @@
111940 char *aDoclist; /* List of docids for full-text queries */
111941 int nDoclist; /* Size of buffer at aDoclist */
111942 u8 bDesc; /* True to sort in descending order */
111943 int eEvalmode; /* An FTS3_EVAL_XX constant */
111944 int nRowAvg; /* Average size of database rows, in pages */
111945 int nDoc; /* Documents in table */
111946
111947 int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */
111948 u32 *aMatchinfo; /* Information about most recent match */
111949 int nMatchinfo; /* Number of elements in aMatchinfo[] */
111950 char *zMatchinfo; /* Matchinfo specification */
@@ -111997,19 +112007,19 @@
111997 int isPrefix; /* True if token ends with a "*" character */
111998
111999 /* Variables above this point are populated when the expression is
112000 ** parsed (by code in fts3_expr.c). Below this point the variables are
112001 ** used when evaluating the expression. */
112002 int bFulltext; /* True if full-text index was used */
112003 Fts3DeferredToken *pDeferred; /* Deferred token object for this token */
112004 Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */
112005 };
112006
112007 struct Fts3Phrase {
112008 /* Cache of doclist for this phrase. */
112009 Fts3Doclist doclist;
112010 int bIncr; /* True if doclist is loaded incrementally */
 
112011
112012 /* Variables below this point are populated by fts3_expr.c when parsing
112013 ** a MATCH expression. Everything above is part of the evaluation phase.
112014 */
112015 int nToken; /* Number of tokens in the phrase */
@@ -112130,10 +112140,11 @@
112130 Fts3SegFilter *pFilter; /* Pointer to filter object */
112131 char *aBuffer; /* Buffer to merge doclists in */
112132 int nBuffer; /* Allocated size of aBuffer[] in bytes */
112133
112134 int iColFilter; /* If >=0, filter for this column */
 
112135
112136 /* Used by fts3.c only. */
112137 int nCost; /* Cost of running iterator */
112138 int bLookup; /* True if a lookup of a single entry. */
112139
@@ -112199,18 +112210,24 @@
112199 Fts3Table*, Fts3MultiSegReader*, int, const char*, int);
112200 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
112201 Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
112202 SQLITE_PRIVATE char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol);
112203 SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
 
112204
112205 SQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);
112206
112207
112208 #endif /* _FTSINT_H */
112209
112210 /************** End of fts3Int.h *********************************************/
112211 /************** Continuing where we left off in fts3.c ***********************/
 
 
 
 
 
112212
112213
112214 #ifndef SQLITE_CORE
112215 SQLITE_EXTENSION_INIT1
112216 #endif
@@ -112995,11 +113012,11 @@
112995 zCsr += nDb;
112996
112997 /* Fill in the azColumn array */
112998 for(iCol=0; iCol<nCol; iCol++){
112999 char *z;
113000 int n;
113001 z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);
113002 memcpy(zCsr, z, n);
113003 zCsr[n] = '\0';
113004 sqlite3Fts3Dequote(zCsr);
113005 p->azColumn[iCol] = zCsr;
@@ -114581,12 +114598,12 @@
114581
114582 /*
114583 ** Implementation of xBegin() method. This is a no-op.
114584 */
114585 static int fts3BeginMethod(sqlite3_vtab *pVtab){
114586 UNUSED_PARAMETER(pVtab);
114587 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
 
114588 assert( p->pSegments==0 );
114589 assert( p->nPendingData==0 );
114590 assert( p->inTransaction!=1 );
114591 TESTONLY( p->inTransaction = 1 );
114592 TESTONLY( p->mxSavepoint = -1; );
@@ -114597,12 +114614,12 @@
114597 ** Implementation of xCommit() method. This is a no-op. The contents of
114598 ** the pending-terms hash-table have already been flushed into the database
114599 ** by fts3SyncMethod().
114600 */
114601 static int fts3CommitMethod(sqlite3_vtab *pVtab){
114602 UNUSED_PARAMETER(pVtab);
114603 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
 
114604 assert( p->nPendingData==0 );
114605 assert( p->inTransaction!=0 );
114606 assert( p->pSegments==0 );
114607 TESTONLY( p->inTransaction = 0 );
114608 TESTONLY( p->mxSavepoint = -1; );
@@ -115083,75 +115100,105 @@
115083 if( rc!=SQLITE_OK ){
115084 *pRc = rc;
115085 return;
115086 }
115087 }
 
 
115088 }else{
115089 *pnOr += (pExpr->eType==FTSQUERY_OR);
115090 fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);
115091 fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);
115092 }
115093 }
115094 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115095
115096 static int fts3EvalPhraseLoad(
115097 Fts3Cursor *pCsr,
115098 Fts3Phrase *p
115099 ){
115100 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
115101 int iToken;
115102 int rc = SQLITE_OK;
115103
115104 char *aDoclist = 0;
115105 int nDoclist = 0;
115106 int iPrev = -1;
115107
115108 for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){
115109 Fts3PhraseToken *pToken = &p->aToken[iToken];
115110 assert( pToken->pSegcsr || pToken->pDeferred );
115111
115112 if( pToken->pDeferred==0 ){
115113 int nThis = 0;
115114 char *pThis = 0;
115115 rc = fts3TermSelect(pTab, pToken, p->iColumn, 1, &nThis, &pThis);
115116 if( rc==SQLITE_OK ){
115117 if( pThis==0 ){
115118 sqlite3_free(aDoclist);
115119 aDoclist = 0;
115120 nDoclist = 0;
115121 break;
115122 }else if( aDoclist==0 ){
115123 aDoclist = pThis;
115124 nDoclist = nThis;
115125 }else{
115126 assert( iPrev>=0 );
115127 fts3DoclistPhraseMerge(pTab->bDescIdx,
115128 iToken-iPrev, aDoclist, nDoclist, pThis, &nThis
115129 );
115130 sqlite3_free(aDoclist);
115131 aDoclist = pThis;
115132 nDoclist = nThis;
115133 }
115134 iPrev = iToken;
115135 }
115136 }
115137 }
115138
115139 if( rc==SQLITE_OK ){
115140 p->doclist.aAll = aDoclist;
115141 p->doclist.nAll = nDoclist;
115142 }else{
115143 sqlite3_free(aDoclist);
115144 }
115145 return rc;
115146 }
115147
115148 static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
115149 int iToken;
115150 int rc = SQLITE_OK;
115151
115152 int nMaxUndeferred = -1;
115153 char *aPoslist = 0;
115154 int nPoslist = 0;
115155 int iPrev = -1;
115156
115157 assert( pPhrase->doclist.bFreeList==0 );
@@ -115192,12 +115239,10 @@
115192 pPhrase->doclist.nList = 0;
115193 return SQLITE_OK;
115194 }
115195 }
115196 iPrev = iToken;
115197 }else{
115198 nMaxUndeferred = iToken;
115199 }
115200 }
115201
115202 if( iPrev>=0 ){
115203 if( nMaxUndeferred<0 ){
@@ -115252,13 +115297,15 @@
115252 static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){
115253 int rc;
115254 Fts3PhraseToken *pFirst = &p->aToken[0];
115255 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
115256
115257 assert( p->doclist.aAll==0 );
115258 if( pCsr->bDesc==pTab->bDescIdx && bOptOk==1 && p->nToken==1
115259 && pFirst->pSegcsr && pFirst->pSegcsr->bLookup
 
 
115260 ){
115261 /* Use the incremental approach. */
115262 int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);
115263 rc = sqlite3Fts3MsrIncrStart(
115264 pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n);
@@ -115394,11 +115441,11 @@
115394 ** with this case by advancing pIter past the zero-padding added by
115395 ** fts3EvalNearTrim2(). */
115396 while( pIter<pEnd && *pIter==0 ) pIter++;
115397
115398 pDL->pNextDocid = pIter;
115399 assert( *pIter || pIter>=&pDL->aAll[pDL->nAll] );
115400 *pbEof = 0;
115401 }
115402 }
115403
115404 return rc;
@@ -115425,17 +115472,18 @@
115425 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
115426 }
115427 }
115428 }
115429
115430
115431 typedef struct Fts3TokenAndCost Fts3TokenAndCost;
115432 struct Fts3TokenAndCost {
115433 Fts3PhraseToken *pToken;
115434 Fts3Expr *pRoot;
 
 
115435 int nOvfl;
115436 int iCol;
115437 };
115438
115439 static void fts3EvalTokenCosts(
115440 Fts3Cursor *pCsr,
115441 Fts3Expr *pRoot,
@@ -115448,10 +115496,12 @@
115448 if( pExpr->eType==FTSQUERY_PHRASE ){
115449 Fts3Phrase *pPhrase = pExpr->pPhrase;
115450 int i;
115451 for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){
115452 Fts3TokenAndCost *pTC = (*ppTC)++;
 
 
115453 pTC->pRoot = pRoot;
115454 pTC->pToken = &pPhrase->aToken[i];
115455 pTC->iCol = pPhrase->iColumn;
115456 *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);
115457 }
@@ -115560,23 +115610,19 @@
115560 /* At this point pTC points to the cheapest remaining token. */
115561 if( ii==0 ){
115562 if( pTC->nOvfl ){
115563 nDocEst = (pTC->nOvfl * pTab->nPgsz + pTab->nPgsz) / 10;
115564 }else{
115565 /* TODO: Fix this so that the doclist need not be read twice. */
115566 Fts3PhraseToken *pToken = pTC->pToken;
115567 int nList = 0;
115568 char *pList = 0;
115569 rc = fts3TermSelect(pTab, pToken, pTC->iCol, 1, &nList, &pList);
 
 
115570 if( rc==SQLITE_OK ){
115571 nDocEst = fts3DoclistCountDocids(1, pList, nList);
115572 }
115573 sqlite3_free(pList);
115574 if( rc==SQLITE_OK ){
115575 rc = sqlite3Fts3TermSegReaderCursor(pCsr,
115576 pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr
115577 );
115578 }
115579 }
115580 }else{
115581 if( pTC->nOvfl>=(nDocEst*nDocSize) ){
115582 Fts3PhraseToken *pToken = pTC->pToken;
@@ -116032,17 +116078,18 @@
116032 Fts3Phrase *pPhrase = pExpr->pPhrase;
116033
116034 if( pPhrase ){
116035 fts3EvalZeroPoslist(pPhrase);
116036 if( pPhrase->bIncr ){
116037 sqlite3Fts3EvalPhraseCleanup(pPhrase);
116038 memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist));
116039 *pRc = sqlite3Fts3EvalStart(pCsr, pExpr, 0);
116040 }else{
116041 pPhrase->doclist.pNextDocid = 0;
116042 pPhrase->doclist.iDocid = 0;
116043 }
 
 
 
116044 }
116045
116046 pExpr->iDocid = 0;
116047 pExpr->bEof = 0;
116048 pExpr->bStart = 0;
@@ -116225,12 +116272,12 @@
116225 int iCol;
116226
116227 if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){
116228 assert( pCsr->nDoc>0 );
116229 for(iCol=0; iCol<pTab->nColumn; iCol++){
116230 aiOut[iCol*3 + 1] = pCsr->nDoc;
116231 aiOut[iCol*3 + 2] = pCsr->nDoc;
116232 }
116233 }else{
116234 rc = fts3EvalGatherStats(pCsr, pExpr);
116235 if( rc==SQLITE_OK ){
116236 assert( pExpr->aMI );
@@ -116334,11 +116381,10 @@
116334 ** May you share freely, never taking more than you give.
116335 **
116336 ******************************************************************************
116337 **
116338 */
116339
116340 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
116341
116342
116343 typedef struct Fts3auxTable Fts3auxTable;
116344 typedef struct Fts3auxCursor Fts3auxCursor;
@@ -118168,11 +118214,10 @@
118168 */
118169 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118170
118171
118172
118173
118174 /*
118175 ** Class derived from sqlite3_tokenizer
118176 */
118177 typedef struct porter_tokenizer {
118178 sqlite3_tokenizer base; /* Base class */
@@ -118808,15 +118853,15 @@
118808 ** (in which case SQLITE_CORE is not defined), or
118809 **
118810 ** * The FTS3 module is being built into the core of
118811 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
118812 */
118813 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118814
118815 #ifndef SQLITE_CORE
118816 SQLITE_EXTENSION_INIT1
118817 #endif
 
 
118818
118819
118820 /*
118821 ** Implementation of the SQL scalar function for accessing the underlying
118822 ** hash table. This function may be called as follows:
@@ -118937,11 +118982,11 @@
118937 sqlite3_tokenizer **ppTok, /* OUT: Tokenizer (if applicable) */
118938 char **pzErr /* OUT: Set to malloced error message */
118939 ){
118940 int rc;
118941 char *z = (char *)zArg;
118942 int n;
118943 char *zCopy;
118944 char *zEnd; /* Pointer to nul-term of zCopy */
118945 sqlite3_tokenizer_module *m;
118946
118947 zCopy = sqlite3_mprintf("%s", zArg);
@@ -119299,11 +119344,10 @@
119299 **
119300 ** * The FTS3 module is being built into the core of
119301 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
119302 */
119303 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
119304
119305
119306
119307
119308 typedef struct simple_tokenizer {
119309 sqlite3_tokenizer base;
@@ -120750,10 +120794,11 @@
120750 pReader->pOffsetList = 0;
120751 }else{
120752 pReader->pOffsetList = p;
120753 }
120754 }else{
 
120755
120756 /* Pointer p currently points at the first byte of an offset list. The
120757 ** following block advances it to point one byte past the end of
120758 ** the same offset list. */
120759 while( 1 ){
@@ -120778,17 +120823,19 @@
120778 */
120779 if( ppOffsetList ){
120780 *ppOffsetList = pReader->pOffsetList;
120781 *pnOffsetList = (int)(p - pReader->pOffsetList - 1);
120782 }
 
 
120783
120784 /* If there are no more entries in the doclist, set pOffsetList to
120785 ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and
120786 ** Fts3SegReader.pOffsetList to point to the next offset list before
120787 ** returning.
120788 */
120789 if( p>=&pReader->aDoclist[pReader->nDoclist] ){
120790 pReader->pOffsetList = 0;
120791 }else{
120792 rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
120793 if( rc==SQLITE_OK ){
120794 sqlite3_int64 iDelta;
@@ -120823,11 +120870,11 @@
120823 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
120824 Fts3SegReader *pReader = pMsr->apSegment[ii];
120825 if( !fts3SegReaderIsPending(pReader)
120826 && !fts3SegReaderIsRootOnly(pReader)
120827 ){
120828 int jj;
120829 for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){
120830 int nBlob;
120831 rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);
120832 if( rc!=SQLITE_OK ) break;
120833 if( (nBlob+35)>pgsz ){
@@ -121768,55 +121815,31 @@
121768
121769 *ppList = pList;
121770 *pnList = nList;
121771 }
121772
121773 SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(
121774 Fts3Table *p, /* Virtual table handle */
121775 Fts3MultiSegReader *pCsr, /* Cursor object */
121776 int iCol, /* Column to match on. */
121777 const char *zTerm, /* Term to iterate through a doclist for */
121778 int nTerm /* Number of bytes in zTerm */
 
 
 
 
 
121779 ){
121780 int i;
121781 int nSegment = pCsr->nSegment;
121782 int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (
121783 p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp
121784 );
121785
121786 assert( pCsr->pFilter==0 );
121787 assert( zTerm && nTerm>0 );
121788
121789 /* Advance each segment iterator until it points to the term zTerm/nTerm. */
121790 for(i=0; i<nSegment; i++){
121791 Fts3SegReader *pSeg = pCsr->apSegment[i];
121792 do {
121793 int rc = fts3SegReaderNext(p, pSeg, 1);
121794 if( rc!=SQLITE_OK ) return rc;
121795 }while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 );
121796 }
121797 fts3SegReaderSort(pCsr->apSegment, nSegment, nSegment, fts3SegReaderCmp);
121798
121799 /* Determine how many of the segments actually point to zTerm/nTerm. */
121800 for(i=0; i<nSegment; i++){
121801 Fts3SegReader *pSeg = pCsr->apSegment[i];
121802 if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){
121803 break;
121804 }
121805 }
121806 pCsr->nAdvance = i;
121807
121808 /* Advance each of the segments to point to the first docid. */
121809 for(i=0; i<pCsr->nAdvance; i++){
121810 int rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);
121811 if( rc!=SQLITE_OK ) return rc;
121812 }
121813 fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);
121814
121815 assert( iCol<0 || iCol<p->nColumn );
121816 pCsr->iColFilter = iCol;
121817
121818 return SQLITE_OK;
121819 }
121820
121821 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
121822 Fts3Table *p, /* Virtual table handle */
@@ -121866,52 +121889,138 @@
121866 if( pMsr->iColFilter>=0 ){
121867 fts3ColumnFilter(pMsr->iColFilter, &pList, &nList);
121868 }
121869
121870 if( nList>0 ){
 
 
 
 
 
 
 
 
121871 *piDocid = iDocid;
121872 *paPoslist = pList;
121873 *pnPoslist = nList;
121874 break;
121875 }
121876 }
121877
121878 }
121879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121880 return SQLITE_OK;
121881 }
121882
121883 SQLITE_PRIVATE int sqlite3Fts3SegReaderStart(
121884 Fts3Table *p, /* Virtual table handle */
121885 Fts3MultiSegReader *pCsr, /* Cursor object */
121886 Fts3SegFilter *pFilter /* Restrictions on range of iteration */
121887 ){
121888 int i;
121889
121890 /* Initialize the cursor object */
121891 pCsr->pFilter = pFilter;
121892
121893 /* If the Fts3SegFilter defines a specific term (or term prefix) to search
121894 ** for, then advance each segment iterator until it points to a term of
121895 ** equal or greater value than the specified term. This prevents many
121896 ** unnecessary merge/sort operations for the case where single segment
121897 ** b-tree leaf nodes contain more than one term.
121898 */
121899 for(i=0; i<pCsr->nSegment; i++){
121900 int nTerm = pFilter->nTerm;
121901 const char *zTerm = pFilter->zTerm;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121902 Fts3SegReader *pSeg = pCsr->apSegment[i];
121903 do {
121904 int rc = fts3SegReaderNext(p, pSeg, 0);
121905 if( rc!=SQLITE_OK ) return rc;
121906 }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 );
121907 }
121908 fts3SegReaderSort(
121909 pCsr->apSegment, pCsr->nSegment, pCsr->nSegment, fts3SegReaderCmp);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121910
121911 return SQLITE_OK;
121912 }
 
121913
121914 SQLITE_PRIVATE int sqlite3Fts3SegReaderStep(
121915 Fts3Table *p, /* Virtual table handle */
121916 Fts3MultiSegReader *pCsr /* Cursor object */
121917 ){
@@ -121981,13 +122090,18 @@
121981 assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );
121982 if( nMerge==1
121983 && !isIgnoreEmpty
121984 && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)
121985 ){
121986 pCsr->aDoclist = apSegment[0]->aDoclist;
121987 pCsr->nDoclist = apSegment[0]->nDoclist;
121988 rc = SQLITE_ROW;
 
 
 
 
 
 
121989 }else{
121990 int nDoclist = 0; /* Size of doclist */
121991 sqlite3_int64 iPrev = 0; /* Previous docid stored in doclist */
121992
121993 /* The current term of the first nMerge entries in the array
@@ -123725,11 +123839,11 @@
123725 if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;
123726 break;
123727
123728 case FTS3_MATCHINFO_NDOC:
123729 if( bGlobal ){
123730 sqlite3_int64 nDoc;
123731 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);
123732 pInfo->aMatchinfo[0] = (u32)nDoc;
123733 }
123734 break;
123735
@@ -125620,11 +125734,11 @@
125620 */
125621 static float cellArea(Rtree *pRtree, RtreeCell *p){
125622 float area = 1.0;
125623 int ii;
125624 for(ii=0; ii<(pRtree->nDim*2); ii+=2){
125625 area = area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));
125626 }
125627 return area;
125628 }
125629
125630 /*
@@ -125633,11 +125747,11 @@
125633 */
125634 static float cellMargin(Rtree *pRtree, RtreeCell *p){
125635 float margin = 0.0;
125636 int ii;
125637 for(ii=0; ii<(pRtree->nDim*2); ii+=2){
125638 margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));
125639 }
125640 return margin;
125641 }
125642
125643 /*
@@ -125718,11 +125832,11 @@
125718
125719 if( x2<x1 ){
125720 o = 0.0;
125721 break;
125722 }else{
125723 o = o * (x2-x1);
125724 }
125725 }
125726 overlap += o;
125727 }
125728 }
@@ -125737,16 +125851,16 @@
125737 RtreeCell *pInsert,
125738 RtreeCell *aCell,
125739 int nCell,
125740 int iExclude
125741 ){
125742 float before;
125743 float after;
125744 before = cellOverlap(pRtree, p, aCell, nCell, iExclude);
125745 cellUnion(pRtree, p, pInsert);
125746 after = cellOverlap(pRtree, p, aCell, nCell, iExclude);
125747 return after-before;
125748 }
125749 #endif
125750
125751
125752 /*
@@ -125764,15 +125878,15 @@
125764 RtreeNode *pNode;
125765 rc = nodeAcquire(pRtree, 1, 0, &pNode);
125766
125767 for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){
125768 int iCell;
125769 sqlite3_int64 iBest;
125770
125771 float fMinGrowth;
125772 float fMinArea;
125773 float fMinOverlap;
125774
125775 int nCell = NCELL(pNode);
125776 RtreeCell cell;
125777 RtreeNode *pChild;
125778
@@ -126198,13 +126312,13 @@
126198 ){
126199 int **aaSorted;
126200 int *aSpare;
126201 int ii;
126202
126203 int iBestDim;
126204 int iBestSplit;
126205 float fBestMargin;
126206
126207 int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
126208
126209 aaSorted = (int **)sqlite3_malloc(nByte);
126210 if( !aaSorted ){
@@ -126222,13 +126336,13 @@
126222 SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);
126223 }
126224
126225 for(ii=0; ii<pRtree->nDim; ii++){
126226 float margin = 0.0;
126227 float fBestOverlap;
126228 float fBestArea;
126229 int iBestLeft;
126230 int nLeft;
126231
126232 for(
126233 nLeft=RTREE_MINCELLS(pRtree);
126234 nLeft<=(nCell-RTREE_MINCELLS(pRtree));
@@ -126539,11 +126653,11 @@
126539 static int deleteCell(Rtree *, RtreeNode *, int, int);
126540
126541 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
126542 int rc;
126543 int rc2;
126544 RtreeNode *pParent;
126545 int iCell;
126546
126547 assert( pNode->nRef==1 );
126548
126549 /* Remove the entry in the parent cell. */
@@ -126687,23 +126801,23 @@
126687 }else{
126688 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
126689 }
126690 aOrder[ii] = ii;
126691 for(iDim=0; iDim<pRtree->nDim; iDim++){
126692 aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);
126693 aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);
126694 }
126695 }
126696 for(iDim=0; iDim<pRtree->nDim; iDim++){
126697 aCenterCoord[iDim] = aCenterCoord[iDim]/((float)nCell*2.0);
126698 }
126699
126700 for(ii=0; ii<nCell; ii++){
126701 aDistance[ii] = 0.0;
126702 for(iDim=0; iDim<pRtree->nDim; iDim++){
126703 float coord = DCOORD(aCell[ii].aCoord[iDim*2+1]) -
126704 DCOORD(aCell[ii].aCoord[iDim*2]);
126705 aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);
126706 }
126707 }
126708
126709 SortByDistance(aOrder, nCell, aDistance, aSpare);
@@ -126798,14 +126912,14 @@
126798 nodeGetCell(pRtree, pNode, ii, &cell);
126799
126800 /* Find a node to store this cell in. pNode->iNode currently contains
126801 ** the height of the sub-tree headed by the cell.
126802 */
126803 rc = ChooseLeaf(pRtree, &cell, pNode->iNode, &pInsert);
126804 if( rc==SQLITE_OK ){
126805 int rc2;
126806 rc = rtreeInsertCell(pRtree, pInsert, &cell, pNode->iNode);
126807 rc2 = nodeRelease(pRtree, pInsert);
126808 if( rc==SQLITE_OK ){
126809 rc = rc2;
126810 }
126811 }
@@ -127190,11 +127304,11 @@
127190 int isCreate /* True for xCreate, false for xConnect */
127191 ){
127192 int rc;
127193 char *zSql;
127194 if( isCreate ){
127195 int iPageSize;
127196 zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb);
127197 rc = getIntFromStmt(db, zSql, &iPageSize);
127198 if( rc==SQLITE_OK ){
127199 pRtree->iNodeSize = iPageSize-64;
127200 if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){
@@ -127993,14 +128107,11 @@
127993 ** May you find forgiveness for yourself and forgive others.
127994 ** May you share freely, never taking more than you give.
127995 **
127996 *************************************************************************
127997 ** This file implements a tokenizer for fts3 based on the ICU library.
127998 **
127999 ** $Id: fts3_icu.c,v 1.3 2008/09/01 18:34:20 danielk1977 Exp $
128000 */
128001
128002 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
128003 #ifdef SQLITE_ENABLE_ICU
128004
128005
128006 #include <unicode/ubrk.h>
128007
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -650,11 +650,11 @@
650 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
651 ** [sqlite_version()] and [sqlite_source_id()].
652 */
653 #define SQLITE_VERSION "3.7.7"
654 #define SQLITE_VERSION_NUMBER 3007007
655 #define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee"
656
657 /*
658 ** CAPI3REF: Run-Time Library Version Numbers
659 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
660 **
@@ -851,11 +851,11 @@
851 ** semicolon-separate SQL statements passed into its 2nd argument,
852 ** in the context of the [database connection] passed in as its 1st
853 ** argument. ^If the callback function of the 3rd argument to
854 ** sqlite3_exec() is not NULL, then it is invoked for each result row
855 ** coming out of the evaluated SQL statements. ^The 4th argument to
856 ** sqlite3_exec() is relayed through to the 1st argument of each
857 ** callback invocation. ^If the callback pointer to sqlite3_exec()
858 ** is NULL, then no callback is ever invoked and result rows are
859 ** ignored.
860 **
861 ** ^If an error occurs while evaluating the SQL statements passed into
@@ -1443,11 +1443,11 @@
1443 ** The xSleep() method causes the calling thread to sleep for at
1444 ** least the number of microseconds given. ^The xCurrentTime()
1445 ** method returns a Julian Day Number for the current date and time as
1446 ** a floating point value.
1447 ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
1448 ** Day Number multiplied by 86400000 (the number of milliseconds in
1449 ** a 24-hour day).
1450 ** ^SQLite will use the xCurrentTimeInt64() method to get the current
1451 ** date and time if that method is available (if iVersion is 2 or
1452 ** greater and the function pointer is not NULL) and will fall back
1453 ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
@@ -1881,11 +1881,11 @@
1881 ** scratch memory beyond what is provided by this configuration option, then
1882 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
1883 **
1884 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1885 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1886 ** the database page cache with the default page cache implementation.
1887 ** This configuration should not be used if an application-define page
1888 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1889 ** There are three arguments to this option: A pointer to 8-byte aligned
1890 ** memory, the size of each page buffer (sz), and the number of pages (N).
1891 ** The sz argument should be the size of the largest database page
@@ -2979,16 +2979,16 @@
2979 ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
2980 **
2981 ** ^If [URI filename] interpretation is enabled, and the filename argument
2982 ** begins with "file:", then the filename is interpreted as a URI. ^URI
2983 ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2984 ** set in the fourth argument to sqlite3_open_v2(), or if it has
2985 ** been enabled globally using the [SQLITE_CONFIG_URI] option with the
2986 ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
2987 ** As of SQLite version 3.7.7, URI filename interpretation is turned off
2988 ** by default, but future releases of SQLite might enable URI filename
2989 ** interpretation by default. See "[URI filenames]" for additional
2990 ** information.
2991 **
2992 ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
2993 ** authority, then it must be either an empty string or the string
2994 ** "localhost". ^If the authority is not an empty string or "localhost", an
@@ -3803,11 +3803,11 @@
3803 ** [extended result codes] might be returned as well.
3804 **
3805 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3806 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3807 ** or occurs outside of an explicit transaction, then you can retry the
3808 ** statement. If the statement is not a [COMMIT] and occurs within an
3809 ** explicit transaction then you should rollback the transaction before
3810 ** continuing.
3811 **
3812 ** ^[SQLITE_DONE] means that the statement has finished executing
3813 ** successfully. sqlite3_step() should not be called again on this virtual
@@ -4082,11 +4082,11 @@
4082
4083 /*
4084 ** CAPI3REF: Destroy A Prepared Statement Object
4085 **
4086 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4087 ** ^If the most recent evaluation of the statement encountered no errors
4088 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
4089 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
4090 ** sqlite3_finalize(S) returns the appropriate [error code] or
4091 ** [extended error code].
4092 **
@@ -5996,11 +5996,11 @@
5996 ** versions of these routines, it should at least provide stubs that always
5997 ** return true so that one does not get spurious assertion failures.
5998 **
5999 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
6000 ** the routine should return 1. This seems counter-intuitive since
6001 ** clearly the mutex cannot be held if it does not exist. But
6002 ** the reason the mutex does not exist is because the build is not
6003 ** using mutexes. And we do not want the assert() containing the
6004 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6005 ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
6006 ** interface should also return 1 when given a NULL pointer.
@@ -6505,11 +6505,11 @@
6505 ** [[the xFetch() page cache methods]]
6506 ** The xFetch() method locates a page in the cache and returns a pointer to
6507 ** the page, or a NULL pointer.
6508 ** A "page", in this context, means a buffer of szPage bytes aligned at an
6509 ** 8-byte boundary. The page to be fetched is determined by the key. ^The
6510 ** minimum key value is 1. After it has been retrieved using xFetch, the page
6511 ** is considered to be "pinned".
6512 **
6513 ** If the requested page is already in the page cache, then the page cache
6514 ** implementation must return a pointer to the page buffer with its content
6515 ** intact. If the requested page is not already in the cache, then the
@@ -24364,10 +24364,14 @@
24364
24365 #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
24366 # include <sys/mount.h>
24367 #endif
24368
24369 #ifdef HAVE_UTIME
24370 # include <utime.h>
24371 #endif
24372
24373 /*
24374 ** Allowed values of unixFile.fsFlags
24375 */
24376 #define SQLITE_FSFLAGS_IS_MSDOS 0x1
24377
@@ -26369,12 +26373,14 @@
26373 /* If we have any lock, then the lock file already exists. All we have
26374 ** to do is adjust our internal record of the lock level.
26375 */
26376 if( pFile->eFileLock > NO_LOCK ){
26377 pFile->eFileLock = eFileLock;
 
26378 /* Always update the timestamp on the old file */
26379 #ifdef HAVE_UTIME
26380 utime(zLockFile, NULL);
26381 #else
26382 utimes(zLockFile, NULL);
26383 #endif
26384 return SQLITE_OK;
26385 }
26386
@@ -32254,11 +32260,12 @@
32260 rc = 1;
32261 }
32262 }
32263
32264 if( rc ){
32265 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
32266 || ( pFile->lastErrno==ERROR_DISK_FULL )){
32267 return SQLITE_FULL;
32268 }
32269 return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath);
32270 }
32271 return SQLITE_OK;
@@ -63496,11 +63503,11 @@
63503 break;
63504 }
63505
63506 /* Opcode: HaltIfNull P1 P2 P3 P4 *
63507 **
63508 ** Check the value in register P3. If it is NULL then Halt using
63509 ** parameter P1, P2, and P4 as if this were a Halt instruction. If the
63510 ** value in register P3 is not NULL, then this routine is a no-op.
63511 */
63512 case OP_HaltIfNull: { /* in3 */
63513 pIn3 = &aMem[pOp->p3];
@@ -64433,11 +64440,11 @@
64440 ** additional information.
64441 **
64442 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
64443 ** true or false and is never NULL. If both operands are NULL then the result
64444 ** of comparison is false. If either operand is NULL then the result is true.
64445 ** If neither operand is NULL the result is the same as it would be if
64446 ** the SQLITE_NULLEQ flag were omitted from P5.
64447 */
64448 /* Opcode: Eq P1 P2 P3 P4 P5
64449 **
64450 ** This works just like the Lt opcode except that the jump is taken if
@@ -64445,11 +64452,11 @@
64452 ** See the Lt opcode for additional information.
64453 **
64454 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
64455 ** true or false and is never NULL. If both operands are NULL then the result
64456 ** of comparison is true. If either operand is NULL then the result is false.
64457 ** If neither operand is NULL the result is the same as it would be if
64458 ** the SQLITE_NULLEQ flag were omitted from P5.
64459 */
64460 /* Opcode: Le P1 P2 P3 P4 P5
64461 **
64462 ** This works just like the Lt opcode except that the jump is taken if
@@ -64730,17 +64737,17 @@
64737 break;
64738 }
64739
64740 /* Opcode: If P1 P2 P3 * *
64741 **
64742 ** Jump to P2 if the value in register P1 is true. The value
64743 ** is considered true if it is numeric and non-zero. If the value
64744 ** in P1 is NULL then take the jump if P3 is true.
64745 */
64746 /* Opcode: IfNot P1 P2 P3 * *
64747 **
64748 ** Jump to P2 if the value in register P1 is False. The value
64749 ** is considered true if it has a numeric value of zero. If the value
64750 ** in P1 is NULL then take the jump if P3 is true.
64751 */
64752 case OP_If: /* jump, in1 */
64753 case OP_IfNot: { /* jump, in1 */
@@ -66390,11 +66397,11 @@
66397 break;
66398 }
66399
66400 /* Opcode: NotExists P1 P2 P3 * *
66401 **
66402 ** Use the content of register P3 as an integer key. If a record
66403 ** with that key does not exist in table of P1, then jump to P2.
66404 ** If the record does exist, then fall through. The cursor is left
66405 ** pointing to the record if it exists.
66406 **
66407 ** The difference between this operation and NotFound is that this
@@ -66468,11 +66475,11 @@
66475 ** written to register P2.
66476 **
66477 ** If P3>0 then P3 is a register in the root frame of this VDBE that holds
66478 ** the largest previously generated record number. No new record numbers are
66479 ** allowed to be less than this value. When this value reaches its maximum,
66480 ** an SQLITE_FULL error is generated. The P3 register is updated with the '
66481 ** generated record number. This P3 mechanism is used to help implement the
66482 ** AUTOINCREMENT feature.
66483 */
66484 case OP_NewRowid: { /* out2-prerelease */
66485 #if 0 /* local variables moved into u.be */
@@ -67110,11 +67117,11 @@
67117 break;
67118 }
67119
67120 /* Opcode: IdxInsert P1 P2 P3 * P5
67121 **
67122 ** Register P2 holds an SQL index key made using the
67123 ** MakeRecord instructions. This opcode writes that key
67124 ** into the index P1. Data for the entry is nil.
67125 **
67126 ** P3 is a flag that provides a hint to the b-tree layer that this
67127 ** insert is likely to be an append.
@@ -111420,16 +111427,10 @@
111427 ** TODO(shess) Provide a VACUUM type operation to clear out all
111428 ** deletions and duplications. This would basically be a forced merge
111429 ** into a single segment.
111430 */
111431
 
 
 
 
 
 
111432 /************** Include fts3Int.h in the middle of fts3.c ********************/
111433 /************** Begin file fts3Int.h *****************************************/
111434 /*
111435 ** 2009 Nov 12
111436 **
@@ -111441,18 +111442,27 @@
111442 ** May you share freely, never taking more than you give.
111443 **
111444 ******************************************************************************
111445 **
111446 */
 
111447 #ifndef _FTSINT_H
111448 #define _FTSINT_H
111449
111450 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
111451 # define NDEBUG 1
111452 #endif
111453
111454 /*
111455 ** FTS4 is really an extension for FTS3. It is enabled using the
111456 ** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all
111457 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
111458 */
111459 #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
111460 # define SQLITE_ENABLE_FTS3
111461 #endif
111462
111463 #ifdef SQLITE_ENABLE_FTS3
111464 /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/
111465 /************** Begin file fts3_tokenizer.h **********************************/
111466 /*
111467 ** 2006 July 10
111468 **
@@ -111940,11 +111950,11 @@
111950 char *aDoclist; /* List of docids for full-text queries */
111951 int nDoclist; /* Size of buffer at aDoclist */
111952 u8 bDesc; /* True to sort in descending order */
111953 int eEvalmode; /* An FTS3_EVAL_XX constant */
111954 int nRowAvg; /* Average size of database rows, in pages */
111955 sqlite3_int64 nDoc; /* Documents in table */
111956
111957 int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */
111958 u32 *aMatchinfo; /* Information about most recent match */
111959 int nMatchinfo; /* Number of elements in aMatchinfo[] */
111960 char *zMatchinfo; /* Matchinfo specification */
@@ -111997,19 +112007,19 @@
112007 int isPrefix; /* True if token ends with a "*" character */
112008
112009 /* Variables above this point are populated when the expression is
112010 ** parsed (by code in fts3_expr.c). Below this point the variables are
112011 ** used when evaluating the expression. */
 
112012 Fts3DeferredToken *pDeferred; /* Deferred token object for this token */
112013 Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */
112014 };
112015
112016 struct Fts3Phrase {
112017 /* Cache of doclist for this phrase. */
112018 Fts3Doclist doclist;
112019 int bIncr; /* True if doclist is loaded incrementally */
112020 int iDoclistToken;
112021
112022 /* Variables below this point are populated by fts3_expr.c when parsing
112023 ** a MATCH expression. Everything above is part of the evaluation phase.
112024 */
112025 int nToken; /* Number of tokens in the phrase */
@@ -112130,10 +112140,11 @@
112140 Fts3SegFilter *pFilter; /* Pointer to filter object */
112141 char *aBuffer; /* Buffer to merge doclists in */
112142 int nBuffer; /* Allocated size of aBuffer[] in bytes */
112143
112144 int iColFilter; /* If >=0, filter for this column */
112145 int bRestart;
112146
112147 /* Used by fts3.c only. */
112148 int nCost; /* Cost of running iterator */
112149 int bLookup; /* True if a lookup of a single entry. */
112150
@@ -112199,18 +112210,24 @@
112210 Fts3Table*, Fts3MultiSegReader*, int, const char*, int);
112211 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
112212 Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
112213 SQLITE_PRIVATE char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol);
112214 SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
112215 SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
112216
112217 SQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);
112218
112219 #endif /* SQLITE_ENABLE_FTS3 */
112220 #endif /* _FTSINT_H */
112221
112222 /************** End of fts3Int.h *********************************************/
112223 /************** Continuing where we left off in fts3.c ***********************/
112224 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
112225
112226 #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)
112227 # define SQLITE_CORE 1
112228 #endif
112229
112230
112231 #ifndef SQLITE_CORE
112232 SQLITE_EXTENSION_INIT1
112233 #endif
@@ -112995,11 +113012,11 @@
113012 zCsr += nDb;
113013
113014 /* Fill in the azColumn array */
113015 for(iCol=0; iCol<nCol; iCol++){
113016 char *z;
113017 int n = 0;
113018 z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);
113019 memcpy(zCsr, z, n);
113020 zCsr[n] = '\0';
113021 sqlite3Fts3Dequote(zCsr);
113022 p->azColumn[iCol] = zCsr;
@@ -114581,12 +114598,12 @@
114598
114599 /*
114600 ** Implementation of xBegin() method. This is a no-op.
114601 */
114602 static int fts3BeginMethod(sqlite3_vtab *pVtab){
 
114603 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
114604 UNUSED_PARAMETER(pVtab);
114605 assert( p->pSegments==0 );
114606 assert( p->nPendingData==0 );
114607 assert( p->inTransaction!=1 );
114608 TESTONLY( p->inTransaction = 1 );
114609 TESTONLY( p->mxSavepoint = -1; );
@@ -114597,12 +114614,12 @@
114614 ** Implementation of xCommit() method. This is a no-op. The contents of
114615 ** the pending-terms hash-table have already been flushed into the database
114616 ** by fts3SyncMethod().
114617 */
114618 static int fts3CommitMethod(sqlite3_vtab *pVtab){
 
114619 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
114620 UNUSED_PARAMETER(pVtab);
114621 assert( p->nPendingData==0 );
114622 assert( p->inTransaction!=0 );
114623 assert( p->pSegments==0 );
114624 TESTONLY( p->inTransaction = 0 );
114625 TESTONLY( p->mxSavepoint = -1; );
@@ -115083,75 +115100,105 @@
115100 if( rc!=SQLITE_OK ){
115101 *pRc = rc;
115102 return;
115103 }
115104 }
115105 assert( pExpr->pPhrase->iDoclistToken==0 );
115106 pExpr->pPhrase->iDoclistToken = -1;
115107 }else{
115108 *pnOr += (pExpr->eType==FTSQUERY_OR);
115109 fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);
115110 fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);
115111 }
115112 }
115113 }
115114
115115 static void fts3EvalPhraseMergeToken(
115116 Fts3Table *pTab,
115117 Fts3Phrase *p,
115118 int iToken,
115119 char *pList,
115120 int nList
115121 ){
115122 assert( iToken!=p->iDoclistToken );
115123
115124 if( pList==0 ){
115125 sqlite3_free(p->doclist.aAll);
115126 p->doclist.aAll = 0;
115127 p->doclist.nAll = 0;
115128 }
115129
115130 else if( p->iDoclistToken<0 ){
115131 p->doclist.aAll = pList;
115132 p->doclist.nAll = nList;
115133 }
115134
115135 else if( p->doclist.aAll==0 ){
115136 sqlite3_free(pList);
115137 }
115138
115139 else {
115140 char *pLeft;
115141 char *pRight;
115142 int nLeft;
115143 int nRight;
115144 int nDiff;
115145
115146 if( p->iDoclistToken<iToken ){
115147 pLeft = p->doclist.aAll;
115148 nLeft = p->doclist.nAll;
115149 pRight = pList;
115150 nRight = nList;
115151 nDiff = iToken - p->iDoclistToken;
115152 }else{
115153 pRight = p->doclist.aAll;
115154 nRight = p->doclist.nAll;
115155 pLeft = pList;
115156 nLeft = nList;
115157 nDiff = p->iDoclistToken - iToken;
115158 }
115159
115160 fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);
115161 sqlite3_free(pLeft);
115162 p->doclist.aAll = pRight;
115163 p->doclist.nAll = nRight;
115164 }
115165
115166 if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
115167 }
115168
115169 static int fts3EvalPhraseLoad(
115170 Fts3Cursor *pCsr,
115171 Fts3Phrase *p
115172 ){
115173 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
115174 int iToken;
115175 int rc = SQLITE_OK;
115176
 
 
 
 
115177 for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){
115178 Fts3PhraseToken *pToken = &p->aToken[iToken];
115179 assert( pToken->pDeferred==0 || pToken->pSegcsr==0 );
115180
115181 if( pToken->pSegcsr ){
115182 int nThis = 0;
115183 char *pThis = 0;
115184 rc = fts3TermSelect(pTab, pToken, p->iColumn, 1, &nThis, &pThis);
115185 if( rc==SQLITE_OK ){
115186 fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
115187 }
115188 }
115189 assert( pToken->pSegcsr==0 );
115190 }
115191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115192 return rc;
115193 }
115194
115195 static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
115196 int iToken;
115197 int rc = SQLITE_OK;
115198
115199 int nMaxUndeferred = pPhrase->iDoclistToken;
115200 char *aPoslist = 0;
115201 int nPoslist = 0;
115202 int iPrev = -1;
115203
115204 assert( pPhrase->doclist.bFreeList==0 );
@@ -115192,12 +115239,10 @@
115239 pPhrase->doclist.nList = 0;
115240 return SQLITE_OK;
115241 }
115242 }
115243 iPrev = iToken;
 
 
115244 }
115245 }
115246
115247 if( iPrev>=0 ){
115248 if( nMaxUndeferred<0 ){
@@ -115252,13 +115297,15 @@
115297 static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){
115298 int rc;
115299 Fts3PhraseToken *pFirst = &p->aToken[0];
115300 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
115301
115302 if( pCsr->bDesc==pTab->bDescIdx
115303 && bOptOk==1
115304 && p->nToken==1
115305 && pFirst->pSegcsr
115306 && pFirst->pSegcsr->bLookup
115307 ){
115308 /* Use the incremental approach. */
115309 int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);
115310 rc = sqlite3Fts3MsrIncrStart(
115311 pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n);
@@ -115394,11 +115441,11 @@
115441 ** with this case by advancing pIter past the zero-padding added by
115442 ** fts3EvalNearTrim2(). */
115443 while( pIter<pEnd && *pIter==0 ) pIter++;
115444
115445 pDL->pNextDocid = pIter;
115446 assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );
115447 *pbEof = 0;
115448 }
115449 }
115450
115451 return rc;
@@ -115425,17 +115472,18 @@
115472 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
115473 }
115474 }
115475 }
115476
 
115477 typedef struct Fts3TokenAndCost Fts3TokenAndCost;
115478 struct Fts3TokenAndCost {
115479 Fts3Phrase *pPhrase; /* The phrase the token belongs to */
115480 int iToken; /* Position of token in phrase */
115481 Fts3PhraseToken *pToken; /* The token itself */
115482 Fts3Expr *pRoot;
115483 int nOvfl;
115484 int iCol; /* The column the token must match */
115485 };
115486
115487 static void fts3EvalTokenCosts(
115488 Fts3Cursor *pCsr,
115489 Fts3Expr *pRoot,
@@ -115448,10 +115496,12 @@
115496 if( pExpr->eType==FTSQUERY_PHRASE ){
115497 Fts3Phrase *pPhrase = pExpr->pPhrase;
115498 int i;
115499 for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){
115500 Fts3TokenAndCost *pTC = (*ppTC)++;
115501 pTC->pPhrase = pPhrase;
115502 pTC->iToken = i;
115503 pTC->pRoot = pRoot;
115504 pTC->pToken = &pPhrase->aToken[i];
115505 pTC->iCol = pPhrase->iColumn;
115506 *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);
115507 }
@@ -115560,23 +115610,19 @@
115610 /* At this point pTC points to the cheapest remaining token. */
115611 if( ii==0 ){
115612 if( pTC->nOvfl ){
115613 nDocEst = (pTC->nOvfl * pTab->nPgsz + pTab->nPgsz) / 10;
115614 }else{
 
115615 Fts3PhraseToken *pToken = pTC->pToken;
115616 int nList = 0;
115617 char *pList = 0;
115618 rc = fts3TermSelect(pTab, pToken, pTC->iCol, 1, &nList, &pList);
115619 assert( rc==SQLITE_OK || pList==0 );
115620
115621 if( rc==SQLITE_OK ){
115622 nDocEst = fts3DoclistCountDocids(1, pList, nList);
115623 fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);
 
 
 
 
 
115624 }
115625 }
115626 }else{
115627 if( pTC->nOvfl>=(nDocEst*nDocSize) ){
115628 Fts3PhraseToken *pToken = pTC->pToken;
@@ -116032,17 +116078,18 @@
116078 Fts3Phrase *pPhrase = pExpr->pPhrase;
116079
116080 if( pPhrase ){
116081 fts3EvalZeroPoslist(pPhrase);
116082 if( pPhrase->bIncr ){
116083 assert( pPhrase->nToken==1 );
116084 assert( pPhrase->aToken[0].pSegcsr );
116085 sqlite3Fts3MsrIncrRestart(pPhrase->aToken[0].pSegcsr);
116086 *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);
 
 
116087 }
116088
116089 pPhrase->doclist.pNextDocid = 0;
116090 pPhrase->doclist.iDocid = 0;
116091 }
116092
116093 pExpr->iDocid = 0;
116094 pExpr->bEof = 0;
116095 pExpr->bStart = 0;
@@ -116225,12 +116272,12 @@
116272 int iCol;
116273
116274 if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){
116275 assert( pCsr->nDoc>0 );
116276 for(iCol=0; iCol<pTab->nColumn; iCol++){
116277 aiOut[iCol*3 + 1] = (u32)pCsr->nDoc;
116278 aiOut[iCol*3 + 2] = (u32)pCsr->nDoc;
116279 }
116280 }else{
116281 rc = fts3EvalGatherStats(pCsr, pExpr);
116282 if( rc==SQLITE_OK ){
116283 assert( pExpr->aMI );
@@ -116334,11 +116381,10 @@
116381 ** May you share freely, never taking more than you give.
116382 **
116383 ******************************************************************************
116384 **
116385 */
 
116386 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
116387
116388
116389 typedef struct Fts3auxTable Fts3auxTable;
116390 typedef struct Fts3auxCursor Fts3auxCursor;
@@ -118168,11 +118214,10 @@
118214 */
118215 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118216
118217
118218
 
118219 /*
118220 ** Class derived from sqlite3_tokenizer
118221 */
118222 typedef struct porter_tokenizer {
118223 sqlite3_tokenizer base; /* Base class */
@@ -118808,15 +118853,15 @@
118853 ** (in which case SQLITE_CORE is not defined), or
118854 **
118855 ** * The FTS3 module is being built into the core of
118856 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
118857 */
 
 
118858 #ifndef SQLITE_CORE
118859 SQLITE_EXTENSION_INIT1
118860 #endif
118861
118862 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
118863
118864
118865 /*
118866 ** Implementation of the SQL scalar function for accessing the underlying
118867 ** hash table. This function may be called as follows:
@@ -118937,11 +118982,11 @@
118982 sqlite3_tokenizer **ppTok, /* OUT: Tokenizer (if applicable) */
118983 char **pzErr /* OUT: Set to malloced error message */
118984 ){
118985 int rc;
118986 char *z = (char *)zArg;
118987 int n = 0;
118988 char *zCopy;
118989 char *zEnd; /* Pointer to nul-term of zCopy */
118990 sqlite3_tokenizer_module *m;
118991
118992 zCopy = sqlite3_mprintf("%s", zArg);
@@ -119299,11 +119344,10 @@
119344 **
119345 ** * The FTS3 module is being built into the core of
119346 ** SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
119347 */
119348 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
 
119349
119350
119351
119352 typedef struct simple_tokenizer {
119353 sqlite3_tokenizer base;
@@ -120750,10 +120794,11 @@
120794 pReader->pOffsetList = 0;
120795 }else{
120796 pReader->pOffsetList = p;
120797 }
120798 }else{
120799 char *pEnd = &pReader->aDoclist[pReader->nDoclist];
120800
120801 /* Pointer p currently points at the first byte of an offset list. The
120802 ** following block advances it to point one byte past the end of
120803 ** the same offset list. */
120804 while( 1 ){
@@ -120778,17 +120823,19 @@
120823 */
120824 if( ppOffsetList ){
120825 *ppOffsetList = pReader->pOffsetList;
120826 *pnOffsetList = (int)(p - pReader->pOffsetList - 1);
120827 }
120828
120829 while( p<pEnd && *p==0 ) p++;
120830
120831 /* If there are no more entries in the doclist, set pOffsetList to
120832 ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and
120833 ** Fts3SegReader.pOffsetList to point to the next offset list before
120834 ** returning.
120835 */
120836 if( p>=pEnd ){
120837 pReader->pOffsetList = 0;
120838 }else{
120839 rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
120840 if( rc==SQLITE_OK ){
120841 sqlite3_int64 iDelta;
@@ -120823,11 +120870,11 @@
120870 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
120871 Fts3SegReader *pReader = pMsr->apSegment[ii];
120872 if( !fts3SegReaderIsPending(pReader)
120873 && !fts3SegReaderIsRootOnly(pReader)
120874 ){
120875 sqlite3_int64 jj;
120876 for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){
120877 int nBlob;
120878 rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);
120879 if( rc!=SQLITE_OK ) break;
120880 if( (nBlob+35)>pgsz ){
@@ -121768,55 +121815,31 @@
121815
121816 *ppList = pList;
121817 *pnList = nList;
121818 }
121819
121820 /*
121821 ** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any
121822 ** existing data). Grow the buffer if required.
121823 **
121824 ** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered
121825 ** trying to resize the buffer, return SQLITE_NOMEM.
121826 */
121827 static int fts3MsrBufferData(
121828 Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */
121829 char *pList,
121830 int nList
121831 ){
121832 if( nList>pMsr->nBuffer ){
121833 char *pNew;
121834 pMsr->nBuffer = nList*2;
121835 pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);
121836 if( !pNew ) return SQLITE_NOMEM;
121837 pMsr->aBuffer = pNew;
121838 }
121839
121840 memcpy(pMsr->aBuffer, pList, nList);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121841 return SQLITE_OK;
121842 }
121843
121844 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
121845 Fts3Table *p, /* Virtual table handle */
@@ -121866,52 +121889,138 @@
121889 if( pMsr->iColFilter>=0 ){
121890 fts3ColumnFilter(pMsr->iColFilter, &pList, &nList);
121891 }
121892
121893 if( nList>0 ){
121894 if( fts3SegReaderIsPending(apSegment[0]) ){
121895 rc = fts3MsrBufferData(pMsr, pList, nList+1);
121896 if( rc!=SQLITE_OK ) return rc;
121897 *paPoslist = pMsr->aBuffer;
121898 assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );
121899 }else{
121900 *paPoslist = pList;
121901 }
121902 *piDocid = iDocid;
 
121903 *pnPoslist = nList;
121904 break;
121905 }
121906 }
 
121907 }
121908
121909 return SQLITE_OK;
121910 }
121911
121912 static int fts3SegReaderStart(
121913 Fts3Table *p, /* Virtual table handle */
121914 Fts3MultiSegReader *pCsr, /* Cursor object */
121915 const char *zTerm, /* Term searched for (or NULL) */
121916 int nTerm /* Length of zTerm in bytes */
121917 ){
121918 int i;
121919 int nSeg = pCsr->nSegment;
121920
121921 /* If the Fts3SegFilter defines a specific term (or term prefix) to search
121922 ** for, then advance each segment iterator until it points to a term of
121923 ** equal or greater value than the specified term. This prevents many
121924 ** unnecessary merge/sort operations for the case where single segment
121925 ** b-tree leaf nodes contain more than one term.
121926 */
121927 for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){
121928 Fts3SegReader *pSeg = pCsr->apSegment[i];
121929 do {
121930 int rc = fts3SegReaderNext(p, pSeg, 0);
121931 if( rc!=SQLITE_OK ) return rc;
121932 }while( zTerm && fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 );
121933 }
121934 fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp);
121935
121936 return SQLITE_OK;
121937 }
121938
121939 SQLITE_PRIVATE int sqlite3Fts3SegReaderStart(
121940 Fts3Table *p, /* Virtual table handle */
121941 Fts3MultiSegReader *pCsr, /* Cursor object */
121942 Fts3SegFilter *pFilter /* Restrictions on range of iteration */
121943 ){
 
 
 
121944 pCsr->pFilter = pFilter;
121945 return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm);
121946 }
121947
121948 SQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(
121949 Fts3Table *p, /* Virtual table handle */
121950 Fts3MultiSegReader *pCsr, /* Cursor object */
121951 int iCol, /* Column to match on. */
121952 const char *zTerm, /* Term to iterate through a doclist for */
121953 int nTerm /* Number of bytes in zTerm */
121954 ){
121955 int i;
121956 int rc;
121957 int nSegment = pCsr->nSegment;
121958 int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (
121959 p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp
121960 );
121961
121962 assert( pCsr->pFilter==0 );
121963 assert( zTerm && nTerm>0 );
121964
121965 /* Advance each segment iterator until it points to the term zTerm/nTerm. */
121966 rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);
121967 if( rc!=SQLITE_OK ) return rc;
121968
121969 /* Determine how many of the segments actually point to zTerm/nTerm. */
121970 for(i=0; i<nSegment; i++){
121971 Fts3SegReader *pSeg = pCsr->apSegment[i];
121972 if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){
121973 break;
121974 }
 
121975 }
121976 pCsr->nAdvance = i;
121977
121978 /* Advance each of the segments to point to the first docid. */
121979 for(i=0; i<pCsr->nAdvance; i++){
121980 rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);
121981 if( rc!=SQLITE_OK ) return rc;
121982 }
121983 fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);
121984
121985 assert( iCol<0 || iCol<p->nColumn );
121986 pCsr->iColFilter = iCol;
121987
121988 return SQLITE_OK;
121989 }
121990
121991 /*
121992 ** This function is called on a MultiSegReader that has been started using
121993 ** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also
121994 ** have been made. Calling this function puts the MultiSegReader in such
121995 ** a state that if the next two calls are:
121996 **
121997 ** sqlite3Fts3SegReaderStart()
121998 ** sqlite3Fts3SegReaderStep()
121999 **
122000 ** then the entire doclist for the term is available in
122001 ** MultiSegReader.aDoclist/nDoclist.
122002 */
122003 SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){
122004 int i; /* Used to iterate through segment-readers */
122005
122006 assert( pCsr->zTerm==0 );
122007 assert( pCsr->nTerm==0 );
122008 assert( pCsr->aDoclist==0 );
122009 assert( pCsr->nDoclist==0 );
122010
122011 pCsr->nAdvance = 0;
122012 pCsr->bRestart = 1;
122013 for(i=0; i<pCsr->nSegment; i++){
122014 pCsr->apSegment[i]->pOffsetList = 0;
122015 pCsr->apSegment[i]->nOffsetList = 0;
122016 pCsr->apSegment[i]->iDocid = 0;
122017 }
122018
122019 return SQLITE_OK;
122020 }
122021
122022
122023 SQLITE_PRIVATE int sqlite3Fts3SegReaderStep(
122024 Fts3Table *p, /* Virtual table handle */
122025 Fts3MultiSegReader *pCsr /* Cursor object */
122026 ){
@@ -121981,13 +122090,18 @@
122090 assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );
122091 if( nMerge==1
122092 && !isIgnoreEmpty
122093 && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)
122094 ){
 
122095 pCsr->nDoclist = apSegment[0]->nDoclist;
122096 if( fts3SegReaderIsPending(apSegment[0]) ){
122097 rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);
122098 pCsr->aDoclist = pCsr->aBuffer;
122099 }else{
122100 pCsr->aDoclist = apSegment[0]->aDoclist;
122101 }
122102 if( rc==SQLITE_OK ) rc = SQLITE_ROW;
122103 }else{
122104 int nDoclist = 0; /* Size of doclist */
122105 sqlite3_int64 iPrev = 0; /* Previous docid stored in doclist */
122106
122107 /* The current term of the first nMerge entries in the array
@@ -123725,11 +123839,11 @@
123839 if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;
123840 break;
123841
123842 case FTS3_MATCHINFO_NDOC:
123843 if( bGlobal ){
123844 sqlite3_int64 nDoc = 0;
123845 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);
123846 pInfo->aMatchinfo[0] = (u32)nDoc;
123847 }
123848 break;
123849
@@ -125620,11 +125734,11 @@
125734 */
125735 static float cellArea(Rtree *pRtree, RtreeCell *p){
125736 float area = 1.0;
125737 int ii;
125738 for(ii=0; ii<(pRtree->nDim*2); ii+=2){
125739 area = (float)(area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])));
125740 }
125741 return area;
125742 }
125743
125744 /*
@@ -125633,11 +125747,11 @@
125747 */
125748 static float cellMargin(Rtree *pRtree, RtreeCell *p){
125749 float margin = 0.0;
125750 int ii;
125751 for(ii=0; ii<(pRtree->nDim*2); ii+=2){
125752 margin += (float)(DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));
125753 }
125754 return margin;
125755 }
125756
125757 /*
@@ -125718,11 +125832,11 @@
125832
125833 if( x2<x1 ){
125834 o = 0.0;
125835 break;
125836 }else{
125837 o = o * (float)(x2-x1);
125838 }
125839 }
125840 overlap += o;
125841 }
125842 }
@@ -125737,16 +125851,16 @@
125851 RtreeCell *pInsert,
125852 RtreeCell *aCell,
125853 int nCell,
125854 int iExclude
125855 ){
125856 double before;
125857 double after;
125858 before = cellOverlap(pRtree, p, aCell, nCell, iExclude);
125859 cellUnion(pRtree, p, pInsert);
125860 after = cellOverlap(pRtree, p, aCell, nCell, iExclude);
125861 return (float)(after-before);
125862 }
125863 #endif
125864
125865
125866 /*
@@ -125764,15 +125878,15 @@
125878 RtreeNode *pNode;
125879 rc = nodeAcquire(pRtree, 1, 0, &pNode);
125880
125881 for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){
125882 int iCell;
125883 sqlite3_int64 iBest = 0;
125884
125885 float fMinGrowth = 0.0;
125886 float fMinArea = 0.0;
125887 float fMinOverlap = 0.0;
125888
125889 int nCell = NCELL(pNode);
125890 RtreeCell cell;
125891 RtreeNode *pChild;
125892
@@ -126198,13 +126312,13 @@
126312 ){
126313 int **aaSorted;
126314 int *aSpare;
126315 int ii;
126316
126317 int iBestDim = 0;
126318 int iBestSplit = 0;
126319 float fBestMargin = 0.0;
126320
126321 int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
126322
126323 aaSorted = (int **)sqlite3_malloc(nByte);
126324 if( !aaSorted ){
@@ -126222,13 +126336,13 @@
126336 SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);
126337 }
126338
126339 for(ii=0; ii<pRtree->nDim; ii++){
126340 float margin = 0.0;
126341 float fBestOverlap = 0.0;
126342 float fBestArea = 0.0;
126343 int iBestLeft = 0;
126344 int nLeft;
126345
126346 for(
126347 nLeft=RTREE_MINCELLS(pRtree);
126348 nLeft<=(nCell-RTREE_MINCELLS(pRtree));
@@ -126539,11 +126653,11 @@
126653 static int deleteCell(Rtree *, RtreeNode *, int, int);
126654
126655 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
126656 int rc;
126657 int rc2;
126658 RtreeNode *pParent = 0;
126659 int iCell;
126660
126661 assert( pNode->nRef==1 );
126662
126663 /* Remove the entry in the parent cell. */
@@ -126687,23 +126801,23 @@
126801 }else{
126802 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
126803 }
126804 aOrder[ii] = ii;
126805 for(iDim=0; iDim<pRtree->nDim; iDim++){
126806 aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2]);
126807 aCenterCoord[iDim] += (float)DCOORD(aCell[ii].aCoord[iDim*2+1]);
126808 }
126809 }
126810 for(iDim=0; iDim<pRtree->nDim; iDim++){
126811 aCenterCoord[iDim] = (float)(aCenterCoord[iDim]/((float)nCell*2.0));
126812 }
126813
126814 for(ii=0; ii<nCell; ii++){
126815 aDistance[ii] = 0.0;
126816 for(iDim=0; iDim<pRtree->nDim; iDim++){
126817 float coord = (float)(DCOORD(aCell[ii].aCoord[iDim*2+1]) -
126818 DCOORD(aCell[ii].aCoord[iDim*2]));
126819 aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);
126820 }
126821 }
126822
126823 SortByDistance(aOrder, nCell, aDistance, aSpare);
@@ -126798,14 +126912,14 @@
126912 nodeGetCell(pRtree, pNode, ii, &cell);
126913
126914 /* Find a node to store this cell in. pNode->iNode currently contains
126915 ** the height of the sub-tree headed by the cell.
126916 */
126917 rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);
126918 if( rc==SQLITE_OK ){
126919 int rc2;
126920 rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);
126921 rc2 = nodeRelease(pRtree, pInsert);
126922 if( rc==SQLITE_OK ){
126923 rc = rc2;
126924 }
126925 }
@@ -127190,11 +127304,11 @@
127304 int isCreate /* True for xCreate, false for xConnect */
127305 ){
127306 int rc;
127307 char *zSql;
127308 if( isCreate ){
127309 int iPageSize = 0;
127310 zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb);
127311 rc = getIntFromStmt(db, zSql, &iPageSize);
127312 if( rc==SQLITE_OK ){
127313 pRtree->iNodeSize = iPageSize-64;
127314 if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){
@@ -127993,14 +128107,11 @@
128107 ** May you find forgiveness for yourself and forgive others.
128108 ** May you share freely, never taking more than you give.
128109 **
128110 *************************************************************************
128111 ** This file implements a tokenizer for fts3 based on the ICU library.
 
 
128112 */
 
128113 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
128114 #ifdef SQLITE_ENABLE_ICU
128115
128116
128117 #include <unicode/ubrk.h>
128118
+10 -10
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.7.7"
111111
#define SQLITE_VERSION_NUMBER 3007007
112
-#define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389"
112
+#define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -308,11 +308,11 @@
308308
** semicolon-separate SQL statements passed into its 2nd argument,
309309
** in the context of the [database connection] passed in as its 1st
310310
** argument. ^If the callback function of the 3rd argument to
311311
** sqlite3_exec() is not NULL, then it is invoked for each result row
312312
** coming out of the evaluated SQL statements. ^The 4th argument to
313
-** to sqlite3_exec() is relayed through to the 1st argument of each
313
+** sqlite3_exec() is relayed through to the 1st argument of each
314314
** callback invocation. ^If the callback pointer to sqlite3_exec()
315315
** is NULL, then no callback is ever invoked and result rows are
316316
** ignored.
317317
**
318318
** ^If an error occurs while evaluating the SQL statements passed into
@@ -900,11 +900,11 @@
900900
** The xSleep() method causes the calling thread to sleep for at
901901
** least the number of microseconds given. ^The xCurrentTime()
902902
** method returns a Julian Day Number for the current date and time as
903903
** a floating point value.
904904
** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
905
-** Day Number multipled by 86400000 (the number of milliseconds in
905
+** Day Number multiplied by 86400000 (the number of milliseconds in
906906
** a 24-hour day).
907907
** ^SQLite will use the xCurrentTimeInt64() method to get the current
908908
** date and time if that method is available (if iVersion is 2 or
909909
** greater and the function pointer is not NULL) and will fall back
910910
** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
@@ -1338,11 +1338,11 @@
13381338
** scratch memory beyond what is provided by this configuration option, then
13391339
** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
13401340
**
13411341
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
13421342
** <dd> ^This option specifies a static memory buffer that SQLite can use for
1343
-** the database page cache with the default page cache implemenation.
1343
+** the database page cache with the default page cache implementation.
13441344
** This configuration should not be used if an application-define page
13451345
** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
13461346
** There are three arguments to this option: A pointer to 8-byte aligned
13471347
** memory, the size of each page buffer (sz), and the number of pages (N).
13481348
** The sz argument should be the size of the largest database page
@@ -2436,16 +2436,16 @@
24362436
** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
24372437
**
24382438
** ^If [URI filename] interpretation is enabled, and the filename argument
24392439
** begins with "file:", then the filename is interpreted as a URI. ^URI
24402440
** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2441
-** is set in the fourth argument to sqlite3_open_v2(), or if it has
2441
+** set in the fourth argument to sqlite3_open_v2(), or if it has
24422442
** been enabled globally using the [SQLITE_CONFIG_URI] option with the
24432443
** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
24442444
** As of SQLite version 3.7.7, URI filename interpretation is turned off
24452445
** by default, but future releases of SQLite might enable URI filename
2446
-** intepretation by default. See "[URI filenames]" for additional
2446
+** interpretation by default. See "[URI filenames]" for additional
24472447
** information.
24482448
**
24492449
** URI filenames are parsed according to RFC 3986. ^If the URI contains an
24502450
** authority, then it must be either an empty string or the string
24512451
** "localhost". ^If the authority is not an empty string or "localhost", an
@@ -3260,11 +3260,11 @@
32603260
** [extended result codes] might be returned as well.
32613261
**
32623262
** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
32633263
** database locks it needs to do its job. ^If the statement is a [COMMIT]
32643264
** or occurs outside of an explicit transaction, then you can retry the
3265
-** statement. If the statement is not a [COMMIT] and occurs within a
3265
+** statement. If the statement is not a [COMMIT] and occurs within an
32663266
** explicit transaction then you should rollback the transaction before
32673267
** continuing.
32683268
**
32693269
** ^[SQLITE_DONE] means that the statement has finished executing
32703270
** successfully. sqlite3_step() should not be called again on this virtual
@@ -3539,11 +3539,11 @@
35393539
35403540
/*
35413541
** CAPI3REF: Destroy A Prepared Statement Object
35423542
**
35433543
** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3544
-** ^If the most recent evaluation of the statement encountered no errors or
3544
+** ^If the most recent evaluation of the statement encountered no errors
35453545
** or if the statement is never been evaluated, then sqlite3_finalize() returns
35463546
** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
35473547
** sqlite3_finalize(S) returns the appropriate [error code] or
35483548
** [extended error code].
35493549
**
@@ -5453,11 +5453,11 @@
54535453
** versions of these routines, it should at least provide stubs that always
54545454
** return true so that one does not get spurious assertion failures.
54555455
**
54565456
** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
54575457
** the routine should return 1. This seems counter-intuitive since
5458
-** clearly the mutex cannot be held if it does not exist. But the
5458
+** clearly the mutex cannot be held if it does not exist. But
54595459
** the reason the mutex does not exist is because the build is not
54605460
** using mutexes. And we do not want the assert() containing the
54615461
** call to sqlite3_mutex_held() to fail, so a non-zero return is
54625462
** the appropriate thing to do. ^The sqlite3_mutex_notheld()
54635463
** interface should also return 1 when given a NULL pointer.
@@ -5962,11 +5962,11 @@
59625962
** [[the xFetch() page cache methods]]
59635963
** The xFetch() method locates a page in the cache and returns a pointer to
59645964
** the page, or a NULL pointer.
59655965
** A "page", in this context, means a buffer of szPage bytes aligned at an
59665966
** 8-byte boundary. The page to be fetched is determined by the key. ^The
5967
-** mimimum key value is 1. After it has been retrieved using xFetch, the page
5967
+** minimum key value is 1. After it has been retrieved using xFetch, the page
59685968
** is considered to be "pinned".
59695969
**
59705970
** If the requested page is already in the page cache, then the page cache
59715971
** implementation must return a pointer to the page buffer with its content
59725972
** intact. If the requested page is not already in the cache, then the
59735973
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.7"
111 #define SQLITE_VERSION_NUMBER 3007007
112 #define SQLITE_SOURCE_ID "2011-06-15 13:11:06 f9750870ee04935f338e4d808900fee5a8b2b389"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -308,11 +308,11 @@
308 ** semicolon-separate SQL statements passed into its 2nd argument,
309 ** in the context of the [database connection] passed in as its 1st
310 ** argument. ^If the callback function of the 3rd argument to
311 ** sqlite3_exec() is not NULL, then it is invoked for each result row
312 ** coming out of the evaluated SQL statements. ^The 4th argument to
313 ** to sqlite3_exec() is relayed through to the 1st argument of each
314 ** callback invocation. ^If the callback pointer to sqlite3_exec()
315 ** is NULL, then no callback is ever invoked and result rows are
316 ** ignored.
317 **
318 ** ^If an error occurs while evaluating the SQL statements passed into
@@ -900,11 +900,11 @@
900 ** The xSleep() method causes the calling thread to sleep for at
901 ** least the number of microseconds given. ^The xCurrentTime()
902 ** method returns a Julian Day Number for the current date and time as
903 ** a floating point value.
904 ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
905 ** Day Number multipled by 86400000 (the number of milliseconds in
906 ** a 24-hour day).
907 ** ^SQLite will use the xCurrentTimeInt64() method to get the current
908 ** date and time if that method is available (if iVersion is 2 or
909 ** greater and the function pointer is not NULL) and will fall back
910 ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
@@ -1338,11 +1338,11 @@
1338 ** scratch memory beyond what is provided by this configuration option, then
1339 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
1340 **
1341 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1342 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1343 ** the database page cache with the default page cache implemenation.
1344 ** This configuration should not be used if an application-define page
1345 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1346 ** There are three arguments to this option: A pointer to 8-byte aligned
1347 ** memory, the size of each page buffer (sz), and the number of pages (N).
1348 ** The sz argument should be the size of the largest database page
@@ -2436,16 +2436,16 @@
2436 ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
2437 **
2438 ** ^If [URI filename] interpretation is enabled, and the filename argument
2439 ** begins with "file:", then the filename is interpreted as a URI. ^URI
2440 ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2441 ** is set in the fourth argument to sqlite3_open_v2(), or if it has
2442 ** been enabled globally using the [SQLITE_CONFIG_URI] option with the
2443 ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
2444 ** As of SQLite version 3.7.7, URI filename interpretation is turned off
2445 ** by default, but future releases of SQLite might enable URI filename
2446 ** intepretation by default. See "[URI filenames]" for additional
2447 ** information.
2448 **
2449 ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
2450 ** authority, then it must be either an empty string or the string
2451 ** "localhost". ^If the authority is not an empty string or "localhost", an
@@ -3260,11 +3260,11 @@
3260 ** [extended result codes] might be returned as well.
3261 **
3262 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3263 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3264 ** or occurs outside of an explicit transaction, then you can retry the
3265 ** statement. If the statement is not a [COMMIT] and occurs within a
3266 ** explicit transaction then you should rollback the transaction before
3267 ** continuing.
3268 **
3269 ** ^[SQLITE_DONE] means that the statement has finished executing
3270 ** successfully. sqlite3_step() should not be called again on this virtual
@@ -3539,11 +3539,11 @@
3539
3540 /*
3541 ** CAPI3REF: Destroy A Prepared Statement Object
3542 **
3543 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3544 ** ^If the most recent evaluation of the statement encountered no errors or
3545 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
3546 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
3547 ** sqlite3_finalize(S) returns the appropriate [error code] or
3548 ** [extended error code].
3549 **
@@ -5453,11 +5453,11 @@
5453 ** versions of these routines, it should at least provide stubs that always
5454 ** return true so that one does not get spurious assertion failures.
5455 **
5456 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
5457 ** the routine should return 1. This seems counter-intuitive since
5458 ** clearly the mutex cannot be held if it does not exist. But the
5459 ** the reason the mutex does not exist is because the build is not
5460 ** using mutexes. And we do not want the assert() containing the
5461 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
5462 ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
5463 ** interface should also return 1 when given a NULL pointer.
@@ -5962,11 +5962,11 @@
5962 ** [[the xFetch() page cache methods]]
5963 ** The xFetch() method locates a page in the cache and returns a pointer to
5964 ** the page, or a NULL pointer.
5965 ** A "page", in this context, means a buffer of szPage bytes aligned at an
5966 ** 8-byte boundary. The page to be fetched is determined by the key. ^The
5967 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
5968 ** is considered to be "pinned".
5969 **
5970 ** If the requested page is already in the page cache, then the page cache
5971 ** implementation must return a pointer to the page buffer with its content
5972 ** intact. If the requested page is not already in the cache, then the
5973
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.7"
111 #define SQLITE_VERSION_NUMBER 3007007
112 #define SQLITE_SOURCE_ID "2011-06-20 23:51:33 e60eefc76fa5066720d76858f6cfca56365330ee"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -308,11 +308,11 @@
308 ** semicolon-separate SQL statements passed into its 2nd argument,
309 ** in the context of the [database connection] passed in as its 1st
310 ** argument. ^If the callback function of the 3rd argument to
311 ** sqlite3_exec() is not NULL, then it is invoked for each result row
312 ** coming out of the evaluated SQL statements. ^The 4th argument to
313 ** sqlite3_exec() is relayed through to the 1st argument of each
314 ** callback invocation. ^If the callback pointer to sqlite3_exec()
315 ** is NULL, then no callback is ever invoked and result rows are
316 ** ignored.
317 **
318 ** ^If an error occurs while evaluating the SQL statements passed into
@@ -900,11 +900,11 @@
900 ** The xSleep() method causes the calling thread to sleep for at
901 ** least the number of microseconds given. ^The xCurrentTime()
902 ** method returns a Julian Day Number for the current date and time as
903 ** a floating point value.
904 ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
905 ** Day Number multiplied by 86400000 (the number of milliseconds in
906 ** a 24-hour day).
907 ** ^SQLite will use the xCurrentTimeInt64() method to get the current
908 ** date and time if that method is available (if iVersion is 2 or
909 ** greater and the function pointer is not NULL) and will fall back
910 ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
@@ -1338,11 +1338,11 @@
1338 ** scratch memory beyond what is provided by this configuration option, then
1339 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
1340 **
1341 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1342 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1343 ** the database page cache with the default page cache implementation.
1344 ** This configuration should not be used if an application-define page
1345 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1346 ** There are three arguments to this option: A pointer to 8-byte aligned
1347 ** memory, the size of each page buffer (sz), and the number of pages (N).
1348 ** The sz argument should be the size of the largest database page
@@ -2436,16 +2436,16 @@
2436 ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
2437 **
2438 ** ^If [URI filename] interpretation is enabled, and the filename argument
2439 ** begins with "file:", then the filename is interpreted as a URI. ^URI
2440 ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2441 ** set in the fourth argument to sqlite3_open_v2(), or if it has
2442 ** been enabled globally using the [SQLITE_CONFIG_URI] option with the
2443 ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
2444 ** As of SQLite version 3.7.7, URI filename interpretation is turned off
2445 ** by default, but future releases of SQLite might enable URI filename
2446 ** interpretation by default. See "[URI filenames]" for additional
2447 ** information.
2448 **
2449 ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
2450 ** authority, then it must be either an empty string or the string
2451 ** "localhost". ^If the authority is not an empty string or "localhost", an
@@ -3260,11 +3260,11 @@
3260 ** [extended result codes] might be returned as well.
3261 **
3262 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3263 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3264 ** or occurs outside of an explicit transaction, then you can retry the
3265 ** statement. If the statement is not a [COMMIT] and occurs within an
3266 ** explicit transaction then you should rollback the transaction before
3267 ** continuing.
3268 **
3269 ** ^[SQLITE_DONE] means that the statement has finished executing
3270 ** successfully. sqlite3_step() should not be called again on this virtual
@@ -3539,11 +3539,11 @@
3539
3540 /*
3541 ** CAPI3REF: Destroy A Prepared Statement Object
3542 **
3543 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3544 ** ^If the most recent evaluation of the statement encountered no errors
3545 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
3546 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
3547 ** sqlite3_finalize(S) returns the appropriate [error code] or
3548 ** [extended error code].
3549 **
@@ -5453,11 +5453,11 @@
5453 ** versions of these routines, it should at least provide stubs that always
5454 ** return true so that one does not get spurious assertion failures.
5455 **
5456 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
5457 ** the routine should return 1. This seems counter-intuitive since
5458 ** clearly the mutex cannot be held if it does not exist. But
5459 ** the reason the mutex does not exist is because the build is not
5460 ** using mutexes. And we do not want the assert() containing the
5461 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
5462 ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
5463 ** interface should also return 1 when given a NULL pointer.
@@ -5962,11 +5962,11 @@
5962 ** [[the xFetch() page cache methods]]
5963 ** The xFetch() method locates a page in the cache and returns a pointer to
5964 ** the page, or a NULL pointer.
5965 ** A "page", in this context, means a buffer of szPage bytes aligned at an
5966 ** 8-byte boundary. The page to be fetched is determined by the key. ^The
5967 ** minimum key value is 1. After it has been retrieved using xFetch, the page
5968 ** is considered to be "pinned".
5969 **
5970 ** If the requested page is already in the page cache, then the page cache
5971 ** implementation must return a pointer to the page buffer with its content
5972 ** intact. If the requested page is not already in the cache, then the
5973

Keyboard Shortcuts

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