libpqxx  4.0.1
robusttransaction.hxx
1 /*-------------------------------------------------------------------------
2  *
3  * FILE
4  * pqxx/robusttransaction.hxx
5  *
6  * DESCRIPTION
7  * definition of the pqxx::robusttransaction class.
8  * pqxx::robusttransaction is a slower but safer transaction class
9  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/robusttransaction instead.
10  *
11  * Copyright (c) 2002-2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
12  *
13  * See COPYING for copyright license. If you did not receive a file called
14  * COPYING with this source code, please notify the distributor of this mistake,
15  * or contact the author.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef PQXX_H_ROBUSTTRANSACTION
20 #define PQXX_H_ROBUSTTRANSACTION
21 
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24 
25 #include "pqxx/dbtransaction"
26 
27 #ifdef PQXX_QUIET_DESTRUCTORS
28 #include "pqxx/errorhandler"
29 #endif
30 
31 
32 /* Methods tested in eg. self-test program test001 are marked with "//[t1]"
33  */
34 
35 
36 namespace pqxx
37 {
38 
45 class PQXX_LIBEXPORT PQXX_NOVTABLE basic_robusttransaction :
46  public dbtransaction
47 {
48 public:
51 
52  virtual ~basic_robusttransaction() =0; //[t16]
53 
54 protected:
56  connection_base &C,
57  const PGSTD::string &IsolationLevel,
58  const PGSTD::string &table_name=PGSTD::string()); //[t16]
59 
60 private:
61  typedef unsigned long IDType;
62  IDType m_record_id;
63  PGSTD::string m_xid;
64  PGSTD::string m_LogTable;
65  PGSTD::string m_sequence;
66  int m_backendpid;
67 
68  virtual void do_begin(); //[t18]
69  virtual void do_commit(); //[t16]
70  virtual void do_abort(); //[t18]
71 
72  void PQXX_PRIVATE CreateLogTable();
73  void PQXX_PRIVATE CreateTransactionRecord();
74  PGSTD::string PQXX_PRIVATE sql_delete() const;
75  void PQXX_PRIVATE DeleteTransactionRecord() throw ();
76  bool PQXX_PRIVATE CheckTransactionRecord();
77 };
78 
79 
80 
82 
148 template<isolation_level ISOLATIONLEVEL=read_committed>
150 {
151 public:
153 
155 
160  const PGSTD::string &Name=PGSTD::string()) :
161  namedclass(fullname("robusttransaction",isolation_tag::name()), Name),
162  basic_robusttransaction(C, isolation_tag::name())
163  { Begin(); }
164 
165  virtual ~robusttransaction() throw ()
166  {
167 #ifdef PQXX_QUIET_DESTRUCTORS
168  quiet_errorhandler quiet(conn());
169 #endif
170  End();
171  }
172 };
173 
178 } // namespace pqxx
179 
180 
181 #include "pqxx/compiler-internal-post.hxx"
182 
183 #endif
184 
Traits class to describe an isolation level; primarly for libpqxx&#39;s own use.
Definition: isolation.hxx:69
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:151
Definition: dbtransaction.hxx:73
An error handler that suppresses any previously registered error handlers.
Definition: errorhandler.hxx:85
virtual ~robusttransaction()
Definition: robusttransaction.hxx:165
isolation_traits< ISOLATIONLEVEL > isolation_tag
Definition: robusttransaction.hxx:152
Definition: isolation.hxx:63
Slightly slower, better-fortified version of transaction.
Definition: robusttransaction.hxx:149
robusttransaction(connection_base &C, const std::string &Name=std::string())
Constructor.
Definition: robusttransaction.hxx:159
isolation_level
Transaction isolation levels.
Definition: isolation.hxx:60
The home of all libpqxx classes, functions, templates, etc.
Definition: basic_connection.hxx:35
isolation_traits< read_committed > isolation_tag
Isolation level is read_committed by default.
Definition: robusttransaction.hxx:50
Definition: robusttransaction.hxx:45