Fossil SCM

Update the built-in SQLite to the latest 3.36.0 alpha for testing.

drh 2021-05-17 18:00 trunk
Commit 1d54782957e4b7f0134a2a8c360fb35e62bb3cee04521715724a407addedf9e4
2 files changed +159 -63 +1 -1
+159 -63
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1186,11 +1186,11 @@
11861186
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11871187
** [sqlite_version()] and [sqlite_source_id()].
11881188
*/
11891189
#define SQLITE_VERSION "3.36.0"
11901190
#define SQLITE_VERSION_NUMBER 3036000
1191
-#define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5"
1191
+#define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09"
11921192
11931193
/*
11941194
** CAPI3REF: Run-Time Library Version Numbers
11951195
** KEYWORDS: sqlite3_version sqlite3_sourceid
11961196
**
@@ -19448,10 +19448,16 @@
1944819448
SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*);
1944919449
1945019450
#ifdef SQLITE_DEBUG
1945119451
SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
1945219452
#endif
19453
+
19454
+#ifndef SQLITE_OMIT_CTE
19455
+SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*);
19456
+#else
19457
+# define sqlite3SelectPopWith 0
19458
+#endif
1945319459
1945419460
/*
1945519461
** Return code from the parse-tree walking primitives and their
1945619462
** callbacks.
1945719463
*/
@@ -48580,11 +48586,14 @@
4858048586
memdbDlClose, /* xDlClose */
4858148587
memdbRandomness, /* xRandomness */
4858248588
memdbSleep, /* xSleep */
4858348589
0, /* memdbCurrentTime, */ /* xCurrentTime */
4858448590
memdbGetLastError, /* xGetLastError */
48585
- memdbCurrentTimeInt64 /* xCurrentTimeInt64 */
48591
+ memdbCurrentTimeInt64, /* xCurrentTimeInt64 */
48592
+ 0, /* xSetSystemCall */
48593
+ 0, /* xGetSystemCall */
48594
+ 0, /* xNextSystemCall */
4858648595
};
4858748596
4858848597
static const sqlite3_io_methods memdb_io_methods = {
4858948598
3, /* iVersion */
4859048599
memdbClose, /* xClose */
@@ -48608,16 +48617,25 @@
4860848617
};
4860948618
4861048619
/*
4861148620
** Enter/leave the mutex on a MemStore
4861248621
*/
48622
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
48623
+static void memdbEnter(MemStore *p){
48624
+ UNUSED_PARAMETER(p);
48625
+}
48626
+static void memdbLeave(MemStore *p){
48627
+ UNUSED_PARAMETER(p);
48628
+}
48629
+#else
4861348630
static void memdbEnter(MemStore *p){
4861448631
sqlite3_mutex_enter(p->pMutex);
4861548632
}
4861648633
static void memdbLeave(MemStore *p){
4861748634
sqlite3_mutex_leave(p->pMutex);
4861848635
}
48636
+#endif
4861948637
4862048638
4862148639
4862248640
/*
4862348641
** Close an memdb-file.
@@ -48760,10 +48778,12 @@
4876048778
4876148779
/*
4876248780
** Sync an memdb-file.
4876348781
*/
4876448782
static int memdbSync(sqlite3_file *pFile, int flags){
48783
+ UNUSED_PARAMETER(pFile);
48784
+ UNUSED_PARAMETER(flags);
4876548785
return SQLITE_OK;
4876648786
}
4876748787
4876848788
/*
4876948789
** Return the current file-size of an memdb-file.
@@ -48869,10 +48889,11 @@
4886948889
4887048890
/*
4887148891
** Return the device characteristic flags supported by an memdb-file.
4887248892
*/
4887348893
static int memdbDeviceCharacteristics(sqlite3_file *pFile){
48894
+ UNUSED_PARAMETER(pFile);
4887448895
return SQLITE_IOCAP_ATOMIC |
4887548896
SQLITE_IOCAP_POWERSAFE_OVERWRITE |
4887648897
SQLITE_IOCAP_SAFE_APPEND |
4887748898
SQLITE_IOCAP_SEQUENTIAL;
4887848899
}
@@ -48897,10 +48918,12 @@
4889748918
}
4889848919
4889948920
/* Release a memory-mapped page */
4890048921
static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
4890148922
MemStore *p = ((MemFile*)pFile)->pStore;
48923
+ UNUSED_PARAMETER(iOfst);
48924
+ UNUSED_PARAMETER(pPage);
4890248925
memdbEnter(p);
4890348926
p->nMmap--;
4890448927
memdbLeave(p);
4890548928
return SQLITE_OK;
4890648929
}
@@ -49009,10 +49032,13 @@
4900949032
sqlite3_vfs *pVfs,
4901049033
const char *zPath,
4901149034
int flags,
4901249035
int *pResOut
4901349036
){
49037
+ UNUSED_PARAMETER(pVfs);
49038
+ UNUSED_PARAMETER(zPath);
49039
+ UNUSED_PARAMETER(flags);
4901449040
*pResOut = 0;
4901549041
return SQLITE_OK;
4901649042
}
4901749043
4901849044
/*
@@ -49024,10 +49050,11 @@
4902449050
sqlite3_vfs *pVfs,
4902549051
const char *zPath,
4902649052
int nOut,
4902749053
char *zOut
4902849054
){
49055
+ UNUSED_PARAMETER(pVfs);
4902949056
sqlite3_snprintf(nOut, zOut, "%s", zPath);
4903049057
return SQLITE_OK;
4903149058
}
4903249059
4903349060
/*
@@ -49268,11 +49295,11 @@
4926849295
** This routine is called when the extension is loaded.
4926949296
** Register the new VFS.
4927049297
*/
4927149298
SQLITE_PRIVATE int sqlite3MemdbInit(void){
4927249299
sqlite3_vfs *pLower = sqlite3_vfs_find(0);
49273
- int sz = pLower->szOsFile;
49300
+ unsigned int sz = pLower->szOsFile;
4927449301
memdb_vfs.pAppData = pLower;
4927549302
/* The following conditional can only be true when compiled for
4927649303
** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
4927749304
** it in, to be safe, but it is marked as NO_TEST since there
4927849305
** is no way to reach it under most builds. */
@@ -65884,11 +65911,11 @@
6588465911
Pgno pgnoRoot, /* The table that might be changing */
6588565912
i64 iRow, /* The rowid that might be changing */
6588665913
int isClearTable /* True if all rows are being deleted */
6588765914
){
6588865915
BtCursor *p;
65889
- if( pBtree->hasIncrblobCur==0 ) return;
65916
+ assert( pBtree->hasIncrblobCur );
6589065917
assert( sqlite3BtreeHoldsMutex(pBtree) );
6589165918
pBtree->hasIncrblobCur = 0;
6589265919
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
6589365920
if( (p->curFlags & BTCF_Incrblob)!=0 ){
6589465921
pBtree->hasIncrblobCur = 1;
@@ -71756,14 +71783,13 @@
7175671783
*pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
7175771784
}
7175871785
}
7175971786
7176071787
/*
71761
-** Free any overflow pages associated with the given Cell. Store
71762
-** size information about the cell in pInfo.
71788
+** Free the overflow pages associated with the given Cell.
7176371789
*/
71764
-static int clearCell(
71790
+static SQLITE_NOINLINE int clearCellOverflow(
7176571791
MemPage *pPage, /* The page that contains the Cell */
7176671792
unsigned char *pCell, /* First byte of the Cell */
7176771793
CellInfo *pInfo /* Size information about the cell */
7176871794
){
7176971795
BtShared *pBt;
@@ -71771,14 +71797,11 @@
7177171797
int rc;
7177271798
int nOvfl;
7177371799
u32 ovflPageSize;
7177471800
7177571801
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
71776
- pPage->xParseCell(pPage, pCell, pInfo);
71777
- if( pInfo->nLocal==pInfo->nPayload ){
71778
- return SQLITE_OK; /* No overflow pages. Return without doing anything */
71779
- }
71802
+ assert( pInfo->nLocal!=pInfo->nPayload );
7178071803
testcase( pCell + pInfo->nSize == pPage->aDataEnd );
7178171804
testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
7178271805
if( pCell + pInfo->nSize > pPage->aDataEnd ){
7178371806
/* Cell extends past end of page */
7178471807
return SQLITE_CORRUPT_PAGE(pPage);
@@ -71829,10 +71852,25 @@
7182971852
if( rc ) return rc;
7183071853
ovflPgno = iNext;
7183171854
}
7183271855
return SQLITE_OK;
7183371856
}
71857
+
71858
+/* Call xParseCell to compute the size of a cell. If the cell contains
71859
+** overflow, then invoke cellClearOverflow to clear out that overflow.
71860
+** STore the result code (SQLITE_OK or some error code) in rc.
71861
+**
71862
+** Implemented as macro to force inlining for performance.
71863
+*/
71864
+#define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \
71865
+ pPage->xParseCell(pPage, pCell, &sInfo); \
71866
+ if( sInfo.nLocal!=sInfo.nPayload ){ \
71867
+ rc = clearCellOverflow(pPage, pCell, &sInfo); \
71868
+ }else{ \
71869
+ rc = SQLITE_OK; \
71870
+ }
71871
+
7183471872
7183571873
/*
7183671874
** Create the byte sequence used to represent a cell on page pPage
7183771875
** and write that byte sequence into pCell[]. Overflow pages are
7183871876
** allocated and filled in as necessary. The calling procedure
@@ -74089,11 +74127,13 @@
7408974127
7409074128
if( pCur->pKeyInfo==0 ){
7409174129
assert( pX->pKey==0 );
7409274130
/* If this is an insert into a table b-tree, invalidate any incrblob
7409374131
** cursors open on the row being replaced */
74094
- invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
74132
+ if( p->hasIncrblobCur ){
74133
+ invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
74134
+ }
7409574135
7409674136
/* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
7409774137
** to a row with the same key as the new entry being inserted.
7409874138
*/
7409974139
#ifdef SQLITE_DEBUG
@@ -74223,11 +74263,11 @@
7422374263
}
7422474264
oldCell = findCell(pPage, idx);
7422574265
if( !pPage->leaf ){
7422674266
memcpy(newCell, oldCell, 4);
7422774267
}
74228
- rc = clearCell(pPage, oldCell, &info);
74268
+ BTREE_CLEAR_CELL(rc, pPage, oldCell, info);
7422974269
testcase( pCur->curFlags & BTCF_ValidOvfl );
7423074270
invalidateOverflowCache(pCur);
7423174271
if( info.nSize==szNew && info.nLocal==info.nPayload
7423274272
&& (!ISAUTOVACUUM || szNew<pPage->minLocal)
7423374273
){
@@ -74516,20 +74556,20 @@
7451674556
if( rc ) return rc;
7451774557
}
7451874558
7451974559
/* If this is a delete operation to remove a row from a table b-tree,
7452074560
** invalidate any incrblob cursors open on the row being deleted. */
74521
- if( pCur->pKeyInfo==0 ){
74561
+ if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){
7452274562
invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
7452374563
}
7452474564
7452574565
/* Make the page containing the entry to be deleted writable. Then free any
7452674566
** overflow pages associated with the entry and finally remove the cell
7452774567
** itself from within the page. */
7452874568
rc = sqlite3PagerWrite(pPage->pDbPage);
7452974569
if( rc ) return rc;
74530
- rc = clearCell(pPage, pCell, &info);
74570
+ BTREE_CLEAR_CELL(rc, pPage, pCell, info);
7453174571
dropCell(pPage, iCellIdx, info.nSize, &rc);
7453274572
if( rc ) return rc;
7453374573
7453474574
/* If the cell deleted was not located on a leaf page, then the cursor
7453574575
** is currently pointing to the largest entry in the sub-tree headed
@@ -74812,11 +74852,11 @@
7481274852
pCell = findCell(pPage, i);
7481374853
if( !pPage->leaf ){
7481474854
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
7481574855
if( rc ) goto cleardatabasepage_out;
7481674856
}
74817
- rc = clearCell(pPage, pCell, &info);
74857
+ BTREE_CLEAR_CELL(rc, pPage, pCell, info);
7481874858
if( rc ) goto cleardatabasepage_out;
7481974859
}
7482074860
if( !pPage->leaf ){
7482174861
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
7482274862
if( rc ) goto cleardatabasepage_out;
@@ -74860,11 +74900,13 @@
7486074900
7486174901
if( SQLITE_OK==rc ){
7486274902
/* Invalidate all incrblob cursors open on table iTable (assuming iTable
7486374903
** is the root of a table b-tree - if it is not, the following call is
7486474904
** a no-op). */
74865
- invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
74905
+ if( p->hasIncrblobCur ){
74906
+ invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
74907
+ }
7486674908
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
7486774909
}
7486874910
sqlite3BtreeLeave(p);
7486974911
return rc;
7487074912
}
@@ -76943,11 +76985,13 @@
7694376985
assert( (p->flags & MEM_Cleared)==0 );
7694476986
}
7694576987
7694676988
/* The szMalloc field holds the correct memory allocation size */
7694776989
assert( p->szMalloc==0
76948
- || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );
76990
+ || (p->flags==MEM_Undefined
76991
+ && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc))
76992
+ || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc));
7694976993
7695076994
/* If p holds a string or blob, the Mem.z must point to exactly
7695176995
** one of the following:
7695276996
**
7695376997
** (1) Memory in Mem.zMalloc and managed by the Mem object
@@ -77107,11 +77151,13 @@
7710777151
** contain a valid string or blob value. */
7710877152
assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
7710977153
testcase( bPreserve && pMem->z==0 );
7711077154
7711177155
assert( pMem->szMalloc==0
77112
- || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
77156
+ || (pMem->flags==MEM_Undefined
77157
+ && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc))
77158
+ || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc));
7711377159
if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
7711477160
if( pMem->db ){
7711577161
pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
7711677162
}else{
7711777163
pMem->zMalloc = sqlite3Realloc(pMem->z, n);
@@ -86561,22 +86607,40 @@
8656186607
assert( iCur>=0 && iCur<p->nCursor );
8656286608
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
8656386609
sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
8656486610
p->apCsr[iCur] = 0;
8656586611
}
86566
- if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
86567
- p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
86568
- memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86569
- pCx->eCurType = eCurType;
86570
- pCx->iDb = iDb;
86571
- pCx->nField = nField;
86572
- pCx->aOffset = &pCx->aType[nField];
86573
- if( eCurType==CURTYPE_BTREE ){
86574
- pCx->uc.pCursor = (BtCursor*)
86575
- &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86576
- sqlite3BtreeCursorZero(pCx->uc.pCursor);
86577
- }
86612
+
86613
+ /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure
86614
+ ** the pMem used to hold space for the cursor has enough storage available
86615
+ ** in pMem->zMalloc. But for the special case of the aMem[] entries used
86616
+ ** to hold cursors, it is faster to in-line the logic. */
86617
+ assert( pMem->flags==MEM_Undefined );
86618
+ assert( (pMem->flags & MEM_Dyn)==0 );
86619
+ assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc );
86620
+ if( pMem->szMalloc<nByte ){
86621
+ if( pMem->szMalloc>0 ){
86622
+ sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
86623
+ }
86624
+ pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
86625
+ if( pMem->zMalloc==0 ){
86626
+ pMem->szMalloc = 0;
86627
+ return 0;
86628
+ }
86629
+ pMem->szMalloc = nByte;
86630
+ }
86631
+
86632
+ p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
86633
+ memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86634
+ pCx->eCurType = eCurType;
86635
+ pCx->iDb = iDb;
86636
+ pCx->nField = nField;
86637
+ pCx->aOffset = &pCx->aType[nField];
86638
+ if( eCurType==CURTYPE_BTREE ){
86639
+ pCx->uc.pCursor = (BtCursor*)
86640
+ &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86641
+ sqlite3BtreeCursorZero(pCx->uc.pCursor);
8657886642
}
8657986643
return pCx;
8658086644
}
8658186645
8658286646
/*
@@ -88401,10 +88465,35 @@
8840188465
8840288466
pIn1 = &aMem[pOp->p1];
8840388467
pIn3 = &aMem[pOp->p3];
8840488468
flags1 = pIn1->flags;
8840588469
flags3 = pIn3->flags;
88470
+ if( (flags1 & flags3 & MEM_Int)!=0 ){
88471
+ assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT );
88472
+ /* Common case of comparison of two integers */
88473
+ if( pIn3->u.i > pIn1->u.i ){
88474
+ iCompare = +1;
88475
+ if( sqlite3aGTb[pOp->opcode] ){
88476
+ VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88477
+ goto jump_to_p2;
88478
+ }
88479
+ }else if( pIn3->u.i < pIn1->u.i ){
88480
+ iCompare = -1;
88481
+ if( sqlite3aLTb[pOp->opcode] ){
88482
+ VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88483
+ goto jump_to_p2;
88484
+ }
88485
+ }else{
88486
+ iCompare = 0;
88487
+ if( sqlite3aEQb[pOp->opcode] ){
88488
+ VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88489
+ goto jump_to_p2;
88490
+ }
88491
+ }
88492
+ VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88493
+ break;
88494
+ }
8840688495
if( (flags1 | flags3)&MEM_Null ){
8840788496
/* One or both operands are NULL */
8840888497
if( pOp->p5 & SQLITE_NULLEQ ){
8840988498
/* If SQLITE_NULLEQ is set (which will only happen if the operator is
8841088499
** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -88431,11 +88520,12 @@
8843188520
goto jump_to_p2;
8843288521
}
8843388522
break;
8843488523
}
8843588524
}else{
88436
- /* Neither operand is NULL. Do a comparison. */
88525
+ /* Neither operand is NULL and we couldn't do the special high-speed
88526
+ ** integer comparison case. So do a general-case comparison. */
8843788527
affinity = pOp->p5 & SQLITE_AFF_MASK;
8843888528
if( affinity>=SQLITE_AFF_NUMERIC ){
8843988529
if( (flags1 | flags3)&MEM_Str ){
8844088530
if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
8844188531
applyNumericAffinity(pIn1,0);
@@ -88444,18 +88534,10 @@
8844488534
}
8844588535
if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
8844688536
applyNumericAffinity(pIn3,0);
8844788537
}
8844888538
}
88449
- /* Handle the common case of integer comparison here, as an
88450
- ** optimization, to avoid a call to sqlite3MemCompare() */
88451
- if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){
88452
- if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }
88453
- if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }
88454
- res = 0;
88455
- goto compare_op;
88456
- }
8845788539
}else if( affinity==SQLITE_AFF_TEXT ){
8845888540
if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
8845988541
testcase( pIn1->flags & MEM_Int );
8846088542
testcase( pIn1->flags & MEM_Real );
8846188543
testcase( pIn1->flags & MEM_IntReal );
@@ -88474,11 +88556,11 @@
8847488556
}
8847588557
}
8847688558
assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
8847788559
res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
8847888560
}
88479
-compare_op:
88561
+
8848088562
/* At this point, res is negative, zero, or positive if reg[P1] is
8848188563
** less than, equal to, or greater than reg[P3], respectively. Compute
8848288564
** the answer to this operator in res2, depending on what the comparison
8848388565
** operator actually is. The next block of code depends on the fact
8848488566
** that the 6 comparison operators are consecutive integers in this
@@ -98926,10 +99008,13 @@
9892699008
#if !defined(SQLITE_OMIT_WINDOWFUNC)
9892799009
if( p->pWinDefn ){
9892899010
Parse *pParse;
9892999011
if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback
9893099012
|| ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT)
99013
+#ifndef SQLITE_OMIT_CTE
99014
+ || pWalker->xSelectCallback2==sqlite3SelectPopWith
99015
+#endif
9893199016
){
9893299017
/* The following may return WRC_Abort if there are unresolvable
9893399018
** symbols (e.g. a table that does not exist) in a window definition. */
9893499019
int rc = walkWindowList(pWalker, p->pWinDefn, 0);
9893599020
return rc;
@@ -100757,10 +100842,23 @@
100757100842
&& sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
100758100843
){
100759100844
return WRC_Abort;
100760100845
}
100761100846
}
100847
+
100848
+#ifndef SQLITE_OMIT_WINDOWFUNC
100849
+ if( IN_RENAME_OBJECT ){
100850
+ Window *pWin;
100851
+ for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100852
+ if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100853
+ || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100854
+ ){
100855
+ return WRC_Abort;
100856
+ }
100857
+ }
100858
+ }
100859
+#endif
100762100860
100763100861
/* The ORDER BY and GROUP BY clauses may not refer to terms in
100764100862
** outer queries
100765100863
*/
100766100864
sNC.pNext = 0;
@@ -100814,23 +100912,10 @@
100814100912
return WRC_Abort;
100815100913
}
100816100914
}
100817100915
}
100818100916
100819
-#ifndef SQLITE_OMIT_WINDOWFUNC
100820
- if( IN_RENAME_OBJECT ){
100821
- Window *pWin;
100822
- for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100823
- if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100824
- || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100825
- ){
100826
- return WRC_Abort;
100827
- }
100828
- }
100829
- }
100830
-#endif
100831
-
100832100917
/* If this is part of a compound SELECT, check that it has the right
100833100918
** number of expressions in the select list. */
100834100919
if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
100835100920
sqlite3SelectWrongNumTermsError(pParse, p->pNext);
100836100921
return WRC_Abort;
@@ -112251,11 +112336,11 @@
112251112336
**
112252112337
** This routine just records the fact that the lock is desired. The
112253112338
** code to make the lock occur is generated by a later call to
112254112339
** codeTableLocks() which occurs during sqlite3FinishCoding().
112255112340
*/
112256
-SQLITE_PRIVATE void sqlite3TableLock(
112341
+static SQLITE_NOINLINE void lockTable(
112257112342
Parse *pParse, /* Parsing context */
112258112343
int iDb, /* Index of the database containing the table to lock */
112259112344
Pgno iTab, /* Root page number of the table to be locked */
112260112345
u8 isWriteLock, /* True for a write lock */
112261112346
const char *zName /* Name of the table to be locked */
@@ -112264,12 +112349,10 @@
112264112349
int i;
112265112350
int nBytes;
112266112351
TableLock *p;
112267112352
assert( iDb>=0 );
112268112353
112269
- if( iDb==1 ) return;
112270
- if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
112271112354
pToplevel = sqlite3ParseToplevel(pParse);
112272112355
for(i=0; i<pToplevel->nTableLock; i++){
112273112356
p = &pToplevel->aTableLock[i];
112274112357
if( p->iDb==iDb && p->iTab==iTab ){
112275112358
p->isWriteLock = (p->isWriteLock || isWriteLock);
@@ -112289,10 +112372,21 @@
112289112372
}else{
112290112373
pToplevel->nTableLock = 0;
112291112374
sqlite3OomFault(pToplevel->db);
112292112375
}
112293112376
}
112377
+SQLITE_PRIVATE void sqlite3TableLock(
112378
+ Parse *pParse, /* Parsing context */
112379
+ int iDb, /* Index of the database containing the table to lock */
112380
+ Pgno iTab, /* Root page number of the table to be locked */
112381
+ u8 isWriteLock, /* True for a write lock */
112382
+ const char *zName /* Name of the table to be locked */
112383
+){
112384
+ if( iDb==1 ) return;
112385
+ if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
112386
+ lockTable(pParse, iDb, iTab, isWriteLock, zName);
112387
+}
112294112388
112295112389
/*
112296112390
** Code an OP_TableLock instruction for each table locked by the
112297112391
** statement (configured by calls to sqlite3TableLock()).
112298112392
*/
@@ -137047,22 +137141,20 @@
137047137141
**
137048137142
** This function is used as the xSelectCallback2() callback by
137049137143
** sqlite3SelectExpand() when walking a SELECT tree to resolve table
137050137144
** names and other FROM clause elements.
137051137145
*/
137052
-static void selectPopWith(Walker *pWalker, Select *p){
137146
+SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){
137053137147
Parse *pParse = pWalker->pParse;
137054137148
if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){
137055137149
With *pWith = findRightmost(p)->pWith;
137056137150
if( pWith!=0 ){
137057137151
assert( pParse->pWith==pWith || pParse->nErr );
137058137152
pParse->pWith = pWith->pOuter;
137059137153
}
137060137154
}
137061137155
}
137062
-#else
137063
-#define selectPopWith 0
137064137156
#endif
137065137157
137066137158
/*
137067137159
** The SrcList_item structure passed as the second argument represents a
137068137160
** sub-query in the FROM clause of a SELECT statement. This function
@@ -137445,11 +137537,11 @@
137445137537
w.xSelectCallback = convertCompoundSelectToSubquery;
137446137538
w.xSelectCallback2 = 0;
137447137539
sqlite3WalkSelect(&w, pSelect);
137448137540
}
137449137541
w.xSelectCallback = selectExpander;
137450
- w.xSelectCallback2 = selectPopWith;
137542
+ w.xSelectCallback2 = sqlite3SelectPopWith;
137451137543
w.eCode = 0;
137452137544
sqlite3WalkSelect(&w, pSelect);
137453137545
}
137454137546
137455137547
@@ -166602,10 +166694,14 @@
166602166694
assert( !db->mallocFailed );
166603166695
return SQLITE_BUSY;
166604166696
}else{
166605166697
sqlite3ExpirePreparedStatements(db, 0);
166606166698
}
166699
+ }else if( xSFunc==0 && xFinal==0 ){
166700
+ /* Trying to delete a function that does not exist. This is a no-op.
166701
+ ** https://sqlite.org/forum/forumpost/726219164b */
166702
+ return SQLITE_OK;
166607166703
}
166608166704
166609166705
p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
166610166706
assert(p || db->mallocFailed);
166611166707
if( !p ){
@@ -235089,12 +235185,12 @@
235089235185
}
235090235186
#endif /* SQLITE_CORE */
235091235187
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235092235188
235093235189
/************** End of stmt.c ************************************************/
235094
-#if __LINE__!=235094
235190
+#if __LINE__!=235190
235095235191
#undef SQLITE_SOURCE_ID
235096
-#define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e117alt2"
235192
+#define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671baalt2"
235097235193
#endif
235098235194
/* Return the source-id for this library */
235099235195
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235100235196
/************************** End of sqlite3.c ******************************/
235101235197
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1186,11 +1186,11 @@
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.36.0"
1190 #define SQLITE_VERSION_NUMBER 3036000
1191 #define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -19448,10 +19448,16 @@
19448 SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*);
19449
19450 #ifdef SQLITE_DEBUG
19451 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
19452 #endif
 
 
 
 
 
 
19453
19454 /*
19455 ** Return code from the parse-tree walking primitives and their
19456 ** callbacks.
19457 */
@@ -48580,11 +48586,14 @@
48580 memdbDlClose, /* xDlClose */
48581 memdbRandomness, /* xRandomness */
48582 memdbSleep, /* xSleep */
48583 0, /* memdbCurrentTime, */ /* xCurrentTime */
48584 memdbGetLastError, /* xGetLastError */
48585 memdbCurrentTimeInt64 /* xCurrentTimeInt64 */
 
 
 
