0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-03-13 13:08:04 +00:00

If a hot-journal file is detected but the application does not have the required read/write permissions, return SQLITE_CANTOPEN. Prior to this change, SQLITE_BUSY was returned. Ticket . (CVS 5849)

FossilOrigin-Name: dc5308c7629abe6a3bad21489c8e97087c264e5a
This commit is contained in:
danielk1977
2008-10-29 07:01:56 +00:00
parent d1370b6d92
commit 281d8bd3ac
4 changed files with 90 additions and 16 deletions

@ -1,5 +1,5 @@
C Remove\sthe\svestigial\smem4\sand\smem6\smemory\sallocators.\s\sAdd\sthe\nSQLITE_ZERO_MALLOC\scompile-time\soption\sand\sthe\smem0.c\smodule\sto\nhandle\smemory\sallocation\sfor\sthat\scase.\s(CVS\s5848) C If\sa\shot-journal\sfile\sis\sdetected\sbut\sthe\sapplication\sdoes\snot\shave\sthe\srequired\sread/write\spermissions,\sreturn\sSQLITE_CANTOPEN.\sPrior\sto\sthis\schange,\sSQLITE_BUSY\swas\sreturned.\sTicket\s#3457.\s(CVS\s5849)
D 2008-10-28T18:58:20 D 2008-10-29T07:01:57
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in da817da72422f9b876602c225fcd17d6ca4182f7 F Makefile.in da817da72422f9b876602c225fcd17d6ca4182f7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -138,7 +138,7 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c 24221ff5ab20cf3472e3ec7eec595f759de55298 F src/os_os2.c 24221ff5ab20cf3472e3ec7eec595f759de55298
F src/os_unix.c 5e3b3c9a54546249c1317cff5343e965192f7f2b F src/os_unix.c 5e3b3c9a54546249c1317cff5343e965192f7f2b
F src/os_win.c a26292f39a73a446aa56b01871e73545da8ce3e4 F src/os_win.c a26292f39a73a446aa56b01871e73545da8ce3e4
F src/pager.c 8377118bd5ae055b66683926b264f6c04442317e F src/pager.c 847de90e441beb9f8eaadb76d00814b8be20f5f6
F src/pager.h 4a57b219c0765fe1870238064e3f46e4eb2cf5af F src/pager.h 4a57b219c0765fe1870238064e3f46e4eb2cf5af
F src/parse.y 2c4758b4c5ead6de8cf7112f5a7cce7561d313fe F src/parse.y 2c4758b4c5ead6de8cf7112f5a7cce7561d313fe
F src/pcache.c 5b80676e664019c1ebc8356cc25332dd69da6269 F src/pcache.c 5b80676e664019c1ebc8356cc25332dd69da6269
@ -572,6 +572,7 @@ F test/tkt3357.test b37a51a12ba5e143d6714778276438606f8f9e27
F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b
F test/tkt3424.test 3171193ce340cff6b7ea81c03b8fa1cbc34ec36e F test/tkt3424.test 3171193ce340cff6b7ea81c03b8fa1cbc34ec36e
F test/tkt3442.test 33722a3fa4bdc0614448044eb5e28765aea28eb7 F test/tkt3442.test 33722a3fa4bdc0614448044eb5e28765aea28eb7
F test/tkt3457.test e9ca2b90f0eb1fb8be73a30d29aacb2e3abedeb9
F test/tkt3461.test 5a63e8d8ee5ce00f076b1e2f82aba5480a0f14ed F test/tkt3461.test 5a63e8d8ee5ce00f076b1e2f82aba5480a0f14ed
F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00 F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00
@ -651,7 +652,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P e9c2adbcbf5c28837b06e0fbba93f1764cc3607f P 4651f590f0b8bf13938b2b15d5082136e763af8d
R f7bf0b80936d7235124831741a662cca R e062a5dfa67b3ff54e219649b4e4fdb6
U drh U danielk1977
Z dd0198037f61ae7a01ce16dbaae2a0df Z d3e719d91fd94e74917b0fa45d10565a

@ -1 +1 @@
4651f590f0b8bf13938b2b15d5082136e763af8d dc5308c7629abe6a3bad21489c8e97087c264e5a

@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while ** file simultaneously, or one process from reading the database while
** another is writing. ** another is writing.
** **
** @(#) $Id: pager.c,v 1.499 2008/10/22 16:26:48 shane Exp $ ** @(#) $Id: pager.c,v 1.500 2008/10/29 07:01:57 danielk1977 Exp $
*/ */
#ifndef SQLITE_OMIT_DISKIO #ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h" #include "sqliteInt.h"
@ -2640,8 +2640,8 @@ static int pagerSharedLock(Pager *pPager){
assert( !pPager->tempFile ); assert( !pPager->tempFile );
rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout); rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);
assert( rc!=SQLITE_OK || pPager->jfd->pMethods ); assert( rc!=SQLITE_OK || pPager->jfd->pMethods );
if( fout&SQLITE_OPEN_READONLY ){ if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){
rc = SQLITE_BUSY; rc = SQLITE_CANTOPEN;
sqlite3OsClose(pPager->jfd); sqlite3OsClose(pPager->jfd);
} }
}else{ }else{
@ -2652,11 +2652,6 @@ static int pagerSharedLock(Pager *pPager){
} }
} }
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
if( rc!=SQLITE_NOMEM && rc!=SQLITE_IOERR_UNLOCK
&& rc!=SQLITE_IOERR_NOMEM
){
rc = SQLITE_BUSY;
}
goto failed; goto failed;
} }
pPager->journalOpen = 1; pPager->journalOpen = 1;

78
test/tkt3457.test Normal file

@ -0,0 +1,78 @@
# 2008 October 29
#
# 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.
#
# $Id: tkt3457.test,v 1.1 2008/10/29 07:01:57 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {$tcl_platform(platform) != "unix"} {
finish_test
return
}
#-----------------------------------------------------------------------
# To roll back a hot-journal file, the application needs read and write
# permission on the journal file in question. The following tests test
# the outcome of trying to rollback a hot-journal file when this is not
# the case.
#
# tkt3457-1.2: Application has neither read, nor write permission on
# the hot-journal file. Result: SQLITE_CANTOPEN.
#
# tkt3457-1.3: Application has write but not read permission on
# the hot-journal file. Result: SQLITE_CANTOPEN.
#
# tkt3457-1.4: Application has read but not write permission on
# the hot-journal file. Result: SQLITE_CANTOPEN.
#
# tkt3457-1.5: Application has read/write permission on the hot-journal
# file. Result: SQLITE_OK.
#
do_test tkt3457-1.1 {
execsql {
CREATE TABLE t1(a, b, c);
INSERT INTO t1 VALUES(1, 2, 3);
BEGIN;
INSERT INTO t1 VALUES(4, 5, 6);
}
file copy -force test.db bak.db
file copy -force test.db-journal bak.db-journal
execsql COMMIT
} {}
do_test tkt3457-1.2 {
file copy -force bak.db-journal test.db-journal
file attributes test.db-journal -permissions ---------
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.3 {
file copy -force bak.db-journal test.db-journal
file attributes test.db-journal -permissions -w--w--w-
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.4 {
file copy -force bak.db-journal test.db-journal
file attributes test.db-journal -permissions r--r--r--
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
do_test tkt3457-1.5 {
file copy -force bak.db-journal test.db-journal
file attributes test.db-journal -permissions rw-rw-rw-
catchsql { SELECT * FROM t1 }
} {0 {1 2 3 4 5 6}}
finish_test