-C Updates\sto\sthe\sVACUUM\sdocumentation.\s\sTicket\s#2257.\s(CVS\s3728)
-D 2007-03-27T15:00:31
+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-27T16:19:52
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
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_win.c 13708a58aa24a9960fa45ac4a681e34f881ae77c
+F src/os_win.c 84c02837a6ec216a07e83a1d10d5a01c417bb489
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 7a60e7e1f8b5abe841282a3dc90823b73fefe8b8
-F src/pager.h 3c16500c25051536e43fb19e246e58fc7cb51d9f
+F src/pager.c 2cc40af071948f6e57eb042f3a99a8921931effc
+F src/pager.h f1b17bf848b3dce5d9afb2701186d3c9a8826f8c
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
F src/prepare.c 37207b2b2ccb41d379b01dd62231686bcc48ef1f
F src/select.c 4d68a0d7f98fb59bcedd0be69750e0445b05899c
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 3ae4654560e91220a95738a73d135d91d937cda1
-F src/sqlite.h.in 6b7383baf76070214f6381f603328ca9b22a7fae
+F src/sqlite.h.in 6217831cf911d0c4dc3d31509cc2d0750bb28f0f
F src/sqlite3ext.h 832e13de075d920e2c76584e2b7af1054bb212df
F src/sqliteInt.h 7a3d16cd517dfce73eeac10963275454d6421f82
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
F src/update.c 876b3142b8db9ce6ddf8374a2ced65e576acabc7
F src/utf.c 67ecb1032bc0b42c105e88d65ef9d9f626eb0e1f
F src/util.c 8e8180ee5597f2474c1da311ff3c464b6966c0f1
-F src/vacuum.c b74b11077318f69e3ab0a474d31c3af87efa35bd
+F src/vacuum.c 8bd895d29e7074e78d4e80f948e35ddc9cf2beef
F src/vdbe.c b68f3a86177fa4d10512a4e276a8961d5c1e2ccf
F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
F src/vdbeInt.h b2ca85ca8abfbba86e380b06c7673dc81c6784c3
F src/vdbeapi.c 6cff63a5b3a52af04b2bef0f7e27ed7ea6f85183
-F src/vdbeaux.c b98177089a57f496a6a36edef038b9d5df2befdb
+F src/vdbeaux.c 1a50dce809a2f5c2d32e8096166b59016dab1b45
F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
F src/vdbemem.c 58a8be2231b0b13e2e77098debe173e79d22f791
F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
F test/enc3.test 890508efff6677345e93bf2a8adb0489b30df030
F test/exclusive.test 83871f52ab1015dc1bfbf86b96e2ece29094d129
F test/exclusive2.test 187993598a83257f4a1126a40d89144c01965500
-F test/exclusive3.test 278bc5107b2f64c2594b2109e4edbfd4458e5851
+F test/exclusive3.test f2d1d0ab2a83bb8326dea516e1c99b833f44d8f8
F test/expr.test c78843f730ccbe973d0c2ad1c99978f936893131
F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
F test/format4.test bf3bed3b13c63abfb3cfec232597a319a31d0bcc
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P cbebfb89603044e48b3a87b79d1eefbbc5b4c8a5
-R 33506ae108a3d63410cc88f37a0bf6d6
-U drh
-Z f8417d4b89ac9d4701324dc273caa2e7
+P c61c97c978dab7535c94033631f5ad2355c55057
+R 0bc45e4cb76bfeab2e890a743828ed44
+U danielk1977
+Z 0cef8b7fd227f96700de124998af2737
-c61c97c978dab7535c94033631f5ad2355c55057
\ No newline at end of file
+b24a6e7b024c8b9a0b6fd15bd8f247e458781ca2
\ No newline at end of file
** Delete the named file
*/
int sqlite3UnixDelete(const char *zFilename){
+ SimulateIOError(return SQLITE_IOERR_DELETE);
unlink(zFilename);
return SQLITE_OK;
}
if( zConverted==0 ){
return SQLITE_NOMEM;
}
+ SimulateIOError(return SQLITE_IOERR_DELETE);
if( isNT() ){
do{
rc = DeleteFileW(zConverted);
** file simultaneously, or one process from reading the database while
** 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
#include "sqliteInt.h"
static int pager_error(Pager *pPager, int rc){
int rc2 = rc & 0xff;
assert( pPager->errCode==SQLITE_FULL || pPager->errCode==SQLITE_OK );
- if(
+ if(
rc2==SQLITE_FULL ||
rc2==SQLITE_IOERR ||
rc2==SQLITE_CORRUPT ||
static int pager_unwritelock(Pager *pPager){
PgHdr *pPg;
int rc = SQLITE_OK;
+ int rc2 = SQLITE_OK;
assert( !MEMDB );
if( pPager->state<PAGER_RESERVED ){
return SQLITE_OK;
}
sqlite3PagerStmtCommit(pPager);
if( pPager->stmtOpen && !pPager->exclusiveMode ){
- if( !pPager->exclusiveMode ){
- sqlite3OsClose(&pPager->stfd);
- pPager->stmtOpen = 0;
- }else{
- sqlite3OsTruncate(pPager->stfd, 0);
- }
+ sqlite3OsClose(&pPager->stfd);
+ pPager->stmtOpen = 0;
}
if( pPager->journalOpen ){
if( pPager->exclusiveMode ){
- sqlite3OsTruncate(pPager->jfd, 0);
+ rc = sqlite3OsTruncate(pPager->jfd, 0);
sqlite3OsSeek(pPager->jfd, 0);
pPager->journalOff = 0;
pPager->journalStarted = 0;
}else{
sqlite3OsClose(&pPager->jfd);
pPager->journalOpen = 0;
- sqlite3OsDelete(pPager->zJournal);
+ rc = sqlite3OsDelete(pPager->zJournal);
}
sqliteFree( pPager->aInJournal );
pPager->aInJournal = 0;
assert( pPager->aInJournal==0 );
assert( pPager->dirtyCache==0 || pPager->useJournal==0 );
}
+
if( !pPager->exclusiveMode ){
- rc = sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
+ rc2 = sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
pPager->state = PAGER_SHARED;
}else if( pPager->state==PAGER_SYNCED ){
pPager->state = PAGER_EXCLUSIVE;
pPager->needSync = 0;
pPager->pFirstSynced = pPager->pFirst;
pPager->dbSize = -1;
- return rc;
+
+ return (rc==SQLITE_OK?rc2:rc);
}
/*
}
}
- sqlite3OsDelete(zMaster);
+ rc = sqlite3OsDelete(zMaster);
delmaster_out:
if( zMasterJournal ){
rc = pager_unwritelock(pPager);
}
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.
*/
if( rc==SQLITE_OK ){
** journal file is never open unless the main database file holds
** a write lock, so there is never any chance of two or more
** 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 ){
pager_unlock(pPager);
return SQLITE_BUSY;
pPg = pager_lookup(pPager, pgno);
if( pPg==0 ){
/* The requested page is not in the page cache. */
+ int nMax;
int h;
TEST_INCR(pPager->nMiss);
if( pPager->nPage<pPager->mxPage || pPager->pFirst==0 || MEMDB ||
if( pPager->nExtra>0 ){
memset(PGHDR_TO_EXTRA(pPg, pPager), 0, pPager->nExtra);
}
+ nMax = sqlite3PagerPagecount(pPager);
if( pPager->errCode ){
sqlite3PagerUnref(pPg);
rc = pPager->errCode;
/* Populate the page with data, either by reading from the database
** file, or by setting the entire page to zero.
*/
- if( sqlite3PagerPagecount(pPager)<(int)pgno || MEMDB
- || (clrFlag && !pPager->alwaysRollback)
- ){
+ if( nMax<(int)pgno || MEMDB || (clrFlag && !pPager->alwaysRollback) ){
memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
}else{
assert( MEMDB==0 );
*/
pPager->nRef--;
assert( pPager->nRef>=0 );
+ // assert( pPager->nRef>0 || !pPager->journalOpen || pPager->journalOff==0 );
if( pPager->nRef==0 && !pPager->exclusiveMode ){
pagerUnlockAndRollback(pPager);
}
** the system will get confused, we have a read-lock on the file and a
** mysterious journal has appeared in the filesystem.
*/
- sqlite3OsDelete(pPager->zJournal);
+ /* sqlite3OsDelete(pPager->zJournal); */
}else{
pager_reset(pPager);
}
** if there have been no changes to the database file. */
assert( pPager->needSync==0 );
rc = pager_unwritelock(pPager);
- return rc;
- }
- assert( pPager->journalOpen );
- rc = sqlite3PagerSync(pPager, 0, 0);
- if( rc==SQLITE_OK ){
- rc = pager_unwritelock(pPager);
+ }else{
+ assert( pPager->journalOpen );
+ rc = sqlite3PagerSync(pPager, 0, 0);
+ if( rc==SQLITE_OK ){
+ rc = pager_unwritelock(pPager);
+ }
}
- return rc;
+ return pager_error(pPager, rc);
}
/*
** subsystem. The page cache subsystem reads and writes a file a page
** 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_
int pager3_refinfo_enable;
#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_ */
** This header file defines the interface that the SQLite library
** 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_
#define _SQLITE3_H_
#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
+#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
/*
** Enable or disable the extended result codes.
** Most of the code in this file may be omitted by defining the
** 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 "vdbeInt.h"
char *zSql = 0; /* SQL statements */
int saved_flags; /* Saved value of the db->flags */
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. */
saved_flags = db->flags;
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
- sqlite3OsTempFileName(zTemp);
if( !db->autoCommit ){
sqlite3SetString(pzErrMsg, "cannot VACUUM from within a transaction",
(char*)0);
**
** An optimisation would be to use a non-journaled pager.
*/
- zSql = sqlite3MPrintf("ATTACH '%q' AS vacuum_db;", zTemp);
- if( !zSql ){
- rc = SQLITE_NOMEM;
- goto end_of_vacuum;
- }
+ zSql = "ATTACH '' AS vacuum_db;";
rc = execSql(db, zSql);
- sqliteFree(zSql);
- zSql = 0;
if( rc!=SQLITE_OK ) goto end_of_vacuum;
pDb = &db->aDb[db->nDb-1];
assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
pDb->pSchema = 0;
}
- sqlite3OsDelete(zTemp);
- strcat(zTemp, "-journal");
- sqlite3OsDelete(zTemp);
- sqliteFree( zSql );
sqlite3ResetInternalSchema(db, 0);
return rc;
}
}
- /* Do the commit only if all databases successfully synced */
- if( rc==SQLITE_OK ){
- for(i=0; i<db->nDb; i++){
- Btree *pBt = db->aDb[i].pBt;
- if( pBt ){
- sqlite3BtreeCommit(pBt);
- }
+ /* Do the commit only if all databases successfully synced.
+ ** If one of the BtreeCommit() calls fails, this indicates an IO error
+ ** while deleting or truncating a journal file. It is unlikely, but
+ ** could happen. In this case abandon processing and return the error.
+ */
+ 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);
}
}
** but some stray 'cold' journals may be lying around. Returning an
** error code won't help matters.
*/
+ disable_simulated_io_errors();
for(i=0; i<db->nDb; i++){
Btree *pBt = db->aDb[i].pBt;
if( pBt ){
sqlite3BtreeCommit(pBt);
}
}
+ enable_simulated_io_errors();
+
sqlite3VtabCommit(db);
}
#endif
# This file runs the tests in the file ioerr.test with auto-vacuum enabled
# 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]
source $testdir/tester.tcl
#source $testdir/select2.test
source $testdir/malloc.test
-#source $testdir/ioerr.test
+source $testdir/ioerr.test
rename sqlite3 ""