/ Check-in [d22c8142]
Login

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

Overview
Comment:Experimental changes to use GetFileInformationByHandle instead of GetFileSize in the Win32 VFS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | filesize-debug
Files: files | file ages | folders
SHA1:d22c8142972dec13435f2023fbaf51dd012b5896
User & Date: mistachkin 2014-06-17 18:43:42
Context
2014-06-17
18:43
Experimental changes to use GetFileInformationByHandle instead of GetFileSize in the Win32 VFS. Closed-Leaf check-in: d22c8142 user: mistachkin tags: filesize-debug
2014-04-24
13:20
Add sqlite3_log() diagnostic messages for a specific type of corruption where the file size is reported to be too small relative to the size in the header. This branch is intended to help debug a specific problem reported from the wild and is not for general use. check-in: 34155c40 user: drh tags: filesize-debug
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318





1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
#endif
}

/*
** Determine the current size of a file in bytes
*/
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
  DWORD upperBits;
  DWORD lowerBits;
  winFile *pFile = (winFile*)id;
  DWORD error;

  assert( id!=0 );
  SimulateIOError(return SQLITE_IOERR_FSTAT);
  lowerBits = GetFileSize(pFile->h, &upperBits);
  if(   (lowerBits == INVALID_FILE_SIZE)
     && ((error = GetLastError()) != NO_ERROR) )
  {





    pFile->lastErrno = error;
    return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath);
  }
  *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
  return SQLITE_OK;
}

/*
** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.
*/
#ifndef LOCKFILE_FAIL_IMMEDIATELY
# define LOCKFILE_FAIL_IMMEDIATELY 1







|
<

<



<
<
<
|
>
>
>
>
>
|


<
<







1301
1302
1303
1304
1305
1306
1307
1308

1309

1310
1311
1312



1313
1314
1315
1316
1317
1318
1319
1320
1321


1322
1323
1324
1325
1326
1327
1328
#endif
}

/*
** Determine the current size of a file in bytes
*/
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
  BY_HANDLE_FILE_INFORMATION info;

  winFile *pFile = (winFile*)id;


  assert( id!=0 );
  SimulateIOError(return SQLITE_IOERR_FSTAT);




  memset(&info, 0, sizeof(BY_HANDLE_FILE_INFORMATION));
  if( GetFileInformationByHandle(pFile->h, &info) ){
    *pSize = (((u64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
    return SQLITE_OK;
  }else{
    pFile->lastErrno = GetLastError();
    return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath);
  }


}

/*
** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.
*/
#ifndef LOCKFILE_FAIL_IMMEDIATELY
# define LOCKFILE_FAIL_IMMEDIATELY 1