Debian Codegraph @

test/memdb2.test

raw
1 # 2022-12-05
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 # This file implements regression tests for SQLite library. The
12 # focus of this file is the "memdb" VFS
13 #
14
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix memdb2
18 do_not_use_codec
19
20 ifcapable !deserialize {
21 finish_test
22 return
23 }
24
25 db close
26
27 #-------------------------------------------------------------------------
28 # Test that when using a memdb database, it is not possible to upgrade
29 # to an EXCLUSIVE lock if some other client is holding SHARED.
30 #
31 foreach {tn fname} {
32 1 file:/test.db?vfs=memdb
33 2 file:\\test.db?vfs=memdb
34 } {
35 if {$tn==2} breakpoint
36 sqlite3 db $fname -uri 1
37 sqlite3 db2 $fname -uri 1
38
39
40 do_execsql_test 1.$tn.1 {
41 CREATE TABLE t1(x, y);
42 INSERT INTO t1 VALUES(1, 2);
43 }
44
45 do_execsql_test -db db2 1.$tn.2 {
46 BEGIN;
47 SELECT * FROM t1;
48 } {1 2}
49
50 do_execsql_test 1.$tn.3 {
51 BEGIN;
52 INSERT INTO t1 VALUES(3, 4);
53 }
54
55 do_catchsql_test 1.$tn.4 {
56 COMMIT
57 } {1 {database is locked}}
58
59 do_execsql_test -db db2 1.$tn.5 {
60 SELECT * FROM t1;
61 END;
62 } {1 2}
63
64 do_execsql_test 1.$tn.6 {
65 COMMIT
66 } {}
67
68 do_execsql_test -db db2 1.$tn.7 {
69 SELECT * FROM t1
70 } {1 2 3 4}
71
72 db close
73 db2 close
74 }
75
76 finish_test