Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pqxx::transaction_base Class Reference

Interface definition (and common code) for "transaction" classes. More...

#include <transaction_base.hxx>

Inheritance diagram for pqxx::transaction_base:

pqxx::dbtransaction pqxx::nontransaction pqxx::basic_robusttransaction pqxx::basic_transaction pqxx::robusttransaction< ISOLATIONLEVEL > pqxx::transaction< ISOLATIONLEVEL > List of all members.

Public Types

typedef isolation_traits<
read_committed > 
isolation_tag
 If nothing else is known, our isolation level is at least read_committed.


Public Member Functions

virtual ~transaction_base ()=0
void commit ()
 Commit the transaction.

void abort ()
 Abort the transaction.

result exec (const char Query[], const PGSTD::string &Desc=PGSTD::string())
 Execute query.

result exec (const PGSTD::string &Query, const PGSTD::string &Desc=PGSTD::string())
 Execute query.

void process_notice (const char Msg[]) const
 Have connection process warning message.

void process_notice (const PGSTD::string &Msg) const
 Have connection process warning message.

PGSTD::string name () const
connection_baseconn () const
 Connection this transaction is running in.

void set_variable (const PGSTD::string &Var, const PGSTD::string &Val)
 Set session variable in this connection.


Protected Member Functions

 transaction_base (connection_base &, const PGSTD::string &TName=PGSTD::string())
void Begin ()
void End () throw ()
 End transaction. To be called by implementing class' destructor.

virtual void do_begin ()=0
 To be implemented by derived implementation class: start transaction.

virtual result do_exec (const char Query[])=0
 To be implemented by derived implementation class: perform query.

virtual void do_commit ()=0
 To be implemented by derived implementation class: commit transaction.

virtual void do_abort ()=0
 To be implemented by derived implementation class: abort transaction.

result DirectExec (const char C[], int Retries, const char OnReconnect[])
 Execute query on connection directly.


Friends

class Cursor
class tablestream
class tablereader
class tablewriter

Detailed Description

Interface definition (and common code) for "transaction" classes.

All database access must be channeled through one of these classes for safety, although not all implementations of this interface need to provide full transactional integrity.

Several implementations of this interface are shipped with libpqxx, including the plain transaction class, the entirely unprotected nontransaction, and the more cautions robusttransaction.


Member Typedef Documentation

typedef isolation_traits<read_committed> pqxx::transaction_base::isolation_tag
 

If nothing else is known, our isolation level is at least read_committed.

Reimplemented in pqxx::basic_robusttransaction, pqxx::robusttransaction< ISOLATIONLEVEL >, and pqxx::transaction< ISOLATIONLEVEL >.


Constructor & Destructor Documentation

pqxx::transaction_base::~transaction_base  )  [pure virtual]
 

pqxx::transaction_base::transaction_base connection_base ,
const PGSTD::string &  TName = PGSTD::string()
[explicit, protected]
 

Create a transaction. The optional name, if given, must begin with a letter and may contain letters and digits only.


Member Function Documentation

void pqxx::transaction_base::abort  ) 
 

Abort the transaction.

No special effort is required to call this function; it will be called implicitly when the transaction is destructed.

void pqxx::transaction_base::Begin  )  [protected]
 

Begin transaction. To be called by implementing class, typically from constructor.

void pqxx::transaction_base::commit  ) 
 

Commit the transaction.

Unless this function is called explicitly, the transaction will not be committed (actually the nontransaction implementation breaks this rule, hence the name).

Once this function returns, the whole transaction will typically be irrevocably completed in the database. There is also, however, a minute risk that the connection to the database may be lost at just the wrong moment. In that case, libpqxx may be unable to determine whether the transaction was completed or aborted and an in_doubt_error will be thrown to make this fact known to the caller. The robusttransaction implementation takes some special precautions to reduce this risk.

connection_base& pqxx::transaction_base::conn  )  const
 

Connection this transaction is running in.

pqxx::result pqxx::transaction_base::DirectExec const char  C[],
int  Retries,
const char  OnReconnect[]
[protected]
 

Execute query on connection directly.

virtual void pqxx::transaction_base::do_abort  )  [protected, pure virtual]
 

To be implemented by derived implementation class: abort transaction.

virtual void pqxx::transaction_base::do_begin  )  [protected, pure virtual]
 

To be implemented by derived implementation class: start transaction.

virtual void pqxx::transaction_base::do_commit  )  [protected, pure virtual]
 

To be implemented by derived implementation class: commit transaction.

virtual result pqxx::transaction_base::do_exec const char  Query[]  )  [protected, pure virtual]
 

To be implemented by derived implementation class: perform query.

void pqxx::transaction_base::End  )  throw () [protected]
 

End transaction. To be called by implementing class' destructor.

result pqxx::transaction_base::exec const PGSTD::string &  Query,
const PGSTD::string &  Desc = PGSTD::string()
 

Execute query.

Perform a query in this transaction. This version may be slightly slower than the version taking a const char[], although the difference is not likely to be very noticeable compared to the time required to execute even a simple query.

Parameters:
Query the query or command to execute
Desc optional identifier for query, to help pinpoint SQL errors

pqxx::result pqxx::transaction_base::exec const char  Query[],
const PGSTD::string &  Desc = PGSTD::string()
 

Execute query.

Perform a query in this transaction.

Parameters:
Query the query or command to execute
Desc optional identifier for query, to help pinpoint SQL errors

PGSTD::string pqxx::transaction_base::name  )  const
 

void pqxx::transaction_base::process_notice const PGSTD::string &  Msg  )  const
 

Have connection process warning message.

void pqxx::transaction_base::process_notice const char  Msg[]  )  const
 

Have connection process warning message.

void pqxx::transaction_base::set_variable const PGSTD::string &  Var,
const PGSTD::string &  Val
 

Set session variable in this connection.

The new value is typically forgotten if the transaction aborts. Known exceptions to this rule are nontransaction, and PostgreSQL versions prior to 7.3. In the case of nontransaction, the set value will be kept regardless, but if the connection ever needs to be recovered, the set value will not be restored.

Parameters:
Var the variable to set
Val the value to store in the variable


Friends And Related Function Documentation

friend class Cursor [friend]
 

friend class tablereader [friend]
 

friend class tablestream [friend]
 

friend class tablewriter [friend]
 


The documentation for this class was generated from the following files:
Generated on Fri Oct 24 20:21:39 2003 for libpqxx by doxygen 1.3.4