Fossil SCM

Update to SQLite 3.35.3 preview for testing.

drh 2021-03-22 12:43 trunk
Commit 8ec00b975b601b47d281215ede679d21b50048248f518e2d90ffc1c3fd8771fa
--- src/shell.c
+++ src/shell.c
@@ -13217,10 +13217,11 @@
1321713217
1321813218
rc = sqlite3_step(pStmt);
1321913219
if( rc!=SQLITE_ROW ) return;
1322013220
nColumn = sqlite3_column_count(pStmt);
1322113221
nAlloc = nColumn*4;
13222
+ if( nAlloc<=0 ) nAlloc = 1;
1322213223
azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
1322313224
if( azData==0 ) shell_out_of_memory();
1322413225
for(i=0; i<nColumn; i++){
1322513226
azData[i] = strdup(sqlite3_column_name(pStmt,i));
1322613227
}
@@ -13256,10 +13257,11 @@
1325613257
n = strlenChar(z);
1325713258
j = i%nColumn;
1325813259
if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
1325913260
}
1326013261
if( seenInterrupt ) goto columnar_end;
13262
+ if( nColumn==0 ) goto columnar_end;
1326113263
switch( p->cMode ){
1326213264
case MODE_Column: {
1326313265
colSep = " ";
1326413266
rowSep = "\n";
1326513267
if( p->showHeader ){
1326613268
--- src/shell.c
+++ src/shell.c
@@ -13217,10 +13217,11 @@
13217
13218 rc = sqlite3_step(pStmt);
13219 if( rc!=SQLITE_ROW ) return;
13220 nColumn = sqlite3_column_count(pStmt);
13221 nAlloc = nColumn*4;
 
13222 azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
13223 if( azData==0 ) shell_out_of_memory();
13224 for(i=0; i<nColumn; i++){
13225 azData[i] = strdup(sqlite3_column_name(pStmt,i));
13226 }
@@ -13256,10 +13257,11 @@
13256 n = strlenChar(z);
13257 j = i%nColumn;
13258 if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
13259 }
13260 if( seenInterrupt ) goto columnar_end;
 
13261 switch( p->cMode ){
13262 case MODE_Column: {
13263 colSep = " ";
13264 rowSep = "\n";
13265 if( p->showHeader ){
13266
--- src/shell.c
+++ src/shell.c
@@ -13217,10 +13217,11 @@
13217
13218 rc = sqlite3_step(pStmt);
13219 if( rc!=SQLITE_ROW ) return;
13220 nColumn = sqlite3_column_count(pStmt);
13221 nAlloc = nColumn*4;
13222 if( nAlloc<=0 ) nAlloc = 1;
13223 azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
13224 if( azData==0 ) shell_out_of_memory();
13225 for(i=0; i<nColumn; i++){
13226 azData[i] = strdup(sqlite3_column_name(pStmt,i));
13227 }
@@ -13256,10 +13257,11 @@
13257 n = strlenChar(z);
13258 j = i%nColumn;
13259 if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
13260 }
13261 if( seenInterrupt ) goto columnar_end;
13262 if( nColumn==0 ) goto columnar_end;
13263 switch( p->cMode ){
13264 case MODE_Column: {
13265 colSep = " ";
13266 rowSep = "\n";
13267 if( p->showHeader ){
13268
+118 -78
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.35.2. By combining all the individual C code files into this
3
+** version 3.35.3. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -1184,13 +1184,13 @@
11841184
**
11851185
** See also: [sqlite3_libversion()],
11861186
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11871187
** [sqlite_version()] and [sqlite_source_id()].
11881188
*/
1189
-#define SQLITE_VERSION "3.35.2"
1190
-#define SQLITE_VERSION_NUMBER 3035002
1191
-#define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827"
1189
+#define SQLITE_VERSION "3.35.3"
1190
+#define SQLITE_VERSION_NUMBER 3035003
1191
+#define SQLITE_SOURCE_ID "2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4f64c"
11921192
11931193
/*
11941194
** CAPI3REF: Run-Time Library Version Numbers
11951195
** KEYWORDS: sqlite3_version sqlite3_sourceid
11961196
**
@@ -21069,10 +21069,11 @@
2106921069
u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
2107021070
#endif
2107121071
Bool isEphemeral:1; /* True for an ephemeral table */
2107221072
Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
2107321073
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
21074
+ Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */
2107421075
u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
2107521076
Btree *pBtx; /* Separate file holding temporary table */
2107621077
i64 seqCount; /* Sequence counter */
2107721078
u32 *aAltMap; /* Mapping from table to index column numbers */
2107821079
@@ -40218,11 +40219,12 @@
4021840219
*/
4021940220
static int unixBackupDir(const char *z, int *pJ){
4022040221
int j = *pJ;
4022140222
int i;
4022240223
if( j<=0 ) return 0;
40223
- for(i=j-1; ALWAYS(i>0) && z[i-1]!='/'; i--){}
40224
+ for(i=j-1; i>0 && z[i-1]!='/'; i--){}
40225
+ if( i==0 ) return 0;
4022440226
if( z[i]=='.' && i==j-2 && z[i+1]=='.' ) return 0;
4022540227
*pJ = i-1;
4022640228
return 1;
4022740229
}
4022840230
@@ -64275,11 +64277,11 @@
6427564277
u8 sharable; /* True if we can share pBt with another db */
6427664278
u8 locked; /* True if db currently has pBt locked */
6427764279
u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */
6427864280
int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
6427964281
int nBackup; /* Number of backup operations reading this btree */
64280
- u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */
64282
+ u32 iBDataVersion; /* Combines with pBt->pPager->iDataVersion */
6428164283
Btree *pNext; /* List of other sharable Btrees from the same db */
6428264284
Btree *pPrev; /* Back pointer of the same list */
6428364285
#ifdef SQLITE_DEBUG
6428464286
u64 nSeek; /* Calls to sqlite3BtreeMovetoUnpacked() */
6428564287
#endif
@@ -67688,23 +67690,27 @@
6768867690
/*
6768967691
** Close an open database and invalidate all cursors.
6769067692
*/
6769167693
SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){
6769267694
BtShared *pBt = p->pBt;
67693
- BtCursor *pCur;
6769467695
6769567696
/* Close all cursors opened via this handle. */
6769667697
assert( sqlite3_mutex_held(p->db->mutex) );
6769767698
sqlite3BtreeEnter(p);
67698
- pCur = pBt->pCursor;
67699
- while( pCur ){
67700
- BtCursor *pTmp = pCur;
67701
- pCur = pCur->pNext;
67702
- if( pTmp->pBtree==p ){
67703
- sqlite3BtreeCloseCursor(pTmp);
67699
+
67700
+ /* Verify that no other cursors have this Btree open */
67701
+#ifdef SQLITE_DEBUG
67702
+ {
67703
+ BtCursor *pCur = pBt->pCursor;
67704
+ while( pCur ){
67705
+ BtCursor *pTmp = pCur;
67706
+ pCur = pCur->pNext;
67707
+ assert( pTmp->pBtree!=p );
67708
+
6770467709
}
6770567710
}
67711
+#endif
6770667712
6770767713
/* Rollback any active transaction and free the handle structure.
6770867714
** The call to sqlite3BtreeRollback() drops any table-locks held by
6770967715
** this handle.
6771067716
*/
@@ -69082,11 +69088,11 @@
6908269088
rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);
6908369089
if( rc!=SQLITE_OK && bCleanup==0 ){
6908469090
sqlite3BtreeLeave(p);
6908569091
return rc;
6908669092
}
69087
- p->iDataVersion--; /* Compensate for pPager->iDataVersion++; */
69093
+ p->iBDataVersion--; /* Compensate for pPager->iDataVersion++; */
6908869094
pBt->inTransaction = TRANS_READ;
6908969095
btreeClearHasContent(pBt);
6909069096
}
6909169097
6909269098
btreeEndTransaction(p);
@@ -69492,11 +69498,18 @@
6949269498
}
6949369499
btreeReleaseAllCursorPages(pCur);
6949469500
unlockBtreeIfUnused(pBt);
6949569501
sqlite3_free(pCur->aOverflow);
6949669502
sqlite3_free(pCur->pKey);
69497
- sqlite3BtreeLeave(pBtree);
69503
+ if( (pBt->openFlags & BTREE_SINGLE) && pBt->pCursor==0 ){
69504
+ /* Since the BtShared is not sharable, there is no need to
69505
+ ** worry about the missing sqlite3BtreeLeave() call here. */
69506
+ assert( pBtree->sharable==0 );
69507
+ sqlite3BtreeClose(pBtree);
69508
+ }else{
69509
+ sqlite3BtreeLeave(pBtree);
69510
+ }
6949869511
pCur->pBtree = 0;
6949969512
}
6950069513
return SQLITE_OK;
6950169514
}
6950269515
@@ -74605,11 +74618,11 @@
7460574618
assert( SQLITE_OK==querySharedCacheTableLock(p, SCHEMA_ROOT, READ_LOCK) );
7460674619
assert( pBt->pPage1 );
7460774620
assert( idx>=0 && idx<=15 );
7460874621
7460974622
if( idx==BTREE_DATA_VERSION ){
74610
- *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;
74623
+ *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iBDataVersion;
7461174624
}else{
7461274625
*pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
7461374626
}
7461474627
7461574628
/* If auto-vacuum is disabled in this build and this is an auto-vacuum
@@ -80833,24 +80846,19 @@
8083380846
SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
8083480847
if( pCx==0 ){
8083580848
return;
8083680849
}
8083780850
assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
80851
+ assert( pCx->pBtx==0 || pCx->isEphemeral );
8083880852
switch( pCx->eCurType ){
8083980853
case CURTYPE_SORTER: {
8084080854
sqlite3VdbeSorterClose(p->db, pCx);
8084180855
break;
8084280856
}
8084380857
case CURTYPE_BTREE: {
80844
- if( pCx->isEphemeral ){
80845
- if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx);
80846
- /* The pCx->pCursor will be close automatically, if it exists, by
80847
- ** the call above. */
80848
- }else{
80849
- assert( pCx->uc.pCursor!=0 );
80850
- sqlite3BtreeCloseCursor(pCx->uc.pCursor);
80851
- }
80858
+ assert( pCx->uc.pCursor!=0 );
80859
+ sqlite3BtreeCloseCursor(pCx->uc.pCursor);
8085280860
break;
8085380861
}
8085480862
#ifndef SQLITE_OMIT_VIRTUALTABLE
8085580863
case CURTYPE_VTAB: {
8085680864
sqlite3_vtab_cursor *pVCur = pCx->uc.pVCur;
@@ -81930,10 +81938,11 @@
8193081938
SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
8193181939
VdbeCursor *p = *pp;
8193281940
assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );
8193381941
if( p->deferredMoveto ){
8193481942
u32 iMap;
81943
+ assert( !p->isEphemeral );
8193581944
if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){
8193681945
*pp = p->pAltCursor;
8193781946
*piCol = iMap - 1;
8193881947
return SQLITE_OK;
8193981948
}
@@ -86138,15 +86147,10 @@
8613886147
ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
8613986148
(eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
8614086149
8614186150
assert( iCur>=0 && iCur<p->nCursor );
8614286151
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
86143
- /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag
86144
- ** is clear. Otherwise, if this is an ephemeral cursor created by
86145
- ** OP_OpenDup, the cursor will not be closed and will still be part
86146
- ** of a BtShared.pCursor list. */
86147
- if( p->apCsr[iCur]->pBtx==0 ) p->apCsr[iCur]->isEphemeral = 0;
8614886152
sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
8614986153
p->apCsr[iCur] = 0;
8615086154
}
8615186155
if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
8615286156
p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
@@ -89828,21 +89832,24 @@
8982889832
VdbeCursor *pOrig; /* The original cursor to be duplicated */
8982989833
VdbeCursor *pCx; /* The new cursor */
8983089834
8983189835
pOrig = p->apCsr[pOp->p2];
8983289836
assert( pOrig );
89833
- assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */
89837
+ assert( pOrig->isEphemeral ); /* Only ephemeral cursors can be duplicated */
8983489838
8983589839
pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
8983689840
if( pCx==0 ) goto no_mem;
8983789841
pCx->nullRow = 1;
8983889842
pCx->isEphemeral = 1;
8983989843
pCx->pKeyInfo = pOrig->pKeyInfo;
8984089844
pCx->isTable = pOrig->isTable;
8984189845
pCx->pgnoRoot = pOrig->pgnoRoot;
8984289846
pCx->isOrdered = pOrig->isOrdered;
89843
- rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
89847
+ pCx->pBtx = pOrig->pBtx;
89848
+ pCx->hasBeenDuped = 1;
89849
+ pOrig->hasBeenDuped = 1;
89850
+ rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
8984489851
pCx->pKeyInfo, pCx->uc.pCursor);
8984589852
/* The sqlite3BtreeCursor() routine can only fail for the first cursor
8984689853
** opened for a database. Since there is already an open cursor when this
8984789854
** opcode is run, the sqlite3BtreeCursor() cannot fail */
8984889855
assert( rc==SQLITE_OK );
@@ -89904,13 +89911,14 @@
8990489911
assert( aMem[pOp->p3].flags & MEM_Null );
8990589912
aMem[pOp->p3].n = 0;
8990689913
aMem[pOp->p3].z = "";
8990789914
}
8990889915
pCx = p->apCsr[pOp->p1];
89909
- if( pCx && ALWAYS(pCx->pBtx) ){
89910
- /* If the ephermeral table is already open, erase all existing content
89911
- ** so that the table is empty again, rather than creating a new table. */
89916
+ if( pCx && !pCx->hasBeenDuped ){
89917
+ /* If the ephermeral table is already open and has no duplicates from
89918
+ ** OP_OpenDup, then erase all existing content so that the table is
89919
+ ** empty again, rather than creating a new table. */
8991289920
assert( pCx->isEphemeral );
8991389921
pCx->seqCount = 0;
8991489922
pCx->cacheStatus = CACHE_STALE;
8991589923
rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
8991689924
}else{
@@ -89920,37 +89928,40 @@
8992089928
rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
8992189929
BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
8992289930
vfsFlags);
8992389931
if( rc==SQLITE_OK ){
8992489932
rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
89925
- }
89926
- if( rc==SQLITE_OK ){
89927
- /* If a transient index is required, create it by calling
89928
- ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
89929
- ** opening it. If a transient table is required, just use the
89930
- ** automatically created table with root-page 1 (an BLOB_INTKEY table).
89931
- */
89932
- if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
89933
- assert( pOp->p4type==P4_KEYINFO );
89934
- rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
89935
- BTREE_BLOBKEY | pOp->p5);
89936
- if( rc==SQLITE_OK ){
89937
- assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
89938
- assert( pKeyInfo->db==db );
89939
- assert( pKeyInfo->enc==ENC(db) );
89940
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
89941
- pKeyInfo, pCx->uc.pCursor);
89942
- }
89943
- pCx->isTable = 0;
89944
- }else{
89945
- pCx->pgnoRoot = SCHEMA_ROOT;
89946
- rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
89947
- 0, pCx->uc.pCursor);
89948
- pCx->isTable = 1;
89949
- }
89950
- }
89951
- pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
89933
+ if( rc==SQLITE_OK ){
89934
+ /* If a transient index is required, create it by calling
89935
+ ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
89936
+ ** opening it. If a transient table is required, just use the
89937
+ ** automatically created table with root-page 1 (an BLOB_INTKEY table).
89938
+ */
89939
+ if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
89940
+ assert( pOp->p4type==P4_KEYINFO );
89941
+ rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
89942
+ BTREE_BLOBKEY | pOp->p5);
89943
+ if( rc==SQLITE_OK ){
89944
+ assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
89945
+ assert( pKeyInfo->db==db );
89946
+ assert( pKeyInfo->enc==ENC(db) );
89947
+ rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
89948
+ pKeyInfo, pCx->uc.pCursor);
89949
+ }
89950
+ pCx->isTable = 0;
89951
+ }else{
89952
+ pCx->pgnoRoot = SCHEMA_ROOT;
89953
+ rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
89954
+ 0, pCx->uc.pCursor);
89955
+ pCx->isTable = 1;
89956
+ }
89957
+ }
89958
+ pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
89959
+ if( rc ){
89960
+ sqlite3BtreeClose(pCx->pBtx);
89961
+ }
89962
+ }
8995289963
}
8995389964
if( rc ) goto abort_due_to_error;
8995489965
pCx->nullRow = 1;
8995589966
break;
8995689967
}
@@ -90380,17 +90391,17 @@
9038090391
** row by, perhaps by invoking sqlite3BtreeStep() on the cursor
9038190392
** between 0 and This.P1 times.
9038290393
**
9038390394
** There are three possible outcomes from this opcode:<ol>
9038490395
**
90385
-** <li> If after This.P1 steps, the cursor is still point to a place that
90386
-** is earlier in the btree than the target row,
90387
-** then fall through into the subsquence OP_SeekGE opcode.
90396
+** <li> If after This.P1 steps, the cursor is still pointing to a place that
90397
+** is earlier in the btree than the target row, then fall through
90398
+** into the subsquence OP_SeekGE opcode.
9038890399
**
9038990400
** <li> If the cursor is successfully moved to the target row by 0 or more
9039090401
** sqlite3BtreeNext() calls, then jump to This.P2, which will land just
90391
-** past the OP_IdxGT opcode that follows the OP_SeekGE.
90402
+** past the OP_IdxGT or OP_IdxGE opcode that follows the OP_SeekGE.
9039290403
**
9039390404
** <li> If the cursor ends up past the target row (indicating the the target
9039490405
** row does not exist in the btree) then jump to SeekOP.P2.
9039590406
** </ol>
9039690407
*/
@@ -90403,11 +90414,12 @@
9040390414
assert( pOp[1].opcode==OP_SeekGE );
9040490415
9040590416
/* pOp->p2 points to the first instruction past the OP_IdxGT that
9040690417
** follows the OP_SeekGE. */
9040790418
assert( pOp->p2>=(int)(pOp-aOp)+2 );
90408
- assert( aOp[pOp->p2-1].opcode==OP_IdxGT );
90419
+ assert( aOp[pOp->p2-1].opcode==OP_IdxGT || aOp[pOp->p2-1].opcode==OP_IdxGE );
90420
+ testcase( aOp[pOp->p2-1].opcode==OP_IdxGE );
9040990421
assert( pOp[1].p1==aOp[pOp->p2-1].p1 );
9041090422
assert( pOp[1].p2==aOp[pOp->p2-1].p2 );
9041190423
assert( pOp[1].p3==aOp[pOp->p2-1].p3 );
9041290424
9041390425
assert( pOp->p1>0 );
@@ -91938,10 +91950,12 @@
9193891950
pTabCur->nullRow = 0;
9193991951
pTabCur->movetoTarget = rowid;
9194091952
pTabCur->deferredMoveto = 1;
9194191953
assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
9194291954
pTabCur->aAltMap = pOp->p4.ai;
91955
+ assert( !pC->isEphemeral );
91956
+ assert( !pTabCur->isEphemeral );
9194391957
pTabCur->pAltCursor = pC;
9194491958
}else{
9194591959
pOut = out2Prerelease(p, pOp);
9194691960
pOut->u.i = rowid;
9194791961
}
@@ -115682,11 +115696,15 @@
115682115696
}
115683115697
115684115698
/* Clean up before exiting */
115685115699
exit_create_index:
115686115700
if( pIndex ) sqlite3FreeIndex(db, pIndex);
115687
- if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */
115701
+ if( pTab ){
115702
+ /* Ensure all REPLACE indexes on pTab are at the end of the pIndex list.
115703
+ ** The list was already ordered when this routine was entered, so at this
115704
+ ** point at most a single index (the newly added index) will be out of
115705
+ ** order. So we have to reorder at most one index. */
115688115706
Index **ppFrom = &pTab->pIndex;
115689115707
Index *pThis;
115690115708
for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){
115691115709
Index *pNext;
115692115710
if( pThis->onError!=OE_Replace ) continue;
@@ -115696,10 +115714,20 @@
115696115714
pNext->pNext = pThis;
115697115715
ppFrom = &pNext->pNext;
115698115716
}
115699115717
break;
115700115718
}
115719
+#ifdef SQLITE_DEBUG
115720
+ /* Verify that all REPLACE indexes really are now at the end
115721
+ ** of the index list. In other words, no other index type ever
115722
+ ** comes after a REPLACE index on the list. */
115723
+ for(pThis = pTab->pIndex; pThis; pThis=pThis->pNext){
115724
+ assert( pThis->onError!=OE_Replace
115725
+ || pThis->pNext==0
115726
+ || pThis->pNext->onError==OE_Replace );
115727
+ }
115728
+#endif
115701115729
}
115702115730
sqlite3ExprDelete(db, pPIWhere);
115703115731
sqlite3ExprListDelete(db, pList);
115704115732
sqlite3SrcListDelete(db, pTblName);
115705115733
sqlite3DbFree(db, zName);
@@ -123112,11 +123140,13 @@
123112123140
pNx->pUpsertSrc = pTabList;
123113123141
pNx->regData = regData;
123114123142
pNx->iDataCur = iDataCur;
123115123143
pNx->iIdxCur = iIdxCur;
123116123144
if( pNx->pUpsertTarget ){
123117
- sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx);
123145
+ if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx) ){
123146
+ goto insert_cleanup;
123147
+ }
123118123148
}
123119123149
pNx = pNx->pNextUpsert;
123120123150
}while( pNx!=0 );
123121123151
}
123122123152
#endif
@@ -124534,11 +124564,11 @@
124534124564
int regData /* Data containing new record */
124535124565
){
124536124566
Vdbe *v = pParse->pVdbe;
124537124567
int r = sqlite3GetTempReg(pParse);
124538124568
assert( !HasRowid(pTab) );
124539
- assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) );
124569
+ assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) || CORRUPT_DB );
124540124570
sqlite3VdbeAddOp2(v, OP_Integer, 0, r);
124541124571
sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE);
124542124572
sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);
124543124573
sqlite3ReleaseTempReg(pParse, r);
124544124574
}
@@ -133082,11 +133112,11 @@
133082133112
sqlite3HashInit(&ht);
133083133113
if( pEList ){
133084133114
nCol = pEList->nExpr;
133085133115
aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
133086133116
testcase( aCol==0 );
133087
- if( nCol>32767 ) nCol = 32767;
133117
+ if( NEVER(nCol>32767) ) nCol = 32767;
133088133118
}else{
133089133119
nCol = 0;
133090133120
aCol = 0;
133091133121
}
133092133122
assert( nCol==(i16)nCol );
@@ -136156,20 +136186,28 @@
136156136186
136157136187
pCte->zCteErr = "circular reference: %s";
136158136188
pSavedWith = pParse->pWith;
136159136189
pParse->pWith = pWith;
136160136190
if( pSel->selFlags & SF_Recursive ){
136191
+ int rc;
136161136192
assert( pRecTerm!=0 );
136162136193
assert( (pRecTerm->selFlags & SF_Recursive)==0 );
136163136194
assert( pRecTerm->pNext!=0 );
136164136195
assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 );
136165136196
assert( pRecTerm->pWith==0 );
136166136197
pRecTerm->pWith = pSel->pWith;
136167
- sqlite3WalkSelect(pWalker, pRecTerm);
136198
+ rc = sqlite3WalkSelect(pWalker, pRecTerm);
136168136199
pRecTerm->pWith = 0;
136200
+ if( rc ){
136201
+ pParse->pWith = pSavedWith;
136202
+ return 2;
136203
+ }
136169136204
}else{
136170
- sqlite3WalkSelect(pWalker, pSel);
136205
+ if( sqlite3WalkSelect(pWalker, pSel) ){
136206
+ pParse->pWith = pSavedWith;
136207
+ return 2;
136208
+ }
136171136209
}
136172136210
pParse->pWith = pWith;
136173136211
136174136212
for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
136175136213
pEList = pLeft->pEList;
@@ -137474,11 +137512,13 @@
137474137512
sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub);
137475137513
}
137476137514
sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
137477137515
pSub->nSelectRow = pPrior->pSelect->nSelectRow;
137478137516
}else{
137479
- /* Generate a subroutine that will materialize the view. */
137517
+ /* Materalize the view. If the view is not correlated, generate a
137518
+ ** subroutine to do the materialization so that subsequent uses of
137519
+ ** the same view can reuse the materialization. */
137480137520
int topAddr;
137481137521
int onceAddr = 0;
137482137522
int retAddr;
137483137523
137484137524
testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
@@ -137501,11 +137541,11 @@
137501137541
if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
137502137542
retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
137503137543
VdbeComment((v, "end %s", pItem->pTab->zName));
137504137544
sqlite3VdbeChangeP1(v, topAddr, retAddr);
137505137545
sqlite3ClearTempRegCache(pParse);
137506
- if( pItem->fg.isCte ){
137546
+ if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){
137507137547
CteUse *pCteUse = pItem->u2.pCteUse;
137508137548
pCteUse->addrM9e = pItem->addrFillSub;
137509137549
pCteUse->regRtn = pItem->regReturn;
137510137550
pCteUse->iCur = pItem->iCursor;
137511137551
pCteUse->nRowEst = pSub->nSelectRow;
@@ -162306,11 +162346,11 @@
162306162346
/* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
162307162347
#endif
162308162348
#ifdef SQLITE_EBCDIC
162309162349
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162310162350
/* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28,
162311
-/* 1x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162351
+/* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162312162352
/* 2x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162313162353
/* 3x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162314162354
/* 4x */ 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 26, 12, 17, 20, 10,
162315162355
/* 5x */ 24, 28, 28, 28, 28, 28, 28, 28, 28, 28, 15, 4, 21, 18, 19, 28,
162316162356
/* 6x */ 11, 16, 28, 28, 28, 28, 28, 28, 28, 28, 28, 23, 22, 2, 13, 6,
@@ -229211,11 +229251,11 @@
229211229251
int nArg, /* Number of args */
229212229252
sqlite3_value **apUnused /* Function arguments */
229213229253
){
229214229254
assert( nArg==0 );
229215229255
UNUSED_PARAM2(nArg, apUnused);
229216
- sqlite3_result_text(pCtx, "fts5: 2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827", -1, SQLITE_TRANSIENT);
229256
+ sqlite3_result_text(pCtx, "fts5: 2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4f64c", -1, SQLITE_TRANSIENT);
229217229257
}
229218229258
229219229259
/*
229220229260
** Return true if zName is the extension on one of the shadow tables used
229221229261
** by this module.
@@ -234137,12 +234177,12 @@
234137234177
}
234138234178
#endif /* SQLITE_CORE */
234139234179
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
234140234180
234141234181
/************** End of stmt.c ************************************************/
234142
-#if __LINE__!=234142
234182
+#if __LINE__!=234182
234143234183
#undef SQLITE_SOURCE_ID
234144
-#define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50calt2"
234184
+#define SQLITE_SOURCE_ID "2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4alt2"
234145234185
#endif
234146234186
/* Return the source-id for this library */
234147234187
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
234148234188
/************************** End of sqlite3.c ******************************/
234149234189
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.35.2. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -1184,13 +1184,13 @@
1184 **
1185 ** See also: [sqlite3_libversion()],
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.35.2"
1190 #define SQLITE_VERSION_NUMBER 3035002
1191 #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -21069,10 +21069,11 @@
21069 u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
21070 #endif
21071 Bool isEphemeral:1; /* True for an ephemeral table */
21072 Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
21073 Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
 
21074 u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
21075 Btree *pBtx; /* Separate file holding temporary table */
21076 i64 seqCount; /* Sequence counter */
21077 u32 *aAltMap; /* Mapping from table to index column numbers */
21078
@@ -40218,11 +40219,12 @@
40218 */
40219 static int unixBackupDir(const char *z, int *pJ){
40220 int j = *pJ;
40221 int i;
40222 if( j<=0 ) return 0;
40223 for(i=j-1; ALWAYS(i>0) && z[i-1]!='/'; i--){}
 
40224 if( z[i]=='.' && i==j-2 && z[i+1]=='.' ) return 0;
40225 *pJ = i-1;
40226 return 1;
40227 }
40228
@@ -64275,11 +64277,11 @@
64275 u8 sharable; /* True if we can share pBt with another db */
64276 u8 locked; /* True if db currently has pBt locked */
64277 u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */
64278 int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
64279 int nBackup; /* Number of backup operations reading this btree */
64280 u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */
64281 Btree *pNext; /* List of other sharable Btrees from the same db */
64282 Btree *pPrev; /* Back pointer of the same list */
64283 #ifdef SQLITE_DEBUG
64284 u64 nSeek; /* Calls to sqlite3BtreeMovetoUnpacked() */
64285 #endif
@@ -67688,23 +67690,27 @@
67688 /*
67689 ** Close an open database and invalidate all cursors.
67690 */
67691 SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){
67692 BtShared *pBt = p->pBt;
67693 BtCursor *pCur;
67694
67695 /* Close all cursors opened via this handle. */
67696 assert( sqlite3_mutex_held(p->db->mutex) );
67697 sqlite3BtreeEnter(p);
67698 pCur = pBt->pCursor;
67699 while( pCur ){
67700 BtCursor *pTmp = pCur;
67701 pCur = pCur->pNext;
67702 if( pTmp->pBtree==p ){
67703 sqlite3BtreeCloseCursor(pTmp);
 
 
 
 
67704 }
67705 }
 
67706
67707 /* Rollback any active transaction and free the handle structure.
67708 ** The call to sqlite3BtreeRollback() drops any table-locks held by
67709 ** this handle.
67710 */
@@ -69082,11 +69088,11 @@
69082 rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);
69083 if( rc!=SQLITE_OK && bCleanup==0 ){
69084 sqlite3BtreeLeave(p);
69085 return rc;
69086 }
69087 p->iDataVersion--; /* Compensate for pPager->iDataVersion++; */
69088 pBt->inTransaction = TRANS_READ;
69089 btreeClearHasContent(pBt);
69090 }
69091
69092 btreeEndTransaction(p);
@@ -69492,11 +69498,18 @@
69492 }
69493 btreeReleaseAllCursorPages(pCur);
69494 unlockBtreeIfUnused(pBt);
69495 sqlite3_free(pCur->aOverflow);
69496 sqlite3_free(pCur->pKey);
69497 sqlite3BtreeLeave(pBtree);
 
 
 
 
 
 
 
