From 68d405e25aa8d22c785b1efc74ec0ace13978ead Mon Sep 17 00:00:00 2001 From: shane Date: Thu, 23 Apr 2009 19:08:32 +0000 Subject: [PATCH] os_win.c, winOpen(), changed to handle the SQLITE_OPEN_EXCLUSIVE flag and sharing modes in the same manner as os_unix.c. Ticket #3821. (CVS 6542) FossilOrigin-Name: 18fef3fcf61c137a89a83352f6769ed06845434a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 94f822ac54..ea67f1fa0a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updated\smisc.\stest\sscripts\sfor\sWindows\stesting\swith\sgcc/cygwin;\s(CVS\s6541) -D 2009-04-23T18:42:05 +C os_win.c,\swinOpen(),\schanged\sto\shandle\sthe\sSQLITE_OPEN_EXCLUSIVE\sflag\sand\ssharing\smodes\sin\sthe\ssame\smanner\sas\sos_unix.c.\sTicket\s#3821.\s(CVS\s6542) +D 2009-04-23T19:08:33 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -144,7 +144,7 @@ F src/os.h fa3f4aa0119ff721a2da4b47ffd74406ac864c05 F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_unix.c 9ad9f45049a3c9eb0b0713b162ff0d7024ff7259 -F src/os_win.c c3d0354b9a7ae75e3e993e6c17f5deb061acbc36 +F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405 F src/pager.c adfdf98f92bcab88246aaa5079df49f9441ebd81 F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f F src/parse.y b7e4341b21736a90b952aa6bb663ec98529b778e @@ -722,7 +722,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 03af25b3ee001c1bf3e7a3218fad6ed311c7c259 -R 30700e10f6c34e71c71283b7d63f7a33 +P 1e2c71596e3f7a69afc5b745c20b2e4e81bffda5 +R 76d5774a4fbfd2590aa81cedc88a2f67 U shane -Z 3c397054349ec943746136fd831f258c +Z ae8755c671bd4929f4c005dcef86f4c8 diff --git a/manifest.uuid b/manifest.uuid index a48ab63d7f..d0313ab81c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e2c71596e3f7a69afc5b745c20b2e4e81bffda5 \ No newline at end of file +18fef3fcf61c137a89a83352f6769ed06845434a \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index cb4c4ce3b3..3bc769bd73 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -12,7 +12,7 @@ ** ** This file contains code that is specific to windows. ** -** $Id: os_win.c,v 1.155 2009/04/15 14:36:26 shane Exp $ +** $Id: os_win.c,v 1.156 2009/04/23 19:08:33 shane Exp $ */ #include "sqliteInt.h" #if SQLITE_OS_WIN /* This file is used for windows only */ @@ -1312,16 +1312,23 @@ static int winOpen( }else{ dwDesiredAccess = GENERIC_READ; } - if( flags & SQLITE_OPEN_CREATE ){ + /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is + ** created. SQLite doesn't use it to indicate "exclusive access" + ** as it is usually understood. + */ + assert(!(flags & SQLITE_OPEN_EXCLUSIVE) || (flags & SQLITE_OPEN_CREATE)); + if( flags & SQLITE_OPEN_EXCLUSIVE ){ + /* Creates a new file, only if it does not already exist. */ + /* If the file exists, it fails. */ + dwCreationDisposition = CREATE_NEW; + }else if( flags & SQLITE_OPEN_CREATE ){ + /* Open existing file, or create if it doesn't exist */ dwCreationDisposition = OPEN_ALWAYS; }else{ + /* Opens a file, only if it exists. */ dwCreationDisposition = OPEN_EXISTING; } - if( flags & SQLITE_OPEN_MAIN_DB ){ - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - }else{ - dwShareMode = 0; - } + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; if( flags & SQLITE_OPEN_DELETEONCLOSE ){ #if SQLITE_OS_WINCE dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN; -- 2.47.2