#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) { } } } } ebea63e75f76dbc79a9be'>root/m4/guix.m4
AgeCommit message (Expand)Author
2019-08-17build: 'GUIX_CHECK_GUILE_JSON' really checks for Guile-JSON 3.x....Ludovic Courtès
2019-07-25maint: Switch to Guile-JSON 3.x....Ludovic Courtès
2019-05-06Add (guix lzlib)....Pierre Neidhardt
2018-11-23Update Guile-SQLite3 URL everywhere....Ludovic Courtès
2018-09-04Switch to Guile-Gcrypt....Ludovic Courtès
2018-06-01build: Check for Guile-SQLite3....Ludovic Courtès
2018-02-26build: Require Guile >= 2.0.13....Ludovic Courtès
2018-01-06build: Detect broken 'equal?' in Guile 2.2.1....Ludovic Courtès
2017-06-30build: Remove check for broken (srfi srfi-37)....Ludovic Courtès
2017-02-20gnu: Add bootstrap-binaries for 'aarch64-linux'....Efraim Flashner
2016-11-25offload: Use Guile-SSH instead of GNU lsh....Ludovic Courtès
2016-08-10build: Correctly determine the system type for GNU/Hurd systems....Manolis Ragkousis
2016-07-20Merge branch 'master' into core-updatesLudovic Courtès
2016-07-19Add (guix zlib)....Ludovic Courtès
2016-06-23build: Remove unneeded conditionals for (guix build syscalls)....Manolis Ragkousis
2016-03-19build: Protect against misconfiguration of localstatedir....Ludovic Courtès
2016-01-13build: Use 127 as the Linux hash-bang limit....Ludovic Courtès
2016-01-12build: 'make check' errors out if file name limits would be hit....Ludovic Courtès
2016-01-12build: Warn against long hash bang lines for tests....Ludovic Courtès