69498 pCur->pBtree = 0;
69499 }
69500 return SQLITE_OK;
69501 }
69502
@@ -74605,11 +74618,11 @@
74605 assert( SQLITE_OK==querySharedCacheTableLock(p, SCHEMA_ROOT, READ_LOCK) );
74606 assert( pBt->pPage1 );
74607 assert( idx>=0 && idx<=15 );
74608
74609 if( idx==BTREE_DATA_VERSION ){
74610 *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;
74611 }else{
74612 *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
74613 }
74614
74615 /* If auto-vacuum is disabled in this build and this is an auto-vacuum
@@ -80833,24 +80846,19 @@
80833 SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
80834 if( pCx==0 ){
80835 return;
80836 }
80837 assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
 
80838 switch( pCx->eCurType ){
80839 case CURTYPE_SORTER: {
80840 sqlite3VdbeSorterClose(p->db, pCx);
80841 break;
80842 }
80843 case CURTYPE_BTREE: {
80844 if( pCx->isEphemeral ){
80845 if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx);
80846 /* The pCx->pCursor will be close automatically, if it exists, by
80847 ** the call above. */
80848 }else{
80849 assert( pCx->uc.pCursor!=0 );
80850 sqlite3BtreeCloseCursor(pCx->uc.pCursor);
80851 }
80852 break;
80853 }
80854 #ifndef SQLITE_OMIT_VIRTUALTABLE
80855 case CURTYPE_VTAB: {
80856 sqlite3_vtab_cursor *pVCur = pCx->uc.pVCur;
@@ -81930,10 +81938,11 @@
81930 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
81931 VdbeCursor *p = *pp;
81932 assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );
81933 if( p->deferredMoveto ){
81934 u32 iMap;
 
81935 if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){
81936 *pp = p->pAltCursor;
81937 *piCol = iMap - 1;
81938 return SQLITE_OK;
81939 }
@@ -86138,15 +86147,10 @@
86138 ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
86139 (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
86140
86141 assert( iCur>=0 && iCur<p->nCursor );
86142 if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
86143 /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag
86144 ** is clear. Otherwise, if this is an ephemeral cursor created by
86145 ** OP_OpenDup, the cursor will not be closed and will still be part
86146 ** of a BtShared.pCursor list. */
86147 if( p->apCsr[iCur]->pBtx==0 ) p->apCsr[iCur]->isEphemeral = 0;
86148 sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
86149 p->apCsr[iCur] = 0;
86150 }
86151 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
86152 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
@@ -89828,21 +89832,24 @@
89828 VdbeCursor *pOrig; /* The original cursor to be duplicated */
89829 VdbeCursor *pCx; /* The new cursor */
89830
89831 pOrig = p->apCsr[pOp->p2];
89832 assert( pOrig );
89833 assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */
89834
89835 pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
89836 if( pCx==0 ) goto no_mem;
89837 pCx->nullRow = 1;
89838 pCx->isEphemeral = 1;
89839 pCx->pKeyInfo = pOrig->pKeyInfo;
89840 pCx->isTable = pOrig->isTable;
89841 pCx->pgnoRoot = pOrig->pgnoRoot;
89842 pCx->isOrdered = pOrig->isOrdered;
89843 rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
 
 
 
