diff options
author | drh <drh@noemail.net> | 2008-03-27 22:42:51 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-03-27 22:42:51 +0000 |
commit | 19db935225bc66eafbc830e3a76262a0d68d870a (patch) | |
tree | d509c76e1bce618ae5be688df7f8d51d1974d1e0 | |
parent | 9882d99993685fb111372c9205c2cd83952580a3 (diff) | |
download | sqlite-19db935225bc66eafbc830e3a76262a0d68d870a.tar.gz sqlite-19db935225bc66eafbc830e3a76262a0d68d870a.zip |
Allow the xAccess method in the VFS to return -1 to signal an I/O
error, and in particular an SQLITE_IOERR_NOMEM. (CVS 4925)
FossilOrigin-Name: 3cb704c4c439425781644b1b653b7e50f02fd91e
-rw-r--r-- | manifest | 24 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/fault.c | 12 | ||||
-rw-r--r-- | src/os.c | 8 | ||||
-rw-r--r-- | src/pager.c | 31 | ||||
-rw-r--r-- | src/pragma.c | 4 | ||||
-rw-r--r-- | src/vdbe.c | 17 | ||||
-rw-r--r-- | src/vdbeaux.c | 18 |
8 files changed, 74 insertions, 42 deletions
@@ -1,5 +1,5 @@ -C Allow\screation\sof\sephemeral\spseudo-tables\s-\spseudo-tables\sthat\scopy\sa\spointer\sto\sa\srow\swhen\sinserted\sinstead\sof\scopying\sthe\srow\sdata.\s(CVS\s4924) -D 2008-03-27T17:59:02 +C Allow\sthe\sxAccess\smethod\sin\sthe\sVFS\sto\sreturn\s-1\sto\ssignal\san\sI/O\nerror,\sand\sin\sparticular\san\sSQLITE_IOERR_NOMEM.\s(CVS\s4925) +D 2008-03-27T22:42:52 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -96,7 +96,7 @@ F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d F src/delete.c 3dc7d7cc46c8675219a7776b7c67b626bba530df F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/expr.c 7e56d2a24af8137f4bebbfa1d7dd1dcf70107c88 -F src/fault.c c28478c7190daef16be09d261c5461638b4d686c +F src/fault.c 83057e86815d473e526f7df0b0108dfdd022ff23 F src/func.c c9e8c7ff4c45027edee89bde7adbf86a3a3b2afe F src/hash.c 53655c312280211444bfe23af6490a460aec2980 F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53 @@ -117,7 +117,7 @@ F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb F src/mutex_os2.c 2911ea96955ab6cba734cc4ad903fe76f834b39e F src/mutex_unix.c c54275523ba4d9b00d6c7783602929b5556dbaf9 F src/mutex_w32.c 133698096a2c4e81cd11ea6f4de7891c66f7b9f7 -F src/os.c 9b943f71aaa1519f26cd45693a91b429b63aa042 +F src/os.c 7bc8d9b187836b87befcc5ae13158a7c55f82329 F src/os.h 497bf5f0f2648461ef65940cfb59ba427430f3fc F src/os_common.h e8b748b2f2ecc8a498e50bfe5d8721f189c19d2a F src/os_os2.c 85c443333761d5b58f041489a7b21ae918993e4f @@ -128,10 +128,10 @@ F src/os_unix.c fdec4e5ee5dd555a6ad4a69f38ab35f0788536b4 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c 22241b59c80ca083a96816df434adb8c097afcd4 +F src/pager.c 1cfa9b04f583a141b84af7995b88906e4d90edad F src/pager.h b1e2258f03878c14b06a95bfa362e8c5c9638170 F src/parse.y b0ee84d94218046ea88c2a6561005710d127ca7d -F src/pragma.c 99cec6d99d0241436494aab15b05da97b0e70683 +F src/pragma.c e659c9e443d11854cff2fd250012365ae0ca81ba F src/prepare.c 185fb47f1fb3e45a345d523eb391d673f5eb367c F src/printf.c 05d2b44d7b5b80c8a4a09108ddad9c20e254370d F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a @@ -174,11 +174,11 @@ F src/update.c 2aefd3c9277792e9fa2414dfe14202119fa49fe7 F src/utf.c 32b00d6e19010025e58f2ecb2f921d5e126771b4 F src/util.c dba9e04121eb17ec4643d6ca231ff859452cf0e2 F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30 -F src/vdbe.c f8e6d7f96f27c273e252c475a54d485943f0bb24 +F src/vdbe.c ecad5d197fe9a0f91c348fd3e776fc149aec1ae7 F src/vdbe.h f72201a0657d5f3d6cc008d1f8d9cc65768518c9 F src/vdbeInt.h 73a3162979585cc15d02e47cec2a1033df768246 F src/vdbeapi.c f74189e4cae0d93b2744386b9ac57f5ab60c5133 -F src/vdbeaux.c 0bdcfad81941f7f6b0b5f2f489d65804d4bdaf02 +F src/vdbeaux.c bb810c1c5450bd7887a39d5eb44f5902e01416f8 F src/vdbeblob.c cc713c142c3d4952b380c98ee035f850830ddbdb F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736 F src/vdbemem.c d48a71d66a7afd564b6537ab7e7442f7729fa5af @@ -619,7 +619,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P adf7645f9a1e12389a7511d2adca9013b7f330fa -R c27119a978dd6220ce607704acf25a98 -U danielk1977 -Z 2fd91019f3a606466497fa3759b61fc9 +P 1a58a87023f7780aee813ac64dda1a80021002a7 +R 0cea7f2cddb629adbd6991774cd393e4 +U drh +Z 7ef7bd639117d54202866f59dc190953 diff --git a/manifest.uuid b/manifest.uuid index 2741d0926..9b4fcff5f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a58a87023f7780aee813ac64dda1a80021002a7
\ No newline at end of file +3cb704c4c439425781644b1b653b7e50f02fd91e
\ No newline at end of file diff --git a/src/fault.c b/src/fault.c index 7e183ed43..d31dd4387 100644 --- a/src/fault.c +++ b/src/fault.c @@ -42,7 +42,7 @@ static struct FaultInjector { int nBenign; /* Number of benign failures seen since last config */ int nFail; /* Number of failures seen since last config */ u8 enable; /* True if enabled */ - u8 benign; /* Ture if next failure will be benign */ + u8 benign; /* True if next failure will be benign */ } aFault[SQLITE_FAULTINJECTOR_COUNT]; /* @@ -105,8 +105,14 @@ int sqlite3FaultPending(int id){ ** a hash table resize is a benign fault. */ void sqlite3FaultBenign(int id, int enable){ - assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT ); - aFault[id].benign = enable; + if( id<0 ){ + for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){ + aFault[id].benign = enable; + } + }else{ + assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT ); + aFault[id].benign = enable; + } } /* @@ -115,7 +115,13 @@ int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ return pVfs->xDelete(pVfs, zPath, dirSync); } int sqlite3OsAccess(sqlite3_vfs *pVfs, const char *zPath, int flags){ - int rc = pVfs->xAccess(pVfs, zPath, flags); + int rc; +#ifdef SQLITE_TEST + void *pTstAlloc = sqlite3_malloc(10); + if (!pTstAlloc) return -1; + sqlite3_free(pTstAlloc); +#endif + rc = pVfs->xAccess(pVfs, zPath, flags); assert( rc==0 || rc==1 ); return rc; } diff --git a/src/pager.c b/src/pager.c index 7f76c13d5..d47321a08 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.420 2008/03/20 11:04:21 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.421 2008/03/27 22:42:52 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -1602,7 +1602,12 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){ zJournal = zMasterJournal; while( (zJournal-zMasterJournal)<nMasterJournal ){ - if( sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS) ){ + rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS); + if( rc!=0 && rc!=1 ){ + rc = SQLITE_IOERR_NOMEM; + goto delmaster_out; + } + if( rc==1 ){ /* One of the journals pointed to by the master journal exists. ** Open it and check if it points at the master journal. If ** so, return without deleting the master journal file. @@ -1773,12 +1778,10 @@ static int pager_playback(Pager *pPager, int isHot){ */ zMaster = pPager->pTmpSpace; rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1); - assert( rc!=SQLITE_DONE ); if( rc!=SQLITE_OK - || (zMaster[0] && !sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS)) + || (zMaster[0] && sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS)==0 ) ){ zMaster = 0; - if( rc==SQLITE_DONE ) rc = SQLITE_OK; goto end_playback; } pPager->journalOff = 0; @@ -3053,19 +3056,23 @@ static PgHdr *pager_get_all_dirty_pages(Pager *pPager){ } /* -** Return TRUE if there is a hot journal on the given pager. +** Return 1 if there is a hot journal on the given pager. ** A hot journal is one that needs to be played back. ** ** If the current size of the database file is 0 but a journal file ** exists, that is probably an old journal left over from a prior ** database with the same name. Just delete the journal. +** +** Return negative if unable to determine the status of the journal. */ static int hasHotJournal(Pager *pPager){ sqlite3_vfs *pVfs = pPager->pVfs; + int rc; if( !pPager->useJournal ) return 0; if( !pPager->fd->pMethods ) return 0; - if( !sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS) ){ - return 0; + rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS); + if( rc<=0 ){ + return rc; } if( sqlite3OsCheckReservedLock(pPager->fd) ){ return 0; @@ -3365,7 +3372,11 @@ static int pagerSharedLock(Pager *pPager){ /* If a journal file exists, and there is no RESERVED lock on the ** database file, then it either needs to be played back or deleted. */ - if( hasHotJournal(pPager) || isHot ){ + rc = hasHotJournal(pPager); + if( rc<0 ){ + return pager_error(pPager, SQLITE_IOERR_NOMEM); + } + if( rc==1 || isHot ){ /* Get an EXCLUSIVE lock on the database file. At this point it is ** important that a RESERVED lock is not obtained on the way to the ** EXCLUSIVE lock. If it were, another process might open the @@ -3402,7 +3413,7 @@ static int pagerSharedLock(Pager *pPager){ */ if( !isHot ){ rc = SQLITE_BUSY; - if( sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS) ){ + if( sqlite3OsAccess(pVfs, pPager->zJournal,SQLITE_ACCESS_EXISTS)==1 ){ int fout = 0; int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL; assert( !pPager->tempFile ); diff --git a/src/pragma.c b/src/pragma.c index 8c396b3b4..a712bd869 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.173 2008/03/25 17:23:33 drh Exp $ +** $Id: pragma.c,v 1.174 2008/03/27 22:42:52 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -571,7 +571,7 @@ void sqlite3Pragma( } }else{ if( zRight[0] - && !sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE) + && sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE)==0 ){ sqlite3ErrorMsg(pParse, "not a writable directory"); goto pragma_out; diff --git a/src/vdbe.c b/src/vdbe.c index e41c6eed0..61e99978a 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.719 2008/03/27 17:59:02 danielk1977 Exp $ +** $Id: vdbe.c,v 1.720 2008/03/27 22:42:52 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -578,8 +578,9 @@ int sqlite3VdbeExec( CHECK_FOR_INTERRUPT; sqlite3VdbeIOTraceSql(p); #ifdef SQLITE_DEBUG + sqlite3FaultBenign(-1, 1); if( p->pc==0 && ((p->db->flags & SQLITE_VdbeListing)!=0 - || sqlite3OsAccess(db->pVfs, "vdbe_explain", SQLITE_ACCESS_EXISTS)) + || sqlite3OsAccess(db->pVfs, "vdbe_explain", SQLITE_ACCESS_EXISTS)==1 ) ){ int i; printf("VDBE Program Listing:\n"); @@ -588,9 +589,10 @@ int sqlite3VdbeExec( sqlite3VdbePrintOp(stdout, i, &p->aOp[i]); } } - if( sqlite3OsAccess(db->pVfs, "vdbe_trace", SQLITE_ACCESS_EXISTS) ){ + if( sqlite3OsAccess(db->pVfs, "vdbe_trace", SQLITE_ACCESS_EXISTS)==1 ){ p->trace = stdout; } + sqlite3FaultBenign(-1, 0); #endif for(pc=p->pc; rc==SQLITE_OK; pc++){ assert( pc>=0 && pc<p->nOp ); @@ -611,9 +613,12 @@ int sqlite3VdbeExec( } sqlite3VdbePrintOp(p->trace, pc, pOp); } - if( p->trace==0 && pc==0 - && sqlite3OsAccess(db->pVfs, "vdbe_sqltrace", SQLITE_ACCESS_EXISTS) ){ - sqlite3VdbePrintSql(p); + if( p->trace==0 && pc==0 ){ + sqlite3FaultBenign(-1, 1); + if( sqlite3OsAccess(db->pVfs, "vdbe_sqltrace", SQLITE_ACCESS_EXISTS)==1 ){ + sqlite3VdbePrintSql(p); + } + sqlite3FaultBenign(-1, 0); } #endif diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 369946c4e..ce37808f1 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1290,13 +1290,17 @@ static int vdbeCommit(sqlite3 *db){ if( !zMaster ){ return SQLITE_NOMEM; } - }while( sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS) ); - - /* Open the master journal. */ - rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, - SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE| - SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0 - ); + rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS); + }while( rc==1 ); + if( rc!=0 ){ + rc = SQLITE_IOERR_NOMEM; + }else{ + /* Open the master journal. */ + rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, + SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE| + SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0 + ); + } if( rc!=SQLITE_OK ){ sqlite3_free(zMaster); return rc; |