Fossil SCM
Update the built-in SQLite to the third beta for 3.32.0.
Commit
a8098efebfa81f25a7c634d6e9ce01210c770b7925b1441dc1385b5a469f9030
Parent
64d79ad4575985e…
2 files changed
+43
-34
+1
-1
+43
-34
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1162,11 +1162,11 @@ | ||
| 1162 | 1162 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1163 | 1163 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1164 | 1164 | */ |
| 1165 | 1165 | #define SQLITE_VERSION "3.32.0" |
| 1166 | 1166 | #define SQLITE_VERSION_NUMBER 3032000 |
| 1167 | -#define SQLITE_SOURCE_ID "2020-05-17 13:47:28 69e149f76853d196c8855fedfc98848b60fb116ac36bc08824b1a122469f8ece" | |
| 1167 | +#define SQLITE_SOURCE_ID "2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde" | |
| 1168 | 1168 | |
| 1169 | 1169 | /* |
| 1170 | 1170 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1171 | 1171 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1172 | 1172 | ** |
| @@ -46821,11 +46821,13 @@ | ||
| 46821 | 46821 | pFile->pVfs = pVfs; |
| 46822 | 46822 | pFile->h = h; |
| 46823 | 46823 | if( isReadonly ){ |
| 46824 | 46824 | pFile->ctrlFlags |= WINFILE_RDONLY; |
| 46825 | 46825 | } |
| 46826 | - if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ | |
| 46826 | + if( (flags & SQLITE_OPEN_MAIN_DB) | |
| 46827 | + && sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) | |
| 46828 | + ){ | |
| 46827 | 46829 | pFile->ctrlFlags |= WINFILE_PSOW; |
| 46828 | 46830 | } |
| 46829 | 46831 | pFile->lastErrno = NO_ERROR; |
| 46830 | 46832 | pFile->zPath = zName; |
| 46831 | 46833 | #if SQLITE_MAX_MMAP_SIZE>0 |
| @@ -59957,29 +59959,47 @@ | ||
| 59957 | 59959 | |
| 59958 | 59960 | aOut[0] = s1; |
| 59959 | 59961 | aOut[1] = s2; |
| 59960 | 59962 | } |
| 59961 | 59963 | |
| 59964 | +/* | |
| 59965 | +** If there is the possibility of concurrent access to the SHM file | |
| 59966 | +** from multiple threads and/or processes, then do a memory barrier. | |
| 59967 | +*/ | |
| 59962 | 59968 | static void walShmBarrier(Wal *pWal){ |
| 59963 | 59969 | if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){ |
| 59964 | 59970 | sqlite3OsShmBarrier(pWal->pDbFd); |
| 59965 | 59971 | } |
| 59966 | 59972 | } |
| 59967 | 59973 | |
| 59974 | +/* | |
| 59975 | +** Add the SQLITE_NO_TSAN as part of the return-type of a function | |
| 59976 | +** definition as a hint that the function contains constructs that | |
| 59977 | +** might give false-positive TSAN warnings. | |
| 59978 | +** | |
| 59979 | +** See tag-20200519-1. | |
| 59980 | +*/ | |
| 59981 | +#if defined(__clang__) && !defined(SQLITE_NO_TSAN) | |
| 59982 | +# define SQLITE_NO_TSAN __attribute__((no_sanitize_thread)) | |
| 59983 | +#else | |
| 59984 | +# define SQLITE_NO_TSAN | |
| 59985 | +#endif | |
| 59986 | + | |
| 59968 | 59987 | /* |
| 59969 | 59988 | ** Write the header information in pWal->hdr into the wal-index. |
| 59970 | 59989 | ** |
| 59971 | 59990 | ** The checksum on pWal->hdr is updated before it is written. |
| 59972 | 59991 | */ |
| 59973 | -static void walIndexWriteHdr(Wal *pWal){ | |
| 59992 | +static SQLITE_NO_TSAN void walIndexWriteHdr(Wal *pWal){ | |
| 59974 | 59993 | volatile WalIndexHdr *aHdr = walIndexHdr(pWal); |
| 59975 | 59994 | const int nCksum = offsetof(WalIndexHdr, aCksum); |
| 59976 | 59995 | |
| 59977 | 59996 | assert( pWal->writeLock ); |
| 59978 | 59997 | pWal->hdr.isInit = 1; |
| 59979 | 59998 | pWal->hdr.iVersion = WALINDEX_MAX_VERSION; |
| 59980 | 59999 | walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum); |
| 60000 | + /* Possible TSAN false-positive. See tag-20200519-1 */ | |
| 59981 | 60001 | memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr)); |
| 59982 | 60002 | walShmBarrier(pWal); |
| 59983 | 60003 | memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr)); |
| 59984 | 60004 | } |
| 59985 | 60005 | |
| @@ -61165,36 +61185,17 @@ | ||
| 61165 | 61185 | ** cannot be backfilled from the WAL. |
| 61166 | 61186 | */ |
| 61167 | 61187 | mxSafeFrame = pWal->hdr.mxFrame; |
| 61168 | 61188 | mxPage = pWal->hdr.nPage; |
| 61169 | 61189 | for(i=1; i<WAL_NREADER; i++){ |
| 61170 | - /* Thread-sanitizer reports that the following is an unsafe read, | |
| 61171 | - ** as some other thread may be in the process of updating the value | |
| 61172 | - ** of the aReadMark[] slot. The assumption here is that if that is | |
| 61173 | - ** happening, the other client may only be increasing the value, | |
| 61174 | - ** not decreasing it. So assuming either that either the "old" or | |
| 61175 | - ** "new" version of the value is read, and not some arbitrary value | |
| 61176 | - ** that would never be written by a real client, things are still | |
| 61177 | - ** safe. | |
| 61178 | - ** | |
| 61179 | - ** Astute readers have pointed out that the assumption stated in the | |
| 61180 | - ** last sentence of the previous paragraph is not guaranteed to be | |
| 61181 | - ** true for all conforming systems. However, the assumption is true | |
| 61182 | - ** for all compilers and architectures in common use today (circa | |
| 61183 | - ** 2019-11-27) and the alternatives are both slow and complex, and | |
| 61184 | - ** so we will continue to go with the current design for now. If this | |
| 61185 | - ** bothers you, or if you really are running on a system where aligned | |
| 61186 | - ** 32-bit reads and writes are not atomic, then you can simply avoid | |
| 61187 | - ** the use of WAL mode, or only use WAL mode together with | |
| 61188 | - ** PRAGMA locking_mode=EXCLUSIVE and all will be well. | |
| 61189 | - */ | |
| 61190 | - u32 y = pInfo->aReadMark[i]; | |
| 61190 | + u32 y = AtomicLoad(pInfo->aReadMark+i); | |
| 61191 | 61191 | if( mxSafeFrame>y ){ |
| 61192 | 61192 | assert( y<=pWal->hdr.mxFrame ); |
| 61193 | 61193 | rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); |
| 61194 | 61194 | if( rc==SQLITE_OK ){ |
| 61195 | - pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED); | |
| 61195 | + u32 iMark = (i==1 ? mxSafeFrame : READMARK_NOT_USED); | |
| 61196 | + AtomicStore(pInfo->aReadMark+i, iMark); | |
| 61196 | 61197 | walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 61197 | 61198 | }else if( rc==SQLITE_BUSY ){ |
| 61198 | 61199 | mxSafeFrame = y; |
| 61199 | 61200 | xBusy = 0; |
| 61200 | 61201 | }else{ |
| @@ -61208,11 +61209,11 @@ | ||
| 61208 | 61209 | rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter); |
| 61209 | 61210 | assert( rc==SQLITE_OK || pIter==0 ); |
| 61210 | 61211 | } |
| 61211 | 61212 | |
| 61212 | 61213 | if( pIter |
| 61213 | - && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK | |
| 61214 | + && (rc = walBusyLock(pWal,xBusy,pBusyArg,WAL_READ_LOCK(0),1))==SQLITE_OK | |
| 61214 | 61215 | ){ |
| 61215 | 61216 | u32 nBackfill = pInfo->nBackfill; |
| 61216 | 61217 | |
| 61217 | 61218 | pInfo->nBackfillAttempted = mxSafeFrame; |
| 61218 | 61219 | |
| @@ -61423,11 +61424,11 @@ | ||
| 61423 | 61424 | ** and *pChanged is set to 1. |
| 61424 | 61425 | ** |
| 61425 | 61426 | ** If the checksum cannot be verified return non-zero. If the header |
| 61426 | 61427 | ** is read successfully and the checksum verified, return zero. |
| 61427 | 61428 | */ |
| 61428 | -static int walIndexTryHdr(Wal *pWal, int *pChanged){ | |
| 61429 | +static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){ | |
| 61429 | 61430 | u32 aCksum[2]; /* Checksum on the header content */ |
| 61430 | 61431 | WalIndexHdr h1, h2; /* Two copies of the header content */ |
| 61431 | 61432 | WalIndexHdr volatile *aHdr; /* Header in shared memory */ |
| 61432 | 61433 | |
| 61433 | 61434 | /* The first page of the wal-index must be mapped at this point. */ |
| @@ -61436,17 +61437,23 @@ | ||
| 61436 | 61437 | /* Read the header. This might happen concurrently with a write to the |
| 61437 | 61438 | ** same area of shared memory on a different CPU in a SMP, |
| 61438 | 61439 | ** meaning it is possible that an inconsistent snapshot is read |
| 61439 | 61440 | ** from the file. If this happens, return non-zero. |
| 61440 | 61441 | ** |
| 61442 | + ** tag-20200519-1: | |
| 61441 | 61443 | ** There are two copies of the header at the beginning of the wal-index. |
| 61442 | 61444 | ** When reading, read [0] first then [1]. Writes are in the reverse order. |
| 61443 | 61445 | ** Memory barriers are used to prevent the compiler or the hardware from |
| 61444 | - ** reordering the reads and writes. | |
| 61446 | + ** reordering the reads and writes. TSAN and similar tools can sometimes | |
| 61447 | + ** give false-positive warnings about these accesses because the tools do not | |
| 61448 | + ** account for the double-read and the memory barrier. The use of mutexes | |
| 61449 | + ** here would be problematic as the memory being accessed is potentially | |
| 61450 | + ** shared among multiple processes and not all mutex implementions work | |
| 61451 | + ** reliably in that environment. | |
| 61445 | 61452 | */ |
| 61446 | 61453 | aHdr = walIndexHdr(pWal); |
| 61447 | - memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); | |
| 61454 | + memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); /* Possible TSAN false-positive */ | |
| 61448 | 61455 | walShmBarrier(pWal); |
| 61449 | 61456 | memcpy(&h2, (void *)&aHdr[1], sizeof(h2)); |
| 61450 | 61457 | |
| 61451 | 61458 | if( memcmp(&h1, &h2, sizeof(h1))!=0 ){ |
| 61452 | 61459 | return 1; /* Dirty read */ |
| @@ -62283,26 +62290,28 @@ | ||
| 62283 | 62290 | for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){ |
| 62284 | 62291 | WalHashLoc sLoc; /* Hash table location */ |
| 62285 | 62292 | int iKey; /* Hash slot index */ |
| 62286 | 62293 | int nCollide; /* Number of hash collisions remaining */ |
| 62287 | 62294 | int rc; /* Error code */ |
| 62295 | + u32 iH; | |
| 62288 | 62296 | |
| 62289 | 62297 | rc = walHashGet(pWal, iHash, &sLoc); |
| 62290 | 62298 | if( rc!=SQLITE_OK ){ |
| 62291 | 62299 | return rc; |
| 62292 | 62300 | } |
| 62293 | 62301 | nCollide = HASHTABLE_NSLOT; |
| 62294 | - for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){ | |
| 62295 | - u32 iH = sLoc.aHash[iKey]; | |
| 62302 | + iKey = walHash(pgno); | |
| 62303 | + while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){ | |
| 62296 | 62304 | u32 iFrame = iH + sLoc.iZero; |
| 62297 | 62305 | if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){ |
| 62298 | 62306 | assert( iFrame>iRead || CORRUPT_DB ); |
| 62299 | 62307 | iRead = iFrame; |
| 62300 | 62308 | } |
| 62301 | 62309 | if( (nCollide--)==0 ){ |
| 62302 | 62310 | return SQLITE_CORRUPT_BKPT; |
| 62303 | 62311 | } |
| 62312 | + iKey = walNextHash(iKey); | |
| 62304 | 62313 | } |
| 62305 | 62314 | if( iRead ) break; |
| 62306 | 62315 | } |
| 62307 | 62316 | |
| 62308 | 62317 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT |
| @@ -224738,11 +224747,11 @@ | ||
| 224738 | 224747 | int nArg, /* Number of args */ |
| 224739 | 224748 | sqlite3_value **apUnused /* Function arguments */ |
| 224740 | 224749 | ){ |
| 224741 | 224750 | assert( nArg==0 ); |
| 224742 | 224751 | UNUSED_PARAM2(nArg, apUnused); |
| 224743 | - sqlite3_result_text(pCtx, "fts5: 2020-05-17 00:26:44 1313557b512297e7b75ed748894379b2022aecf696d5a58318e46a668321c1ff", -1, SQLITE_TRANSIENT); | |
| 224752 | + sqlite3_result_text(pCtx, "fts5: 2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde", -1, SQLITE_TRANSIENT); | |
| 224744 | 224753 | } |
| 224745 | 224754 | |
| 224746 | 224755 | /* |
| 224747 | 224756 | ** Return true if zName is the extension on one of the shadow tables used |
| 224748 | 224757 | ** by this module. |
| @@ -229521,12 +229530,12 @@ | ||
| 229521 | 229530 | } |
| 229522 | 229531 | #endif /* SQLITE_CORE */ |
| 229523 | 229532 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 229524 | 229533 | |
| 229525 | 229534 | /************** End of stmt.c ************************************************/ |
| 229526 | -#if __LINE__!=229526 | |
| 229535 | +#if __LINE__!=229535 | |
| 229527 | 229536 | #undef SQLITE_SOURCE_ID |
| 229528 | -#define SQLITE_SOURCE_ID "2020-05-17 13:47:28 69e149f76853d196c8855fedfc98848b60fb116ac36bc08824b1a122469falt2" | |
| 229537 | +#define SQLITE_SOURCE_ID "2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad4alt2" | |
| 229529 | 229538 | #endif |
| 229530 | 229539 | /* Return the source-id for this library */ |
| 229531 | 229540 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 229532 | 229541 | /************************** End of sqlite3.c ******************************/ |
| 229533 | 229542 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1162,11 +1162,11 @@ | |
| 1162 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1163 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1164 | */ |
| 1165 | #define SQLITE_VERSION "3.32.0" |
| 1166 | #define SQLITE_VERSION_NUMBER 3032000 |
| 1167 | #define SQLITE_SOURCE_ID "2020-05-17 13:47:28 69e149f76853d196c8855fedfc98848b60fb116ac36bc08824b1a122469f8ece" |
| 1168 | |
| 1169 | /* |
| 1170 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1171 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1172 | ** |
| @@ -46821,11 +46821,13 @@ | |
| 46821 | pFile->pVfs = pVfs; |
| 46822 | pFile->h = h; |
| 46823 | if( isReadonly ){ |
| 46824 | pFile->ctrlFlags |= WINFILE_RDONLY; |
| 46825 | } |
| 46826 | if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ |
| 46827 | pFile->ctrlFlags |= WINFILE_PSOW; |
| 46828 | } |
| 46829 | pFile->lastErrno = NO_ERROR; |
| 46830 | pFile->zPath = zName; |
| 46831 | #if SQLITE_MAX_MMAP_SIZE>0 |
| @@ -59957,29 +59959,47 @@ | |
| 59957 | |
| 59958 | aOut[0] = s1; |
| 59959 | aOut[1] = s2; |
| 59960 | } |
| 59961 | |
| 59962 | static void walShmBarrier(Wal *pWal){ |
| 59963 | if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){ |
| 59964 | sqlite3OsShmBarrier(pWal->pDbFd); |
| 59965 | } |
| 59966 | } |
| 59967 | |
| 59968 | /* |
| 59969 | ** Write the header information in pWal->hdr into the wal-index. |
| 59970 | ** |
| 59971 | ** The checksum on pWal->hdr is updated before it is written. |
| 59972 | */ |
| 59973 | static void walIndexWriteHdr(Wal *pWal){ |
| 59974 | volatile WalIndexHdr *aHdr = walIndexHdr(pWal); |
| 59975 | const int nCksum = offsetof(WalIndexHdr, aCksum); |
| 59976 | |
| 59977 | assert( pWal->writeLock ); |
| 59978 | pWal->hdr.isInit = 1; |
| 59979 | pWal->hdr.iVersion = WALINDEX_MAX_VERSION; |
| 59980 | walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum); |
| 59981 | memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr)); |
| 59982 | walShmBarrier(pWal); |
| 59983 | memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr)); |
| 59984 | } |
| 59985 | |
| @@ -61165,36 +61185,17 @@ | |
| 61165 | ** cannot be backfilled from the WAL. |
| 61166 | */ |
| 61167 | mxSafeFrame = pWal->hdr.mxFrame; |
| 61168 | mxPage = pWal->hdr.nPage; |
| 61169 | for(i=1; i<WAL_NREADER; i++){ |
| 61170 | /* Thread-sanitizer reports that the following is an unsafe read, |
| 61171 | ** as some other thread may be in the process of updating the value |
| 61172 | ** of the aReadMark[] slot. The assumption here is that if that is |
| 61173 | ** happening, the other client may only be increasing the value, |
| 61174 | ** not decreasing it. So assuming either that either the "old" or |
| 61175 | ** "new" version of the value is read, and not some arbitrary value |
| 61176 | ** that would never be written by a real client, things are still |
| 61177 | ** safe. |
| 61178 | ** |
| 61179 | ** Astute readers have pointed out that the assumption stated in the |
| 61180 | ** last sentence of the previous paragraph is not guaranteed to be |
| 61181 | ** true for all conforming systems. However, the assumption is true |
| 61182 | ** for all compilers and architectures in common use today (circa |
| 61183 | ** 2019-11-27) and the alternatives are both slow and complex, and |
| 61184 | ** so we will continue to go with the current design for now. If this |
| 61185 | ** bothers you, or if you really are running on a system where aligned |
| 61186 | ** 32-bit reads and writes are not atomic, then you can simply avoid |
| 61187 | ** the use of WAL mode, or only use WAL mode together with |
| 61188 | ** PRAGMA locking_mode=EXCLUSIVE and all will be well. |
| 61189 | */ |
| 61190 | u32 y = pInfo->aReadMark[i]; |
| 61191 | if( mxSafeFrame>y ){ |
| 61192 | assert( y<=pWal->hdr.mxFrame ); |
| 61193 | rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); |
| 61194 | if( rc==SQLITE_OK ){ |
| 61195 | pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED); |
| 61196 | walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 61197 | }else if( rc==SQLITE_BUSY ){ |
| 61198 | mxSafeFrame = y; |
| 61199 | xBusy = 0; |
| 61200 | }else{ |
| @@ -61208,11 +61209,11 @@ | |
| 61208 | rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter); |
| 61209 | assert( rc==SQLITE_OK || pIter==0 ); |
| 61210 | } |
| 61211 | |
| 61212 | if( pIter |
| 61213 | && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK |
| 61214 | ){ |
| 61215 | u32 nBackfill = pInfo->nBackfill; |
| 61216 | |
| 61217 | pInfo->nBackfillAttempted = mxSafeFrame; |
| 61218 | |
| @@ -61423,11 +61424,11 @@ | |
| 61423 | ** and *pChanged is set to 1. |
| 61424 | ** |
| 61425 | ** If the checksum cannot be verified return non-zero. If the header |
| 61426 | ** is read successfully and the checksum verified, return zero. |
| 61427 | */ |
| 61428 | static int walIndexTryHdr(Wal *pWal, int *pChanged){ |
| 61429 | u32 aCksum[2]; /* Checksum on the header content */ |
| 61430 | WalIndexHdr h1, h2; /* Two copies of the header content */ |
| 61431 | WalIndexHdr volatile *aHdr; /* Header in shared memory */ |
| 61432 | |
| 61433 | /* The first page of the wal-index must be mapped at this point. */ |
| @@ -61436,17 +61437,23 @@ | |
| 61436 | /* Read the header. This might happen concurrently with a write to the |
| 61437 | ** same area of shared memory on a different CPU in a SMP, |
| 61438 | ** meaning it is possible that an inconsistent snapshot is read |
| 61439 | ** from the file. If this happens, return non-zero. |
| 61440 | ** |
| 61441 | ** There are two copies of the header at the beginning of the wal-index. |
| 61442 | ** When reading, read [0] first then [1]. Writes are in the reverse order. |
| 61443 | ** Memory barriers are used to prevent the compiler or the hardware from |
| 61444 | ** reordering the reads and writes. |
| 61445 | */ |
| 61446 | aHdr = walIndexHdr(pWal); |
| 61447 | memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); |
| 61448 | walShmBarrier(pWal); |
| 61449 | memcpy(&h2, (void *)&aHdr[1], sizeof(h2)); |
| 61450 | |
| 61451 | if( memcmp(&h1, &h2, sizeof(h1))!=0 ){ |
| 61452 | return 1; /* Dirty read */ |
| @@ -62283,26 +62290,28 @@ | |
| 62283 | for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){ |
| 62284 | WalHashLoc sLoc; /* Hash table location */ |
| 62285 | int iKey; /* Hash slot index */ |
| 62286 | int nCollide; /* Number of hash collisions remaining */ |
| 62287 | int rc; /* Error code */ |
| 62288 | |
| 62289 | rc = walHashGet(pWal, iHash, &sLoc); |
| 62290 | if( rc!=SQLITE_OK ){ |
| 62291 | return rc; |
| 62292 | } |
| 62293 | nCollide = HASHTABLE_NSLOT; |
| 62294 | for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){ |
| 62295 | u32 iH = sLoc.aHash[iKey]; |
| 62296 | u32 iFrame = iH + sLoc.iZero; |
| 62297 | if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){ |
| 62298 | assert( iFrame>iRead || CORRUPT_DB ); |
| 62299 | iRead = iFrame; |
| 62300 | } |
| 62301 | if( (nCollide--)==0 ){ |
| 62302 | return SQLITE_CORRUPT_BKPT; |
| 62303 | } |
| 62304 | } |
| 62305 | if( iRead ) break; |
| 62306 | } |
| 62307 | |
| 62308 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT |
| @@ -224738,11 +224747,11 @@ | |
| 224738 | int nArg, /* Number of args */ |
| 224739 | sqlite3_value **apUnused /* Function arguments */ |
| 224740 | ){ |
| 224741 | assert( nArg==0 ); |
| 224742 | UNUSED_PARAM2(nArg, apUnused); |
| 224743 | sqlite3_result_text(pCtx, "fts5: 2020-05-17 00:26:44 1313557b512297e7b75ed748894379b2022aecf696d5a58318e46a668321c1ff", -1, SQLITE_TRANSIENT); |
| 224744 | } |
| 224745 | |
| 224746 | /* |
| 224747 | ** Return true if zName is the extension on one of the shadow tables used |
| 224748 | ** by this module. |
| @@ -229521,12 +229530,12 @@ | |
| 229521 | } |
| 229522 | #endif /* SQLITE_CORE */ |
| 229523 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 229524 | |
| 229525 | /************** End of stmt.c ************************************************/ |
| 229526 | #if __LINE__!=229526 |
| 229527 | #undef SQLITE_SOURCE_ID |
| 229528 | #define SQLITE_SOURCE_ID "2020-05-17 13:47:28 69e149f76853d196c8855fedfc98848b60fb116ac36bc08824b1a122469falt2" |
| 229529 | #endif |
| 229530 | /* Return the source-id for this library */ |
| 229531 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 229532 | /************************** End of sqlite3.c ******************************/ |
| 229533 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1162,11 +1162,11 @@ | |
| 1162 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1163 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1164 | */ |
| 1165 | #define SQLITE_VERSION "3.32.0" |
| 1166 | #define SQLITE_VERSION_NUMBER 3032000 |
| 1167 | #define SQLITE_SOURCE_ID "2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde" |
| 1168 | |
| 1169 | /* |
| 1170 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1171 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1172 | ** |
| @@ -46821,11 +46821,13 @@ | |
| 46821 | pFile->pVfs = pVfs; |
| 46822 | pFile->h = h; |
| 46823 | if( isReadonly ){ |
| 46824 | pFile->ctrlFlags |= WINFILE_RDONLY; |
| 46825 | } |
| 46826 | if( (flags & SQLITE_OPEN_MAIN_DB) |
| 46827 | && sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) |
| 46828 | ){ |
| 46829 | pFile->ctrlFlags |= WINFILE_PSOW; |
| 46830 | } |
| 46831 | pFile->lastErrno = NO_ERROR; |
| 46832 | pFile->zPath = zName; |
| 46833 | #if SQLITE_MAX_MMAP_SIZE>0 |
| @@ -59957,29 +59959,47 @@ | |
| 59959 | |
| 59960 | aOut[0] = s1; |
| 59961 | aOut[1] = s2; |
| 59962 | } |
| 59963 | |
| 59964 | /* |
| 59965 | ** If there is the possibility of concurrent access to the SHM file |
| 59966 | ** from multiple threads and/or processes, then do a memory barrier. |
| 59967 | */ |
| 59968 | static void walShmBarrier(Wal *pWal){ |
| 59969 | if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){ |
| 59970 | sqlite3OsShmBarrier(pWal->pDbFd); |
| 59971 | } |
| 59972 | } |
| 59973 | |
| 59974 | /* |
| 59975 | ** Add the SQLITE_NO_TSAN as part of the return-type of a function |
| 59976 | ** definition as a hint that the function contains constructs that |
| 59977 | ** might give false-positive TSAN warnings. |
| 59978 | ** |
| 59979 | ** See tag-20200519-1. |
| 59980 | */ |
| 59981 | #if defined(__clang__) && !defined(SQLITE_NO_TSAN) |
| 59982 | # define SQLITE_NO_TSAN __attribute__((no_sanitize_thread)) |
| 59983 | #else |
| 59984 | # define SQLITE_NO_TSAN |
| 59985 | #endif |
| 59986 | |
| 59987 | /* |
| 59988 | ** Write the header information in pWal->hdr into the wal-index. |
| 59989 | ** |
| 59990 | ** The checksum on pWal->hdr is updated before it is written. |
| 59991 | */ |
| 59992 | static SQLITE_NO_TSAN void walIndexWriteHdr(Wal *pWal){ |
| 59993 | volatile WalIndexHdr *aHdr = walIndexHdr(pWal); |
| 59994 | const int nCksum = offsetof(WalIndexHdr, aCksum); |
| 59995 | |
| 59996 | assert( pWal->writeLock ); |
| 59997 | pWal->hdr.isInit = 1; |
| 59998 | pWal->hdr.iVersion = WALINDEX_MAX_VERSION; |
| 59999 | walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum); |
| 60000 | /* Possible TSAN false-positive. See tag-20200519-1 */ |
| 60001 | memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr)); |
| 60002 | walShmBarrier(pWal); |
| 60003 | memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr)); |
| 60004 | } |
| 60005 | |
| @@ -61165,36 +61185,17 @@ | |
| 61185 | ** cannot be backfilled from the WAL. |
| 61186 | */ |
| 61187 | mxSafeFrame = pWal->hdr.mxFrame; |
| 61188 | mxPage = pWal->hdr.nPage; |
| 61189 | for(i=1; i<WAL_NREADER; i++){ |
| 61190 | u32 y = AtomicLoad(pInfo->aReadMark+i); |
| 61191 | if( mxSafeFrame>y ){ |
| 61192 | assert( y<=pWal->hdr.mxFrame ); |
| 61193 | rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); |
| 61194 | if( rc==SQLITE_OK ){ |
| 61195 | u32 iMark = (i==1 ? mxSafeFrame : READMARK_NOT_USED); |
| 61196 | AtomicStore(pInfo->aReadMark+i, iMark); |
| 61197 | walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 61198 | }else if( rc==SQLITE_BUSY ){ |
| 61199 | mxSafeFrame = y; |
| 61200 | xBusy = 0; |
| 61201 | }else{ |
| @@ -61208,11 +61209,11 @@ | |
| 61209 | rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter); |
| 61210 | assert( rc==SQLITE_OK || pIter==0 ); |
| 61211 | } |
| 61212 | |
| 61213 | if( pIter |
| 61214 | && (rc = walBusyLock(pWal,xBusy,pBusyArg,WAL_READ_LOCK(0),1))==SQLITE_OK |
| 61215 | ){ |
| 61216 | u32 nBackfill = pInfo->nBackfill; |
| 61217 | |
| 61218 | pInfo->nBackfillAttempted = mxSafeFrame; |
| 61219 | |
| @@ -61423,11 +61424,11 @@ | |
| 61424 | ** and *pChanged is set to 1. |
| 61425 | ** |
| 61426 | ** If the checksum cannot be verified return non-zero. If the header |
| 61427 | ** is read successfully and the checksum verified, return zero. |
| 61428 | */ |
| 61429 | static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){ |
| 61430 | u32 aCksum[2]; /* Checksum on the header content */ |
| 61431 | WalIndexHdr h1, h2; /* Two copies of the header content */ |
| 61432 | WalIndexHdr volatile *aHdr; /* Header in shared memory */ |
| 61433 | |
| 61434 | /* The first page of the wal-index must be mapped at this point. */ |
| @@ -61436,17 +61437,23 @@ | |
| 61437 | /* Read the header. This might happen concurrently with a write to the |
| 61438 | ** same area of shared memory on a different CPU in a SMP, |
| 61439 | ** meaning it is possible that an inconsistent snapshot is read |
| 61440 | ** from the file. If this happens, return non-zero. |
| 61441 | ** |
| 61442 | ** tag-20200519-1: |
| 61443 | ** There are two copies of the header at the beginning of the wal-index. |
| 61444 | ** When reading, read [0] first then [1]. Writes are in the reverse order. |
| 61445 | ** Memory barriers are used to prevent the compiler or the hardware from |
| 61446 | ** reordering the reads and writes. TSAN and similar tools can sometimes |
| 61447 | ** give false-positive warnings about these accesses because the tools do not |
| 61448 | ** account for the double-read and the memory barrier. The use of mutexes |
| 61449 | ** here would be problematic as the memory being accessed is potentially |
| 61450 | ** shared among multiple processes and not all mutex implementions work |
| 61451 | ** reliably in that environment. |
| 61452 | */ |
| 61453 | aHdr = walIndexHdr(pWal); |
| 61454 | memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); /* Possible TSAN false-positive */ |
| 61455 | walShmBarrier(pWal); |
| 61456 | memcpy(&h2, (void *)&aHdr[1], sizeof(h2)); |
| 61457 | |
| 61458 | if( memcmp(&h1, &h2, sizeof(h1))!=0 ){ |
| 61459 | return 1; /* Dirty read */ |
| @@ -62283,26 +62290,28 @@ | |
| 62290 | for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){ |
| 62291 | WalHashLoc sLoc; /* Hash table location */ |
| 62292 | int iKey; /* Hash slot index */ |
| 62293 | int nCollide; /* Number of hash collisions remaining */ |
| 62294 | int rc; /* Error code */ |
| 62295 | u32 iH; |
| 62296 | |
| 62297 | rc = walHashGet(pWal, iHash, &sLoc); |
| 62298 | if( rc!=SQLITE_OK ){ |
| 62299 | return rc; |
| 62300 | } |
| 62301 | nCollide = HASHTABLE_NSLOT; |
| 62302 | iKey = walHash(pgno); |
| 62303 | while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){ |
| 62304 | u32 iFrame = iH + sLoc.iZero; |
| 62305 | if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){ |
| 62306 | assert( iFrame>iRead || CORRUPT_DB ); |
| 62307 | iRead = iFrame; |
| 62308 | } |
| 62309 | if( (nCollide--)==0 ){ |
| 62310 | return SQLITE_CORRUPT_BKPT; |
| 62311 | } |
| 62312 | iKey = walNextHash(iKey); |
| 62313 | } |
| 62314 | if( iRead ) break; |
| 62315 | } |
| 62316 | |
| 62317 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT |
| @@ -224738,11 +224747,11 @@ | |
| 224747 | int nArg, /* Number of args */ |
| 224748 | sqlite3_value **apUnused /* Function arguments */ |
| 224749 | ){ |
| 224750 | assert( nArg==0 ); |
| 224751 | UNUSED_PARAM2(nArg, apUnused); |
| 224752 | sqlite3_result_text(pCtx, "fts5: 2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde", -1, SQLITE_TRANSIENT); |
| 224753 | } |
| 224754 | |
| 224755 | /* |
| 224756 | ** Return true if zName is the extension on one of the shadow tables used |
| 224757 | ** by this module. |
| @@ -229521,12 +229530,12 @@ | |
| 229530 | } |
| 229531 | #endif /* SQLITE_CORE */ |
| 229532 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 229533 | |
| 229534 | /************** End of stmt.c ************************************************/ |
| 229535 | #if __LINE__!=229535 |
| 229536 | #undef SQLITE_SOURCE_ID |
| 229537 | #define SQLITE_SOURCE_ID "2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad4alt2" |
| 229538 | #endif |
| 229539 | /* Return the source-id for this library */ |
| 229540 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 229541 | /************************** End of sqlite3.c ******************************/ |
| 229542 |
+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.32.0" |
| 127 | 127 | #define SQLITE_VERSION_NUMBER 3032000 |
| 128 | -#define SQLITE_SOURCE_ID "2020-05-17 13:47:28 69e149f76853d196c8855fedfc98848b60fb116ac36bc08824b1a122469f8ece" | |
| 128 | +#define SQLITE_SOURCE_ID "2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde" | |
| 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.32.0" |
| 127 | #define SQLITE_VERSION_NUMBER 3032000 |
| 128 | #define SQLITE_SOURCE_ID "2020-05-17 13:47:28 69e149f76853d196c8855fedfc98848b60fb116ac36bc08824b1a122469f8ece" |
| 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.32.0" |
| 127 | #define SQLITE_VERSION_NUMBER 3032000 |
| 128 | #define SQLITE_SOURCE_ID "2020-05-19 15:51:10 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde" |
| 129 | |
| 130 | /* |
| 131 | ** CAPI3REF: Run-Time Library Version Numbers |
| 132 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 133 | ** |
| 134 |