Fossil SCM

New version of the built-in SQLite that incorporates all the latest static-analyzer warning fixes.

drh 2021-10-06 10:45 trunk
Commit c90dce4ebcf3dfc8be8f221086d085aa14fad431be57a4fdee494365f2f189bd
3 files changed +25 -5 +231 -101 +1 -1
+25 -5
--- src/shell.c
+++ src/shell.c
@@ -872,11 +872,11 @@
872872
for(i=0; i<nAppend; i++){
873873
if( zAppend[i]==quote ) len++;
874874
}
875875
}
876876
877
- if( p->n+len>=p->nAlloc ){
877
+ if( p->z==0 || p->n+len>=p->nAlloc ){
878878
p->nAlloc = p->nAlloc*2 + len + 20;
879879
p->z = realloc(p->z, p->nAlloc);
880880
if( p->z==0 ) shell_out_of_memory();
881881
}
882882
@@ -6261,13 +6261,13 @@
62616261
rc = 1;
62626262
goto re_match_end;
62636263
}
62646264
case RE_OP_CC_EXC: {
62656265
if( c==0 ) break;
6266
- /* fall-through */
6266
+ /* fall-through */ goto re_op_cc_inc;
62676267
}
6268
- case RE_OP_CC_INC: {
6268
+ case RE_OP_CC_INC: re_op_cc_inc: {
62696269
int j = 1;
62706270
int n = pRe->aArg[x];
62716271
int hit = 0;
62726272
for(j=1; j>0 && j<n; j++){
62736273
if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
@@ -6794,10 +6794,13 @@
67946794
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
67956795
typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
67966796
#define MIN(a,b) ((a)<(b) ? (a) : (b))
67976797
67986798
#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
6799
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
6800
+#endif
6801
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
67996802
# define ALWAYS(X) (1)
68006803
# define NEVER(X) (0)
68016804
#elif !defined(NDEBUG)
68026805
# define ALWAYS(X) ((X)?1:(assert(0),0))
68036806
# define NEVER(X) ((X)?(assert(0),1):0)
@@ -9253,10 +9256,27 @@
92539256
*/
92549257
/* #include "sqlite3expert.h" */
92559258
#include <assert.h>
92569259
#include <string.h>
92579260
#include <stdio.h>
9261
+
9262
+#if !defined(SQLITE_AMALGAMATION)
9263
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
9264
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
9265
+#endif
9266
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
9267
+# define ALWAYS(X) (1)
9268
+# define NEVER(X) (0)
9269
+#elif !defined(NDEBUG)
9270
+# define ALWAYS(X) ((X)?1:(assert(0),0))
9271
+# define NEVER(X) ((X)?(assert(0),1):0)
9272
+#else
9273
+# define ALWAYS(X) (X)
9274
+# define NEVER(X) (X)
9275
+#endif
9276
+#endif /* !defined(SQLITE_AMALGAMATION) */
9277
+
92589278
92599279
#ifndef SQLITE_OMIT_VIRTUALTABLE
92609280
92619281
/* typedef sqlite3_int64 i64; */
92629282
/* typedef sqlite3_uint64 u64; */
@@ -9980,13 +10000,13 @@
998010000
idxFinalize(&rc, p1);
998110001
998210002
if( rc!=SQLITE_OK ){
998310003
sqlite3_free(pNew);
998410004
pNew = 0;
9985
- }else{
10005
+ }else if( ALWAYS(pNew!=0) ){
998610006
pNew->zName = pCsr;
9987
- memcpy(pNew->zName, zTab, nTab+1);
10007
+ if( ALWAYS(pNew->zName!=0) ) memcpy(pNew->zName, zTab, nTab+1);
998810008
}
998910009
999010010
*ppOut = pNew;
999110011
return rc;
999210012
}
999310013
--- src/shell.c
+++ src/shell.c
@@ -872,11 +872,11 @@
872 for(i=0; i<nAppend; i++){
873 if( zAppend[i]==quote ) len++;
874 }
875 }
876
877 if( p->n+len>=p->nAlloc ){
878 p->nAlloc = p->nAlloc*2 + len + 20;
879 p->z = realloc(p->z, p->nAlloc);
880 if( p->z==0 ) shell_out_of_memory();
881 }
882
@@ -6261,13 +6261,13 @@
6261 rc = 1;
6262 goto re_match_end;
6263 }
6264 case RE_OP_CC_EXC: {
6265 if( c==0 ) break;
6266 /* fall-through */
6267 }
6268 case RE_OP_CC_INC: {
6269 int j = 1;
6270 int n = pRe->aArg[x];
6271 int hit = 0;
6272 for(j=1; j>0 && j<n; j++){
6273 if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
@@ -6794,10 +6794,13 @@
6794 typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
6795 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
6796 #define MIN(a,b) ((a)<(b) ? (a) : (b))
6797
6798 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
 
 
 
6799 # define ALWAYS(X) (1)
6800 # define NEVER(X) (0)
6801 #elif !defined(NDEBUG)
6802 # define ALWAYS(X) ((X)?1:(assert(0),0))
6803 # define NEVER(X) ((X)?(assert(0),1):0)
@@ -9253,10 +9256,27 @@
9253 */
9254 /* #include "sqlite3expert.h" */
9255 #include <assert.h>
9256 #include <string.h>
9257 #include <stdio.h>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9258
9259 #ifndef SQLITE_OMIT_VIRTUALTABLE
9260
9261 /* typedef sqlite3_int64 i64; */
9262 /* typedef sqlite3_uint64 u64; */
@@ -9980,13 +10000,13 @@
9980 idxFinalize(&rc, p1);
9981
9982 if( rc!=SQLITE_OK ){
9983 sqlite3_free(pNew);
9984 pNew = 0;
9985 }else{
9986 pNew->zName = pCsr;
9987 memcpy(pNew->zName, zTab, nTab+1);
9988 }
9989
9990 *ppOut = pNew;
9991 return rc;
9992 }
9993
--- src/shell.c
+++ src/shell.c
@@ -872,11 +872,11 @@
872 for(i=0; i<nAppend; i++){
873 if( zAppend[i]==quote ) len++;
874 }
875 }
876
877 if( p->z==0 || p->n+len>=p->nAlloc ){
878 p->nAlloc = p->nAlloc*2 + len + 20;
879 p->z = realloc(p->z, p->nAlloc);
880 if( p->z==0 ) shell_out_of_memory();
881 }
882
@@ -6261,13 +6261,13 @@
6261 rc = 1;
6262 goto re_match_end;
6263 }
6264 case RE_OP_CC_EXC: {
6265 if( c==0 ) break;
6266 /* fall-through */ goto re_op_cc_inc;
6267 }
6268 case RE_OP_CC_INC: re_op_cc_inc: {
6269 int j = 1;
6270 int n = pRe->aArg[x];
6271 int hit = 0;
6272 for(j=1; j>0 && j<n; j++){
6273 if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){
@@ -6794,10 +6794,13 @@
6794 typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
6795 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
6796 #define MIN(a,b) ((a)<(b) ? (a) : (b))
6797
6798 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
6799 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
6800 #endif
6801 #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
6802 # define ALWAYS(X) (1)
6803 # define NEVER(X) (0)
6804 #elif !defined(NDEBUG)
6805 # define ALWAYS(X) ((X)?1:(assert(0),0))
6806 # define NEVER(X) ((X)?(assert(0),1):0)
@@ -9253,10 +9256,27 @@
9256 */
9257 /* #include "sqlite3expert.h" */
9258 #include <assert.h>
9259 #include <string.h>
9260 #include <stdio.h>
9261
9262 #if !defined(SQLITE_AMALGAMATION)
9263 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
9264 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
9265 #endif
9266 #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
9267 # define ALWAYS(X) (1)
9268 # define NEVER(X) (0)
9269 #elif !defined(NDEBUG)
9270 # define ALWAYS(X) ((X)?1:(assert(0),0))
9271 # define NEVER(X) ((X)?(assert(0),1):0)
9272 #else
9273 # define ALWAYS(X) (X)
9274 # define NEVER(X) (X)
9275 #endif
9276 #endif /* !defined(SQLITE_AMALGAMATION) */
9277
9278
9279 #ifndef SQLITE_OMIT_VIRTUALTABLE
9280
9281 /* typedef sqlite3_int64 i64; */
9282 /* typedef sqlite3_uint64 u64; */
@@ -9980,13 +10000,13 @@
10000 idxFinalize(&rc, p1);
10001
10002 if( rc!=SQLITE_OK ){
10003 sqlite3_free(pNew);
10004 pNew = 0;
10005 }else if( ALWAYS(pNew!=0) ){
10006 pNew->zName = pCsr;
10007 if( ALWAYS(pNew->zName!=0) ) memcpy(pNew->zName, zTab, nTab+1);
10008 }
10009
10010 *ppOut = pNew;
10011 return rc;
10012 }
10013
+231 -101
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -452,11 +452,11 @@
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455455
#define SQLITE_VERSION "3.37.0"
456456
#define SQLITE_VERSION_NUMBER 3037000
457
-#define SQLITE_SOURCE_ID "2021-10-04 11:10:15 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813"
457
+#define SQLITE_SOURCE_ID "2021-10-06 10:36:56 566e6974892ebd3d3de8d77b24655257a5efe14434c553e1a25fc680b201b336"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -13194,10 +13194,18 @@
1319413194
# define VVA_ONLY(X) X
1319513195
#else
1319613196
# define VVA_ONLY(X)
1319713197
#endif
1319813198
13199
+/*
13200
+** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage
13201
+** and mutation testing
13202
+*/
13203
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
13204
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
13205
+#endif
13206
+
1319913207
/*
1320013208
** The ALWAYS and NEVER macros surround boolean expressions which
1320113209
** are intended to always be true or false, respectively. Such
1320213210
** expressions could be omitted from the code completely. But they
1320313211
** are included in a few cases in order to enhance the resilience
@@ -13209,11 +13217,11 @@
1320913217
**
1321013218
** When doing coverage testing ALWAYS and NEVER are hard-coded to
1321113219
** be true and false so that the unreachable code they specify will
1321213220
** not be counted as untested code.
1321313221
*/
13214
-#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
13222
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
1321513223
# define ALWAYS(X) (1)
1321613224
# define NEVER(X) (0)
1321713225
#elif !defined(NDEBUG)
1321813226
# define ALWAYS(X) ((X)?1:(assert(0),0))
1321913227
# define NEVER(X) ((X)?(assert(0),1):0)
@@ -23573,11 +23581,11 @@
2357323581
2357423582
computeJD(&x);
2357523583
computeYMD_HMS(&x);
2357623584
for(i=j=0; zFmt[i]; i++){
2357723585
if( zFmt[i]!='%' ) continue;
23578
- if( j<i ) sqlite3_str_append(&sRes, zFmt+j, i-j);
23586
+ if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j));
2357923587
i++;
2358023588
j = i + 1;
2358123589
switch( zFmt[i] ){
2358223590
case 'd': {
2358323591
sqlite3_str_appendf(&sRes, "%02d", x.D);
@@ -23649,11 +23657,11 @@
2364923657
sqlite3_str_reset(&sRes);
2365023658
return;
2365123659
}
2365223660
}
2365323661
}
23654
- if( j<i ) sqlite3_str_append(&sRes, zFmt+j, i-j);
23662
+ if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j));
2365523663
sqlite3ResultStrAccum(context, &sRes);
2365623664
}
2365723665
2365823666
/*
2365923667
** current_time()
@@ -49576,11 +49584,11 @@
4957649584
/* NULL pBitvec tests */
4957749585
sqlite3BitvecSet(0, 1);
4957849586
sqlite3BitvecClear(0, 1, pTmpSpace);
4957949587
4958049588
/* Run the program */
49581
- pc = 0;
49589
+ pc = i = 0;
4958249590
while( (op = aOp[pc])!=0 ){
4958349591
switch( op ){
4958449592
case 1:
4958549593
case 2:
4958649594
case 5: {
@@ -55500,10 +55508,11 @@
5550055508
** routine which only updates the change-counter if the update is actually
5550155509
** needed, as determined by the pPager->changeCountDone state variable.
5550255510
*/
5550355511
static void pager_write_changecounter(PgHdr *pPg){
5550455512
u32 change_counter;
55513
+ if( NEVER(pPg==0) ) return;
5550555514
5550655515
/* Increment the value just read and write it back to byte 24. */
5550755516
change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;
5550855517
put32bits(((char*)pPg->pData)+24, change_counter);
5550955518
@@ -68477,11 +68486,10 @@
6847768486
static int lockBtree(BtShared *pBt){
6847868487
int rc; /* Result code from subfunctions */
6847968488
MemPage *pPage1; /* Page 1 of the database file */
6848068489
u32 nPage; /* Number of pages in the database */
6848168490
u32 nPageFile = 0; /* Number of pages in the database file */
68482
- u32 nPageHeader; /* Number of pages in the database according to hdr */
6848368491
6848468492
assert( sqlite3_mutex_held(pBt->mutex) );
6848568493
assert( pBt->pPage1==0 );
6848668494
rc = sqlite3PagerSharedLock(pBt->pPager);
6848768495
if( rc!=SQLITE_OK ) return rc;
@@ -68489,11 +68497,11 @@
6848968497
if( rc!=SQLITE_OK ) return rc;
6849068498
6849168499
/* Do some checking to help insure the file we opened really is
6849268500
** a valid database file.
6849368501
*/
68494
- nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
68502
+ nPage = get4byte(28+(u8*)pPage1->aData);
6849568503
sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);
6849668504
if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
6849768505
nPage = nPageFile;
6849868506
}
6849968507
if( (pBt->db->flags & SQLITE_ResetDatabase)!=0 ){
@@ -73069,15 +73077,14 @@
7306973077
Pgno pgno; /* Temp var to store a page number in */
7307073078
u8 abDone[NB+2]; /* True after i'th new page is populated */
7307173079
Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */
7307273080
Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */
7307373081
u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */
73074
- CellArray b; /* Parsed information on cells being balanced */
73082
+ CellArray b; /* Parsed information on cells being balanced */
7307573083
7307673084
memset(abDone, 0, sizeof(abDone));
73077
- b.nCell = 0;
73078
- b.apCell = 0;
73085
+ memset(&b, 0, sizeof(b));
7307973086
pBt = pParent->pBt;
7308073087
assert( sqlite3_mutex_held(pBt->mutex) );
7308173088
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
7308273089
7308373090
/* At this point pParent may have at most one overflow cell. And if
@@ -73884,11 +73891,11 @@
7388473891
7388573892
/*
7388673893
** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid
7388773894
** on the same B-tree as pCur.
7388873895
**
73889
-** This can if a database is corrupt with two or more SQL tables
73896
+** This can occur if a database is corrupt with two or more SQL tables
7389073897
** pointing to the same b-tree. If an insert occurs on one SQL table
7389173898
** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL
7389273899
** table linked to the same b-tree. If the secondary insert causes a
7389373900
** rebalance, that can change content out from under the cursor on the
7389473901
** first SQL table, violating invariants on the first insert.
@@ -77209,10 +77216,11 @@
7720977216
*/
7721077217
SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
7721177218
#ifndef SQLITE_OMIT_UTF16
7721277219
int rc;
7721377220
#endif
77221
+ assert( pMem!=0 );
7721477222
assert( !sqlite3VdbeMemIsRowSet(pMem) );
7721577223
assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE
7721677224
|| desiredEnc==SQLITE_UTF16BE );
7721777225
if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
7721877226
return SQLITE_OK;
@@ -77341,10 +77349,11 @@
7734177349
** MEM.zMalloc, where it can be safely written.
7734277350
**
7734377351
** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.
7734477352
*/
7734577353
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
77354
+ assert( pMem!=0 );
7734677355
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7734777356
assert( !sqlite3VdbeMemIsRowSet(pMem) );
7734877357
if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
7734977358
if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
7735077359
if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
@@ -77365,10 +77374,11 @@
7736577374
** blob stored in dynamically allocated space.
7736677375
*/
7736777376
#ifndef SQLITE_OMIT_INCRBLOB
7736877377
SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
7736977378
int nByte;
77379
+ assert( pMem!=0 );
7737077380
assert( pMem->flags & MEM_Zero );
7737177381
assert( (pMem->flags&MEM_Blob)!=0 || MemNullNochng(pMem) );
7737277382
testcase( sqlite3_value_nochange(pMem) );
7737377383
assert( !sqlite3VdbeMemIsRowSet(pMem) );
7737477384
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -77392,10 +77402,11 @@
7739277402
7739377403
/*
7739477404
** Make sure the given Mem is \u0000 terminated.
7739577405
*/
7739677406
SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
77407
+ assert( pMem!=0 );
7739777408
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7739877409
testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
7739977410
testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
7740077411
if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
7740177412
return SQLITE_OK; /* Nothing to do */
@@ -77419,10 +77430,11 @@
7741977430
** user and the latter is an internal programming error.
7742077431
*/
7742177432
SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
7742277433
const int nByte = 32;
7742377434
77435
+ assert( pMem!=0 );
7742477436
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7742577437
assert( !(pMem->flags&MEM_Zero) );
7742677438
assert( !(pMem->flags&(MEM_Str|MEM_Blob)) );
7742777439
assert( pMem->flags&(MEM_Int|MEM_Real|MEM_IntReal) );
7742877440
assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -77454,10 +77466,11 @@
7745477466
*/
7745577467
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
7745677468
sqlite3_context ctx;
7745777469
Mem t;
7745877470
assert( pFunc!=0 );
77471
+ assert( pMem!=0 );
7745977472
assert( pFunc->xFinalize!=0 );
7746077473
assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
7746177474
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7746277475
memset(&ctx, 0, sizeof(ctx));
7746377476
memset(&t, 0, sizeof(t));
@@ -77604,10 +77617,11 @@
7760477617
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
7760577618
return value;
7760677619
}
7760777620
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
7760877621
int flags;
77622
+ assert( pMem!=0 );
7760977623
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7761077624
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
7761177625
flags = pMem->flags;
7761277626
if( flags & (MEM_Int|MEM_IntReal) ){
7761377627
testcase( flags & MEM_IntReal );
@@ -77632,10 +77646,11 @@
7763277646
double val = (double)0;
7763377647
sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
7763477648
return val;
7763577649
}
7763677650
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
77651
+ assert( pMem!=0 );
7763777652
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7763877653
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
7763977654
if( pMem->flags & MEM_Real ){
7764077655
return pMem->u.r;
7764177656
}else if( pMem->flags & (MEM_Int|MEM_IntReal) ){
@@ -77664,10 +77679,11 @@
7766477679
** The MEM structure is already a MEM_Real. Try to also make it a
7766577680
** MEM_Int if we can.
7766677681
*/
7766777682
SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
7766877683
i64 ix;
77684
+ assert( pMem!=0 );
7766977685
assert( pMem->flags & MEM_Real );
7767077686
assert( !sqlite3VdbeMemIsRowSet(pMem) );
7767177687
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7767277688
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
7767377689
@@ -77691,10 +77707,11 @@
7769177707
7769277708
/*
7769377709
** Convert pMem to type integer. Invalidate any prior representations.
7769477710
*/
7769577711
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
77712
+ assert( pMem!=0 );
7769677713
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7769777714
assert( !sqlite3VdbeMemIsRowSet(pMem) );
7769877715
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
7769977716
7770077717
pMem->u.i = sqlite3VdbeIntValue(pMem);
@@ -77705,10 +77722,11 @@
7770577722
/*
7770677723
** Convert pMem so that it is of type MEM_Real.
7770777724
** Invalidate any prior representations.
7770877725
*/
7770977726
SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
77727
+ assert( pMem!=0 );
7771077728
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7771177729
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
7771277730
7771377731
pMem->u.r = sqlite3VdbeRealValue(pMem);
7771477732
MemSetTypeFlag(pMem, MEM_Real);
@@ -77738,10 +77756,11 @@
7773877756
** Every effort is made to force the conversion, even if the input
7773977757
** is a string that does not look completely like a number. Convert
7774077758
** as much of the string as we can and ignore the rest.
7774177759
*/
7774277760
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
77761
+ assert( pMem!=0 );
7774377762
testcase( pMem->flags & MEM_Int );
7774477763
testcase( pMem->flags & MEM_Real );
7774577764
testcase( pMem->flags & MEM_IntReal );
7774677765
testcase( pMem->flags & MEM_Null );
7774777766
if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){
@@ -78089,10 +78108,11 @@
7808978108
){
7809078109
i64 nByte = n; /* New value for pMem->n */
7809178110
int iLimit; /* Maximum allowed string or blob size */
7809278111
u16 flags = 0; /* New value for pMem->flags */
7809378112
78113
+ assert( pMem!=0 );
7809478114
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7809578115
assert( !sqlite3VdbeMemIsRowSet(pMem) );
7809678116
7809778117
/* If z is a NULL pointer, set pMem to contain an SQL NULL. */
7809878118
if( !z ){
@@ -79162,12 +79182,14 @@
7916279182
assert( p->iVdbeMagic==VDBE_MAGIC_INIT );
7916379183
assert( op>=0 && op<0xff );
7916479184
if( p->nOpAlloc<=i ){
7916579185
return growOp3(p, op, p1, p2, p3);
7916679186
}
79187
+ assert( p->aOp!=0 );
7916779188
p->nOp++;
7916879189
pOp = &p->aOp[i];
79190
+ assert( pOp!=0 );
7916979191
pOp->opcode = (u8)op;
7917079192
pOp->p5 = 0;
7917179193
pOp->p1 = p1;
7917279194
pOp->p2 = p2;
7917379195
pOp->p3 = p3;
@@ -80406,11 +80428,11 @@
8040680428
zOpName = sqlite3OpcodeName(pOp->opcode);
8040780429
nOpName = sqlite3Strlen30(zOpName);
8040880430
if( zOpName[nOpName+1] ){
8040980431
int seenCom = 0;
8041080432
char c;
80411
- zSynopsis = zOpName += nOpName + 1;
80433
+ zSynopsis = zOpName + nOpName + 1;
8041280434
if( strncmp(zSynopsis,"IF ",3)==0 ){
8041380435
sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3);
8041480436
zSynopsis = zAlt;
8041580437
}
8041680438
for(ii=0; (c = zSynopsis[ii])!=0; ii++){
@@ -91677,11 +91699,11 @@
9167791699
zDb = db->aDb[pC->iDb].zDbSName;
9167891700
pTab = pOp->p4.pTab;
9167991701
assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) );
9168091702
}else{
9168191703
pTab = 0;
91682
- zDb = 0; /* Not needed. Silence a compiler warning. */
91704
+ zDb = 0;
9168391705
}
9168491706
9168591707
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
9168691708
/* Invoke the pre-update hook, if any */
9168791709
if( pTab ){
@@ -91830,17 +91852,18 @@
9183091852
pTab = pOp->p4.pTab;
9183191853
if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
9183291854
pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
9183391855
}
9183491856
}else{
91835
- zDb = 0; /* Not needed. Silence a compiler warning. */
91836
- pTab = 0; /* Not needed. Silence a compiler warning. */
91857
+ zDb = 0;
91858
+ pTab = 0;
9183791859
}
9183891860
9183991861
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
9184091862
/* Invoke the pre-update-hook if required. */
91841
- if( db->xPreUpdateCallback && pOp->p4.pTab ){
91863
+ assert( db->xPreUpdateCallback==0 || pTab==pOp->p4.pTab );
91864
+ if( db->xPreUpdateCallback && pTab ){
9184291865
assert( !(opflags & OPFLAG_ISUPDATE)
9184391866
|| HasRowid(pTab)==0
9184491867
|| (aMem[pOp->p3].flags & MEM_Int)
9184591868
);
9184691869
sqlite3VdbePreUpdateHook(p, pC,
@@ -91877,11 +91900,11 @@
9187791900
if( rc ) goto abort_due_to_error;
9187891901
9187991902
/* Invoke the update-hook if required. */
9188091903
if( opflags & OPFLAG_NCHANGE ){
9188191904
p->nChange++;
91882
- if( db->xUpdateCallback && HasRowid(pTab) ){
91905
+ if( db->xUpdateCallback && ALWAYS(pTab!=0) && HasRowid(pTab) ){
9188391906
db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,
9188491907
pC->movetoTarget);
9188591908
assert( pC->iDb>=0 );
9188691909
}
9188791910
}
@@ -103680,13 +103703,13 @@
103680103703
case TK_UPLUS: {
103681103704
rc = sqlite3ExprIsInteger(p->pLeft, pValue);
103682103705
break;
103683103706
}
103684103707
case TK_UMINUS: {
103685
- int v;
103708
+ int v = 0;
103686103709
if( sqlite3ExprIsInteger(p->pLeft, &v) ){
103687
- assert( v!=(-2147483647-1) );
103710
+ assert( ((unsigned int)v)!=0x80000000 );
103688103711
*pValue = -v;
103689103712
rc = 1;
103690103713
}
103691103714
break;
103692103715
}
@@ -105692,11 +105715,11 @@
105692105715
if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
105693105716
if( !pColl ) pColl = db->pDfltColl;
105694105717
sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
105695105718
}
105696105719
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
105697
- if( pDef->funcFlags & SQLITE_FUNC_OFFSET ){
105720
+ if( (pDef->funcFlags & SQLITE_FUNC_OFFSET)!=0 && ALWAYS(pFarg!=0) ){
105698105721
Expr *pArg = pFarg->a[0].pExpr;
105699105722
if( pArg->op==TK_COLUMN ){
105700105723
sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target);
105701105724
}else{
105702105725
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
@@ -112049,13 +112072,13 @@
112049112072
if( pParse->nErr ) goto attach_end;
112050112073
memset(&sName, 0, sizeof(NameContext));
112051112074
sName.pParse = pParse;
112052112075
112053112076
if(
112054
- SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
112055
- SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
112056
- SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
112077
+ SQLITE_OK!=resolveAttachExpr(&sName, pFilename) ||
112078
+ SQLITE_OK!=resolveAttachExpr(&sName, pDbname) ||
112079
+ SQLITE_OK!=resolveAttachExpr(&sName, pKey)
112057112080
){
112058112081
goto attach_end;
112059112082
}
112060112083
112061112084
#ifndef SQLITE_OMIT_AUTHORIZATION
@@ -128871,11 +128894,11 @@
128871128894
/* iArg: */ 0 },
128872128895
{/* zName: */ "table_list",
128873128896
/* ePragTyp: */ PragTyp_TABLE_LIST,
128874128897
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
128875128898
/* ColNames: */ 15, 6,
128876
- /* iArg: */ 1 },
128899
+ /* iArg: */ 0 },
128877128900
{/* zName: */ "table_xinfo",
128878128901
/* ePragTyp: */ PragTyp_TABLE_INFO,
128879128902
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
128880128903
/* ColNames: */ 8, 7,
128881128904
/* iArg: */ 1 },
@@ -134994,11 +135017,11 @@
134994135017
** function is responsible for ensuring that this structure is eventually
134995135018
** freed.
134996135019
*/
134997135020
static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
134998135021
ExprList *pOrderBy = p->pOrderBy;
134999
- int nOrderBy = p->pOrderBy->nExpr;
135022
+ int nOrderBy = ALWAYS(pOrderBy!=0) ? pOrderBy->nExpr : 0;
135000135023
sqlite3 *db = pParse->db;
135001135024
KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);
135002135025
if( pRet ){
135003135026
int i;
135004135027
for(i=0; i<nOrderBy; i++){
@@ -135615,10 +135638,11 @@
135615135638
Select *pLoop; /* For looping through SELECT statements */
135616135639
CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
135617135640
int nCol; /* Number of columns in result set */
135618135641
135619135642
assert( p->pNext==0 );
135643
+ assert( p->pEList!=0 );
135620135644
nCol = p->pEList->nExpr;
135621135645
pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1);
135622135646
if( !pKeyInfo ){
135623135647
rc = SQLITE_NOMEM_BKPT;
135624135648
goto multi_select_end;
@@ -135966,10 +135990,11 @@
135966135990
*/
135967135991
if( op!=TK_ALL ){
135968135992
for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){
135969135993
struct ExprList_item *pItem;
135970135994
for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){
135995
+ assert( pItem!=0 );
135971135996
assert( pItem->u.x.iOrderByCol>0 );
135972135997
if( pItem->u.x.iOrderByCol==i ) break;
135973135998
}
135974135999
if( j==nOrderBy ){
135975136000
Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
@@ -135992,10 +136017,11 @@
135992136017
aPermute = sqlite3DbMallocRawNN(db, sizeof(u32)*(nOrderBy + 1));
135993136018
if( aPermute ){
135994136019
struct ExprList_item *pItem;
135995136020
aPermute[0] = nOrderBy;
135996136021
for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){
136022
+ assert( pItem!=0 );
135997136023
assert( pItem->u.x.iOrderByCol>0 );
135998136024
assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );
135999136025
aPermute[i] = pItem->u.x.iOrderByCol - 1;
136000136026
}
136001136027
pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
@@ -146974,11 +147000,11 @@
146974147000
x.pWInfo = pWInfo;
146975147001
x.db = pWInfo->pParse->db;
146976147002
for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
146977147003
i16 iRef = pIdx->aiColumn[iIdxCol];
146978147004
if( iRef==XN_EXPR ){
146979
- assert( aColExpr->a[iIdxCol].pExpr!=0 );
147005
+ assert( aColExpr!=0 && aColExpr->a[iIdxCol].pExpr!=0 );
146980147006
x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
146981147007
if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue;
146982147008
w.xExprCallback = whereIndexExprTransNode;
146983147009
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
146984147010
}else if( iRef>=0
@@ -150214,11 +150240,12 @@
150214150240
if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
150215150241
continue;
150216150242
}
150217150243
}
150218150244
if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0
150219
- && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN
150245
+ && (pX = pTerm->pExpr->pRight, ALWAYS(pX!=0))
150246
+ && pX->op==TK_COLUMN
150220150247
&& pX->iTable==pScan->aiCur[0]
150221150248
&& pX->iColumn==pScan->aiColumn[0]
150222150249
){
150223150250
testcase( pTerm->eOperator & WO_IS );
150224150251
continue;
@@ -153969,11 +153996,11 @@
153969153996
}
153970153997
} /* End the loop over all WhereLoops from outer-most down to inner-most */
153971153998
if( obSat==obDone ) return (i8)nOrderBy;
153972153999
if( !isOrderDistinct ){
153973154000
for(i=nOrderBy-1; i>0; i--){
153974
- Bitmask m = MASKBIT(i) - 1;
154001
+ Bitmask m = ALWAYS(i<BMS) ? MASKBIT(i) - 1 : 0;
153975154002
if( (obSat&m)==m ) return i;
153976154003
}
153977154004
return 0;
153978154005
}
153979154006
return -1;
@@ -154494,13 +154521,13 @@
154494154521
pWC = &pWInfo->sWC;
154495154522
pLoop = pBuilder->pNew;
154496154523
pLoop->wsFlags = 0;
154497154524
pLoop->nSkip = 0;
154498154525
pTerm = whereScanInit(&scan, pWC, iCur, -1, WO_EQ|WO_IS, 0);
154526
+ while( pTerm && pTerm->prereqRight ) pTerm = whereScanNext(&scan);
154499154527
if( pTerm ){
154500154528
testcase( pTerm->eOperator & WO_IS );
154501
- assert( pTerm->prereqRight==0 );
154502154529
pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
154503154530
pLoop->aLTerm[0] = pTerm;
154504154531
pLoop->nLTerm = 1;
154505154532
pLoop->u.btree.nEq = 1;
154506154533
/* TUNING: Cost of a rowid lookup is 10 */
@@ -167620,21 +167647,20 @@
167620167647
void (*xValue)(sqlite3_context*),
167621167648
void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
167622167649
FuncDestructor *pDestructor
167623167650
){
167624167651
FuncDef *p;
167625
- int nName;
167626167652
int extraFlags;
167627167653
167628167654
assert( sqlite3_mutex_held(db->mutex) );
167629167655
assert( xValue==0 || xSFunc==0 );
167630167656
if( zFunctionName==0 /* Must have a valid name */
167631167657
|| (xSFunc!=0 && xFinal!=0) /* Not both xSFunc and xFinal */
167632167658
|| ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */
167633167659
|| ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */
167634167660
|| (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)
167635
- || (255<(nName = sqlite3Strlen30( zFunctionName)))
167661
+ || (255<sqlite3Strlen30(zFunctionName))
167636167662
){
167637167663
return SQLITE_MISUSE_BKPT;
167638167664
}
167639167665
167640167666
assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
@@ -168897,11 +168923,11 @@
168897168923
** This routine does the core work of extracting URI parameters from a
168898168924
** database filename for the sqlite3_uri_parameter() interface.
168899168925
*/
168900168926
static const char *uriParameter(const char *zFilename, const char *zParam){
168901168927
zFilename += sqlite3Strlen30(zFilename) + 1;
168902
- while( zFilename[0] ){
168928
+ while( ALWAYS(zFilename!=0) && zFilename[0] ){
168903168929
int x = strcmp(zFilename, zParam);
168904168930
zFilename += sqlite3Strlen30(zFilename) + 1;
168905168931
if( x==0 ) return zFilename;
168906168932
zFilename += sqlite3Strlen30(zFilename) + 1;
168907168933
}
@@ -170245,11 +170271,11 @@
170245170271
*/
170246170272
SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){
170247170273
if( zFilename==0 || N<0 ) return 0;
170248170274
zFilename = databaseName(zFilename);
170249170275
zFilename += sqlite3Strlen30(zFilename) + 1;
170250
- while( zFilename[0] && (N--)>0 ){
170276
+ while( ALWAYS(zFilename) && zFilename[0] && (N--)>0 ){
170251170277
zFilename += sqlite3Strlen30(zFilename) + 1;
170252170278
zFilename += sqlite3Strlen30(zFilename) + 1;
170253170279
}
170254170280
return zFilename[0] ? zFilename : 0;
170255170281
}
@@ -170295,11 +170321,11 @@
170295170321
}
170296170322
SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){
170297170323
if( zFilename==0 ) return 0;
170298170324
zFilename = databaseName(zFilename);
170299170325
zFilename += sqlite3Strlen30(zFilename) + 1;
170300
- while( zFilename[0] ){
170326
+ while( ALWAYS(zFilename) && zFilename[0] ){
170301170327
zFilename += sqlite3Strlen30(zFilename) + 1;
170302170328
zFilename += sqlite3Strlen30(zFilename) + 1;
170303170329
}
170304170330
return zFilename + 1;
170305170331
}
@@ -171599,21 +171625,22 @@
171599171625
#ifndef SQLITE_AMALGAMATION
171600171626
/*
171601171627
** Macros indicating that conditional expressions are always true or
171602171628
** false.
171603171629
*/
171604
-#ifdef SQLITE_COVERAGE_TEST
171605
-# define ALWAYS(x) (1)
171606
-# define NEVER(X) (0)
171607
-#elif defined(SQLITE_DEBUG)
171608
-# define ALWAYS(x) sqlite3Fts3Always((x)!=0)
171609
-# define NEVER(x) sqlite3Fts3Never((x)!=0)
171610
-SQLITE_PRIVATE int sqlite3Fts3Always(int b);
171611
-SQLITE_PRIVATE int sqlite3Fts3Never(int b);
171630
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
171631
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
171632
+#endif
171633
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
171634
+# define ALWAYS(X) (1)
171635
+# define NEVER(X) (0)
171636
+#elif !defined(NDEBUG)
171637
+# define ALWAYS(X) ((X)?1:(assert(0),0))
171638
+# define NEVER(X) ((X)?(assert(0),1):0)
171612171639
#else
171613
-# define ALWAYS(x) (x)
171614
-# define NEVER(x) (x)
171640
+# define ALWAYS(X) (X)
171641
+# define NEVER(X) (X)
171615171642
#endif
171616171643
171617171644
/*
171618171645
** Internal types used by SQLite.
171619171646
*/
@@ -172125,17 +172152,10 @@
172125172152
static int fts3EvalNext(Fts3Cursor *pCsr);
172126172153
static int fts3EvalStart(Fts3Cursor *pCsr);
172127172154
static int fts3TermSegReaderCursor(
172128172155
Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
172129172156
172130
-#ifndef SQLITE_AMALGAMATION
172131
-# if defined(SQLITE_DEBUG)
172132
-SQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; }
172133
-SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; }
172134
-# endif
172135
-#endif
172136
-
172137172157
/*
172138172158
** This variable is set to false when running tests for which the on disk
172139172159
** structures should not be corrupt. Otherwise, true. If it is false, extra
172140172160
** assert() conditions in the fts3 code are activated - conditions that are
172141172161
** only true if it is guaranteed that the fts3 database is not corrupt.
@@ -185824,11 +185844,11 @@
185824185844
185825185845
if( nPrefix>p->term.n || nSuffix>p->nNode-p->iOff || nSuffix==0 ){
185826185846
return FTS_CORRUPT_VTAB;
185827185847
}
185828185848
blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
185829
- if( rc==SQLITE_OK ){
185849
+ if( rc==SQLITE_OK && ALWAYS(p->term.a!=0) ){
185830185850
memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
185831185851
p->term.n = nPrefix+nSuffix;
185832185852
p->iOff += nSuffix;
185833185853
if( p->iChild==0 ){
185834185854
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
@@ -186218,11 +186238,15 @@
186218186238
const char *zRhs, int nRhs /* RHS of comparison */
186219186239
){
186220186240
int nCmp = MIN(nLhs, nRhs);
186221186241
int res;
186222186242
186223
- res = (nCmp ? memcmp(zLhs, zRhs, nCmp) : 0);
186243
+ if( nCmp && ALWAYS(zLhs) && ALWAYS(zRhs) ){
186244
+ res = memcmp(zLhs, zRhs, nCmp);
186245
+ }else{
186246
+ res = 0;
186247
+ }
186224186248
if( res==0 ) res = nLhs - nRhs;
186225186249
186226186250
return res;
186227186251
}
186228186252
@@ -186862,11 +186886,11 @@
186862186886
const char *aHint = sqlite3_column_blob(pSelect, 0);
186863186887
int nHint = sqlite3_column_bytes(pSelect, 0);
186864186888
if( aHint ){
186865186889
blobGrowBuffer(pHint, nHint, &rc);
186866186890
if( rc==SQLITE_OK ){
186867
- memcpy(pHint->a, aHint, nHint);
186891
+ if( ALWAYS(pHint->a!=0) ) memcpy(pHint->a, aHint, nHint);
186868186892
pHint->n = nHint;
186869186893
}
186870186894
}
186871186895
}
186872186896
rc2 = sqlite3_reset(pSelect);
@@ -188953,14 +188977,16 @@
188953188977
** Advance the iterator passed as an argument to the next position. Return
188954188978
** 1 if the iterator is at EOF or if it now points to the start of the
188955188979
** position list for the next column.
188956188980
*/
188957188981
static int fts3LcsIteratorAdvance(LcsIterator *pIter){
188958
- char *pRead = pIter->pRead;
188982
+ char *pRead;
188959188983
sqlite3_int64 iRead;
188960188984
int rc = 0;
188961188985
188986
+ if( NEVER(pIter==0) ) return 1;
188987
+ pRead = pIter->pRead;
188962188988
pRead += sqlite3Fts3GetVarint(pRead, &iRead);
188963188989
if( iRead==0 || iRead==1 ){
188964188990
pRead = 0;
188965188991
rc = 1;
188966188992
}else{
@@ -190478,10 +190504,23 @@
190478190504
** but the definitions need to be repeated for separate compilation. */
190479190505
typedef sqlite3_uint64 u64;
190480190506
typedef unsigned int u32;
190481190507
typedef unsigned short int u16;
190482190508
typedef unsigned char u8;
190509
+# if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
190510
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
190511
+# endif
190512
+# if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
190513
+# define ALWAYS(X) (1)
190514
+# define NEVER(X) (0)
190515
+# elif !defined(NDEBUG)
190516
+# define ALWAYS(X) ((X)?1:(assert(0),0))
190517
+# define NEVER(X) ((X)?(assert(0),1):0)
190518
+# else
190519
+# define ALWAYS(X) (X)
190520
+# define NEVER(X) (X)
190521
+# endif
190483190522
#endif
190484190523
190485190524
/* Objects */
190486190525
typedef struct JsonString JsonString;
190487190526
typedef struct JsonNode JsonNode;
@@ -190820,12 +190859,13 @@
190820190859
static void jsonRenderNode(
190821190860
JsonNode *pNode, /* The node to render */
190822190861
JsonString *pOut, /* Write JSON here */
190823190862
sqlite3_value **aReplace /* Replacement values */
190824190863
){
190864
+ assert( pNode!=0 );
190825190865
if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){
190826
- if( pNode->jnFlags & JNODE_REPLACE ){
190866
+ if( (pNode->jnFlags & JNODE_REPLACE)!=0 && ALWAYS(aReplace!=0) ){
190827190867
jsonAppendValue(pOut, aReplace[pNode->u.iReplace]);
190828190868
return;
190829190869
}
190830190870
pNode = pNode->u.pPatch;
190831190871
}
@@ -191141,11 +191181,11 @@
191141191181
u32 eType, /* Node type */
191142191182
u32 n, /* Content size or sub-node count */
191143191183
const char *zContent /* Content */
191144191184
){
191145191185
JsonNode *p;
191146
- if( pParse->nNode>=pParse->nAlloc ){
191186
+ if( pParse->aNode==0 || pParse->nNode>=pParse->nAlloc ){
191147191187
return jsonParseAddNodeExpand(pParse, eType, n, zContent);
191148191188
}
191149191189
p = &pParse->aNode[pParse->nNode];
191150191190
p->eType = (u8)eType;
191151191191
p->jnFlags = 0;
@@ -193099,10 +193139,13 @@
193099193139
#endif
193100193140
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
193101193141
# undef NDEBUG
193102193142
#endif
193103193143
#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
193144
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
193145
+#endif
193146
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
193104193147
# define ALWAYS(X) (1)
193105193148
# define NEVER(X) (0)
193106193149
#elif !defined(NDEBUG)
193107193150
# define ALWAYS(X) ((X)?1:(assert(0),0))
193108193151
# define NEVER(X) ((X)?(assert(0),1):0)
@@ -193450,11 +193493,16 @@
193450193493
193451193494
/* The testcase() macro should already be defined in the amalgamation. If
193452193495
** it is not, make it a no-op.
193453193496
*/
193454193497
#ifndef SQLITE_AMALGAMATION
193455
-# define testcase(X)
193498
+# ifdef SQLITE_COVERAGE_TEST
193499
+ unsigned int sqlite3RtreeTestcase = 0;
193500
+# define testcase(X) if( X ){ sqlite3RtreeTestcase += __LINE__; }
193501
+# else
193502
+# define testcase(X)
193503
+# endif
193456193504
#endif
193457193505
193458193506
/*
193459193507
** Make sure that the compiler intrinsics we desire are enabled when
193460193508
** compiling with an appropriate version of MSVC unless prevented by
@@ -195214,11 +195262,11 @@
195214195262
RtreeDValue fMinGrowth = RTREE_ZERO;
195215195263
RtreeDValue fMinArea = RTREE_ZERO;
195216195264
195217195265
int nCell = NCELL(pNode);
195218195266
RtreeCell cell;
195219
- RtreeNode *pChild;
195267
+ RtreeNode *pChild = 0;
195220195268
195221195269
RtreeCell *aCell = 0;
195222195270
195223195271
/* Select the child node which will be enlarged the least if pCell
195224195272
** is inserted into it. Resolve ties by choosing the entry with
@@ -195572,10 +195620,11 @@
195572195620
nodeRelease(pRtree, pChild->pParent);
195573195621
nodeReference(pNode);
195574195622
pChild->pParent = pNode;
195575195623
}
195576195624
}
195625
+ if( NEVER(pNode==0) ) return SQLITE_ERROR;
195577195626
return xSetMapping(pRtree, iRowid, pNode->iNode);
195578195627
}
195579195628
195580195629
static int SplitNode(
195581195630
Rtree *pRtree,
@@ -196876,10 +196925,11 @@
196876196925
tree.nDim = (u8)sqlite3_value_int(apArg[0]);
196877196926
if( tree.nDim<1 || tree.nDim>5 ) return;
196878196927
tree.nDim2 = tree.nDim*2;
196879196928
tree.nBytesPerCell = 8 + 8 * tree.nDim;
196880196929
node.zData = (u8 *)sqlite3_value_blob(apArg[1]);
196930
+ if( node.zData==0 ) return;
196881196931
nData = sqlite3_value_bytes(apArg[1]);
196882196932
if( nData<4 ) return;
196883196933
if( nData<NCELL(&node)*tree.nBytesPerCell ) return;
196884196934
196885196935
pOut = sqlite3_str_new(0);
@@ -197707,17 +197757,18 @@
197707197757
sqlite3_value *pVal, /* The value to decode */
197708197758
int *pRc /* Write error here */
197709197759
){
197710197760
GeoPoly *p = 0;
197711197761
int nByte;
197762
+ testcase( pCtx==0 );
197712197763
if( sqlite3_value_type(pVal)==SQLITE_BLOB
197713197764
&& (nByte = sqlite3_value_bytes(pVal))>=(4+6*sizeof(GeoCoord))
197714197765
){
197715197766
const unsigned char *a = sqlite3_value_blob(pVal);
197716197767
int nVertex;
197717197768
if( a==0 ){
197718
- sqlite3_result_error_nomem(pCtx);
197769
+ if( pCtx ) sqlite3_result_error_nomem(pCtx);
197719197770
return 0;
197720197771
}
197721197772
nVertex = (a[1]<<16) + (a[2]<<8) + a[3];
197722197773
if( (a[0]==0 || a[0]==1)
197723197774
&& (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte
@@ -198540,15 +198591,15 @@
198540198591
pActive = pSeg;
198541198592
needSort = 1;
198542198593
}else{
198543198594
/* Remove a segment */
198544198595
if( pActive==pThisEvent->pSeg ){
198545
- pActive = pActive->pNext;
198596
+ pActive = ALWAYS(pActive) ? pActive->pNext : 0;
198546198597
}else{
198547198598
for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){
198548198599
if( pSeg->pNext==pThisEvent->pSeg ){
198549
- pSeg->pNext = pSeg->pNext->pNext;
198600
+ pSeg->pNext = ALWAYS(pSeg->pNext) ? pSeg->pNext->pNext : 0;
198550198601
break;
198551198602
}
198552198603
}
198553198604
}
198554198605
}
@@ -198788,10 +198839,11 @@
198788198839
rc = nodeAcquire(pRtree, 1, 0, &pRoot);
198789198840
if( rc==SQLITE_OK && idxNum<=3 ){
198790198841
RtreeCoord bbox[4];
198791198842
RtreeConstraint *p;
198792198843
assert( argc==1 );
198844
+ assert( argv[0]!=0 );
198793198845
geopolyBBox(0, argv[0], bbox, &rc);
198794198846
if( rc ){
198795198847
goto geopoly_filter_end;
198796198848
}
198797198849
pCsr->aConstraint = p = sqlite3_malloc(sizeof(RtreeConstraint)*4);
@@ -199015,10 +199067,11 @@
199015199067
if( nData>1 /* not a DELETE */
199016199068
&& (!oldRowidValid /* INSERT */
199017199069
|| !sqlite3_value_nochange(aData[2]) /* UPDATE _shape */
199018199070
|| oldRowid!=newRowid) /* Rowid change */
199019199071
){
199072
+ assert( aData[2]!=0 );
199020199073
geopolyBBox(0, aData[2], cell.aCoord, &rc);
199021199074
if( rc ){
199022199075
if( rc==SQLITE_ERROR ){
199023199076
pVtab->zErrMsg =
199024199077
sqlite3_mprintf("_shape does not contain a valid polygon");
@@ -207873,11 +207926,11 @@
207873207926
if( z==0 && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;
207874207927
nVarint = sessionVarintLen(n);
207875207928
207876207929
if( aBuf ){
207877207930
sessionVarintPut(&aBuf[1], n);
207878
- if( n ) memcpy(&aBuf[nVarint + 1], z, n);
207931
+ if( n>0 ) memcpy(&aBuf[nVarint + 1], z, n);
207879207932
}
207880207933
207881207934
nByte = 1 + nVarint + n;
207882207935
break;
207883207936
}
@@ -208478,20 +208531,36 @@
208478208531
"SELECT 2, 'stat', '', 0, '', 0"
208479208532
);
208480208533
}else if( rc==SQLITE_ERROR ){
208481208534
zPragma = sqlite3_mprintf("");
208482208535
}else{
208536
+ *pazCol = 0;
208537
+ *pabPK = 0;
208538
+ *pnCol = 0;
208539
+ if( pzTab ) *pzTab = 0;
208483208540
return rc;
208484208541
}
208485208542
}else{
208486208543
zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
208487208544
}
208488
- if( !zPragma ) return SQLITE_NOMEM;
208545
+ if( !zPragma ){
208546
+ *pazCol = 0;
208547
+ *pabPK = 0;
208548
+ *pnCol = 0;
208549
+ if( pzTab ) *pzTab = 0;
208550
+ return SQLITE_NOMEM;
208551
+ }
208489208552
208490208553
rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);
208491208554
sqlite3_free(zPragma);
208492
- if( rc!=SQLITE_OK ) return rc;
208555
+ if( rc!=SQLITE_OK ){
208556
+ *pazCol = 0;
208557
+ *pabPK = 0;
208558
+ *pnCol = 0;
208559
+ if( pzTab ) *pzTab = 0;
208560
+ return rc;
208561
+ }
208493208562
208494208563
nByte = nThis + 1;
208495208564
while( SQLITE_ROW==sqlite3_step(pStmt) ){
208496208565
nByte += sqlite3_column_bytes(pStmt, 1);
208497208566
nDbCol++;
@@ -208905,11 +208974,15 @@
208905208974
if( pSession->xTableFilter==0
208906208975
|| pSession->xTableFilter(pSession->pFilterCtx, zName)
208907208976
){
208908208977
rc = sqlite3session_attach(pSession, zName);
208909208978
if( rc==SQLITE_OK ){
208910
- for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext);
208979
+ pRet = pSession->pTable;
208980
+ while( ALWAYS(pRet) && pRet->pNext ){
208981
+ pRet = pRet->pNext;
208982
+ }
208983
+ assert( pRet!=0 );
208911208984
assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );
208912208985
}
208913208986
}
208914208987
}
208915208988
@@ -209678,10 +209751,11 @@
209678209751
int bNoop = 1; /* Set to zero if any values are modified */
209679209752
int nRewind = pBuf->nBuf; /* Set to zero if any values are modified */
209680209753
int i; /* Used to iterate through columns */
209681209754
u8 *pCsr = p->aRecord; /* Used to iterate through old.* values */
209682209755
209756
+ assert( abPK!=0 );
209683209757
sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);
209684209758
sessionAppendByte(pBuf, p->bIndirect, &rc);
209685209759
for(i=0; i<sqlite3_column_count(pStmt); i++){
209686209760
int bChanged = 0;
209687209761
int nAdvance;
@@ -209982,16 +210056,18 @@
209982210056
sqlite3 *db = pSession->db; /* Source database handle */
209983210057
SessionTable *pTab; /* Used to iterate through attached tables */
209984210058
SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */
209985210059
int rc; /* Return code */
209986210060
209987
- assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) );
210061
+ assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0) );
210062
+ assert( xOutput!=0 || (pnChangeset!=0 && ppChangeset!=0) );
209988210063
209989210064
/* Zero the output variables in case an error occurs. If this session
209990210065
** object is already in the error state (sqlite3_session.rc != SQLITE_OK),
209991210066
** this call will be a no-op. */
209992210067
if( xOutput==0 ){
210068
+ assert( pnChangeset!=0 && ppChangeset!=0 );
209993210069
*pnChangeset = 0;
209994210070
*ppChangeset = 0;
209995210071
}
209996210072
209997210073
if( pSession->rc ) return pSession->rc;
@@ -210001,12 +210077,12 @@
210001210077
sqlite3_mutex_enter(sqlite3_db_mutex(db));
210002210078
210003210079
for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
210004210080
if( pTab->nEntry ){
210005210081
const char *zName = pTab->zName;
210006
- int nCol; /* Number of columns in table */
210007
- u8 *abPK; /* Primary key array */
210082
+ int nCol = 0; /* Number of columns in table */
210083
+ u8 *abPK = 0; /* Primary key array */
210008210084
const char **azCol = 0; /* Table columns */
210009210085
int i; /* Used to iterate through hash buckets */
210010210086
sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
210011210087
int nRewind = buf.nBuf; /* Initial size of write buffer */
210012210088
int nNoop; /* Size of buffer after writing tbl header */
@@ -210040,10 +210116,11 @@
210040210116
sessionAppendByte(&buf, p->bIndirect, &rc);
210041210117
for(iCol=0; iCol<nCol; iCol++){
210042210118
sessionAppendCol(&buf, pSel, iCol, &rc);
210043210119
}
210044210120
}else{
210121
+ assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */
210045210122
rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);
210046210123
}
210047210124
}else if( p->op!=SQLITE_INSERT ){
210048210125
rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);
210049210126
}
@@ -210100,11 +210177,14 @@
210100210177
SQLITE_API int sqlite3session_changeset(
210101210178
sqlite3_session *pSession, /* Session object */
210102210179
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
210103210180
void **ppChangeset /* OUT: Buffer containing changeset */
210104210181
){
210105
- int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
210182
+ int rc;
210183
+
210184
+ if( pnChangeset==0 || ppChangeset==0 ) return SQLITE_MISUSE;
210185
+ rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
210106210186
assert( rc || pnChangeset==0
210107210187
|| pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
210108210188
);
210109210189
return rc;
210110210190
}
@@ -210115,10 +210195,11 @@
210115210195
SQLITE_API int sqlite3session_changeset_strm(
210116210196
sqlite3_session *pSession,
210117210197
int (*xOutput)(void *pOut, const void *pData, int nData),
210118210198
void *pOut
210119210199
){
210200
+ if( xOutput==0 ) return SQLITE_MISUSE;
210120210201
return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);
210121210202
}
210122210203
210123210204
/*
210124210205
** Streaming version of sqlite3session_patchset().
@@ -210126,10 +210207,11 @@
210126210207
SQLITE_API int sqlite3session_patchset_strm(
210127210208
sqlite3_session *pSession,
210128210209
int (*xOutput)(void *pOut, const void *pData, int nData),
210129210210
void *pOut
210130210211
){
210212
+ if( xOutput==0 ) return SQLITE_MISUSE;
210131210213
return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);
210132210214
}
210133210215
210134210216
/*
210135210217
** Obtain a patchset object containing all changes recorded by the
@@ -210141,10 +210223,11 @@
210141210223
SQLITE_API int sqlite3session_patchset(
210142210224
sqlite3_session *pSession, /* Session object */
210143210225
int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */
210144210226
void **ppPatchset /* OUT: Buffer containing changeset */
210145210227
){
210228
+ if( pnPatchset==0 || ppPatchset==0 ) return SQLITE_MISUSE;
210146210229
return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);
210147210230
}
210148210231
210149210232
/*
210150210233
** Enable or disable the session object passed as the first argument.
@@ -211104,15 +211187,15 @@
211104211187
if( rc!=SQLITE_OK ) goto finished_invert;
211105211188
}
211106211189
}
211107211190
211108211191
assert( rc==SQLITE_OK );
211109
- if( pnInverted ){
211192
+ if( pnInverted && ALWAYS(ppInverted) ){
211110211193
*pnInverted = sOut.nBuf;
211111211194
*ppInverted = sOut.aBuf;
211112211195
sOut.aBuf = 0;
211113
- }else if( sOut.nBuf>0 ){
211196
+ }else if( sOut.nBuf>0 && ALWAYS(xOutput!=0) ){
211114211197
rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
211115211198
}
211116211199
211117211200
finished_invert:
211118211201
sqlite3_free(sOut.aBuf);
@@ -211564,11 +211647,11 @@
211564211647
** in the code below. */
211565211648
assert( xValue==sqlite3changeset_old || xValue==sqlite3changeset_new );
211566211649
211567211650
for(i=0; rc==SQLITE_OK && i<nCol; i++){
211568211651
if( !abPK || abPK[i] ){
211569
- sqlite3_value *pVal;
211652
+ sqlite3_value *pVal = 0;
211570211653
(void)xValue(pIter, i, &pVal);
211571211654
if( pVal==0 ){
211572211655
/* The value in the changeset was "undefined". This indicates a
211573211656
** corrupt changeset blob. */
211574211657
rc = SQLITE_CORRUPT_BKPT;
@@ -212707,13 +212790,13 @@
212707212790
}
212708212791
212709212792
if( rc==SQLITE_OK ){
212710212793
if( xOutput ){
212711212794
if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
212712
- }else{
212795
+ }else if( ppOut ){
212713212796
*ppOut = buf.aBuf;
212714
- *pnOut = buf.nBuf;
212797
+ if( pnOut ) *pnOut = buf.nBuf;
212715212798
buf.aBuf = 0;
212716212799
}
212717212800
}
212718212801
sqlite3_free(buf.aBuf);
212719212802
@@ -213109,11 +213192,11 @@
213109213192
if( rc==SQLITE_OK ){
213110213193
if( xOutput ){
213111213194
if( sOut.nBuf>0 ){
213112213195
rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
213113213196
}
213114
- }else{
213197
+ }else if( ppOut ){
213115213198
*ppOut = (void*)sOut.aBuf;
213116213199
*pnOut = sOut.nBuf;
213117213200
sOut.aBuf = 0;
213118213201
}
213119213202
}
@@ -213852,12 +213935,24 @@
213852213935
#ifndef ArraySize
213853213936
# define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
213854213937
#endif
213855213938
213856213939
#define testcase(x)
213857
-#define ALWAYS(x) 1
213858
-#define NEVER(x) 0
213940
+
213941
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
213942
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
213943
+#endif
213944
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
213945
+# define ALWAYS(X) (1)
213946
+# define NEVER(X) (0)
213947
+#elif !defined(NDEBUG)
213948
+# define ALWAYS(X) ((X)?1:(assert(0),0))
213949
+# define NEVER(X) ((X)?(assert(0),1):0)
213950
+#else
213951
+# define ALWAYS(X) (X)
213952
+# define NEVER(X) (X)
213953
+#endif
213859213954
213860213955
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
213861213956
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
213862213957
213863213958
/*
@@ -217846,10 +217941,11 @@
217846217941
217847217942
z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);
217848217943
z = fts5ConfigSkipWhitespace(z);
217849217944
if( z && *z=='=' ){
217850217945
bOption = 1;
217946
+ assert( zOne!=0 );
217851217947
z++;
217852217948
if( bMustBeCol ) z = 0;
217853217949
}
217854217950
z = fts5ConfigSkipWhitespace(z);
217855217951
if( z && z[0] ){
@@ -217862,11 +217958,15 @@
217862217958
if( z==0 ){
217863217959
*pzErr = sqlite3_mprintf("parse error in \"%s\"", zOrig);
217864217960
rc = SQLITE_ERROR;
217865217961
}else{
217866217962
if( bOption ){
217867
- rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:"", pzErr);
217963
+ rc = fts5ConfigParseSpecial(pGlobal, pRet,
217964
+ ALWAYS(zOne)?zOne:"",
217965
+ zTwo?zTwo:"",
217966
+ pzErr
217967
+ );
217868217968
}else{
217869217969
rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
217870217970
zOne = 0;
217871217971
}
217872217972
}
@@ -218679,10 +218779,11 @@
218679218779
static i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){
218680218780
i64 iRet = 0;
218681218781
int bRetValid = 0;
218682218782
Fts5ExprTerm *p;
218683218783
218784
+ assert( pTerm );
218684218785
assert( pTerm->pSynonym );
218685218786
assert( bDesc==0 || bDesc==1 );
218686218787
for(p=pTerm; p; p=p->pSynonym){
218687218788
if( 0==sqlite3Fts5IterEof(p->pIter) ){
218688218789
i64 iRowid = p->pIter->iRowid;
@@ -220119,11 +220220,11 @@
220119220220
/* This happens when parsing a token or quoted phrase that contains
220120220221
** no token characters at all. (e.g ... MATCH '""'). */
220121220222
sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));
220122220223
}
220123220224
220124
- if( rc==SQLITE_OK ){
220225
+ if( rc==SQLITE_OK && ALWAYS(sCtx.pPhrase) ){
220125220226
/* All the allocations succeeded. Put the expression object together. */
220126220227
pNew->pIndex = pExpr->pIndex;
220127220228
pNew->pConfig = pExpr->pConfig;
220128220229
pNew->nPhrase = 1;
220129220230
pNew->apExprPhrase[0] = sCtx.pPhrase;
@@ -223638,10 +223739,11 @@
223638223739
fts5SegIterNextPage(p, pIter);
223639223740
}
223640223741
223641223742
if( p->rc==SQLITE_OK ){
223642223743
pIter->iLeafOffset = 4;
223744
+ assert( pIter->pLeaf!=0 );
223643223745
assert_nc( pIter->pLeaf->nn>4 );
223644223746
assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
223645223747
pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
223646223748
fts5SegIterLoadTerm(p, pIter, 0);
223647223749
fts5SegIterLoadNPos(p, pIter);
@@ -224598,11 +224700,11 @@
224598224700
pIter->pNextLeaf = 0;
224599224701
pIter->iLeafPgno = iLeafPgno-1;
224600224702
fts5SegIterNextPage(p, pIter);
224601224703
assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );
224602224704
224603
- if( p->rc==SQLITE_OK ){
224705
+ if( p->rc==SQLITE_OK && ALWAYS(pIter->pLeaf!=0) ){
224604224706
int iOff;
224605224707
u8 *a = pIter->pLeaf->p;
224606224708
int n = pIter->pLeaf->szLeaf;
224607224709
224608224710
iOff = fts5LeafFirstRowidOff(pIter->pLeaf);
@@ -225030,11 +225132,15 @@
225030225132
Fts5Index *p,
225031225133
Fts5SegIter *pSeg,
225032225134
Fts5Colset *pColset,
225033225135
Fts5Buffer *pBuf
225034225136
){
225137
+ assert( pBuf!=0 );
225138
+ assert( pSeg!=0 );
225035225139
if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
225140
+ assert( pBuf->p!=0 );
225141
+ assert( pBuf->nSpace >= pBuf->n+pSeg->nPos+FTS5_DATA_ZERO_PADDING );
225036225142
memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);
225037225143
if( pColset==0 ){
225038225144
fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);
225039225145
}else{
225040225146
if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){
@@ -225254,10 +225360,11 @@
225254225360
pIter->base.nData = pIter->poslist.n;
225255225361
}
225256225362
}
225257225363
225258225364
static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){
225365
+ assert( pIter!=0 || (*pRc)!=SQLITE_OK );
225259225366
if( *pRc==SQLITE_OK ){
225260225367
Fts5Config *pConfig = pIter->pIndex->pConfig;
225261225368
if( pConfig->eDetail==FTS5_DETAIL_NONE ){
225262225369
pIter->xSetOutputs = fts5IterSetOutputs_None;
225263225370
}
@@ -225325,11 +225432,14 @@
225325225432
}else{
225326225433
nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);
225327225434
}
225328225435
}
225329225436
*ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
225330
- if( pNew==0 ) return;
225437
+ if( pNew==0 ){
225438
+ assert( p->rc!=SQLITE_OK );
225439
+ goto fts5MultiIterNew_post_check;
225440
+ }
225331225441
pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
225332225442
pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
225333225443
pNew->pColset = pColset;
225334225444
if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
225335225445
fts5IterSetOutputCb(&p->rc, pNew);
@@ -225389,10 +225499,14 @@
225389225499
225390225500
}else{
225391225501
fts5MultiIterFree(pNew);
225392225502
*ppOut = 0;
225393225503
}
225504
+
225505
+fts5MultiIterNew_post_check:
225506
+ assert( (*ppOut)!=0 || p->rc!=SQLITE_OK );
225507
+ return;
225394225508
}
225395225509
225396225510
/*
225397225511
** Create an Fts5Iter that iterates through the doclist provided
225398225512
** as the second argument.
@@ -225436,11 +225550,12 @@
225436225550
/*
225437225551
** Return true if the iterator is at EOF or if an error has occurred.
225438225552
** False otherwise.
225439225553
*/
225440225554
static int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){
225441
- assert( p->rc
225555
+ assert( pIter!=0 || p->rc!=SQLITE_OK );
225556
+ assert( p->rc!=SQLITE_OK
225442225557
|| (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof
225443225558
);
225444225559
return (p->rc || pIter->base.bEof);
225445225560
}
225446225561
@@ -226240,10 +226355,11 @@
226240226355
226241226356
/* Flush the last leaf page to disk. Set the output segment b-tree height
226242226357
** and last leaf page number at the same time. */
226243226358
fts5WriteFinish(p, &writer, &pSeg->pgnoLast);
226244226359
226360
+ assert( pIter!=0 || p->rc!=SQLITE_OK );
226245226361
if( fts5MultiIterEof(p, pIter) ){
226246226362
int i;
226247226363
226248226364
/* Remove the redundant segments from the %_data table */
226249226365
for(i=0; i<nInput; i++){
@@ -226340,11 +226456,11 @@
226340226456
static void fts5IndexAutomerge(
226341226457
Fts5Index *p, /* FTS5 backend object */
226342226458
Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */
226343226459
int nLeaf /* Number of output leaves just written */
226344226460
){
226345
- if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){
226461
+ if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 && ALWAYS((*ppStruct)!=0) ){
226346226462
Fts5Structure *pStruct = *ppStruct;
226347226463
u64 nWrite; /* Initial value of write-counter */
226348226464
int nWork; /* Number of work-quanta to perform */
226349226465
int nRem; /* Number of leaf pages left to write */
226350226466
@@ -227450,15 +227566,19 @@
227450227566
}
227451227567
}else{
227452227568
/* Scan multiple terms in the main index */
227453227569
int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
227454227570
fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet);
227455
- assert( p->rc!=SQLITE_OK || pRet->pColset==0 );
227456
- fts5IterSetOutputCb(&p->rc, pRet);
227457
- if( p->rc==SQLITE_OK ){
227458
- Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
227459
- if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
227571
+ if( pRet==0 ){
227572
+ assert( p->rc!=SQLITE_OK );
227573
+ }else{
227574
+ assert( pRet->pColset==0 );
227575
+ fts5IterSetOutputCb(&p->rc, pRet);
227576
+ if( p->rc==SQLITE_OK ){
227577
+ Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
227578
+ if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
227579
+ }
227460227580
}
227461227581
}
227462227582
227463227583
if( p->rc ){
227464227584
sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
@@ -227702,11 +227822,11 @@
227702227822
int eDetail = p->pConfig->eDetail;
227703227823
u64 cksum = *pCksum;
227704227824
Fts5IndexIter *pIter = 0;
227705227825
int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);
227706227826
227707
- while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){
227827
+ while( rc==SQLITE_OK && ALWAYS(pIter!=0) && 0==sqlite3Fts5IterEof(pIter) ){
227708227828
i64 rowid = pIter->iRowid;
227709227829
227710227830
if( eDetail==FTS5_DETAIL_NONE ){
227711227831
cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n);
227712227832
}else{
@@ -228067,10 +228187,11 @@
228067228187
int eDetail = p->pConfig->eDetail;
228068228188
u64 cksum2 = 0; /* Checksum based on contents of indexes */
228069228189
Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
228070228190
Fts5Iter *pIter; /* Used to iterate through entire index */
228071228191
Fts5Structure *pStruct; /* Index structure */
228192
+ int iLvl, iSeg;
228072228193
228073228194
#ifdef SQLITE_DEBUG
228074228195
/* Used by extra internal tests only run if NDEBUG is not defined */
228075228196
u64 cksum3 = 0; /* Checksum based on contents of indexes */
228076228197
Fts5Buffer term = {0,0,0}; /* Buffer used to hold most recent term */
@@ -228077,19 +228198,20 @@
228077228198
#endif
228078228199
const int flags = FTS5INDEX_QUERY_NOOUTPUT;
228079228200
228080228201
/* Load the FTS index structure */
228081228202
pStruct = fts5StructureRead(p);
228203
+ if( pStruct==0 ){
228204
+ assert( p->rc!=SQLITE_OK );
228205
+ return fts5IndexReturn(p);
228206
+ }
228082228207
228083228208
/* Check that the internal nodes of each segment match the leaves */
228084
- if( pStruct ){
228085
- int iLvl, iSeg;
228086
- for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
228087
- for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
228088
- Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];
228089
- fts5IndexIntegrityCheckSegment(p, pSeg);
228090
- }
228209
+ for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
228210
+ for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
228211
+ Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];
228212
+ fts5IndexIntegrityCheckSegment(p, pSeg);
228091228213
}
228092228214
}
228093228215
228094228216
/* The cksum argument passed to this function is a checksum calculated
228095228217
** based on all expected entries in the FTS index (including prefix index
@@ -230032,11 +230154,12 @@
230032230154
pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);
230033230155
rc = sqlite3Fts5StorageStmt(
230034230156
pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg
230035230157
);
230036230158
if( rc==SQLITE_OK ){
230037
- if( pCsr->ePlan==FTS5_PLAN_ROWID ){
230159
+ if( pRowidEq!=0 ){
230160
+ assert( pCsr->ePlan==FTS5_PLAN_ROWID );
230038230161
sqlite3_bind_value(pCsr->pStmt, 1, pRowidEq);
230039230162
}else{
230040230163
sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);
230041230164
sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);
230042230165
}
@@ -231450,11 +231573,11 @@
231450231573
int nArg, /* Number of args */
231451231574
sqlite3_value **apUnused /* Function arguments */
231452231575
){
231453231576
assert( nArg==0 );
231454231577
UNUSED_PARAM2(nArg, apUnused);
231455
- sqlite3_result_text(pCtx, "fts5: 2021-10-04 11:10:15 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813", -1, SQLITE_TRANSIENT);
231578
+ sqlite3_result_text(pCtx, "fts5: 2021-10-05 18:33:38 a7835bead85b1b18a8affd9835240b0baf9c7af887196bbdcc3f5d58055042fc", -1, SQLITE_TRANSIENT);
231456231579
}
231457231580
231458231581
/*
231459231582
** Return true if zName is the extension on one of the shadow tables used
231460231583
** by this module.
@@ -232001,16 +232124,20 @@
232001232124
rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);
232002232125
for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){
232003232126
if( pConfig->abUnindexed[iCol-1]==0 ){
232004232127
const char *zText;
232005232128
int nText;
232129
+ assert( pSeek==0 || apVal==0 );
232130
+ assert( pSeek!=0 || apVal!=0 );
232006232131
if( pSeek ){
232007232132
zText = (const char*)sqlite3_column_text(pSeek, iCol);
232008232133
nText = sqlite3_column_bytes(pSeek, iCol);
232009
- }else{
232134
+ }else if( ALWAYS(apVal) ){
232010232135
zText = (const char*)sqlite3_value_text(apVal[iCol-1]);
232011232136
nText = sqlite3_value_bytes(apVal[iCol-1]);
232137
+ }else{
232138
+ continue;
232012232139
}
232013232140
ctx.szCol = 0;
232014232141
rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT,
232015232142
zText, nText, (void*)&ctx, fts5StorageInsertCallback
232016232143
);
@@ -232642,12 +232769,13 @@
232642232769
sqlite3_stmt *pLookup = 0; /* Statement to query %_docsize */
232643232770
int rc; /* Return Code */
232644232771
232645232772
assert( p->pConfig->bColumnsize );
232646232773
rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
232647
- if( rc==SQLITE_OK ){
232774
+ if( pLookup ){
232648232775
int bCorrupt = 1;
232776
+ assert( rc==SQLITE_OK );
232649232777
sqlite3_bind_int64(pLookup, 1, iRowid);
232650232778
if( SQLITE_ROW==sqlite3_step(pLookup) ){
232651232779
const u8 *aBlob = sqlite3_column_blob(pLookup, 0);
232652232780
int nBlob = sqlite3_column_bytes(pLookup, 0);
232653232781
if( 0==fts5StorageDecodeSizeArray(aCol, nCol, aBlob, nBlob) ){
@@ -232656,10 +232784,12 @@
232656232784
}
232657232785
rc = sqlite3_reset(pLookup);
232658232786
if( bCorrupt && rc==SQLITE_OK ){
232659232787
rc = FTS5_CORRUPT;
232660232788
}
232789
+ }else{
232790
+ assert( rc!=SQLITE_OK );
232661232791
}
232662232792
232663232793
return rc;
232664232794
}
232665232795
232666232796
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.37.0"
456 #define SQLITE_VERSION_NUMBER 3037000
457 #define SQLITE_SOURCE_ID "2021-10-04 11:10:15 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -13194,10 +13194,18 @@
13194 # define VVA_ONLY(X) X
13195 #else
13196 # define VVA_ONLY(X)
13197 #endif
13198
 
 
 
 
 
 
 
 
13199 /*
13200 ** The ALWAYS and NEVER macros surround boolean expressions which
13201 ** are intended to always be true or false, respectively. Such
13202 ** expressions could be omitted from the code completely. But they
13203 ** are included in a few cases in order to enhance the resilience
@@ -13209,11 +13217,11 @@
13209 **
13210 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
13211 ** be true and false so that the unreachable code they specify will
13212 ** not be counted as untested code.
13213 */
13214 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
13215 # define ALWAYS(X) (1)
13216 # define NEVER(X) (0)
13217 #elif !defined(NDEBUG)
13218 # define ALWAYS(X) ((X)?1:(assert(0),0))
13219 # define NEVER(X) ((X)?(assert(0),1):0)
@@ -23573,11 +23581,11 @@
23573
23574 computeJD(&x);
23575 computeYMD_HMS(&x);
23576 for(i=j=0; zFmt[i]; i++){
23577 if( zFmt[i]!='%' ) continue;
23578 if( j<i ) sqlite3_str_append(&sRes, zFmt+j, i-j);
23579 i++;
23580 j = i + 1;
23581 switch( zFmt[i] ){
23582 case 'd': {
23583 sqlite3_str_appendf(&sRes, "%02d", x.D);
@@ -23649,11 +23657,11 @@
23649 sqlite3_str_reset(&sRes);
23650 return;
23651 }
23652 }
23653 }
23654 if( j<i ) sqlite3_str_append(&sRes, zFmt+j, i-j);
23655 sqlite3ResultStrAccum(context, &sRes);
23656 }
23657
23658 /*
23659 ** current_time()
@@ -49576,11 +49584,11 @@
49576 /* NULL pBitvec tests */
49577 sqlite3BitvecSet(0, 1);
49578 sqlite3BitvecClear(0, 1, pTmpSpace);
49579
49580 /* Run the program */
49581 pc = 0;
49582 while( (op = aOp[pc])!=0 ){
49583 switch( op ){
49584 case 1:
49585 case 2:
49586 case 5: {
@@ -55500,10 +55508,11 @@
55500 ** routine which only updates the change-counter if the update is actually
55501 ** needed, as determined by the pPager->changeCountDone state variable.
55502 */
55503 static void pager_write_changecounter(PgHdr *pPg){
55504 u32 change_counter;
 
55505
55506 /* Increment the value just read and write it back to byte 24. */
55507 change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;
55508 put32bits(((char*)pPg->pData)+24, change_counter);
55509
@@ -68477,11 +68486,10 @@
68477 static int lockBtree(BtShared *pBt){
68478 int rc; /* Result code from subfunctions */
68479 MemPage *pPage1; /* Page 1 of the database file */
68480 u32 nPage; /* Number of pages in the database */
68481 u32 nPageFile = 0; /* Number of pages in the database file */
68482 u32 nPageHeader; /* Number of pages in the database according to hdr */
68483
68484 assert( sqlite3_mutex_held(pBt->mutex) );
68485 assert( pBt->pPage1==0 );
68486 rc = sqlite3PagerSharedLock(pBt->pPager);
68487 if( rc!=SQLITE_OK ) return rc;
@@ -68489,11 +68497,11 @@
68489 if( rc!=SQLITE_OK ) return rc;
68490
68491 /* Do some checking to help insure the file we opened really is
68492 ** a valid database file.
68493 */
68494 nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
68495 sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);
68496 if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
68497 nPage = nPageFile;
68498 }
68499 if( (pBt->db->flags & SQLITE_ResetDatabase)!=0 ){
@@ -73069,15 +73077,14 @@
73069 Pgno pgno; /* Temp var to store a page number in */
73070 u8 abDone[NB+2]; /* True after i'th new page is populated */
73071 Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */
73072 Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */
73073 u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */
73074 CellArray b; /* Parsed information on cells being balanced */
73075
73076 memset(abDone, 0, sizeof(abDone));
73077 b.nCell = 0;
73078 b.apCell = 0;
73079 pBt = pParent->pBt;
73080 assert( sqlite3_mutex_held(pBt->mutex) );
73081 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
73082
73083 /* At this point pParent may have at most one overflow cell. And if
@@ -73884,11 +73891,11 @@
73884
73885 /*
73886 ** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid
73887 ** on the same B-tree as pCur.
73888 **
73889 ** This can if a database is corrupt with two or more SQL tables
73890 ** pointing to the same b-tree. If an insert occurs on one SQL table
73891 ** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL
73892 ** table linked to the same b-tree. If the secondary insert causes a
73893 ** rebalance, that can change content out from under the cursor on the
73894 ** first SQL table, violating invariants on the first insert.
@@ -77209,10 +77216,11 @@
77209 */
77210 SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
77211 #ifndef SQLITE_OMIT_UTF16
77212 int rc;
77213 #endif
 
77214 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77215 assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE
77216 || desiredEnc==SQLITE_UTF16BE );
77217 if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
77218 return SQLITE_OK;
@@ -77341,10 +77349,11 @@
77341 ** MEM.zMalloc, where it can be safely written.
77342 **
77343 ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.
77344 */
77345 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
 
77346 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77347 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77348 if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
77349 if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
77350 if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
@@ -77365,10 +77374,11 @@
77365 ** blob stored in dynamically allocated space.
77366 */
77367 #ifndef SQLITE_OMIT_INCRBLOB
77368 SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
77369 int nByte;
 
77370 assert( pMem->flags & MEM_Zero );
77371 assert( (pMem->flags&MEM_Blob)!=0 || MemNullNochng(pMem) );
77372 testcase( sqlite3_value_nochange(pMem) );
77373 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77374 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -77392,10 +77402,11 @@
77392
77393 /*
77394 ** Make sure the given Mem is \u0000 terminated.
77395 */
77396 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
 
77397 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77398 testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
77399 testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
77400 if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
77401 return SQLITE_OK; /* Nothing to do */
@@ -77419,10 +77430,11 @@
77419 ** user and the latter is an internal programming error.
77420 */
77421 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
77422 const int nByte = 32;
77423
 
77424 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77425 assert( !(pMem->flags&MEM_Zero) );
77426 assert( !(pMem->flags&(MEM_Str|MEM_Blob)) );
77427 assert( pMem->flags&(MEM_Int|MEM_Real|MEM_IntReal) );
77428 assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -77454,10 +77466,11 @@
77454 */
77455 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
77456 sqlite3_context ctx;
77457 Mem t;
77458 assert( pFunc!=0 );
 
77459 assert( pFunc->xFinalize!=0 );
77460 assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
77461 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77462 memset(&ctx, 0, sizeof(ctx));
77463 memset(&t, 0, sizeof(t));
@@ -77604,10 +77617,11 @@
77604 sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
77605 return value;
77606 }
77607 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
77608 int flags;
 
77609 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77610 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77611 flags = pMem->flags;
77612 if( flags & (MEM_Int|MEM_IntReal) ){
77613 testcase( flags & MEM_IntReal );
@@ -77632,10 +77646,11 @@
77632 double val = (double)0;
77633 sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
77634 return val;
77635 }
77636 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
 
77637 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77638 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77639 if( pMem->flags & MEM_Real ){
77640 return pMem->u.r;
77641 }else if( pMem->flags & (MEM_Int|MEM_IntReal) ){
@@ -77664,10 +77679,11 @@
77664 ** The MEM structure is already a MEM_Real. Try to also make it a
77665 ** MEM_Int if we can.
77666 */
77667 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
77668 i64 ix;
 
77669 assert( pMem->flags & MEM_Real );
77670 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77671 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77672 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77673
@@ -77691,10 +77707,11 @@
77691
77692 /*
77693 ** Convert pMem to type integer. Invalidate any prior representations.
77694 */
77695 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
 
77696 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77697 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77698 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77699
77700 pMem->u.i = sqlite3VdbeIntValue(pMem);
@@ -77705,10 +77722,11 @@
77705 /*
77706 ** Convert pMem so that it is of type MEM_Real.
77707 ** Invalidate any prior representations.
77708 */
77709 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
 
77710 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77711 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77712
77713 pMem->u.r = sqlite3VdbeRealValue(pMem);
77714 MemSetTypeFlag(pMem, MEM_Real);
@@ -77738,10 +77756,11 @@
77738 ** Every effort is made to force the conversion, even if the input
77739 ** is a string that does not look completely like a number. Convert
77740 ** as much of the string as we can and ignore the rest.
77741 */
77742 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
 
77743 testcase( pMem->flags & MEM_Int );
77744 testcase( pMem->flags & MEM_Real );
77745 testcase( pMem->flags & MEM_IntReal );
77746 testcase( pMem->flags & MEM_Null );
77747 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){
@@ -78089,10 +78108,11 @@
78089 ){
78090 i64 nByte = n; /* New value for pMem->n */
78091 int iLimit; /* Maximum allowed string or blob size */
78092 u16 flags = 0; /* New value for pMem->flags */
78093
 
78094 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
78095 assert( !sqlite3VdbeMemIsRowSet(pMem) );
78096
78097 /* If z is a NULL pointer, set pMem to contain an SQL NULL. */
78098 if( !z ){
@@ -79162,12 +79182,14 @@
79162 assert( p->iVdbeMagic==VDBE_MAGIC_INIT );
79163 assert( op>=0 && op<0xff );
79164 if( p->nOpAlloc<=i ){
79165 return growOp3(p, op, p1, p2, p3);
79166 }
 
79167 p->nOp++;
79168 pOp = &p->aOp[i];
 
79169 pOp->opcode = (u8)op;
79170 pOp->p5 = 0;
79171 pOp->p1 = p1;
79172 pOp->p2 = p2;
79173 pOp->p3 = p3;
@@ -80406,11 +80428,11 @@
80406 zOpName = sqlite3OpcodeName(pOp->opcode);
80407 nOpName = sqlite3Strlen30(zOpName);
80408 if( zOpName[nOpName+1] ){
80409 int seenCom = 0;
80410 char c;
80411 zSynopsis = zOpName += nOpName + 1;
80412 if( strncmp(zSynopsis,"IF ",3)==0 ){
80413 sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3);
80414 zSynopsis = zAlt;
80415 }
80416 for(ii=0; (c = zSynopsis[ii])!=0; ii++){
@@ -91677,11 +91699,11 @@
91677 zDb = db->aDb[pC->iDb].zDbSName;
91678 pTab = pOp->p4.pTab;
91679 assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) );
91680 }else{
91681 pTab = 0;
91682 zDb = 0; /* Not needed. Silence a compiler warning. */
91683 }
91684
91685 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
91686 /* Invoke the pre-update hook, if any */
91687 if( pTab ){
@@ -91830,17 +91852,18 @@
91830 pTab = pOp->p4.pTab;
91831 if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
91832 pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
91833 }
91834 }else{
91835 zDb = 0; /* Not needed. Silence a compiler warning. */
91836 pTab = 0; /* Not needed. Silence a compiler warning. */
91837 }
91838
91839 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
91840 /* Invoke the pre-update-hook if required. */
91841 if( db->xPreUpdateCallback && pOp->p4.pTab ){
 
91842 assert( !(opflags & OPFLAG_ISUPDATE)
91843 || HasRowid(pTab)==0
91844 || (aMem[pOp->p3].flags & MEM_Int)
91845 );
91846 sqlite3VdbePreUpdateHook(p, pC,
@@ -91877,11 +91900,11 @@
91877 if( rc ) goto abort_due_to_error;
91878
91879 /* Invoke the update-hook if required. */
91880 if( opflags & OPFLAG_NCHANGE ){
91881 p->nChange++;
91882 if( db->xUpdateCallback && HasRowid(pTab) ){
91883 db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,
91884 pC->movetoTarget);
91885 assert( pC->iDb>=0 );
91886 }
91887 }
@@ -103680,13 +103703,13 @@
103680 case TK_UPLUS: {
103681 rc = sqlite3ExprIsInteger(p->pLeft, pValue);
103682 break;
103683 }
103684 case TK_UMINUS: {
103685 int v;
103686 if( sqlite3ExprIsInteger(p->pLeft, &v) ){
103687 assert( v!=(-2147483647-1) );
103688 *pValue = -v;
103689 rc = 1;
103690 }
103691 break;
103692 }
@@ -105692,11 +105715,11 @@
105692 if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
105693 if( !pColl ) pColl = db->pDfltColl;
105694 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
105695 }
105696 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
105697 if( pDef->funcFlags & SQLITE_FUNC_OFFSET ){
105698 Expr *pArg = pFarg->a[0].pExpr;
105699 if( pArg->op==TK_COLUMN ){
105700 sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target);
105701 }else{
105702 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
@@ -112049,13 +112072,13 @@
112049 if( pParse->nErr ) goto attach_end;
112050 memset(&sName, 0, sizeof(NameContext));
112051 sName.pParse = pParse;
112052
112053 if(
112054 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
112055 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
112056 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
112057 ){
112058 goto attach_end;
112059 }
112060
112061 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -128871,11 +128894,11 @@
128871 /* iArg: */ 0 },
128872 {/* zName: */ "table_list",
128873 /* ePragTyp: */ PragTyp_TABLE_LIST,
128874 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
128875 /* ColNames: */ 15, 6,
128876 /* iArg: */ 1 },
128877 {/* zName: */ "table_xinfo",
128878 /* ePragTyp: */ PragTyp_TABLE_INFO,
128879 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
128880 /* ColNames: */ 8, 7,
128881 /* iArg: */ 1 },
@@ -134994,11 +135017,11 @@
134994 ** function is responsible for ensuring that this structure is eventually
134995 ** freed.
134996 */
134997 static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
134998 ExprList *pOrderBy = p->pOrderBy;
134999 int nOrderBy = p->pOrderBy->nExpr;
135000 sqlite3 *db = pParse->db;
135001 KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);
135002 if( pRet ){
135003 int i;
135004 for(i=0; i<nOrderBy; i++){
@@ -135615,10 +135638,11 @@
135615 Select *pLoop; /* For looping through SELECT statements */
135616 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
135617 int nCol; /* Number of columns in result set */
135618
135619 assert( p->pNext==0 );
 
135620 nCol = p->pEList->nExpr;
135621 pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1);
135622 if( !pKeyInfo ){
135623 rc = SQLITE_NOMEM_BKPT;
135624 goto multi_select_end;
@@ -135966,10 +135990,11 @@
135966 */
135967 if( op!=TK_ALL ){
135968 for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){
135969 struct ExprList_item *pItem;
135970 for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){
 
135971 assert( pItem->u.x.iOrderByCol>0 );
135972 if( pItem->u.x.iOrderByCol==i ) break;
135973 }
135974 if( j==nOrderBy ){
135975 Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
@@ -135992,10 +136017,11 @@
135992 aPermute = sqlite3DbMallocRawNN(db, sizeof(u32)*(nOrderBy + 1));
135993 if( aPermute ){
135994 struct ExprList_item *pItem;
135995 aPermute[0] = nOrderBy;
135996 for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){
 
135997 assert( pItem->u.x.iOrderByCol>0 );
135998 assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );
135999 aPermute[i] = pItem->u.x.iOrderByCol - 1;
136000 }
136001 pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
@@ -146974,11 +147000,11 @@
146974 x.pWInfo = pWInfo;
146975 x.db = pWInfo->pParse->db;
146976 for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
146977 i16 iRef = pIdx->aiColumn[iIdxCol];
146978 if( iRef==XN_EXPR ){
146979 assert( aColExpr->a[iIdxCol].pExpr!=0 );
146980 x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
146981 if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue;
146982 w.xExprCallback = whereIndexExprTransNode;
146983 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
146984 }else if( iRef>=0
@@ -150214,11 +150240,12 @@
150214 if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
150215 continue;
150216 }
150217 }
150218 if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0
150219 && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN
 
150220 && pX->iTable==pScan->aiCur[0]
150221 && pX->iColumn==pScan->aiColumn[0]
150222 ){
150223 testcase( pTerm->eOperator & WO_IS );
150224 continue;
@@ -153969,11 +153996,11 @@
153969 }
153970 } /* End the loop over all WhereLoops from outer-most down to inner-most */
153971 if( obSat==obDone ) return (i8)nOrderBy;
153972 if( !isOrderDistinct ){
153973 for(i=nOrderBy-1; i>0; i--){
153974 Bitmask m = MASKBIT(i) - 1;
153975 if( (obSat&m)==m ) return i;
153976 }
153977 return 0;
153978 }
153979 return -1;
@@ -154494,13 +154521,13 @@
154494 pWC = &pWInfo->sWC;
154495 pLoop = pBuilder->pNew;
154496 pLoop->wsFlags = 0;
154497 pLoop->nSkip = 0;
154498 pTerm = whereScanInit(&scan, pWC, iCur, -1, WO_EQ|WO_IS, 0);
 
