@@ -92,7 +92,7 @@ extern SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
9292/*** Begin of #include "sqlite3patched.c" ***/
9393/******************************************************************************
9494** This file is an amalgamation of many separate C source files from SQLite
95- ** version 3.41.0 . By combining all the individual C code files into this
95+ ** version 3.41.1 . By combining all the individual C code files into this
9696** single large file, the entire code can be compiled as a single translation
9797** unit. This allows many compilers to do optimizations that would not be
9898** possible if the files were compiled separately. Performance improvements
@@ -544,9 +544,9 @@ extern "C" {
544544** [sqlite3_libversion_number()], [sqlite3_sourceid()],
545545** [sqlite_version()] and [sqlite_source_id()].
546546*/
547- #define SQLITE_VERSION "3.41.0 "
548- #define SQLITE_VERSION_NUMBER 3041000
549- #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d "
547+ #define SQLITE_VERSION "3.41.1 "
548+ #define SQLITE_VERSION_NUMBER 3041001
549+ #define SQLITE_SOURCE_ID "2023-03-10 12:13:52 20399f3eda5ec249d147ba9e48da6e87f969d7966a9a896764ca437ff7e737ff "
550550
551551/*
552552** CAPI3REF: Run-Time Library Version Numbers
@@ -19256,6 +19256,7 @@ struct IndexedExpr {
1925619256 int iIdxCur; /* The index cursor */
1925719257 int iIdxCol; /* The index column that contains value of pExpr */
1925819258 u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */
19259+ u8 aff; /* Affinity of the pExpr expression */
1925919260 IndexedExpr *pIENext; /* Next in a list of all indexed expressions */
1926019261#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
1926119262 const char *zIdxName; /* Name of index, used only for bytecode comments */
@@ -37189,7 +37190,11 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){
3718937190/*
3719037191** Maximum supported path-length.
3719137192*/
37193+ #if SQLITE3MC_MAX_PATHNAME > 512
37194+ #define MAX_PATHNAME SQLITE3MC_MAX_PATHNAME
37195+ #else
3719237196#define MAX_PATHNAME 512
37197+ #endif
3719337198
3719437199/*
3719537200** Maximum supported symbolic links
@@ -91015,8 +91020,7 @@ static u64 filterHash(const Mem *aMem, const Op *pOp){
9101591020 }else if( p->flags & MEM_Real ){
9101691021 h += sqlite3VdbeIntValue(p);
9101791022 }else if( p->flags & (MEM_Str|MEM_Blob) ){
91018- h += p->n;
91019- if( p->flags & MEM_Zero ) h += p->u.nZero;
91023+ /* no-op */
9102091024 }
9102191025 }
9102291026 return h;
@@ -104595,14 +104599,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
104595104599 if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){
104596104600 testcase( ExprHasProperty(pExpr, EP_OuterON) );
104597104601 assert( !ExprHasProperty(pExpr, EP_IntValue) );
104598- if( pExpr->op==TK_NOTNULL ){
104599- pExpr->u.zToken = "true";
104600- ExprSetProperty(pExpr, EP_IsTrue);
104601- }else{
104602- pExpr->u.zToken = "false";
104603- ExprSetProperty(pExpr, EP_IsFalse);
104604- }
104605- pExpr->op = TK_TRUEFALSE;
104602+ pExpr->u.iValue = (pExpr->op==TK_NOTNULL);
104603+ pExpr->flags |= EP_IntValue;
104604+ pExpr->op = TK_INTEGER;
104605+
104606104606 for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
104607104607 p->nRef = anRef[i];
104608104608 }
@@ -109948,13 +109948,24 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup(
109948109948 IndexedExpr *p;
109949109949 Vdbe *v;
109950109950 for(p=pParse->pIdxEpr; p; p=p->pIENext){
109951+ u8 exprAff;
109951109952 int iDataCur = p->iDataCur;
109952109953 if( iDataCur<0 ) continue;
109953109954 if( pParse->iSelfTab ){
109954109955 if( p->iDataCur!=pParse->iSelfTab-1 ) continue;
109955109956 iDataCur = -1;
109956109957 }
109957109958 if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue;
109959+ assert( p->aff>=SQLITE_AFF_BLOB && p->aff<=SQLITE_AFF_NUMERIC );
109960+ exprAff = sqlite3ExprAffinity(pExpr);
109961+ if( (exprAff<=SQLITE_AFF_BLOB && p->aff!=SQLITE_AFF_BLOB)
109962+ || (exprAff==SQLITE_AFF_TEXT && p->aff!=SQLITE_AFF_TEXT)
109963+ || (exprAff>=SQLITE_AFF_NUMERIC && p->aff!=SQLITE_AFF_NUMERIC)
109964+ ){
109965+ /* Affinity mismatch on a generated column */
109966+ continue;
109967+ }
109968+
109958109969 v = pParse->pVdbe;
109959109970 assert( v!=0 );
109960109971 if( p->bMaybeNullRow ){
@@ -110534,10 +110545,13 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
110534110545 return target;
110535110546 }
110536110547 case TK_COLLATE: {
110537- if( !ExprHasProperty(pExpr, EP_Collate)
110538- && ALWAYS(pExpr->pLeft)
110539- && pExpr->pLeft->op==TK_FUNCTION
110540- ){
110548+ if( !ExprHasProperty(pExpr, EP_Collate) ){
110549+ /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called
110550+ ** "SOFT-COLLATE" that is added to constraints that are pushed down
110551+ ** from outer queries into sub-queries by the push-down optimization.
110552+ ** Clear subtypes as subtypes may not cross a subquery boundary.
110553+ */
110554+ assert( pExpr->pLeft );
110541110555 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
110542110556 if( inReg!=target ){
110543110557 sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
@@ -110645,16 +110659,22 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
110645110659 break;
110646110660 }
110647110661 }
110648- addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
110649- /* Temporarily disable factoring of constant expressions, since
110650- ** even though expressions may appear to be constant, they are not
110651- ** really constant because they originate from the right-hand side
110652- ** of a LEFT JOIN. */
110653- pParse->okConstFactor = 0;
110662+ addrINR = sqlite3VdbeAddOp3(v, OP_IfNullRow, pExpr->iTable, 0, target);
110663+ /* The OP_IfNullRow opcode above can overwrite the result register with
110664+ ** NULL. So we have to ensure that the result register is not a value
110665+ ** that is suppose to be a constant. Two defenses are needed:
110666+ ** (1) Temporarily disable factoring of constant expressions
110667+ ** (2) Make sure the computed value really is stored in register
110668+ ** "target" and not someplace else.
110669+ */
110670+ pParse->okConstFactor = 0; /* note (1) above */
110654110671 inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
110655110672 pParse->okConstFactor = okConstFactor;
110673+ if( inReg!=target ){ /* note (2) above */
110674+ sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
110675+ inReg = target;
110676+ }
110656110677 sqlite3VdbeJumpHere(v, addrINR);
110657- sqlite3VdbeChangeP3(v, addrINR, inReg);
110658110678 break;
110659110679 }
110660110680
@@ -119583,6 +119603,7 @@ SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType
119583119603 ** turn it into one by adding a unary "+" operator. */
119584119604 pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0);
119585119605 }
119606+ if( pExpr && pExpr->op!=TK_RAISE ) pExpr->affExpr = pCol->affinity;
119586119607 sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr);
119587119608 pExpr = 0;
119588119609 goto generated_done;
@@ -126986,6 +127007,18 @@ static void ceilingFunc(
126986127007static double xCeil(double x){ return ceil(x); }
126987127008static double xFloor(double x){ return floor(x); }
126988127009
127010+ /*
127011+ ** Some systems do not have log2() and log10() in their standard math
127012+ ** libraries.
127013+ */
127014+ #if defined(HAVE_LOG10) && HAVE_LOG10==0
127015+ # define log10(X) (0.4342944819032517867*log(X))
127016+ #endif
127017+ #if defined(HAVE_LOG2) && HAVE_LOG2==0
127018+ # define log2(X) (1.442695040888963456*log(X))
127019+ #endif
127020+
127021+
126989127022/*
126990127023** Implementation of SQL functions:
126991127024**
@@ -136365,6 +136398,23 @@ SQLITE_PRIVATE void sqlite3Pragma(
136365136398 jmp4 = integrityCheckResultRow(v);
136366136399 sqlite3VdbeJumpHere(v, jmp2);
136367136400
136401+ /* The OP_IdxRowid opcode is an optimized version of OP_Column
136402+ ** that extracts the rowid off the end of the index record.
136403+ ** But it only works correctly if index record does not have
136404+ ** any extra bytes at the end. Verify that this is the case. */
136405+ if( HasRowid(pTab) ){
136406+ int jmp7;
136407+ sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur+j, 3);
136408+ jmp7 = sqlite3VdbeAddOp3(v, OP_Eq, 3, 0, r1+pIdx->nColumn-1);
136409+ VdbeCoverage(v);
136410+ sqlite3VdbeLoadString(v, 3,
136411+ "rowid not at end-of-record for row ");
136412+ sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
136413+ sqlite3VdbeLoadString(v, 4, " of index ");
136414+ sqlite3VdbeGoto(v, jmp5-1);
136415+ sqlite3VdbeJumpHere(v, jmp7);
136416+ }
136417+
136368136418 /* Any indexed columns with non-BINARY collations must still hold
136369136419 ** the exact same text value as the table. */
136370136420 label6 = 0;
@@ -140660,8 +140710,6 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
140660140710 pCol->affinity = sqlite3ExprAffinity(p);
140661140711 if( pCol->affinity<=SQLITE_AFF_NONE ){
140662140712 pCol->affinity = aff;
140663- }else if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){
140664- pCol->affinity = SQLITE_AFF_FLEXNUM;
140665140713 }
140666140714 if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){
140667140715 int m = 0;
@@ -140675,6 +140723,9 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
140675140723 if( pCol->affinity>=SQLITE_AFF_NUMERIC && (m&0x02)!=0 ){
140676140724 pCol->affinity = SQLITE_AFF_BLOB;
140677140725 }
140726+ if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){
140727+ pCol->affinity = SQLITE_AFF_FLEXNUM;
140728+ }
140678140729 }
140679140730 zType = columnType(&sNC, p, 0, 0, 0);
140680140731 if( zType==0 || pCol->affinity!=sqlite3AffinityType(zType, 0) ){
@@ -142189,7 +142240,7 @@ static Expr *substExpr(
142189142240 sqlite3VectorErrorMsg(pSubst->pParse, pCopy);
142190142241 }else{
142191142242 sqlite3 *db = pSubst->pParse->db;
142192- if( pSubst->isOuterJoin && pCopy->op!=TK_COLUMN ){
142243+ if( pSubst->isOuterJoin ){
142193142244 memset(&ifNullRow, 0, sizeof(ifNullRow));
142194142245 ifNullRow.op = TK_IF_NULL_ROW;
142195142246 ifNullRow.pLeft = pCopy;
@@ -144705,10 +144756,12 @@ static void optimizeAggregateUseOfIndexedExpr(
144705144756 NameContext *pNC /* Name context used to resolve agg-func args */
144706144757){
144707144758 assert( pAggInfo->iFirstReg==0 );
144759+ assert( pSelect!=0 );
144760+ assert( pSelect->pGroupBy!=0 );
144708144761 pAggInfo->nColumn = pAggInfo->nAccumulator;
144709144762 if( ALWAYS(pAggInfo->nSortingColumn>0) ){
144710144763 if( pAggInfo->nColumn==0 ){
144711- pAggInfo->nSortingColumn = 0 ;
144764+ pAggInfo->nSortingColumn = pSelect->pGroupBy->nExpr ;
144712144765 }else{
144713144766 pAggInfo->nSortingColumn =
144714144767 pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1;
@@ -145133,6 +145186,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145133145186 if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
145134145187 if( p->pWhere ) return 0;
145135145188 if( p->pGroupBy ) return 0;
145189+ if( p->pOrderBy ) return 0;
145136145190 pExpr = p->pEList->a[0].pExpr;
145137145191 if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */
145138145192 assert( ExprUseUToken(pExpr) );
@@ -145143,7 +145197,8 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145143145197 if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */
145144145198 pSub = p->pSrc->a[0].pSelect;
145145145199 if( pSub==0 ) return 0; /* The FROM is a subquery */
145146- if( pSub->pPrior==0 ) return 0; /* Must be a compound ry */
145200+ if( pSub->pPrior==0 ) return 0; /* Must be a compound */
145201+ if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */
145147145202 do{
145148145203 if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
145149145204 if( pSub->pWhere ) return 0; /* No WHERE clause */
@@ -145586,7 +145641,6 @@ SQLITE_PRIVATE int sqlite3Select(
145586145641 && countOfViewOptimization(pParse, p)
145587145642 ){
145588145643 if( db->mallocFailed ) goto select_end;
145589- pEList = p->pEList;
145590145644 pTabList = p->pSrc;
145591145645 }
145592145646#endif
@@ -147729,7 +147783,7 @@ static void codeReturningTrigger(
147729147783 }
147730147784 sqlite3ExprListDelete(db, sSelect.pEList);
147731147785 pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
147732- if( !db->mallocFailed ){
147786+ if( pParse->nErr==0 ){
147733147787 NameContext sNC;
147734147788 memset(&sNC, 0, sizeof(sNC));
147735147789 if( pReturning->nRetCol==0 ){
@@ -156953,7 +157007,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
156953157007 pRhs = sqlite3PExpr(pParse, TK_UPLUS,
156954157008 sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
156955157009 pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
156956- if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ) ){
157010+ if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT ) ){
156957157011 joinType = EP_OuterON;
156958157012 }else{
156959157013 joinType = EP_InnerON;
@@ -162661,6 +162715,9 @@ static SQLITE_NOINLINE void whereAddIndexedExpr(
162661162715 p->iIdxCur = iIdxCur;
162662162716 p->iIdxCol = i;
162663162717 p->bMaybeNullRow = bMaybeNullRow;
162718+ if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){
162719+ p->aff = pIdx->zColAff[i];
162720+ }
162664162721#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
162665162722 p->zIdxName = pIdx->zName;
162666162723#endif
@@ -240284,7 +240341,7 @@ static void fts5SourceIdFunc(
240284240341){
240285240342 assert( nArg==0 );
240286240343 UNUSED_PARAM2(nArg, apUnused);
240287- sqlite3_result_text(pCtx, "fts5: 2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d ", -1, SQLITE_TRANSIENT);
240344+ sqlite3_result_text(pCtx, "fts5: 2023-03-10 12:13:52 20399f3eda5ec249d147ba9e48da6e87f969d7966a9a896764ca437ff7e737ff ", -1, SQLITE_TRANSIENT);
240288240345}
240289240346
240290240347/*
@@ -245482,9 +245539,9 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
245482245539
245483245540#define SQLITE3MC_VERSION_MAJOR 1
245484245541#define SQLITE3MC_VERSION_MINOR 6
245485- #define SQLITE3MC_VERSION_RELEASE 0
245542+ #define SQLITE3MC_VERSION_RELEASE 1
245486245543#define SQLITE3MC_VERSION_SUBRELEASE 0
245487- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.6.0 "
245544+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.6.1 "
245488245545
245489245546#endif /* SQLITE3MC_VERSION_H_ */
245490245547/*** End of #include "sqlite3mc_version.h" ***/
@@ -245643,9 +245700,9 @@ extern "C" {
245643245700** [sqlite3_libversion_number()], [sqlite3_sourceid()],
245644245701** [sqlite_version()] and [sqlite_source_id()].
245645245702*/
245646- #define SQLITE_VERSION "3.41.0 "
245647- #define SQLITE_VERSION_NUMBER 3041000
245648- #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d "
245703+ #define SQLITE_VERSION "3.41.1 "
245704+ #define SQLITE_VERSION_NUMBER 3041001
245705+ #define SQLITE_SOURCE_ID "2023-03-10 12:13:52 20399f3eda5ec249d147ba9e48da6e87f969d7966a9a896764ca437ff7e737ff "
245649245706
245650245707/*
245651245708** CAPI3REF: Run-Time Library Version Numbers
@@ -268772,7 +268829,7 @@ sqlite3mcBtreeSetPageSize(Btree* p, int pageSize, int nReserve, int iFix)
268772268829** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
268773268830** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
268774268831**
268775- ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.41.0 amalgamation.
268832+ ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.41.1 amalgamation.
268776268833*/
268777268834SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
268778268835 char **pzErrMsg, /* Write error message here */
@@ -292607,7 +292664,7 @@ sqlite3mcCheckVfs(const char* zVfs)
292607292664 if (pVfs == NULL)
292608292665 {
292609292666 /* VFS not found */
292610- int prefixLen = strlen(SQLITE3MC_VFS_NAME);
292667+ int prefixLen = (int) strlen(SQLITE3MC_VFS_NAME);
292611292668 if (strncmp(zVfs, SQLITE3MC_VFS_NAME, prefixLen) == 0)
292612292669 {
292613292670 /* VFS name starts with prefix. */
0 commit comments