Fossil SCM

Update the built-in SQLite to the first 3.36.0 beta.

drh 2021-06-14 15:36 trunk
Commit 3bb3c516f18122fe75b3d62cfe6290193b985c91cfe07d67bad1f8376c410f06
3 files changed +6 -6 +129 -76 +1 -1
+6 -6
--- src/shell.c
+++ src/shell.c
@@ -6204,11 +6204,11 @@
62046204
}
62056205
}
62066206
}
62076207
if( pRe->aOp[x]==RE_OP_CC_EXC ) hit = !hit;
62086208
if( hit ) re_add_state(pNext, x+n);
6209
- break;
6209
+ break;
62106210
}
62116211
}
62126212
}
62136213
}
62146214
for(i=0; i<pNext->nState; i++){
@@ -6365,11 +6365,11 @@
63656365
const char *zErr;
63666366
while( (c = p->xNextChar(&p->sIn))!=0 ){
63676367
iStart = p->nState;
63686368
switch( c ){
63696369
case '|':
6370
- case '$':
6370
+ case '$':
63716371
case ')': {
63726372
p->sIn.i--;
63736373
return 0;
63746374
}
63756375
case '(': {
@@ -6381,11 +6381,11 @@
63816381
}
63826382
case '.': {
63836383
if( rePeek(p)=='*' ){
63846384
re_append(p, RE_OP_ANYSTAR, 0);
63856385
p->sIn.i++;
6386
- }else{
6386
+ }else{
63876387
re_append(p, RE_OP_ANY, 0);
63886388
}
63896389
break;
63906390
}
63916391
case '*': {
@@ -6590,12 +6590,12 @@
65906590
** A REGEXP B
65916591
**
65926592
** is implemented as regexp(B,A).
65936593
*/
65946594
static void re_sql_func(
6595
- sqlite3_context *context,
6596
- int argc,
6595
+ sqlite3_context *context,
6596
+ int argc,
65976597
sqlite3_value **argv
65986598
){
65996599
ReCompiled *pRe; /* Compiled regular expression */
66006600
const char *zPattern; /* The regular expression */
66016601
const unsigned char *zStr;/* String being searched */
@@ -14815,11 +14815,11 @@
1481514815
" Examples:",
1481614816
" .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
1481714817
" .ar -tf ARCHIVE # List members of ARCHIVE",
1481814818
" .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
1481914819
" See also:",
14820
- " http://sqlite.org/cli.html#sqlar_archive_support",
14820
+ " http://sqlite.org/cli.html#sqlite_archive_support",
1482114821
#endif
1482214822
#ifndef SQLITE_OMIT_AUTHORIZATION
1482314823
".auth ON|OFF Show authorizer callbacks",
1482414824
#endif
1482514825
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
1482614826
--- src/shell.c
+++ src/shell.c
@@ -6204,11 +6204,11 @@
6204 }
6205 }
6206 }
6207 if( pRe->aOp[x]==RE_OP_CC_EXC ) hit = !hit;
6208 if( hit ) re_add_state(pNext, x+n);
6209 break;
6210 }
6211 }
6212 }
6213 }
6214 for(i=0; i<pNext->nState; i++){
@@ -6365,11 +6365,11 @@
6365 const char *zErr;
6366 while( (c = p->xNextChar(&p->sIn))!=0 ){
6367 iStart = p->nState;
6368 switch( c ){
6369 case '|':
6370 case '$':
6371 case ')': {
6372 p->sIn.i--;
6373 return 0;
6374 }
6375 case '(': {
@@ -6381,11 +6381,11 @@
6381 }
6382 case '.': {
6383 if( rePeek(p)=='*' ){
6384 re_append(p, RE_OP_ANYSTAR, 0);
6385 p->sIn.i++;
6386 }else{
6387 re_append(p, RE_OP_ANY, 0);
6388 }
6389 break;
6390 }
6391 case '*': {
@@ -6590,12 +6590,12 @@
6590 ** A REGEXP B
6591 **
6592 ** is implemented as regexp(B,A).
6593 */
6594 static void re_sql_func(
6595 sqlite3_context *context,
6596 int argc,
6597 sqlite3_value **argv
6598 ){
6599 ReCompiled *pRe; /* Compiled regular expression */
6600 const char *zPattern; /* The regular expression */
6601 const unsigned char *zStr;/* String being searched */
@@ -14815,11 +14815,11 @@
14815 " Examples:",
14816 " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
14817 " .ar -tf ARCHIVE # List members of ARCHIVE",
14818 " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
14819 " See also:",
14820 " http://sqlite.org/cli.html#sqlar_archive_support",
14821 #endif
14822 #ifndef SQLITE_OMIT_AUTHORIZATION
14823 ".auth ON|OFF Show authorizer callbacks",
14824 #endif
14825 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
14826
--- src/shell.c
+++ src/shell.c
@@ -6204,11 +6204,11 @@
6204 }
6205 }
6206 }
6207 if( pRe->aOp[x]==RE_OP_CC_EXC ) hit = !hit;
6208 if( hit ) re_add_state(pNext, x+n);
6209 break;
6210 }
6211 }
6212 }
6213 }
6214 for(i=0; i<pNext->nState; i++){
@@ -6365,11 +6365,11 @@
6365 const char *zErr;
6366 while( (c = p->xNextChar(&p->sIn))!=0 ){
6367 iStart = p->nState;
6368 switch( c ){
6369 case '|':
6370 case '$':
6371 case ')': {
6372 p->sIn.i--;
6373 return 0;
6374 }
6375 case '(': {
@@ -6381,11 +6381,11 @@
6381 }
6382 case '.': {
6383 if( rePeek(p)=='*' ){
6384 re_append(p, RE_OP_ANYSTAR, 0);
6385 p->sIn.i++;
6386 }else{
6387 re_append(p, RE_OP_ANY, 0);
6388 }
6389 break;
6390 }
6391 case '*': {
@@ -6590,12 +6590,12 @@
6590 ** A REGEXP B
6591 **
6592 ** is implemented as regexp(B,A).
6593 */
6594 static void re_sql_func(
6595 sqlite3_context *context,
6596 int argc,
6597 sqlite3_value **argv
6598 ){
6599 ReCompiled *pRe; /* Compiled regular expression */
6600 const char *zPattern; /* The regular expression */
6601 const unsigned char *zStr;/* String being searched */
@@ -14815,11 +14815,11 @@
14815 " Examples:",
14816 " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
14817 " .ar -tf ARCHIVE # List members of ARCHIVE",
14818 " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
14819 " See also:",
14820 " http://sqlite.org/cli.html#sqlite_archive_support",
14821 #endif
14822 #ifndef SQLITE_OMIT_AUTHORIZATION
14823 ".auth ON|OFF Show authorizer callbacks",
14824 #endif
14825 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
14826
+129 -76
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1205,11 +1205,11 @@
12051205
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
12061206
** [sqlite_version()] and [sqlite_source_id()].
12071207
*/
12081208
#define SQLITE_VERSION "3.36.0"
12091209
#define SQLITE_VERSION_NUMBER 3036000
1210
-#define SQLITE_SOURCE_ID "2021-06-07 00:41:18 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f41819"
1210
+#define SQLITE_SOURCE_ID "2021-06-14 14:52:27 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1d94b"
12111211
12121212
/*
12131213
** CAPI3REF: Run-Time Library Version Numbers
12141214
** KEYWORDS: sqlite3_version sqlite3_sourceid
12151215
**
@@ -16558,10 +16558,16 @@
1655816558
*/
1655916559
#ifndef SET_FULLSYNC
1656016560
# define SET_FULLSYNC(x,y)
1656116561
#endif
1656216562
16563
+/* Maximum pathname length. Note: FILENAME_MAX defined by stdio.h
16564
+*/
16565
+#ifndef SQLITE_MAX_PATHLEN
16566
+# define SQLITE_MAX_PATHLEN FILENAME_MAX
16567
+#endif
16568
+
1656316569
/*
1656416570
** The default size of a disk sector
1656516571
*/
1656616572
#ifndef SQLITE_DEFAULT_SECTOR_SIZE
1656716573
# define SQLITE_DEFAULT_SECTOR_SIZE 4096
@@ -20158,10 +20164,11 @@
2015820164
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
2015920165
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
2016020166
SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
2016120167
SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
2016220168
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
20169
+SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p);
2016320170
2016420171
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
2016520172
SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
2016620173
#endif
2016720174
@@ -20568,11 +20575,11 @@
2056820575
#ifndef SQLITE_OMIT_CTE
2056920576
SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
2057020577
SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*);
2057120578
SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*);
2057220579
SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*);
20573
-SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8);
20580
+SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8);
2057420581
#else
2057520582
# define sqlite3CteNew(P,T,E,S) ((void*)0)
2057620583
# define sqlite3CteDelete(D,C)
2057720584
# define sqlite3CteWithAdd(P,W,C) ((void*)0)
2057820585
# define sqlite3WithDelete(x,y)
@@ -21670,11 +21677,11 @@
2167021677
SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
2167121678
SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
2167221679
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
2167321680
SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
2167421681
SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
21675
-SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
21682
+SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, i64, u8, void(*)(void*));
2167621683
SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
2167721684
#ifdef SQLITE_OMIT_FLOATING_POINT
2167821685
# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
2167921686
#else
2168021687
SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
@@ -23667,10 +23674,12 @@
2366723674
zPathOut[0] = 0;
2366823675
return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
2366923676
}
2367023677
#ifndef SQLITE_OMIT_LOAD_EXTENSION
2367123678
SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
23679
+ assert( zPath!=0 );
23680
+ assert( strlen(zPath)<=SQLITE_MAX_PATHLEN ); /* tag-20210611-1 */
2367223681
return pVfs->xDlOpen(pVfs, zPath);
2367323682
}
2367423683
SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
2367523684
pVfs->xDlError(pVfs, nByte, zBufOut);
2367623685
}
@@ -66965,11 +66974,11 @@
6696566974
testcase( pc+size==usableSize );
6696666975
put2byte(pAddr, cbrk);
6696766976
if( temp==0 ){
6696866977
if( cbrk==pc ) continue;
6696966978
temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
66970
- memcpy(&temp[iCellStart], &data[iCellStart], (cbrk+size) - iCellStart);
66979
+ memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart);
6697166980
src = temp;
6697266981
}
6697366982
memcpy(&data[cbrk], &src[pc], size);
6697466983
}
6697566984
data[hdr+7] = 0;
@@ -78047,15 +78056,15 @@
7804778056
** either case, SQLITE_TOOBIG is returned.
7804878057
*/
7804978058
SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
7805078059
Mem *pMem, /* Memory cell to set to string value */
7805178060
const char *z, /* String pointer */
78052
- int n, /* Bytes in string, or negative */
78061
+ i64 n, /* Bytes in string, or negative */
7805378062
u8 enc, /* Encoding of z. 0 for BLOBs */
7805478063
void (*xDel)(void*) /* Destructor function */
7805578064
){
78056
- int nByte = n; /* New value for pMem->n */
78065
+ i64 nByte = n; /* New value for pMem->n */
7805778066
int iLimit; /* Maximum allowed string or blob size */
7805878067
u16 flags = 0; /* New value for pMem->flags */
7805978068
7806078069
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
7806178070
assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -78073,11 +78082,11 @@
7807378082
}
7807478083
flags = (enc==0?MEM_Blob:MEM_Str);
7807578084
if( nByte<0 ){
7807678085
assert( enc!=0 );
7807778086
if( enc==SQLITE_UTF8 ){
78078
- nByte = 0x7fffffff & (int)strlen(z);
78087
+ nByte = strlen(z);
7807978088
}else{
7808078089
for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}
7808178090
}
7808278091
flags |= MEM_Term;
7808378092
}
@@ -78085,11 +78094,11 @@
7808578094
/* The following block sets the new values of Mem.z and Mem.xDel. It
7808678095
** also sets a flag in local variable "flags" to indicate the memory
7808778096
** management (one of MEM_Dyn or MEM_Static).
7808878097
*/
7808978098
if( xDel==SQLITE_TRANSIENT ){
78090
- u32 nAlloc = nByte;
78099
+ i64 nAlloc = nByte;
7809178100
if( flags&MEM_Term ){
7809278101
nAlloc += (enc==SQLITE_UTF8?1:2);
7809378102
}
7809478103
if( nByte>iLimit ){
7809578104
return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
@@ -78111,11 +78120,11 @@
7811178120
pMem->xDel = xDel;
7811278121
flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
7811378122
}
7811478123
}
7811578124
78116
- pMem->n = nByte;
78125
+ pMem->n = (int)(nByte & 0x7fffffff);
7811778126
pMem->flags = flags;
7811878127
if( enc ){
7811978128
pMem->enc = enc;
7812078129
#ifdef SQLITE_ENABLE_SESSION
7812178130
}else if( pMem->db==0 ){
@@ -78131,11 +78140,11 @@
7813178140
return SQLITE_NOMEM_BKPT;
7813278141
}
7813378142
#endif
7813478143
7813578144
if( nByte>iLimit ){
78136
- return SQLITE_TOOBIG;
78145
+ return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
7813778146
}
7813878147
7813978148
return SQLITE_OK;
7814078149
}
7814178150
@@ -84527,11 +84536,11 @@
8452784536
}else if( xDel==SQLITE_TRANSIENT ){
8452884537
/* noop */
8452984538
}else{
8453084539
xDel((void*)p);
8453184540
}
84532
- if( pCtx ) sqlite3_result_error_toobig(pCtx);
84541
+ sqlite3_result_error_toobig(pCtx);
8453384542
return SQLITE_TOOBIG;
8453484543
}
8453584544
SQLITE_API void sqlite3_result_blob(
8453684545
sqlite3_context *pCtx,
8453784546
const void *z,
@@ -85509,11 +85518,11 @@
8550985518
*/
8551085519
static int bindText(
8551185520
sqlite3_stmt *pStmt, /* The statement to bind against */
8551285521
int i, /* Index of the parameter to bind */
8551385522
const void *zData, /* Pointer to the data to be bound */
85514
- int nData, /* Number of bytes of data to be bound */
85523
+ i64 nData, /* Number of bytes of data to be bound */
8551585524
void (*xDel)(void*), /* Destructor for the data */
8551685525
u8 encoding /* Encoding for the data */
8551785526
){
8551885527
Vdbe *p = (Vdbe *)pStmt;
8551985528
Mem *pVar;
@@ -85561,15 +85570,11 @@
8556185570
const void *zData,
8556285571
sqlite3_uint64 nData,
8556385572
void (*xDel)(void*)
8556485573
){
8556585574
assert( xDel!=SQLITE_DYNAMIC );
85566
- if( nData>0x7fffffff ){
85567
- return invokeValueDestructor(zData, xDel, 0);
85568
- }else{
85569
- return bindText(pStmt, i, zData, (int)nData, xDel, 0);
85570
- }
85575
+ return bindText(pStmt, i, zData, nData, xDel, 0);
8557185576
}
8557285577
SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
8557385578
int rc;
8557485579
Vdbe *p = (Vdbe *)pStmt;
8557585580
rc = vdbeUnbind(p, i);
@@ -85635,16 +85640,12 @@
8563585640
sqlite3_uint64 nData,
8563685641
void (*xDel)(void*),
8563785642
unsigned char enc
8563885643
){
8563985644
assert( xDel!=SQLITE_DYNAMIC );
85640
- if( nData>0x7fffffff ){
85641
- return invokeValueDestructor(zData, xDel, 0);
85642
- }else{
85643
- if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85644
- return bindText(pStmt, i, zData, (int)nData, xDel, enc);
85645
- }
85645
+ if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85646
+ return bindText(pStmt, i, zData, nData, xDel, enc);
8564685647
}
8564785648
#ifndef SQLITE_OMIT_UTF16
8564885649
SQLITE_API int sqlite3_bind_text16(
8564985650
sqlite3_stmt *pStmt,
8565085651
int i,
@@ -90957,11 +90958,12 @@
9095790958
assert( pOp[1].opcode==OP_SeekGE );
9095890959
9095990960
/* pOp->p2 points to the first instruction past the OP_IdxGT that
9096090961
** follows the OP_SeekGE. */
9096190962
assert( pOp->p2>=(int)(pOp-aOp)+2 );
90962
- assert( aOp[pOp->p2-1].opcode==OP_IdxGT );
90963
+ assert( aOp[pOp->p2-1].opcode==OP_IdxGT || aOp[pOp->p2-1].opcode==OP_IdxGE );
90964
+ testcase( aOp[pOp->p2-1].opcode==OP_IdxGE );
9096390965
assert( pOp[1].p1==aOp[pOp->p2-1].p1 );
9096490966
assert( pOp[1].p2==aOp[pOp->p2-1].p2 );
9096590967
assert( pOp[1].p3==aOp[pOp->p2-1].p3 );
9096690968
9096790969
assert( pOp->p1>0 );
@@ -92847,11 +92849,13 @@
9284792849
}
9284892850
#endif
9284992851
9285092852
iDb = pOp->p1;
9285192853
assert( iDb>=0 && iDb<db->nDb );
92852
- assert( DbHasProperty(db, iDb, DB_SchemaLoaded) || db->mallocFailed );
92854
+ assert( DbHasProperty(db, iDb, DB_SchemaLoaded)
92855
+ || db->mallocFailed
92856
+ || (CORRUPT_DB && (db->flags & SQLITE_NoSchemaError)!=0) );
9285392857
9285492858
#ifndef SQLITE_OMIT_ALTERTABLE
9285592859
if( pOp->p4.z==0 ){
9285692860
sqlite3SchemaClear(db->aDb[iDb].pSchema);
9285792861
db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
@@ -102622,11 +102626,11 @@
102622102626
** Create and return a deep copy of the object passed as the second
102623102627
** argument. If an OOM condition is encountered, NULL is returned
102624102628
** and the db->mallocFailed flag set.
102625102629
*/
102626102630
#ifndef SQLITE_OMIT_CTE
102627
-static With *withDup(sqlite3 *db, With *p){
102631
+SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p){
102628102632
With *pRet = 0;
102629102633
if( p ){
102630102634
sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
102631102635
pRet = sqlite3DbMallocZero(db, nByte);
102632102636
if( pRet ){
@@ -102640,11 +102644,11 @@
102640102644
}
102641102645
}
102642102646
return pRet;
102643102647
}
102644102648
#else
102645
-# define withDup(x,y) 0
102649
+# define sqlite3WithDup(x,y) 0
102646102650
#endif
102647102651
102648102652
#ifndef SQLITE_OMIT_WINDOWFUNC
102649102653
/*
102650102654
** The gatherSelectWindows() procedure and its helper routine
@@ -102844,11 +102848,11 @@
102844102848
pNew->iOffset = 0;
102845102849
pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
102846102850
pNew->addrOpenEphm[0] = -1;
102847102851
pNew->addrOpenEphm[1] = -1;
102848102852
pNew->nSelectRow = p->nSelectRow;
102849
- pNew->pWith = withDup(db, p->pWith);
102853
+ pNew->pWith = sqlite3WithDup(db, p->pWith);
102850102854
#ifndef SQLITE_OMIT_WINDOWFUNC
102851102855
pNew->pWin = 0;
102852102856
pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
102853102857
if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
102854102858
#endif
@@ -108184,19 +108188,34 @@
108184108188
** to select statement pSelect.
108185108189
*/
108186108190
static void renameWalkWith(Walker *pWalker, Select *pSelect){
108187108191
With *pWith = pSelect->pWith;
108188108192
if( pWith ){
108193
+ Parse *pParse = pWalker->pParse;
108189108194
int i;
108195
+ With *pCopy = 0;
108196
+ assert( pWith->nCte>0 );
108197
+ if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){
108198
+ /* Push a copy of the With object onto the with-stack. We use a copy
108199
+ ** here as the original will be expanded and resolved (flags SF_Expanded
108200
+ ** and SF_Resolved) below. And the parser code that uses the with-stack
108201
+ ** fails if the Select objects on it have already been expanded and
108202
+ ** resolved. */
108203
+ pCopy = sqlite3WithDup(pParse->db, pWith);
108204
+ pCopy = sqlite3WithPush(pParse, pCopy, 1);
108205
+ }
108190108206
for(i=0; i<pWith->nCte; i++){
108191108207
Select *p = pWith->a[i].pSelect;
108192108208
NameContext sNC;
108193108209
memset(&sNC, 0, sizeof(sNC));
108194
- sNC.pParse = pWalker->pParse;
108195
- sqlite3SelectPrep(sNC.pParse, p, &sNC);
108210
+ sNC.pParse = pParse;
108211
+ if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC);
108196108212
sqlite3WalkSelect(pWalker, p);
108197
- sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols);
108213
+ sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols);
108214
+ }
108215
+ if( pCopy && pParse->pWith==pCopy ){
108216
+ pParse->pWith = pCopy->pOuter;
108198108217
}
108199108218
}
108200108219
}
108201108220
108202108221
/*
@@ -119237,17 +119256,19 @@
119237119256
){
119238119257
/* This column was already computed by the previous index */
119239119258
continue;
119240119259
}
119241119260
sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
119242
- /* If the column affinity is REAL but the number is an integer, then it
119243
- ** might be stored in the table as an integer (using a compact
119244
- ** representation) then converted to REAL by an OP_RealAffinity opcode.
119245
- ** But we are getting ready to store this value back into an index, where
119246
- ** it should be converted by to INTEGER again. So omit the OP_RealAffinity
119247
- ** opcode if it is present */
119248
- sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
119261
+ if( pIdx->aiColumn[j]>=0 ){
119262
+ /* If the column affinity is REAL but the number is an integer, then it
119263
+ ** might be stored in the table as an integer (using a compact
119264
+ ** representation) then converted to REAL by an OP_RealAffinity opcode.
119265
+ ** But we are getting ready to store this value back into an index, where
119266
+ ** it should be converted by to INTEGER again. So omit the
119267
+ ** OP_RealAffinity opcode if it is present */
119268
+ sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
119269
+ }
119249119270
}
119250119271
if( regOut ){
119251119272
sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
119252119273
}
119253119274
sqlite3ReleaseTempRange(pParse, regBase, nCol);
@@ -127401,11 +127422,11 @@
127401127422
sqlite3_loadext_entry xInit;
127402127423
char *zErrmsg = 0;
127403127424
const char *zEntry;
127404127425
char *zAltEntry = 0;
127405127426
void **aHandle;
127406
- u64 nMsg = 300 + sqlite3Strlen30(zFile);
127427
+ u64 nMsg = strlen(zFile);
127407127428
int ii;
127408127429
int rc;
127409127430
127410127431
/* Shared library endings to try if zFile cannot be loaded as written */
127411127432
static const char *azEndings[] = {
@@ -127435,30 +127456,26 @@
127435127456
return SQLITE_ERROR;
127436127457
}
127437127458
127438127459
zEntry = zProc ? zProc : "sqlite3_extension_init";
127439127460
127461
+ /* tag-20210611-1. Some dlopen() implementations will segfault if given
127462
+ ** an oversize filename. Most filesystems have a pathname limit of 4K,
127463
+ ** so limit the extension filename length to about twice that.
127464
+ ** https://sqlite.org/forum/forumpost/08a0d6d9bf */
127465
+ if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found;
127466
+
127440127467
handle = sqlite3OsDlOpen(pVfs, zFile);
127441127468
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
127442127469
for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
127443127470
char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
127444127471
if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
127445127472
handle = sqlite3OsDlOpen(pVfs, zAltFile);
127446127473
sqlite3_free(zAltFile);
127447127474
}
127448127475
#endif
127449
- if( handle==0 ){
127450
- if( pzErrMsg ){
127451
- *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127452
- if( zErrmsg ){
127453
- sqlite3_snprintf(nMsg, zErrmsg,
127454
- "unable to open shared library [%s]", zFile);
127455
- sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127456
- }
127457
- }
127458
- return SQLITE_ERROR;
127459
- }
127476
+ if( handle==0 ) goto extension_not_found;
127460127477
xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127461127478
127462127479
/* If no entry point was specified and the default legacy
127463127480
** entry point name "sqlite3_extension_init" was not found, then
127464127481
** construct an entry point name "sqlite3_X_init" where the X is
@@ -127491,14 +127508,15 @@
127491127508
zEntry = zAltEntry;
127492127509
xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127493127510
}
127494127511
if( xInit==0 ){
127495127512
if( pzErrMsg ){
127496
- nMsg += sqlite3Strlen30(zEntry);
127513
+ nMsg += strlen(zEntry) + 300;
127497127514
*pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127498127515
if( zErrmsg ){
127499
- sqlite3_snprintf(nMsg, zErrmsg,
127516
+ assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127517
+ sqlite3_snprintf((int)nMsg, zErrmsg,
127500127518
"no entry point [%s] in shared library [%s]", zEntry, zFile);
127501127519
sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127502127520
}
127503127521
}
127504127522
sqlite3OsDlClose(pVfs, handle);
@@ -127528,10 +127546,23 @@
127528127546
sqlite3DbFree(db, db->aExtension);
127529127547
db->aExtension = aHandle;
127530127548
127531127549
db->aExtension[db->nExtension++] = handle;
127532127550
return SQLITE_OK;
127551
+
127552
+extension_not_found:
127553
+ if( pzErrMsg ){
127554
+ nMsg += 300;
127555
+ *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127556
+ if( zErrmsg ){
127557
+ assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127558
+ sqlite3_snprintf((int)nMsg, zErrmsg,
127559
+ "unable to open shared library [%.*s]", SQLITE_MAX_PATHLEN, zFile);
127560
+ sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127561
+ }
127562
+ }
127563
+ return SQLITE_ERROR;
127533127564
}
127534127565
SQLITE_API int sqlite3_load_extension(
127535127566
sqlite3 *db, /* Load the extension into this database connection */
127536127567
const char *zFile, /* Name of the shared library containing extension */
127537127568
const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -131368,13 +131399,15 @@
131368131399
if( rc==SQLITE_OK ){
131369131400
sqlite3AnalysisLoad(db, iDb);
131370131401
}
131371131402
#endif
131372131403
}
131404
+ assert( pDb == &(db->aDb[iDb]) );
131373131405
if( db->mallocFailed ){
131374131406
rc = SQLITE_NOMEM_BKPT;
131375131407
sqlite3ResetAllSchemasOfConnection(db);
131408
+ pDb = &db->aDb[iDb];
131376131409
}else
131377131410
if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
131378131411
/* Hack: If the SQLITE_NoSchemaError flag is set, then consider
131379131412
** the schema loaded, even if errors (other than OOM) occurred. In
131380131413
** this situation the current sqlite3_prepare() operation will fail,
@@ -136426,10 +136459,11 @@
136426136459
** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
136427136460
*/
136428136461
typedef struct WhereConst WhereConst;
136429136462
struct WhereConst {
136430136463
Parse *pParse; /* Parsing context */
136464
+ u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
136431136465
int nConst; /* Number for COLUMN=CONSTANT terms */
136432136466
int nChng; /* Number of times a constant is propagated */
136433136467
int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
136434136468
Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
136435136469
};
@@ -136525,10 +136559,11 @@
136525136559
WhereConst *pConst,
136526136560
Expr *pExpr,
136527136561
int bIgnoreAffBlob
136528136562
){
136529136563
int i;
136564
+ if( pConst->pOomFault[0] ) return WRC_Prune;
136530136565
if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
136531136566
if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
136532136567
testcase( ExprHasProperty(pExpr, EP_FixedCol) );
136533136568
testcase( ExprHasProperty(pExpr, EP_FromJoin) );
136534136569
return WRC_Continue;
@@ -136545,10 +136580,11 @@
136545136580
pConst->nChng++;
136546136581
ExprClearProperty(pExpr, EP_Leaf);
136547136582
ExprSetProperty(pExpr, EP_FixedCol);
136548136583
assert( pExpr->pLeft==0 );
136549136584
pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
136585
+ if( pConst->pParse->db->mallocFailed ) return WRC_Prune;
136550136586
break;
136551136587
}
136552136588
return WRC_Prune;
136553136589
}
136554136590
@@ -136577,10 +136613,11 @@
136577136613
if( pConst->bHasAffBlob ){
136578136614
if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE)
136579136615
|| pExpr->op==TK_IS
136580136616
){
136581136617
propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0);
136618
+ if( pConst->pOomFault[0] ) return WRC_Prune;
136582136619
if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){
136583136620
propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0);
136584136621
}
136585136622
}
136586136623
}
@@ -136644,10 +136681,11 @@
136644136681
){
136645136682
WhereConst x;
136646136683
Walker w;
136647136684
int nChng = 0;
136648136685
x.pParse = pParse;
136686
+ x.pOomFault = &pParse->db->mallocFailed;
136649136687
do{
136650136688
x.nConst = 0;
136651136689
x.nChng = 0;
136652136690
x.apExpr = 0;
136653136691
x.bHasAffBlob = 0;
@@ -137099,25 +137137,33 @@
137099137137
** onto the top of the stack. If argument bFree is true, then this
137100137138
** WITH clause will never be popped from the stack but should instead
137101137139
** be freed along with the Parse object. In other cases, when
137102137140
** bFree==0, the With object will be freed along with the SELECT
137103137141
** statement with which it is associated.
137142
+**
137143
+** This routine returns a copy of pWith. Or, if bFree is true and
137144
+** the pWith object is destroyed immediately due to an OOM condition,
137145
+** then this routine return NULL.
137146
+**
137147
+** If bFree is true, do not continue to use the pWith pointer after
137148
+** calling this routine, Instead, use only the return value.
137104137149
*/
137105
-SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
137150
+SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
137106137151
if( pWith ){
137152
+ if( bFree ){
137153
+ pWith = (With*)sqlite3ParserAddCleanup(pParse,
137154
+ (void(*)(sqlite3*,void*))sqlite3WithDelete,
137155
+ pWith);
137156
+ if( pWith==0 ) return 0;
137157
+ }
137107137158
if( pParse->nErr==0 ){
137108137159
assert( pParse->pWith!=pWith );
137109137160
pWith->pOuter = pParse->pWith;
137110137161
pParse->pWith = pWith;
137111137162
}
137112
- if( bFree ){
137113
- sqlite3ParserAddCleanup(pParse,
137114
- (void(*)(sqlite3*,void*))sqlite3WithDelete,
137115
- pWith);
137116
- testcase( pParse->earlyCleanup );
137117
- }
137118137163
}
137164
+ return pWith;
137119137165
}
137120137166
137121137167
/*
137122137168
** This function checks if argument pFrom refers to a CTE declared by
137123137169
** a WITH clause on the stack currently maintained by the parser (on the
@@ -137474,10 +137520,11 @@
137474137520
){
137475137521
sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
137476137522
pTab->zName);
137477137523
}
137478137524
#ifndef SQLITE_OMIT_VIRTUALTABLE
137525
+ assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 );
137479137526
if( IsVirtual(pTab)
137480137527
&& pFrom->fg.fromDDL
137481137528
&& ALWAYS(pTab->pVTable!=0)
137482137529
&& pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
137483137530
){
@@ -183221,12 +183268,12 @@
183221183268
int nPrev, /* Size of buffer zPrev in bytes */
183222183269
const char *zNext, /* Buffer containing next term */
183223183270
int nNext /* Size of buffer zNext in bytes */
183224183271
){
183225183272
int n;
183226
- UNUSED_PARAMETER(nNext);
183227
- for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);
183273
+ for(n=0; n<nPrev && n<nNext && zPrev[n]==zNext[n]; n++);
183274
+ assert_fts3_nc( n<nNext );
183228183275
return n;
183229183276
}
183230183277
183231183278
/*
183232183279
** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
@@ -184221,11 +184268,11 @@
184221184268
iDelta = (i64)((u64)iDocid - (u64)iPrev);
184222184269
}
184223184270
184224184271
nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
184225184272
184226
- rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist);
184273
+ rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING);
184227184274
if( rc ) return rc;
184228184275
184229184276
if( isFirst ){
184230184277
char *a = &pCsr->aBuffer[nDoclist];
184231184278
int nWrite;
@@ -216164,10 +216211,11 @@
216164216211
return 1;
216165216212
}else{
216166216213
i64 iOff = *piOff;
216167216214
int iVal;
216168216215
fts5FastGetVarint32(a, i, iVal);
216216
+ assert( iVal>=0 );
216169216217
if( iVal<=1 ){
216170216218
if( iVal==0 ){
216171216219
*pi = i;
216172216220
return 0;
216173216221
}
@@ -216177,13 +216225,16 @@
216177216225
if( iVal<2 ){
216178216226
/* This is a corrupt record. So stop parsing it here. */
216179216227
*piOff = -1;
216180216228
return 1;
216181216229
}
216230
+ *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216231
+ }else{
216232
+ *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
216182216233
}
216183
- *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216184216234
*pi = i;
216235
+ assert( *piOff>=iOff );
216185216236
return 0;
216186216237
}
216187216238
}
216188216239
216189216240
@@ -216218,18 +216269,20 @@
216218216269
static void sqlite3Fts5PoslistSafeAppend(
216219216270
Fts5Buffer *pBuf,
216220216271
i64 *piPrev,
216221216272
i64 iPos
216222216273
){
216223
- static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
216224
- if( (iPos & colmask) != (*piPrev & colmask) ){
216225
- pBuf->p[pBuf->n++] = 1;
216226
- pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
216227
- *piPrev = (iPos & colmask);
216228
- }
216229
- pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
216230
- *piPrev = iPos;
216274
+ if( iPos>=*piPrev ){
216275
+ static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
216276
+ if( (iPos & colmask) != (*piPrev & colmask) ){
216277
+ pBuf->p[pBuf->n++] = 1;
216278
+ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
216279
+ *piPrev = (iPos & colmask);
216280
+ }
216281
+ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
216282
+ *piPrev = iPos;
216283
+ }
216231216284
}
216232216285
216233216286
static int sqlite3Fts5PoslistWriterAppend(
216234216287
Fts5Buffer *pBuf,
216235216288
Fts5PoslistWriter *pWriter,
@@ -224157,11 +224210,11 @@
224157224210
pIter->base.nData = p-aCopy;
224158224211
return;
224159224212
}
224160224213
fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy);
224161224214
}
224162
- if( p==pEnd ){
224215
+ if( p>=pEnd ){
224163224216
pIter->base.pData = pIter->poslist.p;
224164224217
pIter->base.nData = pIter->poslist.n;
224165224218
return;
224166224219
}
224167224220
aCopy = p++;
@@ -225953,11 +226006,11 @@
225953226006
Fts5Buffer *p1, /* First list to merge */
225954226007
int nBuf, /* Number of buffers in array aBuf[] */
225955226008
Fts5Buffer *aBuf /* Other lists to merge in */
225956226009
){
225957226010
#define fts5PrefixMergerNextPosition(p) \
225958
- sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos);
226011
+ sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos)
225959226012
#define FTS5_MERGE_NLIST 16
225960226013
PrefixMerger aMerger[FTS5_MERGE_NLIST];
225961226014
PrefixMerger *pHead = 0;
225962226015
int i;
225963226016
int nOut = 0;
@@ -230501,11 +230554,11 @@
230501230554
int nArg, /* Number of args */
230502230555
sqlite3_value **apUnused /* Function arguments */
230503230556
){
230504230557
assert( nArg==0 );
230505230558
UNUSED_PARAM2(nArg, apUnused);
230506
- sqlite3_result_text(pCtx, "fts5: 2021-06-04 23:26:56 1c71de43dbc68002c4a6229e7efffb019655baff67a51fe922571fe420c95835", -1, SQLITE_TRANSIENT);
230559
+ sqlite3_result_text(pCtx, "fts5: 2021-06-14 11:20:30 7068f1f69b4feef49260e80902e6bdae47c21a0daa16c96ed1a0984dd1f14cdc", -1, SQLITE_TRANSIENT);
230507230560
}
230508230561
230509230562
/*
230510230563
** Return true if zName is the extension on one of the shadow tables used
230511230564
** by this module.
@@ -235427,12 +235480,12 @@
235427235480
}
235428235481
#endif /* SQLITE_CORE */
235429235482
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235430235483
235431235484
/************** End of stmt.c ************************************************/
235432
-#if __LINE__!=235432
235485
+#if __LINE__!=235485
235433235486
#undef SQLITE_SOURCE_ID
235434
-#define SQLITE_SOURCE_ID "2021-06-07 00:41:18 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f4alt2"
235487
+#define SQLITE_SOURCE_ID "2021-06-14 14:52:27 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1alt2"
235435235488
#endif
235436235489
/* Return the source-id for this library */
235437235490
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235438235491
/************************** End of sqlite3.c ******************************/
235439235492
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1205,11 +1205,11 @@
1205 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1206 ** [sqlite_version()] and [sqlite_source_id()].
1207 */
1208 #define SQLITE_VERSION "3.36.0"
1209 #define SQLITE_VERSION_NUMBER 3036000
1210 #define SQLITE_SOURCE_ID "2021-06-07 00:41:18 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f41819"
1211
1212 /*
1213 ** CAPI3REF: Run-Time Library Version Numbers
1214 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1215 **
@@ -16558,10 +16558,16 @@
16558 */
16559 #ifndef SET_FULLSYNC
16560 # define SET_FULLSYNC(x,y)
16561 #endif
16562
 
 
 
 
 
 
16563 /*
16564 ** The default size of a disk sector
16565 */
16566 #ifndef SQLITE_DEFAULT_SECTOR_SIZE
16567 # define SQLITE_DEFAULT_SECTOR_SIZE 4096
@@ -20158,10 +20164,11 @@
20158 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
20159 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
20160 SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
20161 SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
20162 SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
 