89844 pCx->pKeyInfo, pCx->uc.pCursor);
89845 /* The sqlite3BtreeCursor() routine can only fail for the first cursor
89846 ** opened for a database. Since there is already an open cursor when this
89847 ** opcode is run, the sqlite3BtreeCursor() cannot fail */
89848 assert( rc==SQLITE_OK );
@@ -89904,13 +89911,14 @@
89904 assert( aMem[pOp->p3].flags & MEM_Null );
89905 aMem[pOp->p3].n = 0;
89906 aMem[pOp->p3].z = "";
89907 }
89908 pCx = p->apCsr[pOp->p1];
89909 if( pCx && ALWAYS(pCx->pBtx) ){
89910 /* If the ephermeral table is already open, erase all existing content
89911 ** so that the table is empty again, rather than creating a new table. */
 
89912 assert( pCx->isEphemeral );
89913 pCx->seqCount = 0;
89914 pCx->cacheStatus = CACHE_STALE;
89915 rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
89916 }else{
@@ -89920,37 +89928,40 @@
89920 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
89921 BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
89922 vfsFlags);
89923 if( rc==SQLITE_OK ){
89924 rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
89925 }
89926 if( rc==SQLITE_OK ){
89927 /* If a transient index is required, create it by calling
89928 ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
89929 ** opening it. If a transient table is required, just use the
89930 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
89931 */
89932 if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
89933 assert( pOp->p4type==P4_KEYINFO );
89934 rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
89935 BTREE_BLOBKEY | pOp->p5);
89936 if( rc==SQLITE_OK ){
89937 assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
89938 assert( pKeyInfo->db==db );
89939 assert( pKeyInfo->enc==ENC(db) );
89940 rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
89941 pKeyInfo, pCx->uc.pCursor);
89942 }
89943 pCx->isTable = 0;
89944 }else{
89945 pCx->pgnoRoot = SCHEMA_ROOT;
89946 rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
89947 0, pCx->uc.pCursor);
89948 pCx->isTable = 1;
89949 }
89950 }
89951 pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
 
 
 
