1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Fix a problem reading from temp databases in SQLITE_DIRECT_OVERFLOW_READ

builds.

FossilOrigin-Name: 81629ba91475938b6ad528e7b1dbef4ad22239782bb2e9c1bb59413aba11da87
This commit is contained in:
dan
2018-11-22 19:10:14 +00:00
parent 8055a3ead4
commit 09236755ee
8 changed files with 78 additions and 20 deletions

View File

@@ -4758,9 +4758,6 @@ static int accessPayload(
/* Need to read this page properly. It contains some of the
** range of data that is being read (eOp==0) or written (eOp!=0).
*/
#ifdef SQLITE_DIRECT_OVERFLOW_READ
sqlite3_file *fd; /* File from which to do direct overflow read */
#endif
int a = amt;
if( a + offset > ovflSize ){
a = ovflSize - offset;
@@ -4771,7 +4768,7 @@ static int accessPayload(
**
** 1) this is a read operation, and
** 2) data is required from the start of this overflow page, and
** 3) there is no open write-transaction, and
** 3) there are no dirty pages in the page-cache
** 4) the database is file-backed, and
** 5) the page is not in the WAL file
** 6) at least 4 bytes have already been read into the output buffer
@@ -4782,11 +4779,10 @@ static int accessPayload(
*/
if( eOp==0 /* (1) */
&& offset==0 /* (2) */
&& pBt->inTransaction==TRANS_READ /* (3) */
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (4) */
&& 0==sqlite3PagerUseWal(pBt->pPager, nextPage) /* (5) */
&& sqlite3PagerDirectReadOk(pBt->pPager, nextPage) /* (3,4,5) */
&& &pBuf[-4]>=pBufStart /* (6) */
){
sqlite3_file *fd = sqlite3PagerFile(pBt->pPager);
u8 aSave[4];
u8 *aWrite = &pBuf[-4];
assert( aWrite>=pBufStart ); /* due to (6) */