/ Check-in [c6f174a0]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Improve the consistency of the diagnostic messages on Windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | cygwinTempPath
Files: files | file ages | folders
SHA1: c6f174a0cb27fe79740fffc7ce51081ec52a5dbd
User & Date: mistachkin 2013-08-31 02:48:56
Context
2013-08-31
05:13
Fix harmless MSVC compiler warning with MEMDEBUG defined. check-in: b48cfd2d user: mistachkin tags: cygwinTempPath
02:48
Improve the consistency of the diagnostic messages on Windows. check-in: c6f174a0 user: mistachkin tags: cygwinTempPath
2013-08-30
21:52
Add support for Cygwin when handling temporary file names. Improve error codes and diagnostic messages for temporary file name handling on Windows. Rename winConvertUtf8Filename to winConvertFromUtf8Filename. Improve placement and comments for forward function declarations. check-in: a411df72 user: mistachkin tags: cygwinTempPath
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  1757   1757       if (*zTok == '\\') *zTok = '_';
  1758   1758     }
  1759   1759   
  1760   1760     /* Create/open the named mutex */
  1761   1761     pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);
  1762   1762     if (!pFile->hMutex){
  1763   1763       pFile->lastErrno = osGetLastError();
  1764         -    winLogError(SQLITE_IOERR, pFile->lastErrno,
  1765         -                "winceCreateLock1", zFilename);
  1766   1764       sqlite3_free(zName);
  1767         -    return SQLITE_IOERR;
         1765  +    return winLogError(SQLITE_IOERR, pFile->lastErrno,
         1766  +                       "winceCreateLock1", zFilename);
  1768   1767     }
  1769   1768   
  1770   1769     /* Acquire the mutex before continuing */
  1771   1770     winceMutexAcquire(pFile->hMutex);
  1772   1771     
  1773   1772     /* Since the names of named mutexes, semaphores, file mappings etc are 
  1774   1773     ** case-sensitive, take advantage of that by uppercasing the mutex name
................................................................................
  2096   2095     */
  2097   2096     dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
  2098   2097   
  2099   2098     if( (dwRet==INVALID_SET_FILE_POINTER
  2100   2099         && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
  2101   2100       pFile->lastErrno = lastErrno;
  2102   2101       winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
  2103         -             "winSeekFile", pFile->zPath);
         2102  +                "winSeekFile", pFile->zPath);
  2104   2103       OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
  2105   2104       return 1;
  2106   2105     }
  2107   2106   
  2108   2107     OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
  2109   2108     return 0;
  2110   2109   #else
................................................................................
  2117   2116   
  2118   2117     x.QuadPart = iOffset;
  2119   2118     bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);
  2120   2119   
  2121   2120     if(!bRet){
  2122   2121       pFile->lastErrno = osGetLastError();
  2123   2122       winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
  2124         -             "winSeekFile", pFile->zPath);
         2123  +                "winSeekFile", pFile->zPath);
  2125   2124       OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
  2126   2125       return 1;
  2127   2126     }
  2128   2127   
  2129   2128     OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
  2130   2129     return 0;
  2131   2130   #endif
................................................................................
  2250   2249            osGetLastError()!=ERROR_HANDLE_EOF ){
  2251   2250   #endif
  2252   2251       DWORD lastErrno;
  2253   2252       if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
  2254   2253       pFile->lastErrno = lastErrno;
  2255   2254       OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
  2256   2255       return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
  2257         -             "winRead", pFile->zPath);
         2256  +                       "winRead", pFile->zPath);
  2258   2257     }
  2259   2258     winLogIoerr(nRetry);
  2260   2259     if( nRead<(DWORD)amt ){
  2261   2260       /* Unread parts of the buffer must be zero-filled */
  2262   2261       memset(&((char*)pBuf)[nRead], 0, amt-nRead);
  2263   2262       OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
  2264   2263       return SQLITE_IOERR_SHORT_READ;
................................................................................
  2356   2355       }
  2357   2356     }
  2358   2357   
  2359   2358     if( rc ){
  2360   2359       if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
  2361   2360          || ( pFile->lastErrno==ERROR_DISK_FULL )){
  2362   2361         OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
  2363         -      return SQLITE_FULL;
         2362  +      return winLogError(SQLITE_FULL, pFile->lastErrno,
         2363  +                         "winWrite1", pFile->zPath);
  2364   2364       }
  2365   2365       OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
  2366   2366       return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
  2367         -             "winWrite", pFile->zPath);
         2367  +                       "winWrite2", pFile->zPath);
  2368   2368     }else{
  2369   2369       winLogIoerr(nRetry);
  2370   2370     }
  2371   2371     OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
  2372   2372     return SQLITE_OK;
  2373   2373   }
  2374   2374   
