Add forward compatibility with the Nix 1.12 database schema
This commit is contained in:
parent
1fa2c86db5
commit
8ca944e009
|
@ -320,8 +320,8 @@ LocalStore::LocalStore(bool reserveSpace)
|
||||||
|
|
||||||
/* Check the current database schema and if necessary do an
|
/* Check the current database schema and if necessary do an
|
||||||
upgrade. */
|
upgrade. */
|
||||||
int curSchema = getSchema();
|
curSchema = getSchema();
|
||||||
if (curSchema > nixSchemaVersion)
|
if (curSchema >= 0x100)
|
||||||
throw Error(format("current Nix store schema is version %1%, but I only support %2%")
|
throw Error(format("current Nix store schema is version %1%, but I only support %2%")
|
||||||
% curSchema % nixSchemaVersion);
|
% curSchema % nixSchemaVersion);
|
||||||
|
|
||||||
|
@ -470,16 +470,18 @@ void LocalStore::openDB(bool create)
|
||||||
"select path from Refs join ValidPaths on referrer = id where reference = (select id from ValidPaths where path = ?);");
|
"select path from Refs join ValidPaths on referrer = id where reference = (select id from ValidPaths where path = ?);");
|
||||||
stmtInvalidatePath.create(db,
|
stmtInvalidatePath.create(db,
|
||||||
"delete from ValidPaths where path = ?;");
|
"delete from ValidPaths where path = ?;");
|
||||||
stmtRegisterFailedPath.create(db,
|
if (curSchema < 9) {
|
||||||
"insert or ignore into FailedPaths (path, time) values (?, ?);");
|
stmtRegisterFailedPath.create(db,
|
||||||
stmtHasPathFailed.create(db,
|
"insert or ignore into FailedPaths (path, time) values (?, ?);");
|
||||||
"select time from FailedPaths where path = ?;");
|
stmtHasPathFailed.create(db,
|
||||||
stmtQueryFailedPaths.create(db,
|
"select time from FailedPaths where path = ?;");
|
||||||
"select path from FailedPaths;");
|
stmtQueryFailedPaths.create(db,
|
||||||
// If the path is a derivation, then clear its outputs.
|
"select path from FailedPaths;");
|
||||||
stmtClearFailedPath.create(db,
|
// If the path is a derivation, then clear its outputs.
|
||||||
"delete from FailedPaths where ?1 = '*' or path = ?1 "
|
stmtClearFailedPath.create(db,
|
||||||
"or path in (select d.path from DerivationOutputs d join ValidPaths v on d.drv = v.id where v.path = ?1);");
|
"delete from FailedPaths where ?1 = '*' or path = ?1 "
|
||||||
|
"or path in (select d.path from DerivationOutputs d join ValidPaths v on d.drv = v.id where v.path = ?1);");
|
||||||
|
}
|
||||||
stmtAddDerivationOutput.create(db,
|
stmtAddDerivationOutput.create(db,
|
||||||
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
|
"insert or replace into DerivationOutputs (drv, id, path) values (?, ?, ?);");
|
||||||
stmtQueryValidDerivers.create(db,
|
stmtQueryValidDerivers.create(db,
|
||||||
|
@ -742,6 +744,7 @@ void LocalStore::addReference(unsigned long long referrer, unsigned long long re
|
||||||
|
|
||||||
void LocalStore::registerFailedPath(const Path & path)
|
void LocalStore::registerFailedPath(const Path & path)
|
||||||
{
|
{
|
||||||
|
if (curSchema >= 9) return;
|
||||||
retry_sqlite {
|
retry_sqlite {
|
||||||
SQLiteStmtUse use(stmtRegisterFailedPath);
|
SQLiteStmtUse use(stmtRegisterFailedPath);
|
||||||
stmtRegisterFailedPath.bind(path);
|
stmtRegisterFailedPath.bind(path);
|
||||||
|
@ -754,6 +757,7 @@ void LocalStore::registerFailedPath(const Path & path)
|
||||||
|
|
||||||
bool LocalStore::hasPathFailed(const Path & path)
|
bool LocalStore::hasPathFailed(const Path & path)
|
||||||
{
|
{
|
||||||
|
if (curSchema >= 9) return false;
|
||||||
retry_sqlite {
|
retry_sqlite {
|
||||||
SQLiteStmtUse use(stmtHasPathFailed);
|
SQLiteStmtUse use(stmtHasPathFailed);
|
||||||
stmtHasPathFailed.bind(path);
|
stmtHasPathFailed.bind(path);
|
||||||
|
@ -767,6 +771,8 @@ bool LocalStore::hasPathFailed(const Path & path)
|
||||||
|
|
||||||
PathSet LocalStore::queryFailedPaths()
|
PathSet LocalStore::queryFailedPaths()
|
||||||
{
|
{
|
||||||
|
if (curSchema >= 9) return {};
|
||||||
|
|
||||||
retry_sqlite {
|
retry_sqlite {
|
||||||
SQLiteStmtUse use(stmtQueryFailedPaths);
|
SQLiteStmtUse use(stmtQueryFailedPaths);
|
||||||
|
|
||||||
|
@ -788,6 +794,8 @@ PathSet LocalStore::queryFailedPaths()
|
||||||
|
|
||||||
void LocalStore::clearFailedPaths(const PathSet & paths)
|
void LocalStore::clearFailedPaths(const PathSet & paths)
|
||||||
{
|
{
|
||||||
|
if (curSchema >= 9) return;
|
||||||
|
|
||||||
retry_sqlite {
|
retry_sqlite {
|
||||||
SQLiteTxn txn(db);
|
SQLiteTxn txn(db);
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ private:
|
||||||
|
|
||||||
Path linksDir;
|
Path linksDir;
|
||||||
|
|
||||||
|
int curSchema = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* Initialise the local store, upgrading the schema if
|
/* Initialise the local store, upgrading the schema if
|
||||||
|
|
Loading…
Reference in a new issue