154499 if( pTerm ){
154500 testcase( pTerm->eOperator & WO_IS );
154501 assert( pTerm->prereqRight==0 );
154502 pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
154503 pLoop->aLTerm[0] = pTerm;
154504 pLoop->nLTerm = 1;
154505 pLoop->u.btree.nEq = 1;
154506 /* TUNING: Cost of a rowid lookup is 10 */
@@ -167620,21 +167647,20 @@
167620 void (*xValue)(sqlite3_context*),
167621 void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
167622 FuncDestructor *pDestructor
167623 ){
167624 FuncDef *p;
167625 int nName;
167626 int extraFlags;
167627
167628 assert( sqlite3_mutex_held(db->mutex) );
167629 assert( xValue==0 || xSFunc==0 );
167630 if( zFunctionName==0 /* Must have a valid name */
167631 || (xSFunc!=0 && xFinal!=0) /* Not both xSFunc and xFinal */
167632 || ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */
167633 || ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */
167634 || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)
167635 || (255<(nName = sqlite3Strlen30( zFunctionName)))
167636 ){
167637 return SQLITE_MISUSE_BKPT;
167638 }
167639
167640 assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
@@ -168897,11 +168923,11 @@
168897 ** This routine does the core work of extracting URI parameters from a
168898 ** database filename for the sqlite3_uri_parameter() interface.
168899 */
168900 static const char *uriParameter(const char *zFilename, const char *zParam){
168901 zFilename += sqlite3Strlen30(zFilename) + 1;
168902 while( zFilename[0] ){
168903 int x = strcmp(zFilename, zParam);
168904 zFilename += sqlite3Strlen30(zFilename) + 1;
168905 if( x==0 ) return zFilename;
168906 zFilename += sqlite3Strlen30(zFilename) + 1;
168907 }
@@ -170245,11 +170271,11 @@
170245 */
170246 SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){
170247 if( zFilename==0 || N<0 ) return 0;
170248 zFilename = databaseName(zFilename);
170249 zFilename += sqlite3Strlen30(zFilename) + 1;
170250 while( zFilename[0] && (N--)>0 ){
170251 zFilename += sqlite3Strlen30(zFilename) + 1;
170252 zFilename += sqlite3Strlen30(zFilename) + 1;
170253 }
170254 return zFilename[0] ? zFilename : 0;
170255 }
@@ -170295,11 +170321,11 @@
170295 }
170296 SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){
170297 if( zFilename==0 ) return 0;
170298 zFilename = databaseName(zFilename);
170299 zFilename += sqlite3Strlen30(zFilename) + 1;
170300 while( zFilename[0] ){
170301 zFilename += sqlite3Strlen30(zFilename) + 1;
170302 zFilename += sqlite3Strlen30(zFilename) + 1;
170303 }
170304 return zFilename + 1;
170305 }
@@ -171599,21 +171625,22 @@
171599 #ifndef SQLITE_AMALGAMATION
171600 /*
171601 ** Macros indicating that conditional expressions are always true or
171602 ** false.
171603 */
171604 #ifdef SQLITE_COVERAGE_TEST
171605 # define ALWAYS(x) (1)
171606 # define NEVER(X) (0)
171607 #elif defined(SQLITE_DEBUG)
171608 # define ALWAYS(x) sqlite3Fts3Always((x)!=0)
171609 # define NEVER(x) sqlite3Fts3Never((x)!=0)
171610 SQLITE_PRIVATE int sqlite3Fts3Always(int b);
171611 SQLITE_PRIVATE int sqlite3Fts3Never(int b);
 
