/ Check-in [b347b5d1]
Login
Overview
Comment:Initial work on reforming usage of OSTRACE by the Windows VFS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winOsTrace
Files: files | file ages | folders
SHA1:b347b5d1a01301f44e6fd20ee03a9529ffd25788
User & Date: mistachkin 2013-04-28 01:44:43
Context
2013-04-29
03:09
More refinements to Windows OSTRACE usage. Replace all usage of sqlite3TestErrorName() with sqlite3ErrName() and add missing return codes. check-in: 05ba5e23 user: mistachkin tags: winOsTrace
2013-04-28
01:44
Initial work on reforming usage of OSTRACE by the Windows VFS. check-in: b347b5d1 user: mistachkin tags: winOsTrace
2013-04-27
18:06
Remove spellfix virtual table documentation from the source tree. Reference the separate documentation on the website instead. check-in: adcf7890 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  1024   1024     db->nDeferredCons = 0;
  1025   1025   
  1026   1026     /* If one has been configured, invoke the rollback-hook callback */
  1027   1027     if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
  1028   1028       db->xRollbackCallback(db->pRollbackArg);
  1029   1029     }
  1030   1030   }
         1031  +
         1032  +/*
         1033  +** Return a static string containing the name corresponding to the error code
         1034  +** specified in the argument.
         1035  +*/
         1036  +const char *sqlite3ErrName(int rc){
         1037  +  const char *zName = 0;
         1038  +  int i;
         1039  +  for(i=0; i<2 && zName==0; i++, rc &= 0xff){
         1040  +    switch( rc ){
         1041  +      case SQLITE_OK:                 zName = "SQLITE_OK";                break;
         1042  +      case SQLITE_ERROR:              zName = "SQLITE_ERROR";             break;
         1043  +      case SQLITE_INTERNAL:           zName = "SQLITE_INTERNAL";          break;
         1044  +      case SQLITE_PERM:               zName = "SQLITE_PERM";              break;
         1045  +      case SQLITE_ABORT:              zName = "SQLITE_ABORT";             break;
         1046  +      case SQLITE_BUSY:               zName = "SQLITE_BUSY";              break;
         1047  +      case SQLITE_LOCKED:             zName = "SQLITE_LOCKED";            break;
         1048  +      case SQLITE_LOCKED_SHAREDCACHE: zName = "SQLITE_LOCKED_SHAREDCACHE";break;
         1049  +      case SQLITE_NOMEM:              zName = "SQLITE_NOMEM";             break;
         1050  +      case SQLITE_READONLY:           zName = "SQLITE_READONLY";          break;
         1051  +      case SQLITE_INTERRUPT:          zName = "SQLITE_INTERRUPT";         break;
         1052  +      case SQLITE_IOERR:              zName = "SQLITE_IOERR";             break;
         1053  +      case SQLITE_CORRUPT:            zName = "SQLITE_CORRUPT";           break;
         1054  +      case SQLITE_NOTFOUND:           zName = "SQLITE_NOTFOUND";          break;
         1055  +      case SQLITE_FULL:               zName = "SQLITE_FULL";              break;
         1056  +      case SQLITE_CANTOPEN:           zName = "SQLITE_CANTOPEN";          break;
         1057  +      case SQLITE_PROTOCOL:           zName = "SQLITE_PROTOCOL";          break;
         1058  +      case SQLITE_EMPTY:              zName = "SQLITE_EMPTY";             break;
         1059  +      case SQLITE_SCHEMA:             zName = "SQLITE_SCHEMA";            break;
         1060  +      case SQLITE_TOOBIG:             zName = "SQLITE_TOOBIG";            break;
         1061  +      case SQLITE_CONSTRAINT:         zName = "SQLITE_CONSTRAINT";        break;
         1062  +      case SQLITE_CONSTRAINT_UNIQUE:  zName = "SQLITE_CONSTRAINT_UNIQUE"; break;
         1063  +      case SQLITE_CONSTRAINT_TRIGGER: zName = "SQLITE_CONSTRAINT_TRIGGER";break;
         1064  +      case SQLITE_CONSTRAINT_FOREIGNKEY:
         1065  +                                zName = "SQLITE_CONSTRAINT_FOREIGNKEY";   break;
         1066  +      case SQLITE_CONSTRAINT_CHECK:   zName = "SQLITE_CONSTRAINT_CHECK";  break;
         1067  +      case SQLITE_CONSTRAINT_PRIMARYKEY:
         1068  +                                zName = "SQLITE_CONSTRAINT_PRIMARYKEY";   break;
         1069  +      case SQLITE_CONSTRAINT_NOTNULL: zName = "SQLITE_CONSTRAINT_NOTNULL";break;
         1070  +      case SQLITE_CONSTRAINT_COMMITHOOK:
         1071  +                                zName = "SQLITE_CONSTRAINT_COMMITHOOK";   break;
         1072  +      case SQLITE_CONSTRAINT_VTAB:    zName = "SQLITE_CONSTRAINT_VTAB";   break;
         1073  +      case SQLITE_CONSTRAINT_FUNCTION:
         1074  +                                zName = "SQLITE_CONSTRAINT_FUNCTION";     break;
         1075  +      case SQLITE_MISMATCH:           zName = "SQLITE_MISMATCH";          break;
         1076  +      case SQLITE_MISUSE:             zName = "SQLITE_MISUSE";            break;
         1077  +      case SQLITE_NOLFS:              zName = "SQLITE_NOLFS";             break;
         1078  +      case SQLITE_AUTH:               zName = "SQLITE_AUTH";              break;
         1079  +      case SQLITE_FORMAT:             zName = "SQLITE_FORMAT";            break;
         1080  +      case SQLITE_RANGE:              zName = "SQLITE_RANGE";             break;
         1081  +      case SQLITE_NOTADB:             zName = "SQLITE_NOTADB";            break;
         1082  +      case SQLITE_ROW:                zName = "SQLITE_ROW";               break;
         1083  +      case SQLITE_NOTICE:             zName = "SQLITE_NOTICE";            break;
         1084  +      case SQLITE_WARNING:            zName = "SQLITE_WARNING";           break;
         1085  +      case SQLITE_DONE:               zName = "SQLITE_DONE";              break;
         1086  +      case SQLITE_IOERR_READ:         zName = "SQLITE_IOERR_READ";        break;
         1087  +      case SQLITE_IOERR_SHORT_READ:   zName = "SQLITE_IOERR_SHORT_READ";  break;
         1088  +      case SQLITE_IOERR_WRITE:        zName = "SQLITE_IOERR_WRITE";       break;
         1089  +      case SQLITE_IOERR_FSYNC:        zName = "SQLITE_IOERR_FSYNC";       break;
         1090  +      case SQLITE_IOERR_DIR_FSYNC:    zName = "SQLITE_IOERR_DIR_FSYNC";   break;
         1091  +      case SQLITE_IOERR_TRUNCATE:     zName = "SQLITE_IOERR_TRUNCATE";    break;
         1092  +      case SQLITE_IOERR_FSTAT:        zName = "SQLITE_IOERR_FSTAT";       break;
         1093  +      case SQLITE_IOERR_UNLOCK:       zName = "SQLITE_IOERR_UNLOCK";      break;
         1094  +      case SQLITE_IOERR_RDLOCK:       zName = "SQLITE_IOERR_RDLOCK";      break;
         1095  +      case SQLITE_IOERR_DELETE:       zName = "SQLITE_IOERR_DELETE";      break;
         1096  +      case SQLITE_IOERR_BLOCKED:      zName = "SQLITE_IOERR_BLOCKED";     break;
         1097  +      case SQLITE_IOERR_NOMEM:        zName = "SQLITE_IOERR_NOMEM";       break;
         1098  +      case SQLITE_IOERR_ACCESS:       zName = "SQLITE_IOERR_ACCESS";      break;
         1099  +      case SQLITE_IOERR_CHECKRESERVEDLOCK:
         1100  +                                zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break;
         1101  +      case SQLITE_IOERR_LOCK:         zName = "SQLITE_IOERR_LOCK";        break;
         1102  +      case SQLITE_CORRUPT_VTAB:       zName = "SQLITE_CORRUPT_VTAB";      break;
         1103  +      case SQLITE_READONLY_RECOVERY:  zName = "SQLITE_READONLY_RECOVERY"; break;
         1104  +      case SQLITE_READONLY_CANTLOCK:  zName = "SQLITE_READONLY_CANTLOCK"; break;
         1105  +      case SQLITE_READONLY_ROLLBACK:  zName = "SQLITE_READONLY_ROLLBACK"; break;
         1106  +    }
         1107  +  }
         1108  +  if( zName==0 ) zName = "SQLITE_Unknown";
         1109  +  return zName;
         1110  +}
  1031   1111   
  1032   1112   /*
  1033   1113   ** Return a static string that describes the kind of error specified in the
  1034   1114   ** argument.
  1035   1115   */
  1036   1116   const char *sqlite3ErrStr(int rc){
  1037   1117     static const char* const aMsg[] = {

Changes to src/os_win.c.

  2023   2023   static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){
  2024   2024   #if !SQLITE_OS_WINRT
  2025   2025     LONG upperBits;                 /* Most sig. 32 bits of new offset */
  2026   2026     LONG lowerBits;                 /* Least sig. 32 bits of new offset */
  2027   2027     DWORD dwRet;                    /* Value returned by SetFilePointer() */
  2028   2028     DWORD lastErrno;                /* Value returned by GetLastError() */
  2029   2029   
         2030  +  OSTRACE(("SEEK file=%p, offset=%lld\n", pFile->h, iOffset));
         2031  +
  2030   2032     upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
  2031   2033     lowerBits = (LONG)(iOffset & 0xffffffff);
  2032   2034   
  2033   2035     /* API oddity: If successful, SetFilePointer() returns a dword 
  2034   2036     ** containing the lower 32-bits of the new file-offset. Or, if it fails,
  2035   2037     ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, 
  2036   2038     ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine 
................................................................................
  2040   2042     dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
  2041   2043   
  2042   2044     if( (dwRet==INVALID_SET_FILE_POINTER
  2043   2045         && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
  2044   2046       pFile->lastErrno = lastErrno;
  2045   2047       winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
  2046   2048                "seekWinFile", pFile->zPath);
         2049  +    OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
  2047   2050       return 1;
  2048   2051     }
  2049   2052   
         2053  +  OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
  2050   2054     return 0;
  2051   2055   #else
  2052   2056     /*
  2053   2057     ** Same as above, except that this implementation works for WinRT.
  2054   2058     */
  2055   2059   
  2056   2060     LARGE_INTEGER x;                /* The new offset */
................................................................................
  2059   2063     x.QuadPart = iOffset;
  2060   2064     bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);
  2061   2065   
  2062   2066     if(!bRet){
  2063   2067       pFile->lastErrno = osGetLastError();
  2064   2068       winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
  2065   2069                "seekWinFile", pFile->zPath);
         2070  +    OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
  2066   2071       return 1;
  2067   2072     }
  2068   2073   
         2074  +  OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
  2069   2075     return 0;
  2070   2076   #endif
  2071   2077   }
  2072   2078   
  2073   2079   #if SQLITE_MAX_MMAP_SIZE>0
  2074   2080   /* Forward references to VFS methods */
  2075   2081   static int winUnmapfile(winFile*);
