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*/
@@ -465,9 +465,9 @@ extern "C" {
465465** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466** [sqlite_version()] and [sqlite_source_id()].
467467*/
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 "
471471
472472/*
473473** CAPI3REF: Run-Time Library Version Numbers
@@ -19064,6 +19064,7 @@ struct Index {
1906419064 unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
1906519065 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
1906619066 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19067+ unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
1906719068 unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
1906819069 unsigned bHasExpr:1; /* Index contains an expression, either a literal
1906919070 ** expression, or a reference to a VIRTUAL column */
@@ -97241,6 +97242,7 @@ case OP_MakeRecord: {
9724197242 zHdr += sqlite3PutVarint(zHdr, serial_type);
9724297243 if( pRec->n ){
9724397244 assert( pRec->z!=0 );
97245+ assert( pRec->z!=(const char*)sqlite3CtypeMap );
9724497246 memcpy(zPayload, pRec->z, pRec->n);
9724597247 zPayload += pRec->n;
9724697248 }
@@ -115468,11 +115470,11 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
115468115470 assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL );
115469115471 assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
115470115472 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
115471- sqlite3VdbeTypeofColumn(v, r1);
115473+ assert( regFree1==0 || regFree1==r1 );
115474+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
115472115475 sqlite3VdbeAddOp2(v, op, r1, dest);
115473115476 VdbeCoverageIf(v, op==TK_ISNULL);
115474115477 VdbeCoverageIf(v, op==TK_NOTNULL);
115475- testcase( regFree1==0 );
115476115478 break;
115477115479 }
115478115480 case TK_BETWEEN: {
@@ -115643,11 +115645,11 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
115643115645 case TK_ISNULL:
115644115646 case TK_NOTNULL: {
115645115647 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
115646- sqlite3VdbeTypeofColumn(v, r1);
115648+ assert( regFree1==0 || regFree1==r1 );
115649+ if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1);
115647115650 sqlite3VdbeAddOp2(v, op, r1, dest);
115648115651 testcase( op==TK_ISNULL ); VdbeCoverageIf(v, op==TK_ISNULL);
115649115652 testcase( op==TK_NOTNULL ); VdbeCoverageIf(v, op==TK_NOTNULL);
115650- testcase( regFree1==0 );
115651115653 break;
115652115654 }
115653115655 case TK_BETWEEN: {
@@ -126336,6 +126338,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126336126338 assert( j<=0x7fff );
126337126339 if( j<0 ){
126338126340 j = pTab->iPKey;
126341+ pIndex->bIdxRowid = 1;
126339126342 }else{
126340126343 if( pTab->aCol[j].notNull==0 ){
126341126344 pIndex->uniqNotNull = 0;
@@ -139132,48 +139135,48 @@ static const char *const pragCName[] = {
139132139135 /* 13 */ "pk",
139133139136 /* 14 */ "hidden",
139134139137 /* table_info reuses 8 */
139135- /* 15 */ "schema ", /* Used by: table_list */
139136- /* 16 */ "name ",
139138+ /* 15 */ "name ", /* Used by: function_list */
139139+ /* 16 */ "builtin ",
139137139140 /* 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 ",
139163139166 /* 43 */ "table", /* Used by: foreign_key_check */
139164139167 /* 44 */ "rowid",
139165139168 /* 45 */ "parent",
139166139169 /* 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 */
139175139177 /* 53 */ "database", /* Used by: lock_status */
139176139178 /* 54 */ "status",
139179+ /* collation_list reuses 33 */
139177139180 /* 55 */ "cache_size", /* Used by: default_cache_size */
139178139181 /* module_list pragma_list reuses 9 */
139179139182 /* 56 */ "timeout", /* Used by: busy_timeout */
@@ -139266,7 +139269,7 @@ static const PragmaName aPragmaName[] = {
139266139269 {/* zName: */ "collation_list",
139267139270 /* ePragTyp: */ PragTyp_COLLATION_LIST,
139268139271 /* ePragFlg: */ PragFlg_Result0,
139269- /* ColNames: */ 38 , 2,
139272+ /* ColNames: */ 33 , 2,
139270139273 /* iArg: */ 0 },
139271139274#endif
139272139275#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
@@ -139301,7 +139304,7 @@ static const PragmaName aPragmaName[] = {
139301139304 {/* zName: */ "database_list",
139302139305 /* ePragTyp: */ PragTyp_DATABASE_LIST,
139303139306 /* ePragFlg: */ PragFlg_Result0,
139304- /* ColNames: */ 47 , 3,
139307+ /* ColNames: */ 50 , 3,
139305139308 /* iArg: */ 0 },
139306139309#endif
139307139310#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
@@ -139381,7 +139384,7 @@ static const PragmaName aPragmaName[] = {
139381139384 {/* zName: */ "function_list",
139382139385 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
139383139386 /* ePragFlg: */ PragFlg_Result0,
139384- /* ColNames: */ 27 , 6,
139387+ /* ColNames: */ 15 , 6,
139385139388 /* iArg: */ 0 },
139386139389#endif
139387139390#endif
@@ -139410,17 +139413,17 @@ static const PragmaName aPragmaName[] = {
139410139413 {/* zName: */ "index_info",
139411139414 /* ePragTyp: */ PragTyp_INDEX_INFO,
139412139415 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139413- /* ColNames: */ 21 , 3,
139416+ /* ColNames: */ 27 , 3,
139414139417 /* iArg: */ 0 },
139415139418 {/* zName: */ "index_list",
139416139419 /* ePragTyp: */ PragTyp_INDEX_LIST,
139417139420 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139418- /* ColNames: */ 38 , 5,
139421+ /* ColNames: */ 33 , 5,
139419139422 /* iArg: */ 0 },
139420139423 {/* zName: */ "index_xinfo",
139421139424 /* ePragTyp: */ PragTyp_INDEX_INFO,
139422139425 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
139423- /* ColNames: */ 21 , 6,
139426+ /* ColNames: */ 27 , 6,
139424139427 /* iArg: */ 1 },
139425139428#endif
139426139429#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
@@ -139599,7 +139602,7 @@ static const PragmaName aPragmaName[] = {
139599139602 {/* zName: */ "stats",
139600139603 /* ePragTyp: */ PragTyp_STATS,
139601139604 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
139602- /* ColNames: */ 33 , 5,
139605+ /* ColNames: */ 38 , 5,
139603139606 /* iArg: */ 0 },
139604139607#endif
139605139608#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
@@ -139618,7 +139621,7 @@ static const PragmaName aPragmaName[] = {
139618139621 {/* zName: */ "table_list",
139619139622 /* ePragTyp: */ PragTyp_TABLE_LIST,
139620139623 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
139621- /* ColNames: */ 15 , 6,
139624+ /* ColNames: */ 21 , 6,
139622139625 /* iArg: */ 0 },
139623139626 {/* zName: */ "table_xinfo",
139624139627 /* ePragTyp: */ PragTyp_TABLE_INFO,
@@ -139695,7 +139698,7 @@ static const PragmaName aPragmaName[] = {
139695139698 {/* zName: */ "wal_checkpoint",
139696139699 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
139697139700 /* ePragFlg: */ PragFlg_NeedSchema,
139698- /* ColNames: */ 50 , 3,
139701+ /* ColNames: */ 47 , 3,
139699139702 /* iArg: */ 0 },
139700139703#endif
139701139704#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
@@ -147073,6 +147076,7 @@ static int multiSelect(
147073147076multi_select_end:
147074147077 pDest->iSdst = dest.iSdst;
147075147078 pDest->nSdst = dest.nSdst;
147079+ pDest->iSDParm2 = dest.iSDParm2;
147076147080 if( pDelete ){
147077147081 sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete);
147078147082 }
@@ -151027,6 +151031,7 @@ static void agginfoFree(sqlite3 *db, void *pArg){
151027151031** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
151028151032** * The outer query is a simple count(*) with no WHERE clause or other
151029151033** extraneous syntax.
151034+ ** * None of the subqueries are DISTINCT (forumpost/a860f5fb2e 2025-03-10)
151030151035**
151031151036** Return TRUE if the optimization is undertaken.
151032151037*/
@@ -151059,7 +151064,11 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
151059151064 if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
151060151065 if( pSub->pWhere ) return 0; /* No WHERE clause */
151061151066 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+ }
151063151072 assert( pSub->pHaving==0 ); /* Due to the previous */
151064151073 pSub = pSub->pPrior; /* Repeat over compound */
151065151074 }while( pSub );
@@ -166881,7 +166890,7 @@ static int whereLoopAddBtreeIndex(
166881166890 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
166882166891 && pNew->u.btree.nEq<pProbe->nColumn
166883166892 && (pNew->u.btree.nEq<pProbe->nKeyCol ||
166884- pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY)
166893+ ( pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY && !pProbe->bIdxRowid) )
166885166894 ){
166886166895 if( pNew->u.btree.nEq>3 ){
166887166896 sqlite3ProgressCheck(pParse);
@@ -255874,7 +255883,7 @@ static void fts5SourceIdFunc(
255874255883){
255875255884 assert( nArg==0 );
255876255885 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);
255878255887}
255879255888
255880255889/*
0 commit comments