171612 #else
171613 # define ALWAYS(x) (x)
171614 # define NEVER(x) (x)
171615 #endif
171616
171617 /*
171618 ** Internal types used by SQLite.
171619 */
@@ -172125,17 +172152,10 @@
172125 static int fts3EvalNext(Fts3Cursor *pCsr);
172126 static int fts3EvalStart(Fts3Cursor *pCsr);
172127 static int fts3TermSegReaderCursor(
172128 Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
172129
172130 #ifndef SQLITE_AMALGAMATION
172131 # if defined(SQLITE_DEBUG)
172132 SQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; }
172133 SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; }
172134 # endif
172135 #endif
172136
172137 /*
172138 ** This variable is set to false when running tests for which the on disk
172139 ** structures should not be corrupt. Otherwise, true. If it is false, extra
172140 ** assert() conditions in the fts3 code are activated - conditions that are
172141 ** only true if it is guaranteed that the fts3 database is not corrupt.
@@ -185824,11 +185844,11 @@
185824
185825 if( nPrefix>p->term.n || nSuffix>p->nNode-p->iOff || nSuffix==0 ){
185826 return FTS_CORRUPT_VTAB;
185827 }
185828 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
185829 if( rc==SQLITE_OK ){
185830 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
185831 p->term.n = nPrefix+nSuffix;
185832 p->iOff += nSuffix;
185833 if( p->iChild==0 ){
185834 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
@@ -186218,11 +186238,15 @@
186218 const char *zRhs, int nRhs /* RHS of comparison */
186219 ){
186220 int nCmp = MIN(nLhs, nRhs);
186221 int res;
186222
186223 res = (nCmp ? memcmp(zLhs, zRhs, nCmp) : 0);
 
 
 
 
186224 if( res==0 ) res = nLhs - nRhs;
186225
186226 return res;
186227 }
186228
@@ -186862,11 +186886,11 @@
186862 const char *aHint = sqlite3_column_blob(pSelect, 0);
186863 int nHint = sqlite3_column_bytes(pSelect, 0);
186864 if( aHint ){
186865 blobGrowBuffer(pHint, nHint, &rc);
186866 if( rc==SQLITE_OK ){
186867 memcpy(pHint->a, aHint, nHint);
186868 pHint->n = nHint;
186869 }
186870 }
186871 }
186872 rc2 = sqlite3_reset(pSelect);
@@ -188953,14 +188977,16 @@
188953 ** Advance the iterator passed as an argument to the next position. Return
188954 ** 1 if the iterator is at EOF or if it now points to the start of the
188955 ** position list for the next column.
188956 */
188957 static int fts3LcsIteratorAdvance(LcsIterator *pIter){
188958 char *pRead = pIter->pRead;
188959 sqlite3_int64 iRead;
188960 int rc = 0;
188961
 
 
188962 pRead += sqlite3Fts3GetVarint(pRead, &iRead);
188963 if( iRead==0 || iRead==1 ){
188964 pRead = 0;
188965 rc = 1;
188966 }else{
@@ -190478,10 +190504,23 @@
190478 ** but the definitions need to be repeated for separate compilation. */
190479 typedef sqlite3_uint64 u64;
190480 typedef unsigned int u32;
190481 typedef unsigned short int u16;
190482 typedef unsigned char u8;
 
 
 
 
 
 
 
 
 
 
 
 
 
190483 #endif
190484
190485 /* Objects */
190486 typedef struct JsonString JsonString;
190487 typedef struct JsonNode JsonNode;
@@ -190820,12 +190859,13 @@
190820 static void jsonRenderNode(
190821 JsonNode *pNode, /* The node to render */
190822 JsonString *pOut, /* Write JSON here */
190823 sqlite3_value **aReplace /* Replacement values */
190824 ){
 
190825 if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){
190826 if( pNode->jnFlags & JNODE_REPLACE ){
190827 jsonAppendValue(pOut, aReplace[pNode->u.iReplace]);
190828 return;
190829 }
190830 pNode = pNode->u.pPatch;
190831 }
@@ -191141,11 +191181,11 @@
191141 u32 eType, /* Node type */
191142 u32 n, /* Content size or sub-node count */
191143 const char *zContent /* Content */
191144 ){
191145 JsonNode *p;
191146 if( pParse->nNode>=pParse->nAlloc ){
191147 return jsonParseAddNodeExpand(pParse, eType, n, zContent);
191148 }
191149 p = &pParse->aNode[pParse->nNode];
191150 p->eType = (u8)eType;
191151 p->jnFlags = 0;
@@ -193099,10 +193139,13 @@
193099 #endif
193100 #if defined(NDEBUG) && defined(SQLITE_DEBUG)
193101 # undef NDEBUG
193102 #endif
193103 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
 
 
 
193104 # define ALWAYS(X) (1)
193105 # define NEVER(X) (0)
193106 #elif !defined(NDEBUG)
193107 # define ALWAYS(X) ((X)?1:(assert(0),0))
193108 # define NEVER(X) ((X)?(assert(0),1):0)
@@ -193450,11 +193493,16 @@
193450
193451 /* The testcase() macro should already be defined in the amalgamation. If
193452 ** it is not, make it a no-op.
193453 */
193454 #ifndef SQLITE_AMALGAMATION
193455 # define testcase(X)
 
 
 
 
 
193456 #endif
193457
193458 /*
193459 ** Make sure that the compiler intrinsics we desire are enabled when
193460 ** compiling with an appropriate version of MSVC unless prevented by
@@ -195214,11 +195262,11 @@
195214 RtreeDValue fMinGrowth = RTREE_ZERO;
195215 RtreeDValue fMinArea = RTREE_ZERO;
195216
195217 int nCell = NCELL(pNode);
195218 RtreeCell cell;
195219 RtreeNode *pChild;
195220
195221 RtreeCell *aCell = 0;
195222
195223 /* Select the child node which will be enlarged the least if pCell
195224 ** is inserted into it. Resolve ties by choosing the entry with
@@ -195572,10 +195620,11 @@
195572 nodeRelease(pRtree, pChild->pParent);
195573 nodeReference(pNode);
195574 pChild->pParent = pNode;
195575 }
195576 }
 
195577 return xSetMapping(pRtree, iRowid, pNode->iNode);
195578 }
195579
195580 static int SplitNode(
195581 Rtree *pRtree,
@@ -196876,10 +196925,11 @@
196876 tree.nDim = (u8)sqlite3_value_int(apArg[0]);
196877 if( tree.nDim<1 || tree.nDim>5 ) return;
196878 tree.nDim2 = tree.nDim*2;
196879 tree.nBytesPerCell = 8 + 8 * tree.nDim;
196880 node.zData = (u8 *)sqlite3_value_blob(apArg[1]);
 
196881 nData = sqlite3_value_bytes(apArg[1]);
196882 if( nData<4 ) return;
196883 if( nData<NCELL(&node)*tree.nBytesPerCell ) return;
196884
196885 pOut = sqlite3_str_new(0);
@@ -197707,17 +197757,18 @@
197707 sqlite3_value *pVal, /* The value to decode */
197708 int *pRc /* Write error here */
197709 ){
197710 GeoPoly *p = 0;
197711 int nByte;
 
197712 if( sqlite3_value_type(pVal)==SQLITE_BLOB
197713 && (nByte = sqlite3_value_bytes(pVal))>=(4+6*sizeof(GeoCoord))
197714 ){
197715 const unsigned char *a = sqlite3_value_blob(pVal);
197716 int nVertex;
197717 if( a==0 ){
197718 sqlite3_result_error_nomem(pCtx);
197719 return 0;
197720 }
197721 nVertex = (a[1]<<16) + (a[2]<<8) + a[3];
197722 if( (a[0]==0 || a[0]==1)
197723 && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte
@@ -198540,15 +198591,15 @@
198540 pActive = pSeg;
198541 needSort = 1;
198542 }else{
198543 /* Remove a segment */
198544 if( pActive==pThisEvent->pSeg ){
198545 pActive = pActive->pNext;
198546 }else{
198547 for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){
198548 if( pSeg->pNext==pThisEvent->pSeg ){
198549 pSeg->pNext = pSeg->pNext->pNext;
198550 break;
198551 }
198552 }
198553 }
198554 }
@@ -198788,10 +198839,11 @@
198788 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
198789 if( rc==SQLITE_OK && idxNum<=3 ){
198790 RtreeCoord bbox[4];
198791 RtreeConstraint *p;
198792 assert( argc==1 );
 
198793 geopolyBBox(0, argv[0], bbox, &rc);
198794 if( rc ){
198795 goto geopoly_filter_end;
198796 }
198797 pCsr->aConstraint = p = sqlite3_malloc(sizeof(RtreeConstraint)*4);
@@ -199015,10 +199067,11 @@
199015 if( nData>1 /* not a DELETE */
199016 && (!oldRowidValid /* INSERT */
199017 || !sqlite3_value_nochange(aData[2]) /* UPDATE _shape */
199018 || oldRowid!=newRowid) /* Rowid change */
199019 ){
 
199020 geopolyBBox(0, aData[2], cell.aCoord, &rc);
199021 if( rc ){
199022 if( rc==SQLITE_ERROR ){
199023 pVtab->zErrMsg =
199024 sqlite3_mprintf("_shape does not contain a valid polygon");
@@ -207873,11 +207926,11 @@
207873 if( z==0 && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;
207874 nVarint = sessionVarintLen(n);
207875
207876 if( aBuf ){
207877 sessionVarintPut(&aBuf[1], n);
207878 if( n ) memcpy(&aBuf[nVarint + 1], z, n);
207879 }
207880
207881 nByte = 1 + nVarint + n;
207882 break;
207883 }
@@ -208478,20 +208531,36 @@
208478 "SELECT 2, 'stat', '', 0, '', 0"
208479 );
208480 }else if( rc==SQLITE_ERROR ){
208481 zPragma = sqlite3_mprintf("");
208482 }else{
 
 
 
 
208483 return rc;
208484 }
208485 }else{
208486 zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
208487 }
208488 if( !zPragma ) return SQLITE_NOMEM;
 
 
 
 
 
 
208489
208490 rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);
208491 sqlite3_free(zPragma);
208492 if( rc!=SQLITE_OK ) return rc;
 
 
 
 
 
 
208493
208494 nByte = nThis + 1;
208495 while( SQLITE_ROW==sqlite3_step(pStmt) ){
208496 nByte += sqlite3_column_bytes(pStmt, 1);
208497 nDbCol++;
@@ -208905,11 +208974,15 @@
208905 if( pSession->xTableFilter==0
208906 || pSession->xTableFilter(pSession->pFilterCtx, zName)
208907 ){
208908 rc = sqlite3session_attach(pSession, zName);
208909 if( rc==SQLITE_OK ){
208910 for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext);
 
 
 
 
208911 assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );
208912 }
208913 }
208914 }
208915
@@ -209678,10 +209751,11 @@
209678 int bNoop = 1; /* Set to zero if any values are modified */
209679 int nRewind = pBuf->nBuf; /* Set to zero if any values are modified */
209680 int i; /* Used to iterate through columns */
209681 u8 *pCsr = p->aRecord; /* Used to iterate through old.* values */
209682
 
