11/******************************************************************************
22** 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
44** single large file, the entire code can be compiled as a single translation
55** unit. This allows many compilers to do optimizations that would not be
66** possible if the files were compiled separately. Performance improvements
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- ** 873d4e274b4988d260ba8354a9718324a1c2 with changes in files:
21+ ** 17144570b0d96ae63cd6f3edca39e27ebd74 with changes in files:
2222**
2323**
2424*/
@@ -466,9 +466,9 @@ extern "C" {
466466** [sqlite3_libversion_number()], [sqlite3_sourceid()],
467467** [sqlite_version()] and [sqlite_source_id()].
468468*/
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 "
472472
473473/*
474474** CAPI3REF: Run-Time Library Version Numbers
@@ -19065,6 +19065,7 @@ struct Index {
1906519065 unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
1906619066 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
1906719067 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19068+ unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
1906819069 unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
1906919070 unsigned bHasExpr:1; /* Index contains an expression, either a literal
1907019071 ** expression, or a reference to a VIRTUAL column */
@@ -97242,6 +97243,7 @@ case OP_MakeRecord: {
9724297243 zHdr += sqlite3PutVarint(zHdr, serial_type);
9724397244 if( pRec->n ){
9724497245 assert( pRec->z!=0 );
97246+ assert( pRec->z!=(const char*)sqlite3CtypeMap );
9724597247 memcpy(zPayload, pRec->z, pRec->n);
9724697248 zPayload += pRec->n;
9724797249 }
@@ -115469,11 +115471,11 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
115469115471 assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL );
115470115472 assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
115471115473 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
115472- sqlite3VdbeTypeofColumn(v, r1);
115474+ assert( regFree1==0 || regFree1==r1 );
115475+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
115473115476 sqlite3VdbeAddOp2(v, op, r1, dest);
115474115477 VdbeCoverageIf(v, op==TK_ISNULL);
115475115478 VdbeCoverageIf(v, op==TK_NOTNULL);
115476- testcase( regFree1==0 );
115477115479 break;
115478115480 }
115479115481 case TK_BETWEEN: {
@@ -115644,11 +115646,11 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
115644115646 case TK_ISNULL:
115645115647 case TK_NOTNULL: {
115646115648 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
115647- sqlite3VdbeTypeofColumn(v, r1);
115649+ assert( regFree1==0 || regFree1==r1 );
115650+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
115648115651 sqlite3VdbeAddOp2(v, op, r1, dest);
115649115652 testcase( op==TK_ISNULL ); VdbeCoverageIf(v, op==TK_ISNULL);
115650115653 testcase( op==TK_NOTNULL ); VdbeCoverageIf(v, op==TK_NOTNULL);
115651- testcase( regFree1==0 );
115652115654 break;
115653115655 }
115654115656 case TK_BETWEEN: {
@@ -126337,6 +126339,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126337126339 assert( j<=0x7fff );
126338126340 if( j<0 ){
126339126341 j = pTab->iPKey;
126342+ pIndex->bIdxRowid = 1;
126340126343 }else{
126341126344 if( pTab->aCol[j].notNull==0 ){
126342126345 pIndex->uniqNotNull = 0;
@@ -139133,48 +139136,48 @@ static const char *const pragCName[] = {
139133139136 /* 13 */ "pk",
139134139137 /* 14 */ "hidden",
139135139138 /* table_info reuses 8 */
139136- /* 15 */ "schema ", /* Used by: table_list */
139137- /* 16 */ "name ",
139139+ /* 15 */ "name ", /* Used by: function_list */
139140+ /* 16 */ "builtin ",
139138139141 /* 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 ",
139164139167 /* 43 */ "table", /* Used by: foreign_key_check */
139165139168 /* 44 */ "rowid",
139166139169 /* 45 */ "parent",
139167139170 /* 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 */
139176139178 /* 53 */ "database", /* Used by: lock_status */
139177139179 /* 54 */ "status",
139180+ /* collation_list reuses 33 */
139178139181 /* 55 */ "cache_size", /* Used by: default_cache_size */
139179139182 /* module_list pragma_list reuses 9 */
139180139183 /* 56 */ "timeout", /* Used by: busy_timeout */
@@ -139267,7 +139270,7 @@ static const PragmaName aPragmaName[] = {
139267139270 {/* zName: */ "collation_list",
139268139271 /* ePragTyp: */ PragTyp_COLLATION_LIST,
139269139272 /* ePragFlg: */ PragFlg_Result0,
139270- /* ColNames: */ 38 , 2,
139273+ /* ColNames: */ 33 , 2,
139271139274 /* iArg: */ 0 },
139272139275#endif
139273139276#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
@@ -139302,7 +139305,7 @@ static const PragmaName aPragmaName[] = {
139302139305 {/* zName: */ "database_list",
139303139306 /* ePragTyp: */ PragTyp_DATABASE_LIST,
139304139307 /* ePragFlg: */ PragFlg_Result0,
139305- /* ColNames: */ 47 , 3,
139308+ /* ColNames: */ 50 , 3,
139306139309 /* iArg: */ 0 },
139307139310#endif
139308139311#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
@@ -139382,7 +139385,7 @@ static const PragmaName aPragmaName[] = {
139382139385 {/* zName: */ "function_list",
139383139386 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
139384139387 /* ePragFlg: */ PragFlg_Result0,
139385- /* ColNames: */ 27 , 6,
139388+ /* ColNames: */ 15 , 6,
139386139389 /* iArg: */ 0 },
139387139390#endif
139388139391#endif
@@ -139411,17 +139414,17 @@ static const PragmaName aPragmaName[] = {
139411139414 {/* zName: */ "index_info",
139412139415 /* ePragTyp: */ PragTyp_INDEX_INFO,
139413139416 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139414- /* ColNames: */ 21 , 3,
139417+ /* ColNames: */ 27 , 3,
139415139418 /* iArg: */ 0 },
139416139419 {/* zName: */ "index_list",
139417139420 /* ePragTyp: */ PragTyp_INDEX_LIST,
139418139421 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139419- /* ColNames: */ 38 , 5,
139422+ /* ColNames: */ 33 , 5,
139420139423 /* iArg: */ 0 },
139421139424 {/* zName: */ "index_xinfo",
139422139425 /* ePragTyp: */ PragTyp_INDEX_INFO,
139423139426 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139424- /* ColNames: */ 21 , 6,
139427+ /* ColNames: */ 27 , 6,
139425139428 /* iArg: */ 1 },
139426139429#endif
139427139430#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
@@ -139600,7 +139603,7 @@ static const PragmaName aPragmaName[] = {
139600139603 {/* zName: */ "stats",
139601139604 /* ePragTyp: */ PragTyp_STATS,
139602139605 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
139603- /* ColNames: */ 33 , 5,
139606+ /* ColNames: */ 38 , 5,
139604139607 /* iArg: */ 0 },
139605139608#endif
139606139609#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
@@ -139619,7 +139622,7 @@ static const PragmaName aPragmaName[] = {
139619139622 {/* zName: */ "table_list",
139620139623 /* ePragTyp: */ PragTyp_TABLE_LIST,
139621139624 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
139622- /* ColNames: */ 15 , 6,
139625+ /* ColNames: */ 21 , 6,
139623139626 /* iArg: */ 0 },
139624139627 {/* zName: */ "table_xinfo",
139625139628 /* ePragTyp: */ PragTyp_TABLE_INFO,
@@ -139696,7 +139699,7 @@ static const PragmaName aPragmaName[] = {
139696139699 {/* zName: */ "wal_checkpoint",
139697139700 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
139698139701 /* ePragFlg: */ PragFlg_NeedSchema,
139699- /* ColNames: */ 50 , 3,
139702+ /* ColNames: */ 47 , 3,
139700139703 /* iArg: */ 0 },
139701139704#endif
139702139705#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
@@ -147074,6 +147077,7 @@ static int multiSelect(
147074147077multi_select_end:
147075147078 pDest->iSdst = dest.iSdst;
147076147079 pDest->nSdst = dest.nSdst;
147080+ pDest->iSDParm2 = dest.iSDParm2;
147077147081 if( pDelete ){
147078147082 sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete);
147079147083 }
@@ -151028,6 +151032,7 @@ static void agginfoFree(sqlite3 *db, void *pArg){
151028151032** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
151029151033** * The outer query is a simple count(*) with no WHERE clause or other
151030151034** extraneous syntax.
151035+ ** * None of the subqueries are DISTINCT (forumpost/a860f5fb2e 2025-03-10)
151031151036**
151032151037** Return TRUE if the optimization is undertaken.
151033151038*/
@@ -151060,7 +151065,11 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
151060151065 if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
151061151066 if( pSub->pWhere ) return 0; /* No WHERE clause */
151062151067 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+ }
151064151073 assert( pSub->pHaving==0 ); /* Due to the previous */
151065151074 pSub = pSub->pPrior; /* Repeat over compound */
151066151075 }while( pSub );
@@ -166882,7 +166891,7 @@ static int whereLoopAddBtreeIndex(
166882166891 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
166883166892 && pNew->u.btree.nEq<pProbe->nColumn
166884166893 && (pNew->u.btree.nEq<pProbe->nKeyCol ||
166885- pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
166894+ ( pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY && !pProbe->bIdxRowid) )
166886166895 ){
166887166896 if( pNew->u.btree.nEq>3 ){
166888166897 sqlite3ProgressCheck(pParse);
@@ -255891,7 +255900,7 @@ static void fts5SourceIdFunc(
255891255900){
255892255901 assert( nArg==0 );
255893255902 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);
255895255904}
255896255905
255897255906/*
0 commit comments