Fossil SCM

Update the built-in SQLite to the latest version 3.47.0 alpha. This SQLite has all of the fixes that are going into the 3.46.1 release, and so the purpose of this update is to beta test those fixes.

drh 2024-08-10 17:49 trunk
Commit dc15083b9ab67f13927adb50d3a70ea00df6e4c1f5eb0689cc6999e3a859105d
+26 -15
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -602,15 +602,10 @@
602602
# endif
603603
#else
604604
# define CIO_WIN_WC_XLATE 0 /* Not exposing translation routines at all */
605605
#endif
606606
607
-#if CIO_WIN_WC_XLATE
608
-/* Character used to represent a known-incomplete UTF-8 char group (�) */
609
-static WCHAR cBadGroup = 0xfffd;
610
-#endif
611
-
612607
#if CIO_WIN_WC_XLATE
613608
static HANDLE handleOfFile(FILE *pf){
614609
int fileDesc = _fileno(pf);
615610
union { intptr_t osfh; HANDLE fh; } fid = {
616611
(fileDesc>=0)? _get_osfhandle(fileDesc) : (intptr_t)INVALID_HANDLE_VALUE
@@ -12839,11 +12834,11 @@
1283912834
(void)argv;
1284012835
rc = sqlite3_finalize(pCsr->pData);
1284112836
pCsr->pData = 0;
1284212837
if( rc==SQLITE_OK ){
1284312838
rc = idxPrintfPrepareStmt(pExpert->db, &pCsr->pData, &pVtab->base.zErrMsg,
12844
- "SELECT * FROM main.%Q WHERE sample()", pVtab->pTab->zName
12839
+ "SELECT * FROM main.%Q WHERE sqlite_expert_sample()", pVtab->pTab->zName
1284512840
);
1284612841
}
1284712842
1284812843
if( rc==SQLITE_OK ){
1284912844
rc = expertNext(cur);
@@ -13713,11 +13708,11 @@
1371313708
char *z; /* SQLITE_TEXT/BLOB value */
1371413709
} aSlot[1];
1371513710
};
1371613711
1371713712
/*
13718
-** Implementation of scalar function rem().
13713
+** Implementation of scalar function sqlite_expert_rem().
1371913714
*/
1372013715
static void idxRemFunc(
1372113716
sqlite3_context *pCtx,
1372213717
int argc,
1372313718
sqlite3_value **argv
@@ -13726,11 +13721,11 @@
1372613721
struct IdxRemSlot *pSlot;
1372713722
int iSlot;
1372813723
assert( argc==2 );
1372913724
1373013725
iSlot = sqlite3_value_int(argv[0]);
13731
- assert( iSlot<=p->nSlot );
13726
+ assert( iSlot<p->nSlot );
1373213727
pSlot = &p->aSlot[iSlot];
1373313728
1373413729
switch( pSlot->eType ){
1373513730
case SQLITE_NULL:
1373613731
/* no-op */
@@ -13837,11 +13832,12 @@
1383713832
while( SQLITE_OK==rc && SQLITE_ROW==sqlite3_step(pIndexXInfo) ){
1383813833
const char *zComma = zCols==0 ? "" : ", ";
1383913834
const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0);
1384013835
const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1);
1384113836
zCols = idxAppendText(&rc, zCols,
13842
- "%sx.%Q IS rem(%d, x.%Q) COLLATE %s", zComma, zName, nCol, zName, zColl
13837
+ "%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s",
13838
+ zComma, zName, nCol, zName, zColl
1384313839
);
1384413840
zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol);
1384513841
}
1384613842
sqlite3_reset(pIndexXInfo);
1384713843
if( rc==SQLITE_OK ){
@@ -13970,17 +13966,17 @@
1397013966
pCtx = (struct IdxRemCtx*)idxMalloc(&rc, nByte);
1397113967
}
1397213968
1397313969
if( rc==SQLITE_OK ){
1397413970
sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
13975
- rc = sqlite3_create_function(
13976
- dbrem, "rem", 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0
13971
+ rc = sqlite3_create_function(dbrem, "sqlite_expert_rem",
13972
+ 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0
1397713973
);
1397813974
}
1397913975
if( rc==SQLITE_OK ){
13980
- rc = sqlite3_create_function(
13981
- p->db, "sample", 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0
13976
+ rc = sqlite3_create_function(p->db, "sqlite_expert_sample",
13977
+ 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0
1398213978
);
1398313979
}
1398413980
1398513981
if( rc==SQLITE_OK ){
1398613982
pCtx->nSlot = nMax+1;
@@ -14028,10 +14024,13 @@
1402814024
1402914025
if( rc==SQLITE_OK ){
1403014026
rc = sqlite3_exec(p->dbm, "ANALYZE sqlite_schema", 0, 0, 0);
1403114027
}
1403214028
14029
+ sqlite3_create_function(p->db, "sqlite_expert_rem", 2, SQLITE_UTF8, 0,0,0,0);
14030
+ sqlite3_create_function(p->db, "sqlite_expert_sample", 0,SQLITE_UTF8,0,0,0,0);
14031
+
1403314032
sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp."UNIQUE_TABLE_NAME,0,0,0);
1403414033
return rc;
1403514034
}
1403614035
1403714036
/*
@@ -16521,10 +16520,11 @@
1652116520
/* Allocate space for payload. And a bit more to catch small buffer
1652216521
** overruns caused by attempting to read a varint or similar from
1652316522
** near the end of a corrupt record. */
1652416523
rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES);
1652516524
if( rc!=SQLITE_OK ) return rc;
16525
+ assert( pCsr->rec.aBuf!=0 );
1652616526
assert( nPayload!=0 );
1652716527
1652816528
/* Load the nLocal bytes of payload */
1652916529
memcpy(pCsr->rec.aBuf, &pCsr->aPage[iOff], nLocal);
1653016530
iOff += nLocal;
@@ -17227,12 +17227,12 @@
1722717227
char *z = 0;
1722817228
va_list ap;
1722917229
va_start(ap, zFmt);
1723017230
if( zFmt ){
1723117231
z = sqlite3_vmprintf(zFmt, ap);
17232
- va_end(ap);
1723317232
}
17233
+ va_end(ap);
1723417234
sqlite3_free(p->zErrMsg);
1723517235
p->zErrMsg = z;
1723617236
p->errCode = errCode;
1723717237
return errCode;
1723817238
}
@@ -22043,10 +22043,18 @@
2204322043
#endif
2204422044
#ifdef INFINITY
2204522045
}else if( sqlite3_strlike("_INF", zVar, 0)==0 ){
2204622046
sqlite3_bind_double(pStmt, i, INFINITY);
2204722047
#endif
22048
+ }else if( strncmp(zVar, "$int_", 5)==0 ){
22049
+ sqlite3_bind_int(pStmt, i, atoi(&zVar[5]));
22050
+ }else if( strncmp(zVar, "$text_", 6)==0 ){
22051
+ char *zBuf = sqlite3_malloc64( strlen(zVar)-5 );
22052
+ if( zBuf ){
22053
+ memcpy(zBuf, &zVar[6], strlen(zVar)-5);
22054
+ sqlite3_bind_text64(pStmt, i, zBuf, -1, sqlite3_free, SQLITE_UTF8);
22055
+ }
2204822056
}else{
2204922057
sqlite3_bind_null(pStmt, i);
2205022058
}
2205122059
sqlite3_reset(pQ);
2205222060
}
@@ -30138,11 +30146,14 @@
3013830146
if( p->eRestoreState<7 ){
3013930147
switch( p->eRestoreState ){
3014030148
case 0: {
3014130149
const char *zExpect = "PRAGMA foreign_keys=OFF;";
3014230150
assert( strlen(zExpect)==24 );
30143
- if( p->bSafeMode==0 && memcmp(zSql, zExpect, 25)==0 ){
30151
+ if( p->bSafeMode==0
30152
+ && strlen(zSql)>=24
30153
+ && memcmp(zSql, zExpect, 25)==0
30154
+ ){
3014430155
p->eRestoreState = 1;
3014530156
}else{
3014630157
p->eRestoreState = 7;
3014730158
}
3014830159
break;
3014930160
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -602,15 +602,10 @@
602 # endif
603 #else
604 # define CIO_WIN_WC_XLATE 0 /* Not exposing translation routines at all */
605 #endif
606
607 #if CIO_WIN_WC_XLATE
608 /* Character used to represent a known-incomplete UTF-8 char group (�) */
609 static WCHAR cBadGroup = 0xfffd;
610 #endif
611
612 #if CIO_WIN_WC_XLATE
613 static HANDLE handleOfFile(FILE *pf){
614 int fileDesc = _fileno(pf);
615 union { intptr_t osfh; HANDLE fh; } fid = {
616 (fileDesc>=0)? _get_osfhandle(fileDesc) : (intptr_t)INVALID_HANDLE_VALUE
@@ -12839,11 +12834,11 @@
12839 (void)argv;
12840 rc = sqlite3_finalize(pCsr->pData);
12841 pCsr->pData = 0;
12842 if( rc==SQLITE_OK ){
12843 rc = idxPrintfPrepareStmt(pExpert->db, &pCsr->pData, &pVtab->base.zErrMsg,
12844 "SELECT * FROM main.%Q WHERE sample()", pVtab->pTab->zName
12845 );
12846 }
12847
12848 if( rc==SQLITE_OK ){
12849 rc = expertNext(cur);
@@ -13713,11 +13708,11 @@
13713 char *z; /* SQLITE_TEXT/BLOB value */
13714 } aSlot[1];
13715 };
13716
13717 /*
13718 ** Implementation of scalar function rem().
13719 */
13720 static void idxRemFunc(
13721 sqlite3_context *pCtx,
13722 int argc,
13723 sqlite3_value **argv
@@ -13726,11 +13721,11 @@
13726 struct IdxRemSlot *pSlot;
13727 int iSlot;
13728 assert( argc==2 );
13729
13730 iSlot = sqlite3_value_int(argv[0]);
13731 assert( iSlot<=p->nSlot );
13732 pSlot = &p->aSlot[iSlot];
13733
13734 switch( pSlot->eType ){
13735 case SQLITE_NULL:
13736 /* no-op */
@@ -13837,11 +13832,12 @@
13837 while( SQLITE_OK==rc && SQLITE_ROW==sqlite3_step(pIndexXInfo) ){
13838 const char *zComma = zCols==0 ? "" : ", ";
13839 const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0);
13840 const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1);
13841 zCols = idxAppendText(&rc, zCols,
13842 "%sx.%Q IS rem(%d, x.%Q) COLLATE %s", zComma, zName, nCol, zName, zColl
 
13843 );
13844 zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol);
13845 }
13846 sqlite3_reset(pIndexXInfo);
13847 if( rc==SQLITE_OK ){
@@ -13970,17 +13966,17 @@
13970 pCtx = (struct IdxRemCtx*)idxMalloc(&rc, nByte);
13971 }
13972
13973 if( rc==SQLITE_OK ){
13974 sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
13975 rc = sqlite3_create_function(
13976 dbrem, "rem", 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0
13977 );
13978 }
13979 if( rc==SQLITE_OK ){
13980 rc = sqlite3_create_function(
13981 p->db, "sample", 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0
13982 );
13983 }
13984
13985 if( rc==SQLITE_OK ){
13986 pCtx->nSlot = nMax+1;
@@ -14028,10 +14024,13 @@
14028
14029 if( rc==SQLITE_OK ){
14030 rc = sqlite3_exec(p->dbm, "ANALYZE sqlite_schema", 0, 0, 0);
14031 }
14032
 
 
 
14033 sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp."UNIQUE_TABLE_NAME,0,0,0);
14034 return rc;
14035 }
14036
14037 /*
@@ -16521,10 +16520,11 @@
16521 /* Allocate space for payload. And a bit more to catch small buffer
16522 ** overruns caused by attempting to read a varint or similar from
16523 ** near the end of a corrupt record. */
16524 rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES);
16525 if( rc!=SQLITE_OK ) return rc;
 
16526 assert( nPayload!=0 );
16527
16528 /* Load the nLocal bytes of payload */
16529 memcpy(pCsr->rec.aBuf, &pCsr->aPage[iOff], nLocal);
16530 iOff += nLocal;
@@ -17227,12 +17227,12 @@
17227 char *z = 0;
17228 va_list ap;
17229 va_start(ap, zFmt);
17230 if( zFmt ){
17231 z = sqlite3_vmprintf(zFmt, ap);
17232 va_end(ap);
17233 }
 
17234 sqlite3_free(p->zErrMsg);
17235 p->zErrMsg = z;
17236 p->errCode = errCode;
17237 return errCode;
17238 }
@@ -22043,10 +22043,18 @@
22043 #endif
22044 #ifdef INFINITY
22045 }else if( sqlite3_strlike("_INF", zVar, 0)==0 ){
22046 sqlite3_bind_double(pStmt, i, INFINITY);
22047 #endif
 
 
 
 
 
 
 
 
22048 }else{
22049 sqlite3_bind_null(pStmt, i);
22050 }
22051 sqlite3_reset(pQ);
22052 }
@@ -30138,11 +30146,14 @@
30138 if( p->eRestoreState<7 ){
30139 switch( p->eRestoreState ){
30140 case 0: {
30141 const char *zExpect = "PRAGMA foreign_keys=OFF;";
30142 assert( strlen(zExpect)==24 );
30143 if( p->bSafeMode==0 && memcmp(zSql, zExpect, 25)==0 ){
 
 
 
30144 p->eRestoreState = 1;
30145 }else{
30146 p->eRestoreState = 7;
30147 }
30148 break;
30149
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -602,15 +602,10 @@
602 # endif
603 #else
604 # define CIO_WIN_WC_XLATE 0 /* Not exposing translation routines at all */
605 #endif
606
 
 
 
 
 
607 #if CIO_WIN_WC_XLATE
608 static HANDLE handleOfFile(FILE *pf){
609 int fileDesc = _fileno(pf);
610 union { intptr_t osfh; HANDLE fh; } fid = {
611 (fileDesc>=0)? _get_osfhandle(fileDesc) : (intptr_t)INVALID_HANDLE_VALUE
@@ -12839,11 +12834,11 @@
12834 (void)argv;
12835 rc = sqlite3_finalize(pCsr->pData);
12836 pCsr->pData = 0;
12837 if( rc==SQLITE_OK ){
12838 rc = idxPrintfPrepareStmt(pExpert->db, &pCsr->pData, &pVtab->base.zErrMsg,
12839 "SELECT * FROM main.%Q WHERE sqlite_expert_sample()", pVtab->pTab->zName
12840 );
12841 }
12842
12843 if( rc==SQLITE_OK ){
12844 rc = expertNext(cur);
@@ -13713,11 +13708,11 @@
13708 char *z; /* SQLITE_TEXT/BLOB value */
13709 } aSlot[1];
13710 };
13711
13712 /*
13713 ** Implementation of scalar function sqlite_expert_rem().
13714 */
13715 static void idxRemFunc(
13716 sqlite3_context *pCtx,
13717 int argc,
13718 sqlite3_value **argv
@@ -13726,11 +13721,11 @@
13721 struct IdxRemSlot *pSlot;
13722 int iSlot;
13723 assert( argc==2 );
13724
13725 iSlot = sqlite3_value_int(argv[0]);
13726 assert( iSlot<p->nSlot );
13727 pSlot = &p->aSlot[iSlot];
13728
13729 switch( pSlot->eType ){
13730 case SQLITE_NULL:
13731 /* no-op */
@@ -13837,11 +13832,12 @@
13832 while( SQLITE_OK==rc && SQLITE_ROW==sqlite3_step(pIndexXInfo) ){
13833 const char *zComma = zCols==0 ? "" : ", ";
13834 const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0);
13835 const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1);
13836 zCols = idxAppendText(&rc, zCols,
13837 "%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s",
13838 zComma, zName, nCol, zName, zColl
13839 );
13840 zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol);
13841 }
13842 sqlite3_reset(pIndexXInfo);
13843 if( rc==SQLITE_OK ){
@@ -13970,17 +13966,17 @@
13966 pCtx = (struct IdxRemCtx*)idxMalloc(&rc, nByte);
13967 }
13968
13969 if( rc==SQLITE_OK ){
13970 sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
13971 rc = sqlite3_create_function(dbrem, "sqlite_expert_rem",
13972 2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0
13973 );
13974 }
13975 if( rc==SQLITE_OK ){
13976 rc = sqlite3_create_function(p->db, "sqlite_expert_sample",
13977 0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0
13978 );
13979 }
13980
13981 if( rc==SQLITE_OK ){
13982 pCtx->nSlot = nMax+1;
@@ -14028,10 +14024,13 @@
14024
14025 if( rc==SQLITE_OK ){
14026 rc = sqlite3_exec(p->dbm, "ANALYZE sqlite_schema", 0, 0, 0);
14027 }
14028
14029 sqlite3_create_function(p->db, "sqlite_expert_rem", 2, SQLITE_UTF8, 0,0,0,0);
14030 sqlite3_create_function(p->db, "sqlite_expert_sample", 0,SQLITE_UTF8,0,0,0,0);
14031
14032 sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp."UNIQUE_TABLE_NAME,0,0,0);
14033 return rc;
14034 }
14035
14036 /*
@@ -16521,10 +16520,11 @@
16520 /* Allocate space for payload. And a bit more to catch small buffer
16521 ** overruns caused by attempting to read a varint or similar from
16522 ** near the end of a corrupt record. */
16523 rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES);
16524 if( rc!=SQLITE_OK ) return rc;
16525 assert( pCsr->rec.aBuf!=0 );
16526 assert( nPayload!=0 );
16527
16528 /* Load the nLocal bytes of payload */
16529 memcpy(pCsr->rec.aBuf, &pCsr->aPage[iOff], nLocal);
16530 iOff += nLocal;
@@ -17227,12 +17227,12 @@
17227 char *z = 0;
17228 va_list ap;
17229 va_start(ap, zFmt);
17230 if( zFmt ){
17231 z = sqlite3_vmprintf(zFmt, ap);
 
17232 }
17233 va_end(ap);
17234 sqlite3_free(p->zErrMsg);
17235 p->zErrMsg = z;
17236 p->errCode = errCode;
17237 return errCode;
17238 }
@@ -22043,10 +22043,18 @@
22043 #endif
22044 #ifdef INFINITY
22045 }else if( sqlite3_strlike("_INF", zVar, 0)==0 ){
22046 sqlite3_bind_double(pStmt, i, INFINITY);
22047 #endif
22048 }else if( strncmp(zVar, "$int_", 5)==0 ){
22049 sqlite3_bind_int(pStmt, i, atoi(&zVar[5]));
22050 }else if( strncmp(zVar, "$text_", 6)==0 ){
22051 char *zBuf = sqlite3_malloc64( strlen(zVar)-5 );
22052 if( zBuf ){
22053 memcpy(zBuf, &zVar[6], strlen(zVar)-5);
22054 sqlite3_bind_text64(pStmt, i, zBuf, -1, sqlite3_free, SQLITE_UTF8);
22055 }
22056 }else{
22057 sqlite3_bind_null(pStmt, i);
22058 }
22059 sqlite3_reset(pQ);
22060 }
@@ -30138,11 +30146,14 @@
30146 if( p->eRestoreState<7 ){
30147 switch( p->eRestoreState ){
30148 case 0: {
30149 const char *zExpect = "PRAGMA foreign_keys=OFF;";
30150 assert( strlen(zExpect)==24 );
30151 if( p->bSafeMode==0
30152 && strlen(zSql)>=24
30153 && memcmp(zSql, zExpect, 25)==0
30154 ){
30155 p->eRestoreState = 1;
30156 }else{
30157 p->eRestoreState = 7;
30158 }
30159 break;
30160
+63 -57
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** bcc31846964102385d5a21eb5e85d7db153b.
21
+** 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a8.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462462
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463463
** [sqlite_version()] and [sqlite_source_id()].
464464
*/
465465
#define SQLITE_VERSION "3.47.0"
466466
#define SQLITE_VERSION_NUMBER 3047000
467
-#define SQLITE_SOURCE_ID "2024-07-24 13:53:51 bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04"
467
+#define SQLITE_SOURCE_ID "2024-08-10 15:46:57 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef"
468468
469469
/*
470470
** CAPI3REF: Run-Time Library Version Numbers
471471
** KEYWORDS: sqlite3_version sqlite3_sourceid
472472
**
@@ -6134,11 +6134,11 @@
61346134
** an [application-defined SQL function] argument V. The subtype
61356135
** information can be used to pass a limited amount of context from
61366136
** one SQL function to another. Use the [sqlite3_result_subtype()]
61376137
** routine to set the subtype for the return value of an SQL function.
61386138
**
6139
-** Every [application-defined SQL function] that invoke this interface
6139
+** Every [application-defined SQL function] that invokes this interface
61406140
** should include the [SQLITE_SUBTYPE] property in the text
61416141
** encoding argument when the function is [sqlite3_create_function|registered].
61426142
** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
61436143
** might return zero instead of the upstream subtype in some corner cases.
61446144
*/
@@ -18902,13 +18902,19 @@
1890218902
**
1890318903
** These macros should not be used prior to the call to
1890418904
** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg.
1890518905
** The assert()s that are part of this macro verify that constraint.
1890618906
*/
18907
+#ifndef NDEBUG
1890718908
#define AggInfoColumnReg(A,I) (assert((A)->iFirstReg),(A)->iFirstReg+(I))
1890818909
#define AggInfoFuncReg(A,I) \
1890918910
(assert((A)->iFirstReg),(A)->iFirstReg+(A)->nColumn+(I))
18911
+#else
18912
+#define AggInfoColumnReg(A,I) ((A)->iFirstReg+(I))
18913
+#define AggInfoFuncReg(A,I) \
18914
+ ((A)->iFirstReg+(A)->nColumn+(I))
18915
+#endif
1891018916
1891118917
/*
1891218918
** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
1891318919
** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater
1891418920
** than 32767 we have to make it 32-bit. 16-bit is preferred because
@@ -103447,17 +103453,18 @@
103447103453
/* The following loop copies up to p->nBuffer bytes per iteration into
103448103454
** the p->aAlloc[] buffer. */
103449103455
while( nRem>0 ){
103450103456
int rc; /* vdbePmaReadBlob() return code */
103451103457
int nCopy; /* Number of bytes to copy */
103452
- u8 *aNext; /* Pointer to buffer to copy data from */
103458
+ u8 *aNext = 0; /* Pointer to buffer to copy data from */
103453103459
103454103460
nCopy = nRem;
103455103461
if( nRem>p->nBuffer ) nCopy = p->nBuffer;
103456103462
rc = vdbePmaReadBlob(p, nCopy, &aNext);
103457103463
if( rc!=SQLITE_OK ) return rc;
103458103464
assert( aNext!=p->aAlloc );
103465
+ assert( aNext!=0 );
103459103466
memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);
103460103467
nRem -= nCopy;
103461103468
}
103462103469
103463103470
*ppOut = p->aAlloc;
@@ -108968,19 +108975,22 @@
108968108975
108969108976
/*
108970108977
** Resolve all names for all expression in an expression list. This is
108971108978
** just like sqlite3ResolveExprNames() except that it works for an expression
108972108979
** list rather than a single expression.
108980
+**
108981
+** The return value is SQLITE_OK (0) for success or SQLITE_ERROR (1) for a
108982
+** failure.
108973108983
*/
108974108984
SQLITE_PRIVATE int sqlite3ResolveExprListNames(
108975108985
NameContext *pNC, /* Namespace to resolve expressions in. */
108976108986
ExprList *pList /* The expression list to be analyzed. */
108977108987
){
108978108988
int i;
108979108989
int savedHasAgg = 0;
108980108990
Walker w;
108981
- if( pList==0 ) return WRC_Continue;
108991
+ if( pList==0 ) return SQLITE_OK;
108982108992
w.pParse = pNC->pParse;
108983108993
w.xExprCallback = resolveExprStep;
108984108994
w.xSelectCallback = resolveSelectStep;
108985108995
w.xSelectCallback2 = 0;
108986108996
w.u.pNC = pNC;
@@ -108990,11 +109000,11 @@
108990109000
Expr *pExpr = pList->a[i].pExpr;
108991109001
if( pExpr==0 ) continue;
108992109002
#if SQLITE_MAX_EXPR_DEPTH>0
108993109003
w.pParse->nHeight += pExpr->nHeight;
108994109004
if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
108995
- return WRC_Abort;
109005
+ return SQLITE_ERROR;
108996109006
}
108997109007
#endif
108998109008
sqlite3WalkExprNN(&w, pExpr);
108999109009
#if SQLITE_MAX_EXPR_DEPTH>0
109000109010
w.pParse->nHeight -= pExpr->nHeight;
@@ -109007,14 +109017,14 @@
109007109017
ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
109008109018
savedHasAgg |= pNC->ncFlags &
109009109019
(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109010109020
pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109011109021
}
109012
- if( w.pParse->nErr>0 ) return WRC_Abort;
109022
+ if( w.pParse->nErr>0 ) return SQLITE_ERROR;
109013109023
}
109014109024
pNC->ncFlags |= savedHasAgg;
109015
- return WRC_Continue;
109025
+ return SQLITE_OK;
109016109026
}
109017109027
109018109028
/*
109019109029
** Resolve all names in all expressions of a SELECT and in all
109020109030
** descendants of the SELECT, including compounds off of p->pPrior,
@@ -117670,11 +117680,11 @@
117670117680
);
117671117681
pParse->eTriggerOp = pNew->op;
117672117682
/* ALWAYS() because if the table of the trigger does not exist, the
117673117683
** error would have been hit before this point */
117674117684
if( ALWAYS(pParse->pTriggerTab) ){
117675
- rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);
117685
+ rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab)!=0;
117676117686
}
117677117687
117678117688
/* Resolve symbols in WHEN clause */
117679117689
if( rc==SQLITE_OK && pNew->pWhen ){
117680117690
rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
@@ -133821,10 +133831,11 @@
133821133831
if( pRet ){
133822133832
SelectDest dest;
133823133833
pRet->pSrc->nSrc = 1;
133824133834
pRet->pPrior = pLeft->pPrior;
133825133835
pRet->op = pLeft->op;
133836
+ if( pRet->pPrior ) pRet->selFlags |= SF_Values;
133826133837
pLeft->pPrior = 0;
133827133838
pLeft->op = TK_SELECT;
133828133839
assert( pLeft->pNext==0 );
133829133840
assert( pRet->pNext==0 );
133830133841
p = &pRet->pSrc->a[0];
@@ -163938,10 +163949,23 @@
163938163949
pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
163939163950
pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
163940163951
pIdxInfo->aConstraint = pIdxCons;
163941163952
pIdxInfo->aOrderBy = pIdxOrderBy;
163942163953
pIdxInfo->aConstraintUsage = pUsage;
163954
+ pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
163955
+ if( HasRowid(pTab)==0 ){
163956
+ /* Ensure that all bits associated with PK columns are set. This is to
163957
+ ** ensure they are available for cases like RIGHT joins or OR loops. */
163958
+ Index *pPk = sqlite3PrimaryKeyIndex((Table*)pTab);
163959
+ assert( pPk!=0 );
163960
+ for(i=0; i<pPk->nKeyCol; i++){
163961
+ int iCol = pPk->aiColumn[i];
163962
+ assert( iCol>=0 );
163963
+ if( iCol>=BMS-1 ) iCol = BMS-1;
163964
+ pIdxInfo->colUsed |= MASKBIT(iCol);
163965
+ }
163966
+ }
163943163967
pHidden->pWC = pWC;
163944163968
pHidden->pParse = pParse;
163945163969
pHidden->eDistinct = eDistinct;
163946163970
pHidden->mIn = 0;
163947163971
for(p=pWC, i=j=0; p; p=p->pOuter){
@@ -166471,11 +166495,13 @@
166471166495
WHERETRACE(0x200,
166472166496
("-> %s might be a covering expression index"
166473166497
" according to whereIsCoveringIndex()\n", pProbe->zName));
166474166498
}
166475166499
}
166476
- }else if( m==0 ){
166500
+ }else if( m==0
166501
+ && (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
166502
+ ){
166477166503
WHERETRACE(0x200,
166478166504
("-> %s a covering index according to bitmasks\n",
166479166505
pProbe->zName, m==0 ? "is" : "is not"));
166480166506
pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
166481166507
}
@@ -166653,11 +166679,10 @@
166653166679
pIdxInfo->idxNum = 0;
166654166680
pIdxInfo->orderByConsumed = 0;
166655166681
pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;
166656166682
pIdxInfo->estimatedRows = 25;
166657166683
pIdxInfo->idxFlags = 0;
166658
- pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
166659166684
pHidden->mHandleIn = 0;
166660166685
166661166686
/* Invoke the virtual table xBestIndex() method */
166662166687
rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
166663166688
if( rc ){
@@ -169503,30 +169528,10 @@
169503169528
if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
169504169529
sqlite3VdbePrintOp(0, pc, pOp);
169505169530
}
169506169531
#endif
169507169532
169508
-#ifdef SQLITE_DEBUG
169509
-/*
169510
-** Return true if cursor iCur is opened by instruction k of the
169511
-** bytecode. Used inside of assert() only.
169512
-*/
169513
-static int cursorIsOpen(Vdbe *v, int iCur, int k){
169514
- while( k>=0 ){
169515
- VdbeOp *pOp = sqlite3VdbeGetOp(v,k--);
169516
- if( pOp->p1!=iCur ) continue;
169517
- if( pOp->opcode==OP_Close ) return 0;
169518
- if( pOp->opcode==OP_OpenRead ) return 1;
169519
- if( pOp->opcode==OP_OpenWrite ) return 1;
169520
- if( pOp->opcode==OP_OpenDup ) return 1;
169521
- if( pOp->opcode==OP_OpenAutoindex ) return 1;
169522
- if( pOp->opcode==OP_OpenEphemeral ) return 1;
169523
- }
169524
- return 0;
169525
-}
169526
-#endif /* SQLITE_DEBUG */
169527
-
169528169533
/*
169529169534
** Generate the end of the WHERE loop. See comments on
169530169535
** sqlite3WhereBegin() for additional information.
169531169536
*/
169532169537
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
@@ -169822,20 +169827,14 @@
169822169827
}else{
169823169828
/* Unable to translate the table reference into an index
169824169829
** reference. Verify that this is harmless - that the
169825169830
** table being referenced really is open.
169826169831
*/
169827
-#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
169828
- assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
169829
- || cursorIsOpen(v,pOp->p1,k)
169830
- || pOp->opcode==OP_Offset
169831
- );
169832
-#else
169833
- assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
169834
- || cursorIsOpen(v,pOp->p1,k)
169835
- );
169836
-#endif
169832
+ if( pLoop->wsFlags & WHERE_IDX_ONLY ){
169833
+ sqlite3ErrorMsg(pParse, "internal query planner error");
169834
+ pParse->rc = SQLITE_INTERNAL;
169835
+ }
169837169836
}
169838169837
}else if( pOp->opcode==OP_Rowid ){
169839169838
pOp->p1 = pLevel->iIdxCur;
169840169839
pOp->opcode = OP_IdxRowid;
169841169840
OpcodeRewriteTrace(db, k, pOp);
@@ -173102,13 +173101,13 @@
173102173101
pLoop->pOrderBy!=0 ? "ORDER BY" : "LIMIT",
173103173102
sqlite3SelectOpName(pNext->op));
173104173103
break;
173105173104
}
173106173105
}
173107
- if( (p->selFlags & SF_MultiValue)==0 &&
173108
- (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
173109
- cnt>mxSelect
173106
+ if( (p->selFlags & (SF_MultiValue|SF_Values))==0
173107
+ && (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
173108
+ && cnt>mxSelect
173110173109
){
173111173110
sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
173112173111
}
173113173112
}
173114173113
}
@@ -196009,15 +196008,11 @@
196009196008
}
196010196009
196011196010
196012196011
#ifdef SQLITE_TEST
196013196012
196014
-#if defined(INCLUDE_SQLITE_TCL_H)
196015
-# include "sqlite_tcl.h"
196016
-#else
196017
-# include "tcl.h"
196018
-#endif
196013
+#include "tclsqlite.h"
196019196014
/* #include <string.h> */
196020196015
196021196016
/*
196022196017
** Implementation of a special SQL scalar function for testing tokenizers
196023196018
** designed to be used in concert with the Tcl testing framework. This
@@ -203240,10 +203235,11 @@
203240203235
}
203241203236
if( iEnd==0x7FFFFFFF ){
203242203237
return 1;
203243203238
}
203244203239
203240
+ assert( pIter->nSnippet>=0 );
203245203241
pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;
203246203242
for(i=0; i<pIter->nPhrase; i++){
203247203243
SnippetPhrase *pPhrase = &pIter->aPhrase[i];
203248203244
fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);
203249203245
fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);
@@ -239485,10 +239481,13 @@
239485239481
break;
239486239482
};
239487239483
}
239488239484
}
239489239485
239486
+/*
239487
+** Add pSub as a child of p.
239488
+*/
239490239489
static void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){
239491239490
int ii = p->nChild;
239492239491
if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){
239493239492
int nByte = sizeof(Fts5ExprNode*) * pSub->nChild;
239494239493
memcpy(&p->apChild[p->nChild], pSub->apChild, nByte);
@@ -239629,23 +239628,27 @@
239629239628
){
239630239629
sqlite3Fts5ParseError(pParse,
239631239630
"fts5: %s queries are not supported (detail!=full)",
239632239631
pNear->nPhrase==1 ? "phrase": "NEAR"
239633239632
);
239634
- sqlite3_free(pRet);
239633
+ sqlite3Fts5ParseNodeFree(pRet);
239635239634
pRet = 0;
239635
+ pNear = 0;
239636
+ assert( pLeft==0 && pRight==0 );
239636239637
}
239637239638
}
239638239639
}else{
239640
+ assert( pNear==0 );
239639239641
fts5ExprAddChildren(pRet, pLeft);
239640239642
fts5ExprAddChildren(pRet, pRight);
239643
+ pLeft = pRight = 0;
239641239644
if( pRet->iHeight>SQLITE_FTS5_MAX_EXPR_DEPTH ){
239642239645
sqlite3Fts5ParseError(pParse,
239643239646
"fts5 expression tree is too large (maximum depth %d)",
239644239647
SQLITE_FTS5_MAX_EXPR_DEPTH
239645239648
);
239646
- sqlite3_free(pRet);
239649
+ sqlite3Fts5ParseNodeFree(pRet);
239647239650
pRet = 0;
239648239651
}
239649239652
}
239650239653
}
239651239654
}
@@ -239679,10 +239682,11 @@
239679239682
|| pLeft->eType==FTS5_AND
239680239683
);
239681239684
assert( pRight->eType==FTS5_STRING
239682239685
|| pRight->eType==FTS5_TERM
239683239686
|| pRight->eType==FTS5_EOF
239687
+ || (pRight->eType==FTS5_AND && pParse->bPhraseToAnd)
239684239688
);
239685239689
239686239690
if( pLeft->eType==FTS5_AND ){
239687239691
pPrev = pLeft->apChild[pLeft->nChild-1];
239688239692
}else{
@@ -253113,11 +253117,11 @@
253113253117
int nArg, /* Number of args */
253114253118
sqlite3_value **apUnused /* Function arguments */
253115253119
){
253116253120
assert( nArg==0 );
253117253121
UNUSED_PARAM2(nArg, apUnused);
253118
- sqlite3_result_text(pCtx, "fts5: 2024-07-24 13:53:51 bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04", -1, SQLITE_TRANSIENT);
253122
+ sqlite3_result_text(pCtx, "fts5: 2024-08-10 15:46:57 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef", -1, SQLITE_TRANSIENT);
253119253123
}
253120253124
253121253125
/*
253122253126
** Return true if zName is the extension on one of the shadow tables used
253123253127
** by this module.
@@ -254598,11 +254602,11 @@
254598254602
rc = SQLITE_NOMEM;
254599254603
}else{
254600254604
int i;
254601254605
memset(p, 0, sizeof(AsciiTokenizer));
254602254606
memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));
254603
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254607
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254604254608
const char *zArg = azArg[i+1];
254605254609
if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
254606254610
fts5AsciiAddExceptions(p, zArg, 1);
254607254611
}else
254608254612
if( 0==sqlite3_stricmp(azArg[i], "separators") ){
@@ -254609,10 +254613,11 @@
254609254613
fts5AsciiAddExceptions(p, zArg, 0);
254610254614
}else{
254611254615
rc = SQLITE_ERROR;
254612254616
}
254613254617
}
254618
+ if( rc==SQLITE_OK && i<nArg ) rc = SQLITE_ERROR;
254614254619
if( rc!=SQLITE_OK ){
254615254620
fts5AsciiDelete((Fts5Tokenizer*)p);
254616254621
p = 0;
254617254622
}
254618254623
}
@@ -254900,21 +254905,20 @@
254900254905
if( p->aFold==0 ){
254901254906
rc = SQLITE_NOMEM;
254902254907
}
254903254908
254904254909
/* Search for a "categories" argument */
254905
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254910
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254906254911
if( 0==sqlite3_stricmp(azArg[i], "categories") ){
254907254912
zCat = azArg[i+1];
254908254913
}
254909254914
}
254910
-
254911254915
if( rc==SQLITE_OK ){
254912254916
rc = unicodeSetCategories(p, zCat);
254913254917
}
254914254918
254915
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254919
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254916254920
const char *zArg = azArg[i+1];
254917254921
if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
254918254922
if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){
254919254923
rc = SQLITE_ERROR;
254920254924
}else{
@@ -254935,10 +254939,11 @@
254935254939
/* no-op */
254936254940
}else{
254937254941
rc = SQLITE_ERROR;
254938254942
}
254939254943
}
254944
+ if( i<nArg && rc==SQLITE_OK ) rc = SQLITE_ERROR;
254940254945
254941254946
}else{
254942254947
rc = SQLITE_NOMEM;
254943254948
}
254944254949
if( rc!=SQLITE_OK ){
@@ -255817,11 +255822,11 @@
255817255822
rc = SQLITE_NOMEM;
255818255823
}else{
255819255824
int i;
255820255825
pNew->bFold = 1;
255821255826
pNew->iFoldParam = 0;
255822
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
255827
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
255823255828
const char *zArg = azArg[i+1];
255824255829
if( 0==sqlite3_stricmp(azArg[i], "case_sensitive") ){
255825255830
if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
255826255831
rc = SQLITE_ERROR;
255827255832
}else{
@@ -255835,10 +255840,11 @@
255835255840
}
255836255841
}else{
255837255842
rc = SQLITE_ERROR;
255838255843
}
255839255844
}
255845
+ if( i<nArg && rc==SQLITE_OK ) rc = SQLITE_ERROR;
255840255846
255841255847
if( pNew->iFoldParam!=0 && pNew->bFold==0 ){
255842255848
rc = SQLITE_ERROR;
255843255849
}
255844255850
255845255851
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** bcc31846964102385d5a21eb5e85d7db153b.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463 ** [sqlite_version()] and [sqlite_source_id()].
464 */
465 #define SQLITE_VERSION "3.47.0"
466 #define SQLITE_VERSION_NUMBER 3047000
467 #define SQLITE_SOURCE_ID "2024-07-24 13:53:51 bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04"
468
469 /*
470 ** CAPI3REF: Run-Time Library Version Numbers
471 ** KEYWORDS: sqlite3_version sqlite3_sourceid
472 **
@@ -6134,11 +6134,11 @@
6134 ** an [application-defined SQL function] argument V. The subtype
6135 ** information can be used to pass a limited amount of context from
6136 ** one SQL function to another. Use the [sqlite3_result_subtype()]
6137 ** routine to set the subtype for the return value of an SQL function.
6138 **
6139 ** Every [application-defined SQL function] that invoke this interface
6140 ** should include the [SQLITE_SUBTYPE] property in the text
6141 ** encoding argument when the function is [sqlite3_create_function|registered].
6142 ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
6143 ** might return zero instead of the upstream subtype in some corner cases.
6144 */
@@ -18902,13 +18902,19 @@
18902 **
18903 ** These macros should not be used prior to the call to
18904 ** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg.
18905 ** The assert()s that are part of this macro verify that constraint.
18906 */
 
