#pragma once #include #include #include "types.hh" class sqlite3; class sqlite3_stmt; namespace nix { /* RAII wrapper to close a SQLite database automatically. */ struct SQLite { sqlite3 * db; SQLite() { db = 0; } ~SQLite(); operator sqlite3 * () { return db; } }; /* RAII wrapper to create and destroy SQLite prepared statements. */ struct SQLiteStmt { sqlite3 * db = 0; sqlite3_stmt * stmt = 0; SQLiteStmt() { } void create(sqlite3 * db, const std::string & s); ~SQLiteStmt(); operator sqlite3_stmt * () { return stmt; } /* Helper for binding / executing statements. */ class Use { friend struct SQLiteStmt; private: SQLiteStmt & stmt; unsigned int curArg = 1; Use(SQLiteStmt & stmt); public: ~Use(); /* Bind the next parameter. */ Use & operator () (const std::string & value, bool notNull = true); Use & operator () (int64_t value, bool notNull = true); Use & bind(); // null int step(); /* Execute a statement that does not return rows. */ void exec(); /* For statements that return 0 or more rows. Returns true iff a row is available. */ bool next(); std::string getStr(int col); int64_t getInt(int col); }; Use use() { return Use(*this); } }; /* RAII helper that ensures transactions are aborted unless explicitly committed. */ struct SQLiteTxn { bool active = false; sqlite3 * db; SQLiteTxn(sqlite3 * db); void commit(); ~SQLiteTxn(); }; MakeError(SQLiteError, Error); MakeError(SQLiteBusy, SQLiteError); [[noreturn]] void throwSQLiteError(sqlite3 * db, const format & f); /* Convenience function for retrying a SQLite transaction when the database is busy. */ template T retrySQLite(std::function fun) { while (true) { try { return fun(); } catch (SQLiteBusy & e) { } } } } /td>
AgeCommit message (Expand)Author
2019-04-10gnu: dub: Don't use unstable tarball....* gnu/packages/dlang.scm (dub)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice
2019-04-10gnu: ldc: Don't use unstable tarball....* gnu/packages/dlang.scm (ldc)[source]: Use GIT-FETCH and GIT-FILE-NAME. [native-inputs]: Likewise. [arguments]: Adjust ‘unpack-submodule-sources’ phase accordingly. Tobias Geerinckx-Rice
2019-04-10gnu: ldc@0.17.4: Don't use unstable tarball....* gnu/packages/dlang.scm (ldc-bootstrap)[source]: Use GIT-FETCH and GIT-FILE-NAME. [native-inputs]: Likewise. [arguments]: Adjust ‘unpack-submodule-sources’ phase accordingly. Tobias Geerinckx-Rice
2019-03-26gnu: ldc: Use INVOKE....* gnu/packages/dlang.scm (ldc)[arguments]: Use INVOKE. Ricardo Wurmus
2019-03-26gnu: ldc-bootstrap: Use INVOKE....* gnu/packages/dlang.scm (ldc-bootstrap)[arguments]: Use INVOKE and unconditionally return #T from build phase. Ricardo Wurmus
2019-02-15gnu: LLVM, Clang: Update to 7.0.1....* gnu/packages/patches/clang-7.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/llvm.scm (llvm, clang-runtime, clang): Update to 7.0.1. (llvm-7.0.1): Remove variable. (clang-from-llvm)[arguments]: Adjust phase to match Clang 7. (llvm-6, clang-runtime-6, clang-6): New public variables. * gnu/packages/dlang.scm (ldc)[native-inputs]: Change LLVM and CLANG to LLVM-6.0 and CLANG-6.0. * gnu/packages/gl.scm (mesa)[inputs]: Change from LLVM to LLVM-6. Marius Bakke