Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: third_party/sqlite/src/test/sharedlock.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2009 July 2 1 # 2009 July 2
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # $Id: sharedlock.test,v 1.1 2009/07/02 17:21:58 danielk1977 Exp $ 12 # $Id: sharedlock.test,v 1.1 2009/07/02 17:21:58 danielk1977 Exp $
13 13
14 set testdir [file dirname $argv0] 14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl 15 source $testdir/tester.tcl
16 set testprefix sharedlock
16 db close 17 db close
17 18
18 ifcapable !shared_cache { 19 ifcapable !shared_cache {
19 finish_test 20 finish_test
20 return 21 return
21 } 22 }
22 23
23 set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 24 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
24 sqlite3 db test.db 25 sqlite3 db test.db
25 sqlite3 db2 test.db 26 sqlite3 db2 test.db
(...skipping 14 matching lines...) Expand all
40 41
41 # This should fail. Connection [db] has a read-lock on t1, which should 42 # This should fail. Connection [db] has a read-lock on t1, which should
42 # prevent connection [db2] from obtaining the write-lock it needs to 43 # prevent connection [db2] from obtaining the write-lock it needs to
43 # modify t1. At one point there was a bug causing the previous INSERT 44 # modify t1. At one point there was a bug causing the previous INSERT
44 # to drop the read-lock belonging to [db]. 45 # to drop the read-lock belonging to [db].
45 if {$a == 2} { catch { db2 eval "INSERT INTO t1 VALUES(4, 'four')" } } 46 if {$a == 2} { catch { db2 eval "INSERT INTO t1 VALUES(4, 'four')" } }
46 } 47 }
47 set res 48 set res
48 } {1 one 2 two 3 three} 49 } {1 one 2 two 3 three}
49 50
51
52 #-------------------------------------------------------------------------
53 # Test that a write-lock is taken on a table when its entire contents
54 # are deleted using the OP_Clear optimization.
55 #
56 foreach {tn delete_sql} {
57 1 { DELETE FROM t2 WHERE 1 }
58 2 { DELETE FROM t2 }
59 } {
60 do_execsql_test 2.1 {
61 DROP TABLE IF EXISTS t2;
62 CREATE TABLE t2(x, y);
63 INSERT INTO t2 VALUES(1, 2);
64 INSERT INTO t2 VALUES(3, 4);
65 }
66
67 do_test 2.2 { execsql { SELECT * FROM t2 } db2 } {1 2 3 4}
68
69 do_execsql_test 2.3 " BEGIN; $delete_sql; "
70
71 do_test 2.4 {
72 catchsql { SELECT * FROM t2 } db2
73 } {1 {database table is locked: t2}}
74
75 do_execsql_test 2.5 COMMIT
76 }
77
78
50 db close 79 db close
51 db2 close 80 db2 close
52
53 sqlite3_enable_shared_cache $::enable_shared_cache 81 sqlite3_enable_shared_cache $::enable_shared_cache
54 finish_test 82 finish_test
55
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698