/ Check-in [0e070067]
Login

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

Overview
Comment:Some test cases for read locks (CVS 1505)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e07006704cd441f91d5fadbf3b644fd20da79bd
User & Date: danielk1977 2004-05-31 12:34:54
Context
2004-05-31
15:06
Website redesign in preparation for adding version 3 documentation. (CVS 1506) check-in: 2052911b user: drh tags: trunk
12:34
Some test cases for read locks (CVS 1505) check-in: 0e070067 user: danielk1977 tags: trunk
11:51
Use read-only transactions. (CVS 1504) check-in: 6c100887 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to test/attach2.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing the ATTACH and DETACH commands
    13     13   # and related functionality.
    14     14   #
    15         -# $Id: attach2.test,v 1.10 2004/05/31 08:26:49 danielk1977 Exp $
           15  +# $Id: attach2.test,v 1.11 2004/05/31 12:34:54 danielk1977 Exp $
    16     16   #
    17     17   
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # Ticket #354
................................................................................
   142    142     set rc
   143    143   } {0}
   144    144   
   145    145   db close
   146    146   for {set i 2} {$i<=15} {incr i} {
   147    147     catch {db$i close}
   148    148   }
   149         -file delete -force test2.db
          149  +
          150  +# Tests attach2-4.* test that read-locks work correctly with attached
          151  +# databases.
          152  +do_test attach2-4.1 {
          153  +  sqlite db test.db
          154  +  sqlite db2 test.db
          155  +  execsql {ATTACH 'test2.db' as file2}
          156  +  execsql {ATTACH 'test2.db' as file2} db2
          157  +} {}
          158  +
          159  +do_test attach2-4.2 {
          160  +  # Handle 'db' read-locks the main file
          161  +  execsql {BEGIN}
          162  +  execsql {SELECT * FROM t1}
          163  +} {}
          164  +do_test attach2-4.3 {
          165  +  execsql {SELECT * FROM t1} db2
          166  +} {}
          167  +do_test attach2-4.4 {
          168  +  set r [catch { 
          169  +    execsql {
          170  +      INSERT INTO t1 VALUES(1, 2)
          171  +    } db2 
          172  +  } msg]
          173  +  list $r $msg
          174  +} {1 {database is locked}}
          175  +do_test attach2-4.5 {
          176  +  # Handle 'db2' write-locks file2
          177  +  execsql {BEGIN} db2
          178  +  execsql {INSERT INTO file2.t1 VALUES(1, 2)} db2
          179  +} {}
          180  +do_test attach2-4.6 {
          181  +  set r [catch { 
          182  +    execsql {
          183  +      SELECT * FROM file2.t1;
          184  +    } 
          185  +  } msg]
          186  +  list $r $msg
          187  +} {1 {database is locked}}
          188  +do_test attach2-4.7 {
          189  +  # Ensure handle 'db' retains the lock on the main file after
          190  +  # failing to obtain a read-lock on file2.
          191  +  set r [catch { 
          192  +    execsql {
          193  +      INSERT INTO t1 VALUES(1, 2)
          194  +    } db2 
          195  +  } msg]
          196  +  list $r $msg
          197  +} {1 {database is locked}}
          198  +do_test attach2-4.8 {
          199  +  # Read lock the main file with db2. Now both handles have a read lock
          200  +  # on the main file, db2 has a write-lock on file2.
          201  +  execsql {SELECT * FROM t1} db2
          202  +} {}
          203  +do_test attach2-4.9 {
          204  +  # Try to upgrade the handle 'db' lock.
          205  +  set r [catch { 
          206  +    execsql {
          207  +      INSERT INTO t1 VALUES(1, 2)
          208  +    } 
          209  +  } msg]
          210  +  list $r $msg
          211  +} {1 {database is locked}}
          212  +do_test attach2-4.10 {
          213  +  # Release the locks held by handle 'db2'
          214  +  execsql {COMMIT} db2
          215  +} {}
          216  +do_test attach2-4.11 {
          217  +  execsql {SELECT * FROM file2.t1}
          218  +} {1 2}
          219  +do_test attach2-4.12 {
          220  +  execsql {INSERT INTO t1 VALUES(1, 2)}
          221  +} {}
          222  +do_test attach2-4.13 {
          223  +  # Release the locks held by handle 'db'
          224  +  execsql {ROLLBACK}
          225  +} {}
          226  +do_test attach2-4.14 {
          227  +  execsql {SELECT * FROM t1} db2
          228  +} {}
   150    229   
          230  +db close
          231  +db2 close
          232  +file delete -force test2.db
   151    233   
   152    234   finish_test
          235  +
          236  +
          237  +
          238  +
          239  +