| | @@ -452,11 +452,11 @@ |
| 452 | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 454 | */ |
| 455 | 455 | #define SQLITE_VERSION "3.39.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3039000 |
| 457 | | -#define SQLITE_SOURCE_ID "2022-05-25 13:10:29 c48a735bd4a1dbd541aed5937c25fc0c606c4263d8ee94cae30a06b1a7b26d9a" |
| 457 | +#define SQLITE_SOURCE_ID "2022-06-03 14:08:40 d18818afc6021a32989499c26ab38fa442e5a55e662e39bb06e5c0daa9c65e25" |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| | @@ -6586,11 +6586,13 @@ |
| 6586 | 6586 | ** CAPI3REF: Return The Schema Name For A Database Connection |
| 6587 | 6587 | ** METHOD: sqlite3 |
| 6588 | 6588 | ** |
| 6589 | 6589 | ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name |
| 6590 | 6590 | ** for the N-th database on database connection D, or a NULL pointer of N is |
| 6591 | | -** out of range. |
| 6591 | +** out of range. An N alue of 0 means the main database file. An N of 1 is |
| 6592 | +** the "temp" schema. Larger values of N correspond to various ATTACH-ed |
| 6593 | +** databases. |
| 6592 | 6594 | ** |
| 6593 | 6595 | ** Space to hold the string that is returned by sqlite3_db_name() is managed |
| 6594 | 6596 | ** by SQLite itself. The string might be deallocated by any operation that |
| 6595 | 6597 | ** changes the schema, including [ATTACH] or [DETACH] or calls to |
| 6596 | 6598 | ** [sqlite3_serialize()] or [sqlite3_deserialize()], even operations that |
| | @@ -17184,11 +17186,11 @@ |
| 17184 | 17186 | #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */ |
| 17185 | 17187 | #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ |
| 17186 | 17188 | #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a |
| 17187 | 17189 | ** single query - might change over time */ |
| 17188 | 17190 | #define SQLITE_FUNC_TEST 0x4000 /* Built-in testing functions */ |
| 17189 | | -#define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */ |
| 17191 | +/* 0x8000 -- available for reuse */ |
| 17190 | 17192 | #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ |
| 17191 | 17193 | #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */ |
| 17192 | 17194 | #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */ |
| 17193 | 17195 | #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */ |
| 17194 | 17196 | #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ |
| | @@ -17201,10 +17203,11 @@ |
| 17201 | 17203 | #define INLINEFUNC_implies_nonnull_row 1 |
| 17202 | 17204 | #define INLINEFUNC_expr_implies_expr 2 |
| 17203 | 17205 | #define INLINEFUNC_expr_compare 3 |
| 17204 | 17206 | #define INLINEFUNC_affinity 4 |
| 17205 | 17207 | #define INLINEFUNC_iif 5 |
| 17208 | +#define INLINEFUNC_sqlite_offset 6 |
| 17206 | 17209 | #define INLINEFUNC_unlikely 99 /* Default case */ |
| 17207 | 17210 | |
| 17208 | 17211 | /* |
| 17209 | 17212 | ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |
| 17210 | 17213 | ** used to create the initializers for the FuncDef structures. |
| | @@ -75943,11 +75946,11 @@ |
| 75943 | 75946 | } |
| 75944 | 75947 | |
| 75945 | 75948 | TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", |
| 75946 | 75949 | pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno, |
| 75947 | 75950 | loc==0 ? "overwrite" : "new entry")); |
| 75948 | | - assert( pPage->isInit ); |
| 75951 | + assert( pPage->isInit || CORRUPT_DB ); |
| 75949 | 75952 | newCell = pBt->pTmpSpace; |
| 75950 | 75953 | assert( newCell!=0 ); |
| 75951 | 75954 | if( flags & BTREE_PREFORMAT ){ |
| 75952 | 75955 | rc = SQLITE_OK; |
| 75953 | 75956 | szNew = pBt->nPreformatSize; |
| | @@ -107506,11 +107509,21 @@ |
| 107506 | 107509 | memset(&caseExpr, 0, sizeof(caseExpr)); |
| 107507 | 107510 | caseExpr.op = TK_CASE; |
| 107508 | 107511 | caseExpr.x.pList = pFarg; |
| 107509 | 107512 | return sqlite3ExprCodeTarget(pParse, &caseExpr, target); |
| 107510 | 107513 | } |
| 107511 | | - |
| 107514 | +#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 107515 | + case INLINEFUNC_sqlite_offset: { |
| 107516 | + Expr *pArg = pFarg->a[0].pExpr; |
| 107517 | + if( pArg->op==TK_COLUMN && pArg->iTable>=0 ){ |
| 107518 | + sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target); |
| 107519 | + }else{ |
| 107520 | + sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 107521 | + } |
| 107522 | + break; |
| 107523 | + } |
| 107524 | +#endif |
| 107512 | 107525 | default: { |
| 107513 | 107526 | /* The UNLIKELY() function is a no-op. The result is the value |
| 107514 | 107527 | ** of the first argument. |
| 107515 | 107528 | */ |
| 107516 | 107529 | assert( nFarg==1 || nFarg==2 ); |
| | @@ -108045,24 +108058,12 @@ |
| 108045 | 108058 | #endif |
| 108046 | 108059 | if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 108047 | 108060 | if( !pColl ) pColl = db->pDfltColl; |
| 108048 | 108061 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ); |
| 108049 | 108062 | } |
| 108050 | | -#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 108051 | | - if( (pDef->funcFlags & SQLITE_FUNC_OFFSET)!=0 && ALWAYS(pFarg!=0) ){ |
| 108052 | | - Expr *pArg = pFarg->a[0].pExpr; |
| 108053 | | - if( pArg->op==TK_COLUMN ){ |
| 108054 | | - sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target); |
| 108055 | | - }else{ |
| 108056 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 108057 | | - } |
| 108058 | | - }else |
| 108059 | | -#endif |
| 108060 | | - { |
| 108061 | | - sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg, |
| 108062 | | - pDef, pExpr->op2); |
| 108063 | | - } |
| 108063 | + sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg, |
| 108064 | + pDef, pExpr->op2); |
| 108064 | 108065 | if( nFarg ){ |
| 108065 | 108066 | if( constMask==0 ){ |
| 108066 | 108067 | sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 108067 | 108068 | }else{ |
| 108068 | 108069 | sqlite3VdbeReleaseRegisters(pParse, r1, nFarg, constMask, 1); |
| | @@ -111282,31 +111283,37 @@ |
| 111282 | 111283 | if( pParse->nErr ) rc = pParse->rc; |
| 111283 | 111284 | } |
| 111284 | 111285 | if( rc==SQLITE_OK && pStep->zTarget ){ |
| 111285 | 111286 | SrcList *pSrc = sqlite3TriggerStepSrc(pParse, pStep); |
| 111286 | 111287 | if( pSrc ){ |
| 111287 | | - int i; |
| 111288 | | - for(i=0; i<pSrc->nSrc && rc==SQLITE_OK; i++){ |
| 111289 | | - SrcItem *p = &pSrc->a[i]; |
| 111290 | | - p->iCursor = pParse->nTab++; |
| 111291 | | - if( p->pSelect ){ |
| 111292 | | - sqlite3SelectPrep(pParse, p->pSelect, 0); |
| 111293 | | - sqlite3ExpandSubquery(pParse, p); |
| 111294 | | - assert( i>0 ); |
| 111295 | | - assert( pStep->pFrom->a[i-1].pSelect ); |
| 111296 | | - sqlite3SelectPrep(pParse, pStep->pFrom->a[i-1].pSelect, 0); |
| 111297 | | - }else{ |
| 111298 | | - p->pTab = sqlite3LocateTableItem(pParse, 0, p); |
| 111299 | | - if( p->pTab==0 ){ |
| 111300 | | - rc = SQLITE_ERROR; |
| 111301 | | - }else{ |
| 111302 | | - p->pTab->nTabRef++; |
| 111303 | | - rc = sqlite3ViewGetColumnNames(pParse, p->pTab); |
| 111288 | + Select *pSel = sqlite3SelectNew( |
| 111289 | + pParse, pStep->pExprList, pSrc, 0, 0, 0, 0, 0, 0 |
| 111290 | + ); |
| 111291 | + if( pSel==0 ){ |
| 111292 | + pStep->pExprList = 0; |
| 111293 | + pSrc = 0; |
| 111294 | + rc = SQLITE_NOMEM; |
| 111295 | + }else{ |
| 111296 | + sqlite3SelectPrep(pParse, pSel, 0); |
| 111297 | + rc = pParse->nErr ? SQLITE_ERROR : SQLITE_OK; |
| 111298 | + assert( pStep->pExprList==0 || pStep->pExprList==pSel->pEList ); |
| 111299 | + assert( pSrc==pSel->pSrc ); |
| 111300 | + if( pStep->pExprList ) pSel->pEList = 0; |
| 111301 | + pSel->pSrc = 0; |
| 111302 | + sqlite3SelectDelete(db, pSel); |
| 111303 | + } |
| 111304 | + if( pStep->pFrom ){ |
| 111305 | + int i; |
| 111306 | + for(i=0; i<pStep->pFrom->nSrc && rc==SQLITE_OK; i++){ |
| 111307 | + SrcItem *p = &pStep->pFrom->a[i]; |
| 111308 | + if( p->pSelect ){ |
| 111309 | + sqlite3SelectPrep(pParse, p->pSelect, 0); |
| 111304 | 111310 | } |
| 111305 | 111311 | } |
| 111306 | 111312 | } |
| 111307 | | - if( rc==SQLITE_OK && db->mallocFailed ){ |
| 111313 | + |
| 111314 | + if( db->mallocFailed ){ |
| 111308 | 111315 | rc = SQLITE_NOMEM; |
| 111309 | 111316 | } |
| 111310 | 111317 | sNC.pSrcList = pSrc; |
| 111311 | 111318 | if( rc==SQLITE_OK && pStep->pWhere ){ |
| 111312 | 111319 | rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere); |
| | @@ -111753,10 +111760,19 @@ |
| 111753 | 111760 | if( rc==SQLITE_OK ){ |
| 111754 | 111761 | renameWalkTrigger(&sWalker, pTrigger); |
| 111755 | 111762 | for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){ |
| 111756 | 111763 | if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){ |
| 111757 | 111764 | renameTokenFind(&sParse, &sCtx, pStep->zTarget); |
| 111765 | + } |
| 111766 | + if( pStep->pFrom ){ |
| 111767 | + int i; |
| 111768 | + for(i=0; i<pStep->pFrom->nSrc; i++){ |
| 111769 | + SrcItem *pItem = &pStep->pFrom->a[i]; |
| 111770 | + if( 0==sqlite3_stricmp(pItem->zName, zOld) ){ |
| 111771 | + renameTokenFind(&sParse, &sCtx, pItem->zName); |
| 111772 | + } |
| 111773 | + } |
| 111758 | 111774 | } |
| 111759 | 111775 | } |
| 111760 | 111776 | } |
| 111761 | 111777 | } |
| 111762 | 111778 | } |
| | @@ -124495,12 +124511,11 @@ |
| 124495 | 124511 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 124496 | 124512 | INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), |
| 124497 | 124513 | INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), |
| 124498 | 124514 | INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), |
| 124499 | 124515 | #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 124500 | | - {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF, |
| 124501 | | - 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} }, |
| 124516 | + INLINE_FUNC(sqlite_offset, 1, INLINEFUNC_sqlite_offset, 0 ), |
| 124502 | 124517 | #endif |
| 124503 | 124518 | FUNCTION(ltrim, 1, 1, 0, trimFunc ), |
| 124504 | 124519 | FUNCTION(ltrim, 2, 1, 0, trimFunc ), |
| 124505 | 124520 | FUNCTION(rtrim, 1, 2, 0, trimFunc ), |
| 124506 | 124521 | FUNCTION(rtrim, 2, 2, 0, trimFunc ), |
| | @@ -137648,14 +137663,15 @@ |
| 137648 | 137663 | pColExpr = pColExpr->pRight; |
| 137649 | 137664 | assert( pColExpr!=0 ); |
| 137650 | 137665 | } |
| 137651 | 137666 | if( pColExpr->op==TK_COLUMN |
| 137652 | 137667 | && ALWAYS( ExprUseYTab(pColExpr) ) |
| 137653 | | - && (pTab = pColExpr->y.pTab)!=0 |
| 137668 | + && ALWAYS( pColExpr->y.pTab!=0 ) |
| 137654 | 137669 | ){ |
| 137655 | 137670 | /* For columns use the column name name */ |
| 137656 | 137671 | int iCol = pColExpr->iColumn; |
| 137672 | + pTab = pColExpr->y.pTab; |
| 137657 | 137673 | if( iCol<0 ) iCol = pTab->iPKey; |
| 137658 | 137674 | zName = iCol>=0 ? pTab->aCol[iCol].zCnName : "rowid"; |
| 137659 | 137675 | }else if( pColExpr->op==TK_ID ){ |
| 137660 | 137676 | assert( !ExprHasProperty(pColExpr, EP_IntValue) ); |
| 137661 | 137677 | zName = pColExpr->u.zToken; |
| | @@ -139264,10 +139280,15 @@ |
| 139264 | 139280 | sqlite3SetJoinExpr(pNew, pExpr->w.iJoin, |
| 139265 | 139281 | pExpr->flags & (EP_OuterON|EP_InnerON)); |
| 139266 | 139282 | } |
| 139267 | 139283 | sqlite3ExprDelete(db, pExpr); |
| 139268 | 139284 | pExpr = pNew; |
| 139285 | + if( pExpr->op==TK_TRUEFALSE ){ |
| 139286 | + pExpr->u.iValue = sqlite3ExprTruthValue(pExpr); |
| 139287 | + pExpr->op = TK_INTEGER; |
| 139288 | + ExprSetProperty(pExpr, EP_IntValue); |
| 139289 | + } |
| 139269 | 139290 | |
| 139270 | 139291 | /* Ensure that the expression now has an implicit collation sequence, |
| 139271 | 139292 | ** just as it did when it was a column of a view or sub-query. */ |
| 139272 | 139293 | if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ |
| 139273 | 139294 | CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); |
| | @@ -143981,11 +144002,11 @@ |
| 143981 | 144002 | ** sees an UPDATE statement inside the body of a CREATE TRIGGER. |
| 143982 | 144003 | */ |
| 143983 | 144004 | SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep( |
| 143984 | 144005 | Parse *pParse, /* Parser */ |
| 143985 | 144006 | Token *pTableName, /* Name of the table to be updated */ |
| 143986 | | - SrcList *pFrom, |
| 144007 | + SrcList *pFrom, /* FROM clause for an UPDATE-FROM, or NULL */ |
| 143987 | 144008 | ExprList *pEList, /* The SET clause: list of column and new values */ |
| 143988 | 144009 | Expr *pWhere, /* The WHERE clause */ |
| 143989 | 144010 | u8 orconf, /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */ |
| 143990 | 144011 | const char *zStart, /* Start of SQL text */ |
| 143991 | 144012 | const char *zEnd /* End of SQL text */ |
| | @@ -144317,10 +144338,18 @@ |
| 144317 | 144338 | if( pSchema!=db->aDb[1].pSchema ){ |
| 144318 | 144339 | pSrc->a[0].pSchema = pSchema; |
| 144319 | 144340 | } |
| 144320 | 144341 | if( pStep->pFrom ){ |
| 144321 | 144342 | SrcList *pDup = sqlite3SrcListDup(db, pStep->pFrom, 0); |
| 144343 | + if( pDup && pDup->nSrc>1 && !IN_RENAME_OBJECT ){ |
| 144344 | + Select *pSubquery; |
| 144345 | + Token as; |
| 144346 | + pSubquery = sqlite3SelectNew(pParse,0,pDup,0,0,0,0,SF_NestedFrom,0); |
| 144347 | + as.n = 0; |
| 144348 | + as.z = 0; |
| 144349 | + pDup = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0); |
| 144350 | + } |
| 144322 | 144351 | pSrc = sqlite3SrcListAppendList(pParse, pSrc, pDup); |
| 144323 | 144352 | } |
| 144324 | 144353 | }else{ |
| 144325 | 144354 | sqlite3DbFree(db, zName); |
| 144326 | 144355 | } |
| | @@ -148977,12 +149006,13 @@ |
| 148977 | 149006 | #define WO_ISNULL 0x0100 |
| 148978 | 149007 | #define WO_OR 0x0200 /* Two or more OR-connected terms */ |
| 148979 | 149008 | #define WO_AND 0x0400 /* Two or more AND-connected terms */ |
| 148980 | 149009 | #define WO_EQUIV 0x0800 /* Of the form A==B, both columns */ |
| 148981 | 149010 | #define WO_NOOP 0x1000 /* This term does not restrict search space */ |
| 149011 | +#define WO_ROWVAL 0x2000 /* A row-value term */ |
| 148982 | 149012 | |
| 148983 | | -#define WO_ALL 0x1fff /* Mask of all possible WO_* values */ |
| 149013 | +#define WO_ALL 0x3fff /* Mask of all possible WO_* values */ |
| 148984 | 149014 | #define WO_SINGLE 0x01ff /* Mask of all non-compound WO_* values */ |
| 148985 | 149015 | |
| 148986 | 149016 | /* |
| 148987 | 149017 | ** These are definitions of bits in the WhereLoop.wsFlags field. |
| 148988 | 149018 | ** The particular combination of bits in each WhereLoop help to |
| | @@ -151622,10 +151652,13 @@ |
| 151622 | 151652 | if( pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT) ){ |
| 151623 | 151653 | if( !ExprHasProperty(pE,EP_OuterON|EP_InnerON) ){ |
| 151624 | 151654 | /* Defer processing WHERE clause constraints until after outer |
| 151625 | 151655 | ** join processing. tag-20220513a */ |
| 151626 | 151656 | continue; |
| 151657 | + }else if( (pTabItem->fg.jointype & JT_LEFT)==JT_LEFT |
| 151658 | + && !ExprHasProperty(pE,EP_OuterON) ){ |
| 151659 | + continue; |
| 151627 | 151660 | }else{ |
| 151628 | 151661 | Bitmask m = sqlite3WhereGetMask(&pWInfo->sMaskSet, pE->w.iJoin); |
| 151629 | 151662 | if( m & pLevel->notReady ){ |
| 151630 | 151663 | /* An ON clause that is not ripe */ |
| 151631 | 151664 | continue; |
| | @@ -151857,11 +151890,15 @@ |
| 151857 | 151890 | } |
| 151858 | 151891 | if( (pTabItem->fg.jointype & JT_LTORJ)==0 ){ |
| 151859 | 151892 | mAll |= pLoop->maskSelf; |
| 151860 | 151893 | for(k=0; k<pWC->nTerm; k++){ |
| 151861 | 151894 | WhereTerm *pTerm = &pWC->a[k]; |
| 151862 | | - if( pTerm->wtFlags & TERM_VIRTUAL ) break; |
| 151895 | + if( (pTerm->wtFlags & (TERM_VIRTUAL|TERM_SLICE))!=0 |
| 151896 | + && pTerm->eOperator!=WO_ROWVAL |
| 151897 | + ){ |
| 151898 | + break; |
| 151899 | + } |
| 151863 | 151900 | if( pTerm->prereqAll & ~mAll ) continue; |
| 151864 | 151901 | if( ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) ) continue; |
| 151865 | 151902 | pSubWhere = sqlite3ExprAnd(pParse, pSubWhere, |
| 151866 | 151903 | sqlite3ExprDup(pParse->db, pTerm->pExpr, 0)); |
| 151867 | 151904 | } |
| | @@ -153015,11 +153052,11 @@ |
| 153015 | 153052 | |
| 153016 | 153053 | #ifdef SQLITE_DEBUG |
| 153017 | 153054 | if( prereqAll!=sqlite3WhereExprUsageNN(pMaskSet, pExpr) ){ |
| 153018 | 153055 | printf("\n*** Incorrect prereqAll computed for:\n"); |
| 153019 | 153056 | sqlite3TreeViewExpr(0,pExpr,0); |
| 153020 | | - abort(); |
| 153057 | + assert( 0 ); |
| 153021 | 153058 | } |
| 153022 | 153059 | #endif |
| 153023 | 153060 | |
| 153024 | 153061 | if( ExprHasProperty(pExpr, EP_OuterON|EP_InnerON) ){ |
| 153025 | 153062 | Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->w.iJoin); |
| | @@ -153321,11 +153358,11 @@ |
| 153321 | 153358 | idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_SLICE); |
| 153322 | 153359 | exprAnalyze(pSrc, pWC, idxNew); |
| 153323 | 153360 | } |
| 153324 | 153361 | pTerm = &pWC->a[idxTerm]; |
| 153325 | 153362 | pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */ |
| 153326 | | - pTerm->eOperator = 0; |
| 153363 | + pTerm->eOperator = WO_ROWVAL; |
| 153327 | 153364 | } |
| 153328 | 153365 | |
| 153329 | 153366 | /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create |
| 153330 | 153367 | ** a virtual term for each vector component. The expression object |
| 153331 | 153368 | ** used by each such virtual term is pExpr (the full vector IN(...) |
| | @@ -153522,11 +153559,11 @@ |
| 153522 | 153559 | for(ii=0; ii<pWC->nTerm; ii++){ |
| 153523 | 153560 | if( pWC->a[ii].wtFlags & TERM_CODED ){ |
| 153524 | 153561 | /* This term is a vector operation that has been decomposed into |
| 153525 | 153562 | ** other, subsequent terms. It can be ignored. See tag-20220128a */ |
| 153526 | 153563 | assert( pWC->a[ii].wtFlags & TERM_VIRTUAL ); |
| 153527 | | - assert( pWC->a[ii].eOperator==0 ); |
| 153564 | + assert( pWC->a[ii].eOperator==WO_ROWVAL ); |
| 153528 | 153565 | continue; |
| 153529 | 153566 | } |
| 153530 | 153567 | if( pWC->a[ii].leftCursor!=iCsr ) return; |
| 153531 | 153568 | } |
| 153532 | 153569 | |
| | @@ -159792,10 +159829,11 @@ |
| 159792 | 159829 | WhereLevel *pLevel; |
| 159793 | 159830 | WhereLoop *pLoop; |
| 159794 | 159831 | SrcList *pTabList = pWInfo->pTabList; |
| 159795 | 159832 | sqlite3 *db = pParse->db; |
| 159796 | 159833 | int iEnd = sqlite3VdbeCurrentAddr(v); |
| 159834 | + int nRJ = 0; |
| 159797 | 159835 | |
| 159798 | 159836 | /* Generate loop termination code. |
| 159799 | 159837 | */ |
| 159800 | 159838 | VdbeModuleComment((v, "End WHERE-core")); |
| 159801 | 159839 | for(i=pWInfo->nLevel-1; i>=0; i--){ |
| | @@ -159808,12 +159846,11 @@ |
| 159808 | 159846 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 159809 | 159847 | pLevel->addrCont = 0; |
| 159810 | 159848 | pRJ->endSubrtn = sqlite3VdbeCurrentAddr(v); |
| 159811 | 159849 | sqlite3VdbeAddOp3(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn, 1); |
| 159812 | 159850 | VdbeCoverage(v); |
| 159813 | | - assert( pParse->withinRJSubrtn>0 ); |
| 159814 | | - pParse->withinRJSubrtn--; |
| 159851 | + nRJ++; |
| 159815 | 159852 | } |
| 159816 | 159853 | pLoop = pLevel->pWLoop; |
| 159817 | 159854 | if( pLevel->op!=OP_Noop ){ |
| 159818 | 159855 | #ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 159819 | 159856 | int addrSeek = 0; |
| | @@ -160090,10 +160127,11 @@ |
| 160090 | 160127 | |
| 160091 | 160128 | /* Final cleanup |
| 160092 | 160129 | */ |
| 160093 | 160130 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; |
| 160094 | 160131 | whereInfoFree(db, pWInfo); |
| 160132 | + pParse->withinRJSubrtn -= nRJ; |
| 160095 | 160133 | return; |
| 160096 | 160134 | } |
| 160097 | 160135 | |
| 160098 | 160136 | /************** End of where.c ***********************************************/ |
| 160099 | 160137 | /************** Begin file window.c ******************************************/ |
| | @@ -190661,10 +190699,12 @@ |
| 190661 | 190699 | if( rc==SQLITE_OK ){ |
| 190662 | 190700 | if( pNode->key.n ){ |
| 190663 | 190701 | pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix); |
| 190664 | 190702 | } |
| 190665 | 190703 | pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix); |
| 190704 | + assert( nPrefix+nSuffix<=nTerm ); |
| 190705 | + assert( nPrefix>=0 ); |
| 190666 | 190706 | memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix); |
| 190667 | 190707 | pBlk->n += nSuffix; |
| 190668 | 190708 | |
| 190669 | 190709 | memcpy(pNode->key.a, zTerm, nTerm); |
| 190670 | 190710 | pNode->key.n = nTerm; |
| | @@ -190783,10 +190823,11 @@ |
| 190783 | 190823 | NodeWriter *pLeaf; /* Object used to write leaf nodes */ |
| 190784 | 190824 | |
| 190785 | 190825 | pLeaf = &pWriter->aNodeWriter[0]; |
| 190786 | 190826 | nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm); |
| 190787 | 190827 | nSuffix = nTerm - nPrefix; |
| 190828 | + if(nSuffix<=0 ) return FTS_CORRUPT_VTAB; |
| 190788 | 190829 | |
| 190789 | 190830 | nSpace = sqlite3Fts3VarintLen(nPrefix); |
| 190790 | 190831 | nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 190791 | 190832 | nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 190792 | 190833 | |
| | @@ -236405,11 +236446,11 @@ |
| 236405 | 236446 | int nArg, /* Number of args */ |
| 236406 | 236447 | sqlite3_value **apUnused /* Function arguments */ |
| 236407 | 236448 | ){ |
| 236408 | 236449 | assert( nArg==0 ); |
| 236409 | 236450 | UNUSED_PARAM2(nArg, apUnused); |
| 236410 | | - sqlite3_result_text(pCtx, "fts5: 2022-05-23 11:51:10 919ba2f0472e12c2d1e82364c1481e778b24ea406615b08992964a4eb80abee7", -1, SQLITE_TRANSIENT); |
| 236451 | + sqlite3_result_text(pCtx, "fts5: 2022-06-03 14:08:40 d18818afc6021a32989499c26ab38fa442e5a55e662e39bb06e5c0daa9c65e25", -1, SQLITE_TRANSIENT); |
| 236411 | 236452 | } |
| 236412 | 236453 | |
| 236413 | 236454 | /* |
| 236414 | 236455 | ** Return true if zName is the extension on one of the shadow tables used |
| 236415 | 236456 | ** by this module. |
| 236416 | 236457 | |