Author: eelco
Date: Wed Sep  1 11:36:22 2010
New Revision: 23594
URL: https://svn.nixos.org/websvn/nix/?rev=23594&sc=1

Log:
* Only do "pragma journal_mode = ..." if the current journal mode
  differs from the desired mode.  There is an open SQLite ticket
  `Executing "PRAGMA journal_mode" may delete journal file while it is
  in use.'

Modified:
   nix/branches/sqlite/src/libstore/local-store.cc

Modified: nix/branches/sqlite/src/libstore/local-store.cc
==============================================================================
--- nix/branches/sqlite/src/libstore/local-store.cc     Wed Sep  1 11:18:39 
2010        (r23593)
+++ nix/branches/sqlite/src/libstore/local-store.cc     Wed Sep  1 11:36:22 
2010        (r23594)
@@ -303,7 +303,16 @@
        The downside is that it doesn't work over NFS, so allow
        truncate mode alternatively. */
     string mode = queryBoolSetting("use-sqlite-wal", true) ? "wal" : 
"truncate";
-    if (sqlite3_exec(db, ("pragma main.journal_mode = " + mode + ";").c_str(), 
0, 0, 0) != SQLITE_OK)
+    string prevMode;
+    {
+        SQLiteStmt stmt;
+        stmt.create(db, "pragma main.journal_mode;");
+        if (sqlite3_step(stmt) != SQLITE_ROW)
+            throw SQLiteError(db, "querying journal mode");
+        prevMode = string((const char *) sqlite3_column_text(stmt, 0));
+    }
+    if (prevMode != mode &&
+        sqlite3_exec(db, ("pragma main.journal_mode = " + mode + ";").c_str(), 
0, 0, 0) != SQLITE_OK)
         throw SQLiteError(db, "setting journal mode");
 
     /* Increase the auto-checkpoint interval to 8192 pages.  This
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to