libpqxx 3.1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

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-2009, 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
28 /* Methods tested in eg. self-test program test001 are marked with "//[t1]"
29 */
30
31
32 namespace pqxx
33 {
34
41 class PQXX_LIBEXPORT PQXX_NOVTABLE basic_robusttransaction :
42 public dbtransaction
43 {
44 public:
46 typedef isolation_traits<read_committed> isolation_tag;
47
48 virtual ~basic_robusttransaction() =0; //[t16]
49
50 protected:
51 basic_robusttransaction(
52 connection_base &C,
53 const PGSTD::string &IsolationLevel,
54 const PGSTD::string &table_name=PGSTD::string()); //[t16]
55
56 private:
57 typedef unsigned long IDType;
58 IDType m_record_id;
59 PGSTD::string m_xid;
60 PGSTD::string m_LogTable;
61 PGSTD::string m_sequence;
62 int m_backendpid;
63
64 virtual void do_begin(); //[t18]
65 virtual void do_commit(); //[t16]
66 virtual void do_abort(); //[t18]
67
68 void PQXX_PRIVATE CreateLogTable();
69 void PQXX_PRIVATE CreateTransactionRecord();
70 PGSTD::string PQXX_PRIVATE sql_delete() const;
71 void PQXX_PRIVATE DeleteTransactionRecord() throw ();
72 bool PQXX_PRIVATE CheckTransactionRecord();
73 };
74
75
76
78
144 template<isolation_level ISOLATIONLEVEL=read_committed>
145 class robusttransaction : public basic_robusttransaction
146 {
147 public:
148 typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
149
151
155 explicit robusttransaction(connection_base &C,
156 const PGSTD::string &Name=PGSTD::string()) :
157 namedclass(fullname("robusttransaction",isolation_tag::name()), Name),
158 basic_robusttransaction(C, isolation_tag::name())
159 { Begin(); }
160
161 virtual ~robusttransaction() throw ()
162 {
163 #ifdef PQXX_QUIET_DESTRUCTORS
164 disable_noticer Quiet(conn());
165 #endif
166 End();
167 }
168 };
169
174 } // namespace pqxx
175
176
177 #include "pqxx/compiler-internal-post.hxx"
178
179 #endif
180