................................................................................
  2090   2096     int rc, cnt = 0;
  2091   2097     winFile *pFile = (winFile*)id;
  2092   2098   
  2093   2099     assert( id!=0 );
  2094   2100   #ifndef SQLITE_OMIT_WAL
  2095   2101     assert( pFile->pShm==0 );
  2096   2102   #endif
  2097         -  OSTRACE(("CLOSE %d\n", pFile->h));
  2098   2103     assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
         2104  +  OSTRACE(("CLOSE file=%p\n", pFile->h));
  2099   2105   
  2100   2106   #if SQLITE_MAX_MMAP_SIZE>0
  2101   2107     rc = winUnmapfile(pFile);
  2102   2108     if( rc!=SQLITE_OK ) return rc;
  2103   2109   #endif
  2104   2110   
  2105   2111     do{
................................................................................
  2117   2123           && cnt++ < WINCE_DELETION_ATTEMPTS
  2118   2124       ){
  2119   2125          sqlite3_win32_sleep(100);  /* Wait a little before trying again */
  2120   2126       }
  2121   2127       sqlite3_free(pFile->zDeleteOnClose);
  2122   2128     }
  2123   2129   #endif
  2124         -  OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
  2125   2130     if( rc ){
  2126   2131       pFile->h = NULL;
  2127   2132     }
  2128   2133     OpenCounter(-1);
         2134  +  OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
  2129   2135     return rc ? SQLITE_OK
  2130   2136               : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
  2131   2137                             "winClose", pFile->zPath);
  2132   2138   }
  2133   2139   
  2134   2140   /*
  2135   2141   ** Read data from a file into a buffer.  Return SQLITE_OK if all
................................................................................
  2148   2154     winFile *pFile = (winFile*)id;  /* file handle */
  2149   2155     DWORD nRead;                    /* Number of bytes actually read from file */
  2150   2156     int nRetry = 0;                 /* Number of retrys */
  2151   2157   
  2152   2158     assert( id!=0 );
  2153   2159     assert( amt>0 );
  2154   2160     SimulateIOError(return SQLITE_IOERR_READ);
  2155         -  OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
         2161  +  OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
         2162  +           pFile->h, pBuf, amt, offset, pFile->locktype));
  2156   2163   
  2157   2164   #if SQLITE_MAX_MMAP_SIZE>0
  2158   2165     /* Deal with as much of this read request as possible by transfering
  2159   2166     ** data from the memory mapping using memcpy().  */
  2160   2167     if( offset<pFile->mmapSize ){
  2161   2168       if( offset+amt <= pFile->mmapSize ){
  2162   2169         memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
         2170  +      OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
  2163   2171         return SQLITE_OK;
  2164   2172       }else{
  2165   2173         int nCopy = (int)(pFile->mmapSize - offset);
  2166   2174         memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
  2167   2175         pBuf = &((u8 *)pBuf)[nCopy];
  2168   2176         amt -= nCopy;
  2169   2177         offset += nCopy;
  2170   2178       }
  2171   2179     }
  2172   2180   #endif
  2173   2181   
  2174   2182   #if SQLITE_OS_WINCE
  2175   2183     if( seekWinFile(pFile, offset) ){
         2184  +    OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
  2176   2185       return SQLITE_FULL;
  2177   2186     }
  2178   2187     while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
  2179   2188   #else
  2180   2189     memset(&overlapped, 0, sizeof(OVERLAPPED));
  2181   2190     overlapped.Offset = (LONG)(offset & 0xffffffff);
  2182   2191     overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
  2183   2192     while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
  2184   2193            osGetLastError()!=ERROR_HANDLE_EOF ){
  2185   2194   #endif
  2186   2195       DWORD lastErrno;
  2187   2196       if( retryIoerr(&nRetry, &lastErrno) ) continue;
  2188   2197       pFile->lastErrno = lastErrno;
         2198  +    OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
  2189   2199       return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
  2190   2200                "winRead", pFile->zPath);
  2191   2201     }
  2192   2202     logIoerr(nRetry);
  2193   2203     if( nRead<(DWORD)amt ){
  2194   2204       /* Unread parts of the buffer must be zero-filled */
  2195   2205       memset(&((char*)pBuf)[nRead], 0, amt-nRead);
         2206  +    OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
  2196   2207       return SQLITE_IOERR_SHORT_READ;
  2197   2208     }
  2198   2209   
         2210  +  OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
  2199   2211     return SQLITE_OK;
  2200   2212   }
  2201   2213   
  2202   2214   /*
  2203   2215   ** Write data from a buffer into a file.  Return SQLITE_OK on success
  2204   2216   ** or some other error code on failure.
  2205   2217   */