20163
20164 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
20165 SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
20166 #endif
20167
@@ -20568,11 +20575,11 @@
20568 #ifndef SQLITE_OMIT_CTE
20569 SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
20570 SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*);
20571 SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*);
20572 SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*);
20573 SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8);
20574 #else
20575 # define sqlite3CteNew(P,T,E,S) ((void*)0)
20576 # define sqlite3CteDelete(D,C)
20577 # define sqlite3CteWithAdd(P,W,C) ((void*)0)
20578 # define sqlite3WithDelete(x,y)
@@ -21670,11 +21677,11 @@
21670 SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
21671 SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
21672 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
21673 SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
21674 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
21675 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
21676 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
21677 #ifdef SQLITE_OMIT_FLOATING_POINT
21678 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
21679 #else
21680 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
@@ -23667,10 +23674,12 @@
23667 zPathOut[0] = 0;
23668 return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
23669 }
23670 #ifndef SQLITE_OMIT_LOAD_EXTENSION
23671 SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
 
 
23672 return pVfs->xDlOpen(pVfs, zPath);
23673 }
23674 SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
23675 pVfs->xDlError(pVfs, nByte, zBufOut);
23676 }
@@ -66965,11 +66974,11 @@
66965 testcase( pc+size==usableSize );
66966 put2byte(pAddr, cbrk);
66967 if( temp==0 ){
66968 if( cbrk==pc ) continue;
66969 temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
66970 memcpy(&temp[iCellStart], &data[iCellStart], (cbrk+size) - iCellStart);
66971 src = temp;
66972 }
66973 memcpy(&data[cbrk], &src[pc], size);
66974 }
66975 data[hdr+7] = 0;
@@ -78047,15 +78056,15 @@
78047 ** either case, SQLITE_TOOBIG is returned.
78048 */
78049 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
78050 Mem *pMem, /* Memory cell to set to string value */
78051 const char *z, /* String pointer */
78052 int n, /* Bytes in string, or negative */
78053 u8 enc, /* Encoding of z. 0 for BLOBs */
78054 void (*xDel)(void*) /* Destructor function */
78055 ){
78056 int nByte = n; /* New value for pMem->n */
78057 int iLimit; /* Maximum allowed string or blob size */
78058 u16 flags = 0; /* New value for pMem->flags */
78059
78060 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
78061 assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -78073,11 +78082,11 @@
78073 }
78074 flags = (enc==0?MEM_Blob:MEM_Str);
78075 if( nByte<0 ){
78076 assert( enc!=0 );
78077 if( enc==SQLITE_UTF8 ){
78078 nByte = 0x7fffffff & (int)strlen(z);
78079 }else{
78080 for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}
78081 }
78082 flags |= MEM_Term;
78083 }
@@ -78085,11 +78094,11 @@
78085 /* The following block sets the new values of Mem.z and Mem.xDel. It
78086 ** also sets a flag in local variable "flags" to indicate the memory
78087 ** management (one of MEM_Dyn or MEM_Static).
78088 */
78089 if( xDel==SQLITE_TRANSIENT ){
78090 u32 nAlloc = nByte;
78091 if( flags&MEM_Term ){
78092 nAlloc += (enc==SQLITE_UTF8?1:2);
78093 }
78094 if( nByte>iLimit ){
78095 return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
@@ -78111,11 +78120,11 @@
78111 pMem->xDel = xDel;
78112 flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
78113 }
78114 }
78115
78116 pMem->n = nByte;
78117 pMem->flags = flags;
78118 if( enc ){
78119 pMem->enc = enc;
78120 #ifdef SQLITE_ENABLE_SESSION
78121 }else if( pMem->db==0 ){
@@ -78131,11 +78140,11 @@
78131 return SQLITE_NOMEM_BKPT;
78132 }
78133 #endif
78134
78135 if( nByte>iLimit ){
78136 return SQLITE_TOOBIG;
78137 }
78138
78139 return SQLITE_OK;
78140 }
78141
@@ -84527,11 +84536,11 @@
84527 }else if( xDel==SQLITE_TRANSIENT ){
84528 /* noop */
84529 }else{
84530 xDel((void*)p);
84531 }
84532 if( pCtx ) sqlite3_result_error_toobig(pCtx);
84533 return SQLITE_TOOBIG;
84534 }
84535 SQLITE_API void sqlite3_result_blob(
84536 sqlite3_context *pCtx,
84537 const void *z,
@@ -85509,11 +85518,11 @@
85509 */
85510 static int bindText(
85511 sqlite3_stmt *pStmt, /* The statement to bind against */
85512 int i, /* Index of the parameter to bind */
85513 const void *zData, /* Pointer to the data to be bound */
85514 int nData, /* Number of bytes of data to be bound */
85515 void (*xDel)(void*), /* Destructor for the data */
85516 u8 encoding /* Encoding for the data */
85517 ){
85518 Vdbe *p = (Vdbe *)pStmt;
85519 Mem *pVar;
@@ -85561,15 +85570,11 @@
85561 const void *zData,
85562 sqlite3_uint64 nData,
85563 void (*xDel)(void*)
85564 ){
85565 assert( xDel!=SQLITE_DYNAMIC );
85566 if( nData>0x7fffffff ){
85567 return invokeValueDestructor(zData, xDel, 0);
85568 }else{
85569 return bindText(pStmt, i, zData, (int)nData, xDel, 0);
85570 }
85571 }
85572 SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
85573 int rc;
85574 Vdbe *p = (Vdbe *)pStmt;
85575 rc = vdbeUnbind(p, i);
@@ -85635,16 +85640,12 @@
85635 sqlite3_uint64 nData,
85636 void (*xDel)(void*),
85637 unsigned char enc
85638 ){
85639 assert( xDel!=SQLITE_DYNAMIC );
85640 if( nData>0x7fffffff ){
85641 return invokeValueDestructor(zData, xDel, 0);
85642 }else{
85643 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85644 return bindText(pStmt, i, zData, (int)nData, xDel, enc);
85645 }
85646 }
85647 #ifndef SQLITE_OMIT_UTF16
85648 SQLITE_API int sqlite3_bind_text16(
85649 sqlite3_stmt *pStmt,
85650 int i,
@@ -90957,11 +90958,12 @@
90957 assert( pOp[1].opcode==OP_SeekGE );
90958
90959 /* pOp->p2 points to the first instruction past the OP_IdxGT that
90960 ** follows the OP_SeekGE. */
90961 assert( pOp->p2>=(int)(pOp-aOp)+2 );
90962 assert( aOp[pOp->p2-1].opcode==OP_IdxGT );
 
90963 assert( pOp[1].p1==aOp[pOp->p2-1].p1 );
90964 assert( pOp[1].p2==aOp[pOp->p2-1].p2 );
90965 assert( pOp[1].p3==aOp[pOp->p2-1].p3 );
90966
90967 assert( pOp->p1>0 );
@@ -92847,11 +92849,13 @@
92847 }
92848 #endif
92849
92850 iDb = pOp->p1;
92851 assert( iDb>=0 && iDb<db->nDb );
92852 assert( DbHasProperty(db, iDb, DB_SchemaLoaded) || db->mallocFailed );
 
 
92853
92854 #ifndef SQLITE_OMIT_ALTERTABLE
92855 if( pOp->p4.z==0 ){
92856 sqlite3SchemaClear(db->aDb[iDb].pSchema);
92857 db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
@@ -102622,11 +102626,11 @@
102622 ** Create and return a deep copy of the object passed as the second
102623 ** argument. If an OOM condition is encountered, NULL is returned
102624 ** and the db->mallocFailed flag set.
102625 */
102626 #ifndef SQLITE_OMIT_CTE
102627 static With *withDup(sqlite3 *db, With *p){
102628 With *pRet = 0;
102629 if( p ){
102630 sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
102631 pRet = sqlite3DbMallocZero(db, nByte);
102632 if( pRet ){
@@ -102640,11 +102644,11 @@
102640 }
102641 }
102642 return pRet;
102643 }
102644 #else
102645 # define withDup(x,y) 0
102646 #endif
102647
102648 #ifndef SQLITE_OMIT_WINDOWFUNC
102649 /*
102650 ** The gatherSelectWindows() procedure and its helper routine
@@ -102844,11 +102848,11 @@
102844 pNew->iOffset = 0;
102845 pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
102846 pNew->addrOpenEphm[0] = -1;
102847 pNew->addrOpenEphm[1] = -1;
102848 pNew->nSelectRow = p->nSelectRow;
102849 pNew->pWith = withDup(db, p->pWith);
102850 #ifndef SQLITE_OMIT_WINDOWFUNC
102851 pNew->pWin = 0;
102852 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
102853 if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
102854 #endif
@@ -108184,19 +108188,34 @@
108184 ** to select statement pSelect.
108185 */
108186 static void renameWalkWith(Walker *pWalker, Select *pSelect){
108187 With *pWith = pSelect->pWith;
108188 if( pWith ){
 
108189 int i;
 
 
 
 
 
 
 
 
 
 
 
108190 for(i=0; i<pWith->nCte; i++){
108191 Select *p = pWith->a[i].pSelect;
108192 NameContext sNC;
108193 memset(&sNC, 0, sizeof(sNC));
108194 sNC.pParse = pWalker->pParse;
108195 sqlite3SelectPrep(sNC.pParse, p, &sNC);
108196 sqlite3WalkSelect(pWalker, p);
108197 sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols);
 
 
 
108198 }
108199 }
108200 }
108201
108202 /*
@@ -119237,17 +119256,19 @@
119237 ){
119238 /* This column was already computed by the previous index */
119239 continue;
119240 }
119241 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
119242 /* If the column affinity is REAL but the number is an integer, then it
119243 ** might be stored in the table as an integer (using a compact
119244 ** representation) then converted to REAL by an OP_RealAffinity opcode.
119245 ** But we are getting ready to store this value back into an index, where
119246 ** it should be converted by to INTEGER again. So omit the OP_RealAffinity
119247 ** opcode if it is present */
119248 sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
 
 
119249 }
119250 if( regOut ){
119251 sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
119252 }
119253 sqlite3ReleaseTempRange(pParse, regBase, nCol);
@@ -127401,11 +127422,11 @@
127401 sqlite3_loadext_entry xInit;
127402 char *zErrmsg = 0;
127403 const char *zEntry;
127404 char *zAltEntry = 0;
127405 void **aHandle;
127406 u64 nMsg = 300 + sqlite3Strlen30(zFile);
127407 int ii;
127408 int rc;
127409
127410 /* Shared library endings to try if zFile cannot be loaded as written */
127411 static const char *azEndings[] = {
@@ -127435,30 +127456,26 @@
127435 return SQLITE_ERROR;
127436 }
127437
127438 zEntry = zProc ? zProc : "sqlite3_extension_init";
127439
 
 
 
 
 
 
127440 handle = sqlite3OsDlOpen(pVfs, zFile);
127441 #if SQLITE_OS_UNIX || SQLITE_OS_WIN
127442 for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
127443 char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
127444 if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
127445 handle = sqlite3OsDlOpen(pVfs, zAltFile);
127446 sqlite3_free(zAltFile);
127447 }
127448 #endif
127449 if( handle==0 ){
127450 if( pzErrMsg ){
127451 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127452 if( zErrmsg ){
127453 sqlite3_snprintf(nMsg, zErrmsg,
127454 "unable to open shared library [%s]", zFile);
127455 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127456 }
127457 }
127458 return SQLITE_ERROR;
127459 }
127460 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127461
127462 /* If no entry point was specified and the default legacy
127463 ** entry point name "sqlite3_extension_init" was not found, then
127464 ** construct an entry point name "sqlite3_X_init" where the X is
@@ -127491,14 +127508,15 @@
127491 zEntry = zAltEntry;
127492 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127493 }
127494 if( xInit==0 ){
127495 if( pzErrMsg ){
127496 nMsg += sqlite3Strlen30(zEntry);
127497 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127498 if( zErrmsg ){
127499 sqlite3_snprintf(nMsg, zErrmsg,
 
127500 "no entry point [%s] in shared library [%s]", zEntry, zFile);
127501 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127502 }
127503 }
127504 sqlite3OsDlClose(pVfs, handle);
@@ -127528,10 +127546,23 @@
127528 sqlite3DbFree(db, db->aExtension);
127529 db->aExtension = aHandle;
127530
127531 db->aExtension[db->nExtension++] = handle;
127532 return SQLITE_OK;
 
 
 
 
 
 
 
 
 
 
 
 
 
127533 }
127534 SQLITE_API int sqlite3_load_extension(
127535 sqlite3 *db, /* Load the extension into this database connection */
127536 const char *zFile, /* Name of the shared library containing extension */
127537 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -131368,13 +131399,15 @@
131368 if( rc==SQLITE_OK ){
131369 sqlite3AnalysisLoad(db, iDb);
131370 }
131371 #endif
131372 }
 
