Another fix to rbu vacuum for a zipvfs case.
FossilOrigin-Name: 29407d70e44ad9ea5ddaf1011d0e212b602a3ddf
This commit is contained in:
parent
beccf1d16f
commit
58e3812988
@ -370,6 +370,10 @@ struct sqlite3rbu {
|
||||
int pgsz;
|
||||
u8 *aBuf;
|
||||
i64 iWalCksum;
|
||||
|
||||
/* Used in RBU vacuum mode only */
|
||||
int nRbu; /* Number of RBU VFS in the stack */
|
||||
rbu_file *pRbuFd; /* Fd for main db of dbRbu */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -2328,7 +2332,6 @@ static RbuState *rbuLoadState(sqlite3rbu *p){
|
||||
** error occurs, leave an error code and message in the RBU handle.
|
||||
*/
|
||||
static void rbuOpenDatabase(sqlite3rbu *p){
|
||||
int nRbu = 0;
|
||||
assert( p->rc==SQLITE_OK );
|
||||
assert( p->dbMain==0 && p->dbRbu==0 );
|
||||
assert( rbuIsVacuum(p) || p->zTarget!=0 );
|
||||
@ -2337,7 +2340,7 @@ static void rbuOpenDatabase(sqlite3rbu *p){
|
||||
p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1);
|
||||
|
||||
if( rbuIsVacuum(p) ){
|
||||
sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, &nRbu);
|
||||
sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p);
|
||||
}
|
||||
|
||||
/* If using separate RBU and state databases, attach the state database to
|
||||
@ -2354,6 +2357,9 @@ static void rbuOpenDatabase(sqlite3rbu *p){
|
||||
|
||||
if( rbuIsVacuum(p) ){
|
||||
int bOpen = 0;
|
||||
p->nRbu = 0;
|
||||
p->pRbuFd = 0;
|
||||
sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p);
|
||||
if( p->eStage>=RBU_STAGE_MOVE ){
|
||||
bOpen = 1;
|
||||
}else{
|
||||
@ -2363,7 +2369,7 @@ static void rbuOpenDatabase(sqlite3rbu *p){
|
||||
rbuFreeState(pState);
|
||||
}
|
||||
}
|
||||
if( bOpen ) p->dbMain = rbuOpenDbhandle(p, p->zRbu, nRbu<=1);
|
||||
if( bOpen ) p->dbMain = rbuOpenDbhandle(p, p->zRbu, p->nRbu<=1);
|
||||
}
|
||||
|
||||
p->eStage = 0;
|
||||
@ -2376,7 +2382,7 @@ static void rbuOpenDatabase(sqlite3rbu *p){
|
||||
p->rc = SQLITE_NOMEM;
|
||||
return;
|
||||
}
|
||||
p->dbMain = rbuOpenDbhandle(p, zTarget, nRbu<=1);
|
||||
p->dbMain = rbuOpenDbhandle(p, zTarget, p->nRbu<=1);
|
||||
sqlite3_free(zTarget);
|
||||
}
|
||||
}
|
||||
@ -3823,17 +3829,12 @@ static int rbuVfsRead(
|
||||
** database as part of an rbu vacuum operation, synthesize the
|
||||
** contents of the first page if it does not yet exist. Otherwise,
|
||||
** SQLite will not check for a *-wal file. */
|
||||
if( p->pRbu && rbuIsVacuum(p->pRbu)
|
||||
if( pRbu && rbuIsVacuum(pRbu)
|
||||
&& rc==SQLITE_IOERR_SHORT_READ && iOfst==0
|
||||
&& (p->openFlags & SQLITE_OPEN_MAIN_DB)
|
||||
){
|
||||
sqlite3_file *pFd = 0;
|
||||
rc = sqlite3_file_control(
|
||||
p->pRbu->dbRbu, "main", SQLITE_FCNTL_FILE_POINTER, (void*)&pFd
|
||||
);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = pFd->pMethods->xRead(pFd, zBuf, iAmt, iOfst);
|
||||
}
|
||||
sqlite3_file *pFd = (sqlite3_file*)pRbu->pRbuFd;
|
||||
rc = pFd->pMethods->xRead(pFd, zBuf, iAmt, iOfst);
|
||||
if( rc==SQLITE_OK ){
|
||||
u8 *aBuf = (u8*)zBuf;
|
||||
rbuPutU32(&aBuf[52], 0); /* largest root page number */
|
||||
@ -4021,8 +4022,9 @@ static int rbuVfsFileControl(sqlite3_file *pFile, int op, void *pArg){
|
||||
return rc;
|
||||
}
|
||||
else if( op==SQLITE_FCNTL_RBUCNT ){
|
||||
int *pnRbu = (int*)pArg;
|
||||
(*pnRbu)++;
|
||||
sqlite3rbu *pRbu = (sqlite3rbu*)pArg;
|
||||
pRbu->nRbu++;
|
||||
pRbu->pRbuFd = p;
|
||||
p->bNolock = 1;
|
||||
}
|
||||
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\ssome\szipvfs\srelated\sproblems\sin\sRBU\svacuum.
|
||||
D 2016-04-18T18:18:18.881
|
||||
C Another\sfix\sto\srbu\svacuum\sfor\sa\szipvfs\scase.
|
||||
D 2016-04-18T21:00:01.258
|
||||
F Makefile.in eba680121821b8a60940a81454316f47a341487a
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836
|
||||
@ -247,7 +247,7 @@ F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda
|
||||
F ext/rbu/rbuprogress.test 2023a7df2c523e3df1cb532eff811cda385a789a
|
||||
F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48
|
||||
F ext/rbu/rbuvacuum.test 75b4231f85622859e814c7f028afad0303f72f60
|
||||
F ext/rbu/sqlite3rbu.c 372ed3aaa396e3edfacdb8976d49aafdbe330cfa
|
||||
F ext/rbu/sqlite3rbu.c ac4621fc62e0bc3e9e92fceb483c0207af25addf
|
||||
F ext/rbu/sqlite3rbu.h 1342ab6121e715b8da59ec35c5b5c16060be7a6b
|
||||
F ext/rbu/test_rbu.c 430b8b9520c233505371d564d3561e0b554355f4
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
@ -1483,7 +1483,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 9a0078a538c7e73a009960347b8953c5af99fefd
|
||||
R dc7cff23cf20a157412c6c371d56e10b
|
||||
P d76f4aaa4caab713460421bd27365a82ac986c20
|
||||
R 02609be0d1cf35faad7663d479babac3
|
||||
U dan
|
||||
Z 72aacc0891d9c46e37fe5c65eb96b678
|
||||
Z ecb53ed56b3181cf4b46470b55ef0f36
|
||||
|
@ -1 +1 @@
|
||||
d76f4aaa4caab713460421bd27365a82ac986c20
|
||||
29407d70e44ad9ea5ddaf1011d0e212b602a3ddf
|
Loading…
Reference in New Issue
Block a user