// file : sqlite/transaction/driver.cxx // copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file // Test esoteric SQLite transaction semantics aspects. // #include // std::auto_ptr #include #include #include #include #include #include "test.hxx" #include "test-odb.hxx" using namespace std; namespace sqlite = odb::sqlite; using namespace sqlite; int main (int argc, char* argv[]) { try { auto_ptr db (create_specific_database (argc, argv)); // In SQLite, when a commit fails because of the deferred foreign // key constraint violation, the transaction is not automatically // rolled back. Make sure we compensate for that. // try { object o; o.p = odb::lazy_ptr (*db, 0); transaction t (db->begin ()); db->persist(o); t.commit (); } catch (const odb::exception&) { } // Make sure we can start a new transaction. // { transaction t (db->begin ()); t.commit (); } } catch (const odb::exception& e) { cerr << e.what () << endl; return 1; } }