[Libpqxx-general] Two phase commit

Maurice Gittens mainmanmauricio at gmail.com
Thu Aug 20 08:45:19 UTC 2009


Hi,

On Sun, Aug 16, 2009 at 11:43 AM, Maurice Gittens <mainmanmauricio at gmail.com
> wrote:

> Hi Jeroen,
>

<snip>


> I think we would want the API to align well with the mental-model used with
> XA compliant TM; keeping things nice and simple in the process.
>
> A suggestion for integration into pqxx follows. (I have no idea if this
> suggestion
> aligns well with the pqxx design policies).
>
>   pqxx::transaction_monitor txmon.
>
>    txmon.add_connection("conn1", "a connection string for a postgres db");
> // creates new connection
>    txmon.add_connection("conn2", pqxxConnection1); // use existing
> connection
>
>   pqxx::transaction<pqxx::read_committed> tx(txmon, "a_tx_id");
>
>   // do stuff with the connections;
>      tx("conn1").exec("select * from pg_class;");
>
>
>   // a managed transaction does not have begin, commit, rollback methods
>      pqxx::managed_transaction mtx = txmon("conn2");
>      mtx.exec("select 1")'
>
>   // do stuff more stuff
>    ...
>

The following statements are not correct ofcourse:


>
>   tx.prepare();
>   tx.commit();
>
>
They should be replaced by:

   txmon.prepare();
   txmon.commit();

Kind regards,
Maurice
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pgfoundry.org/pipermail/libpqxx-general/attachments/20090820/ed44eeaf/attachment.html>


More information about the Libpqxx-general mailing list