about summary refs log tree commit diff
path: root/src/libstore/db.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-12-12T19·14+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-12-12T19·14+0000
commitd87549c1c7bb6f85ff0a019b33b315ace0013e6b (patch)
treeef54e0c9b79ce5419bab05a1e7046edac72a32a5 /src/libstore/db.cc
parent8463f27d8cd09d54648de21c747f895cdb558f83 (diff)
* Automatically delete the old referers table.
Diffstat (limited to 'src/libstore/db.cc')
-rw-r--r--src/libstore/db.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/libstore/db.cc b/src/libstore/db.cc
index 74c933d0e687..7ded82ef1fe8 100644
--- a/src/libstore/db.cc
+++ b/src/libstore/db.cc
@@ -292,11 +292,12 @@ void Database::close()
     try {
 
         for (map<TableId, Db *>::iterator i = tables.begin();
-             i != tables.end(); i++)
+             i != tables.end(); )
         {
-            Db * db = i->second;
-            db->close(DB_NOSYNC);
-            delete db;
+            map<TableId, Db *>::iterator j = i;
+            ++j;
+            closeTable(i->first);
+            i = j;
         }
 
         /* Do a checkpoint every 128 kilobytes, or every 5 minutes. */
@@ -336,6 +337,25 @@ TableId Database::openTable(const string & tableName, bool sorted)
 }
 
 
+void Database::closeTable(TableId table)
+{
+    try {
+        Db * db = getDb(table);
+        db->close(DB_NOSYNC);
+        delete db;
+        tables.erase(table);
+    } catch (DbException e) { rethrow(e); }
+}
+
+
+void Database::deleteTable(const string & table)
+{
+    try {
+        env->dbremove(0, table.c_str(), 0, DB_AUTO_COMMIT);
+    } catch (DbException e) { rethrow(e); }
+}
+
+
 bool Database::queryString(const Transaction & txn, TableId table, 
     const string & key, string & data)
 {