................................................................................
  2484   2484     if( rc ){
  2485   2485       OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
  2486   2486       return SQLITE_OK;
  2487   2487     }else{
  2488   2488       pFile->lastErrno = osGetLastError();
  2489   2489       OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
  2490   2490       return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
  2491         -             "winSync", pFile->zPath);
         2491  +                       "winSync", pFile->zPath);
  2492   2492     }
  2493   2493   #endif
  2494   2494   }
  2495   2495   
  2496   2496   /*
  2497   2497   ** Determine the current size of a file in bytes
  2498   2498   */
................................................................................
  2525   2525   
  2526   2526       lowerBits = osGetFileSize(pFile->h, &upperBits);
  2527   2527       *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
  2528   2528       if(   (lowerBits == INVALID_FILE_SIZE)
  2529   2529          && ((lastErrno = osGetLastError())!=NO_ERROR) ){
  2530   2530         pFile->lastErrno = lastErrno;
  2531   2531         rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
  2532         -             "winFileSize", pFile->zPath);
         2532  +                       "winFileSize", pFile->zPath);
  2533   2533       }
  2534   2534     }
  2535   2535   #endif
  2536   2536     OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
  2537   2537              pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
  2538   2538     return rc;
  2539   2539   }
................................................................................
  2620   2620     else{
  2621   2621       res = winUnlockFile(&pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
  2622   2622     }
  2623   2623   #endif
  2624   2624     if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){
  2625   2625       pFile->lastErrno = lastErrno;
  2626   2626       winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,
  2627         -             "winUnlockReadLock", pFile->zPath);
         2627  +                "winUnlockReadLock", pFile->zPath);
  2628   2628     }
  2629   2629     OSTRACE(("READ-UNLOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res)));
  2630   2630     return res;
  2631   2631   }
  2632   2632   
  2633   2633   /*
  2634   2634   ** Lock the file with the lock specified by parameter locktype - one
................................................................................
  2833   2833     type = pFile->locktype;
  2834   2834     if( type>=EXCLUSIVE_LOCK ){
  2835   2835       winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
  2836   2836       if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){
  2837   2837         /* This should never happen.  We should always be able to
  2838   2838         ** reacquire the read lock */
  2839   2839         rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),
  2840         -               "winUnlock", pFile->zPath);
         2840  +                       "winUnlock", pFile->zPath);
  2841   2841       }
  2842   2842     }
  2843   2843     if( type>=RESERVED_LOCK ){
  2844   2844       winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
  2845   2845     }
  2846   2846     if( locktype==NO_LOCK && type>=SHARED_LOCK ){
  2847   2847       winUnlockReadLock(pFile);
................................................................................
  2948   2948       }
  2949   2949       case SQLITE_FCNTL_TEMPFILENAME: {
  2950   2950         char *zTFile = 0;
  2951   2951         int rc = winGetTempname(pFile->pVfs, &zTFile);
  2952   2952         if( rc==SQLITE_OK ){
  2953   2953           *(char**)pArg = zTFile;
  2954   2954         }
  2955         -      OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
         2955  +      OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
  2956   2956         return rc;
  2957   2957       }
  2958   2958   #if SQLITE_MAX_MMAP_SIZE>0
  2959   2959       case SQLITE_FCNTL_MMAP_SIZE: {
  2960   2960         i64 newLimit = *(i64*)pArg;
  2961   2961         int rc = SQLITE_OK;
  2962   2962         if( newLimit>sqlite3GlobalConfig.mxMmap ){
................................................................................
  2966   2966         if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
  2967   2967           pFile->mmapSizeMax = newLimit;
  2968   2968           if( pFile->mmapSize>0 ){
  2969   2969             (void)winUnmapfile(pFile);
  2970   2970             rc = winMapfile(pFile, -1);
  2971   2971           }
  2972   2972         }
  2973         -      OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
         2973  +      OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
  2974   2974         return rc;
  2975   2975       }
  2976   2976   #endif
  2977   2977     }
  2978   2978     OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
  2979   2979     return SQLITE_NOTFOUND;
  2980   2980   }