................................................................................
  2214   2226     int nRetry = 0;                 /* Number of retries */
  2215   2227   
  2216   2228     assert( amt>0 );
  2217   2229     assert( pFile );
  2218   2230     SimulateIOError(return SQLITE_IOERR_WRITE);
  2219   2231     SimulateDiskfullError(return SQLITE_FULL);
  2220   2232   
  2221         -  OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
         2233  +  OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
         2234  +           pFile->h, pBuf, amt, offset, pFile->locktype));
  2222   2235   
  2223   2236   #if SQLITE_MAX_MMAP_SIZE>0
  2224   2237     /* Deal with as much of this write request as possible by transfering
  2225   2238     ** data from the memory mapping using memcpy().  */
  2226   2239     if( offset<pFile->mmapSize ){
  2227   2240       if( offset+amt <= pFile->mmapSize ){
  2228   2241         memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
         2242  +      OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
  2229   2243         return SQLITE_OK;
  2230   2244       }else{
  2231   2245         int nCopy = (int)(pFile->mmapSize - offset);
  2232   2246         memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
  2233   2247         pBuf = &((u8 *)pBuf)[nCopy];
  2234   2248         amt -= nCopy;
  2235   2249         offset += nCopy;
................................................................................
  2284   2298         rc = 1;
  2285   2299       }
  2286   2300     }
  2287   2301   
  2288   2302     if( rc ){
  2289   2303       if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
  2290   2304          || ( pFile->lastErrno==ERROR_DISK_FULL )){
         2305  +      OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
  2291   2306         return SQLITE_FULL;
  2292   2307       }
         2308  +    OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
  2293   2309       return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
  2294   2310                "winWrite", pFile->zPath);
  2295   2311     }else{
  2296   2312       logIoerr(nRetry);
  2297   2313     }
         2314  +  OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
  2298   2315     return SQLITE_OK;
  2299   2316   }
  2300   2317   
  2301   2318   /*
  2302   2319   ** Truncate an open file to a specified size
  2303   2320   */
  2304   2321   static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
  2305   2322     winFile *pFile = (winFile*)id;  /* File handle object */
  2306   2323     int rc = SQLITE_OK;             /* Return code for this function */
  2307   2324     DWORD lastErrno;
  2308   2325   
  2309   2326     assert( pFile );
  2310         -
  2311         -  OSTRACE(("TRUNCATE %d %lld\n", pFile->h, nByte));
  2312   2327     SimulateIOError(return SQLITE_IOERR_TRUNCATE);
         2328  +  OSTRACE(("TRUNCATE file=%d, size=%lld, lock=%d\n",
         2329  +           pFile->h, nByte, pFile->locktype));
  2313   2330   
  2314   2331     /* If the user has configured a chunk-size for this file, truncate the
  2315   2332     ** file so that it consists of an integer number of chunks (i.e. the
  2316   2333     ** actual file size after the operation may be larger than the requested
  2317   2334     ** size).
  2318   2335     */
  2319   2336     if( pFile->szChunk>0 ){
................................................................................
  2337   2354     ** use read() and write() to access data beyond this point from now on.
  2338   2355     */
  2339   2356     if( pFile->pMapRegion && nByte<pFile->mmapSize ){
  2340   2357       pFile->mmapSize = nByte;
  2341   2358     }
  2342   2359   #endif
  2343   2360   
  2344         -  OSTRACE(("TRUNCATE %d %lld %s\n", pFile->h, nByte, rc ? "failed" : "ok"));
         2361  +  OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
  2345   2362     return rc;
  2346   2363   }
  2347   2364   
  2348   2365   #ifdef SQLITE_TEST
  2349   2366   /*
  2350   2367   ** Count the number of fullsyncs and normal syncs.  This is used to test
  2351   2368   ** that syncs and fullsyncs are occuring at the right times.
................................................................................
  2377   2394   
  2378   2395     assert( pFile );
  2379   2396     /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */
  2380   2397     assert((flags&0x0F)==SQLITE_SYNC_NORMAL
  2381   2398         || (flags&0x0F)==SQLITE_SYNC_FULL
  2382   2399     );
  2383   2400   
  2384         -  OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype));
  2385         -
  2386   2401     /* Unix cannot, but some systems may return SQLITE_FULL from here. This
  2387   2402     ** line is to test that doing so does not cause any problems.
  2388   2403     */
  2389   2404     SimulateDiskfullError( return SQLITE_FULL );
         2405  +
         2406  +  OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
         2407  +           pFile->h, flags, pFile->locktype));
  2390   2408   
  2391   2409   #ifndef SQLITE_TEST
  2392   2410     UNUSED_PARAMETER(flags);
  2393   2411   #else
  2394   2412     if( (flags&0x0F)==SQLITE_SYNC_FULL ){
  2395   2413       sqlite3_fullsync_count++;
  2396   2414     }
................................................................................
  2402   2420     */
  2403   2421   #ifdef SQLITE_NO_SYNC
  2404   2422     return SQLITE_OK;
  2405   2423   #else
  2406   2424     rc = osFlushFileBuffers(pFile->h);
  2407   2425     SimulateIOError( rc=FALSE );
  2408   2426     if( rc ){
         2427  +    OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
  2409   2428       return SQLITE_OK;
  2410   2429     }else{
  2411   2430       pFile->lastErrno = osGetLastError();
         2431  +    OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
  2412   2432       return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
  2413   2433                "winSync", pFile->zPath);
  2414   2434     }
  2415   2435   #endif
  2416   2436   }
  2417   2437   
  2418   2438   /*
................................................................................
  2419   2439   ** Determine the current size of a file in bytes
  2420   2440   */
  2421   2441   static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
  2422   2442     winFile *pFile = (winFile*)id;
  2423   2443     int rc = SQLITE_OK;
  2424   2444   
  2425   2445     assert( id!=0 );
         2446  +  assert( pSize!=0 );
  2426   2447     SimulateIOError(return SQLITE_IOERR_FSTAT);
         2448  +  OSTRACE(("SIZE file=%p, pSize=%p\n", pFile->h, pSize));
         2449  +
  2427   2450   #if SQLITE_OS_WINRT
  2428   2451     {
  2429   2452       FILE_STANDARD_INFO info;
  2430   2453       if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,
  2431   2454                                        &info, sizeof(info)) ){
  2432   2455         *pSize = info.EndOfFile.QuadPart;
  2433   2456       }else{
................................................................................
  2448   2471          && ((lastErrno = osGetLastError())!=NO_ERROR) ){
  2449   2472         pFile->lastErrno = lastErrno;
  2450   2473         rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
  2451   2474                "winFileSize", pFile->zPath);
  2452   2475       }
  2453   2476     }
  2454   2477   #endif
         2478  +  OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
         2479  +           pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
  2455   2480     return rc;
  2456   2481   }
  2457   2482   
  2458   2483   /*
  2459   2484   ** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.
  2460   2485   */
  2461   2486   #ifndef LOCKFILE_FAIL_IMMEDIATELY