18907 #define AggInfoColumnReg(A,I) (assert((A)->iFirstReg),(A)->iFirstReg+(I))
18908 #define AggInfoFuncReg(A,I) \
18909 (assert((A)->iFirstReg),(A)->iFirstReg+(A)->nColumn+(I))
 
 
 
 
 
18910
18911 /*
18912 ** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
18913 ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater
18914 ** than 32767 we have to make it 32-bit. 16-bit is preferred because
@@ -103447,17 +103453,18 @@
103447 /* The following loop copies up to p->nBuffer bytes per iteration into
103448 ** the p->aAlloc[] buffer. */
103449 while( nRem>0 ){
103450 int rc; /* vdbePmaReadBlob() return code */
103451 int nCopy; /* Number of bytes to copy */
103452 u8 *aNext; /* Pointer to buffer to copy data from */
103453
103454 nCopy = nRem;
103455 if( nRem>p->nBuffer ) nCopy = p->nBuffer;
103456 rc = vdbePmaReadBlob(p, nCopy, &aNext);
103457 if( rc!=SQLITE_OK ) return rc;
103458 assert( aNext!=p->aAlloc );
 
103459 memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);
103460 nRem -= nCopy;
103461 }
103462
103463 *ppOut = p->aAlloc;
@@ -108968,19 +108975,22 @@
108968
108969 /*
108970 ** Resolve all names for all expression in an expression list. This is
108971 ** just like sqlite3ResolveExprNames() except that it works for an expression
108972 ** list rather than a single expression.
 
 
 
108973 */
108974 SQLITE_PRIVATE int sqlite3ResolveExprListNames(
108975 NameContext *pNC, /* Namespace to resolve expressions in. */
108976 ExprList *pList /* The expression list to be analyzed. */
108977 ){
108978 int i;
108979 int savedHasAgg = 0;
108980 Walker w;
108981 if( pList==0 ) return WRC_Continue;
108982 w.pParse = pNC->pParse;
108983 w.xExprCallback = resolveExprStep;
108984 w.xSelectCallback = resolveSelectStep;
108985 w.xSelectCallback2 = 0;
108986 w.u.pNC = pNC;
@@ -108990,11 +109000,11 @@
108990 Expr *pExpr = pList->a[i].pExpr;
108991 if( pExpr==0 ) continue;
108992 #if SQLITE_MAX_EXPR_DEPTH>0
108993 w.pParse->nHeight += pExpr->nHeight;
108994 if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
108995 return WRC_Abort;
108996 }
108997 #endif
108998 sqlite3WalkExprNN(&w, pExpr);
108999 #if SQLITE_MAX_EXPR_DEPTH>0
109000 w.pParse->nHeight -= pExpr->nHeight;
@@ -109007,14 +109017,14 @@
109007 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
109008 savedHasAgg |= pNC->ncFlags &
109009 (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109010 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109011 }
109012 if( w.pParse->nErr>0 ) return WRC_Abort;
109013 }
109014 pNC->ncFlags |= savedHasAgg;
109015 return WRC_Continue;
109016 }
109017
109018 /*
109019 ** Resolve all names in all expressions of a SELECT and in all
109020 ** descendants of the SELECT, including compounds off of p->pPrior,
@@ -117670,11 +117680,11 @@
117670 );
117671 pParse->eTriggerOp = pNew->op;
117672 /* ALWAYS() because if the table of the trigger does not exist, the
117673 ** error would have been hit before this point */
117674 if( ALWAYS(pParse->pTriggerTab) ){
117675 rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);
117676 }
117677
117678 /* Resolve symbols in WHEN clause */
117679 if( rc==SQLITE_OK && pNew->pWhen ){
117680 rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
@@ -133821,10 +133831,11 @@
133821 if( pRet ){
133822 SelectDest dest;
133823 pRet->pSrc->nSrc = 1;
133824 pRet->pPrior = pLeft->pPrior;
133825 pRet->op = pLeft->op;
 
133826 pLeft->pPrior = 0;
133827 pLeft->op = TK_SELECT;
133828 assert( pLeft->pNext==0 );
133829 assert( pRet->pNext==0 );
133830 p = &pRet->pSrc->a[0];
@@ -163938,10 +163949,23 @@
163938 pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
163939 pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
163940 pIdxInfo->aConstraint = pIdxCons;
163941 pIdxInfo->aOrderBy = pIdxOrderBy;
163942 pIdxInfo->aConstraintUsage = pUsage;
 
 
 
 
 
 
 
 
 
 
 
 
 
163943 pHidden->pWC = pWC;
163944 pHidden->pParse = pParse;
163945 pHidden->eDistinct = eDistinct;
163946 pHidden->mIn = 0;
163947 for(p=pWC, i=j=0; p; p=p->pOuter){
@@ -166471,11 +166495,13 @@
166471 WHERETRACE(0x200,
166472 ("-> %s might be a covering expression index"
166473 " according to whereIsCoveringIndex()\n", pProbe->zName));
166474 }
166475 }
166476 }else if( m==0 ){
 
 
166477 WHERETRACE(0x200,
166478 ("-> %s a covering index according to bitmasks\n",
166479 pProbe->zName, m==0 ? "is" : "is not"));
166480 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
166481 }
@@ -166653,11 +166679,10 @@
166653 pIdxInfo->idxNum = 0;
166654 pIdxInfo->orderByConsumed = 0;
166655 pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;
166656 pIdxInfo->estimatedRows = 25;
166657 pIdxInfo->idxFlags = 0;
166658 pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
166659 pHidden->mHandleIn = 0;
166660
166661 /* Invoke the virtual table xBestIndex() method */
166662 rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
166663 if( rc ){
@@ -169503,30 +169528,10 @@
169503 if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
169504 sqlite3VdbePrintOp(0, pc, pOp);
169505 }
169506 #endif
169507
169508 #ifdef SQLITE_DEBUG
169509 /*
169510 ** Return true if cursor iCur is opened by instruction k of the
169511 ** bytecode. Used inside of assert() only.
169512 */
169513 static int cursorIsOpen(Vdbe *v, int iCur, int k){
169514 while( k>=0 ){
169515 VdbeOp *pOp = sqlite3VdbeGetOp(v,k--);
169516 if( pOp->p1!=iCur ) continue;
169517 if( pOp->opcode==OP_Close ) return 0;
169518 if( pOp->opcode==OP_OpenRead ) return 1;
169519 if( pOp->opcode==OP_OpenWrite ) return 1;
169520 if( pOp->opcode==OP_OpenDup ) return 1;
169521 if( pOp->opcode==OP_OpenAutoindex ) return 1;
169522 if( pOp->opcode==OP_OpenEphemeral ) return 1;
169523 }
169524 return 0;
169525 }
169526 #endif /* SQLITE_DEBUG */
169527
169528 /*
169529 ** Generate the end of the WHERE loop. See comments on
169530 ** sqlite3WhereBegin() for additional information.
169531 */
169532 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
@@ -169822,20 +169827,14 @@
169822 }else{
169823 /* Unable to translate the table reference into an index
169824 ** reference. Verify that this is harmless - that the
169825 ** table being referenced really is open.
169826 */
169827 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
169828 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
169829 || cursorIsOpen(v,pOp->p1,k)
169830 || pOp->opcode==OP_Offset
169831 );
169832 #else
169833 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
169834 || cursorIsOpen(v,pOp->p1,k)
169835 );
169836 #endif
169837 }
169838 }else if( pOp->opcode==OP_Rowid ){
169839 pOp->p1 = pLevel->iIdxCur;
169840 pOp->opcode = OP_IdxRowid;
169841 OpcodeRewriteTrace(db, k, pOp);
@@ -173102,13 +173101,13 @@
173102 pLoop->pOrderBy!=0 ? "ORDER BY" : "LIMIT",
173103 sqlite3SelectOpName(pNext->op));
173104 break;
173105 }
173106 }
173107 if( (p->selFlags & SF_MultiValue)==0 &&
173108 (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
173109 cnt>mxSelect
173110 ){
173111 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
173112 }
173113 }
173114 }
@@ -196009,15 +196008,11 @@
196009 }
196010
196011
196012 #ifdef SQLITE_TEST
196013
196014 #if defined(INCLUDE_SQLITE_TCL_H)
196015 # include "sqlite_tcl.h"
196016 #else
196017 # include "tcl.h"
196018 #endif
196019 /* #include <string.h> */
196020
196021 /*
196022 ** Implementation of a special SQL scalar function for testing tokenizers
196023 ** designed to be used in concert with the Tcl testing framework. This
@@ -203240,10 +203235,11 @@
203240 }
203241 if( iEnd==0x7FFFFFFF ){
203242 return 1;
203243 }
203244
 
203245 pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;
203246 for(i=0; i<pIter->nPhrase; i++){
203247 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
203248 fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);
203249 fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);
@@ -239485,10 +239481,13 @@
239485 break;
239486 };
239487 }
239488 }
239489
 
 
 
239490 static void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){
239491 int ii = p->nChild;
239492 if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){
239493 int nByte = sizeof(Fts5ExprNode*) * pSub->nChild;
239494 memcpy(&p->apChild[p->nChild], pSub->apChild, nByte);
@@ -239629,23 +239628,27 @@
239629 ){
239630 sqlite3Fts5ParseError(pParse,
239631 "fts5: %s queries are not supported (detail!=full)",
239632 pNear->nPhrase==1 ? "phrase": "NEAR"
239633 );
239634 sqlite3_free(pRet);
239635 pRet = 0;
 
 
239636 }
239637 }
239638 }else{
 
239639 fts5ExprAddChildren(pRet, pLeft);
239640 fts5ExprAddChildren(pRet, pRight);
 
239641 if( pRet->iHeight>SQLITE_FTS5_MAX_EXPR_DEPTH ){
239642 sqlite3Fts5ParseError(pParse,
239643 "fts5 expression tree is too large (maximum depth %d)",
239644 SQLITE_FTS5_MAX_EXPR_DEPTH
239645 );
239646 sqlite3_free(pRet);
239647 pRet = 0;
239648 }
239649 }
239650 }
239651 }
@@ -239679,10 +239682,11 @@
239679 || pLeft->eType==FTS5_AND
239680 );
239681 assert( pRight->eType==FTS5_STRING
239682 || pRight->eType==FTS5_TERM
239683 || pRight->eType==FTS5_EOF
 
239684 );
239685
239686 if( pLeft->eType==FTS5_AND ){
239687 pPrev = pLeft->apChild[pLeft->nChild-1];
239688 }else{
@@ -253113,11 +253117,11 @@
253113 int nArg, /* Number of args */
253114 sqlite3_value **apUnused /* Function arguments */
253115 ){
253116 assert( nArg==0 );
253117 UNUSED_PARAM2(nArg, apUnused);
253118 sqlite3_result_text(pCtx, "fts5: 2024-07-24 13:53:51 bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04", -1, SQLITE_TRANSIENT);
253119 }
253120
253121 /*
253122 ** Return true if zName is the extension on one of the shadow tables used
253123 ** by this module.
@@ -254598,11 +254602,11 @@
254598 rc = SQLITE_NOMEM;
254599 }else{
254600 int i;
254601 memset(p, 0, sizeof(AsciiTokenizer));
254602 memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));
254603 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254604 const char *zArg = azArg[i+1];
254605 if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
254606 fts5AsciiAddExceptions(p, zArg, 1);
254607 }else
254608 if( 0==sqlite3_stricmp(azArg[i], "separators") ){
@@ -254609,10 +254613,11 @@
254609 fts5AsciiAddExceptions(p, zArg, 0);
254610 }else{
254611 rc = SQLITE_ERROR;
254612 }
254613 }
 
254614 if( rc!=SQLITE_OK ){
254615 fts5AsciiDelete((Fts5Tokenizer*)p);
254616 p = 0;
254617 }
254618 }
@@ -254900,21 +254905,20 @@
254900 if( p->aFold==0 ){
254901 rc = SQLITE_NOMEM;
254902 }
254903
254904 /* Search for a "categories" argument */
254905 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254906 if( 0==sqlite3_stricmp(azArg[i], "categories") ){
254907 zCat = azArg[i+1];
254908 }
254909 }
254910
254911 if( rc==SQLITE_OK ){
254912 rc = unicodeSetCategories(p, zCat);
254913 }
254914
254915 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254916 const char *zArg = azArg[i+1];
254917 if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
254918 if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){
254919 rc = SQLITE_ERROR;
254920 }else{
@@ -254935,10 +254939,11 @@
254935 /* no-op */
254936 }else{
254937 rc = SQLITE_ERROR;
254938 }
254939 }
 
