1
1
/******************************************************************************
2
2
** This file is an amalgamation of many separate C source files from SQLite
3
- ** version 3.49.1 . By combining all the individual C code files into this
3
+ ** version 3.49.2 . By combining all the individual C code files into this
4
4
** single large file, the entire code can be compiled as a single translation
5
5
** unit. This allows many compilers to do optimizations that would not be
6
6
** possible if the files were compiled separately. Performance improvements
18
18
** separate file. This file contains only code for the core SQLite library.
19
19
**
20
20
** The content in this amalgamation comes from Fossil check-in
21
- ** 873d4e274b4988d260ba8354a9718324a1c2 with changes in files:
21
+ ** 17144570b0d96ae63cd6f3edca39e27ebd74 with changes in files:
22
22
**
23
23
**
24
24
*/
@@ -465,9 +465,9 @@ extern "C" {
465
465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466
466
** [sqlite_version()] and [sqlite_source_id()].
467
467
*/
468
- #define SQLITE_VERSION "3.49.1 "
469
- #define SQLITE_VERSION_NUMBER 3049001
470
- #define SQLITE_SOURCE_ID "2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70 "
468
+ #define SQLITE_VERSION "3.49.2 "
469
+ #define SQLITE_VERSION_NUMBER 3049002
470
+ #define SQLITE_SOURCE_ID "2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b4861fb1 "
471
471
472
472
/*
473
473
** CAPI3REF: Run-Time Library Version Numbers
@@ -19064,6 +19064,7 @@ struct Index {
19064
19064
unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
19065
19065
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
19066
19066
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19067
+ unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
19067
19068
unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
19068
19069
unsigned bHasExpr:1; /* Index contains an expression, either a literal
19069
19070
** expression, or a reference to a VIRTUAL column */
@@ -97241,6 +97242,7 @@ case OP_MakeRecord: {
97241
97242
zHdr += sqlite3PutVarint(zHdr, serial_type);
97242
97243
if( pRec->n ){
97243
97244
assert( pRec->z!=0 );
97245
+ assert( pRec->z!=(const char*)sqlite3CtypeMap );
97244
97246
memcpy(zPayload, pRec->z, pRec->n);
97245
97247
zPayload += pRec->n;
97246
97248
}
@@ -115468,11 +115470,11 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
115468
115470
assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL );
115469
115471
assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
115470
115472
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
115471
- sqlite3VdbeTypeofColumn(v, r1);
115473
+ assert( regFree1==0 || regFree1==r1 );
115474
+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
115472
115475
sqlite3VdbeAddOp2(v, op, r1, dest);
115473
115476
VdbeCoverageIf(v, op==TK_ISNULL);
115474
115477
VdbeCoverageIf(v, op==TK_NOTNULL);
115475
- testcase( regFree1==0 );
115476
115478
break;
115477
115479
}
115478
115480
case TK_BETWEEN: {
@@ -115643,11 +115645,11 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
115643
115645
case TK_ISNULL:
115644
115646
case TK_NOTNULL: {
115645
115647
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
115646
- sqlite3VdbeTypeofColumn(v, r1);
115648
+ assert( regFree1==0 || regFree1==r1 );
115649
+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
115647
115650
sqlite3VdbeAddOp2(v, op, r1, dest);
115648
115651
testcase( op==TK_ISNULL ); VdbeCoverageIf(v, op==TK_ISNULL);
115649
115652
testcase( op==TK_NOTNULL ); VdbeCoverageIf(v, op==TK_NOTNULL);
115650
- testcase( regFree1==0 );
115651
115653
break;
115652
115654
}
115653
115655
case TK_BETWEEN: {
@@ -126336,6 +126338,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126336
126338
assert( j<=0x7fff );
126337
126339
if( j<0 ){
126338
126340
j = pTab->iPKey;
126341
+ pIndex->bIdxRowid = 1;
126339
126342
}else{
126340
126343
if( pTab->aCol[j].notNull==0 ){
126341
126344
pIndex->uniqNotNull = 0;
@@ -139132,48 +139135,48 @@ static const char *const pragCName[] = {
139132
139135
/* 13 */ "pk",
139133
139136
/* 14 */ "hidden",
139134
139137
/* table_info reuses 8 */
139135
- /* 15 */ "schema ", /* Used by: table_list */
139136
- /* 16 */ "name ",
139138
+ /* 15 */ "name ", /* Used by: function_list */
139139
+ /* 16 */ "builtin ",
139137
139140
/* 17 */ "type",
139138
- /* 18 */ "ncol ",
139139
- /* 19 */ "wr ",
139140
- /* 20 */ "strict ",
139141
- /* 21 */ "seqno ", /* Used by: index_xinfo */
139142
- /* 22 */ "cid ",
139143
- /* 23 */ "name ",
139144
- /* 24 */ "desc ",
139145
- /* 25 */ "coll ",
139146
- /* 26 */ "key ",
139147
- /* 27 */ "name ", /* Used by: function_list */
139148
- /* 28 */ "builtin ",
139149
- /* 29 */ "type ",
139150
- /* 30 */ "enc ",
139151
- /* 31 */ "narg ",
139152
- /* 32 */ "flags ",
139153
- /* 33 */ "tbl ", /* Used by: stats */
139154
- /* 34 */ "idx ",
139155
- /* 35 */ "wdth ",
139156
- /* 36 */ "hght ",
139157
- /* 37 */ "flgs ",
139158
- /* 38 */ "seq ", /* Used by: index_list */
139159
- /* 39 */ "name ",
139160
- /* 40 */ "unique ",
139161
- /* 41 */ "origin ",
139162
- /* 42 */ "partial ",
139141
+ /* 18 */ "enc ",
139142
+ /* 19 */ "narg ",
139143
+ /* 20 */ "flags ",
139144
+ /* 21 */ "schema ", /* Used by: table_list */
139145
+ /* 22 */ "name ",
139146
+ /* 23 */ "type ",
139147
+ /* 24 */ "ncol ",
139148
+ /* 25 */ "wr ",
139149
+ /* 26 */ "strict ",
139150
+ /* 27 */ "seqno ", /* Used by: index_xinfo */
139151
+ /* 28 */ "cid ",
139152
+ /* 29 */ "name ",
139153
+ /* 30 */ "desc ",
139154
+ /* 31 */ "coll ",
139155
+ /* 32 */ "key ",
139156
+ /* 33 */ "seq ", /* Used by: index_list */
139157
+ /* 34 */ "name ",
139158
+ /* 35 */ "unique ",
139159
+ /* 36 */ "origin ",
139160
+ /* 37 */ "partial ",
139161
+ /* 38 */ "tbl ", /* Used by: stats */
139162
+ /* 39 */ "idx ",
139163
+ /* 40 */ "wdth ",
139164
+ /* 41 */ "hght ",
139165
+ /* 42 */ "flgs ",
139163
139166
/* 43 */ "table", /* Used by: foreign_key_check */
139164
139167
/* 44 */ "rowid",
139165
139168
/* 45 */ "parent",
139166
139169
/* 46 */ "fkid",
139167
- /* index_info reuses 21 */
139168
- /* 47 */ "seq", /* Used by: database_list */
139169
- /* 48 */ "name",
139170
- /* 49 */ "file",
139171
- /* 50 */ "busy", /* Used by: wal_checkpoint */
139172
- /* 51 */ "log",
139173
- /* 52 */ "checkpointed",
139174
- /* collation_list reuses 38 */
139170
+ /* 47 */ "busy", /* Used by: wal_checkpoint */
139171
+ /* 48 */ "log",
139172
+ /* 49 */ "checkpointed",
139173
+ /* 50 */ "seq", /* Used by: database_list */
139174
+ /* 51 */ "name",
139175
+ /* 52 */ "file",
139176
+ /* index_info reuses 27 */
139175
139177
/* 53 */ "database", /* Used by: lock_status */
139176
139178
/* 54 */ "status",
139179
+ /* collation_list reuses 33 */
139177
139180
/* 55 */ "cache_size", /* Used by: default_cache_size */
139178
139181
/* module_list pragma_list reuses 9 */
139179
139182
/* 56 */ "timeout", /* Used by: busy_timeout */
@@ -139266,7 +139269,7 @@ static const PragmaName aPragmaName[] = {
139266
139269
{/* zName: */ "collation_list",
139267
139270
/* ePragTyp: */ PragTyp_COLLATION_LIST,
139268
139271
/* ePragFlg: */ PragFlg_Result0,
139269
- /* ColNames: */ 38 , 2,
139272
+ /* ColNames: */ 33 , 2,
139270
139273
/* iArg: */ 0 },
139271
139274
#endif
139272
139275
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
@@ -139301,7 +139304,7 @@ static const PragmaName aPragmaName[] = {
139301
139304
{/* zName: */ "database_list",
139302
139305
/* ePragTyp: */ PragTyp_DATABASE_LIST,
139303
139306
/* ePragFlg: */ PragFlg_Result0,
139304
- /* ColNames: */ 47 , 3,
139307
+ /* ColNames: */ 50 , 3,
139305
139308
/* iArg: */ 0 },
139306
139309
#endif
139307
139310
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
@@ -139381,7 +139384,7 @@ static const PragmaName aPragmaName[] = {
139381
139384
{/* zName: */ "function_list",
139382
139385
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
139383
139386
/* ePragFlg: */ PragFlg_Result0,
139384
- /* ColNames: */ 27 , 6,
139387
+ /* ColNames: */ 15 , 6,
139385
139388
/* iArg: */ 0 },
139386
139389
#endif
139387
139390
#endif
@@ -139410,17 +139413,17 @@ static const PragmaName aPragmaName[] = {
139410
139413
{/* zName: */ "index_info",
139411
139414
/* ePragTyp: */ PragTyp_INDEX_INFO,
139412
139415
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139413
- /* ColNames: */ 21 , 3,
139416
+ /* ColNames: */ 27 , 3,
139414
139417
/* iArg: */ 0 },
139415
139418
{/* zName: */ "index_list",
139416
139419
/* ePragTyp: */ PragTyp_INDEX_LIST,
139417
139420
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139418
- /* ColNames: */ 38 , 5,
139421
+ /* ColNames: */ 33 , 5,
139419
139422
/* iArg: */ 0 },
139420
139423
{/* zName: */ "index_xinfo",
139421
139424
/* ePragTyp: */ PragTyp_INDEX_INFO,
139422
139425
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139423
- /* ColNames: */ 21 , 6,
139426
+ /* ColNames: */ 27 , 6,
139424
139427
/* iArg: */ 1 },
139425
139428
#endif
139426
139429
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
@@ -139599,7 +139602,7 @@ static const PragmaName aPragmaName[] = {
139599
139602
{/* zName: */ "stats",
139600
139603
/* ePragTyp: */ PragTyp_STATS,
139601
139604
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
139602
- /* ColNames: */ 33 , 5,
139605
+ /* ColNames: */ 38 , 5,
139603
139606
/* iArg: */ 0 },
139604
139607
#endif
139605
139608
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
@@ -139618,7 +139621,7 @@ static const PragmaName aPragmaName[] = {
139618
139621
{/* zName: */ "table_list",
139619
139622
/* ePragTyp: */ PragTyp_TABLE_LIST,
139620
139623
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
139621
- /* ColNames: */ 15 , 6,
139624
+ /* ColNames: */ 21 , 6,
139622
139625
/* iArg: */ 0 },
139623
139626
{/* zName: */ "table_xinfo",
139624
139627
/* ePragTyp: */ PragTyp_TABLE_INFO,
@@ -139695,7 +139698,7 @@ static const PragmaName aPragmaName[] = {
139695
139698
{/* zName: */ "wal_checkpoint",
139696
139699
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
139697
139700
/* ePragFlg: */ PragFlg_NeedSchema,
139698
- /* ColNames: */ 50 , 3,
139701
+ /* ColNames: */ 47 , 3,
139699
139702
/* iArg: */ 0 },
139700
139703
#endif
139701
139704
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
@@ -147073,6 +147076,7 @@ static int multiSelect(
147073
147076
multi_select_end:
147074
147077
pDest->iSdst = dest.iSdst;
147075
147078
pDest->nSdst = dest.nSdst;
147079
+ pDest->iSDParm2 = dest.iSDParm2;
147076
147080
if( pDelete ){
147077
147081
sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete);
147078
147082
}
@@ -151027,6 +151031,7 @@ static void agginfoFree(sqlite3 *db, void *pArg){
151027
151031
** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
151028
151032
** * The outer query is a simple count(*) with no WHERE clause or other
151029
151033
** extraneous syntax.
151034
+ ** * None of the subqueries are DISTINCT (forumpost/a860f5fb2e 2025-03-10)
151030
151035
**
151031
151036
** Return TRUE if the optimization is undertaken.
151032
151037
*/
@@ -151059,7 +151064,11 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
151059
151064
if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
151060
151065
if( pSub->pWhere ) return 0; /* No WHERE clause */
151061
151066
if( pSub->pLimit ) return 0; /* No LIMIT clause */
151062
- if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
151067
+ if( pSub->selFlags & (SF_Aggregate|SF_Distinct) ){
151068
+ testcase( pSub->selFlags & SF_Aggregate );
151069
+ testcase( pSub->selFlags & SF_Distinct );
151070
+ return 0; /* Not an aggregate nor DISTINCT */
151071
+ }
151063
151072
assert( pSub->pHaving==0 ); /* Due to the previous */
151064
151073
pSub = pSub->pPrior; /* Repeat over compound */
151065
151074
}while( pSub );
@@ -166881,7 +166890,7 @@ static int whereLoopAddBtreeIndex(
166881
166890
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
166882
166891
&& pNew->u.btree.nEq<pProbe->nColumn
166883
166892
&& (pNew->u.btree.nEq<pProbe->nKeyCol ||
166884
- pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
166893
+ ( pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY && !pProbe->bIdxRowid) )
166885
166894
){
166886
166895
if( pNew->u.btree.nEq>3 ){
166887
166896
sqlite3ProgressCheck(pParse);
@@ -255874,7 +255883,7 @@ static void fts5SourceIdFunc(
255874
255883
){
255875
255884
assert( nArg==0 );
255876
255885
UNUSED_PARAM2(nArg, apUnused);
255877
- sqlite3_result_text(pCtx, "fts5: 2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70 ", -1, SQLITE_TRANSIENT);
255886
+ sqlite3_result_text(pCtx, "fts5: 2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b4861fb1 ", -1, SQLITE_TRANSIENT);
255878
255887
}
255879
255888
255880
255889
/*
0 commit comments