48586 };
48587
48588 static const sqlite3_io_methods memdb_io_methods = {
48589 3, /* iVersion */
48590 memdbClose, /* xClose */
@@ -48608,16 +48617,25 @@
48608 };
48609
48610 /*
48611 ** Enter/leave the mutex on a MemStore
48612 */
 
 
 
 
 
 
 
 
48613 static void memdbEnter(MemStore *p){
48614 sqlite3_mutex_enter(p->pMutex);
48615 }
48616 static void memdbLeave(MemStore *p){
48617 sqlite3_mutex_leave(p->pMutex);
48618 }
 
48619
48620
48621
48622 /*
48623 ** Close an memdb-file.
@@ -48760,10 +48778,12 @@
48760
48761 /*
48762 ** Sync an memdb-file.
48763 */
48764 static int memdbSync(sqlite3_file *pFile, int flags){
 
 
48765 return SQLITE_OK;
48766 }
48767
48768 /*
48769 ** Return the current file-size of an memdb-file.
@@ -48869,10 +48889,11 @@
48869
48870 /*
48871 ** Return the device characteristic flags supported by an memdb-file.
48872 */
48873 static int memdbDeviceCharacteristics(sqlite3_file *pFile){
 
48874 return SQLITE_IOCAP_ATOMIC |
48875 SQLITE_IOCAP_POWERSAFE_OVERWRITE |
48876 SQLITE_IOCAP_SAFE_APPEND |
48877 SQLITE_IOCAP_SEQUENTIAL;
48878 }
@@ -48897,10 +48918,12 @@
48897 }
48898
48899 /* Release a memory-mapped page */
48900 static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
48901 MemStore *p = ((MemFile*)pFile)->pStore;
 
 
48902 memdbEnter(p);
48903 p->nMmap--;
48904 memdbLeave(p);
48905 return SQLITE_OK;
48906 }
@@ -49009,10 +49032,13 @@
49009 sqlite3_vfs *pVfs,
49010 const char *zPath,
49011 int flags,
49012 int *pResOut
49013 ){
 
 
 
49014 *pResOut = 0;
49015 return SQLITE_OK;
49016 }
49017
49018 /*
@@ -49024,10 +49050,11 @@
49024 sqlite3_vfs *pVfs,
49025 const char *zPath,
49026 int nOut,
49027 char *zOut
49028 ){
 
49029 sqlite3_snprintf(nOut, zOut, "%s", zPath);
49030 return SQLITE_OK;
49031 }
49032
49033 /*
@@ -49268,11 +49295,11 @@
49268 ** This routine is called when the extension is loaded.
49269 ** Register the new VFS.
49270 */
49271 SQLITE_PRIVATE int sqlite3MemdbInit(void){
49272 sqlite3_vfs *pLower = sqlite3_vfs_find(0);
49273 int sz = pLower->szOsFile;
49274 memdb_vfs.pAppData = pLower;
49275 /* The following conditional can only be true when compiled for
49276 ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
49277 ** it in, to be safe, but it is marked as NO_TEST since there
49278 ** is no way to reach it under most builds. */
@@ -65884,11 +65911,11 @@
65884 Pgno pgnoRoot, /* The table that might be changing */
65885 i64 iRow, /* The rowid that might be changing */
65886 int isClearTable /* True if all rows are being deleted */
65887 ){
65888 BtCursor *p;
65889 if( pBtree->hasIncrblobCur==0 ) return;
65890 assert( sqlite3BtreeHoldsMutex(pBtree) );
65891 pBtree->hasIncrblobCur = 0;
65892 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
65893 if( (p->curFlags & BTCF_Incrblob)!=0 ){
65894 pBtree->hasIncrblobCur = 1;
@@ -71756,14 +71783,13 @@
71756 *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
71757 }
71758 }
71759
71760 /*
71761 ** Free any overflow pages associated with the given Cell. Store
71762 ** size information about the cell in pInfo.
71763 */
71764 static int clearCell(
71765 MemPage *pPage, /* The page that contains the Cell */
71766 unsigned char *pCell, /* First byte of the Cell */
71767 CellInfo *pInfo /* Size information about the cell */
71768 ){
71769 BtShared *pBt;
@@ -71771,14 +71797,11 @@
71771 int rc;
71772 int nOvfl;
71773 u32 ovflPageSize;
71774
71775 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
71776 pPage->xParseCell(pPage, pCell, pInfo);
71777 if( pInfo->nLocal==pInfo->nPayload ){
71778 return SQLITE_OK; /* No overflow pages. Return without doing anything */
71779 }
71780 testcase( pCell + pInfo->nSize == pPage->aDataEnd );
71781 testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
71782 if( pCell + pInfo->nSize > pPage->aDataEnd ){
71783 /* Cell extends past end of page */
71784 return SQLITE_CORRUPT_PAGE(pPage);
@@ -71829,10 +71852,25 @@
71829 if( rc ) return rc;
71830 ovflPgno = iNext;
71831 }
71832 return SQLITE_OK;
71833 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71834
71835 /*
71836 ** Create the byte sequence used to represent a cell on page pPage
71837 ** and write that byte sequence into pCell[]. Overflow pages are
71838 ** allocated and filled in as necessary. The calling procedure
@@ -74089,11 +74127,13 @@
74089
74090 if( pCur->pKeyInfo==0 ){
74091 assert( pX->pKey==0 );
74092 /* If this is an insert into a table b-tree, invalidate any incrblob
74093 ** cursors open on the row being replaced */
74094 invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
 
 
74095
74096 /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
74097 ** to a row with the same key as the new entry being inserted.
74098 */
74099 #ifdef SQLITE_DEBUG
@@ -74223,11 +74263,11 @@
74223 }
74224 oldCell = findCell(pPage, idx);
74225 if( !pPage->leaf ){
74226 memcpy(newCell, oldCell, 4);
74227 }
74228 rc = clearCell(pPage, oldCell, &info);
74229 testcase( pCur->curFlags & BTCF_ValidOvfl );
74230 invalidateOverflowCache(pCur);
74231 if( info.nSize==szNew && info.nLocal==info.nPayload
74232 && (!ISAUTOVACUUM || szNew<pPage->minLocal)
74233 ){
@@ -74516,20 +74556,20 @@
74516 if( rc ) return rc;
74517 }
74518
74519 /* If this is a delete operation to remove a row from a table b-tree,
74520 ** invalidate any incrblob cursors open on the row being deleted. */
74521 if( pCur->pKeyInfo==0 ){
74522 invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
74523 }
74524
74525 /* Make the page containing the entry to be deleted writable. Then free any
74526 ** overflow pages associated with the entry and finally remove the cell
74527 ** itself from within the page. */
74528 rc = sqlite3PagerWrite(pPage->pDbPage);
74529 if( rc ) return rc;
74530 rc = clearCell(pPage, pCell, &info);
74531 dropCell(pPage, iCellIdx, info.nSize, &rc);
74532 if( rc ) return rc;
74533
74534 /* If the cell deleted was not located on a leaf page, then the cursor
74535 ** is currently pointing to the largest entry in the sub-tree headed
@@ -74812,11 +74852,11 @@
74812 pCell = findCell(pPage, i);
74813 if( !pPage->leaf ){
74814 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
74815 if( rc ) goto cleardatabasepage_out;
74816 }
74817 rc = clearCell(pPage, pCell, &info);
74818 if( rc ) goto cleardatabasepage_out;
74819 }
74820 if( !pPage->leaf ){
74821 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
74822 if( rc ) goto cleardatabasepage_out;
@@ -74860,11 +74900,13 @@
74860
74861 if( SQLITE_OK==rc ){
74862 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
74863 ** is the root of a table b-tree - if it is not, the following call is
74864 ** a no-op). */
74865 invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
 
 
74866 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
74867 }
74868 sqlite3BtreeLeave(p);
74869 return rc;
74870 }
@@ -76943,11 +76985,13 @@
76943 assert( (p->flags & MEM_Cleared)==0 );
76944 }
76945
76946 /* The szMalloc field holds the correct memory allocation size */
76947 assert( p->szMalloc==0
76948 || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );
 
 
76949
76950 /* If p holds a string or blob, the Mem.z must point to exactly
76951 ** one of the following:
76952 **
76953 ** (1) Memory in Mem.zMalloc and managed by the Mem object
@@ -77107,11 +77151,13 @@
77107 ** contain a valid string or blob value. */
77108 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
77109 testcase( bPreserve && pMem->z==0 );
77110
77111 assert( pMem->szMalloc==0
77112 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
 
 
77113 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
77114 if( pMem->db ){
77115 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
77116 }else{
77117 pMem->zMalloc = sqlite3Realloc(pMem->z, n);
@@ -86561,22 +86607,40 @@
86561 assert( iCur>=0 && iCur<p->nCursor );
86562 if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
86563 sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
86564 p->apCsr[iCur] = 0;
86565 }
86566 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
86567 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
86568 memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86569 pCx->eCurType = eCurType;
86570 pCx->iDb = iDb;
86571 pCx->nField = nField;
86572 pCx->aOffset = &pCx->aType[nField];
86573 if( eCurType==CURTYPE_BTREE ){
86574 pCx->uc.pCursor = (BtCursor*)
86575 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86576 sqlite3BtreeCursorZero(pCx->uc.pCursor);
86577 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86578 }
86579 return pCx;
86580 }
86581
86582 /*
@@ -88401,10 +88465,35 @@
88401
88402 pIn1 = &aMem[pOp->p1];
88403 pIn3 = &aMem[pOp->p3];
88404 flags1 = pIn1->flags;
88405 flags3 = pIn3->flags;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88406 if( (flags1 | flags3)&MEM_Null ){
88407 /* One or both operands are NULL */
88408 if( pOp->p5 & SQLITE_NULLEQ ){
88409 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
88410 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -88431,11 +88520,12 @@
88431 goto jump_to_p2;
88432 }
88433 break;
88434 }
88435 }else{
88436 /* Neither operand is NULL. Do a comparison. */
 
88437 affinity = pOp->p5 & SQLITE_AFF_MASK;
88438 if( affinity>=SQLITE_AFF_NUMERIC ){
88439 if( (flags1 | flags3)&MEM_Str ){
88440 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88441 applyNumericAffinity(pIn1,0);
@@ -88444,18 +88534,10 @@
88444 }
88445 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88446 applyNumericAffinity(pIn3,0);
88447 }
88448 }
88449 /* Handle the common case of integer comparison here, as an
88450 ** optimization, to avoid a call to sqlite3MemCompare() */
88451 if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){
88452 if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }
88453 if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }
88454 res = 0;
88455 goto compare_op;
88456 }
88457 }else if( affinity==SQLITE_AFF_TEXT ){
88458 if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
88459 testcase( pIn1->flags & MEM_Int );
88460 testcase( pIn1->flags & MEM_Real );
88461 testcase( pIn1->flags & MEM_IntReal );
@@ -88474,11 +88556,11 @@
88474 }
88475 }
88476 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
88477 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
88478 }
88479 compare_op:
88480 /* At this point, res is negative, zero, or positive if reg[P1] is
88481 ** less than, equal to, or greater than reg[P3], respectively. Compute
88482 ** the answer to this operator in res2, depending on what the comparison
88483 ** operator actually is. The next block of code depends on the fact
88484 ** that the 6 comparison operators are consecutive integers in this
@@ -98926,10 +99008,13 @@
98926 #if !defined(SQLITE_OMIT_WINDOWFUNC)
98927 if( p->pWinDefn ){
98928 Parse *pParse;
98929 if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback
98930 || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT)
 
 
 
98931 ){
98932 /* The following may return WRC_Abort if there are unresolvable
98933 ** symbols (e.g. a table that does not exist) in a window definition. */
98934 int rc = walkWindowList(pWalker, p->pWinDefn, 0);
98935 return rc;
@@ -100757,10 +100842,23 @@
100757 && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
100758 ){
100759 return WRC_Abort;
100760 }
100761 }
 
 
 
 
 
 
 
 
 
 
 
 
 