................................................................................
  2489   2514   /*
  2490   2515   ** Acquire a reader lock.
  2491   2516   ** Different API routines are called depending on whether or not this
  2492   2517   ** is Win9x or WinNT.
  2493   2518   */
  2494   2519   static int getReadLock(winFile *pFile){
  2495   2520     int res;
         2521  +  OSTRACE(("READ-LOCK file=%p, lock=%d\n", pFile->h, pFile->locktype));
  2496   2522     if( isNT() ){
  2497   2523   #if SQLITE_OS_WINCE
  2498   2524       /*
  2499   2525       ** NOTE: Windows CE is handled differently here due its lack of the Win32
  2500   2526       **       API LockFileEx.
  2501   2527       */
  2502   2528       res = winceLockFile(&pFile->h, SHARED_FIRST, 0, 1, 0);
................................................................................
  2514   2540                         SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
  2515   2541     }
  2516   2542   #endif
  2517   2543     if( res == 0 ){
  2518   2544       pFile->lastErrno = osGetLastError();
  2519   2545       /* No need to log a failure to lock */
  2520   2546     }
         2547  +  OSTRACE(("READ-LOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res)));
  2521   2548     return res;
  2522   2549   }
  2523   2550   
  2524   2551   /*
  2525   2552   ** Undo a readlock
  2526   2553   */
  2527   2554   static int unlockReadLock(winFile *pFile){
  2528   2555     int res;
  2529   2556     DWORD lastErrno;
         2557  +  OSTRACE(("READ-UNLOCK file=%p, lock=%d\n", pFile->h, pFile->locktype));
  2530   2558     if( isNT() ){
  2531   2559       res = winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
  2532   2560     }
  2533   2561   #ifdef SQLITE_WIN32_HAS_ANSI
  2534   2562     else{
  2535   2563       res = winUnlockFile(&pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
  2536   2564     }
  2537   2565   #endif
  2538   2566     if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){
  2539   2567       pFile->lastErrno = lastErrno;
  2540   2568       winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,
  2541   2569                "unlockReadLock", pFile->zPath);
  2542   2570     }
         2571  +  OSTRACE(("READ-UNLOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res)));
  2543   2572     return res;
  2544   2573   }
  2545   2574   
  2546   2575   /*
  2547   2576   ** Lock the file with the lock specified by parameter locktype - one
  2548   2577   ** of the following:
  2549   2578   **
................................................................................
  2574   2603     int res = 1;           /* Result of a Windows lock call */
  2575   2604     int newLocktype;       /* Set pFile->locktype to this value before exiting */
  2576   2605     int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
  2577   2606     winFile *pFile = (winFile*)id;
  2578   2607     DWORD lastErrno = NO_ERROR;
  2579   2608   
  2580   2609     assert( id!=0 );
  2581         -  OSTRACE(("LOCK %d %d was %d(%d)\n",
  2582         -           pFile->h, locktype, pFile->locktype, pFile->sharedLockByte));
         2610  +  OSTRACE(("LOCK file=%p, oldLock=%d(%d), newLock=%d\n",
         2611  +           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));
  2583   2612   
  2584   2613     /* If there is already a lock of this type or more restrictive on the
  2585   2614     ** OsFile, do nothing. Don't use the end_lock: exit path, as
  2586   2615     ** sqlite3OsEnterMutex() hasn't been called yet.
  2587   2616     */
  2588   2617     if( pFile->locktype>=locktype ){
         2618  +    OSTRACE(("LOCK-HELD file=%p, rc=SQLITE_OK\n", pFile->h));
  2589   2619       return SQLITE_OK;
  2590   2620     }
  2591   2621   
  2592   2622     /* Make sure the locking sequence is correct
  2593   2623     */
  2594   2624     assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );
  2595   2625     assert( locktype!=PENDING_LOCK );
................................................................................
  2609   2639                                            PENDING_BYTE, 0, 1, 0))==0 ){
  2610   2640         /* Try 3 times to get the pending lock.  This is needed to work
  2611   2641         ** around problems caused by indexing and/or anti-virus software on
  2612   2642         ** Windows systems.
  2613   2643         ** If you are using this code as a model for alternative VFSes, do not
  2614   2644         ** copy this retry logic.  It is a hack intended for Windows only.
  2615   2645         */
  2616         -      OSTRACE(("could not get a PENDING lock. cnt=%d\n", cnt));
         2646  +      OSTRACE(("LOCK-PENDING-FAIL file=%p, count=%d, rc=%s\n",
         2647  +               pFile->h, cnt, sqlite3ErrName(res)));
  2617   2648         if( cnt ) sqlite3_win32_sleep(1);
  2618   2649       }
  2619   2650       gotPendingLock = res;
  2620   2651       if( !res ){
  2621   2652         lastErrno = osGetLastError();
  2622   2653       }
  2623   2654     }
................................................................................
  2654   2685     }
  2655   2686   
  2656   2687     /* Acquire an EXCLUSIVE lock
  2657   2688     */
  2658   2689     if( locktype==EXCLUSIVE_LOCK && res ){
  2659   2690       assert( pFile->locktype>=SHARED_LOCK );
  2660   2691       res = unlockReadLock(pFile);
  2661         -    OSTRACE(("unreadlock = %d\n", res));
  2662   2692       res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,
  2663   2693                         SHARED_SIZE, 0);
  2664   2694       if( res ){
  2665   2695         newLocktype = EXCLUSIVE_LOCK;
  2666   2696       }else{
  2667   2697         lastErrno = osGetLastError();
  2668         -      OSTRACE(("error-code = %d\n", lastErrno));
  2669   2698         getReadLock(pFile);
  2670   2699       }
  2671   2700     }
  2672   2701   
  2673   2702     /* If we are holding a PENDING lock that ought to be released, then
  2674   2703     ** release it now.
  2675   2704     */
