SQLite4
Check-in [3674a5075c]
Not logged in

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

Overview
Comment:Add more simple inter-process locking tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3674a5075c444e05cfb355f4b9b2ca448030861b
User & Date: dan 2012-09-05 19:10:57
Context
2012-09-08
20:08
Add lsm.wiki. check-in: 9a239a8516 user: dan tags: trunk
2012-09-05
19:10
Add more simple inter-process locking tests. check-in: 3674a5075c user: dan tags: trunk
18:52
Fix a bug in the lsm_unix.c xLock method. check-in: e50e06e52c user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/mc1.test.

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
source $testdir/tester.tcl
source $testdir/lock_common.tcl
set testprefix mc1


do_multiclient_test tn {


  do_test 1.$tn.1 { 
    sql1 { CREATE TABLE t1(a PRIMARY KEY, b) } 
    sql1 { INSERT INTO t1 VALUES(1, 2) }
    sql2 { SELECT * FROM t1 }
  } {1 2}

  do_test 1.$tn.2 { file size test.db } 0


  do_test 1.$tn.3 {
    sql2 { BEGIN; INSERT INTO t1 VALUES(2, 4); }
    sql1 { SELECT * FROM t1 }
  } {1 2}



  do_test 1.$tn.4 {
breakpoint
    csql1 { INSERT INTO t1 VALUES(3, 6) }
  } {1 {database is locked}}





































}

finish_test









>








>





>
>

<



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




<
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
73
74
75
76
77
78
79
80
81
82

source $testdir/tester.tcl
source $testdir/lock_common.tcl
set testprefix mc1


do_multiclient_test tn {

  # Test that connection 2 can see changes made by connection 1.
  do_test 1.$tn.1 { 
    sql1 { CREATE TABLE t1(a PRIMARY KEY, b) } 
    sql1 { INSERT INTO t1 VALUES(1, 2) }
    sql2 { SELECT * FROM t1 }
  } {1 2}

  do_test 1.$tn.2 { file size test.db } 0

  # Connection 1 does not see uncommitted changes made by connection 2.
  do_test 1.$tn.3 {
    sql2 { BEGIN; INSERT INTO t1 VALUES(2, 4); }
    sql1 { SELECT * FROM t1 }
  } {1 2}

  # Connection 1 cannot write the database while connection 2 has an open
  # write transaction.
  do_test 1.$tn.4 {

    csql1 { INSERT INTO t1 VALUES(3, 6) }
  } {1 {database is locked}}

  # After connection 2 has committed, connection 1 can write again.
  do_test 1.$tn.5 {
    sql2  { COMMIT }
    csql1 { INSERT INTO t1 VALUES(3, 6) }
    sql1  { SELECT * FROM t1 }
  } {1 2 2 4 3 6}

  # Connection 1 does not see changes commited by connection 2 after its
  # read transaction is opened.
  do_test 1.$tn.6 {
    sql1 { BEGIN; SELECT * FROM t1 }
    sql2 { INSERT INTO t1 VALUES(4, 8) }
    sql1  { SELECT * FROM t1 }
  } {1 2 2 4 3 6}

  # Once the read transaction is closed, connection 1's next read transaction
  # does see changes made during the previous one.
  do_test 1.$tn.7 {
    sql1 { COMMIT; SELECT * FROM t1 }
  } {1 2 2 4 3 6 4 8}

  # Connection 1 cannot write from an out-of-date snapshot.
  do_test 1.$tn.8 {
    sql1  { BEGIN; SELECT * FROM t1 }
    sql2  { INSERT INTO t1 VALUES(5, 10) }
    csql1 { INSERT INTO t1 VALUES(6, 12) }
  } {1 {database is locked}}

  # But it can from a new snapshot.
  do_test 1.$tn.9 {
    sql1  { COMMIT; BEGIN }
    sql1  { INSERT INTO t1 VALUES(6, 12) }
    sql1  { SELECT * FROM t1 }
  } {1 2 2 4 3 6 4 8 5 10 6 12}

  do_test 1.$tn.10 { file size test.db } 0
}

finish_test


Changes to test/permutations.test.

133
134
135
136
137
138
139

140
141
142
143
144
145
146

test_suite "src4" -prefix "" -description {
} -files {
  simple.test simple2.test
  log1.test log2.test log3.test 
  csr1.test
  ckpt1.test


  aggerror.test
  attach.test
  autoindex1.test
  badutf.test
  between.test
  bigrow.test







>







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

test_suite "src4" -prefix "" -description {
} -files {
  simple.test simple2.test
  log1.test log2.test log3.test 
  csr1.test
  ckpt1.test
  mc1.test

  aggerror.test
  attach.test
  autoindex1.test
  badutf.test
  between.test
  bigrow.test