Fossil SCM

Update the built-in SQLite to the latest 3.34.0 alpha that includes the ability to have multiple recursive terms in a recursive CTE. That new capability is expected to be helpful in improving the /finfo page.

drh 2020-10-19 13:25 trunk
Commit 5328f8216004895097bb94f0301b4f6538914da1a86bbb85302987f7f33a0835
3 files changed +4 -2 +93 -43 +11 -4
+4 -2
--- src/shell.c
+++ src/shell.c
@@ -13720,18 +13720,20 @@
1372013720
int rc;
1372113721
const char *zTable;
1372213722
const char *zType;
1372313723
const char *zSql;
1372413724
ShellState *p = (ShellState *)pArg;
13725
+ int dataOnly;
13726
+ int noSys;
1372513727
1372613728
UNUSED_PARAMETER(azNotUsed);
1372713729
if( nArg!=3 || azArg==0 ) return 0;
1372813730
zTable = azArg[0];
1372913731
zType = azArg[1];
1373013732
zSql = azArg[2];
13731
- int dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
13732
- int noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
13733
+ dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
13734
+ noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
1373313735
1373413736
if( strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
1373513737
if( !dataOnly ) raw_printf(p->out, "DELETE FROM sqlite_sequence;\n");
1373613738
}else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
1373713739
if( !dataOnly ) raw_printf(p->out, "ANALYZE sqlite_schema;\n");
1373813740
--- src/shell.c
+++ src/shell.c
@@ -13720,18 +13720,20 @@
13720 int rc;
13721 const char *zTable;
13722 const char *zType;
13723 const char *zSql;
13724 ShellState *p = (ShellState *)pArg;
 
 
13725
13726 UNUSED_PARAMETER(azNotUsed);
13727 if( nArg!=3 || azArg==0 ) return 0;
13728 zTable = azArg[0];
13729 zType = azArg[1];
13730 zSql = azArg[2];
13731 int dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
13732 int noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
13733
13734 if( strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
13735 if( !dataOnly ) raw_printf(p->out, "DELETE FROM sqlite_sequence;\n");
13736 }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
13737 if( !dataOnly ) raw_printf(p->out, "ANALYZE sqlite_schema;\n");
13738
--- src/shell.c
+++ src/shell.c
@@ -13720,18 +13720,20 @@
13720 int rc;
13721 const char *zTable;
13722 const char *zType;
13723 const char *zSql;
13724 ShellState *p = (ShellState *)pArg;
13725 int dataOnly;
13726 int noSys;
13727
13728 UNUSED_PARAMETER(azNotUsed);
13729 if( nArg!=3 || azArg==0 ) return 0;
13730 zTable = azArg[0];
13731 zType = azArg[1];
13732 zSql = azArg[2];
13733 dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
13734 noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
13735
13736 if( strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
13737 if( !dataOnly ) raw_printf(p->out, "DELETE FROM sqlite_sequence;\n");
13738 }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
13739 if( !dataOnly ) raw_printf(p->out, "ANALYZE sqlite_schema;\n");
13740
+93 -43
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1171,11 +1171,11 @@
11711171
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11721172
** [sqlite_version()] and [sqlite_source_id()].
11731173
*/
11741174
#define SQLITE_VERSION "3.34.0"
11751175
#define SQLITE_VERSION_NUMBER 3034000
1176
-#define SQLITE_SOURCE_ID "2020-10-12 18:09:16 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca6409d5"
1176
+#define SQLITE_SOURCE_ID "2020-10-19 12:35:08 77e64647ec429c6e0d884abbd00dabebe738f89544a4984d6fd7a702b928ccfd"
11771177
11781178
/*
11791179
** CAPI3REF: Run-Time Library Version Numbers
11801180
** KEYWORDS: sqlite3_version sqlite3_sourceid
11811181
**
@@ -10290,22 +10290,29 @@
1029010290
1029110291
/*
1029210292
** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
1029310293
**
1029410294
** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
10295
-** method of a [virtual table], then it returns true if and only if the
10295
+** method of a [virtual table], then it might return true if the
1029610296
** column is being fetched as part of an UPDATE operation during which the
10297
-** column value will not change. Applications might use this to substitute
10298
-** a return value that is less expensive to compute and that the corresponding
10297
+** column value will not change. The virtual table implementation can use
10298
+** this hint as permission to substitute a return value that is less
10299
+** expensive to compute and that the corresponding
1029910300
** [xUpdate] method understands as a "no-change" value.
1030010301
**
1030110302
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
1030210303
** the column is not changed by the UPDATE statement, then the xColumn
1030310304
** method can optionally return without setting a result, without calling
1030410305
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
1030510306
** In that case, [sqlite3_value_nochange(X)] will return true for the
1030610307
** same column in the [xUpdate] method.
10308
+**
10309
+** The sqlite3_vtab_nochange() routine is an optimization. Virtual table
10310
+** implementations should continue to give a correct answer even if the
10311
+** sqlite3_vtab_nochange() interface were to always return false. In the
10312
+** current implementation, the sqlite3_vtab_nochange() interface does always
10313
+** returns false for the enhanced [UPDATE FROM] statement.
1030710314
*/
1030810315
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
1030910316
1031010317
/*
1031110318
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
@@ -46915,11 +46922,15 @@
4691546922
}else{
4691646923
/* Opens a file, only if it exists. */
4691746924
dwCreationDisposition = OPEN_EXISTING;
4691846925
}
4691946926
46920
- dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
46927
+ if( 0==sqlite3_uri_boolean(zName, "exclusive", 0) ){
46928
+ dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
46929
+ }else{
46930
+ dwShareMode = 0;
46931
+ }
4692146932
4692246933
if( isDelete ){
4692346934
#if SQLITE_OS_WINCE
4692446935
dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;
4692546936
isTemp = 1;
@@ -48068,15 +48079,18 @@
4806848079
4806948080
/*
4807048081
** Close an memdb-file.
4807148082
**
4807248083
** The pData pointer is owned by the application, so there is nothing
48073
-** to free.
48084
+** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set,
48085
+** in which case we own the pData pointer and need to free it.
4807448086
*/
4807548087
static int memdbClose(sqlite3_file *pFile){
4807648088
MemFile *p = (MemFile *)pFile;
48077
- if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ) sqlite3_free(p->aData);
48089
+ if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){
48090
+ sqlite3_free(p->aData);
48091
+ }
4807848092
return SQLITE_OK;
4807948093
}
4808048094
4808148095
/*
4808248096
** Read data from an memdb-file.
@@ -48531,10 +48545,11 @@
4853148545
p = memdbFromDbSchema(db, zSchema);
4853248546
if( p==0 ){
4853348547
rc = SQLITE_ERROR;
4853448548
}else{
4853548549
p->aData = pData;
48550
+ pData = 0;
4853648551
p->sz = szDb;
4853748552
p->szAlloc = szBuf;
4853848553
p->szMax = szBuf;
4853948554
if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
4854048555
p->szMax = sqlite3GlobalConfig.mxMemdbSize;
@@ -48543,10 +48558,13 @@
4854348558
rc = SQLITE_OK;
4854448559
}
4854548560
4854648561
end_deserialize:
4854748562
sqlite3_finalize(pStmt);
48563
+ if( pData && (mFlags & SQLITE_DESERIALIZE_FREEONCLOSE)!=0 ){
48564
+ sqlite3_free(pData);
48565
+ }
4854848566
sqlite3_mutex_leave(db->mutex);
4854948567
return rc;
4855048568
}
4855148569
4855248570
/*
@@ -115172,11 +115190,11 @@
115172115190
int i;
115173115191
struct SrcList_item *pItem;
115174115192
assert(pList || pParse->db->mallocFailed );
115175115193
if( pList ){
115176115194
for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
115177
- if( pItem->iCursor>=0 ) break;
115195
+ if( pItem->iCursor>=0 ) continue;
115178115196
pItem->iCursor = pParse->nTab++;
115179115197
if( pItem->pSelect ){
115180115198
sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);
115181115199
}
115182115200
}
@@ -131978,10 +131996,11 @@
131978131996
){
131979131997
SrcList *pSrc = p->pSrc; /* The FROM clause of the recursive query */
131980131998
int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
131981131999
Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
131982132000
Select *pSetup = p->pPrior; /* The setup query */
132001
+ Select *pFirstRec; /* Left-most recursive term */
131983132002
int addrTop; /* Top of the loop */
131984132003
int addrCont, addrBreak; /* CONTINUE and BREAK addresses */
131985132004
int iCurrent = 0; /* The Current table */
131986132005
int regCurrent; /* Register holding Current table */
131987132006
int iQueue; /* The Queue table */
@@ -132052,12 +132071,30 @@
132052132071
p->selFlags |= SF_UsesEphemeral;
132053132072
}
132054132073
132055132074
/* Detach the ORDER BY clause from the compound SELECT */
132056132075
p->pOrderBy = 0;
132076
+
132077
+ /* Figure out how many elements of the compound SELECT are part of the
132078
+ ** recursive query. Make sure no recursive elements use aggregate
132079
+ ** functions. Mark the recursive elements as UNION ALL even if they
132080
+ ** are really UNION because the distinctness will be enforced by the
132081
+ ** iDistinct table. pFirstRec is left pointing to the left-most
132082
+ ** recursive term of the CTE.
132083
+ */
132084
+ pFirstRec = p;
132085
+ for(pFirstRec=p; ALWAYS(pFirstRec!=0); pFirstRec=pFirstRec->pPrior){
132086
+ if( pFirstRec->selFlags & SF_Aggregate ){
132087
+ sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
132088
+ goto end_of_recursive_query;
132089
+ }
132090
+ pFirstRec->op = TK_ALL;
132091
+ if( (pFirstRec->pPrior->selFlags & SF_Recursive)==0 ) break;
132092
+ }
132057132093
132058132094
/* Store the results of the setup-query in Queue. */
132095
+ pSetup = pFirstRec->pPrior;
132059132096
pSetup->pNext = 0;
132060132097
ExplainQueryPlan((pParse, 1, "SETUP"));
132061132098
rc = sqlite3Select(pParse, pSetup, &destQueue);
132062132099
pSetup->pNext = p;
132063132100
if( rc ) goto end_of_recursive_query;
@@ -132086,19 +132123,15 @@
132086132123
sqlite3VdbeResolveLabel(v, addrCont);
132087132124
132088132125
/* Execute the recursive SELECT taking the single row in Current as
132089132126
** the value for the recursive-table. Store the results in the Queue.
132090132127
*/
132091
- if( p->selFlags & SF_Aggregate ){
132092
- sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
132093
- }else{
132094
- p->pPrior = 0;
132095
- ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
132096
- sqlite3Select(pParse, p, &destQueue);
132097
- assert( p->pPrior==0 );
132098
- p->pPrior = pSetup;
132099
- }
132128
+ pFirstRec->pPrior = 0;
132129
+ ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
132130
+ sqlite3Select(pParse, p, &destQueue);
132131
+ assert( pFirstRec->pPrior==0 );
132132
+ pFirstRec->pPrior = pSetup;
132100132133
132101132134
/* Keep running the loop until the Queue is empty */
132102132135
sqlite3VdbeGoto(v, addrTop);
132103132136
sqlite3VdbeResolveLabel(v, addrBreak);
132104132137
@@ -132162,10 +132195,20 @@
132162132195
p->nSelectRow = nRow;
132163132196
p = p->pNext;
132164132197
}
132165132198
return rc;
132166132199
}
132200
+
132201
+/*
132202
+** Return true if the SELECT statement which is known to be the recursive
132203
+** part of a recursive CTE still has its anchor terms attached. If the
132204
+** anchor terms have already been removed, then return false.
132205
+*/
132206
+static int hasAnchor(Select *p){
132207
+ while( p && (p->selFlags & SF_Recursive)!=0 ){ p = p->pPrior; }
132208
+ return p!=0;
132209
+}
132167132210
132168132211
/*
132169132212
** This routine is called to process a compound query form from
132170132213
** two or more separate queries using UNION, UNION ALL, EXCEPT, or
132171132214
** INTERSECT
@@ -132248,11 +132291,11 @@
132248132291
*/
132249132292
assert( p->pEList && pPrior->pEList );
132250132293
assert( p->pEList->nExpr==pPrior->pEList->nExpr );
132251132294
132252132295
#ifndef SQLITE_OMIT_CTE
132253
- if( p->selFlags & SF_Recursive ){
132296
+ if( (p->selFlags & SF_Recursive)!=0 && hasAnchor(p) ){
132254132297
generateWithRecursiveQuery(pParse, p, &dest);
132255132298
}else
132256132299
#endif
132257132300
132258132301
/* Compound SELECTs that have an ORDER BY clause are handled separately.
@@ -132339,10 +132382,11 @@
132339132382
assert( p->addrOpenEphm[0] == -1 );
132340132383
p->addrOpenEphm[0] = addr;
132341132384
findRightmost(p)->selFlags |= SF_UsesEphemeral;
132342132385
assert( p->pEList );
132343132386
}
132387
+
132344132388
132345132389
/* Code the SELECT statements to our left
132346132390
*/
132347132391
assert( !pPrior->pOrderBy );
132348132392
sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
@@ -134432,12 +134476,14 @@
134432134476
if( pCte ){
134433134477
Table *pTab;
134434134478
ExprList *pEList;
134435134479
Select *pSel;
134436134480
Select *pLeft; /* Left-most SELECT statement */
134481
+ Select *pRecTerm; /* Left-most recursive term */
134437134482
int bMayRecursive; /* True if compound joined by UNION [ALL] */
134438134483
With *pSavedWith; /* Initial value of pParse->pWith */
134484
+ int iRecTab = -1; /* Cursor for recursive table */
134439134485
134440134486
/* If pCte->zCteErr is non-NULL at this point, then this is an illegal
134441134487
** recursive reference to CTE pCte. Leave an error in pParse and return
134442134488
** early. If pCte->zCteErr is NULL, then this is not a recursive reference.
134443134489
** In this case, proceed. */
@@ -134458,48 +134504,52 @@
134458134504
pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
134459134505
if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;
134460134506
assert( pFrom->pSelect );
134461134507
134462134508
/* Check if this is a recursive CTE. */
134463
- pSel = pFrom->pSelect;
134509
+ pRecTerm = pSel = pFrom->pSelect;
134464134510
bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
134465
- if( bMayRecursive ){
134511
+ while( bMayRecursive && pRecTerm->op==pSel->op ){
134466134512
int i;
134467
- SrcList *pSrc = pFrom->pSelect->pSrc;
134513
+ SrcList *pSrc = pRecTerm->pSrc;
134514
+ assert( pRecTerm->pPrior!=0 );
134468134515
for(i=0; i<pSrc->nSrc; i++){
134469134516
struct SrcList_item *pItem = &pSrc->a[i];
134470134517
if( pItem->zDatabase==0
134471134518
&& pItem->zName!=0
134472134519
&& 0==sqlite3StrICmp(pItem->zName, pCte->zName)
134473
- ){
134520
+ ){
134474134521
pItem->pTab = pTab;
134475134522
pItem->fg.isRecursive = 1;
134523
+ if( pRecTerm->selFlags & SF_Recursive ){
134524
+ sqlite3ErrorMsg(pParse,
134525
+ "multiple references to recursive table: %s", pCte->zName
134526
+ );
134527
+ return SQLITE_ERROR;
134528
+ }
134476134529
pTab->nTabRef++;
134477
- pSel->selFlags |= SF_Recursive;
134530
+ pRecTerm->selFlags |= SF_Recursive;
134531
+ if( iRecTab<0 ) iRecTab = pParse->nTab++;
134532
+ pItem->iCursor = iRecTab;
134478134533
}
134479134534
}
134480
- }
134481
-
134482
- /* Only one recursive reference is permitted. */
134483
- if( pTab->nTabRef>2 ){
134484
- sqlite3ErrorMsg(
134485
- pParse, "multiple references to recursive table: %s", pCte->zName
134486
- );
134487
- return SQLITE_ERROR;
134488
- }
134489
- assert( pTab->nTabRef==1 ||
134490
- ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 ));
134535
+ if( (pRecTerm->selFlags & SF_Recursive)==0 ) break;
134536
+ pRecTerm = pRecTerm->pPrior;
134537
+ }
134491134538
134492134539
pCte->zCteErr = "circular reference: %s";
134493134540
pSavedWith = pParse->pWith;
134494134541
pParse->pWith = pWith;
134495
- if( bMayRecursive ){
134496
- Select *pPrior = pSel->pPrior;
134497
- assert( pPrior->pWith==0 );
134498
- pPrior->pWith = pSel->pWith;
134499
- sqlite3WalkSelect(pWalker, pPrior);
134500
- pPrior->pWith = 0;
134542
+ if( pSel->selFlags & SF_Recursive ){
134543
+ assert( pRecTerm!=0 );
134544
+ assert( (pRecTerm->selFlags & SF_Recursive)==0 );
134545
+ assert( pRecTerm->pNext!=0 );
134546
+ assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 );
134547
+ assert( pRecTerm->pWith==0 );
134548
+ pRecTerm->pWith = pSel->pWith;
134549
+ sqlite3WalkSelect(pWalker, pRecTerm);
134550
+ pRecTerm->pWith = 0;
134501134551
}else{
134502134552
sqlite3WalkSelect(pWalker, pSel);
134503134553
}
134504134554
pParse->pWith = pWith;
134505134555
@@ -147740,11 +147790,11 @@
147740147790
if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
147741147791
if( pTerm->eOperator & WO_SINGLE ){
147742147792
sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
147743147793
pTerm->leftCursor, pTerm->u.x.leftColumn);
147744147794
}else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
147745
- sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
147795
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%llx",
147746147796
pTerm->u.pOrInfo->indexable);
147747147797
}else{
147748147798
sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
147749147799
}
147750147800
sqlite3DebugPrintf(
@@ -231510,12 +231560,12 @@
231510231560
}
231511231561
#endif /* SQLITE_CORE */
231512231562
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
231513231563
231514231564
/************** End of stmt.c ************************************************/
231515
-#if __LINE__!=231515
231565
+#if __LINE__!=231565
231516231566
#undef SQLITE_SOURCE_ID
231517
-#define SQLITE_SOURCE_ID "2020-10-12 18:09:16 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca64alt2"
231567
+#define SQLITE_SOURCE_ID "2020-10-19 12:35:08 77e64647ec429c6e0d884abbd00dabebe738f89544a4984d6fd7a702b928alt2"
231518231568
#endif
231519231569
/* Return the source-id for this library */
231520231570
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
231521231571
/************************** End of sqlite3.c ******************************/
231522231572
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1171,11 +1171,11 @@
1171 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1172 ** [sqlite_version()] and [sqlite_source_id()].
1173 */
1174 #define SQLITE_VERSION "3.34.0"
1175 #define SQLITE_VERSION_NUMBER 3034000
1176 #define SQLITE_SOURCE_ID "2020-10-12 18:09:16 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca6409d5"
1177
1178 /*
1179 ** CAPI3REF: Run-Time Library Version Numbers
1180 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1181 **
@@ -10290,22 +10290,29 @@
10290
10291 /*
10292 ** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
10293 **
10294 ** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
10295 ** method of a [virtual table], then it returns true if and only if the
10296 ** column is being fetched as part of an UPDATE operation during which the
10297 ** column value will not change. Applications might use this to substitute
10298 ** a return value that is less expensive to compute and that the corresponding
 
10299 ** [xUpdate] method understands as a "no-change" value.
10300 **
10301 ** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
10302 ** the column is not changed by the UPDATE statement, then the xColumn
10303 ** method can optionally return without setting a result, without calling
10304 ** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
10305 ** In that case, [sqlite3_value_nochange(X)] will return true for the
10306 ** same column in the [xUpdate] method.
 
 
 
 
 
 
10307 */
10308 SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
10309
10310 /*
10311 ** CAPI3REF: Determine The Collation For a Virtual Table Constraint
@@ -46915,11 +46922,15 @@
46915 }else{
46916 /* Opens a file, only if it exists. */
46917 dwCreationDisposition = OPEN_EXISTING;
46918 }
46919
46920 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
 
 
 
 
46921
46922 if( isDelete ){
46923 #if SQLITE_OS_WINCE
46924 dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;
46925 isTemp = 1;
@@ -48068,15 +48079,18 @@
48068
48069 /*
48070 ** Close an memdb-file.
48071 **
48072 ** The pData pointer is owned by the application, so there is nothing
48073 ** to free.
 
48074 */
48075 static int memdbClose(sqlite3_file *pFile){
48076 MemFile *p = (MemFile *)pFile;
48077 if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ) sqlite3_free(p->aData);
 
 
48078 return SQLITE_OK;
48079 }
48080
48081 /*
48082 ** Read data from an memdb-file.
@@ -48531,10 +48545,11 @@
48531 p = memdbFromDbSchema(db, zSchema);
48532 if( p==0 ){
48533 rc = SQLITE_ERROR;
48534 }else{
48535 p->aData = pData;
 
48536 p->sz = szDb;
48537 p->szAlloc = szBuf;
48538 p->szMax = szBuf;
48539 if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
48540 p->szMax = sqlite3GlobalConfig.mxMemdbSize;
@@ -48543,10 +48558,13 @@
48543 rc = SQLITE_OK;
48544 }
48545
48546 end_deserialize:
48547 sqlite3_finalize(pStmt);
 
 
 
48548 sqlite3_mutex_leave(db->mutex);
48549 return rc;
48550 }
48551
48552 /*
@@ -115172,11 +115190,11 @@
115172 int i;
115173 struct SrcList_item *pItem;
115174 assert(pList || pParse->db->mallocFailed );
115175 if( pList ){
115176 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
115177 if( pItem->iCursor>=0 ) break;
115178 pItem->iCursor = pParse->nTab++;
115179 if( pItem->pSelect ){
115180 sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);
115181 }
115182 }
@@ -131978,10 +131996,11 @@
131978 ){
131979 SrcList *pSrc = p->pSrc; /* The FROM clause of the recursive query */
131980 int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
131981 Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
131982 Select *pSetup = p->pPrior; /* The setup query */
 