................................................................................
  2679   2708   
  2680   2709     /* Update the state of the lock has held in the file descriptor then
  2681   2710     ** return the appropriate result code.
  2682   2711     */
  2683   2712     if( res ){
  2684   2713       rc = SQLITE_OK;
  2685   2714     }else{
  2686         -    OSTRACE(("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
  2687         -           locktype, newLocktype));
         2715  +    OSTRACE(("LOCK-FAIL file=%p, wanted=%d, got=%d\n",
         2716  +             pFile->h, locktype, newLocktype));
  2688   2717       pFile->lastErrno = lastErrno;
  2689   2718       rc = SQLITE_BUSY;
  2690   2719     }
  2691   2720     pFile->locktype = (u8)newLocktype;
         2721  +  OSTRACE(("LOCK file=%p, lock=%d, rc=%s\n",
         2722  +           pFile->h, pFile->locktype, sqlite3ErrName(rc)));
  2692   2723     return rc;
  2693   2724   }
  2694   2725   
  2695   2726   /*
  2696   2727   ** This routine checks if there is a RESERVED lock held on the specified
  2697   2728   ** file by this or any other process. If such a lock is held, return
  2698   2729   ** non-zero, otherwise zero.
  2699   2730   */
  2700   2731   static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
  2701   2732     int rc;
  2702   2733     winFile *pFile = (winFile*)id;
  2703   2734   
  2704   2735     SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
         2736  +  OSTRACE(("TEST-WR-LOCK file=%p, pResOut=%p\n", pFile->h, pResOut));
  2705   2737   
  2706   2738     assert( id!=0 );
  2707   2739     if( pFile->locktype>=RESERVED_LOCK ){
  2708   2740       rc = 1;
  2709         -    OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc));
         2741  +    OSTRACE(("TEST-WR-LOCK file=%p, rc=%d (local)\n", pFile->h, rc));
  2710   2742     }else{
  2711   2743       rc = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE, 0, 1, 0);
  2712   2744       if( rc ){
  2713   2745         winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
  2714   2746       }
  2715   2747       rc = !rc;
  2716         -    OSTRACE(("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc));
         2748  +    OSTRACE(("TEST-WR-LOCK file=%p, rc=%d (remote)\n", pFile->h, rc));
  2717   2749     }
  2718   2750     *pResOut = rc;
         2751  +  OSTRACE(("TEST-WR-LOCK file=%p, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
         2752  +           pFile->h, pResOut, *pResOut));
  2719   2753     return SQLITE_OK;
  2720   2754   }
  2721   2755   
  2722   2756   /*
  2723   2757   ** Lower the locking level on file descriptor id to locktype.  locktype
  2724   2758   ** must be either NO_LOCK or SHARED_LOCK.
  2725   2759   **
................................................................................
  2732   2766   */
  2733   2767   static int winUnlock(sqlite3_file *id, int locktype){
  2734   2768     int type;
  2735   2769     winFile *pFile = (winFile*)id;
  2736   2770     int rc = SQLITE_OK;
  2737   2771     assert( pFile!=0 );
  2738   2772     assert( locktype<=SHARED_LOCK );
  2739         -  OSTRACE(("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
  2740         -          pFile->locktype, pFile->sharedLockByte));
         2773  +  OSTRACE(("UNLOCK file=%p, oldLock=%d(%d), newLock=%d\n",
         2774  +           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));
  2741   2775     type = pFile->locktype;
  2742   2776     if( type>=EXCLUSIVE_LOCK ){
  2743   2777       winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
  2744   2778       if( locktype==SHARED_LOCK && !getReadLock(pFile) ){
  2745   2779         /* This should never happen.  We should always be able to
  2746   2780         ** reacquire the read lock */
  2747   2781         rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),
................................................................................
  2754   2788     if( locktype==NO_LOCK && type>=SHARED_LOCK ){
  2755   2789       unlockReadLock(pFile);
  2756   2790     }
  2757   2791     if( type>=PENDING_LOCK ){
  2758   2792       winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);
  2759   2793     }
  2760   2794     pFile->locktype = (u8)locktype;
         2795  +  OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
         2796  +           pFile->h, pFile->locktype, sqlite3ErrName(rc)));
  2761   2797     return rc;
  2762   2798   }
  2763   2799   
  2764   2800   /*
  2765   2801   ** If *pArg is inititially negative then this is a query.  Set *pArg to
  2766   2802   ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
  2767   2803   **
................................................................................
  2781   2817   static int getTempname(int nBuf, char *zBuf);
  2782   2818   
  2783   2819   /*
  2784   2820   ** Control and query of the open file handle.
  2785   2821   */
  2786   2822   static int winFileControl(sqlite3_file *id, int op, void *pArg){
  2787   2823     winFile *pFile = (winFile*)id;
         2824  +  OSTRACE(("FCNTL file=%p, op=%d, pArg=%p\n", pFile->h, op, pArg));
  2788   2825     switch( op ){
  2789   2826       case SQLITE_FCNTL_LOCKSTATE: {
  2790   2827         *(int*)pArg = pFile->locktype;
         2828  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2791   2829         return SQLITE_OK;
  2792   2830       }
  2793   2831       case SQLITE_LAST_ERRNO: {
  2794   2832         *(int*)pArg = (int)pFile->lastErrno;
         2833  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2795   2834         return SQLITE_OK;
  2796   2835       }
  2797   2836       case SQLITE_FCNTL_CHUNK_SIZE: {
  2798   2837         pFile->szChunk = *(int *)pArg;
         2838  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2799   2839         return SQLITE_OK;
  2800   2840       }
  2801   2841       case SQLITE_FCNTL_SIZE_HINT: {
  2802   2842         if( pFile->szChunk>0 ){
  2803   2843           sqlite3_int64 oldSz;
  2804   2844           int rc = winFileSize(id, &oldSz);
  2805   2845           if( rc==SQLITE_OK ){
................................................................................
  2806   2846             sqlite3_int64 newSz = *(sqlite3_int64*)pArg;
  2807   2847             if( newSz>oldSz ){
  2808   2848               SimulateIOErrorBenign(1);
  2809   2849               rc = winTruncate(id, newSz);
  2810   2850               SimulateIOErrorBenign(0);
  2811   2851             }
  2812   2852           }
         2853  +        OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
  2813   2854           return rc;
  2814   2855         }
         2856  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2815   2857         return SQLITE_OK;
  2816   2858       }
  2817   2859       case SQLITE_FCNTL_PERSIST_WAL: {
  2818   2860         winModeBit(pFile, WINFILE_PERSIST_WAL, (int*)pArg);
         2861  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2819   2862         return SQLITE_OK;
  2820   2863       }
  2821   2864       case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {
  2822   2865         winModeBit(pFile, WINFILE_PSOW, (int*)pArg);
         2866  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2823   2867         return SQLITE_OK;
  2824   2868       }
  2825   2869       case SQLITE_FCNTL_VFSNAME: {
  2826   2870         *(char**)pArg = sqlite3_mprintf("win32");
         2871  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2827   2872         return SQLITE_OK;
  2828   2873       }
  2829   2874       case SQLITE_FCNTL_WIN32_AV_RETRY: {
  2830   2875         int *a = (int*)pArg;
  2831   2876         if( a[0]>0 ){
  2832   2877           win32IoerrRetry = a[0];
  2833   2878         }else{
................................................................................
  2834   2879           a[0] = win32IoerrRetry;
  2835   2880         }
  2836   2881         if( a[1]>0 ){
  2837   2882           win32IoerrRetryDelay = a[1];
  2838   2883         }else{
  2839   2884           a[1] = win32IoerrRetryDelay;
  2840   2885         }
         2886  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2841   2887         return SQLITE_OK;
  2842   2888       }
  2843   2889       case SQLITE_FCNTL_TEMPFILENAME: {
  2844   2890         char *zTFile = sqlite3MallocZero( pFile->pVfs->mxPathname );
  2845   2891         if( zTFile ){
  2846   2892           getTempname(pFile->pVfs->mxPathname, zTFile);
  2847   2893           *(char**)pArg = zTFile;
  2848   2894         }
         2895  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2849   2896         return SQLITE_OK;
  2850   2897       }
  2851   2898   #if SQLITE_MAX_MMAP_SIZE>0
  2852   2899       case SQLITE_FCNTL_MMAP_SIZE: {
  2853   2900         i64 newLimit = *(i64*)pArg;
  2854   2901         if( newLimit>sqlite3GlobalConfig.mxMmap ){
  2855   2902           newLimit = sqlite3GlobalConfig.mxMmap;
  2856   2903         }
  2857   2904         *(i64*)pArg = pFile->mmapSizeMax;
  2858   2905         if( newLimit>=0 ) pFile->mmapSizeMax = newLimit;
         2906  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2859   2907         return SQLITE_OK;
  2860   2908       }
  2861   2909   #endif
  2862   2910     }
         2911  +  OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
  2863   2912     return SQLITE_NOTFOUND;
  2864   2913   }
  2865   2914   
  2866   2915   /*
  2867   2916   ** Return the sector size in bytes of the underlying block device for
  2868   2917   ** the specified file. This is almost always 512 bytes, but may be
  2869   2918   ** larger for some devices.
................................................................................
  3016   3065     int nByte             /* Number of bytes to lock or unlock */
  3017   3066   ){
  3018   3067     int rc = 0;           /* Result code form Lock/UnlockFileEx() */
  3019   3068   
  3020   3069     /* Access to the winShmNode object is serialized by the caller */
  3021   3070     assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );
  3022   3071   
         3072  +  OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
         3073  +           pFile->hFile.h, lockType, ofst, nByte));
         3074  +
  3023   3075     /* Release/Acquire the system-level lock */
  3024   3076     if( lockType==_SHM_UNLCK ){
  3025   3077       rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
  3026   3078     }else{
  3027   3079       /* Initialize the locking parameters */
  3028   3080       DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
  3029   3081       if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
................................................................................
  3033   3085     if( rc!= 0 ){
  3034   3086       rc = SQLITE_OK;
  3035   3087     }else{
  3036   3088       pFile->lastErrno =  osGetLastError();
  3037   3089       rc = SQLITE_BUSY;
  3038   3090     }
  3039   3091   
  3040         -  OSTRACE(("SHM-LOCK %d %s %s 0x%08lx\n", 
  3041         -           pFile->hFile.h,
  3042         -           rc==SQLITE_OK ? "ok" : "failed",
  3043         -           lockType==_SHM_UNLCK ? "UnlockFileEx" : "LockFileEx",
  3044         -           pFile->lastErrno));
         3092  +  OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%d, rc=%s\n", pFile->hFile.h,
         3093  +           (lockType == _SHM_UNLCK) ? "winUnlockFile" : "winLockFile",
         3094  +           pFile->lastErrno, sqlite3ErrName(rc)));
  3045   3095   
  3046   3096     return rc;
  3047   3097   }
  3048   3098   
  3049   3099   /* Forward references to VFS methods */
  3050   3100   static int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);
  3051   3101   static int winDelete(sqlite3_vfs *,const char*,int);