89952 }
89953 if( rc ) goto abort_due_to_error;
89954 pCx->nullRow = 1;
89955 break;
89956 }
@@ -90380,17 +90391,17 @@
90380 ** row by, perhaps by invoking sqlite3BtreeStep() on the cursor
90381 ** between 0 and This.P1 times.
90382 **
90383 ** There are three possible outcomes from this opcode:<ol>
90384 **
90385 ** <li> If after This.P1 steps, the cursor is still point to a place that
90386 ** is earlier in the btree than the target row,
90387 ** then fall through into the subsquence OP_SeekGE opcode.
90388 **
90389 ** <li> If the cursor is successfully moved to the target row by 0 or more
90390 ** sqlite3BtreeNext() calls, then jump to This.P2, which will land just
90391 ** past the OP_IdxGT opcode that follows the OP_SeekGE.
90392 **
90393 ** <li> If the cursor ends up past the target row (indicating the the target
90394 ** row does not exist in the btree) then jump to SeekOP.P2.
90395 ** </ol>
90396 */
@@ -90403,11 +90414,12 @@
90403 assert( pOp[1].opcode==OP_SeekGE );
90404
90405 /* pOp->p2 points to the first instruction past the OP_IdxGT that
90406 ** follows the OP_SeekGE. */
90407 assert( pOp->p2>=(int)(pOp-aOp)+2 );
90408 assert( aOp[pOp->p2-1].opcode==OP_IdxGT );
 
