| | @@ -16,11 +16,11 @@ |
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | | -** 42d67c6fed3a5f21d7b71515aca471ba61d3. |
| 21 | +** de8182cf1773ac0d04268d896a613841cf6b. |
| 22 | 22 | */ |
| 23 | 23 | #define SQLITE_CORE 1 |
| 24 | 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | 25 | #ifndef SQLITE_PRIVATE |
| 26 | 26 | # define SQLITE_PRIVATE static |
| | @@ -459,11 +459,11 @@ |
| 459 | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | 461 | */ |
| 462 | 462 | #define SQLITE_VERSION "3.46.0" |
| 463 | 463 | #define SQLITE_VERSION_NUMBER 3046000 |
| 464 | | -#define SQLITE_SOURCE_ID "2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf" |
| 464 | +#define SQLITE_SOURCE_ID "2024-05-21 11:11:29 de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb" |
| 465 | 465 | |
| 466 | 466 | /* |
| 467 | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | 469 | ** |
| | @@ -10253,27 +10253,48 @@ |
| 10253 | 10253 | ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner |
| 10254 | 10254 | ** is doing a GROUP BY. |
| 10255 | 10255 | ** <li value="2"><p> |
| 10256 | 10256 | ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means |
| 10257 | 10257 | ** that the query planner does not need the rows returned in any particular |
| 10258 | | -** order, as long as rows with the same values in all "aOrderBy" columns |
| 10259 | | -** are adjacent.)^ ^(Furthermore, only a single row for each particular |
| 10260 | | -** combination of values in the columns identified by the "aOrderBy" field |
| 10261 | | -** needs to be returned.)^ ^It is always ok for two or more rows with the same |
| 10262 | | -** values in all "aOrderBy" columns to be returned, as long as all such rows |
| 10263 | | -** are adjacent. ^The virtual table may, if it chooses, omit extra rows |
| 10264 | | -** that have the same value for all columns identified by "aOrderBy". |
| 10265 | | -** ^However omitting the extra rows is optional. |
| 10258 | +** order, as long as rows with the same values in all columns identified |
| 10259 | +** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows |
| 10260 | +** contain the same values for all columns identified by "colUsed", all but |
| 10261 | +** one such row may optionally be omitted from the result.)^ |
| 10262 | +** The virtual table is not required to omit rows that are duplicates |
| 10263 | +** over the "colUsed" columns, but if the virtual table can do that without |
| 10264 | +** too much extra effort, it could potentially help the query to run faster. |
| 10266 | 10265 | ** This mode is used for a DISTINCT query. |
| 10267 | 10266 | ** <li value="3"><p> |
| 10268 | | -** ^(If the sqlite3_vtab_distinct() interface returns 3, that means |
| 10269 | | -** that the query planner needs only distinct rows but it does need the |
| 10270 | | -** rows to be sorted.)^ ^The virtual table implementation is free to omit |
| 10271 | | -** rows that are identical in all aOrderBy columns, if it wants to, but |
| 10272 | | -** it is not required to omit any rows. This mode is used for queries |
| 10267 | +** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the |
| 10268 | +** virtual table must return rows in the order defined by "aOrderBy" as |
| 10269 | +** if the sqlite3_vtab_distinct() interface had returned 0. However if |
| 10270 | +** two or more rows in the result have the same values for all columns |
| 10271 | +** identified by "colUsed", then all but one such row may optionally be |
| 10272 | +** omitted.)^ Like when the return value is 2, the virtual table |
| 10273 | +** is not required to omit rows that are duplicates over the "colUsed" |
| 10274 | +** columns, but if the virtual table can do that without |
| 10275 | +** too much extra effort, it could potentially help the query to run faster. |
| 10276 | +** This mode is used for queries |
| 10273 | 10277 | ** that have both DISTINCT and ORDER BY clauses. |
| 10274 | 10278 | ** </ol> |
| 10279 | +** |
| 10280 | +** <p>The following table summarizes the conditions under which the |
| 10281 | +** virtual table is allowed to set the "orderByConsumed" flag based on |
| 10282 | +** the value returned by sqlite3_vtab_distinct(). This table is a |
| 10283 | +** restatement of the previous four paragraphs: |
| 10284 | +** |
| 10285 | +** <table border=1 cellspacing=0 cellpadding=10 width="90%"> |
| 10286 | +** <tr> |
| 10287 | +** <td valign="top">sqlite3_vtab_distinct() return value |
| 10288 | +** <td valign="top">Rows are returned in aOrderBy order |
| 10289 | +** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent |
| 10290 | +** <td valign="top">Duplicates over all colUsed columns may be omitted |
| 10291 | +** <tr><td>0<td>yes<td>yes<td>no |
| 10292 | +** <tr><td>1<td>no<td>yes<td>no |
| 10293 | +** <tr><td>2<td>no<td>yes<td>yes |
| 10294 | +** <tr><td>3<td>yes<td>yes<td>yes |
| 10295 | +** </table> |
| 10275 | 10296 | ** |
| 10276 | 10297 | ** ^For the purposes of comparing virtual table output values to see if the |
| 10277 | 10298 | ** values are same value for sorting purposes, two NULL values are considered |
| 10278 | 10299 | ** to be the same. In other words, the comparison operator is "IS" |
| 10279 | 10300 | ** (or "IS NOT DISTINCT FROM") and not "==". |
| | @@ -19262,10 +19283,11 @@ |
| 19262 | 19283 | unsigned notCte :1; /* This item may not match a CTE */ |
| 19263 | 19284 | unsigned isUsing :1; /* u3.pUsing is valid */ |
| 19264 | 19285 | unsigned isOn :1; /* u3.pOn was once valid and non-NULL */ |
| 19265 | 19286 | unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */ |
| 19266 | 19287 | unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ |
| 19288 | + unsigned rowidUsed :1; /* The ROWID of this table is referenced */ |
| 19267 | 19289 | } fg; |
| 19268 | 19290 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 19269 | 19291 | union { |
| 19270 | 19292 | Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */ |
| 19271 | 19293 | IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */ |
| | @@ -20806,11 +20828,11 @@ |
| 20806 | 20828 | SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); |
| 20807 | 20829 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 20808 | 20830 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 20809 | 20831 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 20810 | 20832 | SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*); |
| 20811 | | -SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20833 | +SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 20812 | 20834 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| 20813 | 20835 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 20814 | 20836 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 20815 | 20837 | SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*); |
| 20816 | 20838 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int); |
| | @@ -21217,11 +21239,13 @@ |
| 21217 | 21239 | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); |
| 21218 | 21240 | SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); |
| 21219 | 21241 | SQLITE_PRIVATE void sqlite3Error(sqlite3*,int); |
| 21220 | 21242 | SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*); |
| 21221 | 21243 | SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int); |
| 21244 | +#if !defined(SQLITE_OMIT_BLOB_LITERAL) |
| 21222 | 21245 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 21246 | +#endif |
| 21223 | 21247 | SQLITE_PRIVATE u8 sqlite3HexToInt(int h); |
| 21224 | 21248 | SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
| 21225 | 21249 | |
| 21226 | 21250 | #if defined(SQLITE_NEED_ERR_NAME) |
| 21227 | 21251 | SQLITE_PRIVATE const char *sqlite3ErrName(int); |
| | @@ -32752,12 +32776,14 @@ |
| 32752 | 32776 | char zLine[1000]; |
| 32753 | 32777 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 32754 | 32778 | x.printfFlags |= SQLITE_PRINTF_INTERNAL; |
| 32755 | 32779 | sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); |
| 32756 | 32780 | if( pItem->pTab ){ |
| 32757 | | - sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", |
| 32758 | | - pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); |
| 32781 | + sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s", |
| 32782 | + pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, |
| 32783 | + pItem->colUsed, |
| 32784 | + pItem->fg.rowidUsed ? "+rowid" : ""); |
| 32759 | 32785 | } |
| 32760 | 32786 | if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){ |
| 32761 | 32787 | sqlite3_str_appendf(&x, " FULL-OUTER-JOIN"); |
| 32762 | 32788 | }else if( pItem->fg.jointype & JT_LEFT ){ |
| 32763 | 32789 | sqlite3_str_appendf(&x, " LEFT-JOIN"); |
| | @@ -88164,11 +88190,11 @@ |
| 88164 | 88190 | } |
| 88165 | 88191 | } |
| 88166 | 88192 | |
| 88167 | 88193 | /* Check for immediate foreign key violations. */ |
| 88168 | 88194 | if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){ |
| 88169 | | - sqlite3VdbeCheckFk(p, 0); |
| 88195 | + (void)sqlite3VdbeCheckFk(p, 0); |
| 88170 | 88196 | } |
| 88171 | 88197 | |
| 88172 | 88198 | /* If the auto-commit flag is set and this is the only active writer |
| 88173 | 88199 | ** VM, then we do either a commit or rollback of the current transaction. |
| 88174 | 88200 | ** |
| | @@ -107522,12 +107548,16 @@ |
| 107522 | 107548 | ** (See ticket [b92e5e8ec2cdbaa1]). |
| 107523 | 107549 | ** |
| 107524 | 107550 | ** If a generated column is referenced, set bits for every column |
| 107525 | 107551 | ** of the table. |
| 107526 | 107552 | */ |
| 107527 | | - if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){ |
| 107528 | | - pMatch->colUsed |= sqlite3ExprColUsed(pExpr); |
| 107553 | + if( pMatch ){ |
| 107554 | + if( pExpr->iColumn>=0 ){ |
| 107555 | + pMatch->colUsed |= sqlite3ExprColUsed(pExpr); |
| 107556 | + }else{ |
| 107557 | + pMatch->fg.rowidUsed = 1; |
| 107558 | + } |
| 107529 | 107559 | } |
| 107530 | 107560 | |
| 107531 | 107561 | pExpr->op = eNewExprOp; |
| 107532 | 107562 | lookupname_end: |
| 107533 | 107563 | if( cnt==1 ){ |
| | @@ -107975,15 +108005,13 @@ |
| 107975 | 108005 | #else |
| 107976 | 108006 | pNC->ncFlags &= ~NC_AllowAgg; |
| 107977 | 108007 | #endif |
| 107978 | 108008 | } |
| 107979 | 108009 | } |
| 107980 | | -#ifndef SQLITE_OMIT_WINDOWFUNC |
| 107981 | | - else if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 108010 | + else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){ |
| 107982 | 108011 | is_agg = 1; |
| 107983 | 108012 | } |
| 107984 | | -#endif |
| 107985 | 108013 | sqlite3WalkExprList(pWalker, pList); |
| 107986 | 108014 | if( is_agg ){ |
| 107987 | 108015 | if( pExpr->pLeft ){ |
| 107988 | 108016 | assert( pExpr->pLeft->op==TK_ORDER ); |
| 107989 | 108017 | assert( ExprUseXList(pExpr->pLeft) ); |
| | @@ -110419,15 +110447,15 @@ |
| 110419 | 110447 | ** This is similar to sqlite3ExprDelete() except that the delete is |
| 110420 | 110448 | ** deferred until the pParse is deleted. |
| 110421 | 110449 | ** |
| 110422 | 110450 | ** The pExpr might be deleted immediately on an OOM error. |
| 110423 | 110451 | ** |
| 110424 | | -** The deferred delete is (currently) implemented by adding the |
| 110425 | | -** pExpr to the pParse->pConstExpr list with a register number of 0. |
| 110452 | +** Return 0 if the delete was successfully deferred. Return non-zero |
| 110453 | +** if the delete happened immediately because of an OOM. |
| 110426 | 110454 | */ |
| 110427 | | -SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ |
| 110428 | | - sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); |
| 110455 | +SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ |
| 110456 | + return 0==sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); |
| 110429 | 110457 | } |
| 110430 | 110458 | |
| 110431 | 110459 | /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the |
| 110432 | 110460 | ** expression. |
| 110433 | 110461 | */ |
| | @@ -115657,24 +115685,22 @@ |
| 115657 | 115685 | if( pExpr->op!=TK_AGG_FUNCTION ){ |
| 115658 | 115686 | if( iAgg<pAggInfo->nColumn |
| 115659 | 115687 | && pAggInfo->aCol[iAgg].pCExpr==pExpr |
| 115660 | 115688 | ){ |
| 115661 | 115689 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 115662 | | - if( pExpr ){ |
| 115690 | + if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){ |
| 115663 | 115691 | pAggInfo->aCol[iAgg].pCExpr = pExpr; |
| 115664 | | - sqlite3ExprDeferredDelete(pParse, pExpr); |
| 115665 | 115692 | } |
| 115666 | 115693 | } |
| 115667 | 115694 | }else{ |
| 115668 | 115695 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 115669 | 115696 | if( ALWAYS(iAgg<pAggInfo->nFunc) |
| 115670 | 115697 | && pAggInfo->aFunc[iAgg].pFExpr==pExpr |
| 115671 | 115698 | ){ |
| 115672 | 115699 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 115673 | | - if( pExpr ){ |
| 115700 | + if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){ |
| 115674 | 115701 | pAggInfo->aFunc[iAgg].pFExpr = pExpr; |
| 115675 | | - sqlite3ExprDeferredDelete(pParse, pExpr); |
| 115676 | 115702 | } |
| 115677 | 115703 | } |
| 115678 | 115704 | } |
| 115679 | 115705 | } |
| 115680 | 115706 | return WRC_Continue; |
| | @@ -142399,11 +142425,17 @@ |
| 142399 | 142425 | SQLITE_PRIVATE void *sqlite3ParserAddCleanup( |
| 142400 | 142426 | Parse *pParse, /* Destroy when this Parser finishes */ |
| 142401 | 142427 | void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */ |
| 142402 | 142428 | void *pPtr /* Pointer to object to be cleaned up */ |
| 142403 | 142429 | ){ |
| 142404 | | - ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); |
| 142430 | + ParseCleanup *pCleanup; |
| 142431 | + if( sqlite3FaultSim(300) ){ |
| 142432 | + pCleanup = 0; |
| 142433 | + sqlite3OomFault(pParse->db); |
| 142434 | + }else{ |
| 142435 | + pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); |
| 142436 | + } |
| 142405 | 142437 | if( pCleanup ){ |
| 142406 | 142438 | pCleanup->pNext = pParse->pCleanup; |
| 142407 | 142439 | pParse->pCleanup = pCleanup; |
| 142408 | 142440 | pCleanup->pPtr = pPtr; |
| 142409 | 142441 | pCleanup->xCleanup = xCleanup; |
| | @@ -145172,12 +145204,11 @@ |
| 145172 | 145204 | Expr *p; |
| 145173 | 145205 | struct ExprList_item *a; |
| 145174 | 145206 | NameContext sNC; |
| 145175 | 145207 | |
| 145176 | 145208 | assert( pSelect!=0 ); |
| 145177 | | - testcase( (pSelect->selFlags & SF_Resolved)==0 ); |
| 145178 | | - assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT ); |
| 145209 | + assert( (pSelect->selFlags & SF_Resolved)!=0 ); |
| 145179 | 145210 | assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 ); |
| 145180 | 145211 | assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB ); |
| 145181 | 145212 | if( db->mallocFailed || IN_RENAME_OBJECT ) return; |
| 145182 | 145213 | while( pSelect->pPrior ) pSelect = pSelect->pPrior; |
| 145183 | 145214 | a = pSelect->pEList->a; |
| | @@ -145229,16 +145260,16 @@ |
| 145229 | 145260 | } |
| 145230 | 145261 | } |
| 145231 | 145262 | } |
| 145232 | 145263 | } |
| 145233 | 145264 | if( zType ){ |
| 145234 | | - i64 m = sqlite3Strlen30(zType); |
| 145265 | + const i64 k = sqlite3Strlen30(zType); |
| 145235 | 145266 | n = sqlite3Strlen30(pCol->zCnName); |
| 145236 | | - pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2); |
| 145267 | + pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+k+2); |
| 145237 | 145268 | pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL); |
| 145238 | 145269 | if( pCol->zCnName ){ |
| 145239 | | - memcpy(&pCol->zCnName[n+1], zType, m+1); |
| 145270 | + memcpy(&pCol->zCnName[n+1], zType, k+1); |
| 145240 | 145271 | pCol->colFlags |= COLFLAG_HASTYPE; |
| 145241 | 145272 | } |
| 145242 | 145273 | } |
| 145243 | 145274 | pColl = sqlite3ExprCollSeq(pParse, p); |
| 145244 | 145275 | if( pColl ){ |
| | @@ -149260,12 +149291,11 @@ |
| 149260 | 149291 | SrcItem *pFrom; |
| 149261 | 149292 | |
| 149262 | 149293 | if( p->selFlags & SF_HasTypeInfo ) return; |
| 149263 | 149294 | p->selFlags |= SF_HasTypeInfo; |
| 149264 | 149295 | pParse = pWalker->pParse; |
| 149265 | | - testcase( (p->selFlags & SF_Resolved)==0 ); |
| 149266 | | - assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT ); |
| 149296 | + assert( (p->selFlags & SF_Resolved) ); |
| 149267 | 149297 | pTabList = p->pSrc; |
| 149268 | 149298 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 149269 | 149299 | Table *pTab = pFrom->pTab; |
| 149270 | 149300 | assert( pTab!=0 ); |
| 149271 | 149301 | if( (pTab->tabFlags & TF_Ephemeral)!=0 ){ |
| | @@ -156182,11 +156212,14 @@ |
| 156182 | 156212 | */ |
| 156183 | 156213 | z = (const unsigned char*)zCreateTable; |
| 156184 | 156214 | for(i=0; aKeyword[i]; i++){ |
| 156185 | 156215 | int tokenType = 0; |
| 156186 | 156216 | do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE ); |
| 156187 | | - if( tokenType!=aKeyword[i] ) return SQLITE_MISUSE_BKPT; |
| 156217 | + if( tokenType!=aKeyword[i] ){ |
| 156218 | + sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error"); |
| 156219 | + return SQLITE_ERROR; |
| 156220 | + } |
| 156188 | 156221 | } |
| 156189 | 156222 | |
| 156190 | 156223 | sqlite3_mutex_enter(db->mutex); |
| 156191 | 156224 | pCtx = db->pVtabCtx; |
| 156192 | 156225 | if( !pCtx || pCtx->bDeclared ){ |
| | @@ -158803,11 +158836,11 @@ |
| 158803 | 158836 | || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0 |
| 158804 | 158837 | ); |
| 158805 | 158838 | if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){ |
| 158806 | 158839 | pLevel->iLeftJoin = ++pParse->nMem; |
| 158807 | 158840 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin); |
| 158808 | | - VdbeComment((v, "init LEFT JOIN no-match flag")); |
| 158841 | + VdbeComment((v, "init LEFT JOIN match flag")); |
| 158809 | 158842 | } |
| 158810 | 158843 | |
| 158811 | 158844 | /* Compute a safe address to jump to if we discover that the table for |
| 158812 | 158845 | ** this loop is empty and can never contribute content. */ |
| 158813 | 158846 | for(j=iLevel; j>0; j--){ |
| | @@ -163489,11 +163522,11 @@ |
| 163489 | 163522 | /* No matches cause a break out of the loop */ |
| 163490 | 163523 | break; |
| 163491 | 163524 | } |
| 163492 | 163525 | if( i==n ){ |
| 163493 | 163526 | nOrderBy = n; |
| 163494 | | - if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) ){ |
| 163527 | + if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) && !pSrc->fg.rowidUsed ){ |
| 163495 | 163528 | eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0); |
| 163496 | 163529 | }else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){ |
| 163497 | 163530 | eDistinct = 1; |
| 163498 | 163531 | } |
| 163499 | 163532 | } |
| | @@ -208622,17 +208655,10 @@ |
| 208622 | 208655 | } |
| 208623 | 208656 | if( !eErr ) sqlite3_result_int64(ctx, cnt); |
| 208624 | 208657 | jsonParseFree(p); |
| 208625 | 208658 | } |
| 208626 | 208659 | |
| 208627 | | -/* True if the string is all digits */ |
| 208628 | | -static int jsonAllDigits(const char *z, int n){ |
| 208629 | | - int i; |
| 208630 | | - for(i=0; i<n && sqlite3Isdigit(z[i]); i++){} |
| 208631 | | - return i==n; |
| 208632 | | -} |
| 208633 | | - |
| 208634 | 208660 | /* True if the string is all alphanumerics and underscores */ |
| 208635 | 208661 | static int jsonAllAlphanum(const char *z, int n){ |
| 208636 | 208662 | int i; |
| 208637 | 208663 | for(i=0; i<n && (sqlite3Isalnum(z[i]) || z[i]=='_'); i++){} |
| 208638 | 208664 | return i==n; |
| | @@ -208693,11 +208719,11 @@ |
| 208693 | 208719 | ** NUMBER ==> $[NUMBER] // PG compatible |
| 208694 | 208720 | ** LABEL ==> $.LABEL // PG compatible |
| 208695 | 208721 | ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience |
| 208696 | 208722 | */ |
| 208697 | 208723 | jsonStringInit(&jx, ctx); |
| 208698 | | - if( jsonAllDigits(zPath, nPath) ){ |
| 208724 | + if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){ |
| 208699 | 208725 | jsonAppendRawNZ(&jx, "[", 1); |
| 208700 | 208726 | jsonAppendRaw(&jx, zPath, nPath); |
| 208701 | 208727 | jsonAppendRawNZ(&jx, "]", 2); |
| 208702 | 208728 | }else if( jsonAllAlphanum(zPath, nPath) ){ |
| 208703 | 208729 | jsonAppendRawNZ(&jx, ".", 1); |
| | @@ -252511,11 +252537,11 @@ |
| 252511 | 252537 | int nArg, /* Number of args */ |
| 252512 | 252538 | sqlite3_value **apUnused /* Function arguments */ |
| 252513 | 252539 | ){ |
| 252514 | 252540 | assert( nArg==0 ); |
| 252515 | 252541 | UNUSED_PARAM2(nArg, apUnused); |
| 252516 | | - sqlite3_result_text(pCtx, "fts5: 2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf", -1, SQLITE_TRANSIENT); |
| 252542 | + sqlite3_result_text(pCtx, "fts5: 2024-05-20 17:52:35 08058d66d1bde4fcf8324482ee4c6c030c681383470d5076b6f75b74aac2ae29", -1, SQLITE_TRANSIENT); |
| 252517 | 252543 | } |
| 252518 | 252544 | |
| 252519 | 252545 | /* |
| 252520 | 252546 | ** Return true if zName is the extension on one of the shadow tables used |
| 252521 | 252547 | ** by this module. |
| 252522 | 252548 | |