209683 sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);
209684 sessionAppendByte(pBuf, p->bIndirect, &rc);
209685 for(i=0; i<sqlite3_column_count(pStmt); i++){
209686 int bChanged = 0;
209687 int nAdvance;
@@ -209982,16 +210056,18 @@
209982 sqlite3 *db = pSession->db; /* Source database handle */
209983 SessionTable *pTab; /* Used to iterate through attached tables */
209984 SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */
209985 int rc; /* Return code */
209986
209987 assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) );
 
209988
209989 /* Zero the output variables in case an error occurs. If this session
209990 ** object is already in the error state (sqlite3_session.rc != SQLITE_OK),
209991 ** this call will be a no-op. */
209992 if( xOutput==0 ){
 
209993 *pnChangeset = 0;
209994 *ppChangeset = 0;
209995 }
209996
209997 if( pSession->rc ) return pSession->rc;
@@ -210001,12 +210077,12 @@
210001 sqlite3_mutex_enter(sqlite3_db_mutex(db));
210002
210003 for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
210004 if( pTab->nEntry ){
210005 const char *zName = pTab->zName;
210006 int nCol; /* Number of columns in table */
210007 u8 *abPK; /* Primary key array */
210008 const char **azCol = 0; /* Table columns */
210009 int i; /* Used to iterate through hash buckets */
210010 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
210011 int nRewind = buf.nBuf; /* Initial size of write buffer */
210012 int nNoop; /* Size of buffer after writing tbl header */
@@ -210040,10 +210116,11 @@
210040 sessionAppendByte(&buf, p->bIndirect, &rc);
210041 for(iCol=0; iCol<nCol; iCol++){
210042 sessionAppendCol(&buf, pSel, iCol, &rc);
210043 }
210044 }else{
 
210045 rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);
210046 }
210047 }else if( p->op!=SQLITE_INSERT ){
210048 rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);
210049 }
@@ -210100,11 +210177,14 @@
210100 SQLITE_API int sqlite3session_changeset(
210101 sqlite3_session *pSession, /* Session object */
210102 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
210103 void **ppChangeset /* OUT: Buffer containing changeset */
210104 ){
210105 int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
 
 
 
210106 assert( rc || pnChangeset==0
210107 || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
210108 );
210109 return rc;
210110 }
@@ -210115,10 +210195,11 @@
210115 SQLITE_API int sqlite3session_changeset_strm(
210116 sqlite3_session *pSession,
210117 int (*xOutput)(void *pOut, const void *pData, int nData),
210118 void *pOut
210119 ){
 
210120 return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);
210121 }
210122
210123 /*
210124 ** Streaming version of sqlite3session_patchset().
@@ -210126,10 +210207,11 @@
210126 SQLITE_API int sqlite3session_patchset_strm(
210127 sqlite3_session *pSession,
210128 int (*xOutput)(void *pOut, const void *pData, int nData),
210129 void *pOut
210130 ){
 
210131 return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);
210132 }
210133
210134 /*
210135 ** Obtain a patchset object containing all changes recorded by the
@@ -210141,10 +210223,11 @@
210141 SQLITE_API int sqlite3session_patchset(
210142 sqlite3_session *pSession, /* Session object */
210143 int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */
210144 void **ppPatchset /* OUT: Buffer containing changeset */
210145 ){
 
210146 return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);
210147 }
210148
210149 /*
210150 ** Enable or disable the session object passed as the first argument.
@@ -211104,15 +211187,15 @@
211104 if( rc!=SQLITE_OK ) goto finished_invert;
211105 }
211106 }
211107
211108 assert( rc==SQLITE_OK );
211109 if( pnInverted ){
211110 *pnInverted = sOut.nBuf;
211111 *ppInverted = sOut.aBuf;
211112 sOut.aBuf = 0;
211113 }else if( sOut.nBuf>0 ){
211114 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
211115 }
211116
211117 finished_invert:
211118 sqlite3_free(sOut.aBuf);
@@ -211564,11 +211647,11 @@
211564 ** in the code below. */
211565 assert( xValue==sqlite3changeset_old || xValue==sqlite3changeset_new );
211566
211567 for(i=0; rc==SQLITE_OK && i<nCol; i++){
211568 if( !abPK || abPK[i] ){
211569 sqlite3_value *pVal;
211570 (void)xValue(pIter, i, &pVal);
211571 if( pVal==0 ){
211572 /* The value in the changeset was "undefined". This indicates a
211573 ** corrupt changeset blob. */
211574 rc = SQLITE_CORRUPT_BKPT;
@@ -212707,13 +212790,13 @@
212707 }
212708
212709 if( rc==SQLITE_OK ){
212710 if( xOutput ){
212711 if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
212712 }else{
212713 *ppOut = buf.aBuf;
212714 *pnOut = buf.nBuf;
212715 buf.aBuf = 0;
212716 }
212717 }
212718 sqlite3_free(buf.aBuf);
212719
@@ -213109,11 +213192,11 @@
213109 if( rc==SQLITE_OK ){
213110 if( xOutput ){
213111 if( sOut.nBuf>0 ){
213112 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
213113 }
213114 }else{
213115 *ppOut = (void*)sOut.aBuf;
213116 *pnOut = sOut.nBuf;
213117 sOut.aBuf = 0;
213118 }
213119 }
@@ -213852,12 +213935,24 @@
213852 #ifndef ArraySize
213853 # define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
213854 #endif
213855
213856 #define testcase(x)
213857 #define ALWAYS(x) 1
213858 #define NEVER(x) 0
 
 
 
 
 
 
 
 
 
 
 
 
213859
213860 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
213861 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
213862
213863 /*
@@ -217846,10 +217941,11 @@
217846
217847 z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);
217848 z = fts5ConfigSkipWhitespace(z);
217849 if( z && *z=='=' ){
217850 bOption = 1;
 
217851 z++;
217852 if( bMustBeCol ) z = 0;
217853 }
217854 z = fts5ConfigSkipWhitespace(z);
217855 if( z && z[0] ){
@@ -217862,11 +217958,15 @@
217862 if( z==0 ){
217863 *pzErr = sqlite3_mprintf("parse error in \"%s\"", zOrig);
217864 rc = SQLITE_ERROR;
217865 }else{
217866 if( bOption ){
217867 rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:"", pzErr);
 
 
 
 
217868 }else{
217869 rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
217870 zOne = 0;
217871 }
217872 }
@@ -218679,10 +218779,11 @@
218679 static i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){
218680 i64 iRet = 0;
218681 int bRetValid = 0;
218682 Fts5ExprTerm *p;
218683
 
218684 assert( pTerm->pSynonym );
218685 assert( bDesc==0 || bDesc==1 );
218686 for(p=pTerm; p; p=p->pSynonym){
218687 if( 0==sqlite3Fts5IterEof(p->pIter) ){
218688 i64 iRowid = p->pIter->iRowid;
@@ -220119,11 +220220,11 @@
220119 /* This happens when parsing a token or quoted phrase that contains
220120 ** no token characters at all. (e.g ... MATCH '""'). */
220121 sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));
220122 }
220123
220124 if( rc==SQLITE_OK ){
220125 /* All the allocations succeeded. Put the expression object together. */
220126 pNew->pIndex = pExpr->pIndex;
220127 pNew->pConfig = pExpr->pConfig;
220128 pNew->nPhrase = 1;
220129 pNew->apExprPhrase[0] = sCtx.pPhrase;
@@ -223638,10 +223739,11 @@
223638 fts5SegIterNextPage(p, pIter);
223639 }
223640
223641 if( p->rc==SQLITE_OK ){
223642 pIter->iLeafOffset = 4;
 
223643 assert_nc( pIter->pLeaf->nn>4 );
223644 assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
223645 pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
223646 fts5SegIterLoadTerm(p, pIter, 0);
223647 fts5SegIterLoadNPos(p, pIter);
@@ -224598,11 +224700,11 @@
224598 pIter->pNextLeaf = 0;
224599 pIter->iLeafPgno = iLeafPgno-1;
224600 fts5SegIterNextPage(p, pIter);
224601 assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );
224602
224603 if( p->rc==SQLITE_OK ){
224604 int iOff;
224605 u8 *a = pIter->pLeaf->p;
224606 int n = pIter->pLeaf->szLeaf;
224607
224608 iOff = fts5LeafFirstRowidOff(pIter->pLeaf);
@@ -225030,11 +225132,15 @@
225030 Fts5Index *p,
225031 Fts5SegIter *pSeg,
225032 Fts5Colset *pColset,
225033 Fts5Buffer *pBuf
225034 ){
 
 
225035 if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
 
 
225036 memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);
225037 if( pColset==0 ){
225038 fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);
225039 }else{
225040 if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){
@@ -225254,10 +225360,11 @@
225254 pIter->base.nData = pIter->poslist.n;
225255 }
225256 }
225257
225258 static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){
 
225259 if( *pRc==SQLITE_OK ){
225260 Fts5Config *pConfig = pIter->pIndex->pConfig;
225261 if( pConfig->eDetail==FTS5_DETAIL_NONE ){
225262 pIter->xSetOutputs = fts5IterSetOutputs_None;
225263 }
@@ -225325,11 +225432,14 @@
225325 }else{
225326 nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);
225327 }
225328 }
225329 *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
225330 if( pNew==0 ) return;
 
 
 
