mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Test handling of IO errors that occur in OsDelete() or OsTruncate() operations. Also use an anonymous file for temporary storage during a VACUUM. (CVS 3729)
FossilOrigin-Name: b24a6e7b024c8b9a0b6fd15bd8f247e458781ca2
This commit is contained in:
28
manifest
28
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Updates\sto\sthe\sVACUUM\sdocumentation.\s\sTicket\s#2257.\s(CVS\s3728)
|
C Test\shandling\sof\sIO\serrors\sthat\soccur\sin\sOsDelete()\sor\sOsTruncate()\soperations.\sAlso\suse\san\sanonymous\sfile\sfor\stemporary\sstorage\sduring\sa\sVACUUM.\s(CVS\s3729)
|
||||||
D 2007-03-27T15:00:31
|
D 2007-03-27T16:19:52
|
||||||
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
|
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -82,12 +82,12 @@ F src/os_os2.c cb2c4f6d28810b5cee682d8df92352464d5c9d95
|
|||||||
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
|
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
|
||||||
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
|
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
|
||||||
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
|
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
|
||||||
F src/os_unix.c 1f32d15449caa02ada876a0e5b7b774d90e1be77
|
F src/os_unix.c 0d91b28d57c0885fe97fb9020fd1091578066b5b
|
||||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||||
F src/os_win.c 13708a58aa24a9960fa45ac4a681e34f881ae77c
|
F src/os_win.c 84c02837a6ec216a07e83a1d10d5a01c417bb489
|
||||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||||
F src/pager.c 7a60e7e1f8b5abe841282a3dc90823b73fefe8b8
|
F src/pager.c 2cc40af071948f6e57eb042f3a99a8921931effc
|
||||||
F src/pager.h 3c16500c25051536e43fb19e246e58fc7cb51d9f
|
F src/pager.h f1b17bf848b3dce5d9afb2701186d3c9a8826f8c
|
||||||
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
|
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
|
||||||
F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
|
F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
|
||||||
F src/prepare.c 37207b2b2ccb41d379b01dd62231686bcc48ef1f
|
F src/prepare.c 37207b2b2ccb41d379b01dd62231686bcc48ef1f
|
||||||
@@ -96,7 +96,7 @@ F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
|||||||
F src/select.c 4d68a0d7f98fb59bcedd0be69750e0445b05899c
|
F src/select.c 4d68a0d7f98fb59bcedd0be69750e0445b05899c
|
||||||
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
||||||
F src/shell.c 3ae4654560e91220a95738a73d135d91d937cda1
|
F src/shell.c 3ae4654560e91220a95738a73d135d91d937cda1
|
||||||
F src/sqlite.h.in 6b7383baf76070214f6381f603328ca9b22a7fae
|
F src/sqlite.h.in 6217831cf911d0c4dc3d31509cc2d0750bb28f0f
|
||||||
F src/sqlite3ext.h 832e13de075d920e2c76584e2b7af1054bb212df
|
F src/sqlite3ext.h 832e13de075d920e2c76584e2b7af1054bb212df
|
||||||
F src/sqliteInt.h 7a3d16cd517dfce73eeac10963275454d6421f82
|
F src/sqliteInt.h 7a3d16cd517dfce73eeac10963275454d6421f82
|
||||||
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
|
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
|
||||||
@@ -121,12 +121,12 @@ F src/trigger.c 8c55d31876013ed4e97ee7ce24478fbe00db49bb
|
|||||||
F src/update.c 876b3142b8db9ce6ddf8374a2ced65e576acabc7
|
F src/update.c 876b3142b8db9ce6ddf8374a2ced65e576acabc7
|
||||||
F src/utf.c 67ecb1032bc0b42c105e88d65ef9d9f626eb0e1f
|
F src/utf.c 67ecb1032bc0b42c105e88d65ef9d9f626eb0e1f
|
||||||
F src/util.c 8e8180ee5597f2474c1da311ff3c464b6966c0f1
|
F src/util.c 8e8180ee5597f2474c1da311ff3c464b6966c0f1
|
||||||
F src/vacuum.c b74b11077318f69e3ab0a474d31c3af87efa35bd
|
F src/vacuum.c 8bd895d29e7074e78d4e80f948e35ddc9cf2beef
|
||||||
F src/vdbe.c b68f3a86177fa4d10512a4e276a8961d5c1e2ccf
|
F src/vdbe.c b68f3a86177fa4d10512a4e276a8961d5c1e2ccf
|
||||||
F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
|
F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
|
||||||
F src/vdbeInt.h b2ca85ca8abfbba86e380b06c7673dc81c6784c3
|
F src/vdbeInt.h b2ca85ca8abfbba86e380b06c7673dc81c6784c3
|
||||||
F src/vdbeapi.c 6cff63a5b3a52af04b2bef0f7e27ed7ea6f85183
|
F src/vdbeapi.c 6cff63a5b3a52af04b2bef0f7e27ed7ea6f85183
|
||||||
F src/vdbeaux.c b98177089a57f496a6a36edef038b9d5df2befdb
|
F src/vdbeaux.c 1a50dce809a2f5c2d32e8096166b59016dab1b45
|
||||||
F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
|
F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
|
||||||
F src/vdbemem.c 58a8be2231b0b13e2e77098debe173e79d22f791
|
F src/vdbemem.c 58a8be2231b0b13e2e77098debe173e79d22f791
|
||||||
F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
|
F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
|
||||||
@@ -201,7 +201,7 @@ F test/enc2.test 45710bacfa9df29720bc84c067dfdf8c8ddfb797
|
|||||||
F test/enc3.test 890508efff6677345e93bf2a8adb0489b30df030
|
F test/enc3.test 890508efff6677345e93bf2a8adb0489b30df030
|
||||||
F test/exclusive.test 83871f52ab1015dc1bfbf86b96e2ece29094d129
|
F test/exclusive.test 83871f52ab1015dc1bfbf86b96e2ece29094d129
|
||||||
F test/exclusive2.test 187993598a83257f4a1126a40d89144c01965500
|
F test/exclusive2.test 187993598a83257f4a1126a40d89144c01965500
|
||||||
F test/exclusive3.test 278bc5107b2f64c2594b2109e4edbfd4458e5851
|
F test/exclusive3.test f2d1d0ab2a83bb8326dea516e1c99b833f44d8f8
|
||||||
F test/expr.test c78843f730ccbe973d0c2ad1c99978f936893131
|
F test/expr.test c78843f730ccbe973d0c2ad1c99978f936893131
|
||||||
F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
|
F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
|
||||||
F test/format4.test bf3bed3b13c63abfb3cfec232597a319a31d0bcc
|
F test/format4.test bf3bed3b13c63abfb3cfec232597a319a31d0bcc
|
||||||
@@ -442,7 +442,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P cbebfb89603044e48b3a87b79d1eefbbc5b4c8a5
|
P c61c97c978dab7535c94033631f5ad2355c55057
|
||||||
R 33506ae108a3d63410cc88f37a0bf6d6
|
R 0bc45e4cb76bfeab2e890a743828ed44
|
||||||
U drh
|
U danielk1977
|
||||||
Z f8417d4b89ac9d4701324dc273caa2e7
|
Z 0cef8b7fd227f96700de124998af2737
|
||||||
|
@@ -1 +1 @@
|
|||||||
c61c97c978dab7535c94033631f5ad2355c55057
|
b24a6e7b024c8b9a0b6fd15bd8f247e458781ca2
|
@@ -783,6 +783,7 @@ static int transferOwnership(unixFile *pFile){
|
|||||||
** Delete the named file
|
** Delete the named file
|
||||||
*/
|
*/
|
||||||
int sqlite3UnixDelete(const char *zFilename){
|
int sqlite3UnixDelete(const char *zFilename){
|
||||||
|
SimulateIOError(return SQLITE_IOERR_DELETE);
|
||||||
unlink(zFilename);
|
unlink(zFilename);
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
@@ -596,6 +596,7 @@ int sqlite3WinDelete(const char *zFilename){
|
|||||||
if( zConverted==0 ){
|
if( zConverted==0 ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
|
SimulateIOError(return SQLITE_IOERR_DELETE);
|
||||||
if( isNT() ){
|
if( isNT() ){
|
||||||
do{
|
do{
|
||||||
rc = DeleteFileW(zConverted);
|
rc = DeleteFileW(zConverted);
|
||||||
|
65
src/pager.c
65
src/pager.c
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.301 2007/03/27 13:36:37 drh Exp $
|
** @(#) $Id: pager.c,v 1.302 2007/03/27 16:19:52 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -479,7 +479,7 @@ static u32 retrieve32bits(PgHdr *p, int offset){
|
|||||||
static int pager_error(Pager *pPager, int rc){
|
static int pager_error(Pager *pPager, int rc){
|
||||||
int rc2 = rc & 0xff;
|
int rc2 = rc & 0xff;
|
||||||
assert( pPager->errCode==SQLITE_FULL || pPager->errCode==SQLITE_OK );
|
assert( pPager->errCode==SQLITE_FULL || pPager->errCode==SQLITE_OK );
|
||||||
if(
|
if(
|
||||||
rc2==SQLITE_FULL ||
|
rc2==SQLITE_FULL ||
|
||||||
rc2==SQLITE_IOERR ||
|
rc2==SQLITE_IOERR ||
|
||||||
rc2==SQLITE_CORRUPT ||
|
rc2==SQLITE_CORRUPT ||
|
||||||
@@ -922,29 +922,26 @@ static void pager_reset(Pager *pPager){
|
|||||||
static int pager_unwritelock(Pager *pPager){
|
static int pager_unwritelock(Pager *pPager){
|
||||||
PgHdr *pPg;
|
PgHdr *pPg;
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
int rc2 = SQLITE_OK;
|
||||||
assert( !MEMDB );
|
assert( !MEMDB );
|
||||||
if( pPager->state<PAGER_RESERVED ){
|
if( pPager->state<PAGER_RESERVED ){
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
sqlite3PagerStmtCommit(pPager);
|
sqlite3PagerStmtCommit(pPager);
|
||||||
if( pPager->stmtOpen && !pPager->exclusiveMode ){
|
if( pPager->stmtOpen && !pPager->exclusiveMode ){
|
||||||
if( !pPager->exclusiveMode ){
|
sqlite3OsClose(&pPager->stfd);
|
||||||
sqlite3OsClose(&pPager->stfd);
|
pPager->stmtOpen = 0;
|
||||||
pPager->stmtOpen = 0;
|
|
||||||
}else{
|
|
||||||
sqlite3OsTruncate(pPager->stfd, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if( pPager->journalOpen ){
|
if( pPager->journalOpen ){
|
||||||
if( pPager->exclusiveMode ){
|
if( pPager->exclusiveMode ){
|
||||||
sqlite3OsTruncate(pPager->jfd, 0);
|
rc = sqlite3OsTruncate(pPager->jfd, 0);
|
||||||
sqlite3OsSeek(pPager->jfd, 0);
|
sqlite3OsSeek(pPager->jfd, 0);
|
||||||
pPager->journalOff = 0;
|
pPager->journalOff = 0;
|
||||||
pPager->journalStarted = 0;
|
pPager->journalStarted = 0;
|
||||||
}else{
|
}else{
|
||||||
sqlite3OsClose(&pPager->jfd);
|
sqlite3OsClose(&pPager->jfd);
|
||||||
pPager->journalOpen = 0;
|
pPager->journalOpen = 0;
|
||||||
sqlite3OsDelete(pPager->zJournal);
|
rc = sqlite3OsDelete(pPager->zJournal);
|
||||||
}
|
}
|
||||||
sqliteFree( pPager->aInJournal );
|
sqliteFree( pPager->aInJournal );
|
||||||
pPager->aInJournal = 0;
|
pPager->aInJournal = 0;
|
||||||
@@ -964,8 +961,9 @@ static int pager_unwritelock(Pager *pPager){
|
|||||||
assert( pPager->aInJournal==0 );
|
assert( pPager->aInJournal==0 );
|
||||||
assert( pPager->dirtyCache==0 || pPager->useJournal==0 );
|
assert( pPager->dirtyCache==0 || pPager->useJournal==0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !pPager->exclusiveMode ){
|
if( !pPager->exclusiveMode ){
|
||||||
rc = sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
|
rc2 = sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
|
||||||
pPager->state = PAGER_SHARED;
|
pPager->state = PAGER_SHARED;
|
||||||
}else if( pPager->state==PAGER_SYNCED ){
|
}else if( pPager->state==PAGER_SYNCED ){
|
||||||
pPager->state = PAGER_EXCLUSIVE;
|
pPager->state = PAGER_EXCLUSIVE;
|
||||||
@@ -975,7 +973,8 @@ static int pager_unwritelock(Pager *pPager){
|
|||||||
pPager->needSync = 0;
|
pPager->needSync = 0;
|
||||||
pPager->pFirstSynced = pPager->pFirst;
|
pPager->pFirstSynced = pPager->pFirst;
|
||||||
pPager->dbSize = -1;
|
pPager->dbSize = -1;
|
||||||
return rc;
|
|
||||||
|
return (rc==SQLITE_OK?rc2:rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1193,7 +1192,7 @@ static int pager_delmaster(const char *zMaster){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3OsDelete(zMaster);
|
rc = sqlite3OsDelete(zMaster);
|
||||||
|
|
||||||
delmaster_out:
|
delmaster_out:
|
||||||
if( zMasterJournal ){
|
if( zMasterJournal ){
|
||||||
@@ -1417,7 +1416,7 @@ end_playback:
|
|||||||
rc = pager_unwritelock(pPager);
|
rc = pager_unwritelock(pPager);
|
||||||
}
|
}
|
||||||
if( zMaster ){
|
if( zMaster ){
|
||||||
/* If there was a master journal and this routine will return true,
|
/* If there was a master journal and this routine will return success,
|
||||||
** see if it is possible to delete the master journal.
|
** see if it is possible to delete the master journal.
|
||||||
*/
|
*/
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
@@ -2705,8 +2704,21 @@ static int pagerSharedLock(Pager *pPager){
|
|||||||
** journal file is never open unless the main database file holds
|
** journal file is never open unless the main database file holds
|
||||||
** a write lock, so there is never any chance of two or more
|
** a write lock, so there is never any chance of two or more
|
||||||
** processes opening the journal at the same time.
|
** processes opening the journal at the same time.
|
||||||
|
**
|
||||||
|
** Open the journal for read/write access. This is because in
|
||||||
|
** exclusive-access mode the file descriptor will be kept open and
|
||||||
|
** possibly used for a transaction later on. On some systems, the
|
||||||
|
** OsTruncate() call used in exclusive-access mode also requires
|
||||||
|
** a read/write file handle.
|
||||||
*/
|
*/
|
||||||
rc = sqlite3OsOpenReadOnly(pPager->zJournal, &pPager->jfd);
|
rc = SQLITE_BUSY;
|
||||||
|
if( sqlite3OsFileExists(pPager->zJournal) ){
|
||||||
|
int ro;
|
||||||
|
rc = sqlite3OsOpenReadWrite(pPager->zJournal, &pPager->jfd, &ro);
|
||||||
|
if( ro ){
|
||||||
|
rc = SQLITE_BUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
pager_unlock(pPager);
|
pager_unlock(pPager);
|
||||||
return SQLITE_BUSY;
|
return SQLITE_BUSY;
|
||||||
@@ -2823,6 +2835,7 @@ int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag){
|
|||||||
pPg = pager_lookup(pPager, pgno);
|
pPg = pager_lookup(pPager, pgno);
|
||||||
if( pPg==0 ){
|
if( pPg==0 ){
|
||||||
/* The requested page is not in the page cache. */
|
/* The requested page is not in the page cache. */
|
||||||
|
int nMax;
|
||||||
int h;
|
int h;
|
||||||
TEST_INCR(pPager->nMiss);
|
TEST_INCR(pPager->nMiss);
|
||||||
if( pPager->nPage<pPager->mxPage || pPager->pFirst==0 || MEMDB ||
|
if( pPager->nPage<pPager->mxPage || pPager->pFirst==0 || MEMDB ||
|
||||||
@@ -2886,6 +2899,7 @@ int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag){
|
|||||||
if( pPager->nExtra>0 ){
|
if( pPager->nExtra>0 ){
|
||||||
memset(PGHDR_TO_EXTRA(pPg, pPager), 0, pPager->nExtra);
|
memset(PGHDR_TO_EXTRA(pPg, pPager), 0, pPager->nExtra);
|
||||||
}
|
}
|
||||||
|
nMax = sqlite3PagerPagecount(pPager);
|
||||||
if( pPager->errCode ){
|
if( pPager->errCode ){
|
||||||
sqlite3PagerUnref(pPg);
|
sqlite3PagerUnref(pPg);
|
||||||
rc = pPager->errCode;
|
rc = pPager->errCode;
|
||||||
@@ -2895,9 +2909,7 @@ int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag){
|
|||||||
/* Populate the page with data, either by reading from the database
|
/* Populate the page with data, either by reading from the database
|
||||||
** file, or by setting the entire page to zero.
|
** file, or by setting the entire page to zero.
|
||||||
*/
|
*/
|
||||||
if( sqlite3PagerPagecount(pPager)<(int)pgno || MEMDB
|
if( nMax<(int)pgno || MEMDB || (clrFlag && !pPager->alwaysRollback) ){
|
||||||
|| (clrFlag && !pPager->alwaysRollback)
|
|
||||||
){
|
|
||||||
memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
|
memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
|
||||||
}else{
|
}else{
|
||||||
assert( MEMDB==0 );
|
assert( MEMDB==0 );
|
||||||
@@ -3015,6 +3027,7 @@ int sqlite3PagerUnref(DbPage *pPg){
|
|||||||
*/
|
*/
|
||||||
pPager->nRef--;
|
pPager->nRef--;
|
||||||
assert( pPager->nRef>=0 );
|
assert( pPager->nRef>=0 );
|
||||||
|
// assert( pPager->nRef>0 || !pPager->journalOpen || pPager->journalOff==0 );
|
||||||
if( pPager->nRef==0 && !pPager->exclusiveMode ){
|
if( pPager->nRef==0 && !pPager->exclusiveMode ){
|
||||||
pagerUnlockAndRollback(pPager);
|
pagerUnlockAndRollback(pPager);
|
||||||
}
|
}
|
||||||
@@ -3086,7 +3099,7 @@ failed_to_open_journal:
|
|||||||
** the system will get confused, we have a read-lock on the file and a
|
** the system will get confused, we have a read-lock on the file and a
|
||||||
** mysterious journal has appeared in the filesystem.
|
** mysterious journal has appeared in the filesystem.
|
||||||
*/
|
*/
|
||||||
sqlite3OsDelete(pPager->zJournal);
|
/* sqlite3OsDelete(pPager->zJournal); */
|
||||||
}else{
|
}else{
|
||||||
pager_reset(pPager);
|
pager_reset(pPager);
|
||||||
}
|
}
|
||||||
@@ -3611,14 +3624,14 @@ int sqlite3PagerCommit(Pager *pPager){
|
|||||||
** if there have been no changes to the database file. */
|
** if there have been no changes to the database file. */
|
||||||
assert( pPager->needSync==0 );
|
assert( pPager->needSync==0 );
|
||||||
rc = pager_unwritelock(pPager);
|
rc = pager_unwritelock(pPager);
|
||||||
return rc;
|
}else{
|
||||||
|
assert( pPager->journalOpen );
|
||||||
|
rc = sqlite3PagerSync(pPager, 0, 0);
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
rc = pager_unwritelock(pPager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert( pPager->journalOpen );
|
return pager_error(pPager, rc);
|
||||||
rc = sqlite3PagerSync(pPager, 0, 0);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
rc = pager_unwritelock(pPager);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
10
src/pager.h
10
src/pager.h
@@ -13,7 +13,7 @@
|
|||||||
** subsystem. The page cache subsystem reads and writes a file a page
|
** subsystem. The page cache subsystem reads and writes a file a page
|
||||||
** at a time and provides a journal for rollback.
|
** at a time and provides a journal for rollback.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.h,v 1.55 2007/03/24 16:45:05 danielk1977 Exp $
|
** @(#) $Id: pager.h,v 1.56 2007/03/27 16:19:52 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PAGER_H_
|
#ifndef _PAGER_H_
|
||||||
@@ -136,4 +136,12 @@ void sqlite3PagerRefdump(Pager*);
|
|||||||
int pager3_refinfo_enable;
|
int pager3_refinfo_enable;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SQLITE_TEST
|
||||||
|
void disable_simulated_io_errors(void);
|
||||||
|
void enable_simulated_io_errors(void);
|
||||||
|
#else
|
||||||
|
# define disable_simulated_io_errors()
|
||||||
|
# define enable_simulated_io_errors()
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _PAGER_H_ */
|
#endif /* _PAGER_H_ */
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
** This header file defines the interface that the SQLite library
|
** This header file defines the interface that the SQLite library
|
||||||
** presents to client programs.
|
** presents to client programs.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqlite.h.in,v 1.198 2007/01/26 00:51:44 drh Exp $
|
** @(#) $Id: sqlite.h.in,v 1.199 2007/03/27 16:19:52 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE3_H_
|
#ifndef _SQLITE3_H_
|
||||||
#define _SQLITE3_H_
|
#define _SQLITE3_H_
|
||||||
@@ -230,6 +230,7 @@ int sqlite3_exec(
|
|||||||
#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
|
#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
|
||||||
#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
|
#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
|
||||||
#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
|
#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
|
||||||
|
#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Enable or disable the extended result codes.
|
** Enable or disable the extended result codes.
|
||||||
|
16
src/vacuum.c
16
src/vacuum.c
@@ -14,7 +14,7 @@
|
|||||||
** Most of the code in this file may be omitted by defining the
|
** Most of the code in this file may be omitted by defining the
|
||||||
** SQLITE_OMIT_VACUUM macro.
|
** SQLITE_OMIT_VACUUM macro.
|
||||||
**
|
**
|
||||||
** $Id: vacuum.c,v 1.68 2007/03/27 14:44:51 drh Exp $
|
** $Id: vacuum.c,v 1.69 2007/03/27 16:19:52 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
@@ -83,13 +83,11 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
|
|||||||
char *zSql = 0; /* SQL statements */
|
char *zSql = 0; /* SQL statements */
|
||||||
int saved_flags; /* Saved value of the db->flags */
|
int saved_flags; /* Saved value of the db->flags */
|
||||||
Db *pDb = 0; /* Database to detach at end of vacuum */
|
Db *pDb = 0; /* Database to detach at end of vacuum */
|
||||||
char zTemp[SQLITE_TEMPNAME_SIZE+20]; /* Name of the TEMP file */
|
|
||||||
|
|
||||||
/* Save the current value of the write-schema flag before setting it. */
|
/* Save the current value of the write-schema flag before setting it. */
|
||||||
saved_flags = db->flags;
|
saved_flags = db->flags;
|
||||||
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
|
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
|
||||||
|
|
||||||
sqlite3OsTempFileName(zTemp);
|
|
||||||
if( !db->autoCommit ){
|
if( !db->autoCommit ){
|
||||||
sqlite3SetString(pzErrMsg, "cannot VACUUM from within a transaction",
|
sqlite3SetString(pzErrMsg, "cannot VACUUM from within a transaction",
|
||||||
(char*)0);
|
(char*)0);
|
||||||
@@ -106,14 +104,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
|
|||||||
**
|
**
|
||||||
** An optimisation would be to use a non-journaled pager.
|
** An optimisation would be to use a non-journaled pager.
|
||||||
*/
|
*/
|
||||||
zSql = sqlite3MPrintf("ATTACH '%q' AS vacuum_db;", zTemp);
|
zSql = "ATTACH '' AS vacuum_db;";
|
||||||
if( !zSql ){
|
|
||||||
rc = SQLITE_NOMEM;
|
|
||||||
goto end_of_vacuum;
|
|
||||||
}
|
|
||||||
rc = execSql(db, zSql);
|
rc = execSql(db, zSql);
|
||||||
sqliteFree(zSql);
|
|
||||||
zSql = 0;
|
|
||||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||||
pDb = &db->aDb[db->nDb-1];
|
pDb = &db->aDb[db->nDb-1];
|
||||||
assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
|
assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
|
||||||
@@ -263,10 +255,6 @@ end_of_vacuum:
|
|||||||
pDb->pSchema = 0;
|
pDb->pSchema = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3OsDelete(zTemp);
|
|
||||||
strcat(zTemp, "-journal");
|
|
||||||
sqlite3OsDelete(zTemp);
|
|
||||||
sqliteFree( zSql );
|
|
||||||
sqlite3ResetInternalSchema(db, 0);
|
sqlite3ResetInternalSchema(db, 0);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@@ -1094,14 +1094,18 @@ static int vdbeCommit(sqlite3 *db){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do the commit only if all databases successfully synced */
|
/* Do the commit only if all databases successfully synced.
|
||||||
if( rc==SQLITE_OK ){
|
** If one of the BtreeCommit() calls fails, this indicates an IO error
|
||||||
for(i=0; i<db->nDb; i++){
|
** while deleting or truncating a journal file. It is unlikely, but
|
||||||
Btree *pBt = db->aDb[i].pBt;
|
** could happen. In this case abandon processing and return the error.
|
||||||
if( pBt ){
|
*/
|
||||||
sqlite3BtreeCommit(pBt);
|
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
|
||||||
}
|
Btree *pBt = db->aDb[i].pBt;
|
||||||
|
if( pBt ){
|
||||||
|
rc = sqlite3BtreeCommit(pBt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
sqlite3VtabCommit(db);
|
sqlite3VtabCommit(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1225,12 +1229,15 @@ static int vdbeCommit(sqlite3 *db){
|
|||||||
** but some stray 'cold' journals may be lying around. Returning an
|
** but some stray 'cold' journals may be lying around. Returning an
|
||||||
** error code won't help matters.
|
** error code won't help matters.
|
||||||
*/
|
*/
|
||||||
|
disable_simulated_io_errors();
|
||||||
for(i=0; i<db->nDb; i++){
|
for(i=0; i<db->nDb; i++){
|
||||||
Btree *pBt = db->aDb[i].pBt;
|
Btree *pBt = db->aDb[i].pBt;
|
||||||
if( pBt ){
|
if( pBt ){
|
||||||
sqlite3BtreeCommit(pBt);
|
sqlite3BtreeCommit(pBt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
enable_simulated_io_errors();
|
||||||
|
|
||||||
sqlite3VtabCommit(db);
|
sqlite3VtabCommit(db);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
# This file runs the tests in the file ioerr.test with auto-vacuum enabled
|
# This file runs the tests in the file ioerr.test with auto-vacuum enabled
|
||||||
# databases.
|
# databases.
|
||||||
#
|
#
|
||||||
# $Id: exclusive3.test,v 1.1 2007/03/26 16:13:59 danielk1977 Exp $
|
# $Id: exclusive3.test,v 1.2 2007/03/27 16:19:52 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -47,7 +47,7 @@ proc do_test {args} {
|
|||||||
#source $testdir/select2.test
|
#source $testdir/select2.test
|
||||||
|
|
||||||
source $testdir/malloc.test
|
source $testdir/malloc.test
|
||||||
#source $testdir/ioerr.test
|
source $testdir/ioerr.test
|
||||||
|
|
||||||
|
|
||||||
rename sqlite3 ""
|
rename sqlite3 ""
|
||||||
|
Reference in New Issue
Block a user