90409 assert( pOp[1].p1==aOp[pOp->p2-1].p1 );
90410 assert( pOp[1].p2==aOp[pOp->p2-1].p2 );
90411 assert( pOp[1].p3==aOp[pOp->p2-1].p3 );
90412
90413 assert( pOp->p1>0 );
@@ -91938,10 +91950,12 @@
91938 pTabCur->nullRow = 0;
91939 pTabCur->movetoTarget = rowid;
91940 pTabCur->deferredMoveto = 1;
91941 assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
91942 pTabCur->aAltMap = pOp->p4.ai;
 
 
91943 pTabCur->pAltCursor = pC;
91944 }else{
91945 pOut = out2Prerelease(p, pOp);
91946 pOut->u.i = rowid;
91947 }
@@ -115682,11 +115696,15 @@
115682 }
115683
115684 /* Clean up before exiting */
115685 exit_create_index:
115686 if( pIndex ) sqlite3FreeIndex(db, pIndex);
115687 if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */
 
 
 
 
115688 Index **ppFrom = &pTab->pIndex;
115689 Index *pThis;
115690 for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){
115691 Index *pNext;
115692 if( pThis->onError!=OE_Replace ) continue;
@@ -115696,10 +115714,20 @@
115696 pNext->pNext = pThis;
115697 ppFrom = &pNext->pNext;
115698 }
115699 break;
115700 }
 
 
 
 
 
 
 
 
 
 
115701 }
115702 sqlite3ExprDelete(db, pPIWhere);
115703 sqlite3ExprListDelete(db, pList);
115704 sqlite3SrcListDelete(db, pTblName);
115705 sqlite3DbFree(db, zName);
@@ -123112,11 +123140,13 @@
123112 pNx->pUpsertSrc = pTabList;
123113 pNx->regData = regData;
123114 pNx->iDataCur = iDataCur;
123115 pNx->iIdxCur = iIdxCur;
123116 if( pNx->pUpsertTarget ){
123117 sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx);
 
 
123118 }
123119 pNx = pNx->pNextUpsert;
123120 }while( pNx!=0 );
123121 }
123122 #endif
@@ -124534,11 +124564,11 @@
124534 int regData /* Data containing new record */
124535 ){
124536 Vdbe *v = pParse->pVdbe;
124537 int r = sqlite3GetTempReg(pParse);
124538 assert( !HasRowid(pTab) );
124539 assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) );
124540 sqlite3VdbeAddOp2(v, OP_Integer, 0, r);
124541 sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE);
124542 sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);
124543 sqlite3ReleaseTempReg(pParse, r);
124544 }
@@ -133082,11 +133112,11 @@
133082 sqlite3HashInit(&ht);
133083 if( pEList ){
133084 nCol = pEList->nExpr;
133085 aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
133086 testcase( aCol==0 );
133087 if( nCol>32767 ) nCol = 32767;
133088 }else{
133089 nCol = 0;
133090 aCol = 0;
133091 }
133092 assert( nCol==(i16)nCol );
@@ -136156,20 +136186,28 @@
136156
136157 pCte->zCteErr = "circular reference: %s";
136158 pSavedWith = pParse->pWith;
136159 pParse->pWith = pWith;
136160 if( pSel->selFlags & SF_Recursive ){
 
136161 assert( pRecTerm!=0 );
136162 assert( (pRecTerm->selFlags & SF_Recursive)==0 );
136163 assert( pRecTerm->pNext!=0 );
136164 assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 );
136165 assert( pRecTerm->pWith==0 );
136166 pRecTerm->pWith = pSel->pWith;
136167 sqlite3WalkSelect(pWalker, pRecTerm);
136168 pRecTerm->pWith = 0;
 
 
 
 
136169 }else{
136170 sqlite3WalkSelect(pWalker, pSel);
 
 
 
136171 }
136172 pParse->pWith = pWith;
136173
136174 for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
136175 pEList = pLeft->pEList;
@@ -137474,11 +137512,13 @@
137474 sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub);
137475 }
137476 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
137477 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
137478 }else{
137479 /* Generate a subroutine that will materialize the view. */
 
 
137480 int topAddr;
137481 int onceAddr = 0;
137482 int retAddr;
137483
137484 testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
@@ -137501,11 +137541,11 @@
137501 if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
137502 retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
137503 VdbeComment((v, "end %s", pItem->pTab->zName));
137504 sqlite3VdbeChangeP1(v, topAddr, retAddr);
137505 sqlite3ClearTempRegCache(pParse);
137506 if( pItem->fg.isCte ){
137507 CteUse *pCteUse = pItem->u2.pCteUse;
137508 pCteUse->addrM9e = pItem->addrFillSub;
137509 pCteUse->regRtn = pItem->regReturn;
137510 pCteUse->iCur = pItem->iCursor;
137511 pCteUse->nRowEst = pSub->nSelectRow;
@@ -162306,11 +162346,11 @@
162306 /* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
162307 #endif
162308 #ifdef SQLITE_EBCDIC
162309 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162310 /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28,
162311 /* 1x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162312 /* 2x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162313 /* 3x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162314 /* 4x */ 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 26, 12, 17, 20, 10,
162315 /* 5x */ 24, 28, 28, 28, 28, 28, 28, 28, 28, 28, 15, 4, 21, 18, 19, 28,
162316 /* 6x */ 11, 16, 28, 28, 28, 28, 28, 28, 28, 28, 28, 23, 22, 2, 13, 6,
@@ -229211,11 +229251,11 @@
229211 int nArg, /* Number of args */
229212 sqlite3_value **apUnused /* Function arguments */
229213 ){
229214 assert( nArg==0 );
229215 UNUSED_PARAM2(nArg, apUnused);
229216 sqlite3_result_text(pCtx, "fts5: 2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827", -1, SQLITE_TRANSIENT);
229217 }
229218
229219 /*
229220 ** Return true if zName is the extension on one of the shadow tables used
229221 ** by this module.
@@ -234137,12 +234177,12 @@
234137 }
234138 #endif /* SQLITE_CORE */
234139 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
234140
234141 /************** End of stmt.c ************************************************/
234142 #if __LINE__!=234142
234143 #undef SQLITE_SOURCE_ID
234144 #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50calt2"
234145 #endif
234146 /* Return the source-id for this library */
234147 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
234148 /************************** End of sqlite3.c ******************************/
234149
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.35.3. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -1184,13 +1184,13 @@
1184 **
1185 ** See also: [sqlite3_libversion()],
1186 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1187 ** [sqlite_version()] and [sqlite_source_id()].
1188 */
1189 #define SQLITE_VERSION "3.35.3"
1190 #define SQLITE_VERSION_NUMBER 3035003
1191 #define SQLITE_SOURCE_ID "2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4f64c"
1192
1193 /*
1194 ** CAPI3REF: Run-Time Library Version Numbers
1195 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1196 **
@@ -21069,10 +21069,11 @@
21069 u8 wrFlag; /* The wrFlag argument to sqlite3BtreeCursor() */
21070 #endif
21071 Bool isEphemeral:1; /* True for an ephemeral table */
21072 Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */
21073 Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
21074 Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */
21075 u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
21076 Btree *pBtx; /* Separate file holding temporary table */
21077 i64 seqCount; /* Sequence counter */
21078 u32 *aAltMap; /* Mapping from table to index column numbers */
21079
@@ -40218,11 +40219,12 @@
40219 */
40220 static int unixBackupDir(const char *z, int *pJ){
40221 int j = *pJ;
40222 int i;
40223 if( j<=0 ) return 0;
40224 for(i=j-1; i>0 && z[i-1]!='/'; i--){}
40225 if( i==0 ) return 0;
40226 if( z[i]=='.' && i==j-2 && z[i+1]=='.' ) return 0;
40227 *pJ = i-1;
40228 return 1;
40229 }
40230
@@ -64275,11 +64277,11 @@
64277 u8 sharable; /* True if we can share pBt with another db */
64278 u8 locked; /* True if db currently has pBt locked */
64279 u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */
64280 int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
64281 int nBackup; /* Number of backup operations reading this btree */
64282 u32 iBDataVersion; /* Combines with pBt->pPager->iDataVersion */
64283 Btree *pNext; /* List of other sharable Btrees from the same db */
64284 Btree *pPrev; /* Back pointer of the same list */
64285 #ifdef SQLITE_DEBUG
64286 u64 nSeek; /* Calls to sqlite3BtreeMovetoUnpacked() */
64287 #endif
@@ -67688,23 +67690,27 @@
67690 /*
67691 ** Close an open database and invalidate all cursors.
67692 */
67693 SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){
67694 BtShared *pBt = p->pBt;
 
67695
67696 /* Close all cursors opened via this handle. */
67697 assert( sqlite3_mutex_held(p->db->mutex) );
67698 sqlite3BtreeEnter(p);
67699
67700 /* Verify that no other cursors have this Btree open */
67701 #ifdef SQLITE_DEBUG
67702 {
67703 BtCursor *pCur = pBt->pCursor;
67704 while( pCur ){
67705 BtCursor *pTmp = pCur;
67706 pCur = pCur->pNext;
67707 assert( pTmp->pBtree!=p );
67708
67709 }
67710 }
67711 #endif
67712
67713 /* Rollback any active transaction and free the handle structure.
67714 ** The call to sqlite3BtreeRollback() drops any table-locks held by
67715 ** this handle.
67716 */
@@ -69082,11 +69088,11 @@
69088 rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);
69089 if( rc!=SQLITE_OK && bCleanup==0 ){
69090 sqlite3BtreeLeave(p);
69091 return rc;
69092 }
69093 p->iBDataVersion--; /* Compensate for pPager->iDataVersion++; */
69094 pBt->inTransaction = TRANS_READ;
69095 btreeClearHasContent(pBt);
69096 }
69097
69098 btreeEndTransaction(p);
@@ -69492,11 +69498,18 @@
69498 }
69499 btreeReleaseAllCursorPages(pCur);
69500 unlockBtreeIfUnused(pBt);
69501 sqlite3_free(pCur->aOverflow);
69502 sqlite3_free(pCur->pKey);
69503 if( (pBt->openFlags & BTREE_SINGLE) && pBt->pCursor==0 ){
69504 /* Since the BtShared is not sharable, there is no need to
69505 ** worry about the missing sqlite3BtreeLeave() call here. */
69506 assert( pBtree->sharable==0 );
69507 sqlite3BtreeClose(pBtree);
69508 }else{
69509 sqlite3BtreeLeave(pBtree);
69510 }
69511 pCur->pBtree = 0;
69512 }
69513 return SQLITE_OK;
69514 }
69515
@@ -74605,11 +74618,11 @@
74618 assert( SQLITE_OK==querySharedCacheTableLock(p, SCHEMA_ROOT, READ_LOCK) );
74619 assert( pBt->pPage1 );
74620 assert( idx>=0 && idx<=15 );
74621
74622 if( idx==BTREE_DATA_VERSION ){
74623 *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iBDataVersion;
74624 }else{
74625 *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
74626 }
74627
74628 /* If auto-vacuum is disabled in this build and this is an auto-vacuum
@@ -80833,24 +80846,19 @@
80846 SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
80847 if( pCx==0 ){
80848 return;
80849 }
80850 assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
80851 assert( pCx->pBtx==0 || pCx->isEphemeral );
80852 switch( pCx->eCurType ){
80853 case CURTYPE_SORTER: {
80854 sqlite3VdbeSorterClose(p->db, pCx);
80855 break;
80856 }
80857 case CURTYPE_BTREE: {
80858 assert( pCx->uc.pCursor!=0 );
80859 sqlite3BtreeCloseCursor(pCx->uc.pCursor);
 
 
 
 
 
 
80860 break;
80861 }
80862 #ifndef SQLITE_OMIT_VIRTUALTABLE
80863 case CURTYPE_VTAB: {
80864 sqlite3_vtab_cursor *pVCur = pCx->uc.pVCur;
@@ -81930,10 +81938,11 @@
81938 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
81939 VdbeCursor *p = *pp;
81940 assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );
81941 if( p->deferredMoveto ){
81942 u32 iMap;
81943 assert( !p->isEphemeral );
81944 if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){
81945 *pp = p->pAltCursor;
81946 *piCol = iMap - 1;
81947 return SQLITE_OK;
81948 }
@@ -86138,15 +86147,10 @@
86147 ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
86148 (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
86149
86150 assert( iCur>=0 && iCur<p->nCursor );
86151 if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
 
 
 
 
 
86152 sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
86153 p->apCsr[iCur] = 0;
86154 }
86155 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
86156 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
@@ -89828,21 +89832,24 @@
89832 VdbeCursor *pOrig; /* The original cursor to be duplicated */
89833 VdbeCursor *pCx; /* The new cursor */
89834
89835 pOrig = p->apCsr[pOp->p2];
89836 assert( pOrig );
89837 assert( pOrig->isEphemeral ); /* Only ephemeral cursors can be duplicated */
89838
89839 pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
89840 if( pCx==0 ) goto no_mem;
89841 pCx->nullRow = 1;
89842 pCx->isEphemeral = 1;
89843 pCx->pKeyInfo = pOrig->pKeyInfo;
89844 pCx->isTable = pOrig->isTable;
89845 pCx->pgnoRoot = pOrig->pgnoRoot;
89846 pCx->isOrdered = pOrig->isOrdered;
89847 pCx->pBtx = pOrig->pBtx;
89848 pCx->hasBeenDuped = 1;
89849 pOrig->hasBeenDuped = 1;
89850 rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
89851 pCx->pKeyInfo, pCx->uc.pCursor);
89852 /* The sqlite3BtreeCursor() routine can only fail for the first cursor
89853 ** opened for a database. Since there is already an open cursor when this
89854 ** opcode is run, the sqlite3BtreeCursor() cannot fail */
89855 assert( rc==SQLITE_OK );
@@ -89904,13 +89911,14 @@
89911 assert( aMem[pOp->p3].flags & MEM_Null );
89912 aMem[pOp->p3].n = 0;
89913 aMem[pOp->p3].z = "";
89914 }
89915 pCx = p->apCsr[pOp->p1];
89916 if( pCx && !pCx->hasBeenDuped ){
89917 /* If the ephermeral table is already open and has no duplicates from
89918 ** OP_OpenDup, then erase all existing content so that the table is
89919 ** empty again, rather than creating a new table. */
89920 assert( pCx->isEphemeral );
89921 pCx->seqCount = 0;
89922 pCx->cacheStatus = CACHE_STALE;
89923 rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
89924 }else{
@@ -89920,37 +89928,40 @@
89928 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
89929 BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
89930 vfsFlags);
89931 if( rc==SQLITE_OK ){
89932 rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
89933 if( rc==SQLITE_OK ){
89934 /* If a transient index is required, create it by calling
89935 ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
89936 ** opening it. If a transient table is required, just use the
89937 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
89938 */
89939 if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
89940 assert( pOp->p4type==P4_KEYINFO );
89941 rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
89942 BTREE_BLOBKEY | pOp->p5);
89943 if( rc==SQLITE_OK ){
89944 assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
89945 assert( pKeyInfo->db==db );
89946 assert( pKeyInfo->enc==ENC(db) );
89947 rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
89948 pKeyInfo, pCx->uc.pCursor);
89949 }
89950 pCx->isTable = 0;
89951 }else{
89952 pCx->pgnoRoot = SCHEMA_ROOT;
89953 rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
89954 0, pCx->uc.pCursor);
89955 pCx->isTable = 1;
89956 }
89957 }
89958 pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
89959 if( rc ){
89960 sqlite3BtreeClose(pCx->pBtx);
89961 }
89962 }
89963 }
89964 if( rc ) goto abort_due_to_error;
89965 pCx->nullRow = 1;
89966 break;
89967 }
@@ -90380,17 +90391,17 @@
90391 ** row by, perhaps by invoking sqlite3BtreeStep() on the cursor
90392 ** between 0 and This.P1 times.
90393 **
90394 ** There are three possible outcomes from this opcode:<ol>
90395 **
90396 ** <li> If after This.P1 steps, the cursor is still pointing to a place that
90397 ** is earlier in the btree than the target row, then fall through
90398 ** into the subsquence OP_SeekGE opcode.
90399 **
90400 ** <li> If the cursor is successfully moved to the target row by 0 or more
90401 ** sqlite3BtreeNext() calls, then jump to This.P2, which will land just
90402 ** past the OP_IdxGT or OP_IdxGE opcode that follows the OP_SeekGE.
90403 **
90404 ** <li> If the cursor ends up past the target row (indicating the the target
90405 ** row does not exist in the btree) then jump to SeekOP.P2.
90406 ** </ol>
90407 */
@@ -90403,11 +90414,12 @@
90414 assert( pOp[1].opcode==OP_SeekGE );
90415
90416 /* pOp->p2 points to the first instruction past the OP_IdxGT that
90417 ** follows the OP_SeekGE. */
90418 assert( pOp->p2>=(int)(pOp-aOp)+2 );
90419 assert( aOp[pOp->p2-1].opcode==OP_IdxGT || aOp[pOp->p2-1].opcode==OP_IdxGE );
90420 testcase( aOp[pOp->p2-1].opcode==OP_IdxGE );
90421 assert( pOp[1].p1==aOp[pOp->p2-1].p1 );
90422 assert( pOp[1].p2==aOp[pOp->p2-1].p2 );
90423 assert( pOp[1].p3==aOp[pOp->p2-1].p3 );
90424
90425 assert( pOp->p1>0 );
@@ -91938,10 +91950,12 @@
91950 pTabCur->nullRow = 0;
91951 pTabCur->movetoTarget = rowid;
91952 pTabCur->deferredMoveto = 1;
91953 assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
91954 pTabCur->aAltMap = pOp->p4.ai;
91955 assert( !pC->isEphemeral );
91956 assert( !pTabCur->isEphemeral );
91957 pTabCur->pAltCursor = pC;
91958 }else{
91959 pOut = out2Prerelease(p, pOp);
91960 pOut->u.i = rowid;
91961 }
@@ -115682,11 +115696,15 @@
115696 }
115697
115698 /* Clean up before exiting */
115699 exit_create_index:
115700 if( pIndex ) sqlite3FreeIndex(db, pIndex);
115701 if( pTab ){
115702 /* Ensure all REPLACE indexes on pTab are at the end of the pIndex list.
115703 ** The list was already ordered when this routine was entered, so at this
115704 ** point at most a single index (the newly added index) will be out of
115705 ** order. So we have to reorder at most one index. */
115706 Index **ppFrom = &pTab->pIndex;
115707 Index *pThis;
115708 for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){
115709 Index *pNext;
115710 if( pThis->onError!=OE_Replace ) continue;
@@ -115696,10 +115714,20 @@
115714 pNext->pNext = pThis;
115715 ppFrom = &pNext->pNext;
115716 }
115717 break;
115718 }
115719 #ifdef SQLITE_DEBUG
115720 /* Verify that all REPLACE indexes really are now at the end
115721 ** of the index list. In other words, no other index type ever
115722 ** comes after a REPLACE index on the list. */
115723 for(pThis = pTab->pIndex; pThis; pThis=pThis->pNext){
115724 assert( pThis->onError!=OE_Replace
115725 || pThis->pNext==0
115726 || pThis->pNext->onError==OE_Replace );
115727 }
115728 #endif
115729 }
115730 sqlite3ExprDelete(db, pPIWhere);
115731 sqlite3ExprListDelete(db, pList);
115732 sqlite3SrcListDelete(db, pTblName);
115733 sqlite3DbFree(db, zName);
@@ -123112,11 +123140,13 @@
123140 pNx->pUpsertSrc = pTabList;
123141 pNx->regData = regData;
123142 pNx->iDataCur = iDataCur;
123143 pNx->iIdxCur = iIdxCur;
123144 if( pNx->pUpsertTarget ){
123145 if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx) ){
123146 goto insert_cleanup;
123147 }
123148 }
123149 pNx = pNx->pNextUpsert;
123150 }while( pNx!=0 );
123151 }
123152 #endif
@@ -124534,11 +124564,11 @@
124564 int regData /* Data containing new record */
124565 ){
124566 Vdbe *v = pParse->pVdbe;
124567 int r = sqlite3GetTempReg(pParse);
124568 assert( !HasRowid(pTab) );
124569 assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) || CORRUPT_DB );
124570 sqlite3VdbeAddOp2(v, OP_Integer, 0, r);
124571 sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE);
124572 sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);
124573 sqlite3ReleaseTempReg(pParse, r);
124574 }
@@ -133082,11 +133112,11 @@
133112 sqlite3HashInit(&ht);
133113 if( pEList ){
133114 nCol = pEList->nExpr;
133115 aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
133116 testcase( aCol==0 );
133117 if( NEVER(nCol>32767) ) nCol = 32767;
133118 }else{
133119 nCol = 0;
133120 aCol = 0;
133121 }
133122 assert( nCol==(i16)nCol );
@@ -136156,20 +136186,28 @@
136186
136187 pCte->zCteErr = "circular reference: %s";
136188 pSavedWith = pParse->pWith;
136189 pParse->pWith = pWith;
136190 if( pSel->selFlags & SF_Recursive ){
136191 int rc;
136192 assert( pRecTerm!=0 );
136193 assert( (pRecTerm->selFlags & SF_Recursive)==0 );
136194 assert( pRecTerm->pNext!=0 );
136195 assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 );
136196 assert( pRecTerm->pWith==0 );
136197 pRecTerm->pWith = pSel->pWith;
136198 rc = sqlite3WalkSelect(pWalker, pRecTerm);
136199 pRecTerm->pWith = 0;
136200 if( rc ){
136201 pParse->pWith = pSavedWith;
136202 return 2;
136203 }
136204 }else{
136205 if( sqlite3WalkSelect(pWalker, pSel) ){
136206 pParse->pWith = pSavedWith;
136207 return 2;
136208 }
136209 }
136210 pParse->pWith = pWith;
136211
136212 for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
136213 pEList = pLeft->pEList;
@@ -137474,11 +137512,13 @@
137512 sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub);
137513 }
137514 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
137515 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
137516 }else{
137517 /* Materalize the view. If the view is not correlated, generate a
137518 ** subroutine to do the materialization so that subsequent uses of
137519 ** the same view can reuse the materialization. */
137520 int topAddr;
137521 int onceAddr = 0;
137522 int retAddr;
137523
137524 testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */
@@ -137501,11 +137541,11 @@
137541 if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
137542 retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);
137543 VdbeComment((v, "end %s", pItem->pTab->zName));
137544 sqlite3VdbeChangeP1(v, topAddr, retAddr);
137545 sqlite3ClearTempRegCache(pParse);
137546 if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){
137547 CteUse *pCteUse = pItem->u2.pCteUse;
137548 pCteUse->addrM9e = pItem->addrFillSub;
137549 pCteUse->regRtn = pItem->regReturn;
137550 pCteUse->iCur = pItem->iCursor;
137551 pCteUse->nRowEst = pSub->nSelectRow;
@@ -162306,11 +162346,11 @@
162346 /* Fx */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
162347 #endif
162348 #ifdef SQLITE_EBCDIC
162349 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
162350 /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28,
162351 /* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162352 /* 2x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162353 /* 3x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
162354 /* 4x */ 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 26, 12, 17, 20, 10,
162355 /* 5x */ 24, 28, 28, 28, 28, 28, 28, 28, 28, 28, 15, 4, 21, 18, 19, 28,
162356 /* 6x */ 11, 16, 28, 28, 28, 28, 28, 28, 28, 28, 28, 23, 22, 2, 13, 6,
@@ -229211,11 +229251,11 @@
229251 int nArg, /* Number of args */
229252 sqlite3_value **apUnused /* Function arguments */
229253 ){
229254 assert( nArg==0 );
229255 UNUSED_PARAM2(nArg, apUnused);
229256 sqlite3_result_text(pCtx, "fts5: 2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4f64c", -1, SQLITE_TRANSIENT);
229257 }
229258
229259 /*
229260 ** Return true if zName is the extension on one of the shadow tables used
229261 ** by this module.
@@ -234137,12 +234177,12 @@
234177 }
234178 #endif /* SQLITE_CORE */
234179 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
234180
234181 /************** End of stmt.c ************************************************/
234182 #if __LINE__!=234182
234183 #undef SQLITE_SOURCE_ID
234184 #define SQLITE_SOURCE_ID "2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4alt2"
234185 #endif
234186 /* Return the source-id for this library */
234187 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
234188 /************************** End of sqlite3.c ******************************/
234189
+3 -3
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121121
**
122122
** See also: [sqlite3_libversion()],
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126
-#define SQLITE_VERSION "3.35.2"
127
-#define SQLITE_VERSION_NUMBER 3035002
128
-#define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827"
126
+#define SQLITE_VERSION "3.35.3"
127
+#define SQLITE_VERSION_NUMBER 3035003
128
+#define SQLITE_SOURCE_ID "2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4f64c"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.35.2"
127 #define SQLITE_VERSION_NUMBER 3035002
128 #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.35.3"
127 #define SQLITE_VERSION_NUMBER 3035003
128 #define SQLITE_SOURCE_ID "2021-03-21 18:23:48 6bb2134027a12801de8e0c73482d94682f902024800a7e426614f65a2fe4f64c"
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