test14.cxx 946 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <iostream>
  2. #include <pqxx/nontransaction>
  3. #include "test_helpers.hxx"
  4. using namespace pqxx;
  5. // Test nontransaction.
  6. namespace
  7. {
  8. void test_014()
  9. {
  10. connection conn;
  11. // Begin a "non-transaction" acting on our current connection. This is
  12. // really all the transactional integrity we need since we're only
  13. // performing one query which does not modify the database.
  14. nontransaction tx{conn, "test14"};
  15. // The transaction class family also has process_notice() functions.
  16. // These simply pass the notice through to their connection, but this may
  17. // be more convenient in some cases. All process_notice() functions accept
  18. // C++ strings as well as C strings.
  19. tx.process_notice(std::string{"Started nontransaction\n"});
  20. // "Commit" the non-transaction. This doesn't really do anything since
  21. // nontransaction doesn't start a backend transaction.
  22. tx.commit();
  23. }
  24. PQXX_REGISTER_TEST(test_014);
  25. } // namespace