225331 pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
225332 pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
225333 pNew->pColset = pColset;
225334 if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
225335 fts5IterSetOutputCb(&p->rc, pNew);
@@ -225389,10 +225499,14 @@
225389
225390 }else{
225391 fts5MultiIterFree(pNew);
225392 *ppOut = 0;
225393 }
 
 
 
 
225394 }
225395
225396 /*
225397 ** Create an Fts5Iter that iterates through the doclist provided
225398 ** as the second argument.
@@ -225436,11 +225550,12 @@
225436 /*
225437 ** Return true if the iterator is at EOF or if an error has occurred.
225438 ** False otherwise.
225439 */
225440 static int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){
225441 assert( p->rc
 
225442 || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof
225443 );
225444 return (p->rc || pIter->base.bEof);
225445 }
225446
@@ -226240,10 +226355,11 @@
226240
226241 /* Flush the last leaf page to disk. Set the output segment b-tree height
226242 ** and last leaf page number at the same time. */
226243 fts5WriteFinish(p, &writer, &pSeg->pgnoLast);
226244
 
226245 if( fts5MultiIterEof(p, pIter) ){
226246 int i;
226247
226248 /* Remove the redundant segments from the %_data table */
226249 for(i=0; i<nInput; i++){
@@ -226340,11 +226456,11 @@
226340 static void fts5IndexAutomerge(
226341 Fts5Index *p, /* FTS5 backend object */
226342 Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */
226343 int nLeaf /* Number of output leaves just written */
226344 ){
226345 if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){
226346 Fts5Structure *pStruct = *ppStruct;
226347 u64 nWrite; /* Initial value of write-counter */
226348 int nWork; /* Number of work-quanta to perform */
226349 int nRem; /* Number of leaf pages left to write */
226350
@@ -227450,15 +227566,19 @@
227450 }
227451 }else{
227452 /* Scan multiple terms in the main index */
227453 int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
227454 fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet);
227455 assert( p->rc!=SQLITE_OK || pRet->pColset==0 );
227456 fts5IterSetOutputCb(&p->rc, pRet);
227457 if( p->rc==SQLITE_OK ){
227458 Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
227459 if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
 
 
 
 
227460 }
227461 }
227462
227463 if( p->rc ){
227464 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
@@ -227702,11 +227822,11 @@
227702 int eDetail = p->pConfig->eDetail;
227703 u64 cksum = *pCksum;
227704 Fts5IndexIter *pIter = 0;
227705 int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);
227706
227707 while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){
227708 i64 rowid = pIter->iRowid;
227709
227710 if( eDetail==FTS5_DETAIL_NONE ){
227711 cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n);
227712 }else{
@@ -228067,10 +228187,11 @@
228067 int eDetail = p->pConfig->eDetail;
228068 u64 cksum2 = 0; /* Checksum based on contents of indexes */
228069 Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
228070 Fts5Iter *pIter; /* Used to iterate through entire index */
228071 Fts5Structure *pStruct; /* Index structure */
 
228072
228073 #ifdef SQLITE_DEBUG
228074 /* Used by extra internal tests only run if NDEBUG is not defined */
228075 u64 cksum3 = 0; /* Checksum based on contents of indexes */
228076 Fts5Buffer term = {0,0,0}; /* Buffer used to hold most recent term */
@@ -228077,19 +228198,20 @@
228077 #endif
228078 const int flags = FTS5INDEX_QUERY_NOOUTPUT;
228079
228080 /* Load the FTS index structure */
228081 pStruct = fts5StructureRead(p);
 
 
 
 
228082
228083 /* Check that the internal nodes of each segment match the leaves */
228084 if( pStruct ){
228085 int iLvl, iSeg;
228086 for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
228087 for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
228088 Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];
228089 fts5IndexIntegrityCheckSegment(p, pSeg);
228090 }
228091 }
228092 }
228093
228094 /* The cksum argument passed to this function is a checksum calculated
228095 ** based on all expected entries in the FTS index (including prefix index
@@ -230032,11 +230154,12 @@
230032 pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);
230033 rc = sqlite3Fts5StorageStmt(
230034 pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg
230035 );
230036 if( rc==SQLITE_OK ){
230037 if( pCsr->ePlan==FTS5_PLAN_ROWID ){
 
230038 sqlite3_bind_value(pCsr->pStmt, 1, pRowidEq);
230039 }else{
230040 sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);
230041 sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);
230042 }
@@ -231450,11 +231573,11 @@
231450 int nArg, /* Number of args */
231451 sqlite3_value **apUnused /* Function arguments */
231452 ){
231453 assert( nArg==0 );
231454 UNUSED_PARAM2(nArg, apUnused);
231455 sqlite3_result_text(pCtx, "fts5: 2021-10-04 11:10:15 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813", -1, SQLITE_TRANSIENT);
231456 }
231457
231458 /*
231459 ** Return true if zName is the extension on one of the shadow tables used
231460 ** by this module.
@@ -232001,16 +232124,20 @@
232001 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);
232002 for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){
232003 if( pConfig->abUnindexed[iCol-1]==0 ){
232004 const char *zText;
232005 int nText;
 
 
232006 if( pSeek ){
232007 zText = (const char*)sqlite3_column_text(pSeek, iCol);
232008 nText = sqlite3_column_bytes(pSeek, iCol);
232009 }else{
232010 zText = (const char*)sqlite3_value_text(apVal[iCol-1]);
232011 nText = sqlite3_value_bytes(apVal[iCol-1]);
 
 
232012 }
232013 ctx.szCol = 0;
232014 rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT,
232015 zText, nText, (void*)&ctx, fts5StorageInsertCallback
232016 );
@@ -232642,12 +232769,13 @@
232642 sqlite3_stmt *pLookup = 0; /* Statement to query %_docsize */
232643 int rc; /* Return Code */
232644
232645 assert( p->pConfig->bColumnsize );
232646 rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
232647 if( rc==SQLITE_OK ){
232648 int bCorrupt = 1;
 
232649 sqlite3_bind_int64(pLookup, 1, iRowid);
232650 if( SQLITE_ROW==sqlite3_step(pLookup) ){
232651 const u8 *aBlob = sqlite3_column_blob(pLookup, 0);
232652 int nBlob = sqlite3_column_bytes(pLookup, 0);
232653 if( 0==fts5StorageDecodeSizeArray(aCol, nCol, aBlob, nBlob) ){
@@ -232656,10 +232784,12 @@
232656 }
232657 rc = sqlite3_reset(pLookup);
232658 if( bCorrupt && rc==SQLITE_OK ){
232659 rc = FTS5_CORRUPT;
232660 }
 
 
232661 }
232662
232663 return rc;
232664 }
232665
232666
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.37.0"
456 #define SQLITE_VERSION_NUMBER 3037000
457 #define SQLITE_SOURCE_ID "2021-10-06 10:36:56 566e6974892ebd3d3de8d77b24655257a5efe14434c553e1a25fc680b201b336"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -13194,10 +13194,18 @@
13194 # define VVA_ONLY(X) X
13195 #else
13196 # define VVA_ONLY(X)
13197 #endif
13198
13199 /*
13200 ** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage
13201 ** and mutation testing
13202 */
13203 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
13204 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
13205 #endif
13206
13207 /*
13208 ** The ALWAYS and NEVER macros surround boolean expressions which
13209 ** are intended to always be true or false, respectively. Such
13210 ** expressions could be omitted from the code completely. But they
13211 ** are included in a few cases in order to enhance the resilience
@@ -13209,11 +13217,11 @@
13217 **
13218 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
13219 ** be true and false so that the unreachable code they specify will
13220 ** not be counted as untested code.
13221 */
13222 #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
13223 # define ALWAYS(X) (1)
13224 # define NEVER(X) (0)
13225 #elif !defined(NDEBUG)
13226 # define ALWAYS(X) ((X)?1:(assert(0),0))
13227 # define NEVER(X) ((X)?(assert(0),1):0)
@@ -23573,11 +23581,11 @@
23581
23582 computeJD(&x);
23583 computeYMD_HMS(&x);
23584 for(i=j=0; zFmt[i]; i++){
23585 if( zFmt[i]!='%' ) continue;
23586 if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j));
23587 i++;
23588 j = i + 1;
23589 switch( zFmt[i] ){
23590 case 'd': {
23591 sqlite3_str_appendf(&sRes, "%02d", x.D);
@@ -23649,11 +23657,11 @@
23657 sqlite3_str_reset(&sRes);
23658 return;
23659 }
23660 }
23661 }
23662 if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j));
23663 sqlite3ResultStrAccum(context, &sRes);
23664 }
23665
23666 /*
23667 ** current_time()
@@ -49576,11 +49584,11 @@
49584 /* NULL pBitvec tests */
49585 sqlite3BitvecSet(0, 1);
49586 sqlite3BitvecClear(0, 1, pTmpSpace);
49587
49588 /* Run the program */
49589 pc = i = 0;
49590 while( (op = aOp[pc])!=0 ){
49591 switch( op ){
49592 case 1:
49593 case 2:
49594 case 5: {
@@ -55500,10 +55508,11 @@
55508 ** routine which only updates the change-counter if the update is actually
55509 ** needed, as determined by the pPager->changeCountDone state variable.
55510 */
55511 static void pager_write_changecounter(PgHdr *pPg){
55512 u32 change_counter;
55513 if( NEVER(pPg==0) ) return;
55514
55515 /* Increment the value just read and write it back to byte 24. */
55516 change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;
55517 put32bits(((char*)pPg->pData)+24, change_counter);
55518
@@ -68477,11 +68486,10 @@
68486 static int lockBtree(BtShared *pBt){
68487 int rc; /* Result code from subfunctions */
68488 MemPage *pPage1; /* Page 1 of the database file */
68489 u32 nPage; /* Number of pages in the database */
68490 u32 nPageFile = 0; /* Number of pages in the database file */
 
68491
68492 assert( sqlite3_mutex_held(pBt->mutex) );
68493 assert( pBt->pPage1==0 );
68494 rc = sqlite3PagerSharedLock(pBt->pPager);
68495 if( rc!=SQLITE_OK ) return rc;
@@ -68489,11 +68497,11 @@
68497 if( rc!=SQLITE_OK ) return rc;
68498
68499 /* Do some checking to help insure the file we opened really is
68500 ** a valid database file.
68501 */
68502 nPage = get4byte(28+(u8*)pPage1->aData);
68503 sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);
68504 if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
68505 nPage = nPageFile;
68506 }
68507 if( (pBt->db->flags & SQLITE_ResetDatabase)!=0 ){
@@ -73069,15 +73077,14 @@
73077 Pgno pgno; /* Temp var to store a page number in */
73078 u8 abDone[NB+2]; /* True after i'th new page is populated */
73079 Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */
73080 Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */
73081 u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */
73082 CellArray b; /* Parsed information on cells being balanced */
73083
73084 memset(abDone, 0, sizeof(abDone));
73085 memset(&b, 0, sizeof(b));
 
73086 pBt = pParent->pBt;
73087 assert( sqlite3_mutex_held(pBt->mutex) );
73088 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
73089
73090 /* At this point pParent may have at most one overflow cell. And if
@@ -73884,11 +73891,11 @@
73891
73892 /*
73893 ** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid
73894 ** on the same B-tree as pCur.
73895 **
73896 ** This can occur if a database is corrupt with two or more SQL tables
73897 ** pointing to the same b-tree. If an insert occurs on one SQL table
73898 ** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL
73899 ** table linked to the same b-tree. If the secondary insert causes a
73900 ** rebalance, that can change content out from under the cursor on the
73901 ** first SQL table, violating invariants on the first insert.
@@ -77209,10 +77216,11 @@
77216 */
77217 SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
77218 #ifndef SQLITE_OMIT_UTF16
77219 int rc;
77220 #endif
77221 assert( pMem!=0 );
77222 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77223 assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE
77224 || desiredEnc==SQLITE_UTF16BE );
77225 if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
77226 return SQLITE_OK;
@@ -77341,10 +77349,11 @@
77349 ** MEM.zMalloc, where it can be safely written.
77350 **
77351 ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.
77352 */
77353 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
77354 assert( pMem!=0 );
77355 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77356 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77357 if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
77358 if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
77359 if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
@@ -77365,10 +77374,11 @@
77374 ** blob stored in dynamically allocated space.
77375 */
77376 #ifndef SQLITE_OMIT_INCRBLOB
77377 SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
77378 int nByte;
77379 assert( pMem!=0 );
77380 assert( pMem->flags & MEM_Zero );
77381 assert( (pMem->flags&MEM_Blob)!=0 || MemNullNochng(pMem) );
77382 testcase( sqlite3_value_nochange(pMem) );
77383 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77384 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -77392,10 +77402,11 @@
77402
77403 /*
77404 ** Make sure the given Mem is \u0000 terminated.
77405 */
77406 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
77407 assert( pMem!=0 );
77408 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77409 testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
77410 testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
77411 if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
77412 return SQLITE_OK; /* Nothing to do */
@@ -77419,10 +77430,11 @@
77430 ** user and the latter is an internal programming error.
77431 */
77432 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
77433 const int nByte = 32;
77434
77435 assert( pMem!=0 );
77436 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77437 assert( !(pMem->flags&MEM_Zero) );
77438 assert( !(pMem->flags&(MEM_Str|MEM_Blob)) );
77439 assert( pMem->flags&(MEM_Int|MEM_Real|MEM_IntReal) );
77440 assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -77454,10 +77466,11 @@
77466 */
77467 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
77468 sqlite3_context ctx;
77469 Mem t;
77470 assert( pFunc!=0 );
77471 assert( pMem!=0 );
77472 assert( pFunc->xFinalize!=0 );
77473 assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
77474 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77475 memset(&ctx, 0, sizeof(ctx));
77476 memset(&t, 0, sizeof(t));
@@ -77604,10 +77617,11 @@
77617 sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
77618 return value;
77619 }
77620 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
77621 int flags;
77622 assert( pMem!=0 );
77623 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77624 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77625 flags = pMem->flags;
77626 if( flags & (MEM_Int|MEM_IntReal) ){
77627 testcase( flags & MEM_IntReal );
@@ -77632,10 +77646,11 @@
77646 double val = (double)0;
77647 sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
77648 return val;
77649 }
77650 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
77651 assert( pMem!=0 );
77652 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77653 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77654 if( pMem->flags & MEM_Real ){
77655 return pMem->u.r;
77656 }else if( pMem->flags & (MEM_Int|MEM_IntReal) ){
@@ -77664,10 +77679,11 @@
77679 ** The MEM structure is already a MEM_Real. Try to also make it a
77680 ** MEM_Int if we can.
77681 */
77682 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
77683 i64 ix;
77684 assert( pMem!=0 );
77685 assert( pMem->flags & MEM_Real );
77686 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77687 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77688 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77689
@@ -77691,10 +77707,11 @@
77707
77708 /*
77709 ** Convert pMem to type integer. Invalidate any prior representations.
77710 */
77711 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
77712 assert( pMem!=0 );
77713 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77714 assert( !sqlite3VdbeMemIsRowSet(pMem) );
77715 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77716
77717 pMem->u.i = sqlite3VdbeIntValue(pMem);
@@ -77705,10 +77722,11 @@
77722 /*
77723 ** Convert pMem so that it is of type MEM_Real.
77724 ** Invalidate any prior representations.
77725 */
77726 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
77727 assert( pMem!=0 );
77728 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
77729 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
77730
77731 pMem->u.r = sqlite3VdbeRealValue(pMem);
77732 MemSetTypeFlag(pMem, MEM_Real);
@@ -77738,10 +77756,11 @@
77756 ** Every effort is made to force the conversion, even if the input
77757 ** is a string that does not look completely like a number. Convert
77758 ** as much of the string as we can and ignore the rest.
77759 */
77760 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
77761 assert( pMem!=0 );
77762 testcase( pMem->flags & MEM_Int );
77763 testcase( pMem->flags & MEM_Real );
77764 testcase( pMem->flags & MEM_IntReal );
77765 testcase( pMem->flags & MEM_Null );
77766 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){
@@ -78089,10 +78108,11 @@
78108 ){
78109 i64 nByte = n; /* New value for pMem->n */
78110 int iLimit; /* Maximum allowed string or blob size */
78111 u16 flags = 0; /* New value for pMem->flags */
78112
78113 assert( pMem!=0 );
78114 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
78115 assert( !sqlite3VdbeMemIsRowSet(pMem) );
78116
78117 /* If z is a NULL pointer, set pMem to contain an SQL NULL. */
78118 if( !z ){
@@ -79162,12 +79182,14 @@
79182 assert( p->iVdbeMagic==VDBE_MAGIC_INIT );
79183 assert( op>=0 && op<0xff );
79184 if( p->nOpAlloc<=i ){
79185 return growOp3(p, op, p1, p2, p3);
79186 }
79187 assert( p->aOp!=0 );
79188 p->nOp++;
79189 pOp = &p->aOp[i];
79190 assert( pOp!=0 );
79191 pOp->opcode = (u8)op;
79192 pOp->p5 = 0;
79193 pOp->p1 = p1;
79194 pOp->p2 = p2;
79195 pOp->p3 = p3;
@@ -80406,11 +80428,11 @@
80428 zOpName = sqlite3OpcodeName(pOp->opcode);
80429 nOpName = sqlite3Strlen30(zOpName);
80430 if( zOpName[nOpName+1] ){
80431 int seenCom = 0;
80432 char c;
80433 zSynopsis = zOpName + nOpName + 1;
80434 if( strncmp(zSynopsis,"IF ",3)==0 ){
80435 sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3);
80436 zSynopsis = zAlt;
80437 }
80438 for(ii=0; (c = zSynopsis[ii])!=0; ii++){
@@ -91677,11 +91699,11 @@
91699 zDb = db->aDb[pC->iDb].zDbSName;
91700 pTab = pOp->p4.pTab;
91701 assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) );
91702 }else{
91703 pTab = 0;
91704 zDb = 0;
91705 }
91706
91707 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
91708 /* Invoke the pre-update hook, if any */
91709 if( pTab ){
@@ -91830,17 +91852,18 @@
91852 pTab = pOp->p4.pTab;
91853 if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
91854 pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
91855 }
91856 }else{
91857 zDb = 0;
91858 pTab = 0;
91859 }
91860
91861 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
91862 /* Invoke the pre-update-hook if required. */
91863 assert( db->xPreUpdateCallback==0 || pTab==pOp->p4.pTab );
91864 if( db->xPreUpdateCallback && pTab ){
91865 assert( !(opflags & OPFLAG_ISUPDATE)
91866 || HasRowid(pTab)==0
91867 || (aMem[pOp->p3].flags & MEM_Int)
91868 );
91869 sqlite3VdbePreUpdateHook(p, pC,
@@ -91877,11 +91900,11 @@
91900 if( rc ) goto abort_due_to_error;
91901
91902 /* Invoke the update-hook if required. */
91903 if( opflags & OPFLAG_NCHANGE ){
91904 p->nChange++;
91905 if( db->xUpdateCallback && ALWAYS(pTab!=0) && HasRowid(pTab) ){
91906 db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,
91907 pC->movetoTarget);
91908 assert( pC->iDb>=0 );
91909 }
91910 }
@@ -103680,13 +103703,13 @@
103703 case TK_UPLUS: {
103704 rc = sqlite3ExprIsInteger(p->pLeft, pValue);
103705 break;
103706 }
103707 case TK_UMINUS: {
103708 int v = 0;
103709 if( sqlite3ExprIsInteger(p->pLeft, &v) ){
103710 assert( ((unsigned int)v)!=0x80000000 );
103711 *pValue = -v;
103712 rc = 1;
103713 }
103714 break;
103715 }
@@ -105692,11 +105715,11 @@
105715 if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
105716 if( !pColl ) pColl = db->pDfltColl;
105717 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
105718 }
105719 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
105720 if( (pDef->funcFlags & SQLITE_FUNC_OFFSET)!=0 && ALWAYS(pFarg!=0) ){
105721 Expr *pArg = pFarg->a[0].pExpr;
105722 if( pArg->op==TK_COLUMN ){
105723 sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target);
105724 }else{
105725 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
@@ -112049,13 +112072,13 @@
112072 if( pParse->nErr ) goto attach_end;
112073 memset(&sName, 0, sizeof(NameContext));
112074 sName.pParse = pParse;
112075
112076 if(
112077 SQLITE_OK!=resolveAttachExpr(&sName, pFilename) ||
112078 SQLITE_OK!=resolveAttachExpr(&sName, pDbname) ||
112079 SQLITE_OK!=resolveAttachExpr(&sName, pKey)
112080 ){
112081 goto attach_end;
112082 }
112083
112084 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -128871,11 +128894,11 @@
128894 /* iArg: */ 0 },
128895 {/* zName: */ "table_list",
128896 /* ePragTyp: */ PragTyp_TABLE_LIST,
128897 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
128898 /* ColNames: */ 15, 6,
128899 /* iArg: */ 0 },
128900 {/* zName: */ "table_xinfo",
128901 /* ePragTyp: */ PragTyp_TABLE_INFO,
128902 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
128903 /* ColNames: */ 8, 7,
128904 /* iArg: */ 1 },
@@ -134994,11 +135017,11 @@
135017 ** function is responsible for ensuring that this structure is eventually
135018 ** freed.
135019 */
135020 static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
135021 ExprList *pOrderBy = p->pOrderBy;
135022 int nOrderBy = ALWAYS(pOrderBy!=0) ? pOrderBy->nExpr : 0;
135023 sqlite3 *db = pParse->db;
135024 KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);
135025 if( pRet ){
135026 int i;
135027 for(i=0; i<nOrderBy; i++){
@@ -135615,10 +135638,11 @@
135638 Select *pLoop; /* For looping through SELECT statements */
135639 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
135640 int nCol; /* Number of columns in result set */
135641
135642 assert( p->pNext==0 );
135643 assert( p->pEList!=0 );
135644 nCol = p->pEList->nExpr;
135645 pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1);
135646 if( !pKeyInfo ){
135647 rc = SQLITE_NOMEM_BKPT;
135648 goto multi_select_end;
@@ -135966,10 +135990,11 @@
135990 */
135991 if( op!=TK_ALL ){
135992 for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){
135993 struct ExprList_item *pItem;
135994 for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){
135995 assert( pItem!=0 );
135996 assert( pItem->u.x.iOrderByCol>0 );
135997 if( pItem->u.x.iOrderByCol==i ) break;
135998 }
135999 if( j==nOrderBy ){
136000 Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
@@ -135992,10 +136017,11 @@
136017 aPermute = sqlite3DbMallocRawNN(db, sizeof(u32)*(nOrderBy + 1));
136018 if( aPermute ){
136019 struct ExprList_item *pItem;
136020 aPermute[0] = nOrderBy;
136021 for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){
136022 assert( pItem!=0 );
136023 assert( pItem->u.x.iOrderByCol>0 );
136024 assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );
136025 aPermute[i] = pItem->u.x.iOrderByCol - 1;
136026 }
136027 pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
@@ -146974,11 +147000,11 @@
147000 x.pWInfo = pWInfo;
147001 x.db = pWInfo->pParse->db;
147002 for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
147003 i16 iRef = pIdx->aiColumn[iIdxCol];
147004 if( iRef==XN_EXPR ){
147005 assert( aColExpr!=0 && aColExpr->a[iIdxCol].pExpr!=0 );
147006 x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
147007 if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue;
147008 w.xExprCallback = whereIndexExprTransNode;
147009 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
147010 }else if( iRef>=0
@@ -150214,11 +150240,12 @@
150240 if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
150241 continue;
150242 }
150243 }
150244 if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0
150245 && (pX = pTerm->pExpr->pRight, ALWAYS(pX!=0))
150246 && pX->op==TK_COLUMN
150247 && pX->iTable==pScan->aiCur[0]
150248 && pX->iColumn==pScan->aiColumn[0]
150249 ){
150250 testcase( pTerm->eOperator & WO_IS );
150251 continue;
@@ -153969,11 +153996,11 @@
153996 }
153997 } /* End the loop over all WhereLoops from outer-most down to inner-most */
153998 if( obSat==obDone ) return (i8)nOrderBy;
153999 if( !isOrderDistinct ){
154000 for(i=nOrderBy-1; i>0; i--){
154001 Bitmask m = ALWAYS(i<BMS) ? MASKBIT(i) - 1 : 0;
154002 if( (obSat&m)==m ) return i;
154003 }
154004 return 0;
154005 }
154006 return -1;
@@ -154494,13 +154521,13 @@
154521 pWC = &pWInfo->sWC;
154522 pLoop = pBuilder->pNew;
154523 pLoop->wsFlags = 0;
154524 pLoop->nSkip = 0;
154525 pTerm = whereScanInit(&scan, pWC, iCur, -1, WO_EQ|WO_IS, 0);
154526 while( pTerm && pTerm->prereqRight ) pTerm = whereScanNext(&scan);
154527 if( pTerm ){
154528 testcase( pTerm->eOperator & WO_IS );
 
154529 pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
154530 pLoop->aLTerm[0] = pTerm;
154531 pLoop->nLTerm = 1;
154532 pLoop->u.btree.nEq = 1;
154533 /* TUNING: Cost of a rowid lookup is 10 */
@@ -167620,21 +167647,20 @@
167647 void (*xValue)(sqlite3_context*),
167648 void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
167649 FuncDestructor *pDestructor
167650 ){
167651 FuncDef *p;
 
167652 int extraFlags;
167653
167654 assert( sqlite3_mutex_held(db->mutex) );
167655 assert( xValue==0 || xSFunc==0 );
167656 if( zFunctionName==0 /* Must have a valid name */
167657 || (xSFunc!=0 && xFinal!=0) /* Not both xSFunc and xFinal */
167658 || ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */
167659 || ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */
167660 || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)
167661 || (255<sqlite3Strlen30(zFunctionName))
167662 ){
167663 return SQLITE_MISUSE_BKPT;
167664 }
167665
167666 assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
@@ -168897,11 +168923,11 @@
168923 ** This routine does the core work of extracting URI parameters from a
168924 ** database filename for the sqlite3_uri_parameter() interface.
168925 */
168926 static const char *uriParameter(const char *zFilename, const char *zParam){
168927 zFilename += sqlite3Strlen30(zFilename) + 1;
168928 while( ALWAYS(zFilename!=0) && zFilename[0] ){
168929 int x = strcmp(zFilename, zParam);
168930 zFilename += sqlite3Strlen30(zFilename) + 1;
168931 if( x==0 ) return zFilename;
168932 zFilename += sqlite3Strlen30(zFilename) + 1;
168933 }
@@ -170245,11 +170271,11 @@
170271 */
170272 SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){
170273 if( zFilename==0 || N<0 ) return 0;
170274 zFilename = databaseName(zFilename);
170275 zFilename += sqlite3Strlen30(zFilename) + 1;
170276 while( ALWAYS(zFilename) && zFilename[0] && (N--)>0 ){
170277 zFilename += sqlite3Strlen30(zFilename) + 1;
170278 zFilename += sqlite3Strlen30(zFilename) + 1;
170279 }
170280 return zFilename[0] ? zFilename : 0;
170281 }
@@ -170295,11 +170321,11 @@
170321 }
170322 SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){
170323 if( zFilename==0 ) return 0;
170324 zFilename = databaseName(zFilename);
170325 zFilename += sqlite3Strlen30(zFilename) + 1;
170326 while( ALWAYS(zFilename) && zFilename[0] ){
170327 zFilename += sqlite3Strlen30(zFilename) + 1;
170328 zFilename += sqlite3Strlen30(zFilename) + 1;
170329 }
170330 return zFilename + 1;
170331 }
@@ -171599,21 +171625,22 @@
171625 #ifndef SQLITE_AMALGAMATION
171626 /*
171627 ** Macros indicating that conditional expressions are always true or
171628 ** false.
171629 */
171630 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
171631 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
171632 #endif
171633 #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
171634 # define ALWAYS(X) (1)
171635 # define NEVER(X) (0)
171636 #elif !defined(NDEBUG)
171637 # define ALWAYS(X) ((X)?1:(assert(0),0))
171638 # define NEVER(X) ((X)?(assert(0),1):0)
171639 #else
171640 # define ALWAYS(X) (X)
171641 # define NEVER(X) (X)
171642 #endif
171643
171644 /*
171645 ** Internal types used by SQLite.
171646 */
@@ -172125,17 +172152,10 @@
172152 static int fts3EvalNext(Fts3Cursor *pCsr);
172153 static int fts3EvalStart(Fts3Cursor *pCsr);
172154 static int fts3TermSegReaderCursor(
172155 Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
172156
 
 
 
 
 
 
 
172157 /*
172158 ** This variable is set to false when running tests for which the on disk
172159 ** structures should not be corrupt. Otherwise, true. If it is false, extra
172160 ** assert() conditions in the fts3 code are activated - conditions that are
172161 ** only true if it is guaranteed that the fts3 database is not corrupt.
@@ -185824,11 +185844,11 @@
185844
185845 if( nPrefix>p->term.n || nSuffix>p->nNode-p->iOff || nSuffix==0 ){
185846 return FTS_CORRUPT_VTAB;
185847 }
185848 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
185849 if( rc==SQLITE_OK && ALWAYS(p->term.a!=0) ){
185850 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
185851 p->term.n = nPrefix+nSuffix;
185852 p->iOff += nSuffix;
185853 if( p->iChild==0 ){
185854 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
@@ -186218,11 +186238,15 @@
186238 const char *zRhs, int nRhs /* RHS of comparison */
186239 ){
186240 int nCmp = MIN(nLhs, nRhs);
186241 int res;
186242
186243 if( nCmp && ALWAYS(zLhs) && ALWAYS(zRhs) ){
186244 res = memcmp(zLhs, zRhs, nCmp);
186245 }else{
186246 res = 0;
186247 }
186248 if( res==0 ) res = nLhs - nRhs;
186249
186250 return res;
186251 }
186252
@@ -186862,11 +186886,11 @@
186886 const char *aHint = sqlite3_column_blob(pSelect, 0);
186887 int nHint = sqlite3_column_bytes(pSelect, 0);
186888 if( aHint ){
186889 blobGrowBuffer(pHint, nHint, &rc);
186890 if( rc==SQLITE_OK ){
186891 if( ALWAYS(pHint->a!=0) ) memcpy(pHint->a, aHint, nHint);
186892 pHint->n = nHint;
186893 }
186894 }
186895 }
186896 rc2 = sqlite3_reset(pSelect);
@@ -188953,14 +188977,16 @@
188977 ** Advance the iterator passed as an argument to the next position. Return
188978 ** 1 if the iterator is at EOF or if it now points to the start of the
188979 ** position list for the next column.
188980 */
188981 static int fts3LcsIteratorAdvance(LcsIterator *pIter){
188982 char *pRead;
188983 sqlite3_int64 iRead;
188984 int rc = 0;
188985
188986 if( NEVER(pIter==0) ) return 1;
188987 pRead = pIter->pRead;
188988 pRead += sqlite3Fts3GetVarint(pRead, &iRead);
188989 if( iRead==0 || iRead==1 ){
188990 pRead = 0;
188991 rc = 1;
188992 }else{
@@ -190478,10 +190504,23 @@
190504 ** but the definitions need to be repeated for separate compilation. */
190505 typedef sqlite3_uint64 u64;
190506 typedef unsigned int u32;
190507 typedef unsigned short int u16;
190508 typedef unsigned char u8;
190509 # if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
190510 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
190511 # endif
190512 # if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
190513 # define ALWAYS(X) (1)
190514 # define NEVER(X) (0)
190515 # elif !defined(NDEBUG)
190516 # define ALWAYS(X) ((X)?1:(assert(0),0))
190517 # define NEVER(X) ((X)?(assert(0),1):0)
190518 # else
190519 # define ALWAYS(X) (X)
190520 # define NEVER(X) (X)
190521 # endif
190522 #endif
190523
190524 /* Objects */
190525 typedef struct JsonString JsonString;
190526 typedef struct JsonNode JsonNode;
@@ -190820,12 +190859,13 @@
190859 static void jsonRenderNode(
190860 JsonNode *pNode, /* The node to render */
190861 JsonString *pOut, /* Write JSON here */
190862 sqlite3_value **aReplace /* Replacement values */
190863 ){
190864 assert( pNode!=0 );
190865 if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){
190866 if( (pNode->jnFlags & JNODE_REPLACE)!=0 && ALWAYS(aReplace!=0) ){
190867 jsonAppendValue(pOut, aReplace[pNode->u.iReplace]);
190868 return;
190869 }
190870 pNode = pNode->u.pPatch;
190871 }
@@ -191141,11 +191181,11 @@
191181 u32 eType, /* Node type */
191182 u32 n, /* Content size or sub-node count */
191183 const char *zContent /* Content */
191184 ){
191185 JsonNode *p;
191186 if( pParse->aNode==0 || pParse->nNode>=pParse->nAlloc ){
191187 return jsonParseAddNodeExpand(pParse, eType, n, zContent);
191188 }
191189 p = &pParse->aNode[pParse->nNode];
191190 p->eType = (u8)eType;
191191 p->jnFlags = 0;
@@ -193099,10 +193139,13 @@
193139 #endif
193140 #if defined(NDEBUG) && defined(SQLITE_DEBUG)
193141 # undef NDEBUG
193142 #endif
193143 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
193144 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
193145 #endif
193146 #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
193147 # define ALWAYS(X) (1)
193148 # define NEVER(X) (0)
193149 #elif !defined(NDEBUG)
193150 # define ALWAYS(X) ((X)?1:(assert(0),0))
193151 # define NEVER(X) ((X)?(assert(0),1):0)
@@ -193450,11 +193493,16 @@
193493
193494 /* The testcase() macro should already be defined in the amalgamation. If
193495 ** it is not, make it a no-op.
193496 */
193497 #ifndef SQLITE_AMALGAMATION
193498 # ifdef SQLITE_COVERAGE_TEST
193499 unsigned int sqlite3RtreeTestcase = 0;
193500 # define testcase(X) if( X ){ sqlite3RtreeTestcase += __LINE__; }
193501 # else
193502 # define testcase(X)
193503 # endif
193504 #endif
193505
193506 /*
193507 ** Make sure that the compiler intrinsics we desire are enabled when
193508 ** compiling with an appropriate version of MSVC unless prevented by
@@ -195214,11 +195262,11 @@
195262 RtreeDValue fMinGrowth = RTREE_ZERO;
195263 RtreeDValue fMinArea = RTREE_ZERO;
195264
195265 int nCell = NCELL(pNode);
195266 RtreeCell cell;
195267 RtreeNode *pChild = 0;
195268
195269 RtreeCell *aCell = 0;
195270
195271 /* Select the child node which will be enlarged the least if pCell
195272 ** is inserted into it. Resolve ties by choosing the entry with
@@ -195572,10 +195620,11 @@
195620 nodeRelease(pRtree, pChild->pParent);
195621 nodeReference(pNode);
195622 pChild->pParent = pNode;
195623 }
195624 }
195625 if( NEVER(pNode==0) ) return SQLITE_ERROR;
195626 return xSetMapping(pRtree, iRowid, pNode->iNode);
195627 }
195628
195629 static int SplitNode(
195630 Rtree *pRtree,
@@ -196876,10 +196925,11 @@
196925 tree.nDim = (u8)sqlite3_value_int(apArg[0]);
196926 if( tree.nDim<1 || tree.nDim>5 ) return;
196927 tree.nDim2 = tree.nDim*2;
196928 tree.nBytesPerCell = 8 + 8 * tree.nDim;
196929 node.zData = (u8 *)sqlite3_value_blob(apArg[1]);
196930 if( node.zData==0 ) return;
196931 nData = sqlite3_value_bytes(apArg[1]);
196932 if( nData<4 ) return;
196933 if( nData<NCELL(&node)*tree.nBytesPerCell ) return;
196934
196935 pOut = sqlite3_str_new(0);
@@ -197707,17 +197757,18 @@
197757 sqlite3_value *pVal, /* The value to decode */
197758 int *pRc /* Write error here */
197759 ){
197760 GeoPoly *p = 0;
197761 int nByte;
197762 testcase( pCtx==0 );
197763 if( sqlite3_value_type(pVal)==SQLITE_BLOB
197764 && (nByte = sqlite3_value_bytes(pVal))>=(4+6*sizeof(GeoCoord))
197765 ){
197766 const unsigned char *a = sqlite3_value_blob(pVal);
197767 int nVertex;
197768 if( a==0 ){
197769 if( pCtx ) sqlite3_result_error_nomem(pCtx);
197770 return 0;
197771 }
197772 nVertex = (a[1]<<16) + (a[2]<<8) + a[3];
197773 if( (a[0]==0 || a[0]==1)
197774 && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte
@@ -198540,15 +198591,15 @@
198591 pActive = pSeg;
198592 needSort = 1;
198593 }else{
198594 /* Remove a segment */
198595 if( pActive==pThisEvent->pSeg ){
198596 pActive = ALWAYS(pActive) ? pActive->pNext : 0;
198597 }else{
198598 for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){
198599 if( pSeg->pNext==pThisEvent->pSeg ){
198600 pSeg->pNext = ALWAYS(pSeg->pNext) ? pSeg->pNext->pNext : 0;
198601 break;
198602 }
198603 }
198604 }
198605 }
@@ -198788,10 +198839,11 @@
198839 rc = nodeAcquire(pRtree, 1, 0, &pRoot);
198840 if( rc==SQLITE_OK && idxNum<=3 ){
198841 RtreeCoord bbox[4];
198842 RtreeConstraint *p;
198843 assert( argc==1 );
198844 assert( argv[0]!=0 );
198845 geopolyBBox(0, argv[0], bbox, &rc);
198846 if( rc ){
198847 goto geopoly_filter_end;
198848 }
198849 pCsr->aConstraint = p = sqlite3_malloc(sizeof(RtreeConstraint)*4);
@@ -199015,10 +199067,11 @@
199067 if( nData>1 /* not a DELETE */
199068 && (!oldRowidValid /* INSERT */
199069 || !sqlite3_value_nochange(aData[2]) /* UPDATE _shape */
199070 || oldRowid!=newRowid) /* Rowid change */
199071 ){
199072 assert( aData[2]!=0 );
199073 geopolyBBox(0, aData[2], cell.aCoord, &rc);
199074 if( rc ){
199075 if( rc==SQLITE_ERROR ){
199076 pVtab->zErrMsg =
199077 sqlite3_mprintf("_shape does not contain a valid polygon");
@@ -207873,11 +207926,11 @@
207926 if( z==0 && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;
207927 nVarint = sessionVarintLen(n);
207928
207929 if( aBuf ){
207930 sessionVarintPut(&aBuf[1], n);
207931 if( n>0 ) memcpy(&aBuf[nVarint + 1], z, n);
207932 }
207933
207934 nByte = 1 + nVarint + n;
207935 break;
207936 }
@@ -208478,20 +208531,36 @@
208531 "SELECT 2, 'stat', '', 0, '', 0"
208532 );
208533 }else if( rc==SQLITE_ERROR ){
208534 zPragma = sqlite3_mprintf("");
208535 }else{
208536 *pazCol = 0;
208537 *pabPK = 0;
208538 *pnCol = 0;
208539 if( pzTab ) *pzTab = 0;
208540 return rc;
208541 }
208542 }else{
208543 zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
208544 }
208545 if( !zPragma ){
208546 *pazCol = 0;
208547 *pabPK = 0;
208548 *pnCol = 0;
208549 if( pzTab ) *pzTab = 0;
208550 return SQLITE_NOMEM;
208551 }
208552
208553 rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);
208554 sqlite3_free(zPragma);
208555 if( rc!=SQLITE_OK ){
208556 *pazCol = 0;
208557 *pabPK = 0;
208558 *pnCol = 0;
208559 if( pzTab ) *pzTab = 0;
208560 return rc;
208561 }
208562
208563 nByte = nThis + 1;
208564 while( SQLITE_ROW==sqlite3_step(pStmt) ){
208565 nByte += sqlite3_column_bytes(pStmt, 1);
208566 nDbCol++;
@@ -208905,11 +208974,15 @@
208974 if( pSession->xTableFilter==0
208975 || pSession->xTableFilter(pSession->pFilterCtx, zName)
208976 ){
208977 rc = sqlite3session_attach(pSession, zName);
208978 if( rc==SQLITE_OK ){
208979 pRet = pSession->pTable;
208980 while( ALWAYS(pRet) && pRet->pNext ){
208981 pRet = pRet->pNext;
208982 }
208983 assert( pRet!=0 );
208984 assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );
208985 }
208986 }
208987 }
208988
@@ -209678,10 +209751,11 @@
209751 int bNoop = 1; /* Set to zero if any values are modified */
209752 int nRewind = pBuf->nBuf; /* Set to zero if any values are modified */
209753 int i; /* Used to iterate through columns */
209754 u8 *pCsr = p->aRecord; /* Used to iterate through old.* values */
209755
209756 assert( abPK!=0 );
209757 sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);
209758 sessionAppendByte(pBuf, p->bIndirect, &rc);
209759 for(i=0; i<sqlite3_column_count(pStmt); i++){
209760 int bChanged = 0;
209761 int nAdvance;
@@ -209982,16 +210056,18 @@
210056 sqlite3 *db = pSession->db; /* Source database handle */
210057 SessionTable *pTab; /* Used to iterate through attached tables */
210058 SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */
210059 int rc; /* Return code */
210060
210061 assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0) );
210062 assert( xOutput!=0 || (pnChangeset!=0 && ppChangeset!=0) );
210063
210064 /* Zero the output variables in case an error occurs. If this session
210065 ** object is already in the error state (sqlite3_session.rc != SQLITE_OK),
210066 ** this call will be a no-op. */
210067 if( xOutput==0 ){
210068 assert( pnChangeset!=0 && ppChangeset!=0 );
210069 *pnChangeset = 0;
210070 *ppChangeset = 0;
210071 }
210072
210073 if( pSession->rc ) return pSession->rc;
@@ -210001,12 +210077,12 @@
210077 sqlite3_mutex_enter(sqlite3_db_mutex(db));
210078
210079 for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
210080 if( pTab->nEntry ){
210081 const char *zName = pTab->zName;
210082 int nCol = 0; /* Number of columns in table */
210083 u8 *abPK = 0; /* Primary key array */
210084 const char **azCol = 0; /* Table columns */
210085 int i; /* Used to iterate through hash buckets */
210086 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
210087 int nRewind = buf.nBuf; /* Initial size of write buffer */
210088 int nNoop; /* Size of buffer after writing tbl header */
@@ -210040,10 +210116,11 @@
210116 sessionAppendByte(&buf, p->bIndirect, &rc);
210117 for(iCol=0; iCol<nCol; iCol++){
210118 sessionAppendCol(&buf, pSel, iCol, &rc);
210119 }
210120 }else{
210121 assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */
210122 rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);
210123 }
210124 }else if( p->op!=SQLITE_INSERT ){
210125 rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);
210126 }
@@ -210100,11 +210177,14 @@
210177 SQLITE_API int sqlite3session_changeset(
210178 sqlite3_session *pSession, /* Session object */
210179 int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
210180 void **ppChangeset /* OUT: Buffer containing changeset */
210181 ){
210182 int rc;
210183
210184 if( pnChangeset==0 || ppChangeset==0 ) return SQLITE_MISUSE;
210185 rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
210186 assert( rc || pnChangeset==0
210187 || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
210188 );
210189 return rc;
210190 }
@@ -210115,10 +210195,11 @@
210195 SQLITE_API int sqlite3session_changeset_strm(
210196 sqlite3_session *pSession,
210197 int (*xOutput)(void *pOut, const void *pData, int nData),
210198 void *pOut
210199 ){
210200 if( xOutput==0 ) return SQLITE_MISUSE;
210201 return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);
210202 }
210203
210204 /*
210205 ** Streaming version of sqlite3session_patchset().
@@ -210126,10 +210207,11 @@
210207 SQLITE_API int sqlite3session_patchset_strm(
210208 sqlite3_session *pSession,
210209 int (*xOutput)(void *pOut, const void *pData, int nData),
210210 void *pOut
210211 ){
210212 if( xOutput==0 ) return SQLITE_MISUSE;
210213 return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);
210214 }
210215
210216 /*
210217 ** Obtain a patchset object containing all changes recorded by the
@@ -210141,10 +210223,11 @@
210223 SQLITE_API int sqlite3session_patchset(
210224 sqlite3_session *pSession, /* Session object */
210225 int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */
210226 void **ppPatchset /* OUT: Buffer containing changeset */
210227 ){
210228 if( pnPatchset==0 || ppPatchset==0 ) return SQLITE_MISUSE;
210229 return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);
210230 }
210231
210232 /*
210233 ** Enable or disable the session object passed as the first argument.
@@ -211104,15 +211187,15 @@
211187 if( rc!=SQLITE_OK ) goto finished_invert;
211188 }
211189 }
211190
211191 assert( rc==SQLITE_OK );
211192 if( pnInverted && ALWAYS(ppInverted) ){
211193 *pnInverted = sOut.nBuf;
211194 *ppInverted = sOut.aBuf;
211195 sOut.aBuf = 0;
211196 }else if( sOut.nBuf>0 && ALWAYS(xOutput!=0) ){
211197 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
211198 }
211199
211200 finished_invert:
211201 sqlite3_free(sOut.aBuf);
@@ -211564,11 +211647,11 @@
211647 ** in the code below. */
211648 assert( xValue==sqlite3changeset_old || xValue==sqlite3changeset_new );
211649
211650 for(i=0; rc==SQLITE_OK && i<nCol; i++){
211651 if( !abPK || abPK[i] ){
211652 sqlite3_value *pVal = 0;
211653 (void)xValue(pIter, i, &pVal);
211654 if( pVal==0 ){
211655 /* The value in the changeset was "undefined". This indicates a
211656 ** corrupt changeset blob. */
211657 rc = SQLITE_CORRUPT_BKPT;
@@ -212707,13 +212790,13 @@
212790 }
212791
212792 if( rc==SQLITE_OK ){
212793 if( xOutput ){
212794 if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
212795 }else if( ppOut ){
212796 *ppOut = buf.aBuf;
212797 if( pnOut ) *pnOut = buf.nBuf;
212798 buf.aBuf = 0;
212799 }
212800 }
212801 sqlite3_free(buf.aBuf);
212802
@@ -213109,11 +213192,11 @@
213192 if( rc==SQLITE_OK ){
213193 if( xOutput ){
213194 if( sOut.nBuf>0 ){
213195 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
213196 }
213197 }else if( ppOut ){
213198 *ppOut = (void*)sOut.aBuf;
213199 *pnOut = sOut.nBuf;
213200 sOut.aBuf = 0;
213201 }
213202 }
@@ -213852,12 +213935,24 @@
213935 #ifndef ArraySize
213936 # define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
213937 #endif
213938
213939 #define testcase(x)
213940
213941 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
213942 # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
213943 #endif
213944 #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
213945 # define ALWAYS(X) (1)
213946 # define NEVER(X) (0)
213947 #elif !defined(NDEBUG)
213948 # define ALWAYS(X) ((X)?1:(assert(0),0))
213949 # define NEVER(X) ((X)?(assert(0),1):0)
213950 #else
213951 # define ALWAYS(X) (X)
213952 # define NEVER(X) (X)
213953 #endif
213954
213955 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
213956 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
213957
213958 /*
@@ -217846,10 +217941,11 @@
217941
217942 z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);
217943 z = fts5ConfigSkipWhitespace(z);
217944 if( z && *z=='=' ){
217945 bOption = 1;
217946 assert( zOne!=0 );
217947 z++;
217948 if( bMustBeCol ) z = 0;
217949 }
217950 z = fts5ConfigSkipWhitespace(z);
217951 if( z && z[0] ){
@@ -217862,11 +217958,15 @@
217958 if( z==0 ){
217959 *pzErr = sqlite3_mprintf("parse error in \"%s\"", zOrig);
217960 rc = SQLITE_ERROR;
217961 }else{
217962 if( bOption ){
217963 rc = fts5ConfigParseSpecial(pGlobal, pRet,
217964 ALWAYS(zOne)?zOne:"",
217965 zTwo?zTwo:"",
217966 pzErr
217967 );
217968 }else{
217969 rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
217970 zOne = 0;
217971 }
217972 }
@@ -218679,10 +218779,11 @@
218779 static i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){
218780 i64 iRet = 0;
218781 int bRetValid = 0;
218782 Fts5ExprTerm *p;
218783
218784 assert( pTerm );
218785 assert( pTerm->pSynonym );
218786 assert( bDesc==0 || bDesc==1 );
218787 for(p=pTerm; p; p=p->pSynonym){
218788 if( 0==sqlite3Fts5IterEof(p->pIter) ){
218789 i64 iRowid = p->pIter->iRowid;
@@ -220119,11 +220220,11 @@
220220 /* This happens when parsing a token or quoted phrase that contains
220221 ** no token characters at all. (e.g ... MATCH '""'). */
220222 sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));
220223 }
220224
220225 if( rc==SQLITE_OK && ALWAYS(sCtx.pPhrase) ){
220226 /* All the allocations succeeded. Put the expression object together. */
220227 pNew->pIndex = pExpr->pIndex;
220228 pNew->pConfig = pExpr->pConfig;
220229 pNew->nPhrase = 1;
220230 pNew->apExprPhrase[0] = sCtx.pPhrase;
@@ -223638,10 +223739,11 @@
223739 fts5SegIterNextPage(p, pIter);
223740 }
223741
223742 if( p->rc==SQLITE_OK ){
223743 pIter->iLeafOffset = 4;
223744 assert( pIter->pLeaf!=0 );
223745 assert_nc( pIter->pLeaf->nn>4 );
223746 assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
223747 pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
223748 fts5SegIterLoadTerm(p, pIter, 0);
223749 fts5SegIterLoadNPos(p, pIter);
@@ -224598,11 +224700,11 @@
224700 pIter->pNextLeaf = 0;
224701 pIter->iLeafPgno = iLeafPgno-1;
224702 fts5SegIterNextPage(p, pIter);
224703 assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );
224704
224705 if( p->rc==SQLITE_OK && ALWAYS(pIter->pLeaf!=0) ){
224706 int iOff;
224707 u8 *a = pIter->pLeaf->p;
224708 int n = pIter->pLeaf->szLeaf;
224709
224710 iOff = fts5LeafFirstRowidOff(pIter->pLeaf);
@@ -225030,11 +225132,15 @@
225132 Fts5Index *p,
225133 Fts5SegIter *pSeg,
225134 Fts5Colset *pColset,
225135 Fts5Buffer *pBuf
225136 ){
225137 assert( pBuf!=0 );
225138 assert( pSeg!=0 );
225139 if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
225140 assert( pBuf->p!=0 );
225141 assert( pBuf->nSpace >= pBuf->n+pSeg->nPos+FTS5_DATA_ZERO_PADDING );
225142 memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);
225143 if( pColset==0 ){
225144 fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);
225145 }else{
225146 if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){
@@ -225254,10 +225360,11 @@
225360 pIter->base.nData = pIter->poslist.n;
225361 }
225362 }
225363
225364 static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){
225365 assert( pIter!=0 || (*pRc)!=SQLITE_OK );
225366 if( *pRc==SQLITE_OK ){
225367 Fts5Config *pConfig = pIter->pIndex->pConfig;
225368 if( pConfig->eDetail==FTS5_DETAIL_NONE ){
225369 pIter->xSetOutputs = fts5IterSetOutputs_None;
225370 }
@@ -225325,11 +225432,14 @@
225432 }else{
225433 nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);
225434 }
225435 }
225436 *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
225437 if( pNew==0 ){
225438 assert( p->rc!=SQLITE_OK );
225439 goto fts5MultiIterNew_post_check;
225440 }
225441 pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
225442 pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
225443 pNew->pColset = pColset;
225444 if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
225445 fts5IterSetOutputCb(&p->rc, pNew);
@@ -225389,10 +225499,14 @@
225499
225500 }else{
225501 fts5MultiIterFree(pNew);
225502 *ppOut = 0;
225503 }
225504
225505 fts5MultiIterNew_post_check:
225506 assert( (*ppOut)!=0 || p->rc!=SQLITE_OK );
225507 return;
225508 }
225509
225510 /*
225511 ** Create an Fts5Iter that iterates through the doclist provided
225512 ** as the second argument.
@@ -225436,11 +225550,12 @@
225550 /*
225551 ** Return true if the iterator is at EOF or if an error has occurred.
225552 ** False otherwise.
225553 */
225554 static int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){
225555 assert( pIter!=0 || p->rc!=SQLITE_OK );
225556 assert( p->rc!=SQLITE_OK
225557 || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof
225558 );
225559 return (p->rc || pIter->base.bEof);
225560 }
225561
@@ -226240,10 +226355,11 @@
226355
226356 /* Flush the last leaf page to disk. Set the output segment b-tree height
226357 ** and last leaf page number at the same time. */
226358 fts5WriteFinish(p, &writer, &pSeg->pgnoLast);
226359
226360 assert( pIter!=0 || p->rc!=SQLITE_OK );
226361 if( fts5MultiIterEof(p, pIter) ){
226362 int i;
226363
226364 /* Remove the redundant segments from the %_data table */
226365 for(i=0; i<nInput; i++){
@@ -226340,11 +226456,11 @@
226456 static void fts5IndexAutomerge(
226457 Fts5Index *p, /* FTS5 backend object */
226458 Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */
226459 int nLeaf /* Number of output leaves just written */
226460 ){
226461 if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 && ALWAYS((*ppStruct)!=0) ){
226462 Fts5Structure *pStruct = *ppStruct;
226463 u64 nWrite; /* Initial value of write-counter */
226464 int nWork; /* Number of work-quanta to perform */
226465 int nRem; /* Number of leaf pages left to write */
226466
@@ -227450,15 +227566,19 @@
227566 }
227567 }else{
227568 /* Scan multiple terms in the main index */
227569 int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
227570 fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet);
227571 if( pRet==0 ){
227572 assert( p->rc!=SQLITE_OK );
227573 }else{
227574 assert( pRet->pColset==0 );
227575 fts5IterSetOutputCb(&p->rc, pRet);
227576 if( p->rc==SQLITE_OK ){
227577 Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
227578 if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
227579 }
227580 }
227581 }
227582
227583 if( p->rc ){
227584 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
@@ -227702,11 +227822,11 @@
227822 int eDetail = p->pConfig->eDetail;
227823 u64 cksum = *pCksum;
227824 Fts5IndexIter *pIter = 0;
227825 int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);
227826
227827 while( rc==SQLITE_OK && ALWAYS(pIter!=0) && 0==sqlite3Fts5IterEof(pIter) ){
227828 i64 rowid = pIter->iRowid;
227829
227830 if( eDetail==FTS5_DETAIL_NONE ){
227831 cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n);
227832 }else{
@@ -228067,10 +228187,11 @@
228187 int eDetail = p->pConfig->eDetail;
228188 u64 cksum2 = 0; /* Checksum based on contents of indexes */
228189 Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
228190 Fts5Iter *pIter; /* Used to iterate through entire index */
228191 Fts5Structure *pStruct; /* Index structure */
228192 int iLvl, iSeg;
228193
228194 #ifdef SQLITE_DEBUG
228195 /* Used by extra internal tests only run if NDEBUG is not defined */
228196 u64 cksum3 = 0; /* Checksum based on contents of indexes */
228197 Fts5Buffer term = {0,0,0}; /* Buffer used to hold most recent term */
@@ -228077,19 +228198,20 @@
228198 #endif
228199 const int flags = FTS5INDEX_QUERY_NOOUTPUT;
228200
228201 /* Load the FTS index structure */
228202 pStruct = fts5StructureRead(p);
228203 if( pStruct==0 ){
228204 assert( p->rc!=SQLITE_OK );
228205 return fts5IndexReturn(p);
228206 }
228207
228208 /* Check that the internal nodes of each segment match the leaves */
228209 for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
228210 for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
228211 Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];
228212 fts5IndexIntegrityCheckSegment(p, pSeg);
 
 
 
