Fossil SCM
Update the built-in SQLite to the latest 3.37.0 alpha, for testing.
Commit
39fbaf34e1f58e49de831c61f52b18731f85d738d9e7cc0896080b05e8eb96f3
Parent
c9f3d9c2a92344d…
2 files changed
+271
-118
+10
-1
+271
-118
| --- src/sqlite3.c | ||
| +++ src/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.37.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3037000 |
| 457 | -#define SQLITE_SOURCE_ID "2021-11-04 14:04:20 9147390d9885a37a62edc1058f313434627f1b59965c890877d2cb119e355c78" | |
| 457 | +#define SQLITE_SOURCE_ID "2021-11-09 13:31:42 de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae" | |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| @@ -913,10 +913,11 @@ | ||
| 913 | 913 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 914 | 914 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 915 | 915 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 916 | 916 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 917 | 917 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 918 | +#define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ | |
| 918 | 919 | |
| 919 | 920 | /* Reserved: 0x00F00000 */ |
| 920 | 921 | /* Legacy compatibility: */ |
| 921 | 922 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
| 922 | 923 | |
| @@ -3732,10 +3733,18 @@ | ||
| 3732 | 3733 | ** |
| 3733 | 3734 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 3734 | 3735 | ** <dd>The database is opened [shared cache] disabled, overriding |
| 3735 | 3736 | ** the default shared cache setting provided by |
| 3736 | 3737 | ** [sqlite3_enable_shared_cache()].)^ |
| 3738 | +** | |
| 3739 | +** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> | |
| 3740 | +** <dd>The database connection comes up in "extended result code mode". | |
| 3741 | +** In other words, the database behaves has if | |
| 3742 | +** [sqlite3_extended_result_codes(db,1)] where called on the database | |
| 3743 | +** connection as soon as the connection is created. In addition to setting | |
| 3744 | +** the extended result code mode, this flag also causes [sqlite3_open_v2()] | |
| 3745 | +** to return an extended result code.</dd> | |
| 3737 | 3746 | ** |
| 3738 | 3747 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 3739 | 3748 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 3740 | 3749 | ** </dl>)^ |
| 3741 | 3750 | ** |
| @@ -18901,12 +18910,12 @@ | ||
| 18901 | 18910 | union { /* Extra data for callback */ |
| 18902 | 18911 | NameContext *pNC; /* Naming context */ |
| 18903 | 18912 | int n; /* A counter */ |
| 18904 | 18913 | int iCur; /* A cursor number */ |
| 18905 | 18914 | SrcList *pSrcList; /* FROM clause */ |
| 18906 | - struct SrcCount *pSrcCount; /* Counting column references */ | |
| 18907 | 18915 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 18916 | + struct RefSrcList *pRefSrcList; /* sqlite3ReferencesSrcList() */ | |
| 18908 | 18917 | int *aiCol; /* array of column indexes */ |
| 18909 | 18918 | struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 18910 | 18919 | struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */ |
| 18911 | 18920 | ExprList *pGroupBy; /* GROUP BY clause */ |
| 18912 | 18921 | Select *pSelect; /* HAVING to WHERE clause ctx */ |
| @@ -19560,11 +19569,11 @@ | ||
| 19560 | 19569 | SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int); |
| 19561 | 19570 | SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); |
| 19562 | 19571 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 19563 | 19572 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 19564 | 19573 | SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |
| 19565 | -SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); | |
| 19574 | +SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse*, Expr*, SrcList*); | |
| 19566 | 19575 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 19567 | 19576 | #ifndef SQLITE_UNTESTABLE |
| 19568 | 19577 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| 19569 | 19578 | SQLITE_PRIVATE void sqlite3PrngRestoreState(void); |
| 19570 | 19579 | #endif |
| @@ -22193,11 +22202,15 @@ | ||
| 22193 | 22202 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 22194 | 22203 | #endif |
| 22195 | 22204 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); |
| 22196 | 22205 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 22197 | 22206 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 22207 | +#ifndef SQLITE_OMIT_INCRBLOB | |
| 22198 | 22208 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 22209 | +#else | |
| 22210 | +SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem*,int); | |
| 22211 | +#endif | |
| 22199 | 22212 | #ifdef SQLITE_DEBUG |
| 22200 | 22213 | SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); |
| 22201 | 22214 | #endif |
| 22202 | 22215 | SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); |
| 22203 | 22216 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| @@ -48826,12 +48839,13 @@ | ||
| 48826 | 48839 | */ |
| 48827 | 48840 | static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ |
| 48828 | 48841 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48829 | 48842 | int rc = SQLITE_OK; |
| 48830 | 48843 | memdbEnter(p); |
| 48831 | - if( NEVER(size>p->sz) ){ | |
| 48832 | - rc = SQLITE_FULL; | |
| 48844 | + if( size>p->sz ){ | |
| 48845 | + /* This can only happen with a corrupt wal mode db */ | |
| 48846 | + rc = SQLITE_CORRUPT; | |
| 48833 | 48847 | }else{ |
| 48834 | 48848 | p->sz = size; |
| 48835 | 48849 | } |
| 48836 | 48850 | memdbLeave(p); |
| 48837 | 48851 | return rc; |
| @@ -78041,19 +78055,35 @@ | ||
| 78041 | 78055 | |
| 78042 | 78056 | /* |
| 78043 | 78057 | ** Delete any previous value and set the value to be a BLOB of length |
| 78044 | 78058 | ** n containing all zeros. |
| 78045 | 78059 | */ |
| 78060 | +#ifndef SQLITE_OMIT_INCRBLOB | |
| 78046 | 78061 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ |
| 78047 | 78062 | sqlite3VdbeMemRelease(pMem); |
| 78048 | 78063 | pMem->flags = MEM_Blob|MEM_Zero; |
| 78049 | 78064 | pMem->n = 0; |
| 78050 | 78065 | if( n<0 ) n = 0; |
| 78051 | 78066 | pMem->u.nZero = n; |
| 78052 | 78067 | pMem->enc = SQLITE_UTF8; |
| 78053 | 78068 | pMem->z = 0; |
| 78054 | 78069 | } |
| 78070 | +#else | |
| 78071 | +SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ | |
| 78072 | + int nByte = n>0?n:1; | |
| 78073 | + if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){ | |
| 78074 | + return SQLITE_NOMEM_BKPT; | |
| 78075 | + } | |
| 78076 | + assert( pMem->z!=0 ); | |
| 78077 | + assert( sqlite3DbMallocSize(pMem->db, pMem->z)>=nByte ); | |
| 78078 | + memset(pMem->z, 0, nByte); | |
| 78079 | + pMem->n = n>0?n:0; | |
| 78080 | + pMem->flags = MEM_Blob; | |
| 78081 | + pMem->enc = SQLITE_UTF8; | |
| 78082 | + return SQLITE_OK; | |
| 78083 | +} | |
| 78084 | +#endif | |
| 78055 | 78085 | |
| 78056 | 78086 | /* |
| 78057 | 78087 | ** The pMem is known to contain content that needs to be destroyed prior |
| 78058 | 78088 | ** to a value change. So invoke the destructor, then set the value to |
| 78059 | 78089 | ** a 64-bit integer. |
| @@ -84914,12 +84944,16 @@ | ||
| 84914 | 84944 | Mem *pOut = pCtx->pOut; |
| 84915 | 84945 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 84916 | 84946 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 84917 | 84947 | return SQLITE_TOOBIG; |
| 84918 | 84948 | } |
| 84949 | +#ifndef SQLITE_OMIT_INCRBLOB | |
| 84919 | 84950 | sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 84920 | 84951 | return SQLITE_OK; |
| 84952 | +#else | |
| 84953 | + return sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); | |
| 84954 | +#endif | |
| 84921 | 84955 | } |
| 84922 | 84956 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 84923 | 84957 | pCtx->isError = errCode ? errCode : -1; |
| 84924 | 84958 | #ifdef SQLITE_DEBUG |
| 84925 | 84959 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| @@ -85927,11 +85961,15 @@ | ||
| 85927 | 85961 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ |
| 85928 | 85962 | int rc; |
| 85929 | 85963 | Vdbe *p = (Vdbe *)pStmt; |
| 85930 | 85964 | rc = vdbeUnbind(p, i); |
| 85931 | 85965 | if( rc==SQLITE_OK ){ |
| 85966 | +#ifndef SQLITE_OMIT_INCRBLOB | |
| 85932 | 85967 | sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); |
| 85968 | +#else | |
| 85969 | + rc = sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); | |
| 85970 | +#endif | |
| 85933 | 85971 | sqlite3_mutex_leave(p->db->mutex); |
| 85934 | 85972 | } |
| 85935 | 85973 | return rc; |
| 85936 | 85974 | } |
| 85937 | 85975 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| @@ -100579,19 +100617,22 @@ | ||
| 100579 | 100617 | sqlite3WindowLink(pSel, pWin); |
| 100580 | 100618 | pNC->ncFlags |= NC_HasWin; |
| 100581 | 100619 | }else |
| 100582 | 100620 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 100583 | 100621 | { |
| 100584 | - NameContext *pNC2 = pNC; | |
| 100622 | + NameContext *pNC2; /* For looping up thru outer contexts */ | |
| 100585 | 100623 | pExpr->op = TK_AGG_FUNCTION; |
| 100586 | 100624 | pExpr->op2 = 0; |
| 100587 | 100625 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100588 | 100626 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 100589 | 100627 | sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); |
| 100590 | 100628 | } |
| 100591 | 100629 | #endif |
| 100592 | - while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){ | |
| 100630 | + pNC2 = pNC; | |
| 100631 | + while( pNC2 | |
| 100632 | + && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 | |
| 100633 | + ){ | |
| 100593 | 100634 | pExpr->op2++; |
| 100594 | 100635 | pNC2 = pNC2->pNext; |
| 100595 | 100636 | } |
| 100596 | 100637 | assert( pDef!=0 || IN_RENAME_OBJECT ); |
| 100597 | 100638 | if( pNC2 && pDef ){ |
| @@ -101557,12 +101598,12 @@ | ||
| 101557 | 101598 | |
| 101558 | 101599 | /* |
| 101559 | 101600 | ** Return the affinity character for a single column of a table. |
| 101560 | 101601 | */ |
| 101561 | 101602 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(const Table *pTab, int iCol){ |
| 101562 | - assert( iCol<pTab->nCol ); | |
| 101563 | - return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER; | |
| 101603 | + if( iCol<0 || NEVER(iCol>=pTab->nCol) ) return SQLITE_AFF_INTEGER; | |
| 101604 | + return pTab->aCol[iCol].affinity; | |
| 101564 | 101605 | } |
| 101565 | 101606 | |
| 101566 | 101607 | /* |
| 101567 | 101608 | ** Return the 'affinity' of the expression pExpr if any. |
| 101568 | 101609 | ** |
| @@ -107414,93 +107455,128 @@ | ||
| 107414 | 107455 | sqlite3WalkExpr(&w, pExpr); |
| 107415 | 107456 | return !w.eCode; |
| 107416 | 107457 | } |
| 107417 | 107458 | |
| 107418 | 107459 | |
| 107419 | -/* | |
| 107420 | -** An instance of the following structure is used by the tree walker | |
| 107421 | -** to count references to table columns in the arguments of an | |
| 107422 | -** aggregate function, in order to implement the | |
| 107423 | -** sqlite3FunctionThisSrc() routine. | |
| 107460 | +/* Structure used to pass information throught the Walker in order to | |
| 107461 | +** implement sqlite3ReferencesSrcList(). | |
| 107424 | 107462 | */ |
| 107425 | -struct SrcCount { | |
| 107426 | - SrcList *pSrc; /* One particular FROM clause in a nested query */ | |
| 107427 | - int iSrcInner; /* Smallest cursor number in this context */ | |
| 107428 | - int nThis; /* Number of references to columns in pSrcList */ | |
| 107429 | - int nOther; /* Number of references to columns in other FROM clauses */ | |
| 107463 | +struct RefSrcList { | |
| 107464 | + sqlite3 *db; /* Database connection used for sqlite3DbRealloc() */ | |
| 107465 | + SrcList *pRef; /* Looking for references to these tables */ | |
| 107466 | + int nExclude; /* Number of tables to exclude from the search */ | |
| 107467 | + int *aiExclude; /* Cursor IDs for tables to exclude from the search */ | |
| 107430 | 107468 | }; |
| 107431 | 107469 | |
| 107432 | 107470 | /* |
| 107433 | -** xSelect callback for sqlite3FunctionUsesThisSrc(). If this is the first | |
| 107434 | -** SELECT with a FROM clause encountered during this iteration, set | |
| 107435 | -** SrcCount.iSrcInner to the cursor number of the leftmost object in | |
| 107436 | -** the FROM cause. | |
| 107471 | +** Walker SELECT callbacks for sqlite3ReferencesSrcList(). | |
| 107472 | +** | |
| 107473 | +** When entering a new subquery on the pExpr argument, add all FROM clause | |
| 107474 | +** entries for that subquery to the exclude list. | |
| 107475 | +** | |
| 107476 | +** When leaving the subquery, remove those entries from the exclude list. | |
| 107437 | 107477 | */ |
| 107438 | -static int selectSrcCount(Walker *pWalker, Select *pSel){ | |
| 107439 | - struct SrcCount *p = pWalker->u.pSrcCount; | |
| 107440 | - if( p->iSrcInner==0x7FFFFFFF && ALWAYS(pSel->pSrc) && pSel->pSrc->nSrc ){ | |
| 107441 | - pWalker->u.pSrcCount->iSrcInner = pSel->pSrc->a[0].iCursor; | |
| 107478 | +static int selectRefEnter(Walker *pWalker, Select *pSelect){ | |
| 107479 | + struct RefSrcList *p = pWalker->u.pRefSrcList; | |
| 107480 | + SrcList *pSrc = pSelect->pSrc; | |
| 107481 | + int i, j, *piNew; | |
| 107482 | + if( pSrc->nSrc==0 ) return WRC_Continue; | |
| 107483 | + j = p->nExclude; | |
| 107484 | + p->nExclude += pSrc->nSrc; | |
| 107485 | + piNew = sqlite3DbRealloc(p->db, p->aiExclude, p->nExclude*sizeof(int)); | |
| 107486 | + if( piNew==0 ){ | |
| 107487 | + p->nExclude = 0; | |
| 107488 | + return WRC_Abort; | |
| 107489 | + }else{ | |
| 107490 | + p->aiExclude = piNew; | |
| 107491 | + } | |
| 107492 | + for(i=0; i<pSrc->nSrc; i++, j++){ | |
| 107493 | + p->aiExclude[j] = pSrc->a[i].iCursor; | |
| 107442 | 107494 | } |
| 107443 | 107495 | return WRC_Continue; |
| 107444 | 107496 | } |
| 107445 | - | |
| 107446 | -/* | |
| 107447 | -** Count the number of references to columns. | |
| 107448 | -*/ | |
| 107449 | -static int exprSrcCount(Walker *pWalker, Expr *pExpr){ | |
| 107450 | - /* There was once a NEVER() on the second term on the grounds that | |
| 107451 | - ** sqlite3FunctionUsesThisSrc() was always called before | |
| 107452 | - ** sqlite3ExprAnalyzeAggregates() and so the TK_COLUMNs have not yet | |
| 107453 | - ** been converted into TK_AGG_COLUMN. But this is no longer true due | |
| 107454 | - ** to window functions - sqlite3WindowRewrite() may now indirectly call | |
| 107455 | - ** FunctionUsesThisSrc() when creating a new sub-select. */ | |
| 107456 | - if( pExpr->op==TK_COLUMN || pExpr->op==TK_AGG_COLUMN ){ | |
| 107457 | - int i; | |
| 107458 | - struct SrcCount *p = pWalker->u.pSrcCount; | |
| 107459 | - SrcList *pSrc = p->pSrc; | |
| 107497 | +static void selectRefLeave(Walker *pWalker, Select *pSelect){ | |
| 107498 | + struct RefSrcList *p = pWalker->u.pRefSrcList; | |
| 107499 | + SrcList *pSrc = pSelect->pSrc; | |
| 107500 | + if( p->nExclude ){ | |
| 107501 | + assert( p->nExclude>=pSrc->nSrc ); | |
| 107502 | + p->nExclude -= pSrc->nSrc; | |
| 107503 | + } | |
| 107504 | +} | |
| 107505 | + | |
| 107506 | +/* This is the Walker EXPR callback for sqlite3ReferencesSrcList(). | |
| 107507 | +** | |
| 107508 | +** Set the 0x01 bit of pWalker->eCode if there is a reference to any | |
| 107509 | +** of the tables shown in RefSrcList.pRef. | |
| 107510 | +** | |
| 107511 | +** Set the 0x02 bit of pWalker->eCode if there is a reference to a | |
| 107512 | +** table is in neither RefSrcList.pRef nor RefSrcList.aiExclude. | |
| 107513 | +*/ | |
| 107514 | +static int exprRefToSrcList(Walker *pWalker, Expr *pExpr){ | |
| 107515 | + if( pExpr->op==TK_COLUMN | |
| 107516 | + || pExpr->op==TK_AGG_COLUMN | |
| 107517 | + ){ | |
| 107518 | + int i; | |
| 107519 | + struct RefSrcList *p = pWalker->u.pRefSrcList; | |
| 107520 | + SrcList *pSrc = p->pRef; | |
| 107460 | 107521 | int nSrc = pSrc ? pSrc->nSrc : 0; |
| 107461 | 107522 | for(i=0; i<nSrc; i++){ |
| 107462 | - if( pExpr->iTable==pSrc->a[i].iCursor ) break; | |
| 107463 | - } | |
| 107464 | - if( i<nSrc ){ | |
| 107465 | - p->nThis++; | |
| 107466 | - }else if( pExpr->iTable<p->iSrcInner ){ | |
| 107467 | - /* In a well-formed parse tree (no name resolution errors), | |
| 107468 | - ** TK_COLUMN nodes with smaller Expr.iTable values are in an | |
| 107469 | - ** outer context. Those are the only ones to count as "other" */ | |
| 107470 | - p->nOther++; | |
| 107523 | + if( pExpr->iTable==pSrc->a[i].iCursor ){ | |
| 107524 | + pWalker->eCode |= 1; | |
| 107525 | + return WRC_Continue; | |
| 107526 | + } | |
| 107527 | + } | |
| 107528 | + for(i=0; i<p->nExclude && p->aiExclude[i]!=pExpr->iTable; i++){} | |
| 107529 | + if( i>=p->nExclude ){ | |
| 107530 | + pWalker->eCode |= 2; | |
| 107471 | 107531 | } |
| 107472 | 107532 | } |
| 107473 | 107533 | return WRC_Continue; |
| 107474 | 107534 | } |
| 107475 | 107535 | |
| 107476 | 107536 | /* |
| 107477 | -** Determine if any of the arguments to the pExpr Function reference | |
| 107478 | -** pSrcList. Return true if they do. Also return true if the function | |
| 107479 | -** has no arguments or has only constant arguments. Return false if pExpr | |
| 107480 | -** references columns but not columns of tables found in pSrcList. | |
| 107537 | +** Check to see if pExpr references any tables in pSrcList. | |
| 107538 | +** Possible return values: | |
| 107539 | +** | |
| 107540 | +** 1 pExpr does references a table in pSrcList. | |
| 107541 | +** | |
| 107542 | +** 0 pExpr references some table that is not defined in either | |
| 107543 | +** pSrcList or in subqueries of pExpr itself. | |
| 107544 | +** | |
| 107545 | +** -1 pExpr only references no tables at all, or it only | |
| 107546 | +** references tables defined in subqueries of pExpr itself. | |
| 107547 | +** | |
| 107548 | +** As currently used, pExpr is always an aggregate function call. That | |
| 107549 | +** fact is exploited for efficiency. | |
| 107481 | 107550 | */ |
| 107482 | -SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){ | |
| 107551 | +SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse *pParse, Expr *pExpr, SrcList *pSrcList){ | |
| 107483 | 107552 | Walker w; |
| 107484 | - struct SrcCount cnt; | |
| 107485 | - assert( pExpr->op==TK_AGG_FUNCTION ); | |
| 107553 | + struct RefSrcList x; | |
| 107486 | 107554 | memset(&w, 0, sizeof(w)); |
| 107487 | - w.xExprCallback = exprSrcCount; | |
| 107488 | - w.xSelectCallback = selectSrcCount; | |
| 107489 | - w.u.pSrcCount = &cnt; | |
| 107490 | - cnt.pSrc = pSrcList; | |
| 107491 | - cnt.iSrcInner = (pSrcList&&pSrcList->nSrc)?pSrcList->a[0].iCursor:0x7FFFFFFF; | |
| 107492 | - cnt.nThis = 0; | |
| 107493 | - cnt.nOther = 0; | |
| 107555 | + memset(&x, 0, sizeof(x)); | |
| 107556 | + w.xExprCallback = exprRefToSrcList; | |
| 107557 | + w.xSelectCallback = selectRefEnter; | |
| 107558 | + w.xSelectCallback2 = selectRefLeave; | |
| 107559 | + w.u.pRefSrcList = &x; | |
| 107560 | + x.db = pParse->db; | |
| 107561 | + x.pRef = pSrcList; | |
| 107562 | + assert( pExpr->op==TK_AGG_FUNCTION ); | |
| 107494 | 107563 | assert( ExprUseXList(pExpr) ); |
| 107495 | 107564 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 107496 | 107565 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 107497 | 107566 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 107498 | 107567 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 107499 | 107568 | } |
| 107500 | 107569 | #endif |
| 107501 | - return cnt.nThis>0 || cnt.nOther==0; | |
| 107570 | + sqlite3DbFree(pParse->db, x.aiExclude); | |
| 107571 | + if( w.eCode & 0x01 ){ | |
| 107572 | + return 1; | |
| 107573 | + }else if( w.eCode ){ | |
| 107574 | + return 0; | |
| 107575 | + }else{ | |
| 107576 | + return -1; | |
| 107577 | + } | |
| 107502 | 107578 | } |
| 107503 | 107579 | |
| 107504 | 107580 | /* |
| 107505 | 107581 | ** This is a Walker expression node callback. |
| 107506 | 107582 | ** |
| @@ -115414,10 +115490,11 @@ | ||
| 115414 | 115490 | |
| 115415 | 115491 | assert( IsVirtual(pTab) ); |
| 115416 | 115492 | pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->u.vtab.azArg[0]); |
| 115417 | 115493 | if( pMod==0 ) return; |
| 115418 | 115494 | if( NEVER(pMod->pModule==0) ) return; |
| 115495 | + if( pMod->pModule->iVersion<3 ) return; | |
| 115419 | 115496 | if( pMod->pModule->xShadowName==0 ) return; |
| 115420 | 115497 | assert( pTab->zName!=0 ); |
| 115421 | 115498 | nName = sqlite3Strlen30(pTab->zName); |
| 115422 | 115499 | for(k=sqliteHashFirst(&pTab->pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 115423 | 115500 | Table *pOther = sqliteHashData(k); |
| @@ -116321,10 +116398,13 @@ | ||
| 116321 | 116398 | if( sqlite3StrNICmp(pTab->zName+7, "parameters", 10)==0 ) return 0; |
| 116322 | 116399 | return 1; |
| 116323 | 116400 | } |
| 116324 | 116401 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ |
| 116325 | 116402 | return 1; |
| 116403 | + } | |
| 116404 | + if( pTab->tabFlags & TF_Eponymous ){ | |
| 116405 | + return 1; | |
| 116326 | 116406 | } |
| 116327 | 116407 | return 0; |
| 116328 | 116408 | } |
| 116329 | 116409 | |
| 116330 | 116410 | /* |
| @@ -127801,11 +127881,11 @@ | ||
| 127801 | 127881 | /* Version 3.34.0 and later */ |
| 127802 | 127882 | #define sqlite3_txn_state sqlite3_api->txn_state |
| 127803 | 127883 | /* Version 3.36.1 and later */ |
| 127804 | 127884 | #define sqlite3_changes64 sqlite3_api->changes64 |
| 127805 | 127885 | #define sqlite3_total_changes64 sqlite3_api->total_changes64 |
| 127806 | -* Version 3.37.0 and later */ | |
| 127886 | +/* Version 3.37.0 and later */ | |
| 127807 | 127887 | #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages |
| 127808 | 127888 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 127809 | 127889 | |
| 127810 | 127890 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 127811 | 127891 | /* This case when the file really is being compiled as a loadable |
| @@ -138037,31 +138117,43 @@ | ||
| 138037 | 138117 | ** |
| 138038 | 138118 | ** SELECT count(*) FROM <tbl> |
| 138039 | 138119 | ** |
| 138040 | 138120 | ** where table is a database table, not a sub-select or view. If the query |
| 138041 | 138121 | ** does match this pattern, then a pointer to the Table object representing |
| 138042 | -** <tbl> is returned. Otherwise, 0 is returned. | |
| 138122 | +** <tbl> is returned. Otherwise, NULL is returned. | |
| 138123 | +** | |
| 138124 | +** This routine a condition for the count optimization. A correct answer | |
| 138125 | +** is obtained (though perhaps more slowly) if this routine returns NULL when | |
| 138126 | +** it could have returned a table pointer. But returning the pointer when | |
| 138127 | +** NULL should have been returned can result in incorrect answers and/or | |
| 138128 | +** crashes. So, when in doubt, return NULL. | |
| 138043 | 138129 | */ |
| 138044 | 138130 | static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ |
| 138045 | 138131 | Table *pTab; |
| 138046 | 138132 | Expr *pExpr; |
| 138047 | 138133 | |
| 138048 | 138134 | assert( !p->pGroupBy ); |
| 138049 | 138135 | |
| 138050 | - if( p->pWhere || p->pEList->nExpr!=1 | |
| 138051 | - || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect | |
| 138136 | + if( p->pWhere | |
| 138137 | + || p->pEList->nExpr!=1 | |
| 138138 | + || p->pSrc->nSrc!=1 | |
| 138139 | + || p->pSrc->a[0].pSelect | |
| 138140 | + || pAggInfo->nFunc!=1 | |
| 138052 | 138141 | ){ |
| 138053 | 138142 | return 0; |
| 138054 | 138143 | } |
| 138055 | 138144 | pTab = p->pSrc->a[0].pTab; |
| 138145 | + assert( pTab!=0 ); | |
| 138146 | + assert( !IsView(pTab) ); | |
| 138147 | + if( !IsOrdinaryTable(pTab) ) return 0; | |
| 138056 | 138148 | pExpr = p->pEList->a[0].pExpr; |
| 138057 | - assert( pTab && !IsView(pTab) && pExpr ); | |
| 138058 | - | |
| 138059 | - if( IsVirtual(pTab) ) return 0; | |
| 138149 | + assert( pExpr!=0 ); | |
| 138060 | 138150 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; |
| 138061 | - if( NEVER(pAggInfo->nFunc==0) ) return 0; | |
| 138062 | 138151 | if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0; |
| 138152 | + assert( pAggInfo->aFunc[0].pFExpr==pExpr ); | |
| 138153 | + testcase( ExprHasProperty(pExpr, EP_Distinct) ); | |
| 138154 | + testcase( ExprHasProperty(pExpr, EP_WinFunc) ); | |
| 138063 | 138155 | if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0; |
| 138064 | 138156 | |
| 138065 | 138157 | return pTab; |
| 138066 | 138158 | } |
| 138067 | 138159 | |
| @@ -145189,11 +145281,14 @@ | ||
| 145189 | 145281 | SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){ |
| 145190 | 145282 | int rc = SQLITE_OK; |
| 145191 | 145283 | Table *pTab; |
| 145192 | 145284 | |
| 145193 | 145285 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); |
| 145194 | - if( pTab!=0 && ALWAYS(IsVirtual(pTab)) && ALWAYS(pTab->u.vtab.p!=0) ){ | |
| 145286 | + if( ALWAYS(pTab!=0) | |
| 145287 | + && ALWAYS(IsVirtual(pTab)) | |
| 145288 | + && ALWAYS(pTab->u.vtab.p!=0) | |
| 145289 | + ){ | |
| 145195 | 145290 | VTable *p; |
| 145196 | 145291 | int (*xDestroy)(sqlite3_vtab *); |
| 145197 | 145292 | for(p=pTab->u.vtab.p; p; p=p->pNext){ |
| 145198 | 145293 | assert( p->pVtab ); |
| 145199 | 145294 | if( p->pVtab->nRef>0 ){ |
| @@ -155813,10 +155908,11 @@ | ||
| 155813 | 155908 | ** program. |
| 155814 | 155909 | */ |
| 155815 | 155910 | for(ii=0; ii<nTabList; ii++){ |
| 155816 | 155911 | int addrExplain; |
| 155817 | 155912 | int wsFlags; |
| 155913 | + if( pParse->nErr ) goto whereBeginError; | |
| 155818 | 155914 | pLevel = &pWInfo->a[ii]; |
| 155819 | 155915 | wsFlags = pLevel->pWLoop->wsFlags; |
| 155820 | 155916 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155821 | 155917 | if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){ |
| 155822 | 155918 | constructAutomaticIndex(pParse, &pWInfo->sWC, |
| @@ -157266,11 +157362,15 @@ | ||
| 157266 | 157362 | } |
| 157267 | 157363 | }else{ |
| 157268 | 157364 | sqlite3SelectDelete(db, pSub); |
| 157269 | 157365 | } |
| 157270 | 157366 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| 157271 | - sqlite3DbFree(db, pTab); | |
| 157367 | + | |
| 157368 | + /* Defer deleting the temporary table pTab because if an error occurred, | |
| 157369 | + ** there could still be references to that table embedded in the | |
| 157370 | + ** result-set or ORDER BY clause of the SELECT statement p. */ | |
| 157371 | + sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab); | |
| 157272 | 157372 | } |
| 157273 | 157373 | |
| 157274 | 157374 | if( rc ){ |
| 157275 | 157375 | if( pParse->nErr==0 ){ |
| 157276 | 157376 | assert( pParse->db->mallocFailed ); |
| @@ -160713,13 +160813,13 @@ | ||
| 160713 | 160813 | yyStackEntry *yystackEnd; /* Last entry in the stack */ |
| 160714 | 160814 | #endif |
| 160715 | 160815 | }; |
| 160716 | 160816 | typedef struct yyParser yyParser; |
| 160717 | 160817 | |
| 160818 | +/* #include <assert.h> */ | |
| 160718 | 160819 | #ifndef NDEBUG |
| 160719 | 160820 | /* #include <stdio.h> */ |
| 160720 | -/* #include <assert.h> */ | |
| 160721 | 160821 | static FILE *yyTraceFILE = 0; |
| 160722 | 160822 | static char *yyTracePrompt = 0; |
| 160723 | 160823 | #endif /* NDEBUG */ |
| 160724 | 160824 | |
| 160725 | 160825 | #ifndef NDEBUG |
| @@ -164464,12 +164564,12 @@ | ||
| 164464 | 164564 | assert( yypParser->yytos>=yypParser->yystack ); |
| 164465 | 164565 | assert( yyact==yypParser->yytos->stateno ); |
| 164466 | 164566 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); |
| 164467 | 164567 | if( yyact >= YY_MIN_REDUCE ){ |
| 164468 | 164568 | unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ |
| 164469 | - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); | |
| 164470 | 164569 | #ifndef NDEBUG |
| 164570 | + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); | |
| 164471 | 164571 | if( yyTraceFILE ){ |
| 164472 | 164572 | int yysize = yyRuleInfoNRhs[yyruleno]; |
| 164473 | 164573 | if( yysize ){ |
| 164474 | 164574 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 164475 | 164575 | yyTracePrompt, |
| @@ -169582,12 +169682,12 @@ | ||
| 169582 | 169682 | ** |
| 169583 | 169683 | ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were |
| 169584 | 169684 | ** dealt with in the previous code block. Besides these, the only |
| 169585 | 169685 | ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, |
| 169586 | 169686 | ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, |
| 169587 | - ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask | |
| 169588 | - ** off all other flags. | |
| 169687 | + ** SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_EXRESCODE, and some reserved | |
| 169688 | + ** bits. Silently mask off all other flags. | |
| 169589 | 169689 | */ |
| 169590 | 169690 | flags &= ~( SQLITE_OPEN_DELETEONCLOSE | |
| 169591 | 169691 | SQLITE_OPEN_EXCLUSIVE | |
| 169592 | 169692 | SQLITE_OPEN_MAIN_DB | |
| 169593 | 169693 | SQLITE_OPEN_TEMP_DB | |
| @@ -169618,11 +169718,11 @@ | ||
| 169618 | 169718 | if( isThreadsafe==0 ){ |
| 169619 | 169719 | sqlite3MutexWarnOnContention(db->mutex); |
| 169620 | 169720 | } |
| 169621 | 169721 | } |
| 169622 | 169722 | sqlite3_mutex_enter(db->mutex); |
| 169623 | - db->errMask = 0xff; | |
| 169723 | + db->errMask = (flags & SQLITE_OPEN_EXRESCODE)!=0 ? 0xffffffff : 0xff; | |
| 169624 | 169724 | db->nDb = 2; |
| 169625 | 169725 | db->eOpenState = SQLITE_STATE_BUSY; |
| 169626 | 169726 | db->aDb = db->aDbStatic; |
| 169627 | 169727 | db->lookaside.bDisable = 1; |
| 169628 | 169728 | db->lookaside.sz = 0; |
| @@ -169850,12 +169950,12 @@ | ||
| 169850 | 169950 | assert( db->mutex!=0 || isThreadsafe==0 |
| 169851 | 169951 | || sqlite3GlobalConfig.bFullMutex==0 ); |
| 169852 | 169952 | sqlite3_mutex_leave(db->mutex); |
| 169853 | 169953 | } |
| 169854 | 169954 | rc = sqlite3_errcode(db); |
| 169855 | - assert( db!=0 || rc==SQLITE_NOMEM ); | |
| 169856 | - if( rc==SQLITE_NOMEM ){ | |
| 169955 | + assert( db!=0 || (rc&0xff)==SQLITE_NOMEM ); | |
| 169956 | + if( (rc&0xff)==SQLITE_NOMEM ){ | |
| 169857 | 169957 | sqlite3_close(db); |
| 169858 | 169958 | db = 0; |
| 169859 | 169959 | }else if( rc!=SQLITE_OK ){ |
| 169860 | 169960 | db->eOpenState = SQLITE_STATE_SICK; |
| 169861 | 169961 | } |
| @@ -169866,11 +169966,11 @@ | ||
| 169866 | 169966 | void *pArg = sqlite3GlobalConfig.pSqllogArg; |
| 169867 | 169967 | sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0); |
| 169868 | 169968 | } |
| 169869 | 169969 | #endif |
| 169870 | 169970 | sqlite3_free_filename(zOpen); |
| 169871 | - return rc & 0xff; | |
| 169971 | + return rc; | |
| 169872 | 169972 | } |
| 169873 | 169973 | |
| 169874 | 169974 | |
| 169875 | 169975 | /* |
| 169876 | 169976 | ** Open a new database handle. |
| @@ -178416,10 +178516,13 @@ | ||
| 178416 | 178516 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| 178417 | 178517 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 178418 | 178518 | if( bEofSave==0 && pNear->iDocid==iDocid ) break; |
| 178419 | 178519 | } |
| 178420 | 178520 | assert( rc!=SQLITE_OK || pPhrase->bIncr==0 ); |
| 178521 | + if( rc==SQLITE_OK && pNear->bEof!=bEofSave ){ | |
| 178522 | + rc = FTS_CORRUPT_VTAB; | |
| 178523 | + } | |
| 178421 | 178524 | } |
| 178422 | 178525 | if( bTreeEof ){ |
| 178423 | 178526 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| 178424 | 178527 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 178425 | 178528 | } |
| @@ -190106,17 +190209,17 @@ | ||
| 190106 | 190209 | int iEnd = 0; |
| 190107 | 190210 | int iCurrent = 0; |
| 190108 | 190211 | const char *zDoc; |
| 190109 | 190212 | int nDoc; |
| 190110 | 190213 | |
| 190111 | - /* Initialize the contents of sCtx.aTerm[] for column iCol. There is | |
| 190112 | - ** no way that this operation can fail, so the return code from | |
| 190113 | - ** fts3ExprIterate() can be discarded. | |
| 190214 | + /* Initialize the contents of sCtx.aTerm[] for column iCol. This | |
| 190215 | + ** operation may fail if the database contains corrupt records. | |
| 190114 | 190216 | */ |
| 190115 | 190217 | sCtx.iCol = iCol; |
| 190116 | 190218 | sCtx.iTerm = 0; |
| 190117 | - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); | |
| 190219 | + rc = fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); | |
| 190220 | + if( rc!=SQLITE_OK ) goto offsets_out; | |
| 190118 | 190221 | |
| 190119 | 190222 | /* Retreive the text stored in column iCol. If an SQL NULL is stored |
| 190120 | 190223 | ** in column iCol, jump immediately to the next iteration of the loop. |
| 190121 | 190224 | ** If an OOM occurs while retrieving the data (this can happen if SQLite |
| 190122 | 190225 | ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM |
| @@ -201672,10 +201775,17 @@ | ||
| 201672 | 201775 | ** Swap two objects of type TYPE. |
| 201673 | 201776 | */ |
| 201674 | 201777 | #if !defined(SQLITE_AMALGAMATION) |
| 201675 | 201778 | # define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} |
| 201676 | 201779 | #endif |
| 201780 | + | |
| 201781 | +/* | |
| 201782 | +** Name of the URI option that causes RBU to take an exclusive lock as | |
| 201783 | +** part of the incremental checkpoint operation. | |
| 201784 | +*/ | |
| 201785 | +#define RBU_EXCLUSIVE_CHECKPOINT "rbu_exclusive_checkpoint" | |
| 201786 | + | |
| 201677 | 201787 | |
| 201678 | 201788 | /* |
| 201679 | 201789 | ** The rbu_state table is used to save the state of a partially applied |
| 201680 | 201790 | ** update so that it can be resumed later. The table consists of integer |
| 201681 | 201791 | ** keys mapped to values as follows: |
| @@ -204319,17 +204429,23 @@ | ||
| 204319 | 204429 | |
| 204320 | 204430 | |
| 204321 | 204431 | /* |
| 204322 | 204432 | ** Open the database handle and attach the RBU database as "rbu". If an |
| 204323 | 204433 | ** error occurs, leave an error code and message in the RBU handle. |
| 204434 | +** | |
| 204435 | +** If argument dbMain is not NULL, then it is a database handle already | |
| 204436 | +** open on the target database. Use this handle instead of opening a new | |
| 204437 | +** one. | |
| 204324 | 204438 | */ |
| 204325 | -static void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){ | |
| 204439 | +static void rbuOpenDatabase(sqlite3rbu *p, sqlite3 *dbMain, int *pbRetry){ | |
| 204326 | 204440 | assert( p->rc || (p->dbMain==0 && p->dbRbu==0) ); |
| 204327 | 204441 | assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 ); |
| 204442 | + assert( dbMain==0 || rbuIsVacuum(p)==0 ); | |
| 204328 | 204443 | |
| 204329 | 204444 | /* Open the RBU database */ |
| 204330 | 204445 | p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1); |
| 204446 | + p->dbMain = dbMain; | |
| 204331 | 204447 | |
| 204332 | 204448 | if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){ |
| 204333 | 204449 | sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p); |
| 204334 | 204450 | if( p->zState==0 ){ |
| 204335 | 204451 | const char *zFile = sqlite3_db_filename(p->dbRbu, "main"); |
| @@ -204691,19 +204807,35 @@ | ||
| 204691 | 204807 | p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff); |
| 204692 | 204808 | } |
| 204693 | 204809 | |
| 204694 | 204810 | |
| 204695 | 204811 | /* |
| 204696 | -** Take an EXCLUSIVE lock on the database file. | |
| 204812 | +** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if | |
| 204813 | +** successful, or an SQLite error code otherwise. | |
| 204697 | 204814 | */ |
| 204698 | -static void rbuLockDatabase(sqlite3rbu *p){ | |
| 204699 | - sqlite3_file *pReal = p->pTargetFd->pReal; | |
| 204700 | - assert( p->rc==SQLITE_OK ); | |
| 204701 | - p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED); | |
| 204702 | - if( p->rc==SQLITE_OK ){ | |
| 204703 | - p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE); | |
| 204815 | +static int rbuLockDatabase(sqlite3 *db){ | |
| 204816 | + int rc = SQLITE_OK; | |
| 204817 | + sqlite3_file *fd = 0; | |
| 204818 | + sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd); | |
| 204819 | + | |
| 204820 | + if( fd->pMethods ){ | |
| 204821 | + rc = fd->pMethods->xLock(fd, SQLITE_LOCK_SHARED); | |
| 204822 | + if( rc==SQLITE_OK ){ | |
| 204823 | + rc = fd->pMethods->xLock(fd, SQLITE_LOCK_EXCLUSIVE); | |
| 204824 | + } | |
| 204704 | 204825 | } |
| 204826 | + return rc; | |
| 204827 | +} | |
| 204828 | + | |
| 204829 | +/* | |
| 204830 | +** Return true if the database handle passed as the only argument | |
| 204831 | +** was opened with the rbu_exclusive_checkpoint=1 URI parameter | |
| 204832 | +** specified. Or false otherwise. | |
| 204833 | +*/ | |
| 204834 | +static int rbuExclusiveCheckpoint(sqlite3 *db){ | |
| 204835 | + const char *zUri = sqlite3_db_filename(db, 0); | |
| 204836 | + return sqlite3_uri_boolean(zUri, RBU_EXCLUSIVE_CHECKPOINT, 0); | |
| 204705 | 204837 | } |
| 204706 | 204838 | |
| 204707 | 204839 | #if defined(_WIN32_WCE) |
| 204708 | 204840 | static LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){ |
| 204709 | 204841 | int nChar; |
| @@ -204757,22 +204889,28 @@ | ||
| 204757 | 204889 | ** in WAL mode). So no other connection may be writing the db. |
| 204758 | 204890 | ** |
| 204759 | 204891 | ** In order to ensure that there are no database readers, an EXCLUSIVE |
| 204760 | 204892 | ** lock is obtained here before the *-oal is moved to *-wal. |
| 204761 | 204893 | */ |
| 204762 | - rbuLockDatabase(p); | |
| 204894 | + sqlite3 *dbMain = 0; | |
| 204895 | + rbuFileSuffix3(zBase, zWal); | |
| 204896 | + rbuFileSuffix3(zBase, zOal); | |
| 204897 | + | |
| 204898 | + /* Re-open the databases. */ | |
| 204899 | + rbuObjIterFinalize(&p->objiter); | |
| 204900 | + sqlite3_close(p->dbRbu); | |
| 204901 | + sqlite3_close(p->dbMain); | |
| 204902 | + p->dbMain = 0; | |
| 204903 | + p->dbRbu = 0; | |
| 204904 | + | |
| 204905 | + dbMain = rbuOpenDbhandle(p, p->zTarget, 1); | |
| 204906 | + if( dbMain ){ | |
| 204907 | + assert( p->rc==SQLITE_OK ); | |
| 204908 | + p->rc = rbuLockDatabase(dbMain); | |
| 204909 | + } | |
| 204910 | + | |
| 204763 | 204911 | if( p->rc==SQLITE_OK ){ |
| 204764 | - rbuFileSuffix3(zBase, zWal); | |
| 204765 | - rbuFileSuffix3(zBase, zOal); | |
| 204766 | - | |
| 204767 | - /* Re-open the databases. */ | |
| 204768 | - rbuObjIterFinalize(&p->objiter); | |
| 204769 | - sqlite3_close(p->dbRbu); | |
| 204770 | - sqlite3_close(p->dbMain); | |
| 204771 | - p->dbMain = 0; | |
| 204772 | - p->dbRbu = 0; | |
| 204773 | - | |
| 204774 | 204912 | #if defined(_WIN32_WCE) |
| 204775 | 204913 | { |
| 204776 | 204914 | LPWSTR zWideOal; |
| 204777 | 204915 | LPWSTR zWideWal; |
| 204778 | 204916 | |
| @@ -204795,15 +204933,23 @@ | ||
| 204795 | 204933 | } |
| 204796 | 204934 | } |
| 204797 | 204935 | #else |
| 204798 | 204936 | p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK; |
| 204799 | 204937 | #endif |
| 204938 | + } | |
| 204800 | 204939 | |
| 204801 | - if( p->rc==SQLITE_OK ){ | |
| 204802 | - rbuOpenDatabase(p, 0); | |
| 204803 | - rbuSetupCheckpoint(p, 0); | |
| 204804 | - } | |
| 204940 | + if( p->rc!=SQLITE_OK | |
| 204941 | + || rbuIsVacuum(p) | |
| 204942 | + || rbuExclusiveCheckpoint(dbMain)==0 | |
| 204943 | + ){ | |
| 204944 | + sqlite3_close(dbMain); | |
| 204945 | + dbMain = 0; | |
| 204946 | + } | |
| 204947 | + | |
| 204948 | + if( p->rc==SQLITE_OK ){ | |
| 204949 | + rbuOpenDatabase(p, dbMain, 0); | |
| 204950 | + rbuSetupCheckpoint(p, 0); | |
| 204805 | 204951 | } |
| 204806 | 204952 | } |
| 204807 | 204953 | |
| 204808 | 204954 | sqlite3_free(zWal); |
| 204809 | 204955 | sqlite3_free(zOal); |
| @@ -205550,13 +205696,13 @@ | ||
| 205550 | 205696 | ** to be a wal-mode db. But, this may have happened due to an earlier |
| 205551 | 205697 | ** RBU vacuum operation leaving an old wal file in the directory. |
| 205552 | 205698 | ** If this is the case, it will have been checkpointed and deleted |
| 205553 | 205699 | ** when the handle was closed and a second attempt to open the |
| 205554 | 205700 | ** database may succeed. */ |
| 205555 | - rbuOpenDatabase(p, &bRetry); | |
| 205701 | + rbuOpenDatabase(p, 0, &bRetry); | |
| 205556 | 205702 | if( bRetry ){ |
| 205557 | - rbuOpenDatabase(p, 0); | |
| 205703 | + rbuOpenDatabase(p, 0, 0); | |
| 205558 | 205704 | } |
| 205559 | 205705 | } |
| 205560 | 205706 | |
| 205561 | 205707 | if( p->rc==SQLITE_OK ){ |
| 205562 | 205708 | pState = rbuLoadState(p); |
| @@ -205647,10 +205793,18 @@ | ||
| 205647 | 205793 | } |
| 205648 | 205794 | } |
| 205649 | 205795 | }else if( p->eStage==RBU_STAGE_MOVE ){ |
| 205650 | 205796 | /* no-op */ |
| 205651 | 205797 | }else if( p->eStage==RBU_STAGE_CKPT ){ |
| 205798 | + if( !rbuIsVacuum(p) && rbuExclusiveCheckpoint(p->dbMain) ){ | |
| 205799 | + /* If the rbu_exclusive_checkpoint=1 URI parameter was specified | |
| 205800 | + ** and an incremental checkpoint is being resumed, attempt an | |
| 205801 | + ** exclusive lock on the db file. If this fails, so be it. */ | |
| 205802 | + p->eStage = RBU_STAGE_DONE; | |
| 205803 | + rbuLockDatabase(p->dbMain); | |
| 205804 | + p->eStage = RBU_STAGE_CKPT; | |
| 205805 | + } | |
| 205652 | 205806 | rbuSetupCheckpoint(p, pState); |
| 205653 | 205807 | }else if( p->eStage==RBU_STAGE_DONE ){ |
| 205654 | 205808 | p->rc = SQLITE_DONE; |
| 205655 | 205809 | }else{ |
| 205656 | 205810 | p->rc = SQLITE_CORRUPT; |
| @@ -205684,11 +205838,10 @@ | ||
| 205684 | 205838 | const char *zTarget, |
| 205685 | 205839 | const char *zRbu, |
| 205686 | 205840 | const char *zState |
| 205687 | 205841 | ){ |
| 205688 | 205842 | if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); } |
| 205689 | - /* TODO: Check that zTarget and zRbu are non-NULL */ | |
| 205690 | 205843 | return openRbuHandle(zTarget, zRbu, zState); |
| 205691 | 205844 | } |
| 205692 | 205845 | |
| 205693 | 205846 | /* |
| 205694 | 205847 | ** Open a handle to begin or resume an RBU VACUUM operation. |
| @@ -215805,13 +215958,13 @@ | ||
| 215805 | 215958 | fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */ |
| 215806 | 215959 | #endif |
| 215807 | 215960 | }; |
| 215808 | 215961 | typedef struct fts5yyParser fts5yyParser; |
| 215809 | 215962 | |
| 215810 | -#ifndef NDEBUG | |
| 215811 | -/* #include <stdio.h> */ | |
| 215812 | 215963 | /* #include <assert.h> */ |
| 215964 | +#ifndef NDEBUG | |
| 215965 | +/* #include <stdio.h> */ | |
| 215813 | 215966 | static FILE *fts5yyTraceFILE = 0; |
| 215814 | 215967 | static char *fts5yyTracePrompt = 0; |
| 215815 | 215968 | #endif /* NDEBUG */ |
| 215816 | 215969 | |
| 215817 | 215970 | #ifndef NDEBUG |
| @@ -216744,12 +216897,12 @@ | ||
| 216744 | 216897 | assert( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystack ); |
| 216745 | 216898 | assert( fts5yyact==fts5yypParser->fts5yytos->stateno ); |
| 216746 | 216899 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); |
| 216747 | 216900 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ |
| 216748 | 216901 | unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */ |
| 216749 | - assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); | |
| 216750 | 216902 | #ifndef NDEBUG |
| 216903 | + assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); | |
| 216751 | 216904 | if( fts5yyTraceFILE ){ |
| 216752 | 216905 | int fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; |
| 216753 | 216906 | if( fts5yysize ){ |
| 216754 | 216907 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 216755 | 216908 | fts5yyTracePrompt, |
| @@ -232260,11 +232413,11 @@ | ||
| 232260 | 232413 | int nArg, /* Number of args */ |
| 232261 | 232414 | sqlite3_value **apUnused /* Function arguments */ |
| 232262 | 232415 | ){ |
| 232263 | 232416 | assert( nArg==0 ); |
| 232264 | 232417 | UNUSED_PARAM2(nArg, apUnused); |
| 232265 | - sqlite3_result_text(pCtx, "fts5: 2021-11-02 17:55:01 1d9004cd015073853ce0ca811a68ea5411733eedee993b97a38a42ba139d7590", -1, SQLITE_TRANSIENT); | |
| 232418 | + sqlite3_result_text(pCtx, "fts5: 2021-11-09 13:31:42 de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae", -1, SQLITE_TRANSIENT); | |
| 232266 | 232419 | } |
| 232267 | 232420 | |
| 232268 | 232421 | /* |
| 232269 | 232422 | ** Return true if zName is the extension on one of the shadow tables used |
| 232270 | 232423 | ** by this module. |
| 232271 | 232424 |
| --- src/sqlite3.c | |
| +++ src/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.37.0" |
| 456 | #define SQLITE_VERSION_NUMBER 3037000 |
| 457 | #define SQLITE_SOURCE_ID "2021-11-04 14:04:20 9147390d9885a37a62edc1058f313434627f1b59965c890877d2cb119e355c78" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -913,10 +913,11 @@ | |
| 913 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 914 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 915 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 916 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 917 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 918 | |
| 919 | /* Reserved: 0x00F00000 */ |
| 920 | /* Legacy compatibility: */ |
| 921 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
| 922 | |
| @@ -3732,10 +3733,18 @@ | |
| 3732 | ** |
| 3733 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 3734 | ** <dd>The database is opened [shared cache] disabled, overriding |
| 3735 | ** the default shared cache setting provided by |
| 3736 | ** [sqlite3_enable_shared_cache()].)^ |
| 3737 | ** |
| 3738 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 3739 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 3740 | ** </dl>)^ |
| 3741 | ** |
| @@ -18901,12 +18910,12 @@ | |
| 18901 | union { /* Extra data for callback */ |
| 18902 | NameContext *pNC; /* Naming context */ |
| 18903 | int n; /* A counter */ |
| 18904 | int iCur; /* A cursor number */ |
| 18905 | SrcList *pSrcList; /* FROM clause */ |
| 18906 | struct SrcCount *pSrcCount; /* Counting column references */ |
| 18907 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 18908 | int *aiCol; /* array of column indexes */ |
| 18909 | struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 18910 | struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */ |
| 18911 | ExprList *pGroupBy; /* GROUP BY clause */ |
| 18912 | Select *pSelect; /* HAVING to WHERE clause ctx */ |
| @@ -19560,11 +19569,11 @@ | |
| 19560 | SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int); |
| 19561 | SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); |
| 19562 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 19563 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 19564 | SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |
| 19565 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); |
| 19566 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 19567 | #ifndef SQLITE_UNTESTABLE |
| 19568 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| 19569 | SQLITE_PRIVATE void sqlite3PrngRestoreState(void); |
| 19570 | #endif |
| @@ -22193,11 +22202,15 @@ | |
| 22193 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 22194 | #endif |
| 22195 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); |
| 22196 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 22197 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 22198 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 22199 | #ifdef SQLITE_DEBUG |
| 22200 | SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); |
| 22201 | #endif |
| 22202 | SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); |
| 22203 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| @@ -48826,12 +48839,13 @@ | |
| 48826 | */ |
| 48827 | static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ |
| 48828 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48829 | int rc = SQLITE_OK; |
| 48830 | memdbEnter(p); |
| 48831 | if( NEVER(size>p->sz) ){ |
| 48832 | rc = SQLITE_FULL; |
| 48833 | }else{ |
| 48834 | p->sz = size; |
| 48835 | } |
| 48836 | memdbLeave(p); |
| 48837 | return rc; |
| @@ -78041,19 +78055,35 @@ | |
| 78041 | |
| 78042 | /* |
| 78043 | ** Delete any previous value and set the value to be a BLOB of length |
| 78044 | ** n containing all zeros. |
| 78045 | */ |
| 78046 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ |
| 78047 | sqlite3VdbeMemRelease(pMem); |
| 78048 | pMem->flags = MEM_Blob|MEM_Zero; |
| 78049 | pMem->n = 0; |
| 78050 | if( n<0 ) n = 0; |
| 78051 | pMem->u.nZero = n; |
| 78052 | pMem->enc = SQLITE_UTF8; |
| 78053 | pMem->z = 0; |
| 78054 | } |
| 78055 | |
| 78056 | /* |
| 78057 | ** The pMem is known to contain content that needs to be destroyed prior |
| 78058 | ** to a value change. So invoke the destructor, then set the value to |
| 78059 | ** a 64-bit integer. |
| @@ -84914,12 +84944,16 @@ | |
| 84914 | Mem *pOut = pCtx->pOut; |
| 84915 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 84916 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 84917 | return SQLITE_TOOBIG; |
| 84918 | } |
| 84919 | sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 84920 | return SQLITE_OK; |
| 84921 | } |
| 84922 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 84923 | pCtx->isError = errCode ? errCode : -1; |
| 84924 | #ifdef SQLITE_DEBUG |
| 84925 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| @@ -85927,11 +85961,15 @@ | |
| 85927 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ |
| 85928 | int rc; |
| 85929 | Vdbe *p = (Vdbe *)pStmt; |
| 85930 | rc = vdbeUnbind(p, i); |
| 85931 | if( rc==SQLITE_OK ){ |
| 85932 | sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); |
| 85933 | sqlite3_mutex_leave(p->db->mutex); |
| 85934 | } |
| 85935 | return rc; |
| 85936 | } |
| 85937 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| @@ -100579,19 +100617,22 @@ | |
| 100579 | sqlite3WindowLink(pSel, pWin); |
| 100580 | pNC->ncFlags |= NC_HasWin; |
| 100581 | }else |
| 100582 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 100583 | { |
| 100584 | NameContext *pNC2 = pNC; |
| 100585 | pExpr->op = TK_AGG_FUNCTION; |
| 100586 | pExpr->op2 = 0; |
| 100587 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100588 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 100589 | sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); |
| 100590 | } |
| 100591 | #endif |
| 100592 | while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){ |
| 100593 | pExpr->op2++; |
| 100594 | pNC2 = pNC2->pNext; |
| 100595 | } |
| 100596 | assert( pDef!=0 || IN_RENAME_OBJECT ); |
| 100597 | if( pNC2 && pDef ){ |
| @@ -101557,12 +101598,12 @@ | |
| 101557 | |
| 101558 | /* |
| 101559 | ** Return the affinity character for a single column of a table. |
| 101560 | */ |
| 101561 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(const Table *pTab, int iCol){ |
| 101562 | assert( iCol<pTab->nCol ); |
| 101563 | return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER; |
| 101564 | } |
| 101565 | |
| 101566 | /* |
| 101567 | ** Return the 'affinity' of the expression pExpr if any. |
| 101568 | ** |
| @@ -107414,93 +107455,128 @@ | |
| 107414 | sqlite3WalkExpr(&w, pExpr); |
| 107415 | return !w.eCode; |
| 107416 | } |
| 107417 | |
| 107418 | |
| 107419 | /* |
| 107420 | ** An instance of the following structure is used by the tree walker |
| 107421 | ** to count references to table columns in the arguments of an |
| 107422 | ** aggregate function, in order to implement the |
| 107423 | ** sqlite3FunctionThisSrc() routine. |
| 107424 | */ |
| 107425 | struct SrcCount { |
| 107426 | SrcList *pSrc; /* One particular FROM clause in a nested query */ |
| 107427 | int iSrcInner; /* Smallest cursor number in this context */ |
| 107428 | int nThis; /* Number of references to columns in pSrcList */ |
| 107429 | int nOther; /* Number of references to columns in other FROM clauses */ |
| 107430 | }; |
| 107431 | |
| 107432 | /* |
| 107433 | ** xSelect callback for sqlite3FunctionUsesThisSrc(). If this is the first |
| 107434 | ** SELECT with a FROM clause encountered during this iteration, set |
| 107435 | ** SrcCount.iSrcInner to the cursor number of the leftmost object in |
| 107436 | ** the FROM cause. |
| 107437 | */ |
| 107438 | static int selectSrcCount(Walker *pWalker, Select *pSel){ |
| 107439 | struct SrcCount *p = pWalker->u.pSrcCount; |
| 107440 | if( p->iSrcInner==0x7FFFFFFF && ALWAYS(pSel->pSrc) && pSel->pSrc->nSrc ){ |
| 107441 | pWalker->u.pSrcCount->iSrcInner = pSel->pSrc->a[0].iCursor; |
| 107442 | } |
| 107443 | return WRC_Continue; |
| 107444 | } |
| 107445 | |
| 107446 | /* |
| 107447 | ** Count the number of references to columns. |
| 107448 | */ |
| 107449 | static int exprSrcCount(Walker *pWalker, Expr *pExpr){ |
| 107450 | /* There was once a NEVER() on the second term on the grounds that |
| 107451 | ** sqlite3FunctionUsesThisSrc() was always called before |
| 107452 | ** sqlite3ExprAnalyzeAggregates() and so the TK_COLUMNs have not yet |
| 107453 | ** been converted into TK_AGG_COLUMN. But this is no longer true due |
| 107454 | ** to window functions - sqlite3WindowRewrite() may now indirectly call |
| 107455 | ** FunctionUsesThisSrc() when creating a new sub-select. */ |
| 107456 | if( pExpr->op==TK_COLUMN || pExpr->op==TK_AGG_COLUMN ){ |
| 107457 | int i; |
| 107458 | struct SrcCount *p = pWalker->u.pSrcCount; |
| 107459 | SrcList *pSrc = p->pSrc; |
| 107460 | int nSrc = pSrc ? pSrc->nSrc : 0; |
| 107461 | for(i=0; i<nSrc; i++){ |
| 107462 | if( pExpr->iTable==pSrc->a[i].iCursor ) break; |
| 107463 | } |
| 107464 | if( i<nSrc ){ |
| 107465 | p->nThis++; |
| 107466 | }else if( pExpr->iTable<p->iSrcInner ){ |
| 107467 | /* In a well-formed parse tree (no name resolution errors), |
| 107468 | ** TK_COLUMN nodes with smaller Expr.iTable values are in an |
| 107469 | ** outer context. Those are the only ones to count as "other" */ |
| 107470 | p->nOther++; |
| 107471 | } |
| 107472 | } |
| 107473 | return WRC_Continue; |
| 107474 | } |
| 107475 | |
| 107476 | /* |
| 107477 | ** Determine if any of the arguments to the pExpr Function reference |
| 107478 | ** pSrcList. Return true if they do. Also return true if the function |
| 107479 | ** has no arguments or has only constant arguments. Return false if pExpr |
| 107480 | ** references columns but not columns of tables found in pSrcList. |
| 107481 | */ |
| 107482 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){ |
| 107483 | Walker w; |
| 107484 | struct SrcCount cnt; |
| 107485 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 107486 | memset(&w, 0, sizeof(w)); |
| 107487 | w.xExprCallback = exprSrcCount; |
| 107488 | w.xSelectCallback = selectSrcCount; |
| 107489 | w.u.pSrcCount = &cnt; |
| 107490 | cnt.pSrc = pSrcList; |
| 107491 | cnt.iSrcInner = (pSrcList&&pSrcList->nSrc)?pSrcList->a[0].iCursor:0x7FFFFFFF; |
| 107492 | cnt.nThis = 0; |
| 107493 | cnt.nOther = 0; |
| 107494 | assert( ExprUseXList(pExpr) ); |
| 107495 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 107496 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 107497 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 107498 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 107499 | } |
| 107500 | #endif |
| 107501 | return cnt.nThis>0 || cnt.nOther==0; |
| 107502 | } |
| 107503 | |
| 107504 | /* |
| 107505 | ** This is a Walker expression node callback. |
| 107506 | ** |
| @@ -115414,10 +115490,11 @@ | |
| 115414 | |
| 115415 | assert( IsVirtual(pTab) ); |
| 115416 | pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->u.vtab.azArg[0]); |
| 115417 | if( pMod==0 ) return; |
| 115418 | if( NEVER(pMod->pModule==0) ) return; |
| 115419 | if( pMod->pModule->xShadowName==0 ) return; |
| 115420 | assert( pTab->zName!=0 ); |
| 115421 | nName = sqlite3Strlen30(pTab->zName); |
| 115422 | for(k=sqliteHashFirst(&pTab->pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 115423 | Table *pOther = sqliteHashData(k); |
| @@ -116321,10 +116398,13 @@ | |
| 116321 | if( sqlite3StrNICmp(pTab->zName+7, "parameters", 10)==0 ) return 0; |
| 116322 | return 1; |
| 116323 | } |
| 116324 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ |
| 116325 | return 1; |
| 116326 | } |
| 116327 | return 0; |
| 116328 | } |
| 116329 | |
| 116330 | /* |
| @@ -127801,11 +127881,11 @@ | |
| 127801 | /* Version 3.34.0 and later */ |
| 127802 | #define sqlite3_txn_state sqlite3_api->txn_state |
| 127803 | /* Version 3.36.1 and later */ |
| 127804 | #define sqlite3_changes64 sqlite3_api->changes64 |
| 127805 | #define sqlite3_total_changes64 sqlite3_api->total_changes64 |
| 127806 | * Version 3.37.0 and later */ |
| 127807 | #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages |
| 127808 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 127809 | |
| 127810 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 127811 | /* This case when the file really is being compiled as a loadable |
| @@ -138037,31 +138117,43 @@ | |
| 138037 | ** |
| 138038 | ** SELECT count(*) FROM <tbl> |
| 138039 | ** |
| 138040 | ** where table is a database table, not a sub-select or view. If the query |
| 138041 | ** does match this pattern, then a pointer to the Table object representing |
| 138042 | ** <tbl> is returned. Otherwise, 0 is returned. |
| 138043 | */ |
| 138044 | static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ |
| 138045 | Table *pTab; |
| 138046 | Expr *pExpr; |
| 138047 | |
| 138048 | assert( !p->pGroupBy ); |
| 138049 | |
| 138050 | if( p->pWhere || p->pEList->nExpr!=1 |
| 138051 | || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect |
| 138052 | ){ |
| 138053 | return 0; |
| 138054 | } |
| 138055 | pTab = p->pSrc->a[0].pTab; |
| 138056 | pExpr = p->pEList->a[0].pExpr; |
| 138057 | assert( pTab && !IsView(pTab) && pExpr ); |
| 138058 | |
| 138059 | if( IsVirtual(pTab) ) return 0; |
| 138060 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; |
| 138061 | if( NEVER(pAggInfo->nFunc==0) ) return 0; |
| 138062 | if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0; |
| 138063 | if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0; |
| 138064 | |
| 138065 | return pTab; |
| 138066 | } |
| 138067 | |
| @@ -145189,11 +145281,14 @@ | |
| 145189 | SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){ |
| 145190 | int rc = SQLITE_OK; |
| 145191 | Table *pTab; |
| 145192 | |
| 145193 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); |
| 145194 | if( pTab!=0 && ALWAYS(IsVirtual(pTab)) && ALWAYS(pTab->u.vtab.p!=0) ){ |
| 145195 | VTable *p; |
| 145196 | int (*xDestroy)(sqlite3_vtab *); |
| 145197 | for(p=pTab->u.vtab.p; p; p=p->pNext){ |
| 145198 | assert( p->pVtab ); |
| 145199 | if( p->pVtab->nRef>0 ){ |
| @@ -155813,10 +155908,11 @@ | |
| 155813 | ** program. |
| 155814 | */ |
| 155815 | for(ii=0; ii<nTabList; ii++){ |
| 155816 | int addrExplain; |
| 155817 | int wsFlags; |
| 155818 | pLevel = &pWInfo->a[ii]; |
| 155819 | wsFlags = pLevel->pWLoop->wsFlags; |
| 155820 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155821 | if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){ |
| 155822 | constructAutomaticIndex(pParse, &pWInfo->sWC, |
| @@ -157266,11 +157362,15 @@ | |
| 157266 | } |
| 157267 | }else{ |
| 157268 | sqlite3SelectDelete(db, pSub); |
| 157269 | } |
| 157270 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| 157271 | sqlite3DbFree(db, pTab); |
| 157272 | } |
| 157273 | |
| 157274 | if( rc ){ |
| 157275 | if( pParse->nErr==0 ){ |
| 157276 | assert( pParse->db->mallocFailed ); |
| @@ -160713,13 +160813,13 @@ | |
| 160713 | yyStackEntry *yystackEnd; /* Last entry in the stack */ |
| 160714 | #endif |
| 160715 | }; |
| 160716 | typedef struct yyParser yyParser; |
| 160717 | |
| 160718 | #ifndef NDEBUG |
| 160719 | /* #include <stdio.h> */ |
| 160720 | /* #include <assert.h> */ |
| 160721 | static FILE *yyTraceFILE = 0; |
| 160722 | static char *yyTracePrompt = 0; |
| 160723 | #endif /* NDEBUG */ |
| 160724 | |
| 160725 | #ifndef NDEBUG |
| @@ -164464,12 +164564,12 @@ | |
| 164464 | assert( yypParser->yytos>=yypParser->yystack ); |
| 164465 | assert( yyact==yypParser->yytos->stateno ); |
| 164466 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); |
| 164467 | if( yyact >= YY_MIN_REDUCE ){ |
| 164468 | unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ |
| 164469 | assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); |
| 164470 | #ifndef NDEBUG |
| 164471 | if( yyTraceFILE ){ |
| 164472 | int yysize = yyRuleInfoNRhs[yyruleno]; |
| 164473 | if( yysize ){ |
| 164474 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 164475 | yyTracePrompt, |
| @@ -169582,12 +169682,12 @@ | |
| 169582 | ** |
| 169583 | ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were |
| 169584 | ** dealt with in the previous code block. Besides these, the only |
| 169585 | ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, |
| 169586 | ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, |
| 169587 | ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask |
| 169588 | ** off all other flags. |
| 169589 | */ |
| 169590 | flags &= ~( SQLITE_OPEN_DELETEONCLOSE | |
| 169591 | SQLITE_OPEN_EXCLUSIVE | |
| 169592 | SQLITE_OPEN_MAIN_DB | |
| 169593 | SQLITE_OPEN_TEMP_DB | |
| @@ -169618,11 +169718,11 @@ | |
| 169618 | if( isThreadsafe==0 ){ |
| 169619 | sqlite3MutexWarnOnContention(db->mutex); |
| 169620 | } |
| 169621 | } |
| 169622 | sqlite3_mutex_enter(db->mutex); |
| 169623 | db->errMask = 0xff; |
| 169624 | db->nDb = 2; |
| 169625 | db->eOpenState = SQLITE_STATE_BUSY; |
| 169626 | db->aDb = db->aDbStatic; |
| 169627 | db->lookaside.bDisable = 1; |
| 169628 | db->lookaside.sz = 0; |
| @@ -169850,12 +169950,12 @@ | |
| 169850 | assert( db->mutex!=0 || isThreadsafe==0 |
| 169851 | || sqlite3GlobalConfig.bFullMutex==0 ); |
| 169852 | sqlite3_mutex_leave(db->mutex); |
| 169853 | } |
| 169854 | rc = sqlite3_errcode(db); |
| 169855 | assert( db!=0 || rc==SQLITE_NOMEM ); |
| 169856 | if( rc==SQLITE_NOMEM ){ |
| 169857 | sqlite3_close(db); |
| 169858 | db = 0; |
| 169859 | }else if( rc!=SQLITE_OK ){ |
| 169860 | db->eOpenState = SQLITE_STATE_SICK; |
| 169861 | } |
| @@ -169866,11 +169966,11 @@ | |
| 169866 | void *pArg = sqlite3GlobalConfig.pSqllogArg; |
| 169867 | sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0); |
| 169868 | } |
| 169869 | #endif |
| 169870 | sqlite3_free_filename(zOpen); |
| 169871 | return rc & 0xff; |
| 169872 | } |
| 169873 | |
| 169874 | |
| 169875 | /* |
| 169876 | ** Open a new database handle. |
| @@ -178416,10 +178516,13 @@ | |
| 178416 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| 178417 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 178418 | if( bEofSave==0 && pNear->iDocid==iDocid ) break; |
| 178419 | } |
| 178420 | assert( rc!=SQLITE_OK || pPhrase->bIncr==0 ); |
| 178421 | } |
| 178422 | if( bTreeEof ){ |
| 178423 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| 178424 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 178425 | } |
| @@ -190106,17 +190209,17 @@ | |
| 190106 | int iEnd = 0; |
| 190107 | int iCurrent = 0; |
| 190108 | const char *zDoc; |
| 190109 | int nDoc; |
| 190110 | |
| 190111 | /* Initialize the contents of sCtx.aTerm[] for column iCol. There is |
| 190112 | ** no way that this operation can fail, so the return code from |
| 190113 | ** fts3ExprIterate() can be discarded. |
| 190114 | */ |
| 190115 | sCtx.iCol = iCol; |
| 190116 | sCtx.iTerm = 0; |
| 190117 | (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); |
| 190118 | |
| 190119 | /* Retreive the text stored in column iCol. If an SQL NULL is stored |
| 190120 | ** in column iCol, jump immediately to the next iteration of the loop. |
| 190121 | ** If an OOM occurs while retrieving the data (this can happen if SQLite |
| 190122 | ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM |
| @@ -201672,10 +201775,17 @@ | |
| 201672 | ** Swap two objects of type TYPE. |
| 201673 | */ |
| 201674 | #if !defined(SQLITE_AMALGAMATION) |
| 201675 | # define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} |
| 201676 | #endif |
| 201677 | |
| 201678 | /* |
| 201679 | ** The rbu_state table is used to save the state of a partially applied |
| 201680 | ** update so that it can be resumed later. The table consists of integer |
| 201681 | ** keys mapped to values as follows: |
| @@ -204319,17 +204429,23 @@ | |
| 204319 | |
| 204320 | |
| 204321 | /* |
| 204322 | ** Open the database handle and attach the RBU database as "rbu". If an |
| 204323 | ** error occurs, leave an error code and message in the RBU handle. |
| 204324 | */ |
| 204325 | static void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){ |
| 204326 | assert( p->rc || (p->dbMain==0 && p->dbRbu==0) ); |
| 204327 | assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 ); |
| 204328 | |
| 204329 | /* Open the RBU database */ |
| 204330 | p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1); |
| 204331 | |
| 204332 | if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){ |
| 204333 | sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p); |
| 204334 | if( p->zState==0 ){ |
| 204335 | const char *zFile = sqlite3_db_filename(p->dbRbu, "main"); |
| @@ -204691,19 +204807,35 @@ | |
| 204691 | p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff); |
| 204692 | } |
| 204693 | |
| 204694 | |
| 204695 | /* |
| 204696 | ** Take an EXCLUSIVE lock on the database file. |
| 204697 | */ |
| 204698 | static void rbuLockDatabase(sqlite3rbu *p){ |
| 204699 | sqlite3_file *pReal = p->pTargetFd->pReal; |
| 204700 | assert( p->rc==SQLITE_OK ); |
| 204701 | p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED); |
| 204702 | if( p->rc==SQLITE_OK ){ |
| 204703 | p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE); |
| 204704 | } |
| 204705 | } |
| 204706 | |
| 204707 | #if defined(_WIN32_WCE) |
| 204708 | static LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){ |
| 204709 | int nChar; |
| @@ -204757,22 +204889,28 @@ | |
| 204757 | ** in WAL mode). So no other connection may be writing the db. |
| 204758 | ** |
| 204759 | ** In order to ensure that there are no database readers, an EXCLUSIVE |
| 204760 | ** lock is obtained here before the *-oal is moved to *-wal. |
| 204761 | */ |
| 204762 | rbuLockDatabase(p); |
| 204763 | if( p->rc==SQLITE_OK ){ |
| 204764 | rbuFileSuffix3(zBase, zWal); |
| 204765 | rbuFileSuffix3(zBase, zOal); |
| 204766 | |
| 204767 | /* Re-open the databases. */ |
| 204768 | rbuObjIterFinalize(&p->objiter); |
| 204769 | sqlite3_close(p->dbRbu); |
| 204770 | sqlite3_close(p->dbMain); |
| 204771 | p->dbMain = 0; |
| 204772 | p->dbRbu = 0; |
| 204773 | |
| 204774 | #if defined(_WIN32_WCE) |
| 204775 | { |
| 204776 | LPWSTR zWideOal; |
| 204777 | LPWSTR zWideWal; |
| 204778 | |
| @@ -204795,15 +204933,23 @@ | |
| 204795 | } |
| 204796 | } |
| 204797 | #else |
| 204798 | p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK; |
| 204799 | #endif |
| 204800 | |
| 204801 | if( p->rc==SQLITE_OK ){ |
| 204802 | rbuOpenDatabase(p, 0); |
| 204803 | rbuSetupCheckpoint(p, 0); |
| 204804 | } |
| 204805 | } |
| 204806 | } |
| 204807 | |
| 204808 | sqlite3_free(zWal); |
| 204809 | sqlite3_free(zOal); |
| @@ -205550,13 +205696,13 @@ | |
| 205550 | ** to be a wal-mode db. But, this may have happened due to an earlier |
| 205551 | ** RBU vacuum operation leaving an old wal file in the directory. |
| 205552 | ** If this is the case, it will have been checkpointed and deleted |
| 205553 | ** when the handle was closed and a second attempt to open the |
| 205554 | ** database may succeed. */ |
| 205555 | rbuOpenDatabase(p, &bRetry); |
| 205556 | if( bRetry ){ |
| 205557 | rbuOpenDatabase(p, 0); |
| 205558 | } |
| 205559 | } |
| 205560 | |
| 205561 | if( p->rc==SQLITE_OK ){ |
| 205562 | pState = rbuLoadState(p); |
| @@ -205647,10 +205793,18 @@ | |
| 205647 | } |
| 205648 | } |
| 205649 | }else if( p->eStage==RBU_STAGE_MOVE ){ |
| 205650 | /* no-op */ |
| 205651 | }else if( p->eStage==RBU_STAGE_CKPT ){ |
| 205652 | rbuSetupCheckpoint(p, pState); |
| 205653 | }else if( p->eStage==RBU_STAGE_DONE ){ |
| 205654 | p->rc = SQLITE_DONE; |
| 205655 | }else{ |
| 205656 | p->rc = SQLITE_CORRUPT; |
| @@ -205684,11 +205838,10 @@ | |
| 205684 | const char *zTarget, |
| 205685 | const char *zRbu, |
| 205686 | const char *zState |
| 205687 | ){ |
| 205688 | if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); } |
| 205689 | /* TODO: Check that zTarget and zRbu are non-NULL */ |
| 205690 | return openRbuHandle(zTarget, zRbu, zState); |
| 205691 | } |
| 205692 | |
| 205693 | /* |
| 205694 | ** Open a handle to begin or resume an RBU VACUUM operation. |
| @@ -215805,13 +215958,13 @@ | |
| 215805 | fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */ |
| 215806 | #endif |
| 215807 | }; |
| 215808 | typedef struct fts5yyParser fts5yyParser; |
| 215809 | |
| 215810 | #ifndef NDEBUG |
| 215811 | /* #include <stdio.h> */ |
| 215812 | /* #include <assert.h> */ |
| 215813 | static FILE *fts5yyTraceFILE = 0; |
| 215814 | static char *fts5yyTracePrompt = 0; |
| 215815 | #endif /* NDEBUG */ |
| 215816 | |
| 215817 | #ifndef NDEBUG |
| @@ -216744,12 +216897,12 @@ | |
| 216744 | assert( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystack ); |
| 216745 | assert( fts5yyact==fts5yypParser->fts5yytos->stateno ); |
| 216746 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); |
| 216747 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ |
| 216748 | unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */ |
| 216749 | assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); |
| 216750 | #ifndef NDEBUG |
| 216751 | if( fts5yyTraceFILE ){ |
| 216752 | int fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; |
| 216753 | if( fts5yysize ){ |
| 216754 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 216755 | fts5yyTracePrompt, |
| @@ -232260,11 +232413,11 @@ | |
| 232260 | int nArg, /* Number of args */ |
| 232261 | sqlite3_value **apUnused /* Function arguments */ |
| 232262 | ){ |
| 232263 | assert( nArg==0 ); |
| 232264 | UNUSED_PARAM2(nArg, apUnused); |
| 232265 | sqlite3_result_text(pCtx, "fts5: 2021-11-02 17:55:01 1d9004cd015073853ce0ca811a68ea5411733eedee993b97a38a42ba139d7590", -1, SQLITE_TRANSIENT); |
| 232266 | } |
| 232267 | |
| 232268 | /* |
| 232269 | ** Return true if zName is the extension on one of the shadow tables used |
| 232270 | ** by this module. |
| 232271 |
| --- src/sqlite3.c | |
| +++ src/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.37.0" |
| 456 | #define SQLITE_VERSION_NUMBER 3037000 |
| 457 | #define SQLITE_SOURCE_ID "2021-11-09 13:31:42 de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae" |
| 458 | |
| 459 | /* |
| 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | ** |
| @@ -913,10 +913,11 @@ | |
| 913 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 914 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 915 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 916 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 917 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 918 | #define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ |
| 919 | |
| 920 | /* Reserved: 0x00F00000 */ |
| 921 | /* Legacy compatibility: */ |
| 922 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
| 923 | |
| @@ -3732,10 +3733,18 @@ | |
| 3733 | ** |
| 3734 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 3735 | ** <dd>The database is opened [shared cache] disabled, overriding |
| 3736 | ** the default shared cache setting provided by |
| 3737 | ** [sqlite3_enable_shared_cache()].)^ |
| 3738 | ** |
| 3739 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> |
| 3740 | ** <dd>The database connection comes up in "extended result code mode". |
| 3741 | ** In other words, the database behaves has if |
| 3742 | ** [sqlite3_extended_result_codes(db,1)] where called on the database |
| 3743 | ** connection as soon as the connection is created. In addition to setting |
| 3744 | ** the extended result code mode, this flag also causes [sqlite3_open_v2()] |
| 3745 | ** to return an extended result code.</dd> |
| 3746 | ** |
| 3747 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 3748 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 3749 | ** </dl>)^ |
| 3750 | ** |
| @@ -18901,12 +18910,12 @@ | |
| 18910 | union { /* Extra data for callback */ |
| 18911 | NameContext *pNC; /* Naming context */ |
| 18912 | int n; /* A counter */ |
| 18913 | int iCur; /* A cursor number */ |
| 18914 | SrcList *pSrcList; /* FROM clause */ |
| 18915 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 18916 | struct RefSrcList *pRefSrcList; /* sqlite3ReferencesSrcList() */ |
| 18917 | int *aiCol; /* array of column indexes */ |
| 18918 | struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 18919 | struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */ |
| 18920 | ExprList *pGroupBy; /* GROUP BY clause */ |
| 18921 | Select *pSelect; /* HAVING to WHERE clause ctx */ |
| @@ -19560,11 +19569,11 @@ | |
| 19569 | SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int); |
| 19570 | SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); |
| 19571 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 19572 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 19573 | SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |
| 19574 | SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse*, Expr*, SrcList*); |
| 19575 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 19576 | #ifndef SQLITE_UNTESTABLE |
| 19577 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| 19578 | SQLITE_PRIVATE void sqlite3PrngRestoreState(void); |
| 19579 | #endif |
| @@ -22193,11 +22202,15 @@ | |
| 22202 | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); |
| 22203 | #endif |
| 22204 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); |
| 22205 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 22206 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 22207 | #ifndef SQLITE_OMIT_INCRBLOB |
| 22208 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 22209 | #else |
| 22210 | SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 22211 | #endif |
| 22212 | #ifdef SQLITE_DEBUG |
| 22213 | SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); |
| 22214 | #endif |
| 22215 | SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); |
| 22216 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| @@ -48826,12 +48839,13 @@ | |
| 48839 | */ |
| 48840 | static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ |
| 48841 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48842 | int rc = SQLITE_OK; |
| 48843 | memdbEnter(p); |
| 48844 | if( size>p->sz ){ |
| 48845 | /* This can only happen with a corrupt wal mode db */ |
| 48846 | rc = SQLITE_CORRUPT; |
| 48847 | }else{ |
| 48848 | p->sz = size; |
| 48849 | } |
| 48850 | memdbLeave(p); |
| 48851 | return rc; |
| @@ -78041,19 +78055,35 @@ | |
| 78055 | |
| 78056 | /* |
| 78057 | ** Delete any previous value and set the value to be a BLOB of length |
| 78058 | ** n containing all zeros. |
| 78059 | */ |
| 78060 | #ifndef SQLITE_OMIT_INCRBLOB |
| 78061 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ |
| 78062 | sqlite3VdbeMemRelease(pMem); |
| 78063 | pMem->flags = MEM_Blob|MEM_Zero; |
| 78064 | pMem->n = 0; |
| 78065 | if( n<0 ) n = 0; |
| 78066 | pMem->u.nZero = n; |
| 78067 | pMem->enc = SQLITE_UTF8; |
| 78068 | pMem->z = 0; |
| 78069 | } |
| 78070 | #else |
| 78071 | SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ |
| 78072 | int nByte = n>0?n:1; |
| 78073 | if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){ |
| 78074 | return SQLITE_NOMEM_BKPT; |
| 78075 | } |
| 78076 | assert( pMem->z!=0 ); |
| 78077 | assert( sqlite3DbMallocSize(pMem->db, pMem->z)>=nByte ); |
| 78078 | memset(pMem->z, 0, nByte); |
| 78079 | pMem->n = n>0?n:0; |
| 78080 | pMem->flags = MEM_Blob; |
| 78081 | pMem->enc = SQLITE_UTF8; |
| 78082 | return SQLITE_OK; |
| 78083 | } |
| 78084 | #endif |
| 78085 | |
| 78086 | /* |
| 78087 | ** The pMem is known to contain content that needs to be destroyed prior |
| 78088 | ** to a value change. So invoke the destructor, then set the value to |
| 78089 | ** a 64-bit integer. |
| @@ -84914,12 +84944,16 @@ | |
| 84944 | Mem *pOut = pCtx->pOut; |
| 84945 | assert( sqlite3_mutex_held(pOut->db->mutex) ); |
| 84946 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 84947 | return SQLITE_TOOBIG; |
| 84948 | } |
| 84949 | #ifndef SQLITE_OMIT_INCRBLOB |
| 84950 | sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 84951 | return SQLITE_OK; |
| 84952 | #else |
| 84953 | return sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 84954 | #endif |
| 84955 | } |
| 84956 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 84957 | pCtx->isError = errCode ? errCode : -1; |
| 84958 | #ifdef SQLITE_DEBUG |
| 84959 | if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| @@ -85927,11 +85961,15 @@ | |
| 85961 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ |
| 85962 | int rc; |
| 85963 | Vdbe *p = (Vdbe *)pStmt; |
| 85964 | rc = vdbeUnbind(p, i); |
| 85965 | if( rc==SQLITE_OK ){ |
| 85966 | #ifndef SQLITE_OMIT_INCRBLOB |
| 85967 | sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); |
| 85968 | #else |
| 85969 | rc = sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); |
| 85970 | #endif |
| 85971 | sqlite3_mutex_leave(p->db->mutex); |
| 85972 | } |
| 85973 | return rc; |
| 85974 | } |
| 85975 | SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ |
| @@ -100579,19 +100617,22 @@ | |
| 100617 | sqlite3WindowLink(pSel, pWin); |
| 100618 | pNC->ncFlags |= NC_HasWin; |
| 100619 | }else |
| 100620 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 100621 | { |
| 100622 | NameContext *pNC2; /* For looping up thru outer contexts */ |
| 100623 | pExpr->op = TK_AGG_FUNCTION; |
| 100624 | pExpr->op2 = 0; |
| 100625 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100626 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 100627 | sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); |
| 100628 | } |
| 100629 | #endif |
| 100630 | pNC2 = pNC; |
| 100631 | while( pNC2 |
| 100632 | && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 |
| 100633 | ){ |
| 100634 | pExpr->op2++; |
| 100635 | pNC2 = pNC2->pNext; |
| 100636 | } |
| 100637 | assert( pDef!=0 || IN_RENAME_OBJECT ); |
| 100638 | if( pNC2 && pDef ){ |
| @@ -101557,12 +101598,12 @@ | |
| 101598 | |
| 101599 | /* |
| 101600 | ** Return the affinity character for a single column of a table. |
| 101601 | */ |
| 101602 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(const Table *pTab, int iCol){ |
| 101603 | if( iCol<0 || NEVER(iCol>=pTab->nCol) ) return SQLITE_AFF_INTEGER; |
| 101604 | return pTab->aCol[iCol].affinity; |
| 101605 | } |
| 101606 | |
| 101607 | /* |
| 101608 | ** Return the 'affinity' of the expression pExpr if any. |
| 101609 | ** |
| @@ -107414,93 +107455,128 @@ | |
| 107455 | sqlite3WalkExpr(&w, pExpr); |
| 107456 | return !w.eCode; |
| 107457 | } |
| 107458 | |
| 107459 | |
| 107460 | /* Structure used to pass information throught the Walker in order to |
| 107461 | ** implement sqlite3ReferencesSrcList(). |
| 107462 | */ |
| 107463 | struct RefSrcList { |
| 107464 | sqlite3 *db; /* Database connection used for sqlite3DbRealloc() */ |
| 107465 | SrcList *pRef; /* Looking for references to these tables */ |
| 107466 | int nExclude; /* Number of tables to exclude from the search */ |
| 107467 | int *aiExclude; /* Cursor IDs for tables to exclude from the search */ |
| 107468 | }; |
| 107469 | |
| 107470 | /* |
| 107471 | ** Walker SELECT callbacks for sqlite3ReferencesSrcList(). |
| 107472 | ** |
| 107473 | ** When entering a new subquery on the pExpr argument, add all FROM clause |
| 107474 | ** entries for that subquery to the exclude list. |
| 107475 | ** |
| 107476 | ** When leaving the subquery, remove those entries from the exclude list. |
| 107477 | */ |
| 107478 | static int selectRefEnter(Walker *pWalker, Select *pSelect){ |
| 107479 | struct RefSrcList *p = pWalker->u.pRefSrcList; |
| 107480 | SrcList *pSrc = pSelect->pSrc; |
| 107481 | int i, j, *piNew; |
| 107482 | if( pSrc->nSrc==0 ) return WRC_Continue; |
| 107483 | j = p->nExclude; |
| 107484 | p->nExclude += pSrc->nSrc; |
| 107485 | piNew = sqlite3DbRealloc(p->db, p->aiExclude, p->nExclude*sizeof(int)); |
| 107486 | if( piNew==0 ){ |
| 107487 | p->nExclude = 0; |
| 107488 | return WRC_Abort; |
| 107489 | }else{ |
| 107490 | p->aiExclude = piNew; |
| 107491 | } |
| 107492 | for(i=0; i<pSrc->nSrc; i++, j++){ |
| 107493 | p->aiExclude[j] = pSrc->a[i].iCursor; |
| 107494 | } |
| 107495 | return WRC_Continue; |
| 107496 | } |
| 107497 | static void selectRefLeave(Walker *pWalker, Select *pSelect){ |
| 107498 | struct RefSrcList *p = pWalker->u.pRefSrcList; |
| 107499 | SrcList *pSrc = pSelect->pSrc; |
| 107500 | if( p->nExclude ){ |
| 107501 | assert( p->nExclude>=pSrc->nSrc ); |
| 107502 | p->nExclude -= pSrc->nSrc; |
| 107503 | } |
| 107504 | } |
| 107505 | |
| 107506 | /* This is the Walker EXPR callback for sqlite3ReferencesSrcList(). |
| 107507 | ** |
| 107508 | ** Set the 0x01 bit of pWalker->eCode if there is a reference to any |
| 107509 | ** of the tables shown in RefSrcList.pRef. |
| 107510 | ** |
| 107511 | ** Set the 0x02 bit of pWalker->eCode if there is a reference to a |
| 107512 | ** table is in neither RefSrcList.pRef nor RefSrcList.aiExclude. |
| 107513 | */ |
| 107514 | static int exprRefToSrcList(Walker *pWalker, Expr *pExpr){ |
| 107515 | if( pExpr->op==TK_COLUMN |
| 107516 | || pExpr->op==TK_AGG_COLUMN |
| 107517 | ){ |
| 107518 | int i; |
| 107519 | struct RefSrcList *p = pWalker->u.pRefSrcList; |
| 107520 | SrcList *pSrc = p->pRef; |
| 107521 | int nSrc = pSrc ? pSrc->nSrc : 0; |
| 107522 | for(i=0; i<nSrc; i++){ |
| 107523 | if( pExpr->iTable==pSrc->a[i].iCursor ){ |
| 107524 | pWalker->eCode |= 1; |
| 107525 | return WRC_Continue; |
| 107526 | } |
| 107527 | } |
| 107528 | for(i=0; i<p->nExclude && p->aiExclude[i]!=pExpr->iTable; i++){} |
| 107529 | if( i>=p->nExclude ){ |
| 107530 | pWalker->eCode |= 2; |
| 107531 | } |
| 107532 | } |
| 107533 | return WRC_Continue; |
| 107534 | } |
| 107535 | |
| 107536 | /* |
| 107537 | ** Check to see if pExpr references any tables in pSrcList. |
| 107538 | ** Possible return values: |
| 107539 | ** |
| 107540 | ** 1 pExpr does references a table in pSrcList. |
| 107541 | ** |
| 107542 | ** 0 pExpr references some table that is not defined in either |
| 107543 | ** pSrcList or in subqueries of pExpr itself. |
| 107544 | ** |
| 107545 | ** -1 pExpr only references no tables at all, or it only |
| 107546 | ** references tables defined in subqueries of pExpr itself. |
| 107547 | ** |
| 107548 | ** As currently used, pExpr is always an aggregate function call. That |
| 107549 | ** fact is exploited for efficiency. |
| 107550 | */ |
| 107551 | SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse *pParse, Expr *pExpr, SrcList *pSrcList){ |
| 107552 | Walker w; |
| 107553 | struct RefSrcList x; |
| 107554 | memset(&w, 0, sizeof(w)); |
| 107555 | memset(&x, 0, sizeof(x)); |
| 107556 | w.xExprCallback = exprRefToSrcList; |
| 107557 | w.xSelectCallback = selectRefEnter; |
| 107558 | w.xSelectCallback2 = selectRefLeave; |
| 107559 | w.u.pRefSrcList = &x; |
| 107560 | x.db = pParse->db; |
| 107561 | x.pRef = pSrcList; |
| 107562 | assert( pExpr->op==TK_AGG_FUNCTION ); |
| 107563 | assert( ExprUseXList(pExpr) ); |
| 107564 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 107565 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 107566 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 107567 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 107568 | } |
| 107569 | #endif |
| 107570 | sqlite3DbFree(pParse->db, x.aiExclude); |
| 107571 | if( w.eCode & 0x01 ){ |
| 107572 | return 1; |
| 107573 | }else if( w.eCode ){ |
| 107574 | return 0; |
| 107575 | }else{ |
| 107576 | return -1; |
| 107577 | } |
| 107578 | } |
| 107579 | |
| 107580 | /* |
| 107581 | ** This is a Walker expression node callback. |
| 107582 | ** |
| @@ -115414,10 +115490,11 @@ | |
| 115490 | |
| 115491 | assert( IsVirtual(pTab) ); |
| 115492 | pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->u.vtab.azArg[0]); |
| 115493 | if( pMod==0 ) return; |
| 115494 | if( NEVER(pMod->pModule==0) ) return; |
| 115495 | if( pMod->pModule->iVersion<3 ) return; |
| 115496 | if( pMod->pModule->xShadowName==0 ) return; |
| 115497 | assert( pTab->zName!=0 ); |
| 115498 | nName = sqlite3Strlen30(pTab->zName); |
| 115499 | for(k=sqliteHashFirst(&pTab->pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 115500 | Table *pOther = sqliteHashData(k); |
| @@ -116321,10 +116398,13 @@ | |
| 116398 | if( sqlite3StrNICmp(pTab->zName+7, "parameters", 10)==0 ) return 0; |
| 116399 | return 1; |
| 116400 | } |
| 116401 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ |
| 116402 | return 1; |
| 116403 | } |
| 116404 | if( pTab->tabFlags & TF_Eponymous ){ |
| 116405 | return 1; |
| 116406 | } |
| 116407 | return 0; |
| 116408 | } |
| 116409 | |
| 116410 | /* |
| @@ -127801,11 +127881,11 @@ | |
| 127881 | /* Version 3.34.0 and later */ |
| 127882 | #define sqlite3_txn_state sqlite3_api->txn_state |
| 127883 | /* Version 3.36.1 and later */ |
| 127884 | #define sqlite3_changes64 sqlite3_api->changes64 |
| 127885 | #define sqlite3_total_changes64 sqlite3_api->total_changes64 |
| 127886 | /* Version 3.37.0 and later */ |
| 127887 | #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages |
| 127888 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 127889 | |
| 127890 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 127891 | /* This case when the file really is being compiled as a loadable |
| @@ -138037,31 +138117,43 @@ | |
| 138117 | ** |
| 138118 | ** SELECT count(*) FROM <tbl> |
| 138119 | ** |
| 138120 | ** where table is a database table, not a sub-select or view. If the query |
| 138121 | ** does match this pattern, then a pointer to the Table object representing |
| 138122 | ** <tbl> is returned. Otherwise, NULL is returned. |
| 138123 | ** |
| 138124 | ** This routine a condition for the count optimization. A correct answer |
| 138125 | ** is obtained (though perhaps more slowly) if this routine returns NULL when |
| 138126 | ** it could have returned a table pointer. But returning the pointer when |
| 138127 | ** NULL should have been returned can result in incorrect answers and/or |
| 138128 | ** crashes. So, when in doubt, return NULL. |
| 138129 | */ |
| 138130 | static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ |
| 138131 | Table *pTab; |
| 138132 | Expr *pExpr; |
| 138133 | |
| 138134 | assert( !p->pGroupBy ); |
| 138135 | |
| 138136 | if( p->pWhere |
| 138137 | || p->pEList->nExpr!=1 |
| 138138 | || p->pSrc->nSrc!=1 |
| 138139 | || p->pSrc->a[0].pSelect |
| 138140 | || pAggInfo->nFunc!=1 |
| 138141 | ){ |
| 138142 | return 0; |
| 138143 | } |
| 138144 | pTab = p->pSrc->a[0].pTab; |
| 138145 | assert( pTab!=0 ); |
| 138146 | assert( !IsView(pTab) ); |
| 138147 | if( !IsOrdinaryTable(pTab) ) return 0; |
| 138148 | pExpr = p->pEList->a[0].pExpr; |
| 138149 | assert( pExpr!=0 ); |
| 138150 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; |
| 138151 | if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0; |
| 138152 | assert( pAggInfo->aFunc[0].pFExpr==pExpr ); |
| 138153 | testcase( ExprHasProperty(pExpr, EP_Distinct) ); |
| 138154 | testcase( ExprHasProperty(pExpr, EP_WinFunc) ); |
| 138155 | if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0; |
| 138156 | |
| 138157 | return pTab; |
| 138158 | } |
| 138159 | |
| @@ -145189,11 +145281,14 @@ | |
| 145281 | SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){ |
| 145282 | int rc = SQLITE_OK; |
| 145283 | Table *pTab; |
| 145284 | |
| 145285 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); |
| 145286 | if( ALWAYS(pTab!=0) |
| 145287 | && ALWAYS(IsVirtual(pTab)) |
| 145288 | && ALWAYS(pTab->u.vtab.p!=0) |
| 145289 | ){ |
| 145290 | VTable *p; |
| 145291 | int (*xDestroy)(sqlite3_vtab *); |
| 145292 | for(p=pTab->u.vtab.p; p; p=p->pNext){ |
| 145293 | assert( p->pVtab ); |
| 145294 | if( p->pVtab->nRef>0 ){ |
| @@ -155813,10 +155908,11 @@ | |
| 155908 | ** program. |
| 155909 | */ |
| 155910 | for(ii=0; ii<nTabList; ii++){ |
| 155911 | int addrExplain; |
| 155912 | int wsFlags; |
| 155913 | if( pParse->nErr ) goto whereBeginError; |
| 155914 | pLevel = &pWInfo->a[ii]; |
| 155915 | wsFlags = pLevel->pWLoop->wsFlags; |
| 155916 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155917 | if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){ |
| 155918 | constructAutomaticIndex(pParse, &pWInfo->sWC, |
| @@ -157266,11 +157362,15 @@ | |
| 157362 | } |
| 157363 | }else{ |
| 157364 | sqlite3SelectDelete(db, pSub); |
| 157365 | } |
| 157366 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| 157367 | |
| 157368 | /* Defer deleting the temporary table pTab because if an error occurred, |
| 157369 | ** there could still be references to that table embedded in the |
| 157370 | ** result-set or ORDER BY clause of the SELECT statement p. */ |
| 157371 | sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab); |
| 157372 | } |
| 157373 | |
| 157374 | if( rc ){ |
| 157375 | if( pParse->nErr==0 ){ |
| 157376 | assert( pParse->db->mallocFailed ); |
| @@ -160713,13 +160813,13 @@ | |
| 160813 | yyStackEntry *yystackEnd; /* Last entry in the stack */ |
| 160814 | #endif |
| 160815 | }; |
| 160816 | typedef struct yyParser yyParser; |
| 160817 | |
| 160818 | /* #include <assert.h> */ |
| 160819 | #ifndef NDEBUG |
| 160820 | /* #include <stdio.h> */ |
| 160821 | static FILE *yyTraceFILE = 0; |
| 160822 | static char *yyTracePrompt = 0; |
| 160823 | #endif /* NDEBUG */ |
| 160824 | |
| 160825 | #ifndef NDEBUG |
| @@ -164464,12 +164564,12 @@ | |
| 164564 | assert( yypParser->yytos>=yypParser->yystack ); |
| 164565 | assert( yyact==yypParser->yytos->stateno ); |
| 164566 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); |
| 164567 | if( yyact >= YY_MIN_REDUCE ){ |
| 164568 | unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ |
| 164569 | #ifndef NDEBUG |
| 164570 | assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); |
| 164571 | if( yyTraceFILE ){ |
| 164572 | int yysize = yyRuleInfoNRhs[yyruleno]; |
| 164573 | if( yysize ){ |
| 164574 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 164575 | yyTracePrompt, |
| @@ -169582,12 +169682,12 @@ | |
| 169682 | ** |
| 169683 | ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were |
| 169684 | ** dealt with in the previous code block. Besides these, the only |
| 169685 | ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, |
| 169686 | ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, |
| 169687 | ** SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_EXRESCODE, and some reserved |
| 169688 | ** bits. Silently mask off all other flags. |
| 169689 | */ |
| 169690 | flags &= ~( SQLITE_OPEN_DELETEONCLOSE | |
| 169691 | SQLITE_OPEN_EXCLUSIVE | |
| 169692 | SQLITE_OPEN_MAIN_DB | |
| 169693 | SQLITE_OPEN_TEMP_DB | |
| @@ -169618,11 +169718,11 @@ | |
| 169718 | if( isThreadsafe==0 ){ |
| 169719 | sqlite3MutexWarnOnContention(db->mutex); |
| 169720 | } |
| 169721 | } |
| 169722 | sqlite3_mutex_enter(db->mutex); |
| 169723 | db->errMask = (flags & SQLITE_OPEN_EXRESCODE)!=0 ? 0xffffffff : 0xff; |
| 169724 | db->nDb = 2; |
| 169725 | db->eOpenState = SQLITE_STATE_BUSY; |
| 169726 | db->aDb = db->aDbStatic; |
| 169727 | db->lookaside.bDisable = 1; |
| 169728 | db->lookaside.sz = 0; |
| @@ -169850,12 +169950,12 @@ | |
| 169950 | assert( db->mutex!=0 || isThreadsafe==0 |
| 169951 | || sqlite3GlobalConfig.bFullMutex==0 ); |
| 169952 | sqlite3_mutex_leave(db->mutex); |
| 169953 | } |
| 169954 | rc = sqlite3_errcode(db); |
| 169955 | assert( db!=0 || (rc&0xff)==SQLITE_NOMEM ); |
| 169956 | if( (rc&0xff)==SQLITE_NOMEM ){ |
| 169957 | sqlite3_close(db); |
| 169958 | db = 0; |
| 169959 | }else if( rc!=SQLITE_OK ){ |
| 169960 | db->eOpenState = SQLITE_STATE_SICK; |
| 169961 | } |
| @@ -169866,11 +169966,11 @@ | |
| 169966 | void *pArg = sqlite3GlobalConfig.pSqllogArg; |
| 169967 | sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0); |
| 169968 | } |
| 169969 | #endif |
| 169970 | sqlite3_free_filename(zOpen); |
| 169971 | return rc; |
| 169972 | } |
| 169973 | |
| 169974 | |
| 169975 | /* |
| 169976 | ** Open a new database handle. |
| @@ -178416,10 +178516,13 @@ | |
| 178516 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| 178517 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 178518 | if( bEofSave==0 && pNear->iDocid==iDocid ) break; |
| 178519 | } |
| 178520 | assert( rc!=SQLITE_OK || pPhrase->bIncr==0 ); |
| 178521 | if( rc==SQLITE_OK && pNear->bEof!=bEofSave ){ |
| 178522 | rc = FTS_CORRUPT_VTAB; |
| 178523 | } |
| 178524 | } |
| 178525 | if( bTreeEof ){ |
| 178526 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| 178527 | fts3EvalNextRow(pCsr, pNear, &rc); |
| 178528 | } |
| @@ -190106,17 +190209,17 @@ | |
| 190209 | int iEnd = 0; |
| 190210 | int iCurrent = 0; |
| 190211 | const char *zDoc; |
| 190212 | int nDoc; |
| 190213 | |
| 190214 | /* Initialize the contents of sCtx.aTerm[] for column iCol. This |
| 190215 | ** operation may fail if the database contains corrupt records. |
| 190216 | */ |
| 190217 | sCtx.iCol = iCol; |
| 190218 | sCtx.iTerm = 0; |
| 190219 | rc = fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); |
| 190220 | if( rc!=SQLITE_OK ) goto offsets_out; |
| 190221 | |
| 190222 | /* Retreive the text stored in column iCol. If an SQL NULL is stored |
| 190223 | ** in column iCol, jump immediately to the next iteration of the loop. |
| 190224 | ** If an OOM occurs while retrieving the data (this can happen if SQLite |
| 190225 | ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM |
| @@ -201672,10 +201775,17 @@ | |
| 201775 | ** Swap two objects of type TYPE. |
| 201776 | */ |
| 201777 | #if !defined(SQLITE_AMALGAMATION) |
| 201778 | # define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;} |
| 201779 | #endif |
| 201780 | |
| 201781 | /* |
| 201782 | ** Name of the URI option that causes RBU to take an exclusive lock as |
| 201783 | ** part of the incremental checkpoint operation. |
| 201784 | */ |
| 201785 | #define RBU_EXCLUSIVE_CHECKPOINT "rbu_exclusive_checkpoint" |
| 201786 | |
| 201787 | |
| 201788 | /* |
| 201789 | ** The rbu_state table is used to save the state of a partially applied |
| 201790 | ** update so that it can be resumed later. The table consists of integer |
| 201791 | ** keys mapped to values as follows: |
| @@ -204319,17 +204429,23 @@ | |
| 204429 | |
| 204430 | |
| 204431 | /* |
| 204432 | ** Open the database handle and attach the RBU database as "rbu". If an |
| 204433 | ** error occurs, leave an error code and message in the RBU handle. |
| 204434 | ** |
| 204435 | ** If argument dbMain is not NULL, then it is a database handle already |
| 204436 | ** open on the target database. Use this handle instead of opening a new |
| 204437 | ** one. |
| 204438 | */ |
| 204439 | static void rbuOpenDatabase(sqlite3rbu *p, sqlite3 *dbMain, int *pbRetry){ |
| 204440 | assert( p->rc || (p->dbMain==0 && p->dbRbu==0) ); |
| 204441 | assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 ); |
| 204442 | assert( dbMain==0 || rbuIsVacuum(p)==0 ); |
| 204443 | |
| 204444 | /* Open the RBU database */ |
| 204445 | p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1); |
| 204446 | p->dbMain = dbMain; |
| 204447 | |
| 204448 | if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){ |
| 204449 | sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p); |
| 204450 | if( p->zState==0 ){ |
| 204451 | const char *zFile = sqlite3_db_filename(p->dbRbu, "main"); |
| @@ -204691,19 +204807,35 @@ | |
| 204807 | p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff); |
| 204808 | } |
| 204809 | |
| 204810 | |
| 204811 | /* |
| 204812 | ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if |
| 204813 | ** successful, or an SQLite error code otherwise. |
| 204814 | */ |
| 204815 | static int rbuLockDatabase(sqlite3 *db){ |
| 204816 | int rc = SQLITE_OK; |
| 204817 | sqlite3_file *fd = 0; |
| 204818 | sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd); |
| 204819 | |
| 204820 | if( fd->pMethods ){ |
| 204821 | rc = fd->pMethods->xLock(fd, SQLITE_LOCK_SHARED); |
| 204822 | if( rc==SQLITE_OK ){ |
| 204823 | rc = fd->pMethods->xLock(fd, SQLITE_LOCK_EXCLUSIVE); |
| 204824 | } |
| 204825 | } |
| 204826 | return rc; |
| 204827 | } |
| 204828 | |
| 204829 | /* |
| 204830 | ** Return true if the database handle passed as the only argument |
| 204831 | ** was opened with the rbu_exclusive_checkpoint=1 URI parameter |
| 204832 | ** specified. Or false otherwise. |
| 204833 | */ |
| 204834 | static int rbuExclusiveCheckpoint(sqlite3 *db){ |
| 204835 | const char *zUri = sqlite3_db_filename(db, 0); |
| 204836 | return sqlite3_uri_boolean(zUri, RBU_EXCLUSIVE_CHECKPOINT, 0); |
| 204837 | } |
| 204838 | |
| 204839 | #if defined(_WIN32_WCE) |
| 204840 | static LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){ |
| 204841 | int nChar; |
| @@ -204757,22 +204889,28 @@ | |
| 204889 | ** in WAL mode). So no other connection may be writing the db. |
| 204890 | ** |
| 204891 | ** In order to ensure that there are no database readers, an EXCLUSIVE |
| 204892 | ** lock is obtained here before the *-oal is moved to *-wal. |
| 204893 | */ |
| 204894 | sqlite3 *dbMain = 0; |
| 204895 | rbuFileSuffix3(zBase, zWal); |
| 204896 | rbuFileSuffix3(zBase, zOal); |
| 204897 | |
| 204898 | /* Re-open the databases. */ |
| 204899 | rbuObjIterFinalize(&p->objiter); |
| 204900 | sqlite3_close(p->dbRbu); |
| 204901 | sqlite3_close(p->dbMain); |
| 204902 | p->dbMain = 0; |
| 204903 | p->dbRbu = 0; |
| 204904 | |
| 204905 | dbMain = rbuOpenDbhandle(p, p->zTarget, 1); |
| 204906 | if( dbMain ){ |
| 204907 | assert( p->rc==SQLITE_OK ); |
| 204908 | p->rc = rbuLockDatabase(dbMain); |
| 204909 | } |
| 204910 | |
| 204911 | if( p->rc==SQLITE_OK ){ |
| 204912 | #if defined(_WIN32_WCE) |
| 204913 | { |
| 204914 | LPWSTR zWideOal; |
| 204915 | LPWSTR zWideWal; |
| 204916 | |
| @@ -204795,15 +204933,23 @@ | |
| 204933 | } |
| 204934 | } |
| 204935 | #else |
| 204936 | p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK; |
| 204937 | #endif |
| 204938 | } |
| 204939 | |
| 204940 | if( p->rc!=SQLITE_OK |
| 204941 | || rbuIsVacuum(p) |
| 204942 | || rbuExclusiveCheckpoint(dbMain)==0 |
| 204943 | ){ |
| 204944 | sqlite3_close(dbMain); |
| 204945 | dbMain = 0; |
| 204946 | } |
| 204947 | |
| 204948 | if( p->rc==SQLITE_OK ){ |
| 204949 | rbuOpenDatabase(p, dbMain, 0); |
| 204950 | rbuSetupCheckpoint(p, 0); |
| 204951 | } |
| 204952 | } |
| 204953 | |
| 204954 | sqlite3_free(zWal); |
| 204955 | sqlite3_free(zOal); |
| @@ -205550,13 +205696,13 @@ | |
| 205696 | ** to be a wal-mode db. But, this may have happened due to an earlier |
| 205697 | ** RBU vacuum operation leaving an old wal file in the directory. |
| 205698 | ** If this is the case, it will have been checkpointed and deleted |
| 205699 | ** when the handle was closed and a second attempt to open the |
| 205700 | ** database may succeed. */ |
| 205701 | rbuOpenDatabase(p, 0, &bRetry); |
| 205702 | if( bRetry ){ |
| 205703 | rbuOpenDatabase(p, 0, 0); |
| 205704 | } |
| 205705 | } |
| 205706 | |
| 205707 | if( p->rc==SQLITE_OK ){ |
| 205708 | pState = rbuLoadState(p); |
| @@ -205647,10 +205793,18 @@ | |
| 205793 | } |
| 205794 | } |
| 205795 | }else if( p->eStage==RBU_STAGE_MOVE ){ |
| 205796 | /* no-op */ |
| 205797 | }else if( p->eStage==RBU_STAGE_CKPT ){ |
| 205798 | if( !rbuIsVacuum(p) && rbuExclusiveCheckpoint(p->dbMain) ){ |
| 205799 | /* If the rbu_exclusive_checkpoint=1 URI parameter was specified |
| 205800 | ** and an incremental checkpoint is being resumed, attempt an |
| 205801 | ** exclusive lock on the db file. If this fails, so be it. */ |
| 205802 | p->eStage = RBU_STAGE_DONE; |
| 205803 | rbuLockDatabase(p->dbMain); |
| 205804 | p->eStage = RBU_STAGE_CKPT; |
| 205805 | } |
| 205806 | rbuSetupCheckpoint(p, pState); |
| 205807 | }else if( p->eStage==RBU_STAGE_DONE ){ |
| 205808 | p->rc = SQLITE_DONE; |
| 205809 | }else{ |
| 205810 | p->rc = SQLITE_CORRUPT; |
| @@ -205684,11 +205838,10 @@ | |
| 205838 | const char *zTarget, |
| 205839 | const char *zRbu, |
| 205840 | const char *zState |
| 205841 | ){ |
| 205842 | if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); } |
| 205843 | return openRbuHandle(zTarget, zRbu, zState); |
| 205844 | } |
| 205845 | |
| 205846 | /* |
| 205847 | ** Open a handle to begin or resume an RBU VACUUM operation. |
| @@ -215805,13 +215958,13 @@ | |
| 215958 | fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */ |
| 215959 | #endif |
| 215960 | }; |
| 215961 | typedef struct fts5yyParser fts5yyParser; |
| 215962 | |
| 215963 | /* #include <assert.h> */ |
| 215964 | #ifndef NDEBUG |
| 215965 | /* #include <stdio.h> */ |
| 215966 | static FILE *fts5yyTraceFILE = 0; |
| 215967 | static char *fts5yyTracePrompt = 0; |
| 215968 | #endif /* NDEBUG */ |
| 215969 | |
| 215970 | #ifndef NDEBUG |
| @@ -216744,12 +216897,12 @@ | |
| 216897 | assert( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystack ); |
| 216898 | assert( fts5yyact==fts5yypParser->fts5yytos->stateno ); |
| 216899 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); |
| 216900 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ |
| 216901 | unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */ |
| 216902 | #ifndef NDEBUG |
| 216903 | assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); |
| 216904 | if( fts5yyTraceFILE ){ |
| 216905 | int fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; |
| 216906 | if( fts5yysize ){ |
| 216907 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
| 216908 | fts5yyTracePrompt, |
| @@ -232260,11 +232413,11 @@ | |
| 232413 | int nArg, /* Number of args */ |
| 232414 | sqlite3_value **apUnused /* Function arguments */ |
| 232415 | ){ |
| 232416 | assert( nArg==0 ); |
| 232417 | UNUSED_PARAM2(nArg, apUnused); |
| 232418 | sqlite3_result_text(pCtx, "fts5: 2021-11-09 13:31:42 de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae", -1, SQLITE_TRANSIENT); |
| 232419 | } |
| 232420 | |
| 232421 | /* |
| 232422 | ** Return true if zName is the extension on one of the shadow tables used |
| 232423 | ** by this module. |
| 232424 |
+10
-1
| --- src/sqlite3.h | ||
| +++ src/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.37.0" |
| 150 | 150 | #define SQLITE_VERSION_NUMBER 3037000 |
| 151 | -#define SQLITE_SOURCE_ID "2021-11-04 14:04:20 9147390d9885a37a62edc1058f313434627f1b59965c890877d2cb119e355c78" | |
| 151 | +#define SQLITE_SOURCE_ID "2021-11-09 13:31:42 de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae" | |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | 156 | ** |
| @@ -607,10 +607,11 @@ | ||
| 607 | 607 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 608 | 608 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 609 | 609 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 610 | 610 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 611 | 611 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 612 | +#define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ | |
| 612 | 613 | |
| 613 | 614 | /* Reserved: 0x00F00000 */ |
| 614 | 615 | /* Legacy compatibility: */ |
| 615 | 616 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
| 616 | 617 | |
| @@ -3426,10 +3427,18 @@ | ||
| 3426 | 3427 | ** |
| 3427 | 3428 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 3428 | 3429 | ** <dd>The database is opened [shared cache] disabled, overriding |
| 3429 | 3430 | ** the default shared cache setting provided by |
| 3430 | 3431 | ** [sqlite3_enable_shared_cache()].)^ |
| 3432 | +** | |
| 3433 | +** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> | |
| 3434 | +** <dd>The database connection comes up in "extended result code mode". | |
| 3435 | +** In other words, the database behaves has if | |
| 3436 | +** [sqlite3_extended_result_codes(db,1)] where called on the database | |
| 3437 | +** connection as soon as the connection is created. In addition to setting | |
| 3438 | +** the extended result code mode, this flag also causes [sqlite3_open_v2()] | |
| 3439 | +** to return an extended result code.</dd> | |
| 3431 | 3440 | ** |
| 3432 | 3441 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 3433 | 3442 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 3434 | 3443 | ** </dl>)^ |
| 3435 | 3444 | ** |
| 3436 | 3445 |
| --- src/sqlite3.h | |
| +++ src/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.37.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3037000 |
| 151 | #define SQLITE_SOURCE_ID "2021-11-04 14:04:20 9147390d9885a37a62edc1058f313434627f1b59965c890877d2cb119e355c78" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| @@ -607,10 +607,11 @@ | |
| 607 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 608 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 609 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 610 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 611 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 612 | |
| 613 | /* Reserved: 0x00F00000 */ |
| 614 | /* Legacy compatibility: */ |
| 615 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
| 616 | |
| @@ -3426,10 +3427,18 @@ | |
| 3426 | ** |
| 3427 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 3428 | ** <dd>The database is opened [shared cache] disabled, overriding |
| 3429 | ** the default shared cache setting provided by |
| 3430 | ** [sqlite3_enable_shared_cache()].)^ |
| 3431 | ** |
| 3432 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 3433 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 3434 | ** </dl>)^ |
| 3435 | ** |
| 3436 |
| --- src/sqlite3.h | |
| +++ src/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.37.0" |
| 150 | #define SQLITE_VERSION_NUMBER 3037000 |
| 151 | #define SQLITE_SOURCE_ID "2021-11-09 13:31:42 de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae" |
| 152 | |
| 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | ** |
| @@ -607,10 +607,11 @@ | |
| 607 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 608 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 609 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 610 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 611 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 612 | #define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ |
| 613 | |
| 614 | /* Reserved: 0x00F00000 */ |
| 615 | /* Legacy compatibility: */ |
| 616 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ |
| 617 | |
| @@ -3426,10 +3427,18 @@ | |
| 3427 | ** |
| 3428 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 3429 | ** <dd>The database is opened [shared cache] disabled, overriding |
| 3430 | ** the default shared cache setting provided by |
| 3431 | ** [sqlite3_enable_shared_cache()].)^ |
| 3432 | ** |
| 3433 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> |
| 3434 | ** <dd>The database connection comes up in "extended result code mode". |
| 3435 | ** In other words, the database behaves has if |
| 3436 | ** [sqlite3_extended_result_codes(db,1)] where called on the database |
| 3437 | ** connection as soon as the connection is created. In addition to setting |
| 3438 | ** the extended result code mode, this flag also causes [sqlite3_open_v2()] |
| 3439 | ** to return an extended result code.</dd> |
| 3440 | ** |
| 3441 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 3442 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 3443 | ** </dl>)^ |
| 3444 | ** |
| 3445 |