................................................................................
  3057   3107   ** by VFS shared-memory methods.
  3058   3108   */
  3059   3109   static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){
  3060   3110     winShmNode **pp;
  3061   3111     winShmNode *p;
  3062   3112     BOOL bRc;
  3063   3113     assert( winShmMutexHeld() );
         3114  +  OSTRACE(("SHM-PURGE pid=%d, deleteFlag=%d\n",
         3115  +           (int)osGetCurrentProcessId(), deleteFlag));
  3064   3116     pp = &winShmNodeList;
  3065   3117     while( (p = *pp)!=0 ){
  3066   3118       if( p->nRef==0 ){
  3067   3119         int i;
  3068   3120         if( p->mutex ) sqlite3_mutex_free(p->mutex);
  3069   3121         for(i=0; i<p->nRegion; i++){
  3070   3122           bRc = osUnmapViewOfFile(p->aRegion[i].pMap);
  3071         -        OSTRACE(("SHM-PURGE pid-%d unmap region=%d %s\n",
         3123  +        OSTRACE(("SHM-PURGE-UNMAP pid=%d, region=%d, rc=%s\n",
  3072   3124                    (int)osGetCurrentProcessId(), i,
  3073   3125                    bRc ? "ok" : "failed"));
  3074   3126           bRc = osCloseHandle(p->aRegion[i].hMap);
  3075         -        OSTRACE(("SHM-PURGE pid-%d close region=%d %s\n",
         3127  +        OSTRACE(("SHM-PURGE-CLOSE pid=%d, region=%d, rc=%s\n",
  3076   3128                    (int)osGetCurrentProcessId(), i,
  3077   3129                    bRc ? "ok" : "failed"));
  3078   3130         }
  3079   3131         if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){
  3080   3132           SimulateIOErrorBenign(1);
  3081   3133           winClose((sqlite3_file *)&p->hFile);
  3082   3134           SimulateIOErrorBenign(0);
................................................................................
  3349   3401         if( rc==SQLITE_OK ){
  3350   3402           assert( (p->sharedMask & mask)==0 );
  3351   3403           p->exclMask |= mask;
  3352   3404         }
  3353   3405       }
  3354   3406     }
  3355   3407     sqlite3_mutex_leave(pShmNode->mutex);
  3356         -  OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x %s\n",
  3357         -           p->id, (int)osGetCurrentProcessId(), p->sharedMask, p->exclMask,
  3358         -           rc ? "failed" : "ok"));
         3408  +  OSTRACE(("SHM-LOCK pid=%d, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\n",
         3409  +           (int)osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,
         3410  +           sqlite3ErrName(rc)));
  3359   3411     return rc;
  3360   3412   }
  3361   3413   
  3362   3414   /*
  3363   3415   ** Implement a memory barrier or memory fence on shared memory.  
  3364   3416   **
  3365   3417   ** All loads and stores begun before the barrier must complete before
................................................................................
  3472   3524             NULL, PAGE_READWRITE, 0, nByte, NULL
  3473   3525         );
  3474   3526   #elif defined(SQLITE_WIN32_HAS_ANSI)
  3475   3527         hMap = osCreateFileMappingA(pShmNode->hFile.h, 
  3476   3528             NULL, PAGE_READWRITE, 0, nByte, NULL
  3477   3529         );
  3478   3530   #endif
  3479         -      OSTRACE(("SHM-MAP pid-%d create region=%d nbyte=%d %s\n",
         3531  +      OSTRACE(("SHM-MAP-CREATE pid=%d, region=%d, size=%d, rc=%s\n",
  3480   3532                  (int)osGetCurrentProcessId(), pShmNode->nRegion, nByte,
  3481   3533                  hMap ? "ok" : "failed"));
  3482   3534         if( hMap ){
  3483   3535           int iOffset = pShmNode->nRegion*szRegion;
  3484   3536           int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
  3485   3537   #if SQLITE_OS_WINRT
  3486   3538           pMap = osMapViewOfFileFromApp(hMap, FILE_MAP_WRITE | FILE_MAP_READ,
................................................................................
  3487   3539               iOffset - iOffsetShift, szRegion + iOffsetShift
  3488   3540           );
  3489   3541   #else
  3490   3542           pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ,
  3491   3543               0, iOffset - iOffsetShift, szRegion + iOffsetShift
  3492   3544           );
  3493   3545   #endif
  3494         -        OSTRACE(("SHM-MAP pid-%d map region=%d offset=%d size=%d %s\n",
         3546  +        OSTRACE(("SHM-MAP-MAP pid=%d, region=%d, offset=%d, size=%d, rc=%s\n",
  3495   3547                    (int)osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
  3496   3548                    szRegion, pMap ? "ok" : "failed"));
  3497   3549         }
  3498   3550         if( !pMap ){
  3499   3551           pShmNode->lastErrno = osGetLastError();
  3500   3552           rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
  3501   3553                    "winShmMap3", pDbFd->zPath);
................................................................................
  3531   3583   
  3532   3584   /*
  3533   3585   ** Cleans up the mapped region of the specified file, if any.
  3534   3586   */
  3535   3587   #if SQLITE_MAX_MMAP_SIZE>0
  3536   3588   static int winUnmapfile(winFile *pFile){
  3537   3589     assert( pFile!=0 );
         3590  +  OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, hMap=%p, pMapRegion=%p, "
         3591  +           "mmapSize=%lld, mmapSizeActual=%lld, mmapSizeMax=%lld\n",
         3592  +           (int)osGetCurrentProcessId(), pFile, pFile->hMap,
         3593  +           pFile->pMapRegion, pFile->mmapSize, pFile->mmapSizeActual,
         3594  +           pFile->mmapSizeMax));
  3538   3595     if( pFile->pMapRegion ){
  3539   3596       if( !osUnmapViewOfFile(pFile->pMapRegion) ){
  3540   3597         pFile->lastErrno = osGetLastError();
         3598  +      OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, pMapRegion=%p, "
         3599  +               "rc=SQLITE_IOERR_MMAP\n", (int)osGetCurrentProcessId(),
         3600  +               pFile, pFile->pMapRegion));
  3541   3601         return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
  3542   3602                            "winUnmap1", pFile->zPath);
  3543   3603       }
  3544   3604       pFile->pMapRegion = 0;
  3545   3605       pFile->mmapSize = 0;
  3546   3606       pFile->mmapSizeActual = 0;
  3547   3607     }
  3548   3608     if( pFile->hMap!=NULL ){
  3549   3609       if( !osCloseHandle(pFile->hMap) ){
  3550   3610         pFile->lastErrno = osGetLastError();
         3611  +      OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
         3612  +               (int)osGetCurrentProcessId(), pFile, pFile->hMap));
  3551   3613         return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
  3552   3614                            "winUnmap2", pFile->zPath);
  3553   3615       }
  3554   3616       pFile->hMap = NULL;
  3555   3617     }
         3618  +  OSTRACE(("UNMAP-FILE pid=%d, pFile=%p, rc=SQLITE_OK\n",
         3619  +           (int)osGetCurrentProcessId(), pFile));
  3556   3620     return SQLITE_OK;
  3557   3621   }
  3558   3622   
  3559   3623   /*
  3560   3624   ** Memory map or remap the file opened by file-descriptor pFd (if the file
  3561   3625   ** is already mapped, the existing mapping is replaced by the new). Or, if 
  3562   3626   ** there already exists a mapping for this file, and there are still 
................................................................................
  3573   3637   ** code otherwise.
  3574   3638   */
  3575   3639   static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
  3576   3640     sqlite3_int64 nMap = nByte;
  3577   3641     int rc;
  3578   3642   
  3579   3643     assert( nMap>=0 || pFd->nFetchOut==0 );
         3644  +  OSTRACE(("MAP-FILE pid=%d, pFile=%p, size=%lld\n",
         3645  +           (int)osGetCurrentProcessId(), pFd, nByte));
         3646  +
  3580   3647     if( pFd->nFetchOut>0 ) return SQLITE_OK;
  3581   3648   
  3582   3649     if( nMap<0 ){
  3583   3650       rc = winFileSize((sqlite3_file*)pFd, &nMap);
  3584   3651       if( rc ){
         3652  +      OSTRACE(("MAP-FILE pid=%d, pFile=%p, rc=SQLITE_IOERR_FSTAT\n",
         3653  +               (int)osGetCurrentProcessId(), pFd));
  3585   3654         return SQLITE_IOERR_FSTAT;
  3586   3655       }
  3587   3656     }
  3588   3657     if( nMap>pFd->mmapSizeMax ){
  3589   3658       nMap = pFd->mmapSizeMax;
  3590   3659     }
  3591   3660     nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);
