/ Check-in [0a87a854]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Test that the asynchronous backend works with components like "." or ".." in the path to the database file. (CVS 4403)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0a87a854226ccea920484613dd7f7873e673c96e
User & Date: danielk1977 2007-09-05 14:32:25
Context
2007-09-05
16:54
Fix error handling (malloc and io errors) in the asynchronous backend. (CVS 4404) check-in: 80a44382 user: danielk1977 tags: trunk
14:32
Test that the asynchronous backend works with components like "." or ".." in the path to the database file. (CVS 4403) check-in: 0a87a854 user: danielk1977 tags: trunk
14:30
Restore the sqlite3_mutex_try() optimization on winNT systems. (CVS 4402) check-in: 3aace2fa user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_async.c.

   617    617       for(pIter=pLock->pList; pIter; pIter=pIter->pNext){
   618    618         assert(pIter->eAsyncLock>=pIter->eLock);
   619    619         if( pIter->eAsyncLock>eRequired ){
   620    620           eRequired = pIter->eAsyncLock;
   621    621           assert(eRequired>=0 && eRequired<=SQLITE_LOCK_EXCLUSIVE);
   622    622         }
   623    623       }
          624  +
   624    625       if( eRequired>pLock->eLock ){
   625    626         rc = sqlite3OsLock(pLock->pFile, eRequired);
   626         -    }else if(eRequired<pLock->eLock){
          627  +      if( rc==SQLITE_OK ){
          628  +        pLock->eLock = eRequired;
          629  +      }
          630  +    }
          631  +    else if( eRequired<pLock->eLock && eRequired<=SQLITE_LOCK_SHARED ){
   627    632         rc = sqlite3OsUnlock(pLock->pFile, eRequired);
   628         -    }
   629         -    if( rc==SQLITE_OK ){
   630         -      pLock->eLock = eRequired;
          633  +      if( rc==SQLITE_OK ){
          634  +        pLock->eLock = eRequired;
          635  +      }
   631    636       }
   632    637     }
   633    638   
   634    639     return rc;
   635    640   }
   636    641   
   637    642   /*
................................................................................
   928    933           iIn++;
   929    934           continue;
   930    935         }
   931    936   
   932    937         /* Replace any occurences of "<path-component>/../" with "" */
   933    938         if( iOut>0 && iIn<=(nPathOut-4) 
   934    939          && zPathOut[iIn]=='/' && zPathOut[iIn+1]=='.' 
   935         -       && zPathOut[iIn+2]=='.' && zPathOut[iIn+2]=='/'
          940  +       && zPathOut[iIn+2]=='.' && zPathOut[iIn+3]=='/'
   936    941         ){
   937    942           iIn += 3;
   938    943           iOut--;
   939         -        for( ; iOut>0 && zPathOut[iOut]!='/'; iOut--);
          944  +        for( ; iOut>0 && zPathOut[iOut-1]!='/'; iOut--);
   940    945           continue;
   941    946         }
   942    947   
   943    948         zPathOut[iOut++] = zPathOut[iIn];
   944    949       }
   945    950       zPathOut[iOut] = '\0';
   946    951     }

Added test/async3.test.

            1  +# 2007 September 5
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# The focus of this file is testing the code in test_async.c.
           13  +# Specifically, it tests that the xFullPathname() method of
           14  +# of the asynchronous vfs works correctly.
           15  +#
           16  +# $Id: async3.test,v 1.1 2007/09/05 14:32:25 danielk1977 Exp $
           17  +
           18  +set testdir [file dirname $argv0]
           19  +source $testdir/tester.tcl
           20  +
           21  +if { [info commands sqlite3async_enable]==""  } {
           22  +  # The async logic is not built into this system
           23  +  puts "Skipping async3 tests: not compiled with required features"
           24  +  finish_test
           25  +  return
           26  +}
           27  +
           28  +db close
           29  +sqlite3async_enable 1
           30  +sqlite3async_start
           31  +
           32  +set paths {
           33  +  chocolate/banana/vanilla/file.db
           34  +  chocolate//banana/vanilla/file.db
           35  +  chocolate/./banana//vanilla/file.db
           36  +  chocolate/banana/./vanilla/file.db
           37  +  chocolate/banana/../banana/vanilla/file.db
           38  +  chocolate/banana/./vanilla/extra_bit/../file.db
           39  +}
           40  +
           41  +do_test async3-1.0 {
           42  +  file mkdir [file join chocolate banana vanilla]
           43  +  file delete -force chocolate/banana/vanilla/file.db
           44  +  file delete -force chocolate/banana/vanilla/file.db-journal
           45  +} {}
           46  +do_test async3-1.1 {
           47  +  sqlite3 db chocolate/banana/vanilla/file.db
           48  +  execsql {
           49  +    CREATE TABLE abc(a, b, c);
           50  +    BEGIN;
           51  +    INSERT INTO abc VALUES(1, 2, 3);
           52  +  }
           53  +} {}
           54  +
           55  +set N 2
           56  +foreach p $paths {
           57  +  sqlite3 db2 $p
           58  +  do_test async3-1.$N.1 {
           59  +    execsql {SELECT * FROM abc} db2
           60  +  } {}
           61  +  do_test async3-1.$N.2 {
           62  +    catchsql {INSERT INTO abc VALUES(4, 5, 6)} db2
           63  +  } {1 {database is locked}}
           64  +  db2 close
           65  +  incr N
           66  +}
           67  +
           68  +db close
           69  +sqlite3async_halt idle
           70  +sqlite3async_wait
           71  +sqlite3async_enable 0
           72  +finish_test