/ Check-in [82e03f1b]
Login

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

Overview
Comment:Fixed error detection in winTrucate() in os_win.c. Windows version only. Ticket #3640. (CVS 6262)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:82e03f1b5481c6fe5e94976f086e8fe8c99881af
User & Date: shane 2009-02-05 03:16:21
Context
2009-02-05
16:31
Make the pending byte adjustable via sqlite3_test_control() on all builds, not just on test builds. (CVS 6263) check-in: e8f192e2 user: drh tags: trunk
03:16
Fixed error detection in winTrucate() in os_win.c. Windows version only. Ticket #3640. (CVS 6262) check-in: 82e03f1b user: shane tags: trunk
03:00
Improved overrun detection in mem2.c (SQLITE_MEMDEBUG). Previously was only checking up to 3 extra bytes allocated due to rounding. (CVS 6261) check-in: a6fe3d6b user: shane tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
723
724
725
726
727
728
729

730
731
732
733



734
735
736
737

738
739
740
741
742
743
744
745
746
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to windows.
**
** $Id: os_win.c,v 1.147 2009/02/04 03:59:25 shane Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_WIN               /* This file is used for windows only */


/*
** A Note About Memory Allocation:
................................................................................
** Truncate an open file to a specified size
*/
static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
  DWORD rc;
  LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff);
  LONG lowerBits = (LONG)(nByte & 0xffffffff);
  winFile *pFile = (winFile*)id;

  OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
  SimulateIOError(return SQLITE_IOERR_TRUNCATE);
  rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
  if( INVALID_SET_FILE_POINTER != rc ){



    /* SetEndOfFile will fail if nByte is negative */
    if( SetEndOfFile(pFile->h) ){
      return SQLITE_OK;
    }

  }
  pFile->lastErrno = GetLastError();
  return SQLITE_IOERR_TRUNCATE;
}

#ifdef SQLITE_TEST
/*
** Count the number of fullsyncs and normal syncs.  This is used to test
** that syncs and fullsyncs are occuring at the right times.







|







 







>



|
>
>
>




>

|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to windows.
**
** $Id: os_win.c,v 1.148 2009/02/05 03:16:21 shane Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_WIN               /* This file is used for windows only */


/*
** A Note About Memory Allocation:
................................................................................
** Truncate an open file to a specified size
*/
static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
  DWORD rc;
  LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff);
  LONG lowerBits = (LONG)(nByte & 0xffffffff);
  winFile *pFile = (winFile*)id;
  DWORD error = NO_ERROR;
  OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
  SimulateIOError(return SQLITE_IOERR_TRUNCATE);
  rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
  if( INVALID_SET_FILE_POINTER == rc ){
    error = GetLastError();
  }
  if( error == NO_ERROR ){
    /* SetEndOfFile will fail if nByte is negative */
    if( SetEndOfFile(pFile->h) ){
      return SQLITE_OK;
    }
    error = GetLastError();
  }
  pFile->lastErrno = error;
  return SQLITE_IOERR_TRUNCATE;
}

#ifdef SQLITE_TEST
/*
** Count the number of fullsyncs and normal syncs.  This is used to test
** that syncs and fullsyncs are occuring at the right times.