diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-11-17 12:40:52 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-11-17 12:40:52 +0000 |
commit | e60c962fb8dd3d8be37c1f4ae08d5247901fa129 (patch) | |
tree | c8ac16743478164312460f897901d1731930dbd1 /src/libstore | |
parent | 1db6259076b1b8f667451da8d2e44a55ece19056 (diff) |
* Add an operation `nix-store -q --size'.
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/local-store.cc | 14 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 9595561bc..201e4bae1 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -88,6 +88,13 @@ void SQLiteStmt::bind(int value) } +void SQLiteStmt::bind64(long long value) +{ + if (sqlite3_bind_int64(stmt, curArg++, value) != SQLITE_OK) + throw SQLiteError(db, "binding argument"); +} + + void SQLiteStmt::bind() { if (sqlite3_bind_null(stmt, curArg++) != SQLITE_OK) @@ -340,7 +347,7 @@ void LocalStore::openDB(bool create) stmtAddReference.create(db, "insert or replace into Refs (referrer, reference) values (?, ?);"); stmtQueryPathInfo.create(db, - "select id, hash, registrationTime, deriver from ValidPaths where path = ?;"); + "select id, hash, registrationTime, deriver, narSize from ValidPaths where path = ?;"); stmtQueryReferences.create(db, "select path from Refs join ValidPaths on reference = id where referrer = ?;"); stmtQueryReferrers.create(db, @@ -449,7 +456,7 @@ unsigned long long LocalStore::addValidPath(const ValidPathInfo & info) else stmtRegisterValidPath.bind(); // null if (info.narSize != 0) - stmtRegisterValidPath.bind(info.narSize); + stmtRegisterValidPath.bind64(info.narSize); else stmtRegisterValidPath.bind(); // null if (sqlite3_step(stmtRegisterValidPath) != SQLITE_DONE) @@ -600,6 +607,9 @@ ValidPathInfo LocalStore::queryPathInfo(const Path & path) s = (const char *) sqlite3_column_text(stmtQueryPathInfo, 3); if (s) info.deriver = s; + /* Note that narSize = NULL yields 0. */ + info.narSize = sqlite3_column_int64(stmtQueryPathInfo, 4); + /* Get the references. */ SQLiteStmtUse use2(stmtQueryReferences); diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 2fd31c26d..4076e5957 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -70,6 +70,7 @@ struct SQLiteStmt operator sqlite3_stmt * () { return stmt; } void bind(const string & value); void bind(int value); + void bind64(long long value); void bind(); }; |