20 #ifndef PQXX_H_TRANSACTION_BASE
21 #define PQXX_H_TRANSACTION_BASE
23 #include "pqxx/compiler-public.hxx"
24 #include "pqxx/compiler-internal-pre.hxx"
35 #include "pqxx/connection_base"
36 #include "pqxx/isolation"
37 #include "pqxx/result"
44 class connection_base;
45 class transaction_base;
64 void unregister_me() throw ();
65 void reg_pending_error(const PGSTD::
string &) throw ();
66 bool registered() const throw () {
return m_registered; }
89 { add_binary_param(v,
true);
return *
this; }
91 { add_param(v,
true);
return *
this; }
93 { add_binary_param(v, nonnull);
return *
this; }
96 { add_param(v, nonnull);
return *
this; }
105 const PGSTD::string m_query;
114 class transaction_subtransaction;
115 class transaction_tablereader;
116 class transaction_tablewriter;
117 class transaction_transactionfocus;
168 PGSTD::string
esc(
const char str[])
const {
return conn().esc(str); }
170 PGSTD::string esc(
const char str[],
size_t maxlen)
const
171 {
return conn().esc(str, maxlen); }
173 PGSTD::string
esc(
const PGSTD::string &str)
const {
return conn().esc(str); }
187 PGSTD::string esc_raw(
const unsigned char str[],
size_t len)
const
188 {
return conn().esc_raw(str, len); }
190 PGSTD::string esc_raw(
const PGSTD::string &)
const;
194 template<
typename T> PGSTD::string quote(
const T &t)
const
195 {
return conn().quote(t); }
198 PGSTD::string quote_raw(
const unsigned char str[],
size_t len)
const
199 {
return conn().quote_raw(str, len); }
201 PGSTD::string quote_raw(
const PGSTD::string &str)
const;
204 PGSTD::string quote_name(
const PGSTD::string &identifier)
const
205 {
return conn().quote_name(identifier); }
224 result exec(
const PGSTD::string &Query,
225 const PGSTD::string &Desc=PGSTD::string());
227 result exec(
const PGSTD::stringstream &Query,
228 const PGSTD::string &Desc=PGSTD::string())
229 {
return exec(Query.str(), Desc); }
297 void process_notice(
const char Msg[])
const
298 { m_Conn.process_notice(Msg); }
300 void process_notice(
const PGSTD::string &Msg)
const
301 { m_Conn.process_notice(Msg); }
316 void set_variable(
const PGSTD::string &Var,
const PGSTD::string &Val);
328 PGSTD::string get_variable(
const PGSTD::string &);
350 virtual
void do_begin() =0;
352 virtual
result do_exec(const
char Query[]) =0;
354 virtual
void do_commit() =0;
356 virtual
void do_abort() =0;
369 result DirectExec(const
char C[],
int Retries=0);
372 void reactivation_avoidance_clear() throw ()
373 {m_reactivation_avoidance.
clear();}
411 void PQXX_PRIVATE activate();
413 void PQXX_PRIVATE CheckPendingError();
415 template<
typename T>
bool parm_is_null(T *p)
const throw () {
return !p; }
416 template<
typename T>
bool parm_is_null(T)
const throw () {
return false; }
418 friend class pqxx::internal::gate::transaction_transactionfocus;
421 void PQXX_PRIVATE RegisterPendingError(const PGSTD::
string &) throw ();
423 friend class pqxx::internal::gate::transaction_tablereader;
424 void PQXX_PRIVATE BeginCopyRead(const PGSTD::
string &, const PGSTD::
string &);
425 bool ReadCopyLine(PGSTD::
string &);
427 friend class pqxx::internal::gate::transaction_tablewriter;
428 void PQXX_PRIVATE BeginCopyWrite(
429 const PGSTD::
string &Table,
430 const PGSTD::
string &Columns);
431 void WriteCopyLine(const PGSTD::
string &);
434 friend class pqxx::internal::gate::transaction_subtransaction;
438 internal::unique<internal::transactionfocus> m_Focus;
441 PGSTD::map<PGSTD::
string, PGSTD::
string> m_Vars;
442 PGSTD::
string m_PendingError;
449 transaction_base &operator=(const transaction_base &);
455 #include "pqxx/compiler-internal-post.hxx"