19 #ifndef PQXX_H_CONNECTION_BASE
20 #define PQXX_H_CONNECTION_BASE
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
29 #include "pqxx/except"
30 #include "pqxx/prepared_statement"
31 #include "pqxx/strconv"
47 class transaction_base;
48 class notify_listener;
49 class connectionpolicy;
53 class reactivation_avoidance_exemption;
61 void add(
int n)
throw () { m_counter += n; }
62 void clear() throw () { m_counter = 0; }
63 int get()
const throw () {
return m_counter; }
82 struct PQXX_LIBEXPORT PQXX_NOVTABLE
noticer :
83 PGSTD::unary_function<const char[], void>
87 virtual void operator()(
const char Msg[])
throw () =0;
122 const PGSTD::string &user,
123 const PGSTD::string &password);
130 class connection_dbtransaction;
131 class connection_largeobject;
132 class connection_notify_listener;
133 class connection_parameterized_invocation;
134 class connection_pipeline;
135 class connection_prepare_declaration;
136 class connection_prepare_invocation;
137 class connection_reactivation_avoidance_exemption;
138 class connection_sql_cursor;
139 class connection_transaction;
182 void disconnect()
throw ();
189 bool is_open()
const throw ();
270 void inhibit_reactivation(
bool inhibit)
271 { m_inhibit_reactivation=inhibit; }
279 void simulate_failure();
305 PGSTD::auto_ptr<noticer> set_noticer(PGSTD::auto_ptr<noticer> N)
310 void process_notice(
const char[]) throw ();
312 void process_notice(const PGSTD::
string &) throw ();
317 void trace(FILE *) throw ();
331 const
char *dbname();
337 const
char *username();
343 const
char *hostname();
361 int backendpid() const throw ();
378 int sock() const throw ();
464 int protocol_version()
const throw ();
479 int server_version() const throw ();
489 void set_client_encoding(const PGSTD::
string &Encoding)
490 { set_variable(
"CLIENT_ENCODING", Encoding); }
509 void set_variable(
const PGSTD::string &Var,
510 const PGSTD::string &Value);
520 PGSTD::string get_variable(
const PGSTD::string &);
551 int await_notification();
560 int await_notification(
long seconds,
long microseconds);
644 const PGSTD::string &definition);
656 void unprepare(
const PGSTD::string &name);
669 void prepare_now(
const PGSTD::string &name);
709 template<
typename TRANSACTOR>
710 void perform(
const TRANSACTOR &T,
int Attempts);
716 template<
typename TRANSACTOR>
727 PGSTD::string adorn_name(
const PGSTD::string &);
798 PGSTD::string esc(
const char str[]);
801 PGSTD::string esc(
const char str[],
size_t maxlen);
804 PGSTD::string esc(
const PGSTD::string &str);
807 PGSTD::string esc_raw(
const unsigned char str[],
size_t len);
812 PGSTD::string quote(
const T &t)
815 return "'" + this->esc(
to_string(t)) +
"'";
826 void close() throw ();
827 void wait_read() const;
828 void wait_read(
long seconds,
long microseconds) const;
829 void wait_write() const;
832 result make_result(internal::pq::PGresult *rhs, const PGSTD::
string &query);
834 void PQXX_PRIVATE clearcaps() throw ();
835 void PQXX_PRIVATE SetupState();
836 void PQXX_PRIVATE check_result(const
result &);
838 void PQXX_PRIVATE InternalSetTrace() throw ();
839 int PQXX_PRIVATE Status() const throw ();
840 const
char *ErrMsg() const throw ();
841 void PQXX_PRIVATE Reset();
842 void PQXX_PRIVATE RestoreVars();
843 PGSTD::
string PQXX_PRIVATE RawGetVar(const PGSTD::
string &);
844 void PQXX_PRIVATE process_notice_raw(const
char msg[]) throw ();
845 void switchnoticer(const PGSTD::auto_ptr<
noticer> &) throw ();
847 void read_capabilities() throw ();
849 prepare::internal::prepared_def &find_prepared(const PGSTD::
string &);
851 friend class internal::gate::connection_prepare_declaration;
852 void prepare_param_declare(
853 const PGSTD::
string &statement,
854 const PGSTD::
string &sqltype,
855 prepare::param_treatment);
856 void prepare_param_declare_varargs(
857 const PGSTD::
string &statement,
858 prepare::param_treatment);
860 prepare::internal::prepared_def ®ister_prepared(const PGSTD::
string &);
862 friend class internal::gate::connection_prepare_invocation;
863 result prepared_exec(const PGSTD::
string &,
867 bool prepared_exists(const PGSTD::
string &) const;
870 internal::pq::PGconn *m_Conn;
878 PGSTD::auto_ptr<
noticer> m_Noticer;
885 internal::pq::PQnoticeProcessor m_defaultNoticeProcessor;
890 typedef PGSTD::multimap<PGSTD::
string, pqxx::
notify_listener *> listenerlist;
892 listenerlist m_listeners;
895 PGSTD::map<PGSTD::
string, PGSTD::
string> m_Vars;
897 typedef PGSTD::map<PGSTD::
string, prepare::internal::prepared_def> PSMap;
906 internal::reactivation_avoidance_counter m_reactivation_avoidance;
915 bool m_inhibit_reactivation;
918 PGSTD::bitset<cap_end> m_caps;
920 friend class internal::gate::connection_transaction;
921 result PQXX_PRIVATE Exec(const
char[],
int Retries);
923 void PQXX_PRIVATE UnregisterTransaction(transaction_base *) throw ();
924 bool PQXX_PRIVATE ReadCopyLine(PGSTD::
string &);
925 void PQXX_PRIVATE WriteCopyLine(const PGSTD::
string &);
926 void PQXX_PRIVATE EndCopyWrite();
927 void PQXX_PRIVATE RawSetVar(const PGSTD::
string &, const PGSTD::
string &);
928 void PQXX_PRIVATE AddVariables(const PGSTD::map<PGSTD::
string,
931 friend class internal::gate::connection_largeobject;
932 internal::pq::PGconn *RawConnection()
const {
return m_Conn; }
934 friend class internal::gate::connection_notify_listener;
938 friend class internal::gate::connection_pipeline;
939 void PQXX_PRIVATE start_exec(const PGSTD::
string &);
940 bool PQXX_PRIVATE consume_input() throw ();
941 bool PQXX_PRIVATE is_busy() const throw ();
942 int PQXX_PRIVATE encoding_code() throw ();
943 internal::pq::PGresult *get_result();
945 friend class internal::gate::connection_dbtransaction;
947 friend class internal::gate::connection_sql_cursor;
948 void add_reactivation_avoidance_count(
int);
950 friend class internal::gate::connection_reactivation_avoidance_exemption;
952 friend class internal::gate::connection_parameterized_invocation;
953 result parameterized_exec(
954 const PGSTD::
string &query,
955 const
char *const params[],
956 const
int paramlengths[],
961 connection_base &operator=(const connection_base &);
981 scoped_noticer(connection_base &c, PGSTD::auto_ptr<noticer> t)
throw () :
982 m_c(c), m_org(c.set_noticer(t)) { }
992 scoped_noticer(connection_base &c,
noticer *t)
throw () :
996 PGSTD::auto_ptr<noticer> x(t);
997 PGSTD::auto_ptr<noticer> y(c.set_noticer(x));
1002 connection_base &m_c;
1003 PGSTD::auto_ptr<noticer> m_org;
1007 scoped_noticer(
const scoped_noticer &);
1008 scoped_noticer operator=(
const scoped_noticer &);
1034 connection_base &m_home;
1048 #include "pqxx/compiler-internal-post.hxx"