................................................................................
  3282   3282       /* Check to see if another process is holding the dead-man switch.
  3283   3283       ** If not, truncate the file to zero length. 
  3284   3284       */
  3285   3285       if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
  3286   3286         rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
  3287   3287         if( rc!=SQLITE_OK ){
  3288   3288           rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
  3289         -                 "winOpenShm", pDbFd->zPath);
         3289  +                         "winOpenShm", pDbFd->zPath);
  3290   3290         }
  3291   3291       }
  3292   3292       if( rc==SQLITE_OK ){
  3293   3293         winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
  3294   3294         rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
  3295   3295       }
  3296   3296       if( rc ) goto shm_open_err;
................................................................................
  3542   3542       /* The requested region is not mapped into this processes address space.
  3543   3543       ** Check to see if it has been allocated (i.e. if the wal-index file is
  3544   3544       ** large enough to contain the requested region).
  3545   3545       */
  3546   3546       rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
  3547   3547       if( rc!=SQLITE_OK ){
  3548   3548         rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
  3549         -               "winShmMap1", pDbFd->zPath);
         3549  +                       "winShmMap1", pDbFd->zPath);
  3550   3550         goto shmpage_out;
  3551   3551       }
  3552   3552   
  3553   3553       if( sz<nByte ){
  3554   3554         /* The requested memory region does not exist. If isWrite is set to
  3555   3555         ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned.
  3556   3556         **
................................................................................
  3557   3557         ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate
  3558   3558         ** the requested memory region.
  3559   3559         */
  3560   3560         if( !isWrite ) goto shmpage_out;
  3561   3561         rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
  3562   3562         if( rc!=SQLITE_OK ){
  3563   3563           rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
  3564         -                 "winShmMap2", pDbFd->zPath);
         3564  +                         "winShmMap2", pDbFd->zPath);
  3565   3565           goto shmpage_out;
  3566   3566         }
  3567   3567       }
  3568   3568   
  3569   3569       /* Map the requested memory region into this processes address space. */
  3570   3570       apNew = (struct ShmRegion *)sqlite3_realloc(
  3571   3571           pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])
................................................................................
  3611   3611           OSTRACE(("SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\n",
  3612   3612                    osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
  3613   3613                    szRegion, pMap ? "ok" : "failed"));
  3614   3614         }
  3615   3615         if( !pMap ){
  3616   3616           pShmNode->lastErrno = osGetLastError();
  3617   3617           rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
  3618         -                 "winShmMap3", pDbFd->zPath);
         3618  +                         "winShmMap3", pDbFd->zPath);
  3619   3619           if( hMap ) osCloseHandle(hMap);
  3620   3620           goto shmpage_out;
  3621   3621         }
  3622   3622   
  3623   3623         pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;
  3624   3624         pShmNode->aRegion[pShmNode->nRegion].hMap = hMap;
  3625   3625         pShmNode->nRegion++;
................................................................................
  3659   3659     if( pFile->pMapRegion ){
  3660   3660       if( !osUnmapViewOfFile(pFile->pMapRegion) ){
  3661   3661         pFile->lastErrno = osGetLastError();
  3662   3662         OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, "
  3663   3663                  "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile,
  3664   3664                  pFile->pMapRegion));
  3665   3665         return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
  3666         -                         "winUnmap1", pFile->zPath);
         3666  +                         "winUnmapfile1", pFile->zPath);
  3667   3667       }
  3668   3668       pFile->pMapRegion = 0;
  3669   3669       pFile->mmapSize = 0;
  3670   3670       pFile->mmapSizeActual = 0;
  3671   3671     }
  3672   3672     if( pFile->hMap!=NULL ){
  3673   3673       if( !osCloseHandle(pFile->hMap) ){
  3674   3674         pFile->lastErrno = osGetLastError();
  3675   3675         OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
  3676   3676                  osGetCurrentProcessId(), pFile, pFile->hMap));
  3677   3677         return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
  3678         -                         "winUnmap2", pFile->zPath);
         3678  +                         "winUnmapfile2", pFile->zPath);
  3679   3679       }
  3680   3680       pFile->hMap = NULL;
  3681   3681     }
  3682   3682     OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
  3683   3683              osGetCurrentProcessId(), pFile));
  3684   3684     return SQLITE_OK;
  3685   3685   }