................................................................................
  3615   3684                                   (DWORD)(nMap & 0xffffffff), NULL);
  3616   3685   #endif
  3617   3686       if( pFd->hMap==NULL ){
  3618   3687         pFd->lastErrno = osGetLastError();
  3619   3688         rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3620   3689                          "winMapfile", pFd->zPath);
  3621   3690         /* Log the error, but continue normal operation using xRead/xWrite */
         3691  +      OSTRACE(("MAP-FILE-CREATE pid=%d, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
         3692  +               (int)osGetCurrentProcessId(), pFd));
  3622   3693         return SQLITE_OK;
  3623   3694       }
  3624   3695       assert( (nMap % winSysInfo.dwPageSize)==0 );
  3625   3696   #if SQLITE_OS_WINRT
  3626   3697       pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
  3627   3698   #else
  3628   3699       assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
................................................................................
  3630   3701   #endif
  3631   3702       if( pNew==NULL ){
  3632   3703         osCloseHandle(pFd->hMap);
  3633   3704         pFd->hMap = NULL;
  3634   3705         pFd->lastErrno = osGetLastError();
  3635   3706         winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3636   3707                     "winMapfile", pFd->zPath);
         3708  +      OSTRACE(("MAP-FILE-MAP pid=%d, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
         3709  +               (int)osGetCurrentProcessId(), pFd));
  3637   3710         return SQLITE_OK;
  3638   3711       }
  3639   3712       pFd->pMapRegion = pNew;
  3640   3713       pFd->mmapSize = nMap;
  3641   3714       pFd->mmapSizeActual = nMap;
  3642   3715     }
  3643   3716   
         3717  +  OSTRACE(("MAP-FILE pid=%d, pFile=%p, rc=SQLITE_OK\n",
         3718  +           (int)osGetCurrentProcessId(), pFd));
  3644   3719     return SQLITE_OK;
  3645   3720   }
  3646   3721   #endif /* SQLITE_MAX_MMAP_SIZE>0 */
  3647   3722   
  3648   3723   /*
  3649   3724   ** If possible, return a pointer to a mapping of file fd starting at offset
  3650   3725   ** iOff. The mapping must be valid for at least nAmt bytes.
................................................................................
  3659   3734   */
  3660   3735   static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
  3661   3736   #if SQLITE_MAX_MMAP_SIZE>0
  3662   3737     winFile *pFd = (winFile*)fd;   /* The underlying database file */
  3663   3738   #endif
  3664   3739     *pp = 0;
  3665   3740   
         3741  +  OSTRACE(("FETCH pid=%d, pFile=%p, offset=%lld, amount=%d, pp=%p\n",
         3742  +           (int)osGetCurrentProcessId(), fd, iOff, nAmt, pp));
         3743  +
  3666   3744   #if SQLITE_MAX_MMAP_SIZE>0
  3667   3745     if( pFd->mmapSizeMax>0 ){
  3668   3746       if( pFd->pMapRegion==0 ){
  3669   3747         int rc = winMapfile(pFd, -1);
  3670         -      if( rc!=SQLITE_OK ) return rc;
         3748  +      if( rc!=SQLITE_OK ){
         3749  +        OSTRACE(("FETCH pid=%d, pFile=%p, rc=%s\n",
         3750  +                 (int)osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
         3751  +        return rc;
         3752  +      }
  3671   3753       }
  3672   3754       if( pFd->mmapSize >= iOff+nAmt ){
  3673   3755         *pp = &((u8 *)pFd->pMapRegion)[iOff];
  3674   3756         pFd->nFetchOut++;
  3675   3757       }
  3676   3758     }
  3677   3759   #endif
         3760  +
         3761  +  OSTRACE(("FETCH pid=%d, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\n",
         3762  +           (int)osGetCurrentProcessId(), fd, pp, pp ? *pp : 0));
  3678   3763     return SQLITE_OK;
  3679   3764   }
  3680   3765   
  3681   3766   /*
  3682   3767   ** If the third argument is non-NULL, then this function releases a 
  3683   3768   ** reference obtained by an earlier call to unixFetch(). The second
  3684   3769   ** argument passed to this function must be the same as the corresponding
................................................................................
  3696   3781     ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),
  3697   3782     ** then there must be at least one outstanding.  */
  3698   3783     assert( (p==0)==(pFd->nFetchOut==0) );
  3699   3784   
  3700   3785     /* If p!=0, it must match the iOff value. */
  3701   3786     assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );
  3702   3787   
         3788  +  OSTRACE(("UNFETCH pid=%d, pFile=%p, offset=%lld, p=%p\n",
         3789  +           (int)osGetCurrentProcessId(), pFd, iOff, p));
         3790  +
  3703   3791     if( p ){
  3704   3792       pFd->nFetchOut--;
  3705   3793     }else{
  3706   3794       /* FIXME:  If Windows truly always prevents truncating or deleting a
  3707   3795       ** file while a mapping is held, then the following winUnmapfile() call
  3708   3796       ** is unnecessary can can be omitted - potentially improving
  3709   3797       ** performance.  */
  3710   3798       winUnmapfile(pFd);
  3711   3799     }
  3712   3800   
  3713   3801     assert( pFd->nFetchOut>=0 );
  3714   3802   #endif
         3803  +
         3804  +  OSTRACE(("UNFETCH pid=%d, pFile=%p, rc=SQLITE_OK\n",
         3805  +           (int)osGetCurrentProcessId(), fd));
  3715   3806     return SQLITE_OK;
  3716   3807   }
  3717   3808   
  3718   3809   /*
  3719   3810   ** Here ends the implementation of all sqlite3_file methods.
  3720   3811   **
  3721   3812   ********************** End sqlite3_file Methods *******************************
................................................................................
  3804   3895       WCHAR zWidePath[MAX_PATH];
  3805   3896       osGetTempPathW(MAX_PATH-30, zWidePath);
  3806   3897       zMulti = unicodeToUtf8(zWidePath);
  3807   3898       if( zMulti ){
  3808   3899         sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
  3809   3900         sqlite3_free(zMulti);
  3810   3901       }else{
         3902  +      OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
  3811   3903         return SQLITE_IOERR_NOMEM;
  3812   3904       }
  3813   3905     }
  3814   3906   #ifdef SQLITE_WIN32_HAS_ANSI
  3815   3907     else{
  3816   3908       char *zUtf8;
  3817   3909       char zMbcsPath[MAX_PATH];
  3818   3910       osGetTempPathA(MAX_PATH-30, zMbcsPath);
  3819   3911       zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
  3820   3912       if( zUtf8 ){
  3821   3913         sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
  3822   3914         sqlite3_free(zUtf8);
  3823   3915       }else{
         3916  +      OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
  3824   3917         return SQLITE_IOERR_NOMEM;
  3825   3918       }
  3826   3919     }
  3827   3920   #endif
  3828   3921   #endif
  3829   3922   
  3830   3923     /* Check that the output buffer is large enough for the temporary file 
  3831   3924     ** name. If it is not, return SQLITE_ERROR.
  3832   3925     */
  3833   3926     nTempPath = sqlite3Strlen30(zTempPath);
  3834   3927   
  3835   3928     if( (nTempPath + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){
         3929  +    OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
  3836   3930       return SQLITE_ERROR;
  3837   3931     }
  3838   3932   
  3839   3933     for(i=nTempPath; i>0 && zTempPath[i-1]=='\\'; i--){}
  3840   3934     zTempPath[i] = 0;
  3841   3935   
  3842   3936     sqlite3_snprintf(nBuf-18, zBuf, (nTempPath > 0) ?
................................................................................
  3846   3940     sqlite3_randomness(15, &zBuf[j]);
  3847   3941     for(i=0; i<15; i++, j++){
  3848   3942       zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
  3849   3943     }
  3850   3944     zBuf[j] = 0;
  3851   3945     zBuf[j+1] = 0;
  3852   3946   
  3853         -  OSTRACE(("TEMP FILENAME: %s\n", zBuf));
  3854         -  return SQLITE_OK; 
         3947  +  OSTRACE(("TEMP-FILENAME name=%s, rc=SQLITE_OK\n", zBuf));
         3948  +  return SQLITE_OK;
  3855   3949   }
  3856   3950   
  3857   3951   /*
  3858   3952   ** Return TRUE if the named file is really a directory.  Return false if
  3859   3953   ** it is something other than a directory, or if there is any kind of memory
  3860   3954   ** allocation failure.
  3861   3955   */
................................................................................
  3926   4020   #ifndef NDEBUG
  3927   4021     int isOpenJournal = (isCreate && (
  3928   4022           eType==SQLITE_OPEN_MASTER_JOURNAL 
  3929   4023        || eType==SQLITE_OPEN_MAIN_JOURNAL 
  3930   4024        || eType==SQLITE_OPEN_WAL
  3931   4025     ));
  3932   4026   #endif
         4027  +
         4028  +  OSTRACE(("OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\n",
         4029  +           zUtf8Name, id, flags, pOutFlags));
  3933   4030   
  3934   4031     /* Check the following statements are true: 
  3935   4032     **
  3936   4033     **   (a) Exactly one of the READWRITE and READONLY flags must be set, and 
  3937   4034     **   (b) if CREATE is set, then READWRITE must also be set, and
  3938   4035     **   (c) if EXCLUSIVE is set, then CREATE must also be set.
  3939   4036     **   (d) if DELETEONCLOSE is set, then CREATE must also be set.
................................................................................
  3972   4069     ** temporary file name to use 
  3973   4070     */
  3974   4071     if( !zUtf8Name ){
  3975   4072       assert(isDelete && !isOpenJournal);
  3976   4073       memset(zTmpname, 0, MAX_PATH+2);
  3977   4074       rc = getTempname(MAX_PATH+2, zTmpname);
  3978   4075       if( rc!=SQLITE_OK ){
         4076  +      OSTRACE(("OPEN name=%s, rc=%s",
         4077  +               zUtf8Name, sqlite3ErrName(rc)));
  3979   4078         return rc;
  3980   4079       }
  3981   4080       zUtf8Name = zTmpname;
  3982   4081     }
  3983   4082   
  3984   4083     /* Database filenames are double-zero terminated if they are not
  3985   4084     ** URIs with parameters.  Hence, they can always be passed into
................................................................................
  3987   4086     */
  3988   4087     assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||
  3989   4088           zUtf8Name[strlen(zUtf8Name)+1]==0 );
  3990   4089   
  3991   4090     /* Convert the filename to the system encoding. */
  3992   4091     zConverted = convertUtf8Filename(zUtf8Name);
  3993   4092     if( zConverted==0 ){
         4093  +    OSTRACE(("OPEN name=%s, rc=SQLITE_IOERR_NOMEM", zUtf8Name));
  3994   4094       return SQLITE_IOERR_NOMEM;
  3995   4095     }
  3996   4096   
  3997   4097     if( winIsDir(zConverted) ){
  3998   4098       sqlite3_free(zConverted);
         4099  +    OSTRACE(("OPEN name=%s, rc=SQLITE_CANTOPEN_ISDIR", zUtf8Name));
  3999   4100       return SQLITE_CANTOPEN_ISDIR;
  4000   4101     }
  4001   4102   
  4002   4103     if( isReadWrite ){
  4003   4104       dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
  4004   4105     }else{
  4005   4106       dwDesiredAccess = GENERIC_READ;
................................................................................
  4082   4183                                 retryIoerr(&cnt, &lastErrno) ){
  4083   4184                  /* Noop */
  4084   4185       }
  4085   4186     }
  4086   4187   #endif
  4087   4188     logIoerr(cnt);
  4088   4189   
  4089         -  OSTRACE(("OPEN %d %s 0x%lx %s\n", 
  4090         -           h, zName, dwDesiredAccess, 
  4091         -           h==INVALID_HANDLE_VALUE ? "failed" : "ok"));
         4190  +  OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
         4191  +           dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
  4092   4192   
  4093   4193     if( h==INVALID_HANDLE_VALUE ){
  4094   4194       pFile->lastErrno = lastErrno;
  4095   4195       winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
  4096   4196       sqlite3_free(zConverted);
  4097   4197       if( isReadWrite && !isExclusive ){
  4098   4198         return winOpen(pVfs, zName, id, 
................................................................................
  4114   4214   
  4115   4215   #if SQLITE_OS_WINCE
  4116   4216     if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
  4117   4217          && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
  4118   4218     ){
  4119   4219       osCloseHandle(h);
  4120   4220       sqlite3_free(zConverted);
         4221  +    OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
  4121   4222       return rc;
  4122   4223     }
  4123   4224     if( isTemp ){
  4124   4225       pFile->zDeleteOnClose = zConverted;
  4125   4226     }else
  4126   4227   #endif
  4127   4228     {
................................................................................
  4173   4274     DWORD attr;
  4174   4275     DWORD lastErrno;
  4175   4276     void *zConverted;
  4176   4277     UNUSED_PARAMETER(pVfs);
  4177   4278     UNUSED_PARAMETER(syncDir);
  4178   4279   
  4179   4280     SimulateIOError(return SQLITE_IOERR_DELETE);
         4281  +  OSTRACE(("DELETE name=%s, syncDir=%d\n", zFilename, syncDir));
         4282  +
  4180   4283     zConverted = convertUtf8Filename(zFilename);
  4181   4284     if( zConverted==0 ){
  4182   4285       return SQLITE_IOERR_NOMEM;
  4183   4286     }
  4184   4287     if( isNT() ){
  4185   4288       do {
  4186   4289   #if SQLITE_OS_WINRT
................................................................................
  4258   4361     if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
  4259   4362       rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
  4260   4363                "winDelete", zFilename);
  4261   4364     }else{
  4262   4365       logIoerr(cnt);
  4263   4366     }
  4264   4367     sqlite3_free(zConverted);
  4265         -  OSTRACE(("DELETE \"%s\" %s\n", zFilename, (rc ? "failed" : "ok" )));
         4368  +  OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
  4266   4369     return rc;
  4267   4370   }
  4268   4371   
  4269   4372   /*
  4270   4373   ** Check the existence and status of a file.
  4271   4374   */
  4272   4375   static int winAccess(
................................................................................
  4278   4381     DWORD attr;
  4279   4382     int rc = 0;
  4280   4383     DWORD lastErrno;
  4281   4384     void *zConverted;
  4282   4385     UNUSED_PARAMETER(pVfs);
  4283   4386   
  4284   4387     SimulateIOError( return SQLITE_IOERR_ACCESS; );
         4388  +  OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n",
         4389  +           zFilename, flags, pResOut));
         4390  +
  4285   4391     zConverted = convertUtf8Filename(zFilename);
  4286   4392     if( zConverted==0 ){
         4393  +    OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
  4287   4394       return SQLITE_IOERR_NOMEM;
  4288   4395     }
  4289   4396     if( isNT() ){
  4290   4397       int cnt = 0;
  4291   4398       WIN32_FILE_ATTRIBUTE_DATA sAttrData;
  4292   4399       memset(&sAttrData, 0, sizeof(sAttrData));
  4293   4400       while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
................................................................................
  4330   4437         rc = attr!=INVALID_FILE_ATTRIBUTES &&
  4331   4438                (attr & FILE_ATTRIBUTE_READONLY)==0;
  4332   4439         break;
  4333   4440       default:
  4334   4441         assert(!"Invalid flags argument");
  4335   4442     }
  4336   4443     *pResOut = rc;
         4444  +  OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
         4445  +           zFilename, pResOut, *pResOut));
  4337   4446     return SQLITE_OK;
  4338   4447   }
  4339   4448   
  4340   4449   
  4341   4450   /*
  4342   4451   ** Returns non-zero if the specified path name should be used verbatim.  If
  4343   4452   ** non-zero is returned from this function, the calling function must simply

Changes to src/sqliteInt.h.

  3088   3088   int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
  3089   3089   char sqlite3ExprAffinity(Expr *pExpr);
  3090   3090   int sqlite3Atoi64(const char*, i64*, int, u8);
  3091   3091   void sqlite3Error(sqlite3*, int, const char*,...);
  3092   3092   void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
  3093   3093   u8 sqlite3HexToInt(int h);
  3094   3094   int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
         3095  +const char *sqlite3ErrName(int);
  3095   3096   const char *sqlite3ErrStr(int);
  3096   3097   int sqlite3ReadSchema(Parse *pParse);
  3097   3098   CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
  3098   3099   CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
  3099   3100   CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
  3100   3101   Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, Token*);
  3101   3102   Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);