131373 if( db->mallocFailed ){
131374 rc = SQLITE_NOMEM_BKPT;
131375 sqlite3ResetAllSchemasOfConnection(db);
 
131376 }else
131377 if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
131378 /* Hack: If the SQLITE_NoSchemaError flag is set, then consider
131379 ** the schema loaded, even if errors (other than OOM) occurred. In
131380 ** this situation the current sqlite3_prepare() operation will fail,
@@ -136426,10 +136459,11 @@
136426 ** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
136427 */
136428 typedef struct WhereConst WhereConst;
136429 struct WhereConst {
136430 Parse *pParse; /* Parsing context */
 
136431 int nConst; /* Number for COLUMN=CONSTANT terms */
136432 int nChng; /* Number of times a constant is propagated */
136433 int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
136434 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
136435 };
@@ -136525,10 +136559,11 @@
136525 WhereConst *pConst,
136526 Expr *pExpr,
136527 int bIgnoreAffBlob
136528 ){
136529 int i;
 
136530 if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
136531 if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
136532 testcase( ExprHasProperty(pExpr, EP_FixedCol) );
136533 testcase( ExprHasProperty(pExpr, EP_FromJoin) );
136534 return WRC_Continue;
@@ -136545,10 +136580,11 @@
136545 pConst->nChng++;
136546 ExprClearProperty(pExpr, EP_Leaf);
136547 ExprSetProperty(pExpr, EP_FixedCol);
136548 assert( pExpr->pLeft==0 );
136549 pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
 
136550 break;
136551 }
136552 return WRC_Prune;
136553 }
136554
@@ -136577,10 +136613,11 @@
136577 if( pConst->bHasAffBlob ){
136578 if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE)
136579 || pExpr->op==TK_IS
136580 ){
136581 propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0);
 
136582 if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){
136583 propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0);
136584 }
136585 }
136586 }
@@ -136644,10 +136681,11 @@
136644 ){
136645 WhereConst x;
136646 Walker w;
136647 int nChng = 0;
136648 x.pParse = pParse;
 
136649 do{
136650 x.nConst = 0;
136651 x.nChng = 0;
136652 x.apExpr = 0;
136653 x.bHasAffBlob = 0;
@@ -137099,25 +137137,33 @@
137099 ** onto the top of the stack. If argument bFree is true, then this
137100 ** WITH clause will never be popped from the stack but should instead
137101 ** be freed along with the Parse object. In other cases, when
137102 ** bFree==0, the With object will be freed along with the SELECT
137103 ** statement with which it is associated.
 
 
 
 
 
 
 
137104 */
137105 SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
137106 if( pWith ){
 
 
 
 
 
 
137107 if( pParse->nErr==0 ){
137108 assert( pParse->pWith!=pWith );
137109 pWith->pOuter = pParse->pWith;
137110 pParse->pWith = pWith;
137111 }
137112 if( bFree ){
137113 sqlite3ParserAddCleanup(pParse,
137114 (void(*)(sqlite3*,void*))sqlite3WithDelete,
137115 pWith);
137116 testcase( pParse->earlyCleanup );
137117 }
137118 }
 
137119 }
137120
137121 /*
137122 ** This function checks if argument pFrom refers to a CTE declared by
137123 ** a WITH clause on the stack currently maintained by the parser (on the
@@ -137474,10 +137520,11 @@
137474 ){
137475 sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
137476 pTab->zName);
137477 }
137478 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
137479 if( IsVirtual(pTab)
137480 && pFrom->fg.fromDDL
137481 && ALWAYS(pTab->pVTable!=0)
137482 && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
137483 ){
@@ -183221,12 +183268,12 @@
183221 int nPrev, /* Size of buffer zPrev in bytes */
183222 const char *zNext, /* Buffer containing next term */
183223 int nNext /* Size of buffer zNext in bytes */
183224 ){
183225 int n;
183226 UNUSED_PARAMETER(nNext);
183227 for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);
183228 return n;
183229 }
183230
183231 /*
183232 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
@@ -184221,11 +184268,11 @@
184221 iDelta = (i64)((u64)iDocid - (u64)iPrev);
184222 }
184223
184224 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
184225
184226 rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist);
184227 if( rc ) return rc;
184228
184229 if( isFirst ){
184230 char *a = &pCsr->aBuffer[nDoclist];
184231 int nWrite;
@@ -216164,10 +216211,11 @@
216164 return 1;
216165 }else{
216166 i64 iOff = *piOff;
216167 int iVal;
216168 fts5FastGetVarint32(a, i, iVal);
 
216169 if( iVal<=1 ){
216170 if( iVal==0 ){
216171 *pi = i;
216172 return 0;
216173 }
@@ -216177,13 +216225,16 @@
216177 if( iVal<2 ){
216178 /* This is a corrupt record. So stop parsing it here. */
216179 *piOff = -1;
216180 return 1;
216181 }
 
 
 