................................................................................
  3746   3746       pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,
  3747   3747                                   (DWORD)((nMap>>32) & 0xffffffff),
  3748   3748                                   (DWORD)(nMap & 0xffffffff), NULL);
  3749   3749   #endif
  3750   3750       if( pFd->hMap==NULL ){
  3751   3751         pFd->lastErrno = osGetLastError();
  3752   3752         rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3753         -                       "winMapfile", pFd->zPath);
         3753  +                       "winMapfile1", pFd->zPath);
  3754   3754         /* Log the error, but continue normal operation using xRead/xWrite */
  3755         -      OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
  3756         -               osGetCurrentProcessId(), pFd));
         3755  +      OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\n",
         3756  +               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
  3757   3757         return SQLITE_OK;
  3758   3758       }
  3759   3759       assert( (nMap % winSysInfo.dwPageSize)==0 );
  3760   3760       assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
  3761   3761   #if SQLITE_OS_WINRT
  3762   3762       pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
  3763   3763   #else
  3764   3764       pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
  3765   3765   #endif
  3766   3766       if( pNew==NULL ){
  3767   3767         osCloseHandle(pFd->hMap);
  3768   3768         pFd->hMap = NULL;
  3769   3769         pFd->lastErrno = osGetLastError();
  3770         -      winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
  3771         -                  "winMapfile", pFd->zPath);
  3772         -      OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
  3773         -               osGetCurrentProcessId(), pFd));
         3770  +      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
         3771  +                       "winMapfile2", pFd->zPath);
         3772  +      /* Log the error, but continue normal operation using xRead/xWrite */
         3773  +      OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\n",
         3774  +               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
  3774   3775         return SQLITE_OK;
  3775   3776       }
  3776   3777       pFd->pMapRegion = pNew;
  3777   3778       pFd->mmapSize = nMap;
  3778   3779       pFd->mmapSizeActual = nMap;
  3779   3780     }
  3780   3781   