100762
100763 /* The ORDER BY and GROUP BY clauses may not refer to terms in
100764 ** outer queries
100765 */
100766 sNC.pNext = 0;
@@ -100814,23 +100912,10 @@
100814 return WRC_Abort;
100815 }
100816 }
100817 }
100818
100819 #ifndef SQLITE_OMIT_WINDOWFUNC
100820 if( IN_RENAME_OBJECT ){
100821 Window *pWin;
100822 for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100823 if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100824 || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100825 ){
100826 return WRC_Abort;
100827 }
100828 }
100829 }
100830 #endif
100831
100832 /* If this is part of a compound SELECT, check that it has the right
100833 ** number of expressions in the select list. */
100834 if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
100835 sqlite3SelectWrongNumTermsError(pParse, p->pNext);
100836 return WRC_Abort;
@@ -112251,11 +112336,11 @@
112251 **
112252 ** This routine just records the fact that the lock is desired. The
112253 ** code to make the lock occur is generated by a later call to
112254 ** codeTableLocks() which occurs during sqlite3FinishCoding().
112255 */
112256 SQLITE_PRIVATE void sqlite3TableLock(
112257 Parse *pParse, /* Parsing context */
112258 int iDb, /* Index of the database containing the table to lock */
112259 Pgno iTab, /* Root page number of the table to be locked */
112260 u8 isWriteLock, /* True for a write lock */
112261 const char *zName /* Name of the table to be locked */
@@ -112264,12 +112349,10 @@
112264 int i;
112265 int nBytes;
112266 TableLock *p;
112267 assert( iDb>=0 );
112268
112269 if( iDb==1 ) return;
112270 if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
112271 pToplevel = sqlite3ParseToplevel(pParse);
112272 for(i=0; i<pToplevel->nTableLock; i++){
112273 p = &pToplevel->aTableLock[i];
112274 if( p->iDb==iDb && p->iTab==iTab ){
112275 p->isWriteLock = (p->isWriteLock || isWriteLock);
@@ -112289,10 +112372,21 @@
112289 }else{
112290 pToplevel->nTableLock = 0;
112291 sqlite3OomFault(pToplevel->db);
112292 }
112293 }
 
 
 
 
 
 
 
 
 
 
 
112294
112295 /*
112296 ** Code an OP_TableLock instruction for each table locked by the
112297 ** statement (configured by calls to sqlite3TableLock()).
112298 */
@@ -137047,22 +137141,20 @@
137047 **
137048 ** This function is used as the xSelectCallback2() callback by
137049 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
137050 ** names and other FROM clause elements.
137051 */
137052 static void selectPopWith(Walker *pWalker, Select *p){
137053 Parse *pParse = pWalker->pParse;
137054 if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){
137055 With *pWith = findRightmost(p)->pWith;
137056 if( pWith!=0 ){
137057 assert( pParse->pWith==pWith || pParse->nErr );
137058 pParse->pWith = pWith->pOuter;
137059 }
137060 }
137061 }
137062 #else
137063 #define selectPopWith 0
137064 #endif
137065
137066 /*
137067 ** The SrcList_item structure passed as the second argument represents a
137068 ** sub-query in the FROM clause of a SELECT statement. This function
@@ -137445,11 +137537,11 @@
137445 w.xSelectCallback = convertCompoundSelectToSubquery;
137446 w.xSelectCallback2 = 0;
137447 sqlite3WalkSelect(&w, pSelect);
137448 }
137449 w.xSelectCallback = selectExpander;
137450 w.xSelectCallback2 = selectPopWith;
137451 w.eCode = 0;
137452 sqlite3WalkSelect(&w, pSelect);
137453 }
137454
137455
@@ -166602,10 +166694,14 @@
166602 assert( !db->mallocFailed );
166603 return SQLITE_BUSY;
166604 }else{
166605 sqlite3ExpirePreparedStatements(db, 0);
166606 }
 
 
 
 
166607 }
166608
166609 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
166610 assert(p || db->mallocFailed);
166611 if( !p ){
@@ -235089,12 +235185,12 @@
235089 }
235090 #endif /* SQLITE_CORE */
235091 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235092
235093 /************** End of stmt.c ************************************************/
235094 #if __LINE__!=235094
235095 #undef SQLITE_SOURCE_ID
235096 #define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e117alt2"
235097 #endif
235098 /* Return the source-id for this library */
235099 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235100 /************************** End of sqlite3.c ******************************/
235101
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1186,11 +1186,11 @@
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.36.0"
1190 #define SQLITE_VERSION_NUMBER 3036000
1191 #define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -19448,10 +19448,16 @@
19448 SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*);
19449
19450 #ifdef SQLITE_DEBUG
19451 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
19452 #endif
19453
19454 #ifndef SQLITE_OMIT_CTE
19455 SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*);
19456 #else
19457 # define sqlite3SelectPopWith 0
19458 #endif
19459
19460 /*
19461 ** Return code from the parse-tree walking primitives and their
19462 ** callbacks.
19463 */
@@ -48580,11 +48586,14 @@
48586 memdbDlClose, /* xDlClose */
48587 memdbRandomness, /* xRandomness */
48588 memdbSleep, /* xSleep */
48589 0, /* memdbCurrentTime, */ /* xCurrentTime */
48590 memdbGetLastError, /* xGetLastError */
48591 memdbCurrentTimeInt64, /* xCurrentTimeInt64 */
48592 0, /* xSetSystemCall */
48593 0, /* xGetSystemCall */
48594 0, /* xNextSystemCall */
48595 };
48596
48597 static const sqlite3_io_methods memdb_io_methods = {
48598 3, /* iVersion */
48599 memdbClose, /* xClose */
@@ -48608,16 +48617,25 @@
48617 };
48618
48619 /*
48620 ** Enter/leave the mutex on a MemStore
48621 */
48622 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
48623 static void memdbEnter(MemStore *p){
48624 UNUSED_PARAMETER(p);
48625 }
48626 static void memdbLeave(MemStore *p){
48627 UNUSED_PARAMETER(p);
48628 }
48629 #else
48630 static void memdbEnter(MemStore *p){
48631 sqlite3_mutex_enter(p->pMutex);
48632 }
48633 static void memdbLeave(MemStore *p){
48634 sqlite3_mutex_leave(p->pMutex);
48635 }
48636 #endif
48637
48638
48639
48640 /*
48641 ** Close an memdb-file.
@@ -48760,10 +48778,12 @@
48778
48779 /*
48780 ** Sync an memdb-file.
48781 */
48782 static int memdbSync(sqlite3_file *pFile, int flags){
48783 UNUSED_PARAMETER(pFile);
48784 UNUSED_PARAMETER(flags);
48785 return SQLITE_OK;
48786 }
48787
48788 /*
48789 ** Return the current file-size of an memdb-file.
@@ -48869,10 +48889,11 @@
48889
48890 /*
48891 ** Return the device characteristic flags supported by an memdb-file.
48892 */
48893 static int memdbDeviceCharacteristics(sqlite3_file *pFile){
48894 UNUSED_PARAMETER(pFile);
48895 return SQLITE_IOCAP_ATOMIC |
48896 SQLITE_IOCAP_POWERSAFE_OVERWRITE |
48897 SQLITE_IOCAP_SAFE_APPEND |
48898 SQLITE_IOCAP_SEQUENTIAL;
48899 }
@@ -48897,10 +48918,12 @@
48918 }
48919
48920 /* Release a memory-mapped page */
48921 static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
48922 MemStore *p = ((MemFile*)pFile)->pStore;
48923 UNUSED_PARAMETER(iOfst);
48924 UNUSED_PARAMETER(pPage);
48925 memdbEnter(p);
48926 p->nMmap--;
48927 memdbLeave(p);
48928 return SQLITE_OK;
48929 }
@@ -49009,10 +49032,13 @@
49032 sqlite3_vfs *pVfs,
49033 const char *zPath,
49034 int flags,
49035 int *pResOut
49036 ){
49037 UNUSED_PARAMETER(pVfs);
49038 UNUSED_PARAMETER(zPath);
49039 UNUSED_PARAMETER(flags);
49040 *pResOut = 0;
49041 return SQLITE_OK;
49042 }
49043
49044 /*
@@ -49024,10 +49050,11 @@
49050 sqlite3_vfs *pVfs,
49051 const char *zPath,
49052 int nOut,
49053 char *zOut
49054 ){
49055 UNUSED_PARAMETER(pVfs);
49056 sqlite3_snprintf(nOut, zOut, "%s", zPath);
49057 return SQLITE_OK;
49058 }
49059
49060 /*
@@ -49268,11 +49295,11 @@
49295 ** This routine is called when the extension is loaded.
49296 ** Register the new VFS.
49297 */
49298 SQLITE_PRIVATE int sqlite3MemdbInit(void){
49299 sqlite3_vfs *pLower = sqlite3_vfs_find(0);
49300 unsigned int sz = pLower->szOsFile;
49301 memdb_vfs.pAppData = pLower;
49302 /* The following conditional can only be true when compiled for
49303 ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
49304 ** it in, to be safe, but it is marked as NO_TEST since there
49305 ** is no way to reach it under most builds. */
@@ -65884,11 +65911,11 @@
65911 Pgno pgnoRoot, /* The table that might be changing */
65912 i64 iRow, /* The rowid that might be changing */
65913 int isClearTable /* True if all rows are being deleted */
65914 ){
65915 BtCursor *p;
65916 assert( pBtree->hasIncrblobCur );
65917 assert( sqlite3BtreeHoldsMutex(pBtree) );
65918 pBtree->hasIncrblobCur = 0;
65919 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
65920 if( (p->curFlags & BTCF_Incrblob)!=0 ){
65921 pBtree->hasIncrblobCur = 1;
@@ -71756,14 +71783,13 @@
71783 *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
71784 }
71785 }
71786
71787 /*
71788 ** Free the overflow pages associated with the given Cell.
 
71789 */
71790 static SQLITE_NOINLINE int clearCellOverflow(
71791 MemPage *pPage, /* The page that contains the Cell */
71792 unsigned char *pCell, /* First byte of the Cell */
71793 CellInfo *pInfo /* Size information about the cell */
71794 ){
71795 BtShared *pBt;
@@ -71771,14 +71797,11 @@
71797 int rc;
71798 int nOvfl;
71799 u32 ovflPageSize;
71800
71801 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
71802 assert( pInfo->nLocal!=pInfo->nPayload );
 
 
 
71803 testcase( pCell + pInfo->nSize == pPage->aDataEnd );
71804 testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
71805 if( pCell + pInfo->nSize > pPage->aDataEnd ){
71806 /* Cell extends past end of page */
71807 return SQLITE_CORRUPT_PAGE(pPage);
@@ -71829,10 +71852,25 @@
71852 if( rc ) return rc;
71853 ovflPgno = iNext;
71854 }
71855 return SQLITE_OK;
71856 }
71857
71858 /* Call xParseCell to compute the size of a cell. If the cell contains
71859 ** overflow, then invoke cellClearOverflow to clear out that overflow.
71860 ** STore the result code (SQLITE_OK or some error code) in rc.
71861 **
71862 ** Implemented as macro to force inlining for performance.
71863 */
71864 #define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \
71865 pPage->xParseCell(pPage, pCell, &sInfo); \
71866 if( sInfo.nLocal!=sInfo.nPayload ){ \
71867 rc = clearCellOverflow(pPage, pCell, &sInfo); \
71868 }else{ \
71869 rc = SQLITE_OK; \
71870 }
71871
71872
71873 /*
71874 ** Create the byte sequence used to represent a cell on page pPage
71875 ** and write that byte sequence into pCell[]. Overflow pages are
71876 ** allocated and filled in as necessary. The calling procedure
@@ -74089,11 +74127,13 @@
74127
74128 if( pCur->pKeyInfo==0 ){
74129 assert( pX->pKey==0 );
74130 /* If this is an insert into a table b-tree, invalidate any incrblob
74131 ** cursors open on the row being replaced */
74132 if( p->hasIncrblobCur ){
74133 invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
74134 }
74135
74136 /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
74137 ** to a row with the same key as the new entry being inserted.
74138 */
74139 #ifdef SQLITE_DEBUG
@@ -74223,11 +74263,11 @@
74263 }
74264 oldCell = findCell(pPage, idx);
74265 if( !pPage->leaf ){
74266 memcpy(newCell, oldCell, 4);
74267 }
74268 BTREE_CLEAR_CELL(rc, pPage, oldCell, info);
74269 testcase( pCur->curFlags & BTCF_ValidOvfl );
74270 invalidateOverflowCache(pCur);
74271 if( info.nSize==szNew && info.nLocal==info.nPayload
74272 && (!ISAUTOVACUUM || szNew<pPage->minLocal)
74273 ){
@@ -74516,20 +74556,20 @@
74556 if( rc ) return rc;
74557 }
74558
74559 /* If this is a delete operation to remove a row from a table b-tree,
74560 ** invalidate any incrblob cursors open on the row being deleted. */
74561 if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){
74562 invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
74563 }
74564
74565 /* Make the page containing the entry to be deleted writable. Then free any
74566 ** overflow pages associated with the entry and finally remove the cell
74567 ** itself from within the page. */
74568 rc = sqlite3PagerWrite(pPage->pDbPage);
74569 if( rc ) return rc;
74570 BTREE_CLEAR_CELL(rc, pPage, pCell, info);
74571 dropCell(pPage, iCellIdx, info.nSize, &rc);
74572 if( rc ) return rc;
74573
74574 /* If the cell deleted was not located on a leaf page, then the cursor
74575 ** is currently pointing to the largest entry in the sub-tree headed
@@ -74812,11 +74852,11 @@
74852 pCell = findCell(pPage, i);
74853 if( !pPage->leaf ){
74854 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
74855 if( rc ) goto cleardatabasepage_out;
74856 }
74857 BTREE_CLEAR_CELL(rc, pPage, pCell, info);
74858 if( rc ) goto cleardatabasepage_out;
74859 }
74860 if( !pPage->leaf ){
74861 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
74862 if( rc ) goto cleardatabasepage_out;
@@ -74860,11 +74900,13 @@
74900
74901 if( SQLITE_OK==rc ){
74902 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
74903 ** is the root of a table b-tree - if it is not, the following call is
74904 ** a no-op). */
74905 if( p->hasIncrblobCur ){
74906 invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
74907 }
74908 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
74909 }
74910 sqlite3BtreeLeave(p);
74911 return rc;
74912 }
@@ -76943,11 +76985,13 @@
76985 assert( (p->flags & MEM_Cleared)==0 );
76986 }
76987
76988 /* The szMalloc field holds the correct memory allocation size */
76989 assert( p->szMalloc==0
76990 || (p->flags==MEM_Undefined
76991 && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc))
76992 || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc));
76993
76994 /* If p holds a string or blob, the Mem.z must point to exactly
76995 ** one of the following:
76996 **
76997 ** (1) Memory in Mem.zMalloc and managed by the Mem object
@@ -77107,11 +77151,13 @@
77151 ** contain a valid string or blob value. */
77152 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
77153 testcase( bPreserve && pMem->z==0 );
77154
77155 assert( pMem->szMalloc==0
77156 || (pMem->flags==MEM_Undefined
77157 && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc))
77158 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc));
77159 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
77160 if( pMem->db ){
77161 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
77162 }else{
77163 pMem->zMalloc = sqlite3Realloc(pMem->z, n);
@@ -86561,22 +86607,40 @@
86607 assert( iCur>=0 && iCur<p->nCursor );
86608 if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
86609 sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
86610 p->apCsr[iCur] = 0;
86611 }
86612
86613 /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure
86614 ** the pMem used to hold space for the cursor has enough storage available
86615 ** in pMem->zMalloc. But for the special case of the aMem[] entries used
86616 ** to hold cursors, it is faster to in-line the logic. */
86617 assert( pMem->flags==MEM_Undefined );
86618 assert( (pMem->flags & MEM_Dyn)==0 );
86619 assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc );
86620 if( pMem->szMalloc<nByte ){
86621 if( pMem->szMalloc>0 ){
86622 sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
86623 }
86624 pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
86625 if( pMem->zMalloc==0 ){
86626 pMem->szMalloc = 0;
86627 return 0;
86628 }
86629 pMem->szMalloc = nByte;
86630 }
86631
86632 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
86633 memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
86634 pCx->eCurType = eCurType;
86635 pCx->iDb = iDb;
86636 pCx->nField = nField;
86637 pCx->aOffset = &pCx->aType[nField];
86638 if( eCurType==CURTYPE_BTREE ){
86639 pCx->uc.pCursor = (BtCursor*)
86640 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
86641 sqlite3BtreeCursorZero(pCx->uc.pCursor);
86642 }
86643 return pCx;
86644 }
86645
86646 /*
@@ -88401,10 +88465,35 @@
88465
88466 pIn1 = &aMem[pOp->p1];
88467 pIn3 = &aMem[pOp->p3];
88468 flags1 = pIn1->flags;
88469 flags3 = pIn3->flags;
88470 if( (flags1 & flags3 & MEM_Int)!=0 ){
88471 assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT );
88472 /* Common case of comparison of two integers */
88473 if( pIn3->u.i > pIn1->u.i ){
88474 iCompare = +1;
88475 if( sqlite3aGTb[pOp->opcode] ){
88476 VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88477 goto jump_to_p2;
88478 }
88479 }else if( pIn3->u.i < pIn1->u.i ){
88480 iCompare = -1;
88481 if( sqlite3aLTb[pOp->opcode] ){
88482 VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88483 goto jump_to_p2;
88484 }
88485 }else{
88486 iCompare = 0;
88487 if( sqlite3aEQb[pOp->opcode] ){
88488 VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88489 goto jump_to_p2;
88490 }
88491 }
88492 VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
88493 break;
88494 }
88495 if( (flags1 | flags3)&MEM_Null ){
88496 /* One or both operands are NULL */
88497 if( pOp->p5 & SQLITE_NULLEQ ){
88498 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
88499 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -88431,11 +88520,12 @@
88520 goto jump_to_p2;
88521 }
88522 break;
88523 }
88524 }else{
88525 /* Neither operand is NULL and we couldn't do the special high-speed
88526 ** integer comparison case. So do a general-case comparison. */
88527 affinity = pOp->p5 & SQLITE_AFF_MASK;
88528 if( affinity>=SQLITE_AFF_NUMERIC ){
88529 if( (flags1 | flags3)&MEM_Str ){
88530 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88531 applyNumericAffinity(pIn1,0);
@@ -88444,18 +88534,10 @@
88534 }
88535 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
88536 applyNumericAffinity(pIn3,0);
88537 }
88538 }
 
 
 
 
 
 
 
 
88539 }else if( affinity==SQLITE_AFF_TEXT ){
88540 if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
88541 testcase( pIn1->flags & MEM_Int );
88542 testcase( pIn1->flags & MEM_Real );
88543 testcase( pIn1->flags & MEM_IntReal );
@@ -88474,11 +88556,11 @@
88556 }
88557 }
88558 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
88559 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
88560 }
88561
88562 /* At this point, res is negative, zero, or positive if reg[P1] is
88563 ** less than, equal to, or greater than reg[P3], respectively. Compute
88564 ** the answer to this operator in res2, depending on what the comparison
88565 ** operator actually is. The next block of code depends on the fact
88566 ** that the 6 comparison operators are consecutive integers in this
@@ -98926,10 +99008,13 @@
99008 #if !defined(SQLITE_OMIT_WINDOWFUNC)
99009 if( p->pWinDefn ){
99010 Parse *pParse;
99011 if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback
99012 || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT)
99013 #ifndef SQLITE_OMIT_CTE
99014 || pWalker->xSelectCallback2==sqlite3SelectPopWith
99015 #endif
99016 ){
99017 /* The following may return WRC_Abort if there are unresolvable
99018 ** symbols (e.g. a table that does not exist) in a window definition. */
99019 int rc = walkWindowList(pWalker, p->pWinDefn, 0);
99020 return rc;
@@ -100757,10 +100842,23 @@
100842 && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg)
100843 ){
100844 return WRC_Abort;
100845 }
100846 }
100847
100848 #ifndef SQLITE_OMIT_WINDOWFUNC
100849 if( IN_RENAME_OBJECT ){
100850 Window *pWin;
100851 for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
100852 if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
100853 || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
100854 ){
100855 return WRC_Abort;
100856 }
100857 }
100858 }
100859 #endif
100860
100861 /* The ORDER BY and GROUP BY clauses may not refer to terms in
100862 ** outer queries
100863 */
100864 sNC.pNext = 0;
@@ -100814,23 +100912,10 @@
100912 return WRC_Abort;
100913 }
100914 }
100915 }
100916
 
 
 
 
 
 
 
 
 
 
 
 
 