131983 int addrTop; /* Top of the loop */
131984 int addrCont, addrBreak; /* CONTINUE and BREAK addresses */
131985 int iCurrent = 0; /* The Current table */
131986 int regCurrent; /* Register holding Current table */
131987 int iQueue; /* The Queue table */
@@ -132052,12 +132071,30 @@
132052 p->selFlags |= SF_UsesEphemeral;
132053 }
132054
132055 /* Detach the ORDER BY clause from the compound SELECT */
132056 p->pOrderBy = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132057
132058 /* Store the results of the setup-query in Queue. */
 
132059 pSetup->pNext = 0;
132060 ExplainQueryPlan((pParse, 1, "SETUP"));
132061 rc = sqlite3Select(pParse, pSetup, &destQueue);
132062 pSetup->pNext = p;
132063 if( rc ) goto end_of_recursive_query;
@@ -132086,19 +132123,15 @@
132086 sqlite3VdbeResolveLabel(v, addrCont);
132087
132088 /* Execute the recursive SELECT taking the single row in Current as
132089 ** the value for the recursive-table. Store the results in the Queue.
132090 */
132091 if( p->selFlags & SF_Aggregate ){
132092 sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
132093 }else{
132094 p->pPrior = 0;
132095 ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
132096 sqlite3Select(pParse, p, &destQueue);
132097 assert( p->pPrior==0 );
132098 p->pPrior = pSetup;
132099 }
132100
132101 /* Keep running the loop until the Queue is empty */
132102 sqlite3VdbeGoto(v, addrTop);
132103 sqlite3VdbeResolveLabel(v, addrBreak);
132104
@@ -132162,10 +132195,20 @@
132162 p->nSelectRow = nRow;
132163 p = p->pNext;
132164 }
132165 return rc;
132166 }
 
 
 
 
 
 
 
 
 
 
132167
132168 /*
132169 ** This routine is called to process a compound query form from
132170 ** two or more separate queries using UNION, UNION ALL, EXCEPT, or
132171 ** INTERSECT
@@ -132248,11 +132291,11 @@
132248 */
132249 assert( p->pEList && pPrior->pEList );
132250 assert( p->pEList->nExpr==pPrior->pEList->nExpr );
132251
132252 #ifndef SQLITE_OMIT_CTE
132253 if( p->selFlags & SF_Recursive ){
132254 generateWithRecursiveQuery(pParse, p, &dest);
132255 }else
132256 #endif
132257
132258 /* Compound SELECTs that have an ORDER BY clause are handled separately.
@@ -132339,10 +132382,11 @@
132339 assert( p->addrOpenEphm[0] == -1 );
132340 p->addrOpenEphm[0] = addr;
132341 findRightmost(p)->selFlags |= SF_UsesEphemeral;
132342 assert( p->pEList );
132343 }
 
132344
132345 /* Code the SELECT statements to our left
132346 */
132347 assert( !pPrior->pOrderBy );
132348 sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
@@ -134432,12 +134476,14 @@
134432 if( pCte ){
134433 Table *pTab;
134434 ExprList *pEList;
134435 Select *pSel;
134436 Select *pLeft; /* Left-most SELECT statement */
 
134437 int bMayRecursive; /* True if compound joined by UNION [ALL] */
134438 With *pSavedWith; /* Initial value of pParse->pWith */
 
134439
134440 /* If pCte->zCteErr is non-NULL at this point, then this is an illegal
134441 ** recursive reference to CTE pCte. Leave an error in pParse and return
134442 ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.
134443 ** In this case, proceed. */
@@ -134458,48 +134504,52 @@
134458 pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
134459 if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;
134460 assert( pFrom->pSelect );
134461
134462 /* Check if this is a recursive CTE. */
134463 pSel = pFrom->pSelect;
134464 bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
134465 if( bMayRecursive ){
134466 int i;
134467 SrcList *pSrc = pFrom->pSelect->pSrc;
 
134468 for(i=0; i<pSrc->nSrc; i++){
134469 struct SrcList_item *pItem = &pSrc->a[i];
134470 if( pItem->zDatabase==0
134471 && pItem->zName!=0
134472 && 0==sqlite3StrICmp(pItem->zName, pCte->zName)
134473 ){
134474 pItem->pTab = pTab;
134475 pItem->fg.isRecursive = 1;
 
 
 
 
 
 
134476 pTab->nTabRef++;
134477 pSel->selFlags |= SF_Recursive;
 
 
134478 }
134479 }
134480 }
134481
134482 /* Only one recursive reference is permitted. */
134483 if( pTab->nTabRef>2 ){
134484 sqlite3ErrorMsg(
134485 pParse, "multiple references to recursive table: %s", pCte->zName
134486 );
134487 return SQLITE_ERROR;
134488 }
134489 assert( pTab->nTabRef==1 ||
134490 ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 ));
134491
134492 pCte->zCteErr = "circular reference: %s";
134493 pSavedWith = pParse->pWith;
134494 pParse->pWith = pWith;
134495 if( bMayRecursive ){
134496 Select *pPrior = pSel->pPrior;
134497 assert( pPrior->pWith==0 );
134498 pPrior->pWith = pSel->pWith;
134499 sqlite3WalkSelect(pWalker, pPrior);
134500 pPrior->pWith = 0;
 
 
 
134501 }else{
134502 sqlite3WalkSelect(pWalker, pSel);
134503 }
134504 pParse->pWith = pWith;
134505
@@ -147740,11 +147790,11 @@
147740 if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
147741 if( pTerm->eOperator & WO_SINGLE ){
147742 sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
147743 pTerm->leftCursor, pTerm->u.x.leftColumn);
147744 }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
147745 sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
147746 pTerm->u.pOrInfo->indexable);
147747 }else{
147748 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
147749 }
147750 sqlite3DebugPrintf(
@@ -231510,12 +231560,12 @@
231510 }
231511 #endif /* SQLITE_CORE */
231512 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
231513
231514 /************** End of stmt.c ************************************************/
231515 #if __LINE__!=231515
231516 #undef SQLITE_SOURCE_ID
231517 #define SQLITE_SOURCE_ID "2020-10-12 18:09:16 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca64alt2"
231518 #endif
231519 /* Return the source-id for this library */
231520 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
231521 /************************** End of sqlite3.c ******************************/
231522
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1171,11 +1171,11 @@
1171 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1172 ** [sqlite_version()] and [sqlite_source_id()].
1173 */
1174 #define SQLITE_VERSION "3.34.0"
1175 #define SQLITE_VERSION_NUMBER 3034000
1176 #define SQLITE_SOURCE_ID "2020-10-19 12:35:08 77e64647ec429c6e0d884abbd00dabebe738f89544a4984d6fd7a702b928ccfd"
1177
1178 /*
1179 ** CAPI3REF: Run-Time Library Version Numbers
1180 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1181 **
@@ -10290,22 +10290,29 @@
10290
10291 /*
10292 ** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
10293 **
10294 ** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
10295 ** method of a [virtual table], then it might return true if the
10296 ** column is being fetched as part of an UPDATE operation during which the
10297 ** column value will not change. The virtual table implementation can use
10298 ** this hint as permission to substitute a return value that is less
10299 ** expensive to compute and that the corresponding
10300 ** [xUpdate] method understands as a "no-change" value.
10301 **
10302 ** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
10303 ** the column is not changed by the UPDATE statement, then the xColumn
10304 ** method can optionally return without setting a result, without calling
10305 ** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
10306 ** In that case, [sqlite3_value_nochange(X)] will return true for the
10307 ** same column in the [xUpdate] method.
10308 **
10309 ** The sqlite3_vtab_nochange() routine is an optimization. Virtual table
10310 ** implementations should continue to give a correct answer even if the
10311 ** sqlite3_vtab_nochange() interface were to always return false. In the
10312 ** current implementation, the sqlite3_vtab_nochange() interface does always
10313 ** returns false for the enhanced [UPDATE FROM] statement.
10314 */
10315 SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
10316
10317 /*
10318 ** CAPI3REF: Determine The Collation For a Virtual Table Constraint
@@ -46915,11 +46922,15 @@
46922 }else{
46923 /* Opens a file, only if it exists. */
46924 dwCreationDisposition = OPEN_EXISTING;
46925 }
46926
46927 if( 0==sqlite3_uri_boolean(zName, "exclusive", 0) ){
46928 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
46929 }else{
46930 dwShareMode = 0;
46931 }
46932
46933 if( isDelete ){
46934 #if SQLITE_OS_WINCE
46935 dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;
46936 isTemp = 1;
@@ -48068,15 +48079,18 @@
48079
48080 /*
48081 ** Close an memdb-file.
48082 **
48083 ** The pData pointer is owned by the application, so there is nothing
48084 ** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set,
48085 ** in which case we own the pData pointer and need to free it.
48086 */
48087 static int memdbClose(sqlite3_file *pFile){
48088 MemFile *p = (MemFile *)pFile;
48089 if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){
48090 sqlite3_free(p->aData);
48091 }
48092 return SQLITE_OK;
48093 }
48094
48095 /*
48096 ** Read data from an memdb-file.
@@ -48531,10 +48545,11 @@
48545 p = memdbFromDbSchema(db, zSchema);
48546 if( p==0 ){
48547 rc = SQLITE_ERROR;
48548 }else{
48549 p->aData = pData;
48550 pData = 0;
48551 p->sz = szDb;
48552 p->szAlloc = szBuf;
48553 p->szMax = szBuf;
48554 if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
48555 p->szMax = sqlite3GlobalConfig.mxMemdbSize;
@@ -48543,10 +48558,13 @@
48558 rc = SQLITE_OK;
48559 }
48560
48561 end_deserialize:
48562 sqlite3_finalize(pStmt);
48563 if( pData && (mFlags & SQLITE_DESERIALIZE_FREEONCLOSE)!=0 ){
48564 sqlite3_free(pData);
48565 }
48566 sqlite3_mutex_leave(db->mutex);
48567 return rc;
48568 }
48569
48570 /*
@@ -115172,11 +115190,11 @@
115190 int i;
115191 struct SrcList_item *pItem;
115192 assert(pList || pParse->db->mallocFailed );
115193 if( pList ){
115194 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
115195 if( pItem->iCursor>=0 ) continue;
115196 pItem->iCursor = pParse->nTab++;
115197 if( pItem->pSelect ){
115198 sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);
115199 }
115200 }
@@ -131978,10 +131996,11 @@
131996 ){
131997 SrcList *pSrc = p->pSrc; /* The FROM clause of the recursive query */
131998 int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
131999 Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
132000 Select *pSetup = p->pPrior; /* The setup query */
132001 Select *pFirstRec; /* Left-most recursive term */
132002 int addrTop; /* Top of the loop */
132003 int addrCont, addrBreak; /* CONTINUE and BREAK addresses */
132004 int iCurrent = 0; /* The Current table */
132005 int regCurrent; /* Register holding Current table */
132006 int iQueue; /* The Queue table */
@@ -132052,12 +132071,30 @@
132071 p->selFlags |= SF_UsesEphemeral;
132072 }
132073
132074 /* Detach the ORDER BY clause from the compound SELECT */
132075 p->pOrderBy = 0;
132076
132077 /* Figure out how many elements of the compound SELECT are part of the
132078 ** recursive query. Make sure no recursive elements use aggregate
132079 ** functions. Mark the recursive elements as UNION ALL even if they
132080 ** are really UNION because the distinctness will be enforced by the
132081 ** iDistinct table. pFirstRec is left pointing to the left-most
132082 ** recursive term of the CTE.
132083 */
132084 pFirstRec = p;
132085 for(pFirstRec=p; ALWAYS(pFirstRec!=0); pFirstRec=pFirstRec->pPrior){
132086 if( pFirstRec->selFlags & SF_Aggregate ){
132087 sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
132088 goto end_of_recursive_query;
132089 }
132090 pFirstRec->op = TK_ALL;
132091 if( (pFirstRec->pPrior->selFlags & SF_Recursive)==0 ) break;
132092 }
132093
132094 /* Store the results of the setup-query in Queue. */
132095 pSetup = pFirstRec->pPrior;
132096 pSetup->pNext = 0;
132097 ExplainQueryPlan((pParse, 1, "SETUP"));
132098 rc = sqlite3Select(pParse, pSetup, &destQueue);
132099 pSetup->pNext = p;
132100 if( rc ) goto end_of_recursive_query;
@@ -132086,19 +132123,15 @@
132123 sqlite3VdbeResolveLabel(v, addrCont);
132124
132125 /* Execute the recursive SELECT taking the single row in Current as
132126 ** the value for the recursive-table. Store the results in the Queue.
132127 */
132128 pFirstRec->pPrior = 0;
132129 ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
132130 sqlite3Select(pParse, p, &destQueue);
132131 assert( pFirstRec->pPrior==0 );
132132 pFirstRec->pPrior = pSetup;
 
 
 
 
132133
132134 /* Keep running the loop until the Queue is empty */
132135 sqlite3VdbeGoto(v, addrTop);
132136 sqlite3VdbeResolveLabel(v, addrBreak);
132137
@@ -132162,10 +132195,20 @@
132195 p->nSelectRow = nRow;
132196 p = p->pNext;
132197 }
132198 return rc;
132199 }
132200
132201 /*
132202 ** Return true if the SELECT statement which is known to be the recursive
132203 ** part of a recursive CTE still has its anchor terms attached. If the
132204 ** anchor terms have already been removed, then return false.
132205 */
132206 static int hasAnchor(Select *p){
132207 while( p && (p->selFlags & SF_Recursive)!=0 ){ p = p->pPrior; }
132208 return p!=0;
132209 }
132210
132211 /*
132212 ** This routine is called to process a compound query form from
132213 ** two or more separate queries using UNION, UNION ALL, EXCEPT, or
132214 ** INTERSECT
@@ -132248,11 +132291,11 @@
132291 */
132292 assert( p->pEList && pPrior->pEList );
132293 assert( p->pEList->nExpr==pPrior->pEList->nExpr );
132294
132295 #ifndef SQLITE_OMIT_CTE
132296 if( (p->selFlags & SF_Recursive)!=0 && hasAnchor(p) ){
132297 generateWithRecursiveQuery(pParse, p, &dest);
132298 }else
132299 #endif
132300
132301 /* Compound SELECTs that have an ORDER BY clause are handled separately.
@@ -132339,10 +132382,11 @@
132382 assert( p->addrOpenEphm[0] == -1 );
132383 p->addrOpenEphm[0] = addr;
132384 findRightmost(p)->selFlags |= SF_UsesEphemeral;
132385 assert( p->pEList );
132386 }
132387
132388
132389 /* Code the SELECT statements to our left
132390 */
132391 assert( !pPrior->pOrderBy );
132392 sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
@@ -134432,12 +134476,14 @@
134476 if( pCte ){
134477 Table *pTab;
134478 ExprList *pEList;
134479 Select *pSel;
134480 Select *pLeft; /* Left-most SELECT statement */
134481 Select *pRecTerm; /* Left-most recursive term */
134482 int bMayRecursive; /* True if compound joined by UNION [ALL] */
134483 With *pSavedWith; /* Initial value of pParse->pWith */
134484 int iRecTab = -1; /* Cursor for recursive table */
134485
134486 /* If pCte->zCteErr is non-NULL at this point, then this is an illegal
134487 ** recursive reference to CTE pCte. Leave an error in pParse and return
134488 ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.
134489 ** In this case, proceed. */
@@ -134458,48 +134504,52 @@
134504 pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
134505 if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;
134506 assert( pFrom->pSelect );
134507
134508 /* Check if this is a recursive CTE. */
134509 pRecTerm = pSel = pFrom->pSelect;
134510 bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
134511 while( bMayRecursive && pRecTerm->op==pSel->op ){
134512 int i;
134513 SrcList *pSrc = pRecTerm->pSrc;
134514 assert( pRecTerm->pPrior!=0 );
134515 for(i=0; i<pSrc->nSrc; i++){
134516 struct SrcList_item *pItem = &pSrc->a[i];
134517 if( pItem->zDatabase==0
134518 && pItem->zName!=0
134519 && 0==sqlite3StrICmp(pItem->zName, pCte->zName)
134520 ){
134521 pItem->pTab = pTab;
134522 pItem->fg.isRecursive = 1;
134523 if( pRecTerm->selFlags & SF_Recursive ){
134524 sqlite3ErrorMsg(pParse,
134525 "multiple references to recursive table: %s", pCte->zName
134526 );
134527 return SQLITE_ERROR;
134528 }
134529 pTab->nTabRef++;
134530 pRecTerm->selFlags |= SF_Recursive;
134531 if( iRecTab<0 ) iRecTab = pParse->nTab++;
134532 pItem->iCursor = iRecTab;
134533 }
134534 }
134535 if( (pRecTerm->selFlags & SF_Recursive)==0 ) break;
134536 pRecTerm = pRecTerm->pPrior;
134537 }
 
 
 
 
 
 
 
 
134538
134539 pCte->zCteErr = "circular reference: %s";
134540 pSavedWith = pParse->pWith;
134541 pParse->pWith = pWith;
134542 if( pSel->selFlags & SF_Recursive ){
134543 assert( pRecTerm!=0 );
134544 assert( (pRecTerm->selFlags & SF_Recursive)==0 );
134545 assert( pRecTerm->pNext!=0 );
134546 assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 );
134547 assert( pRecTerm->pWith==0 );
134548 pRecTerm->pWith = pSel->pWith;
134549 sqlite3WalkSelect(pWalker, pRecTerm);
134550 pRecTerm->pWith = 0;
134551 }else{
134552 sqlite3WalkSelect(pWalker, pSel);
134553 }
134554 pParse->pWith = pWith;
134555
@@ -147740,11 +147790,11 @@
147790 if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
147791 if( pTerm->eOperator & WO_SINGLE ){
147792 sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
147793 pTerm->leftCursor, pTerm->u.x.leftColumn);
147794 }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
147795 sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%llx",
147796 pTerm->u.pOrInfo->indexable);
147797 }else{
147798 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
147799 }
147800 sqlite3DebugPrintf(
@@ -231510,12 +231560,12 @@
231560 }
231561 #endif /* SQLITE_CORE */
231562 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
231563
231564 /************** End of stmt.c ************************************************/
231565 #if __LINE__!=231565
231566 #undef SQLITE_SOURCE_ID
231567 #define SQLITE_SOURCE_ID "2020-10-19 12:35:08 77e64647ec429c6e0d884abbd00dabebe738f89544a4984d6fd7a702b928alt2"
231568 #endif
231569 /* Return the source-id for this library */
231570 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
231571 /************************** End of sqlite3.c ******************************/
231572
+11 -4
--- 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.34.0"
127127
#define SQLITE_VERSION_NUMBER 3034000
128
-#define SQLITE_SOURCE_ID "2020-10-12 18:09:16 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca6409d5"
128
+#define SQLITE_SOURCE_ID "2020-10-19 12:35:08 77e64647ec429c6e0d884abbd00dabebe738f89544a4984d6fd7a702b928ccfd"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -9242,22 +9242,29 @@
92429242
92439243
/*
92449244
** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
92459245
**
92469246
** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
9247
-** method of a [virtual table], then it returns true if and only if the
9247
+** method of a [virtual table], then it might return true if the
92489248
** column is being fetched as part of an UPDATE operation during which the
9249
-** column value will not change. Applications might use this to substitute
9250
-** a return value that is less expensive to compute and that the corresponding
9249
+** column value will not change. The virtual table implementation can use
9250
+** this hint as permission to substitute a return value that is less
9251
+** expensive to compute and that the corresponding
92519252
** [xUpdate] method understands as a "no-change" value.
92529253
**
92539254
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
92549255
** the column is not changed by the UPDATE statement, then the xColumn
92559256
** method can optionally return without setting a result, without calling
92569257
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
92579258
** In that case, [sqlite3_value_nochange(X)] will return true for the
92589259
** same column in the [xUpdate] method.
9260
+**
9261
+** The sqlite3_vtab_nochange() routine is an optimization. Virtual table
9262
+** implementations should continue to give a correct answer even if the
9263
+** sqlite3_vtab_nochange() interface were to always return false. In the
9264
+** current implementation, the sqlite3_vtab_nochange() interface does always
9265
+** returns false for the enhanced [UPDATE FROM] statement.
92599266
*/
92609267
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
92619268
92629269
/*
92639270
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
92649271
--- 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.34.0"
127 #define SQLITE_VERSION_NUMBER 3034000
128 #define SQLITE_SOURCE_ID "2020-10-12 18:09:16 7e17c2f4b7dc9b563d0b4da949bb134dc7c4fc9c86ce03891432a884ca6409d5"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -9242,22 +9242,29 @@
9242
9243 /*
9244 ** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
9245 **
9246 ** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
9247 ** method of a [virtual table], then it returns true if and only if the
9248 ** column is being fetched as part of an UPDATE operation during which the
9249 ** column value will not change. Applications might use this to substitute
9250 ** a return value that is less expensive to compute and that the corresponding
 
9251 ** [xUpdate] method understands as a "no-change" value.
9252 **
9253 ** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
9254 ** the column is not changed by the UPDATE statement, then the xColumn
9255 ** method can optionally return without setting a result, without calling
9256 ** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
9257 ** In that case, [sqlite3_value_nochange(X)] will return true for the
9258 ** same column in the [xUpdate] method.
 
 
 
 
 
 
9259 */
9260 SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
9261
9262 /*
9263 ** CAPI3REF: Determine The Collation For a Virtual Table Constraint
9264
--- 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.34.0"
127 #define SQLITE_VERSION_NUMBER 3034000
128 #define SQLITE_SOURCE_ID "2020-10-19 12:35:08 77e64647ec429c6e0d884abbd00dabebe738f89544a4984d6fd7a702b928ccfd"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -9242,22 +9242,29 @@
9242
9243 /*
9244 ** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
9245 **
9246 ** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
9247 ** method of a [virtual table], then it might return true if the
9248 ** column is being fetched as part of an UPDATE operation during which the
9249 ** column value will not change. The virtual table implementation can use
9250 ** this hint as permission to substitute a return value that is less
9251 ** expensive to compute and that the corresponding
9252 ** [xUpdate] method understands as a "no-change" value.
9253 **
9254 ** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
9255 ** the column is not changed by the UPDATE statement, then the xColumn
9256 ** method can optionally return without setting a result, without calling
9257 ** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
9258 ** In that case, [sqlite3_value_nochange(X)] will return true for the
9259 ** same column in the [xUpdate] method.
9260 **
9261 ** The sqlite3_vtab_nochange() routine is an optimization. Virtual table
9262 ** implementations should continue to give a correct answer even if the
9263 ** sqlite3_vtab_nochange() interface were to always return false. In the
9264 ** current implementation, the sqlite3_vtab_nochange() interface does always
9265 ** returns false for the enhanced [UPDATE FROM] statement.
9266 */
9267 SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
9268
9269 /*
9270 ** CAPI3REF: Determine The Collation For a Virtual Table Constraint
9271

Keyboard Shortcuts

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