diff --git a/manifest b/manifest index 32a5baf41b..67fa8c4f42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_db_release_memory()\sinterface\sand\sthe\sshrink_memory\spragma. -D 2011-11-16T19:29:17.253 +C Back\sout\sthe\s[ceee03c79a]\schange. +D 2011-11-16T23:29:37.606 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -125,7 +125,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 4368158da74d4711888e03264105c5c527d76caf F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 149cccf2134f555583d0825e47b17104aa06cb84 +F src/btree.c 2521a74f04cf288497af3b318fa3a31efb272ef6 F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h ea863a819224d3e6845ad1e39954d41558b8cd8b F src/build.c 8915bb6d72ead998f94c2756ea8d143c77709b70 @@ -976,7 +976,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 457513f21f2438c61b1a214716e338a4e3eeaafa -R 2aefebff3180a54a438215134f3a783d +P 3f58e7c8895d1252eff56282c08b1a6f1194452c 1bbbf8574a820c5f787a937f02a8e2a91264ace0 +R 8e7cbea058ef7fa5fd72b3406095ff67 U drh -Z 6faa593abe3d90439929fe507a12385d +Z e301581f8f88dd3a374b15753c08fc01 diff --git a/manifest.uuid b/manifest.uuid index f09b57bd77..485d59ac9c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3f58e7c8895d1252eff56282c08b1a6f1194452c \ No newline at end of file +69ec53fc1c60b07bf4aaa983dcd5bf3164fb1ea5 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 43933fa27d..a1b05e1f3e 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1776,12 +1776,7 @@ int sqlite3BtreeOpen( sqlite3_free(p); return SQLITE_NOMEM; } - rc = sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname); - if( rc ){ - sqlite3_free(zFullPathname); - sqlite3_free(p); - return rc; - } + sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname); #if SQLITE_THREADSAFE mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN); sqlite3_mutex_enter(mutexOpen); @@ -2482,9 +2477,9 @@ static int newDatabase(BtShared *pBt){ } pP1 = pBt->pPage1; assert( pP1!=0 ); + data = pP1->aData; rc = sqlite3PagerWrite(pP1->pDbPage); if( rc ) return rc; - data = pP1->aData; memcpy(data, zMagicHeader, sizeof(zMagicHeader)); assert( sizeof(zMagicHeader)==16 ); data[16] = (u8)((pBt->pageSize>>8)&0xff); @@ -3782,6 +3777,38 @@ static int getOverflowPage( return (rc==SQLITE_DONE ? SQLITE_OK : rc); } +/* +** Copy data from a buffer to a page, or from a page to a buffer. +** +** pPayload is a pointer to data stored on database page pDbPage. +** If argument eOp is false, then nByte bytes of data are copied +** from pPayload to the buffer pointed at by pBuf. If eOp is true, +** then sqlite3PagerWrite() is called on pDbPage and nByte bytes +** of data are copied from the buffer pBuf to pPayload. +** +** SQLITE_OK is returned on success, otherwise an error code. +*/ +static int copyPayload( + void *pPayload, /* Pointer to page data */ + void *pBuf, /* Pointer to buffer */ + int nByte, /* Number of bytes to copy */ + int eOp, /* 0 -> copy from page, 1 -> copy to page */ + DbPage *pDbPage /* Page containing pPayload */ +){ + if( eOp ){ + /* Copy data from buffer to page (a write operation) */ + int rc = sqlite3PagerWrite(pDbPage); + if( rc!=SQLITE_OK ){ + return rc; + } + memcpy(pPayload, pBuf, nByte); + }else{ + /* Copy data from page to buffer (a read operation) */ + memcpy(pBuf, pPayload, nByte); + } + return SQLITE_OK; +} + /* ** This function is used to read or overwrite payload information ** for the entry that the pCur cursor is pointing to. If the eOp @@ -3829,7 +3856,6 @@ static int accessPayload( assert( pCur->aiIdx[pCur->iPage]nCell ); assert( cursorHoldsMutex(pCur) ); - getCellInfo(pCur); aPayload = pCur->info.pCell + pCur->info.nHeader; nKey = (pPage->intKey ? 0 : (int)pCur->info.nKey); @@ -3847,14 +3873,7 @@ static int accessPayload( if( a+offset>pCur->info.nLocal ){ a = pCur->info.nLocal - offset; } - if( eOp ){ - if( (rc = sqlite3PagerWrite(pPage->pDbPage))!=SQLITE_OK ) return rc; - getCellInfo(pCur); - aPayload = pCur->info.pCell + pCur->info.nHeader; - memcpy(aPayload+offset, pBuf, a); - }else{ - memcpy(pBuf, aPayload+offset, a); - } + rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage); offset = 0; pBuf += a; amt -= a; @@ -3965,17 +3984,9 @@ static int accessPayload( DbPage *pDbPage; rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage); if( rc==SQLITE_OK ){ - if( eOp && (rc = sqlite3PagerWrite(pDbPage))!=SQLITE_OK ){ - sqlite3PagerUnref(pDbPage); - return rc; - } aPayload = sqlite3PagerGetData(pDbPage); nextPage = get4byte(aPayload); - if( eOp ){ - memcpy(&aPayload[offset+4], pBuf, a); - }else{ - memcpy(pBuf, &aPayload[offset+4], a); - } + rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage); sqlite3PagerUnref(pDbPage); offset = 0; } @@ -7374,14 +7385,16 @@ void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){ */ int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){ BtShared *pBt = p->pBt; + unsigned char *pP1; int rc; assert( idx>=1 && idx<=15 ); sqlite3BtreeEnter(p); assert( p->inTrans==TRANS_WRITE ); assert( pBt->pPage1!=0 ); + pP1 = pBt->pPage1->aData; rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); if( rc==SQLITE_OK ){ - put4byte(&pBt->pPage1->aData[36 + idx*4], iMeta); + put4byte(&pP1[36 + idx*4], iMeta); #ifndef SQLITE_OMIT_AUTOVACUUM if( idx==BTREE_INCR_VACUUM ){ assert( pBt->autoVacuum || iMeta==0 ); @@ -8210,7 +8223,6 @@ int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){ if( rc==SQLITE_OK ){ rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); if( rc==SQLITE_OK ){ - aData = pBt->pPage1->aData; aData[18] = (u8)iVersion; aData[19] = (u8)iVersion; }