aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-02-22 11:44:17 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-02-22 11:44:17 +0000
commit103cfee056cbc8f002929fd5958e305c1a75fe45 (patch)
treed790817c90c3cffeeed5a21b30cbda7562526128 /src/libstore/local-store.cc
parent299ff64812ce166d230f1b630f794be226c7a178 (diff)
* Revert r19650 (implement gc-keep-outputs by looking for derivations
with the same name as the output) and instead use the DerivationOutputs table in the database, which is the correct way to to do things.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 2f12256db..0590b294b 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -297,6 +297,8 @@ void LocalStore::prepareStatements()
"select time from FailedPaths where path = ?;");
stmtAddDerivationOutput.create(db,
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
+ stmtQueryValidDerivers.create(db,
+ "select v.id, v.path from DerivationOutputs d join ValidPaths v on d.drv = v.id where d.path = ?;");
}
@@ -599,6 +601,28 @@ Path LocalStore::queryDeriver(const Path & path)
}
+PathSet LocalStore::queryValidDerivers(const Path & path)
+{
+ assertStorePath(path);
+
+ SQLiteStmtUse use(stmtQueryValidDerivers);
+ stmtQueryValidDerivers.bind(path);
+
+ PathSet derivers;
+ int r;
+ while ((r = sqlite3_step(stmtQueryValidDerivers)) == SQLITE_ROW) {
+ const char * s = (const char *) sqlite3_column_text(stmtQueryValidDerivers, 1);
+ assert(s);
+ derivers.insert(s);
+ }
+
+ if (r != SQLITE_DONE)
+ throw SQLiteError(db, format("error getting valid derivers of `%1%'") % path);
+
+ return derivers;
+}
+
+
void LocalStore::startSubstituter(const Path & substituter, RunningSubstituter & run)
{
if (run.pid != -1) return;