Index: src/test_async.c ================================================================== --- src/test_async.c +++ src/test_async.c @@ -619,17 +619,22 @@ if( pIter->eAsyncLock>eRequired ){ eRequired = pIter->eAsyncLock; assert(eRequired>=0 && eRequired<=SQLITE_LOCK_EXCLUSIVE); } } + if( eRequired>pLock->eLock ){ rc = sqlite3OsLock(pLock->pFile, eRequired); - }else if(eRequiredeLock){ + if( rc==SQLITE_OK ){ + pLock->eLock = eRequired; + } + } + else if( eRequiredeLock && eRequired<=SQLITE_LOCK_SHARED ){ rc = sqlite3OsUnlock(pLock->pFile, eRequired); - } - if( rc==SQLITE_OK ){ - pLock->eLock = eRequired; + if( rc==SQLITE_OK ){ + pLock->eLock = eRequired; + } } } return rc; } @@ -930,15 +935,15 @@ } /* Replace any occurences of "/../" 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; } zPathOut[iOut++] = zPathOut[iIn]; } ADDED test/async3.test Index: test/async3.test ================================================================== --- /dev/null +++ test/async3.test @@ -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