216182 }
216183 *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216184 *pi = i;
 
216185 return 0;
216186 }
216187 }
216188
216189
@@ -216218,18 +216269,20 @@
216218 static void sqlite3Fts5PoslistSafeAppend(
216219 Fts5Buffer *pBuf,
216220 i64 *piPrev,
216221 i64 iPos
216222 ){
216223 static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
216224 if( (iPos & colmask) != (*piPrev & colmask) ){
216225 pBuf->p[pBuf->n++] = 1;
216226 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
216227 *piPrev = (iPos & colmask);
216228 }
216229 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
216230 *piPrev = iPos;
 
 
216231 }
216232
216233 static int sqlite3Fts5PoslistWriterAppend(
216234 Fts5Buffer *pBuf,
216235 Fts5PoslistWriter *pWriter,
@@ -224157,11 +224210,11 @@
224157 pIter->base.nData = p-aCopy;
224158 return;
224159 }
224160 fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy);
224161 }
224162 if( p==pEnd ){
224163 pIter->base.pData = pIter->poslist.p;
224164 pIter->base.nData = pIter->poslist.n;
224165 return;
224166 }
224167 aCopy = p++;
@@ -225953,11 +226006,11 @@
225953 Fts5Buffer *p1, /* First list to merge */
225954 int nBuf, /* Number of buffers in array aBuf[] */
225955 Fts5Buffer *aBuf /* Other lists to merge in */
225956 ){
225957 #define fts5PrefixMergerNextPosition(p) \
225958 sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos);
225959 #define FTS5_MERGE_NLIST 16
225960 PrefixMerger aMerger[FTS5_MERGE_NLIST];
225961 PrefixMerger *pHead = 0;
225962 int i;
225963 int nOut = 0;
@@ -230501,11 +230554,11 @@
230501 int nArg, /* Number of args */
230502 sqlite3_value **apUnused /* Function arguments */
230503 ){
230504 assert( nArg==0 );
230505 UNUSED_PARAM2(nArg, apUnused);
230506 sqlite3_result_text(pCtx, "fts5: 2021-06-04 23:26:56 1c71de43dbc68002c4a6229e7efffb019655baff67a51fe922571fe420c95835", -1, SQLITE_TRANSIENT);
230507 }
230508
230509 /*
230510 ** Return true if zName is the extension on one of the shadow tables used
230511 ** by this module.
@@ -235427,12 +235480,12 @@
235427 }
235428 #endif /* SQLITE_CORE */
235429 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235430
235431 /************** End of stmt.c ************************************************/
235432 #if __LINE__!=235432
235433 #undef SQLITE_SOURCE_ID
235434 #define SQLITE_SOURCE_ID "2021-06-07 00:41:18 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f4alt2"
235435 #endif
235436 /* Return the source-id for this library */
235437 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235438 /************************** End of sqlite3.c ******************************/
235439
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1205,11 +1205,11 @@
1205 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1206 ** [sqlite_version()] and [sqlite_source_id()].
1207 */
1208 #define SQLITE_VERSION "3.36.0"
1209 #define SQLITE_VERSION_NUMBER 3036000
1210 #define SQLITE_SOURCE_ID "2021-06-14 14:52:27 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1d94b"
1211
1212 /*
1213 ** CAPI3REF: Run-Time Library Version Numbers
1214 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1215 **
@@ -16558,10 +16558,16 @@
16558 */
16559 #ifndef SET_FULLSYNC
16560 # define SET_FULLSYNC(x,y)
16561 #endif
16562
16563 /* Maximum pathname length. Note: FILENAME_MAX defined by stdio.h
16564 */
16565 #ifndef SQLITE_MAX_PATHLEN
16566 # define SQLITE_MAX_PATHLEN FILENAME_MAX
16567 #endif
16568
16569 /*
16570 ** The default size of a disk sector
16571 */
16572 #ifndef SQLITE_DEFAULT_SECTOR_SIZE
16573 # define SQLITE_DEFAULT_SECTOR_SIZE 4096
@@ -20158,10 +20164,11 @@
20164 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
20165 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
20166 SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
20167 SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
20168 SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
20169 SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p);
20170
20171 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
20172 SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
20173 #endif
20174
@@ -20568,11 +20575,11 @@
20575 #ifndef SQLITE_OMIT_CTE
20576 SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8);
20577 SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*);
20578 SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*);
20579 SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*);
20580 SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8);
20581 #else
20582 # define sqlite3CteNew(P,T,E,S) ((void*)0)
20583 # define sqlite3CteDelete(D,C)
20584 # define sqlite3CteWithAdd(P,W,C) ((void*)0)
20585 # define sqlite3WithDelete(x,y)
@@ -21670,11 +21677,11 @@
21677 SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
21678 SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
21679 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
21680 SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
21681 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
21682 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, i64, u8, void(*)(void*));
21683 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
21684 #ifdef SQLITE_OMIT_FLOATING_POINT
21685 # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
21686 #else
21687 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
@@ -23667,10 +23674,12 @@
23674 zPathOut[0] = 0;
23675 return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);
23676 }
23677 #ifndef SQLITE_OMIT_LOAD_EXTENSION
23678 SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
23679 assert( zPath!=0 );
23680 assert( strlen(zPath)<=SQLITE_MAX_PATHLEN ); /* tag-20210611-1 */
23681 return pVfs->xDlOpen(pVfs, zPath);
23682 }
23683 SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
23684 pVfs->xDlError(pVfs, nByte, zBufOut);
23685 }
@@ -66965,11 +66974,11 @@
66974 testcase( pc+size==usableSize );
66975 put2byte(pAddr, cbrk);
66976 if( temp==0 ){
66977 if( cbrk==pc ) continue;
66978 temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
66979 memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart);
66980 src = temp;
66981 }
66982 memcpy(&data[cbrk], &src[pc], size);
66983 }
66984 data[hdr+7] = 0;
@@ -78047,15 +78056,15 @@
78056 ** either case, SQLITE_TOOBIG is returned.
78057 */
78058 SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
78059 Mem *pMem, /* Memory cell to set to string value */
78060 const char *z, /* String pointer */
78061 i64 n, /* Bytes in string, or negative */
78062 u8 enc, /* Encoding of z. 0 for BLOBs */
78063 void (*xDel)(void*) /* Destructor function */
78064 ){
78065 i64 nByte = n; /* New value for pMem->n */
78066 int iLimit; /* Maximum allowed string or blob size */
78067 u16 flags = 0; /* New value for pMem->flags */
78068
78069 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
78070 assert( !sqlite3VdbeMemIsRowSet(pMem) );
@@ -78073,11 +78082,11 @@
78082 }
78083 flags = (enc==0?MEM_Blob:MEM_Str);
78084 if( nByte<0 ){
78085 assert( enc!=0 );
78086 if( enc==SQLITE_UTF8 ){
78087 nByte = strlen(z);
78088 }else{
78089 for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}
78090 }
78091 flags |= MEM_Term;
78092 }
@@ -78085,11 +78094,11 @@
78094 /* The following block sets the new values of Mem.z and Mem.xDel. It
78095 ** also sets a flag in local variable "flags" to indicate the memory
78096 ** management (one of MEM_Dyn or MEM_Static).
78097 */
78098 if( xDel==SQLITE_TRANSIENT ){
78099 i64 nAlloc = nByte;
78100 if( flags&MEM_Term ){
78101 nAlloc += (enc==SQLITE_UTF8?1:2);
78102 }
78103 if( nByte>iLimit ){
78104 return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
@@ -78111,11 +78120,11 @@
78120 pMem->xDel = xDel;
78121 flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
78122 }
78123 }
78124
78125 pMem->n = (int)(nByte & 0x7fffffff);
78126 pMem->flags = flags;
78127 if( enc ){
78128 pMem->enc = enc;
78129 #ifdef SQLITE_ENABLE_SESSION
78130 }else if( pMem->db==0 ){
@@ -78131,11 +78140,11 @@
78140 return SQLITE_NOMEM_BKPT;
78141 }
78142 #endif
78143
78144 if( nByte>iLimit ){
78145 return sqlite3ErrorToParser(pMem->db, SQLITE_TOOBIG);
78146 }
78147
78148 return SQLITE_OK;
78149 }
78150
@@ -84527,11 +84536,11 @@
84536 }else if( xDel==SQLITE_TRANSIENT ){
84537 /* noop */
84538 }else{
84539 xDel((void*)p);
84540 }
84541 sqlite3_result_error_toobig(pCtx);
84542 return SQLITE_TOOBIG;
84543 }
84544 SQLITE_API void sqlite3_result_blob(
84545 sqlite3_context *pCtx,
84546 const void *z,
@@ -85509,11 +85518,11 @@
85518 */
85519 static int bindText(
85520 sqlite3_stmt *pStmt, /* The statement to bind against */
85521 int i, /* Index of the parameter to bind */
85522 const void *zData, /* Pointer to the data to be bound */
85523 i64 nData, /* Number of bytes of data to be bound */
85524 void (*xDel)(void*), /* Destructor for the data */
85525 u8 encoding /* Encoding for the data */
85526 ){
85527 Vdbe *p = (Vdbe *)pStmt;
85528 Mem *pVar;
@@ -85561,15 +85570,11 @@
85570 const void *zData,
85571 sqlite3_uint64 nData,
85572 void (*xDel)(void*)
85573 ){
85574 assert( xDel!=SQLITE_DYNAMIC );
85575 return bindText(pStmt, i, zData, nData, xDel, 0);
 
 
 
 
85576 }
85577 SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
85578 int rc;
85579 Vdbe *p = (Vdbe *)pStmt;
85580 rc = vdbeUnbind(p, i);
@@ -85635,16 +85640,12 @@
85640 sqlite3_uint64 nData,
85641 void (*xDel)(void*),
85642 unsigned char enc
85643 ){
85644 assert( xDel!=SQLITE_DYNAMIC );
85645 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
85646 return bindText(pStmt, i, zData, nData, xDel, enc);
 
 
 
 
85647 }
85648 #ifndef SQLITE_OMIT_UTF16
85649 SQLITE_API int sqlite3_bind_text16(
85650 sqlite3_stmt *pStmt,
85651 int i,
@@ -90957,11 +90958,12 @@
90958 assert( pOp[1].opcode==OP_SeekGE );
90959
90960 /* pOp->p2 points to the first instruction past the OP_IdxGT that
90961 ** follows the OP_SeekGE. */
90962 assert( pOp->p2>=(int)(pOp-aOp)+2 );
90963 assert( aOp[pOp->p2-1].opcode==OP_IdxGT || aOp[pOp->p2-1].opcode==OP_IdxGE );
90964 testcase( aOp[pOp->p2-1].opcode==OP_IdxGE );
90965 assert( pOp[1].p1==aOp[pOp->p2-1].p1 );
90966 assert( pOp[1].p2==aOp[pOp->p2-1].p2 );
90967 assert( pOp[1].p3==aOp[pOp->p2-1].p3 );
90968
90969 assert( pOp->p1>0 );
@@ -92847,11 +92849,13 @@
92849 }
92850 #endif
92851
92852 iDb = pOp->p1;
92853 assert( iDb>=0 && iDb<db->nDb );
92854 assert( DbHasProperty(db, iDb, DB_SchemaLoaded)
92855 || db->mallocFailed
92856 || (CORRUPT_DB && (db->flags & SQLITE_NoSchemaError)!=0) );
92857
92858 #ifndef SQLITE_OMIT_ALTERTABLE
92859 if( pOp->p4.z==0 ){
92860 sqlite3SchemaClear(db->aDb[iDb].pSchema);
92861 db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
@@ -102622,11 +102626,11 @@
102626 ** Create and return a deep copy of the object passed as the second
102627 ** argument. If an OOM condition is encountered, NULL is returned
102628 ** and the db->mallocFailed flag set.
102629 */
102630 #ifndef SQLITE_OMIT_CTE
102631 SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p){
102632 With *pRet = 0;
102633 if( p ){
102634 sqlite3_int64 nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
102635 pRet = sqlite3DbMallocZero(db, nByte);
102636 if( pRet ){
@@ -102640,11 +102644,11 @@
102644 }
102645 }
102646 return pRet;
102647 }
102648 #else
102649 # define sqlite3WithDup(x,y) 0
102650 #endif
102651
102652 #ifndef SQLITE_OMIT_WINDOWFUNC
102653 /*
102654 ** The gatherSelectWindows() procedure and its helper routine
@@ -102844,11 +102848,11 @@
102848 pNew->iOffset = 0;
102849 pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
102850 pNew->addrOpenEphm[0] = -1;
102851 pNew->addrOpenEphm[1] = -1;
102852 pNew->nSelectRow = p->nSelectRow;
102853 pNew->pWith = sqlite3WithDup(db, p->pWith);
102854 #ifndef SQLITE_OMIT_WINDOWFUNC
102855 pNew->pWin = 0;
102856 pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
102857 if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
102858 #endif
@@ -108184,19 +108188,34 @@
108188 ** to select statement pSelect.
108189 */
108190 static void renameWalkWith(Walker *pWalker, Select *pSelect){
108191 With *pWith = pSelect->pWith;
108192 if( pWith ){
108193 Parse *pParse = pWalker->pParse;
108194 int i;
108195 With *pCopy = 0;
108196 assert( pWith->nCte>0 );
108197 if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){
108198 /* Push a copy of the With object onto the with-stack. We use a copy
108199 ** here as the original will be expanded and resolved (flags SF_Expanded
108200 ** and SF_Resolved) below. And the parser code that uses the with-stack
108201 ** fails if the Select objects on it have already been expanded and
108202 ** resolved. */
108203 pCopy = sqlite3WithDup(pParse->db, pWith);
108204 pCopy = sqlite3WithPush(pParse, pCopy, 1);
108205 }
108206 for(i=0; i<pWith->nCte; i++){
108207 Select *p = pWith->a[i].pSelect;
108208 NameContext sNC;
108209 memset(&sNC, 0, sizeof(sNC));
108210 sNC.pParse = pParse;
108211 if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC);
108212 sqlite3WalkSelect(pWalker, p);
108213 sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols);
108214 }
108215 if( pCopy && pParse->pWith==pCopy ){
108216 pParse->pWith = pCopy->pOuter;
108217 }
108218 }
108219 }
108220
108221 /*
@@ -119237,17 +119256,19 @@
119256 ){
119257 /* This column was already computed by the previous index */
119258 continue;
119259 }
119260 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
119261 if( pIdx->aiColumn[j]>=0 ){
119262 /* If the column affinity is REAL but the number is an integer, then it
119263 ** might be stored in the table as an integer (using a compact
119264 ** representation) then converted to REAL by an OP_RealAffinity opcode.
119265 ** But we are getting ready to store this value back into an index, where
119266 ** it should be converted by to INTEGER again. So omit the
119267 ** OP_RealAffinity opcode if it is present */
119268 sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
119269 }
119270 }
119271 if( regOut ){
119272 sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
119273 }
119274 sqlite3ReleaseTempRange(pParse, regBase, nCol);
@@ -127401,11 +127422,11 @@
127422 sqlite3_loadext_entry xInit;
127423 char *zErrmsg = 0;
127424 const char *zEntry;
127425 char *zAltEntry = 0;
127426 void **aHandle;
127427 u64 nMsg = strlen(zFile);
127428 int ii;
127429 int rc;
127430
127431 /* Shared library endings to try if zFile cannot be loaded as written */
127432 static const char *azEndings[] = {
@@ -127435,30 +127456,26 @@
127456 return SQLITE_ERROR;
127457 }
127458
127459 zEntry = zProc ? zProc : "sqlite3_extension_init";
127460
127461 /* tag-20210611-1. Some dlopen() implementations will segfault if given
127462 ** an oversize filename. Most filesystems have a pathname limit of 4K,
127463 ** so limit the extension filename length to about twice that.
127464 ** https://sqlite.org/forum/forumpost/08a0d6d9bf */
127465 if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found;
127466
127467 handle = sqlite3OsDlOpen(pVfs, zFile);
127468 #if SQLITE_OS_UNIX || SQLITE_OS_WIN
127469 for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
127470 char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
127471 if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
127472 handle = sqlite3OsDlOpen(pVfs, zAltFile);
127473 sqlite3_free(zAltFile);
127474 }
127475 #endif
127476 if( handle==0 ) goto extension_not_found;
 
 
 
 
 
 
 
 
 
 
127477 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127478
127479 /* If no entry point was specified and the default legacy
127480 ** entry point name "sqlite3_extension_init" was not found, then
127481 ** construct an entry point name "sqlite3_X_init" where the X is
@@ -127491,14 +127508,15 @@
127508 zEntry = zAltEntry;
127509 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
127510 }
127511 if( xInit==0 ){
127512 if( pzErrMsg ){
127513 nMsg += strlen(zEntry) + 300;
127514 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127515 if( zErrmsg ){
127516 assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127517 sqlite3_snprintf((int)nMsg, zErrmsg,
127518 "no entry point [%s] in shared library [%s]", zEntry, zFile);
127519 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127520 }
127521 }
127522 sqlite3OsDlClose(pVfs, handle);
@@ -127528,10 +127546,23 @@
127546 sqlite3DbFree(db, db->aExtension);
127547 db->aExtension = aHandle;
127548
127549 db->aExtension[db->nExtension++] = handle;
127550 return SQLITE_OK;
127551
127552 extension_not_found:
127553 if( pzErrMsg ){
127554 nMsg += 300;
127555 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
127556 if( zErrmsg ){
127557 assert( nMsg<0x7fffffff ); /* zErrmsg would be NULL if not so */
127558 sqlite3_snprintf((int)nMsg, zErrmsg,
127559 "unable to open shared library [%.*s]", SQLITE_MAX_PATHLEN, zFile);
127560 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
127561 }
127562 }
127563 return SQLITE_ERROR;
127564 }
127565 SQLITE_API int sqlite3_load_extension(
127566 sqlite3 *db, /* Load the extension into this database connection */
127567 const char *zFile, /* Name of the shared library containing extension */
127568 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -131368,13 +131399,15 @@
131399 if( rc==SQLITE_OK ){
131400 sqlite3AnalysisLoad(db, iDb);
131401 }
131402 #endif
131403 }
131404 assert( pDb == &(db->aDb[iDb]) );
131405 if( db->mallocFailed ){
131406 rc = SQLITE_NOMEM_BKPT;
131407 sqlite3ResetAllSchemasOfConnection(db);
131408 pDb = &db->aDb[iDb];
131409 }else
131410 if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
131411 /* Hack: If the SQLITE_NoSchemaError flag is set, then consider
131412 ** the schema loaded, even if errors (other than OOM) occurred. In
131413 ** this situation the current sqlite3_prepare() operation will fail,
@@ -136426,10 +136459,11 @@
136459 ** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
136460 */
136461 typedef struct WhereConst WhereConst;
136462 struct WhereConst {
136463 Parse *pParse; /* Parsing context */
136464 u8 *pOomFault; /* Pointer to pParse->db->mallocFailed */
136465 int nConst; /* Number for COLUMN=CONSTANT terms */
136466 int nChng; /* Number of times a constant is propagated */
136467 int bHasAffBlob; /* At least one column in apExpr[] as affinity BLOB */
136468 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
136469 };
@@ -136525,10 +136559,11 @@
136559 WhereConst *pConst,
136560 Expr *pExpr,
136561 int bIgnoreAffBlob
136562 ){
136563 int i;
136564 if( pConst->pOomFault[0] ) return WRC_Prune;
136565 if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
136566 if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){
136567 testcase( ExprHasProperty(pExpr, EP_FixedCol) );
136568 testcase( ExprHasProperty(pExpr, EP_FromJoin) );
136569 return WRC_Continue;
@@ -136545,10 +136580,11 @@
136580 pConst->nChng++;
136581 ExprClearProperty(pExpr, EP_Leaf);
136582 ExprSetProperty(pExpr, EP_FixedCol);
136583 assert( pExpr->pLeft==0 );
136584 pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
136585 if( pConst->pParse->db->mallocFailed ) return WRC_Prune;
136586 break;
136587 }
136588 return WRC_Prune;
136589 }
136590
@@ -136577,10 +136613,11 @@
136613 if( pConst->bHasAffBlob ){
136614 if( (pExpr->op>=TK_EQ && pExpr->op<=TK_GE)
136615 || pExpr->op==TK_IS
136616 ){
136617 propagateConstantExprRewriteOne(pConst, pExpr->pLeft, 0);
136618 if( pConst->pOomFault[0] ) return WRC_Prune;
136619 if( sqlite3ExprAffinity(pExpr->pLeft)!=SQLITE_AFF_TEXT ){
136620 propagateConstantExprRewriteOne(pConst, pExpr->pRight, 0);
136621 }
136622 }
136623 }
@@ -136644,10 +136681,11 @@
136681 ){
136682 WhereConst x;
136683 Walker w;
136684 int nChng = 0;
136685 x.pParse = pParse;
136686 x.pOomFault = &pParse->db->mallocFailed;
136687 do{
136688 x.nConst = 0;
136689 x.nChng = 0;
136690 x.apExpr = 0;
136691 x.bHasAffBlob = 0;
@@ -137099,25 +137137,33 @@
137137 ** onto the top of the stack. If argument bFree is true, then this
137138 ** WITH clause will never be popped from the stack but should instead
137139 ** be freed along with the Parse object. In other cases, when
137140 ** bFree==0, the With object will be freed along with the SELECT
137141 ** statement with which it is associated.
137142 **
137143 ** This routine returns a copy of pWith. Or, if bFree is true and
137144 ** the pWith object is destroyed immediately due to an OOM condition,
137145 ** then this routine return NULL.
137146 **
137147 ** If bFree is true, do not continue to use the pWith pointer after
137148 ** calling this routine, Instead, use only the return value.
137149 */
137150 SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
137151 if( pWith ){
137152 if( bFree ){
137153 pWith = (With*)sqlite3ParserAddCleanup(pParse,
137154 (void(*)(sqlite3*,void*))sqlite3WithDelete,
137155 pWith);
137156 if( pWith==0 ) return 0;
137157 }
137158 if( pParse->nErr==0 ){
137159 assert( pParse->pWith!=pWith );
137160 pWith->pOuter = pParse->pWith;
137161 pParse->pWith = pWith;
137162 }
 
 
 
 
 
 
137163 }
137164 return pWith;
137165 }
137166
137167 /*
137168 ** This function checks if argument pFrom refers to a CTE declared by
137169 ** a WITH clause on the stack currently maintained by the parser (on the
@@ -137474,10 +137520,11 @@
137520 ){
137521 sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
137522 pTab->zName);
137523 }
137524 #ifndef SQLITE_OMIT_VIRTUALTABLE
137525 assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 );
137526 if( IsVirtual(pTab)
137527 && pFrom->fg.fromDDL
137528 && ALWAYS(pTab->pVTable!=0)
137529 && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
137530 ){
@@ -183221,12 +183268,12 @@
183268 int nPrev, /* Size of buffer zPrev in bytes */
183269 const char *zNext, /* Buffer containing next term */
183270 int nNext /* Size of buffer zNext in bytes */
183271 ){
183272 int n;
183273 for(n=0; n<nPrev && n<nNext && zPrev[n]==zNext[n]; n++);
183274 assert_fts3_nc( n<nNext );
183275 return n;
183276 }
183277
183278 /*
183279 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
@@ -184221,11 +184268,11 @@
184268 iDelta = (i64)((u64)iDocid - (u64)iPrev);
184269 }
184270
184271 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
184272
184273 rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING);
184274 if( rc ) return rc;
184275
184276 if( isFirst ){
184277 char *a = &pCsr->aBuffer[nDoclist];
184278 int nWrite;
@@ -216164,10 +216211,11 @@
216211 return 1;
216212 }else{
216213 i64 iOff = *piOff;
216214 int iVal;
216215 fts5FastGetVarint32(a, i, iVal);
216216 assert( iVal>=0 );
216217 if( iVal<=1 ){
216218 if( iVal==0 ){
216219 *pi = i;
216220 return 0;
216221 }
@@ -216177,13 +216225,16 @@
216225 if( iVal<2 ){
216226 /* This is a corrupt record. So stop parsing it here. */
216227 *piOff = -1;
216228 return 1;
216229 }
216230 *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216231 }else{
216232 *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
216233 }
 