100917 /* If this is part of a compound SELECT, check that it has the right
100918 ** number of expressions in the select list. */
100919 if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
100920 sqlite3SelectWrongNumTermsError(pParse, p->pNext);
100921 return WRC_Abort;
@@ -112251,11 +112336,11 @@
112336 **
112337 ** This routine just records the fact that the lock is desired. The
112338 ** code to make the lock occur is generated by a later call to
112339 ** codeTableLocks() which occurs during sqlite3FinishCoding().
112340 */
112341 static SQLITE_NOINLINE void lockTable(
112342 Parse *pParse, /* Parsing context */
112343 int iDb, /* Index of the database containing the table to lock */
112344 Pgno iTab, /* Root page number of the table to be locked */
112345 u8 isWriteLock, /* True for a write lock */
112346 const char *zName /* Name of the table to be locked */
@@ -112264,12 +112349,10 @@
112349 int i;
112350 int nBytes;
112351 TableLock *p;
112352 assert( iDb>=0 );
112353
 
 
112354 pToplevel = sqlite3ParseToplevel(pParse);
112355 for(i=0; i<pToplevel->nTableLock; i++){
112356 p = &pToplevel->aTableLock[i];
112357 if( p->iDb==iDb && p->iTab==iTab ){
112358 p->isWriteLock = (p->isWriteLock || isWriteLock);
@@ -112289,10 +112372,21 @@
112372 }else{
112373 pToplevel->nTableLock = 0;
112374 sqlite3OomFault(pToplevel->db);
112375 }
112376 }
112377 SQLITE_PRIVATE void sqlite3TableLock(
112378 Parse *pParse, /* Parsing context */
112379 int iDb, /* Index of the database containing the table to lock */
112380 Pgno iTab, /* Root page number of the table to be locked */
112381 u8 isWriteLock, /* True for a write lock */
112382 const char *zName /* Name of the table to be locked */
112383 ){
112384 if( iDb==1 ) return;
112385 if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
112386 lockTable(pParse, iDb, iTab, isWriteLock, zName);
112387 }
112388
112389 /*
112390 ** Code an OP_TableLock instruction for each table locked by the
112391 ** statement (configured by calls to sqlite3TableLock()).
112392 */
@@ -137047,22 +137141,20 @@
137141 **
137142 ** This function is used as the xSelectCallback2() callback by
137143 ** sqlite3SelectExpand() when walking a SELECT tree to resolve table
137144 ** names and other FROM clause elements.
137145 */
137146 SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){
137147 Parse *pParse = pWalker->pParse;
137148 if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){
137149 With *pWith = findRightmost(p)->pWith;
137150 if( pWith!=0 ){
137151 assert( pParse->pWith==pWith || pParse->nErr );
137152 pParse->pWith = pWith->pOuter;
137153 }
137154 }
137155 }
 
 
137156 #endif
137157
137158 /*
137159 ** The SrcList_item structure passed as the second argument represents a
137160 ** sub-query in the FROM clause of a SELECT statement. This function
@@ -137445,11 +137537,11 @@
137537 w.xSelectCallback = convertCompoundSelectToSubquery;
137538 w.xSelectCallback2 = 0;
137539 sqlite3WalkSelect(&w, pSelect);
137540 }
137541 w.xSelectCallback = selectExpander;
137542 w.xSelectCallback2 = sqlite3SelectPopWith;
137543 w.eCode = 0;
137544 sqlite3WalkSelect(&w, pSelect);
137545 }
137546
137547
@@ -166602,10 +166694,14 @@
166694 assert( !db->mallocFailed );
166695 return SQLITE_BUSY;
166696 }else{
166697 sqlite3ExpirePreparedStatements(db, 0);
166698 }
166699 }else if( xSFunc==0 && xFinal==0 ){
166700 /* Trying to delete a function that does not exist. This is a no-op.
166701 ** https://sqlite.org/forum/forumpost/726219164b */
166702 return SQLITE_OK;
166703 }
166704
166705 p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
166706 assert(p || db->mallocFailed);
166707 if( !p ){
@@ -235089,12 +235185,12 @@
235185 }
235186 #endif /* SQLITE_CORE */
235187 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235188
235189 /************** End of stmt.c ************************************************/
235190 #if __LINE__!=235190
235191 #undef SQLITE_SOURCE_ID
235192 #define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671baalt2"
235193 #endif
235194 /* Return the source-id for this library */
235195 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235196 /************************** End of sqlite3.c ******************************/
235197
+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-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5"
128
+#define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09"
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-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5"
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-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09"
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