228213 }
228214 }
228215
228216 /* The cksum argument passed to this function is a checksum calculated
228217 ** based on all expected entries in the FTS index (including prefix index
@@ -230032,11 +230154,12 @@
230154 pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);
230155 rc = sqlite3Fts5StorageStmt(
230156 pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg
230157 );
230158 if( rc==SQLITE_OK ){
230159 if( pRowidEq!=0 ){
230160 assert( pCsr->ePlan==FTS5_PLAN_ROWID );
230161 sqlite3_bind_value(pCsr->pStmt, 1, pRowidEq);
230162 }else{
230163 sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);
230164 sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);
230165 }
@@ -231450,11 +231573,11 @@
231573 int nArg, /* Number of args */
231574 sqlite3_value **apUnused /* Function arguments */
231575 ){
231576 assert( nArg==0 );
231577 UNUSED_PARAM2(nArg, apUnused);
231578 sqlite3_result_text(pCtx, "fts5: 2021-10-05 18:33:38 a7835bead85b1b18a8affd9835240b0baf9c7af887196bbdcc3f5d58055042fc", -1, SQLITE_TRANSIENT);
231579 }
231580
231581 /*
231582 ** Return true if zName is the extension on one of the shadow tables used
231583 ** by this module.
@@ -232001,16 +232124,20 @@
232124 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);
232125 for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){
232126 if( pConfig->abUnindexed[iCol-1]==0 ){
232127 const char *zText;
232128 int nText;
232129 assert( pSeek==0 || apVal==0 );
232130 assert( pSeek!=0 || apVal!=0 );
232131 if( pSeek ){
232132 zText = (const char*)sqlite3_column_text(pSeek, iCol);
232133 nText = sqlite3_column_bytes(pSeek, iCol);
232134 }else if( ALWAYS(apVal) ){
232135 zText = (const char*)sqlite3_value_text(apVal[iCol-1]);
232136 nText = sqlite3_value_bytes(apVal[iCol-1]);
232137 }else{
232138 continue;
232139 }
232140 ctx.szCol = 0;
232141 rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT,
232142 zText, nText, (void*)&ctx, fts5StorageInsertCallback
232143 );
@@ -232642,12 +232769,13 @@
232769 sqlite3_stmt *pLookup = 0; /* Statement to query %_docsize */
232770 int rc; /* Return Code */
232771
232772 assert( p->pConfig->bColumnsize );
232773 rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
232774 if( pLookup ){
232775 int bCorrupt = 1;
232776 assert( rc==SQLITE_OK );
232777 sqlite3_bind_int64(pLookup, 1, iRowid);
232778 if( SQLITE_ROW==sqlite3_step(pLookup) ){
232779 const u8 *aBlob = sqlite3_column_blob(pLookup, 0);
232780 int nBlob = sqlite3_column_bytes(pLookup, 0);
232781 if( 0==fts5StorageDecodeSizeArray(aCol, nCol, aBlob, nBlob) ){
@@ -232656,10 +232784,12 @@
232784 }
232785 rc = sqlite3_reset(pLookup);
232786 if( bCorrupt && rc==SQLITE_OK ){
232787 rc = FTS5_CORRUPT;
232788 }
232789 }else{
232790 assert( rc!=SQLITE_OK );
232791 }
232792
232793 return rc;
232794 }
232795
232796
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.37.0"
150150
#define SQLITE_VERSION_NUMBER 3037000
151
-#define SQLITE_SOURCE_ID "2021-10-04 11:10:15 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813"
151
+#define SQLITE_SOURCE_ID "2021-10-06 10:36:56 566e6974892ebd3d3de8d77b24655257a5efe14434c553e1a25fc680b201b336"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.37.0"
150 #define SQLITE_VERSION_NUMBER 3037000
151 #define SQLITE_SOURCE_ID "2021-10-04 11:10:15 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.37.0"
150 #define SQLITE_VERSION_NUMBER 3037000
151 #define SQLITE_SOURCE_ID "2021-10-06 10:36:56 566e6974892ebd3d3de8d77b24655257a5efe14434c553e1a25fc680b201b336"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

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