................................................................................
  4046   4047             OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
  4047   4048             return SQLITE_IOERR_NOMEM;
  4048   4049           }
  4049   4050           if( cygwin_conv_path(
  4050   4051                   osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
  4051   4052                   zConverted, nBuf+1)<0 ){
  4052   4053             sqlite3_free(zConverted);
  4053         -          winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
  4054         -                      "cygwin_conv_path", zDir);
  4055   4054             OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
  4056         -          return SQLITE_IOERR_CONVPATH;
         4055  +          return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
         4056  +                             "winGetTempname1", zDir);
  4057   4057           }
  4058   4058           if( winIsDir(zConverted) ){
  4059   4059             /* At this point, we know the candidate directory exists and should
  4060   4060             ** be used.  However, we may need to convert the string containing
  4061   4061             ** its name into UTF-8 (i.e. if it is UTF-16 right now).
  4062   4062             */
  4063   4063             if( osIsNT() ){
................................................................................
  4090   4090         sqlite3_free(zBuf);
  4091   4091         OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
  4092   4092         return SQLITE_IOERR_NOMEM;
  4093   4093       }
  4094   4094       if( osGetTempPathW(nBuf, zWidePath)==0 ){
  4095   4095         sqlite3_free(zWidePath);
  4096   4096         sqlite3_free(zBuf);
  4097         -      winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
  4098         -                  "winGetTempname", 0);
  4099   4097         OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
  4100         -      return SQLITE_IOERR_GETTEMPPATH;
         4098  +      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
         4099  +                         "winGetTempname1", 0);
  4101   4100       }
  4102   4101       zMulti = winUnicodeToUtf8(zWidePath);
  4103   4102       if( zMulti ){
  4104   4103         sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti);
  4105   4104         sqlite3_free(zMulti);
  4106   4105         sqlite3_free(zWidePath);
  4107   4106       }else{
................................................................................
  4118   4117       if( !zMbcsPath ){
  4119   4118         sqlite3_free(zBuf);
  4120   4119         OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
  4121   4120         return SQLITE_IOERR_NOMEM;
  4122   4121       }
  4123   4122       if( osGetTempPathA(nBuf, zMbcsPath)==0 ){
  4124   4123         sqlite3_free(zBuf);
  4125         -      winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
  4126         -                  "winGetTempname", 0);
  4127   4124         OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
  4128         -      return SQLITE_IOERR_GETTEMPPATH;
         4125  +      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
         4126  +                         "winGetTempname2", 0);
  4129   4127       }
  4130   4128       zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
  4131   4129       if( zUtf8 ){
  4132   4130         sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
  4133   4131         sqlite3_free(zUtf8);
  4134   4132       }else{
  4135   4133         sqlite3_free(zBuf);
................................................................................
  4144   4142     ** name. If it is not, return SQLITE_ERROR.
  4145   4143     */
  4146   4144     nLen = sqlite3Strlen30(zBuf);
  4147   4145   
  4148   4146     if( (nLen + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){
  4149   4147       sqlite3_free(zBuf);
  4150   4148       OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
  4151         -    return SQLITE_ERROR;
         4149  +    return winLogError(SQLITE_ERROR, 0, "winGetTempname3", 0);
  4152   4150     }
  4153   4151   
  4154   4152     sqlite3_snprintf(nBuf-18-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);
  4155   4153   
  4156   4154     j = sqlite3Strlen30(zBuf);
  4157   4155     sqlite3_randomness(15, &zBuf[j]);
  4158   4156     for(i=0; i<15; i++, j++){
................................................................................
  4581   4579           rc = SQLITE_ERROR; /* No more retries. */
  4582   4580           break;
  4583   4581         }
  4584   4582       } while(1);
  4585   4583     }
  4586   4584   #endif
  4587   4585     if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
  4588         -    rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
  4589         -             "winDelete", zFilename);
         4586  +    rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
  4590   4587     }else{
  4591   4588       winLogIoerr(cnt);
  4592   4589     }
  4593   4590     sqlite3_free(zConverted);
  4594   4591     OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
  4595   4592     return rc;
  4596   4593   }
................................................................................
  4636   4633           attr = INVALID_FILE_ATTRIBUTES;
  4637   4634         }else{
  4638   4635           attr = sAttrData.dwFileAttributes;
  4639   4636         }
  4640   4637       }else{
  4641   4638         winLogIoerr(cnt);
  4642   4639         if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
  4643         -        winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename);
  4644   4640           sqlite3_free(zConverted);
  4645         -        return SQLITE_IOERR_ACCESS;
         4641  +        return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
         4642  +                           zFilename);
  4646   4643         }else{
  4647   4644           attr = INVALID_FILE_ATTRIBUTES;
  4648   4645         }
  4649   4646       }
  4650   4647     }
  4651   4648   #ifdef SQLITE_WIN32_HAS_ANSI
  4652   4649     else{
................................................................................
  4740   4737       ** NOTE: We are dealing with a relative path name and the data
  4741   4738       **       directory has been set.  Therefore, use it as the basis
  4742   4739       **       for converting the relative path name to an absolute
  4743   4740       **       one by prepending the data directory and a slash.
  4744   4741       */
  4745   4742       char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
  4746   4743       if( !zOut ){
  4747         -      winLogError(SQLITE_IOERR_NOMEM, 0, "winFullPathname", zRelative);
  4748   4744         return SQLITE_IOERR_NOMEM;
  4749   4745       }
  4750   4746       if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
  4751   4747                            pVfs->mxPathname+1)<0 ){
  4752         -      winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname",
  4753         -                  zRelative);
  4754   4748         sqlite3_free(zOut);
  4755         -      return SQLITE_CANTOPEN_CONVPATH;
         4749  +      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
         4750  +                         "winFullPathname1", zRelative);
  4756   4751       }
  4757   4752       sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
  4758   4753                        sqlite3_data_directory, winGetDirDep(), zOut);
  4759   4754       sqlite3_free(zOut);
  4760   4755     }else{
  4761   4756       if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
  4762         -      winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname",
  4763         -                  zRelative);
  4764         -      return SQLITE_CANTOPEN_CONVPATH;
         4757  +      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
         4758  +                         "winFullPathname2", zRelative);
  4765   4759       }
  4766   4760     }
  4767   4761     return SQLITE_OK;
  4768   4762   #endif
  4769   4763   
  4770   4764   #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
  4771   4765     SimulateIOError( return SQLITE_ERROR );
................................................................................
  4790   4784     DWORD nByte;
  4791   4785     void *zConverted;
  4792   4786     char *zOut;
  4793   4787   
  4794   4788     /* If this path name begins with "/X:", where "X" is any alphabetic
  4795   4789     ** character, discard the initial "/" from the pathname.
  4796   4790     */
  4797         -  if( zRelative[0]=='/' && sqlite3Isalpha(zRelative[1]) && zRelative[2]==':' ){
         4791  +  if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
  4798   4792       zRelative++;
  4799   4793     }
  4800   4794   
  4801   4795     /* It's odd to simulate an io-error here, but really this is just
  4802   4796     ** using the io-error infrastructure to test that SQLite handles this
  4803   4797     ** function failing. This function could fail if, for example, the
  4804   4798     ** current working directory has been unlinked.
................................................................................
  4819   4813     if( zConverted==0 ){
  4820   4814       return SQLITE_IOERR_NOMEM;
  4821   4815     }
  4822   4816     if( osIsNT() ){
  4823   4817       LPWSTR zTemp;
  4824   4818       nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);
  4825   4819       if( nByte==0 ){
  4826         -      winLogError(SQLITE_ERROR, osGetLastError(),
  4827         -                  "GetFullPathNameW1", zConverted);
  4828   4820         sqlite3_free(zConverted);
  4829         -      return SQLITE_CANTOPEN_FULLPATH;
         4821  +      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
         4822  +                         "winFullPathname1", zRelative);
  4830   4823       }
  4831   4824       nByte += 3;
  4832   4825       zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
  4833   4826       if( zTemp==0 ){
  4834   4827         sqlite3_free(zConverted);
  4835   4828         return SQLITE_IOERR_NOMEM;
  4836   4829       }
  4837   4830       nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);
  4838   4831       if( nByte==0 ){
  4839         -      winLogError(SQLITE_ERROR, osGetLastError(),
  4840         -                  "GetFullPathNameW2", zConverted);
  4841   4832         sqlite3_free(zConverted);
  4842   4833         sqlite3_free(zTemp);
  4843         -      return SQLITE_CANTOPEN_FULLPATH;
         4834  +      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
         4835  +                         "winFullPathname2", zRelative);
  4844   4836       }
  4845   4837       sqlite3_free(zConverted);
  4846   4838       zOut = winUnicodeToUtf8(zTemp);
  4847   4839       sqlite3_free(zTemp);
  4848   4840     }
  4849   4841   #ifdef SQLITE_WIN32_HAS_ANSI
  4850   4842     else{
  4851   4843       char *zTemp;
  4852   4844       nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);
  4853   4845       if( nByte==0 ){
  4854         -      winLogError(SQLITE_ERROR, osGetLastError(),
  4855         -                  "GetFullPathNameA1", zConverted);
  4856   4846         sqlite3_free(zConverted);
  4857         -      return SQLITE_CANTOPEN_FULLPATH;
         4847  +      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
         4848  +                         "winFullPathname3", zRelative);
  4858   4849       }
  4859   4850       nByte += 3;
  4860   4851       zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
  4861   4852       if( zTemp==0 ){
  4862   4853         sqlite3_free(zConverted);
  4863   4854         return SQLITE_IOERR_NOMEM;
  4864   4855       }
  4865   4856       nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
  4866   4857       if( nByte==0 ){
  4867         -      winLogError(SQLITE_ERROR, osGetLastError(),
  4868         -                  "GetFullPathNameA2", zConverted);
  4869   4858         sqlite3_free(zConverted);
  4870   4859         sqlite3_free(zTemp);
  4871         -      return SQLITE_CANTOPEN_FULLPATH;
         4860  +      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
         4861  +                         "winFullPathname4", zRelative);
  4872   4862       }
  4873   4863       sqlite3_free(zConverted);
  4874   4864       zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
  4875   4865       sqlite3_free(zTemp);
  4876   4866     }
  4877   4867   #endif
  4878   4868     if( zOut ){