1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Test that the asynchronous backend works with components like "." or ".." in the path to the database file. (CVS 4403)

FossilOrigin-Name: 0a87a854226ccea920484613dd7f7873e673c96e
This commit is contained in:
danielk1977
2007-09-05 14:32:25 +00:00
parent df6a81c838
commit 7be2cce333
4 changed files with 92 additions and 14 deletions

View File

@ -1,5 +1,5 @@
C Restore\sthe\ssqlite3_mutex_try()\soptimization\son\swinNT\ssystems.\s(CVS\s4402)
D 2007-09-05T14:30:42
C Test\sthat\sthe\sasynchronous\sbackend\sworks\swith\scomponents\slike\s"."\sor\s".."\sin\sthe\spath\sto\sthe\sdatabase\sfile.\s(CVS\s4403)
D 2007-09-05T14:32:25
F Makefile.in cbfb898945536a8f9ea8b897e1586dd1fdbcc5db
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -145,7 +145,7 @@ F src/test6.c 0513982dfef4da2a4154b538d2bf538b84ca21d3
F src/test7.c a9d509d0e9ad214b4772696f49f6e61be26213d1
F src/test8.c f113aa3723a52113d0fa7c28155ecd37e7e04077
F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f
F src/test_async.c 5d30feff6238f083eb32a55f5c18b036a1a5e40c
F src/test_async.c 6e30875ed6227a28f61ce5fce6cd6b3571c06133
F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
F src/test_config.c 6fb459214b27952b143f45e35200d94096d54cc6
@ -182,6 +182,7 @@ F test/altermalloc.test 1f4d2d66750bea1a78cd9f0b7dba5bfb155dd6cf
F test/analyze.test 2f55535aa335785db1a2f97d3f3831c16c09f8b0
F test/async.test eca5ea2646ea4adfbfa276fa710238e79eb1d477
F test/async2.test 75f2d15f4c27189ec3296cf2565ec91834bbed76
F test/async3.test 60a6e5a8e739a418d3f95f16d3061e54583997ee
F test/attach.test b849e1baae863c3a6132ff8b9b1baf356ab6c178
F test/attach2.test 78bc1a25ea8785c7571b44f5947ada2bd5d78127
F test/attach3.test eafcafb107585aecc2ed1569a77914138eef46a9
@ -569,7 +570,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 1786e9c881a67fbf8bd014d643590534c8c601dc
R 13dbaebf3174563b1064b0b1bbb0d310
U drh
Z 14476c6d97c0081a9542a49eeb3e06d4
P 3aace2fa91e96038f7a32366828ac7520470fa67
R 4773df5025bfb3384ab08322753dc6d8
U danielk1977
Z f1ee4a8ff07588869cdd656e05c5eaeb

View File

@ -1 +1 @@
3aace2fa91e96038f7a32366828ac7520470fa67
0a87a854226ccea920484613dd7f7873e673c96e

View File

@ -621,13 +621,18 @@ static int getFileLock(AsyncLock *pLock){
assert(eRequired>=0 && eRequired<=SQLITE_LOCK_EXCLUSIVE);
}
}
if( eRequired>pLock->eLock ){
rc = sqlite3OsLock(pLock->pFile, eRequired);
}else if(eRequired<pLock->eLock){
rc = sqlite3OsUnlock(pLock->pFile, eRequired);
if( rc==SQLITE_OK ){
pLock->eLock = eRequired;
}
}
if( rc==SQLITE_OK ){
pLock->eLock = eRequired;
else if( eRequired<pLock->eLock && eRequired<=SQLITE_LOCK_SHARED ){
rc = sqlite3OsUnlock(pLock->pFile, eRequired);
if( rc==SQLITE_OK ){
pLock->eLock = eRequired;
}
}
}
@ -932,11 +937,11 @@ static int asyncFullPathname(
/* Replace any occurences of "<path-component>/../" with "" */
if( iOut>0 && iIn<=(nPathOut-4)
&& zPathOut[iIn]=='/' && zPathOut[iIn+1]=='.'
&& zPathOut[iIn+2]=='.' && zPathOut[iIn+2]=='/'
&& zPathOut[iIn+2]=='.' && zPathOut[iIn+3]=='/'
){
iIn += 3;
iOut--;
for( ; iOut>0 && zPathOut[iOut]!='/'; iOut--);
for( ; iOut>0 && zPathOut[iOut-1]!='/'; iOut--);
continue;
}

72
test/async3.test Normal file
View File

@ -0,0 +1,72 @@
# 2007 September 5
#
# 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.
#
#***********************************************************************
#
# The focus of this file is testing the code in test_async.c.
# Specifically, it tests that the xFullPathname() method of
# of the asynchronous vfs works correctly.
#
# $Id: async3.test,v 1.1 2007/09/05 14:32:25 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if { [info commands sqlite3async_enable]=="" } {
# The async logic is not built into this system
puts "Skipping async3 tests: not compiled with required features"
finish_test
return
}
db close
sqlite3async_enable 1
sqlite3async_start
set paths {
chocolate/banana/vanilla/file.db
chocolate//banana/vanilla/file.db
chocolate/./banana//vanilla/file.db
chocolate/banana/./vanilla/file.db
chocolate/banana/../banana/vanilla/file.db
chocolate/banana/./vanilla/extra_bit/../file.db
}
do_test async3-1.0 {
file mkdir [file join chocolate banana vanilla]
file delete -force chocolate/banana/vanilla/file.db
file delete -force chocolate/banana/vanilla/file.db-journal
} {}
do_test async3-1.1 {
sqlite3 db chocolate/banana/vanilla/file.db
execsql {
CREATE TABLE abc(a, b, c);
BEGIN;
INSERT INTO abc VALUES(1, 2, 3);
}
} {}
set N 2
foreach p $paths {
sqlite3 db2 $p
do_test async3-1.$N.1 {
execsql {SELECT * FROM abc} db2
} {}
do_test async3-1.$N.2 {
catchsql {INSERT INTO abc VALUES(4, 5, 6)} db2
} {1 {database is locked}}
db2 close
incr N
}
db close
sqlite3async_halt idle
sqlite3async_wait
sqlite3async_enable 0
finish_test