Fossil SCM
Update the built-in SQLite to the latest 3.36.0 alpha for testing.
Commit
1d54782957e4b7f0134a2a8c360fb35e62bb3cee04521715724a407addedf9e4
Parent
b3080a2286d701f…
2 files changed
+159
-63
+1
-1
+159
-63
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1186,11 +1186,11 @@ | ||
| 1186 | 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | 1187 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | 1188 | */ |
| 1189 | 1189 | #define SQLITE_VERSION "3.36.0" |
| 1190 | 1190 | #define SQLITE_VERSION_NUMBER 3036000 |
| 1191 | -#define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5" | |
| 1191 | +#define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09" | |
| 1192 | 1192 | |
| 1193 | 1193 | /* |
| 1194 | 1194 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1195 | 1195 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1196 | 1196 | ** |
| @@ -19448,10 +19448,16 @@ | ||
| 19448 | 19448 | SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*); |
| 19449 | 19449 | |
| 19450 | 19450 | #ifdef SQLITE_DEBUG |
| 19451 | 19451 | SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); |
| 19452 | 19452 | #endif |
| 19453 | + | |
| 19454 | +#ifndef SQLITE_OMIT_CTE | |
| 19455 | +SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*); | |
| 19456 | +#else | |
| 19457 | +# define sqlite3SelectPopWith 0 | |
| 19458 | +#endif | |
| 19453 | 19459 | |
| 19454 | 19460 | /* |
| 19455 | 19461 | ** Return code from the parse-tree walking primitives and their |
| 19456 | 19462 | ** callbacks. |
| 19457 | 19463 | */ |
| @@ -48580,11 +48586,14 @@ | ||
| 48580 | 48586 | memdbDlClose, /* xDlClose */ |
| 48581 | 48587 | memdbRandomness, /* xRandomness */ |
| 48582 | 48588 | memdbSleep, /* xSleep */ |
| 48583 | 48589 | 0, /* memdbCurrentTime, */ /* xCurrentTime */ |
| 48584 | 48590 | memdbGetLastError, /* xGetLastError */ |
| 48585 | - memdbCurrentTimeInt64 /* xCurrentTimeInt64 */ | |
| 48591 | + memdbCurrentTimeInt64, /* xCurrentTimeInt64 */ | |
| 48592 | + 0, /* xSetSystemCall */ | |
| 48593 | + 0, /* xGetSystemCall */ | |
| 48594 | + 0, /* xNextSystemCall */ | |
| 48586 | 48595 | }; |
| 48587 | 48596 | |
| 48588 | 48597 | static const sqlite3_io_methods memdb_io_methods = { |
| 48589 | 48598 | 3, /* iVersion */ |
| 48590 | 48599 | memdbClose, /* xClose */ |
| @@ -48608,16 +48617,25 @@ | ||
| 48608 | 48617 | }; |
| 48609 | 48618 | |
| 48610 | 48619 | /* |
| 48611 | 48620 | ** Enter/leave the mutex on a MemStore |
| 48612 | 48621 | */ |
| 48622 | +#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0 | |
| 48623 | +static void memdbEnter(MemStore *p){ | |
| 48624 | + UNUSED_PARAMETER(p); | |
| 48625 | +} | |
| 48626 | +static void memdbLeave(MemStore *p){ | |
| 48627 | + UNUSED_PARAMETER(p); | |
| 48628 | +} | |
| 48629 | +#else | |
| 48613 | 48630 | static void memdbEnter(MemStore *p){ |
| 48614 | 48631 | sqlite3_mutex_enter(p->pMutex); |
| 48615 | 48632 | } |
| 48616 | 48633 | static void memdbLeave(MemStore *p){ |
| 48617 | 48634 | sqlite3_mutex_leave(p->pMutex); |
| 48618 | 48635 | } |
| 48636 | +#endif | |
| 48619 | 48637 | |
| 48620 | 48638 | |
| 48621 | 48639 | |
| 48622 | 48640 | /* |
| 48623 | 48641 | ** Close an memdb-file. |
| @@ -48760,10 +48778,12 @@ | ||
| 48760 | 48778 | |
| 48761 | 48779 | /* |
| 48762 | 48780 | ** Sync an memdb-file. |
| 48763 | 48781 | */ |
| 48764 | 48782 | static int memdbSync(sqlite3_file *pFile, int flags){ |
| 48783 | + UNUSED_PARAMETER(pFile); | |
| 48784 | + UNUSED_PARAMETER(flags); | |
| 48765 | 48785 | return SQLITE_OK; |
| 48766 | 48786 | } |
| 48767 | 48787 | |
| 48768 | 48788 | /* |
| 48769 | 48789 | ** Return the current file-size of an memdb-file. |
| @@ -48869,10 +48889,11 @@ | ||
| 48869 | 48889 | |
| 48870 | 48890 | /* |
| 48871 | 48891 | ** Return the device characteristic flags supported by an memdb-file. |
| 48872 | 48892 | */ |
| 48873 | 48893 | static int memdbDeviceCharacteristics(sqlite3_file *pFile){ |
| 48894 | + UNUSED_PARAMETER(pFile); | |
| 48874 | 48895 | return SQLITE_IOCAP_ATOMIC | |
| 48875 | 48896 | SQLITE_IOCAP_POWERSAFE_OVERWRITE | |
| 48876 | 48897 | SQLITE_IOCAP_SAFE_APPEND | |
| 48877 | 48898 | SQLITE_IOCAP_SEQUENTIAL; |
| 48878 | 48899 | } |
| @@ -48897,10 +48918,12 @@ | ||
| 48897 | 48918 | } |
| 48898 | 48919 | |
| 48899 | 48920 | /* Release a memory-mapped page */ |
| 48900 | 48921 | static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ |
| 48901 | 48922 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48923 | + UNUSED_PARAMETER(iOfst); | |
| 48924 | + UNUSED_PARAMETER(pPage); | |
| 48902 | 48925 | memdbEnter(p); |
| 48903 | 48926 | p->nMmap--; |
| 48904 | 48927 | memdbLeave(p); |
| 48905 | 48928 | return SQLITE_OK; |
| 48906 | 48929 | } |
| @@ -49009,10 +49032,13 @@ | ||
| 49009 | 49032 | sqlite3_vfs *pVfs, |
| 49010 | 49033 | const char *zPath, |
| 49011 | 49034 | int flags, |
| 49012 | 49035 | int *pResOut |
| 49013 | 49036 | ){ |
| 49037 | + UNUSED_PARAMETER(pVfs); | |
| 49038 | + UNUSED_PARAMETER(zPath); | |
| 49039 | + UNUSED_PARAMETER(flags); | |
| 49014 | 49040 | *pResOut = 0; |
| 49015 | 49041 | return SQLITE_OK; |
| 49016 | 49042 | } |
| 49017 | 49043 | |
| 49018 | 49044 | /* |
| @@ -49024,10 +49050,11 @@ | ||
| 49024 | 49050 | sqlite3_vfs *pVfs, |
| 49025 | 49051 | const char *zPath, |
| 49026 | 49052 | int nOut, |
| 49027 | 49053 | char *zOut |
| 49028 | 49054 | ){ |
| 49055 | + UNUSED_PARAMETER(pVfs); | |
| 49029 | 49056 | sqlite3_snprintf(nOut, zOut, "%s", zPath); |
| 49030 | 49057 | return SQLITE_OK; |
| 49031 | 49058 | } |
| 49032 | 49059 | |
| 49033 | 49060 | /* |
| @@ -49268,11 +49295,11 @@ | ||
| 49268 | 49295 | ** This routine is called when the extension is loaded. |
| 49269 | 49296 | ** Register the new VFS. |
| 49270 | 49297 | */ |
| 49271 | 49298 | SQLITE_PRIVATE int sqlite3MemdbInit(void){ |
| 49272 | 49299 | sqlite3_vfs *pLower = sqlite3_vfs_find(0); |
| 49273 | - int sz = pLower->szOsFile; | |
| 49300 | + unsigned int sz = pLower->szOsFile; | |
| 49274 | 49301 | memdb_vfs.pAppData = pLower; |
| 49275 | 49302 | /* The following conditional can only be true when compiled for |
| 49276 | 49303 | ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave |
| 49277 | 49304 | ** it in, to be safe, but it is marked as NO_TEST since there |
| 49278 | 49305 | ** is no way to reach it under most builds. */ |
| @@ -65884,11 +65911,11 @@ | ||
| 65884 | 65911 | Pgno pgnoRoot, /* The table that might be changing */ |
| 65885 | 65912 | i64 iRow, /* The rowid that might be changing */ |
| 65886 | 65913 | int isClearTable /* True if all rows are being deleted */ |
| 65887 | 65914 | ){ |
| 65888 | 65915 | BtCursor *p; |
| 65889 | - if( pBtree->hasIncrblobCur==0 ) return; | |
| 65916 | + assert( pBtree->hasIncrblobCur ); | |
| 65890 | 65917 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 65891 | 65918 | pBtree->hasIncrblobCur = 0; |
| 65892 | 65919 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 65893 | 65920 | if( (p->curFlags & BTCF_Incrblob)!=0 ){ |
| 65894 | 65921 | pBtree->hasIncrblobCur = 1; |
| @@ -71756,14 +71783,13 @@ | ||
| 71756 | 71783 | *pRC = freePage2(pPage->pBt, pPage, pPage->pgno); |
| 71757 | 71784 | } |
| 71758 | 71785 | } |
| 71759 | 71786 | |
| 71760 | 71787 | /* |
| 71761 | -** Free any overflow pages associated with the given Cell. Store | |
| 71762 | -** size information about the cell in pInfo. | |
| 71788 | +** Free the overflow pages associated with the given Cell. | |
| 71763 | 71789 | */ |
| 71764 | -static int clearCell( | |
| 71790 | +static SQLITE_NOINLINE int clearCellOverflow( | |
| 71765 | 71791 | MemPage *pPage, /* The page that contains the Cell */ |
| 71766 | 71792 | unsigned char *pCell, /* First byte of the Cell */ |
| 71767 | 71793 | CellInfo *pInfo /* Size information about the cell */ |
| 71768 | 71794 | ){ |
| 71769 | 71795 | BtShared *pBt; |
| @@ -71771,14 +71797,11 @@ | ||
| 71771 | 71797 | int rc; |
| 71772 | 71798 | int nOvfl; |
| 71773 | 71799 | u32 ovflPageSize; |
| 71774 | 71800 | |
| 71775 | 71801 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 71776 | - pPage->xParseCell(pPage, pCell, pInfo); | |
| 71777 | - if( pInfo->nLocal==pInfo->nPayload ){ | |
| 71778 | - return SQLITE_OK; /* No overflow pages. Return without doing anything */ | |
| 71779 | - } | |
| 71802 | + assert( pInfo->nLocal!=pInfo->nPayload ); | |
| 71780 | 71803 | testcase( pCell + pInfo->nSize == pPage->aDataEnd ); |
| 71781 | 71804 | testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd ); |
| 71782 | 71805 | if( pCell + pInfo->nSize > pPage->aDataEnd ){ |
| 71783 | 71806 | /* Cell extends past end of page */ |
| 71784 | 71807 | return SQLITE_CORRUPT_PAGE(pPage); |
| @@ -71829,10 +71852,25 @@ | ||
| 71829 | 71852 | if( rc ) return rc; |
| 71830 | 71853 | ovflPgno = iNext; |
| 71831 | 71854 | } |
| 71832 | 71855 | return SQLITE_OK; |
| 71833 | 71856 | } |
| 71857 | + | |
| 71858 | +/* Call xParseCell to compute the size of a cell. If the cell contains | |
| 71859 | +** overflow, then invoke cellClearOverflow to clear out that overflow. | |
| 71860 | +** STore the result code (SQLITE_OK or some error code) in rc. | |
| 71861 | +** | |
| 71862 | +** Implemented as macro to force inlining for performance. | |
| 71863 | +*/ | |
| 71864 | +#define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \ | |
| 71865 | + pPage->xParseCell(pPage, pCell, &sInfo); \ | |
| 71866 | + if( sInfo.nLocal!=sInfo.nPayload ){ \ | |
| 71867 | + rc = clearCellOverflow(pPage, pCell, &sInfo); \ | |
| 71868 | + }else{ \ | |
| 71869 | + rc = SQLITE_OK; \ | |
| 71870 | + } | |
| 71871 | + | |
| 71834 | 71872 | |
| 71835 | 71873 | /* |
| 71836 | 71874 | ** Create the byte sequence used to represent a cell on page pPage |
| 71837 | 71875 | ** and write that byte sequence into pCell[]. Overflow pages are |
| 71838 | 71876 | ** allocated and filled in as necessary. The calling procedure |
| @@ -74089,11 +74127,13 @@ | ||
| 74089 | 74127 | |
| 74090 | 74128 | if( pCur->pKeyInfo==0 ){ |
| 74091 | 74129 | assert( pX->pKey==0 ); |
| 74092 | 74130 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 74093 | 74131 | ** cursors open on the row being replaced */ |
| 74094 | - invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); | |
| 74132 | + if( p->hasIncrblobCur ){ | |
| 74133 | + invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); | |
| 74134 | + } | |
| 74095 | 74135 | |
| 74096 | 74136 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 74097 | 74137 | ** to a row with the same key as the new entry being inserted. |
| 74098 | 74138 | */ |
| 74099 | 74139 | #ifdef SQLITE_DEBUG |
| @@ -74223,11 +74263,11 @@ | ||
| 74223 | 74263 | } |
| 74224 | 74264 | oldCell = findCell(pPage, idx); |
| 74225 | 74265 | if( !pPage->leaf ){ |
| 74226 | 74266 | memcpy(newCell, oldCell, 4); |
| 74227 | 74267 | } |
| 74228 | - rc = clearCell(pPage, oldCell, &info); | |
| 74268 | + BTREE_CLEAR_CELL(rc, pPage, oldCell, info); | |
| 74229 | 74269 | testcase( pCur->curFlags & BTCF_ValidOvfl ); |
| 74230 | 74270 | invalidateOverflowCache(pCur); |
| 74231 | 74271 | if( info.nSize==szNew && info.nLocal==info.nPayload |
| 74232 | 74272 | && (!ISAUTOVACUUM || szNew<pPage->minLocal) |
| 74233 | 74273 | ){ |
| @@ -74516,20 +74556,20 @@ | ||
| 74516 | 74556 | if( rc ) return rc; |
| 74517 | 74557 | } |
| 74518 | 74558 | |
| 74519 | 74559 | /* If this is a delete operation to remove a row from a table b-tree, |
| 74520 | 74560 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 74521 | - if( pCur->pKeyInfo==0 ){ | |
| 74561 | + if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){ | |
| 74522 | 74562 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 74523 | 74563 | } |
| 74524 | 74564 | |
| 74525 | 74565 | /* Make the page containing the entry to be deleted writable. Then free any |
| 74526 | 74566 | ** overflow pages associated with the entry and finally remove the cell |
| 74527 | 74567 | ** itself from within the page. */ |
| 74528 | 74568 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 74529 | 74569 | if( rc ) return rc; |
| 74530 | - rc = clearCell(pPage, pCell, &info); | |
| 74570 | + BTREE_CLEAR_CELL(rc, pPage, pCell, info); | |
| 74531 | 74571 | dropCell(pPage, iCellIdx, info.nSize, &rc); |
| 74532 | 74572 | if( rc ) return rc; |
| 74533 | 74573 | |
| 74534 | 74574 | /* If the cell deleted was not located on a leaf page, then the cursor |
| 74535 | 74575 | ** is currently pointing to the largest entry in the sub-tree headed |
| @@ -74812,11 +74852,11 @@ | ||
| 74812 | 74852 | pCell = findCell(pPage, i); |
| 74813 | 74853 | if( !pPage->leaf ){ |
| 74814 | 74854 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 74815 | 74855 | if( rc ) goto cleardatabasepage_out; |
| 74816 | 74856 | } |
| 74817 | - rc = clearCell(pPage, pCell, &info); | |
| 74857 | + BTREE_CLEAR_CELL(rc, pPage, pCell, info); | |
| 74818 | 74858 | if( rc ) goto cleardatabasepage_out; |
| 74819 | 74859 | } |
| 74820 | 74860 | if( !pPage->leaf ){ |
| 74821 | 74861 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 74822 | 74862 | if( rc ) goto cleardatabasepage_out; |
| @@ -74860,11 +74900,13 @@ | ||
| 74860 | 74900 | |
| 74861 | 74901 | if( SQLITE_OK==rc ){ |
| 74862 | 74902 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 74863 | 74903 | ** is the root of a table b-tree - if it is not, the following call is |
| 74864 | 74904 | ** a no-op). */ |
| 74865 | - invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); | |
| 74905 | + if( p->hasIncrblobCur ){ | |
| 74906 | + invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); | |
| 74907 | + } | |
| 74866 | 74908 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 74867 | 74909 | } |
| 74868 | 74910 | sqlite3BtreeLeave(p); |
| 74869 | 74911 | return rc; |
| 74870 | 74912 | } |
| @@ -76943,11 +76985,13 @@ | ||
| 76943 | 76985 | assert( (p->flags & MEM_Cleared)==0 ); |
| 76944 | 76986 | } |
| 76945 | 76987 | |
| 76946 | 76988 | /* The szMalloc field holds the correct memory allocation size */ |
| 76947 | 76989 | assert( p->szMalloc==0 |
| 76948 | - || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); | |
| 76990 | + || (p->flags==MEM_Undefined | |
| 76991 | + && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc)) | |
| 76992 | + || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc)); | |
| 76949 | 76993 | |
| 76950 | 76994 | /* If p holds a string or blob, the Mem.z must point to exactly |
| 76951 | 76995 | ** one of the following: |
| 76952 | 76996 | ** |
| 76953 | 76997 | ** (1) Memory in Mem.zMalloc and managed by the Mem object |
| @@ -77107,11 +77151,13 @@ | ||
| 77107 | 77151 | ** contain a valid string or blob value. */ |
| 77108 | 77152 | assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 77109 | 77153 | testcase( bPreserve && pMem->z==0 ); |
| 77110 | 77154 | |
| 77111 | 77155 | assert( pMem->szMalloc==0 |
| 77112 | - || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) ); | |
| 77156 | + || (pMem->flags==MEM_Undefined | |
| 77157 | + && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc)) | |
| 77158 | + || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc)); | |
| 77113 | 77159 | if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){ |
| 77114 | 77160 | if( pMem->db ){ |
| 77115 | 77161 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 77116 | 77162 | }else{ |
| 77117 | 77163 | pMem->zMalloc = sqlite3Realloc(pMem->z, n); |
| @@ -86561,22 +86607,40 @@ | ||
| 86561 | 86607 | assert( iCur>=0 && iCur<p->nCursor ); |
| 86562 | 86608 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 86563 | 86609 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 86564 | 86610 | p->apCsr[iCur] = 0; |
| 86565 | 86611 | } |
| 86566 | - if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){ | |
| 86567 | - p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; | |
| 86568 | - memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); | |
| 86569 | - pCx->eCurType = eCurType; | |
| 86570 | - pCx->iDb = iDb; | |
| 86571 | - pCx->nField = nField; | |
| 86572 | - pCx->aOffset = &pCx->aType[nField]; | |
| 86573 | - if( eCurType==CURTYPE_BTREE ){ | |
| 86574 | - pCx->uc.pCursor = (BtCursor*) | |
| 86575 | - &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; | |
| 86576 | - sqlite3BtreeCursorZero(pCx->uc.pCursor); | |
| 86577 | - } | |
| 86612 | + | |
| 86613 | + /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure | |
| 86614 | + ** the pMem used to hold space for the cursor has enough storage available | |
| 86615 | + ** in pMem->zMalloc. But for the special case of the aMem[] entries used | |
| 86616 | + ** to hold cursors, it is faster to in-line the logic. */ | |
| 86617 | + assert( pMem->flags==MEM_Undefined ); | |
| 86618 | + assert( (pMem->flags & MEM_Dyn)==0 ); | |
| 86619 | + assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc ); | |
| 86620 | + if( pMem->szMalloc<nByte ){ | |
| 86621 | + if( pMem->szMalloc>0 ){ | |
| 86622 | + sqlite3DbFreeNN(pMem->db, pMem->zMalloc); | |
| 86623 | + } | |
| 86624 | + pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte); | |
| 86625 | + if( pMem->zMalloc==0 ){ | |
| 86626 | + pMem->szMalloc = 0; | |
| 86627 | + return 0; | |
| 86628 | + } | |
| 86629 | + pMem->szMalloc = nByte; | |
| 86630 | + } | |
| 86631 | + | |
| 86632 | + p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc; | |
| 86633 | + memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); | |
| 86634 | + pCx->eCurType = eCurType; | |
| 86635 | + pCx->iDb = iDb; | |
| 86636 | + pCx->nField = nField; | |
| 86637 | + pCx->aOffset = &pCx->aType[nField]; | |
| 86638 | + if( eCurType==CURTYPE_BTREE ){ | |
| 86639 | + pCx->uc.pCursor = (BtCursor*) | |
| 86640 | + &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; | |
| 86641 | + sqlite3BtreeCursorZero(pCx->uc.pCursor); | |
| 86578 | 86642 | } |
| 86579 | 86643 | return pCx; |
| 86580 | 86644 | } |
| 86581 | 86645 | |
| 86582 | 86646 | /* |
| @@ -88401,10 +88465,35 @@ | ||
| 88401 | 88465 | |
| 88402 | 88466 | pIn1 = &aMem[pOp->p1]; |
| 88403 | 88467 | pIn3 = &aMem[pOp->p3]; |
| 88404 | 88468 | flags1 = pIn1->flags; |
| 88405 | 88469 | flags3 = pIn3->flags; |
| 88470 | + if( (flags1 & flags3 & MEM_Int)!=0 ){ | |
| 88471 | + assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT ); | |
| 88472 | + /* Common case of comparison of two integers */ | |
| 88473 | + if( pIn3->u.i > pIn1->u.i ){ | |
| 88474 | + iCompare = +1; | |
| 88475 | + if( sqlite3aGTb[pOp->opcode] ){ | |
| 88476 | + VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); | |
| 88477 | + goto jump_to_p2; | |
| 88478 | + } | |
| 88479 | + }else if( pIn3->u.i < pIn1->u.i ){ | |
| 88480 | + iCompare = -1; | |
| 88481 | + if( sqlite3aLTb[pOp->opcode] ){ | |
| 88482 | + VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); | |
| 88483 | + goto jump_to_p2; | |
| 88484 | + } | |
| 88485 | + }else{ | |
| 88486 | + iCompare = 0; | |
| 88487 | + if( sqlite3aEQb[pOp->opcode] ){ | |
| 88488 | + VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); | |
| 88489 | + goto jump_to_p2; | |
| 88490 | + } | |
| 88491 | + } | |
| 88492 | + VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3); | |
| 88493 | + break; | |
| 88494 | + } | |
| 88406 | 88495 | if( (flags1 | flags3)&MEM_Null ){ |
| 88407 | 88496 | /* One or both operands are NULL */ |
| 88408 | 88497 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| 88409 | 88498 | /* If SQLITE_NULLEQ is set (which will only happen if the operator is |
| 88410 | 88499 | ** OP_Eq or OP_Ne) then take the jump or not depending on whether |
| @@ -88431,11 +88520,12 @@ | ||
| 88431 | 88520 | goto jump_to_p2; |
| 88432 | 88521 | } |
| 88433 | 88522 | break; |
| 88434 | 88523 | } |
| 88435 | 88524 | }else{ |
| 88436 | - /* Neither operand is NULL. Do a comparison. */ | |
| 88525 | + /* Neither operand is NULL and we couldn't do the special high-speed | |
| 88526 | + ** integer comparison case. So do a general-case comparison. */ | |
| 88437 | 88527 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 88438 | 88528 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 88439 | 88529 | if( (flags1 | flags3)&MEM_Str ){ |
| 88440 | 88530 | if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88441 | 88531 | applyNumericAffinity(pIn1,0); |
| @@ -88444,18 +88534,10 @@ | ||
| 88444 | 88534 | } |
| 88445 | 88535 | if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88446 | 88536 | applyNumericAffinity(pIn3,0); |
| 88447 | 88537 | } |
| 88448 | 88538 | } |
| 88449 | - /* Handle the common case of integer comparison here, as an | |
| 88450 | - ** optimization, to avoid a call to sqlite3MemCompare() */ | |
| 88451 | - if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){ | |
| 88452 | - if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; } | |
| 88453 | - if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; } | |
| 88454 | - res = 0; | |
| 88455 | - goto compare_op; | |
| 88456 | - } | |
| 88457 | 88539 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 88458 | 88540 | if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 88459 | 88541 | testcase( pIn1->flags & MEM_Int ); |
| 88460 | 88542 | testcase( pIn1->flags & MEM_Real ); |
| 88461 | 88543 | testcase( pIn1->flags & MEM_IntReal ); |
| @@ -88474,11 +88556,11 @@ | ||
| 88474 | 88556 | } |
| 88475 | 88557 | } |
| 88476 | 88558 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 88477 | 88559 | res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 88478 | 88560 | } |
| 88479 | -compare_op: | |
| 88561 | + | |
| 88480 | 88562 | /* At this point, res is negative, zero, or positive if reg[P1] is |
| 88481 | 88563 | ** less than, equal to, or greater than reg[P3], respectively. Compute |
| 88482 | 88564 | ** the answer to this operator in res2, depending on what the comparison |
| 88483 | 88565 | ** operator actually is. The next block of code depends on the fact |
| 88484 | 88566 | ** that the 6 comparison operators are consecutive integers in this |
| @@ -98926,10 +99008,13 @@ | ||
| 98926 | 99008 | #if !defined(SQLITE_OMIT_WINDOWFUNC) |
| 98927 | 99009 | if( p->pWinDefn ){ |
| 98928 | 99010 | Parse *pParse; |
| 98929 | 99011 | if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback |
| 98930 | 99012 | || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT) |
| 99013 | +#ifndef SQLITE_OMIT_CTE | |
| 99014 | + || pWalker->xSelectCallback2==sqlite3SelectPopWith | |
| 99015 | +#endif | |
| 98931 | 99016 | ){ |
| 98932 | 99017 | /* The following may return WRC_Abort if there are unresolvable |
| 98933 | 99018 | ** symbols (e.g. a table that does not exist) in a window definition. */ |
| 98934 | 99019 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); |
| 98935 | 99020 | return rc; |
| @@ -100757,10 +100842,23 @@ | ||
| 100757 | 100842 | && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) |
| 100758 | 100843 | ){ |
| 100759 | 100844 | return WRC_Abort; |
| 100760 | 100845 | } |
| 100761 | 100846 | } |
| 100847 | + | |
| 100848 | +#ifndef SQLITE_OMIT_WINDOWFUNC | |
| 100849 | + if( IN_RENAME_OBJECT ){ | |
| 100850 | + Window *pWin; | |
| 100851 | + for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ | |
| 100852 | + if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) | |
| 100853 | + || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) | |
| 100854 | + ){ | |
| 100855 | + return WRC_Abort; | |
| 100856 | + } | |
| 100857 | + } | |
| 100858 | + } | |
| 100859 | +#endif | |
| 100762 | 100860 | |
| 100763 | 100861 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 100764 | 100862 | ** outer queries |
| 100765 | 100863 | */ |
| 100766 | 100864 | sNC.pNext = 0; |
| @@ -100814,23 +100912,10 @@ | ||
| 100814 | 100912 | return WRC_Abort; |
| 100815 | 100913 | } |
| 100816 | 100914 | } |
| 100817 | 100915 | } |
| 100818 | 100916 | |
| 100819 | -#ifndef SQLITE_OMIT_WINDOWFUNC | |
| 100820 | - if( IN_RENAME_OBJECT ){ | |
| 100821 | - Window *pWin; | |
| 100822 | - for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ | |
| 100823 | - if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) | |
| 100824 | - || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) | |
| 100825 | - ){ | |
| 100826 | - return WRC_Abort; | |
| 100827 | - } | |
| 100828 | - } | |
| 100829 | - } | |
| 100830 | -#endif | |
| 100831 | - | |
| 100832 | 100917 | /* If this is part of a compound SELECT, check that it has the right |
| 100833 | 100918 | ** number of expressions in the select list. */ |
| 100834 | 100919 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ |
| 100835 | 100920 | sqlite3SelectWrongNumTermsError(pParse, p->pNext); |
| 100836 | 100921 | return WRC_Abort; |
| @@ -112251,11 +112336,11 @@ | ||
| 112251 | 112336 | ** |
| 112252 | 112337 | ** This routine just records the fact that the lock is desired. The |
| 112253 | 112338 | ** code to make the lock occur is generated by a later call to |
| 112254 | 112339 | ** codeTableLocks() which occurs during sqlite3FinishCoding(). |
| 112255 | 112340 | */ |
| 112256 | -SQLITE_PRIVATE void sqlite3TableLock( | |
| 112341 | +static SQLITE_NOINLINE void lockTable( | |
| 112257 | 112342 | Parse *pParse, /* Parsing context */ |
| 112258 | 112343 | int iDb, /* Index of the database containing the table to lock */ |
| 112259 | 112344 | Pgno iTab, /* Root page number of the table to be locked */ |
| 112260 | 112345 | u8 isWriteLock, /* True for a write lock */ |
| 112261 | 112346 | const char *zName /* Name of the table to be locked */ |
| @@ -112264,12 +112349,10 @@ | ||
| 112264 | 112349 | int i; |
| 112265 | 112350 | int nBytes; |
| 112266 | 112351 | TableLock *p; |
| 112267 | 112352 | assert( iDb>=0 ); |
| 112268 | 112353 | |
| 112269 | - if( iDb==1 ) return; | |
| 112270 | - if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; | |
| 112271 | 112354 | pToplevel = sqlite3ParseToplevel(pParse); |
| 112272 | 112355 | for(i=0; i<pToplevel->nTableLock; i++){ |
| 112273 | 112356 | p = &pToplevel->aTableLock[i]; |
| 112274 | 112357 | if( p->iDb==iDb && p->iTab==iTab ){ |
| 112275 | 112358 | p->isWriteLock = (p->isWriteLock || isWriteLock); |
| @@ -112289,10 +112372,21 @@ | ||
| 112289 | 112372 | }else{ |
| 112290 | 112373 | pToplevel->nTableLock = 0; |
| 112291 | 112374 | sqlite3OomFault(pToplevel->db); |
| 112292 | 112375 | } |
| 112293 | 112376 | } |
| 112377 | +SQLITE_PRIVATE void sqlite3TableLock( | |
| 112378 | + Parse *pParse, /* Parsing context */ | |
| 112379 | + int iDb, /* Index of the database containing the table to lock */ | |
| 112380 | + Pgno iTab, /* Root page number of the table to be locked */ | |
| 112381 | + u8 isWriteLock, /* True for a write lock */ | |
| 112382 | + const char *zName /* Name of the table to be locked */ | |
| 112383 | +){ | |
| 112384 | + if( iDb==1 ) return; | |
| 112385 | + if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; | |
| 112386 | + lockTable(pParse, iDb, iTab, isWriteLock, zName); | |
| 112387 | +} | |
| 112294 | 112388 | |
| 112295 | 112389 | /* |
| 112296 | 112390 | ** Code an OP_TableLock instruction for each table locked by the |
| 112297 | 112391 | ** statement (configured by calls to sqlite3TableLock()). |
| 112298 | 112392 | */ |
| @@ -137047,22 +137141,20 @@ | ||
| 137047 | 137141 | ** |
| 137048 | 137142 | ** This function is used as the xSelectCallback2() callback by |
| 137049 | 137143 | ** sqlite3SelectExpand() when walking a SELECT tree to resolve table |
| 137050 | 137144 | ** names and other FROM clause elements. |
| 137051 | 137145 | */ |
| 137052 | -static void selectPopWith(Walker *pWalker, Select *p){ | |
| 137146 | +SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){ | |
| 137053 | 137147 | Parse *pParse = pWalker->pParse; |
| 137054 | 137148 | if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ |
| 137055 | 137149 | With *pWith = findRightmost(p)->pWith; |
| 137056 | 137150 | if( pWith!=0 ){ |
| 137057 | 137151 | assert( pParse->pWith==pWith || pParse->nErr ); |
| 137058 | 137152 | pParse->pWith = pWith->pOuter; |
| 137059 | 137153 | } |
| 137060 | 137154 | } |
| 137061 | 137155 | } |
| 137062 | -#else | |
| 137063 | -#define selectPopWith 0 | |
| 137064 | 137156 | #endif |
| 137065 | 137157 | |
| 137066 | 137158 | /* |
| 137067 | 137159 | ** The SrcList_item structure passed as the second argument represents a |
| 137068 | 137160 | ** sub-query in the FROM clause of a SELECT statement. This function |
| @@ -137445,11 +137537,11 @@ | ||
| 137445 | 137537 | w.xSelectCallback = convertCompoundSelectToSubquery; |
| 137446 | 137538 | w.xSelectCallback2 = 0; |
| 137447 | 137539 | sqlite3WalkSelect(&w, pSelect); |
| 137448 | 137540 | } |
| 137449 | 137541 | w.xSelectCallback = selectExpander; |
| 137450 | - w.xSelectCallback2 = selectPopWith; | |
| 137542 | + w.xSelectCallback2 = sqlite3SelectPopWith; | |
| 137451 | 137543 | w.eCode = 0; |
| 137452 | 137544 | sqlite3WalkSelect(&w, pSelect); |
| 137453 | 137545 | } |
| 137454 | 137546 | |
| 137455 | 137547 | |
| @@ -166602,10 +166694,14 @@ | ||
| 166602 | 166694 | assert( !db->mallocFailed ); |
| 166603 | 166695 | return SQLITE_BUSY; |
| 166604 | 166696 | }else{ |
| 166605 | 166697 | sqlite3ExpirePreparedStatements(db, 0); |
| 166606 | 166698 | } |
| 166699 | + }else if( xSFunc==0 && xFinal==0 ){ | |
| 166700 | + /* Trying to delete a function that does not exist. This is a no-op. | |
| 166701 | + ** https://sqlite.org/forum/forumpost/726219164b */ | |
| 166702 | + return SQLITE_OK; | |
| 166607 | 166703 | } |
| 166608 | 166704 | |
| 166609 | 166705 | p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1); |
| 166610 | 166706 | assert(p || db->mallocFailed); |
| 166611 | 166707 | if( !p ){ |
| @@ -235089,12 +235185,12 @@ | ||
| 235089 | 235185 | } |
| 235090 | 235186 | #endif /* SQLITE_CORE */ |
| 235091 | 235187 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 235092 | 235188 | |
| 235093 | 235189 | /************** End of stmt.c ************************************************/ |
| 235094 | -#if __LINE__!=235094 | |
| 235190 | +#if __LINE__!=235190 | |
| 235095 | 235191 | #undef SQLITE_SOURCE_ID |
| 235096 | -#define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e117alt2" | |
| 235192 | +#define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671baalt2" | |
| 235097 | 235193 | #endif |
| 235098 | 235194 | /* Return the source-id for this library */ |
| 235099 | 235195 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 235100 | 235196 | /************************** End of sqlite3.c ******************************/ |
| 235101 | 235197 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1186,11 +1186,11 @@ | |
| 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | */ |
| 1189 | #define SQLITE_VERSION "3.36.0" |
| 1190 | #define SQLITE_VERSION_NUMBER 3036000 |
| 1191 | #define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5" |
| 1192 | |
| 1193 | /* |
| 1194 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1195 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1196 | ** |
| @@ -19448,10 +19448,16 @@ | |
| 19448 | SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*); |
| 19449 | |
| 19450 | #ifdef SQLITE_DEBUG |
| 19451 | SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); |
| 19452 | #endif |
| 19453 | |
| 19454 | /* |
| 19455 | ** Return code from the parse-tree walking primitives and their |
| 19456 | ** callbacks. |
| 19457 | */ |
| @@ -48580,11 +48586,14 @@ | |
| 48580 | memdbDlClose, /* xDlClose */ |
| 48581 | memdbRandomness, /* xRandomness */ |
| 48582 | memdbSleep, /* xSleep */ |
| 48583 | 0, /* memdbCurrentTime, */ /* xCurrentTime */ |
| 48584 | memdbGetLastError, /* xGetLastError */ |
| 48585 | memdbCurrentTimeInt64 /* xCurrentTimeInt64 */ |
| 48586 | }; |
| 48587 | |
| 48588 | static const sqlite3_io_methods memdb_io_methods = { |
| 48589 | 3, /* iVersion */ |
| 48590 | memdbClose, /* xClose */ |
| @@ -48608,16 +48617,25 @@ | |
| 48608 | }; |
| 48609 | |
| 48610 | /* |
| 48611 | ** Enter/leave the mutex on a MemStore |
| 48612 | */ |
| 48613 | static void memdbEnter(MemStore *p){ |
| 48614 | sqlite3_mutex_enter(p->pMutex); |
| 48615 | } |
| 48616 | static void memdbLeave(MemStore *p){ |
| 48617 | sqlite3_mutex_leave(p->pMutex); |
| 48618 | } |
| 48619 | |
| 48620 | |
| 48621 | |
| 48622 | /* |
| 48623 | ** Close an memdb-file. |
| @@ -48760,10 +48778,12 @@ | |
| 48760 | |
| 48761 | /* |
| 48762 | ** Sync an memdb-file. |
| 48763 | */ |
| 48764 | static int memdbSync(sqlite3_file *pFile, int flags){ |
| 48765 | return SQLITE_OK; |
| 48766 | } |
| 48767 | |
| 48768 | /* |
| 48769 | ** Return the current file-size of an memdb-file. |
| @@ -48869,10 +48889,11 @@ | |
| 48869 | |
| 48870 | /* |
| 48871 | ** Return the device characteristic flags supported by an memdb-file. |
| 48872 | */ |
| 48873 | static int memdbDeviceCharacteristics(sqlite3_file *pFile){ |
| 48874 | return SQLITE_IOCAP_ATOMIC | |
| 48875 | SQLITE_IOCAP_POWERSAFE_OVERWRITE | |
| 48876 | SQLITE_IOCAP_SAFE_APPEND | |
| 48877 | SQLITE_IOCAP_SEQUENTIAL; |
| 48878 | } |
| @@ -48897,10 +48918,12 @@ | |
| 48897 | } |
| 48898 | |
| 48899 | /* Release a memory-mapped page */ |
| 48900 | static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ |
| 48901 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48902 | memdbEnter(p); |
| 48903 | p->nMmap--; |
| 48904 | memdbLeave(p); |
| 48905 | return SQLITE_OK; |
| 48906 | } |
| @@ -49009,10 +49032,13 @@ | |
| 49009 | sqlite3_vfs *pVfs, |
| 49010 | const char *zPath, |
| 49011 | int flags, |
| 49012 | int *pResOut |
| 49013 | ){ |
| 49014 | *pResOut = 0; |
| 49015 | return SQLITE_OK; |
| 49016 | } |
| 49017 | |
| 49018 | /* |
| @@ -49024,10 +49050,11 @@ | |
| 49024 | sqlite3_vfs *pVfs, |
| 49025 | const char *zPath, |
| 49026 | int nOut, |
| 49027 | char *zOut |
| 49028 | ){ |
| 49029 | sqlite3_snprintf(nOut, zOut, "%s", zPath); |
| 49030 | return SQLITE_OK; |
| 49031 | } |
| 49032 | |
| 49033 | /* |
| @@ -49268,11 +49295,11 @@ | |
| 49268 | ** This routine is called when the extension is loaded. |
| 49269 | ** Register the new VFS. |
| 49270 | */ |
| 49271 | SQLITE_PRIVATE int sqlite3MemdbInit(void){ |
| 49272 | sqlite3_vfs *pLower = sqlite3_vfs_find(0); |
| 49273 | int sz = pLower->szOsFile; |
| 49274 | memdb_vfs.pAppData = pLower; |
| 49275 | /* The following conditional can only be true when compiled for |
| 49276 | ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave |
| 49277 | ** it in, to be safe, but it is marked as NO_TEST since there |
| 49278 | ** is no way to reach it under most builds. */ |
| @@ -65884,11 +65911,11 @@ | |
| 65884 | Pgno pgnoRoot, /* The table that might be changing */ |
| 65885 | i64 iRow, /* The rowid that might be changing */ |
| 65886 | int isClearTable /* True if all rows are being deleted */ |
| 65887 | ){ |
| 65888 | BtCursor *p; |
| 65889 | if( pBtree->hasIncrblobCur==0 ) return; |
| 65890 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 65891 | pBtree->hasIncrblobCur = 0; |
| 65892 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 65893 | if( (p->curFlags & BTCF_Incrblob)!=0 ){ |
| 65894 | pBtree->hasIncrblobCur = 1; |
| @@ -71756,14 +71783,13 @@ | |
| 71756 | *pRC = freePage2(pPage->pBt, pPage, pPage->pgno); |
| 71757 | } |
| 71758 | } |
| 71759 | |
| 71760 | /* |
| 71761 | ** Free any overflow pages associated with the given Cell. Store |
| 71762 | ** size information about the cell in pInfo. |
| 71763 | */ |
| 71764 | static int clearCell( |
| 71765 | MemPage *pPage, /* The page that contains the Cell */ |
| 71766 | unsigned char *pCell, /* First byte of the Cell */ |
| 71767 | CellInfo *pInfo /* Size information about the cell */ |
| 71768 | ){ |
| 71769 | BtShared *pBt; |
| @@ -71771,14 +71797,11 @@ | |
| 71771 | int rc; |
| 71772 | int nOvfl; |
| 71773 | u32 ovflPageSize; |
| 71774 | |
| 71775 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 71776 | pPage->xParseCell(pPage, pCell, pInfo); |
| 71777 | if( pInfo->nLocal==pInfo->nPayload ){ |
| 71778 | return SQLITE_OK; /* No overflow pages. Return without doing anything */ |
| 71779 | } |
| 71780 | testcase( pCell + pInfo->nSize == pPage->aDataEnd ); |
| 71781 | testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd ); |
| 71782 | if( pCell + pInfo->nSize > pPage->aDataEnd ){ |
| 71783 | /* Cell extends past end of page */ |
| 71784 | return SQLITE_CORRUPT_PAGE(pPage); |
| @@ -71829,10 +71852,25 @@ | |
| 71829 | if( rc ) return rc; |
| 71830 | ovflPgno = iNext; |
| 71831 | } |
| 71832 | return SQLITE_OK; |
| 71833 | } |
| 71834 | |
| 71835 | /* |
| 71836 | ** Create the byte sequence used to represent a cell on page pPage |
| 71837 | ** and write that byte sequence into pCell[]. Overflow pages are |
| 71838 | ** allocated and filled in as necessary. The calling procedure |
| @@ -74089,11 +74127,13 @@ | |
| 74089 | |
| 74090 | if( pCur->pKeyInfo==0 ){ |
| 74091 | assert( pX->pKey==0 ); |
| 74092 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 74093 | ** cursors open on the row being replaced */ |
| 74094 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); |
| 74095 | |
| 74096 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 74097 | ** to a row with the same key as the new entry being inserted. |
| 74098 | */ |
| 74099 | #ifdef SQLITE_DEBUG |
| @@ -74223,11 +74263,11 @@ | |
| 74223 | } |
| 74224 | oldCell = findCell(pPage, idx); |
| 74225 | if( !pPage->leaf ){ |
| 74226 | memcpy(newCell, oldCell, 4); |
| 74227 | } |
| 74228 | rc = clearCell(pPage, oldCell, &info); |
| 74229 | testcase( pCur->curFlags & BTCF_ValidOvfl ); |
| 74230 | invalidateOverflowCache(pCur); |
| 74231 | if( info.nSize==szNew && info.nLocal==info.nPayload |
| 74232 | && (!ISAUTOVACUUM || szNew<pPage->minLocal) |
| 74233 | ){ |
| @@ -74516,20 +74556,20 @@ | |
| 74516 | if( rc ) return rc; |
| 74517 | } |
| 74518 | |
| 74519 | /* If this is a delete operation to remove a row from a table b-tree, |
| 74520 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 74521 | if( pCur->pKeyInfo==0 ){ |
| 74522 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 74523 | } |
| 74524 | |
| 74525 | /* Make the page containing the entry to be deleted writable. Then free any |
| 74526 | ** overflow pages associated with the entry and finally remove the cell |
| 74527 | ** itself from within the page. */ |
| 74528 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 74529 | if( rc ) return rc; |
| 74530 | rc = clearCell(pPage, pCell, &info); |
| 74531 | dropCell(pPage, iCellIdx, info.nSize, &rc); |
| 74532 | if( rc ) return rc; |
| 74533 | |
| 74534 | /* If the cell deleted was not located on a leaf page, then the cursor |
| 74535 | ** is currently pointing to the largest entry in the sub-tree headed |
| @@ -74812,11 +74852,11 @@ | |
| 74812 | pCell = findCell(pPage, i); |
| 74813 | if( !pPage->leaf ){ |
| 74814 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 74815 | if( rc ) goto cleardatabasepage_out; |
| 74816 | } |
| 74817 | rc = clearCell(pPage, pCell, &info); |
| 74818 | if( rc ) goto cleardatabasepage_out; |
| 74819 | } |
| 74820 | if( !pPage->leaf ){ |
| 74821 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 74822 | if( rc ) goto cleardatabasepage_out; |
| @@ -74860,11 +74900,13 @@ | |
| 74860 | |
| 74861 | if( SQLITE_OK==rc ){ |
| 74862 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 74863 | ** is the root of a table b-tree - if it is not, the following call is |
| 74864 | ** a no-op). */ |
| 74865 | invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); |
| 74866 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 74867 | } |
| 74868 | sqlite3BtreeLeave(p); |
| 74869 | return rc; |
| 74870 | } |
| @@ -76943,11 +76985,13 @@ | |
| 76943 | assert( (p->flags & MEM_Cleared)==0 ); |
| 76944 | } |
| 76945 | |
| 76946 | /* The szMalloc field holds the correct memory allocation size */ |
| 76947 | assert( p->szMalloc==0 |
| 76948 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 76949 | |
| 76950 | /* If p holds a string or blob, the Mem.z must point to exactly |
| 76951 | ** one of the following: |
| 76952 | ** |
| 76953 | ** (1) Memory in Mem.zMalloc and managed by the Mem object |
| @@ -77107,11 +77151,13 @@ | |
| 77107 | ** contain a valid string or blob value. */ |
| 77108 | assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 77109 | testcase( bPreserve && pMem->z==0 ); |
| 77110 | |
| 77111 | assert( pMem->szMalloc==0 |
| 77112 | || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) ); |
| 77113 | if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){ |
| 77114 | if( pMem->db ){ |
| 77115 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 77116 | }else{ |
| 77117 | pMem->zMalloc = sqlite3Realloc(pMem->z, n); |
| @@ -86561,22 +86607,40 @@ | |
| 86561 | assert( iCur>=0 && iCur<p->nCursor ); |
| 86562 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 86563 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 86564 | p->apCsr[iCur] = 0; |
| 86565 | } |
| 86566 | if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){ |
| 86567 | p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; |
| 86568 | memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); |
| 86569 | pCx->eCurType = eCurType; |
| 86570 | pCx->iDb = iDb; |
| 86571 | pCx->nField = nField; |
| 86572 | pCx->aOffset = &pCx->aType[nField]; |
| 86573 | if( eCurType==CURTYPE_BTREE ){ |
| 86574 | pCx->uc.pCursor = (BtCursor*) |
| 86575 | &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; |
| 86576 | sqlite3BtreeCursorZero(pCx->uc.pCursor); |
| 86577 | } |
| 86578 | } |
| 86579 | return pCx; |
| 86580 | } |
| 86581 | |
| 86582 | /* |
| @@ -88401,10 +88465,35 @@ | |
| 88401 | |
| 88402 | pIn1 = &aMem[pOp->p1]; |
| 88403 | pIn3 = &aMem[pOp->p3]; |
| 88404 | flags1 = pIn1->flags; |
| 88405 | flags3 = pIn3->flags; |
| 88406 | if( (flags1 | flags3)&MEM_Null ){ |
| 88407 | /* One or both operands are NULL */ |
| 88408 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| 88409 | /* If SQLITE_NULLEQ is set (which will only happen if the operator is |
| 88410 | ** OP_Eq or OP_Ne) then take the jump or not depending on whether |
| @@ -88431,11 +88520,12 @@ | |
| 88431 | goto jump_to_p2; |
| 88432 | } |
| 88433 | break; |
| 88434 | } |
| 88435 | }else{ |
| 88436 | /* Neither operand is NULL. Do a comparison. */ |
| 88437 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 88438 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 88439 | if( (flags1 | flags3)&MEM_Str ){ |
| 88440 | if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88441 | applyNumericAffinity(pIn1,0); |
| @@ -88444,18 +88534,10 @@ | |
| 88444 | } |
| 88445 | if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88446 | applyNumericAffinity(pIn3,0); |
| 88447 | } |
| 88448 | } |
| 88449 | /* Handle the common case of integer comparison here, as an |
| 88450 | ** optimization, to avoid a call to sqlite3MemCompare() */ |
| 88451 | if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){ |
| 88452 | if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; } |
| 88453 | if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; } |
| 88454 | res = 0; |
| 88455 | goto compare_op; |
| 88456 | } |
| 88457 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 88458 | if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 88459 | testcase( pIn1->flags & MEM_Int ); |
| 88460 | testcase( pIn1->flags & MEM_Real ); |
| 88461 | testcase( pIn1->flags & MEM_IntReal ); |
| @@ -88474,11 +88556,11 @@ | |
| 88474 | } |
| 88475 | } |
| 88476 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 88477 | res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 88478 | } |
| 88479 | compare_op: |
| 88480 | /* At this point, res is negative, zero, or positive if reg[P1] is |
| 88481 | ** less than, equal to, or greater than reg[P3], respectively. Compute |
| 88482 | ** the answer to this operator in res2, depending on what the comparison |
| 88483 | ** operator actually is. The next block of code depends on the fact |
| 88484 | ** that the 6 comparison operators are consecutive integers in this |
| @@ -98926,10 +99008,13 @@ | |
| 98926 | #if !defined(SQLITE_OMIT_WINDOWFUNC) |
| 98927 | if( p->pWinDefn ){ |
| 98928 | Parse *pParse; |
| 98929 | if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback |
| 98930 | || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT) |
| 98931 | ){ |
| 98932 | /* The following may return WRC_Abort if there are unresolvable |
| 98933 | ** symbols (e.g. a table that does not exist) in a window definition. */ |
| 98934 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); |
| 98935 | return rc; |
| @@ -100757,10 +100842,23 @@ | |
| 100757 | && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) |
| 100758 | ){ |
| 100759 | return WRC_Abort; |
| 100760 | } |
| 100761 | } |
| 100762 | |
| 100763 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 100764 | ** outer queries |
| 100765 | */ |
| 100766 | sNC.pNext = 0; |
| @@ -100814,23 +100912,10 @@ | |
| 100814 | return WRC_Abort; |
| 100815 | } |
| 100816 | } |
| 100817 | } |
| 100818 | |
| 100819 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100820 | if( IN_RENAME_OBJECT ){ |
| 100821 | Window *pWin; |
| 100822 | for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ |
| 100823 | if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) |
| 100824 | || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) |
| 100825 | ){ |
| 100826 | return WRC_Abort; |
| 100827 | } |
| 100828 | } |
| 100829 | } |
| 100830 | #endif |
| 100831 | |
| 100832 | /* If this is part of a compound SELECT, check that it has the right |
| 100833 | ** number of expressions in the select list. */ |
| 100834 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ |
| 100835 | sqlite3SelectWrongNumTermsError(pParse, p->pNext); |
| 100836 | return WRC_Abort; |
| @@ -112251,11 +112336,11 @@ | |
| 112251 | ** |
| 112252 | ** This routine just records the fact that the lock is desired. The |
| 112253 | ** code to make the lock occur is generated by a later call to |
| 112254 | ** codeTableLocks() which occurs during sqlite3FinishCoding(). |
| 112255 | */ |
| 112256 | SQLITE_PRIVATE void sqlite3TableLock( |
| 112257 | Parse *pParse, /* Parsing context */ |
| 112258 | int iDb, /* Index of the database containing the table to lock */ |
| 112259 | Pgno iTab, /* Root page number of the table to be locked */ |
| 112260 | u8 isWriteLock, /* True for a write lock */ |
| 112261 | const char *zName /* Name of the table to be locked */ |
| @@ -112264,12 +112349,10 @@ | |
| 112264 | int i; |
| 112265 | int nBytes; |
| 112266 | TableLock *p; |
| 112267 | assert( iDb>=0 ); |
| 112268 | |
| 112269 | if( iDb==1 ) return; |
| 112270 | if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; |
| 112271 | pToplevel = sqlite3ParseToplevel(pParse); |
| 112272 | for(i=0; i<pToplevel->nTableLock; i++){ |
| 112273 | p = &pToplevel->aTableLock[i]; |
| 112274 | if( p->iDb==iDb && p->iTab==iTab ){ |
| 112275 | p->isWriteLock = (p->isWriteLock || isWriteLock); |
| @@ -112289,10 +112372,21 @@ | |
| 112289 | }else{ |
| 112290 | pToplevel->nTableLock = 0; |
| 112291 | sqlite3OomFault(pToplevel->db); |
| 112292 | } |
| 112293 | } |
| 112294 | |
| 112295 | /* |
| 112296 | ** Code an OP_TableLock instruction for each table locked by the |
| 112297 | ** statement (configured by calls to sqlite3TableLock()). |
| 112298 | */ |
| @@ -137047,22 +137141,20 @@ | |
| 137047 | ** |
| 137048 | ** This function is used as the xSelectCallback2() callback by |
| 137049 | ** sqlite3SelectExpand() when walking a SELECT tree to resolve table |
| 137050 | ** names and other FROM clause elements. |
| 137051 | */ |
| 137052 | static void selectPopWith(Walker *pWalker, Select *p){ |
| 137053 | Parse *pParse = pWalker->pParse; |
| 137054 | if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ |
| 137055 | With *pWith = findRightmost(p)->pWith; |
| 137056 | if( pWith!=0 ){ |
| 137057 | assert( pParse->pWith==pWith || pParse->nErr ); |
| 137058 | pParse->pWith = pWith->pOuter; |
| 137059 | } |
| 137060 | } |
| 137061 | } |
| 137062 | #else |
| 137063 | #define selectPopWith 0 |
| 137064 | #endif |
| 137065 | |
| 137066 | /* |
| 137067 | ** The SrcList_item structure passed as the second argument represents a |
| 137068 | ** sub-query in the FROM clause of a SELECT statement. This function |
| @@ -137445,11 +137537,11 @@ | |
| 137445 | w.xSelectCallback = convertCompoundSelectToSubquery; |
| 137446 | w.xSelectCallback2 = 0; |
| 137447 | sqlite3WalkSelect(&w, pSelect); |
| 137448 | } |
| 137449 | w.xSelectCallback = selectExpander; |
| 137450 | w.xSelectCallback2 = selectPopWith; |
| 137451 | w.eCode = 0; |
| 137452 | sqlite3WalkSelect(&w, pSelect); |
| 137453 | } |
| 137454 | |
| 137455 | |
| @@ -166602,10 +166694,14 @@ | |
| 166602 | assert( !db->mallocFailed ); |
| 166603 | return SQLITE_BUSY; |
| 166604 | }else{ |
| 166605 | sqlite3ExpirePreparedStatements(db, 0); |
| 166606 | } |
| 166607 | } |
| 166608 | |
| 166609 | p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1); |
| 166610 | assert(p || db->mallocFailed); |
| 166611 | if( !p ){ |
| @@ -235089,12 +235185,12 @@ | |
| 235089 | } |
| 235090 | #endif /* SQLITE_CORE */ |
| 235091 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 235092 | |
| 235093 | /************** End of stmt.c ************************************************/ |
| 235094 | #if __LINE__!=235094 |
| 235095 | #undef SQLITE_SOURCE_ID |
| 235096 | #define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e117alt2" |
| 235097 | #endif |
| 235098 | /* Return the source-id for this library */ |
| 235099 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 235100 | /************************** End of sqlite3.c ******************************/ |
| 235101 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1186,11 +1186,11 @@ | |
| 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | */ |
| 1189 | #define SQLITE_VERSION "3.36.0" |
| 1190 | #define SQLITE_VERSION_NUMBER 3036000 |
| 1191 | #define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09" |
| 1192 | |
| 1193 | /* |
| 1194 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1195 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1196 | ** |
| @@ -19448,10 +19448,16 @@ | |
| 19448 | SQLITE_PRIVATE void sqlite3WalkWinDefnDummyCallback(Walker*,Select*); |
| 19449 | |
| 19450 | #ifdef SQLITE_DEBUG |
| 19451 | SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); |
| 19452 | #endif |
| 19453 | |
| 19454 | #ifndef SQLITE_OMIT_CTE |
| 19455 | SQLITE_PRIVATE void sqlite3SelectPopWith(Walker*, Select*); |
| 19456 | #else |
| 19457 | # define sqlite3SelectPopWith 0 |
| 19458 | #endif |
| 19459 | |
| 19460 | /* |
| 19461 | ** Return code from the parse-tree walking primitives and their |
| 19462 | ** callbacks. |
| 19463 | */ |
| @@ -48580,11 +48586,14 @@ | |
| 48586 | memdbDlClose, /* xDlClose */ |
| 48587 | memdbRandomness, /* xRandomness */ |
| 48588 | memdbSleep, /* xSleep */ |
| 48589 | 0, /* memdbCurrentTime, */ /* xCurrentTime */ |
| 48590 | memdbGetLastError, /* xGetLastError */ |
| 48591 | memdbCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 48592 | 0, /* xSetSystemCall */ |
| 48593 | 0, /* xGetSystemCall */ |
| 48594 | 0, /* xNextSystemCall */ |
| 48595 | }; |
| 48596 | |
| 48597 | static const sqlite3_io_methods memdb_io_methods = { |
| 48598 | 3, /* iVersion */ |
| 48599 | memdbClose, /* xClose */ |
| @@ -48608,16 +48617,25 @@ | |
| 48617 | }; |
| 48618 | |
| 48619 | /* |
| 48620 | ** Enter/leave the mutex on a MemStore |
| 48621 | */ |
| 48622 | #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0 |
| 48623 | static void memdbEnter(MemStore *p){ |
| 48624 | UNUSED_PARAMETER(p); |
| 48625 | } |
| 48626 | static void memdbLeave(MemStore *p){ |
| 48627 | UNUSED_PARAMETER(p); |
| 48628 | } |
| 48629 | #else |
| 48630 | static void memdbEnter(MemStore *p){ |
| 48631 | sqlite3_mutex_enter(p->pMutex); |
| 48632 | } |
| 48633 | static void memdbLeave(MemStore *p){ |
| 48634 | sqlite3_mutex_leave(p->pMutex); |
| 48635 | } |
| 48636 | #endif |
| 48637 | |
| 48638 | |
| 48639 | |
| 48640 | /* |
| 48641 | ** Close an memdb-file. |
| @@ -48760,10 +48778,12 @@ | |
| 48778 | |
| 48779 | /* |
| 48780 | ** Sync an memdb-file. |
| 48781 | */ |
| 48782 | static int memdbSync(sqlite3_file *pFile, int flags){ |
| 48783 | UNUSED_PARAMETER(pFile); |
| 48784 | UNUSED_PARAMETER(flags); |
| 48785 | return SQLITE_OK; |
| 48786 | } |
| 48787 | |
| 48788 | /* |
| 48789 | ** Return the current file-size of an memdb-file. |
| @@ -48869,10 +48889,11 @@ | |
| 48889 | |
| 48890 | /* |
| 48891 | ** Return the device characteristic flags supported by an memdb-file. |
| 48892 | */ |
| 48893 | static int memdbDeviceCharacteristics(sqlite3_file *pFile){ |
| 48894 | UNUSED_PARAMETER(pFile); |
| 48895 | return SQLITE_IOCAP_ATOMIC | |
| 48896 | SQLITE_IOCAP_POWERSAFE_OVERWRITE | |
| 48897 | SQLITE_IOCAP_SAFE_APPEND | |
| 48898 | SQLITE_IOCAP_SEQUENTIAL; |
| 48899 | } |
| @@ -48897,10 +48918,12 @@ | |
| 48918 | } |
| 48919 | |
| 48920 | /* Release a memory-mapped page */ |
| 48921 | static int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ |
| 48922 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48923 | UNUSED_PARAMETER(iOfst); |
| 48924 | UNUSED_PARAMETER(pPage); |
| 48925 | memdbEnter(p); |
| 48926 | p->nMmap--; |
| 48927 | memdbLeave(p); |
| 48928 | return SQLITE_OK; |
| 48929 | } |
| @@ -49009,10 +49032,13 @@ | |
| 49032 | sqlite3_vfs *pVfs, |
| 49033 | const char *zPath, |
| 49034 | int flags, |
| 49035 | int *pResOut |
| 49036 | ){ |
| 49037 | UNUSED_PARAMETER(pVfs); |
| 49038 | UNUSED_PARAMETER(zPath); |
| 49039 | UNUSED_PARAMETER(flags); |
| 49040 | *pResOut = 0; |
| 49041 | return SQLITE_OK; |
| 49042 | } |
| 49043 | |
| 49044 | /* |
| @@ -49024,10 +49050,11 @@ | |
| 49050 | sqlite3_vfs *pVfs, |
| 49051 | const char *zPath, |
| 49052 | int nOut, |
| 49053 | char *zOut |
| 49054 | ){ |
| 49055 | UNUSED_PARAMETER(pVfs); |
| 49056 | sqlite3_snprintf(nOut, zOut, "%s", zPath); |
| 49057 | return SQLITE_OK; |
| 49058 | } |
| 49059 | |
| 49060 | /* |
| @@ -49268,11 +49295,11 @@ | |
| 49295 | ** This routine is called when the extension is loaded. |
| 49296 | ** Register the new VFS. |
| 49297 | */ |
| 49298 | SQLITE_PRIVATE int sqlite3MemdbInit(void){ |
| 49299 | sqlite3_vfs *pLower = sqlite3_vfs_find(0); |
| 49300 | unsigned int sz = pLower->szOsFile; |
| 49301 | memdb_vfs.pAppData = pLower; |
| 49302 | /* The following conditional can only be true when compiled for |
| 49303 | ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave |
| 49304 | ** it in, to be safe, but it is marked as NO_TEST since there |
| 49305 | ** is no way to reach it under most builds. */ |
| @@ -65884,11 +65911,11 @@ | |
| 65911 | Pgno pgnoRoot, /* The table that might be changing */ |
| 65912 | i64 iRow, /* The rowid that might be changing */ |
| 65913 | int isClearTable /* True if all rows are being deleted */ |
| 65914 | ){ |
| 65915 | BtCursor *p; |
| 65916 | assert( pBtree->hasIncrblobCur ); |
| 65917 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 65918 | pBtree->hasIncrblobCur = 0; |
| 65919 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 65920 | if( (p->curFlags & BTCF_Incrblob)!=0 ){ |
| 65921 | pBtree->hasIncrblobCur = 1; |
| @@ -71756,14 +71783,13 @@ | |
| 71783 | *pRC = freePage2(pPage->pBt, pPage, pPage->pgno); |
| 71784 | } |
| 71785 | } |
| 71786 | |
| 71787 | /* |
| 71788 | ** Free the overflow pages associated with the given Cell. |
| 71789 | */ |
| 71790 | static SQLITE_NOINLINE int clearCellOverflow( |
| 71791 | MemPage *pPage, /* The page that contains the Cell */ |
| 71792 | unsigned char *pCell, /* First byte of the Cell */ |
| 71793 | CellInfo *pInfo /* Size information about the cell */ |
| 71794 | ){ |
| 71795 | BtShared *pBt; |
| @@ -71771,14 +71797,11 @@ | |
| 71797 | int rc; |
| 71798 | int nOvfl; |
| 71799 | u32 ovflPageSize; |
| 71800 | |
| 71801 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 71802 | assert( pInfo->nLocal!=pInfo->nPayload ); |
| 71803 | testcase( pCell + pInfo->nSize == pPage->aDataEnd ); |
| 71804 | testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd ); |
| 71805 | if( pCell + pInfo->nSize > pPage->aDataEnd ){ |
| 71806 | /* Cell extends past end of page */ |
| 71807 | return SQLITE_CORRUPT_PAGE(pPage); |
| @@ -71829,10 +71852,25 @@ | |
| 71852 | if( rc ) return rc; |
| 71853 | ovflPgno = iNext; |
| 71854 | } |
| 71855 | return SQLITE_OK; |
| 71856 | } |
| 71857 | |
| 71858 | /* Call xParseCell to compute the size of a cell. If the cell contains |
| 71859 | ** overflow, then invoke cellClearOverflow to clear out that overflow. |
| 71860 | ** STore the result code (SQLITE_OK or some error code) in rc. |
| 71861 | ** |
| 71862 | ** Implemented as macro to force inlining for performance. |
| 71863 | */ |
| 71864 | #define BTREE_CLEAR_CELL(rc, pPage, pCell, sInfo) \ |
| 71865 | pPage->xParseCell(pPage, pCell, &sInfo); \ |
| 71866 | if( sInfo.nLocal!=sInfo.nPayload ){ \ |
| 71867 | rc = clearCellOverflow(pPage, pCell, &sInfo); \ |
| 71868 | }else{ \ |
| 71869 | rc = SQLITE_OK; \ |
| 71870 | } |
| 71871 | |
| 71872 | |
| 71873 | /* |
| 71874 | ** Create the byte sequence used to represent a cell on page pPage |
| 71875 | ** and write that byte sequence into pCell[]. Overflow pages are |
| 71876 | ** allocated and filled in as necessary. The calling procedure |
| @@ -74089,11 +74127,13 @@ | |
| 74127 | |
| 74128 | if( pCur->pKeyInfo==0 ){ |
| 74129 | assert( pX->pKey==0 ); |
| 74130 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 74131 | ** cursors open on the row being replaced */ |
| 74132 | if( p->hasIncrblobCur ){ |
| 74133 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); |
| 74134 | } |
| 74135 | |
| 74136 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 74137 | ** to a row with the same key as the new entry being inserted. |
| 74138 | */ |
| 74139 | #ifdef SQLITE_DEBUG |
| @@ -74223,11 +74263,11 @@ | |
| 74263 | } |
| 74264 | oldCell = findCell(pPage, idx); |
| 74265 | if( !pPage->leaf ){ |
| 74266 | memcpy(newCell, oldCell, 4); |
| 74267 | } |
| 74268 | BTREE_CLEAR_CELL(rc, pPage, oldCell, info); |
| 74269 | testcase( pCur->curFlags & BTCF_ValidOvfl ); |
| 74270 | invalidateOverflowCache(pCur); |
| 74271 | if( info.nSize==szNew && info.nLocal==info.nPayload |
| 74272 | && (!ISAUTOVACUUM || szNew<pPage->minLocal) |
| 74273 | ){ |
| @@ -74516,20 +74556,20 @@ | |
| 74556 | if( rc ) return rc; |
| 74557 | } |
| 74558 | |
| 74559 | /* If this is a delete operation to remove a row from a table b-tree, |
| 74560 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 74561 | if( pCur->pKeyInfo==0 && p->hasIncrblobCur ){ |
| 74562 | invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 74563 | } |
| 74564 | |
| 74565 | /* Make the page containing the entry to be deleted writable. Then free any |
| 74566 | ** overflow pages associated with the entry and finally remove the cell |
| 74567 | ** itself from within the page. */ |
| 74568 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 74569 | if( rc ) return rc; |
| 74570 | BTREE_CLEAR_CELL(rc, pPage, pCell, info); |
| 74571 | dropCell(pPage, iCellIdx, info.nSize, &rc); |
| 74572 | if( rc ) return rc; |
| 74573 | |
| 74574 | /* If the cell deleted was not located on a leaf page, then the cursor |
| 74575 | ** is currently pointing to the largest entry in the sub-tree headed |
| @@ -74812,11 +74852,11 @@ | |
| 74852 | pCell = findCell(pPage, i); |
| 74853 | if( !pPage->leaf ){ |
| 74854 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 74855 | if( rc ) goto cleardatabasepage_out; |
| 74856 | } |
| 74857 | BTREE_CLEAR_CELL(rc, pPage, pCell, info); |
| 74858 | if( rc ) goto cleardatabasepage_out; |
| 74859 | } |
| 74860 | if( !pPage->leaf ){ |
| 74861 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 74862 | if( rc ) goto cleardatabasepage_out; |
| @@ -74860,11 +74900,13 @@ | |
| 74900 | |
| 74901 | if( SQLITE_OK==rc ){ |
| 74902 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 74903 | ** is the root of a table b-tree - if it is not, the following call is |
| 74904 | ** a no-op). */ |
| 74905 | if( p->hasIncrblobCur ){ |
| 74906 | invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); |
| 74907 | } |
| 74908 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 74909 | } |
| 74910 | sqlite3BtreeLeave(p); |
| 74911 | return rc; |
| 74912 | } |
| @@ -76943,11 +76985,13 @@ | |
| 76985 | assert( (p->flags & MEM_Cleared)==0 ); |
| 76986 | } |
| 76987 | |
| 76988 | /* The szMalloc field holds the correct memory allocation size */ |
| 76989 | assert( p->szMalloc==0 |
| 76990 | || (p->flags==MEM_Undefined |
| 76991 | && p->szMalloc<=sqlite3DbMallocSize(p->db,p->zMalloc)) |
| 76992 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc)); |
| 76993 | |
| 76994 | /* If p holds a string or blob, the Mem.z must point to exactly |
| 76995 | ** one of the following: |
| 76996 | ** |
| 76997 | ** (1) Memory in Mem.zMalloc and managed by the Mem object |
| @@ -77107,11 +77151,13 @@ | |
| 77151 | ** contain a valid string or blob value. */ |
| 77152 | assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 77153 | testcase( bPreserve && pMem->z==0 ); |
| 77154 | |
| 77155 | assert( pMem->szMalloc==0 |
| 77156 | || (pMem->flags==MEM_Undefined |
| 77157 | && pMem->szMalloc<=sqlite3DbMallocSize(pMem->db,pMem->zMalloc)) |
| 77158 | || pMem->szMalloc==sqlite3DbMallocSize(pMem->db,pMem->zMalloc)); |
| 77159 | if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){ |
| 77160 | if( pMem->db ){ |
| 77161 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 77162 | }else{ |
| 77163 | pMem->zMalloc = sqlite3Realloc(pMem->z, n); |
| @@ -86561,22 +86607,40 @@ | |
| 86607 | assert( iCur>=0 && iCur<p->nCursor ); |
| 86608 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 86609 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 86610 | p->apCsr[iCur] = 0; |
| 86611 | } |
| 86612 | |
| 86613 | /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure |
| 86614 | ** the pMem used to hold space for the cursor has enough storage available |
| 86615 | ** in pMem->zMalloc. But for the special case of the aMem[] entries used |
| 86616 | ** to hold cursors, it is faster to in-line the logic. */ |
| 86617 | assert( pMem->flags==MEM_Undefined ); |
| 86618 | assert( (pMem->flags & MEM_Dyn)==0 ); |
| 86619 | assert( pMem->szMalloc==0 || pMem->z==pMem->zMalloc ); |
| 86620 | if( pMem->szMalloc<nByte ){ |
| 86621 | if( pMem->szMalloc>0 ){ |
| 86622 | sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 86623 | } |
| 86624 | pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte); |
| 86625 | if( pMem->zMalloc==0 ){ |
| 86626 | pMem->szMalloc = 0; |
| 86627 | return 0; |
| 86628 | } |
| 86629 | pMem->szMalloc = nByte; |
| 86630 | } |
| 86631 | |
| 86632 | p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc; |
| 86633 | memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); |
| 86634 | pCx->eCurType = eCurType; |
| 86635 | pCx->iDb = iDb; |
| 86636 | pCx->nField = nField; |
| 86637 | pCx->aOffset = &pCx->aType[nField]; |
| 86638 | if( eCurType==CURTYPE_BTREE ){ |
| 86639 | pCx->uc.pCursor = (BtCursor*) |
| 86640 | &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; |
| 86641 | sqlite3BtreeCursorZero(pCx->uc.pCursor); |
| 86642 | } |
| 86643 | return pCx; |
| 86644 | } |
| 86645 | |
| 86646 | /* |
| @@ -88401,10 +88465,35 @@ | |
| 88465 | |
| 88466 | pIn1 = &aMem[pOp->p1]; |
| 88467 | pIn3 = &aMem[pOp->p3]; |
| 88468 | flags1 = pIn1->flags; |
| 88469 | flags3 = pIn3->flags; |
| 88470 | if( (flags1 & flags3 & MEM_Int)!=0 ){ |
| 88471 | assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT ); |
| 88472 | /* Common case of comparison of two integers */ |
| 88473 | if( pIn3->u.i > pIn1->u.i ){ |
| 88474 | iCompare = +1; |
| 88475 | if( sqlite3aGTb[pOp->opcode] ){ |
| 88476 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88477 | goto jump_to_p2; |
| 88478 | } |
| 88479 | }else if( pIn3->u.i < pIn1->u.i ){ |
| 88480 | iCompare = -1; |
| 88481 | if( sqlite3aLTb[pOp->opcode] ){ |
| 88482 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88483 | goto jump_to_p2; |
| 88484 | } |
| 88485 | }else{ |
| 88486 | iCompare = 0; |
| 88487 | if( sqlite3aEQb[pOp->opcode] ){ |
| 88488 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88489 | goto jump_to_p2; |
| 88490 | } |
| 88491 | } |
| 88492 | VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 88493 | break; |
| 88494 | } |
| 88495 | if( (flags1 | flags3)&MEM_Null ){ |
| 88496 | /* One or both operands are NULL */ |
| 88497 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| 88498 | /* If SQLITE_NULLEQ is set (which will only happen if the operator is |
| 88499 | ** OP_Eq or OP_Ne) then take the jump or not depending on whether |
| @@ -88431,11 +88520,12 @@ | |
| 88520 | goto jump_to_p2; |
| 88521 | } |
| 88522 | break; |
| 88523 | } |
| 88524 | }else{ |
| 88525 | /* Neither operand is NULL and we couldn't do the special high-speed |
| 88526 | ** integer comparison case. So do a general-case comparison. */ |
| 88527 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 88528 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 88529 | if( (flags1 | flags3)&MEM_Str ){ |
| 88530 | if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88531 | applyNumericAffinity(pIn1,0); |
| @@ -88444,18 +88534,10 @@ | |
| 88534 | } |
| 88535 | if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ |
| 88536 | applyNumericAffinity(pIn3,0); |
| 88537 | } |
| 88538 | } |
| 88539 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 88540 | if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 88541 | testcase( pIn1->flags & MEM_Int ); |
| 88542 | testcase( pIn1->flags & MEM_Real ); |
| 88543 | testcase( pIn1->flags & MEM_IntReal ); |
| @@ -88474,11 +88556,11 @@ | |
| 88556 | } |
| 88557 | } |
| 88558 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 88559 | res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 88560 | } |
| 88561 | |
| 88562 | /* At this point, res is negative, zero, or positive if reg[P1] is |
| 88563 | ** less than, equal to, or greater than reg[P3], respectively. Compute |
| 88564 | ** the answer to this operator in res2, depending on what the comparison |
| 88565 | ** operator actually is. The next block of code depends on the fact |
| 88566 | ** that the 6 comparison operators are consecutive integers in this |
| @@ -98926,10 +99008,13 @@ | |
| 99008 | #if !defined(SQLITE_OMIT_WINDOWFUNC) |
| 99009 | if( p->pWinDefn ){ |
| 99010 | Parse *pParse; |
| 99011 | if( pWalker->xSelectCallback2==sqlite3WalkWinDefnDummyCallback |
| 99012 | || ((pParse = pWalker->pParse)!=0 && IN_RENAME_OBJECT) |
| 99013 | #ifndef SQLITE_OMIT_CTE |
| 99014 | || pWalker->xSelectCallback2==sqlite3SelectPopWith |
| 99015 | #endif |
| 99016 | ){ |
| 99017 | /* The following may return WRC_Abort if there are unresolvable |
| 99018 | ** symbols (e.g. a table that does not exist) in a window definition. */ |
| 99019 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); |
| 99020 | return rc; |
| @@ -100757,10 +100842,23 @@ | |
| 100842 | && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) |
| 100843 | ){ |
| 100844 | return WRC_Abort; |
| 100845 | } |
| 100846 | } |
| 100847 | |
| 100848 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100849 | if( IN_RENAME_OBJECT ){ |
| 100850 | Window *pWin; |
| 100851 | for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ |
| 100852 | if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) |
| 100853 | || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) |
| 100854 | ){ |
| 100855 | return WRC_Abort; |
| 100856 | } |
| 100857 | } |
| 100858 | } |
| 100859 | #endif |
| 100860 | |
| 100861 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 100862 | ** outer queries |
| 100863 | */ |
| 100864 | sNC.pNext = 0; |
| @@ -100814,23 +100912,10 @@ | |
| 100912 | return WRC_Abort; |
| 100913 | } |
| 100914 | } |
| 100915 | } |
| 100916 | |
| 100917 | /* If this is part of a compound SELECT, check that it has the right |
| 100918 | ** number of expressions in the select list. */ |
| 100919 | if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ |
| 100920 | sqlite3SelectWrongNumTermsError(pParse, p->pNext); |
| 100921 | return WRC_Abort; |
| @@ -112251,11 +112336,11 @@ | |
| 112336 | ** |
| 112337 | ** This routine just records the fact that the lock is desired. The |
| 112338 | ** code to make the lock occur is generated by a later call to |
| 112339 | ** codeTableLocks() which occurs during sqlite3FinishCoding(). |
| 112340 | */ |
| 112341 | static SQLITE_NOINLINE void lockTable( |
| 112342 | Parse *pParse, /* Parsing context */ |
| 112343 | int iDb, /* Index of the database containing the table to lock */ |
| 112344 | Pgno iTab, /* Root page number of the table to be locked */ |
| 112345 | u8 isWriteLock, /* True for a write lock */ |
| 112346 | const char *zName /* Name of the table to be locked */ |
| @@ -112264,12 +112349,10 @@ | |
| 112349 | int i; |
| 112350 | int nBytes; |
| 112351 | TableLock *p; |
| 112352 | assert( iDb>=0 ); |
| 112353 | |
| 112354 | pToplevel = sqlite3ParseToplevel(pParse); |
| 112355 | for(i=0; i<pToplevel->nTableLock; i++){ |
| 112356 | p = &pToplevel->aTableLock[i]; |
| 112357 | if( p->iDb==iDb && p->iTab==iTab ){ |
| 112358 | p->isWriteLock = (p->isWriteLock || isWriteLock); |
| @@ -112289,10 +112372,21 @@ | |
| 112372 | }else{ |
| 112373 | pToplevel->nTableLock = 0; |
| 112374 | sqlite3OomFault(pToplevel->db); |
| 112375 | } |
| 112376 | } |
| 112377 | SQLITE_PRIVATE void sqlite3TableLock( |
| 112378 | Parse *pParse, /* Parsing context */ |
| 112379 | int iDb, /* Index of the database containing the table to lock */ |
| 112380 | Pgno iTab, /* Root page number of the table to be locked */ |
| 112381 | u8 isWriteLock, /* True for a write lock */ |
| 112382 | const char *zName /* Name of the table to be locked */ |
| 112383 | ){ |
| 112384 | if( iDb==1 ) return; |
| 112385 | if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; |
| 112386 | lockTable(pParse, iDb, iTab, isWriteLock, zName); |
| 112387 | } |
| 112388 | |
| 112389 | /* |
| 112390 | ** Code an OP_TableLock instruction for each table locked by the |
| 112391 | ** statement (configured by calls to sqlite3TableLock()). |
| 112392 | */ |
| @@ -137047,22 +137141,20 @@ | |
| 137141 | ** |
| 137142 | ** This function is used as the xSelectCallback2() callback by |
| 137143 | ** sqlite3SelectExpand() when walking a SELECT tree to resolve table |
| 137144 | ** names and other FROM clause elements. |
| 137145 | */ |
| 137146 | SQLITE_PRIVATE void sqlite3SelectPopWith(Walker *pWalker, Select *p){ |
| 137147 | Parse *pParse = pWalker->pParse; |
| 137148 | if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ |
| 137149 | With *pWith = findRightmost(p)->pWith; |
| 137150 | if( pWith!=0 ){ |
| 137151 | assert( pParse->pWith==pWith || pParse->nErr ); |
| 137152 | pParse->pWith = pWith->pOuter; |
| 137153 | } |
| 137154 | } |
| 137155 | } |
| 137156 | #endif |
| 137157 | |
| 137158 | /* |
| 137159 | ** The SrcList_item structure passed as the second argument represents a |
| 137160 | ** sub-query in the FROM clause of a SELECT statement. This function |
| @@ -137445,11 +137537,11 @@ | |
| 137537 | w.xSelectCallback = convertCompoundSelectToSubquery; |
| 137538 | w.xSelectCallback2 = 0; |
| 137539 | sqlite3WalkSelect(&w, pSelect); |
| 137540 | } |
| 137541 | w.xSelectCallback = selectExpander; |
| 137542 | w.xSelectCallback2 = sqlite3SelectPopWith; |
| 137543 | w.eCode = 0; |
| 137544 | sqlite3WalkSelect(&w, pSelect); |
| 137545 | } |
| 137546 | |
| 137547 | |
| @@ -166602,10 +166694,14 @@ | |
| 166694 | assert( !db->mallocFailed ); |
| 166695 | return SQLITE_BUSY; |
| 166696 | }else{ |
| 166697 | sqlite3ExpirePreparedStatements(db, 0); |
| 166698 | } |
| 166699 | }else if( xSFunc==0 && xFinal==0 ){ |
| 166700 | /* Trying to delete a function that does not exist. This is a no-op. |
| 166701 | ** https://sqlite.org/forum/forumpost/726219164b */ |
| 166702 | return SQLITE_OK; |
| 166703 | } |
| 166704 | |
| 166705 | p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1); |
| 166706 | assert(p || db->mallocFailed); |
| 166707 | if( !p ){ |
| @@ -235089,12 +235185,12 @@ | |
| 235185 | } |
| 235186 | #endif /* SQLITE_CORE */ |
| 235187 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 235188 | |
| 235189 | /************** End of stmt.c ************************************************/ |
| 235190 | #if __LINE__!=235190 |
| 235191 | #undef SQLITE_SOURCE_ID |
| 235192 | #define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671baalt2" |
| 235193 | #endif |
| 235194 | /* Return the source-id for this library */ |
| 235195 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 235196 | /************************** End of sqlite3.c ******************************/ |
| 235197 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -123,11 +123,11 @@ | ||
| 123 | 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 124 | 124 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 125 | 125 | */ |
| 126 | 126 | #define SQLITE_VERSION "3.36.0" |
| 127 | 127 | #define SQLITE_VERSION_NUMBER 3036000 |
| 128 | -#define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5" | |
| 128 | +#define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09" | |
| 129 | 129 | |
| 130 | 130 | /* |
| 131 | 131 | ** CAPI3REF: Run-Time Library Version Numbers |
| 132 | 132 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 133 | 133 | ** |
| 134 | 134 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -123,11 +123,11 @@ | |
| 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 124 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 125 | */ |
| 126 | #define SQLITE_VERSION "3.36.0" |
| 127 | #define SQLITE_VERSION_NUMBER 3036000 |
| 128 | #define SQLITE_SOURCE_ID "2021-05-14 15:37:00 cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5" |
| 129 | |
| 130 | /* |
| 131 | ** CAPI3REF: Run-Time Library Version Numbers |
| 132 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 133 | ** |
| 134 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -123,11 +123,11 @@ | |
| 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 124 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 125 | */ |
| 126 | #define SQLITE_VERSION "3.36.0" |
| 127 | #define SQLITE_VERSION_NUMBER 3036000 |
| 128 | #define SQLITE_SOURCE_ID "2021-05-17 17:14:38 ace12a3912a4fdc2f0e741361ec705652a11b6f5e3548d54bd6f273671ba1e09" |
| 129 | |
| 130 | /* |
| 131 | ** CAPI3REF: Run-Time Library Version Numbers |
| 132 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 133 | ** |
| 134 |