216234 *pi = i;
216235 assert( *piOff>=iOff );
216236 return 0;
216237 }
216238 }
216239
216240
@@ -216218,18 +216269,20 @@
216269 static void sqlite3Fts5PoslistSafeAppend(
216270 Fts5Buffer *pBuf,
216271 i64 *piPrev,
216272 i64 iPos
216273 ){
216274 if( iPos>=*piPrev ){
216275 static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;
216276 if( (iPos & colmask) != (*piPrev & colmask) ){
216277 pBuf->p[pBuf->n++] = 1;
216278 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));
216279 *piPrev = (iPos & colmask);
216280 }
216281 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);
216282 *piPrev = iPos;
216283 }
216284 }
216285
216286 static int sqlite3Fts5PoslistWriterAppend(
216287 Fts5Buffer *pBuf,
216288 Fts5PoslistWriter *pWriter,
@@ -224157,11 +224210,11 @@
224210 pIter->base.nData = p-aCopy;
224211 return;
224212 }
224213 fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy);
224214 }
224215 if( p>=pEnd ){
224216 pIter->base.pData = pIter->poslist.p;
224217 pIter->base.nData = pIter->poslist.n;
224218 return;
224219 }
224220 aCopy = p++;
@@ -225953,11 +226006,11 @@
226006 Fts5Buffer *p1, /* First list to merge */
226007 int nBuf, /* Number of buffers in array aBuf[] */
226008 Fts5Buffer *aBuf /* Other lists to merge in */
226009 ){
226010 #define fts5PrefixMergerNextPosition(p) \
226011 sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos)
226012 #define FTS5_MERGE_NLIST 16
226013 PrefixMerger aMerger[FTS5_MERGE_NLIST];
226014 PrefixMerger *pHead = 0;
226015 int i;
226016 int nOut = 0;
@@ -230501,11 +230554,11 @@
230554 int nArg, /* Number of args */
230555 sqlite3_value **apUnused /* Function arguments */
230556 ){
230557 assert( nArg==0 );
230558 UNUSED_PARAM2(nArg, apUnused);
230559 sqlite3_result_text(pCtx, "fts5: 2021-06-14 11:20:30 7068f1f69b4feef49260e80902e6bdae47c21a0daa16c96ed1a0984dd1f14cdc", -1, SQLITE_TRANSIENT);
230560 }
230561
230562 /*
230563 ** Return true if zName is the extension on one of the shadow tables used
230564 ** by this module.
@@ -235427,12 +235480,12 @@
235480 }
235481 #endif /* SQLITE_CORE */
235482 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235483
235484 /************** End of stmt.c ************************************************/
235485 #if __LINE__!=235485
235486 #undef SQLITE_SOURCE_ID
235487 #define SQLITE_SOURCE_ID "2021-06-14 14:52:27 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1alt2"
235488 #endif
235489 /* Return the source-id for this library */
235490 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235491 /************************** End of sqlite3.c ******************************/
235492
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.36.0"
127127
#define SQLITE_VERSION_NUMBER 3036000
128
-#define SQLITE_SOURCE_ID "2021-06-07 00:41:18 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f41819"
128
+#define SQLITE_SOURCE_ID "2021-06-14 14:52:27 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1d94b"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.36.0"
127 #define SQLITE_VERSION_NUMBER 3036000
128 #define SQLITE_SOURCE_ID "2021-06-07 00:41:18 2aa9368b63b42ac7c700516f109edcc6098c12b850eae591afed4e51a3f41819"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.36.0"
127 #define SQLITE_VERSION_NUMBER 3036000
128 #define SQLITE_SOURCE_ID "2021-06-14 14:52:27 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1d94b"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134

Keyboard Shortcuts

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