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

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

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 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/tempdb.test ('k') | third_party/sqlite/src/test/tempfault.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/tempdb2.test
diff --git a/third_party/sqlite/src/test/tempdb2.test b/third_party/sqlite/src/test/tempdb2.test
new file mode 100644
index 0000000000000000000000000000000000000000..5f019bd11722a5e4ae0d5309f73e27ba516b73e2
--- /dev/null
+++ b/third_party/sqlite/src/test/tempdb2.test
@@ -0,0 +1,76 @@
+# 2016 March 3
+#
+# 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.
+#
+#***********************************************************************
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tempdb2
+
+db close
+sqlite3 db ""
+
+proc int2str {i} { string range [string repeat "$i." 450] 0 899 }
+db func int2str int2str
+
+#-------------------------------------------------------------------------
+#
+# 1.1: Write a big transaction to the db. One so large that it forces
+# the file to be created and the cache flushed to disk on COMMIT.
+#
+# 1.2: Write a small transaction - one small enough that it remains in
+# memory on COMMIT. All the pages of table [t1] are now dirty.
+#
+# 1.3: Delete the contents of [t1]. This moves all of its leaves to the
+# free-list and causes the btree layer to call PagerDontWrite() on
+# each of them.
+#
+# Then do a big update on table [t2]. So big that the former leaves
+# of [t1] are forced out of the cache. Then roll back the transaction.
+# If the PagerDontWrite() calls are honoured and the data is not written
+# to disk, the update made in test 1.2 will be lost at this point. Or, if
+# they are ignored (as they should be for temp databases), the update
+# will be safely written out to disk before the cache entries are
+# discarded.
+#
+do_execsql_test 1.1 {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=50;
+
+ BEGIN;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, int2str(1));
+ INSERT INTO t1 VALUES(2, int2str(1));
+ INSERT INTO t1 VALUES(3, int2str(1));
+
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ WITH c(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100 )
+ INSERT INTO t2 SELECT x, int2str(x) FROM c;
+ COMMIT;
+
+ PRAGMA lock_status;
+} {main unlocked temp closed}
+
+do_execsql_test 1.2 {
+ UPDATE t1 SET b=int2str(2);
+ SELECT b=int2str(2) FROM t1
+} {1 1 1}
+
+do_execsql_test 1.3 {
+ BEGIN;
+ DELETE FROM t1;
+ UPDATE t2 SET b=int2str(a+1);
+ ROLLBACK;
+}
+
+do_execsql_test 1.4 {
+ SELECT b=int2str(2) FROM t1
+} {1 1 1}
+
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/tempdb.test ('k') | third_party/sqlite/src/test/tempfault.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698