blob: 286bfc3f8493200745b2ab56a6f34eb7a0c5d531 [file] [log] [blame]
dan49d40262022-12-05 14:20:54 +00001# 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
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
dan118b53b2022-12-15 18:56:12 +000017set testprefix memdb2
dan49d40262022-12-05 14:20:54 +000018do_not_use_codec
19
20ifcapable !deserialize {
21 finish_test
22 return
23}
24
25db 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#
dan118b53b2022-12-15 18:56:12 +000031foreach {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
dan49d40262022-12-05 14:20:54 +000038
dan118b53b2022-12-15 18:56:12 +000039
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
dan49d40262022-12-05 14:20:54 +000074}
75
dan49d40262022-12-05 14:20:54 +000076finish_test
dan118b53b2022-12-15 18:56:12 +000077