Fossil SCM
Update the built-in SQLite to the first 3.41.1 beta, for testing.
Commit
782a7f9898f4e8e65677fa9284a76a5c5b08bc57a98f3a35ff748036801724b6
Parent
bb583b0cc427ff9…
2 files changed
+87
-34
+3
-3
+87
-34
| --- extsrc/sqlite3.c | ||
| +++ extsrc/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.41.0. By combining all the individual C code files into this | |
| 3 | +** version 3.41.1. 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 |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -450,13 +450,13 @@ | ||
| 450 | 450 | ** |
| 451 | 451 | ** See also: [sqlite3_libversion()], |
| 452 | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 454 | */ |
| 455 | -#define SQLITE_VERSION "3.41.0" | |
| 456 | -#define SQLITE_VERSION_NUMBER 3041000 | |
| 457 | -#define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d" | |
| 455 | +#define SQLITE_VERSION "3.41.1" | |
| 456 | +#define SQLITE_VERSION_NUMBER 3041001 | |
| 457 | +#define SQLITE_SOURCE_ID "2023-03-09 16:04:34 cc8a0ee40cfc83ab42a0ff452de0a53fe17784aefb944ea7ac2cb078a8310730" | |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| @@ -19154,10 +19154,11 @@ | ||
| 19154 | 19154 | Expr *pExpr; /* The expression contained in the index */ |
| 19155 | 19155 | int iDataCur; /* The data cursor associated with the index */ |
| 19156 | 19156 | int iIdxCur; /* The index cursor */ |
| 19157 | 19157 | int iIdxCol; /* The index column that contains value of pExpr */ |
| 19158 | 19158 | u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */ |
| 19159 | + u8 aff; /* Affinity of the pExpr expression */ | |
| 19159 | 19160 | IndexedExpr *pIENext; /* Next in a list of all indexed expressions */ |
| 19160 | 19161 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 19161 | 19162 | const char *zIdxName; /* Name of index, used only for bytecode comments */ |
| 19162 | 19163 | #endif |
| 19163 | 19164 | }; |
| @@ -90913,12 +90914,11 @@ | ||
| 90913 | 90914 | if( p->flags & (MEM_Int|MEM_IntReal) ){ |
| 90914 | 90915 | h += p->u.i; |
| 90915 | 90916 | }else if( p->flags & MEM_Real ){ |
| 90916 | 90917 | h += sqlite3VdbeIntValue(p); |
| 90917 | 90918 | }else if( p->flags & (MEM_Str|MEM_Blob) ){ |
| 90918 | - h += p->n; | |
| 90919 | - if( p->flags & MEM_Zero ) h += p->u.nZero; | |
| 90919 | + /* no-op */ | |
| 90920 | 90920 | } |
| 90921 | 90921 | } |
| 90922 | 90922 | return h; |
| 90923 | 90923 | } |
| 90924 | 90924 | |
| @@ -104493,18 +104493,14 @@ | ||
| 104493 | 104493 | } |
| 104494 | 104494 | sqlite3WalkExpr(pWalker, pExpr->pLeft); |
| 104495 | 104495 | if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ |
| 104496 | 104496 | testcase( ExprHasProperty(pExpr, EP_OuterON) ); |
| 104497 | 104497 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 104498 | - if( pExpr->op==TK_NOTNULL ){ | |
| 104499 | - pExpr->u.zToken = "true"; | |
| 104500 | - ExprSetProperty(pExpr, EP_IsTrue); | |
| 104501 | - }else{ | |
| 104502 | - pExpr->u.zToken = "false"; | |
| 104503 | - ExprSetProperty(pExpr, EP_IsFalse); | |
| 104504 | - } | |
| 104505 | - pExpr->op = TK_TRUEFALSE; | |
| 104498 | + pExpr->u.iValue = (pExpr->op==TK_NOTNULL); | |
| 104499 | + pExpr->flags |= EP_IntValue; | |
| 104500 | + pExpr->op = TK_INTEGER; | |
| 104501 | + | |
| 104506 | 104502 | for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){ |
| 104507 | 104503 | p->nRef = anRef[i]; |
| 104508 | 104504 | } |
| 104509 | 104505 | sqlite3ExprDelete(pParse->db, pExpr->pLeft); |
| 104510 | 104506 | pExpr->pLeft = 0; |
| @@ -109846,17 +109842,28 @@ | ||
| 109846 | 109842 | int target /* Where to store the result of the expression */ |
| 109847 | 109843 | ){ |
| 109848 | 109844 | IndexedExpr *p; |
| 109849 | 109845 | Vdbe *v; |
| 109850 | 109846 | for(p=pParse->pIdxEpr; p; p=p->pIENext){ |
| 109847 | + u8 exprAff; | |
| 109851 | 109848 | int iDataCur = p->iDataCur; |
| 109852 | 109849 | if( iDataCur<0 ) continue; |
| 109853 | 109850 | if( pParse->iSelfTab ){ |
| 109854 | 109851 | if( p->iDataCur!=pParse->iSelfTab-1 ) continue; |
| 109855 | 109852 | iDataCur = -1; |
| 109856 | 109853 | } |
| 109857 | 109854 | if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue; |
| 109855 | + assert( p->aff>=SQLITE_AFF_BLOB && p->aff<=SQLITE_AFF_NUMERIC ); | |
| 109856 | + exprAff = sqlite3ExprAffinity(pExpr); | |
| 109857 | + if( (exprAff<=SQLITE_AFF_BLOB && p->aff!=SQLITE_AFF_BLOB) | |
| 109858 | + || (exprAff==SQLITE_AFF_TEXT && p->aff!=SQLITE_AFF_TEXT) | |
| 109859 | + || (exprAff>=SQLITE_AFF_NUMERIC && p->aff!=SQLITE_AFF_NUMERIC) | |
| 109860 | + ){ | |
| 109861 | + /* Affinity mismatch on a generated column */ | |
| 109862 | + continue; | |
| 109863 | + } | |
| 109864 | + | |
| 109858 | 109865 | v = pParse->pVdbe; |
| 109859 | 109866 | assert( v!=0 ); |
| 109860 | 109867 | if( p->bMaybeNullRow ){ |
| 109861 | 109868 | /* If the index is on a NULL row due to an outer join, then we |
| 109862 | 109869 | ** cannot extract the value from the index. The value must be |
| @@ -110432,14 +110439,17 @@ | ||
| 110432 | 110439 | case TK_BETWEEN: { |
| 110433 | 110440 | exprCodeBetween(pParse, pExpr, target, 0, 0); |
| 110434 | 110441 | return target; |
| 110435 | 110442 | } |
| 110436 | 110443 | case TK_COLLATE: { |
| 110437 | - if( !ExprHasProperty(pExpr, EP_Collate) | |
| 110438 | - && ALWAYS(pExpr->pLeft) | |
| 110439 | - && pExpr->pLeft->op==TK_FUNCTION | |
| 110440 | - ){ | |
| 110444 | + if( !ExprHasProperty(pExpr, EP_Collate) ){ | |
| 110445 | + /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called | |
| 110446 | + ** "SOFT-COLLATE" that is added to constraints that are pushed down | |
| 110447 | + ** from outer queries into sub-queries by the push-down optimization. | |
| 110448 | + ** Clear subtypes as subtypes may not cross a subquery boundary. | |
| 110449 | + */ | |
| 110450 | + assert( pExpr->pLeft ); | |
| 110441 | 110451 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 110442 | 110452 | if( inReg!=target ){ |
| 110443 | 110453 | sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); |
| 110444 | 110454 | inReg = target; |
| 110445 | 110455 | } |
| @@ -110543,20 +110553,26 @@ | ||
| 110543 | 110553 | target); |
| 110544 | 110554 | inReg = target; |
| 110545 | 110555 | break; |
| 110546 | 110556 | } |
| 110547 | 110557 | } |
| 110548 | - addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable); | |
| 110549 | - /* Temporarily disable factoring of constant expressions, since | |
| 110550 | - ** even though expressions may appear to be constant, they are not | |
| 110551 | - ** really constant because they originate from the right-hand side | |
| 110552 | - ** of a LEFT JOIN. */ | |
| 110553 | - pParse->okConstFactor = 0; | |
| 110558 | + addrINR = sqlite3VdbeAddOp3(v, OP_IfNullRow, pExpr->iTable, 0, target); | |
| 110559 | + /* The OP_IfNullRow opcode above can overwrite the result register with | |
| 110560 | + ** NULL. So we have to ensure that the result register is not a value | |
| 110561 | + ** that is suppose to be a constant. Two defenses are needed: | |
| 110562 | + ** (1) Temporarily disable factoring of constant expressions | |
| 110563 | + ** (2) Make sure the computed value really is stored in register | |
| 110564 | + ** "target" and not someplace else. | |
| 110565 | + */ | |
| 110566 | + pParse->okConstFactor = 0; /* note (1) above */ | |
| 110554 | 110567 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 110555 | 110568 | pParse->okConstFactor = okConstFactor; |
| 110569 | + if( inReg!=target ){ /* note (2) above */ | |
| 110570 | + sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); | |
| 110571 | + inReg = target; | |
| 110572 | + } | |
| 110556 | 110573 | sqlite3VdbeJumpHere(v, addrINR); |
| 110557 | - sqlite3VdbeChangeP3(v, addrINR, inReg); | |
| 110558 | 110574 | break; |
| 110559 | 110575 | } |
| 110560 | 110576 | |
| 110561 | 110577 | /* |
| 110562 | 110578 | ** Form A: |
| @@ -119476,10 +119492,11 @@ | ||
| 119476 | 119492 | ** just a reference to another column, in order for covering index |
| 119477 | 119493 | ** optimizations to work correctly. So if the value is not an expression, |
| 119478 | 119494 | ** turn it into one by adding a unary "+" operator. */ |
| 119479 | 119495 | pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0); |
| 119480 | 119496 | } |
| 119497 | + if( pExpr && pExpr->op!=TK_RAISE ) pExpr->affExpr = pCol->affinity; | |
| 119481 | 119498 | sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr); |
| 119482 | 119499 | pExpr = 0; |
| 119483 | 119500 | goto generated_done; |
| 119484 | 119501 | |
| 119485 | 119502 | generated_error: |
| @@ -126878,10 +126895,22 @@ | ||
| 126878 | 126895 | ** unable to take a pointer to these functions. Hence, we here wrap them |
| 126879 | 126896 | ** in our own actual functions. |
| 126880 | 126897 | */ |
| 126881 | 126898 | static double xCeil(double x){ return ceil(x); } |
| 126882 | 126899 | static double xFloor(double x){ return floor(x); } |
| 126900 | + | |
| 126901 | +/* | |
| 126902 | +** Some systems do not have log2() and log10() in their standard math | |
| 126903 | +** libraries. | |
| 126904 | +*/ | |
| 126905 | +#if defined(HAVE_LOG10) && HAVE_LOG10==0 | |
| 126906 | +# define log10(X) (0.4342944819032517867*log(X)) | |
| 126907 | +#endif | |
| 126908 | +#if defined(HAVE_LOG2) && HAVE_LOG2==0 | |
| 126909 | +# define log2(X) (1.442695040888963456*log(X)) | |
| 126910 | +#endif | |
| 126911 | + | |
| 126883 | 126912 | |
| 126884 | 126913 | /* |
| 126885 | 126914 | ** Implementation of SQL functions: |
| 126886 | 126915 | ** |
| 126887 | 126916 | ** ln(X) - natural logarithm |
| @@ -136257,10 +136286,27 @@ | ||
| 136257 | 136286 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 136258 | 136287 | jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); |
| 136259 | 136288 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 136260 | 136289 | jmp4 = integrityCheckResultRow(v); |
| 136261 | 136290 | sqlite3VdbeJumpHere(v, jmp2); |
| 136291 | + | |
| 136292 | + /* The OP_IdxRowid opcode is an optimized version of OP_Column | |
| 136293 | + ** that extracts the rowid off the end of the index record. | |
| 136294 | + ** But it only works correctly if index record does not have | |
| 136295 | + ** any extra bytes at the end. Verify that this is the case. */ | |
| 136296 | + if( HasRowid(pTab) ){ | |
| 136297 | + int jmp7; | |
| 136298 | + sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur+j, 3); | |
| 136299 | + jmp7 = sqlite3VdbeAddOp3(v, OP_Eq, 3, 0, r1+pIdx->nColumn-1); | |
| 136300 | + VdbeCoverage(v); | |
| 136301 | + sqlite3VdbeLoadString(v, 3, | |
| 136302 | + "rowid not at end-of-record for row "); | |
| 136303 | + sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); | |
| 136304 | + sqlite3VdbeLoadString(v, 4, " of index "); | |
| 136305 | + sqlite3VdbeGoto(v, jmp5-1); | |
| 136306 | + sqlite3VdbeJumpHere(v, jmp7); | |
| 136307 | + } | |
| 136262 | 136308 | |
| 136263 | 136309 | /* Any indexed columns with non-BINARY collations must still hold |
| 136264 | 136310 | ** the exact same text value as the table. */ |
| 136265 | 136311 | label6 = 0; |
| 136266 | 136312 | for(kk=0; kk<pIdx->nKeyCol; kk++){ |
| @@ -140553,12 +140599,10 @@ | ||
| 140553 | 140599 | p = a[i].pExpr; |
| 140554 | 140600 | /* pCol->szEst = ... // Column size est for SELECT tables never used */ |
| 140555 | 140601 | pCol->affinity = sqlite3ExprAffinity(p); |
| 140556 | 140602 | if( pCol->affinity<=SQLITE_AFF_NONE ){ |
| 140557 | 140603 | pCol->affinity = aff; |
| 140558 | - }else if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){ | |
| 140559 | - pCol->affinity = SQLITE_AFF_FLEXNUM; | |
| 140560 | 140604 | } |
| 140561 | 140605 | if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){ |
| 140562 | 140606 | int m = 0; |
| 140563 | 140607 | Select *pS2; |
| 140564 | 140608 | for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){ |
| @@ -140567,10 +140611,13 @@ | ||
| 140567 | 140611 | if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ |
| 140568 | 140612 | pCol->affinity = SQLITE_AFF_BLOB; |
| 140569 | 140613 | }else |
| 140570 | 140614 | if( pCol->affinity>=SQLITE_AFF_NUMERIC && (m&0x02)!=0 ){ |
| 140571 | 140615 | pCol->affinity = SQLITE_AFF_BLOB; |
| 140616 | + } | |
| 140617 | + if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){ | |
| 140618 | + pCol->affinity = SQLITE_AFF_FLEXNUM; | |
| 140572 | 140619 | } |
| 140573 | 140620 | } |
| 140574 | 140621 | zType = columnType(&sNC, p, 0, 0, 0); |
| 140575 | 140622 | if( zType==0 || pCol->affinity!=sqlite3AffinityType(zType, 0) ){ |
| 140576 | 140623 | if( pCol->affinity==SQLITE_AFF_NUMERIC |
| @@ -142082,11 +142129,11 @@ | ||
| 142082 | 142129 | assert( pExpr->pRight==0 ); |
| 142083 | 142130 | if( sqlite3ExprIsVector(pCopy) ){ |
| 142084 | 142131 | sqlite3VectorErrorMsg(pSubst->pParse, pCopy); |
| 142085 | 142132 | }else{ |
| 142086 | 142133 | sqlite3 *db = pSubst->pParse->db; |
| 142087 | - if( pSubst->isOuterJoin && pCopy->op!=TK_COLUMN ){ | |
| 142134 | + if( pSubst->isOuterJoin ){ | |
| 142088 | 142135 | memset(&ifNullRow, 0, sizeof(ifNullRow)); |
| 142089 | 142136 | ifNullRow.op = TK_IF_NULL_ROW; |
| 142090 | 142137 | ifNullRow.pLeft = pCopy; |
| 142091 | 142138 | ifNullRow.iTable = pSubst->iNewTable; |
| 142092 | 142139 | ifNullRow.iColumn = -99; |
| @@ -144598,14 +144645,16 @@ | ||
| 144598 | 144645 | Select *pSelect, /* The SELECT statement being processed */ |
| 144599 | 144646 | AggInfo *pAggInfo, /* The aggregate info */ |
| 144600 | 144647 | NameContext *pNC /* Name context used to resolve agg-func args */ |
| 144601 | 144648 | ){ |
| 144602 | 144649 | assert( pAggInfo->iFirstReg==0 ); |
| 144650 | + assert( pSelect!=0 ); | |
| 144651 | + assert( pSelect->pGroupBy!=0 ); | |
| 144603 | 144652 | pAggInfo->nColumn = pAggInfo->nAccumulator; |
| 144604 | 144653 | if( ALWAYS(pAggInfo->nSortingColumn>0) ){ |
| 144605 | 144654 | if( pAggInfo->nColumn==0 ){ |
| 144606 | - pAggInfo->nSortingColumn = 0; | |
| 144655 | + pAggInfo->nSortingColumn = pSelect->pGroupBy->nExpr; | |
| 144607 | 144656 | }else{ |
| 144608 | 144657 | pAggInfo->nSortingColumn = |
| 144609 | 144658 | pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1; |
| 144610 | 144659 | } |
| 144611 | 144660 | } |
| @@ -145026,10 +145075,11 @@ | ||
| 145026 | 145075 | sqlite3 *db; |
| 145027 | 145076 | if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */ |
| 145028 | 145077 | if( p->pEList->nExpr!=1 ) return 0; /* Single result column */ |
| 145029 | 145078 | if( p->pWhere ) return 0; |
| 145030 | 145079 | if( p->pGroupBy ) return 0; |
| 145080 | + if( p->pOrderBy ) return 0; | |
| 145031 | 145081 | pExpr = p->pEList->a[0].pExpr; |
| 145032 | 145082 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */ |
| 145033 | 145083 | assert( ExprUseUToken(pExpr) ); |
| 145034 | 145084 | if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */ |
| 145035 | 145085 | assert( ExprUseXList(pExpr) ); |
| @@ -145036,11 +145086,12 @@ | ||
| 145036 | 145086 | if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ |
| 145037 | 145087 | if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ |
| 145038 | 145088 | if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */ |
| 145039 | 145089 | pSub = p->pSrc->a[0].pSelect; |
| 145040 | 145090 | if( pSub==0 ) return 0; /* The FROM is a subquery */ |
| 145041 | - if( pSub->pPrior==0 ) return 0; /* Must be a compound ry */ | |
| 145091 | + if( pSub->pPrior==0 ) return 0; /* Must be a compound */ | |
| 145092 | + if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */ | |
| 145042 | 145093 | do{ |
| 145043 | 145094 | if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */ |
| 145044 | 145095 | if( pSub->pWhere ) return 0; /* No WHERE clause */ |
| 145045 | 145096 | if( pSub->pLimit ) return 0; /* No LIMIT clause */ |
| 145046 | 145097 | if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */ |
| @@ -145479,11 +145530,10 @@ | ||
| 145479 | 145530 | #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION |
| 145480 | 145531 | if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView) |
| 145481 | 145532 | && countOfViewOptimization(pParse, p) |
| 145482 | 145533 | ){ |
| 145483 | 145534 | if( db->mallocFailed ) goto select_end; |
| 145484 | - pEList = p->pEList; | |
| 145485 | 145535 | pTabList = p->pSrc; |
| 145486 | 145536 | } |
| 145487 | 145537 | #endif |
| 145488 | 145538 | |
| 145489 | 145539 | /* For each term in the FROM clause, do two things: |
| @@ -147622,11 +147672,11 @@ | ||
| 147622 | 147672 | assert( db->mallocFailed==0 ); |
| 147623 | 147673 | sqlite3GenerateColumnNames(pParse, &sSelect); |
| 147624 | 147674 | } |
| 147625 | 147675 | sqlite3ExprListDelete(db, sSelect.pEList); |
| 147626 | 147676 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
| 147627 | - if( !db->mallocFailed ){ | |
| 147677 | + if( pParse->nErr==0 ){ | |
| 147628 | 147678 | NameContext sNC; |
| 147629 | 147679 | memset(&sNC, 0, sizeof(sNC)); |
| 147630 | 147680 | if( pReturning->nRetCol==0 ){ |
| 147631 | 147681 | pReturning->nRetCol = pNew->nExpr; |
| 147632 | 147682 | pReturning->iRetCur = pParse->nTab++; |
| @@ -156846,11 +156896,11 @@ | ||
| 156846 | 156896 | pColRef->y.pTab = pTab; |
| 156847 | 156897 | pItem->colUsed |= sqlite3ExprColUsed(pColRef); |
| 156848 | 156898 | pRhs = sqlite3PExpr(pParse, TK_UPLUS, |
| 156849 | 156899 | sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); |
| 156850 | 156900 | pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs); |
| 156851 | - if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ) ){ | |
| 156901 | + if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT) ){ | |
| 156852 | 156902 | joinType = EP_OuterON; |
| 156853 | 156903 | }else{ |
| 156854 | 156904 | joinType = EP_InnerON; |
| 156855 | 156905 | } |
| 156856 | 156906 | sqlite3SetJoinExpr(pTerm, pItem->iCursor, joinType); |
| @@ -162554,10 +162604,13 @@ | ||
| 162554 | 162604 | p->pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 162555 | 162605 | p->iDataCur = pTabItem->iCursor; |
| 162556 | 162606 | p->iIdxCur = iIdxCur; |
| 162557 | 162607 | p->iIdxCol = i; |
| 162558 | 162608 | p->bMaybeNullRow = bMaybeNullRow; |
| 162609 | + if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){ | |
| 162610 | + p->aff = pIdx->zColAff[i]; | |
| 162611 | + } | |
| 162559 | 162612 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 162560 | 162613 | p->zIdxName = pIdx->zName; |
| 162561 | 162614 | #endif |
| 162562 | 162615 | pParse->pIdxEpr = p; |
| 162563 | 162616 | if( p->pIENext==0 ){ |
| @@ -240169,11 +240222,11 @@ | ||
| 240169 | 240222 | int nArg, /* Number of args */ |
| 240170 | 240223 | sqlite3_value **apUnused /* Function arguments */ |
| 240171 | 240224 | ){ |
| 240172 | 240225 | assert( nArg==0 ); |
| 240173 | 240226 | UNUSED_PARAM2(nArg, apUnused); |
| 240174 | - sqlite3_result_text(pCtx, "fts5: 2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d", -1, SQLITE_TRANSIENT); | |
| 240227 | + sqlite3_result_text(pCtx, "fts5: 2023-03-09 16:04:34 cc8a0ee40cfc83ab42a0ff452de0a53fe17784aefb944ea7ac2cb078a8310730", -1, SQLITE_TRANSIENT); | |
| 240175 | 240228 | } |
| 240176 | 240229 | |
| 240177 | 240230 | /* |
| 240178 | 240231 | ** Return true if zName is the extension on one of the shadow tables used |
| 240179 | 240232 | ** by this module. |
| 240180 | 240233 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.41.0. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -450,13 +450,13 @@ | |
| 450 | ** |
| 451 | ** See also: [sqlite3_libversion()], |
| 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | */ |
| 455 | #define SQLITE_VERSION "3.41.0" |
| 456 | #define SQLITE_VERSION_NUMBER 3041000 |
| 457 | #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -19154,10 +19154,11 @@ | |
| 19154 | Expr *pExpr; /* The expression contained in the index */ |
| 19155 | int iDataCur; /* The data cursor associated with the index */ |
| 19156 | int iIdxCur; /* The index cursor */ |
| 19157 | int iIdxCol; /* The index column that contains value of pExpr */ |
| 19158 | u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */ |
| 19159 | IndexedExpr *pIENext; /* Next in a list of all indexed expressions */ |
| 19160 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 19161 | const char *zIdxName; /* Name of index, used only for bytecode comments */ |
| 19162 | #endif |
| 19163 | }; |
| @@ -90913,12 +90914,11 @@ | |
| 90913 | if( p->flags & (MEM_Int|MEM_IntReal) ){ |
| 90914 | h += p->u.i; |
| 90915 | }else if( p->flags & MEM_Real ){ |
| 90916 | h += sqlite3VdbeIntValue(p); |
| 90917 | }else if( p->flags & (MEM_Str|MEM_Blob) ){ |
| 90918 | h += p->n; |
| 90919 | if( p->flags & MEM_Zero ) h += p->u.nZero; |
| 90920 | } |
| 90921 | } |
| 90922 | return h; |
| 90923 | } |
| 90924 | |
| @@ -104493,18 +104493,14 @@ | |
| 104493 | } |
| 104494 | sqlite3WalkExpr(pWalker, pExpr->pLeft); |
| 104495 | if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ |
| 104496 | testcase( ExprHasProperty(pExpr, EP_OuterON) ); |
| 104497 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 104498 | if( pExpr->op==TK_NOTNULL ){ |
| 104499 | pExpr->u.zToken = "true"; |
| 104500 | ExprSetProperty(pExpr, EP_IsTrue); |
| 104501 | }else{ |
| 104502 | pExpr->u.zToken = "false"; |
| 104503 | ExprSetProperty(pExpr, EP_IsFalse); |
| 104504 | } |
| 104505 | pExpr->op = TK_TRUEFALSE; |
| 104506 | for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){ |
| 104507 | p->nRef = anRef[i]; |
| 104508 | } |
| 104509 | sqlite3ExprDelete(pParse->db, pExpr->pLeft); |
| 104510 | pExpr->pLeft = 0; |
| @@ -109846,17 +109842,28 @@ | |
| 109846 | int target /* Where to store the result of the expression */ |
| 109847 | ){ |
| 109848 | IndexedExpr *p; |
| 109849 | Vdbe *v; |
| 109850 | for(p=pParse->pIdxEpr; p; p=p->pIENext){ |
| 109851 | int iDataCur = p->iDataCur; |
| 109852 | if( iDataCur<0 ) continue; |
| 109853 | if( pParse->iSelfTab ){ |
| 109854 | if( p->iDataCur!=pParse->iSelfTab-1 ) continue; |
| 109855 | iDataCur = -1; |
| 109856 | } |
| 109857 | if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue; |
| 109858 | v = pParse->pVdbe; |
| 109859 | assert( v!=0 ); |
| 109860 | if( p->bMaybeNullRow ){ |
| 109861 | /* If the index is on a NULL row due to an outer join, then we |
| 109862 | ** cannot extract the value from the index. The value must be |
| @@ -110432,14 +110439,17 @@ | |
| 110432 | case TK_BETWEEN: { |
| 110433 | exprCodeBetween(pParse, pExpr, target, 0, 0); |
| 110434 | return target; |
| 110435 | } |
| 110436 | case TK_COLLATE: { |
| 110437 | if( !ExprHasProperty(pExpr, EP_Collate) |
| 110438 | && ALWAYS(pExpr->pLeft) |
| 110439 | && pExpr->pLeft->op==TK_FUNCTION |
| 110440 | ){ |
| 110441 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 110442 | if( inReg!=target ){ |
| 110443 | sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); |
| 110444 | inReg = target; |
| 110445 | } |
| @@ -110543,20 +110553,26 @@ | |
| 110543 | target); |
| 110544 | inReg = target; |
| 110545 | break; |
| 110546 | } |
| 110547 | } |
| 110548 | addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable); |
| 110549 | /* Temporarily disable factoring of constant expressions, since |
| 110550 | ** even though expressions may appear to be constant, they are not |
| 110551 | ** really constant because they originate from the right-hand side |
| 110552 | ** of a LEFT JOIN. */ |
| 110553 | pParse->okConstFactor = 0; |
| 110554 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 110555 | pParse->okConstFactor = okConstFactor; |
| 110556 | sqlite3VdbeJumpHere(v, addrINR); |
| 110557 | sqlite3VdbeChangeP3(v, addrINR, inReg); |
| 110558 | break; |
| 110559 | } |
| 110560 | |
| 110561 | /* |
| 110562 | ** Form A: |
| @@ -119476,10 +119492,11 @@ | |
| 119476 | ** just a reference to another column, in order for covering index |
| 119477 | ** optimizations to work correctly. So if the value is not an expression, |
| 119478 | ** turn it into one by adding a unary "+" operator. */ |
| 119479 | pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0); |
| 119480 | } |
| 119481 | sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr); |
| 119482 | pExpr = 0; |
| 119483 | goto generated_done; |
| 119484 | |
| 119485 | generated_error: |
| @@ -126878,10 +126895,22 @@ | |
| 126878 | ** unable to take a pointer to these functions. Hence, we here wrap them |
| 126879 | ** in our own actual functions. |
| 126880 | */ |
| 126881 | static double xCeil(double x){ return ceil(x); } |
| 126882 | static double xFloor(double x){ return floor(x); } |
| 126883 | |
| 126884 | /* |
| 126885 | ** Implementation of SQL functions: |
| 126886 | ** |
| 126887 | ** ln(X) - natural logarithm |
| @@ -136257,10 +136286,27 @@ | |
| 136257 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 136258 | jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); |
| 136259 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 136260 | jmp4 = integrityCheckResultRow(v); |
| 136261 | sqlite3VdbeJumpHere(v, jmp2); |
| 136262 | |
| 136263 | /* Any indexed columns with non-BINARY collations must still hold |
| 136264 | ** the exact same text value as the table. */ |
| 136265 | label6 = 0; |
| 136266 | for(kk=0; kk<pIdx->nKeyCol; kk++){ |
| @@ -140553,12 +140599,10 @@ | |
| 140553 | p = a[i].pExpr; |
| 140554 | /* pCol->szEst = ... // Column size est for SELECT tables never used */ |
| 140555 | pCol->affinity = sqlite3ExprAffinity(p); |
| 140556 | if( pCol->affinity<=SQLITE_AFF_NONE ){ |
| 140557 | pCol->affinity = aff; |
| 140558 | }else if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){ |
| 140559 | pCol->affinity = SQLITE_AFF_FLEXNUM; |
| 140560 | } |
| 140561 | if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){ |
| 140562 | int m = 0; |
| 140563 | Select *pS2; |
| 140564 | for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){ |
| @@ -140567,10 +140611,13 @@ | |
| 140567 | if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ |
| 140568 | pCol->affinity = SQLITE_AFF_BLOB; |
| 140569 | }else |
| 140570 | if( pCol->affinity>=SQLITE_AFF_NUMERIC && (m&0x02)!=0 ){ |
| 140571 | pCol->affinity = SQLITE_AFF_BLOB; |
| 140572 | } |
| 140573 | } |
| 140574 | zType = columnType(&sNC, p, 0, 0, 0); |
| 140575 | if( zType==0 || pCol->affinity!=sqlite3AffinityType(zType, 0) ){ |
| 140576 | if( pCol->affinity==SQLITE_AFF_NUMERIC |
| @@ -142082,11 +142129,11 @@ | |
| 142082 | assert( pExpr->pRight==0 ); |
| 142083 | if( sqlite3ExprIsVector(pCopy) ){ |
| 142084 | sqlite3VectorErrorMsg(pSubst->pParse, pCopy); |
| 142085 | }else{ |
| 142086 | sqlite3 *db = pSubst->pParse->db; |
| 142087 | if( pSubst->isOuterJoin && pCopy->op!=TK_COLUMN ){ |
| 142088 | memset(&ifNullRow, 0, sizeof(ifNullRow)); |
| 142089 | ifNullRow.op = TK_IF_NULL_ROW; |
| 142090 | ifNullRow.pLeft = pCopy; |
| 142091 | ifNullRow.iTable = pSubst->iNewTable; |
| 142092 | ifNullRow.iColumn = -99; |
| @@ -144598,14 +144645,16 @@ | |
| 144598 | Select *pSelect, /* The SELECT statement being processed */ |
| 144599 | AggInfo *pAggInfo, /* The aggregate info */ |
| 144600 | NameContext *pNC /* Name context used to resolve agg-func args */ |
| 144601 | ){ |
| 144602 | assert( pAggInfo->iFirstReg==0 ); |
| 144603 | pAggInfo->nColumn = pAggInfo->nAccumulator; |
| 144604 | if( ALWAYS(pAggInfo->nSortingColumn>0) ){ |
| 144605 | if( pAggInfo->nColumn==0 ){ |
| 144606 | pAggInfo->nSortingColumn = 0; |
| 144607 | }else{ |
| 144608 | pAggInfo->nSortingColumn = |
| 144609 | pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1; |
| 144610 | } |
| 144611 | } |
| @@ -145026,10 +145075,11 @@ | |
| 145026 | sqlite3 *db; |
| 145027 | if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */ |
| 145028 | if( p->pEList->nExpr!=1 ) return 0; /* Single result column */ |
| 145029 | if( p->pWhere ) return 0; |
| 145030 | if( p->pGroupBy ) return 0; |
| 145031 | pExpr = p->pEList->a[0].pExpr; |
| 145032 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */ |
| 145033 | assert( ExprUseUToken(pExpr) ); |
| 145034 | if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */ |
| 145035 | assert( ExprUseXList(pExpr) ); |
| @@ -145036,11 +145086,12 @@ | |
| 145036 | if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ |
| 145037 | if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ |
| 145038 | if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */ |
| 145039 | pSub = p->pSrc->a[0].pSelect; |
| 145040 | if( pSub==0 ) return 0; /* The FROM is a subquery */ |
| 145041 | if( pSub->pPrior==0 ) return 0; /* Must be a compound ry */ |
| 145042 | do{ |
| 145043 | if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */ |
| 145044 | if( pSub->pWhere ) return 0; /* No WHERE clause */ |
| 145045 | if( pSub->pLimit ) return 0; /* No LIMIT clause */ |
| 145046 | if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */ |
| @@ -145479,11 +145530,10 @@ | |
| 145479 | #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION |
| 145480 | if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView) |
| 145481 | && countOfViewOptimization(pParse, p) |
| 145482 | ){ |
| 145483 | if( db->mallocFailed ) goto select_end; |
| 145484 | pEList = p->pEList; |
| 145485 | pTabList = p->pSrc; |
| 145486 | } |
| 145487 | #endif |
| 145488 | |
| 145489 | /* For each term in the FROM clause, do two things: |
| @@ -147622,11 +147672,11 @@ | |
| 147622 | assert( db->mallocFailed==0 ); |
| 147623 | sqlite3GenerateColumnNames(pParse, &sSelect); |
| 147624 | } |
| 147625 | sqlite3ExprListDelete(db, sSelect.pEList); |
| 147626 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
| 147627 | if( !db->mallocFailed ){ |
| 147628 | NameContext sNC; |
| 147629 | memset(&sNC, 0, sizeof(sNC)); |
| 147630 | if( pReturning->nRetCol==0 ){ |
| 147631 | pReturning->nRetCol = pNew->nExpr; |
| 147632 | pReturning->iRetCur = pParse->nTab++; |
| @@ -156846,11 +156896,11 @@ | |
| 156846 | pColRef->y.pTab = pTab; |
| 156847 | pItem->colUsed |= sqlite3ExprColUsed(pColRef); |
| 156848 | pRhs = sqlite3PExpr(pParse, TK_UPLUS, |
| 156849 | sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); |
| 156850 | pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs); |
| 156851 | if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ) ){ |
| 156852 | joinType = EP_OuterON; |
| 156853 | }else{ |
| 156854 | joinType = EP_InnerON; |
| 156855 | } |
| 156856 | sqlite3SetJoinExpr(pTerm, pItem->iCursor, joinType); |
| @@ -162554,10 +162604,13 @@ | |
| 162554 | p->pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 162555 | p->iDataCur = pTabItem->iCursor; |
| 162556 | p->iIdxCur = iIdxCur; |
| 162557 | p->iIdxCol = i; |
| 162558 | p->bMaybeNullRow = bMaybeNullRow; |
| 162559 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 162560 | p->zIdxName = pIdx->zName; |
| 162561 | #endif |
| 162562 | pParse->pIdxEpr = p; |
| 162563 | if( p->pIENext==0 ){ |
| @@ -240169,11 +240222,11 @@ | |
| 240169 | int nArg, /* Number of args */ |
| 240170 | sqlite3_value **apUnused /* Function arguments */ |
| 240171 | ){ |
| 240172 | assert( nArg==0 ); |
| 240173 | UNUSED_PARAM2(nArg, apUnused); |
| 240174 | sqlite3_result_text(pCtx, "fts5: 2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d", -1, SQLITE_TRANSIENT); |
| 240175 | } |
| 240176 | |
| 240177 | /* |
| 240178 | ** Return true if zName is the extension on one of the shadow tables used |
| 240179 | ** by this module. |
| 240180 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.41.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -450,13 +450,13 @@ | |
| 450 | ** |
| 451 | ** See also: [sqlite3_libversion()], |
| 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | */ |
| 455 | #define SQLITE_VERSION "3.41.1" |
| 456 | #define SQLITE_VERSION_NUMBER 3041001 |
| 457 | #define SQLITE_SOURCE_ID "2023-03-09 16:04:34 cc8a0ee40cfc83ab42a0ff452de0a53fe17784aefb944ea7ac2cb078a8310730" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -19154,10 +19154,11 @@ | |
| 19154 | Expr *pExpr; /* The expression contained in the index */ |
| 19155 | int iDataCur; /* The data cursor associated with the index */ |
| 19156 | int iIdxCur; /* The index cursor */ |
| 19157 | int iIdxCol; /* The index column that contains value of pExpr */ |
| 19158 | u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */ |
| 19159 | u8 aff; /* Affinity of the pExpr expression */ |
| 19160 | IndexedExpr *pIENext; /* Next in a list of all indexed expressions */ |
| 19161 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 19162 | const char *zIdxName; /* Name of index, used only for bytecode comments */ |
| 19163 | #endif |
| 19164 | }; |
| @@ -90913,12 +90914,11 @@ | |
| 90914 | if( p->flags & (MEM_Int|MEM_IntReal) ){ |
| 90915 | h += p->u.i; |
| 90916 | }else if( p->flags & MEM_Real ){ |
| 90917 | h += sqlite3VdbeIntValue(p); |
| 90918 | }else if( p->flags & (MEM_Str|MEM_Blob) ){ |
| 90919 | /* no-op */ |
| 90920 | } |
| 90921 | } |
| 90922 | return h; |
| 90923 | } |
| 90924 | |
| @@ -104493,18 +104493,14 @@ | |
| 104493 | } |
| 104494 | sqlite3WalkExpr(pWalker, pExpr->pLeft); |
| 104495 | if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ |
| 104496 | testcase( ExprHasProperty(pExpr, EP_OuterON) ); |
| 104497 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 104498 | pExpr->u.iValue = (pExpr->op==TK_NOTNULL); |
| 104499 | pExpr->flags |= EP_IntValue; |
| 104500 | pExpr->op = TK_INTEGER; |
| 104501 | |
| 104502 | for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){ |
| 104503 | p->nRef = anRef[i]; |
| 104504 | } |
| 104505 | sqlite3ExprDelete(pParse->db, pExpr->pLeft); |
| 104506 | pExpr->pLeft = 0; |
| @@ -109846,17 +109842,28 @@ | |
| 109842 | int target /* Where to store the result of the expression */ |
| 109843 | ){ |
| 109844 | IndexedExpr *p; |
| 109845 | Vdbe *v; |
| 109846 | for(p=pParse->pIdxEpr; p; p=p->pIENext){ |
| 109847 | u8 exprAff; |
| 109848 | int iDataCur = p->iDataCur; |
| 109849 | if( iDataCur<0 ) continue; |
| 109850 | if( pParse->iSelfTab ){ |
| 109851 | if( p->iDataCur!=pParse->iSelfTab-1 ) continue; |
| 109852 | iDataCur = -1; |
| 109853 | } |
| 109854 | if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue; |
| 109855 | assert( p->aff>=SQLITE_AFF_BLOB && p->aff<=SQLITE_AFF_NUMERIC ); |
| 109856 | exprAff = sqlite3ExprAffinity(pExpr); |
| 109857 | if( (exprAff<=SQLITE_AFF_BLOB && p->aff!=SQLITE_AFF_BLOB) |
| 109858 | || (exprAff==SQLITE_AFF_TEXT && p->aff!=SQLITE_AFF_TEXT) |
| 109859 | || (exprAff>=SQLITE_AFF_NUMERIC && p->aff!=SQLITE_AFF_NUMERIC) |
| 109860 | ){ |
| 109861 | /* Affinity mismatch on a generated column */ |
| 109862 | continue; |
| 109863 | } |
| 109864 | |
| 109865 | v = pParse->pVdbe; |
| 109866 | assert( v!=0 ); |
| 109867 | if( p->bMaybeNullRow ){ |
| 109868 | /* If the index is on a NULL row due to an outer join, then we |
| 109869 | ** cannot extract the value from the index. The value must be |
| @@ -110432,14 +110439,17 @@ | |
| 110439 | case TK_BETWEEN: { |
| 110440 | exprCodeBetween(pParse, pExpr, target, 0, 0); |
| 110441 | return target; |
| 110442 | } |
| 110443 | case TK_COLLATE: { |
| 110444 | if( !ExprHasProperty(pExpr, EP_Collate) ){ |
| 110445 | /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called |
| 110446 | ** "SOFT-COLLATE" that is added to constraints that are pushed down |
| 110447 | ** from outer queries into sub-queries by the push-down optimization. |
| 110448 | ** Clear subtypes as subtypes may not cross a subquery boundary. |
| 110449 | */ |
| 110450 | assert( pExpr->pLeft ); |
| 110451 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 110452 | if( inReg!=target ){ |
| 110453 | sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); |
| 110454 | inReg = target; |
| 110455 | } |
| @@ -110543,20 +110553,26 @@ | |
| 110553 | target); |
| 110554 | inReg = target; |
| 110555 | break; |
| 110556 | } |
| 110557 | } |
| 110558 | addrINR = sqlite3VdbeAddOp3(v, OP_IfNullRow, pExpr->iTable, 0, target); |
| 110559 | /* The OP_IfNullRow opcode above can overwrite the result register with |
| 110560 | ** NULL. So we have to ensure that the result register is not a value |
| 110561 | ** that is suppose to be a constant. Two defenses are needed: |
| 110562 | ** (1) Temporarily disable factoring of constant expressions |
| 110563 | ** (2) Make sure the computed value really is stored in register |
| 110564 | ** "target" and not someplace else. |
| 110565 | */ |
| 110566 | pParse->okConstFactor = 0; /* note (1) above */ |
| 110567 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 110568 | pParse->okConstFactor = okConstFactor; |
| 110569 | if( inReg!=target ){ /* note (2) above */ |
| 110570 | sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); |
| 110571 | inReg = target; |
| 110572 | } |
| 110573 | sqlite3VdbeJumpHere(v, addrINR); |
| 110574 | break; |
| 110575 | } |
| 110576 | |
| 110577 | /* |
| 110578 | ** Form A: |
| @@ -119476,10 +119492,11 @@ | |
| 119492 | ** just a reference to another column, in order for covering index |
| 119493 | ** optimizations to work correctly. So if the value is not an expression, |
| 119494 | ** turn it into one by adding a unary "+" operator. */ |
| 119495 | pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0); |
| 119496 | } |
| 119497 | if( pExpr && pExpr->op!=TK_RAISE ) pExpr->affExpr = pCol->affinity; |
| 119498 | sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr); |
| 119499 | pExpr = 0; |
| 119500 | goto generated_done; |
| 119501 | |
| 119502 | generated_error: |
| @@ -126878,10 +126895,22 @@ | |
| 126895 | ** unable to take a pointer to these functions. Hence, we here wrap them |
| 126896 | ** in our own actual functions. |
| 126897 | */ |
| 126898 | static double xCeil(double x){ return ceil(x); } |
| 126899 | static double xFloor(double x){ return floor(x); } |
| 126900 | |
| 126901 | /* |
| 126902 | ** Some systems do not have log2() and log10() in their standard math |
| 126903 | ** libraries. |
| 126904 | */ |
| 126905 | #if defined(HAVE_LOG10) && HAVE_LOG10==0 |
| 126906 | # define log10(X) (0.4342944819032517867*log(X)) |
| 126907 | #endif |
| 126908 | #if defined(HAVE_LOG2) && HAVE_LOG2==0 |
| 126909 | # define log2(X) (1.442695040888963456*log(X)) |
| 126910 | #endif |
| 126911 | |
| 126912 | |
| 126913 | /* |
| 126914 | ** Implementation of SQL functions: |
| 126915 | ** |
| 126916 | ** ln(X) - natural logarithm |
| @@ -136257,10 +136286,27 @@ | |
| 136286 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 136287 | jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); |
| 136288 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 136289 | jmp4 = integrityCheckResultRow(v); |
| 136290 | sqlite3VdbeJumpHere(v, jmp2); |
| 136291 | |
| 136292 | /* The OP_IdxRowid opcode is an optimized version of OP_Column |
| 136293 | ** that extracts the rowid off the end of the index record. |
| 136294 | ** But it only works correctly if index record does not have |
| 136295 | ** any extra bytes at the end. Verify that this is the case. */ |
| 136296 | if( HasRowid(pTab) ){ |
| 136297 | int jmp7; |
| 136298 | sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur+j, 3); |
| 136299 | jmp7 = sqlite3VdbeAddOp3(v, OP_Eq, 3, 0, r1+pIdx->nColumn-1); |
| 136300 | VdbeCoverage(v); |
| 136301 | sqlite3VdbeLoadString(v, 3, |
| 136302 | "rowid not at end-of-record for row "); |
| 136303 | sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); |
| 136304 | sqlite3VdbeLoadString(v, 4, " of index "); |
| 136305 | sqlite3VdbeGoto(v, jmp5-1); |
| 136306 | sqlite3VdbeJumpHere(v, jmp7); |
| 136307 | } |
| 136308 | |
| 136309 | /* Any indexed columns with non-BINARY collations must still hold |
| 136310 | ** the exact same text value as the table. */ |
| 136311 | label6 = 0; |
| 136312 | for(kk=0; kk<pIdx->nKeyCol; kk++){ |
| @@ -140553,12 +140599,10 @@ | |
| 140599 | p = a[i].pExpr; |
| 140600 | /* pCol->szEst = ... // Column size est for SELECT tables never used */ |
| 140601 | pCol->affinity = sqlite3ExprAffinity(p); |
| 140602 | if( pCol->affinity<=SQLITE_AFF_NONE ){ |
| 140603 | pCol->affinity = aff; |
| 140604 | } |
| 140605 | if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){ |
| 140606 | int m = 0; |
| 140607 | Select *pS2; |
| 140608 | for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){ |
| @@ -140567,10 +140611,13 @@ | |
| 140611 | if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ |
| 140612 | pCol->affinity = SQLITE_AFF_BLOB; |
| 140613 | }else |
| 140614 | if( pCol->affinity>=SQLITE_AFF_NUMERIC && (m&0x02)!=0 ){ |
| 140615 | pCol->affinity = SQLITE_AFF_BLOB; |
| 140616 | } |
| 140617 | if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){ |
| 140618 | pCol->affinity = SQLITE_AFF_FLEXNUM; |
| 140619 | } |
| 140620 | } |
| 140621 | zType = columnType(&sNC, p, 0, 0, 0); |
| 140622 | if( zType==0 || pCol->affinity!=sqlite3AffinityType(zType, 0) ){ |
| 140623 | if( pCol->affinity==SQLITE_AFF_NUMERIC |
| @@ -142082,11 +142129,11 @@ | |
| 142129 | assert( pExpr->pRight==0 ); |
| 142130 | if( sqlite3ExprIsVector(pCopy) ){ |
| 142131 | sqlite3VectorErrorMsg(pSubst->pParse, pCopy); |
| 142132 | }else{ |
| 142133 | sqlite3 *db = pSubst->pParse->db; |
| 142134 | if( pSubst->isOuterJoin ){ |
| 142135 | memset(&ifNullRow, 0, sizeof(ifNullRow)); |
| 142136 | ifNullRow.op = TK_IF_NULL_ROW; |
| 142137 | ifNullRow.pLeft = pCopy; |
| 142138 | ifNullRow.iTable = pSubst->iNewTable; |
| 142139 | ifNullRow.iColumn = -99; |
| @@ -144598,14 +144645,16 @@ | |
| 144645 | Select *pSelect, /* The SELECT statement being processed */ |
| 144646 | AggInfo *pAggInfo, /* The aggregate info */ |
| 144647 | NameContext *pNC /* Name context used to resolve agg-func args */ |
| 144648 | ){ |
| 144649 | assert( pAggInfo->iFirstReg==0 ); |
| 144650 | assert( pSelect!=0 ); |
| 144651 | assert( pSelect->pGroupBy!=0 ); |
| 144652 | pAggInfo->nColumn = pAggInfo->nAccumulator; |
| 144653 | if( ALWAYS(pAggInfo->nSortingColumn>0) ){ |
| 144654 | if( pAggInfo->nColumn==0 ){ |
| 144655 | pAggInfo->nSortingColumn = pSelect->pGroupBy->nExpr; |
| 144656 | }else{ |
| 144657 | pAggInfo->nSortingColumn = |
| 144658 | pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1; |
| 144659 | } |
| 144660 | } |
| @@ -145026,10 +145075,11 @@ | |
| 145075 | sqlite3 *db; |
| 145076 | if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */ |
| 145077 | if( p->pEList->nExpr!=1 ) return 0; /* Single result column */ |
| 145078 | if( p->pWhere ) return 0; |
| 145079 | if( p->pGroupBy ) return 0; |
| 145080 | if( p->pOrderBy ) return 0; |
| 145081 | pExpr = p->pEList->a[0].pExpr; |
| 145082 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */ |
| 145083 | assert( ExprUseUToken(pExpr) ); |
| 145084 | if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */ |
| 145085 | assert( ExprUseXList(pExpr) ); |
| @@ -145036,11 +145086,12 @@ | |
| 145086 | if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ |
| 145087 | if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ |
| 145088 | if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */ |
| 145089 | pSub = p->pSrc->a[0].pSelect; |
| 145090 | if( pSub==0 ) return 0; /* The FROM is a subquery */ |
| 145091 | if( pSub->pPrior==0 ) return 0; /* Must be a compound */ |
| 145092 | if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */ |
| 145093 | do{ |
| 145094 | if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */ |
| 145095 | if( pSub->pWhere ) return 0; /* No WHERE clause */ |
| 145096 | if( pSub->pLimit ) return 0; /* No LIMIT clause */ |
| 145097 | if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */ |
| @@ -145479,11 +145530,10 @@ | |
| 145530 | #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION |
| 145531 | if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView) |
| 145532 | && countOfViewOptimization(pParse, p) |
| 145533 | ){ |
| 145534 | if( db->mallocFailed ) goto select_end; |
| 145535 | pTabList = p->pSrc; |
| 145536 | } |
| 145537 | #endif |
| 145538 | |
| 145539 | /* For each term in the FROM clause, do two things: |
| @@ -147622,11 +147672,11 @@ | |
| 147672 | assert( db->mallocFailed==0 ); |
| 147673 | sqlite3GenerateColumnNames(pParse, &sSelect); |
| 147674 | } |
| 147675 | sqlite3ExprListDelete(db, sSelect.pEList); |
| 147676 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
| 147677 | if( pParse->nErr==0 ){ |
| 147678 | NameContext sNC; |
| 147679 | memset(&sNC, 0, sizeof(sNC)); |
| 147680 | if( pReturning->nRetCol==0 ){ |
| 147681 | pReturning->nRetCol = pNew->nExpr; |
| 147682 | pReturning->iRetCur = pParse->nTab++; |
| @@ -156846,11 +156896,11 @@ | |
| 156896 | pColRef->y.pTab = pTab; |
| 156897 | pItem->colUsed |= sqlite3ExprColUsed(pColRef); |
| 156898 | pRhs = sqlite3PExpr(pParse, TK_UPLUS, |
| 156899 | sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); |
| 156900 | pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs); |
| 156901 | if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT) ){ |
| 156902 | joinType = EP_OuterON; |
| 156903 | }else{ |
| 156904 | joinType = EP_InnerON; |
| 156905 | } |
| 156906 | sqlite3SetJoinExpr(pTerm, pItem->iCursor, joinType); |
| @@ -162554,10 +162604,13 @@ | |
| 162604 | p->pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 162605 | p->iDataCur = pTabItem->iCursor; |
| 162606 | p->iIdxCur = iIdxCur; |
| 162607 | p->iIdxCol = i; |
| 162608 | p->bMaybeNullRow = bMaybeNullRow; |
| 162609 | if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){ |
| 162610 | p->aff = pIdx->zColAff[i]; |
| 162611 | } |
| 162612 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 162613 | p->zIdxName = pIdx->zName; |
| 162614 | #endif |
| 162615 | pParse->pIdxEpr = p; |
| 162616 | if( p->pIENext==0 ){ |
| @@ -240169,11 +240222,11 @@ | |
| 240222 | int nArg, /* Number of args */ |
| 240223 | sqlite3_value **apUnused /* Function arguments */ |
| 240224 | ){ |
| 240225 | assert( nArg==0 ); |
| 240226 | UNUSED_PARAM2(nArg, apUnused); |
| 240227 | sqlite3_result_text(pCtx, "fts5: 2023-03-09 16:04:34 cc8a0ee40cfc83ab42a0ff452de0a53fe17784aefb944ea7ac2cb078a8310730", -1, SQLITE_TRANSIENT); |
| 240228 | } |
| 240229 | |
| 240230 | /* |
| 240231 | ** Return true if zName is the extension on one of the shadow tables used |
| 240232 | ** by this module. |
| 240233 |
+3
-3
| --- extsrc/sqlite3.h | ||
| +++ extsrc/sqlite3.h | ||
| @@ -144,13 +144,13 @@ | ||
| 144 | 144 | ** |
| 145 | 145 | ** See also: [sqlite3_libversion()], |
| 146 | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | 148 | */ |
| 149 | -#define SQLITE_VERSION "3.41.0" | |
| 150 | -#define SQLITE_VERSION_NUMBER 3041000 | |
| 151 | -#define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d" | |
| 149 | +#define SQLITE_VERSION "3.41.1" | |
| 150 | +#define SQLITE_VERSION_NUMBER 3041001 | |
| 151 | +#define SQLITE_SOURCE_ID "2023-03-09 16:04:34 cc8a0ee40cfc83ab42a0ff452de0a53fe17784aefb944ea7ac2cb078a8310730" | |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | 156 | ** |
| 157 | 157 |
| --- extsrc/sqlite3.h | |
| +++ extsrc/sqlite3.h | |
| @@ -144,13 +144,13 @@ | |
| 144 | ** |
| 145 | ** See also: [sqlite3_libversion()], |
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ |
| 149 | #define SQLITE_VERSION "3.41.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3041000 |
| 151 | #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| 157 |
| --- extsrc/sqlite3.h | |
| +++ extsrc/sqlite3.h | |
| @@ -144,13 +144,13 @@ | |
| 144 | ** |
| 145 | ** See also: [sqlite3_libversion()], |
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ |
| 149 | #define SQLITE_VERSION "3.41.1" |
| 150 | #define SQLITE_VERSION_NUMBER 3041001 |
| 151 | #define SQLITE_SOURCE_ID "2023-03-09 16:04:34 cc8a0ee40cfc83ab42a0ff452de0a53fe17784aefb944ea7ac2cb078a8310730" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| 157 |