Re: second "begin transaction" emits a warning - Mailing list pgsql-hackers

From Tom Lane
Subject Re: second "begin transaction" emits a warning
Date
Msg-id 531.1134774690@sss.pgh.pa.us
Whole thread Raw
In response to second "begin transaction" emits a warning  (Jaime Casanova <systemguards@gmail.com>)
List pgsql-hackers
Jaime Casanova <systemguards@gmail.com> writes:
> recently someone show us this code in the spanish list...

>> BEGIN WORK;
>> INSERT INTO mitabla VALUES (1);
>> BEGIN TRANSACTION;
>> INSERT INTO mitabla VALUES (2);
>> INSERT INTO mitabla VALUES (3);
>> COMMIT TRANSACTION;
>> INSERT INTO mitabla VALUES (4);
>> ROLLBACK WORK;

> he was expecting an empty table but instead he gets this:

> so, why BeginTransactionBlock emits just a warning and not an error?

I can't get real excited about this case.  If the second BEGIN had
errored out, he'd *still* not get an empty table: the COMMIT would
end the aborted transaction, then the last INSERT would succeed,
then the ROLLBACK would complain about "no transaction in progress".
Maybe there's an argument for turning the warning into an error,
but this example doesn't provide it.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Treat
Date:
Subject: reducing bloat in pg_statistic
Next
From: Robert Treat
Date:
Subject: Re: second "begin transaction" emits a warning