/ Check-in [4b36de46]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the windows OS layer so that it returns detailed IOERR error codes. (CVS 3583)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4b36de46c42e2e42d611b38ff18949bea55c803b
User & Date: drh 2007-01-09 17:18:19
Context
2007-01-09
23:13
Documentation updates prior to version 3.3.10. Among the changes is a fix for ticket #2148 (CVS 3584) check-in: 686beffa user: drh tags: trunk
17:18
Fix the windows OS layer so that it returns detailed IOERR error codes. (CVS 3583) check-in: 4b36de46 user: drh tags: trunk
15:32
Work around win2k problems so that single-character filenames can be used. Ticket #2151. (CVS 3582) check-in: c4eb2100 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

   996    996   ** Read data from a file into a buffer.  Return SQLITE_OK if all
   997    997   ** bytes were read successfully and SQLITE_IOERR if anything goes
   998    998   ** wrong.
   999    999   */
  1000   1000   static int winRead(OsFile *id, void *pBuf, int amt){
  1001   1001     DWORD got;
  1002   1002     assert( id!=0 );
  1003         -  SimulateIOError(return SQLITE_IOERR);
         1003  +  SimulateIOError(return SQLITE_IOERR_READ);
  1004   1004     TRACE3("READ %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
  1005   1005     if( !ReadFile(((winFile*)id)->h, pBuf, amt, &got, 0) ){
  1006   1006       return SQLITE_IOERR_READ;
  1007   1007     }
  1008   1008     if( got==(DWORD)amt ){
  1009   1009       return SQLITE_OK;
  1010   1010     }else{
................................................................................
  1017   1017   ** Write data from a buffer into a file.  Return SQLITE_OK on success
  1018   1018   ** or some other error code on failure.
  1019   1019   */
  1020   1020   static int winWrite(OsFile *id, const void *pBuf, int amt){
  1021   1021     int rc = 0;
  1022   1022     DWORD wrote;
  1023   1023     assert( id!=0 );
  1024         -  SimulateIOError(return SQLITE_IOERR);
         1024  +  SimulateIOError(return SQLITE_IOERR_READ);
  1025   1025     SimulateDiskfullError(return SQLITE_FULL);
  1026   1026     TRACE3("WRITE %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
  1027   1027     assert( amt>0 );
  1028   1028     while( amt>0 && (rc = WriteFile(((winFile*)id)->h, pBuf, amt, &wrote, 0))!=0
  1029   1029            && wrote>0 ){
  1030   1030       amt -= wrote;
  1031   1031       pBuf = &((char*)pBuf)[wrote];
................................................................................
  1077   1077   }
  1078   1078   
  1079   1079   /*
  1080   1080   ** Sync the directory zDirname. This is a no-op on operating systems other
  1081   1081   ** than UNIX.
  1082   1082   */
  1083   1083   int sqlite3WinSyncDirectory(const char *zDirname){
  1084         -  SimulateIOError(return SQLITE_IOERR);
         1084  +  SimulateIOError(return SQLITE_IOERR_READ);
  1085   1085     return SQLITE_OK;
  1086   1086   }
  1087   1087   
  1088   1088   /*
  1089   1089   ** Truncate an open file to a specified size
  1090   1090   */
  1091   1091   static int winTruncate(OsFile *id, i64 nByte){
  1092   1092     LONG upperBits = nByte>>32;
  1093   1093     assert( id!=0 );
  1094   1094     TRACE3("TRUNCATE %d %lld\n", ((winFile*)id)->h, nByte);
  1095         -  SimulateIOError(return SQLITE_IOERR);
         1095  +  SimulateIOError(return SQLITE_IOERR_TRUNCATE);
  1096   1096     SetFilePointer(((winFile*)id)->h, nByte, &upperBits, FILE_BEGIN);
  1097   1097     SetEndOfFile(((winFile*)id)->h);
  1098   1098     return SQLITE_OK;
  1099   1099   }
  1100   1100   
  1101   1101   /*
  1102   1102   ** Determine the current size of a file in bytes
  1103   1103   */
  1104   1104   static int winFileSize(OsFile *id, i64 *pSize){
  1105   1105     DWORD upperBits, lowerBits;
  1106   1106     assert( id!=0 );
  1107         -  SimulateIOError(return SQLITE_IOERR);
         1107  +  SimulateIOError(return SQLITE_IOERR_FSTAT);
  1108   1108     lowerBits = GetFileSize(((winFile*)id)->h, &upperBits);
  1109   1109     *pSize = (((i64)upperBits)<<32) + lowerBits;
  1110   1110     return SQLITE_OK;
  1111   1111   }
  1112   1112   
  1113   1113   /*
  1114   1114   ** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.
................................................................................
  1361   1361             pFile->locktype, pFile->sharedLockByte);
  1362   1362     type = pFile->locktype;
  1363   1363     if( type>=EXCLUSIVE_LOCK ){
  1364   1364       UnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
  1365   1365       if( locktype==SHARED_LOCK && !getReadLock(pFile) ){
  1366   1366         /* This should never happen.  We should always be able to
  1367   1367         ** reacquire the read lock */
  1368         -      rc = SQLITE_IOERR;
         1368  +      rc = SQLITE_IOERR_UNLOCK;
  1369   1369       }
  1370   1370     }
  1371   1371     if( type>=RESERVED_LOCK ){
  1372   1372       UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
  1373   1373     }
  1374   1374     if( locktype==NO_LOCK && type>=SHARED_LOCK ){
  1375   1375       unlockReadLock(pFile);