On 23 April 2013 06:05, Patrick Rotsaert <[email protected]> wrote:
>
> 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?

There is no support for plugging in session/connection obtained
directly from low-level client API.

You need to patch SOCI to suit your needs.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to