SQLite

Check-in [697498d4e8]
Login

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

Overview
Comment:Add comments to the changes of check-in (3200). (CVS 3202)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 697498d4e86a42d7063417a9549ad04aaf4db31c
User & Date: drh 2006-06-04 23:31:49.000
Context
2006-06-06
11:45
In joins of the form "A left B, C" make sure they are not transformed into "A left C, B". Ticket #1830. See also #1652. (CVS 3203) (check-in: 2baa983653 user: drh tags: trunk)
2006-06-04
23:31
Add comments to the changes of check-in (3200). (CVS 3202) (check-in: 697498d4e8 user: drh tags: trunk)
23:20
Fix a windows portability problem in trans.test. (CVS 3201) (check-in: f2538dfdb6 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_win.c.
472
473
474
475
476
477
478
479









480

481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
}
/*
** End of the special code for wince
*****************************************************************************/
#endif /* OS_WINCE */

/*
** Delete the named file









*/

int sqlite3WinDelete(const char *zFilename){
  WCHAR *zWide = utf8ToUnicode(zFilename);
  int cnt = 0;
  int rc;
  if( zWide ){
    do{
      rc = DeleteFileW(zWide);
    }while( rc==0 && cnt++ < 3 && (Sleep(100), 1) );
    sqliteFree(zWide);
  }else{
#if OS_WINCE
    return SQLITE_NOMEM;
#else
    do{
      rc = DeleteFileA(zFilename);
    }while( rc==0 && cnt++ < 3 && (Sleep(100), 1) );
#endif
  }
  TRACE2("DELETE \"%s\"\n", zFilename);
  return rc==0 ? SQLITE_OK : SQLITE_IOERR;
}

/*







|
>
>
>
>
>
>
>
>
>

>







|







|







472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
}
/*
** End of the special code for wince
*****************************************************************************/
#endif /* OS_WINCE */

/*
** Delete the named file.
**
** Note that windows does not allow a file to be deleted if some other
** process has it open.  Sometimes a virus scanner or indexing program
** will open a journal file shortly after it is created in order to do
** whatever it is it does.  While this other process is holding the
** file open, we will be unable to delete it.  To work around this
** problem, we delay 100 milliseconds and try to delete again.  Up
** to MX_DELETION_ATTEMPTs deletion attempts are run before giving
** up and returning an error.
*/
#define MX_DELETION_ATTEMPTS 3
int sqlite3WinDelete(const char *zFilename){
  WCHAR *zWide = utf8ToUnicode(zFilename);
  int cnt = 0;
  int rc;
  if( zWide ){
    do{
      rc = DeleteFileW(zWide);
    }while( rc==0 && cnt++ < MX_DELETION_ATTEMPTS && (Sleep(100), 1) );
    sqliteFree(zWide);
  }else{
#if OS_WINCE
    return SQLITE_NOMEM;
#else
    do{
      rc = DeleteFileA(zFilename);
    }while( rc==0 && cnt++ < MX_DELETION_ATTEMPTS && (Sleep(100), 1) );
#endif
  }
  TRACE2("DELETE \"%s\"\n", zFilename);
  return rc==0 ? SQLITE_OK : SQLITE_IOERR;
}

/*
626
627
628
629
630
631
632






633
634
635
636
637
638
639
**
** If delFlag is true, then make arrangements to automatically delete
** the file when it is closed.
**
** On success, write the file handle into *id and return SQLITE_OK.
**
** On failure, return SQLITE_CANTOPEN.






*/
int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){
  winFile f;
  HANDLE h;
  int fileflags;
  WCHAR *zWide = utf8ToUnicode(zFilename);
  assert( *pId == 0 );







>
>
>
>
>
>







636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
**
** If delFlag is true, then make arrangements to automatically delete
** the file when it is closed.
**
** On success, write the file handle into *id and return SQLITE_OK.
**
** On failure, return SQLITE_CANTOPEN.
**
** Sometimes if we have just deleted a prior journal file, windows
** will fail to open a new one because there is a "pending delete".
** To work around this bug, we pause for 100 milliseconds and attempt
** a second open after the first one fails.  The whole operation only
** fails if both open attempts are unsuccessful.
*/
int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){
  winFile f;
  HANDLE h;
  int fileflags;
  WCHAR *zWide = utf8ToUnicode(zFilename);
  assert( *pId == 0 );
804
805
806
807
808
809
810







811

812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
  }
  TRACE2("TEMP FILENAME: %s\n", zBuf);
  return SQLITE_OK; 
}

/*
** Close a file.







*/

static int winClose(OsFile **pId){
  winFile *pFile;
  int rc = 1;
  if( pId && (pFile = (winFile*)*pId)!=0 ){
    int rc, cnt = 0;
    TRACE2("CLOSE %d\n", pFile->h);
    do{
      rc = CloseHandle(pFile->h);
    }while( rc==0 && cnt++ < 3 && (Sleep(100), 1) );
#if OS_WINCE
    winceDestroyLock(pFile);
    if( pFile->zDeleteOnClose ){
      DeleteFileW(pFile->zDeleteOnClose);
      sqliteFree(pFile->zDeleteOnClose);
    }
#endif







>
>
>
>
>
>
>

>








|







820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
  }
  TRACE2("TEMP FILENAME: %s\n", zBuf);
  return SQLITE_OK; 
}

/*
** Close a file.
**
** It is reported that an attempt to close a handle might sometimes
** fail.  This is a very unreasonable result, but windows is notorious
** for being unreasonable so I do not doubt that it might happen.  If
** the close fails, we pause for 100 milliseconds and try again.  As
** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before
** giving up and returning an error.
*/
#define MX_CLOSE_ATTEMPT 3
static int winClose(OsFile **pId){
  winFile *pFile;
  int rc = 1;
  if( pId && (pFile = (winFile*)*pId)!=0 ){
    int rc, cnt = 0;
    TRACE2("CLOSE %d\n", pFile->h);
    do{
      rc = CloseHandle(pFile->h);
    }while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
#if OS_WINCE
    winceDestroyLock(pFile);
    if( pFile->zDeleteOnClose ){
      DeleteFileW(pFile->zDeleteOnClose);
      sqliteFree(pFile->zDeleteOnClose);
    }
#endif