[Libpqxx-general] Liskov Substitution and Transactions

Jeroen Vermeulen jtv at xs4all.nl
Wed Apr 29 13:31:53 UTC 2009


Maurice Gittens wrote:

> Assuming:
>    typedef std::vector<pqxx::transaction_base*> TransactionStack;
>    TransactionStack theTxStack;
> 
> The statement:
>     // theTxStack is not empty
>     theTxStack.push_back(new pqxx::subtransaction(*theTxStack.back(), 
> std::string("")));
> 
> still barfs. It seems a subtransaction takes a dbtransaction as a 
> constructor argument.

That's true; it needs a transaction that's really being bracketed on the 
backend.  Simplest way around is a downcast; transaction_base has a 
vtable so the runtime should still be able to check it.

Or you can use the latest trunk, with ~dbtransaction public, and keep 
dbtransaction pointers after all.


Jeroen


More information about the Libpqxx-general mailing list