Fossil SCM

Update the built-in SQLite to 3.19.0

jan.nijtmans 2017-05-22 14:29 trunk
Commit e1da46fed4e2c57093f31d2f37d42eddbe17b3fe3d23f37904822f308773a7e8
+63 -50
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398398
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399399
** [sqlite_version()] and [sqlite_source_id()].
400400
*/
401401
#define SQLITE_VERSION "3.19.0"
402402
#define SQLITE_VERSION_NUMBER 3019000
403
-#define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
403
+#define SQLITE_SOURCE_ID "2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40"
404404
405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
407407
** KEYWORDS: sqlite3_version sqlite3_sourceid
408408
**
@@ -9671,11 +9671,11 @@
96719671
**
96729672
** As well as the regular sqlite3changegroup_add() and
96739673
** sqlite3changegroup_output() functions, also available are the streaming
96749674
** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
96759675
*/
9676
-int sqlite3changegroup_new(sqlite3_changegroup **pp);
9676
+SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
96779677
96789678
/*
96799679
** CAPI3REF: Add A Changeset To A Changegroup
96809680
**
96819681
** Add all changes within the changeset (or patchset) in buffer pData (size
@@ -9748,11 +9748,11 @@
97489748
** function returns SQLITE_NOMEM. In all cases, if an error occurs the
97499749
** final contents of the changegroup is undefined.
97509750
**
97519751
** If no error occurs, SQLITE_OK is returned.
97529752
*/
9753
-int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9753
+SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
97549754
97559755
/*
97569756
** CAPI3REF: Obtain A Composite Changeset From A Changegroup
97579757
**
97589758
** Obtain a buffer containing a changeset (or patchset) representing the
@@ -9774,20 +9774,20 @@
97749774
** is returned and the output variables are set to the size of and a
97759775
** pointer to the output buffer, respectively. In this case it is the
97769776
** responsibility of the caller to eventually free the buffer using a
97779777
** call to sqlite3_free().
97789778
*/
9779
-int sqlite3changegroup_output(
9779
+SQLITE_API int sqlite3changegroup_output(
97809780
sqlite3_changegroup*,
97819781
int *pnData, /* OUT: Size of output buffer in bytes */
97829782
void **ppData /* OUT: Pointer to output buffer */
97839783
);
97849784
97859785
/*
97869786
** CAPI3REF: Delete A Changegroup Object
97879787
*/
9788
-void sqlite3changegroup_delete(sqlite3_changegroup*);
9788
+SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
97899789
97909790
/*
97919791
** CAPI3REF: Apply A Changeset To A Database
97929792
**
97939793
** Apply a changeset to a database. This function attempts to update the
@@ -10172,15 +10172,15 @@
1017210172
SQLITE_API int sqlite3session_patchset_strm(
1017310173
sqlite3_session *pSession,
1017410174
int (*xOutput)(void *pOut, const void *pData, int nData),
1017510175
void *pOut
1017610176
);
10177
-int sqlite3changegroup_add_strm(sqlite3_changegroup*,
10177
+SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*,
1017810178
int (*xInput)(void *pIn, void *pData, int *pnData),
1017910179
void *pIn
1018010180
);
10181
-int sqlite3changegroup_output_strm(sqlite3_changegroup*,
10181
+SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
1018210182
int (*xOutput)(void *pOut, const void *pData, int nData),
1018310183
void *pOut
1018410184
);
1018510185
1018610186
@@ -82388,14 +82388,16 @@
8238882388
}
8238982389
#endif
8239082390
pIdxKey = &r;
8239182391
pFree = 0;
8239282392
}else{
82393
+ assert( pIn3->flags & MEM_Blob );
82394
+ rc = ExpandBlob(pIn3);
82395
+ assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
82396
+ if( rc ) goto no_mem;
8239382397
pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);
8239482398
if( pIdxKey==0 ) goto no_mem;
82395
- assert( pIn3->flags & MEM_Blob );
82396
- (void)ExpandBlob(pIn3);
8239782399
sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
8239882400
}
8239982401
pIdxKey->default_rc = 0;
8240082402
takeJump = 0;
8240182403
if( pOp->opcode==OP_NoConflict ){
@@ -91239,11 +91241,10 @@
9123991241
}else{
9124091242
return 1;
9124191243
}
9124291244
}
9124391245
91244
-#ifndef SQLITE_OMIT_SUBQUERY
9124591246
/*
9124691247
** Return a pointer to a subexpression of pVector that is the i-th
9124791248
** column of the vector (numbered starting with 0). The caller must
9124891249
** ensure that i is within range.
9124991250
**
@@ -91267,13 +91268,11 @@
9126791268
return pVector->x.pList->a[i].pExpr;
9126891269
}
9126991270
}
9127091271
return pVector;
9127191272
}
91272
-#endif /* !defined(SQLITE_OMIT_SUBQUERY) */
9127391273
91274
-#ifndef SQLITE_OMIT_SUBQUERY
9127591274
/*
9127691275
** Compute and return a new Expr object which when passed to
9127791276
** sqlite3ExprCode() will generate all necessary code to compute
9127891277
** the iField-th column of the vector expression pVector.
9127991278
**
@@ -91327,11 +91326,10 @@
9132791326
if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
9132891327
pRet = sqlite3ExprDup(pParse->db, pVector, 0);
9132991328
}
9133091329
return pRet;
9133191330
}
91332
-#endif /* !define(SQLITE_OMIT_SUBQUERY) */
9133391331
9133491332
/*
9133591333
** If expression pExpr is of type TK_SELECT, generate code to evaluate
9133691334
** it. Return the register in which the result is stored (or, if the
9133791335
** sub-select returns more than one column, the first in an array
@@ -94298,11 +94296,15 @@
9429894296
if( nResult==1 ){
9429994297
iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);
9430094298
}else{
9430194299
*piFreeable = 0;
9430294300
if( p->op==TK_SELECT ){
94301
+#if SQLITE_OMIT_SUBQUERY
94302
+ iResult = 0;
94303
+#else
9430394304
iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
94305
+#endif
9430494306
}else{
9430594307
int i;
9430694308
iResult = pParse->nMem+1;
9430794309
pParse->nMem += nResult;
9430894310
for(i=0; i<nResult; i++){
@@ -185267,13 +185269,15 @@
185267185269
Fts5Buffer *pBuf,
185268185270
u32 nData,
185269185271
const u8 *pData
185270185272
){
185271185273
assert_nc( *pRc || nData>=0 );
185272
- if( fts5BufferGrow(pRc, pBuf, nData) ) return;
185273
- memcpy(&pBuf->p[pBuf->n], pData, nData);
185274
- pBuf->n += nData;
185274
+ if( nData ){
185275
+ if( fts5BufferGrow(pRc, pBuf, nData) ) return;
185276
+ memcpy(&pBuf->p[pBuf->n], pData, nData);
185277
+ pBuf->n += nData;
185278
+ }
185275185279
}
185276185280
185277185281
/*
185278185282
** Append the nul-terminated string zStr to the buffer pBuf. This function
185279185283
** ensures that the byte following the buffer data is set to 0x00, even
@@ -185446,12 +185450,12 @@
185446185450
185447185451
static void *sqlite3Fts5MallocZero(int *pRc, int nByte){
185448185452
void *pRet = 0;
185449185453
if( *pRc==SQLITE_OK ){
185450185454
pRet = sqlite3_malloc(nByte);
185451
- if( pRet==0 && nByte>0 ){
185452
- *pRc = SQLITE_NOMEM;
185455
+ if( pRet==0 ){
185456
+ if( nByte>0 ) *pRc = SQLITE_NOMEM;
185453185457
}else{
185454185458
memset(pRet, 0, nByte);
185455185459
}
185456185460
}
185457185461
return pRet;
@@ -189408,13 +189412,14 @@
189408189412
Fts5HashEntry **aSlot; /* Array of hash slots */
189409189413
};
189410189414
189411189415
/*
189412189416
** Each entry in the hash table is represented by an object of the
189413
-** following type. Each object, its key (zKey[]) and its current data
189414
-** are stored in a single memory allocation. The position list data
189415
-** immediately follows the key data in memory.
189417
+** following type. Each object, its key (a nul-terminated string) and
189418
+** its current data are stored in a single memory allocation. The
189419
+** key immediately follows the object in memory. The position list
189420
+** data immediately follows the key data in memory.
189416189421
**
189417189422
** The data that follows the key is in a similar, but not identical format
189418189423
** to the doclist data stored in the database. It is:
189419189424
**
189420189425
** * Rowid, as a varint
@@ -189434,24 +189439,24 @@
189434189439
Fts5HashEntry *pScanNext; /* Next entry in sorted order */
189435189440
189436189441
int nAlloc; /* Total size of allocation */
189437189442
int iSzPoslist; /* Offset of space for 4-byte poslist size */
189438189443
int nData; /* Total bytes of data (incl. structure) */
189439
- int nKey; /* Length of zKey[] in bytes */
189444
+ int nKey; /* Length of key in bytes */
189440189445
u8 bDel; /* Set delete-flag @ iSzPoslist */
189441189446
u8 bContent; /* Set content-flag (detail=none mode) */
189442189447
i16 iCol; /* Column of last value written */
189443189448
int iPos; /* Position of last value written */
189444189449
i64 iRowid; /* Rowid of last value written */
189445
- char zKey[8]; /* Nul-terminated entry key */
189446189450
};
189447189451
189448189452
/*
189449
-** Size of Fts5HashEntry without the zKey[] array.
189453
+** Eqivalent to:
189454
+**
189455
+** char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }
189450189456
*/
189451
-#define FTS5_HASHENTRYSIZE (sizeof(Fts5HashEntry)-8)
189452
-
189457
+#define fts5EntryKey(p) ( ((char *)(&(p)[1])) )
189453189458
189454189459
189455189460
/*
189456189461
** Allocate a new hash table.
189457189462
*/
@@ -189545,11 +189550,11 @@
189545189550
for(i=0; i<pHash->nSlot; i++){
189546189551
while( apOld[i] ){
189547189552
int iHash;
189548189553
Fts5HashEntry *p = apOld[i];
189549189554
apOld[i] = p->pHashNext;
189550
- iHash = fts5HashKey(nNew, (u8*)p->zKey, (int)strlen(p->zKey));
189555
+ iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), strlen(fts5EntryKey(p)));
189551189556
p->pHashNext = apNew[iHash];
189552189557
apNew[iHash] = p;
189553189558
}
189554189559
}
189555189560
@@ -189616,22 +189621,24 @@
189616189621
bNew = (pHash->eDetail==FTS5_DETAIL_FULL);
189617189622
189618189623
/* Attempt to locate an existing hash entry */
189619189624
iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);
189620189625
for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189621
- if( p->zKey[0]==bByte
189626
+ char *zKey = fts5EntryKey(p);
189627
+ if( zKey[0]==bByte
189622189628
&& p->nKey==nToken
189623
- && memcmp(&p->zKey[1], pToken, nToken)==0
189629
+ && memcmp(&zKey[1], pToken, nToken)==0
189624189630
){
189625189631
break;
189626189632
}
189627189633
}
189628189634
189629189635
/* If an existing hash entry cannot be found, create a new one. */
189630189636
if( p==0 ){
189631189637
/* Figure out how much space to allocate */
189632
- int nByte = FTS5_HASHENTRYSIZE + (nToken+1) + 1 + 64;
189638
+ char *zKey;
189639
+ int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
189633189640
if( nByte<128 ) nByte = 128;
189634189641
189635189642
/* Grow the Fts5Hash.aSlot[] array if necessary. */
189636189643
if( (pHash->nEntry*2)>=pHash->nSlot ){
189637189644
int rc = fts5HashResize(pHash);
@@ -189640,18 +189647,19 @@
189640189647
}
189641189648
189642189649
/* Allocate new Fts5HashEntry and add it to the hash table. */
189643189650
p = (Fts5HashEntry*)sqlite3_malloc(nByte);
189644189651
if( !p ) return SQLITE_NOMEM;
189645
- memset(p, 0, FTS5_HASHENTRYSIZE);
189652
+ memset(p, 0, sizeof(Fts5HashEntry));
189646189653
p->nAlloc = nByte;
189647
- p->zKey[0] = bByte;
189648
- memcpy(&p->zKey[1], pToken, nToken);
189649
- assert( iHash==fts5HashKey(pHash->nSlot, (u8*)p->zKey, nToken+1) );
189654
+ zKey = fts5EntryKey(p);
189655
+ zKey[0] = bByte;
189656
+ memcpy(&zKey[1], pToken, nToken);
189657
+ assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
189650189658
p->nKey = nToken;
189651
- p->zKey[nToken+1] = '\0';
189652
- p->nData = nToken+1 + 1 + FTS5_HASHENTRYSIZE;
189659
+ zKey[nToken+1] = '\0';
189660
+ p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);
189653189661
p->pHashNext = pHash->aSlot[iHash];
189654189662
pHash->aSlot[iHash] = p;
189655189663
pHash->nEntry++;
189656189664
189657189665
/* Add the first rowid field to the hash-entry */
@@ -189765,13 +189773,15 @@
189765189773
}else if( p2==0 ){
189766189774
*ppOut = p1;
189767189775
p1 = 0;
189768189776
}else{
189769189777
int i = 0;
189770
- while( p1->zKey[i]==p2->zKey[i] ) i++;
189778
+ char *zKey1 = fts5EntryKey(p1);
189779
+ char *zKey2 = fts5EntryKey(p2);
189780
+ while( zKey1[i]==zKey2[i] ) i++;
189771189781
189772
- if( ((u8)p1->zKey[i])>((u8)p2->zKey[i]) ){
189782
+ if( ((u8)zKey1[i])>((u8)zKey2[i]) ){
189773189783
/* p2 is smaller */
189774189784
*ppOut = p2;
189775189785
ppOut = &p2->pScanNext;
189776189786
p2 = p2->pScanNext;
189777189787
}else{
@@ -189810,11 +189820,11 @@
189810189820
memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
189811189821
189812189822
for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
189813189823
Fts5HashEntry *pIter;
189814189824
for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
189815
- if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){
189825
+ if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
189816189826
Fts5HashEntry *pEntry = pIter;
189817189827
pEntry->pScanNext = 0;
189818189828
for(i=0; ap[i]; i++){
189819189829
pEntry = fts5HashEntryMerge(pEntry, ap[i]);
189820189830
ap[i] = 0;
@@ -189843,20 +189853,22 @@
189843189853
const char *pTerm, int nTerm, /* Query term */
189844189854
const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
189845189855
int *pnDoclist /* OUT: Size of doclist in bytes */
189846189856
){
189847189857
unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
189858
+ char *zKey;
189848189859
Fts5HashEntry *p;
189849189860
189850189861
for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189851
- if( memcmp(p->zKey, pTerm, nTerm)==0 && p->zKey[nTerm]==0 ) break;
189862
+ zKey = fts5EntryKey(p);
189863
+ if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
189852189864
}
189853189865
189854189866
if( p ){
189855189867
fts5HashAddPoslistSize(pHash, p);
189856
- *ppDoclist = (const u8*)&p->zKey[nTerm+1];
189857
- *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
189868
+ *ppDoclist = (const u8*)&zKey[nTerm+1];
189869
+ *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
189858189870
}else{
189859189871
*ppDoclist = 0;
189860189872
*pnDoclist = 0;
189861189873
}
189862189874
@@ -189885,15 +189897,16 @@
189885189897
const u8 **ppDoclist, /* OUT: pointer to doclist */
189886189898
int *pnDoclist /* OUT: size of doclist in bytes */
189887189899
){
189888189900
Fts5HashEntry *p;
189889189901
if( (p = pHash->pScan) ){
189890
- int nTerm = (int)strlen(p->zKey);
189902
+ char *zKey = fts5EntryKey(p);
189903
+ int nTerm = (int)strlen(zKey);
189891189904
fts5HashAddPoslistSize(pHash, p);
189892
- *pzTerm = p->zKey;
189893
- *ppDoclist = (const u8*)&p->zKey[nTerm+1];
189894
- *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
189905
+ *pzTerm = zKey;
189906
+ *ppDoclist = (const u8*)&zKey[nTerm+1];
189907
+ *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
189895189908
}else{
189896189909
*pzTerm = 0;
189897189910
*ppDoclist = 0;
189898189911
*pnDoclist = 0;
189899189912
}
@@ -194993,11 +195006,11 @@
194993195006
194994195007
pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
194995195008
if( pData ){
194996195009
pData->p = (u8*)&pData[1];
194997195010
pData->nn = pData->szLeaf = doclist.n;
194998
- memcpy(pData->p, doclist.p, doclist.n);
195011
+ if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);
194999195012
fts5MultiIterNew2(p, pData, bDesc, ppIter);
195000195013
}
195001195014
fts5BufferFree(&doclist);
195002195015
}
195003195016
@@ -195232,11 +195245,11 @@
195232195245
/* If the QUERY_SCAN flag is set, all other flags must be clear. */
195233195246
assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );
195234195247
195235195248
if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
195236195249
int iIdx = 0; /* Index to search */
195237
- memcpy(&buf.p[1], pToken, nToken);
195250
+ if( nToken ) memcpy(&buf.p[1], pToken, nToken);
195238195251
195239195252
/* Figure out which index to search and set iIdx accordingly. If this
195240195253
** is a prefix query for which there is no prefix index, set iIdx to
195241195254
** greater than pConfig->nPrefix to indicate that the query will be
195242195255
** satisfied by scanning multiple terms in the main index.
@@ -195281,11 +195294,11 @@
195281195294
if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
195282195295
}
195283195296
}
195284195297
195285195298
if( p->rc ){
195286
- sqlite3Fts5IterClose(&pRet->base);
195299
+ sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
195287195300
pRet = 0;
195288195301
fts5CloseReader(p);
195289195302
}
195290195303
195291195304
*ppIter = &pRet->base;
@@ -199021,11 +199034,11 @@
199021199034
int nArg, /* Number of args */
199022199035
sqlite3_value **apUnused /* Function arguments */
199023199036
){
199024199037
assert( nArg==0 );
199025199038
UNUSED_PARAM2(nArg, apUnused);
199026
- sqlite3_result_text(pCtx, "fts5: 2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736", -1, SQLITE_TRANSIENT);
199039
+ sqlite3_result_text(pCtx, "fts5: 2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40", -1, SQLITE_TRANSIENT);
199027199040
}
199028199041
199029199042
static int fts5Init(sqlite3 *db){
199030199043
static const sqlite3_module fts5Mod = {
199031199044
/* iVersion */ 2,
199032199045
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.19.0"
402 #define SQLITE_VERSION_NUMBER 3019000
403 #define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -9671,11 +9671,11 @@
9671 **
9672 ** As well as the regular sqlite3changegroup_add() and
9673 ** sqlite3changegroup_output() functions, also available are the streaming
9674 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9675 */
9676 int sqlite3changegroup_new(sqlite3_changegroup **pp);
9677
9678 /*
9679 ** CAPI3REF: Add A Changeset To A Changegroup
9680 **
9681 ** Add all changes within the changeset (or patchset) in buffer pData (size
@@ -9748,11 +9748,11 @@
9748 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the
9749 ** final contents of the changegroup is undefined.
9750 **
9751 ** If no error occurs, SQLITE_OK is returned.
9752 */
9753 int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9754
9755 /*
9756 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9757 **
9758 ** Obtain a buffer containing a changeset (or patchset) representing the
@@ -9774,20 +9774,20 @@
9774 ** is returned and the output variables are set to the size of and a
9775 ** pointer to the output buffer, respectively. In this case it is the
9776 ** responsibility of the caller to eventually free the buffer using a
9777 ** call to sqlite3_free().
9778 */
9779 int sqlite3changegroup_output(
9780 sqlite3_changegroup*,
9781 int *pnData, /* OUT: Size of output buffer in bytes */
9782 void **ppData /* OUT: Pointer to output buffer */
9783 );
9784
9785 /*
9786 ** CAPI3REF: Delete A Changegroup Object
9787 */
9788 void sqlite3changegroup_delete(sqlite3_changegroup*);
9789
9790 /*
9791 ** CAPI3REF: Apply A Changeset To A Database
9792 **
9793 ** Apply a changeset to a database. This function attempts to update the
@@ -10172,15 +10172,15 @@
10172 SQLITE_API int sqlite3session_patchset_strm(
10173 sqlite3_session *pSession,
10174 int (*xOutput)(void *pOut, const void *pData, int nData),
10175 void *pOut
10176 );
10177 int sqlite3changegroup_add_strm(sqlite3_changegroup*,
10178 int (*xInput)(void *pIn, void *pData, int *pnData),
10179 void *pIn
10180 );
10181 int sqlite3changegroup_output_strm(sqlite3_changegroup*,
10182 int (*xOutput)(void *pOut, const void *pData, int nData),
10183 void *pOut
10184 );
10185
10186
@@ -82388,14 +82388,16 @@
82388 }
82389 #endif
82390 pIdxKey = &r;
82391 pFree = 0;
82392 }else{
 
 
 
 
82393 pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);
82394 if( pIdxKey==0 ) goto no_mem;
82395 assert( pIn3->flags & MEM_Blob );
82396 (void)ExpandBlob(pIn3);
82397 sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
82398 }
82399 pIdxKey->default_rc = 0;
82400 takeJump = 0;
82401 if( pOp->opcode==OP_NoConflict ){
@@ -91239,11 +91241,10 @@
91239 }else{
91240 return 1;
91241 }
91242 }
91243
91244 #ifndef SQLITE_OMIT_SUBQUERY
91245 /*
91246 ** Return a pointer to a subexpression of pVector that is the i-th
91247 ** column of the vector (numbered starting with 0). The caller must
91248 ** ensure that i is within range.
91249 **
@@ -91267,13 +91268,11 @@
91267 return pVector->x.pList->a[i].pExpr;
91268 }
91269 }
91270 return pVector;
91271 }
91272 #endif /* !defined(SQLITE_OMIT_SUBQUERY) */
91273
91274 #ifndef SQLITE_OMIT_SUBQUERY
91275 /*
91276 ** Compute and return a new Expr object which when passed to
91277 ** sqlite3ExprCode() will generate all necessary code to compute
91278 ** the iField-th column of the vector expression pVector.
91279 **
@@ -91327,11 +91326,10 @@
91327 if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
91328 pRet = sqlite3ExprDup(pParse->db, pVector, 0);
91329 }
91330 return pRet;
91331 }
91332 #endif /* !define(SQLITE_OMIT_SUBQUERY) */
91333
91334 /*
91335 ** If expression pExpr is of type TK_SELECT, generate code to evaluate
91336 ** it. Return the register in which the result is stored (or, if the
91337 ** sub-select returns more than one column, the first in an array
@@ -94298,11 +94296,15 @@
94298 if( nResult==1 ){
94299 iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);
94300 }else{
94301 *piFreeable = 0;
94302 if( p->op==TK_SELECT ){
 
 
 
94303 iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
 
94304 }else{
94305 int i;
94306 iResult = pParse->nMem+1;
94307 pParse->nMem += nResult;
94308 for(i=0; i<nResult; i++){
@@ -185267,13 +185269,15 @@
185267 Fts5Buffer *pBuf,
185268 u32 nData,
185269 const u8 *pData
185270 ){
185271 assert_nc( *pRc || nData>=0 );
185272 if( fts5BufferGrow(pRc, pBuf, nData) ) return;
185273 memcpy(&pBuf->p[pBuf->n], pData, nData);
185274 pBuf->n += nData;
 
 
185275 }
185276
185277 /*
185278 ** Append the nul-terminated string zStr to the buffer pBuf. This function
185279 ** ensures that the byte following the buffer data is set to 0x00, even
@@ -185446,12 +185450,12 @@
185446
185447 static void *sqlite3Fts5MallocZero(int *pRc, int nByte){
185448 void *pRet = 0;
185449 if( *pRc==SQLITE_OK ){
185450 pRet = sqlite3_malloc(nByte);
185451 if( pRet==0 && nByte>0 ){
185452 *pRc = SQLITE_NOMEM;
185453 }else{
185454 memset(pRet, 0, nByte);
185455 }
185456 }
185457 return pRet;
@@ -189408,13 +189412,14 @@
189408 Fts5HashEntry **aSlot; /* Array of hash slots */
189409 };
189410
189411 /*
189412 ** Each entry in the hash table is represented by an object of the
189413 ** following type. Each object, its key (zKey[]) and its current data
189414 ** are stored in a single memory allocation. The position list data
189415 ** immediately follows the key data in memory.
 
189416 **
189417 ** The data that follows the key is in a similar, but not identical format
189418 ** to the doclist data stored in the database. It is:
189419 **
189420 ** * Rowid, as a varint
@@ -189434,24 +189439,24 @@
189434 Fts5HashEntry *pScanNext; /* Next entry in sorted order */
189435
189436 int nAlloc; /* Total size of allocation */
189437 int iSzPoslist; /* Offset of space for 4-byte poslist size */
189438 int nData; /* Total bytes of data (incl. structure) */
189439 int nKey; /* Length of zKey[] in bytes */
189440 u8 bDel; /* Set delete-flag @ iSzPoslist */
189441 u8 bContent; /* Set content-flag (detail=none mode) */
189442 i16 iCol; /* Column of last value written */
189443 int iPos; /* Position of last value written */
189444 i64 iRowid; /* Rowid of last value written */
189445 char zKey[8]; /* Nul-terminated entry key */
189446 };
189447
189448 /*
189449 ** Size of Fts5HashEntry without the zKey[] array.
 
 
189450 */
189451 #define FTS5_HASHENTRYSIZE (sizeof(Fts5HashEntry)-8)
189452
189453
189454
189455 /*
189456 ** Allocate a new hash table.
189457 */
@@ -189545,11 +189550,11 @@
189545 for(i=0; i<pHash->nSlot; i++){
189546 while( apOld[i] ){
189547 int iHash;
189548 Fts5HashEntry *p = apOld[i];
189549 apOld[i] = p->pHashNext;
189550 iHash = fts5HashKey(nNew, (u8*)p->zKey, (int)strlen(p->zKey));
189551 p->pHashNext = apNew[iHash];
189552 apNew[iHash] = p;
189553 }
189554 }
189555
@@ -189616,22 +189621,24 @@
189616 bNew = (pHash->eDetail==FTS5_DETAIL_FULL);
189617
189618 /* Attempt to locate an existing hash entry */
189619 iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);
189620 for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189621 if( p->zKey[0]==bByte
 
189622 && p->nKey==nToken
189623 && memcmp(&p->zKey[1], pToken, nToken)==0
189624 ){
189625 break;
189626 }
189627 }
189628
189629 /* If an existing hash entry cannot be found, create a new one. */
189630 if( p==0 ){
189631 /* Figure out how much space to allocate */
189632 int nByte = FTS5_HASHENTRYSIZE + (nToken+1) + 1 + 64;
 
189633 if( nByte<128 ) nByte = 128;
189634
189635 /* Grow the Fts5Hash.aSlot[] array if necessary. */
189636 if( (pHash->nEntry*2)>=pHash->nSlot ){
189637 int rc = fts5HashResize(pHash);
@@ -189640,18 +189647,19 @@
189640 }
189641
189642 /* Allocate new Fts5HashEntry and add it to the hash table. */
189643 p = (Fts5HashEntry*)sqlite3_malloc(nByte);
189644 if( !p ) return SQLITE_NOMEM;
189645 memset(p, 0, FTS5_HASHENTRYSIZE);
189646 p->nAlloc = nByte;
189647 p->zKey[0] = bByte;
189648 memcpy(&p->zKey[1], pToken, nToken);
189649 assert( iHash==fts5HashKey(pHash->nSlot, (u8*)p->zKey, nToken+1) );
 
189650 p->nKey = nToken;
189651 p->zKey[nToken+1] = '\0';
189652 p->nData = nToken+1 + 1 + FTS5_HASHENTRYSIZE;
189653 p->pHashNext = pHash->aSlot[iHash];
189654 pHash->aSlot[iHash] = p;
189655 pHash->nEntry++;
189656
189657 /* Add the first rowid field to the hash-entry */
@@ -189765,13 +189773,15 @@
189765 }else if( p2==0 ){
189766 *ppOut = p1;
189767 p1 = 0;
189768 }else{
189769 int i = 0;
189770 while( p1->zKey[i]==p2->zKey[i] ) i++;
 
 
189771
189772 if( ((u8)p1->zKey[i])>((u8)p2->zKey[i]) ){
189773 /* p2 is smaller */
189774 *ppOut = p2;
189775 ppOut = &p2->pScanNext;
189776 p2 = p2->pScanNext;
189777 }else{
@@ -189810,11 +189820,11 @@
189810 memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
189811
189812 for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
189813 Fts5HashEntry *pIter;
189814 for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
189815 if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){
189816 Fts5HashEntry *pEntry = pIter;
189817 pEntry->pScanNext = 0;
189818 for(i=0; ap[i]; i++){
189819 pEntry = fts5HashEntryMerge(pEntry, ap[i]);
189820 ap[i] = 0;
@@ -189843,20 +189853,22 @@
189843 const char *pTerm, int nTerm, /* Query term */
189844 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
189845 int *pnDoclist /* OUT: Size of doclist in bytes */
189846 ){
189847 unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
 
189848 Fts5HashEntry *p;
189849
189850 for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189851 if( memcmp(p->zKey, pTerm, nTerm)==0 && p->zKey[nTerm]==0 ) break;
 
189852 }
189853
189854 if( p ){
189855 fts5HashAddPoslistSize(pHash, p);
189856 *ppDoclist = (const u8*)&p->zKey[nTerm+1];
189857 *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
189858 }else{
189859 *ppDoclist = 0;
189860 *pnDoclist = 0;
189861 }
189862
@@ -189885,15 +189897,16 @@
189885 const u8 **ppDoclist, /* OUT: pointer to doclist */
189886 int *pnDoclist /* OUT: size of doclist in bytes */
189887 ){
189888 Fts5HashEntry *p;
189889 if( (p = pHash->pScan) ){
189890 int nTerm = (int)strlen(p->zKey);
 
189891 fts5HashAddPoslistSize(pHash, p);
189892 *pzTerm = p->zKey;
189893 *ppDoclist = (const u8*)&p->zKey[nTerm+1];
189894 *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
189895 }else{
189896 *pzTerm = 0;
189897 *ppDoclist = 0;
189898 *pnDoclist = 0;
189899 }
@@ -194993,11 +195006,11 @@
194993
194994 pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
194995 if( pData ){
194996 pData->p = (u8*)&pData[1];
194997 pData->nn = pData->szLeaf = doclist.n;
194998 memcpy(pData->p, doclist.p, doclist.n);
194999 fts5MultiIterNew2(p, pData, bDesc, ppIter);
195000 }
195001 fts5BufferFree(&doclist);
195002 }
195003
@@ -195232,11 +195245,11 @@
195232 /* If the QUERY_SCAN flag is set, all other flags must be clear. */
195233 assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );
195234
195235 if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
195236 int iIdx = 0; /* Index to search */
195237 memcpy(&buf.p[1], pToken, nToken);
195238
195239 /* Figure out which index to search and set iIdx accordingly. If this
195240 ** is a prefix query for which there is no prefix index, set iIdx to
195241 ** greater than pConfig->nPrefix to indicate that the query will be
195242 ** satisfied by scanning multiple terms in the main index.
@@ -195281,11 +195294,11 @@
195281 if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
195282 }
195283 }
195284
195285 if( p->rc ){
195286 sqlite3Fts5IterClose(&pRet->base);
195287 pRet = 0;
195288 fts5CloseReader(p);
195289 }
195290
195291 *ppIter = &pRet->base;
@@ -199021,11 +199034,11 @@
199021 int nArg, /* Number of args */
199022 sqlite3_value **apUnused /* Function arguments */
199023 ){
199024 assert( nArg==0 );
199025 UNUSED_PARAM2(nArg, apUnused);
199026 sqlite3_result_text(pCtx, "fts5: 2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736", -1, SQLITE_TRANSIENT);
199027 }
199028
199029 static int fts5Init(sqlite3 *db){
199030 static const sqlite3_module fts5Mod = {
199031 /* iVersion */ 2,
199032
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.19.0"
402 #define SQLITE_VERSION_NUMBER 3019000
403 #define SQLITE_SOURCE_ID "2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -9671,11 +9671,11 @@
9671 **
9672 ** As well as the regular sqlite3changegroup_add() and
9673 ** sqlite3changegroup_output() functions, also available are the streaming
9674 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9675 */
9676 SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
9677
9678 /*
9679 ** CAPI3REF: Add A Changeset To A Changegroup
9680 **
9681 ** Add all changes within the changeset (or patchset) in buffer pData (size
@@ -9748,11 +9748,11 @@
9748 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the
9749 ** final contents of the changegroup is undefined.
9750 **
9751 ** If no error occurs, SQLITE_OK is returned.
9752 */
9753 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9754
9755 /*
9756 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9757 **
9758 ** Obtain a buffer containing a changeset (or patchset) representing the
@@ -9774,20 +9774,20 @@
9774 ** is returned and the output variables are set to the size of and a
9775 ** pointer to the output buffer, respectively. In this case it is the
9776 ** responsibility of the caller to eventually free the buffer using a
9777 ** call to sqlite3_free().
9778 */
9779 SQLITE_API int sqlite3changegroup_output(
9780 sqlite3_changegroup*,
9781 int *pnData, /* OUT: Size of output buffer in bytes */
9782 void **ppData /* OUT: Pointer to output buffer */
9783 );
9784
9785 /*
9786 ** CAPI3REF: Delete A Changegroup Object
9787 */
9788 SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
9789
9790 /*
9791 ** CAPI3REF: Apply A Changeset To A Database
9792 **
9793 ** Apply a changeset to a database. This function attempts to update the
@@ -10172,15 +10172,15 @@
10172 SQLITE_API int sqlite3session_patchset_strm(
10173 sqlite3_session *pSession,
10174 int (*xOutput)(void *pOut, const void *pData, int nData),
10175 void *pOut
10176 );
10177 SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*,
10178 int (*xInput)(void *pIn, void *pData, int *pnData),
10179 void *pIn
10180 );
10181 SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
10182 int (*xOutput)(void *pOut, const void *pData, int nData),
10183 void *pOut
10184 );
10185
10186
@@ -82388,14 +82388,16 @@
82388 }
82389 #endif
82390 pIdxKey = &r;
82391 pFree = 0;
82392 }else{
82393 assert( pIn3->flags & MEM_Blob );
82394 rc = ExpandBlob(pIn3);
82395 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
82396 if( rc ) goto no_mem;
82397 pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);
82398 if( pIdxKey==0 ) goto no_mem;
 
 
82399 sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
82400 }
82401 pIdxKey->default_rc = 0;
82402 takeJump = 0;
82403 if( pOp->opcode==OP_NoConflict ){
@@ -91239,11 +91241,10 @@
91241 }else{
91242 return 1;
91243 }
91244 }
91245
 
91246 /*
91247 ** Return a pointer to a subexpression of pVector that is the i-th
91248 ** column of the vector (numbered starting with 0). The caller must
91249 ** ensure that i is within range.
91250 **
@@ -91267,13 +91268,11 @@
91268 return pVector->x.pList->a[i].pExpr;
91269 }
91270 }
91271 return pVector;
91272 }
 
91273
 
91274 /*
91275 ** Compute and return a new Expr object which when passed to
91276 ** sqlite3ExprCode() will generate all necessary code to compute
91277 ** the iField-th column of the vector expression pVector.
91278 **
@@ -91327,11 +91326,10 @@
91326 if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
91327 pRet = sqlite3ExprDup(pParse->db, pVector, 0);
91328 }
91329 return pRet;
91330 }
 
91331
91332 /*
91333 ** If expression pExpr is of type TK_SELECT, generate code to evaluate
91334 ** it. Return the register in which the result is stored (or, if the
91335 ** sub-select returns more than one column, the first in an array
@@ -94298,11 +94296,15 @@
94296 if( nResult==1 ){
94297 iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);
94298 }else{
94299 *piFreeable = 0;
94300 if( p->op==TK_SELECT ){
94301 #if SQLITE_OMIT_SUBQUERY
94302 iResult = 0;
94303 #else
94304 iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
94305 #endif
94306 }else{
94307 int i;
94308 iResult = pParse->nMem+1;
94309 pParse->nMem += nResult;
94310 for(i=0; i<nResult; i++){
@@ -185267,13 +185269,15 @@
185269 Fts5Buffer *pBuf,
185270 u32 nData,
185271 const u8 *pData
185272 ){
185273 assert_nc( *pRc || nData>=0 );
185274 if( nData ){
185275 if( fts5BufferGrow(pRc, pBuf, nData) ) return;
185276 memcpy(&pBuf->p[pBuf->n], pData, nData);
185277 pBuf->n += nData;
185278 }
185279 }
185280
185281 /*
185282 ** Append the nul-terminated string zStr to the buffer pBuf. This function
185283 ** ensures that the byte following the buffer data is set to 0x00, even
@@ -185446,12 +185450,12 @@
185450
185451 static void *sqlite3Fts5MallocZero(int *pRc, int nByte){
185452 void *pRet = 0;
185453 if( *pRc==SQLITE_OK ){
185454 pRet = sqlite3_malloc(nByte);
185455 if( pRet==0 ){
185456 if( nByte>0 ) *pRc = SQLITE_NOMEM;
185457 }else{
185458 memset(pRet, 0, nByte);
185459 }
185460 }
185461 return pRet;
@@ -189408,13 +189412,14 @@
189412 Fts5HashEntry **aSlot; /* Array of hash slots */
189413 };
189414
189415 /*
189416 ** Each entry in the hash table is represented by an object of the
189417 ** following type. Each object, its key (a nul-terminated string) and
189418 ** its current data are stored in a single memory allocation. The
189419 ** key immediately follows the object in memory. The position list
189420 ** data immediately follows the key data in memory.
189421 **
189422 ** The data that follows the key is in a similar, but not identical format
189423 ** to the doclist data stored in the database. It is:
189424 **
189425 ** * Rowid, as a varint
@@ -189434,24 +189439,24 @@
189439 Fts5HashEntry *pScanNext; /* Next entry in sorted order */
189440
189441 int nAlloc; /* Total size of allocation */
189442 int iSzPoslist; /* Offset of space for 4-byte poslist size */
189443 int nData; /* Total bytes of data (incl. structure) */
189444 int nKey; /* Length of key in bytes */
189445 u8 bDel; /* Set delete-flag @ iSzPoslist */
189446 u8 bContent; /* Set content-flag (detail=none mode) */
189447 i16 iCol; /* Column of last value written */
189448 int iPos; /* Position of last value written */
189449 i64 iRowid; /* Rowid of last value written */
 
189450 };
189451
189452 /*
189453 ** Eqivalent to:
189454 **
189455 ** char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }
189456 */
189457 #define fts5EntryKey(p) ( ((char *)(&(p)[1])) )
 
189458
189459
189460 /*
189461 ** Allocate a new hash table.
189462 */
@@ -189545,11 +189550,11 @@
189550 for(i=0; i<pHash->nSlot; i++){
189551 while( apOld[i] ){
189552 int iHash;
189553 Fts5HashEntry *p = apOld[i];
189554 apOld[i] = p->pHashNext;
189555 iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), strlen(fts5EntryKey(p)));
189556 p->pHashNext = apNew[iHash];
189557 apNew[iHash] = p;
189558 }
189559 }
189560
@@ -189616,22 +189621,24 @@
189621 bNew = (pHash->eDetail==FTS5_DETAIL_FULL);
189622
189623 /* Attempt to locate an existing hash entry */
189624 iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);
189625 for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189626 char *zKey = fts5EntryKey(p);
189627 if( zKey[0]==bByte
189628 && p->nKey==nToken
189629 && memcmp(&zKey[1], pToken, nToken)==0
189630 ){
189631 break;
189632 }
189633 }
189634
189635 /* If an existing hash entry cannot be found, create a new one. */
189636 if( p==0 ){
189637 /* Figure out how much space to allocate */
189638 char *zKey;
189639 int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
189640 if( nByte<128 ) nByte = 128;
189641
189642 /* Grow the Fts5Hash.aSlot[] array if necessary. */
189643 if( (pHash->nEntry*2)>=pHash->nSlot ){
189644 int rc = fts5HashResize(pHash);
@@ -189640,18 +189647,19 @@
189647 }
189648
189649 /* Allocate new Fts5HashEntry and add it to the hash table. */
189650 p = (Fts5HashEntry*)sqlite3_malloc(nByte);
189651 if( !p ) return SQLITE_NOMEM;
189652 memset(p, 0, sizeof(Fts5HashEntry));
189653 p->nAlloc = nByte;
189654 zKey = fts5EntryKey(p);
189655 zKey[0] = bByte;
189656 memcpy(&zKey[1], pToken, nToken);
189657 assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
189658 p->nKey = nToken;
189659 zKey[nToken+1] = '\0';
189660 p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);
189661 p->pHashNext = pHash->aSlot[iHash];
189662 pHash->aSlot[iHash] = p;
189663 pHash->nEntry++;
189664
189665 /* Add the first rowid field to the hash-entry */
@@ -189765,13 +189773,15 @@
189773 }else if( p2==0 ){
189774 *ppOut = p1;
189775 p1 = 0;
189776 }else{
189777 int i = 0;
189778 char *zKey1 = fts5EntryKey(p1);
189779 char *zKey2 = fts5EntryKey(p2);
189780 while( zKey1[i]==zKey2[i] ) i++;
189781
189782 if( ((u8)zKey1[i])>((u8)zKey2[i]) ){
189783 /* p2 is smaller */
189784 *ppOut = p2;
189785 ppOut = &p2->pScanNext;
189786 p2 = p2->pScanNext;
189787 }else{
@@ -189810,11 +189820,11 @@
189820 memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
189821
189822 for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
189823 Fts5HashEntry *pIter;
189824 for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
189825 if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
189826 Fts5HashEntry *pEntry = pIter;
189827 pEntry->pScanNext = 0;
189828 for(i=0; ap[i]; i++){
189829 pEntry = fts5HashEntryMerge(pEntry, ap[i]);
189830 ap[i] = 0;
@@ -189843,20 +189853,22 @@
189853 const char *pTerm, int nTerm, /* Query term */
189854 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
189855 int *pnDoclist /* OUT: Size of doclist in bytes */
189856 ){
189857 unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
189858 char *zKey;
189859 Fts5HashEntry *p;
189860
189861 for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189862 zKey = fts5EntryKey(p);
189863 if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
189864 }
189865
189866 if( p ){
189867 fts5HashAddPoslistSize(pHash, p);
189868 *ppDoclist = (const u8*)&zKey[nTerm+1];
189869 *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
189870 }else{
189871 *ppDoclist = 0;
189872 *pnDoclist = 0;
189873 }
189874
@@ -189885,15 +189897,16 @@
189897 const u8 **ppDoclist, /* OUT: pointer to doclist */
189898 int *pnDoclist /* OUT: size of doclist in bytes */
189899 ){
189900 Fts5HashEntry *p;
189901 if( (p = pHash->pScan) ){
189902 char *zKey = fts5EntryKey(p);
189903 int nTerm = (int)strlen(zKey);
189904 fts5HashAddPoslistSize(pHash, p);
189905 *pzTerm = zKey;
189906 *ppDoclist = (const u8*)&zKey[nTerm+1];
189907 *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
189908 }else{
189909 *pzTerm = 0;
189910 *ppDoclist = 0;
189911 *pnDoclist = 0;
189912 }
@@ -194993,11 +195006,11 @@
195006
195007 pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
195008 if( pData ){
195009 pData->p = (u8*)&pData[1];
195010 pData->nn = pData->szLeaf = doclist.n;
195011 if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);
195012 fts5MultiIterNew2(p, pData, bDesc, ppIter);
195013 }
195014 fts5BufferFree(&doclist);
195015 }
195016
@@ -195232,11 +195245,11 @@
195245 /* If the QUERY_SCAN flag is set, all other flags must be clear. */
195246 assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );
195247
195248 if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
195249 int iIdx = 0; /* Index to search */
195250 if( nToken ) memcpy(&buf.p[1], pToken, nToken);
195251
195252 /* Figure out which index to search and set iIdx accordingly. If this
195253 ** is a prefix query for which there is no prefix index, set iIdx to
195254 ** greater than pConfig->nPrefix to indicate that the query will be
195255 ** satisfied by scanning multiple terms in the main index.
@@ -195281,11 +195294,11 @@
195294 if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
195295 }
195296 }
195297
195298 if( p->rc ){
195299 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
195300 pRet = 0;
195301 fts5CloseReader(p);
195302 }
195303
195304 *ppIter = &pRet->base;
@@ -199021,11 +199034,11 @@
199034 int nArg, /* Number of args */
199035 sqlite3_value **apUnused /* Function arguments */
199036 ){
199037 assert( nArg==0 );
199038 UNUSED_PARAM2(nArg, apUnused);
199039 sqlite3_result_text(pCtx, "fts5: 2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40", -1, SQLITE_TRANSIENT);
199040 }
199041
199042 static int fts5Init(sqlite3 *db){
199043 static const sqlite3_module fts5Mod = {
199044 /* iVersion */ 2,
199045
+7 -7
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.19.0"
125125
#define SQLITE_VERSION_NUMBER 3019000
126
-#define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
126
+#define SQLITE_SOURCE_ID "2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -9394,11 +9394,11 @@
93949394
**
93959395
** As well as the regular sqlite3changegroup_add() and
93969396
** sqlite3changegroup_output() functions, also available are the streaming
93979397
** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
93989398
*/
9399
-int sqlite3changegroup_new(sqlite3_changegroup **pp);
9399
+SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
94009400
94019401
/*
94029402
** CAPI3REF: Add A Changeset To A Changegroup
94039403
**
94049404
** Add all changes within the changeset (or patchset) in buffer pData (size
@@ -9471,11 +9471,11 @@
94719471
** function returns SQLITE_NOMEM. In all cases, if an error occurs the
94729472
** final contents of the changegroup is undefined.
94739473
**
94749474
** If no error occurs, SQLITE_OK is returned.
94759475
*/
9476
-int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9476
+SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
94779477
94789478
/*
94799479
** CAPI3REF: Obtain A Composite Changeset From A Changegroup
94809480
**
94819481
** Obtain a buffer containing a changeset (or patchset) representing the
@@ -9497,20 +9497,20 @@
94979497
** is returned and the output variables are set to the size of and a
94989498
** pointer to the output buffer, respectively. In this case it is the
94999499
** responsibility of the caller to eventually free the buffer using a
95009500
** call to sqlite3_free().
95019501
*/
9502
-int sqlite3changegroup_output(
9502
+SQLITE_API int sqlite3changegroup_output(
95039503
sqlite3_changegroup*,
95049504
int *pnData, /* OUT: Size of output buffer in bytes */
95059505
void **ppData /* OUT: Pointer to output buffer */
95069506
);
95079507
95089508
/*
95099509
** CAPI3REF: Delete A Changegroup Object
95109510
*/
9511
-void sqlite3changegroup_delete(sqlite3_changegroup*);
9511
+SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
95129512
95139513
/*
95149514
** CAPI3REF: Apply A Changeset To A Database
95159515
**
95169516
** Apply a changeset to a database. This function attempts to update the
@@ -9895,15 +9895,15 @@
98959895
SQLITE_API int sqlite3session_patchset_strm(
98969896
sqlite3_session *pSession,
98979897
int (*xOutput)(void *pOut, const void *pData, int nData),
98989898
void *pOut
98999899
);
9900
-int sqlite3changegroup_add_strm(sqlite3_changegroup*,
9900
+SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*,
99019901
int (*xInput)(void *pIn, void *pData, int *pnData),
99029902
void *pIn
99039903
);
9904
-int sqlite3changegroup_output_strm(sqlite3_changegroup*,
9904
+SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
99059905
int (*xOutput)(void *pOut, const void *pData, int nData),
99069906
void *pOut
99079907
);
99089908
99099909
99109910
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.19.0"
125 #define SQLITE_VERSION_NUMBER 3019000
126 #define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -9394,11 +9394,11 @@
9394 **
9395 ** As well as the regular sqlite3changegroup_add() and
9396 ** sqlite3changegroup_output() functions, also available are the streaming
9397 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9398 */
9399 int sqlite3changegroup_new(sqlite3_changegroup **pp);
9400
9401 /*
9402 ** CAPI3REF: Add A Changeset To A Changegroup
9403 **
9404 ** Add all changes within the changeset (or patchset) in buffer pData (size
@@ -9471,11 +9471,11 @@
9471 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the
9472 ** final contents of the changegroup is undefined.
9473 **
9474 ** If no error occurs, SQLITE_OK is returned.
9475 */
9476 int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9477
9478 /*
9479 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9480 **
9481 ** Obtain a buffer containing a changeset (or patchset) representing the
@@ -9497,20 +9497,20 @@
9497 ** is returned and the output variables are set to the size of and a
9498 ** pointer to the output buffer, respectively. In this case it is the
9499 ** responsibility of the caller to eventually free the buffer using a
9500 ** call to sqlite3_free().
9501 */
9502 int sqlite3changegroup_output(
9503 sqlite3_changegroup*,
9504 int *pnData, /* OUT: Size of output buffer in bytes */
9505 void **ppData /* OUT: Pointer to output buffer */
9506 );
9507
9508 /*
9509 ** CAPI3REF: Delete A Changegroup Object
9510 */
9511 void sqlite3changegroup_delete(sqlite3_changegroup*);
9512
9513 /*
9514 ** CAPI3REF: Apply A Changeset To A Database
9515 **
9516 ** Apply a changeset to a database. This function attempts to update the
@@ -9895,15 +9895,15 @@
9895 SQLITE_API int sqlite3session_patchset_strm(
9896 sqlite3_session *pSession,
9897 int (*xOutput)(void *pOut, const void *pData, int nData),
9898 void *pOut
9899 );
9900 int sqlite3changegroup_add_strm(sqlite3_changegroup*,
9901 int (*xInput)(void *pIn, void *pData, int *pnData),
9902 void *pIn
9903 );
9904 int sqlite3changegroup_output_strm(sqlite3_changegroup*,
9905 int (*xOutput)(void *pOut, const void *pData, int nData),
9906 void *pOut
9907 );
9908
9909
9910
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.19.0"
125 #define SQLITE_VERSION_NUMBER 3019000
126 #define SQLITE_SOURCE_ID "2017-05-22 13:58:13 28a94eb282822cad1d1420f2dad6bf65e4b8b9062eda4a0b9ee8270b2c608e40"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -9394,11 +9394,11 @@
9394 **
9395 ** As well as the regular sqlite3changegroup_add() and
9396 ** sqlite3changegroup_output() functions, also available are the streaming
9397 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9398 */
9399 SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
9400
9401 /*
9402 ** CAPI3REF: Add A Changeset To A Changegroup
9403 **
9404 ** Add all changes within the changeset (or patchset) in buffer pData (size
@@ -9471,11 +9471,11 @@
9471 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the
9472 ** final contents of the changegroup is undefined.
9473 **
9474 ** If no error occurs, SQLITE_OK is returned.
9475 */
9476 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9477
9478 /*
9479 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9480 **
9481 ** Obtain a buffer containing a changeset (or patchset) representing the
@@ -9497,20 +9497,20 @@
9497 ** is returned and the output variables are set to the size of and a
9498 ** pointer to the output buffer, respectively. In this case it is the
9499 ** responsibility of the caller to eventually free the buffer using a
9500 ** call to sqlite3_free().
9501 */
9502 SQLITE_API int sqlite3changegroup_output(
9503 sqlite3_changegroup*,
9504 int *pnData, /* OUT: Size of output buffer in bytes */
9505 void **ppData /* OUT: Pointer to output buffer */
9506 );
9507
9508 /*
9509 ** CAPI3REF: Delete A Changegroup Object
9510 */
9511 SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
9512
9513 /*
9514 ** CAPI3REF: Apply A Changeset To A Database
9515 **
9516 ** Apply a changeset to a database. This function attempts to update the
@@ -9895,15 +9895,15 @@
9895 SQLITE_API int sqlite3session_patchset_strm(
9896 sqlite3_session *pSession,
9897 int (*xOutput)(void *pOut, const void *pData, int nData),
9898 void *pOut
9899 );
9900 SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*,
9901 int (*xInput)(void *pIn, void *pData, int *pnData),
9902 void *pIn
9903 );
9904 SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
9905 int (*xOutput)(void *pOut, const void *pData, int nData),
9906 void *pOut
9907 );
9908
9909
9910
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,7 +1,12 @@
11
<title>Change Log</title>
22
3
+<a name='v2_3'></a>
4
+<h2>Changes for Version 2.3 (2017-??-??)</h2>
5
+
6
+ * Update the built-in SQLite to version 3.19.0.
7
+
38
<a name='v2_2'></a>
49
<h2>Changes for Version 2.2 (2017-04-11)</h2>
510
611
* GIT comment tags are now handled by Fossil during import/export.
712
* Show the content of README files on directory listings.
813
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,7 +1,12 @@
1 <title>Change Log</title>
2
 
 
 
 
 
3 <a name='v2_2'></a>
4 <h2>Changes for Version 2.2 (2017-04-11)</h2>
5
6 * GIT comment tags are now handled by Fossil during import/export.
7 * Show the content of README files on directory listings.
8
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,7 +1,12 @@
1 <title>Change Log</title>
2
3 <a name='v2_3'></a>
4 <h2>Changes for Version 2.3 (2017-??-??)</h2>
5
6 * Update the built-in SQLite to version 3.19.0.
7
8 <a name='v2_2'></a>
9 <h2>Changes for Version 2.2 (2017-04-11)</h2>
10
11 * GIT comment tags are now handled by Fossil during import/export.
12 * Show the content of README files on directory listings.
13

Keyboard Shortcuts

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