]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the signature of sqlite3PagerPagecount() so that it can return an error code...
authordanielk1977 <danielk1977@noemail.net>
Sat, 7 Jun 2008 08:58:22 +0000 (08:58 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Sat, 7 Jun 2008 08:58:22 +0000 (08:58 +0000)
FossilOrigin-Name: e9f01c01866d302d81bf9ebc484ea6351cbc0f60

manifest
manifest.uuid
src/btree.c
src/pager.c
src/pager.h
src/test2.c
src/vdbe.c
test/ioerr.test

index 558f58409a045efba940bfbb8393ea9080e1e4eb..29e0588d4da81a2fa13d5c3f9d05c6646f7675a5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Do\snot\scall\sxSync()\sfrom\szeroJournalHdr()\sif\sthe\sPager.noSync\sflag\sis\sset\s(i.e.\sfor\stemp\sfiles).\s(CVS\s5194)
-D 2008-06-07T05:19:38
+C Change\sthe\ssignature\sof\ssqlite3PagerPagecount()\sso\sthat\sit\scan\sreturn\san\serror\scode.\s(CVS\s5195)
+D 2008-06-07T08:58:22
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in ce92ea8dc7adfb743757794f51c10d1b0d9c55e4
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -96,7 +96,7 @@ F src/attach.c 496cc628b2e8c4d8db99d7c136761fcbebd8420b
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/bitvec.c ab50c4b8c6a899dae499f5a805eebe4223c78269
 F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
-F src/btree.c 7bee6ba457f3e241911fab69b1602eb43c65b438
+F src/btree.c fca8ae92574deb31fe95483cbf1fa185e77c8fd2
 F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b
 F src/btreeInt.h dc04ee33d8eb84714b2acdf81336fbbf6e764530
 F src/build.c a52d9d51341444a2131e3431608f245db80d9591
@@ -133,8 +133,8 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
 F src/os_os2.c 1578149e21c4eac42c7f230a6f40500846f8e781
 F src/os_unix.c 47936aee8265e482faa626141d97d896aa981ef4
 F src/os_win.c 0d975b131b2b104d6d69d9f16bdf3c8cec28e81d
-F src/pager.c 7ce0a4abcc7e096adbd79277bb7c048ae24190f1
-F src/pager.h 7b1de4bf2cf2d9b7b312e6ed5bc7fcc9ba9aa2a4
+F src/pager.c be98ceeb55bbcda9251c1a846d28c3d323885708
+F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba
 F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
 F src/pragma.c 70e7c865dce85fdf9df81848af2169009a56ed08
 F src/prepare.c cbc9301aba1d0fc3d05fae576f2eb667c189cb36
@@ -149,7 +149,7 @@ F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
 F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
 F src/tclsqlite.c c57e740e30bd6dda678796eed62c7f0e64689834
 F src/test1.c 736be7dea5cc126356bbb61a4b1ac5ff4fac7994
-F src/test2.c f0808cc643528b9620e4059ca9bda8346f526121
+F src/test2.c c46d146019ab6e37474e66b3c789e5237d9ea7b7
 F src/test3.c b5c1d1047a45af03375d66b3eec603faafa3ddc6
 F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
 F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
@@ -179,7 +179,7 @@ F src/update.c 2d7143b9014e955509cc4f323f9a9584fb898f34
 F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
 F src/util.c 43277088f8fea4109a640aa46731b8752c3fb4a7
 F src/vacuum.c a5c289e561ed72283e97d2485491986bc7d684eb
-F src/vdbe.c a113a62ae6779830dcc6b2caec9b89d894db4f71
+F src/vdbe.c 1936425c3455535a1a20e26a65c470fb009a1ed8
 F src/vdbe.h 1e3722d471739c2b213c6283b60373290e52f7ea
 F src/vdbeInt.h de321b2c02593e1420106634ed1f5a7d77ad35a7
 F src/vdbeapi.c 22b01ed175e4d4c613ee82cabc7a44a275641206
@@ -353,7 +353,7 @@ F test/insert5.test 509017213328147d3acdfa2c441bfd82362dda41
 F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1
 F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f
 F test/io.test 833a1746518ec3005aa7792f9bcb8f01923ff544
-F test/ioerr.test a9dc72225498e95d08235352243e90e7a88e7b2b
+F test/ioerr.test 035470704718a2982a8d14e8a46316e6acd667ac
 F test/ioerr2.test b9c9a0491a812707762a7c002876553be54d9969
 F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd
 F test/ioerr4.test fc6eddfec2efc2f1ed217b9eae4c1c1d3516ce86
@@ -591,7 +591,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c c65494ca99d1e09c246dfe37a7ca7a354af9990f
-P de8b87d65a85c4dabe53281092d9a23555a8e2d6
-R 4108c9364e1aef5c2e5946df2ebf6495
+P 9f5cbe29226151113e4565fcf8170317afe1b8c6
+R c5a7106bdebe8d6a8255cc886f35d9c1
 U danielk1977
-Z ce75257a59bcc2211b7d68c3ccc3199f
+Z 439ab2cd9536726e391f52e67ee1840b
index a668c75bb1938494277ff3e9c3b5b7733767b7d6..553cfc6d4a032dd8ab6ccb3670e28c1fd54083aa 100644 (file)
@@ -1 +1 @@
-9f5cbe29226151113e4565fcf8170317afe1b8c6
\ No newline at end of file
+e9f01c01866d302d81bf9ebc484ea6351cbc0f60
\ No newline at end of file
index 2f8c6ed3d5cdd7cd4dfc79a17f1305c55485a782..f08e7784aa334d50de4af86b8ea2f29d6974b886 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.458 2008/05/09 16:57:51 danielk1977 Exp $
+** $Id: btree.c,v 1.459 2008/06/07 08:58:22 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -1654,15 +1654,14 @@ static int lockBtree(BtShared *pBt){
   /* Do some checking to help insure the file we opened really is
   ** a valid database file. 
   */
-  rc = SQLITE_NOTADB;
-  nPage = sqlite3PagerPagecount(pBt->pPager);
-  if( nPage<0 ){
-    rc = SQLITE_IOERR;
+  rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
+  if( rc!=SQLITE_OK ){
     goto page1_init_failed;
   }else if( nPage>0 ){
     int pageSize;
     int usableSize;
     u8 *page1 = pPage1->aData;
+    rc = SQLITE_NOTADB;
     if( memcmp(page1, zMagicHeader, 16)!=0 ){
       goto page1_init_failed;
     }
@@ -1800,9 +1799,13 @@ static int newDatabase(BtShared *pBt){
   MemPage *pP1;
   unsigned char *data;
   int rc;
+  int nPage;
 
   assert( sqlite3_mutex_held(pBt->mutex) );
-  if( sqlite3PagerPagecount(pBt->pPager)>0 ) return SQLITE_OK;
+  rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
+  if( rc!=SQLITE_OK || nPage>0 ){
+    return rc;
+  }
   pP1 = pBt->pPage1;
   assert( pP1!=0 );
   data = pP1->aData;
@@ -2143,6 +2146,13 @@ static int relocatePage(
   return rc;
 }
 
+static int pagerPagecount(Pager *pPager){
+  int rc;
+  int nPage;
+  rc = sqlite3PagerPagecount(pPager, &nPage);
+  return (rc==SQLITE_OK?nPage:-1);
+}
+
 /* Forward declaration required by incrVacuumStep(). */
 static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);
 
@@ -2168,7 +2178,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin){
   assert( sqlite3_mutex_held(pBt->mutex) );
   iLastPg = pBt->nTrunc;
   if( iLastPg==0 ){
-    iLastPg = sqlite3PagerPagecount(pBt->pPager);
+    iLastPg = pagerPagecount(pBt->pPager);
   }
 
   if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){
@@ -2301,7 +2311,7 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *pnTrunc){
       Pgno nFree;
       Pgno nPtrmap;
       const int pgsz = pBt->pageSize;
-      Pgno nOrig = sqlite3PagerPagecount(pBt->pPager);
+      int nOrig = pagerPagecount(pBt->pPager);
 
       if( PTRMAP_ISPAGE(pBt, nOrig) ){
         return SQLITE_CORRUPT_BKPT;
@@ -2722,7 +2732,7 @@ static int btreeCursor(
     }
   }
   pCur->pgnoRoot = (Pgno)iTable;
-  if( iTable==1 && sqlite3PagerPagecount(pBt->pPager)==0 ){
+  if( iTable==1 && pagerPagecount(pBt->pPager)==0 ){
     rc = SQLITE_EMPTY;
     goto create_cursor_exception;
   }
@@ -2977,7 +2987,7 @@ static int getOverflowPage(
       iGuess++;
     }
 
-    if( iGuess<=sqlite3PagerPagecount(pBt->pPager) ){
+    if( iGuess<=pagerPagecount(pBt->pPager) ){
       rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
       if( rc!=SQLITE_OK ){
         return rc;
@@ -3962,7 +3972,7 @@ static int allocateBtreePage(
     ** the entire-list will be searched for that page.
     */
 #ifndef SQLITE_OMIT_AUTOVACUUM
-    if( exact && nearby<=sqlite3PagerPagecount(pBt->pPager) ){
+    if( exact && nearby<=pagerPagecount(pBt->pPager) ){
       u8 eType;
       assert( nearby>0 );
       assert( pBt->autoVacuum );
@@ -4098,7 +4108,9 @@ static int allocateBtreePage(
         iPage = get4byte(&aData[8+closest*4]);
         if( !searchList || iPage==nearby ){
           *pPgno = iPage;
-          if( *pPgno>sqlite3PagerPagecount(pBt->pPager) ){
+          int nPage;
+          nPage = pagerPagecount(pBt->pPager);
+          if( *pPgno>nPage ){
             /* Free page off the end of the file */
             rc = SQLITE_CORRUPT_BKPT;
             goto end_allocate_page;
@@ -4127,7 +4139,8 @@ static int allocateBtreePage(
   }else{
     /* There are no pages on the freelist, so create a new page at the
     ** end of the file */
-    *pPgno = sqlite3PagerPagecount(pBt->pPager) + 1;
+    int nPage = pagerPagecount(pBt->pPager);
+    *pPgno = nPage + 1;
 
 #ifndef SQLITE_OMIT_AUTOVACUUM
     if( pBt->nTrunc ){
@@ -4281,7 +4294,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
   assert( ovflPgno==0 || nOvfl>0 );
   while( nOvfl-- ){
     MemPage *pOvfl;
-    if( ovflPgno==0 || ovflPgno>sqlite3PagerPagecount(pBt->pPager) ){
+    if( ovflPgno==0 || ovflPgno>pagerPagecount(pBt->pPager) ){
       return SQLITE_CORRUPT_BKPT;
     }
 
@@ -5425,7 +5438,7 @@ static int balance_shallower(MemPage *pPage){
     */
     pgnoChild = get4byte(&pPage->aData[pPage->hdrOffset+8]);
     assert( pgnoChild>0 );
-    assert( pgnoChild<=sqlite3PagerPagecount(pPage->pBt->pPager) );
+    assert( pgnoChild<=pagerPagecount(pPage->pBt->pPager) );
     rc = sqlite3BtreeGetPage(pPage->pBt, pgnoChild, &pChild, 0);
     if( rc ) goto end_shallow_balance;
     if( pPage->pgno==1 ){
@@ -6003,7 +6016,7 @@ static int clearDatabasePage(
   int i;
 
   assert( sqlite3_mutex_held(pBt->mutex) );
-  if( pgno>sqlite3PagerPagecount(pBt->pPager) ){
+  if( pgno>pagerPagecount(pBt->pPager) ){
     return SQLITE_CORRUPT_BKPT;
   }
 
@@ -6659,7 +6672,7 @@ char *sqlite3BtreeIntegrityCheck(
   }
   sCheck.pBt = pBt;
   sCheck.pPager = pBt->pPager;
-  sCheck.nPage = sqlite3PagerPagecount(sCheck.pPager);
+  sCheck.nPage = pagerPagecount(sCheck.pPager);
   sCheck.mxErr = mxErr;
   sCheck.nErr = 0;
   *pnErr = 0;
@@ -6820,8 +6833,8 @@ static int btreeCopyFile(Btree *pTo, Btree *pFrom){
     return SQLITE_BUSY;
   }
 
-  nToPage = sqlite3PagerPagecount(pBtTo->pPager);
-  nFromPage = sqlite3PagerPagecount(pBtFrom->pPager);
+  nToPage = pagerPagecount(pBtTo->pPager);
+  nFromPage = pagerPagecount(pBtFrom->pPager);
   iSkip = PENDING_BYTE_PAGE(pBtTo);
 
   /* Variable nNewPage is the number of pages required to store the
index de95f5b9e95befa56798c39a99461dc60d1f595e..06fce97b2d3a8b218f0a97e343a64b63d026ea48 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.455 2008/06/07 05:19:38 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.456 2008/06/07 08:58:22 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -2461,7 +2461,7 @@ int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
   if( mxPage>0 ){
     pPager->mxPgno = mxPage;
   }
-  sqlite3PagerPagecount(pPager);
+  sqlite3PagerPagecount(pPager, 0);
   return pPager->mxPgno;
 }
 
@@ -2522,12 +2522,12 @@ int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){
 ** PENDING_BYTE is byte 4096 (the first byte of page 5) and the size of the
 ** file is 4096 bytes, 5 is returned instead of 4.
 */
-int sqlite3PagerPagecount(Pager *pPager){
+int sqlite3PagerPagecount(Pager *pPager, int *pnPage){
   i64 n = 0;
   int rc;
   assert( pPager!=0 );
   if( pPager->errCode ){
-    return -1;
+    return pPager->errCode;
   }
   if( pPager->dbSize>=0 ){
     n = pPager->dbSize;
@@ -2538,7 +2538,7 @@ int sqlite3PagerPagecount(Pager *pPager){
       pPager->nRef++;
       pager_error(pPager, rc);
       pPager->nRef--;
-      return -1;
+      return rc;
     }
     if( n>0 && n<pPager->pageSize ){
       n = 1;
@@ -2555,7 +2555,10 @@ int sqlite3PagerPagecount(Pager *pPager){
   if( n>pPager->mxPgno ){
     pPager->mxPgno = n;
   }
-  return n;
+  if( pnPage ){
+    *pnPage = n;
+  }
+  return SQLITE_OK;
 }
 
 
@@ -2697,7 +2700,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
 int sqlite3PagerTruncate(Pager *pPager, Pgno nPage){
   int rc;
   assert( pPager->state>=PAGER_SHARED || MEMDB );
-  sqlite3PagerPagecount(pPager);
+  sqlite3PagerPagecount(pPager, 0);
   if( pPager->errCode ){
     rc = pPager->errCode;
     return rc;
@@ -3148,12 +3151,11 @@ static int hasHotJournal(Pager *pPager){
     }
 
     if( rc==SQLITE_OK && exists && !locked ){
-      int nPage = sqlite3PagerPagecount(pPager);
-      if( nPage==0 ){
+      int nPage;
+      rc = sqlite3PagerPagecount(pPager, &nPage);
+      if( rc==SQLITE_OK && nPage==0 ){
         sqlite3OsDelete(pVfs, pPager->zJournal, 0);
         exists = 0;
-      }else if( nPage<0 ){
-        rc = SQLITE_IOERR;
       }
     }
 
@@ -3553,7 +3555,7 @@ static int pagerSharedLock(Pager *pPager){
         ** it can be neglected.
         */
         char dbFileVers[sizeof(pPager->dbFileVers)];
-        sqlite3PagerPagecount(pPager);
+        sqlite3PagerPagecount(pPager, 0);
 
         if( pPager->errCode ){
           rc = pPager->errCode;
@@ -3789,9 +3791,8 @@ static int pagerAcquire(
     if( pPager->nExtra>0 ){
       memset(PGHDR_TO_EXTRA(pPg, pPager), 0, pPager->nExtra);
     }
-    nMax = sqlite3PagerPagecount(pPager);
-    if( pPager->errCode ){
-      rc = pPager->errCode;
+    rc = sqlite3PagerPagecount(pPager, &nMax);
+    if( rc!=SQLITE_OK ){
       sqlite3PagerUnref(pPg);
       return rc;
     }
@@ -3949,7 +3950,7 @@ static int pager_open_journal(Pager *pPager){
   assert( pPager->state>=PAGER_RESERVED );
   assert( pPager->useJournal );
   assert( pPager->pInJournal==0 );
-  sqlite3PagerPagecount(pPager);
+  sqlite3PagerPagecount(pPager, 0);
   pagerLeave(pPager);
   pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);
   pagerEnter(pPager);
@@ -4079,7 +4080,7 @@ int sqlite3PagerBegin(DbPage *pPg, int exFlag){
     assert( pPager->nRec==0 );
     assert( pPager->origDbSize==0 );
     assert( pPager->pInJournal==0 );
-    sqlite3PagerPagecount(pPager);
+    sqlite3PagerPagecount(pPager, 0);
     pagerLeave(pPager);
     pPager->pInJournal = sqlite3BitvecCreate( pPager->dbSize );
     pagerEnter(pPager);
@@ -4365,7 +4366,7 @@ int sqlite3PagerWrite(DbPage *pDbPage){
     */
     pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;
 
-    nPageCount = sqlite3PagerPagecount(pPager);
+    sqlite3PagerPagecount(pPager, (int *)&nPageCount);
     if( pPg->pgno>nPageCount ){
       nPage = (pPg->pgno - pg1)+1;
     }else if( (pg1+nPagePerSector-1)>nPageCount ){
index 224f55143c8f63684ce69769ae7cf241188fa9ca..ddcffa583fc9e434a463a2f8a26acd693dbaad33 100644 (file)
@@ -13,7 +13,7 @@
 ** 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.75 2008/06/06 11:11:26 danielk1977 Exp $
+** @(#) $Id: pager.h,v 1.76 2008/06/07 08:58:22 danielk1977 Exp $
 */
 
 #ifndef _PAGER_H_
@@ -85,7 +85,7 @@ DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
 int sqlite3PagerRef(DbPage*);
 int sqlite3PagerUnref(DbPage*);
 int sqlite3PagerWrite(DbPage*);
-int sqlite3PagerPagecount(Pager*);
+int sqlite3PagerPagecount(Pager*, int*);
 int sqlite3PagerTruncate(Pager*,Pgno);
 int sqlite3PagerBegin(DbPage*, int exFlag);
 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, Pgno, int);
index 68e9c65c0b71781bcb42b26b830af4e8e7abcab8..ae9f06e3a6dc5721b4950b86d4bf56255cd312cd 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test2.c,v 1.57 2008/03/21 16:45:48 drh Exp $
+** $Id: test2.c,v 1.58 2008/06/07 08:58:22 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -305,13 +305,15 @@ static int pager_pagecount(
 ){
   Pager *pPager;
   char zBuf[100];
+  int nPage;
   if( argc!=2 ){
     Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
        " ID\"", 0);
     return TCL_ERROR;
   }
   pPager = sqlite3TextToPtr(argv[1]);
-  sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",sqlite3PagerPagecount(pPager));
+  sqlite3PagerPagecount(pPager, &nPage);
+  sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nPage);
   Tcl_AppendResult(interp, zBuf, 0);
   return TCL_OK;
 }
index 62a68b5683619f8f07bcdf5ba5af8a7f4b231fc5..0b2a7e3ab1a4fb20bb3c5179fd6434942778f0af 100644 (file)
@@ -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.747 2008/06/06 15:04:37 drh Exp $
+** $Id: vdbe.c,v 1.748 2008/06/07 08:58:22 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -489,8 +489,17 @@ static void registerTrace(FILE *out, int iReg, Mem *p){
 
 #ifdef SQLITE_DEBUG
 static int fileExists(sqlite3 *db, const char *zFile){
-  int res;
-  int rc = sqlite3OsAccess(db->pVfs, zFile, SQLITE_ACCESS_EXISTS, &res);
+  int res = 0;
+  int rc = SQLITE_OK;
+#ifdef SQLITE_TEST
+  /* If we are currently testing IO errors, then do not call OsAccess() to
+  ** test for the presence of zFile. This is because any IO error that
+  ** occurs here will not be reported, causing the test to fail.
+  */
+  extern int sqlite3_io_error_pending;
+  if( sqlite3_io_error_pending<=0 )
+#endif
+    rc = sqlite3OsAccess(db->pVfs, zFile, SQLITE_ACCESS_EXISTS, &res);
   return (res && rc==SQLITE_OK);
 }
 #endif
@@ -2636,7 +2645,7 @@ case OP_OpenWrite: {
     case SQLITE_OK: {
       int flags = sqlite3BtreeFlags(pCur->pCursor);
       /* Sanity checking.  Only the lower four bits of the flags byte should
-      ** be used.  Bit 3 (mask 0x08) is unpreditable.  The lower 3 bits
+      ** be used.  Bit 3 (mask 0x08) is unpredictable.  The lower 3 bits
       ** (mask 0x07) should be either 5 (intkey+leafdata for tables) or
       ** 2 (zerodata for indices).  If these conditions are not met it can
       ** only mean that we are dealing with a corrupt database file
@@ -4817,10 +4826,8 @@ case OP_Pagecount: {            /* out2-prerelease */
   int nPage;
   Pager *pPager = sqlite3BtreePager(db->aDb[p1].pBt);
 
-  nPage = sqlite3PagerPagecount(pPager);
-  if( nPage<0 ){
-    rc = SQLITE_IOERR;
-  }else{
+  rc = sqlite3PagerPagecount(pPager, &nPage);
+  if( rc==SQLITE_OK ){
     pOut->flags = MEM_Int;
     pOut->u.i = nPage;
   }
index adf679405d5e38f2cf99a1df7ce4f1c0173bee19..00d1116adb30116e2350f9bf7b5407e722fc326a 100644 (file)
 # The tests in this file use special facilities that are only
 # available in the SQLite test fixture.
 #
-# $Id: ioerr.test,v 1.36 2008/06/05 11:39:12 danielk1977 Exp $
+# $Id: ioerr.test,v 1.37 2008/06/07 08:58:23 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
-
 # If SQLITE_DEFAULT_AUTOVACUUM is set to true, then a simulated IO error
 # on the 8th IO operation in the SQL script below doesn't report an error.
 #