1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Do not attempt to take any write lock on a read-only database on Windows.

FossilOrigin-Name: a47ff0cdab0f82398c68ea770053f193f4812a51
This commit is contained in:
drh
2015-05-28 00:54:35 +00:00
parent 3da29a112a
commit 275fe3adf1
4 changed files with 76 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
C The\sfuzzoomtest\smakefile\starget\sis\sno\slonger\ssupported,\sso\supdate\nreleasetest.tcl\saccordingly. C Do\snot\sattempt\sto\stake\sany\swrite\slock\son\sa\sread-only\sdatabase\son\sWindows.
D 2015-05-27T19:35:08.477 D 2015-05-28T00:54:35.202
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 994bab32a3a69e0c35bd148b65cde49879772964 F Makefile.in 994bab32a3a69e0c35bd148b65cde49879772964
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -235,7 +235,7 @@ F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc
F src/os_win.c 97f7828a9554d753665b6fcf7540e31c2b3d6a6e F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 9bc918a009285f96ec6dac62dd764c7063552455 F src/pager.c 9bc918a009285f96ec6dac62dd764c7063552455
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
@@ -843,6 +843,7 @@ F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea
F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14
F test/rollbackfault.test 6a004f71087cc399296cffbb5429ea6da655ae65 F test/rollbackfault.test 6a004f71087cc399296cffbb5429ea6da655ae65
F test/rowallock.test f7f834125f11ff62f6e1ae7d0b07fd9228f2d5a2
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test 742b5741584a8a44fd83e856cc2896688401d645 F test/rowid.test 742b5741584a8a44fd83e856cc2896688401d645
F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798 F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798
@@ -1279,7 +1280,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 8bfe834432b37f94779da6c71fc369651f024590 P 06959d4ada53b765cae4b192a691fced4b8aebbb
R 7269484077d02112c37e52a4369ae264 R b30cfcc10e16186636545a138869402d
U drh U drh
Z 7d5ba49e31193e65fb96ee7978e16396 Z 3b24ef1efe39a20b744ff0c0269b43f9

View File

@@ -1 +1 @@
06959d4ada53b765cae4b192a691fced4b8aebbb a47ff0cdab0f82398c68ea770053f193f4812a51

View File

@@ -3015,6 +3015,12 @@ static int winLock(sqlite3_file *id, int locktype){
return SQLITE_OK; return SQLITE_OK;
} }
/* Do not allow any kind of write-lock on a read-only database
*/
if( (pFile->ctrlFlags & WINFILE_RDONLY)!=0 && locktype>=RESERVED_LOCK ){
return SQLITE_IOERR_LOCK;
}
/* Make sure the locking sequence is correct /* Make sure the locking sequence is correct
*/ */
assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK ); assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );

62
test/rowallock.test Normal file
View File

@@ -0,0 +1,62 @@
# 2015-05-28
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing locks on read-only WAL-mode databases.
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
set testprefix rowallock
do_multiclient_test tn {
code2 { db2 close }
code3 { db3 close }
do_execsql_test 1.$tn.1 {
PRAGMA page_size = 4096;
CREATE TABLE t1(a, b);
CREATE TABLE t2(a, b);
INSERT INTO t1 VALUES(1, 2), (3, 4);
PRAGMA journal_mode = wal;
} {wal}
code1 {
db close
sqlite3 db test.db -readonly 1
}
do_execsql_test 1.$tn.2 {
PRAGMA mmap_size = 1000000;
} {1000000}
do_execsql_test 1.$tn.2.1 {
SELECT * FROM t1;
} {1 2 3 4}
do_catchsql_test 1.$tn.3 {
INSERT INTO t1 VALUES(5, 6);
} {1 {attempt to write a readonly database}}
do_test 1.$tn.4 {
code2 { sqlite3 db2 test.db }
sql2 { INSERT INTO t1 VALUES(5, 6); }
code2 { db2 close }
file exists test.db-wal
} {1}
do_test 1.$tn.5 {
sql1 { SELECT * FROM t2 }
code1 { db close }
file exists test.db-wal
} {1}
}
finish_test