about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-02-18T13·48+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-02-18T13·48+0000
commita053d2d8e53f2967c64ab2b204727e4c27f06c0e (patch)
tree31e40ad0c7777ee4782ffb5accd7097128877c55 /src/libstore/local-store.cc
parentdbddac0fe91072b402ccb3801c952e3159f0cba4 (diff)
* Add the deriver to the ValidPaths table. In principle we could now
  store all the derivers of a path efficiently.  But that opens a big
  can of worms with respect to garbage collector semantics.

Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 03c5d76b37..35391f3aaf 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1217,19 +1217,14 @@ void LocalStore::upgradeStore6()
 
     PathSet validPaths = queryValidPaths();
 
+    if (sqlite3_exec(db, "begin;", 0, 0, 0) != SQLITE_OK)
+        throw SQLiteError(db, "running `begin' command");
+
     sqlite3_stmt * registerStmt;
-    if (sqlite3_prepare_v2(db, "insert into ValidPaths (path, hash, registrationTime) values (?, ?, ?);",
+    if (sqlite3_prepare_v2(db, "insert into ValidPaths (path, hash, registrationTime, deriver) values (?, ?, ?, ?);",
             -1, &registerStmt, 0) != SQLITE_OK)
         throw SQLiteError(db, "creating statement");
     
-    sqlite3_stmt * addRefStmt;
-    if (sqlite3_prepare_v2(db, "insert into Refs (referrer, reference) values (?, ?);",
-            -1, &addRefStmt, 0) != SQLITE_OK)
-        throw SQLiteError(db, "creating statement");
-    
-    if (sqlite3_exec(db, "begin;", 0, 0, 0) != SQLITE_OK)
-        throw SQLiteError(db, "running `begin' command");
-
     std::map<Path, sqlite3_int64> pathToId;
     
     foreach (PathSet::iterator, i, validPaths) {
@@ -1244,6 +1239,13 @@ void LocalStore::upgradeStore6()
             throw SQLiteError(db, "binding argument 2");
         if (sqlite3_bind_int(registerStmt, 3, info.registrationTime) != SQLITE_OK)
             throw SQLiteError(db, "binding argument 3");
+        if (info.deriver != "") {
+            if (sqlite3_bind_text(registerStmt, 4, info.deriver.c_str(), -1, SQLITE_TRANSIENT) != SQLITE_OK)
+                throw SQLiteError(db, "binding argument 4");
+        } else {
+            if (sqlite3_bind_null(registerStmt, 4) != SQLITE_OK)
+                throw SQLiteError(db, "binding argument 4");
+        }
         if (sqlite3_step(registerStmt) != SQLITE_DONE)
             throw SQLiteError(db, "registering valid path in database");
 
@@ -1252,8 +1254,16 @@ void LocalStore::upgradeStore6()
         std::cerr << ".";
     }
 
+    if (sqlite3_finalize(registerStmt) != SQLITE_OK)
+        throw SQLiteError(db, "finalizing statement");
+
     std::cerr << "|";
     
+    sqlite3_stmt * addRefStmt;
+    if (sqlite3_prepare_v2(db, "insert into Refs (referrer, reference) values (?, ?);",
+            -1, &addRefStmt, 0) != SQLITE_OK)
+        throw SQLiteError(db, "creating statement");
+    
     foreach (PathSet::iterator, i, validPaths) {
         ValidPathInfo info = queryPathInfo(*i, true);
         
@@ -1278,9 +1288,6 @@ void LocalStore::upgradeStore6()
     if (sqlite3_exec(db, "commit;", 0, 0, 0) != SQLITE_OK)
         throw SQLiteError(db, "running `commit' command");
     
-    if (sqlite3_finalize(registerStmt) != SQLITE_OK)
-        throw SQLiteError(db, "finalizing statement");
-
     if (sqlite3_finalize(addRefStmt) != SQLITE_OK)
         throw SQLiteError(db, "finalizing statement");