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/snapshot_fault.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/snapshot2.test ('k') | third_party/sqlite/src/test/sort.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/snapshot_fault.test
diff --git a/third_party/sqlite/src/test/snapshot_fault.test b/third_party/sqlite/src/test/snapshot_fault.test
index 3ac13daefd42400fb7060b7ad49562dfac45c27f..5c6cf40a6f1d19ab4f7e66875dcc1543a6cb03c5 100644
--- a/third_party/sqlite/src/test/snapshot_fault.test
+++ b/third_party/sqlite/src/test/snapshot_fault.test
@@ -146,7 +146,7 @@ do_faultsim_test 3.0 -prep {
error $msg
}
} -test {
- faultsim_test_result {0 {}} {1 SQLITE_IOERR} \
+ faultsim_test_result {0 {}} {1 SQLITE_IOERR} {1 SQLITE_NOMEM} \
{1 SQLITE_IOERR_NOMEM} {1 SQLITE_IOERR_READ}
if {$testrc==0} {
set res [db eval {
@@ -159,6 +159,68 @@ do_faultsim_test 3.0 -prep {
sqlite3_snapshot_free $::snapshot
}
+#-------------------------------------------------------------------------
+# Test the handling of faults that occur within sqlite3_snapshot_recover().
+#
+reset_db
+do_execsql_test 4.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(zzz);
+ INSERT INTO t1 VALUES('abc');
+ INSERT INTO t1 VALUES('def');
+} {wal}
+faultsim_save_and_close
+
+do_test 4.0.1 {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+ sqlite3_snapshot_recover db main
+} {}
+db close
+
+do_faultsim_test 4.0 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+} -body {
+ sqlite3_snapshot_recover db main
+} -test {
+ faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM}
+}
+
+# The following test cases contrive to call sqlite3_snapshot_recover()
+# before all pages of the *-shm file have been mapped. This tests an
+# extra branch of error handling logic in snapshot_recover().
+#
+reset_db
+do_execsql_test 4.1.0 {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = wal;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE t1(zzz);
+ INSERT INTO t1 VALUES(randomblob( 500 * 9500 ));
+ PRAGMA user_version = 211;
+} {wal 0}
+
+do_test 4.1.1 {
+ list [file size test.db-shm] [file size test.db]
+} {98304 512}
+
+faultsim_save_and_close
+do_faultsim_test 4.1 -faults shm* -prep {
+ catch { db2 close }
+ catch { db close }
+ faultsim_restore_and_reopen
+ sqlite3 db2 test.db
+ db2 eval { SELECT * FROM sqlite_master }
+ db eval BEGIN
+ sqlite3_snapshot_get_blob db main
+ db eval COMMIT
+} -body {
+ sqlite3_snapshot_recover db main
+} -test {
+ faultsim_test_result {0 {}} {1 SQLITE_IOERR}
+}
+
finish_test
« no previous file with comments | « third_party/sqlite/src/test/snapshot2.test ('k') | third_party/sqlite/src/test/sort.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698