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

Changes to test/attach2.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
142
143
144
145
146
147
148
149
150








151











































































152





#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach2.test,v 1.10 2004/05/31 08:26:49 danielk1977 Exp $
#


set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Ticket #354
................................................................................
  set rc
} {0}

db close
for {set i 2} {$i<=15} {incr i} {
  catch {db$i close}
}
file delete -force test2.db





















































































finish_test












|







 







<

>
>
>
>
>
>
>
>

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

>
>
>
>
>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
142
143
144
145
146
147
148

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach2.test,v 1.11 2004/05/31 12:34:54 danielk1977 Exp $
#


set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Ticket #354
................................................................................
  set rc
} {0}

db close
for {set i 2} {$i<=15} {incr i} {
  catch {db$i close}
}


# Tests attach2-4.* test that read-locks work correctly with attached
# databases.
do_test attach2-4.1 {
  sqlite db test.db
  sqlite db2 test.db
  execsql {ATTACH 'test2.db' as file2}
  execsql {ATTACH 'test2.db' as file2} db2
} {}

do_test attach2-4.2 {
  # Handle 'db' read-locks the main file
  execsql {BEGIN}
  execsql {SELECT * FROM t1}
} {}
do_test attach2-4.3 {
  execsql {SELECT * FROM t1} db2
} {}
do_test attach2-4.4 {
  set r [catch { 
    execsql {
      INSERT INTO t1 VALUES(1, 2)
    } db2 
  } msg]
  list $r $msg
} {1 {database is locked}}
do_test attach2-4.5 {
  # Handle 'db2' write-locks file2
  execsql {BEGIN} db2
  execsql {INSERT INTO file2.t1 VALUES(1, 2)} db2
} {}
do_test attach2-4.6 {
  set r [catch { 
    execsql {
      SELECT * FROM file2.t1;
    } 
  } msg]
  list $r $msg
} {1 {database is locked}}
do_test attach2-4.7 {
  # Ensure handle 'db' retains the lock on the main file after
  # failing to obtain a read-lock on file2.
  set r [catch { 
    execsql {
      INSERT INTO t1 VALUES(1, 2)
    } db2 
  } msg]
  list $r $msg
} {1 {database is locked}}
do_test attach2-4.8 {
  # Read lock the main file with db2. Now both handles have a read lock
  # on the main file, db2 has a write-lock on file2.
  execsql {SELECT * FROM t1} db2
} {}
do_test attach2-4.9 {
  # Try to upgrade the handle 'db' lock.
  set r [catch { 
    execsql {
      INSERT INTO t1 VALUES(1, 2)
    } 
  } msg]
  list $r $msg
} {1 {database is locked}}
do_test attach2-4.10 {
  # Release the locks held by handle 'db2'
  execsql {COMMIT} db2
} {}
do_test attach2-4.11 {
  execsql {SELECT * FROM file2.t1}
} {1 2}
do_test attach2-4.12 {
  execsql {INSERT INTO t1 VALUES(1, 2)}
} {}
do_test attach2-4.13 {
  # Release the locks held by handle 'db'
  execsql {ROLLBACK}
} {}
do_test attach2-4.14 {
  execsql {SELECT * FROM t1} db2
} {}

db close
db2 close
file delete -force test2.db

finish_test