diff options
author | jan.nijtmans <jan.nijtmans@noemail.net> | 2025-03-27 14:13:12 +0000 |
---|---|---|
committer | jan.nijtmans <jan.nijtmans@noemail.net> | 2025-03-27 14:13:12 +0000 |
commit | eb2644024af7124222b2e5e0faab66275aefbb92 (patch) | |
tree | e6129b54bed088cda5f398a0aaf413e944aadb9f /src | |
parent | 22d502e33a294f3f2c05d0dc1c51494589ef9724 (diff) | |
parent | 7b3477c7764cb48cfc676454f9a35c377cb7c79f (diff) | |
download | sqlite-eb2644024af7124222b2e5e0faab66275aefbb92.tar.gz sqlite-eb2644024af7124222b2e5e0faab66275aefbb92.zip |
Merge trunk. Some additional test-fixes for Cygwin
FossilOrigin-Name: b36adadfa202fb8951149561471c3e01085d31e1837c99806f308f234cd24a8e
Diffstat (limited to 'src')
-rw-r--r-- | src/os_win.c | 32 | ||||
-rw-r--r-- | src/shell.c.in | 2 | ||||
-rw-r--r-- | src/test_delete.c | 4 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/os_win.c b/src/os_win.c index e0fbe968c..0dd56af58 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5439,6 +5439,12 @@ static int winAccess( ); /* +** The Windows version of xAccess() accepts an extra bit in the flags +** parameter that prevents an anti-virus retry loop. +*/ +#define NORETRY 0x4000 + +/* ** Open a file. */ static int winOpen( @@ -5462,6 +5468,7 @@ static int winOpen( void *zConverted; /* Filename in OS encoding */ const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */ int cnt = 0; + int isRO = 0; /* file is known to be accessible readonly */ /* If argument zPath is a NULL pointer, this function is required to open ** a temporary file. Use this buffer to store the file name in. @@ -5626,9 +5633,9 @@ static int winOpen( &extendedParameters); if( h!=INVALID_HANDLE_VALUE ) break; if( isReadWrite ){ - int rc2, isRO = 0; + int rc2; sqlite3BeginBenignMalloc(); - rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO); + rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO); sqlite3EndBenignMalloc(); if( rc2==SQLITE_OK && isRO ) break; } @@ -5643,9 +5650,9 @@ static int winOpen( NULL); if( h!=INVALID_HANDLE_VALUE ) break; if( isReadWrite ){ - int rc2, isRO = 0; + int rc2; sqlite3BeginBenignMalloc(); - rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO); + rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO); sqlite3EndBenignMalloc(); if( rc2==SQLITE_OK && isRO ) break; } @@ -5663,9 +5670,9 @@ static int winOpen( NULL); if( h!=INVALID_HANDLE_VALUE ) break; if( isReadWrite ){ - int rc2, isRO = 0; + int rc2; sqlite3BeginBenignMalloc(); - rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO); + rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO); sqlite3EndBenignMalloc(); if( rc2==SQLITE_OK && isRO ) break; } @@ -5680,7 +5687,7 @@ static int winOpen( if( h==INVALID_HANDLE_VALUE ){ sqlite3_free(zConverted); sqlite3_free(zTmpname); - if( isReadWrite && !isExclusive ){ + if( isReadWrite && isRO && !isExclusive ){ return winOpen(pVfs, zName, id, ((flags|SQLITE_OPEN_READONLY) & ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), @@ -5882,8 +5889,14 @@ static int winAccess( int rc = 0; DWORD lastErrno = 0; void *zConverted; + int noRetry = 0; /* Do not use winRetryIoerr() */ UNUSED_PARAMETER(pVfs); + if( (flags & NORETRY)!=0 ){ + noRetry = 1; + flags &= ~NORETRY; + } + SimulateIOError( return SQLITE_IOERR_ACCESS; ); OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n", zFilename, flags, pResOut)); @@ -5906,7 +5919,10 @@ static int winAccess( memset(&sAttrData, 0, sizeof(sAttrData)); while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted, GetFileExInfoStandard, - &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){} + &sAttrData)) + && !noRetry + && winRetryIoerr(&cnt, &lastErrno) + ){ /* Loop until true */} if( rc ){ /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file ** as if it does not exist. diff --git a/src/shell.c.in b/src/shell.c.in index 8272956eb..4efcfee95 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -6855,7 +6855,7 @@ static int shell_dbtotxt_command(ShellState *p, int nArg, char **azArg){ for(j=0; j<16 && aLine[j]==0; j++){} if( j==16 ) continue; if( !seenPageLabel ){ - sqlite3_fprintf(p->out, "| page %lld offset %lld\n", pgno, pgno*pgSz); + sqlite3_fprintf(p->out, "| page %lld offset %lld\n",pgno,(pgno-1)*pgSz); seenPageLabel = 1; } sqlite3_fprintf(p->out, "| %5d:", i); diff --git a/src/test_delete.c b/src/test_delete.c index 68fdbc6a7..3f34a72c4 100644 --- a/src/test_delete.c +++ b/src/test_delete.c @@ -63,7 +63,7 @@ static int sqlite3DeleteUnlinkIfExists( int *pbExists ){ int rc = SQLITE_ERROR; -#if SQLITE_OS_WIN +#ifdef _WIN32 if( pVfs ){ if( pbExists ) *pbExists = 1; rc = pVfs->xDelete(pVfs, zFile, 0); @@ -115,7 +115,7 @@ SQLITE_API int sqlite3_delete_database( { "%s-wal%03d", SQLITE_MULTIPLEX_WAL_8_3_OFFSET, 1 }, }; -#ifdef SQLITE_OS_WIN +#ifdef _WIN32 sqlite3_vfs *pVfs = sqlite3_vfs_find("win32"); #else sqlite3_vfs *pVfs = 0; |