libpqxx  7.0.1
pqxx::pqxx::robusttransaction< ISOLATION > Class Template Referencefinal

Slightly slower, better-fortified version of transaction. More...

#include <robusttransaction.hxx>

Inheritance diagram for pqxx::pqxx::robusttransaction< ISOLATION >:

Public Member Functions

 robusttransaction (connection &c, std::string_view name=std::string_view{})
 
virtual ~robusttransaction () noexcept override
 
- Public Member Functions inherited from pqxx::internal::basic_robusttransaction
virtual ~basic_robusttransaction () override=0
 

Additional Inherited Members

- Protected Member Functions inherited from pqxx::internal::basic_robusttransaction
 basic_robusttransaction (connection &c, char const begin_command[])
 
- Protected Member Functions inherited from pqxx::dbtransaction
 dbtransaction (connection &c)
 

Detailed Description

template<isolation_level ISOLATION = read_committed>
class pqxx::pqxx::robusttransaction< ISOLATION >

Slightly slower, better-fortified version of transaction.

Requires PostgreSQL 10 or better.

robusttransaction is similar to transaction, but spends more time and effort to deal with the hopefully rare case that the connection to the backend is lost just while it's trying to commit. In such cases, the client does not know whether the backend (on the other side of the broken connection) managed to commit the transaction.

Whe this happens, robusttransaction tries to reconnect to the database and figure out what happened.

This service level was made optional since you may not want to pay the overhead where it is not necessary. Certainly the use of this class makes no sense for local connections, or for transactions that read the database but never modify it, or for noncritical database manipulations.

Besides being slower, it's also more complex. Which means that in practice a robusttransaction could actually fail more instead of less often than a normal transaction. What robusttransaction tries to achieve is to give you certainty, not just be more successful per se.

Constructor & Destructor Documentation

◆ robusttransaction()

template<isolation_level ISOLATION = read_committed>
pqxx::pqxx::robusttransaction< ISOLATION >::robusttransaction ( connection &  c,
std::string_view  name = std::string_view{} 
)
explicit

Create robusttransaction of given name.

Parameters
cConnection inside which this robusttransaction should live.
nameoptional human-readable name for this transaction.

◆ ~robusttransaction()

template<isolation_level ISOLATION = read_committed>
virtual pqxx::pqxx::robusttransaction< ISOLATION >::~robusttransaction ( )
overridevirtualnoexcept

The documentation for this class was generated from the following file: