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
** .fossil-settings/empty-dirs
24
24
** .fossil-settings/ignore-glob
@@ -495,9 +495,9 @@ extern "C" {
495
495
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
496
496
** [sqlite_version()] and [sqlite_source_id()].
497
497
*/
498
- #define SQLITE_VERSION "3.49.1 "
499
- #define SQLITE_VERSION_NUMBER 3049001
500
- #define SQLITE_SOURCE_ID "2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f1alt1 "
498
+ #define SQLITE_VERSION "3.49.2 "
499
+ #define SQLITE_VERSION_NUMBER 3049002
500
+ #define SQLITE_SOURCE_ID "2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1 "
501
501
502
502
/*
503
503
** CAPI3REF: Run-Time Library Version Numbers
@@ -19165,6 +19165,7 @@ struct Index {
19165
19165
unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
19166
19166
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
19167
19167
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19168
+ unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
19168
19169
unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
19169
19170
unsigned bHasExpr:1; /* Index contains an expression, either a literal
19170
19171
** expression, or a reference to a VIRTUAL column */
@@ -97633,6 +97634,7 @@ case OP_MakeRecord: {
97633
97634
zHdr += sqlite3PutVarint(zHdr, serial_type);
97634
97635
if( pRec->n ){
97635
97636
assert( pRec->z!=0 );
97637
+ assert( pRec->z!=(const char*)sqlite3CtypeMap );
97636
97638
memcpy(zPayload, pRec->z, pRec->n);
97637
97639
zPayload += pRec->n;
97638
97640
}
@@ -107603,7 +107605,7 @@ SQLITE_API void sqlite3pager_reset(Pager *pPager);
107603
107605
#define CIPHER_STR(s) #s
107604
107606
107605
107607
#ifndef CIPHER_VERSION_NUMBER
107606
- #define CIPHER_VERSION_NUMBER 4.8 .0
107608
+ #define CIPHER_VERSION_NUMBER 4.9 .0
107607
107609
#endif
107608
107610
107609
107611
#ifndef CIPHER_VERSION_BUILD
@@ -108093,10 +108095,6 @@ int sqlcipher_extra_init(const char* arg) {
108093
108095
void sqlcipher_extra_shutdown(void) {
108094
108096
int i = 0;
108095
108097
sqlcipher_provider *provider = NULL;
108096
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
108097
- if(mutex) {
108098
- sqlite3_mutex_enter(mutex);
108099
- }
108100
108098
108101
108099
/* if sqlcipher hasn't been initialized or the shutdown already completed exit early */
108102
108100
if(!sqlcipher_init || sqlcipher_shutdown) {
@@ -108167,9 +108165,6 @@ void sqlcipher_extra_shutdown(void) {
108167
108165
sqlcipher_init = 0;
108168
108166
sqlcipher_init_error = SQLITE_ERROR;
108169
108167
sqlcipher_shutdown = 1;
108170
- if(mutex) {
108171
- sqlite3_mutex_leave(mutex);
108172
- }
108173
108168
}
108174
108169
108175
108170
static void sqlcipher_shield(unsigned char *in, int sz) {
@@ -121135,11 +121130,11 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
121135
121130
assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL );
121136
121131
assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
121137
121132
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
121138
- sqlite3VdbeTypeofColumn(v, r1);
121133
+ assert( regFree1==0 || regFree1==r1 );
121134
+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
121139
121135
sqlite3VdbeAddOp2(v, op, r1, dest);
121140
121136
VdbeCoverageIf(v, op==TK_ISNULL);
121141
121137
VdbeCoverageIf(v, op==TK_NOTNULL);
121142
- testcase( regFree1==0 );
121143
121138
break;
121144
121139
}
121145
121140
case TK_BETWEEN: {
@@ -121310,11 +121305,11 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
121310
121305
case TK_ISNULL:
121311
121306
case TK_NOTNULL: {
121312
121307
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
121313
- sqlite3VdbeTypeofColumn(v, r1);
121308
+ assert( regFree1==0 || regFree1==r1 );
121309
+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
121314
121310
sqlite3VdbeAddOp2(v, op, r1, dest);
121315
121311
testcase( op==TK_ISNULL ); VdbeCoverageIf(v, op==TK_ISNULL);
121316
121312
testcase( op==TK_NOTNULL ); VdbeCoverageIf(v, op==TK_NOTNULL);
121317
- testcase( regFree1==0 );
121318
121313
break;
121319
121314
}
121320
121315
case TK_BETWEEN: {
@@ -132049,6 +132044,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
132049
132044
assert( j<=0x7fff );
132050
132045
if( j<0 ){
132051
132046
j = pTab->iPKey;
132047
+ pIndex->bIdxRowid = 1;
132052
132048
}else{
132053
132049
if( pTab->aCol[j].notNull==0 ){
132054
132050
pIndex->uniqNotNull = 0;
@@ -144846,48 +144842,48 @@ static const char *const pragCName[] = {
144846
144842
/* 13 */ "pk",
144847
144843
/* 14 */ "hidden",
144848
144844
/* table_info reuses 8 */
144849
- /* 15 */ "schema ", /* Used by: table_list */
144850
- /* 16 */ "name ",
144845
+ /* 15 */ "name ", /* Used by: function_list */
144846
+ /* 16 */ "builtin ",
144851
144847
/* 17 */ "type",
144852
- /* 18 */ "ncol ",
144853
- /* 19 */ "wr ",
144854
- /* 20 */ "strict ",
144855
- /* 21 */ "seqno ", /* Used by: index_xinfo */
144856
- /* 22 */ "cid ",
144857
- /* 23 */ "name ",
144858
- /* 24 */ "desc ",
144859
- /* 25 */ "coll ",
144860
- /* 26 */ "key ",
144861
- /* 27 */ "name ", /* Used by: function_list */
144862
- /* 28 */ "builtin ",
144863
- /* 29 */ "type ",
144864
- /* 30 */ "enc ",
144865
- /* 31 */ "narg ",
144866
- /* 32 */ "flags ",
144867
- /* 33 */ "tbl ", /* Used by: stats */
144868
- /* 34 */ "idx ",
144869
- /* 35 */ "wdth ",
144870
- /* 36 */ "hght ",
144871
- /* 37 */ "flgs ",
144872
- /* 38 */ "seq ", /* Used by: index_list */
144873
- /* 39 */ "name ",
144874
- /* 40 */ "unique ",
144875
- /* 41 */ "origin ",
144876
- /* 42 */ "partial ",
144848
+ /* 18 */ "enc ",
144849
+ /* 19 */ "narg ",
144850
+ /* 20 */ "flags ",
144851
+ /* 21 */ "schema ", /* Used by: table_list */
144852
+ /* 22 */ "name ",
144853
+ /* 23 */ "type ",
144854
+ /* 24 */ "ncol ",
144855
+ /* 25 */ "wr ",
144856
+ /* 26 */ "strict ",
144857
+ /* 27 */ "seqno ", /* Used by: index_xinfo */
144858
+ /* 28 */ "cid ",
144859
+ /* 29 */ "name ",
144860
+ /* 30 */ "desc ",
144861
+ /* 31 */ "coll ",
144862
+ /* 32 */ "key ",
144863
+ /* 33 */ "seq ", /* Used by: index_list */
144864
+ /* 34 */ "name ",
144865
+ /* 35 */ "unique ",
144866
+ /* 36 */ "origin ",
144867
+ /* 37 */ "partial ",
144868
+ /* 38 */ "tbl ", /* Used by: stats */
144869
+ /* 39 */ "idx ",
144870
+ /* 40 */ "wdth ",
144871
+ /* 41 */ "hght ",
144872
+ /* 42 */ "flgs ",
144877
144873
/* 43 */ "table", /* Used by: foreign_key_check */
144878
144874
/* 44 */ "rowid",
144879
144875
/* 45 */ "parent",
144880
144876
/* 46 */ "fkid",
144881
- /* index_info reuses 21 */
144882
- /* 47 */ "seq", /* Used by: database_list */
144883
- /* 48 */ "name",
144884
- /* 49 */ "file",
144885
- /* 50 */ "busy", /* Used by: wal_checkpoint */
144886
- /* 51 */ "log",
144887
- /* 52 */ "checkpointed",
144888
- /* collation_list reuses 38 */
144877
+ /* 47 */ "busy", /* Used by: wal_checkpoint */
144878
+ /* 48 */ "log",
144879
+ /* 49 */ "checkpointed",
144880
+ /* 50 */ "seq", /* Used by: database_list */
144881
+ /* 51 */ "name",
144882
+ /* 52 */ "file",
144883
+ /* index_info reuses 27 */
144889
144884
/* 53 */ "database", /* Used by: lock_status */
144890
144885
/* 54 */ "status",
144886
+ /* collation_list reuses 33 */
144891
144887
/* 55 */ "cache_size", /* Used by: default_cache_size */
144892
144888
/* module_list pragma_list reuses 9 */
144893
144889
/* 56 */ "timeout", /* Used by: busy_timeout */
@@ -144980,7 +144976,7 @@ static const PragmaName aPragmaName[] = {
144980
144976
{/* zName: */ "collation_list",
144981
144977
/* ePragTyp: */ PragTyp_COLLATION_LIST,
144982
144978
/* ePragFlg: */ PragFlg_Result0,
144983
- /* ColNames: */ 38 , 2,
144979
+ /* ColNames: */ 33 , 2,
144984
144980
/* iArg: */ 0 },
144985
144981
#endif
144986
144982
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
@@ -145015,7 +145011,7 @@ static const PragmaName aPragmaName[] = {
145015
145011
{/* zName: */ "database_list",
145016
145012
/* ePragTyp: */ PragTyp_DATABASE_LIST,
145017
145013
/* ePragFlg: */ PragFlg_Result0,
145018
- /* ColNames: */ 47 , 3,
145014
+ /* ColNames: */ 50 , 3,
145019
145015
/* iArg: */ 0 },
145020
145016
#endif
145021
145017
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
@@ -145095,7 +145091,7 @@ static const PragmaName aPragmaName[] = {
145095
145091
{/* zName: */ "function_list",
145096
145092
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
145097
145093
/* ePragFlg: */ PragFlg_Result0,
145098
- /* ColNames: */ 27 , 6,
145094
+ /* ColNames: */ 15 , 6,
145099
145095
/* iArg: */ 0 },
145100
145096
#endif
145101
145097
#endif
@@ -145138,17 +145134,17 @@ static const PragmaName aPragmaName[] = {
145138
145134
{/* zName: */ "index_info",
145139
145135
/* ePragTyp: */ PragTyp_INDEX_INFO,
145140
145136
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
145141
- /* ColNames: */ 21 , 3,
145137
+ /* ColNames: */ 27 , 3,
145142
145138
/* iArg: */ 0 },
145143
145139
{/* zName: */ "index_list",
145144
145140
/* ePragTyp: */ PragTyp_INDEX_LIST,
145145
145141
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
145146
- /* ColNames: */ 38 , 5,
145142
+ /* ColNames: */ 33 , 5,
145147
145143
/* iArg: */ 0 },
145148
145144
{/* zName: */ "index_xinfo",
145149
145145
/* ePragTyp: */ PragTyp_INDEX_INFO,
145150
145146
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
145151
- /* ColNames: */ 21 , 6,
145147
+ /* ColNames: */ 27 , 6,
145152
145148
/* iArg: */ 1 },
145153
145149
#endif
145154
145150
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
@@ -145347,7 +145343,7 @@ static const PragmaName aPragmaName[] = {
145347
145343
{/* zName: */ "stats",
145348
145344
/* ePragTyp: */ PragTyp_STATS,
145349
145345
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
145350
- /* ColNames: */ 33 , 5,
145346
+ /* ColNames: */ 38 , 5,
145351
145347
/* iArg: */ 0 },
145352
145348
#endif
145353
145349
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
@@ -145366,7 +145362,7 @@ static const PragmaName aPragmaName[] = {
145366
145362
{/* zName: */ "table_list",
145367
145363
/* ePragTyp: */ PragTyp_TABLE_LIST,
145368
145364
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
145369
- /* ColNames: */ 15 , 6,
145365
+ /* ColNames: */ 21 , 6,
145370
145366
/* iArg: */ 0 },
145371
145367
{/* zName: */ "table_xinfo",
145372
145368
/* ePragTyp: */ PragTyp_TABLE_INFO,
@@ -145457,7 +145453,7 @@ static const PragmaName aPragmaName[] = {
145457
145453
{/* zName: */ "wal_checkpoint",
145458
145454
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
145459
145455
/* ePragFlg: */ PragFlg_NeedSchema,
145460
- /* ColNames: */ 50 , 3,
145456
+ /* ColNames: */ 47 , 3,
145461
145457
/* iArg: */ 0 },
145462
145458
#endif
145463
145459
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
@@ -152899,6 +152895,7 @@ static int multiSelect(
152899
152895
multi_select_end:
152900
152896
pDest->iSdst = dest.iSdst;
152901
152897
pDest->nSdst = dest.nSdst;
152898
+ pDest->iSDParm2 = dest.iSDParm2;
152902
152899
if( pDelete ){
152903
152900
sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete);
152904
152901
}
@@ -156853,6 +156850,7 @@ static void agginfoFree(sqlite3 *db, void *pArg){
156853
156850
** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
156854
156851
** * The outer query is a simple count(*) with no WHERE clause or other
156855
156852
** extraneous syntax.
156853
+ ** * None of the subqueries are DISTINCT (forumpost/a860f5fb2e 2025-03-10)
156856
156854
**
156857
156855
** Return TRUE if the optimization is undertaken.
156858
156856
*/
@@ -156885,7 +156883,11 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
156885
156883
if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
156886
156884
if( pSub->pWhere ) return 0; /* No WHERE clause */
156887
156885
if( pSub->pLimit ) return 0; /* No LIMIT clause */
156888
- if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
156886
+ if( pSub->selFlags & (SF_Aggregate|SF_Distinct) ){
156887
+ testcase( pSub->selFlags & SF_Aggregate );
156888
+ testcase( pSub->selFlags & SF_Distinct );
156889
+ return 0; /* Not an aggregate nor DISTINCT */
156890
+ }
156889
156891
assert( pSub->pHaving==0 ); /* Due to the previous */
156890
156892
pSub = pSub->pPrior; /* Repeat over compound */
156891
156893
}while( pSub );
@@ -172722,7 +172724,7 @@ static int whereLoopAddBtreeIndex(
172722
172724
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
172723
172725
&& pNew->u.btree.nEq<pProbe->nColumn
172724
172726
&& (pNew->u.btree.nEq<pProbe->nKeyCol ||
172725
- pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
172727
+ ( pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY && !pProbe->bIdxRowid) )
172726
172728
){
172727
172729
if( pNew->u.btree.nEq>3 ){
172728
172730
sqlite3ProgressCheck(pParse);
@@ -261757,7 +261759,7 @@ static void fts5SourceIdFunc(
261757
261759
){
261758
261760
assert( nArg==0 );
261759
261761
UNUSED_PARAM2(nArg, apUnused);
261760
- sqlite3_result_text(pCtx, "fts5: 2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70 ", -1, SQLITE_TRANSIENT);
261762
+ sqlite3_result_text(pCtx, "fts5: 2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b4861fb1 ", -1, SQLITE_TRANSIENT);
261761
261763
}
261762
261764
261763
261765
/*
0 commit comments