From: drh Date: Thu, 1 May 2014 01:49:22 +0000 (+0000) Subject: Take out the special handling of nolock=true in os_win.c and add it to X-Git-Tag: version-3.8.5~51^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=57fe136b23aca972e867a3c7925980c1a5e80842;p=thirdparty%2Fsqlite.git Take out the special handling of nolock=true in os_win.c and add it to pager.c, so that it works for all VFSes. Add the pPager->noLock boolean for clarity. FossilOrigin-Name: 725c1c14be331bce9bf074960dbfa7b6d4c1ba87 --- diff --git a/manifest b/manifest index 2f57028bf7..6ac75f7987 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sunnecessary\sxUnlock\soperations\son\stemp\sfile. -D 2014-05-01T01:20:05.808 +C Take\sout\sthe\sspecial\shandling\sof\snolock=true\sin\sos_win.c\sand\sadd\sit\sto\npager.c,\sso\sthat\sit\sworks\sfor\sall\sVFSes.\s\sAdd\sthe\spPager->noLock\sboolean\nfor\sclarity. +D 2014-05-01T01:49:22.279 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -205,8 +205,8 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c ae4b5240af4619d711301d7992396e182585269f -F src/os_win.c 1662c40d22be162698a31725e836eede09e841ed -F src/pager.c 52b7f435cb06063ccb52ff7089dfbc7be613b9b2 +F src/os_win.c e71678ac927d0a0fb11d993db20a9748eabf808e +F src/pager.c 6ed54e169933200b8d113674d5da46a5cbd32c6c F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 F src/parse.y 22d6a074e5f5a7258947a1dc55a9bf946b765dd0 F src/pcache.c d8eafac28290d4bb80332005435db44991d07fc2 @@ -1166,7 +1166,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 71f152c85d79ebd9ca48bc9c4c71fc4debaf2437 -R 936969710ee66727ffa03c716e1344c2 +P 1829c38c3233c8cb194fae6d560d35a8916b1348 +R 9585bcff14fbe775451a3a647d896079 U drh -Z b6af320858436be94ae3e128e461e236 +Z 3dae204f6c4a7be4483961b87ae0c17a diff --git a/manifest.uuid b/manifest.uuid index 8ca149ad7f..d015fa2fa6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1829c38c3233c8cb194fae6d560d35a8916b1348 \ No newline at end of file +725c1c14be331bce9bf074960dbfa7b6d4c1ba87 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index bf5b9c72d1..287dad3b57 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -275,7 +275,6 @@ struct winFile { #define WINFILE_RDONLY 0x02 /* Connection is read only */ #define WINFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */ #define WINFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ -#define WINFILE_NOLOCK 0x20 /* Never do any real locking */ /* * The size of the buffer used by sqlite3_win32_write_debug(). @@ -2860,10 +2859,6 @@ static int winLock(sqlite3_file *id, int locktype){ assert( id!=0 ); OSTRACE(("LOCK file=%p, oldLock=%d(%d), newLock=%d\n", pFile->h, pFile->locktype, pFile->sharedLockByte, locktype)); - if( pFile->ctrlFlags & WINFILE_NOLOCK ){ - OSTRACE(("LOCK-NOP file=%p, rc=SQLITE_OK\n", pFile->h)); - return SQLITE_OK; - } /* If there is already a lock of this type or more restrictive on the ** OsFile, do nothing. Don't use the end_lock: exit path, as @@ -2991,10 +2986,7 @@ static int winCheckReservedLock(sqlite3_file *id, int *pResOut){ OSTRACE(("TEST-WR-LOCK file=%p, pResOut=%p\n", pFile->h, pResOut)); assert( id!=0 ); - if( pFile->ctrlFlags & WINFILE_NOLOCK ){ - rc = 0; - OSTRACE(("TEST-WR-LOCK file=%p, rc=%d (nop)\n", pFile->h, rc)); - }else if( pFile->locktype>=RESERVED_LOCK ){ + if( pFile->locktype>=RESERVED_LOCK ){ rc = 1; OSTRACE(("TEST-WR-LOCK file=%p, rc=%d (local)\n", pFile->h, rc)); }else{ @@ -3030,10 +3022,6 @@ static int winUnlock(sqlite3_file *id, int locktype){ assert( locktype<=SHARED_LOCK ); OSTRACE(("UNLOCK file=%p, oldLock=%d(%d), newLock=%d\n", pFile->h, pFile->locktype, pFile->sharedLockByte, locktype)); - if( pFile->ctrlFlags & WINFILE_NOLOCK ){ - OSTRACE(("UNLOCK-NOP file=%p, rc=SQLITE_OK\n", pFile->h)); - return SQLITE_OK; - } type = pFile->locktype; if( type>=EXCLUSIVE_LOCK ){ winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); @@ -4704,9 +4692,6 @@ static int winOpen( if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ pFile->ctrlFlags |= WINFILE_PSOW; } - if( sqlite3_uri_boolean(zName, "nolock", 0) ){ - pFile->ctrlFlags |= WINFILE_NOLOCK; - } pFile->lastErrno = NO_ERROR; pFile->zPath = zName; #if SQLITE_MAX_MMAP_SIZE>0 diff --git a/src/pager.c b/src/pager.c index 15d21cd9b1..9ab7cfbe54 100644 --- a/src/pager.c +++ b/src/pager.c @@ -626,7 +626,8 @@ struct Pager { u8 ckptSyncFlags; /* SYNC_NORMAL or SYNC_FULL for checkpoint */ u8 walSyncFlags; /* SYNC_NORMAL or SYNC_FULL for wal writes */ u8 syncFlags; /* SYNC_NORMAL or SYNC_FULL otherwise */ - u8 tempFile; /* zFilename is a temporary file */ + u8 tempFile; /* zFilename is a temporary or immutable file */ + u8 noLock; /* Do not lock (except in WAL mode) */ u8 readOnly; /* True for a read-only database */ u8 memDb; /* True to inhibit all file I/O */ @@ -1089,9 +1090,9 @@ static int pagerUnlockDb(Pager *pPager, int eLock){ assert( !pPager->exclusiveMode || pPager->eLock==eLock ); assert( eLock==NO_LOCK || eLock==SHARED_LOCK ); assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 ); - if( isOpen(pPager->fd) && !pPager->tempFile ){ + if( isOpen(pPager->fd) ){ assert( pPager->eLock>=eLock ); - rc = sqlite3OsUnlock(pPager->fd, eLock); + rc = pPager->noLock ? SQLITE_OK : sqlite3OsUnlock(pPager->fd, eLock); if( pPager->eLock!=UNKNOWN_LOCK ){ pPager->eLock = (u8)eLock; } @@ -1115,7 +1116,7 @@ static int pagerLockDb(Pager *pPager, int eLock){ assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK ); if( pPager->eLockeLock==UNKNOWN_LOCK ){ - rc = sqlite3OsLock(pPager->fd, eLock); + rc = pPager->noLock ? SQLITE_OK : sqlite3OsLock(pPager->fd, eLock); if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){ pPager->eLock = (u8)eLock; IOTRACE(("LOCK %p %d\n", pPager, eLock)) @@ -4699,6 +4700,7 @@ int sqlite3PagerOpen( } } #endif + pPager->noLock = sqlite3_uri_boolean(zFilename, "nolock", 0); if( (iDc & SQLITE_IOCAP_IMMUTABLE)!=0 || sqlite3_uri_boolean(zFilename, "immutable", 0) ){ vfsFlags |= SQLITE_OPEN_READONLY; @@ -4714,11 +4716,14 @@ int sqlite3PagerOpen( ** This branch is also run for an in-memory database. An in-memory ** database is the same as a temp-file that is never written out to ** disk and uses an in-memory rollback journal. + ** + ** This branch also runs for files marked as immutable. */ act_like_temp_file: tempFile = 1; - pPager->eState = PAGER_READER; - pPager->eLock = EXCLUSIVE_LOCK; + pPager->eState = PAGER_READER; /* Pretend we already have a lock */ + pPager->eLock = EXCLUSIVE_LOCK; /* Pretend we are in EXCLUSIVE locking mode */ + pPager->noLock = 1; /* Do no locking */ readOnly = (vfsFlags&SQLITE_OPEN_READONLY); }