mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Continuing refinements to the filesize-in-header enhancement.
FossilOrigin-Name: 79e22b95038c50b9b7f35e09262805ff6338b59b
This commit is contained in:
28
manifest
28
manifest
@@ -1,8 +1,8 @@
|
|||||||
-----BEGIN PGP SIGNED MESSAGE-----
|
-----BEGIN PGP SIGNED MESSAGE-----
|
||||||
Hash: SHA1
|
Hash: SHA1
|
||||||
|
|
||||||
C Add\sa\sNEVER\smacro\saround\sa\stest\sin\sbtree.c\sthat\scan\snot\slonger\sbe\strue.
|
C Continuing\srefinements\sto\sthe\sfilesize-in-header\senhancement.
|
||||||
D 2010-03-30T15:51:13
|
D 2010-03-30T22:58:34
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
|
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -109,11 +109,11 @@ F src/alter.c e6f4d11b1c0b23642fc46bac9abe0753c4294e05
|
|||||||
F src/analyze.c 8dfd781ac326496746ecdfc3e099250ed5d79be5
|
F src/analyze.c 8dfd781ac326496746ecdfc3e099250ed5d79be5
|
||||||
F src/attach.c 7abe1607c2054585377cdba3c219e8572f84ca5e
|
F src/attach.c 7abe1607c2054585377cdba3c219e8572f84ca5e
|
||||||
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
||||||
F src/backup.c b293534bc2df23c57668a585b17ee7faaaef0939
|
F src/backup.c e86634da8c48357a759694c9c7c471125cd8d5a8
|
||||||
F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0
|
F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0
|
||||||
F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff
|
F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff
|
||||||
F src/btree.c dc9dc08fcc61f65cd7d85d85fc08905475eea406
|
F src/btree.c d3a0ee18bd4aa2339e9cf2f7d93f67b022b4670b
|
||||||
F src/btree.h 0e193b7e90f1d78b79c79474040e3d66a553a4fa
|
F src/btree.h ad6cff92286f9b02ec32f0b97136e9a544249f37
|
||||||
F src/btreeInt.h 22447d259639271774a931cbf66aa55112846681
|
F src/btreeInt.h 22447d259639271774a931cbf66aa55112846681
|
||||||
F src/build.c 11100b66fb97638d2d874c1d34d8db90650bb1d7
|
F src/build.c 11100b66fb97638d2d874c1d34d8db90650bb1d7
|
||||||
F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f
|
F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f
|
||||||
@@ -155,7 +155,7 @@ F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30
|
|||||||
F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f
|
F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f
|
||||||
F src/os_unix.c 148d2f625db3727250c0b880481ae7630b6d0eb0
|
F src/os_unix.c 148d2f625db3727250c0b880481ae7630b6d0eb0
|
||||||
F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053
|
F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053
|
||||||
F src/pager.c af1c58b7b884839853cc553681f771297de56049
|
F src/pager.c 0fcd5b4359a0c1fcf06b705a5060ad7597802082
|
||||||
F src/pager.h ef8a2cf10084f60ab45ee2dfded8bf8b0c655ddf
|
F src/pager.h ef8a2cf10084f60ab45ee2dfded8bf8b0c655ddf
|
||||||
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
|
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
|
||||||
F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
|
F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
|
||||||
@@ -214,7 +214,7 @@ F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208
|
|||||||
F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685
|
F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685
|
||||||
F src/util.c 32aebf04c10e51ad3977a928b7416bed671b620b
|
F src/util.c 32aebf04c10e51ad3977a928b7416bed671b620b
|
||||||
F src/vacuum.c b1d542c8919d4d11119f78069e1906a1ad07e0ee
|
F src/vacuum.c b1d542c8919d4d11119f78069e1906a1ad07e0ee
|
||||||
F src/vdbe.c 8acca6dab2505e9650f6f014ada6ef30570cba99
|
F src/vdbe.c afd58607e70bca91da8c5f9effeef0065862d0d0
|
||||||
F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3
|
F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3
|
||||||
F src/vdbeInt.h ae1e6ba0dd3fb4a886898d2829d748be701b01f8
|
F src/vdbeInt.h ae1e6ba0dd3fb4a886898d2829d748be701b01f8
|
||||||
F src/vdbeapi.c 74c25680046a116b24b95393914d3669c23305dc
|
F src/vdbeapi.c 74c25680046a116b24b95393914d3669c23305dc
|
||||||
@@ -239,7 +239,7 @@ F test/analyze3.test 506203875258ffd8ffa879b9c3c5432022d2b6d8
|
|||||||
F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb
|
F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb
|
||||||
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
|
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
|
||||||
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
|
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
|
||||||
F test/async4.test aafa6328c559d3e4bb587de770cbdecfca06f0da
|
F test/async4.test 166cc07057ff6f908fe42dcffaa8ca732c757acb
|
||||||
F test/async5.test f3592d79c84d6e83a5f50d3fd500445f7d97dfdf
|
F test/async5.test f3592d79c84d6e83a5f50d3fd500445f7d97dfdf
|
||||||
F test/attach.test ce9660e51768fab93cf129787be886c5d6c4fd81
|
F test/attach.test ce9660e51768fab93cf129787be886c5d6c4fd81
|
||||||
F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
|
F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
|
||||||
@@ -797,14 +797,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P ca359a3e8048bd11605c41c4b48134c0343e543b
|
P c117f99236a009778bb7878da464918554391f0a
|
||||||
R 32ec8ae8b71a3dfac8895cb995707072
|
R efa6bf51e48ad2d5be1cf09661f1f24c
|
||||||
U drh
|
U drh
|
||||||
Z b60f084ae0f371ea36d8a15f0b37127b
|
Z b0d1f74939d4990ca433eff4c752959f
|
||||||
-----BEGIN PGP SIGNATURE-----
|
-----BEGIN PGP SIGNATURE-----
|
||||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||||
|
|
||||||
iD8DBQFLsh30oxKgR168RlERAh4HAJ9Ddtt3lx/ldCmB2GllUt31h81qEwCfZ4JP
|
iD8DBQFLsoIeoxKgR168RlERAll7AKCH3KzJCOwYaOHCNPa0u9bjSrh3pACeK50J
|
||||||
cTXZAF6OUE+YI98jV9daDJc=
|
6SkuHmaYw2uYZf0RGmlXHx8=
|
||||||
=R6CC
|
=y9Cm
|
||||||
-----END PGP SIGNATURE-----
|
-----END PGP SIGNATURE-----
|
||||||
|
@@ -1 +1 @@
|
|||||||
c117f99236a009778bb7878da464918554391f0a
|
79e22b95038c50b9b7f35e09262805ff6338b59b
|
@@ -331,9 +331,8 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
|||||||
/* Now that there is a read-lock on the source database, query the
|
/* Now that there is a read-lock on the source database, query the
|
||||||
** source pager for the number of pages in the database.
|
** source pager for the number of pages in the database.
|
||||||
*/
|
*/
|
||||||
if( rc==SQLITE_OK ){
|
nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc);
|
||||||
rc = sqlite3PagerPagecount(pSrcPager, &nSrcPage);
|
assert( nSrcPage>=0 );
|
||||||
}
|
|
||||||
for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){
|
for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){
|
||||||
const Pgno iSrcPg = p->iNext; /* Source page number */
|
const Pgno iSrcPg = p->iNext; /* Source page number */
|
||||||
if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){
|
if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){
|
||||||
|
28
src/btree.c
28
src/btree.c
@@ -1560,9 +1560,13 @@ static MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){
|
|||||||
** Return the size of the database file in pages. If there is any kind of
|
** Return the size of the database file in pages. If there is any kind of
|
||||||
** error, return ((unsigned int)-1).
|
** error, return ((unsigned int)-1).
|
||||||
*/
|
*/
|
||||||
static Pgno pagerPagecount(BtShared *pBt){
|
static Pgno btreePagecount(BtShared *pBt){
|
||||||
int nPage = (int)pBt->nPage;
|
return pBt->nPage;
|
||||||
return nPage;
|
}
|
||||||
|
u32 sqlite3BtreeLastPage(Btree *p){
|
||||||
|
assert( sqlite3BtreeHoldsMutex(p) );
|
||||||
|
assert( ((p->pBt->nPage)&0x8000000)==0 );
|
||||||
|
return (int)btreePagecount(p->pBt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1579,7 +1583,7 @@ static int getAndInitPage(
|
|||||||
MemPage **ppPage /* Write the page pointer here */
|
MemPage **ppPage /* Write the page pointer here */
|
||||||
){
|
){
|
||||||
int rc;
|
int rc;
|
||||||
TESTONLY( Pgno iLastPg = pagerPagecount(pBt); )
|
TESTONLY( Pgno iLastPg = btreePagecount(pBt); )
|
||||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
|
|
||||||
rc = btreeGetPage(pBt, pgno, ppPage, 0);
|
rc = btreeGetPage(pBt, pgno, ppPage, 0);
|
||||||
@@ -2881,7 +2885,7 @@ int sqlite3BtreeIncrVacuum(Btree *p){
|
|||||||
rc = SQLITE_DONE;
|
rc = SQLITE_DONE;
|
||||||
}else{
|
}else{
|
||||||
invalidateAllOverflowCache(pBt);
|
invalidateAllOverflowCache(pBt);
|
||||||
rc = incrVacuumStep(pBt, 0, pagerPagecount(pBt));
|
rc = incrVacuumStep(pBt, 0, btreePagecount(pBt));
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
|
rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
|
||||||
put4byte(&pBt->pPage1->aData[28], pBt->nPage);
|
put4byte(&pBt->pPage1->aData[28], pBt->nPage);
|
||||||
@@ -2916,7 +2920,7 @@ static int autoVacuumCommit(BtShared *pBt){
|
|||||||
int nEntry; /* Number of entries on one ptrmap page */
|
int nEntry; /* Number of entries on one ptrmap page */
|
||||||
Pgno nOrig; /* Database size before freeing */
|
Pgno nOrig; /* Database size before freeing */
|
||||||
|
|
||||||
nOrig = pagerPagecount(pBt);
|
nOrig = btreePagecount(pBt);
|
||||||
if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){
|
if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){
|
||||||
/* It is not possible to create a database for which the final page
|
/* It is not possible to create a database for which the final page
|
||||||
** is either a pointer-map page or the pending-byte page. If one
|
** is either a pointer-map page or the pending-byte page. If one
|
||||||
@@ -3333,7 +3337,7 @@ static int btreeCursor(
|
|||||||
if( NEVER(wrFlag && pBt->readOnly) ){
|
if( NEVER(wrFlag && pBt->readOnly) ){
|
||||||
return SQLITE_READONLY;
|
return SQLITE_READONLY;
|
||||||
}
|
}
|
||||||
if( iTable==1 && pagerPagecount(pBt)==0 ){
|
if( iTable==1 && btreePagecount(pBt)==0 ){
|
||||||
return SQLITE_EMPTY;
|
return SQLITE_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3604,7 +3608,7 @@ static int getOverflowPage(
|
|||||||
iGuess++;
|
iGuess++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( iGuess<=pagerPagecount(pBt) ){
|
if( iGuess<=btreePagecount(pBt) ){
|
||||||
rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
|
rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
|
||||||
if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
|
if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
|
||||||
next = iGuess;
|
next = iGuess;
|
||||||
@@ -4636,7 +4640,7 @@ static int allocateBtreePage(
|
|||||||
|
|
||||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
pPage1 = pBt->pPage1;
|
pPage1 = pBt->pPage1;
|
||||||
mxPage = pagerPagecount(pBt);
|
mxPage = btreePagecount(pBt);
|
||||||
n = get4byte(&pPage1->aData[36]);
|
n = get4byte(&pPage1->aData[36]);
|
||||||
testcase( n==mxPage-1 );
|
testcase( n==mxPage-1 );
|
||||||
if( n>=mxPage ){
|
if( n>=mxPage ){
|
||||||
@@ -5050,7 +5054,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
|
|||||||
while( nOvfl-- ){
|
while( nOvfl-- ){
|
||||||
Pgno iNext = 0;
|
Pgno iNext = 0;
|
||||||
MemPage *pOvfl = 0;
|
MemPage *pOvfl = 0;
|
||||||
if( ovflPgno<2 || ovflPgno>pagerPagecount(pBt) ){
|
if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){
|
||||||
/* 0 is not a legal page number and page 1 cannot be an
|
/* 0 is not a legal page number and page 1 cannot be an
|
||||||
** overflow page. Therefore if ovflPgno<2 or past the end of the
|
** overflow page. Therefore if ovflPgno<2 or past the end of the
|
||||||
** file the database must be corrupt. */
|
** file the database must be corrupt. */
|
||||||
@@ -6929,7 +6933,7 @@ static int clearDatabasePage(
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
if( pgno>pagerPagecount(pBt) ){
|
if( pgno>btreePagecount(pBt) ){
|
||||||
return SQLITE_CORRUPT_BKPT;
|
return SQLITE_CORRUPT_BKPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7680,7 +7684,7 @@ char *sqlite3BtreeIntegrityCheck(
|
|||||||
nRef = sqlite3PagerRefcount(pBt->pPager);
|
nRef = sqlite3PagerRefcount(pBt->pPager);
|
||||||
sCheck.pBt = pBt;
|
sCheck.pBt = pBt;
|
||||||
sCheck.pPager = pBt->pPager;
|
sCheck.pPager = pBt->pPager;
|
||||||
sCheck.nPage = pagerPagecount(sCheck.pBt);
|
sCheck.nPage = btreePagecount(sCheck.pBt);
|
||||||
sCheck.mxErr = mxErr;
|
sCheck.mxErr = mxErr;
|
||||||
sCheck.nErr = 0;
|
sCheck.nErr = 0;
|
||||||
sCheck.mallocFailed = 0;
|
sCheck.mallocFailed = 0;
|
||||||
|
@@ -81,6 +81,7 @@ int sqlite3BtreeSyncDisabled(Btree*);
|
|||||||
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
|
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
|
||||||
int sqlite3BtreeGetPageSize(Btree*);
|
int sqlite3BtreeGetPageSize(Btree*);
|
||||||
int sqlite3BtreeMaxPageCount(Btree*,int);
|
int sqlite3BtreeMaxPageCount(Btree*,int);
|
||||||
|
u32 sqlite3BtreeLastPage(Btree*);
|
||||||
int sqlite3BtreeSecureDelete(Btree*,int);
|
int sqlite3BtreeSecureDelete(Btree*,int);
|
||||||
int sqlite3BtreeGetReserve(Btree*);
|
int sqlite3BtreeGetReserve(Btree*);
|
||||||
int sqlite3BtreeSetAutoVacuum(Btree *, int);
|
int sqlite3BtreeSetAutoVacuum(Btree *, int);
|
||||||
|
35
src/pager.c
35
src/pager.c
@@ -1123,8 +1123,9 @@ static void pager_unlock(Pager *pPager){
|
|||||||
|
|
||||||
/* If the file is unlocked, somebody else might change it. The
|
/* If the file is unlocked, somebody else might change it. The
|
||||||
** values stored in Pager.dbSize etc. might become invalid if
|
** values stored in Pager.dbSize etc. might become invalid if
|
||||||
** this happens. TODO: Really, this doesn't need to be cleared
|
** this happens. One can argue that this doesn't need to be cleared
|
||||||
** until the change-counter check fails in PagerSharedLock().
|
** until the change-counter check fails in PagerSharedLock().
|
||||||
|
** Clearing the page size cache here is being conservative.
|
||||||
*/
|
*/
|
||||||
pPager->dbSizeValid = 0;
|
pPager->dbSizeValid = 0;
|
||||||
|
|
||||||
@@ -2382,10 +2383,12 @@ void *sqlite3PagerTempSpace(Pager *pPager){
|
|||||||
** Regardless of mxPage, return the current maximum page count.
|
** Regardless of mxPage, return the current maximum page count.
|
||||||
*/
|
*/
|
||||||
int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
|
int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
|
||||||
|
int nPage;
|
||||||
if( mxPage>0 ){
|
if( mxPage>0 ){
|
||||||
pPager->mxPgno = mxPage;
|
pPager->mxPgno = mxPage;
|
||||||
}
|
}
|
||||||
sqlite3PagerPagecount(pPager, 0);
|
sqlite3PagerPagecount(pPager, &nPage);
|
||||||
|
assert( pPager->mxPgno>=nPage );
|
||||||
return pPager->mxPgno;
|
return pPager->mxPgno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2497,9 +2500,7 @@ int sqlite3PagerPagecount(Pager *pPager, int *pnPage){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set the output variable and return SQLITE_OK */
|
/* Set the output variable and return SQLITE_OK */
|
||||||
if( pnPage ){
|
*pnPage = nPage;
|
||||||
*pnPage = nPage;
|
|
||||||
}
|
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3697,16 +3698,16 @@ int sqlite3PagerSharedLock(Pager *pPager){
|
|||||||
** detected. The chance of an undetected change is so small that
|
** detected. The chance of an undetected change is so small that
|
||||||
** it can be neglected.
|
** it can be neglected.
|
||||||
*/
|
*/
|
||||||
|
int nPage;
|
||||||
char dbFileVers[sizeof(pPager->dbFileVers)];
|
char dbFileVers[sizeof(pPager->dbFileVers)];
|
||||||
sqlite3PagerPagecount(pPager, 0);
|
sqlite3PagerPagecount(pPager, &nPage);
|
||||||
|
|
||||||
if( pPager->errCode ){
|
if( pPager->errCode ){
|
||||||
rc = pPager->errCode;
|
rc = pPager->errCode;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( pPager->dbSizeValid );
|
if( nPage>0 ){
|
||||||
if( pPager->dbSize>0 ){
|
|
||||||
IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
|
IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
|
||||||
rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
|
rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
@@ -3991,6 +3992,7 @@ static int openSubJournal(Pager *pPager){
|
|||||||
*/
|
*/
|
||||||
static int pager_open_journal(Pager *pPager){
|
static int pager_open_journal(Pager *pPager){
|
||||||
int rc = SQLITE_OK; /* Return code */
|
int rc = SQLITE_OK; /* Return code */
|
||||||
|
int nPage; /* Size of database file */
|
||||||
sqlite3_vfs * const pVfs = pPager->pVfs; /* Local cache of vfs pointer */
|
sqlite3_vfs * const pVfs = pPager->pVfs; /* Local cache of vfs pointer */
|
||||||
|
|
||||||
assert( pPager->state>=PAGER_RESERVED );
|
assert( pPager->state>=PAGER_RESERVED );
|
||||||
@@ -4003,13 +4005,9 @@ static int pager_open_journal(Pager *pPager){
|
|||||||
** an error state. */
|
** an error state. */
|
||||||
if( NEVER(pPager->errCode) ) return pPager->errCode;
|
if( NEVER(pPager->errCode) ) return pPager->errCode;
|
||||||
|
|
||||||
/* TODO: Is it really possible to get here with dbSizeValid==0? If not,
|
|
||||||
** the call to PagerPagecount() can be removed.
|
|
||||||
*/
|
|
||||||
testcase( pPager->dbSizeValid==0 );
|
testcase( pPager->dbSizeValid==0 );
|
||||||
sqlite3PagerPagecount(pPager, 0);
|
sqlite3PagerPagecount(pPager, &nPage);
|
||||||
|
pPager->pInJournal = sqlite3BitvecCreate(nPage);
|
||||||
pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);
|
|
||||||
if( pPager->pInJournal==0 ){
|
if( pPager->pInJournal==0 ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
@@ -4490,7 +4488,6 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
|
|||||||
put32bits(((char*)pPgHdr->pData)+24, change_counter);
|
put32bits(((char*)pPgHdr->pData)+24, change_counter);
|
||||||
|
|
||||||
/* Also store the SQLite version number in bytes 96..99 */
|
/* Also store the SQLite version number in bytes 96..99 */
|
||||||
assert( pPager->dbSizeValid );
|
|
||||||
put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER);
|
put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER);
|
||||||
|
|
||||||
/* If running in direct mode, write the contents of page 1 to the file. */
|
/* If running in direct mode, write the contents of page 1 to the file. */
|
||||||
@@ -4918,8 +4915,9 @@ int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
|
|||||||
if( nSavepoint>nCurrent && pPager->useJournal ){
|
if( nSavepoint>nCurrent && pPager->useJournal ){
|
||||||
int ii; /* Iterator variable */
|
int ii; /* Iterator variable */
|
||||||
PagerSavepoint *aNew; /* New Pager.aSavepoint array */
|
PagerSavepoint *aNew; /* New Pager.aSavepoint array */
|
||||||
|
int nPage; /* Size of database file */
|
||||||
|
|
||||||
rc = sqlite3PagerPagecount(pPager, 0);
|
rc = sqlite3PagerPagecount(pPager, &nPage);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
|
|
||||||
/* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
|
/* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
|
||||||
@@ -4938,15 +4936,14 @@ int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
|
|||||||
|
|
||||||
/* Populate the PagerSavepoint structures just allocated. */
|
/* Populate the PagerSavepoint structures just allocated. */
|
||||||
for(ii=nCurrent; ii<nSavepoint; ii++){
|
for(ii=nCurrent; ii<nSavepoint; ii++){
|
||||||
assert( pPager->dbSizeValid );
|
aNew[ii].nOrig = nPage;
|
||||||
aNew[ii].nOrig = pPager->dbSize;
|
|
||||||
if( isOpen(pPager->jfd) && pPager->journalOff>0 ){
|
if( isOpen(pPager->jfd) && pPager->journalOff>0 ){
|
||||||
aNew[ii].iOffset = pPager->journalOff;
|
aNew[ii].iOffset = pPager->journalOff;
|
||||||
}else{
|
}else{
|
||||||
aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);
|
aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);
|
||||||
}
|
}
|
||||||
aNew[ii].iSubRec = pPager->nSubRec;
|
aNew[ii].iSubRec = pPager->nSubRec;
|
||||||
aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);
|
aNew[ii].pInSavepoint = sqlite3BitvecCreate(nPage);
|
||||||
if( !aNew[ii].pInSavepoint ){
|
if( !aNew[ii].pInSavepoint ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
|
14
src/vdbe.c
14
src/vdbe.c
@@ -5616,19 +5616,7 @@ case OP_VUpdate: {
|
|||||||
** Write the current number of pages in database P1 to memory cell P2.
|
** Write the current number of pages in database P1 to memory cell P2.
|
||||||
*/
|
*/
|
||||||
case OP_Pagecount: { /* out2-prerelease */
|
case OP_Pagecount: { /* out2-prerelease */
|
||||||
int p1;
|
pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);
|
||||||
int nPage;
|
|
||||||
Pager *pPager;
|
|
||||||
|
|
||||||
p1 = pOp->p1;
|
|
||||||
pPager = sqlite3BtreePager(db->aDb[p1].pBt);
|
|
||||||
rc = sqlite3PagerPagecount(pPager, &nPage);
|
|
||||||
/* OP_Pagecount is always called from within a read transaction. The
|
|
||||||
** page count has already been successfully read and cached. So the
|
|
||||||
** sqlite3PagerPagecount() call above cannot fail. */
|
|
||||||
if( ALWAYS(rc==SQLITE_OK) ){
|
|
||||||
pOut->u.i = nPage;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -94,6 +94,7 @@ do_test async4.1.14 {
|
|||||||
do_test async4.1.15 {
|
do_test async4.1.15 {
|
||||||
sqlite3async_start
|
sqlite3async_start
|
||||||
sqlite3async_wait
|
sqlite3async_wait
|
||||||
|
hexio_write test.db 28 00000000
|
||||||
execsql { pragma integrity_check } db2
|
execsql { pragma integrity_check } db2
|
||||||
} {{*** in database main ***
|
} {{*** in database main ***
|
||||||
Page 5 is never used}}
|
Page 5 is never used}}
|
||||||
|
Reference in New Issue
Block a user