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