254940
254941 }else{
254942 rc = SQLITE_NOMEM;
254943 }
254944 if( rc!=SQLITE_OK ){
@@ -255817,11 +255822,11 @@
255817 rc = SQLITE_NOMEM;
255818 }else{
255819 int i;
255820 pNew->bFold = 1;
255821 pNew->iFoldParam = 0;
255822 for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
255823 const char *zArg = azArg[i+1];
255824 if( 0==sqlite3_stricmp(azArg[i], "case_sensitive") ){
255825 if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
255826 rc = SQLITE_ERROR;
255827 }else{
@@ -255835,10 +255840,11 @@
255835 }
255836 }else{
255837 rc = SQLITE_ERROR;
255838 }
255839 }
 
255840
255841 if( pNew->iFoldParam!=0 && pNew->bFold==0 ){
255842 rc = SQLITE_ERROR;
255843 }
255844
255845
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a8.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463 ** [sqlite_version()] and [sqlite_source_id()].
464 */
465 #define SQLITE_VERSION "3.47.0"
466 #define SQLITE_VERSION_NUMBER 3047000
467 #define SQLITE_SOURCE_ID "2024-08-10 15:46:57 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef"
468
469 /*
470 ** CAPI3REF: Run-Time Library Version Numbers
471 ** KEYWORDS: sqlite3_version sqlite3_sourceid
472 **
@@ -6134,11 +6134,11 @@
6134 ** an [application-defined SQL function] argument V. The subtype
6135 ** information can be used to pass a limited amount of context from
6136 ** one SQL function to another. Use the [sqlite3_result_subtype()]
6137 ** routine to set the subtype for the return value of an SQL function.
6138 **
6139 ** Every [application-defined SQL function] that invokes this interface
6140 ** should include the [SQLITE_SUBTYPE] property in the text
6141 ** encoding argument when the function is [sqlite3_create_function|registered].
6142 ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
6143 ** might return zero instead of the upstream subtype in some corner cases.
6144 */
@@ -18902,13 +18902,19 @@
18902 **
18903 ** These macros should not be used prior to the call to
18904 ** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg.
18905 ** The assert()s that are part of this macro verify that constraint.
18906 */
18907 #ifndef NDEBUG
18908 #define AggInfoColumnReg(A,I) (assert((A)->iFirstReg),(A)->iFirstReg+(I))
18909 #define AggInfoFuncReg(A,I) \
18910 (assert((A)->iFirstReg),(A)->iFirstReg+(A)->nColumn+(I))
18911 #else
18912 #define AggInfoColumnReg(A,I) ((A)->iFirstReg+(I))
18913 #define AggInfoFuncReg(A,I) \
18914 ((A)->iFirstReg+(A)->nColumn+(I))
18915 #endif
18916
18917 /*
18918 ** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
18919 ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater
18920 ** than 32767 we have to make it 32-bit. 16-bit is preferred because
@@ -103447,17 +103453,18 @@
103453 /* The following loop copies up to p->nBuffer bytes per iteration into
103454 ** the p->aAlloc[] buffer. */
103455 while( nRem>0 ){
103456 int rc; /* vdbePmaReadBlob() return code */
103457 int nCopy; /* Number of bytes to copy */
103458 u8 *aNext = 0; /* Pointer to buffer to copy data from */
103459
103460 nCopy = nRem;
103461 if( nRem>p->nBuffer ) nCopy = p->nBuffer;
103462 rc = vdbePmaReadBlob(p, nCopy, &aNext);
103463 if( rc!=SQLITE_OK ) return rc;
103464 assert( aNext!=p->aAlloc );
103465 assert( aNext!=0 );
103466 memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);
103467 nRem -= nCopy;
103468 }
103469
103470 *ppOut = p->aAlloc;
@@ -108968,19 +108975,22 @@
108975
108976 /*
108977 ** Resolve all names for all expression in an expression list. This is
108978 ** just like sqlite3ResolveExprNames() except that it works for an expression
108979 ** list rather than a single expression.
108980 **
108981 ** The return value is SQLITE_OK (0) for success or SQLITE_ERROR (1) for a
108982 ** failure.
108983 */
108984 SQLITE_PRIVATE int sqlite3ResolveExprListNames(
108985 NameContext *pNC, /* Namespace to resolve expressions in. */
108986 ExprList *pList /* The expression list to be analyzed. */
108987 ){
108988 int i;
108989 int savedHasAgg = 0;
108990 Walker w;
108991 if( pList==0 ) return SQLITE_OK;
108992 w.pParse = pNC->pParse;
108993 w.xExprCallback = resolveExprStep;
108994 w.xSelectCallback = resolveSelectStep;
108995 w.xSelectCallback2 = 0;
108996 w.u.pNC = pNC;
@@ -108990,11 +109000,11 @@
109000 Expr *pExpr = pList->a[i].pExpr;
109001 if( pExpr==0 ) continue;
109002 #if SQLITE_MAX_EXPR_DEPTH>0
109003 w.pParse->nHeight += pExpr->nHeight;
109004 if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
109005 return SQLITE_ERROR;
109006 }
109007 #endif
109008 sqlite3WalkExprNN(&w, pExpr);
109009 #if SQLITE_MAX_EXPR_DEPTH>0
109010 w.pParse->nHeight -= pExpr->nHeight;
@@ -109007,14 +109017,14 @@
109017 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
109018 savedHasAgg |= pNC->ncFlags &
109019 (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109020 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109021 }
109022 if( w.pParse->nErr>0 ) return SQLITE_ERROR;
109023 }
109024 pNC->ncFlags |= savedHasAgg;
109025 return SQLITE_OK;
109026 }
109027
109028 /*
109029 ** Resolve all names in all expressions of a SELECT and in all
109030 ** descendants of the SELECT, including compounds off of p->pPrior,
@@ -117670,11 +117680,11 @@
117680 );
117681 pParse->eTriggerOp = pNew->op;
117682 /* ALWAYS() because if the table of the trigger does not exist, the
117683 ** error would have been hit before this point */
117684 if( ALWAYS(pParse->pTriggerTab) ){
117685 rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab)!=0;
117686 }
117687
117688 /* Resolve symbols in WHEN clause */
117689 if( rc==SQLITE_OK && pNew->pWhen ){
117690 rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
@@ -133821,10 +133831,11 @@
133831 if( pRet ){
133832 SelectDest dest;
133833 pRet->pSrc->nSrc = 1;
133834 pRet->pPrior = pLeft->pPrior;
133835 pRet->op = pLeft->op;
133836 if( pRet->pPrior ) pRet->selFlags |= SF_Values;
133837 pLeft->pPrior = 0;
133838 pLeft->op = TK_SELECT;
133839 assert( pLeft->pNext==0 );
133840 assert( pRet->pNext==0 );
133841 p = &pRet->pSrc->a[0];
@@ -163938,10 +163949,23 @@
163949 pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
163950 pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
163951 pIdxInfo->aConstraint = pIdxCons;
163952 pIdxInfo->aOrderBy = pIdxOrderBy;
163953 pIdxInfo->aConstraintUsage = pUsage;
163954 pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
163955 if( HasRowid(pTab)==0 ){
163956 /* Ensure that all bits associated with PK columns are set. This is to
163957 ** ensure they are available for cases like RIGHT joins or OR loops. */
163958 Index *pPk = sqlite3PrimaryKeyIndex((Table*)pTab);
163959 assert( pPk!=0 );
163960 for(i=0; i<pPk->nKeyCol; i++){
163961 int iCol = pPk->aiColumn[i];
163962 assert( iCol>=0 );
163963 if( iCol>=BMS-1 ) iCol = BMS-1;
163964 pIdxInfo->colUsed |= MASKBIT(iCol);
163965 }
163966 }
163967 pHidden->pWC = pWC;
163968 pHidden->pParse = pParse;
163969 pHidden->eDistinct = eDistinct;
163970 pHidden->mIn = 0;
163971 for(p=pWC, i=j=0; p; p=p->pOuter){
@@ -166471,11 +166495,13 @@
166495 WHERETRACE(0x200,
166496 ("-> %s might be a covering expression index"
166497 " according to whereIsCoveringIndex()\n", pProbe->zName));
166498 }
166499 }
166500 }else if( m==0
166501 && (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
166502 ){
166503 WHERETRACE(0x200,
166504 ("-> %s a covering index according to bitmasks\n",
166505 pProbe->zName, m==0 ? "is" : "is not"));
166506 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
166507 }
@@ -166653,11 +166679,10 @@
166679 pIdxInfo->idxNum = 0;
166680 pIdxInfo->orderByConsumed = 0;
166681 pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;
166682 pIdxInfo->estimatedRows = 25;
166683 pIdxInfo->idxFlags = 0;
 
166684 pHidden->mHandleIn = 0;
166685
166686 /* Invoke the virtual table xBestIndex() method */
166687 rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
166688 if( rc ){
@@ -169503,30 +169528,10 @@
169528 if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
169529 sqlite3VdbePrintOp(0, pc, pOp);
169530 }
169531 #endif
169532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169533 /*
169534 ** Generate the end of the WHERE loop. See comments on
169535 ** sqlite3WhereBegin() for additional information.
169536 */
169537 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
@@ -169822,20 +169827,14 @@
169827 }else{
169828 /* Unable to translate the table reference into an index
169829 ** reference. Verify that this is harmless - that the
169830 ** table being referenced really is open.
169831 */
169832 if( pLoop->wsFlags & WHERE_IDX_ONLY ){
169833 sqlite3ErrorMsg(pParse, "internal query planner error");
169834 pParse->rc = SQLITE_INTERNAL;
169835 }
 
 
 
 
 
 
169836 }
169837 }else if( pOp->opcode==OP_Rowid ){
169838 pOp->p1 = pLevel->iIdxCur;
169839 pOp->opcode = OP_IdxRowid;
169840 OpcodeRewriteTrace(db, k, pOp);
@@ -173102,13 +173101,13 @@
173101 pLoop->pOrderBy!=0 ? "ORDER BY" : "LIMIT",
173102 sqlite3SelectOpName(pNext->op));
173103 break;
173104 }
173105 }
173106 if( (p->selFlags & (SF_MultiValue|SF_Values))==0
173107 && (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
173108 && cnt>mxSelect
173109 ){
173110 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
173111 }
173112 }
173113 }
@@ -196009,15 +196008,11 @@
196008 }
196009
196010
196011 #ifdef SQLITE_TEST
196012
196013 #include "tclsqlite.h"
 
 
 
 
196014 /* #include <string.h> */
196015
196016 /*
196017 ** Implementation of a special SQL scalar function for testing tokenizers
196018 ** designed to be used in concert with the Tcl testing framework. This
@@ -203240,10 +203235,11 @@
203235 }
203236 if( iEnd==0x7FFFFFFF ){
203237 return 1;
203238 }
203239
203240 assert( pIter->nSnippet>=0 );
203241 pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;
203242 for(i=0; i<pIter->nPhrase; i++){
203243 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
203244 fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);
203245 fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);
@@ -239485,10 +239481,13 @@
239481 break;
239482 };
239483 }
239484 }
239485
239486 /*
239487 ** Add pSub as a child of p.
239488 */
239489 static void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){
239490 int ii = p->nChild;
239491 if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){
239492 int nByte = sizeof(Fts5ExprNode*) * pSub->nChild;
239493 memcpy(&p->apChild[p->nChild], pSub->apChild, nByte);
@@ -239629,23 +239628,27 @@
239628 ){
239629 sqlite3Fts5ParseError(pParse,
239630 "fts5: %s queries are not supported (detail!=full)",
239631 pNear->nPhrase==1 ? "phrase": "NEAR"
239632 );
239633 sqlite3Fts5ParseNodeFree(pRet);
239634 pRet = 0;
239635 pNear = 0;
239636 assert( pLeft==0 && pRight==0 );
239637 }
239638 }
239639 }else{
239640 assert( pNear==0 );
239641 fts5ExprAddChildren(pRet, pLeft);
239642 fts5ExprAddChildren(pRet, pRight);
239643 pLeft = pRight = 0;
239644 if( pRet->iHeight>SQLITE_FTS5_MAX_EXPR_DEPTH ){
239645 sqlite3Fts5ParseError(pParse,
239646 "fts5 expression tree is too large (maximum depth %d)",
239647 SQLITE_FTS5_MAX_EXPR_DEPTH
239648 );
239649 sqlite3Fts5ParseNodeFree(pRet);
239650 pRet = 0;
239651 }
239652 }
239653 }
239654 }
@@ -239679,10 +239682,11 @@
239682 || pLeft->eType==FTS5_AND
239683 );
239684 assert( pRight->eType==FTS5_STRING
239685 || pRight->eType==FTS5_TERM
239686 || pRight->eType==FTS5_EOF
239687 || (pRight->eType==FTS5_AND && pParse->bPhraseToAnd)
239688 );
239689
239690 if( pLeft->eType==FTS5_AND ){
239691 pPrev = pLeft->apChild[pLeft->nChild-1];
239692 }else{
@@ -253113,11 +253117,11 @@
253117 int nArg, /* Number of args */
253118 sqlite3_value **apUnused /* Function arguments */
253119 ){
253120 assert( nArg==0 );
253121 UNUSED_PARAM2(nArg, apUnused);
253122 sqlite3_result_text(pCtx, "fts5: 2024-08-10 15:46:57 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef", -1, SQLITE_TRANSIENT);
253123 }
253124
253125 /*
253126 ** Return true if zName is the extension on one of the shadow tables used
253127 ** by this module.
@@ -254598,11 +254602,11 @@
254602 rc = SQLITE_NOMEM;
254603 }else{
254604 int i;
254605 memset(p, 0, sizeof(AsciiTokenizer));
254606 memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));
254607 for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254608 const char *zArg = azArg[i+1];
254609 if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
254610 fts5AsciiAddExceptions(p, zArg, 1);
254611 }else
254612 if( 0==sqlite3_stricmp(azArg[i], "separators") ){
@@ -254609,10 +254613,11 @@
254613 fts5AsciiAddExceptions(p, zArg, 0);
254614 }else{
254615 rc = SQLITE_ERROR;
254616 }
254617 }
254618 if( rc==SQLITE_OK && i<nArg ) rc = SQLITE_ERROR;
254619 if( rc!=SQLITE_OK ){
254620 fts5AsciiDelete((Fts5Tokenizer*)p);
254621 p = 0;
254622 }
254623 }
@@ -254900,21 +254905,20 @@
254905 if( p->aFold==0 ){
254906 rc = SQLITE_NOMEM;
254907 }
254908
254909 /* Search for a "categories" argument */
254910 for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254911 if( 0==sqlite3_stricmp(azArg[i], "categories") ){
254912 zCat = azArg[i+1];
254913 }
254914 }
 
