Fossil SCM

Update the built-in SQLite to the latest 3.41.0 alpha, for testing of SQLite.

drh 2023-01-27 15:40 trunk
Commit 0f30113b3b2004953fc6db7976ac78fc060e24be8aacb690a3f9b16210334e46
+11 -7
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -19933,10 +19933,11 @@
1993319933
#endif /* SQLITE_OMIT_TRACE */
1993419934
#ifdef SQLITE_DEBUG
1993519935
".unmodule NAME ... Unregister virtual table modules",
1993619936
" --allexcept Unregister everything except those named",
1993719937
#endif
19938
+ ".version Show source, library and compiler versions",
1993819939
".vfsinfo ?AUX? Information about the top-level VFS",
1993919940
".vfslist List all available VFSes",
1994019941
".vfsname ?AUX? Print the name of the VFS stack",
1994119942
".width NUM1 NUM2 ... Set minimum column widths for columnar output",
1994219943
" Negative values right-justify",
@@ -21130,11 +21131,11 @@
2113021131
const unsigned char *zName;
2113121132
const unsigned char *zSql;
2113221133
char *zErrMsg = 0;
2113321134
2113421135
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
21135
- " WHERE %s", zWhere);
21136
+ " WHERE %s ORDER BY rowid ASC", zWhere);
2113621137
shell_check_oom(zQuery);
2113721138
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
2113821139
if( rc ){
2113921140
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
2114021141
sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
@@ -21143,16 +21144,18 @@
2114321144
}
2114421145
while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
2114521146
zName = sqlite3_column_text(pQuery, 0);
2114621147
zSql = sqlite3_column_text(pQuery, 1);
2114721148
if( zName==0 || zSql==0 ) continue;
21148
- printf("%s... ", zName); fflush(stdout);
21149
- sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
21150
- if( zErrMsg ){
21151
- utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
21152
- sqlite3_free(zErrMsg);
21153
- zErrMsg = 0;
21149
+ if( sqlite3_stricmp((char*)zName, "sqlite_sequence")!=0 ){
21150
+ printf("%s... ", zName); fflush(stdout);
21151
+ sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
21152
+ if( zErrMsg ){
21153
+ utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
21154
+ sqlite3_free(zErrMsg);
21155
+ zErrMsg = 0;
21156
+ }
2115421157
}
2115521158
if( xForEach ){
2115621159
xForEach(p, newDb, (const char*)zName);
2115721160
}
2115821161
printf("done\n");
@@ -21172,10 +21175,11 @@
2117221175
}
2117321176
while( sqlite3_step(pQuery)==SQLITE_ROW ){
2117421177
zName = sqlite3_column_text(pQuery, 0);
2117521178
zSql = sqlite3_column_text(pQuery, 1);
2117621179
if( zName==0 || zSql==0 ) continue;
21180
+ if( sqlite3_stricmp((char*)zName, "sqlite_sequence")!=0 ) continue;
2117721181
printf("%s... ", zName); fflush(stdout);
2117821182
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
2117921183
if( zErrMsg ){
2118021184
utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
2118121185
sqlite3_free(zErrMsg);
2118221186
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -19933,10 +19933,11 @@
19933 #endif /* SQLITE_OMIT_TRACE */
19934 #ifdef SQLITE_DEBUG
19935 ".unmodule NAME ... Unregister virtual table modules",
19936 " --allexcept Unregister everything except those named",
19937 #endif
 
19938 ".vfsinfo ?AUX? Information about the top-level VFS",
19939 ".vfslist List all available VFSes",
19940 ".vfsname ?AUX? Print the name of the VFS stack",
19941 ".width NUM1 NUM2 ... Set minimum column widths for columnar output",
19942 " Negative values right-justify",
@@ -21130,11 +21131,11 @@
21130 const unsigned char *zName;
21131 const unsigned char *zSql;
21132 char *zErrMsg = 0;
21133
21134 zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
21135 " WHERE %s", zWhere);
21136 shell_check_oom(zQuery);
21137 rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
21138 if( rc ){
21139 utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
21140 sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
@@ -21143,16 +21144,18 @@
21143 }
21144 while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
21145 zName = sqlite3_column_text(pQuery, 0);
21146 zSql = sqlite3_column_text(pQuery, 1);
21147 if( zName==0 || zSql==0 ) continue;
21148 printf("%s... ", zName); fflush(stdout);
21149 sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
21150 if( zErrMsg ){
21151 utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
21152 sqlite3_free(zErrMsg);
21153 zErrMsg = 0;
 
 
21154 }
21155 if( xForEach ){
21156 xForEach(p, newDb, (const char*)zName);
21157 }
21158 printf("done\n");
@@ -21172,10 +21175,11 @@
21172 }
21173 while( sqlite3_step(pQuery)==SQLITE_ROW ){
21174 zName = sqlite3_column_text(pQuery, 0);
21175 zSql = sqlite3_column_text(pQuery, 1);
21176 if( zName==0 || zSql==0 ) continue;
 
21177 printf("%s... ", zName); fflush(stdout);
21178 sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
21179 if( zErrMsg ){
21180 utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
21181 sqlite3_free(zErrMsg);
21182
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -19933,10 +19933,11 @@
19933 #endif /* SQLITE_OMIT_TRACE */
19934 #ifdef SQLITE_DEBUG
19935 ".unmodule NAME ... Unregister virtual table modules",
19936 " --allexcept Unregister everything except those named",
19937 #endif
19938 ".version Show source, library and compiler versions",
19939 ".vfsinfo ?AUX? Information about the top-level VFS",
19940 ".vfslist List all available VFSes",
19941 ".vfsname ?AUX? Print the name of the VFS stack",
19942 ".width NUM1 NUM2 ... Set minimum column widths for columnar output",
19943 " Negative values right-justify",
@@ -21130,11 +21131,11 @@
21131 const unsigned char *zName;
21132 const unsigned char *zSql;
21133 char *zErrMsg = 0;
21134
21135 zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
21136 " WHERE %s ORDER BY rowid ASC", zWhere);
21137 shell_check_oom(zQuery);
21138 rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
21139 if( rc ){
21140 utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
21141 sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
@@ -21143,16 +21144,18 @@
21144 }
21145 while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
21146 zName = sqlite3_column_text(pQuery, 0);
21147 zSql = sqlite3_column_text(pQuery, 1);
21148 if( zName==0 || zSql==0 ) continue;
21149 if( sqlite3_stricmp((char*)zName, "sqlite_sequence")!=0 ){
21150 printf("%s... ", zName); fflush(stdout);
21151 sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
21152 if( zErrMsg ){
21153 utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
21154 sqlite3_free(zErrMsg);
21155 zErrMsg = 0;
21156 }
21157 }
21158 if( xForEach ){
21159 xForEach(p, newDb, (const char*)zName);
21160 }
21161 printf("done\n");
@@ -21172,10 +21175,11 @@
21175 }
21176 while( sqlite3_step(pQuery)==SQLITE_ROW ){
21177 zName = sqlite3_column_text(pQuery, 0);
21178 zSql = sqlite3_column_text(pQuery, 1);
21179 if( zName==0 || zSql==0 ) continue;
21180 if( sqlite3_stricmp((char*)zName, "sqlite_sequence")!=0 ) continue;
21181 printf("%s... ", zName); fflush(stdout);
21182 sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
21183 if( zErrMsg ){
21184 utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
21185 sqlite3_free(zErrMsg);
21186
+230 -68
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455455
#define SQLITE_VERSION "3.41.0"
456456
#define SQLITE_VERSION_NUMBER 3041000
457
-#define SQLITE_SOURCE_ID "2023-01-16 18:13:00 83f21285fe86430a66ce6841606e3ad7c27da52ac75a034c6a00c7a9fdb9791d"
457
+#define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -10110,18 +10110,17 @@
1011010110
** [xFilter|xFilter() method] of a [virtual table] implementation.
1011110111
** The result of invoking these interfaces from any other context
1011210112
** is undefined and probably harmful.
1011310113
**
1011410114
** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
10115
-** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
10115
+** sqlite3_vtab_in_next(X,P) should be one of the parameters to the
1011610116
** xFilter method which invokes these routines, and specifically
1011710117
** a parameter that was previously selected for all-at-once IN constraint
1011810118
** processing use the [sqlite3_vtab_in()] interface in the
1011910119
** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
1012010120
** an xFilter argument that was selected for all-at-once IN constraint
10121
-** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
10122
-** exhibit some other undefined or harmful behavior.
10121
+** processing, then these routines return [SQLITE_ERROR].)^
1012310122
**
1012410123
** ^(Use these routines to access all values on the right-hand side
1012510124
** of the IN constraint using code like the following:
1012610125
**
1012710126
** <blockquote><pre>
@@ -23039,10 +23038,12 @@
2303923038
SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
2304023039
SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
2304123040
SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
2304223041
SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
2304323042
SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
23043
+
23044
+SQLITE_PRIVATE void sqlite3VdbeValueListFree(void*);
2304423045
2304523046
#ifdef SQLITE_DEBUG
2304623047
SQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe*, VdbeCursor*);
2304723048
SQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe*);
2304823049
#else
@@ -58359,11 +58360,11 @@
5835958360
if( rc==SQLITE_OK && zSuper[0] && res ){
5836058361
/* If there was a super-journal and this routine will return success,
5836158362
** see if it is possible to delete the super-journal.
5836258363
*/
5836358364
assert( zSuper==&pPager->pTmpSpace[4] );
58364
- memset(&zSuper[-4], 0, 4);
58365
+ memset(pPager->pTmpSpace, 0, 4);
5836558366
rc = pager_delsuper(pPager, zSuper);
5836658367
testcase( rc!=SQLITE_OK );
5836758368
}
5836858369
if( isHot && nPlayback ){
5836958370
sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, "recovered %d pages from %s",
@@ -88576,10 +88577,21 @@
8857688577
*/
8857788578
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){
8857888579
assert( p );
8857988580
return sqlite3_value_nochange(p->pOut);
8858088581
}
88582
+
88583
+/*
88584
+** The destructor function for a ValueList object. This needs to be
88585
+** a separate function, unknowable to the application, to ensure that
88586
+** calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not
88587
+** preceeded by activation of IN processing via sqlite3_vtab_int() do not
88588
+** try to access a fake ValueList object inserted by a hostile extension.
88589
+*/
88590
+SQLITE_PRIVATE void sqlite3VdbeValueListFree(void *pToDelete){
88591
+ sqlite3_free(pToDelete);
88592
+}
8858188593
8858288594
/*
8858388595
** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
8858488596
** sqlite3_vtab_in_next() (if bNext!=0).
8858588597
*/
@@ -88591,12 +88603,19 @@
8859188603
int rc;
8859288604
ValueList *pRhs;
8859388605
8859488606
*ppOut = 0;
8859588607
if( pVal==0 ) return SQLITE_MISUSE;
88596
- pRhs = (ValueList*)sqlite3_value_pointer(pVal, "ValueList");
88597
- if( pRhs==0 ) return SQLITE_MISUSE;
88608
+ if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){
88609
+ return SQLITE_ERROR;
88610
+ }else{
88611
+ assert( (pVal->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) ==
88612
+ (MEM_Null|MEM_Term|MEM_Subtype) );
88613
+ assert( pVal->eSubtype=='p' );
88614
+ assert( pVal->u.zPType!=0 && strcmp(pVal->u.zPType,"ValueList")==0 );
88615
+ pRhs = (ValueList*)pVal->z;
88616
+ }
8859888617
if( bNext ){
8859988618
rc = sqlite3BtreeNext(pRhs->pCsr, 0);
8860088619
}else{
8860188620
int dummy = 0;
8860288621
rc = sqlite3BtreeFirst(pRhs->pCsr, &dummy);
@@ -92358,11 +92377,11 @@
9235892377
affinity = pOp->p5 & SQLITE_AFF_MASK;
9235992378
if( affinity>=SQLITE_AFF_NUMERIC ){
9236092379
if( (flags1 | flags3)&MEM_Str ){
9236192380
if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
9236292381
applyNumericAffinity(pIn1,0);
92363
- testcase( flags3==pIn3->flags );
92382
+ assert( flags3==pIn3->flags || CORRUPT_DB );
9236492383
flags3 = pIn3->flags;
9236592384
}
9236692385
if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
9236792386
applyNumericAffinity(pIn3,0);
9236892387
}
@@ -98195,11 +98214,11 @@
9819598214
if( pRhs==0 ) goto no_mem;
9819698215
pRhs->pCsr = pC->uc.pCursor;
9819798216
pRhs->pOut = &aMem[pOp->p3];
9819898217
pOut = out2Prerelease(p, pOp);
9819998218
pOut->flags = MEM_Null;
98200
- sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3_free);
98219
+ sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3VdbeValueListFree);
9820198220
break;
9820298221
}
9820398222
#endif /* SQLITE_OMIT_VIRTUALTABLE */
9820498223
9820598224
@@ -116559,11 +116578,11 @@
116559116578
const char *zFile;
116560116579
char *zPath = 0;
116561116580
char *zErr = 0;
116562116581
unsigned int flags;
116563116582
Db *aNew; /* New array of Db pointers */
116564
- Db *pNew; /* Db object for the newly attached database */
116583
+ Db *pNew = 0; /* Db object for the newly attached database */
116565116584
char *zErrDyn = 0;
116566116585
sqlite3_vfs *pVfs;
116567116586
116568116587
UNUSED_PARAMETER(NotUsed);
116569116588
zFile = (const char *)sqlite3_value_text(argv[0]);
@@ -116579,17 +116598,30 @@
116579116598
116580116599
if( REOPEN_AS_MEMDB(db) ){
116581116600
/* This is not a real ATTACH. Instead, this routine is being called
116582116601
** from sqlite3_deserialize() to close database db->init.iDb and
116583116602
** reopen it as a MemDB */
116603
+ Btree *pNewBt = 0;
116584116604
pVfs = sqlite3_vfs_find("memdb");
116585116605
if( pVfs==0 ) return;
116586
- pNew = &db->aDb[db->init.iDb];
116587
- if( pNew->pBt ) sqlite3BtreeClose(pNew->pBt);
116588
- pNew->pBt = 0;
116589
- pNew->pSchema = 0;
116590
- rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNew->pBt, 0, SQLITE_OPEN_MAIN_DB);
116606
+ rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNewBt, 0, SQLITE_OPEN_MAIN_DB);
116607
+ if( rc==SQLITE_OK ){
116608
+ Schema *pNewSchema = sqlite3SchemaGet(db, pNewBt);
116609
+ if( pNewSchema ){
116610
+ /* Both the Btree and the new Schema were allocated successfully.
116611
+ ** Close the old db and update the aDb[] slot with the new memdb
116612
+ ** values. */
116613
+ pNew = &db->aDb[db->init.iDb];
116614
+ if( ALWAYS(pNew->pBt) ) sqlite3BtreeClose(pNew->pBt);
116615
+ pNew->pBt = pNewBt;
116616
+ pNew->pSchema = pNewSchema;
116617
+ }else{
116618
+ sqlite3BtreeClose(pNewBt);
116619
+ rc = SQLITE_NOMEM;
116620
+ }
116621
+ }
116622
+ if( rc ) goto attach_error;
116591116623
}else{
116592116624
/* This is a real ATTACH
116593116625
**
116594116626
** Check for the following errors:
116595116627
**
@@ -116698,11 +116730,11 @@
116698116730
rc = SQLITE_AUTH_USER;
116699116731
}
116700116732
}
116701116733
#endif
116702116734
if( rc ){
116703
- if( !REOPEN_AS_MEMDB(db) ){
116735
+ if( ALWAYS(!REOPEN_AS_MEMDB(db)) ){
116704116736
int iDb = db->nDb - 1;
116705116737
assert( iDb>=2 );
116706116738
if( db->aDb[iDb].pBt ){
116707116739
sqlite3BtreeClose(db->aDb[iDb].pBt);
116708116740
db->aDb[iDb].pBt = 0;
@@ -116814,10 +116846,12 @@
116814116846
int rc;
116815116847
NameContext sName;
116816116848
Vdbe *v;
116817116849
sqlite3* db = pParse->db;
116818116850
int regArgs;
116851
+
116852
+ if( SQLITE_OK!=sqlite3ReadSchema(pParse) ) goto attach_end;
116819116853
116820116854
if( pParse->nErr ) goto attach_end;
116821116855
memset(&sName, 0, sizeof(NameContext));
116822116856
sName.pParse = pParse;
116823116857
@@ -125826,10 +125860,100 @@
125826125860
}
125827125861
*z = 0;
125828125862
sqlite3_result_text(context, zHex, n*2, sqlite3_free);
125829125863
}
125830125864
}
125865
+
125866
+/*
125867
+** Buffer zStr contains nStr bytes of utf-8 encoded text. Return 1 if zStr
125868
+** contains character ch, or 0 if it does not.
125869
+*/
125870
+static int strContainsChar(const u8 *zStr, int nStr, u32 ch){
125871
+ const u8 *zEnd = &zStr[nStr];
125872
+ const u8 *z = zStr;
125873
+ while( z<zEnd ){
125874
+ u32 tst = Utf8Read(z);
125875
+ if( tst==ch ) return 1;
125876
+ }
125877
+ return 0;
125878
+}
125879
+
125880
+/*
125881
+** The unhex() function. This function may be invoked with either one or
125882
+** two arguments. In both cases the first argument is interpreted as text
125883
+** a text value containing a set of pairs of hexadecimal digits which are
125884
+** decoded and returned as a blob.
125885
+**
125886
+** If there is only a single argument, then it must consist only of an
125887
+** even number of hexadeximal digits. Otherwise, return NULL.
125888
+**
125889
+** Or, if there is a second argument, then any character that appears in
125890
+** the second argument is also allowed to appear between pairs of hexadecimal
125891
+** digits in the first argument. If any other character appears in the
125892
+** first argument, or if one of the allowed characters appears between
125893
+** two hexadecimal digits that make up a single byte, NULL is returned.
125894
+**
125895
+** The following expressions are all true:
125896
+**
125897
+** unhex('ABCD') IS x'ABCD'
125898
+** unhex('AB CD') IS NULL
125899
+** unhex('AB CD', ' ') IS x'ABCD'
125900
+** unhex('A BCD', ' ') IS NULL
125901
+*/
125902
+static void unhexFunc(
125903
+ sqlite3_context *pCtx,
125904
+ int argc,
125905
+ sqlite3_value **argv
125906
+){
125907
+ const u8 *zPass = (const u8*)"";
125908
+ int nPass = 0;
125909
+ const u8 *zHex = sqlite3_value_text(argv[0]);
125910
+ int nHex = sqlite3_value_bytes(argv[0]);
125911
+#ifdef SQLITE_DEBUG
125912
+ const u8 *zEnd = &zHex[nHex];
125913
+#endif
125914
+ u8 *pBlob = 0;
125915
+ u8 *p = 0;
125916
+
125917
+ assert( argc==1 || argc==2 );
125918
+ if( argc==2 ){
125919
+ zPass = sqlite3_value_text(argv[1]);
125920
+ nPass = sqlite3_value_bytes(argv[1]);
125921
+ }
125922
+ if( !zHex || !zPass ) return;
125923
+
125924
+ p = pBlob = contextMalloc(pCtx, (nHex/2)+1);
125925
+ if( pBlob ){
125926
+ u8 c; /* Most significant digit of next byte */
125927
+ u8 d; /* Least significant digit of next byte */
125928
+
125929
+ while( (c = *zHex)!=0x00 ){
125930
+ while( !sqlite3Isxdigit(c) ){
125931
+ u32 ch = Utf8Read(zHex);
125932
+ assert( zHex<=zEnd );
125933
+ if( !strContainsChar(zPass, nPass, ch) ) goto unhex_null;
125934
+ c = *zHex;
125935
+ if( c==0x00 ) goto unhex_done;
125936
+ }
125937
+ zHex++;
125938
+ assert( *zEnd==0x00 );
125939
+ assert( zHex<=zEnd );
125940
+ d = *(zHex++);
125941
+ if( !sqlite3Isxdigit(d) ) goto unhex_null;
125942
+ *(p++) = (sqlite3HexToInt(c)<<4) | sqlite3HexToInt(d);
125943
+ }
125944
+ }
125945
+
125946
+ unhex_done:
125947
+ sqlite3_result_blob(pCtx, pBlob, (p - pBlob), sqlite3_free);
125948
+ return;
125949
+
125950
+ unhex_null:
125951
+ sqlite3_free(pBlob);
125952
+ return;
125953
+}
125954
+
125831125955
125832125956
/*
125833125957
** The zeroblob(N) function returns a zero-filled blob of size N bytes.
125834125958
*/
125835125959
static void zeroblobFunc(
@@ -126891,10 +127015,12 @@
126891127015
FUNCTION(round, 2, 0, 0, roundFunc ),
126892127016
#endif
126893127017
FUNCTION(upper, 1, 0, 0, upperFunc ),
126894127018
FUNCTION(lower, 1, 0, 0, lowerFunc ),
126895127019
FUNCTION(hex, 1, 0, 0, hexFunc ),
127020
+ FUNCTION(unhex, 1, 0, 0, unhexFunc ),
127021
+ FUNCTION(unhex, 2, 0, 0, unhexFunc ),
126896127022
INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
126897127023
VFUNCTION(random, 0, 0, 0, randomFunc ),
126898127024
VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
126899127025
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
126900127026
DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@@ -137240,11 +137366,16 @@
137240137366
encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;
137241137367
if( encoding==0 ) encoding = SQLITE_UTF8;
137242137368
#else
137243137369
encoding = SQLITE_UTF8;
137244137370
#endif
137245
- sqlite3SetTextEncoding(db, encoding);
137371
+ if( db->nVdbeActive>0 && encoding!=ENC(db) ){
137372
+ rc = SQLITE_LOCKED;
137373
+ goto initone_error_out;
137374
+ }else{
137375
+ sqlite3SetTextEncoding(db, encoding);
137376
+ }
137246137377
}else{
137247137378
/* If opening an attached database, the encoding much match ENC(db) */
137248137379
if( (meta[BTREE_TEXT_ENCODING-1] & 3)!=ENC(db) ){
137249137380
sqlite3SetString(pzErrMsg, db, "attached databases must use the same"
137250137381
" text encoding as main database");
@@ -150191,14 +150322,14 @@
150191150322
|| db->eOpenState==SQLITE_STATE_ZOMBIE );
150192150323
150193150324
pVTab->nRef--;
150194150325
if( pVTab->nRef==0 ){
150195150326
sqlite3_vtab *p = pVTab->pVtab;
150196
- sqlite3VtabModuleUnref(pVTab->db, pVTab->pMod);
150197150327
if( p ){
150198150328
p->pModule->xDisconnect(p);
150199150329
}
150330
+ sqlite3VtabModuleUnref(pVTab->db, pVTab->pMod);
150200150331
sqlite3DbFree(db, pVTab);
150201150332
}
150202150333
}
150203150334
150204150335
/*
@@ -160714,11 +160845,11 @@
160714160845
160715160846
#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
160716160847
&& !defined(SQLITE_OMIT_VIRTUALTABLE)
160717160848
/*
160718160849
** Cause the prepared statement that is associated with a call to
160719
-** xBestIndex to potentiall use all schemas. If the statement being
160850
+** xBestIndex to potentially use all schemas. If the statement being
160720160851
** prepared is read-only, then just start read transactions on all
160721160852
** schemas. But if this is a write operation, start writes on all
160722160853
** schemas.
160723160854
**
160724160855
** This is used by the (built-in) sqlite_dbpage virtual table.
@@ -160729,11 +160860,11 @@
160729160860
int nDb = pParse->db->nDb;
160730160861
int i;
160731160862
for(i=0; i<nDb; i++){
160732160863
sqlite3CodeVerifySchema(pParse, i);
160733160864
}
160734
- if( pParse->writeMask ){
160865
+ if( DbMaskNonZero(pParse->writeMask) ){
160735160866
for(i=0; i<nDb; i++){
160736160867
sqlite3BeginWriteOperation(pParse, 0, i);
160737160868
}
160738160869
}
160739160870
}
@@ -180122,10 +180253,12 @@
180122180253
SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int);
180123180254
SQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int);
180124180255
SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);
180125180256
#endif
180126180257
180258
+SQLITE_PRIVATE int sqlite3Fts3ExprIterate(Fts3Expr*, int (*x)(Fts3Expr*,int,void*), void*);
180259
+
180127180260
#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */
180128180261
#endif /* _FTSINT_H */
180129180262
180130180263
/************** End of fts3Int.h *********************************************/
180131180264
/************** Continuing where we left off in fts3.c ***********************/
@@ -185125,13 +185258,12 @@
185125185258
static void fts3EvalNextRow(
185126185259
Fts3Cursor *pCsr, /* FTS Cursor handle */
185127185260
Fts3Expr *pExpr, /* Expr. to advance to next matching row */
185128185261
int *pRc /* IN/OUT: Error code */
185129185262
){
185130
- if( *pRc==SQLITE_OK ){
185263
+ if( *pRc==SQLITE_OK && pExpr->bEof==0 ){
185131185264
int bDescDoclist = pCsr->bDesc; /* Used by DOCID_CMP() macro */
185132
- assert( pExpr->bEof==0 );
185133185265
pExpr->bStart = 1;
185134185266
185135185267
switch( pExpr->eType ){
185136185268
case FTSQUERY_NEAR:
185137185269
case FTSQUERY_AND: {
@@ -185602,10 +185734,26 @@
185602185734
185603185735
fts3EvalUpdateCounts(pExpr->pLeft, nCol);
185604185736
fts3EvalUpdateCounts(pExpr->pRight, nCol);
185605185737
}
185606185738
}
185739
+
185740
+/*
185741
+** This is an sqlite3Fts3ExprIterate() callback. If the Fts3Expr.aMI[] array
185742
+** has not yet been allocated, allocate and zero it. Otherwise, just zero
185743
+** it.
185744
+*/
185745
+static int fts3AllocateMSI(Fts3Expr *pExpr, int iPhrase, void *pCtx){
185746
+ Fts3Table *pTab = (Fts3Table*)pCtx;
185747
+ UNUSED_PARAMETER(iPhrase);
185748
+ if( pExpr->aMI==0 ){
185749
+ pExpr->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
185750
+ if( pExpr->aMI==0 ) return SQLITE_NOMEM;
185751
+ }
185752
+ memset(pExpr->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
185753
+ return SQLITE_OK;
185754
+}
185607185755
185608185756
/*
185609185757
** Expression pExpr must be of type FTSQUERY_PHRASE.
185610185758
**
185611185759
** If it is not already allocated and populated, this function allocates and
@@ -185624,34 +185772,29 @@
185624185772
185625185773
assert( pExpr->eType==FTSQUERY_PHRASE );
185626185774
if( pExpr->aMI==0 ){
185627185775
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
185628185776
Fts3Expr *pRoot; /* Root of NEAR expression */
185629
- Fts3Expr *p; /* Iterator used for several purposes */
185630185777
185631185778
sqlite3_int64 iPrevId = pCsr->iPrevId;
185632185779
sqlite3_int64 iDocid;
185633185780
u8 bEof;
185634185781
185635185782
/* Find the root of the NEAR expression */
185636185783
pRoot = pExpr;
185637
- while( pRoot->pParent && pRoot->pParent->eType==FTSQUERY_NEAR ){
185784
+ while( pRoot->pParent
185785
+ && (pRoot->pParent->eType==FTSQUERY_NEAR || pRoot->bDeferred)
185786
+ ){
185638185787
pRoot = pRoot->pParent;
185639185788
}
185640185789
iDocid = pRoot->iDocid;
185641185790
bEof = pRoot->bEof;
185642185791
assert( pRoot->bStart );
185643185792
185644185793
/* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */
185645
- for(p=pRoot; p; p=p->pLeft){
185646
- Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);
185647
- assert( pE->aMI==0 );
185648
- pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
185649
- if( !pE->aMI ) return SQLITE_NOMEM;
185650
- memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
185651
- }
185652
-
185794
+ rc = sqlite3Fts3ExprIterate(pRoot, fts3AllocateMSI, (void*)pTab);
185795
+ if( rc!=SQLITE_OK ) return rc;
185653185796
fts3EvalRestart(pCsr, pRoot, &rc);
185654185797
185655185798
while( pCsr->isEof==0 && rc==SQLITE_OK ){
185656185799
185657185800
do {
@@ -185803,10 +185946,11 @@
185803185946
int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
185804185947
int bOr = 0;
185805185948
u8 bTreeEof = 0;
185806185949
Fts3Expr *p; /* Used to iterate from pExpr to root */
185807185950
Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
185951
+ Fts3Expr *pRun; /* Closest non-deferred ancestor of pNear */
185808185952
int bMatch;
185809185953
185810185954
/* Check if this phrase descends from an OR expression node. If not,
185811185955
** return NULL. Otherwise, the entry that corresponds to docid
185812185956
** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
@@ -185817,29 +185961,34 @@
185817185961
if( p->eType==FTSQUERY_OR ) bOr = 1;
185818185962
if( p->eType==FTSQUERY_NEAR ) pNear = p;
185819185963
if( p->bEof ) bTreeEof = 1;
185820185964
}
185821185965
if( bOr==0 ) return SQLITE_OK;
185966
+ pRun = pNear;
185967
+ while( pRun->bDeferred ){
185968
+ assert( pRun->pParent );
185969
+ pRun = pRun->pParent;
185970
+ }
185822185971
185823185972
/* This is the descendent of an OR node. In this case we cannot use
185824185973
** an incremental phrase. Load the entire doclist for the phrase
185825185974
** into memory in this case. */
185826185975
if( pPhrase->bIncr ){
185827
- int bEofSave = pNear->bEof;
185828
- fts3EvalRestart(pCsr, pNear, &rc);
185829
- while( rc==SQLITE_OK && !pNear->bEof ){
185830
- fts3EvalNextRow(pCsr, pNear, &rc);
185831
- if( bEofSave==0 && pNear->iDocid==iDocid ) break;
185976
+ int bEofSave = pRun->bEof;
185977
+ fts3EvalRestart(pCsr, pRun, &rc);
185978
+ while( rc==SQLITE_OK && !pRun->bEof ){
185979
+ fts3EvalNextRow(pCsr, pRun, &rc);
185980
+ if( bEofSave==0 && pRun->iDocid==iDocid ) break;
185832185981
}
185833185982
assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
185834
- if( rc==SQLITE_OK && pNear->bEof!=bEofSave ){
185983
+ if( rc==SQLITE_OK && pRun->bEof!=bEofSave ){
185835185984
rc = FTS_CORRUPT_VTAB;
185836185985
}
185837185986
}
185838185987
if( bTreeEof ){
185839
- while( rc==SQLITE_OK && !pNear->bEof ){
185840
- fts3EvalNextRow(pCsr, pNear, &rc);
185988
+ while( rc==SQLITE_OK && !pRun->bEof ){
185989
+ fts3EvalNextRow(pCsr, pRun, &rc);
185841185990
}
185842185991
}
185843185992
if( rc!=SQLITE_OK ) return rc;
185844185993
185845185994
bMatch = 1;
@@ -195942,11 +196091,11 @@
195942196091
*/
195943196092
#define FTS3_MATCHINFO_DEFAULT "pcx"
195944196093
195945196094
195946196095
/*
195947
-** Used as an fts3ExprIterate() context when loading phrase doclists to
196096
+** Used as an sqlite3Fts3ExprIterate() context when loading phrase doclists to
195948196097
** Fts3Expr.aDoclist[]/nDoclist.
195949196098
*/
195950196099
typedef struct LoadDoclistCtx LoadDoclistCtx;
195951196100
struct LoadDoclistCtx {
195952196101
Fts3Cursor *pCsr; /* FTS3 Cursor */
@@ -195986,11 +196135,11 @@
195986196135
u64 covered; /* Mask of query phrases covered */
195987196136
u64 hlmask; /* Mask of snippet terms to highlight */
195988196137
};
195989196138
195990196139
/*
195991
-** This type is used as an fts3ExprIterate() context object while
196140
+** This type is used as an sqlite3Fts3ExprIterate() context object while
195992196141
** accumulating the data returned by the matchinfo() function.
195993196142
*/
195994196143
typedef struct MatchInfo MatchInfo;
195995196144
struct MatchInfo {
195996196145
Fts3Cursor *pCursor; /* FTS3 Cursor */
@@ -196145,11 +196294,11 @@
196145196294
*pp += fts3GetVarint32(*pp, &iVal);
196146196295
*piPos += (iVal-2);
196147196296
}
196148196297
196149196298
/*
196150
-** Helper function for fts3ExprIterate() (see below).
196299
+** Helper function for sqlite3Fts3ExprIterate() (see below).
196151196300
*/
196152196301
static int fts3ExprIterate2(
196153196302
Fts3Expr *pExpr, /* Expression to iterate phrases of */
196154196303
int *piPhrase, /* Pointer to phrase counter */
196155196304
int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
@@ -196179,23 +196328,22 @@
196179196328
** If the callback function returns anything other than SQLITE_OK,
196180196329
** the iteration is abandoned and the error code returned immediately.
196181196330
** Otherwise, SQLITE_OK is returned after a callback has been made for
196182196331
** all eligible phrase nodes.
196183196332
*/
196184
-static int fts3ExprIterate(
196333
+SQLITE_PRIVATE int sqlite3Fts3ExprIterate(
196185196334
Fts3Expr *pExpr, /* Expression to iterate phrases of */
196186196335
int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
196187196336
void *pCtx /* Second argument to pass to callback */
196188196337
){
196189196338
int iPhrase = 0; /* Variable used as the phrase counter */
196190196339
return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
196191196340
}
196192196341
196193
-
196194196342
/*
196195
-** This is an fts3ExprIterate() callback used while loading the doclists
196196
-** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also
196343
+** This is an sqlite3Fts3ExprIterate() callback used while loading the
196344
+** doclists for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also
196197196345
** fts3ExprLoadDoclists().
196198196346
*/
196199196347
static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
196200196348
int rc = SQLITE_OK;
196201196349
Fts3Phrase *pPhrase = pExpr->pPhrase;
@@ -196223,13 +196371,13 @@
196223196371
Fts3Cursor *pCsr, /* Fts3 cursor for current query */
196224196372
int *pnPhrase, /* OUT: Number of phrases in query */
196225196373
int *pnToken /* OUT: Number of tokens in query */
196226196374
){
196227196375
int rc; /* Return Code */
196228
- LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */
196376
+ LoadDoclistCtx sCtx = {0,0,0}; /* Context for sqlite3Fts3ExprIterate() */
196229196377
sCtx.pCsr = pCsr;
196230
- rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
196378
+ rc = sqlite3Fts3ExprIterate(pCsr->pExpr,fts3ExprLoadDoclistsCb,(void*)&sCtx);
196231196379
if( pnPhrase ) *pnPhrase = sCtx.nPhrase;
196232196380
if( pnToken ) *pnToken = sCtx.nToken;
196233196381
return rc;
196234196382
}
196235196383
@@ -196238,11 +196386,11 @@
196238196386
pExpr->iPhrase = iPhrase;
196239196387
return SQLITE_OK;
196240196388
}
196241196389
static int fts3ExprPhraseCount(Fts3Expr *pExpr){
196242196390
int nPhrase = 0;
196243
- (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
196391
+ (void)sqlite3Fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
196244196392
return nPhrase;
196245196393
}
196246196394
196247196395
/*
196248196396
** Advance the position list iterator specified by the first two
@@ -196366,12 +196514,13 @@
196366196514
*pmCover = mCover;
196367196515
*pmHighlight = mHighlight;
196368196516
}
196369196517
196370196518
/*
196371
-** This function is an fts3ExprIterate() callback used by fts3BestSnippet().
196372
-** Each invocation populates an element of the SnippetIter.aPhrase[] array.
196519
+** This function is an sqlite3Fts3ExprIterate() callback used by
196520
+** fts3BestSnippet(). Each invocation populates an element of the
196521
+** SnippetIter.aPhrase[] array.
196373196522
*/
196374196523
static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
196375196524
SnippetIter *p = (SnippetIter *)ctx;
196376196525
SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];
196377196526
char *pCsr;
@@ -196457,11 +196606,13 @@
196457196606
sIter.pCsr = pCsr;
196458196607
sIter.iCol = iCol;
196459196608
sIter.nSnippet = nSnippet;
196460196609
sIter.nPhrase = nList;
196461196610
sIter.iCurrent = -1;
196462
- rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);
196611
+ rc = sqlite3Fts3ExprIterate(
196612
+ pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter
196613
+ );
196463196614
if( rc==SQLITE_OK ){
196464196615
196465196616
/* Set the *pmSeen output variable. */
196466196617
for(i=0; i<nList; i++){
196467196618
if( sIter.aPhrase[i].pHead ){
@@ -196818,14 +196969,14 @@
196818196969
}
196819196970
return rc;
196820196971
}
196821196972
196822196973
/*
196823
-** fts3ExprIterate() callback used to collect the "global" matchinfo stats
196824
-** for a single query.
196974
+** sqlite3Fts3ExprIterate() callback used to collect the "global" matchinfo
196975
+** stats for a single query.
196825196976
**
196826
-** fts3ExprIterate() callback to load the 'global' elements of a
196977
+** sqlite3Fts3ExprIterate() callback to load the 'global' elements of a
196827196978
** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements
196828196979
** of the matchinfo array that are constant for all rows returned by the
196829196980
** current query.
196830196981
**
196831196982
** Argument pCtx is actually a pointer to a struct of type MatchInfo. This
@@ -196856,11 +197007,11 @@
196856197007
p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]
196857197008
);
196858197009
}
196859197010
196860197011
/*
196861
-** fts3ExprIterate() callback used to collect the "local" part of the
197012
+** sqlite3Fts3ExprIterate() callback used to collect the "local" part of the
196862197013
** FTS3_MATCHINFO_HITS array. The local stats are those elements of the
196863197014
** array that are different for each row returned by the query.
196864197015
*/
196865197016
static int fts3ExprLocalHitsCb(
196866197017
Fts3Expr *pExpr, /* Phrase expression node */
@@ -197052,11 +197203,11 @@
197052197203
/* Allocate and populate the array of LcsIterator objects. The array
197053197204
** contains one element for each matchable phrase in the query.
197054197205
**/
197055197206
aIter = sqlite3Fts3MallocZero(sizeof(LcsIterator) * pCsr->nPhrase);
197056197207
if( !aIter ) return SQLITE_NOMEM;
197057
- (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
197208
+ (void)sqlite3Fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
197058197209
197059197210
for(i=0; i<pInfo->nPhrase; i++){
197060197211
LcsIterator *pIter = &aIter[i];
197061197212
nToken -= pIter->pExpr->pPhrase->nToken;
197062197213
pIter->iPosOffset = nToken;
@@ -197229,15 +197380,15 @@
197229197380
if( bGlobal ){
197230197381
if( pCsr->pDeferred ){
197231197382
rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc,0,0);
197232197383
if( rc!=SQLITE_OK ) break;
197233197384
}
197234
- rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
197385
+ rc = sqlite3Fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
197235197386
sqlite3Fts3EvalTestDeferred(pCsr, &rc);
197236197387
if( rc!=SQLITE_OK ) break;
197237197388
}
197238
- (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
197389
+ (void)sqlite3Fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
197239197390
break;
197240197391
}
197241197392
}
197242197393
197243197394
pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);
@@ -197456,11 +197607,11 @@
197456197607
sqlite3_int64 iDocid;
197457197608
TermOffset *aTerm;
197458197609
};
197459197610
197460197611
/*
197461
-** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().
197612
+** This function is an sqlite3Fts3ExprIterate() callback used by sqlite3Fts3Offsets().
197462197613
*/
197463197614
static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
197464197615
TermOffsetCtx *p = (TermOffsetCtx *)ctx;
197465197616
int nTerm; /* Number of tokens in phrase */
197466197617
int iTerm; /* For looping through nTerm phrase terms */
@@ -197538,11 +197689,13 @@
197538197689
/* Initialize the contents of sCtx.aTerm[] for column iCol. This
197539197690
** operation may fail if the database contains corrupt records.
197540197691
*/
197541197692
sCtx.iCol = iCol;
197542197693
sCtx.iTerm = 0;
197543
- rc = fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);
197694
+ rc = sqlite3Fts3ExprIterate(
197695
+ pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx
197696
+ );
197544197697
if( rc!=SQLITE_OK ) goto offsets_out;
197545197698
197546197699
/* Retreive the text stored in column iCol. If an SQL NULL is stored
197547197700
** in column iCol, jump immediately to the next iteration of the loop.
197548197701
** If an OOM occurs while retrieving the data (this can happen if SQLite
@@ -200914,10 +201067,17 @@
200914201067
}else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
200915201068
aIdx[iCol] = i;
200916201069
idxMask |= iMask;
200917201070
}
200918201071
}
201072
+ if( pIdxInfo->nOrderBy>0
201073
+ && pIdxInfo->aOrderBy[0].iColumn<0
201074
+ && pIdxInfo->aOrderBy[0].desc==0
201075
+ ){
201076
+ pIdxInfo->orderByConsumed = 1;
201077
+ }
201078
+
200919201079
if( (unusableMask & ~idxMask)!=0 ){
200920201080
/* If there are any unusable constraints on JSON or ROOT, then reject
200921201081
** this entire plan */
200922201082
return SQLITE_CONSTRAINT;
200923201083
}
@@ -201109,14 +201269,14 @@
201109201269
JFUNCTION(json_parse, 1, 0, jsonParseFunc),
201110201270
JFUNCTION(json_test1, 1, 0, jsonTest1Func),
201111201271
#endif
201112201272
WAGGREGATE(json_group_array, 1, 0, 0,
201113201273
jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
201114
- SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS),
201274
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC),
201115201275
WAGGREGATE(json_group_object, 2, 0, 0,
201116201276
jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
201117
- SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS)
201277
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC)
201118201278
};
201119201279
sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
201120201280
#endif
201121201281
}
201122201282
@@ -208579,11 +208739,11 @@
208579208739
** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);
208580208740
**
208581208741
** The order of the columns in the data_% table does not matter.
208582208742
**
208583208743
** Instead of a regular table, the RBU database may also contain virtual
208584
-** tables or view named using the data_<target> naming scheme.
208744
+** tables or views named using the data_<target> naming scheme.
208585208745
**
208586208746
** Instead of the plain data_<target> naming scheme, RBU database tables
208587208747
** may also be named data<integer>_<target>, where <integer> is any sequence
208588208748
** of zero or more numeric characters (0-9). This can be significant because
208589208749
** tables within the RBU database are always processed in order sorted by
@@ -208592,11 +208752,11 @@
208592208752
** are processed. This can be useful, for example, to ensure that "external
208593208753
** content" FTS4 tables are updated before their underlying content tables.
208594208754
**
208595208755
** If the target database table is a virtual table or a table that has no
208596208756
** PRIMARY KEY declaration, the data_% table must also contain a column
208597
-** named "rbu_rowid". This column is mapped to the tables implicit primary
208757
+** named "rbu_rowid". This column is mapped to the table's implicit primary
208598208758
** key column - "rowid". Virtual tables for which the "rowid" column does
208599208759
** not function like a primary key value cannot be updated using RBU. For
208600208760
** example, if the target db contains either of the following:
208601208761
**
208602208762
** CREATE VIRTUAL TABLE x1 USING fts3(a, b);
@@ -239876,11 +240036,11 @@
239876240036
int nArg, /* Number of args */
239877240037
sqlite3_value **apUnused /* Function arguments */
239878240038
){
239879240039
assert( nArg==0 );
239880240040
UNUSED_PARAM2(nArg, apUnused);
239881
- sqlite3_result_text(pCtx, "fts5: 2023-01-16 18:13:00 83f21285fe86430a66ce6841606e3ad7c27da52ac75a034c6a00c7a9fdb9791d", -1, SQLITE_TRANSIENT);
240041
+ sqlite3_result_text(pCtx, "fts5: 2023-01-19 18:16:09 fa10e561f5dcdb23af862c2e486e877d379f12eae077ae5fd3da6028f1c20b49", -1, SQLITE_TRANSIENT);
239882240042
}
239883240043
239884240044
/*
239885240045
** Return true if zName is the extension on one of the shadow tables used
239886240046
** by this module.
@@ -239949,11 +240109,13 @@
239949240109
db, "fts5", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
239950240110
);
239951240111
}
239952240112
if( rc==SQLITE_OK ){
239953240113
rc = sqlite3_create_function(
239954
- db, "fts5_source_id", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0
240114
+ db, "fts5_source_id", 0,
240115
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
240116
+ p, fts5SourceIdFunc, 0, 0
239955240117
);
239956240118
}
239957240119
}
239958240120
239959240121
/* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file
239960240122
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.41.0"
456 #define SQLITE_VERSION_NUMBER 3041000
457 #define SQLITE_SOURCE_ID "2023-01-16 18:13:00 83f21285fe86430a66ce6841606e3ad7c27da52ac75a034c6a00c7a9fdb9791d"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -10110,18 +10110,17 @@
10110 ** [xFilter|xFilter() method] of a [virtual table] implementation.
10111 ** The result of invoking these interfaces from any other context
10112 ** is undefined and probably harmful.
10113 **
10114 ** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
10115 ** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
10116 ** xFilter method which invokes these routines, and specifically
10117 ** a parameter that was previously selected for all-at-once IN constraint
10118 ** processing use the [sqlite3_vtab_in()] interface in the
10119 ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
10120 ** an xFilter argument that was selected for all-at-once IN constraint
10121 ** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
10122 ** exhibit some other undefined or harmful behavior.
10123 **
10124 ** ^(Use these routines to access all values on the right-hand side
10125 ** of the IN constraint using code like the following:
10126 **
10127 ** <blockquote><pre>
@@ -23039,10 +23038,12 @@
23039 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
23040 SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
23041 SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
23042 SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
23043 SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
 
 
23044
23045 #ifdef SQLITE_DEBUG
23046 SQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe*, VdbeCursor*);
23047 SQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe*);
23048 #else
@@ -58359,11 +58360,11 @@
58359 if( rc==SQLITE_OK && zSuper[0] && res ){
58360 /* If there was a super-journal and this routine will return success,
58361 ** see if it is possible to delete the super-journal.
58362 */
58363 assert( zSuper==&pPager->pTmpSpace[4] );
58364 memset(&zSuper[-4], 0, 4);
58365 rc = pager_delsuper(pPager, zSuper);
58366 testcase( rc!=SQLITE_OK );
58367 }
58368 if( isHot && nPlayback ){
58369 sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, "recovered %d pages from %s",
@@ -88576,10 +88577,21 @@
88576 */
88577 SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){
88578 assert( p );
88579 return sqlite3_value_nochange(p->pOut);
88580 }
 
 
 
 
 
 
 
 
 
 
 
