/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/test_async.c.

617
618
619
620
621
622
623

624
625

626
627
628



629
630
631
632

633
634
635
636
637
638
639
...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
    for(pIter=pLock->pList; pIter; pIter=pIter->pNext){
      assert(pIter->eAsyncLock>=pIter->eLock);
      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(eRequired<pLock->eLock){
      rc = sqlite3OsUnlock(pLock->pFile, eRequired);
    }



    if( rc==SQLITE_OK ){
      pLock->eLock = eRequired;
    }
  }


  return rc;
}

/*
** The following two methods - asyncLock() and asyncUnlock() - are used
** to obtain and release locks on database files opened with the
................................................................................
        iIn++;
        continue;
      }

      /* Replace any occurences of "<path-component>/../" with "" */
      if( iOut>0 && iIn<=(nPathOut-4) 
       && zPathOut[iIn]=='/' && zPathOut[iIn+1]=='.' 
       && zPathOut[iIn+2]=='.' && zPathOut[iIn+2]=='/'
      ){
        iIn += 3;
        iOut--;
        for( ; iOut>0 && zPathOut[iOut]!='/'; iOut--);
        continue;
      }

      zPathOut[iOut++] = zPathOut[iIn];
    }
    zPathOut[iOut] = '\0';
  }







>


>
|
<
|
>
>
>




>







 







|



|







617
618
619
620
621
622
623
624
625
626
627
628

629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
...
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
    for(pIter=pLock->pList; pIter; pIter=pIter->pNext){
      assert(pIter->eAsyncLock>=pIter->eLock);
      if( pIter->eAsyncLock>eRequired ){
        eRequired = pIter->eAsyncLock;
        assert(eRequired>=0 && eRequired<=SQLITE_LOCK_EXCLUSIVE);
      }
    }

    if( eRequired>pLock->eLock ){
      rc = sqlite3OsLock(pLock->pFile, 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;
      }
    }
  }

  return rc;
}

/*
** The following two methods - asyncLock() and asyncUnlock() - are used
** to obtain and release locks on database files opened with the
................................................................................
        iIn++;
        continue;
      }

      /* Replace any occurences of "<path-component>/../" with "" */
      if( iOut>0 && iIn<=(nPathOut-4) 
       && zPathOut[iIn]=='/' && zPathOut[iIn+1]=='.' 
       && zPathOut[iIn+2]=='.' && zPathOut[iIn+3]=='/'
      ){
        iIn += 3;
        iOut--;
        for( ; iOut>0 && zPathOut[iOut-1]!='/'; iOut--);
        continue;
      }

      zPathOut[iOut++] = zPathOut[iIn];
    }
    zPathOut[iOut] = '\0';
  }

Added test/async3.test.

















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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