Fossil SCM
Import the latest 3.40.0 alpha version of SQLite into the tree.
Commit
fbad2772263c7172efca1c39e0b17401f8b9e6013173ae7138bf5f179e8989bb
Parent
8ab498bd060f45d…
2 files changed
+154
-172
+1
-1
+154
-172
| --- extsrc/sqlite3.c | ||
| +++ extsrc/sqlite3.c | ||
| @@ -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.40.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3040000 |
| 457 | -#define SQLITE_SOURCE_ID "2022-09-02 21:19:24 da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c" | |
| 457 | +#define SQLITE_SOURCE_ID "2022-09-28 19:14:01 f25cf63471cbed1edb27591e57fead62550d4046dbdcb61312288f0f6f24c646" | |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| @@ -29076,22 +29076,38 @@ | ||
| 29076 | 29076 | sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 29077 | 29077 | } |
| 29078 | 29078 | *pp = p; |
| 29079 | 29079 | } |
| 29080 | 29080 | |
| 29081 | +/* | |
| 29082 | +** Maximum size of any single memory allocation. | |
| 29083 | +** | |
| 29084 | +** This is not a limit on the total amount of memory used. This is | |
| 29085 | +** a limit on the size parameter to sqlite3_malloc() and sqlite3_realloc(). | |
| 29086 | +** | |
| 29087 | +** The upper bound is slightly less than 2GiB: 0x7ffffeff == 2,147,483,391 | |
| 29088 | +** This provides a 256-byte safety margin for defense against 32-bit | |
| 29089 | +** signed integer overflow bugs when computing memory allocation sizes. | |
| 29090 | +** Parnoid applications might want to reduce the maximum allocation size | |
| 29091 | +** further for an even larger safety margin. 0x3fffffff or 0x0fffffff | |
| 29092 | +** or even smaller would be reasonable upper bounds on the size of a memory | |
| 29093 | +** allocations for most applications. | |
| 29094 | +*/ | |
| 29095 | +#ifndef SQLITE_MAX_ALLOCATION_SIZE | |
| 29096 | +# define SQLITE_MAX_ALLOCATION_SIZE 2147483391 | |
| 29097 | +#endif | |
| 29098 | +#if SQLITE_MAX_ALLOCATION_SIZE>2147483391 | |
| 29099 | +# error Maximum size for SQLITE_MAX_ALLOCATION_SIZE is 2147483391 | |
| 29100 | +#endif | |
| 29101 | + | |
| 29081 | 29102 | /* |
| 29082 | 29103 | ** Allocate memory. This routine is like sqlite3_malloc() except that it |
| 29083 | 29104 | ** assumes the memory subsystem has already been initialized. |
| 29084 | 29105 | */ |
| 29085 | 29106 | SQLITE_PRIVATE void *sqlite3Malloc(u64 n){ |
| 29086 | 29107 | void *p; |
| 29087 | - if( n==0 || n>=0x7fffff00 ){ | |
| 29088 | - /* A memory allocation of a number of bytes which is near the maximum | |
| 29089 | - ** signed integer value might cause an integer overflow inside of the | |
| 29090 | - ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving | |
| 29091 | - ** 255 bytes of overhead. SQLite itself will never use anything near | |
| 29092 | - ** this amount. The only way to reach the limit is with sqlite3_malloc() */ | |
| 29108 | + if( n==0 || n>SQLITE_MAX_ALLOCATION_SIZE ){ | |
| 29093 | 29109 | p = 0; |
| 29094 | 29110 | }else if( sqlite3GlobalConfig.bMemstat ){ |
| 29095 | 29111 | sqlite3_mutex_enter(mem0.mutex); |
| 29096 | 29112 | mallocWithAlarm((int)n, &p); |
| 29097 | 29113 | sqlite3_mutex_leave(mem0.mutex); |
| @@ -45571,12 +45587,13 @@ | ||
| 45571 | 45587 | SQLITE_API int sqlite3_win32_set_directory8( |
| 45572 | 45588 | unsigned long type, /* Identifier for directory being set or reset */ |
| 45573 | 45589 | const char *zValue /* New value for directory being set or reset */ |
| 45574 | 45590 | ){ |
| 45575 | 45591 | char **ppDirectory = 0; |
| 45592 | + int rc; | |
| 45576 | 45593 | #ifndef SQLITE_OMIT_AUTOINIT |
| 45577 | - int rc = sqlite3_initialize(); | |
| 45594 | + rc = sqlite3_initialize(); | |
| 45578 | 45595 | if( rc ) return rc; |
| 45579 | 45596 | #endif |
| 45580 | 45597 | sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); |
| 45581 | 45598 | if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){ |
| 45582 | 45599 | ppDirectory = &sqlite3_data_directory; |
| @@ -49415,11 +49432,12 @@ | ||
| 49415 | 49432 | const char *zRelative, /* Possibly relative input path */ |
| 49416 | 49433 | int nFull, /* Size of output buffer in bytes */ |
| 49417 | 49434 | char *zFull /* Output buffer */ |
| 49418 | 49435 | ){ |
| 49419 | 49436 | int rc; |
| 49420 | - sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); | |
| 49437 | + MUTEX_LOGIC( sqlite3_mutex *pMutex; ) | |
| 49438 | + MUTEX_LOGIC( pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); ) | |
| 49421 | 49439 | sqlite3_mutex_enter(pMutex); |
| 49422 | 49440 | rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull); |
| 49423 | 49441 | sqlite3_mutex_leave(pMutex); |
| 49424 | 49442 | return rc; |
| 49425 | 49443 | } |
| @@ -51798,18 +51816,18 @@ | ||
| 51798 | 51816 | assert( p->nRef>0 ); |
| 51799 | 51817 | assert( newPgno>0 ); |
| 51800 | 51818 | assert( sqlite3PcachePageSanity(p) ); |
| 51801 | 51819 | pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); |
| 51802 | 51820 | pOther = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, newPgno, 0); |
| 51803 | - sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); | |
| 51804 | 51821 | if( pOther ){ |
| 51805 | - PgHdr *pPg = (PgHdr*)pOther->pExtra; | |
| 51806 | - pPg->pgno = p->pgno; | |
| 51807 | - if( pPg->pPage==0 ){ | |
| 51808 | - sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pOther, 0); | |
| 51809 | - } | |
| 51822 | + PgHdr *pXPage = (PgHdr*)pOther->pExtra; | |
| 51823 | + assert( pXPage->nRef==0 ); | |
| 51824 | + pXPage->nRef++; | |
| 51825 | + pCache->nRefSum++; | |
| 51826 | + sqlite3PcacheDrop(pXPage); | |
| 51810 | 51827 | } |
| 51828 | + sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); | |
| 51811 | 51829 | p->pgno = newPgno; |
| 51812 | 51830 | if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ |
| 51813 | 51831 | pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); |
| 51814 | 51832 | assert( sqlite3PcachePageSanity(p) ); |
| 51815 | 51833 | } |
| @@ -53202,27 +53220,12 @@ | ||
| 53202 | 53220 | while( (*pp)!=pPage ){ |
| 53203 | 53221 | pp = &(*pp)->pNext; |
| 53204 | 53222 | } |
| 53205 | 53223 | *pp = pPage->pNext; |
| 53206 | 53224 | |
| 53225 | + assert( pcache1FetchNoMutex(p, iNew, 0)==0 ); /* iNew not in cache */ | |
| 53207 | 53226 | hNew = iNew%pCache->nHash; |
| 53208 | - pp = &pCache->apHash[hNew]; | |
| 53209 | - while( *pp ){ | |
| 53210 | - if( (*pp)->iKey==iNew ){ | |
| 53211 | - /* If there is already another pcache entry at iNew, change it to iOld, | |
| 53212 | - ** thus swapping the positions of iNew and iOld */ | |
| 53213 | - PgHdr1 *pOld = *pp; | |
| 53214 | - *pp = pOld->pNext; | |
| 53215 | - pOld->pNext = pCache->apHash[hOld]; | |
| 53216 | - pCache->apHash[hOld] = pOld; | |
| 53217 | - pOld->iKey = iOld; | |
| 53218 | - break; | |
| 53219 | - }else{ | |
| 53220 | - pp = &(*pp)->pNext; | |
| 53221 | - } | |
| 53222 | - } | |
| 53223 | - | |
| 53224 | 53227 | pPage->iKey = iNew; |
| 53225 | 53228 | pPage->pNext = pCache->apHash[hNew]; |
| 53226 | 53229 | pCache->apHash[hNew] = pPage; |
| 53227 | 53230 | if( iNew>pCache->iMaxKey ){ |
| 53228 | 53231 | pCache->iMaxKey = iNew; |
| @@ -68523,11 +68526,11 @@ | ||
| 68523 | 68526 | if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage); |
| 68524 | 68527 | sz2 = get2byte(&data[iFree2+2]); |
| 68525 | 68528 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); |
| 68526 | 68529 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 68527 | 68530 | sz += sz2; |
| 68528 | - }else if( NEVER(iFree+sz>usableSize) ){ | |
| 68531 | + }else if( iFree+sz>usableSize ){ | |
| 68529 | 68532 | return SQLITE_CORRUPT_PAGE(pPage); |
| 68530 | 68533 | } |
| 68531 | 68534 | |
| 68532 | 68535 | cbrk = top+sz; |
| 68533 | 68536 | assert( cbrk+(iFree-top) <= usableSize ); |
| @@ -93400,16 +93403,20 @@ | ||
| 93400 | 93403 | } |
| 93401 | 93404 | |
| 93402 | 93405 | /* Opcode: IfNotOpen P1 P2 * * * |
| 93403 | 93406 | ** Synopsis: if( !csr[P1] ) goto P2 |
| 93404 | 93407 | ** |
| 93405 | -** If cursor P1 is not open, jump to instruction P2. Otherwise, fall through. | |
| 93408 | +** If cursor P1 is not open or if P1 is set to a NULL row using the | |
| 93409 | +** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through. | |
| 93406 | 93410 | */ |
| 93407 | 93411 | case OP_IfNotOpen: { /* jump */ |
| 93412 | + VdbeCursor *pCur; | |
| 93413 | + | |
| 93408 | 93414 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 93409 | - VdbeBranchTaken(p->apCsr[pOp->p1]==0, 2); | |
| 93410 | - if( !p->apCsr[pOp->p1] ){ | |
| 93415 | + pCur = p->apCsr[pOp->p1]; | |
| 93416 | + VdbeBranchTaken(pCur==0 || pCur->nullRow, 2); | |
| 93417 | + if( pCur==0 || pCur->nullRow ){ | |
| 93411 | 93418 | goto jump_to_p2_and_check_for_interrupt; |
| 93412 | 93419 | } |
| 93413 | 93420 | break; |
| 93414 | 93421 | } |
| 93415 | 93422 | |
| @@ -107028,10 +107035,11 @@ | ||
| 107028 | 107035 | } |
| 107029 | 107036 | if( pKeyInfo ){ |
| 107030 | 107037 | sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO); |
| 107031 | 107038 | } |
| 107032 | 107039 | if( addrOnce ){ |
| 107040 | + sqlite3VdbeAddOp1(v, OP_NullRow, iTab); | |
| 107033 | 107041 | sqlite3VdbeJumpHere(v, addrOnce); |
| 107034 | 107042 | /* Subroutine return */ |
| 107035 | 107043 | assert( ExprUseYSub(pExpr) ); |
| 107036 | 107044 | assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn |
| 107037 | 107045 | || pParse->nErr ); |
| @@ -139569,11 +139577,11 @@ | ||
| 139569 | 139577 | ** position in the parent that NULL-able due to an OUTER JOIN. Either the |
| 139570 | 139578 | ** target slot in the parent is the right operand of a LEFT JOIN, or one of |
| 139571 | 139579 | ** the left operands of a RIGHT JOIN. In either case, we need to potentially |
| 139572 | 139580 | ** bypass the substituted expression with OP_IfNullRow. |
| 139573 | 139581 | ** |
| 139574 | -** Suppose the original expression integer constant. Even though the table | |
| 139582 | +** Suppose the original expression is an integer constant. Even though the table | |
| 139575 | 139583 | ** has the nullRow flag set, because the expression is an integer constant, |
| 139576 | 139584 | ** it will not be NULLed out. So instead, we insert an OP_IfNullRow opcode |
| 139577 | 139585 | ** that checks to see if the nullRow flag is set on the table. If the nullRow |
| 139578 | 139586 | ** flag is set, then the value in the register is set to NULL and the original |
| 139579 | 139587 | ** expression is bypassed. If the nullRow flag is not set, then the original |
| @@ -140026,23 +140034,17 @@ | ||
| 140026 | 140034 | ** |
| 140027 | 140035 | ** (26) The subquery may not be the right operand of a RIGHT JOIN. |
| 140028 | 140036 | ** See also (3) for restrictions on LEFT JOIN. |
| 140029 | 140037 | ** |
| 140030 | 140038 | ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 140031 | -** is the first element of the parent query. This must be the | |
| 140032 | -** the case if: | |
| 140033 | -** (27a) the subquery is not compound query, and | |
| 140039 | +** is the first element of the parent query. Two subcases: | |
| 140040 | +** (27a) the subquery is not a compound query. | |
| 140034 | 140041 | ** (27b) the subquery is a compound query and the RIGHT JOIN occurs |
| 140035 | 140042 | ** in any arm of the compound query. (See also (17g).) |
| 140036 | 140043 | ** |
| 140037 | 140044 | ** (28) The subquery is not a MATERIALIZED CTE. |
| 140038 | 140045 | ** |
| 140039 | -** (29) Either the subquery is not the right-hand operand of a join with an | |
| 140040 | -** ON or USING clause nor the right-hand operand of a NATURAL JOIN, or | |
| 140041 | -** the right-most table within the FROM clause of the subquery | |
| 140042 | -** is not part of an outer join. | |
| 140043 | -** | |
| 140044 | 140046 | ** |
| 140045 | 140047 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 140046 | 140048 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 140047 | 140049 | ** uses aggregates. |
| 140048 | 140050 | ** |
| @@ -140142,57 +140144,19 @@ | ||
| 140142 | 140144 | ){ |
| 140143 | 140145 | return 0; |
| 140144 | 140146 | } |
| 140145 | 140147 | isOuterJoin = 1; |
| 140146 | 140148 | } |
| 140147 | -#ifdef SQLITE_EXTRA_IFNULLROW | |
| 140148 | - else if( iFrom>0 && !isAgg ){ | |
| 140149 | - /* Setting isOuterJoin to -1 causes OP_IfNullRow opcodes to be generated for | |
| 140150 | - ** every reference to any result column from subquery in a join, even | |
| 140151 | - ** though they are not necessary. This will stress-test the OP_IfNullRow | |
| 140152 | - ** opcode. */ | |
| 140153 | - isOuterJoin = -1; | |
| 140154 | - } | |
| 140155 | -#endif | |
| 140156 | 140149 | |
| 140157 | 140150 | assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 140158 | 140151 | if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 140159 | 140152 | return 0; /* Restriction (27a) */ |
| 140160 | 140153 | } |
| 140161 | 140154 | if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ |
| 140162 | 140155 | return 0; /* (28) */ |
| 140163 | 140156 | } |
| 140164 | 140157 | |
| 140165 | - /* Restriction (29): | |
| 140166 | - ** | |
| 140167 | - ** We do not want two constraints on the same term of the flattened | |
| 140168 | - ** query where one constraint has EP_InnerON and the other is EP_OuterON. | |
| 140169 | - ** To prevent this, one or the other of the following conditions must be | |
| 140170 | - ** false: | |
| 140171 | - ** | |
| 140172 | - ** (29a) The right-most entry in the FROM clause of the subquery | |
| 140173 | - ** must not be part of an outer join. | |
| 140174 | - ** | |
| 140175 | - ** (29b) The subquery itself must not be the right operand of a | |
| 140176 | - ** NATURAL join or a join that as an ON or USING clause. | |
| 140177 | - ** | |
| 140178 | - ** These conditions are sufficient to keep an EP_OuterON from being | |
| 140179 | - ** flattened into an EP_InnerON. Restrictions (3a) and (27a) prevent | |
| 140180 | - ** an EP_InnerON from being flattened into an EP_OuterON. | |
| 140181 | - */ | |
| 140182 | - if( pSubSrc->nSrc>=2 | |
| 140183 | - && (pSubSrc->a[pSubSrc->nSrc-1].fg.jointype & JT_OUTER)!=0 | |
| 140184 | - ){ | |
| 140185 | - if( (pSubitem->fg.jointype & JT_NATURAL)!=0 | |
| 140186 | - || pSubitem->fg.isUsing | |
| 140187 | - || NEVER(pSubitem->u3.pOn!=0) /* ON clause already shifted into WHERE */ | |
| 140188 | - || pSubitem->fg.isOn | |
| 140189 | - ){ | |
| 140190 | - return 0; | |
| 140191 | - } | |
| 140192 | - } | |
| 140193 | - | |
| 140194 | 140158 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 140195 | 140159 | ** use only the UNION ALL operator. And none of the simple select queries |
| 140196 | 140160 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 140197 | 140161 | ** queries. |
| 140198 | 140162 | */ |
| @@ -144296,10 +144260,27 @@ | ||
| 144296 | 144260 | ** build the sqlite_schema entry |
| 144297 | 144261 | */ |
| 144298 | 144262 | if( !db->init.busy ){ |
| 144299 | 144263 | Vdbe *v; |
| 144300 | 144264 | char *z; |
| 144265 | + | |
| 144266 | + /* If this is a new CREATE TABLE statement, and if shadow tables | |
| 144267 | + ** are read-only, and the trigger makes a change to a shadow table, | |
| 144268 | + ** then raise an error - do not allow the trigger to be created. */ | |
| 144269 | + if( sqlite3ReadOnlyShadowTables(db) ){ | |
| 144270 | + TriggerStep *pStep; | |
| 144271 | + for(pStep=pTrig->step_list; pStep; pStep=pStep->pNext){ | |
| 144272 | + if( pStep->zTarget!=0 | |
| 144273 | + && sqlite3ShadowTableName(db, pStep->zTarget) | |
| 144274 | + ){ | |
| 144275 | + sqlite3ErrorMsg(pParse, | |
| 144276 | + "trigger \"%s\" may not write to shadow table \"%s\"", | |
| 144277 | + pTrig->zName, pStep->zTarget); | |
| 144278 | + goto triggerfinish_cleanup; | |
| 144279 | + } | |
| 144280 | + } | |
| 144281 | + } | |
| 144301 | 144282 | |
| 144302 | 144283 | /* Make an entry in the sqlite_schema table */ |
| 144303 | 144284 | v = sqlite3GetVdbe(pParse); |
| 144304 | 144285 | if( v==0 ) goto triggerfinish_cleanup; |
| 144305 | 144286 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| @@ -155004,10 +154985,47 @@ | ||
| 155004 | 154985 | } |
| 155005 | 154986 | #else |
| 155006 | 154987 | #define whereTraceIndexInfoInputs(A) |
| 155007 | 154988 | #define whereTraceIndexInfoOutputs(A) |
| 155008 | 154989 | #endif |
| 154990 | + | |
| 154991 | +/* | |
| 154992 | +** We know that pSrc is an operand of an outer join. Return true if | |
| 154993 | +** pTerm is a constraint that is compatible with that join. | |
| 154994 | +** | |
| 154995 | +** pTerm must be EP_OuterON if pSrc is the right operand of an | |
| 154996 | +** outer join. pTerm can be either EP_OuterON or EP_InnerON if pSrc | |
| 154997 | +** is the left operand of a RIGHT join. | |
| 154998 | +** | |
| 154999 | +** See https://sqlite.org/forum/forumpost/206d99a16dd9212f | |
| 155000 | +** for an example of a WHERE clause constraints that may not be used on | |
| 155001 | +** the right table of a RIGHT JOIN because the constraint implies a | |
| 155002 | +** not-NULL condition on the left table of the RIGHT JOIN. | |
| 155003 | +*/ | |
| 155004 | +static int constraintCompatibleWithOuterJoin( | |
| 155005 | + const WhereTerm *pTerm, /* WHERE clause term to check */ | |
| 155006 | + const SrcItem *pSrc /* Table we are trying to access */ | |
| 155007 | +){ | |
| 155008 | + assert( (pSrc->fg.jointype&(JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ); /* By caller */ | |
| 155009 | + testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); | |
| 155010 | + testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); | |
| 155011 | + testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ) | |
| 155012 | + testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); | |
| 155013 | + if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) | |
| 155014 | + || pTerm->pExpr->w.iJoin != pSrc->iCursor | |
| 155015 | + ){ | |
| 155016 | + return 0; | |
| 155017 | + } | |
| 155018 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_RIGHT))!=0 | |
| 155019 | + && ExprHasProperty(pTerm->pExpr, EP_InnerON) | |
| 155020 | + ){ | |
| 155021 | + return 0; | |
| 155022 | + } | |
| 155023 | + return 1; | |
| 155024 | +} | |
| 155025 | + | |
| 155026 | + | |
| 155009 | 155027 | |
| 155010 | 155028 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155011 | 155029 | /* |
| 155012 | 155030 | ** Return TRUE if the WHERE clause term pTerm is of a form where it |
| 155013 | 155031 | ** could be used with an index to access pSrc, assuming an appropriate |
| @@ -155020,20 +155038,14 @@ | ||
| 155020 | 155038 | ){ |
| 155021 | 155039 | char aff; |
| 155022 | 155040 | if( pTerm->leftCursor!=pSrc->iCursor ) return 0; |
| 155023 | 155041 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; |
| 155024 | 155042 | assert( (pSrc->fg.jointype & JT_RIGHT)==0 ); |
| 155025 | - if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ){ | |
| 155026 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); | |
| 155027 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); | |
| 155028 | - testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ) | |
| 155029 | - testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); | |
| 155030 | - if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) | |
| 155031 | - || pTerm->pExpr->w.iJoin != pSrc->iCursor | |
| 155032 | - ){ | |
| 155033 | - return 0; /* See tag-20191211-001 */ | |
| 155034 | - } | |
| 155043 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 | |
| 155044 | + && !constraintCompatibleWithOuterJoin(pTerm,pSrc) | |
| 155045 | + ){ | |
| 155046 | + return 0; /* See https://sqlite.org/forum/forumpost/51e6959f61 */ | |
| 155035 | 155047 | } |
| 155036 | 155048 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 155037 | 155049 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 155038 | 155050 | if( pTerm->u.x.leftColumn<0 ) return 0; |
| 155039 | 155051 | aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; |
| @@ -155441,26 +155453,14 @@ | ||
| 155441 | 155453 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 155442 | 155454 | |
| 155443 | 155455 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 155444 | 155456 | assert( pTerm->u.x.leftColumn>=XN_ROWID ); |
| 155445 | 155457 | assert( pTerm->u.x.leftColumn<pTab->nCol ); |
| 155446 | - | |
| 155447 | - /* tag-20191211-002: WHERE-clause constraints are not useful to the | |
| 155448 | - ** right-hand table of a LEFT JOIN nor to the either table of a | |
| 155449 | - ** RIGHT JOIN. See tag-20191211-001 for the | |
| 155450 | - ** equivalent restriction for ordinary tables. */ | |
| 155451 | - if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ){ | |
| 155452 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); | |
| 155453 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_RIGHT ); | |
| 155454 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); | |
| 155455 | - testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ); | |
| 155456 | - testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); | |
| 155457 | - if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) | |
| 155458 | - || pTerm->pExpr->w.iJoin != pSrc->iCursor | |
| 155459 | - ){ | |
| 155460 | - continue; | |
| 155461 | - } | |
| 155458 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 | |
| 155459 | + && !constraintCompatibleWithOuterJoin(pTerm,pSrc) | |
| 155460 | + ){ | |
| 155461 | + continue; | |
| 155462 | 155462 | } |
| 155463 | 155463 | nTerm++; |
| 155464 | 155464 | pTerm->wtFlags |= TERM_OK; |
| 155465 | 155465 | } |
| 155466 | 155466 | |
| @@ -157114,36 +157114,15 @@ | ||
| 157114 | 157114 | |
| 157115 | 157115 | /* Do not allow the upper bound of a LIKE optimization range constraint |
| 157116 | 157116 | ** to mix with a lower range bound from some other source */ |
| 157117 | 157117 | if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 157118 | 157118 | |
| 157119 | - /* tag-20191211-001: Do not allow constraints from the WHERE clause to | |
| 157120 | - ** be used by the right table of a LEFT JOIN nor by the left table of a | |
| 157121 | - ** RIGHT JOIN. Only constraints in the ON clause are allowed. | |
| 157122 | - ** See tag-20191211-002 for the vtab equivalent. | |
| 157123 | - ** | |
| 157124 | - ** 2022-06-06: See https://sqlite.org/forum/forumpost/206d99a16dd9212f | |
| 157125 | - ** for an example of a WHERE clause constraints that may not be used on | |
| 157126 | - ** the right table of a RIGHT JOIN because the constraint implies a | |
| 157127 | - ** not-NULL condition on the left table of the RIGHT JOIN. | |
| 157128 | - ** | |
| 157129 | - ** 2022-06-10: The same condition applies to termCanDriveIndex() above. | |
| 157130 | - ** https://sqlite.org/forum/forumpost/51e6959f61 | |
| 157131 | - */ | |
| 157132 | - if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ){ | |
| 157133 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); | |
| 157134 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_RIGHT ); | |
| 157135 | - testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); | |
| 157136 | - testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ) | |
| 157137 | - testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); | |
| 157138 | - if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) | |
| 157139 | - || pTerm->pExpr->w.iJoin != pSrc->iCursor | |
| 157140 | - ){ | |
| 157141 | - continue; | |
| 157142 | - } | |
| 157143 | - } | |
| 157144 | - | |
| 157119 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 | |
| 157120 | + && !constraintCompatibleWithOuterJoin(pTerm,pSrc) | |
| 157121 | + ){ | |
| 157122 | + continue; | |
| 157123 | + } | |
| 157145 | 157124 | if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){ |
| 157146 | 157125 | pBuilder->bldFlags1 |= SQLITE_BLDF1_UNIQUE; |
| 157147 | 157126 | }else{ |
| 157148 | 157127 | pBuilder->bldFlags1 |= SQLITE_BLDF1_INDEXED; |
| 157149 | 157128 | } |
| @@ -177299,11 +177278,11 @@ | ||
| 177299 | 177278 | Fts3SegReader **apSegment; /* Array of Fts3SegReader objects */ |
| 177300 | 177279 | int nSegment; /* Size of apSegment array */ |
| 177301 | 177280 | int nAdvance; /* How many seg-readers to advance */ |
| 177302 | 177281 | Fts3SegFilter *pFilter; /* Pointer to filter object */ |
| 177303 | 177282 | char *aBuffer; /* Buffer to merge doclists in */ |
| 177304 | - int nBuffer; /* Allocated size of aBuffer[] in bytes */ | |
| 177283 | + i64 nBuffer; /* Allocated size of aBuffer[] in bytes */ | |
| 177305 | 177284 | |
| 177306 | 177285 | int iColFilter; /* If >=0, filter for this column */ |
| 177307 | 177286 | int bRestart; |
| 177308 | 177287 | |
| 177309 | 177288 | /* Used by fts3.c only. */ |
| @@ -179995,11 +179974,11 @@ | ||
| 179995 | 179974 | ** as a single-byte delta, whereas in the second it must be stored as a |
| 179996 | 179975 | ** FTS3_VARINT_MAX byte varint. |
| 179997 | 179976 | ** |
| 179998 | 179977 | ** Similar padding is added in the fts3DoclistOrMerge() function. |
| 179999 | 179978 | */ |
| 180000 | - pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1); | |
| 179979 | + pTS->aaOutput[0] = sqlite3_malloc64((i64)nDoclist + FTS3_VARINT_MAX + 1); | |
| 180001 | 179980 | pTS->anOutput[0] = nDoclist; |
| 180002 | 179981 | if( pTS->aaOutput[0] ){ |
| 180003 | 179982 | memcpy(pTS->aaOutput[0], aDoclist, nDoclist); |
| 180004 | 179983 | memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX); |
| 180005 | 179984 | }else{ |
| @@ -181852,11 +181831,11 @@ | ||
| 181852 | 181831 | |
| 181853 | 181832 | /* Check if the current entries really are a phrase match */ |
| 181854 | 181833 | if( bEof==0 ){ |
| 181855 | 181834 | int nList = 0; |
| 181856 | 181835 | int nByte = a[p->nToken-1].nList; |
| 181857 | - char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING); | |
| 181836 | + char *aDoclist = sqlite3_malloc64((i64)nByte+FTS3_BUFFER_PADDING); | |
| 181858 | 181837 | if( !aDoclist ) return SQLITE_NOMEM; |
| 181859 | 181838 | memcpy(aDoclist, a[p->nToken-1].pList, nByte+1); |
| 181860 | 181839 | memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING); |
| 181861 | 181840 | |
| 181862 | 181841 | for(i=0; i<(p->nToken-1); i++){ |
| @@ -186088,11 +186067,11 @@ | ||
| 186088 | 186067 | if( c->iOffset>iStartOffset ){ |
| 186089 | 186068 | int n = c->iOffset-iStartOffset; |
| 186090 | 186069 | if( n>c->nAllocated ){ |
| 186091 | 186070 | char *pNew; |
| 186092 | 186071 | c->nAllocated = n+20; |
| 186093 | - pNew = sqlite3_realloc(c->zToken, c->nAllocated); | |
| 186072 | + pNew = sqlite3_realloc64(c->zToken, c->nAllocated); | |
| 186094 | 186073 | if( !pNew ) return SQLITE_NOMEM; |
| 186095 | 186074 | c->zToken = pNew; |
| 186096 | 186075 | } |
| 186097 | 186076 | porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes); |
| 186098 | 186077 | *pzToken = c->zToken; |
| @@ -186840,11 +186819,11 @@ | ||
| 186840 | 186819 | if( c->iOffset>iStartOffset ){ |
| 186841 | 186820 | int i, n = c->iOffset-iStartOffset; |
| 186842 | 186821 | if( n>c->nTokenAllocated ){ |
| 186843 | 186822 | char *pNew; |
| 186844 | 186823 | c->nTokenAllocated = n+20; |
| 186845 | - pNew = sqlite3_realloc(c->pToken, c->nTokenAllocated); | |
| 186824 | + pNew = sqlite3_realloc64(c->pToken, c->nTokenAllocated); | |
| 186846 | 186825 | if( !pNew ) return SQLITE_NOMEM; |
| 186847 | 186826 | c->pToken = pNew; |
| 186848 | 186827 | } |
| 186849 | 186828 | for(i=0; i<n; i++){ |
| 186850 | 186829 | /* TODO(shess) This needs expansion to handle UTF-8 |
| @@ -188002,27 +187981,27 @@ | ||
| 188002 | 187981 | ){ |
| 188003 | 187982 | PendingList *p = *pp; |
| 188004 | 187983 | |
| 188005 | 187984 | /* Allocate or grow the PendingList as required. */ |
| 188006 | 187985 | if( !p ){ |
| 188007 | - p = sqlite3_malloc(sizeof(*p) + 100); | |
| 187986 | + p = sqlite3_malloc64(sizeof(*p) + 100); | |
| 188008 | 187987 | if( !p ){ |
| 188009 | 187988 | return SQLITE_NOMEM; |
| 188010 | 187989 | } |
| 188011 | 187990 | p->nSpace = 100; |
| 188012 | 187991 | p->aData = (char *)&p[1]; |
| 188013 | 187992 | p->nData = 0; |
| 188014 | 187993 | } |
| 188015 | 187994 | else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){ |
| 188016 | - int nNew = p->nSpace * 2; | |
| 188017 | - p = sqlite3_realloc(p, sizeof(*p) + nNew); | |
| 187995 | + i64 nNew = p->nSpace * 2; | |
| 187996 | + p = sqlite3_realloc64(p, sizeof(*p) + nNew); | |
| 188018 | 187997 | if( !p ){ |
| 188019 | 187998 | sqlite3_free(*pp); |
| 188020 | 187999 | *pp = 0; |
| 188021 | 188000 | return SQLITE_NOMEM; |
| 188022 | 188001 | } |
| 188023 | - p->nSpace = nNew; | |
| 188002 | + p->nSpace = (int)nNew; | |
| 188024 | 188003 | p->aData = (char *)&p[1]; |
| 188025 | 188004 | } |
| 188026 | 188005 | |
| 188027 | 188006 | /* Append the new serialized varint to the end of the list. */ |
| 188028 | 188007 | p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i); |
| @@ -188575,11 +188554,11 @@ | ||
| 188575 | 188554 | |
| 188576 | 188555 | if( rc==SQLITE_OK ){ |
| 188577 | 188556 | int nByte = sqlite3_blob_bytes(p->pSegments); |
| 188578 | 188557 | *pnBlob = nByte; |
| 188579 | 188558 | if( paBlob ){ |
| 188580 | - char *aByte = sqlite3_malloc(nByte + FTS3_NODE_PADDING); | |
| 188559 | + char *aByte = sqlite3_malloc64((i64)nByte + FTS3_NODE_PADDING); | |
| 188581 | 188560 | if( !aByte ){ |
| 188582 | 188561 | rc = SQLITE_NOMEM; |
| 188583 | 188562 | }else{ |
| 188584 | 188563 | if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){ |
| 188585 | 188564 | nByte = FTS3_NODE_CHUNKSIZE; |
| @@ -188692,19 +188671,19 @@ | ||
| 188692 | 188671 | int nCopy = pList->nData+1; |
| 188693 | 188672 | |
| 188694 | 188673 | int nTerm = fts3HashKeysize(pElem); |
| 188695 | 188674 | if( (nTerm+1)>pReader->nTermAlloc ){ |
| 188696 | 188675 | sqlite3_free(pReader->zTerm); |
| 188697 | - pReader->zTerm = (char*)sqlite3_malloc((nTerm+1)*2); | |
| 188676 | + pReader->zTerm = (char*)sqlite3_malloc64(((i64)nTerm+1)*2); | |
| 188698 | 188677 | if( !pReader->zTerm ) return SQLITE_NOMEM; |
| 188699 | 188678 | pReader->nTermAlloc = (nTerm+1)*2; |
| 188700 | 188679 | } |
| 188701 | 188680 | memcpy(pReader->zTerm, fts3HashKey(pElem), nTerm); |
| 188702 | 188681 | pReader->zTerm[nTerm] = '\0'; |
| 188703 | 188682 | pReader->nTerm = nTerm; |
| 188704 | 188683 | |
| 188705 | - aCopy = (char*)sqlite3_malloc(nCopy); | |
| 188684 | + aCopy = (char*)sqlite3_malloc64(nCopy); | |
| 188706 | 188685 | if( !aCopy ) return SQLITE_NOMEM; |
| 188707 | 188686 | memcpy(aCopy, pList->aData, nCopy); |
| 188708 | 188687 | pReader->nNode = pReader->nDoclist = nCopy; |
| 188709 | 188688 | pReader->aNode = pReader->aDoclist = aCopy; |
| 188710 | 188689 | pReader->ppNextElem++; |
| @@ -188987,11 +188966,11 @@ | ||
| 188987 | 188966 | if( iStartLeaf==0 ){ |
| 188988 | 188967 | if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB; |
| 188989 | 188968 | nExtra = nRoot + FTS3_NODE_PADDING; |
| 188990 | 188969 | } |
| 188991 | 188970 | |
| 188992 | - pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra); | |
| 188971 | + pReader = (Fts3SegReader *)sqlite3_malloc64(sizeof(Fts3SegReader) + nExtra); | |
| 188993 | 188972 | if( !pReader ){ |
| 188994 | 188973 | return SQLITE_NOMEM; |
| 188995 | 188974 | } |
| 188996 | 188975 | memset(pReader, 0, sizeof(Fts3SegReader)); |
| 188997 | 188976 | pReader->iIdx = iAge; |
| @@ -189079,11 +189058,11 @@ | ||
| 189079 | 189058 | int nKey = fts3HashKeysize(pE); |
| 189080 | 189059 | if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){ |
| 189081 | 189060 | if( nElem==nAlloc ){ |
| 189082 | 189061 | Fts3HashElem **aElem2; |
| 189083 | 189062 | nAlloc += 16; |
| 189084 | - aElem2 = (Fts3HashElem **)sqlite3_realloc( | |
| 189063 | + aElem2 = (Fts3HashElem **)sqlite3_realloc64( | |
| 189085 | 189064 | aElem, nAlloc*sizeof(Fts3HashElem *) |
| 189086 | 189065 | ); |
| 189087 | 189066 | if( !aElem2 ){ |
| 189088 | 189067 | rc = SQLITE_NOMEM; |
| 189089 | 189068 | nElem = 0; |
| @@ -189413,11 +189392,11 @@ | ||
| 189413 | 189392 | ** p->nNodeSize bytes, but since this scenario only comes about when |
| 189414 | 189393 | ** the database contain two terms that share a prefix of almost 2KB, |
| 189415 | 189394 | ** this is not expected to be a serious problem. |
| 189416 | 189395 | */ |
| 189417 | 189396 | assert( pTree->aData==(char *)&pTree[1] ); |
| 189418 | - pTree->aData = (char *)sqlite3_malloc(nReq); | |
| 189397 | + pTree->aData = (char *)sqlite3_malloc64(nReq); | |
| 189419 | 189398 | if( !pTree->aData ){ |
| 189420 | 189399 | return SQLITE_NOMEM; |
| 189421 | 189400 | } |
| 189422 | 189401 | } |
| 189423 | 189402 | |
| @@ -189431,11 +189410,11 @@ | ||
| 189431 | 189410 | pTree->nData = nData + nSuffix; |
| 189432 | 189411 | pTree->nEntry++; |
| 189433 | 189412 | |
| 189434 | 189413 | if( isCopyTerm ){ |
| 189435 | 189414 | if( pTree->nMalloc<nTerm ){ |
| 189436 | - char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2); | |
| 189415 | + char *zNew = sqlite3_realloc64(pTree->zMalloc, (i64)nTerm*2); | |
| 189437 | 189416 | if( !zNew ){ |
| 189438 | 189417 | return SQLITE_NOMEM; |
| 189439 | 189418 | } |
| 189440 | 189419 | pTree->nMalloc = nTerm*2; |
| 189441 | 189420 | pTree->zMalloc = zNew; |
| @@ -189457,11 +189436,11 @@ | ||
| 189457 | 189436 | ** |
| 189458 | 189437 | ** Otherwise, the term is not added to the new node, it is left empty for |
| 189459 | 189438 | ** now. Instead, the term is inserted into the parent of pTree. If pTree |
| 189460 | 189439 | ** has no parent, one is created here. |
| 189461 | 189440 | */ |
| 189462 | - pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize); | |
| 189441 | + pNew = (SegmentNode *)sqlite3_malloc64(sizeof(SegmentNode) + p->nNodeSize); | |
| 189463 | 189442 | if( !pNew ){ |
| 189464 | 189443 | return SQLITE_NOMEM; |
| 189465 | 189444 | } |
| 189466 | 189445 | memset(pNew, 0, sizeof(SegmentNode)); |
| 189467 | 189446 | pNew->nData = 1 + FTS3_VARINT_MAX; |
| @@ -189595,26 +189574,26 @@ | ||
| 189595 | 189574 | const char *aDoclist, /* Pointer to buffer containing doclist */ |
| 189596 | 189575 | int nDoclist /* Size of doclist in bytes */ |
| 189597 | 189576 | ){ |
| 189598 | 189577 | int nPrefix; /* Size of term prefix in bytes */ |
| 189599 | 189578 | int nSuffix; /* Size of term suffix in bytes */ |
| 189600 | - int nReq; /* Number of bytes required on leaf page */ | |
| 189579 | + i64 nReq; /* Number of bytes required on leaf page */ | |
| 189601 | 189580 | int nData; |
| 189602 | 189581 | SegmentWriter *pWriter = *ppWriter; |
| 189603 | 189582 | |
| 189604 | 189583 | if( !pWriter ){ |
| 189605 | 189584 | int rc; |
| 189606 | 189585 | sqlite3_stmt *pStmt; |
| 189607 | 189586 | |
| 189608 | 189587 | /* Allocate the SegmentWriter structure */ |
| 189609 | - pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter)); | |
| 189588 | + pWriter = (SegmentWriter *)sqlite3_malloc64(sizeof(SegmentWriter)); | |
| 189610 | 189589 | if( !pWriter ) return SQLITE_NOMEM; |
| 189611 | 189590 | memset(pWriter, 0, sizeof(SegmentWriter)); |
| 189612 | 189591 | *ppWriter = pWriter; |
| 189613 | 189592 | |
| 189614 | 189593 | /* Allocate a buffer in which to accumulate data */ |
| 189615 | - pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize); | |
| 189594 | + pWriter->aData = (char *)sqlite3_malloc64(p->nNodeSize); | |
| 189616 | 189595 | if( !pWriter->aData ) return SQLITE_NOMEM; |
| 189617 | 189596 | pWriter->nSize = p->nNodeSize; |
| 189618 | 189597 | |
| 189619 | 189598 | /* Find the next free blockid in the %_segments table */ |
| 189620 | 189599 | rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0); |
| @@ -189685,11 +189664,11 @@ | ||
| 189685 | 189664 | |
| 189686 | 189665 | /* If the buffer currently allocated is too small for this entry, realloc |
| 189687 | 189666 | ** the buffer to make it large enough. |
| 189688 | 189667 | */ |
| 189689 | 189668 | if( nReq>pWriter->nSize ){ |
| 189690 | - char *aNew = sqlite3_realloc(pWriter->aData, nReq); | |
| 189669 | + char *aNew = sqlite3_realloc64(pWriter->aData, nReq); | |
| 189691 | 189670 | if( !aNew ) return SQLITE_NOMEM; |
| 189692 | 189671 | pWriter->aData = aNew; |
| 189693 | 189672 | pWriter->nSize = nReq; |
| 189694 | 189673 | } |
| 189695 | 189674 | assert( nData+nReq<=pWriter->nSize ); |
| @@ -189710,11 +189689,11 @@ | ||
| 189710 | 189689 | ** zTerm is transient, so take a copy of the term data. Otherwise, just |
| 189711 | 189690 | ** store a copy of the pointer. |
| 189712 | 189691 | */ |
| 189713 | 189692 | if( isCopyTerm ){ |
| 189714 | 189693 | if( nTerm>pWriter->nMalloc ){ |
| 189715 | - char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2); | |
| 189694 | + char *zNew = sqlite3_realloc64(pWriter->zMalloc, (i64)nTerm*2); | |
| 189716 | 189695 | if( !zNew ){ |
| 189717 | 189696 | return SQLITE_NOMEM; |
| 189718 | 189697 | } |
| 189719 | 189698 | pWriter->nMalloc = nTerm*2; |
| 189720 | 189699 | pWriter->zMalloc = zNew; |
| @@ -190018,16 +189997,16 @@ | ||
| 190018 | 189997 | ** trying to resize the buffer, return SQLITE_NOMEM. |
| 190019 | 189998 | */ |
| 190020 | 189999 | static int fts3MsrBufferData( |
| 190021 | 190000 | Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */ |
| 190022 | 190001 | char *pList, |
| 190023 | - int nList | |
| 190002 | + i64 nList | |
| 190024 | 190003 | ){ |
| 190025 | 190004 | if( nList>pMsr->nBuffer ){ |
| 190026 | 190005 | char *pNew; |
| 190027 | 190006 | pMsr->nBuffer = nList*2; |
| 190028 | - pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer); | |
| 190007 | + pNew = (char *)sqlite3_realloc64(pMsr->aBuffer, pMsr->nBuffer); | |
| 190029 | 190008 | if( !pNew ) return SQLITE_NOMEM; |
| 190030 | 190009 | pMsr->aBuffer = pNew; |
| 190031 | 190010 | } |
| 190032 | 190011 | |
| 190033 | 190012 | assert( nList>0 ); |
| @@ -190079,11 +190058,11 @@ | ||
| 190079 | 190058 | } |
| 190080 | 190059 | if( rc!=SQLITE_OK ) return rc; |
| 190081 | 190060 | fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp); |
| 190082 | 190061 | |
| 190083 | 190062 | if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){ |
| 190084 | - rc = fts3MsrBufferData(pMsr, pList, nList+1); | |
| 190063 | + rc = fts3MsrBufferData(pMsr, pList, (i64)nList+1); | |
| 190085 | 190064 | if( rc!=SQLITE_OK ) return rc; |
| 190086 | 190065 | assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); |
| 190087 | 190066 | pList = pMsr->aBuffer; |
| 190088 | 190067 | } |
| 190089 | 190068 | |
| @@ -190216,15 +190195,15 @@ | ||
| 190216 | 190195 | } |
| 190217 | 190196 | |
| 190218 | 190197 | return SQLITE_OK; |
| 190219 | 190198 | } |
| 190220 | 190199 | |
| 190221 | -static int fts3GrowSegReaderBuffer(Fts3MultiSegReader *pCsr, int nReq){ | |
| 190200 | +static int fts3GrowSegReaderBuffer(Fts3MultiSegReader *pCsr, i64 nReq){ | |
| 190222 | 190201 | if( nReq>pCsr->nBuffer ){ |
| 190223 | 190202 | char *aNew; |
| 190224 | 190203 | pCsr->nBuffer = nReq*2; |
| 190225 | - aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer); | |
| 190204 | + aNew = sqlite3_realloc64(pCsr->aBuffer, pCsr->nBuffer); | |
| 190226 | 190205 | if( !aNew ){ |
| 190227 | 190206 | return SQLITE_NOMEM; |
| 190228 | 190207 | } |
| 190229 | 190208 | pCsr->aBuffer = aNew; |
| 190230 | 190209 | } |
| @@ -190311,11 +190290,12 @@ | ||
| 190311 | 190290 | && !isFirst |
| 190312 | 190291 | && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) |
| 190313 | 190292 | ){ |
| 190314 | 190293 | pCsr->nDoclist = apSegment[0]->nDoclist; |
| 190315 | 190294 | if( fts3SegReaderIsPending(apSegment[0]) ){ |
| 190316 | - rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist); | |
| 190295 | + rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, | |
| 190296 | + (i64)pCsr->nDoclist); | |
| 190317 | 190297 | pCsr->aDoclist = pCsr->aBuffer; |
| 190318 | 190298 | }else{ |
| 190319 | 190299 | pCsr->aDoclist = apSegment[0]->aDoclist; |
| 190320 | 190300 | } |
| 190321 | 190301 | if( rc==SQLITE_OK ) rc = SQLITE_ROW; |
| @@ -190364,11 +190344,12 @@ | ||
| 190364 | 190344 | iDelta = (i64)((u64)iDocid - (u64)iPrev); |
| 190365 | 190345 | } |
| 190366 | 190346 | |
| 190367 | 190347 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 190368 | 190348 | |
| 190369 | - rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING); | |
| 190349 | + rc = fts3GrowSegReaderBuffer(pCsr, | |
| 190350 | + (i64)nByte+nDoclist+FTS3_NODE_PADDING); | |
| 190370 | 190351 | if( rc ) return rc; |
| 190371 | 190352 | |
| 190372 | 190353 | if( isFirst ){ |
| 190373 | 190354 | char *a = &pCsr->aBuffer[nDoclist]; |
| 190374 | 190355 | int nWrite; |
| @@ -190390,11 +190371,11 @@ | ||
| 190390 | 190371 | } |
| 190391 | 190372 | |
| 190392 | 190373 | fts3SegReaderSort(apSegment, nMerge, j, xCmp); |
| 190393 | 190374 | } |
| 190394 | 190375 | if( nDoclist>0 ){ |
| 190395 | - rc = fts3GrowSegReaderBuffer(pCsr, nDoclist+FTS3_NODE_PADDING); | |
| 190376 | + rc = fts3GrowSegReaderBuffer(pCsr, (i64)nDoclist+FTS3_NODE_PADDING); | |
| 190396 | 190377 | if( rc ) return rc; |
| 190397 | 190378 | memset(&pCsr->aBuffer[nDoclist], 0, FTS3_NODE_PADDING); |
| 190398 | 190379 | pCsr->aDoclist = pCsr->aBuffer; |
| 190399 | 190380 | pCsr->nDoclist = nDoclist; |
| 190400 | 190381 | rc = SQLITE_ROW; |
| @@ -191103,11 +191084,11 @@ | ||
| 191103 | 191084 | ** to reflect the new size of the pBlob->a[] buffer. |
| 191104 | 191085 | */ |
| 191105 | 191086 | static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){ |
| 191106 | 191087 | if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){ |
| 191107 | 191088 | int nAlloc = nMin; |
| 191108 | - char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc); | |
| 191089 | + char *a = (char *)sqlite3_realloc64(pBlob->a, nAlloc); | |
| 191109 | 191090 | if( a ){ |
| 191110 | 191091 | pBlob->nAlloc = nAlloc; |
| 191111 | 191092 | pBlob->a = a; |
| 191112 | 191093 | }else{ |
| 191113 | 191094 | *pRc = SQLITE_NOMEM; |
| @@ -191900,11 +191881,11 @@ | ||
| 191900 | 191881 | sqlite3_bind_int64(pSelect, 1, iAbsLevel); |
| 191901 | 191882 | while( SQLITE_ROW==sqlite3_step(pSelect) ){ |
| 191902 | 191883 | if( nIdx>=nAlloc ){ |
| 191903 | 191884 | int *aNew; |
| 191904 | 191885 | nAlloc += 16; |
| 191905 | - aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int)); | |
| 191886 | + aNew = sqlite3_realloc64(aIdx, nAlloc*sizeof(int)); | |
| 191906 | 191887 | if( !aNew ){ |
| 191907 | 191888 | rc = SQLITE_NOMEM; |
| 191908 | 191889 | break; |
| 191909 | 191890 | } |
| 191910 | 191891 | aIdx = aNew; |
| @@ -192274,11 +192255,11 @@ | ||
| 192274 | 192255 | Blob hint = {0, 0, 0}; /* Hint read from %_stat table */ |
| 192275 | 192256 | int bDirtyHint = 0; /* True if blob 'hint' has been modified */ |
| 192276 | 192257 | |
| 192277 | 192258 | /* Allocate space for the cursor, filter and writer objects */ |
| 192278 | 192259 | const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter); |
| 192279 | - pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc); | |
| 192260 | + pWriter = (IncrmergeWriter *)sqlite3_malloc64(nAlloc); | |
| 192280 | 192261 | if( !pWriter ) return SQLITE_NOMEM; |
| 192281 | 192262 | pFilter = (Fts3SegFilter *)&pWriter[1]; |
| 192282 | 192263 | pCsr = (Fts3MultiSegReader *)&pFilter[1]; |
| 192283 | 192264 | |
| 192284 | 192265 | rc = fts3IncrmergeHintLoad(p, &hint); |
| @@ -192910,11 +192891,11 @@ | ||
| 192910 | 192891 | |
| 192911 | 192892 | if( p->pList==0 ){ |
| 192912 | 192893 | return SQLITE_OK; |
| 192913 | 192894 | } |
| 192914 | 192895 | |
| 192915 | - pRet = (char *)sqlite3_malloc(p->pList->nData); | |
| 192896 | + pRet = (char *)sqlite3_malloc64(p->pList->nData); | |
| 192916 | 192897 | if( !pRet ) return SQLITE_NOMEM; |
| 192917 | 192898 | |
| 192918 | 192899 | nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy); |
| 192919 | 192900 | *pnData = p->pList->nData - nSkip; |
| 192920 | 192901 | *ppData = pRet; |
| @@ -192930,11 +192911,11 @@ | ||
| 192930 | 192911 | Fts3Cursor *pCsr, /* Fts3 table cursor */ |
| 192931 | 192912 | Fts3PhraseToken *pToken, /* Token to defer */ |
| 192932 | 192913 | int iCol /* Column that token must appear in (or -1) */ |
| 192933 | 192914 | ){ |
| 192934 | 192915 | Fts3DeferredToken *pDeferred; |
| 192935 | - pDeferred = sqlite3_malloc(sizeof(*pDeferred)); | |
| 192916 | + pDeferred = sqlite3_malloc64(sizeof(*pDeferred)); | |
| 192936 | 192917 | if( !pDeferred ){ |
| 192937 | 192918 | return SQLITE_NOMEM; |
| 192938 | 192919 | } |
| 192939 | 192920 | memset(pDeferred, 0, sizeof(*pDeferred)); |
| 192940 | 192921 | pDeferred->pToken = pToken; |
| @@ -205112,12 +205093,13 @@ | ||
| 205112 | 205093 | } |
| 205113 | 205094 | pExpr = uregex_open(zPattern, -1, 0, 0, &status); |
| 205114 | 205095 | |
| 205115 | 205096 | if( U_SUCCESS(status) ){ |
| 205116 | 205097 | sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete); |
| 205117 | - }else{ | |
| 205118 | - assert(!pExpr); | |
| 205098 | + pExpr = sqlite3_get_auxdata(p, 0); | |
| 205099 | + } | |
| 205100 | + if( !pExpr ){ | |
| 205119 | 205101 | icuFunctionError(p, "uregex_open", status); |
| 205120 | 205102 | return; |
| 205121 | 205103 | } |
| 205122 | 205104 | } |
| 205123 | 205105 | |
| @@ -237002,11 +236984,11 @@ | ||
| 237002 | 236984 | int nArg, /* Number of args */ |
| 237003 | 236985 | sqlite3_value **apUnused /* Function arguments */ |
| 237004 | 236986 | ){ |
| 237005 | 236987 | assert( nArg==0 ); |
| 237006 | 236988 | UNUSED_PARAM2(nArg, apUnused); |
| 237007 | - sqlite3_result_text(pCtx, "fts5: 2022-09-02 21:19:24 da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c", -1, SQLITE_TRANSIENT); | |
| 236989 | + sqlite3_result_text(pCtx, "fts5: 2022-09-28 19:14:01 f25cf63471cbed1edb27591e57fead62550d4046dbdcb61312288f0f6f24c646", -1, SQLITE_TRANSIENT); | |
| 237008 | 236990 | } |
| 237009 | 236991 | |
| 237010 | 236992 | /* |
| 237011 | 236993 | ** Return true if zName is the extension on one of the shadow tables used |
| 237012 | 236994 | ** by this module. |
| 237013 | 236995 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -452,11 +452,11 @@ | |
| 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | */ |
| 455 | #define SQLITE_VERSION "3.40.0" |
| 456 | #define SQLITE_VERSION_NUMBER 3040000 |
| 457 | #define SQLITE_SOURCE_ID "2022-09-02 21:19:24 da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -29076,22 +29076,38 @@ | |
| 29076 | sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 29077 | } |
| 29078 | *pp = p; |
| 29079 | } |
| 29080 | |
| 29081 | /* |
| 29082 | ** Allocate memory. This routine is like sqlite3_malloc() except that it |
| 29083 | ** assumes the memory subsystem has already been initialized. |
| 29084 | */ |
| 29085 | SQLITE_PRIVATE void *sqlite3Malloc(u64 n){ |
| 29086 | void *p; |
| 29087 | if( n==0 || n>=0x7fffff00 ){ |
| 29088 | /* A memory allocation of a number of bytes which is near the maximum |
| 29089 | ** signed integer value might cause an integer overflow inside of the |
| 29090 | ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving |
| 29091 | ** 255 bytes of overhead. SQLite itself will never use anything near |
| 29092 | ** this amount. The only way to reach the limit is with sqlite3_malloc() */ |
| 29093 | p = 0; |
| 29094 | }else if( sqlite3GlobalConfig.bMemstat ){ |
| 29095 | sqlite3_mutex_enter(mem0.mutex); |
| 29096 | mallocWithAlarm((int)n, &p); |
| 29097 | sqlite3_mutex_leave(mem0.mutex); |
| @@ -45571,12 +45587,13 @@ | |
| 45571 | SQLITE_API int sqlite3_win32_set_directory8( |
| 45572 | unsigned long type, /* Identifier for directory being set or reset */ |
| 45573 | const char *zValue /* New value for directory being set or reset */ |
| 45574 | ){ |
| 45575 | char **ppDirectory = 0; |
| 45576 | #ifndef SQLITE_OMIT_AUTOINIT |
| 45577 | int rc = sqlite3_initialize(); |
| 45578 | if( rc ) return rc; |
| 45579 | #endif |
| 45580 | sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); |
| 45581 | if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){ |
| 45582 | ppDirectory = &sqlite3_data_directory; |
| @@ -49415,11 +49432,12 @@ | |
| 49415 | const char *zRelative, /* Possibly relative input path */ |
| 49416 | int nFull, /* Size of output buffer in bytes */ |
| 49417 | char *zFull /* Output buffer */ |
| 49418 | ){ |
| 49419 | int rc; |
| 49420 | sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); |
| 49421 | sqlite3_mutex_enter(pMutex); |
| 49422 | rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull); |
| 49423 | sqlite3_mutex_leave(pMutex); |
| 49424 | return rc; |
| 49425 | } |
| @@ -51798,18 +51816,18 @@ | |
| 51798 | assert( p->nRef>0 ); |
| 51799 | assert( newPgno>0 ); |
| 51800 | assert( sqlite3PcachePageSanity(p) ); |
| 51801 | pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); |
| 51802 | pOther = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, newPgno, 0); |
| 51803 | sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); |
| 51804 | if( pOther ){ |
| 51805 | PgHdr *pPg = (PgHdr*)pOther->pExtra; |
| 51806 | pPg->pgno = p->pgno; |
| 51807 | if( pPg->pPage==0 ){ |
| 51808 | sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pOther, 0); |
| 51809 | } |
| 51810 | } |
| 51811 | p->pgno = newPgno; |
| 51812 | if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ |
| 51813 | pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); |
| 51814 | assert( sqlite3PcachePageSanity(p) ); |
| 51815 | } |
| @@ -53202,27 +53220,12 @@ | |
| 53202 | while( (*pp)!=pPage ){ |
| 53203 | pp = &(*pp)->pNext; |
| 53204 | } |
| 53205 | *pp = pPage->pNext; |
| 53206 | |
| 53207 | hNew = iNew%pCache->nHash; |
| 53208 | pp = &pCache->apHash[hNew]; |
| 53209 | while( *pp ){ |
| 53210 | if( (*pp)->iKey==iNew ){ |
| 53211 | /* If there is already another pcache entry at iNew, change it to iOld, |
| 53212 | ** thus swapping the positions of iNew and iOld */ |
| 53213 | PgHdr1 *pOld = *pp; |
| 53214 | *pp = pOld->pNext; |
| 53215 | pOld->pNext = pCache->apHash[hOld]; |
| 53216 | pCache->apHash[hOld] = pOld; |
| 53217 | pOld->iKey = iOld; |
| 53218 | break; |
| 53219 | }else{ |
| 53220 | pp = &(*pp)->pNext; |
| 53221 | } |
| 53222 | } |
| 53223 | |
| 53224 | pPage->iKey = iNew; |
| 53225 | pPage->pNext = pCache->apHash[hNew]; |
| 53226 | pCache->apHash[hNew] = pPage; |
| 53227 | if( iNew>pCache->iMaxKey ){ |
| 53228 | pCache->iMaxKey = iNew; |
| @@ -68523,11 +68526,11 @@ | |
| 68523 | if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage); |
| 68524 | sz2 = get2byte(&data[iFree2+2]); |
| 68525 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); |
| 68526 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 68527 | sz += sz2; |
| 68528 | }else if( NEVER(iFree+sz>usableSize) ){ |
| 68529 | return SQLITE_CORRUPT_PAGE(pPage); |
| 68530 | } |
| 68531 | |
| 68532 | cbrk = top+sz; |
| 68533 | assert( cbrk+(iFree-top) <= usableSize ); |
| @@ -93400,16 +93403,20 @@ | |
| 93400 | } |
| 93401 | |
| 93402 | /* Opcode: IfNotOpen P1 P2 * * * |
| 93403 | ** Synopsis: if( !csr[P1] ) goto P2 |
| 93404 | ** |
| 93405 | ** If cursor P1 is not open, jump to instruction P2. Otherwise, fall through. |
| 93406 | */ |
| 93407 | case OP_IfNotOpen: { /* jump */ |
| 93408 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 93409 | VdbeBranchTaken(p->apCsr[pOp->p1]==0, 2); |
| 93410 | if( !p->apCsr[pOp->p1] ){ |
| 93411 | goto jump_to_p2_and_check_for_interrupt; |
| 93412 | } |
| 93413 | break; |
| 93414 | } |
| 93415 | |
| @@ -107028,10 +107035,11 @@ | |
| 107028 | } |
| 107029 | if( pKeyInfo ){ |
| 107030 | sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO); |
| 107031 | } |
| 107032 | if( addrOnce ){ |
| 107033 | sqlite3VdbeJumpHere(v, addrOnce); |
| 107034 | /* Subroutine return */ |
| 107035 | assert( ExprUseYSub(pExpr) ); |
| 107036 | assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn |
| 107037 | || pParse->nErr ); |
| @@ -139569,11 +139577,11 @@ | |
| 139569 | ** position in the parent that NULL-able due to an OUTER JOIN. Either the |
| 139570 | ** target slot in the parent is the right operand of a LEFT JOIN, or one of |
| 139571 | ** the left operands of a RIGHT JOIN. In either case, we need to potentially |
| 139572 | ** bypass the substituted expression with OP_IfNullRow. |
| 139573 | ** |
| 139574 | ** Suppose the original expression integer constant. Even though the table |
| 139575 | ** has the nullRow flag set, because the expression is an integer constant, |
| 139576 | ** it will not be NULLed out. So instead, we insert an OP_IfNullRow opcode |
| 139577 | ** that checks to see if the nullRow flag is set on the table. If the nullRow |
| 139578 | ** flag is set, then the value in the register is set to NULL and the original |
| 139579 | ** expression is bypassed. If the nullRow flag is not set, then the original |
| @@ -140026,23 +140034,17 @@ | |
| 140026 | ** |
| 140027 | ** (26) The subquery may not be the right operand of a RIGHT JOIN. |
| 140028 | ** See also (3) for restrictions on LEFT JOIN. |
| 140029 | ** |
| 140030 | ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 140031 | ** is the first element of the parent query. This must be the |
| 140032 | ** the case if: |
| 140033 | ** (27a) the subquery is not compound query, and |
| 140034 | ** (27b) the subquery is a compound query and the RIGHT JOIN occurs |
| 140035 | ** in any arm of the compound query. (See also (17g).) |
| 140036 | ** |
| 140037 | ** (28) The subquery is not a MATERIALIZED CTE. |
| 140038 | ** |
| 140039 | ** (29) Either the subquery is not the right-hand operand of a join with an |
| 140040 | ** ON or USING clause nor the right-hand operand of a NATURAL JOIN, or |
| 140041 | ** the right-most table within the FROM clause of the subquery |
| 140042 | ** is not part of an outer join. |
| 140043 | ** |
| 140044 | ** |
| 140045 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 140046 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 140047 | ** uses aggregates. |
| 140048 | ** |
| @@ -140142,57 +140144,19 @@ | |
| 140142 | ){ |
| 140143 | return 0; |
| 140144 | } |
| 140145 | isOuterJoin = 1; |
| 140146 | } |
| 140147 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 140148 | else if( iFrom>0 && !isAgg ){ |
| 140149 | /* Setting isOuterJoin to -1 causes OP_IfNullRow opcodes to be generated for |
| 140150 | ** every reference to any result column from subquery in a join, even |
| 140151 | ** though they are not necessary. This will stress-test the OP_IfNullRow |
| 140152 | ** opcode. */ |
| 140153 | isOuterJoin = -1; |
| 140154 | } |
| 140155 | #endif |
| 140156 | |
| 140157 | assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 140158 | if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 140159 | return 0; /* Restriction (27a) */ |
| 140160 | } |
| 140161 | if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ |
| 140162 | return 0; /* (28) */ |
| 140163 | } |
| 140164 | |
| 140165 | /* Restriction (29): |
| 140166 | ** |
| 140167 | ** We do not want two constraints on the same term of the flattened |
| 140168 | ** query where one constraint has EP_InnerON and the other is EP_OuterON. |
| 140169 | ** To prevent this, one or the other of the following conditions must be |
| 140170 | ** false: |
| 140171 | ** |
| 140172 | ** (29a) The right-most entry in the FROM clause of the subquery |
| 140173 | ** must not be part of an outer join. |
| 140174 | ** |
| 140175 | ** (29b) The subquery itself must not be the right operand of a |
| 140176 | ** NATURAL join or a join that as an ON or USING clause. |
| 140177 | ** |
| 140178 | ** These conditions are sufficient to keep an EP_OuterON from being |
| 140179 | ** flattened into an EP_InnerON. Restrictions (3a) and (27a) prevent |
| 140180 | ** an EP_InnerON from being flattened into an EP_OuterON. |
| 140181 | */ |
| 140182 | if( pSubSrc->nSrc>=2 |
| 140183 | && (pSubSrc->a[pSubSrc->nSrc-1].fg.jointype & JT_OUTER)!=0 |
| 140184 | ){ |
| 140185 | if( (pSubitem->fg.jointype & JT_NATURAL)!=0 |
| 140186 | || pSubitem->fg.isUsing |
| 140187 | || NEVER(pSubitem->u3.pOn!=0) /* ON clause already shifted into WHERE */ |
| 140188 | || pSubitem->fg.isOn |
| 140189 | ){ |
| 140190 | return 0; |
| 140191 | } |
| 140192 | } |
| 140193 | |
| 140194 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 140195 | ** use only the UNION ALL operator. And none of the simple select queries |
| 140196 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 140197 | ** queries. |
| 140198 | */ |
| @@ -144296,10 +144260,27 @@ | |
| 144296 | ** build the sqlite_schema entry |
| 144297 | */ |
| 144298 | if( !db->init.busy ){ |
| 144299 | Vdbe *v; |
| 144300 | char *z; |
| 144301 | |
| 144302 | /* Make an entry in the sqlite_schema table */ |
| 144303 | v = sqlite3GetVdbe(pParse); |
| 144304 | if( v==0 ) goto triggerfinish_cleanup; |
| 144305 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| @@ -155004,10 +154985,47 @@ | |
| 155004 | } |
| 155005 | #else |
| 155006 | #define whereTraceIndexInfoInputs(A) |
| 155007 | #define whereTraceIndexInfoOutputs(A) |
| 155008 | #endif |
| 155009 | |
| 155010 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155011 | /* |
| 155012 | ** Return TRUE if the WHERE clause term pTerm is of a form where it |
| 155013 | ** could be used with an index to access pSrc, assuming an appropriate |
| @@ -155020,20 +155038,14 @@ | |
| 155020 | ){ |
| 155021 | char aff; |
| 155022 | if( pTerm->leftCursor!=pSrc->iCursor ) return 0; |
| 155023 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; |
| 155024 | assert( (pSrc->fg.jointype & JT_RIGHT)==0 ); |
| 155025 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ){ |
| 155026 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); |
| 155027 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); |
| 155028 | testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ) |
| 155029 | testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); |
| 155030 | if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) |
| 155031 | || pTerm->pExpr->w.iJoin != pSrc->iCursor |
| 155032 | ){ |
| 155033 | return 0; /* See tag-20191211-001 */ |
| 155034 | } |
| 155035 | } |
| 155036 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 155037 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 155038 | if( pTerm->u.x.leftColumn<0 ) return 0; |
| 155039 | aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; |
| @@ -155441,26 +155453,14 @@ | |
| 155441 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 155442 | |
| 155443 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 155444 | assert( pTerm->u.x.leftColumn>=XN_ROWID ); |
| 155445 | assert( pTerm->u.x.leftColumn<pTab->nCol ); |
| 155446 | |
| 155447 | /* tag-20191211-002: WHERE-clause constraints are not useful to the |
| 155448 | ** right-hand table of a LEFT JOIN nor to the either table of a |
| 155449 | ** RIGHT JOIN. See tag-20191211-001 for the |
| 155450 | ** equivalent restriction for ordinary tables. */ |
| 155451 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ){ |
| 155452 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); |
| 155453 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_RIGHT ); |
| 155454 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); |
| 155455 | testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ); |
| 155456 | testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); |
| 155457 | if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) |
| 155458 | || pTerm->pExpr->w.iJoin != pSrc->iCursor |
| 155459 | ){ |
| 155460 | continue; |
| 155461 | } |
| 155462 | } |
| 155463 | nTerm++; |
| 155464 | pTerm->wtFlags |= TERM_OK; |
| 155465 | } |
| 155466 | |
| @@ -157114,36 +157114,15 @@ | |
| 157114 | |
| 157115 | /* Do not allow the upper bound of a LIKE optimization range constraint |
| 157116 | ** to mix with a lower range bound from some other source */ |
| 157117 | if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 157118 | |
| 157119 | /* tag-20191211-001: Do not allow constraints from the WHERE clause to |
| 157120 | ** be used by the right table of a LEFT JOIN nor by the left table of a |
| 157121 | ** RIGHT JOIN. Only constraints in the ON clause are allowed. |
| 157122 | ** See tag-20191211-002 for the vtab equivalent. |
| 157123 | ** |
| 157124 | ** 2022-06-06: See https://sqlite.org/forum/forumpost/206d99a16dd9212f |
| 157125 | ** for an example of a WHERE clause constraints that may not be used on |
| 157126 | ** the right table of a RIGHT JOIN because the constraint implies a |
| 157127 | ** not-NULL condition on the left table of the RIGHT JOIN. |
| 157128 | ** |
| 157129 | ** 2022-06-10: The same condition applies to termCanDriveIndex() above. |
| 157130 | ** https://sqlite.org/forum/forumpost/51e6959f61 |
| 157131 | */ |
| 157132 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ){ |
| 157133 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); |
| 157134 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_RIGHT ); |
| 157135 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); |
| 157136 | testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ) |
| 157137 | testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); |
| 157138 | if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) |
| 157139 | || pTerm->pExpr->w.iJoin != pSrc->iCursor |
| 157140 | ){ |
| 157141 | continue; |
| 157142 | } |
| 157143 | } |
| 157144 | |
| 157145 | if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){ |
| 157146 | pBuilder->bldFlags1 |= SQLITE_BLDF1_UNIQUE; |
| 157147 | }else{ |
| 157148 | pBuilder->bldFlags1 |= SQLITE_BLDF1_INDEXED; |
| 157149 | } |
| @@ -177299,11 +177278,11 @@ | |
| 177299 | Fts3SegReader **apSegment; /* Array of Fts3SegReader objects */ |
| 177300 | int nSegment; /* Size of apSegment array */ |
| 177301 | int nAdvance; /* How many seg-readers to advance */ |
| 177302 | Fts3SegFilter *pFilter; /* Pointer to filter object */ |
| 177303 | char *aBuffer; /* Buffer to merge doclists in */ |
| 177304 | int nBuffer; /* Allocated size of aBuffer[] in bytes */ |
| 177305 | |
| 177306 | int iColFilter; /* If >=0, filter for this column */ |
| 177307 | int bRestart; |
| 177308 | |
| 177309 | /* Used by fts3.c only. */ |
| @@ -179995,11 +179974,11 @@ | |
| 179995 | ** as a single-byte delta, whereas in the second it must be stored as a |
| 179996 | ** FTS3_VARINT_MAX byte varint. |
| 179997 | ** |
| 179998 | ** Similar padding is added in the fts3DoclistOrMerge() function. |
| 179999 | */ |
| 180000 | pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1); |
| 180001 | pTS->anOutput[0] = nDoclist; |
| 180002 | if( pTS->aaOutput[0] ){ |
| 180003 | memcpy(pTS->aaOutput[0], aDoclist, nDoclist); |
| 180004 | memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX); |
| 180005 | }else{ |
| @@ -181852,11 +181831,11 @@ | |
| 181852 | |
| 181853 | /* Check if the current entries really are a phrase match */ |
| 181854 | if( bEof==0 ){ |
| 181855 | int nList = 0; |
| 181856 | int nByte = a[p->nToken-1].nList; |
| 181857 | char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING); |
| 181858 | if( !aDoclist ) return SQLITE_NOMEM; |
| 181859 | memcpy(aDoclist, a[p->nToken-1].pList, nByte+1); |
| 181860 | memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING); |
| 181861 | |
| 181862 | for(i=0; i<(p->nToken-1); i++){ |
| @@ -186088,11 +186067,11 @@ | |
| 186088 | if( c->iOffset>iStartOffset ){ |
| 186089 | int n = c->iOffset-iStartOffset; |
| 186090 | if( n>c->nAllocated ){ |
| 186091 | char *pNew; |
| 186092 | c->nAllocated = n+20; |
| 186093 | pNew = sqlite3_realloc(c->zToken, c->nAllocated); |
| 186094 | if( !pNew ) return SQLITE_NOMEM; |
| 186095 | c->zToken = pNew; |
| 186096 | } |
| 186097 | porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes); |
| 186098 | *pzToken = c->zToken; |
| @@ -186840,11 +186819,11 @@ | |
| 186840 | if( c->iOffset>iStartOffset ){ |
| 186841 | int i, n = c->iOffset-iStartOffset; |
| 186842 | if( n>c->nTokenAllocated ){ |
| 186843 | char *pNew; |
| 186844 | c->nTokenAllocated = n+20; |
| 186845 | pNew = sqlite3_realloc(c->pToken, c->nTokenAllocated); |
| 186846 | if( !pNew ) return SQLITE_NOMEM; |
| 186847 | c->pToken = pNew; |
| 186848 | } |
| 186849 | for(i=0; i<n; i++){ |
| 186850 | /* TODO(shess) This needs expansion to handle UTF-8 |
| @@ -188002,27 +187981,27 @@ | |
| 188002 | ){ |
| 188003 | PendingList *p = *pp; |
| 188004 | |
| 188005 | /* Allocate or grow the PendingList as required. */ |
| 188006 | if( !p ){ |
| 188007 | p = sqlite3_malloc(sizeof(*p) + 100); |
| 188008 | if( !p ){ |
| 188009 | return SQLITE_NOMEM; |
| 188010 | } |
| 188011 | p->nSpace = 100; |
| 188012 | p->aData = (char *)&p[1]; |
| 188013 | p->nData = 0; |
| 188014 | } |
| 188015 | else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){ |
| 188016 | int nNew = p->nSpace * 2; |
| 188017 | p = sqlite3_realloc(p, sizeof(*p) + nNew); |
| 188018 | if( !p ){ |
| 188019 | sqlite3_free(*pp); |
| 188020 | *pp = 0; |
| 188021 | return SQLITE_NOMEM; |
| 188022 | } |
| 188023 | p->nSpace = nNew; |
| 188024 | p->aData = (char *)&p[1]; |
| 188025 | } |
| 188026 | |
| 188027 | /* Append the new serialized varint to the end of the list. */ |
| 188028 | p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i); |
| @@ -188575,11 +188554,11 @@ | |
| 188575 | |
| 188576 | if( rc==SQLITE_OK ){ |
| 188577 | int nByte = sqlite3_blob_bytes(p->pSegments); |
| 188578 | *pnBlob = nByte; |
| 188579 | if( paBlob ){ |
| 188580 | char *aByte = sqlite3_malloc(nByte + FTS3_NODE_PADDING); |
| 188581 | if( !aByte ){ |
| 188582 | rc = SQLITE_NOMEM; |
| 188583 | }else{ |
| 188584 | if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){ |
| 188585 | nByte = FTS3_NODE_CHUNKSIZE; |
| @@ -188692,19 +188671,19 @@ | |
| 188692 | int nCopy = pList->nData+1; |
| 188693 | |
| 188694 | int nTerm = fts3HashKeysize(pElem); |
| 188695 | if( (nTerm+1)>pReader->nTermAlloc ){ |
| 188696 | sqlite3_free(pReader->zTerm); |
| 188697 | pReader->zTerm = (char*)sqlite3_malloc((nTerm+1)*2); |
| 188698 | if( !pReader->zTerm ) return SQLITE_NOMEM; |
| 188699 | pReader->nTermAlloc = (nTerm+1)*2; |
| 188700 | } |
| 188701 | memcpy(pReader->zTerm, fts3HashKey(pElem), nTerm); |
| 188702 | pReader->zTerm[nTerm] = '\0'; |
| 188703 | pReader->nTerm = nTerm; |
| 188704 | |
| 188705 | aCopy = (char*)sqlite3_malloc(nCopy); |
| 188706 | if( !aCopy ) return SQLITE_NOMEM; |
| 188707 | memcpy(aCopy, pList->aData, nCopy); |
| 188708 | pReader->nNode = pReader->nDoclist = nCopy; |
| 188709 | pReader->aNode = pReader->aDoclist = aCopy; |
| 188710 | pReader->ppNextElem++; |
| @@ -188987,11 +188966,11 @@ | |
| 188987 | if( iStartLeaf==0 ){ |
| 188988 | if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB; |
| 188989 | nExtra = nRoot + FTS3_NODE_PADDING; |
| 188990 | } |
| 188991 | |
| 188992 | pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra); |
| 188993 | if( !pReader ){ |
| 188994 | return SQLITE_NOMEM; |
| 188995 | } |
| 188996 | memset(pReader, 0, sizeof(Fts3SegReader)); |
| 188997 | pReader->iIdx = iAge; |
| @@ -189079,11 +189058,11 @@ | |
| 189079 | int nKey = fts3HashKeysize(pE); |
| 189080 | if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){ |
| 189081 | if( nElem==nAlloc ){ |
| 189082 | Fts3HashElem **aElem2; |
| 189083 | nAlloc += 16; |
| 189084 | aElem2 = (Fts3HashElem **)sqlite3_realloc( |
| 189085 | aElem, nAlloc*sizeof(Fts3HashElem *) |
| 189086 | ); |
| 189087 | if( !aElem2 ){ |
| 189088 | rc = SQLITE_NOMEM; |
| 189089 | nElem = 0; |
| @@ -189413,11 +189392,11 @@ | |
| 189413 | ** p->nNodeSize bytes, but since this scenario only comes about when |
| 189414 | ** the database contain two terms that share a prefix of almost 2KB, |
| 189415 | ** this is not expected to be a serious problem. |
| 189416 | */ |
| 189417 | assert( pTree->aData==(char *)&pTree[1] ); |
| 189418 | pTree->aData = (char *)sqlite3_malloc(nReq); |
| 189419 | if( !pTree->aData ){ |
| 189420 | return SQLITE_NOMEM; |
| 189421 | } |
| 189422 | } |
| 189423 | |
| @@ -189431,11 +189410,11 @@ | |
| 189431 | pTree->nData = nData + nSuffix; |
| 189432 | pTree->nEntry++; |
| 189433 | |
| 189434 | if( isCopyTerm ){ |
| 189435 | if( pTree->nMalloc<nTerm ){ |
| 189436 | char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2); |
| 189437 | if( !zNew ){ |
| 189438 | return SQLITE_NOMEM; |
| 189439 | } |
| 189440 | pTree->nMalloc = nTerm*2; |
| 189441 | pTree->zMalloc = zNew; |
| @@ -189457,11 +189436,11 @@ | |
| 189457 | ** |
| 189458 | ** Otherwise, the term is not added to the new node, it is left empty for |
| 189459 | ** now. Instead, the term is inserted into the parent of pTree. If pTree |
| 189460 | ** has no parent, one is created here. |
| 189461 | */ |
| 189462 | pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize); |
| 189463 | if( !pNew ){ |
| 189464 | return SQLITE_NOMEM; |
| 189465 | } |
| 189466 | memset(pNew, 0, sizeof(SegmentNode)); |
| 189467 | pNew->nData = 1 + FTS3_VARINT_MAX; |
| @@ -189595,26 +189574,26 @@ | |
| 189595 | const char *aDoclist, /* Pointer to buffer containing doclist */ |
| 189596 | int nDoclist /* Size of doclist in bytes */ |
| 189597 | ){ |
| 189598 | int nPrefix; /* Size of term prefix in bytes */ |
| 189599 | int nSuffix; /* Size of term suffix in bytes */ |
| 189600 | int nReq; /* Number of bytes required on leaf page */ |
| 189601 | int nData; |
| 189602 | SegmentWriter *pWriter = *ppWriter; |
| 189603 | |
| 189604 | if( !pWriter ){ |
| 189605 | int rc; |
| 189606 | sqlite3_stmt *pStmt; |
| 189607 | |
| 189608 | /* Allocate the SegmentWriter structure */ |
| 189609 | pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter)); |
| 189610 | if( !pWriter ) return SQLITE_NOMEM; |
| 189611 | memset(pWriter, 0, sizeof(SegmentWriter)); |
| 189612 | *ppWriter = pWriter; |
| 189613 | |
| 189614 | /* Allocate a buffer in which to accumulate data */ |
| 189615 | pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize); |
| 189616 | if( !pWriter->aData ) return SQLITE_NOMEM; |
| 189617 | pWriter->nSize = p->nNodeSize; |
| 189618 | |
| 189619 | /* Find the next free blockid in the %_segments table */ |
| 189620 | rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0); |
| @@ -189685,11 +189664,11 @@ | |
| 189685 | |
| 189686 | /* If the buffer currently allocated is too small for this entry, realloc |
| 189687 | ** the buffer to make it large enough. |
| 189688 | */ |
| 189689 | if( nReq>pWriter->nSize ){ |
| 189690 | char *aNew = sqlite3_realloc(pWriter->aData, nReq); |
| 189691 | if( !aNew ) return SQLITE_NOMEM; |
| 189692 | pWriter->aData = aNew; |
| 189693 | pWriter->nSize = nReq; |
| 189694 | } |
| 189695 | assert( nData+nReq<=pWriter->nSize ); |
| @@ -189710,11 +189689,11 @@ | |
| 189710 | ** zTerm is transient, so take a copy of the term data. Otherwise, just |
| 189711 | ** store a copy of the pointer. |
| 189712 | */ |
| 189713 | if( isCopyTerm ){ |
| 189714 | if( nTerm>pWriter->nMalloc ){ |
| 189715 | char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2); |
| 189716 | if( !zNew ){ |
| 189717 | return SQLITE_NOMEM; |
| 189718 | } |
| 189719 | pWriter->nMalloc = nTerm*2; |
| 189720 | pWriter->zMalloc = zNew; |
| @@ -190018,16 +189997,16 @@ | |
| 190018 | ** trying to resize the buffer, return SQLITE_NOMEM. |
| 190019 | */ |
| 190020 | static int fts3MsrBufferData( |
| 190021 | Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */ |
| 190022 | char *pList, |
| 190023 | int nList |
| 190024 | ){ |
| 190025 | if( nList>pMsr->nBuffer ){ |
| 190026 | char *pNew; |
| 190027 | pMsr->nBuffer = nList*2; |
| 190028 | pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer); |
| 190029 | if( !pNew ) return SQLITE_NOMEM; |
| 190030 | pMsr->aBuffer = pNew; |
| 190031 | } |
| 190032 | |
| 190033 | assert( nList>0 ); |
| @@ -190079,11 +190058,11 @@ | |
| 190079 | } |
| 190080 | if( rc!=SQLITE_OK ) return rc; |
| 190081 | fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp); |
| 190082 | |
| 190083 | if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){ |
| 190084 | rc = fts3MsrBufferData(pMsr, pList, nList+1); |
| 190085 | if( rc!=SQLITE_OK ) return rc; |
| 190086 | assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); |
| 190087 | pList = pMsr->aBuffer; |
| 190088 | } |
| 190089 | |
| @@ -190216,15 +190195,15 @@ | |
| 190216 | } |
| 190217 | |
| 190218 | return SQLITE_OK; |
| 190219 | } |
| 190220 | |
| 190221 | static int fts3GrowSegReaderBuffer(Fts3MultiSegReader *pCsr, int nReq){ |
| 190222 | if( nReq>pCsr->nBuffer ){ |
| 190223 | char *aNew; |
| 190224 | pCsr->nBuffer = nReq*2; |
| 190225 | aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer); |
| 190226 | if( !aNew ){ |
| 190227 | return SQLITE_NOMEM; |
| 190228 | } |
| 190229 | pCsr->aBuffer = aNew; |
| 190230 | } |
| @@ -190311,11 +190290,12 @@ | |
| 190311 | && !isFirst |
| 190312 | && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) |
| 190313 | ){ |
| 190314 | pCsr->nDoclist = apSegment[0]->nDoclist; |
| 190315 | if( fts3SegReaderIsPending(apSegment[0]) ){ |
| 190316 | rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist); |
| 190317 | pCsr->aDoclist = pCsr->aBuffer; |
| 190318 | }else{ |
| 190319 | pCsr->aDoclist = apSegment[0]->aDoclist; |
| 190320 | } |
| 190321 | if( rc==SQLITE_OK ) rc = SQLITE_ROW; |
| @@ -190364,11 +190344,12 @@ | |
| 190364 | iDelta = (i64)((u64)iDocid - (u64)iPrev); |
| 190365 | } |
| 190366 | |
| 190367 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 190368 | |
| 190369 | rc = fts3GrowSegReaderBuffer(pCsr, nByte+nDoclist+FTS3_NODE_PADDING); |
| 190370 | if( rc ) return rc; |
| 190371 | |
| 190372 | if( isFirst ){ |
| 190373 | char *a = &pCsr->aBuffer[nDoclist]; |
| 190374 | int nWrite; |
| @@ -190390,11 +190371,11 @@ | |
| 190390 | } |
| 190391 | |
| 190392 | fts3SegReaderSort(apSegment, nMerge, j, xCmp); |
| 190393 | } |
| 190394 | if( nDoclist>0 ){ |
| 190395 | rc = fts3GrowSegReaderBuffer(pCsr, nDoclist+FTS3_NODE_PADDING); |
| 190396 | if( rc ) return rc; |
| 190397 | memset(&pCsr->aBuffer[nDoclist], 0, FTS3_NODE_PADDING); |
| 190398 | pCsr->aDoclist = pCsr->aBuffer; |
| 190399 | pCsr->nDoclist = nDoclist; |
| 190400 | rc = SQLITE_ROW; |
| @@ -191103,11 +191084,11 @@ | |
| 191103 | ** to reflect the new size of the pBlob->a[] buffer. |
| 191104 | */ |
| 191105 | static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){ |
| 191106 | if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){ |
| 191107 | int nAlloc = nMin; |
| 191108 | char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc); |
| 191109 | if( a ){ |
| 191110 | pBlob->nAlloc = nAlloc; |
| 191111 | pBlob->a = a; |
| 191112 | }else{ |
| 191113 | *pRc = SQLITE_NOMEM; |
| @@ -191900,11 +191881,11 @@ | |
| 191900 | sqlite3_bind_int64(pSelect, 1, iAbsLevel); |
| 191901 | while( SQLITE_ROW==sqlite3_step(pSelect) ){ |
| 191902 | if( nIdx>=nAlloc ){ |
| 191903 | int *aNew; |
| 191904 | nAlloc += 16; |
| 191905 | aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int)); |
| 191906 | if( !aNew ){ |
| 191907 | rc = SQLITE_NOMEM; |
| 191908 | break; |
| 191909 | } |
| 191910 | aIdx = aNew; |
| @@ -192274,11 +192255,11 @@ | |
| 192274 | Blob hint = {0, 0, 0}; /* Hint read from %_stat table */ |
| 192275 | int bDirtyHint = 0; /* True if blob 'hint' has been modified */ |
| 192276 | |
| 192277 | /* Allocate space for the cursor, filter and writer objects */ |
| 192278 | const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter); |
| 192279 | pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc); |
| 192280 | if( !pWriter ) return SQLITE_NOMEM; |
| 192281 | pFilter = (Fts3SegFilter *)&pWriter[1]; |
| 192282 | pCsr = (Fts3MultiSegReader *)&pFilter[1]; |
| 192283 | |
| 192284 | rc = fts3IncrmergeHintLoad(p, &hint); |
| @@ -192910,11 +192891,11 @@ | |
| 192910 | |
| 192911 | if( p->pList==0 ){ |
| 192912 | return SQLITE_OK; |
| 192913 | } |
| 192914 | |
| 192915 | pRet = (char *)sqlite3_malloc(p->pList->nData); |
| 192916 | if( !pRet ) return SQLITE_NOMEM; |
| 192917 | |
| 192918 | nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy); |
| 192919 | *pnData = p->pList->nData - nSkip; |
| 192920 | *ppData = pRet; |
| @@ -192930,11 +192911,11 @@ | |
| 192930 | Fts3Cursor *pCsr, /* Fts3 table cursor */ |
| 192931 | Fts3PhraseToken *pToken, /* Token to defer */ |
| 192932 | int iCol /* Column that token must appear in (or -1) */ |
| 192933 | ){ |
| 192934 | Fts3DeferredToken *pDeferred; |
| 192935 | pDeferred = sqlite3_malloc(sizeof(*pDeferred)); |
| 192936 | if( !pDeferred ){ |
| 192937 | return SQLITE_NOMEM; |
| 192938 | } |
| 192939 | memset(pDeferred, 0, sizeof(*pDeferred)); |
| 192940 | pDeferred->pToken = pToken; |
| @@ -205112,12 +205093,13 @@ | |
| 205112 | } |
| 205113 | pExpr = uregex_open(zPattern, -1, 0, 0, &status); |
| 205114 | |
| 205115 | if( U_SUCCESS(status) ){ |
| 205116 | sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete); |
| 205117 | }else{ |
| 205118 | assert(!pExpr); |
| 205119 | icuFunctionError(p, "uregex_open", status); |
| 205120 | return; |
| 205121 | } |
| 205122 | } |
| 205123 | |
| @@ -237002,11 +236984,11 @@ | |
| 237002 | int nArg, /* Number of args */ |
| 237003 | sqlite3_value **apUnused /* Function arguments */ |
| 237004 | ){ |
| 237005 | assert( nArg==0 ); |
| 237006 | UNUSED_PARAM2(nArg, apUnused); |
| 237007 | sqlite3_result_text(pCtx, "fts5: 2022-09-02 21:19:24 da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c", -1, SQLITE_TRANSIENT); |
| 237008 | } |
| 237009 | |
| 237010 | /* |
| 237011 | ** Return true if zName is the extension on one of the shadow tables used |
| 237012 | ** by this module. |
| 237013 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -452,11 +452,11 @@ | |
| 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | */ |
| 455 | #define SQLITE_VERSION "3.40.0" |
| 456 | #define SQLITE_VERSION_NUMBER 3040000 |
| 457 | #define SQLITE_SOURCE_ID "2022-09-28 19:14:01 f25cf63471cbed1edb27591e57fead62550d4046dbdcb61312288f0f6f24c646" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -29076,22 +29076,38 @@ | |
| 29076 | sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 29077 | } |
| 29078 | *pp = p; |
| 29079 | } |
| 29080 | |
| 29081 | /* |
| 29082 | ** Maximum size of any single memory allocation. |
| 29083 | ** |
| 29084 | ** This is not a limit on the total amount of memory used. This is |
| 29085 | ** a limit on the size parameter to sqlite3_malloc() and sqlite3_realloc(). |
| 29086 | ** |
| 29087 | ** The upper bound is slightly less than 2GiB: 0x7ffffeff == 2,147,483,391 |
| 29088 | ** This provides a 256-byte safety margin for defense against 32-bit |
| 29089 | ** signed integer overflow bugs when computing memory allocation sizes. |
| 29090 | ** Parnoid applications might want to reduce the maximum allocation size |
| 29091 | ** further for an even larger safety margin. 0x3fffffff or 0x0fffffff |
| 29092 | ** or even smaller would be reasonable upper bounds on the size of a memory |
| 29093 | ** allocations for most applications. |
| 29094 | */ |
| 29095 | #ifndef SQLITE_MAX_ALLOCATION_SIZE |
| 29096 | # define SQLITE_MAX_ALLOCATION_SIZE 2147483391 |
| 29097 | #endif |
| 29098 | #if SQLITE_MAX_ALLOCATION_SIZE>2147483391 |
| 29099 | # error Maximum size for SQLITE_MAX_ALLOCATION_SIZE is 2147483391 |
| 29100 | #endif |
| 29101 | |
| 29102 | /* |
| 29103 | ** Allocate memory. This routine is like sqlite3_malloc() except that it |
| 29104 | ** assumes the memory subsystem has already been initialized. |
| 29105 | */ |
| 29106 | SQLITE_PRIVATE void *sqlite3Malloc(u64 n){ |
| 29107 | void *p; |
| 29108 | if( n==0 || n>SQLITE_MAX_ALLOCATION_SIZE ){ |
| 29109 | p = 0; |
| 29110 | }else if( sqlite3GlobalConfig.bMemstat ){ |
| 29111 | sqlite3_mutex_enter(mem0.mutex); |
| 29112 | mallocWithAlarm((int)n, &p); |
| 29113 | sqlite3_mutex_leave(mem0.mutex); |
| @@ -45571,12 +45587,13 @@ | |
| 45587 | SQLITE_API int sqlite3_win32_set_directory8( |
| 45588 | unsigned long type, /* Identifier for directory being set or reset */ |
| 45589 | const char *zValue /* New value for directory being set or reset */ |
| 45590 | ){ |
| 45591 | char **ppDirectory = 0; |
| 45592 | int rc; |
| 45593 | #ifndef SQLITE_OMIT_AUTOINIT |
| 45594 | rc = sqlite3_initialize(); |
| 45595 | if( rc ) return rc; |
| 45596 | #endif |
| 45597 | sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); |
| 45598 | if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){ |
| 45599 | ppDirectory = &sqlite3_data_directory; |
| @@ -49415,11 +49432,12 @@ | |
| 49432 | const char *zRelative, /* Possibly relative input path */ |
| 49433 | int nFull, /* Size of output buffer in bytes */ |
| 49434 | char *zFull /* Output buffer */ |
| 49435 | ){ |
| 49436 | int rc; |
| 49437 | MUTEX_LOGIC( sqlite3_mutex *pMutex; ) |
| 49438 | MUTEX_LOGIC( pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); ) |
| 49439 | sqlite3_mutex_enter(pMutex); |
| 49440 | rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull); |
| 49441 | sqlite3_mutex_leave(pMutex); |
| 49442 | return rc; |
| 49443 | } |
| @@ -51798,18 +51816,18 @@ | |
| 51816 | assert( p->nRef>0 ); |
| 51817 | assert( newPgno>0 ); |
| 51818 | assert( sqlite3PcachePageSanity(p) ); |
| 51819 | pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); |
| 51820 | pOther = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, newPgno, 0); |
| 51821 | if( pOther ){ |
| 51822 | PgHdr *pXPage = (PgHdr*)pOther->pExtra; |
| 51823 | assert( pXPage->nRef==0 ); |
| 51824 | pXPage->nRef++; |
| 51825 | pCache->nRefSum++; |
| 51826 | sqlite3PcacheDrop(pXPage); |
| 51827 | } |
| 51828 | sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); |
| 51829 | p->pgno = newPgno; |
| 51830 | if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ |
| 51831 | pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); |
| 51832 | assert( sqlite3PcachePageSanity(p) ); |
| 51833 | } |
| @@ -53202,27 +53220,12 @@ | |
| 53220 | while( (*pp)!=pPage ){ |
| 53221 | pp = &(*pp)->pNext; |
| 53222 | } |
| 53223 | *pp = pPage->pNext; |
| 53224 | |
| 53225 | assert( pcache1FetchNoMutex(p, iNew, 0)==0 ); /* iNew not in cache */ |
| 53226 | hNew = iNew%pCache->nHash; |
| 53227 | pPage->iKey = iNew; |
| 53228 | pPage->pNext = pCache->apHash[hNew]; |
| 53229 | pCache->apHash[hNew] = pPage; |
| 53230 | if( iNew>pCache->iMaxKey ){ |
| 53231 | pCache->iMaxKey = iNew; |
| @@ -68523,11 +68526,11 @@ | |
| 68526 | if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage); |
| 68527 | sz2 = get2byte(&data[iFree2+2]); |
| 68528 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); |
| 68529 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 68530 | sz += sz2; |
| 68531 | }else if( iFree+sz>usableSize ){ |
| 68532 | return SQLITE_CORRUPT_PAGE(pPage); |
| 68533 | } |
| 68534 | |
| 68535 | cbrk = top+sz; |
| 68536 | assert( cbrk+(iFree-top) <= usableSize ); |
| @@ -93400,16 +93403,20 @@ | |
| 93403 | } |
| 93404 | |
| 93405 | /* Opcode: IfNotOpen P1 P2 * * * |
| 93406 | ** Synopsis: if( !csr[P1] ) goto P2 |
| 93407 | ** |
| 93408 | ** If cursor P1 is not open or if P1 is set to a NULL row using the |
| 93409 | ** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through. |
| 93410 | */ |
| 93411 | case OP_IfNotOpen: { /* jump */ |
| 93412 | VdbeCursor *pCur; |
| 93413 | |
| 93414 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 93415 | pCur = p->apCsr[pOp->p1]; |
| 93416 | VdbeBranchTaken(pCur==0 || pCur->nullRow, 2); |
| 93417 | if( pCur==0 || pCur->nullRow ){ |
| 93418 | goto jump_to_p2_and_check_for_interrupt; |
| 93419 | } |
| 93420 | break; |
| 93421 | } |
| 93422 | |
| @@ -107028,10 +107035,11 @@ | |
| 107035 | } |
| 107036 | if( pKeyInfo ){ |
| 107037 | sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO); |
| 107038 | } |
| 107039 | if( addrOnce ){ |
| 107040 | sqlite3VdbeAddOp1(v, OP_NullRow, iTab); |
| 107041 | sqlite3VdbeJumpHere(v, addrOnce); |
| 107042 | /* Subroutine return */ |
| 107043 | assert( ExprUseYSub(pExpr) ); |
| 107044 | assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn |
| 107045 | || pParse->nErr ); |
| @@ -139569,11 +139577,11 @@ | |
| 139577 | ** position in the parent that NULL-able due to an OUTER JOIN. Either the |
| 139578 | ** target slot in the parent is the right operand of a LEFT JOIN, or one of |
| 139579 | ** the left operands of a RIGHT JOIN. In either case, we need to potentially |
| 139580 | ** bypass the substituted expression with OP_IfNullRow. |
| 139581 | ** |
| 139582 | ** Suppose the original expression is an integer constant. Even though the table |
| 139583 | ** has the nullRow flag set, because the expression is an integer constant, |
| 139584 | ** it will not be NULLed out. So instead, we insert an OP_IfNullRow opcode |
| 139585 | ** that checks to see if the nullRow flag is set on the table. If the nullRow |
| 139586 | ** flag is set, then the value in the register is set to NULL and the original |
| 139587 | ** expression is bypassed. If the nullRow flag is not set, then the original |
| @@ -140026,23 +140034,17 @@ | |
| 140034 | ** |
| 140035 | ** (26) The subquery may not be the right operand of a RIGHT JOIN. |
| 140036 | ** See also (3) for restrictions on LEFT JOIN. |
| 140037 | ** |
| 140038 | ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 140039 | ** is the first element of the parent query. Two subcases: |
| 140040 | ** (27a) the subquery is not a compound query. |
| 140041 | ** (27b) the subquery is a compound query and the RIGHT JOIN occurs |
| 140042 | ** in any arm of the compound query. (See also (17g).) |
| 140043 | ** |
| 140044 | ** (28) The subquery is not a MATERIALIZED CTE. |
| 140045 | ** |
| 140046 | ** |
| 140047 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 140048 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 140049 | ** uses aggregates. |
| 140050 | ** |
| @@ -140142,57 +140144,19 @@ | |
| 140144 | ){ |
| 140145 | return 0; |
| 140146 | } |
| 140147 | isOuterJoin = 1; |
| 140148 | } |
| 140149 | |
| 140150 | assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 140151 | if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 140152 | return 0; /* Restriction (27a) */ |
| 140153 | } |
| 140154 | if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ |
| 140155 | return 0; /* (28) */ |
| 140156 | } |
| 140157 | |
| 140158 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 140159 | ** use only the UNION ALL operator. And none of the simple select queries |
| 140160 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 140161 | ** queries. |
| 140162 | */ |
| @@ -144296,10 +144260,27 @@ | |
| 144260 | ** build the sqlite_schema entry |
| 144261 | */ |
| 144262 | if( !db->init.busy ){ |
| 144263 | Vdbe *v; |
| 144264 | char *z; |
| 144265 | |
| 144266 | /* If this is a new CREATE TABLE statement, and if shadow tables |
| 144267 | ** are read-only, and the trigger makes a change to a shadow table, |
| 144268 | ** then raise an error - do not allow the trigger to be created. */ |
| 144269 | if( sqlite3ReadOnlyShadowTables(db) ){ |
| 144270 | TriggerStep *pStep; |
| 144271 | for(pStep=pTrig->step_list; pStep; pStep=pStep->pNext){ |
| 144272 | if( pStep->zTarget!=0 |
| 144273 | && sqlite3ShadowTableName(db, pStep->zTarget) |
| 144274 | ){ |
| 144275 | sqlite3ErrorMsg(pParse, |
| 144276 | "trigger \"%s\" may not write to shadow table \"%s\"", |
| 144277 | pTrig->zName, pStep->zTarget); |
| 144278 | goto triggerfinish_cleanup; |
| 144279 | } |
| 144280 | } |
| 144281 | } |
| 144282 | |
| 144283 | /* Make an entry in the sqlite_schema table */ |
| 144284 | v = sqlite3GetVdbe(pParse); |
| 144285 | if( v==0 ) goto triggerfinish_cleanup; |
| 144286 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| @@ -155004,10 +154985,47 @@ | |
| 154985 | } |
| 154986 | #else |
| 154987 | #define whereTraceIndexInfoInputs(A) |
| 154988 | #define whereTraceIndexInfoOutputs(A) |
| 154989 | #endif |
| 154990 | |
| 154991 | /* |
| 154992 | ** We know that pSrc is an operand of an outer join. Return true if |
| 154993 | ** pTerm is a constraint that is compatible with that join. |
| 154994 | ** |
| 154995 | ** pTerm must be EP_OuterON if pSrc is the right operand of an |
| 154996 | ** outer join. pTerm can be either EP_OuterON or EP_InnerON if pSrc |
| 154997 | ** is the left operand of a RIGHT join. |
| 154998 | ** |
| 154999 | ** See https://sqlite.org/forum/forumpost/206d99a16dd9212f |
| 155000 | ** for an example of a WHERE clause constraints that may not be used on |
| 155001 | ** the right table of a RIGHT JOIN because the constraint implies a |
| 155002 | ** not-NULL condition on the left table of the RIGHT JOIN. |
| 155003 | */ |
| 155004 | static int constraintCompatibleWithOuterJoin( |
| 155005 | const WhereTerm *pTerm, /* WHERE clause term to check */ |
| 155006 | const SrcItem *pSrc /* Table we are trying to access */ |
| 155007 | ){ |
| 155008 | assert( (pSrc->fg.jointype&(JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 ); /* By caller */ |
| 155009 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LEFT ); |
| 155010 | testcase( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))==JT_LTORJ ); |
| 155011 | testcase( ExprHasProperty(pTerm->pExpr, EP_OuterON) ) |
| 155012 | testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); |
| 155013 | if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) |
| 155014 | || pTerm->pExpr->w.iJoin != pSrc->iCursor |
| 155015 | ){ |
| 155016 | return 0; |
| 155017 | } |
| 155018 | if( (pSrc->fg.jointype & (JT_LEFT|JT_RIGHT))!=0 |
| 155019 | && ExprHasProperty(pTerm->pExpr, EP_InnerON) |
| 155020 | ){ |
| 155021 | return 0; |
| 155022 | } |
| 155023 | return 1; |
| 155024 | } |
| 155025 | |
| 155026 | |
| 155027 | |
| 155028 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155029 | /* |
| 155030 | ** Return TRUE if the WHERE clause term pTerm is of a form where it |
| 155031 | ** could be used with an index to access pSrc, assuming an appropriate |
| @@ -155020,20 +155038,14 @@ | |
| 155038 | ){ |
| 155039 | char aff; |
| 155040 | if( pTerm->leftCursor!=pSrc->iCursor ) return 0; |
| 155041 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; |
| 155042 | assert( (pSrc->fg.jointype & JT_RIGHT)==0 ); |
| 155043 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 |
| 155044 | && !constraintCompatibleWithOuterJoin(pTerm,pSrc) |
| 155045 | ){ |
| 155046 | return 0; /* See https://sqlite.org/forum/forumpost/51e6959f61 */ |
| 155047 | } |
| 155048 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 155049 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 155050 | if( pTerm->u.x.leftColumn<0 ) return 0; |
| 155051 | aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; |
| @@ -155441,26 +155453,14 @@ | |
| 155453 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 155454 | |
| 155455 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 155456 | assert( pTerm->u.x.leftColumn>=XN_ROWID ); |
| 155457 | assert( pTerm->u.x.leftColumn<pTab->nCol ); |
| 155458 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 |
| 155459 | && !constraintCompatibleWithOuterJoin(pTerm,pSrc) |
| 155460 | ){ |
| 155461 | continue; |
| 155462 | } |
| 155463 | nTerm++; |
| 155464 | pTerm->wtFlags |= TERM_OK; |
| 155465 | } |
| 155466 | |
| @@ -157114,36 +157114,15 @@ | |
| 157114 | |
| 157115 | /* Do not allow the upper bound of a LIKE optimization range constraint |
| 157116 | ** to mix with a lower range bound from some other source */ |
| 157117 | if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 157118 | |
| 157119 | if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0 |
| 157120 | && !constraintCompatibleWithOuterJoin(pTerm,pSrc) |
| 157121 | ){ |
| 157122 | continue; |
| 157123 | } |
| 157124 | if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){ |
| 157125 | pBuilder->bldFlags1 |= SQLITE_BLDF1_UNIQUE; |
| 157126 | }else{ |
| 157127 | pBuilder->bldFlags1 |= SQLITE_BLDF1_INDEXED; |
| 157128 | } |
| @@ -177299,11 +177278,11 @@ | |
| 177278 | Fts3SegReader **apSegment; /* Array of Fts3SegReader objects */ |
| 177279 | int nSegment; /* Size of apSegment array */ |
| 177280 | int nAdvance; /* How many seg-readers to advance */ |
| 177281 | Fts3SegFilter *pFilter; /* Pointer to filter object */ |
| 177282 | char *aBuffer; /* Buffer to merge doclists in */ |
| 177283 | i64 nBuffer; /* Allocated size of aBuffer[] in bytes */ |
| 177284 | |
| 177285 | int iColFilter; /* If >=0, filter for this column */ |
| 177286 | int bRestart; |
| 177287 | |
| 177288 | /* Used by fts3.c only. */ |
| @@ -179995,11 +179974,11 @@ | |
| 179974 | ** as a single-byte delta, whereas in the second it must be stored as a |
| 179975 | ** FTS3_VARINT_MAX byte varint. |
| 179976 | ** |
| 179977 | ** Similar padding is added in the fts3DoclistOrMerge() function. |
| 179978 | */ |
| 179979 | pTS->aaOutput[0] = sqlite3_malloc64((i64)nDoclist + FTS3_VARINT_MAX + 1); |
| 179980 | pTS->anOutput[0] = nDoclist; |
| 179981 | if( pTS->aaOutput[0] ){ |
| 179982 | memcpy(pTS->aaOutput[0], aDoclist, nDoclist); |
| 179983 | memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX); |
| 179984 | }else{ |
| @@ -181852,11 +181831,11 @@ | |
| 181831 | |
| 181832 | /* Check if the current entries really are a phrase match */ |
| 181833 | if( bEof==0 ){ |
| 181834 | int nList = 0; |
| 181835 | int nByte = a[p->nToken-1].nList; |
| 181836 | char *aDoclist = sqlite3_malloc64((i64)nByte+FTS3_BUFFER_PADDING); |
| 181837 | if( !aDoclist ) return SQLITE_NOMEM; |
| 181838 | memcpy(aDoclist, a[p->nToken-1].pList, nByte+1); |
| 181839 | memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING); |
| 181840 | |
| 181841 | for(i=0; i<(p->nToken-1); i++){ |
| @@ -186088,11 +186067,11 @@ | |
| 186067 | if( c->iOffset>iStartOffset ){ |
| 186068 | int n = c->iOffset-iStartOffset; |
| 186069 | if( n>c->nAllocated ){ |
| 186070 | char *pNew; |
| 186071 | c->nAllocated = n+20; |
| 186072 | pNew = sqlite3_realloc64(c->zToken, c->nAllocated); |
| 186073 | if( !pNew ) return SQLITE_NOMEM; |
| 186074 | c->zToken = pNew; |
| 186075 | } |
| 186076 | porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes); |
| 186077 | *pzToken = c->zToken; |
| @@ -186840,11 +186819,11 @@ | |
| 186819 | if( c->iOffset>iStartOffset ){ |
| 186820 | int i, n = c->iOffset-iStartOffset; |
| 186821 | if( n>c->nTokenAllocated ){ |
| 186822 | char *pNew; |
| 186823 | c->nTokenAllocated = n+20; |
| 186824 | pNew = sqlite3_realloc64(c->pToken, c->nTokenAllocated); |
| 186825 | if( !pNew ) return SQLITE_NOMEM; |
| 186826 | c->pToken = pNew; |
| 186827 | } |
| 186828 | for(i=0; i<n; i++){ |
| 186829 | /* TODO(shess) This needs expansion to handle UTF-8 |
| @@ -188002,27 +187981,27 @@ | |
| 187981 | ){ |
| 187982 | PendingList *p = *pp; |
| 187983 | |
| 187984 | /* Allocate or grow the PendingList as required. */ |
| 187985 | if( !p ){ |
| 187986 | p = sqlite3_malloc64(sizeof(*p) + 100); |
| 187987 | if( !p ){ |
| 187988 | return SQLITE_NOMEM; |
| 187989 | } |
| 187990 | p->nSpace = 100; |
| 187991 | p->aData = (char *)&p[1]; |
| 187992 | p->nData = 0; |
| 187993 | } |
| 187994 | else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){ |
| 187995 | i64 nNew = p->nSpace * 2; |
| 187996 | p = sqlite3_realloc64(p, sizeof(*p) + nNew); |
| 187997 | if( !p ){ |
| 187998 | sqlite3_free(*pp); |
| 187999 | *pp = 0; |
| 188000 | return SQLITE_NOMEM; |
| 188001 | } |
| 188002 | p->nSpace = (int)nNew; |
| 188003 | p->aData = (char *)&p[1]; |
| 188004 | } |
| 188005 | |
| 188006 | /* Append the new serialized varint to the end of the list. */ |
| 188007 | p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i); |
| @@ -188575,11 +188554,11 @@ | |
| 188554 | |
| 188555 | if( rc==SQLITE_OK ){ |
| 188556 | int nByte = sqlite3_blob_bytes(p->pSegments); |
| 188557 | *pnBlob = nByte; |
| 188558 | if( paBlob ){ |
| 188559 | char *aByte = sqlite3_malloc64((i64)nByte + FTS3_NODE_PADDING); |
| 188560 | if( !aByte ){ |
| 188561 | rc = SQLITE_NOMEM; |
| 188562 | }else{ |
| 188563 | if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){ |
| 188564 | nByte = FTS3_NODE_CHUNKSIZE; |
| @@ -188692,19 +188671,19 @@ | |
| 188671 | int nCopy = pList->nData+1; |
| 188672 | |
| 188673 | int nTerm = fts3HashKeysize(pElem); |
| 188674 | if( (nTerm+1)>pReader->nTermAlloc ){ |
| 188675 | sqlite3_free(pReader->zTerm); |
| 188676 | pReader->zTerm = (char*)sqlite3_malloc64(((i64)nTerm+1)*2); |
| 188677 | if( !pReader->zTerm ) return SQLITE_NOMEM; |
| 188678 | pReader->nTermAlloc = (nTerm+1)*2; |
| 188679 | } |
| 188680 | memcpy(pReader->zTerm, fts3HashKey(pElem), nTerm); |
| 188681 | pReader->zTerm[nTerm] = '\0'; |
| 188682 | pReader->nTerm = nTerm; |
| 188683 | |
| 188684 | aCopy = (char*)sqlite3_malloc64(nCopy); |
| 188685 | if( !aCopy ) return SQLITE_NOMEM; |
| 188686 | memcpy(aCopy, pList->aData, nCopy); |
| 188687 | pReader->nNode = pReader->nDoclist = nCopy; |
| 188688 | pReader->aNode = pReader->aDoclist = aCopy; |
| 188689 | pReader->ppNextElem++; |
| @@ -188987,11 +188966,11 @@ | |
| 188966 | if( iStartLeaf==0 ){ |
| 188967 | if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB; |
| 188968 | nExtra = nRoot + FTS3_NODE_PADDING; |
| 188969 | } |
| 188970 | |
| 188971 | pReader = (Fts3SegReader *)sqlite3_malloc64(sizeof(Fts3SegReader) + nExtra); |
| 188972 | if( !pReader ){ |
| 188973 | return SQLITE_NOMEM; |
| 188974 | } |
| 188975 | memset(pReader, 0, sizeof(Fts3SegReader)); |
| 188976 | pReader->iIdx = iAge; |
| @@ -189079,11 +189058,11 @@ | |
| 189058 | int nKey = fts3HashKeysize(pE); |
| 189059 | if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){ |
| 189060 | if( nElem==nAlloc ){ |
| 189061 | Fts3HashElem **aElem2; |
| 189062 | nAlloc += 16; |
| 189063 | aElem2 = (Fts3HashElem **)sqlite3_realloc64( |
| 189064 | aElem, nAlloc*sizeof(Fts3HashElem *) |
| 189065 | ); |
| 189066 | if( !aElem2 ){ |
| 189067 | rc = SQLITE_NOMEM; |
| 189068 | nElem = 0; |
| @@ -189413,11 +189392,11 @@ | |
| 189392 | ** p->nNodeSize bytes, but since this scenario only comes about when |
| 189393 | ** the database contain two terms that share a prefix of almost 2KB, |
| 189394 | ** this is not expected to be a serious problem. |
| 189395 | */ |
| 189396 | assert( pTree->aData==(char *)&pTree[1] ); |
| 189397 | pTree->aData = (char *)sqlite3_malloc64(nReq); |
| 189398 | if( !pTree->aData ){ |
| 189399 | return SQLITE_NOMEM; |
| 189400 | } |
| 189401 | } |
| 189402 | |
| @@ -189431,11 +189410,11 @@ | |
| 189410 | pTree->nData = nData + nSuffix; |
| 189411 | pTree->nEntry++; |
| 189412 | |
| 189413 | if( isCopyTerm ){ |
| 189414 | if( pTree->nMalloc<nTerm ){ |
| 189415 | char *zNew = sqlite3_realloc64(pTree->zMalloc, (i64)nTerm*2); |
| 189416 | if( !zNew ){ |
| 189417 | return SQLITE_NOMEM; |
| 189418 | } |
| 189419 | pTree->nMalloc = nTerm*2; |
| 189420 | pTree->zMalloc = zNew; |
| @@ -189457,11 +189436,11 @@ | |
| 189436 | ** |
| 189437 | ** Otherwise, the term is not added to the new node, it is left empty for |
| 189438 | ** now. Instead, the term is inserted into the parent of pTree. If pTree |
| 189439 | ** has no parent, one is created here. |
| 189440 | */ |
| 189441 | pNew = (SegmentNode *)sqlite3_malloc64(sizeof(SegmentNode) + p->nNodeSize); |
| 189442 | if( !pNew ){ |
| 189443 | return SQLITE_NOMEM; |
| 189444 | } |
| 189445 | memset(pNew, 0, sizeof(SegmentNode)); |
| 189446 | pNew->nData = 1 + FTS3_VARINT_MAX; |
| @@ -189595,26 +189574,26 @@ | |
| 189574 | const char *aDoclist, /* Pointer to buffer containing doclist */ |
| 189575 | int nDoclist /* Size of doclist in bytes */ |
| 189576 | ){ |
| 189577 | int nPrefix; /* Size of term prefix in bytes */ |
| 189578 | int nSuffix; /* Size of term suffix in bytes */ |
| 189579 | i64 nReq; /* Number of bytes required on leaf page */ |
| 189580 | int nData; |
| 189581 | SegmentWriter *pWriter = *ppWriter; |
| 189582 | |
| 189583 | if( !pWriter ){ |
| 189584 | int rc; |
| 189585 | sqlite3_stmt *pStmt; |
| 189586 | |
| 189587 | /* Allocate the SegmentWriter structure */ |
| 189588 | pWriter = (SegmentWriter *)sqlite3_malloc64(sizeof(SegmentWriter)); |
| 189589 | if( !pWriter ) return SQLITE_NOMEM; |
| 189590 | memset(pWriter, 0, sizeof(SegmentWriter)); |
| 189591 | *ppWriter = pWriter; |
| 189592 | |
| 189593 | /* Allocate a buffer in which to accumulate data */ |
| 189594 | pWriter->aData = (char *)sqlite3_malloc64(p->nNodeSize); |
| 189595 | if( !pWriter->aData ) return SQLITE_NOMEM; |
| 189596 | pWriter->nSize = p->nNodeSize; |
| 189597 | |
| 189598 | /* Find the next free blockid in the %_segments table */ |
| 189599 | rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0); |
| @@ -189685,11 +189664,11 @@ | |
| 189664 | |
| 189665 | /* If the buffer currently allocated is too small for this entry, realloc |
| 189666 | ** the buffer to make it large enough. |
| 189667 | */ |
| 189668 | if( nReq>pWriter->nSize ){ |
| 189669 | char *aNew = sqlite3_realloc64(pWriter->aData, nReq); |
| 189670 | if( !aNew ) return SQLITE_NOMEM; |
| 189671 | pWriter->aData = aNew; |
| 189672 | pWriter->nSize = nReq; |
| 189673 | } |
| 189674 | assert( nData+nReq<=pWriter->nSize ); |
| @@ -189710,11 +189689,11 @@ | |
| 189689 | ** zTerm is transient, so take a copy of the term data. Otherwise, just |
| 189690 | ** store a copy of the pointer. |
| 189691 | */ |
| 189692 | if( isCopyTerm ){ |
| 189693 | if( nTerm>pWriter->nMalloc ){ |
| 189694 | char *zNew = sqlite3_realloc64(pWriter->zMalloc, (i64)nTerm*2); |
| 189695 | if( !zNew ){ |
| 189696 | return SQLITE_NOMEM; |
| 189697 | } |
| 189698 | pWriter->nMalloc = nTerm*2; |
| 189699 | pWriter->zMalloc = zNew; |
| @@ -190018,16 +189997,16 @@ | |
| 189997 | ** trying to resize the buffer, return SQLITE_NOMEM. |
| 189998 | */ |
| 189999 | static int fts3MsrBufferData( |
| 190000 | Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */ |
| 190001 | char *pList, |
| 190002 | i64 nList |
| 190003 | ){ |
| 190004 | if( nList>pMsr->nBuffer ){ |
| 190005 | char *pNew; |
| 190006 | pMsr->nBuffer = nList*2; |
| 190007 | pNew = (char *)sqlite3_realloc64(pMsr->aBuffer, pMsr->nBuffer); |
| 190008 | if( !pNew ) return SQLITE_NOMEM; |
| 190009 | pMsr->aBuffer = pNew; |
| 190010 | } |
| 190011 | |
| 190012 | assert( nList>0 ); |
| @@ -190079,11 +190058,11 @@ | |
| 190058 | } |
| 190059 | if( rc!=SQLITE_OK ) return rc; |
| 190060 | fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp); |
| 190061 | |
| 190062 | if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){ |
| 190063 | rc = fts3MsrBufferData(pMsr, pList, (i64)nList+1); |
| 190064 | if( rc!=SQLITE_OK ) return rc; |
| 190065 | assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 ); |
| 190066 | pList = pMsr->aBuffer; |
| 190067 | } |
| 190068 | |
| @@ -190216,15 +190195,15 @@ | |
| 190195 | } |
| 190196 | |
| 190197 | return SQLITE_OK; |
| 190198 | } |
| 190199 | |
| 190200 | static int fts3GrowSegReaderBuffer(Fts3MultiSegReader *pCsr, i64 nReq){ |
| 190201 | if( nReq>pCsr->nBuffer ){ |
| 190202 | char *aNew; |
| 190203 | pCsr->nBuffer = nReq*2; |
| 190204 | aNew = sqlite3_realloc64(pCsr->aBuffer, pCsr->nBuffer); |
| 190205 | if( !aNew ){ |
| 190206 | return SQLITE_NOMEM; |
| 190207 | } |
| 190208 | pCsr->aBuffer = aNew; |
| 190209 | } |
| @@ -190311,11 +190290,12 @@ | |
| 190290 | && !isFirst |
| 190291 | && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) |
| 190292 | ){ |
| 190293 | pCsr->nDoclist = apSegment[0]->nDoclist; |
| 190294 | if( fts3SegReaderIsPending(apSegment[0]) ){ |
| 190295 | rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, |
| 190296 | (i64)pCsr->nDoclist); |
| 190297 | pCsr->aDoclist = pCsr->aBuffer; |
| 190298 | }else{ |
| 190299 | pCsr->aDoclist = apSegment[0]->aDoclist; |
| 190300 | } |
| 190301 | if( rc==SQLITE_OK ) rc = SQLITE_ROW; |
| @@ -190364,11 +190344,12 @@ | |
| 190344 | iDelta = (i64)((u64)iDocid - (u64)iPrev); |
| 190345 | } |
| 190346 | |
| 190347 | nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); |
| 190348 | |
| 190349 | rc = fts3GrowSegReaderBuffer(pCsr, |
| 190350 | (i64)nByte+nDoclist+FTS3_NODE_PADDING); |
| 190351 | if( rc ) return rc; |
| 190352 | |
| 190353 | if( isFirst ){ |
| 190354 | char *a = &pCsr->aBuffer[nDoclist]; |
| 190355 | int nWrite; |
| @@ -190390,11 +190371,11 @@ | |
| 190371 | } |
| 190372 | |
| 190373 | fts3SegReaderSort(apSegment, nMerge, j, xCmp); |
| 190374 | } |
| 190375 | if( nDoclist>0 ){ |
| 190376 | rc = fts3GrowSegReaderBuffer(pCsr, (i64)nDoclist+FTS3_NODE_PADDING); |
| 190377 | if( rc ) return rc; |
| 190378 | memset(&pCsr->aBuffer[nDoclist], 0, FTS3_NODE_PADDING); |
| 190379 | pCsr->aDoclist = pCsr->aBuffer; |
| 190380 | pCsr->nDoclist = nDoclist; |
| 190381 | rc = SQLITE_ROW; |
| @@ -191103,11 +191084,11 @@ | |
| 191084 | ** to reflect the new size of the pBlob->a[] buffer. |
| 191085 | */ |
| 191086 | static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){ |
| 191087 | if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){ |
| 191088 | int nAlloc = nMin; |
| 191089 | char *a = (char *)sqlite3_realloc64(pBlob->a, nAlloc); |
| 191090 | if( a ){ |
| 191091 | pBlob->nAlloc = nAlloc; |
| 191092 | pBlob->a = a; |
| 191093 | }else{ |
| 191094 | *pRc = SQLITE_NOMEM; |
| @@ -191900,11 +191881,11 @@ | |
| 191881 | sqlite3_bind_int64(pSelect, 1, iAbsLevel); |
| 191882 | while( SQLITE_ROW==sqlite3_step(pSelect) ){ |
| 191883 | if( nIdx>=nAlloc ){ |
| 191884 | int *aNew; |
| 191885 | nAlloc += 16; |
| 191886 | aNew = sqlite3_realloc64(aIdx, nAlloc*sizeof(int)); |
| 191887 | if( !aNew ){ |
| 191888 | rc = SQLITE_NOMEM; |
| 191889 | break; |
| 191890 | } |
| 191891 | aIdx = aNew; |
| @@ -192274,11 +192255,11 @@ | |
| 192255 | Blob hint = {0, 0, 0}; /* Hint read from %_stat table */ |
| 192256 | int bDirtyHint = 0; /* True if blob 'hint' has been modified */ |
| 192257 | |
| 192258 | /* Allocate space for the cursor, filter and writer objects */ |
| 192259 | const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter); |
| 192260 | pWriter = (IncrmergeWriter *)sqlite3_malloc64(nAlloc); |
| 192261 | if( !pWriter ) return SQLITE_NOMEM; |
| 192262 | pFilter = (Fts3SegFilter *)&pWriter[1]; |
| 192263 | pCsr = (Fts3MultiSegReader *)&pFilter[1]; |
| 192264 | |
| 192265 | rc = fts3IncrmergeHintLoad(p, &hint); |
| @@ -192910,11 +192891,11 @@ | |
| 192891 | |
| 192892 | if( p->pList==0 ){ |
| 192893 | return SQLITE_OK; |
| 192894 | } |
| 192895 | |
| 192896 | pRet = (char *)sqlite3_malloc64(p->pList->nData); |
| 192897 | if( !pRet ) return SQLITE_NOMEM; |
| 192898 | |
| 192899 | nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy); |
| 192900 | *pnData = p->pList->nData - nSkip; |
| 192901 | *ppData = pRet; |
| @@ -192930,11 +192911,11 @@ | |
| 192911 | Fts3Cursor *pCsr, /* Fts3 table cursor */ |
| 192912 | Fts3PhraseToken *pToken, /* Token to defer */ |
| 192913 | int iCol /* Column that token must appear in (or -1) */ |
| 192914 | ){ |
| 192915 | Fts3DeferredToken *pDeferred; |
| 192916 | pDeferred = sqlite3_malloc64(sizeof(*pDeferred)); |
| 192917 | if( !pDeferred ){ |
| 192918 | return SQLITE_NOMEM; |
| 192919 | } |
| 192920 | memset(pDeferred, 0, sizeof(*pDeferred)); |
| 192921 | pDeferred->pToken = pToken; |
| @@ -205112,12 +205093,13 @@ | |
| 205093 | } |
| 205094 | pExpr = uregex_open(zPattern, -1, 0, 0, &status); |
| 205095 | |
| 205096 | if( U_SUCCESS(status) ){ |
| 205097 | sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete); |
| 205098 | pExpr = sqlite3_get_auxdata(p, 0); |
| 205099 | } |
| 205100 | if( !pExpr ){ |
| 205101 | icuFunctionError(p, "uregex_open", status); |
| 205102 | return; |
| 205103 | } |
| 205104 | } |
| 205105 | |
| @@ -237002,11 +236984,11 @@ | |
| 236984 | int nArg, /* Number of args */ |
| 236985 | sqlite3_value **apUnused /* Function arguments */ |
| 236986 | ){ |
| 236987 | assert( nArg==0 ); |
| 236988 | UNUSED_PARAM2(nArg, apUnused); |
| 236989 | sqlite3_result_text(pCtx, "fts5: 2022-09-28 19:14:01 f25cf63471cbed1edb27591e57fead62550d4046dbdcb61312288f0f6f24c646", -1, SQLITE_TRANSIENT); |
| 236990 | } |
| 236991 | |
| 236992 | /* |
| 236993 | ** Return true if zName is the extension on one of the shadow tables used |
| 236994 | ** by this module. |
| 236995 |
+1
-1
| --- extsrc/sqlite3.h | ||
| +++ extsrc/sqlite3.h | ||
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | 148 | */ |
| 149 | 149 | #define SQLITE_VERSION "3.40.0" |
| 150 | 150 | #define SQLITE_VERSION_NUMBER 3040000 |
| 151 | -#define SQLITE_SOURCE_ID "2022-09-02 21:19:24 da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c" | |
| 151 | +#define SQLITE_SOURCE_ID "2022-09-28 19:14:01 f25cf63471cbed1edb27591e57fead62550d4046dbdcb61312288f0f6f24c646" | |
| 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 | |
| @@ -146,11 +146,11 @@ | |
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ |
| 149 | #define SQLITE_VERSION "3.40.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3040000 |
| 151 | #define SQLITE_SOURCE_ID "2022-09-02 21:19:24 da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| 157 |
| --- extsrc/sqlite3.h | |
| +++ extsrc/sqlite3.h | |
| @@ -146,11 +146,11 @@ | |
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ |
| 149 | #define SQLITE_VERSION "3.40.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3040000 |
| 151 | #define SQLITE_SOURCE_ID "2022-09-28 19:14:01 f25cf63471cbed1edb27591e57fead62550d4046dbdcb61312288f0f6f24c646" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| 157 |