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

Unified Diff: third_party/sqlite/src/test/wal6.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/wal5.test ('k') | third_party/sqlite/src/test/wal64k.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/wal6.test
diff --git a/third_party/sqlite/src/test/wal6.test b/third_party/sqlite/src/test/wal6.test
index 6fae48e9eabab325d2ac38958fea88896980787a..2498907ea908549f9ecc636b0ba1ba3170565fa3 100644
--- a/third_party/sqlite/src/test/wal6.test
+++ b/third_party/sqlite/src/test/wal6.test
@@ -14,6 +14,7 @@
#
set testdir [file dirname $argv0]
+set testprefix wal6
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
@@ -29,62 +30,168 @@ forcedelete test.db
set all_journal_modes {delete persist truncate memory off}
foreach jmode $all_journal_modes {
- do_test wal6-1.0.$jmode {
+ do_test wal6-1.0.$jmode {
sqlite3 db test.db
execsql "PRAGMA journal_mode = $jmode;"
- } $jmode
+ } $jmode
- do_test wal6-1.1.$jmode {
- execsql {
- CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
- INSERT INTO t1 VALUES(1,2);
- SELECT * FROM t1;
- }
- } {1 2}
+ do_test wal6-1.1.$jmode {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t1;
+ }
+ } {1 2}
# Under Windows, you'll get an error trying to delete
-# a file this is already opened. For now, make sure
-# we get that error, then close the first connection
+# a file this is already opened. Close the first connection
# so the other tests work.
if {$tcl_platform(platform)=="windows"} {
if {$jmode=="persist" || $jmode=="truncate"} {
- do_test wal6-1.2.$jmode.win {
- sqlite3 db2 test.db
- catchsql {
- PRAGMA journal_mode=WAL;
- } db2
- } {1 {disk I/O error}}
- db2 close
- db close
+ db close
}
}
- do_test wal6-1.2.$jmode {
- sqlite3 db2 test.db
- execsql {
- PRAGMA journal_mode=WAL;
- INSERT INTO t1 VALUES(3,4);
- SELECT * FROM t1 ORDER BY a;
- } db2
- } {wal 1 2 3 4}
+ do_test wal6-1.2.$jmode {
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA journal_mode=WAL;
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1 ORDER BY a;
+ } db2
+ } {wal 1 2 3 4}
if {$tcl_platform(platform)=="windows"} {
if {$jmode=="persist" || $jmode=="truncate"} {
- sqlite3 db test.db
+ sqlite3 db test.db
}
}
- do_test wal6-1.3.$jmode {
- execsql {
- SELECT * FROM t1 ORDER BY a;
- }
- } {1 2 3 4}
+ do_test wal6-1.3.$jmode {
+ execsql {
+ SELECT * FROM t1 ORDER BY a;
+ }
+ } {1 2 3 4}
- db close
- db2 close
+ db close
+ db2 close
forcedelete test.db
}
+#-------------------------------------------------------------------------
+# Test that SQLITE_BUSY_SNAPSHOT is returned as expected.
+#
+reset_db
+sqlite3 db2 test.db
+
+do_execsql_test 2.1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b TEXT);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ BEGIN;
+ SELECT * FROM t1;
+} {wal 1 one 2 two}
+
+do_test 2.2 {
+ execsql {
+ SELECT * FROM t1;
+ INSERT INTO t1 VALUES(3, 'three');
+ } db2
+} {1 one 2 two}
+
+do_catchsql_test 2.3 {
+ INSERT INTO t1 VALUES('x', 'x')
+} {1 {database is locked}}
+
+do_test 2.4 {
+ list [sqlite3_errcode db] [sqlite3_extended_errcode db]
+} {SQLITE_BUSY SQLITE_BUSY_SNAPSHOT}
+
+do_execsql_test 2.5 {
+ SELECT * FROM t1;
+ COMMIT;
+ INSERT INTO t1 VALUES('x', 'x')
+} {1 one 2 two}
+
+proc test3 {prefix} {
+ do_test $prefix.1 {
+ execsql { SELECT count(*) FROM t1 }
+ } {0}
+ do_test $prefix.2 {
+ execsql { INSERT INTO t1 VALUES('x', 'x') } db2
+ } {}
+ do_test $prefix.3 {
+ execsql { INSERT INTO t1 VALUES('y', 'y') }
+ } {}
+ do_test $prefix.4 {
+ execsql { SELECT count(*) FROM t1 }
+ } {2}
+}
+
+do_execsql_test 2.6.1 { DELETE FROM t1 }
+test3 2.6.2
+
+db func test3 test3
+do_execsql_test 2.6.3 { DELETE FROM t1 }
+db eval {SELECT test3('2.6.4')}
+
+do_test 2.x {
+ db2 close
+} {}
+
+#-------------------------------------------------------------------------
+# Check that if BEGIN IMMEDIATE fails, it does not leave the user with
+# an open read-transaction (unless one was already open before the BEGIN
+# IMMEDIATE). Even if there are other active VMs.
+#
+
+proc test4 {prefix} {
+ do_test $prefix.1 {
+ catchsql { BEGIN IMMEDIATE }
+ } {1 {database is locked}}
+
+ do_test $prefix.2 {
+ execsql { COMMIT } db2
+ } {}
+
+ do_test $prefix.3 {
+ execsql { BEGIN IMMEDIATE }
+ } {}
+ do_test $prefix.4 {
+ execsql { COMMIT }
+ } {}
+}
+
+reset_db
+sqlite3 db2 test.db
+do_execsql_test 3.1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE ab(a PRIMARY KEY, b);
+} {wal}
+
+do_test 3.2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO ab VALUES(1, 2);
+ } db2
+} {}
+test4 3.2.2
+
+db func test4 test4
+do_test 3.3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO ab VALUES(3, 4);
+ } db2
+} {}
+
+db eval {SELECT test4('3.3.2')}
+
+do_test 3.x {
+ db2 close
+} {}
+
finish_test
« no previous file with comments | « third_party/sqlite/src/test/wal5.test ('k') | third_party/sqlite/src/test/wal64k.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698