254915 if( rc==SQLITE_OK ){
254916 rc = unicodeSetCategories(p, zCat);
254917 }
254918
254919 for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254920 const char *zArg = azArg[i+1];
254921 if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
254922 if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){
254923 rc = SQLITE_ERROR;
254924 }else{
@@ -254935,10 +254939,11 @@
254939 /* no-op */
254940 }else{
254941 rc = SQLITE_ERROR;
254942 }
254943 }
254944 if( i<nArg && rc==SQLITE_OK ) rc = SQLITE_ERROR;
254945
254946 }else{
254947 rc = SQLITE_NOMEM;
254948 }
254949 if( rc!=SQLITE_OK ){
@@ -255817,11 +255822,11 @@
255822 rc = SQLITE_NOMEM;
255823 }else{
255824 int i;
255825 pNew->bFold = 1;
255826 pNew->iFoldParam = 0;
255827 for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
255828 const char *zArg = azArg[i+1];
255829 if( 0==sqlite3_stricmp(azArg[i], "case_sensitive") ){
255830 if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
255831 rc = SQLITE_ERROR;
255832 }else{
@@ -255835,10 +255840,11 @@
255840 }
255841 }else{
255842 rc = SQLITE_ERROR;
255843 }
255844 }
255845 if( i<nArg && rc==SQLITE_OK ) rc = SQLITE_ERROR;
255846
255847 if( pNew->iFoldParam!=0 && pNew->bFold==0 ){
255848 rc = SQLITE_ERROR;
255849 }
255850
255851
--- 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.47.0"
150150
#define SQLITE_VERSION_NUMBER 3047000
151
-#define SQLITE_SOURCE_ID "2024-07-24 13:53:51 bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04"
151
+#define SQLITE_SOURCE_ID "2024-08-10 15:46:57 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -5818,11 +5818,11 @@
58185818
** an [application-defined SQL function] argument V. The subtype
58195819
** information can be used to pass a limited amount of context from
58205820
** one SQL function to another. Use the [sqlite3_result_subtype()]
58215821
** routine to set the subtype for the return value of an SQL function.
58225822
**
5823
-** Every [application-defined SQL function] that invoke this interface
5823
+** Every [application-defined SQL function] that invokes this interface
58245824
** should include the [SQLITE_SUBTYPE] property in the text
58255825
** encoding argument when the function is [sqlite3_create_function|registered].
58265826
** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
58275827
** might return zero instead of the upstream subtype in some corner cases.
58285828
*/
58295829
--- 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.47.0"
150 #define SQLITE_VERSION_NUMBER 3047000
151 #define SQLITE_SOURCE_ID "2024-07-24 13:53:51 bcc31846964102385d5a21eb5e85d7db153b155e76b4e2847c9453d3d0e1af04"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -5818,11 +5818,11 @@
5818 ** an [application-defined SQL function] argument V. The subtype
5819 ** information can be used to pass a limited amount of context from
5820 ** one SQL function to another. Use the [sqlite3_result_subtype()]
5821 ** routine to set the subtype for the return value of an SQL function.
5822 **
5823 ** Every [application-defined SQL function] that invoke this interface
5824 ** should include the [SQLITE_SUBTYPE] property in the text
5825 ** encoding argument when the function is [sqlite3_create_function|registered].
5826 ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
5827 ** might return zero instead of the upstream subtype in some corner cases.
5828 */
5829
--- 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.47.0"
150 #define SQLITE_VERSION_NUMBER 3047000
151 #define SQLITE_SOURCE_ID "2024-08-10 15:46:57 3778b2a9ca1cc12a88ef6c32a1ee7c58a0a829ed9715a3d32a225d377d7527ef"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -5818,11 +5818,11 @@
5818 ** an [application-defined SQL function] argument V. The subtype
5819 ** information can be used to pass a limited amount of context from
5820 ** one SQL function to another. Use the [sqlite3_result_subtype()]
5821 ** routine to set the subtype for the return value of an SQL function.
5822 **
5823 ** Every [application-defined SQL function] that invokes this interface
5824 ** should include the [SQLITE_SUBTYPE] property in the text
5825 ** encoding argument when the function is [sqlite3_create_function|registered].
5826 ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
5827 ** might return zero instead of the upstream subtype in some corner cases.
5828 */
5829

Keyboard Shortcuts

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