Patrick Rotsaert
2013-04-23 05:05:24 UTC
Hi,
I'd like to use soci in an application plugin that receives a PGconn (postgresql libpq) connection as a parameter. Ideally, this connection would be reused, so that no extra connection needs to be made.
There does not appear to be a way to instantiate a soci::session from a PGconn*. I tried to subclass soci::postgresql_session_backend and soci::postgresql_backend_factory, but the soci::postgresql_session_backend ctor will always setup a new connection.
The quickest fix would be to add a protected ctor:
struct postgresql_session_backend : details::session_backend
{
...
protected:
postgresql_session_backend(PGconn * conn) : statementCount_(0), conn_(conn) {}
};
This way, I could subclass the session and factory backends. The session destructor would set conn_ = 0, so that postgresql_session_backend::clean_up would not close the connection.
Any other ideas perhaps?
Thx, Pat
I'd like to use soci in an application plugin that receives a PGconn (postgresql libpq) connection as a parameter. Ideally, this connection would be reused, so that no extra connection needs to be made.
There does not appear to be a way to instantiate a soci::session from a PGconn*. I tried to subclass soci::postgresql_session_backend and soci::postgresql_backend_factory, but the soci::postgresql_session_backend ctor will always setup a new connection.
The quickest fix would be to add a protected ctor:
struct postgresql_session_backend : details::session_backend
{
...
protected:
postgresql_session_backend(PGconn * conn) : statementCount_(0), conn_(conn) {}
};
This way, I could subclass the session and factory backends. The session destructor would set conn_ = 0, so that postgresql_session_backend::clean_up would not close the connection.
Any other ideas perhaps?
Thx, Pat