88581
88582 /*
88583 ** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
88584 ** sqlite3_vtab_in_next() (if bNext!=0).
88585 */
@@ -88591,12 +88603,19 @@
88591 int rc;
88592 ValueList *pRhs;
88593
88594 *ppOut = 0;
88595 if( pVal==0 ) return SQLITE_MISUSE;
88596 pRhs = (ValueList*)sqlite3_value_pointer(pVal, "ValueList");
88597 if( pRhs==0 ) return SQLITE_MISUSE;
 
 
 
 
 
 
 
88598 if( bNext ){
88599 rc = sqlite3BtreeNext(pRhs->pCsr, 0);
88600 }else{
88601 int dummy = 0;
88602 rc = sqlite3BtreeFirst(pRhs->pCsr, &dummy);
@@ -92358,11 +92377,11 @@
92358 affinity = pOp->p5 & SQLITE_AFF_MASK;
92359 if( affinity>=SQLITE_AFF_NUMERIC ){
92360 if( (flags1 | flags3)&MEM_Str ){
92361 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
92362 applyNumericAffinity(pIn1,0);
92363 testcase( flags3==pIn3->flags );
92364 flags3 = pIn3->flags;
92365 }
92366 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
92367 applyNumericAffinity(pIn3,0);
92368 }
@@ -98195,11 +98214,11 @@
98195 if( pRhs==0 ) goto no_mem;
98196 pRhs->pCsr = pC->uc.pCursor;
98197 pRhs->pOut = &aMem[pOp->p3];
98198 pOut = out2Prerelease(p, pOp);
98199 pOut->flags = MEM_Null;
98200 sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3_free);
98201 break;
98202 }
98203 #endif /* SQLITE_OMIT_VIRTUALTABLE */
98204
98205
@@ -116559,11 +116578,11 @@
116559 const char *zFile;
116560 char *zPath = 0;
116561 char *zErr = 0;
116562 unsigned int flags;
116563 Db *aNew; /* New array of Db pointers */
116564 Db *pNew; /* Db object for the newly attached database */
116565 char *zErrDyn = 0;
116566 sqlite3_vfs *pVfs;
116567
116568 UNUSED_PARAMETER(NotUsed);
116569 zFile = (const char *)sqlite3_value_text(argv[0]);
@@ -116579,17 +116598,30 @@
116579
116580 if( REOPEN_AS_MEMDB(db) ){
116581 /* This is not a real ATTACH. Instead, this routine is being called
116582 ** from sqlite3_deserialize() to close database db->init.iDb and
116583 ** reopen it as a MemDB */
 
116584 pVfs = sqlite3_vfs_find("memdb");
116585 if( pVfs==0 ) return;
116586 pNew = &db->aDb[db->init.iDb];
116587 if( pNew->pBt ) sqlite3BtreeClose(pNew->pBt);
116588 pNew->pBt = 0;
116589 pNew->pSchema = 0;
116590 rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNew->pBt, 0, SQLITE_OPEN_MAIN_DB);
 
 
 
 
 
 
 
 
 
 
 
 
116591 }else{
116592 /* This is a real ATTACH
116593 **
116594 ** Check for the following errors:
116595 **
@@ -116698,11 +116730,11 @@
116698 rc = SQLITE_AUTH_USER;
116699 }
116700 }
116701 #endif
116702 if( rc ){
116703 if( !REOPEN_AS_MEMDB(db) ){
116704 int iDb = db->nDb - 1;
116705 assert( iDb>=2 );
116706 if( db->aDb[iDb].pBt ){
116707 sqlite3BtreeClose(db->aDb[iDb].pBt);
116708 db->aDb[iDb].pBt = 0;
@@ -116814,10 +116846,12 @@
116814 int rc;
116815 NameContext sName;
116816 Vdbe *v;
116817 sqlite3* db = pParse->db;
116818 int regArgs;
 
 
116819
116820 if( pParse->nErr ) goto attach_end;
116821 memset(&sName, 0, sizeof(NameContext));
116822 sName.pParse = pParse;
116823
@@ -125826,10 +125860,100 @@
125826 }
125827 *z = 0;
125828 sqlite3_result_text(context, zHex, n*2, sqlite3_free);
125829 }
125830 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125831
125832 /*
125833 ** The zeroblob(N) function returns a zero-filled blob of size N bytes.
125834 */
125835 static void zeroblobFunc(
@@ -126891,10 +127015,12 @@
126891 FUNCTION(round, 2, 0, 0, roundFunc ),
126892 #endif
126893 FUNCTION(upper, 1, 0, 0, upperFunc ),
126894 FUNCTION(lower, 1, 0, 0, lowerFunc ),
126895 FUNCTION(hex, 1, 0, 0, hexFunc ),
 
 
126896 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
126897 VFUNCTION(random, 0, 0, 0, randomFunc ),
126898 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
126899 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
126900 DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@@ -137240,11 +137366,16 @@
137240 encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;
137241 if( encoding==0 ) encoding = SQLITE_UTF8;
137242 #else
137243 encoding = SQLITE_UTF8;
137244 #endif
137245 sqlite3SetTextEncoding(db, encoding);
 
 
 
 
 
137246 }else{
137247 /* If opening an attached database, the encoding much match ENC(db) */
137248 if( (meta[BTREE_TEXT_ENCODING-1] & 3)!=ENC(db) ){
137249 sqlite3SetString(pzErrMsg, db, "attached databases must use the same"
137250 " text encoding as main database");
@@ -150191,14 +150322,14 @@
150191 || db->eOpenState==SQLITE_STATE_ZOMBIE );
150192
150193 pVTab->nRef--;
150194 if( pVTab->nRef==0 ){
150195 sqlite3_vtab *p = pVTab->pVtab;
150196 sqlite3VtabModuleUnref(pVTab->db, pVTab->pMod);
150197 if( p ){
150198 p->pModule->xDisconnect(p);
150199 }
 
150200 sqlite3DbFree(db, pVTab);
150201 }
150202 }
150203
150204 /*
@@ -160714,11 +160845,11 @@
160714
160715 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
160716 && !defined(SQLITE_OMIT_VIRTUALTABLE)
160717 /*
160718 ** Cause the prepared statement that is associated with a call to
160719 ** xBestIndex to potentiall use all schemas. If the statement being
160720 ** prepared is read-only, then just start read transactions on all
160721 ** schemas. But if this is a write operation, start writes on all
160722 ** schemas.
160723 **
160724 ** This is used by the (built-in) sqlite_dbpage virtual table.
@@ -160729,11 +160860,11 @@
160729 int nDb = pParse->db->nDb;
160730 int i;
160731 for(i=0; i<nDb; i++){
160732 sqlite3CodeVerifySchema(pParse, i);
160733 }
160734 if( pParse->writeMask ){
160735 for(i=0; i<nDb; i++){
160736 sqlite3BeginWriteOperation(pParse, 0, i);
160737 }
160738 }
160739 }
@@ -180122,10 +180253,12 @@
180122 SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int);
180123 SQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int);
180124 SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);
180125 #endif
180126
 
 
180127 #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */
180128 #endif /* _FTSINT_H */
180129
180130 /************** End of fts3Int.h *********************************************/
180131 /************** Continuing where we left off in fts3.c ***********************/
@@ -185125,13 +185258,12 @@
185125 static void fts3EvalNextRow(
185126 Fts3Cursor *pCsr, /* FTS Cursor handle */
185127 Fts3Expr *pExpr, /* Expr. to advance to next matching row */
185128 int *pRc /* IN/OUT: Error code */
185129 ){
185130 if( *pRc==SQLITE_OK ){
185131 int bDescDoclist = pCsr->bDesc; /* Used by DOCID_CMP() macro */
185132 assert( pExpr->bEof==0 );
185133 pExpr->bStart = 1;
185134
185135 switch( pExpr->eType ){
185136 case FTSQUERY_NEAR:
185137 case FTSQUERY_AND: {
@@ -185602,10 +185734,26 @@
185602
185603 fts3EvalUpdateCounts(pExpr->pLeft, nCol);
185604 fts3EvalUpdateCounts(pExpr->pRight, nCol);
185605 }
185606 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185607
185608 /*
185609 ** Expression pExpr must be of type FTSQUERY_PHRASE.
185610 **
185611 ** If it is not already allocated and populated, this function allocates and
@@ -185624,34 +185772,29 @@
185624
185625 assert( pExpr->eType==FTSQUERY_PHRASE );
185626 if( pExpr->aMI==0 ){
185627 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
185628 Fts3Expr *pRoot; /* Root of NEAR expression */
185629 Fts3Expr *p; /* Iterator used for several purposes */
185630
185631 sqlite3_int64 iPrevId = pCsr->iPrevId;
185632 sqlite3_int64 iDocid;
185633 u8 bEof;
185634
185635 /* Find the root of the NEAR expression */
185636 pRoot = pExpr;
185637 while( pRoot->pParent && pRoot->pParent->eType==FTSQUERY_NEAR ){
 
 
185638 pRoot = pRoot->pParent;
185639 }
185640 iDocid = pRoot->iDocid;
185641 bEof = pRoot->bEof;
185642 assert( pRoot->bStart );
185643
185644 /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */
185645 for(p=pRoot; p; p=p->pLeft){
185646 Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);
185647 assert( pE->aMI==0 );
185648 pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
185649 if( !pE->aMI ) return SQLITE_NOMEM;
185650 memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
185651 }
185652
185653 fts3EvalRestart(pCsr, pRoot, &rc);
185654
185655 while( pCsr->isEof==0 && rc==SQLITE_OK ){
185656
185657 do {
@@ -185803,10 +185946,11 @@
185803 int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
185804 int bOr = 0;
185805 u8 bTreeEof = 0;
185806 Fts3Expr *p; /* Used to iterate from pExpr to root */
185807 Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
 
185808 int bMatch;
185809
185810 /* Check if this phrase descends from an OR expression node. If not,
185811 ** return NULL. Otherwise, the entry that corresponds to docid
185812 ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
@@ -185817,29 +185961,34 @@
185817 if( p->eType==FTSQUERY_OR ) bOr = 1;
185818 if( p->eType==FTSQUERY_NEAR ) pNear = p;
185819 if( p->bEof ) bTreeEof = 1;
185820 }
185821 if( bOr==0 ) return SQLITE_OK;
 
 
 
 
 
185822
185823 /* This is the descendent of an OR node. In this case we cannot use
185824 ** an incremental phrase. Load the entire doclist for the phrase
185825 ** into memory in this case. */
185826 if( pPhrase->bIncr ){
185827 int bEofSave = pNear->bEof;
185828 fts3EvalRestart(pCsr, pNear, &rc);
185829 while( rc==SQLITE_OK && !pNear->bEof ){
185830 fts3EvalNextRow(pCsr, pNear, &rc);
185831 if( bEofSave==0 && pNear->iDocid==iDocid ) break;
185832 }
185833 assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
185834 if( rc==SQLITE_OK && pNear->bEof!=bEofSave ){
185835 rc = FTS_CORRUPT_VTAB;
185836 }
185837 }
185838 if( bTreeEof ){
185839 while( rc==SQLITE_OK && !pNear->bEof ){
185840 fts3EvalNextRow(pCsr, pNear, &rc);
185841 }
185842 }
185843 if( rc!=SQLITE_OK ) return rc;
185844
185845 bMatch = 1;
@@ -195942,11 +196091,11 @@
195942 */
195943 #define FTS3_MATCHINFO_DEFAULT "pcx"
195944
195945
195946 /*
195947 ** Used as an fts3ExprIterate() context when loading phrase doclists to
195948 ** Fts3Expr.aDoclist[]/nDoclist.
195949 */
195950 typedef struct LoadDoclistCtx LoadDoclistCtx;
195951 struct LoadDoclistCtx {
195952 Fts3Cursor *pCsr; /* FTS3 Cursor */
@@ -195986,11 +196135,11 @@
195986 u64 covered; /* Mask of query phrases covered */
195987 u64 hlmask; /* Mask of snippet terms to highlight */
195988 };
195989
195990 /*
195991 ** This type is used as an fts3ExprIterate() context object while
195992 ** accumulating the data returned by the matchinfo() function.
195993 */
195994 typedef struct MatchInfo MatchInfo;
195995 struct MatchInfo {
195996 Fts3Cursor *pCursor; /* FTS3 Cursor */
@@ -196145,11 +196294,11 @@
196145 *pp += fts3GetVarint32(*pp, &iVal);
196146 *piPos += (iVal-2);
196147 }
196148
196149 /*
196150 ** Helper function for fts3ExprIterate() (see below).
196151 */
196152 static int fts3ExprIterate2(
196153 Fts3Expr *pExpr, /* Expression to iterate phrases of */
196154 int *piPhrase, /* Pointer to phrase counter */
196155 int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
@@ -196179,23 +196328,22 @@
196179 ** If the callback function returns anything other than SQLITE_OK,
196180 ** the iteration is abandoned and the error code returned immediately.
196181 ** Otherwise, SQLITE_OK is returned after a callback has been made for
196182 ** all eligible phrase nodes.
196183 */
196184 static int fts3ExprIterate(
196185 Fts3Expr *pExpr, /* Expression to iterate phrases of */
196186 int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
196187 void *pCtx /* Second argument to pass to callback */
196188 ){
196189 int iPhrase = 0; /* Variable used as the phrase counter */
196190 return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
196191 }
196192
196193
196194 /*
196195 ** This is an fts3ExprIterate() callback used while loading the doclists
196196 ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also
196197 ** fts3ExprLoadDoclists().
196198 */
196199 static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
196200 int rc = SQLITE_OK;
196201 Fts3Phrase *pPhrase = pExpr->pPhrase;
@@ -196223,13 +196371,13 @@
196223 Fts3Cursor *pCsr, /* Fts3 cursor for current query */
196224 int *pnPhrase, /* OUT: Number of phrases in query */
196225 int *pnToken /* OUT: Number of tokens in query */
196226 ){
196227 int rc; /* Return Code */
196228 LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */
196229 sCtx.pCsr = pCsr;
196230 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
196231 if( pnPhrase ) *pnPhrase = sCtx.nPhrase;
196232 if( pnToken ) *pnToken = sCtx.nToken;
196233 return rc;
196234 }
196235
@@ -196238,11 +196386,11 @@
196238 pExpr->iPhrase = iPhrase;
196239 return SQLITE_OK;
196240 }
196241 static int fts3ExprPhraseCount(Fts3Expr *pExpr){
196242 int nPhrase = 0;
196243 (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
196244 return nPhrase;
196245 }
196246
196247 /*
196248 ** Advance the position list iterator specified by the first two
@@ -196366,12 +196514,13 @@
196366 *pmCover = mCover;
196367 *pmHighlight = mHighlight;
196368 }
196369
196370 /*
196371 ** This function is an fts3ExprIterate() callback used by fts3BestSnippet().
196372 ** Each invocation populates an element of the SnippetIter.aPhrase[] array.
 
196373 */
196374 static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
196375 SnippetIter *p = (SnippetIter *)ctx;
196376 SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];
196377 char *pCsr;
@@ -196457,11 +196606,13 @@
196457 sIter.pCsr = pCsr;
196458 sIter.iCol = iCol;
196459 sIter.nSnippet = nSnippet;
196460 sIter.nPhrase = nList;
196461 sIter.iCurrent = -1;
196462 rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);
 
 
196463 if( rc==SQLITE_OK ){
196464
196465 /* Set the *pmSeen output variable. */
196466 for(i=0; i<nList; i++){
196467 if( sIter.aPhrase[i].pHead ){
@@ -196818,14 +196969,14 @@
196818 }
196819 return rc;
196820 }
196821
196822 /*
196823 ** fts3ExprIterate() callback used to collect the "global" matchinfo stats
196824 ** for a single query.
196825 **
196826 ** fts3ExprIterate() callback to load the 'global' elements of a
196827 ** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements
196828 ** of the matchinfo array that are constant for all rows returned by the
196829 ** current query.
196830 **
196831 ** Argument pCtx is actually a pointer to a struct of type MatchInfo. This
@@ -196856,11 +197007,11 @@
196856 p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]
196857 );
196858 }
196859
196860 /*
196861 ** fts3ExprIterate() callback used to collect the "local" part of the
196862 ** FTS3_MATCHINFO_HITS array. The local stats are those elements of the
196863 ** array that are different for each row returned by the query.
196864 */
196865 static int fts3ExprLocalHitsCb(
196866 Fts3Expr *pExpr, /* Phrase expression node */
@@ -197052,11 +197203,11 @@
197052 /* Allocate and populate the array of LcsIterator objects. The array
197053 ** contains one element for each matchable phrase in the query.
197054 **/
197055 aIter = sqlite3Fts3MallocZero(sizeof(LcsIterator) * pCsr->nPhrase);
197056 if( !aIter ) return SQLITE_NOMEM;
197057 (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
197058
197059 for(i=0; i<pInfo->nPhrase; i++){
197060 LcsIterator *pIter = &aIter[i];
197061 nToken -= pIter->pExpr->pPhrase->nToken;
197062 pIter->iPosOffset = nToken;
@@ -197229,15 +197380,15 @@
197229 if( bGlobal ){
197230 if( pCsr->pDeferred ){
197231 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc,0,0);
197232 if( rc!=SQLITE_OK ) break;
197233 }
197234 rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
197235 sqlite3Fts3EvalTestDeferred(pCsr, &rc);
197236 if( rc!=SQLITE_OK ) break;
197237 }
197238 (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
197239 break;
197240 }
197241 }
197242
197243 pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);
@@ -197456,11 +197607,11 @@
197456 sqlite3_int64 iDocid;
197457 TermOffset *aTerm;
197458 };
197459
197460 /*
197461 ** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().
197462 */
197463 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
197464 TermOffsetCtx *p = (TermOffsetCtx *)ctx;
197465 int nTerm; /* Number of tokens in phrase */
197466 int iTerm; /* For looping through nTerm phrase terms */
@@ -197538,11 +197689,13 @@
197538 /* Initialize the contents of sCtx.aTerm[] for column iCol. This
197539 ** operation may fail if the database contains corrupt records.
197540 */
197541 sCtx.iCol = iCol;
197542 sCtx.iTerm = 0;
197543 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);
 
 
197544 if( rc!=SQLITE_OK ) goto offsets_out;
197545
197546 /* Retreive the text stored in column iCol. If an SQL NULL is stored
197547 ** in column iCol, jump immediately to the next iteration of the loop.
197548 ** If an OOM occurs while retrieving the data (this can happen if SQLite
@@ -200914,10 +201067,17 @@
200914 }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
200915 aIdx[iCol] = i;
200916 idxMask |= iMask;
200917 }
200918 }
 
 
 
 
 
 
 
200919 if( (unusableMask & ~idxMask)!=0 ){
200920 /* If there are any unusable constraints on JSON or ROOT, then reject
200921 ** this entire plan */
200922 return SQLITE_CONSTRAINT;
200923 }
@@ -201109,14 +201269,14 @@
201109 JFUNCTION(json_parse, 1, 0, jsonParseFunc),
201110 JFUNCTION(json_test1, 1, 0, jsonTest1Func),
201111 #endif
201112 WAGGREGATE(json_group_array, 1, 0, 0,
201113 jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
201114 SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS),
201115 WAGGREGATE(json_group_object, 2, 0, 0,
201116 jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
201117 SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS)
201118 };
201119 sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
201120 #endif
201121 }
201122
@@ -208579,11 +208739,11 @@
208579 ** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);
208580 **
208581 ** The order of the columns in the data_% table does not matter.
208582 **
208583 ** Instead of a regular table, the RBU database may also contain virtual
208584 ** tables or view named using the data_<target> naming scheme.
208585 **
208586 ** Instead of the plain data_<target> naming scheme, RBU database tables
208587 ** may also be named data<integer>_<target>, where <integer> is any sequence
208588 ** of zero or more numeric characters (0-9). This can be significant because
208589 ** tables within the RBU database are always processed in order sorted by
@@ -208592,11 +208752,11 @@
208592 ** are processed. This can be useful, for example, to ensure that "external
208593 ** content" FTS4 tables are updated before their underlying content tables.
208594 **
208595 ** If the target database table is a virtual table or a table that has no
208596 ** PRIMARY KEY declaration, the data_% table must also contain a column
208597 ** named "rbu_rowid". This column is mapped to the tables implicit primary
208598 ** key column - "rowid". Virtual tables for which the "rowid" column does
208599 ** not function like a primary key value cannot be updated using RBU. For
208600 ** example, if the target db contains either of the following:
208601 **
208602 ** CREATE VIRTUAL TABLE x1 USING fts3(a, b);
@@ -239876,11 +240036,11 @@
239876 int nArg, /* Number of args */
239877 sqlite3_value **apUnused /* Function arguments */
239878 ){
239879 assert( nArg==0 );
239880 UNUSED_PARAM2(nArg, apUnused);
239881 sqlite3_result_text(pCtx, "fts5: 2023-01-16 18:13:00 83f21285fe86430a66ce6841606e3ad7c27da52ac75a034c6a00c7a9fdb9791d", -1, SQLITE_TRANSIENT);
239882 }
239883
239884 /*
239885 ** Return true if zName is the extension on one of the shadow tables used
239886 ** by this module.
@@ -239949,11 +240109,13 @@
239949 db, "fts5", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
239950 );
239951 }
239952 if( rc==SQLITE_OK ){
239953 rc = sqlite3_create_function(
239954 db, "fts5_source_id", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0
 
 
239955 );
239956 }
239957 }
239958
239959 /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file
239960
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.41.0"
456 #define SQLITE_VERSION_NUMBER 3041000
457 #define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -10110,18 +10110,17 @@
10110 ** [xFilter|xFilter() method] of a [virtual table] implementation.
10111 ** The result of invoking these interfaces from any other context
10112 ** is undefined and probably harmful.
10113 **
10114 ** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
10115 ** sqlite3_vtab_in_next(X,P) should be one of the parameters to the
10116 ** xFilter method which invokes these routines, and specifically
10117 ** a parameter that was previously selected for all-at-once IN constraint
10118 ** processing use the [sqlite3_vtab_in()] interface in the
10119 ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
10120 ** an xFilter argument that was selected for all-at-once IN constraint
10121 ** processing, then these routines return [SQLITE_ERROR].)^
 
10122 **
10123 ** ^(Use these routines to access all values on the right-hand side
10124 ** of the IN constraint using code like the following:
10125 **
10126 ** <blockquote><pre>
@@ -23039,10 +23038,12 @@
23038 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
23039 SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
23040 SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
23041 SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
23042 SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
23043
23044 SQLITE_PRIVATE void sqlite3VdbeValueListFree(void*);
23045
23046 #ifdef SQLITE_DEBUG
23047 SQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe*, VdbeCursor*);
23048 SQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe*);
23049 #else
@@ -58359,11 +58360,11 @@
58360 if( rc==SQLITE_OK && zSuper[0] && res ){
58361 /* If there was a super-journal and this routine will return success,
58362 ** see if it is possible to delete the super-journal.
58363 */
58364 assert( zSuper==&pPager->pTmpSpace[4] );
58365 memset(pPager->pTmpSpace, 0, 4);
58366 rc = pager_delsuper(pPager, zSuper);
58367 testcase( rc!=SQLITE_OK );
58368 }
58369 if( isHot && nPlayback ){
58370 sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, "recovered %d pages from %s",
@@ -88576,10 +88577,21 @@
88577 */
88578 SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){
88579 assert( p );
88580 return sqlite3_value_nochange(p->pOut);
88581 }
88582
88583 /*
88584 ** The destructor function for a ValueList object. This needs to be
88585 ** a separate function, unknowable to the application, to ensure that
88586 ** calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not
88587 ** preceeded by activation of IN processing via sqlite3_vtab_int() do not
88588 ** try to access a fake ValueList object inserted by a hostile extension.
88589 */
88590 SQLITE_PRIVATE void sqlite3VdbeValueListFree(void *pToDelete){
88591 sqlite3_free(pToDelete);
88592 }
88593
88594 /*
88595 ** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
88596 ** sqlite3_vtab_in_next() (if bNext!=0).
88597 */
@@ -88591,12 +88603,19 @@
88603 int rc;
88604 ValueList *pRhs;
88605
88606 *ppOut = 0;
88607 if( pVal==0 ) return SQLITE_MISUSE;
88608 if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){
88609 return SQLITE_ERROR;
88610 }else{
88611 assert( (pVal->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) ==
88612 (MEM_Null|MEM_Term|MEM_Subtype) );
88613 assert( pVal->eSubtype=='p' );
88614 assert( pVal->u.zPType!=0 && strcmp(pVal->u.zPType,"ValueList")==0 );
88615 pRhs = (ValueList*)pVal->z;
88616 }
88617 if( bNext ){
88618 rc = sqlite3BtreeNext(pRhs->pCsr, 0);
88619 }else{
88620 int dummy = 0;
88621 rc = sqlite3BtreeFirst(pRhs->pCsr, &dummy);
@@ -92358,11 +92377,11 @@
92377 affinity = pOp->p5 & SQLITE_AFF_MASK;
92378 if( affinity>=SQLITE_AFF_NUMERIC ){
92379 if( (flags1 | flags3)&MEM_Str ){
92380 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
92381 applyNumericAffinity(pIn1,0);
92382 assert( flags3==pIn3->flags || CORRUPT_DB );
92383 flags3 = pIn3->flags;
92384 }
92385 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
92386 applyNumericAffinity(pIn3,0);
92387 }
@@ -98195,11 +98214,11 @@
98214 if( pRhs==0 ) goto no_mem;
98215 pRhs->pCsr = pC->uc.pCursor;
98216 pRhs->pOut = &aMem[pOp->p3];
98217 pOut = out2Prerelease(p, pOp);
98218 pOut->flags = MEM_Null;
98219 sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3VdbeValueListFree);
98220 break;
98221 }
98222 #endif /* SQLITE_OMIT_VIRTUALTABLE */
98223
98224
@@ -116559,11 +116578,11 @@
116578 const char *zFile;
116579 char *zPath = 0;
116580 char *zErr = 0;
116581 unsigned int flags;
116582 Db *aNew; /* New array of Db pointers */
116583 Db *pNew = 0; /* Db object for the newly attached database */
116584 char *zErrDyn = 0;
116585 sqlite3_vfs *pVfs;
116586
116587 UNUSED_PARAMETER(NotUsed);
116588 zFile = (const char *)sqlite3_value_text(argv[0]);
@@ -116579,17 +116598,30 @@
116598
116599 if( REOPEN_AS_MEMDB(db) ){
116600 /* This is not a real ATTACH. Instead, this routine is being called
116601 ** from sqlite3_deserialize() to close database db->init.iDb and
116602 ** reopen it as a MemDB */
116603 Btree *pNewBt = 0;
116604 pVfs = sqlite3_vfs_find("memdb");
116605 if( pVfs==0 ) return;
116606 rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNewBt, 0, SQLITE_OPEN_MAIN_DB);
116607 if( rc==SQLITE_OK ){
116608 Schema *pNewSchema = sqlite3SchemaGet(db, pNewBt);
116609 if( pNewSchema ){
116610 /* Both the Btree and the new Schema were allocated successfully.
116611 ** Close the old db and update the aDb[] slot with the new memdb
116612 ** values. */
116613 pNew = &db->aDb[db->init.iDb];
116614 if( ALWAYS(pNew->pBt) ) sqlite3BtreeClose(pNew->pBt);
116615 pNew->pBt = pNewBt;
116616 pNew->pSchema = pNewSchema;
116617 }else{
116618 sqlite3BtreeClose(pNewBt);
116619 rc = SQLITE_NOMEM;
116620 }
116621 }
116622 if( rc ) goto attach_error;
116623 }else{
116624 /* This is a real ATTACH
116625 **
116626 ** Check for the following errors:
116627 **
@@ -116698,11 +116730,11 @@
116730 rc = SQLITE_AUTH_USER;
116731 }
116732 }
116733 #endif
116734 if( rc ){
116735 if( ALWAYS(!REOPEN_AS_MEMDB(db)) ){
116736 int iDb = db->nDb - 1;
116737 assert( iDb>=2 );
116738 if( db->aDb[iDb].pBt ){
116739 sqlite3BtreeClose(db->aDb[iDb].pBt);
116740 db->aDb[iDb].pBt = 0;
@@ -116814,10 +116846,12 @@
116846 int rc;
116847 NameContext sName;
116848 Vdbe *v;
116849 sqlite3* db = pParse->db;
116850 int regArgs;
116851
116852 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ) goto attach_end;
116853
116854 if( pParse->nErr ) goto attach_end;
116855 memset(&sName, 0, sizeof(NameContext));
116856 sName.pParse = pParse;
116857
@@ -125826,10 +125860,100 @@
125860 }
125861 *z = 0;
125862 sqlite3_result_text(context, zHex, n*2, sqlite3_free);
125863 }
125864 }
125865
125866 /*
125867 ** Buffer zStr contains nStr bytes of utf-8 encoded text. Return 1 if zStr
125868 ** contains character ch, or 0 if it does not.
125869 */
125870 static int strContainsChar(const u8 *zStr, int nStr, u32 ch){
125871 const u8 *zEnd = &zStr[nStr];
125872 const u8 *z = zStr;
125873 while( z<zEnd ){
125874 u32 tst = Utf8Read(z);
125875 if( tst==ch ) return 1;
125876 }
125877 return 0;
125878 }
125879
125880 /*
125881 ** The unhex() function. This function may be invoked with either one or
125882 ** two arguments. In both cases the first argument is interpreted as text
125883 ** a text value containing a set of pairs of hexadecimal digits which are
125884 ** decoded and returned as a blob.
125885 **
125886 ** If there is only a single argument, then it must consist only of an
125887 ** even number of hexadeximal digits. Otherwise, return NULL.
125888 **
125889 ** Or, if there is a second argument, then any character that appears in
125890 ** the second argument is also allowed to appear between pairs of hexadecimal
125891 ** digits in the first argument. If any other character appears in the
125892 ** first argument, or if one of the allowed characters appears between
125893 ** two hexadecimal digits that make up a single byte, NULL is returned.
125894 **
125895 ** The following expressions are all true:
125896 **
125897 ** unhex('ABCD') IS x'ABCD'
125898 ** unhex('AB CD') IS NULL
125899 ** unhex('AB CD', ' ') IS x'ABCD'
125900 ** unhex('A BCD', ' ') IS NULL
125901 */
125902 static void unhexFunc(
125903 sqlite3_context *pCtx,
125904 int argc,
125905 sqlite3_value **argv
125906 ){
125907 const u8 *zPass = (const u8*)"";
125908 int nPass = 0;
125909 const u8 *zHex = sqlite3_value_text(argv[0]);
125910 int nHex = sqlite3_value_bytes(argv[0]);
125911 #ifdef SQLITE_DEBUG
125912 const u8 *zEnd = &zHex[nHex];
125913 #endif
125914 u8 *pBlob = 0;
125915 u8 *p = 0;
125916
125917 assert( argc==1 || argc==2 );
125918 if( argc==2 ){
125919 zPass = sqlite3_value_text(argv[1]);
125920 nPass = sqlite3_value_bytes(argv[1]);
125921 }
125922 if( !zHex || !zPass ) return;
125923
125924 p = pBlob = contextMalloc(pCtx, (nHex/2)+1);
125925 if( pBlob ){
125926 u8 c; /* Most significant digit of next byte */
125927 u8 d; /* Least significant digit of next byte */
125928
125929 while( (c = *zHex)!=0x00 ){
125930 while( !sqlite3Isxdigit(c) ){
125931 u32 ch = Utf8Read(zHex);
125932 assert( zHex<=zEnd );
125933 if( !strContainsChar(zPass, nPass, ch) ) goto unhex_null;
125934 c = *zHex;
125935 if( c==0x00 ) goto unhex_done;
125936 }
125937 zHex++;
125938 assert( *zEnd==0x00 );
125939 assert( zHex<=zEnd );
125940 d = *(zHex++);
125941 if( !sqlite3Isxdigit(d) ) goto unhex_null;
125942 *(p++) = (sqlite3HexToInt(c)<<4) | sqlite3HexToInt(d);
125943 }
125944 }
125945
125946 unhex_done:
125947 sqlite3_result_blob(pCtx, pBlob, (p - pBlob), sqlite3_free);
125948 return;
125949
125950 unhex_null:
125951 sqlite3_free(pBlob);
125952 return;
125953 }
125954
125955
125956 /*
125957 ** The zeroblob(N) function returns a zero-filled blob of size N bytes.
125958 */
125959 static void zeroblobFunc(
@@ -126891,10 +127015,12 @@
127015 FUNCTION(round, 2, 0, 0, roundFunc ),
127016 #endif
127017 FUNCTION(upper, 1, 0, 0, upperFunc ),
127018 FUNCTION(lower, 1, 0, 0, lowerFunc ),
127019 FUNCTION(hex, 1, 0, 0, hexFunc ),
127020 FUNCTION(unhex, 1, 0, 0, unhexFunc ),
127021 FUNCTION(unhex, 2, 0, 0, unhexFunc ),
127022 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
127023 VFUNCTION(random, 0, 0, 0, randomFunc ),
127024 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
127025 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
127026 DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@@ -137240,11 +137366,16 @@
137366 encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;
137367 if( encoding==0 ) encoding = SQLITE_UTF8;
137368 #else
137369 encoding = SQLITE_UTF8;
137370 #endif
137371 if( db->nVdbeActive>0 && encoding!=ENC(db) ){
137372 rc = SQLITE_LOCKED;
137373 goto initone_error_out;
137374 }else{
137375 sqlite3SetTextEncoding(db, encoding);
137376 }
137377 }else{
137378 /* If opening an attached database, the encoding much match ENC(db) */
137379 if( (meta[BTREE_TEXT_ENCODING-1] & 3)!=ENC(db) ){
137380 sqlite3SetString(pzErrMsg, db, "attached databases must use the same"
137381 " text encoding as main database");
@@ -150191,14 +150322,14 @@
150322 || db->eOpenState==SQLITE_STATE_ZOMBIE );
150323
150324 pVTab->nRef--;
150325 if( pVTab->nRef==0 ){
150326 sqlite3_vtab *p = pVTab->pVtab;
 
150327 if( p ){
150328 p->pModule->xDisconnect(p);
150329 }
150330 sqlite3VtabModuleUnref(pVTab->db, pVTab->pMod);
150331 sqlite3DbFree(db, pVTab);
150332 }
150333 }
150334
150335 /*
@@ -160714,11 +160845,11 @@
160845
160846 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
160847 && !defined(SQLITE_OMIT_VIRTUALTABLE)
160848 /*
160849 ** Cause the prepared statement that is associated with a call to
160850 ** xBestIndex to potentially use all schemas. If the statement being
160851 ** prepared is read-only, then just start read transactions on all
160852 ** schemas. But if this is a write operation, start writes on all
160853 ** schemas.
160854 **
160855 ** This is used by the (built-in) sqlite_dbpage virtual table.
@@ -160729,11 +160860,11 @@
160860 int nDb = pParse->db->nDb;
160861 int i;
160862 for(i=0; i<nDb; i++){
160863 sqlite3CodeVerifySchema(pParse, i);
160864 }
160865 if( DbMaskNonZero(pParse->writeMask) ){
160866 for(i=0; i<nDb; i++){
160867 sqlite3BeginWriteOperation(pParse, 0, i);
160868 }
160869 }
160870 }
@@ -180122,10 +180253,12 @@
180253 SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int);
180254 SQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int);
180255 SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);
180256 #endif
180257
180258 SQLITE_PRIVATE int sqlite3Fts3ExprIterate(Fts3Expr*, int (*x)(Fts3Expr*,int,void*), void*);
180259
180260 #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */
180261 #endif /* _FTSINT_H */
180262
180263 /************** End of fts3Int.h *********************************************/
180264 /************** Continuing where we left off in fts3.c ***********************/
@@ -185125,13 +185258,12 @@
185258 static void fts3EvalNextRow(
185259 Fts3Cursor *pCsr, /* FTS Cursor handle */
185260 Fts3Expr *pExpr, /* Expr. to advance to next matching row */
185261 int *pRc /* IN/OUT: Error code */
185262 ){
185263 if( *pRc==SQLITE_OK && pExpr->bEof==0 ){
185264 int bDescDoclist = pCsr->bDesc; /* Used by DOCID_CMP() macro */
 
185265 pExpr->bStart = 1;
185266
185267 switch( pExpr->eType ){
185268 case FTSQUERY_NEAR:
185269 case FTSQUERY_AND: {
@@ -185602,10 +185734,26 @@
185734
185735 fts3EvalUpdateCounts(pExpr->pLeft, nCol);
185736 fts3EvalUpdateCounts(pExpr->pRight, nCol);
185737 }
185738 }
185739
185740 /*
185741 ** This is an sqlite3Fts3ExprIterate() callback. If the Fts3Expr.aMI[] array
185742 ** has not yet been allocated, allocate and zero it. Otherwise, just zero
185743 ** it.
185744 */
185745 static int fts3AllocateMSI(Fts3Expr *pExpr, int iPhrase, void *pCtx){
185746 Fts3Table *pTab = (Fts3Table*)pCtx;
185747 UNUSED_PARAMETER(iPhrase);
185748 if( pExpr->aMI==0 ){
185749 pExpr->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
185750 if( pExpr->aMI==0 ) return SQLITE_NOMEM;
185751 }
185752 memset(pExpr->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
185753 return SQLITE_OK;
185754 }
185755
185756 /*
185757 ** Expression pExpr must be of type FTSQUERY_PHRASE.
185758 **
185759 ** If it is not already allocated and populated, this function allocates and
@@ -185624,34 +185772,29 @@
185772
185773 assert( pExpr->eType==FTSQUERY_PHRASE );
185774 if( pExpr->aMI==0 ){
185775 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
185776 Fts3Expr *pRoot; /* Root of NEAR expression */
 
185777
185778 sqlite3_int64 iPrevId = pCsr->iPrevId;
185779 sqlite3_int64 iDocid;
185780 u8 bEof;
185781
185782 /* Find the root of the NEAR expression */
185783 pRoot = pExpr;
185784 while( pRoot->pParent
185785 && (pRoot->pParent->eType==FTSQUERY_NEAR || pRoot->bDeferred)
185786 ){
185787 pRoot = pRoot->pParent;
185788 }
185789 iDocid = pRoot->iDocid;
185790 bEof = pRoot->bEof;
185791 assert( pRoot->bStart );
185792
185793 /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */
185794 rc = sqlite3Fts3ExprIterate(pRoot, fts3AllocateMSI, (void*)pTab);
185795 if( rc!=SQLITE_OK ) return rc;
 
 
 
 
 
 
185796 fts3EvalRestart(pCsr, pRoot, &rc);
185797
185798 while( pCsr->isEof==0 && rc==SQLITE_OK ){
185799
185800 do {
@@ -185803,10 +185946,11 @@
185946 int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
185947 int bOr = 0;
185948 u8 bTreeEof = 0;
185949 Fts3Expr *p; /* Used to iterate from pExpr to root */
185950 Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
185951 Fts3Expr *pRun; /* Closest non-deferred ancestor of pNear */
185952 int bMatch;
185953
185954 /* Check if this phrase descends from an OR expression node. If not,
185955 ** return NULL. Otherwise, the entry that corresponds to docid
185956 ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
@@ -185817,29 +185961,34 @@
185961 if( p->eType==FTSQUERY_OR ) bOr = 1;
185962 if( p->eType==FTSQUERY_NEAR ) pNear = p;
185963 if( p->bEof ) bTreeEof = 1;
185964 }
185965 if( bOr==0 ) return SQLITE_OK;
185966 pRun = pNear;
185967 while( pRun->bDeferred ){
185968 assert( pRun->pParent );
185969 pRun = pRun->pParent;
185970 }
185971
185972 /* This is the descendent of an OR node. In this case we cannot use
185973 ** an incremental phrase. Load the entire doclist for the phrase
185974 ** into memory in this case. */
185975 if( pPhrase->bIncr ){
185976 int bEofSave = pRun->bEof;
185977 fts3EvalRestart(pCsr, pRun, &rc);
185978 while( rc==SQLITE_OK && !pRun->bEof ){
185979 fts3EvalNextRow(pCsr, pRun, &rc);
185980 if( bEofSave==0 && pRun->iDocid==iDocid ) break;
185981 }
185982 assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
185983 if( rc==SQLITE_OK && pRun->bEof!=bEofSave ){
185984 rc = FTS_CORRUPT_VTAB;
185985 }
185986 }
185987 if( bTreeEof ){
185988 while( rc==SQLITE_OK && !pRun->bEof ){
185989 fts3EvalNextRow(pCsr, pRun, &rc);
185990 }
185991 }
185992 if( rc!=SQLITE_OK ) return rc;
185993
185994 bMatch = 1;
@@ -195942,11 +196091,11 @@
196091 */
196092 #define FTS3_MATCHINFO_DEFAULT "pcx"
196093
196094
196095 /*
196096 ** Used as an sqlite3Fts3ExprIterate() context when loading phrase doclists to
196097 ** Fts3Expr.aDoclist[]/nDoclist.
196098 */
196099 typedef struct LoadDoclistCtx LoadDoclistCtx;
196100 struct LoadDoclistCtx {
196101 Fts3Cursor *pCsr; /* FTS3 Cursor */
@@ -195986,11 +196135,11 @@
196135 u64 covered; /* Mask of query phrases covered */
196136 u64 hlmask; /* Mask of snippet terms to highlight */
196137 };
196138
196139 /*
196140 ** This type is used as an sqlite3Fts3ExprIterate() context object while
196141 ** accumulating the data returned by the matchinfo() function.
196142 */
196143 typedef struct MatchInfo MatchInfo;
196144 struct MatchInfo {
196145 Fts3Cursor *pCursor; /* FTS3 Cursor */
@@ -196145,11 +196294,11 @@
196294 *pp += fts3GetVarint32(*pp, &iVal);
196295 *piPos += (iVal-2);
196296 }
196297
196298 /*
196299 ** Helper function for sqlite3Fts3ExprIterate() (see below).
196300 */
196301 static int fts3ExprIterate2(
196302 Fts3Expr *pExpr, /* Expression to iterate phrases of */
196303 int *piPhrase, /* Pointer to phrase counter */
196304 int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
@@ -196179,23 +196328,22 @@
196328 ** If the callback function returns anything other than SQLITE_OK,
196329 ** the iteration is abandoned and the error code returned immediately.
196330 ** Otherwise, SQLITE_OK is returned after a callback has been made for
196331 ** all eligible phrase nodes.
196332 */
196333 SQLITE_PRIVATE int sqlite3Fts3ExprIterate(
196334 Fts3Expr *pExpr, /* Expression to iterate phrases of */
196335 int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
196336 void *pCtx /* Second argument to pass to callback */
196337 ){
196338 int iPhrase = 0; /* Variable used as the phrase counter */
196339 return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
196340 }
196341
 
196342 /*
196343 ** This is an sqlite3Fts3ExprIterate() callback used while loading the
196344 ** doclists for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also
196345 ** fts3ExprLoadDoclists().
196346 */
196347 static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
196348 int rc = SQLITE_OK;
196349 Fts3Phrase *pPhrase = pExpr->pPhrase;
@@ -196223,13 +196371,13 @@
196371 Fts3Cursor *pCsr, /* Fts3 cursor for current query */
196372 int *pnPhrase, /* OUT: Number of phrases in query */
196373 int *pnToken /* OUT: Number of tokens in query */
196374 ){
196375 int rc; /* Return Code */
196376 LoadDoclistCtx sCtx = {0,0,0}; /* Context for sqlite3Fts3ExprIterate() */
196377 sCtx.pCsr = pCsr;
196378 rc = sqlite3Fts3ExprIterate(pCsr->pExpr,fts3ExprLoadDoclistsCb,(void*)&sCtx);
196379 if( pnPhrase ) *pnPhrase = sCtx.nPhrase;
196380 if( pnToken ) *pnToken = sCtx.nToken;
196381 return rc;
196382 }
196383
@@ -196238,11 +196386,11 @@
196386 pExpr->iPhrase = iPhrase;
196387 return SQLITE_OK;
196388 }
196389 static int fts3ExprPhraseCount(Fts3Expr *pExpr){
196390 int nPhrase = 0;
196391 (void)sqlite3Fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
196392 return nPhrase;
196393 }
196394
196395 /*
196396 ** Advance the position list iterator specified by the first two
@@ -196366,12 +196514,13 @@
196514 *pmCover = mCover;
196515 *pmHighlight = mHighlight;
196516 }
196517
196518 /*
196519 ** This function is an sqlite3Fts3ExprIterate() callback used by
196520 ** fts3BestSnippet(). Each invocation populates an element of the
196521 ** SnippetIter.aPhrase[] array.
196522 */
196523 static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
196524 SnippetIter *p = (SnippetIter *)ctx;
196525 SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];
196526 char *pCsr;
@@ -196457,11 +196606,13 @@
196606 sIter.pCsr = pCsr;
196607 sIter.iCol = iCol;
196608 sIter.nSnippet = nSnippet;
196609 sIter.nPhrase = nList;
196610 sIter.iCurrent = -1;
196611 rc = sqlite3Fts3ExprIterate(
196612 pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter
196613 );
196614 if( rc==SQLITE_OK ){
196615
196616 /* Set the *pmSeen output variable. */
196617 for(i=0; i<nList; i++){
196618 if( sIter.aPhrase[i].pHead ){
@@ -196818,14 +196969,14 @@
196969 }
196970 return rc;
196971 }
196972
196973 /*
196974 ** sqlite3Fts3ExprIterate() callback used to collect the "global" matchinfo
196975 ** stats for a single query.
196976 **
196977 ** sqlite3Fts3ExprIterate() callback to load the 'global' elements of a
196978 ** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements
196979 ** of the matchinfo array that are constant for all rows returned by the
196980 ** current query.
196981 **
196982 ** Argument pCtx is actually a pointer to a struct of type MatchInfo. This
@@ -196856,11 +197007,11 @@
197007 p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]
197008 );
197009 }
197010
197011 /*
197012 ** sqlite3Fts3ExprIterate() callback used to collect the "local" part of the
197013 ** FTS3_MATCHINFO_HITS array. The local stats are those elements of the
197014 ** array that are different for each row returned by the query.
197015 */
197016 static int fts3ExprLocalHitsCb(
197017 Fts3Expr *pExpr, /* Phrase expression node */
@@ -197052,11 +197203,11 @@
197203 /* Allocate and populate the array of LcsIterator objects. The array
197204 ** contains one element for each matchable phrase in the query.
197205 **/
197206 aIter = sqlite3Fts3MallocZero(sizeof(LcsIterator) * pCsr->nPhrase);
197207 if( !aIter ) return SQLITE_NOMEM;
197208 (void)sqlite3Fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
197209
197210 for(i=0; i<pInfo->nPhrase; i++){
197211 LcsIterator *pIter = &aIter[i];
197212 nToken -= pIter->pExpr->pPhrase->nToken;
197213 pIter->iPosOffset = nToken;
@@ -197229,15 +197380,15 @@
197380 if( bGlobal ){
197381 if( pCsr->pDeferred ){
197382 rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc,0,0);
197383 if( rc!=SQLITE_OK ) break;
197384 }
197385 rc = sqlite3Fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
197386 sqlite3Fts3EvalTestDeferred(pCsr, &rc);
197387 if( rc!=SQLITE_OK ) break;
197388 }
197389 (void)sqlite3Fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
197390 break;
197391 }
197392 }
197393
197394 pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);
@@ -197456,11 +197607,11 @@
197607 sqlite3_int64 iDocid;
197608 TermOffset *aTerm;
197609 };
197610
197611 /*
197612 ** This function is an sqlite3Fts3ExprIterate() callback used by sqlite3Fts3Offsets().
197613 */
197614 static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
197615 TermOffsetCtx *p = (TermOffsetCtx *)ctx;
197616 int nTerm; /* Number of tokens in phrase */
197617 int iTerm; /* For looping through nTerm phrase terms */
@@ -197538,11 +197689,13 @@
197689 /* Initialize the contents of sCtx.aTerm[] for column iCol. This
197690 ** operation may fail if the database contains corrupt records.
197691 */
197692 sCtx.iCol = iCol;
197693 sCtx.iTerm = 0;
197694 rc = sqlite3Fts3ExprIterate(
197695 pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx
197696 );
197697 if( rc!=SQLITE_OK ) goto offsets_out;
197698
197699 /* Retreive the text stored in column iCol. If an SQL NULL is stored
197700 ** in column iCol, jump immediately to the next iteration of the loop.
197701 ** If an OOM occurs while retrieving the data (this can happen if SQLite
@@ -200914,10 +201067,17 @@
201067 }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
201068 aIdx[iCol] = i;
201069 idxMask |= iMask;
201070 }
201071 }
201072 if( pIdxInfo->nOrderBy>0
201073 && pIdxInfo->aOrderBy[0].iColumn<0
201074 && pIdxInfo->aOrderBy[0].desc==0
201075 ){
201076 pIdxInfo->orderByConsumed = 1;
201077 }
201078
201079 if( (unusableMask & ~idxMask)!=0 ){
201080 /* If there are any unusable constraints on JSON or ROOT, then reject
201081 ** this entire plan */
201082 return SQLITE_CONSTRAINT;
201083 }
@@ -201109,14 +201269,14 @@
201269 JFUNCTION(json_parse, 1, 0, jsonParseFunc),
201270 JFUNCTION(json_test1, 1, 0, jsonTest1Func),
201271 #endif
201272 WAGGREGATE(json_group_array, 1, 0, 0,
201273 jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
201274 SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC),
201275 WAGGREGATE(json_group_object, 2, 0, 0,
201276 jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
201277 SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC)
201278 };
201279 sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
201280 #endif
201281 }
201282
@@ -208579,11 +208739,11 @@
208739 ** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);
208740 **
208741 ** The order of the columns in the data_% table does not matter.
208742 **
208743 ** Instead of a regular table, the RBU database may also contain virtual
208744 ** tables or views named using the data_<target> naming scheme.
208745 **
208746 ** Instead of the plain data_<target> naming scheme, RBU database tables
208747 ** may also be named data<integer>_<target>, where <integer> is any sequence
208748 ** of zero or more numeric characters (0-9). This can be significant because
208749 ** tables within the RBU database are always processed in order sorted by
@@ -208592,11 +208752,11 @@
208752 ** are processed. This can be useful, for example, to ensure that "external
208753 ** content" FTS4 tables are updated before their underlying content tables.
208754 **
208755 ** If the target database table is a virtual table or a table that has no
208756 ** PRIMARY KEY declaration, the data_% table must also contain a column
208757 ** named "rbu_rowid". This column is mapped to the table's implicit primary
208758 ** key column - "rowid". Virtual tables for which the "rowid" column does
208759 ** not function like a primary key value cannot be updated using RBU. For
208760 ** example, if the target db contains either of the following:
208761 **
208762 ** CREATE VIRTUAL TABLE x1 USING fts3(a, b);
@@ -239876,11 +240036,11 @@
240036 int nArg, /* Number of args */
240037 sqlite3_value **apUnused /* Function arguments */
240038 ){
240039 assert( nArg==0 );
240040 UNUSED_PARAM2(nArg, apUnused);
240041 sqlite3_result_text(pCtx, "fts5: 2023-01-19 18:16:09 fa10e561f5dcdb23af862c2e486e877d379f12eae077ae5fd3da6028f1c20b49", -1, SQLITE_TRANSIENT);
240042 }
240043
240044 /*
240045 ** Return true if zName is the extension on one of the shadow tables used
240046 ** by this module.
@@ -239949,11 +240109,13 @@
240109 db, "fts5", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0
240110 );
240111 }
240112 if( rc==SQLITE_OK ){
240113 rc = sqlite3_create_function(
240114 db, "fts5_source_id", 0,
240115 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
240116 p, fts5SourceIdFunc, 0, 0
240117 );
240118 }
240119 }
240120
240121 /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file
240122
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.41.0"
150150
#define SQLITE_VERSION_NUMBER 3041000
151
-#define SQLITE_SOURCE_ID "2023-01-16 18:13:00 83f21285fe86430a66ce6841606e3ad7c27da52ac75a034c6a00c7a9fdb9791d"
151
+#define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -9804,18 +9804,17 @@
98049804
** [xFilter|xFilter() method] of a [virtual table] implementation.
98059805
** The result of invoking these interfaces from any other context
98069806
** is undefined and probably harmful.
98079807
**
98089808
** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
9809
-** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
9809
+** sqlite3_vtab_in_next(X,P) should be one of the parameters to the
98109810
** xFilter method which invokes these routines, and specifically
98119811
** a parameter that was previously selected for all-at-once IN constraint
98129812
** processing use the [sqlite3_vtab_in()] interface in the
98139813
** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
98149814
** an xFilter argument that was selected for all-at-once IN constraint
9815
-** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
9816
-** exhibit some other undefined or harmful behavior.
9815
+** processing, then these routines return [SQLITE_ERROR].)^
98179816
**
98189817
** ^(Use these routines to access all values on the right-hand side
98199818
** of the IN constraint using code like the following:
98209819
**
98219820
** <blockquote><pre>
98229821
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.41.0"
150 #define SQLITE_VERSION_NUMBER 3041000
151 #define SQLITE_SOURCE_ID "2023-01-16 18:13:00 83f21285fe86430a66ce6841606e3ad7c27da52ac75a034c6a00c7a9fdb9791d"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9804,18 +9804,17 @@
9804 ** [xFilter|xFilter() method] of a [virtual table] implementation.
9805 ** The result of invoking these interfaces from any other context
9806 ** is undefined and probably harmful.
9807 **
9808 ** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
9809 ** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
9810 ** xFilter method which invokes these routines, and specifically
9811 ** a parameter that was previously selected for all-at-once IN constraint
9812 ** processing use the [sqlite3_vtab_in()] interface in the
9813 ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
9814 ** an xFilter argument that was selected for all-at-once IN constraint
9815 ** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
9816 ** exhibit some other undefined or harmful behavior.
9817 **
9818 ** ^(Use these routines to access all values on the right-hand side
9819 ** of the IN constraint using code like the following:
9820 **
9821 ** <blockquote><pre>
9822
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.41.0"
150 #define SQLITE_VERSION_NUMBER 3041000
151 #define SQLITE_SOURCE_ID "2023-01-27 07:53:49 eabb551b8b3d33fc3a327ecf7225436a3a3f616901e22c868fd76a5e3adc7b3f"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9804,18 +9804,17 @@
9804 ** [xFilter|xFilter() method] of a [virtual table] implementation.
9805 ** The result of invoking these interfaces from any other context
9806 ** is undefined and probably harmful.
9807 **
9808 ** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
9809 ** sqlite3_vtab_in_next(X,P) should be one of the parameters to the
9810 ** xFilter method which invokes these routines, and specifically
9811 ** a parameter that was previously selected for all-at-once IN constraint
9812 ** processing use the [sqlite3_vtab_in()] interface in the
9813 ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
9814 ** an xFilter argument that was selected for all-at-once IN constraint
9815 ** processing, then these routines return [SQLITE_ERROR].)^
 
9816 **
9817 ** ^(Use these routines to access all values on the right-hand side
9818 ** of the IN constraint using code like the following:
9819 **
9820 ** <blockquote><pre>
9821

Keyboard Shortcuts

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