2012/1/3 Dmitriy Igrishin <dmit...@gmail.com>
> Hey Koen
>
> You're right. As you observed, we've added a new feature to
>> transaction handling (a hint from Bart Vanhauwaert): to auto-commit
>> transactions when the transaction object destructs if the destruction
>> is not a consequence of an exception being thrown (I was unaware that
>> C++ actually has a function for detecting that:
>> std::uncaught_exception()).
>>
> I think that more correct way to detecting that is to use
> transaction status, returned by the backend. In case of
> Postgres (libpq) its a function PQtransactionStatus().
>
By the way, in PostgreSQL any transaction block may be
closed by COMMIT command -- the transaction is doomed
on ROLLBACK if some command within it cause the error:
dmitigr=> BEGIN;
BEGIN
dmitigr=> SELECT version();
version
----------------------------------------------------------------------------------------------
PostgreSQL 9.1.0 on x86_64-unknown-linux-gnu, compiled by gcc (Debian
4.6.1-4) 4.6.1, 64-bit
(1 row)
dmitigr=> BAD_COMMAND;
ERROR: syntax error at or near "BAD_COMMAND"
LINE 1: BAD_COMMAND;
^
dmitigr=> SELECT version();
ERROR: current transaction is aborted, commands ignored until end of
transaction block
dmitigr=> COMMIT;
ROLLBACK
So, there is no need to perform ROLLBACK explicitly
(in case when the descruction of the transaction object
performed by the stack unwinding).
>
>> The upshot is: you no longer are required to explicitly commit() all
>> your transactions -- this is now the "default" behavior.
>>
>
> Really good idea.
>
>
> --
> // Dmitriy.
>
>
>
--
// Dmitriy.
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest