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

Unified Diff: third_party/sqlite/sqlite-src-3080704/test/pager4.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
Index: third_party/sqlite/sqlite-src-3080704/test/pager4.test
diff --git a/third_party/sqlite/sqlite-src-3080704/test/pager4.test b/third_party/sqlite/sqlite-src-3080704/test/pager4.test
new file mode 100644
index 0000000000000000000000000000000000000000..2cf73d1b1752293f4cdf4d2038e041f5186a7ec3
--- /dev/null
+++ b/third_party/sqlite/sqlite-src-3080704/test/pager4.test
@@ -0,0 +1,99 @@
+# 2013-12-06
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests for the SQLITE_READONLY_DBMOVED error condition: the database file
+# is unlinked or renamed out from under SQLite.
+#
+
+if {$tcl_platform(platform)!="unix"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+# Create a database file for testing
+#
+do_execsql_test pager4-1.1 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(673,'stone','philips');
+ SELECT * FROM t1;
+} {673 stone philips}
+
+# After renaming the database file while it is open, one can still
+# read from the database, but writing returns a READONLY error.
+#
+file delete -force test-xyz.db
+file rename test.db test-xyz.db
+do_catchsql_test pager4-1.2 {
+ SELECT * FROM t1;
+} {0 {673 stone philips}}
+do_catchsql_test pager4-1.3 {
+ UPDATE t1 SET a=537;
+} {1 {attempt to write a readonly database}}
+
+# Creating a different database file with the same name of the original
+# is detected and still leaves the database read-only.
+#
+sqlite3 db2 test.db
+db2 eval {CREATE TABLE t2(x,y,z)}
+do_catchsql_test pager4-1.4 {
+ UPDATE t1 SET a=948;
+} {1 {attempt to write a readonly database}}
+
+# Changing the name back clears the READONLY error
+#
+db2 close
+file delete -force test.db
+file rename test-xyz.db test.db
+do_catchsql_test pager4-1.5 {
+ SELECT * FROM t1;
+} {0 {673 stone philips}}
+do_catchsql_test pager4-1.6 {
+ UPDATE t1 SET a=537;
+ SELECT * FROM t1;
+} {0 {537 stone philips}}
+
+# We can write to a renamed database if journal_mode=OFF or
+# journal_mode=MEMORY.
+#
+file rename test.db test-xyz.db
+do_catchsql_test pager4-1.7 {
+ PRAGMA journal_mode=OFF;
+ UPDATE t1 SET a=107;
+ SELECT * FROM t1;
+} {0 {off 107 stone philips}}
+do_catchsql_test pager4-1.8 {
+ PRAGMA journal_mode=MEMORY;
+ UPDATE t1 SET b='magpie';
+ SELECT * FROM t1;
+} {0 {memory 107 magpie philips}}
+
+# Any other journal mode gives a READONLY error
+#
+do_catchsql_test pager4-1.9 {
+ PRAGMA journal_mode=DELETE;
+ UPDATE t1 SET c='jaguar';
+} {1 {attempt to write a readonly database}}
+do_catchsql_test pager4-1.10 {
+ PRAGMA journal_mode=TRUNCATE;
+ UPDATE t1 SET c='jaguar';
+} {1 {attempt to write a readonly database}}
+do_catchsql_test pager4-1.11 {
+ PRAGMA journal_mode=PERSIST;
+ UPDATE t1 SET c='jaguar';
+} {1 {attempt to write a readonly database}}
+
+
+finish_test
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/pager3.test ('k') | third_party/sqlite/sqlite-src-3080704/test/pagerfault.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698